From 1af1c4593d7bb5b001174fd1c8feb6df00563b63 Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot Date: Sat, 28 Feb 2026 01:02:59 +0000 Subject: [PATCH] Sync build v0.9.291 Automated sync from private repository. Commit: 2d97ba2f920ff7f2f9a06494f10de9de5aa0762b --- frontend/dist/VERSION | 2 +- ...C5X.js => AnalyzerFilterPanel-BIfh-GdY.js} | 6 +- ...BmJRWt4U.js => AnimatedNumber-BAXz0cmM.js} | 4 +- ...r-D5WYHXmJ.js => BasemapLayer-Bm_seLWQ.js} | 4 +- ...ble-0UYYugYB.js => ChatBubble-Bxq40Qnq.js} | 2 +- ....js => CollisionExplorerModal-Cm5c7tcU.js} | 4 +- ...-DbTSQonP.js => Configuration-eqZcR8dI.js} | 2 +- ...l-CNsW1W2q.js => ConfirmModal-B0nTD1Q0.js} | 4 +- frontend/dist/assets/Contacts-CKgzKZ-Z.js | 47 ---- frontend/dist/assets/Contacts-CcwYnw5c.js | 52 ++++ ..._cg.js => ContactsMapMapLibre-7MZRUDIi.js} | 12 +- ...oard-BN8YnIZD.js => Dashboard-Da3hQ53f.js} | 4 +- ...ataBox-W2v3wy8k.js => DataBox-CQS-Zhu0.js} | 2 +- ...7JxOp.js => DeepAnalysisModal-CaP_TRSd.js} | 14 +- .../{Grid-CEGkNRmt.js => Grid-BoZ-SJB7.js} | 2 +- ...n-BJvlGsWZ.js => KeycapButton-CT5jwzf3.js} | 2 +- ...CkL4j4OZ.js => LightSparkline-5OIe9Q0M.js} | 2 +- .../{Login-BAnk0zoo.js => Login-DH5OEqBN.js} | 2 +- .../{Logs-BebUdPuw.js => Logs-COCuHgwW.js} | 4 +- ...raph-TagJOEOk.js => MeshGraph-CElh2Drl.js} | 12 +- ...tr-.js => NodeInformationCard-BLxCCOW5.js} | 2 +- frontend/dist/assets/PacketList-CnGGHFuk.js | 67 +++++ frontend/dist/assets/PacketList-DNy8yTeL.js | 67 ----- .../dist/assets/PacketObservatory-CaTxuw1q.js | 5 + .../dist/assets/PacketObservatory-CcMk90ki.js | 5 - frontend/dist/assets/Packets-CPDPqpOg.js | 1 - frontend/dist/assets/Packets-aeMTl269.js | 1 + ...out-NQBVrM09.js => PageLayout-BIcqC04y.js} | 2 +- .../dist/assets/PathMapMapLibre-ANGN4-cP.js | 6 - .../dist/assets/PathMapMapLibre-CUvyj6hi.js | 6 + ...ver-IEGP0mqy.js => RoomServer-BJlrNokH.js} | 4 +- ...sions-Dynaz1Ws.js => Sessions-BctisK9q.js} | 4 +- ...w_bfp50.js => SignalIndicator-LNOR_5YF.js} | 4 +- ...ics-B1hA6UVh.js => Statistics-BV-givjs.js} | 4 +- ...{System-CWAaClFq.js => System-Dl7BjZT4.js} | 4 +- ...minal-iUtnCprU.js => Terminal-Bs4pn1qU.js} | 26 +- ...C9rlkV.js => TimeRangeStepper-Dh4JEQ42.js} | 2 +- ...ivity-2-g8m4_g.js => activity-Dr_TPIps.js} | 2 +- ...ntenna-DOuH490Q.js => antenna-zVXb9cuG.js} | 2 +- ...ow-up-DbeeGdHO.js => arrow-up-DJuSVUZI.js} | 2 +- ...ils-D1Q4VWjO.js => chat-utils-Di4-nywi.js} | 2 +- ...-DUgYTR6d.js => chevron-right-DqpRZiGf.js} | 2 +- ...k-BOp4wLxA.js => circle-check-CBI-CiRo.js} | 2 +- ...IA.js => circle-question-mark-DC7QfrVK.js} | 2 +- ...P4bcU.js => consumer-registry-DPYvsBcc.js} | 2 +- ...abase-BEyHF_p_.js => database-CDN_R6oC.js} | 2 +- ...VWyZU.js => decryption.worker-CmMB-xKW.js} | 2 +- ...nload-IUkhheKK.js => download-BbqYTv8j.js} | 2 +- ...{easing-CXN4GmUW.js => easing-DSebI9nw.js} | 2 +- ...o83B2Z.js => element-movement-BqZOD4DT.js} | 2 +- ...{funnel-BDRRJl0y.js => funnel-D4Wxq-Fx.js} | 2 +- frontend/dist/assets/geo-utils-BP1zBK9h.js | 1 - .../{hash-BkZp0AKy.js => hash-9uwO8S8N.js} | 2 +- frontend/dist/assets/index-BwGHI0A_.js | 266 ++++++++++++++++++ frontend/dist/assets/index-C8IY8K2r.js | 266 ------------------ .../{index-B-prVW1V.js => index-OH01SZkk.js} | 2 +- ...ound-CQ-pu-yY.js => key-round-DKeM0xKx.js} | 2 +- ...{layers-Oxzfug7f.js => layers-C8ICjJ-w.js} | 2 +- ...g-CX7bMGSJ.js => link-scoring-BSZA-fkH.js} | 2 +- ...istbox-BhQdM5DY.js => listbox-_tsR-2yL.js} | 2 +- ...ap-pin-DMVHq6j8.js => map-pin-VRY_TOuh.js} | 2 +- ...gl-DihO1Cg6.js => maplibre-gl-DJ441a35.js} | 2 +- ...mgOV.js => monitor-smartphone-BxljwdQV.js} | 2 +- ...etwork-DBkquEPb.js => network-9doWJxcL.js} | 2 +- ...pes-3T9Wr7vI.js => node-types-DmTOZWT4.js} | 2 +- .../dist/assets/payload-decoders-7zyi-Y-D.js | 1 + .../dist/assets/payload-decoders-BX6pSxwl.js | 1 - .../{ping-lLlOzF2r.js => ping-DW5e4gor.js} | 2 +- .../{plus-PWV57wbr.js => plus-C0xom_iW.js} | 2 +- frontend/dist/assets/primitives-Ca8Zb5cD.js | 1 - frontend/dist/assets/primitives-Cgn8YJud.js | 1 + ...-cw-BqACEANM.js => refresh-cw-DYpAqCT4.js} | 2 +- ...{search-zALFwCS4.js => search-B7iMjmGm.js} | 2 +- ...s-2-BUdn2-nA.js => settings-2-B_NiASQG.js} | 2 +- ...{shield-DlHwWwz2.js => shield-DOTPcYJ1.js} | 2 +- ...{system-D5HdVkRh.js => system-oD9MKxRy.js} | 2 +- ...{target-DviLCm8U.js => target-LdPtzGwl.js} | 2 +- ...8k00uu7o.js => triangle-alert-B4kC1YDk.js} | 2 +- ...x-BqDpg.js => useMapViewStore-CPURakCb.js} | 4 +- .../dist/assets/usePipelineStore-11oXtutw.js | 2 + .../dist/assets/usePipelineStore-CyFB3GIy.js | 2 - ...F.js => webgl-device-QoBMYpnS-CGfZSI9d.js} | 4 +- .../{wifi-Cq9uCDyf.js => wifi-BaASFkdf.js} | 2 +- frontend/dist/index.html | 2 +- frontend/package.json | 2 +- 85 files changed, 510 insertions(+), 506 deletions(-) rename frontend/dist/assets/{AnalyzerFilterPanel-BPawhC5X.js => AnalyzerFilterPanel-BIfh-GdY.js} (95%) rename frontend/dist/assets/{AnimatedNumber-BmJRWt4U.js => AnimatedNumber-BAXz0cmM.js} (60%) rename frontend/dist/assets/{BasemapLayer-D5WYHXmJ.js => BasemapLayer-Bm_seLWQ.js} (99%) rename frontend/dist/assets/{ChatBubble-0UYYugYB.js => ChatBubble-Bxq40Qnq.js} (93%) rename frontend/dist/assets/{CollisionExplorerModal-DeHgfjGl.js => CollisionExplorerModal-Cm5c7tcU.js} (92%) rename frontend/dist/assets/{Configuration-DbTSQonP.js => Configuration-eqZcR8dI.js} (98%) rename frontend/dist/assets/{ConfirmModal-CNsW1W2q.js => ConfirmModal-B0nTD1Q0.js} (83%) delete mode 100644 frontend/dist/assets/Contacts-CKgzKZ-Z.js create mode 100644 frontend/dist/assets/Contacts-CcwYnw5c.js rename frontend/dist/assets/{ContactsMapMapLibre-CKQy2_cg.js => ContactsMapMapLibre-7MZRUDIi.js} (99%) rename frontend/dist/assets/{Dashboard-BN8YnIZD.js => Dashboard-Da3hQ53f.js} (97%) rename frontend/dist/assets/{DataBox-W2v3wy8k.js => DataBox-CQS-Zhu0.js} (97%) rename frontend/dist/assets/{DeepAnalysisModal-B2m7JxOp.js => DeepAnalysisModal-CaP_TRSd.js} (78%) rename frontend/dist/assets/{Grid-CEGkNRmt.js => Grid-BoZ-SJB7.js} (95%) rename frontend/dist/assets/{KeycapButton-BJvlGsWZ.js => KeycapButton-CT5jwzf3.js} (98%) rename frontend/dist/assets/{LightSparkline-CkL4j4OZ.js => LightSparkline-5OIe9Q0M.js} (96%) rename frontend/dist/assets/{Login-BAnk0zoo.js => Login-DH5OEqBN.js} (99%) rename frontend/dist/assets/{Logs-BebUdPuw.js => Logs-COCuHgwW.js} (63%) rename frontend/dist/assets/{MeshGraph-TagJOEOk.js => MeshGraph-CElh2Drl.js} (98%) rename frontend/dist/assets/{NodeInformationCard-p2ujbtr-.js => NodeInformationCard-BLxCCOW5.js} (90%) create mode 100644 frontend/dist/assets/PacketList-CnGGHFuk.js delete mode 100644 frontend/dist/assets/PacketList-DNy8yTeL.js create mode 100644 frontend/dist/assets/PacketObservatory-CaTxuw1q.js delete mode 100644 frontend/dist/assets/PacketObservatory-CcMk90ki.js delete mode 100644 frontend/dist/assets/Packets-CPDPqpOg.js create mode 100644 frontend/dist/assets/Packets-aeMTl269.js rename frontend/dist/assets/{PageLayout-NQBVrM09.js => PageLayout-BIcqC04y.js} (93%) delete mode 100644 frontend/dist/assets/PathMapMapLibre-ANGN4-cP.js create mode 100644 frontend/dist/assets/PathMapMapLibre-CUvyj6hi.js rename frontend/dist/assets/{RoomServer-IEGP0mqy.js => RoomServer-BJlrNokH.js} (94%) rename frontend/dist/assets/{Sessions-Dynaz1Ws.js => Sessions-BctisK9q.js} (90%) rename frontend/dist/assets/{SignalIndicator-Dw_bfp50.js => SignalIndicator-LNOR_5YF.js} (87%) rename frontend/dist/assets/{Statistics-B1hA6UVh.js => Statistics-BV-givjs.js} (97%) rename frontend/dist/assets/{System-CWAaClFq.js => System-Dl7BjZT4.js} (95%) rename frontend/dist/assets/{Terminal-iUtnCprU.js => Terminal-Bs4pn1qU.js} (99%) rename frontend/dist/assets/{TimeRangeStepper-BlC9rlkV.js => TimeRangeStepper-Dh4JEQ42.js} (95%) rename frontend/dist/assets/{activity-2-g8m4_g.js => activity-Dr_TPIps.js} (89%) rename frontend/dist/assets/{antenna-DOuH490Q.js => antenna-zVXb9cuG.js} (90%) rename frontend/dist/assets/{arrow-up-DbeeGdHO.js => arrow-up-DJuSVUZI.js} (92%) rename frontend/dist/assets/{chat-utils-D1Q4VWjO.js => chat-utils-Di4-nywi.js} (94%) rename frontend/dist/assets/{chevron-right-DUgYTR6d.js => chevron-right-DqpRZiGf.js} (85%) rename frontend/dist/assets/{circle-check-BOp4wLxA.js => circle-check-CBI-CiRo.js} (87%) rename frontend/dist/assets/{circle-question-mark-C7l07_IA.js => circle-question-mark-DC7QfrVK.js} (89%) rename frontend/dist/assets/{consumer-registry-lDKP4bcU.js => consumer-registry-DPYvsBcc.js} (92%) rename frontend/dist/assets/{database-BEyHF_p_.js => database-CDN_R6oC.js} (89%) rename frontend/dist/assets/{decryption.worker-B7tVWyZU.js => decryption.worker-CmMB-xKW.js} (59%) rename frontend/dist/assets/{download-IUkhheKK.js => download-BbqYTv8j.js} (89%) rename frontend/dist/assets/{easing-CXN4GmUW.js => easing-DSebI9nw.js} (90%) rename frontend/dist/assets/{element-movement-D4o83B2Z.js => element-movement-BqZOD4DT.js} (67%) rename frontend/dist/assets/{funnel-BDRRJl0y.js => funnel-D4Wxq-Fx.js} (89%) delete mode 100644 frontend/dist/assets/geo-utils-BP1zBK9h.js rename frontend/dist/assets/{hash-BkZp0AKy.js => hash-9uwO8S8N.js} (90%) create mode 100644 frontend/dist/assets/index-BwGHI0A_.js delete mode 100644 frontend/dist/assets/index-C8IY8K2r.js rename frontend/dist/assets/{index-B-prVW1V.js => index-OH01SZkk.js} (81%) rename frontend/dist/assets/{key-round-CQ-pu-yY.js => key-round-DKeM0xKx.js} (91%) rename frontend/dist/assets/{layers-Oxzfug7f.js => layers-C8ICjJ-w.js} (92%) rename frontend/dist/assets/{link-scoring-CX7bMGSJ.js => link-scoring-BSZA-fkH.js} (78%) rename frontend/dist/assets/{listbox-BhQdM5DY.js => listbox-_tsR-2yL.js} (82%) rename frontend/dist/assets/{map-pin-DMVHq6j8.js => map-pin-VRY_TOuh.js} (99%) rename frontend/dist/assets/{maplibre-gl-DihO1Cg6.js => maplibre-gl-DJ441a35.js} (99%) rename frontend/dist/assets/{monitor-smartphone-DF_mmgOV.js => monitor-smartphone-BxljwdQV.js} (91%) rename frontend/dist/assets/{network-DBkquEPb.js => network-9doWJxcL.js} (92%) rename frontend/dist/assets/{node-types-3T9Wr7vI.js => node-types-DmTOZWT4.js} (95%) create mode 100644 frontend/dist/assets/payload-decoders-7zyi-Y-D.js delete mode 100644 frontend/dist/assets/payload-decoders-BX6pSxwl.js rename frontend/dist/assets/{ping-lLlOzF2r.js => ping-DW5e4gor.js} (94%) rename frontend/dist/assets/{plus-PWV57wbr.js => plus-C0xom_iW.js} (86%) delete mode 100644 frontend/dist/assets/primitives-Ca8Zb5cD.js create mode 100644 frontend/dist/assets/primitives-Cgn8YJud.js rename frontend/dist/assets/{refresh-cw-BqACEANM.js => refresh-cw-DYpAqCT4.js} (91%) rename frontend/dist/assets/{search-zALFwCS4.js => search-B7iMjmGm.js} (87%) rename frontend/dist/assets/{settings-2-BUdn2-nA.js => settings-2-B_NiASQG.js} (89%) rename frontend/dist/assets/{shield-DlHwWwz2.js => shield-DOTPcYJ1.js} (90%) rename frontend/dist/assets/{system-D5HdVkRh.js => system-oD9MKxRy.js} (91%) rename frontend/dist/assets/{target-DviLCm8U.js => target-LdPtzGwl.js} (94%) rename frontend/dist/assets/{triangle-alert-8k00uu7o.js => triangle-alert-B4kC1YDk.js} (89%) rename frontend/dist/assets/{useMapViewStore-ax-BqDpg.js => useMapViewStore-CPURakCb.js} (93%) create mode 100644 frontend/dist/assets/usePipelineStore-11oXtutw.js delete mode 100644 frontend/dist/assets/usePipelineStore-CyFB3GIy.js rename frontend/dist/assets/{webgl-device-QoBMYpnS-BzCsS41F.js => webgl-device-QoBMYpnS-CGfZSI9d.js} (53%) rename frontend/dist/assets/{wifi-Cq9uCDyf.js => wifi-BaASFkdf.js} (90%) diff --git a/frontend/dist/VERSION b/frontend/dist/VERSION index 2f8e85f7..eb39ffb7 100644 --- a/frontend/dist/VERSION +++ b/frontend/dist/VERSION @@ -1 +1 @@ -0.9.290 +0.9.291 diff --git a/frontend/dist/assets/AnalyzerFilterPanel-BPawhC5X.js b/frontend/dist/assets/AnalyzerFilterPanel-BIfh-GdY.js similarity index 95% rename from frontend/dist/assets/AnalyzerFilterPanel-BPawhC5X.js rename to frontend/dist/assets/AnalyzerFilterPanel-BIfh-GdY.js index 883f908d..80a268b7 100644 --- a/frontend/dist/assets/AnalyzerFilterPanel-BPawhC5X.js +++ b/frontend/dist/assets/AnalyzerFilterPanel-BIfh-GdY.js @@ -1,4 +1,4 @@ -import{d as U,$ as J,r as u,j as n,bc as K,R as q,bL as G,B as Q}from"./index-C8IY8K2r.js";import{c as V}from"./node-types-3T9Wr7vI.js";import{F as Y}from"./funnel-BDRRJl0y.js";import{M as Z}from"./monitor-smartphone-DF_mmgOV.js";import{C as W}from"./circle-question-mark-C7l07_IA.js";import{S as ee}from"./search-zALFwCS4.js";/** +import{d as U,$ as J,r as u,j as n,bc as K,R as q,bO as G,B as Q}from"./index-BwGHI0A_.js";import{c as V}from"./node-types-DmTOZWT4.js";import{F as Y}from"./funnel-D4Wxq-Fx.js";import{M as Z}from"./monitor-smartphone-BxljwdQV.js";import{C as W}from"./circle-question-mark-DC7QfrVK.js";import{S as ee}from"./search-B7iMjmGm.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -8,7 +8,7 @@ import{d as U,$ as J,r as u,j as n,bc as K,R as q,bL as G,B as Q}from"./index-C8 * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const ne=[["path",{d:"M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z",key:"1ptgy4"}],["path",{d:"M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97",key:"1sl1rz"}]],oe=U("droplets",ne);function xe(){return{timeStart:null,timeEnd:null,deviceTypes:new Set,nodeIds:new Set,disabledNodeIds:new Set,nodeFilterMode:"source"}}function re(d,l){const{timeStart:c,timeEnd:t,deviceTypes:o,nodeIds:x,disabledNodeIds:v,nodeFilterMode:w}=d,m=c!==null||t!==null,N=o.size>0;let h;if(v.size>0){h=new Set;for(const j of x)v.has(j)||h.add(j)}else h=x;const S=h.size>0;let k=null;if(S){k=new Set;for(const j of h)k.add(J(j))}return{hasTime:m,hasDevice:N,hasNode:S,tStart:c??l.start,tEnd:t??l.end,deviceTypes:o,effectiveNodeIds:h,nodeIdPrefixes:k,nodeFilterMode:w,needsDisambiguation:N||S}}function ae(d,l,c){if(l.hasTime&&(d.timestampl.tEnd))return!1;if(l.needsDisambiguation){const t=c(d);if(l.hasDevice&&!l.deviceTypes.has(t.type))return!1;if(l.hasNode){if(l.nodeFilterMode==="observed"){let o=!1;if(t.hash&&l.effectiveNodeIds.has(t.hash)&&(o=!0),!o&&d.dst_hash&&(l.effectiveNodeIds.has(d.dst_hash)||l.nodeIdPrefixes.has(J(d.dst_hash)))&&(o=!0),!o){const x=d.forwarded_path??d.original_path;if(x&&Array.isArray(x))for(const v of x){const w=String(v).toUpperCase();if(l.nodeIdPrefixes.has(w)){o=!0;break}}}if(!o)return!1}else if(!t.hash||!l.effectiveNodeIds.has(t.hash))return!1}}return!0}function he(d,l,c,t){const o=re(l,t);return!o.hasTime&&!o.hasDevice&&!o.hasNode?d:d.filter(x=>ae(x,o,c))}function X(d,l){const c=new Date(d*1e3),t=v=>v.toString().padStart(2,"0"),o=`${t(c.getHours())}:${t(c.getMinutes())}`;return l<24?o:`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][c.getMonth()]} ${c.getDate()} ${o}`}const le=[{type:"repeater",label:"Repeater",icon:q,buttonColor:"primary",iconColor:"text-sys-blue",hoverClass:"hover:border-sys-blue hover:text-sys-blue hover:!bg-transparent"},{type:"companion",label:"Companion",icon:Z,buttonColor:"indigo",iconColor:"text-sys-indigo",hoverClass:"hover:border-sys-indigo hover:text-sys-indigo hover:!bg-transparent"},{type:"room_server",label:"Room",icon:G,buttonColor:"purple",iconColor:"text-sys-purple",hoverClass:"hover:border-sys-purple hover:text-sys-purple hover:!bg-transparent"},{type:"unknown",label:"Unknown",icon:W,buttonColor:"zinc",iconColor:"text-zinc-400",hoverClass:"hover:border-zinc-400 hover:text-zinc-400 hover:!bg-transparent"}],D=60,E=.005;function ie({min:d,max:l,valueStart:c,valueEnd:t,onChange:o}){const x=u.useRef(null),[v,w]=u.useState(null),m=u.useRef({valueStart:c,valueEnd:t,min:d,max:l});m.current={valueStart:c,valueEnd:t,min:d,max:l};const N=u.useRef({offset:0,width:0}),h=l-d||1,S=h/3600,k=c??d,j=t??l,C=(k-d)/h*100,F=(j-d)/h*100,_=c!==null||t!==null,I=u.useCallback(i=>{const a=x.current.getBoundingClientRect(),e=Math.max(0,Math.min(1,(i-a.left)/a.width)),{min:s,max:r}=m.current;return Math.round(s+e*(r-s||1))},[]),T=u.useCallback((i,a)=>{a.preventDefault(),a.stopPropagation();const e=a.currentTarget;e.setPointerCapture(a.pointerId),w(i);const s=f=>{const g=I(f.clientX),{valueStart:y,valueEnd:b,min:p,max:L}=m.current,z=L-p||1;if(i==="start"){const M=Math.min(g,(b??L)-D);o(M<=p+z*E?null:M,b)}else{const M=Math.max(g,(y??p)+D);o(y,M>=L-z*E?null:M)}},r=()=>{w(null),e.removeEventListener("pointermove",s),e.removeEventListener("pointerup",r),e.removeEventListener("pointercancel",r)};e.addEventListener("pointermove",s),e.addEventListener("pointerup",r),e.addEventListener("pointercancel",r)},[I,o]),$=u.useCallback(i=>{i.preventDefault(),i.stopPropagation();const a=i.currentTarget;a.setPointerCapture(i.pointerId),w("range");const e=m.current.valueStart??m.current.min,s=m.current.valueEnd??m.current.max;N.current={offset:I(i.clientX)-e,width:s-e};const r=g=>{const y=I(g.clientX),{min:b,max:p}=m.current,{offset:L,width:z}=N.current;let M=y-L;M=Math.max(b,Math.min(p-z,M));const O=M+z;o(Math.round(M)<=b?null:Math.round(M),Math.round(O)>=p?null:Math.round(O))},f=()=>{w(null),a.removeEventListener("pointermove",r),a.removeEventListener("pointerup",f),a.removeEventListener("pointercancel",f)};a.addEventListener("pointermove",r),a.addEventListener("pointerup",f),a.addEventListener("pointercancel",f)},[I,o]),H=u.useCallback(i=>{const a=I(i.clientX),{valueStart:e,valueEnd:s,min:r,max:f}=m.current,g=f-r||1,y=e??r,b=s??f;if(Math.abs(a-y)<=Math.abs(a-b)){const p=Math.min(a,b-D);o(p<=r+g*E?null:p,s)}else{const p=Math.max(a,y+D);o(e,p>=f-g*E?null:p)}},[I,o]),R=u.useCallback(()=>o(null,null),[o]),A=u.useCallback((i,a)=>{const e=a.key==="ArrowRight"||a.key==="ArrowUp"?1:a.key==="ArrowLeft"||a.key==="ArrowDown"?-1:0;if(!e)return;a.preventDefault();const s=(a.shiftKey?.1:.01)*h,{valueStart:r,valueEnd:f,min:g,max:y}=m.current,b=y-g||1;if(i==="start"){const p=Math.max(g,Math.min((r??g)+e*s,(f??y)-D));o(p<=g+b*E?null:p,f)}else{const p=Math.min(y,Math.max((f??y)+e*s,(r??g)+D));o(r,p>=y-b*E?null:p)}},[h,o]),P=i=>{const a=i==="start"?c!==null:t!==null,e=v===i;return["absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-1 h-4 rounded-full","before:content-[''] before:absolute before:-inset-x-3 before:-inset-y-1","touch-none outline-none",e?"cursor-grabbing":"cursor-ew-resize",e?"bg-sys-blue shadow-[0_0_8px_var(--sys-blue)] scale-x-150 z-20":a?"bg-sys-blue shadow-[0_0_4px_var(--sys-blue)] hover:shadow-[0_0_8px_var(--sys-blue)] hover:scale-x-150 z-10":"bg-edge-subtle hover:bg-fg-muted hover:scale-x-150 z-10",e?"":"transition-[transform,box-shadow,background-color] duration-150 ease-out","focus-visible:ring-2 focus-visible:ring-sys-blue/50"].filter(Boolean).join(" ")};return n.jsxs("div",{className:"flex flex-col gap-0.5 min-w-[160px] sm:min-w-[220px]",children:[n.jsxs("div",{className:"flex items-center justify-between type-data-xs text-fg-muted tabular-nums select-none",children:[n.jsx("span",{className:_&&c!==null?"text-sys-blue":"",children:X(k,S)}),n.jsx("span",{className:_&&t!==null?"text-sys-blue":"",children:X(j,S)})]}),n.jsxs("div",{ref:x,className:"relative h-5 select-none",onPointerDown:H,onDoubleClick:R,children:[n.jsx("div",{className:"absolute inset-x-0 top-1/2 -translate-y-1/2 h-1.5 rounded-full bg-white/[0.06] pointer-events-none"}),_?n.jsx("div",{className:["group/band absolute inset-y-0 touch-none",v==="range"?"cursor-grabbing":"cursor-grab"].join(" "),style:{left:`${C}%`,right:`${100-F}%`},onPointerDown:$,children:n.jsx("div",{className:["absolute inset-x-0 top-1/2 -translate-y-1/2 h-1.5 rounded-full pointer-events-none transition-colors",v==="range"?"bg-sys-blue/40":"bg-sys-blue/25 group-hover/band:bg-sys-blue/35"].join(" ")})}):n.jsx("div",{className:"absolute inset-x-0 top-1/2 -translate-y-1/2 h-1.5 rounded-full bg-white/[0.04] pointer-events-none"}),n.jsx("div",{role:"slider",tabIndex:0,"aria-label":"Range start","aria-valuenow":k,className:P("start"),style:{left:`${C}%`},onPointerDown:i=>T("start",i),onKeyDown:i=>A("start",i)}),n.jsx("div",{role:"slider",tabIndex:0,"aria-label":"Range end","aria-valuenow":j,className:P("end"),style:{left:`${F}%`},onPointerDown:i=>T("end",i),onKeyDown:i=>A("end",i)})]})]})}function fe({parentStartTs:d,parentEndTs:l,neighbors:c,filter:t,onChange:o,scatterDotSize:x,onScatterDotSizeChange:v,scatterOpacity:w,onScatterOpacityChange:m}){const[N,h]=u.useState(""),[S,k]=u.useState(!1),j=u.useRef(null);u.useEffect(()=>{function e(s){j.current&&!j.current.contains(s.target)&&k(!1)}if(S)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[S]);const C=u.useMemo(()=>Object.entries(c).map(([e,s])=>{const r=V(s);return{hash:e,name:s.name??s.node_name??e.slice(0,8),type:r.type,label:r.label}}).sort((e,s)=>e.name.localeCompare(s.name)),[c]),F=u.useMemo(()=>{if(!N)return C;const e=N.toLowerCase();return C.filter(s=>s.name.toLowerCase().includes(e)||s.hash.toLowerCase().includes(e))},[C,N]),_=t.timeStart!==null||t.timeEnd!==null||t.deviceTypes.size>0||t.nodeIds.size>0,I=u.useCallback((e,s)=>{o({...t,timeStart:e,timeEnd:s})},[t,o]),T=u.useCallback(e=>{const s=new Set(t.deviceTypes);s.has(e)?s.delete(e):s.add(e),o({...t,deviceTypes:s})},[t,o]),$=u.useCallback(e=>{const s=new Set(t.nodeIds);s.has(e)?s.delete(e):s.add(e),o({...t,nodeIds:s}),h("")},[t,o]),H=u.useCallback(e=>{const s=new Set(t.nodeIds);s.delete(e);const r=new Set(t.disabledNodeIds);r.delete(e),o({...t,nodeIds:s,disabledNodeIds:r})},[t,o]),R=u.useCallback(e=>{const s=new Set(t.disabledNodeIds);s.has(e)?s.delete(e):s.add(e),o({...t,disabledNodeIds:s})},[t,o]),A=u.useCallback(()=>{o({...t,nodeFilterMode:t.nodeFilterMode==="source"?"observed":"source"})},[t,o]),P=u.useCallback(()=>{o({timeStart:null,timeEnd:null,deviceTypes:new Set,nodeIds:new Set,disabledNodeIds:new Set,nodeFilterMode:"source"}),h("")},[o]),i=u.useMemo(()=>{const e=new Map;for(const s of t.nodeIds){const r=c[s];e.set(s,(r==null?void 0:r.name)??(r==null?void 0:r.node_name)??s.slice(0,8))}return e},[t.nodeIds,c]),a=!!(v&&m);return n.jsxs("div",{className:"flex flex-col gap-2 card-padding",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[a&&n.jsxs(n.Fragment,{children:[n.jsx(B,{icon:n.jsx(se,{className:"w-3 h-3"}),label:"Size",value:x??.8,onChange:v,min:.3,max:3,step:.1,format:e=>e.toFixed(1)}),n.jsx(B,{icon:n.jsx(oe,{className:"w-3 h-3"}),label:"Opacity",value:w??50,onChange:m,min:5,max:100,step:5,format:e=>`${Math.round(e)}%`}),n.jsx("div",{className:"w-px h-4 bg-edge-subtle shrink-0 hidden sm:block"})]}),n.jsx("div",{className:"flex items-center gap-1.5 text-fg-muted shrink-0",children:n.jsx(Y,{className:"w-3.5 h-3.5"})}),n.jsx("div",{className:"flex-1 min-w-[120px]",children:n.jsx(ie,{min:d,max:l,valueStart:t.timeStart,valueEnd:t.timeEnd,onChange:I})}),_&&n.jsxs("button",{type:"button",onClick:P,className:"flex items-center gap-1 px-2 py-0.5 rounded-full type-data-xs text-fg-muted hover:text-fg-primary border border-edge-subtle hover:border-fg-muted/40 transition-colors shrink-0",title:"Clear all filters",children:[n.jsx(K,{className:"w-3 h-3"}),n.jsx("span",{className:"hidden sm:inline",children:"Clear"})]})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("div",{className:"flex items-center gap-1.5 overflow-x-auto pb-0.5 -mb-0.5 shrink-0",children:le.map(({type:e,label:s,icon:r,buttonColor:f,iconColor:g,hoverClass:y})=>{const b=t.deviceTypes.has(e);return n.jsxs(Q,{color:b?f:"zinc",outline:!b,className:`!h-8 !py-0 ${b?"":y}`,onClick:()=>T(e),title:`Filter by ${s}`,children:[n.jsx(r,{"data-slot":"icon",className:b?"":g}),n.jsx("span",{className:`hidden sm:inline ${b?"":"text-fg-muted"}`,children:s})]},e)})}),n.jsx("div",{className:"w-px h-4 bg-edge-subtle shrink-0 hidden md:block"}),n.jsxs("div",{className:"relative flex items-center gap-1.5 flex-1 min-w-[120px] sm:min-w-[180px] h-8 px-2 rounded-md border border-edge-subtle bg-white/[0.03] transition-colors focus-within:border-sys-blue",ref:j,children:[n.jsx(ee,{className:"w-3 h-3 text-fg-muted/50 shrink-0"}),n.jsx("input",{type:"text",className:"flex-1 min-w-[60px] type-data-xs py-0.5 bg-transparent text-fg-secondary placeholder:text-fg-muted/40 border-none focus:outline-none",placeholder:"Search nodes...",value:N,onChange:e=>{h(e.target.value),k(!0)},onFocus:()=>k(!0)}),S&&F.length>0&&n.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 z-[200] surface-popover border border-edge-subtle radius-inner max-h-48 overflow-y-auto",children:F.slice(0,20).map(e=>{const s=t.nodeIds.has(e.hash);return n.jsxs("button",{type:"button",onClick:()=>$(e.hash),className:` + */const ne=[["path",{d:"M7 16.3c2.2 0 4-1.83 4-4.05 0-1.16-.57-2.26-1.71-3.19S7.29 6.75 7 5.3c-.29 1.45-1.14 2.84-2.29 3.76S3 11.1 3 12.25c0 2.22 1.8 4.05 4 4.05z",key:"1ptgy4"}],["path",{d:"M12.56 6.6A10.97 10.97 0 0 0 14 3.02c.5 2.5 2 4.9 4 6.5s3 3.5 3 5.5a6.98 6.98 0 0 1-11.91 4.97",key:"1sl1rz"}]],oe=U("droplets",ne);function xe(){return{timeStart:null,timeEnd:null,deviceTypes:new Set,nodeIds:new Set,disabledNodeIds:new Set,nodeFilterMode:"source"}}function re(d,l){const{timeStart:c,timeEnd:t,deviceTypes:o,nodeIds:x,disabledNodeIds:v,nodeFilterMode:w}=d,m=c!==null||t!==null,N=o.size>0;let h;if(v.size>0){h=new Set;for(const j of x)v.has(j)||h.add(j)}else h=x;const S=h.size>0;let k=null;if(S){k=new Set;for(const j of h)k.add(J(j))}return{hasTime:m,hasDevice:N,hasNode:S,tStart:c??l.start,tEnd:t??l.end,deviceTypes:o,effectiveNodeIds:h,nodeIdPrefixes:k,nodeFilterMode:w,needsDisambiguation:N||S}}function ae(d,l,c){if(l.hasTime&&(d.timestampl.tEnd))return!1;if(l.needsDisambiguation){const t=c(d);if(l.hasDevice&&!l.deviceTypes.has(t.type))return!1;if(l.hasNode){if(l.nodeFilterMode==="observed"){let o=!1;if(t.hash&&l.effectiveNodeIds.has(t.hash)&&(o=!0),!o&&d.dst_hash&&(l.effectiveNodeIds.has(d.dst_hash)||l.nodeIdPrefixes.has(J(d.dst_hash)))&&(o=!0),!o){const x=d.forwarded_path??d.original_path;if(x&&Array.isArray(x))for(const v of x){const w=String(v).toUpperCase();if(l.nodeIdPrefixes.has(w)){o=!0;break}}}if(!o)return!1}else if(!t.hash||!l.effectiveNodeIds.has(t.hash))return!1}}return!0}function he(d,l,c,t){const o=re(l,t);return!o.hasTime&&!o.hasDevice&&!o.hasNode?d:d.filter(x=>ae(x,o,c))}function X(d,l){const c=new Date(d*1e3),t=v=>v.toString().padStart(2,"0"),o=`${t(c.getHours())}:${t(c.getMinutes())}`;return l<24?o:`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][c.getMonth()]} ${c.getDate()} ${o}`}const le=[{type:"repeater",label:"Repeater",icon:q,buttonColor:"primary",iconColor:"text-sys-blue",hoverClass:"hover:border-sys-blue hover:text-sys-blue hover:!bg-transparent"},{type:"companion",label:"Companion",icon:Z,buttonColor:"indigo",iconColor:"text-sys-indigo",hoverClass:"hover:border-sys-indigo hover:text-sys-indigo hover:!bg-transparent"},{type:"room_server",label:"Room",icon:G,buttonColor:"purple",iconColor:"text-sys-purple",hoverClass:"hover:border-sys-purple hover:text-sys-purple hover:!bg-transparent"},{type:"unknown",label:"Unknown",icon:W,buttonColor:"zinc",iconColor:"text-zinc-400",hoverClass:"hover:border-zinc-400 hover:text-zinc-400 hover:!bg-transparent"}],D=60,E=.005;function ie({min:d,max:l,valueStart:c,valueEnd:t,onChange:o}){const x=u.useRef(null),[v,w]=u.useState(null),m=u.useRef({valueStart:c,valueEnd:t,min:d,max:l});m.current={valueStart:c,valueEnd:t,min:d,max:l};const N=u.useRef({offset:0,width:0}),h=l-d||1,S=h/3600,k=c??d,j=t??l,C=(k-d)/h*100,F=(j-d)/h*100,_=c!==null||t!==null,I=u.useCallback(i=>{const a=x.current.getBoundingClientRect(),e=Math.max(0,Math.min(1,(i-a.left)/a.width)),{min:s,max:r}=m.current;return Math.round(s+e*(r-s||1))},[]),T=u.useCallback((i,a)=>{a.preventDefault(),a.stopPropagation();const e=a.currentTarget;e.setPointerCapture(a.pointerId),w(i);const s=f=>{const g=I(f.clientX),{valueStart:y,valueEnd:b,min:p,max:L}=m.current,z=L-p||1;if(i==="start"){const M=Math.min(g,(b??L)-D);o(M<=p+z*E?null:M,b)}else{const M=Math.max(g,(y??p)+D);o(y,M>=L-z*E?null:M)}},r=()=>{w(null),e.removeEventListener("pointermove",s),e.removeEventListener("pointerup",r),e.removeEventListener("pointercancel",r)};e.addEventListener("pointermove",s),e.addEventListener("pointerup",r),e.addEventListener("pointercancel",r)},[I,o]),$=u.useCallback(i=>{i.preventDefault(),i.stopPropagation();const a=i.currentTarget;a.setPointerCapture(i.pointerId),w("range");const e=m.current.valueStart??m.current.min,s=m.current.valueEnd??m.current.max;N.current={offset:I(i.clientX)-e,width:s-e};const r=g=>{const y=I(g.clientX),{min:b,max:p}=m.current,{offset:L,width:z}=N.current;let M=y-L;M=Math.max(b,Math.min(p-z,M));const H=M+z;o(Math.round(M)<=b?null:Math.round(M),Math.round(H)>=p?null:Math.round(H))},f=()=>{w(null),a.removeEventListener("pointermove",r),a.removeEventListener("pointerup",f),a.removeEventListener("pointercancel",f)};a.addEventListener("pointermove",r),a.addEventListener("pointerup",f),a.addEventListener("pointercancel",f)},[I,o]),O=u.useCallback(i=>{const a=I(i.clientX),{valueStart:e,valueEnd:s,min:r,max:f}=m.current,g=f-r||1,y=e??r,b=s??f;if(Math.abs(a-y)<=Math.abs(a-b)){const p=Math.min(a,b-D);o(p<=r+g*E?null:p,s)}else{const p=Math.max(a,y+D);o(e,p>=f-g*E?null:p)}},[I,o]),R=u.useCallback(()=>o(null,null),[o]),A=u.useCallback((i,a)=>{const e=a.key==="ArrowRight"||a.key==="ArrowUp"?1:a.key==="ArrowLeft"||a.key==="ArrowDown"?-1:0;if(!e)return;a.preventDefault();const s=(a.shiftKey?.1:.01)*h,{valueStart:r,valueEnd:f,min:g,max:y}=m.current,b=y-g||1;if(i==="start"){const p=Math.max(g,Math.min((r??g)+e*s,(f??y)-D));o(p<=g+b*E?null:p,f)}else{const p=Math.min(y,Math.max((f??y)+e*s,(r??g)+D));o(r,p>=y-b*E?null:p)}},[h,o]),P=i=>{const a=i==="start"?c!==null:t!==null,e=v===i;return["absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-1 h-4 rounded-full","before:content-[''] before:absolute before:-inset-x-3 before:-inset-y-1","touch-none outline-none",e?"cursor-grabbing":"cursor-ew-resize",e?"bg-sys-blue shadow-[0_0_8px_var(--sys-blue)] scale-x-150 z-20":a?"bg-sys-blue shadow-[0_0_4px_var(--sys-blue)] hover:shadow-[0_0_8px_var(--sys-blue)] hover:scale-x-150 z-10":"bg-edge-subtle hover:bg-fg-muted hover:scale-x-150 z-10",e?"":"transition-[transform,box-shadow,background-color] duration-150 ease-out","focus-visible:ring-2 focus-visible:ring-sys-blue/50"].filter(Boolean).join(" ")};return n.jsxs("div",{className:"flex flex-col gap-0.5 min-w-[160px] sm:min-w-[220px]",children:[n.jsxs("div",{className:"flex items-center justify-between type-data-xs text-fg-muted tabular-nums select-none",children:[n.jsx("span",{className:_&&c!==null?"text-sys-blue":"",children:X(k,S)}),n.jsx("span",{className:_&&t!==null?"text-sys-blue":"",children:X(j,S)})]}),n.jsxs("div",{ref:x,className:"relative h-5 select-none",onPointerDown:O,onDoubleClick:R,children:[n.jsx("div",{className:"absolute inset-x-0 top-1/2 -translate-y-1/2 h-1.5 rounded-full bg-white/[0.06] pointer-events-none"}),_?n.jsx("div",{className:["group/band absolute inset-y-0 touch-none",v==="range"?"cursor-grabbing":"cursor-grab"].join(" "),style:{left:`${C}%`,right:`${100-F}%`},onPointerDown:$,children:n.jsx("div",{className:["absolute inset-x-0 top-1/2 -translate-y-1/2 h-1.5 rounded-full pointer-events-none transition-colors",v==="range"?"bg-sys-blue/40":"bg-sys-blue/25 group-hover/band:bg-sys-blue/35"].join(" ")})}):n.jsx("div",{className:"absolute inset-x-0 top-1/2 -translate-y-1/2 h-1.5 rounded-full bg-white/[0.04] pointer-events-none"}),n.jsx("div",{role:"slider",tabIndex:0,"aria-label":"Range start","aria-valuenow":k,className:P("start"),style:{left:`${C}%`},onPointerDown:i=>T("start",i),onKeyDown:i=>A("start",i)}),n.jsx("div",{role:"slider",tabIndex:0,"aria-label":"Range end","aria-valuenow":j,className:P("end"),style:{left:`${F}%`},onPointerDown:i=>T("end",i),onKeyDown:i=>A("end",i)})]})]})}function fe({parentStartTs:d,parentEndTs:l,neighbors:c,filter:t,onChange:o,scatterDotSize:x,onScatterDotSizeChange:v,scatterOpacity:w,onScatterOpacityChange:m}){const[N,h]=u.useState(""),[S,k]=u.useState(!1),j=u.useRef(null);u.useEffect(()=>{function e(s){j.current&&!j.current.contains(s.target)&&k(!1)}if(S)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[S]);const C=u.useMemo(()=>Object.entries(c).map(([e,s])=>{const r=V(s);return{hash:e,name:s.name??s.node_name??e.slice(0,8),type:r.type,label:r.label}}).sort((e,s)=>e.name.localeCompare(s.name)),[c]),F=u.useMemo(()=>{if(!N)return C;const e=N.toLowerCase();return C.filter(s=>s.name.toLowerCase().includes(e)||s.hash.toLowerCase().includes(e))},[C,N]),_=t.timeStart!==null||t.timeEnd!==null||t.deviceTypes.size>0||t.nodeIds.size>0,I=u.useCallback((e,s)=>{o({...t,timeStart:e,timeEnd:s})},[t,o]),T=u.useCallback(e=>{const s=new Set(t.deviceTypes);s.has(e)?s.delete(e):s.add(e),o({...t,deviceTypes:s})},[t,o]),$=u.useCallback(e=>{const s=new Set(t.nodeIds);s.has(e)?s.delete(e):s.add(e),o({...t,nodeIds:s}),h("")},[t,o]),O=u.useCallback(e=>{const s=new Set(t.nodeIds);s.delete(e);const r=new Set(t.disabledNodeIds);r.delete(e),o({...t,nodeIds:s,disabledNodeIds:r})},[t,o]),R=u.useCallback(e=>{const s=new Set(t.disabledNodeIds);s.has(e)?s.delete(e):s.add(e),o({...t,disabledNodeIds:s})},[t,o]),A=u.useCallback(()=>{o({...t,nodeFilterMode:t.nodeFilterMode==="source"?"observed":"source"})},[t,o]),P=u.useCallback(()=>{o({timeStart:null,timeEnd:null,deviceTypes:new Set,nodeIds:new Set,disabledNodeIds:new Set,nodeFilterMode:"source"}),h("")},[o]),i=u.useMemo(()=>{const e=new Map;for(const s of t.nodeIds){const r=c[s];e.set(s,(r==null?void 0:r.name)??(r==null?void 0:r.node_name)??s.slice(0,8))}return e},[t.nodeIds,c]),a=!!(v&&m);return n.jsxs("div",{className:"flex flex-col gap-2 card-padding",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[a&&n.jsxs(n.Fragment,{children:[n.jsx(B,{icon:n.jsx(se,{className:"w-3 h-3"}),label:"Size",value:x??.8,onChange:v,min:.3,max:3,step:.1,format:e=>e.toFixed(1)}),n.jsx(B,{icon:n.jsx(oe,{className:"w-3 h-3"}),label:"Opacity",value:w??50,onChange:m,min:5,max:100,step:5,format:e=>`${Math.round(e)}%`}),n.jsx("div",{className:"w-px h-4 bg-edge-subtle shrink-0 hidden sm:block"})]}),n.jsx("div",{className:"flex items-center gap-1.5 text-fg-muted shrink-0",children:n.jsx(Y,{className:"w-3.5 h-3.5"})}),n.jsx("div",{className:"flex-1 min-w-[120px]",children:n.jsx(ie,{min:d,max:l,valueStart:t.timeStart,valueEnd:t.timeEnd,onChange:I})}),_&&n.jsxs("button",{type:"button",onClick:P,className:"flex items-center gap-1 px-2 py-0.5 rounded-full type-data-xs text-fg-muted hover:text-fg-primary border border-edge-subtle hover:border-fg-muted/40 transition-colors shrink-0",title:"Clear all filters",children:[n.jsx(K,{className:"w-3 h-3"}),n.jsx("span",{className:"hidden sm:inline",children:"Clear"})]})]}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsx("div",{className:"flex items-center gap-1.5 overflow-x-auto pb-0.5 -mb-0.5 shrink-0",children:le.map(({type:e,label:s,icon:r,buttonColor:f,iconColor:g,hoverClass:y})=>{const b=t.deviceTypes.has(e);return n.jsxs(Q,{color:b?f:"zinc",outline:!b,className:`!h-8 !py-0 ${b?"":y}`,onClick:()=>T(e),title:`Filter by ${s}`,children:[n.jsx(r,{"data-slot":"icon",className:b?"":g}),n.jsx("span",{className:`hidden sm:inline ${b?"":"text-fg-muted"}`,children:s})]},e)})}),n.jsx("div",{className:"w-px h-4 bg-edge-subtle shrink-0 hidden md:block"}),n.jsxs("div",{className:"relative flex items-center gap-1.5 flex-1 min-w-[120px] sm:min-w-[180px] h-8 px-2 rounded-md border border-edge-subtle bg-white/[0.03] transition-colors focus-within:border-sys-blue",ref:j,children:[n.jsx(ee,{className:"w-3 h-3 text-fg-muted/50 shrink-0"}),n.jsx("input",{type:"text",className:"flex-1 min-w-[60px] type-data-xs py-0.5 bg-transparent text-fg-secondary placeholder:text-fg-muted/40 border-none focus:outline-none",placeholder:"Search nodes...",value:N,onChange:e=>{h(e.target.value),k(!0)},onFocus:()=>k(!0)}),S&&F.length>0&&n.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 z-[200] surface-popover border border-edge-subtle radius-inner max-h-48 overflow-y-auto",children:F.slice(0,20).map(e=>{const s=t.nodeIds.has(e.hash);return n.jsxs("button",{type:"button",onClick:()=>$(e.hash),className:` w-full flex items-center gap-2 px-2.5 py-1.5 type-data-xs text-left transition-colors ${s?"bg-sys-indigo/15 text-sys-indigo":"text-fg-secondary hover:bg-subtle-fill"} - `,children:[n.jsx("span",{className:"flex-1 truncate",children:e.name}),n.jsx("span",{className:"text-fg-muted type-data-xs shrink-0",children:e.label})]},e.hash)})})]})]}),t.nodeIds.size>0&&n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[Array.from(t.nodeIds).map(e=>{const s=t.disabledNodeIds.has(e);return n.jsxs("span",{role:"button",tabIndex:0,onClick:()=>R(e),onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),R(e))},className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full type-data-xs border transition-colors select-none ${s?"bg-zinc-500/10 text-fg-muted border-edge-subtle cursor-pointer hover:bg-zinc-500/15":"bg-sys-indigo/15 text-sys-indigo border-sys-indigo/25 cursor-pointer hover:bg-sys-indigo/25"}`,title:e,children:[i.get(e)??e.slice(0,8),n.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),H(e)},className:"hover:text-fg-primary transition-colors -mr-0.5",title:"Remove from filter",children:n.jsx(K,{className:"w-3 h-3"})})]},e)}),n.jsx("button",{type:"button",onClick:A,className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full type-data-xs border transition-colors ${t.nodeFilterMode==="observed"?"bg-sys-blue/15 text-sys-blue border-sys-blue/25 hover:bg-sys-blue/25":"bg-white/[0.04] text-fg-muted border-edge-subtle hover:text-fg-secondary hover:border-fg-muted/40"}`,title:t.nodeFilterMode==="source"?"Source Only — showing packets sent by selected node(s)":"Total Observed — showing all packets where selected node(s) appear (source, path, or destination)",children:t.nodeFilterMode==="source"?"Source Only":"Total Observed"})]})]})}const B=u.memo(function({icon:l,label:c,value:t,onChange:o,min:x,max:v,step:w,format:m}){return n.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[n.jsxs("div",{className:"flex items-center gap-1.5 text-fg-muted shrink-0",children:[l,n.jsx("span",{className:"type-data-xs font-medium hidden sm:inline",children:c})]}),n.jsx("input",{type:"range",min:x,max:v,step:w,value:t,onChange:N=>o(parseFloat(N.target.value)),className:"flex-1 h-1 min-w-[60px] bg-subtle-fill rounded appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-2.5 [&::-webkit-slider-thumb]:h-2.5 [&::-webkit-slider-thumb]:bg-sys-blue [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:cursor-pointer"}),n.jsx("span",{className:"type-data-xs text-fg-secondary tabular-nums shrink-0 w-8 text-right",children:m?m(t):t})]})});export{fe as A,he as a,xe as c}; + `,children:[n.jsx("span",{className:"flex-1 truncate",children:e.name}),n.jsx("span",{className:"text-fg-muted type-data-xs shrink-0",children:e.label})]},e.hash)})})]})]}),t.nodeIds.size>0&&n.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[Array.from(t.nodeIds).map(e=>{const s=t.disabledNodeIds.has(e);return n.jsxs("span",{role:"button",tabIndex:0,onClick:()=>R(e),onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),R(e))},className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full type-data-xs border transition-colors select-none ${s?"bg-zinc-500/10 text-fg-muted border-edge-subtle cursor-pointer hover:bg-zinc-500/15":"bg-sys-indigo/15 text-sys-indigo border-sys-indigo/25 cursor-pointer hover:bg-sys-indigo/25"}`,title:e,children:[i.get(e)??e.slice(0,8),n.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),O(e)},className:"hover:text-fg-primary transition-colors -mr-0.5",title:"Remove from filter",children:n.jsx(K,{className:"w-3 h-3"})})]},e)}),n.jsx("button",{type:"button",onClick:A,className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full type-data-xs border transition-colors ${t.nodeFilterMode==="observed"?"bg-sys-blue/15 text-sys-blue border-sys-blue/25 hover:bg-sys-blue/25":"bg-white/[0.04] text-fg-muted border-edge-subtle hover:text-fg-secondary hover:border-fg-muted/40"}`,title:t.nodeFilterMode==="source"?"Source Only — showing packets sent by selected node(s)":"Total Observed — showing all packets where selected node(s) appear (source, path, or destination)",children:t.nodeFilterMode==="source"?"Source Only":"Total Observed"})]})]})}const B=u.memo(function({icon:l,label:c,value:t,onChange:o,min:x,max:v,step:w,format:m}){return n.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[n.jsxs("div",{className:"flex items-center gap-1.5 text-fg-muted shrink-0",children:[l,n.jsx("span",{className:"type-data-xs font-medium hidden sm:inline",children:c})]}),n.jsx("input",{type:"range",min:x,max:v,step:w,value:t,onChange:N=>o(parseFloat(N.target.value)),className:"flex-1 h-1 min-w-[60px] bg-subtle-fill rounded appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-2.5 [&::-webkit-slider-thumb]:h-2.5 [&::-webkit-slider-thumb]:bg-sys-blue [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:cursor-pointer"}),n.jsx("span",{className:"type-data-xs text-fg-secondary tabular-nums shrink-0 w-8 text-right",children:m?m(t):t})]})});export{fe as A,he as a,xe as c}; diff --git a/frontend/dist/assets/AnimatedNumber-BmJRWt4U.js b/frontend/dist/assets/AnimatedNumber-BAXz0cmM.js similarity index 60% rename from frontend/dist/assets/AnimatedNumber-BmJRWt4U.js rename to frontend/dist/assets/AnimatedNumber-BAXz0cmM.js index a0e1c320..a4313416 100644 --- a/frontend/dist/assets/AnimatedNumber-BmJRWt4U.js +++ b/frontend/dist/assets/AnimatedNumber-BAXz0cmM.js @@ -1,6 +1,6 @@ -import{d as f,r as e,ci as l,j as m,cj as A}from"./index-C8IY8K2r.js";import{A as h}from"./index-B-prVW1V.js";/** +import{d as p,r as e,cl as f,j as m,cm as A}from"./index-BwGHI0A_.js";import{A as h}from"./index-OH01SZkk.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 y=[["path",{d:"M6 18.5a3.5 3.5 0 1 0 7 0c0-1.57.92-2.52 2.04-3.46",key:"1qngmn"}],["path",{d:"M6 8.5c0-.75.13-1.47.36-2.14",key:"b06bma"}],["path",{d:"M8.8 3.15A6.5 6.5 0 0 1 19 8.5c0 1.63-.44 2.81-1.09 3.76",key:"g10hsz"}],["path",{d:"M12.5 6A2.5 2.5 0 0 1 15 8.5M10 13a2 2 0 0 0 1.82-1.18",key:"ygzou7"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]],k=f("ear-off",y),E=e.memo(function({value:t,format:a,prefix:s,suffix:i,className:r,priority:c="medium"}){const[n,u]=e.useState(!1),[d,o]=e.useState(t);e.useEffect(()=>l(()=>{u(!0),o(0)},c),[c]),e.useEffect(()=>{n&&o(t)},[n,t]);const p=`${s??""}${t.toLocaleString(void 0,a)}${i??""}`;return n?m.jsx(h,{className:`${r??""} overflow-hidden`,format:a,prefix:s,suffix:i,transition:A.numberTicker,children:d}):m.jsx("span",{className:r,children:p})});export{E as A,k as E}; + */const y=[["path",{d:"M6 18.5a3.5 3.5 0 1 0 7 0c0-1.57.92-2.52 2.04-3.46",key:"1qngmn"}],["path",{d:"M6 8.5c0-.75.13-1.47.36-2.14",key:"b06bma"}],["path",{d:"M8.8 3.15A6.5 6.5 0 0 1 19 8.5c0 1.63-.44 2.81-1.09 3.76",key:"g10hsz"}],["path",{d:"M12.5 6A2.5 2.5 0 0 1 15 8.5M10 13a2 2 0 0 0 1.82-1.18",key:"ygzou7"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]],E=p("ear-off",y),j=e.memo(function({value:t,format:a,prefix:s,suffix:i,className:r,priority:c="medium"}){const[n,u]=e.useState(!1),[d,o]=e.useState(t);e.useEffect(()=>f(()=>{u(!0),o(0)},c),[c]),e.useEffect(()=>{n&&o(t)},[n,t]);const l=`${s??""}${t.toLocaleString(void 0,a)}${i??""}`;return n?m.jsx(h,{className:`${r??""} overflow-hidden`,format:a,prefix:s,suffix:i,transition:A.numberTicker,children:d}):m.jsx("span",{className:r,children:l})});export{j as A,E}; diff --git a/frontend/dist/assets/BasemapLayer-D5WYHXmJ.js b/frontend/dist/assets/BasemapLayer-Bm_seLWQ.js similarity index 99% rename from frontend/dist/assets/BasemapLayer-D5WYHXmJ.js rename to frontend/dist/assets/BasemapLayer-Bm_seLWQ.js index 427d2d3c..6db0369b 100644 --- a/frontend/dist/assets/BasemapLayer-D5WYHXmJ.js +++ b/frontend/dist/assets/BasemapLayer-Bm_seLWQ.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-C8IY8K2r.js","assets/index-DUfCykEc.css"])))=>i.map(i=>d[i]); -import{r as i,bo as $,aD as B,bh as G}from"./index-C8IY8K2r.js";const H=i.createContext(null);function K(){var s;const e=(s=i.useContext(H))==null?void 0:s.maps,t=i.useContext(w);return i.useMemo(()=>({...e,current:t==null?void 0:t.map}),[e,t])}function Y(e,t){const n=Array.isArray(e)?e[0]:e?e.x:0,s=Array.isArray(e)?e[1]:e?e.y:0,o=Array.isArray(t)?t[0]:t?t.x:0,r=Array.isArray(t)?t[1]:t?t.y:0;return n===o&&s===r}function v(e,t){if(e===t)return!0;if(!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n{let o=null;"interactive"in s&&(o=Object.assign({},s),delete o.interactive);const r=t[s.ref];if(r){o=o||Object.assign({},s),delete o.ref;for(const a of J)a in r&&(o[a]=r[a])}return o||s});return{...e,layers:n}}const A={version:8,sources:{},layers:[]},U={mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",click:"onClick",dblclick:"onDblClick",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",mouseout:"onMouseOut",contextmenu:"onContextMenu",touchstart:"onTouchStart",touchend:"onTouchEnd",touchmove:"onTouchMove",touchcancel:"onTouchCancel"},F={movestart:"onMoveStart",move:"onMove",moveend:"onMoveEnd",dragstart:"onDragStart",drag:"onDrag",dragend:"onDragEnd",zoomstart:"onZoomStart",zoom:"onZoom",zoomend:"onZoomEnd",rotatestart:"onRotateStart",rotate:"onRotate",rotateend:"onRotateEnd",pitchstart:"onPitchStart",pitch:"onPitch",pitchend:"onPitchEnd"},D={wheel:"onWheel",boxzoomstart:"onBoxZoomStart",boxzoomend:"onBoxZoomEnd",boxzoomcancel:"onBoxZoomCancel",resize:"onResize",load:"onLoad",render:"onRender",idle:"onIdle",remove:"onRemove",data:"onData",styledata:"onStyleData",sourcedata:"onSourceData",error:"onError"},X=["minZoom","maxZoom","minPitch","maxPitch","maxBounds","projection","renderWorldCopies"],Q=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate","touchPitch"];class b{constructor(t,n,s){this._map=null,this._internalUpdate=!1,this._hoveredFeatures=null,this._propsedCameraUpdate=null,this._styleComponents={},this._onEvent=o=>{const r=this.props[D[o.type]];r?r(o):o.type==="error"&&console.error(o.error)},this._onCameraEvent=o=>{if(this._internalUpdate)return;o.viewState=this._propsedCameraUpdate||P(this._map.transform);const r=this.props[F[o.type]];r&&r(o)},this._onCameraUpdate=o=>this._internalUpdate?o:(this._propsedCameraUpdate=P(o),z(o,this.props)),this._onPointerEvent=o=>{(o.type==="mousemove"||o.type==="mouseout")&&this._updateHover(o);const r=this.props[U[o.type]];r&&(this.props.interactiveLayerIds&&o.type!=="mouseover"&&o.type!=="mouseout"&&(o.features=this._hoveredFeatures||this._queryRenderedFeatures(o.point)),r(o),delete o.features)},this._MapClass=t,this.props=n,this._initialize(s)}get map(){return this._map}setProps(t){const n=this.props;this.props=t;const s=this._updateSettings(t,n),o=this._updateSize(t),r=this._updateViewState(t);this._updateStyle(t,n),this._updateStyleComponents(t),this._updateHandlers(t,n),(s||o||r&&!this._map.isMoving())&&this.redraw()}static reuse(t,n){const s=b.savedMaps.pop();if(!s)return null;const o=s.map,r=o.getContainer();for(n.className=r.className;r.childNodes.length>0;)n.appendChild(r.childNodes[0]);o._container=n;const a=o._resizeObserver;a&&(a.disconnect(),a.observe(n)),s.setProps({...t,styleDiffing:!1}),o.resize();const{initialViewState:c}=t;return c&&(c.bounds?o.fitBounds(c.bounds,{...c.fitBoundsOptions,duration:0}):s._updateViewState(c)),o.isStyleLoaded()?o.fire("load"):o.once("style.load",()=>o.fire("load")),o._update(),s}_initialize(t){const{props:n}=this,{mapStyle:s=A}=n,o={...n,...n.initialViewState,container:t,style:O(s)},r=o.initialViewState||o.viewState||o;if(Object.assign(o,{center:[r.longitude||0,r.latitude||0],zoom:r.zoom||0,pitch:r.pitch||0,bearing:r.bearing||0}),n.gl){const c=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=()=>(HTMLCanvasElement.prototype.getContext=c,n.gl)}const a=new this._MapClass(o);r.padding&&a.setPadding(r.padding),n.cursor&&(a.getCanvas().style.cursor=n.cursor),a.transformCameraUpdate=this._onCameraUpdate,a.on("style.load",()=>{var c;this._styleComponents={light:a.getLight(),sky:a.getSky(),projection:(c=a.getProjection)==null?void 0:c.call(a),terrain:a.getTerrain()},this._updateStyleComponents(this.props)}),a.on("sourcedata",()=>{this._updateStyleComponents(this.props)});for(const c in U)a.on(c,this._onPointerEvent);for(const c in F)a.on(c,this._onCameraEvent);for(const c in D)a.on(c,this._onEvent);this._map=a}recycle(){const n=this.map.getContainer().querySelector("[mapboxgl-children]");n==null||n.remove(),b.savedMaps.push(this)}destroy(){this._map.remove()}redraw(){const t=this._map;t.style&&(t._frame&&(t._frame.cancel(),t._frame=null),t._render())}_updateSize(t){const{viewState:n}=t;if(n){const s=this._map;if(n.width!==s.transform.width||n.height!==s.transform.height)return s.resize(),!0}return!1}_updateViewState(t){const n=this._map,s=n.transform;if(!n.isMoving()){const r=z(s,t);if(Object.keys(r).length>0)return this._internalUpdate=!0,n.jumpTo(r),this._internalUpdate=!1,!0}return!1}_updateSettings(t,n){const s=this._map;let o=!1;for(const r of X)if(r in t&&!v(t[r],n[r])){o=!0;const a=s[`set${r[0].toUpperCase()}${r.slice(1)}`];a==null||a.call(s,t[r])}return o}_updateStyle(t,n){if(t.cursor!==n.cursor&&(this._map.getCanvas().style.cursor=t.cursor||""),t.mapStyle!==n.mapStyle){const{mapStyle:s=A,styleDiffing:o=!0}=t,r={diff:o};"localIdeographFontFamily"in t&&(r.localIdeographFontFamily=t.localIdeographFontFamily),this._map.setStyle(O(s),r)}}_updateStyleComponents({light:t,projection:n,sky:s,terrain:o}){var c,u;const r=this._map,a=this._styleComponents;r.style._loaded&&(t&&!v(t,a.light)&&(a.light=t,r.setLight(t)),n&&!v(n,a.projection)&&n!==((c=a.projection)==null?void 0:c.type)&&(a.projection=typeof n=="string"?{type:n}:n,(u=r.setProjection)==null||u.call(r,a.projection)),s&&!v(s,a.sky)&&(a.sky=s,r.setSky(s)),o!==void 0&&!v(o,a.terrain)&&(!o||r.getSource(o.source))&&(a.terrain=o,r.setTerrain(o)))}_updateHandlers(t,n){const s=this._map;for(const o of Q){const r=t[o]??!0,a=n[o]??!0;v(r,a)||(r?s[o].enable(r):s[o].disable())}}_queryRenderedFeatures(t){const n=this._map,{interactiveLayerIds:s=[]}=this.props;try{return n.queryRenderedFeatures(t,{layers:s.filter(n.getLayer.bind(n))})}catch{return[]}}_updateHover(t){var o;const{props:n}=this;if(n.interactiveLayerIds&&(n.onMouseMove||n.onMouseEnter||n.onMouseLeave)){const r=t.type,a=((o=this._hoveredFeatures)==null?void 0:o.length)>0,c=this._queryRenderedFeatures(t.point),u=c.length>0;!u&&a&&(t.type="mouseleave",this._onPointerEvent(t)),this._hoveredFeatures=c,u&&!a&&(t.type="mouseenter",this._onPointerEvent(t)),t.type=r}else this._hoveredFeatures=null}}b.savedMaps=[];const ee=["setMaxBounds","setMinZoom","setMaxZoom","setMinPitch","setMaxPitch","setRenderWorldCopies","setProjection","setStyle","addSource","removeSource","addLayer","removeLayer","setLayerZoomRange","setFilter","setPaintProperty","setLayoutProperty","setLight","setTerrain","setFog","remove"];function te(e){if(!e)return null;const t=e.map,n={getMap:()=>t};for(const s of ne(t))!(s in n)&&!ee.includes(s)&&(n[s]=t[s].bind(t));return n}function ne(e){const t=new Set;let n=e;for(;n;){for(const s of Object.getOwnPropertyNames(n))s[0]!=="_"&&typeof e[s]=="function"&&s!=="fire"&&s!=="setEventedParent"&&t.add(s);n=Object.getPrototypeOf(n)}return Array.from(t)}const oe=typeof document<"u"?i.useLayoutEffect:i.useEffect;function re(e,t){const{RTLTextPlugin:n,maxParallelImageRequests:s,workerCount:o,workerUrl:r}=t;if(n&&e.getRTLTextPluginStatus&&e.getRTLTextPluginStatus()==="unavailable"){const{pluginUrl:a,lazy:c=!0}=typeof n=="string"?{pluginUrl:n}:n;e.setRTLTextPlugin(a,u=>{u&&console.error(u)},c)}s!==void 0&&e.setMaxParallelImageRequests(s),o!==void 0&&e.setWorkerCount(o),r!==void 0&&e.setWorkerUrl(r)}const w=i.createContext(null);function se(e,t){const n=i.useContext(H),[s,o]=i.useState(null),r=i.useRef(),{current:a}=i.useRef({mapLib:null,map:null});i.useEffect(()=>{const l=e.mapLib;let d=!0,f;return Promise.resolve(l||$(()=>import("./maplibre-gl-DihO1Cg6.js").then(m=>m.m),__vite__mapDeps([0,1]))).then(m=>{if(!d)return;if(!m)throw new Error("Invalid mapLib");const y="Map"in m?m:m.default;if(!y.Map)throw new Error("Invalid mapLib");re(y,e),e.reuseMaps&&(f=b.reuse(e,r.current)),f||(f=new b(y.Map,e,r.current)),a.map=te(f),a.mapLib=y,o(f),n==null||n.onMapMount(a.map,e.id)}).catch(m=>{const{onError:y}=e;y?y({type:"error",target:null,originalEvent:null,error:m}):console.error(m)}),()=>{d=!1,f&&(n==null||n.onMapUnmount(e.id),e.reuseMaps?f.recycle():f.destroy())}},[]),oe(()=>{s&&s.setProps(e)}),i.useImperativeHandle(t,()=>a.map,[s]);const c=i.useMemo(()=>({position:"relative",width:"100%",height:"100%",...e.style}),[e.style]),u={height:"100%"};return i.createElement("div",{id:e.id,ref:r,style:c},s&&i.createElement(w.Provider,{value:a},i.createElement("div",{"mapboxgl-children":"",style:u},e.children)))}const Me=i.forwardRef(se),ae=/box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;function L(e,t){if(!e||!t)return;const n=e.style;for(const s in t){const o=t[s];Number.isFinite(o)&&!ae.test(s)?n[s]=`${o}px`:n[s]=o}}function Z(e,t){if(e===t)return null;const n=N(e),s=N(t),o=[];for(const r of s)n.has(r)||o.push(r);for(const r of n)s.has(r)||o.push(r);return o.length===0?null:o}function N(e){return new Set(e?e.trim().split(/\s+/):[])}const be=i.memo(i.forwardRef((e,t)=>{const{map:n,mapLib:s}=i.useContext(w),o=i.useRef({props:e}),r=i.useMemo(()=>{let E=!1;i.Children.forEach(e.children,h=>{h&&(E=!0)});const k={...e,element:E?document.createElement("div"):void 0},p=new s.Marker(k);return p.setLngLat([e.longitude,e.latitude]),p.getElement().addEventListener("click",h=>{var g,_;(_=(g=o.current.props).onClick)==null||_.call(g,{type:"click",target:p,originalEvent:h})}),p.on("dragstart",h=>{var _,S;const g=h;g.lngLat=r.getLngLat(),(S=(_=o.current.props).onDragStart)==null||S.call(_,g)}),p.on("drag",h=>{var _,S;const g=h;g.lngLat=r.getLngLat(),(S=(_=o.current.props).onDrag)==null||S.call(_,g)}),p.on("dragend",h=>{var _,S;const g=h;g.lngLat=r.getLngLat(),(S=(_=o.current.props).onDragEnd)==null||S.call(_,g)}),p},[]);i.useEffect(()=>(r.addTo(n.getMap()),()=>{r.remove()}),[]);const{longitude:a,latitude:c,offset:u,style:l,draggable:d=!1,popup:f=null,rotation:m=0,rotationAlignment:y="auto",pitchAlignment:C="auto"}=e;i.useEffect(()=>{L(r.getElement(),l)},[l]),i.useImperativeHandle(t,()=>r,[]);const T=o.current.props;(r.getLngLat().lng!==a||r.getLngLat().lat!==c)&&r.setLngLat([a,c]),u&&!Y(r.getOffset(),u)&&r.setOffset(u),r.isDraggable()!==d&&r.setDraggable(d),r.getRotation()!==m&&r.setRotation(m),r.getRotationAlignment()!==y&&r.setRotationAlignment(y),r.getPitchAlignment()!==C&&r.setPitchAlignment(C),r.getPopup()!==f&&r.setPopup(f);const x=Z(T.className,e.className);if(x)for(const E of x)r.toggleClassName(E);return o.current.props=e,B.createPortal(e.children,r.getElement())})),xe=i.memo(i.forwardRef((e,t)=>{const{map:n,mapLib:s}=i.useContext(w),o=i.useMemo(()=>document.createElement("div"),[]),r=i.useRef({props:e}),a=i.useMemo(()=>{const c={...e},u=new s.Popup(c);return u.setLngLat([e.longitude,e.latitude]),u.once("open",l=>{var d,f;(f=(d=r.current.props).onOpen)==null||f.call(d,l)}),u},[]);if(i.useEffect(()=>{const c=u=>{var l,d;(d=(l=r.current.props).onClose)==null||d.call(l,u)};return a.on("close",c),a.setDOMContent(o).addTo(n.getMap()),()=>{a.off("close",c),a.isOpen()&&a.remove()}},[]),i.useEffect(()=>{L(a.getElement(),e.style)},[e.style]),i.useImperativeHandle(t,()=>a,[]),a.isOpen()){const c=r.current.props;(a.getLngLat().lng!==e.longitude||a.getLngLat().lat!==e.latitude)&&a.setLngLat([e.longitude,e.latitude]),e.offset&&!v(c.offset,e.offset)&&a.setOffset(e.offset),(c.anchor!==e.anchor||c.maxWidth!==e.maxWidth)&&(a.options.anchor=e.anchor,a.setMaxWidth(e.maxWidth));const u=Z(c.className,e.className);if(u)for(const l of u)a.toggleClassName(l);r.current.props=e}return B.createPortal(e.children,o)}));function M(e,t,n,s){const o=i.useContext(w),r=i.useMemo(()=>e(o),[]);return i.useEffect(()=>{const a=t,c=null,u=typeof t=="function"?t:null,{map:l}=o;return l.hasControl(r)||(l.addControl(r,a==null?void 0:a.position),c&&c(o)),()=>{u&&u(o),l.hasControl(r)&&l.removeControl(r)}},[]),r}function ie(e){const t=M(({mapLib:n})=>new n.AttributionControl(e),{position:e.position});return i.useEffect(()=>{L(t._container,e.style)},[e.style]),null}i.memo(ie);function ce(e){const t=M(({mapLib:n})=>new n.FullscreenControl({container:e.containerId&&document.getElementById(e.containerId)}),{position:e.position});return i.useEffect(()=>{L(t._controlContainer,e.style)},[e.style]),null}i.memo(ce);function le(e,t){const n=i.useRef({props:e}),s=M(({mapLib:o})=>{const r=new o.GeolocateControl(e),a=r._setupUI;return r._setupUI=()=>{r._container.hasChildNodes()||a()},r.on("geolocate",c=>{var u,l;(l=(u=n.current.props).onGeolocate)==null||l.call(u,c)}),r.on("error",c=>{var u,l;(l=(u=n.current.props).onError)==null||l.call(u,c)}),r.on("outofmaxbounds",c=>{var u,l;(l=(u=n.current.props).onOutOfMaxBounds)==null||l.call(u,c)}),r.on("trackuserlocationstart",c=>{var u,l;(l=(u=n.current.props).onTrackUserLocationStart)==null||l.call(u,c)}),r.on("trackuserlocationend",c=>{var u,l;(l=(u=n.current.props).onTrackUserLocationEnd)==null||l.call(u,c)}),r},{position:e.position});return n.current.props=e,i.useImperativeHandle(t,()=>s,[]),i.useEffect(()=>{L(s._container,e.style)},[e.style]),null}i.memo(i.forwardRef(le));function ue(e){const t=M(({mapLib:n})=>new n.NavigationControl(e),{position:e.position});return i.useEffect(()=>{L(t._container,e.style)},[e.style]),null}i.memo(ue);function fe(e){const t=M(({mapLib:r})=>new r.ScaleControl(e),{position:e.position}),n=i.useRef(e),s=n.current;n.current=e;const{style:o}=e;return e.maxWidth!==void 0&&e.maxWidth!==s.maxWidth&&(t.options.maxWidth=e.maxWidth),e.unit!==void 0&&e.unit!==s.unit&&t.setUnit(e.unit),i.useEffect(()=>{L(t._container,o)},[o]),null}const ke=i.memo(fe);function de(e){const t=M(({mapLib:n})=>new n.TerrainControl(e),{position:e.position});return i.useEffect(()=>{L(t._container,e.style)},[e.style]),null}i.memo(de);function me(e){const t=M(({mapLib:n})=>new n.LogoControl(e),{position:e.position});return i.useEffect(()=>{L(t._container,e.style)},[e.style]),null}i.memo(me);function R(e,t){if(!e)throw new Error(t)}let ye=0;function ge(e,t,n){if(e.style&&e.style._loaded){const s={...n};return delete s.id,delete s.children,e.addSource(t,s),e.getSource(t)}return null}function he(e,t,n){var a,c,u;R(t.id===n.id,"source id changed"),R(t.type===n.type,"source type changed");let s="",o=0;for(const l in t)l!=="children"&&l!=="id"&&!v(n[l],t[l])&&(s=l,o++);if(!o)return;const r=t.type;if(r==="geojson")e.setData(t.data);else if(r==="image")e.updateImage({url:t.url,coordinates:t.coordinates});else switch(s){case"coordinates":(a=e.setCoordinates)==null||a.call(e,t.coordinates);break;case"url":(c=e.setUrl)==null||c.call(e,t.url);break;case"tiles":(u=e.setTiles)==null||u.call(e,t.tiles);break;default:console.warn(`Unable to update prop: ${s}`)}}function Re(e){const t=i.useContext(w).map.getMap(),n=i.useRef(e),[,s]=i.useState(0),o=i.useMemo(()=>e.id||`jsx-source-${ye++}`,[]);i.useEffect(()=>{if(t){const a=()=>setTimeout(()=>s(c=>c+1),0);return t.on("styledata",a),a(),()=>{var c;if(t.off("styledata",a),t.style&&t.style._loaded&&t.getSource(o)){const u=(c=t.getStyle())==null?void 0:c.layers;if(u)for(const l of u)l.source===o&&t.removeLayer(l.id);t.removeSource(o)}}}},[t]);let r=t&&t.style&&t.getSource(o);return r?he(r,e,n.current):r=ge(t,o,e),n.current=e,r&&i.Children.map(e.children,a=>a&&i.cloneElement(a,{source:o}))||null}function pe(e,t,n,s){if(R(n.id===s.id,"layer id changed"),R(n.type===s.type,"layer type changed"),n.type==="custom"||s.type==="custom")return;const{layout:o={},paint:r={},filter:a,minzoom:c,maxzoom:u,beforeId:l}=n;if(l!==s.beforeId&&e.moveLayer(t,l),o!==s.layout){const d=s.layout||{};for(const f in o)v(o[f],d[f])||e.setLayoutProperty(t,f,o[f]);for(const f in d)o.hasOwnProperty(f)||e.setLayoutProperty(t,f,void 0)}if(r!==s.paint){const d=s.paint||{};for(const f in r)v(r[f],d[f])||e.setPaintProperty(t,f,r[f]);for(const f in d)r.hasOwnProperty(f)||e.setPaintProperty(t,f,void 0)}v(a,s.filter)||e.setFilter(t,a),(c!==s.minzoom||u!==s.maxzoom)&&e.setLayerZoomRange(t,c,u)}function ve(e,t,n){if(e.style&&e.style._loaded&&(!("source"in n)||e.getSource(n.source))){const s={...n,id:t};delete s.beforeId,e.addLayer(s,n.beforeId)}}let _e=0;function Ie(e){const t=i.useContext(w).map.getMap(),n=i.useRef(e),[,s]=i.useState(0),o=i.useMemo(()=>e.id||`jsx-layer-${_e++}`,[]);if(i.useEffect(()=>{if(t){const a=()=>s(c=>c+1);return t.on("styledata",a),a(),()=>{t.off("styledata",a),t.style&&t.style._loaded&&t.getLayer(o)&&t.removeLayer(o)}}},[t]),t&&t.style&&t.getLayer(o))try{pe(t,o,e,n.current)}catch(a){console.warn(a)}else ve(t,o,e);return n.current=e,null}const V="pymc-basemap-mode",j="dark";function Le(){if(typeof window>"u")return j;try{const e=localStorage.getItem(V);if(e==="light"||e==="dark")return e}catch{}return j}function W(e){if(!(typeof window>"u"))try{localStorage.setItem(V,e)}catch{}}const q=G(e=>({mode:Le(),toggle:()=>e(t=>{const n=t.mode==="light"?"dark":"light";return W(n),{mode:n}}),setMode:t=>{W(t),e({mode:t})}})),Te=()=>q(e=>e.mode),Pe=()=>q(e=>e.toggle),Ce={light:"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",dark:"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json"},Se={light:"basemap-light-",dark:"basemap-dark-"},I={};async function Ee(e){if(I[e])return I[e];const n=await(await fetch(Ce[e])).json();return I[e]=n,n}function ze({mode:e}){const{current:t}=K(),[n,s]=i.useState(null),o=i.useRef({light:!1,dark:!1}),r=i.useRef({light:[],dark:[]});i.useEffect(()=>{const l=()=>{var y;const m=(y=t==null?void 0:t.getMap)==null?void 0:y.call(t);m&&!n&&s(m)};l();const d=setInterval(l,50),f=setTimeout(()=>clearInterval(d),5e3);return()=>{clearInterval(d),clearTimeout(f)}},[t,n]);const a=i.useCallback(async(l,d,f)=>{var E,k;if(o.current[d])return;const m=Se[d],y=await Ee(d),C=[];for(const[p,h]of Object.entries(y.sources||{})){const g=m+p;l.getSource(g)||l.addSource(g,h)}const x=(k=(((E=l.getStyle())==null?void 0:E.layers)||[]).find(p=>!p.id.startsWith("basemap-light-")&&!p.id.startsWith("basemap-dark-")))==null?void 0:k.id;for(const p of y.layers||[]){const h=m+p.id;if(C.push(h),l.getLayer(h))continue;const g={...p,id:h};"source"in g&&typeof g.source=="string"&&(g.source=m+g.source),g.layout||(g.layout={}),g.layout.visibility=f?"visible":"none";try{l.addLayer(g,x)}catch(_){console.warn(`[BasemapLayer] Failed to add layer ${h}:`,_)}}r.current[d]=C,o.current[d]=!0},[]),c=i.useCallback((l,d,f)=>{const m=r.current[d],y=f?"visible":"none";for(const C of m)if(l.getLayer(C))try{l.setLayoutProperty(C,"visibility",y)}catch{}},[]),u=i.useCallback(l=>{var m;const f=(((m=l.getStyle())==null?void 0:m.layers)||[]).filter(y=>!y.id.startsWith("basemap-light-")&&!y.id.startsWith("basemap-dark-"));for(const y of f)try{l.moveLayer(y.id)}catch{}},[]);return i.useEffect(()=>{if(!n)return;const l=d=>{n.hasImage(d.id)||n.addImage(d.id,{width:1,height:1,data:new Uint8Array([0,0,0,0])})};return n.on("styleimagemissing",l),()=>{n.off("styleimagemissing",l)}},[n]),i.useEffect(()=>{if(!n)return;let l=!1;const d=async()=>{if(!l)try{await Promise.all([a(n,"light",e==="light"),a(n,"dark",e==="dark")]),l||u(n)}catch(m){console.error("[BasemapLayer] Setup error:",m)}};n.isStyleLoaded()?d():(n.once("style.load",d),n.once("load",()=>{!l&&!o.current.light&&d()}));const f=()=>{l||setTimeout(()=>{!l&&o.current.light&&o.current.dark&&u(n)},100)};return n.on("styledata",f),()=>{l=!0,n.off("styledata",f)}},[n,a,u,e]),i.useEffect(()=>{n&&(!o.current.light||!o.current.dark||(c(n,"light",e==="light"),c(n,"dark",e==="dark")))},[n,e,c]),null}export{ze as B,Ie as L,Me as M,xe as P,Re as S,be as a,K as b,Pe as c,ke as d,Te as u}; +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BwGHI0A_.js","assets/index-DUfCykEc.css"])))=>i.map(i=>d[i]); +import{r as i,bo as $,aD as B,bh as G}from"./index-BwGHI0A_.js";const H=i.createContext(null);function K(){var s;const e=(s=i.useContext(H))==null?void 0:s.maps,t=i.useContext(w);return i.useMemo(()=>({...e,current:t==null?void 0:t.map}),[e,t])}function Y(e,t){const n=Array.isArray(e)?e[0]:e?e.x:0,s=Array.isArray(e)?e[1]:e?e.y:0,o=Array.isArray(t)?t[0]:t?t.x:0,r=Array.isArray(t)?t[1]:t?t.y:0;return n===o&&s===r}function v(e,t){if(e===t)return!0;if(!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n{let o=null;"interactive"in s&&(o=Object.assign({},s),delete o.interactive);const r=t[s.ref];if(r){o=o||Object.assign({},s),delete o.ref;for(const a of J)a in r&&(o[a]=r[a])}return o||s});return{...e,layers:n}}const A={version:8,sources:{},layers:[]},U={mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",click:"onClick",dblclick:"onDblClick",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",mouseout:"onMouseOut",contextmenu:"onContextMenu",touchstart:"onTouchStart",touchend:"onTouchEnd",touchmove:"onTouchMove",touchcancel:"onTouchCancel"},F={movestart:"onMoveStart",move:"onMove",moveend:"onMoveEnd",dragstart:"onDragStart",drag:"onDrag",dragend:"onDragEnd",zoomstart:"onZoomStart",zoom:"onZoom",zoomend:"onZoomEnd",rotatestart:"onRotateStart",rotate:"onRotate",rotateend:"onRotateEnd",pitchstart:"onPitchStart",pitch:"onPitch",pitchend:"onPitchEnd"},D={wheel:"onWheel",boxzoomstart:"onBoxZoomStart",boxzoomend:"onBoxZoomEnd",boxzoomcancel:"onBoxZoomCancel",resize:"onResize",load:"onLoad",render:"onRender",idle:"onIdle",remove:"onRemove",data:"onData",styledata:"onStyleData",sourcedata:"onSourceData",error:"onError"},X=["minZoom","maxZoom","minPitch","maxPitch","maxBounds","projection","renderWorldCopies"],Q=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate","touchPitch"];class b{constructor(t,n,s){this._map=null,this._internalUpdate=!1,this._hoveredFeatures=null,this._propsedCameraUpdate=null,this._styleComponents={},this._onEvent=o=>{const r=this.props[D[o.type]];r?r(o):o.type==="error"&&console.error(o.error)},this._onCameraEvent=o=>{if(this._internalUpdate)return;o.viewState=this._propsedCameraUpdate||P(this._map.transform);const r=this.props[F[o.type]];r&&r(o)},this._onCameraUpdate=o=>this._internalUpdate?o:(this._propsedCameraUpdate=P(o),z(o,this.props)),this._onPointerEvent=o=>{(o.type==="mousemove"||o.type==="mouseout")&&this._updateHover(o);const r=this.props[U[o.type]];r&&(this.props.interactiveLayerIds&&o.type!=="mouseover"&&o.type!=="mouseout"&&(o.features=this._hoveredFeatures||this._queryRenderedFeatures(o.point)),r(o),delete o.features)},this._MapClass=t,this.props=n,this._initialize(s)}get map(){return this._map}setProps(t){const n=this.props;this.props=t;const s=this._updateSettings(t,n),o=this._updateSize(t),r=this._updateViewState(t);this._updateStyle(t,n),this._updateStyleComponents(t),this._updateHandlers(t,n),(s||o||r&&!this._map.isMoving())&&this.redraw()}static reuse(t,n){const s=b.savedMaps.pop();if(!s)return null;const o=s.map,r=o.getContainer();for(n.className=r.className;r.childNodes.length>0;)n.appendChild(r.childNodes[0]);o._container=n;const a=o._resizeObserver;a&&(a.disconnect(),a.observe(n)),s.setProps({...t,styleDiffing:!1}),o.resize();const{initialViewState:c}=t;return c&&(c.bounds?o.fitBounds(c.bounds,{...c.fitBoundsOptions,duration:0}):s._updateViewState(c)),o.isStyleLoaded()?o.fire("load"):o.once("style.load",()=>o.fire("load")),o._update(),s}_initialize(t){const{props:n}=this,{mapStyle:s=A}=n,o={...n,...n.initialViewState,container:t,style:O(s)},r=o.initialViewState||o.viewState||o;if(Object.assign(o,{center:[r.longitude||0,r.latitude||0],zoom:r.zoom||0,pitch:r.pitch||0,bearing:r.bearing||0}),n.gl){const c=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=()=>(HTMLCanvasElement.prototype.getContext=c,n.gl)}const a=new this._MapClass(o);r.padding&&a.setPadding(r.padding),n.cursor&&(a.getCanvas().style.cursor=n.cursor),a.transformCameraUpdate=this._onCameraUpdate,a.on("style.load",()=>{var c;this._styleComponents={light:a.getLight(),sky:a.getSky(),projection:(c=a.getProjection)==null?void 0:c.call(a),terrain:a.getTerrain()},this._updateStyleComponents(this.props)}),a.on("sourcedata",()=>{this._updateStyleComponents(this.props)});for(const c in U)a.on(c,this._onPointerEvent);for(const c in F)a.on(c,this._onCameraEvent);for(const c in D)a.on(c,this._onEvent);this._map=a}recycle(){const n=this.map.getContainer().querySelector("[mapboxgl-children]");n==null||n.remove(),b.savedMaps.push(this)}destroy(){this._map.remove()}redraw(){const t=this._map;t.style&&(t._frame&&(t._frame.cancel(),t._frame=null),t._render())}_updateSize(t){const{viewState:n}=t;if(n){const s=this._map;if(n.width!==s.transform.width||n.height!==s.transform.height)return s.resize(),!0}return!1}_updateViewState(t){const n=this._map,s=n.transform;if(!n.isMoving()){const r=z(s,t);if(Object.keys(r).length>0)return this._internalUpdate=!0,n.jumpTo(r),this._internalUpdate=!1,!0}return!1}_updateSettings(t,n){const s=this._map;let o=!1;for(const r of X)if(r in t&&!v(t[r],n[r])){o=!0;const a=s[`set${r[0].toUpperCase()}${r.slice(1)}`];a==null||a.call(s,t[r])}return o}_updateStyle(t,n){if(t.cursor!==n.cursor&&(this._map.getCanvas().style.cursor=t.cursor||""),t.mapStyle!==n.mapStyle){const{mapStyle:s=A,styleDiffing:o=!0}=t,r={diff:o};"localIdeographFontFamily"in t&&(r.localIdeographFontFamily=t.localIdeographFontFamily),this._map.setStyle(O(s),r)}}_updateStyleComponents({light:t,projection:n,sky:s,terrain:o}){var c,u;const r=this._map,a=this._styleComponents;r.style._loaded&&(t&&!v(t,a.light)&&(a.light=t,r.setLight(t)),n&&!v(n,a.projection)&&n!==((c=a.projection)==null?void 0:c.type)&&(a.projection=typeof n=="string"?{type:n}:n,(u=r.setProjection)==null||u.call(r,a.projection)),s&&!v(s,a.sky)&&(a.sky=s,r.setSky(s)),o!==void 0&&!v(o,a.terrain)&&(!o||r.getSource(o.source))&&(a.terrain=o,r.setTerrain(o)))}_updateHandlers(t,n){const s=this._map;for(const o of Q){const r=t[o]??!0,a=n[o]??!0;v(r,a)||(r?s[o].enable(r):s[o].disable())}}_queryRenderedFeatures(t){const n=this._map,{interactiveLayerIds:s=[]}=this.props;try{return n.queryRenderedFeatures(t,{layers:s.filter(n.getLayer.bind(n))})}catch{return[]}}_updateHover(t){var o;const{props:n}=this;if(n.interactiveLayerIds&&(n.onMouseMove||n.onMouseEnter||n.onMouseLeave)){const r=t.type,a=((o=this._hoveredFeatures)==null?void 0:o.length)>0,c=this._queryRenderedFeatures(t.point),u=c.length>0;!u&&a&&(t.type="mouseleave",this._onPointerEvent(t)),this._hoveredFeatures=c,u&&!a&&(t.type="mouseenter",this._onPointerEvent(t)),t.type=r}else this._hoveredFeatures=null}}b.savedMaps=[];const ee=["setMaxBounds","setMinZoom","setMaxZoom","setMinPitch","setMaxPitch","setRenderWorldCopies","setProjection","setStyle","addSource","removeSource","addLayer","removeLayer","setLayerZoomRange","setFilter","setPaintProperty","setLayoutProperty","setLight","setTerrain","setFog","remove"];function te(e){if(!e)return null;const t=e.map,n={getMap:()=>t};for(const s of ne(t))!(s in n)&&!ee.includes(s)&&(n[s]=t[s].bind(t));return n}function ne(e){const t=new Set;let n=e;for(;n;){for(const s of Object.getOwnPropertyNames(n))s[0]!=="_"&&typeof e[s]=="function"&&s!=="fire"&&s!=="setEventedParent"&&t.add(s);n=Object.getPrototypeOf(n)}return Array.from(t)}const oe=typeof document<"u"?i.useLayoutEffect:i.useEffect;function re(e,t){const{RTLTextPlugin:n,maxParallelImageRequests:s,workerCount:o,workerUrl:r}=t;if(n&&e.getRTLTextPluginStatus&&e.getRTLTextPluginStatus()==="unavailable"){const{pluginUrl:a,lazy:c=!0}=typeof n=="string"?{pluginUrl:n}:n;e.setRTLTextPlugin(a,u=>{u&&console.error(u)},c)}s!==void 0&&e.setMaxParallelImageRequests(s),o!==void 0&&e.setWorkerCount(o),r!==void 0&&e.setWorkerUrl(r)}const w=i.createContext(null);function se(e,t){const n=i.useContext(H),[s,o]=i.useState(null),r=i.useRef(),{current:a}=i.useRef({mapLib:null,map:null});i.useEffect(()=>{const l=e.mapLib;let d=!0,f;return Promise.resolve(l||$(()=>import("./maplibre-gl-DJ441a35.js").then(m=>m.m),__vite__mapDeps([0,1]))).then(m=>{if(!d)return;if(!m)throw new Error("Invalid mapLib");const y="Map"in m?m:m.default;if(!y.Map)throw new Error("Invalid mapLib");re(y,e),e.reuseMaps&&(f=b.reuse(e,r.current)),f||(f=new b(y.Map,e,r.current)),a.map=te(f),a.mapLib=y,o(f),n==null||n.onMapMount(a.map,e.id)}).catch(m=>{const{onError:y}=e;y?y({type:"error",target:null,originalEvent:null,error:m}):console.error(m)}),()=>{d=!1,f&&(n==null||n.onMapUnmount(e.id),e.reuseMaps?f.recycle():f.destroy())}},[]),oe(()=>{s&&s.setProps(e)}),i.useImperativeHandle(t,()=>a.map,[s]);const c=i.useMemo(()=>({position:"relative",width:"100%",height:"100%",...e.style}),[e.style]),u={height:"100%"};return i.createElement("div",{id:e.id,ref:r,style:c},s&&i.createElement(w.Provider,{value:a},i.createElement("div",{"mapboxgl-children":"",style:u},e.children)))}const Me=i.forwardRef(se),ae=/box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;function L(e,t){if(!e||!t)return;const n=e.style;for(const s in t){const o=t[s];Number.isFinite(o)&&!ae.test(s)?n[s]=`${o}px`:n[s]=o}}function Z(e,t){if(e===t)return null;const n=N(e),s=N(t),o=[];for(const r of s)n.has(r)||o.push(r);for(const r of n)s.has(r)||o.push(r);return o.length===0?null:o}function N(e){return new Set(e?e.trim().split(/\s+/):[])}const be=i.memo(i.forwardRef((e,t)=>{const{map:n,mapLib:s}=i.useContext(w),o=i.useRef({props:e}),r=i.useMemo(()=>{let E=!1;i.Children.forEach(e.children,h=>{h&&(E=!0)});const k={...e,element:E?document.createElement("div"):void 0},p=new s.Marker(k);return p.setLngLat([e.longitude,e.latitude]),p.getElement().addEventListener("click",h=>{var g,_;(_=(g=o.current.props).onClick)==null||_.call(g,{type:"click",target:p,originalEvent:h})}),p.on("dragstart",h=>{var _,S;const g=h;g.lngLat=r.getLngLat(),(S=(_=o.current.props).onDragStart)==null||S.call(_,g)}),p.on("drag",h=>{var _,S;const g=h;g.lngLat=r.getLngLat(),(S=(_=o.current.props).onDrag)==null||S.call(_,g)}),p.on("dragend",h=>{var _,S;const g=h;g.lngLat=r.getLngLat(),(S=(_=o.current.props).onDragEnd)==null||S.call(_,g)}),p},[]);i.useEffect(()=>(r.addTo(n.getMap()),()=>{r.remove()}),[]);const{longitude:a,latitude:c,offset:u,style:l,draggable:d=!1,popup:f=null,rotation:m=0,rotationAlignment:y="auto",pitchAlignment:C="auto"}=e;i.useEffect(()=>{L(r.getElement(),l)},[l]),i.useImperativeHandle(t,()=>r,[]);const T=o.current.props;(r.getLngLat().lng!==a||r.getLngLat().lat!==c)&&r.setLngLat([a,c]),u&&!Y(r.getOffset(),u)&&r.setOffset(u),r.isDraggable()!==d&&r.setDraggable(d),r.getRotation()!==m&&r.setRotation(m),r.getRotationAlignment()!==y&&r.setRotationAlignment(y),r.getPitchAlignment()!==C&&r.setPitchAlignment(C),r.getPopup()!==f&&r.setPopup(f);const x=Z(T.className,e.className);if(x)for(const E of x)r.toggleClassName(E);return o.current.props=e,B.createPortal(e.children,r.getElement())})),xe=i.memo(i.forwardRef((e,t)=>{const{map:n,mapLib:s}=i.useContext(w),o=i.useMemo(()=>document.createElement("div"),[]),r=i.useRef({props:e}),a=i.useMemo(()=>{const c={...e},u=new s.Popup(c);return u.setLngLat([e.longitude,e.latitude]),u.once("open",l=>{var d,f;(f=(d=r.current.props).onOpen)==null||f.call(d,l)}),u},[]);if(i.useEffect(()=>{const c=u=>{var l,d;(d=(l=r.current.props).onClose)==null||d.call(l,u)};return a.on("close",c),a.setDOMContent(o).addTo(n.getMap()),()=>{a.off("close",c),a.isOpen()&&a.remove()}},[]),i.useEffect(()=>{L(a.getElement(),e.style)},[e.style]),i.useImperativeHandle(t,()=>a,[]),a.isOpen()){const c=r.current.props;(a.getLngLat().lng!==e.longitude||a.getLngLat().lat!==e.latitude)&&a.setLngLat([e.longitude,e.latitude]),e.offset&&!v(c.offset,e.offset)&&a.setOffset(e.offset),(c.anchor!==e.anchor||c.maxWidth!==e.maxWidth)&&(a.options.anchor=e.anchor,a.setMaxWidth(e.maxWidth));const u=Z(c.className,e.className);if(u)for(const l of u)a.toggleClassName(l);r.current.props=e}return B.createPortal(e.children,o)}));function M(e,t,n,s){const o=i.useContext(w),r=i.useMemo(()=>e(o),[]);return i.useEffect(()=>{const a=t,c=null,u=typeof t=="function"?t:null,{map:l}=o;return l.hasControl(r)||(l.addControl(r,a==null?void 0:a.position),c&&c(o)),()=>{u&&u(o),l.hasControl(r)&&l.removeControl(r)}},[]),r}function ie(e){const t=M(({mapLib:n})=>new n.AttributionControl(e),{position:e.position});return i.useEffect(()=>{L(t._container,e.style)},[e.style]),null}i.memo(ie);function ce(e){const t=M(({mapLib:n})=>new n.FullscreenControl({container:e.containerId&&document.getElementById(e.containerId)}),{position:e.position});return i.useEffect(()=>{L(t._controlContainer,e.style)},[e.style]),null}i.memo(ce);function le(e,t){const n=i.useRef({props:e}),s=M(({mapLib:o})=>{const r=new o.GeolocateControl(e),a=r._setupUI;return r._setupUI=()=>{r._container.hasChildNodes()||a()},r.on("geolocate",c=>{var u,l;(l=(u=n.current.props).onGeolocate)==null||l.call(u,c)}),r.on("error",c=>{var u,l;(l=(u=n.current.props).onError)==null||l.call(u,c)}),r.on("outofmaxbounds",c=>{var u,l;(l=(u=n.current.props).onOutOfMaxBounds)==null||l.call(u,c)}),r.on("trackuserlocationstart",c=>{var u,l;(l=(u=n.current.props).onTrackUserLocationStart)==null||l.call(u,c)}),r.on("trackuserlocationend",c=>{var u,l;(l=(u=n.current.props).onTrackUserLocationEnd)==null||l.call(u,c)}),r},{position:e.position});return n.current.props=e,i.useImperativeHandle(t,()=>s,[]),i.useEffect(()=>{L(s._container,e.style)},[e.style]),null}i.memo(i.forwardRef(le));function ue(e){const t=M(({mapLib:n})=>new n.NavigationControl(e),{position:e.position});return i.useEffect(()=>{L(t._container,e.style)},[e.style]),null}i.memo(ue);function fe(e){const t=M(({mapLib:r})=>new r.ScaleControl(e),{position:e.position}),n=i.useRef(e),s=n.current;n.current=e;const{style:o}=e;return e.maxWidth!==void 0&&e.maxWidth!==s.maxWidth&&(t.options.maxWidth=e.maxWidth),e.unit!==void 0&&e.unit!==s.unit&&t.setUnit(e.unit),i.useEffect(()=>{L(t._container,o)},[o]),null}const ke=i.memo(fe);function de(e){const t=M(({mapLib:n})=>new n.TerrainControl(e),{position:e.position});return i.useEffect(()=>{L(t._container,e.style)},[e.style]),null}i.memo(de);function me(e){const t=M(({mapLib:n})=>new n.LogoControl(e),{position:e.position});return i.useEffect(()=>{L(t._container,e.style)},[e.style]),null}i.memo(me);function R(e,t){if(!e)throw new Error(t)}let ye=0;function ge(e,t,n){if(e.style&&e.style._loaded){const s={...n};return delete s.id,delete s.children,e.addSource(t,s),e.getSource(t)}return null}function he(e,t,n){var a,c,u;R(t.id===n.id,"source id changed"),R(t.type===n.type,"source type changed");let s="",o=0;for(const l in t)l!=="children"&&l!=="id"&&!v(n[l],t[l])&&(s=l,o++);if(!o)return;const r=t.type;if(r==="geojson")e.setData(t.data);else if(r==="image")e.updateImage({url:t.url,coordinates:t.coordinates});else switch(s){case"coordinates":(a=e.setCoordinates)==null||a.call(e,t.coordinates);break;case"url":(c=e.setUrl)==null||c.call(e,t.url);break;case"tiles":(u=e.setTiles)==null||u.call(e,t.tiles);break;default:console.warn(`Unable to update prop: ${s}`)}}function Re(e){const t=i.useContext(w).map.getMap(),n=i.useRef(e),[,s]=i.useState(0),o=i.useMemo(()=>e.id||`jsx-source-${ye++}`,[]);i.useEffect(()=>{if(t){const a=()=>setTimeout(()=>s(c=>c+1),0);return t.on("styledata",a),a(),()=>{var c;if(t.off("styledata",a),t.style&&t.style._loaded&&t.getSource(o)){const u=(c=t.getStyle())==null?void 0:c.layers;if(u)for(const l of u)l.source===o&&t.removeLayer(l.id);t.removeSource(o)}}}},[t]);let r=t&&t.style&&t.getSource(o);return r?he(r,e,n.current):r=ge(t,o,e),n.current=e,r&&i.Children.map(e.children,a=>a&&i.cloneElement(a,{source:o}))||null}function pe(e,t,n,s){if(R(n.id===s.id,"layer id changed"),R(n.type===s.type,"layer type changed"),n.type==="custom"||s.type==="custom")return;const{layout:o={},paint:r={},filter:a,minzoom:c,maxzoom:u,beforeId:l}=n;if(l!==s.beforeId&&e.moveLayer(t,l),o!==s.layout){const d=s.layout||{};for(const f in o)v(o[f],d[f])||e.setLayoutProperty(t,f,o[f]);for(const f in d)o.hasOwnProperty(f)||e.setLayoutProperty(t,f,void 0)}if(r!==s.paint){const d=s.paint||{};for(const f in r)v(r[f],d[f])||e.setPaintProperty(t,f,r[f]);for(const f in d)r.hasOwnProperty(f)||e.setPaintProperty(t,f,void 0)}v(a,s.filter)||e.setFilter(t,a),(c!==s.minzoom||u!==s.maxzoom)&&e.setLayerZoomRange(t,c,u)}function ve(e,t,n){if(e.style&&e.style._loaded&&(!("source"in n)||e.getSource(n.source))){const s={...n,id:t};delete s.beforeId,e.addLayer(s,n.beforeId)}}let _e=0;function Ie(e){const t=i.useContext(w).map.getMap(),n=i.useRef(e),[,s]=i.useState(0),o=i.useMemo(()=>e.id||`jsx-layer-${_e++}`,[]);if(i.useEffect(()=>{if(t){const a=()=>s(c=>c+1);return t.on("styledata",a),a(),()=>{t.off("styledata",a),t.style&&t.style._loaded&&t.getLayer(o)&&t.removeLayer(o)}}},[t]),t&&t.style&&t.getLayer(o))try{pe(t,o,e,n.current)}catch(a){console.warn(a)}else ve(t,o,e);return n.current=e,null}const V="pymc-basemap-mode",j="dark";function Le(){if(typeof window>"u")return j;try{const e=localStorage.getItem(V);if(e==="light"||e==="dark")return e}catch{}return j}function W(e){if(!(typeof window>"u"))try{localStorage.setItem(V,e)}catch{}}const q=G(e=>({mode:Le(),toggle:()=>e(t=>{const n=t.mode==="light"?"dark":"light";return W(n),{mode:n}}),setMode:t=>{W(t),e({mode:t})}})),Te=()=>q(e=>e.mode),Pe=()=>q(e=>e.toggle),Ce={light:"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",dark:"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json"},Se={light:"basemap-light-",dark:"basemap-dark-"},I={};async function Ee(e){if(I[e])return I[e];const n=await(await fetch(Ce[e])).json();return I[e]=n,n}function ze({mode:e}){const{current:t}=K(),[n,s]=i.useState(null),o=i.useRef({light:!1,dark:!1}),r=i.useRef({light:[],dark:[]});i.useEffect(()=>{const l=()=>{var y;const m=(y=t==null?void 0:t.getMap)==null?void 0:y.call(t);m&&!n&&s(m)};l();const d=setInterval(l,50),f=setTimeout(()=>clearInterval(d),5e3);return()=>{clearInterval(d),clearTimeout(f)}},[t,n]);const a=i.useCallback(async(l,d,f)=>{var E,k;if(o.current[d])return;const m=Se[d],y=await Ee(d),C=[];for(const[p,h]of Object.entries(y.sources||{})){const g=m+p;l.getSource(g)||l.addSource(g,h)}const x=(k=(((E=l.getStyle())==null?void 0:E.layers)||[]).find(p=>!p.id.startsWith("basemap-light-")&&!p.id.startsWith("basemap-dark-")))==null?void 0:k.id;for(const p of y.layers||[]){const h=m+p.id;if(C.push(h),l.getLayer(h))continue;const g={...p,id:h};"source"in g&&typeof g.source=="string"&&(g.source=m+g.source),g.layout||(g.layout={}),g.layout.visibility=f?"visible":"none";try{l.addLayer(g,x)}catch(_){console.warn(`[BasemapLayer] Failed to add layer ${h}:`,_)}}r.current[d]=C,o.current[d]=!0},[]),c=i.useCallback((l,d,f)=>{const m=r.current[d],y=f?"visible":"none";for(const C of m)if(l.getLayer(C))try{l.setLayoutProperty(C,"visibility",y)}catch{}},[]),u=i.useCallback(l=>{var m;const f=(((m=l.getStyle())==null?void 0:m.layers)||[]).filter(y=>!y.id.startsWith("basemap-light-")&&!y.id.startsWith("basemap-dark-"));for(const y of f)try{l.moveLayer(y.id)}catch{}},[]);return i.useEffect(()=>{if(!n)return;const l=d=>{n.hasImage(d.id)||n.addImage(d.id,{width:1,height:1,data:new Uint8Array([0,0,0,0])})};return n.on("styleimagemissing",l),()=>{n.off("styleimagemissing",l)}},[n]),i.useEffect(()=>{if(!n)return;let l=!1;const d=async()=>{if(!l)try{await Promise.all([a(n,"light",e==="light"),a(n,"dark",e==="dark")]),l||u(n)}catch(m){console.error("[BasemapLayer] Setup error:",m)}};n.isStyleLoaded()?d():(n.once("style.load",d),n.once("load",()=>{!l&&!o.current.light&&d()}));const f=()=>{l||setTimeout(()=>{!l&&o.current.light&&o.current.dark&&u(n)},100)};return n.on("styledata",f),()=>{l=!0,n.off("styledata",f)}},[n,a,u,e]),i.useEffect(()=>{n&&(!o.current.light||!o.current.dark||(c(n,"light",e==="light"),c(n,"dark",e==="dark")))},[n,e,c]),null}export{ze as B,Ie as L,Me as M,xe as P,Re as S,be as a,K as b,Pe as c,ke as d,Te as u}; diff --git a/frontend/dist/assets/ChatBubble-0UYYugYB.js b/frontend/dist/assets/ChatBubble-Bxq40Qnq.js similarity index 93% rename from frontend/dist/assets/ChatBubble-0UYYugYB.js rename to frontend/dist/assets/ChatBubble-Bxq40Qnq.js index 2196f3db..620a649e 100644 --- a/frontend/dist/assets/ChatBubble-0UYYugYB.js +++ b/frontend/dist/assets/ChatBubble-Bxq40Qnq.js @@ -1,4 +1,4 @@ -import{d as h,r as u,j as e,c as t}from"./index-C8IY8K2r.js";import{e as f,g as p,a as g,b as j,f as b}from"./chat-utils-D1Q4VWjO.js";/** +import{d as h,r as u,j as e,c as t}from"./index-BwGHI0A_.js";import{e as f,g as p,a as g,b as j,f as b}from"./chat-utils-Di4-nywi.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/CollisionExplorerModal-DeHgfjGl.js b/frontend/dist/assets/CollisionExplorerModal-Cm5c7tcU.js similarity index 92% rename from frontend/dist/assets/CollisionExplorerModal-DeHgfjGl.js rename to frontend/dist/assets/CollisionExplorerModal-Cm5c7tcU.js index 5159e994..d5c61420 100644 --- a/frontend/dist/assets/CollisionExplorerModal-DeHgfjGl.js +++ b/frontend/dist/assets/CollisionExplorerModal-Cm5c7tcU.js @@ -1,6 +1,6 @@ -import{d as k,r as c,E as L,bB as S,H,j as e,ac as R,ad as T,bp as B,c as N,q as w,w as E,x as _,bL as D}from"./index-C8IY8K2r.js";import{u as I,M as P,B as q,S as z,L as W,a as U}from"./BasemapLayer-D5WYHXmJ.js";import{T as F}from"./triangle-alert-8k00uu7o.js";import{M as A}from"./map-pin-DMVHq6j8.js";import{M as Y}from"./monitor-smartphone-DF_mmgOV.js";/** +import{d as k,r as c,E as L,bE as S,H,j as e,ac as R,ad as T,br as E,c as N,q as w,w as B,x as _,bO as D}from"./index-BwGHI0A_.js";import{u as I,M as P,B as q,S as z,L as W,a as U}from"./BasemapLayer-Bm_seLWQ.js";import{T as F}from"./triangle-alert-B4kC1YDk.js";import{M as A}from"./map-pin-VRY_TOuh.js";import{M as Y}from"./monitor-smartphone-BxljwdQV.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 $=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],G=k("share-2",$);function J(n){var f;return(f=navigator.clipboard)!=null&&f.writeText?(navigator.clipboard.writeText(n).catch(()=>{}),!0):!1}const Q={version:8,sources:{},layers:[],glyphs:"https://tiles.basemaps.cartocdn.com/fonts/{fontstack}/{range}.pbf"};function M({node:n,isHovered:f,onHover:g}){const[y,p]=c.useState(!1),j=c.useCallback(d=>{d.stopPropagation(),J(n.hash),p(!0),setTimeout(()=>p(!1),2e3)},[n.hash]),h=n.contactType.toLowerCase(),m=h.includes("room")||h.includes("server"),o=h==="companion"||h==="client";let r=G,l="text-sys-blue";return m?(r=D,l="text-signal-fair"):o?(r=Y,l="text-fg-muted"):n.isNeighbor&&(l="text-sys-green"),e.jsxs("div",{className:N("flex items-center gap-3 px-3 py-2.5 radius-inner transition-base cursor-pointer",f?"bg-sys-blue/10":"hover:bg-subtle-fill"),onMouseEnter:()=>g(n.hash),onMouseLeave:()=>g(null),children:[e.jsx(r,{className:N("w-4 h-4 flex-shrink-0",l)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"type-label text-fg-primary truncate",children:n.name}),n.isNeighbor&&e.jsx(w,{color:"green",compact:!0,children:"NBR"}),n.isRepeater&&e.jsx(w,{color:"zinc",compact:!0,children:"RPT"}),n.isHub&&e.jsx(w,{color:"indigo",compact:!0,children:"HUB"})]}),e.jsxs("button",{onClick:j,className:N("mt-1 inline-flex items-center gap-1 type-data-xs px-1.5 py-0.5 rounded","border transition-all cursor-pointer",y?"border-sys-green/50 bg-sys-green/10 text-sys-green":"border-edge-subtle bg-subtle/50 text-fg-muted hover:border-edge-strong"),title:`Copy: ${n.hash}`,children:[n.hash.slice(0,12),"…",y?e.jsx(E,{className:"w-2.5 h-2.5"}):e.jsx(_,{className:"w-2.5 h-2.5 opacity-50"})]})]})]})}function C({nodes:n,hoveredHash:f,onHover:g}){const y=I(),p=c.useRef(null),j=B(),[h,m]=c.useState(!1),o=c.useMemo(()=>n.filter(a=>a.latitude!=null&&a.longitude!=null&&(a.latitude!==0||a.longitude!==0)),[n]),r=c.useMemo(()=>{if(o.length===0)return null;let a=1/0,s=-1/0,t=1/0,i=-1/0;for(const x of o)a=Math.min(a,x.longitude),s=Math.max(s,x.longitude),t=Math.min(t,x.latitude),i=Math.max(i,x.latitude);const u=.01;if(i-tr?{longitude:(r[0][0]+r[1][0])/2,latitude:(r[0][1]+r[1][1])/2}:{longitude:0,latitude:0},[r]),d=c.useMemo(()=>{if(o.length<2)return null;const a=[];for(let s=0;s{var s;const a=(s=p.current)==null?void 0:s.getMap();if(!a||!r){m(!0);return}a.fitBounds(r,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:13,duration:0}),setTimeout(()=>m(!0),50)},[r]),b=j&&h;return o.length===0?e.jsx("div",{className:"h-full flex items-center justify-center bg-subtle/30 radius-inner",children:e.jsxs("div",{className:"text-center text-fg-secondary p-4",children:[e.jsx(A,{className:"w-8 h-8 mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No location data available"})]})}):e.jsxs("div",{className:"h-full w-full relative radius-inner overflow-hidden bg-elevated",children:[e.jsx("div",{className:N("absolute inset-0 flex items-center justify-center z-10","transition-opacity duration-200 pointer-events-none",b?"opacity-0":"opacity-100 bg-elevated"),children:e.jsx("div",{className:"w-5 h-5 border-2 border-text-muted/30 border-t-text-muted rounded-full animate-spin"})}),e.jsx("div",{className:N("h-full w-full transition-opacity duration-200",b?"opacity-100":"opacity-0"),children:e.jsxs(P,{ref:p,initialViewState:{longitude:l.longitude,latitude:l.latitude,zoom:10},style:{height:"100%",width:"100%"},mapStyle:Q,attributionControl:!1,onLoad:v,children:[e.jsx(q,{mode:y}),d&&e.jsx(z,{id:"collision-edges",type:"geojson",data:d,children:e.jsx(W,{id:"collision-edges-line",type:"line",paint:{"line-color":"#3B3F4A","line-width":2,"line-opacity":.8},layout:{"line-cap":"round","line-join":"round"}})}),o.map(a=>{const s=a.hash===f,t=a.hash.startsWith("0x")?a.hash.slice(2,4).toUpperCase():a.hash.slice(0,2).toUpperCase();return e.jsx(U,{longitude:a.longitude,latitude:a.latitude,anchor:"center",children:e.jsx("div",{className:"cursor-pointer transition-all duration-150",onMouseEnter:()=>g(a.hash),onMouseLeave:()=>g(null),style:{pointerEvents:"auto"},children:e.jsxs(w,{color:"amber",filled:!0,className:"type-data-xs shadow-lg",children:[t,s&&e.jsx("span",{className:"ml-1 opacity-75 font-sans",children:a.name})]})})},a.hash)})]})})]})}function V({isOpen:n,prefix:f,candidateHashes:g,onClose:y}){const p=L(),j=S(),h=H(),[m,o]=c.useState(null),r=c.useMemo(()=>new Set(h.map(s=>s.hash)),[h]),l=(p==null?void 0:p.neighbors)??{},d=c.useMemo(()=>{const s=t=>{if(l[t])return l[t];if(!t.startsWith("0x")&&l["0x"+t])return l["0x"+t];if(t.startsWith("0x")&&l[t.slice(2)])return l[t.slice(2)]};return g.map(t=>{var u;const i=s(t);return{hash:t,name:(i==null?void 0:i.node_name)||(i==null?void 0:i.name)||`Unknown (${t.slice(0,8)}…)`,contactType:(i==null?void 0:i.contact_type)||"",isRepeater:(i==null?void 0:i.is_repeater)||((u=i==null?void 0:i.contact_type)==null?void 0:u.toLowerCase())==="repeater"||!1,isNeighbor:r.has(t)||r.has("0x"+t)||r.has(t.replace(/^0x/,"")),isHub:j.has(t),latitude:i==null?void 0:i.latitude,longitude:i==null?void 0:i.longitude}}).sort((t,i)=>t.isNeighbor!==i.isNeighbor?t.isNeighbor?-1:1:t.isHub!==i.isHub?t.isHub?-1:1:t.name.localeCompare(i.name))},[g,l,r,j]),v=c.useMemo(()=>d.some(s=>s.latitude!=null&&s.longitude!=null&&(s.latitude!==0||s.longitude!==0)),[d]),b=c.useCallback(s=>{o(s)},[]),a=v?"4xl":"lg";return n?e.jsxs(R,{open:n,onClose:y,size:a,motionPlus:!0,className:v?"sm:h-[500px] sm:max-h-[600px]":"",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-edge-subtle",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 radius-inner bg-signal-fair/10",children:e.jsx(F,{className:"w-5 h-5 text-signal-fair"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"type-micro",children:["Prefix Collision: ",e.jsx("span",{className:"font-mono text-sys-blue",children:f})]}),e.jsxs("p",{className:"text-xs text-fg-secondary",children:[d.length," nodes share this prefix"]})]})]}),e.jsx("button",{onClick:y,className:"sm:hidden min-h-[44px] min-w-[44px] px-3 flex items-center justify-center text-[15px] font-medium text-sys-blue active:text-sys-blue/70 transition-base radius-inner active:bg-subtle-fill",children:"Done"}),e.jsx("button",{onClick:y,className:"hidden sm:flex items-center justify-center p-2 text-fg-muted hover:text-fg-primary transition-base radius-inner hover:bg-subtle","aria-label":"Close",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs(T,{className:"p-0 overflow-hidden flex-1 flex flex-col min-h-0",children:[e.jsxs("div",{className:"sm:hidden flex-1 overflow-y-auto",children:[v&&e.jsx("div",{className:"h-64 p-2 border-b border-edge-subtle",children:e.jsx(C,{nodes:d,hoveredHash:m,onHover:b})}),e.jsx("div",{className:"p-2",children:d.map(s=>e.jsx(M,{node:s,isHovered:m===s.hash,onHover:b},s.hash))})]}),v?e.jsxs("div",{className:"hidden sm:grid sm:grid-cols-[280px_minmax(400px,1fr)] flex-1 overflow-hidden sm:min-w-[700px]",children:[e.jsx("div",{className:"overflow-y-auto border-r border-edge-subtle",children:e.jsx("div",{className:"p-2",children:d.map(s=>e.jsx(M,{node:s,isHovered:m===s.hash,onHover:b},s.hash))})}),e.jsx("div",{className:"overflow-hidden p-2",children:e.jsx(C,{nodes:d,hoveredHash:m,onHover:b})})]}):e.jsx("div",{className:"hidden sm:block flex-1 overflow-y-auto",children:e.jsx("div",{className:"p-2",children:d.map(s=>e.jsx(M,{node:s,isHovered:m===s.hash,onHover:b},s.hash))})})]})]}):null}const se=c.memo(V);export{se as C,G as S}; + */const $=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],G=k("share-2",$);function J(n){var f;return(f=navigator.clipboard)!=null&&f.writeText?(navigator.clipboard.writeText(n).catch(()=>{}),!0):!1}const O={version:8,sources:{},layers:[],glyphs:"https://tiles.basemaps.cartocdn.com/fonts/{fontstack}/{range}.pbf"};function M({node:n,isHovered:f,onHover:g}){const[y,p]=c.useState(!1),j=c.useCallback(d=>{d.stopPropagation(),J(n.hash),p(!0),setTimeout(()=>p(!1),2e3)},[n.hash]),h=n.contactType.toLowerCase(),m=h.includes("room")||h.includes("server"),o=h==="companion"||h==="client";let r=G,l="text-sys-blue";return m?(r=D,l="text-signal-fair"):o?(r=Y,l="text-fg-muted"):n.isNeighbor&&(l="text-sys-green"),e.jsxs("div",{className:N("flex items-center gap-3 px-3 py-2.5 radius-inner transition-base cursor-pointer",f?"bg-sys-blue/10":"hover:bg-subtle-fill"),onMouseEnter:()=>g(n.hash),onMouseLeave:()=>g(null),children:[e.jsx(r,{className:N("w-4 h-4 flex-shrink-0",l)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"type-label text-fg-primary truncate",children:n.name}),n.isNeighbor&&e.jsx(w,{color:"green",compact:!0,children:"NBR"}),n.isRepeater&&e.jsx(w,{color:"zinc",compact:!0,children:"RPT"}),n.isHub&&e.jsx(w,{color:"indigo",compact:!0,children:"HUB"})]}),e.jsxs("button",{onClick:j,className:N("mt-1 inline-flex items-center gap-1 type-data-xs px-1.5 py-0.5 rounded","border transition-all cursor-pointer",y?"border-sys-green/50 bg-sys-green/10 text-sys-green":"border-edge-subtle bg-subtle/50 text-fg-muted hover:border-edge-strong"),title:`Copy: ${n.hash}`,children:[n.hash.slice(0,12),"…",y?e.jsx(B,{className:"w-2.5 h-2.5"}):e.jsx(_,{className:"w-2.5 h-2.5 opacity-50"})]})]})]})}function C({nodes:n,hoveredHash:f,onHover:g}){const y=I(),p=c.useRef(null),j=E(),[h,m]=c.useState(!1),o=c.useMemo(()=>n.filter(a=>a.latitude!=null&&a.longitude!=null&&(a.latitude!==0||a.longitude!==0)),[n]),r=c.useMemo(()=>{if(o.length===0)return null;let a=1/0,s=-1/0,t=1/0,i=-1/0;for(const x of o)a=Math.min(a,x.longitude),s=Math.max(s,x.longitude),t=Math.min(t,x.latitude),i=Math.max(i,x.latitude);const u=.01;if(i-tr?{longitude:(r[0][0]+r[1][0])/2,latitude:(r[0][1]+r[1][1])/2}:{longitude:0,latitude:0},[r]),d=c.useMemo(()=>{if(o.length<2)return null;const a=[];for(let s=0;s{var s;const a=(s=p.current)==null?void 0:s.getMap();if(!a||!r){m(!0);return}a.fitBounds(r,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:13,duration:0}),setTimeout(()=>m(!0),50)},[r]),b=j&&h;return o.length===0?e.jsx("div",{className:"h-full flex items-center justify-center bg-subtle/30 radius-inner",children:e.jsxs("div",{className:"text-center text-fg-secondary p-4",children:[e.jsx(A,{className:"w-8 h-8 mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No location data available"})]})}):e.jsxs("div",{className:"h-full w-full relative radius-inner overflow-hidden bg-elevated",children:[e.jsx("div",{className:N("absolute inset-0 flex items-center justify-center z-10","transition-opacity duration-200 pointer-events-none",b?"opacity-0":"opacity-100 bg-elevated"),children:e.jsx("div",{className:"w-5 h-5 border-2 border-text-muted/30 border-t-text-muted rounded-full animate-spin"})}),e.jsx("div",{className:N("h-full w-full transition-opacity duration-200",b?"opacity-100":"opacity-0"),children:e.jsxs(P,{ref:p,initialViewState:{longitude:l.longitude,latitude:l.latitude,zoom:10},style:{height:"100%",width:"100%"},mapStyle:O,attributionControl:!1,onLoad:v,children:[e.jsx(q,{mode:y}),d&&e.jsx(z,{id:"collision-edges",type:"geojson",data:d,children:e.jsx(W,{id:"collision-edges-line",type:"line",paint:{"line-color":"#3B3F4A","line-width":2,"line-opacity":.8},layout:{"line-cap":"round","line-join":"round"}})}),o.map(a=>{const s=a.hash===f,t=a.hash.startsWith("0x")?a.hash.slice(2,4).toUpperCase():a.hash.slice(0,2).toUpperCase();return e.jsx(U,{longitude:a.longitude,latitude:a.latitude,anchor:"center",children:e.jsx("div",{className:"cursor-pointer transition-all duration-150",onMouseEnter:()=>g(a.hash),onMouseLeave:()=>g(null),style:{pointerEvents:"auto"},children:e.jsxs(w,{color:"amber",filled:!0,className:"type-data-xs shadow-lg",children:[t,s&&e.jsx("span",{className:"ml-1 opacity-75 font-sans",children:a.name})]})})},a.hash)})]})})]})}function Q({isOpen:n,prefix:f,candidateHashes:g,onClose:y}){const p=L(),j=S(),h=H(),[m,o]=c.useState(null),r=c.useMemo(()=>new Set(h.map(s=>s.hash)),[h]),l=(p==null?void 0:p.neighbors)??{},d=c.useMemo(()=>{const s=t=>{if(l[t])return l[t];if(!t.startsWith("0x")&&l["0x"+t])return l["0x"+t];if(t.startsWith("0x")&&l[t.slice(2)])return l[t.slice(2)]};return g.map(t=>{var u;const i=s(t);return{hash:t,name:(i==null?void 0:i.node_name)||(i==null?void 0:i.name)||`Unknown (${t.slice(0,8)}…)`,contactType:(i==null?void 0:i.contact_type)||"",isRepeater:(i==null?void 0:i.is_repeater)||((u=i==null?void 0:i.contact_type)==null?void 0:u.toLowerCase())==="repeater"||!1,isNeighbor:r.has(t)||r.has("0x"+t)||r.has(t.replace(/^0x/,"")),isHub:j.has(t),latitude:i==null?void 0:i.latitude,longitude:i==null?void 0:i.longitude}}).sort((t,i)=>t.isNeighbor!==i.isNeighbor?t.isNeighbor?-1:1:t.isHub!==i.isHub?t.isHub?-1:1:t.name.localeCompare(i.name))},[g,l,r,j]),v=c.useMemo(()=>d.some(s=>s.latitude!=null&&s.longitude!=null&&(s.latitude!==0||s.longitude!==0)),[d]),b=c.useCallback(s=>{o(s)},[]),a=v?"4xl":"lg";return n?e.jsxs(R,{open:n,onClose:y,size:a,motionPlus:!0,className:v?"sm:h-[500px] sm:max-h-[600px]":"",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-edge-subtle",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 radius-inner bg-signal-fair/10",children:e.jsx(F,{className:"w-5 h-5 text-signal-fair"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"type-micro",children:["Prefix Collision: ",e.jsx("span",{className:"font-mono text-sys-blue",children:f})]}),e.jsxs("p",{className:"text-xs text-fg-secondary",children:[d.length," nodes share this prefix"]})]})]}),e.jsx("button",{onClick:y,className:"sm:hidden min-h-[44px] min-w-[44px] px-3 flex items-center justify-center text-[15px] font-medium text-sys-blue active:text-sys-blue/70 transition-base radius-inner active:bg-subtle-fill",children:"Done"}),e.jsx("button",{onClick:y,className:"hidden sm:flex items-center justify-center p-2 text-fg-muted hover:text-fg-primary transition-base radius-inner hover:bg-subtle","aria-label":"Close",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs(T,{className:"p-0 overflow-hidden flex-1 flex flex-col min-h-0",children:[e.jsxs("div",{className:"sm:hidden flex-1 overflow-y-auto",children:[v&&e.jsx("div",{className:"h-64 p-2 border-b border-edge-subtle",children:e.jsx(C,{nodes:d,hoveredHash:m,onHover:b})}),e.jsx("div",{className:"p-2",children:d.map(s=>e.jsx(M,{node:s,isHovered:m===s.hash,onHover:b},s.hash))})]}),v?e.jsxs("div",{className:"hidden sm:grid sm:grid-cols-[280px_minmax(400px,1fr)] flex-1 overflow-hidden sm:min-w-[700px]",children:[e.jsx("div",{className:"overflow-y-auto border-r border-edge-subtle",children:e.jsx("div",{className:"p-2",children:d.map(s=>e.jsx(M,{node:s,isHovered:m===s.hash,onHover:b},s.hash))})}),e.jsx("div",{className:"overflow-hidden p-2",children:e.jsx(C,{nodes:d,hoveredHash:m,onHover:b})})]}):e.jsx("div",{className:"hidden sm:block flex-1 overflow-y-auto",children:e.jsx("div",{className:"p-2",children:d.map(s=>e.jsx(M,{node:s,isHovered:m===s.hash,onHover:b},s.hash))})})]})]}):null}const se=c.memo(Q);export{se as C,G as S}; diff --git a/frontend/dist/assets/Configuration-DbTSQonP.js b/frontend/dist/assets/Configuration-eqZcR8dI.js similarity index 98% rename from frontend/dist/assets/Configuration-DbTSQonP.js rename to frontend/dist/assets/Configuration-eqZcR8dI.js index 925d9dee..d2ba2f9c 100644 --- a/frontend/dist/assets/Configuration-DbTSQonP.js +++ b/frontend/dist/assets/Configuration-eqZcR8dI.js @@ -1,5 +1,5 @@ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/latin-400-BcR6IdUc.css","assets/latin-500-DCnAHIrw.css","assets/latin-600-CnkPk-vb.css","assets/latin-700-UC1i-VSI.css"])))=>i.map(i=>d[i]); -import{d as ue,r as t,j as e,c as l,L as $,w as B,bc as J,ae as Ss,dA as Ee,dB as es,dC as Je,bo as Se,T as ie,M as Zs,S as et,dD as st,F as X,cb as Qe,bN as tt,v as at,dE as Ts,dF as nt,dG as lt,dH as rt,R as it,B as F,dI as $e,I as ot,x as ct}from"./index-C8IY8K2r.js";import{g as dt,a as ut,c as mt,r as xt,s as ft,b as ht,u as pt,d as yt}from"./system-D5HdVkRh.js";import{T as Ps,C as gt}from"./ConfirmModal-CNsW1W2q.js";import{N as bt}from"./NodeInformationCard-p2ujbtr-.js";import{i as jt,g as vt,s as Nt,a as kt,k as wt}from"./keycap-sfx-ByZp-njj.js";import{C as Y,P as Ct,a as St,B as Tt}from"./PageLayout-NQBVrM09.js";import{R as te,C as Te}from"./Grid-CEGkNRmt.js";import{A as _t}from"./antenna-DOuH490Q.js";import{P as _s}from"./plus-PWV57wbr.js";import{K as qe}from"./key-round-CQ-pu-yY.js";import{C as Ft}from"./circle-check-BOp4wLxA.js";import{T as Ge}from"./triangle-alert-8k00uu7o.js";import{R as Et}from"./refresh-cw-BqACEANM.js";import{C as Rt}from"./chevron-right-DUgYTR6d.js";import"./DataBox-W2v3wy8k.js";/** +import{d as ue,r as t,j as e,c as l,L as $,w as B,bc as J,ae as Ss,dF as Ee,dG as es,dH as Je,bo as Se,T as ie,M as Zs,S as et,dI as st,F as X,ce as Qe,bQ as tt,v as at,dJ as Ts,dK as nt,dL as lt,dM as rt,R as it,B as F,dN as $e,I as ot,x as ct}from"./index-BwGHI0A_.js";import{g as dt,a as ut,c as mt,r as xt,s as ft,b as ht,u as pt,d as yt}from"./system-oD9MKxRy.js";import{T as Ps,C as gt}from"./ConfirmModal-B0nTD1Q0.js";import{N as bt}from"./NodeInformationCard-BLxCCOW5.js";import{i as jt,g as vt,s as Nt,a as kt,k as wt}from"./keycap-sfx-ByZp-njj.js";import{C as Y,P as Ct,a as St,B as Tt}from"./PageLayout-BIcqC04y.js";import{R as te,C as Te}from"./Grid-BoZ-SJB7.js";import{A as _t}from"./antenna-zVXb9cuG.js";import{P as _s}from"./plus-C0xom_iW.js";import{K as qe}from"./key-round-DKeM0xKx.js";import{C as Ft}from"./circle-check-CBI-CiRo.js";import{T as Ge}from"./triangle-alert-B4kC1YDk.js";import{R as Et}from"./refresh-cw-DYpAqCT4.js";import{C as Rt}from"./chevron-right-DqpRZiGf.js";import"./DataBox-CQS-Zhu0.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/ConfirmModal-CNsW1W2q.js b/frontend/dist/assets/ConfirmModal-B0nTD1Q0.js similarity index 83% rename from frontend/dist/assets/ConfirmModal-CNsW1W2q.js rename to frontend/dist/assets/ConfirmModal-B0nTD1Q0.js index 60b15aaa..9990ead1 100644 --- a/frontend/dist/assets/ConfirmModal-CNsW1W2q.js +++ b/frontend/dist/assets/ConfirmModal-B0nTD1Q0.js @@ -1,6 +1,6 @@ -import{d as l,r as m,j as s,ac as x,dr as h,c as p,ad as f,dK as g,B as o}from"./index-C8IY8K2r.js";import{T as j}from"./triangle-alert-8k00uu7o.js";/** +import{d as l,r as m,j as s,ac as x,dw as h,c as p,ad as f,dP as g,B as o}from"./index-BwGHI0A_.js";import{T as j}from"./triangle-alert-B4kC1YDk.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 u=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],M=l("trash-2",u),y={danger:"text-sys-red",warning:"text-sys-indigo",default:"text-sys-blue"},C={danger:"danger",warning:"warning",default:"primary"};function N({isOpen:t,title:n="Confirm",message:r,confirmLabel:i="Confirm",cancelLabel:c="Cancel",variant:e="default",onConfirm:d,onCancel:a}){return s.jsxs(x,{open:t,onClose:a,size:"sm",children:[s.jsx(h,{icon:s.jsx(j,{className:p("w-5 h-5",y[e])}),title:n,onClose:a}),s.jsx(f,{children:s.jsx("p",{className:"text-sm text-fg-secondary",children:r})}),s.jsxs(g,{children:[s.jsx(o,{color:"muted",onClick:a,className:"flex-1",children:c}),s.jsx(o,{color:C[e],onClick:d,className:"flex-1",children:i})]})]})}const A=m.memo(N);export{A as C,M as T}; + */const u=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],M=l("trash-2",u),y={danger:"text-sys-red",warning:"text-sys-indigo",default:"text-sys-blue"},C={danger:"danger",warning:"warning",default:"primary"};function N({isOpen:t,title:n="Confirm",message:r,confirmLabel:i="Confirm",cancelLabel:c="Cancel",variant:e="default",onConfirm:d,onCancel:a}){return s.jsxs(x,{open:t,onClose:a,size:"sm",children:[s.jsx(h,{icon:s.jsx(j,{className:p("w-5 h-5",y[e])}),title:n,onClose:a}),s.jsx(f,{children:s.jsx("p",{className:"text-sm text-fg-secondary",children:r})}),s.jsxs(g,{children:[s.jsx(o,{color:"muted",onClick:a,className:"flex-1",children:c}),s.jsx(o,{color:C[e],onClick:d,className:"flex-1",children:i})]})]})}const w=m.memo(N);export{w as C,M as T}; diff --git a/frontend/dist/assets/Contacts-CKgzKZ-Z.js b/frontend/dist/assets/Contacts-CKgzKZ-Z.js deleted file mode 100644 index 5ffdeda5..00000000 --- a/frontend/dist/assets/Contacts-CKgzKZ-Z.js +++ /dev/null @@ -1,47 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ContactsMapMapLibre-CKQy2_cg.js","assets/index-C8IY8K2r.js","assets/BasemapLayer-D5WYHXmJ.js","assets/consumer-registry-lDKP4bcU.js","assets/link-scoring-CX7bMGSJ.js","assets/ConfirmModal-CNsW1W2q.js","assets/triangle-alert-8k00uu7o.js","assets/DeepAnalysisModal-B2m7JxOp.js","assets/geo-utils-BP1zBK9h.js","assets/download-IUkhheKK.js","assets/database-BEyHF_p_.js","assets/useMapViewStore-ax-BqDpg.js","assets/index-B-prVW1V.js","assets/refresh-cw-BqACEANM.js","assets/target-DviLCm8U.js","assets/funnel-BDRRJl0y.js","assets/plus-PWV57wbr.js","assets/easing-CXN4GmUW.js","assets/wifi-Cq9uCDyf.js","assets/SignalIndicator-Dw_bfp50.js","assets/chevron-right-DUgYTR6d.js","assets/node-types-3T9Wr7vI.js","assets/badge-colors-BNUqIXCA.js","assets/LightSparkline-CkL4j4OZ.js","assets/map-pin-DMVHq6j8.js","assets/ping-lLlOzF2r.js","assets/PageLayout-NQBVrM09.js","assets/listbox-BhQdM5DY.js","assets/element-movement-D4o83B2Z.js","assets/TimeRangeStepper-BlC9rlkV.js","assets/chat-utils-D1Q4VWjO.js","assets/CollisionExplorerModal-DeHgfjGl.js","assets/monitor-smartphone-DF_mmgOV.js","assets/DataBox-W2v3wy8k.js","assets/circle-question-mark-C7l07_IA.js","assets/network-DBkquEPb.js","assets/activity-2-g8m4_g.js","assets/search-zALFwCS4.js","assets/index-DUfCykEc.css","assets/BasemapLayer-B1CfjdFi.css","assets/ContactsMapMapLibre-BwWOEply.css"])))=>i.map(i=>d[i]); -import{d as O,j as e,r as n,bo as Ze,bI as Te,bJ as $e,$ as ae,w as we,a9 as Re,bK as es,bL as he,R as pe,q as k,bM as ss,L as Ee,bN as ts,J as as,bO as ns,bP as rs,bQ as os,H as is,bR as cs,bS as ls,bT as ds,K as ms,aa as xs,N as Ne,bU as us,bV as ps,b8 as te,o as hs,I as fs,bc as gs,c as ve}from"./index-C8IY8K2r.js";import{p as js}from"./ping-lLlOzF2r.js";import{c as ke}from"./node-types-3T9Wr7vI.js";import{P as bs,a as Ns,B as ys}from"./PageLayout-NQBVrM09.js";import{L as vs,a as ue}from"./listbox-BhQdM5DY.js";import{T as _e}from"./TimeRangeStepper-BlC9rlkV.js";import{u as ws,e as ks,f as Cs,r as Ms}from"./consumer-registry-lDKP4bcU.js";import{e as Ss,g as Ps,a as Rs}from"./chat-utils-D1Q4VWjO.js";import{A as _s,b as Ls,C as Ts}from"./SignalIndicator-Dw_bfp50.js";import{C as $s,S as Es}from"./CollisionExplorerModal-DeHgfjGl.js";import{E as Fs,T as Os}from"./target-DviLCm8U.js";import{D as Hs}from"./DataBox-W2v3wy8k.js";import{C as W}from"./badge-colors-BNUqIXCA.js";import{C as Fe}from"./circle-question-mark-C7l07_IA.js";import{N as zs}from"./network-DBkquEPb.js";import{A as Oe}from"./activity-2-g8m4_g.js";import{T as Ds,C as Is}from"./ConfirmModal-CNsW1W2q.js";import{M as Le}from"./monitor-smartphone-DF_mmgOV.js";import{M as As}from"./map-pin-DMVHq6j8.js";import{S as Bs}from"./search-zALFwCS4.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 Vs=[["path",{d:"M17 7 7 17",key:"15tmo1"}],["path",{d:"M17 17H7V7",key:"1org7z"}]],Us=O("arrow-down-left",Vs);/** - * @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 qs=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],Gs=O("arrow-up-down",qs);/** - * @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 Ws=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],Qs=O("calendar",Ws);/** - * @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 Ks=[["path",{d:"M4 12V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2",key:"jrl274"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 16h2v6",key:"1bxocy"}],["path",{d:"M10 22h4",key:"ceow96"}],["rect",{x:"2",y:"16",width:"4",height:"6",rx:"2",key:"r45zd0"}]],Js=O("file-digit",Ks);/** - * @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 Ys=[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]],Xs=O("list-filter",Ys);/** - * @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 Zs=[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]],et=O("move",Zs);/** - * @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 st=[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]],tt=O("radio-tower",st);/** - * @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 at=[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]],He=O("ruler",at);/** - * @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 nt=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],rt=O("trending-down",nt);class ot extends n.Component{constructor(i){super(i),this.state={hasError:!1}}static getDerivedStateFromError(i){return{hasError:!0,error:i}}render(){var i;return this.state.hasError?e.jsx("div",{className:"map-container-16-9 flex items-center justify-center rounded-2xl surface-base",role:"alert","aria-live":"assertive",children:e.jsxs("div",{className:"text-center text-fg-muted p-4",children:[e.jsx("p",{className:"text-lg mb-2",children:"Map failed to load"}),e.jsx("p",{className:"text-sm text-fg-muted",children:((i=this.state.error)==null?void 0:i.message)||"Unknown error"}),e.jsx("p",{className:"text-xs text-fg-muted mt-2",children:"Try refreshing the page or check your browser's WebGL support."})]})}):this.props.children}}const it=n.lazy(()=>Ze(()=>import("./ContactsMapMapLibre-CKQy2_cg.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40])));function ct({neighbors:r,localNode:i,localHash:f,onRemoveNode:x,selectedNodeHash:g,onNodeSelected:N,highlightedEdgeKey:h,highlightedGhost:d}){return e.jsx(ot,{children:e.jsx(n.Suspense,{fallback:e.jsx("div",{className:"map-container-16-9 flex items-center justify-center rounded-2xl surface-base",role:"status","aria-live":"polite","aria-label":"Loading map",children:e.jsxs("div",{className:"text-fg-muted flex items-center gap-3",children:[e.jsx("div",{className:"w-5 h-5 border-2 border-sys-blue border-t-transparent rounded-full animate-spin","aria-hidden":"true"}),e.jsx("span",{children:"Loading map..."})]})}),children:e.jsx(it,{neighbors:r,localNode:i,localHash:f,onRemoveNode:x,selectedNodeHash:g,onNodeSelected:N,highlightedEdgeKey:h,highlightedGhost:d})})})}function lt({hash:r,className:i="",size:f="sm",collisionInfo:x,isViterbiResolved:g}){const N=Te(),h=$e(),[d,z]=n.useState(!1),C=n.useMemo(()=>ae(r),[r]),L=n.useMemo(()=>x!==void 0?x:C?N.find(u=>u.prefix===C)??null:null,[C,N,x]),T=g??(h.totalPaths>0&&h.avgPathConfidence>=.7),H=n.useCallback(u=>{u.preventDefault(),u.stopPropagation(),z(!0)},[]),D=n.useCallback(()=>{z(!1)},[]);if(!L)return null;const y=f==="sm"?"w-3.5 h-3.5":"w-4 h-4",I=T?"text-sys-cyan hover:text-sys-cyan hover:bg-sys-cyan/10 focus:ring-sys-cyan/50":"text-signal-fair hover:text-sys-indigo hover:bg-signal-fair/10 focus:ring-signal-fair/50",Q=T?`Prefix conflict resolved by Viterbi HMM (${(h.avgPathConfidence*100).toFixed(0)}% confidence)`:`Prefix conflict: ${L.candidateCount} nodes share prefix "${C}"`;return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:H,className:`inline-flex items-center justify-center p-0.5 rounded focus:outline-none focus:ring-2 transition-colors cursor-pointer touch-manipulation ${I} ${i}`,title:Q,"aria-label":`View prefix conflict for ${C}${T?" (Viterbi resolved)":""}`,children:T?e.jsxs("span",{className:"relative",children:[e.jsx(Fs,{className:y}),e.jsx(we,{className:"absolute -bottom-0.5 -right-0.5 w-2 h-2 text-sys-green"})]}):e.jsx(Js,{className:y})}),e.jsx($s,{isOpen:d,prefix:L.prefix,candidateHashes:L.candidateHashes,onClose:D})]})}const dt=n.memo(lt),ze=[{target:"Contacts",fn:"name",minStage:1,when:ks},{target:"Contacts",fn:"traceLinks.directed",minStage:2,when:Cs}];Ms(ze);function mt(r){return r<1e3?`${Math.round(r)}m`:`${(r/1e3).toFixed(1)}km`}function xt({hash:r,contact:i,isHub:f,isNeighbor:x,distance:g,centrality:N,sparklineData:h,neighborSignal:d,collisionInfo:z,isViterbiResolved:C,isPinging:L,isPingingThis:T,pingResult:H,pingError:D,gatewayInfo:y,lastForwarderPrefix:I,isMobile:Q,pathStability:u,onRowClick:K,onPing:$,onRemove:fe}){ws(ze);const V=i.latitude&&i.longitude&&i.latitude!==0&&i.longitude!==0,E=i.node_name||i.name||"Unknown",v=x&&d,ne=ke(i),{isRepeater:P,isCompanion:J,isRoomServer:j,isClient:Y,label:X}=ne,re=x?`${X} — Direct RF contact (zero-hop neighbor)`:`${X} — Flood routing (multi-hop via mesh)`,Z=i.first_seen?Re(i.first_seen).replace(/ ago$/i," old"):null;return e.jsxs("div",{className:`contacts-grid-row ${f?"bg-sys-amber/5 border-l-2 border-l-sys-amber":""} ${V?"cursor-pointer hover:bg-subtle-fill":""}`,onClick:()=>K(r),children:[e.jsxs("div",{className:"contacts-col-node flex items-center gap-2 min-w-0",children:[v&&(d==null?void 0:d.avgSnr)!==null?e.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 self-center ${es(d.avgSnr)}`}):e.jsx("div",{className:"w-2 flex-shrink-0"}),e.jsx("div",{className:"w-6 h-6 flex items-center justify-center flex-shrink-0",title:re,children:(()=>{if(j&&P)return e.jsxs("div",{className:"relative w-5 h-5",children:[e.jsx(he,{className:"w-5 h-5 absolute inset-0 text-sys-pink"}),e.jsx(Es,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-sys-teal"})]});if(j)return e.jsx(he,{className:"w-5 h-5 text-sys-pink"});if(P)return e.jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center ring-[1.5px] ring-sys-blue",children:e.jsx(pe,{className:"w-3.5 h-3.5 text-sys-blue"})});if((J||Y)&&E!=="Unknown"){const{emoji:w,cleanName:R}=Ss(E);return e.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center",style:{backgroundColor:Ps(R)},children:w?e.jsx("span",{className:"text-sm leading-none",children:w}):e.jsx("span",{className:"text-white text-[9px] font-bold tracking-tighter",children:Rs(E)})})}return e.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center bg-zinc-500/20",children:e.jsx(Fe,{className:"w-3.5 h-3.5 text-sys-amber"})})})()}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 overflow-hidden",children:[e.jsx("span",{className:"roster-title truncate",title:E,children:E}),x&&e.jsx(k,{color:W.neighbor,compact:!0,className:"flex-shrink-0",children:"NBR"}),f&&e.jsxs(k,{color:W.hub,compact:!0,className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(zs,{className:"w-3 h-3"}),"HUB"]}),P&&e.jsx(k,{color:W.repeater,compact:!0,className:"flex-shrink-0",children:"RPT"}),j&&e.jsx(k,{color:W.room,compact:!0,className:"flex-shrink-0",children:"ROOM"}),J&&e.jsx(k,{color:W.companion,compact:!0,className:"flex-shrink-0",children:"COMP"}),Y&&e.jsx(k,{color:W.client,compact:!0,className:"flex-shrink-0",children:"CLIENT"}),Q&&e.jsxs(k,{color:"cyan",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",children:[e.jsx(et,{className:"w-2.5 h-2.5"}),"MOBILE"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx(Hs,{copy:!0,size:"compact",truncate:[8,6],children:r}),e.jsx(dt,{hash:r,collisionInfo:z,isViterbiResolved:C}),!x&&y&&e.jsxs(k,{color:"zinc",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",title:`Via ${y.name||y.prefix} (${y.hopCount} hop${y.hopCount!==1?"s":""})`,children:[e.jsx(_s,{className:"w-2.5 h-2.5"}),e.jsx("span",{className:"font-mono",children:y.prefix}),y.hopCount>1&&e.jsxs("span",{className:"opacity-60",children:["+",y.hopCount-1]})]}),I&&!x&&e.jsxs(k,{color:"zinc",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",title:`Last forwarded by ${I}`,children:[e.jsx(Us,{className:"w-2.5 h-2.5"}),e.jsx("span",{className:"font-mono",children:I})]}),u!=null&&u!==0&&e.jsx(k,{color:u>0?"green":"amber",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",title:u>0?"Path stability improving":"Path stability declining",children:u>0?e.jsx(ss,{className:"w-2.5 h-2.5"}):e.jsx(rt,{className:"w-2.5 h-2.5"})}),h.length>0&&(()=>{const w=h.reduce((oe,ge)=>oe+ge.count,0);if(w===0)return null;const R=w/24;return e.jsxs(k,{color:"zinc",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",title:`${w} packets in last 24h (~${R.toFixed(1)}/hr)`,children:[e.jsx(tt,{className:"w-2.5 h-2.5"}),e.jsxs("span",{children:[R<1?"<1":R.toFixed(0),"/hr"]})]})})(),Z&&e.jsxs(k,{color:"zinc",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0 opacity-70",title:`First discovered ${Z}`,children:[e.jsx(Qs,{className:"w-2.5 h-2.5"}),e.jsx("span",{children:Z})]})]})]})]}),e.jsxs("div",{className:"contacts-col-signal flex items-center justify-end gap-2",children:[v&&(d==null?void 0:d.avgRssi)!==null&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ls,{rssi:d.avgRssi,className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:Math.round(d.avgRssi)})]}),v&&(d==null?void 0:d.avgSnr)!==null&&e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[d.avgSnr.toFixed(1)," dB"]})]}),e.jsx("div",{className:"contacts-col-distance flex items-center justify-end gap-1 text-fg-muted",children:g!=null&&e.jsxs(e.Fragment,{children:[e.jsx(He,{className:"w-3 h-3"}),e.jsx("span",{className:"type-data-xs",children:mt(g)})]})}),e.jsx("div",{className:"contacts-col-centrality flex items-center justify-end gap-1",children:N>0&&e.jsxs(e.Fragment,{children:[e.jsx(Oe,{className:"w-3 h-3 text-sys-indigo"}),e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[(N*100).toFixed(0),"%"]})]})}),e.jsx("div",{className:"contacts-col-seen flex items-center justify-end",children:e.jsx("span",{className:"type-data-xs text-fg-primary whitespace-nowrap",children:i.last_seen?Re(i.last_seen):"—"})}),e.jsxs("div",{className:"contacts-col-actions flex items-center justify-end gap-1",children:[x&&e.jsx(e.Fragment,{children:H?e.jsxs("div",{className:"flex items-center gap-1 text-sys-green",title:`RTT: ${H.rtt_ms.toFixed(0)}ms`,children:[e.jsx(we,{className:"w-3.5 h-3.5"}),e.jsxs("span",{className:"type-data-xs hidden sm:inline",children:[H.snr_db.toFixed(1),"dB"]})]}):D?e.jsx("span",{className:"text-sys-red text-xs",title:D,children:"✗"}):e.jsx("button",{onClick:w=>$(r,w),disabled:L,className:"p-1 sm:p-1.5 radius-inner text-fg-muted/50 hover:text-sys-blue hover:bg-sys-blue/10 transition-base disabled:opacity-50 disabled:cursor-not-allowed",title:"Ping neighbor for updated signal info",children:T?e.jsx(Ee,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4 animate-spin"}):e.jsx(Os,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})}),e.jsx("button",{onClick:w=>{w.stopPropagation(),fe(r,E)},className:"p-1 sm:p-1.5 radius-inner text-fg-muted/50 hover:text-sys-red hover:bg-sys-red/10 transition-base",title:"Remove contact",children:e.jsx(Ds,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})]})]})}const ut=n.memo(xt),pt=6371e3,ht=[],ft=[{field:"lastHeard",icon:Ts,label:"Recent"},{field:"distance",icon:He,label:"Distance"},{field:"centrality",icon:Oe,label:"Centrality"}];function gt(r){switch(r){case"room_server":return"room";case"repeater":return"repeater";case"companion":return"companion";case"unknown":return"companion"}}function jt(r){const i=ke(r);return gt(i.type)}function ye(r,i){const{color:f="primary",border:x=!1}=i??{};return ve("flex items-center gap-1.5 px-2 py-1.5 text-sm radius-inner transition-base",r?f==="success"?"bg-sys-green/20 text-sys-green":"bg-sys-blue/20 text-sys-blue":"text-fg-muted hover:text-fg-secondary hover-bg",x&&(r?f==="success"?"border border-sys-green/30":"border border-sys-blue/30":"border border-transparent"))}function bt(r,i,f,x){const g=(f-r)*Math.PI/180,N=(x-i)*Math.PI/180,h=Math.sin(g/2)*Math.sin(g/2)+Math.cos(r*Math.PI/180)*Math.cos(f*Math.PI/180)*Math.sin(N/2)*Math.sin(N/2),d=2*Math.atan2(Math.sqrt(h),Math.sqrt(1-h));return pt*d}function Nt(){const{stats:r}=ts(),i=as(),f=ns(),x=rs(),g=os(),N=is(),h=cs(),d=ls(),z=ds(),C=ms(),L=xs(),T=Ne[C],H=Te(),D=$e(),y=us(),I=D.totalPaths>0&&D.avgPathConfidence>=.7,Q=n.useMemo(()=>{const s=new Map;for(const t of H)s.set(t.prefix,t);return s},[H]),[u,K]=n.useState(null),[$,fe]=n.useState("lastHeard"),[V,E]=n.useState("desc"),[v,ne]=n.useState(""),[P,J]=n.useState(!1),[j,Y]=n.useState(new Set),[X,re]=n.useState(!1),[Z,w]=n.useState(null),[R,oe]=n.useState(null),[ge,je]=n.useState(new Map),[De,ee]=n.useState(new Map),[M,Ie]=n.useState(25),[U,ie]=n.useState(25),be=n.useRef(null),ce=n.useMemo(()=>(r==null?void 0:r.neighbors)??{},[r==null?void 0:r.neighbors]),A=n.useMemo(()=>{const t=Date.now()/1e3-T.minutes*60;return Object.fromEntries(Object.entries(ce).filter(([a,o])=>i.has(a)?!1:(o.last_seen??0)>=t))},[ce,i,T.minutes]),_=ps(),q=r==null?void 0:r.local_hash,Ae=n.useMemo(()=>{const s=new Map;if(!q||h.size===0)return s;for(const[t,a]of h)if(t.endsWith(`→${q}`)&&a.hops.length>1){const o=t.split("→")[0],c=a.hops[a.hops.length-1];s.set(o,c)}return s},[h,q]),le=n.useMemo(()=>{const s=new Map;if(!(_!=null&&_.latitude)||!(_!=null&&_.longitude))return s;for(const[t,a]of Object.entries(A))a.latitude&&a.longitude&&a.latitude!==0&&a.longitude!==0?s.set(t,bt(_.latitude,_.longitude,a.latitude,a.longitude)):s.set(t,null);return s},[A,_]),{neighborHashSet:de,neighborSignalMap:Be}=n.useMemo(()=>{const s=new Set,t=new Map;for(const a of N)s.add(a.hash),t.set(a.hash,{avgRssi:a.avgRssi,avgSnr:a.avgSnr});return{neighborHashSet:s,neighborSignalMap:t}},[N]),Ce=n.useMemo(()=>{const s=v.toLowerCase().trim(),t=s==="neighbor"||s==="neighbors",a=P||t,o=j.size>0;return Object.fromEntries(Object.entries(A).filter(([c,l])=>{if(o){const S=jt(l);if(!j.has(S))return!1}if(a&&!de.has(c))return!1;if(t||!s)return!0;const B=(l.node_name||l.name||"").toLowerCase(),b=ae(c).toLowerCase();return B.includes(s)||b.includes(s)||c.toLowerCase().includes(s)}))},[A,v,P,de,j]),p=n.useMemo(()=>{const s=Object.entries(Ce),t=v.toLowerCase().trim(),a=t.length===2&&/^[0-9a-f]{2}$/i.test(t);return s.sort(([o,c],[l,B])=>{if(a){const S=ae(o).toLowerCase(),F=ae(l).toLowerCase(),se=S===t,me=F===t;if(se&&!me)return-1;if(me&&!se)return 1}let b=0;switch($){case"lastHeard":b=(c.last_seen||0)-(B.last_seen||0);break;case"distance":{const S=le.get(o)??null,F=le.get(l)??null;S===null&&F===null?b=0:S===null?b=1:F===null?b=-1:b=S-F;break}case"centrality":{const S=g.get(o)||0,F=g.get(l)||0;b=S-F;break}}return V==="desc"?-b:b})},[Ce,$,V,le,g,v]),m=n.useMemo(()=>{let s=0,t=0,a=0,o=0,c=0;for(const[,l]of p){const B=ke(l),b=l.latitude&&l.longitude&&l.latitude!==0&&l.longitude!==0;switch(B.type){case"room_server":a++;break;case"repeater":t++;break;case"companion":s++;break;case"unknown":c++;break}b&&o++}return{companions:s,repeaters:t,roomServers:a,total:p.length,withLocation:o,unknown:c}},[p]),Ve=n.useMemo(()=>new Set(x),[x]),Me=n.useMemo(()=>M===0?p:p.slice(0,U),[p,U,M]);n.useEffect(()=>{ie(M||p.length)},[$,V,v,P,j,M,p.length]),n.useEffect(()=>{const s=t=>{t.target.closest("[data-dropdown]")||re(!1)};return document.addEventListener("click",s),()=>document.removeEventListener("click",s)},[]),n.useEffect(()=>{if(M===0)return;const s=new IntersectionObserver(t=>{t[0].isIntersecting&&UMath.min(a+M,p.length))},{threshold:.1,rootMargin:"100px"});return be.current&&s.observe(be.current),()=>s.disconnect()},[M,U,p.length]);const Ue=n.useCallback(s=>{Ie(s),ie(s||p.length)},[p.length]),qe=n.useCallback(s=>{$===s?E(t=>t==="desc"?"asc":"desc"):(fe(s),E("desc"))},[$]),Ge=n.useCallback(s=>{const t=A[s];t!=null&&t.latitude&&(t!=null&&t.longitude)&&t.latitude!==0&&t.longitude!==0&&w(s)},[A]),We=n.useCallback(()=>{w(null)},[]),Qe=n.useCallback((s,t)=>{K({hash:s,name:t})},[]),Ke=n.useCallback(async(s,t)=>{if(t.stopPropagation(),!R){oe(s),je(a=>{const o=new Map(a);return o.delete(s),o}),ee(a=>{const o=new Map(a);return o.delete(s),o});try{const a=s.startsWith("0x")?s.slice(0,4):`0x${s.slice(0,2)}`,o=await js(a,30);o.success&&o.data?(je(c=>new Map(c).set(s,o.data)),setTimeout(()=>{je(c=>{const l=new Map(c);return l.delete(s),l})},1e4)):(ee(c=>new Map(c).set(s,o.error||"Ping failed")),setTimeout(()=>{ee(c=>{const l=new Map(c);return l.delete(s),l})},5e3))}catch(a){const o=a instanceof Error?a.message:"Ping failed";ee(c=>new Map(c).set(s,o)),setTimeout(()=>{ee(c=>{const l=new Map(c);return l.delete(s),l})},5e3)}finally{oe(null)}}},[R]);return e.jsxs(bs,{children:[e.jsx(Ns,{title:"Contacts",icon:e.jsx(te,{}),controls:e.jsxs("div",{className:"flex items-center gap-3 sm:gap-5",children:[e.jsxs("div",{className:"hidden sm:flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Total:"}),e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:`${m.total} discovered node${m.total!==1?"s":""} on the mesh network`,children:[e.jsx(te,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:m.total})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Types:"}),m.repeaters>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Repeaters",children:[e.jsx(pe,{className:"w-3.5 h-3.5 text-sys-blue"}),e.jsx("span",{children:m.repeaters})]}),m.companions>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Companions",children:[e.jsx(Le,{className:"w-3.5 h-3.5 text-fg-muted"}),e.jsx("span",{children:m.companions})]}),m.roomServers>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Room Servers",children:[e.jsx(he,{className:"w-3.5 h-3.5 text-sys-pink"}),e.jsx("span",{children:m.roomServers})]}),m.withLocation>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"With GPS location",children:[e.jsx(As,{className:"w-3.5 h-3.5 text-sys-green"}),e.jsx("span",{children:m.withLocation})]}),m.unknown>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Unknown type",children:[e.jsx(Fe,{className:"w-3.5 h-3.5 text-sys-amber"}),e.jsx("span",{children:m.unknown})]})]})]}),e.jsxs("div",{className:"flex sm:hidden items-center gap-1.5",children:[e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx(te,{className:"w-3 h-3 text-fg-secondary"}),e.jsx("span",{children:m.total})]}),m.repeaters>0&&e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx(pe,{className:"w-3 h-3 text-sys-blue"}),e.jsx("span",{children:m.repeaters})]}),m.companions>0&&e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx(Le,{className:"w-3 h-3 text-fg-muted"}),e.jsx("span",{children:m.companions})]}),m.roomServers>0&&e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx(he,{className:"w-3 h-3 text-sys-pink"}),e.jsx("span",{children:m.roomServers})]}),e.jsx(_e,{ranges:Ne,selectedIndex:C,onSelect:L,size:"sm"})]}),e.jsx("div",{className:"hidden sm:block",children:e.jsx(_e,{ranges:Ne,selectedIndex:C,onSelect:L})})]})}),e.jsxs(ys,{children:[z?e.jsx(ct,{neighbors:A,localNode:_??void 0,localHash:q,onRemoveNode:f,selectedNodeHash:Z,onNodeSelected:We}):e.jsx("div",{className:"surface-base radius-card aspect-video flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-6 h-6 border-2 border-sys-blue border-t-transparent rounded-full animate-spin"}),e.jsx("span",{className:"text-sm text-fg-muted",children:"Loading map..."})]})}),e.jsx(hs,{noPadding:!0,children:z?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 px-3 sm:px-4 py-2.5 border-b border-edge-subtle",children:[e.jsx("span",{className:"icon-md flex items-center justify-center text-icon-card-title flex-shrink-0",children:e.jsx(te,{})}),e.jsx("span",{className:"type-micro flex-shrink-0 mr-auto hidden sm:block",children:"Discovered Contacts"}),e.jsx(fs,{type:"search",size:"sm",value:v,onChange:s=>ne(s.target.value),placeholder:"Search...",leadingIcon:e.jsx(Bs,{className:"w-3.5 h-3.5"}),trailingIcon:v?e.jsx("button",{onClick:()=>{ne(""),(v.toLowerCase().trim()==="neighbor"||v.toLowerCase().trim()==="neighbors")&&J(!1)},className:"text-fg-muted hover:text-fg-secondary",children:e.jsx(gs,{className:"w-3 h-3"})}):void 0,className:"w-24 sm:w-32 xl:w-44","aria-label":"Search contacts"}),e.jsx("div",{className:"h-4 w-px bg-border-subtle flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsxs("div",{className:"relative","data-dropdown":!0,children:[e.jsxs("button",{onClick:()=>re(!X),className:ye(j.size>0,{border:!0}),title:"Filter by contact type",children:[e.jsx(Xs,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:"Filter"}),j.size>0&&e.jsx("span",{className:"tabular-nums text-xs bg-sys-blue/30 px-1 rounded",children:j.size})]}),X&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-50 surface-elevated radius-inner py-1 min-w-[140px]",children:[[{key:"repeater",label:"Repeaters"},{key:"companion",label:"Companions"},{key:"room",label:"Rooms"}].map(({key:s,label:t})=>e.jsxs("button",{onClick:()=>{Y(a=>{const o=new Set(a);return o.has(s)?o.delete(s):o.add(s),o})},className:"w-full px-3 py-1.5 text-sm text-left hover-bg transition-base flex items-center gap-2",children:[e.jsx("span",{className:ve("w-4 h-4 flex items-center justify-center radius-badge border",j.has(s)?"bg-sys-blue border-sys-blue text-white":"border-edge-subtle"),children:j.has(s)&&e.jsx(we,{className:"w-3 h-3"})}),e.jsx("span",{className:j.has(s)?"text-fg-primary":"text-fg-secondary",children:t})]},s)),j.size>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t border-edge-subtle my-1"}),e.jsx("button",{onClick:()=>Y(new Set),className:"w-full px-3 py-1.5 text-sm text-left text-fg-muted hover:text-fg-secondary hover-bg transition-base",children:"Clear filters"})]})]})]}),de.size>0&&e.jsxs("button",{onClick:()=>J(!P),className:ye(P,{color:"success",border:!0}),title:P?"Show all contacts":"Show only MeshCore neighbors (direct RF contact)",children:[e.jsx(pe,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:"Neighbors"})]})]}),e.jsx("div",{className:"h-4 w-px bg-border-subtle flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[ft.map(({field:s,icon:t,label:a})=>e.jsxs("button",{onClick:()=>qe(s),className:ye($===s),title:`Sort by ${a.toLowerCase()}`,children:[e.jsx(t,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:a}),$===s&&e.jsx(Gs,{className:ve("w-3 h-3",V==="asc"&&"rotate-180")})]},s)),e.jsx("div",{className:"h-4 w-px bg-border-subtle"}),e.jsxs(vs,{value:M,onChange:Ue,className:"w-auto min-w-[50px] [&_button]:py-1 [&_button]:px-2 [&_button]:text-xs [&_button]:min-h-0","aria-label":"Items per page",children:[e.jsx(ue,{value:25,children:"25"}),e.jsx(ue,{value:50,children:"50"}),e.jsx(ue,{value:100,children:"100"}),e.jsx(ue,{value:0,children:"All"})]})]})]}),p.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hidden sm:grid contacts-grid-header border-b border-edge-subtle/50 px-3 py-2 type-micro text-fg-muted",children:[e.jsx("div",{className:"contacts-col-node",children:"Node"}),e.jsx("div",{className:"contacts-col-signal text-right",children:"Signal"}),e.jsx("div",{className:"contacts-col-distance text-right",children:"Distance"}),e.jsx("div",{className:"contacts-col-centrality text-right",children:"Centrality"}),e.jsx("div",{className:"contacts-col-seen text-right",children:"Last Seen"}),e.jsx("div",{className:"contacts-col-actions"})]}),e.jsx("div",{className:"divide-y divide-edge-subtle/30",children:Me.map(([s,t])=>{const a=ae(s),o=Ve.has(s),c=de.has(s),l=le.get(s)??null,B=g.get(s)||0,b=c?Be.get(s):void 0,S=a?Q.get(a)??null:null,F=y.get(s)??ht;let se=null;if(!c&&q&&h.size>0){const Ye=`${s}→${q}`,xe=h.get(Ye);if(xe&&xe.hops.length>0){const Se=xe.hops[0],Pe=Object.keys(ce).find(Xe=>Xe.toUpperCase().startsWith(Se.toUpperCase())),G=Pe?ce[Pe]:null;se={prefix:Se,name:(G==null?void 0:G.node_name)??(G==null?void 0:G.name)??null,hopCount:xe.hopCount}}}const me=d.has(s),Je=Ae.get(s)??null;return e.jsx(ut,{hash:s,contact:t,isHub:o,isNeighbor:c,distance:l,centrality:B,sparklineData:F,neighborSignal:b,collisionInfo:S,isViterbiResolved:I,isPinging:R!==null,isPingingThis:R===s,pingResult:ge.get(s),pingError:De.get(s),gatewayInfo:se,lastForwarderPrefix:Je,isMobile:me,onRowClick:Ge,onPing:Ke,onRemove:Qe},s)})}),M>0&&U0&&Uie(s=>Math.min(s+M,p.length)),className:"text-sys-blue hover:text-sys-blue/80 transition-base",children:"Load more"})]})]}):e.jsxs("div",{className:"roster-empty",children:[e.jsx(te,{className:"roster-empty-icon"}),e.jsx("div",{className:"type-label text-fg-secondary",children:"No Contacts Discovered"}),e.jsx("div",{className:"type-data-xs text-fg-muted mt-1",children:"Contacts will appear here as they advertise on the mesh network."})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-edge-subtle",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded bg-elevated animate-pulse"}),e.jsx("div",{className:"w-32 h-4 rounded bg-elevated animate-pulse"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-16 h-6 rounded bg-elevated animate-pulse"}),e.jsx("div",{className:"w-24 h-6 rounded bg-elevated animate-pulse"}),e.jsx("div",{className:"w-16 h-6 rounded bg-elevated animate-pulse"})]})]}),e.jsx("div",{className:"px-3 py-3 space-y-3",children:[...Array(5)].map((s,t)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-5 h-5 rounded bg-elevated animate-pulse"}),e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"h-4 w-32 rounded bg-elevated animate-pulse"}),e.jsx("div",{className:"h-3 w-24 rounded bg-elevated animate-pulse"})]}),e.jsx("div",{className:"w-12 h-4 rounded bg-elevated animate-pulse"}),e.jsx("div",{className:"w-16 h-4 rounded bg-elevated animate-pulse"})]},t))})]})})]}),e.jsx(Is,{isOpen:!!u,title:"Remove Contact",message:`Are you sure you would like to remove ${(u==null?void 0:u.name)||"this contact"}?`,confirmLabel:"Remove",cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{u&&f(u.hash),K(null)},onCancel:()=>K(null)})]})}const At=Object.freeze(Object.defineProperty({__proto__:null,default:Nt},Symbol.toStringTag,{value:"Module"}));export{At as C,dt as P,He as R,rt as T}; diff --git a/frontend/dist/assets/Contacts-CcwYnw5c.js b/frontend/dist/assets/Contacts-CcwYnw5c.js new file mode 100644 index 00000000..3a613816 --- /dev/null +++ b/frontend/dist/assets/Contacts-CcwYnw5c.js @@ -0,0 +1,52 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ContactsMapMapLibre-7MZRUDIi.js","assets/index-BwGHI0A_.js","assets/BasemapLayer-Bm_seLWQ.js","assets/consumer-registry-DPYvsBcc.js","assets/link-scoring-BSZA-fkH.js","assets/ConfirmModal-B0nTD1Q0.js","assets/triangle-alert-B4kC1YDk.js","assets/DeepAnalysisModal-CaP_TRSd.js","assets/download-BbqYTv8j.js","assets/database-CDN_R6oC.js","assets/useMapViewStore-CPURakCb.js","assets/index-OH01SZkk.js","assets/refresh-cw-DYpAqCT4.js","assets/target-LdPtzGwl.js","assets/funnel-D4Wxq-Fx.js","assets/plus-C0xom_iW.js","assets/easing-DSebI9nw.js","assets/wifi-BaASFkdf.js","assets/SignalIndicator-LNOR_5YF.js","assets/chevron-right-DqpRZiGf.js","assets/node-types-DmTOZWT4.js","assets/badge-colors-BNUqIXCA.js","assets/LightSparkline-5OIe9Q0M.js","assets/map-pin-VRY_TOuh.js","assets/usePipelineStore-11oXtutw.js","assets/ping-DW5e4gor.js","assets/PageLayout-BIcqC04y.js","assets/listbox-_tsR-2yL.js","assets/element-movement-BqZOD4DT.js","assets/TimeRangeStepper-Dh4JEQ42.js","assets/chat-utils-Di4-nywi.js","assets/CollisionExplorerModal-Cm5c7tcU.js","assets/monitor-smartphone-BxljwdQV.js","assets/DataBox-CQS-Zhu0.js","assets/circle-question-mark-DC7QfrVK.js","assets/network-9doWJxcL.js","assets/activity-Dr_TPIps.js","assets/search-B7iMjmGm.js","assets/index-DUfCykEc.css","assets/BasemapLayer-B1CfjdFi.css","assets/ContactsMapMapLibre-BwWOEply.css"])))=>i.map(i=>d[i]); +import{d as L,j as e,r as n,bo as ss,bL as Ee,bM as Fe,$ as ne,w as Ce,a9 as Le,bN as ts,bO as fe,R as he,q as k,bP as as,L as Oe,bQ as ns,J as rs,bR as os,bS as is,bT as cs,H as ls,bU as ds,bV as ms,bW as xs,K as us,aa as ps,N as ve,bX as hs,bY as fs,b8 as ae,o as gs,I as js,bc as bs,c as ke}from"./index-BwGHI0A_.js";import{useDiscoveredNodes as ys}from"./usePipelineStore-11oXtutw.js";import{p as Ns}from"./ping-DW5e4gor.js";import{c as Me}from"./node-types-DmTOZWT4.js";import{P as vs,a as ws,B as ks}from"./PageLayout-BIcqC04y.js";import{L as Cs,a as pe}from"./listbox-_tsR-2yL.js";import{T as Te}from"./TimeRangeStepper-Dh4JEQ42.js";import{u as Ms,e as Ss,f as _s,r as Ps}from"./consumer-registry-DPYvsBcc.js";import{e as Rs,g as Ls,a as Ts}from"./chat-utils-Di4-nywi.js";import{A as $s,b as Es,C as Fs}from"./SignalIndicator-LNOR_5YF.js";import{C as Os,S as zs}from"./CollisionExplorerModal-Cm5c7tcU.js";import{E as Hs,T as Ds}from"./target-LdPtzGwl.js";import{D as As}from"./DataBox-CQS-Zhu0.js";import{C as G}from"./badge-colors-BNUqIXCA.js";import{C as ze}from"./circle-question-mark-DC7QfrVK.js";import{N as Is}from"./network-9doWJxcL.js";import{A as He}from"./activity-Dr_TPIps.js";import{T as Bs,C as Vs}from"./ConfirmModal-B0nTD1Q0.js";import{M as $e}from"./monitor-smartphone-BxljwdQV.js";import{M as Us}from"./map-pin-VRY_TOuh.js";import{S as qs}from"./search-B7iMjmGm.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 Ws=[["path",{d:"M17 7 7 17",key:"15tmo1"}],["path",{d:"M17 17H7V7",key:"1org7z"}]],Gs=L("arrow-down-left",Ws);/** + * @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 Qs=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],Ks=L("arrow-up-down",Qs);/** + * @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 Ys=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],Xs=L("calendar",Ys);/** + * @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 Js=[["path",{d:"M4 12V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2",key:"jrl274"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 16h2v6",key:"1bxocy"}],["path",{d:"M10 22h4",key:"ceow96"}],["rect",{x:"2",y:"16",width:"4",height:"6",rx:"2",key:"r45zd0"}]],Zs=L("file-digit",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 et=[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]],st=L("list-filter",et);/** + * @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 tt=[["path",{d:"M12.75 7.09a3 3 0 0 1 2.16 2.16",key:"1d4wjd"}],["path",{d:"M17.072 17.072c-1.634 2.17-3.527 3.912-4.471 4.727a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 1.432-4.568",key:"12yil7"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.475 2.818A8 8 0 0 1 20 10c0 1.183-.31 2.377-.81 3.533",key:"lhrkcz"}],["path",{d:"M9.13 9.13a3 3 0 0 0 3.74 3.74",key:"13wojd"}]],at=L("map-pin-off",tt);/** + * @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 nt=[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]],rt=L("move",nt);/** + * @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 ot=[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]],it=L("radio-tower",ot);/** + * @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 ct=[["path",{d:"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z",key:"icamh8"}],["path",{d:"m14.5 12.5 2-2",key:"inckbg"}],["path",{d:"m11.5 9.5 2-2",key:"fmmyf7"}],["path",{d:"m8.5 6.5 2-2",key:"vc6u1g"}],["path",{d:"m17.5 15.5 2-2",key:"wo5hmg"}]],De=L("ruler",ct);/** + * @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 lt=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],dt=L("trending-down",lt);class mt extends n.Component{constructor(i){super(i),this.state={hasError:!1}}static getDerivedStateFromError(i){return{hasError:!0,error:i}}render(){var i;return this.state.hasError?e.jsx("div",{className:"map-container-16-9 flex items-center justify-center rounded-2xl surface-base",role:"alert","aria-live":"assertive",children:e.jsxs("div",{className:"text-center text-fg-muted p-4",children:[e.jsx("p",{className:"text-lg mb-2",children:"Map failed to load"}),e.jsx("p",{className:"text-sm text-fg-muted",children:((i=this.state.error)==null?void 0:i.message)||"Unknown error"}),e.jsx("p",{className:"text-xs text-fg-muted mt-2",children:"Try refreshing the page or check your browser's WebGL support."})]})}):this.props.children}}const xt=n.lazy(()=>ss(()=>import("./ContactsMapMapLibre-7MZRUDIi.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40])));function ut({neighbors:o,localNode:i,localHash:f,onRemoveNode:x,selectedNodeHash:g,onNodeSelected:y,highlightedEdgeKey:h,highlightedGhost:d}){return e.jsx(mt,{children:e.jsx(n.Suspense,{fallback:e.jsx("div",{className:"map-container-16-9 flex items-center justify-center rounded-2xl surface-base",role:"status","aria-live":"polite","aria-label":"Loading map",children:e.jsxs("div",{className:"text-fg-muted flex items-center gap-3",children:[e.jsx("div",{className:"w-5 h-5 border-2 border-sys-blue border-t-transparent rounded-full animate-spin","aria-hidden":"true"}),e.jsx("span",{children:"Loading map..."})]})}),children:e.jsx(xt,{neighbors:o,localNode:i,localHash:f,onRemoveNode:x,selectedNodeHash:g,onNodeSelected:y,highlightedEdgeKey:h,highlightedGhost:d})})})}function pt({hash:o,className:i="",size:f="sm",collisionInfo:x,isViterbiResolved:g}){const y=Ee(),h=Fe(),[d,H]=n.useState(!1),C=n.useMemo(()=>ne(o),[o]),T=n.useMemo(()=>x!==void 0?x:C?y.find(u=>u.prefix===C)??null:null,[C,y,x]),$=g??(h.totalPaths>0&&h.avgPathConfidence>=.7),z=n.useCallback(u=>{u.preventDefault(),u.stopPropagation(),H(!0)},[]),D=n.useCallback(()=>{H(!1)},[]);if(!T)return null;const N=f==="sm"?"w-3.5 h-3.5":"w-4 h-4",A=$?"text-sys-cyan hover:text-sys-cyan hover:bg-sys-cyan/10 focus:ring-sys-cyan/50":"text-signal-fair hover:text-sys-indigo hover:bg-signal-fair/10 focus:ring-signal-fair/50",Q=$?`Prefix conflict resolved by Viterbi HMM (${(h.avgPathConfidence*100).toFixed(0)}% confidence)`:`Prefix conflict: ${T.candidateCount} nodes share prefix "${C}"`;return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:z,className:`inline-flex items-center justify-center p-0.5 rounded focus:outline-none focus:ring-2 transition-colors cursor-pointer touch-manipulation ${A} ${i}`,title:Q,"aria-label":`View prefix conflict for ${C}${$?" (Viterbi resolved)":""}`,children:$?e.jsxs("span",{className:"relative",children:[e.jsx(Hs,{className:N}),e.jsx(Ce,{className:"absolute -bottom-0.5 -right-0.5 w-2 h-2 text-sys-green"})]}):e.jsx(Zs,{className:N})}),e.jsx(Os,{isOpen:d,prefix:T.prefix,candidateHashes:T.candidateHashes,onClose:D})]})}const ht=n.memo(pt),Ae=[{target:"Contacts",fn:"name",minStage:1,when:Ss},{target:"Contacts",fn:"traceLinks.directed",minStage:2,when:_s}];Ps(Ae);function ft(o){return o<1e3?`${Math.round(o)}m`:`${(o/1e3).toFixed(1)}km`}function gt({hash:o,contact:i,isHub:f,isNeighbor:x,distance:g,centrality:y,sparklineData:h,neighborSignal:d,collisionInfo:H,isViterbiResolved:C,isPinging:T,isPingingThis:$,pingResult:z,pingError:D,gatewayInfo:N,lastForwarderPrefix:A,isMobile:Q,pathStability:u,onRowClick:K,onPing:E,onRemove:ge}){Ms(Ae);const I=i.latitude&&i.longitude&&i.latitude!==0&&i.longitude!==0,F=i.node_name||i.name||"Unknown",v=x&&d,re=Me(i),{isRepeater:_,isCompanion:Y,isRoomServer:j,isClient:X,label:J}=re,oe=x?`${J} — Direct RF contact (zero-hop neighbor)`:`${J} — Flood routing (multi-hop via mesh)`,Z=i.first_seen?Le(i.first_seen).replace(/ ago$/i," old"):null;return e.jsxs("div",{className:`contacts-grid-row ${f?"bg-sys-amber/5 border-l-2 border-l-sys-amber":""} ${I?"cursor-pointer hover:bg-subtle-fill":""}`,onClick:()=>K(o),children:[e.jsxs("div",{className:"contacts-col-node flex items-center gap-2 min-w-0",children:[v&&(d==null?void 0:d.avgSnr)!==null?e.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 self-center ${ts(d.avgSnr)}`}):e.jsx("div",{className:"w-2 flex-shrink-0"}),e.jsx("div",{className:"w-6 h-6 flex items-center justify-center flex-shrink-0",title:oe,children:(()=>{if(j&&_)return e.jsxs("div",{className:"relative w-5 h-5",children:[e.jsx(fe,{className:"w-5 h-5 absolute inset-0 text-sys-pink"}),e.jsx(zs,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-sys-teal"})]});if(j)return e.jsx(fe,{className:"w-5 h-5 text-sys-pink"});if(_)return e.jsx("div",{className:"w-5 h-5 rounded-full flex items-center justify-center ring-[1.5px] ring-sys-blue",children:e.jsx(he,{className:"w-3.5 h-3.5 text-sys-blue"})});if((Y||X)&&F!=="Unknown"){const{emoji:w,cleanName:P}=Rs(F);return e.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center",style:{backgroundColor:Ls(P)},children:w?e.jsx("span",{className:"text-sm leading-none",children:w}):e.jsx("span",{className:"text-white text-[9px] font-bold tracking-tighter",children:Ts(F)})})}return e.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center bg-zinc-500/20",children:e.jsx(ze,{className:"w-3.5 h-3.5 text-sys-amber"})})})()}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 overflow-hidden",children:[e.jsx("span",{className:"roster-title truncate",title:F,children:F}),x&&e.jsx(k,{color:G.neighbor,compact:!0,className:"flex-shrink-0",children:"NBR"}),f&&e.jsxs(k,{color:G.hub,compact:!0,className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(Is,{className:"w-3 h-3"}),"HUB"]}),_&&e.jsx(k,{color:G.repeater,compact:!0,className:"flex-shrink-0",children:"RPT"}),j&&e.jsx(k,{color:G.room,compact:!0,className:"flex-shrink-0",children:"ROOM"}),Y&&e.jsx(k,{color:G.companion,compact:!0,className:"flex-shrink-0",children:"COMP"}),X&&e.jsx(k,{color:G.client,compact:!0,className:"flex-shrink-0",children:"CLIENT"}),Q&&e.jsxs(k,{color:"cyan",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",children:[e.jsx(rt,{className:"w-2.5 h-2.5"}),"MOBILE"]}),!I&&e.jsx("span",{className:"flex items-center gap-0.5 flex-shrink-0 text-fg-muted/50",title:"No GPS location provided",children:e.jsx(at,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx(As,{copy:!0,size:"compact",truncate:[8,6],children:o}),e.jsx(ht,{hash:o,collisionInfo:H,isViterbiResolved:C}),!x&&N&&e.jsxs(k,{color:"zinc",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",title:`Via ${N.name||N.prefix} (${N.hopCount} hop${N.hopCount!==1?"s":""})`,children:[e.jsx($s,{className:"w-2.5 h-2.5"}),e.jsx("span",{className:"font-mono",children:N.prefix}),N.hopCount>1&&e.jsxs("span",{className:"opacity-60",children:["+",N.hopCount-1]})]}),A&&!x&&e.jsxs(k,{color:"zinc",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",title:`Last forwarded by ${A}`,children:[e.jsx(Gs,{className:"w-2.5 h-2.5"}),e.jsx("span",{className:"font-mono",children:A})]}),u!=null&&u!==0&&e.jsx(k,{color:u>0?"green":"amber",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",title:u>0?"Path stability improving":"Path stability declining",children:u>0?e.jsx(as,{className:"w-2.5 h-2.5"}):e.jsx(dt,{className:"w-2.5 h-2.5"})}),h.length>0&&(()=>{const w=h.reduce((ie,je)=>ie+je.count,0);if(w===0)return null;const P=w/24;return e.jsxs(k,{color:"zinc",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",title:`${w} packets in last 24h (~${P.toFixed(1)}/hr)`,children:[e.jsx(it,{className:"w-2.5 h-2.5"}),e.jsxs("span",{children:[P<1?"<1":P.toFixed(0),"/hr"]})]})})(),Z&&e.jsxs(k,{color:"zinc",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0 opacity-70",title:`First discovered ${Z}`,children:[e.jsx(Xs,{className:"w-2.5 h-2.5"}),e.jsx("span",{children:Z})]})]})]})]}),e.jsxs("div",{className:"contacts-col-signal flex items-center justify-end gap-2",children:[v&&(d==null?void 0:d.avgRssi)!==null&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Es,{rssi:d.avgRssi,className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:Math.round(d.avgRssi)})]}),v&&(d==null?void 0:d.avgSnr)!==null&&e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[d.avgSnr.toFixed(1)," dB"]})]}),e.jsx("div",{className:"contacts-col-distance flex items-center justify-end gap-1 text-fg-muted",children:g!=null&&e.jsxs(e.Fragment,{children:[e.jsx(De,{className:"w-3 h-3"}),e.jsx("span",{className:"type-data-xs",children:ft(g)})]})}),e.jsx("div",{className:"contacts-col-centrality flex items-center justify-end gap-1",children:y>0&&e.jsxs(e.Fragment,{children:[e.jsx(He,{className:"w-3 h-3 text-sys-indigo"}),e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[(y*100).toFixed(0),"%"]})]})}),e.jsx("div",{className:"contacts-col-seen flex items-center justify-end",children:e.jsx("span",{className:"type-data-xs text-fg-primary whitespace-nowrap",children:i.last_seen?Le(i.last_seen):"—"})}),e.jsxs("div",{className:"contacts-col-actions flex items-center justify-end gap-1",children:[x&&e.jsx(e.Fragment,{children:z?e.jsxs("div",{className:"flex items-center gap-1 text-sys-green",title:`RTT: ${z.rtt_ms.toFixed(0)}ms`,children:[e.jsx(Ce,{className:"w-3.5 h-3.5"}),e.jsxs("span",{className:"type-data-xs hidden sm:inline",children:[z.snr_db.toFixed(1),"dB"]})]}):D?e.jsx("span",{className:"text-sys-red text-xs",title:D,children:"✗"}):e.jsx("button",{onClick:w=>E(o,w),disabled:T,className:"p-1 sm:p-1.5 radius-inner text-fg-muted/50 hover:text-sys-blue hover:bg-sys-blue/10 transition-base disabled:opacity-50 disabled:cursor-not-allowed",title:"Ping neighbor for updated signal info",children:$?e.jsx(Oe,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4 animate-spin"}):e.jsx(Ds,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})}),e.jsx("button",{onClick:w=>{w.stopPropagation(),ge(o,F)},className:"p-1 sm:p-1.5 radius-inner text-fg-muted/50 hover:text-sys-red hover:bg-sys-red/10 transition-base",title:"Remove contact",children:e.jsx(Bs,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})]})]})}const jt=n.memo(gt),bt=6371e3,yt=[],Nt=[{field:"lastHeard",icon:Fs,label:"Recent"},{field:"distance",icon:De,label:"Distance"},{field:"centrality",icon:He,label:"Centrality"}];function vt(o){switch(o){case"room_server":return"room";case"repeater":return"repeater";case"companion":return"companion";case"unknown":return"companion"}}function wt(o){const i=Me(o);return vt(i.type)}function we(o,i){const{color:f="primary",border:x=!1}=i??{};return ke("flex items-center gap-1.5 px-2 py-1.5 text-sm radius-inner transition-base",o?f==="success"?"bg-sys-green/20 text-sys-green":"bg-sys-blue/20 text-sys-blue":"text-fg-muted hover:text-fg-secondary hover-bg",x&&(o?f==="success"?"border border-sys-green/30":"border border-sys-blue/30":"border border-transparent"))}function kt(o,i,f,x){const g=(f-o)*Math.PI/180,y=(x-i)*Math.PI/180,h=Math.sin(g/2)*Math.sin(g/2)+Math.cos(o*Math.PI/180)*Math.cos(f*Math.PI/180)*Math.sin(y/2)*Math.sin(y/2),d=2*Math.atan2(Math.sqrt(h),Math.sqrt(1-h));return bt*d}function Ct(){const{stats:o}=ns(),i=rs(),f=os(),x=is(),g=cs(),y=ls(),h=ds(),d=ms(),H=xs(),C=us(),T=ps(),$=ve[C],z=Ee(),D=Fe(),N=hs(),A=D.totalPaths>0&&D.avgPathConfidence>=.7,Q=n.useMemo(()=>{const s=new Map;for(const t of z)s.set(t.prefix,t);return s},[z]),[u,K]=n.useState(null),[E,ge]=n.useState("lastHeard"),[I,F]=n.useState("desc"),[v,re]=n.useState(""),[_,Y]=n.useState(!1),[j,X]=n.useState(new Set),[J,oe]=n.useState(!1),[Z,w]=n.useState(null),[P,ie]=n.useState(null),[je,be]=n.useState(new Map),[Ie,ee]=n.useState(new Map),[M,Be]=n.useState(25),[U,ce]=n.useState(25),ye=n.useRef(null),se=n.useMemo(()=>(o==null?void 0:o.neighbors)??{},[o==null?void 0:o.neighbors]),Ne=ys(),le=n.useMemo(()=>{if(Ne.size===0)return se;const s=new Set;for(const a of Object.keys(se))s.add((a.startsWith("0x")?a.slice(2):a).toLowerCase());let t=null;for(const[a,r]of Ne){const c=(a.startsWith("0x")?a.slice(2):a).toLowerCase();s.has(c)||(t||(t={...se}),t[a]={last_seen:r.lastSeen,name:r.name??void 0,node_name:r.name??void 0,latitude:r.latitude,longitude:r.longitude,is_repeater:r.nodeType==="repeater",contact_type:r.nodeType==="repeater"?"Repeater":r.nodeType==="companion"?"Companion":r.nodeType==="room_server"?"Room Server":void 0})}return t??se},[se,Ne]),B=n.useMemo(()=>{const t=Date.now()/1e3-$.minutes*60;return Object.fromEntries(Object.entries(le).filter(([a,r])=>i.has(a)?!1:(r.last_seen??0)>=t))},[le,i,$.minutes]),R=fs(),q=o==null?void 0:o.local_hash,Ve=n.useMemo(()=>{const s=new Map;if(!q||h.size===0)return s;for(const[t,a]of h)if(t.endsWith(`→${q}`)&&a.hops.length>1){const r=t.split("→")[0],c=a.hops[a.hops.length-1];s.set(r,c)}return s},[h,q]),de=n.useMemo(()=>{const s=new Map;if(!(R!=null&&R.latitude)||!(R!=null&&R.longitude))return s;for(const[t,a]of Object.entries(B))a.latitude&&a.longitude&&a.latitude!==0&&a.longitude!==0?s.set(t,kt(R.latitude,R.longitude,a.latitude,a.longitude)):s.set(t,null);return s},[B,R]),{neighborHashSet:me,neighborSignalMap:Ue}=n.useMemo(()=>{const s=new Set,t=new Map;for(const a of y)s.add(a.hash),t.set(a.hash,{avgRssi:a.avgRssi,avgSnr:a.avgSnr});return{neighborHashSet:s,neighborSignalMap:t}},[y]),Se=n.useMemo(()=>{const s=v.toLowerCase().trim(),t=s==="neighbor"||s==="neighbors",a=_||t,r=j.size>0;return Object.fromEntries(Object.entries(B).filter(([c,l])=>{if(r){const S=wt(l);if(!j.has(S))return!1}if(a&&!me.has(c))return!1;if(t||!s)return!0;const V=(l.node_name||l.name||"").toLowerCase(),b=ne(c).toLowerCase();return V.includes(s)||b.includes(s)||c.toLowerCase().includes(s)}))},[B,v,_,me,j]),p=n.useMemo(()=>{const s=Object.entries(Se),t=v.toLowerCase().trim(),a=t.length===2&&/^[0-9a-f]{2}$/i.test(t);return s.sort(([r,c],[l,V])=>{if(a){const S=ne(r).toLowerCase(),O=ne(l).toLowerCase(),te=S===t,xe=O===t;if(te&&!xe)return-1;if(xe&&!te)return 1}let b=0;switch(E){case"lastHeard":b=(c.last_seen||0)-(V.last_seen||0);break;case"distance":{const S=de.get(r)??null,O=de.get(l)??null;S===null&&O===null?b=0:S===null?b=1:O===null?b=-1:b=S-O;break}case"centrality":{const S=g.get(r)||0,O=g.get(l)||0;b=S-O;break}}return I==="desc"?-b:b})},[Se,E,I,de,g,v]),m=n.useMemo(()=>{let s=0,t=0,a=0,r=0,c=0;for(const[,l]of p){const V=Me(l),b=l.latitude&&l.longitude&&l.latitude!==0&&l.longitude!==0;switch(V.type){case"room_server":a++;break;case"repeater":t++;break;case"companion":s++;break;case"unknown":c++;break}b&&r++}return{companions:s,repeaters:t,roomServers:a,total:p.length,withLocation:r,unknown:c}},[p]),qe=n.useMemo(()=>new Set(x),[x]),_e=n.useMemo(()=>M===0?p:p.slice(0,U),[p,U,M]);n.useEffect(()=>{ce(M||p.length)},[E,I,v,_,j,M,p.length]),n.useEffect(()=>{const s=t=>{t.target.closest("[data-dropdown]")||oe(!1)};return document.addEventListener("click",s),()=>document.removeEventListener("click",s)},[]),n.useEffect(()=>{if(M===0)return;const s=new IntersectionObserver(t=>{t[0].isIntersecting&&UMath.min(a+M,p.length))},{threshold:.1,rootMargin:"100px"});return ye.current&&s.observe(ye.current),()=>s.disconnect()},[M,U,p.length]);const We=n.useCallback(s=>{Be(s),ce(s||p.length)},[p.length]),Ge=n.useCallback(s=>{E===s?F(t=>t==="desc"?"asc":"desc"):(ge(s),F("desc"))},[E]),Qe=n.useCallback(s=>{const t=B[s];t!=null&&t.latitude&&(t!=null&&t.longitude)&&t.latitude!==0&&t.longitude!==0&&w(s)},[B]),Ke=n.useCallback(()=>{w(null)},[]),Ye=n.useCallback((s,t)=>{K({hash:s,name:t})},[]),Xe=n.useCallback(async(s,t)=>{if(t.stopPropagation(),!P){ie(s),be(a=>{const r=new Map(a);return r.delete(s),r}),ee(a=>{const r=new Map(a);return r.delete(s),r});try{const a=s.startsWith("0x")?s.slice(0,4):`0x${s.slice(0,2)}`,r=await Ns(a,30);r.success&&r.data?(be(c=>new Map(c).set(s,r.data)),setTimeout(()=>{be(c=>{const l=new Map(c);return l.delete(s),l})},1e4)):(ee(c=>new Map(c).set(s,r.error||"Ping failed")),setTimeout(()=>{ee(c=>{const l=new Map(c);return l.delete(s),l})},5e3))}catch(a){const r=a instanceof Error?a.message:"Ping failed";ee(c=>new Map(c).set(s,r)),setTimeout(()=>{ee(c=>{const l=new Map(c);return l.delete(s),l})},5e3)}finally{ie(null)}}},[P]);return e.jsxs(vs,{children:[e.jsx(ws,{title:"Contacts",icon:e.jsx(ae,{}),controls:e.jsxs("div",{className:"flex items-center gap-3 sm:gap-5",children:[e.jsxs("div",{className:"hidden sm:flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Total:"}),e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:`${m.total} discovered node${m.total!==1?"s":""} on the mesh network`,children:[e.jsx(ae,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:m.total})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs text-fg-muted",children:"Types:"}),m.repeaters>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Repeaters",children:[e.jsx(he,{className:"w-3.5 h-3.5 text-sys-blue"}),e.jsx("span",{children:m.repeaters})]}),m.companions>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Companions",children:[e.jsx($e,{className:"w-3.5 h-3.5 text-fg-muted"}),e.jsx("span",{children:m.companions})]}),m.roomServers>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Room Servers",children:[e.jsx(fe,{className:"w-3.5 h-3.5 text-sys-pink"}),e.jsx("span",{children:m.roomServers})]}),m.withLocation>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"With GPS location",children:[e.jsx(Us,{className:"w-3.5 h-3.5 text-sys-green"}),e.jsx("span",{children:m.withLocation})]}),m.unknown>0&&e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:"Unknown type",children:[e.jsx(ze,{className:"w-3.5 h-3.5 text-sys-amber"}),e.jsx("span",{children:m.unknown})]})]})]}),e.jsxs("div",{className:"flex sm:hidden items-center gap-1.5",children:[e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx(ae,{className:"w-3 h-3 text-fg-secondary"}),e.jsx("span",{children:m.total})]}),m.repeaters>0&&e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx(he,{className:"w-3 h-3 text-sys-blue"}),e.jsx("span",{children:m.repeaters})]}),m.companions>0&&e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx($e,{className:"w-3 h-3 text-fg-muted"}),e.jsx("span",{children:m.companions})]}),m.roomServers>0&&e.jsxs("span",{className:"data-box !px-1.5 !py-0.5 !text-[10px] flex items-center gap-1",children:[e.jsx(fe,{className:"w-3 h-3 text-sys-pink"}),e.jsx("span",{children:m.roomServers})]}),e.jsx(Te,{ranges:ve,selectedIndex:C,onSelect:T,size:"sm"})]}),e.jsx("div",{className:"hidden sm:block",children:e.jsx(Te,{ranges:ve,selectedIndex:C,onSelect:T})})]})}),e.jsxs(ks,{children:[H?e.jsx(ut,{neighbors:B,localNode:R??void 0,localHash:q,onRemoveNode:f,selectedNodeHash:Z,onNodeSelected:Ke}):e.jsx("div",{className:"surface-base radius-card aspect-video flex items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-6 h-6 border-2 border-sys-blue border-t-transparent rounded-full animate-spin"}),e.jsx("span",{className:"text-sm text-fg-muted",children:"Loading map..."})]})}),e.jsx(gs,{noPadding:!0,children:H?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 px-3 sm:px-4 py-2.5 border-b border-edge-subtle",children:[e.jsx("span",{className:"icon-md flex items-center justify-center text-icon-card-title flex-shrink-0",children:e.jsx(ae,{})}),e.jsx("span",{className:"type-micro flex-shrink-0 mr-auto hidden sm:block",children:"Discovered Contacts"}),e.jsx(js,{type:"search",size:"sm",value:v,onChange:s=>re(s.target.value),placeholder:"Search...",leadingIcon:e.jsx(qs,{className:"w-3.5 h-3.5"}),trailingIcon:v?e.jsx("button",{onClick:()=>{re(""),(v.toLowerCase().trim()==="neighbor"||v.toLowerCase().trim()==="neighbors")&&Y(!1)},className:"text-fg-muted hover:text-fg-secondary",children:e.jsx(bs,{className:"w-3 h-3"})}):void 0,className:"w-24 sm:w-32 xl:w-44","aria-label":"Search contacts"}),e.jsx("div",{className:"h-4 w-px bg-border-subtle flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsxs("div",{className:"relative","data-dropdown":!0,children:[e.jsxs("button",{onClick:()=>oe(!J),className:we(j.size>0,{border:!0}),title:"Filter by contact type",children:[e.jsx(st,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:"Filter"}),j.size>0&&e.jsx("span",{className:"tabular-nums text-xs bg-sys-blue/30 px-1 rounded",children:j.size})]}),J&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-50 surface-elevated radius-inner py-1 min-w-[140px]",children:[[{key:"repeater",label:"Repeaters"},{key:"companion",label:"Companions"},{key:"room",label:"Rooms"}].map(({key:s,label:t})=>e.jsxs("button",{onClick:()=>{X(a=>{const r=new Set(a);return r.has(s)?r.delete(s):r.add(s),r})},className:"w-full px-3 py-1.5 text-sm text-left hover-bg transition-base flex items-center gap-2",children:[e.jsx("span",{className:ke("w-4 h-4 flex items-center justify-center radius-badge border",j.has(s)?"bg-sys-blue border-sys-blue text-white":"border-edge-subtle"),children:j.has(s)&&e.jsx(Ce,{className:"w-3 h-3"})}),e.jsx("span",{className:j.has(s)?"text-fg-primary":"text-fg-secondary",children:t})]},s)),j.size>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t border-edge-subtle my-1"}),e.jsx("button",{onClick:()=>X(new Set),className:"w-full px-3 py-1.5 text-sm text-left text-fg-muted hover:text-fg-secondary hover-bg transition-base",children:"Clear filters"})]})]})]}),me.size>0&&e.jsxs("button",{onClick:()=>Y(!_),className:we(_,{color:"success",border:!0}),title:_?"Show all contacts":"Show only MeshCore neighbors (direct RF contact)",children:[e.jsx(he,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:"Neighbors"})]})]}),e.jsx("div",{className:"h-4 w-px bg-border-subtle flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[Nt.map(({field:s,icon:t,label:a})=>e.jsxs("button",{onClick:()=>Ge(s),className:we(E===s),title:`Sort by ${a.toLowerCase()}`,children:[e.jsx(t,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:a}),E===s&&e.jsx(Ks,{className:ke("w-3 h-3",I==="asc"&&"rotate-180")})]},s)),e.jsx("div",{className:"h-4 w-px bg-border-subtle"}),e.jsxs(Cs,{value:M,onChange:We,className:"w-auto min-w-[50px] [&_button]:py-1 [&_button]:px-2 [&_button]:text-xs [&_button]:min-h-0","aria-label":"Items per page",children:[e.jsx(pe,{value:25,children:"25"}),e.jsx(pe,{value:50,children:"50"}),e.jsx(pe,{value:100,children:"100"}),e.jsx(pe,{value:0,children:"All"})]})]})]}),p.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hidden sm:grid contacts-grid-header border-b border-edge-subtle/50 px-3 py-2 type-micro text-fg-muted",children:[e.jsx("div",{className:"contacts-col-node",children:"Node"}),e.jsx("div",{className:"contacts-col-signal text-right",children:"Signal"}),e.jsx("div",{className:"contacts-col-distance text-right",children:"Distance"}),e.jsx("div",{className:"contacts-col-centrality text-right",children:"Centrality"}),e.jsx("div",{className:"contacts-col-seen text-right",children:"Last Seen"}),e.jsx("div",{className:"contacts-col-actions"})]}),e.jsx("div",{className:"divide-y divide-edge-subtle/30",children:_e.map(([s,t])=>{const a=ne(s),r=qe.has(s),c=me.has(s),l=de.get(s)??null,V=g.get(s)||0,b=c?Ue.get(s):void 0,S=a?Q.get(a)??null:null,O=N.get(s)??yt;let te=null;if(!c&&q&&h.size>0){const Ze=`${s}→${q}`,ue=h.get(Ze);if(ue&&ue.hops.length>0){const Pe=ue.hops[0],Re=Object.keys(le).find(es=>es.toUpperCase().startsWith(Pe.toUpperCase())),W=Re?le[Re]:null;te={prefix:Pe,name:(W==null?void 0:W.node_name)??(W==null?void 0:W.name)??null,hopCount:ue.hopCount}}}const xe=d.has(s),Je=Ve.get(s)??null;return e.jsx(jt,{hash:s,contact:t,isHub:r,isNeighbor:c,distance:l,centrality:V,sparklineData:O,neighborSignal:b,collisionInfo:S,isViterbiResolved:A,isPinging:P!==null,isPingingThis:P===s,pingResult:je.get(s),pingError:Ie.get(s),gatewayInfo:te,lastForwarderPrefix:Je,isMobile:xe,onRowClick:Qe,onPing:Xe,onRemove:Ye},s)})}),M>0&&U0&&Uce(s=>Math.min(s+M,p.length)),className:"text-sys-blue hover:text-sys-blue/80 transition-base",children:"Load more"})]})]}):e.jsxs("div",{className:"roster-empty",children:[e.jsx(ae,{className:"roster-empty-icon"}),e.jsx("div",{className:"type-label text-fg-secondary",children:"No Contacts Discovered"}),e.jsx("div",{className:"type-data-xs text-fg-muted mt-1",children:"Contacts will appear here as they advertise on the mesh network."})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-edge-subtle",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 rounded bg-elevated animate-pulse"}),e.jsx("div",{className:"w-32 h-4 rounded bg-elevated animate-pulse"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-16 h-6 rounded bg-elevated animate-pulse"}),e.jsx("div",{className:"w-24 h-6 rounded bg-elevated animate-pulse"}),e.jsx("div",{className:"w-16 h-6 rounded bg-elevated animate-pulse"})]})]}),e.jsx("div",{className:"px-3 py-3 space-y-3",children:[...Array(5)].map((s,t)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-5 h-5 rounded bg-elevated animate-pulse"}),e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"h-4 w-32 rounded bg-elevated animate-pulse"}),e.jsx("div",{className:"h-3 w-24 rounded bg-elevated animate-pulse"})]}),e.jsx("div",{className:"w-12 h-4 rounded bg-elevated animate-pulse"}),e.jsx("div",{className:"w-16 h-4 rounded bg-elevated animate-pulse"})]},t))})]})})]}),e.jsx(Vs,{isOpen:!!u,title:"Remove Contact",message:`Are you sure you would like to remove ${(u==null?void 0:u.name)||"this contact"}?`,confirmLabel:"Remove",cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{u&&f(u.hash),K(null)},onCancel:()=>K(null)})]})}const Gt=Object.freeze(Object.defineProperty({__proto__:null,default:Ct},Symbol.toStringTag,{value:"Module"}));export{Gt as C,ht as P,De as R,dt as T}; diff --git a/frontend/dist/assets/ContactsMapMapLibre-CKQy2_cg.js b/frontend/dist/assets/ContactsMapMapLibre-7MZRUDIi.js similarity index 99% rename from frontend/dist/assets/ContactsMapMapLibre-CKQy2_cg.js rename to frontend/dist/assets/ContactsMapMapLibre-7MZRUDIi.js index fc12f4f2..e5a62ed6 100644 --- a/frontend/dist/assets/ContactsMapMapLibre-CKQy2_cg.js +++ b/frontend/dist/assets/ContactsMapMapLibre-7MZRUDIi.js @@ -1,4 +1,4 @@ -import{d as L0,_ as ta,r as R,fa as ra,cR as e0,Z as j0,fb as Fo,fc as gs,fd as na,bD as oa,bJ as ia,j as p,bL as sa,c as I0,a0 as ps,m as u0,ae as ys,A as R0,b as Ur,B as Ot,cS as la,bF as so,M as Po,S as Qo,cI as xs,L as Oo,bh as ws,ac as aa,R as vs,bc as dn,ad as ua,w as zo,b8 as gi,fe as ks,y as ca,E as fa,cQ as ha,ff as da,a9 as bs,bj as pi,bl as ma,x as Ho,bH as ga,aD as pa,e7 as Cs,fg as ya,bM as xa,fh as wa,ep as Es,$ as hn,bX as va,fi as Ss,fj as ka,fk as ba,ah as Ms,q as y0,fl as Bs,bw as Ca,f8 as Ea,by as Sa,cJ as Ma,H as Ba,fm as Da,ej as _a,fn as lo}from"./index-C8IY8K2r.js";import{u as Ds,b as Ar,S as X0,L as t0,P as Ta,c as Ra,M as ja,d as Ia,B as La}from"./BasemapLayer-D5WYHXmJ.js";import{u as _s,r as Ts,e as yi,f as xi,g as Na}from"./consumer-registry-lDKP4bcU.js";import{L as On,c as Fa}from"./link-scoring-CX7bMGSJ.js";import{T as Go,C as Pa}from"./ConfirmModal-CNsW1W2q.js";import{b as Qa,e as Oa,a as Rs,m as wi,f as za,d as Ha,M as Ga,g as Ua,E as Va,u as Wa,G as Ya,h as Ka,i as Za,j as $a,D as qa}from"./DeepAnalysisModal-B2m7JxOp.js";import{H as Ja,A as un,Z as Xa,D as vi,p as Au,c as eu,u as ur}from"./useMapViewStore-ax-BqDpg.js";import{R as js}from"./refresh-cw-BqACEANM.js";import{E as Is}from"./target-DviLCm8U.js";import{F as tu}from"./funnel-BDRRJl0y.js";import{P as ru}from"./plus-PWV57wbr.js";import{C as nu,a as Ls,b as ko,c as ou}from"./easing-CXN4GmUW.js";import{D as iu}from"./download-IUkhheKK.js";import{W as su}from"./wifi-Cq9uCDyf.js";import{C as Ns}from"./SignalIndicator-Dw_bfp50.js";import{C as lu}from"./chevron-right-DUgYTR6d.js";import{T as au,P as uu,R as cu}from"./Contacts-CKgzKZ-Z.js";import{c as fu}from"./node-types-3T9Wr7vI.js";import{H as ki,C as Lr,N as hu,a as du}from"./badge-colors-BNUqIXCA.js";import{L as mu}from"./LightSparkline-CkL4j4OZ.js";import{M as gu}from"./map-pin-DMVHq6j8.js";import{c as Fs}from"./geo-utils-BP1zBK9h.js";import"./triangle-alert-8k00uu7o.js";import"./database-BEyHF_p_.js";import"./index-B-prVW1V.js";import"./ping-lLlOzF2r.js";import"./PageLayout-NQBVrM09.js";import"./listbox-BhQdM5DY.js";import"./element-movement-D4o83B2Z.js";import"./TimeRangeStepper-BlC9rlkV.js";import"./chat-utils-D1Q4VWjO.js";import"./CollisionExplorerModal-DeHgfjGl.js";import"./monitor-smartphone-DF_mmgOV.js";import"./DataBox-W2v3wy8k.js";import"./circle-question-mark-C7l07_IA.js";import"./network-DBkquEPb.js";import"./activity-2-g8m4_g.js";import"./search-zALFwCS4.js";/** +import{d as L0,_ as ta,r as R,fg as ra,cW as e0,Z as j0,fh as Fo,fi as gs,fj as na,bG as oa,bM as ia,j as p,bO as sa,c as I0,a0 as ps,m as u0,ae as ys,A as R0,b as Ur,B as Ot,cX as la,bI as so,M as Po,S as Qo,cN as xs,L as Oo,bh as ws,ac as aa,R as vs,bc as dn,ad as ua,w as zo,b8 as gi,fk as ks,y as ca,E as fa,cV as ha,fl as da,a9 as bs,bj as pi,bl as ma,x as Ho,bK as ga,aD as pa,ed as Cs,fm as ya,bP as xa,fn as wa,fo as Es,$ as hn,b_ as va,fp as Ss,fq as ka,fr as ba,ah as Ms,q as y0,fs as Bs,by as Ca,fe as Ea,bB as Sa,cL as Ds,cO as Ma,H as Ba,ft as Da,ep as _a,fu as lo}from"./index-BwGHI0A_.js";import{u as _s,b as Ar,S as X0,L as t0,P as Ta,c as Ra,M as ja,d as Ia,B as La}from"./BasemapLayer-Bm_seLWQ.js";import{u as Ts,r as Rs,e as yi,f as xi,g as Na}from"./consumer-registry-DPYvsBcc.js";import{L as On,c as Fa}from"./link-scoring-BSZA-fkH.js";import{T as Go,C as Pa}from"./ConfirmModal-B0nTD1Q0.js";import{b as Qa,e as Oa,a as js,m as wi,f as za,d as Ha,M as Ga,g as Ua,E as Va,u as Wa,G as Ya,h as Ka,i as Za,j as $a,D as qa}from"./DeepAnalysisModal-CaP_TRSd.js";import{H as Ja,A as un,Z as Xa,D as vi,p as Au,c as eu,u as ur}from"./useMapViewStore-CPURakCb.js";import{R as Is}from"./refresh-cw-DYpAqCT4.js";import{E as Ls}from"./target-LdPtzGwl.js";import{F as tu}from"./funnel-D4Wxq-Fx.js";import{P as ru}from"./plus-C0xom_iW.js";import{C as nu,a as Ns,b as ko,c as ou}from"./easing-DSebI9nw.js";import{D as iu}from"./download-BbqYTv8j.js";import{W as su}from"./wifi-BaASFkdf.js";import{C as Fs}from"./SignalIndicator-LNOR_5YF.js";import{C as lu}from"./chevron-right-DqpRZiGf.js";import{T as au,P as uu,R as cu}from"./Contacts-CcwYnw5c.js";import{c as fu}from"./node-types-DmTOZWT4.js";import{H as ki,C as Lr,N as hu,a as du}from"./badge-colors-BNUqIXCA.js";import{L as mu}from"./LightSparkline-5OIe9Q0M.js";import{M as gu}from"./map-pin-VRY_TOuh.js";import"./triangle-alert-B4kC1YDk.js";import"./database-CDN_R6oC.js";import"./index-OH01SZkk.js";import"./usePipelineStore-11oXtutw.js";import"./ping-DW5e4gor.js";import"./PageLayout-BIcqC04y.js";import"./listbox-_tsR-2yL.js";import"./element-movement-BqZOD4DT.js";import"./TimeRangeStepper-Dh4JEQ42.js";import"./chat-utils-Di4-nywi.js";import"./CollisionExplorerModal-Cm5c7tcU.js";import"./monitor-smartphone-BxljwdQV.js";import"./DataBox-CQS-Zhu0.js";import"./circle-question-mark-DC7QfrVK.js";import"./network-9doWJxcL.js";import"./activity-Dr_TPIps.js";import"./search-B7iMjmGm.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -43,14 +43,14 @@ import{d as L0,_ as ta,r as R,fa as ra,cR as e0,Z as j0,fb as Fo,fc as gs,fd as * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const Tu=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],Ru=L0("wrench",Tu);function ju(c,u){return u.filter(y=>y.nodes.includes(c)).sort((y,x)=>x.avgCertainCount-y.avgCertainCount)}function Iu(c,u,g){const y=ju(c,u),x=new Set,C=[];for(const T of y)for(const P of T.edgeKeys)if(!x.has(P)){x.add(P);const _=g.get(P);C.push({key:P,certainCount:(_==null?void 0:_.certainCount)??0})}return C.sort((T,P)=>P.certainCount-T.certainCount),{loops:y,highlightedEdgeKeys:x,sortedEdges:C}}function Lu(c){const u=new Map;for(const g of c)for(const y of g.edgeKeys){const x=u.get(y)??[];x.push(g),u.set(y,x)}return u}const Sn={MAX_THICKNESS_AT:300,MIN_VALIDATIONS:5},Nu=6,bi=1;function Co(c,u){const g=Math.max(Sn.MIN_VALIDATIONS,Math.min(c,Sn.MAX_THICKNESS_AT)),y=Math.log(Sn.MIN_VALIDATIONS),x=Math.log(Sn.MAX_THICKNESS_AT),T=(Math.log(g)-y)/(x-y);return bi+(Nu-bi)*T}const Fu=Pu(Qu);function Pu(c){return function(u,g,y=g){if(!((g=+g)>=0))throw new RangeError("invalid rx");if(!((y=+y)>=0))throw new RangeError("invalid ry");let{data:x,width:C,height:T}=u;if(!((C=Math.floor(C))>=0))throw new RangeError("invalid width");if(!((T=Math.floor(T!==void 0?T:x.length/C))>=0))throw new RangeError("invalid height");if(!C||!T||!g&&!y)return u;const P=g&&c(g),_=y&&c(y),E=x.slice();return P&&_?(Nr(P,E,x,C,T),Nr(P,x,E,C,T),Nr(P,E,x,C,T),Fr(_,x,E,C,T),Fr(_,E,x,C,T),Fr(_,x,E,C,T)):P?(Nr(P,x,E,C,T),Nr(P,E,x,C,T),Nr(P,x,E,C,T)):_&&(Fr(_,x,E,C,T),Fr(_,E,x,C,T),Fr(_,x,E,C,T)),u}}function Nr(c,u,g,y,x){for(let C=0,T=y*x;C{if(!((P-=_)>=T))return;let E=u*C[T];const Q=_*u,O=Q+_;for(let H=T,V=T+Q;H{if(!((C-=T)>=x))return;let P=c*y[x];const _=T*c;for(let E=x,Q=x+_;E=y&&++g;return g}function Hu(c,u,g){let y;for(;;){const x=Qa(c,u,g);if(x===y||x===0||!isFinite(x))return[c,u];x>0?(c=Math.floor(c/x)*x,u=Math.ceil(u/x)*x):x<0&&(c=Math.ceil(c*x)/x,u=Math.floor(u*x)/x),y=x}}function Gu(c){return Math.max(1,Math.ceil(Math.log(zu(c))/Math.LN2)+1)}var Uu=Array.prototype,Qs=Uu.slice;function Vu(c,u){return c-u}function Wu(c){for(var u=0,g=c.length,y=c[g-1][1]*c[0][0]-c[g-1][0]*c[0][1];++u()=>c;function Yu(c,u){for(var g=-1,y=u.length,x;++gy!=V>y&&g<(H-E)*(y-Q)/(V-Q)+E&&(x=-x)}return x}function Zu(c,u,g){var y;return $u(c,u,g)&&qu(c[y=+(c[0]===u[0])],g[y],u[y])}function $u(c,u,g){return(u[0]-c[0])*(g[1]-c[1])===(g[0]-c[0])*(u[1]-c[1])}function qu(c,u,g){return c<=u&&u<=g||g<=u&&u<=c}function Ju(){}var _0=[[],[[[1,1.5],[.5,1]]],[[[1.5,1],[1,1.5]]],[[[1.5,1],[.5,1]]],[[[1,.5],[1.5,1]]],[[[1,1.5],[.5,1]],[[1,.5],[1.5,1]]],[[[1,.5],[1,1.5]]],[[[1,.5],[.5,1]]],[[[.5,1],[1,.5]]],[[[1,1.5],[1,.5]]],[[[.5,1],[1,.5]],[[1.5,1],[1,1.5]]],[[[1.5,1],[1,.5]]],[[[.5,1],[1.5,1]]],[[[1,1.5],[1.5,1]]],[[[.5,1],[1,1.5]]],[]];function Ci(){var c=1,u=1,g=Gu,y=_;function x(E){var Q=g(E);if(Array.isArray(Q))Q=Q.slice().sort(Vu);else{const O=Oa(E,Xu);for(Q=Rs(...Hu(O[0],O[1],Q),Q);Q[Q.length-1]>=O[1];)Q.pop();for(;Q[1]C(E,O))}function C(E,Q){const O=Q==null?NaN:+Q;if(isNaN(O))throw new Error(`invalid value: ${Q}`);var H=[],V=[];return T(E,O,function(K){y(K,E,O),Wu(K)>0?H.push([K]):V.push(K)}),V.forEach(function(K){for(var aA=0,J=H.length,eA;aA=Q,_0[Z<<2].forEach(oA);++K0&&V0&&K=0&&O>=0))throw new Error("invalid size");return c=Q,u=O,x},x.thresholds=function(E){return arguments.length?(g=typeof E=="function"?E:Array.isArray(E)?J0(Qs.call(E)):J0(E),x):g},x.smooth=function(E){return arguments.length?(y=E?_:Ju,x):y===_},x}function Xu(c){return isFinite(c)?c:NaN}function cr(c,u){return c==null?!1:+c>=u}function ao(c){return c==null||isNaN(c=+c)?-1/0:c}function Ei(c,u,g,y){const x=y-u,C=g-u,T=isFinite(x)||isFinite(C)?x/C:Math.sign(x)/Math.sign(C);return isNaN(T)?c:c+T-.5}function Ac(c){return c[0]}function ec(c){return c[1]}function tc(){return 1}function rc(){var c=Ac,u=ec,g=tc,y=960,x=500,C=20,T=2,P=C*3,_=y+P*2>>T,E=x+P*2>>T,Q=J0(20);function O(Z){var uA=new Float32Array(_*E),oA=Math.pow(2,-T),vA=-1;for(const LA of Z){var iA=(c(LA,++vA,Z)+P)*oA,fA=(u(LA,vA,Z)+P)*oA,jA=+g(LA,vA,Z);if(jA&&iA>=0&&iA<_&&fA>=0&&fAiA*vA))(uA).map((iA,fA)=>(iA.value=+oA[fA],V(iA)))}H.contours=function(Z){var uA=O(Z),oA=Ci().size([_,E]),vA=Math.pow(2,2*T),iA=fA=>{fA=+fA;var jA=V(oA.contour(uA,fA*vA));return jA.value=fA,jA};return Object.defineProperty(iA,"max",{get:()=>wi(uA)/vA}),iA};function V(Z){return Z.coordinates.forEach(K),Z}function K(Z){Z.forEach(aA)}function aA(Z){Z.forEach(J)}function J(Z){Z[0]=Z[0]*Math.pow(2,T)-P,Z[1]=Z[1]*Math.pow(2,T)-P}function eA(){return P=C*3,_=y+P*2>>T,E=x+P*2>>T,H}return H.x=function(Z){return arguments.length?(c=typeof Z=="function"?Z:J0(+Z),H):c},H.y=function(Z){return arguments.length?(u=typeof Z=="function"?Z:J0(+Z),H):u},H.weight=function(Z){return arguments.length?(g=typeof Z=="function"?Z:J0(+Z),H):g},H.size=function(Z){if(!arguments.length)return[y,x];var uA=+Z[0],oA=+Z[1];if(!(uA>=0&&oA>=0))throw new Error("invalid size");return y=uA,x=oA,eA()},H.cellSize=function(Z){if(!arguments.length)return 1<=1))throw new Error("invalid cell size");return T=Math.floor(Math.log(Z)/Math.LN2),eA()},H.thresholds=function(Z){return arguments.length?(Q=typeof Z=="function"?Z:Array.isArray(Z)?J0(Qs.call(Z)):J0(Z),H):Q},H.bandwidth=function(Z){if(!arguments.length)return Math.sqrt(C*(C+1));if(!((Z=+Z)>=0))throw new Error("invalid bandwidth");return C=(Math.sqrt(4*Z*Z+1)-1)/2,eA()},H}function Eo(){const c=ta();return R.useMemo(()=>ra.getPackets(),[c])}const Os=16,So=24,T0=Os,nc=5,yr={textPrimary:j0[900],textSecondary:"#4A4A4A",textMuted:j0[500],border:"rgba(0, 0, 0, 0.12)",hoverBg:"rgba(0, 0, 0, 0.06)",disabledText:"rgba(0, 0, 0, 0.25)"},gr={nodeFill:e0.blue,nodeStroke:"rgba(255,255,255,0.9)",nodeColor:e0.indigo,localColor:e0.amber,hubColor:e0.purple,gatewayColor:e0.indigo,mobileColor:e0.orange,roomServerColor:e0.pink,neighborColor:e0.amber,edges:{rest:j0[700],restBright:j0[600],restDim:j0[800],hoverDirect:"#6FBCBD",hoverLoop:"#8B7BAD",hoverStandard:j0[400],hoverNeighbor:e0.amber,neighborRest:j0[500],neighborHover:e0.amber,highlight:"#FFD700"},edgeOpacity:.82};function Uo(){if(typeof window>"u")return gr;const c=Fo(),u=gs();return{nodeFill:c.nodeFill,nodeStroke:c.nodeStroke,nodeColor:gr.nodeColor,localColor:c.localColor,hubColor:c.hubColor,gatewayColor:c.gatewayColor,mobileColor:c.mobileColor,roomServerColor:c.roomColor,neighborColor:c.neighborColor,edges:{rest:u.rest,restBright:u.restBright,restDim:u.restDim,hoverDirect:u.hoverDirect,hoverLoop:u.hoverLoop,hoverStandard:u.hoverStandard,hoverNeighbor:u.hoverNeighbor,neighborRest:gr.edges.neighborRest,neighborHover:gr.edges.neighborHover,highlight:u.highlight},edgeOpacity:gr.edgeOpacity}}const Mn=2e3,Bn=750,oc="#00FF00",ic=500,Si=500,Mi=250,sc=150,zs=200,lc=Ur.snappy,x0=yr,Hs=R.createContext("dark"),Vn=()=>R.useContext(Hs);function Pr({color:c,ring:u}){const g=T0-2;return p.jsx("span",{className:"shrink-0 rounded-full","aria-hidden":"true",style:{width:g,height:g,backgroundColor:u?"transparent":c,border:u?`${nc-1}px solid ${c}`:void 0,boxSizing:"border-box"}})}function uo({color:c,pattern:u="solid"}){return p.jsx("svg",{className:"shrink-0","aria-hidden":"true",width:18,height:6,viewBox:"0 0 18 6",children:p.jsx("line",{x1:0,y1:3,x2:18,y2:3,stroke:c,strokeWidth:3,strokeLinecap:"round",strokeDasharray:u==="dashed"?"5,3":u==="dotted"?"2,3":void 0})})}function A0({indicator:c,label:u,tooltip:g}){const y=Vn()==="light";return p.jsxs("div",{className:"flex items-center gap-1.5",children:[c,p.jsx("span",{className:I0(!y&&"text-fg-secondary"),style:y?{color:x0.textSecondary}:void 0,children:u}),g&&p.jsx(ps,{content:g,delay:zs,children:p.jsx("span",{className:I0("cursor-help text-[11px] opacity-75 hover:opacity-100 transition-opacity",!y&&"text-fg-muted"),style:y?{color:x0.textMuted}:void 0,children:"ⓘ"})})]})}function ac(c){return`legend-section-${c.toLowerCase().replace(/\s+/g,"-")}`}function co({title:c,tooltip:u,isOpen:g,onToggle:y,showDivider:x,children:C}){const T=Vn()==="light",P=ac(c);return p.jsxs("div",{className:x?"mt-2 pt-2 border-t":"",style:x?{borderColor:T?x0.border:"var(--map-ui-border)"}:void 0,children:[p.jsxs("button",{type:"button",onClick:y,"aria-expanded":g,"aria-controls":P,className:I0("group w-full flex items-center justify-between py-1 min-h-[44px] sm:min-h-0 font-medium transition-colors",!T&&"text-fg-secondary hover:text-fg-primary"),style:T?{color:x0.textSecondary}:void 0,children:[p.jsxs("span",{className:"flex items-center gap-1",children:[c,p.jsx(ps,{content:u,delay:zs,children:p.jsx("span",{className:I0("cursor-help text-[11px] opacity-75 group-hover:opacity-100 transition-opacity",!T&&"text-fg-muted"),style:T?{color:x0.textMuted}:void 0,children:"ⓘ"})})]}),p.jsx(u0.span,{animate:{rotate:g?0:-90},transition:{duration:.15},"aria-hidden":"true",children:p.jsx(ys,{className:"w-3 h-3",style:T?{color:x0.textMuted}:{color:"var(--fg-muted)"}})})]}),p.jsx(R0,{initial:!1,children:g&&p.jsx(u0.div,{id:P,role:"region","aria-label":c,initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:lc,className:"overflow-hidden",children:p.jsx("div",{className:"flex flex-col gap-1 pt-1.5",children:C})})})]})}function Bi({label:c,value:u,color:g}){const y=Vn()==="light";return p.jsxs("div",{className:I0("flex justify-between tabular-nums",!y&&"text-fg-muted"),style:y?{color:x0.textMuted}:void 0,children:[p.jsx("span",{children:c}),p.jsx("span",{style:g?{color:g}:y?{color:x0.textSecondary}:{color:"var(--fg-secondary)"},children:u})]})}function Di({icon:c,color:u,title:g,subtitle:y}){const x=Vn()==="light";return p.jsx("div",{className:"mt-1.5 pt-1.5 border-t",style:{borderColor:x?x0.border:"var(--map-ui-border)"},children:p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx("span",{className:"shrink-0",style:{color:u},children:c}),p.jsxs("div",{className:"flex flex-col min-w-0",children:[p.jsx("span",{className:"font-medium truncate",style:{color:u},children:g}),p.jsx("span",{className:I0("text-[10px] leading-tight",!x&&"text-fg-muted"),style:x?{color:x0.textMuted}:void 0,children:y})]})]})})}function uc(c){return c.some(([,u])=>{var y;const g=(y=u.contact_type)==null?void 0:y.toLowerCase();return g==="room server"||g==="room_server"||g==="room"||g==="server"})}function cc(c){let u=0;for(const g of c.txDelayRecommendations.values())g.networkRole==="backbone"&&u++;return u}function fc({showTopology:c,validatedPolylineCount:u,filteredNeighborCount:g,hasLocalNode:y,meshTopology:x,zeroHopNeighbors:C,neighborsWithLocation:T,basemapMode:P="dark"}){const _=na(),E=oa(),Q=ia(),O=E.filter(oA=>oA.isLikelyReal).length,H=cc(x),V=C.size>0,[K,aA]=R.useState(!0),[J,eA]=R.useState(!0),[Z,uA]=R.useState(!0);return p.jsx(Hs.Provider,{value:P,children:p.jsxs("div",{className:"map-control-surface p-2.5 text-xs",children:[p.jsxs(co,{title:"Nodes",tooltip:"Node type shown by shape + color. Yellow = direct RF neighbor.",isOpen:K,onToggle:()=>aA(oA=>!oA),children:[p.jsx(A0,{indicator:p.jsx(Pr,{color:_.nodeFill}),label:"Node",tooltip:"Standard mesh node. Repeater, client, or companion device."}),p.jsx(A0,{indicator:p.jsx(Pr,{color:_.hubColor}),label:"Hub",tooltip:"Network hub (≥10% of last-hop traffic)."}),uc(T)&&p.jsx(A0,{indicator:p.jsx(sa,{className:"w-3 h-3 shrink-0",style:{color:_.roomColor},strokeWidth:2.5}),label:"Room",tooltip:"Room Server identity for client sync."}),p.jsx(A0,{indicator:p.jsx(Ja,{className:"w-3 h-3 shrink-0",style:{color:_.localColor},strokeWidth:2.5}),label:"Local",tooltip:"Your repeater running pyMC_Repeater."}),V&&p.jsx(A0,{indicator:p.jsx(Pr,{color:_.neighborColor}),label:"Neighbor",tooltip:"Zero-hop direct RF contact."}),x.gatewayNodes.length>0&&p.jsx(A0,{indicator:p.jsx(Pr,{color:_.gatewayColor}),label:"Gateway",tooltip:"Significant forwarder (7-10% traffic)."}),H>0&&p.jsx(A0,{indicator:p.jsx(Pr,{color:_.hubColor}),label:"Backbone",tooltip:"Critical relay with high centrality."}),x.mobileNodes.length>0&&p.jsx(A0,{indicator:p.jsx(Pr,{color:_.mobileColor,ring:!0}),label:"Mobile",tooltip:"Volatile node that appears/disappears."}),O>0&&p.jsx(A0,{indicator:p.jsx(za,{className:"w-3 h-3 shrink-0",style:{color:_.ghostColor},strokeWidth:2.5}),label:`Ghost (${O})`,tooltip:"Unknown repeater from Viterbi analysis."})]}),V&&p.jsxs(co,{title:"Link Quality",tooltip:"Neighbor edge colors based on bidirectional balance.",isOpen:J,onToggle:()=>eA(oA=>!oA),showDivider:!0,children:[p.jsx(A0,{indicator:p.jsx(uo,{color:On.YELLOW,pattern:"solid"}),label:"2-Way",tooltip:"33-67% balanced. Ideal bidirectional link."}),p.jsx(A0,{indicator:p.jsx(uo,{color:On.GREEN,pattern:"dashed"}),label:"Listener",tooltip:">67% listener. They hear us well."}),p.jsx(A0,{indicator:p.jsx(uo,{color:On.RED,pattern:"dotted"}),label:"Loud",tooltip:"<33% listener. They route more to us."})]}),c&&u>0&&p.jsxs(co,{title:"Topology",tooltip:"Links with 5+ validations. Thickness = strength.",isOpen:Z,onToggle:()=>uA(oA=>!oA),showDivider:!0,children:[p.jsx(Bi,{label:"Nodes",value:g+(y?1:0)}),x.hubNodes.length>0&&p.jsx(Bi,{label:"Hubs",value:x.hubNodes.length,color:gr.hubColor}),x.loops.length>0&&p.jsx(Di,{icon:p.jsx(js,{className:"w-3 h-3"}),color:gr.edges.hoverLoop,title:`${x.loops.length} ${x.loops.length===1?"Loop":"Loops"}`,subtitle:"Redundant paths"}),Q.totalPaths>0&&p.jsx(Di,{icon:p.jsx(Is,{className:"w-3 h-3"}),color:_.ghostColor,title:`${Q.totalPaths.toLocaleString()} Viterbi`,subtitle:"HMM decoded paths"})]})]})})}const _i={repeater:"blue",companion:"cyan",room_server:"pink",hubs:"indigo",direct:"green"},Dn={repeater:"Repeaters",companion:"Companions",room_server:"Rooms",hubs:"Hubs",direct:"Direct"},Ti={repeater:"Repeater nodes (mesh relays)",companion:"Companion devices (clients)",room_server:"Room server nodes",hubs:"Hub nodes and their connections",direct:"Zero-hop (direct RF) neighbors"},hc=["repeater","companion","room_server"],Ri=["hubs","direct"],Qr="!p-2.5 sm:!p-1.5 !rounded-md min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 shrink-0 flex items-center justify-center",_n="!p-2.5 sm:!p-1.5 !rounded-none min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 shrink-0 flex items-center justify-center",dc=()=>typeof window>"u"?!1:window.innerWidth<640;function mc({mapRef:c,showNeighborLines:u,onToggleNeighborLines:g,hasNeighborPolylines:y,nodeFilters:x,onToggleFilter:C,onToggleAll:T,filterCounts:P,showCoverage:_,onToggleCoverage:E,showMinCut:Q=!1,onToggleMinCut:O,hasMinCutData:H=!1,show3DTerrain:V,onToggle3DTerrain:K,basemapMode:aA,onToggleBasemap:J,isFullscreen:eA,onToggleFullscreen:Z,showLinkQuality:uA=!1,onToggleLinkQuality:oA,hasTraceLinks:vA=!1}){const[iA,fA]=R.useState(()=>!dc()),jA=()=>{var NA,GA;(GA=(NA=c.current)==null?void 0:NA.getMap())==null||GA.zoomIn()},DA=()=>{var NA,GA;(GA=(NA=c.current)==null?void 0:NA.getMap())==null||GA.zoomOut()},CA=()=>{var GA;const NA=(GA=c.current)==null?void 0:GA.getMap();NA&&NA.easeTo({bearing:0,pitch:0,duration:300})},yA="w-4 h-4",kA=aA==="light"?"#525252":"var(--fg-secondary)",LA=x.length>=un.length;return p.jsx(p.Fragment,{children:p.jsxs("div",{className:"absolute top-3 right-3 z-[600] flex flex-col gap-2 sm:top-4 sm:right-4 max-w-[calc(100vw-1.5rem)] sm:max-w-none pr-[env(safe-area-inset-right)]",children:[p.jsxs("div",{className:"map-control-surface flex flex-nowrap items-center gap-0.5 sm:gap-1 p-1 overflow-hidden",children:[y&&p.jsx(Ot,{plain:!0,color:u?"warning":"muted",onClick:g,title:u?"Hide edge lines":"Show edge lines","aria-label":u?"Hide edge lines":"Show edge lines","aria-pressed":u,className:Qr,"data-tint":u?"warning":void 0,children:p.jsx(la,{className:yA})}),p.jsx(Ot,{plain:!0,color:"muted",onClick:()=>fA(NA=>!NA),title:iA?"Hide node filters":"Show node filters","aria-label":iA?"Collapse node filters":"Expand node filters","aria-expanded":iA,className:Qr,children:p.jsx(tu,{className:yA})}),p.jsx(R0,{initial:!1,children:iA&&p.jsxs(u0.div,{className:"flex items-center gap-0.5 flex-nowrap overflow-x-auto scrollbar-none max-w-[50vw] sm:max-w-none sm:overflow-visible",role:"group","aria-label":"Node type filters",initial:{width:0,opacity:0},animate:{width:"auto",opacity:1},exit:{width:0,opacity:0},transition:{duration:.2,ease:[.4,0,.2,1]},children:[p.jsx(so,{color:LA?"green":"zinc",customColor:LA?void 0:kA,onClick:T,title:"Show all nodes","aria-pressed":LA,"aria-label":"Show all node types",className:"shrink-0",children:"All"}),hc.map(NA=>{const GA=P[NA];if(GA===0)return null;const bA=!LA&&x.includes(NA);return p.jsx(so,{color:bA?_i[NA]:"zinc",customColor:bA?void 0:kA,onClick:()=>C(NA),title:Ti[NA],"aria-pressed":bA,"aria-label":`${Dn[NA]} (${GA})`,className:"shrink-0",children:Dn[NA]},NA)}),Ri.some(NA=>P[NA]>0)&&p.jsx("span",{className:"mx-0.5 h-3 w-px bg-[var(--map-ui-border,var(--edge-subtle))] hidden sm:block shrink-0","aria-hidden":"true"}),Ri.map(NA=>{const GA=P[NA];if(GA===0)return null;const bA=!LA&&x.includes(NA);return p.jsx(so,{color:bA?_i[NA]:"zinc",customColor:bA?void 0:kA,onClick:()=>C(NA),title:Ti[NA],"aria-pressed":bA,"aria-label":`${Dn[NA]} (${GA})`,className:"shrink-0",children:Dn[NA]},NA)})]})}),H&&O&&p.jsx(Ot,{plain:!0,color:Q?"primary":"muted",onClick:O,title:Q?"Hide community partition":"Show community partition","aria-label":Q?"Hide community partition":"Show community partition","aria-pressed":Q,className:Qr,"data-tint":Q?"primary":void 0,children:p.jsx(bo,{className:yA})}),p.jsx(Ot,{plain:!0,color:aA==="light"?"primary":"muted",onClick:J,title:aA==="light"?"Switch to dark map":"Switch to light map","aria-label":aA==="light"?"Switch to dark map":"Switch to light map","aria-pressed":aA==="light",className:Qr,"data-tint":aA==="light"?"primary":void 0,children:aA==="light"?p.jsx(Po,{className:yA}):p.jsx(Qo,{className:yA})}),p.jsx(Ot,{plain:!0,color:V?"success":"muted",onClick:K,title:V?"Disable 3D terrain":"Enable 3D terrain","aria-label":V?"Disable 3D terrain":"Enable 3D terrain","aria-pressed":V,className:Qr,"data-tint":V?"success":void 0,children:p.jsx(bu,{className:yA})}),p.jsx(Ot,{plain:!0,color:"muted",onClick:Z,title:eA?"Exit fullscreen":"Fullscreen","aria-label":eA?"Exit fullscreen":"Enter fullscreen","aria-pressed":eA,className:Qr,children:eA?p.jsx(Ha,{className:yA}):p.jsx(Ga,{className:yA})})]}),p.jsxs("div",{className:"map-control-surface flex flex-col items-stretch !overflow-hidden self-end !p-0",children:[p.jsx(Ot,{plain:!0,color:"muted",onClick:jA,title:"Zoom in","aria-label":"Zoom in",className:_n,children:p.jsx(ru,{className:yA})}),p.jsx("div",{className:"h-px bg-border-subtle","aria-hidden":"true"}),p.jsx(Ot,{plain:!0,color:"muted",onClick:DA,title:"Zoom out","aria-label":"Zoom out",className:_n,children:p.jsx(xs,{className:yA})}),p.jsx("div",{className:"h-px bg-border-subtle","aria-hidden":"true"}),p.jsx(Ot,{plain:!0,color:"muted",onClick:CA,title:"Reset bearing to north","aria-label":"Reset bearing to north",className:_n,children:p.jsx(nu,{className:yA})})]}),vA&&oA&&p.jsx("div",{className:"map-control-surface flex flex-col items-stretch !overflow-hidden self-end !p-0",children:p.jsx(Ot,{plain:!0,color:uA?"success":"muted",onClick:oA,title:uA?"Hide link quality overlay":"Show link quality overlay","aria-label":uA?"Hide link quality overlay":"Show link quality overlay","aria-pressed":uA,className:_n,"data-tint":uA?"success":void 0,children:p.jsx(Ps,{className:yA})})})]})})}const gc="#4ADE80",pc="#16A34A",yc="rgba(10, 26, 10, 1)",xc="rgba(220, 252, 231, 1)",fo={text:yr.textSecondary,activeText:pc,activeBg:xc},wc={activeBg:yc},fr="DeepAnalysis",vc=700,ji="abcdefghijklmnopqrstuvwxyz0123456789";function kc(){return ji[Math.floor(Math.random()*ji.length)]}function bc({isActive:c,hasAnalyzed:u,isLoading:g,onClick:y,basemapMode:x="dark"}){const C=x==="light",T=C?fo.text:void 0,P=C?fo.activeText:gc,[_,E]=R.useState(!1),[Q,O]=R.useState(fr),H=R.useRef(!1),V=R.useRef(null),[K]=R.useState(()=>{var Z;return typeof window<"u"&&(((Z=window.matchMedia)==null?void 0:Z.call(window,"(hover: hover)").matches)??!1)}),aA=_&&!c&&!g&&K;R.useEffect(()=>{if(_&&!c&&!g&&!H.current){H.current=!0;const Z=performance.now(),uA=oA=>{const vA=oA-Z,iA=Math.min(vA/vc,1),fA=Math.floor(iA*fr.length);let jA="";for(let DA=0;DA{V.current&&cancelAnimationFrame(V.current)}},[_,c,g]);const J=g?"Analyzing...":Q,eA=g?"Analyzing packet history":u?c?"Hide topology edges":"Show topology edges":"Load full packet history and build topology";return p.jsxs("button",{onClick:y,onMouseEnter:()=>K&&E(!0),onMouseLeave:()=>K&&E(!1),onPointerEnter:()=>K&&E(!0),onPointerLeave:()=>K&&E(!1),disabled:g,className:`map-tool-btn flex items-center gap-2 w-full text-left radius-inner transition-base ${g?"cursor-wait":""}`,style:{padding:"0.5rem 0.625rem",...c&&{backgroundColor:C?fo.activeBg:wc.activeBg}},title:eA,"aria-label":eA,"aria-pressed":c,children:[g?p.jsx(Oo,{className:"w-3.5 h-3.5 shrink-0 animate-spin",style:{color:P}}):p.jsx(Ua,{className:`w-3.5 h-3.5 shrink-0 transition-colors ${c?"":"text-fg-secondary"}`,style:{...c&&{color:P},...aA&&{color:P},...!c&&!aA&&T&&{color:T}}}),p.jsx("span",{className:`${c?"":"text-fg-secondary"}`,"aria-hidden":"true",style:{fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:"0.6875rem",fontWeight:c||aA?700:500,letterSpacing:"-0.01em",lineHeight:1,...c&&{color:P},...aA&&{color:P},...!c&&!aA&&T&&{color:T}},children:J})]})}const Cc=e0.teal,Ec="#0D7377",Sc="rgba(10, 36, 32, 1)",Mc="rgba(204, 251, 241, 1)",ho={text:yr.textSecondary,activeTeal:Ec,activeBg:Mc},Bc={activeBg:Sc},Ii="LiveTrace",Dc=400,Li=100;function _c({isActive:c,onClick:u,basemapMode:g="dark"}){const y=g==="light",x=y?ho.text:void 0,C=y?ho.activeTeal:Cc,[T,P]=R.useState(!1),[_,E]=R.useState(0),Q=R.useRef(!1),O=R.useRef(null),[H,V]=R.useState(0),K=R.useRef(!1),[aA]=R.useState(()=>{var uA;return typeof window<"u"&&(((uA=window.matchMedia)==null?void 0:uA.call(window,"(hover: hover)").matches)??!1)}),J=T&&!c&&aA;R.useEffect(()=>{J&&!K.current&&(K.current=!0,V(1),setTimeout(()=>V(2),Li),setTimeout(()=>V(3),Li*2)),T||(K.current=!1,V(0))},[J,T]),R.useEffect(()=>{if(T&&!c&&!Q.current){Q.current=!0;const uA=performance.now(),oA=vA=>{const iA=vA-uA,fA=Math.min(iA/Dc,1);E(fA),fA<1&&(O.current=requestAnimationFrame(oA))};O.current=requestAnimationFrame(oA)}return T||(O.current&&(cancelAnimationFrame(O.current),O.current=null),Q.current=!1,E(0)),()=>{O.current&&cancelAnimationFrame(O.current)}},[T,c]);const eA=uA=>{if(c)return C;if(!J)return x;const oA=Ii.length,vA=_*(oA+2);return uA>=vA-2&&uAaA&&P(!0),onMouseLeave:()=>aA&&P(!1),onPointerEnter:()=>aA&&P(!0),onPointerLeave:()=>aA&&P(!1),className:"map-tool-btn flex items-center gap-2 w-full text-left radius-inner transition-base",style:{padding:"0.5rem 0.625rem",...c&&{backgroundColor:y?ho.activeBg:Bc.activeBg}},title:c?"Disable live packet tracing (reduces CPU usage)":"Enable live packet tracing","aria-label":Z,"aria-pressed":c,children:[p.jsx(Xa,{className:`w-3.5 h-3.5 shrink-0 ${c?"":"text-fg-secondary"}`,fill:H===1?"#FFFFFF":H===3?C:"none",stroke:H===1||H===2?"#FFFFFF":c||J?C:x||"currentColor",style:{transition:"fill 0.05s, stroke 0.05s"}}),p.jsx("span",{className:`${c?"":"text-fg-secondary"}`,"aria-hidden":"true",style:{fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:"0.6875rem",fontWeight:c||J?700:500,letterSpacing:"-0.01em",lineHeight:1},children:Ii.split("").map((uA,oA)=>p.jsx("span",{style:{color:eA(oA)||void 0},children:uA},oA))})]})}const Ni=.2,Tc="rgba(26, 20, 8, 1)",Rc="rgba(254, 243, 199, 1)",Tn={text:yr.textSecondary,activeBg:Rc,disabledText:yr.disabledText},jc={activeBg:Tc},mo=.01,go=1,Fi="#fe8019",Ic="'Wardrive', serif",Mo=1.45,Lc=Mo*1.1,Nc=80;function Fc({isActive:c,onClick:u,brightness:g=.7,onBrightnessChange:y,basemapMode:x="dark"}){const C=x==="light",T=C?Tn.text:void 0,[P,_]=R.useState(!1),[E,Q]=R.useState(!1),[O]=R.useState(()=>{var uA;return typeof window<"u"&&(((uA=window.matchMedia)==null?void 0:uA.call(window,"(hover: hover)").matches)??!1)});R.useEffect(()=>{if(!P||c)return;const uA=requestAnimationFrame(()=>Q(!0)),oA=setTimeout(()=>Q(!1),Nc);return()=>{cancelAnimationFrame(uA),clearTimeout(oA)}},[P,c]);const H=Math.max(mo,Math.min(go,g)),V=uA=>{uA.stopPropagation();const oA=Math.min(go,H+Ni);y==null||y(oA)},K=uA=>{uA.stopPropagation();const oA=Math.max(mo,H-Ni);y==null||y(oA)},aA=Hmo+.001,eA=P&&!c&&O,Z=c?"Configure wardriving coverage":"Show wardriving coverage";return p.jsxs("button",{onClick:u,onMouseEnter:()=>O&&_(!0),onMouseLeave:()=>O&&_(!1),onPointerEnter:()=>O&&_(!0),onPointerLeave:()=>O&&_(!1),className:"map-tool-btn flex items-center gap-2 w-full text-left radius-inner transition-base",style:{padding:"0.5rem 0.625rem",...c&&{backgroundColor:C?Tn.activeBg:jc.activeBg}},title:Z,"aria-label":Z,"aria-pressed":c,children:[p.jsx(Bu,{className:`w-3.5 h-3.5 shrink-0 transition-colors ${c?"text-sys-amber":"text-fg-secondary"}`,style:eA?{color:Fi}:!c&&T?{color:T}:void 0}),p.jsx("span",{className:`${c?"text-sys-amber":"text-fg-secondary"}`,"aria-hidden":"true",style:{fontFamily:c||eA?Ic:"ui-monospace, SFMono-Regular, monospace",fontSize:c||eA?"0.75rem":"0.6875rem",fontWeight:500,letterSpacing:"-0.01em",lineHeight:1,transition:"none",transform:c?`scale(${Mo})`:eA?`scale(${E?Lc:Mo})`:void 0,transformOrigin:"left center",...eA?{color:Fi}:!c&&T?{color:T}:{}},children:"Wardrive"}),c&&y&&p.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[p.jsx("button",{onClick:K,disabled:!J,className:`p-1 sm:p-0.5 min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 flex items-center justify-center rounded transition-colors ${J?"text-sys-amber hover:bg-[var(--map-ui-hover,var(--elevated))] active:bg-[var(--map-ui-active,var(--subtle))]":"cursor-not-allowed"}`,style:J?void 0:{color:C?Tn.disabledText:"rgba(251, 191, 36, 0.3)"},title:`Decrease opacity (${Math.round(H*100)}%)`,"aria-label":`Decrease opacity, currently ${Math.round(H*100)}%`,children:p.jsx(Po,{className:"w-3.5 h-3.5"})}),p.jsx("button",{onClick:V,disabled:!aA,className:`p-1 sm:p-0.5 min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 flex items-center justify-center rounded transition-colors ${aA?"text-sys-amber hover:bg-[var(--map-ui-hover,var(--elevated))] active:bg-[var(--map-ui-active,var(--subtle))]":"cursor-not-allowed"}`,style:aA?void 0:{color:C?Tn.disabledText:"rgba(251, 191, 36, 0.3)"},title:`Increase opacity (${Math.round(H*100)}%)`,"aria-label":`Increase opacity, currently ${Math.round(H*100)}%`,children:p.jsx(Qo,{className:"w-3.5 h-3.5"})})]})]})}const Pc="0123456789bcdefghjkmnpqrstuvwxyz";function Qc(c){let u=!0,g=-90,y=90,x=-180,C=180;for(const T of c.toLowerCase()){const P=Pc.indexOf(T);if(P!==-1)for(let _=4;_>=0;_--){const E=P>>_&1;if(u){const Q=(x+C)/2;E?x=Q:C=Q}else{const Q=(g+y)/2;E?g=Q:y=Q}u=!u}}return{lat:(g+y)/2,lon:(x+C)/2}}function Oc(c){return Math.exp(-c*Math.LN2/7)}const Bo="pymc-wardriving-url",Gs="pymc-wardriving-enabled",Us="pymc-wardriving-brightness",Pi=.7;function zc(){return typeof localStorage>"u"?"":localStorage.getItem(Bo)||""}function Qi(c){typeof localStorage>"u"||(c?localStorage.setItem(Bo,c):localStorage.removeItem(Bo))}function Hc(){return typeof localStorage>"u"?!1:localStorage.getItem(Gs)==="true"}function Rn(c){typeof localStorage>"u"||localStorage.setItem(Gs,String(c))}function Gc(){if(typeof localStorage>"u")return Pi;const c=localStorage.getItem(Us);if(c){const u=parseFloat(c);if(!isNaN(u)&&u>=.01&&u<=1)return u}return Pi}function Uc(c){if(typeof localStorage>"u")return;const u=Math.max(.01,Math.min(1,c));localStorage.setItem(Us,String(u))}const Vc=8e3;async function Wc(c,u={},g=Vc){const y=new AbortController,x=setTimeout(()=>y.abort(),g);try{return await fetch(c,{...u,signal:y.signal})}catch(C){throw C instanceof Error&&C.name==="AbortError"?new Error(`Connection timed out after ${g/1e3}s`):C}finally{clearTimeout(x)}}async function Yc(c){const g=`${c.replace(/\/+$/,"").replace(/\/get-nodes$/,"").replace(/\/get-samples$/,"")}/get-samples`,y=await Wc(g,{headers:{Accept:"application/json"}});if(!y.ok)throw new Error(`Failed to fetch precise samples: ${y.status}`);return y.json()}function Kc(c,u=null){if(c!==null){const y=(Math.max(-12,Math.min(12,c))+12)/24;if(u!==null){const C=(Math.max(-120,Math.min(-50,u))+120)/70;return y*.8+C*.2}return y}return u!==null?(Math.max(-120,Math.min(-50,u))+120)/70:.5}function Zc(c){var g;const u=[];for(const y of c.keys){if(!y.observed)continue;const{lat:x,lon:C}=Qc(y.hash),T=parseInt(y.time,10),P=isNaN(T)?30:(Date.now()-T)/(1e3*60*60*24),_=Oc(P),Q=Kc(y.snr,y.rssi)*(.3+_*.7);u.push({lat:x,lon:C,successRate:y.observed?1:0,weight:Q,totalSamples:1,ageDays:P,geohash:y.hash,repeaters:((g=y.path)==null?void 0:g.map(O=>O.toLowerCase()))||[]})}return u}const cn=ws((c,u)=>({status:"idle",isVisible:Hc(),coveragePoints:[],repeaters:[],error:null,stats:{coverageCount:0,repeaterCount:0,lastUpdated:null},url:zc(),brightness:Gc(),isModalOpen:!1,openModal:()=>c({isModalOpen:!0}),closeModal:()=>c({isModalOpen:!1}),setUrl:g=>c({url:g}),setBrightness:g=>{const y=Math.max(.01,Math.min(1,g));Uc(y),c({brightness:y})},toggleVisibility:()=>{const g=!u().isVisible;Rn(g),c({isVisible:g})},setVisible:g=>{Rn(g),c({isVisible:g})},loadCoverage:async g=>{if(!g.trim())return c({error:"Please enter a URL",status:"error"}),!1;try{new URL(g.trim())}catch{return c({error:"Invalid URL format",status:"error"}),!1}c({error:null,status:"connecting"});try{c({status:"loading"});const y=await Yc(g.trim());if(!y||typeof y!="object")throw new Error("Invalid response from server");if(!Array.isArray(y.keys))throw new Error("No sample data found in response");c({status:"processing"});const x=Zc(y);if(x.length===0)throw new Error("No valid coverage points found");return c({coveragePoints:x,repeaters:[],stats:{coverageCount:x.length,repeaterCount:0,lastUpdated:new Date},status:"success",isVisible:!0,url:g.trim()}),Qi(g.trim()),Rn(!0),!0}catch(y){const x=y instanceof Error?y.message:"Failed to load coverage data";let C=x;return x.includes("timed out")?C="Connection timed out. Server may be unreachable or slow.":x.includes("Failed to fetch")||x.includes("NetworkError")?C="Could not connect to server. Check the URL and try again.":x.includes("CORS")?C="Server does not allow cross-origin requests.":x.includes("404")?C="Coverage endpoint not found. Check the URL.":(x.includes("ERR_NAME_NOT_RESOLVED")||x.includes("DNS"))&&(C="Server not found. Check the URL for typos."),c({error:C,status:"error"}),!1}},clearCoverage:()=>{c({coveragePoints:[],repeaters:[],stats:{coverageCount:0,repeaterCount:0,lastUpdated:null},status:"idle",error:null,isVisible:!1,url:""}),Qi(""),Rn(!1)}})),$c={bg:"#F8F8F8",bgSubtle:"#F0F0F0",bgElevated:"#FFFFFF",bgInput:"#FFFFFF",border:"rgba(0, 0, 0, 0.12)",borderStrong:"rgba(0, 0, 0, 0.20)",borderFocus:"#3B82F6",text:"#1A1A1A",textSecondary:"#4A4A4A",textMuted:"#737373",success:"#059669",successBg:"#ECFDF5",successBorder:"#A7F3D0",error:"#DC2626",errorBg:"#FEF2F2",errorBorder:"#FECACA",info:"#2563EB",infoBg:"#EFF6FF",infoBorder:"#BFDBFE",warning:"#D97706",warningBg:"#FFFBEB",warningBorder:"#FDE68A",primary:"#F59E0B",hoverBg:"rgba(0, 0, 0, 0.04)",sliderTrack:"#E5E7EB",sliderThumb:"#F59E0B"},Vs={bg:"var(--surface)",bgSubtle:"var(--subtle)",bgElevated:"var(--elevated)",bgInput:"var(--subtle)",border:"var(--edge-subtle)",borderStrong:"var(--edge-strong)",borderFocus:"var(--sys-blue)",text:"var(--fg-primary)",textSecondary:"var(--fg-secondary)",textMuted:"var(--fg-muted)",success:"var(--sys-green)",successBg:"rgba(74, 222, 128, 0.1)",successBorder:"rgba(74, 222, 128, 0.3)",error:"var(--sys-red)",errorBg:"rgba(239, 68, 68, 0.1)",errorBorder:"rgba(239, 68, 68, 0.3)",info:"var(--sys-indigo)",infoBg:"rgba(249, 210, 111, 0.1)",infoBorder:"rgba(249, 210, 111, 0.3)",warning:"var(--sys-indigo)",warningBg:"rgba(249, 210, 111, 0.1)",warningBorder:"rgba(249, 210, 111, 0.3)",primary:"var(--sys-indigo)",hoverBg:"var(--hover-tint)",sliderTrack:"var(--elevated)",sliderThumb:"var(--sys-indigo)"},Ws=R.createContext({theme:Vs,isLight:!1});function xr(){return R.useContext(Ws)}function qc({status:c,hasData:u}){const{theme:g,isLight:y}=xr(),x=R.useMemo(()=>c==="connecting"||c==="loading"||c==="processing"?{icon:p.jsx(Oo,{className:"w-3.5 h-3.5 animate-spin"}),label:c==="connecting"?"Connecting...":c==="loading"?"Loading...":"Processing...",color:g.warning,bg:g.warningBg}:c==="error"?{icon:p.jsx(_u,{className:"w-3.5 h-3.5"}),label:"Disconnected",color:g.error,bg:g.errorBg}:u?{icon:p.jsx(su,{className:"w-3.5 h-3.5"}),label:"Connected",color:g.success,bg:g.successBg}:{icon:p.jsx(vs,{className:"w-3.5 h-3.5"}),label:"Ready",color:g.textMuted,bg:y?"rgba(0,0,0,0.04)":"rgba(255,255,255,0.04)"},[c,u,g,y]);return p.jsxs(u0.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},className:"flex items-center gap-1.5 px-2 py-1 rounded-full text-xs font-medium",style:{backgroundColor:x.bg,color:x.color},children:[x.icon,p.jsx("span",{children:x.label})]},x.label)}function Jc({status:c}){const{theme:u}=xr(),g=R.useMemo(()=>{switch(c){case"connecting":return 25;case"loading":return 60;case"processing":return 90;default:return 0}},[c]);return g===0?null:p.jsx(u0.div,{initial:{opacity:0,scaleY:0},animate:{opacity:1,scaleY:1},exit:{opacity:0,scaleY:0},className:"h-1 rounded-full overflow-hidden origin-top",style:{backgroundColor:u.sliderTrack},children:p.jsx(u0.div,{className:"h-full rounded-full",style:{backgroundColor:u.primary},initial:{width:0},animate:{width:`${g}%`},transition:{duration:.4,ease:"easeOut"}})})}function Oi({variant:c,title:u,description:g,onDismiss:y}){const{theme:x}=xr(),C=R.useMemo(()=>{switch(c){case"success":return{icon:p.jsx(zo,{className:"w-4 h-4"}),color:x.success,bg:x.successBg,border:x.successBorder};case"error":return{icon:p.jsx(xu,{className:"w-4 h-4"}),color:x.error,bg:x.errorBg,border:x.errorBorder};case"info":return{icon:p.jsx(vu,{className:"w-4 h-4"}),color:x.info,bg:x.infoBg,border:x.infoBorder}}},[c,x]);return p.jsxs(u0.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:Ur.snappy,className:"flex items-start gap-3 p-3 rounded-lg border",style:{backgroundColor:C.bg,borderColor:C.border,color:C.color},children:[p.jsx("div",{className:"shrink-0 mt-0.5",children:C.icon}),p.jsxs("div",{className:"flex-1 min-w-0",children:[p.jsx("p",{className:"text-sm font-medium",children:u}),g&&p.jsx("p",{className:"text-xs mt-0.5 opacity-80",children:g})]}),y&&p.jsx("button",{onClick:y,className:"shrink-0 p-1 rounded hover:bg-black/10 transition-colors","aria-label":"Dismiss",children:p.jsx(dn,{className:"w-3.5 h-3.5"})})]})}function Xc({value:c,onChange:u,onSubmit:g,disabled:y}){const{theme:x,isLight:C}=xr(),[T,P]=R.useState(!1),_=E=>{E.key==="Enter"&&!E.shiftKey&&!y&&(E.preventDefault(),g())};return p.jsxs("div",{className:"space-y-1.5",children:[p.jsx("label",{className:"block text-sm font-medium",style:{color:x.textSecondary},children:"Coverage Server URL"}),p.jsxs("div",{className:"relative",children:[p.jsx("input",{type:"url",value:c,onChange:E=>u(E.target.value),onKeyDown:_,onFocus:()=>P(!0),onBlur:()=>P(!1),placeholder:"https://coverage.wcmesh.com",disabled:y,className:I0("w-full pl-3 pr-10 py-2.5 rounded-lg border text-sm transition-all duration-150","focus:outline-none",y&&"opacity-50 cursor-not-allowed"),style:{backgroundColor:x.bgInput,borderColor:T?x.borderFocus:x.border,color:x.text,boxShadow:T?`0 0 0 3px ${C?"rgba(59, 130, 246, 0.15)":"rgba(139, 92, 246, 0.15)"}`:"none"}}),c&&!y&&p.jsx("button",{onClick:()=>u(""),className:"absolute right-2.5 top-1/2 -translate-y-1/2 p-1 rounded transition-colors",style:{color:x.textMuted},onMouseEnter:E=>E.currentTarget.style.color=x.text,onMouseLeave:E=>E.currentTarget.style.color=x.textMuted,"aria-label":"Clear URL",children:p.jsx(dn,{className:"w-4 h-4"})})]}),p.jsx("p",{className:"text-xs",style:{color:x.textMuted},children:"Press Enter to connect, or use the Connect button below"})]})}function Af({value:c,onChange:u}){const{theme:g,isLight:y}=xr(),x=Math.round(c*100);return p.jsx(u0.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:Ur.gentle,className:"overflow-hidden",children:p.jsx("div",{className:"p-3 rounded-lg border",style:{backgroundColor:g.bgSubtle,borderColor:g.border},children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("div",{className:"relative w-4 h-4",children:[p.jsx(Po,{className:"w-4 h-4 absolute inset-0 transition-opacity",style:{color:g.textMuted,opacity:c<.5?1:0}}),p.jsx(Qo,{className:"w-4 h-4 absolute inset-0 transition-opacity",style:{color:g.primary,opacity:c>=.5?1:0}})]}),p.jsxs("div",{className:"flex-1",children:[p.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[p.jsx("span",{className:"text-xs font-medium",style:{color:g.textSecondary},children:"Layer Opacity"}),p.jsxs("span",{className:"text-xs font-mono tabular-nums px-1.5 py-0.5 rounded",style:{color:g.text,backgroundColor:y?"rgba(0,0,0,0.06)":"rgba(255,255,255,0.06)"},children:[x,"%"]})]}),p.jsx("input",{type:"range",min:5,max:100,value:x,onChange:C=>u(Number(C.target.value)/100),className:I0("w-full h-2 rounded-full appearance-none cursor-pointer","[&::-webkit-slider-thumb]:appearance-none","[&::-webkit-slider-thumb]:w-4","[&::-webkit-slider-thumb]:h-4","[&::-webkit-slider-thumb]:rounded-full","[&::-webkit-slider-thumb]:cursor-pointer","[&::-webkit-slider-thumb]:transition-transform","[&::-webkit-slider-thumb]:hover:scale-110","[&::-webkit-slider-thumb]:shadow-lg","[&::-moz-range-thumb]:appearance-none","[&::-moz-range-thumb]:w-4","[&::-moz-range-thumb]:h-4","[&::-moz-range-thumb]:rounded-full","[&::-moz-range-thumb]:border-0","[&::-moz-range-thumb]:cursor-pointer"),style:{background:`linear-gradient(to right, ${g.primary} ${x}%, ${g.sliderTrack} ${x}%)`,"--thumb-color":g.sliderThumb}}),p.jsx("style",{children:` + */const Tu=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],Ru=L0("wrench",Tu);function ju(c,u){return u.filter(y=>y.nodes.includes(c)).sort((y,x)=>x.avgCertainCount-y.avgCertainCount)}function Iu(c,u,g){const y=ju(c,u),x=new Set,C=[];for(const T of y)for(const P of T.edgeKeys)if(!x.has(P)){x.add(P);const _=g.get(P);C.push({key:P,certainCount:(_==null?void 0:_.certainCount)??0})}return C.sort((T,P)=>P.certainCount-T.certainCount),{loops:y,highlightedEdgeKeys:x,sortedEdges:C}}function Lu(c){const u=new Map;for(const g of c)for(const y of g.edgeKeys){const x=u.get(y)??[];x.push(g),u.set(y,x)}return u}const Sn={MAX_THICKNESS_AT:300,MIN_VALIDATIONS:5},Nu=6,bi=1;function Co(c,u){const g=Math.max(Sn.MIN_VALIDATIONS,Math.min(c,Sn.MAX_THICKNESS_AT)),y=Math.log(Sn.MIN_VALIDATIONS),x=Math.log(Sn.MAX_THICKNESS_AT),T=(Math.log(g)-y)/(x-y);return bi+(Nu-bi)*T}const Fu=Pu(Qu);function Pu(c){return function(u,g,y=g){if(!((g=+g)>=0))throw new RangeError("invalid rx");if(!((y=+y)>=0))throw new RangeError("invalid ry");let{data:x,width:C,height:T}=u;if(!((C=Math.floor(C))>=0))throw new RangeError("invalid width");if(!((T=Math.floor(T!==void 0?T:x.length/C))>=0))throw new RangeError("invalid height");if(!C||!T||!g&&!y)return u;const P=g&&c(g),_=y&&c(y),E=x.slice();return P&&_?(Nr(P,E,x,C,T),Nr(P,x,E,C,T),Nr(P,E,x,C,T),Fr(_,x,E,C,T),Fr(_,E,x,C,T),Fr(_,x,E,C,T)):P?(Nr(P,x,E,C,T),Nr(P,E,x,C,T),Nr(P,x,E,C,T)):_&&(Fr(_,x,E,C,T),Fr(_,E,x,C,T),Fr(_,x,E,C,T)),u}}function Nr(c,u,g,y,x){for(let C=0,T=y*x;C{if(!((P-=_)>=T))return;let E=u*C[T];const Q=_*u,O=Q+_;for(let H=T,V=T+Q;H{if(!((C-=T)>=x))return;let P=c*y[x];const _=T*c;for(let E=x,Q=x+_;E=y&&++g;return g}function Hu(c,u,g){let y;for(;;){const x=Qa(c,u,g);if(x===y||x===0||!isFinite(x))return[c,u];x>0?(c=Math.floor(c/x)*x,u=Math.ceil(u/x)*x):x<0&&(c=Math.ceil(c*x)/x,u=Math.floor(u*x)/x),y=x}}function Gu(c){return Math.max(1,Math.ceil(Math.log(zu(c))/Math.LN2)+1)}var Uu=Array.prototype,Qs=Uu.slice;function Vu(c,u){return c-u}function Wu(c){for(var u=0,g=c.length,y=c[g-1][1]*c[0][0]-c[g-1][0]*c[0][1];++u()=>c;function Yu(c,u){for(var g=-1,y=u.length,x;++gy!=V>y&&g<(H-E)*(y-Q)/(V-Q)+E&&(x=-x)}return x}function Zu(c,u,g){var y;return $u(c,u,g)&&qu(c[y=+(c[0]===u[0])],g[y],u[y])}function $u(c,u,g){return(u[0]-c[0])*(g[1]-c[1])===(g[0]-c[0])*(u[1]-c[1])}function qu(c,u,g){return c<=u&&u<=g||g<=u&&u<=c}function Ju(){}var _0=[[],[[[1,1.5],[.5,1]]],[[[1.5,1],[1,1.5]]],[[[1.5,1],[.5,1]]],[[[1,.5],[1.5,1]]],[[[1,1.5],[.5,1]],[[1,.5],[1.5,1]]],[[[1,.5],[1,1.5]]],[[[1,.5],[.5,1]]],[[[.5,1],[1,.5]]],[[[1,1.5],[1,.5]]],[[[.5,1],[1,.5]],[[1.5,1],[1,1.5]]],[[[1.5,1],[1,.5]]],[[[.5,1],[1.5,1]]],[[[1,1.5],[1.5,1]]],[[[.5,1],[1,1.5]]],[]];function Ci(){var c=1,u=1,g=Gu,y=_;function x(E){var Q=g(E);if(Array.isArray(Q))Q=Q.slice().sort(Vu);else{const O=Oa(E,Xu);for(Q=js(...Hu(O[0],O[1],Q),Q);Q[Q.length-1]>=O[1];)Q.pop();for(;Q[1]C(E,O))}function C(E,Q){const O=Q==null?NaN:+Q;if(isNaN(O))throw new Error(`invalid value: ${Q}`);var H=[],V=[];return T(E,O,function(K){y(K,E,O),Wu(K)>0?H.push([K]):V.push(K)}),V.forEach(function(K){for(var aA=0,J=H.length,eA;aA=Q,_0[Z<<2].forEach(oA);++K0&&V0&&K=0&&O>=0))throw new Error("invalid size");return c=Q,u=O,x},x.thresholds=function(E){return arguments.length?(g=typeof E=="function"?E:Array.isArray(E)?J0(Qs.call(E)):J0(E),x):g},x.smooth=function(E){return arguments.length?(y=E?_:Ju,x):y===_},x}function Xu(c){return isFinite(c)?c:NaN}function cr(c,u){return c==null?!1:+c>=u}function ao(c){return c==null||isNaN(c=+c)?-1/0:c}function Ei(c,u,g,y){const x=y-u,C=g-u,T=isFinite(x)||isFinite(C)?x/C:Math.sign(x)/Math.sign(C);return isNaN(T)?c:c+T-.5}function Ac(c){return c[0]}function ec(c){return c[1]}function tc(){return 1}function rc(){var c=Ac,u=ec,g=tc,y=960,x=500,C=20,T=2,P=C*3,_=y+P*2>>T,E=x+P*2>>T,Q=J0(20);function O(Z){var uA=new Float32Array(_*E),oA=Math.pow(2,-T),vA=-1;for(const LA of Z){var iA=(c(LA,++vA,Z)+P)*oA,fA=(u(LA,vA,Z)+P)*oA,jA=+g(LA,vA,Z);if(jA&&iA>=0&&iA<_&&fA>=0&&fAiA*vA))(uA).map((iA,fA)=>(iA.value=+oA[fA],V(iA)))}H.contours=function(Z){var uA=O(Z),oA=Ci().size([_,E]),vA=Math.pow(2,2*T),iA=fA=>{fA=+fA;var jA=V(oA.contour(uA,fA*vA));return jA.value=fA,jA};return Object.defineProperty(iA,"max",{get:()=>wi(uA)/vA}),iA};function V(Z){return Z.coordinates.forEach(K),Z}function K(Z){Z.forEach(aA)}function aA(Z){Z.forEach(J)}function J(Z){Z[0]=Z[0]*Math.pow(2,T)-P,Z[1]=Z[1]*Math.pow(2,T)-P}function eA(){return P=C*3,_=y+P*2>>T,E=x+P*2>>T,H}return H.x=function(Z){return arguments.length?(c=typeof Z=="function"?Z:J0(+Z),H):c},H.y=function(Z){return arguments.length?(u=typeof Z=="function"?Z:J0(+Z),H):u},H.weight=function(Z){return arguments.length?(g=typeof Z=="function"?Z:J0(+Z),H):g},H.size=function(Z){if(!arguments.length)return[y,x];var uA=+Z[0],oA=+Z[1];if(!(uA>=0&&oA>=0))throw new Error("invalid size");return y=uA,x=oA,eA()},H.cellSize=function(Z){if(!arguments.length)return 1<=1))throw new Error("invalid cell size");return T=Math.floor(Math.log(Z)/Math.LN2),eA()},H.thresholds=function(Z){return arguments.length?(Q=typeof Z=="function"?Z:Array.isArray(Z)?J0(Qs.call(Z)):J0(Z),H):Q},H.bandwidth=function(Z){if(!arguments.length)return Math.sqrt(C*(C+1));if(!((Z=+Z)>=0))throw new Error("invalid bandwidth");return C=(Math.sqrt(4*Z*Z+1)-1)/2,eA()},H}function Eo(){const c=ta();return R.useMemo(()=>ra.getPackets(),[c])}const Os=16,So=24,T0=Os,nc=5,yr={textPrimary:j0[900],textSecondary:"#4A4A4A",textMuted:j0[500],border:"rgba(0, 0, 0, 0.12)",hoverBg:"rgba(0, 0, 0, 0.06)",disabledText:"rgba(0, 0, 0, 0.25)"},gr={nodeFill:e0.blue,nodeStroke:"rgba(255,255,255,0.9)",nodeColor:e0.indigo,localColor:e0.amber,hubColor:e0.purple,gatewayColor:e0.indigo,mobileColor:e0.orange,roomServerColor:e0.pink,neighborColor:e0.amber,edges:{rest:j0[700],restBright:j0[600],restDim:j0[800],hoverDirect:"#6FBCBD",hoverLoop:"#8B7BAD",hoverStandard:j0[400],hoverNeighbor:e0.amber,neighborRest:j0[500],neighborHover:e0.amber,highlight:"#FFD700"},edgeOpacity:.82};function Uo(){if(typeof window>"u")return gr;const c=Fo(),u=gs();return{nodeFill:c.nodeFill,nodeStroke:c.nodeStroke,nodeColor:gr.nodeColor,localColor:c.localColor,hubColor:c.hubColor,gatewayColor:c.gatewayColor,mobileColor:c.mobileColor,roomServerColor:c.roomColor,neighborColor:c.neighborColor,edges:{rest:u.rest,restBright:u.restBright,restDim:u.restDim,hoverDirect:u.hoverDirect,hoverLoop:u.hoverLoop,hoverStandard:u.hoverStandard,hoverNeighbor:u.hoverNeighbor,neighborRest:gr.edges.neighborRest,neighborHover:gr.edges.neighborHover,highlight:u.highlight},edgeOpacity:gr.edgeOpacity}}const Mn=2e3,Bn=750,oc="#00FF00",ic=500,Si=500,Mi=250,sc=150,zs=200,lc=Ur.snappy,x0=yr,Hs=R.createContext("dark"),Vn=()=>R.useContext(Hs);function Pr({color:c,ring:u}){const g=T0-2;return p.jsx("span",{className:"shrink-0 rounded-full","aria-hidden":"true",style:{width:g,height:g,backgroundColor:u?"transparent":c,border:u?`${nc-1}px solid ${c}`:void 0,boxSizing:"border-box"}})}function uo({color:c,pattern:u="solid"}){return p.jsx("svg",{className:"shrink-0","aria-hidden":"true",width:18,height:6,viewBox:"0 0 18 6",children:p.jsx("line",{x1:0,y1:3,x2:18,y2:3,stroke:c,strokeWidth:3,strokeLinecap:"round",strokeDasharray:u==="dashed"?"5,3":u==="dotted"?"2,3":void 0})})}function A0({indicator:c,label:u,tooltip:g}){const y=Vn()==="light";return p.jsxs("div",{className:"flex items-center gap-1.5",children:[c,p.jsx("span",{className:I0(!y&&"text-fg-secondary"),style:y?{color:x0.textSecondary}:void 0,children:u}),g&&p.jsx(ps,{content:g,delay:zs,children:p.jsx("span",{className:I0("cursor-help text-[11px] opacity-75 hover:opacity-100 transition-opacity",!y&&"text-fg-muted"),style:y?{color:x0.textMuted}:void 0,children:"ⓘ"})})]})}function ac(c){return`legend-section-${c.toLowerCase().replace(/\s+/g,"-")}`}function co({title:c,tooltip:u,isOpen:g,onToggle:y,showDivider:x,children:C}){const T=Vn()==="light",P=ac(c);return p.jsxs("div",{className:x?"mt-2 pt-2 border-t":"",style:x?{borderColor:T?x0.border:"var(--map-ui-border)"}:void 0,children:[p.jsxs("button",{type:"button",onClick:y,"aria-expanded":g,"aria-controls":P,className:I0("group w-full flex items-center justify-between py-1 min-h-[44px] sm:min-h-0 font-medium transition-colors",!T&&"text-fg-secondary hover:text-fg-primary"),style:T?{color:x0.textSecondary}:void 0,children:[p.jsxs("span",{className:"flex items-center gap-1",children:[c,p.jsx(ps,{content:u,delay:zs,children:p.jsx("span",{className:I0("cursor-help text-[11px] opacity-75 group-hover:opacity-100 transition-opacity",!T&&"text-fg-muted"),style:T?{color:x0.textMuted}:void 0,children:"ⓘ"})})]}),p.jsx(u0.span,{animate:{rotate:g?0:-90},transition:{duration:.15},"aria-hidden":"true",children:p.jsx(ys,{className:"w-3 h-3",style:T?{color:x0.textMuted}:{color:"var(--fg-muted)"}})})]}),p.jsx(R0,{initial:!1,children:g&&p.jsx(u0.div,{id:P,role:"region","aria-label":c,initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:lc,className:"overflow-hidden",children:p.jsx("div",{className:"flex flex-col gap-1 pt-1.5",children:C})})})]})}function Bi({label:c,value:u,color:g}){const y=Vn()==="light";return p.jsxs("div",{className:I0("flex justify-between tabular-nums",!y&&"text-fg-muted"),style:y?{color:x0.textMuted}:void 0,children:[p.jsx("span",{children:c}),p.jsx("span",{style:g?{color:g}:y?{color:x0.textSecondary}:{color:"var(--fg-secondary)"},children:u})]})}function Di({icon:c,color:u,title:g,subtitle:y}){const x=Vn()==="light";return p.jsx("div",{className:"mt-1.5 pt-1.5 border-t",style:{borderColor:x?x0.border:"var(--map-ui-border)"},children:p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx("span",{className:"shrink-0",style:{color:u},children:c}),p.jsxs("div",{className:"flex flex-col min-w-0",children:[p.jsx("span",{className:"font-medium truncate",style:{color:u},children:g}),p.jsx("span",{className:I0("text-[10px] leading-tight",!x&&"text-fg-muted"),style:x?{color:x0.textMuted}:void 0,children:y})]})]})})}function uc(c){return c.some(([,u])=>{var y;const g=(y=u.contact_type)==null?void 0:y.toLowerCase();return g==="room server"||g==="room_server"||g==="room"||g==="server"})}function cc(c){let u=0;for(const g of c.txDelayRecommendations.values())g.networkRole==="backbone"&&u++;return u}function fc({showTopology:c,validatedPolylineCount:u,filteredNeighborCount:g,hasLocalNode:y,meshTopology:x,zeroHopNeighbors:C,neighborsWithLocation:T,basemapMode:P="dark"}){const _=na(),E=oa(),Q=ia(),O=E.filter(oA=>oA.isLikelyReal).length,H=cc(x),V=C.size>0,[K,aA]=R.useState(!0),[J,eA]=R.useState(!0),[Z,uA]=R.useState(!0);return p.jsx(Hs.Provider,{value:P,children:p.jsxs("div",{className:"map-control-surface p-2.5 text-xs",children:[p.jsxs(co,{title:"Nodes",tooltip:"Node type shown by shape + color. Yellow = direct RF neighbor.",isOpen:K,onToggle:()=>aA(oA=>!oA),children:[p.jsx(A0,{indicator:p.jsx(Pr,{color:_.nodeFill}),label:"Node",tooltip:"Standard mesh node. Repeater, client, or companion device."}),p.jsx(A0,{indicator:p.jsx(Pr,{color:_.hubColor}),label:"Hub",tooltip:"Network hub (≥10% of last-hop traffic)."}),uc(T)&&p.jsx(A0,{indicator:p.jsx(sa,{className:"w-3 h-3 shrink-0",style:{color:_.roomColor},strokeWidth:2.5}),label:"Room",tooltip:"Room Server identity for client sync."}),p.jsx(A0,{indicator:p.jsx(Ja,{className:"w-3 h-3 shrink-0",style:{color:_.localColor},strokeWidth:2.5}),label:"Local",tooltip:"Your repeater running pyMC_Repeater."}),V&&p.jsx(A0,{indicator:p.jsx(Pr,{color:_.neighborColor}),label:"Neighbor",tooltip:"Zero-hop direct RF contact."}),x.gatewayNodes.length>0&&p.jsx(A0,{indicator:p.jsx(Pr,{color:_.gatewayColor}),label:"Gateway",tooltip:"Significant forwarder (7-10% traffic)."}),H>0&&p.jsx(A0,{indicator:p.jsx(Pr,{color:_.hubColor}),label:"Backbone",tooltip:"Critical relay with high centrality."}),x.mobileNodes.length>0&&p.jsx(A0,{indicator:p.jsx(Pr,{color:_.mobileColor,ring:!0}),label:"Mobile",tooltip:"Volatile node that appears/disappears."}),O>0&&p.jsx(A0,{indicator:p.jsx(za,{className:"w-3 h-3 shrink-0",style:{color:_.ghostColor},strokeWidth:2.5}),label:`Ghost (${O})`,tooltip:"Unknown repeater from Viterbi analysis."})]}),V&&p.jsxs(co,{title:"Link Quality",tooltip:"Neighbor edge colors based on bidirectional balance.",isOpen:J,onToggle:()=>eA(oA=>!oA),showDivider:!0,children:[p.jsx(A0,{indicator:p.jsx(uo,{color:On.YELLOW,pattern:"solid"}),label:"2-Way",tooltip:"33-67% balanced. Ideal bidirectional link."}),p.jsx(A0,{indicator:p.jsx(uo,{color:On.GREEN,pattern:"dashed"}),label:"Listener",tooltip:">67% listener. They hear us well."}),p.jsx(A0,{indicator:p.jsx(uo,{color:On.RED,pattern:"dotted"}),label:"Loud",tooltip:"<33% listener. They route more to us."})]}),c&&u>0&&p.jsxs(co,{title:"Topology",tooltip:"Links with 5+ validations. Thickness = strength.",isOpen:Z,onToggle:()=>uA(oA=>!oA),showDivider:!0,children:[p.jsx(Bi,{label:"Nodes",value:g+(y?1:0)}),x.hubNodes.length>0&&p.jsx(Bi,{label:"Hubs",value:x.hubNodes.length,color:gr.hubColor}),x.loops.length>0&&p.jsx(Di,{icon:p.jsx(Is,{className:"w-3 h-3"}),color:gr.edges.hoverLoop,title:`${x.loops.length} ${x.loops.length===1?"Loop":"Loops"}`,subtitle:"Redundant paths"}),Q.totalPaths>0&&p.jsx(Di,{icon:p.jsx(Ls,{className:"w-3 h-3"}),color:_.ghostColor,title:`${Q.totalPaths.toLocaleString()} Viterbi`,subtitle:"HMM decoded paths"})]})]})})}const _i={repeater:"blue",companion:"cyan",room_server:"pink",hubs:"indigo",direct:"green"},Dn={repeater:"Repeaters",companion:"Companions",room_server:"Rooms",hubs:"Hubs",direct:"Direct"},Ti={repeater:"Repeater nodes (mesh relays)",companion:"Companion devices (clients)",room_server:"Room server nodes",hubs:"Hub nodes and their connections",direct:"Zero-hop (direct RF) neighbors"},hc=["repeater","companion","room_server"],Ri=["hubs","direct"],Qr="!p-2.5 sm:!p-1.5 !rounded-md min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 shrink-0 flex items-center justify-center",_n="!p-2.5 sm:!p-1.5 !rounded-none min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 shrink-0 flex items-center justify-center",dc=()=>typeof window>"u"?!1:window.innerWidth<640;function mc({mapRef:c,showNeighborLines:u,onToggleNeighborLines:g,hasNeighborPolylines:y,nodeFilters:x,onToggleFilter:C,onToggleAll:T,filterCounts:P,showCoverage:_,onToggleCoverage:E,showMinCut:Q=!1,onToggleMinCut:O,hasMinCutData:H=!1,show3DTerrain:V,onToggle3DTerrain:K,basemapMode:aA,onToggleBasemap:J,isFullscreen:eA,onToggleFullscreen:Z,showLinkQuality:uA=!1,onToggleLinkQuality:oA,hasTraceLinks:vA=!1}){const[iA,fA]=R.useState(()=>!dc()),jA=()=>{var NA,GA;(GA=(NA=c.current)==null?void 0:NA.getMap())==null||GA.zoomIn()},DA=()=>{var NA,GA;(GA=(NA=c.current)==null?void 0:NA.getMap())==null||GA.zoomOut()},CA=()=>{var GA;const NA=(GA=c.current)==null?void 0:GA.getMap();NA&&NA.easeTo({bearing:0,pitch:0,duration:300})},yA="w-4 h-4",kA=aA==="light"?"#525252":"var(--fg-secondary)",LA=x.length>=un.length;return p.jsx(p.Fragment,{children:p.jsxs("div",{className:"absolute top-3 right-3 z-[600] flex flex-col gap-2 sm:top-4 sm:right-4 max-w-[calc(100vw-1.5rem)] sm:max-w-none pr-[env(safe-area-inset-right)]",children:[p.jsxs("div",{className:"map-control-surface flex flex-nowrap items-center gap-0.5 sm:gap-1 p-1 overflow-hidden",children:[y&&p.jsx(Ot,{plain:!0,color:u?"warning":"muted",onClick:g,title:u?"Hide edge lines":"Show edge lines","aria-label":u?"Hide edge lines":"Show edge lines","aria-pressed":u,className:Qr,"data-tint":u?"warning":void 0,children:p.jsx(la,{className:yA})}),p.jsx(Ot,{plain:!0,color:"muted",onClick:()=>fA(NA=>!NA),title:iA?"Hide node filters":"Show node filters","aria-label":iA?"Collapse node filters":"Expand node filters","aria-expanded":iA,className:Qr,children:p.jsx(tu,{className:yA})}),p.jsx(R0,{initial:!1,children:iA&&p.jsxs(u0.div,{className:"flex items-center gap-0.5 flex-nowrap overflow-x-auto scrollbar-none max-w-[50vw] sm:max-w-none sm:overflow-visible",role:"group","aria-label":"Node type filters",initial:{width:0,opacity:0},animate:{width:"auto",opacity:1},exit:{width:0,opacity:0},transition:{duration:.2,ease:[.4,0,.2,1]},children:[p.jsx(so,{color:LA?"green":"zinc",customColor:LA?void 0:kA,onClick:T,title:"Show all nodes","aria-pressed":LA,"aria-label":"Show all node types",className:"shrink-0",children:"All"}),hc.map(NA=>{const GA=P[NA];if(GA===0)return null;const bA=!LA&&x.includes(NA);return p.jsx(so,{color:bA?_i[NA]:"zinc",customColor:bA?void 0:kA,onClick:()=>C(NA),title:Ti[NA],"aria-pressed":bA,"aria-label":`${Dn[NA]} (${GA})`,className:"shrink-0",children:Dn[NA]},NA)}),Ri.some(NA=>P[NA]>0)&&p.jsx("span",{className:"mx-0.5 h-3 w-px bg-[var(--map-ui-border,var(--edge-subtle))] hidden sm:block shrink-0","aria-hidden":"true"}),Ri.map(NA=>{const GA=P[NA];if(GA===0)return null;const bA=!LA&&x.includes(NA);return p.jsx(so,{color:bA?_i[NA]:"zinc",customColor:bA?void 0:kA,onClick:()=>C(NA),title:Ti[NA],"aria-pressed":bA,"aria-label":`${Dn[NA]} (${GA})`,className:"shrink-0",children:Dn[NA]},NA)})]})}),H&&O&&p.jsx(Ot,{plain:!0,color:Q?"primary":"muted",onClick:O,title:Q?"Hide community partition":"Show community partition","aria-label":Q?"Hide community partition":"Show community partition","aria-pressed":Q,className:Qr,"data-tint":Q?"primary":void 0,children:p.jsx(bo,{className:yA})}),p.jsx(Ot,{plain:!0,color:aA==="light"?"primary":"muted",onClick:J,title:aA==="light"?"Switch to dark map":"Switch to light map","aria-label":aA==="light"?"Switch to dark map":"Switch to light map","aria-pressed":aA==="light",className:Qr,"data-tint":aA==="light"?"primary":void 0,children:aA==="light"?p.jsx(Po,{className:yA}):p.jsx(Qo,{className:yA})}),p.jsx(Ot,{plain:!0,color:V?"success":"muted",onClick:K,title:V?"Disable 3D terrain":"Enable 3D terrain","aria-label":V?"Disable 3D terrain":"Enable 3D terrain","aria-pressed":V,className:Qr,"data-tint":V?"success":void 0,children:p.jsx(bu,{className:yA})}),p.jsx(Ot,{plain:!0,color:"muted",onClick:Z,title:eA?"Exit fullscreen":"Fullscreen","aria-label":eA?"Exit fullscreen":"Enter fullscreen","aria-pressed":eA,className:Qr,children:eA?p.jsx(Ha,{className:yA}):p.jsx(Ga,{className:yA})})]}),p.jsxs("div",{className:"map-control-surface flex flex-col items-stretch !overflow-hidden self-end !p-0",children:[p.jsx(Ot,{plain:!0,color:"muted",onClick:jA,title:"Zoom in","aria-label":"Zoom in",className:_n,children:p.jsx(ru,{className:yA})}),p.jsx("div",{className:"h-px bg-border-subtle","aria-hidden":"true"}),p.jsx(Ot,{plain:!0,color:"muted",onClick:DA,title:"Zoom out","aria-label":"Zoom out",className:_n,children:p.jsx(xs,{className:yA})}),p.jsx("div",{className:"h-px bg-border-subtle","aria-hidden":"true"}),p.jsx(Ot,{plain:!0,color:"muted",onClick:CA,title:"Reset bearing to north","aria-label":"Reset bearing to north",className:_n,children:p.jsx(nu,{className:yA})})]}),vA&&oA&&p.jsx("div",{className:"map-control-surface flex flex-col items-stretch !overflow-hidden self-end !p-0",children:p.jsx(Ot,{plain:!0,color:uA?"success":"muted",onClick:oA,title:uA?"Hide link quality overlay":"Show link quality overlay","aria-label":uA?"Hide link quality overlay":"Show link quality overlay","aria-pressed":uA,className:_n,"data-tint":uA?"success":void 0,children:p.jsx(Ps,{className:yA})})})]})})}const gc="#4ADE80",pc="#16A34A",yc="rgba(10, 26, 10, 1)",xc="rgba(220, 252, 231, 1)",fo={text:yr.textSecondary,activeText:pc,activeBg:xc},wc={activeBg:yc},fr="DeepAnalysis",vc=700,ji="abcdefghijklmnopqrstuvwxyz0123456789";function kc(){return ji[Math.floor(Math.random()*ji.length)]}function bc({isActive:c,hasAnalyzed:u,isLoading:g,onClick:y,basemapMode:x="dark"}){const C=x==="light",T=C?fo.text:void 0,P=C?fo.activeText:gc,[_,E]=R.useState(!1),[Q,O]=R.useState(fr),H=R.useRef(!1),V=R.useRef(null),[K]=R.useState(()=>{var Z;return typeof window<"u"&&(((Z=window.matchMedia)==null?void 0:Z.call(window,"(hover: hover)").matches)??!1)}),aA=_&&!c&&!g&&K;R.useEffect(()=>{if(_&&!c&&!g&&!H.current){H.current=!0;const Z=performance.now(),uA=oA=>{const vA=oA-Z,iA=Math.min(vA/vc,1),fA=Math.floor(iA*fr.length);let jA="";for(let DA=0;DA{V.current&&cancelAnimationFrame(V.current)}},[_,c,g]);const J=g?"Analyzing...":Q,eA=g?"Analyzing packet history":u?c?"Hide topology edges":"Show topology edges":"Load full packet history and build topology";return p.jsxs("button",{onClick:y,onMouseEnter:()=>K&&E(!0),onMouseLeave:()=>K&&E(!1),onPointerEnter:()=>K&&E(!0),onPointerLeave:()=>K&&E(!1),disabled:g,className:`map-tool-btn flex items-center gap-2 w-full text-left radius-inner transition-base ${g?"cursor-wait":""}`,style:{padding:"0.5rem 0.625rem",...c&&{backgroundColor:C?fo.activeBg:wc.activeBg}},title:eA,"aria-label":eA,"aria-pressed":c,children:[g?p.jsx(Oo,{className:"w-3.5 h-3.5 shrink-0 animate-spin",style:{color:P}}):p.jsx(Ua,{className:`w-3.5 h-3.5 shrink-0 transition-colors ${c?"":"text-fg-secondary"}`,style:{...c&&{color:P},...aA&&{color:P},...!c&&!aA&&T&&{color:T}}}),p.jsx("span",{className:`${c?"":"text-fg-secondary"}`,"aria-hidden":"true",style:{fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:"0.6875rem",fontWeight:c||aA?700:500,letterSpacing:"-0.01em",lineHeight:1,...c&&{color:P},...aA&&{color:P},...!c&&!aA&&T&&{color:T}},children:J})]})}const Cc=e0.teal,Ec="#0D7377",Sc="rgba(10, 36, 32, 1)",Mc="rgba(204, 251, 241, 1)",ho={text:yr.textSecondary,activeTeal:Ec,activeBg:Mc},Bc={activeBg:Sc},Ii="LiveTrace",Dc=400,Li=100;function _c({isActive:c,onClick:u,basemapMode:g="dark"}){const y=g==="light",x=y?ho.text:void 0,C=y?ho.activeTeal:Cc,[T,P]=R.useState(!1),[_,E]=R.useState(0),Q=R.useRef(!1),O=R.useRef(null),[H,V]=R.useState(0),K=R.useRef(!1),[aA]=R.useState(()=>{var uA;return typeof window<"u"&&(((uA=window.matchMedia)==null?void 0:uA.call(window,"(hover: hover)").matches)??!1)}),J=T&&!c&&aA;R.useEffect(()=>{J&&!K.current&&(K.current=!0,V(1),setTimeout(()=>V(2),Li),setTimeout(()=>V(3),Li*2)),T||(K.current=!1,V(0))},[J,T]),R.useEffect(()=>{if(T&&!c&&!Q.current){Q.current=!0;const uA=performance.now(),oA=vA=>{const iA=vA-uA,fA=Math.min(iA/Dc,1);E(fA),fA<1&&(O.current=requestAnimationFrame(oA))};O.current=requestAnimationFrame(oA)}return T||(O.current&&(cancelAnimationFrame(O.current),O.current=null),Q.current=!1,E(0)),()=>{O.current&&cancelAnimationFrame(O.current)}},[T,c]);const eA=uA=>{if(c)return C;if(!J)return x;const oA=Ii.length,vA=_*(oA+2);return uA>=vA-2&&uAaA&&P(!0),onMouseLeave:()=>aA&&P(!1),onPointerEnter:()=>aA&&P(!0),onPointerLeave:()=>aA&&P(!1),className:"map-tool-btn flex items-center gap-2 w-full text-left radius-inner transition-base",style:{padding:"0.5rem 0.625rem",...c&&{backgroundColor:y?ho.activeBg:Bc.activeBg}},title:c?"Disable live packet tracing (reduces CPU usage)":"Enable live packet tracing","aria-label":Z,"aria-pressed":c,children:[p.jsx(Xa,{className:`w-3.5 h-3.5 shrink-0 ${c?"":"text-fg-secondary"}`,fill:H===1?"#FFFFFF":H===3?C:"none",stroke:H===1||H===2?"#FFFFFF":c||J?C:x||"currentColor",style:{transition:"fill 0.05s, stroke 0.05s"}}),p.jsx("span",{className:`${c?"":"text-fg-secondary"}`,"aria-hidden":"true",style:{fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:"0.6875rem",fontWeight:c||J?700:500,letterSpacing:"-0.01em",lineHeight:1},children:Ii.split("").map((uA,oA)=>p.jsx("span",{style:{color:eA(oA)||void 0},children:uA},oA))})]})}const Ni=.2,Tc="rgba(26, 20, 8, 1)",Rc="rgba(254, 243, 199, 1)",Tn={text:yr.textSecondary,activeBg:Rc,disabledText:yr.disabledText},jc={activeBg:Tc},mo=.01,go=1,Fi="#fe8019",Ic="'Wardrive', serif",Mo=1.45,Lc=Mo*1.1,Nc=80;function Fc({isActive:c,onClick:u,brightness:g=.7,onBrightnessChange:y,basemapMode:x="dark"}){const C=x==="light",T=C?Tn.text:void 0,[P,_]=R.useState(!1),[E,Q]=R.useState(!1),[O]=R.useState(()=>{var uA;return typeof window<"u"&&(((uA=window.matchMedia)==null?void 0:uA.call(window,"(hover: hover)").matches)??!1)});R.useEffect(()=>{if(!P||c)return;const uA=requestAnimationFrame(()=>Q(!0)),oA=setTimeout(()=>Q(!1),Nc);return()=>{cancelAnimationFrame(uA),clearTimeout(oA)}},[P,c]);const H=Math.max(mo,Math.min(go,g)),V=uA=>{uA.stopPropagation();const oA=Math.min(go,H+Ni);y==null||y(oA)},K=uA=>{uA.stopPropagation();const oA=Math.max(mo,H-Ni);y==null||y(oA)},aA=Hmo+.001,eA=P&&!c&&O,Z=c?"Configure wardriving coverage":"Show wardriving coverage";return p.jsxs("button",{onClick:u,onMouseEnter:()=>O&&_(!0),onMouseLeave:()=>O&&_(!1),onPointerEnter:()=>O&&_(!0),onPointerLeave:()=>O&&_(!1),className:"map-tool-btn flex items-center gap-2 w-full text-left radius-inner transition-base",style:{padding:"0.5rem 0.625rem",...c&&{backgroundColor:C?Tn.activeBg:jc.activeBg}},title:Z,"aria-label":Z,"aria-pressed":c,children:[p.jsx(Bu,{className:`w-3.5 h-3.5 shrink-0 transition-colors ${c?"text-sys-amber":"text-fg-secondary"}`,style:eA?{color:Fi}:!c&&T?{color:T}:void 0}),p.jsx("span",{className:`${c?"text-sys-amber":"text-fg-secondary"}`,"aria-hidden":"true",style:{fontFamily:c||eA?Ic:"ui-monospace, SFMono-Regular, monospace",fontSize:c||eA?"0.75rem":"0.6875rem",fontWeight:500,letterSpacing:"-0.01em",lineHeight:1,transition:"none",transform:c?`scale(${Mo})`:eA?`scale(${E?Lc:Mo})`:void 0,transformOrigin:"left center",...eA?{color:Fi}:!c&&T?{color:T}:{}},children:"Wardrive"}),c&&y&&p.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[p.jsx("button",{onClick:K,disabled:!J,className:`p-1 sm:p-0.5 min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 flex items-center justify-center rounded transition-colors ${J?"text-sys-amber hover:bg-[var(--map-ui-hover,var(--elevated))] active:bg-[var(--map-ui-active,var(--subtle))]":"cursor-not-allowed"}`,style:J?void 0:{color:C?Tn.disabledText:"rgba(251, 191, 36, 0.3)"},title:`Decrease opacity (${Math.round(H*100)}%)`,"aria-label":`Decrease opacity, currently ${Math.round(H*100)}%`,children:p.jsx(Po,{className:"w-3.5 h-3.5"})}),p.jsx("button",{onClick:V,disabled:!aA,className:`p-1 sm:p-0.5 min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 flex items-center justify-center rounded transition-colors ${aA?"text-sys-amber hover:bg-[var(--map-ui-hover,var(--elevated))] active:bg-[var(--map-ui-active,var(--subtle))]":"cursor-not-allowed"}`,style:aA?void 0:{color:C?Tn.disabledText:"rgba(251, 191, 36, 0.3)"},title:`Increase opacity (${Math.round(H*100)}%)`,"aria-label":`Increase opacity, currently ${Math.round(H*100)}%`,children:p.jsx(Qo,{className:"w-3.5 h-3.5"})})]})]})}const Pc="0123456789bcdefghjkmnpqrstuvwxyz";function Qc(c){let u=!0,g=-90,y=90,x=-180,C=180;for(const T of c.toLowerCase()){const P=Pc.indexOf(T);if(P!==-1)for(let _=4;_>=0;_--){const E=P>>_&1;if(u){const Q=(x+C)/2;E?x=Q:C=Q}else{const Q=(g+y)/2;E?g=Q:y=Q}u=!u}}return{lat:(g+y)/2,lon:(x+C)/2}}function Oc(c){return Math.exp(-c*Math.LN2/7)}const Bo="pymc-wardriving-url",Gs="pymc-wardriving-enabled",Us="pymc-wardriving-brightness",Pi=.7;function zc(){return typeof localStorage>"u"?"":localStorage.getItem(Bo)||""}function Qi(c){typeof localStorage>"u"||(c?localStorage.setItem(Bo,c):localStorage.removeItem(Bo))}function Hc(){return typeof localStorage>"u"?!1:localStorage.getItem(Gs)==="true"}function Rn(c){typeof localStorage>"u"||localStorage.setItem(Gs,String(c))}function Gc(){if(typeof localStorage>"u")return Pi;const c=localStorage.getItem(Us);if(c){const u=parseFloat(c);if(!isNaN(u)&&u>=.01&&u<=1)return u}return Pi}function Uc(c){if(typeof localStorage>"u")return;const u=Math.max(.01,Math.min(1,c));localStorage.setItem(Us,String(u))}const Vc=8e3;async function Wc(c,u={},g=Vc){const y=new AbortController,x=setTimeout(()=>y.abort(),g);try{return await fetch(c,{...u,signal:y.signal})}catch(C){throw C instanceof Error&&C.name==="AbortError"?new Error(`Connection timed out after ${g/1e3}s`):C}finally{clearTimeout(x)}}async function Yc(c){const g=`${c.replace(/\/+$/,"").replace(/\/get-nodes$/,"").replace(/\/get-samples$/,"")}/get-samples`,y=await Wc(g,{headers:{Accept:"application/json"}});if(!y.ok)throw new Error(`Failed to fetch precise samples: ${y.status}`);return y.json()}function Kc(c,u=null){if(c!==null){const y=(Math.max(-12,Math.min(12,c))+12)/24;if(u!==null){const C=(Math.max(-120,Math.min(-50,u))+120)/70;return y*.8+C*.2}return y}return u!==null?(Math.max(-120,Math.min(-50,u))+120)/70:.5}function Zc(c){var g;const u=[];for(const y of c.keys){if(!y.observed)continue;const{lat:x,lon:C}=Qc(y.hash),T=parseInt(y.time,10),P=isNaN(T)?30:(Date.now()-T)/(1e3*60*60*24),_=Oc(P),Q=Kc(y.snr,y.rssi)*(.3+_*.7);u.push({lat:x,lon:C,successRate:y.observed?1:0,weight:Q,totalSamples:1,ageDays:P,geohash:y.hash,repeaters:((g=y.path)==null?void 0:g.map(O=>O.toLowerCase()))||[]})}return u}const cn=ws((c,u)=>({status:"idle",isVisible:Hc(),coveragePoints:[],repeaters:[],error:null,stats:{coverageCount:0,repeaterCount:0,lastUpdated:null},url:zc(),brightness:Gc(),isModalOpen:!1,openModal:()=>c({isModalOpen:!0}),closeModal:()=>c({isModalOpen:!1}),setUrl:g=>c({url:g}),setBrightness:g=>{const y=Math.max(.01,Math.min(1,g));Uc(y),c({brightness:y})},toggleVisibility:()=>{const g=!u().isVisible;Rn(g),c({isVisible:g})},setVisible:g=>{Rn(g),c({isVisible:g})},loadCoverage:async g=>{if(!g.trim())return c({error:"Please enter a URL",status:"error"}),!1;try{new URL(g.trim())}catch{return c({error:"Invalid URL format",status:"error"}),!1}c({error:null,status:"connecting"});try{c({status:"loading"});const y=await Yc(g.trim());if(!y||typeof y!="object")throw new Error("Invalid response from server");if(!Array.isArray(y.keys))throw new Error("No sample data found in response");c({status:"processing"});const x=Zc(y);if(x.length===0)throw new Error("No valid coverage points found");return c({coveragePoints:x,repeaters:[],stats:{coverageCount:x.length,repeaterCount:0,lastUpdated:new Date},status:"success",isVisible:!0,url:g.trim()}),Qi(g.trim()),Rn(!0),!0}catch(y){const x=y instanceof Error?y.message:"Failed to load coverage data";let C=x;return x.includes("timed out")?C="Connection timed out. Server may be unreachable or slow.":x.includes("Failed to fetch")||x.includes("NetworkError")?C="Could not connect to server. Check the URL and try again.":x.includes("CORS")?C="Server does not allow cross-origin requests.":x.includes("404")?C="Coverage endpoint not found. Check the URL.":(x.includes("ERR_NAME_NOT_RESOLVED")||x.includes("DNS"))&&(C="Server not found. Check the URL for typos."),c({error:C,status:"error"}),!1}},clearCoverage:()=>{c({coveragePoints:[],repeaters:[],stats:{coverageCount:0,repeaterCount:0,lastUpdated:null},status:"idle",error:null,isVisible:!1,url:""}),Qi(""),Rn(!1)}})),$c={bg:"#F8F8F8",bgSubtle:"#F0F0F0",bgElevated:"#FFFFFF",bgInput:"#FFFFFF",border:"rgba(0, 0, 0, 0.12)",borderStrong:"rgba(0, 0, 0, 0.20)",borderFocus:"#3B82F6",text:"#1A1A1A",textSecondary:"#4A4A4A",textMuted:"#737373",success:"#059669",successBg:"#ECFDF5",successBorder:"#A7F3D0",error:"#DC2626",errorBg:"#FEF2F2",errorBorder:"#FECACA",info:"#2563EB",infoBg:"#EFF6FF",infoBorder:"#BFDBFE",warning:"#D97706",warningBg:"#FFFBEB",warningBorder:"#FDE68A",primary:"#F59E0B",hoverBg:"rgba(0, 0, 0, 0.04)",sliderTrack:"#E5E7EB",sliderThumb:"#F59E0B"},Vs={bg:"var(--surface)",bgSubtle:"var(--subtle)",bgElevated:"var(--elevated)",bgInput:"var(--subtle)",border:"var(--edge-subtle)",borderStrong:"var(--edge-strong)",borderFocus:"var(--sys-blue)",text:"var(--fg-primary)",textSecondary:"var(--fg-secondary)",textMuted:"var(--fg-muted)",success:"var(--sys-green)",successBg:"rgba(74, 222, 128, 0.1)",successBorder:"rgba(74, 222, 128, 0.3)",error:"var(--sys-red)",errorBg:"rgba(239, 68, 68, 0.1)",errorBorder:"rgba(239, 68, 68, 0.3)",info:"var(--sys-indigo)",infoBg:"rgba(249, 210, 111, 0.1)",infoBorder:"rgba(249, 210, 111, 0.3)",warning:"var(--sys-indigo)",warningBg:"rgba(249, 210, 111, 0.1)",warningBorder:"rgba(249, 210, 111, 0.3)",primary:"var(--sys-indigo)",hoverBg:"var(--hover-tint)",sliderTrack:"var(--elevated)",sliderThumb:"var(--sys-indigo)"},Ws=R.createContext({theme:Vs,isLight:!1});function xr(){return R.useContext(Ws)}function qc({status:c,hasData:u}){const{theme:g,isLight:y}=xr(),x=R.useMemo(()=>c==="connecting"||c==="loading"||c==="processing"?{icon:p.jsx(Oo,{className:"w-3.5 h-3.5 animate-spin"}),label:c==="connecting"?"Connecting...":c==="loading"?"Loading...":"Processing...",color:g.warning,bg:g.warningBg}:c==="error"?{icon:p.jsx(_u,{className:"w-3.5 h-3.5"}),label:"Disconnected",color:g.error,bg:g.errorBg}:u?{icon:p.jsx(su,{className:"w-3.5 h-3.5"}),label:"Connected",color:g.success,bg:g.successBg}:{icon:p.jsx(vs,{className:"w-3.5 h-3.5"}),label:"Ready",color:g.textMuted,bg:y?"rgba(0,0,0,0.04)":"rgba(255,255,255,0.04)"},[c,u,g,y]);return p.jsxs(u0.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},className:"flex items-center gap-1.5 px-2 py-1 rounded-full text-xs font-medium",style:{backgroundColor:x.bg,color:x.color},children:[x.icon,p.jsx("span",{children:x.label})]},x.label)}function Jc({status:c}){const{theme:u}=xr(),g=R.useMemo(()=>{switch(c){case"connecting":return 25;case"loading":return 60;case"processing":return 90;default:return 0}},[c]);return g===0?null:p.jsx(u0.div,{initial:{opacity:0,scaleY:0},animate:{opacity:1,scaleY:1},exit:{opacity:0,scaleY:0},className:"h-1 rounded-full overflow-hidden origin-top",style:{backgroundColor:u.sliderTrack},children:p.jsx(u0.div,{className:"h-full rounded-full",style:{backgroundColor:u.primary},initial:{width:0},animate:{width:`${g}%`},transition:{duration:.4,ease:"easeOut"}})})}function Oi({variant:c,title:u,description:g,onDismiss:y}){const{theme:x}=xr(),C=R.useMemo(()=>{switch(c){case"success":return{icon:p.jsx(zo,{className:"w-4 h-4"}),color:x.success,bg:x.successBg,border:x.successBorder};case"error":return{icon:p.jsx(xu,{className:"w-4 h-4"}),color:x.error,bg:x.errorBg,border:x.errorBorder};case"info":return{icon:p.jsx(vu,{className:"w-4 h-4"}),color:x.info,bg:x.infoBg,border:x.infoBorder}}},[c,x]);return p.jsxs(u0.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:Ur.snappy,className:"flex items-start gap-3 p-3 rounded-lg border",style:{backgroundColor:C.bg,borderColor:C.border,color:C.color},children:[p.jsx("div",{className:"shrink-0 mt-0.5",children:C.icon}),p.jsxs("div",{className:"flex-1 min-w-0",children:[p.jsx("p",{className:"text-sm font-medium",children:u}),g&&p.jsx("p",{className:"text-xs mt-0.5 opacity-80",children:g})]}),y&&p.jsx("button",{onClick:y,className:"shrink-0 p-1 rounded hover:bg-black/10 transition-colors","aria-label":"Dismiss",children:p.jsx(dn,{className:"w-3.5 h-3.5"})})]})}function Xc({value:c,onChange:u,onSubmit:g,disabled:y}){const{theme:x,isLight:C}=xr(),[T,P]=R.useState(!1),_=E=>{E.key==="Enter"&&!E.shiftKey&&!y&&(E.preventDefault(),g())};return p.jsxs("div",{className:"space-y-1.5",children:[p.jsx("label",{className:"block text-sm font-medium",style:{color:x.textSecondary},children:"Coverage Server URL"}),p.jsxs("div",{className:"relative",children:[p.jsx("input",{type:"url",value:c,onChange:E=>u(E.target.value),onKeyDown:_,onFocus:()=>P(!0),onBlur:()=>P(!1),placeholder:"https://coverage.wcmesh.com",disabled:y,className:I0("w-full pl-3 pr-10 py-2.5 rounded-lg border text-sm transition-all duration-150","focus:outline-none",y&&"opacity-50 cursor-not-allowed"),style:{backgroundColor:x.bgInput,borderColor:T?x.borderFocus:x.border,color:x.text,boxShadow:T?`0 0 0 3px ${C?"rgba(59, 130, 246, 0.15)":"rgba(139, 92, 246, 0.15)"}`:"none"}}),c&&!y&&p.jsx("button",{onClick:()=>u(""),className:"absolute right-2.5 top-1/2 -translate-y-1/2 p-1 rounded transition-colors",style:{color:x.textMuted},onMouseEnter:E=>E.currentTarget.style.color=x.text,onMouseLeave:E=>E.currentTarget.style.color=x.textMuted,"aria-label":"Clear URL",children:p.jsx(dn,{className:"w-4 h-4"})})]}),p.jsx("p",{className:"text-xs",style:{color:x.textMuted},children:"Press Enter to connect, or use the Connect button below"})]})}function Af({value:c,onChange:u}){const{theme:g,isLight:y}=xr(),x=Math.round(c*100);return p.jsx(u0.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:Ur.gentle,className:"overflow-hidden",children:p.jsx("div",{className:"p-3 rounded-lg border",style:{backgroundColor:g.bgSubtle,borderColor:g.border},children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("div",{className:"relative w-4 h-4",children:[p.jsx(Po,{className:"w-4 h-4 absolute inset-0 transition-opacity",style:{color:g.textMuted,opacity:c<.5?1:0}}),p.jsx(Qo,{className:"w-4 h-4 absolute inset-0 transition-opacity",style:{color:g.primary,opacity:c>=.5?1:0}})]}),p.jsxs("div",{className:"flex-1",children:[p.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[p.jsx("span",{className:"text-xs font-medium",style:{color:g.textSecondary},children:"Layer Opacity"}),p.jsxs("span",{className:"text-xs font-mono tabular-nums px-1.5 py-0.5 rounded",style:{color:g.text,backgroundColor:y?"rgba(0,0,0,0.06)":"rgba(255,255,255,0.06)"},children:[x,"%"]})]}),p.jsx("input",{type:"range",min:5,max:100,value:x,onChange:C=>u(Number(C.target.value)/100),className:I0("w-full h-2 rounded-full appearance-none cursor-pointer","[&::-webkit-slider-thumb]:appearance-none","[&::-webkit-slider-thumb]:w-4","[&::-webkit-slider-thumb]:h-4","[&::-webkit-slider-thumb]:rounded-full","[&::-webkit-slider-thumb]:cursor-pointer","[&::-webkit-slider-thumb]:transition-transform","[&::-webkit-slider-thumb]:hover:scale-110","[&::-webkit-slider-thumb]:shadow-lg","[&::-moz-range-thumb]:appearance-none","[&::-moz-range-thumb]:w-4","[&::-moz-range-thumb]:h-4","[&::-moz-range-thumb]:rounded-full","[&::-moz-range-thumb]:border-0","[&::-moz-range-thumb]:cursor-pointer"),style:{background:`linear-gradient(to right, ${g.primary} ${x}%, ${g.sliderTrack} ${x}%)`,"--thumb-color":g.sliderThumb}}),p.jsx("style",{children:` input[type="range"]::-webkit-slider-thumb { background-color: ${g.sliderThumb}; } input[type="range"]::-moz-range-thumb { background-color: ${g.sliderThumb}; } - `})]})]})})})}function ef({coverageCount:c,repeaterCount:u,lastUpdated:g}){const{theme:y}=xr();return p.jsxs("div",{className:"grid grid-cols-3 gap-2 p-3 rounded-lg border",style:{backgroundColor:y.bgSubtle,borderColor:y.border},children:[p.jsxs("div",{className:"text-center",children:[p.jsx(vi,{value:c,format:{useGrouping:!0,maximumFractionDigits:0},className:"text-lg font-semibold tabular-nums block",style:{color:y.text}}),p.jsx("div",{className:"text-xs mt-0.5",style:{color:y.textMuted},children:"Points"})]}),p.jsxs("div",{className:"text-center border-x",style:{borderColor:y.border},children:[p.jsx(vi,{value:u,format:{useGrouping:!0,maximumFractionDigits:0},className:"text-lg font-semibold tabular-nums block",style:{color:y.text}}),p.jsx("div",{className:"text-xs mt-0.5",style:{color:y.textMuted},children:"Repeaters"})]}),p.jsxs("div",{className:"text-center",children:[p.jsxs("div",{className:"flex items-center justify-center gap-1",children:[p.jsx(Ns,{className:"w-3.5 h-3.5",style:{color:y.textMuted}}),p.jsx("span",{className:"text-lg font-semibold tabular-nums",style:{color:y.text},children:g?g.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"—"})]}),p.jsx("div",{className:"text-xs mt-0.5",style:{color:y.textMuted},children:"Updated"})]})]})}function zi({icon:c,label:u,onClick:g,disabled:y,variant:x="default",active:C}){const{theme:T,isLight:P}=xr(),_=R.useMemo(()=>x==="danger"?{text:T.error,hoverBg:P?"rgba(220, 38, 38, 0.08)":"rgba(239, 68, 68, 0.15)"}:{text:C?T.primary:T.textSecondary,hoverBg:T.hoverBg},[x,C,T,P]);return p.jsxs("button",{onClick:g,disabled:y,className:I0("flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-sm font-medium transition-colors",y&&"opacity-50 cursor-not-allowed"),style:{color:_.text},onMouseEnter:E=>!y&&(E.currentTarget.style.backgroundColor=_.hoverBg),onMouseLeave:E=>E.currentTarget.style.backgroundColor="transparent",children:[c,p.jsx("span",{children:u})]})}function tf(){const c=Ds(),u=c==="light",g=u?$c:Vs,{isModalOpen:y,closeModal:x,status:C,isVisible:T,stats:P,error:_,url:E,brightness:Q,loadCoverage:O,clearCoverage:H,toggleVisibility:V,setUrl:K,setBrightness:aA}=cn(),J=C==="connecting"||C==="loading"||C==="processing",eA=P.coverageCount>0,[Z,uA]=R.useState(!0),[oA,vA]=R.useState(E);R.useEffect(()=>{vA(E)},[E]),R.useEffect(()=>{C==="error"&&uA(!0)},[C]);const iA=R.useCallback(async()=>{await O(oA)},[oA,O]),fA=R.useCallback(()=>{vA(""),H()},[H]),jA=R.useCallback(yA=>{vA(yA),K(yA)},[K]),DA=R.useCallback(()=>{J||x()},[J,x]),CA=oA.trim().length>0&&!J;return p.jsx(Ws.Provider,{value:{theme:g,isLight:u},children:p.jsxs(aa,{open:y,onClose:DA,size:"md",bottomSheet:!0,basemapMode:c,children:[p.jsxs("div",{className:"flex items-center justify-between p-4 border-b",style:{borderColor:g.border},children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:"p-2 rounded-lg",style:{backgroundColor:g.bgSubtle,color:g.primary},children:p.jsx(vs,{className:"w-5 h-5"})}),p.jsxs("div",{children:[p.jsx("h2",{className:"type-micro",style:{color:g.text},children:"Wardriving Coverage"}),p.jsx("p",{className:"text-xs",style:{color:g.textMuted},children:"RF coverage heatmap overlay"})]})]}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(qc,{status:C,hasData:eA}),!J&&p.jsxs(p.Fragment,{children:[p.jsx("button",{onClick:DA,className:"sm:hidden min-h-[44px] min-w-[44px] px-3 flex items-center justify-center text-[15px] font-medium transition-base radius-inner active:bg-subtle-fill",style:{color:g.primary},children:"Done"}),p.jsx("button",{onClick:DA,className:"hidden sm:flex items-center justify-center p-2 rounded-lg transition-colors",style:{color:g.textMuted},onMouseEnter:yA=>{yA.currentTarget.style.color=g.text,yA.currentTarget.style.backgroundColor=g.hoverBg},onMouseLeave:yA=>{yA.currentTarget.style.color=g.textMuted,yA.currentTarget.style.backgroundColor="transparent"},"aria-label":"Close",children:p.jsx(dn,{className:"w-5 h-5"})})]})]})]}),p.jsx(R0,{children:J&&p.jsx(Jc,{status:C})}),p.jsxs(ua,{className:"space-y-4",children:[p.jsx(Xc,{value:oA,onChange:jA,onSubmit:iA,disabled:J}),p.jsx(R0,{children:C==="error"&&_&&Z&&p.jsx(Oi,{variant:"error",title:"Connection Failed",description:_,onDismiss:()=>uA(!1)})}),p.jsx(R0,{children:C==="success"&&eA&&p.jsx(Oi,{variant:"success",title:"Coverage Data Loaded",description:"Adjust opacity below, then close to view on map"})}),p.jsx(R0,{children:eA&&!J&&p.jsx(u0.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:8},transition:Ur.snappy,children:p.jsx(ef,{coverageCount:P.coverageCount,repeaterCount:P.repeaterCount,lastUpdated:P.lastUpdated})})}),p.jsx(R0,{children:eA&&!J&&p.jsx(Af,{value:Q,onChange:aA})})]}),p.jsxs("div",{className:"flex items-center justify-between p-4 border-t",style:{borderColor:g.border},children:[p.jsx("div",{className:"flex items-center gap-1",children:p.jsx(R0,{children:eA&&p.jsxs(u0.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},exit:{opacity:0,x:-10},transition:Ur.snappy,className:"flex items-center gap-1",children:[p.jsx(zi,{icon:T?p.jsx(Va,{className:"w-4 h-4"}):p.jsx(Is,{className:"w-4 h-4"}),label:T?"Hide":"Show",onClick:V,disabled:J,active:T}),p.jsx(zi,{icon:p.jsx(Go,{className:"w-4 h-4"}),label:"Clear",onClick:fA,disabled:J,variant:"danger"})]})})}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Ot,{plain:!0,color:"muted",onClick:DA,disabled:J,children:eA?"Done":"Cancel"}),p.jsx(Ot,{color:"warning",onClick:iA,disabled:!CA,children:J?p.jsxs(p.Fragment,{children:[p.jsx(Oo,{"data-slot":"icon",className:"animate-spin"}),C==="connecting"?"Connecting...":C==="loading"?"Loading...":"Processing..."]}):eA?p.jsxs(p.Fragment,{children:[p.jsx(js,{"data-slot":"icon"}),"Refresh"]}):p.jsxs(p.Fragment,{children:[p.jsx(iu,{"data-slot":"icon"}),"Connect"]})})]})]})]})})}const rf={bandwidth:.07,threshold:.1,opacity:1,strokeWidth:4.5},r0={...yr,trackBg:yr.border};function jn({label:c,value:u,min:g,max:y,step:x,unit:C,formatValue:T,onChange:P,isLightMode:_}){const E=T?T(u):u.toFixed(2);return p.jsxs("div",{className:"flex items-center gap-2 sm:gap-2",children:[p.jsx("span",{className:"text-xs font-medium w-14 sm:w-16 shrink-0",style:_?{color:r0.textSecondary}:{color:"var(--fg-secondary)"},children:c}),p.jsx("input",{type:"range",min:g,max:y,step:x,value:u,onChange:Q=>P(parseFloat(Q.target.value)),className:`flex-1 h-1.5 rounded-full appearance-none cursor-pointer + `})]})]})})})}function ef({coverageCount:c,repeaterCount:u,lastUpdated:g}){const{theme:y}=xr();return p.jsxs("div",{className:"grid grid-cols-3 gap-2 p-3 rounded-lg border",style:{backgroundColor:y.bgSubtle,borderColor:y.border},children:[p.jsxs("div",{className:"text-center",children:[p.jsx(vi,{value:c,format:{useGrouping:!0,maximumFractionDigits:0},className:"text-lg font-semibold tabular-nums block",style:{color:y.text}}),p.jsx("div",{className:"text-xs mt-0.5",style:{color:y.textMuted},children:"Points"})]}),p.jsxs("div",{className:"text-center border-x",style:{borderColor:y.border},children:[p.jsx(vi,{value:u,format:{useGrouping:!0,maximumFractionDigits:0},className:"text-lg font-semibold tabular-nums block",style:{color:y.text}}),p.jsx("div",{className:"text-xs mt-0.5",style:{color:y.textMuted},children:"Repeaters"})]}),p.jsxs("div",{className:"text-center",children:[p.jsxs("div",{className:"flex items-center justify-center gap-1",children:[p.jsx(Fs,{className:"w-3.5 h-3.5",style:{color:y.textMuted}}),p.jsx("span",{className:"text-lg font-semibold tabular-nums",style:{color:y.text},children:g?g.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"—"})]}),p.jsx("div",{className:"text-xs mt-0.5",style:{color:y.textMuted},children:"Updated"})]})]})}function zi({icon:c,label:u,onClick:g,disabled:y,variant:x="default",active:C}){const{theme:T,isLight:P}=xr(),_=R.useMemo(()=>x==="danger"?{text:T.error,hoverBg:P?"rgba(220, 38, 38, 0.08)":"rgba(239, 68, 68, 0.15)"}:{text:C?T.primary:T.textSecondary,hoverBg:T.hoverBg},[x,C,T,P]);return p.jsxs("button",{onClick:g,disabled:y,className:I0("flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-sm font-medium transition-colors",y&&"opacity-50 cursor-not-allowed"),style:{color:_.text},onMouseEnter:E=>!y&&(E.currentTarget.style.backgroundColor=_.hoverBg),onMouseLeave:E=>E.currentTarget.style.backgroundColor="transparent",children:[c,p.jsx("span",{children:u})]})}function tf(){const c=_s(),u=c==="light",g=u?$c:Vs,{isModalOpen:y,closeModal:x,status:C,isVisible:T,stats:P,error:_,url:E,brightness:Q,loadCoverage:O,clearCoverage:H,toggleVisibility:V,setUrl:K,setBrightness:aA}=cn(),J=C==="connecting"||C==="loading"||C==="processing",eA=P.coverageCount>0,[Z,uA]=R.useState(!0),[oA,vA]=R.useState(E);R.useEffect(()=>{vA(E)},[E]),R.useEffect(()=>{C==="error"&&uA(!0)},[C]);const iA=R.useCallback(async()=>{await O(oA)},[oA,O]),fA=R.useCallback(()=>{vA(""),H()},[H]),jA=R.useCallback(yA=>{vA(yA),K(yA)},[K]),DA=R.useCallback(()=>{J||x()},[J,x]),CA=oA.trim().length>0&&!J;return p.jsx(Ws.Provider,{value:{theme:g,isLight:u},children:p.jsxs(aa,{open:y,onClose:DA,size:"md",bottomSheet:!0,basemapMode:c,children:[p.jsxs("div",{className:"flex items-center justify-between p-4 border-b",style:{borderColor:g.border},children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:"p-2 rounded-lg",style:{backgroundColor:g.bgSubtle,color:g.primary},children:p.jsx(vs,{className:"w-5 h-5"})}),p.jsxs("div",{children:[p.jsx("h2",{className:"type-micro",style:{color:g.text},children:"Wardriving Coverage"}),p.jsx("p",{className:"text-xs",style:{color:g.textMuted},children:"RF coverage heatmap overlay"})]})]}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(qc,{status:C,hasData:eA}),!J&&p.jsxs(p.Fragment,{children:[p.jsx("button",{onClick:DA,className:"sm:hidden min-h-[44px] min-w-[44px] px-3 flex items-center justify-center text-[15px] font-medium transition-base radius-inner active:bg-subtle-fill",style:{color:g.primary},children:"Done"}),p.jsx("button",{onClick:DA,className:"hidden sm:flex items-center justify-center p-2 rounded-lg transition-colors",style:{color:g.textMuted},onMouseEnter:yA=>{yA.currentTarget.style.color=g.text,yA.currentTarget.style.backgroundColor=g.hoverBg},onMouseLeave:yA=>{yA.currentTarget.style.color=g.textMuted,yA.currentTarget.style.backgroundColor="transparent"},"aria-label":"Close",children:p.jsx(dn,{className:"w-5 h-5"})})]})]})]}),p.jsx(R0,{children:J&&p.jsx(Jc,{status:C})}),p.jsxs(ua,{className:"space-y-4",children:[p.jsx(Xc,{value:oA,onChange:jA,onSubmit:iA,disabled:J}),p.jsx(R0,{children:C==="error"&&_&&Z&&p.jsx(Oi,{variant:"error",title:"Connection Failed",description:_,onDismiss:()=>uA(!1)})}),p.jsx(R0,{children:C==="success"&&eA&&p.jsx(Oi,{variant:"success",title:"Coverage Data Loaded",description:"Adjust opacity below, then close to view on map"})}),p.jsx(R0,{children:eA&&!J&&p.jsx(u0.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:8},transition:Ur.snappy,children:p.jsx(ef,{coverageCount:P.coverageCount,repeaterCount:P.repeaterCount,lastUpdated:P.lastUpdated})})}),p.jsx(R0,{children:eA&&!J&&p.jsx(Af,{value:Q,onChange:aA})})]}),p.jsxs("div",{className:"flex items-center justify-between p-4 border-t",style:{borderColor:g.border},children:[p.jsx("div",{className:"flex items-center gap-1",children:p.jsx(R0,{children:eA&&p.jsxs(u0.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},exit:{opacity:0,x:-10},transition:Ur.snappy,className:"flex items-center gap-1",children:[p.jsx(zi,{icon:T?p.jsx(Va,{className:"w-4 h-4"}):p.jsx(Ls,{className:"w-4 h-4"}),label:T?"Hide":"Show",onClick:V,disabled:J,active:T}),p.jsx(zi,{icon:p.jsx(Go,{className:"w-4 h-4"}),label:"Clear",onClick:fA,disabled:J,variant:"danger"})]})})}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Ot,{plain:!0,color:"muted",onClick:DA,disabled:J,children:eA?"Done":"Cancel"}),p.jsx(Ot,{color:"warning",onClick:iA,disabled:!CA,children:J?p.jsxs(p.Fragment,{children:[p.jsx(Oo,{"data-slot":"icon",className:"animate-spin"}),C==="connecting"?"Connecting...":C==="loading"?"Loading...":"Processing..."]}):eA?p.jsxs(p.Fragment,{children:[p.jsx(Is,{"data-slot":"icon"}),"Refresh"]}):p.jsxs(p.Fragment,{children:[p.jsx(iu,{"data-slot":"icon"}),"Connect"]})})]})]})]})})}const rf={bandwidth:.07,threshold:.1,opacity:1,strokeWidth:4.5},r0={...yr,trackBg:yr.border};function jn({label:c,value:u,min:g,max:y,step:x,unit:C,formatValue:T,onChange:P,isLightMode:_}){const E=T?T(u):u.toFixed(2);return p.jsxs("div",{className:"flex items-center gap-2 sm:gap-2",children:[p.jsx("span",{className:"text-xs font-medium w-14 sm:w-16 shrink-0",style:_?{color:r0.textSecondary}:{color:"var(--fg-secondary)"},children:c}),p.jsx("input",{type:"range",min:g,max:y,step:x,value:u,onChange:Q=>P(parseFloat(Q.target.value)),className:`flex-1 h-1.5 rounded-full appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3.5 [&::-webkit-slider-thumb]:h-3.5 @@ -96,7 +96,7 @@ Compares older measurements to newer ones.`,Z=((LA=Q.forward)==null?void 0:LA.un max-h-[45vh] /* sm+: taller allowance */ sm:max-h-[420px] - `,children:[p.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2 sm:py-2 min-h-[44px] sm:min-h-0 border-b border-edge-subtle",children:[p.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[p.jsx(Ps,{className:"w-4 h-4 sm:w-3.5 sm:h-3.5 text-sys-green shrink-0"}),p.jsx(Or,{prefix:c.nodeA.prefix,name:H}),p.jsx("span",{className:"type-data-xs text-fg-muted",children:"↔"}),p.jsx(Or,{prefix:c.nodeB.prefix,name:V})]}),p.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[aA>0&&p.jsx("span",{className:"type-data-xs text-fg-muted",title:pi(aA),children:bs(aA)}),p.jsx(Ot,{plain:!0,color:"muted",onClick:u,className:"!p-1.5 sm:!p-0.5 !rounded-md min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 flex items-center justify-center",children:p.jsx(dn,{className:"w-4 h-4 sm:w-3.5 sm:h-3.5"})})]})]}),p.jsxs("div",{className:"px-3 py-2.5 border-b border-edge-subtle",children:[p.jsxs("div",{className:"space-y-1.5 mb-2",children:[p.jsxs("div",{className:"flex items-center justify-between cursor-help",title:`${c.nodeA.prefix}→${c.nodeB.prefix}: mean of ${((GA=c.aToB)==null?void 0:GA.count)??0} measurements`,children:[p.jsxs("span",{className:"flex items-center gap-1",children:[p.jsx(Or,{prefix:c.nodeA.prefix,name:H}),p.jsx("span",{className:"type-data-xs text-fg-muted",children:"→"}),p.jsx(Or,{prefix:c.nodeB.prefix,name:V})]}),c.aToB?p.jsxs("span",{className:`type-data-sm tabular-nums font-semibold ${fn(c.aToB.mean,E)}`,children:[c.aToB.mean.toFixed(1),p.jsx("span",{className:"text-fg-muted font-normal ml-0.5",children:"dB"})]}):p.jsx("span",{className:"type-data-sm text-fg-muted",children:"—"})]}),p.jsxs("div",{className:"flex items-center justify-between cursor-help",title:`${c.nodeB.prefix}→${c.nodeA.prefix}: mean of ${((bA=c.bToA)==null?void 0:bA.count)??0} measurements`,children:[p.jsxs("span",{className:"flex items-center gap-1",children:[p.jsx(Or,{prefix:c.nodeB.prefix,name:V}),p.jsx("span",{className:"type-data-xs text-fg-muted",children:"→"}),p.jsx(Or,{prefix:c.nodeA.prefix,name:H})]}),c.bToA?p.jsxs("span",{className:`type-data-sm tabular-nums font-semibold ${fn(c.bToA.mean,E)}`,children:[c.bToA.mean.toFixed(1),p.jsx("span",{className:"text-fg-muted font-normal ml-0.5",children:"dB"})]}):p.jsx("span",{className:"type-data-sm text-fg-muted",children:"—"})]})]}),p.jsxs("div",{className:"grid grid-cols-2 gap-0 -mx-3 border-t border-edge-subtle",children:[p.jsx("div",{className:"px-3 pt-2 pb-1 border-r border-edge-subtle",children:p.jsx(Hi,{stats:c.aToB,direction:`${c.nodeA.prefix}→${c.nodeB.prefix}`,sf:E,noiseFloor:T})}),p.jsx("div",{className:"px-3 pt-2 pb-1",children:p.jsx(Hi,{stats:c.bToA,direction:`${c.nodeB.prefix}→${c.nodeA.prefix}`,sf:E,noiseFloor:T})})]})]}),p.jsxs("div",{className:"px-3 py-1.5 border-b border-edge-subtle",children:[K!=="insufficient"&&p.jsxs("div",{className:"flex items-center justify-between gap-2 py-[3px] cursor-help",title:eA,children:[p.jsx("span",{className:"type-data-xs text-fg-muted",children:"Trend"}),p.jsx("span",{className:"data-box data-box-compact",children:p.jsxs("span",{className:"flex items-center gap-1",children:[uf(K),p.jsx("span",{className:"text-fg-secondary capitalize",children:K})]})})]}),J>0&&p.jsx(zn,{label:"Unique traces",value:J.toString(),tooltip:oA})]}),O.length>0&&p.jsxs("div",{className:"px-3 py-2 flex-1 min-h-0 flex flex-col",children:[p.jsxs("p",{className:"type-micro text-fg-secondary mb-1 shrink-0",children:["Source packets (",O.length,")"]}),p.jsx("div",{className:"overflow-y-auto flex-1 min-h-0 overscroll-contain",style:{scrollbarGutter:"stable"},children:O.map((cA,sA)=>{const TA=Ys(cA),MA=TA?Ks(cA,TA):null,WA=MA?Math.max(0,MA.length-1):0,ae=MA?MA.map(UA=>(g==null?void 0:g.get(UA))??UA).join(" → "):null,JA=P===sA,ZA=cA.id??`${cA.packet_hash}-${cA.timestamp}`;return p.jsxs("div",{className:"rounded-sm",style:sA%2===1?cf:void 0,children:[p.jsxs("button",{onClick:()=>_(JA?null:sA),className:"flex items-center gap-1.5 py-[3px] px-1 w-full text-left text-[10px] font-mono text-fg-secondary hover:text-fg-primary transition-colors group",children:[JA?p.jsx(ys,{className:"w-2.5 h-2.5 text-fg-muted shrink-0"}):p.jsx(lu,{className:"w-2.5 h-2.5 text-fg-muted shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"}),p.jsx("span",{className:"text-fg-muted w-[52px] shrink-0",children:pi(cA.timestamp)}),ae?p.jsx("span",{className:"text-fg-secondary truncate min-w-0",title:MA.join(" → "),children:ae}):p.jsx("span",{className:"text-fg-muted truncate min-w-0 italic",children:"path n/a"}),p.jsxs("span",{className:"text-fg-muted shrink-0",children:[WA,"h"]}),cA.snr!=null&&p.jsx("span",{className:`shrink-0 tabular-nums ${fn(cA.snr,E)}`,children:cA.snr.toFixed(1)})]}),JA&&p.jsxs("div",{className:"mb-1 mt-0.5 mx-1 pl-2 border-l border-edge-subtle space-y-0.5 text-[10px]",children:[cA.rssi!=null&&p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:"text-fg-muted",children:"RSSI"}),p.jsxs("span",{className:"font-mono tabular-nums text-fg-secondary",children:[cA.rssi," dBm"]})]}),cA.snr!=null&&p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:"text-fg-muted",children:"SNR"}),p.jsxs("span",{className:`font-mono tabular-nums ${fn(cA.snr,E)}`,children:[cA.snr.toFixed(1)," dB"]})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:"text-fg-muted",children:"Route"}),p.jsx("span",{className:"font-mono text-fg-secondary",children:ma(cA.route??cA.route_type)})]}),cA.packet_hash&&p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:"text-fg-muted",children:"Hash"}),p.jsxs("button",{onClick:UA=>{UA.stopPropagation(),navigator.clipboard.writeText(cA.packet_hash)},className:"flex items-center gap-1 font-mono text-fg-secondary hover:text-fg-primary transition-colors",title:"Copy packet hash",children:[p.jsx("span",{className:"truncate max-w-[120px]",children:cA.packet_hash}),p.jsx(Ho,{className:"w-2.5 h-2.5 text-fg-muted shrink-0"})]})]}),cA.src_hash&&p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:"text-fg-muted",children:"Source"}),p.jsx("span",{className:"font-mono text-fg-secondary truncate max-w-[140px]",title:cA.src_hash,children:cA.src_hash})]}),MA&&MA.length>0&&p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:"text-fg-muted",children:"Path"}),p.jsx("span",{className:"font-mono text-fg-secondary truncate max-w-[140px]",title:MA.join(" → "),children:MA.join(" → ")})]})]})]},ZA)})})]})]})})}const hf={getItem:c=>{try{return localStorage.getItem(c)}catch{return null}},setItem:(c,u)=>{try{localStorage.setItem(c,u)}catch{}},removeItem:c=>{try{localStorage.removeItem(c)}catch{}}},Zs=ws()(Au(c=>({isEnabled:!1,toggle:()=>c(u=>({isEnabled:!u.isEnabled})),setEnabled:u=>c({isEnabled:u})}),{name:"pymc-live-trace",storage:eu(()=>hf)})),df=()=>Zs(c=>c.isEnabled),mf=()=>Zs(c=>c.toggle);var Rt=(function(c){c=c||{};var u=typeof c<"u"?c:{},g={},y;for(y in u)u.hasOwnProperty(y)&&(g[y]=u[y]);var x="";function C(rA){return u.locateFile?u.locateFile(rA,x):x+rA}var T;typeof document<"u"&&document.currentScript&&(x=document.currentScript.src),x.indexOf("blob:")!==0?x=x.substr(0,x.lastIndexOf("/")+1):x="",T=function(pA,IA,xA){var t=new XMLHttpRequest;t.open("GET",pA,!0),t.responseType="arraybuffer",t.onload=function(){if(t.status==200||t.status==0&&t.response){IA(t.response);return}var ge=c0(pA);if(ge){IA(ge.buffer);return}xA()},t.onerror=xA,t.send(null)};var P=u.print||console.log.bind(console),_=u.printErr||console.warn.bind(console);for(y in g)g.hasOwnProperty(y)&&(u[y]=g[y]);g=null,u.arguments&&u.arguments;var E=0,Q=function(rA){E=rA},O=function(){return E},H=8;function V(rA,pA,IA,xA){switch(IA=IA||"i8",IA.charAt(IA.length-1)==="*"&&(IA="i32"),IA){case"i1":kA[rA>>0]=pA;break;case"i8":kA[rA>>0]=pA;break;case"i16":NA[rA>>1]=pA;break;case"i32":GA[rA>>2]=pA;break;case"i64":st=[pA>>>0,(ze=pA,+Ce(ze)>=1?ze>0?(Ke(+pe(ze/4294967296),4294967295)|0)>>>0:~~+Se((ze-+(~~ze>>>0))/4294967296)>>>0:0)],GA[rA>>2]=st[0],GA[rA+4>>2]=st[1];break;case"float":bA[rA>>2]=pA;break;case"double":cA[rA>>3]=pA;break;default:dt("invalid type for setValue: "+IA)}}function K(rA,pA,IA){switch(pA=pA||"i8",pA.charAt(pA.length-1)==="*"&&(pA="i32"),pA){case"i1":return kA[rA>>0];case"i8":return kA[rA>>0];case"i16":return NA[rA>>1];case"i32":return GA[rA>>2];case"i64":return GA[rA>>2];case"float":return bA[rA>>2];case"double":return cA[rA>>3];default:dt("invalid type for getValue: "+pA)}return null}var aA=!1;function J(rA,pA){rA||dt("Assertion failed: "+pA)}function eA(rA){var pA=u["_"+rA];return J(pA,"Cannot call unknown function "+rA+", make sure it is exported"),pA}function Z(rA,pA,IA,xA,t){var b={string:function(ie){var et=0;if(ie!=null&&ie!==0){var Lt=(ie.length<<2)+1;et=at(Lt),jA(ie,et,Lt)}return et},array:function(ie){var et=at(ie.length);return DA(ie,et),et}};function ge(ie){return pA==="string"?iA(ie):pA==="boolean"?!!ie:ie}var De=eA(rA),He=[],$A=0;if(xA)for(var ye=0;ye=xA);)++t;if(t-pA>16&&rA.subarray&&oA)return oA.decode(rA.subarray(pA,t));for(var b="";pA>10,56320|$A&1023)}}return b}function iA(rA,pA){return rA?vA(LA,rA,pA):""}function fA(rA,pA,IA,xA){if(!(xA>0))return 0;for(var t=IA,b=IA+xA-1,ge=0;ge=55296&&De<=57343){var He=rA.charCodeAt(++ge);De=65536+((De&1023)<<10)|He&1023}if(De<=127){if(IA>=b)break;pA[IA++]=De}else if(De<=2047){if(IA+1>=b)break;pA[IA++]=192|De>>6,pA[IA++]=128|De&63}else if(De<=65535){if(IA+2>=b)break;pA[IA++]=224|De>>12,pA[IA++]=128|De>>6&63,pA[IA++]=128|De&63}else{if(IA+3>=b)break;pA[IA++]=240|De>>18,pA[IA++]=128|De>>12&63,pA[IA++]=128|De>>6&63,pA[IA++]=128|De&63}}return pA[IA]=0,IA-t}function jA(rA,pA,IA){return fA(rA,LA,pA,IA)}typeof TextDecoder<"u"&&new TextDecoder("utf-16le");function DA(rA,pA){kA.set(rA,pA)}function CA(rA,pA){return rA%pA>0&&(rA+=pA-rA%pA),rA}var yA,kA,LA,NA,GA,bA,cA;function sA(rA){yA=rA,u.HEAP8=kA=new Int8Array(rA),u.HEAP16=NA=new Int16Array(rA),u.HEAP32=GA=new Int32Array(rA),u.HEAPU8=LA=new Uint8Array(rA),u.HEAPU16=new Uint16Array(rA),u.HEAPU32=new Uint32Array(rA),u.HEAPF32=bA=new Float32Array(rA),u.HEAPF64=cA=new Float64Array(rA)}var TA=5271536,MA=28624,WA=u.TOTAL_MEMORY||33554432;u.buffer?yA=u.buffer:yA=new ArrayBuffer(WA),WA=yA.byteLength,sA(yA),GA[MA>>2]=TA;function ae(rA){for(;rA.length>0;){var pA=rA.shift();if(typeof pA=="function"){pA();continue}var IA=pA.func;typeof IA=="number"?pA.arg===void 0?u.dynCall_v(IA):u.dynCall_vi(IA,pA.arg):IA(pA.arg===void 0?null:pA.arg)}}var JA=[],ZA=[],UA=[],Ie=[];function Le(){if(u.preRun)for(typeof u.preRun=="function"&&(u.preRun=[u.preRun]);u.preRun.length;)Ye(u.preRun.shift());ae(JA)}function oe(){ae(ZA)}function me(){ae(UA)}function ue(){if(u.postRun)for(typeof u.postRun=="function"&&(u.postRun=[u.postRun]);u.postRun.length;)be(u.postRun.shift());ae(Ie)}function Ye(rA){JA.unshift(rA)}function be(rA){Ie.unshift(rA)}var Ce=Math.abs,Se=Math.ceil,pe=Math.floor,Ke=Math.min,$e=0,qe=null;function Xe(rA){$e++,u.monitorRunDependencies&&u.monitorRunDependencies($e)}function vt(rA){if($e--,u.monitorRunDependencies&&u.monitorRunDependencies($e),$e==0&&qe){var pA=qe;qe=null,pA()}}u.preloadedImages={},u.preloadedAudios={};var Qe=null,Je="data:application/octet-stream;base64,";function Be(rA){return String.prototype.startsWith?rA.startsWith(Je):rA.indexOf(Je)===0}var ze,st;Qe="data:application/octet-stream;base64,AAAAAAAAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAAAQAAAAQAAAADAAAABgAAAAUAAAACAAAAAAAAAAIAAAADAAAAAQAAAAQAAAAGAAAAAAAAAAUAAAADAAAABgAAAAQAAAAFAAAAAAAAAAEAAAACAAAABAAAAAUAAAAGAAAAAAAAAAIAAAADAAAAAQAAAAUAAAACAAAAAAAAAAEAAAADAAAABgAAAAQAAAAGAAAAAAAAAAUAAAACAAAAAQAAAAQAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAAAAAAEAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAYAAAAAAAAABQAAAAAAAAAAAAAABAAAAAUAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAYAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAIAAAAAAAAAAAAAAAYAAAAAAAAAAwAAAAIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAFAAAABAAAAAAAAAABAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAYAAAAAAAAABAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAgAAAAQAAAADAAAACAAAAAEAAAAHAAAABgAAAAkAAAAAAAAAAwAAAAIAAAACAAAABgAAAAoAAAALAAAAAAAAAAEAAAAFAAAAAwAAAA0AAAABAAAABwAAAAQAAAAMAAAAAAAAAAQAAAB/AAAADwAAAAgAAAADAAAAAAAAAAwAAAAFAAAAAgAAABIAAAAKAAAACAAAAAAAAAAQAAAABgAAAA4AAAALAAAAEQAAAAEAAAAJAAAAAgAAAAcAAAAVAAAACQAAABMAAAADAAAADQAAAAEAAAAIAAAABQAAABYAAAAQAAAABAAAAAAAAAAPAAAACQAAABMAAAAOAAAAFAAAAAEAAAAHAAAABgAAAAoAAAALAAAAGAAAABcAAAAFAAAAAgAAABIAAAALAAAAEQAAABcAAAAZAAAAAgAAAAYAAAAKAAAADAAAABwAAAANAAAAGgAAAAQAAAAPAAAAAwAAAA0AAAAaAAAAFQAAAB0AAAADAAAADAAAAAcAAAAOAAAAfwAAABEAAAAbAAAACQAAABQAAAAGAAAADwAAABYAAAAcAAAAHwAAAAQAAAAIAAAADAAAABAAAAASAAAAIQAAAB4AAAAIAAAABQAAABYAAAARAAAACwAAAA4AAAAGAAAAIwAAABkAAAAbAAAAEgAAABgAAAAeAAAAIAAAAAUAAAAKAAAAEAAAABMAAAAiAAAAFAAAACQAAAAHAAAAFQAAAAkAAAAUAAAADgAAABMAAAAJAAAAKAAAABsAAAAkAAAAFQAAACYAAAATAAAAIgAAAA0AAAAdAAAABwAAABYAAAAQAAAAKQAAACEAAAAPAAAACAAAAB8AAAAXAAAAGAAAAAsAAAAKAAAAJwAAACUAAAAZAAAAGAAAAH8AAAAgAAAAJQAAAAoAAAAXAAAAEgAAABkAAAAXAAAAEQAAAAsAAAAtAAAAJwAAACMAAAAaAAAAKgAAAB0AAAArAAAADAAAABwAAAANAAAAGwAAACgAAAAjAAAALgAAAA4AAAAUAAAAEQAAABwAAAAfAAAAKgAAACwAAAAMAAAADwAAABoAAAAdAAAAKwAAACYAAAAvAAAADQAAABoAAAAVAAAAHgAAACAAAAAwAAAAMgAAABAAAAASAAAAIQAAAB8AAAApAAAALAAAADUAAAAPAAAAFgAAABwAAAAgAAAAHgAAABgAAAASAAAANAAAADIAAAAlAAAAIQAAAB4AAAAxAAAAMAAAABYAAAAQAAAAKQAAACIAAAATAAAAJgAAABUAAAA2AAAAJAAAADMAAAAjAAAALgAAAC0AAAA4AAAAEQAAABsAAAAZAAAAJAAAABQAAAAiAAAAEwAAADcAAAAoAAAANgAAACUAAAAnAAAANAAAADkAAAAYAAAAFwAAACAAAAAmAAAAfwAAACIAAAAzAAAAHQAAAC8AAAAVAAAAJwAAACUAAAAZAAAAFwAAADsAAAA5AAAALQAAACgAAAAbAAAAJAAAABQAAAA8AAAALgAAADcAAAApAAAAMQAAADUAAAA9AAAAFgAAACEAAAAfAAAAKgAAADoAAAArAAAAPgAAABwAAAAsAAAAGgAAACsAAAA+AAAALwAAAEAAAAAaAAAAKgAAAB0AAAAsAAAANQAAADoAAABBAAAAHAAAAB8AAAAqAAAALQAAACcAAAAjAAAAGQAAAD8AAAA7AAAAOAAAAC4AAAA8AAAAOAAAAEQAAAAbAAAAKAAAACMAAAAvAAAAJgAAACsAAAAdAAAARQAAADMAAABAAAAAMAAAADEAAAAeAAAAIQAAAEMAAABCAAAAMgAAADEAAAB/AAAAPQAAAEIAAAAhAAAAMAAAACkAAAAyAAAAMAAAACAAAAAeAAAARgAAAEMAAAA0AAAAMwAAAEUAAAA2AAAARwAAACYAAAAvAAAAIgAAADQAAAA5AAAARgAAAEoAAAAgAAAAJQAAADIAAAA1AAAAPQAAAEEAAABLAAAAHwAAACkAAAAsAAAANgAAAEcAAAA3AAAASQAAACIAAAAzAAAAJAAAADcAAAAoAAAANgAAACQAAABIAAAAPAAAAEkAAAA4AAAARAAAAD8AAABNAAAAIwAAAC4AAAAtAAAAOQAAADsAAABKAAAATgAAACUAAAAnAAAANAAAADoAAAB/AAAAPgAAAEwAAAAsAAAAQQAAACoAAAA7AAAAPwAAAE4AAABPAAAAJwAAAC0AAAA5AAAAPAAAAEgAAABEAAAAUAAAACgAAAA3AAAALgAAAD0AAAA1AAAAMQAAACkAAABRAAAASwAAAEIAAAA+AAAAKwAAADoAAAAqAAAAUgAAAEAAAABMAAAAPwAAAH8AAAA4AAAALQAAAE8AAAA7AAAATQAAAEAAAAAvAAAAPgAAACsAAABUAAAARQAAAFIAAABBAAAAOgAAADUAAAAsAAAAVgAAAEwAAABLAAAAQgAAAEMAAABRAAAAVQAAADEAAAAwAAAAPQAAAEMAAABCAAAAMgAAADAAAABXAAAAVQAAAEYAAABEAAAAOAAAADwAAAAuAAAAWgAAAE0AAABQAAAARQAAADMAAABAAAAALwAAAFkAAABHAAAAVAAAAEYAAABDAAAANAAAADIAAABTAAAAVwAAAEoAAABHAAAAWQAAAEkAAABbAAAAMwAAAEUAAAA2AAAASAAAAH8AAABJAAAANwAAAFAAAAA8AAAAWAAAAEkAAABbAAAASAAAAFgAAAA2AAAARwAAADcAAABKAAAATgAAAFMAAABcAAAANAAAADkAAABGAAAASwAAAEEAAAA9AAAANQAAAF4AAABWAAAAUQAAAEwAAABWAAAAUgAAAGAAAAA6AAAAQQAAAD4AAABNAAAAPwAAAEQAAAA4AAAAXQAAAE8AAABaAAAATgAAAEoAAAA7AAAAOQAAAF8AAABcAAAATwAAAE8AAABOAAAAPwAAADsAAABdAAAAXwAAAE0AAABQAAAARAAAAEgAAAA8AAAAYwAAAFoAAABYAAAAUQAAAFUAAABeAAAAZQAAAD0AAABCAAAASwAAAFIAAABgAAAAVAAAAGIAAAA+AAAATAAAAEAAAABTAAAAfwAAAEoAAABGAAAAZAAAAFcAAABcAAAAVAAAAEUAAABSAAAAQAAAAGEAAABZAAAAYgAAAFUAAABXAAAAZQAAAGYAAABCAAAAQwAAAFEAAABWAAAATAAAAEsAAABBAAAAaAAAAGAAAABeAAAAVwAAAFMAAABmAAAAZAAAAEMAAABGAAAAVQAAAFgAAABIAAAAWwAAAEkAAABjAAAAUAAAAGkAAABZAAAAYQAAAFsAAABnAAAARQAAAFQAAABHAAAAWgAAAE0AAABQAAAARAAAAGoAAABdAAAAYwAAAFsAAABJAAAAWQAAAEcAAABpAAAAWAAAAGcAAABcAAAAUwAAAE4AAABKAAAAbAAAAGQAAABfAAAAXQAAAE8AAABaAAAATQAAAG0AAABfAAAAagAAAF4AAABWAAAAUQAAAEsAAABrAAAAaAAAAGUAAABfAAAAXAAAAE8AAABOAAAAbQAAAGwAAABdAAAAYAAAAGgAAABiAAAAbgAAAEwAAABWAAAAUgAAAGEAAAB/AAAAYgAAAFQAAABnAAAAWQAAAG8AAABiAAAAbgAAAGEAAABvAAAAUgAAAGAAAABUAAAAYwAAAFAAAABpAAAAWAAAAGoAAABaAAAAcQAAAGQAAABmAAAAUwAAAFcAAABsAAAAcgAAAFwAAABlAAAAZgAAAGsAAABwAAAAUQAAAFUAAABeAAAAZgAAAGUAAABXAAAAVQAAAHIAAABwAAAAZAAAAGcAAABbAAAAYQAAAFkAAAB0AAAAaQAAAG8AAABoAAAAawAAAG4AAABzAAAAVgAAAF4AAABgAAAAaQAAAFgAAABnAAAAWwAAAHEAAABjAAAAdAAAAGoAAABdAAAAYwAAAFoAAAB1AAAAbQAAAHEAAABrAAAAfwAAAGUAAABeAAAAcwAAAGgAAABwAAAAbAAAAGQAAABfAAAAXAAAAHYAAAByAAAAbQAAAG0AAABsAAAAXQAAAF8AAAB1AAAAdgAAAGoAAABuAAAAYgAAAGgAAABgAAAAdwAAAG8AAABzAAAAbwAAAGEAAABuAAAAYgAAAHQAAABnAAAAdwAAAHAAAABrAAAAZgAAAGUAAAB4AAAAcwAAAHIAAABxAAAAYwAAAHQAAABpAAAAdQAAAGoAAAB5AAAAcgAAAHAAAABkAAAAZgAAAHYAAAB4AAAAbAAAAHMAAABuAAAAawAAAGgAAAB4AAAAdwAAAHAAAAB0AAAAZwAAAHcAAABvAAAAcQAAAGkAAAB5AAAAdQAAAH8AAABtAAAAdgAAAHEAAAB5AAAAagAAAHYAAAB4AAAAbAAAAHIAAAB1AAAAeQAAAG0AAAB3AAAAbwAAAHMAAABuAAAAeQAAAHQAAAB4AAAAeAAAAHMAAAByAAAAcAAAAHkAAAB3AAAAdgAAAHkAAAB0AAAAeAAAAHcAAAB1AAAAcQAAAHYAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAACAAAABQAAAAEAAAAAAAAA/////wEAAAAAAAAAAwAAAAQAAAACAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAEAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAUAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAUAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAIAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAD/////AQAAAAAAAAADAAAABAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAUAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAEAAAD//////////wEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAAAAAAAAAAABAAAAAgAAAAYAAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAAAAAAAAAAAAQAAAAEAAAAFAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAAAAAAAAAAABAAAAAwAAAAcAAAAGAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAADgAAAAIAAAAAAAAAAAAAAAEAAAAAAAAACQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAAAAAAAAAAAAAEAAAAEAAAACAAAAAoAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAAAAAAAAAAAAQAAAAsAAAAPAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAIAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAAAAAAAAAAAAQAAAAwAAAAQAAAADAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAADwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAAAAAAAAAAABAAAACgAAABMAAAAIAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAAAAAAAAAAAAAEAAAANAAAAEQAAAA0AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAACAAAAAAAAAAAAAAABAAAADgAAABIAAAAPAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAADwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAASAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABIAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAAAAAAAAQAAAP//////////EwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAASAAAAAAAAABgAAAAAAAAAIQAAAAAAAAAeAAAAAAAAACAAAAADAAAAMQAAAAEAAAAwAAAAAwAAADIAAAADAAAACAAAAAAAAAAFAAAABQAAAAoAAAAFAAAAFgAAAAAAAAAQAAAAAAAAABIAAAAAAAAAKQAAAAEAAAAhAAAAAAAAAB4AAAAAAAAABAAAAAAAAAAAAAAABQAAAAIAAAAFAAAADwAAAAEAAAAIAAAAAAAAAAUAAAAFAAAAHwAAAAEAAAAWAAAAAAAAABAAAAAAAAAAAgAAAAAAAAAGAAAAAAAAAA4AAAAAAAAACgAAAAAAAAALAAAAAAAAABEAAAADAAAAGAAAAAEAAAAXAAAAAwAAABkAAAADAAAAAAAAAAAAAAABAAAABQAAAAkAAAAFAAAABQAAAAAAAAACAAAAAAAAAAYAAAAAAAAAEgAAAAEAAAAKAAAAAAAAAAsAAAAAAAAABAAAAAEAAAADAAAABQAAAAcAAAAFAAAACAAAAAEAAAAAAAAAAAAAAAEAAAAFAAAAEAAAAAEAAAAFAAAAAAAAAAIAAAAAAAAABwAAAAAAAAAVAAAAAAAAACYAAAAAAAAACQAAAAAAAAATAAAAAAAAACIAAAADAAAADgAAAAEAAAAUAAAAAwAAACQAAAADAAAAAwAAAAAAAAANAAAABQAAAB0AAAAFAAAAAQAAAAAAAAAHAAAAAAAAABUAAAAAAAAABgAAAAEAAAAJAAAAAAAAABMAAAAAAAAABAAAAAIAAAAMAAAABQAAABoAAAAFAAAAAAAAAAEAAAADAAAAAAAAAA0AAAAFAAAAAgAAAAEAAAABAAAAAAAAAAcAAAAAAAAAGgAAAAAAAAAqAAAAAAAAADoAAAAAAAAAHQAAAAAAAAArAAAAAAAAAD4AAAADAAAAJgAAAAEAAAAvAAAAAwAAAEAAAAADAAAADAAAAAAAAAAcAAAABQAAACwAAAAFAAAADQAAAAAAAAAaAAAAAAAAACoAAAAAAAAAFQAAAAEAAAAdAAAAAAAAACsAAAAAAAAABAAAAAMAAAAPAAAABQAAAB8AAAAFAAAAAwAAAAEAAAAMAAAAAAAAABwAAAAFAAAABwAAAAEAAAANAAAAAAAAABoAAAAAAAAAHwAAAAAAAAApAAAAAAAAADEAAAAAAAAALAAAAAAAAAA1AAAAAAAAAD0AAAADAAAAOgAAAAEAAABBAAAAAwAAAEsAAAADAAAADwAAAAAAAAAWAAAABQAAACEAAAAFAAAAHAAAAAAAAAAfAAAAAAAAACkAAAAAAAAAKgAAAAEAAAAsAAAAAAAAADUAAAAAAAAABAAAAAQAAAAIAAAABQAAABAAAAAFAAAADAAAAAEAAAAPAAAAAAAAABYAAAAFAAAAGgAAAAEAAAAcAAAAAAAAAB8AAAAAAAAAMgAAAAAAAAAwAAAAAAAAADEAAAADAAAAIAAAAAAAAAAeAAAAAwAAACEAAAADAAAAGAAAAAMAAAASAAAAAwAAABAAAAADAAAARgAAAAAAAABDAAAAAAAAAEIAAAADAAAANAAAAAMAAAAyAAAAAAAAADAAAAAAAAAAJQAAAAMAAAAgAAAAAAAAAB4AAAADAAAAUwAAAAAAAABXAAAAAwAAAFUAAAADAAAASgAAAAMAAABGAAAAAAAAAEMAAAAAAAAAOQAAAAEAAAA0AAAAAwAAADIAAAAAAAAAGQAAAAAAAAAXAAAAAAAAABgAAAADAAAAEQAAAAAAAAALAAAAAwAAAAoAAAADAAAADgAAAAMAAAAGAAAAAwAAAAIAAAADAAAALQAAAAAAAAAnAAAAAAAAACUAAAADAAAAIwAAAAMAAAAZAAAAAAAAABcAAAAAAAAAGwAAAAMAAAARAAAAAAAAAAsAAAADAAAAPwAAAAAAAAA7AAAAAwAAADkAAAADAAAAOAAAAAMAAAAtAAAAAAAAACcAAAAAAAAALgAAAAMAAAAjAAAAAwAAABkAAAAAAAAAJAAAAAAAAAAUAAAAAAAAAA4AAAADAAAAIgAAAAAAAAATAAAAAwAAAAkAAAADAAAAJgAAAAMAAAAVAAAAAwAAAAcAAAADAAAANwAAAAAAAAAoAAAAAAAAABsAAAADAAAANgAAAAMAAAAkAAAAAAAAABQAAAAAAAAAMwAAAAMAAAAiAAAAAAAAABMAAAADAAAASAAAAAAAAAA8AAAAAwAAAC4AAAADAAAASQAAAAMAAAA3AAAAAAAAACgAAAAAAAAARwAAAAMAAAA2AAAAAwAAACQAAAAAAAAAQAAAAAAAAAAvAAAAAAAAACYAAAADAAAAPgAAAAAAAAArAAAAAwAAAB0AAAADAAAAOgAAAAMAAAAqAAAAAwAAABoAAAADAAAAVAAAAAAAAABFAAAAAAAAADMAAAADAAAAUgAAAAMAAABAAAAAAAAAAC8AAAAAAAAATAAAAAMAAAA+AAAAAAAAACsAAAADAAAAYQAAAAAAAABZAAAAAwAAAEcAAAADAAAAYgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAYAAAAAMAAABSAAAAAwAAAEAAAAAAAAAASwAAAAAAAABBAAAAAAAAADoAAAADAAAAPQAAAAAAAAA1AAAAAwAAACwAAAADAAAAMQAAAAMAAAApAAAAAwAAAB8AAAADAAAAXgAAAAAAAABWAAAAAAAAAEwAAAADAAAAUQAAAAMAAABLAAAAAAAAAEEAAAAAAAAAQgAAAAMAAAA9AAAAAAAAADUAAAADAAAAawAAAAAAAABoAAAAAwAAAGAAAAADAAAAZQAAAAMAAABeAAAAAAAAAFYAAAAAAAAAVQAAAAMAAABRAAAAAwAAAEsAAAAAAAAAOQAAAAAAAAA7AAAAAAAAAD8AAAADAAAASgAAAAAAAABOAAAAAwAAAE8AAAADAAAAUwAAAAMAAABcAAAAAwAAAF8AAAADAAAAJQAAAAAAAAAnAAAAAwAAAC0AAAADAAAANAAAAAAAAAA5AAAAAAAAADsAAAAAAAAARgAAAAMAAABKAAAAAAAAAE4AAAADAAAAGAAAAAAAAAAXAAAAAwAAABkAAAADAAAAIAAAAAMAAAAlAAAAAAAAACcAAAADAAAAMgAAAAMAAAA0AAAAAAAAADkAAAAAAAAALgAAAAAAAAA8AAAAAAAAAEgAAAADAAAAOAAAAAAAAABEAAAAAwAAAFAAAAADAAAAPwAAAAMAAABNAAAAAwAAAFoAAAADAAAAGwAAAAAAAAAoAAAAAwAAADcAAAADAAAAIwAAAAAAAAAuAAAAAAAAADwAAAAAAAAALQAAAAMAAAA4AAAAAAAAAEQAAAADAAAADgAAAAAAAAAUAAAAAwAAACQAAAADAAAAEQAAAAMAAAAbAAAAAAAAACgAAAADAAAAGQAAAAMAAAAjAAAAAAAAAC4AAAAAAAAARwAAAAAAAABZAAAAAAAAAGEAAAADAAAASQAAAAAAAABbAAAAAwAAAGcAAAADAAAASAAAAAMAAABYAAAAAwAAAGkAAAADAAAAMwAAAAAAAABFAAAAAwAAAFQAAAADAAAANgAAAAAAAABHAAAAAAAAAFkAAAAAAAAANwAAAAMAAABJAAAAAAAAAFsAAAADAAAAJgAAAAAAAAAvAAAAAwAAAEAAAAADAAAAIgAAAAMAAAAzAAAAAAAAAEUAAAADAAAAJAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAYAAAAAAAAABoAAAAAAAAAGsAAAADAAAAYgAAAAAAAABuAAAAAwAAAHMAAAADAAAAYQAAAAMAAABvAAAAAwAAAHcAAAADAAAATAAAAAAAAABWAAAAAwAAAF4AAAADAAAAUgAAAAAAAABgAAAAAAAAAGgAAAAAAAAAVAAAAAMAAABiAAAAAAAAAG4AAAADAAAAOgAAAAAAAABBAAAAAwAAAEsAAAADAAAAPgAAAAMAAABMAAAAAAAAAFYAAAADAAAAQAAAAAMAAABSAAAAAAAAAGAAAAAAAAAAVQAAAAAAAABXAAAAAAAAAFMAAAADAAAAZQAAAAAAAABmAAAAAwAAAGQAAAADAAAAawAAAAMAAABwAAAAAwAAAHIAAAADAAAAQgAAAAAAAABDAAAAAwAAAEYAAAADAAAAUQAAAAAAAABVAAAAAAAAAFcAAAAAAAAAXgAAAAMAAABlAAAAAAAAAGYAAAADAAAAMQAAAAAAAAAwAAAAAwAAADIAAAADAAAAPQAAAAMAAABCAAAAAAAAAEMAAAADAAAASwAAAAMAAABRAAAAAAAAAFUAAAAAAAAAXwAAAAAAAABcAAAAAAAAAFMAAAAAAAAATwAAAAAAAABOAAAAAAAAAEoAAAADAAAAPwAAAAEAAAA7AAAAAwAAADkAAAADAAAAbQAAAAAAAABsAAAAAAAAAGQAAAAFAAAAXQAAAAEAAABfAAAAAAAAAFwAAAAAAAAATQAAAAEAAABPAAAAAAAAAE4AAAAAAAAAdQAAAAQAAAB2AAAABQAAAHIAAAAFAAAAagAAAAEAAABtAAAAAAAAAGwAAAAAAAAAWgAAAAEAAABdAAAAAQAAAF8AAAAAAAAAWgAAAAAAAABNAAAAAAAAAD8AAAAAAAAAUAAAAAAAAABEAAAAAAAAADgAAAADAAAASAAAAAEAAAA8AAAAAwAAAC4AAAADAAAAagAAAAAAAABdAAAAAAAAAE8AAAAFAAAAYwAAAAEAAABaAAAAAAAAAE0AAAAAAAAAWAAAAAEAAABQAAAAAAAAAEQAAAAAAAAAdQAAAAMAAABtAAAABQAAAF8AAAAFAAAAcQAAAAEAAABqAAAAAAAAAF0AAAAAAAAAaQAAAAEAAABjAAAAAQAAAFoAAAAAAAAAaQAAAAAAAABYAAAAAAAAAEgAAAAAAAAAZwAAAAAAAABbAAAAAAAAAEkAAAADAAAAYQAAAAEAAABZAAAAAwAAAEcAAAADAAAAcQAAAAAAAABjAAAAAAAAAFAAAAAFAAAAdAAAAAEAAABpAAAAAAAAAFgAAAAAAAAAbwAAAAEAAABnAAAAAAAAAFsAAAAAAAAAdQAAAAIAAABqAAAABQAAAFoAAAAFAAAAeQAAAAEAAABxAAAAAAAAAGMAAAAAAAAAdwAAAAEAAAB0AAAAAQAAAGkAAAAAAAAAdwAAAAAAAABvAAAAAAAAAGEAAAAAAAAAcwAAAAAAAABuAAAAAAAAAGIAAAADAAAAawAAAAEAAABoAAAAAwAAAGAAAAADAAAAeQAAAAAAAAB0AAAAAAAAAGcAAAAFAAAAeAAAAAEAAAB3AAAAAAAAAG8AAAAAAAAAcAAAAAEAAABzAAAAAAAAAG4AAAAAAAAAdQAAAAEAAABxAAAABQAAAGkAAAAFAAAAdgAAAAEAAAB5AAAAAAAAAHQAAAAAAAAAcgAAAAEAAAB4AAAAAQAAAHcAAAAAAAAAcgAAAAAAAABwAAAAAAAAAGsAAAAAAAAAZAAAAAAAAABmAAAAAAAAAGUAAAADAAAAUwAAAAEAAABXAAAAAwAAAFUAAAADAAAAdgAAAAAAAAB4AAAAAAAAAHMAAAAFAAAAbAAAAAEAAAByAAAAAAAAAHAAAAAAAAAAXAAAAAEAAABkAAAAAAAAAGYAAAAAAAAAdQAAAAAAAAB5AAAABQAAAHcAAAAFAAAAbQAAAAEAAAB2AAAAAAAAAHgAAAAAAAAAXwAAAAEAAABsAAAAAQAAAHIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAGAAAAAgAAAAUAAAABAAAABAAAAAAAAAAAAAAABQAAAAMAAAABAAAABgAAAAQAAAACAAAAAAAAAH6iBfbytuk/Gq6akm/58z/Xrm0Liez0P5doSdOpSwRAWs602ULg8D/dT7Rcbo/1v1N1RQHFNOM/g9Snx7HW3L8HWsP8Q3jfP6VwOLosutk/9rjk1YQcxj+gnmKMsNn6P/HDeuPFY+M/YHwDjqKhB0Ci19/fCVrbP4UxKkDWOP6/pvljWa09tL9wi7wrQXjnv/Z6yLImkM2/3yTlOzY14D+m+WNZrT20PzwKVQnrQwNA9nrIsiaQzT/g40rFrRQFwPa45NWEHMa/kbslHEZq97/xw3rjxWPjv4cLC2SMBci/otff3wla27+rKF5oIAv0P1N1RQHFNOO/iDJPGyWHBUAHWsP8Q3jfvwQf/by16gXAfqIF9vK26b8XrO0Vh0r+v9eubQuJ7PS/BxLrA0ZZ479azrTZQuDwv1MK1EuItPw/yscgV9Z6FkAwHBR2WjQMQJNRzXsQ5vY/GlUHVJYKF0DONuFv2lMNQNCGZ28QJfk/0WUwoIL36D8ggDOMQuATQNqMOeAy/wZAWFYOYM+M2z/LWC4uH3oSQDE+LyTsMgRAkJzhRGWFGEDd4soovCQQQKqk0DJMEP8/rGmNdwOLBUAW2X/9xCbjP4hu3dcqJhNAzuYItRvdB0CgzW3zJW/sPxotm/Y2TxRAQAk9XmdDDEC1Kx9MKgT3P1M+NctcghZAFVqcLlb0C0Bgzd3sB2b2P77mZDPUWhZAFROHJpUGCEDAfma5CxXtPz1DWq/zYxRAmhYY5824F0DOuQKWSbAOQNCMqrvu3fs/L6DR22K2wT9nAAxPBU8RQGiN6mW43AFAZhu25b633D8c1YgmzowSQNM25BRKWARArGS08/lNxD+LFssHwmMRQLC5aNcxBgJABL9HT0WRF0CjCmJmOGEOQHsuaVzMP/s/TWJCaGGwBUCeu1PAPLzjP9nqN9DZOBNAKE4JcydbCkCGtbd1qjPzP8dgm9U8jhVAtPeKTkVwDkCeCLss5l37P401XMPLmBdAFd29VMVQDUBg0yA55h75Pz6odcYLCRdApBM4rBrkAkDyAVWgQxbRP4XDMnK20hFAymLlF7EmzD8GUgo9XBHlP3lbK7T9COc/k+OhPthhy7+YGEpnrOvCPzBFhLs15u4/epbqB6H4uz9IuuLF5svev6lzLKY31es/CaQ0envF5z8ZY0xlUADXv7zaz7HYEuI/CfbK1sn16T8uAQfWwxLWPzKn/YuFN94/5KdbC1AFu793fyCSnlfvPzK2y4doAMY/NRg5t1/X6b/shq4QJaHDP5yNIAKPOeI/vpn7BSE30r/X4YQrO6nrv78Ziv/Thto/DqJ1Y6+y5z9l51NaxFrlv8QlA65HOLS/86dxiEc96z+Hj0+LFjneP6LzBZ8LTc2/DaJ1Y6+y579l51NaxFrlP8QlA65HOLQ/8qdxiEc967+Jj0+LFjnev6LzBZ8LTc0/1qdbC1AFuz93fyCSnlfvvzK2y4doAMa/NRg5t1/X6T/vhq4QJaHDv5yNIAKPOeK/wJn7BSE30j/W4YQrO6nrP78Ziv/Thtq/CaQ0envF578XY0xlUADXP7zaz7HYEuK/CvbK1sn16b8rAQfWwxLWvzKn/YuFN96/zWLlF7EmzL8GUgo9XBHlv3lbK7T9COe/kOOhPthhyz+cGEpnrOvCvzBFhLs15u6/c5bqB6H4u79IuuLF5sveP6lzLKY31eu/AQAAAP////8HAAAA/////zEAAAD/////VwEAAP////9hCQAA/////6dBAAD/////kcsBAP/////3kAwA/////8H2VwAAAAAAAAAAAAAAAAACAAAA/////w4AAAD/////YgAAAP////+uAgAA/////8ISAAD/////ToMAAP////8ilwMA/////+4hGQD/////gu2vAAAAAAAAAAAAAAAAAAAAAAACAAAA//////////8BAAAAAwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////AgAAAP//////////AQAAAAAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD/////////////////////AQAAAP///////////////wIAAAD///////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP///////////////////////////////wIAAAD///////////////8BAAAA/////////////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAABAAAA//////////8CAAAA//////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAAAQAAAP//////////AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAACAAAAAAAAAAIAAAABAAAAAQAAAAIAAAACAAAAAAAAAAUAAAAFAAAAAAAAAAIAAAACAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAAEAAAACAAAAAgAAAAIAAAAAAAAABQAAAAYAAAAAAAAAAgAAAAIAAAADAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAAAAAACAAAAAQAAAAMAAAACAAAAAgAAAAAAAAAFAAAABwAAAAAAAAACAAAAAgAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAACAAAAAAAAAAIAAAABAAAABAAAAAIAAAACAAAAAAAAAAUAAAAIAAAAAAAAAAIAAAACAAAAAwAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAIAAAAAAAAAAgAAAAEAAAAAAAAAAgAAAAIAAAAAAAAABQAAAAkAAAAAAAAAAgAAAAIAAAADAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAIAAAAAAAAAAwAAAA4AAAACAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAgAAAAMAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAgAAAAAAAAADAAAACgAAAAIAAAAAAAAAAgAAAAMAAAABAAAAAAAAAAIAAAACAAAAAwAAAAcAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAIAAAACAAAAAAAAAAMAAAALAAAAAgAAAAAAAAACAAAAAwAAAAIAAAAAAAAAAgAAAAIAAAADAAAACAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAgAAAAIAAAAAAAAAAwAAAAwAAAACAAAAAAAAAAIAAAADAAAAAwAAAAAAAAACAAAAAgAAAAMAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAACAAAAAgAAAAAAAAADAAAADQAAAAIAAAAAAAAAAgAAAAMAAAAEAAAAAAAAAAIAAAACAAAAAwAAAAoAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAIAAAACAAAAAAAAAAMAAAAGAAAAAgAAAAAAAAACAAAAAwAAAA8AAAAAAAAAAgAAAAIAAAADAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAIAAAAAAAAAAwAAAAcAAAACAAAAAAAAAAIAAAADAAAAEAAAAAAAAAACAAAAAgAAAAMAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAACAAAAAgAAAAAAAAADAAAACAAAAAIAAAAAAAAAAgAAAAMAAAARAAAAAAAAAAIAAAACAAAAAwAAAA0AAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAACAAAAAAAAAAMAAAAJAAAAAgAAAAAAAAACAAAAAwAAABIAAAAAAAAAAgAAAAIAAAADAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAgAAAAIAAAAAAAAAAwAAAAUAAAACAAAAAAAAAAIAAAADAAAAEwAAAAAAAAACAAAAAgAAAAMAAAAPAAAAAAAAAAAAAAAAAAAAAAAAABAAAAACAAAAAAAAAAIAAAABAAAAEwAAAAIAAAACAAAAAAAAAAUAAAAKAAAAAAAAAAIAAAACAAAAAwAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAIAAAAAAAAAAgAAAAEAAAAPAAAAAgAAAAIAAAAAAAAABQAAAAsAAAAAAAAAAgAAAAIAAAADAAAAEQAAAAAAAAAAAAAAAAAAAAAAAAASAAAAAgAAAAAAAAACAAAAAQAAABAAAAACAAAAAgAAAAAAAAAFAAAADAAAAAAAAAACAAAAAgAAAAMAAAASAAAAAAAAAAAAAAAAAAAAAAAAABMAAAACAAAAAAAAAAIAAAABAAAAEQAAAAIAAAACAAAAAAAAAAUAAAANAAAAAAAAAAIAAAACAAAAAwAAABMAAAAAAAAAAAAAAAAAAAAAAAAADwAAAAIAAAAAAAAAAgAAAAEAAAASAAAAAgAAAAIAAAAAAAAABQAAAA4AAAAAAAAAAgAAAAIAAAADAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAAAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAEAAAAAAQAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAA6B6FaUp9QQTPXMuL4myJBraiDfBwx9UBYJseitzTIQOL5if9jqZtAnXX+Z+ycb0C3pucbhRBCQG8wJBYqpRRAlWbDCzCY5z/eFWBUEve6P/+qo4Q50Y4/D9YM3iCcYT8fcA2QJSA0P4ADxu0qAAc/BNcGolVJ2j5d9FACqwquPh9z7MthtI9CSUSYJke/YUJQ/64OyjU0Qpi0+HCmFQdCm3GfIVdh2kHsJ11kAyauQYC3UDFJOoFBSJsFV1OwU0FK5fcxX4AmQWhy/zZIt/lACqaCPsBjzUDbdUNIScugQMYQlVJ4MXNANiuq8GTvRUDxTXnulxEZQFZ8QX5kpuw/qmG/JwYFlEAluh3Q6DB+QKn4vyNq0GZAKOXekas+UUB8xabXXhI6QG63C2pLtSNAdDBtyNfLDUDyOcu67ID2P0rCMvRXAeE/Ki2TSVyzyT9Dk+8Sz2uzP5J+w5ARWp0/NQAoOiMuhj9YnP+RyMJwPxgW7TvQVFk/KgsLYF0kQz9g5dAC6IwzQcgHPVvDex1B1XjppodHBkHJq3OMM9fwQNvcmJ7wddlAInGPpQs/w0BRobq5EBmtQJZ2ai7n+ZVAtv2G5E+bgECG+gIfKBlpQK5f8jdI91JAL39sL/WpPEB8rGxhDqklQK6yUf43XhBAxL9y/tK8+D86XyZpgrHiPwAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAP////8AAAAAAAAAAAAAAAABAAAAAAAAAAAAAAD/////AAAAAAAAAAABAAAAAQAAAAAAAAAAAAAA/////wAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAP////8FAAAABQAAAAAAAAAAAAAAAAAAAAAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAABQAAAAEAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAQAAAAAAAQABAAABAQAAAAAAAQAAAAEAAAABAAEAAAAAAAAAAAAAAAAAAAAAquJYWJZl+D9jaeZNtj/zPwwdI9KqaeO/qGefXwdHdz+q4lhYlmX4P+OrlPMN3PI/DB0j0qpp47+7SQLV4VIEQKriWFiWZfg/r2kma3tz8T82eQmLqNIGwMRIWXMqSvo/fcCszPux9j+jara6ozTwP6hnn18HR3c/MSoKLequ8r+SabgA2nj0P7jBLbDOHO8/1Ym/ICfH4T+6lxjvlFXHv73m373LRPU/0vXyDVxo7T+ToKRHJXMAQF/33578aPE/pAyy64tD9T8+U/hCvyruPwxv8Y7YYwLAuXYr8NAiCEB4+LDK0Sn0P1Qeuy4j+eo/OMx50n7K7L+TrGB/nyf8v5ehC2fbYPM/aXMKexiT6z8mFRIMjg/zP7yUVwGGBNw/E6opHERf8z/z0wR2g9DqPw4pBpcOhvu/NbA29uWAA8DMaTExyXzyP02biiQ+Ruk/S8jz2/FKBEB1pzZnpbb9P7pQU4wLfPI//7ZcQXeG6D9CqEQvAYoIwDB2VB6sSgRAVyv8H5We8T+EHWF8XNPmPzB2wT8Nrrg/SEi+cX+w4L8of+GtdSDxP1sjk5AdouU/6ZjOVru13r8K0obqI6bxvwVbdNXyhfA/w5GG024n5z+rwmtMzP8BwLw9pSX49QXABe/2uQxP8D+b6wCzCvXkP7uGT87fK+Q/pz/JWw4coj+qoBf2J0nwP/yE3PUo0+I/vFJeHcaC+D96luSIqvntP/bf8sHUYu8/gZNN41mL4z9bhOqVOF4FwO6lmAh1hQhAbCVxbdhk7z+1C8NdDcfiPwG36x/0OQBAx0WJ76c2+D9nlSHXANfuP2HlfZ3gqOE/EwnVlVPg9r96+oHzEH//v5bXzdT1Auw/DM3GwLsA4D9p/8uoKcr+v+U9x5DQVAPAehjSdghb7D9sc1IetODgP8MVwwB1pu6/azPk6OGe978W8t/TUc3rP+0QMvYfP+A/RsG/QpSE8D+l3uwScxzgPwQaifgujuw/k1Vti1I43z8MAwLnSh0GQH5nYnwwZgJAiGUzWC5s6j8WyyI/BbLgPw4iUapGeQJAB3W+imnp/j9BLWR4ssrpP2t+gG5Pstk/cpBsfm6DCMCOpU9dOZsFQEv8nFypHeo/ehJ6i+6S2D9jqlGEmarLv7STC5TRiOa/bC+x8WZD6D9H3yUkWpDZP8gZvmCMuQLAreY19/eRBsCoPOc8UzzpP6KI/QV+y9g/t/MoboyWzT+Hv5q3Zu3Mvy2xROCT4uY/9gQitMMg1T9abAqhWMDkv1oLTavoUfG/PMUJP9CD5j+fHRX3t6fSPz7W2gk6bvs/WRnuHwqN9D8YFturGCTmP1EZczv0b9I/5t4exabB5D/1ESLh5fTEP9X2z6SYweQ/6lv3I2zT0D9zkRGNUNMAQKoSvc4EIfs/Xggt8wQI5T+mJHHg/w/SP4lhT/9t8vQ/DrZ/DbwH7D+XlhbYZrjkP34LIpFt6c4/lwfp8fLX9L+j96CTTf76v3WdNhEv9uM/d8c3o4lV0D/vFdCHVcsFwAHeDq0F1QhApbYqcZiN5D9KoilqByXLPwX0/diA0vq/0fo0GxnxAMBbaTkvlCzjP/RrFrWXrMs/UYTrky7jA0DB9f4FiZYAQEGAk/3QzeE/r/TeqE8t0D/OqjlsnPbvvz8RKU8JOfW/smSEbK/O4T8MzuyPm3DDP/rFtctq9gZAfb1EVEaSA0Dts5dVInnhP18SFMc79MM/7y34cw6LAMDFrRJsZO0DwC2KLvLSYuA/hx5wcUHewz+49SnK/4ruPyeS0PX9a+E/ZxaaLvvZ3z8WPu5T2QS8Pygo4RIvMqa/BJ0Kqsd0279cKW4ay8jdP3b05bmZ364/10/qtdxk2r+Bcz6CDMvpv54qOw+Amdw/qLV71pW7sT/YKc80nIPUP8OfIaBJ77G/LyTuD1un2z+diYu8efWzP1wU7ACkfwjAZroyPL1yBkAmv3lKJJbbPysKSE4W+p0/dIgqY79TA8ATLTOQ3tsGwJ2zweD/Xdg/XO/jXeFUaL8VW2qLFKfov1cA9Aa6XfK/tIa7YGgI2T+f3hu/sxqPv2nXdPpf3Pc/jkw8Jbda8j+tT/z8tGPVP1yBHpJd35k/KYvYOy1s8j/yz+kCQjPrP9+agH7x59g/PZfJ9aBhpr/rDKzvYBb+PwtkiaGCt/c/vb1mVr+f1T/JIHwHc8Govw7aeF6+9vG/Xv7kD6fp979isYioQYHVP7AIQZuSFrG/3z1AdUTnAUDN3XY9O7f9P0AdQ9ljYNQ/dJANJPTOrb8kLECUiiPlP4yF7UgmStA/9xGmXxCG1T9qZzix4W2zv2SGJRJVrPe/Fh9a2M/B/b8IexzFCoPSP9y1QFD2bLe/Q86cWLJe/b+mOOfYm78BwOTjkPAGE9E/8aPCUKu/ub9pPZyLCiUGwBA7Mev/BQlALOmrlRi+0j+AMJ/dKULBv7iLtL6a6QRAEMDV/yajAUDa62dE3crJP1P70RgBUbq/38hVnR6esT/s1tG10Z/Ov/zLwalHPss/dTS9NKTXx78nMcRzCIEHQAabxDsAmQRA0tyLK3gSyT+Aui7nOhDGv5Gs58z3WgHATN3forJuBMCAui7nOhDGP9Lciyt4Esm/WAJyHQ4c7z8UP5HFIs3iP3U0vTSk18c//MvBqUc+y7+cvv8HLg/Kvy1I/mHsI+K/U/vRGAFRuj/a62dE3crJv8p+WV8KlQjAuQ/nOP43B0CAMJ/dKULBPyzpq5UYvtK/ZoU+VoLh4L9etLlRUfvtv/GjwlCrv7k/5OOQ8AYT0b9DfT9FhufXPwUX8hJp+4u/3LVAUPZstz8IexzFCoPSv9+L609E5fQ/q9Fz7X2J7T9qZzix4W2zP/cRpl8QhtW/vtNilqGX+j8MOy7QJoL0P3SQDST0zq0/QB1D2WNg1L8IIjSvGNkDwGB8Jou2GAfAsAhBm5IWsT9isYioQYHVvyS9D3zb6uy/gnwRa7uM9L/JIHwHc8GoP729Zla/n9W/CsAHJZwmAEDEW6OYT1r6Pz2XyfWgYaY/35qAfvHn2L83Tdy4lS30vxf2/gZ0jPq/XIEekl3fmb+tT/z8tGPVvybPr2zJ1/+/K7mJ0ypVAsCf3hu/sxqPPwCGu2BoCNm/5oITrpZn+r+UDUyDP+n/v1zv413hVGg/nbPB4P9d2L9MlmkxNvgCQMtZlKE85v8/KwpIThb6nb8mv3lKJJbbv8+SZsTvOOc/pQCIIOYw0j+diYu8efWzvy8k7g9bp9u/kxYDa+pKtD9XlYvA8HnVv6i1e9aVu7G/nio7D4CZ3L/WR6rNh5EGwCkgQweBkghAdvTluZnfrr9cKW4ay8jdvxbjhr1f1QVAR5C0MzivAkAWPu5T2QS8v2cWmi772d+/cKj4lzLJCEBx2QJfYrMFQIcecHFB3sO/LYou8tJi4L+jr7lhO38BwIcI0Nb7xgTAXxIUxzv0w7/ts5dVInnhv0T+l8DZLfE/MP3FoFvS5D8MzuyPm3DDv7JkhGyvzuG/tzhzRIRc0b9Ovv3/0z7mv6/03qhPLdC/m4CT/dDN4b9dwjU5VCQBQBBJX1ntCv0/9GsWtZesy79baTkvlCzjv1mjYgEz++S/oW6KnOQW8b9KoilqByXLv6W2KnGYjeS/SmaKz3Vx9z+BZB5yxGHwP3fHN6OJVdC/dZ02ES/2478PuaBjLrXaP4/JU81pPaO/fgsikW3pzr+XlhbYZrjkv4tSn7YDbP0/f2LnFKlF9z+mJHHg/w/Sv14ILfMECOW/mfg4qYhR/b+OP+RQDCACwOpb9yNs09C/1fbPpJjB5L9pN2WOVZ3wv3hHy9nxIve/URlzO/Rv0r8YFturGCTmv1d1/KKR8QPA8gsy9qzSB8CfHRX3t6fSvzzFCT/Qg+a/EYStnrzV9r/2QJqI7Lb9v/YEIrTDINW/LbFE4JPi5r/7kQEs5fEDQHunnf4GeQBAooj9BX7L2L+oPOc8Uzzpv+ydYY2SSAfAL4HK6CRTB0BH3yUkWpDZv2wvsfFmQ+i/Ik0Yzruh6T8fM3LoGoDUP3oSeovukti/S/ycXKkd6r9rEv+7UWcHQCRIQe/GfwNAa36Abk+y2b9BLWR4ssrpv9KT87qa0bM/FTyktw823L8WyyI/BbLgv4hlM1gubOq/DizMp9Ki6r8b5ckdjVrzv5NVbYtSON+/BBqJ+C6O7L/dUBFqgyXYv00Wh18r7+q/7RAy9h8/4L8W8t/TUc3rv4RM5DKx3wDAfvWIj94aBcBsc1IetODgv3oY0nYIW+y/oGcTFF54AUDkJqS/FKX6PwzNxsC7AOC/ltfN1PUC7L+5Wrz/zHnzP6688w2rNOc/YeV9neCo4b9nlSHXANfuvw9RsxKjY/s/1V8GteXE8j+1C8NdDcfiv2wlcW3YZO+/IOywaA7Q8b9bFP+4Tg36v4GTTeNZi+O/9t/ywdRi77+tRc3yFR7eP2bkcHXJkLO//ITc9SjT4r+qoBf2J0nwv2YHKoswwfm/iQcLspCjAcCb6wCzCvXkvwXv9rkMT/C/YkuwYAMXBMApCNUai9kIwMORhtNuJ+e/BVt01fKF8L+ZqWEfvIjsP6h693QZYNk/WyOTkB2i5b8of+GtdSDxvwpaaulDSwVADMQAX+lOAECEHWF8XNPmv1cr/B+VnvG/XyFG6opcCMD/mtR32/UEQP+2XEF3hui/ulBTjAt88r/imfCfRP+yP9zbvtc8XeO/TZuKJD5G6b/MaTExyXzyvxiTQeElXOO/rbJRQVGN9L/z0wR2g9DqvxOqKRxEX/O/FDGCEei99j9x8zV4VYTmP2lzCnsYk+u/l6ELZ9tg878pRXacaDT/v3k6GZRqoQXAVB67LiP56r94+LDK0Sn0vwO6pZ9b7wFAvK0nKVcc9j8+U/hCvyruv6QMsuuLQ/W/FPhKFYv46j8MyxaDTOW/v9L18g1caO2/vebfvctE9b/7GD8ZrF3xv3gx1AR9bQDAuMEtsM4c77+SabgA2nj0v5xKFIwxsATArKNSBaKsB0Cjara6ozTwv33ArMz7sfa/dF2U0FcWCcDxL357DJX/P69pJmt7c/G/quJYWJZl+L/YntVJlnrSP4sRLzXM+fe/46uU8w3c8r+q4lhYlmX4v85lu5+QRwRAsI0H/WU8479jaeZNtj/zv6riWFiWZfi/sI0H/WU847/OZbufkEcEQHAoPUBrnss/9exKzDtFtT88wM8kax+gP9OqeKeAYog/MW0ItiZvcj+ph+smvt5bP2lCaV5dEUU/StaUmQDaLz+kK9y22BMYP0O3whZuMwI/IIbgZGWE6z7UkjYaEM3UPuezxwa9cr8+LybxRMnFpz6E1N8DbPiRPsYjySMvK3s+//////8fAAj//////zMQCP////9/MiAI/////28yMAj/////YzJACP///z9iMlAI////N2IyYAj///8zYjJwCP//vzNiMoAI//+rM2IykAj/f6szYjKgCP8PqzNiMrAI/wOrM2IywAi/A6szYjLQCJ8DqzNiMuAImQOrM2Iy8Aj//////z8PCP//////Kx8I/////38pLwj/////Pyk/CP////85KU8I////PzgpXwj///8POClvCP///w44KX8I//8fDjgpjwj//w8OOCmfCP9/DQ44Ka8I/w8NDjgpvwj/DQ0OOCnPCP8MDQ44Kd8IxwwNDjgp7wjEDA0OOCn/CAcAAAAHAAAAAQAAAAIAAAAEAAAAAwAAAAAAAAAAAAAABwAAAAMAAAABAAAAAgAAAAUAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAACAAAAAQAAAAMAAAAOAAAABgAAAAsAAAACAAAABwAAAAEAAAAYAAAABQAAAAoAAAABAAAABgAAAAAAAAAmAAAABwAAAAwAAAADAAAACAAAAAIAAAAxAAAACQAAAA4AAAAAAAAABQAAAAQAAAA6AAAACAAAAA0AAAAEAAAACQAAAAMAAAA/AAAACwAAAAYAAAAPAAAACgAAABAAAABIAAAADAAAAAcAAAAQAAAACwAAABEAAABTAAAACgAAAAUAAAATAAAADgAAAA8AAABhAAAADQAAAAgAAAARAAAADAAAABIAAABrAAAADgAAAAkAAAASAAAADQAAABMAAAB1AAAADwAAABMAAAARAAAAEgAAABAAAAAGAAAAAgAAAAMAAAAFAAAABAAAAAAAAAAAAAAAAAAAAAYAAAACAAAAAwAAAAEAAAAFAAAABAAAAAAAAAAAAAAABwAAAAUAAAADAAAABAAAAAEAAAAAAAAAAgAAAAAAAAACAAAAAwAAAAEAAAAFAAAABAAAAAYAAAAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+b8YLURU+yEJQBgtRFT7IQnAYWxnb3MuYwBoM05laWdoYm9yUm90YXRpb25zAGNvb3JkaWprLmMAX3VwQXA3Q2hlY2tlZABfdXBBcDdyQ2hlY2tlZABkaXJlY3RlZEVkZ2UuYwBkaXJlY3RlZEVkZ2VUb0JvdW5kYXJ5AGFkamFjZW50RmFjZURpclt0bXBGaWprLmZhY2VdW2ZpamsuZmFjZV0gPT0gS0kAZmFjZWlqay5jAF9mYWNlSWprUGVudFRvQ2VsbEJvdW5kYXJ5AGFkamFjZW50RmFjZURpcltjZW50ZXJJSksuZmFjZV1bZmFjZTJdID09IEtJAF9mYWNlSWprVG9DZWxsQm91bmRhcnkAaDNJbmRleC5jAGNvbXBhY3RDZWxscwBsYXRMbmdUb0NlbGwAY2VsbFRvQ2hpbGRQb3MAdmFsaWRhdGVDaGlsZFBvcwBsYXRMbmcuYwBjZWxsQXJlYVJhZHMyAHBvbHlnb24tPm5leHQgPT0gTlVMTABsaW5rZWRHZW8uYwBhZGROZXdMaW5rZWRQb2x5Z29uAG5leHQgIT0gTlVMTABsb29wICE9IE5VTEwAYWRkTmV3TGlua2VkTG9vcABwb2x5Z29uLT5maXJzdCA9PSBOVUxMAGFkZExpbmtlZExvb3AAY29vcmQgIT0gTlVMTABhZGRMaW5rZWRDb29yZABsb29wLT5maXJzdCA9PSBOVUxMAGlubmVyTG9vcHMgIT0gTlVMTABub3JtYWxpemVNdWx0aVBvbHlnb24AYmJveGVzICE9IE5VTEwAY2FuZGlkYXRlcyAhPSBOVUxMAGZpbmRQb2x5Z29uRm9ySG9sZQBjYW5kaWRhdGVCQm94ZXMgIT0gTlVMTAByZXZEaXIgIT0gSU5WQUxJRF9ESUdJVABsb2NhbGlqLmMAY2VsbFRvTG9jYWxJamsAYmFzZUNlbGwgIT0gb3JpZ2luQmFzZUNlbGwAIShvcmlnaW5PblBlbnQgJiYgaW5kZXhPblBlbnQpAGJhc2VDZWxsID09IG9yaWdpbkJhc2VDZWxsAGJhc2VDZWxsICE9IElOVkFMSURfQkFTRV9DRUxMAGxvY2FsSWprVG9DZWxsACFfaXNCYXNlQ2VsbFBlbnRhZ29uKGJhc2VDZWxsKQBiYXNlQ2VsbFJvdGF0aW9ucyA+PSAwAGdyaWRQYXRoQ2VsbHMAcG9seWZpbGwuYwBpdGVyU3RlcFBvbHlnb25Db21wYWN0ADAAdmVydGV4LmMAdmVydGV4Um90YXRpb25zAGNlbGxUb1ZlcnRleABncmFwaC0+YnVja2V0cyAhPSBOVUxMAHZlcnRleEdyYXBoLmMAaW5pdFZlcnRleEdyYXBoAG5vZGUgIT0gTlVMTABhZGRWZXJ0ZXhOb2Rl";var jt=28640;function v0(rA,pA,IA,xA){dt("Assertion failed: "+iA(rA)+", at: "+[pA?iA(pA):"unknown filename",IA,xA?iA(xA):"unknown function"])}function Yt(){return kA.length}function Kt(rA,pA,IA){LA.set(LA.subarray(pA,pA+IA),rA)}function N0(rA){return u.___errno_location&&(GA[u.___errno_location()>>2]=rA),rA}function er(rA){dt("OOM")}function k0(rA){try{var pA=new ArrayBuffer(rA);return pA.byteLength!=rA?void 0:(new Int8Array(pA).set(kA),f0(pA),sA(pA),1)}catch{}}function zt(rA){var pA=Yt(),IA=16777216,xA=2147483648-IA;if(rA>xA)return!1;for(var t=16777216,b=Math.max(pA,t);b>4,t=(De&15)<<4|He>>2,b=(He&3)<<6|$A,IA=IA+String.fromCharCode(xA),He!==64&&(IA=IA+String.fromCharCode(t)),$A!==64&&(IA=IA+String.fromCharCode(b));while(ye13780509?(A=vn(15,A)|0,A|0):(r=((e|0)<0)<<31>>31,o=ft(e|0,r|0,3,0)|0,n=S()|0,r=KA(e|0,r|0,1,0)|0,r=ft(o|0,n|0,r|0,S()|0)|0,r=KA(r|0,S()|0,1,0)|0,e=S()|0,t[A>>2]=r,t[A+4>>2]=e,A=0,A|0)}function v(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,D(e,A,r,n,0)|0}function D(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0,a=0,f=0;if(a=k,k=k+16|0,s=a,!(F(e,A,r,n,o)|0))return n=0,k=a,n|0;do if((r|0)>=0){if((r|0)>13780509){if(i=vn(15,s)|0,i|0)break;l=s,s=t[l>>2]|0,l=t[l+4>>2]|0}else i=((r|0)<0)<<31>>31,f=ft(r|0,i|0,3,0)|0,l=S()|0,i=KA(r|0,i|0,1,0)|0,i=ft(f|0,l|0,i|0,S()|0)|0,i=KA(i|0,S()|0,1,0)|0,l=S()|0,t[s>>2]=i,t[s+4>>2]=l,s=i;if(Y0(n|0,0,s<<3|0)|0,o|0){Y0(o|0,0,s<<2|0)|0,i=X(e,A,r,n,o,s,l,0)|0;break}i=Qt(s,4)|0,i?(f=X(e,A,r,n,i,s,l,0)|0,qA(i),i=f):i=13}else i=2;while(!1);return f=i,k=a,f|0}function F(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0;if(G=k,k=k+16|0,I=G,L=G+8|0,j=I,t[j>>2]=e,t[j+4>>2]=A,(r|0)<0)return L=2,k=G,L|0;if(i=n,t[i>>2]=e,t[i+4>>2]=A,i=(o|0)!=0,i&&(t[o>>2]=0),Oe(e,A)|0)return L=9,k=G,L|0;t[L>>2]=0;A:do if((r|0)>=1)if(i)for(m=1,f=0,M=0,j=1,i=e;;){if(!(f|M)){if(i=Y(i,A,4,L,I)|0,i|0)break A;if(A=I,i=t[A>>2]|0,A=t[A+4>>2]|0,Oe(i,A)|0){i=9;break A}}if(i=Y(i,A,t[26800+(M<<2)>>2]|0,L,I)|0,i|0)break A;if(A=I,i=t[A>>2]|0,A=t[A+4>>2]|0,e=n+(m<<3)|0,t[e>>2]=i,t[e+4>>2]=A,t[o+(m<<2)>>2]=j,e=f+1|0,s=(e|0)==(j|0),l=M+1|0,a=(l|0)==6,Oe(i,A)|0){i=9;break A}if(j=j+(a&s&1)|0,(j|0)>(r|0)){i=0;break}else m=m+1|0,f=s?0:e,M=s?a?0:l:M}else for(m=1,f=0,M=0,j=1,i=e;;){if(!(f|M)){if(i=Y(i,A,4,L,I)|0,i|0)break A;if(A=I,i=t[A>>2]|0,A=t[A+4>>2]|0,Oe(i,A)|0){i=9;break A}}if(i=Y(i,A,t[26800+(M<<2)>>2]|0,L,I)|0,i|0)break A;if(A=I,i=t[A>>2]|0,A=t[A+4>>2]|0,e=n+(m<<3)|0,t[e>>2]=i,t[e+4>>2]=A,e=f+1|0,s=(e|0)==(j|0),l=M+1|0,a=(l|0)==6,Oe(i,A)|0){i=9;break A}if(j=j+(a&s&1)|0,(j|0)>(r|0)){i=0;break}else m=m+1|0,f=s?0:e,M=s?a?0:l:M}else i=0;while(!1);return L=i,k=G,L|0}function X(e,A,r,n,o,i,s,l){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0,i=i|0,s=s|0,l=l|0;var a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0;if(G=k,k=k+16|0,I=G+8|0,L=G,a=jr(e|0,A|0,i|0,s|0)|0,m=S()|0,M=n+(a<<3)|0,W=M,nA=t[W>>2]|0,W=t[W+4>>2]|0,f=(nA|0)==(e|0)&(W|0)==(A|0),!((nA|0)==0&(W|0)==0|f))do a=KA(a|0,m|0,1,0)|0,a=Rr(a|0,S()|0,i|0,s|0)|0,m=S()|0,M=n+(a<<3)|0,nA=M,W=t[nA>>2]|0,nA=t[nA+4>>2]|0,f=(W|0)==(e|0)&(nA|0)==(A|0);while(!((W|0)==0&(nA|0)==0|f));if(a=o+(a<<2)|0,f&&(t[a>>2]|0)<=(l|0)||(nA=M,t[nA>>2]=e,t[nA+4>>2]=A,t[a>>2]=l,(l|0)>=(r|0)))return nA=0,k=G,nA|0;switch(f=l+1|0,t[I>>2]=0,a=Y(e,A,2,I,L)|0,a|0){case 9:{j=9;break}case 0:{a=L,a=X(t[a>>2]|0,t[a+4>>2]|0,r,n,o,i,s,f)|0,a||(j=9);break}}A:do if((j|0)==9){switch(t[I>>2]=0,a=Y(e,A,3,I,L)|0,a|0){case 9:break;case 0:{if(a=L,a=X(t[a>>2]|0,t[a+4>>2]|0,r,n,o,i,s,f)|0,a|0)break A;break}default:break A}switch(t[I>>2]=0,a=Y(e,A,1,I,L)|0,a|0){case 9:break;case 0:{if(a=L,a=X(t[a>>2]|0,t[a+4>>2]|0,r,n,o,i,s,f)|0,a|0)break A;break}default:break A}switch(t[I>>2]=0,a=Y(e,A,5,I,L)|0,a|0){case 9:break;case 0:{if(a=L,a=X(t[a>>2]|0,t[a+4>>2]|0,r,n,o,i,s,f)|0,a|0)break A;break}default:break A}switch(t[I>>2]=0,a=Y(e,A,4,I,L)|0,a|0){case 9:break;case 0:{if(a=L,a=X(t[a>>2]|0,t[a+4>>2]|0,r,n,o,i,s,f)|0,a|0)break A;break}default:break A}switch(t[I>>2]=0,a=Y(e,A,6,I,L)|0,a|0){case 9:break;case 0:{if(a=L,a=X(t[a>>2]|0,t[a+4>>2]|0,r,n,o,i,s,f)|0,a|0)break A;break}default:break A}return nA=0,k=G,nA|0}while(!1);return nA=a,k=G,nA|0}function Y(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0;if(r>>>0>6)return o=1,o|0;if(M=(t[n>>2]|0)%6|0,t[n>>2]=M,(M|0)>0){i=0;do r=Gt(r)|0,i=i+1|0;while((i|0)<(t[n>>2]|0))}if(M=wA(e|0,A|0,45)|0,S()|0,m=M&127,m>>>0>121)return o=5,o|0;a=Pt(e,A)|0,i=wA(e|0,A|0,52)|0,S()|0,i=i&15;A:do if(!i)f=8;else{for(;;){if(s=(15-i|0)*3|0,l=wA(e|0,A|0,s|0)|0,S()|0,l=l&7,(l|0)==7){A=5;break}if(L=(Jt(i)|0)==0,i=i+-1|0,j=EA(7,0,s|0)|0,A=A&~(S()|0),I=EA(t[(L?432:16)+(l*28|0)+(r<<2)>>2]|0,0,s|0)|0,s=S()|0,r=t[(L?640:224)+(l*28|0)+(r<<2)>>2]|0,e=I|e&~j,A=s|A,!r){r=0;break A}if(!i){f=8;break A}}return A|0}while(!1);(f|0)==8&&(L=t[848+(m*28|0)+(r<<2)>>2]|0,I=EA(L|0,0,45)|0,e=I|e,A=S()|0|A&-1040385,r=t[4272+(m*28|0)+(r<<2)>>2]|0,(L&127|0)==127&&(L=EA(t[848+(m*28|0)+20>>2]|0,0,45)|0,A=S()|0|A&-1040385,r=t[4272+(m*28|0)+20>>2]|0,e=lr(L|e,A)|0,A=S()|0,t[n>>2]=(t[n>>2]|0)+1)),l=wA(e|0,A|0,45)|0,S()|0,l=l&127;A:do if(Re(l)|0){e:do if((Pt(e,A)|0)==1){if((m|0)!=(l|0))if(S0(l,t[7696+(m*28|0)>>2]|0)|0){e=Zn(e,A)|0,s=1,A=S()|0;break}else OA(27795,26864,533,26872);switch(a|0){case 3:{e=lr(e,A)|0,A=S()|0,t[n>>2]=(t[n>>2]|0)+1,s=0;break e}case 5:{e=Zn(e,A)|0,A=S()|0,t[n>>2]=(t[n>>2]|0)+5,s=0;break e}case 0:return L=9,L|0;default:return L=1,L|0}}else s=0;while(!1);if((r|0)>0){i=0;do e=Kn(e,A)|0,A=S()|0,i=i+1|0;while((i|0)!=(r|0))}if((m|0)!=(l|0)){if(!(Et(l)|0)){if((s|0)!=0|(Pt(e,A)|0)!=5)break;t[n>>2]=(t[n>>2]|0)+1;break}switch(M&127){case 8:case 118:break A}(Pt(e,A)|0)!=3&&(t[n>>2]=(t[n>>2]|0)+1)}}else if((r|0)>0){i=0;do e=lr(e,A)|0,A=S()|0,i=i+1|0;while((i|0)!=(r|0))}while(!1);return t[n>>2]=((t[n>>2]|0)+r|0)%6|0,L=o,t[L>>2]=e,t[L+4>>2]=A,L=0,L|0}function hA(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,RA(e,A,r,n)|0?(Y0(n|0,0,r*48|0)|0,n=XA(e,A,r,n)|0,n|0):(n=0,n|0)}function RA(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0;if(L=k,k=k+16|0,j=L,I=L+8|0,M=j,t[M>>2]=e,t[M+4>>2]=A,(r|0)<0)return I=2,k=L,I|0;if(!r)return I=n,t[I>>2]=e,t[I+4>>2]=A,I=0,k=L,I|0;t[I>>2]=0;A:do if(Oe(e,A)|0)e=9;else{o=0,M=e;do{if(e=Y(M,A,4,I,j)|0,e|0)break A;if(A=j,M=t[A>>2]|0,A=t[A+4>>2]|0,o=o+1|0,Oe(M,A)|0){e=9;break A}}while((o|0)<(r|0));m=n,t[m>>2]=M,t[m+4>>2]=A,m=r+-1|0,f=0,e=1;do{if(o=26800+(f<<2)|0,(f|0)==5)for(s=t[o>>2]|0,i=0,o=e;;){if(e=j,e=Y(t[e>>2]|0,t[e+4>>2]|0,s,I,j)|0,e|0)break A;if((i|0)!=(m|0))if(a=j,l=t[a>>2]|0,a=t[a+4>>2]|0,e=n+(o<<3)|0,t[e>>2]=l,t[e+4>>2]=a,!(Oe(l,a)|0))e=o+1|0;else{e=9;break A}else e=o;if(i=i+1|0,(i|0)>=(r|0))break;o=e}else for(s=j,a=t[o>>2]|0,l=0,o=e,i=t[s>>2]|0,s=t[s+4>>2]|0;;){if(e=Y(i,s,a,I,j)|0,e|0)break A;if(s=j,i=t[s>>2]|0,s=t[s+4>>2]|0,e=n+(o<<3)|0,t[e>>2]=i,t[e+4>>2]=s,e=o+1|0,Oe(i,s)|0){e=9;break A}if(l=l+1|0,(l|0)>=(r|0))break;o=e}f=f+1|0}while(f>>>0<6);e=j,e=(M|0)==(t[e>>2]|0)&&(A|0)==(t[e+4>>2]|0)?0:9}while(!1);return I=e,k=L,I|0}function XA(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0;if(M=k,k=k+16|0,s=M,!r)return t[n>>2]=e,t[n+4>>2]=A,n=0,k=M,n|0;do if((r|0)>=0){if((r|0)>13780509){if(o=vn(15,s)|0,o|0)break;i=s,o=t[i>>2]|0,i=t[i+4>>2]|0}else o=((r|0)<0)<<31>>31,m=ft(r|0,o|0,3,0)|0,i=S()|0,o=KA(r|0,o|0,1,0)|0,o=ft(m|0,i|0,o|0,S()|0)|0,o=KA(o|0,S()|0,1,0)|0,i=S()|0,m=s,t[m>>2]=o,t[m+4>>2]=i;if(f=Qt(o,8)|0,!f)o=13;else{if(m=Qt(o,4)|0,!m){qA(f),o=13;break}if(o=X(e,A,r,f,m,o,i,0)|0,o|0){qA(f),qA(m);break}if(A=t[s>>2]|0,s=t[s+4>>2]|0,(s|0)>0|(s|0)==0&A>>>0>0){o=0,l=0,a=0;do e=f+(l<<3)|0,i=t[e>>2]|0,e=t[e+4>>2]|0,!((i|0)==0&(e|0)==0)&&(t[m+(l<<2)>>2]|0)==(r|0)&&(j=n+(o<<3)|0,t[j>>2]=i,t[j+4>>2]=e,o=o+1|0),l=KA(l|0,a|0,1,0)|0,a=S()|0;while((a|0)<(s|0)|(a|0)==(s|0)&l>>>0>>0)}qA(f),qA(m),o=0}}else o=2;while(!1);return j=o,k=M,j|0}function Ae(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0;for(l=k,k=k+16|0,i=l,s=l+8|0,o=(Oe(e,A)|0)==0,o=o?1:2;;){if(t[s>>2]=0,f=(Y(e,A,o,s,i)|0)==0,a=i,f&((t[a>>2]|0)==(r|0)?(t[a+4>>2]|0)==(n|0):0)){e=4;break}if(o=o+1|0,o>>>0>=7){o=7,e=4;break}}return(e|0)==4?(k=l,o|0):0}function ce(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0;if(l=k,k=k+48|0,o=l+16|0,i=l+8|0,s=l,r=on(r)|0,r|0)return s=r,k=l,s|0;if(f=e,a=t[f+4>>2]|0,r=i,t[r>>2]=t[f>>2],t[r+4>>2]=a,ei(i,o),r=mA(o,A,s)|0,!r){if(A=t[i>>2]|0,i=t[e+8>>2]|0,(i|0)>0){o=t[e+12>>2]|0,r=0;do A=(t[o+(r<<3)>>2]|0)+A|0,r=r+1|0;while((r|0)<(i|0))}r=s,o=t[r>>2]|0,r=t[r+4>>2]|0,i=((A|0)<0)<<31>>31,(r|0)<(i|0)|(r|0)==(i|0)&o>>>0>>0?(r=s,t[r>>2]=A,t[r+4>>2]=i,r=i):A=o,a=KA(A|0,r|0,12,0)|0,f=S()|0,r=s,t[r>>2]=a,t[r+4>>2]=f,r=n,t[r>>2]=a,t[r+4>>2]=f,r=0}return f=r,k=l,f|0}function Ge(e,A,r,n,o,i,s){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0,i=i|0,s=s|0;var l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0,$=0,U=0,BA=0,zA=0,QA=0,fe=0,he=0,Ee=0,ne=0,HA=0,SA=0,ve=0,Ve=0,de=0,We=0,Tt=0,mi=0;if(Ve=k,k=k+64|0,ne=Ve+48|0,HA=Ve+32|0,SA=Ve+24|0,BA=Ve+8|0,zA=Ve,a=t[e>>2]|0,(a|0)<=0)return ve=0,k=Ve,ve|0;for(QA=e+4|0,fe=ne+8|0,he=HA+8|0,Ee=BA+8|0,l=0,$=0;;){f=t[QA>>2]|0,q=f+($<<4)|0,t[ne>>2]=t[q>>2],t[ne+4>>2]=t[q+4>>2],t[ne+8>>2]=t[q+8>>2],t[ne+12>>2]=t[q+12>>2],($|0)==(a+-1|0)?(t[HA>>2]=t[f>>2],t[HA+4>>2]=t[f+4>>2],t[HA+8>>2]=t[f+8>>2],t[HA+12>>2]=t[f+12>>2]):(q=f+($+1<<4)|0,t[HA>>2]=t[q>>2],t[HA+4>>2]=t[q+4>>2],t[HA+8>>2]=t[q+8>>2],t[HA+12>>2]=t[q+12>>2]),a=FA(ne,HA,n,SA)|0;A:do if(a)f=0,l=a;else if(a=SA,f=t[a>>2]|0,a=t[a+4>>2]|0,(a|0)>0|(a|0)==0&f>>>0>0){nA=0,q=0;e:for(;;){if(We=1/(+(f>>>0)+4294967296*+(a|0)),mi=+b[ne>>3],a=ct(f|0,a|0,nA|0,q|0)|0,Tt=+(a>>>0)+4294967296*+(S()|0),de=+(nA>>>0)+4294967296*+(q|0),b[BA>>3]=We*(mi*Tt)+We*(+b[HA>>3]*de),b[Ee>>3]=We*(+b[fe>>3]*Tt)+We*(+b[he>>3]*de),a=$n(BA,n,zA)|0,a|0){l=a;break}W=zA,G=t[W>>2]|0,W=t[W+4>>2]|0,j=jr(G|0,W|0,A|0,r|0)|0,m=S()|0,a=s+(j<<3)|0,M=a,f=t[M>>2]|0,M=t[M+4>>2]|0;t:do if((f|0)==0&(M|0)==0)U=a,ve=16;else for(I=0,L=0;;){if((I|0)>(r|0)|(I|0)==(r|0)&L>>>0>A>>>0){l=1;break e}if((f|0)==(G|0)&(M|0)==(W|0))break t;if(a=KA(j|0,m|0,1,0)|0,j=Rr(a|0,S()|0,A|0,r|0)|0,m=S()|0,L=KA(L|0,I|0,1,0)|0,I=S()|0,a=s+(j<<3)|0,M=a,f=t[M>>2]|0,M=t[M+4>>2]|0,(f|0)==0&(M|0)==0){U=a,ve=16;break}}while(!1);if((ve|0)==16&&(ve=0,!((G|0)==0&(W|0)==0))&&(L=U,t[L>>2]=G,t[L+4>>2]=W,L=i+(t[o>>2]<<3)|0,t[L>>2]=G,t[L+4>>2]=W,L=o,L=KA(t[L>>2]|0,t[L+4>>2]|0,1,0)|0,G=S()|0,W=o,t[W>>2]=L,t[W+4>>2]=G),nA=KA(nA|0,q|0,1,0)|0,q=S()|0,a=SA,f=t[a>>2]|0,a=t[a+4>>2]|0,!((a|0)>(q|0)|(a|0)==(q|0)&f>>>0>nA>>>0)){f=1;break A}}f=0}else f=1;while(!1);if($=$+1|0,!f){ve=21;break}if(a=t[e>>2]|0,($|0)>=(a|0)){l=0,ve=21;break}}return(ve|0)==21?(k=Ve,l|0):0}function bt(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0,$=0,U=0,BA=0,zA=0,QA=0,fe=0,he=0,Ee=0,ne=0,HA=0,SA=0,ve=0,Ve=0,de=0,We=0,Tt=0;if(Tt=k,k=k+112|0,ve=Tt+80|0,a=Tt+72|0,Ve=Tt,de=Tt+56|0,o=on(r)|0,o|0)return We=o,k=Tt,We|0;if(f=e+8|0,We=p0((t[f>>2]<<5)+32|0)|0,!We)return We=13,k=Tt,We|0;if(ro(e,We),o=on(r)|0,!o){if(HA=e,SA=t[HA+4>>2]|0,o=a,t[o>>2]=t[HA>>2],t[o+4>>2]=SA,ei(a,ve),o=mA(ve,A,Ve)|0,o)HA=0,SA=0;else{if(o=t[a>>2]|0,i=t[f>>2]|0,(i|0)>0){s=t[e+12>>2]|0,r=0;do o=(t[s+(r<<3)>>2]|0)+o|0,r=r+1|0;while((r|0)!=(i|0));r=o}else r=o;o=Ve,i=t[o>>2]|0,o=t[o+4>>2]|0,s=((r|0)<0)<<31>>31,(o|0)<(s|0)|(o|0)==(s|0)&i>>>0>>0?(o=Ve,t[o>>2]=r,t[o+4>>2]=s,o=s):r=i,HA=KA(r|0,o|0,12,0)|0,SA=S()|0,o=Ve,t[o>>2]=HA,t[o+4>>2]=SA,o=0}if(!o){if(r=Qt(HA,8)|0,!r)return qA(We),We=13,k=Tt,We|0;if(l=Qt(HA,8)|0,!l)return qA(We),qA(r),We=13,k=Tt,We|0;Ee=ve,t[Ee>>2]=0,t[Ee+4>>2]=0,Ee=e,ne=t[Ee+4>>2]|0,o=a,t[o>>2]=t[Ee>>2],t[o+4>>2]=ne,o=Ge(a,HA,SA,A,ve,r,l)|0;A:do if(o)qA(r),qA(l),qA(We);else{e:do if((t[f>>2]|0)>0){for(s=e+12|0,i=0;o=Ge((t[s>>2]|0)+(i<<3)|0,HA,SA,A,ve,r,l)|0,i=i+1|0,!(o|0);)if((i|0)>=(t[f>>2]|0))break e;qA(r),qA(l),qA(We);break A}while(!1);(SA|0)>0|(SA|0)==0&HA>>>0>0&&Y0(l|0,0,HA<<3|0)|0,ne=ve,Ee=t[ne+4>>2]|0;e:do if((Ee|0)>0|(Ee|0)==0&(t[ne>>2]|0)>>>0>0){QA=r,fe=l,he=r,Ee=l,ne=r,o=r,U=r,BA=l,zA=l,r=l;t:for(;;){for(W=0,nA=0,q=0,$=0,i=0,s=0;;){l=Ve,a=l+56|0;do t[l>>2]=0,l=l+4|0;while((l|0)<(a|0));if(A=QA+(W<<3)|0,f=t[A>>2]|0,A=t[A+4>>2]|0,F(f,A,1,Ve,0)|0){l=Ve,a=l+56|0;do t[l>>2]=0,l=l+4|0;while((l|0)<(a|0));l=Qt(7,4)|0,l|0&&(X(f,A,1,Ve,l,7,0,0)|0,qA(l))}for(G=0;;){L=Ve+(G<<3)|0,I=t[L>>2]|0,L=t[L+4>>2]|0;r:do if((I|0)==0&(L|0)==0)l=i,a=s;else{if(m=jr(I|0,L|0,HA|0,SA|0)|0,f=S()|0,l=n+(m<<3)|0,A=l,a=t[A>>2]|0,A=t[A+4>>2]|0,!((a|0)==0&(A|0)==0)){M=0,j=0;do{if((M|0)>(SA|0)|(M|0)==(SA|0)&j>>>0>HA>>>0)break t;if((a|0)==(I|0)&(A|0)==(L|0)){l=i,a=s;break r}l=KA(m|0,f|0,1,0)|0,m=Rr(l|0,S()|0,HA|0,SA|0)|0,f=S()|0,j=KA(j|0,M|0,1,0)|0,M=S()|0,l=n+(m<<3)|0,A=l,a=t[A>>2]|0,A=t[A+4>>2]|0}while(!((a|0)==0&(A|0)==0))}if((I|0)==0&(L|0)==0){l=i,a=s;break}ar(I,L,de)|0,no(e,We,de)|0&&(j=KA(i|0,s|0,1,0)|0,s=S()|0,M=l,t[M>>2]=I,t[M+4>>2]=L,i=fe+(i<<3)|0,t[i>>2]=I,t[i+4>>2]=L,i=j),l=i,a=s}while(!1);if(G=G+1|0,G>>>0>=7)break;i=l,s=a}if(W=KA(W|0,nA|0,1,0)|0,nA=S()|0,q=KA(q|0,$|0,1,0)|0,$=S()|0,s=ve,i=t[s>>2]|0,s=t[s+4>>2]|0,($|0)<(s|0)|($|0)==(s|0)&q>>>0>>0)i=l,s=a;else break}if((s|0)>0|(s|0)==0&i>>>0>0){i=0,s=0;do $=QA+(i<<3)|0,t[$>>2]=0,t[$+4>>2]=0,i=KA(i|0,s|0,1,0)|0,s=S()|0,$=ve,q=t[$+4>>2]|0;while((s|0)<(q|0)|((s|0)==(q|0)?i>>>0<(t[$>>2]|0)>>>0:0))}if($=ve,t[$>>2]=l,t[$+4>>2]=a,(a|0)>0|(a|0)==0&l>>>0>0)G=r,W=zA,nA=ne,q=BA,$=fe,r=U,zA=o,BA=he,U=G,o=W,ne=Ee,Ee=nA,he=q,fe=QA,QA=$;else break e}qA(he),qA(Ee),qA(We),o=1;break A}else o=l;while(!1);qA(We),qA(r),qA(o),o=0}while(!1);return We=o,k=Tt,We|0}}return qA(We),We=o,k=Tt,We|0}function Ct(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0;if(m=k,k=k+176|0,a=m,(A|0)<1)return si(r,0,0),f=0,k=m,f|0;for(l=e,l=wA(t[l>>2]|0,t[l+4>>2]|0,52)|0,S()|0,si(r,(A|0)>6?A:6,l&15),l=0;n=e+(l<<3)|0,n=_r(t[n>>2]|0,t[n+4>>2]|0,a)|0,!(n|0);){if(n=t[a>>2]|0,(n|0)>0){s=0;do i=a+8+(s<<4)|0,s=s+1|0,n=a+8+(((s|0)%(n|0)|0)<<4)|0,o=Jl(r,n,i)|0,o?ui(r,o)|0:ql(r,i,n)|0,n=t[a>>2]|0;while((s|0)<(n|0))}if(l=l+1|0,(l|0)>=(A|0)){n=0,f=13;break}}return(f|0)==13?(k=m,n|0):(li(r),f=n,k=m,f|0)}function pt(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0;if(i=k,k=k+32|0,n=i,o=i+16|0,e=Ct(e,A,o)|0,e|0)return r=e,k=i,r|0;if(t[r>>2]=0,t[r+4>>2]=0,t[r+8>>2]=0,e=ai(o)|0,e|0)do{A=Ml(r)|0;do Bl(A,e)|0,s=e+16|0,t[n>>2]=t[s>>2],t[n+4>>2]=t[s+4>>2],t[n+8>>2]=t[s+8>>2],t[n+12>>2]=t[s+12>>2],ui(o,e)|0,e=Xl(o,n)|0;while((e|0)!=0);e=ai(o)|0}while((e|0)!=0);return li(o),e=Dl(r)|0,e?(qo(r),s=e,k=i,s|0):(s=0,k=i,s|0)}function Re(e){return e=e|0,e>>>0>121?(e=0,e|0):(e=t[7696+(e*28|0)+16>>2]|0,e|0)}function Et(e){return e=e|0,(e|0)==4|(e|0)==117|0}function m0(e){return e=e|0,t[11120+((t[e>>2]|0)*216|0)+((t[e+4>>2]|0)*72|0)+((t[e+8>>2]|0)*24|0)+(t[e+12>>2]<<3)>>2]|0}function l0(e){return e=e|0,t[11120+((t[e>>2]|0)*216|0)+((t[e+4>>2]|0)*72|0)+((t[e+8>>2]|0)*24|0)+(t[e+12>>2]<<3)+4>>2]|0}function H0(e,A){e=e|0,A=A|0,e=7696+(e*28|0)|0,t[A>>2]=t[e>>2],t[A+4>>2]=t[e+4>>2],t[A+8>>2]=t[e+8>>2],t[A+12>>2]=t[e+12>>2]}function qt(e,A){e=e|0,A=A|0;var r=0,n=0;if(A>>>0>20)return A=-1,A|0;do if((t[11120+(A*216|0)>>2]|0)!=(e|0))if((t[11120+(A*216|0)+8>>2]|0)!=(e|0))if((t[11120+(A*216|0)+16>>2]|0)!=(e|0))if((t[11120+(A*216|0)+24>>2]|0)!=(e|0))if((t[11120+(A*216|0)+32>>2]|0)!=(e|0))if((t[11120+(A*216|0)+40>>2]|0)!=(e|0))if((t[11120+(A*216|0)+48>>2]|0)!=(e|0))if((t[11120+(A*216|0)+56>>2]|0)!=(e|0))if((t[11120+(A*216|0)+64>>2]|0)!=(e|0))if((t[11120+(A*216|0)+72>>2]|0)!=(e|0))if((t[11120+(A*216|0)+80>>2]|0)!=(e|0))if((t[11120+(A*216|0)+88>>2]|0)!=(e|0))if((t[11120+(A*216|0)+96>>2]|0)!=(e|0))if((t[11120+(A*216|0)+104>>2]|0)!=(e|0))if((t[11120+(A*216|0)+112>>2]|0)!=(e|0))if((t[11120+(A*216|0)+120>>2]|0)!=(e|0))if((t[11120+(A*216|0)+128>>2]|0)!=(e|0))if((t[11120+(A*216|0)+136>>2]|0)==(e|0))e=2,r=1,n=2;else{if((t[11120+(A*216|0)+144>>2]|0)==(e|0)){e=0,r=2,n=0;break}if((t[11120+(A*216|0)+152>>2]|0)==(e|0)){e=0,r=2,n=1;break}if((t[11120+(A*216|0)+160>>2]|0)==(e|0)){e=0,r=2,n=2;break}if((t[11120+(A*216|0)+168>>2]|0)==(e|0)){e=1,r=2,n=0;break}if((t[11120+(A*216|0)+176>>2]|0)==(e|0)){e=1,r=2,n=1;break}if((t[11120+(A*216|0)+184>>2]|0)==(e|0)){e=1,r=2,n=2;break}if((t[11120+(A*216|0)+192>>2]|0)==(e|0)){e=2,r=2,n=0;break}if((t[11120+(A*216|0)+200>>2]|0)==(e|0)){e=2,r=2,n=1;break}if((t[11120+(A*216|0)+208>>2]|0)==(e|0)){e=2,r=2,n=2;break}else e=-1;return e|0}else e=2,r=1,n=1;else e=2,r=1,n=0;else e=1,r=1,n=2;else e=1,r=1,n=1;else e=1,r=1,n=0;else e=0,r=1,n=2;else e=0,r=1,n=1;else e=0,r=1,n=0;else e=2,r=0,n=2;else e=2,r=0,n=1;else e=2,r=0,n=0;else e=1,r=0,n=2;else e=1,r=0,n=1;else e=1,r=0,n=0;else e=0,r=0,n=2;else e=0,r=0,n=1;else e=0,r=0,n=0;while(!1);return A=t[11120+(A*216|0)+(r*72|0)+(e*24|0)+(n<<3)+4>>2]|0,A|0}function S0(e,A){return e=e|0,A=A|0,(t[7696+(e*28|0)+20>>2]|0)==(A|0)?(A=1,A|0):(A=(t[7696+(e*28|0)+24>>2]|0)==(A|0),A|0)}function nr(e,A){return e=e|0,A=A|0,t[848+(e*28|0)+(A<<2)>>2]|0}function or(e,A){return e=e|0,A=A|0,(t[848+(e*28|0)>>2]|0)==(A|0)?(A=0,A|0):(t[848+(e*28|0)+4>>2]|0)==(A|0)?(A=1,A|0):(t[848+(e*28|0)+8>>2]|0)==(A|0)?(A=2,A|0):(t[848+(e*28|0)+12>>2]|0)==(A|0)?(A=3,A|0):(t[848+(e*28|0)+16>>2]|0)==(A|0)?(A=4,A|0):(t[848+(e*28|0)+20>>2]|0)==(A|0)?(A=5,A|0):((t[848+(e*28|0)+24>>2]|0)==(A|0)?6:7)|0}function Vr(){return 122}function Wr(e){e=e|0;var A=0,r=0,n=0;A=0;do EA(A|0,0,45)|0,n=S()|0|134225919,r=e+(A<<3)|0,t[r>>2]=-1,t[r+4>>2]=n,A=A+1|0;while((A|0)!=122);return 0}function Yr(e){e=e|0;var A=0,r=0,n=0;return n=+b[e+16>>3],r=+b[e+24>>3],A=n-r,+(n>3]<+b[e+24>>3]|0}function ir(e){return e=e|0,+(+b[e>>3]-+b[e+8>>3])}function a0(e,A){e=e|0,A=A|0;var r=0,n=0,o=0;return r=+b[A>>3],!(r>=+b[e+8>>3])||!(r<=+b[e>>3])?(A=0,A|0):(n=+b[e+16>>3],r=+b[e+24>>3],o=+b[A+8>>3],A=o>=r,e=o<=n&1,n>3]<+b[A+8>>3]||+b[e+8>>3]>+b[A>>3]?(n=0,n|0):(i=+b[e+16>>3],r=e+24|0,m=+b[r>>3],s=i>3],o=A+24|0,a=+b[o>>3],l=f>3],A)||(m=+Vt(+b[r>>3],e),m>+Vt(+b[n>>3],A))?(l=0,l|0):(l=1,l|0))}function M0(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0;i=+b[e+16>>3],a=+b[e+24>>3],e=i>3],s=+b[A+24>>3],o=l>2]=e?o|A?1:2:0,t[n>>2]=o?e?1:A?2:1:0}function z(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0;return+b[e>>3]<+b[A>>3]||+b[e+8>>3]>+b[A+8>>3]?(n=0,n|0):(n=e+16|0,a=+b[n>>3],i=+b[e+24>>3],s=a>3],o=A+24|0,f=+b[o>>3],l=m>3],A)?(m=+Vt(+b[n>>3],e),l=m>=+Vt(+b[r>>3],A),l|0):(l=0,l|0))}function lA(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0,l=0;o=k,k=k+176|0,n=o,t[n>>2]=4,l=+b[A>>3],b[n+8>>3]=l,i=+b[A+16>>3],b[n+16>>3]=i,b[n+24>>3]=l,l=+b[A+24>>3],b[n+32>>3]=l,s=+b[A+8>>3],b[n+40>>3]=s,b[n+48>>3]=l,b[n+56>>3]=s,b[n+64>>3]=i,A=n+72|0,r=A+96|0;do t[A>>2]=0,A=A+4|0;while((A|0)<(r|0));Ir(e|0,n|0,168)|0,k=o}function mA(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0;L=k,k=k+288|0,m=L+264|0,M=L+96|0,f=L,l=f,a=l+96|0;do t[l>>2]=0,l=l+4|0;while((l|0)<(a|0));return A=Jn(A,f)|0,A|0?(I=A,k=L,I|0):(a=f,f=t[a>>2]|0,a=t[a+4>>2]|0,ar(f,a,m)|0,_r(f,a,M)|0,s=+rn(m,M+8|0),b[m>>3]=+b[e>>3],a=m+8|0,b[a>>3]=+b[e+16>>3],b[M>>3]=+b[e+8>>3],f=M+8|0,b[f>>3]=+b[e+24>>3],o=+rn(m,M),W=+b[a>>3]-+b[f>>3],i=+$A(+W),G=+b[m>>3]-+b[M>>3],n=+$A(+G),!(W==0|G==0)&&(W=+hi(+i,+n),W=+gt(+(o*o/+Cn(+(W/+Cn(+i,+n)),3)/(s*(s*2.59807621135)*.8))),b[ge>>3]=W,j=~~W>>>0,I=+$A(W)>=1?W>0?~~+At(+He(W/4294967296),4294967295)>>>0:~~+gt((W-+(~~W>>>0))/4294967296)>>>0:0,(t[ge+4>>2]&2146435072|0)!=2146435072)?(M=(j|0)==0&(I|0)==0,A=r,t[A>>2]=M?1:j,t[A+4>>2]=M?0:I,A=0):A=1,I=A,k=L,I|0)}function FA(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0;f=k,k=k+288|0,s=f+264|0,l=f+96|0,a=f,o=a,i=o+96|0;do t[o>>2]=0,o=o+4|0;while((o|0)<(i|0));return r=Jn(r,a)|0,r|0?(n=r,k=f,n|0):(r=a,o=t[r>>2]|0,r=t[r+4>>2]|0,ar(o,r,s)|0,_r(o,r,l)|0,m=+rn(s,l+8|0),m=+gt(+(+rn(e,A)/(m*2))),b[ge>>3]=m,r=~~m>>>0,o=+$A(m)>=1?m>0?~~+At(+He(m/4294967296),4294967295)>>>0:~~+gt((m-+(~~m>>>0))/4294967296)>>>0:0,(t[ge+4>>2]&2146435072|0)==2146435072?(n=1,k=f,n|0):(a=(r|0)==0&(o|0)==0,t[n>>2]=a?1:r,t[n+4>>2]=a?0:o,n=0,k=f,n|0))}function VA(e,A){e=e|0,A=+A;var r=0,n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0;i=e+16|0,s=+b[i>>3],r=e+24|0,o=+b[r>>3],n=s-o,n=s>3],l=e+8|0,a=+b[l>>3],m=f-a,n=(n*A-n)*.5,A=(m*A-m)*.5,f=f+A,b[e>>3]=f>1.5707963267948966?1.5707963267948966:f,A=a-A,b[l>>3]=A<-1.5707963267948966?-1.5707963267948966:A,A=s+n,A=A>3.141592653589793?A+-6.283185307179586:A,b[i>>3]=A<-3.141592653589793?A+6.283185307179586:A,A=o-n,A=A>3.141592653589793?A+-6.283185307179586:A,b[r>>3]=A<-3.141592653589793?A+6.283185307179586:A}function xe(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0,t[e>>2]=A,t[e+4>>2]=r,t[e+8>>2]=n}function tt(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0;M=A+8|0,t[M>>2]=0,a=+b[e>>3],s=+$A(+a),f=+b[e+8>>3],l=+$A(+f)*1.1547005383792515,s=s+l*.5,r=~~s,e=~~l,s=s-+(r|0),l=l-+(e|0);do if(s<.5)if(s<.3333333333333333)if(t[A>>2]=r,l<(s+1)*.5){t[A+4>>2]=e;break}else{e=e+1|0,t[A+4>>2]=e;break}else if(j=1-s,e=(!(l>2]=e,j<=l&l>2]=r;break}else{t[A>>2]=r;break}else{if(!(s<.6666666666666666))if(r=r+1|0,t[A>>2]=r,l>2]=e;break}else{e=e+1|0,t[A+4>>2]=e;break}if(l<1-s){if(t[A+4>>2]=e,s*2+-1>2]=r;break}}else e=e+1|0,t[A+4>>2]=e;r=r+1|0,t[A>>2]=r}while(!1);do if(a<0)if(e&1){m=(e+1|0)/2|0,m=ct(r|0,((r|0)<0)<<31>>31|0,m|0,((m|0)<0)<<31>>31|0)|0,r=~~(+(r|0)-((+(m>>>0)+4294967296*+(S()|0))*2+1)),t[A>>2]=r;break}else{m=(e|0)/2|0,m=ct(r|0,((r|0)<0)<<31>>31|0,m|0,((m|0)<0)<<31>>31|0)|0,r=~~(+(r|0)-(+(m>>>0)+4294967296*+(S()|0))*2),t[A>>2]=r;break}while(!1);m=A+4|0,f<0&&(r=r-((e<<1|1|0)/2|0)|0,t[A>>2]=r,e=0-e|0,t[m>>2]=e),n=e-r|0,(r|0)<0?(o=0-r|0,t[m>>2]=n,t[M>>2]=o,t[A>>2]=0,e=n,r=0):o=0,(e|0)<0&&(r=r-e|0,t[A>>2]=r,o=o-e|0,t[M>>2]=o,t[m>>2]=0,e=0),i=r-o|0,n=e-o|0,(o|0)<0&&(t[A>>2]=i,t[m>>2]=n,t[M>>2]=0,e=n,r=i,o=0),n=(e|0)<(r|0)?e:r,n=(o|0)<(n|0)?o:n,!((n|0)<=0)&&(t[A>>2]=r-n,t[m>>2]=e-n,t[M>>2]=o-n)}function Me(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0;A=t[e>>2]|0,s=e+4|0,r=t[s>>2]|0,(A|0)<0&&(r=r-A|0,t[s>>2]=r,i=e+8|0,t[i>>2]=(t[i>>2]|0)-A,t[e>>2]=0,A=0),(r|0)<0?(A=A-r|0,t[e>>2]=A,i=e+8|0,o=(t[i>>2]|0)-r|0,t[i>>2]=o,t[s>>2]=0,r=0):(o=e+8|0,i=o,o=t[o>>2]|0),(o|0)<0&&(A=A-o|0,t[e>>2]=A,r=r-o|0,t[s>>2]=r,t[i>>2]=0,o=0),n=(r|0)<(A|0)?r:A,n=(o|0)<(n|0)?o:n,!((n|0)<=0)&&(t[e>>2]=A-n,t[s>>2]=r-n,t[i>>2]=o-n)}function ut(e,A){e=e|0,A=A|0;var r=0,n=0;n=t[e+8>>2]|0,r=+((t[e+4>>2]|0)-n|0),b[A>>3]=+((t[e>>2]|0)-n|0)-r*.5,b[A+8>>3]=r*.8660254037844386}function Ze(e,A,r){e=e|0,A=A|0,r=r|0,t[r>>2]=(t[A>>2]|0)+(t[e>>2]|0),t[r+4>>2]=(t[A+4>>2]|0)+(t[e+4>>2]|0),t[r+8>>2]=(t[A+8>>2]|0)+(t[e+8>>2]|0)}function yt(e,A,r){e=e|0,A=A|0,r=r|0,t[r>>2]=(t[e>>2]|0)-(t[A>>2]|0),t[r+4>>2]=(t[e+4>>2]|0)-(t[A+4>>2]|0),t[r+8>>2]=(t[e+8>>2]|0)-(t[A+8>>2]|0)}function ot(e,A){e=e|0,A=A|0;var r=0,n=0;r=Pe(t[e>>2]|0,A)|0,t[e>>2]=r,r=e+4|0,n=Pe(t[r>>2]|0,A)|0,t[r>>2]=n,e=e+8|0,A=Pe(t[e>>2]|0,A)|0,t[e>>2]=A}function St(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0;s=t[e>>2]|0,l=(s|0)<0,n=(t[e+4>>2]|0)-(l?s:0)|0,i=(n|0)<0,o=(i?0-n|0:0)+((t[e+8>>2]|0)-(l?s:0))|0,r=(o|0)<0,e=r?0:o,A=(i?0:n)-(r?o:0)|0,o=(l?0:s)-(i?n:0)-(r?o:0)|0,r=(A|0)<(o|0)?A:o,r=(e|0)<(r|0)?e:r,n=(r|0)>0,e=e-(n?r:0)|0,A=A-(n?r:0)|0;A:do switch(o-(n?r:0)|0){case 0:switch(A|0){case 0:return l=(e|0)==0?0:(e|0)==1?1:7,l|0;case 1:return l=(e|0)==0?2:(e|0)==1?3:7,l|0;default:break A}case 1:switch(A|0){case 0:return l=(e|0)==0?4:(e|0)==1?5:7,l|0;case 1:{if(!e)e=6;else break A;return e|0}default:break A}}while(!1);return l=7,l|0}function wr(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0,a=0,f=0;if(a=e+8|0,s=t[a>>2]|0,l=(t[e>>2]|0)-s|0,f=e+4|0,s=(t[f>>2]|0)-s|0,l>>>0>715827881|s>>>0>715827881){if(n=(l|0)>0,o=2147483647-l|0,i=-2147483648-l|0,(n?(o|0)<(l|0):(i|0)>(l|0))||(r=l<<1,n?(2147483647-r|0)<(l|0):(-2147483648-r|0)>(l|0))||((s|0)>0?(2147483647-s|0)<(s|0):(-2147483648-s|0)>(s|0))||(A=l*3|0,r=s<<1,(n?(o|0)<(r|0):(i|0)>(r|0))||((l|0)>-1?(A|-2147483648|0)>=(s|0):(A^-2147483648|0)<(s|0))))return f=1,f|0}else r=s<<1,A=l*3|0;return n=V0(+(A-s|0)*.14285714285714285)|0,t[e>>2]=n,o=V0(+(r+l|0)*.14285714285714285)|0,t[f>>2]=o,t[a>>2]=0,r=(o|0)<(n|0),A=r?n:o,r=r?o:n,(r|0)<0&&(((r|0)==-2147483648||((A|0)>0?(2147483647-A|0)<(r|0):(-2147483648-A|0)>(r|0)))&&OA(27795,26892,354,26903),((A|0)>-1?(A|-2147483648|0)>=(r|0):(A^-2147483648|0)<(r|0))&&OA(27795,26892,354,26903)),A=o-n|0,(n|0)<0?(r=0-n|0,t[f>>2]=A,t[a>>2]=r,t[e>>2]=0,n=0):(A=o,r=0),(A|0)<0&&(n=n-A|0,t[e>>2]=n,r=r-A|0,t[a>>2]=r,t[f>>2]=0,A=0),i=n-r|0,o=A-r|0,(r|0)<0?(t[e>>2]=i,t[f>>2]=o,t[a>>2]=0,A=o,o=i,r=0):o=n,n=(A|0)<(o|0)?A:o,n=(r|0)<(n|0)?r:n,(n|0)<=0?(f=0,f|0):(t[e>>2]=o-n,t[f>>2]=A-n,t[a>>2]=r-n,f=0,f|0)}function mn(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0,a=0;if(s=e+8|0,o=t[s>>2]|0,i=(t[e>>2]|0)-o|0,l=e+4|0,o=(t[l>>2]|0)-o|0,i>>>0>715827881|o>>>0>715827881){if(r=(i|0)>0,(r?(2147483647-i|0)<(i|0):(-2147483648-i|0)>(i|0))||(A=i<<1,n=(o|0)>0,n?(2147483647-o|0)<(o|0):(-2147483648-o|0)>(o|0)))return l=1,l|0;if(a=o<<1,(n?(2147483647-a|0)<(o|0):(-2147483648-a|0)>(o|0))||(r?(2147483647-A|0)<(o|0):(-2147483648-A|0)>(o|0))||(r=o*3|0,(o|0)>-1?(r|-2147483648|0)>=(i|0):(r^-2147483648|0)<(i|0)))return a=1,a|0}else r=o*3|0,A=i<<1;return n=V0(+(A+o|0)*.14285714285714285)|0,t[e>>2]=n,o=V0(+(r-i|0)*.14285714285714285)|0,t[l>>2]=o,t[s>>2]=0,r=(o|0)<(n|0),A=r?n:o,r=r?o:n,(r|0)<0&&(((r|0)==-2147483648||((A|0)>0?(2147483647-A|0)<(r|0):(-2147483648-A|0)>(r|0)))&&OA(27795,26892,402,26917),((A|0)>-1?(A|-2147483648|0)>=(r|0):(A^-2147483648|0)<(r|0))&&OA(27795,26892,402,26917)),A=o-n|0,(n|0)<0?(r=0-n|0,t[l>>2]=A,t[s>>2]=r,t[e>>2]=0,n=0):(A=o,r=0),(A|0)<0&&(n=n-A|0,t[e>>2]=n,r=r-A|0,t[s>>2]=r,t[l>>2]=0,A=0),i=n-r|0,o=A-r|0,(r|0)<0?(t[e>>2]=i,t[l>>2]=o,t[s>>2]=0,A=o,o=i,r=0):o=n,n=(A|0)<(o|0)?A:o,n=(r|0)<(n|0)?r:n,(n|0)<=0?(a=0,a|0):(t[e>>2]=o-n,t[l>>2]=A-n,t[s>>2]=r-n,a=0,a|0)}function vr(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0;s=e+8|0,r=t[s>>2]|0,A=(t[e>>2]|0)-r|0,l=e+4|0,r=(t[l>>2]|0)-r|0,n=V0(+((A*3|0)-r|0)*.14285714285714285)|0,t[e>>2]=n,A=V0(+((r<<1)+A|0)*.14285714285714285)|0,t[l>>2]=A,t[s>>2]=0,r=A-n|0,(n|0)<0?(i=0-n|0,t[l>>2]=r,t[s>>2]=i,t[e>>2]=0,A=r,n=0,r=i):r=0,(A|0)<0&&(n=n-A|0,t[e>>2]=n,r=r-A|0,t[s>>2]=r,t[l>>2]=0,A=0),i=n-r|0,o=A-r|0,(r|0)<0?(t[e>>2]=i,t[l>>2]=o,t[s>>2]=0,A=o,o=i,r=0):o=n,n=(A|0)<(o|0)?A:o,n=(r|0)<(n|0)?r:n,!((n|0)<=0)&&(t[e>>2]=o-n,t[l>>2]=A-n,t[s>>2]=r-n)}function kr(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0;s=e+8|0,r=t[s>>2]|0,A=(t[e>>2]|0)-r|0,l=e+4|0,r=(t[l>>2]|0)-r|0,n=V0(+((A<<1)+r|0)*.14285714285714285)|0,t[e>>2]=n,A=V0(+((r*3|0)-A|0)*.14285714285714285)|0,t[l>>2]=A,t[s>>2]=0,r=A-n|0,(n|0)<0?(i=0-n|0,t[l>>2]=r,t[s>>2]=i,t[e>>2]=0,A=r,n=0,r=i):r=0,(A|0)<0&&(n=n-A|0,t[e>>2]=n,r=r-A|0,t[s>>2]=r,t[l>>2]=0,A=0),i=n-r|0,o=A-r|0,(r|0)<0?(t[e>>2]=i,t[l>>2]=o,t[s>>2]=0,A=o,o=i,r=0):o=n,n=(A|0)<(o|0)?A:o,n=(r|0)<(n|0)?r:n,!((n|0)<=0)&&(t[e>>2]=o-n,t[l>>2]=A-n,t[s>>2]=r-n)}function br(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0;A=t[e>>2]|0,s=e+4|0,r=t[s>>2]|0,l=e+8|0,n=t[l>>2]|0,o=r+(A*3|0)|0,t[e>>2]=o,r=n+(r*3|0)|0,t[s>>2]=r,A=(n*3|0)+A|0,t[l>>2]=A,n=r-o|0,(o|0)<0?(A=A-o|0,t[s>>2]=n,t[l>>2]=A,t[e>>2]=0,r=n,n=0):n=o,(r|0)<0&&(n=n-r|0,t[e>>2]=n,A=A-r|0,t[l>>2]=A,t[s>>2]=0,r=0),i=n-A|0,o=r-A|0,(A|0)<0?(t[e>>2]=i,t[s>>2]=o,t[l>>2]=0,n=i,A=0):o=r,r=(o|0)<(n|0)?o:n,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=n-r,t[s>>2]=o-r,t[l>>2]=A-r)}function Ht(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0;o=t[e>>2]|0,s=e+4|0,A=t[s>>2]|0,l=e+8|0,r=t[l>>2]|0,n=(A*3|0)+o|0,o=r+(o*3|0)|0,t[e>>2]=o,t[s>>2]=n,A=(r*3|0)+A|0,t[l>>2]=A,r=n-o|0,(o|0)<0?(A=A-o|0,t[s>>2]=r,t[l>>2]=A,t[e>>2]=0,o=0):r=n,(r|0)<0&&(o=o-r|0,t[e>>2]=o,A=A-r|0,t[l>>2]=A,t[s>>2]=0,r=0),i=o-A|0,n=r-A|0,(A|0)<0?(t[e>>2]=i,t[s>>2]=n,t[l>>2]=0,o=i,A=0):n=r,r=(n|0)<(o|0)?n:o,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=o-r,t[s>>2]=n-r,t[l>>2]=A-r)}function gn(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0,l=0;(A+-1|0)>>>0>=6||(o=(t[15440+(A*12|0)>>2]|0)+(t[e>>2]|0)|0,t[e>>2]=o,l=e+4|0,n=(t[15440+(A*12|0)+4>>2]|0)+(t[l>>2]|0)|0,t[l>>2]=n,s=e+8|0,A=(t[15440+(A*12|0)+8>>2]|0)+(t[s>>2]|0)|0,t[s>>2]=A,r=n-o|0,(o|0)<0?(A=A-o|0,t[l>>2]=r,t[s>>2]=A,t[e>>2]=0,n=0):(r=n,n=o),(r|0)<0&&(n=n-r|0,t[e>>2]=n,A=A-r|0,t[s>>2]=A,t[l>>2]=0,r=0),i=n-A|0,o=r-A|0,(A|0)<0?(t[e>>2]=i,t[l>>2]=o,t[s>>2]=0,n=i,A=0):o=r,r=(o|0)<(n|0)?o:n,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=n-r,t[l>>2]=o-r,t[s>>2]=A-r))}function Cr(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0;o=t[e>>2]|0,s=e+4|0,A=t[s>>2]|0,l=e+8|0,r=t[l>>2]|0,n=A+o|0,o=r+o|0,t[e>>2]=o,t[s>>2]=n,A=r+A|0,t[l>>2]=A,r=n-o|0,(o|0)<0?(A=A-o|0,t[s>>2]=r,t[l>>2]=A,t[e>>2]=0,n=0):(r=n,n=o),(r|0)<0&&(n=n-r|0,t[e>>2]=n,A=A-r|0,t[l>>2]=A,t[s>>2]=0,r=0),i=n-A|0,o=r-A|0,(A|0)<0?(t[e>>2]=i,t[s>>2]=o,t[l>>2]=0,n=i,A=0):o=r,r=(o|0)<(n|0)?o:n,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=n-r,t[s>>2]=o-r,t[l>>2]=A-r)}function B0(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0;A=t[e>>2]|0,s=e+4|0,n=t[s>>2]|0,l=e+8|0,r=t[l>>2]|0,o=n+A|0,t[e>>2]=o,n=r+n|0,t[s>>2]=n,A=r+A|0,t[l>>2]=A,r=n-o|0,(o|0)<0?(A=A-o|0,t[s>>2]=r,t[l>>2]=A,t[e>>2]=0,n=0):(r=n,n=o),(r|0)<0&&(n=n-r|0,t[e>>2]=n,A=A-r|0,t[l>>2]=A,t[s>>2]=0,r=0),i=n-A|0,o=r-A|0,(A|0)<0?(t[e>>2]=i,t[s>>2]=o,t[l>>2]=0,n=i,A=0):o=r,r=(o|0)<(n|0)?o:n,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=n-r,t[s>>2]=o-r,t[l>>2]=A-r)}function Gt(e){switch(e=e|0,e|0){case 1:{e=5;break}case 5:{e=4;break}case 4:{e=6;break}case 6:{e=2;break}case 2:{e=3;break}case 3:{e=1;break}}return e|0}function Ut(e){switch(e=e|0,e|0){case 1:{e=3;break}case 3:{e=2;break}case 2:{e=6;break}case 6:{e=4;break}case 4:{e=5;break}case 5:{e=1;break}}return e|0}function Kr(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0;A=t[e>>2]|0,s=e+4|0,r=t[s>>2]|0,l=e+8|0,n=t[l>>2]|0,o=r+(A<<1)|0,t[e>>2]=o,r=n+(r<<1)|0,t[s>>2]=r,A=(n<<1)+A|0,t[l>>2]=A,n=r-o|0,(o|0)<0?(A=A-o|0,t[s>>2]=n,t[l>>2]=A,t[e>>2]=0,r=n,n=0):n=o,(r|0)<0&&(n=n-r|0,t[e>>2]=n,A=A-r|0,t[l>>2]=A,t[s>>2]=0,r=0),i=n-A|0,o=r-A|0,(A|0)<0?(t[e>>2]=i,t[s>>2]=o,t[l>>2]=0,n=i,A=0):o=r,r=(o|0)<(n|0)?o:n,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=n-r,t[s>>2]=o-r,t[l>>2]=A-r)}function Zr(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0;o=t[e>>2]|0,s=e+4|0,A=t[s>>2]|0,l=e+8|0,r=t[l>>2]|0,n=(A<<1)+o|0,o=r+(o<<1)|0,t[e>>2]=o,t[s>>2]=n,A=(r<<1)+A|0,t[l>>2]=A,r=n-o|0,(o|0)<0?(A=A-o|0,t[s>>2]=r,t[l>>2]=A,t[e>>2]=0,o=0):r=n,(r|0)<0&&(o=o-r|0,t[e>>2]=o,A=A-r|0,t[l>>2]=A,t[s>>2]=0,r=0),i=o-A|0,n=r-A|0,(A|0)<0?(t[e>>2]=i,t[s>>2]=n,t[l>>2]=0,o=i,A=0):n=r,r=(n|0)<(o|0)?n:o,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=o-r,t[s>>2]=n-r,t[l>>2]=A-r)}function Er(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0,l=0;return s=(t[e>>2]|0)-(t[A>>2]|0)|0,l=(s|0)<0,n=(t[e+4>>2]|0)-(t[A+4>>2]|0)-(l?s:0)|0,i=(n|0)<0,o=(l?0-s|0:0)+(t[e+8>>2]|0)-(t[A+8>>2]|0)+(i?0-n|0:0)|0,e=(o|0)<0,A=e?0:o,r=(i?0:n)-(e?o:0)|0,o=(l?0:s)-(i?n:0)-(e?o:0)|0,e=(r|0)<(o|0)?r:o,e=(A|0)<(e|0)?A:e,n=(e|0)>0,A=A-(n?e:0)|0,r=r-(n?e:0)|0,e=o-(n?e:0)|0,e=(e|0)>-1?e:0-e|0,r=(r|0)>-1?r:0-r|0,A=(A|0)>-1?A:0-A|0,A=(r|0)>(A|0)?r:A,((e|0)>(A|0)?e:A)|0}function $r(e,A){e=e|0,A=A|0;var r=0;r=t[e+8>>2]|0,t[A>>2]=(t[e>>2]|0)-r,t[A+4>>2]=(t[e+4>>2]|0)-r}function Mt(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0,l=0;return n=t[e>>2]|0,t[A>>2]=n,o=t[e+4>>2]|0,s=A+4|0,t[s>>2]=o,l=A+8|0,t[l>>2]=0,r=(o|0)<(n|0),e=r?n:o,r=r?o:n,(r|0)<0&&((r|0)==-2147483648||((e|0)>0?(2147483647-e|0)<(r|0):(-2147483648-e|0)>(r|0))||((e|0)>-1?(e|-2147483648|0)>=(r|0):(e^-2147483648|0)<(r|0)))?(A=1,A|0):(e=o-n|0,(n|0)<0?(r=0-n|0,t[s>>2]=e,t[l>>2]=r,t[A>>2]=0,n=0):(e=o,r=0),(e|0)<0&&(n=n-e|0,t[A>>2]=n,r=r-e|0,t[l>>2]=r,t[s>>2]=0,e=0),i=n-r|0,o=e-r|0,(r|0)<0?(t[A>>2]=i,t[s>>2]=o,t[l>>2]=0,e=o,o=i,r=0):o=n,n=(e|0)<(o|0)?e:o,n=(r|0)<(n|0)?r:n,(n|0)<=0?(A=0,A|0):(t[A>>2]=o-n,t[s>>2]=e-n,t[l>>2]=r-n,A=0,A|0))}function qr(e){e=e|0;var A=0,r=0,n=0,o=0;A=e+8|0,o=t[A>>2]|0,r=o-(t[e>>2]|0)|0,t[e>>2]=r,n=e+4|0,e=(t[n>>2]|0)-o|0,t[n>>2]=e,t[A>>2]=0-(e+r)}function Jr(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0;r=t[e>>2]|0,A=0-r|0,t[e>>2]=A,s=e+8|0,t[s>>2]=0,l=e+4|0,n=t[l>>2]|0,o=n+r|0,(r|0)>0?(t[l>>2]=o,t[s>>2]=r,t[e>>2]=0,A=0,n=o):r=0,(n|0)<0?(i=A-n|0,t[e>>2]=i,r=r-n|0,t[s>>2]=r,t[l>>2]=0,o=i-r|0,A=0-r|0,(r|0)<0?(t[e>>2]=o,t[l>>2]=A,t[s>>2]=0,n=A,r=0):(n=0,o=i)):o=A,A=(n|0)<(o|0)?n:o,A=(r|0)<(A|0)?r:A,!((A|0)<=0)&&(t[e>>2]=o-A,t[l>>2]=n-A,t[s>>2]=r-A)}function Yn(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0,a=0,f=0,m=0,M=0;if(M=k,k=k+64|0,m=M,l=M+56|0,!(!0&(A&2013265920|0)==134217728&(!0&(n&2013265920|0)==134217728)))return o=5,k=M,o|0;if((e|0)==(r|0)&(A|0)==(n|0))return t[o>>2]=0,o=0,k=M,o|0;if(s=wA(e|0,A|0,52)|0,S()|0,s=s&15,f=wA(r|0,n|0,52)|0,S()|0,(s|0)!=(f&15|0))return o=12,k=M,o|0;if(i=s+-1|0,s>>>0>1){_t(e,A,i,m)|0,_t(r,n,i,l)|0,f=m,a=t[f>>2]|0,f=t[f+4>>2]|0;A:do if((a|0)==(t[l>>2]|0)&&(f|0)==(t[l+4>>2]|0)){s=(s^15)*3|0,i=wA(e|0,A|0,s|0)|0,S()|0,i=i&7,s=wA(r|0,n|0,s|0)|0,S()|0,s=s&7;do if((i|0)==0|(s|0)==0)t[o>>2]=1,i=0;else if((i|0)==7)i=5;else{if((i|0)==1|(s|0)==1&&Oe(a,f)|0){i=5;break}if((t[15536+(i<<2)>>2]|0)!=(s|0)&&(t[15568+(i<<2)>>2]|0)!=(s|0))break A;t[o>>2]=1,i=0}while(!1);return o=i,k=M,o|0}while(!1)}i=m,s=i+56|0;do t[i>>2]=0,i=i+4|0;while((i|0)<(s|0));return v(e,A,1,m)|0,A=m,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0))&&(A=m+8|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))&&(A=m+16|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))&&(A=m+24|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))&&(A=m+32|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))&&(A=m+40|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))?(i=m+48|0,i=((t[i>>2]|0)==(r|0)?(t[i+4>>2]|0)==(n|0):0)&1):i=1,t[o>>2]=i,o=0,k=M,o|0}function pn(e,A,r,n,o){return e=e|0,A=A|0,r=r|0,n=n|0,o=o|0,r=Ae(e,A,r,n)|0,(r|0)==7?(o=11,o|0):(n=EA(r|0,0,56)|0,A=A&-2130706433|(S()|0)|268435456,t[o>>2]=e|n,t[o+4>>2]=A,o=0,o|0)}function Sr(e,A,r){return e=e|0,A=A|0,r=r|0,!0&(A&2013265920|0)==268435456?(t[r>>2]=e,t[r+4>>2]=A&-2130706433|134217728,r=0,r|0):(r=6,r|0)}function yn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0;return o=k,k=k+16|0,n=o,t[n>>2]=0,!0&(A&2013265920|0)==268435456?(i=wA(e|0,A|0,56)|0,S()|0,n=Y(e,A&-2130706433|134217728,i&7,n,r)|0,k=o,n|0):(n=6,k=o,n|0)}function Xr(e,A){e=e|0,A=A|0;var r=0;switch(r=wA(e|0,A|0,56)|0,S()|0,r&7){case 0:case 7:return r=0,r|0}return r=A&-2130706433|134217728,!(!0&(A&2013265920|0)==268435456)||!0&(A&117440512|0)==16777216&(Oe(e,r)|0)!=0?(r=0,r|0):(r=Ue(e,r)|0,r|0)}function Mr(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0;return o=k,k=k+16|0,n=o,!0&(A&2013265920|0)==268435456?(i=A&-2130706433|134217728,s=r,t[s>>2]=e,t[s+4>>2]=i,t[n>>2]=0,A=wA(e|0,A|0,56)|0,S()|0,n=Y(e,i,A&7,n,r+8|0)|0,k=o,n|0):(n=6,k=o,n|0)}function Br(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0;return o=(Oe(e,A)|0)==0,A=A&-2130706433,n=r,t[n>>2]=o?e:0,t[n+4>>2]=o?A|285212672:0,n=r+8|0,t[n>>2]=e,t[n+4>>2]=A|301989888,n=r+16|0,t[n>>2]=e,t[n+4>>2]=A|318767104,n=r+24|0,t[n>>2]=e,t[n+4>>2]=A|335544320,n=r+32|0,t[n>>2]=e,t[n+4>>2]=A|352321536,r=r+40|0,t[r>>2]=e,t[r+4>>2]=A|369098752,0}function sr(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0;return s=k,k=k+16|0,o=s,i=A&-2130706433|134217728,!0&(A&2013265920|0)==268435456?(n=wA(e|0,A|0,56)|0,S()|0,n=Kl(e,i,n&7)|0,(n|0)==-1?(t[r>>2]=0,i=6,k=s,i|0):(Dr(e,i,o)|0&&OA(27795,26932,282,26947),A=wA(e|0,A|0,52)|0,S()|0,A=A&15,Oe(e,i)|0?w(o,A,n,2,r):AA(o,A,n,2,r),i=0,k=s,i|0)):(i=6,k=s,i|0)}function xn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0;n=k,k=k+16|0,o=n,wn(e,A,r,o),tt(o,r+4|0),k=n}function wn(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0;if(l=k,k=k+16|0,a=l,An(e,r,a),i=+Lt(+(1-+b[a>>3]*.5)),i<1e-16){t[n>>2]=0,t[n+4>>2]=0,t[n+8>>2]=0,t[n+12>>2]=0,k=l;return}if(a=t[r>>2]|0,o=+b[15920+(a*24|0)>>3],o=+tn(o-+tn(+pl(15600+(a<<4)|0,e))),Jt(A)|0?s=+tn(o+-.3334731722518321):s=o,o=+et(+i)*2.618033988749896,(A|0)>0){e=0;do o=o*2.6457513110645907,e=e+1|0;while((e|0)!=(A|0))}i=+_e(+s)*o,b[n>>3]=i,s=+ie(+s)*o,b[n+8>>3]=s,k=l}function An(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0;if(i=k,k=k+32|0,o=i,Yl(e,o),t[A>>2]=0,b[r>>3]=5,n=+it(16400,o),n<+b[r>>3]&&(t[A>>2]=0,b[r>>3]=n),n=+it(16424,o),n<+b[r>>3]&&(t[A>>2]=1,b[r>>3]=n),n=+it(16448,o),n<+b[r>>3]&&(t[A>>2]=2,b[r>>3]=n),n=+it(16472,o),n<+b[r>>3]&&(t[A>>2]=3,b[r>>3]=n),n=+it(16496,o),n<+b[r>>3]&&(t[A>>2]=4,b[r>>3]=n),n=+it(16520,o),n<+b[r>>3]&&(t[A>>2]=5,b[r>>3]=n),n=+it(16544,o),n<+b[r>>3]&&(t[A>>2]=6,b[r>>3]=n),n=+it(16568,o),n<+b[r>>3]&&(t[A>>2]=7,b[r>>3]=n),n=+it(16592,o),n<+b[r>>3]&&(t[A>>2]=8,b[r>>3]=n),n=+it(16616,o),n<+b[r>>3]&&(t[A>>2]=9,b[r>>3]=n),n=+it(16640,o),n<+b[r>>3]&&(t[A>>2]=10,b[r>>3]=n),n=+it(16664,o),n<+b[r>>3]&&(t[A>>2]=11,b[r>>3]=n),n=+it(16688,o),n<+b[r>>3]&&(t[A>>2]=12,b[r>>3]=n),n=+it(16712,o),n<+b[r>>3]&&(t[A>>2]=13,b[r>>3]=n),n=+it(16736,o),n<+b[r>>3]&&(t[A>>2]=14,b[r>>3]=n),n=+it(16760,o),n<+b[r>>3]&&(t[A>>2]=15,b[r>>3]=n),n=+it(16784,o),n<+b[r>>3]&&(t[A>>2]=16,b[r>>3]=n),n=+it(16808,o),n<+b[r>>3]&&(t[A>>2]=17,b[r>>3]=n),n=+it(16832,o),n<+b[r>>3]&&(t[A>>2]=18,b[r>>3]=n),n=+it(16856,o),!(n<+b[r>>3])){k=i;return}t[A>>2]=19,b[r>>3]=n,k=i}function G0(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0;if(i=+Wl(e),i<1e-16){A=15600+(A<<4)|0,t[o>>2]=t[A>>2],t[o+4>>2]=t[A+4>>2],t[o+8>>2]=t[A+8>>2],t[o+12>>2]=t[A+12>>2];return}if(s=+Te(+ +b[e+8>>3],+ +b[e>>3]),(r|0)>0){e=0;do i=i*.37796447300922725,e=e+1|0;while((e|0)!=(r|0))}l=i*.3333333333333333,n?(r=(Jt(r)|0)==0,i=+mt(+((r?l:l*.37796447300922725)*.381966011250105))):(i=+mt(+(i*.381966011250105)),Jt(r)|0&&(s=+tn(s+.3334731722518321))),yl(15600+(A<<4)|0,+tn(+b[15920+(A*24|0)>>3]-s),i,o)}function d(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0;n=k,k=k+16|0,o=n,ut(e+4|0,o),G0(o,t[e>>2]|0,A,0,r),k=n}function w(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0,$=0,U=0,BA=0,zA=0,QA=0,fe=0,he=0,Ee=0,ne=0,HA=0,SA=0,ve=0,Ve=0,de=0;if(ve=k,k=k+272|0,i=ve+256|0,q=ve+240|0,ne=ve,HA=ve+224|0,SA=ve+208|0,$=ve+176|0,U=ve+160|0,BA=ve+192|0,zA=ve+144|0,QA=ve+128|0,fe=ve+112|0,he=ve+96|0,Ee=ve+80|0,t[i>>2]=A,t[q>>2]=t[e>>2],t[q+4>>2]=t[e+4>>2],t[q+8>>2]=t[e+8>>2],t[q+12>>2]=t[e+12>>2],B(q,i,ne),t[o>>2]=0,q=n+r+((n|0)==5&1)|0,(q|0)<=(r|0)){k=ve;return}a=t[i>>2]|0,f=HA+4|0,m=$+4|0,M=r+5|0,j=16880+(a<<2)|0,I=16960+(a<<2)|0,L=QA+8|0,G=fe+8|0,W=he+8|0,nA=SA+4|0,l=r;A:for(;;){s=ne+(((l|0)%5|0)<<4)|0,t[SA>>2]=t[s>>2],t[SA+4>>2]=t[s+4>>2],t[SA+8>>2]=t[s+8>>2],t[SA+12>>2]=t[s+12>>2];do;while((N(SA,a,0,1)|0)==2);if((l|0)>(r|0)&(Jt(A)|0)!=0){if(t[$>>2]=t[SA>>2],t[$+4>>2]=t[SA+4>>2],t[$+8>>2]=t[SA+8>>2],t[$+12>>2]=t[SA+12>>2],ut(f,U),n=t[$>>2]|0,i=t[17040+(n*80|0)+(t[HA>>2]<<2)>>2]|0,t[$>>2]=t[18640+(n*80|0)+(i*20|0)>>2],s=t[18640+(n*80|0)+(i*20|0)+16>>2]|0,(s|0)>0){e=0;do Cr(m),e=e+1|0;while((e|0)<(s|0))}switch(s=18640+(n*80|0)+(i*20|0)+4|0,t[BA>>2]=t[s>>2],t[BA+4>>2]=t[s+4>>2],t[BA+8>>2]=t[s+8>>2],ot(BA,(t[j>>2]|0)*3|0),Ze(m,BA,m),Me(m),ut(m,zA),Ve=+(t[I>>2]|0),b[QA>>3]=Ve*3,b[L>>3]=0,de=Ve*-1.5,b[fe>>3]=de,b[G>>3]=Ve*2.598076211353316,b[he>>3]=de,b[W>>3]=Ve*-2.598076211353316,t[17040+((t[$>>2]|0)*80|0)+(t[SA>>2]<<2)>>2]|0){case 1:{e=fe,n=QA;break}case 3:{e=he,n=fe;break}case 2:{e=QA,n=he;break}default:{e=12;break A}}ni(U,zA,n,e,Ee),G0(Ee,t[$>>2]|0,a,1,o+8+(t[o>>2]<<4)|0),t[o>>2]=(t[o>>2]|0)+1}if((l|0)<(M|0)&&(ut(nA,$),G0($,t[SA>>2]|0,a,1,o+8+(t[o>>2]<<4)|0),t[o>>2]=(t[o>>2]|0)+1),t[HA>>2]=t[SA>>2],t[HA+4>>2]=t[SA+4>>2],t[HA+8>>2]=t[SA+8>>2],t[HA+12>>2]=t[SA+12>>2],l=l+1|0,(l|0)>=(q|0)){e=3;break}}if((e|0)==3){k=ve;return}else(e|0)==12&&OA(26970,27017,572,27027)}function B(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0;a=k,k=k+128|0,n=a+64|0,o=a,i=n,s=20240,l=i+60|0;do t[i>>2]=t[s>>2],i=i+4|0,s=s+4|0;while((i|0)<(l|0));i=o,s=20304,l=i+60|0;do t[i>>2]=t[s>>2],i=i+4|0,s=s+4|0;while((i|0)<(l|0));l=(Jt(t[A>>2]|0)|0)==0,n=l?n:o,o=e+4|0,Kr(o),Zr(o),Jt(t[A>>2]|0)|0&&(Ht(o),t[A>>2]=(t[A>>2]|0)+1),t[r>>2]=t[e>>2],A=r+4|0,Ze(o,n,A),Me(A),t[r+16>>2]=t[e>>2],A=r+20|0,Ze(o,n+12|0,A),Me(A),t[r+32>>2]=t[e>>2],A=r+36|0,Ze(o,n+24|0,A),Me(A),t[r+48>>2]=t[e>>2],A=r+52|0,Ze(o,n+36|0,A),Me(A),t[r+64>>2]=t[e>>2],r=r+68|0,Ze(o,n+48|0,r),Me(r),k=a}function N(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0;if(L=k,k=k+32|0,j=L+12|0,l=L,I=e+4|0,M=t[16960+(A<<2)>>2]|0,m=(n|0)!=0,M=m?M*3|0:M,o=t[I>>2]|0,f=e+8|0,s=t[f>>2]|0,m){if(i=e+12|0,n=t[i>>2]|0,o=s+o+n|0,(o|0)==(M|0))return I=1,k=L,I|0;a=i}else a=e+12|0,n=t[a>>2]|0,o=s+o+n|0;if((o|0)<=(M|0))return I=0,k=L,I|0;do if((n|0)>0){if(n=t[e>>2]|0,(s|0)>0){i=18640+(n*80|0)+60|0,n=e;break}n=18640+(n*80|0)+40|0,r?(xe(j,M,0,0),yt(I,j,l),B0(l),Ze(l,j,I),i=n,n=e):(i=n,n=e)}else i=18640+((t[e>>2]|0)*80|0)+20|0,n=e;while(!1);if(t[n>>2]=t[i>>2],o=i+16|0,(t[o>>2]|0)>0){n=0;do Cr(I),n=n+1|0;while((n|0)<(t[o>>2]|0))}return e=i+4|0,t[j>>2]=t[e>>2],t[j+4>>2]=t[e+4>>2],t[j+8>>2]=t[e+8>>2],A=t[16880+(A<<2)>>2]|0,ot(j,m?A*3|0:A),Ze(I,j,I),Me(I),m?n=((t[f>>2]|0)+(t[I>>2]|0)+(t[a>>2]|0)|0)==(M|0)?1:2:n=2,I=n,k=L,I|0}function tA(e,A){e=e|0,A=A|0;var r=0;do r=N(e,A,0,1)|0;while((r|0)==2);return r|0}function AA(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0,$=0,U=0,BA=0,zA=0,QA=0,fe=0,he=0,Ee=0,ne=0;if(he=k,k=k+240|0,i=he+224|0,BA=he+208|0,zA=he,QA=he+192|0,fe=he+176|0,W=he+160|0,nA=he+144|0,q=he+128|0,$=he+112|0,U=he+96|0,t[i>>2]=A,t[BA>>2]=t[e>>2],t[BA+4>>2]=t[e+4>>2],t[BA+8>>2]=t[e+8>>2],t[BA+12>>2]=t[e+12>>2],dA(BA,i,zA),t[o>>2]=0,G=n+r+((n|0)==6&1)|0,(G|0)<=(r|0)){k=he;return}a=t[i>>2]|0,f=r+6|0,m=16960+(a<<2)|0,M=nA+8|0,j=q+8|0,I=$+8|0,L=QA+4|0,s=0,l=r,n=-1;A:for(;;){if(i=(l|0)%6|0,e=zA+(i<<4)|0,t[QA>>2]=t[e>>2],t[QA+4>>2]=t[e+4>>2],t[QA+8>>2]=t[e+8>>2],t[QA+12>>2]=t[e+12>>2],e=s,s=N(QA,a,0,1)|0,(l|0)>(r|0)&(Jt(A)|0)!=0&&(e|0)!=1&&(t[QA>>2]|0)!=(n|0)){switch(ut(zA+(((i+5|0)%6|0)<<4)+4|0,fe),ut(zA+(i<<4)+4|0,W),Ee=+(t[m>>2]|0),b[nA>>3]=Ee*3,b[M>>3]=0,ne=Ee*-1.5,b[q>>3]=ne,b[j>>3]=Ee*2.598076211353316,b[$>>3]=ne,b[I>>3]=Ee*-2.598076211353316,i=t[BA>>2]|0,t[17040+(i*80|0)+(((n|0)==(i|0)?t[QA>>2]|0:n)<<2)>>2]|0){case 1:{e=q,n=nA;break}case 3:{e=$,n=q;break}case 2:{e=nA,n=$;break}default:{e=8;break A}}ni(fe,W,n,e,U),!(oi(fe,U)|0)&&!(oi(W,U)|0)&&(G0(U,t[BA>>2]|0,a,1,o+8+(t[o>>2]<<4)|0),t[o>>2]=(t[o>>2]|0)+1)}if((l|0)<(f|0)&&(ut(L,fe),G0(fe,t[QA>>2]|0,a,1,o+8+(t[o>>2]<<4)|0),t[o>>2]=(t[o>>2]|0)+1),l=l+1|0,(l|0)>=(G|0)){e=3;break}else n=t[QA>>2]|0}if((e|0)==3){k=he;return}else(e|0)==8&&OA(27054,27017,737,27099)}function dA(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0;a=k,k=k+160|0,n=a+80|0,o=a,i=n,s=20368,l=i+72|0;do t[i>>2]=t[s>>2],i=i+4|0,s=s+4|0;while((i|0)<(l|0));i=o,s=20448,l=i+72|0;do t[i>>2]=t[s>>2],i=i+4|0,s=s+4|0;while((i|0)<(l|0));l=(Jt(t[A>>2]|0)|0)==0,n=l?n:o,o=e+4|0,Kr(o),Zr(o),Jt(t[A>>2]|0)|0&&(Ht(o),t[A>>2]=(t[A>>2]|0)+1),t[r>>2]=t[e>>2],A=r+4|0,Ze(o,n,A),Me(A),t[r+16>>2]=t[e>>2],A=r+20|0,Ze(o,n+12|0,A),Me(A),t[r+32>>2]=t[e>>2],A=r+36|0,Ze(o,n+24|0,A),Me(A),t[r+48>>2]=t[e>>2],A=r+52|0,Ze(o,n+36|0,A),Me(A),t[r+64>>2]=t[e>>2],A=r+68|0,Ze(o,n+48|0,A),Me(A),t[r+80>>2]=t[e>>2],r=r+84|0,Ze(o,n+60|0,r),Me(r),k=a}function _A(e,A){return e=e|0,A=A|0,A=wA(e|0,A|0,52)|0,S()|0,A&15|0}function te(e,A){return e=e|0,A=A|0,A=wA(e|0,A|0,45)|0,S()|0,A&127|0}function ke(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,(r+-1|0)>>>0>14?(n=4,n|0):(r=wA(e|0,A|0,(15-r|0)*3|0)|0,S()|0,t[n>>2]=r&7,n=0,n|0)}function we(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0;if(e>>>0>15)return n=4,n|0;if(A>>>0>121)return n=17,n|0;s=EA(e|0,0,52)|0,o=S()|0,l=EA(A|0,0,45)|0,o=o|(S()|0)|134225919;A:do if((e|0)>=1){for(l=1,s=(xA[20528+A>>0]|0)!=0,i=-1;;){if(A=t[r+(l+-1<<2)>>2]|0,A>>>0>6){o=18,A=10;break}if(!((A|0)==0|s^1))if((A|0)==1){o=19,A=10;break}else s=0;if(f=(15-l|0)*3|0,a=EA(7,0,f|0)|0,o=o&~(S()|0),A=EA(A|0,((A|0)<0)<<31>>31|0,f|0)|0,i=A|i&~a,o=S()|0|o,(l|0)<(e|0))l=l+1|0;else break A}if((A|0)==10)return o|0}else i=-1;while(!1);return f=n,t[f>>2]=i,t[f+4>>2]=o,f=0,f|0}function Ue(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0;return!(!0&(A&-16777216|0)==134217728)||(n=wA(e|0,A|0,52)|0,S()|0,n=n&15,r=wA(e|0,A|0,45)|0,S()|0,r=r&127,r>>>0>121)?(e=0,e|0):(s=(n^15)*3|0,o=wA(e|0,A|0,s|0)|0,s=EA(o|0,S()|0,s|0)|0,o=S()|0,i=ct(-1227133514,-1171,s|0,o|0)|0,!((s&613566756&i|0)==0&(o&4681&(S()|0)|0)==0)||(s=(n*3|0)+19|0,i=EA(~e|0,~A|0,s|0)|0,s=wA(i|0,S()|0,s|0)|0,!((n|0)==15|(s|0)==0&(S()|0)==0))?(s=0,s|0):!(xA[20528+r>>0]|0)||(A=A&8191,(e|0)==0&(A|0)==0)?(s=1,s|0):(s=io(e|0,A|0)|0,S()|0,((63-s|0)%3|0|0)!=0|0))}function Bt(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0;return!0&(A&-16777216|0)==134217728&&(n=wA(e|0,A|0,52)|0,S()|0,n=n&15,r=wA(e|0,A|0,45)|0,S()|0,r=r&127,r>>>0<=121)&&(s=(n^15)*3|0,o=wA(e|0,A|0,s|0)|0,s=EA(o|0,S()|0,s|0)|0,o=S()|0,i=ct(-1227133514,-1171,s|0,o|0)|0,(s&613566756&i|0)==0&(o&4681&(S()|0)|0)==0)&&(s=(n*3|0)+19|0,i=EA(~e|0,~A|0,s|0)|0,s=wA(i|0,S()|0,s|0)|0,(n|0)==15|(s|0)==0&(S()|0)==0)&&(!(xA[20528+r>>0]|0)||(r=A&8191,(e|0)==0&(r|0)==0)||(s=io(e|0,r|0)|0,S()|0,(63-s|0)%3|0|0))||Xr(e,A)|0?(s=1,s|0):(s=(ii(e,A)|0)!=0&1,s|0)}function Dt(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0;if(o=EA(A|0,0,52)|0,i=S()|0,r=EA(r|0,0,45)|0,r=i|(S()|0)|134225919,(A|0)<1){i=-1,n=r,A=e,t[A>>2]=i,e=e+4|0,t[e>>2]=n;return}for(i=1,o=-1;s=(15-i|0)*3|0,l=EA(7,0,s|0)|0,r=r&~(S()|0),s=EA(n|0,0,s|0)|0,o=o&~l|s,r=r|(S()|0),(i|0)!=(A|0);)i=i+1|0;l=e,s=l,t[s>>2]=o,l=l+4|0,t[l>>2]=r}function _t(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0;if(i=wA(e|0,A|0,52)|0,S()|0,i=i&15,r>>>0>15)return n=4,n|0;if((i|0)<(r|0))return n=12,n|0;if((i|0)==(r|0))return t[n>>2]=e,t[n+4>>2]=A,n=0,n|0;if(o=EA(r|0,0,52)|0,o=o|e,e=S()|0|A&-15728641,(i|0)>(r|0))do A=EA(7,0,(14-r|0)*3|0)|0,r=r+1|0,o=A|o,e=S()|0|e;while((r|0)<(i|0));return t[n>>2]=o,t[n+4>>2]=e,n=0,n|0}function g0(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0;if(i=wA(e|0,A|0,52)|0,S()|0,i=i&15,!((r|0)<16&(i|0)<=(r|0)))return n=4,n|0;o=r-i|0,r=wA(e|0,A|0,45)|0,S()|0;A:do if(!(Re(r&127)|0))r=U0(7,0,o,((o|0)<0)<<31>>31)|0,o=S()|0;else{e:do if(i|0){for(r=1;s=EA(7,0,(15-r|0)*3|0)|0,!!((s&e|0)==0&((S()|0)&A|0)==0);)if(r>>>0>>0)r=r+1|0;else break e;r=U0(7,0,o,((o|0)<0)<<31>>31)|0,o=S()|0;break A}while(!1);r=U0(7,0,o,((o|0)<0)<<31>>31)|0,r=ft(r|0,S()|0,5,0)|0,r=KA(r|0,S()|0,-5,-1)|0,r=W0(r|0,S()|0,6,0)|0,r=KA(r|0,S()|0,1,0)|0,o=S()|0}while(!1);return s=n,t[s>>2]=r,t[s+4>>2]=o,s=0,s|0}function Oe(e,A){e=e|0,A=A|0;var r=0,n=0,o=0;if(o=wA(e|0,A|0,45)|0,S()|0,!(Re(o&127)|0))return o=0,o|0;o=wA(e|0,A|0,52)|0,S()|0,o=o&15;A:do if(!o)r=0;else for(n=1;;){if(r=wA(e|0,A|0,(15-n|0)*3|0)|0,S()|0,r=r&7,r|0)break A;if(n>>>0>>0)n=n+1|0;else{r=0;break}}while(!1);return o=(r|0)==0&1,o|0}function en(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0;if(s=k,k=k+16|0,i=s,Xn(i,e,A,r),A=i,e=t[A>>2]|0,A=t[A+4>>2]|0,(e|0)==0&(A|0)==0)return k=s,0;o=0,r=0;do l=n+(o<<3)|0,t[l>>2]=e,t[l+4>>2]=A,o=KA(o|0,r|0,1,0)|0,r=S()|0,Ao(i),l=i,e=t[l>>2]|0,A=t[l+4>>2]|0;while(!((e|0)==0&(A|0)==0));return k=s,0}function Vo(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,(n|0)<(r|0)?(r=A,n=e,YA(r|0),n|0):(r=EA(-1,-1,((n-r|0)*3|0)+3|0)|0,n=EA(~r|0,~(S()|0)|0,(15-n|0)*3|0)|0,r=~(S()|0)&A,n=~n&e,YA(r|0),n|0)}function Wo(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0;return o=wA(e|0,A|0,52)|0,S()|0,o=o&15,(r|0)<16&(o|0)<=(r|0)?((o|0)<(r|0)&&(o=EA(-1,-1,((r+-1-o|0)*3|0)+3|0)|0,o=EA(~o|0,~(S()|0)|0,(15-r|0)*3|0)|0,A=~(S()|0)&A,e=~o&e),o=EA(r|0,0,52)|0,r=A&-15728641|(S()|0),t[n>>2]=e|o,t[n+4>>2]=r,n=0,n|0):(n=4,n|0)}function ol(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0,$=0,U=0,BA=0,zA=0,QA=0,fe=0,he=0,Ee=0,ne=0,HA=0,SA=0;if((r|0)==0&(n|0)==0)return SA=0,SA|0;if(o=e,i=t[o>>2]|0,o=t[o+4>>2]|0,!0&(o&15728640|0)==0){if(!((n|0)>0|(n|0)==0&r>>>0>0)||(SA=A,t[SA>>2]=i,t[SA+4>>2]=o,(r|0)==1&(n|0)==0))return SA=0,SA|0;o=1,i=0;do ne=e+(o<<3)|0,HA=t[ne+4>>2]|0,SA=A+(o<<3)|0,t[SA>>2]=t[ne>>2],t[SA+4>>2]=HA,o=KA(o|0,i|0,1,0)|0,i=S()|0;while((i|0)<(n|0)|(i|0)==(n|0)&o>>>0>>0);return o=0,o|0}if(Ee=r<<3,HA=p0(Ee)|0,!HA)return SA=13,SA|0;if(Ir(HA|0,e|0,Ee|0)|0,ne=Qt(r,8)|0,!ne)return qA(HA),SA=13,SA|0;A:for(;;){o=HA,f=t[o>>2]|0,o=t[o+4>>2]|0,fe=wA(f|0,o|0,52)|0,S()|0,fe=fe&15,he=fe+-1|0,QA=(fe|0)!=0,zA=(n|0)>0|(n|0)==0&r>>>0>0;e:do if(QA&zA){if(q=EA(he|0,0,52)|0,$=S()|0,he>>>0>15){if(!((f|0)==0&(o|0)==0)){SA=16;break A}for(i=0,e=0;;){if(i=KA(i|0,e|0,1,0)|0,e=S()|0,!((e|0)<(n|0)|(e|0)==(n|0)&i>>>0>>0))break e;if(s=HA+(i<<3)|0,BA=t[s>>2]|0,s=t[s+4>>2]|0,!((BA|0)==0&(s|0)==0)){o=s,SA=16;break A}}}for(l=f,e=o,i=0,s=0;;){if(!((l|0)==0&(e|0)==0)){if(!(!0&(e&117440512|0)==0)){SA=21;break A}if(m=wA(l|0,e|0,52)|0,S()|0,m=m&15,(m|0)<(he|0)){o=12,SA=27;break A}if((m|0)!=(he|0)&&(l=l|q,e=e&-15728641|$,m>>>0>=fe>>>0)){a=he;do BA=EA(7,0,(14-a|0)*3|0)|0,a=a+1|0,l=BA|l,e=S()|0|e;while(a>>>0>>0)}if(j=jr(l|0,e|0,r|0,n|0)|0,I=S()|0,a=ne+(j<<3)|0,m=a,M=t[m>>2]|0,m=t[m+4>>2]|0,!((M|0)==0&(m|0)==0)){W=0,nA=0;do{if((W|0)>(n|0)|(W|0)==(n|0)&nA>>>0>r>>>0){SA=31;break A}if((M|0)==(l|0)&(m&-117440513|0)==(e|0)){L=wA(M|0,m|0,56)|0,S()|0,L=L&7,G=L+1|0,BA=wA(M|0,m|0,45)|0,S()|0;t:do if(!(Re(BA&127)|0))m=7;else{if(M=wA(M|0,m|0,52)|0,S()|0,M=M&15,!M){m=6;break}for(m=1;;){if(BA=EA(7,0,(15-m|0)*3|0)|0,!((BA&l|0)==0&((S()|0)&e|0)==0)){m=7;break t}if(m>>>0>>0)m=m+1|0;else{m=6;break}}}while(!1);if((L+2|0)>>>0>m>>>0){SA=41;break A}BA=EA(G|0,0,56)|0,e=S()|0|e&-117440513,U=a,t[U>>2]=0,t[U+4>>2]=0,l=BA|l}else j=KA(j|0,I|0,1,0)|0,j=Rr(j|0,S()|0,r|0,n|0)|0,I=S()|0;nA=KA(nA|0,W|0,1,0)|0,W=S()|0,a=ne+(j<<3)|0,m=a,M=t[m>>2]|0,m=t[m+4>>2]|0}while(!((M|0)==0&(m|0)==0))}BA=a,t[BA>>2]=l,t[BA+4>>2]=e}if(i=KA(i|0,s|0,1,0)|0,s=S()|0,!((s|0)<(n|0)|(s|0)==(n|0)&i>>>0>>0))break e;e=HA+(i<<3)|0,l=t[e>>2]|0,e=t[e+4>>2]|0}}while(!1);if(BA=KA(r|0,n|0,5,0)|0,U=S()|0,U>>>0<0|(U|0)==0&BA>>>0<11){SA=85;break}if(BA=W0(r|0,n|0,6,0)|0,S()|0,BA=Qt(BA,8)|0,!BA){SA=48;break}do if(zA){for(G=0,e=0,L=0,W=0;;){if(m=ne+(G<<3)|0,s=m,i=t[s>>2]|0,s=t[s+4>>2]|0,(i|0)==0&(s|0)==0)U=L;else{M=wA(i|0,s|0,56)|0,S()|0,M=M&7,l=M+1|0,j=s&-117440513,U=wA(i|0,s|0,45)|0,S()|0;e:do if(Re(U&127)|0){if(I=wA(i|0,s|0,52)|0,S()|0,I=I&15,I|0)for(a=1;;){if(U=EA(7,0,(15-a|0)*3|0)|0,!((i&U|0)==0&(j&(S()|0)|0)==0))break e;if(a>>>0>>0)a=a+1|0;else break}s=EA(l|0,0,56)|0,i=s|i,s=S()|0|j,l=m,t[l>>2]=i,t[l+4>>2]=s,l=M+2|0}while(!1);(l|0)==7?(U=BA+(e<<3)|0,t[U>>2]=i,t[U+4>>2]=s&-117440513,e=KA(e|0,L|0,1,0)|0,U=S()|0):U=L}if(G=KA(G|0,W|0,1,0)|0,W=S()|0,(W|0)<(n|0)|(W|0)==(n|0)&G>>>0>>0)L=U;else break}if(zA){if(nA=he>>>0>15,q=EA(he|0,0,52)|0,$=S()|0,!QA){for(i=0,a=0,l=0,s=0;(f|0)==0&(o|0)==0||(he=A+(i<<3)|0,t[he>>2]=f,t[he+4>>2]=o,i=KA(i|0,a|0,1,0)|0,a=S()|0),l=KA(l|0,s|0,1,0)|0,s=S()|0,!!((s|0)<(n|0)|(s|0)==(n|0)&l>>>0>>0);)o=HA+(l<<3)|0,f=t[o>>2]|0,o=t[o+4>>2]|0;o=U;break}for(i=0,a=0,s=0,l=0;;){do if(!((f|0)==0&(o|0)==0)){if(I=wA(f|0,o|0,52)|0,S()|0,I=I&15,nA|(I|0)<(he|0)){SA=80;break A}if((I|0)!=(he|0)){if(m=f|q,M=o&-15728641|$,I>>>0>=fe>>>0){j=he;do QA=EA(7,0,(14-j|0)*3|0)|0,j=j+1|0,m=QA|m,M=S()|0|M;while(j>>>0>>0)}}else m=f,M=o;L=jr(m|0,M|0,r|0,n|0)|0,j=0,I=0,W=S()|0;do{if((j|0)>(n|0)|(j|0)==(n|0)&I>>>0>r>>>0){SA=81;break A}if(QA=ne+(L<<3)|0,G=t[QA+4>>2]|0,(G&-117440513|0)==(M|0)&&(t[QA>>2]|0)==(m|0)){SA=65;break}QA=KA(L|0,W|0,1,0)|0,L=Rr(QA|0,S()|0,r|0,n|0)|0,W=S()|0,I=KA(I|0,j|0,1,0)|0,j=S()|0,QA=ne+(L<<3)|0}while(!((t[QA>>2]|0)==(m|0)&&(t[QA+4>>2]|0)==(M|0)));if((SA|0)==65&&(SA=0,!0&(G&117440512|0)==100663296))break;QA=A+(i<<3)|0,t[QA>>2]=f,t[QA+4>>2]=o,i=KA(i|0,a|0,1,0)|0,a=S()|0}while(!1);if(s=KA(s|0,l|0,1,0)|0,l=S()|0,!((l|0)<(n|0)|(l|0)==(n|0)&s>>>0>>0))break;o=HA+(s<<3)|0,f=t[o>>2]|0,o=t[o+4>>2]|0}o=U}else i=0,o=U}else i=0,e=0,o=0;while(!1);if(Y0(ne|0,0,Ee|0)|0,Ir(HA|0,BA|0,e<<3|0)|0,qA(BA),(e|0)==0&(o|0)==0){SA=89;break}else A=A+(i<<3)|0,n=o,r=e}if((SA|0)==16)!0&(o&117440512|0)==0?(o=4,SA=27):SA=21;else if((SA|0)==31)OA(27795,27122,620,27132);else{if((SA|0)==41)return qA(HA),qA(ne),SA=10,SA|0;if((SA|0)==48)return qA(HA),qA(ne),SA=13,SA|0;(SA|0)==80?OA(27795,27122,711,27132):(SA|0)==81?OA(27795,27122,723,27132):(SA|0)==85&&(Ir(A|0,HA|0,r<<3|0)|0,SA=89)}return(SA|0)==21?(qA(HA),qA(ne),SA=5,SA|0):(SA|0)==27?(qA(HA),qA(ne),SA=o,SA|0):(SA|0)==89?(qA(HA),qA(ne),SA=0,SA|0):0}function il(e,A,r,n,o,i,s){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0,i=i|0,s=s|0;var l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0;if(G=k,k=k+16|0,L=G,!((r|0)>0|(r|0)==0&A>>>0>0))return L=0,k=G,L|0;if((s|0)>=16)return L=12,k=G,L|0;j=0,I=0,M=0,l=0;A:for(;;){if(f=e+(j<<3)|0,a=t[f>>2]|0,f=t[f+4>>2]|0,m=wA(a|0,f|0,52)|0,S()|0,(m&15|0)>(s|0)){l=12,a=11;break}if(Xn(L,a,f,s),m=L,f=t[m>>2]|0,m=t[m+4>>2]|0,(f|0)==0&(m|0)==0)a=M;else{a=M;do{if(!((l|0)<(i|0)|(l|0)==(i|0)&a>>>0>>0)){a=10;break A}M=n+(a<<3)|0,t[M>>2]=f,t[M+4>>2]=m,a=KA(a|0,l|0,1,0)|0,l=S()|0,Ao(L),M=L,f=t[M>>2]|0,m=t[M+4>>2]|0}while(!((f|0)==0&(m|0)==0))}if(j=KA(j|0,I|0,1,0)|0,I=S()|0,(I|0)<(r|0)|(I|0)==(r|0)&j>>>0>>0)M=a;else{l=0,a=11;break}}return(a|0)==10?(L=14,k=G,L|0):(a|0)==11?(k=G,l|0):0}function sl(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0;j=k,k=k+16|0,M=j;A:do if((r|0)>0|(r|0)==0&A>>>0>0){for(f=0,s=0,i=0,m=0;;){if(a=e+(f<<3)|0,l=t[a>>2]|0,a=t[a+4>>2]|0,!((l|0)==0&(a|0)==0)&&(a=(g0(l,a,n,M)|0)==0,l=M,s=KA(t[l>>2]|0,t[l+4>>2]|0,s|0,i|0)|0,i=S()|0,!a)){i=12;break}if(f=KA(f|0,m|0,1,0)|0,m=S()|0,!((m|0)<(r|0)|(m|0)==(r|0)&f>>>0>>0))break A}return k=j,i|0}else s=0,i=0;while(!1);return t[o>>2]=s,t[o+4>>2]=i,o=0,k=j,o|0}function ll(e,A){return e=e|0,A=A|0,A=wA(e|0,A|0,52)|0,S()|0,A&1|0}function Pt(e,A){e=e|0,A=A|0;var r=0,n=0,o=0;if(o=wA(e|0,A|0,52)|0,S()|0,o=o&15,!o)return o=0,o|0;for(n=1;;){if(r=wA(e|0,A|0,(15-n|0)*3|0)|0,S()|0,r=r&7,r|0){n=5;break}if(n>>>0>>0)n=n+1|0;else{r=0,n=5;break}}return(n|0)==5?r|0:0}function Kn(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0,l=0,a=0;if(a=wA(e|0,A|0,52)|0,S()|0,a=a&15,!a)return l=A,a=e,YA(l|0),a|0;for(l=1,r=0;;){i=(15-l|0)*3|0,n=EA(7,0,i|0)|0,o=S()|0,s=wA(e|0,A|0,i|0)|0,S()|0,i=EA(Gt(s&7)|0,0,i|0)|0,s=S()|0,e=i|e&~n,A=s|A&~o;A:do if(!r)if((i&n|0)==0&(s&o|0)==0)r=0;else if(n=wA(e|0,A|0,52)|0,S()|0,n=n&15,!n)r=1;else{r=1;e:for(;;){switch(s=wA(e|0,A|0,(15-r|0)*3|0)|0,S()|0,s&7){case 1:break e;case 0:break;default:{r=1;break A}}if(r>>>0>>0)r=r+1|0;else{r=1;break A}}for(r=1;;)if(s=(15-r|0)*3|0,o=wA(e|0,A|0,s|0)|0,S()|0,i=EA(7,0,s|0)|0,A=A&~(S()|0),s=EA(Gt(o&7)|0,0,s|0)|0,e=e&~i|s,A=A|(S()|0),r>>>0>>0)r=r+1|0;else{r=1;break}}while(!1);if(l>>>0>>0)l=l+1|0;else break}return YA(A|0),e|0}function lr(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0;if(n=wA(e|0,A|0,52)|0,S()|0,n=n&15,!n)return r=A,n=e,YA(r|0),n|0;for(r=1;i=(15-r|0)*3|0,s=wA(e|0,A|0,i|0)|0,S()|0,o=EA(7,0,i|0)|0,A=A&~(S()|0),i=EA(Gt(s&7)|0,0,i|0)|0,e=i|e&~o,A=S()|0|A,r>>>0>>0;)r=r+1|0;return YA(A|0),e|0}function al(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0,l=0,a=0;if(a=wA(e|0,A|0,52)|0,S()|0,a=a&15,!a)return l=A,a=e,YA(l|0),a|0;for(l=1,r=0;;){i=(15-l|0)*3|0,n=EA(7,0,i|0)|0,o=S()|0,s=wA(e|0,A|0,i|0)|0,S()|0,i=EA(Ut(s&7)|0,0,i|0)|0,s=S()|0,e=i|e&~n,A=s|A&~o;A:do if(!r)if((i&n|0)==0&(s&o|0)==0)r=0;else if(n=wA(e|0,A|0,52)|0,S()|0,n=n&15,!n)r=1;else{r=1;e:for(;;){switch(s=wA(e|0,A|0,(15-r|0)*3|0)|0,S()|0,s&7){case 1:break e;case 0:break;default:{r=1;break A}}if(r>>>0>>0)r=r+1|0;else{r=1;break A}}for(r=1;;)if(o=(15-r|0)*3|0,i=EA(7,0,o|0)|0,s=A&~(S()|0),A=wA(e|0,A|0,o|0)|0,S()|0,A=EA(Ut(A&7)|0,0,o|0)|0,e=e&~i|A,A=s|(S()|0),r>>>0>>0)r=r+1|0;else{r=1;break}}while(!1);if(l>>>0>>0)l=l+1|0;else break}return YA(A|0),e|0}function Zn(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0;if(n=wA(e|0,A|0,52)|0,S()|0,n=n&15,!n)return r=A,n=e,YA(r|0),n|0;for(r=1;s=(15-r|0)*3|0,i=EA(7,0,s|0)|0,o=A&~(S()|0),A=wA(e|0,A|0,s|0)|0,S()|0,A=EA(Ut(A&7)|0,0,s|0)|0,e=A|e&~i,A=S()|0|o,r>>>0>>0;)r=r+1|0;return YA(A|0),e|0}function ul(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0;if(a=k,k=k+64|0,l=a+40|0,n=a+24|0,o=a+12|0,i=a,EA(A|0,0,52)|0,r=S()|0|134225919,!A)return(t[e+4>>2]|0)>2||(t[e+8>>2]|0)>2||(t[e+12>>2]|0)>2?(s=0,l=0,YA(s|0),k=a,l|0):(EA(m0(e)|0,0,45)|0,s=S()|0|r,l=-1,YA(s|0),k=a,l|0);if(t[l>>2]=t[e>>2],t[l+4>>2]=t[e+4>>2],t[l+8>>2]=t[e+8>>2],t[l+12>>2]=t[e+12>>2],s=l+4|0,(A|0)>0)for(e=-1;t[n>>2]=t[s>>2],t[n+4>>2]=t[s+4>>2],t[n+8>>2]=t[s+8>>2],A&1?(vr(s),t[o>>2]=t[s>>2],t[o+4>>2]=t[s+4>>2],t[o+8>>2]=t[s+8>>2],br(o)):(kr(s),t[o>>2]=t[s>>2],t[o+4>>2]=t[s+4>>2],t[o+8>>2]=t[s+8>>2],Ht(o)),yt(n,o,i),Me(i),m=(15-A|0)*3|0,f=EA(7,0,m|0)|0,r=r&~(S()|0),m=EA(St(i)|0,0,m|0)|0,e=m|e&~f,r=S()|0|r,(A|0)>1;)A=A+-1|0;else e=-1;A:do if((t[s>>2]|0)<=2&&(t[l+8>>2]|0)<=2&&(t[l+12>>2]|0)<=2){if(n=m0(l)|0,A=EA(n|0,0,45)|0,A=A|e,e=S()|0|r&-1040385,i=l0(l)|0,!(Re(n)|0)){if((i|0)<=0)break;for(o=0;;){if(n=wA(A|0,e|0,52)|0,S()|0,n=n&15,n)for(r=1;m=(15-r|0)*3|0,l=wA(A|0,e|0,m|0)|0,S()|0,f=EA(7,0,m|0)|0,e=e&~(S()|0),m=EA(Gt(l&7)|0,0,m|0)|0,A=A&~f|m,e=e|(S()|0),r>>>0>>0;)r=r+1|0;if(o=o+1|0,(o|0)==(i|0))break A}}o=wA(A|0,e|0,52)|0,S()|0,o=o&15;e:do if(o){r=1;t:for(;;){switch(m=wA(A|0,e|0,(15-r|0)*3|0)|0,S()|0,m&7){case 1:break t;case 0:break;default:break e}if(r>>>0>>0)r=r+1|0;else break e}if(S0(n,t[l>>2]|0)|0)for(r=1;l=(15-r|0)*3|0,f=EA(7,0,l|0)|0,m=e&~(S()|0),e=wA(A|0,e|0,l|0)|0,S()|0,e=EA(Ut(e&7)|0,0,l|0)|0,A=A&~f|e,e=m|(S()|0),r>>>0>>0;)r=r+1|0;else for(r=1;m=(15-r|0)*3|0,l=wA(A|0,e|0,m|0)|0,S()|0,f=EA(7,0,m|0)|0,e=e&~(S()|0),m=EA(Gt(l&7)|0,0,m|0)|0,A=A&~f|m,e=e|(S()|0),r>>>0>>0;)r=r+1|0}while(!1);if((i|0)>0){r=0;do A=Kn(A,e)|0,e=S()|0,r=r+1|0;while((r|0)!=(i|0))}}else A=0,e=0;while(!1);return f=e,m=A,YA(f|0),k=a,m|0}function Jt(e){return e=e|0,(e|0)%2|0|0}function $n(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0;return o=k,k=k+16|0,n=o,A>>>0>15?(n=4,k=o,n|0):(t[e+4>>2]&2146435072|0)==2146435072||(t[e+8+4>>2]&2146435072|0)==2146435072?(n=3,k=o,n|0):(xn(e,A,n),A=ul(n,A)|0,n=S()|0,t[r>>2]=A,t[r+4>>2]=n,(A|0)==0&(n|0)==0&&OA(27795,27122,1050,27145),n=0,k=o,n|0)}function qn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0;if(o=r+4|0,i=wA(e|0,A|0,52)|0,S()|0,i=i&15,s=wA(e|0,A|0,45)|0,S()|0,n=(i|0)==0,Re(s&127)|0){if(n)return s=1,s|0;n=1}else{if(n)return s=0,s|0;(t[o>>2]|0)==0&&(t[r+8>>2]|0)==0?n=(t[r+12>>2]|0)!=0&1:n=1}for(r=1;r&1?br(o):Ht(o),s=wA(e|0,A|0,(15-r|0)*3|0)|0,S()|0,gn(o,s&7),r>>>0>>0;)r=r+1|0;return n|0}function Dr(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0;if(m=k,k=k+16|0,a=m,f=wA(e|0,A|0,45)|0,S()|0,f=f&127,f>>>0>121)return t[r>>2]=0,t[r+4>>2]=0,t[r+8>>2]=0,t[r+12>>2]=0,f=5,k=m,f|0;A:do if((Re(f)|0)!=0&&(i=wA(e|0,A|0,52)|0,S()|0,i=i&15,(i|0)!=0)){n=1;e:for(;;){switch(l=wA(e|0,A|0,(15-n|0)*3|0)|0,S()|0,l&7){case 5:break e;case 0:break;default:{n=A;break A}}if(n>>>0>>0)n=n+1|0;else{n=A;break A}}for(o=1,n=A;A=(15-o|0)*3|0,s=EA(7,0,A|0)|0,l=n&~(S()|0),n=wA(e|0,n|0,A|0)|0,S()|0,n=EA(Ut(n&7)|0,0,A|0)|0,e=e&~s|n,n=l|(S()|0),o>>>0>>0;)o=o+1|0}else n=A;while(!1);if(l=7696+(f*28|0)|0,t[r>>2]=t[l>>2],t[r+4>>2]=t[l+4>>2],t[r+8>>2]=t[l+8>>2],t[r+12>>2]=t[l+12>>2],!(qn(e,n,r)|0))return f=0,k=m,f|0;if(s=r+4|0,t[a>>2]=t[s>>2],t[a+4>>2]=t[s+4>>2],t[a+8>>2]=t[s+8>>2],i=wA(e|0,n|0,52)|0,S()|0,l=i&15,i&1?(Ht(s),i=l+1|0):i=l,!(Re(f)|0))n=0;else{A:do if(!l)n=0;else for(A=1;;){if(o=wA(e|0,n|0,(15-A|0)*3|0)|0,S()|0,o=o&7,o|0){n=o;break A}if(A>>>0>>0)A=A+1|0;else{n=0;break}}while(!1);n=(n|0)==4&1}if(!(N(r,i,n,0)|0))(i|0)!=(l|0)&&(t[s>>2]=t[a>>2],t[s+4>>2]=t[a+4>>2],t[s+8>>2]=t[a+8>>2]);else{if(Re(f)|0)do;while((N(r,i,0,0)|0)!=0);(i|0)!=(l|0)&&kr(s)}return f=0,k=m,f|0}function ar(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0;return i=k,k=k+16|0,n=i,o=Dr(e,A,n)|0,o|0?(k=i,o|0):(o=wA(e|0,A|0,52)|0,S()|0,d(n,o&15,r),o=0,k=i,o|0)}function _r(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0;if(s=k,k=k+16|0,i=s,n=Dr(e,A,i)|0,n|0)return i=n,k=s,i|0;n=wA(e|0,A|0,45)|0,S()|0,n=(Re(n&127)|0)==0,o=wA(e|0,A|0,52)|0,S()|0,o=o&15;A:do if(!n){if(o|0)for(n=1;;){if(l=EA(7,0,(15-n|0)*3|0)|0,!((l&e|0)==0&((S()|0)&A|0)==0))break A;if(n>>>0>>0)n=n+1|0;else break}return w(i,o,0,5,r),l=0,k=s,l|0}while(!1);return AA(i,o,0,6,r),l=0,k=s,l|0}function cl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0;if(o=wA(e|0,A|0,45)|0,S()|0,!(Re(o&127)|0))return o=2,t[r>>2]=o,0;if(o=wA(e|0,A|0,52)|0,S()|0,o=o&15,!o)return o=5,t[r>>2]=o,0;for(n=1;;){if(i=EA(7,0,(15-n|0)*3|0)|0,!((i&e|0)==0&((S()|0)&A|0)==0)){n=2,e=6;break}if(n>>>0>>0)n=n+1|0;else{n=5,e=6;break}}return(e|0)==6&&(t[r>>2]=n),0}function Yo(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0;M=k,k=k+128|0,f=M+112|0,i=M+96|0,m=M,o=wA(e|0,A|0,52)|0,S()|0,l=o&15,t[f>>2]=l,s=wA(e|0,A|0,45)|0,S()|0,s=s&127;A:do if(Re(s)|0){if(l|0)for(n=1;;){if(a=EA(7,0,(15-n|0)*3|0)|0,!((a&e|0)==0&((S()|0)&A|0)==0)){o=0;break A}if(n>>>0>>0)n=n+1|0;else break}if(o&1)o=1;else return a=EA(l+1|0,0,52)|0,m=S()|0|A&-15728641,f=EA(7,0,(14-l|0)*3|0)|0,m=Yo((a|e)&~f,m&~(S()|0),r)|0,k=M,m|0}else o=0;while(!1);if(n=Dr(e,A,i)|0,!n){o?(B(i,f,m),a=5):(dA(i,f,m),a=6);A:do if(Re(s)|0)if(!l)e=5;else for(n=1;;){if(s=EA(7,0,(15-n|0)*3|0)|0,!((s&e|0)==0&((S()|0)&A|0)==0)){e=2;break A}if(n>>>0>>0)n=n+1|0;else{e=5;break}}else e=2;while(!1);Y0(r|0,-1,e<<2|0)|0;A:do if(o)for(i=0;;){if(s=m+(i<<4)|0,tA(s,t[f>>2]|0)|0,s=t[s>>2]|0,l=t[r>>2]|0,(l|0)==-1|(l|0)==(s|0))n=r;else{o=0;do{if(o=o+1|0,o>>>0>=e>>>0){n=1;break A}n=r+(o<<2)|0,l=t[n>>2]|0}while(!((l|0)==-1|(l|0)==(s|0)))}if(t[n>>2]=s,i=i+1|0,i>>>0>=a>>>0){n=0;break}}else for(i=0;;){if(s=m+(i<<4)|0,N(s,t[f>>2]|0,0,1)|0,s=t[s>>2]|0,l=t[r>>2]|0,(l|0)==-1|(l|0)==(s|0))n=r;else{o=0;do{if(o=o+1|0,o>>>0>=e>>>0){n=1;break A}n=r+(o<<2)|0,l=t[n>>2]|0}while(!((l|0)==-1|(l|0)==(s|0)))}if(t[n>>2]=s,i=i+1|0,i>>>0>=a>>>0){n=0;break}}while(!1)}return m=n,k=M,m|0}function fl(){return 12}function Jn(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0,l=0,a=0;if(e>>>0>15)return l=4,l|0;if(EA(e|0,0,52)|0,l=S()|0|134225919,!e){r=0,n=0;do Re(n)|0&&(EA(n|0,0,45)|0,s=l|(S()|0),e=A+(r<<3)|0,t[e>>2]=-1,t[e+4>>2]=s,r=r+1|0),n=n+1|0;while((n|0)!=122);return r=0,r|0}r=0,s=0;do{if(Re(s)|0){for(EA(s|0,0,45)|0,n=1,o=-1,i=l|(S()|0);a=EA(7,0,(15-n|0)*3|0)|0,o=o&~a,i=i&~(S()|0),(n|0)!=(e|0);)n=n+1|0;a=A+(r<<3)|0,t[a>>2]=o,t[a+4>>2]=i,r=r+1|0}s=s+1|0}while((s|0)!=122);return r=0,r|0}function hl(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0;if(q=k,k=k+16|0,W=q,nA=wA(e|0,A|0,52)|0,S()|0,nA=nA&15,r>>>0>15)return nA=4,k=q,nA|0;if((nA|0)<(r|0))return nA=12,k=q,nA|0;if((nA|0)!=(r|0))if(i=EA(r|0,0,52)|0,i=i|e,l=S()|0|A&-15728641,(nA|0)>(r|0)){a=r;do G=EA(7,0,(14-a|0)*3|0)|0,a=a+1|0,i=G|i,l=S()|0|l;while((a|0)<(nA|0));G=i}else G=i;else G=e,l=A;L=wA(G|0,l|0,45)|0,S()|0;A:do if(Re(L&127)|0){if(a=wA(G|0,l|0,52)|0,S()|0,a=a&15,a|0)for(i=1;;){if(L=EA(7,0,(15-i|0)*3|0)|0,!((L&G|0)==0&((S()|0)&l|0)==0)){f=33;break A}if(i>>>0>>0)i=i+1|0;else break}if(L=n,t[L>>2]=0,t[L+4>>2]=0,(nA|0)>(r|0)){for(L=A&-15728641,I=nA;;){if(j=I,I=I+-1|0,I>>>0>15|(nA|0)<(I|0)){f=19;break}if((nA|0)!=(I|0))if(i=EA(I|0,0,52)|0,i=i|e,a=S()|0|L,(nA|0)<(j|0))M=i;else{f=I;do M=EA(7,0,(14-f|0)*3|0)|0,f=f+1|0,i=M|i,a=S()|0|a;while((f|0)<(nA|0));M=i}else M=e,a=A;if(m=wA(M|0,a|0,45)|0,S()|0,!(Re(m&127)|0))i=0;else{m=wA(M|0,a|0,52)|0,S()|0,m=m&15;e:do if(!m)i=0;else for(f=1;;){if(i=wA(M|0,a|0,(15-f|0)*3|0)|0,S()|0,i=i&7,i|0)break e;if(f>>>0>>0)f=f+1|0;else{i=0;break}}while(!1);i=(i|0)==0&1}if(a=wA(e|0,A|0,(15-j|0)*3|0)|0,S()|0,a=a&7,(a|0)==7){o=5,f=42;break}if(i=(i|0)!=0,(a|0)==1&i){o=5,f=42;break}if(M=a+(((a|0)!=0&i)<<31>>31)|0,M|0&&(f=nA-j|0,f=U0(7,0,f,((f|0)<0)<<31>>31)|0,m=S()|0,i?(i=ft(f|0,m|0,5,0)|0,i=KA(i|0,S()|0,-5,-1)|0,i=W0(i|0,S()|0,6,0)|0,i=KA(i|0,S()|0,1,0)|0,a=S()|0):(i=f,a=m),j=M+-1|0,j=ft(f|0,m|0,j|0,((j|0)<0)<<31>>31|0)|0,j=KA(i|0,a|0,j|0,S()|0)|0,M=S()|0,m=n,m=KA(j|0,M|0,t[m>>2]|0,t[m+4>>2]|0)|0,M=S()|0,j=n,t[j>>2]=m,t[j+4>>2]=M),(I|0)<=(r|0)){f=37;break}}if((f|0)==19)OA(27795,27122,1367,27158);else if((f|0)==37){s=n,o=t[s+4>>2]|0,s=t[s>>2]|0;break}else if((f|0)==42)return k=q,o|0}else o=0,s=0}else f=33;while(!1);A:do if((f|0)==33)if(L=n,t[L>>2]=0,t[L+4>>2]=0,(nA|0)>(r|0)){for(i=nA;;){if(o=wA(e|0,A|0,(15-i|0)*3|0)|0,S()|0,o=o&7,(o|0)==7){o=5;break}if(s=nA-i|0,s=U0(7,0,s,((s|0)<0)<<31>>31)|0,o=ft(s|0,S()|0,o|0,0)|0,s=S()|0,L=n,s=KA(t[L>>2]|0,t[L+4>>2]|0,o|0,s|0)|0,o=S()|0,L=n,t[L>>2]=s,t[L+4>>2]=o,i=i+-1|0,(i|0)<=(r|0))break A}return k=q,o|0}else o=0,s=0;while(!1);return g0(G,l,nA,W)|0&&OA(27795,27122,1327,27173),nA=W,W=t[nA+4>>2]|0,((o|0)>-1|(o|0)==-1&s>>>0>4294967295)&((W|0)>(o|0)|((W|0)==(o|0)?(t[nA>>2]|0)>>>0>s>>>0:0))?(nA=0,k=q,nA|0):(OA(27795,27122,1407,27158),0)}function dl(e,A,r,n,o,i){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0,i=i|0;var s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0;if(M=k,k=k+16|0,s=M,o>>>0>15)return i=4,k=M,i|0;if(l=wA(r|0,n|0,52)|0,S()|0,l=l&15,(l|0)>(o|0))return i=12,k=M,i|0;if(g0(r,n,o,s)|0&&OA(27795,27122,1327,27173),m=s,f=t[m+4>>2]|0,!(((A|0)>-1|(A|0)==-1&e>>>0>4294967295)&((f|0)>(A|0)|((f|0)==(A|0)?(t[m>>2]|0)>>>0>e>>>0:0))))return i=2,k=M,i|0;m=o-l|0,o=EA(o|0,0,52)|0,a=S()|0|n&-15728641,f=i,t[f>>2]=o|r,t[f+4>>2]=a,f=wA(r|0,n|0,45)|0,S()|0;A:do if(Re(f&127)|0){if(l|0)for(s=1;;){if(f=EA(7,0,(15-s|0)*3|0)|0,!((f&r|0)==0&((S()|0)&n|0)==0))break A;if(s>>>0>>0)s=s+1|0;else break}if((m|0)<1)return i=0,k=M,i|0;for(f=l^15,n=-1,a=1,s=1;;){l=m-a|0,l=U0(7,0,l,((l|0)<0)<<31>>31)|0,r=S()|0;do if(s)if(s=ft(l|0,r|0,5,0)|0,s=KA(s|0,S()|0,-5,-1)|0,s=W0(s|0,S()|0,6,0)|0,o=S()|0,(A|0)>(o|0)|(A|0)==(o|0)&e>>>0>s>>>0){A=KA(e|0,A|0,-1,-1)|0,A=ct(A|0,S()|0,s|0,o|0)|0,s=S()|0,j=i,L=t[j>>2]|0,j=t[j+4>>2]|0,G=(f+n|0)*3|0,I=EA(7,0,G|0)|0,j=j&~(S()|0),n=W0(A|0,s|0,l|0,r|0)|0,e=S()|0,o=KA(n|0,e|0,2,0)|0,G=EA(o|0,S()|0,G|0)|0,j=S()|0|j,o=i,t[o>>2]=G|L&~I,t[o+4>>2]=j,e=ft(n|0,e|0,l|0,r|0)|0,e=ct(A|0,s|0,e|0,S()|0)|0,s=0,A=S()|0;break}else{G=i,I=t[G>>2]|0,G=t[G+4>>2]|0,L=EA(7,0,(f+n|0)*3|0)|0,G=G&~(S()|0),s=i,t[s>>2]=I&~L,t[s+4>>2]=G,s=1;break}else I=i,o=t[I>>2]|0,I=t[I+4>>2]|0,n=(f+n|0)*3|0,j=EA(7,0,n|0)|0,I=I&~(S()|0),G=W0(e|0,A|0,l|0,r|0)|0,s=S()|0,n=EA(G|0,s|0,n|0)|0,I=S()|0|I,L=i,t[L>>2]=n|o&~j,t[L+4>>2]=I,s=ft(G|0,s|0,l|0,r|0)|0,e=ct(e|0,A|0,s|0,S()|0)|0,s=0,A=S()|0;while(!1);if((m|0)>(a|0))n=~a,a=a+1|0;else{A=0;break}}return k=M,A|0}while(!1);if((m|0)<1)return G=0,k=M,G|0;for(o=l^15,s=1;;)if(L=m-s|0,L=U0(7,0,L,((L|0)<0)<<31>>31)|0,G=S()|0,a=i,r=t[a>>2]|0,a=t[a+4>>2]|0,l=(o-s|0)*3|0,n=EA(7,0,l|0)|0,a=a&~(S()|0),j=W0(e|0,A|0,L|0,G|0)|0,I=S()|0,l=EA(j|0,I|0,l|0)|0,a=S()|0|a,f=i,t[f>>2]=l|r&~n,t[f+4>>2]=a,G=ft(j|0,I|0,L|0,G|0)|0,e=ct(e|0,A|0,G|0,S()|0)|0,A=S()|0,(m|0)<=(s|0)){A=0;break}else s=s+1|0;return k=M,A|0}function Xn(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0;o=wA(A|0,r|0,52)|0,S()|0,o=o&15,(A|0)==0&(r|0)==0|((n|0)>15|(o|0)>(n|0))?(i=-1,A=-1,r=0,o=0):(A=Vo(A,r,o+1|0,n)|0,s=(S()|0)&-15728641,r=EA(n|0,0,52)|0,r=A|r,s=s|(S()|0),A=(Oe(r,s)|0)==0,i=o,A=A?-1:n,o=s),s=e,t[s>>2]=r,t[s+4>>2]=o,t[e+8>>2]=i,t[e+12>>2]=A}function Ko(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0;if(o=wA(e|0,A|0,52)|0,S()|0,o=o&15,i=n+8|0,t[i>>2]=o,(e|0)==0&(A|0)==0|((r|0)>15|(o|0)>(r|0))){r=n,t[r>>2]=0,t[r+4>>2]=0,t[i>>2]=-1,t[n+12>>2]=-1;return}if(e=Vo(e,A,o+1|0,r)|0,i=(S()|0)&-15728641,o=EA(r|0,0,52)|0,o=e|o,i=i|(S()|0),e=n,t[e>>2]=o,t[e+4>>2]=i,e=n+12|0,Oe(o,i)|0){t[e>>2]=r;return}else{t[e>>2]=-1;return}}function Ao(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0,a=0,f=0;if(r=e,A=t[r>>2]|0,r=t[r+4>>2]|0,!((A|0)==0&(r|0)==0)&&(n=wA(A|0,r|0,52)|0,S()|0,n=n&15,l=EA(1,0,(n^15)*3|0)|0,A=KA(l|0,S()|0,A|0,r|0)|0,r=S()|0,l=e,t[l>>2]=A,t[l+4>>2]=r,l=e+8|0,s=t[l>>2]|0,!((n|0)<(s|0)))){for(a=e+12|0,i=n;;){if((i|0)==(s|0)){n=5;break}if(f=(i|0)==(t[a>>2]|0),o=(15-i|0)*3|0,n=wA(A|0,r|0,o|0)|0,S()|0,n=n&7,f&((n|0)==1&!0)){n=7;break}if(!((n|0)==7&!0)){n=10;break}if(f=EA(1,0,o|0)|0,A=KA(A|0,r|0,f|0,S()|0)|0,r=S()|0,f=e,t[f>>2]=A,t[f+4>>2]=r,(i|0)>(s|0))i=i+-1|0;else{n=10;break}}if((n|0)==5){f=e,t[f>>2]=0,t[f+4>>2]=0,t[l>>2]=-1,t[a>>2]=-1;return}else if((n|0)==7){s=EA(1,0,o|0)|0,s=KA(A|0,r|0,s|0,S()|0)|0,l=S()|0,f=e,t[f>>2]=s,t[f+4>>2]=l,t[a>>2]=i+-1;return}else if((n|0)==10)return}}function tn(e){e=+e;var A=0;return A=e<0?e+6.283185307179586:e,+(e>=6.283185307179586?A+-6.283185307179586:A)}function Tr(e,A){return e=e|0,A=A|0,+$A(+(+b[e>>3]-+b[A>>3]))<17453292519943298e-27?(A=+$A(+(+b[e+8>>3]-+b[A+8>>3]))<17453292519943298e-27,A|0):(A=0,A|0)}function Vt(e,A){switch(e=+e,A=A|0,A|0){case 1:{e=e<0?e+6.283185307179586:e;break}case 2:{e=e>0?e+-6.283185307179586:e;break}}return+e}function ml(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0;return o=+b[A>>3],n=+b[e>>3],i=+ie(+((o-n)*.5)),r=+ie(+((+b[A+8>>3]-+b[e+8>>3])*.5)),r=i*i+r*(+_e(+o)*+_e(+n)*r),+(+Te(+ +ye(+r),+ +ye(+(1-r)))*2)}function rn(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0;return o=+b[A>>3],n=+b[e>>3],i=+ie(+((o-n)*.5)),r=+ie(+((+b[A+8>>3]-+b[e+8>>3])*.5)),r=i*i+r*(+_e(+o)*+_e(+n)*r),+(+Te(+ +ye(+r),+ +ye(+(1-r)))*2*6371.007180918475)}function gl(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0;return o=+b[A>>3],n=+b[e>>3],i=+ie(+((o-n)*.5)),r=+ie(+((+b[A+8>>3]-+b[e+8>>3])*.5)),r=i*i+r*(+_e(+o)*+_e(+n)*r),+(+Te(+ +ye(+r),+ +ye(+(1-r)))*2*6371.007180918475*1e3)}function pl(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0;return i=+b[A>>3],n=+_e(+i),o=+b[A+8>>3]-+b[e+8>>3],s=n*+ie(+o),r=+b[e>>3],+ +Te(+s,+(+ie(+i)*+_e(+r)-+_e(+o)*(n*+ie(+r))))}function yl(e,A,r,n){e=e|0,A=+A,r=+r,n=n|0;var o=0,i=0,s=0,l=0;if(r<1e-16){t[n>>2]=t[e>>2],t[n+4>>2]=t[e+4>>2],t[n+8>>2]=t[e+8>>2],t[n+12>>2]=t[e+12>>2];return}i=A<0?A+6.283185307179586:A,i=A>=6.283185307179586?i+-6.283185307179586:i;do if(i<1e-16)A=+b[e>>3]+r,b[n>>3]=A,o=n;else{if(o=+$A(+(i+-3.141592653589793))<1e-16,A=+b[e>>3],o){A=A-r,b[n>>3]=A,o=n;break}if(s=+_e(+r),r=+ie(+r),A=s*+ie(+A)+ +_e(+i)*(r*+_e(+A)),A=A>1?1:A,A=+h0(+(A<-1?-1:A)),b[n>>3]=A,+$A(+(A+-1.5707963267948966))<1e-16){b[n>>3]=1.5707963267948966,b[n+8>>3]=0;return}if(+$A(+(A+1.5707963267948966))<1e-16){b[n>>3]=-1.5707963267948966,b[n+8>>3]=0;return}if(l=1/+_e(+A),i=r*+ie(+i)*l,r=+b[e>>3],A=l*((s-+ie(+A)*+ie(+r))/+_e(+r)),s=i>1?1:i,A=A>1?1:A,A=+b[e+8>>3]+ +Te(+(s<-1?-1:s),+(A<-1?-1:A)),A>3.141592653589793)do A=A+-6.283185307179586;while(A>3.141592653589793);if(A<-3.141592653589793)do A=A+6.283185307179586;while(A<-3.141592653589793);b[n+8>>3]=A;return}while(!1);if(+$A(+(A+-1.5707963267948966))<1e-16){b[o>>3]=1.5707963267948966,b[n+8>>3]=0;return}if(+$A(+(A+1.5707963267948966))<1e-16){b[o>>3]=-1.5707963267948966,b[n+8>>3]=0;return}if(A=+b[e+8>>3],A>3.141592653589793)do A=A+-6.283185307179586;while(A>3.141592653589793);if(A<-3.141592653589793)do A=A+6.283185307179586;while(A<-3.141592653589793);b[n+8>>3]=A}function Zo(e,A){return e=e|0,A=A|0,e>>>0>15?(A=4,A|0):(b[A>>3]=+b[20656+(e<<3)>>3],A=0,A|0)}function xl(e,A){return e=e|0,A=A|0,e>>>0>15?(A=4,A|0):(b[A>>3]=+b[20784+(e<<3)>>3],A=0,A|0)}function wl(e,A){return e=e|0,A=A|0,e>>>0>15?(A=4,A|0):(b[A>>3]=+b[20912+(e<<3)>>3],A=0,A|0)}function vl(e,A){return e=e|0,A=A|0,e>>>0>15?(A=4,A|0):(b[A>>3]=+b[21040+(e<<3)>>3],A=0,A|0)}function vn(e,A){e=e|0,A=A|0;var r=0;return e>>>0>15?(A=4,A|0):(r=U0(7,0,e,((e|0)<0)<<31>>31)|0,r=ft(r|0,S()|0,120,0)|0,e=S()|0,t[A>>2]=r|2,t[A+4>>2]=e,A=0,A|0)}function $o(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0;return j=+b[A>>3],m=+b[e>>3],a=+ie(+((j-m)*.5)),i=+b[A+8>>3],f=+b[e+8>>3],s=+ie(+((i-f)*.5)),l=+_e(+m),M=+_e(+j),s=a*a+s*(M*l*s),s=+Te(+ +ye(+s),+ +ye(+(1-s)))*2,a=+b[r>>3],j=+ie(+((a-j)*.5)),n=+b[r+8>>3],i=+ie(+((n-i)*.5)),o=+_e(+a),i=j*j+i*(M*o*i),i=+Te(+ +ye(+i),+ +ye(+(1-i)))*2,a=+ie(+((m-a)*.5)),n=+ie(+((f-n)*.5)),n=a*a+n*(l*o*n),n=+Te(+ +ye(+n),+ +ye(+(1-n)))*2,o=(s+i+n)*.5,+(+mt(+ +ye(+(+et(+(o*.5))*+et(+((o-s)*.5))*+et(+((o-i)*.5))*+et(+((o-n)*.5)))))*4)}function eo(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0;if(l=k,k=k+192|0,i=l+168|0,s=l,o=ar(e,A,i)|0,o|0)return r=o,k=l,r|0;if(_r(e,A,s)|0&&OA(27795,27190,415,27199),A=t[s>>2]|0,(A|0)>0){if(n=+$o(s+8|0,s+8+(((A|0)!=1&1)<<4)|0,i)+0,(A|0)!=1){e=1;do o=e,e=e+1|0,n=n+ +$o(s+8+(o<<4)|0,s+8+(((e|0)%(A|0)|0)<<4)|0,i);while((e|0)<(A|0))}}else n=0;return b[r>>3]=n,r=0,k=l,r|0}function kl(e,A,r){return e=e|0,A=A|0,r=r|0,e=eo(e,A,r)|0,e|0||(b[r>>3]=+b[r>>3]*6371.007180918475*6371.007180918475),e|0}function bl(e,A,r){return e=e|0,A=A|0,r=r|0,e=eo(e,A,r)|0,e|0||(b[r>>3]=+b[r>>3]*6371.007180918475*6371.007180918475*1e3*1e3),e|0}function Cl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0;if(l=k,k=k+176|0,s=l,e=sr(e,A,s)|0,e|0)return s=e,k=l,s|0;if(b[r>>3]=0,e=t[s>>2]|0,(e|0)<=1)return s=0,k=l,s|0;A=e+-1|0,e=0,n=+b[s+8>>3],o=+b[s+16>>3],i=0;do e=e+1|0,f=n,n=+b[s+8+(e<<4)>>3],m=+ie(+((n-f)*.5)),a=o,o=+b[s+8+(e<<4)+8>>3],a=+ie(+((o-a)*.5)),a=m*m+a*(+_e(+n)*+_e(+f)*a),i=i+ +Te(+ +ye(+a),+ +ye(+(1-a)))*2;while((e|0)<(A|0));return b[r>>3]=i,s=0,k=l,s|0}function El(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0;if(l=k,k=k+176|0,s=l,e=sr(e,A,s)|0,e|0)return s=e,i=+b[r>>3],i=i*6371.007180918475,b[r>>3]=i,k=l,s|0;if(b[r>>3]=0,e=t[s>>2]|0,(e|0)<=1)return s=0,i=0,i=i*6371.007180918475,b[r>>3]=i,k=l,s|0;A=e+-1|0,e=0,n=+b[s+8>>3],o=+b[s+16>>3],i=0;do e=e+1|0,f=n,n=+b[s+8+(e<<4)>>3],m=+ie(+((n-f)*.5)),a=o,o=+b[s+8+(e<<4)+8>>3],a=+ie(+((o-a)*.5)),a=m*m+a*(+_e(+f)*+_e(+n)*a),i=i+ +Te(+ +ye(+a),+ +ye(+(1-a)))*2;while((e|0)!=(A|0));return b[r>>3]=i,s=0,m=i,m=m*6371.007180918475,b[r>>3]=m,k=l,s|0}function Sl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0;if(l=k,k=k+176|0,s=l,e=sr(e,A,s)|0,e|0)return s=e,i=+b[r>>3],i=i*6371.007180918475,i=i*1e3,b[r>>3]=i,k=l,s|0;if(b[r>>3]=0,e=t[s>>2]|0,(e|0)<=1)return s=0,i=0,i=i*6371.007180918475,i=i*1e3,b[r>>3]=i,k=l,s|0;A=e+-1|0,e=0,n=+b[s+8>>3],o=+b[s+16>>3],i=0;do e=e+1|0,f=n,n=+b[s+8+(e<<4)>>3],m=+ie(+((n-f)*.5)),a=o,o=+b[s+8+(e<<4)+8>>3],a=+ie(+((o-a)*.5)),a=m*m+a*(+_e(+f)*+_e(+n)*a),i=i+ +Te(+ +ye(+a),+ +ye(+(1-a)))*2;while((e|0)!=(A|0));return b[r>>3]=i,s=0,m=i,m=m*6371.007180918475,m=m*1e3,b[r>>3]=m,k=l,s|0}function Ml(e){e=e|0;var A=0,r=0,n=0;return A=Qt(1,12)|0,A||OA(27280,27235,49,27293),r=e+4|0,n=t[r>>2]|0,n|0?(n=n+8|0,t[n>>2]=A,t[r>>2]=A,A|0):(t[e>>2]|0&&OA(27310,27235,61,27333),n=e,t[n>>2]=A,t[r>>2]=A,A|0)}function Bl(e,A){e=e|0,A=A|0;var r=0,n=0;return n=p0(24)|0,n||OA(27347,27235,78,27361),t[n>>2]=t[A>>2],t[n+4>>2]=t[A+4>>2],t[n+8>>2]=t[A+8>>2],t[n+12>>2]=t[A+12>>2],t[n+16>>2]=0,A=e+4|0,r=t[A>>2]|0,r|0?(t[r+16>>2]=n,t[A>>2]=n,n|0):(t[e>>2]|0&&OA(27376,27235,82,27361),t[e>>2]=n,t[A>>2]=n,n|0)}function qo(e){e=e|0;var A=0,r=0,n=0,o=0;if(e)for(n=1;;){if(A=t[e>>2]|0,A|0)do{if(r=t[A>>2]|0,r|0)do o=r,r=t[r+16>>2]|0,qA(o);while((r|0)!=0);o=A,A=t[A+8>>2]|0,qA(o)}while((A|0)!=0);if(A=e,e=t[e+8>>2]|0,n||qA(A),e)n=0;else break}}function Dl(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0,$=0,U=0,BA=0,zA=0,QA=0,fe=0,he=0,Ee=0,ne=0,HA=0,SA=0,ve=0,Ve=0,de=0;if(o=e+8|0,t[o>>2]|0)return de=1,de|0;if(n=t[e>>2]|0,!n)return de=0,de|0;A=n,r=0;do r=r+1|0,A=t[A+8>>2]|0;while((A|0)!=0);if(r>>>0<2)return de=0,de|0;ve=p0(r<<2)|0,ve||OA(27396,27235,317,27415),SA=p0(r<<5)|0,SA||OA(27437,27235,321,27415),t[e>>2]=0,zA=e+4|0,t[zA>>2]=0,t[o>>2]=0,r=0,HA=0,BA=0,M=0;A:for(;;){if(m=t[n>>2]|0,m){i=0,s=m;do{if(a=+b[s+8>>3],A=s,s=t[s+16>>2]|0,f=(s|0)==0,o=f?m:s,l=+b[o+8>>3],+$A(+(a-l))>3.141592653589793){de=14;break}i=i+(l-a)*(+b[A>>3]+ +b[o>>3])}while(!f);if((de|0)==14){de=0,i=0,A=m;do U=+b[A+8>>3],ne=A+16|0,Ee=t[ne>>2]|0,Ee=(Ee|0)==0?m:Ee,$=+b[Ee+8>>3],i=i+(+b[A>>3]+ +b[Ee>>3])*(($<0?$+6.283185307179586:$)-(U<0?U+6.283185307179586:U)),A=t[((A|0)==0?n:ne)>>2]|0;while((A|0)!=0)}i>0?(t[ve+(HA<<2)>>2]=n,HA=HA+1|0,o=BA,A=M):de=19}else de=19;if((de|0)==19){de=0;do if(r){if(A=r+8|0,t[A>>2]|0){de=21;break A}if(r=Qt(1,12)|0,!r){de=23;break A}t[A>>2]=r,o=r+4|0,s=r,A=M}else if(M){o=zA,s=M+8|0,A=n,r=e;break}else if(t[e>>2]|0){de=27;break A}else{o=zA,s=e,A=n,r=e;break}while(!1);if(t[s>>2]=n,t[o>>2]=n,s=SA+(BA<<5)|0,f=t[n>>2]|0,f){for(m=SA+(BA<<5)+8|0,b[m>>3]=17976931348623157e292,M=SA+(BA<<5)+24|0,b[M>>3]=17976931348623157e292,b[s>>3]=-17976931348623157e292,j=SA+(BA<<5)+16|0,b[j>>3]=-17976931348623157e292,nA=17976931348623157e292,q=-17976931348623157e292,o=0,I=f,a=17976931348623157e292,G=17976931348623157e292,W=-17976931348623157e292,l=-17976931348623157e292;i=+b[I>>3],U=+b[I+8>>3],I=t[I+16>>2]|0,L=(I|0)==0,$=+b[(L?f:I)+8>>3],i>3]=i,a=i),U>3]=U,G=U),i>W?b[s>>3]=i:i=W,U>l&&(b[j>>3]=U,l=U),nA=U>0&Uq?U:q,o=o|+$A(+(U-$))>3.141592653589793,!L;)W=i;o&&(b[j>>3]=q,b[M>>3]=nA)}else t[s>>2]=0,t[s+4>>2]=0,t[s+8>>2]=0,t[s+12>>2]=0,t[s+16>>2]=0,t[s+20>>2]=0,t[s+24>>2]=0,t[s+28>>2]=0;o=BA+1|0}if(ne=n+8|0,n=t[ne>>2]|0,t[ne>>2]=0,n)BA=o,M=A;else{de=45;break}}if((de|0)==21)OA(27213,27235,35,27247);else if((de|0)==23)OA(27267,27235,37,27247);else if((de|0)==27)OA(27310,27235,61,27333);else if((de|0)==45){A:do if((HA|0)>0){for(ne=(o|0)==0,he=o<<2,Ee=(e|0)==0,fe=0,A=0;;){if(QA=t[ve+(fe<<2)>>2]|0,ne)de=73;else{if(BA=p0(he)|0,!BA){de=50;break}if(zA=p0(he)|0,!zA){de=52;break}e:do if(Ee)r=0;else{for(o=0,r=0,s=e;n=SA+(o<<5)|0,Jo(t[s>>2]|0,n,t[QA>>2]|0)|0?(t[BA+(r<<2)>>2]=s,t[zA+(r<<2)>>2]=n,L=r+1|0):L=r,s=t[s+8>>2]|0,s;)o=o+1|0,r=L;if((L|0)>0)if(n=t[BA>>2]|0,(L|0)==1)r=n;else for(j=0,I=-1,r=n,M=n;;){for(f=t[M>>2]|0,n=0,s=0;o=t[t[BA+(s<<2)>>2]>>2]|0,(o|0)==(f|0)?m=n:m=n+((Jo(o,t[zA+(s<<2)>>2]|0,t[f>>2]|0)|0)&1)|0,s=s+1|0,(s|0)!=(L|0);)n=m;if(o=(m|0)>(I|0),r=o?M:r,n=j+1|0,(n|0)==(L|0))break e;j=n,I=o?m:I,M=t[BA+(n<<2)>>2]|0}else r=0}while(!1);if(qA(BA),qA(zA),r){if(o=r+4|0,n=t[o>>2]|0,n)r=n+8|0;else if(t[r>>2]|0){de=70;break}t[r>>2]=QA,t[o>>2]=QA}else de=73}if((de|0)==73){if(de=0,A=t[QA>>2]|0,A|0)do zA=A,A=t[A+16>>2]|0,qA(zA);while((A|0)!=0);qA(QA),A=1}if(fe=fe+1|0,(fe|0)>=(HA|0)){Ve=A;break A}}(de|0)==50?OA(27452,27235,249,27471):(de|0)==52?OA(27490,27235,252,27471):(de|0)==70&&OA(27310,27235,61,27333)}else Ve=0;while(!1);return qA(ve),qA(SA),de=Ve,de|0}return 0}function Jo(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0;if(!(a0(A,r)|0)||(A=Ft(A)|0,n=+b[r>>3],o=+b[r+8>>3],o=A&o<0?o+6.283185307179586:o,e=t[e>>2]|0,!e))return e=0,e|0;if(A){A=0,f=o,r=e;A:for(;;){for(;s=+b[r>>3],o=+b[r+8>>3],r=r+16|0,m=t[r>>2]|0,m=(m|0)==0?e:m,i=+b[m>>3],l=+b[m+8>>3],s>i?(a=s,s=l):(a=i,i=s,s=o,o=l),n=n==i|n==a?n+2220446049250313e-31:n,!!(na);)if(r=t[r>>2]|0,!r){r=22;break A}if(l=s<0?s+6.283185307179586:s,s=o<0?o+6.283185307179586:o,f=l==f|s==f?f+-2220446049250313e-31:f,a=l+(s-l)*((n-i)/(a-i)),(a<0?a+6.283185307179586:a)>f&&(A=A^1),r=t[r>>2]|0,!r){r=22;break}}if((r|0)==22)return A|0}else{A=0,f=o,r=e;A:for(;;){for(;s=+b[r>>3],o=+b[r+8>>3],r=r+16|0,m=t[r>>2]|0,m=(m|0)==0?e:m,i=+b[m>>3],l=+b[m+8>>3],s>i?(a=s,s=l):(a=i,i=s,s=o,o=l),n=n==i|n==a?n+2220446049250313e-31:n,!!(na);)if(r=t[r>>2]|0,!r){r=22;break A}if(f=s==f|o==f?f+-2220446049250313e-31:f,s+(o-s)*((n-i)/(a-i))>f&&(A=A^1),r=t[r>>2]|0,!r){r=22;break}}if((r|0)==22)return A|0}return 0}function D0(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0;if(q=k,k=k+32|0,nA=q+16|0,W=q,i=wA(e|0,A|0,52)|0,S()|0,i=i&15,I=wA(r|0,n|0,52)|0,S()|0,(i|0)!=(I&15|0))return nA=12,k=q,nA|0;if(f=wA(e|0,A|0,45)|0,S()|0,f=f&127,m=wA(r|0,n|0,45)|0,S()|0,m=m&127,f>>>0>121|m>>>0>121)return nA=5,k=q,nA|0;if(I=(f|0)!=(m|0),I){if(l=or(f,m)|0,(l|0)==7)return nA=1,k=q,nA|0;a=or(m,f)|0,(a|0)==7?OA(27514,27538,161,27548):(L=l,s=a)}else L=0,s=0;M=Re(f)|0,j=Re(m)|0,t[nA>>2]=0,t[nA+4>>2]=0,t[nA+8>>2]=0,t[nA+12>>2]=0;do if(L){if(m=t[4272+(f*28|0)+(L<<2)>>2]|0,l=(m|0)>0,j)if(l){f=0,a=r,l=n;do a=al(a,l)|0,l=S()|0,s=Ut(s)|0,(s|0)==1&&(s=Ut(1)|0),f=f+1|0;while((f|0)!=(m|0));m=s,f=a,a=l}else m=s,f=r,a=n;else if(l){f=0,a=r,l=n;do a=Zn(a,l)|0,l=S()|0,s=Ut(s)|0,f=f+1|0;while((f|0)!=(m|0));m=s,f=a,a=l}else m=s,f=r,a=n;if(qn(f,a,nA)|0,I||OA(27563,27538,191,27548),l=(M|0)!=0,s=(j|0)!=0,l&s&&OA(27590,27538,192,27548),l){if(s=Pt(e,A)|0,(s|0)==7){i=5;break}if(xA[22e3+(s*7|0)+L>>0]|0){i=1;break}a=t[21168+(s*28|0)+(L<<2)>>2]|0,f=a}else if(s){if(s=Pt(f,a)|0,(s|0)==7){i=5;break}if(xA[22e3+(s*7|0)+m>>0]|0){i=1;break}f=0,a=t[21168+(m*28|0)+(s<<2)>>2]|0}else f=0,a=0;if((f|a|0)<0)i=5;else{if((a|0)>0){l=nA+4|0,s=0;do B0(l),s=s+1|0;while((s|0)!=(a|0))}if(t[W>>2]=0,t[W+4>>2]=0,t[W+8>>2]=0,gn(W,L),i|0)for(;Jt(i)|0?br(W):Ht(W),(i|0)>1;)i=i+-1|0;if((f|0)>0){i=0;do B0(W),i=i+1|0;while((i|0)!=(f|0))}G=nA+4|0,Ze(G,W,G),Me(G),G=51}}else if(qn(r,n,nA)|0,(M|0)!=0&(j|0)!=0)if((m|0)!=(f|0)&&OA(27621,27538,261,27548),s=Pt(e,A)|0,i=Pt(r,n)|0,(s|0)==7|(i|0)==7)i=5;else if(xA[22e3+(s*7|0)+i>>0]|0)i=1;else if(s=t[21168+(s*28|0)+(i<<2)>>2]|0,(s|0)>0){l=nA+4|0,i=0;do B0(l),i=i+1|0;while((i|0)!=(s|0));G=51}else G=51;else G=51;while(!1);return(G|0)==51&&(i=nA+4|0,t[o>>2]=t[i>>2],t[o+4>>2]=t[i+4>>2],t[o+8>>2]=t[i+8>>2],i=0),nA=i,k=q,nA|0}function Xo(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0,$=0;if(G=k,k=k+48|0,f=G+36|0,s=G+24|0,l=G+12|0,a=G,o=wA(e|0,A|0,52)|0,S()|0,o=o&15,j=wA(e|0,A|0,45)|0,S()|0,j=j&127,j>>>0>121)return n=5,k=G,n|0;if(m=Re(j)|0,EA(o|0,0,52)|0,W=S()|0|134225919,i=n,t[i>>2]=-1,t[i+4>>2]=W,!o)return o=St(r)|0,(o|0)==7||(o=nr(j,o)|0,(o|0)==127)?(W=1,k=G,W|0):(I=EA(o|0,0,45)|0,L=S()|0,j=n,L=t[j+4>>2]&-1040385|L,W=n,t[W>>2]=t[j>>2]|I,t[W+4>>2]=L,W=0,k=G,W|0);for(t[f>>2]=t[r>>2],t[f+4>>2]=t[r+4>>2],t[f+8>>2]=t[r+8>>2],r=o;;){if(i=r,r=r+-1|0,t[s>>2]=t[f>>2],t[s+4>>2]=t[f+4>>2],t[s+8>>2]=t[f+8>>2],Jt(i)|0){if(o=wr(f)|0,o|0){r=13;break}t[l>>2]=t[f>>2],t[l+4>>2]=t[f+4>>2],t[l+8>>2]=t[f+8>>2],br(l)}else{if(o=mn(f)|0,o|0){r=13;break}t[l>>2]=t[f>>2],t[l+4>>2]=t[f+4>>2],t[l+8>>2]=t[f+8>>2],Ht(l)}if(yt(s,l,a),Me(a),o=n,q=t[o>>2]|0,o=t[o+4>>2]|0,$=(15-i|0)*3|0,nA=EA(7,0,$|0)|0,o=o&~(S()|0),$=EA(St(a)|0,0,$|0)|0,o=S()|0|o,W=n,t[W>>2]=$|q&~nA,t[W+4>>2]=o,(i|0)<=1){r=14;break}}A:do if((r|0)!=13&&(r|0)==14)if((t[f>>2]|0)<=1&&(t[f+4>>2]|0)<=1&&(t[f+8>>2]|0)<=1){r=St(f)|0,o=nr(j,r)|0,(o|0)==127?a=0:a=Re(o)|0;e:do if(r){if(m){if(o=Pt(e,A)|0,(o|0)==7){o=5;break A}if(i=t[21376+(o*28|0)+(r<<2)>>2]|0,(i|0)>0){o=r,r=0;do o=Gt(o)|0,r=r+1|0;while((r|0)!=(i|0))}else o=r;if((o|0)==1){o=9;break A}r=nr(j,o)|0,(r|0)==127&&OA(27648,27538,411,27678),Re(r)|0?OA(27693,27538,412,27678):(L=r,I=i,M=o)}else L=o,I=0,M=r;if(l=t[4272+(j*28|0)+(M<<2)>>2]|0,(l|0)<=-1&&OA(27724,27538,419,27678),!a){if((I|0)<0){o=5;break A}if(I|0){i=n,o=0,r=t[i>>2]|0,i=t[i+4>>2]|0;do r=lr(r,i)|0,i=S()|0,$=n,t[$>>2]=r,t[$+4>>2]=i,o=o+1|0;while((o|0)<(I|0))}if((l|0)<=0){o=L,r=58;break}for(i=n,o=0,r=t[i>>2]|0,i=t[i+4>>2]|0;;)if(r=lr(r,i)|0,i=S()|0,$=n,t[$>>2]=r,t[$+4>>2]=i,o=o+1|0,(o|0)==(l|0)){o=L,r=58;break e}}if(s=or(L,j)|0,(s|0)==7&&OA(27514,27538,428,27678),o=n,r=t[o>>2]|0,o=t[o+4>>2]|0,(l|0)>0){i=0;do r=lr(r,o)|0,o=S()|0,$=n,t[$>>2]=r,t[$+4>>2]=o,i=i+1|0;while((i|0)!=(l|0))}if(o=Pt(r,o)|0,(o|0)==7&&OA(27795,27538,440,27678),r=Et(L)|0,r=t[(r?21792:21584)+(s*28|0)+(o<<2)>>2]|0,(r|0)<0&&OA(27795,27538,454,27678),!r)o=L,r=58;else{s=n,o=0,i=t[s>>2]|0,s=t[s+4>>2]|0;do i=Kn(i,s)|0,s=S()|0,$=n,t[$>>2]=i,t[$+4>>2]=s,o=o+1|0;while((o|0)<(r|0));o=L,r=58}}else if((m|0)!=0&(a|0)!=0){if(r=Pt(e,A)|0,i=n,i=Pt(t[i>>2]|0,t[i+4>>2]|0)|0,(r|0)==7|(i|0)==7){o=5;break A}if(i=t[21376+(r*28|0)+(i<<2)>>2]|0,(i|0)<0){o=5;break A}if(!i)r=59;else{l=n,r=0,s=t[l>>2]|0,l=t[l+4>>2]|0;do s=lr(s,l)|0,l=S()|0,$=n,t[$>>2]=s,t[$+4>>2]=l,r=r+1|0;while((r|0)<(i|0));r=58}}else r=58;while(!1);if((r|0)==58&&a&&(r=59),(r|0)==59&&($=n,(Pt(t[$>>2]|0,t[$+4>>2]|0)|0)==1)){o=9;break}$=n,nA=t[$>>2]|0,$=t[$+4>>2]&-1040385,q=EA(o|0,0,45)|0,$=$|(S()|0),o=n,t[o>>2]=nA|q,t[o+4>>2]=$,o=0}else o=1;while(!1);return $=o,k=G,$|0}function _l(e,A,r,n,o,i){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0,i=i|0;var s=0,l=0;return l=k,k=k+16|0,s=l,o?e=15:(e=D0(e,A,r,n,s)|0,e||($r(s,i),e=0)),k=l,e|0}function Tl(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0;return s=k,k=k+16|0,i=s,n?r=15:(r=Mt(r,i)|0,r||(r=Xo(e,A,i,o)|0)),k=s,r|0}function Rl(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0,a=0;return a=k,k=k+32|0,s=a+12|0,l=a,i=D0(e,A,e,A,s)|0,i|0?(l=i,k=a,l|0):(e=D0(e,A,r,n,l)|0,e|0?(l=e,k=a,l|0):(s=Er(s,l)|0,l=o,t[l>>2]=s,t[l+4>>2]=((s|0)<0)<<31>>31,l=0,k=a,l|0))}function jl(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0,a=0;return a=k,k=k+32|0,s=a+12|0,l=a,i=D0(e,A,e,A,s)|0,!i&&(i=D0(e,A,r,n,l)|0,!i)?(n=Er(s,l)|0,n=KA(n|0,((n|0)<0)<<31>>31|0,1,0)|0,s=S()|0,l=o,t[l>>2]=n,t[l+4>>2]=s,l=0,k=a,l|0):(l=i,k=a,l|0)}function Il(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0,$=0,U=0,BA=0,zA=0,QA=0,fe=0;if(QA=k,k=k+48|0,BA=QA+24|0,s=QA+12|0,zA=QA,i=D0(e,A,e,A,BA)|0,!i&&(i=D0(e,A,r,n,s)|0,!i)){$=Er(BA,s)|0,U=(($|0)<0)<<31>>31,t[BA>>2]=0,t[BA+4>>2]=0,t[BA+8>>2]=0,t[s>>2]=0,t[s+4>>2]=0,t[s+8>>2]=0,D0(e,A,e,A,BA)|0&&OA(27795,27538,692,27747),D0(e,A,r,n,s)|0&&OA(27795,27538,697,27747),qr(BA),qr(s),m=($|0)==0?0:1/+($|0),r=t[BA>>2]|0,G=m*+((t[s>>2]|0)-r|0),W=BA+4|0,n=t[W>>2]|0,nA=m*+((t[s+4>>2]|0)-n|0),q=BA+8|0,i=t[q>>2]|0,m=m*+((t[s+8>>2]|0)-i|0),t[zA>>2]=r,M=zA+4|0,t[M>>2]=n,j=zA+8|0,t[j>>2]=i;A:do if(($|0)<0)i=0;else for(I=0,L=0;;){a=+(L>>>0)+4294967296*+(I|0),fe=G*a+ +(r|0),l=nA*a+ +(n|0),a=m*a+ +(i|0),r=~~+En(+fe),s=~~+En(+l),i=~~+En(+a),fe=+$A(+(+(r|0)-fe)),l=+$A(+(+(s|0)-l)),a=+$A(+(+(i|0)-a));do if(fe>l&fe>a)r=0-(s+i)|0,n=s;else if(f=0-r|0,l>a){n=f-i|0;break}else{n=s,i=f-s|0;break}while(!1);if(t[zA>>2]=r,t[M>>2]=n,t[j>>2]=i,Jr(zA),i=Xo(e,A,zA,o+(L<<3)|0)|0,i|0)break A;if(!((I|0)<(U|0)|(I|0)==(U|0)&L>>>0<$>>>0)){i=0;break A}r=KA(L|0,I|0,1,0)|0,n=S()|0,I=n,L=r,r=t[BA>>2]|0,n=t[W>>2]|0,i=t[q>>2]|0}while(!1);return zA=i,k=QA,zA|0}return zA=i,k=QA,zA|0}function U0(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0;if((r|0)==0&(n|0)==0)return o=0,i=1,YA(o|0),i|0;i=e,o=A,e=1,A=0;do s=(r&1|0)==0&!0,e=ft((s?1:i)|0,(s?0:o)|0,e|0,A|0)|0,A=S()|0,r=fi(r|0,n|0,1)|0,n=S()|0,i=ft(i|0,o|0,i|0,o|0)|0,o=S()|0;while(!((r|0)==0&(n|0)==0));return YA(A|0),e|0}function to(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0;l=k,k=k+16|0,i=l,s=wA(e|0,A|0,52)|0,S()|0,s=s&15;do if(s){if(o=ar(e,A,i)|0,!o){f=+b[i>>3],a=1/+_e(+f),m=+b[25968+(s<<3)>>3],b[r>>3]=f+m,b[r+8>>3]=f-m,f=+b[i+8>>3],a=m*a,b[r+16>>3]=a+f,b[r+24>>3]=f-a;break}return s=o,k=l,s|0}else{if(o=wA(e|0,A|0,45)|0,S()|0,o=o&127,o>>>0>121)return s=5,k=l,s|0;i=22064+(o<<5)|0,t[r>>2]=t[i>>2],t[r+4>>2]=t[i+4>>2],t[r+8>>2]=t[i+8>>2],t[r+12>>2]=t[i+12>>2],t[r+16>>2]=t[i+16>>2],t[r+20>>2]=t[i+20>>2],t[r+24>>2]=t[i+24>>2],t[r+28>>2]=t[i+28>>2];break}while(!1);return VA(r,n?1.4:1.1),n=26096+(s<<3)|0,(t[n>>2]|0)==(e|0)&&(t[n+4>>2]|0)==(A|0)&&(b[r>>3]=1.5707963267948966),s=26224+(s<<3)|0,(t[s>>2]|0)==(e|0)&&(t[s+4>>2]|0)==(A|0)&&(b[r+8>>3]=-1.5707963267948966),+b[r>>3]!=1.5707963267948966&&+b[r+8>>3]!=-1.5707963267948966?(s=0,k=l,s|0):(b[r+16>>3]=3.141592653589793,b[r+24>>3]=-3.141592653589793,s=0,k=l,s|0)}function Ll(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0;f=k,k=k+48|0,s=f+32|0,i=f+40|0,l=f,Dt(s,0,0,0),a=t[s>>2]|0,s=t[s+4>>2]|0;do if(r>>>0<=15){if(o=on(n)|0,o|0){n=l,t[n>>2]=0,t[n+4>>2]=0,t[l+8>>2]=o,t[l+12>>2]=-1,n=l+16|0,a=l+29|0,t[n>>2]=0,t[n+4>>2]=0,t[n+8>>2]=0,xA[n+12>>0]=0,xA[a>>0]=xA[i>>0]|0,xA[a+1>>0]=xA[i+1>>0]|0,xA[a+2>>0]=xA[i+2>>0]|0;break}if(o=Qt((t[A+8>>2]|0)+1|0,32)|0,o){ro(A,o),m=l,t[m>>2]=a,t[m+4>>2]=s,t[l+8>>2]=0,t[l+12>>2]=r,t[l+16>>2]=n,t[l+20>>2]=A,t[l+24>>2]=o,xA[l+28>>0]=0,a=l+29|0,xA[a>>0]=xA[i>>0]|0,xA[a+1>>0]=xA[i+1>>0]|0,xA[a+2>>0]=xA[i+2>>0]|0;break}else{n=l,t[n>>2]=0,t[n+4>>2]=0,t[l+8>>2]=13,t[l+12>>2]=-1,n=l+16|0,a=l+29|0,t[n>>2]=0,t[n+4>>2]=0,t[n+8>>2]=0,xA[n+12>>0]=0,xA[a>>0]=xA[i>>0]|0,xA[a+1>>0]=xA[i+1>>0]|0,xA[a+2>>0]=xA[i+2>>0]|0;break}}else a=l,t[a>>2]=0,t[a+4>>2]=0,t[l+8>>2]=4,t[l+12>>2]=-1,a=l+16|0,m=l+29|0,t[a>>2]=0,t[a+4>>2]=0,t[a+8>>2]=0,xA[a+12>>0]=0,xA[m>>0]=xA[i>>0]|0,xA[m+1>>0]=xA[i+1>>0]|0,xA[m+2>>0]=xA[i+2>>0]|0;while(!1);kn(l),t[e>>2]=t[l>>2],t[e+4>>2]=t[l+4>>2],t[e+8>>2]=t[l+8>>2],t[e+12>>2]=t[l+12>>2],t[e+16>>2]=t[l+16>>2],t[e+20>>2]=t[l+20>>2],t[e+24>>2]=t[l+24>>2],t[e+28>>2]=t[l+28>>2],k=f}function kn(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0,$=0,U=0;if(U=k,k=k+336|0,I=U+168|0,L=U,n=e,r=t[n>>2]|0,n=t[n+4>>2]|0,(r|0)==0&(n|0)==0){k=U;return}if(A=e+28|0,xA[A>>0]|0?(r=Ai(r,n)|0,n=S()|0):xA[A>>0]=1,$=e+20|0,!(t[t[$>>2]>>2]|0)){A=e+24|0,r=t[A>>2]|0,r|0&&qA(r),q=e,t[q>>2]=0,t[q+4>>2]=0,t[e+8>>2]=0,t[$>>2]=0,t[e+12>>2]=-1,t[e+16>>2]=0,t[A>>2]=0,k=U;return}q=e+16|0,A=t[q>>2]|0,o=A&15;A:do if((r|0)==0&(n|0)==0)nA=e+24|0;else{G=e+12|0,M=(o|0)==3,m=A&255,a=(o|1|0)==3,j=e+24|0,f=(o+-1|0)>>>0<3,s=(o|2|0)==3,l=L+8|0;e:for(;;){if(i=wA(r|0,n|0,52)|0,S()|0,i=i&15,(i|0)==(t[G>>2]|0)){switch(m&15){case 0:case 2:case 3:{if(o=ar(r,n,I)|0,o|0){W=15;break e}if(no(t[$>>2]|0,t[j>>2]|0,I)|0){W=19;break e}break}}if(a&&(o=t[(t[$>>2]|0)+4>>2]|0,t[I>>2]=t[o>>2],t[I+4>>2]=t[o+4>>2],t[I+8>>2]=t[o+8>>2],t[I+12>>2]=t[o+12>>2],a0(26832,I)|0)){if($n(t[(t[$>>2]|0)+4>>2]|0,i,L)|0){W=25;break}if(o=L,(t[o>>2]|0)==(r|0)&&(t[o+4>>2]|0)==(n|0)){W=29;break}}if(f){if(o=_r(r,n,I)|0,o|0){W=32;break}if(to(r,n,L,0)|0){W=36;break}if(s&&ti(t[$>>2]|0,t[j>>2]|0,I,L)|0){W=42;break}if(a&&ri(t[$>>2]|0,t[j>>2]|0,I,L)|0){W=42;break}}if(M){if(A=to(r,n,I,1)|0,o=t[j>>2]|0,A|0){W=45;break}if(Ne(o,I)|0){if(lA(L,I),z(I,t[j>>2]|0)|0){W=53;break}if(no(t[$>>2]|0,t[j>>2]|0,l)|0){W=53;break}if(ri(t[$>>2]|0,t[j>>2]|0,L,I)|0){W=53;break}}}}do if((i|0)<(t[G>>2]|0)){if(A=to(r,n,I,1)|0,o=t[j>>2]|0,A|0){W=58;break e}if(!(Ne(o,I)|0)){W=73;break}if(z(t[j>>2]|0,I)|0&&(lA(L,I),ti(t[$>>2]|0,t[j>>2]|0,L,I)|0)){W=65;break e}if(r=Wo(r,n,i+1|0,L)|0,r|0){W=67;break e}n=L,r=t[n>>2]|0,n=t[n+4>>2]|0}else W=73;while(!1);if((W|0)==73&&(W=0,r=Ai(r,n)|0,n=S()|0),(r|0)==0&(n|0)==0){nA=j;break A}}switch(W|0){case 15:{A=t[j>>2]|0,A|0&&qA(A),W=e,t[W>>2]=0,t[W+4>>2]=0,t[$>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[j>>2]=0,t[e+8>>2]=o,W=20;break}case 19:{t[e>>2]=r,t[e+4>>2]=n,W=20;break}case 25:{OA(27795,27761,470,27772);break}case 29:{t[e>>2]=r,t[e+4>>2]=n,k=U;return}case 32:{A=t[j>>2]|0,A|0&&qA(A),nA=e,t[nA>>2]=0,t[nA+4>>2]=0,t[$>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[j>>2]=0,t[e+8>>2]=o,k=U;return}case 36:{OA(27795,27761,493,27772);break}case 42:{t[e>>2]=r,t[e+4>>2]=n,k=U;return}case 45:{o|0&&qA(o),W=e,t[W>>2]=0,t[W+4>>2]=0,t[$>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[j>>2]=0,t[e+8>>2]=A,W=55;break}case 53:{t[e>>2]=r,t[e+4>>2]=n,W=55;break}case 58:{o|0&&qA(o),W=e,t[W>>2]=0,t[W+4>>2]=0,t[$>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[j>>2]=0,t[e+8>>2]=A,W=71;break}case 65:{t[e>>2]=r,t[e+4>>2]=n,W=71;break}case 67:{A=t[j>>2]|0,A|0&&qA(A),nA=e,t[nA>>2]=0,t[nA+4>>2]=0,t[$>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[j>>2]=0,t[e+8>>2]=r,k=U;return}}if((W|0)==20){k=U;return}else if((W|0)==55){k=U;return}else if((W|0)==71){k=U;return}}while(!1);A=t[nA>>2]|0,A|0&&qA(A),W=e,t[W>>2]=0,t[W+4>>2]=0,t[e+8>>2]=0,t[$>>2]=0,t[e+12>>2]=-1,t[q>>2]=0,t[nA>>2]=0,k=U}function Ai(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0;M=k,k=k+16|0,m=M,n=wA(e|0,A|0,52)|0,S()|0,n=n&15,r=wA(e|0,A|0,45)|0,S()|0;do if(n){for(;r=EA(n+4095|0,0,52)|0,o=S()|0|A&-15728641,i=(15-n|0)*3|0,s=EA(7,0,i|0)|0,l=S()|0,r=r|e|s,o=o|l,a=wA(e|0,A|0,i|0)|0,S()|0,a=a&7,n=n+-1|0,!(a>>>0<6);)if(n)A=o,e=r;else{f=4;break}if((f|0)==4){r=wA(r|0,o|0,45)|0,S()|0;break}return m=(a|0)==0&(Oe(r,o)|0)!=0,m=EA((m?2:1)+a|0,0,i|0)|0,f=S()|0|A&~l,m=m|e&~s,YA(f|0),k=M,m|0}while(!1);return r=r&127,r>>>0>120?(f=0,m=0,YA(f|0),k=M,m|0):(Dt(m,0,r+1|0,0),f=t[m+4>>2]|0,m=t[m>>2]|0,YA(f|0),k=M,m|0)}function Nl(e,A,r,n,o,i){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0,i=i|0;var s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0;W=k,k=k+160|0,M=W+80|0,l=W+64|0,j=W+112|0,G=W,Ll(M,e,A,r),f=M,Xn(l,t[f>>2]|0,t[f+4>>2]|0,A),f=l,a=t[f>>2]|0,f=t[f+4>>2]|0,s=t[M+8>>2]|0,I=j+4|0,t[I>>2]=t[M>>2],t[I+4>>2]=t[M+4>>2],t[I+8>>2]=t[M+8>>2],t[I+12>>2]=t[M+12>>2],t[I+16>>2]=t[M+16>>2],t[I+20>>2]=t[M+20>>2],t[I+24>>2]=t[M+24>>2],t[I+28>>2]=t[M+28>>2],I=G,t[I>>2]=a,t[I+4>>2]=f,I=G+8|0,t[I>>2]=s,e=G+12|0,A=j,r=e+36|0;do t[e>>2]=t[A>>2],e=e+4|0,A=A+4|0;while((e|0)<(r|0));if(j=G+48|0,t[j>>2]=t[l>>2],t[j+4>>2]=t[l+4>>2],t[j+8>>2]=t[l+8>>2],t[j+12>>2]=t[l+12>>2],(a|0)==0&(f|0)==0)return G=s,k=W,G|0;r=G+16|0,m=G+24|0,M=G+28|0,s=0,l=0,A=a,e=f;do{if(!((s|0)<(o|0)|(s|0)==(o|0)&l>>>0>>0)){L=4;break}if(f=l,l=KA(l|0,s|0,1,0)|0,s=S()|0,f=i+(f<<3)|0,t[f>>2]=A,t[f+4>>2]=e,Ao(j),e=j,A=t[e>>2]|0,e=t[e+4>>2]|0,(A|0)==0&(e|0)==0){if(kn(r),A=r,e=t[A>>2]|0,A=t[A+4>>2]|0,(e|0)==0&(A|0)==0){L=10;break}Ko(e,A,t[M>>2]|0,j),e=j,A=t[e>>2]|0,e=t[e+4>>2]|0}f=G,t[f>>2]=A,t[f+4>>2]=e}while(!((A|0)==0&(e|0)==0));return(L|0)==4?(e=G+40|0,A=t[e>>2]|0,A|0&&qA(A),L=G+16|0,t[L>>2]=0,t[L+4>>2]=0,t[m>>2]=0,t[G+36>>2]=0,t[M>>2]=-1,t[G+32>>2]=0,t[e>>2]=0,Ko(0,0,0,j),t[G>>2]=0,t[G+4>>2]=0,t[I>>2]=0,G=14,k=W,G|0):((L|0)==10&&(t[G>>2]=0,t[G+4>>2]=0,t[I>>2]=t[m>>2]),G=t[I>>2]|0,k=W,G|0)}function Fl(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0;if(M=k,k=k+48|0,a=M+32|0,l=M+40|0,f=M,!(t[e>>2]|0))return m=n,t[m>>2]=0,t[m+4>>2]=0,m=0,k=M,m|0;Dt(a,0,0,0),s=a,o=t[s>>2]|0,s=t[s+4>>2]|0;do if(A>>>0>15)m=f,t[m>>2]=0,t[m+4>>2]=0,t[f+8>>2]=4,t[f+12>>2]=-1,m=f+16|0,r=f+29|0,t[m>>2]=0,t[m+4>>2]=0,t[m+8>>2]=0,xA[m+12>>0]=0,xA[r>>0]=xA[l>>0]|0,xA[r+1>>0]=xA[l+1>>0]|0,xA[r+2>>0]=xA[l+2>>0]|0,r=4,m=9;else{if(r=on(r)|0,r|0){a=f,t[a>>2]=0,t[a+4>>2]=0,t[f+8>>2]=r,t[f+12>>2]=-1,a=f+16|0,m=f+29|0,t[a>>2]=0,t[a+4>>2]=0,t[a+8>>2]=0,xA[a+12>>0]=0,xA[m>>0]=xA[l>>0]|0,xA[m+1>>0]=xA[l+1>>0]|0,xA[m+2>>0]=xA[l+2>>0]|0,m=9;break}if(r=Qt((t[e+8>>2]|0)+1|0,32)|0,!r){m=f,t[m>>2]=0,t[m+4>>2]=0,t[f+8>>2]=13,t[f+12>>2]=-1,m=f+16|0,r=f+29|0,t[m>>2]=0,t[m+4>>2]=0,t[m+8>>2]=0,xA[m+12>>0]=0,xA[r>>0]=xA[l>>0]|0,xA[r+1>>0]=xA[l+1>>0]|0,xA[r+2>>0]=xA[l+2>>0]|0,r=13,m=9;break}ro(e,r),I=f,t[I>>2]=o,t[I+4>>2]=s,s=f+8|0,t[s>>2]=0,t[f+12>>2]=A,t[f+20>>2]=e,t[f+24>>2]=r,xA[f+28>>0]=0,o=f+29|0,xA[o>>0]=xA[l>>0]|0,xA[o+1>>0]=xA[l+1>>0]|0,xA[o+2>>0]=xA[l+2>>0]|0,t[f+16>>2]=3,j=+ir(r),j=j*+Yr(r),i=+$A(+ +b[r>>3]),i=j/+_e(+ +Cn(+i,+ +$A(+ +b[r+8>>3])))*6371.007180918475*6371.007180918475,o=f+12|0,r=t[o>>2]|0;A:do if((r|0)>0)do{if(Zo(r+-1|0,a)|0,!(i/+b[a>>3]>10))break A;I=t[o>>2]|0,r=I+-1|0,t[o>>2]=r}while((I|0)>1);while(!1);if(kn(f),o=n,t[o>>2]=0,t[o+4>>2]=0,o=f,r=t[o>>2]|0,o=t[o+4>>2]|0,!((r|0)==0&(o|0)==0))do g0(r,o,A,a)|0,l=a,e=n,l=KA(t[e>>2]|0,t[e+4>>2]|0,t[l>>2]|0,t[l+4>>2]|0)|0,e=S()|0,I=n,t[I>>2]=l,t[I+4>>2]=e,kn(f),I=f,r=t[I>>2]|0,o=t[I+4>>2]|0;while(!((r|0)==0&(o|0)==0));r=t[s>>2]|0}while(!1);return I=r,k=M,I|0}function nn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0;if(!(a0(A,r)|0)||(A=Ft(A)|0,n=+b[r>>3],o=+b[r+8>>3],o=A&o<0?o+6.283185307179586:o,j=t[e>>2]|0,(j|0)<=0))return j=0,j|0;if(M=t[e+4>>2]|0,A){A=0,m=o,r=-1,e=0;A:for(;;){for(f=e;s=+b[M+(f<<4)>>3],o=+b[M+(f<<4)+8>>3],e=(r+2|0)%(j|0)|0,i=+b[M+(e<<4)>>3],l=+b[M+(e<<4)+8>>3],s>i?(a=s,s=l):(a=i,i=s,s=o,o=l),n=n==i|n==a?n+2220446049250313e-31:n,!!(na);)if(r=f+1|0,(r|0)>=(j|0)){r=22;break A}else e=f,f=r,r=e;if(l=s<0?s+6.283185307179586:s,s=o<0?o+6.283185307179586:o,m=l==m|s==m?m+-2220446049250313e-31:m,a=l+(s-l)*((n-i)/(a-i)),(a<0?a+6.283185307179586:a)>m&&(A=A^1),e=f+1|0,(e|0)>=(j|0)){r=22;break}else r=f}if((r|0)==22)return A|0}else{A=0,m=o,r=-1,e=0;A:for(;;){for(f=e;s=+b[M+(f<<4)>>3],o=+b[M+(f<<4)+8>>3],e=(r+2|0)%(j|0)|0,i=+b[M+(e<<4)>>3],l=+b[M+(e<<4)+8>>3],s>i?(a=s,s=l):(a=i,i=s,s=o,o=l),n=n==i|n==a?n+2220446049250313e-31:n,!!(na);)if(r=f+1|0,(r|0)>=(j|0)){r=22;break A}else e=f,f=r,r=e;if(m=s==m|o==m?m+-2220446049250313e-31:m,s+(o-s)*((n-i)/(a-i))>m&&(A=A^1),e=f+1|0,(e|0)>=(j|0)){r=22;break}else r=f}if((r|0)==22)return A|0}return 0}function ei(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0;if(L=t[e>>2]|0,!L){t[A>>2]=0,t[A+4>>2]=0,t[A+8>>2]=0,t[A+12>>2]=0,t[A+16>>2]=0,t[A+20>>2]=0,t[A+24>>2]=0,t[A+28>>2]=0;return}if(G=A+8|0,b[G>>3]=17976931348623157e292,W=A+24|0,b[W>>3]=17976931348623157e292,b[A>>3]=-17976931348623157e292,nA=A+16|0,b[nA>>3]=-17976931348623157e292,!((L|0)<=0)){for(j=t[e+4>>2]|0,f=17976931348623157e292,m=-17976931348623157e292,M=0,e=-1,i=17976931348623157e292,s=17976931348623157e292,a=-17976931348623157e292,n=-17976931348623157e292,I=0;r=+b[j+(I<<4)>>3],l=+b[j+(I<<4)+8>>3],e=e+2|0,o=+b[j+(((e|0)==(L|0)?0:e)<<4)+8>>3],r>3]=r,i=r),l>3]=l,s=l),r>a?b[A>>3]=r:r=a,l>n&&(b[nA>>3]=l,n=l),f=l>0&lm?l:m,M=M|+$A(+(l-o))>3.141592653589793,e=I+1|0,(e|0)!=(L|0);)q=I,a=r,I=e,e=q;M&&(b[nA>>3]=m,b[W>>3]=f)}}function on(e){return e=e|0,(e>>>0<4?0:15)|0}function ro(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0,$=0,U=0,BA=0,zA=0,QA=0;if(L=t[e>>2]|0,L){if(G=A+8|0,b[G>>3]=17976931348623157e292,W=A+24|0,b[W>>3]=17976931348623157e292,b[A>>3]=-17976931348623157e292,nA=A+16|0,b[nA>>3]=-17976931348623157e292,(L|0)>0){for(o=t[e+4>>2]|0,j=17976931348623157e292,I=-17976931348623157e292,n=0,r=-1,a=17976931348623157e292,f=17976931348623157e292,M=-17976931348623157e292,s=-17976931348623157e292,q=0;i=+b[o+(q<<4)>>3],m=+b[o+(q<<4)+8>>3],zA=r+2|0,l=+b[o+(((zA|0)==(L|0)?0:zA)<<4)+8>>3],i>3]=i,a=i),m>3]=m,f=m),i>M?b[A>>3]=i:i=M,m>s&&(b[nA>>3]=m,s=m),j=m>0&mI?m:I,n=n|+$A(+(m-l))>3.141592653589793,r=q+1|0,(r|0)!=(L|0);)zA=q,M=i,q=r,r=zA;n&&(b[nA>>3]=I,b[W>>3]=j)}}else t[A>>2]=0,t[A+4>>2]=0,t[A+8>>2]=0,t[A+12>>2]=0,t[A+16>>2]=0,t[A+20>>2]=0,t[A+24>>2]=0,t[A+28>>2]=0;if(zA=e+8|0,r=t[zA>>2]|0,!((r|0)<=0)){BA=e+12|0,U=0;do if(o=t[BA>>2]|0,n=U,U=U+1|0,W=A+(U<<5)|0,nA=t[o+(n<<3)>>2]|0,nA){if(q=A+(U<<5)+8|0,b[q>>3]=17976931348623157e292,e=A+(U<<5)+24|0,b[e>>3]=17976931348623157e292,b[W>>3]=-17976931348623157e292,$=A+(U<<5)+16|0,b[$>>3]=-17976931348623157e292,(nA|0)>0){for(L=t[o+(n<<3)+4>>2]|0,j=17976931348623157e292,I=-17976931348623157e292,o=0,n=-1,G=0,a=17976931348623157e292,f=17976931348623157e292,m=-17976931348623157e292,s=-17976931348623157e292;i=+b[L+(G<<4)>>3],M=+b[L+(G<<4)+8>>3],n=n+2|0,l=+b[L+(((n|0)==(nA|0)?0:n)<<4)+8>>3],i>3]=i,a=i),M>3]=M,f=M),i>m?b[W>>3]=i:i=m,M>s&&(b[$>>3]=M,s=M),j=M>0&MI?M:I,o=o|+$A(+(M-l))>3.141592653589793,n=G+1|0,(n|0)!=(nA|0);)QA=G,G=n,m=i,n=QA;o&&(b[$>>3]=I,b[e>>3]=j)}}else t[W>>2]=0,t[W+4>>2]=0,t[W+8>>2]=0,t[W+12>>2]=0,t[W+16>>2]=0,t[W+20>>2]=0,t[W+24>>2]=0,t[W+28>>2]=0,r=t[zA>>2]|0;while((U|0)<(r|0))}}function no(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0;if(!(nn(e,A,r)|0))return o=0,o|0;if(o=e+8|0,(t[o>>2]|0)<=0)return o=1,o|0;for(n=e+12|0,e=0;;){if(i=e,e=e+1|0,nn((t[n>>2]|0)+(i<<3)|0,A+(e<<5)|0,r)|0){e=0,n=6;break}if((e|0)>=(t[o>>2]|0)){e=1,n=6;break}}return(n|0)==6?e|0:0}function ti(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0;if(f=k,k=k+16|0,l=f,s=r+8|0,!(nn(e,A,s)|0))return a=0,k=f,a|0;a=e+8|0;A:do if((t[a>>2]|0)>0){for(i=e+12|0,o=0;;){if(m=o,o=o+1|0,nn((t[i>>2]|0)+(m<<3)|0,A+(o<<5)|0,s)|0){o=0;break}if((o|0)>=(t[a>>2]|0))break A}return k=f,o|0}while(!1);if(bn(e,A,r,n)|0)return m=0,k=f,m|0;t[l>>2]=t[r>>2],t[l+4>>2]=s,o=t[a>>2]|0;A:do if((o|0)>0)for(e=e+12|0,s=0,i=o;;){if(o=t[e>>2]|0,(t[o+(s<<3)>>2]|0)>0){if(nn(l,n,t[o+(s<<3)+4>>2]|0)|0){o=0;break A}if(o=s+1|0,bn((t[e>>2]|0)+(s<<3)|0,A+(o<<5)|0,r,n)|0){o=0;break A}i=t[a>>2]|0}else o=s+1|0;if((o|0)<(i|0))s=o;else{o=1;break}}else o=1;while(!1);return m=o,k=f,m|0}function bn(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0,$=0,U=0,BA=0,zA=0,QA=0,fe=0;if(zA=k,k=k+176|0,q=zA+172|0,o=zA+168|0,$=zA,!(Ne(A,n)|0))return e=0,k=zA,e|0;if(M0(A,n,q,o),Ir($|0,r|0,168)|0,(t[r>>2]|0)>0){A=0;do QA=$+8+(A<<4)+8|0,nA=+Vt(+b[QA>>3],t[o>>2]|0),b[QA>>3]=nA,A=A+1|0;while((A|0)<(t[r>>2]|0))}G=+b[n>>3],W=+b[n+8>>3],nA=+Vt(+b[n+16>>3],t[o>>2]|0),I=+Vt(+b[n+24>>3],t[o>>2]|0);A:do if((t[e>>2]|0)>0){if(n=e+4|0,o=t[$>>2]|0,(o|0)<=0){for(A=0;;)if(A=A+1|0,(A|0)>=(t[e>>2]|0)){A=0;break A}}for(r=0;;){if(A=t[n>>2]|0,j=+b[A+(r<<4)>>3],L=+Vt(+b[A+(r<<4)+8>>3],t[q>>2]|0),A=t[n>>2]|0,r=r+1|0,QA=(r|0)%(t[e>>2]|0)|0,i=+b[A+(QA<<4)>>3],s=+Vt(+b[A+(QA<<4)+8>>3],t[q>>2]|0),!(j>=G)|!(i>=G)&&!(j<=W)|!(i<=W)&&!(L<=I)|!(s<=I)&&!(L>=nA)|!(s>=nA)){M=i-j,f=s-L,A=0;do if(fe=A,A=A+1|0,QA=(A|0)==(o|0)?0:A,i=+b[$+8+(fe<<4)+8>>3],s=+b[$+8+(QA<<4)+8>>3]-i,l=+b[$+8+(fe<<4)>>3],a=+b[$+8+(QA<<4)>>3]-l,m=M*s-f*a,m!=0&&(U=L-i,BA=j-l,a=(U*a-s*BA)/m,!(a<0|a>1))&&(m=(M*U-f*BA)/m,m>=0&m<=1)){A=1;break A}while((A|0)<(o|0))}if((r|0)>=(t[e>>2]|0)){A=0;break}}}else A=0;while(!1);return fe=A,k=zA,fe|0}function ri(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0;if(bn(e,A,r,n)|0)return i=1,i|0;if(i=e+8|0,(t[i>>2]|0)<=0)return i=0,i|0;for(o=e+12|0,e=0;;){if(s=e,e=e+1|0,bn((t[o>>2]|0)+(s<<3)|0,A+(e<<5)|0,r,n)|0){e=1,o=6;break}if((e|0)>=(t[i>>2]|0)){e=0,o=6;break}}return(o|0)==6?e|0:0}function Pl(){return 8}function Ql(){return 16}function Ol(){return 168}function zl(){return 8}function Hl(){return 16}function Gl(){return 12}function Ul(){return 8}function Vl(e){return e=e|0,+(+((t[e>>2]|0)>>>0)+4294967296*+(t[e+4>>2]|0))}function Wl(e){e=e|0;var A=0,r=0;return r=+b[e>>3],A=+b[e+8>>3],+ +ye(+(r*r+A*A))}function ni(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0;f=+b[e>>3],a=+b[A>>3]-f,l=+b[e+8>>3],s=+b[A+8>>3]-l,M=+b[r>>3],i=+b[n>>3]-M,j=+b[r+8>>3],m=+b[n+8>>3]-j,i=(i*(l-j)-(f-M)*m)/(a*m-s*i),b[o>>3]=f+a*i,b[o+8>>3]=l+s*i}function oi(e,A){return e=e|0,A=A|0,+$A(+(+b[e>>3]-+b[A>>3]))<11920928955078125e-23?(A=+$A(+(+b[e+8>>3]-+b[A+8>>3]))<11920928955078125e-23,A|0):(A=0,A|0)}function it(e,A){e=e|0,A=A|0;var r=0,n=0,o=0;return o=+b[e>>3]-+b[A>>3],n=+b[e+8>>3]-+b[A+8>>3],r=+b[e+16>>3]-+b[A+16>>3],+(o*o+n*n+r*r)}function Yl(e,A){e=e|0,A=A|0;var r=0,n=0,o=0;r=+b[e>>3],n=+_e(+r),r=+ie(+r),b[A+16>>3]=r,r=+b[e+8>>3],o=n*+_e(+r),b[A>>3]=o,r=n*+ie(+r),b[A+8>>3]=r}function Kl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0;if(i=k,k=k+16|0,o=i,n=Oe(e,A)|0,(r+-1|0)>>>0>5||(n=(n|0)!=0,(r|0)==1&n))return o=-1,k=i,o|0;do if(sn(e,A,o)|0)n=-1;else if(n){n=((t[26352+(r<<2)>>2]|0)+5-(t[o>>2]|0)|0)%5|0;break}else{n=((t[26384+(r<<2)>>2]|0)+6-(t[o>>2]|0)|0)%6|0;break}while(!1);return o=n,k=i,o|0}function sn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0;if(m=k,k=k+32|0,l=m+16|0,a=m,n=Dr(e,A,l)|0,n|0)return r=n,k=m,r|0;i=te(e,A)|0,f=Pt(e,A)|0,H0(i,a),n=qt(i,t[l>>2]|0)|0;do if(Re(i)|0){do switch(i|0){case 4:{o=0;break}case 14:{o=1;break}case 24:{o=2;break}case 38:{o=3;break}case 49:{o=4;break}case 58:{o=5;break}case 63:{o=6;break}case 72:{o=7;break}case 83:{o=8;break}case 97:{o=9;break}case 107:{o=10;break}case 117:{o=11;break}default:OA(27795,27797,75,27806)}while(!1);if(s=t[26416+(o*24|0)+8>>2]|0,A=t[26416+(o*24|0)+16>>2]|0,e=t[l>>2]|0,(e|0)!=(t[a>>2]|0)&&(a=Et(i)|0,e=t[l>>2]|0,a|(e|0)==(A|0)&&(n=(n+1|0)%6|0)),(f|0)==3&(e|0)==(A|0)){n=(n+5|0)%6|0;break}(f|0)==5&(e|0)==(s|0)&&(n=(n+1|0)%6|0)}while(!1);return t[r>>2]=n,r=0,k=m,r|0}function Xt(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0,$=0;if($=k,k=k+32|0,q=$+24|0,W=$+20|0,L=$+8|0,I=$+16|0,j=$,a=(Oe(e,A)|0)==0,a=a?6:5,m=wA(e|0,A|0,52)|0,S()|0,m=m&15,a>>>0<=r>>>0)return n=2,k=$,n|0;M=(m|0)==0,!M&&(G=EA(7,0,(m^15)*3|0)|0,(G&e|0)==0&((S()|0)&A|0)==0)?o=r:i=4;A:do if((i|0)==4){if(o=(Oe(e,A)|0)!=0,((o?4:5)|0)<(r|0)||sn(e,A,q)|0||(i=(t[q>>2]|0)+r|0,o?o=26704+(((i|0)%5|0)<<2)|0:o=26736+(((i|0)%6|0)<<2)|0,G=t[o>>2]|0,(G|0)==7))return n=1,k=$,n|0;t[W>>2]=0,o=Y(e,A,G,W,L)|0;do if(!o){if(l=L,f=t[l>>2]|0,l=t[l+4>>2]|0,s=l>>>0>>0|(l|0)==(A|0)&f>>>0>>0,i=s?f:e,s=s?l:A,!M&&(M=EA(7,0,(m^15)*3|0)|0,(f&M|0)==0&(l&(S()|0)|0)==0))o=r;else{if(l=(r+-1+a|0)%(a|0)|0,o=Oe(e,A)|0,(l|0)<0&&OA(27795,27797,248,27822),a=(o|0)!=0,((a?4:5)|0)<(l|0)&&OA(27795,27797,248,27822),sn(e,A,q)|0&&OA(27795,27797,248,27822),o=(t[q>>2]|0)+l|0,a?o=26704+(((o|0)%5|0)<<2)|0:o=26736+(((o|0)%6|0)<<2)|0,l=t[o>>2]|0,(l|0)==7&&OA(27795,27797,248,27822),t[I>>2]=0,o=Y(e,A,l,I,j)|0,o|0)break;f=j,a=t[f>>2]|0,f=t[f+4>>2]|0;do if(f>>>0>>0|(f|0)==(s|0)&a>>>0>>0){if(Oe(a,f)|0?i=Ae(a,f,e,A)|0:i=t[26800+((((t[I>>2]|0)+(t[26768+(l<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,o=Oe(a,f)|0,(i+-1|0)>>>0>5){o=-1,i=a,s=f;break}if(o=(o|0)!=0,(i|0)==1&o){o=-1,i=a,s=f;break}do if(sn(a,f,q)|0)o=-1;else if(o){o=((t[26352+(i<<2)>>2]|0)+5-(t[q>>2]|0)|0)%5|0;break}else{o=((t[26384+(i<<2)>>2]|0)+6-(t[q>>2]|0)|0)%6|0;break}while(!1);i=a,s=f}else o=r;while(!1);l=L,f=t[l>>2]|0,l=t[l+4>>2]|0}if((i|0)==(f|0)&(s|0)==(l|0)){if(a=(Oe(f,l)|0)!=0,a?e=Ae(f,l,e,A)|0:e=t[26800+((((t[W>>2]|0)+(t[26768+(G<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,o=Oe(f,l)|0,(e+-1|0)>>>0<=5&&(nA=(o|0)!=0,!((e|0)==1&nA)))do if(sn(f,l,q)|0)o=-1;else if(nA){o=((t[26352+(e<<2)>>2]|0)+5-(t[q>>2]|0)|0)%5|0;break}else{o=((t[26384+(e<<2)>>2]|0)+6-(t[q>>2]|0)|0)%6|0;break}while(!1);else o=-1;o=o+1|0,o=(o|0)==6|a&(o|0)==5?0:o}A=s,e=i;break A}while(!1);return n=o,k=$,n|0}while(!1);return nA=EA(o|0,0,56)|0,q=S()|0|A&-2130706433|536870912,t[n>>2]=nA|e,t[n+4>>2]=q,n=0,k=$,n|0}function Zl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0;return i=(Oe(e,A)|0)==0,n=Xt(e,A,0,r)|0,o=(n|0)==0,i?!o||(n=Xt(e,A,1,r+8|0)|0,n|0)||(n=Xt(e,A,2,r+16|0)|0,n|0)||(n=Xt(e,A,3,r+24|0)|0,n|0)||(n=Xt(e,A,4,r+32|0)|0,n)?(i=n,i|0):Xt(e,A,5,r+40|0)|0:!o||(n=Xt(e,A,1,r+8|0)|0,n|0)||(n=Xt(e,A,2,r+16|0)|0,n|0)||(n=Xt(e,A,3,r+24|0)|0,n|0)||(n=Xt(e,A,4,r+32|0)|0,n|0)?(i=n,i|0):(i=r+40|0,t[i>>2]=0,t[i+4>>2]=0,i=0,i|0)}function $l(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0;return a=k,k=k+192|0,o=a,i=a+168|0,s=wA(e|0,A|0,56)|0,S()|0,s=s&7,l=A&-2130706433|134217728,n=Dr(e,l,i)|0,n|0?(l=n,k=a,l|0):(A=wA(e|0,A|0,52)|0,S()|0,A=A&15,Oe(e,l)|0?w(i,A,s,1,o):AA(i,A,s,1,o),l=o+8|0,t[r>>2]=t[l>>2],t[r+4>>2]=t[l+4>>2],t[r+8>>2]=t[l+8>>2],t[r+12>>2]=t[l+12>>2],l=0,k=a,l|0)}function ii(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0;return o=k,k=k+16|0,r=o,!(!0&(A&2013265920|0)==536870912)||(n=A&-2130706433|134217728,!(Ue(e,n)|0))?(n=0,k=o,n|0):(i=wA(e|0,A|0,56)|0,S()|0,i=(Xt(e,n,i&7,r)|0)==0,n=r,n=i&((t[n>>2]|0)==(e|0)?(t[n+4>>2]|0)==(A|0):0)&1,k=o,n|0)}function si(e,A,r){e=e|0,A=A|0,r=r|0;var n=0;(A|0)>0?(n=Qt(A,4)|0,t[e>>2]=n,n||OA(27835,27858,40,27872)):t[e>>2]=0,t[e+4>>2]=A,t[e+8>>2]=0,t[e+12>>2]=r}function li(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0;o=e+4|0,i=e+12|0,s=e+8|0;A:for(;;){for(r=t[o>>2]|0,A=0;;){if((A|0)>=(r|0))break A;if(n=t[e>>2]|0,l=t[n+(A<<2)>>2]|0,!l)A=A+1|0;else break}A=n+(~~(+$A(+(+lt(10,+ +(15-(t[i>>2]|0)|0))*(+b[l>>3]+ +b[l+8>>3])))%+(r|0))>>>0<<2)|0,r=t[A>>2]|0;e:do if(r|0){if(n=l+32|0,(r|0)==(l|0))t[A>>2]=t[n>>2];else{if(r=r+32|0,A=t[r>>2]|0,!A)break;for(;(A|0)!=(l|0);)if(r=A+32|0,A=t[r>>2]|0,!A)break e;t[r>>2]=t[n>>2]}qA(l),t[s>>2]=(t[s>>2]|0)+-1}while(!1)}qA(t[e>>2]|0)}function ai(e){e=e|0;var A=0,r=0,n=0;for(n=t[e+4>>2]|0,r=0;;){if((r|0)>=(n|0)){A=0,r=4;break}if(A=t[(t[e>>2]|0)+(r<<2)>>2]|0,!A)r=r+1|0;else{r=4;break}}return(r|0)==4?A|0:0}function ui(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0;if(r=~~(+$A(+(+lt(10,+ +(15-(t[e+12>>2]|0)|0))*(+b[A>>3]+ +b[A+8>>3])))%+(t[e+4>>2]|0))>>>0,r=(t[e>>2]|0)+(r<<2)|0,n=t[r>>2]|0,!n)return i=1,i|0;i=A+32|0;do if((n|0)!=(A|0)){if(r=t[n+32>>2]|0,!r)return i=1,i|0;for(o=r;;){if((o|0)==(A|0)){o=8;break}if(r=t[o+32>>2]|0,r)n=o,o=r;else{r=1,o=10;break}}if((o|0)==8){t[n+32>>2]=t[i>>2];break}else if((o|0)==10)return r|0}else t[r>>2]=t[i>>2];while(!1);return qA(A),i=e+8|0,t[i>>2]=(t[i>>2]|0)+-1,i=0,i|0}function ql(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0;i=p0(40)|0,i||OA(27888,27858,98,27901),t[i>>2]=t[A>>2],t[i+4>>2]=t[A+4>>2],t[i+8>>2]=t[A+8>>2],t[i+12>>2]=t[A+12>>2],o=i+16|0,t[o>>2]=t[r>>2],t[o+4>>2]=t[r+4>>2],t[o+8>>2]=t[r+8>>2],t[o+12>>2]=t[r+12>>2],t[i+32>>2]=0,o=~~(+$A(+(+lt(10,+ +(15-(t[e+12>>2]|0)|0))*(+b[A>>3]+ +b[A+8>>3])))%+(t[e+4>>2]|0))>>>0,o=(t[e>>2]|0)+(o<<2)|0,n=t[o>>2]|0;do if(!n)t[o>>2]=i;else{for(;!(Tr(n,A)|0&&Tr(n+16|0,r)|0);)if(o=t[n+32>>2]|0,n=(o|0)==0?n:o,!(t[n+32>>2]|0)){s=10;break}if((s|0)==10){t[n+32>>2]=i;break}return qA(i),s=n,s|0}while(!1);return s=e+8|0,t[s>>2]=(t[s>>2]|0)+1,s=i,s|0}function Jl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0;if(o=~~(+$A(+(+lt(10,+ +(15-(t[e+12>>2]|0)|0))*(+b[A>>3]+ +b[A+8>>3])))%+(t[e+4>>2]|0))>>>0,o=t[(t[e>>2]|0)+(o<<2)>>2]|0,!o)return r=0,r|0;if(!r){for(e=o;;){if(Tr(e,A)|0){n=10;break}if(e=t[e+32>>2]|0,!e){e=0,n=10;break}}if((n|0)==10)return e|0}for(e=o;;){if(Tr(e,A)|0&&Tr(e+16|0,r)|0){n=10;break}if(e=t[e+32>>2]|0,!e){e=0,n=10;break}}return(n|0)==10?e|0:0}function Xl(e,A){e=e|0,A=A|0;var r=0;if(r=~~(+$A(+(+lt(10,+ +(15-(t[e+12>>2]|0)|0))*(+b[A>>3]+ +b[A+8>>3])))%+(t[e+4>>2]|0))>>>0,e=t[(t[e>>2]|0)+(r<<2)>>2]|0,!e)return r=0,r|0;for(;;){if(Tr(e,A)|0){A=5;break}if(e=t[e+32>>2]|0,!e){e=0,A=5;break}}return(A|0)==5?e|0:0}function Aa(){return 27920}function V0(e){return e=+e,~~+di(+e)|0}function p0(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0,$=0,U=0,BA=0;BA=k,k=k+16|0,j=BA;do if(e>>>0<245){if(f=e>>>0<11?16:e+11&-8,e=f>>>3,M=t[6981]|0,r=M>>>e,r&3|0)return A=(r&1^1)+e|0,e=27964+(A<<1<<2)|0,r=e+8|0,n=t[r>>2]|0,o=n+8|0,i=t[o>>2]|0,(i|0)==(e|0)?t[6981]=M&~(1<>2]=e,t[r>>2]=i),U=A<<3,t[n+4>>2]=U|3,U=n+U+4|0,t[U>>2]=t[U>>2]|1,U=o,k=BA,U|0;if(m=t[6983]|0,f>>>0>m>>>0){if(r|0)return A=2<>>12&16,A=A>>>l,r=A>>>5&8,A=A>>>r,i=A>>>2&4,A=A>>>i,e=A>>>1&2,A=A>>>e,n=A>>>1&1,n=(r|l|i|e|n)+(A>>>n)|0,A=27964+(n<<1<<2)|0,e=A+8|0,i=t[e>>2]|0,l=i+8|0,r=t[l>>2]|0,(r|0)==(A|0)?(e=M&~(1<>2]=A,t[e>>2]=r,e=M),U=n<<3,s=U-f|0,t[i+4>>2]=f|3,o=i+f|0,t[o+4>>2]=s|1,t[i+U>>2]=s,m|0&&(n=t[6986]|0,A=m>>>3,r=27964+(A<<1<<2)|0,A=1<>2]|0):(t[6981]=e|A,A=r,e=r+8|0),t[e>>2]=n,t[A+12>>2]=n,t[n+8>>2]=A,t[n+12>>2]=r),t[6983]=s,t[6986]=o,U=l,k=BA,U|0;if(i=t[6982]|0,i){for(r=(i&0-i)+-1|0,o=r>>>12&16,r=r>>>o,n=r>>>5&8,r=r>>>n,s=r>>>2&4,r=r>>>s,l=r>>>1&2,r=r>>>l,a=r>>>1&1,a=t[28228+((n|o|s|l|a)+(r>>>a)<<2)>>2]|0,r=a,l=a,a=(t[a+4>>2]&-8)-f|0;e=t[r+16>>2]|0,!(!e&&(e=t[r+20>>2]|0,!e));)s=(t[e+4>>2]&-8)-f|0,o=s>>>0>>0,r=e,l=o?e:l,a=o?s:a;if(s=l+f|0,s>>>0>l>>>0){o=t[l+24>>2]|0,A=t[l+12>>2]|0;do if((A|0)==(l|0)){if(e=l+20|0,A=t[e>>2]|0,!A&&(e=l+16|0,A=t[e>>2]|0,!A)){r=0;break}for(;;)if(n=A+20|0,r=t[n>>2]|0,r)A=r,e=n;else if(n=A+16|0,r=t[n>>2]|0,r)A=r,e=n;else break;t[e>>2]=0,r=A}else r=t[l+8>>2]|0,t[r+12>>2]=A,t[A+8>>2]=r,r=A;while(!1);do if(o|0){if(A=t[l+28>>2]|0,e=28228+(A<<2)|0,(l|0)==(t[e>>2]|0)){if(t[e>>2]=r,!r){t[6982]=i&~(1<>2]|0)==(l|0)?U:o+20|0)>>2]=r,!r)break;t[r+24>>2]=o,A=t[l+16>>2]|0,A|0&&(t[r+16>>2]=A,t[A+24>>2]=r),A=t[l+20>>2]|0,A|0&&(t[r+20>>2]=A,t[A+24>>2]=r)}while(!1);return a>>>0<16?(U=a+f|0,t[l+4>>2]=U|3,U=l+U+4|0,t[U>>2]=t[U>>2]|1):(t[l+4>>2]=f|3,t[s+4>>2]=a|1,t[s+a>>2]=a,m|0&&(n=t[6986]|0,A=m>>>3,r=27964+(A<<1<<2)|0,A=1<>2]|0):(t[6981]=A|M,A=r,e=r+8|0),t[e>>2]=n,t[A+12>>2]=n,t[n+8>>2]=A,t[n+12>>2]=r),t[6983]=a,t[6986]=s),U=l+8|0,k=BA,U|0}else M=f}else M=f}else M=f}else if(e>>>0<=4294967231)if(e=e+11|0,f=e&-8,n=t[6982]|0,n){o=0-f|0,e=e>>>8,e?f>>>0>16777215?a=31:(M=(e+1048320|0)>>>16&8,G=e<>>16&4,G=G<>>16&2,a=14-(l|M|a)+(G<>>15)|0,a=f>>>(a+7|0)&1|a<<1):a=0,r=t[28228+(a<<2)>>2]|0;A:do if(!r)r=0,e=0,G=61;else for(e=0,l=f<<((a|0)==31?0:25-(a>>>1)|0),i=0;;){if(s=(t[r+4>>2]&-8)-f|0,s>>>0>>0)if(s)e=r,o=s;else{e=r,o=0,G=65;break A}if(G=t[r+20>>2]|0,r=t[r+16+(l>>>31<<2)>>2]|0,i=(G|0)==0|(G|0)==(r|0)?i:G,r)l=l<<1;else{r=i,G=61;break}}while(!1);if((G|0)==61){if((r|0)==0&(e|0)==0){if(e=2<>>12&16,M=M>>>s,i=M>>>5&8,M=M>>>i,l=M>>>2&4,M=M>>>l,a=M>>>1&2,M=M>>>a,r=M>>>1&1,e=0,r=t[28228+((i|s|l|a|r)+(M>>>r)<<2)>>2]|0}r?G=65:(l=e,s=o)}if((G|0)==65)for(i=r;;)if(M=(t[i+4>>2]&-8)-f|0,r=M>>>0>>0,o=r?M:o,e=r?i:e,r=t[i+16>>2]|0,r||(r=t[i+20>>2]|0),r)i=r;else{l=e,s=o;break}if((l|0)!=0&&s>>>0<((t[6983]|0)-f|0)>>>0&&(m=l+f|0,m>>>0>l>>>0)){i=t[l+24>>2]|0,A=t[l+12>>2]|0;do if((A|0)==(l|0)){if(e=l+20|0,A=t[e>>2]|0,!A&&(e=l+16|0,A=t[e>>2]|0,!A)){A=0;break}for(;;)if(o=A+20|0,r=t[o>>2]|0,r)A=r,e=o;else if(o=A+16|0,r=t[o>>2]|0,r)A=r,e=o;else break;t[e>>2]=0}else U=t[l+8>>2]|0,t[U+12>>2]=A,t[A+8>>2]=U;while(!1);do if(i){if(e=t[l+28>>2]|0,r=28228+(e<<2)|0,(l|0)==(t[r>>2]|0)){if(t[r>>2]=A,!A){n=n&~(1<>2]|0)==(l|0)?U:i+20|0)>>2]=A,!A)break;t[A+24>>2]=i,e=t[l+16>>2]|0,e|0&&(t[A+16>>2]=e,t[e+24>>2]=A),e=t[l+20>>2]|0,e&&(t[A+20>>2]=e,t[e+24>>2]=A)}while(!1);A:do if(s>>>0<16)U=s+f|0,t[l+4>>2]=U|3,U=l+U+4|0,t[U>>2]=t[U>>2]|1;else{if(t[l+4>>2]=f|3,t[m+4>>2]=s|1,t[m+s>>2]=s,A=s>>>3,s>>>0<256){r=27964+(A<<1<<2)|0,e=t[6981]|0,A=1<>2]|0):(t[6981]=e|A,A=r,e=r+8|0),t[e>>2]=m,t[A+12>>2]=m,t[m+8>>2]=A,t[m+12>>2]=r;break}if(A=s>>>8,A?s>>>0>16777215?r=31:($=(A+1048320|0)>>>16&8,U=A<<$,q=(U+520192|0)>>>16&4,U=U<>>16&2,r=14-(q|$|r)+(U<>>15)|0,r=s>>>(r+7|0)&1|r<<1):r=0,A=28228+(r<<2)|0,t[m+28>>2]=r,e=m+16|0,t[e+4>>2]=0,t[e>>2]=0,e=1<>2]=m,t[m+24>>2]=A,t[m+12>>2]=m,t[m+8>>2]=m;break}A=t[A>>2]|0;e:do if((t[A+4>>2]&-8|0)!=(s|0)){for(n=s<<((r|0)==31?0:25-(r>>>1)|0);r=A+16+(n>>>31<<2)|0,e=t[r>>2]|0,!!e;)if((t[e+4>>2]&-8|0)==(s|0)){A=e;break e}else n=n<<1,A=e;t[r>>2]=m,t[m+24>>2]=A,t[m+12>>2]=m,t[m+8>>2]=m;break A}while(!1);$=A+8|0,U=t[$>>2]|0,t[U+12>>2]=m,t[$>>2]=m,t[m+8>>2]=U,t[m+12>>2]=A,t[m+24>>2]=0}while(!1);return U=l+8|0,k=BA,U|0}else M=f}else M=f;else M=-1;while(!1);if(r=t[6983]|0,r>>>0>=M>>>0)return A=r-M|0,e=t[6986]|0,A>>>0>15?(U=e+M|0,t[6986]=U,t[6983]=A,t[U+4>>2]=A|1,t[e+r>>2]=A,t[e+4>>2]=M|3):(t[6983]=0,t[6986]=0,t[e+4>>2]=r|3,U=e+r+4|0,t[U>>2]=t[U>>2]|1),U=e+8|0,k=BA,U|0;if(s=t[6984]|0,s>>>0>M>>>0)return q=s-M|0,t[6984]=q,U=t[6987]|0,$=U+M|0,t[6987]=$,t[$+4>>2]=q|1,t[U+4>>2]=M|3,U=U+8|0,k=BA,U|0;if(t[7099]|0?e=t[7101]|0:(t[7101]=4096,t[7100]=4096,t[7102]=-1,t[7103]=-1,t[7104]=0,t[7092]=0,t[7099]=j&-16^1431655768,e=4096),l=M+48|0,a=M+47|0,i=e+a|0,o=0-e|0,f=i&o,f>>>0<=M>>>0||(e=t[7091]|0,e|0&&(m=t[7089]|0,j=m+f|0,j>>>0<=m>>>0|j>>>0>e>>>0)))return U=0,k=BA,U|0;A:do if(t[7092]&4)A=0,G=143;else{r=t[6987]|0;e:do if(r){for(n=28372;j=t[n>>2]|0,!(j>>>0<=r>>>0&&(j+(t[n+4>>2]|0)|0)>>>0>r>>>0);)if(e=t[n+8>>2]|0,e)n=e;else{G=128;break e}if(A=i-s&o,A>>>0<2147483647)if(e=K0(A|0)|0,(e|0)==((t[n>>2]|0)+(t[n+4>>2]|0)|0)){if((e|0)!=-1){s=A,i=e,G=145;break A}}else n=e,G=136;else A=0}else G=128;while(!1);do if((G|0)==128)if(r=K0(0)|0,(r|0)!=-1&&(A=r,I=t[7100]|0,L=I+-1|0,A=((L&A|0)==0?0:(L+A&0-I)-A|0)+f|0,I=t[7089]|0,L=A+I|0,A>>>0>M>>>0&A>>>0<2147483647)){if(j=t[7091]|0,j|0&&L>>>0<=I>>>0|L>>>0>j>>>0){A=0;break}if(e=K0(A|0)|0,(e|0)==(r|0)){s=A,i=r,G=145;break A}else n=e,G=136}else A=0;while(!1);do if((G|0)==136){if(r=0-A|0,!(l>>>0>A>>>0&(A>>>0<2147483647&(n|0)!=-1)))if((n|0)==-1){A=0;break}else{s=A,i=n,G=145;break A}if(e=t[7101]|0,e=a-A+e&0-e,e>>>0>=2147483647){s=A,i=n,G=145;break A}if((K0(e|0)|0)==-1){K0(r|0)|0,A=0;break}else{s=e+A|0,i=n,G=145;break A}}while(!1);t[7092]=t[7092]|4,G=143}while(!1);if((G|0)==143&&f>>>0<2147483647&&(q=K0(f|0)|0,L=K0(0)|0,W=L-q|0,nA=W>>>0>(M+40|0)>>>0,!((q|0)==-1|nA^1|q>>>0>>0&((q|0)!=-1&(L|0)!=-1)^1))&&(s=nA?W:A,i=q,G=145),(G|0)==145){A=(t[7089]|0)+s|0,t[7089]=A,A>>>0>(t[7090]|0)>>>0&&(t[7090]=A),a=t[6987]|0;A:do if(a){for(A=28372;;){if(e=t[A>>2]|0,r=t[A+4>>2]|0,(i|0)==(e+r|0)){G=154;break}if(n=t[A+8>>2]|0,n)A=n;else break}if((G|0)==154&&($=A+4|0,(t[A+12>>2]&8|0)==0)&&i>>>0>a>>>0&e>>>0<=a>>>0){t[$>>2]=r+s,U=(t[6984]|0)+s|0,q=a+8|0,q=(q&7|0)==0?0:0-q&7,$=a+q|0,q=U-q|0,t[6987]=$,t[6984]=q,t[$+4>>2]=q|1,t[a+U+4>>2]=40,t[6988]=t[7103];break}for(i>>>0<(t[6985]|0)>>>0&&(t[6985]=i),r=i+s|0,A=28372;;){if((t[A>>2]|0)==(r|0)){G=162;break}if(e=t[A+8>>2]|0,e)A=e;else break}if((G|0)==162&&(t[A+12>>2]&8|0)==0){t[A>>2]=i,m=A+4|0,t[m>>2]=(t[m>>2]|0)+s,m=i+8|0,m=i+((m&7|0)==0?0:0-m&7)|0,A=r+8|0,A=r+((A&7|0)==0?0:0-A&7)|0,f=m+M|0,l=A-m-M|0,t[m+4>>2]=M|3;e:do if((a|0)==(A|0))U=(t[6984]|0)+l|0,t[6984]=U,t[6987]=f,t[f+4>>2]=U|1;else{if((t[6986]|0)==(A|0)){U=(t[6983]|0)+l|0,t[6983]=U,t[6986]=f,t[f+4>>2]=U|1,t[f+U>>2]=U;break}if(e=t[A+4>>2]|0,(e&3|0)==1){s=e&-8,n=e>>>3;t:do if(e>>>0<256)if(e=t[A+8>>2]|0,r=t[A+12>>2]|0,(r|0)==(e|0)){t[6981]=t[6981]&~(1<>2]=r,t[r+8>>2]=e;break}else{i=t[A+24>>2]|0,e=t[A+12>>2]|0;do if((e|0)==(A|0)){if(r=A+16|0,n=r+4|0,e=t[n>>2]|0,e)r=n;else if(e=t[r>>2]|0,!e){e=0;break}for(;;)if(o=e+20|0,n=t[o>>2]|0,n)e=n,r=o;else if(o=e+16|0,n=t[o>>2]|0,n)e=n,r=o;else break;t[r>>2]=0}else U=t[A+8>>2]|0,t[U+12>>2]=e,t[e+8>>2]=U;while(!1);if(!i)break;r=t[A+28>>2]|0,n=28228+(r<<2)|0;do if((t[n>>2]|0)!=(A|0)){if(U=i+16|0,t[((t[U>>2]|0)==(A|0)?U:i+20|0)>>2]=e,!e)break t}else{if(t[n>>2]=e,e|0)break;t[6982]=t[6982]&~(1<>2]=i,r=A+16|0,n=t[r>>2]|0,n|0&&(t[e+16>>2]=n,t[n+24>>2]=e),r=t[r+4>>2]|0,!r)break;t[e+20>>2]=r,t[r+24>>2]=e}while(!1);A=A+s|0,o=s+l|0}else o=l;if(A=A+4|0,t[A>>2]=t[A>>2]&-2,t[f+4>>2]=o|1,t[f+o>>2]=o,A=o>>>3,o>>>0<256){r=27964+(A<<1<<2)|0,e=t[6981]|0,A=1<>2]|0):(t[6981]=e|A,A=r,e=r+8|0),t[e>>2]=f,t[A+12>>2]=f,t[f+8>>2]=A,t[f+12>>2]=r;break}A=o>>>8;do if(!A)n=0;else{if(o>>>0>16777215){n=31;break}$=(A+1048320|0)>>>16&8,U=A<<$,q=(U+520192|0)>>>16&4,U=U<>>16&2,n=14-(q|$|n)+(U<>>15)|0,n=o>>>(n+7|0)&1|n<<1}while(!1);if(A=28228+(n<<2)|0,t[f+28>>2]=n,e=f+16|0,t[e+4>>2]=0,t[e>>2]=0,e=t[6982]|0,r=1<>2]=f,t[f+24>>2]=A,t[f+12>>2]=f,t[f+8>>2]=f;break}A=t[A>>2]|0;t:do if((t[A+4>>2]&-8|0)!=(o|0)){for(n=o<<((n|0)==31?0:25-(n>>>1)|0);r=A+16+(n>>>31<<2)|0,e=t[r>>2]|0,!!e;)if((t[e+4>>2]&-8|0)==(o|0)){A=e;break t}else n=n<<1,A=e;t[r>>2]=f,t[f+24>>2]=A,t[f+12>>2]=f,t[f+8>>2]=f;break e}while(!1);$=A+8|0,U=t[$>>2]|0,t[U+12>>2]=f,t[$>>2]=f,t[f+8>>2]=U,t[f+12>>2]=A,t[f+24>>2]=0}while(!1);return U=m+8|0,k=BA,U|0}for(A=28372;e=t[A>>2]|0,!(e>>>0<=a>>>0&&(U=e+(t[A+4>>2]|0)|0,U>>>0>a>>>0));)A=t[A+8>>2]|0;o=U+-47|0,e=o+8|0,e=o+((e&7|0)==0?0:0-e&7)|0,o=a+16|0,e=e>>>0>>0?a:e,A=e+8|0,r=s+-40|0,q=i+8|0,q=(q&7|0)==0?0:0-q&7,$=i+q|0,q=r-q|0,t[6987]=$,t[6984]=q,t[$+4>>2]=q|1,t[i+r+4>>2]=40,t[6988]=t[7103],r=e+4|0,t[r>>2]=27,t[A>>2]=t[7093],t[A+4>>2]=t[7094],t[A+8>>2]=t[7095],t[A+12>>2]=t[7096],t[7093]=i,t[7094]=s,t[7096]=0,t[7095]=A,A=e+24|0;do $=A,A=A+4|0,t[A>>2]=7;while(($+8|0)>>>0>>0);if((e|0)!=(a|0)){if(i=e-a|0,t[r>>2]=t[r>>2]&-2,t[a+4>>2]=i|1,t[e>>2]=i,A=i>>>3,i>>>0<256){r=27964+(A<<1<<2)|0,e=t[6981]|0,A=1<>2]|0):(t[6981]=e|A,A=r,e=r+8|0),t[e>>2]=a,t[A+12>>2]=a,t[a+8>>2]=A,t[a+12>>2]=r;break}if(A=i>>>8,A?i>>>0>16777215?n=31:($=(A+1048320|0)>>>16&8,U=A<<$,q=(U+520192|0)>>>16&4,U=U<>>16&2,n=14-(q|$|n)+(U<>>15)|0,n=i>>>(n+7|0)&1|n<<1):n=0,r=28228+(n<<2)|0,t[a+28>>2]=n,t[a+20>>2]=0,t[o>>2]=0,A=t[6982]|0,e=1<>2]=a,t[a+24>>2]=r,t[a+12>>2]=a,t[a+8>>2]=a;break}A=t[r>>2]|0;e:do if((t[A+4>>2]&-8|0)!=(i|0)){for(n=i<<((n|0)==31?0:25-(n>>>1)|0);r=A+16+(n>>>31<<2)|0,e=t[r>>2]|0,!!e;)if((t[e+4>>2]&-8|0)==(i|0)){A=e;break e}else n=n<<1,A=e;t[r>>2]=a,t[a+24>>2]=A,t[a+12>>2]=a,t[a+8>>2]=a;break A}while(!1);$=A+8|0,U=t[$>>2]|0,t[U+12>>2]=a,t[$>>2]=a,t[a+8>>2]=U,t[a+12>>2]=A,t[a+24>>2]=0}}else U=t[6985]|0,(U|0)==0|i>>>0>>0&&(t[6985]=i),t[7093]=i,t[7094]=s,t[7096]=0,t[6990]=t[7099],t[6989]=-1,t[6994]=27964,t[6993]=27964,t[6996]=27972,t[6995]=27972,t[6998]=27980,t[6997]=27980,t[7e3]=27988,t[6999]=27988,t[7002]=27996,t[7001]=27996,t[7004]=28004,t[7003]=28004,t[7006]=28012,t[7005]=28012,t[7008]=28020,t[7007]=28020,t[7010]=28028,t[7009]=28028,t[7012]=28036,t[7011]=28036,t[7014]=28044,t[7013]=28044,t[7016]=28052,t[7015]=28052,t[7018]=28060,t[7017]=28060,t[7020]=28068,t[7019]=28068,t[7022]=28076,t[7021]=28076,t[7024]=28084,t[7023]=28084,t[7026]=28092,t[7025]=28092,t[7028]=28100,t[7027]=28100,t[7030]=28108,t[7029]=28108,t[7032]=28116,t[7031]=28116,t[7034]=28124,t[7033]=28124,t[7036]=28132,t[7035]=28132,t[7038]=28140,t[7037]=28140,t[7040]=28148,t[7039]=28148,t[7042]=28156,t[7041]=28156,t[7044]=28164,t[7043]=28164,t[7046]=28172,t[7045]=28172,t[7048]=28180,t[7047]=28180,t[7050]=28188,t[7049]=28188,t[7052]=28196,t[7051]=28196,t[7054]=28204,t[7053]=28204,t[7056]=28212,t[7055]=28212,U=s+-40|0,q=i+8|0,q=(q&7|0)==0?0:0-q&7,$=i+q|0,q=U-q|0,t[6987]=$,t[6984]=q,t[$+4>>2]=q|1,t[i+U+4>>2]=40,t[6988]=t[7103];while(!1);if(A=t[6984]|0,A>>>0>M>>>0)return q=A-M|0,t[6984]=q,U=t[6987]|0,$=U+M|0,t[6987]=$,t[$+4>>2]=q|1,t[U+4>>2]=M|3,U=U+8|0,k=BA,U|0}return U=Aa()|0,t[U>>2]=12,U=0,k=BA,U|0}function qA(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0,a=0;if(e){r=e+-8|0,o=t[6985]|0,e=t[e+-4>>2]|0,A=e&-8,a=r+A|0;do if(e&1)l=r,s=r;else{if(n=t[r>>2]|0,!(e&3)||(s=r+(0-n)|0,i=n+A|0,s>>>0>>0))return;if((t[6986]|0)==(s|0)){if(e=a+4|0,A=t[e>>2]|0,(A&3|0)!=3){l=s,A=i;break}t[6983]=i,t[e>>2]=A&-2,t[s+4>>2]=i|1,t[s+i>>2]=i;return}if(r=n>>>3,n>>>0<256)if(e=t[s+8>>2]|0,A=t[s+12>>2]|0,(A|0)==(e|0)){t[6981]=t[6981]&~(1<>2]=A,t[A+8>>2]=e,l=s,A=i;break}o=t[s+24>>2]|0,e=t[s+12>>2]|0;do if((e|0)==(s|0)){if(A=s+16|0,r=A+4|0,e=t[r>>2]|0,e)A=r;else if(e=t[A>>2]|0,!e){e=0;break}for(;;)if(n=e+20|0,r=t[n>>2]|0,r)e=r,A=n;else if(n=e+16|0,r=t[n>>2]|0,r)e=r,A=n;else break;t[A>>2]=0}else l=t[s+8>>2]|0,t[l+12>>2]=e,t[e+8>>2]=l;while(!1);if(o){if(A=t[s+28>>2]|0,r=28228+(A<<2)|0,(t[r>>2]|0)==(s|0)){if(t[r>>2]=e,!e){t[6982]=t[6982]&~(1<>2]|0)==(s|0)?l:o+20|0)>>2]=e,!e){l=s,A=i;break}t[e+24>>2]=o,A=s+16|0,r=t[A>>2]|0,r|0&&(t[e+16>>2]=r,t[r+24>>2]=e),A=t[A+4>>2]|0,A?(t[e+20>>2]=A,t[A+24>>2]=e,l=s,A=i):(l=s,A=i)}else l=s,A=i}while(!1);if(!(s>>>0>=a>>>0)&&(e=a+4|0,n=t[e>>2]|0,!!(n&1))){if(n&2)t[e>>2]=n&-2,t[l+4>>2]=A|1,t[s+A>>2]=A,o=A;else{if((t[6987]|0)==(a|0)){if(a=(t[6984]|0)+A|0,t[6984]=a,t[6987]=l,t[l+4>>2]=a|1,(l|0)!=(t[6986]|0))return;t[6986]=0,t[6983]=0;return}if((t[6986]|0)==(a|0)){a=(t[6983]|0)+A|0,t[6983]=a,t[6986]=s,t[l+4>>2]=a|1,t[s+a>>2]=a;return}o=(n&-8)+A|0,r=n>>>3;do if(n>>>0<256)if(A=t[a+8>>2]|0,e=t[a+12>>2]|0,(e|0)==(A|0)){t[6981]=t[6981]&~(1<>2]=e,t[e+8>>2]=A;break}else{i=t[a+24>>2]|0,e=t[a+12>>2]|0;do if((e|0)==(a|0)){if(A=a+16|0,r=A+4|0,e=t[r>>2]|0,e)A=r;else if(e=t[A>>2]|0,!e){r=0;break}for(;;)if(n=e+20|0,r=t[n>>2]|0,r)e=r,A=n;else if(n=e+16|0,r=t[n>>2]|0,r)e=r,A=n;else break;t[A>>2]=0,r=e}else r=t[a+8>>2]|0,t[r+12>>2]=e,t[e+8>>2]=r,r=e;while(!1);if(i|0){if(e=t[a+28>>2]|0,A=28228+(e<<2)|0,(t[A>>2]|0)==(a|0)){if(t[A>>2]=r,!r){t[6982]=t[6982]&~(1<>2]|0)==(a|0)?n:i+20|0)>>2]=r,!r)break;t[r+24>>2]=i,e=a+16|0,A=t[e>>2]|0,A|0&&(t[r+16>>2]=A,t[A+24>>2]=r),e=t[e+4>>2]|0,e|0&&(t[r+20>>2]=e,t[e+24>>2]=r)}}while(!1);if(t[l+4>>2]=o|1,t[s+o>>2]=o,(l|0)==(t[6986]|0)){t[6983]=o;return}}if(e=o>>>3,o>>>0<256){r=27964+(e<<1<<2)|0,A=t[6981]|0,e=1<>2]|0):(t[6981]=A|e,e=r,A=r+8|0),t[A>>2]=l,t[e+12>>2]=l,t[l+8>>2]=e,t[l+12>>2]=r;return}e=o>>>8,e?o>>>0>16777215?n=31:(s=(e+1048320|0)>>>16&8,a=e<>>16&4,a=a<>>16&2,n=14-(i|s|n)+(a<>>15)|0,n=o>>>(n+7|0)&1|n<<1):n=0,e=28228+(n<<2)|0,t[l+28>>2]=n,t[l+20>>2]=0,t[l+16>>2]=0,A=t[6982]|0,r=1<>2]=l,t[l+24>>2]=e,t[l+12>>2]=l,t[l+8>>2]=l;else{e=t[e>>2]|0;e:do if((t[e+4>>2]&-8|0)!=(o|0)){for(n=o<<((n|0)==31?0:25-(n>>>1)|0);r=e+16+(n>>>31<<2)|0,A=t[r>>2]|0,!!A;)if((t[A+4>>2]&-8|0)==(o|0)){e=A;break e}else n=n<<1,e=A;t[r>>2]=l,t[l+24>>2]=e,t[l+12>>2]=l,t[l+8>>2]=l;break A}while(!1);s=e+8|0,a=t[s>>2]|0,t[a+12>>2]=l,t[s>>2]=l,t[l+8>>2]=a,t[l+12>>2]=e,t[l+24>>2]=0}while(!1);if(a=(t[6989]|0)+-1|0,t[6989]=a,!(a|0)){for(e=28380;e=t[e>>2]|0,e;)e=e+8|0;t[6989]=-1}}}}function Qt(e,A){e=e|0,A=A|0;var r=0;return e?(r=Pe(A,e)|0,(A|e)>>>0>65535&&(r=((r>>>0)/(e>>>0)|0|0)==(A|0)?r:-1)):r=0,e=p0(r)|0,!e||!(t[e+-4>>2]&3)||Y0(e|0,0,r|0)|0,e|0}function KA(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,r=e+r>>>0,YA(A+n+(r>>>0>>0|0)>>>0|0),r|0|0}function ct(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,n=A-n-(r>>>0>e>>>0|0)>>>0,YA(n|0),e-r>>>0|0|0}function ci(e){return e=e|0,(e?31-(nt(e^e-1)|0)|0:32)|0}function oo(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0;if(m=e,a=A,f=a,s=r,j=n,l=j,!f)return i=(o|0)!=0,l?i?(t[o>>2]=e|0,t[o+4>>2]=A&0,j=0,o=0,YA(j|0),o|0):(j=0,o=0,YA(j|0),o|0):(i&&(t[o>>2]=(m>>>0)%(s>>>0),t[o+4>>2]=0),j=0,o=(m>>>0)/(s>>>0)>>>0,YA(j|0),o|0);i=(l|0)==0;do if(s){if(!i){if(i=(nt(l|0)|0)-(nt(f|0)|0)|0,i>>>0<=31){M=i+1|0,l=31-i|0,A=i-31>>31,s=M,e=m>>>(M>>>0)&A|f<>>(M>>>0)&A,i=0,l=m<>2]=e|0,t[o+4>>2]=a|A&0,j=0,o=0,YA(j|0),o|0):(j=0,o=0,YA(j|0),o|0)}if(i=s-1|0,i&s|0){l=(nt(s|0)|0)+33-(nt(f|0)|0)|0,L=64-l|0,M=32-l|0,a=M>>31,I=l-32|0,A=I>>31,s=l,e=M-1>>31&f>>>(I>>>0)|(f<>>(l>>>0))&A,A=A&f>>>(l>>>0),i=m<>>(I>>>0))&a|m<>31;break}return o|0&&(t[o>>2]=i&m,t[o+4>>2]=0),(s|0)==1?(I=a|A&0,L=e|0|0,YA(I|0),L|0):(L=ci(s|0)|0,I=f>>>(L>>>0)|0,L=f<<32-L|m>>>(L>>>0)|0,YA(I|0),L|0)}else{if(i)return o|0&&(t[o>>2]=(f>>>0)%(s>>>0),t[o+4>>2]=0),I=0,L=(f>>>0)/(s>>>0)>>>0,YA(I|0),L|0;if(!m)return o|0&&(t[o>>2]=0,t[o+4>>2]=(f>>>0)%(l>>>0)),I=0,L=(f>>>0)/(l>>>0)>>>0,YA(I|0),L|0;if(i=l-1|0,!(i&l))return o|0&&(t[o>>2]=e|0,t[o+4>>2]=i&f|A&0),I=0,L=f>>>((ci(l|0)|0)>>>0),YA(I|0),L|0;if(i=(nt(l|0)|0)-(nt(f|0)|0)|0,i>>>0<=30){A=i+1|0,l=31-i|0,s=A,e=f<>>(A>>>0),A=f>>>(A>>>0),i=0,l=m<>2]=e|0,t[o+4>>2]=a|A&0,I=0,L=0,YA(I|0),L|0):(I=0,L=0,YA(I|0),L|0)}while(!1);if(!s)f=l,a=0,l=0;else{M=r|0|0,m=j|n&0,f=KA(M|0,m|0,-1,-1)|0,r=S()|0,a=l,l=0;do n=a,a=i>>>31|a<<1,i=l|i<<1,n=e<<1|n>>>31|0,j=e>>>31|A<<1|0,ct(f|0,r|0,n|0,j|0)|0,L=S()|0,I=L>>31|((L|0)<0?-1:0)<<1,l=I&1,e=ct(n|0,j|0,I&M|0,(((L|0)<0?-1:0)>>31|((L|0)<0?-1:0)<<1)&m|0)|0,A=S()|0,s=s-1|0;while((s|0)!=0);f=a,a=0}return s=0,o|0&&(t[o>>2]=e,t[o+4>>2]=A),I=(i|0)>>>31|(f|s)<<1|(s<<1|i>>>31)&0|a,L=(i<<1|0)&-2|l,YA(I|0),L|0}function W0(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0;return f=A>>31|((A|0)<0?-1:0)<<1,a=((A|0)<0?-1:0)>>31|((A|0)<0?-1:0)<<1,i=n>>31|((n|0)<0?-1:0)<<1,o=((n|0)<0?-1:0)>>31|((n|0)<0?-1:0)<<1,l=ct(f^e|0,a^A|0,f|0,a|0)|0,s=S()|0,e=i^f,A=o^a,ct((oo(l,s,ct(i^r|0,o^n|0,i|0,o|0)|0,S()|0,0)|0)^e|0,(S()|0)^A|0,e|0,A|0)|0}function ea(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0;return i=e&65535,o=A&65535,r=Pe(o,i)|0,n=e>>>16,e=(r>>>16)+(Pe(o,n)|0)|0,o=A>>>16,A=Pe(o,i)|0,YA((e>>>16)+(Pe(o,n)|0)+(((e&65535)+A|0)>>>16)|0),e+A<<16|r&65535|0|0}function ft(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0;return o=e,i=r,r=ea(o,i)|0,e=S()|0,YA((Pe(A,i)|0)+(Pe(n,o)|0)+e|e&0|0),r|0|0|0}function Rr(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0;return o=k,k=k+16|0,l=o|0,s=A>>31|((A|0)<0?-1:0)<<1,i=((A|0)<0?-1:0)>>31|((A|0)<0?-1:0)<<1,f=n>>31|((n|0)<0?-1:0)<<1,a=((n|0)<0?-1:0)>>31|((n|0)<0?-1:0)<<1,e=ct(s^e|0,i^A|0,s|0,i|0)|0,A=S()|0,oo(e,A,ct(f^r|0,a^n|0,f|0,a|0)|0,S()|0,l)|0,n=ct(t[l>>2]^s|0,t[l+4>>2]^i|0,s|0,i|0)|0,r=S()|0,k=o,YA(r|0),n|0}function jr(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0;return i=k,k=k+16|0,o=i|0,oo(e,A,r,n,o)|0,k=i,YA(t[o+4>>2]|0),t[o>>2]|0|0}function fi(e,A,r){return e=e|0,A=A|0,r=r|0,(r|0)<32?(YA(A>>r|0),e>>>r|(A&(1<>r-32|0)}function wA(e,A,r){return e=e|0,A=A|0,r=r|0,(r|0)<32?(YA(A>>>r|0),e>>>r|(A&(1<>>r-32|0)}function EA(e,A,r){return e=e|0,A=A|0,r=r|0,(r|0)<32?(YA(A<>>32-r|0),e<=0?+He(e+.5):+gt(e-.5)}function Ir(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0;if((r|0)>=8192)return i0(e|0,A|0,r|0)|0,e|0;if(i=e|0,o=e+r|0,(e&3)==(A&3)){for(;e&3;){if(!r)return i|0;xA[e>>0]=xA[A>>0]|0,e=e+1|0,A=A+1|0,r=r-1|0}for(r=o&-4|0,n=r-64|0;(e|0)<=(n|0);)t[e>>2]=t[A>>2],t[e+4>>2]=t[A+4>>2],t[e+8>>2]=t[A+8>>2],t[e+12>>2]=t[A+12>>2],t[e+16>>2]=t[A+16>>2],t[e+20>>2]=t[A+20>>2],t[e+24>>2]=t[A+24>>2],t[e+28>>2]=t[A+28>>2],t[e+32>>2]=t[A+32>>2],t[e+36>>2]=t[A+36>>2],t[e+40>>2]=t[A+40>>2],t[e+44>>2]=t[A+44>>2],t[e+48>>2]=t[A+48>>2],t[e+52>>2]=t[A+52>>2],t[e+56>>2]=t[A+56>>2],t[e+60>>2]=t[A+60>>2],e=e+64|0,A=A+64|0;for(;(e|0)<(r|0);)t[e>>2]=t[A>>2],e=e+4|0,A=A+4|0}else for(r=o-4|0;(e|0)<(r|0);)xA[e>>0]=xA[A>>0]|0,xA[e+1>>0]=xA[A+1>>0]|0,xA[e+2>>0]=xA[A+2>>0]|0,xA[e+3>>0]=xA[A+3>>0]|0,e=e+4|0,A=A+4|0;for(;(e|0)<(o|0);)xA[e>>0]=xA[A>>0]|0,e=e+1|0,A=A+1|0;return i|0}function Y0(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0;if(i=e+r|0,A=A&255,(r|0)>=67){for(;e&3;)xA[e>>0]=A,e=e+1|0;for(n=i&-4|0,s=A|A<<8|A<<16|A<<24,o=n-64|0;(e|0)<=(o|0);)t[e>>2]=s,t[e+4>>2]=s,t[e+8>>2]=s,t[e+12>>2]=s,t[e+16>>2]=s,t[e+20>>2]=s,t[e+24>>2]=s,t[e+28>>2]=s,t[e+32>>2]=s,t[e+36>>2]=s,t[e+40>>2]=s,t[e+44>>2]=s,t[e+48>>2]=s,t[e+52>>2]=s,t[e+56>>2]=s,t[e+60>>2]=s,e=e+64|0;for(;(e|0)<(n|0);)t[e>>2]=s,e=e+4|0}for(;(e|0)<(i|0);)xA[e>>0]=A,e=e+1|0;return i-r|0}function di(e){return e=+e,e>=0?+He(e+.5):+gt(e-.5)}function K0(e){e=e|0;var A=0,r=0,n=0;return n=Q0()|0,r=t[De>>2]|0,A=r+e|0,(e|0)>0&(A|0)<(r|0)|(A|0)<0?(d0(A|0)|0,Nt(12),-1):(A|0)>(n|0)&&!(s0(A|0)|0)?(Nt(12),-1):(t[De>>2]=A,r|0)}return{___divdi3:W0,___muldi3:ft,___remdi3:Rr,___uremdi3:jr,_areNeighborCells:Yn,_bitshift64Ashr:fi,_bitshift64Lshr:wA,_bitshift64Shl:EA,_calloc:Qt,_cellAreaKm2:kl,_cellAreaM2:bl,_cellAreaRads2:eo,_cellToBoundary:_r,_cellToCenterChild:Wo,_cellToChildPos:hl,_cellToChildren:en,_cellToChildrenSize:g0,_cellToLatLng:ar,_cellToLocalIj:_l,_cellToParent:_t,_cellToVertex:Xt,_cellToVertexes:Zl,_cellsToDirectedEdge:pn,_cellsToLinkedMultiPolygon:pt,_childPosToCell:dl,_compactCells:ol,_constructCell:we,_destroyLinkedMultiPolygon:qo,_directedEdgeToBoundary:sr,_directedEdgeToCells:Mr,_edgeLengthKm:El,_edgeLengthM:Sl,_edgeLengthRads:Cl,_emscripten_replace_memory:C0,_free:qA,_getBaseCellNumber:te,_getDirectedEdgeDestination:yn,_getDirectedEdgeOrigin:Sr,_getHexagonAreaAvgKm2:Zo,_getHexagonAreaAvgM2:xl,_getHexagonEdgeLengthAvgKm:wl,_getHexagonEdgeLengthAvgM:vl,_getIcosahedronFaces:Yo,_getIndexDigit:ke,_getNumCells:vn,_getPentagons:Jn,_getRes0Cells:Wr,_getResolution:_A,_greatCircleDistanceKm:rn,_greatCircleDistanceM:gl,_greatCircleDistanceRads:ml,_gridDisk:v,_gridDiskDistances:D,_gridDistance:Rl,_gridPathCells:Il,_gridPathCellsSize:jl,_gridRing:hA,_gridRingUnsafe:RA,_i64Add:KA,_i64Subtract:ct,_isPentagon:Oe,_isResClassIII:ll,_isValidCell:Ue,_isValidDirectedEdge:Xr,_isValidIndex:Bt,_isValidVertex:ii,_latLngToCell:$n,_llvm_ctlz_i64:io,_llvm_maxnum_f64:hi,_llvm_minnum_f64:Cn,_llvm_round_f64:En,_localIjToCell:Tl,_malloc:p0,_maxFaceCount:cl,_maxGridDiskSize:h,_maxPolygonToCellsSize:ce,_maxPolygonToCellsSizeExperimental:Fl,_memcpy:Ir,_memset:Y0,_originToDirectedEdges:Br,_pentagonCount:fl,_polygonToCells:bt,_polygonToCellsExperimental:Nl,_readInt64AsDoubleFromPointer:Vl,_res0CellCount:Vr,_round:di,_sbrk:K0,_sizeOfCellBoundary:Ol,_sizeOfCoordIJ:Ul,_sizeOfGeoLoop:zl,_sizeOfGeoPolygon:Hl,_sizeOfH3Index:Pl,_sizeOfLatLng:Ql,_sizeOfLinkedGeoPolygon:Gl,_uncompactCells:il,_uncompactCellsSize:sl,_vertexToLatLng:$l,establishStackSpace:E0,stackAlloc:$t,stackRestore:z0,stackSave:O0}})(rr,F0,yA);u.___divdi3=gA.___divdi3,u.___muldi3=gA.___muldi3,u.___remdi3=gA.___remdi3,u.___uremdi3=gA.___uremdi3,u._areNeighborCells=gA._areNeighborCells,u._bitshift64Ashr=gA._bitshift64Ashr,u._bitshift64Lshr=gA._bitshift64Lshr,u._bitshift64Shl=gA._bitshift64Shl,u._calloc=gA._calloc,u._cellAreaKm2=gA._cellAreaKm2,u._cellAreaM2=gA._cellAreaM2,u._cellAreaRads2=gA._cellAreaRads2,u._cellToBoundary=gA._cellToBoundary,u._cellToCenterChild=gA._cellToCenterChild,u._cellToChildPos=gA._cellToChildPos,u._cellToChildren=gA._cellToChildren,u._cellToChildrenSize=gA._cellToChildrenSize,u._cellToLatLng=gA._cellToLatLng,u._cellToLocalIj=gA._cellToLocalIj,u._cellToParent=gA._cellToParent,u._cellToVertex=gA._cellToVertex,u._cellToVertexes=gA._cellToVertexes,u._cellsToDirectedEdge=gA._cellsToDirectedEdge,u._cellsToLinkedMultiPolygon=gA._cellsToLinkedMultiPolygon,u._childPosToCell=gA._childPosToCell,u._compactCells=gA._compactCells,u._constructCell=gA._constructCell,u._destroyLinkedMultiPolygon=gA._destroyLinkedMultiPolygon,u._directedEdgeToBoundary=gA._directedEdgeToBoundary,u._directedEdgeToCells=gA._directedEdgeToCells,u._edgeLengthKm=gA._edgeLengthKm,u._edgeLengthM=gA._edgeLengthM,u._edgeLengthRads=gA._edgeLengthRads;var f0=u._emscripten_replace_memory=gA._emscripten_replace_memory;u._free=gA._free,u._getBaseCellNumber=gA._getBaseCellNumber,u._getDirectedEdgeDestination=gA._getDirectedEdgeDestination,u._getDirectedEdgeOrigin=gA._getDirectedEdgeOrigin,u._getHexagonAreaAvgKm2=gA._getHexagonAreaAvgKm2,u._getHexagonAreaAvgM2=gA._getHexagonAreaAvgM2,u._getHexagonEdgeLengthAvgKm=gA._getHexagonEdgeLengthAvgKm,u._getHexagonEdgeLengthAvgM=gA._getHexagonEdgeLengthAvgM,u._getIcosahedronFaces=gA._getIcosahedronFaces,u._getIndexDigit=gA._getIndexDigit,u._getNumCells=gA._getNumCells,u._getPentagons=gA._getPentagons,u._getRes0Cells=gA._getRes0Cells,u._getResolution=gA._getResolution,u._greatCircleDistanceKm=gA._greatCircleDistanceKm,u._greatCircleDistanceM=gA._greatCircleDistanceM,u._greatCircleDistanceRads=gA._greatCircleDistanceRads,u._gridDisk=gA._gridDisk,u._gridDiskDistances=gA._gridDiskDistances,u._gridDistance=gA._gridDistance,u._gridPathCells=gA._gridPathCells,u._gridPathCellsSize=gA._gridPathCellsSize,u._gridRing=gA._gridRing,u._gridRingUnsafe=gA._gridRingUnsafe,u._i64Add=gA._i64Add,u._i64Subtract=gA._i64Subtract,u._isPentagon=gA._isPentagon,u._isResClassIII=gA._isResClassIII,u._isValidCell=gA._isValidCell,u._isValidDirectedEdge=gA._isValidDirectedEdge,u._isValidIndex=gA._isValidIndex,u._isValidVertex=gA._isValidVertex,u._latLngToCell=gA._latLngToCell,u._llvm_ctlz_i64=gA._llvm_ctlz_i64,u._llvm_maxnum_f64=gA._llvm_maxnum_f64,u._llvm_minnum_f64=gA._llvm_minnum_f64,u._llvm_round_f64=gA._llvm_round_f64,u._localIjToCell=gA._localIjToCell,u._malloc=gA._malloc,u._maxFaceCount=gA._maxFaceCount,u._maxGridDiskSize=gA._maxGridDiskSize,u._maxPolygonToCellsSize=gA._maxPolygonToCellsSize,u._maxPolygonToCellsSizeExperimental=gA._maxPolygonToCellsSizeExperimental,u._memcpy=gA._memcpy,u._memset=gA._memset,u._originToDirectedEdges=gA._originToDirectedEdges,u._pentagonCount=gA._pentagonCount,u._polygonToCells=gA._polygonToCells,u._polygonToCellsExperimental=gA._polygonToCellsExperimental,u._readInt64AsDoubleFromPointer=gA._readInt64AsDoubleFromPointer,u._res0CellCount=gA._res0CellCount,u._round=gA._round,u._sbrk=gA._sbrk,u._sizeOfCellBoundary=gA._sizeOfCellBoundary,u._sizeOfCoordIJ=gA._sizeOfCoordIJ,u._sizeOfGeoLoop=gA._sizeOfGeoLoop,u._sizeOfGeoPolygon=gA._sizeOfGeoPolygon,u._sizeOfH3Index=gA._sizeOfH3Index,u._sizeOfLatLng=gA._sizeOfLatLng,u._sizeOfLinkedGeoPolygon=gA._sizeOfLinkedGeoPolygon,u._uncompactCells=gA._uncompactCells,u._uncompactCellsSize=gA._uncompactCellsSize,u._vertexToLatLng=gA._vertexToLatLng,u.establishStackSpace=gA.establishStackSpace;var at=u.stackAlloc=gA.stackAlloc,Fe=u.stackRestore=gA.stackRestore,n0=u.stackSave=gA.stackSave;if(u.asm=gA,u.cwrap=uA,u.setValue=V,u.getValue=K,Qe){Be(Qe)||(Qe=C(Qe));{Xe();var Zt=function(rA){rA.byteLength&&(rA=new Uint8Array(rA)),LA.set(rA,H),u.memoryInitializerRequest&&delete u.memoryInitializerRequest.response,vt()},xt=function(){T(Qe,Zt,function(){throw"could not load memory initializer "+Qe})},kt=c0(Qe);if(kt)Zt(kt.buffer);else if(u.memoryInitializerRequest){var o0=function(){var rA=u.memoryInitializerRequest,pA=rA.response;if(rA.status!==200&&rA.status!==0){var IA=c0(u.memoryInitializerRequestURL);if(IA)pA=IA.buffer;else{console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+rA.status+", retrying "+Qe),xt();return}}Zt(pA)};u.memoryInitializerRequest.response?setTimeout(o0,0):u.memoryInitializerRequest.addEventListener("load",o0)}else xt()}}var wt;qe=function rA(){wt||It(),wt||(qe=rA)};function It(rA){if($e>0||(Le(),$e>0))return;function pA(){wt||(wt=!0,!aA&&(oe(),me(),u.onRuntimeInitialized&&u.onRuntimeInitialized(),ue()))}u.setStatus?(u.setStatus("Running..."),setTimeout(function(){setTimeout(function(){u.setStatus("")},1),pA()},1)):pA()}u.run=It;function dt(rA){throw u.onAbort&&u.onAbort(rA),rA+="",P(rA),_(rA),aA=!0,"abort("+rA+"). Build with -s ASSERTIONS=1 for more info."}if(u.abort=dt,u.preInit)for(typeof u.preInit=="function"&&(u.preInit=[u.preInit]);u.preInit.length>0;)u.preInit.pop()();return It(),c})(typeof Rt=="object"?Rt:{}),re="number",ee=re,zr=re,se=re,le=re,ht=re,PA=re,gf=[["sizeOfH3Index",re],["sizeOfLatLng",re],["sizeOfCellBoundary",re],["sizeOfGeoLoop",re],["sizeOfGeoPolygon",re],["sizeOfLinkedGeoPolygon",re],["sizeOfCoordIJ",re],["readInt64AsDoubleFromPointer",re],["isValidCell",zr,[se,le]],["isValidIndex",zr,[se,le]],["latLngToCell",ee,[re,re,ht,PA]],["cellToLatLng",ee,[se,le,PA]],["cellToBoundary",ee,[se,le,PA]],["maxGridDiskSize",ee,[re,PA]],["gridDisk",ee,[se,le,re,PA]],["gridDiskDistances",ee,[se,le,re,PA,PA]],["gridRing",ee,[se,le,re,PA]],["gridRingUnsafe",ee,[se,le,re,PA]],["maxPolygonToCellsSize",ee,[PA,ht,re,PA]],["polygonToCells",ee,[PA,ht,re,PA]],["maxPolygonToCellsSizeExperimental",ee,[PA,ht,re,PA]],["polygonToCellsExperimental",ee,[PA,ht,re,re,re,PA]],["cellsToLinkedMultiPolygon",ee,[PA,re,PA]],["destroyLinkedMultiPolygon",null,[PA]],["compactCells",ee,[PA,PA,re,re]],["uncompactCells",ee,[PA,re,re,PA,re,ht]],["uncompactCellsSize",ee,[PA,re,re,ht,PA]],["isPentagon",zr,[se,le]],["isResClassIII",zr,[se,le]],["getBaseCellNumber",re,[se,le]],["getResolution",re,[se,le]],["getIndexDigit",re,[se,le,re]],["constructCell",ee,[re,re,PA,PA]],["maxFaceCount",ee,[se,le,PA]],["getIcosahedronFaces",ee,[se,le,PA]],["cellToParent",ee,[se,le,ht,PA]],["cellToChildren",ee,[se,le,ht,PA]],["cellToCenterChild",ee,[se,le,ht,PA]],["cellToChildrenSize",ee,[se,le,ht,PA]],["cellToChildPos",ee,[se,le,ht,PA]],["childPosToCell",ee,[re,re,se,le,ht,PA]],["areNeighborCells",ee,[se,le,se,le,PA]],["cellsToDirectedEdge",ee,[se,le,se,le,PA]],["getDirectedEdgeOrigin",ee,[se,le,PA]],["getDirectedEdgeDestination",ee,[se,le,PA]],["isValidDirectedEdge",zr,[se,le]],["directedEdgeToCells",ee,[se,le,PA]],["originToDirectedEdges",ee,[se,le,PA]],["directedEdgeToBoundary",ee,[se,le,PA]],["gridDistance",ee,[se,le,se,le,PA]],["gridPathCells",ee,[se,le,se,le,PA]],["gridPathCellsSize",ee,[se,le,se,le,PA]],["cellToLocalIj",ee,[se,le,se,le,re,PA]],["localIjToCell",ee,[se,le,PA,re,PA]],["getHexagonAreaAvgM2",ee,[ht,PA]],["getHexagonAreaAvgKm2",ee,[ht,PA]],["getHexagonEdgeLengthAvgM",ee,[ht,PA]],["getHexagonEdgeLengthAvgKm",ee,[ht,PA]],["greatCircleDistanceM",re,[PA,PA]],["greatCircleDistanceKm",re,[PA,PA]],["greatCircleDistanceRads",re,[PA,PA]],["cellAreaM2",ee,[se,le,PA]],["cellAreaKm2",ee,[se,le,PA]],["cellAreaRads2",ee,[se,le,PA]],["edgeLengthM",ee,[se,le,PA]],["edgeLengthKm",ee,[se,le,PA]],["edgeLengthRads",ee,[se,le,PA]],["getNumCells",ee,[ht,PA]],["getRes0Cells",ee,[PA]],["res0CellCount",re],["getPentagons",ee,[re,PA]],["pentagonCount",re],["cellToVertex",ee,[se,le,re,PA]],["cellToVertexes",ee,[se,le,PA]],["vertexToLatLng",ee,[se,le,PA]],["isValidVertex",zr,[se,le]]],pf=0,yf=1,xf=2,wf=3,vf=4,kf=5,bf=6,Cf=7,Ef=8,Sf=9,Mf=10,Bf=11,Df=12,_f=13,Tf=14,Rf=15,jf=16,If=17,Lf=18,Nf=19,rt={};rt[pf]="Success";rt[yf]="The operation failed but a more specific error is not available";rt[xf]="Argument was outside of acceptable range";rt[wf]="Latitude or longitude arguments were outside of acceptable range";rt[vf]="Resolution argument was outside of acceptable range";rt[kf]="Cell argument was not valid";rt[bf]="Directed edge argument was not valid";rt[Cf]="Undirected edge argument was not valid";rt[Ef]="Vertex argument was not valid";rt[Sf]="Pentagon distortion was encountered";rt[Mf]="Duplicate input";rt[Bf]="Cell arguments were not neighbors";rt[Df]="Cell arguments had incompatible resolutions";rt[_f]="Memory allocation failed";rt[Tf]="Bounds of provided memory were insufficient";rt[Rf]="Mode or flags argument was not valid";rt[jf]="Index argument was not valid";rt[If]="Base cell number was outside of acceptable range";rt[Lf]="Child indexing digits invalid";rt[Nf]="Child indexing digits refer to a deleted subsequence";var Ff=1e3,Pf=1001,$s=1002,Wn={};Wn[Ff]="Unknown unit";Wn[Pf]="Array length out of bounds";Wn[$s]="Got unexpected null value for H3 index";var Qf="Unknown error";function qs(c,u,g){var y=g&&"value"in g,x=new Error((c[u]||Qf)+" (code: "+u+(y?", value: "+g.value:"")+")");return x.code=u,x}function Of(c,u){var g=arguments.length===2?{value:u}:{};return qs(rt,c,g)}function zf(c,u){var g=arguments.length===2?{value:u}:{};return qs(Wn,c,g)}function Js(c){if(c!==0)throw Of(c)}var w0={};gf.forEach(function(u){w0[u[0]]=Rt.cwrap.apply(Rt,u)});var Gr=16,Hf=4,Gn=8,Do=w0.sizeOfH3Index(),Gf=w0.sizeOfLatLng(),Uf=w0.sizeOfCellBoundary();w0.sizeOfGeoPolygon();w0.sizeOfGeoLoop();w0.sizeOfLinkedGeoPolygon();w0.sizeOfCoordIJ();function Vf(c){if(!c)throw zf($s);return c}var Wf=/[^0-9a-fA-F]/;function Yf(c){if(Array.isArray(c)&&c.length===2&&Number.isInteger(c[0])&&Number.isInteger(c[1]))return c;if(typeof c!="string"||Wf.test(c))return[0,0];var u=parseInt(c.substring(0,c.length-8),Gr),g=parseInt(c.substring(c.length-8),Gr);return[g,u]}function Gi(c){if(c>=0)return c.toString(Gr);c=c&2147483647;var u=Xs(8,c.toString(Gr)),g=(parseInt(u[0],Gr)+8).toString(Gr);return u=g+u.substring(1),u}function Kf(c,u){return Gi(u)+Xs(8,Gi(c))}function Xs(c,u){for(var g=c-u.length,y="",x=0;x.85?.9+(c-.85)/.15*.1:.1+(c-.15)/.7*.8}function tl(c,u,g,y){const x=g-u;if(x<.001)return Vi(y[12]);const C=Math.max(0,Math.min(1,(c-u)/x)),T=s2(C),P=Math.min(23,Math.floor(T*24));return Vi(y[P])}function l2(c){const u=new Map;for(const C of c){if(typeof C.lat!="number"||typeof C.lon!="number"||isNaN(C.lat)||isNaN(C.lon))continue;const T=Jf(C.lat,C.lon,e2),P=u.get(T),_=C.weight;P?(P.count++,P.qualitySum+=_):u.set(T,{count:1,qualitySum:_})}const g=[];let y=1/0,x=-1/0;for(const[C,T]of u.entries()){const P=T.qualitySum/T.count;g.push({hexId:C,count:T.count,avgQuality:P}),y=Math.min(y,P),x=Math.max(x,P)}return{cells:g,minQuality:g.length>0?y:0,maxQuality:g.length>0?x:0}}function a2(c,u,g,y){const x=[];for(const C of c){const P=Al(C.hexId).map(([E,Q])=>[Q,E]);P.push(P[0]);const _=tl(C.avgQuality,u,g,y);x.push({type:"Feature",properties:{color:_,quality:C.avgQuality,count:C.count},geometry:{type:"Polygon",coordinates:[P]}})}return{type:"FeatureCollection",features:x}}async function u2(c,u,g,y,x){const C=[];let T=0;for(;T[V,H]);Q.push(Q[0]);const O=tl(_.avgQuality,u,g,y);C.push({type:"Feature",properties:{color:O,quality:_.avgQuality,count:_.count},geometry:{type:"Polygon",coordinates:[Q]}})}TrequestAnimationFrame(_))}return{type:"FeatureCollection",features:C}}function c2(c,u){const[g,y]=R.useState(c);return R.useEffect(()=>{const x=setTimeout(()=>y(c),u);return()=>clearTimeout(x)},[c,u]),g}function f2({coveragePoints:c,visible:u,terrainEnabled:g=!1,brightness:y=t2,basemapMode:x="dark"}){const{current:C}=Ar(),[T,P]=R.useState(null);R.useEffect(()=>{const Z=()=>{var iA;const vA=(iA=C==null?void 0:C.getMap)==null?void 0:iA.call(C);vA&&!T&&P(vA)};Z();const uA=setInterval(Z,50),oA=setTimeout(()=>clearInterval(uA),5e3);return()=>{clearInterval(uA),clearTimeout(oA)}},[C,T]);const[_,E]=R.useState(null),[Q,O]=R.useState(!1),H=R.useRef({aborted:!1}),V=R.useRef(0),K=R.useRef(x),aA=c2(c,r2),J=R.useMemo(()=>i2(x),[x]);R.useEffect(()=>{if(!aA||!Array.isArray(aA)||aA.length===0){queueMicrotask(()=>{E(null),V.current=0});return}const Z=K.current!==x;if(aA.length===V.current&&_&&!Z)return;V.current=aA.length,K.current=x,H.current.aborted=!0,H.current={aborted:!1};const uA=H.current;O(!0);const{cells:oA,minQuality:vA,maxQuality:iA}=l2(aA);if(oA.length===0){E(null),O(!1);return}if(oA.length{!uA.aborted&&fA&&E(fA)}).finally(()=>{uA.aborted||O(!1)}),()=>{uA.aborted=!0}},[aA,J]),R.useEffect(()=>{if(!T)return;const Z=()=>{var uA,oA;try{const vA=T.getLayer(dr),iA=T.getSource(hr);if(u&&_&&_.features.length>0){if(iA?T.getSource(hr).setData(_):T.addSource(hr,{type:"geojson",data:_}),!vA){const fA=T.getLayer("topology-weak-edges-native"),jA=(oA=(uA=T.getStyle())==null?void 0:uA.layers)==null?void 0:oA.find(CA=>CA.type==="symbol"),DA=fA?"topology-weak-edges-native":jA==null?void 0:jA.id;T.addLayer({id:dr,type:"fill",source:hr,paint:{"fill-color":["get","color"],"fill-opacity":y}},DA)}}else vA&&T.removeLayer(dr),iA&&T.removeSource(hr)}catch(vA){console.warn("[WardrivingHexLayerMapLibre] Layer update error:",vA)}};T.isStyleLoaded()?Z():T.once("style.load",Z)},[T,u,_,g]),R.useEffect(()=>{if(!(!T||!u))try{T.getLayer(dr)&&T.setPaintProperty(dr,"fill-opacity",y)}catch{}},[T,y,u]),R.useEffect(()=>()=>{if(T)try{T.getLayer(dr)&&T.removeLayer(dr),T.getSource(hr)&&T.removeSource(hr)}catch{}},[T]);const eA=(_==null?void 0:_.features.length)??0;return eA>0&&u?p.jsx("div",{"data-testid":"wardriving-hexlayer-maplibre-active","data-point-count":(c==null?void 0:c.length)||0,"data-cell-count":eA,"data-terrain-enabled":g,"data-is-processing":Q,style:{display:"none"}}):null}const Wi="https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png",Yi="terrarium",Ki=256,Zi=14,ln={shadowColor:"rgba(10, 10, 10, 0.6)",highlightColor:"rgba(245, 240, 230, 0.4)",accentColor:"rgba(90, 75, 65, 0.3)",illuminationDirection:315,exaggeration:.35},Z0="terrain-dem",Hr="hillshade-dem",Ln="terrain-hillshade";function h2({enabled:c,exaggeration:u=4}){const{current:g}=Ar(),[y,x]=R.useState(null),C=R.useRef(null);return R.useEffect(()=>{const T=()=>{var Q;const E=(Q=g==null?void 0:g.getMap)==null?void 0:Q.call(g);E&&!y&&x(E)};T();const P=setInterval(T,50),_=setTimeout(()=>clearInterval(P),5e3);return()=>{clearInterval(P),clearTimeout(_)}},[g,y]),R.useEffect(()=>{if(!y)return;let T=!0;const P=()=>{var _,E;if(T)try{if(y.getSource(Hr)||y.addSource(Hr,{type:"raster-dem",tiles:[Wi],encoding:Yi,tileSize:Ki,maxzoom:Zi}),!y.getLayer(Ln)){const Q=(E=(_=y.getStyle())==null?void 0:_.layers)==null?void 0:E.find(O=>O.type==="symbol");y.addLayer({id:Ln,type:"hillshade",source:Hr,paint:{"hillshade-shadow-color":ln.shadowColor,"hillshade-highlight-color":ln.highlightColor,"hillshade-accent-color":ln.accentColor,"hillshade-illumination-direction":ln.illuminationDirection,"hillshade-exaggeration":ln.exaggeration}},Q==null?void 0:Q.id)}y.getSource(Z0)||y.addSource(Z0,{type:"raster-dem",tiles:[Wi],encoding:Yi,tileSize:Ki,maxzoom:Zi})}catch(Q){console.error("[TerrainLayer] Source/layer setup error:",Q)}};return y.isStyleLoaded()?P():(y.once("style.load",P),y.once("load",()=>{T&&!y.getSource(Hr)&&P()})),()=>{T=!1}},[y]),R.useEffect(()=>{if(!y)return;let T=!0,P=!1;const _=()=>{if(!(!T||!y.getSource(Z0)))try{c?(y.setCenterClampedToGround(!1),y.setTerrain({source:Z0,exaggeration:u}),y.setMaxPitch(70),!P&&y.getPitch()<30&&!y.isMoving()&&(P=!0,C.current!==null&&clearTimeout(C.current),C.current=window.setTimeout(()=>{C.current=null,T&&!y.isMoving()&&y.getPitch()<30&&y.easeTo({pitch:45,duration:1e3})},200))):(y.setTerrain(null),y.setCenterClampedToGround(!0),y.getPitch()>0&&!y.isMoving()&&y.easeTo({pitch:0,duration:800}),y.setMaxPitch(60))}catch(E){console.error("[TerrainLayer] Terrain state error:",E)}};if(y.isStyleLoaded()&&y.getSource(Z0))_();else{const E=()=>{y.getSource(Z0)&&_()};y.once("idle",E)}return()=>{T=!1,C.current!==null&&(clearTimeout(C.current),C.current=null)}},[y,c,u]),R.useEffect(()=>()=>{var T;try{(T=y==null?void 0:y.getStyle)!=null&&T.call(y)&&y.isStyleLoaded()&&(y.setTerrain(null),y.getLayer(Ln)&&y.removeLayer(Ln),y.getSource(Hr)&&y.removeSource(Hr),y.getSource(Z0)&&y.removeSource(Z0))}catch{}},[y]),null}const d2=.03,m2=.1,g2=2,p2=3,y2=.02,x2=3;function w2(c,u=x2){if(c.length<3||u<=0)return c;let g=c;for(let y=0;y0&&x.push([x[0][0],x[0][1]]),g=x}return g}function v2(c,u){let g=1/0,y=-1/0,x=1/0,C=-1/0;for(const[T,P]of c)Ty&&(y=T),PC&&(C=P);return g-=u,y+=u,x-=u,C+=u,{minX:g,minY:x,maxX:y,maxY:C,width:y-g,height:C-x}}function k2(c,u={}){if(c.length(eA-C.minX)/C.width*Q,V=eA=>(eA-C.minY)/C.height*O,K=eA=>eA/Q*C.width+C.minX,aA=eA=>eA/O*C.height+C.minY,J=g/C.width*Q;try{const Z=rc().x(DA=>H(DA[0])).y(DA=>V(DA[1])).size([Q,O]).bandwidth(Math.max(5,J)).cellSize(x)(c);if(Z.length===0)return{coordinates:[],valid:!1};const oA=Math.max(...Z.map(DA=>DA.value))*y;let vA=Z[0],iA=1/0;for(const DA of Z){const CA=Math.abs(DA.value-oA);CA0){const LA=kA[0],NA=kA[kA.length-1];(LA[0]!==NA[0]||LA[1]!==NA[1])&&kA.push([LA[0],LA[1]])}if(kA.length>=4){const LA=w2(kA);CA.push(LA)}}CA.length>0&&fA.push(CA)}const jA=[];for(const DA of fA)for(const CA of DA)jA.push(CA);return{coordinates:fA,valid:fA.length>0}}catch(eA){return console.warn("[KDE Contour] Failed to generate contour:",eA),{coordinates:[],valid:!1}}}function b2(c,u={}){const g=k2(c,u);return!g.valid||g.coordinates.length===0?null:g.coordinates.length===1?{type:"Polygon",coordinates:g.coordinates[0]}:{type:"MultiPolygon",coordinates:g.coordinates}}const C2="mincut-partition",E2="mincut-partition-fill",S2="mincut-partition-stroke",M2=3,B2=.05,D2=.15,_2=.008,$i=12;function qi(c,u,g){return(u[0]-c[0])*(g[1]-c[1])-(u[1]-c[1])*(g[0]-c[0])}function T2(c){if(c.length<3)return c;const u=[...c].sort((x,C)=>x[0]-C[0]||x[1]-C[1]),g=[];for(const x of u){for(;g.length>=2&&qi(g[g.length-2],g[g.length-1],x)<=0;)g.pop();g.push(x)}const y=[];for(let x=u.length-1;x>=0;x--){const C=u[x];for(;y.length>=2&&qi(y[y.length-2],y[y.length-1],C)<=0;)y.pop();y.push(C)}return g.pop(),y.pop(),g.concat(y)}function R2(c,u){if(c.length<3)return c;let g=0,y=0;for(const[x,C]of c)g+=x,y+=C;return g/=c.length,y/=c.length,c.map(([x,C])=>{const T=x-g,P=C-y,_=Math.sqrt(T*T+P*P);if(_<1e-4)return[x,C];const E=(_+u)/_;return[g+T*E,y+P*E]})}function j2(c,u,g,y,x){const C=x*x,T=C*x;return[.5*(2*u[0]+(-c[0]+g[0])*x+(2*c[0]-5*u[0]+4*g[0]-y[0])*C+(-c[0]+3*u[0]-3*g[0]+y[0])*T),.5*(2*u[1]+(-c[1]+g[1])*x+(2*c[1]-5*u[1]+4*g[1]-y[1])*C+(-c[1]+3*u[1]-3*g[1]+y[1])*T)]}function I2(c){if(c.length<3)return c;const u=[],g=c.length;for(let y=0;yc?N2(c,u,x,C):{type:"FeatureCollection",features:[]},[c,u,x,C]),_=g?y:0,E={"fill-color":["get","color"],"fill-opacity":_},Q={"line-color":["get","borderColor"],"line-width":T,"line-opacity":_};return p.jsxs(X0,{id:C2,type:"geojson",data:P,children:[p.jsx(t0,{id:E2,type:"fill",paint:E}),p.jsx(t0,{id:S2,type:"line",paint:Q})]})}function P2(c,u=!1,g=!1,y=!1,x=.7,C){const T=gs(C);return y?x>=.75?T.restBright:T.rest:x>=.85?T.rest:(x>=.7,T.restDim)}function Ji(c){return[c[1],c[0]]}function Q2(c,u,g,y=12){const[x,C]=c,[T,P]=u,_=[];for(let E=0;E<=y;E++){const Q=E/y,O=C+(P-C)*Q,H=x+(T-x)*Q,V=4*g*Q*(1-Q);_.push([O,H,V])}return _}function Xi(c,u,g,y,x,C,T,P,_,E,Q,O="dark"){const H=Uo(),V=[];let K=1/0,aA=-1/0;const J=[];for(const Z of c){const uA=Z.edge.avgConfidence??(u?.7:.5),oA=Z.edge.certainCount/Math.max(T,1),vA=uA*.7+oA*.3+(u?.5:0);J.push({polyline:Z,brightnessScore:vA}),K=Math.min(K,vA),aA=Math.max(aA,vA)}if(J.length===0)return{type:"FeatureCollection",features:[]};const eA=aA-K||1;J.sort((Z,uA)=>Z.brightnessScore-uA.brightnessScore);for(const{polyline:Z,brightnessScore:uA}of J){const{from:oA,to:vA,edge:iA}=Z,fA=g.get(iA.key)??0;if(fA<=0)continue;const jA=P.has(iA.key),DA=_.has(iA.key),CA=iA.avgConfidence??(u?.7:.5),yA=E===iA.key,kA=Q[iA.fromHash],LA=Q[iA.toHash],NA=(kA==null?void 0:kA.node_name)||(kA==null?void 0:kA.name)||iA.fromHash.slice(0,8),GA=(LA==null?void 0:LA.node_name)||(LA==null?void 0:LA.name)||iA.toHash.slice(0,8),bA=[oA[0]+(vA[0]-oA[0])*fA,oA[1]+(vA[1]-oA[1])*fA];let cA;if(!u)cA=1.5;else{const ae=C.get(iA.key)??Co(iA.certainCount),JA=x.get(iA.key)??ae;cA=JA+(ae-JA)*y,yA?cA=Math.max(cA*1.6,4.5):DA&&(cA=cA*1.3)}let sA;yA?sA=H.edges.highlight:sA=P2(!1,iA.isDirectPathEdge??!1,jA,DA,CA,O);let TA;yA?TA=H.edges.highlight:iA.isDirectPathEdge?TA=H.edges.hoverDirect:jA?TA=H.edges.hoverLoop:TA=H.edges.hoverStandard;let MA;if(!u)MA=(.3+CA*.3)*fA;else{const ae=Math.min(fA*1.5,1)*H.edgeOpacity;MA=DA?ae*1.15:ae}yA&&(MA=.95);const WA=(uA-K)/eA;V.push({type:"Feature",properties:{key:iA.key,baseColor:sA,hoverColor:TA,baseWidth:cA,baseOpacity:MA,brightnessScore:WA,isLoopEdge:jA,isBackbone:DA,isDirectPath:iA.isDirectPathEdge??!1,isHubConnection:iA.isHubConnection??!1,isZeroHop:iA.isZeroHop??!1,isValidated:u,certainCount:iA.certainCount,confidence:CA,symmetryRatio:iA.symmetryRatio??1,dominantDirection:iA.dominantDirection??"balanced",fromName:NA,toName:GA,fromHash:iA.fromHash,toHash:iA.toHash},geometry:{type:"LineString",coordinates:[Ji(oA),Ji(bA)]}})}return{type:"FeatureCollection",features:V}}const O2=150,z2=8;function As(c,u){const g=Uo(),y=[];let x=0;for(const C of c){const T=u.get(C.hash);T&&T.blendedScore>x&&(x=T.blendedScore)}for(const C of c){const{from:T,to:P,hash:_,neighbor:E,lastHopData:Q}=C,O=`neighbor-${_}`,H=(Q==null?void 0:Q.avgRssi)??E.rssi??null,V=(Q==null?void 0:Q.avgSnr)??E.snr??null,K=(Q==null?void 0:Q.count)??0,aA=(Q==null?void 0:Q.confidence)??1,J=u.get(_),eA=(J==null?void 0:J.listenerScore)??0,Z=(J==null?void 0:J.loudScore)??0,uA=(J==null?void 0:J.blendedScore)??0,oA=x>0?uA/x:0,vA=C.rxAdvertCount??0,iA=C.txProxyCount??0,fA=vA+iA,jA=fA>0?(iA-vA)/fA:0,DA=Q2(T,P,O2,z2);y.push({type:"Feature",properties:{key:O,hash:_,name:E.node_name||E.name||_.slice(0,8),prefix:_.slice(2,4).toUpperCase(),color:g.neighborColor,width:2.5,opacity:.85,rssi:H,snr:V,packetCount:K,confidence:aA,hasAvgRssi:(Q==null?void 0:Q.avgRssi)!==void 0,hasAvgSnr:(Q==null?void 0:Q.avgSnr)!==void 0,isNeighborEdge:!0,listenerScore:eA,loudScore:Z,blendedScore:uA,trafficWeight:oA,linkAsymmetry:jA,rxAdvertCount:vA,txProxyCount:iA},geometry:{type:"LineString",coordinates:DA}})}return{type:"FeatureCollection",features:y}}function H2({map:c,showTopology:u,validatedPolylines:g,weakPolylines:y,maxCertainCount:x,loopEdgeKeys:C,backboneEdgeKeys:T,highlightedEdgeKey:P,neighbors:_,validatedSourceId:E,weakSourceId:Q,neighborPolylines:O=[],showNeighborLines:H=!0,neighborSourceId:V,neighborLinkScores:K=new Map,basemapMode:aA}){const J=R.useRef(null);R.useEffect(()=>{const oe=c&&"current"in c?c.current:c;J.current=oe});const eA=R.useRef(new Map),Z=R.useRef(1),uA=R.useRef(new Map),oA=R.useRef(new Map),vA=R.useRef(!1),iA=R.useRef(null),fA=R.useRef(u),jA=R.useRef(new Set),DA=R.useRef(""),CA=R.useRef(new Map),yA=R.useRef(""),kA=R.useRef(""),LA=R.useRef(""),NA=R.useRef(g),GA=R.useRef(y),bA=R.useRef(x),cA=R.useRef(C),sA=R.useRef(T),TA=R.useRef(P),MA=R.useRef(_),WA=R.useRef(O),ae=R.useRef(H),JA=R.useRef(K),ZA=R.useRef(aA);R.useEffect(()=>{NA.current=g,GA.current=y,bA.current=x,cA.current=C,sA.current=T,TA.current=P,MA.current=_,WA.current=O,ae.current=H,JA.current=K,ZA.current=aA},[g,y,x,C,T,P,_,O,H,K,aA]);const UA=R.useCallback((oe=!1)=>{var Ce,Se,pe,Ke,$e,qe,Xe,vt,Qe,Je;const me=J.current;if(!me)return;const ue=me.getSource(E),Ye=me.getSource(Q),be=me.getSource(V);if(ue){const Be=Xi(NA.current,!0,eA.current,Z.current,uA.current,oA.current,bA.current,cA.current,sA.current,TA.current,MA.current,ZA.current),ze=`${Be.features.length}:${((Se=(Ce=Be.features[0])==null?void 0:Ce.properties)==null?void 0:Se.key)??""}:${((Ke=(pe=Be.features[Be.features.length-1])==null?void 0:pe.properties)==null?void 0:Ke.key)??""}:${Array.from(eA.current.values()).reduce((st,jt)=>st+jt,0).toFixed(2)}`;(oe||ze!==yA.current)&&(ue.setData(Be),yA.current=ze)}if(Ye){const Be=Xi(GA.current,!1,eA.current,Z.current,uA.current,oA.current,bA.current,cA.current,sA.current,TA.current,MA.current,ZA.current),ze=`${Be.features.length}:${((qe=($e=Be.features[0])==null?void 0:$e.properties)==null?void 0:qe.key)??""}:${((vt=(Xe=Be.features[Be.features.length-1])==null?void 0:Xe.properties)==null?void 0:vt.key)??""}`;(oe||ze!==kA.current)&&(Ye.setData(Be),kA.current=ze)}if(be&&WA.current.length>0){const Be=As(WA.current,JA.current),ze=`${Be.features.length}:${((Je=(Qe=Be.features[0])==null?void 0:Qe.properties)==null?void 0:Je.hash)??""}`;(oe||ze!==LA.current)&&(be.setData(Be),LA.current=ze)}},[E,Q,V]),Ie=R.useCallback(()=>{iA.current&&(cancelAnimationFrame(iA.current),iA.current=null),eA.current=new Map,Z.current=1,uA.current=new Map,oA.current=new Map,vA.current=!1,jA.current=new Set,DA.current="",CA.current=new Map},[]);R.useEffect(()=>{const oe=fA.current,me=u;if(fA.current=u,!!J.current){if(iA.current&&(cancelAnimationFrame(iA.current),iA.current=null),oe&&!me&&!vA.current){vA.current=!0;const Ye=new Map(eA.current);let be=null;const Ce=Se=>{be||(be=Se);const pe=Se-be,Ke=Math.min(pe/ic,1),$e=Ls(Ke);for(const[qe,Xe]of Ye)eA.current.set(qe,Xe*(1-$e));UA(!0),Ke<1?iA.current=requestAnimationFrame(Ce):(vA.current=!1,eA.current=new Map,jA.current=new Set,DA.current="",uA.current=new Map,oA.current=new Map,iA.current=null,UA(!0))};iA.current=requestAnimationFrame(Ce)}!oe&&me&&(eA.current=new Map,jA.current=new Set,DA.current="")}},[u,UA]),R.useEffect(()=>{const oe=J.current;if(!u||vA.current||!oe)return;const me=[...g,...y],ue=me.map(pe=>`${pe.edge.key}:${pe.edge.certainCount}`).sort().join(","),Ye=jA.current.size===0,be=DA.current!==""&&DA.current!==ue;if(!Ye&&!be){UA();return}const Ce=[],Se=[];for(const{edge:pe}of me)jA.current.has(pe.key)?Se.push(pe.key):Ce.push(pe.key);be&&Se.length>0&&(uA.current=new Map(CA.current),Z.current=0),oA.current=new Map;for(const{edge:pe}of g){const Ke=Co(pe.certainCount);oA.current.set(pe.key,Ke)}for(const pe of Ce)eA.current.set(pe,0);for(const pe of Se)eA.current.has(pe)||eA.current.set(pe,1);if(Ce.length>0||be&&Se.length>0){iA.current&&(cancelAnimationFrame(iA.current),iA.current=null);let pe=null;const Ke=Math.min(100,Mn/Math.max(Ce.length,1)/2),$e=qe=>{pe||(pe=qe);const Xe=qe-pe;for(let Qe=0;Qe0){const Qe=Math.min(Xe/Mn,1);Z.current=ko(Qe)}UA(!0);const vt=Mn+(Ce.length-1)*Ke;Xe{const oe=J.current;if(!oe||!V)return;const me=()=>{const be=oe.getSource(V);if(!be)return!1;if(O.length>0){const Ce=As(O,K);be.setData(Ce)}else be.setData({type:"FeatureCollection",features:[]});return!0};if(me())return;const ue=be=>{be.sourceId===V&&me()&&oe.off("sourcedata",ue)};oe.on("sourcedata",ue);const Ye=()=>{me()&&(oe.off("styledata",Ye),oe.off("sourcedata",ue))};return oe.on("styledata",Ye),()=>{oe.off("sourcedata",ue),oe.off("styledata",Ye)}},[V,O,K]);const Le=R.useRef(aA);return R.useEffect(()=>{aA!==Le.current&&(Le.current=aA,yA.current="",kA.current="",LA.current="",UA(!0))},[aA,UA]),R.useEffect(()=>()=>{iA.current&&(cancelAnimationFrame(iA.current),iA.current=null)},[]),{isExiting:vA.current,isAnimating:iA.current!==null,resetAnimationState:Ie,weightAnimProgress:Z.current,animStartWeights:uA.current,animTargetWeights:oA.current}}function G2({activeFilters:c,neighborHashes:u,hubConnectedNodes:g,directNodeSet:y,localConnectedNodes:x,nodeTypeMap:C,showTopology:T}){const[P,_]=R.useState(new Map),E=R.useMemo(()=>[...c].sort().join(","),[c]),Q=R.useRef(E),O=R.useRef(!1),H=R.useRef(new Map),V=R.useRef(null),K=R.useRef(g),aA=R.useRef(y),J=R.useRef(x),eA=R.useRef(C),Z=R.useRef(T);return R.useEffect(()=>{K.current=g,aA.current=y,J.current=x,eA.current=C,Z.current=T},[g,y,x,C,T]),R.useEffect(()=>{const oA=Q.current,vA=E;if(Q.current=E,oA===vA)return;V.current&&(cancelAnimationFrame(V.current),V.current=null);const iA=new Set(oA?oA.split(",").filter(Boolean):[]),fA=c,jA=K.current,DA=aA.current,CA=eA.current;for(const bA of u)H.current.has(bA)||H.current.set(bA,Math.random());const yA=(bA,cA)=>{if(cA.size===0)return!1;const sA=CA.get(bA)??"unknown";return!!(cA.has("repeater")&&sA==="repeater"||cA.has("companion")&&(sA==="companion"||sA==="unknown")||cA.has("room_server")&&sA==="room_server"||cA.has("direct")&&DA.has(bA)||cA.has("hubs")&&jA.has(bA))},kA=[];for(const bA of u){const cA=yA(bA,iA),sA=yA(bA,fA);cA!==sA&&kA.push({hash:bA,startOpacity:cA?1:0,targetOpacity:sA?1:0})}if(kA.length===0)return;O.current=!0,_(bA=>{const cA=new Map(bA);for(const{hash:sA,startOpacity:TA}of kA)cA.set(sA,TA);return cA});const LA=kA;let NA=null;const GA=bA=>{NA||(NA=bA);const cA=bA-NA;let sA=!0;_(()=>{const MA=new Map;for(const{hash:WA,startOpacity:ae,targetOpacity:JA}of LA){const ZA=(H.current.get(WA)??0)*Mi,UA=Math.max(0,cA-ZA),Ie=Math.min(UA/Si,1),Le=ko(Ie),oe=ae+(JA-ae)*Le;MA.set(WA,oe),Ie<1&&(sA=!1)}return MA});const TA=Si+Mi;cA{V.current&&(cancelAnimationFrame(V.current),V.current=null),O.current=!1}},[E,c,u]),{nodeOpacities:P,getNodeOpacity:(oA,vA)=>O.current&&P.has(oA)?P.get(oA):vA?1:0}}const po=240,es=240;function U2(c,u){if(c{T.current=C},[C]);const P=R.useRef(0),_=R.useRef(null),E=R.useRef(new Map),Q=R.useRef(new Map);R.useEffect(()=>{Q.current=V2(c)},[c]);const O=R.useRef(null);return R.useEffect(()=>{const H=()=>{const V=performance.now(),K=E.current;if(K.size===0){_.current=null,x(new Map);return}const aA=new Map,J=[];for(const[eA,{startTime:Z,staggerDelay:uA}]of K){const oA=V-Z-uA;if(!(oA<0))if(oA>=Bn)J.push(eA);else{const vA=U2(oA,Bn);vA>0&&aA.set(eA,vA)}}for(const eA of J)K.delete(eA);x(aA),K.size>0&&O.current?_.current=requestAnimationFrame(O.current):_.current=null};O.current=H},[]),R.useEffect(()=>{if(!g)return;const H=T.current;if(H.length===0)return;const V=P.current,K=H.filter(Z=>(Z.timestamp??0)>V);if(V===0){const Z=H.reduce((uA,oA)=>Math.max(uA,oA.timestamp??0),0);P.current=Z;return}if(K.length===0)return;const aA=K.reduce((Z,uA)=>Math.max(Z,uA.timestamp??0),0);P.current=aA;const J=performance.now();let eA=0;for(const Z of K){const uA=Es(Z,u);if(!uA||uA.original.length===0)continue;const oA=W2(uA.original,Q.current,u);if(oA.length===0)continue;const vA=Bn*.5;for(let iA=0;iA()=>{_.current!==null&&(cancelAnimationFrame(_.current),_.current=null)},[]),{blinkingNodes:y,blinkColor:oc}}const $0="edge-blink-source",pr="edge-blink-layer",_o=1e3,To=1e3,yo=150,K2=175,Z2=3e4,$2=e0.teal,q2="#8B7BAD",J2=2.5,X2=1.875,A1=.5,Un="node-markers-layer";function e1(c){if(!c.getLayer(pr))return;const u=c.getLayer(Un)?Un:void 0;try{c.moveLayer(pr,u)}catch{}}function t1(c,u){const g=new Map;for(const y of Object.keys(c)){const x=hn(y);g.has(x)||g.set(x,y)}if(u){const y=hn(u);g.set(y,u)}return g}function r1(c){return c<0||c>=_o?0:1-c/_o}function n1(c){if(c<0||c>=To)return 0;const u=c/To;return Math.pow(1-u,3)}function Nn(c){return[c[1],c[0]]}function o1({map:c,nodeCoordinates:u,packets:g,localHash:y,neighbors:x,meshTopology:C,enabled:T=!0}){const P=R.useRef(null),_=c&&"current"in c?c.current:c;R.useEffect(()=>{P.current=_},[_]);const E=R.useRef(!1),Q=R.useRef(null),O=R.useRef([]),H=R.useRef(0),V=R.useRef(!1),[K,aA]=R.useState(!1),J=R.useRef(null),eA=R.useRef([]),Z=R.useRef(new Map),uA=R.useRef(u);R.useEffect(()=>{uA.current=u},[u]),R.useEffect(()=>{Z.current=t1(x,y)},[x,y]),R.useEffect(()=>{if(!T){J.current&&(clearTimeout(J.current),J.current=null),eA.current=[],Q.current!==null&&(cancelAnimationFrame(Q.current),Q.current=null),O.current=[];const fA=P.current;if(fA&&E.current){const jA=fA.getSource($0);jA&&jA.setData({type:"FeatureCollection",features:[]})}V.current=!1,H.current=0}},[T]),R.useEffect(()=>{const fA=_;if(!fA)return;let jA=null,DA=!1;const CA=()=>{if(!DA&&!E.current)try{fA.getLayer(pr)&&fA.removeLayer(pr),fA.getSource($0)&&fA.removeSource($0),fA.addSource($0,{type:"geojson",data:{type:"FeatureCollection",features:[]}});const yA=fA.getLayer(Un)?Un:void 0;fA.addLayer({id:pr,type:"line",source:$0,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":["case",["any",["==",["get","isSpeculative"],!0],["==",["get","isSpeculative"],"true"]],q2,$2],"line-width":["case",["any",["==",["get","isSpeculative"],!0],["==",["get","isSpeculative"],"true"]],X2,J2],"line-opacity":["*",["get","opacityMult"],["interpolate",["linear"],["get","intensity"],0,0,.1,.8,.5,1,1,1]]}},yA),E.current=!0,aA(!0),jA&&(clearInterval(jA),jA=null)}catch{}};return fA.isStyleLoaded()&&CA(),fA.once("style.load",()=>{CA()}),E.current||(jA=setInterval(()=>{if(E.current){jA&&clearInterval(jA);return}CA()},100),setTimeout(()=>{jA&&(clearInterval(jA),jA=null)},5e3)),()=>{DA=!0,jA&&clearInterval(jA),Q.current!==null&&(cancelAnimationFrame(Q.current),Q.current=null);const yA=P.current;if(yA&&E.current){try{yA.getLayer(pr)&&yA.removeLayer(pr),yA.getSource($0)&&yA.removeSource($0)}catch{}E.current=!1,aA(!1)}}},[_]);const oA=R.useRef(()=>{});R.useEffect(()=>{oA.current=()=>{const fA=P.current;if(!fA)return;const jA=fA.getSource($0);if(!jA)return;const DA=performance.now(),CA=O.current,yA=[],kA=[];for(const LA of CA){const NA=DA-LA.startTime-LA.delay,GA=LA.isSpeculative?To:_o;if(NA0&&yA.push({type:"Feature",properties:{intensity:bA,opacityMult:LA.isSpeculative?A1:1,isSpeculative:LA.isSpeculative??!1},geometry:{type:"LineString",coordinates:[LA.fromCoord,LA.toCoord]}})}}jA.setData({type:"FeatureCollection",features:yA}),O.current=kA,kA.length>0?Q.current=requestAnimationFrame(()=>oA.current()):Q.current=null}},[]);const vA=R.useCallback(()=>{const fA=P.current;fA&&e1(fA),Q.current===null&&(Q.current=requestAnimationFrame(()=>oA.current()))},[]),iA=R.useCallback(()=>{if(!P.current||!E.current)return;const jA=eA.current;if(eA.current=[],J.current=null,jA.length===0)return;const DA=Z.current,CA=uA.current;if(DA.size===0)return;const yA=performance.now();let kA=0,LA=!1;const NA=new Set;for(const GA of jA){const bA=Es(GA,y);if(!bA||bA.original.length<2)continue;const cA=bA.original;let sA=0,TA=null;for(let JA=0;JA0){JA.sort((Le,oe)=>oe.confidence-Le.confidence);const ZA=Math.max(1,Math.ceil(JA.length*.25)),UA=JA.slice(0,ZA),Ie=kA+sA*yo;for(const{edgeKey:Le,otherHash:oe}of UA){const me=CA.get(TA),ue=CA.get(oe);O.current.push({edgeKey:Le,fromCoord:Nn(me),toCoord:Nn(ue),startTime:yA,delay:Ie,isSpeculative:!0}),NA.add(Le),LA=!0}}}sA>0&&(kA+=sA*yo*.5)}LA&&vA()},[y,C,vA]);R.useEffect(()=>{const fA=P.current;if(!T||!fA||!K||g.length===0)return;const jA=Date.now(),DA=H.current;if(!V.current){V.current=!0;const kA=(jA-Z2)/1e3,LA=g.filter(GA=>(GA.timestamp??0)>=kA);let NA=0;for(const GA of g){const bA=GA.timestamp??0;bA>NA&&(NA=bA)}if(H.current=NA,LA.length>0){LA.sort((bA,cA)=>(bA.timestamp??0)-(cA.timestamp??0));const GA=LA.slice(-20);eA.current.push(...GA),iA()}return}const CA=g.filter(kA=>(kA.timestamp??0)>DA);if(CA.length===0)return;let yA=0;for(const kA of CA){const LA=kA.timestamp??0;LA>yA&&(yA=LA)}H.current=yA,eA.current.push(...CA),J.current&&clearTimeout(J.current),J.current=setTimeout(iA,K2)},[T,g,iA,K]),R.useEffect(()=>()=>{J.current&&clearTimeout(J.current)},[])}var q0={},mr={};/** + `,children:[p.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2 sm:py-2 min-h-[44px] sm:min-h-0 border-b border-edge-subtle",children:[p.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[p.jsx(Ps,{className:"w-4 h-4 sm:w-3.5 sm:h-3.5 text-sys-green shrink-0"}),p.jsx(Or,{prefix:c.nodeA.prefix,name:H}),p.jsx("span",{className:"type-data-xs text-fg-muted",children:"↔"}),p.jsx(Or,{prefix:c.nodeB.prefix,name:V})]}),p.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[aA>0&&p.jsx("span",{className:"type-data-xs text-fg-muted",title:pi(aA),children:bs(aA)}),p.jsx(Ot,{plain:!0,color:"muted",onClick:u,className:"!p-1.5 sm:!p-0.5 !rounded-md min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 flex items-center justify-center",children:p.jsx(dn,{className:"w-4 h-4 sm:w-3.5 sm:h-3.5"})})]})]}),p.jsxs("div",{className:"px-3 py-2.5 border-b border-edge-subtle",children:[p.jsxs("div",{className:"space-y-1.5 mb-2",children:[p.jsxs("div",{className:"flex items-center justify-between cursor-help",title:`${c.nodeA.prefix}→${c.nodeB.prefix}: mean of ${((GA=c.aToB)==null?void 0:GA.count)??0} measurements`,children:[p.jsxs("span",{className:"flex items-center gap-1",children:[p.jsx(Or,{prefix:c.nodeA.prefix,name:H}),p.jsx("span",{className:"type-data-xs text-fg-muted",children:"→"}),p.jsx(Or,{prefix:c.nodeB.prefix,name:V})]}),c.aToB?p.jsxs("span",{className:`type-data-sm tabular-nums font-semibold ${fn(c.aToB.mean,E)}`,children:[c.aToB.mean.toFixed(1),p.jsx("span",{className:"text-fg-muted font-normal ml-0.5",children:"dB"})]}):p.jsx("span",{className:"type-data-sm text-fg-muted",children:"—"})]}),p.jsxs("div",{className:"flex items-center justify-between cursor-help",title:`${c.nodeB.prefix}→${c.nodeA.prefix}: mean of ${((bA=c.bToA)==null?void 0:bA.count)??0} measurements`,children:[p.jsxs("span",{className:"flex items-center gap-1",children:[p.jsx(Or,{prefix:c.nodeB.prefix,name:V}),p.jsx("span",{className:"type-data-xs text-fg-muted",children:"→"}),p.jsx(Or,{prefix:c.nodeA.prefix,name:H})]}),c.bToA?p.jsxs("span",{className:`type-data-sm tabular-nums font-semibold ${fn(c.bToA.mean,E)}`,children:[c.bToA.mean.toFixed(1),p.jsx("span",{className:"text-fg-muted font-normal ml-0.5",children:"dB"})]}):p.jsx("span",{className:"type-data-sm text-fg-muted",children:"—"})]})]}),p.jsxs("div",{className:"grid grid-cols-2 gap-0 -mx-3 border-t border-edge-subtle",children:[p.jsx("div",{className:"px-3 pt-2 pb-1 border-r border-edge-subtle",children:p.jsx(Hi,{stats:c.aToB,direction:`${c.nodeA.prefix}→${c.nodeB.prefix}`,sf:E,noiseFloor:T})}),p.jsx("div",{className:"px-3 pt-2 pb-1",children:p.jsx(Hi,{stats:c.bToA,direction:`${c.nodeB.prefix}→${c.nodeA.prefix}`,sf:E,noiseFloor:T})})]})]}),p.jsxs("div",{className:"px-3 py-1.5 border-b border-edge-subtle",children:[K!=="insufficient"&&p.jsxs("div",{className:"flex items-center justify-between gap-2 py-[3px] cursor-help",title:eA,children:[p.jsx("span",{className:"type-data-xs text-fg-muted",children:"Trend"}),p.jsx("span",{className:"data-box data-box-compact",children:p.jsxs("span",{className:"flex items-center gap-1",children:[uf(K),p.jsx("span",{className:"text-fg-secondary capitalize",children:K})]})})]}),J>0&&p.jsx(zn,{label:"Unique traces",value:J.toString(),tooltip:oA})]}),O.length>0&&p.jsxs("div",{className:"px-3 py-2 flex-1 min-h-0 flex flex-col",children:[p.jsxs("p",{className:"type-micro text-fg-secondary mb-1 shrink-0",children:["Source packets (",O.length,")"]}),p.jsx("div",{className:"overflow-y-auto flex-1 min-h-0 overscroll-contain",style:{scrollbarGutter:"stable"},children:O.map((cA,sA)=>{const TA=Ys(cA),MA=TA?Ks(cA,TA):null,WA=MA?Math.max(0,MA.length-1):0,ae=MA?MA.map(UA=>(g==null?void 0:g.get(UA))??UA).join(" → "):null,JA=P===sA,ZA=cA.id??`${cA.packet_hash}-${cA.timestamp}`;return p.jsxs("div",{className:"rounded-sm",style:sA%2===1?cf:void 0,children:[p.jsxs("button",{onClick:()=>_(JA?null:sA),className:"flex items-center gap-1.5 py-[3px] px-1 w-full text-left text-[10px] font-mono text-fg-secondary hover:text-fg-primary transition-colors group",children:[JA?p.jsx(ys,{className:"w-2.5 h-2.5 text-fg-muted shrink-0"}):p.jsx(lu,{className:"w-2.5 h-2.5 text-fg-muted shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"}),p.jsx("span",{className:"text-fg-muted w-[52px] shrink-0",children:pi(cA.timestamp)}),ae?p.jsx("span",{className:"text-fg-secondary truncate min-w-0",title:MA.join(" → "),children:ae}):p.jsx("span",{className:"text-fg-muted truncate min-w-0 italic",children:"path n/a"}),p.jsxs("span",{className:"text-fg-muted shrink-0",children:[WA,"h"]}),cA.snr!=null&&p.jsx("span",{className:`shrink-0 tabular-nums ${fn(cA.snr,E)}`,children:cA.snr.toFixed(1)})]}),JA&&p.jsxs("div",{className:"mb-1 mt-0.5 mx-1 pl-2 border-l border-edge-subtle space-y-0.5 text-[10px]",children:[cA.rssi!=null&&p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:"text-fg-muted",children:"RSSI"}),p.jsxs("span",{className:"font-mono tabular-nums text-fg-secondary",children:[cA.rssi," dBm"]})]}),cA.snr!=null&&p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:"text-fg-muted",children:"SNR"}),p.jsxs("span",{className:`font-mono tabular-nums ${fn(cA.snr,E)}`,children:[cA.snr.toFixed(1)," dB"]})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:"text-fg-muted",children:"Route"}),p.jsx("span",{className:"font-mono text-fg-secondary",children:ma(cA.route??cA.route_type)})]}),cA.packet_hash&&p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:"text-fg-muted",children:"Hash"}),p.jsxs("button",{onClick:UA=>{UA.stopPropagation(),navigator.clipboard.writeText(cA.packet_hash)},className:"flex items-center gap-1 font-mono text-fg-secondary hover:text-fg-primary transition-colors",title:"Copy packet hash",children:[p.jsx("span",{className:"truncate max-w-[120px]",children:cA.packet_hash}),p.jsx(Ho,{className:"w-2.5 h-2.5 text-fg-muted shrink-0"})]})]}),cA.src_hash&&p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:"text-fg-muted",children:"Source"}),p.jsx("span",{className:"font-mono text-fg-secondary truncate max-w-[140px]",title:cA.src_hash,children:cA.src_hash})]}),MA&&MA.length>0&&p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:"text-fg-muted",children:"Path"}),p.jsx("span",{className:"font-mono text-fg-secondary truncate max-w-[140px]",title:MA.join(" → "),children:MA.join(" → ")})]})]})]},ZA)})})]})]})})}const hf={getItem:c=>{try{return localStorage.getItem(c)}catch{return null}},setItem:(c,u)=>{try{localStorage.setItem(c,u)}catch{}},removeItem:c=>{try{localStorage.removeItem(c)}catch{}}},Zs=ws()(Au(c=>({isEnabled:!1,toggle:()=>c(u=>({isEnabled:!u.isEnabled})),setEnabled:u=>c({isEnabled:u})}),{name:"pymc-live-trace",storage:eu(()=>hf)})),df=()=>Zs(c=>c.isEnabled),mf=()=>Zs(c=>c.toggle);var Rt=(function(c){c=c||{};var u=typeof c<"u"?c:{},g={},y;for(y in u)u.hasOwnProperty(y)&&(g[y]=u[y]);var x="";function C(rA){return u.locateFile?u.locateFile(rA,x):x+rA}var T;typeof document<"u"&&document.currentScript&&(x=document.currentScript.src),x.indexOf("blob:")!==0?x=x.substr(0,x.lastIndexOf("/")+1):x="",T=function(pA,IA,xA){var t=new XMLHttpRequest;t.open("GET",pA,!0),t.responseType="arraybuffer",t.onload=function(){if(t.status==200||t.status==0&&t.response){IA(t.response);return}var ge=c0(pA);if(ge){IA(ge.buffer);return}xA()},t.onerror=xA,t.send(null)};var P=u.print||console.log.bind(console),_=u.printErr||console.warn.bind(console);for(y in g)g.hasOwnProperty(y)&&(u[y]=g[y]);g=null,u.arguments&&u.arguments;var E=0,Q=function(rA){E=rA},O=function(){return E},H=8;function V(rA,pA,IA,xA){switch(IA=IA||"i8",IA.charAt(IA.length-1)==="*"&&(IA="i32"),IA){case"i1":kA[rA>>0]=pA;break;case"i8":kA[rA>>0]=pA;break;case"i16":NA[rA>>1]=pA;break;case"i32":GA[rA>>2]=pA;break;case"i64":st=[pA>>>0,(ze=pA,+Ce(ze)>=1?ze>0?(Ke(+pe(ze/4294967296),4294967295)|0)>>>0:~~+Se((ze-+(~~ze>>>0))/4294967296)>>>0:0)],GA[rA>>2]=st[0],GA[rA+4>>2]=st[1];break;case"float":bA[rA>>2]=pA;break;case"double":cA[rA>>3]=pA;break;default:dt("invalid type for setValue: "+IA)}}function K(rA,pA,IA){switch(pA=pA||"i8",pA.charAt(pA.length-1)==="*"&&(pA="i32"),pA){case"i1":return kA[rA>>0];case"i8":return kA[rA>>0];case"i16":return NA[rA>>1];case"i32":return GA[rA>>2];case"i64":return GA[rA>>2];case"float":return bA[rA>>2];case"double":return cA[rA>>3];default:dt("invalid type for getValue: "+pA)}return null}var aA=!1;function J(rA,pA){rA||dt("Assertion failed: "+pA)}function eA(rA){var pA=u["_"+rA];return J(pA,"Cannot call unknown function "+rA+", make sure it is exported"),pA}function Z(rA,pA,IA,xA,t){var b={string:function(ie){var et=0;if(ie!=null&&ie!==0){var Lt=(ie.length<<2)+1;et=at(Lt),jA(ie,et,Lt)}return et},array:function(ie){var et=at(ie.length);return DA(ie,et),et}};function ge(ie){return pA==="string"?iA(ie):pA==="boolean"?!!ie:ie}var De=eA(rA),He=[],$A=0;if(xA)for(var ye=0;ye=xA);)++t;if(t-pA>16&&rA.subarray&&oA)return oA.decode(rA.subarray(pA,t));for(var b="";pA>10,56320|$A&1023)}}return b}function iA(rA,pA){return rA?vA(LA,rA,pA):""}function fA(rA,pA,IA,xA){if(!(xA>0))return 0;for(var t=IA,b=IA+xA-1,ge=0;ge=55296&&De<=57343){var He=rA.charCodeAt(++ge);De=65536+((De&1023)<<10)|He&1023}if(De<=127){if(IA>=b)break;pA[IA++]=De}else if(De<=2047){if(IA+1>=b)break;pA[IA++]=192|De>>6,pA[IA++]=128|De&63}else if(De<=65535){if(IA+2>=b)break;pA[IA++]=224|De>>12,pA[IA++]=128|De>>6&63,pA[IA++]=128|De&63}else{if(IA+3>=b)break;pA[IA++]=240|De>>18,pA[IA++]=128|De>>12&63,pA[IA++]=128|De>>6&63,pA[IA++]=128|De&63}}return pA[IA]=0,IA-t}function jA(rA,pA,IA){return fA(rA,LA,pA,IA)}typeof TextDecoder<"u"&&new TextDecoder("utf-16le");function DA(rA,pA){kA.set(rA,pA)}function CA(rA,pA){return rA%pA>0&&(rA+=pA-rA%pA),rA}var yA,kA,LA,NA,GA,bA,cA;function sA(rA){yA=rA,u.HEAP8=kA=new Int8Array(rA),u.HEAP16=NA=new Int16Array(rA),u.HEAP32=GA=new Int32Array(rA),u.HEAPU8=LA=new Uint8Array(rA),u.HEAPU16=new Uint16Array(rA),u.HEAPU32=new Uint32Array(rA),u.HEAPF32=bA=new Float32Array(rA),u.HEAPF64=cA=new Float64Array(rA)}var TA=5271536,MA=28624,WA=u.TOTAL_MEMORY||33554432;u.buffer?yA=u.buffer:yA=new ArrayBuffer(WA),WA=yA.byteLength,sA(yA),GA[MA>>2]=TA;function ae(rA){for(;rA.length>0;){var pA=rA.shift();if(typeof pA=="function"){pA();continue}var IA=pA.func;typeof IA=="number"?pA.arg===void 0?u.dynCall_v(IA):u.dynCall_vi(IA,pA.arg):IA(pA.arg===void 0?null:pA.arg)}}var JA=[],ZA=[],UA=[],Ie=[];function Le(){if(u.preRun)for(typeof u.preRun=="function"&&(u.preRun=[u.preRun]);u.preRun.length;)Ye(u.preRun.shift());ae(JA)}function oe(){ae(ZA)}function me(){ae(UA)}function ue(){if(u.postRun)for(typeof u.postRun=="function"&&(u.postRun=[u.postRun]);u.postRun.length;)be(u.postRun.shift());ae(Ie)}function Ye(rA){JA.unshift(rA)}function be(rA){Ie.unshift(rA)}var Ce=Math.abs,Se=Math.ceil,pe=Math.floor,Ke=Math.min,$e=0,qe=null;function Xe(rA){$e++,u.monitorRunDependencies&&u.monitorRunDependencies($e)}function vt(rA){if($e--,u.monitorRunDependencies&&u.monitorRunDependencies($e),$e==0&&qe){var pA=qe;qe=null,pA()}}u.preloadedImages={},u.preloadedAudios={};var Qe=null,Je="data:application/octet-stream;base64,";function Be(rA){return String.prototype.startsWith?rA.startsWith(Je):rA.indexOf(Je)===0}var ze,st;Qe="data:application/octet-stream;base64,AAAAAAAAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAAAQAAAAQAAAADAAAABgAAAAUAAAACAAAAAAAAAAIAAAADAAAAAQAAAAQAAAAGAAAAAAAAAAUAAAADAAAABgAAAAQAAAAFAAAAAAAAAAEAAAACAAAABAAAAAUAAAAGAAAAAAAAAAIAAAADAAAAAQAAAAUAAAACAAAAAAAAAAEAAAADAAAABgAAAAQAAAAGAAAAAAAAAAUAAAACAAAAAQAAAAQAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAAAAAAEAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAYAAAAAAAAABQAAAAAAAAAAAAAABAAAAAUAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAYAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAABAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAgAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAMAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAAEAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABQAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAYAAAAAAAAAAQAAAAIAAAADAAAABAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAIAAAAAAAAAAAAAAAYAAAAAAAAAAwAAAAIAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAFAAAABAAAAAAAAAABAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAYAAAAAAAAABAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAFAAAAAgAAAAQAAAADAAAACAAAAAEAAAAHAAAABgAAAAkAAAAAAAAAAwAAAAIAAAACAAAABgAAAAoAAAALAAAAAAAAAAEAAAAFAAAAAwAAAA0AAAABAAAABwAAAAQAAAAMAAAAAAAAAAQAAAB/AAAADwAAAAgAAAADAAAAAAAAAAwAAAAFAAAAAgAAABIAAAAKAAAACAAAAAAAAAAQAAAABgAAAA4AAAALAAAAEQAAAAEAAAAJAAAAAgAAAAcAAAAVAAAACQAAABMAAAADAAAADQAAAAEAAAAIAAAABQAAABYAAAAQAAAABAAAAAAAAAAPAAAACQAAABMAAAAOAAAAFAAAAAEAAAAHAAAABgAAAAoAAAALAAAAGAAAABcAAAAFAAAAAgAAABIAAAALAAAAEQAAABcAAAAZAAAAAgAAAAYAAAAKAAAADAAAABwAAAANAAAAGgAAAAQAAAAPAAAAAwAAAA0AAAAaAAAAFQAAAB0AAAADAAAADAAAAAcAAAAOAAAAfwAAABEAAAAbAAAACQAAABQAAAAGAAAADwAAABYAAAAcAAAAHwAAAAQAAAAIAAAADAAAABAAAAASAAAAIQAAAB4AAAAIAAAABQAAABYAAAARAAAACwAAAA4AAAAGAAAAIwAAABkAAAAbAAAAEgAAABgAAAAeAAAAIAAAAAUAAAAKAAAAEAAAABMAAAAiAAAAFAAAACQAAAAHAAAAFQAAAAkAAAAUAAAADgAAABMAAAAJAAAAKAAAABsAAAAkAAAAFQAAACYAAAATAAAAIgAAAA0AAAAdAAAABwAAABYAAAAQAAAAKQAAACEAAAAPAAAACAAAAB8AAAAXAAAAGAAAAAsAAAAKAAAAJwAAACUAAAAZAAAAGAAAAH8AAAAgAAAAJQAAAAoAAAAXAAAAEgAAABkAAAAXAAAAEQAAAAsAAAAtAAAAJwAAACMAAAAaAAAAKgAAAB0AAAArAAAADAAAABwAAAANAAAAGwAAACgAAAAjAAAALgAAAA4AAAAUAAAAEQAAABwAAAAfAAAAKgAAACwAAAAMAAAADwAAABoAAAAdAAAAKwAAACYAAAAvAAAADQAAABoAAAAVAAAAHgAAACAAAAAwAAAAMgAAABAAAAASAAAAIQAAAB8AAAApAAAALAAAADUAAAAPAAAAFgAAABwAAAAgAAAAHgAAABgAAAASAAAANAAAADIAAAAlAAAAIQAAAB4AAAAxAAAAMAAAABYAAAAQAAAAKQAAACIAAAATAAAAJgAAABUAAAA2AAAAJAAAADMAAAAjAAAALgAAAC0AAAA4AAAAEQAAABsAAAAZAAAAJAAAABQAAAAiAAAAEwAAADcAAAAoAAAANgAAACUAAAAnAAAANAAAADkAAAAYAAAAFwAAACAAAAAmAAAAfwAAACIAAAAzAAAAHQAAAC8AAAAVAAAAJwAAACUAAAAZAAAAFwAAADsAAAA5AAAALQAAACgAAAAbAAAAJAAAABQAAAA8AAAALgAAADcAAAApAAAAMQAAADUAAAA9AAAAFgAAACEAAAAfAAAAKgAAADoAAAArAAAAPgAAABwAAAAsAAAAGgAAACsAAAA+AAAALwAAAEAAAAAaAAAAKgAAAB0AAAAsAAAANQAAADoAAABBAAAAHAAAAB8AAAAqAAAALQAAACcAAAAjAAAAGQAAAD8AAAA7AAAAOAAAAC4AAAA8AAAAOAAAAEQAAAAbAAAAKAAAACMAAAAvAAAAJgAAACsAAAAdAAAARQAAADMAAABAAAAAMAAAADEAAAAeAAAAIQAAAEMAAABCAAAAMgAAADEAAAB/AAAAPQAAAEIAAAAhAAAAMAAAACkAAAAyAAAAMAAAACAAAAAeAAAARgAAAEMAAAA0AAAAMwAAAEUAAAA2AAAARwAAACYAAAAvAAAAIgAAADQAAAA5AAAARgAAAEoAAAAgAAAAJQAAADIAAAA1AAAAPQAAAEEAAABLAAAAHwAAACkAAAAsAAAANgAAAEcAAAA3AAAASQAAACIAAAAzAAAAJAAAADcAAAAoAAAANgAAACQAAABIAAAAPAAAAEkAAAA4AAAARAAAAD8AAABNAAAAIwAAAC4AAAAtAAAAOQAAADsAAABKAAAATgAAACUAAAAnAAAANAAAADoAAAB/AAAAPgAAAEwAAAAsAAAAQQAAACoAAAA7AAAAPwAAAE4AAABPAAAAJwAAAC0AAAA5AAAAPAAAAEgAAABEAAAAUAAAACgAAAA3AAAALgAAAD0AAAA1AAAAMQAAACkAAABRAAAASwAAAEIAAAA+AAAAKwAAADoAAAAqAAAAUgAAAEAAAABMAAAAPwAAAH8AAAA4AAAALQAAAE8AAAA7AAAATQAAAEAAAAAvAAAAPgAAACsAAABUAAAARQAAAFIAAABBAAAAOgAAADUAAAAsAAAAVgAAAEwAAABLAAAAQgAAAEMAAABRAAAAVQAAADEAAAAwAAAAPQAAAEMAAABCAAAAMgAAADAAAABXAAAAVQAAAEYAAABEAAAAOAAAADwAAAAuAAAAWgAAAE0AAABQAAAARQAAADMAAABAAAAALwAAAFkAAABHAAAAVAAAAEYAAABDAAAANAAAADIAAABTAAAAVwAAAEoAAABHAAAAWQAAAEkAAABbAAAAMwAAAEUAAAA2AAAASAAAAH8AAABJAAAANwAAAFAAAAA8AAAAWAAAAEkAAABbAAAASAAAAFgAAAA2AAAARwAAADcAAABKAAAATgAAAFMAAABcAAAANAAAADkAAABGAAAASwAAAEEAAAA9AAAANQAAAF4AAABWAAAAUQAAAEwAAABWAAAAUgAAAGAAAAA6AAAAQQAAAD4AAABNAAAAPwAAAEQAAAA4AAAAXQAAAE8AAABaAAAATgAAAEoAAAA7AAAAOQAAAF8AAABcAAAATwAAAE8AAABOAAAAPwAAADsAAABdAAAAXwAAAE0AAABQAAAARAAAAEgAAAA8AAAAYwAAAFoAAABYAAAAUQAAAFUAAABeAAAAZQAAAD0AAABCAAAASwAAAFIAAABgAAAAVAAAAGIAAAA+AAAATAAAAEAAAABTAAAAfwAAAEoAAABGAAAAZAAAAFcAAABcAAAAVAAAAEUAAABSAAAAQAAAAGEAAABZAAAAYgAAAFUAAABXAAAAZQAAAGYAAABCAAAAQwAAAFEAAABWAAAATAAAAEsAAABBAAAAaAAAAGAAAABeAAAAVwAAAFMAAABmAAAAZAAAAEMAAABGAAAAVQAAAFgAAABIAAAAWwAAAEkAAABjAAAAUAAAAGkAAABZAAAAYQAAAFsAAABnAAAARQAAAFQAAABHAAAAWgAAAE0AAABQAAAARAAAAGoAAABdAAAAYwAAAFsAAABJAAAAWQAAAEcAAABpAAAAWAAAAGcAAABcAAAAUwAAAE4AAABKAAAAbAAAAGQAAABfAAAAXQAAAE8AAABaAAAATQAAAG0AAABfAAAAagAAAF4AAABWAAAAUQAAAEsAAABrAAAAaAAAAGUAAABfAAAAXAAAAE8AAABOAAAAbQAAAGwAAABdAAAAYAAAAGgAAABiAAAAbgAAAEwAAABWAAAAUgAAAGEAAAB/AAAAYgAAAFQAAABnAAAAWQAAAG8AAABiAAAAbgAAAGEAAABvAAAAUgAAAGAAAABUAAAAYwAAAFAAAABpAAAAWAAAAGoAAABaAAAAcQAAAGQAAABmAAAAUwAAAFcAAABsAAAAcgAAAFwAAABlAAAAZgAAAGsAAABwAAAAUQAAAFUAAABeAAAAZgAAAGUAAABXAAAAVQAAAHIAAABwAAAAZAAAAGcAAABbAAAAYQAAAFkAAAB0AAAAaQAAAG8AAABoAAAAawAAAG4AAABzAAAAVgAAAF4AAABgAAAAaQAAAFgAAABnAAAAWwAAAHEAAABjAAAAdAAAAGoAAABdAAAAYwAAAFoAAAB1AAAAbQAAAHEAAABrAAAAfwAAAGUAAABeAAAAcwAAAGgAAABwAAAAbAAAAGQAAABfAAAAXAAAAHYAAAByAAAAbQAAAG0AAABsAAAAXQAAAF8AAAB1AAAAdgAAAGoAAABuAAAAYgAAAGgAAABgAAAAdwAAAG8AAABzAAAAbwAAAGEAAABuAAAAYgAAAHQAAABnAAAAdwAAAHAAAABrAAAAZgAAAGUAAAB4AAAAcwAAAHIAAABxAAAAYwAAAHQAAABpAAAAdQAAAGoAAAB5AAAAcgAAAHAAAABkAAAAZgAAAHYAAAB4AAAAbAAAAHMAAABuAAAAawAAAGgAAAB4AAAAdwAAAHAAAAB0AAAAZwAAAHcAAABvAAAAcQAAAGkAAAB5AAAAdQAAAH8AAABtAAAAdgAAAHEAAAB5AAAAagAAAHYAAAB4AAAAbAAAAHIAAAB1AAAAeQAAAG0AAAB3AAAAbwAAAHMAAABuAAAAeQAAAHQAAAB4AAAAeAAAAHMAAAByAAAAcAAAAHkAAAB3AAAAdgAAAHkAAAB0AAAAeAAAAHcAAAB1AAAAcQAAAHYAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAACAAAABQAAAAEAAAAAAAAA/////wEAAAAAAAAAAwAAAAQAAAACAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAFAAAAAQAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAABQAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAEAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAQAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAUAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAAABQAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAADAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAAAAAD/////AwAAAAAAAAAFAAAAAgAAAAAAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAADAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAAAAAABAAAAAwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAADAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAwAAAAAAAAAAAAAA/////wMAAAAAAAAABQAAAAIAAAAAAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAwAAAAAAAAADAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAMAAAADAAAAAwAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAwAAAAUAAAABAAAAAAAAAP////8DAAAAAAAAAAUAAAACAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABAAAAAUAAAABAAAAAAAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAABQAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAIAAAAFAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAADAAAAAQAAAAAAAAABAAAAAAAAAAUAAAAAAAAAAAAAAAUAAAAFAAAAAAAAAAAAAAD/////AQAAAAAAAAADAAAABAAAAAIAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAFAAAABQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAUAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAEAAAD//////////wEAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAAAAAAAAAAABAAAAAgAAAAYAAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAAAAAAAAAAAAQAAAAEAAAAFAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAACAAAAAAAAAAAAAAABAAAAAwAAAAcAAAAGAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAADgAAAAIAAAAAAAAAAAAAAAEAAAAAAAAACQAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAMAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAIAAAAAAAAAAAAAAAEAAAAEAAAACAAAAAoAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAALAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAAAAAAAAAAAAQAAAAsAAAAPAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAIAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAABQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHAAAAAgAAAAAAAAAAAAAAAQAAAAwAAAAQAAAADAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAPAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAADwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAADQAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAUAAAACAAAAAAAAAAAAAAABAAAACgAAABMAAAAIAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAACQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAAAAAAAAAAAAAEAAAANAAAAEQAAAA0AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAARAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAEAAAABAAAAAAAAAAAAAAAAAAAAEQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAA0AAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAkAAAACAAAAAAAAAAAAAAABAAAADgAAABIAAAAPAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAADwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAASAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAABEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABIAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAATAAAAAgAAAAAAAAAAAAAAAQAAAP//////////EwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAEgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAASAAAAAAAAABgAAAAAAAAAIQAAAAAAAAAeAAAAAAAAACAAAAADAAAAMQAAAAEAAAAwAAAAAwAAADIAAAADAAAACAAAAAAAAAAFAAAABQAAAAoAAAAFAAAAFgAAAAAAAAAQAAAAAAAAABIAAAAAAAAAKQAAAAEAAAAhAAAAAAAAAB4AAAAAAAAABAAAAAAAAAAAAAAABQAAAAIAAAAFAAAADwAAAAEAAAAIAAAAAAAAAAUAAAAFAAAAHwAAAAEAAAAWAAAAAAAAABAAAAAAAAAAAgAAAAAAAAAGAAAAAAAAAA4AAAAAAAAACgAAAAAAAAALAAAAAAAAABEAAAADAAAAGAAAAAEAAAAXAAAAAwAAABkAAAADAAAAAAAAAAAAAAABAAAABQAAAAkAAAAFAAAABQAAAAAAAAACAAAAAAAAAAYAAAAAAAAAEgAAAAEAAAAKAAAAAAAAAAsAAAAAAAAABAAAAAEAAAADAAAABQAAAAcAAAAFAAAACAAAAAEAAAAAAAAAAAAAAAEAAAAFAAAAEAAAAAEAAAAFAAAAAAAAAAIAAAAAAAAABwAAAAAAAAAVAAAAAAAAACYAAAAAAAAACQAAAAAAAAATAAAAAAAAACIAAAADAAAADgAAAAEAAAAUAAAAAwAAACQAAAADAAAAAwAAAAAAAAANAAAABQAAAB0AAAAFAAAAAQAAAAAAAAAHAAAAAAAAABUAAAAAAAAABgAAAAEAAAAJAAAAAAAAABMAAAAAAAAABAAAAAIAAAAMAAAABQAAABoAAAAFAAAAAAAAAAEAAAADAAAAAAAAAA0AAAAFAAAAAgAAAAEAAAABAAAAAAAAAAcAAAAAAAAAGgAAAAAAAAAqAAAAAAAAADoAAAAAAAAAHQAAAAAAAAArAAAAAAAAAD4AAAADAAAAJgAAAAEAAAAvAAAAAwAAAEAAAAADAAAADAAAAAAAAAAcAAAABQAAACwAAAAFAAAADQAAAAAAAAAaAAAAAAAAACoAAAAAAAAAFQAAAAEAAAAdAAAAAAAAACsAAAAAAAAABAAAAAMAAAAPAAAABQAAAB8AAAAFAAAAAwAAAAEAAAAMAAAAAAAAABwAAAAFAAAABwAAAAEAAAANAAAAAAAAABoAAAAAAAAAHwAAAAAAAAApAAAAAAAAADEAAAAAAAAALAAAAAAAAAA1AAAAAAAAAD0AAAADAAAAOgAAAAEAAABBAAAAAwAAAEsAAAADAAAADwAAAAAAAAAWAAAABQAAACEAAAAFAAAAHAAAAAAAAAAfAAAAAAAAACkAAAAAAAAAKgAAAAEAAAAsAAAAAAAAADUAAAAAAAAABAAAAAQAAAAIAAAABQAAABAAAAAFAAAADAAAAAEAAAAPAAAAAAAAABYAAAAFAAAAGgAAAAEAAAAcAAAAAAAAAB8AAAAAAAAAMgAAAAAAAAAwAAAAAAAAADEAAAADAAAAIAAAAAAAAAAeAAAAAwAAACEAAAADAAAAGAAAAAMAAAASAAAAAwAAABAAAAADAAAARgAAAAAAAABDAAAAAAAAAEIAAAADAAAANAAAAAMAAAAyAAAAAAAAADAAAAAAAAAAJQAAAAMAAAAgAAAAAAAAAB4AAAADAAAAUwAAAAAAAABXAAAAAwAAAFUAAAADAAAASgAAAAMAAABGAAAAAAAAAEMAAAAAAAAAOQAAAAEAAAA0AAAAAwAAADIAAAAAAAAAGQAAAAAAAAAXAAAAAAAAABgAAAADAAAAEQAAAAAAAAALAAAAAwAAAAoAAAADAAAADgAAAAMAAAAGAAAAAwAAAAIAAAADAAAALQAAAAAAAAAnAAAAAAAAACUAAAADAAAAIwAAAAMAAAAZAAAAAAAAABcAAAAAAAAAGwAAAAMAAAARAAAAAAAAAAsAAAADAAAAPwAAAAAAAAA7AAAAAwAAADkAAAADAAAAOAAAAAMAAAAtAAAAAAAAACcAAAAAAAAALgAAAAMAAAAjAAAAAwAAABkAAAAAAAAAJAAAAAAAAAAUAAAAAAAAAA4AAAADAAAAIgAAAAAAAAATAAAAAwAAAAkAAAADAAAAJgAAAAMAAAAVAAAAAwAAAAcAAAADAAAANwAAAAAAAAAoAAAAAAAAABsAAAADAAAANgAAAAMAAAAkAAAAAAAAABQAAAAAAAAAMwAAAAMAAAAiAAAAAAAAABMAAAADAAAASAAAAAAAAAA8AAAAAwAAAC4AAAADAAAASQAAAAMAAAA3AAAAAAAAACgAAAAAAAAARwAAAAMAAAA2AAAAAwAAACQAAAAAAAAAQAAAAAAAAAAvAAAAAAAAACYAAAADAAAAPgAAAAAAAAArAAAAAwAAAB0AAAADAAAAOgAAAAMAAAAqAAAAAwAAABoAAAADAAAAVAAAAAAAAABFAAAAAAAAADMAAAADAAAAUgAAAAMAAABAAAAAAAAAAC8AAAAAAAAATAAAAAMAAAA+AAAAAAAAACsAAAADAAAAYQAAAAAAAABZAAAAAwAAAEcAAAADAAAAYgAAAAMAAABUAAAAAAAAAEUAAAAAAAAAYAAAAAMAAABSAAAAAwAAAEAAAAAAAAAASwAAAAAAAABBAAAAAAAAADoAAAADAAAAPQAAAAAAAAA1AAAAAwAAACwAAAADAAAAMQAAAAMAAAApAAAAAwAAAB8AAAADAAAAXgAAAAAAAABWAAAAAAAAAEwAAAADAAAAUQAAAAMAAABLAAAAAAAAAEEAAAAAAAAAQgAAAAMAAAA9AAAAAAAAADUAAAADAAAAawAAAAAAAABoAAAAAwAAAGAAAAADAAAAZQAAAAMAAABeAAAAAAAAAFYAAAAAAAAAVQAAAAMAAABRAAAAAwAAAEsAAAAAAAAAOQAAAAAAAAA7AAAAAAAAAD8AAAADAAAASgAAAAAAAABOAAAAAwAAAE8AAAADAAAAUwAAAAMAAABcAAAAAwAAAF8AAAADAAAAJQAAAAAAAAAnAAAAAwAAAC0AAAADAAAANAAAAAAAAAA5AAAAAAAAADsAAAAAAAAARgAAAAMAAABKAAAAAAAAAE4AAAADAAAAGAAAAAAAAAAXAAAAAwAAABkAAAADAAAAIAAAAAMAAAAlAAAAAAAAACcAAAADAAAAMgAAAAMAAAA0AAAAAAAAADkAAAAAAAAALgAAAAAAAAA8AAAAAAAAAEgAAAADAAAAOAAAAAAAAABEAAAAAwAAAFAAAAADAAAAPwAAAAMAAABNAAAAAwAAAFoAAAADAAAAGwAAAAAAAAAoAAAAAwAAADcAAAADAAAAIwAAAAAAAAAuAAAAAAAAADwAAAAAAAAALQAAAAMAAAA4AAAAAAAAAEQAAAADAAAADgAAAAAAAAAUAAAAAwAAACQAAAADAAAAEQAAAAMAAAAbAAAAAAAAACgAAAADAAAAGQAAAAMAAAAjAAAAAAAAAC4AAAAAAAAARwAAAAAAAABZAAAAAAAAAGEAAAADAAAASQAAAAAAAABbAAAAAwAAAGcAAAADAAAASAAAAAMAAABYAAAAAwAAAGkAAAADAAAAMwAAAAAAAABFAAAAAwAAAFQAAAADAAAANgAAAAAAAABHAAAAAAAAAFkAAAAAAAAANwAAAAMAAABJAAAAAAAAAFsAAAADAAAAJgAAAAAAAAAvAAAAAwAAAEAAAAADAAAAIgAAAAMAAAAzAAAAAAAAAEUAAAADAAAAJAAAAAMAAAA2AAAAAAAAAEcAAAAAAAAAYAAAAAAAAABoAAAAAAAAAGsAAAADAAAAYgAAAAAAAABuAAAAAwAAAHMAAAADAAAAYQAAAAMAAABvAAAAAwAAAHcAAAADAAAATAAAAAAAAABWAAAAAwAAAF4AAAADAAAAUgAAAAAAAABgAAAAAAAAAGgAAAAAAAAAVAAAAAMAAABiAAAAAAAAAG4AAAADAAAAOgAAAAAAAABBAAAAAwAAAEsAAAADAAAAPgAAAAMAAABMAAAAAAAAAFYAAAADAAAAQAAAAAMAAABSAAAAAAAAAGAAAAAAAAAAVQAAAAAAAABXAAAAAAAAAFMAAAADAAAAZQAAAAAAAABmAAAAAwAAAGQAAAADAAAAawAAAAMAAABwAAAAAwAAAHIAAAADAAAAQgAAAAAAAABDAAAAAwAAAEYAAAADAAAAUQAAAAAAAABVAAAAAAAAAFcAAAAAAAAAXgAAAAMAAABlAAAAAAAAAGYAAAADAAAAMQAAAAAAAAAwAAAAAwAAADIAAAADAAAAPQAAAAMAAABCAAAAAAAAAEMAAAADAAAASwAAAAMAAABRAAAAAAAAAFUAAAAAAAAAXwAAAAAAAABcAAAAAAAAAFMAAAAAAAAATwAAAAAAAABOAAAAAAAAAEoAAAADAAAAPwAAAAEAAAA7AAAAAwAAADkAAAADAAAAbQAAAAAAAABsAAAAAAAAAGQAAAAFAAAAXQAAAAEAAABfAAAAAAAAAFwAAAAAAAAATQAAAAEAAABPAAAAAAAAAE4AAAAAAAAAdQAAAAQAAAB2AAAABQAAAHIAAAAFAAAAagAAAAEAAABtAAAAAAAAAGwAAAAAAAAAWgAAAAEAAABdAAAAAQAAAF8AAAAAAAAAWgAAAAAAAABNAAAAAAAAAD8AAAAAAAAAUAAAAAAAAABEAAAAAAAAADgAAAADAAAASAAAAAEAAAA8AAAAAwAAAC4AAAADAAAAagAAAAAAAABdAAAAAAAAAE8AAAAFAAAAYwAAAAEAAABaAAAAAAAAAE0AAAAAAAAAWAAAAAEAAABQAAAAAAAAAEQAAAAAAAAAdQAAAAMAAABtAAAABQAAAF8AAAAFAAAAcQAAAAEAAABqAAAAAAAAAF0AAAAAAAAAaQAAAAEAAABjAAAAAQAAAFoAAAAAAAAAaQAAAAAAAABYAAAAAAAAAEgAAAAAAAAAZwAAAAAAAABbAAAAAAAAAEkAAAADAAAAYQAAAAEAAABZAAAAAwAAAEcAAAADAAAAcQAAAAAAAABjAAAAAAAAAFAAAAAFAAAAdAAAAAEAAABpAAAAAAAAAFgAAAAAAAAAbwAAAAEAAABnAAAAAAAAAFsAAAAAAAAAdQAAAAIAAABqAAAABQAAAFoAAAAFAAAAeQAAAAEAAABxAAAAAAAAAGMAAAAAAAAAdwAAAAEAAAB0AAAAAQAAAGkAAAAAAAAAdwAAAAAAAABvAAAAAAAAAGEAAAAAAAAAcwAAAAAAAABuAAAAAAAAAGIAAAADAAAAawAAAAEAAABoAAAAAwAAAGAAAAADAAAAeQAAAAAAAAB0AAAAAAAAAGcAAAAFAAAAeAAAAAEAAAB3AAAAAAAAAG8AAAAAAAAAcAAAAAEAAABzAAAAAAAAAG4AAAAAAAAAdQAAAAEAAABxAAAABQAAAGkAAAAFAAAAdgAAAAEAAAB5AAAAAAAAAHQAAAAAAAAAcgAAAAEAAAB4AAAAAQAAAHcAAAAAAAAAcgAAAAAAAABwAAAAAAAAAGsAAAAAAAAAZAAAAAAAAABmAAAAAAAAAGUAAAADAAAAUwAAAAEAAABXAAAAAwAAAFUAAAADAAAAdgAAAAAAAAB4AAAAAAAAAHMAAAAFAAAAbAAAAAEAAAByAAAAAAAAAHAAAAAAAAAAXAAAAAEAAABkAAAAAAAAAGYAAAAAAAAAdQAAAAAAAAB5AAAABQAAAHcAAAAFAAAAbQAAAAEAAAB2AAAAAAAAAHgAAAAAAAAAXwAAAAEAAABsAAAAAQAAAHIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAGAAAAAgAAAAUAAAABAAAABAAAAAAAAAAAAAAABQAAAAMAAAABAAAABgAAAAQAAAACAAAAAAAAAH6iBfbytuk/Gq6akm/58z/Xrm0Liez0P5doSdOpSwRAWs602ULg8D/dT7Rcbo/1v1N1RQHFNOM/g9Snx7HW3L8HWsP8Q3jfP6VwOLosutk/9rjk1YQcxj+gnmKMsNn6P/HDeuPFY+M/YHwDjqKhB0Ci19/fCVrbP4UxKkDWOP6/pvljWa09tL9wi7wrQXjnv/Z6yLImkM2/3yTlOzY14D+m+WNZrT20PzwKVQnrQwNA9nrIsiaQzT/g40rFrRQFwPa45NWEHMa/kbslHEZq97/xw3rjxWPjv4cLC2SMBci/otff3wla27+rKF5oIAv0P1N1RQHFNOO/iDJPGyWHBUAHWsP8Q3jfvwQf/by16gXAfqIF9vK26b8XrO0Vh0r+v9eubQuJ7PS/BxLrA0ZZ479azrTZQuDwv1MK1EuItPw/yscgV9Z6FkAwHBR2WjQMQJNRzXsQ5vY/GlUHVJYKF0DONuFv2lMNQNCGZ28QJfk/0WUwoIL36D8ggDOMQuATQNqMOeAy/wZAWFYOYM+M2z/LWC4uH3oSQDE+LyTsMgRAkJzhRGWFGEDd4soovCQQQKqk0DJMEP8/rGmNdwOLBUAW2X/9xCbjP4hu3dcqJhNAzuYItRvdB0CgzW3zJW/sPxotm/Y2TxRAQAk9XmdDDEC1Kx9MKgT3P1M+NctcghZAFVqcLlb0C0Bgzd3sB2b2P77mZDPUWhZAFROHJpUGCEDAfma5CxXtPz1DWq/zYxRAmhYY5824F0DOuQKWSbAOQNCMqrvu3fs/L6DR22K2wT9nAAxPBU8RQGiN6mW43AFAZhu25b633D8c1YgmzowSQNM25BRKWARArGS08/lNxD+LFssHwmMRQLC5aNcxBgJABL9HT0WRF0CjCmJmOGEOQHsuaVzMP/s/TWJCaGGwBUCeu1PAPLzjP9nqN9DZOBNAKE4JcydbCkCGtbd1qjPzP8dgm9U8jhVAtPeKTkVwDkCeCLss5l37P401XMPLmBdAFd29VMVQDUBg0yA55h75Pz6odcYLCRdApBM4rBrkAkDyAVWgQxbRP4XDMnK20hFAymLlF7EmzD8GUgo9XBHlP3lbK7T9COc/k+OhPthhy7+YGEpnrOvCPzBFhLs15u4/epbqB6H4uz9IuuLF5svev6lzLKY31es/CaQ0envF5z8ZY0xlUADXv7zaz7HYEuI/CfbK1sn16T8uAQfWwxLWPzKn/YuFN94/5KdbC1AFu793fyCSnlfvPzK2y4doAMY/NRg5t1/X6b/shq4QJaHDP5yNIAKPOeI/vpn7BSE30r/X4YQrO6nrv78Ziv/Thto/DqJ1Y6+y5z9l51NaxFrlv8QlA65HOLS/86dxiEc96z+Hj0+LFjneP6LzBZ8LTc2/DaJ1Y6+y579l51NaxFrlP8QlA65HOLQ/8qdxiEc967+Jj0+LFjnev6LzBZ8LTc0/1qdbC1AFuz93fyCSnlfvvzK2y4doAMa/NRg5t1/X6T/vhq4QJaHDv5yNIAKPOeK/wJn7BSE30j/W4YQrO6nrP78Ziv/Thtq/CaQ0envF578XY0xlUADXP7zaz7HYEuK/CvbK1sn16b8rAQfWwxLWvzKn/YuFN96/zWLlF7EmzL8GUgo9XBHlv3lbK7T9COe/kOOhPthhyz+cGEpnrOvCvzBFhLs15u6/c5bqB6H4u79IuuLF5sveP6lzLKY31eu/AQAAAP////8HAAAA/////zEAAAD/////VwEAAP////9hCQAA/////6dBAAD/////kcsBAP/////3kAwA/////8H2VwAAAAAAAAAAAAAAAAACAAAA/////w4AAAD/////YgAAAP////+uAgAA/////8ISAAD/////ToMAAP////8ilwMA/////+4hGQD/////gu2vAAAAAAAAAAAAAAAAAAAAAAACAAAA//////////8BAAAAAwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////////////////////AQAAAAAAAAACAAAA////////////////AwAAAP//////////////////////////////////////////////////////////AgAAAP//////////AQAAAAAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD/////////////////////AQAAAP///////////////wIAAAD///////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAD///////////////8CAAAAAQAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8BAAAAAgAAAP///////////////wAAAAD/////////////////////AwAAAP///////////////////////////////wIAAAD///////////////8BAAAA/////////////////////wAAAAD/////////////////////AwAAAP////////////////////////////////////////////////////8DAAAA/////////////////////wAAAAABAAAA//////////8CAAAA//////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAA////////////////AgAAAAAAAAABAAAA//////////////////////////////////////////////////////////////////////////8DAAAAAQAAAP//////////AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAACAAAAAAAAAAIAAAABAAAAAQAAAAIAAAACAAAAAAAAAAUAAAAFAAAAAAAAAAIAAAACAAAAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAAEAAAACAAAAAgAAAAIAAAAAAAAABQAAAAYAAAAAAAAAAgAAAAIAAAADAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAgAAAAAAAAACAAAAAQAAAAMAAAACAAAAAgAAAAAAAAAFAAAABwAAAAAAAAACAAAAAgAAAAMAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAACAAAAAAAAAAIAAAABAAAABAAAAAIAAAACAAAAAAAAAAUAAAAIAAAAAAAAAAIAAAACAAAAAwAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAIAAAAAAAAAAgAAAAEAAAAAAAAAAgAAAAIAAAAAAAAABQAAAAkAAAAAAAAAAgAAAAIAAAADAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAKAAAAAgAAAAIAAAAAAAAAAwAAAA4AAAACAAAAAAAAAAIAAAADAAAAAAAAAAAAAAACAAAAAgAAAAMAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAsAAAACAAAAAgAAAAAAAAADAAAACgAAAAIAAAAAAAAAAgAAAAMAAAABAAAAAAAAAAIAAAACAAAAAwAAAAcAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAIAAAACAAAAAAAAAAMAAAALAAAAAgAAAAAAAAACAAAAAwAAAAIAAAAAAAAAAgAAAAIAAAADAAAACAAAAAAAAAAAAAAAAAAAAAAAAAANAAAAAgAAAAIAAAAAAAAAAwAAAAwAAAACAAAAAAAAAAIAAAADAAAAAwAAAAAAAAACAAAAAgAAAAMAAAAJAAAAAAAAAAAAAAAAAAAAAAAAAA4AAAACAAAAAgAAAAAAAAADAAAADQAAAAIAAAAAAAAAAgAAAAMAAAAEAAAAAAAAAAIAAAACAAAAAwAAAAoAAAAAAAAAAAAAAAAAAAAAAAAABQAAAAIAAAACAAAAAAAAAAMAAAAGAAAAAgAAAAAAAAACAAAAAwAAAA8AAAAAAAAAAgAAAAIAAAADAAAACwAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAAgAAAAIAAAAAAAAAAwAAAAcAAAACAAAAAAAAAAIAAAADAAAAEAAAAAAAAAACAAAAAgAAAAMAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAACAAAAAgAAAAAAAAADAAAACAAAAAIAAAAAAAAAAgAAAAMAAAARAAAAAAAAAAIAAAACAAAAAwAAAA0AAAAAAAAAAAAAAAAAAAAAAAAACAAAAAIAAAACAAAAAAAAAAMAAAAJAAAAAgAAAAAAAAACAAAAAwAAABIAAAAAAAAAAgAAAAIAAAADAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAJAAAAAgAAAAIAAAAAAAAAAwAAAAUAAAACAAAAAAAAAAIAAAADAAAAEwAAAAAAAAACAAAAAgAAAAMAAAAPAAAAAAAAAAAAAAAAAAAAAAAAABAAAAACAAAAAAAAAAIAAAABAAAAEwAAAAIAAAACAAAAAAAAAAUAAAAKAAAAAAAAAAIAAAACAAAAAwAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEQAAAAIAAAAAAAAAAgAAAAEAAAAPAAAAAgAAAAIAAAAAAAAABQAAAAsAAAAAAAAAAgAAAAIAAAADAAAAEQAAAAAAAAAAAAAAAAAAAAAAAAASAAAAAgAAAAAAAAACAAAAAQAAABAAAAACAAAAAgAAAAAAAAAFAAAADAAAAAAAAAACAAAAAgAAAAMAAAASAAAAAAAAAAAAAAAAAAAAAAAAABMAAAACAAAAAAAAAAIAAAABAAAAEQAAAAIAAAACAAAAAAAAAAUAAAANAAAAAAAAAAIAAAACAAAAAwAAABMAAAAAAAAAAAAAAAAAAAAAAAAADwAAAAIAAAAAAAAAAgAAAAEAAAASAAAAAgAAAAIAAAAAAAAABQAAAA4AAAAAAAAAAgAAAAIAAAADAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAAAAAAAAAAAAAIAAAABAAAAAAAAAAEAAAACAAAAAQAAAAAAAAACAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAAAAAACAAAAAQAAAAAAAAABAAAAAgAAAAAAAAAAAAAAAgAAAAEAAAAAAAAAAQAAAAIAAAABAAAAAAAAAAIAAAACAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAEAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAFAAAABAAAAAAAAAABAAAABQAAAAQAAAAAAAAABQAAAAUAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAEAAAAAAQAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAABAAAAAAAAAAAAAQAAAAAAAAAAAAA6B6FaUp9QQTPXMuL4myJBraiDfBwx9UBYJseitzTIQOL5if9jqZtAnXX+Z+ycb0C3pucbhRBCQG8wJBYqpRRAlWbDCzCY5z/eFWBUEve6P/+qo4Q50Y4/D9YM3iCcYT8fcA2QJSA0P4ADxu0qAAc/BNcGolVJ2j5d9FACqwquPh9z7MthtI9CSUSYJke/YUJQ/64OyjU0Qpi0+HCmFQdCm3GfIVdh2kHsJ11kAyauQYC3UDFJOoFBSJsFV1OwU0FK5fcxX4AmQWhy/zZIt/lACqaCPsBjzUDbdUNIScugQMYQlVJ4MXNANiuq8GTvRUDxTXnulxEZQFZ8QX5kpuw/qmG/JwYFlEAluh3Q6DB+QKn4vyNq0GZAKOXekas+UUB8xabXXhI6QG63C2pLtSNAdDBtyNfLDUDyOcu67ID2P0rCMvRXAeE/Ki2TSVyzyT9Dk+8Sz2uzP5J+w5ARWp0/NQAoOiMuhj9YnP+RyMJwPxgW7TvQVFk/KgsLYF0kQz9g5dAC6IwzQcgHPVvDex1B1XjppodHBkHJq3OMM9fwQNvcmJ7wddlAInGPpQs/w0BRobq5EBmtQJZ2ai7n+ZVAtv2G5E+bgECG+gIfKBlpQK5f8jdI91JAL39sL/WpPEB8rGxhDqklQK6yUf43XhBAxL9y/tK8+D86XyZpgrHiPwAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAP////8AAAAAAAAAAAAAAAABAAAAAAAAAAAAAAD/////AAAAAAAAAAABAAAAAQAAAAAAAAAAAAAA/////wAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAP////8FAAAABQAAAAAAAAAAAAAAAAAAAAAAAAD/////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////////////////////////////////////wAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////////////////////////////////////8AAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////////////////////////////////////AAAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAAAAAAEAAAAAAAAABQAAAAEAAAABAAAAAAAAAAAAAAABAAAAAQAAAAAAAAABAAAAAQAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAQAAAAAAAQABAAABAQAAAAAAAQAAAAEAAAABAAEAAAAAAAAAAAAAAAAAAAAAquJYWJZl+D9jaeZNtj/zPwwdI9KqaeO/qGefXwdHdz+q4lhYlmX4P+OrlPMN3PI/DB0j0qpp47+7SQLV4VIEQKriWFiWZfg/r2kma3tz8T82eQmLqNIGwMRIWXMqSvo/fcCszPux9j+jara6ozTwP6hnn18HR3c/MSoKLequ8r+SabgA2nj0P7jBLbDOHO8/1Ym/ICfH4T+6lxjvlFXHv73m373LRPU/0vXyDVxo7T+ToKRHJXMAQF/33578aPE/pAyy64tD9T8+U/hCvyruPwxv8Y7YYwLAuXYr8NAiCEB4+LDK0Sn0P1Qeuy4j+eo/OMx50n7K7L+TrGB/nyf8v5ehC2fbYPM/aXMKexiT6z8mFRIMjg/zP7yUVwGGBNw/E6opHERf8z/z0wR2g9DqPw4pBpcOhvu/NbA29uWAA8DMaTExyXzyP02biiQ+Ruk/S8jz2/FKBEB1pzZnpbb9P7pQU4wLfPI//7ZcQXeG6D9CqEQvAYoIwDB2VB6sSgRAVyv8H5We8T+EHWF8XNPmPzB2wT8Nrrg/SEi+cX+w4L8of+GtdSDxP1sjk5AdouU/6ZjOVru13r8K0obqI6bxvwVbdNXyhfA/w5GG024n5z+rwmtMzP8BwLw9pSX49QXABe/2uQxP8D+b6wCzCvXkP7uGT87fK+Q/pz/JWw4coj+qoBf2J0nwP/yE3PUo0+I/vFJeHcaC+D96luSIqvntP/bf8sHUYu8/gZNN41mL4z9bhOqVOF4FwO6lmAh1hQhAbCVxbdhk7z+1C8NdDcfiPwG36x/0OQBAx0WJ76c2+D9nlSHXANfuP2HlfZ3gqOE/EwnVlVPg9r96+oHzEH//v5bXzdT1Auw/DM3GwLsA4D9p/8uoKcr+v+U9x5DQVAPAehjSdghb7D9sc1IetODgP8MVwwB1pu6/azPk6OGe978W8t/TUc3rP+0QMvYfP+A/RsG/QpSE8D+l3uwScxzgPwQaifgujuw/k1Vti1I43z8MAwLnSh0GQH5nYnwwZgJAiGUzWC5s6j8WyyI/BbLgPw4iUapGeQJAB3W+imnp/j9BLWR4ssrpP2t+gG5Pstk/cpBsfm6DCMCOpU9dOZsFQEv8nFypHeo/ehJ6i+6S2D9jqlGEmarLv7STC5TRiOa/bC+x8WZD6D9H3yUkWpDZP8gZvmCMuQLAreY19/eRBsCoPOc8UzzpP6KI/QV+y9g/t/MoboyWzT+Hv5q3Zu3Mvy2xROCT4uY/9gQitMMg1T9abAqhWMDkv1oLTavoUfG/PMUJP9CD5j+fHRX3t6fSPz7W2gk6bvs/WRnuHwqN9D8YFturGCTmP1EZczv0b9I/5t4exabB5D/1ESLh5fTEP9X2z6SYweQ/6lv3I2zT0D9zkRGNUNMAQKoSvc4EIfs/Xggt8wQI5T+mJHHg/w/SP4lhT/9t8vQ/DrZ/DbwH7D+XlhbYZrjkP34LIpFt6c4/lwfp8fLX9L+j96CTTf76v3WdNhEv9uM/d8c3o4lV0D/vFdCHVcsFwAHeDq0F1QhApbYqcZiN5D9KoilqByXLPwX0/diA0vq/0fo0GxnxAMBbaTkvlCzjP/RrFrWXrMs/UYTrky7jA0DB9f4FiZYAQEGAk/3QzeE/r/TeqE8t0D/OqjlsnPbvvz8RKU8JOfW/smSEbK/O4T8MzuyPm3DDP/rFtctq9gZAfb1EVEaSA0Dts5dVInnhP18SFMc79MM/7y34cw6LAMDFrRJsZO0DwC2KLvLSYuA/hx5wcUHewz+49SnK/4ruPyeS0PX9a+E/ZxaaLvvZ3z8WPu5T2QS8Pygo4RIvMqa/BJ0Kqsd0279cKW4ay8jdP3b05bmZ364/10/qtdxk2r+Bcz6CDMvpv54qOw+Amdw/qLV71pW7sT/YKc80nIPUP8OfIaBJ77G/LyTuD1un2z+diYu8efWzP1wU7ACkfwjAZroyPL1yBkAmv3lKJJbbPysKSE4W+p0/dIgqY79TA8ATLTOQ3tsGwJ2zweD/Xdg/XO/jXeFUaL8VW2qLFKfov1cA9Aa6XfK/tIa7YGgI2T+f3hu/sxqPv2nXdPpf3Pc/jkw8Jbda8j+tT/z8tGPVP1yBHpJd35k/KYvYOy1s8j/yz+kCQjPrP9+agH7x59g/PZfJ9aBhpr/rDKzvYBb+PwtkiaGCt/c/vb1mVr+f1T/JIHwHc8Govw7aeF6+9vG/Xv7kD6fp979isYioQYHVP7AIQZuSFrG/3z1AdUTnAUDN3XY9O7f9P0AdQ9ljYNQ/dJANJPTOrb8kLECUiiPlP4yF7UgmStA/9xGmXxCG1T9qZzix4W2zv2SGJRJVrPe/Fh9a2M/B/b8IexzFCoPSP9y1QFD2bLe/Q86cWLJe/b+mOOfYm78BwOTjkPAGE9E/8aPCUKu/ub9pPZyLCiUGwBA7Mev/BQlALOmrlRi+0j+AMJ/dKULBv7iLtL6a6QRAEMDV/yajAUDa62dE3crJP1P70RgBUbq/38hVnR6esT/s1tG10Z/Ov/zLwalHPss/dTS9NKTXx78nMcRzCIEHQAabxDsAmQRA0tyLK3gSyT+Aui7nOhDGv5Gs58z3WgHATN3forJuBMCAui7nOhDGP9Lciyt4Esm/WAJyHQ4c7z8UP5HFIs3iP3U0vTSk18c//MvBqUc+y7+cvv8HLg/Kvy1I/mHsI+K/U/vRGAFRuj/a62dE3crJv8p+WV8KlQjAuQ/nOP43B0CAMJ/dKULBPyzpq5UYvtK/ZoU+VoLh4L9etLlRUfvtv/GjwlCrv7k/5OOQ8AYT0b9DfT9FhufXPwUX8hJp+4u/3LVAUPZstz8IexzFCoPSv9+L609E5fQ/q9Fz7X2J7T9qZzix4W2zP/cRpl8QhtW/vtNilqGX+j8MOy7QJoL0P3SQDST0zq0/QB1D2WNg1L8IIjSvGNkDwGB8Jou2GAfAsAhBm5IWsT9isYioQYHVvyS9D3zb6uy/gnwRa7uM9L/JIHwHc8GoP729Zla/n9W/CsAHJZwmAEDEW6OYT1r6Pz2XyfWgYaY/35qAfvHn2L83Tdy4lS30vxf2/gZ0jPq/XIEekl3fmb+tT/z8tGPVvybPr2zJ1/+/K7mJ0ypVAsCf3hu/sxqPPwCGu2BoCNm/5oITrpZn+r+UDUyDP+n/v1zv413hVGg/nbPB4P9d2L9MlmkxNvgCQMtZlKE85v8/KwpIThb6nb8mv3lKJJbbv8+SZsTvOOc/pQCIIOYw0j+diYu8efWzvy8k7g9bp9u/kxYDa+pKtD9XlYvA8HnVv6i1e9aVu7G/nio7D4CZ3L/WR6rNh5EGwCkgQweBkghAdvTluZnfrr9cKW4ay8jdvxbjhr1f1QVAR5C0MzivAkAWPu5T2QS8v2cWmi772d+/cKj4lzLJCEBx2QJfYrMFQIcecHFB3sO/LYou8tJi4L+jr7lhO38BwIcI0Nb7xgTAXxIUxzv0w7/ts5dVInnhv0T+l8DZLfE/MP3FoFvS5D8MzuyPm3DDv7JkhGyvzuG/tzhzRIRc0b9Ovv3/0z7mv6/03qhPLdC/m4CT/dDN4b9dwjU5VCQBQBBJX1ntCv0/9GsWtZesy79baTkvlCzjv1mjYgEz++S/oW6KnOQW8b9KoilqByXLv6W2KnGYjeS/SmaKz3Vx9z+BZB5yxGHwP3fHN6OJVdC/dZ02ES/2478PuaBjLrXaP4/JU81pPaO/fgsikW3pzr+XlhbYZrjkv4tSn7YDbP0/f2LnFKlF9z+mJHHg/w/Sv14ILfMECOW/mfg4qYhR/b+OP+RQDCACwOpb9yNs09C/1fbPpJjB5L9pN2WOVZ3wv3hHy9nxIve/URlzO/Rv0r8YFturGCTmv1d1/KKR8QPA8gsy9qzSB8CfHRX3t6fSvzzFCT/Qg+a/EYStnrzV9r/2QJqI7Lb9v/YEIrTDINW/LbFE4JPi5r/7kQEs5fEDQHunnf4GeQBAooj9BX7L2L+oPOc8Uzzpv+ydYY2SSAfAL4HK6CRTB0BH3yUkWpDZv2wvsfFmQ+i/Ik0Yzruh6T8fM3LoGoDUP3oSeovukti/S/ycXKkd6r9rEv+7UWcHQCRIQe/GfwNAa36Abk+y2b9BLWR4ssrpv9KT87qa0bM/FTyktw823L8WyyI/BbLgv4hlM1gubOq/DizMp9Ki6r8b5ckdjVrzv5NVbYtSON+/BBqJ+C6O7L/dUBFqgyXYv00Wh18r7+q/7RAy9h8/4L8W8t/TUc3rv4RM5DKx3wDAfvWIj94aBcBsc1IetODgv3oY0nYIW+y/oGcTFF54AUDkJqS/FKX6PwzNxsC7AOC/ltfN1PUC7L+5Wrz/zHnzP6688w2rNOc/YeV9neCo4b9nlSHXANfuvw9RsxKjY/s/1V8GteXE8j+1C8NdDcfiv2wlcW3YZO+/IOywaA7Q8b9bFP+4Tg36v4GTTeNZi+O/9t/ywdRi77+tRc3yFR7eP2bkcHXJkLO//ITc9SjT4r+qoBf2J0nwv2YHKoswwfm/iQcLspCjAcCb6wCzCvXkvwXv9rkMT/C/YkuwYAMXBMApCNUai9kIwMORhtNuJ+e/BVt01fKF8L+ZqWEfvIjsP6h693QZYNk/WyOTkB2i5b8of+GtdSDxvwpaaulDSwVADMQAX+lOAECEHWF8XNPmv1cr/B+VnvG/XyFG6opcCMD/mtR32/UEQP+2XEF3hui/ulBTjAt88r/imfCfRP+yP9zbvtc8XeO/TZuKJD5G6b/MaTExyXzyvxiTQeElXOO/rbJRQVGN9L/z0wR2g9DqvxOqKRxEX/O/FDGCEei99j9x8zV4VYTmP2lzCnsYk+u/l6ELZ9tg878pRXacaDT/v3k6GZRqoQXAVB67LiP56r94+LDK0Sn0vwO6pZ9b7wFAvK0nKVcc9j8+U/hCvyruv6QMsuuLQ/W/FPhKFYv46j8MyxaDTOW/v9L18g1caO2/vebfvctE9b/7GD8ZrF3xv3gx1AR9bQDAuMEtsM4c77+SabgA2nj0v5xKFIwxsATArKNSBaKsB0Cjara6ozTwv33ArMz7sfa/dF2U0FcWCcDxL357DJX/P69pJmt7c/G/quJYWJZl+L/YntVJlnrSP4sRLzXM+fe/46uU8w3c8r+q4lhYlmX4v85lu5+QRwRAsI0H/WU8479jaeZNtj/zv6riWFiWZfi/sI0H/WU847/OZbufkEcEQHAoPUBrnss/9exKzDtFtT88wM8kax+gP9OqeKeAYog/MW0ItiZvcj+ph+smvt5bP2lCaV5dEUU/StaUmQDaLz+kK9y22BMYP0O3whZuMwI/IIbgZGWE6z7UkjYaEM3UPuezxwa9cr8+LybxRMnFpz6E1N8DbPiRPsYjySMvK3s+//////8fAAj//////zMQCP////9/MiAI/////28yMAj/////YzJACP///z9iMlAI////N2IyYAj///8zYjJwCP//vzNiMoAI//+rM2IykAj/f6szYjKgCP8PqzNiMrAI/wOrM2IywAi/A6szYjLQCJ8DqzNiMuAImQOrM2Iy8Aj//////z8PCP//////Kx8I/////38pLwj/////Pyk/CP////85KU8I////PzgpXwj///8POClvCP///w44KX8I//8fDjgpjwj//w8OOCmfCP9/DQ44Ka8I/w8NDjgpvwj/DQ0OOCnPCP8MDQ44Kd8IxwwNDjgp7wjEDA0OOCn/CAcAAAAHAAAAAQAAAAIAAAAEAAAAAwAAAAAAAAAAAAAABwAAAAMAAAABAAAAAgAAAAUAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAACAAAAAQAAAAMAAAAOAAAABgAAAAsAAAACAAAABwAAAAEAAAAYAAAABQAAAAoAAAABAAAABgAAAAAAAAAmAAAABwAAAAwAAAADAAAACAAAAAIAAAAxAAAACQAAAA4AAAAAAAAABQAAAAQAAAA6AAAACAAAAA0AAAAEAAAACQAAAAMAAAA/AAAACwAAAAYAAAAPAAAACgAAABAAAABIAAAADAAAAAcAAAAQAAAACwAAABEAAABTAAAACgAAAAUAAAATAAAADgAAAA8AAABhAAAADQAAAAgAAAARAAAADAAAABIAAABrAAAADgAAAAkAAAASAAAADQAAABMAAAB1AAAADwAAABMAAAARAAAAEgAAABAAAAAGAAAAAgAAAAMAAAAFAAAABAAAAAAAAAAAAAAAAAAAAAYAAAACAAAAAwAAAAEAAAAFAAAABAAAAAAAAAAAAAAABwAAAAUAAAADAAAABAAAAAEAAAAAAAAAAgAAAAAAAAACAAAAAwAAAAEAAAAFAAAABAAAAAYAAAAAAAAAAAAAABgtRFT7Ifk/GC1EVPsh+b8YLURU+yEJQBgtRFT7IQnAYWxnb3MuYwBoM05laWdoYm9yUm90YXRpb25zAGNvb3JkaWprLmMAX3VwQXA3Q2hlY2tlZABfdXBBcDdyQ2hlY2tlZABkaXJlY3RlZEVkZ2UuYwBkaXJlY3RlZEVkZ2VUb0JvdW5kYXJ5AGFkamFjZW50RmFjZURpclt0bXBGaWprLmZhY2VdW2ZpamsuZmFjZV0gPT0gS0kAZmFjZWlqay5jAF9mYWNlSWprUGVudFRvQ2VsbEJvdW5kYXJ5AGFkamFjZW50RmFjZURpcltjZW50ZXJJSksuZmFjZV1bZmFjZTJdID09IEtJAF9mYWNlSWprVG9DZWxsQm91bmRhcnkAaDNJbmRleC5jAGNvbXBhY3RDZWxscwBsYXRMbmdUb0NlbGwAY2VsbFRvQ2hpbGRQb3MAdmFsaWRhdGVDaGlsZFBvcwBsYXRMbmcuYwBjZWxsQXJlYVJhZHMyAHBvbHlnb24tPm5leHQgPT0gTlVMTABsaW5rZWRHZW8uYwBhZGROZXdMaW5rZWRQb2x5Z29uAG5leHQgIT0gTlVMTABsb29wICE9IE5VTEwAYWRkTmV3TGlua2VkTG9vcABwb2x5Z29uLT5maXJzdCA9PSBOVUxMAGFkZExpbmtlZExvb3AAY29vcmQgIT0gTlVMTABhZGRMaW5rZWRDb29yZABsb29wLT5maXJzdCA9PSBOVUxMAGlubmVyTG9vcHMgIT0gTlVMTABub3JtYWxpemVNdWx0aVBvbHlnb24AYmJveGVzICE9IE5VTEwAY2FuZGlkYXRlcyAhPSBOVUxMAGZpbmRQb2x5Z29uRm9ySG9sZQBjYW5kaWRhdGVCQm94ZXMgIT0gTlVMTAByZXZEaXIgIT0gSU5WQUxJRF9ESUdJVABsb2NhbGlqLmMAY2VsbFRvTG9jYWxJamsAYmFzZUNlbGwgIT0gb3JpZ2luQmFzZUNlbGwAIShvcmlnaW5PblBlbnQgJiYgaW5kZXhPblBlbnQpAGJhc2VDZWxsID09IG9yaWdpbkJhc2VDZWxsAGJhc2VDZWxsICE9IElOVkFMSURfQkFTRV9DRUxMAGxvY2FsSWprVG9DZWxsACFfaXNCYXNlQ2VsbFBlbnRhZ29uKGJhc2VDZWxsKQBiYXNlQ2VsbFJvdGF0aW9ucyA+PSAwAGdyaWRQYXRoQ2VsbHMAcG9seWZpbGwuYwBpdGVyU3RlcFBvbHlnb25Db21wYWN0ADAAdmVydGV4LmMAdmVydGV4Um90YXRpb25zAGNlbGxUb1ZlcnRleABncmFwaC0+YnVja2V0cyAhPSBOVUxMAHZlcnRleEdyYXBoLmMAaW5pdFZlcnRleEdyYXBoAG5vZGUgIT0gTlVMTABhZGRWZXJ0ZXhOb2Rl";var jt=28640;function v0(rA,pA,IA,xA){dt("Assertion failed: "+iA(rA)+", at: "+[pA?iA(pA):"unknown filename",IA,xA?iA(xA):"unknown function"])}function Yt(){return kA.length}function Kt(rA,pA,IA){LA.set(LA.subarray(pA,pA+IA),rA)}function N0(rA){return u.___errno_location&&(GA[u.___errno_location()>>2]=rA),rA}function er(rA){dt("OOM")}function k0(rA){try{var pA=new ArrayBuffer(rA);return pA.byteLength!=rA?void 0:(new Int8Array(pA).set(kA),f0(pA),sA(pA),1)}catch{}}function zt(rA){var pA=Yt(),IA=16777216,xA=2147483648-IA;if(rA>xA)return!1;for(var t=16777216,b=Math.max(pA,t);b>4,t=(De&15)<<4|He>>2,b=(He&3)<<6|$A,IA=IA+String.fromCharCode(xA),He!==64&&(IA=IA+String.fromCharCode(t)),$A!==64&&(IA=IA+String.fromCharCode(b));while(ye13780509?(A=vn(15,A)|0,A|0):(r=((e|0)<0)<<31>>31,o=ft(e|0,r|0,3,0)|0,n=S()|0,r=KA(e|0,r|0,1,0)|0,r=ft(o|0,n|0,r|0,S()|0)|0,r=KA(r|0,S()|0,1,0)|0,e=S()|0,t[A>>2]=r,t[A+4>>2]=e,A=0,A|0)}function v(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,D(e,A,r,n,0)|0}function D(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0,a=0,f=0;if(a=k,k=k+16|0,s=a,!(F(e,A,r,n,o)|0))return n=0,k=a,n|0;do if((r|0)>=0){if((r|0)>13780509){if(i=vn(15,s)|0,i|0)break;l=s,s=t[l>>2]|0,l=t[l+4>>2]|0}else i=((r|0)<0)<<31>>31,f=ft(r|0,i|0,3,0)|0,l=S()|0,i=KA(r|0,i|0,1,0)|0,i=ft(f|0,l|0,i|0,S()|0)|0,i=KA(i|0,S()|0,1,0)|0,l=S()|0,t[s>>2]=i,t[s+4>>2]=l,s=i;if(Y0(n|0,0,s<<3|0)|0,o|0){Y0(o|0,0,s<<2|0)|0,i=X(e,A,r,n,o,s,l,0)|0;break}i=Qt(s,4)|0,i?(f=X(e,A,r,n,i,s,l,0)|0,qA(i),i=f):i=13}else i=2;while(!1);return f=i,k=a,f|0}function F(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0;if(G=k,k=k+16|0,I=G,L=G+8|0,j=I,t[j>>2]=e,t[j+4>>2]=A,(r|0)<0)return L=2,k=G,L|0;if(i=n,t[i>>2]=e,t[i+4>>2]=A,i=(o|0)!=0,i&&(t[o>>2]=0),Oe(e,A)|0)return L=9,k=G,L|0;t[L>>2]=0;A:do if((r|0)>=1)if(i)for(m=1,f=0,M=0,j=1,i=e;;){if(!(f|M)){if(i=Y(i,A,4,L,I)|0,i|0)break A;if(A=I,i=t[A>>2]|0,A=t[A+4>>2]|0,Oe(i,A)|0){i=9;break A}}if(i=Y(i,A,t[26800+(M<<2)>>2]|0,L,I)|0,i|0)break A;if(A=I,i=t[A>>2]|0,A=t[A+4>>2]|0,e=n+(m<<3)|0,t[e>>2]=i,t[e+4>>2]=A,t[o+(m<<2)>>2]=j,e=f+1|0,s=(e|0)==(j|0),l=M+1|0,a=(l|0)==6,Oe(i,A)|0){i=9;break A}if(j=j+(a&s&1)|0,(j|0)>(r|0)){i=0;break}else m=m+1|0,f=s?0:e,M=s?a?0:l:M}else for(m=1,f=0,M=0,j=1,i=e;;){if(!(f|M)){if(i=Y(i,A,4,L,I)|0,i|0)break A;if(A=I,i=t[A>>2]|0,A=t[A+4>>2]|0,Oe(i,A)|0){i=9;break A}}if(i=Y(i,A,t[26800+(M<<2)>>2]|0,L,I)|0,i|0)break A;if(A=I,i=t[A>>2]|0,A=t[A+4>>2]|0,e=n+(m<<3)|0,t[e>>2]=i,t[e+4>>2]=A,e=f+1|0,s=(e|0)==(j|0),l=M+1|0,a=(l|0)==6,Oe(i,A)|0){i=9;break A}if(j=j+(a&s&1)|0,(j|0)>(r|0)){i=0;break}else m=m+1|0,f=s?0:e,M=s?a?0:l:M}else i=0;while(!1);return L=i,k=G,L|0}function X(e,A,r,n,o,i,s,l){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0,i=i|0,s=s|0,l=l|0;var a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0;if(G=k,k=k+16|0,I=G+8|0,L=G,a=jr(e|0,A|0,i|0,s|0)|0,m=S()|0,M=n+(a<<3)|0,W=M,nA=t[W>>2]|0,W=t[W+4>>2]|0,f=(nA|0)==(e|0)&(W|0)==(A|0),!((nA|0)==0&(W|0)==0|f))do a=KA(a|0,m|0,1,0)|0,a=Rr(a|0,S()|0,i|0,s|0)|0,m=S()|0,M=n+(a<<3)|0,nA=M,W=t[nA>>2]|0,nA=t[nA+4>>2]|0,f=(W|0)==(e|0)&(nA|0)==(A|0);while(!((W|0)==0&(nA|0)==0|f));if(a=o+(a<<2)|0,f&&(t[a>>2]|0)<=(l|0)||(nA=M,t[nA>>2]=e,t[nA+4>>2]=A,t[a>>2]=l,(l|0)>=(r|0)))return nA=0,k=G,nA|0;switch(f=l+1|0,t[I>>2]=0,a=Y(e,A,2,I,L)|0,a|0){case 9:{j=9;break}case 0:{a=L,a=X(t[a>>2]|0,t[a+4>>2]|0,r,n,o,i,s,f)|0,a||(j=9);break}}A:do if((j|0)==9){switch(t[I>>2]=0,a=Y(e,A,3,I,L)|0,a|0){case 9:break;case 0:{if(a=L,a=X(t[a>>2]|0,t[a+4>>2]|0,r,n,o,i,s,f)|0,a|0)break A;break}default:break A}switch(t[I>>2]=0,a=Y(e,A,1,I,L)|0,a|0){case 9:break;case 0:{if(a=L,a=X(t[a>>2]|0,t[a+4>>2]|0,r,n,o,i,s,f)|0,a|0)break A;break}default:break A}switch(t[I>>2]=0,a=Y(e,A,5,I,L)|0,a|0){case 9:break;case 0:{if(a=L,a=X(t[a>>2]|0,t[a+4>>2]|0,r,n,o,i,s,f)|0,a|0)break A;break}default:break A}switch(t[I>>2]=0,a=Y(e,A,4,I,L)|0,a|0){case 9:break;case 0:{if(a=L,a=X(t[a>>2]|0,t[a+4>>2]|0,r,n,o,i,s,f)|0,a|0)break A;break}default:break A}switch(t[I>>2]=0,a=Y(e,A,6,I,L)|0,a|0){case 9:break;case 0:{if(a=L,a=X(t[a>>2]|0,t[a+4>>2]|0,r,n,o,i,s,f)|0,a|0)break A;break}default:break A}return nA=0,k=G,nA|0}while(!1);return nA=a,k=G,nA|0}function Y(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0;if(r>>>0>6)return o=1,o|0;if(M=(t[n>>2]|0)%6|0,t[n>>2]=M,(M|0)>0){i=0;do r=Gt(r)|0,i=i+1|0;while((i|0)<(t[n>>2]|0))}if(M=wA(e|0,A|0,45)|0,S()|0,m=M&127,m>>>0>121)return o=5,o|0;a=Pt(e,A)|0,i=wA(e|0,A|0,52)|0,S()|0,i=i&15;A:do if(!i)f=8;else{for(;;){if(s=(15-i|0)*3|0,l=wA(e|0,A|0,s|0)|0,S()|0,l=l&7,(l|0)==7){A=5;break}if(L=(Jt(i)|0)==0,i=i+-1|0,j=EA(7,0,s|0)|0,A=A&~(S()|0),I=EA(t[(L?432:16)+(l*28|0)+(r<<2)>>2]|0,0,s|0)|0,s=S()|0,r=t[(L?640:224)+(l*28|0)+(r<<2)>>2]|0,e=I|e&~j,A=s|A,!r){r=0;break A}if(!i){f=8;break A}}return A|0}while(!1);(f|0)==8&&(L=t[848+(m*28|0)+(r<<2)>>2]|0,I=EA(L|0,0,45)|0,e=I|e,A=S()|0|A&-1040385,r=t[4272+(m*28|0)+(r<<2)>>2]|0,(L&127|0)==127&&(L=EA(t[848+(m*28|0)+20>>2]|0,0,45)|0,A=S()|0|A&-1040385,r=t[4272+(m*28|0)+20>>2]|0,e=lr(L|e,A)|0,A=S()|0,t[n>>2]=(t[n>>2]|0)+1)),l=wA(e|0,A|0,45)|0,S()|0,l=l&127;A:do if(Re(l)|0){e:do if((Pt(e,A)|0)==1){if((m|0)!=(l|0))if(S0(l,t[7696+(m*28|0)>>2]|0)|0){e=Zn(e,A)|0,s=1,A=S()|0;break}else OA(27795,26864,533,26872);switch(a|0){case 3:{e=lr(e,A)|0,A=S()|0,t[n>>2]=(t[n>>2]|0)+1,s=0;break e}case 5:{e=Zn(e,A)|0,A=S()|0,t[n>>2]=(t[n>>2]|0)+5,s=0;break e}case 0:return L=9,L|0;default:return L=1,L|0}}else s=0;while(!1);if((r|0)>0){i=0;do e=Kn(e,A)|0,A=S()|0,i=i+1|0;while((i|0)!=(r|0))}if((m|0)!=(l|0)){if(!(Et(l)|0)){if((s|0)!=0|(Pt(e,A)|0)!=5)break;t[n>>2]=(t[n>>2]|0)+1;break}switch(M&127){case 8:case 118:break A}(Pt(e,A)|0)!=3&&(t[n>>2]=(t[n>>2]|0)+1)}}else if((r|0)>0){i=0;do e=lr(e,A)|0,A=S()|0,i=i+1|0;while((i|0)!=(r|0))}while(!1);return t[n>>2]=((t[n>>2]|0)+r|0)%6|0,L=o,t[L>>2]=e,t[L+4>>2]=A,L=0,L|0}function hA(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,RA(e,A,r,n)|0?(Y0(n|0,0,r*48|0)|0,n=XA(e,A,r,n)|0,n|0):(n=0,n|0)}function RA(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0;if(L=k,k=k+16|0,j=L,I=L+8|0,M=j,t[M>>2]=e,t[M+4>>2]=A,(r|0)<0)return I=2,k=L,I|0;if(!r)return I=n,t[I>>2]=e,t[I+4>>2]=A,I=0,k=L,I|0;t[I>>2]=0;A:do if(Oe(e,A)|0)e=9;else{o=0,M=e;do{if(e=Y(M,A,4,I,j)|0,e|0)break A;if(A=j,M=t[A>>2]|0,A=t[A+4>>2]|0,o=o+1|0,Oe(M,A)|0){e=9;break A}}while((o|0)<(r|0));m=n,t[m>>2]=M,t[m+4>>2]=A,m=r+-1|0,f=0,e=1;do{if(o=26800+(f<<2)|0,(f|0)==5)for(s=t[o>>2]|0,i=0,o=e;;){if(e=j,e=Y(t[e>>2]|0,t[e+4>>2]|0,s,I,j)|0,e|0)break A;if((i|0)!=(m|0))if(a=j,l=t[a>>2]|0,a=t[a+4>>2]|0,e=n+(o<<3)|0,t[e>>2]=l,t[e+4>>2]=a,!(Oe(l,a)|0))e=o+1|0;else{e=9;break A}else e=o;if(i=i+1|0,(i|0)>=(r|0))break;o=e}else for(s=j,a=t[o>>2]|0,l=0,o=e,i=t[s>>2]|0,s=t[s+4>>2]|0;;){if(e=Y(i,s,a,I,j)|0,e|0)break A;if(s=j,i=t[s>>2]|0,s=t[s+4>>2]|0,e=n+(o<<3)|0,t[e>>2]=i,t[e+4>>2]=s,e=o+1|0,Oe(i,s)|0){e=9;break A}if(l=l+1|0,(l|0)>=(r|0))break;o=e}f=f+1|0}while(f>>>0<6);e=j,e=(M|0)==(t[e>>2]|0)&&(A|0)==(t[e+4>>2]|0)?0:9}while(!1);return I=e,k=L,I|0}function XA(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0;if(M=k,k=k+16|0,s=M,!r)return t[n>>2]=e,t[n+4>>2]=A,n=0,k=M,n|0;do if((r|0)>=0){if((r|0)>13780509){if(o=vn(15,s)|0,o|0)break;i=s,o=t[i>>2]|0,i=t[i+4>>2]|0}else o=((r|0)<0)<<31>>31,m=ft(r|0,o|0,3,0)|0,i=S()|0,o=KA(r|0,o|0,1,0)|0,o=ft(m|0,i|0,o|0,S()|0)|0,o=KA(o|0,S()|0,1,0)|0,i=S()|0,m=s,t[m>>2]=o,t[m+4>>2]=i;if(f=Qt(o,8)|0,!f)o=13;else{if(m=Qt(o,4)|0,!m){qA(f),o=13;break}if(o=X(e,A,r,f,m,o,i,0)|0,o|0){qA(f),qA(m);break}if(A=t[s>>2]|0,s=t[s+4>>2]|0,(s|0)>0|(s|0)==0&A>>>0>0){o=0,l=0,a=0;do e=f+(l<<3)|0,i=t[e>>2]|0,e=t[e+4>>2]|0,!((i|0)==0&(e|0)==0)&&(t[m+(l<<2)>>2]|0)==(r|0)&&(j=n+(o<<3)|0,t[j>>2]=i,t[j+4>>2]=e,o=o+1|0),l=KA(l|0,a|0,1,0)|0,a=S()|0;while((a|0)<(s|0)|(a|0)==(s|0)&l>>>0>>0)}qA(f),qA(m),o=0}}else o=2;while(!1);return j=o,k=M,j|0}function Ae(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0;for(l=k,k=k+16|0,i=l,s=l+8|0,o=(Oe(e,A)|0)==0,o=o?1:2;;){if(t[s>>2]=0,f=(Y(e,A,o,s,i)|0)==0,a=i,f&((t[a>>2]|0)==(r|0)?(t[a+4>>2]|0)==(n|0):0)){e=4;break}if(o=o+1|0,o>>>0>=7){o=7,e=4;break}}return(e|0)==4?(k=l,o|0):0}function ce(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0;if(l=k,k=k+48|0,o=l+16|0,i=l+8|0,s=l,r=on(r)|0,r|0)return s=r,k=l,s|0;if(f=e,a=t[f+4>>2]|0,r=i,t[r>>2]=t[f>>2],t[r+4>>2]=a,ei(i,o),r=mA(o,A,s)|0,!r){if(A=t[i>>2]|0,i=t[e+8>>2]|0,(i|0)>0){o=t[e+12>>2]|0,r=0;do A=(t[o+(r<<3)>>2]|0)+A|0,r=r+1|0;while((r|0)<(i|0))}r=s,o=t[r>>2]|0,r=t[r+4>>2]|0,i=((A|0)<0)<<31>>31,(r|0)<(i|0)|(r|0)==(i|0)&o>>>0>>0?(r=s,t[r>>2]=A,t[r+4>>2]=i,r=i):A=o,a=KA(A|0,r|0,12,0)|0,f=S()|0,r=s,t[r>>2]=a,t[r+4>>2]=f,r=n,t[r>>2]=a,t[r+4>>2]=f,r=0}return f=r,k=l,f|0}function Ge(e,A,r,n,o,i,s){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0,i=i|0,s=s|0;var l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0,$=0,U=0,BA=0,zA=0,QA=0,fe=0,he=0,Ee=0,ne=0,HA=0,SA=0,ve=0,Ve=0,de=0,We=0,Tt=0,mi=0;if(Ve=k,k=k+64|0,ne=Ve+48|0,HA=Ve+32|0,SA=Ve+24|0,BA=Ve+8|0,zA=Ve,a=t[e>>2]|0,(a|0)<=0)return ve=0,k=Ve,ve|0;for(QA=e+4|0,fe=ne+8|0,he=HA+8|0,Ee=BA+8|0,l=0,$=0;;){f=t[QA>>2]|0,q=f+($<<4)|0,t[ne>>2]=t[q>>2],t[ne+4>>2]=t[q+4>>2],t[ne+8>>2]=t[q+8>>2],t[ne+12>>2]=t[q+12>>2],($|0)==(a+-1|0)?(t[HA>>2]=t[f>>2],t[HA+4>>2]=t[f+4>>2],t[HA+8>>2]=t[f+8>>2],t[HA+12>>2]=t[f+12>>2]):(q=f+($+1<<4)|0,t[HA>>2]=t[q>>2],t[HA+4>>2]=t[q+4>>2],t[HA+8>>2]=t[q+8>>2],t[HA+12>>2]=t[q+12>>2]),a=FA(ne,HA,n,SA)|0;A:do if(a)f=0,l=a;else if(a=SA,f=t[a>>2]|0,a=t[a+4>>2]|0,(a|0)>0|(a|0)==0&f>>>0>0){nA=0,q=0;e:for(;;){if(We=1/(+(f>>>0)+4294967296*+(a|0)),mi=+b[ne>>3],a=ct(f|0,a|0,nA|0,q|0)|0,Tt=+(a>>>0)+4294967296*+(S()|0),de=+(nA>>>0)+4294967296*+(q|0),b[BA>>3]=We*(mi*Tt)+We*(+b[HA>>3]*de),b[Ee>>3]=We*(+b[fe>>3]*Tt)+We*(+b[he>>3]*de),a=$n(BA,n,zA)|0,a|0){l=a;break}W=zA,G=t[W>>2]|0,W=t[W+4>>2]|0,j=jr(G|0,W|0,A|0,r|0)|0,m=S()|0,a=s+(j<<3)|0,M=a,f=t[M>>2]|0,M=t[M+4>>2]|0;t:do if((f|0)==0&(M|0)==0)U=a,ve=16;else for(I=0,L=0;;){if((I|0)>(r|0)|(I|0)==(r|0)&L>>>0>A>>>0){l=1;break e}if((f|0)==(G|0)&(M|0)==(W|0))break t;if(a=KA(j|0,m|0,1,0)|0,j=Rr(a|0,S()|0,A|0,r|0)|0,m=S()|0,L=KA(L|0,I|0,1,0)|0,I=S()|0,a=s+(j<<3)|0,M=a,f=t[M>>2]|0,M=t[M+4>>2]|0,(f|0)==0&(M|0)==0){U=a,ve=16;break}}while(!1);if((ve|0)==16&&(ve=0,!((G|0)==0&(W|0)==0))&&(L=U,t[L>>2]=G,t[L+4>>2]=W,L=i+(t[o>>2]<<3)|0,t[L>>2]=G,t[L+4>>2]=W,L=o,L=KA(t[L>>2]|0,t[L+4>>2]|0,1,0)|0,G=S()|0,W=o,t[W>>2]=L,t[W+4>>2]=G),nA=KA(nA|0,q|0,1,0)|0,q=S()|0,a=SA,f=t[a>>2]|0,a=t[a+4>>2]|0,!((a|0)>(q|0)|(a|0)==(q|0)&f>>>0>nA>>>0)){f=1;break A}}f=0}else f=1;while(!1);if($=$+1|0,!f){ve=21;break}if(a=t[e>>2]|0,($|0)>=(a|0)){l=0,ve=21;break}}return(ve|0)==21?(k=Ve,l|0):0}function bt(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0,$=0,U=0,BA=0,zA=0,QA=0,fe=0,he=0,Ee=0,ne=0,HA=0,SA=0,ve=0,Ve=0,de=0,We=0,Tt=0;if(Tt=k,k=k+112|0,ve=Tt+80|0,a=Tt+72|0,Ve=Tt,de=Tt+56|0,o=on(r)|0,o|0)return We=o,k=Tt,We|0;if(f=e+8|0,We=p0((t[f>>2]<<5)+32|0)|0,!We)return We=13,k=Tt,We|0;if(ro(e,We),o=on(r)|0,!o){if(HA=e,SA=t[HA+4>>2]|0,o=a,t[o>>2]=t[HA>>2],t[o+4>>2]=SA,ei(a,ve),o=mA(ve,A,Ve)|0,o)HA=0,SA=0;else{if(o=t[a>>2]|0,i=t[f>>2]|0,(i|0)>0){s=t[e+12>>2]|0,r=0;do o=(t[s+(r<<3)>>2]|0)+o|0,r=r+1|0;while((r|0)!=(i|0));r=o}else r=o;o=Ve,i=t[o>>2]|0,o=t[o+4>>2]|0,s=((r|0)<0)<<31>>31,(o|0)<(s|0)|(o|0)==(s|0)&i>>>0>>0?(o=Ve,t[o>>2]=r,t[o+4>>2]=s,o=s):r=i,HA=KA(r|0,o|0,12,0)|0,SA=S()|0,o=Ve,t[o>>2]=HA,t[o+4>>2]=SA,o=0}if(!o){if(r=Qt(HA,8)|0,!r)return qA(We),We=13,k=Tt,We|0;if(l=Qt(HA,8)|0,!l)return qA(We),qA(r),We=13,k=Tt,We|0;Ee=ve,t[Ee>>2]=0,t[Ee+4>>2]=0,Ee=e,ne=t[Ee+4>>2]|0,o=a,t[o>>2]=t[Ee>>2],t[o+4>>2]=ne,o=Ge(a,HA,SA,A,ve,r,l)|0;A:do if(o)qA(r),qA(l),qA(We);else{e:do if((t[f>>2]|0)>0){for(s=e+12|0,i=0;o=Ge((t[s>>2]|0)+(i<<3)|0,HA,SA,A,ve,r,l)|0,i=i+1|0,!(o|0);)if((i|0)>=(t[f>>2]|0))break e;qA(r),qA(l),qA(We);break A}while(!1);(SA|0)>0|(SA|0)==0&HA>>>0>0&&Y0(l|0,0,HA<<3|0)|0,ne=ve,Ee=t[ne+4>>2]|0;e:do if((Ee|0)>0|(Ee|0)==0&(t[ne>>2]|0)>>>0>0){QA=r,fe=l,he=r,Ee=l,ne=r,o=r,U=r,BA=l,zA=l,r=l;t:for(;;){for(W=0,nA=0,q=0,$=0,i=0,s=0;;){l=Ve,a=l+56|0;do t[l>>2]=0,l=l+4|0;while((l|0)<(a|0));if(A=QA+(W<<3)|0,f=t[A>>2]|0,A=t[A+4>>2]|0,F(f,A,1,Ve,0)|0){l=Ve,a=l+56|0;do t[l>>2]=0,l=l+4|0;while((l|0)<(a|0));l=Qt(7,4)|0,l|0&&(X(f,A,1,Ve,l,7,0,0)|0,qA(l))}for(G=0;;){L=Ve+(G<<3)|0,I=t[L>>2]|0,L=t[L+4>>2]|0;r:do if((I|0)==0&(L|0)==0)l=i,a=s;else{if(m=jr(I|0,L|0,HA|0,SA|0)|0,f=S()|0,l=n+(m<<3)|0,A=l,a=t[A>>2]|0,A=t[A+4>>2]|0,!((a|0)==0&(A|0)==0)){M=0,j=0;do{if((M|0)>(SA|0)|(M|0)==(SA|0)&j>>>0>HA>>>0)break t;if((a|0)==(I|0)&(A|0)==(L|0)){l=i,a=s;break r}l=KA(m|0,f|0,1,0)|0,m=Rr(l|0,S()|0,HA|0,SA|0)|0,f=S()|0,j=KA(j|0,M|0,1,0)|0,M=S()|0,l=n+(m<<3)|0,A=l,a=t[A>>2]|0,A=t[A+4>>2]|0}while(!((a|0)==0&(A|0)==0))}if((I|0)==0&(L|0)==0){l=i,a=s;break}ar(I,L,de)|0,no(e,We,de)|0&&(j=KA(i|0,s|0,1,0)|0,s=S()|0,M=l,t[M>>2]=I,t[M+4>>2]=L,i=fe+(i<<3)|0,t[i>>2]=I,t[i+4>>2]=L,i=j),l=i,a=s}while(!1);if(G=G+1|0,G>>>0>=7)break;i=l,s=a}if(W=KA(W|0,nA|0,1,0)|0,nA=S()|0,q=KA(q|0,$|0,1,0)|0,$=S()|0,s=ve,i=t[s>>2]|0,s=t[s+4>>2]|0,($|0)<(s|0)|($|0)==(s|0)&q>>>0>>0)i=l,s=a;else break}if((s|0)>0|(s|0)==0&i>>>0>0){i=0,s=0;do $=QA+(i<<3)|0,t[$>>2]=0,t[$+4>>2]=0,i=KA(i|0,s|0,1,0)|0,s=S()|0,$=ve,q=t[$+4>>2]|0;while((s|0)<(q|0)|((s|0)==(q|0)?i>>>0<(t[$>>2]|0)>>>0:0))}if($=ve,t[$>>2]=l,t[$+4>>2]=a,(a|0)>0|(a|0)==0&l>>>0>0)G=r,W=zA,nA=ne,q=BA,$=fe,r=U,zA=o,BA=he,U=G,o=W,ne=Ee,Ee=nA,he=q,fe=QA,QA=$;else break e}qA(he),qA(Ee),qA(We),o=1;break A}else o=l;while(!1);qA(We),qA(r),qA(o),o=0}while(!1);return We=o,k=Tt,We|0}}return qA(We),We=o,k=Tt,We|0}function Ct(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0;if(m=k,k=k+176|0,a=m,(A|0)<1)return si(r,0,0),f=0,k=m,f|0;for(l=e,l=wA(t[l>>2]|0,t[l+4>>2]|0,52)|0,S()|0,si(r,(A|0)>6?A:6,l&15),l=0;n=e+(l<<3)|0,n=_r(t[n>>2]|0,t[n+4>>2]|0,a)|0,!(n|0);){if(n=t[a>>2]|0,(n|0)>0){s=0;do i=a+8+(s<<4)|0,s=s+1|0,n=a+8+(((s|0)%(n|0)|0)<<4)|0,o=Jl(r,n,i)|0,o?ui(r,o)|0:ql(r,i,n)|0,n=t[a>>2]|0;while((s|0)<(n|0))}if(l=l+1|0,(l|0)>=(A|0)){n=0,f=13;break}}return(f|0)==13?(k=m,n|0):(li(r),f=n,k=m,f|0)}function pt(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0;if(i=k,k=k+32|0,n=i,o=i+16|0,e=Ct(e,A,o)|0,e|0)return r=e,k=i,r|0;if(t[r>>2]=0,t[r+4>>2]=0,t[r+8>>2]=0,e=ai(o)|0,e|0)do{A=Ml(r)|0;do Bl(A,e)|0,s=e+16|0,t[n>>2]=t[s>>2],t[n+4>>2]=t[s+4>>2],t[n+8>>2]=t[s+8>>2],t[n+12>>2]=t[s+12>>2],ui(o,e)|0,e=Xl(o,n)|0;while((e|0)!=0);e=ai(o)|0}while((e|0)!=0);return li(o),e=Dl(r)|0,e?(qo(r),s=e,k=i,s|0):(s=0,k=i,s|0)}function Re(e){return e=e|0,e>>>0>121?(e=0,e|0):(e=t[7696+(e*28|0)+16>>2]|0,e|0)}function Et(e){return e=e|0,(e|0)==4|(e|0)==117|0}function m0(e){return e=e|0,t[11120+((t[e>>2]|0)*216|0)+((t[e+4>>2]|0)*72|0)+((t[e+8>>2]|0)*24|0)+(t[e+12>>2]<<3)>>2]|0}function l0(e){return e=e|0,t[11120+((t[e>>2]|0)*216|0)+((t[e+4>>2]|0)*72|0)+((t[e+8>>2]|0)*24|0)+(t[e+12>>2]<<3)+4>>2]|0}function H0(e,A){e=e|0,A=A|0,e=7696+(e*28|0)|0,t[A>>2]=t[e>>2],t[A+4>>2]=t[e+4>>2],t[A+8>>2]=t[e+8>>2],t[A+12>>2]=t[e+12>>2]}function qt(e,A){e=e|0,A=A|0;var r=0,n=0;if(A>>>0>20)return A=-1,A|0;do if((t[11120+(A*216|0)>>2]|0)!=(e|0))if((t[11120+(A*216|0)+8>>2]|0)!=(e|0))if((t[11120+(A*216|0)+16>>2]|0)!=(e|0))if((t[11120+(A*216|0)+24>>2]|0)!=(e|0))if((t[11120+(A*216|0)+32>>2]|0)!=(e|0))if((t[11120+(A*216|0)+40>>2]|0)!=(e|0))if((t[11120+(A*216|0)+48>>2]|0)!=(e|0))if((t[11120+(A*216|0)+56>>2]|0)!=(e|0))if((t[11120+(A*216|0)+64>>2]|0)!=(e|0))if((t[11120+(A*216|0)+72>>2]|0)!=(e|0))if((t[11120+(A*216|0)+80>>2]|0)!=(e|0))if((t[11120+(A*216|0)+88>>2]|0)!=(e|0))if((t[11120+(A*216|0)+96>>2]|0)!=(e|0))if((t[11120+(A*216|0)+104>>2]|0)!=(e|0))if((t[11120+(A*216|0)+112>>2]|0)!=(e|0))if((t[11120+(A*216|0)+120>>2]|0)!=(e|0))if((t[11120+(A*216|0)+128>>2]|0)!=(e|0))if((t[11120+(A*216|0)+136>>2]|0)==(e|0))e=2,r=1,n=2;else{if((t[11120+(A*216|0)+144>>2]|0)==(e|0)){e=0,r=2,n=0;break}if((t[11120+(A*216|0)+152>>2]|0)==(e|0)){e=0,r=2,n=1;break}if((t[11120+(A*216|0)+160>>2]|0)==(e|0)){e=0,r=2,n=2;break}if((t[11120+(A*216|0)+168>>2]|0)==(e|0)){e=1,r=2,n=0;break}if((t[11120+(A*216|0)+176>>2]|0)==(e|0)){e=1,r=2,n=1;break}if((t[11120+(A*216|0)+184>>2]|0)==(e|0)){e=1,r=2,n=2;break}if((t[11120+(A*216|0)+192>>2]|0)==(e|0)){e=2,r=2,n=0;break}if((t[11120+(A*216|0)+200>>2]|0)==(e|0)){e=2,r=2,n=1;break}if((t[11120+(A*216|0)+208>>2]|0)==(e|0)){e=2,r=2,n=2;break}else e=-1;return e|0}else e=2,r=1,n=1;else e=2,r=1,n=0;else e=1,r=1,n=2;else e=1,r=1,n=1;else e=1,r=1,n=0;else e=0,r=1,n=2;else e=0,r=1,n=1;else e=0,r=1,n=0;else e=2,r=0,n=2;else e=2,r=0,n=1;else e=2,r=0,n=0;else e=1,r=0,n=2;else e=1,r=0,n=1;else e=1,r=0,n=0;else e=0,r=0,n=2;else e=0,r=0,n=1;else e=0,r=0,n=0;while(!1);return A=t[11120+(A*216|0)+(r*72|0)+(e*24|0)+(n<<3)+4>>2]|0,A|0}function S0(e,A){return e=e|0,A=A|0,(t[7696+(e*28|0)+20>>2]|0)==(A|0)?(A=1,A|0):(A=(t[7696+(e*28|0)+24>>2]|0)==(A|0),A|0)}function nr(e,A){return e=e|0,A=A|0,t[848+(e*28|0)+(A<<2)>>2]|0}function or(e,A){return e=e|0,A=A|0,(t[848+(e*28|0)>>2]|0)==(A|0)?(A=0,A|0):(t[848+(e*28|0)+4>>2]|0)==(A|0)?(A=1,A|0):(t[848+(e*28|0)+8>>2]|0)==(A|0)?(A=2,A|0):(t[848+(e*28|0)+12>>2]|0)==(A|0)?(A=3,A|0):(t[848+(e*28|0)+16>>2]|0)==(A|0)?(A=4,A|0):(t[848+(e*28|0)+20>>2]|0)==(A|0)?(A=5,A|0):((t[848+(e*28|0)+24>>2]|0)==(A|0)?6:7)|0}function Vr(){return 122}function Wr(e){e=e|0;var A=0,r=0,n=0;A=0;do EA(A|0,0,45)|0,n=S()|0|134225919,r=e+(A<<3)|0,t[r>>2]=-1,t[r+4>>2]=n,A=A+1|0;while((A|0)!=122);return 0}function Yr(e){e=e|0;var A=0,r=0,n=0;return n=+b[e+16>>3],r=+b[e+24>>3],A=n-r,+(n>3]<+b[e+24>>3]|0}function ir(e){return e=e|0,+(+b[e>>3]-+b[e+8>>3])}function a0(e,A){e=e|0,A=A|0;var r=0,n=0,o=0;return r=+b[A>>3],!(r>=+b[e+8>>3])||!(r<=+b[e>>3])?(A=0,A|0):(n=+b[e+16>>3],r=+b[e+24>>3],o=+b[A+8>>3],A=o>=r,e=o<=n&1,n>3]<+b[A+8>>3]||+b[e+8>>3]>+b[A>>3]?(n=0,n|0):(i=+b[e+16>>3],r=e+24|0,m=+b[r>>3],s=i>3],o=A+24|0,a=+b[o>>3],l=f>3],A)||(m=+Vt(+b[r>>3],e),m>+Vt(+b[n>>3],A))?(l=0,l|0):(l=1,l|0))}function M0(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0;i=+b[e+16>>3],a=+b[e+24>>3],e=i>3],s=+b[A+24>>3],o=l>2]=e?o|A?1:2:0,t[n>>2]=o?e?1:A?2:1:0}function z(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0;return+b[e>>3]<+b[A>>3]||+b[e+8>>3]>+b[A+8>>3]?(n=0,n|0):(n=e+16|0,a=+b[n>>3],i=+b[e+24>>3],s=a>3],o=A+24|0,f=+b[o>>3],l=m>3],A)?(m=+Vt(+b[n>>3],e),l=m>=+Vt(+b[r>>3],A),l|0):(l=0,l|0))}function lA(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0,l=0;o=k,k=k+176|0,n=o,t[n>>2]=4,l=+b[A>>3],b[n+8>>3]=l,i=+b[A+16>>3],b[n+16>>3]=i,b[n+24>>3]=l,l=+b[A+24>>3],b[n+32>>3]=l,s=+b[A+8>>3],b[n+40>>3]=s,b[n+48>>3]=l,b[n+56>>3]=s,b[n+64>>3]=i,A=n+72|0,r=A+96|0;do t[A>>2]=0,A=A+4|0;while((A|0)<(r|0));Ir(e|0,n|0,168)|0,k=o}function mA(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0;L=k,k=k+288|0,m=L+264|0,M=L+96|0,f=L,l=f,a=l+96|0;do t[l>>2]=0,l=l+4|0;while((l|0)<(a|0));return A=Jn(A,f)|0,A|0?(I=A,k=L,I|0):(a=f,f=t[a>>2]|0,a=t[a+4>>2]|0,ar(f,a,m)|0,_r(f,a,M)|0,s=+rn(m,M+8|0),b[m>>3]=+b[e>>3],a=m+8|0,b[a>>3]=+b[e+16>>3],b[M>>3]=+b[e+8>>3],f=M+8|0,b[f>>3]=+b[e+24>>3],o=+rn(m,M),W=+b[a>>3]-+b[f>>3],i=+$A(+W),G=+b[m>>3]-+b[M>>3],n=+$A(+G),!(W==0|G==0)&&(W=+hi(+i,+n),W=+gt(+(o*o/+Cn(+(W/+Cn(+i,+n)),3)/(s*(s*2.59807621135)*.8))),b[ge>>3]=W,j=~~W>>>0,I=+$A(W)>=1?W>0?~~+At(+He(W/4294967296),4294967295)>>>0:~~+gt((W-+(~~W>>>0))/4294967296)>>>0:0,(t[ge+4>>2]&2146435072|0)!=2146435072)?(M=(j|0)==0&(I|0)==0,A=r,t[A>>2]=M?1:j,t[A+4>>2]=M?0:I,A=0):A=1,I=A,k=L,I|0)}function FA(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0;f=k,k=k+288|0,s=f+264|0,l=f+96|0,a=f,o=a,i=o+96|0;do t[o>>2]=0,o=o+4|0;while((o|0)<(i|0));return r=Jn(r,a)|0,r|0?(n=r,k=f,n|0):(r=a,o=t[r>>2]|0,r=t[r+4>>2]|0,ar(o,r,s)|0,_r(o,r,l)|0,m=+rn(s,l+8|0),m=+gt(+(+rn(e,A)/(m*2))),b[ge>>3]=m,r=~~m>>>0,o=+$A(m)>=1?m>0?~~+At(+He(m/4294967296),4294967295)>>>0:~~+gt((m-+(~~m>>>0))/4294967296)>>>0:0,(t[ge+4>>2]&2146435072|0)==2146435072?(n=1,k=f,n|0):(a=(r|0)==0&(o|0)==0,t[n>>2]=a?1:r,t[n+4>>2]=a?0:o,n=0,k=f,n|0))}function VA(e,A){e=e|0,A=+A;var r=0,n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0;i=e+16|0,s=+b[i>>3],r=e+24|0,o=+b[r>>3],n=s-o,n=s>3],l=e+8|0,a=+b[l>>3],m=f-a,n=(n*A-n)*.5,A=(m*A-m)*.5,f=f+A,b[e>>3]=f>1.5707963267948966?1.5707963267948966:f,A=a-A,b[l>>3]=A<-1.5707963267948966?-1.5707963267948966:A,A=s+n,A=A>3.141592653589793?A+-6.283185307179586:A,b[i>>3]=A<-3.141592653589793?A+6.283185307179586:A,A=o-n,A=A>3.141592653589793?A+-6.283185307179586:A,b[r>>3]=A<-3.141592653589793?A+6.283185307179586:A}function xe(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0,t[e>>2]=A,t[e+4>>2]=r,t[e+8>>2]=n}function tt(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0;M=A+8|0,t[M>>2]=0,a=+b[e>>3],s=+$A(+a),f=+b[e+8>>3],l=+$A(+f)*1.1547005383792515,s=s+l*.5,r=~~s,e=~~l,s=s-+(r|0),l=l-+(e|0);do if(s<.5)if(s<.3333333333333333)if(t[A>>2]=r,l<(s+1)*.5){t[A+4>>2]=e;break}else{e=e+1|0,t[A+4>>2]=e;break}else if(j=1-s,e=(!(l>2]=e,j<=l&l>2]=r;break}else{t[A>>2]=r;break}else{if(!(s<.6666666666666666))if(r=r+1|0,t[A>>2]=r,l>2]=e;break}else{e=e+1|0,t[A+4>>2]=e;break}if(l<1-s){if(t[A+4>>2]=e,s*2+-1>2]=r;break}}else e=e+1|0,t[A+4>>2]=e;r=r+1|0,t[A>>2]=r}while(!1);do if(a<0)if(e&1){m=(e+1|0)/2|0,m=ct(r|0,((r|0)<0)<<31>>31|0,m|0,((m|0)<0)<<31>>31|0)|0,r=~~(+(r|0)-((+(m>>>0)+4294967296*+(S()|0))*2+1)),t[A>>2]=r;break}else{m=(e|0)/2|0,m=ct(r|0,((r|0)<0)<<31>>31|0,m|0,((m|0)<0)<<31>>31|0)|0,r=~~(+(r|0)-(+(m>>>0)+4294967296*+(S()|0))*2),t[A>>2]=r;break}while(!1);m=A+4|0,f<0&&(r=r-((e<<1|1|0)/2|0)|0,t[A>>2]=r,e=0-e|0,t[m>>2]=e),n=e-r|0,(r|0)<0?(o=0-r|0,t[m>>2]=n,t[M>>2]=o,t[A>>2]=0,e=n,r=0):o=0,(e|0)<0&&(r=r-e|0,t[A>>2]=r,o=o-e|0,t[M>>2]=o,t[m>>2]=0,e=0),i=r-o|0,n=e-o|0,(o|0)<0&&(t[A>>2]=i,t[m>>2]=n,t[M>>2]=0,e=n,r=i,o=0),n=(e|0)<(r|0)?e:r,n=(o|0)<(n|0)?o:n,!((n|0)<=0)&&(t[A>>2]=r-n,t[m>>2]=e-n,t[M>>2]=o-n)}function Me(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0;A=t[e>>2]|0,s=e+4|0,r=t[s>>2]|0,(A|0)<0&&(r=r-A|0,t[s>>2]=r,i=e+8|0,t[i>>2]=(t[i>>2]|0)-A,t[e>>2]=0,A=0),(r|0)<0?(A=A-r|0,t[e>>2]=A,i=e+8|0,o=(t[i>>2]|0)-r|0,t[i>>2]=o,t[s>>2]=0,r=0):(o=e+8|0,i=o,o=t[o>>2]|0),(o|0)<0&&(A=A-o|0,t[e>>2]=A,r=r-o|0,t[s>>2]=r,t[i>>2]=0,o=0),n=(r|0)<(A|0)?r:A,n=(o|0)<(n|0)?o:n,!((n|0)<=0)&&(t[e>>2]=A-n,t[s>>2]=r-n,t[i>>2]=o-n)}function ut(e,A){e=e|0,A=A|0;var r=0,n=0;n=t[e+8>>2]|0,r=+((t[e+4>>2]|0)-n|0),b[A>>3]=+((t[e>>2]|0)-n|0)-r*.5,b[A+8>>3]=r*.8660254037844386}function Ze(e,A,r){e=e|0,A=A|0,r=r|0,t[r>>2]=(t[A>>2]|0)+(t[e>>2]|0),t[r+4>>2]=(t[A+4>>2]|0)+(t[e+4>>2]|0),t[r+8>>2]=(t[A+8>>2]|0)+(t[e+8>>2]|0)}function yt(e,A,r){e=e|0,A=A|0,r=r|0,t[r>>2]=(t[e>>2]|0)-(t[A>>2]|0),t[r+4>>2]=(t[e+4>>2]|0)-(t[A+4>>2]|0),t[r+8>>2]=(t[e+8>>2]|0)-(t[A+8>>2]|0)}function ot(e,A){e=e|0,A=A|0;var r=0,n=0;r=Pe(t[e>>2]|0,A)|0,t[e>>2]=r,r=e+4|0,n=Pe(t[r>>2]|0,A)|0,t[r>>2]=n,e=e+8|0,A=Pe(t[e>>2]|0,A)|0,t[e>>2]=A}function St(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0;s=t[e>>2]|0,l=(s|0)<0,n=(t[e+4>>2]|0)-(l?s:0)|0,i=(n|0)<0,o=(i?0-n|0:0)+((t[e+8>>2]|0)-(l?s:0))|0,r=(o|0)<0,e=r?0:o,A=(i?0:n)-(r?o:0)|0,o=(l?0:s)-(i?n:0)-(r?o:0)|0,r=(A|0)<(o|0)?A:o,r=(e|0)<(r|0)?e:r,n=(r|0)>0,e=e-(n?r:0)|0,A=A-(n?r:0)|0;A:do switch(o-(n?r:0)|0){case 0:switch(A|0){case 0:return l=(e|0)==0?0:(e|0)==1?1:7,l|0;case 1:return l=(e|0)==0?2:(e|0)==1?3:7,l|0;default:break A}case 1:switch(A|0){case 0:return l=(e|0)==0?4:(e|0)==1?5:7,l|0;case 1:{if(!e)e=6;else break A;return e|0}default:break A}}while(!1);return l=7,l|0}function wr(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0,a=0,f=0;if(a=e+8|0,s=t[a>>2]|0,l=(t[e>>2]|0)-s|0,f=e+4|0,s=(t[f>>2]|0)-s|0,l>>>0>715827881|s>>>0>715827881){if(n=(l|0)>0,o=2147483647-l|0,i=-2147483648-l|0,(n?(o|0)<(l|0):(i|0)>(l|0))||(r=l<<1,n?(2147483647-r|0)<(l|0):(-2147483648-r|0)>(l|0))||((s|0)>0?(2147483647-s|0)<(s|0):(-2147483648-s|0)>(s|0))||(A=l*3|0,r=s<<1,(n?(o|0)<(r|0):(i|0)>(r|0))||((l|0)>-1?(A|-2147483648|0)>=(s|0):(A^-2147483648|0)<(s|0))))return f=1,f|0}else r=s<<1,A=l*3|0;return n=V0(+(A-s|0)*.14285714285714285)|0,t[e>>2]=n,o=V0(+(r+l|0)*.14285714285714285)|0,t[f>>2]=o,t[a>>2]=0,r=(o|0)<(n|0),A=r?n:o,r=r?o:n,(r|0)<0&&(((r|0)==-2147483648||((A|0)>0?(2147483647-A|0)<(r|0):(-2147483648-A|0)>(r|0)))&&OA(27795,26892,354,26903),((A|0)>-1?(A|-2147483648|0)>=(r|0):(A^-2147483648|0)<(r|0))&&OA(27795,26892,354,26903)),A=o-n|0,(n|0)<0?(r=0-n|0,t[f>>2]=A,t[a>>2]=r,t[e>>2]=0,n=0):(A=o,r=0),(A|0)<0&&(n=n-A|0,t[e>>2]=n,r=r-A|0,t[a>>2]=r,t[f>>2]=0,A=0),i=n-r|0,o=A-r|0,(r|0)<0?(t[e>>2]=i,t[f>>2]=o,t[a>>2]=0,A=o,o=i,r=0):o=n,n=(A|0)<(o|0)?A:o,n=(r|0)<(n|0)?r:n,(n|0)<=0?(f=0,f|0):(t[e>>2]=o-n,t[f>>2]=A-n,t[a>>2]=r-n,f=0,f|0)}function mn(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0,a=0;if(s=e+8|0,o=t[s>>2]|0,i=(t[e>>2]|0)-o|0,l=e+4|0,o=(t[l>>2]|0)-o|0,i>>>0>715827881|o>>>0>715827881){if(r=(i|0)>0,(r?(2147483647-i|0)<(i|0):(-2147483648-i|0)>(i|0))||(A=i<<1,n=(o|0)>0,n?(2147483647-o|0)<(o|0):(-2147483648-o|0)>(o|0)))return l=1,l|0;if(a=o<<1,(n?(2147483647-a|0)<(o|0):(-2147483648-a|0)>(o|0))||(r?(2147483647-A|0)<(o|0):(-2147483648-A|0)>(o|0))||(r=o*3|0,(o|0)>-1?(r|-2147483648|0)>=(i|0):(r^-2147483648|0)<(i|0)))return a=1,a|0}else r=o*3|0,A=i<<1;return n=V0(+(A+o|0)*.14285714285714285)|0,t[e>>2]=n,o=V0(+(r-i|0)*.14285714285714285)|0,t[l>>2]=o,t[s>>2]=0,r=(o|0)<(n|0),A=r?n:o,r=r?o:n,(r|0)<0&&(((r|0)==-2147483648||((A|0)>0?(2147483647-A|0)<(r|0):(-2147483648-A|0)>(r|0)))&&OA(27795,26892,402,26917),((A|0)>-1?(A|-2147483648|0)>=(r|0):(A^-2147483648|0)<(r|0))&&OA(27795,26892,402,26917)),A=o-n|0,(n|0)<0?(r=0-n|0,t[l>>2]=A,t[s>>2]=r,t[e>>2]=0,n=0):(A=o,r=0),(A|0)<0&&(n=n-A|0,t[e>>2]=n,r=r-A|0,t[s>>2]=r,t[l>>2]=0,A=0),i=n-r|0,o=A-r|0,(r|0)<0?(t[e>>2]=i,t[l>>2]=o,t[s>>2]=0,A=o,o=i,r=0):o=n,n=(A|0)<(o|0)?A:o,n=(r|0)<(n|0)?r:n,(n|0)<=0?(a=0,a|0):(t[e>>2]=o-n,t[l>>2]=A-n,t[s>>2]=r-n,a=0,a|0)}function vr(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0;s=e+8|0,r=t[s>>2]|0,A=(t[e>>2]|0)-r|0,l=e+4|0,r=(t[l>>2]|0)-r|0,n=V0(+((A*3|0)-r|0)*.14285714285714285)|0,t[e>>2]=n,A=V0(+((r<<1)+A|0)*.14285714285714285)|0,t[l>>2]=A,t[s>>2]=0,r=A-n|0,(n|0)<0?(i=0-n|0,t[l>>2]=r,t[s>>2]=i,t[e>>2]=0,A=r,n=0,r=i):r=0,(A|0)<0&&(n=n-A|0,t[e>>2]=n,r=r-A|0,t[s>>2]=r,t[l>>2]=0,A=0),i=n-r|0,o=A-r|0,(r|0)<0?(t[e>>2]=i,t[l>>2]=o,t[s>>2]=0,A=o,o=i,r=0):o=n,n=(A|0)<(o|0)?A:o,n=(r|0)<(n|0)?r:n,!((n|0)<=0)&&(t[e>>2]=o-n,t[l>>2]=A-n,t[s>>2]=r-n)}function kr(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0;s=e+8|0,r=t[s>>2]|0,A=(t[e>>2]|0)-r|0,l=e+4|0,r=(t[l>>2]|0)-r|0,n=V0(+((A<<1)+r|0)*.14285714285714285)|0,t[e>>2]=n,A=V0(+((r*3|0)-A|0)*.14285714285714285)|0,t[l>>2]=A,t[s>>2]=0,r=A-n|0,(n|0)<0?(i=0-n|0,t[l>>2]=r,t[s>>2]=i,t[e>>2]=0,A=r,n=0,r=i):r=0,(A|0)<0&&(n=n-A|0,t[e>>2]=n,r=r-A|0,t[s>>2]=r,t[l>>2]=0,A=0),i=n-r|0,o=A-r|0,(r|0)<0?(t[e>>2]=i,t[l>>2]=o,t[s>>2]=0,A=o,o=i,r=0):o=n,n=(A|0)<(o|0)?A:o,n=(r|0)<(n|0)?r:n,!((n|0)<=0)&&(t[e>>2]=o-n,t[l>>2]=A-n,t[s>>2]=r-n)}function br(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0;A=t[e>>2]|0,s=e+4|0,r=t[s>>2]|0,l=e+8|0,n=t[l>>2]|0,o=r+(A*3|0)|0,t[e>>2]=o,r=n+(r*3|0)|0,t[s>>2]=r,A=(n*3|0)+A|0,t[l>>2]=A,n=r-o|0,(o|0)<0?(A=A-o|0,t[s>>2]=n,t[l>>2]=A,t[e>>2]=0,r=n,n=0):n=o,(r|0)<0&&(n=n-r|0,t[e>>2]=n,A=A-r|0,t[l>>2]=A,t[s>>2]=0,r=0),i=n-A|0,o=r-A|0,(A|0)<0?(t[e>>2]=i,t[s>>2]=o,t[l>>2]=0,n=i,A=0):o=r,r=(o|0)<(n|0)?o:n,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=n-r,t[s>>2]=o-r,t[l>>2]=A-r)}function Ht(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0;o=t[e>>2]|0,s=e+4|0,A=t[s>>2]|0,l=e+8|0,r=t[l>>2]|0,n=(A*3|0)+o|0,o=r+(o*3|0)|0,t[e>>2]=o,t[s>>2]=n,A=(r*3|0)+A|0,t[l>>2]=A,r=n-o|0,(o|0)<0?(A=A-o|0,t[s>>2]=r,t[l>>2]=A,t[e>>2]=0,o=0):r=n,(r|0)<0&&(o=o-r|0,t[e>>2]=o,A=A-r|0,t[l>>2]=A,t[s>>2]=0,r=0),i=o-A|0,n=r-A|0,(A|0)<0?(t[e>>2]=i,t[s>>2]=n,t[l>>2]=0,o=i,A=0):n=r,r=(n|0)<(o|0)?n:o,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=o-r,t[s>>2]=n-r,t[l>>2]=A-r)}function gn(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0,l=0;(A+-1|0)>>>0>=6||(o=(t[15440+(A*12|0)>>2]|0)+(t[e>>2]|0)|0,t[e>>2]=o,l=e+4|0,n=(t[15440+(A*12|0)+4>>2]|0)+(t[l>>2]|0)|0,t[l>>2]=n,s=e+8|0,A=(t[15440+(A*12|0)+8>>2]|0)+(t[s>>2]|0)|0,t[s>>2]=A,r=n-o|0,(o|0)<0?(A=A-o|0,t[l>>2]=r,t[s>>2]=A,t[e>>2]=0,n=0):(r=n,n=o),(r|0)<0&&(n=n-r|0,t[e>>2]=n,A=A-r|0,t[s>>2]=A,t[l>>2]=0,r=0),i=n-A|0,o=r-A|0,(A|0)<0?(t[e>>2]=i,t[l>>2]=o,t[s>>2]=0,n=i,A=0):o=r,r=(o|0)<(n|0)?o:n,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=n-r,t[l>>2]=o-r,t[s>>2]=A-r))}function Cr(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0;o=t[e>>2]|0,s=e+4|0,A=t[s>>2]|0,l=e+8|0,r=t[l>>2]|0,n=A+o|0,o=r+o|0,t[e>>2]=o,t[s>>2]=n,A=r+A|0,t[l>>2]=A,r=n-o|0,(o|0)<0?(A=A-o|0,t[s>>2]=r,t[l>>2]=A,t[e>>2]=0,n=0):(r=n,n=o),(r|0)<0&&(n=n-r|0,t[e>>2]=n,A=A-r|0,t[l>>2]=A,t[s>>2]=0,r=0),i=n-A|0,o=r-A|0,(A|0)<0?(t[e>>2]=i,t[s>>2]=o,t[l>>2]=0,n=i,A=0):o=r,r=(o|0)<(n|0)?o:n,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=n-r,t[s>>2]=o-r,t[l>>2]=A-r)}function B0(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0;A=t[e>>2]|0,s=e+4|0,n=t[s>>2]|0,l=e+8|0,r=t[l>>2]|0,o=n+A|0,t[e>>2]=o,n=r+n|0,t[s>>2]=n,A=r+A|0,t[l>>2]=A,r=n-o|0,(o|0)<0?(A=A-o|0,t[s>>2]=r,t[l>>2]=A,t[e>>2]=0,n=0):(r=n,n=o),(r|0)<0&&(n=n-r|0,t[e>>2]=n,A=A-r|0,t[l>>2]=A,t[s>>2]=0,r=0),i=n-A|0,o=r-A|0,(A|0)<0?(t[e>>2]=i,t[s>>2]=o,t[l>>2]=0,n=i,A=0):o=r,r=(o|0)<(n|0)?o:n,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=n-r,t[s>>2]=o-r,t[l>>2]=A-r)}function Gt(e){switch(e=e|0,e|0){case 1:{e=5;break}case 5:{e=4;break}case 4:{e=6;break}case 6:{e=2;break}case 2:{e=3;break}case 3:{e=1;break}}return e|0}function Ut(e){switch(e=e|0,e|0){case 1:{e=3;break}case 3:{e=2;break}case 2:{e=6;break}case 6:{e=4;break}case 4:{e=5;break}case 5:{e=1;break}}return e|0}function Kr(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0;A=t[e>>2]|0,s=e+4|0,r=t[s>>2]|0,l=e+8|0,n=t[l>>2]|0,o=r+(A<<1)|0,t[e>>2]=o,r=n+(r<<1)|0,t[s>>2]=r,A=(n<<1)+A|0,t[l>>2]=A,n=r-o|0,(o|0)<0?(A=A-o|0,t[s>>2]=n,t[l>>2]=A,t[e>>2]=0,r=n,n=0):n=o,(r|0)<0&&(n=n-r|0,t[e>>2]=n,A=A-r|0,t[l>>2]=A,t[s>>2]=0,r=0),i=n-A|0,o=r-A|0,(A|0)<0?(t[e>>2]=i,t[s>>2]=o,t[l>>2]=0,n=i,A=0):o=r,r=(o|0)<(n|0)?o:n,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=n-r,t[s>>2]=o-r,t[l>>2]=A-r)}function Zr(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0;o=t[e>>2]|0,s=e+4|0,A=t[s>>2]|0,l=e+8|0,r=t[l>>2]|0,n=(A<<1)+o|0,o=r+(o<<1)|0,t[e>>2]=o,t[s>>2]=n,A=(r<<1)+A|0,t[l>>2]=A,r=n-o|0,(o|0)<0?(A=A-o|0,t[s>>2]=r,t[l>>2]=A,t[e>>2]=0,o=0):r=n,(r|0)<0&&(o=o-r|0,t[e>>2]=o,A=A-r|0,t[l>>2]=A,t[s>>2]=0,r=0),i=o-A|0,n=r-A|0,(A|0)<0?(t[e>>2]=i,t[s>>2]=n,t[l>>2]=0,o=i,A=0):n=r,r=(n|0)<(o|0)?n:o,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=o-r,t[s>>2]=n-r,t[l>>2]=A-r)}function Er(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0,l=0;return s=(t[e>>2]|0)-(t[A>>2]|0)|0,l=(s|0)<0,n=(t[e+4>>2]|0)-(t[A+4>>2]|0)-(l?s:0)|0,i=(n|0)<0,o=(l?0-s|0:0)+(t[e+8>>2]|0)-(t[A+8>>2]|0)+(i?0-n|0:0)|0,e=(o|0)<0,A=e?0:o,r=(i?0:n)-(e?o:0)|0,o=(l?0:s)-(i?n:0)-(e?o:0)|0,e=(r|0)<(o|0)?r:o,e=(A|0)<(e|0)?A:e,n=(e|0)>0,A=A-(n?e:0)|0,r=r-(n?e:0)|0,e=o-(n?e:0)|0,e=(e|0)>-1?e:0-e|0,r=(r|0)>-1?r:0-r|0,A=(A|0)>-1?A:0-A|0,A=(r|0)>(A|0)?r:A,((e|0)>(A|0)?e:A)|0}function $r(e,A){e=e|0,A=A|0;var r=0;r=t[e+8>>2]|0,t[A>>2]=(t[e>>2]|0)-r,t[A+4>>2]=(t[e+4>>2]|0)-r}function Mt(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0,l=0;return n=t[e>>2]|0,t[A>>2]=n,o=t[e+4>>2]|0,s=A+4|0,t[s>>2]=o,l=A+8|0,t[l>>2]=0,r=(o|0)<(n|0),e=r?n:o,r=r?o:n,(r|0)<0&&((r|0)==-2147483648||((e|0)>0?(2147483647-e|0)<(r|0):(-2147483648-e|0)>(r|0))||((e|0)>-1?(e|-2147483648|0)>=(r|0):(e^-2147483648|0)<(r|0)))?(A=1,A|0):(e=o-n|0,(n|0)<0?(r=0-n|0,t[s>>2]=e,t[l>>2]=r,t[A>>2]=0,n=0):(e=o,r=0),(e|0)<0&&(n=n-e|0,t[A>>2]=n,r=r-e|0,t[l>>2]=r,t[s>>2]=0,e=0),i=n-r|0,o=e-r|0,(r|0)<0?(t[A>>2]=i,t[s>>2]=o,t[l>>2]=0,e=o,o=i,r=0):o=n,n=(e|0)<(o|0)?e:o,n=(r|0)<(n|0)?r:n,(n|0)<=0?(A=0,A|0):(t[A>>2]=o-n,t[s>>2]=e-n,t[l>>2]=r-n,A=0,A|0))}function qr(e){e=e|0;var A=0,r=0,n=0,o=0;A=e+8|0,o=t[A>>2]|0,r=o-(t[e>>2]|0)|0,t[e>>2]=r,n=e+4|0,e=(t[n>>2]|0)-o|0,t[n>>2]=e,t[A>>2]=0-(e+r)}function Jr(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0;r=t[e>>2]|0,A=0-r|0,t[e>>2]=A,s=e+8|0,t[s>>2]=0,l=e+4|0,n=t[l>>2]|0,o=n+r|0,(r|0)>0?(t[l>>2]=o,t[s>>2]=r,t[e>>2]=0,A=0,n=o):r=0,(n|0)<0?(i=A-n|0,t[e>>2]=i,r=r-n|0,t[s>>2]=r,t[l>>2]=0,o=i-r|0,A=0-r|0,(r|0)<0?(t[e>>2]=o,t[l>>2]=A,t[s>>2]=0,n=A,r=0):(n=0,o=i)):o=A,A=(n|0)<(o|0)?n:o,A=(r|0)<(A|0)?r:A,!((A|0)<=0)&&(t[e>>2]=o-A,t[l>>2]=n-A,t[s>>2]=r-A)}function Yn(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0,a=0,f=0,m=0,M=0;if(M=k,k=k+64|0,m=M,l=M+56|0,!(!0&(A&2013265920|0)==134217728&(!0&(n&2013265920|0)==134217728)))return o=5,k=M,o|0;if((e|0)==(r|0)&(A|0)==(n|0))return t[o>>2]=0,o=0,k=M,o|0;if(s=wA(e|0,A|0,52)|0,S()|0,s=s&15,f=wA(r|0,n|0,52)|0,S()|0,(s|0)!=(f&15|0))return o=12,k=M,o|0;if(i=s+-1|0,s>>>0>1){_t(e,A,i,m)|0,_t(r,n,i,l)|0,f=m,a=t[f>>2]|0,f=t[f+4>>2]|0;A:do if((a|0)==(t[l>>2]|0)&&(f|0)==(t[l+4>>2]|0)){s=(s^15)*3|0,i=wA(e|0,A|0,s|0)|0,S()|0,i=i&7,s=wA(r|0,n|0,s|0)|0,S()|0,s=s&7;do if((i|0)==0|(s|0)==0)t[o>>2]=1,i=0;else if((i|0)==7)i=5;else{if((i|0)==1|(s|0)==1&&Oe(a,f)|0){i=5;break}if((t[15536+(i<<2)>>2]|0)!=(s|0)&&(t[15568+(i<<2)>>2]|0)!=(s|0))break A;t[o>>2]=1,i=0}while(!1);return o=i,k=M,o|0}while(!1)}i=m,s=i+56|0;do t[i>>2]=0,i=i+4|0;while((i|0)<(s|0));return v(e,A,1,m)|0,A=m,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0))&&(A=m+8|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))&&(A=m+16|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))&&(A=m+24|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))&&(A=m+32|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))&&(A=m+40|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))?(i=m+48|0,i=((t[i>>2]|0)==(r|0)?(t[i+4>>2]|0)==(n|0):0)&1):i=1,t[o>>2]=i,o=0,k=M,o|0}function pn(e,A,r,n,o){return e=e|0,A=A|0,r=r|0,n=n|0,o=o|0,r=Ae(e,A,r,n)|0,(r|0)==7?(o=11,o|0):(n=EA(r|0,0,56)|0,A=A&-2130706433|(S()|0)|268435456,t[o>>2]=e|n,t[o+4>>2]=A,o=0,o|0)}function Sr(e,A,r){return e=e|0,A=A|0,r=r|0,!0&(A&2013265920|0)==268435456?(t[r>>2]=e,t[r+4>>2]=A&-2130706433|134217728,r=0,r|0):(r=6,r|0)}function yn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0;return o=k,k=k+16|0,n=o,t[n>>2]=0,!0&(A&2013265920|0)==268435456?(i=wA(e|0,A|0,56)|0,S()|0,n=Y(e,A&-2130706433|134217728,i&7,n,r)|0,k=o,n|0):(n=6,k=o,n|0)}function Xr(e,A){e=e|0,A=A|0;var r=0;switch(r=wA(e|0,A|0,56)|0,S()|0,r&7){case 0:case 7:return r=0,r|0}return r=A&-2130706433|134217728,!(!0&(A&2013265920|0)==268435456)||!0&(A&117440512|0)==16777216&(Oe(e,r)|0)!=0?(r=0,r|0):(r=Ue(e,r)|0,r|0)}function Mr(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0;return o=k,k=k+16|0,n=o,!0&(A&2013265920|0)==268435456?(i=A&-2130706433|134217728,s=r,t[s>>2]=e,t[s+4>>2]=i,t[n>>2]=0,A=wA(e|0,A|0,56)|0,S()|0,n=Y(e,i,A&7,n,r+8|0)|0,k=o,n|0):(n=6,k=o,n|0)}function Br(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0;return o=(Oe(e,A)|0)==0,A=A&-2130706433,n=r,t[n>>2]=o?e:0,t[n+4>>2]=o?A|285212672:0,n=r+8|0,t[n>>2]=e,t[n+4>>2]=A|301989888,n=r+16|0,t[n>>2]=e,t[n+4>>2]=A|318767104,n=r+24|0,t[n>>2]=e,t[n+4>>2]=A|335544320,n=r+32|0,t[n>>2]=e,t[n+4>>2]=A|352321536,r=r+40|0,t[r>>2]=e,t[r+4>>2]=A|369098752,0}function sr(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0;return s=k,k=k+16|0,o=s,i=A&-2130706433|134217728,!0&(A&2013265920|0)==268435456?(n=wA(e|0,A|0,56)|0,S()|0,n=Kl(e,i,n&7)|0,(n|0)==-1?(t[r>>2]=0,i=6,k=s,i|0):(Dr(e,i,o)|0&&OA(27795,26932,282,26947),A=wA(e|0,A|0,52)|0,S()|0,A=A&15,Oe(e,i)|0?w(o,A,n,2,r):AA(o,A,n,2,r),i=0,k=s,i|0)):(i=6,k=s,i|0)}function xn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0;n=k,k=k+16|0,o=n,wn(e,A,r,o),tt(o,r+4|0),k=n}function wn(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0;if(l=k,k=k+16|0,a=l,An(e,r,a),i=+Lt(+(1-+b[a>>3]*.5)),i<1e-16){t[n>>2]=0,t[n+4>>2]=0,t[n+8>>2]=0,t[n+12>>2]=0,k=l;return}if(a=t[r>>2]|0,o=+b[15920+(a*24|0)>>3],o=+tn(o-+tn(+pl(15600+(a<<4)|0,e))),Jt(A)|0?s=+tn(o+-.3334731722518321):s=o,o=+et(+i)*2.618033988749896,(A|0)>0){e=0;do o=o*2.6457513110645907,e=e+1|0;while((e|0)!=(A|0))}i=+_e(+s)*o,b[n>>3]=i,s=+ie(+s)*o,b[n+8>>3]=s,k=l}function An(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0;if(i=k,k=k+32|0,o=i,Yl(e,o),t[A>>2]=0,b[r>>3]=5,n=+it(16400,o),n<+b[r>>3]&&(t[A>>2]=0,b[r>>3]=n),n=+it(16424,o),n<+b[r>>3]&&(t[A>>2]=1,b[r>>3]=n),n=+it(16448,o),n<+b[r>>3]&&(t[A>>2]=2,b[r>>3]=n),n=+it(16472,o),n<+b[r>>3]&&(t[A>>2]=3,b[r>>3]=n),n=+it(16496,o),n<+b[r>>3]&&(t[A>>2]=4,b[r>>3]=n),n=+it(16520,o),n<+b[r>>3]&&(t[A>>2]=5,b[r>>3]=n),n=+it(16544,o),n<+b[r>>3]&&(t[A>>2]=6,b[r>>3]=n),n=+it(16568,o),n<+b[r>>3]&&(t[A>>2]=7,b[r>>3]=n),n=+it(16592,o),n<+b[r>>3]&&(t[A>>2]=8,b[r>>3]=n),n=+it(16616,o),n<+b[r>>3]&&(t[A>>2]=9,b[r>>3]=n),n=+it(16640,o),n<+b[r>>3]&&(t[A>>2]=10,b[r>>3]=n),n=+it(16664,o),n<+b[r>>3]&&(t[A>>2]=11,b[r>>3]=n),n=+it(16688,o),n<+b[r>>3]&&(t[A>>2]=12,b[r>>3]=n),n=+it(16712,o),n<+b[r>>3]&&(t[A>>2]=13,b[r>>3]=n),n=+it(16736,o),n<+b[r>>3]&&(t[A>>2]=14,b[r>>3]=n),n=+it(16760,o),n<+b[r>>3]&&(t[A>>2]=15,b[r>>3]=n),n=+it(16784,o),n<+b[r>>3]&&(t[A>>2]=16,b[r>>3]=n),n=+it(16808,o),n<+b[r>>3]&&(t[A>>2]=17,b[r>>3]=n),n=+it(16832,o),n<+b[r>>3]&&(t[A>>2]=18,b[r>>3]=n),n=+it(16856,o),!(n<+b[r>>3])){k=i;return}t[A>>2]=19,b[r>>3]=n,k=i}function G0(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0;if(i=+Wl(e),i<1e-16){A=15600+(A<<4)|0,t[o>>2]=t[A>>2],t[o+4>>2]=t[A+4>>2],t[o+8>>2]=t[A+8>>2],t[o+12>>2]=t[A+12>>2];return}if(s=+Te(+ +b[e+8>>3],+ +b[e>>3]),(r|0)>0){e=0;do i=i*.37796447300922725,e=e+1|0;while((e|0)!=(r|0))}l=i*.3333333333333333,n?(r=(Jt(r)|0)==0,i=+mt(+((r?l:l*.37796447300922725)*.381966011250105))):(i=+mt(+(i*.381966011250105)),Jt(r)|0&&(s=+tn(s+.3334731722518321))),yl(15600+(A<<4)|0,+tn(+b[15920+(A*24|0)>>3]-s),i,o)}function d(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0;n=k,k=k+16|0,o=n,ut(e+4|0,o),G0(o,t[e>>2]|0,A,0,r),k=n}function w(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0,$=0,U=0,BA=0,zA=0,QA=0,fe=0,he=0,Ee=0,ne=0,HA=0,SA=0,ve=0,Ve=0,de=0;if(ve=k,k=k+272|0,i=ve+256|0,q=ve+240|0,ne=ve,HA=ve+224|0,SA=ve+208|0,$=ve+176|0,U=ve+160|0,BA=ve+192|0,zA=ve+144|0,QA=ve+128|0,fe=ve+112|0,he=ve+96|0,Ee=ve+80|0,t[i>>2]=A,t[q>>2]=t[e>>2],t[q+4>>2]=t[e+4>>2],t[q+8>>2]=t[e+8>>2],t[q+12>>2]=t[e+12>>2],B(q,i,ne),t[o>>2]=0,q=n+r+((n|0)==5&1)|0,(q|0)<=(r|0)){k=ve;return}a=t[i>>2]|0,f=HA+4|0,m=$+4|0,M=r+5|0,j=16880+(a<<2)|0,I=16960+(a<<2)|0,L=QA+8|0,G=fe+8|0,W=he+8|0,nA=SA+4|0,l=r;A:for(;;){s=ne+(((l|0)%5|0)<<4)|0,t[SA>>2]=t[s>>2],t[SA+4>>2]=t[s+4>>2],t[SA+8>>2]=t[s+8>>2],t[SA+12>>2]=t[s+12>>2];do;while((N(SA,a,0,1)|0)==2);if((l|0)>(r|0)&(Jt(A)|0)!=0){if(t[$>>2]=t[SA>>2],t[$+4>>2]=t[SA+4>>2],t[$+8>>2]=t[SA+8>>2],t[$+12>>2]=t[SA+12>>2],ut(f,U),n=t[$>>2]|0,i=t[17040+(n*80|0)+(t[HA>>2]<<2)>>2]|0,t[$>>2]=t[18640+(n*80|0)+(i*20|0)>>2],s=t[18640+(n*80|0)+(i*20|0)+16>>2]|0,(s|0)>0){e=0;do Cr(m),e=e+1|0;while((e|0)<(s|0))}switch(s=18640+(n*80|0)+(i*20|0)+4|0,t[BA>>2]=t[s>>2],t[BA+4>>2]=t[s+4>>2],t[BA+8>>2]=t[s+8>>2],ot(BA,(t[j>>2]|0)*3|0),Ze(m,BA,m),Me(m),ut(m,zA),Ve=+(t[I>>2]|0),b[QA>>3]=Ve*3,b[L>>3]=0,de=Ve*-1.5,b[fe>>3]=de,b[G>>3]=Ve*2.598076211353316,b[he>>3]=de,b[W>>3]=Ve*-2.598076211353316,t[17040+((t[$>>2]|0)*80|0)+(t[SA>>2]<<2)>>2]|0){case 1:{e=fe,n=QA;break}case 3:{e=he,n=fe;break}case 2:{e=QA,n=he;break}default:{e=12;break A}}ni(U,zA,n,e,Ee),G0(Ee,t[$>>2]|0,a,1,o+8+(t[o>>2]<<4)|0),t[o>>2]=(t[o>>2]|0)+1}if((l|0)<(M|0)&&(ut(nA,$),G0($,t[SA>>2]|0,a,1,o+8+(t[o>>2]<<4)|0),t[o>>2]=(t[o>>2]|0)+1),t[HA>>2]=t[SA>>2],t[HA+4>>2]=t[SA+4>>2],t[HA+8>>2]=t[SA+8>>2],t[HA+12>>2]=t[SA+12>>2],l=l+1|0,(l|0)>=(q|0)){e=3;break}}if((e|0)==3){k=ve;return}else(e|0)==12&&OA(26970,27017,572,27027)}function B(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0;a=k,k=k+128|0,n=a+64|0,o=a,i=n,s=20240,l=i+60|0;do t[i>>2]=t[s>>2],i=i+4|0,s=s+4|0;while((i|0)<(l|0));i=o,s=20304,l=i+60|0;do t[i>>2]=t[s>>2],i=i+4|0,s=s+4|0;while((i|0)<(l|0));l=(Jt(t[A>>2]|0)|0)==0,n=l?n:o,o=e+4|0,Kr(o),Zr(o),Jt(t[A>>2]|0)|0&&(Ht(o),t[A>>2]=(t[A>>2]|0)+1),t[r>>2]=t[e>>2],A=r+4|0,Ze(o,n,A),Me(A),t[r+16>>2]=t[e>>2],A=r+20|0,Ze(o,n+12|0,A),Me(A),t[r+32>>2]=t[e>>2],A=r+36|0,Ze(o,n+24|0,A),Me(A),t[r+48>>2]=t[e>>2],A=r+52|0,Ze(o,n+36|0,A),Me(A),t[r+64>>2]=t[e>>2],r=r+68|0,Ze(o,n+48|0,r),Me(r),k=a}function N(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0;if(L=k,k=k+32|0,j=L+12|0,l=L,I=e+4|0,M=t[16960+(A<<2)>>2]|0,m=(n|0)!=0,M=m?M*3|0:M,o=t[I>>2]|0,f=e+8|0,s=t[f>>2]|0,m){if(i=e+12|0,n=t[i>>2]|0,o=s+o+n|0,(o|0)==(M|0))return I=1,k=L,I|0;a=i}else a=e+12|0,n=t[a>>2]|0,o=s+o+n|0;if((o|0)<=(M|0))return I=0,k=L,I|0;do if((n|0)>0){if(n=t[e>>2]|0,(s|0)>0){i=18640+(n*80|0)+60|0,n=e;break}n=18640+(n*80|0)+40|0,r?(xe(j,M,0,0),yt(I,j,l),B0(l),Ze(l,j,I),i=n,n=e):(i=n,n=e)}else i=18640+((t[e>>2]|0)*80|0)+20|0,n=e;while(!1);if(t[n>>2]=t[i>>2],o=i+16|0,(t[o>>2]|0)>0){n=0;do Cr(I),n=n+1|0;while((n|0)<(t[o>>2]|0))}return e=i+4|0,t[j>>2]=t[e>>2],t[j+4>>2]=t[e+4>>2],t[j+8>>2]=t[e+8>>2],A=t[16880+(A<<2)>>2]|0,ot(j,m?A*3|0:A),Ze(I,j,I),Me(I),m?n=((t[f>>2]|0)+(t[I>>2]|0)+(t[a>>2]|0)|0)==(M|0)?1:2:n=2,I=n,k=L,I|0}function tA(e,A){e=e|0,A=A|0;var r=0;do r=N(e,A,0,1)|0;while((r|0)==2);return r|0}function AA(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0,$=0,U=0,BA=0,zA=0,QA=0,fe=0,he=0,Ee=0,ne=0;if(he=k,k=k+240|0,i=he+224|0,BA=he+208|0,zA=he,QA=he+192|0,fe=he+176|0,W=he+160|0,nA=he+144|0,q=he+128|0,$=he+112|0,U=he+96|0,t[i>>2]=A,t[BA>>2]=t[e>>2],t[BA+4>>2]=t[e+4>>2],t[BA+8>>2]=t[e+8>>2],t[BA+12>>2]=t[e+12>>2],dA(BA,i,zA),t[o>>2]=0,G=n+r+((n|0)==6&1)|0,(G|0)<=(r|0)){k=he;return}a=t[i>>2]|0,f=r+6|0,m=16960+(a<<2)|0,M=nA+8|0,j=q+8|0,I=$+8|0,L=QA+4|0,s=0,l=r,n=-1;A:for(;;){if(i=(l|0)%6|0,e=zA+(i<<4)|0,t[QA>>2]=t[e>>2],t[QA+4>>2]=t[e+4>>2],t[QA+8>>2]=t[e+8>>2],t[QA+12>>2]=t[e+12>>2],e=s,s=N(QA,a,0,1)|0,(l|0)>(r|0)&(Jt(A)|0)!=0&&(e|0)!=1&&(t[QA>>2]|0)!=(n|0)){switch(ut(zA+(((i+5|0)%6|0)<<4)+4|0,fe),ut(zA+(i<<4)+4|0,W),Ee=+(t[m>>2]|0),b[nA>>3]=Ee*3,b[M>>3]=0,ne=Ee*-1.5,b[q>>3]=ne,b[j>>3]=Ee*2.598076211353316,b[$>>3]=ne,b[I>>3]=Ee*-2.598076211353316,i=t[BA>>2]|0,t[17040+(i*80|0)+(((n|0)==(i|0)?t[QA>>2]|0:n)<<2)>>2]|0){case 1:{e=q,n=nA;break}case 3:{e=$,n=q;break}case 2:{e=nA,n=$;break}default:{e=8;break A}}ni(fe,W,n,e,U),!(oi(fe,U)|0)&&!(oi(W,U)|0)&&(G0(U,t[BA>>2]|0,a,1,o+8+(t[o>>2]<<4)|0),t[o>>2]=(t[o>>2]|0)+1)}if((l|0)<(f|0)&&(ut(L,fe),G0(fe,t[QA>>2]|0,a,1,o+8+(t[o>>2]<<4)|0),t[o>>2]=(t[o>>2]|0)+1),l=l+1|0,(l|0)>=(G|0)){e=3;break}else n=t[QA>>2]|0}if((e|0)==3){k=he;return}else(e|0)==8&&OA(27054,27017,737,27099)}function dA(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0;a=k,k=k+160|0,n=a+80|0,o=a,i=n,s=20368,l=i+72|0;do t[i>>2]=t[s>>2],i=i+4|0,s=s+4|0;while((i|0)<(l|0));i=o,s=20448,l=i+72|0;do t[i>>2]=t[s>>2],i=i+4|0,s=s+4|0;while((i|0)<(l|0));l=(Jt(t[A>>2]|0)|0)==0,n=l?n:o,o=e+4|0,Kr(o),Zr(o),Jt(t[A>>2]|0)|0&&(Ht(o),t[A>>2]=(t[A>>2]|0)+1),t[r>>2]=t[e>>2],A=r+4|0,Ze(o,n,A),Me(A),t[r+16>>2]=t[e>>2],A=r+20|0,Ze(o,n+12|0,A),Me(A),t[r+32>>2]=t[e>>2],A=r+36|0,Ze(o,n+24|0,A),Me(A),t[r+48>>2]=t[e>>2],A=r+52|0,Ze(o,n+36|0,A),Me(A),t[r+64>>2]=t[e>>2],A=r+68|0,Ze(o,n+48|0,A),Me(A),t[r+80>>2]=t[e>>2],r=r+84|0,Ze(o,n+60|0,r),Me(r),k=a}function _A(e,A){return e=e|0,A=A|0,A=wA(e|0,A|0,52)|0,S()|0,A&15|0}function te(e,A){return e=e|0,A=A|0,A=wA(e|0,A|0,45)|0,S()|0,A&127|0}function ke(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,(r+-1|0)>>>0>14?(n=4,n|0):(r=wA(e|0,A|0,(15-r|0)*3|0)|0,S()|0,t[n>>2]=r&7,n=0,n|0)}function we(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0;if(e>>>0>15)return n=4,n|0;if(A>>>0>121)return n=17,n|0;s=EA(e|0,0,52)|0,o=S()|0,l=EA(A|0,0,45)|0,o=o|(S()|0)|134225919;A:do if((e|0)>=1){for(l=1,s=(xA[20528+A>>0]|0)!=0,i=-1;;){if(A=t[r+(l+-1<<2)>>2]|0,A>>>0>6){o=18,A=10;break}if(!((A|0)==0|s^1))if((A|0)==1){o=19,A=10;break}else s=0;if(f=(15-l|0)*3|0,a=EA(7,0,f|0)|0,o=o&~(S()|0),A=EA(A|0,((A|0)<0)<<31>>31|0,f|0)|0,i=A|i&~a,o=S()|0|o,(l|0)<(e|0))l=l+1|0;else break A}if((A|0)==10)return o|0}else i=-1;while(!1);return f=n,t[f>>2]=i,t[f+4>>2]=o,f=0,f|0}function Ue(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0;return!(!0&(A&-16777216|0)==134217728)||(n=wA(e|0,A|0,52)|0,S()|0,n=n&15,r=wA(e|0,A|0,45)|0,S()|0,r=r&127,r>>>0>121)?(e=0,e|0):(s=(n^15)*3|0,o=wA(e|0,A|0,s|0)|0,s=EA(o|0,S()|0,s|0)|0,o=S()|0,i=ct(-1227133514,-1171,s|0,o|0)|0,!((s&613566756&i|0)==0&(o&4681&(S()|0)|0)==0)||(s=(n*3|0)+19|0,i=EA(~e|0,~A|0,s|0)|0,s=wA(i|0,S()|0,s|0)|0,!((n|0)==15|(s|0)==0&(S()|0)==0))?(s=0,s|0):!(xA[20528+r>>0]|0)||(A=A&8191,(e|0)==0&(A|0)==0)?(s=1,s|0):(s=io(e|0,A|0)|0,S()|0,((63-s|0)%3|0|0)!=0|0))}function Bt(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0;return!0&(A&-16777216|0)==134217728&&(n=wA(e|0,A|0,52)|0,S()|0,n=n&15,r=wA(e|0,A|0,45)|0,S()|0,r=r&127,r>>>0<=121)&&(s=(n^15)*3|0,o=wA(e|0,A|0,s|0)|0,s=EA(o|0,S()|0,s|0)|0,o=S()|0,i=ct(-1227133514,-1171,s|0,o|0)|0,(s&613566756&i|0)==0&(o&4681&(S()|0)|0)==0)&&(s=(n*3|0)+19|0,i=EA(~e|0,~A|0,s|0)|0,s=wA(i|0,S()|0,s|0)|0,(n|0)==15|(s|0)==0&(S()|0)==0)&&(!(xA[20528+r>>0]|0)||(r=A&8191,(e|0)==0&(r|0)==0)||(s=io(e|0,r|0)|0,S()|0,(63-s|0)%3|0|0))||Xr(e,A)|0?(s=1,s|0):(s=(ii(e,A)|0)!=0&1,s|0)}function Dt(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0;if(o=EA(A|0,0,52)|0,i=S()|0,r=EA(r|0,0,45)|0,r=i|(S()|0)|134225919,(A|0)<1){i=-1,n=r,A=e,t[A>>2]=i,e=e+4|0,t[e>>2]=n;return}for(i=1,o=-1;s=(15-i|0)*3|0,l=EA(7,0,s|0)|0,r=r&~(S()|0),s=EA(n|0,0,s|0)|0,o=o&~l|s,r=r|(S()|0),(i|0)!=(A|0);)i=i+1|0;l=e,s=l,t[s>>2]=o,l=l+4|0,t[l>>2]=r}function _t(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0;if(i=wA(e|0,A|0,52)|0,S()|0,i=i&15,r>>>0>15)return n=4,n|0;if((i|0)<(r|0))return n=12,n|0;if((i|0)==(r|0))return t[n>>2]=e,t[n+4>>2]=A,n=0,n|0;if(o=EA(r|0,0,52)|0,o=o|e,e=S()|0|A&-15728641,(i|0)>(r|0))do A=EA(7,0,(14-r|0)*3|0)|0,r=r+1|0,o=A|o,e=S()|0|e;while((r|0)<(i|0));return t[n>>2]=o,t[n+4>>2]=e,n=0,n|0}function g0(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0;if(i=wA(e|0,A|0,52)|0,S()|0,i=i&15,!((r|0)<16&(i|0)<=(r|0)))return n=4,n|0;o=r-i|0,r=wA(e|0,A|0,45)|0,S()|0;A:do if(!(Re(r&127)|0))r=U0(7,0,o,((o|0)<0)<<31>>31)|0,o=S()|0;else{e:do if(i|0){for(r=1;s=EA(7,0,(15-r|0)*3|0)|0,!!((s&e|0)==0&((S()|0)&A|0)==0);)if(r>>>0>>0)r=r+1|0;else break e;r=U0(7,0,o,((o|0)<0)<<31>>31)|0,o=S()|0;break A}while(!1);r=U0(7,0,o,((o|0)<0)<<31>>31)|0,r=ft(r|0,S()|0,5,0)|0,r=KA(r|0,S()|0,-5,-1)|0,r=W0(r|0,S()|0,6,0)|0,r=KA(r|0,S()|0,1,0)|0,o=S()|0}while(!1);return s=n,t[s>>2]=r,t[s+4>>2]=o,s=0,s|0}function Oe(e,A){e=e|0,A=A|0;var r=0,n=0,o=0;if(o=wA(e|0,A|0,45)|0,S()|0,!(Re(o&127)|0))return o=0,o|0;o=wA(e|0,A|0,52)|0,S()|0,o=o&15;A:do if(!o)r=0;else for(n=1;;){if(r=wA(e|0,A|0,(15-n|0)*3|0)|0,S()|0,r=r&7,r|0)break A;if(n>>>0>>0)n=n+1|0;else{r=0;break}}while(!1);return o=(r|0)==0&1,o|0}function en(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0;if(s=k,k=k+16|0,i=s,Xn(i,e,A,r),A=i,e=t[A>>2]|0,A=t[A+4>>2]|0,(e|0)==0&(A|0)==0)return k=s,0;o=0,r=0;do l=n+(o<<3)|0,t[l>>2]=e,t[l+4>>2]=A,o=KA(o|0,r|0,1,0)|0,r=S()|0,Ao(i),l=i,e=t[l>>2]|0,A=t[l+4>>2]|0;while(!((e|0)==0&(A|0)==0));return k=s,0}function Vo(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,(n|0)<(r|0)?(r=A,n=e,YA(r|0),n|0):(r=EA(-1,-1,((n-r|0)*3|0)+3|0)|0,n=EA(~r|0,~(S()|0)|0,(15-n|0)*3|0)|0,r=~(S()|0)&A,n=~n&e,YA(r|0),n|0)}function Wo(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0;return o=wA(e|0,A|0,52)|0,S()|0,o=o&15,(r|0)<16&(o|0)<=(r|0)?((o|0)<(r|0)&&(o=EA(-1,-1,((r+-1-o|0)*3|0)+3|0)|0,o=EA(~o|0,~(S()|0)|0,(15-r|0)*3|0)|0,A=~(S()|0)&A,e=~o&e),o=EA(r|0,0,52)|0,r=A&-15728641|(S()|0),t[n>>2]=e|o,t[n+4>>2]=r,n=0,n|0):(n=4,n|0)}function ol(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0,$=0,U=0,BA=0,zA=0,QA=0,fe=0,he=0,Ee=0,ne=0,HA=0,SA=0;if((r|0)==0&(n|0)==0)return SA=0,SA|0;if(o=e,i=t[o>>2]|0,o=t[o+4>>2]|0,!0&(o&15728640|0)==0){if(!((n|0)>0|(n|0)==0&r>>>0>0)||(SA=A,t[SA>>2]=i,t[SA+4>>2]=o,(r|0)==1&(n|0)==0))return SA=0,SA|0;o=1,i=0;do ne=e+(o<<3)|0,HA=t[ne+4>>2]|0,SA=A+(o<<3)|0,t[SA>>2]=t[ne>>2],t[SA+4>>2]=HA,o=KA(o|0,i|0,1,0)|0,i=S()|0;while((i|0)<(n|0)|(i|0)==(n|0)&o>>>0>>0);return o=0,o|0}if(Ee=r<<3,HA=p0(Ee)|0,!HA)return SA=13,SA|0;if(Ir(HA|0,e|0,Ee|0)|0,ne=Qt(r,8)|0,!ne)return qA(HA),SA=13,SA|0;A:for(;;){o=HA,f=t[o>>2]|0,o=t[o+4>>2]|0,fe=wA(f|0,o|0,52)|0,S()|0,fe=fe&15,he=fe+-1|0,QA=(fe|0)!=0,zA=(n|0)>0|(n|0)==0&r>>>0>0;e:do if(QA&zA){if(q=EA(he|0,0,52)|0,$=S()|0,he>>>0>15){if(!((f|0)==0&(o|0)==0)){SA=16;break A}for(i=0,e=0;;){if(i=KA(i|0,e|0,1,0)|0,e=S()|0,!((e|0)<(n|0)|(e|0)==(n|0)&i>>>0>>0))break e;if(s=HA+(i<<3)|0,BA=t[s>>2]|0,s=t[s+4>>2]|0,!((BA|0)==0&(s|0)==0)){o=s,SA=16;break A}}}for(l=f,e=o,i=0,s=0;;){if(!((l|0)==0&(e|0)==0)){if(!(!0&(e&117440512|0)==0)){SA=21;break A}if(m=wA(l|0,e|0,52)|0,S()|0,m=m&15,(m|0)<(he|0)){o=12,SA=27;break A}if((m|0)!=(he|0)&&(l=l|q,e=e&-15728641|$,m>>>0>=fe>>>0)){a=he;do BA=EA(7,0,(14-a|0)*3|0)|0,a=a+1|0,l=BA|l,e=S()|0|e;while(a>>>0>>0)}if(j=jr(l|0,e|0,r|0,n|0)|0,I=S()|0,a=ne+(j<<3)|0,m=a,M=t[m>>2]|0,m=t[m+4>>2]|0,!((M|0)==0&(m|0)==0)){W=0,nA=0;do{if((W|0)>(n|0)|(W|0)==(n|0)&nA>>>0>r>>>0){SA=31;break A}if((M|0)==(l|0)&(m&-117440513|0)==(e|0)){L=wA(M|0,m|0,56)|0,S()|0,L=L&7,G=L+1|0,BA=wA(M|0,m|0,45)|0,S()|0;t:do if(!(Re(BA&127)|0))m=7;else{if(M=wA(M|0,m|0,52)|0,S()|0,M=M&15,!M){m=6;break}for(m=1;;){if(BA=EA(7,0,(15-m|0)*3|0)|0,!((BA&l|0)==0&((S()|0)&e|0)==0)){m=7;break t}if(m>>>0>>0)m=m+1|0;else{m=6;break}}}while(!1);if((L+2|0)>>>0>m>>>0){SA=41;break A}BA=EA(G|0,0,56)|0,e=S()|0|e&-117440513,U=a,t[U>>2]=0,t[U+4>>2]=0,l=BA|l}else j=KA(j|0,I|0,1,0)|0,j=Rr(j|0,S()|0,r|0,n|0)|0,I=S()|0;nA=KA(nA|0,W|0,1,0)|0,W=S()|0,a=ne+(j<<3)|0,m=a,M=t[m>>2]|0,m=t[m+4>>2]|0}while(!((M|0)==0&(m|0)==0))}BA=a,t[BA>>2]=l,t[BA+4>>2]=e}if(i=KA(i|0,s|0,1,0)|0,s=S()|0,!((s|0)<(n|0)|(s|0)==(n|0)&i>>>0>>0))break e;e=HA+(i<<3)|0,l=t[e>>2]|0,e=t[e+4>>2]|0}}while(!1);if(BA=KA(r|0,n|0,5,0)|0,U=S()|0,U>>>0<0|(U|0)==0&BA>>>0<11){SA=85;break}if(BA=W0(r|0,n|0,6,0)|0,S()|0,BA=Qt(BA,8)|0,!BA){SA=48;break}do if(zA){for(G=0,e=0,L=0,W=0;;){if(m=ne+(G<<3)|0,s=m,i=t[s>>2]|0,s=t[s+4>>2]|0,(i|0)==0&(s|0)==0)U=L;else{M=wA(i|0,s|0,56)|0,S()|0,M=M&7,l=M+1|0,j=s&-117440513,U=wA(i|0,s|0,45)|0,S()|0;e:do if(Re(U&127)|0){if(I=wA(i|0,s|0,52)|0,S()|0,I=I&15,I|0)for(a=1;;){if(U=EA(7,0,(15-a|0)*3|0)|0,!((i&U|0)==0&(j&(S()|0)|0)==0))break e;if(a>>>0>>0)a=a+1|0;else break}s=EA(l|0,0,56)|0,i=s|i,s=S()|0|j,l=m,t[l>>2]=i,t[l+4>>2]=s,l=M+2|0}while(!1);(l|0)==7?(U=BA+(e<<3)|0,t[U>>2]=i,t[U+4>>2]=s&-117440513,e=KA(e|0,L|0,1,0)|0,U=S()|0):U=L}if(G=KA(G|0,W|0,1,0)|0,W=S()|0,(W|0)<(n|0)|(W|0)==(n|0)&G>>>0>>0)L=U;else break}if(zA){if(nA=he>>>0>15,q=EA(he|0,0,52)|0,$=S()|0,!QA){for(i=0,a=0,l=0,s=0;(f|0)==0&(o|0)==0||(he=A+(i<<3)|0,t[he>>2]=f,t[he+4>>2]=o,i=KA(i|0,a|0,1,0)|0,a=S()|0),l=KA(l|0,s|0,1,0)|0,s=S()|0,!!((s|0)<(n|0)|(s|0)==(n|0)&l>>>0>>0);)o=HA+(l<<3)|0,f=t[o>>2]|0,o=t[o+4>>2]|0;o=U;break}for(i=0,a=0,s=0,l=0;;){do if(!((f|0)==0&(o|0)==0)){if(I=wA(f|0,o|0,52)|0,S()|0,I=I&15,nA|(I|0)<(he|0)){SA=80;break A}if((I|0)!=(he|0)){if(m=f|q,M=o&-15728641|$,I>>>0>=fe>>>0){j=he;do QA=EA(7,0,(14-j|0)*3|0)|0,j=j+1|0,m=QA|m,M=S()|0|M;while(j>>>0>>0)}}else m=f,M=o;L=jr(m|0,M|0,r|0,n|0)|0,j=0,I=0,W=S()|0;do{if((j|0)>(n|0)|(j|0)==(n|0)&I>>>0>r>>>0){SA=81;break A}if(QA=ne+(L<<3)|0,G=t[QA+4>>2]|0,(G&-117440513|0)==(M|0)&&(t[QA>>2]|0)==(m|0)){SA=65;break}QA=KA(L|0,W|0,1,0)|0,L=Rr(QA|0,S()|0,r|0,n|0)|0,W=S()|0,I=KA(I|0,j|0,1,0)|0,j=S()|0,QA=ne+(L<<3)|0}while(!((t[QA>>2]|0)==(m|0)&&(t[QA+4>>2]|0)==(M|0)));if((SA|0)==65&&(SA=0,!0&(G&117440512|0)==100663296))break;QA=A+(i<<3)|0,t[QA>>2]=f,t[QA+4>>2]=o,i=KA(i|0,a|0,1,0)|0,a=S()|0}while(!1);if(s=KA(s|0,l|0,1,0)|0,l=S()|0,!((l|0)<(n|0)|(l|0)==(n|0)&s>>>0>>0))break;o=HA+(s<<3)|0,f=t[o>>2]|0,o=t[o+4>>2]|0}o=U}else i=0,o=U}else i=0,e=0,o=0;while(!1);if(Y0(ne|0,0,Ee|0)|0,Ir(HA|0,BA|0,e<<3|0)|0,qA(BA),(e|0)==0&(o|0)==0){SA=89;break}else A=A+(i<<3)|0,n=o,r=e}if((SA|0)==16)!0&(o&117440512|0)==0?(o=4,SA=27):SA=21;else if((SA|0)==31)OA(27795,27122,620,27132);else{if((SA|0)==41)return qA(HA),qA(ne),SA=10,SA|0;if((SA|0)==48)return qA(HA),qA(ne),SA=13,SA|0;(SA|0)==80?OA(27795,27122,711,27132):(SA|0)==81?OA(27795,27122,723,27132):(SA|0)==85&&(Ir(A|0,HA|0,r<<3|0)|0,SA=89)}return(SA|0)==21?(qA(HA),qA(ne),SA=5,SA|0):(SA|0)==27?(qA(HA),qA(ne),SA=o,SA|0):(SA|0)==89?(qA(HA),qA(ne),SA=0,SA|0):0}function il(e,A,r,n,o,i,s){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0,i=i|0,s=s|0;var l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0;if(G=k,k=k+16|0,L=G,!((r|0)>0|(r|0)==0&A>>>0>0))return L=0,k=G,L|0;if((s|0)>=16)return L=12,k=G,L|0;j=0,I=0,M=0,l=0;A:for(;;){if(f=e+(j<<3)|0,a=t[f>>2]|0,f=t[f+4>>2]|0,m=wA(a|0,f|0,52)|0,S()|0,(m&15|0)>(s|0)){l=12,a=11;break}if(Xn(L,a,f,s),m=L,f=t[m>>2]|0,m=t[m+4>>2]|0,(f|0)==0&(m|0)==0)a=M;else{a=M;do{if(!((l|0)<(i|0)|(l|0)==(i|0)&a>>>0>>0)){a=10;break A}M=n+(a<<3)|0,t[M>>2]=f,t[M+4>>2]=m,a=KA(a|0,l|0,1,0)|0,l=S()|0,Ao(L),M=L,f=t[M>>2]|0,m=t[M+4>>2]|0}while(!((f|0)==0&(m|0)==0))}if(j=KA(j|0,I|0,1,0)|0,I=S()|0,(I|0)<(r|0)|(I|0)==(r|0)&j>>>0>>0)M=a;else{l=0,a=11;break}}return(a|0)==10?(L=14,k=G,L|0):(a|0)==11?(k=G,l|0):0}function sl(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0;j=k,k=k+16|0,M=j;A:do if((r|0)>0|(r|0)==0&A>>>0>0){for(f=0,s=0,i=0,m=0;;){if(a=e+(f<<3)|0,l=t[a>>2]|0,a=t[a+4>>2]|0,!((l|0)==0&(a|0)==0)&&(a=(g0(l,a,n,M)|0)==0,l=M,s=KA(t[l>>2]|0,t[l+4>>2]|0,s|0,i|0)|0,i=S()|0,!a)){i=12;break}if(f=KA(f|0,m|0,1,0)|0,m=S()|0,!((m|0)<(r|0)|(m|0)==(r|0)&f>>>0>>0))break A}return k=j,i|0}else s=0,i=0;while(!1);return t[o>>2]=s,t[o+4>>2]=i,o=0,k=j,o|0}function ll(e,A){return e=e|0,A=A|0,A=wA(e|0,A|0,52)|0,S()|0,A&1|0}function Pt(e,A){e=e|0,A=A|0;var r=0,n=0,o=0;if(o=wA(e|0,A|0,52)|0,S()|0,o=o&15,!o)return o=0,o|0;for(n=1;;){if(r=wA(e|0,A|0,(15-n|0)*3|0)|0,S()|0,r=r&7,r|0){n=5;break}if(n>>>0>>0)n=n+1|0;else{r=0,n=5;break}}return(n|0)==5?r|0:0}function Kn(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0,l=0,a=0;if(a=wA(e|0,A|0,52)|0,S()|0,a=a&15,!a)return l=A,a=e,YA(l|0),a|0;for(l=1,r=0;;){i=(15-l|0)*3|0,n=EA(7,0,i|0)|0,o=S()|0,s=wA(e|0,A|0,i|0)|0,S()|0,i=EA(Gt(s&7)|0,0,i|0)|0,s=S()|0,e=i|e&~n,A=s|A&~o;A:do if(!r)if((i&n|0)==0&(s&o|0)==0)r=0;else if(n=wA(e|0,A|0,52)|0,S()|0,n=n&15,!n)r=1;else{r=1;e:for(;;){switch(s=wA(e|0,A|0,(15-r|0)*3|0)|0,S()|0,s&7){case 1:break e;case 0:break;default:{r=1;break A}}if(r>>>0>>0)r=r+1|0;else{r=1;break A}}for(r=1;;)if(s=(15-r|0)*3|0,o=wA(e|0,A|0,s|0)|0,S()|0,i=EA(7,0,s|0)|0,A=A&~(S()|0),s=EA(Gt(o&7)|0,0,s|0)|0,e=e&~i|s,A=A|(S()|0),r>>>0>>0)r=r+1|0;else{r=1;break}}while(!1);if(l>>>0>>0)l=l+1|0;else break}return YA(A|0),e|0}function lr(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0;if(n=wA(e|0,A|0,52)|0,S()|0,n=n&15,!n)return r=A,n=e,YA(r|0),n|0;for(r=1;i=(15-r|0)*3|0,s=wA(e|0,A|0,i|0)|0,S()|0,o=EA(7,0,i|0)|0,A=A&~(S()|0),i=EA(Gt(s&7)|0,0,i|0)|0,e=i|e&~o,A=S()|0|A,r>>>0>>0;)r=r+1|0;return YA(A|0),e|0}function al(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0,l=0,a=0;if(a=wA(e|0,A|0,52)|0,S()|0,a=a&15,!a)return l=A,a=e,YA(l|0),a|0;for(l=1,r=0;;){i=(15-l|0)*3|0,n=EA(7,0,i|0)|0,o=S()|0,s=wA(e|0,A|0,i|0)|0,S()|0,i=EA(Ut(s&7)|0,0,i|0)|0,s=S()|0,e=i|e&~n,A=s|A&~o;A:do if(!r)if((i&n|0)==0&(s&o|0)==0)r=0;else if(n=wA(e|0,A|0,52)|0,S()|0,n=n&15,!n)r=1;else{r=1;e:for(;;){switch(s=wA(e|0,A|0,(15-r|0)*3|0)|0,S()|0,s&7){case 1:break e;case 0:break;default:{r=1;break A}}if(r>>>0>>0)r=r+1|0;else{r=1;break A}}for(r=1;;)if(o=(15-r|0)*3|0,i=EA(7,0,o|0)|0,s=A&~(S()|0),A=wA(e|0,A|0,o|0)|0,S()|0,A=EA(Ut(A&7)|0,0,o|0)|0,e=e&~i|A,A=s|(S()|0),r>>>0>>0)r=r+1|0;else{r=1;break}}while(!1);if(l>>>0>>0)l=l+1|0;else break}return YA(A|0),e|0}function Zn(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0;if(n=wA(e|0,A|0,52)|0,S()|0,n=n&15,!n)return r=A,n=e,YA(r|0),n|0;for(r=1;s=(15-r|0)*3|0,i=EA(7,0,s|0)|0,o=A&~(S()|0),A=wA(e|0,A|0,s|0)|0,S()|0,A=EA(Ut(A&7)|0,0,s|0)|0,e=A|e&~i,A=S()|0|o,r>>>0>>0;)r=r+1|0;return YA(A|0),e|0}function ul(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0;if(a=k,k=k+64|0,l=a+40|0,n=a+24|0,o=a+12|0,i=a,EA(A|0,0,52)|0,r=S()|0|134225919,!A)return(t[e+4>>2]|0)>2||(t[e+8>>2]|0)>2||(t[e+12>>2]|0)>2?(s=0,l=0,YA(s|0),k=a,l|0):(EA(m0(e)|0,0,45)|0,s=S()|0|r,l=-1,YA(s|0),k=a,l|0);if(t[l>>2]=t[e>>2],t[l+4>>2]=t[e+4>>2],t[l+8>>2]=t[e+8>>2],t[l+12>>2]=t[e+12>>2],s=l+4|0,(A|0)>0)for(e=-1;t[n>>2]=t[s>>2],t[n+4>>2]=t[s+4>>2],t[n+8>>2]=t[s+8>>2],A&1?(vr(s),t[o>>2]=t[s>>2],t[o+4>>2]=t[s+4>>2],t[o+8>>2]=t[s+8>>2],br(o)):(kr(s),t[o>>2]=t[s>>2],t[o+4>>2]=t[s+4>>2],t[o+8>>2]=t[s+8>>2],Ht(o)),yt(n,o,i),Me(i),m=(15-A|0)*3|0,f=EA(7,0,m|0)|0,r=r&~(S()|0),m=EA(St(i)|0,0,m|0)|0,e=m|e&~f,r=S()|0|r,(A|0)>1;)A=A+-1|0;else e=-1;A:do if((t[s>>2]|0)<=2&&(t[l+8>>2]|0)<=2&&(t[l+12>>2]|0)<=2){if(n=m0(l)|0,A=EA(n|0,0,45)|0,A=A|e,e=S()|0|r&-1040385,i=l0(l)|0,!(Re(n)|0)){if((i|0)<=0)break;for(o=0;;){if(n=wA(A|0,e|0,52)|0,S()|0,n=n&15,n)for(r=1;m=(15-r|0)*3|0,l=wA(A|0,e|0,m|0)|0,S()|0,f=EA(7,0,m|0)|0,e=e&~(S()|0),m=EA(Gt(l&7)|0,0,m|0)|0,A=A&~f|m,e=e|(S()|0),r>>>0>>0;)r=r+1|0;if(o=o+1|0,(o|0)==(i|0))break A}}o=wA(A|0,e|0,52)|0,S()|0,o=o&15;e:do if(o){r=1;t:for(;;){switch(m=wA(A|0,e|0,(15-r|0)*3|0)|0,S()|0,m&7){case 1:break t;case 0:break;default:break e}if(r>>>0>>0)r=r+1|0;else break e}if(S0(n,t[l>>2]|0)|0)for(r=1;l=(15-r|0)*3|0,f=EA(7,0,l|0)|0,m=e&~(S()|0),e=wA(A|0,e|0,l|0)|0,S()|0,e=EA(Ut(e&7)|0,0,l|0)|0,A=A&~f|e,e=m|(S()|0),r>>>0>>0;)r=r+1|0;else for(r=1;m=(15-r|0)*3|0,l=wA(A|0,e|0,m|0)|0,S()|0,f=EA(7,0,m|0)|0,e=e&~(S()|0),m=EA(Gt(l&7)|0,0,m|0)|0,A=A&~f|m,e=e|(S()|0),r>>>0>>0;)r=r+1|0}while(!1);if((i|0)>0){r=0;do A=Kn(A,e)|0,e=S()|0,r=r+1|0;while((r|0)!=(i|0))}}else A=0,e=0;while(!1);return f=e,m=A,YA(f|0),k=a,m|0}function Jt(e){return e=e|0,(e|0)%2|0|0}function $n(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0;return o=k,k=k+16|0,n=o,A>>>0>15?(n=4,k=o,n|0):(t[e+4>>2]&2146435072|0)==2146435072||(t[e+8+4>>2]&2146435072|0)==2146435072?(n=3,k=o,n|0):(xn(e,A,n),A=ul(n,A)|0,n=S()|0,t[r>>2]=A,t[r+4>>2]=n,(A|0)==0&(n|0)==0&&OA(27795,27122,1050,27145),n=0,k=o,n|0)}function qn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0;if(o=r+4|0,i=wA(e|0,A|0,52)|0,S()|0,i=i&15,s=wA(e|0,A|0,45)|0,S()|0,n=(i|0)==0,Re(s&127)|0){if(n)return s=1,s|0;n=1}else{if(n)return s=0,s|0;(t[o>>2]|0)==0&&(t[r+8>>2]|0)==0?n=(t[r+12>>2]|0)!=0&1:n=1}for(r=1;r&1?br(o):Ht(o),s=wA(e|0,A|0,(15-r|0)*3|0)|0,S()|0,gn(o,s&7),r>>>0>>0;)r=r+1|0;return n|0}function Dr(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0;if(m=k,k=k+16|0,a=m,f=wA(e|0,A|0,45)|0,S()|0,f=f&127,f>>>0>121)return t[r>>2]=0,t[r+4>>2]=0,t[r+8>>2]=0,t[r+12>>2]=0,f=5,k=m,f|0;A:do if((Re(f)|0)!=0&&(i=wA(e|0,A|0,52)|0,S()|0,i=i&15,(i|0)!=0)){n=1;e:for(;;){switch(l=wA(e|0,A|0,(15-n|0)*3|0)|0,S()|0,l&7){case 5:break e;case 0:break;default:{n=A;break A}}if(n>>>0>>0)n=n+1|0;else{n=A;break A}}for(o=1,n=A;A=(15-o|0)*3|0,s=EA(7,0,A|0)|0,l=n&~(S()|0),n=wA(e|0,n|0,A|0)|0,S()|0,n=EA(Ut(n&7)|0,0,A|0)|0,e=e&~s|n,n=l|(S()|0),o>>>0>>0;)o=o+1|0}else n=A;while(!1);if(l=7696+(f*28|0)|0,t[r>>2]=t[l>>2],t[r+4>>2]=t[l+4>>2],t[r+8>>2]=t[l+8>>2],t[r+12>>2]=t[l+12>>2],!(qn(e,n,r)|0))return f=0,k=m,f|0;if(s=r+4|0,t[a>>2]=t[s>>2],t[a+4>>2]=t[s+4>>2],t[a+8>>2]=t[s+8>>2],i=wA(e|0,n|0,52)|0,S()|0,l=i&15,i&1?(Ht(s),i=l+1|0):i=l,!(Re(f)|0))n=0;else{A:do if(!l)n=0;else for(A=1;;){if(o=wA(e|0,n|0,(15-A|0)*3|0)|0,S()|0,o=o&7,o|0){n=o;break A}if(A>>>0>>0)A=A+1|0;else{n=0;break}}while(!1);n=(n|0)==4&1}if(!(N(r,i,n,0)|0))(i|0)!=(l|0)&&(t[s>>2]=t[a>>2],t[s+4>>2]=t[a+4>>2],t[s+8>>2]=t[a+8>>2]);else{if(Re(f)|0)do;while((N(r,i,0,0)|0)!=0);(i|0)!=(l|0)&&kr(s)}return f=0,k=m,f|0}function ar(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0;return i=k,k=k+16|0,n=i,o=Dr(e,A,n)|0,o|0?(k=i,o|0):(o=wA(e|0,A|0,52)|0,S()|0,d(n,o&15,r),o=0,k=i,o|0)}function _r(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0;if(s=k,k=k+16|0,i=s,n=Dr(e,A,i)|0,n|0)return i=n,k=s,i|0;n=wA(e|0,A|0,45)|0,S()|0,n=(Re(n&127)|0)==0,o=wA(e|0,A|0,52)|0,S()|0,o=o&15;A:do if(!n){if(o|0)for(n=1;;){if(l=EA(7,0,(15-n|0)*3|0)|0,!((l&e|0)==0&((S()|0)&A|0)==0))break A;if(n>>>0>>0)n=n+1|0;else break}return w(i,o,0,5,r),l=0,k=s,l|0}while(!1);return AA(i,o,0,6,r),l=0,k=s,l|0}function cl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0;if(o=wA(e|0,A|0,45)|0,S()|0,!(Re(o&127)|0))return o=2,t[r>>2]=o,0;if(o=wA(e|0,A|0,52)|0,S()|0,o=o&15,!o)return o=5,t[r>>2]=o,0;for(n=1;;){if(i=EA(7,0,(15-n|0)*3|0)|0,!((i&e|0)==0&((S()|0)&A|0)==0)){n=2,e=6;break}if(n>>>0>>0)n=n+1|0;else{n=5,e=6;break}}return(e|0)==6&&(t[r>>2]=n),0}function Yo(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0;M=k,k=k+128|0,f=M+112|0,i=M+96|0,m=M,o=wA(e|0,A|0,52)|0,S()|0,l=o&15,t[f>>2]=l,s=wA(e|0,A|0,45)|0,S()|0,s=s&127;A:do if(Re(s)|0){if(l|0)for(n=1;;){if(a=EA(7,0,(15-n|0)*3|0)|0,!((a&e|0)==0&((S()|0)&A|0)==0)){o=0;break A}if(n>>>0>>0)n=n+1|0;else break}if(o&1)o=1;else return a=EA(l+1|0,0,52)|0,m=S()|0|A&-15728641,f=EA(7,0,(14-l|0)*3|0)|0,m=Yo((a|e)&~f,m&~(S()|0),r)|0,k=M,m|0}else o=0;while(!1);if(n=Dr(e,A,i)|0,!n){o?(B(i,f,m),a=5):(dA(i,f,m),a=6);A:do if(Re(s)|0)if(!l)e=5;else for(n=1;;){if(s=EA(7,0,(15-n|0)*3|0)|0,!((s&e|0)==0&((S()|0)&A|0)==0)){e=2;break A}if(n>>>0>>0)n=n+1|0;else{e=5;break}}else e=2;while(!1);Y0(r|0,-1,e<<2|0)|0;A:do if(o)for(i=0;;){if(s=m+(i<<4)|0,tA(s,t[f>>2]|0)|0,s=t[s>>2]|0,l=t[r>>2]|0,(l|0)==-1|(l|0)==(s|0))n=r;else{o=0;do{if(o=o+1|0,o>>>0>=e>>>0){n=1;break A}n=r+(o<<2)|0,l=t[n>>2]|0}while(!((l|0)==-1|(l|0)==(s|0)))}if(t[n>>2]=s,i=i+1|0,i>>>0>=a>>>0){n=0;break}}else for(i=0;;){if(s=m+(i<<4)|0,N(s,t[f>>2]|0,0,1)|0,s=t[s>>2]|0,l=t[r>>2]|0,(l|0)==-1|(l|0)==(s|0))n=r;else{o=0;do{if(o=o+1|0,o>>>0>=e>>>0){n=1;break A}n=r+(o<<2)|0,l=t[n>>2]|0}while(!((l|0)==-1|(l|0)==(s|0)))}if(t[n>>2]=s,i=i+1|0,i>>>0>=a>>>0){n=0;break}}while(!1)}return m=n,k=M,m|0}function fl(){return 12}function Jn(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0,l=0,a=0;if(e>>>0>15)return l=4,l|0;if(EA(e|0,0,52)|0,l=S()|0|134225919,!e){r=0,n=0;do Re(n)|0&&(EA(n|0,0,45)|0,s=l|(S()|0),e=A+(r<<3)|0,t[e>>2]=-1,t[e+4>>2]=s,r=r+1|0),n=n+1|0;while((n|0)!=122);return r=0,r|0}r=0,s=0;do{if(Re(s)|0){for(EA(s|0,0,45)|0,n=1,o=-1,i=l|(S()|0);a=EA(7,0,(15-n|0)*3|0)|0,o=o&~a,i=i&~(S()|0),(n|0)!=(e|0);)n=n+1|0;a=A+(r<<3)|0,t[a>>2]=o,t[a+4>>2]=i,r=r+1|0}s=s+1|0}while((s|0)!=122);return r=0,r|0}function hl(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0;if(q=k,k=k+16|0,W=q,nA=wA(e|0,A|0,52)|0,S()|0,nA=nA&15,r>>>0>15)return nA=4,k=q,nA|0;if((nA|0)<(r|0))return nA=12,k=q,nA|0;if((nA|0)!=(r|0))if(i=EA(r|0,0,52)|0,i=i|e,l=S()|0|A&-15728641,(nA|0)>(r|0)){a=r;do G=EA(7,0,(14-a|0)*3|0)|0,a=a+1|0,i=G|i,l=S()|0|l;while((a|0)<(nA|0));G=i}else G=i;else G=e,l=A;L=wA(G|0,l|0,45)|0,S()|0;A:do if(Re(L&127)|0){if(a=wA(G|0,l|0,52)|0,S()|0,a=a&15,a|0)for(i=1;;){if(L=EA(7,0,(15-i|0)*3|0)|0,!((L&G|0)==0&((S()|0)&l|0)==0)){f=33;break A}if(i>>>0>>0)i=i+1|0;else break}if(L=n,t[L>>2]=0,t[L+4>>2]=0,(nA|0)>(r|0)){for(L=A&-15728641,I=nA;;){if(j=I,I=I+-1|0,I>>>0>15|(nA|0)<(I|0)){f=19;break}if((nA|0)!=(I|0))if(i=EA(I|0,0,52)|0,i=i|e,a=S()|0|L,(nA|0)<(j|0))M=i;else{f=I;do M=EA(7,0,(14-f|0)*3|0)|0,f=f+1|0,i=M|i,a=S()|0|a;while((f|0)<(nA|0));M=i}else M=e,a=A;if(m=wA(M|0,a|0,45)|0,S()|0,!(Re(m&127)|0))i=0;else{m=wA(M|0,a|0,52)|0,S()|0,m=m&15;e:do if(!m)i=0;else for(f=1;;){if(i=wA(M|0,a|0,(15-f|0)*3|0)|0,S()|0,i=i&7,i|0)break e;if(f>>>0>>0)f=f+1|0;else{i=0;break}}while(!1);i=(i|0)==0&1}if(a=wA(e|0,A|0,(15-j|0)*3|0)|0,S()|0,a=a&7,(a|0)==7){o=5,f=42;break}if(i=(i|0)!=0,(a|0)==1&i){o=5,f=42;break}if(M=a+(((a|0)!=0&i)<<31>>31)|0,M|0&&(f=nA-j|0,f=U0(7,0,f,((f|0)<0)<<31>>31)|0,m=S()|0,i?(i=ft(f|0,m|0,5,0)|0,i=KA(i|0,S()|0,-5,-1)|0,i=W0(i|0,S()|0,6,0)|0,i=KA(i|0,S()|0,1,0)|0,a=S()|0):(i=f,a=m),j=M+-1|0,j=ft(f|0,m|0,j|0,((j|0)<0)<<31>>31|0)|0,j=KA(i|0,a|0,j|0,S()|0)|0,M=S()|0,m=n,m=KA(j|0,M|0,t[m>>2]|0,t[m+4>>2]|0)|0,M=S()|0,j=n,t[j>>2]=m,t[j+4>>2]=M),(I|0)<=(r|0)){f=37;break}}if((f|0)==19)OA(27795,27122,1367,27158);else if((f|0)==37){s=n,o=t[s+4>>2]|0,s=t[s>>2]|0;break}else if((f|0)==42)return k=q,o|0}else o=0,s=0}else f=33;while(!1);A:do if((f|0)==33)if(L=n,t[L>>2]=0,t[L+4>>2]=0,(nA|0)>(r|0)){for(i=nA;;){if(o=wA(e|0,A|0,(15-i|0)*3|0)|0,S()|0,o=o&7,(o|0)==7){o=5;break}if(s=nA-i|0,s=U0(7,0,s,((s|0)<0)<<31>>31)|0,o=ft(s|0,S()|0,o|0,0)|0,s=S()|0,L=n,s=KA(t[L>>2]|0,t[L+4>>2]|0,o|0,s|0)|0,o=S()|0,L=n,t[L>>2]=s,t[L+4>>2]=o,i=i+-1|0,(i|0)<=(r|0))break A}return k=q,o|0}else o=0,s=0;while(!1);return g0(G,l,nA,W)|0&&OA(27795,27122,1327,27173),nA=W,W=t[nA+4>>2]|0,((o|0)>-1|(o|0)==-1&s>>>0>4294967295)&((W|0)>(o|0)|((W|0)==(o|0)?(t[nA>>2]|0)>>>0>s>>>0:0))?(nA=0,k=q,nA|0):(OA(27795,27122,1407,27158),0)}function dl(e,A,r,n,o,i){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0,i=i|0;var s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0;if(M=k,k=k+16|0,s=M,o>>>0>15)return i=4,k=M,i|0;if(l=wA(r|0,n|0,52)|0,S()|0,l=l&15,(l|0)>(o|0))return i=12,k=M,i|0;if(g0(r,n,o,s)|0&&OA(27795,27122,1327,27173),m=s,f=t[m+4>>2]|0,!(((A|0)>-1|(A|0)==-1&e>>>0>4294967295)&((f|0)>(A|0)|((f|0)==(A|0)?(t[m>>2]|0)>>>0>e>>>0:0))))return i=2,k=M,i|0;m=o-l|0,o=EA(o|0,0,52)|0,a=S()|0|n&-15728641,f=i,t[f>>2]=o|r,t[f+4>>2]=a,f=wA(r|0,n|0,45)|0,S()|0;A:do if(Re(f&127)|0){if(l|0)for(s=1;;){if(f=EA(7,0,(15-s|0)*3|0)|0,!((f&r|0)==0&((S()|0)&n|0)==0))break A;if(s>>>0>>0)s=s+1|0;else break}if((m|0)<1)return i=0,k=M,i|0;for(f=l^15,n=-1,a=1,s=1;;){l=m-a|0,l=U0(7,0,l,((l|0)<0)<<31>>31)|0,r=S()|0;do if(s)if(s=ft(l|0,r|0,5,0)|0,s=KA(s|0,S()|0,-5,-1)|0,s=W0(s|0,S()|0,6,0)|0,o=S()|0,(A|0)>(o|0)|(A|0)==(o|0)&e>>>0>s>>>0){A=KA(e|0,A|0,-1,-1)|0,A=ct(A|0,S()|0,s|0,o|0)|0,s=S()|0,j=i,L=t[j>>2]|0,j=t[j+4>>2]|0,G=(f+n|0)*3|0,I=EA(7,0,G|0)|0,j=j&~(S()|0),n=W0(A|0,s|0,l|0,r|0)|0,e=S()|0,o=KA(n|0,e|0,2,0)|0,G=EA(o|0,S()|0,G|0)|0,j=S()|0|j,o=i,t[o>>2]=G|L&~I,t[o+4>>2]=j,e=ft(n|0,e|0,l|0,r|0)|0,e=ct(A|0,s|0,e|0,S()|0)|0,s=0,A=S()|0;break}else{G=i,I=t[G>>2]|0,G=t[G+4>>2]|0,L=EA(7,0,(f+n|0)*3|0)|0,G=G&~(S()|0),s=i,t[s>>2]=I&~L,t[s+4>>2]=G,s=1;break}else I=i,o=t[I>>2]|0,I=t[I+4>>2]|0,n=(f+n|0)*3|0,j=EA(7,0,n|0)|0,I=I&~(S()|0),G=W0(e|0,A|0,l|0,r|0)|0,s=S()|0,n=EA(G|0,s|0,n|0)|0,I=S()|0|I,L=i,t[L>>2]=n|o&~j,t[L+4>>2]=I,s=ft(G|0,s|0,l|0,r|0)|0,e=ct(e|0,A|0,s|0,S()|0)|0,s=0,A=S()|0;while(!1);if((m|0)>(a|0))n=~a,a=a+1|0;else{A=0;break}}return k=M,A|0}while(!1);if((m|0)<1)return G=0,k=M,G|0;for(o=l^15,s=1;;)if(L=m-s|0,L=U0(7,0,L,((L|0)<0)<<31>>31)|0,G=S()|0,a=i,r=t[a>>2]|0,a=t[a+4>>2]|0,l=(o-s|0)*3|0,n=EA(7,0,l|0)|0,a=a&~(S()|0),j=W0(e|0,A|0,L|0,G|0)|0,I=S()|0,l=EA(j|0,I|0,l|0)|0,a=S()|0|a,f=i,t[f>>2]=l|r&~n,t[f+4>>2]=a,G=ft(j|0,I|0,L|0,G|0)|0,e=ct(e|0,A|0,G|0,S()|0)|0,A=S()|0,(m|0)<=(s|0)){A=0;break}else s=s+1|0;return k=M,A|0}function Xn(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0;o=wA(A|0,r|0,52)|0,S()|0,o=o&15,(A|0)==0&(r|0)==0|((n|0)>15|(o|0)>(n|0))?(i=-1,A=-1,r=0,o=0):(A=Vo(A,r,o+1|0,n)|0,s=(S()|0)&-15728641,r=EA(n|0,0,52)|0,r=A|r,s=s|(S()|0),A=(Oe(r,s)|0)==0,i=o,A=A?-1:n,o=s),s=e,t[s>>2]=r,t[s+4>>2]=o,t[e+8>>2]=i,t[e+12>>2]=A}function Ko(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0;if(o=wA(e|0,A|0,52)|0,S()|0,o=o&15,i=n+8|0,t[i>>2]=o,(e|0)==0&(A|0)==0|((r|0)>15|(o|0)>(r|0))){r=n,t[r>>2]=0,t[r+4>>2]=0,t[i>>2]=-1,t[n+12>>2]=-1;return}if(e=Vo(e,A,o+1|0,r)|0,i=(S()|0)&-15728641,o=EA(r|0,0,52)|0,o=e|o,i=i|(S()|0),e=n,t[e>>2]=o,t[e+4>>2]=i,e=n+12|0,Oe(o,i)|0){t[e>>2]=r;return}else{t[e>>2]=-1;return}}function Ao(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0,a=0,f=0;if(r=e,A=t[r>>2]|0,r=t[r+4>>2]|0,!((A|0)==0&(r|0)==0)&&(n=wA(A|0,r|0,52)|0,S()|0,n=n&15,l=EA(1,0,(n^15)*3|0)|0,A=KA(l|0,S()|0,A|0,r|0)|0,r=S()|0,l=e,t[l>>2]=A,t[l+4>>2]=r,l=e+8|0,s=t[l>>2]|0,!((n|0)<(s|0)))){for(a=e+12|0,i=n;;){if((i|0)==(s|0)){n=5;break}if(f=(i|0)==(t[a>>2]|0),o=(15-i|0)*3|0,n=wA(A|0,r|0,o|0)|0,S()|0,n=n&7,f&((n|0)==1&!0)){n=7;break}if(!((n|0)==7&!0)){n=10;break}if(f=EA(1,0,o|0)|0,A=KA(A|0,r|0,f|0,S()|0)|0,r=S()|0,f=e,t[f>>2]=A,t[f+4>>2]=r,(i|0)>(s|0))i=i+-1|0;else{n=10;break}}if((n|0)==5){f=e,t[f>>2]=0,t[f+4>>2]=0,t[l>>2]=-1,t[a>>2]=-1;return}else if((n|0)==7){s=EA(1,0,o|0)|0,s=KA(A|0,r|0,s|0,S()|0)|0,l=S()|0,f=e,t[f>>2]=s,t[f+4>>2]=l,t[a>>2]=i+-1;return}else if((n|0)==10)return}}function tn(e){e=+e;var A=0;return A=e<0?e+6.283185307179586:e,+(e>=6.283185307179586?A+-6.283185307179586:A)}function Tr(e,A){return e=e|0,A=A|0,+$A(+(+b[e>>3]-+b[A>>3]))<17453292519943298e-27?(A=+$A(+(+b[e+8>>3]-+b[A+8>>3]))<17453292519943298e-27,A|0):(A=0,A|0)}function Vt(e,A){switch(e=+e,A=A|0,A|0){case 1:{e=e<0?e+6.283185307179586:e;break}case 2:{e=e>0?e+-6.283185307179586:e;break}}return+e}function ml(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0;return o=+b[A>>3],n=+b[e>>3],i=+ie(+((o-n)*.5)),r=+ie(+((+b[A+8>>3]-+b[e+8>>3])*.5)),r=i*i+r*(+_e(+o)*+_e(+n)*r),+(+Te(+ +ye(+r),+ +ye(+(1-r)))*2)}function rn(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0;return o=+b[A>>3],n=+b[e>>3],i=+ie(+((o-n)*.5)),r=+ie(+((+b[A+8>>3]-+b[e+8>>3])*.5)),r=i*i+r*(+_e(+o)*+_e(+n)*r),+(+Te(+ +ye(+r),+ +ye(+(1-r)))*2*6371.007180918475)}function gl(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0;return o=+b[A>>3],n=+b[e>>3],i=+ie(+((o-n)*.5)),r=+ie(+((+b[A+8>>3]-+b[e+8>>3])*.5)),r=i*i+r*(+_e(+o)*+_e(+n)*r),+(+Te(+ +ye(+r),+ +ye(+(1-r)))*2*6371.007180918475*1e3)}function pl(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0;return i=+b[A>>3],n=+_e(+i),o=+b[A+8>>3]-+b[e+8>>3],s=n*+ie(+o),r=+b[e>>3],+ +Te(+s,+(+ie(+i)*+_e(+r)-+_e(+o)*(n*+ie(+r))))}function yl(e,A,r,n){e=e|0,A=+A,r=+r,n=n|0;var o=0,i=0,s=0,l=0;if(r<1e-16){t[n>>2]=t[e>>2],t[n+4>>2]=t[e+4>>2],t[n+8>>2]=t[e+8>>2],t[n+12>>2]=t[e+12>>2];return}i=A<0?A+6.283185307179586:A,i=A>=6.283185307179586?i+-6.283185307179586:i;do if(i<1e-16)A=+b[e>>3]+r,b[n>>3]=A,o=n;else{if(o=+$A(+(i+-3.141592653589793))<1e-16,A=+b[e>>3],o){A=A-r,b[n>>3]=A,o=n;break}if(s=+_e(+r),r=+ie(+r),A=s*+ie(+A)+ +_e(+i)*(r*+_e(+A)),A=A>1?1:A,A=+h0(+(A<-1?-1:A)),b[n>>3]=A,+$A(+(A+-1.5707963267948966))<1e-16){b[n>>3]=1.5707963267948966,b[n+8>>3]=0;return}if(+$A(+(A+1.5707963267948966))<1e-16){b[n>>3]=-1.5707963267948966,b[n+8>>3]=0;return}if(l=1/+_e(+A),i=r*+ie(+i)*l,r=+b[e>>3],A=l*((s-+ie(+A)*+ie(+r))/+_e(+r)),s=i>1?1:i,A=A>1?1:A,A=+b[e+8>>3]+ +Te(+(s<-1?-1:s),+(A<-1?-1:A)),A>3.141592653589793)do A=A+-6.283185307179586;while(A>3.141592653589793);if(A<-3.141592653589793)do A=A+6.283185307179586;while(A<-3.141592653589793);b[n+8>>3]=A;return}while(!1);if(+$A(+(A+-1.5707963267948966))<1e-16){b[o>>3]=1.5707963267948966,b[n+8>>3]=0;return}if(+$A(+(A+1.5707963267948966))<1e-16){b[o>>3]=-1.5707963267948966,b[n+8>>3]=0;return}if(A=+b[e+8>>3],A>3.141592653589793)do A=A+-6.283185307179586;while(A>3.141592653589793);if(A<-3.141592653589793)do A=A+6.283185307179586;while(A<-3.141592653589793);b[n+8>>3]=A}function Zo(e,A){return e=e|0,A=A|0,e>>>0>15?(A=4,A|0):(b[A>>3]=+b[20656+(e<<3)>>3],A=0,A|0)}function xl(e,A){return e=e|0,A=A|0,e>>>0>15?(A=4,A|0):(b[A>>3]=+b[20784+(e<<3)>>3],A=0,A|0)}function wl(e,A){return e=e|0,A=A|0,e>>>0>15?(A=4,A|0):(b[A>>3]=+b[20912+(e<<3)>>3],A=0,A|0)}function vl(e,A){return e=e|0,A=A|0,e>>>0>15?(A=4,A|0):(b[A>>3]=+b[21040+(e<<3)>>3],A=0,A|0)}function vn(e,A){e=e|0,A=A|0;var r=0;return e>>>0>15?(A=4,A|0):(r=U0(7,0,e,((e|0)<0)<<31>>31)|0,r=ft(r|0,S()|0,120,0)|0,e=S()|0,t[A>>2]=r|2,t[A+4>>2]=e,A=0,A|0)}function $o(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0;return j=+b[A>>3],m=+b[e>>3],a=+ie(+((j-m)*.5)),i=+b[A+8>>3],f=+b[e+8>>3],s=+ie(+((i-f)*.5)),l=+_e(+m),M=+_e(+j),s=a*a+s*(M*l*s),s=+Te(+ +ye(+s),+ +ye(+(1-s)))*2,a=+b[r>>3],j=+ie(+((a-j)*.5)),n=+b[r+8>>3],i=+ie(+((n-i)*.5)),o=+_e(+a),i=j*j+i*(M*o*i),i=+Te(+ +ye(+i),+ +ye(+(1-i)))*2,a=+ie(+((m-a)*.5)),n=+ie(+((f-n)*.5)),n=a*a+n*(l*o*n),n=+Te(+ +ye(+n),+ +ye(+(1-n)))*2,o=(s+i+n)*.5,+(+mt(+ +ye(+(+et(+(o*.5))*+et(+((o-s)*.5))*+et(+((o-i)*.5))*+et(+((o-n)*.5)))))*4)}function eo(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0;if(l=k,k=k+192|0,i=l+168|0,s=l,o=ar(e,A,i)|0,o|0)return r=o,k=l,r|0;if(_r(e,A,s)|0&&OA(27795,27190,415,27199),A=t[s>>2]|0,(A|0)>0){if(n=+$o(s+8|0,s+8+(((A|0)!=1&1)<<4)|0,i)+0,(A|0)!=1){e=1;do o=e,e=e+1|0,n=n+ +$o(s+8+(o<<4)|0,s+8+(((e|0)%(A|0)|0)<<4)|0,i);while((e|0)<(A|0))}}else n=0;return b[r>>3]=n,r=0,k=l,r|0}function kl(e,A,r){return e=e|0,A=A|0,r=r|0,e=eo(e,A,r)|0,e|0||(b[r>>3]=+b[r>>3]*6371.007180918475*6371.007180918475),e|0}function bl(e,A,r){return e=e|0,A=A|0,r=r|0,e=eo(e,A,r)|0,e|0||(b[r>>3]=+b[r>>3]*6371.007180918475*6371.007180918475*1e3*1e3),e|0}function Cl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0;if(l=k,k=k+176|0,s=l,e=sr(e,A,s)|0,e|0)return s=e,k=l,s|0;if(b[r>>3]=0,e=t[s>>2]|0,(e|0)<=1)return s=0,k=l,s|0;A=e+-1|0,e=0,n=+b[s+8>>3],o=+b[s+16>>3],i=0;do e=e+1|0,f=n,n=+b[s+8+(e<<4)>>3],m=+ie(+((n-f)*.5)),a=o,o=+b[s+8+(e<<4)+8>>3],a=+ie(+((o-a)*.5)),a=m*m+a*(+_e(+n)*+_e(+f)*a),i=i+ +Te(+ +ye(+a),+ +ye(+(1-a)))*2;while((e|0)<(A|0));return b[r>>3]=i,s=0,k=l,s|0}function El(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0;if(l=k,k=k+176|0,s=l,e=sr(e,A,s)|0,e|0)return s=e,i=+b[r>>3],i=i*6371.007180918475,b[r>>3]=i,k=l,s|0;if(b[r>>3]=0,e=t[s>>2]|0,(e|0)<=1)return s=0,i=0,i=i*6371.007180918475,b[r>>3]=i,k=l,s|0;A=e+-1|0,e=0,n=+b[s+8>>3],o=+b[s+16>>3],i=0;do e=e+1|0,f=n,n=+b[s+8+(e<<4)>>3],m=+ie(+((n-f)*.5)),a=o,o=+b[s+8+(e<<4)+8>>3],a=+ie(+((o-a)*.5)),a=m*m+a*(+_e(+f)*+_e(+n)*a),i=i+ +Te(+ +ye(+a),+ +ye(+(1-a)))*2;while((e|0)!=(A|0));return b[r>>3]=i,s=0,m=i,m=m*6371.007180918475,b[r>>3]=m,k=l,s|0}function Sl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0;if(l=k,k=k+176|0,s=l,e=sr(e,A,s)|0,e|0)return s=e,i=+b[r>>3],i=i*6371.007180918475,i=i*1e3,b[r>>3]=i,k=l,s|0;if(b[r>>3]=0,e=t[s>>2]|0,(e|0)<=1)return s=0,i=0,i=i*6371.007180918475,i=i*1e3,b[r>>3]=i,k=l,s|0;A=e+-1|0,e=0,n=+b[s+8>>3],o=+b[s+16>>3],i=0;do e=e+1|0,f=n,n=+b[s+8+(e<<4)>>3],m=+ie(+((n-f)*.5)),a=o,o=+b[s+8+(e<<4)+8>>3],a=+ie(+((o-a)*.5)),a=m*m+a*(+_e(+f)*+_e(+n)*a),i=i+ +Te(+ +ye(+a),+ +ye(+(1-a)))*2;while((e|0)!=(A|0));return b[r>>3]=i,s=0,m=i,m=m*6371.007180918475,m=m*1e3,b[r>>3]=m,k=l,s|0}function Ml(e){e=e|0;var A=0,r=0,n=0;return A=Qt(1,12)|0,A||OA(27280,27235,49,27293),r=e+4|0,n=t[r>>2]|0,n|0?(n=n+8|0,t[n>>2]=A,t[r>>2]=A,A|0):(t[e>>2]|0&&OA(27310,27235,61,27333),n=e,t[n>>2]=A,t[r>>2]=A,A|0)}function Bl(e,A){e=e|0,A=A|0;var r=0,n=0;return n=p0(24)|0,n||OA(27347,27235,78,27361),t[n>>2]=t[A>>2],t[n+4>>2]=t[A+4>>2],t[n+8>>2]=t[A+8>>2],t[n+12>>2]=t[A+12>>2],t[n+16>>2]=0,A=e+4|0,r=t[A>>2]|0,r|0?(t[r+16>>2]=n,t[A>>2]=n,n|0):(t[e>>2]|0&&OA(27376,27235,82,27361),t[e>>2]=n,t[A>>2]=n,n|0)}function qo(e){e=e|0;var A=0,r=0,n=0,o=0;if(e)for(n=1;;){if(A=t[e>>2]|0,A|0)do{if(r=t[A>>2]|0,r|0)do o=r,r=t[r+16>>2]|0,qA(o);while((r|0)!=0);o=A,A=t[A+8>>2]|0,qA(o)}while((A|0)!=0);if(A=e,e=t[e+8>>2]|0,n||qA(A),e)n=0;else break}}function Dl(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0,$=0,U=0,BA=0,zA=0,QA=0,fe=0,he=0,Ee=0,ne=0,HA=0,SA=0,ve=0,Ve=0,de=0;if(o=e+8|0,t[o>>2]|0)return de=1,de|0;if(n=t[e>>2]|0,!n)return de=0,de|0;A=n,r=0;do r=r+1|0,A=t[A+8>>2]|0;while((A|0)!=0);if(r>>>0<2)return de=0,de|0;ve=p0(r<<2)|0,ve||OA(27396,27235,317,27415),SA=p0(r<<5)|0,SA||OA(27437,27235,321,27415),t[e>>2]=0,zA=e+4|0,t[zA>>2]=0,t[o>>2]=0,r=0,HA=0,BA=0,M=0;A:for(;;){if(m=t[n>>2]|0,m){i=0,s=m;do{if(a=+b[s+8>>3],A=s,s=t[s+16>>2]|0,f=(s|0)==0,o=f?m:s,l=+b[o+8>>3],+$A(+(a-l))>3.141592653589793){de=14;break}i=i+(l-a)*(+b[A>>3]+ +b[o>>3])}while(!f);if((de|0)==14){de=0,i=0,A=m;do U=+b[A+8>>3],ne=A+16|0,Ee=t[ne>>2]|0,Ee=(Ee|0)==0?m:Ee,$=+b[Ee+8>>3],i=i+(+b[A>>3]+ +b[Ee>>3])*(($<0?$+6.283185307179586:$)-(U<0?U+6.283185307179586:U)),A=t[((A|0)==0?n:ne)>>2]|0;while((A|0)!=0)}i>0?(t[ve+(HA<<2)>>2]=n,HA=HA+1|0,o=BA,A=M):de=19}else de=19;if((de|0)==19){de=0;do if(r){if(A=r+8|0,t[A>>2]|0){de=21;break A}if(r=Qt(1,12)|0,!r){de=23;break A}t[A>>2]=r,o=r+4|0,s=r,A=M}else if(M){o=zA,s=M+8|0,A=n,r=e;break}else if(t[e>>2]|0){de=27;break A}else{o=zA,s=e,A=n,r=e;break}while(!1);if(t[s>>2]=n,t[o>>2]=n,s=SA+(BA<<5)|0,f=t[n>>2]|0,f){for(m=SA+(BA<<5)+8|0,b[m>>3]=17976931348623157e292,M=SA+(BA<<5)+24|0,b[M>>3]=17976931348623157e292,b[s>>3]=-17976931348623157e292,j=SA+(BA<<5)+16|0,b[j>>3]=-17976931348623157e292,nA=17976931348623157e292,q=-17976931348623157e292,o=0,I=f,a=17976931348623157e292,G=17976931348623157e292,W=-17976931348623157e292,l=-17976931348623157e292;i=+b[I>>3],U=+b[I+8>>3],I=t[I+16>>2]|0,L=(I|0)==0,$=+b[(L?f:I)+8>>3],i>3]=i,a=i),U>3]=U,G=U),i>W?b[s>>3]=i:i=W,U>l&&(b[j>>3]=U,l=U),nA=U>0&Uq?U:q,o=o|+$A(+(U-$))>3.141592653589793,!L;)W=i;o&&(b[j>>3]=q,b[M>>3]=nA)}else t[s>>2]=0,t[s+4>>2]=0,t[s+8>>2]=0,t[s+12>>2]=0,t[s+16>>2]=0,t[s+20>>2]=0,t[s+24>>2]=0,t[s+28>>2]=0;o=BA+1|0}if(ne=n+8|0,n=t[ne>>2]|0,t[ne>>2]=0,n)BA=o,M=A;else{de=45;break}}if((de|0)==21)OA(27213,27235,35,27247);else if((de|0)==23)OA(27267,27235,37,27247);else if((de|0)==27)OA(27310,27235,61,27333);else if((de|0)==45){A:do if((HA|0)>0){for(ne=(o|0)==0,he=o<<2,Ee=(e|0)==0,fe=0,A=0;;){if(QA=t[ve+(fe<<2)>>2]|0,ne)de=73;else{if(BA=p0(he)|0,!BA){de=50;break}if(zA=p0(he)|0,!zA){de=52;break}e:do if(Ee)r=0;else{for(o=0,r=0,s=e;n=SA+(o<<5)|0,Jo(t[s>>2]|0,n,t[QA>>2]|0)|0?(t[BA+(r<<2)>>2]=s,t[zA+(r<<2)>>2]=n,L=r+1|0):L=r,s=t[s+8>>2]|0,s;)o=o+1|0,r=L;if((L|0)>0)if(n=t[BA>>2]|0,(L|0)==1)r=n;else for(j=0,I=-1,r=n,M=n;;){for(f=t[M>>2]|0,n=0,s=0;o=t[t[BA+(s<<2)>>2]>>2]|0,(o|0)==(f|0)?m=n:m=n+((Jo(o,t[zA+(s<<2)>>2]|0,t[f>>2]|0)|0)&1)|0,s=s+1|0,(s|0)!=(L|0);)n=m;if(o=(m|0)>(I|0),r=o?M:r,n=j+1|0,(n|0)==(L|0))break e;j=n,I=o?m:I,M=t[BA+(n<<2)>>2]|0}else r=0}while(!1);if(qA(BA),qA(zA),r){if(o=r+4|0,n=t[o>>2]|0,n)r=n+8|0;else if(t[r>>2]|0){de=70;break}t[r>>2]=QA,t[o>>2]=QA}else de=73}if((de|0)==73){if(de=0,A=t[QA>>2]|0,A|0)do zA=A,A=t[A+16>>2]|0,qA(zA);while((A|0)!=0);qA(QA),A=1}if(fe=fe+1|0,(fe|0)>=(HA|0)){Ve=A;break A}}(de|0)==50?OA(27452,27235,249,27471):(de|0)==52?OA(27490,27235,252,27471):(de|0)==70&&OA(27310,27235,61,27333)}else Ve=0;while(!1);return qA(ve),qA(SA),de=Ve,de|0}return 0}function Jo(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0;if(!(a0(A,r)|0)||(A=Ft(A)|0,n=+b[r>>3],o=+b[r+8>>3],o=A&o<0?o+6.283185307179586:o,e=t[e>>2]|0,!e))return e=0,e|0;if(A){A=0,f=o,r=e;A:for(;;){for(;s=+b[r>>3],o=+b[r+8>>3],r=r+16|0,m=t[r>>2]|0,m=(m|0)==0?e:m,i=+b[m>>3],l=+b[m+8>>3],s>i?(a=s,s=l):(a=i,i=s,s=o,o=l),n=n==i|n==a?n+2220446049250313e-31:n,!!(na);)if(r=t[r>>2]|0,!r){r=22;break A}if(l=s<0?s+6.283185307179586:s,s=o<0?o+6.283185307179586:o,f=l==f|s==f?f+-2220446049250313e-31:f,a=l+(s-l)*((n-i)/(a-i)),(a<0?a+6.283185307179586:a)>f&&(A=A^1),r=t[r>>2]|0,!r){r=22;break}}if((r|0)==22)return A|0}else{A=0,f=o,r=e;A:for(;;){for(;s=+b[r>>3],o=+b[r+8>>3],r=r+16|0,m=t[r>>2]|0,m=(m|0)==0?e:m,i=+b[m>>3],l=+b[m+8>>3],s>i?(a=s,s=l):(a=i,i=s,s=o,o=l),n=n==i|n==a?n+2220446049250313e-31:n,!!(na);)if(r=t[r>>2]|0,!r){r=22;break A}if(f=s==f|o==f?f+-2220446049250313e-31:f,s+(o-s)*((n-i)/(a-i))>f&&(A=A^1),r=t[r>>2]|0,!r){r=22;break}}if((r|0)==22)return A|0}return 0}function D0(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0;if(q=k,k=k+32|0,nA=q+16|0,W=q,i=wA(e|0,A|0,52)|0,S()|0,i=i&15,I=wA(r|0,n|0,52)|0,S()|0,(i|0)!=(I&15|0))return nA=12,k=q,nA|0;if(f=wA(e|0,A|0,45)|0,S()|0,f=f&127,m=wA(r|0,n|0,45)|0,S()|0,m=m&127,f>>>0>121|m>>>0>121)return nA=5,k=q,nA|0;if(I=(f|0)!=(m|0),I){if(l=or(f,m)|0,(l|0)==7)return nA=1,k=q,nA|0;a=or(m,f)|0,(a|0)==7?OA(27514,27538,161,27548):(L=l,s=a)}else L=0,s=0;M=Re(f)|0,j=Re(m)|0,t[nA>>2]=0,t[nA+4>>2]=0,t[nA+8>>2]=0,t[nA+12>>2]=0;do if(L){if(m=t[4272+(f*28|0)+(L<<2)>>2]|0,l=(m|0)>0,j)if(l){f=0,a=r,l=n;do a=al(a,l)|0,l=S()|0,s=Ut(s)|0,(s|0)==1&&(s=Ut(1)|0),f=f+1|0;while((f|0)!=(m|0));m=s,f=a,a=l}else m=s,f=r,a=n;else if(l){f=0,a=r,l=n;do a=Zn(a,l)|0,l=S()|0,s=Ut(s)|0,f=f+1|0;while((f|0)!=(m|0));m=s,f=a,a=l}else m=s,f=r,a=n;if(qn(f,a,nA)|0,I||OA(27563,27538,191,27548),l=(M|0)!=0,s=(j|0)!=0,l&s&&OA(27590,27538,192,27548),l){if(s=Pt(e,A)|0,(s|0)==7){i=5;break}if(xA[22e3+(s*7|0)+L>>0]|0){i=1;break}a=t[21168+(s*28|0)+(L<<2)>>2]|0,f=a}else if(s){if(s=Pt(f,a)|0,(s|0)==7){i=5;break}if(xA[22e3+(s*7|0)+m>>0]|0){i=1;break}f=0,a=t[21168+(m*28|0)+(s<<2)>>2]|0}else f=0,a=0;if((f|a|0)<0)i=5;else{if((a|0)>0){l=nA+4|0,s=0;do B0(l),s=s+1|0;while((s|0)!=(a|0))}if(t[W>>2]=0,t[W+4>>2]=0,t[W+8>>2]=0,gn(W,L),i|0)for(;Jt(i)|0?br(W):Ht(W),(i|0)>1;)i=i+-1|0;if((f|0)>0){i=0;do B0(W),i=i+1|0;while((i|0)!=(f|0))}G=nA+4|0,Ze(G,W,G),Me(G),G=51}}else if(qn(r,n,nA)|0,(M|0)!=0&(j|0)!=0)if((m|0)!=(f|0)&&OA(27621,27538,261,27548),s=Pt(e,A)|0,i=Pt(r,n)|0,(s|0)==7|(i|0)==7)i=5;else if(xA[22e3+(s*7|0)+i>>0]|0)i=1;else if(s=t[21168+(s*28|0)+(i<<2)>>2]|0,(s|0)>0){l=nA+4|0,i=0;do B0(l),i=i+1|0;while((i|0)!=(s|0));G=51}else G=51;else G=51;while(!1);return(G|0)==51&&(i=nA+4|0,t[o>>2]=t[i>>2],t[o+4>>2]=t[i+4>>2],t[o+8>>2]=t[i+8>>2],i=0),nA=i,k=q,nA|0}function Xo(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0,$=0;if(G=k,k=k+48|0,f=G+36|0,s=G+24|0,l=G+12|0,a=G,o=wA(e|0,A|0,52)|0,S()|0,o=o&15,j=wA(e|0,A|0,45)|0,S()|0,j=j&127,j>>>0>121)return n=5,k=G,n|0;if(m=Re(j)|0,EA(o|0,0,52)|0,W=S()|0|134225919,i=n,t[i>>2]=-1,t[i+4>>2]=W,!o)return o=St(r)|0,(o|0)==7||(o=nr(j,o)|0,(o|0)==127)?(W=1,k=G,W|0):(I=EA(o|0,0,45)|0,L=S()|0,j=n,L=t[j+4>>2]&-1040385|L,W=n,t[W>>2]=t[j>>2]|I,t[W+4>>2]=L,W=0,k=G,W|0);for(t[f>>2]=t[r>>2],t[f+4>>2]=t[r+4>>2],t[f+8>>2]=t[r+8>>2],r=o;;){if(i=r,r=r+-1|0,t[s>>2]=t[f>>2],t[s+4>>2]=t[f+4>>2],t[s+8>>2]=t[f+8>>2],Jt(i)|0){if(o=wr(f)|0,o|0){r=13;break}t[l>>2]=t[f>>2],t[l+4>>2]=t[f+4>>2],t[l+8>>2]=t[f+8>>2],br(l)}else{if(o=mn(f)|0,o|0){r=13;break}t[l>>2]=t[f>>2],t[l+4>>2]=t[f+4>>2],t[l+8>>2]=t[f+8>>2],Ht(l)}if(yt(s,l,a),Me(a),o=n,q=t[o>>2]|0,o=t[o+4>>2]|0,$=(15-i|0)*3|0,nA=EA(7,0,$|0)|0,o=o&~(S()|0),$=EA(St(a)|0,0,$|0)|0,o=S()|0|o,W=n,t[W>>2]=$|q&~nA,t[W+4>>2]=o,(i|0)<=1){r=14;break}}A:do if((r|0)!=13&&(r|0)==14)if((t[f>>2]|0)<=1&&(t[f+4>>2]|0)<=1&&(t[f+8>>2]|0)<=1){r=St(f)|0,o=nr(j,r)|0,(o|0)==127?a=0:a=Re(o)|0;e:do if(r){if(m){if(o=Pt(e,A)|0,(o|0)==7){o=5;break A}if(i=t[21376+(o*28|0)+(r<<2)>>2]|0,(i|0)>0){o=r,r=0;do o=Gt(o)|0,r=r+1|0;while((r|0)!=(i|0))}else o=r;if((o|0)==1){o=9;break A}r=nr(j,o)|0,(r|0)==127&&OA(27648,27538,411,27678),Re(r)|0?OA(27693,27538,412,27678):(L=r,I=i,M=o)}else L=o,I=0,M=r;if(l=t[4272+(j*28|0)+(M<<2)>>2]|0,(l|0)<=-1&&OA(27724,27538,419,27678),!a){if((I|0)<0){o=5;break A}if(I|0){i=n,o=0,r=t[i>>2]|0,i=t[i+4>>2]|0;do r=lr(r,i)|0,i=S()|0,$=n,t[$>>2]=r,t[$+4>>2]=i,o=o+1|0;while((o|0)<(I|0))}if((l|0)<=0){o=L,r=58;break}for(i=n,o=0,r=t[i>>2]|0,i=t[i+4>>2]|0;;)if(r=lr(r,i)|0,i=S()|0,$=n,t[$>>2]=r,t[$+4>>2]=i,o=o+1|0,(o|0)==(l|0)){o=L,r=58;break e}}if(s=or(L,j)|0,(s|0)==7&&OA(27514,27538,428,27678),o=n,r=t[o>>2]|0,o=t[o+4>>2]|0,(l|0)>0){i=0;do r=lr(r,o)|0,o=S()|0,$=n,t[$>>2]=r,t[$+4>>2]=o,i=i+1|0;while((i|0)!=(l|0))}if(o=Pt(r,o)|0,(o|0)==7&&OA(27795,27538,440,27678),r=Et(L)|0,r=t[(r?21792:21584)+(s*28|0)+(o<<2)>>2]|0,(r|0)<0&&OA(27795,27538,454,27678),!r)o=L,r=58;else{s=n,o=0,i=t[s>>2]|0,s=t[s+4>>2]|0;do i=Kn(i,s)|0,s=S()|0,$=n,t[$>>2]=i,t[$+4>>2]=s,o=o+1|0;while((o|0)<(r|0));o=L,r=58}}else if((m|0)!=0&(a|0)!=0){if(r=Pt(e,A)|0,i=n,i=Pt(t[i>>2]|0,t[i+4>>2]|0)|0,(r|0)==7|(i|0)==7){o=5;break A}if(i=t[21376+(r*28|0)+(i<<2)>>2]|0,(i|0)<0){o=5;break A}if(!i)r=59;else{l=n,r=0,s=t[l>>2]|0,l=t[l+4>>2]|0;do s=lr(s,l)|0,l=S()|0,$=n,t[$>>2]=s,t[$+4>>2]=l,r=r+1|0;while((r|0)<(i|0));r=58}}else r=58;while(!1);if((r|0)==58&&a&&(r=59),(r|0)==59&&($=n,(Pt(t[$>>2]|0,t[$+4>>2]|0)|0)==1)){o=9;break}$=n,nA=t[$>>2]|0,$=t[$+4>>2]&-1040385,q=EA(o|0,0,45)|0,$=$|(S()|0),o=n,t[o>>2]=nA|q,t[o+4>>2]=$,o=0}else o=1;while(!1);return $=o,k=G,$|0}function _l(e,A,r,n,o,i){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0,i=i|0;var s=0,l=0;return l=k,k=k+16|0,s=l,o?e=15:(e=D0(e,A,r,n,s)|0,e||($r(s,i),e=0)),k=l,e|0}function Tl(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0;return s=k,k=k+16|0,i=s,n?r=15:(r=Mt(r,i)|0,r||(r=Xo(e,A,i,o)|0)),k=s,r|0}function Rl(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0,a=0;return a=k,k=k+32|0,s=a+12|0,l=a,i=D0(e,A,e,A,s)|0,i|0?(l=i,k=a,l|0):(e=D0(e,A,r,n,l)|0,e|0?(l=e,k=a,l|0):(s=Er(s,l)|0,l=o,t[l>>2]=s,t[l+4>>2]=((s|0)<0)<<31>>31,l=0,k=a,l|0))}function jl(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0,a=0;return a=k,k=k+32|0,s=a+12|0,l=a,i=D0(e,A,e,A,s)|0,!i&&(i=D0(e,A,r,n,l)|0,!i)?(n=Er(s,l)|0,n=KA(n|0,((n|0)<0)<<31>>31|0,1,0)|0,s=S()|0,l=o,t[l>>2]=n,t[l+4>>2]=s,l=0,k=a,l|0):(l=i,k=a,l|0)}function Il(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0,$=0,U=0,BA=0,zA=0,QA=0,fe=0;if(QA=k,k=k+48|0,BA=QA+24|0,s=QA+12|0,zA=QA,i=D0(e,A,e,A,BA)|0,!i&&(i=D0(e,A,r,n,s)|0,!i)){$=Er(BA,s)|0,U=(($|0)<0)<<31>>31,t[BA>>2]=0,t[BA+4>>2]=0,t[BA+8>>2]=0,t[s>>2]=0,t[s+4>>2]=0,t[s+8>>2]=0,D0(e,A,e,A,BA)|0&&OA(27795,27538,692,27747),D0(e,A,r,n,s)|0&&OA(27795,27538,697,27747),qr(BA),qr(s),m=($|0)==0?0:1/+($|0),r=t[BA>>2]|0,G=m*+((t[s>>2]|0)-r|0),W=BA+4|0,n=t[W>>2]|0,nA=m*+((t[s+4>>2]|0)-n|0),q=BA+8|0,i=t[q>>2]|0,m=m*+((t[s+8>>2]|0)-i|0),t[zA>>2]=r,M=zA+4|0,t[M>>2]=n,j=zA+8|0,t[j>>2]=i;A:do if(($|0)<0)i=0;else for(I=0,L=0;;){a=+(L>>>0)+4294967296*+(I|0),fe=G*a+ +(r|0),l=nA*a+ +(n|0),a=m*a+ +(i|0),r=~~+En(+fe),s=~~+En(+l),i=~~+En(+a),fe=+$A(+(+(r|0)-fe)),l=+$A(+(+(s|0)-l)),a=+$A(+(+(i|0)-a));do if(fe>l&fe>a)r=0-(s+i)|0,n=s;else if(f=0-r|0,l>a){n=f-i|0;break}else{n=s,i=f-s|0;break}while(!1);if(t[zA>>2]=r,t[M>>2]=n,t[j>>2]=i,Jr(zA),i=Xo(e,A,zA,o+(L<<3)|0)|0,i|0)break A;if(!((I|0)<(U|0)|(I|0)==(U|0)&L>>>0<$>>>0)){i=0;break A}r=KA(L|0,I|0,1,0)|0,n=S()|0,I=n,L=r,r=t[BA>>2]|0,n=t[W>>2]|0,i=t[q>>2]|0}while(!1);return zA=i,k=QA,zA|0}return zA=i,k=QA,zA|0}function U0(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0;if((r|0)==0&(n|0)==0)return o=0,i=1,YA(o|0),i|0;i=e,o=A,e=1,A=0;do s=(r&1|0)==0&!0,e=ft((s?1:i)|0,(s?0:o)|0,e|0,A|0)|0,A=S()|0,r=fi(r|0,n|0,1)|0,n=S()|0,i=ft(i|0,o|0,i|0,o|0)|0,o=S()|0;while(!((r|0)==0&(n|0)==0));return YA(A|0),e|0}function to(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0;l=k,k=k+16|0,i=l,s=wA(e|0,A|0,52)|0,S()|0,s=s&15;do if(s){if(o=ar(e,A,i)|0,!o){f=+b[i>>3],a=1/+_e(+f),m=+b[25968+(s<<3)>>3],b[r>>3]=f+m,b[r+8>>3]=f-m,f=+b[i+8>>3],a=m*a,b[r+16>>3]=a+f,b[r+24>>3]=f-a;break}return s=o,k=l,s|0}else{if(o=wA(e|0,A|0,45)|0,S()|0,o=o&127,o>>>0>121)return s=5,k=l,s|0;i=22064+(o<<5)|0,t[r>>2]=t[i>>2],t[r+4>>2]=t[i+4>>2],t[r+8>>2]=t[i+8>>2],t[r+12>>2]=t[i+12>>2],t[r+16>>2]=t[i+16>>2],t[r+20>>2]=t[i+20>>2],t[r+24>>2]=t[i+24>>2],t[r+28>>2]=t[i+28>>2];break}while(!1);return VA(r,n?1.4:1.1),n=26096+(s<<3)|0,(t[n>>2]|0)==(e|0)&&(t[n+4>>2]|0)==(A|0)&&(b[r>>3]=1.5707963267948966),s=26224+(s<<3)|0,(t[s>>2]|0)==(e|0)&&(t[s+4>>2]|0)==(A|0)&&(b[r+8>>3]=-1.5707963267948966),+b[r>>3]!=1.5707963267948966&&+b[r+8>>3]!=-1.5707963267948966?(s=0,k=l,s|0):(b[r+16>>3]=3.141592653589793,b[r+24>>3]=-3.141592653589793,s=0,k=l,s|0)}function Ll(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0;f=k,k=k+48|0,s=f+32|0,i=f+40|0,l=f,Dt(s,0,0,0),a=t[s>>2]|0,s=t[s+4>>2]|0;do if(r>>>0<=15){if(o=on(n)|0,o|0){n=l,t[n>>2]=0,t[n+4>>2]=0,t[l+8>>2]=o,t[l+12>>2]=-1,n=l+16|0,a=l+29|0,t[n>>2]=0,t[n+4>>2]=0,t[n+8>>2]=0,xA[n+12>>0]=0,xA[a>>0]=xA[i>>0]|0,xA[a+1>>0]=xA[i+1>>0]|0,xA[a+2>>0]=xA[i+2>>0]|0;break}if(o=Qt((t[A+8>>2]|0)+1|0,32)|0,o){ro(A,o),m=l,t[m>>2]=a,t[m+4>>2]=s,t[l+8>>2]=0,t[l+12>>2]=r,t[l+16>>2]=n,t[l+20>>2]=A,t[l+24>>2]=o,xA[l+28>>0]=0,a=l+29|0,xA[a>>0]=xA[i>>0]|0,xA[a+1>>0]=xA[i+1>>0]|0,xA[a+2>>0]=xA[i+2>>0]|0;break}else{n=l,t[n>>2]=0,t[n+4>>2]=0,t[l+8>>2]=13,t[l+12>>2]=-1,n=l+16|0,a=l+29|0,t[n>>2]=0,t[n+4>>2]=0,t[n+8>>2]=0,xA[n+12>>0]=0,xA[a>>0]=xA[i>>0]|0,xA[a+1>>0]=xA[i+1>>0]|0,xA[a+2>>0]=xA[i+2>>0]|0;break}}else a=l,t[a>>2]=0,t[a+4>>2]=0,t[l+8>>2]=4,t[l+12>>2]=-1,a=l+16|0,m=l+29|0,t[a>>2]=0,t[a+4>>2]=0,t[a+8>>2]=0,xA[a+12>>0]=0,xA[m>>0]=xA[i>>0]|0,xA[m+1>>0]=xA[i+1>>0]|0,xA[m+2>>0]=xA[i+2>>0]|0;while(!1);kn(l),t[e>>2]=t[l>>2],t[e+4>>2]=t[l+4>>2],t[e+8>>2]=t[l+8>>2],t[e+12>>2]=t[l+12>>2],t[e+16>>2]=t[l+16>>2],t[e+20>>2]=t[l+20>>2],t[e+24>>2]=t[l+24>>2],t[e+28>>2]=t[l+28>>2],k=f}function kn(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0,$=0,U=0;if(U=k,k=k+336|0,I=U+168|0,L=U,n=e,r=t[n>>2]|0,n=t[n+4>>2]|0,(r|0)==0&(n|0)==0){k=U;return}if(A=e+28|0,xA[A>>0]|0?(r=Ai(r,n)|0,n=S()|0):xA[A>>0]=1,$=e+20|0,!(t[t[$>>2]>>2]|0)){A=e+24|0,r=t[A>>2]|0,r|0&&qA(r),q=e,t[q>>2]=0,t[q+4>>2]=0,t[e+8>>2]=0,t[$>>2]=0,t[e+12>>2]=-1,t[e+16>>2]=0,t[A>>2]=0,k=U;return}q=e+16|0,A=t[q>>2]|0,o=A&15;A:do if((r|0)==0&(n|0)==0)nA=e+24|0;else{G=e+12|0,M=(o|0)==3,m=A&255,a=(o|1|0)==3,j=e+24|0,f=(o+-1|0)>>>0<3,s=(o|2|0)==3,l=L+8|0;e:for(;;){if(i=wA(r|0,n|0,52)|0,S()|0,i=i&15,(i|0)==(t[G>>2]|0)){switch(m&15){case 0:case 2:case 3:{if(o=ar(r,n,I)|0,o|0){W=15;break e}if(no(t[$>>2]|0,t[j>>2]|0,I)|0){W=19;break e}break}}if(a&&(o=t[(t[$>>2]|0)+4>>2]|0,t[I>>2]=t[o>>2],t[I+4>>2]=t[o+4>>2],t[I+8>>2]=t[o+8>>2],t[I+12>>2]=t[o+12>>2],a0(26832,I)|0)){if($n(t[(t[$>>2]|0)+4>>2]|0,i,L)|0){W=25;break}if(o=L,(t[o>>2]|0)==(r|0)&&(t[o+4>>2]|0)==(n|0)){W=29;break}}if(f){if(o=_r(r,n,I)|0,o|0){W=32;break}if(to(r,n,L,0)|0){W=36;break}if(s&&ti(t[$>>2]|0,t[j>>2]|0,I,L)|0){W=42;break}if(a&&ri(t[$>>2]|0,t[j>>2]|0,I,L)|0){W=42;break}}if(M){if(A=to(r,n,I,1)|0,o=t[j>>2]|0,A|0){W=45;break}if(Ne(o,I)|0){if(lA(L,I),z(I,t[j>>2]|0)|0){W=53;break}if(no(t[$>>2]|0,t[j>>2]|0,l)|0){W=53;break}if(ri(t[$>>2]|0,t[j>>2]|0,L,I)|0){W=53;break}}}}do if((i|0)<(t[G>>2]|0)){if(A=to(r,n,I,1)|0,o=t[j>>2]|0,A|0){W=58;break e}if(!(Ne(o,I)|0)){W=73;break}if(z(t[j>>2]|0,I)|0&&(lA(L,I),ti(t[$>>2]|0,t[j>>2]|0,L,I)|0)){W=65;break e}if(r=Wo(r,n,i+1|0,L)|0,r|0){W=67;break e}n=L,r=t[n>>2]|0,n=t[n+4>>2]|0}else W=73;while(!1);if((W|0)==73&&(W=0,r=Ai(r,n)|0,n=S()|0),(r|0)==0&(n|0)==0){nA=j;break A}}switch(W|0){case 15:{A=t[j>>2]|0,A|0&&qA(A),W=e,t[W>>2]=0,t[W+4>>2]=0,t[$>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[j>>2]=0,t[e+8>>2]=o,W=20;break}case 19:{t[e>>2]=r,t[e+4>>2]=n,W=20;break}case 25:{OA(27795,27761,470,27772);break}case 29:{t[e>>2]=r,t[e+4>>2]=n,k=U;return}case 32:{A=t[j>>2]|0,A|0&&qA(A),nA=e,t[nA>>2]=0,t[nA+4>>2]=0,t[$>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[j>>2]=0,t[e+8>>2]=o,k=U;return}case 36:{OA(27795,27761,493,27772);break}case 42:{t[e>>2]=r,t[e+4>>2]=n,k=U;return}case 45:{o|0&&qA(o),W=e,t[W>>2]=0,t[W+4>>2]=0,t[$>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[j>>2]=0,t[e+8>>2]=A,W=55;break}case 53:{t[e>>2]=r,t[e+4>>2]=n,W=55;break}case 58:{o|0&&qA(o),W=e,t[W>>2]=0,t[W+4>>2]=0,t[$>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[j>>2]=0,t[e+8>>2]=A,W=71;break}case 65:{t[e>>2]=r,t[e+4>>2]=n,W=71;break}case 67:{A=t[j>>2]|0,A|0&&qA(A),nA=e,t[nA>>2]=0,t[nA+4>>2]=0,t[$>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[j>>2]=0,t[e+8>>2]=r,k=U;return}}if((W|0)==20){k=U;return}else if((W|0)==55){k=U;return}else if((W|0)==71){k=U;return}}while(!1);A=t[nA>>2]|0,A|0&&qA(A),W=e,t[W>>2]=0,t[W+4>>2]=0,t[e+8>>2]=0,t[$>>2]=0,t[e+12>>2]=-1,t[q>>2]=0,t[nA>>2]=0,k=U}function Ai(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0;M=k,k=k+16|0,m=M,n=wA(e|0,A|0,52)|0,S()|0,n=n&15,r=wA(e|0,A|0,45)|0,S()|0;do if(n){for(;r=EA(n+4095|0,0,52)|0,o=S()|0|A&-15728641,i=(15-n|0)*3|0,s=EA(7,0,i|0)|0,l=S()|0,r=r|e|s,o=o|l,a=wA(e|0,A|0,i|0)|0,S()|0,a=a&7,n=n+-1|0,!(a>>>0<6);)if(n)A=o,e=r;else{f=4;break}if((f|0)==4){r=wA(r|0,o|0,45)|0,S()|0;break}return m=(a|0)==0&(Oe(r,o)|0)!=0,m=EA((m?2:1)+a|0,0,i|0)|0,f=S()|0|A&~l,m=m|e&~s,YA(f|0),k=M,m|0}while(!1);return r=r&127,r>>>0>120?(f=0,m=0,YA(f|0),k=M,m|0):(Dt(m,0,r+1|0,0),f=t[m+4>>2]|0,m=t[m>>2]|0,YA(f|0),k=M,m|0)}function Nl(e,A,r,n,o,i){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0,i=i|0;var s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0;W=k,k=k+160|0,M=W+80|0,l=W+64|0,j=W+112|0,G=W,Ll(M,e,A,r),f=M,Xn(l,t[f>>2]|0,t[f+4>>2]|0,A),f=l,a=t[f>>2]|0,f=t[f+4>>2]|0,s=t[M+8>>2]|0,I=j+4|0,t[I>>2]=t[M>>2],t[I+4>>2]=t[M+4>>2],t[I+8>>2]=t[M+8>>2],t[I+12>>2]=t[M+12>>2],t[I+16>>2]=t[M+16>>2],t[I+20>>2]=t[M+20>>2],t[I+24>>2]=t[M+24>>2],t[I+28>>2]=t[M+28>>2],I=G,t[I>>2]=a,t[I+4>>2]=f,I=G+8|0,t[I>>2]=s,e=G+12|0,A=j,r=e+36|0;do t[e>>2]=t[A>>2],e=e+4|0,A=A+4|0;while((e|0)<(r|0));if(j=G+48|0,t[j>>2]=t[l>>2],t[j+4>>2]=t[l+4>>2],t[j+8>>2]=t[l+8>>2],t[j+12>>2]=t[l+12>>2],(a|0)==0&(f|0)==0)return G=s,k=W,G|0;r=G+16|0,m=G+24|0,M=G+28|0,s=0,l=0,A=a,e=f;do{if(!((s|0)<(o|0)|(s|0)==(o|0)&l>>>0>>0)){L=4;break}if(f=l,l=KA(l|0,s|0,1,0)|0,s=S()|0,f=i+(f<<3)|0,t[f>>2]=A,t[f+4>>2]=e,Ao(j),e=j,A=t[e>>2]|0,e=t[e+4>>2]|0,(A|0)==0&(e|0)==0){if(kn(r),A=r,e=t[A>>2]|0,A=t[A+4>>2]|0,(e|0)==0&(A|0)==0){L=10;break}Ko(e,A,t[M>>2]|0,j),e=j,A=t[e>>2]|0,e=t[e+4>>2]|0}f=G,t[f>>2]=A,t[f+4>>2]=e}while(!((A|0)==0&(e|0)==0));return(L|0)==4?(e=G+40|0,A=t[e>>2]|0,A|0&&qA(A),L=G+16|0,t[L>>2]=0,t[L+4>>2]=0,t[m>>2]=0,t[G+36>>2]=0,t[M>>2]=-1,t[G+32>>2]=0,t[e>>2]=0,Ko(0,0,0,j),t[G>>2]=0,t[G+4>>2]=0,t[I>>2]=0,G=14,k=W,G|0):((L|0)==10&&(t[G>>2]=0,t[G+4>>2]=0,t[I>>2]=t[m>>2]),G=t[I>>2]|0,k=W,G|0)}function Fl(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0;if(M=k,k=k+48|0,a=M+32|0,l=M+40|0,f=M,!(t[e>>2]|0))return m=n,t[m>>2]=0,t[m+4>>2]=0,m=0,k=M,m|0;Dt(a,0,0,0),s=a,o=t[s>>2]|0,s=t[s+4>>2]|0;do if(A>>>0>15)m=f,t[m>>2]=0,t[m+4>>2]=0,t[f+8>>2]=4,t[f+12>>2]=-1,m=f+16|0,r=f+29|0,t[m>>2]=0,t[m+4>>2]=0,t[m+8>>2]=0,xA[m+12>>0]=0,xA[r>>0]=xA[l>>0]|0,xA[r+1>>0]=xA[l+1>>0]|0,xA[r+2>>0]=xA[l+2>>0]|0,r=4,m=9;else{if(r=on(r)|0,r|0){a=f,t[a>>2]=0,t[a+4>>2]=0,t[f+8>>2]=r,t[f+12>>2]=-1,a=f+16|0,m=f+29|0,t[a>>2]=0,t[a+4>>2]=0,t[a+8>>2]=0,xA[a+12>>0]=0,xA[m>>0]=xA[l>>0]|0,xA[m+1>>0]=xA[l+1>>0]|0,xA[m+2>>0]=xA[l+2>>0]|0,m=9;break}if(r=Qt((t[e+8>>2]|0)+1|0,32)|0,!r){m=f,t[m>>2]=0,t[m+4>>2]=0,t[f+8>>2]=13,t[f+12>>2]=-1,m=f+16|0,r=f+29|0,t[m>>2]=0,t[m+4>>2]=0,t[m+8>>2]=0,xA[m+12>>0]=0,xA[r>>0]=xA[l>>0]|0,xA[r+1>>0]=xA[l+1>>0]|0,xA[r+2>>0]=xA[l+2>>0]|0,r=13,m=9;break}ro(e,r),I=f,t[I>>2]=o,t[I+4>>2]=s,s=f+8|0,t[s>>2]=0,t[f+12>>2]=A,t[f+20>>2]=e,t[f+24>>2]=r,xA[f+28>>0]=0,o=f+29|0,xA[o>>0]=xA[l>>0]|0,xA[o+1>>0]=xA[l+1>>0]|0,xA[o+2>>0]=xA[l+2>>0]|0,t[f+16>>2]=3,j=+ir(r),j=j*+Yr(r),i=+$A(+ +b[r>>3]),i=j/+_e(+ +Cn(+i,+ +$A(+ +b[r+8>>3])))*6371.007180918475*6371.007180918475,o=f+12|0,r=t[o>>2]|0;A:do if((r|0)>0)do{if(Zo(r+-1|0,a)|0,!(i/+b[a>>3]>10))break A;I=t[o>>2]|0,r=I+-1|0,t[o>>2]=r}while((I|0)>1);while(!1);if(kn(f),o=n,t[o>>2]=0,t[o+4>>2]=0,o=f,r=t[o>>2]|0,o=t[o+4>>2]|0,!((r|0)==0&(o|0)==0))do g0(r,o,A,a)|0,l=a,e=n,l=KA(t[e>>2]|0,t[e+4>>2]|0,t[l>>2]|0,t[l+4>>2]|0)|0,e=S()|0,I=n,t[I>>2]=l,t[I+4>>2]=e,kn(f),I=f,r=t[I>>2]|0,o=t[I+4>>2]|0;while(!((r|0)==0&(o|0)==0));r=t[s>>2]|0}while(!1);return I=r,k=M,I|0}function nn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0;if(!(a0(A,r)|0)||(A=Ft(A)|0,n=+b[r>>3],o=+b[r+8>>3],o=A&o<0?o+6.283185307179586:o,j=t[e>>2]|0,(j|0)<=0))return j=0,j|0;if(M=t[e+4>>2]|0,A){A=0,m=o,r=-1,e=0;A:for(;;){for(f=e;s=+b[M+(f<<4)>>3],o=+b[M+(f<<4)+8>>3],e=(r+2|0)%(j|0)|0,i=+b[M+(e<<4)>>3],l=+b[M+(e<<4)+8>>3],s>i?(a=s,s=l):(a=i,i=s,s=o,o=l),n=n==i|n==a?n+2220446049250313e-31:n,!!(na);)if(r=f+1|0,(r|0)>=(j|0)){r=22;break A}else e=f,f=r,r=e;if(l=s<0?s+6.283185307179586:s,s=o<0?o+6.283185307179586:o,m=l==m|s==m?m+-2220446049250313e-31:m,a=l+(s-l)*((n-i)/(a-i)),(a<0?a+6.283185307179586:a)>m&&(A=A^1),e=f+1|0,(e|0)>=(j|0)){r=22;break}else r=f}if((r|0)==22)return A|0}else{A=0,m=o,r=-1,e=0;A:for(;;){for(f=e;s=+b[M+(f<<4)>>3],o=+b[M+(f<<4)+8>>3],e=(r+2|0)%(j|0)|0,i=+b[M+(e<<4)>>3],l=+b[M+(e<<4)+8>>3],s>i?(a=s,s=l):(a=i,i=s,s=o,o=l),n=n==i|n==a?n+2220446049250313e-31:n,!!(na);)if(r=f+1|0,(r|0)>=(j|0)){r=22;break A}else e=f,f=r,r=e;if(m=s==m|o==m?m+-2220446049250313e-31:m,s+(o-s)*((n-i)/(a-i))>m&&(A=A^1),e=f+1|0,(e|0)>=(j|0)){r=22;break}else r=f}if((r|0)==22)return A|0}return 0}function ei(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0;if(L=t[e>>2]|0,!L){t[A>>2]=0,t[A+4>>2]=0,t[A+8>>2]=0,t[A+12>>2]=0,t[A+16>>2]=0,t[A+20>>2]=0,t[A+24>>2]=0,t[A+28>>2]=0;return}if(G=A+8|0,b[G>>3]=17976931348623157e292,W=A+24|0,b[W>>3]=17976931348623157e292,b[A>>3]=-17976931348623157e292,nA=A+16|0,b[nA>>3]=-17976931348623157e292,!((L|0)<=0)){for(j=t[e+4>>2]|0,f=17976931348623157e292,m=-17976931348623157e292,M=0,e=-1,i=17976931348623157e292,s=17976931348623157e292,a=-17976931348623157e292,n=-17976931348623157e292,I=0;r=+b[j+(I<<4)>>3],l=+b[j+(I<<4)+8>>3],e=e+2|0,o=+b[j+(((e|0)==(L|0)?0:e)<<4)+8>>3],r>3]=r,i=r),l>3]=l,s=l),r>a?b[A>>3]=r:r=a,l>n&&(b[nA>>3]=l,n=l),f=l>0&lm?l:m,M=M|+$A(+(l-o))>3.141592653589793,e=I+1|0,(e|0)!=(L|0);)q=I,a=r,I=e,e=q;M&&(b[nA>>3]=m,b[W>>3]=f)}}function on(e){return e=e|0,(e>>>0<4?0:15)|0}function ro(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0,$=0,U=0,BA=0,zA=0,QA=0;if(L=t[e>>2]|0,L){if(G=A+8|0,b[G>>3]=17976931348623157e292,W=A+24|0,b[W>>3]=17976931348623157e292,b[A>>3]=-17976931348623157e292,nA=A+16|0,b[nA>>3]=-17976931348623157e292,(L|0)>0){for(o=t[e+4>>2]|0,j=17976931348623157e292,I=-17976931348623157e292,n=0,r=-1,a=17976931348623157e292,f=17976931348623157e292,M=-17976931348623157e292,s=-17976931348623157e292,q=0;i=+b[o+(q<<4)>>3],m=+b[o+(q<<4)+8>>3],zA=r+2|0,l=+b[o+(((zA|0)==(L|0)?0:zA)<<4)+8>>3],i>3]=i,a=i),m>3]=m,f=m),i>M?b[A>>3]=i:i=M,m>s&&(b[nA>>3]=m,s=m),j=m>0&mI?m:I,n=n|+$A(+(m-l))>3.141592653589793,r=q+1|0,(r|0)!=(L|0);)zA=q,M=i,q=r,r=zA;n&&(b[nA>>3]=I,b[W>>3]=j)}}else t[A>>2]=0,t[A+4>>2]=0,t[A+8>>2]=0,t[A+12>>2]=0,t[A+16>>2]=0,t[A+20>>2]=0,t[A+24>>2]=0,t[A+28>>2]=0;if(zA=e+8|0,r=t[zA>>2]|0,!((r|0)<=0)){BA=e+12|0,U=0;do if(o=t[BA>>2]|0,n=U,U=U+1|0,W=A+(U<<5)|0,nA=t[o+(n<<3)>>2]|0,nA){if(q=A+(U<<5)+8|0,b[q>>3]=17976931348623157e292,e=A+(U<<5)+24|0,b[e>>3]=17976931348623157e292,b[W>>3]=-17976931348623157e292,$=A+(U<<5)+16|0,b[$>>3]=-17976931348623157e292,(nA|0)>0){for(L=t[o+(n<<3)+4>>2]|0,j=17976931348623157e292,I=-17976931348623157e292,o=0,n=-1,G=0,a=17976931348623157e292,f=17976931348623157e292,m=-17976931348623157e292,s=-17976931348623157e292;i=+b[L+(G<<4)>>3],M=+b[L+(G<<4)+8>>3],n=n+2|0,l=+b[L+(((n|0)==(nA|0)?0:n)<<4)+8>>3],i>3]=i,a=i),M>3]=M,f=M),i>m?b[W>>3]=i:i=m,M>s&&(b[$>>3]=M,s=M),j=M>0&MI?M:I,o=o|+$A(+(M-l))>3.141592653589793,n=G+1|0,(n|0)!=(nA|0);)QA=G,G=n,m=i,n=QA;o&&(b[$>>3]=I,b[e>>3]=j)}}else t[W>>2]=0,t[W+4>>2]=0,t[W+8>>2]=0,t[W+12>>2]=0,t[W+16>>2]=0,t[W+20>>2]=0,t[W+24>>2]=0,t[W+28>>2]=0,r=t[zA>>2]|0;while((U|0)<(r|0))}}function no(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0;if(!(nn(e,A,r)|0))return o=0,o|0;if(o=e+8|0,(t[o>>2]|0)<=0)return o=1,o|0;for(n=e+12|0,e=0;;){if(i=e,e=e+1|0,nn((t[n>>2]|0)+(i<<3)|0,A+(e<<5)|0,r)|0){e=0,n=6;break}if((e|0)>=(t[o>>2]|0)){e=1,n=6;break}}return(n|0)==6?e|0:0}function ti(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0;if(f=k,k=k+16|0,l=f,s=r+8|0,!(nn(e,A,s)|0))return a=0,k=f,a|0;a=e+8|0;A:do if((t[a>>2]|0)>0){for(i=e+12|0,o=0;;){if(m=o,o=o+1|0,nn((t[i>>2]|0)+(m<<3)|0,A+(o<<5)|0,s)|0){o=0;break}if((o|0)>=(t[a>>2]|0))break A}return k=f,o|0}while(!1);if(bn(e,A,r,n)|0)return m=0,k=f,m|0;t[l>>2]=t[r>>2],t[l+4>>2]=s,o=t[a>>2]|0;A:do if((o|0)>0)for(e=e+12|0,s=0,i=o;;){if(o=t[e>>2]|0,(t[o+(s<<3)>>2]|0)>0){if(nn(l,n,t[o+(s<<3)+4>>2]|0)|0){o=0;break A}if(o=s+1|0,bn((t[e>>2]|0)+(s<<3)|0,A+(o<<5)|0,r,n)|0){o=0;break A}i=t[a>>2]|0}else o=s+1|0;if((o|0)<(i|0))s=o;else{o=1;break}}else o=1;while(!1);return m=o,k=f,m|0}function bn(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0,$=0,U=0,BA=0,zA=0,QA=0,fe=0;if(zA=k,k=k+176|0,q=zA+172|0,o=zA+168|0,$=zA,!(Ne(A,n)|0))return e=0,k=zA,e|0;if(M0(A,n,q,o),Ir($|0,r|0,168)|0,(t[r>>2]|0)>0){A=0;do QA=$+8+(A<<4)+8|0,nA=+Vt(+b[QA>>3],t[o>>2]|0),b[QA>>3]=nA,A=A+1|0;while((A|0)<(t[r>>2]|0))}G=+b[n>>3],W=+b[n+8>>3],nA=+Vt(+b[n+16>>3],t[o>>2]|0),I=+Vt(+b[n+24>>3],t[o>>2]|0);A:do if((t[e>>2]|0)>0){if(n=e+4|0,o=t[$>>2]|0,(o|0)<=0){for(A=0;;)if(A=A+1|0,(A|0)>=(t[e>>2]|0)){A=0;break A}}for(r=0;;){if(A=t[n>>2]|0,j=+b[A+(r<<4)>>3],L=+Vt(+b[A+(r<<4)+8>>3],t[q>>2]|0),A=t[n>>2]|0,r=r+1|0,QA=(r|0)%(t[e>>2]|0)|0,i=+b[A+(QA<<4)>>3],s=+Vt(+b[A+(QA<<4)+8>>3],t[q>>2]|0),!(j>=G)|!(i>=G)&&!(j<=W)|!(i<=W)&&!(L<=I)|!(s<=I)&&!(L>=nA)|!(s>=nA)){M=i-j,f=s-L,A=0;do if(fe=A,A=A+1|0,QA=(A|0)==(o|0)?0:A,i=+b[$+8+(fe<<4)+8>>3],s=+b[$+8+(QA<<4)+8>>3]-i,l=+b[$+8+(fe<<4)>>3],a=+b[$+8+(QA<<4)>>3]-l,m=M*s-f*a,m!=0&&(U=L-i,BA=j-l,a=(U*a-s*BA)/m,!(a<0|a>1))&&(m=(M*U-f*BA)/m,m>=0&m<=1)){A=1;break A}while((A|0)<(o|0))}if((r|0)>=(t[e>>2]|0)){A=0;break}}}else A=0;while(!1);return fe=A,k=zA,fe|0}function ri(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0;if(bn(e,A,r,n)|0)return i=1,i|0;if(i=e+8|0,(t[i>>2]|0)<=0)return i=0,i|0;for(o=e+12|0,e=0;;){if(s=e,e=e+1|0,bn((t[o>>2]|0)+(s<<3)|0,A+(e<<5)|0,r,n)|0){e=1,o=6;break}if((e|0)>=(t[i>>2]|0)){e=0,o=6;break}}return(o|0)==6?e|0:0}function Pl(){return 8}function Ql(){return 16}function Ol(){return 168}function zl(){return 8}function Hl(){return 16}function Gl(){return 12}function Ul(){return 8}function Vl(e){return e=e|0,+(+((t[e>>2]|0)>>>0)+4294967296*+(t[e+4>>2]|0))}function Wl(e){e=e|0;var A=0,r=0;return r=+b[e>>3],A=+b[e+8>>3],+ +ye(+(r*r+A*A))}function ni(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0;f=+b[e>>3],a=+b[A>>3]-f,l=+b[e+8>>3],s=+b[A+8>>3]-l,M=+b[r>>3],i=+b[n>>3]-M,j=+b[r+8>>3],m=+b[n+8>>3]-j,i=(i*(l-j)-(f-M)*m)/(a*m-s*i),b[o>>3]=f+a*i,b[o+8>>3]=l+s*i}function oi(e,A){return e=e|0,A=A|0,+$A(+(+b[e>>3]-+b[A>>3]))<11920928955078125e-23?(A=+$A(+(+b[e+8>>3]-+b[A+8>>3]))<11920928955078125e-23,A|0):(A=0,A|0)}function it(e,A){e=e|0,A=A|0;var r=0,n=0,o=0;return o=+b[e>>3]-+b[A>>3],n=+b[e+8>>3]-+b[A+8>>3],r=+b[e+16>>3]-+b[A+16>>3],+(o*o+n*n+r*r)}function Yl(e,A){e=e|0,A=A|0;var r=0,n=0,o=0;r=+b[e>>3],n=+_e(+r),r=+ie(+r),b[A+16>>3]=r,r=+b[e+8>>3],o=n*+_e(+r),b[A>>3]=o,r=n*+ie(+r),b[A+8>>3]=r}function Kl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0;if(i=k,k=k+16|0,o=i,n=Oe(e,A)|0,(r+-1|0)>>>0>5||(n=(n|0)!=0,(r|0)==1&n))return o=-1,k=i,o|0;do if(sn(e,A,o)|0)n=-1;else if(n){n=((t[26352+(r<<2)>>2]|0)+5-(t[o>>2]|0)|0)%5|0;break}else{n=((t[26384+(r<<2)>>2]|0)+6-(t[o>>2]|0)|0)%6|0;break}while(!1);return o=n,k=i,o|0}function sn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0;if(m=k,k=k+32|0,l=m+16|0,a=m,n=Dr(e,A,l)|0,n|0)return r=n,k=m,r|0;i=te(e,A)|0,f=Pt(e,A)|0,H0(i,a),n=qt(i,t[l>>2]|0)|0;do if(Re(i)|0){do switch(i|0){case 4:{o=0;break}case 14:{o=1;break}case 24:{o=2;break}case 38:{o=3;break}case 49:{o=4;break}case 58:{o=5;break}case 63:{o=6;break}case 72:{o=7;break}case 83:{o=8;break}case 97:{o=9;break}case 107:{o=10;break}case 117:{o=11;break}default:OA(27795,27797,75,27806)}while(!1);if(s=t[26416+(o*24|0)+8>>2]|0,A=t[26416+(o*24|0)+16>>2]|0,e=t[l>>2]|0,(e|0)!=(t[a>>2]|0)&&(a=Et(i)|0,e=t[l>>2]|0,a|(e|0)==(A|0)&&(n=(n+1|0)%6|0)),(f|0)==3&(e|0)==(A|0)){n=(n+5|0)%6|0;break}(f|0)==5&(e|0)==(s|0)&&(n=(n+1|0)%6|0)}while(!1);return t[r>>2]=n,r=0,k=m,r|0}function Xt(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0,$=0;if($=k,k=k+32|0,q=$+24|0,W=$+20|0,L=$+8|0,I=$+16|0,j=$,a=(Oe(e,A)|0)==0,a=a?6:5,m=wA(e|0,A|0,52)|0,S()|0,m=m&15,a>>>0<=r>>>0)return n=2,k=$,n|0;M=(m|0)==0,!M&&(G=EA(7,0,(m^15)*3|0)|0,(G&e|0)==0&((S()|0)&A|0)==0)?o=r:i=4;A:do if((i|0)==4){if(o=(Oe(e,A)|0)!=0,((o?4:5)|0)<(r|0)||sn(e,A,q)|0||(i=(t[q>>2]|0)+r|0,o?o=26704+(((i|0)%5|0)<<2)|0:o=26736+(((i|0)%6|0)<<2)|0,G=t[o>>2]|0,(G|0)==7))return n=1,k=$,n|0;t[W>>2]=0,o=Y(e,A,G,W,L)|0;do if(!o){if(l=L,f=t[l>>2]|0,l=t[l+4>>2]|0,s=l>>>0>>0|(l|0)==(A|0)&f>>>0>>0,i=s?f:e,s=s?l:A,!M&&(M=EA(7,0,(m^15)*3|0)|0,(f&M|0)==0&(l&(S()|0)|0)==0))o=r;else{if(l=(r+-1+a|0)%(a|0)|0,o=Oe(e,A)|0,(l|0)<0&&OA(27795,27797,248,27822),a=(o|0)!=0,((a?4:5)|0)<(l|0)&&OA(27795,27797,248,27822),sn(e,A,q)|0&&OA(27795,27797,248,27822),o=(t[q>>2]|0)+l|0,a?o=26704+(((o|0)%5|0)<<2)|0:o=26736+(((o|0)%6|0)<<2)|0,l=t[o>>2]|0,(l|0)==7&&OA(27795,27797,248,27822),t[I>>2]=0,o=Y(e,A,l,I,j)|0,o|0)break;f=j,a=t[f>>2]|0,f=t[f+4>>2]|0;do if(f>>>0>>0|(f|0)==(s|0)&a>>>0>>0){if(Oe(a,f)|0?i=Ae(a,f,e,A)|0:i=t[26800+((((t[I>>2]|0)+(t[26768+(l<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,o=Oe(a,f)|0,(i+-1|0)>>>0>5){o=-1,i=a,s=f;break}if(o=(o|0)!=0,(i|0)==1&o){o=-1,i=a,s=f;break}do if(sn(a,f,q)|0)o=-1;else if(o){o=((t[26352+(i<<2)>>2]|0)+5-(t[q>>2]|0)|0)%5|0;break}else{o=((t[26384+(i<<2)>>2]|0)+6-(t[q>>2]|0)|0)%6|0;break}while(!1);i=a,s=f}else o=r;while(!1);l=L,f=t[l>>2]|0,l=t[l+4>>2]|0}if((i|0)==(f|0)&(s|0)==(l|0)){if(a=(Oe(f,l)|0)!=0,a?e=Ae(f,l,e,A)|0:e=t[26800+((((t[W>>2]|0)+(t[26768+(G<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,o=Oe(f,l)|0,(e+-1|0)>>>0<=5&&(nA=(o|0)!=0,!((e|0)==1&nA)))do if(sn(f,l,q)|0)o=-1;else if(nA){o=((t[26352+(e<<2)>>2]|0)+5-(t[q>>2]|0)|0)%5|0;break}else{o=((t[26384+(e<<2)>>2]|0)+6-(t[q>>2]|0)|0)%6|0;break}while(!1);else o=-1;o=o+1|0,o=(o|0)==6|a&(o|0)==5?0:o}A=s,e=i;break A}while(!1);return n=o,k=$,n|0}while(!1);return nA=EA(o|0,0,56)|0,q=S()|0|A&-2130706433|536870912,t[n>>2]=nA|e,t[n+4>>2]=q,n=0,k=$,n|0}function Zl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0;return i=(Oe(e,A)|0)==0,n=Xt(e,A,0,r)|0,o=(n|0)==0,i?!o||(n=Xt(e,A,1,r+8|0)|0,n|0)||(n=Xt(e,A,2,r+16|0)|0,n|0)||(n=Xt(e,A,3,r+24|0)|0,n|0)||(n=Xt(e,A,4,r+32|0)|0,n)?(i=n,i|0):Xt(e,A,5,r+40|0)|0:!o||(n=Xt(e,A,1,r+8|0)|0,n|0)||(n=Xt(e,A,2,r+16|0)|0,n|0)||(n=Xt(e,A,3,r+24|0)|0,n|0)||(n=Xt(e,A,4,r+32|0)|0,n|0)?(i=n,i|0):(i=r+40|0,t[i>>2]=0,t[i+4>>2]=0,i=0,i|0)}function $l(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0,l=0,a=0;return a=k,k=k+192|0,o=a,i=a+168|0,s=wA(e|0,A|0,56)|0,S()|0,s=s&7,l=A&-2130706433|134217728,n=Dr(e,l,i)|0,n|0?(l=n,k=a,l|0):(A=wA(e|0,A|0,52)|0,S()|0,A=A&15,Oe(e,l)|0?w(i,A,s,1,o):AA(i,A,s,1,o),l=o+8|0,t[r>>2]=t[l>>2],t[r+4>>2]=t[l+4>>2],t[r+8>>2]=t[l+8>>2],t[r+12>>2]=t[l+12>>2],l=0,k=a,l|0)}function ii(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0;return o=k,k=k+16|0,r=o,!(!0&(A&2013265920|0)==536870912)||(n=A&-2130706433|134217728,!(Ue(e,n)|0))?(n=0,k=o,n|0):(i=wA(e|0,A|0,56)|0,S()|0,i=(Xt(e,n,i&7,r)|0)==0,n=r,n=i&((t[n>>2]|0)==(e|0)?(t[n+4>>2]|0)==(A|0):0)&1,k=o,n|0)}function si(e,A,r){e=e|0,A=A|0,r=r|0;var n=0;(A|0)>0?(n=Qt(A,4)|0,t[e>>2]=n,n||OA(27835,27858,40,27872)):t[e>>2]=0,t[e+4>>2]=A,t[e+8>>2]=0,t[e+12>>2]=r}function li(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0;o=e+4|0,i=e+12|0,s=e+8|0;A:for(;;){for(r=t[o>>2]|0,A=0;;){if((A|0)>=(r|0))break A;if(n=t[e>>2]|0,l=t[n+(A<<2)>>2]|0,!l)A=A+1|0;else break}A=n+(~~(+$A(+(+lt(10,+ +(15-(t[i>>2]|0)|0))*(+b[l>>3]+ +b[l+8>>3])))%+(r|0))>>>0<<2)|0,r=t[A>>2]|0;e:do if(r|0){if(n=l+32|0,(r|0)==(l|0))t[A>>2]=t[n>>2];else{if(r=r+32|0,A=t[r>>2]|0,!A)break;for(;(A|0)!=(l|0);)if(r=A+32|0,A=t[r>>2]|0,!A)break e;t[r>>2]=t[n>>2]}qA(l),t[s>>2]=(t[s>>2]|0)+-1}while(!1)}qA(t[e>>2]|0)}function ai(e){e=e|0;var A=0,r=0,n=0;for(n=t[e+4>>2]|0,r=0;;){if((r|0)>=(n|0)){A=0,r=4;break}if(A=t[(t[e>>2]|0)+(r<<2)>>2]|0,!A)r=r+1|0;else{r=4;break}}return(r|0)==4?A|0:0}function ui(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0;if(r=~~(+$A(+(+lt(10,+ +(15-(t[e+12>>2]|0)|0))*(+b[A>>3]+ +b[A+8>>3])))%+(t[e+4>>2]|0))>>>0,r=(t[e>>2]|0)+(r<<2)|0,n=t[r>>2]|0,!n)return i=1,i|0;i=A+32|0;do if((n|0)!=(A|0)){if(r=t[n+32>>2]|0,!r)return i=1,i|0;for(o=r;;){if((o|0)==(A|0)){o=8;break}if(r=t[o+32>>2]|0,r)n=o,o=r;else{r=1,o=10;break}}if((o|0)==8){t[n+32>>2]=t[i>>2];break}else if((o|0)==10)return r|0}else t[r>>2]=t[i>>2];while(!1);return qA(A),i=e+8|0,t[i>>2]=(t[i>>2]|0)+-1,i=0,i|0}function ql(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0;i=p0(40)|0,i||OA(27888,27858,98,27901),t[i>>2]=t[A>>2],t[i+4>>2]=t[A+4>>2],t[i+8>>2]=t[A+8>>2],t[i+12>>2]=t[A+12>>2],o=i+16|0,t[o>>2]=t[r>>2],t[o+4>>2]=t[r+4>>2],t[o+8>>2]=t[r+8>>2],t[o+12>>2]=t[r+12>>2],t[i+32>>2]=0,o=~~(+$A(+(+lt(10,+ +(15-(t[e+12>>2]|0)|0))*(+b[A>>3]+ +b[A+8>>3])))%+(t[e+4>>2]|0))>>>0,o=(t[e>>2]|0)+(o<<2)|0,n=t[o>>2]|0;do if(!n)t[o>>2]=i;else{for(;!(Tr(n,A)|0&&Tr(n+16|0,r)|0);)if(o=t[n+32>>2]|0,n=(o|0)==0?n:o,!(t[n+32>>2]|0)){s=10;break}if((s|0)==10){t[n+32>>2]=i;break}return qA(i),s=n,s|0}while(!1);return s=e+8|0,t[s>>2]=(t[s>>2]|0)+1,s=i,s|0}function Jl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0;if(o=~~(+$A(+(+lt(10,+ +(15-(t[e+12>>2]|0)|0))*(+b[A>>3]+ +b[A+8>>3])))%+(t[e+4>>2]|0))>>>0,o=t[(t[e>>2]|0)+(o<<2)>>2]|0,!o)return r=0,r|0;if(!r){for(e=o;;){if(Tr(e,A)|0){n=10;break}if(e=t[e+32>>2]|0,!e){e=0,n=10;break}}if((n|0)==10)return e|0}for(e=o;;){if(Tr(e,A)|0&&Tr(e+16|0,r)|0){n=10;break}if(e=t[e+32>>2]|0,!e){e=0,n=10;break}}return(n|0)==10?e|0:0}function Xl(e,A){e=e|0,A=A|0;var r=0;if(r=~~(+$A(+(+lt(10,+ +(15-(t[e+12>>2]|0)|0))*(+b[A>>3]+ +b[A+8>>3])))%+(t[e+4>>2]|0))>>>0,e=t[(t[e>>2]|0)+(r<<2)>>2]|0,!e)return r=0,r|0;for(;;){if(Tr(e,A)|0){A=5;break}if(e=t[e+32>>2]|0,!e){e=0,A=5;break}}return(A|0)==5?e|0:0}function Aa(){return 27920}function V0(e){return e=+e,~~+di(+e)|0}function p0(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0,G=0,W=0,nA=0,q=0,$=0,U=0,BA=0;BA=k,k=k+16|0,j=BA;do if(e>>>0<245){if(f=e>>>0<11?16:e+11&-8,e=f>>>3,M=t[6981]|0,r=M>>>e,r&3|0)return A=(r&1^1)+e|0,e=27964+(A<<1<<2)|0,r=e+8|0,n=t[r>>2]|0,o=n+8|0,i=t[o>>2]|0,(i|0)==(e|0)?t[6981]=M&~(1<>2]=e,t[r>>2]=i),U=A<<3,t[n+4>>2]=U|3,U=n+U+4|0,t[U>>2]=t[U>>2]|1,U=o,k=BA,U|0;if(m=t[6983]|0,f>>>0>m>>>0){if(r|0)return A=2<>>12&16,A=A>>>l,r=A>>>5&8,A=A>>>r,i=A>>>2&4,A=A>>>i,e=A>>>1&2,A=A>>>e,n=A>>>1&1,n=(r|l|i|e|n)+(A>>>n)|0,A=27964+(n<<1<<2)|0,e=A+8|0,i=t[e>>2]|0,l=i+8|0,r=t[l>>2]|0,(r|0)==(A|0)?(e=M&~(1<>2]=A,t[e>>2]=r,e=M),U=n<<3,s=U-f|0,t[i+4>>2]=f|3,o=i+f|0,t[o+4>>2]=s|1,t[i+U>>2]=s,m|0&&(n=t[6986]|0,A=m>>>3,r=27964+(A<<1<<2)|0,A=1<>2]|0):(t[6981]=e|A,A=r,e=r+8|0),t[e>>2]=n,t[A+12>>2]=n,t[n+8>>2]=A,t[n+12>>2]=r),t[6983]=s,t[6986]=o,U=l,k=BA,U|0;if(i=t[6982]|0,i){for(r=(i&0-i)+-1|0,o=r>>>12&16,r=r>>>o,n=r>>>5&8,r=r>>>n,s=r>>>2&4,r=r>>>s,l=r>>>1&2,r=r>>>l,a=r>>>1&1,a=t[28228+((n|o|s|l|a)+(r>>>a)<<2)>>2]|0,r=a,l=a,a=(t[a+4>>2]&-8)-f|0;e=t[r+16>>2]|0,!(!e&&(e=t[r+20>>2]|0,!e));)s=(t[e+4>>2]&-8)-f|0,o=s>>>0>>0,r=e,l=o?e:l,a=o?s:a;if(s=l+f|0,s>>>0>l>>>0){o=t[l+24>>2]|0,A=t[l+12>>2]|0;do if((A|0)==(l|0)){if(e=l+20|0,A=t[e>>2]|0,!A&&(e=l+16|0,A=t[e>>2]|0,!A)){r=0;break}for(;;)if(n=A+20|0,r=t[n>>2]|0,r)A=r,e=n;else if(n=A+16|0,r=t[n>>2]|0,r)A=r,e=n;else break;t[e>>2]=0,r=A}else r=t[l+8>>2]|0,t[r+12>>2]=A,t[A+8>>2]=r,r=A;while(!1);do if(o|0){if(A=t[l+28>>2]|0,e=28228+(A<<2)|0,(l|0)==(t[e>>2]|0)){if(t[e>>2]=r,!r){t[6982]=i&~(1<>2]|0)==(l|0)?U:o+20|0)>>2]=r,!r)break;t[r+24>>2]=o,A=t[l+16>>2]|0,A|0&&(t[r+16>>2]=A,t[A+24>>2]=r),A=t[l+20>>2]|0,A|0&&(t[r+20>>2]=A,t[A+24>>2]=r)}while(!1);return a>>>0<16?(U=a+f|0,t[l+4>>2]=U|3,U=l+U+4|0,t[U>>2]=t[U>>2]|1):(t[l+4>>2]=f|3,t[s+4>>2]=a|1,t[s+a>>2]=a,m|0&&(n=t[6986]|0,A=m>>>3,r=27964+(A<<1<<2)|0,A=1<>2]|0):(t[6981]=A|M,A=r,e=r+8|0),t[e>>2]=n,t[A+12>>2]=n,t[n+8>>2]=A,t[n+12>>2]=r),t[6983]=a,t[6986]=s),U=l+8|0,k=BA,U|0}else M=f}else M=f}else M=f}else if(e>>>0<=4294967231)if(e=e+11|0,f=e&-8,n=t[6982]|0,n){o=0-f|0,e=e>>>8,e?f>>>0>16777215?a=31:(M=(e+1048320|0)>>>16&8,G=e<>>16&4,G=G<>>16&2,a=14-(l|M|a)+(G<>>15)|0,a=f>>>(a+7|0)&1|a<<1):a=0,r=t[28228+(a<<2)>>2]|0;A:do if(!r)r=0,e=0,G=61;else for(e=0,l=f<<((a|0)==31?0:25-(a>>>1)|0),i=0;;){if(s=(t[r+4>>2]&-8)-f|0,s>>>0>>0)if(s)e=r,o=s;else{e=r,o=0,G=65;break A}if(G=t[r+20>>2]|0,r=t[r+16+(l>>>31<<2)>>2]|0,i=(G|0)==0|(G|0)==(r|0)?i:G,r)l=l<<1;else{r=i,G=61;break}}while(!1);if((G|0)==61){if((r|0)==0&(e|0)==0){if(e=2<>>12&16,M=M>>>s,i=M>>>5&8,M=M>>>i,l=M>>>2&4,M=M>>>l,a=M>>>1&2,M=M>>>a,r=M>>>1&1,e=0,r=t[28228+((i|s|l|a|r)+(M>>>r)<<2)>>2]|0}r?G=65:(l=e,s=o)}if((G|0)==65)for(i=r;;)if(M=(t[i+4>>2]&-8)-f|0,r=M>>>0>>0,o=r?M:o,e=r?i:e,r=t[i+16>>2]|0,r||(r=t[i+20>>2]|0),r)i=r;else{l=e,s=o;break}if((l|0)!=0&&s>>>0<((t[6983]|0)-f|0)>>>0&&(m=l+f|0,m>>>0>l>>>0)){i=t[l+24>>2]|0,A=t[l+12>>2]|0;do if((A|0)==(l|0)){if(e=l+20|0,A=t[e>>2]|0,!A&&(e=l+16|0,A=t[e>>2]|0,!A)){A=0;break}for(;;)if(o=A+20|0,r=t[o>>2]|0,r)A=r,e=o;else if(o=A+16|0,r=t[o>>2]|0,r)A=r,e=o;else break;t[e>>2]=0}else U=t[l+8>>2]|0,t[U+12>>2]=A,t[A+8>>2]=U;while(!1);do if(i){if(e=t[l+28>>2]|0,r=28228+(e<<2)|0,(l|0)==(t[r>>2]|0)){if(t[r>>2]=A,!A){n=n&~(1<>2]|0)==(l|0)?U:i+20|0)>>2]=A,!A)break;t[A+24>>2]=i,e=t[l+16>>2]|0,e|0&&(t[A+16>>2]=e,t[e+24>>2]=A),e=t[l+20>>2]|0,e&&(t[A+20>>2]=e,t[e+24>>2]=A)}while(!1);A:do if(s>>>0<16)U=s+f|0,t[l+4>>2]=U|3,U=l+U+4|0,t[U>>2]=t[U>>2]|1;else{if(t[l+4>>2]=f|3,t[m+4>>2]=s|1,t[m+s>>2]=s,A=s>>>3,s>>>0<256){r=27964+(A<<1<<2)|0,e=t[6981]|0,A=1<>2]|0):(t[6981]=e|A,A=r,e=r+8|0),t[e>>2]=m,t[A+12>>2]=m,t[m+8>>2]=A,t[m+12>>2]=r;break}if(A=s>>>8,A?s>>>0>16777215?r=31:($=(A+1048320|0)>>>16&8,U=A<<$,q=(U+520192|0)>>>16&4,U=U<>>16&2,r=14-(q|$|r)+(U<>>15)|0,r=s>>>(r+7|0)&1|r<<1):r=0,A=28228+(r<<2)|0,t[m+28>>2]=r,e=m+16|0,t[e+4>>2]=0,t[e>>2]=0,e=1<>2]=m,t[m+24>>2]=A,t[m+12>>2]=m,t[m+8>>2]=m;break}A=t[A>>2]|0;e:do if((t[A+4>>2]&-8|0)!=(s|0)){for(n=s<<((r|0)==31?0:25-(r>>>1)|0);r=A+16+(n>>>31<<2)|0,e=t[r>>2]|0,!!e;)if((t[e+4>>2]&-8|0)==(s|0)){A=e;break e}else n=n<<1,A=e;t[r>>2]=m,t[m+24>>2]=A,t[m+12>>2]=m,t[m+8>>2]=m;break A}while(!1);$=A+8|0,U=t[$>>2]|0,t[U+12>>2]=m,t[$>>2]=m,t[m+8>>2]=U,t[m+12>>2]=A,t[m+24>>2]=0}while(!1);return U=l+8|0,k=BA,U|0}else M=f}else M=f;else M=-1;while(!1);if(r=t[6983]|0,r>>>0>=M>>>0)return A=r-M|0,e=t[6986]|0,A>>>0>15?(U=e+M|0,t[6986]=U,t[6983]=A,t[U+4>>2]=A|1,t[e+r>>2]=A,t[e+4>>2]=M|3):(t[6983]=0,t[6986]=0,t[e+4>>2]=r|3,U=e+r+4|0,t[U>>2]=t[U>>2]|1),U=e+8|0,k=BA,U|0;if(s=t[6984]|0,s>>>0>M>>>0)return q=s-M|0,t[6984]=q,U=t[6987]|0,$=U+M|0,t[6987]=$,t[$+4>>2]=q|1,t[U+4>>2]=M|3,U=U+8|0,k=BA,U|0;if(t[7099]|0?e=t[7101]|0:(t[7101]=4096,t[7100]=4096,t[7102]=-1,t[7103]=-1,t[7104]=0,t[7092]=0,t[7099]=j&-16^1431655768,e=4096),l=M+48|0,a=M+47|0,i=e+a|0,o=0-e|0,f=i&o,f>>>0<=M>>>0||(e=t[7091]|0,e|0&&(m=t[7089]|0,j=m+f|0,j>>>0<=m>>>0|j>>>0>e>>>0)))return U=0,k=BA,U|0;A:do if(t[7092]&4)A=0,G=143;else{r=t[6987]|0;e:do if(r){for(n=28372;j=t[n>>2]|0,!(j>>>0<=r>>>0&&(j+(t[n+4>>2]|0)|0)>>>0>r>>>0);)if(e=t[n+8>>2]|0,e)n=e;else{G=128;break e}if(A=i-s&o,A>>>0<2147483647)if(e=K0(A|0)|0,(e|0)==((t[n>>2]|0)+(t[n+4>>2]|0)|0)){if((e|0)!=-1){s=A,i=e,G=145;break A}}else n=e,G=136;else A=0}else G=128;while(!1);do if((G|0)==128)if(r=K0(0)|0,(r|0)!=-1&&(A=r,I=t[7100]|0,L=I+-1|0,A=((L&A|0)==0?0:(L+A&0-I)-A|0)+f|0,I=t[7089]|0,L=A+I|0,A>>>0>M>>>0&A>>>0<2147483647)){if(j=t[7091]|0,j|0&&L>>>0<=I>>>0|L>>>0>j>>>0){A=0;break}if(e=K0(A|0)|0,(e|0)==(r|0)){s=A,i=r,G=145;break A}else n=e,G=136}else A=0;while(!1);do if((G|0)==136){if(r=0-A|0,!(l>>>0>A>>>0&(A>>>0<2147483647&(n|0)!=-1)))if((n|0)==-1){A=0;break}else{s=A,i=n,G=145;break A}if(e=t[7101]|0,e=a-A+e&0-e,e>>>0>=2147483647){s=A,i=n,G=145;break A}if((K0(e|0)|0)==-1){K0(r|0)|0,A=0;break}else{s=e+A|0,i=n,G=145;break A}}while(!1);t[7092]=t[7092]|4,G=143}while(!1);if((G|0)==143&&f>>>0<2147483647&&(q=K0(f|0)|0,L=K0(0)|0,W=L-q|0,nA=W>>>0>(M+40|0)>>>0,!((q|0)==-1|nA^1|q>>>0>>0&((q|0)!=-1&(L|0)!=-1)^1))&&(s=nA?W:A,i=q,G=145),(G|0)==145){A=(t[7089]|0)+s|0,t[7089]=A,A>>>0>(t[7090]|0)>>>0&&(t[7090]=A),a=t[6987]|0;A:do if(a){for(A=28372;;){if(e=t[A>>2]|0,r=t[A+4>>2]|0,(i|0)==(e+r|0)){G=154;break}if(n=t[A+8>>2]|0,n)A=n;else break}if((G|0)==154&&($=A+4|0,(t[A+12>>2]&8|0)==0)&&i>>>0>a>>>0&e>>>0<=a>>>0){t[$>>2]=r+s,U=(t[6984]|0)+s|0,q=a+8|0,q=(q&7|0)==0?0:0-q&7,$=a+q|0,q=U-q|0,t[6987]=$,t[6984]=q,t[$+4>>2]=q|1,t[a+U+4>>2]=40,t[6988]=t[7103];break}for(i>>>0<(t[6985]|0)>>>0&&(t[6985]=i),r=i+s|0,A=28372;;){if((t[A>>2]|0)==(r|0)){G=162;break}if(e=t[A+8>>2]|0,e)A=e;else break}if((G|0)==162&&(t[A+12>>2]&8|0)==0){t[A>>2]=i,m=A+4|0,t[m>>2]=(t[m>>2]|0)+s,m=i+8|0,m=i+((m&7|0)==0?0:0-m&7)|0,A=r+8|0,A=r+((A&7|0)==0?0:0-A&7)|0,f=m+M|0,l=A-m-M|0,t[m+4>>2]=M|3;e:do if((a|0)==(A|0))U=(t[6984]|0)+l|0,t[6984]=U,t[6987]=f,t[f+4>>2]=U|1;else{if((t[6986]|0)==(A|0)){U=(t[6983]|0)+l|0,t[6983]=U,t[6986]=f,t[f+4>>2]=U|1,t[f+U>>2]=U;break}if(e=t[A+4>>2]|0,(e&3|0)==1){s=e&-8,n=e>>>3;t:do if(e>>>0<256)if(e=t[A+8>>2]|0,r=t[A+12>>2]|0,(r|0)==(e|0)){t[6981]=t[6981]&~(1<>2]=r,t[r+8>>2]=e;break}else{i=t[A+24>>2]|0,e=t[A+12>>2]|0;do if((e|0)==(A|0)){if(r=A+16|0,n=r+4|0,e=t[n>>2]|0,e)r=n;else if(e=t[r>>2]|0,!e){e=0;break}for(;;)if(o=e+20|0,n=t[o>>2]|0,n)e=n,r=o;else if(o=e+16|0,n=t[o>>2]|0,n)e=n,r=o;else break;t[r>>2]=0}else U=t[A+8>>2]|0,t[U+12>>2]=e,t[e+8>>2]=U;while(!1);if(!i)break;r=t[A+28>>2]|0,n=28228+(r<<2)|0;do if((t[n>>2]|0)!=(A|0)){if(U=i+16|0,t[((t[U>>2]|0)==(A|0)?U:i+20|0)>>2]=e,!e)break t}else{if(t[n>>2]=e,e|0)break;t[6982]=t[6982]&~(1<>2]=i,r=A+16|0,n=t[r>>2]|0,n|0&&(t[e+16>>2]=n,t[n+24>>2]=e),r=t[r+4>>2]|0,!r)break;t[e+20>>2]=r,t[r+24>>2]=e}while(!1);A=A+s|0,o=s+l|0}else o=l;if(A=A+4|0,t[A>>2]=t[A>>2]&-2,t[f+4>>2]=o|1,t[f+o>>2]=o,A=o>>>3,o>>>0<256){r=27964+(A<<1<<2)|0,e=t[6981]|0,A=1<>2]|0):(t[6981]=e|A,A=r,e=r+8|0),t[e>>2]=f,t[A+12>>2]=f,t[f+8>>2]=A,t[f+12>>2]=r;break}A=o>>>8;do if(!A)n=0;else{if(o>>>0>16777215){n=31;break}$=(A+1048320|0)>>>16&8,U=A<<$,q=(U+520192|0)>>>16&4,U=U<>>16&2,n=14-(q|$|n)+(U<>>15)|0,n=o>>>(n+7|0)&1|n<<1}while(!1);if(A=28228+(n<<2)|0,t[f+28>>2]=n,e=f+16|0,t[e+4>>2]=0,t[e>>2]=0,e=t[6982]|0,r=1<>2]=f,t[f+24>>2]=A,t[f+12>>2]=f,t[f+8>>2]=f;break}A=t[A>>2]|0;t:do if((t[A+4>>2]&-8|0)!=(o|0)){for(n=o<<((n|0)==31?0:25-(n>>>1)|0);r=A+16+(n>>>31<<2)|0,e=t[r>>2]|0,!!e;)if((t[e+4>>2]&-8|0)==(o|0)){A=e;break t}else n=n<<1,A=e;t[r>>2]=f,t[f+24>>2]=A,t[f+12>>2]=f,t[f+8>>2]=f;break e}while(!1);$=A+8|0,U=t[$>>2]|0,t[U+12>>2]=f,t[$>>2]=f,t[f+8>>2]=U,t[f+12>>2]=A,t[f+24>>2]=0}while(!1);return U=m+8|0,k=BA,U|0}for(A=28372;e=t[A>>2]|0,!(e>>>0<=a>>>0&&(U=e+(t[A+4>>2]|0)|0,U>>>0>a>>>0));)A=t[A+8>>2]|0;o=U+-47|0,e=o+8|0,e=o+((e&7|0)==0?0:0-e&7)|0,o=a+16|0,e=e>>>0>>0?a:e,A=e+8|0,r=s+-40|0,q=i+8|0,q=(q&7|0)==0?0:0-q&7,$=i+q|0,q=r-q|0,t[6987]=$,t[6984]=q,t[$+4>>2]=q|1,t[i+r+4>>2]=40,t[6988]=t[7103],r=e+4|0,t[r>>2]=27,t[A>>2]=t[7093],t[A+4>>2]=t[7094],t[A+8>>2]=t[7095],t[A+12>>2]=t[7096],t[7093]=i,t[7094]=s,t[7096]=0,t[7095]=A,A=e+24|0;do $=A,A=A+4|0,t[A>>2]=7;while(($+8|0)>>>0>>0);if((e|0)!=(a|0)){if(i=e-a|0,t[r>>2]=t[r>>2]&-2,t[a+4>>2]=i|1,t[e>>2]=i,A=i>>>3,i>>>0<256){r=27964+(A<<1<<2)|0,e=t[6981]|0,A=1<>2]|0):(t[6981]=e|A,A=r,e=r+8|0),t[e>>2]=a,t[A+12>>2]=a,t[a+8>>2]=A,t[a+12>>2]=r;break}if(A=i>>>8,A?i>>>0>16777215?n=31:($=(A+1048320|0)>>>16&8,U=A<<$,q=(U+520192|0)>>>16&4,U=U<>>16&2,n=14-(q|$|n)+(U<>>15)|0,n=i>>>(n+7|0)&1|n<<1):n=0,r=28228+(n<<2)|0,t[a+28>>2]=n,t[a+20>>2]=0,t[o>>2]=0,A=t[6982]|0,e=1<>2]=a,t[a+24>>2]=r,t[a+12>>2]=a,t[a+8>>2]=a;break}A=t[r>>2]|0;e:do if((t[A+4>>2]&-8|0)!=(i|0)){for(n=i<<((n|0)==31?0:25-(n>>>1)|0);r=A+16+(n>>>31<<2)|0,e=t[r>>2]|0,!!e;)if((t[e+4>>2]&-8|0)==(i|0)){A=e;break e}else n=n<<1,A=e;t[r>>2]=a,t[a+24>>2]=A,t[a+12>>2]=a,t[a+8>>2]=a;break A}while(!1);$=A+8|0,U=t[$>>2]|0,t[U+12>>2]=a,t[$>>2]=a,t[a+8>>2]=U,t[a+12>>2]=A,t[a+24>>2]=0}}else U=t[6985]|0,(U|0)==0|i>>>0>>0&&(t[6985]=i),t[7093]=i,t[7094]=s,t[7096]=0,t[6990]=t[7099],t[6989]=-1,t[6994]=27964,t[6993]=27964,t[6996]=27972,t[6995]=27972,t[6998]=27980,t[6997]=27980,t[7e3]=27988,t[6999]=27988,t[7002]=27996,t[7001]=27996,t[7004]=28004,t[7003]=28004,t[7006]=28012,t[7005]=28012,t[7008]=28020,t[7007]=28020,t[7010]=28028,t[7009]=28028,t[7012]=28036,t[7011]=28036,t[7014]=28044,t[7013]=28044,t[7016]=28052,t[7015]=28052,t[7018]=28060,t[7017]=28060,t[7020]=28068,t[7019]=28068,t[7022]=28076,t[7021]=28076,t[7024]=28084,t[7023]=28084,t[7026]=28092,t[7025]=28092,t[7028]=28100,t[7027]=28100,t[7030]=28108,t[7029]=28108,t[7032]=28116,t[7031]=28116,t[7034]=28124,t[7033]=28124,t[7036]=28132,t[7035]=28132,t[7038]=28140,t[7037]=28140,t[7040]=28148,t[7039]=28148,t[7042]=28156,t[7041]=28156,t[7044]=28164,t[7043]=28164,t[7046]=28172,t[7045]=28172,t[7048]=28180,t[7047]=28180,t[7050]=28188,t[7049]=28188,t[7052]=28196,t[7051]=28196,t[7054]=28204,t[7053]=28204,t[7056]=28212,t[7055]=28212,U=s+-40|0,q=i+8|0,q=(q&7|0)==0?0:0-q&7,$=i+q|0,q=U-q|0,t[6987]=$,t[6984]=q,t[$+4>>2]=q|1,t[i+U+4>>2]=40,t[6988]=t[7103];while(!1);if(A=t[6984]|0,A>>>0>M>>>0)return q=A-M|0,t[6984]=q,U=t[6987]|0,$=U+M|0,t[6987]=$,t[$+4>>2]=q|1,t[U+4>>2]=M|3,U=U+8|0,k=BA,U|0}return U=Aa()|0,t[U>>2]=12,U=0,k=BA,U|0}function qA(e){e=e|0;var A=0,r=0,n=0,o=0,i=0,s=0,l=0,a=0;if(e){r=e+-8|0,o=t[6985]|0,e=t[e+-4>>2]|0,A=e&-8,a=r+A|0;do if(e&1)l=r,s=r;else{if(n=t[r>>2]|0,!(e&3)||(s=r+(0-n)|0,i=n+A|0,s>>>0>>0))return;if((t[6986]|0)==(s|0)){if(e=a+4|0,A=t[e>>2]|0,(A&3|0)!=3){l=s,A=i;break}t[6983]=i,t[e>>2]=A&-2,t[s+4>>2]=i|1,t[s+i>>2]=i;return}if(r=n>>>3,n>>>0<256)if(e=t[s+8>>2]|0,A=t[s+12>>2]|0,(A|0)==(e|0)){t[6981]=t[6981]&~(1<>2]=A,t[A+8>>2]=e,l=s,A=i;break}o=t[s+24>>2]|0,e=t[s+12>>2]|0;do if((e|0)==(s|0)){if(A=s+16|0,r=A+4|0,e=t[r>>2]|0,e)A=r;else if(e=t[A>>2]|0,!e){e=0;break}for(;;)if(n=e+20|0,r=t[n>>2]|0,r)e=r,A=n;else if(n=e+16|0,r=t[n>>2]|0,r)e=r,A=n;else break;t[A>>2]=0}else l=t[s+8>>2]|0,t[l+12>>2]=e,t[e+8>>2]=l;while(!1);if(o){if(A=t[s+28>>2]|0,r=28228+(A<<2)|0,(t[r>>2]|0)==(s|0)){if(t[r>>2]=e,!e){t[6982]=t[6982]&~(1<>2]|0)==(s|0)?l:o+20|0)>>2]=e,!e){l=s,A=i;break}t[e+24>>2]=o,A=s+16|0,r=t[A>>2]|0,r|0&&(t[e+16>>2]=r,t[r+24>>2]=e),A=t[A+4>>2]|0,A?(t[e+20>>2]=A,t[A+24>>2]=e,l=s,A=i):(l=s,A=i)}else l=s,A=i}while(!1);if(!(s>>>0>=a>>>0)&&(e=a+4|0,n=t[e>>2]|0,!!(n&1))){if(n&2)t[e>>2]=n&-2,t[l+4>>2]=A|1,t[s+A>>2]=A,o=A;else{if((t[6987]|0)==(a|0)){if(a=(t[6984]|0)+A|0,t[6984]=a,t[6987]=l,t[l+4>>2]=a|1,(l|0)!=(t[6986]|0))return;t[6986]=0,t[6983]=0;return}if((t[6986]|0)==(a|0)){a=(t[6983]|0)+A|0,t[6983]=a,t[6986]=s,t[l+4>>2]=a|1,t[s+a>>2]=a;return}o=(n&-8)+A|0,r=n>>>3;do if(n>>>0<256)if(A=t[a+8>>2]|0,e=t[a+12>>2]|0,(e|0)==(A|0)){t[6981]=t[6981]&~(1<>2]=e,t[e+8>>2]=A;break}else{i=t[a+24>>2]|0,e=t[a+12>>2]|0;do if((e|0)==(a|0)){if(A=a+16|0,r=A+4|0,e=t[r>>2]|0,e)A=r;else if(e=t[A>>2]|0,!e){r=0;break}for(;;)if(n=e+20|0,r=t[n>>2]|0,r)e=r,A=n;else if(n=e+16|0,r=t[n>>2]|0,r)e=r,A=n;else break;t[A>>2]=0,r=e}else r=t[a+8>>2]|0,t[r+12>>2]=e,t[e+8>>2]=r,r=e;while(!1);if(i|0){if(e=t[a+28>>2]|0,A=28228+(e<<2)|0,(t[A>>2]|0)==(a|0)){if(t[A>>2]=r,!r){t[6982]=t[6982]&~(1<>2]|0)==(a|0)?n:i+20|0)>>2]=r,!r)break;t[r+24>>2]=i,e=a+16|0,A=t[e>>2]|0,A|0&&(t[r+16>>2]=A,t[A+24>>2]=r),e=t[e+4>>2]|0,e|0&&(t[r+20>>2]=e,t[e+24>>2]=r)}}while(!1);if(t[l+4>>2]=o|1,t[s+o>>2]=o,(l|0)==(t[6986]|0)){t[6983]=o;return}}if(e=o>>>3,o>>>0<256){r=27964+(e<<1<<2)|0,A=t[6981]|0,e=1<>2]|0):(t[6981]=A|e,e=r,A=r+8|0),t[A>>2]=l,t[e+12>>2]=l,t[l+8>>2]=e,t[l+12>>2]=r;return}e=o>>>8,e?o>>>0>16777215?n=31:(s=(e+1048320|0)>>>16&8,a=e<>>16&4,a=a<>>16&2,n=14-(i|s|n)+(a<>>15)|0,n=o>>>(n+7|0)&1|n<<1):n=0,e=28228+(n<<2)|0,t[l+28>>2]=n,t[l+20>>2]=0,t[l+16>>2]=0,A=t[6982]|0,r=1<>2]=l,t[l+24>>2]=e,t[l+12>>2]=l,t[l+8>>2]=l;else{e=t[e>>2]|0;e:do if((t[e+4>>2]&-8|0)!=(o|0)){for(n=o<<((n|0)==31?0:25-(n>>>1)|0);r=e+16+(n>>>31<<2)|0,A=t[r>>2]|0,!!A;)if((t[A+4>>2]&-8|0)==(o|0)){e=A;break e}else n=n<<1,e=A;t[r>>2]=l,t[l+24>>2]=e,t[l+12>>2]=l,t[l+8>>2]=l;break A}while(!1);s=e+8|0,a=t[s>>2]|0,t[a+12>>2]=l,t[s>>2]=l,t[l+8>>2]=a,t[l+12>>2]=e,t[l+24>>2]=0}while(!1);if(a=(t[6989]|0)+-1|0,t[6989]=a,!(a|0)){for(e=28380;e=t[e>>2]|0,e;)e=e+8|0;t[6989]=-1}}}}function Qt(e,A){e=e|0,A=A|0;var r=0;return e?(r=Pe(A,e)|0,(A|e)>>>0>65535&&(r=((r>>>0)/(e>>>0)|0|0)==(A|0)?r:-1)):r=0,e=p0(r)|0,!e||!(t[e+-4>>2]&3)||Y0(e|0,0,r|0)|0,e|0}function KA(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,r=e+r>>>0,YA(A+n+(r>>>0>>0|0)>>>0|0),r|0|0}function ct(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,n=A-n-(r>>>0>e>>>0|0)>>>0,YA(n|0),e-r>>>0|0|0}function ci(e){return e=e|0,(e?31-(nt(e^e-1)|0)|0:32)|0}function oo(e,A,r,n,o){e=e|0,A=A|0,r=r|0,n=n|0,o=o|0;var i=0,s=0,l=0,a=0,f=0,m=0,M=0,j=0,I=0,L=0;if(m=e,a=A,f=a,s=r,j=n,l=j,!f)return i=(o|0)!=0,l?i?(t[o>>2]=e|0,t[o+4>>2]=A&0,j=0,o=0,YA(j|0),o|0):(j=0,o=0,YA(j|0),o|0):(i&&(t[o>>2]=(m>>>0)%(s>>>0),t[o+4>>2]=0),j=0,o=(m>>>0)/(s>>>0)>>>0,YA(j|0),o|0);i=(l|0)==0;do if(s){if(!i){if(i=(nt(l|0)|0)-(nt(f|0)|0)|0,i>>>0<=31){M=i+1|0,l=31-i|0,A=i-31>>31,s=M,e=m>>>(M>>>0)&A|f<>>(M>>>0)&A,i=0,l=m<>2]=e|0,t[o+4>>2]=a|A&0,j=0,o=0,YA(j|0),o|0):(j=0,o=0,YA(j|0),o|0)}if(i=s-1|0,i&s|0){l=(nt(s|0)|0)+33-(nt(f|0)|0)|0,L=64-l|0,M=32-l|0,a=M>>31,I=l-32|0,A=I>>31,s=l,e=M-1>>31&f>>>(I>>>0)|(f<>>(l>>>0))&A,A=A&f>>>(l>>>0),i=m<>>(I>>>0))&a|m<>31;break}return o|0&&(t[o>>2]=i&m,t[o+4>>2]=0),(s|0)==1?(I=a|A&0,L=e|0|0,YA(I|0),L|0):(L=ci(s|0)|0,I=f>>>(L>>>0)|0,L=f<<32-L|m>>>(L>>>0)|0,YA(I|0),L|0)}else{if(i)return o|0&&(t[o>>2]=(f>>>0)%(s>>>0),t[o+4>>2]=0),I=0,L=(f>>>0)/(s>>>0)>>>0,YA(I|0),L|0;if(!m)return o|0&&(t[o>>2]=0,t[o+4>>2]=(f>>>0)%(l>>>0)),I=0,L=(f>>>0)/(l>>>0)>>>0,YA(I|0),L|0;if(i=l-1|0,!(i&l))return o|0&&(t[o>>2]=e|0,t[o+4>>2]=i&f|A&0),I=0,L=f>>>((ci(l|0)|0)>>>0),YA(I|0),L|0;if(i=(nt(l|0)|0)-(nt(f|0)|0)|0,i>>>0<=30){A=i+1|0,l=31-i|0,s=A,e=f<>>(A>>>0),A=f>>>(A>>>0),i=0,l=m<>2]=e|0,t[o+4>>2]=a|A&0,I=0,L=0,YA(I|0),L|0):(I=0,L=0,YA(I|0),L|0)}while(!1);if(!s)f=l,a=0,l=0;else{M=r|0|0,m=j|n&0,f=KA(M|0,m|0,-1,-1)|0,r=S()|0,a=l,l=0;do n=a,a=i>>>31|a<<1,i=l|i<<1,n=e<<1|n>>>31|0,j=e>>>31|A<<1|0,ct(f|0,r|0,n|0,j|0)|0,L=S()|0,I=L>>31|((L|0)<0?-1:0)<<1,l=I&1,e=ct(n|0,j|0,I&M|0,(((L|0)<0?-1:0)>>31|((L|0)<0?-1:0)<<1)&m|0)|0,A=S()|0,s=s-1|0;while((s|0)!=0);f=a,a=0}return s=0,o|0&&(t[o>>2]=e,t[o+4>>2]=A),I=(i|0)>>>31|(f|s)<<1|(s<<1|i>>>31)&0|a,L=(i<<1|0)&-2|l,YA(I|0),L|0}function W0(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0;return f=A>>31|((A|0)<0?-1:0)<<1,a=((A|0)<0?-1:0)>>31|((A|0)<0?-1:0)<<1,i=n>>31|((n|0)<0?-1:0)<<1,o=((n|0)<0?-1:0)>>31|((n|0)<0?-1:0)<<1,l=ct(f^e|0,a^A|0,f|0,a|0)|0,s=S()|0,e=i^f,A=o^a,ct((oo(l,s,ct(i^r|0,o^n|0,i|0,o|0)|0,S()|0,0)|0)^e|0,(S()|0)^A|0,e|0,A|0)|0}function ea(e,A){e=e|0,A=A|0;var r=0,n=0,o=0,i=0;return i=e&65535,o=A&65535,r=Pe(o,i)|0,n=e>>>16,e=(r>>>16)+(Pe(o,n)|0)|0,o=A>>>16,A=Pe(o,i)|0,YA((e>>>16)+(Pe(o,n)|0)+(((e&65535)+A|0)>>>16)|0),e+A<<16|r&65535|0|0}function ft(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0;return o=e,i=r,r=ea(o,i)|0,e=S()|0,YA((Pe(A,i)|0)+(Pe(n,o)|0)+e|e&0|0),r|0|0|0}function Rr(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0,s=0,l=0,a=0,f=0;return o=k,k=k+16|0,l=o|0,s=A>>31|((A|0)<0?-1:0)<<1,i=((A|0)<0?-1:0)>>31|((A|0)<0?-1:0)<<1,f=n>>31|((n|0)<0?-1:0)<<1,a=((n|0)<0?-1:0)>>31|((n|0)<0?-1:0)<<1,e=ct(s^e|0,i^A|0,s|0,i|0)|0,A=S()|0,oo(e,A,ct(f^r|0,a^n|0,f|0,a|0)|0,S()|0,l)|0,n=ct(t[l>>2]^s|0,t[l+4>>2]^i|0,s|0,i|0)|0,r=S()|0,k=o,YA(r|0),n|0}function jr(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var o=0,i=0;return i=k,k=k+16|0,o=i|0,oo(e,A,r,n,o)|0,k=i,YA(t[o+4>>2]|0),t[o>>2]|0|0}function fi(e,A,r){return e=e|0,A=A|0,r=r|0,(r|0)<32?(YA(A>>r|0),e>>>r|(A&(1<>r-32|0)}function wA(e,A,r){return e=e|0,A=A|0,r=r|0,(r|0)<32?(YA(A>>>r|0),e>>>r|(A&(1<>>r-32|0)}function EA(e,A,r){return e=e|0,A=A|0,r=r|0,(r|0)<32?(YA(A<>>32-r|0),e<=0?+He(e+.5):+gt(e-.5)}function Ir(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0;if((r|0)>=8192)return i0(e|0,A|0,r|0)|0,e|0;if(i=e|0,o=e+r|0,(e&3)==(A&3)){for(;e&3;){if(!r)return i|0;xA[e>>0]=xA[A>>0]|0,e=e+1|0,A=A+1|0,r=r-1|0}for(r=o&-4|0,n=r-64|0;(e|0)<=(n|0);)t[e>>2]=t[A>>2],t[e+4>>2]=t[A+4>>2],t[e+8>>2]=t[A+8>>2],t[e+12>>2]=t[A+12>>2],t[e+16>>2]=t[A+16>>2],t[e+20>>2]=t[A+20>>2],t[e+24>>2]=t[A+24>>2],t[e+28>>2]=t[A+28>>2],t[e+32>>2]=t[A+32>>2],t[e+36>>2]=t[A+36>>2],t[e+40>>2]=t[A+40>>2],t[e+44>>2]=t[A+44>>2],t[e+48>>2]=t[A+48>>2],t[e+52>>2]=t[A+52>>2],t[e+56>>2]=t[A+56>>2],t[e+60>>2]=t[A+60>>2],e=e+64|0,A=A+64|0;for(;(e|0)<(r|0);)t[e>>2]=t[A>>2],e=e+4|0,A=A+4|0}else for(r=o-4|0;(e|0)<(r|0);)xA[e>>0]=xA[A>>0]|0,xA[e+1>>0]=xA[A+1>>0]|0,xA[e+2>>0]=xA[A+2>>0]|0,xA[e+3>>0]=xA[A+3>>0]|0,e=e+4|0,A=A+4|0;for(;(e|0)<(o|0);)xA[e>>0]=xA[A>>0]|0,e=e+1|0,A=A+1|0;return i|0}function Y0(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,o=0,i=0,s=0;if(i=e+r|0,A=A&255,(r|0)>=67){for(;e&3;)xA[e>>0]=A,e=e+1|0;for(n=i&-4|0,s=A|A<<8|A<<16|A<<24,o=n-64|0;(e|0)<=(o|0);)t[e>>2]=s,t[e+4>>2]=s,t[e+8>>2]=s,t[e+12>>2]=s,t[e+16>>2]=s,t[e+20>>2]=s,t[e+24>>2]=s,t[e+28>>2]=s,t[e+32>>2]=s,t[e+36>>2]=s,t[e+40>>2]=s,t[e+44>>2]=s,t[e+48>>2]=s,t[e+52>>2]=s,t[e+56>>2]=s,t[e+60>>2]=s,e=e+64|0;for(;(e|0)<(n|0);)t[e>>2]=s,e=e+4|0}for(;(e|0)<(i|0);)xA[e>>0]=A,e=e+1|0;return i-r|0}function di(e){return e=+e,e>=0?+He(e+.5):+gt(e-.5)}function K0(e){e=e|0;var A=0,r=0,n=0;return n=Q0()|0,r=t[De>>2]|0,A=r+e|0,(e|0)>0&(A|0)<(r|0)|(A|0)<0?(d0(A|0)|0,Nt(12),-1):(A|0)>(n|0)&&!(s0(A|0)|0)?(Nt(12),-1):(t[De>>2]=A,r|0)}return{___divdi3:W0,___muldi3:ft,___remdi3:Rr,___uremdi3:jr,_areNeighborCells:Yn,_bitshift64Ashr:fi,_bitshift64Lshr:wA,_bitshift64Shl:EA,_calloc:Qt,_cellAreaKm2:kl,_cellAreaM2:bl,_cellAreaRads2:eo,_cellToBoundary:_r,_cellToCenterChild:Wo,_cellToChildPos:hl,_cellToChildren:en,_cellToChildrenSize:g0,_cellToLatLng:ar,_cellToLocalIj:_l,_cellToParent:_t,_cellToVertex:Xt,_cellToVertexes:Zl,_cellsToDirectedEdge:pn,_cellsToLinkedMultiPolygon:pt,_childPosToCell:dl,_compactCells:ol,_constructCell:we,_destroyLinkedMultiPolygon:qo,_directedEdgeToBoundary:sr,_directedEdgeToCells:Mr,_edgeLengthKm:El,_edgeLengthM:Sl,_edgeLengthRads:Cl,_emscripten_replace_memory:C0,_free:qA,_getBaseCellNumber:te,_getDirectedEdgeDestination:yn,_getDirectedEdgeOrigin:Sr,_getHexagonAreaAvgKm2:Zo,_getHexagonAreaAvgM2:xl,_getHexagonEdgeLengthAvgKm:wl,_getHexagonEdgeLengthAvgM:vl,_getIcosahedronFaces:Yo,_getIndexDigit:ke,_getNumCells:vn,_getPentagons:Jn,_getRes0Cells:Wr,_getResolution:_A,_greatCircleDistanceKm:rn,_greatCircleDistanceM:gl,_greatCircleDistanceRads:ml,_gridDisk:v,_gridDiskDistances:D,_gridDistance:Rl,_gridPathCells:Il,_gridPathCellsSize:jl,_gridRing:hA,_gridRingUnsafe:RA,_i64Add:KA,_i64Subtract:ct,_isPentagon:Oe,_isResClassIII:ll,_isValidCell:Ue,_isValidDirectedEdge:Xr,_isValidIndex:Bt,_isValidVertex:ii,_latLngToCell:$n,_llvm_ctlz_i64:io,_llvm_maxnum_f64:hi,_llvm_minnum_f64:Cn,_llvm_round_f64:En,_localIjToCell:Tl,_malloc:p0,_maxFaceCount:cl,_maxGridDiskSize:h,_maxPolygonToCellsSize:ce,_maxPolygonToCellsSizeExperimental:Fl,_memcpy:Ir,_memset:Y0,_originToDirectedEdges:Br,_pentagonCount:fl,_polygonToCells:bt,_polygonToCellsExperimental:Nl,_readInt64AsDoubleFromPointer:Vl,_res0CellCount:Vr,_round:di,_sbrk:K0,_sizeOfCellBoundary:Ol,_sizeOfCoordIJ:Ul,_sizeOfGeoLoop:zl,_sizeOfGeoPolygon:Hl,_sizeOfH3Index:Pl,_sizeOfLatLng:Ql,_sizeOfLinkedGeoPolygon:Gl,_uncompactCells:il,_uncompactCellsSize:sl,_vertexToLatLng:$l,establishStackSpace:E0,stackAlloc:$t,stackRestore:z0,stackSave:O0}})(rr,F0,yA);u.___divdi3=gA.___divdi3,u.___muldi3=gA.___muldi3,u.___remdi3=gA.___remdi3,u.___uremdi3=gA.___uremdi3,u._areNeighborCells=gA._areNeighborCells,u._bitshift64Ashr=gA._bitshift64Ashr,u._bitshift64Lshr=gA._bitshift64Lshr,u._bitshift64Shl=gA._bitshift64Shl,u._calloc=gA._calloc,u._cellAreaKm2=gA._cellAreaKm2,u._cellAreaM2=gA._cellAreaM2,u._cellAreaRads2=gA._cellAreaRads2,u._cellToBoundary=gA._cellToBoundary,u._cellToCenterChild=gA._cellToCenterChild,u._cellToChildPos=gA._cellToChildPos,u._cellToChildren=gA._cellToChildren,u._cellToChildrenSize=gA._cellToChildrenSize,u._cellToLatLng=gA._cellToLatLng,u._cellToLocalIj=gA._cellToLocalIj,u._cellToParent=gA._cellToParent,u._cellToVertex=gA._cellToVertex,u._cellToVertexes=gA._cellToVertexes,u._cellsToDirectedEdge=gA._cellsToDirectedEdge,u._cellsToLinkedMultiPolygon=gA._cellsToLinkedMultiPolygon,u._childPosToCell=gA._childPosToCell,u._compactCells=gA._compactCells,u._constructCell=gA._constructCell,u._destroyLinkedMultiPolygon=gA._destroyLinkedMultiPolygon,u._directedEdgeToBoundary=gA._directedEdgeToBoundary,u._directedEdgeToCells=gA._directedEdgeToCells,u._edgeLengthKm=gA._edgeLengthKm,u._edgeLengthM=gA._edgeLengthM,u._edgeLengthRads=gA._edgeLengthRads;var f0=u._emscripten_replace_memory=gA._emscripten_replace_memory;u._free=gA._free,u._getBaseCellNumber=gA._getBaseCellNumber,u._getDirectedEdgeDestination=gA._getDirectedEdgeDestination,u._getDirectedEdgeOrigin=gA._getDirectedEdgeOrigin,u._getHexagonAreaAvgKm2=gA._getHexagonAreaAvgKm2,u._getHexagonAreaAvgM2=gA._getHexagonAreaAvgM2,u._getHexagonEdgeLengthAvgKm=gA._getHexagonEdgeLengthAvgKm,u._getHexagonEdgeLengthAvgM=gA._getHexagonEdgeLengthAvgM,u._getIcosahedronFaces=gA._getIcosahedronFaces,u._getIndexDigit=gA._getIndexDigit,u._getNumCells=gA._getNumCells,u._getPentagons=gA._getPentagons,u._getRes0Cells=gA._getRes0Cells,u._getResolution=gA._getResolution,u._greatCircleDistanceKm=gA._greatCircleDistanceKm,u._greatCircleDistanceM=gA._greatCircleDistanceM,u._greatCircleDistanceRads=gA._greatCircleDistanceRads,u._gridDisk=gA._gridDisk,u._gridDiskDistances=gA._gridDiskDistances,u._gridDistance=gA._gridDistance,u._gridPathCells=gA._gridPathCells,u._gridPathCellsSize=gA._gridPathCellsSize,u._gridRing=gA._gridRing,u._gridRingUnsafe=gA._gridRingUnsafe,u._i64Add=gA._i64Add,u._i64Subtract=gA._i64Subtract,u._isPentagon=gA._isPentagon,u._isResClassIII=gA._isResClassIII,u._isValidCell=gA._isValidCell,u._isValidDirectedEdge=gA._isValidDirectedEdge,u._isValidIndex=gA._isValidIndex,u._isValidVertex=gA._isValidVertex,u._latLngToCell=gA._latLngToCell,u._llvm_ctlz_i64=gA._llvm_ctlz_i64,u._llvm_maxnum_f64=gA._llvm_maxnum_f64,u._llvm_minnum_f64=gA._llvm_minnum_f64,u._llvm_round_f64=gA._llvm_round_f64,u._localIjToCell=gA._localIjToCell,u._malloc=gA._malloc,u._maxFaceCount=gA._maxFaceCount,u._maxGridDiskSize=gA._maxGridDiskSize,u._maxPolygonToCellsSize=gA._maxPolygonToCellsSize,u._maxPolygonToCellsSizeExperimental=gA._maxPolygonToCellsSizeExperimental,u._memcpy=gA._memcpy,u._memset=gA._memset,u._originToDirectedEdges=gA._originToDirectedEdges,u._pentagonCount=gA._pentagonCount,u._polygonToCells=gA._polygonToCells,u._polygonToCellsExperimental=gA._polygonToCellsExperimental,u._readInt64AsDoubleFromPointer=gA._readInt64AsDoubleFromPointer,u._res0CellCount=gA._res0CellCount,u._round=gA._round,u._sbrk=gA._sbrk,u._sizeOfCellBoundary=gA._sizeOfCellBoundary,u._sizeOfCoordIJ=gA._sizeOfCoordIJ,u._sizeOfGeoLoop=gA._sizeOfGeoLoop,u._sizeOfGeoPolygon=gA._sizeOfGeoPolygon,u._sizeOfH3Index=gA._sizeOfH3Index,u._sizeOfLatLng=gA._sizeOfLatLng,u._sizeOfLinkedGeoPolygon=gA._sizeOfLinkedGeoPolygon,u._uncompactCells=gA._uncompactCells,u._uncompactCellsSize=gA._uncompactCellsSize,u._vertexToLatLng=gA._vertexToLatLng,u.establishStackSpace=gA.establishStackSpace;var at=u.stackAlloc=gA.stackAlloc,Fe=u.stackRestore=gA.stackRestore,n0=u.stackSave=gA.stackSave;if(u.asm=gA,u.cwrap=uA,u.setValue=V,u.getValue=K,Qe){Be(Qe)||(Qe=C(Qe));{Xe();var Zt=function(rA){rA.byteLength&&(rA=new Uint8Array(rA)),LA.set(rA,H),u.memoryInitializerRequest&&delete u.memoryInitializerRequest.response,vt()},xt=function(){T(Qe,Zt,function(){throw"could not load memory initializer "+Qe})},kt=c0(Qe);if(kt)Zt(kt.buffer);else if(u.memoryInitializerRequest){var o0=function(){var rA=u.memoryInitializerRequest,pA=rA.response;if(rA.status!==200&&rA.status!==0){var IA=c0(u.memoryInitializerRequestURL);if(IA)pA=IA.buffer;else{console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+rA.status+", retrying "+Qe),xt();return}}Zt(pA)};u.memoryInitializerRequest.response?setTimeout(o0,0):u.memoryInitializerRequest.addEventListener("load",o0)}else xt()}}var wt;qe=function rA(){wt||It(),wt||(qe=rA)};function It(rA){if($e>0||(Le(),$e>0))return;function pA(){wt||(wt=!0,!aA&&(oe(),me(),u.onRuntimeInitialized&&u.onRuntimeInitialized(),ue()))}u.setStatus?(u.setStatus("Running..."),setTimeout(function(){setTimeout(function(){u.setStatus("")},1),pA()},1)):pA()}u.run=It;function dt(rA){throw u.onAbort&&u.onAbort(rA),rA+="",P(rA),_(rA),aA=!0,"abort("+rA+"). Build with -s ASSERTIONS=1 for more info."}if(u.abort=dt,u.preInit)for(typeof u.preInit=="function"&&(u.preInit=[u.preInit]);u.preInit.length>0;)u.preInit.pop()();return It(),c})(typeof Rt=="object"?Rt:{}),re="number",ee=re,zr=re,se=re,le=re,ht=re,PA=re,gf=[["sizeOfH3Index",re],["sizeOfLatLng",re],["sizeOfCellBoundary",re],["sizeOfGeoLoop",re],["sizeOfGeoPolygon",re],["sizeOfLinkedGeoPolygon",re],["sizeOfCoordIJ",re],["readInt64AsDoubleFromPointer",re],["isValidCell",zr,[se,le]],["isValidIndex",zr,[se,le]],["latLngToCell",ee,[re,re,ht,PA]],["cellToLatLng",ee,[se,le,PA]],["cellToBoundary",ee,[se,le,PA]],["maxGridDiskSize",ee,[re,PA]],["gridDisk",ee,[se,le,re,PA]],["gridDiskDistances",ee,[se,le,re,PA,PA]],["gridRing",ee,[se,le,re,PA]],["gridRingUnsafe",ee,[se,le,re,PA]],["maxPolygonToCellsSize",ee,[PA,ht,re,PA]],["polygonToCells",ee,[PA,ht,re,PA]],["maxPolygonToCellsSizeExperimental",ee,[PA,ht,re,PA]],["polygonToCellsExperimental",ee,[PA,ht,re,re,re,PA]],["cellsToLinkedMultiPolygon",ee,[PA,re,PA]],["destroyLinkedMultiPolygon",null,[PA]],["compactCells",ee,[PA,PA,re,re]],["uncompactCells",ee,[PA,re,re,PA,re,ht]],["uncompactCellsSize",ee,[PA,re,re,ht,PA]],["isPentagon",zr,[se,le]],["isResClassIII",zr,[se,le]],["getBaseCellNumber",re,[se,le]],["getResolution",re,[se,le]],["getIndexDigit",re,[se,le,re]],["constructCell",ee,[re,re,PA,PA]],["maxFaceCount",ee,[se,le,PA]],["getIcosahedronFaces",ee,[se,le,PA]],["cellToParent",ee,[se,le,ht,PA]],["cellToChildren",ee,[se,le,ht,PA]],["cellToCenterChild",ee,[se,le,ht,PA]],["cellToChildrenSize",ee,[se,le,ht,PA]],["cellToChildPos",ee,[se,le,ht,PA]],["childPosToCell",ee,[re,re,se,le,ht,PA]],["areNeighborCells",ee,[se,le,se,le,PA]],["cellsToDirectedEdge",ee,[se,le,se,le,PA]],["getDirectedEdgeOrigin",ee,[se,le,PA]],["getDirectedEdgeDestination",ee,[se,le,PA]],["isValidDirectedEdge",zr,[se,le]],["directedEdgeToCells",ee,[se,le,PA]],["originToDirectedEdges",ee,[se,le,PA]],["directedEdgeToBoundary",ee,[se,le,PA]],["gridDistance",ee,[se,le,se,le,PA]],["gridPathCells",ee,[se,le,se,le,PA]],["gridPathCellsSize",ee,[se,le,se,le,PA]],["cellToLocalIj",ee,[se,le,se,le,re,PA]],["localIjToCell",ee,[se,le,PA,re,PA]],["getHexagonAreaAvgM2",ee,[ht,PA]],["getHexagonAreaAvgKm2",ee,[ht,PA]],["getHexagonEdgeLengthAvgM",ee,[ht,PA]],["getHexagonEdgeLengthAvgKm",ee,[ht,PA]],["greatCircleDistanceM",re,[PA,PA]],["greatCircleDistanceKm",re,[PA,PA]],["greatCircleDistanceRads",re,[PA,PA]],["cellAreaM2",ee,[se,le,PA]],["cellAreaKm2",ee,[se,le,PA]],["cellAreaRads2",ee,[se,le,PA]],["edgeLengthM",ee,[se,le,PA]],["edgeLengthKm",ee,[se,le,PA]],["edgeLengthRads",ee,[se,le,PA]],["getNumCells",ee,[ht,PA]],["getRes0Cells",ee,[PA]],["res0CellCount",re],["getPentagons",ee,[re,PA]],["pentagonCount",re],["cellToVertex",ee,[se,le,re,PA]],["cellToVertexes",ee,[se,le,PA]],["vertexToLatLng",ee,[se,le,PA]],["isValidVertex",zr,[se,le]]],pf=0,yf=1,xf=2,wf=3,vf=4,kf=5,bf=6,Cf=7,Ef=8,Sf=9,Mf=10,Bf=11,Df=12,_f=13,Tf=14,Rf=15,jf=16,If=17,Lf=18,Nf=19,rt={};rt[pf]="Success";rt[yf]="The operation failed but a more specific error is not available";rt[xf]="Argument was outside of acceptable range";rt[wf]="Latitude or longitude arguments were outside of acceptable range";rt[vf]="Resolution argument was outside of acceptable range";rt[kf]="Cell argument was not valid";rt[bf]="Directed edge argument was not valid";rt[Cf]="Undirected edge argument was not valid";rt[Ef]="Vertex argument was not valid";rt[Sf]="Pentagon distortion was encountered";rt[Mf]="Duplicate input";rt[Bf]="Cell arguments were not neighbors";rt[Df]="Cell arguments had incompatible resolutions";rt[_f]="Memory allocation failed";rt[Tf]="Bounds of provided memory were insufficient";rt[Rf]="Mode or flags argument was not valid";rt[jf]="Index argument was not valid";rt[If]="Base cell number was outside of acceptable range";rt[Lf]="Child indexing digits invalid";rt[Nf]="Child indexing digits refer to a deleted subsequence";var Ff=1e3,Pf=1001,$s=1002,Wn={};Wn[Ff]="Unknown unit";Wn[Pf]="Array length out of bounds";Wn[$s]="Got unexpected null value for H3 index";var Qf="Unknown error";function qs(c,u,g){var y=g&&"value"in g,x=new Error((c[u]||Qf)+" (code: "+u+(y?", value: "+g.value:"")+")");return x.code=u,x}function Of(c,u){var g=arguments.length===2?{value:u}:{};return qs(rt,c,g)}function zf(c,u){var g=arguments.length===2?{value:u}:{};return qs(Wn,c,g)}function Js(c){if(c!==0)throw Of(c)}var w0={};gf.forEach(function(u){w0[u[0]]=Rt.cwrap.apply(Rt,u)});var Gr=16,Hf=4,Gn=8,Do=w0.sizeOfH3Index(),Gf=w0.sizeOfLatLng(),Uf=w0.sizeOfCellBoundary();w0.sizeOfGeoPolygon();w0.sizeOfGeoLoop();w0.sizeOfLinkedGeoPolygon();w0.sizeOfCoordIJ();function Vf(c){if(!c)throw zf($s);return c}var Wf=/[^0-9a-fA-F]/;function Yf(c){if(Array.isArray(c)&&c.length===2&&Number.isInteger(c[0])&&Number.isInteger(c[1]))return c;if(typeof c!="string"||Wf.test(c))return[0,0];var u=parseInt(c.substring(0,c.length-8),Gr),g=parseInt(c.substring(c.length-8),Gr);return[g,u]}function Gi(c){if(c>=0)return c.toString(Gr);c=c&2147483647;var u=Xs(8,c.toString(Gr)),g=(parseInt(u[0],Gr)+8).toString(Gr);return u=g+u.substring(1),u}function Kf(c,u){return Gi(u)+Xs(8,Gi(c))}function Xs(c,u){for(var g=c-u.length,y="",x=0;x.85?.9+(c-.85)/.15*.1:.1+(c-.15)/.7*.8}function tl(c,u,g,y){const x=g-u;if(x<.001)return Vi(y[12]);const C=Math.max(0,Math.min(1,(c-u)/x)),T=s2(C),P=Math.min(23,Math.floor(T*24));return Vi(y[P])}function l2(c){const u=new Map;for(const C of c){if(typeof C.lat!="number"||typeof C.lon!="number"||isNaN(C.lat)||isNaN(C.lon))continue;const T=Jf(C.lat,C.lon,e2),P=u.get(T),_=C.weight;P?(P.count++,P.qualitySum+=_):u.set(T,{count:1,qualitySum:_})}const g=[];let y=1/0,x=-1/0;for(const[C,T]of u.entries()){const P=T.qualitySum/T.count;g.push({hexId:C,count:T.count,avgQuality:P}),y=Math.min(y,P),x=Math.max(x,P)}return{cells:g,minQuality:g.length>0?y:0,maxQuality:g.length>0?x:0}}function a2(c,u,g,y){const x=[];for(const C of c){const P=Al(C.hexId).map(([E,Q])=>[Q,E]);P.push(P[0]);const _=tl(C.avgQuality,u,g,y);x.push({type:"Feature",properties:{color:_,quality:C.avgQuality,count:C.count},geometry:{type:"Polygon",coordinates:[P]}})}return{type:"FeatureCollection",features:x}}async function u2(c,u,g,y,x){const C=[];let T=0;for(;T[V,H]);Q.push(Q[0]);const O=tl(_.avgQuality,u,g,y);C.push({type:"Feature",properties:{color:O,quality:_.avgQuality,count:_.count},geometry:{type:"Polygon",coordinates:[Q]}})}TrequestAnimationFrame(_))}return{type:"FeatureCollection",features:C}}function c2(c,u){const[g,y]=R.useState(c);return R.useEffect(()=>{const x=setTimeout(()=>y(c),u);return()=>clearTimeout(x)},[c,u]),g}function f2({coveragePoints:c,visible:u,terrainEnabled:g=!1,brightness:y=t2,basemapMode:x="dark"}){const{current:C}=Ar(),[T,P]=R.useState(null);R.useEffect(()=>{const Z=()=>{var iA;const vA=(iA=C==null?void 0:C.getMap)==null?void 0:iA.call(C);vA&&!T&&P(vA)};Z();const uA=setInterval(Z,50),oA=setTimeout(()=>clearInterval(uA),5e3);return()=>{clearInterval(uA),clearTimeout(oA)}},[C,T]);const[_,E]=R.useState(null),[Q,O]=R.useState(!1),H=R.useRef({aborted:!1}),V=R.useRef(0),K=R.useRef(x),aA=c2(c,r2),J=R.useMemo(()=>i2(x),[x]);R.useEffect(()=>{if(!aA||!Array.isArray(aA)||aA.length===0){queueMicrotask(()=>{E(null),V.current=0});return}const Z=K.current!==x;if(aA.length===V.current&&_&&!Z)return;V.current=aA.length,K.current=x,H.current.aborted=!0,H.current={aborted:!1};const uA=H.current;O(!0);const{cells:oA,minQuality:vA,maxQuality:iA}=l2(aA);if(oA.length===0){E(null),O(!1);return}if(oA.length{!uA.aborted&&fA&&E(fA)}).finally(()=>{uA.aborted||O(!1)}),()=>{uA.aborted=!0}},[aA,J]),R.useEffect(()=>{if(!T)return;const Z=()=>{var uA,oA;try{const vA=T.getLayer(dr),iA=T.getSource(hr);if(u&&_&&_.features.length>0){if(iA?T.getSource(hr).setData(_):T.addSource(hr,{type:"geojson",data:_}),!vA){const fA=T.getLayer("topology-weak-edges-native"),jA=(oA=(uA=T.getStyle())==null?void 0:uA.layers)==null?void 0:oA.find(CA=>CA.type==="symbol"),DA=fA?"topology-weak-edges-native":jA==null?void 0:jA.id;T.addLayer({id:dr,type:"fill",source:hr,paint:{"fill-color":["get","color"],"fill-opacity":y}},DA)}}else vA&&T.removeLayer(dr),iA&&T.removeSource(hr)}catch(vA){console.warn("[WardrivingHexLayerMapLibre] Layer update error:",vA)}};T.isStyleLoaded()?Z():T.once("style.load",Z)},[T,u,_,g]),R.useEffect(()=>{if(!(!T||!u))try{T.getLayer(dr)&&T.setPaintProperty(dr,"fill-opacity",y)}catch{}},[T,y,u]),R.useEffect(()=>()=>{if(T)try{T.getLayer(dr)&&T.removeLayer(dr),T.getSource(hr)&&T.removeSource(hr)}catch{}},[T]);const eA=(_==null?void 0:_.features.length)??0;return eA>0&&u?p.jsx("div",{"data-testid":"wardriving-hexlayer-maplibre-active","data-point-count":(c==null?void 0:c.length)||0,"data-cell-count":eA,"data-terrain-enabled":g,"data-is-processing":Q,style:{display:"none"}}):null}const Wi="https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png",Yi="terrarium",Ki=256,Zi=14,ln={shadowColor:"rgba(10, 10, 10, 0.6)",highlightColor:"rgba(245, 240, 230, 0.4)",accentColor:"rgba(90, 75, 65, 0.3)",illuminationDirection:315,exaggeration:.35},Z0="terrain-dem",Hr="hillshade-dem",Ln="terrain-hillshade";function h2({enabled:c,exaggeration:u=4}){const{current:g}=Ar(),[y,x]=R.useState(null),C=R.useRef(null);return R.useEffect(()=>{const T=()=>{var Q;const E=(Q=g==null?void 0:g.getMap)==null?void 0:Q.call(g);E&&!y&&x(E)};T();const P=setInterval(T,50),_=setTimeout(()=>clearInterval(P),5e3);return()=>{clearInterval(P),clearTimeout(_)}},[g,y]),R.useEffect(()=>{if(!y)return;let T=!0;const P=()=>{var _,E;if(T)try{if(y.getSource(Hr)||y.addSource(Hr,{type:"raster-dem",tiles:[Wi],encoding:Yi,tileSize:Ki,maxzoom:Zi}),!y.getLayer(Ln)){const Q=(E=(_=y.getStyle())==null?void 0:_.layers)==null?void 0:E.find(O=>O.type==="symbol");y.addLayer({id:Ln,type:"hillshade",source:Hr,paint:{"hillshade-shadow-color":ln.shadowColor,"hillshade-highlight-color":ln.highlightColor,"hillshade-accent-color":ln.accentColor,"hillshade-illumination-direction":ln.illuminationDirection,"hillshade-exaggeration":ln.exaggeration}},Q==null?void 0:Q.id)}y.getSource(Z0)||y.addSource(Z0,{type:"raster-dem",tiles:[Wi],encoding:Yi,tileSize:Ki,maxzoom:Zi})}catch(Q){console.error("[TerrainLayer] Source/layer setup error:",Q)}};return y.isStyleLoaded()?P():(y.once("style.load",P),y.once("load",()=>{T&&!y.getSource(Hr)&&P()})),()=>{T=!1}},[y]),R.useEffect(()=>{if(!y)return;let T=!0,P=!1;const _=()=>{if(!(!T||!y.getSource(Z0)))try{c?(y.setCenterClampedToGround(!1),y.setTerrain({source:Z0,exaggeration:u}),y.setMaxPitch(70),!P&&y.getPitch()<30&&!y.isMoving()&&(P=!0,C.current!==null&&clearTimeout(C.current),C.current=window.setTimeout(()=>{C.current=null,T&&!y.isMoving()&&y.getPitch()<30&&y.easeTo({pitch:45,duration:1e3})},200))):(y.setTerrain(null),y.setCenterClampedToGround(!0),y.getPitch()>0&&!y.isMoving()&&y.easeTo({pitch:0,duration:800}),y.setMaxPitch(60))}catch(E){console.error("[TerrainLayer] Terrain state error:",E)}};if(y.isStyleLoaded()&&y.getSource(Z0))_();else{const E=()=>{y.getSource(Z0)&&_()};y.once("idle",E)}return()=>{T=!1,C.current!==null&&(clearTimeout(C.current),C.current=null)}},[y,c,u]),R.useEffect(()=>()=>{var T;try{(T=y==null?void 0:y.getStyle)!=null&&T.call(y)&&y.isStyleLoaded()&&(y.setTerrain(null),y.getLayer(Ln)&&y.removeLayer(Ln),y.getSource(Hr)&&y.removeSource(Hr),y.getSource(Z0)&&y.removeSource(Z0))}catch{}},[y]),null}const d2=.03,m2=.1,g2=2,p2=3,y2=.02,x2=3;function w2(c,u=x2){if(c.length<3||u<=0)return c;let g=c;for(let y=0;y0&&x.push([x[0][0],x[0][1]]),g=x}return g}function v2(c,u){let g=1/0,y=-1/0,x=1/0,C=-1/0;for(const[T,P]of c)Ty&&(y=T),PC&&(C=P);return g-=u,y+=u,x-=u,C+=u,{minX:g,minY:x,maxX:y,maxY:C,width:y-g,height:C-x}}function k2(c,u={}){if(c.length(eA-C.minX)/C.width*Q,V=eA=>(eA-C.minY)/C.height*O,K=eA=>eA/Q*C.width+C.minX,aA=eA=>eA/O*C.height+C.minY,J=g/C.width*Q;try{const Z=rc().x(DA=>H(DA[0])).y(DA=>V(DA[1])).size([Q,O]).bandwidth(Math.max(5,J)).cellSize(x)(c);if(Z.length===0)return{coordinates:[],valid:!1};const oA=Math.max(...Z.map(DA=>DA.value))*y;let vA=Z[0],iA=1/0;for(const DA of Z){const CA=Math.abs(DA.value-oA);CA0){const LA=kA[0],NA=kA[kA.length-1];(LA[0]!==NA[0]||LA[1]!==NA[1])&&kA.push([LA[0],LA[1]])}if(kA.length>=4){const LA=w2(kA);CA.push(LA)}}CA.length>0&&fA.push(CA)}const jA=[];for(const DA of fA)for(const CA of DA)jA.push(CA);return{coordinates:fA,valid:fA.length>0}}catch(eA){return console.warn("[KDE Contour] Failed to generate contour:",eA),{coordinates:[],valid:!1}}}function b2(c,u={}){const g=k2(c,u);return!g.valid||g.coordinates.length===0?null:g.coordinates.length===1?{type:"Polygon",coordinates:g.coordinates[0]}:{type:"MultiPolygon",coordinates:g.coordinates}}const C2="mincut-partition",E2="mincut-partition-fill",S2="mincut-partition-stroke",M2=3,B2=.05,D2=.15,_2=.008,$i=12;function qi(c,u,g){return(u[0]-c[0])*(g[1]-c[1])-(u[1]-c[1])*(g[0]-c[0])}function T2(c){if(c.length<3)return c;const u=[...c].sort((x,C)=>x[0]-C[0]||x[1]-C[1]),g=[];for(const x of u){for(;g.length>=2&&qi(g[g.length-2],g[g.length-1],x)<=0;)g.pop();g.push(x)}const y=[];for(let x=u.length-1;x>=0;x--){const C=u[x];for(;y.length>=2&&qi(y[y.length-2],y[y.length-1],C)<=0;)y.pop();y.push(C)}return g.pop(),y.pop(),g.concat(y)}function R2(c,u){if(c.length<3)return c;let g=0,y=0;for(const[x,C]of c)g+=x,y+=C;return g/=c.length,y/=c.length,c.map(([x,C])=>{const T=x-g,P=C-y,_=Math.sqrt(T*T+P*P);if(_<1e-4)return[x,C];const E=(_+u)/_;return[g+T*E,y+P*E]})}function j2(c,u,g,y,x){const C=x*x,T=C*x;return[.5*(2*u[0]+(-c[0]+g[0])*x+(2*c[0]-5*u[0]+4*g[0]-y[0])*C+(-c[0]+3*u[0]-3*g[0]+y[0])*T),.5*(2*u[1]+(-c[1]+g[1])*x+(2*c[1]-5*u[1]+4*g[1]-y[1])*C+(-c[1]+3*u[1]-3*g[1]+y[1])*T)]}function I2(c){if(c.length<3)return c;const u=[],g=c.length;for(let y=0;yc?N2(c,u,x,C):{type:"FeatureCollection",features:[]},[c,u,x,C]),_=g?y:0,E={"fill-color":["get","color"],"fill-opacity":_},Q={"line-color":["get","borderColor"],"line-width":T,"line-opacity":_};return p.jsxs(X0,{id:C2,type:"geojson",data:P,children:[p.jsx(t0,{id:E2,type:"fill",paint:E}),p.jsx(t0,{id:S2,type:"line",paint:Q})]})}function P2(c,u=!1,g=!1,y=!1,x=.7,C){const T=gs(C);return y?x>=.75?T.restBright:T.rest:x>=.85?T.rest:(x>=.7,T.restDim)}function Ji(c){return[c[1],c[0]]}function Q2(c,u,g,y=12){const[x,C]=c,[T,P]=u,_=[];for(let E=0;E<=y;E++){const Q=E/y,O=C+(P-C)*Q,H=x+(T-x)*Q,V=4*g*Q*(1-Q);_.push([O,H,V])}return _}function Xi(c,u,g,y,x,C,T,P,_,E,Q,O="dark"){const H=Uo(),V=[];let K=1/0,aA=-1/0;const J=[];for(const Z of c){const uA=Z.edge.avgConfidence??(u?.7:.5),oA=Z.edge.certainCount/Math.max(T,1),vA=uA*.7+oA*.3+(u?.5:0);J.push({polyline:Z,brightnessScore:vA}),K=Math.min(K,vA),aA=Math.max(aA,vA)}if(J.length===0)return{type:"FeatureCollection",features:[]};const eA=aA-K||1;J.sort((Z,uA)=>Z.brightnessScore-uA.brightnessScore);for(const{polyline:Z,brightnessScore:uA}of J){const{from:oA,to:vA,edge:iA}=Z,fA=g.get(iA.key)??0;if(fA<=0)continue;const jA=P.has(iA.key),DA=_.has(iA.key),CA=iA.avgConfidence??(u?.7:.5),yA=E===iA.key,kA=Q[iA.fromHash],LA=Q[iA.toHash],NA=(kA==null?void 0:kA.node_name)||(kA==null?void 0:kA.name)||iA.fromHash.slice(0,8),GA=(LA==null?void 0:LA.node_name)||(LA==null?void 0:LA.name)||iA.toHash.slice(0,8),bA=[oA[0]+(vA[0]-oA[0])*fA,oA[1]+(vA[1]-oA[1])*fA];let cA;if(!u)cA=1.5;else{const ae=C.get(iA.key)??Co(iA.certainCount),JA=x.get(iA.key)??ae;cA=JA+(ae-JA)*y,yA?cA=Math.max(cA*1.6,4.5):DA&&(cA=cA*1.3)}let sA;yA?sA=H.edges.highlight:sA=P2(!1,iA.isDirectPathEdge??!1,jA,DA,CA,O);let TA;yA?TA=H.edges.highlight:iA.isDirectPathEdge?TA=H.edges.hoverDirect:jA?TA=H.edges.hoverLoop:TA=H.edges.hoverStandard;let MA;if(!u)MA=(.3+CA*.3)*fA;else{const ae=Math.min(fA*1.5,1)*H.edgeOpacity;MA=DA?ae*1.15:ae}yA&&(MA=.95);const WA=(uA-K)/eA;V.push({type:"Feature",properties:{key:iA.key,baseColor:sA,hoverColor:TA,baseWidth:cA,baseOpacity:MA,brightnessScore:WA,isLoopEdge:jA,isBackbone:DA,isDirectPath:iA.isDirectPathEdge??!1,isHubConnection:iA.isHubConnection??!1,isZeroHop:iA.isZeroHop??!1,isValidated:u,certainCount:iA.certainCount,confidence:CA,symmetryRatio:iA.symmetryRatio??1,dominantDirection:iA.dominantDirection??"balanced",fromName:NA,toName:GA,fromHash:iA.fromHash,toHash:iA.toHash},geometry:{type:"LineString",coordinates:[Ji(oA),Ji(bA)]}})}return{type:"FeatureCollection",features:V}}const O2=150,z2=8;function As(c,u){const g=Uo(),y=[];let x=0;for(const C of c){const T=u.get(C.hash);T&&T.blendedScore>x&&(x=T.blendedScore)}for(const C of c){const{from:T,to:P,hash:_,neighbor:E,lastHopData:Q}=C,O=`neighbor-${_}`,H=(Q==null?void 0:Q.avgRssi)??E.rssi??null,V=(Q==null?void 0:Q.avgSnr)??E.snr??null,K=(Q==null?void 0:Q.count)??0,aA=(Q==null?void 0:Q.confidence)??1,J=u.get(_),eA=(J==null?void 0:J.listenerScore)??0,Z=(J==null?void 0:J.loudScore)??0,uA=(J==null?void 0:J.blendedScore)??0,oA=x>0?uA/x:0,vA=C.rxAdvertCount??0,iA=C.txProxyCount??0,fA=vA+iA,jA=fA>0?(iA-vA)/fA:0,DA=Q2(T,P,O2,z2);y.push({type:"Feature",properties:{key:O,hash:_,name:E.node_name||E.name||_.slice(0,8),prefix:_.slice(2,4).toUpperCase(),color:g.neighborColor,width:2.5,opacity:.85,rssi:H,snr:V,packetCount:K,confidence:aA,hasAvgRssi:(Q==null?void 0:Q.avgRssi)!==void 0,hasAvgSnr:(Q==null?void 0:Q.avgSnr)!==void 0,isNeighborEdge:!0,listenerScore:eA,loudScore:Z,blendedScore:uA,trafficWeight:oA,linkAsymmetry:jA,rxAdvertCount:vA,txProxyCount:iA},geometry:{type:"LineString",coordinates:DA}})}return{type:"FeatureCollection",features:y}}function H2({map:c,showTopology:u,validatedPolylines:g,weakPolylines:y,maxCertainCount:x,loopEdgeKeys:C,backboneEdgeKeys:T,highlightedEdgeKey:P,neighbors:_,validatedSourceId:E,weakSourceId:Q,neighborPolylines:O=[],showNeighborLines:H=!0,neighborSourceId:V,neighborLinkScores:K=new Map,basemapMode:aA}){const J=R.useRef(null);R.useEffect(()=>{const oe=c&&"current"in c?c.current:c;J.current=oe});const eA=R.useRef(new Map),Z=R.useRef(1),uA=R.useRef(new Map),oA=R.useRef(new Map),vA=R.useRef(!1),iA=R.useRef(null),fA=R.useRef(u),jA=R.useRef(new Set),DA=R.useRef(""),CA=R.useRef(new Map),yA=R.useRef(""),kA=R.useRef(""),LA=R.useRef(""),NA=R.useRef(g),GA=R.useRef(y),bA=R.useRef(x),cA=R.useRef(C),sA=R.useRef(T),TA=R.useRef(P),MA=R.useRef(_),WA=R.useRef(O),ae=R.useRef(H),JA=R.useRef(K),ZA=R.useRef(aA);R.useEffect(()=>{NA.current=g,GA.current=y,bA.current=x,cA.current=C,sA.current=T,TA.current=P,MA.current=_,WA.current=O,ae.current=H,JA.current=K,ZA.current=aA},[g,y,x,C,T,P,_,O,H,K,aA]);const UA=R.useCallback((oe=!1)=>{var Ce,Se,pe,Ke,$e,qe,Xe,vt,Qe,Je;const me=J.current;if(!me)return;const ue=me.getSource(E),Ye=me.getSource(Q),be=me.getSource(V);if(ue){const Be=Xi(NA.current,!0,eA.current,Z.current,uA.current,oA.current,bA.current,cA.current,sA.current,TA.current,MA.current,ZA.current),ze=`${Be.features.length}:${((Se=(Ce=Be.features[0])==null?void 0:Ce.properties)==null?void 0:Se.key)??""}:${((Ke=(pe=Be.features[Be.features.length-1])==null?void 0:pe.properties)==null?void 0:Ke.key)??""}:${Array.from(eA.current.values()).reduce((st,jt)=>st+jt,0).toFixed(2)}`;(oe||ze!==yA.current)&&(ue.setData(Be),yA.current=ze)}if(Ye){const Be=Xi(GA.current,!1,eA.current,Z.current,uA.current,oA.current,bA.current,cA.current,sA.current,TA.current,MA.current,ZA.current),ze=`${Be.features.length}:${((qe=($e=Be.features[0])==null?void 0:$e.properties)==null?void 0:qe.key)??""}:${((vt=(Xe=Be.features[Be.features.length-1])==null?void 0:Xe.properties)==null?void 0:vt.key)??""}`;(oe||ze!==kA.current)&&(Ye.setData(Be),kA.current=ze)}if(be&&WA.current.length>0){const Be=As(WA.current,JA.current),ze=`${Be.features.length}:${((Je=(Qe=Be.features[0])==null?void 0:Qe.properties)==null?void 0:Je.hash)??""}`;(oe||ze!==LA.current)&&(be.setData(Be),LA.current=ze)}},[E,Q,V]),Ie=R.useCallback(()=>{iA.current&&(cancelAnimationFrame(iA.current),iA.current=null),eA.current=new Map,Z.current=1,uA.current=new Map,oA.current=new Map,vA.current=!1,jA.current=new Set,DA.current="",CA.current=new Map},[]);R.useEffect(()=>{const oe=fA.current,me=u;if(fA.current=u,!!J.current){if(iA.current&&(cancelAnimationFrame(iA.current),iA.current=null),oe&&!me&&!vA.current){vA.current=!0;const Ye=new Map(eA.current);let be=null;const Ce=Se=>{be||(be=Se);const pe=Se-be,Ke=Math.min(pe/ic,1),$e=Ns(Ke);for(const[qe,Xe]of Ye)eA.current.set(qe,Xe*(1-$e));UA(!0),Ke<1?iA.current=requestAnimationFrame(Ce):(vA.current=!1,eA.current=new Map,jA.current=new Set,DA.current="",uA.current=new Map,oA.current=new Map,iA.current=null,UA(!0))};iA.current=requestAnimationFrame(Ce)}!oe&&me&&(eA.current=new Map,jA.current=new Set,DA.current="")}},[u,UA]),R.useEffect(()=>{const oe=J.current;if(!u||vA.current||!oe)return;const me=[...g,...y],ue=me.map(pe=>`${pe.edge.key}:${pe.edge.certainCount}`).sort().join(","),Ye=jA.current.size===0,be=DA.current!==""&&DA.current!==ue;if(!Ye&&!be){UA();return}const Ce=[],Se=[];for(const{edge:pe}of me)jA.current.has(pe.key)?Se.push(pe.key):Ce.push(pe.key);be&&Se.length>0&&(uA.current=new Map(CA.current),Z.current=0),oA.current=new Map;for(const{edge:pe}of g){const Ke=Co(pe.certainCount);oA.current.set(pe.key,Ke)}for(const pe of Ce)eA.current.set(pe,0);for(const pe of Se)eA.current.has(pe)||eA.current.set(pe,1);if(Ce.length>0||be&&Se.length>0){iA.current&&(cancelAnimationFrame(iA.current),iA.current=null);let pe=null;const Ke=Math.min(100,Mn/Math.max(Ce.length,1)/2),$e=qe=>{pe||(pe=qe);const Xe=qe-pe;for(let Qe=0;Qe0){const Qe=Math.min(Xe/Mn,1);Z.current=ko(Qe)}UA(!0);const vt=Mn+(Ce.length-1)*Ke;Xe{const oe=J.current;if(!oe||!V)return;const me=()=>{const be=oe.getSource(V);if(!be)return!1;if(O.length>0){const Ce=As(O,K);be.setData(Ce)}else be.setData({type:"FeatureCollection",features:[]});return!0};if(me())return;const ue=be=>{be.sourceId===V&&me()&&oe.off("sourcedata",ue)};oe.on("sourcedata",ue);const Ye=()=>{me()&&(oe.off("styledata",Ye),oe.off("sourcedata",ue))};return oe.on("styledata",Ye),()=>{oe.off("sourcedata",ue),oe.off("styledata",Ye)}},[V,O,K]);const Le=R.useRef(aA);return R.useEffect(()=>{aA!==Le.current&&(Le.current=aA,yA.current="",kA.current="",LA.current="",UA(!0))},[aA,UA]),R.useEffect(()=>()=>{iA.current&&(cancelAnimationFrame(iA.current),iA.current=null)},[]),{isExiting:vA.current,isAnimating:iA.current!==null,resetAnimationState:Ie,weightAnimProgress:Z.current,animStartWeights:uA.current,animTargetWeights:oA.current}}function G2({activeFilters:c,neighborHashes:u,hubConnectedNodes:g,directNodeSet:y,localConnectedNodes:x,nodeTypeMap:C,showTopology:T}){const[P,_]=R.useState(new Map),E=R.useMemo(()=>[...c].sort().join(","),[c]),Q=R.useRef(E),O=R.useRef(!1),H=R.useRef(new Map),V=R.useRef(null),K=R.useRef(g),aA=R.useRef(y),J=R.useRef(x),eA=R.useRef(C),Z=R.useRef(T);return R.useEffect(()=>{K.current=g,aA.current=y,J.current=x,eA.current=C,Z.current=T},[g,y,x,C,T]),R.useEffect(()=>{const oA=Q.current,vA=E;if(Q.current=E,oA===vA)return;V.current&&(cancelAnimationFrame(V.current),V.current=null);const iA=new Set(oA?oA.split(",").filter(Boolean):[]),fA=c,jA=K.current,DA=aA.current,CA=eA.current;for(const bA of u)H.current.has(bA)||H.current.set(bA,Math.random());const yA=(bA,cA)=>{if(cA.size===0)return!1;const sA=CA.get(bA)??"unknown";return!!(cA.has("repeater")&&sA==="repeater"||cA.has("companion")&&(sA==="companion"||sA==="unknown")||cA.has("room_server")&&sA==="room_server"||cA.has("direct")&&DA.has(bA)||cA.has("hubs")&&jA.has(bA))},kA=[];for(const bA of u){const cA=yA(bA,iA),sA=yA(bA,fA);cA!==sA&&kA.push({hash:bA,startOpacity:cA?1:0,targetOpacity:sA?1:0})}if(kA.length===0)return;O.current=!0,_(bA=>{const cA=new Map(bA);for(const{hash:sA,startOpacity:TA}of kA)cA.set(sA,TA);return cA});const LA=kA;let NA=null;const GA=bA=>{NA||(NA=bA);const cA=bA-NA;let sA=!0;_(()=>{const MA=new Map;for(const{hash:WA,startOpacity:ae,targetOpacity:JA}of LA){const ZA=(H.current.get(WA)??0)*Mi,UA=Math.max(0,cA-ZA),Ie=Math.min(UA/Si,1),Le=ko(Ie),oe=ae+(JA-ae)*Le;MA.set(WA,oe),Ie<1&&(sA=!1)}return MA});const TA=Si+Mi;cA{V.current&&(cancelAnimationFrame(V.current),V.current=null),O.current=!1}},[E,c,u]),{nodeOpacities:P,getNodeOpacity:(oA,vA)=>O.current&&P.has(oA)?P.get(oA):vA?1:0}}const po=240,es=240;function U2(c,u){if(c{T.current=C},[C]);const P=R.useRef(0),_=R.useRef(null),E=R.useRef(new Map),Q=R.useRef(new Map);R.useEffect(()=>{Q.current=V2(c)},[c]);const O=R.useRef(null);return R.useEffect(()=>{const H=()=>{const V=performance.now(),K=E.current;if(K.size===0){_.current=null,x(new Map);return}const aA=new Map,J=[];for(const[eA,{startTime:Z,staggerDelay:uA}]of K){const oA=V-Z-uA;if(!(oA<0))if(oA>=Bn)J.push(eA);else{const vA=U2(oA,Bn);vA>0&&aA.set(eA,vA)}}for(const eA of J)K.delete(eA);x(aA),K.size>0&&O.current?_.current=requestAnimationFrame(O.current):_.current=null};O.current=H},[]),R.useEffect(()=>{if(!g)return;const H=T.current;if(H.length===0)return;const V=P.current,K=H.filter(Z=>(Z.timestamp??0)>V);if(V===0){const Z=H.reduce((uA,oA)=>Math.max(uA,oA.timestamp??0),0);P.current=Z;return}if(K.length===0)return;const aA=K.reduce((Z,uA)=>Math.max(Z,uA.timestamp??0),0);P.current=aA;const J=performance.now();let eA=0;for(const Z of K){const uA=Es(Z,u);if(!uA||uA.original.length===0)continue;const oA=W2(uA.original,Q.current,u);if(oA.length===0)continue;const vA=Bn*.5;for(let iA=0;iA()=>{_.current!==null&&(cancelAnimationFrame(_.current),_.current=null)},[]),{blinkingNodes:y,blinkColor:oc}}const $0="edge-blink-source",pr="edge-blink-layer",_o=1e3,To=1e3,yo=150,K2=175,Z2=3e4,$2=e0.teal,q2="#8B7BAD",J2=2.5,X2=1.875,A1=.5,Un="node-markers-layer";function e1(c){if(!c.getLayer(pr))return;const u=c.getLayer(Un)?Un:void 0;try{c.moveLayer(pr,u)}catch{}}function t1(c,u){const g=new Map;for(const y of Object.keys(c)){const x=hn(y);g.has(x)||g.set(x,y)}if(u){const y=hn(u);g.set(y,u)}return g}function r1(c){return c<0||c>=_o?0:1-c/_o}function n1(c){if(c<0||c>=To)return 0;const u=c/To;return Math.pow(1-u,3)}function Nn(c){return[c[1],c[0]]}function o1({map:c,nodeCoordinates:u,packets:g,localHash:y,neighbors:x,meshTopology:C,enabled:T=!0}){const P=R.useRef(null),_=c&&"current"in c?c.current:c;R.useEffect(()=>{P.current=_},[_]);const E=R.useRef(!1),Q=R.useRef(null),O=R.useRef([]),H=R.useRef(0),V=R.useRef(!1),[K,aA]=R.useState(!1),J=R.useRef(null),eA=R.useRef([]),Z=R.useRef(new Map),uA=R.useRef(u);R.useEffect(()=>{uA.current=u},[u]),R.useEffect(()=>{Z.current=t1(x,y)},[x,y]),R.useEffect(()=>{if(!T){J.current&&(clearTimeout(J.current),J.current=null),eA.current=[],Q.current!==null&&(cancelAnimationFrame(Q.current),Q.current=null),O.current=[];const fA=P.current;if(fA&&E.current){const jA=fA.getSource($0);jA&&jA.setData({type:"FeatureCollection",features:[]})}V.current=!1,H.current=0}},[T]),R.useEffect(()=>{const fA=_;if(!fA)return;let jA=null,DA=!1;const CA=()=>{if(!DA&&!E.current)try{fA.getLayer(pr)&&fA.removeLayer(pr),fA.getSource($0)&&fA.removeSource($0),fA.addSource($0,{type:"geojson",data:{type:"FeatureCollection",features:[]}});const yA=fA.getLayer(Un)?Un:void 0;fA.addLayer({id:pr,type:"line",source:$0,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":["case",["any",["==",["get","isSpeculative"],!0],["==",["get","isSpeculative"],"true"]],q2,$2],"line-width":["case",["any",["==",["get","isSpeculative"],!0],["==",["get","isSpeculative"],"true"]],X2,J2],"line-opacity":["*",["get","opacityMult"],["interpolate",["linear"],["get","intensity"],0,0,.1,.8,.5,1,1,1]]}},yA),E.current=!0,aA(!0),jA&&(clearInterval(jA),jA=null)}catch{}};return fA.isStyleLoaded()&&CA(),fA.once("style.load",()=>{CA()}),E.current||(jA=setInterval(()=>{if(E.current){jA&&clearInterval(jA);return}CA()},100),setTimeout(()=>{jA&&(clearInterval(jA),jA=null)},5e3)),()=>{DA=!0,jA&&clearInterval(jA),Q.current!==null&&(cancelAnimationFrame(Q.current),Q.current=null);const yA=P.current;if(yA&&E.current){try{yA.getLayer(pr)&&yA.removeLayer(pr),yA.getSource($0)&&yA.removeSource($0)}catch{}E.current=!1,aA(!1)}}},[_]);const oA=R.useRef(()=>{});R.useEffect(()=>{oA.current=()=>{const fA=P.current;if(!fA)return;const jA=fA.getSource($0);if(!jA)return;const DA=performance.now(),CA=O.current,yA=[],kA=[];for(const LA of CA){const NA=DA-LA.startTime-LA.delay,GA=LA.isSpeculative?To:_o;if(NA0&&yA.push({type:"Feature",properties:{intensity:bA,opacityMult:LA.isSpeculative?A1:1,isSpeculative:LA.isSpeculative??!1},geometry:{type:"LineString",coordinates:[LA.fromCoord,LA.toCoord]}})}}jA.setData({type:"FeatureCollection",features:yA}),O.current=kA,kA.length>0?Q.current=requestAnimationFrame(()=>oA.current()):Q.current=null}},[]);const vA=R.useCallback(()=>{const fA=P.current;fA&&e1(fA),Q.current===null&&(Q.current=requestAnimationFrame(()=>oA.current()))},[]),iA=R.useCallback(()=>{if(!P.current||!E.current)return;const jA=eA.current;if(eA.current=[],J.current=null,jA.length===0)return;const DA=Z.current,CA=uA.current;if(DA.size===0)return;const yA=performance.now();let kA=0,LA=!1;const NA=new Set;for(const GA of jA){const bA=Es(GA,y);if(!bA||bA.original.length<2)continue;const cA=bA.original;let sA=0,TA=null;for(let JA=0;JA0){JA.sort((Le,oe)=>oe.confidence-Le.confidence);const ZA=Math.max(1,Math.ceil(JA.length*.25)),UA=JA.slice(0,ZA),Ie=kA+sA*yo;for(const{edgeKey:Le,otherHash:oe}of UA){const me=CA.get(TA),ue=CA.get(oe);O.current.push({edgeKey:Le,fromCoord:Nn(me),toCoord:Nn(ue),startTime:yA,delay:Ie,isSpeculative:!0}),NA.add(Le),LA=!0}}}sA>0&&(kA+=sA*yo*.5)}LA&&vA()},[y,C,vA]);R.useEffect(()=>{const fA=P.current;if(!T||!fA||!K||g.length===0)return;const jA=Date.now(),DA=H.current;if(!V.current){V.current=!0;const kA=(jA-Z2)/1e3,LA=g.filter(GA=>(GA.timestamp??0)>=kA);let NA=0;for(const GA of g){const bA=GA.timestamp??0;bA>NA&&(NA=bA)}if(H.current=NA,LA.length>0){LA.sort((bA,cA)=>(bA.timestamp??0)-(cA.timestamp??0));const GA=LA.slice(-20);eA.current.push(...GA),iA()}return}const CA=g.filter(kA=>(kA.timestamp??0)>DA);if(CA.length===0)return;let yA=0;for(const kA of CA){const LA=kA.timestamp??0;LA>yA&&(yA=LA)}H.current=yA,eA.current.push(...CA),J.current&&clearTimeout(J.current),J.current=setTimeout(iA,K2)},[T,g,iA,K]),R.useEffect(()=>()=>{J.current&&clearTimeout(J.current)},[])}var q0={},mr={};/** * @license React * react-dom-server-legacy.browser.production.min.js * @@ -122,5 +122,5 @@ Compares older measurements to newer ones.`,Z=((LA=Q.forward)==null?void 0:LA.un `),Qe=/^[a-zA-Z][a-zA-Z:_\.\-\d]*$/,Je=new Map;function Be(d){var w=Je.get(d);if(w===void 0){if(!Qe.test(d))throw Error(u(65,d));w=E("<"+d),Je.set(d,w)}return w}var ze=E("");function st(d,w,B,N,tA){switch(w){case"select":d.push(Be("select"));var AA=null,dA=null;for(we in B)if(O.call(B,we)){var _A=B[we];if(_A!=null)switch(we){case"children":AA=_A;break;case"dangerouslySetInnerHTML":dA=_A;break;case"defaultValue":case"value":break;default:Ce(d,N,we,_A)}}return d.push(Se),Ke(d,dA,AA),AA;case"option":dA=tA.selectedValue,d.push(Be("option"));var te=_A=null,ke=null,we=null;for(AA in B)if(O.call(B,AA)){var Ue=B[AA];if(Ue!=null)switch(AA){case"children":_A=Ue;break;case"selected":ke=Ue;break;case"dangerouslySetInnerHTML":we=Ue;break;case"value":te=Ue;default:Ce(d,N,AA,Ue)}}if(dA!=null)if(B=te!==null?""+te:$e(_A),CA(dA)){for(N=0;N"),Yt=E(''),N0=E(""),er=E(''),zt=E(""),b0=E(""),tr=E("");function gA(d,w,B){if(x(d,er),B===null)throw Error(u(395));return x(d,B),C(d,k0)}var f0=E('"),n0=E('"),kt=E('"),It=E(''),rA=E(""),pA=E(''),xA=E(""),t=E(''),ge=E(""),De=E(''),$A=E("");function ye(d,w,B,N){switch(B.insertionMode){case 0:case 1:return x(d,f0),x(d,w.segmentPrefix),x(d,_(N.toString(16))),C(d,at);case 2:return x(d,n0),x(d,w.segmentPrefix),x(d,_(N.toString(16))),C(d,Zt);case 3:return x(d,kt),x(d,w.segmentPrefix),x(d,_(N.toString(16))),C(d,o0);case 4:return x(d,It),x(d,w.segmentPrefix),x(d,_(N.toString(16))),C(d,dt);case 5:return x(d,pA),x(d,w.segmentPrefix),x(d,_(N.toString(16))),C(d,IA);case 6:return x(d,t),x(d,w.segmentPrefix),x(d,_(N.toString(16))),C(d,b);case 7:return x(d,De),x(d,w.segmentPrefix),x(d,_(N.toString(16))),C(d,He);default:throw Error(u(397))}}function lt(d,w){switch(w.insertionMode){case 0:case 1:return C(d,Fe);case 2:return C(d,xt);case 3:return C(d,wt);case 4:return C(d,rA);case 5:return C(d,xA);case 6:return C(d,ge);case 7:return C(d,$A);default:throw Error(u(397))}}var _e=E('function $RS(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("'),ie=E('$RS("'),et=E('","'),Lt=E('")<\/script>'),h0=E('function $RC(a,b){a=document.getElementById(a);b=document.getElementById(b);b.parentNode.removeChild(b);if(a){a=a.previousSibling;var f=a.parentNode,c=a.nextSibling,e=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d)if(0===e)break;else e--;else"$"!==d&&"$?"!==d&&"$!"!==d||e++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;b.firstChild;)f.insertBefore(b.firstChild,c);a.data="$";a._reactRetry&&a._reactRetry()}};$RC("'),mt=E('$RC("'),Te=E('","'),gt=E('")<\/script>'),Pe=E('function $RX(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())};$RX("'),At=E('$RX("'),P0=E('"'),nt=E(")<\/script>"),YA=E(","),S=/[<\u2028\u2029]/g;function OA(d){return JSON.stringify(d).replace(S,function(w){switch(w){case"<":return"\\u003c";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";default:throw Error("escapeJSStringsForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React")}})}var Nt=Object.assign,Q0=Symbol.for("react.element"),i0=Symbol.for("react.portal"),s0=Symbol.for("react.fragment"),d0=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),C0=Symbol.for("react.provider"),$t=Symbol.for("react.context"),O0=Symbol.for("react.forward_ref"),z0=Symbol.for("react.suspense"),E0=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),D=Symbol.for("react.scope"),F=Symbol.for("react.debug_trace_mode"),X=Symbol.for("react.legacy_hidden"),Y=Symbol.for("react.default_value"),hA=Symbol.iterator;function RA(d){if(d==null)return null;if(typeof d=="function")return d.displayName||d.name||null;if(typeof d=="string")return d;switch(d){case s0:return"Fragment";case i0:return"Portal";case k:return"Profiler";case d0:return"StrictMode";case z0:return"Suspense";case E0:return"SuspenseList"}if(typeof d=="object")switch(d.$$typeof){case $t:return(d.displayName||"Context")+".Consumer";case C0:return(d._context.displayName||"Context")+".Provider";case O0:var w=d.render;return d=d.displayName,d||(d=w.displayName||w.name||"",d=d!==""?"ForwardRef("+d+")":"ForwardRef"),d;case h:return w=d.displayName||null,w!==null?w:RA(d.type)||"Memo";case v:w=d._payload,d=d._init;try{return RA(d(w))}catch{}}return null}var XA={};function Ae(d,w){if(d=d.contextTypes,!d)return XA;var B={},N;for(N in d)B[N]=w[N];return B}var ce=null;function Ge(d,w){if(d!==w){d.context._currentValue=d.parentValue,d=d.parent;var B=w.parent;if(d===null){if(B!==null)throw Error(u(401))}else{if(B===null)throw Error(u(401));Ge(d,B)}w.context._currentValue=w.value}}function bt(d){d.context._currentValue=d.parentValue,d=d.parent,d!==null&&bt(d)}function Ct(d){var w=d.parent;w!==null&&Ct(w),d.context._currentValue=d.value}function pt(d,w){if(d.context._currentValue=d.parentValue,d=d.parent,d===null)throw Error(u(402));d.depth===w.depth?Ge(d,w):pt(d,w)}function Re(d,w){var B=w.parent;if(B===null)throw Error(u(402));d.depth===B.depth?Ge(d,B):Re(d,B),w.context._currentValue=w.value}function Et(d){var w=ce;w!==d&&(w===null?Ct(d):d===null?bt(w):w.depth===d.depth?Ge(w,d):w.depth>d.depth?pt(w,d):Re(w,d),ce=d)}var m0={isMounted:function(){return!1},enqueueSetState:function(d,w){d=d._reactInternals,d.queue!==null&&d.queue.push(w)},enqueueReplaceState:function(d,w){d=d._reactInternals,d.replace=!0,d.queue=[w]},enqueueForceUpdate:function(){}};function l0(d,w,B,N){var tA=d.state!==void 0?d.state:null;d.updater=m0,d.props=B,d.state=tA;var AA={queue:[],replace:!1};d._reactInternals=AA;var dA=w.contextType;if(d.context=typeof dA=="object"&&dA!==null?dA._currentValue:N,dA=w.getDerivedStateFromProps,typeof dA=="function"&&(dA=dA(B,tA),tA=dA==null?tA:Nt({},tA,dA),d.state=tA),typeof w.getDerivedStateFromProps!="function"&&typeof d.getSnapshotBeforeUpdate!="function"&&(typeof d.UNSAFE_componentWillMount=="function"||typeof d.componentWillMount=="function"))if(w=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),w!==d.state&&m0.enqueueReplaceState(d,d.state,null),AA.queue!==null&&0>=dA,tA-=dA,{id:1<<32-S0(w)+tA|B<>>=0,d===0?32:31-(nr(d)/or|0)|0}function Wr(d,w){return d===w&&(d!==0||1/d===1/w)||d!==d&&w!==w}var Yr=typeof Object.is=="function"?Object.is:Wr,Ft=null,ir=null,a0=null,Ne=null,M0=!1,z=!1,lA=0,mA=null,FA=0;function VA(){if(Ft===null)throw Error(u(321));return Ft}function xe(){if(0d.progressiveChunkSize)N.rootSegmentID=d.nextSegmentId++,d.completedBoundaries.push(N),gA(w,d.responseState,N.id),Mr(d,w,B);else{if(C(w,N0),B=N.completedSegments,B.length!==1)throw Error(u(391));Br(d,w,B[0])}return C(w,b0)}function sr(d,w,B){return ye(w,d.responseState,B.formatContext,B.id),Br(d,w,B),lt(w,B.formatContext)}function xn(d,w,B){for(var N=B.completedSegments,tA=0;tA{const P=`set txdelay ${x.toFixed(1)} -set direct.txdelay ${C.toFixed(1)}`;try{await navigator.clipboard.writeText(P),y(!0),setTimeout(()=>y(!1),1500)}catch{const E=document.createElement("textarea");E.value=P,E.style.position="fixed",E.style.opacity="0",document.body.appendChild(E),E.select();try{document.execCommand("copy"),y(!0),setTimeout(()=>y(!1),1500)}catch{console.error("Failed to copy")}document.body.removeChild(E)}};return p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsxs("button",{onClick:T,className:"flex items-center gap-2 flex-1 py-1 px-1.5 bg-sys-amber/5 hover:bg-sys-amber/10 rounded transition-colors group",title:"Click to copy CLI commands",children:[p.jsx(Ru,{className:"w-3 h-3 text-sys-amber shrink-0"}),p.jsx("span",{className:"text-fg-muted",children:"TxDelay"}),p.jsxs("div",{className:"flex gap-2",children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("span",{className:"text-fg-muted",children:"F"}),p.jsxs("span",{className:"data-box data-box-compact text-sys-amber",children:["×",x.toFixed(1)]})]}),p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("span",{className:"text-fg-muted",children:"D"}),p.jsxs("span",{className:"data-box data-box-compact text-sys-amber",children:["×",C.toFixed(1)]})]})]}),g?p.jsx(zo,{className:"w-3 h-3 text-sys-green ml-auto"}):p.jsx(Ho,{className:"w-3 h-3 text-fg-muted opacity-0 group-hover:opacity-100 transition-opacity ml-auto"})]}),u&&p.jsx("button",{onClick:u,className:"p-1 text-fg-secondary hover:text-sys-red hover:bg-sys-red/10 rounded transition-colors",title:"Remove from contacts",children:p.jsx(Go,{className:"w-3.5 h-3.5"})})]})}function h1({hash:c,hashPrefix:u,name:g,isHub:y,isGateway:x,isBackbone:C,isZeroHop:T,isMobile:P,isRoomServer:_,isStale:E,lastSeenTimestamp:Q,centrality:O,affinity:H,meanSnr:V,meanRssi:K,neighbor:aA,onRemove:J,txDelayRec:eA}){const[Z,uA]=R.useState(!1),oA=async()=>{try{await navigator.clipboard.writeText(c),uA(!0),setTimeout(()=>uA(!1),1500)}catch(DA){console.error("Failed to copy hash:",DA);const CA=document.createElement("textarea");CA.value=c,CA.style.position="fixed",CA.style.opacity="0",document.body.appendChild(CA),CA.select();try{document.execCommand("copy"),uA(!0),setTimeout(()=>uA(!1),1500)}catch{console.error("Fallback copy also failed")}document.body.removeChild(CA)}},vA=T?"Direct":H!=null&&H.typicalHopPosition?`${H.typicalHopPosition}-hop`:null,iA=eA&&!eA.insufficientData,fA={hub:"Hub: High-connectivity node that bridges many paths",backbone:"Backbone: Critical relay with high traffic",relay:"Relay: Standard forwarding node",edge:"Edge: Peripheral node"},jA={high:"1000+ packets",medium:"500-999 packets",low:"100-499 packets",insufficient:"Insufficient data"};return p.jsxs("div",{className:"w-[240px] pr-2",children:[p.jsx("div",{className:"text-[14px] font-semibold text-fg-primary leading-tight truncate mb-1",children:g}),p.jsxs("div",{className:"flex items-center gap-1 flex-wrap mb-1.5",children:[p.jsx("code",{className:"type-data-xs text-fg-secondary bg-data-box-bg border border-data-box-border px-1 py-0.5 rounded",children:u}),p.jsx("button",{onClick:oA,className:"p-0.5 hover:bg-subtle-fill-hover rounded transition-colors",title:"Copy full hash",children:Z?p.jsx(zo,{className:"w-3 h-3 text-sys-green"}):p.jsx(Ho,{className:"w-3 h-3 text-fg-secondary"})}),p.jsx(uu,{hash:c,size:"sm"}),vA&&p.jsx(y0,{color:T?ki.direct:ki.multihop,compact:!0,children:vA}),aA.is_repeater&&p.jsx(y0,{color:Lr.repeater,compact:!0,children:"Rptr"}),y&&p.jsx(y0,{color:Lr.hub,compact:!0,title:"Hub: ≥10% of last-hop traffic",children:"Hub"}),x&&!y&&p.jsx(y0,{color:Lr.gateway,compact:!0,title:"Gateway: 7-10% of last-hop traffic",children:"Gate"}),C&&p.jsx(y0,{color:Lr.backbone,compact:!0,title:"Backbone",children:"Bone"}),P&&p.jsx(y0,{color:Lr.mobile,compact:!0,children:"Mobile"}),_&&p.jsx(y0,{color:Lr.room,compact:!0,children:"Room"}),E&&Q&&p.jsxs(y0,{compact:!0,title:"Neighbor not heard in 7+ days",children:["Idle ",c1(Q)]})]}),p.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-secondary mb-1.5",children:[p.jsxs("span",{className:"flex items-center gap-0.5",children:[p.jsx(Ns,{className:"w-3 h-3 text-fg-muted shrink-0"}),p.jsx("span",{className:"font-mono",children:bs(aA.last_seen)})]}),(H==null?void 0:H.distanceMeters)&&p.jsxs("span",{className:"flex items-center gap-0.5",children:[p.jsx(cu,{className:"w-3 h-3 text-fg-muted shrink-0"}),p.jsx("span",{className:"font-mono font-semibold text-fg-primary",children:u1(H.distanceMeters)})]}),aA.latitude&&aA.longitude&&aA.latitude!==0&&aA.longitude!==0&&p.jsxs("span",{className:"flex items-center gap-0.5",children:[p.jsx(gu,{className:"w-3 h-3 text-fg-muted shrink-0"}),p.jsxs("span",{className:"font-mono text-fg-muted",children:[aA.latitude.toFixed(2),", ",aA.longitude.toFixed(2)]})]})]}),p.jsx("div",{className:"mb-1.5",style:{width:224},children:p.jsx(a1,{nodeHash:c,width:224,height:26,showArea:!0,showTooltip:!0})}),p.jsxs("div",{className:"flex gap-3 text-xs mb-1.5",children:[p.jsxs("div",{className:"flex-1 space-y-1",children:[p.jsxs("div",{className:"flex justify-between items-center gap-2",children:[p.jsx("span",{className:"text-fg-muted",children:"Packets"}),p.jsx("span",{className:"data-box data-box-compact",children:(H==null?void 0:H.frequency)||0})]}),T&&V!==void 0&&p.jsxs("div",{className:"flex justify-between items-center gap-2",children:[p.jsx("span",{className:"text-fg-muted",children:"SNR"}),p.jsxs("span",{className:"data-box data-box-compact",children:[V.toFixed(1)," dB"]})]}),iA&&eA.networkRole&&p.jsxs("div",{className:"flex justify-between items-center gap-2",children:[p.jsx("span",{className:"text-fg-muted",children:"Role"}),p.jsx(y0,{color:hu[eA.networkRole],compact:!0,title:fA[eA.networkRole],children:eA.networkRole})]})]}),p.jsxs("div",{className:"flex-1 space-y-1",children:[p.jsxs("div",{className:"flex justify-between items-center gap-2",children:[p.jsx("span",{className:"text-fg-muted",children:"Adverts"}),p.jsx("span",{className:"data-box data-box-compact",children:aA.advert_count||0})]}),T&&K!==void 0&&p.jsxs("div",{className:"flex justify-between items-center gap-2",children:[p.jsx("span",{className:"text-fg-muted",children:"RSSI"}),p.jsxs("span",{className:"data-box data-box-compact",children:[Math.round(K)," dBm"]})]}),iA&&eA.dataConfidence&&p.jsxs("div",{className:"flex justify-between items-center gap-2",children:[p.jsx("span",{className:"text-fg-muted",children:"Data"}),p.jsx(y0,{color:du[eA.dataConfidence],compact:!0,title:jA[eA.dataConfidence],children:eA.dataConfidence})]})]}),!iA&&J&&p.jsx("button",{onClick:J,className:"p-1 self-start text-fg-secondary hover:text-sys-red hover:bg-sys-red/10 rounded transition-colors",title:"Remove from contacts",children:p.jsx(Go,{className:"w-3.5 h-3.5"})})]}),iA&&p.jsx(f1,{txDelayRec:eA,onRemove:J})]})}const Pn="node-markers-native",Ro="node-markers-layer",jo="node-markers-layer-local",je={standard:"marker-standard",standardNeighbor:"marker-standard-neighbor",hub:"marker-hub",hubNeighbor:"marker-hub-neighbor",gateway:"marker-gateway",gatewayNeighbor:"marker-gateway-neighbor",mobile:"marker-mobile",mobileNeighbor:"marker-mobile-neighbor",roomServer:"marker-room-server",roomServerNeighbor:"marker-room-server-neighbor",local:"marker-local",stale5Day:"marker-stale-5day",stale10Day:"marker-stale-10day",blinkBlack:"marker-blink-black",blinkBlackLocal:"marker-blink-black-local",blink:"marker-blink",blinkLocal:"marker-blink-local"},d1=10,m1=6,g1=5,p1=10,os={tier1:j0[500],tier2:j0[700]};function y1(c){if(!c)return 0;const u=Date.now(),g=c*1e3,y=(u-g)/(1e3*60*60*24);return y>=p1?2:y>=g1?1:0}const Wt=2,x1=Os*Wt,is=So*Wt;function w1(c){const u=Fo(),g=(P,_,E=0,Q=!1)=>{const O=x1,H=document.createElement("canvas");H.width=O,H.height=O;const V=H.getContext("2d",Q?{colorSpace:"display-p3"}:void 0),K=O/2,aA=O/2,J=O/2-2-E/2;return V.beginPath(),V.arc(K,aA,J,0,Math.PI*2),V.fillStyle=P,V.fill(),_&&E>0&&(V.strokeStyle=_,V.lineWidth=E*Wt,V.stroke()),V.shadowColor="rgba(0,0,0,0.3)",V.shadowBlur=2*Wt,V.shadowOffsetY=1*Wt,{data:V.getImageData(0,0,O,O),pixelRatio:Wt}},y=(P,_=!1)=>{const E=is,Q=document.createElement("canvas");Q.width=E,Q.height=E;const O=Q.getContext("2d",_?{colorSpace:"display-p3"}:void 0),H=E/2,V=E/2,K=So*.35*Wt;return O.strokeStyle=P,O.lineWidth=2.5*Wt,O.lineCap="round",O.lineJoin="round",O.beginPath(),O.moveTo(H-K,V),O.lineTo(H,V-K),O.lineTo(H+K,V),O.stroke(),O.beginPath(),O.moveTo(H-K*.7,V),O.lineTo(H-K*.7,V+K*.7),O.lineTo(H+K*.7,V+K*.7),O.lineTo(H+K*.7,V),O.stroke(),O.beginPath(),O.moveTo(H-K*.2,V+K*.7),O.lineTo(H-K*.2,V+K*.2),O.lineTo(H+K*.2,V+K*.2),O.lineTo(H+K*.2,V+K*.7),O.stroke(),{data:O.getImageData(0,0,E,E),pixelRatio:Wt}},x=(P,_)=>{const E=is,Q=document.createElement("canvas");Q.width=E,Q.height=E;const O=Q.getContext("2d"),H=E/2,V=E/2,K=So*.35*Wt;return O.strokeStyle=P,O.lineWidth=2.5*Wt,O.lineCap="round",O.lineJoin="round",_&&(O.fillStyle=_),O.beginPath(),O.roundRect(H-K,V-K*.6,K*1.6,K*1.2,3*Wt),_&&O.fill(),O.stroke(),O.beginPath(),O.moveTo(H-K*.3,V+K*.6),O.lineTo(H-K*.6,V+K),O.lineTo(H,V+K*.6),O.stroke(),{data:O.getImageData(0,0,E,E),pixelRatio:Wt}},C="#00FF00",T={[je.standard]:g(u.nodeFill),[je.standardNeighbor]:g(u.neighborColor),[je.hub]:g(u.hubColor),[je.hubNeighbor]:g(u.neighborColor),[je.gateway]:g(u.gatewayColor),[je.gatewayNeighbor]:g(u.neighborColor),[je.mobile]:g("transparent",u.mobileColor,2.5),[je.mobileNeighbor]:g(u.neighborColor),[je.roomServer]:x(u.roomColor),[je.roomServerNeighbor]:x(u.neighborColor,"#1a1a1c"),[je.local]:y(u.localColor),[je.stale5Day]:g(os.tier1),[je.stale10Day]:g(os.tier2),[je.blinkBlack]:g("#000000"),[je.blinkBlackLocal]:y("#000000"),[je.blink]:g(C,void 0,0,!0),[je.blinkLocal]:y(C,!0)};for(const[P,_]of Object.entries(T))try{c.hasImage(P)&&c.removeImage(P),c.addImage(P,_.data,{pixelRatio:_.pixelRatio})}catch{}}function ss(c){var g;const u=(g=c.contact_type)==null?void 0:g.toLowerCase();return u==="room server"||u==="room_server"||u==="room"||u==="server"}function xo(c){return c.startsWith("0x")?c.slice(2,4).toUpperCase():c.slice(0,2).toUpperCase()}function v1({neighborsWithLocation:c,localNode:u,localHash:g,zeroHopNeighbors:y,lastHopNeighborMap:x,meshTopology:C,hoveredMarker:T,onMarkerHover:P,getNodeOpacity:_,shouldShowNode:E,onRequestRemove:Q,openPopupId:O,onOpenPopup:H,onClosePopup:V,onNodeClick:K,blinkingNodes:aA}){const{current:J}=Ar(),eA=R.useRef(!1),[Z,uA]=R.useState(!1);R.useEffect(()=>{var ZA;const cA=(ZA=J==null?void 0:J.getMap)==null?void 0:ZA.call(J);if(!cA)return;const sA=()=>{try{w1(cA),eA.current=!0,Z||uA(!0)}catch(UA){console.warn("Failed to load node marker icons:",UA)}};cA.isStyleLoaded()?sA():cA.once("style.load",sA);const TA=()=>{cA.hasImage(je.standard)||sA()};cA.on("styledata",TA);const MA=()=>{eA.current=!1,sA()},WA=new MutationObserver(UA=>{for(const Ie of UA)if(Ie.attributeName==="data-theme"){setTimeout(MA,100);break}});WA.observe(document.documentElement,{attributes:!0});const ae=document.querySelector("[data-basemap]");let JA=null;return ae&&(JA=new MutationObserver(UA=>{for(const Ie of UA)if(Ie.attributeName==="data-basemap"){setTimeout(MA,100);break}}),JA.observe(ae,{attributes:!0})),()=>{cA.off("styledata",TA),WA.disconnect(),JA==null||JA.disconnect()}},[J,Z]);const oA=R.useMemo(()=>{var TA;const cA=[],sA=[...c].sort(([MA,WA],[ae,JA])=>{const ZA=(UA,Ie)=>{var Le;return ss(Ie)?5e3:y.has(UA)?3e3:C.hubNodes.includes(UA)?2e3:(Le=C.gatewayNodes)!=null&&Le.includes(UA)?1e3:0};return ZA(MA,WA)-ZA(ae,JA)});for(const[MA,WA]of sA){if(!WA.latitude||!WA.longitude)continue;if(g){const qe=g.startsWith("0x")?g.slice(2,4).toLowerCase():g.slice(0,2).toLowerCase(),Xe=MA.startsWith("0x")?MA.slice(2,4).toLowerCase():MA.slice(0,2).toLowerCase();if(qe===Xe||MA===g)continue}const ae=E(MA),JA=_(MA,ae);if(JA<=.01)continue;const ZA=y.has(MA),UA=C.hubNodes.includes(MA),Ie=((TA=C.gatewayNodes)==null?void 0:TA.includes(MA))??!1,Le=C.mobileNodes.includes(MA),oe=ss(WA),me=C.centrality.get(MA)||0,ue=x.get(MA),Ye=WA.last_seen||(ue==null?void 0:ue.lastSeen),be=y1(Ye),Ce=be>0;let Se=JA;be===2?Se=Math.min(JA,.25):be===1&&(Se=Math.min(JA,.5));let pe="standard";oe?pe="roomServer":UA?pe="hub":Ie?pe="gateway":Le&&(pe="mobile");const Ke=C.fullAffinity.get(MA),$e=C.txDelayRecommendations.get(MA);cA.push({type:"Feature",geometry:{type:"Point",coordinates:[WA.longitude,WA.latitude]},properties:{hash:MA,name:WA.node_name||WA.name||"Unknown",hashPrefix:xo(MA),iconType:pe,isNeighbor:ZA,isHub:UA,isGateway:Ie,isMobile:Le,isRoomServer:oe,isStale:Ce,staleTier:be,isZeroHop:ZA,opacity:Se,blinkIntensity:0,lastSeenTimestamp:Ye,centrality:me,neighborJson:JSON.stringify(WA),affinityJson:Ke?JSON.stringify(Ke):void 0,txDelayRecJson:$e?JSON.stringify($e):void 0,meanSnr:(ue==null?void 0:ue.avgSnr)??void 0,meanRssi:(ue==null?void 0:ue.avgRssi)??void 0}})}return{type:"FeatureCollection",features:cA}},[c,g,y,x,C,_,E]),vA=R.useMemo(()=>!(u!=null&&u.latitude)||!(u!=null&&u.longitude)?{type:"FeatureCollection",features:[]}:{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:[u.longitude,u.latitude]},properties:{hash:"local",name:u.name,hashPrefix:g?xo(g):"",iconType:"local",isNeighbor:!1,isHub:!1,isGateway:!1,isMobile:!1,isRoomServer:!1,isStale:!1,staleTier:0,isZeroHop:!1,opacity:1,blinkIntensity:0,centrality:0}}]},[u,g]),iA=R.useRef(O);R.useEffect(()=>{iA.current=O},[O]);const fA=R.useCallback(cA=>{var MA;if(!cA.features||cA.features.length===0)return;const TA=(MA=cA.features[0].properties)==null?void 0:MA.hash;TA&&(iA.current===TA?V==null||V():H&&H(TA),K&&TA!=="local"&&K(TA))},[H,V,K]),jA=R.useCallback(cA=>{var MA,WA;if(!cA.features||cA.features.length===0)return;const sA=(MA=J==null?void 0:J.getMap)==null?void 0:MA.call(J);sA&&(sA.getCanvas().style.cursor="pointer");const TA=(WA=cA.features[0].properties)==null?void 0:WA.hash;TA&&P(TA)},[J,P]),DA=R.useCallback(()=>{var sA;const cA=(sA=J==null?void 0:J.getMap)==null?void 0:sA.call(J);cA&&(cA.getCanvas().style.cursor=""),P(null)},[J,P]);R.useEffect(()=>{var TA;const cA=(TA=J==null?void 0:J.getMap)==null?void 0:TA.call(J);if(!cA||!Z)return;const sA=[Ro,jo];for(const MA of sA)cA.on("click",MA,fA),cA.on("mouseenter",MA,jA),cA.on("mouseleave",MA,DA);return()=>{for(const MA of sA)cA.off("click",MA,fA),cA.off("mouseenter",MA,jA),cA.off("mouseleave",MA,DA)}},[J,Z,fA,jA,DA]);const CA=R.useRef(oA),yA=R.useRef(vA);R.useEffect(()=>{CA.current=oA,yA.current=vA},[oA,vA]),R.useEffect(()=>{var MA;const cA=(MA=J==null?void 0:J.getMap)==null?void 0:MA.call(J);if(!cA||!Z||!aA||aA.size===0)return;const sA=cA.getSource(Pn),TA=cA.getSource(`${Pn}-local`);if(!(!sA&&!TA)){if(sA){const WA=CA.current;let ae=!1;const JA=WA.features.map(ZA=>{const UA=aA.get(ZA.properties.hash)??0;return UA!==ZA.properties.blinkIntensity?(ae=!0,{...ZA,properties:{...ZA.properties,blinkIntensity:UA}}):ZA});ae&&sA.setData({type:"FeatureCollection",features:JA})}if(TA&&g){const WA=aA.get(g)??0,ae=yA.current;ae.features.length>0&&ae.features[0].properties.blinkIntensity!==WA&&TA.setData({type:"FeatureCollection",features:[{...ae.features[0],properties:{...ae.features[0].properties,blinkIntensity:WA}}]})}}},[J,Z,aA,g]);const kA=R.useMemo(()=>{if(!O)return null;if(O==="local"&&u)return{longitude:u.longitude,latitude:u.latitude,isLocal:!0,name:u.name,hash:g};const cA=oA.features.find(MA=>MA.properties.hash===O);if(!cA)return null;const sA=cA.properties,TA=sA.txDelayRecJson?JSON.parse(sA.txDelayRecJson):void 0;return{longitude:cA.geometry.coordinates[0],latitude:cA.geometry.coordinates[1],isLocal:!1,hash:sA.hash,hashPrefix:sA.hashPrefix,name:sA.name,isHub:sA.isHub,isGateway:sA.isGateway,isBackbone:(TA==null?void 0:TA.networkRole)==="backbone",isZeroHop:sA.isZeroHop,isMobile:sA.isMobile,isRoomServer:sA.isRoomServer,isStale:sA.isStale,lastSeenTimestamp:sA.lastSeenTimestamp,centrality:sA.centrality,neighbor:sA.neighborJson?JSON.parse(sA.neighborJson):void 0,affinity:sA.affinityJson?JSON.parse(sA.affinityJson):void 0,txDelayRec:TA,meanSnr:sA.meanSnr,meanRssi:sA.meanRssi}},[O,u,g,oA]);if(!Z)return null;const LA=Fo(),NA=["case",[">",["get","blinkIntensity"],.66],je.blink,[">",["get","blinkIntensity"],.33],je.blinkBlack,["==",["get","staleTier"],2],je.stale10Day,["==",["get","staleTier"],1],je.stale5Day,["==",["get","iconType"],"roomServer"],["case",["get","isNeighbor"],je.roomServerNeighbor,je.roomServer],["==",["get","iconType"],"hub"],["case",["get","isNeighbor"],je.hubNeighbor,je.hub],["==",["get","iconType"],"gateway"],["case",["get","isNeighbor"],je.gatewayNeighbor,je.gateway],["==",["get","iconType"],"mobile"],["case",["get","isNeighbor"],je.mobileNeighbor,je.mobile],["case",["get","isNeighbor"],je.standardNeighbor,je.standard]],GA=["interpolate",["linear"],["zoom"],m1,.25,d1,1],bA=["get","opacity"];return p.jsxs(p.Fragment,{children:[p.jsx(X0,{id:Pn,type:"geojson",data:oA,children:p.jsx(t0,{id:Ro,type:"symbol",layout:{"icon-image":NA,"icon-size":GA,"icon-allow-overlap":!0,"icon-ignore-placement":!0,"symbol-sort-key":["get","opacity"]},paint:{"icon-opacity":bA}})}),p.jsx(X0,{id:`${Pn}-local`,type:"geojson",data:vA,children:p.jsx(t0,{id:jo,type:"symbol",layout:{"icon-image":["case",[">",["get","blinkIntensity"],.66],je.blinkLocal,[">",["get","blinkIntensity"],.33],je.blinkBlackLocal,je.local],"icon-size":GA,"icon-allow-overlap":!0,"icon-ignore-placement":!0},paint:{"icon-opacity":1}})}),kA&&V&&p.jsx(Ta,{longitude:kA.longitude,latitude:kA.latitude,offset:{center:[0,0],top:[0,T0/2+4],"top-left":[6,T0/2+4],"top-right":[-6,T0/2+4],bottom:[0,-T0/2-4],"bottom-left":[6,-T0/2-4],"bottom-right":[-6,-T0/2-4],left:[T0/2+4,0],right:[-T0/2-4,0]},maxWidth:"280px",closeOnClick:!1,onClose:V,className:"maplibre-popup",children:kA.isLocal?p.jsxs("div",{className:"text-sm",children:[p.jsx("strong",{className:"text-base",children:kA.name}),kA.hash&&p.jsx("span",{className:"ml-2 font-mono text-xs text-fg-muted surface-badge px-1.5 py-0.5 rounded",children:xo(kA.hash)}),p.jsx("br",{}),p.jsx("span",{style:{color:LA.localColor},className:"font-medium",children:"This Node (Local)"}),p.jsx("br",{}),u&&p.jsxs("span",{className:"text-xs text-fg-muted",children:[u.latitude.toFixed(5),", ",u.longitude.toFixed(5)]})]}):kA.neighbor&&kA.hash?p.jsx(h1,{hash:kA.hash,hashPrefix:kA.hashPrefix,name:kA.name,isHub:kA.isHub,isGateway:kA.isGateway,isBackbone:kA.isBackbone,isZeroHop:kA.isZeroHop,isMobile:kA.isMobile,isRoomServer:kA.isRoomServer,isStale:kA.isStale,lastSeenTimestamp:kA.lastSeenTimestamp,centrality:kA.centrality,affinity:kA.affinity,meanSnr:kA.meanSnr,meanRssi:kA.meanRssi,neighbor:kA.neighbor,txDelayRec:kA.txDelayRec,onRemove:Q?()=>Q(kA.hash,kA.name):void 0}):null})]})}const k1=[Ro,jo],Io="topology-validated-edges-native",Lo="topology-weak-edges-native",No="neighbor-edges-native",ls="topology-weak-edges-native",Qn="topology-validated-edges-native",wo="neighbor-edges-native",vo={type:"FeatureCollection",features:[]},an={"line-cap":"round","line-join":"round"},as={"line-color":"transparent","line-width":16,"line-opacity":0};function b1(c,u,g,y,x,C){const T=Uo(),P=c!==null,_=x&&x.size>0,E=C&&C.size>0,Q=_?Array.from(x):[],O=E?Array.from(C):[],H=u,V=.5,aA=(()=>{if(H<=0)return["get","baseColor"];const kA=1-H*.5;return["case",[">=",["get","brightnessScore"],kA],"#FFFFFF",["get","baseColor"]]})(),eA=H<=0?1:["max",.1,["+",1,["*",H,3,["-",["get","brightnessScore"],V]]]],uA=_?["in",["get","key"],["literal",Q]]:E?["in",["get","key"],["literal",O]]:P?["==",["get","key"],c]:!1,oA=P||_||E,vA=T.edges.hoverLoop,iA=T.edges.highlight;return{"line-color":oA?["case",uA,_?vA:E?iA:["get","hoverColor"],aA]:aA,"line-width":oA?["case",uA,["max",["*",["get","baseWidth"],g,1.3],3.5],["*",["get","baseWidth"],g]]:["*",["get","baseWidth"],g],"line-opacity":["case",["<",["get","brightnessScore"],y],0,oA?["case",uA,["min",["*",["get","baseOpacity"],1.25],1],["*",["get","baseOpacity"],eA,.35]]:["*",["get","baseOpacity"],eA]]}}const C1=10,E1=6;function S1(c){const u=c!==null,{YELLOW:g,GREEN:y,RED:x,GRAY:C}=On,T=["to-number",["get","listenerScore"],0],P=["to-number",["get","loudScore"],0],E=["/",T,["max",["+",T,P],1]],Q=["case",["all",["==",T,0],["==",P,0]],C,[">=",E,.97],y,["<=",E,.03],x,["interpolate",["linear"],E,.03,x,.5,g,.97,y]],O=.2,J=["*",["+",O,["*",["to-number",["get","trafficWeight"],0],1-O]],8],eA=5,Z=u?["case",["==",["get","key"],c],["max",J,eA],J]:J,uA=u?["case",["==",["get","key"],c],["max",["*",J,.25],eA*.25],["*",J,.25]]:["*",J,.25];return{"line-color":Q,"line-width":["interpolate",["linear"],["zoom"],E1,uA,C1,Z],"line-opacity":u?["case",["==",["get","key"],c],1,.35]:.9}}function M1({showTopology:c,isExiting:u,hoveredEdgeKey:g,highlightedLoopEdges:y,highlightedFocusEdges:x,onEdgeHover:C,onLoopHover:T,loops:P=[],neighborNames:_={},opacityBias:E=.5,widthMultiplier:Q=1,trafficFilter:O=0,showNeighborLines:H=!0,disableHover:V=!1}){const{current:K}=Ar(),aA=c||u,J=!0,eA=H?"visible":"none",Z=V||u,uA=R.useRef(null),oA=R.useRef(Z),vA=R.useRef(new Map),iA=R.useRef(_),fA=R.useRef(T);R.useLayoutEffect(()=>{oA.current=Z,iA.current=_,fA.current=T});const jA=R.useMemo(()=>Lu(P),[P]);R.useLayoutEffect(()=>{vA.current=jA},[jA]);const DA=R.useCallback(bA=>{var MA,WA;if(oA.current||!bA.features||bA.features.length===0)return;const sA=bA.features[0].properties;if(!(sA!=null&&sA.key))return;const TA=sA.key;if(TA!==uA.current){uA.current=TA;const ae=sA.isNeighborEdge===!0||sA.isNeighborEdge==="true",JA=sA.isLoopEdge===!0||sA.isLoopEdge==="true";if(ae){const ZA={key:TA,fromName:"Local",toName:sA.name,certainCount:Number(sA.packetCount)||0,confidence:1,isBackbone:!1,isLoopEdge:!1,isDirectPath:!0,isZeroHop:!0,symmetryRatio:1,dominantDirection:"balanced",isHubConnection:!1};C(TA,[bA.lngLat.lng,bA.lngLat.lat],ZA),(MA=fA.current)==null||MA.call(fA,null)}else if(JA&&fA.current){const ZA=vA.current.get(TA)??[];if(ZA.length>0){const UA=new Set;for(const me of ZA)for(const ue of me.edgeKeys)UA.add(ue);const Le=ZA[0].nodes.map(me=>iA.current[me]||me.substring(0,4)),oe={loops:ZA,highlightedEdgeKeys:UA,hoveredEdgeKey:TA,nodeNames:Le};fA.current(oe,[bA.lngLat.lng,bA.lngLat.lat]),C(TA)}else{const UA={key:TA,fromName:sA.fromName,toName:sA.toName,certainCount:Number(sA.certainCount),confidence:Number(sA.confidence),isBackbone:sA.isBackbone===!0||sA.isBackbone==="true",isLoopEdge:!0,isDirectPath:sA.isDirectPath===!0||sA.isDirectPath==="true",isZeroHop:sA.isZeroHop===!0||sA.isZeroHop==="true",symmetryRatio:Number(sA.symmetryRatio),dominantDirection:sA.dominantDirection,isHubConnection:sA.isHubConnection===!0||sA.isHubConnection==="true"};C(TA,[bA.lngLat.lng,bA.lngLat.lat],UA)}}else{const ZA={key:TA,fromName:sA.fromName,toName:sA.toName,certainCount:Number(sA.certainCount),confidence:Number(sA.confidence),isBackbone:sA.isBackbone===!0||sA.isBackbone==="true",isLoopEdge:JA,isDirectPath:sA.isDirectPath===!0||sA.isDirectPath==="true",isZeroHop:sA.isZeroHop===!0||sA.isZeroHop==="true",symmetryRatio:Number(sA.symmetryRatio),dominantDirection:sA.dominantDirection,isHubConnection:sA.isHubConnection===!0||sA.isHubConnection==="true"};C(TA,[bA.lngLat.lng,bA.lngLat.lat],ZA),(WA=fA.current)==null||WA.call(fA,null)}}},[C]),CA=R.useCallback(()=>{var bA;uA.current!==null&&(uA.current=null,C(null),(bA=fA.current)==null||bA.call(fA,null))},[C]);R.useEffect(()=>{var MA;const bA=(MA=K==null?void 0:K.getMap)==null?void 0:MA.call(K);if(!bA||!aA)return;const cA="topology-validated-edges-hitarea-native",sA=()=>{try{return bA.getStyle()&&bA.getLayer(cA)}catch{return!1}},TA=()=>sA()?(bA.on("mousemove",cA,DA),bA.on("mouseleave",cA,CA),!0):!1;if(!TA()){const WA=()=>{TA()&&bA.off("styledata",WA)};return bA.on("styledata",WA),()=>{try{bA.off("styledata",WA),sA()&&(bA.off("mousemove",cA,DA),bA.off("mouseleave",cA,CA))}catch{}}}return()=>{try{sA()&&(bA.off("mousemove",cA,DA),bA.off("mouseleave",cA,CA))}catch{}}},[K,aA,DA,CA]),R.useEffect(()=>{var MA;const bA=(MA=K==null?void 0:K.getMap)==null?void 0:MA.call(K);if(!bA||!J||!H)return;const cA="neighbor-edges-hitarea-native",sA=()=>{try{return bA.getStyle()&&bA.getLayer(cA)}catch{return!1}},TA=()=>sA()?(bA.on("mousemove",cA,DA),bA.on("mouseleave",cA,CA),!0):!1;if(!TA()){const WA=()=>{TA()&&bA.off("styledata",WA)};return bA.on("styledata",WA),()=>{try{bA.off("styledata",WA),sA()&&(bA.off("mousemove",cA,DA),bA.off("mouseleave",cA,CA))}catch{}}}return()=>{try{sA()&&(bA.off("mousemove",cA,DA),bA.off("mouseleave",cA,CA))}catch{}}},[K,J,H,DA,CA]),R.useEffect(()=>{var JA;const bA=(JA=K==null?void 0:K.getMap)==null?void 0:JA.call(K);if(!bA)return;let cA=null;const sA=(ZA,UA)=>{try{if(bA.getLayer(ZA)&&bA.getLayer(UA))return bA.moveLayer(ZA,UA),!0}catch{}return!1},TA=()=>{try{if(!bA.getLayer("node-markers-layer"))return;sA(wo,"node-markers-layer"),sA("neighbor-edges-hitarea-native",wo),(sA(Qn,"neighbor-edges-hitarea-native")||sA(Qn,"node-markers-layer"))&&sA("topology-validated-edges-hitarea-native",Qn),sA(ls,"topology-validated-edges-hitarea-native")}catch{}},MA=()=>{cA&&clearTimeout(cA),cA=setTimeout(TA,50)},WA=setTimeout(TA,100);bA.on("styledata",MA);const ae=ZA=>{(ZA.sourceId===Io||ZA.sourceId===Lo||ZA.sourceId===No)&&MA()};return bA.on("sourcedata",ae),()=>{clearTimeout(WA),cA&&clearTimeout(cA);try{bA.off("styledata",MA),bA.off("sourcedata",ae)}catch{}}},[K,aA,J,H]);const yA=Z?null:g,NA=b1(yA,E,Q,O,Z?null:y,x??null),GA=S1(yA);return p.jsxs(p.Fragment,{children:[aA&&p.jsx(X0,{id:Lo,type:"geojson",data:vo,children:p.jsx(t0,{id:ls,type:"line",paint:NA,layout:{...an,visibility:eA}})}),aA&&p.jsxs(X0,{id:Io,type:"geojson",data:vo,children:[p.jsx(t0,{id:"topology-validated-edges-hitarea-native",type:"line",paint:as,layout:{...an,visibility:eA}}),p.jsx(t0,{id:Qn,type:"line",paint:NA,layout:{...an,visibility:eA}})]}),p.jsxs(X0,{id:No,type:"geojson",data:vo,children:[p.jsx(t0,{id:"neighbor-edges-hitarea-native",type:"line",paint:as,layout:{...an,visibility:eA}}),p.jsx(t0,{id:wo,type:"line",paint:GA,layout:{...an,visibility:eA}})]})]})}const B1=["topology-validated-edges-hitarea-native","topology-validated-edges-native","topology-weak-edges-native","neighbor-edges-hitarea-native","neighbor-edges-native"];function D1({targetHash:c,nodeCoordinates:u,onComplete:g}){const{current:y}=Ar(),x=R.useRef(null);return R.useEffect(()=>{if(!y||!c||c===x.current)return;const C=u.get(c);if(!C)return;const T=y.getMap();T.isMoving()&&T.stop(),x.current=c;const[P,_]=C;y.flyTo({center:[_,P],zoom:10,duration:2500,essential:!0}),setTimeout(()=>{g==null||g()},2600)},[c,u,y,g]),null}function _1({highlightedEdgeKey:c,validatedPolylines:u,weakPolylines:g,onEnsureTopology:y}){const{current:x}=Ar(),C=R.useRef(null);return R.useEffect(()=>{if(!x||!c||c===C.current)return;C.current=c,y();const T=u.find(H=>H.edge.key===c)||g.find(H=>H.edge.key===c);if(!T||x.getMap().isMoving())return;const _=(T.from[0]+T.to[0])/2,E=(T.from[1]+T.to[1])/2,Q=x.getZoom(),O=Math.max(Q,11);x.easeTo({center:[E,_],zoom:O,duration:500})},[c,u,g,x,y]),null}const us="link-quality-edges",T1="link-quality-edges-layer",Hn="link-quality-edges-hitarea",cs={type:"FeatureCollection",features:[]};function R1(c,u){return cEa(),[]),E=R.useMemo(()=>!c||C.length===0||T.size===0?cs:j1(C,u,g,_,P),[c,C,T.size,u,g,_,P]);R.useEffect(()=>{if(!x)return;const O=x.getMap();if(O)try{const H=O.getSource(us);H&&"setData"in H&&(H.setData(E),O.triggerRepaint())}catch{}},[E,x]);const Q=c?"visible":"none";return p.jsxs(X0,{id:us,type:"geojson",data:cs,children:[p.jsx(t0,{id:T1,type:"line",layout:{...fs,visibility:Q},paint:I1}),p.jsx(t0,{id:Hn,type:"line",layout:{...fs,visibility:Q},paint:L1})]})}const F1="rgba(167, 139, 250, 0.15)",hs=500,P1=.5,ds=2e3,ms=1500,Q1=1e3;function O1(c,u,g,y=64){const x=[],T=g/6371e3*(180/Math.PI),P=T/Math.cos(u*Math.PI/180);for(let _=0;_<=y;_++){const E=_/y*2*Math.PI,Q=c+P*Math.cos(E),O=u+T*Math.sin(E);x.push([Q,O])}return{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[x]}}}function z1({ghost:c,neighborCoordinates:u,onHighlightedNeighborsChange:g}){const{current:y}=Ar(),x=R.useRef(null),C=R.useRef(null),T=R.useMemo(()=>c?new Set(c.commonNeighbors):new Set,[c]);R.useEffect(()=>{g==null||g(T)},[T,g]);const P=R.useMemo(()=>{if(!(c!=null&&c.commonNeighbors)||c.commonNeighbors.length<2)return ds*4;let Q=0;const O=[];for(const H of c.commonNeighbors){const V=u.get(H);V&&O.push(V)}c.estimatedLocation&&O.push([c.estimatedLocation.lat,c.estimatedLocation.lon]);for(let H=0;HQ&&(Q=K)}return Math.max(Q,hs*4)},[c,u]),_=R.useMemo(()=>{if(!(c!=null&&c.estimatedLocation))return{type:"FeatureCollection",features:[]};const{lat:Q,lon:O,uncertaintyM:H}=c.estimatedLocation,V=P*P1,K=H>0?H:ds,aA=Math.max(hs,Math.min(K,V));return{type:"FeatureCollection",features:[O1(O,Q,aA)]}},[c,P]);if(R.useEffect(()=>{if(!y)return;const Q=y.getMap();if(c&&c.prefix!==C.current){if(C.current=c.prefix,!x.current&&Q.getZoom()>3){const H=Q.getCenter();x.current={center:[H.lng,H.lat],zoom:Q.getZoom(),pitch:Q.getPitch(),bearing:Q.getBearing()}}const O=[];for(const H of c.commonNeighbors){const V=u.get(H);V&&O.push([V[1],V[0]])}if(c.estimatedLocation&&O.push([c.estimatedLocation.lon,c.estimatedLocation.lat]),O.length>0){const H=()=>{var V;if(Q.isMoving()){setTimeout(H,100);return}if(O.length===1)y.flyTo({center:O[0],zoom:13,duration:ms});else{let K=1/0,aA=-1/0,J=1/0,eA=-1/0;for(const[Z,uA]of O)K=Math.min(K,Z),aA=Math.max(aA,Z),J=Math.min(J,uA),eA=Math.max(eA,uA);if((V=c.estimatedLocation)!=null&&V.uncertaintyM){const Z=c.estimatedLocation.uncertaintyM/111e3;K-=Z,aA+=Z,J-=Z,eA+=Z}y.fitBounds([[K,J],[aA,eA]],{padding:{top:60,bottom:60,left:60,right:60},maxZoom:14,duration:ms})}};setTimeout(H,50)}}if(!c&&C.current!==null&&(C.current=null,x.current)){const O=x.current,H=()=>{if(Q.isMoving()){setTimeout(H,100);return}y.flyTo({center:O.center,zoom:O.zoom,pitch:O.pitch,bearing:O.bearing,duration:Q1}),x.current=null};setTimeout(H,50)}},[c,y,u]),!(c!=null&&c.estimatedLocation))return null;const E={"fill-color":F1,"fill-opacity":.8};return p.jsx(X0,{id:"ghost-uncertainty-circle",type:"geojson",data:_,children:p.jsx(t0,{id:"ghost-uncertainty-fill",type:"fill",paint:E})})}const nl=[{target:"Map",fn:"gps",minStage:1,when:yi},{target:"Map",fn:"_advertNodeType",minStage:1,when:yi},{target:"Topology",fn:"traceHops",minStage:1,when:xi},{target:"Topology",fn:"path.entries",minStage:1,when:Na},{target:"Topology",fn:"traceSrc",minStage:1,when:xi}];Ts(nl);const H1={version:8,sources:{},layers:[],glyphs:"https://tiles.basemaps.cartocdn.com/fonts/{fontstack}/{range}.pbf"},G1={longitude:0,latitude:0,zoom:2};function U1(c,u,g,y){return Fs(c,u,g,y)/1e3}function V1(c,u){if(c.length<=2)return c;let g,y;if(u!=null&&u.latitude&&(u!=null&&u.longitude))g=u.latitude,y=u.longitude;else{let E=0,Q=0;for(const[O,H]of c)E+=O,Q+=H;g=E/c.length,y=Q/c.length}const x=c.map(([E,Q])=>({pos:[E,Q],dist:U1(g,y,E,Q)}));x.sort((E,Q)=>E.dist-Q.dist);const C=Math.floor(x.length/2),T=x[C].dist,P=Math.max(T*3,50),_=x.filter(E=>E.dist<=P).map(E=>E.pos);return _.length0&&(H=Math.floor(Math.log2(360/O*1.2)),H=Math.max(1,Math.min(14,H))),H=Math.min(H+1,12),{longitude:P,latitude:_,zoom:H}}function Y1(c,u,g,y){var x;if(u){const C=u.loops[0],T=u.loops.length,P=[{label:"hops",value:C.size},{label:"seen",value:C.minCertainCount}],_=[];return C.includesLocal&&_.push({text:"★ Includes your node",color:"text-sys-amber"}),T>1&&_.push({text:`+${T-1} overlapping`,color:"text-sys-indigo/70"}),{type:"loop",title:{icon:"⟳",text:`Redundant Path${T>1?"s":""}`,color:"text-sys-indigo"},subtitle:{text:`${u.nodeNames.join(" → ")} → ${u.nodeNames[0]}`,color:"text-fg-secondary",mono:!0},stats:P,badges:_}}if((c==null?void 0:c.type)==="neighbor"){const C=c.properties,T=[];C.rssi!==void 0&&C.rssi!==null&&T.push({label:"RSSI",value:`${Math.round(C.rssi)} dBm`,unit:C.hasAvgRssi?"avg":void 0}),C.snr!==void 0&&C.snr!==null&&T.push({label:"SNR",value:`${Number(C.snr).toFixed(1)} dB`,unit:C.hasAvgSnr?"avg":void 0});const P=C.listenerScore??0,_=C.loudScore??0,E=P>0||_>0;return E&&(T.push({label:"listener",value:P,color:"text-sys-green"}),T.push({label:"loud",value:_,color:"text-sys-red"})),C.packetCount!==void 0&&!E&&T.push({label:"packets",value:Number(C.packetCount).toLocaleString()}),{type:"neighbor",title:{icon:"●",text:C.prefix?`${C.name} (${C.prefix})`:C.name,color:"text-sys-amber"},subtitle:{text:"Direct RF Neighbor",color:"text-sys-amber/70"},stats:T,badges:[]}}if((c==null?void 0:c.type)==="topology"){const C=c.properties,T=g>0?Number(C.certainCount)/g:0,P=[{label:"validations",value:C.certainCount},{label:"of max traffic",value:`${Math.round(T*100)}%`},{label:"confidence",value:`${Math.round(Number(C.confidence)*100)}%`}];if(C.symmetryRatio!==void 0&&C.symmetryRatio<1){const Q=C.dominantDirection==="forward"?"→":C.dominantDirection==="reverse"?"←":"↔";P.push({label:"symmetric",value:`${Q} ${Math.round(C.symmetryRatio*100)}%`,color:"text-fg-muted"})}const _=(x=y==null?void 0:y.get(C.key))==null?void 0:x.traceQuality;if(_!=null&&_.composite){const Q=_.composite;P.push({label:"trace SNR",value:`${Q.mean.toFixed(1)} dB`,unit:`n=${Q.count}`,color:Q.mean>=10?"text-sys-green":Q.mean>=0?"text-sys-amber":"text-sys-red"}),_.asymmetryDb!=null&&_.asymmetryDb>1&&P.push({label:"asymmetry",value:`${_.asymmetryDb.toFixed(1)} dB`,color:_.asymmetryDb>5?"text-sys-red":"text-sys-amber"})}const E=[];if(C.isBackbone&&E.push({text:"Backbone",color:"text-zinc-300"}),C.isLoopEdge&&E.push({text:"Redundant",color:"text-sys-indigo"}),C.isDirectPath&&E.push({text:"Direct Path",color:"text-sys-teal"}),_){const Q=_.quality==="excellent"||_.quality==="good"?"text-sys-green":_.quality==="fair"?"text-sys-amber":_.quality==="poor"||_.quality==="critical"?"text-sys-red":"text-fg-muted";_.quality!=="unknown"&&E.push({text:`TRACE ${_.quality}`,color:Q})}return{type:"topology",title:{icon:"",text:`${C.fromName} ↔ ${C.toName}`,color:"text-fg-primary"},stats:P,badges:E}}return null}function K1({data:c}){const u=c.subtitle&&c.type==="loop",g=c.subtitle&&c.type!=="loop";return p.jsxs("div",{className:"w-[540px]",children:[p.jsxs("div",{className:"flex items-center justify-between h-5",children:[p.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[c.title.icon&&p.jsx("span",{className:`${c.title.color} text-base leading-none flex-shrink-0`,children:c.title.icon}),p.jsx("span",{className:`${c.title.color} font-semibold text-[13px] truncate`,children:c.title.text}),g&&p.jsx("span",{className:`${c.subtitle.color} text-[11px] flex-shrink-0`,children:c.subtitle.text})]}),c.badges.length>0&&p.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:c.badges.map((y,x)=>p.jsx("span",{className:`${y.color} text-[11px] font-medium`,children:y.text},x))})]}),u&&p.jsx("div",{className:"h-4 mt-0.5 overflow-hidden",children:p.jsx("span",{className:"type-data-xs text-fg-muted truncate block",children:c.subtitle.text})}),p.jsx("div",{className:`flex items-center gap-4 h-4 ${u?"mt-1":"mt-1.5"} text-[11px]`,children:c.stats.map((y,x)=>p.jsxs("span",{className:"whitespace-nowrap",children:[p.jsx("span",{className:`font-mono tabular-nums font-semibold ${y.color??"text-fg-primary"}`,children:y.value}),p.jsx("span",{className:"text-fg-muted ml-1",children:y.label}),y.unit&&p.jsx("span",{className:"text-fg-muted/50 ml-0.5",children:y.unit})]},x))})]})}function jh({neighbors:c,localNode:u,localHash:g,onRemoveNode:y,selectedNodeHash:x,onNodeSelected:C,highlightedEdgeKey:T,highlightedGhost:P}){_s(nl);const _=R.useRef(null),E=Ma(),Q=Ba(),O=Ms(),H=Da(),V=_a(),K=Bs(),[aA,J]=R.useState(!1),eA=ur(z=>z.viewState),Z=ur(z=>z.toggles),uA=ur(z=>z.hasAnalyzed),oA=ur(z=>z.setViewState),vA=ur(z=>z.setToggle),iA=ur(z=>z.setHasAnalyzed),fA=ur(z=>z.modalMapOpen),jA=lo(z=>z.preloadFromNodes),DA=lo(z=>z.isLoading),CA=lo(z=>z.terrainGrid),yA=g??H,kA=R.useMemo(()=>{const z=[];for(const[,lA]of Object.entries(c))lA.latitude&&lA.longitude&&z.push([lA.latitude,lA.longitude]);return z},[c]),LA=R.useMemo(()=>W1(kA,u),[kA,u]),[NA,GA]=R.useState(()=>eA??LA??G1),bA=R.useCallback(z=>{GA(z),queueMicrotask(()=>oA(z))},[oA]),cA=R.useRef(!!eA);R.useEffect(()=>{!cA.current&&LA&&!eA?(GA(LA),queueMicrotask(()=>oA(LA)),cA.current=!0,setTimeout(()=>J(!0),50)):eA&&setTimeout(()=>J(!0),50)},[LA,eA,oA]);const[sA,TA]=R.useState(!1),[MA,WA]=R.useState(()=>Z.showTopology&&!O.topologyLoadComplete?!1:Z.showTopology),[ae,JA]=R.useState(Z.showNeighborLines),[ZA,UA]=R.useState(!1),[Ie,Le]=R.useState(Z.showMinCut),[oe,me]=R.useState(rf),[ue,Ye]=R.useState(Z.show3DTerrain),[be,Ce]=R.useState(Z.showLinkQuality),[Se,pe]=R.useState(()=>Z.nodeFilters.length>0?Z.nodeFilters:[...un]),Ke=R.useCallback(z=>{WA(lA=>{const mA=typeof z=="function"?z(lA):z;return queueMicrotask(()=>vA("showTopology",mA)),mA})},[vA]),$e=R.useCallback(z=>{JA(lA=>{const mA=typeof z=="function"?z(lA):z;return queueMicrotask(()=>vA("showNeighborLines",mA)),mA})},[vA]),qe=R.useCallback(z=>{Le(lA=>{const mA=typeof z=="function"?z(lA):z;return queueMicrotask(()=>vA("showMinCut",mA)),mA})},[vA]),Xe=R.useCallback(z=>{Ye(lA=>{const mA=typeof z=="function"?z(lA):z;return queueMicrotask(()=>vA("show3DTerrain",mA)),mA})},[vA]),vt=R.useCallback(z=>{Ce(lA=>{const mA=typeof z=="function"?z(lA):z;return queueMicrotask(()=>vA("showLinkQuality",mA)),mA})},[vA]),Qe=R.useCallback(z=>{pe(z),queueMicrotask(()=>vA("nodeFilters",z))},[vA]),[Je,Be]=R.useState(null),[ze,st]=R.useState(null),[jt,v0]=R.useState(null),[Yt,Kt]=R.useState(null),[N0]=R.useState(0),[er]=R.useState(.5),[k0]=R.useState(0),[zt,b0]=R.useState(null),[tr,c0]=R.useState(""),[rr,F0]=R.useState(!1),[gA,f0]=R.useState(!1),[at,Fe]=R.useState(()=>uA&&!O.topologyLoadComplete?!1:uA);R.useEffect(()=>{if(O.topologyLoadComplete)return;const z=uA&&!at,lA=Z.showTopology&&!MA;!z&&!lA||queueMicrotask(()=>{z&&iA(!1),lA&&vA("showTopology",!1)})},[uA,Z.showTopology,O.topologyLoadComplete,at,MA,iA,vA]);const n0=R.useCallback(z=>{Fe(z),queueMicrotask(()=>iA(z))},[iA]),[Zt,xt]=R.useState(null),kt=R.useCallback(z=>xt(z),[]),o0=R.useCallback(()=>xt(null),[]),[,wt]=R.useState(new Set),It=cn(z=>z.coveragePoints),dt=cn(z=>z.isVisible),rA=cn(z=>z.brightness),pA=cn(z=>z.openModal),IA=df(),xA=mf(),t=Ds(),b=Ra(),ge=R.useRef(!1);R.useEffect(()=>{It.length>0&&dt&&!ge.current&&($e(!1),ge.current=!0)},[It.length,dt]);const De=R.useRef(null);R.useEffect(()=>{if(x&&x!==De.current){De.current=x;const z=setTimeout(()=>{xt(x)},1250);return()=>clearTimeout(z)}},[x]);const[He,$A]=R.useState(null),[ye,lt]=R.useState(null),_e=R.useCallback((z,lA,mA)=>{st(z),z&&lA&&mA?$A({longitude:lA[0],latitude:lA[1],type:"topology",properties:{key:mA.key,fromName:mA.fromName,toName:mA.toName,certainCount:mA.certainCount,confidence:mA.confidence,isBackbone:mA.isBackbone,isLoopEdge:mA.isLoopEdge,isDirectPath:mA.isDirectPath,isHubConnection:mA.isHubConnection,symmetryRatio:mA.symmetryRatio,dominantDirection:mA.dominantDirection}}):z||$A(null)},[]),ie=R.useCallback((z,lA)=>{lt(z),z&&$A(null)},[]),et=R.useMemo(()=>{var VA;if(!MA||!Je||ze)return null;const z=E.loops;if(z.length===0)return null;const lA=Iu(Je,z,E.edgeMap);if(lA.loops.length===0)return null;const FA=lA.loops[0].nodes.map(xe=>{var tt,Me;return xe===yA?"You":((tt=c[xe])==null?void 0:tt.node_name)||((Me=c[xe])==null?void 0:Me.name)||xe.substring(0,4)});return{loops:lA.loops,highlightedEdgeKeys:lA.highlightedEdgeKeys,hoveredEdgeKey:((VA=lA.sortedEdges[0])==null?void 0:VA.key)||"",nodeNames:FA}},[MA,Je,ze,E.loops,E.edgeMap,c,yA]);R.useEffect(()=>{ze||lt(et)},[et,ze]);const Lt=R.useMemo(()=>{const z={};for(const[lA,mA]of Object.entries(c))z[lA]=mA.node_name||mA.name||lA.substring(0,4);return yA&&(z[yA]="You"),z},[c,yA]),h0=R.useMemo(()=>{const z=new Map;for(const[lA,mA]of Object.entries(c)){const FA=lA.slice(0,2).toUpperCase(),VA=mA.node_name||mA.name||FA;z.set(FA,VA)}return yA&&z.set(yA.slice(0,2).toUpperCase(),"You"),z},[c,yA]),mt=R.useMemo(()=>Object.entries(c).filter(([,z])=>z.latitude&&z.longitude),[c]),Te=R.useMemo(()=>{const z=new Map;yA&&(u!=null&&u.latitude)&&(u!=null&&u.longitude)&&z.set(yA,[u.latitude,u.longitude]);for(const[lA,mA]of mt)mA.latitude&&mA.longitude&&z.set(lA,[mA.latitude,mA.longitude]);return z},[yA,u,mt]),gt=R.useMemo(()=>{const z=new Map;for(const lA of Q)lA.status!=="expired"&&z.set(lA.hash,{hash:lA.hash,prefix:lA.prefix,count:lA.count,avgRssi:lA.avgRssi,avgSnr:lA.avgSnr,lastSeen:lA.lastSeen,confidence:1,status:lA.status});return z},[Q]),Pe=R.useMemo(()=>{var lA,mA;const z=new Set;for(const FA of gt.keys())(lA=c[FA])!=null&&lA.latitude&&((mA=c[FA])!=null&&mA.longitude)&&z.add(FA);return z},[gt,c]),At=Eo(),P0=R.useMemo(()=>{if(Pe.size===0||!yA)return new Map;if(At.length===0)return new Map;const z=hn(yA);return Fa(At,Pe,z).scores},[Pe,yA,At]),nt=R.useCallback(z=>yA?!!(z.fromHash===yA&&Pe.has(z.toHash)||z.toHash===yA&&Pe.has(z.fromHash)):!1,[yA,Pe]),YA=R.useMemo(()=>{var lA,mA;if(Q.length===0||!yA)return[];if(O.backgroundLoadComplete)return[];const z=[];for(const FA of Q){if(FA.status==="expired"||!((lA=c[FA.hash])!=null&&lA.latitude)||!((mA=c[FA.hash])!=null&&mA.longitude))continue;const VA=[yA,FA.hash].sort(),xe=`${VA[0]}~${VA[1]}`;z.push({fromHash:yA,toHash:FA.hash,key:xe,packetCount:FA.count,avgConfidence:1,strength:.8,avgRecency:1,hopDistanceFromLocal:0,isHubConnection:!1,isCertain:!0,certainCount:FA.count,isLoopEdge:!1,forwardCount:FA.count,reverseCount:0,symmetryRatio:0,dominantDirection:"forward",floodCount:FA.count,directCount:0,isDirectPathEdge:!1,isZeroHop:!0,avgRssi:FA.avgRssi,avgSnr:FA.avgSnr})}return z},[Q,yA,O.backgroundLoadComplete,c]),S=R.useMemo(()=>{const z=[];if(YA.length>0&&!O.backgroundLoadComplete){for(const lA of YA){const mA=Te.get(lA.fromHash),FA=Te.get(lA.toHash);mA&&FA&&z.push({from:mA,to:FA,edge:lA})}return z}for(const lA of E.validatedEdges){if(nt(lA))continue;const mA=Te.get(lA.fromHash),FA=Te.get(lA.toHash);mA&&FA&&z.push({from:mA,to:FA,edge:lA})}return z},[E.validatedEdges,Te,nt,YA,O.backgroundLoadComplete]),OA=R.useMemo(()=>{const z=[];for(const lA of E.weakEdges){if(nt(lA))continue;const mA=Te.get(lA.fromHash),FA=Te.get(lA.toHash);mA&&FA&&z.push({from:mA,to:FA,edge:lA})}return z},[E.weakEdges,Te,nt]),Nt=R.useMemo(()=>{if(!(u!=null&&u.latitude)||!(u!=null&&u.longitude))return[];const z=[],lA=[u.latitude,u.longitude],mA=new Map;for(const VA of E.lastHopNeighbors)mA.set(VA.hash,VA.count);const FA=new Map;for(const VA of Q)FA.set(VA.hash,VA.count);for(const VA of Pe){const xe=c[VA];if(!(xe!=null&&xe.latitude)||!(xe!=null&&xe.longitude))continue;const tt=FA.get(VA),Me=mA.get(VA);z.push({from:lA,to:[xe.latitude,xe.longitude],hash:VA,neighbor:xe,lastHopData:gt.get(VA)??null,rxAdvertCount:tt,txProxyCount:Me})}return z},[u,Pe,c,gt,E.lastHopNeighbors,Q]),Q0=R.useMemo(()=>new Set(E.loopEdgeKeys),[E.loopEdgeKeys]),i0=R.useMemo(()=>new Set(E.backboneEdges),[E.backboneEdges]),s0=R.useMemo(()=>{if(!jt)return null;const z=E.validatedEdges.filter(VA=>VA.fromHash===jt||VA.toHash===jt);if(z.length===0)return null;const lA=[...z].sort((VA,xe)=>xe.certainCount-VA.certainCount),mA=Math.max(1,Math.ceil(lA.length*.2)),FA=lA.slice(0,mA);return new Set(FA.map(VA=>VA.key))},[jt,E.validatedEdges]),d0=R.useMemo(()=>{let z=0;if(YA.length>0&&!O.backgroundLoadComplete){for(const lA of YA)lA.certainCount>z&&(z=lA.certainCount);return z||1}for(const lA of E.validatedEdges)lA.certainCount>z&&(z=lA.certainCount);return z||1},[E.validatedEdges,YA,O.backgroundLoadComplete]),k=R.useMemo(()=>{if(E.validatedEdges.length===0)return null;const z=new Set;for(const FA of E.validatedEdges)z.add(FA.fromHash),z.add(FA.toHash);const lA=Array.from(z).filter(FA=>Te.has(FA)).sort();if(lA.length<3)return null;const mA=new Map;for(const FA of lA){const VA=Te.get(FA);VA&&mA.set(FA,VA)}return $a(E.validatedEdges,lA,mA,E.edgeBetweenness)},[E.validatedEdges,Te,E.edgeBetweenness]),C0=R.useCallback(()=>{qe(z=>{const lA=!z;if(lA&&k&&_.current){const mA=_.current.getMap();if(!mA)return lA;let FA=1/0,VA=-1/0,xe=1/0,tt=-1/0,Me=!1;for(const[,ut]of k.communities)for(const Ze of ut){const yt=Te.get(Ze);if(yt){const[ot,St]=yt;xe=Math.min(xe,ot),tt=Math.max(tt,ot),FA=Math.min(FA,St),VA=Math.max(VA,St),Me=!0}}Me&&mA.fitBounds([[FA,xe],[VA,tt]],{padding:{top:60,bottom:100,left:60,right:320},duration:800,maxZoom:14})}return lA})},[k,Te]),$t=R.useRef(null);R.useLayoutEffect(()=>{var z,lA;$t.current=((lA=(z=_.current)==null?void 0:z.getMap)==null?void 0:lA.call(z))??null});const O0=Eo();o1({map:$t,nodeCoordinates:Te,packets:O0,localHash:yA,neighbors:c,meshTopology:E,enabled:IA});const{isExiting:z0,isAnimating:E0,resetAnimationState:h}=H2({map:$t,showTopology:MA,validatedPolylines:S,weakPolylines:OA,maxCertainCount:d0,loopEdgeKeys:Q0,backboneEdgeKeys:i0,highlightedEdgeKey:T,neighbors:c,validatedSourceId:Io,weakSourceId:Lo,neighborPolylines:Nt,showNeighborLines:ae,neighborSourceId:No,neighborLinkScores:P0,basemapMode:t}),v=R.useMemo(()=>{const z=new Set;for(const lA of E.hubNodes){z.add(lA);for(const mA of E.validatedEdges)mA.fromHash===lA&&z.add(mA.toHash),mA.toHash===lA&&z.add(mA.fromHash)}return z},[E.hubNodes,E.validatedEdges]),D=R.useMemo(()=>{const z=new Set;if(!g)return z;for(const lA of E.validatedEdges)lA.fromHash===g&&z.add(lA.toHash),lA.toHash===g&&z.add(lA.fromHash);return z},[g,E.validatedEdges]),F=R.useMemo(()=>{const z=new Map;for(const[lA,mA]of mt)z.set(lA,fu(mA).type);return z},[mt]),X=R.useMemo(()=>{let z=0,lA=0,mA=0;for(const[,FA]of F)FA==="repeater"?z++:FA==="companion"||FA==="unknown"?lA++:FA==="room_server"&&mA++;return{repeater:z,companion:lA,room_server:mA,hubs:E.hubNodes.length,direct:Pe.size}},[F,E.hubNodes.length,Pe.size]),Y=R.useMemo(()=>new Set(Se),[Se]),{getNodeOpacity:hA}=G2({activeFilters:Y,neighborHashes:mt.map(([z])=>z),hubConnectedNodes:v,directNodeSet:Pe,localConnectedNodes:D,nodeTypeMap:F,showTopology:MA}),{blinkingNodes:RA,blinkColor:XA}=Y2({neighbors:c,localHash:g,enabled:IA}),Ae=R.useCallback(z=>{if(Y.size===0)return!1;const lA=F.get(z)??"unknown";return!!(Y.has("repeater")&&lA==="repeater"||Y.has("companion")&&(lA==="companion"||lA==="unknown")||Y.has("room_server")&&lA==="room_server"||Y.has("direct")&&Pe.has(z)||Y.has("hubs")&&v.has(z))},[Y,F,Pe,v]),ce=R.useCallback(()=>{f0(!0),F0(!0)},[]),Ge=R.useCallback(()=>{at?Ke(z=>!z):ce()},[at,ce]),bt=R.useCallback(z=>{bA(z.viewState),(z.viewState.pitch??0)>10&&!ue&&Xe(!0)},[ue]),Ct=R.useCallback(()=>{TA(z=>{var FA,VA,xe,tt,Me,ut,Ze;const lA=!z,mA=(xe=(VA=(FA=_.current)==null?void 0:FA.getContainer())==null?void 0:VA.closest(".map-container-fullscreen, .map-container-16-9"))==null?void 0:xe.parentElement;return lA?mA&&document.fullscreenEnabled?(tt=mA.requestFullscreen)==null||tt.call(mA).catch(()=>{}):mA&&document.webkitFullscreenEnabled&&((Me=mA.webkitRequestFullscreen)==null||Me.call(mA)):document.fullscreenElement?(ut=document.exitFullscreen)==null||ut.call(document).catch(()=>{}):document.webkitFullscreenElement&&((Ze=document.webkitExitFullscreen)==null||Ze.call(document)),lA})},[]),pt=R.useCallback(()=>{const z=Se.length>=un.length;Qe(z?[]:[...un])},[Se,Qe]),Re=R.useCallback(z=>{Se.length>=un.length?Qe([z]):Se.includes(z)?Qe(Se.filter(mA=>mA!==z)):Qe([...Se,z])},[Se,Qe]),Et=R.useCallback(()=>{$e(z=>!z)},[]),m0=R.useCallback(()=>{UA(z=>!z)},[]),l0=R.useCallback(()=>{vt(z=>{const lA=!z;return lA||Kt(null),lA})},[]),H0=R.useCallback(()=>{Xe(z=>{const lA=!z;if(_.current){const mA=_.current.getMap();mA&&mA.stop()}if(lA&&_.current){const mA=_.current.getMap();mA&&mA.easeTo({pitch:45,duration:1500,easing:Ls})}if(!lA&&_.current){const mA=_.current.getMap();mA&&mA.easeTo({pitch:0,bearing:0,duration:800,easing:ou})}return lA})},[]),qt=R.useCallback(()=>{MA||Ke(!0)},[MA]),S0=R.useCallback((z,lA)=>{b0(z),c0(lA)},[]),nr=R.useCallback(()=>{zt&&y&&y(zt),b0(null),c0("")},[zt,y]),or=R.useMemo(()=>[...B1,...k1,...be?[Hn]:[]],[be]),Vr=R.useCallback(z=>{var mA;if((mA=z.features)==null?void 0:mA.some(FA=>{var VA,xe;return(xe=(VA=FA.layer)==null?void 0:VA.id)==null?void 0:xe.startsWith("node-markers-")})){$A(null),st(null);return}if(be&&z.features&&z.features.length>0){const FA=z.features.find(VA=>{var xe;return((xe=VA.layer)==null?void 0:xe.id)===Hn});if(FA!=null&&FA.properties){const{fromHash:VA,toHash:xe}=FA.properties;if(VA&&xe){const tt=K.find(Me=>Me.nodeA.hash===VA&&Me.nodeB.hash===xe||Me.nodeA.hash===xe&&Me.nodeB.hash===VA);if(tt){Kt(tt),xt(null);return}}}}xt(null),$A(null),st(null),v0(null),Kt(null)},[be,K]),Wr=R.useCallback(z=>{v0(lA=>lA===z?null:z),Kt(null)},[]),Yr=R.useCallback(z=>{var Me,ut,Ze;if(!z.features||z.features.length===0)return;if(z.features.some(yt=>{var ot,St;return(St=(ot=yt.layer)==null?void 0:ot.id)==null?void 0:St.startsWith("node-markers-")})){ze&&(st(null),$A(null));return}if(be&&z.features.some(yt=>{var ot;return((ot=yt.layer)==null?void 0:ot.id)===Hn})){try{(Me=_.current)!=null&&Me.getCanvas()&&(_.current.getCanvas().style.cursor="pointer")}catch{}return}const mA=z.features.find(yt=>{var St;const ot=(St=yt.layer)==null?void 0:St.id;return(ot==null?void 0:ot.startsWith("topology-"))||(ot==null?void 0:ot.startsWith("neighbor-"))});if(!mA)return;const FA=(ut=mA.layer)==null?void 0:ut.id,VA=mA.properties;if(!(VA!=null&&VA.key))return;const xe=FA==null?void 0:FA.startsWith("topology-"),tt=FA==null?void 0:FA.startsWith("neighbor-");if(xe||tt){const yt=VA.key.replace(/-loop[12]$/,"");st(yt),z.lngLat&&$A({longitude:z.lngLat.lng,latitude:z.lngLat.lat,type:xe?"topology":"neighbor",properties:VA})}try{(Ze=_.current)!=null&&Ze.getCanvas()&&(_.current.getCanvas().style.cursor="pointer")}catch{}},[ze,be]),Ft=R.useCallback(()=>{var z;st(null),$A(null);try{(z=_.current)!=null&&z.getCanvas()&&(_.current.getCanvas().style.cursor="")}catch{}},[]),ir=sA?"map-container-fullscreen":"map-container-16-9",a0=kA.length>0||(u==null?void 0:u.latitude)&&(u==null?void 0:u.longitude),Ne=!aA||!a0,M0=a0;return p.jsxs("div",{className:`relative ${ir} ${sA?"":"rounded-2xl overflow-hidden"}`,role:"application","aria-label":"Mesh network contacts map","aria-describedby":"map-instructions","data-basemap":t,children:[p.jsx("span",{id:"map-instructions",className:"sr-only",children:"Interactive map showing mesh network contacts. Use mouse or touch to pan and zoom. Press Tab to navigate map controls. Press Escape to exit fullscreen mode."}),Ne&&p.jsx("div",{className:"absolute inset-0 z-50 surface-base rounded-2xl flex items-center justify-center","aria-hidden":"true",children:p.jsxs("div",{className:"flex flex-col items-center gap-3",children:[p.jsx("div",{className:"w-6 h-6 border-2 border-sys-blue border-t-transparent rounded-full animate-spin"}),p.jsx("span",{className:"text-sm text-fg-muted",children:"Loading map..."})]})}),M0&&p.jsx("div",{className:`relative w-full h-full ${sA?"":"rounded-[1.125rem] overflow-hidden"} ${Ne?"opacity-0":"opacity-100 transition-opacity duration-300"}`,style:fA?{visibility:"hidden"}:void 0,children:p.jsxs(ja,{ref:_,...NA,onMove:bt,mapStyle:H1,style:{width:"100%",height:"100%"},attributionControl:!1,interactiveLayerIds:or,onMouseMove:Yr,onMouseLeave:Ft,onClick:Vr,onError:z=>{console.error("MapLibre error:",z.error)},onIdle:()=>{if(!CA&&!DA&&_.current){const z=_.current.getMap();if(z){const lA=Object.values(c).filter(mA=>mA.latitude&&mA.longitude).map(mA=>({latitude:mA.latitude,longitude:mA.longitude}));u!=null&&u.latitude&&(u!=null&&u.longitude)&&lA.push({latitude:u.latitude,longitude:u.longitude}),lA.length>0&&jA(lA,z)}}},children:[p.jsx(Ia,{position:"bottom-right"}),p.jsx(La,{mode:t}),p.jsx(h2,{enabled:ue,exaggeration:4}),p.jsx(f2,{coveragePoints:It,visible:It.length>0&&dt,terrainEnabled:ue,brightness:rA,basemapMode:t}),p.jsx(F2,{partition:k,nodeCoordinates:Te,visible:Ie&&at,opacity:oe.opacity,bandwidth:oe.bandwidth,threshold:oe.threshold,strokeWidth:oe.strokeWidth}),p.jsx(M1,{showTopology:MA,isExiting:z0,hoveredEdgeKey:ze,highlightedLoopEdges:ye==null?void 0:ye.highlightedEdgeKeys,highlightedFocusEdges:s0,onEdgeHover:_e,onLoopHover:ie,loops:E.loops,neighborNames:Lt,opacityBias:N0,widthMultiplier:er,trafficFilter:k0,showNeighborLines:ae,disableHover:E0||gA}),p.jsx(N1,{visible:be,nodeCoordinates:Te,focusedNodeHash:jt,basemapMode:t}),x&&p.jsx(D1,{targetHash:x,nodeCoordinates:Te,onComplete:C}),T&&p.jsx(_1,{highlightedEdgeKey:T,validatedPolylines:S,weakPolylines:OA,onEnsureTopology:qt}),p.jsx(z1,{ghost:P??null,neighborCoordinates:Te,onHighlightedNeighborsChange:wt}),p.jsx(v1,{neighborsWithLocation:mt,localNode:u,localHash:g,zeroHopNeighbors:Pe,lastHopNeighborMap:gt,meshTopology:E,hoveredMarker:Je,onMarkerHover:Be,getNodeOpacity:hA,shouldShowNode:Ae,onRequestRemove:y?S0:void 0,openPopupId:Zt,onOpenPopup:kt,onClosePopup:o0,onNodeClick:Wr,blinkingNodes:RA,blinkColor:XA})]})}),(()=>{const z=Y1(He?{type:He.type,properties:He.properties}:null,ye,d0,E.edgeMap);return z&&p.jsx("div",{className:"map-edge-tooltip",children:p.jsx("div",{className:"map-control-surface map-edge-tooltip-inner",children:p.jsx(K1,{data:z})})})})(),p.jsx(mc,{mapRef:_,showNeighborLines:ae,onToggleNeighborLines:Et,hasNeighborPolylines:Nt.length>0,nodeFilters:Se,onToggleFilter:Re,onToggleAll:pt,filterCounts:X,showCoverage:ZA,onToggleCoverage:m0,showMinCut:Ie,onToggleMinCut:C0,hasMinCutData:at&&k!==null&&k.numCommunities>1,show3DTerrain:ue,onToggle3DTerrain:H0,basemapMode:t,onToggleBasemap:b,isFullscreen:sA,onToggleFullscreen:Ct,showLinkQuality:be,onToggleLinkQuality:l0,hasTraceLinks:V}),be&&Yt&&p.jsx(ff,{pair:Yt,onClose:()=>Kt(null),prefixToName:h0}),p.jsxs("div",{className:"map-legend-stack",children:[p.jsxs("div",{className:"map-tool-row",children:[p.jsx(bc,{isActive:MA,hasAnalyzed:at,isLoading:gA,onClick:Ge,basemapMode:t}),p.jsx(_c,{isActive:IA,onClick:xA,basemapMode:t}),p.jsx(Fc,{isActive:It.length>0&&dt,onClick:pA,basemapMode:t})]}),p.jsx(fc,{showTopology:MA,validatedPolylineCount:S.length,filteredNeighborCount:mt.length,hasLocalNode:!!(u!=null&&u.latitude&&(u!=null&&u.longitude)),meshTopology:E,zeroHopNeighbors:Pe,neighborsWithLocation:mt,basemapMode:t})]}),p.jsx(Pa,{isOpen:zt!==null,onCancel:()=>b0(null),onConfirm:nr,title:"Remove Node?",message:`Remove "${tr}" from the contacts list? This will hide the node until it sends a new packet.`,confirmLabel:"Remove",cancelLabel:"Cancel",variant:"danger"}),p.jsx(qa,{isOpen:rr,onClose:()=>{F0(!1),f0(!1),h(),n0(!0),setTimeout(()=>Ke(!0),sc)}}),p.jsx(tf,{}),p.jsx(nf,{visible:Ie&&at,onClose:()=>qe(!1),settings:oe,onSettingsChange:me,partition:k,totalNodes:Object.keys(c).length,basemapMode:t})]})}export{jh as default}; +`&&d.push(vt),AA;case"area":case"base":case"br":case"col":case"embed":case"hr":case"img":case"keygen":case"link":case"meta":case"param":case"source":case"track":case"wbr":d.push(Be(w));for(var Dt in B)if(O.call(B,Dt)&&(AA=B[Dt],AA!=null))switch(Dt){case"children":case"dangerouslySetInnerHTML":throw Error(u(399,w));default:Ce(d,N,Dt,AA)}return d.push(pe),null;case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return Xe(d,B,w,N);case"html":return tA.insertionMode===0&&d.push(ze),Xe(d,B,w,N);default:if(w.indexOf("-")===-1&&typeof B.is!="string")return Xe(d,B,w,N);d.push(Be(w)),dA=AA=null;for(ke in B)if(O.call(B,ke)&&(_A=B[ke],_A!=null))switch(ke){case"children":AA=_A;break;case"dangerouslySetInnerHTML":dA=_A;break;case"style":oe(d,N,_A);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":break;default:aA(ke)&&typeof _A!="function"&&typeof _A!="symbol"&&d.push(me,_(ke),ue,_(fA(_A)),Ye)}return d.push(Se),Ke(d,dA,AA),AA}}var jt=E(""),Yt=E(''),N0=E(""),er=E(''),zt=E(""),b0=E(""),tr=E("");function gA(d,w,B){if(x(d,er),B===null)throw Error(u(395));return x(d,B),C(d,k0)}var f0=E('"),n0=E('"),kt=E('"),It=E(''),rA=E(""),pA=E(''),xA=E(""),t=E(''),ge=E(""),De=E(''),$A=E("");function ye(d,w,B,N){switch(B.insertionMode){case 0:case 1:return x(d,f0),x(d,w.segmentPrefix),x(d,_(N.toString(16))),C(d,at);case 2:return x(d,n0),x(d,w.segmentPrefix),x(d,_(N.toString(16))),C(d,Zt);case 3:return x(d,kt),x(d,w.segmentPrefix),x(d,_(N.toString(16))),C(d,o0);case 4:return x(d,It),x(d,w.segmentPrefix),x(d,_(N.toString(16))),C(d,dt);case 5:return x(d,pA),x(d,w.segmentPrefix),x(d,_(N.toString(16))),C(d,IA);case 6:return x(d,t),x(d,w.segmentPrefix),x(d,_(N.toString(16))),C(d,b);case 7:return x(d,De),x(d,w.segmentPrefix),x(d,_(N.toString(16))),C(d,He);default:throw Error(u(397))}}function lt(d,w){switch(w.insertionMode){case 0:case 1:return C(d,Fe);case 2:return C(d,xt);case 3:return C(d,wt);case 4:return C(d,rA);case 5:return C(d,xA);case 6:return C(d,ge);case 7:return C(d,$A);default:throw Error(u(397))}}var _e=E('function $RS(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("'),ie=E('$RS("'),et=E('","'),Lt=E('")<\/script>'),h0=E('function $RC(a,b){a=document.getElementById(a);b=document.getElementById(b);b.parentNode.removeChild(b);if(a){a=a.previousSibling;var f=a.parentNode,c=a.nextSibling,e=0;do{if(c&&8===c.nodeType){var d=c.data;if("/$"===d)if(0===e)break;else e--;else"$"!==d&&"$?"!==d&&"$!"!==d||e++}d=c.nextSibling;f.removeChild(c);c=d}while(c);for(;b.firstChild;)f.insertBefore(b.firstChild,c);a.data="$";a._reactRetry&&a._reactRetry()}};$RC("'),mt=E('$RC("'),Te=E('","'),gt=E('")<\/script>'),Pe=E('function $RX(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())};$RX("'),At=E('$RX("'),P0=E('"'),nt=E(")<\/script>"),YA=E(","),S=/[<\u2028\u2029]/g;function OA(d){return JSON.stringify(d).replace(S,function(w){switch(w){case"<":return"\\u003c";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";default:throw Error("escapeJSStringsForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React")}})}var Nt=Object.assign,Q0=Symbol.for("react.element"),i0=Symbol.for("react.portal"),s0=Symbol.for("react.fragment"),d0=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),C0=Symbol.for("react.provider"),$t=Symbol.for("react.context"),O0=Symbol.for("react.forward_ref"),z0=Symbol.for("react.suspense"),E0=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),D=Symbol.for("react.scope"),F=Symbol.for("react.debug_trace_mode"),X=Symbol.for("react.legacy_hidden"),Y=Symbol.for("react.default_value"),hA=Symbol.iterator;function RA(d){if(d==null)return null;if(typeof d=="function")return d.displayName||d.name||null;if(typeof d=="string")return d;switch(d){case s0:return"Fragment";case i0:return"Portal";case k:return"Profiler";case d0:return"StrictMode";case z0:return"Suspense";case E0:return"SuspenseList"}if(typeof d=="object")switch(d.$$typeof){case $t:return(d.displayName||"Context")+".Consumer";case C0:return(d._context.displayName||"Context")+".Provider";case O0:var w=d.render;return d=d.displayName,d||(d=w.displayName||w.name||"",d=d!==""?"ForwardRef("+d+")":"ForwardRef"),d;case h:return w=d.displayName||null,w!==null?w:RA(d.type)||"Memo";case v:w=d._payload,d=d._init;try{return RA(d(w))}catch{}}return null}var XA={};function Ae(d,w){if(d=d.contextTypes,!d)return XA;var B={},N;for(N in d)B[N]=w[N];return B}var ce=null;function Ge(d,w){if(d!==w){d.context._currentValue=d.parentValue,d=d.parent;var B=w.parent;if(d===null){if(B!==null)throw Error(u(401))}else{if(B===null)throw Error(u(401));Ge(d,B)}w.context._currentValue=w.value}}function bt(d){d.context._currentValue=d.parentValue,d=d.parent,d!==null&&bt(d)}function Ct(d){var w=d.parent;w!==null&&Ct(w),d.context._currentValue=d.value}function pt(d,w){if(d.context._currentValue=d.parentValue,d=d.parent,d===null)throw Error(u(402));d.depth===w.depth?Ge(d,w):pt(d,w)}function Re(d,w){var B=w.parent;if(B===null)throw Error(u(402));d.depth===B.depth?Ge(d,B):Re(d,B),w.context._currentValue=w.value}function Et(d){var w=ce;w!==d&&(w===null?Ct(d):d===null?bt(w):w.depth===d.depth?Ge(w,d):w.depth>d.depth?pt(w,d):Re(w,d),ce=d)}var m0={isMounted:function(){return!1},enqueueSetState:function(d,w){d=d._reactInternals,d.queue!==null&&d.queue.push(w)},enqueueReplaceState:function(d,w){d=d._reactInternals,d.replace=!0,d.queue=[w]},enqueueForceUpdate:function(){}};function l0(d,w,B,N){var tA=d.state!==void 0?d.state:null;d.updater=m0,d.props=B,d.state=tA;var AA={queue:[],replace:!1};d._reactInternals=AA;var dA=w.contextType;if(d.context=typeof dA=="object"&&dA!==null?dA._currentValue:N,dA=w.getDerivedStateFromProps,typeof dA=="function"&&(dA=dA(B,tA),tA=dA==null?tA:Nt({},tA,dA),d.state=tA),typeof w.getDerivedStateFromProps!="function"&&typeof d.getSnapshotBeforeUpdate!="function"&&(typeof d.UNSAFE_componentWillMount=="function"||typeof d.componentWillMount=="function"))if(w=d.state,typeof d.componentWillMount=="function"&&d.componentWillMount(),typeof d.UNSAFE_componentWillMount=="function"&&d.UNSAFE_componentWillMount(),w!==d.state&&m0.enqueueReplaceState(d,d.state,null),AA.queue!==null&&0>=dA,tA-=dA,{id:1<<32-S0(w)+tA|B<>>=0,d===0?32:31-(nr(d)/or|0)|0}function Wr(d,w){return d===w&&(d!==0||1/d===1/w)||d!==d&&w!==w}var Yr=typeof Object.is=="function"?Object.is:Wr,Ft=null,ir=null,a0=null,Ne=null,M0=!1,z=!1,lA=0,mA=null,FA=0;function VA(){if(Ft===null)throw Error(u(321));return Ft}function xe(){if(0d.progressiveChunkSize)N.rootSegmentID=d.nextSegmentId++,d.completedBoundaries.push(N),gA(w,d.responseState,N.id),Mr(d,w,B);else{if(C(w,N0),B=N.completedSegments,B.length!==1)throw Error(u(391));Br(d,w,B[0])}return C(w,b0)}function sr(d,w,B){return ye(w,d.responseState,B.formatContext,B.id),Br(d,w,B),lt(w,B.formatContext)}function xn(d,w,B){for(var N=B.completedSegments,tA=0;tA{const P=`set txdelay ${x.toFixed(1)} +set direct.txdelay ${C.toFixed(1)}`;try{await navigator.clipboard.writeText(P),y(!0),setTimeout(()=>y(!1),1500)}catch{const E=document.createElement("textarea");E.value=P,E.style.position="fixed",E.style.opacity="0",document.body.appendChild(E),E.select();try{document.execCommand("copy"),y(!0),setTimeout(()=>y(!1),1500)}catch{console.error("Failed to copy")}document.body.removeChild(E)}};return p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsxs("button",{onClick:T,className:"flex items-center gap-2 flex-1 py-1 px-1.5 bg-sys-amber/5 hover:bg-sys-amber/10 rounded transition-colors group",title:"Click to copy CLI commands",children:[p.jsx(Ru,{className:"w-3 h-3 text-sys-amber shrink-0"}),p.jsx("span",{className:"text-fg-muted",children:"TxDelay"}),p.jsxs("div",{className:"flex gap-2",children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("span",{className:"text-fg-muted",children:"F"}),p.jsxs("span",{className:"data-box data-box-compact text-sys-amber",children:["×",x.toFixed(1)]})]}),p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("span",{className:"text-fg-muted",children:"D"}),p.jsxs("span",{className:"data-box data-box-compact text-sys-amber",children:["×",C.toFixed(1)]})]})]}),g?p.jsx(zo,{className:"w-3 h-3 text-sys-green ml-auto"}):p.jsx(Ho,{className:"w-3 h-3 text-fg-muted opacity-0 group-hover:opacity-100 transition-opacity ml-auto"})]}),u&&p.jsx("button",{onClick:u,className:"p-1 text-fg-secondary hover:text-sys-red hover:bg-sys-red/10 rounded transition-colors",title:"Remove from contacts",children:p.jsx(Go,{className:"w-3.5 h-3.5"})})]})}function h1({hash:c,hashPrefix:u,name:g,isHub:y,isGateway:x,isBackbone:C,isZeroHop:T,isMobile:P,isRoomServer:_,isStale:E,lastSeenTimestamp:Q,centrality:O,affinity:H,meanSnr:V,meanRssi:K,neighbor:aA,onRemove:J,txDelayRec:eA}){const[Z,uA]=R.useState(!1),oA=async()=>{try{await navigator.clipboard.writeText(c),uA(!0),setTimeout(()=>uA(!1),1500)}catch(DA){console.error("Failed to copy hash:",DA);const CA=document.createElement("textarea");CA.value=c,CA.style.position="fixed",CA.style.opacity="0",document.body.appendChild(CA),CA.select();try{document.execCommand("copy"),uA(!0),setTimeout(()=>uA(!1),1500)}catch{console.error("Fallback copy also failed")}document.body.removeChild(CA)}},vA=T?"Direct":H!=null&&H.typicalHopPosition?`${H.typicalHopPosition}-hop`:null,iA=eA&&!eA.insufficientData,fA={hub:"Hub: High-connectivity node that bridges many paths",backbone:"Backbone: Critical relay with high traffic",relay:"Relay: Standard forwarding node",edge:"Edge: Peripheral node"},jA={high:"1000+ packets",medium:"500-999 packets",low:"100-499 packets",insufficient:"Insufficient data"};return p.jsxs("div",{className:"w-[240px] pr-2",children:[p.jsx("div",{className:"text-[14px] font-semibold text-fg-primary leading-tight truncate mb-1",children:g}),p.jsxs("div",{className:"flex items-center gap-1 flex-wrap mb-1.5",children:[p.jsx("code",{className:"type-data-xs text-fg-secondary bg-data-box-bg border border-data-box-border px-1 py-0.5 rounded",children:u}),p.jsx("button",{onClick:oA,className:"p-0.5 hover:bg-subtle-fill-hover rounded transition-colors",title:"Copy full hash",children:Z?p.jsx(zo,{className:"w-3 h-3 text-sys-green"}):p.jsx(Ho,{className:"w-3 h-3 text-fg-secondary"})}),p.jsx(uu,{hash:c,size:"sm"}),vA&&p.jsx(y0,{color:T?ki.direct:ki.multihop,compact:!0,children:vA}),aA.is_repeater&&p.jsx(y0,{color:Lr.repeater,compact:!0,children:"Rptr"}),y&&p.jsx(y0,{color:Lr.hub,compact:!0,title:"Hub: ≥10% of last-hop traffic",children:"Hub"}),x&&!y&&p.jsx(y0,{color:Lr.gateway,compact:!0,title:"Gateway: 7-10% of last-hop traffic",children:"Gate"}),C&&p.jsx(y0,{color:Lr.backbone,compact:!0,title:"Backbone",children:"Bone"}),P&&p.jsx(y0,{color:Lr.mobile,compact:!0,children:"Mobile"}),_&&p.jsx(y0,{color:Lr.room,compact:!0,children:"Room"}),E&&Q&&p.jsxs(y0,{compact:!0,title:"Neighbor not heard in 7+ days",children:["Idle ",c1(Q)]})]}),p.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-secondary mb-1.5",children:[p.jsxs("span",{className:"flex items-center gap-0.5",children:[p.jsx(Fs,{className:"w-3 h-3 text-fg-muted shrink-0"}),p.jsx("span",{className:"font-mono",children:bs(aA.last_seen)})]}),(H==null?void 0:H.distanceMeters)&&p.jsxs("span",{className:"flex items-center gap-0.5",children:[p.jsx(cu,{className:"w-3 h-3 text-fg-muted shrink-0"}),p.jsx("span",{className:"font-mono font-semibold text-fg-primary",children:u1(H.distanceMeters)})]}),aA.latitude&&aA.longitude&&aA.latitude!==0&&aA.longitude!==0&&p.jsxs("span",{className:"flex items-center gap-0.5",children:[p.jsx(gu,{className:"w-3 h-3 text-fg-muted shrink-0"}),p.jsxs("span",{className:"font-mono text-fg-muted",children:[aA.latitude.toFixed(2),", ",aA.longitude.toFixed(2)]})]})]}),p.jsx("div",{className:"mb-1.5",style:{width:224},children:p.jsx(a1,{nodeHash:c,width:224,height:26,showArea:!0,showTooltip:!0})}),p.jsxs("div",{className:"flex gap-3 text-xs mb-1.5",children:[p.jsxs("div",{className:"flex-1 space-y-1",children:[p.jsxs("div",{className:"flex justify-between items-center gap-2",children:[p.jsx("span",{className:"text-fg-muted",children:"Packets"}),p.jsx("span",{className:"data-box data-box-compact",children:(H==null?void 0:H.frequency)||0})]}),T&&V!==void 0&&p.jsxs("div",{className:"flex justify-between items-center gap-2",children:[p.jsx("span",{className:"text-fg-muted",children:"SNR"}),p.jsxs("span",{className:"data-box data-box-compact",children:[V.toFixed(1)," dB"]})]}),iA&&eA.networkRole&&p.jsxs("div",{className:"flex justify-between items-center gap-2",children:[p.jsx("span",{className:"text-fg-muted",children:"Role"}),p.jsx(y0,{color:hu[eA.networkRole],compact:!0,title:fA[eA.networkRole],children:eA.networkRole})]})]}),p.jsxs("div",{className:"flex-1 space-y-1",children:[p.jsxs("div",{className:"flex justify-between items-center gap-2",children:[p.jsx("span",{className:"text-fg-muted",children:"Adverts"}),p.jsx("span",{className:"data-box data-box-compact",children:aA.advert_count||0})]}),T&&K!==void 0&&p.jsxs("div",{className:"flex justify-between items-center gap-2",children:[p.jsx("span",{className:"text-fg-muted",children:"RSSI"}),p.jsxs("span",{className:"data-box data-box-compact",children:[Math.round(K)," dBm"]})]}),iA&&eA.dataConfidence&&p.jsxs("div",{className:"flex justify-between items-center gap-2",children:[p.jsx("span",{className:"text-fg-muted",children:"Data"}),p.jsx(y0,{color:du[eA.dataConfidence],compact:!0,title:jA[eA.dataConfidence],children:eA.dataConfidence})]})]}),!iA&&J&&p.jsx("button",{onClick:J,className:"p-1 self-start text-fg-secondary hover:text-sys-red hover:bg-sys-red/10 rounded transition-colors",title:"Remove from contacts",children:p.jsx(Go,{className:"w-3.5 h-3.5"})})]}),iA&&p.jsx(f1,{txDelayRec:eA,onRemove:J})]})}const Pn="node-markers-native",Ro="node-markers-layer",jo="node-markers-layer-local",je={standard:"marker-standard",standardNeighbor:"marker-standard-neighbor",hub:"marker-hub",hubNeighbor:"marker-hub-neighbor",gateway:"marker-gateway",gatewayNeighbor:"marker-gateway-neighbor",mobile:"marker-mobile",mobileNeighbor:"marker-mobile-neighbor",roomServer:"marker-room-server",roomServerNeighbor:"marker-room-server-neighbor",local:"marker-local",stale5Day:"marker-stale-5day",stale10Day:"marker-stale-10day",blinkBlack:"marker-blink-black",blinkBlackLocal:"marker-blink-black-local",blink:"marker-blink",blinkLocal:"marker-blink-local"},d1=10,m1=6,g1=5,p1=10,os={tier1:j0[500],tier2:j0[700]};function y1(c){if(!c)return 0;const u=Date.now(),g=c*1e3,y=(u-g)/(1e3*60*60*24);return y>=p1?2:y>=g1?1:0}const Wt=2,x1=Os*Wt,is=So*Wt;function w1(c){const u=Fo(),g=(P,_,E=0,Q=!1)=>{const O=x1,H=document.createElement("canvas");H.width=O,H.height=O;const V=H.getContext("2d",Q?{colorSpace:"display-p3"}:void 0),K=O/2,aA=O/2,J=O/2-2-E/2;return V.beginPath(),V.arc(K,aA,J,0,Math.PI*2),V.fillStyle=P,V.fill(),_&&E>0&&(V.strokeStyle=_,V.lineWidth=E*Wt,V.stroke()),V.shadowColor="rgba(0,0,0,0.3)",V.shadowBlur=2*Wt,V.shadowOffsetY=1*Wt,{data:V.getImageData(0,0,O,O),pixelRatio:Wt}},y=(P,_=!1)=>{const E=is,Q=document.createElement("canvas");Q.width=E,Q.height=E;const O=Q.getContext("2d",_?{colorSpace:"display-p3"}:void 0),H=E/2,V=E/2,K=So*.35*Wt;return O.strokeStyle=P,O.lineWidth=2.5*Wt,O.lineCap="round",O.lineJoin="round",O.beginPath(),O.moveTo(H-K,V),O.lineTo(H,V-K),O.lineTo(H+K,V),O.stroke(),O.beginPath(),O.moveTo(H-K*.7,V),O.lineTo(H-K*.7,V+K*.7),O.lineTo(H+K*.7,V+K*.7),O.lineTo(H+K*.7,V),O.stroke(),O.beginPath(),O.moveTo(H-K*.2,V+K*.7),O.lineTo(H-K*.2,V+K*.2),O.lineTo(H+K*.2,V+K*.2),O.lineTo(H+K*.2,V+K*.7),O.stroke(),{data:O.getImageData(0,0,E,E),pixelRatio:Wt}},x=(P,_)=>{const E=is,Q=document.createElement("canvas");Q.width=E,Q.height=E;const O=Q.getContext("2d"),H=E/2,V=E/2,K=So*.35*Wt;return O.strokeStyle=P,O.lineWidth=2.5*Wt,O.lineCap="round",O.lineJoin="round",_&&(O.fillStyle=_),O.beginPath(),O.roundRect(H-K,V-K*.6,K*1.6,K*1.2,3*Wt),_&&O.fill(),O.stroke(),O.beginPath(),O.moveTo(H-K*.3,V+K*.6),O.lineTo(H-K*.6,V+K),O.lineTo(H,V+K*.6),O.stroke(),{data:O.getImageData(0,0,E,E),pixelRatio:Wt}},C="#00FF00",T={[je.standard]:g(u.nodeFill),[je.standardNeighbor]:g(u.neighborColor),[je.hub]:g(u.hubColor),[je.hubNeighbor]:g(u.neighborColor),[je.gateway]:g(u.gatewayColor),[je.gatewayNeighbor]:g(u.neighborColor),[je.mobile]:g("transparent",u.mobileColor,2.5),[je.mobileNeighbor]:g(u.neighborColor),[je.roomServer]:x(u.roomColor),[je.roomServerNeighbor]:x(u.neighborColor,"#1a1a1c"),[je.local]:y(u.localColor),[je.stale5Day]:g(os.tier1),[je.stale10Day]:g(os.tier2),[je.blinkBlack]:g("#000000"),[je.blinkBlackLocal]:y("#000000"),[je.blink]:g(C,void 0,0,!0),[je.blinkLocal]:y(C,!0)};for(const[P,_]of Object.entries(T))try{c.hasImage(P)&&c.removeImage(P),c.addImage(P,_.data,{pixelRatio:_.pixelRatio})}catch{}}function ss(c){var g;const u=(g=c.contact_type)==null?void 0:g.toLowerCase();return u==="room server"||u==="room_server"||u==="room"||u==="server"}function xo(c){return c.startsWith("0x")?c.slice(2,4).toUpperCase():c.slice(0,2).toUpperCase()}function v1({neighborsWithLocation:c,localNode:u,localHash:g,zeroHopNeighbors:y,lastHopNeighborMap:x,meshTopology:C,hoveredMarker:T,onMarkerHover:P,getNodeOpacity:_,shouldShowNode:E,onRequestRemove:Q,openPopupId:O,onOpenPopup:H,onClosePopup:V,onNodeClick:K,blinkingNodes:aA}){const{current:J}=Ar(),eA=R.useRef(!1),[Z,uA]=R.useState(!1);R.useEffect(()=>{var ZA;const cA=(ZA=J==null?void 0:J.getMap)==null?void 0:ZA.call(J);if(!cA)return;const sA=()=>{try{w1(cA),eA.current=!0,Z||uA(!0)}catch(UA){console.warn("Failed to load node marker icons:",UA)}};cA.isStyleLoaded()?sA():cA.once("style.load",sA);const TA=()=>{cA.hasImage(je.standard)||sA()};cA.on("styledata",TA);const MA=()=>{eA.current=!1,sA()},WA=new MutationObserver(UA=>{for(const Ie of UA)if(Ie.attributeName==="data-theme"){setTimeout(MA,100);break}});WA.observe(document.documentElement,{attributes:!0});const ae=document.querySelector("[data-basemap]");let JA=null;return ae&&(JA=new MutationObserver(UA=>{for(const Ie of UA)if(Ie.attributeName==="data-basemap"){setTimeout(MA,100);break}}),JA.observe(ae,{attributes:!0})),()=>{cA.off("styledata",TA),WA.disconnect(),JA==null||JA.disconnect()}},[J,Z]);const oA=R.useMemo(()=>{var TA;const cA=[],sA=[...c].sort(([MA,WA],[ae,JA])=>{const ZA=(UA,Ie)=>{var Le;return ss(Ie)?5e3:y.has(UA)?3e3:C.hubNodes.includes(UA)?2e3:(Le=C.gatewayNodes)!=null&&Le.includes(UA)?1e3:0};return ZA(MA,WA)-ZA(ae,JA)});for(const[MA,WA]of sA){if(!WA.latitude||!WA.longitude)continue;if(g){const qe=g.startsWith("0x")?g.slice(2,4).toLowerCase():g.slice(0,2).toLowerCase(),Xe=MA.startsWith("0x")?MA.slice(2,4).toLowerCase():MA.slice(0,2).toLowerCase();if(qe===Xe||MA===g)continue}const ae=E(MA),JA=_(MA,ae);if(JA<=.01)continue;const ZA=y.has(MA),UA=C.hubNodes.includes(MA),Ie=((TA=C.gatewayNodes)==null?void 0:TA.includes(MA))??!1,Le=C.mobileNodes.includes(MA),oe=ss(WA),me=C.centrality.get(MA)||0,ue=x.get(MA),Ye=WA.last_seen||(ue==null?void 0:ue.lastSeen),be=y1(Ye),Ce=be>0;let Se=JA;be===2?Se=Math.min(JA,.25):be===1&&(Se=Math.min(JA,.5));let pe="standard";oe?pe="roomServer":UA?pe="hub":Ie?pe="gateway":Le&&(pe="mobile");const Ke=C.fullAffinity.get(MA),$e=C.txDelayRecommendations.get(MA);cA.push({type:"Feature",geometry:{type:"Point",coordinates:[WA.longitude,WA.latitude]},properties:{hash:MA,name:WA.node_name||WA.name||"Unknown",hashPrefix:xo(MA),iconType:pe,isNeighbor:ZA,isHub:UA,isGateway:Ie,isMobile:Le,isRoomServer:oe,isStale:Ce,staleTier:be,isZeroHop:ZA,opacity:Se,blinkIntensity:0,lastSeenTimestamp:Ye,centrality:me,neighborJson:JSON.stringify(WA),affinityJson:Ke?JSON.stringify(Ke):void 0,txDelayRecJson:$e?JSON.stringify($e):void 0,meanSnr:(ue==null?void 0:ue.avgSnr)??void 0,meanRssi:(ue==null?void 0:ue.avgRssi)??void 0}})}return{type:"FeatureCollection",features:cA}},[c,g,y,x,C,_,E]),vA=R.useMemo(()=>!(u!=null&&u.latitude)||!(u!=null&&u.longitude)?{type:"FeatureCollection",features:[]}:{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:[u.longitude,u.latitude]},properties:{hash:"local",name:u.name,hashPrefix:g?xo(g):"",iconType:"local",isNeighbor:!1,isHub:!1,isGateway:!1,isMobile:!1,isRoomServer:!1,isStale:!1,staleTier:0,isZeroHop:!1,opacity:1,blinkIntensity:0,centrality:0}}]},[u,g]),iA=R.useRef(O);R.useEffect(()=>{iA.current=O},[O]);const fA=R.useCallback(cA=>{var MA;if(!cA.features||cA.features.length===0)return;const TA=(MA=cA.features[0].properties)==null?void 0:MA.hash;TA&&(iA.current===TA?V==null||V():H&&H(TA),K&&TA!=="local"&&K(TA))},[H,V,K]),jA=R.useCallback(cA=>{var MA,WA;if(!cA.features||cA.features.length===0)return;const sA=(MA=J==null?void 0:J.getMap)==null?void 0:MA.call(J);sA&&(sA.getCanvas().style.cursor="pointer");const TA=(WA=cA.features[0].properties)==null?void 0:WA.hash;TA&&P(TA)},[J,P]),DA=R.useCallback(()=>{var sA;const cA=(sA=J==null?void 0:J.getMap)==null?void 0:sA.call(J);cA&&(cA.getCanvas().style.cursor=""),P(null)},[J,P]);R.useEffect(()=>{var TA;const cA=(TA=J==null?void 0:J.getMap)==null?void 0:TA.call(J);if(!cA||!Z)return;const sA=[Ro,jo];for(const MA of sA)cA.on("click",MA,fA),cA.on("mouseenter",MA,jA),cA.on("mouseleave",MA,DA);return()=>{for(const MA of sA)cA.off("click",MA,fA),cA.off("mouseenter",MA,jA),cA.off("mouseleave",MA,DA)}},[J,Z,fA,jA,DA]);const CA=R.useRef(oA),yA=R.useRef(vA);R.useEffect(()=>{CA.current=oA,yA.current=vA},[oA,vA]),R.useEffect(()=>{var MA;const cA=(MA=J==null?void 0:J.getMap)==null?void 0:MA.call(J);if(!cA||!Z||!aA||aA.size===0)return;const sA=cA.getSource(Pn),TA=cA.getSource(`${Pn}-local`);if(!(!sA&&!TA)){if(sA){const WA=CA.current;let ae=!1;const JA=WA.features.map(ZA=>{const UA=aA.get(ZA.properties.hash)??0;return UA!==ZA.properties.blinkIntensity?(ae=!0,{...ZA,properties:{...ZA.properties,blinkIntensity:UA}}):ZA});ae&&sA.setData({type:"FeatureCollection",features:JA})}if(TA&&g){const WA=aA.get(g)??0,ae=yA.current;ae.features.length>0&&ae.features[0].properties.blinkIntensity!==WA&&TA.setData({type:"FeatureCollection",features:[{...ae.features[0],properties:{...ae.features[0].properties,blinkIntensity:WA}}]})}}},[J,Z,aA,g]);const kA=R.useMemo(()=>{if(!O)return null;if(O==="local"&&u)return{longitude:u.longitude,latitude:u.latitude,isLocal:!0,name:u.name,hash:g};const cA=oA.features.find(MA=>MA.properties.hash===O);if(!cA)return null;const sA=cA.properties,TA=sA.txDelayRecJson?JSON.parse(sA.txDelayRecJson):void 0;return{longitude:cA.geometry.coordinates[0],latitude:cA.geometry.coordinates[1],isLocal:!1,hash:sA.hash,hashPrefix:sA.hashPrefix,name:sA.name,isHub:sA.isHub,isGateway:sA.isGateway,isBackbone:(TA==null?void 0:TA.networkRole)==="backbone",isZeroHop:sA.isZeroHop,isMobile:sA.isMobile,isRoomServer:sA.isRoomServer,isStale:sA.isStale,lastSeenTimestamp:sA.lastSeenTimestamp,centrality:sA.centrality,neighbor:sA.neighborJson?JSON.parse(sA.neighborJson):void 0,affinity:sA.affinityJson?JSON.parse(sA.affinityJson):void 0,txDelayRec:TA,meanSnr:sA.meanSnr,meanRssi:sA.meanRssi}},[O,u,g,oA]);if(!Z)return null;const LA=Fo(),NA=["case",[">",["get","blinkIntensity"],.66],je.blink,[">",["get","blinkIntensity"],.33],je.blinkBlack,["==",["get","staleTier"],2],je.stale10Day,["==",["get","staleTier"],1],je.stale5Day,["==",["get","iconType"],"roomServer"],["case",["get","isNeighbor"],je.roomServerNeighbor,je.roomServer],["==",["get","iconType"],"hub"],["case",["get","isNeighbor"],je.hubNeighbor,je.hub],["==",["get","iconType"],"gateway"],["case",["get","isNeighbor"],je.gatewayNeighbor,je.gateway],["==",["get","iconType"],"mobile"],["case",["get","isNeighbor"],je.mobileNeighbor,je.mobile],["case",["get","isNeighbor"],je.standardNeighbor,je.standard]],GA=["interpolate",["linear"],["zoom"],m1,.25,d1,1],bA=["get","opacity"];return p.jsxs(p.Fragment,{children:[p.jsx(X0,{id:Pn,type:"geojson",data:oA,children:p.jsx(t0,{id:Ro,type:"symbol",layout:{"icon-image":NA,"icon-size":GA,"icon-allow-overlap":!0,"icon-ignore-placement":!0,"symbol-sort-key":["get","opacity"]},paint:{"icon-opacity":bA}})}),p.jsx(X0,{id:`${Pn}-local`,type:"geojson",data:vA,children:p.jsx(t0,{id:jo,type:"symbol",layout:{"icon-image":["case",[">",["get","blinkIntensity"],.66],je.blinkLocal,[">",["get","blinkIntensity"],.33],je.blinkBlackLocal,je.local],"icon-size":GA,"icon-allow-overlap":!0,"icon-ignore-placement":!0},paint:{"icon-opacity":1}})}),kA&&V&&p.jsx(Ta,{longitude:kA.longitude,latitude:kA.latitude,offset:{center:[0,0],top:[0,T0/2+4],"top-left":[6,T0/2+4],"top-right":[-6,T0/2+4],bottom:[0,-T0/2-4],"bottom-left":[6,-T0/2-4],"bottom-right":[-6,-T0/2-4],left:[T0/2+4,0],right:[-T0/2-4,0]},maxWidth:"280px",closeOnClick:!1,onClose:V,className:"maplibre-popup",children:kA.isLocal?p.jsxs("div",{className:"text-sm",children:[p.jsx("strong",{className:"text-base",children:kA.name}),kA.hash&&p.jsx("span",{className:"ml-2 font-mono text-xs text-fg-muted surface-badge px-1.5 py-0.5 rounded",children:xo(kA.hash)}),p.jsx("br",{}),p.jsx("span",{style:{color:LA.localColor},className:"font-medium",children:"This Node (Local)"}),p.jsx("br",{}),u&&p.jsxs("span",{className:"text-xs text-fg-muted",children:[u.latitude.toFixed(5),", ",u.longitude.toFixed(5)]})]}):kA.neighbor&&kA.hash?p.jsx(h1,{hash:kA.hash,hashPrefix:kA.hashPrefix,name:kA.name,isHub:kA.isHub,isGateway:kA.isGateway,isBackbone:kA.isBackbone,isZeroHop:kA.isZeroHop,isMobile:kA.isMobile,isRoomServer:kA.isRoomServer,isStale:kA.isStale,lastSeenTimestamp:kA.lastSeenTimestamp,centrality:kA.centrality,affinity:kA.affinity,meanSnr:kA.meanSnr,meanRssi:kA.meanRssi,neighbor:kA.neighbor,txDelayRec:kA.txDelayRec,onRemove:Q?()=>Q(kA.hash,kA.name):void 0}):null})]})}const k1=[Ro,jo],Io="topology-validated-edges-native",Lo="topology-weak-edges-native",No="neighbor-edges-native",ls="topology-weak-edges-native",Qn="topology-validated-edges-native",wo="neighbor-edges-native",vo={type:"FeatureCollection",features:[]},an={"line-cap":"round","line-join":"round"},as={"line-color":"transparent","line-width":16,"line-opacity":0};function b1(c,u,g,y,x,C){const T=Uo(),P=c!==null,_=x&&x.size>0,E=C&&C.size>0,Q=_?Array.from(x):[],O=E?Array.from(C):[],H=u,V=.5,aA=(()=>{if(H<=0)return["get","baseColor"];const kA=1-H*.5;return["case",[">=",["get","brightnessScore"],kA],"#FFFFFF",["get","baseColor"]]})(),eA=H<=0?1:["max",.1,["+",1,["*",H,3,["-",["get","brightnessScore"],V]]]],uA=_?["in",["get","key"],["literal",Q]]:E?["in",["get","key"],["literal",O]]:P?["==",["get","key"],c]:!1,oA=P||_||E,vA=T.edges.hoverLoop,iA=T.edges.highlight;return{"line-color":oA?["case",uA,_?vA:E?iA:["get","hoverColor"],aA]:aA,"line-width":oA?["case",uA,["max",["*",["get","baseWidth"],g,1.3],3.5],["*",["get","baseWidth"],g]]:["*",["get","baseWidth"],g],"line-opacity":["case",["<",["get","brightnessScore"],y],0,oA?["case",uA,["min",["*",["get","baseOpacity"],1.25],1],["*",["get","baseOpacity"],eA,.35]]:["*",["get","baseOpacity"],eA]]}}const C1=10,E1=6;function S1(c){const u=c!==null,{YELLOW:g,GREEN:y,RED:x,GRAY:C}=On,T=["to-number",["get","listenerScore"],0],P=["to-number",["get","loudScore"],0],E=["/",T,["max",["+",T,P],1]],Q=["case",["all",["==",T,0],["==",P,0]],C,[">=",E,.97],y,["<=",E,.03],x,["interpolate",["linear"],E,.03,x,.5,g,.97,y]],O=.2,J=["*",["+",O,["*",["to-number",["get","trafficWeight"],0],1-O]],8],eA=5,Z=u?["case",["==",["get","key"],c],["max",J,eA],J]:J,uA=u?["case",["==",["get","key"],c],["max",["*",J,.25],eA*.25],["*",J,.25]]:["*",J,.25];return{"line-color":Q,"line-width":["interpolate",["linear"],["zoom"],E1,uA,C1,Z],"line-opacity":u?["case",["==",["get","key"],c],1,.35]:.9}}function M1({showTopology:c,isExiting:u,hoveredEdgeKey:g,highlightedLoopEdges:y,highlightedFocusEdges:x,onEdgeHover:C,onLoopHover:T,loops:P=[],neighborNames:_={},opacityBias:E=.5,widthMultiplier:Q=1,trafficFilter:O=0,showNeighborLines:H=!0,disableHover:V=!1}){const{current:K}=Ar(),aA=c||u,J=!0,eA=H?"visible":"none",Z=V||u,uA=R.useRef(null),oA=R.useRef(Z),vA=R.useRef(new Map),iA=R.useRef(_),fA=R.useRef(T);R.useLayoutEffect(()=>{oA.current=Z,iA.current=_,fA.current=T});const jA=R.useMemo(()=>Lu(P),[P]);R.useLayoutEffect(()=>{vA.current=jA},[jA]);const DA=R.useCallback(bA=>{var MA,WA;if(oA.current||!bA.features||bA.features.length===0)return;const sA=bA.features[0].properties;if(!(sA!=null&&sA.key))return;const TA=sA.key;if(TA!==uA.current){uA.current=TA;const ae=sA.isNeighborEdge===!0||sA.isNeighborEdge==="true",JA=sA.isLoopEdge===!0||sA.isLoopEdge==="true";if(ae){const ZA={key:TA,fromName:"Local",toName:sA.name,certainCount:Number(sA.packetCount)||0,confidence:1,isBackbone:!1,isLoopEdge:!1,isDirectPath:!0,isZeroHop:!0,symmetryRatio:1,dominantDirection:"balanced",isHubConnection:!1};C(TA,[bA.lngLat.lng,bA.lngLat.lat],ZA),(MA=fA.current)==null||MA.call(fA,null)}else if(JA&&fA.current){const ZA=vA.current.get(TA)??[];if(ZA.length>0){const UA=new Set;for(const me of ZA)for(const ue of me.edgeKeys)UA.add(ue);const Le=ZA[0].nodes.map(me=>iA.current[me]||me.substring(0,4)),oe={loops:ZA,highlightedEdgeKeys:UA,hoveredEdgeKey:TA,nodeNames:Le};fA.current(oe,[bA.lngLat.lng,bA.lngLat.lat]),C(TA)}else{const UA={key:TA,fromName:sA.fromName,toName:sA.toName,certainCount:Number(sA.certainCount),confidence:Number(sA.confidence),isBackbone:sA.isBackbone===!0||sA.isBackbone==="true",isLoopEdge:!0,isDirectPath:sA.isDirectPath===!0||sA.isDirectPath==="true",isZeroHop:sA.isZeroHop===!0||sA.isZeroHop==="true",symmetryRatio:Number(sA.symmetryRatio),dominantDirection:sA.dominantDirection,isHubConnection:sA.isHubConnection===!0||sA.isHubConnection==="true"};C(TA,[bA.lngLat.lng,bA.lngLat.lat],UA)}}else{const ZA={key:TA,fromName:sA.fromName,toName:sA.toName,certainCount:Number(sA.certainCount),confidence:Number(sA.confidence),isBackbone:sA.isBackbone===!0||sA.isBackbone==="true",isLoopEdge:JA,isDirectPath:sA.isDirectPath===!0||sA.isDirectPath==="true",isZeroHop:sA.isZeroHop===!0||sA.isZeroHop==="true",symmetryRatio:Number(sA.symmetryRatio),dominantDirection:sA.dominantDirection,isHubConnection:sA.isHubConnection===!0||sA.isHubConnection==="true"};C(TA,[bA.lngLat.lng,bA.lngLat.lat],ZA),(WA=fA.current)==null||WA.call(fA,null)}}},[C]),CA=R.useCallback(()=>{var bA;uA.current!==null&&(uA.current=null,C(null),(bA=fA.current)==null||bA.call(fA,null))},[C]);R.useEffect(()=>{var MA;const bA=(MA=K==null?void 0:K.getMap)==null?void 0:MA.call(K);if(!bA||!aA)return;const cA="topology-validated-edges-hitarea-native",sA=()=>{try{return bA.getStyle()&&bA.getLayer(cA)}catch{return!1}},TA=()=>sA()?(bA.on("mousemove",cA,DA),bA.on("mouseleave",cA,CA),!0):!1;if(!TA()){const WA=()=>{TA()&&bA.off("styledata",WA)};return bA.on("styledata",WA),()=>{try{bA.off("styledata",WA),sA()&&(bA.off("mousemove",cA,DA),bA.off("mouseleave",cA,CA))}catch{}}}return()=>{try{sA()&&(bA.off("mousemove",cA,DA),bA.off("mouseleave",cA,CA))}catch{}}},[K,aA,DA,CA]),R.useEffect(()=>{var MA;const bA=(MA=K==null?void 0:K.getMap)==null?void 0:MA.call(K);if(!bA||!J||!H)return;const cA="neighbor-edges-hitarea-native",sA=()=>{try{return bA.getStyle()&&bA.getLayer(cA)}catch{return!1}},TA=()=>sA()?(bA.on("mousemove",cA,DA),bA.on("mouseleave",cA,CA),!0):!1;if(!TA()){const WA=()=>{TA()&&bA.off("styledata",WA)};return bA.on("styledata",WA),()=>{try{bA.off("styledata",WA),sA()&&(bA.off("mousemove",cA,DA),bA.off("mouseleave",cA,CA))}catch{}}}return()=>{try{sA()&&(bA.off("mousemove",cA,DA),bA.off("mouseleave",cA,CA))}catch{}}},[K,J,H,DA,CA]),R.useEffect(()=>{var JA;const bA=(JA=K==null?void 0:K.getMap)==null?void 0:JA.call(K);if(!bA)return;let cA=null;const sA=(ZA,UA)=>{try{if(bA.getLayer(ZA)&&bA.getLayer(UA))return bA.moveLayer(ZA,UA),!0}catch{}return!1},TA=()=>{try{if(!bA.getLayer("node-markers-layer"))return;sA(wo,"node-markers-layer"),sA("neighbor-edges-hitarea-native",wo),(sA(Qn,"neighbor-edges-hitarea-native")||sA(Qn,"node-markers-layer"))&&sA("topology-validated-edges-hitarea-native",Qn),sA(ls,"topology-validated-edges-hitarea-native")}catch{}},MA=()=>{cA&&clearTimeout(cA),cA=setTimeout(TA,50)},WA=setTimeout(TA,100);bA.on("styledata",MA);const ae=ZA=>{(ZA.sourceId===Io||ZA.sourceId===Lo||ZA.sourceId===No)&&MA()};return bA.on("sourcedata",ae),()=>{clearTimeout(WA),cA&&clearTimeout(cA);try{bA.off("styledata",MA),bA.off("sourcedata",ae)}catch{}}},[K,aA,J,H]);const yA=Z?null:g,NA=b1(yA,E,Q,O,Z?null:y,x??null),GA=S1(yA);return p.jsxs(p.Fragment,{children:[aA&&p.jsx(X0,{id:Lo,type:"geojson",data:vo,children:p.jsx(t0,{id:ls,type:"line",paint:NA,layout:{...an,visibility:eA}})}),aA&&p.jsxs(X0,{id:Io,type:"geojson",data:vo,children:[p.jsx(t0,{id:"topology-validated-edges-hitarea-native",type:"line",paint:as,layout:{...an,visibility:eA}}),p.jsx(t0,{id:Qn,type:"line",paint:NA,layout:{...an,visibility:eA}})]}),p.jsxs(X0,{id:No,type:"geojson",data:vo,children:[p.jsx(t0,{id:"neighbor-edges-hitarea-native",type:"line",paint:as,layout:{...an,visibility:eA}}),p.jsx(t0,{id:wo,type:"line",paint:GA,layout:{...an,visibility:eA}})]})]})}const B1=["topology-validated-edges-hitarea-native","topology-validated-edges-native","topology-weak-edges-native","neighbor-edges-hitarea-native","neighbor-edges-native"];function D1({targetHash:c,nodeCoordinates:u,onComplete:g}){const{current:y}=Ar(),x=R.useRef(null);return R.useEffect(()=>{if(!y||!c||c===x.current)return;const C=u.get(c);if(!C)return;const T=y.getMap();T.isMoving()&&T.stop(),x.current=c;const[P,_]=C;y.flyTo({center:[_,P],zoom:10,duration:2500,essential:!0}),setTimeout(()=>{g==null||g()},2600)},[c,u,y,g]),null}function _1({highlightedEdgeKey:c,validatedPolylines:u,weakPolylines:g,onEnsureTopology:y}){const{current:x}=Ar(),C=R.useRef(null);return R.useEffect(()=>{if(!x||!c||c===C.current)return;C.current=c,y();const T=u.find(H=>H.edge.key===c)||g.find(H=>H.edge.key===c);if(!T||x.getMap().isMoving())return;const _=(T.from[0]+T.to[0])/2,E=(T.from[1]+T.to[1])/2,Q=x.getZoom(),O=Math.max(Q,11);x.easeTo({center:[E,_],zoom:O,duration:500})},[c,u,g,x,y]),null}const us="link-quality-edges",T1="link-quality-edges-layer",Hn="link-quality-edges-hitarea",cs={type:"FeatureCollection",features:[]};function R1(c,u){return cEa(),[]),E=R.useMemo(()=>!c||C.length===0||T.size===0?cs:j1(C,u,g,_,P),[c,C,T.size,u,g,_,P]);R.useEffect(()=>{if(!x)return;const O=x.getMap();if(O)try{const H=O.getSource(us);H&&"setData"in H&&(H.setData(E),O.triggerRepaint())}catch{}},[E,x]);const Q=c?"visible":"none";return p.jsxs(X0,{id:us,type:"geojson",data:cs,children:[p.jsx(t0,{id:T1,type:"line",layout:{...fs,visibility:Q},paint:I1}),p.jsx(t0,{id:Hn,type:"line",layout:{...fs,visibility:Q},paint:L1})]})}const F1="rgba(167, 139, 250, 0.15)",hs=500,P1=.5,ds=2e3,ms=1500,Q1=1e3;function O1(c,u,g,y=64){const x=[],T=g/6371e3*(180/Math.PI),P=T/Math.cos(u*Math.PI/180);for(let _=0;_<=y;_++){const E=_/y*2*Math.PI,Q=c+P*Math.cos(E),O=u+T*Math.sin(E);x.push([Q,O])}return{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[x]}}}function z1({ghost:c,neighborCoordinates:u,onHighlightedNeighborsChange:g}){const{current:y}=Ar(),x=R.useRef(null),C=R.useRef(null),T=R.useMemo(()=>c?new Set(c.commonNeighbors):new Set,[c]);R.useEffect(()=>{g==null||g(T)},[T,g]);const P=R.useMemo(()=>{if(!(c!=null&&c.commonNeighbors)||c.commonNeighbors.length<2)return ds*4;let Q=0;const O=[];for(const H of c.commonNeighbors){const V=u.get(H);V&&O.push(V)}c.estimatedLocation&&O.push([c.estimatedLocation.lat,c.estimatedLocation.lon]);for(let H=0;HQ&&(Q=K)}return Math.max(Q,hs*4)},[c,u]),_=R.useMemo(()=>{if(!(c!=null&&c.estimatedLocation))return{type:"FeatureCollection",features:[]};const{lat:Q,lon:O,uncertaintyM:H}=c.estimatedLocation,V=P*P1,K=H>0?H:ds,aA=Math.max(hs,Math.min(K,V));return{type:"FeatureCollection",features:[O1(O,Q,aA)]}},[c,P]);if(R.useEffect(()=>{if(!y)return;const Q=y.getMap();if(c&&c.prefix!==C.current){if(C.current=c.prefix,!x.current&&Q.getZoom()>3){const H=Q.getCenter();x.current={center:[H.lng,H.lat],zoom:Q.getZoom(),pitch:Q.getPitch(),bearing:Q.getBearing()}}const O=[];for(const H of c.commonNeighbors){const V=u.get(H);V&&O.push([V[1],V[0]])}if(c.estimatedLocation&&O.push([c.estimatedLocation.lon,c.estimatedLocation.lat]),O.length>0){const H=()=>{var V;if(Q.isMoving()){setTimeout(H,100);return}if(O.length===1)y.flyTo({center:O[0],zoom:13,duration:ms});else{let K=1/0,aA=-1/0,J=1/0,eA=-1/0;for(const[Z,uA]of O)K=Math.min(K,Z),aA=Math.max(aA,Z),J=Math.min(J,uA),eA=Math.max(eA,uA);if((V=c.estimatedLocation)!=null&&V.uncertaintyM){const Z=c.estimatedLocation.uncertaintyM/111e3;K-=Z,aA+=Z,J-=Z,eA+=Z}y.fitBounds([[K,J],[aA,eA]],{padding:{top:60,bottom:60,left:60,right:60},maxZoom:14,duration:ms})}};setTimeout(H,50)}}if(!c&&C.current!==null&&(C.current=null,x.current)){const O=x.current,H=()=>{if(Q.isMoving()){setTimeout(H,100);return}y.flyTo({center:O.center,zoom:O.zoom,pitch:O.pitch,bearing:O.bearing,duration:Q1}),x.current=null};setTimeout(H,50)}},[c,y,u]),!(c!=null&&c.estimatedLocation))return null;const E={"fill-color":F1,"fill-opacity":.8};return p.jsx(X0,{id:"ghost-uncertainty-circle",type:"geojson",data:_,children:p.jsx(t0,{id:"ghost-uncertainty-fill",type:"fill",paint:E})})}const nl=[{target:"Map",fn:"gps",minStage:1,when:yi},{target:"Map",fn:"_advertNodeType",minStage:1,when:yi},{target:"Topology",fn:"traceHops",minStage:1,when:xi},{target:"Topology",fn:"path.entries",minStage:1,when:Na},{target:"Topology",fn:"traceSrc",minStage:1,when:xi}];Rs(nl);const H1={version:8,sources:{},layers:[],glyphs:"https://tiles.basemaps.cartocdn.com/fonts/{fontstack}/{range}.pbf"},G1={longitude:0,latitude:0,zoom:2};function U1(c,u,g,y){return Ds(c,u,g,y)/1e3}function V1(c,u){if(c.length<=2)return c;let g,y;if(u!=null&&u.latitude&&(u!=null&&u.longitude))g=u.latitude,y=u.longitude;else{let E=0,Q=0;for(const[O,H]of c)E+=O,Q+=H;g=E/c.length,y=Q/c.length}const x=c.map(([E,Q])=>({pos:[E,Q],dist:U1(g,y,E,Q)}));x.sort((E,Q)=>E.dist-Q.dist);const C=Math.floor(x.length/2),T=x[C].dist,P=Math.max(T*3,50),_=x.filter(E=>E.dist<=P).map(E=>E.pos);return _.length0&&(H=Math.floor(Math.log2(360/O*1.2)),H=Math.max(1,Math.min(14,H))),H=Math.min(H+1,12),{longitude:P,latitude:_,zoom:H}}function Y1(c,u,g,y){var x;if(u){const C=u.loops[0],T=u.loops.length,P=[{label:"hops",value:C.size},{label:"seen",value:C.minCertainCount}],_=[];return C.includesLocal&&_.push({text:"★ Includes your node",color:"text-sys-amber"}),T>1&&_.push({text:`+${T-1} overlapping`,color:"text-sys-indigo/70"}),{type:"loop",title:{icon:"⟳",text:`Redundant Path${T>1?"s":""}`,color:"text-sys-indigo"},subtitle:{text:`${u.nodeNames.join(" → ")} → ${u.nodeNames[0]}`,color:"text-fg-secondary",mono:!0},stats:P,badges:_}}if((c==null?void 0:c.type)==="neighbor"){const C=c.properties,T=[];C.rssi!==void 0&&C.rssi!==null&&T.push({label:"RSSI",value:`${Math.round(C.rssi)} dBm`,unit:C.hasAvgRssi?"avg":void 0}),C.snr!==void 0&&C.snr!==null&&T.push({label:"SNR",value:`${Number(C.snr).toFixed(1)} dB`,unit:C.hasAvgSnr?"avg":void 0});const P=C.listenerScore??0,_=C.loudScore??0,E=P>0||_>0;return E&&(T.push({label:"listener",value:P,color:"text-sys-green"}),T.push({label:"loud",value:_,color:"text-sys-red"})),C.packetCount!==void 0&&!E&&T.push({label:"packets",value:Number(C.packetCount).toLocaleString()}),{type:"neighbor",title:{icon:"●",text:C.prefix?`${C.name} (${C.prefix})`:C.name,color:"text-sys-amber"},subtitle:{text:"Direct RF Neighbor",color:"text-sys-amber/70"},stats:T,badges:[]}}if((c==null?void 0:c.type)==="topology"){const C=c.properties,T=g>0?Number(C.certainCount)/g:0,P=[{label:"validations",value:C.certainCount},{label:"of max traffic",value:`${Math.round(T*100)}%`},{label:"confidence",value:`${Math.round(Number(C.confidence)*100)}%`}];if(C.symmetryRatio!==void 0&&C.symmetryRatio<1){const Q=C.dominantDirection==="forward"?"→":C.dominantDirection==="reverse"?"←":"↔";P.push({label:"symmetric",value:`${Q} ${Math.round(C.symmetryRatio*100)}%`,color:"text-fg-muted"})}const _=(x=y==null?void 0:y.get(C.key))==null?void 0:x.traceQuality;if(_!=null&&_.composite){const Q=_.composite;P.push({label:"trace SNR",value:`${Q.mean.toFixed(1)} dB`,unit:`n=${Q.count}`,color:Q.mean>=10?"text-sys-green":Q.mean>=0?"text-sys-amber":"text-sys-red"}),_.asymmetryDb!=null&&_.asymmetryDb>1&&P.push({label:"asymmetry",value:`${_.asymmetryDb.toFixed(1)} dB`,color:_.asymmetryDb>5?"text-sys-red":"text-sys-amber"})}const E=[];if(C.isBackbone&&E.push({text:"Backbone",color:"text-zinc-300"}),C.isLoopEdge&&E.push({text:"Redundant",color:"text-sys-indigo"}),C.isDirectPath&&E.push({text:"Direct Path",color:"text-sys-teal"}),_){const Q=_.quality==="excellent"||_.quality==="good"?"text-sys-green":_.quality==="fair"?"text-sys-amber":_.quality==="poor"||_.quality==="critical"?"text-sys-red":"text-fg-muted";_.quality!=="unknown"&&E.push({text:`TRACE ${_.quality}`,color:Q})}return{type:"topology",title:{icon:"",text:`${C.fromName} ↔ ${C.toName}`,color:"text-fg-primary"},stats:P,badges:E}}return null}function K1({data:c}){const u=c.subtitle&&c.type==="loop",g=c.subtitle&&c.type!=="loop";return p.jsxs("div",{className:"w-[540px]",children:[p.jsxs("div",{className:"flex items-center justify-between h-5",children:[p.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[c.title.icon&&p.jsx("span",{className:`${c.title.color} text-base leading-none flex-shrink-0`,children:c.title.icon}),p.jsx("span",{className:`${c.title.color} font-semibold text-[13px] truncate`,children:c.title.text}),g&&p.jsx("span",{className:`${c.subtitle.color} text-[11px] flex-shrink-0`,children:c.subtitle.text})]}),c.badges.length>0&&p.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:c.badges.map((y,x)=>p.jsx("span",{className:`${y.color} text-[11px] font-medium`,children:y.text},x))})]}),u&&p.jsx("div",{className:"h-4 mt-0.5 overflow-hidden",children:p.jsx("span",{className:"type-data-xs text-fg-muted truncate block",children:c.subtitle.text})}),p.jsx("div",{className:`flex items-center gap-4 h-4 ${u?"mt-1":"mt-1.5"} text-[11px]`,children:c.stats.map((y,x)=>p.jsxs("span",{className:"whitespace-nowrap",children:[p.jsx("span",{className:`font-mono tabular-nums font-semibold ${y.color??"text-fg-primary"}`,children:y.value}),p.jsx("span",{className:"text-fg-muted ml-1",children:y.label}),y.unit&&p.jsx("span",{className:"text-fg-muted/50 ml-0.5",children:y.unit})]},x))})]})}function jh({neighbors:c,localNode:u,localHash:g,onRemoveNode:y,selectedNodeHash:x,onNodeSelected:C,highlightedEdgeKey:T,highlightedGhost:P}){Ts(nl);const _=R.useRef(null),E=Ma(),Q=Ba(),O=Ms(),H=Da(),V=_a(),K=Bs(),[aA,J]=R.useState(!1),eA=ur(z=>z.viewState),Z=ur(z=>z.toggles),uA=ur(z=>z.hasAnalyzed),oA=ur(z=>z.setViewState),vA=ur(z=>z.setToggle),iA=ur(z=>z.setHasAnalyzed),fA=ur(z=>z.modalMapOpen),jA=lo(z=>z.preloadFromNodes),DA=lo(z=>z.isLoading),CA=lo(z=>z.terrainGrid),yA=g??H,kA=R.useMemo(()=>{const z=[];for(const[,lA]of Object.entries(c))lA.latitude&&lA.longitude&&z.push([lA.latitude,lA.longitude]);return z},[c]),LA=R.useMemo(()=>W1(kA,u),[kA,u]),[NA,GA]=R.useState(()=>eA??LA??G1),bA=R.useCallback(z=>{GA(z),queueMicrotask(()=>oA(z))},[oA]),cA=R.useRef(!!eA);R.useEffect(()=>{!cA.current&&LA&&!eA?(GA(LA),queueMicrotask(()=>oA(LA)),cA.current=!0,setTimeout(()=>J(!0),50)):eA&&setTimeout(()=>J(!0),50)},[LA,eA,oA]);const[sA,TA]=R.useState(!1),[MA,WA]=R.useState(()=>Z.showTopology&&!O.topologyLoadComplete?!1:Z.showTopology),[ae,JA]=R.useState(Z.showNeighborLines),[ZA,UA]=R.useState(!1),[Ie,Le]=R.useState(Z.showMinCut),[oe,me]=R.useState(rf),[ue,Ye]=R.useState(Z.show3DTerrain),[be,Ce]=R.useState(Z.showLinkQuality),[Se,pe]=R.useState(()=>Z.nodeFilters.length>0?Z.nodeFilters:[...un]),Ke=R.useCallback(z=>{WA(lA=>{const mA=typeof z=="function"?z(lA):z;return queueMicrotask(()=>vA("showTopology",mA)),mA})},[vA]),$e=R.useCallback(z=>{JA(lA=>{const mA=typeof z=="function"?z(lA):z;return queueMicrotask(()=>vA("showNeighborLines",mA)),mA})},[vA]),qe=R.useCallback(z=>{Le(lA=>{const mA=typeof z=="function"?z(lA):z;return queueMicrotask(()=>vA("showMinCut",mA)),mA})},[vA]),Xe=R.useCallback(z=>{Ye(lA=>{const mA=typeof z=="function"?z(lA):z;return queueMicrotask(()=>vA("show3DTerrain",mA)),mA})},[vA]),vt=R.useCallback(z=>{Ce(lA=>{const mA=typeof z=="function"?z(lA):z;return queueMicrotask(()=>vA("showLinkQuality",mA)),mA})},[vA]),Qe=R.useCallback(z=>{pe(z),queueMicrotask(()=>vA("nodeFilters",z))},[vA]),[Je,Be]=R.useState(null),[ze,st]=R.useState(null),[jt,v0]=R.useState(null),[Yt,Kt]=R.useState(null),[N0]=R.useState(0),[er]=R.useState(.5),[k0]=R.useState(0),[zt,b0]=R.useState(null),[tr,c0]=R.useState(""),[rr,F0]=R.useState(!1),[gA,f0]=R.useState(!1),[at,Fe]=R.useState(()=>uA&&!O.topologyLoadComplete?!1:uA);R.useEffect(()=>{if(O.topologyLoadComplete)return;const z=uA&&!at,lA=Z.showTopology&&!MA;!z&&!lA||queueMicrotask(()=>{z&&iA(!1),lA&&vA("showTopology",!1)})},[uA,Z.showTopology,O.topologyLoadComplete,at,MA,iA,vA]);const n0=R.useCallback(z=>{Fe(z),queueMicrotask(()=>iA(z))},[iA]),[Zt,xt]=R.useState(null),kt=R.useCallback(z=>xt(z),[]),o0=R.useCallback(()=>xt(null),[]),[,wt]=R.useState(new Set),It=cn(z=>z.coveragePoints),dt=cn(z=>z.isVisible),rA=cn(z=>z.brightness),pA=cn(z=>z.openModal),IA=df(),xA=mf(),t=_s(),b=Ra(),ge=R.useRef(!1);R.useEffect(()=>{It.length>0&&dt&&!ge.current&&($e(!1),ge.current=!0)},[It.length,dt]);const De=R.useRef(null);R.useEffect(()=>{if(x&&x!==De.current){De.current=x;const z=setTimeout(()=>{xt(x)},1250);return()=>clearTimeout(z)}},[x]);const[He,$A]=R.useState(null),[ye,lt]=R.useState(null),_e=R.useCallback((z,lA,mA)=>{st(z),z&&lA&&mA?$A({longitude:lA[0],latitude:lA[1],type:"topology",properties:{key:mA.key,fromName:mA.fromName,toName:mA.toName,certainCount:mA.certainCount,confidence:mA.confidence,isBackbone:mA.isBackbone,isLoopEdge:mA.isLoopEdge,isDirectPath:mA.isDirectPath,isHubConnection:mA.isHubConnection,symmetryRatio:mA.symmetryRatio,dominantDirection:mA.dominantDirection}}):z||$A(null)},[]),ie=R.useCallback((z,lA)=>{lt(z),z&&$A(null)},[]),et=R.useMemo(()=>{var VA;if(!MA||!Je||ze)return null;const z=E.loops;if(z.length===0)return null;const lA=Iu(Je,z,E.edgeMap);if(lA.loops.length===0)return null;const FA=lA.loops[0].nodes.map(xe=>{var tt,Me;return xe===yA?"You":((tt=c[xe])==null?void 0:tt.node_name)||((Me=c[xe])==null?void 0:Me.name)||xe.substring(0,4)});return{loops:lA.loops,highlightedEdgeKeys:lA.highlightedEdgeKeys,hoveredEdgeKey:((VA=lA.sortedEdges[0])==null?void 0:VA.key)||"",nodeNames:FA}},[MA,Je,ze,E.loops,E.edgeMap,c,yA]);R.useEffect(()=>{ze||lt(et)},[et,ze]);const Lt=R.useMemo(()=>{const z={};for(const[lA,mA]of Object.entries(c))z[lA]=mA.node_name||mA.name||lA.substring(0,4);return yA&&(z[yA]="You"),z},[c,yA]),h0=R.useMemo(()=>{const z=new Map;for(const[lA,mA]of Object.entries(c)){const FA=lA.slice(0,2).toUpperCase(),VA=mA.node_name||mA.name||FA;z.set(FA,VA)}return yA&&z.set(yA.slice(0,2).toUpperCase(),"You"),z},[c,yA]),mt=R.useMemo(()=>Object.entries(c).filter(([,z])=>z.latitude&&z.longitude),[c]),Te=R.useMemo(()=>{const z=new Map;yA&&(u!=null&&u.latitude)&&(u!=null&&u.longitude)&&z.set(yA,[u.latitude,u.longitude]);for(const[lA,mA]of mt)mA.latitude&&mA.longitude&&z.set(lA,[mA.latitude,mA.longitude]);return z},[yA,u,mt]),gt=R.useMemo(()=>{const z=new Map;for(const lA of Q)lA.status!=="expired"&&z.set(lA.hash,{hash:lA.hash,prefix:lA.prefix,count:lA.count,avgRssi:lA.avgRssi,avgSnr:lA.avgSnr,lastSeen:lA.lastSeen,confidence:1,status:lA.status});return z},[Q]),Pe=R.useMemo(()=>{var lA,mA;const z=new Set;for(const FA of gt.keys())(lA=c[FA])!=null&&lA.latitude&&((mA=c[FA])!=null&&mA.longitude)&&z.add(FA);return z},[gt,c]),At=Eo(),P0=R.useMemo(()=>{if(Pe.size===0||!yA)return new Map;if(At.length===0)return new Map;const z=hn(yA);return Fa(At,Pe,z).scores},[Pe,yA,At]),nt=R.useCallback(z=>yA?!!(z.fromHash===yA&&Pe.has(z.toHash)||z.toHash===yA&&Pe.has(z.fromHash)):!1,[yA,Pe]),YA=R.useMemo(()=>{var lA,mA;if(Q.length===0||!yA)return[];if(O.backgroundLoadComplete)return[];const z=[];for(const FA of Q){if(FA.status==="expired"||!((lA=c[FA.hash])!=null&&lA.latitude)||!((mA=c[FA.hash])!=null&&mA.longitude))continue;const VA=[yA,FA.hash].sort(),xe=`${VA[0]}~${VA[1]}`;z.push({fromHash:yA,toHash:FA.hash,key:xe,packetCount:FA.count,avgConfidence:1,strength:.8,avgRecency:1,hopDistanceFromLocal:0,isHubConnection:!1,isCertain:!0,certainCount:FA.count,isLoopEdge:!1,forwardCount:FA.count,reverseCount:0,symmetryRatio:0,dominantDirection:"forward",floodCount:FA.count,directCount:0,isDirectPathEdge:!1,isZeroHop:!0,avgRssi:FA.avgRssi,avgSnr:FA.avgSnr})}return z},[Q,yA,O.backgroundLoadComplete,c]),S=R.useMemo(()=>{const z=[];if(YA.length>0&&!O.backgroundLoadComplete){for(const lA of YA){const mA=Te.get(lA.fromHash),FA=Te.get(lA.toHash);mA&&FA&&z.push({from:mA,to:FA,edge:lA})}return z}for(const lA of E.validatedEdges){if(nt(lA))continue;const mA=Te.get(lA.fromHash),FA=Te.get(lA.toHash);mA&&FA&&z.push({from:mA,to:FA,edge:lA})}return z},[E.validatedEdges,Te,nt,YA,O.backgroundLoadComplete]),OA=R.useMemo(()=>{const z=[];for(const lA of E.weakEdges){if(nt(lA))continue;const mA=Te.get(lA.fromHash),FA=Te.get(lA.toHash);mA&&FA&&z.push({from:mA,to:FA,edge:lA})}return z},[E.weakEdges,Te,nt]),Nt=R.useMemo(()=>{if(!(u!=null&&u.latitude)||!(u!=null&&u.longitude))return[];const z=[],lA=[u.latitude,u.longitude],mA=new Map;for(const VA of E.lastHopNeighbors)mA.set(VA.hash,VA.count);const FA=new Map;for(const VA of Q)FA.set(VA.hash,VA.count);for(const VA of Pe){const xe=c[VA];if(!(xe!=null&&xe.latitude)||!(xe!=null&&xe.longitude))continue;const tt=FA.get(VA),Me=mA.get(VA);z.push({from:lA,to:[xe.latitude,xe.longitude],hash:VA,neighbor:xe,lastHopData:gt.get(VA)??null,rxAdvertCount:tt,txProxyCount:Me})}return z},[u,Pe,c,gt,E.lastHopNeighbors,Q]),Q0=R.useMemo(()=>new Set(E.loopEdgeKeys),[E.loopEdgeKeys]),i0=R.useMemo(()=>new Set(E.backboneEdges),[E.backboneEdges]),s0=R.useMemo(()=>{if(!jt)return null;const z=E.validatedEdges.filter(VA=>VA.fromHash===jt||VA.toHash===jt);if(z.length===0)return null;const lA=[...z].sort((VA,xe)=>xe.certainCount-VA.certainCount),mA=Math.max(1,Math.ceil(lA.length*.2)),FA=lA.slice(0,mA);return new Set(FA.map(VA=>VA.key))},[jt,E.validatedEdges]),d0=R.useMemo(()=>{let z=0;if(YA.length>0&&!O.backgroundLoadComplete){for(const lA of YA)lA.certainCount>z&&(z=lA.certainCount);return z||1}for(const lA of E.validatedEdges)lA.certainCount>z&&(z=lA.certainCount);return z||1},[E.validatedEdges,YA,O.backgroundLoadComplete]),k=R.useMemo(()=>{if(E.validatedEdges.length===0)return null;const z=new Set;for(const FA of E.validatedEdges)z.add(FA.fromHash),z.add(FA.toHash);const lA=Array.from(z).filter(FA=>Te.has(FA)).sort();if(lA.length<3)return null;const mA=new Map;for(const FA of lA){const VA=Te.get(FA);VA&&mA.set(FA,VA)}return $a(E.validatedEdges,lA,mA,E.edgeBetweenness)},[E.validatedEdges,Te,E.edgeBetweenness]),C0=R.useCallback(()=>{qe(z=>{const lA=!z;if(lA&&k&&_.current){const mA=_.current.getMap();if(!mA)return lA;let FA=1/0,VA=-1/0,xe=1/0,tt=-1/0,Me=!1;for(const[,ut]of k.communities)for(const Ze of ut){const yt=Te.get(Ze);if(yt){const[ot,St]=yt;xe=Math.min(xe,ot),tt=Math.max(tt,ot),FA=Math.min(FA,St),VA=Math.max(VA,St),Me=!0}}Me&&mA.fitBounds([[FA,xe],[VA,tt]],{padding:{top:60,bottom:100,left:60,right:320},duration:800,maxZoom:14})}return lA})},[k,Te]),$t=R.useRef(null);R.useLayoutEffect(()=>{var z,lA;$t.current=((lA=(z=_.current)==null?void 0:z.getMap)==null?void 0:lA.call(z))??null});const O0=Eo();o1({map:$t,nodeCoordinates:Te,packets:O0,localHash:yA,neighbors:c,meshTopology:E,enabled:IA});const{isExiting:z0,isAnimating:E0,resetAnimationState:h}=H2({map:$t,showTopology:MA,validatedPolylines:S,weakPolylines:OA,maxCertainCount:d0,loopEdgeKeys:Q0,backboneEdgeKeys:i0,highlightedEdgeKey:T,neighbors:c,validatedSourceId:Io,weakSourceId:Lo,neighborPolylines:Nt,showNeighborLines:ae,neighborSourceId:No,neighborLinkScores:P0,basemapMode:t}),v=R.useMemo(()=>{const z=new Set;for(const lA of E.hubNodes){z.add(lA);for(const mA of E.validatedEdges)mA.fromHash===lA&&z.add(mA.toHash),mA.toHash===lA&&z.add(mA.fromHash)}return z},[E.hubNodes,E.validatedEdges]),D=R.useMemo(()=>{const z=new Set;if(!g)return z;for(const lA of E.validatedEdges)lA.fromHash===g&&z.add(lA.toHash),lA.toHash===g&&z.add(lA.fromHash);return z},[g,E.validatedEdges]),F=R.useMemo(()=>{const z=new Map;for(const[lA,mA]of mt)z.set(lA,fu(mA).type);return z},[mt]),X=R.useMemo(()=>{let z=0,lA=0,mA=0;for(const[,FA]of F)FA==="repeater"?z++:FA==="companion"||FA==="unknown"?lA++:FA==="room_server"&&mA++;return{repeater:z,companion:lA,room_server:mA,hubs:E.hubNodes.length,direct:Pe.size}},[F,E.hubNodes.length,Pe.size]),Y=R.useMemo(()=>new Set(Se),[Se]),{getNodeOpacity:hA}=G2({activeFilters:Y,neighborHashes:mt.map(([z])=>z),hubConnectedNodes:v,directNodeSet:Pe,localConnectedNodes:D,nodeTypeMap:F,showTopology:MA}),{blinkingNodes:RA,blinkColor:XA}=Y2({neighbors:c,localHash:g,enabled:IA}),Ae=R.useCallback(z=>{if(Y.size===0)return!1;const lA=F.get(z)??"unknown";return!!(Y.has("repeater")&&lA==="repeater"||Y.has("companion")&&(lA==="companion"||lA==="unknown")||Y.has("room_server")&&lA==="room_server"||Y.has("direct")&&Pe.has(z)||Y.has("hubs")&&v.has(z))},[Y,F,Pe,v]),ce=R.useCallback(()=>{f0(!0),F0(!0)},[]),Ge=R.useCallback(()=>{at?Ke(z=>!z):ce()},[at,ce]),bt=R.useCallback(z=>{bA(z.viewState),(z.viewState.pitch??0)>10&&!ue&&Xe(!0)},[ue]),Ct=R.useCallback(()=>{TA(z=>{var FA,VA,xe,tt,Me,ut,Ze;const lA=!z,mA=(xe=(VA=(FA=_.current)==null?void 0:FA.getContainer())==null?void 0:VA.closest(".map-container-fullscreen, .map-container-16-9"))==null?void 0:xe.parentElement;return lA?mA&&document.fullscreenEnabled?(tt=mA.requestFullscreen)==null||tt.call(mA).catch(()=>{}):mA&&document.webkitFullscreenEnabled&&((Me=mA.webkitRequestFullscreen)==null||Me.call(mA)):document.fullscreenElement?(ut=document.exitFullscreen)==null||ut.call(document).catch(()=>{}):document.webkitFullscreenElement&&((Ze=document.webkitExitFullscreen)==null||Ze.call(document)),lA})},[]),pt=R.useCallback(()=>{const z=Se.length>=un.length;Qe(z?[]:[...un])},[Se,Qe]),Re=R.useCallback(z=>{Se.length>=un.length?Qe([z]):Se.includes(z)?Qe(Se.filter(mA=>mA!==z)):Qe([...Se,z])},[Se,Qe]),Et=R.useCallback(()=>{$e(z=>!z)},[]),m0=R.useCallback(()=>{UA(z=>!z)},[]),l0=R.useCallback(()=>{vt(z=>{const lA=!z;return lA||Kt(null),lA})},[]),H0=R.useCallback(()=>{Xe(z=>{const lA=!z;if(_.current){const mA=_.current.getMap();mA&&mA.stop()}if(lA&&_.current){const mA=_.current.getMap();mA&&mA.easeTo({pitch:45,duration:1500,easing:Ns})}if(!lA&&_.current){const mA=_.current.getMap();mA&&mA.easeTo({pitch:0,bearing:0,duration:800,easing:ou})}return lA})},[]),qt=R.useCallback(()=>{MA||Ke(!0)},[MA]),S0=R.useCallback((z,lA)=>{b0(z),c0(lA)},[]),nr=R.useCallback(()=>{zt&&y&&y(zt),b0(null),c0("")},[zt,y]),or=R.useMemo(()=>[...B1,...k1,...be?[Hn]:[]],[be]),Vr=R.useCallback(z=>{var mA;if((mA=z.features)==null?void 0:mA.some(FA=>{var VA,xe;return(xe=(VA=FA.layer)==null?void 0:VA.id)==null?void 0:xe.startsWith("node-markers-")})){$A(null),st(null);return}if(be&&z.features&&z.features.length>0){const FA=z.features.find(VA=>{var xe;return((xe=VA.layer)==null?void 0:xe.id)===Hn});if(FA!=null&&FA.properties){const{fromHash:VA,toHash:xe}=FA.properties;if(VA&&xe){const tt=K.find(Me=>Me.nodeA.hash===VA&&Me.nodeB.hash===xe||Me.nodeA.hash===xe&&Me.nodeB.hash===VA);if(tt){Kt(tt),xt(null);return}}}}xt(null),$A(null),st(null),v0(null),Kt(null)},[be,K]),Wr=R.useCallback(z=>{v0(lA=>lA===z?null:z),Kt(null)},[]),Yr=R.useCallback(z=>{var Me,ut,Ze;if(!z.features||z.features.length===0)return;if(z.features.some(yt=>{var ot,St;return(St=(ot=yt.layer)==null?void 0:ot.id)==null?void 0:St.startsWith("node-markers-")})){ze&&(st(null),$A(null));return}if(be&&z.features.some(yt=>{var ot;return((ot=yt.layer)==null?void 0:ot.id)===Hn})){try{(Me=_.current)!=null&&Me.getCanvas()&&(_.current.getCanvas().style.cursor="pointer")}catch{}return}const mA=z.features.find(yt=>{var St;const ot=(St=yt.layer)==null?void 0:St.id;return(ot==null?void 0:ot.startsWith("topology-"))||(ot==null?void 0:ot.startsWith("neighbor-"))});if(!mA)return;const FA=(ut=mA.layer)==null?void 0:ut.id,VA=mA.properties;if(!(VA!=null&&VA.key))return;const xe=FA==null?void 0:FA.startsWith("topology-"),tt=FA==null?void 0:FA.startsWith("neighbor-");if(xe||tt){const yt=VA.key.replace(/-loop[12]$/,"");st(yt),z.lngLat&&$A({longitude:z.lngLat.lng,latitude:z.lngLat.lat,type:xe?"topology":"neighbor",properties:VA})}try{(Ze=_.current)!=null&&Ze.getCanvas()&&(_.current.getCanvas().style.cursor="pointer")}catch{}},[ze,be]),Ft=R.useCallback(()=>{var z;st(null),$A(null);try{(z=_.current)!=null&&z.getCanvas()&&(_.current.getCanvas().style.cursor="")}catch{}},[]),ir=sA?"map-container-fullscreen":"map-container-16-9",a0=kA.length>0||(u==null?void 0:u.latitude)&&(u==null?void 0:u.longitude),Ne=!aA||!a0,M0=a0;return p.jsxs("div",{className:`relative ${ir} ${sA?"":"rounded-2xl overflow-hidden"}`,role:"application","aria-label":"Mesh network contacts map","aria-describedby":"map-instructions","data-basemap":t,children:[p.jsx("span",{id:"map-instructions",className:"sr-only",children:"Interactive map showing mesh network contacts. Use mouse or touch to pan and zoom. Press Tab to navigate map controls. Press Escape to exit fullscreen mode."}),Ne&&p.jsx("div",{className:"absolute inset-0 z-50 surface-base rounded-2xl flex items-center justify-center","aria-hidden":"true",children:p.jsxs("div",{className:"flex flex-col items-center gap-3",children:[p.jsx("div",{className:"w-6 h-6 border-2 border-sys-blue border-t-transparent rounded-full animate-spin"}),p.jsx("span",{className:"text-sm text-fg-muted",children:"Loading map..."})]})}),M0&&p.jsx("div",{className:`relative w-full h-full ${sA?"":"rounded-[1.125rem] overflow-hidden"} ${Ne?"opacity-0":"opacity-100 transition-opacity duration-300"}`,style:fA?{visibility:"hidden"}:void 0,children:p.jsxs(ja,{ref:_,...NA,onMove:bt,mapStyle:H1,style:{width:"100%",height:"100%"},attributionControl:!1,interactiveLayerIds:or,onMouseMove:Yr,onMouseLeave:Ft,onClick:Vr,onError:z=>{console.error("MapLibre error:",z.error)},onIdle:()=>{if(!CA&&!DA&&_.current){const z=_.current.getMap();if(z){const lA=Object.values(c).filter(mA=>mA.latitude&&mA.longitude).map(mA=>({latitude:mA.latitude,longitude:mA.longitude}));u!=null&&u.latitude&&(u!=null&&u.longitude)&&lA.push({latitude:u.latitude,longitude:u.longitude}),lA.length>0&&jA(lA,z)}}},children:[p.jsx(Ia,{position:"bottom-right"}),p.jsx(La,{mode:t}),p.jsx(h2,{enabled:ue,exaggeration:4}),p.jsx(f2,{coveragePoints:It,visible:It.length>0&&dt,terrainEnabled:ue,brightness:rA,basemapMode:t}),p.jsx(F2,{partition:k,nodeCoordinates:Te,visible:Ie&&at,opacity:oe.opacity,bandwidth:oe.bandwidth,threshold:oe.threshold,strokeWidth:oe.strokeWidth}),p.jsx(M1,{showTopology:MA,isExiting:z0,hoveredEdgeKey:ze,highlightedLoopEdges:ye==null?void 0:ye.highlightedEdgeKeys,highlightedFocusEdges:s0,onEdgeHover:_e,onLoopHover:ie,loops:E.loops,neighborNames:Lt,opacityBias:N0,widthMultiplier:er,trafficFilter:k0,showNeighborLines:ae,disableHover:E0||gA}),p.jsx(N1,{visible:be,nodeCoordinates:Te,focusedNodeHash:jt,basemapMode:t}),x&&p.jsx(D1,{targetHash:x,nodeCoordinates:Te,onComplete:C}),T&&p.jsx(_1,{highlightedEdgeKey:T,validatedPolylines:S,weakPolylines:OA,onEnsureTopology:qt}),p.jsx(z1,{ghost:P??null,neighborCoordinates:Te,onHighlightedNeighborsChange:wt}),p.jsx(v1,{neighborsWithLocation:mt,localNode:u,localHash:g,zeroHopNeighbors:Pe,lastHopNeighborMap:gt,meshTopology:E,hoveredMarker:Je,onMarkerHover:Be,getNodeOpacity:hA,shouldShowNode:Ae,onRequestRemove:y?S0:void 0,openPopupId:Zt,onOpenPopup:kt,onClosePopup:o0,onNodeClick:Wr,blinkingNodes:RA,blinkColor:XA})]})}),(()=>{const z=Y1(He?{type:He.type,properties:He.properties}:null,ye,d0,E.edgeMap);return z&&p.jsx("div",{className:"map-edge-tooltip",children:p.jsx("div",{className:"map-control-surface map-edge-tooltip-inner",children:p.jsx(K1,{data:z})})})})(),p.jsx(mc,{mapRef:_,showNeighborLines:ae,onToggleNeighborLines:Et,hasNeighborPolylines:Nt.length>0,nodeFilters:Se,onToggleFilter:Re,onToggleAll:pt,filterCounts:X,showCoverage:ZA,onToggleCoverage:m0,showMinCut:Ie,onToggleMinCut:C0,hasMinCutData:at&&k!==null&&k.numCommunities>1,show3DTerrain:ue,onToggle3DTerrain:H0,basemapMode:t,onToggleBasemap:b,isFullscreen:sA,onToggleFullscreen:Ct,showLinkQuality:be,onToggleLinkQuality:l0,hasTraceLinks:V}),be&&Yt&&p.jsx(ff,{pair:Yt,onClose:()=>Kt(null),prefixToName:h0}),p.jsxs("div",{className:"map-legend-stack",children:[p.jsxs("div",{className:"map-tool-row",children:[p.jsx(bc,{isActive:MA,hasAnalyzed:at,isLoading:gA,onClick:Ge,basemapMode:t}),p.jsx(_c,{isActive:IA,onClick:xA,basemapMode:t}),p.jsx(Fc,{isActive:It.length>0&&dt,onClick:pA,basemapMode:t})]}),p.jsx(fc,{showTopology:MA,validatedPolylineCount:S.length,filteredNeighborCount:mt.length,hasLocalNode:!!(u!=null&&u.latitude&&(u!=null&&u.longitude)),meshTopology:E,zeroHopNeighbors:Pe,neighborsWithLocation:mt,basemapMode:t})]}),p.jsx(Pa,{isOpen:zt!==null,onCancel:()=>b0(null),onConfirm:nr,title:"Remove Node?",message:`Remove "${tr}" from the contacts list? This will hide the node until it sends a new packet.`,confirmLabel:"Remove",cancelLabel:"Cancel",variant:"danger"}),p.jsx(qa,{isOpen:rr,onClose:()=>{F0(!1),f0(!1),h(),n0(!0),setTimeout(()=>Ke(!0),sc)}}),p.jsx(tf,{}),p.jsx(nf,{visible:Ie&&at,onClose:()=>qe(!1),settings:oe,onSettingsChange:me,partition:k,totalNodes:Object.keys(c).length,basemapMode:t})]})}export{jh as default}; diff --git a/frontend/dist/assets/Dashboard-BN8YnIZD.js b/frontend/dist/assets/Dashboard-Da3hQ53f.js similarity index 97% rename from frontend/dist/assets/Dashboard-BN8YnIZD.js rename to frontend/dist/assets/Dashboard-Da3hQ53f.js index b942ab77..591021dc 100644 --- a/frontend/dist/assets/Dashboard-BN8YnIZD.js +++ b/frontend/dist/assets/Dashboard-Da3hQ53f.js @@ -1,4 +1,4 @@ -import{d as A,e as st,r as f,j as e,A as Re,m as Q,S as nt,M as at,U as ot,f as it,h as rt,k as lt,n as ct,o as H,p as ue,q as U,t as dt,v as mt,w as be,x as ut,L as ee,y as G,z as xt,D as ht,E as te,F as Be,T as ft,G as pt,B as je,R as Le,H as Fe,J as gt,K as X,N as P,O as yt,P as bt,Q as jt,V as Nt,W as vt,X as wt,Y as ne,u as xe,_ as kt,$ as Ne,a0 as ae,a1 as K,a2 as Mt,a3 as J,a4 as Ct,a5 as Tt,a6 as St,a7 as ve,a8 as _t,c as F,a9 as Dt,aa as Pe,ab as we,ac as Rt,ad as Bt,ae as Lt,af as Ft,ag as Pt,ah as At,ai as $t}from"./index-C8IY8K2r.js";import{C as ke,P as Et,a as Ht,B as It}from"./PageLayout-NQBVrM09.js";import{u as I,r as O,h as Ot,a as zt,b as Wt,i as qt}from"./consumer-registry-lDKP4bcU.js";import{A as V,E as Ut}from"./AnimatedNumber-BmJRWt4U.js";import{c as Vt}from"./node-types-3T9Wr7vI.js";import{b as Ae,c as q,a as Gt,d as Xt,F as Z}from"./meshcore-tx-constants-DgpFTAmf.js";import{S as Yt,u as ce,P as Kt,T as Jt,C as $e,a as Zt}from"./PacketList-DNy8yTeL.js";import{u as Qt,a as es}from"./usePipelineStore-CyFB3GIy.js";import{A as Me}from"./SignalIndicator-Dw_bfp50.js";import{T as Ee}from"./TimeRangeStepper-BlC9rlkV.js";import{L as he}from"./LightSparkline-CkL4j4OZ.js";import{c as ts}from"./link-scoring-CX7bMGSJ.js";import{Z as ss,H as ns}from"./useMapViewStore-ax-BqDpg.js";import{N as as}from"./NodeInformationCard-p2ujbtr-.js";import{g as os,e as oe,a as is,f as rs}from"./chat-utils-D1Q4VWjO.js";import{M as He,C as ls}from"./ChatBubble-0UYYugYB.js";import{C as Ce}from"./chevron-right-DUgYTR6d.js";import{H as cs}from"./hash-BkZp0AKy.js";import{R as ie,C as re}from"./Grid-CEGkNRmt.js";import"./index-B-prVW1V.js";import"./primitives-Ca8Zb5cD.js";import"./payload-decoders-BX6pSxwl.js";import"./badge-colors-BNUqIXCA.js";import"./arrow-up-DbeeGdHO.js";import"./map-pin-DMVHq6j8.js";import"./circle-question-mark-C7l07_IA.js";import"./triangle-alert-8k00uu7o.js";import"./DataBox-W2v3wy8k.js";import"./layers-Oxzfug7f.js";import"./activity-2-g8m4_g.js";import"./circle-check-BOp4wLxA.js";import"./database-BEyHF_p_.js";import"./shield-DlHwWwz2.js";import"./geo-utils-BP1zBK9h.js";/** +import{d as A,e as st,r as f,j as e,A as Re,m as Q,S as nt,M as at,U as ot,f as it,h as rt,k as lt,n as ct,o as H,p as ue,q as U,t as dt,v as mt,w as be,x as ut,L as ee,y as G,z as xt,D as ht,E as te,F as Be,T as ft,G as pt,B as je,R as Le,H as Fe,J as gt,K as X,N as P,O as yt,P as bt,Q as jt,V as Nt,W as vt,X as wt,Y as ne,u as xe,_ as kt,$ as Ne,a0 as ae,a1 as K,a2 as Mt,a3 as J,a4 as Ct,a5 as Tt,a6 as St,a7 as ve,a8 as _t,c as F,a9 as Dt,aa as Pe,ab as we,ac as Rt,ad as Bt,ae as Lt,af as Ft,ag as Pt,ah as At,ai as $t}from"./index-BwGHI0A_.js";import{C as ke,P as Et,a as Ht,B as It}from"./PageLayout-BIcqC04y.js";import{u as I,r as O,h as Ot,a as zt,b as Wt,i as qt}from"./consumer-registry-DPYvsBcc.js";import{A as V,E as Ut}from"./AnimatedNumber-BAXz0cmM.js";import{c as Vt}from"./node-types-DmTOZWT4.js";import{b as Ae,c as q,a as Gt,d as Xt,F as Z}from"./meshcore-tx-constants-DgpFTAmf.js";import{S as Yt,u as ce,P as Kt,T as Jt,C as $e,a as Zt}from"./PacketList-CnGGHFuk.js";import{useGetDecodedContent as Qt,useResolveSource as es}from"./usePipelineStore-11oXtutw.js";import{A as Me}from"./SignalIndicator-LNOR_5YF.js";import{T as Ee}from"./TimeRangeStepper-Dh4JEQ42.js";import{L as he}from"./LightSparkline-5OIe9Q0M.js";import{c as ts}from"./link-scoring-BSZA-fkH.js";import{Z as ss,H as ns}from"./useMapViewStore-CPURakCb.js";import{N as as}from"./NodeInformationCard-BLxCCOW5.js";import{g as os,e as oe,a as is,f as rs}from"./chat-utils-Di4-nywi.js";import{M as He,C as ls}from"./ChatBubble-Bxq40Qnq.js";import{C as Ce}from"./chevron-right-DqpRZiGf.js";import{H as cs}from"./hash-9uwO8S8N.js";import{R as ie,C as re}from"./Grid-BoZ-SJB7.js";import"./index-OH01SZkk.js";import"./primitives-Cgn8YJud.js";import"./payload-decoders-7zyi-Y-D.js";import"./badge-colors-BNUqIXCA.js";import"./arrow-up-DJuSVUZI.js";import"./map-pin-VRY_TOuh.js";import"./circle-question-mark-DC7QfrVK.js";import"./triangle-alert-B4kC1YDk.js";import"./DataBox-CQS-Zhu0.js";import"./layers-C8ICjJ-w.js";import"./activity-Dr_TPIps.js";import"./circle-check-CBI-CiRo.js";import"./database-CDN_R6oC.js";import"./shield-DOTPcYJ1.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -51,4 +51,4 @@ import{d as A,e as st,r as f,j as e,A as Re,m as Q,S as nt,M as at,U as ot,f as */const Ss=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],_s=A("timer",Ss),Ie=[{target:"ReceivedChart",fn:"type",minStage:1},{target:"ReceivedChart",fn:"airtime",minStage:1,when:Ot}];O(Ie);function Ds(t,s,n){const a=Date.now()/1e3,o=s*60,i=a-o,l=o/n,m=[];for(let x=0;xa)continue;const g=Math.min(n-1,Math.floor((u-i)/l)),c=x.type??x.payload_type??0,h=x.length??x.payload_length??0,y=m[g];y.bytesByType[c]=(y.bytesByType[c]??0)+h,y.totalBytes+=h,d[c]=(d[c]??0)+h}const r=Object.keys(d).map(x=>parseInt(x,10)).filter(x=>d[x]>0).sort((x,u)=>d[u]-d[x]);return{buckets:m,activeTypes:r,totalByType:d}}function Rs(t){const n=new Date(t*1e3).getHours();return n>=6&&n<18}function Bs(t){return new Date(t*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})}function Ls({packets:t,rangeMinutes:s,bucketCount:n}){I(Ie);const a=st(),[o,i]=f.useState(null),[l,m]=f.useState(null),[d,r]=f.useState(null),{buckets:x,activeTypes:u,totalByType:g}=f.useMemo(()=>Ds(t,s,n),[t,s,n]),c=f.useCallback((j,N,w)=>{i(N),m(w)},[]),h=x.length>0&&u.length>0,y=o?Rs(o.start):null,v=o?Bs(o.start):"",k=d!==null&&y!==null&&d!==y;y!==d&&r(y);const M=48;return e.jsxs("div",{className:"flex flex-col h-full relative",children:[e.jsx("div",{className:"h-5 relative mb-1 shrink-0",children:o&&l!==null&&e.jsxs("div",{className:"absolute flex items-center gap-1.5 type-data-sm -translate-x-1/2",style:{left:`calc(${M}px + ${l*100}% * (1 - ${M}px / 100%))`},children:[e.jsx(Re,{mode:"wait",children:e.jsx(Q.span,{initial:k?{opacity:0,scale:.5,rotate:-90}:!1,animate:{opacity:1,scale:1,rotate:0},exit:{opacity:0,scale:.5,rotate:90},transition:{duration:.25,ease:"easeOut"},children:y?e.jsx(nt,{className:"w-4 h-4 text-sys-amber"}):e.jsx(at,{className:"w-4 h-4 text-sys-blue"})},y?"sun":"moon")}),e.jsx("span",{className:"text-fg-secondary",children:v})]})}),e.jsx("div",{className:"flex-1 min-h-0",children:h&&e.jsx(ot,{buckets:x,activeTypes:u,gridColor:a.grid,axisTickColor:a.axisTick,onHover:c})}),e.jsx("div",{className:"pt-2 px-1 pb-2 shrink-0",children:h&&e.jsx(it,{activeTypes:u,totalByType:g})})]})}function Fs(t,s,n){var i,l;if(t.length<=n)return t;const a=t.length/n,o=[];for(let m=0;m0&&(u.bytesByType[c]=(u.bytesByType[c]??0)+h)}}o.push(u)}return o}function Ps(t,s,n,a,o,i,l){if(s.length===0)return;const m=Fs(s,n,ct.statsCard),d=m.length,r=i/d,x=m.map(g=>g.totalBytes),u=Math.max(...x);if(u!==0){for(let g=0;g{const l=t.map(d=>d.start),m=t.map(()=>1);return[l,m]},[t]);return f.useEffect(()=>{if(!n.current||t.length===0)return;const l=n.current,m=l.getBoundingClientRect(),d=Math.floor(m.width)||200,r=Math.floor(m.height)||60,x={width:d,height:r,padding:[0,0,0,0],cursor:{show:!1},scales:{x:{time:!1},y:{range:[0,1]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1}],legend:{show:!1},hooks:{draw:[c=>{const h=c.ctx,{left:y,top:v,width:k,height:M}=c.bbox;Ps(h,a.current,o.current,y,v,k,M)}]}},u=new rt(x,i,l),g=new ResizeObserver(()=>{const c=l.getBoundingClientRect();c.width>0&&c.height>0&&u.setSize({width:Math.floor(c.width),height:Math.floor(c.height)})});return g.observe(l),()=>{g.disconnect(),u.destroy()}},[i,t.length]),t.length===0?e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsx("div",{className:"w-full h-0.5 rounded-full bg-fg-muted/15"})}):e.jsx("div",{ref:n,className:"w-full h-full"})}const Oe=f.memo(As),ze=[{target:"ForwardedCard",fn:"type",minStage:1}];O(ze);function $s(t,s,n){const a=Date.now()/1e3,o=s*60,i=a-o,l=o/n,m=[];for(let c=0;ca)continue;const v=Math.min(n-1,Math.floor((y-i)/l)),k=c.type??c.payload_type??0,M=c.length??c.payload_length??0,j=m[v];j.bytesByType[k]=(j.bytesByType[k]??0)+M,j.totalBytes+=M,d[k]=(d[k]??0)+M,r++}const x=Object.keys(d).map(c=>parseInt(c,10)).filter(c=>d[c]>0).sort((c,h)=>d[h]-d[c]),u=s/60,g=u>0?Math.round(r/u):0;return{buckets:m,activeTypes:x,ratePerHour:g}}function Es({value:t,receivedCount:s,packets:n,rangeMinutes:a,bucketCount:o,timeRangeLabel:i,icon:l,isLoaded:m=!0}){I(ze);const{buckets:d,activeTypes:r,ratePerHour:x}=f.useMemo(()=>$s(n,a,o),[n,a,o]),u=s>0?(t/s*100).toFixed(1):null;return m?e.jsxs(H,{children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 mb-2 sm:mb-3",children:[l&&e.jsx("span",{className:"icon-sm text-icon-card-title",children:l}),e.jsx("span",{className:"type-micro",children:"FORWARDED"}),i&&e.jsx(U,{color:"zinc",className:"hidden sm:inline-flex",children:i})]}),e.jsx("div",{className:"type-data-xl text-fg-primary",children:e.jsx(V,{value:t,className:"font-mono tabular-nums",priority:"high"})}),e.jsx("div",{className:"flex-1 mt-1 overflow-hidden min-h-[40px] sm:min-h-[60px]",children:r.length>0?e.jsx(Oe,{buckets:d,activeTypes:r}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx("div",{className:"w-full h-0.5 rounded-full bg-fg-muted/15"})})}),e.jsx("div",{className:"pt-1.5 sm:pt-2 mt-1",children:e.jsxs("div",{className:"flex gap-2 sm:gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Rate"}),e.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[x,"/hr"]})]}),u!==null&&e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Ratio"}),e.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[u,"%"]})]})]})})]}):e.jsx(H,{children:e.jsx(ue,{})})}const We=[{target:"DroppedCard",fn:"type",minStage:1}];O(We);function Hs(t,s,n){const a=Date.now()/1e3,o=s*60,i=a-o,l=o/n,m=[];for(let c=0;ca)continue;const y=Math.min(n-1,Math.floor((h-i)/l)),v=c.type??c.payload_type??0,k=c.length??c.payload_length??0,M=m[y];M.bytesByType[v]=(M.bytesByType[v]??0)+k,M.totalBytes+=k,d[v]=(d[v]??0)+k,r++}const x=Object.keys(d).map(c=>parseInt(c,10)).filter(c=>d[c]>0).sort((c,h)=>d[h]-d[c]),u=s/60,g=u>0?Math.round(r/u):0;return{buckets:m,activeTypes:x,ratePerHour:g}}function Is({value:t,receivedCount:s,packets:n,rangeMinutes:a,bucketCount:o,timeRangeLabel:i,icon:l,isLoaded:m=!0}){I(We);const{buckets:d,activeTypes:r,ratePerHour:x}=f.useMemo(()=>Hs(n,a,o),[n,a,o]),u=s>0?(t/s*100).toFixed(1):null;return m?e.jsxs(H,{children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 mb-2 sm:mb-3",children:[l&&e.jsx("span",{className:"icon-sm text-icon-card-title",children:l}),e.jsx("span",{className:"type-micro",children:"DROPPED"}),i&&e.jsx(U,{color:"zinc",className:"hidden sm:inline-flex",children:i})]}),e.jsx("div",{className:"type-data-xl text-fg-primary",children:e.jsx(V,{value:t,className:"font-mono tabular-nums",priority:"high"})}),e.jsx("div",{className:"flex-1 mt-1 overflow-hidden min-h-[40px] sm:min-h-[60px]",children:r.length>0?e.jsx(Oe,{buckets:d,activeTypes:r}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx("div",{className:"w-full h-0.5 rounded-full bg-fg-muted/15"})})}),e.jsx("div",{className:"pt-1.5 sm:pt-2 mt-1",children:e.jsxs("div",{className:"flex gap-2 sm:gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Rate"}),e.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[x,"/hr"]})]}),u!==null&&e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Drop %"}),e.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[u,"%"]})]})]})})]}):e.jsx(H,{children:e.jsx(ue,{})})}const Os={",":"punc",".":"punc-period",":":"punc-colon","/":"punc-slash"},de=/([,\.:\/])/g;function zs(t){return t.split(de).map((n,a)=>{const o=Os[n];return o?e.jsx("span",{className:o,children:n},a):n})}const $=f.memo(function({children:s,className:n="",as:a="span"}){const o=f.useMemo(()=>{let i;return typeof s=="number"?i=s.toLocaleString():Array.isArray(s)?i=s.join(""):i=String(s??""),de.test(i)?(de.lastIndex=0,zs(i)):i},[s]);return e.jsx(a,{className:`data-tight ${n}`.trim(),children:o})}),Ws=2,qs=1;function Us(t,s,n){const a=d=>(d==null?void 0:d.reduce((r,x)=>r+x.count,0))??0,o=a(s),i=a(n),l=o||(t==null?void 0:t.rx_count)||1,m=i||(t==null?void 0:t.dropped_count)||0;return l>0?m/(l+m)*100:0}function Vs(t,s,n){const a=o=>(o==null?void 0:o.reduce((i,l)=>i+l.count,0))??0;if(s!=null&&s.length&&n){const i=a(s)*100,l=s.length*n*1e3;return i/l*100}if(t){const o=(t.uptime_seconds||1)*1e3;return(t.total_airtime_ms||t.airtime_used_ms||0)/o*100}return 0}function Te(t,s,n){return Gt(Math.max(s,Math.min(n,t)))}function Gs(t,s,n,a,o){let i=Ae(t);s>20?i+=Z*2:s>12&&(i+=Z),n>8&&(i+=Z);const l=Te(i,0,Ws);let m=Xt(t);n>8&&(m+=Z);const d=Te(m,0,qs),r=q(l),x=q(d),u=a!==null?q(a):null;let g="stable";return u!==null&&(r>u?g="increase":r{if(r!=="applying"){x("applying");try{const se=await mt({tx_delay_factor:L,direct_tx_delay_factor:E});se!=null&&se.success?(x("success"),setTimeout(()=>x("idle"),2e3)):(x("error"),setTimeout(()=>x("idle"),2500))}catch{x("error"),setTimeout(()=>x("idle"),2500)}}},[r]);if(!l)return e.jsx(H,{children:e.jsx(ue,{})});const c=10080*60,y=Math.floor(Date.now()/1e3)-c,v=Object.values((t==null?void 0:t.neighbors)??{}).filter(L=>L.zero_hop&&L.last_seen>=y&&Vt(L).isRepeater).length,k=u.filter(L=>L.status==="active"||L.lastSeen>=y).length,M=Math.max(v,k),j=Us(t,s,n),N=Vs(t,a,o),w=((pe=(fe=t==null?void 0:t.config)==null?void 0:fe.delays)==null?void 0:pe.tx_delay_factor)??null,C=((ye=(ge=t==null?void 0:t.config)==null?void 0:ge.delays)==null?void 0:ye.direct_tx_delay_factor)??null,p=Gs(M,j,N,w),D=M!==1,T=Ae(M),_=[`${M} repeater${D?"s":""} heard in the last 7 days (base ×${T.toFixed(1)}).`];p.floodFactor===T&&j<=12&&N<=8?_.push("No modifiers applied — network looks healthy."):(j>20?_.push(`High duplicate rate (${j.toFixed(1)}%) suggests frequent collisions — window widened.`):j>12&&_.push(`Elevated duplicate rate (${j.toFixed(1)}%) — window widened one step.`),N>8&&_.push(`Channel is busy (${N.toFixed(1)}% TX util) — extra spacing added.`));const b=[`Direct uses one forwarder — ×${p.directFactor.toFixed(1)} backoff for channel contention.`];N>8&&b.push("Busy channel — small extra backoff.");const S=[`Flood ×${p.floodFactor.toFixed(1)} (${p.floodSlots} slot${p.floodSlots!==1?"s":""})`,..._,"",`Direct ×${p.directFactor.toFixed(1)}`,...b,"","Click to copy CLI commands"].join(` `),R=w!==null?q(w):null,B=C!==null?q(C):null,W=R!==null&&p.floodSlots!==R,Ze=B!==null&&p.directSlots!==B,Qe=W||Ze,et=async()=>{const L=`set txdelay ${p.floodFactor.toFixed(1)} set direct.txdelay ${p.directFactor.toFixed(1)}`;try{await navigator.clipboard.writeText(L),d(!0),setTimeout(()=>d(!1),1500)}catch{const E=document.createElement("textarea");E.value=L,E.style.position="fixed",E.style.opacity="0",document.body.appendChild(E),E.select();try{document.execCommand("copy"),d(!0),setTimeout(()=>d(!1),1500)}catch{console.error("Failed to copy commands")}document.body.removeChild(E)}},tt=()=>g(p.floodFactor,p.directFactor);return e.jsxs(H,{children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 mb-2 sm:mb-3 flex-wrap",children:[e.jsx(Yt,{className:"w-4 h-4 text-icon-card-title flex-shrink-0"}),e.jsx("span",{className:"type-micro",children:"DELAY DOCTOR"}),i&&e.jsx(U,{color:"zinc",className:"hidden sm:inline-flex",children:i})]}),e.jsxs("button",{onClick:et,className:"flex gap-3 mb-2 sm:mb-3 w-full text-left hover:bg-subtle-fill radius-inner transition-base p-1 -m-1 group",title:S,children:[e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsx("span",{className:"type-data-xl text-fg-primary",children:e.jsxs($,{children:["×",p.floodFactor.toFixed(1)]})}),e.jsx("span",{className:"type-micro text-fg-muted mt-0.5 sm:mt-1",children:"Flood"})]}),e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsx("span",{className:"type-data-xl text-sys-blue",children:e.jsxs($,{children:["×",p.directFactor.toFixed(1)]})}),e.jsx("span",{className:"type-micro text-fg-muted mt-0.5 sm:mt-1",children:"Direct"})]}),e.jsx("div",{className:"flex items-center self-center opacity-0 group-hover:opacity-100 transition-opacity",children:m?e.jsx(be,{className:"w-4 h-4 text-sys-green"}):e.jsx(ut,{className:"w-4 h-4 text-fg-muted"})})]}),e.jsx("div",{className:"flex-1 py-2",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"data-box-label",children:"Dupe"}),e.jsxs("div",{className:`data-box data-box-fill data-box-left ${p.duplicateRate>8?"text-status-warning":""}`,children:[p.duplicateRate.toFixed(1),"%"]})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"data-box-label",children:"TX Util"}),e.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[p.txUtilization.toFixed(2),"%"]})]})]})}),e.jsx("div",{className:"pt-2 mt-auto",children:e.jsxs("div",{className:"flex items-end justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Current"}),e.jsx("div",{className:"flex gap-2",children:w!==null?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"data-box",children:["×",w.toFixed(2)]}),e.jsxs("div",{className:"data-box",style:{color:"var(--sys-blue)"},children:["×",(C==null?void 0:C.toFixed(2))??"—"]})]}):e.jsx("span",{className:"text-sm text-fg-muted",children:"No config"})})]}),Qe&&e.jsxs("button",{onClick:tt,disabled:r==="applying"||r==="success",className:`flex items-center gap-1.5 px-2.5 py-1.5 radius-inner type-micro font-medium transition-base - ${r==="success"?"bg-sys-green/15 text-sys-green":r==="error"?"bg-sys-red/15 text-sys-red":r==="applying"?"bg-subtle-fill text-fg-muted":"bg-sys-blue/10 text-sys-blue hover:bg-sys-blue/20"}`,title:`Apply ×${p.floodFactor.toFixed(1)} flood, ×${p.directFactor.toFixed(1)} direct`,children:[r==="success"?"Rx'd":r==="error"?"Failed":"Apply",r==="applying"?e.jsx(ee,{className:"w-3.5 h-3.5 animate-spin"}):r==="success"?e.jsx(be,{className:"w-3.5 h-3.5"}):e.jsxs("span",{className:"relative inline-flex items-end w-6 h-3.5",children:[e.jsx(ws,{className:"w-3.5 h-3.5 absolute left-0 bottom-0"}),e.jsx(Ts,{className:"w-3 h-3 absolute right-0 bottom-0"})]})]})]})})]})}const qe=[{target:"RecentPackets",fn:"rssi",minStage:1},{target:"RecentPackets",fn:"snr",minStage:1}];O(qe);const Ys=25;function Ks(){I(qe);const t=G(),s=xt(),n=ht(),a=te(),o=Qt(),i=ce(c=>c.requestChannel),[l,m]=f.useState(!0),d=f.useCallback(c=>m(c),[]),r=f.useMemo(()=>[...t.length<=100?t:t.slice(-100)].sort((h,y)=>(y.timestamp??0)-(h.timestamp??0)),[t]),x=a==null?void 0:a.local_hash,u=a==null?void 0:a.neighbors,g=es();return e.jsxs(H,{noPadding:!0,className:"!overflow-visible",children:[e.jsx(Be,{listHeader:!0,icon:e.jsx(Le,{}),title:"Recent Packets",actions:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ft,{enabled:l,onChange:d,label:"Hide Dupes",size:"sm"}),n&&e.jsx(pt,{showLabel:!0}),e.jsxs(je,{color:"primary",outline:!0,href:"/packets",children:["View all",e.jsx(Me,{"data-slot":"icon"})]})]})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-1",children:e.jsx(Kt,{packets:r,allPackets:t,localHash:x,neighbors:u,resolveSource:g,getDecodedContent:o,onChannelClick:i,loading:s,maxPackets:Ys,showPagination:!1,flashNewest:!0,hideDupes:l,emptyMessage:"No packets received",footerAction:e.jsxs(je,{color:"primary",outline:!0,href:"/packets",children:["View all",e.jsx(Me,{"data-slot":"icon"})]})})})]})}const Js={stable:"M5 12h14",up:"M5 15l7-7 7 7",down:"M19 9l-7 7-7-7"};function Zs({trend:t}){return e.jsx("span",{className:`mini-widget-trend ${t}`,children:e.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:Js[t]})})})}function Qs(){return e.jsx("div",{className:"mini-widget-loading",children:e.jsx("div",{className:"mini-widget-loading-spinner"})})}function en({message:t}){return e.jsx("div",{className:"mini-widget-error",children:e.jsx("span",{title:t,children:"No data"})})}function z({title:t,icon:s,value:n,unit:a,valueSize:o="md",status:i,subtitle:l,trend:m,children:d,isLoading:r=!1,error:x,className:u="",onClick:g}){const c=["mini-widget-value",o==="lg"&&"mini-widget-value-lg",o==="sm"&&"mini-widget-value-sm"].filter(Boolean).join(" "),h=["mini-widget",u].filter(Boolean).join(" ");return e.jsxs(H,{noPadding:!0,className:h,onClick:g,children:[e.jsxs("div",{className:"mini-widget-header",children:[s,e.jsx("span",{className:"mini-widget-title",children:t}),i&&i!=="unknown"&&e.jsx("div",{className:`mini-widget-status-dot ${i}`}),m&&e.jsx(Zs,{trend:m})]}),r?e.jsx(Qs,{}):x?e.jsx(en,{message:x}):e.jsxs(e.Fragment,{children:[n!==void 0&&e.jsxs("div",{className:c,children:[typeof n=="number"?e.jsx(V,{value:n,className:"font-mono tabular-nums",priority:"medium",format:Number.isInteger(n)?void 0:{minimumFractionDigits:1,maximumFractionDigits:1}}):e.jsx($,{children:n}),a&&e.jsx("span",{className:"mini-widget-unit",children:a})]}),l&&e.jsx("div",{className:"mini-widget-subtitle",children:l}),d]})]})}const tn={DELTA_CRITICAL:10,SLOPE_CRITICAL:4,JITTER_CRITICAL:6,DELTA_WARNING:5,SLOPE_WARNING:2,JITTER_WARNING:4},Ue={baselineMedian:null,baselineP10:null,baselineP90:null,currentMedian:null,currentSampleCount:0,delta:0,slope:0,jitter:0,penalty:0,penaltyReason:null,computedAt:0,isReliable:!1};function me(t,s){if(t.length===0)return null;const n=[...t].sort((l,m)=>l-m),a=s/100*(n.length-1),o=Math.floor(a),i=Math.ceil(a);return o===i?n[o]:n[o]+(n[i]-n[o])*(a-o)}function Se(t){return me(t,50)}function sn(t){if(t.length<2)return 0;const s=t.reduce((o,i)=>o+i,0)/t.length,a=t.map(o=>Math.pow(o-s,2)).reduce((o,i)=>o+i,0)/t.length;return Math.sqrt(a)}function nn(t){if(t.length<2)return 0;const s=t.length;let n=0,a=0,o=0,i=0;const l=t[0].timestamp;for(const d of t){const r=(d.timestamp-l)/3600,x=d.value;n+=r,a+=x,o+=r*x,i+=r*r}const m=s*i-n*n;return Math.abs(m)<1e-4?0:(s*o-n*a)/m}function an(t,s,n){const a=tn;return t>=a.DELTA_CRITICAL?[2,`Noise floor ${t.toFixed(1)} dB above baseline`]:s>=a.SLOPE_CRITICAL?[2,`Noise floor rising ${s.toFixed(1)} dB/hour`]:n>=a.JITTER_CRITICAL?[2,`Noise floor unstable (±${n.toFixed(1)} dB)`]:t>=a.DELTA_WARNING?[1,`Noise floor ${t.toFixed(1)} dB above baseline`]:s>=a.SLOPE_WARNING?[1,`Noise floor rising ${s.toFixed(1)} dB/hour`]:n>=a.JITTER_WARNING?[1,`Noise floor variable (±${n.toFixed(1)} dB)`]:[0,null]}function on(t){if(t.length===0)return{...Ue,computedAt:Math.floor(Date.now()/1e3)};const s=Math.floor(Date.now()/1e3),n=t.filter(v=>Number.isFinite(v)),a=t.length>0?[t[t.length-1]]:[],o=t.slice(-4).filter(v=>Number.isFinite(v)),i=Se(n),l=me(n,10),m=me(n,90),d=Se(a),r=d!==null&&l!==null?d-l:0,x=o.map((v,k)=>({timestamp:s-(o.length-1-k)*3600,value:v})),u=nn(x),g=sn(o),c=n.length>=12,[h,y]=c?an(r,u,g):[0,null];return{baselineMedian:i,baselineP10:l,baselineP90:m,currentMedian:d,currentSampleCount:a.length,delta:r,slope:u,jitter:g,penalty:h,penaltyReason:y,computedAt:s,isReliable:c}}const rn={lbtStats:null,noiseFloor:null,sparklineNoiseFloor:[],noiseFloorWindowHistory:[],linkQuality:null,channelHealth:null,nfTrend:Ue,radioConfig:null,trends:null,stats:null,recentPackets:[],quickNeighbors:[],isLoading:!0,error:null,refresh:async()=>{}},Ve=f.createContext(rn);function ln({children:t}){var b;const s=te(),n=G(),a=Fe(),o=gt(),i=X(),l=P[i],m=Math.max(1,l.minutes/60),d=s===null,r=f.useMemo(()=>yt(n,m),[n,m]),x=(s==null?void 0:s.noise_floor_dbm)??null,u=f.useMemo(()=>bt(x)?x:null,[x]),g=f.useMemo(()=>{var R;const S=(R=s==null?void 0:s.config)==null?void 0:R.radio;return S?{sf:S.spreading_factor??7,bwHz:S.bandwidth??125e3}:null},[(b=s==null?void 0:s.config)==null?void 0:b.radio]),c=jt(m),h=Nt(m),y=s==null?void 0:s.neighbors,v=f.useMemo(()=>Object.fromEntries(Object.entries(y??{}).filter(([R])=>!o.has(R))),[y,o]),k=f.useMemo(()=>a.filter(S=>!o.has(S.hash)),[a,o]),M=f.useMemo(()=>on(c),[c]),j=f.useMemo(()=>vt(k,v,g),[k,v,g]),N=f.useMemo(()=>wt(r,u,j),[r,u,j]),[w,C]=f.useState({noiseFloor:null,networkScore:null,channelHealth:null}),p=f.useRef(0);f.useEffect(()=>{const S=()=>{const B=Date.now();B-p.current>3e4&&(p.current=B,C({noiseFloor:u,networkScore:(j==null?void 0:j.networkScore)??null,channelHealth:(N==null?void 0:N.score)??null}))};S();const R=setInterval(S,5e3);return()=>clearInterval(R)},[u,j==null?void 0:j.networkScore,N==null?void 0:N.score]);const D=f.useMemo(()=>({noiseFloor:{current:u,previous:w.noiseFloor,trend:u!==null?ne(u,w.noiseFloor,2,!0):"stable"},networkScore:{current:(j==null?void 0:j.networkScore)??0,previous:w.networkScore,trend:ne((j==null?void 0:j.networkScore)??0,w.networkScore,3,!1)},channelHealth:{current:(N==null?void 0:N.score)??0,previous:w.channelHealth,trend:ne((N==null?void 0:N.score)??0,w.channelHealth,3,!1)}}),[u,j==null?void 0:j.networkScore,N==null?void 0:N.score,w]),_={lbtStats:r,noiseFloor:u,sparklineNoiseFloor:c,noiseFloorWindowHistory:h,linkQuality:j,channelHealth:N,nfTrend:M,radioConfig:g,trends:D,stats:s,recentPackets:n,quickNeighbors:a,isLoading:d,error:null,refresh:async()=>{}};return e.jsx(Ve.Provider,{value:_,children:t})}function Y(){const t=f.useContext(Ve);if(t===void 0)throw new Error("useLBTData must be used within an LBTDataProvider");return t}function cn(t){return t<100?"excellent":t<250?"good":t<500?"fair":t<1e3?"congested":"critical"}function dn(t,s){return t===0?"No backoffs":`${s.toFixed(0)}% retry rate`}function mn(){const{lbtStats:t,isLoading:s,error:n}=Y(),a=xe(),o=(t==null?void 0:t.avgBackoffMs)??0,i=(t==null?void 0:t.retryRate)??0,l=t?cn(o):"unknown",m=t==null?void 0:t.sparklineBackoff,d=f.useMemo(()=>!m||m.length<2?[]:m.map((r,x)=>({timestamp:Date.now()-(m.length-1-x)*36e5,count:r})),[m]);return e.jsx(z,{title:"LBT Backoff",icon:e.jsx(_s,{className:"mini-widget-icon"}),value:Math.round(o),unit:"ms",status:l,subtitle:t?dn(o,i):void 0,isLoading:s,error:n,onClick:()=>a("/packets"),children:e.jsx("div",{className:"mini-widget-sparkline w-full",children:e.jsx(he,{data:d,width:9999,height:24,color:"var(--sys-blue)",isLoading:s,className:"w-full"})})})}function le(t){return t===0?"—":t<1?"<1":Math.round(t).toString()}function un(){const{lbtStats:t,isLoading:s,error:n}=Y(),a=xe(),o=(t==null?void 0:t.channelBusyCount)??0,i=(t==null?void 0:t.totalPacketsWithLBT)??0,l=(t==null?void 0:t.channelBusyRate)??0,m=(t==null?void 0:t.retryRate)??0,d=(t==null?void 0:t.avgBackoffMs)??0,r=(t==null?void 0:t.minBackoffMs)??0,x=(t==null?void 0:t.maxBackoffMs)??0,u=m>0?Math.max(0,(m-l)/m*100):100;return e.jsx(z,{title:"Ch. Busy",icon:e.jsx(Ut,{className:"mini-widget-icon"}),isLoading:s,error:n,onClick:()=>a("/packets"),children:e.jsx("div",{className:"flex-1 flex items-end",children:e.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)] sm:grid-cols-[auto_minmax(0,1fr)_auto_minmax(0,1fr)] gap-x-2 gap-y-1 sm:gap-y-2 w-full items-baseline",children:[e.jsx("span",{className:"data-box-label mb-0 text-[10px] sm:text-sm",title:`${o} packets exceeded max CAD attempts (5) out of ${i} total transmissions.`,children:"Failed:"}),e.jsxs("div",{className:"data-box data-box-compact sm:data-box justify-self-start",title:`${o} packets exceeded max CAD attempts (5) out of ${i} total transmissions.`,children:[e.jsx($,{children:o}),e.jsx("span",{className:"text-fg-muted punc-slash",children:"/"}),e.jsx($,{children:i})]}),e.jsx("span",{className:"data-box-label mb-0 text-[10px] sm:text-sm",title:`${u.toFixed(1)}% of packets that needed LBT retries were sent successfully.`,children:"Sent:"}),e.jsx("div",{className:"data-box data-box-compact sm:data-box justify-self-start",title:`${u.toFixed(1)}% of packets that needed LBT retries were sent successfully.`,children:e.jsxs($,{children:[u.toFixed(0),"%"]})}),e.jsx("span",{className:"data-box-label mb-0 text-[10px] sm:text-sm",title:`Average LBT backoff delay: ${d.toFixed(0)}ms.`,children:"Mean:"}),e.jsxs("div",{className:"data-box data-box-compact sm:data-box justify-self-start",title:`Average LBT backoff delay: ${d.toFixed(0)}ms.`,children:[e.jsx($,{children:le(d)}),e.jsx("span",{className:"text-fg-muted text-xs",children:"ms"})]}),e.jsx("span",{className:"data-box-label mb-0 text-[10px] sm:text-sm",title:`Backoff range: ${r.toFixed(0)}ms min, ${x.toFixed(0)}ms max.`,children:"Range:"}),e.jsxs("div",{className:"data-box data-box-compact sm:data-box justify-self-start",title:`Backoff range: ${r.toFixed(0)}ms min, ${x.toFixed(0)}ms max.`,children:[e.jsx($,{children:le(r)}),e.jsx("span",{className:"text-fg-muted punc-slash",children:"/"}),e.jsx($,{children:le(x)})]})]})})})}const xn=.25,_e=48;function hn(t,s,n,a){const o=t.length;if(o===0)return[];if(o===1)return new Array(a).fill(s[0]);if(o===2){const u=new Array(a);for(let g=0;gw-C),h=Math.max(c[i-1],1e-10);let y=0,v=0,k=0,M=0,j=0;for(let w=0;w=1)continue;const p=C*C*C,D=(1-p)*(1-p)*(1-p),T=t[w]-g;y+=D,v+=D*T,k+=D*s[w],M+=D*T*T,j+=D*T*s[w]}if(y===0){r[u]=s[Math.round(u/(a-1)*(o-1))];continue}const N=y*M-v*v;r[u]=Math.abs(N)<1e-10?k/y:(M*k-v*j)/N}return r}function fn(t){return t===null||t<-110?"excellent":t<-100?"good":t<-90?"fair":t<-80?"congested":"critical"}function pn(t){return t===null?"No reading":t<-115?"Very quiet":t<-105?"Quiet":t<-95?"Moderate":t<-85?"Elevated":"High interference"}function gn(){const{noiseFloor:t,noiseFloorWindowHistory:s,trends:n,isLoading:a,error:o}=Y(),i=fn(t),l=n==null?void 0:n.noiseFloor.trend,m=f.useMemo(()=>{if(!s||s.length<2)return[];const r=s.map(g=>g.timestamp),x=s.map(g=>-g.noise_floor_dbm);return hn(r,x,xn,_e).map((g,c)=>({timestamp:Date.now()-(_e-1-c)*36e5,count:g}))},[s]),d=t!==null?Math.round(t):"—";return e.jsx(z,{title:"Noise Floor",icon:e.jsx(xs,{className:"mini-widget-icon"}),value:d,unit:t!==null?"dBm":void 0,status:i,trend:l,subtitle:pn(t),isLoading:a,error:o,children:e.jsx("div",{className:"mini-widget-sparkline w-full",children:e.jsx(he,{data:m,width:9999,height:22,color:"var(--sys-blue)",isLoading:a,className:"w-full"})})})}const Ge=[{target:"LinkLeaders",fn:"path",minStage:1,when:zt},{target:"LinkLeaders",fn:"src_hash",minStage:1,when:Wt}];O(Ge);function yn(){I(Ge);const t=xe(),s=Fe(),n=G(),a=te(),o=X(),l=P[o].minutes*60,m=kt(),d=f.useMemo(()=>{if(m===0)return n;const p=m-l;return n.filter(D=>D.timestamp>=p)},[n,l,m]),r=a===null,x=a!=null&&a.local_hash?Ne(a.local_hash):"",u=(a==null?void 0:a.neighbors)??{},{neighborHashes:g,neighborNames:c}=f.useMemo(()=>{const p=new Set,D=new Map;for(const T of s){p.add(T.hash);const _=u[T.hash],b=(_==null?void 0:_.name)||(_==null?void 0:_.node_name)||T.prefix;D.set(T.hash,b)}return{neighborHashes:p,neighborNames:D}},[s,u]),h=f.useMemo(()=>{if(g.size===0||d.length===0||!x)return{champion:null,listener:null,loudest:null};const{scores:p}=ts(d,g,x),D=[];for(const[S,R]of p)R.blendedScore!==0&&D.push({...R,name:c.get(S)??Ne(S)});let T=null,_=null,b=null;for(const S of D)(!T||S.blendedScore>T.blendedScore)&&(T=S),(!_||S.listenerScore>_.listenerScore)&&(_=S),(!b||S.loudScore>b.loudScore)&&(b=S);return{champion:T,listener:_,loudest:b}},[d,g,x,c]),y=p=>e.jsxs("div",{className:"max-w-[220px]",children:[e.jsxs("div",{className:"font-semibold mb-1",children:["🏆 Champion: ",p.name]}),e.jsxs("div",{className:"text-fg-muted mb-1",children:["Blended Score: ",p.blendedScore,e.jsx("span",{className:"text-fg-muted/60 ml-1",children:"(Listener + Loud)"})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-1 mt-1 space-y-0.5",children:[e.jsxs("div",{children:["Listener: ",p.listenerScore,"/100 (",p.listenerCount," shared paths)"]}),e.jsxs("div",{children:["Loud: ",p.loudScore,"/100 (",p.loudCount," packets relayed)"]})]})]}),v=p=>e.jsxs("div",{className:"max-w-[220px]",children:[e.jsxs("div",{className:"font-semibold mb-1",children:["👂 Best Listener: ",p.name]}),e.jsxs("div",{className:"text-fg-muted mb-1",children:["Score: ",p.listenerScore,"/100"]}),e.jsx("div",{className:"border-t border-edge-subtle pt-1 mt-1",children:e.jsxs("div",{children:[p.listenerCount," packets where they heard your transmissions"]})})]}),k=p=>e.jsxs("div",{className:"max-w-[220px]",children:[e.jsxs("div",{className:"font-semibold mb-1",children:["📢 Loudest: ",p.name]}),e.jsxs("div",{className:"text-fg-muted mb-1",children:["Score: ",p.loudScore,"/100"]}),e.jsx("div",{className:"border-t border-edge-subtle pt-1 mt-1",children:e.jsxs("div",{children:[p.loudCount," packets they relayed directly to you"]})})]}),{champion:M,listener:j,loudest:N}=h,C=M||j||N?e.jsxs("div",{className:"flex flex-col gap-0 sm:gap-0.5 mt-auto",children:[M&&e.jsx(ae,{content:y(M),children:e.jsxs("div",{className:"flex items-center gap-1 text-xs sm:text-sm radius-badge px-1 -mx-1 hover-bg transition-base cursor-default",children:[e.jsx(Jt,{className:"w-2.5 h-2.5 sm:w-3 sm:h-3 text-map-neighbor-color flex-shrink-0"}),e.jsx("span",{className:"font-semibold text-map-neighbor-color font-mono truncate flex-1 min-w-0",children:M.name}),e.jsx("span",{className:"text-map-neighbor-color pl-1 sm:pl-2 tabular-nums flex-shrink-0 w-7 sm:w-9 text-right",children:M.blendedScore})]})}),j&&e.jsx(ae,{content:v(j),children:e.jsxs("div",{className:"flex items-center gap-1 text-xs sm:text-sm radius-badge px-1 -mx-1 hover-bg transition-base cursor-default",children:[e.jsx(gs,{className:"w-2.5 h-2.5 sm:w-3 sm:h-3 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-fg-muted font-mono truncate flex-1 min-w-0",children:j.name}),e.jsx("span",{className:"text-fg-muted pl-1 sm:pl-2 tabular-nums flex-shrink-0 w-7 sm:w-9 text-right",children:j.listenerScore})]})}),N&&e.jsx(ae,{content:k(N),children:e.jsxs("div",{className:"flex items-center gap-1 text-xs sm:text-sm radius-badge px-1 -mx-1 hover-bg transition-base cursor-default",children:[e.jsx(bs,{className:"w-2.5 h-2.5 sm:w-3 sm:h-3 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-fg-muted font-mono truncate flex-1 min-w-0",children:N.name}),e.jsx("span",{className:"text-fg-muted pl-1 sm:pl-2 tabular-nums flex-shrink-0 w-7 sm:w-9 text-right",children:N.loudScore})]})})]}):s.length===0?e.jsx("div",{className:"flex items-center justify-center text-xs sm:text-sm text-fg-muted mt-auto",children:"No direct neighbors"}):e.jsx("div",{className:"flex items-center justify-center text-xs sm:text-sm text-fg-muted mt-auto",children:"No routing data yet"});return e.jsx(z,{title:"Link Leaders",icon:e.jsx(Ms,{className:"mini-widget-icon"}),isLoading:r,onClick:()=>t("/contacts"),children:C})}function bn(t){const{retryRate:s,channelBusyCount:n,totalPacketsWithLBT:a,avgBackoffMs:o,maxBackoffMs:i}=t;if(a===0)return 0;const l=Math.min(a/10,1),m=.15,d=Math.log(1+s*m)/Math.log(1+100*m)*40,r=n/a*100,x=Math.min(r*.5,25);let u=0;o>100&&(u=Math.min(Math.log10(o/100)*8,15));let g=0;i>500&&o>0&&i>o*2&&(g=Math.min((i-500)/200,5));const h=(d+x+u+g)*l;return Math.min(h,85)}function jn(t){return t<15?"excellent":t<30?"good":t<45?"fair":t<60?"congested":"critical"}function Nn(t){return t<15?"Clear channel":t<30?"Light traffic":t<45?"Moderate traffic":t<60?"Heavy traffic":t<75?"Congested":"Severe congestion"}function vn(){const{lbtStats:t,isLoading:s,error:n}=Y(),a=t?bn(t):0,o=t?jn(a):"unknown",i=(t==null?void 0:t.maxBackoffMs)??0,l=t?i>200?`Max backoff: ${Math.round(i)}ms`:Nn(a):void 0,m=t==null?void 0:t.sparklineCollisionRisk,d=f.useMemo(()=>!m||m.length<2?[]:m.map((x,u)=>({timestamp:Date.now()-(m.length-1-u)*36e5,count:x})),[m]),r=Math.round(a*10)/10;return e.jsx(z,{title:"Collision Risk",icon:e.jsx(ss,{className:"mini-widget-icon"}),value:r,unit:"%",status:o,subtitle:l,isLoading:s,error:n,children:e.jsx("div",{className:"mini-widget-sparkline w-full",children:e.jsx(he,{data:d,width:9999,height:24,color:"var(--sys-blue)",isLoading:s,className:"w-full"})})})}function wn(t){return t<30?"excellent":t<50?"good":t<70?"fair":t<90?"congested":"critical"}function kn(t){return t<1e3?`${Math.round(t)}ms`:t<6e4?`${(t/1e3).toFixed(1)}s`:`${(t/6e4).toFixed(1)}m`}function Mn(){const[t,s]=f.useState(!1),[n]=f.useState(0),{stats:a,lbtStats:o,isLoading:i}=Y(),l=f.useMemo(()=>{if(!a)return null;const c=a.airtime_used_ms??0,h=a.max_airtime_ms??1,y=a.airtime_remaining_ms??0,v=a.utilization_percent??(h>0?c/h*100:0);return{usedMs:c,maxMs:h,remainingMs:y,utilizationPercent:v}},[a]),m=f.useMemo(()=>{if(!o||o.totalPacketsWithLBT===0)return 100;const c=o.totalPacketsWithLBT-o.packetsWithRetries,h=o.totalPacketsWithLBT;return c/h*100},[o]),d=(l==null?void 0:l.utilizationPercent)??0,r=wn(d),x=(l==null?void 0:l.remainingMs)??0,u=m<95?`${m.toFixed(0)}% clean TX`:`${kn(x)} remaining`,g=l?e.jsx("div",{className:"mini-widget-progress mt-auto",children:e.jsx("div",{className:`mini-widget-progress-bar ${r}`,style:{width:`${Math.min(d,100)}%`}})}):null;return e.jsx(z,{title:"Duty Cycle",icon:e.jsx(Le,{className:"mini-widget-icon"}),value:d.toFixed(1),unit:"%",status:r,subtitle:u,isLoading:i,children:g})}function Cn(){return e.jsxs("div",{className:"mini-widget",children:[e.jsxs("div",{className:"mini-widget-header",children:[e.jsx(K,{className:"w-4 h-4"}),e.jsx(K,{className:"h-3 w-16"})]}),e.jsx(K,{className:"h-7 w-12 mt-2"}),e.jsx(K,{className:"h-3 w-20 mt-2"})]})}function Tn(){return e.jsx("div",{className:"widget-row",children:Array.from({length:6}).map((t,s)=>e.jsx(Cn,{},s))})}const Xe=[{target:"MeshHealth",fn:"type",minStage:1}];O(Xe);function Sn({className:t="",isLoaded:s=!0}){return I(Xe),e.jsxs("div",{className:`mesh-health-container relative ${t}`,children:[e.jsxs("div",{className:"mesh-health-header",children:[e.jsx(Mt,{className:"w-4 h-4 text-sys-blue"}),e.jsx("span",{className:"type-label text-fg-muted",children:"MESH HEALTH"})]}),s?e.jsx(ln,{children:e.jsxs("div",{className:"widget-row",children:[e.jsx(mn,{}),e.jsx(vn,{}),e.jsx(gn,{}),e.jsx(Mn,{}),e.jsx(un,{}),e.jsx(yn,{})]})}):e.jsx(Tn,{})]})}const Ye=[{target:"PublicChannel",fn:"decrypt",minStage:2,when:qt}];O(Ye);let Ke="",Je="",De="";function _n(){const t=new Date,s=t.toDateString();if(s!==De){De=s,Ke=s;const n=new Date(t);n.setDate(n.getDate()-1),Je=n.toDateString()}}function Dn(t){_n();const s=new Date(t*1e3).toDateString();return s===Ke?"Today":s===Je?"Yesterday":new Date(t*1e3).toLocaleDateString([],{weekday:"short",month:"short",day:"numeric"})}function Rn(t,s,n){return`${t||""}|${s}|${n}`}function Bn(t,s){const n=t.message,a=s.message;return n.timestamp===a.timestamp&&n.text===a.text&&n.senderName===a.senderName&&n.channelHash===a.channelHash&&n.channelName===a.channelName&&t.isChannelSelected===s.isChannelSelected&&t.onChannelClick===s.onChannelClick}const Ln=f.memo(function({message:s,onChannelClick:n,isChannelSelected:a}){const o=s.channelName||s.channelHash.slice(0,6);return e.jsx("div",{style:{transform:"translateZ(0)",willChange:"transform"},children:e.jsx(ls,{senderName:s.senderName||"Unknown",text:s.text,timestamp:s.timestamp,nameAccessory:e.jsx($e,{channelName:o,active:a,onClick:()=>n==null?void 0:n(s.channelHash)})})})},Bn);function Fn({open:t,onClose:s,messages:n,onLoadMore:a,hasMoreToLoad:o,isDecoding:i,initialChannel:l}){const m=f.useRef(null),d=f.useRef(!0),r=X(),x=Pe(),u=f.useRef(!1);f.useEffect(()=>{t?(u.current=!0,we.resume()):u.current&&we.pause()},[t]);const g=f.useMemo(()=>{const b=Date.now()/1e3,S=P[r].minutes,R=b-S*60;return[...n].filter(B=>B.timestamp>=R).sort((B,W)=>B.timestamp-W.timestamp)},[n,r]),c=f.useCallback(()=>{const b=m.current;b&&(d.current=b.scrollTop>=-50)},[]),h=f.useMemo(()=>{const b=new Map;for(const S of g){const R=S.channelHash,B=b.get(R);B?B.count++:b.set(R,{name:S.channelName||S.channelHash.slice(0,6),hash:S.channelHash,count:1})}return Array.from(b.values()).sort((S,R)=>R.count-S.count)},[g]),y=h.length,[v,k]=f.useState(null),[M,j]=f.useState(!1);f.useEffect(()=>{t&&l&&k(l)},[t,l]);const N=f.useCallback(()=>{a(v,h)},[a,v,h]),w=f.useMemo(()=>v?g.filter(b=>b.channelHash===v):g,[g,v]),C=f.useMemo(()=>{const b=[];let S="";for(const R of w){const B=Dn(R.timestamp);B!==S&&(b.push({type:"date",date:B}),S=B),b.push({type:"message",message:R})}return b},[w]);f.useLayoutEffect(()=>{const b=m.current;b&&d.current&&(b.scrollTop=0)},[w.length]);const p=19,D=h.slice(0,p),T=h.slice(p),_=T.length>0;return e.jsx(Rt,{open:t,onClose:s,size:"lg",motionPlus:!0,solid:!0,children:e.jsxs(Bt,{className:"p-0 flex flex-col h-[80vh] max-h-[700px] rounded-2xl",children:[e.jsx("div",{className:"flex-shrink-0 px-4 sm:px-5 py-3 sm:py-4",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(He,{className:"size-5 text-icon-card-title flex-shrink-0"}),e.jsx("h2",{className:"type-micro",children:"Public Channels"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ee,{ranges:P,selectedIndex:r,onSelect:x,size:"sm"}),e.jsx("button",{onClick:s,className:"sm:hidden min-h-[44px] min-w-[44px] px-3 flex items-center justify-center text-[15px] font-medium text-sys-blue active:text-sys-blue/70 transition-base radius-inner active:bg-subtle-fill",children:"Done"}),e.jsx("button",{onClick:s,className:"hidden sm:flex items-center justify-center p-2 text-fg-muted hover:text-fg-primary transition-base radius-inner hover:bg-subtle","aria-label":"Close",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})]})}),e.jsx("div",{className:"flex-shrink-0 px-3 pb-2 relative z-10 isolate",style:{minHeight:y>0?void 0:0},children:y>0&&e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsxs("button",{onClick:()=>k(null),className:F("px-2 py-0.5 rounded text-xs font-medium transition-all","ring-1 ring-inset",v===null?"bg-sys-blue/20 text-sys-blue ring-sys-blue/30":"bg-subtle-fill text-fg-secondary ring-edge-subtle hover:bg-subtle-fill-strong"),children:["All ",y]}),D.map(b=>e.jsx("button",{onClick:()=>k(b.hash),className:F("flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium transition-all","ring-1 ring-inset",v===b.hash?"bg-sys-blue/20 text-sys-blue ring-sys-blue/30":"bg-subtle-fill text-fg-secondary ring-edge-subtle hover:bg-subtle-fill-strong"),children:e.jsx("span",{className:"truncate max-w-[80px]",children:b.name})},b.hash)),_&&e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>j(!M),className:F("flex items-center gap-0.5 px-2 py-0.5 rounded text-xs font-medium transition-all","ring-1 ring-inset",M||T.some(b=>b.hash===v)?"bg-sys-blue/20 text-sys-blue ring-sys-blue/30":"bg-subtle-fill text-fg-secondary ring-edge-subtle hover:bg-subtle-fill-strong"),children:["+",T.length,e.jsx(Lt,{className:F("size-3 transition-transform",M&&"rotate-180")})]}),M&&e.jsx("div",{className:F("absolute top-full left-0 mt-1 z-50","min-w-[140px] max-h-[200px] overflow-y-auto","p-1 rounded-lg","bg-elevated backdrop-blur-xl","ring-1 ring-edge-subtle shadow-xl"),children:T.map(b=>e.jsxs("button",{onClick:()=>{k(b.hash),j(!1)},className:F("w-full flex items-center gap-1.5 px-2 py-1 rounded text-xs font-medium transition-all text-left",v===b.hash?"bg-sys-blue/20 text-sys-blue":"text-fg-secondary hover:bg-subtle-fill-strong"),children:[e.jsx(cs,{className:"size-2.5 opacity-60 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:b.name}),e.jsxs("span",{className:"opacity-60 ml-auto",children:["(",b.count,")"]})]},b.hash))})]})]})}),e.jsx("div",{ref:m,onScroll:c,className:F("flex-1 overflow-y-auto overflow-x-hidden","mx-3 mb-3 rounded-md","bg-body","ring-1 ring-inset ring-edge-subtle","flex flex-col-reverse"),children:i&&w.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full min-h-[300px] text-fg-muted px-4 py-4",children:[e.jsx(ee,{className:"size-12 mb-4 text-sys-indigo animate-spin"}),e.jsx("p",{className:"text-lg font-medium",children:"Loading messages..."})]}):w.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full min-h-[300px] text-fg-muted px-4 py-4",children:[e.jsx(Ns,{className:"size-16 mb-4 opacity-20"}),e.jsx("p",{className:"text-lg font-medium",children:"No messages yet"}),e.jsx("p",{className:"text-sm mt-1 opacity-70",children:v?"No messages in this channel":"Public channel messages will appear here"})]}):e.jsxs("div",{className:"px-4 py-4",children:[o&&e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("button",{onClick:N,disabled:i,className:F("px-4 py-1.5 rounded-full","text-[11px] font-medium","ring-1 ring-inset",i?"bg-subtle-fill text-fg-muted ring-edge-subtle cursor-wait":"bg-sys-blue/10 text-sys-blue ring-sys-blue/20 hover:bg-sys-blue/20 hover:ring-sys-blue/30"),children:i?e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(ee,{className:"size-3 animate-spin"}),"Loading..."]}):"Load older messages"})}),C.map((b,S)=>{if(b.type==="date")return e.jsx("div",{className:"flex justify-center my-4",children:e.jsx("span",{className:F("px-3.5 py-1.5 rounded-full","bg-subtle-fill backdrop-blur-sm","text-[11px] text-fg-muted/80 font-medium","ring-1 ring-edge-subtle"),children:b.date})},`date-${b.date}-${S}`);const R=`msg-${b.message.timestamp}-${b.message.senderName||"anon"}-${b.message.channelHash}`;return e.jsx("div",{className:"mb-3",children:e.jsx(Ln,{message:b.message,onChannelClick:k,isChannelSelected:v===b.message.channelHash})},R)})]})}),e.jsx("div",{className:"flex-shrink-0 px-5 py-2 text-center",children:e.jsxs("p",{className:"text-[11px] text-fg-muted",children:[w.length," messages · ",y," ",y===1?"channel":"channels",i&&e.jsxs("span",{className:"ml-2 text-sys-indigo",children:[e.jsx(ee,{className:"inline size-3 animate-spin mr-1"}),"Decrypting..."]})]})})]})})}function Pn(t){const s=[],n=new Set;for(const a of t.values()){const o=a.decoded;if(!o||!o.decrypted||o.macCorrupted||!o.text)continue;const i=Rn(o.senderName,o.channelHash,o.text);n.has(i)||(n.add(i),s.push({timestamp:a.timestamp,channelName:o.channelName,channelHash:o.channelHash,senderName:o.senderName,text:o.text,rssi:a.rssi,snr:a.snr}))}return s}function An({isLoaded:t=!0}){I(Ye);const s=G(),[n,a]=f.useState(!1),[o,i]=f.useState(null),l=X(),m=f.useCallback(()=>{i(null),a(!0),J.getState().queueDecryption(s)},[s]),d=ce(C=>C.requestedHash),r=ce(C=>C.clearRequest);f.useEffect(()=>{d&&(i(d),a(!0),J.getState().queueDecryption(s),r())},[d,r,s]);const x=Ct(),u=Tt(),g=St(),c=f.useMemo(()=>Pn(x),[x]),h=f.useMemo(()=>{const C=Date.now()/1e3,p=P[l].minutes,D=C-p*60;return c.filter(T=>T.timestamp>=D)},[c,l]),y=f.useMemo(()=>h.length===0?null:h.reduce((C,p)=>p.timestamp>C.timestamp?p:C),[h]),v=u.isDecoding,M=f.useMemo(()=>{const C=Date.now()/1e3,p=P[l].minutes,D=C-p*60,T=new Set;let _=0;for(const b of s)(b.type??b.payload_type)===ve.GRP_TXT&&((b.timestamp??0){const C=Date.now()/1e3,p=P[l].minutes,D=C-p*60;for(const T of s)if((T.type??T.payload_type)===ve.GRP_TXT&&!((T.timestamp??0){if(!v){if(C){const D=p.find(T=>T.hash===C);if(D){console.log(`[PublicChannelCard] Fast-path load for #${D.name}`),J.getState().queueChannelDecryption(s,D.name);return}}J.getState().queueDecryption(s)}},[s,v]);return t?e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:m,className:F("group cursor-pointer rounded-2xl transition-all duration-150","bg-surface/80 backdrop-blur-lg depth-raised","hover:bg-subtle-fill","px-3 py-2.5 sm:px-4 sm:py-3"),children:e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 flex-shrink-0",children:[e.jsx(He,{className:"size-4 text-icon-card-title flex-shrink-0"}),e.jsx("span",{className:"type-micro",children:"CHAT ACTIVITY"}),M>0&&e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-md bg-subtle-fill ring-1 ring-inset ring-edge-subtle text-sm tabular-nums text-fg-secondary",children:M}),e.jsx(Ce,{className:"size-4 text-fg-muted group-hover:text-sys-indigo transition-colors ml-auto sm:hidden"})]}),e.jsxs("div",{className:"flex items-center gap-2 sm:gap-1.5 min-w-0 overflow-hidden",children:[e.jsx(Re,{mode:"wait",initial:!1,children:y?e.jsxs(Q.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},exit:{opacity:0,y:-16},transition:{duration:.2,ease:[.4,0,.2,1]},className:"flex items-center gap-2 sm:gap-1.5 min-w-0",children:[y.channelName&&e.jsx("span",{className:"hidden sm:inline-flex",children:e.jsx($e,{channelName:y.channelName})}),e.jsx("div",{className:"hidden sm:flex w-[30px] h-[30px] rounded-full items-center justify-center flex-shrink-0 ring-1 ring-edge-subtle",style:{backgroundColor:os(oe(y.senderName||"").cleanName)},children:oe(y.senderName||"").emoji?e.jsx("span",{className:"text-base",children:oe(y.senderName||"").emoji}):e.jsx("span",{className:"text-white text-xs font-bold tracking-tighter",children:is(y.senderName||"")})}),e.jsx("div",{className:"inline-flex items-center px-3 py-1.5 rounded-2xl rounded-tr-md bg-[#007AFF] shadow-sm min-w-0 flex-1 sm:flex-initial sm:max-w-xs sm:-ml-px",children:e.jsx("span",{className:"text-sm text-white truncate tracking-wide",children:rs(y.text)})}),e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-md bg-subtle-fill ring-1 ring-inset ring-edge-subtle text-sm tabular-nums text-fg-secondary flex-shrink-0",children:Dt(y.timestamp)})]},`msg-${y.timestamp}-${y.senderName}-${y.channelHash}`):g?e.jsx(Q.span,{initial:{opacity:0},animate:{opacity:1},className:"text-sm text-fg-muted italic",children:"No messages yet"},"empty"):e.jsxs(Q.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,y:-16},transition:{duration:.15},className:"flex items-center gap-2 sm:gap-1.5",children:[e.jsx("div",{className:"hidden sm:block w-8 h-4 rounded bg-subtle-fill-strong animate-pulse"}),e.jsx("div",{className:"hidden sm:block w-[30px] h-[30px] rounded-full bg-subtle-fill-strong animate-pulse"}),e.jsx("div",{className:"h-8 w-32 sm:w-48 rounded-2xl bg-subtle-fill-strong animate-pulse"}),e.jsx("div",{className:"w-12 h-6 rounded-md bg-subtle-fill-strong animate-pulse"})]},"skeleton")}),e.jsx(Ce,{className:"size-4 text-fg-muted group-hover:text-sys-indigo transition-colors flex-shrink-0 hidden sm:block ml-1"})]})]})}),e.jsx(Fn,{open:n,onClose:()=>a(!1),messages:c,onLoadMore:w,hasMoreToLoad:N,isDecoding:v,initialChannel:o})]}):e.jsx("div",{className:"h-14 rounded-xl bg-elevated/50 animate-pulse"})}function ga(){var M,j;const t=te(),s=Ft(),n=G(),a=Pt(),o=f.useRef(!1);a&&!o.current&&(o.current=!0);const i=o.current,l=X(),m=Pe(),d=At(),r=P[l]??P[4],x=d.isBackgroundLoading&&l>=5,u=(M=t==null?void 0:t.config)==null?void 0:M.radio,g=f.useMemo(()=>u?{sf:u.spreading_factor??10,bw:u.bandwidth??25e4,cr:u.coding_rate??5,preamble:u.preamble_length??8}:null,[u]),c=n.length,h=f.useMemo(()=>c?$t(r.minutes,r.buckets,n,t):null,[c,r.minutes,r.buckets,g]),y=f.useMemo(()=>{const N=R=>(R==null?void 0:R.reduce((B,W)=>B+W.count,0))??0,w=N(h==null?void 0:h.received),C=N(h==null?void 0:h.unique_received),p=N(h==null?void 0:h.forwarded),D=N(h==null?void 0:h.dropped),T=N(h==null?void 0:h.transmitted),_=((h==null?void 0:h.time_range_minutes)??r.minutes)/60,b=_>0?Math.round(w/_):0,S=_>0?Math.round(p/_):0;return{received:w,uniqueReceived:C,forwarded:p,dropped:D,transmitted:T,rxPerHour:b,fwdPerHour:S}},[h,r.minutes]),v=f.useMemo(()=>{if(!n.length)return{totalBytes:0,kbPerHour:0};const N=Date.now()/1e3,w=r.minutes*60,C=N-w;let p=0;for(const _ of n)_.transmitted||_.timestampN||(p+=_.length??_.payload_length??0);const D=r.minutes/60,T=D>0?Math.round(p/1024/D):0;return{totalBytes:p,kbPerHour:T}},[n,r.minutes]),k=(t==null?void 0:t.node_name)??((j=t==null?void 0:t.config)==null?void 0:j.node_name)??"Unknown Node";return f.useEffect(()=>{k&&k!=="Unknown Node"&&(document.title=`pyMC: ${k}`)},[k]),s?e.jsxs(ke,{neomorphic:!0,className:"p-8 text-center",children:[e.jsx("p",{className:"type-subheading text-sys-red mb-2",children:"Failed to connect to backend"}),e.jsx("p",{className:"type-body text-fg-muted",children:s}),e.jsx("p",{className:"type-data-sm text-fg-muted mt-4",children:"Make sure the backend is running on port 8000"})]}):e.jsxs(Et,{children:[e.jsx(Ht,{title:k,icon:e.jsx(ns,{}),controls:e.jsx(Ee,{ranges:P,selectedIndex:l,onSelect:m,isPending:x})}),e.jsxs(It,{children:[e.jsx(An,{isLoaded:i}),e.jsx(ie,{template:"hero-auto",children:e.jsxs(ke,{neomorphic:!0,children:[e.jsx(Be,{icon:e.jsx(fs,{}),title:"PACKETS RECEIVED",badge:r.label,badgeColor:"zinc",actions:i?e.jsxs("div",{className:"data-box",children:[v.kbPerHour," KB/hr"]}):e.jsx("div",{className:"data-box opacity-0",children:"0 KB/hr"})}),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:i?e.jsx(V,{value:y.received,className:"font-mono tabular-nums",priority:"high"}):e.jsx("span",{className:"opacity-30",children:"—"})}),e.jsx(U,{color:"zinc",className:"mb-0.5 sm:mb-1",children:"Total Rx"})]}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("div",{className:"type-data-xl text-fg-primary",children:i?e.jsx(V,{value:y.uniqueReceived,className:"font-mono tabular-nums",priority:"high"}):e.jsx("span",{className:"opacity-30",children:"—"})}),e.jsx(U,{color:"zinc",className:"mb-0.5 sm:mb-1",children:"Unique"})]})]}),e.jsxs("div",{className:"mt-2 flex-1 min-h-0 relative",children:[e.jsx("div",{className:`absolute inset-0 flex items-end gap-1 transition-opacity duration-300 ${i?"opacity-0 pointer-events-none":"opacity-100"}`,"aria-hidden":i,children:[45,72,33,58,80,42,65,28,55,75,38,62].map((N,w)=>e.jsx("div",{className:"flex-1 bg-subtle-fill rounded-sm animate-pulse",style:{height:`${N}%`}},w))}),e.jsx("div",{className:`h-full transition-opacity duration-300 ${i?"opacity-100":"opacity-0"}`,children:e.jsx(Ls,{packets:n,rangeMinutes:r.minutes,bucketCount:r.buckets})})]})]})}),e.jsxs(ie,{template:"compact",children:[e.jsx(re,{span:6,lg:4,children:e.jsx(Es,{value:y.forwarded,receivedCount:y.received,packets:n,rangeMinutes:r.minutes,bucketCount:r.buckets,timeRangeLabel:r.label,icon:e.jsx(ms,{className:"w-4 h-4"}),isLoaded:i})}),e.jsx(re,{span:6,lg:4,children:e.jsx(Is,{value:y.dropped,receivedCount:y.received,packets:n,rangeMinutes:r.minutes,bucketCount:r.buckets,timeRangeLabel:r.label,icon:e.jsx(Zt,{className:"w-4 h-4"}),isLoaded:i})}),e.jsx(re,{span:12,lg:4,children:e.jsx(Xs,{stats:t,localHash:t==null?void 0:t.local_hash,receivedBuckets:h==null?void 0:h.received,droppedBuckets:h==null?void 0:h.dropped,forwardedBuckets:h==null?void 0:h.forwarded,bucketDurationSeconds:h==null?void 0:h.bucket_duration_seconds,timeRangeLabel:r.label,isLoaded:i})})]}),e.jsx(Sn,{isLoaded:i}),e.jsx(Ks,{}),t&&e.jsx(ie,{template:"auto",children:e.jsx(as,{nodeName:k,repeaterVersion:t.version,coreVersion:t.core_version,localHash:t.local_hash,publicKey:t.public_key})})]})]})}export{ga as default}; + ${r==="success"?"bg-sys-green/15 text-sys-green":r==="error"?"bg-sys-red/15 text-sys-red":r==="applying"?"bg-subtle-fill text-fg-muted":"bg-sys-blue/10 text-sys-blue hover:bg-sys-blue/20"}`,title:`Apply ×${p.floodFactor.toFixed(1)} flood, ×${p.directFactor.toFixed(1)} direct`,children:[r==="success"?"Rx'd":r==="error"?"Failed":"Apply",r==="applying"?e.jsx(ee,{className:"w-3.5 h-3.5 animate-spin"}):r==="success"?e.jsx(be,{className:"w-3.5 h-3.5"}):e.jsxs("span",{className:"relative inline-flex items-end w-6 h-3.5",children:[e.jsx(ws,{className:"w-3.5 h-3.5 absolute left-0 bottom-0"}),e.jsx(Ts,{className:"w-3 h-3 absolute right-0 bottom-0"})]})]})]})})]})}const qe=[{target:"RecentPackets",fn:"rssi",minStage:1},{target:"RecentPackets",fn:"snr",minStage:1}];O(qe);const Ys=25;function Ks(){I(qe);const t=G(),s=xt(),n=ht(),a=te(),o=Qt(),i=ce(c=>c.requestChannel),[l,m]=f.useState(!0),d=f.useCallback(c=>m(c),[]),r=f.useMemo(()=>[...t.length<=100?t:t.slice(-100)].sort((h,y)=>(y.timestamp??0)-(h.timestamp??0)),[t]),x=a==null?void 0:a.local_hash,u=a==null?void 0:a.neighbors,g=es();return e.jsxs(H,{noPadding:!0,className:"!overflow-visible",children:[e.jsx(Be,{listHeader:!0,icon:e.jsx(Le,{}),title:"Recent Packets",actions:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ft,{enabled:l,onChange:d,label:"Hide Dupes",size:"sm"}),n&&e.jsx(pt,{showLabel:!0}),e.jsxs(je,{color:"primary",outline:!0,href:"/packets",children:["View all",e.jsx(Me,{"data-slot":"icon"})]})]})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto px-1",children:e.jsx(Kt,{packets:r,allPackets:t,localHash:x,neighbors:u,resolveSource:g,getDecodedContent:o,onChannelClick:i,loading:s,maxPackets:Ys,showPagination:!1,flashNewest:!0,hideDupes:l,emptyMessage:"No packets received",footerAction:e.jsxs(je,{color:"primary",outline:!0,href:"/packets",children:["View all",e.jsx(Me,{"data-slot":"icon"})]})})})]})}const Js={stable:"M5 12h14",up:"M5 15l7-7 7 7",down:"M19 9l-7 7-7-7"};function Zs({trend:t}){return e.jsx("span",{className:`mini-widget-trend ${t}`,children:e.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:Js[t]})})})}function Qs(){return e.jsx("div",{className:"mini-widget-loading",children:e.jsx("div",{className:"mini-widget-loading-spinner"})})}function en({message:t}){return e.jsx("div",{className:"mini-widget-error",children:e.jsx("span",{title:t,children:"No data"})})}function z({title:t,icon:s,value:n,unit:a,valueSize:o="md",status:i,subtitle:l,trend:m,children:d,isLoading:r=!1,error:x,className:u="",onClick:g}){const c=["mini-widget-value",o==="lg"&&"mini-widget-value-lg",o==="sm"&&"mini-widget-value-sm"].filter(Boolean).join(" "),h=["mini-widget",u].filter(Boolean).join(" ");return e.jsxs(H,{noPadding:!0,className:h,onClick:g,children:[e.jsxs("div",{className:"mini-widget-header",children:[s,e.jsx("span",{className:"mini-widget-title",children:t}),i&&i!=="unknown"&&e.jsx("div",{className:`mini-widget-status-dot ${i}`}),m&&e.jsx(Zs,{trend:m})]}),r?e.jsx(Qs,{}):x?e.jsx(en,{message:x}):e.jsxs(e.Fragment,{children:[n!==void 0&&e.jsxs("div",{className:c,children:[typeof n=="number"?e.jsx(V,{value:n,className:"font-mono tabular-nums",priority:"medium",format:Number.isInteger(n)?void 0:{minimumFractionDigits:1,maximumFractionDigits:1}}):e.jsx($,{children:n}),a&&e.jsx("span",{className:"mini-widget-unit",children:a})]}),l&&e.jsx("div",{className:"mini-widget-subtitle",children:l}),d]})]})}const tn={DELTA_CRITICAL:10,SLOPE_CRITICAL:4,JITTER_CRITICAL:6,DELTA_WARNING:5,SLOPE_WARNING:2,JITTER_WARNING:4},Ue={baselineMedian:null,baselineP10:null,baselineP90:null,currentMedian:null,currentSampleCount:0,delta:0,slope:0,jitter:0,penalty:0,penaltyReason:null,computedAt:0,isReliable:!1};function me(t,s){if(t.length===0)return null;const n=[...t].sort((l,m)=>l-m),a=s/100*(n.length-1),o=Math.floor(a),i=Math.ceil(a);return o===i?n[o]:n[o]+(n[i]-n[o])*(a-o)}function Se(t){return me(t,50)}function sn(t){if(t.length<2)return 0;const s=t.reduce((o,i)=>o+i,0)/t.length,a=t.map(o=>Math.pow(o-s,2)).reduce((o,i)=>o+i,0)/t.length;return Math.sqrt(a)}function nn(t){if(t.length<2)return 0;const s=t.length;let n=0,a=0,o=0,i=0;const l=t[0].timestamp;for(const d of t){const r=(d.timestamp-l)/3600,x=d.value;n+=r,a+=x,o+=r*x,i+=r*r}const m=s*i-n*n;return Math.abs(m)<1e-4?0:(s*o-n*a)/m}function an(t,s,n){const a=tn;return t>=a.DELTA_CRITICAL?[2,`Noise floor ${t.toFixed(1)} dB above baseline`]:s>=a.SLOPE_CRITICAL?[2,`Noise floor rising ${s.toFixed(1)} dB/hour`]:n>=a.JITTER_CRITICAL?[2,`Noise floor unstable (±${n.toFixed(1)} dB)`]:t>=a.DELTA_WARNING?[1,`Noise floor ${t.toFixed(1)} dB above baseline`]:s>=a.SLOPE_WARNING?[1,`Noise floor rising ${s.toFixed(1)} dB/hour`]:n>=a.JITTER_WARNING?[1,`Noise floor variable (±${n.toFixed(1)} dB)`]:[0,null]}function on(t){if(t.length===0)return{...Ue,computedAt:Math.floor(Date.now()/1e3)};const s=Math.floor(Date.now()/1e3),n=t.filter(v=>Number.isFinite(v)),a=t.length>0?[t[t.length-1]]:[],o=t.slice(-4).filter(v=>Number.isFinite(v)),i=Se(n),l=me(n,10),m=me(n,90),d=Se(a),r=d!==null&&l!==null?d-l:0,x=o.map((v,k)=>({timestamp:s-(o.length-1-k)*3600,value:v})),u=nn(x),g=sn(o),c=n.length>=12,[h,y]=c?an(r,u,g):[0,null];return{baselineMedian:i,baselineP10:l,baselineP90:m,currentMedian:d,currentSampleCount:a.length,delta:r,slope:u,jitter:g,penalty:h,penaltyReason:y,computedAt:s,isReliable:c}}const rn={lbtStats:null,noiseFloor:null,sparklineNoiseFloor:[],noiseFloorWindowHistory:[],linkQuality:null,channelHealth:null,nfTrend:Ue,radioConfig:null,trends:null,stats:null,recentPackets:[],quickNeighbors:[],isLoading:!0,error:null,refresh:async()=>{}},Ve=f.createContext(rn);function ln({children:t}){var b;const s=te(),n=G(),a=Fe(),o=gt(),i=X(),l=P[i],m=Math.max(1,l.minutes/60),d=s===null,r=f.useMemo(()=>yt(n,m),[n,m]),x=(s==null?void 0:s.noise_floor_dbm)??null,u=f.useMemo(()=>bt(x)?x:null,[x]),g=f.useMemo(()=>{var R;const S=(R=s==null?void 0:s.config)==null?void 0:R.radio;return S?{sf:S.spreading_factor??7,bwHz:S.bandwidth??125e3}:null},[(b=s==null?void 0:s.config)==null?void 0:b.radio]),c=jt(m),h=Nt(m),y=s==null?void 0:s.neighbors,v=f.useMemo(()=>Object.fromEntries(Object.entries(y??{}).filter(([R])=>!o.has(R))),[y,o]),k=f.useMemo(()=>a.filter(S=>!o.has(S.hash)),[a,o]),M=f.useMemo(()=>on(c),[c]),j=f.useMemo(()=>vt(k,v,g),[k,v,g]),N=f.useMemo(()=>wt(r,u,j),[r,u,j]),[w,C]=f.useState({noiseFloor:null,networkScore:null,channelHealth:null}),p=f.useRef(0);f.useEffect(()=>{const S=()=>{const B=Date.now();B-p.current>3e4&&(p.current=B,C({noiseFloor:u,networkScore:(j==null?void 0:j.networkScore)??null,channelHealth:(N==null?void 0:N.score)??null}))};S();const R=setInterval(S,5e3);return()=>clearInterval(R)},[u,j==null?void 0:j.networkScore,N==null?void 0:N.score]);const D=f.useMemo(()=>({noiseFloor:{current:u,previous:w.noiseFloor,trend:u!==null?ne(u,w.noiseFloor,2,!0):"stable"},networkScore:{current:(j==null?void 0:j.networkScore)??0,previous:w.networkScore,trend:ne((j==null?void 0:j.networkScore)??0,w.networkScore,3,!1)},channelHealth:{current:(N==null?void 0:N.score)??0,previous:w.channelHealth,trend:ne((N==null?void 0:N.score)??0,w.channelHealth,3,!1)}}),[u,j==null?void 0:j.networkScore,N==null?void 0:N.score,w]),_={lbtStats:r,noiseFloor:u,sparklineNoiseFloor:c,noiseFloorWindowHistory:h,linkQuality:j,channelHealth:N,nfTrend:M,radioConfig:g,trends:D,stats:s,recentPackets:n,quickNeighbors:a,isLoading:d,error:null,refresh:async()=>{}};return e.jsx(Ve.Provider,{value:_,children:t})}function Y(){const t=f.useContext(Ve);if(t===void 0)throw new Error("useLBTData must be used within an LBTDataProvider");return t}function cn(t){return t<100?"excellent":t<250?"good":t<500?"fair":t<1e3?"congested":"critical"}function dn(t,s){return t===0?"No backoffs":`${s.toFixed(0)}% retry rate`}function mn(){const{lbtStats:t,isLoading:s,error:n}=Y(),a=xe(),o=(t==null?void 0:t.avgBackoffMs)??0,i=(t==null?void 0:t.retryRate)??0,l=t?cn(o):"unknown",m=t==null?void 0:t.sparklineBackoff,d=f.useMemo(()=>!m||m.length<2?[]:m.map((r,x)=>({timestamp:Date.now()-(m.length-1-x)*36e5,count:r})),[m]);return e.jsx(z,{title:"LBT Backoff",icon:e.jsx(_s,{className:"mini-widget-icon"}),value:Math.round(o),unit:"ms",status:l,subtitle:t?dn(o,i):void 0,isLoading:s,error:n,onClick:()=>a("/packets"),children:e.jsx("div",{className:"mini-widget-sparkline w-full",children:e.jsx(he,{data:d,width:9999,height:24,color:"var(--sys-blue)",isLoading:s,className:"w-full"})})})}function le(t){return t===0?"—":t<1?"<1":Math.round(t).toString()}function un(){const{lbtStats:t,isLoading:s,error:n}=Y(),a=xe(),o=(t==null?void 0:t.channelBusyCount)??0,i=(t==null?void 0:t.totalPacketsWithLBT)??0,l=(t==null?void 0:t.channelBusyRate)??0,m=(t==null?void 0:t.retryRate)??0,d=(t==null?void 0:t.avgBackoffMs)??0,r=(t==null?void 0:t.minBackoffMs)??0,x=(t==null?void 0:t.maxBackoffMs)??0,u=m>0?Math.max(0,(m-l)/m*100):100;return e.jsx(z,{title:"Ch. Busy",icon:e.jsx(Ut,{className:"mini-widget-icon"}),isLoading:s,error:n,onClick:()=>a("/packets"),children:e.jsx("div",{className:"flex-1 flex items-end",children:e.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)] sm:grid-cols-[auto_minmax(0,1fr)_auto_minmax(0,1fr)] gap-x-2 gap-y-1 sm:gap-y-2 w-full items-baseline",children:[e.jsx("span",{className:"data-box-label mb-0 text-[10px] sm:text-sm",title:`${o} packets exceeded max CAD attempts (5) out of ${i} total transmissions.`,children:"Failed:"}),e.jsxs("div",{className:"data-box data-box-compact sm:data-box justify-self-start",title:`${o} packets exceeded max CAD attempts (5) out of ${i} total transmissions.`,children:[e.jsx($,{children:o}),e.jsx("span",{className:"text-fg-muted punc-slash",children:"/"}),e.jsx($,{children:i})]}),e.jsx("span",{className:"data-box-label mb-0 text-[10px] sm:text-sm",title:`${u.toFixed(1)}% of packets that needed LBT retries were sent successfully.`,children:"Sent:"}),e.jsx("div",{className:"data-box data-box-compact sm:data-box justify-self-start",title:`${u.toFixed(1)}% of packets that needed LBT retries were sent successfully.`,children:e.jsxs($,{children:[u.toFixed(0),"%"]})}),e.jsx("span",{className:"data-box-label mb-0 text-[10px] sm:text-sm",title:`Average LBT backoff delay: ${d.toFixed(0)}ms.`,children:"Mean:"}),e.jsxs("div",{className:"data-box data-box-compact sm:data-box justify-self-start",title:`Average LBT backoff delay: ${d.toFixed(0)}ms.`,children:[e.jsx($,{children:le(d)}),e.jsx("span",{className:"text-fg-muted text-xs",children:"ms"})]}),e.jsx("span",{className:"data-box-label mb-0 text-[10px] sm:text-sm",title:`Backoff range: ${r.toFixed(0)}ms min, ${x.toFixed(0)}ms max.`,children:"Range:"}),e.jsxs("div",{className:"data-box data-box-compact sm:data-box justify-self-start",title:`Backoff range: ${r.toFixed(0)}ms min, ${x.toFixed(0)}ms max.`,children:[e.jsx($,{children:le(r)}),e.jsx("span",{className:"text-fg-muted punc-slash",children:"/"}),e.jsx($,{children:le(x)})]})]})})})}const xn=.25,_e=48;function hn(t,s,n,a){const o=t.length;if(o===0)return[];if(o===1)return new Array(a).fill(s[0]);if(o===2){const u=new Array(a);for(let g=0;gw-C),h=Math.max(c[i-1],1e-10);let y=0,v=0,k=0,M=0,j=0;for(let w=0;w=1)continue;const p=C*C*C,D=(1-p)*(1-p)*(1-p),T=t[w]-g;y+=D,v+=D*T,k+=D*s[w],M+=D*T*T,j+=D*T*s[w]}if(y===0){r[u]=s[Math.round(u/(a-1)*(o-1))];continue}const N=y*M-v*v;r[u]=Math.abs(N)<1e-10?k/y:(M*k-v*j)/N}return r}function fn(t){return t===null||t<-110?"excellent":t<-100?"good":t<-90?"fair":t<-80?"congested":"critical"}function pn(t){return t===null?"No reading":t<-115?"Very quiet":t<-105?"Quiet":t<-95?"Moderate":t<-85?"Elevated":"High interference"}function gn(){const{noiseFloor:t,noiseFloorWindowHistory:s,trends:n,isLoading:a,error:o}=Y(),i=fn(t),l=n==null?void 0:n.noiseFloor.trend,m=f.useMemo(()=>{if(!s||s.length<2)return[];const r=s.map(g=>g.timestamp),x=s.map(g=>-g.noise_floor_dbm);return hn(r,x,xn,_e).map((g,c)=>({timestamp:Date.now()-(_e-1-c)*36e5,count:g}))},[s]),d=t!==null?Math.round(t):"—";return e.jsx(z,{title:"Noise Floor",icon:e.jsx(xs,{className:"mini-widget-icon"}),value:d,unit:t!==null?"dBm":void 0,status:i,trend:l,subtitle:pn(t),isLoading:a,error:o,children:e.jsx("div",{className:"mini-widget-sparkline w-full",children:e.jsx(he,{data:m,width:9999,height:22,color:"var(--sys-blue)",isLoading:a,className:"w-full"})})})}const Ge=[{target:"LinkLeaders",fn:"path",minStage:1,when:zt},{target:"LinkLeaders",fn:"src_hash",minStage:1,when:Wt}];O(Ge);function yn(){I(Ge);const t=xe(),s=Fe(),n=G(),a=te(),o=X(),l=P[o].minutes*60,m=kt(),d=f.useMemo(()=>{if(m===0)return n;const p=m-l;return n.filter(D=>D.timestamp>=p)},[n,l,m]),r=a===null,x=a!=null&&a.local_hash?Ne(a.local_hash):"",u=(a==null?void 0:a.neighbors)??{},{neighborHashes:g,neighborNames:c}=f.useMemo(()=>{const p=new Set,D=new Map;for(const T of s){p.add(T.hash);const _=u[T.hash],b=(_==null?void 0:_.name)||(_==null?void 0:_.node_name)||T.prefix;D.set(T.hash,b)}return{neighborHashes:p,neighborNames:D}},[s,u]),h=f.useMemo(()=>{if(g.size===0||d.length===0||!x)return{champion:null,listener:null,loudest:null};const{scores:p}=ts(d,g,x),D=[];for(const[S,R]of p)R.blendedScore!==0&&D.push({...R,name:c.get(S)??Ne(S)});let T=null,_=null,b=null;for(const S of D)(!T||S.blendedScore>T.blendedScore)&&(T=S),(!_||S.listenerScore>_.listenerScore)&&(_=S),(!b||S.loudScore>b.loudScore)&&(b=S);return{champion:T,listener:_,loudest:b}},[d,g,x,c]),y=p=>e.jsxs("div",{className:"max-w-[220px]",children:[e.jsxs("div",{className:"font-semibold mb-1",children:["🏆 Champion: ",p.name]}),e.jsxs("div",{className:"text-fg-muted mb-1",children:["Blended Score: ",p.blendedScore,e.jsx("span",{className:"text-fg-muted/60 ml-1",children:"(Listener + Loud)"})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-1 mt-1 space-y-0.5",children:[e.jsxs("div",{children:["Listener: ",p.listenerScore,"/100 (",p.listenerCount," shared paths)"]}),e.jsxs("div",{children:["Loud: ",p.loudScore,"/100 (",p.loudCount," packets relayed)"]})]})]}),v=p=>e.jsxs("div",{className:"max-w-[220px]",children:[e.jsxs("div",{className:"font-semibold mb-1",children:["👂 Best Listener: ",p.name]}),e.jsxs("div",{className:"text-fg-muted mb-1",children:["Score: ",p.listenerScore,"/100"]}),e.jsx("div",{className:"border-t border-edge-subtle pt-1 mt-1",children:e.jsxs("div",{children:[p.listenerCount," packets where they heard your transmissions"]})})]}),k=p=>e.jsxs("div",{className:"max-w-[220px]",children:[e.jsxs("div",{className:"font-semibold mb-1",children:["📢 Loudest: ",p.name]}),e.jsxs("div",{className:"text-fg-muted mb-1",children:["Score: ",p.loudScore,"/100"]}),e.jsx("div",{className:"border-t border-edge-subtle pt-1 mt-1",children:e.jsxs("div",{children:[p.loudCount," packets they relayed directly to you"]})})]}),{champion:M,listener:j,loudest:N}=h,C=M||j||N?e.jsxs("div",{className:"flex flex-col gap-0 sm:gap-0.5 mt-auto",children:[M&&e.jsx(ae,{content:y(M),children:e.jsxs("div",{className:"flex items-center gap-1 text-xs sm:text-sm radius-badge px-1 -mx-1 hover-bg transition-base cursor-default",children:[e.jsx(Jt,{className:"w-2.5 h-2.5 sm:w-3 sm:h-3 text-map-neighbor-color flex-shrink-0"}),e.jsx("span",{className:"font-semibold text-map-neighbor-color font-mono truncate flex-1 min-w-0",children:M.name}),e.jsx("span",{className:"text-map-neighbor-color pl-1 sm:pl-2 tabular-nums flex-shrink-0 w-7 sm:w-9 text-right",children:M.blendedScore})]})}),j&&e.jsx(ae,{content:v(j),children:e.jsxs("div",{className:"flex items-center gap-1 text-xs sm:text-sm radius-badge px-1 -mx-1 hover-bg transition-base cursor-default",children:[e.jsx(gs,{className:"w-2.5 h-2.5 sm:w-3 sm:h-3 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-fg-muted font-mono truncate flex-1 min-w-0",children:j.name}),e.jsx("span",{className:"text-fg-muted pl-1 sm:pl-2 tabular-nums flex-shrink-0 w-7 sm:w-9 text-right",children:j.listenerScore})]})}),N&&e.jsx(ae,{content:k(N),children:e.jsxs("div",{className:"flex items-center gap-1 text-xs sm:text-sm radius-badge px-1 -mx-1 hover-bg transition-base cursor-default",children:[e.jsx(bs,{className:"w-2.5 h-2.5 sm:w-3 sm:h-3 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-fg-muted font-mono truncate flex-1 min-w-0",children:N.name}),e.jsx("span",{className:"text-fg-muted pl-1 sm:pl-2 tabular-nums flex-shrink-0 w-7 sm:w-9 text-right",children:N.loudScore})]})})]}):s.length===0?e.jsx("div",{className:"flex items-center justify-center text-xs sm:text-sm text-fg-muted mt-auto",children:"No direct neighbors"}):e.jsx("div",{className:"flex items-center justify-center text-xs sm:text-sm text-fg-muted mt-auto",children:"No routing data yet"});return e.jsx(z,{title:"Link Leaders",icon:e.jsx(Ms,{className:"mini-widget-icon"}),isLoading:r,onClick:()=>t("/contacts"),children:C})}function bn(t){const{retryRate:s,channelBusyCount:n,totalPacketsWithLBT:a,avgBackoffMs:o,maxBackoffMs:i}=t;if(a===0)return 0;const l=Math.min(a/10,1),m=.15,d=Math.log(1+s*m)/Math.log(1+100*m)*40,r=n/a*100,x=Math.min(r*.5,25);let u=0;o>100&&(u=Math.min(Math.log10(o/100)*8,15));let g=0;i>500&&o>0&&i>o*2&&(g=Math.min((i-500)/200,5));const h=(d+x+u+g)*l;return Math.min(h,85)}function jn(t){return t<15?"excellent":t<30?"good":t<45?"fair":t<60?"congested":"critical"}function Nn(t){return t<15?"Clear channel":t<30?"Light traffic":t<45?"Moderate traffic":t<60?"Heavy traffic":t<75?"Congested":"Severe congestion"}function vn(){const{lbtStats:t,isLoading:s,error:n}=Y(),a=t?bn(t):0,o=t?jn(a):"unknown",i=(t==null?void 0:t.maxBackoffMs)??0,l=t?i>200?`Max backoff: ${Math.round(i)}ms`:Nn(a):void 0,m=t==null?void 0:t.sparklineCollisionRisk,d=f.useMemo(()=>!m||m.length<2?[]:m.map((x,u)=>({timestamp:Date.now()-(m.length-1-u)*36e5,count:x})),[m]),r=Math.round(a*10)/10;return e.jsx(z,{title:"Collision Risk",icon:e.jsx(ss,{className:"mini-widget-icon"}),value:r,unit:"%",status:o,subtitle:l,isLoading:s,error:n,children:e.jsx("div",{className:"mini-widget-sparkline w-full",children:e.jsx(he,{data:d,width:9999,height:24,color:"var(--sys-blue)",isLoading:s,className:"w-full"})})})}function wn(t){return t<30?"excellent":t<50?"good":t<70?"fair":t<90?"congested":"critical"}function kn(t){return t<1e3?`${Math.round(t)}ms`:t<6e4?`${(t/1e3).toFixed(1)}s`:`${(t/6e4).toFixed(1)}m`}function Mn(){const[t,s]=f.useState(!1),[n]=f.useState(0),{stats:a,lbtStats:o,isLoading:i}=Y(),l=f.useMemo(()=>{if(!a)return null;const c=a.airtime_used_ms??0,h=a.max_airtime_ms??1,y=a.airtime_remaining_ms??0,v=a.utilization_percent??(h>0?c/h*100:0);return{usedMs:c,maxMs:h,remainingMs:y,utilizationPercent:v}},[a]),m=f.useMemo(()=>{if(!o||o.totalPacketsWithLBT===0)return 100;const c=o.totalPacketsWithLBT-o.packetsWithRetries,h=o.totalPacketsWithLBT;return c/h*100},[o]),d=(l==null?void 0:l.utilizationPercent)??0,r=wn(d),x=(l==null?void 0:l.remainingMs)??0,u=m<95?`${m.toFixed(0)}% clean TX`:`${kn(x)} remaining`,g=l?e.jsx("div",{className:"mini-widget-progress mt-auto",children:e.jsx("div",{className:`mini-widget-progress-bar ${r}`,style:{width:`${Math.min(d,100)}%`}})}):null;return e.jsx(z,{title:"Duty Cycle",icon:e.jsx(Le,{className:"mini-widget-icon"}),value:d.toFixed(1),unit:"%",status:r,subtitle:u,isLoading:i,children:g})}function Cn(){return e.jsxs("div",{className:"mini-widget",children:[e.jsxs("div",{className:"mini-widget-header",children:[e.jsx(K,{className:"w-4 h-4"}),e.jsx(K,{className:"h-3 w-16"})]}),e.jsx(K,{className:"h-7 w-12 mt-2"}),e.jsx(K,{className:"h-3 w-20 mt-2"})]})}function Tn(){return e.jsx("div",{className:"widget-row",children:Array.from({length:6}).map((t,s)=>e.jsx(Cn,{},s))})}const Xe=[{target:"MeshHealth",fn:"type",minStage:1}];O(Xe);function Sn({className:t="",isLoaded:s=!0}){return I(Xe),e.jsxs("div",{className:`mesh-health-container relative ${t}`,children:[e.jsxs("div",{className:"mesh-health-header",children:[e.jsx(Mt,{className:"w-4 h-4 text-sys-blue"}),e.jsx("span",{className:"type-label text-fg-muted",children:"MESH HEALTH"})]}),s?e.jsx(ln,{children:e.jsxs("div",{className:"widget-row",children:[e.jsx(mn,{}),e.jsx(vn,{}),e.jsx(gn,{}),e.jsx(Mn,{}),e.jsx(un,{}),e.jsx(yn,{})]})}):e.jsx(Tn,{})]})}const Ye=[{target:"PublicChannel",fn:"decrypt",minStage:2,when:qt}];O(Ye);let Ke="",Je="",De="";function _n(){const t=new Date,s=t.toDateString();if(s!==De){De=s,Ke=s;const n=new Date(t);n.setDate(n.getDate()-1),Je=n.toDateString()}}function Dn(t){_n();const s=new Date(t*1e3).toDateString();return s===Ke?"Today":s===Je?"Yesterday":new Date(t*1e3).toLocaleDateString([],{weekday:"short",month:"short",day:"numeric"})}function Rn(t,s,n){return`${t||""}|${s}|${n}`}function Bn(t,s){const n=t.message,a=s.message;return n.timestamp===a.timestamp&&n.text===a.text&&n.senderName===a.senderName&&n.channelHash===a.channelHash&&n.channelName===a.channelName&&t.isChannelSelected===s.isChannelSelected&&t.onChannelClick===s.onChannelClick}const Ln=f.memo(function({message:s,onChannelClick:n,isChannelSelected:a}){const o=s.channelName||s.channelHash.slice(0,6);return e.jsx("div",{style:{transform:"translateZ(0)",willChange:"transform"},children:e.jsx(ls,{senderName:s.senderName||"Unknown",text:s.text,timestamp:s.timestamp,nameAccessory:e.jsx($e,{channelName:o,active:a,onClick:()=>n==null?void 0:n(s.channelHash)})})})},Bn);function Fn({open:t,onClose:s,messages:n,onLoadMore:a,hasMoreToLoad:o,isDecoding:i,initialChannel:l}){const m=f.useRef(null),d=f.useRef(!0),r=X(),x=Pe(),u=f.useRef(!1);f.useEffect(()=>{t?(u.current=!0,we.resume()):u.current&&we.pause()},[t]);const g=f.useMemo(()=>{const b=Date.now()/1e3,S=P[r].minutes,R=b-S*60;return[...n].filter(B=>B.timestamp>=R).sort((B,W)=>B.timestamp-W.timestamp)},[n,r]),c=f.useCallback(()=>{const b=m.current;b&&(d.current=b.scrollTop>=-50)},[]),h=f.useMemo(()=>{const b=new Map;for(const S of g){const R=S.channelHash,B=b.get(R);B?B.count++:b.set(R,{name:S.channelName||S.channelHash.slice(0,6),hash:S.channelHash,count:1})}return Array.from(b.values()).sort((S,R)=>R.count-S.count)},[g]),y=h.length,[v,k]=f.useState(null),[M,j]=f.useState(!1);f.useEffect(()=>{t&&l&&k(l)},[t,l]);const N=f.useCallback(()=>{a(v,h)},[a,v,h]),w=f.useMemo(()=>v?g.filter(b=>b.channelHash===v):g,[g,v]),C=f.useMemo(()=>{const b=[];let S="";for(const R of w){const B=Dn(R.timestamp);B!==S&&(b.push({type:"date",date:B}),S=B),b.push({type:"message",message:R})}return b},[w]);f.useLayoutEffect(()=>{const b=m.current;b&&d.current&&(b.scrollTop=0)},[w.length]);const p=19,D=h.slice(0,p),T=h.slice(p),_=T.length>0;return e.jsx(Rt,{open:t,onClose:s,size:"lg",motionPlus:!0,solid:!0,children:e.jsxs(Bt,{className:"p-0 flex flex-col h-[80vh] max-h-[700px] rounded-2xl",children:[e.jsx("div",{className:"flex-shrink-0 px-4 sm:px-5 py-3 sm:py-4",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(He,{className:"size-5 text-icon-card-title flex-shrink-0"}),e.jsx("h2",{className:"type-micro",children:"Public Channels"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ee,{ranges:P,selectedIndex:r,onSelect:x,size:"sm"}),e.jsx("button",{onClick:s,className:"sm:hidden min-h-[44px] min-w-[44px] px-3 flex items-center justify-center text-[15px] font-medium text-sys-blue active:text-sys-blue/70 transition-base radius-inner active:bg-subtle-fill",children:"Done"}),e.jsx("button",{onClick:s,className:"hidden sm:flex items-center justify-center p-2 text-fg-muted hover:text-fg-primary transition-base radius-inner hover:bg-subtle","aria-label":"Close",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]})]})}),e.jsx("div",{className:"flex-shrink-0 px-3 pb-2 relative z-10 isolate",style:{minHeight:y>0?void 0:0},children:y>0&&e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsxs("button",{onClick:()=>k(null),className:F("px-2 py-0.5 rounded text-xs font-medium transition-all","ring-1 ring-inset",v===null?"bg-sys-blue/20 text-sys-blue ring-sys-blue/30":"bg-subtle-fill text-fg-secondary ring-edge-subtle hover:bg-subtle-fill-strong"),children:["All ",y]}),D.map(b=>e.jsx("button",{onClick:()=>k(b.hash),className:F("flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium transition-all","ring-1 ring-inset",v===b.hash?"bg-sys-blue/20 text-sys-blue ring-sys-blue/30":"bg-subtle-fill text-fg-secondary ring-edge-subtle hover:bg-subtle-fill-strong"),children:e.jsx("span",{className:"truncate max-w-[80px]",children:b.name})},b.hash)),_&&e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>j(!M),className:F("flex items-center gap-0.5 px-2 py-0.5 rounded text-xs font-medium transition-all","ring-1 ring-inset",M||T.some(b=>b.hash===v)?"bg-sys-blue/20 text-sys-blue ring-sys-blue/30":"bg-subtle-fill text-fg-secondary ring-edge-subtle hover:bg-subtle-fill-strong"),children:["+",T.length,e.jsx(Lt,{className:F("size-3 transition-transform",M&&"rotate-180")})]}),M&&e.jsx("div",{className:F("absolute top-full left-0 mt-1 z-50","min-w-[140px] max-h-[200px] overflow-y-auto","p-1 rounded-lg","bg-elevated backdrop-blur-xl","ring-1 ring-edge-subtle shadow-xl"),children:T.map(b=>e.jsxs("button",{onClick:()=>{k(b.hash),j(!1)},className:F("w-full flex items-center gap-1.5 px-2 py-1 rounded text-xs font-medium transition-all text-left",v===b.hash?"bg-sys-blue/20 text-sys-blue":"text-fg-secondary hover:bg-subtle-fill-strong"),children:[e.jsx(cs,{className:"size-2.5 opacity-60 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:b.name}),e.jsxs("span",{className:"opacity-60 ml-auto",children:["(",b.count,")"]})]},b.hash))})]})]})}),e.jsx("div",{ref:m,onScroll:c,className:F("flex-1 overflow-y-auto overflow-x-hidden","mx-3 mb-3 rounded-md","bg-body","ring-1 ring-inset ring-edge-subtle","flex flex-col-reverse"),children:i&&w.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full min-h-[300px] text-fg-muted px-4 py-4",children:[e.jsx(ee,{className:"size-12 mb-4 text-sys-indigo animate-spin"}),e.jsx("p",{className:"text-lg font-medium",children:"Loading messages..."})]}):w.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full min-h-[300px] text-fg-muted px-4 py-4",children:[e.jsx(Ns,{className:"size-16 mb-4 opacity-20"}),e.jsx("p",{className:"text-lg font-medium",children:"No messages yet"}),e.jsx("p",{className:"text-sm mt-1 opacity-70",children:v?"No messages in this channel":"Public channel messages will appear here"})]}):e.jsxs("div",{className:"px-4 py-4",children:[o&&e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("button",{onClick:N,disabled:i,className:F("px-4 py-1.5 rounded-full","text-[11px] font-medium","ring-1 ring-inset",i?"bg-subtle-fill text-fg-muted ring-edge-subtle cursor-wait":"bg-sys-blue/10 text-sys-blue ring-sys-blue/20 hover:bg-sys-blue/20 hover:ring-sys-blue/30"),children:i?e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(ee,{className:"size-3 animate-spin"}),"Loading..."]}):"Load older messages"})}),C.map((b,S)=>{if(b.type==="date")return e.jsx("div",{className:"flex justify-center my-4",children:e.jsx("span",{className:F("px-3.5 py-1.5 rounded-full","bg-subtle-fill backdrop-blur-sm","text-[11px] text-fg-muted/80 font-medium","ring-1 ring-edge-subtle"),children:b.date})},`date-${b.date}-${S}`);const R=`msg-${b.message.timestamp}-${b.message.senderName||"anon"}-${b.message.channelHash}`;return e.jsx("div",{className:"mb-3",children:e.jsx(Ln,{message:b.message,onChannelClick:k,isChannelSelected:v===b.message.channelHash})},R)})]})}),e.jsx("div",{className:"flex-shrink-0 px-5 py-2 text-center",children:e.jsxs("p",{className:"text-[11px] text-fg-muted",children:[w.length," messages · ",y," ",y===1?"channel":"channels",i&&e.jsxs("span",{className:"ml-2 text-sys-indigo",children:[e.jsx(ee,{className:"inline size-3 animate-spin mr-1"}),"Decrypting..."]})]})})]})})}function Pn(t){const s=[],n=new Set;for(const a of t.values()){const o=a.decoded;if(!o||!o.decrypted||o.macCorrupted||!o.text)continue;const i=Rn(o.senderName,o.channelHash,o.text);n.has(i)||(n.add(i),s.push({timestamp:a.timestamp,channelName:o.channelName,channelHash:o.channelHash,senderName:o.senderName,text:o.text,rssi:a.rssi,snr:a.snr}))}return s}function An({isLoaded:t=!0}){I(Ye);const s=G(),[n,a]=f.useState(!1),[o,i]=f.useState(null),l=X(),m=f.useCallback(()=>{i(null),a(!0),J.getState().queueDecryption(s)},[s]),d=ce(C=>C.requestedHash),r=ce(C=>C.clearRequest);f.useEffect(()=>{d&&(i(d),a(!0),J.getState().queueDecryption(s),r())},[d,r,s]);const x=Ct(),u=Tt(),g=St(),c=f.useMemo(()=>Pn(x),[x]),h=f.useMemo(()=>{const C=Date.now()/1e3,p=P[l].minutes,D=C-p*60;return c.filter(T=>T.timestamp>=D)},[c,l]),y=f.useMemo(()=>h.length===0?null:h.reduce((C,p)=>p.timestamp>C.timestamp?p:C),[h]),v=u.isDecoding,M=f.useMemo(()=>{const C=Date.now()/1e3,p=P[l].minutes,D=C-p*60,T=new Set;let _=0;for(const b of s)(b.type??b.payload_type)===ve.GRP_TXT&&((b.timestamp??0){const C=Date.now()/1e3,p=P[l].minutes,D=C-p*60;for(const T of s)if((T.type??T.payload_type)===ve.GRP_TXT&&!((T.timestamp??0){if(!v){if(C){const D=p.find(T=>T.hash===C);if(D){console.log(`[PublicChannelCard] Fast-path load for #${D.name}`),J.getState().queueChannelDecryption(s,D.name);return}}J.getState().queueDecryption(s)}},[s,v]);return t?e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:m,className:F("group cursor-pointer rounded-2xl transition-all duration-150","bg-surface/80 backdrop-blur-lg depth-raised","hover:bg-subtle-fill","px-3 py-2.5 sm:px-4 sm:py-3"),children:e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 flex-shrink-0",children:[e.jsx(He,{className:"size-4 text-icon-card-title flex-shrink-0"}),e.jsx("span",{className:"type-micro",children:"CHAT ACTIVITY"}),M>0&&e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-md bg-subtle-fill ring-1 ring-inset ring-edge-subtle text-sm tabular-nums text-fg-secondary",children:M}),e.jsx(Ce,{className:"size-4 text-fg-muted group-hover:text-sys-indigo transition-colors ml-auto sm:hidden"})]}),e.jsxs("div",{className:"flex items-center gap-2 sm:gap-1.5 min-w-0 overflow-hidden",children:[e.jsx(Re,{mode:"wait",initial:!1,children:y?e.jsxs(Q.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},exit:{opacity:0,y:-16},transition:{duration:.2,ease:[.4,0,.2,1]},className:"flex items-center gap-2 sm:gap-1.5 min-w-0",children:[y.channelName&&e.jsx("span",{className:"hidden sm:inline-flex",children:e.jsx($e,{channelName:y.channelName})}),e.jsx("div",{className:"hidden sm:flex w-[30px] h-[30px] rounded-full items-center justify-center flex-shrink-0 ring-1 ring-edge-subtle",style:{backgroundColor:os(oe(y.senderName||"").cleanName)},children:oe(y.senderName||"").emoji?e.jsx("span",{className:"text-base",children:oe(y.senderName||"").emoji}):e.jsx("span",{className:"text-white text-xs font-bold tracking-tighter",children:is(y.senderName||"")})}),e.jsx("div",{className:"inline-flex items-center px-3 py-1.5 rounded-2xl rounded-tr-md bg-[#007AFF] shadow-sm min-w-0 flex-1 sm:flex-initial sm:max-w-xs sm:-ml-px",children:e.jsx("span",{className:"text-sm text-white truncate tracking-wide",children:rs(y.text)})}),e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-md bg-subtle-fill ring-1 ring-inset ring-edge-subtle text-sm tabular-nums text-fg-secondary flex-shrink-0",children:Dt(y.timestamp)})]},`msg-${y.timestamp}-${y.senderName}-${y.channelHash}`):g?e.jsx(Q.span,{initial:{opacity:0},animate:{opacity:1},className:"text-sm text-fg-muted italic",children:"No messages yet"},"empty"):e.jsxs(Q.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0,y:-16},transition:{duration:.15},className:"flex items-center gap-2 sm:gap-1.5",children:[e.jsx("div",{className:"hidden sm:block w-8 h-4 rounded bg-subtle-fill-strong animate-pulse"}),e.jsx("div",{className:"hidden sm:block w-[30px] h-[30px] rounded-full bg-subtle-fill-strong animate-pulse"}),e.jsx("div",{className:"h-8 w-32 sm:w-48 rounded-2xl bg-subtle-fill-strong animate-pulse"}),e.jsx("div",{className:"w-12 h-6 rounded-md bg-subtle-fill-strong animate-pulse"})]},"skeleton")}),e.jsx(Ce,{className:"size-4 text-fg-muted group-hover:text-sys-indigo transition-colors flex-shrink-0 hidden sm:block ml-1"})]})]})}),e.jsx(Fn,{open:n,onClose:()=>a(!1),messages:c,onLoadMore:w,hasMoreToLoad:N,isDecoding:v,initialChannel:o})]}):e.jsx("div",{className:"h-14 rounded-xl bg-elevated/50 animate-pulse"})}function pa(){var M,j;const t=te(),s=Ft(),n=G(),a=Pt(),o=f.useRef(!1);a&&!o.current&&(o.current=!0);const i=o.current,l=X(),m=Pe(),d=At(),r=P[l]??P[4],x=d.isBackgroundLoading&&l>=5,u=(M=t==null?void 0:t.config)==null?void 0:M.radio,g=f.useMemo(()=>u?{sf:u.spreading_factor??10,bw:u.bandwidth??25e4,cr:u.coding_rate??5,preamble:u.preamble_length??8}:null,[u]),c=n.length,h=f.useMemo(()=>c?$t(r.minutes,r.buckets,n,t):null,[c,r.minutes,r.buckets,g]),y=f.useMemo(()=>{const N=R=>(R==null?void 0:R.reduce((B,W)=>B+W.count,0))??0,w=N(h==null?void 0:h.received),C=N(h==null?void 0:h.unique_received),p=N(h==null?void 0:h.forwarded),D=N(h==null?void 0:h.dropped),T=N(h==null?void 0:h.transmitted),_=((h==null?void 0:h.time_range_minutes)??r.minutes)/60,b=_>0?Math.round(w/_):0,S=_>0?Math.round(p/_):0;return{received:w,uniqueReceived:C,forwarded:p,dropped:D,transmitted:T,rxPerHour:b,fwdPerHour:S}},[h,r.minutes]),v=f.useMemo(()=>{if(!n.length)return{totalBytes:0,kbPerHour:0};const N=Date.now()/1e3,w=r.minutes*60,C=N-w;let p=0;for(const _ of n)_.transmitted||_.timestampN||(p+=_.length??_.payload_length??0);const D=r.minutes/60,T=D>0?Math.round(p/1024/D):0;return{totalBytes:p,kbPerHour:T}},[n,r.minutes]),k=(t==null?void 0:t.node_name)??((j=t==null?void 0:t.config)==null?void 0:j.node_name)??"Unknown Node";return f.useEffect(()=>{k&&k!=="Unknown Node"&&(document.title=`pyMC: ${k}`)},[k]),s?e.jsxs(ke,{neomorphic:!0,className:"p-8 text-center",children:[e.jsx("p",{className:"type-subheading text-sys-red mb-2",children:"Failed to connect to backend"}),e.jsx("p",{className:"type-body text-fg-muted",children:s}),e.jsx("p",{className:"type-data-sm text-fg-muted mt-4",children:"Make sure the backend is running on port 8000"})]}):e.jsxs(Et,{children:[e.jsx(Ht,{title:k,icon:e.jsx(ns,{}),controls:e.jsx(Ee,{ranges:P,selectedIndex:l,onSelect:m,isPending:x})}),e.jsxs(It,{children:[e.jsx(An,{isLoaded:i}),e.jsx(ie,{template:"hero-auto",children:e.jsxs(ke,{neomorphic:!0,children:[e.jsx(Be,{icon:e.jsx(fs,{}),title:"PACKETS RECEIVED",badge:r.label,badgeColor:"zinc",actions:i?e.jsxs("div",{className:"data-box",children:[v.kbPerHour," KB/hr"]}):e.jsx("div",{className:"data-box opacity-0",children:"0 KB/hr"})}),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:i?e.jsx(V,{value:y.received,className:"font-mono tabular-nums",priority:"high"}):e.jsx("span",{className:"opacity-30",children:"—"})}),e.jsx(U,{color:"zinc",className:"mb-0.5 sm:mb-1",children:"Total Rx"})]}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("div",{className:"type-data-xl text-fg-primary",children:i?e.jsx(V,{value:y.uniqueReceived,className:"font-mono tabular-nums",priority:"high"}):e.jsx("span",{className:"opacity-30",children:"—"})}),e.jsx(U,{color:"zinc",className:"mb-0.5 sm:mb-1",children:"Unique"})]})]}),e.jsxs("div",{className:"mt-2 flex-1 min-h-0 relative",children:[e.jsx("div",{className:`absolute inset-0 flex items-end gap-1 transition-opacity duration-300 ${i?"opacity-0 pointer-events-none":"opacity-100"}`,"aria-hidden":i,children:[45,72,33,58,80,42,65,28,55,75,38,62].map((N,w)=>e.jsx("div",{className:"flex-1 bg-subtle-fill rounded-sm animate-pulse",style:{height:`${N}%`}},w))}),e.jsx("div",{className:`h-full transition-opacity duration-300 ${i?"opacity-100":"opacity-0"}`,children:e.jsx(Ls,{packets:n,rangeMinutes:r.minutes,bucketCount:r.buckets})})]})]})}),e.jsxs(ie,{template:"compact",children:[e.jsx(re,{span:6,lg:4,children:e.jsx(Es,{value:y.forwarded,receivedCount:y.received,packets:n,rangeMinutes:r.minutes,bucketCount:r.buckets,timeRangeLabel:r.label,icon:e.jsx(ms,{className:"w-4 h-4"}),isLoaded:i})}),e.jsx(re,{span:6,lg:4,children:e.jsx(Is,{value:y.dropped,receivedCount:y.received,packets:n,rangeMinutes:r.minutes,bucketCount:r.buckets,timeRangeLabel:r.label,icon:e.jsx(Zt,{className:"w-4 h-4"}),isLoaded:i})}),e.jsx(re,{span:12,lg:4,children:e.jsx(Xs,{stats:t,localHash:t==null?void 0:t.local_hash,receivedBuckets:h==null?void 0:h.received,droppedBuckets:h==null?void 0:h.dropped,forwardedBuckets:h==null?void 0:h.forwarded,bucketDurationSeconds:h==null?void 0:h.bucket_duration_seconds,timeRangeLabel:r.label,isLoaded:i})})]}),e.jsx(Sn,{isLoaded:i}),e.jsx(Ks,{}),t&&e.jsx(ie,{template:"auto",children:e.jsx(as,{nodeName:k,repeaterVersion:t.version,coreVersion:t.core_version,localHash:t.local_hash,publicKey:t.public_key})})]})]})}export{pa as default}; diff --git a/frontend/dist/assets/DataBox-W2v3wy8k.js b/frontend/dist/assets/DataBox-CQS-Zhu0.js similarity index 97% rename from frontend/dist/assets/DataBox-W2v3wy8k.js rename to frontend/dist/assets/DataBox-CQS-Zhu0.js index 43af769a..237e59ef 100644 --- a/frontend/dist/assets/DataBox-W2v3wy8k.js +++ b/frontend/dist/assets/DataBox-CQS-Zhu0.js @@ -1 +1 @@ -import{r as u,j as a,c as r,w as T,x as N}from"./index-C8IY8K2r.js";const E={standard:"w-3 h-3",compact:"w-2.5 h-2.5",responsive:"w-2.5 h-2.5 sm:w-3 sm:h-3"};function k(t){var s;if(typeof window<"u"&&(window.isSecureContext||window.location.protocol==="https:"||window.location.hostname==="localhost")&&((s=navigator.clipboard)!=null&&s.writeText))return navigator.clipboard.writeText(t).catch(()=>{}),!0;try{const{scrollX:o,scrollY:i}=window,e=document.createElement("textarea");e.value=t,e.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0;pointer-events:none",e.setAttribute("readonly",""),document.body.appendChild(e),e.focus({preventScroll:!0}),e.select(),e.setSelectionRange(0,t.length);const l=document.execCommand("copy");return document.body.removeChild(e),window.scrollTo(o,i),l}catch(o){return console.error("Copy failed:",o),!1}}function $({children:t,copyValue:x,copy:s=!1,size:o="standard",className:i,title:e,color:l,truncate:d}){const[m,y]=u.useState(!1),[S,w]=u.useState(!1),f=u.useRef(null),c=x??(typeof t=="string"?t:""),C=E[o],h=(()=>{if(!d||typeof t!="string")return t;const n=t,[p,g]=d===!0?[6,4]:d;return n.length<=p+g+3?n:`${n.slice(0,p)}…${n.slice(-g)}`})(),j=u.useCallback(n=>{if(!s)return;n.preventDefault(),n.stopPropagation(),f.current&&clearTimeout(f.current);const p=k(c);y(!0),f.current=setTimeout(()=>y(!1),2e3),p||console.warn("Copy may have failed for:",c.slice(0,16)+"...")},[s,c]),v=o==="compact"?"data-box-compact":o==="responsive"?"data-box-responsive":"",b=s?e||`Click to copy: ${c}`:e;return s?a.jsxs("button",{type:"button",onClick:j,onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1),className:r("data-box interactive",v,"cursor-pointer select-none gap-1","hover-bg",l,i),title:b,"aria-label":`Copy ${c}`,children:[a.jsx("span",{className:r("transition-colors duration-200",m?"text-sys-green":""),children:h}),a.jsx("span",{className:r("flex items-center justify-center",o==="compact"?"w-3 h-3":"w-3.5 h-3.5"),children:m?a.jsx(T,{className:r("text-sys-green",C)}):a.jsx(N,{className:r("transition-opacity duration-200",S?"opacity-70":"opacity-40",C)})})]}):a.jsx("span",{className:r("data-box",v,l,i),title:b,children:h})}export{$ as D}; +import{r as u,j as a,c as r,w as T,x as N}from"./index-BwGHI0A_.js";const E={standard:"w-3 h-3",compact:"w-2.5 h-2.5",responsive:"w-2.5 h-2.5 sm:w-3 sm:h-3"};function k(t){var s;if(typeof window<"u"&&(window.isSecureContext||window.location.protocol==="https:"||window.location.hostname==="localhost")&&((s=navigator.clipboard)!=null&&s.writeText))return navigator.clipboard.writeText(t).catch(()=>{}),!0;try{const{scrollX:o,scrollY:i}=window,e=document.createElement("textarea");e.value=t,e.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0;pointer-events:none",e.setAttribute("readonly",""),document.body.appendChild(e),e.focus({preventScroll:!0}),e.select(),e.setSelectionRange(0,t.length);const l=document.execCommand("copy");return document.body.removeChild(e),window.scrollTo(o,i),l}catch(o){return console.error("Copy failed:",o),!1}}function $({children:t,copyValue:x,copy:s=!1,size:o="standard",className:i,title:e,color:l,truncate:d}){const[m,y]=u.useState(!1),[S,w]=u.useState(!1),f=u.useRef(null),c=x??(typeof t=="string"?t:""),C=E[o],h=(()=>{if(!d||typeof t!="string")return t;const n=t,[p,g]=d===!0?[6,4]:d;return n.length<=p+g+3?n:`${n.slice(0,p)}…${n.slice(-g)}`})(),j=u.useCallback(n=>{if(!s)return;n.preventDefault(),n.stopPropagation(),f.current&&clearTimeout(f.current);const p=k(c);y(!0),f.current=setTimeout(()=>y(!1),2e3),p||console.warn("Copy may have failed for:",c.slice(0,16)+"...")},[s,c]),v=o==="compact"?"data-box-compact":o==="responsive"?"data-box-responsive":"",b=s?e||`Click to copy: ${c}`:e;return s?a.jsxs("button",{type:"button",onClick:j,onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1),className:r("data-box interactive",v,"cursor-pointer select-none gap-1","hover-bg",l,i),title:b,"aria-label":`Copy ${c}`,children:[a.jsx("span",{className:r("transition-colors duration-200",m?"text-sys-green":""),children:h}),a.jsx("span",{className:r("flex items-center justify-center",o==="compact"?"w-3 h-3":"w-3.5 h-3.5"),children:m?a.jsx(T,{className:r("text-sys-green",C)}):a.jsx(N,{className:r("transition-opacity duration-200",S?"opacity-70":"opacity-40",C)})})]}):a.jsx("span",{className:r("data-box",v,l,i),title:b,children:h})}export{$ as D}; diff --git a/frontend/dist/assets/DeepAnalysisModal-B2m7JxOp.js b/frontend/dist/assets/DeepAnalysisModal-CaP_TRSd.js similarity index 78% rename from frontend/dist/assets/DeepAnalysisModal-B2m7JxOp.js rename to frontend/dist/assets/DeepAnalysisModal-CaP_TRSd.js index bcb8310b..85958e80 100644 --- a/frontend/dist/assets/DeepAnalysisModal-B2m7JxOp.js +++ b/frontend/dist/assets/DeepAnalysisModal-CaP_TRSd.js @@ -1,31 +1,31 @@ -import{d as b,bf as G,ds as q,dt as D,r as M,bN as F,fR as P,fS as W,j as f,ac as $,fT as B,ad as H,m as Y,w as L,c as w,L as U}from"./index-C8IY8K2r.js";import{c as R}from"./geo-utils-BP1zBK9h.js";import{D as K}from"./download-IUkhheKK.js";import{D as X}from"./database-BEyHF_p_.js";/** +import{d as b,bf as G,dx as q,dy as D,cL as L,r as M,bQ as F,fY as P,fZ as W,j as f,ac as $,f_ as B,ad as Y,m as H,w as R,c as w,L as U}from"./index-BwGHI0A_.js";import{D as K}from"./download-BbqYTv8j.js";import{D as X}from"./database-CDN_R6oC.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 Z=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Se=b("eye-off",Z);/** + */const Z=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Ie=b("eye-off",Z);/** * @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 J=[["path",{d:"M9 10h.01",key:"qbtxuw"}],["path",{d:"M15 10h.01",key:"1qmjsl"}],["path",{d:"M12 2a8 8 0 0 0-8 8v12l3-3 2.5 2.5L12 19l2.5 2.5L17 19l3 3V10a8 8 0 0 0-8-8z",key:"uwwb07"}]],Q=b("ghost",J);/** + */const Q=[["path",{d:"M9 10h.01",key:"qbtxuw"}],["path",{d:"M15 10h.01",key:"1qmjsl"}],["path",{d:"M12 2a8 8 0 0 0-8 8v12l3-3 2.5 2.5L12 19l2.5 2.5L17 19l3 3V10a8 8 0 0 0-8-8z",key:"uwwb07"}]],J=b("ghost",Q);/** * @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 ee=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],C=b("git-branch",ee);/** + */const ee=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],_=b("git-branch",ee);/** * @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 te=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],Ae=b("grip-vertical",te);/** + */const te=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],Se=b("grip-vertical",te);/** * @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 ne=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],De=b("maximize-2",ne);/** + */const ne=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],Ae=b("maximize-2",ne);/** * @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 ie=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],Le=b("minimize-2",ie);class se{constructor(){this.componentControls=new Set}subscribe(e){return this.componentControls.add(e),()=>this.componentControls.delete(e)}start(e,t){this.componentControls.forEach(i=>{i.start(e.nativeEvent||e,t)})}cancel(){this.componentControls.forEach(e=>{e.cancel()})}stop(){this.componentControls.forEach(e=>{e.stop()})}}const oe=()=>new se;function Re(){return G(oe)}const ce={hidden:{opacity:0,scale:.9},visible:{opacity:1,scale:1,transition:{type:"spring",stiffness:400,damping:15}},exit:{opacity:0,scale:.9,transition:{duration:D.fast}}},Oe={hidden:{opacity:0,y:"100%"},visible:{opacity:1,y:0,transition:{type:"spring",stiffness:400,damping:30}},exit:{opacity:0,y:"100%",transition:{duration:D.medium,ease:q.easeIn}}},re=1e-8,ae=100,E=3,le=4,k=5,fe=20,ue=.001,_=.3,me=30,de=.05,he=.7,T=.3;function N(n,e){let t=0;for(let i=0;i0)for(let t=0;t[a,r])),l=Array(o).fill(null).map(()=>Array(o).fill(0));for(const a of n){const r=c.get(a.fromHash),s=c.get(a.toHash);if(r!==void 0&&s!==void 0&&r!==s){const m=a.strength*a.certainCount;let u=1;if(t){const y=t.get(a.fromHash),x=t.get(a.toHash);if(y&&x){const V=R(y[0],y[1],x[0],x[1])/1e3;u=ye(V)}}let d=1;if(i){const y=[a.fromHash,a.toHash].sort().join("-");d=1-(i.get(y)??0)*he}const h=a.symmetryRatio??0,p=T+(1-T)*h,g=Math.pow(m,1-_)*Math.pow(u,_)*d*p;l[r][s]=g,l[s][r]=g}}return l}function O(n){const e=n.length,t=Array(e).fill(null).map(()=>Array(e).fill(0));for(let i=0;iArray(e).fill(0));for(let r=0;rMath.sin(s*12.9898)*43758.5453%1-.5);S(c,t),I(c);let l=0;for(let r=0;r=n.length)return n;const t=[],i=n.length/e;for(let o=0;oc.has(h.fromHash)&&c.has(h.toHash));if(l.length===0)return null;const a=xe(l,e,t,i),r=O(a),{vector:s,eigenvalue:m}=z(r);if(m({hash:u,community:0,fiedlerValue:0})),numCommunities:1,fiedlerValue:0,isConnected:o<=1};const c=[];let l=1/0;const a=[[e,0]];for(;a.length>0;){const[u,d]=a.shift();if((t?be(u,t):0)>fe&&d=k*2){const g=je(n,u,t,i);if(g){l=Math.min(l,g.fiedlerValue),a.push([g.group0,d+1]),a.push([g.group1,d+1]);continue}}c.push(u)}const r=new Map,s=[],m=new Map;for(let u=0;u[a,r])),o=Array(t).fill(null).map(()=>Array(t).fill(0));for(const a of n){const r=i.get(a.fromHash),s=i.get(a.toHash);r!==void 0&&s!==void 0&&r!==s&&(o[r][s]=1,o[s][r]=1)}const c=O(o),{eigenvalue:l}=z(c);return Math.max(0,l)}function qe(n){const e=["rgba(139, 92, 246, 0.6)","rgba(16, 185, 129, 0.6)","rgba(245, 158, 11, 0.6)","rgba(239, 68, 68, 0.6)","rgba(59, 130, 246, 0.6)","rgba(236, 72, 153, 0.6)","rgba(20, 184, 166, 0.6)","rgba(249, 115, 22, 0.6)"];return e[n%e.length]}function Fe(n,e){let t,i;if(e===void 0)for(const o of n)o!=null&&(t===void 0?o>=o&&(t=i=o):(t>o&&(t=o),i=c&&(t=i=c):(t>c&&(t=c),i=Ne?10:c>=ve?5:c>=we?2:1;let a,r,s;return o<0?(s=Math.pow(10,-o)/l,a=Math.round(n*s),r=Math.round(e*s),a/se&&--r,s=-s):(s=Math.pow(10,o)*l,a=Math.round(n/s),r=Math.round(e/s),a*se&&--r),r0))return[];if(n===e)return[n];const i=e=o))return[];const a=c-o+1,r=new Array(a);if(i)if(l<0)for(let s=0;s=i)&&(t=i);return t}function j({label:n,icon:e,status:t,detail:i}){return f.jsxs("div",{className:w("flex items-center gap-3 py-3 px-4 radius-inset transition-base",t==="active"&&"bg-sys-blue/10",t==="complete"&&"bg-sys-blue/10 ring-2 ring-inset ring-sys-blue",t==="pending"&&"opacity-40"),children:[f.jsx("div",{className:w("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 transition-all duration-300",t==="active"&&"bg-sys-blue/20",t==="complete"&&"bg-sys-blue/20",t==="pending"&&"bg-subtle-fill"),children:t==="complete"?f.jsx(L,{className:"w-4 h-4 text-sys-blue"}):t==="active"?f.jsx(U,{className:"w-4 h-4 animate-spin text-sys-blue"}):f.jsx("span",{className:"text-fg-muted",children:e})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("div",{className:w("text-sm font-medium transition-colors",t==="active"&&"text-sys-blue",t==="complete"&&"text-sys-blue",t==="pending"&&"text-fg-muted"),children:n}),i&&t!=="pending"&&f.jsx("div",{className:"text-xs text-fg-muted mt-0.5 truncate",children:i})]})]})}function ke({isOpen:n,onClose:e}){const{packetCacheState:t,triggerDeepAnalysis:i}=F(),o=P(),c=W(),l=t.packetCount,[a,r]=M.useState("fetching");M.useEffect(()=>{n&&i()},[n,i]),M.useEffect(()=>{if(n){if(t.isTopologyLoading)r("fetching");else if(o)r("analyzing"),setTimeout(()=>r("building"),500),setTimeout(()=>r("discovering"),1e3);else if(c>0&&!t.isTopologyLoading){r("complete");const p=setTimeout(()=>{e()},1500);return()=>clearTimeout(p)}}},[n,t.isTopologyLoading,o,c,e]);const s=a==="complete",m=t.loadProgress,u=M.useMemo(()=>{if(m&&m.target>0){const p=(m.loaded/1e3).toFixed(1),g=(m.target/1e3).toFixed(1);return`Loading... ${p}k / ${g}k packets (${m.percent}%)`}return l>0?`${l.toLocaleString()} packets loaded`:"Connecting to database..."},[m,l]),d=p=>{const g=["fetching","analyzing","building","discovering","complete"],y=g.indexOf(a),x=g.indexOf(p);return x{};return f.jsx($,{open:n,onClose:h,size:"sm",bottomSheet:!1,children:f.jsx(B,{isLoading:!s,borderRadius:16,children:f.jsx(H,{className:"p-6 radius-card overflow-hidden",children:s?f.jsxs("div",{className:"flex flex-col items-center py-6",children:[f.jsx(Y.div,{variants:ce,initial:"hidden",animate:"visible",className:"w-16 h-16 rounded-full flex items-center justify-center mb-4 bg-sys-blue/20",children:f.jsx(L,{className:"w-8 h-8 text-sys-blue"})}),f.jsx("h3",{className:"type-micro text-sys-blue",children:"Ready!"}),f.jsx("button",{onClick:e,className:"mt-3 sm:hidden min-h-[44px] min-w-[44px] px-4 flex items-center justify-center text-[15px] font-medium text-sys-blue active:text-sys-blue/70 transition-base radius-inner active:bg-subtle-fill",children:"Done"})]}):f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[f.jsx("div",{className:"w-10 h-10 radius-inset flex items-center justify-center bg-sys-blue/15",children:f.jsx(C,{className:"w-5 h-5 text-sys-blue"})}),f.jsxs("div",{children:[f.jsx("h3",{className:"type-micro",children:"Deep Analysis"}),f.jsx("p",{className:"text-xs text-fg-muted",children:"Building mesh topology"})]})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(j,{label:"Fetching Packets",icon:f.jsx(K,{className:"w-4 h-4"}),status:d("fetching"),detail:u}),f.jsx(j,{label:"Analyzing Database",icon:f.jsx(X,{className:"w-4 h-4"}),status:d("analyzing"),detail:"Processing packet paths"}),f.jsx(j,{label:"Building Topology",icon:f.jsx(C,{className:"w-4 h-4"}),status:d("building"),detail:"Computing mesh edges"}),f.jsx(j,{label:"Discovering Nodes",icon:f.jsx(Q,{className:"w-4 h-4"}),status:d("discovering"),detail:"Viterbi HMM ghost detection"})]}),f.jsx("p",{className:"text-xs text-fg-muted text-center mt-5",children:"This may take a few seconds..."})]})})})})}const Be=M.memo(ke);export{Be as D,Se as E,Ae as G,De as M,Pe as a,A as b,Ge as c,Le as d,Fe as e,Q as f,C as g,qe as h,Ve as i,ze as j,$e as m,Oe as s,We as t,Re as u}; + */const ie=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],De=b("minimize-2",ie);class se{constructor(){this.componentControls=new Set}subscribe(e){return this.componentControls.add(e),()=>this.componentControls.delete(e)}start(e,t){this.componentControls.forEach(i=>{i.start(e.nativeEvent||e,t)})}cancel(){this.componentControls.forEach(e=>{e.cancel()})}stop(){this.componentControls.forEach(e=>{e.stop()})}}const oe=()=>new se;function Le(){return G(oe)}const ce={hidden:{opacity:0,scale:.9},visible:{opacity:1,scale:1,transition:{type:"spring",stiffness:400,damping:15}},exit:{opacity:0,scale:.9,transition:{duration:D.fast}}},Re={hidden:{opacity:0,y:"100%"},visible:{opacity:1,y:0,transition:{type:"spring",stiffness:400,damping:30}},exit:{opacity:0,y:"100%",transition:{duration:D.medium,ease:q.easeIn}}},re=1e-8,ae=100,E=3,le=4,k=5,fe=20,ue=.001,C=.3,me=30,de=.05,he=.7,T=.3;function v(n,e){let t=0;for(let i=0;i0)for(let t=0;t[a,r])),l=Array(o).fill(null).map(()=>Array(o).fill(0));for(const a of n){const r=c.get(a.fromHash),s=c.get(a.toHash);if(r!==void 0&&s!==void 0&&r!==s){const m=a.strength*a.certainCount;let u=1;if(t){const y=t.get(a.fromHash),x=t.get(a.toHash);if(y&&x){const V=L(y[0],y[1],x[0],x[1])/1e3;u=ye(V)}}let d=1;if(i){const y=[a.fromHash,a.toHash].sort().join("-");d=1-(i.get(y)??0)*he}const h=a.symmetryRatio??0,p=T+(1-T)*h,g=Math.pow(m,1-C)*Math.pow(u,C)*d*p;l[r][s]=g,l[s][r]=g}}return l}function O(n){const e=n.length,t=Array(e).fill(null).map(()=>Array(e).fill(0));for(let i=0;iArray(e).fill(0));for(let r=0;rMath.sin(s*12.9898)*43758.5453%1-.5);S(c,t),I(c);let l=0;for(let r=0;r=n.length)return n;const t=[],i=n.length/e;for(let o=0;oc.has(h.fromHash)&&c.has(h.toHash));if(l.length===0)return null;const a=xe(l,e,t,i),r=O(a),{vector:s,eigenvalue:m}=z(r);if(m({hash:u,community:0,fiedlerValue:0})),numCommunities:1,fiedlerValue:0,isConnected:o<=1};const c=[];let l=1/0;const a=[[e,0]];for(;a.length>0;){const[u,d]=a.shift();if((t?be(u,t):0)>fe&&d=k*2){const g=je(n,u,t,i);if(g){l=Math.min(l,g.fiedlerValue),a.push([g.group0,d+1]),a.push([g.group1,d+1]);continue}}c.push(u)}const r=new Map,s=[],m=new Map;for(let u=0;u[a,r])),o=Array(t).fill(null).map(()=>Array(t).fill(0));for(const a of n){const r=i.get(a.fromHash),s=i.get(a.toHash);r!==void 0&&s!==void 0&&r!==s&&(o[r][s]=1,o[s][r]=1)}const c=O(o),{eigenvalue:l}=z(c);return Math.max(0,l)}function Ge(n){const e=["rgba(139, 92, 246, 0.6)","rgba(16, 185, 129, 0.6)","rgba(245, 158, 11, 0.6)","rgba(239, 68, 68, 0.6)","rgba(59, 130, 246, 0.6)","rgba(236, 72, 153, 0.6)","rgba(20, 184, 166, 0.6)","rgba(249, 115, 22, 0.6)"];return e[n%e.length]}function qe(n,e){let t,i;if(e===void 0)for(const o of n)o!=null&&(t===void 0?o>=o&&(t=i=o):(t>o&&(t=o),i=c&&(t=i=c):(t>c&&(t=c),i=ve?10:c>=Ne?5:c>=we?2:1;let a,r,s;return o<0?(s=Math.pow(10,-o)/l,a=Math.round(n*s),r=Math.round(e*s),a/se&&--r,s=-s):(s=Math.pow(10,o)*l,a=Math.round(n/s),r=Math.round(e/s),a*se&&--r),r0))return[];if(n===e)return[n];const i=e=o))return[];const a=c-o+1,r=new Array(a);if(i)if(l<0)for(let s=0;s=i)&&(t=i);return t}function j({label:n,icon:e,status:t,detail:i}){return f.jsxs("div",{className:w("flex items-center gap-3 py-3 px-4 radius-inset transition-base",t==="active"&&"bg-sys-blue/10",t==="complete"&&"bg-sys-blue/10 ring-2 ring-inset ring-sys-blue",t==="pending"&&"opacity-40"),children:[f.jsx("div",{className:w("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 transition-all duration-300",t==="active"&&"bg-sys-blue/20",t==="complete"&&"bg-sys-blue/20",t==="pending"&&"bg-subtle-fill"),children:t==="complete"?f.jsx(R,{className:"w-4 h-4 text-sys-blue"}):t==="active"?f.jsx(U,{className:"w-4 h-4 animate-spin text-sys-blue"}):f.jsx("span",{className:"text-fg-muted",children:e})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("div",{className:w("text-sm font-medium transition-colors",t==="active"&&"text-sys-blue",t==="complete"&&"text-sys-blue",t==="pending"&&"text-fg-muted"),children:n}),i&&t!=="pending"&&f.jsx("div",{className:"text-xs text-fg-muted mt-0.5 truncate",children:i})]})]})}function ke({isOpen:n,onClose:e}){const{packetCacheState:t,triggerDeepAnalysis:i}=F(),o=P(),c=W(),l=t.packetCount,[a,r]=M.useState("fetching");M.useEffect(()=>{n&&i()},[n,i]),M.useEffect(()=>{if(n){if(t.isTopologyLoading)r("fetching");else if(o)r("analyzing"),setTimeout(()=>r("building"),500),setTimeout(()=>r("discovering"),1e3);else if(c>0&&!t.isTopologyLoading){r("complete");const p=setTimeout(()=>{e()},1500);return()=>clearTimeout(p)}}},[n,t.isTopologyLoading,o,c,e]);const s=a==="complete",m=t.loadProgress,u=M.useMemo(()=>{if(m&&m.target>0){const p=(m.loaded/1e3).toFixed(1),g=(m.target/1e3).toFixed(1);return`Loading... ${p}k / ${g}k packets (${m.percent}%)`}return l>0?`${l.toLocaleString()} packets loaded`:"Connecting to database..."},[m,l]),d=p=>{const g=["fetching","analyzing","building","discovering","complete"],y=g.indexOf(a),x=g.indexOf(p);return x{};return f.jsx($,{open:n,onClose:h,size:"sm",bottomSheet:!1,children:f.jsx(B,{isLoading:!s,borderRadius:16,children:f.jsx(Y,{className:"p-6 radius-card overflow-hidden",children:s?f.jsxs("div",{className:"flex flex-col items-center py-6",children:[f.jsx(H.div,{variants:ce,initial:"hidden",animate:"visible",className:"w-16 h-16 rounded-full flex items-center justify-center mb-4 bg-sys-blue/20",children:f.jsx(R,{className:"w-8 h-8 text-sys-blue"})}),f.jsx("h3",{className:"type-micro text-sys-blue",children:"Ready!"}),f.jsx("button",{onClick:e,className:"mt-3 sm:hidden min-h-[44px] min-w-[44px] px-4 flex items-center justify-center text-[15px] font-medium text-sys-blue active:text-sys-blue/70 transition-base radius-inner active:bg-subtle-fill",children:"Done"})]}):f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[f.jsx("div",{className:"w-10 h-10 radius-inset flex items-center justify-center bg-sys-blue/15",children:f.jsx(_,{className:"w-5 h-5 text-sys-blue"})}),f.jsxs("div",{children:[f.jsx("h3",{className:"type-micro",children:"Deep Analysis"}),f.jsx("p",{className:"text-xs text-fg-muted",children:"Building mesh topology"})]})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx(j,{label:"Fetching Packets",icon:f.jsx(K,{className:"w-4 h-4"}),status:d("fetching"),detail:u}),f.jsx(j,{label:"Analyzing Database",icon:f.jsx(X,{className:"w-4 h-4"}),status:d("analyzing"),detail:"Processing packet paths"}),f.jsx(j,{label:"Building Topology",icon:f.jsx(_,{className:"w-4 h-4"}),status:d("building"),detail:"Computing mesh edges"}),f.jsx(j,{label:"Discovering Nodes",icon:f.jsx(J,{className:"w-4 h-4"}),status:d("discovering"),detail:"Viterbi HMM ghost detection"})]}),f.jsx("p",{className:"text-xs text-fg-muted text-center mt-5",children:"This may take a few seconds..."})]})})})})}const $e=M.memo(ke);export{$e as D,Ie as E,Se as G,Ae as M,Fe as a,A as b,Ve as c,De as d,qe as e,J as f,_ as g,Ge as h,ze as i,Oe as j,We as m,Re as s,Pe as t,Le as u}; diff --git a/frontend/dist/assets/Grid-CEGkNRmt.js b/frontend/dist/assets/Grid-BoZ-SJB7.js similarity index 95% rename from frontend/dist/assets/Grid-CEGkNRmt.js rename to frontend/dist/assets/Grid-BoZ-SJB7.js index 5a24f980..ff7598a9 100644 --- a/frontend/dist/assets/Grid-CEGkNRmt.js +++ b/frontend/dist/assets/Grid-BoZ-SJB7.js @@ -1 +1 @@ -import{r as b,j as c,c as d}from"./index-C8IY8K2r.js";const g={hero:{mobile:12},"hero-tall":{mobile:12},"hero-auto":{mobile:12},panel:{mobile:12,md:6},feature:{mobile:12,md:6,lg:4},standard:{mobile:12,sm:6,lg:4,xl:3},compact:{mobile:6,lg:3},widget:{mobile:6,sm:4,md:3,lg:2},auto:{mobile:12}},p={hero:"bento-row-hero","hero-tall":"bento-row-hero-tall","hero-auto":"bento-row-hero-auto",panel:"bento-row-panel",feature:"bento-row-feature",standard:"bento-row-standard",compact:"bento-row-compact",widget:"bento-row-widget",auto:"bento-row-auto"};function w({template:o,children:r,className:e,gap:n}){const t=g[o],m=p[o],a=n==="none"?"gap-0":n==="sm"?"bento-gap-sm":n==="lg"?"bento-gap-lg":"bento-gap",i=b.Children.map(r,l=>!b.isValidElement(l)||l.type===u?l:c.jsx(u,{span:t.mobile,sm:t.sm,md:t.md,lg:t.lg,xl:t.xl,children:l}));return c.jsx("div",{className:d("bento-row",m,a,e),children:i})}function s(o,r=""){const e=r?`${r}:`:"";return o==="full"?`${e}col-span-full`:o==="auto"?`${e}col-auto`:o===1.5?`${e}bento-col-1-5`:`${e}bento-col-${o}`}function u({children:o,span:r,sm:e,md:n,lg:t,xl:m,ratio:a,className:i}){const l=d("bento-cell",s(r),e&&s(e,"sm"),n&&s(n,"md"),t&&s(t,"lg"),m&&s(m,"xl"),i);return c.jsx("div",{className:l,"data-ratio":a??void 0,style:a?{"--cell-ratio":a}:void 0,children:o})}export{u as C,w as R}; +import{r as b,j as c,c as d}from"./index-BwGHI0A_.js";const g={hero:{mobile:12},"hero-tall":{mobile:12},"hero-auto":{mobile:12},panel:{mobile:12,md:6},feature:{mobile:12,md:6,lg:4},standard:{mobile:12,sm:6,lg:4,xl:3},compact:{mobile:6,lg:3},widget:{mobile:6,sm:4,md:3,lg:2},auto:{mobile:12}},p={hero:"bento-row-hero","hero-tall":"bento-row-hero-tall","hero-auto":"bento-row-hero-auto",panel:"bento-row-panel",feature:"bento-row-feature",standard:"bento-row-standard",compact:"bento-row-compact",widget:"bento-row-widget",auto:"bento-row-auto"};function w({template:o,children:r,className:e,gap:n}){const t=g[o],m=p[o],a=n==="none"?"gap-0":n==="sm"?"bento-gap-sm":n==="lg"?"bento-gap-lg":"bento-gap",i=b.Children.map(r,l=>!b.isValidElement(l)||l.type===u?l:c.jsx(u,{span:t.mobile,sm:t.sm,md:t.md,lg:t.lg,xl:t.xl,children:l}));return c.jsx("div",{className:d("bento-row",m,a,e),children:i})}function s(o,r=""){const e=r?`${r}:`:"";return o==="full"?`${e}col-span-full`:o==="auto"?`${e}col-auto`:o===1.5?`${e}bento-col-1-5`:`${e}bento-col-${o}`}function u({children:o,span:r,sm:e,md:n,lg:t,xl:m,ratio:a,className:i}){const l=d("bento-cell",s(r),e&&s(e,"sm"),n&&s(n,"md"),t&&s(t,"lg"),m&&s(m,"xl"),i);return c.jsx("div",{className:l,"data-ratio":a??void 0,style:a?{"--cell-ratio":a}:void 0,children:o})}export{u as C,w as R}; diff --git a/frontend/dist/assets/KeycapButton-BJvlGsWZ.js b/frontend/dist/assets/KeycapButton-CT5jwzf3.js similarity index 98% rename from frontend/dist/assets/KeycapButton-BJvlGsWZ.js rename to frontend/dist/assets/KeycapButton-CT5jwzf3.js index 69a0f55b..d4f753c1 100644 --- a/frontend/dist/assets/KeycapButton-BJvlGsWZ.js +++ b/frontend/dist/assets/KeycapButton-CT5jwzf3.js @@ -1 +1 @@ -import{r as l,j as t,Z as O}from"./index-C8IY8K2r.js";import{b as F,c as x}from"./keycap-sfx-ByZp-njj.js";const R={a:"24,3 76,3 83,7 76,11 24,11 17,7",b:"88,22 93,27 93,71 88,76 83,71 83,27",c:"88,106 93,111 93,155 88,160 83,155 83,111",d:"24,171 76,171 83,175 76,179 24,179 17,175",e:"12,106 17,111 17,155 12,160 7,155 7,111",f:"12,22 17,27 17,71 12,76 7,71 7,27",g:"24,86 76,86 83,91 76,96 24,96 17,91"},w=Object.keys(R),N={0:"abcdef",1:"bc",2:"abdeg",3:"abcdg",4:"bcfg",5:"acdfg",6:"acdefg",7:"abc",8:"abcdefg",9:"abcdfg",A:"abcefg",B:"cdefg",C:"adef",D:"bcdeg",E:"adefg",F:"aefg",G:"acdef",H:"bcefg",I:"ef",J:"bcde",L:"def",M:"abcefg",N:"ceg",O:"abcdef",P:"abefg",Q:"abcfg",R:"eg",S:"acdfg",T:"defg",U:"bcdef",V:"cde",Y:"bcdfg",Z:"abdeg",a:"abcefg",b:"cdefg",c:"deg",d:"bcdeg",e:"adefg",f:"aefg",g:"abcdfg",h:"cefg",i:"c",j:"bcde",l:"def",m:"abcef",n:"ceg",o:"cdeg",p:"abefg",r:"eg",s:"acdfg",t:"defg",u:"cde",v:"cde",y:"bcdfg"," ":"",_:"d","-":"g","=":"dg","°":"abfg",'"':"bf","'":"f","(":"adef",")":"abcd","[":"adef","]":"abcd","!":"bc",".":"d"},C=6,D=56,L=2;function B(){return w.filter(()=>Math.random()>.45).join("")}function $(r,i){const n=Array.from(r).map(a=>N[a.toUpperCase()]??N[a]??""),d=Math.max(0,(i??0)-r.length);for(let a=0;a{if(a)return;const e=$(r,d),o=e.length,g=C+(o-1)*L;let y=0,b,E=!1;const k=()=>{if(!E){if(y++,y>=g){f(null);return}f(e.map((j,_)=>{const v=C+_*L;return y>=v?j:B()})),b=setTimeout(k,D)}};return k(),()=>{E=!0,clearTimeout(b)}},[r,d,a]);const c=(e,o)=>t.jsx("svg",{viewBox:"0 0 100 182",width:h,height:n,className:"seven-seg__char","aria-hidden":"true",children:w.map(g=>t.jsx("polygon",{points:R[g],fill:i,stroke:i,strokeWidth:4,strokeLinejoin:"round",opacity:e.includes(g)?1:M},g))},o),s=$(r,d),u=T??s;return t.jsxs("span",{className:`seven-seg${S?` ${S}`:""}`,children:[u.map((e,o)=>c(e,`${o}-${e}`)),t.jsx("span",{className:"sr-only",children:r})]})}const G={grey:"/assets/keycap.svg",red:"/assets/keycap-red.svg"},I=O[900],P="#FFDEB0";function Z({icon:r,variant:i="grey",onClick:n,onPress:d,sentDuration:a=2e3,title:S,disabled:h=!1,className:m,iconColor:M=I,iconActiveColor:T=P,indicators:f}){const c=!!d,[s,u]=l.useState("idle"),[e,o]=l.useState(!1),g=l.useRef(),y=c?s==="held":e,b=c&&(s==="sending"||s==="sent"),E=c?s==="held"||s==="sending":e;l.useEffect(()=>()=>clearTimeout(g.current),[]);const k=l.useCallback(()=>{h||b||(F(),c?u("held"):o(!0))},[h,b,c]),j=l.useCallback(async()=>{if(c){if(s!=="held")return;x(),u("sending");const p=await d();u(p?"sent":"idle"),p&&(g.current=setTimeout(()=>u("idle"),a))}else{if(!e)return;o(!1),x(),n==null||n()}},[c,s,d,a,e,n]),_=l.useCallback(()=>{c?s==="held"&&(x(),u("idle")):(e&&x(),o(!1))},[c,s,e]),v=t.jsx("button",{onMouseDown:k,onMouseUp:j,onMouseLeave:_,onTouchStart:k,onTouchEnd:j,onTouchCancel:_,disabled:h||b,className:`keycap-btn${i==="red"?" keycap-btn--red-cap":""}${E?" keycap-btn--pressed":""}${m&&!f?` ${m}`:""}`,title:S,children:t.jsxs("div",{className:"keycap-wrap",children:[t.jsx("img",{src:G[i],alt:"",className:"keycap-btn__img",draggable:!1}),t.jsx("span",{className:"keycap-icon-overlay",style:{color:y||s==="sending"?T:M},children:r})]})});return f!=null&&f.length?t.jsxs("div",{className:`keycap-group${m?` ${m}`:""}`,children:[v,t.jsx("div",{className:"indicator-key-pair",children:f.map(p=>{const A=p.trackPress?s:p.active?"active":"idle";return t.jsxs("div",{className:`indicator-key${A!=="idle"?` indicator-key--${A}`:""}`,children:[t.jsx("span",{className:"indicator-key__label",children:p.label}),t.jsx("span",{className:"indicator-key__led"})]},p.label)})})]}):v}export{Z as K,Y as S}; +import{r as l,j as t,Z as O}from"./index-BwGHI0A_.js";import{b as F,c as x}from"./keycap-sfx-ByZp-njj.js";const R={a:"24,3 76,3 83,7 76,11 24,11 17,7",b:"88,22 93,27 93,71 88,76 83,71 83,27",c:"88,106 93,111 93,155 88,160 83,155 83,111",d:"24,171 76,171 83,175 76,179 24,179 17,175",e:"12,106 17,111 17,155 12,160 7,155 7,111",f:"12,22 17,27 17,71 12,76 7,71 7,27",g:"24,86 76,86 83,91 76,96 24,96 17,91"},w=Object.keys(R),N={0:"abcdef",1:"bc",2:"abdeg",3:"abcdg",4:"bcfg",5:"acdfg",6:"acdefg",7:"abc",8:"abcdefg",9:"abcdfg",A:"abcefg",B:"cdefg",C:"adef",D:"bcdeg",E:"adefg",F:"aefg",G:"acdef",H:"bcefg",I:"ef",J:"bcde",L:"def",M:"abcefg",N:"ceg",O:"abcdef",P:"abefg",Q:"abcfg",R:"eg",S:"acdfg",T:"defg",U:"bcdef",V:"cde",Y:"bcdfg",Z:"abdeg",a:"abcefg",b:"cdefg",c:"deg",d:"bcdeg",e:"adefg",f:"aefg",g:"abcdfg",h:"cefg",i:"c",j:"bcde",l:"def",m:"abcef",n:"ceg",o:"cdeg",p:"abefg",r:"eg",s:"acdfg",t:"defg",u:"cde",v:"cde",y:"bcdfg"," ":"",_:"d","-":"g","=":"dg","°":"abfg",'"':"bf","'":"f","(":"adef",")":"abcd","[":"adef","]":"abcd","!":"bc",".":"d"},C=6,D=56,L=2;function B(){return w.filter(()=>Math.random()>.45).join("")}function $(r,i){const n=Array.from(r).map(a=>N[a.toUpperCase()]??N[a]??""),d=Math.max(0,(i??0)-r.length);for(let a=0;a{if(a)return;const e=$(r,d),o=e.length,g=C+(o-1)*L;let y=0,b,E=!1;const k=()=>{if(!E){if(y++,y>=g){f(null);return}f(e.map((j,_)=>{const v=C+_*L;return y>=v?j:B()})),b=setTimeout(k,D)}};return k(),()=>{E=!0,clearTimeout(b)}},[r,d,a]);const c=(e,o)=>t.jsx("svg",{viewBox:"0 0 100 182",width:h,height:n,className:"seven-seg__char","aria-hidden":"true",children:w.map(g=>t.jsx("polygon",{points:R[g],fill:i,stroke:i,strokeWidth:4,strokeLinejoin:"round",opacity:e.includes(g)?1:M},g))},o),s=$(r,d),u=T??s;return t.jsxs("span",{className:`seven-seg${S?` ${S}`:""}`,children:[u.map((e,o)=>c(e,`${o}-${e}`)),t.jsx("span",{className:"sr-only",children:r})]})}const G={grey:"/assets/keycap.svg",red:"/assets/keycap-red.svg"},I=O[900],P="#FFDEB0";function Z({icon:r,variant:i="grey",onClick:n,onPress:d,sentDuration:a=2e3,title:S,disabled:h=!1,className:m,iconColor:M=I,iconActiveColor:T=P,indicators:f}){const c=!!d,[s,u]=l.useState("idle"),[e,o]=l.useState(!1),g=l.useRef(),y=c?s==="held":e,b=c&&(s==="sending"||s==="sent"),E=c?s==="held"||s==="sending":e;l.useEffect(()=>()=>clearTimeout(g.current),[]);const k=l.useCallback(()=>{h||b||(F(),c?u("held"):o(!0))},[h,b,c]),j=l.useCallback(async()=>{if(c){if(s!=="held")return;x(),u("sending");const p=await d();u(p?"sent":"idle"),p&&(g.current=setTimeout(()=>u("idle"),a))}else{if(!e)return;o(!1),x(),n==null||n()}},[c,s,d,a,e,n]),_=l.useCallback(()=>{c?s==="held"&&(x(),u("idle")):(e&&x(),o(!1))},[c,s,e]),v=t.jsx("button",{onMouseDown:k,onMouseUp:j,onMouseLeave:_,onTouchStart:k,onTouchEnd:j,onTouchCancel:_,disabled:h||b,className:`keycap-btn${i==="red"?" keycap-btn--red-cap":""}${E?" keycap-btn--pressed":""}${m&&!f?` ${m}`:""}`,title:S,children:t.jsxs("div",{className:"keycap-wrap",children:[t.jsx("img",{src:G[i],alt:"",className:"keycap-btn__img",draggable:!1}),t.jsx("span",{className:"keycap-icon-overlay",style:{color:y||s==="sending"?T:M},children:r})]})});return f!=null&&f.length?t.jsxs("div",{className:`keycap-group${m?` ${m}`:""}`,children:[v,t.jsx("div",{className:"indicator-key-pair",children:f.map(p=>{const A=p.trackPress?s:p.active?"active":"idle";return t.jsxs("div",{className:`indicator-key${A!=="idle"?` indicator-key--${A}`:""}`,children:[t.jsx("span",{className:"indicator-key__label",children:p.label}),t.jsx("span",{className:"indicator-key__led"})]},p.label)})})]}):v}export{Z as K,Y as S}; diff --git a/frontend/dist/assets/LightSparkline-CkL4j4OZ.js b/frontend/dist/assets/LightSparkline-5OIe9Q0M.js similarity index 96% rename from frontend/dist/assets/LightSparkline-CkL4j4OZ.js rename to frontend/dist/assets/LightSparkline-5OIe9Q0M.js index 18956202..aef4a3ea 100644 --- a/frontend/dist/assets/LightSparkline-CkL4j4OZ.js +++ b/frontend/dist/assets/LightSparkline-5OIe9Q0M.js @@ -1 +1 @@ -import{r as m,j as u}from"./index-C8IY8K2r.js";const a="var(--sparkline-critical)",C="var(--sparkline-poor)",L="var(--sparkline-fair)",g="var(--sparkline-good)",y="var(--sparkline-excellent)",$="var(--fg-muted)";function j(o){if(o.length===0)return a;const r=o.slice(-4),e=r.reduce((t,c)=>t+c.count,0),n=e/r.length,l=o.reduce((t,c)=>t+c.count,0)/o.length;if(e===0)return a;if(l>0){const t=n/l;return t>=1.2?y:t>=.8?g:t>=.4?L:t>=.1?C:a}return e>=10?y:e>=5?g:e>=2?L:e>=1?C:a}function h(o,r,e,n=2){if(o.length<2)return"";const s=o.map(i=>i.count),l=Math.max(...s,1),t=Math.min(...s),c=l-t||1,p=r-n*2,O=e-n*2,x=s.map((i,f)=>({x:n+f/(s.length-1)*p,y:n+O-(i-t)/c*O}));let k=`M ${x[0].x.toFixed(1)} ${x[0].y.toFixed(1)}`;for(let i=1;ih(r,e,n),[r,e,n]),p=m.useMemo(()=>s??(r.length>0?j(r):$),[s,r]);return l&&r.length<2?u.jsx("div",{className:`flex items-center justify-center ${t}`,style:{width:e,height:n},children:u.jsx("div",{className:"rounded animate-pulse bg-subtle-fill-hover",style:{width:e-8,height:n-6}})}):r.length<2?u.jsx("svg",{width:e,height:n,viewBox:`0 0 ${e} ${n}`,className:t,"aria-hidden":"true",children:u.jsx("line",{x1:4,y1:n/2,x2:e-4,y2:n/2,stroke:a,strokeWidth:1.5,strokeDasharray:"3,2"})}):u.jsx("svg",{width:e,height:n,viewBox:`0 0 ${e} ${n}`,preserveAspectRatio:"none",className:t,"aria-hidden":"true",style:{maxWidth:"100%"},children:u.jsx("path",{d:c,fill:"none",stroke:p,strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})})});export{A as L}; +import{r as m,j as u}from"./index-BwGHI0A_.js";const a="var(--sparkline-critical)",C="var(--sparkline-poor)",L="var(--sparkline-fair)",g="var(--sparkline-good)",y="var(--sparkline-excellent)",$="var(--fg-muted)";function j(o){if(o.length===0)return a;const r=o.slice(-4),e=r.reduce((t,c)=>t+c.count,0),n=e/r.length,l=o.reduce((t,c)=>t+c.count,0)/o.length;if(e===0)return a;if(l>0){const t=n/l;return t>=1.2?y:t>=.8?g:t>=.4?L:t>=.1?C:a}return e>=10?y:e>=5?g:e>=2?L:e>=1?C:a}function h(o,r,e,n=2){if(o.length<2)return"";const s=o.map(i=>i.count),l=Math.max(...s,1),t=Math.min(...s),c=l-t||1,p=r-n*2,O=e-n*2,x=s.map((i,f)=>({x:n+f/(s.length-1)*p,y:n+O-(i-t)/c*O}));let k=`M ${x[0].x.toFixed(1)} ${x[0].y.toFixed(1)}`;for(let i=1;ih(r,e,n),[r,e,n]),p=m.useMemo(()=>s??(r.length>0?j(r):$),[s,r]);return l&&r.length<2?u.jsx("div",{className:`flex items-center justify-center ${t}`,style:{width:e,height:n},children:u.jsx("div",{className:"rounded animate-pulse bg-subtle-fill-hover",style:{width:e-8,height:n-6}})}):r.length<2?u.jsx("svg",{width:e,height:n,viewBox:`0 0 ${e} ${n}`,className:t,"aria-hidden":"true",children:u.jsx("line",{x1:4,y1:n/2,x2:e-4,y2:n/2,stroke:a,strokeWidth:1.5,strokeDasharray:"3,2"})}):u.jsx("svg",{width:e,height:n,viewBox:`0 0 ${e} ${n}`,preserveAspectRatio:"none",className:t,"aria-hidden":"true",style:{maxWidth:"100%"},children:u.jsx("path",{d:c,fill:"none",stroke:p,strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})})});export{A as L}; diff --git a/frontend/dist/assets/Login-BAnk0zoo.js b/frontend/dist/assets/Login-DH5OEqBN.js similarity index 99% rename from frontend/dist/assets/Login-BAnk0zoo.js rename to frontend/dist/assets/Login-DH5OEqBN.js index d07d86c8..56fe4e54 100644 --- a/frontend/dist/assets/Login-BAnk0zoo.js +++ b/frontend/dist/assets/Login-DH5OEqBN.js @@ -1,3 +1,3 @@ -import{r as o,j as e,u as F,g as Y,i as $,s as Z,l as X,m as L,a as q,b as S,c as H,I as A,C as O,A as z,B as U,Z as V}from"./index-C8IY8K2r.js";import{g as T,B as G,r as K,T as J}from"./ascii-burst-DN6etEs5.js";const w=["@@@@@@@ @@@ @@@ @@@@@@@@@@ @@@@@@@ ","@@@@@@@@ @@@ @@@ @@@@@@@@@@@ @@@@@@@@ ","@@! @@@ @@! !@@ @@! @@! @@! !@@ ","!@! @!@ !@! @!! !@! !@! !@! !@! ","@!@@!@! !@!@! @!! !!@ @!@ !@! ","!!@!!! @!!! !@! ! !@! !!! ","!!: !!: !!: !!: :!! ",":!: :!: :!: :!: :!: "," :: :: ::: :: ::: ::: "," : : : : :: :: : "],Q=J-1,ee=w.length,te=Math.max(...w.map(s=>s.length)),se=.994,ne=.08,re=.25,ae=8,oe=9.6,ie=20,W=.008,k=20,_=" . ˙·∙⁺˚°:;~*+✧✩×✴░✦✶✳oO▒#%&xX▓@MW8B█████",ce={" ":0,".":.08,":":.15,"!":.5,"@":.85,"#":.6,$:.7,"%":.65,"&":.6,"*":.3,"+":.25,"-":.1,"=":.2,_:.05,"~":.2,"^":.15,"|":.4,"/":.3,"\\":.3,"(":.35,")":.35,"[":.4,"]":.4,"{":.45,"}":.45,"<":.3,">":.3,"?":.4,";":.2,"'":.1,'"':.15,",":.08,"`":.05};function le(s){let t="",n=0,a=!1,x="",p=!1,l=!1,g=!1;for(;n",a=!1),x="",p=!1,l=!1,g=!1;else if(u==="1")p=!0,g=!0;else if(u==="2")l=!0,g=!0;else if(u.startsWith("38;2;")){const C=u.split(";");x=`rgb(${C[2]},${C[3]},${C[4]})`,g=!0}}else{if(g){a&&(t+="");const u=[];x&&u.push(`color:${x}`),p&&u.push("font-weight:700"),l&&u.push("opacity:0.6"),u.length>0?(t+=``,a=!0):a=!1,g=!1}const h=s[n];h==="<"?t+="<":h===">"?t+=">":h==="&"?t+="&":t+=h,n++}return a&&(t+=""),t}function P(s){let t="";for(let n=0;n0&&(t+=` +import{r as o,j as e,u as F,g as Y,i as $,s as Z,l as X,m as L,a as q,b as S,c as H,I as A,C as O,A as z,B as U,Z as V}from"./index-BwGHI0A_.js";import{g as T,B as G,r as K,T as J}from"./ascii-burst-DN6etEs5.js";const w=["@@@@@@@ @@@ @@@ @@@@@@@@@@ @@@@@@@ ","@@@@@@@@ @@@ @@@ @@@@@@@@@@@ @@@@@@@@ ","@@! @@@ @@! !@@ @@! @@! @@! !@@ ","!@! @!@ !@! @!! !@! !@! !@! !@! ","@!@@!@! !@!@! @!! !!@ @!@ !@! ","!!@!!! @!!! !@! ! !@! !!! ","!!: !!: !!: !!: :!! ",":!: :!: :!: :!: :!: "," :: :: ::: :: ::: ::: "," : : : : :: :: : "],Q=J-1,ee=w.length,te=Math.max(...w.map(s=>s.length)),se=.994,ne=.08,re=.25,ae=8,oe=9.6,ie=20,W=.008,k=20,_=" . ˙·∙⁺˚°:;~*+✧✩×✴░✦✶✳oO▒#%&xX▓@MW8B█████",ce={" ":0,".":.08,":":.15,"!":.5,"@":.85,"#":.6,$:.7,"%":.65,"&":.6,"*":.3,"+":.25,"-":.1,"=":.2,_:.05,"~":.2,"^":.15,"|":.4,"/":.3,"\\":.3,"(":.35,")":.35,"[":.4,"]":.4,"{":.45,"}":.45,"<":.3,">":.3,"?":.4,";":.2,"'":.1,'"':.15,",":.08,"`":.05};function le(s){let t="",n=0,a=!1,x="",p=!1,l=!1,g=!1;for(;n",a=!1),x="",p=!1,l=!1,g=!1;else if(u==="1")p=!0,g=!0;else if(u==="2")l=!0,g=!0;else if(u.startsWith("38;2;")){const C=u.split(";");x=`rgb(${C[2]},${C[3]},${C[4]})`,g=!0}}else{if(g){a&&(t+="");const u=[];x&&u.push(`color:${x}`),p&&u.push("font-weight:700"),l&&u.push("opacity:0.6"),u.length>0?(t+=``,a=!0):a=!1,g=!1}const h=s[n];h==="<"?t+="<":h===">"?t+=">":h==="&"?t+="&":t+=h,n++}return a&&(t+=""),t}function P(s){let t="";for(let n=0;n0&&(t+=` `),t+=le(s[n]);return t}const ue="rgb(91,91,214)",y=[[91,91,214],[72,70,200],[110,110,230],[150,150,245],[190,210,255],[0,240,255],[255,50,180],[80,255,180]];function R(s,t,n){return`rgb(${Math.round(s[0]+(t[0]-s[0])*n)},${Math.round(s[1]+(t[1]-s[1])*n)},${Math.round(s[2]+(t[2]-s[2])*n)})`}function de(s){const t=Math.max(0,Math.min(.999,s));return _[Math.floor(t*_.length)]}function me(s){return ce[s]??.5}function he(s,t){const n=Math.abs(s);if(n<.3)return R(y[0],y[2],n/.3);if(n<.6){const a=(n-.3)/.3;return R(y[3],y[4],a)}else{const a=Math.sin(t*17.3)*.5+.5;return a<.4?R(y[4],y[5],(n-.6)/.4):a<.6?`rgb(${y[6].join(",")})`:a<.7?`rgb(${y[7].join(",")})`:"rgb(255,252,255)"}}function I(s){let t="";for(let n=0;n0&&(t+=` `);const a=w[n]||"";for(let x=0;x0?Math.exp(-m*m/2):Math.exp(-m*m/12),j=c*re-C.radius*.4,M=Math.sin(j*Math.PI),d=b*C.strength;l+=b*M*C.strength,d>h&&(h=d,g=j+n*.1+x*.05)}if(l=Math.max(-1,Math.min(1,l)),Math.abs(l)${p}`;else{const r=me(p)+l*.5,i=Math.max(.02,Math.min(.98,r)),c=de(i),f=he(l,g);t+=`${c}`}}}return t}function Ce(){const s=o.useRef(null),t=o.useRef([]),n=o.useRef(0),[a,x]=o.useState(!1);o.useEffect(()=>{const r=s.current;if(!r)return;let i=0;r.innerHTML=P(T(w,0));const c=setInterval(()=>{if(i++,i>Q){clearInterval(c),x(!0);return}r.innerHTML=P(T(w,i))},G);return()=>{clearInterval(c),K()}},[]),o.useEffect(()=>{if(!a)return;const r=s.current;if(!r)return;let i=!0;const c=()=>{if(!i)return;const f=t.current;for(const m of f)m.radius+=ne,m.strength*=se;t.current=f.filter(m=>m.strength>W),t.current.length>0?r.innerHTML=I(t.current):r.innerHTML=I([]),n.current=requestAnimationFrame(c)};return n.current=requestAnimationFrame(c),()=>{i=!1,cancelAnimationFrame(n.current)}},[a]);const p=o.useRef(null),l=o.useCallback((r,i,c=1)=>{const f=s.current;if(!f||!a)return;const m=f.getBoundingClientRect(),b=r-m.left,j=i-m.top,M=b/oe,d=j/ie;t.current.length>=ae&&t.current.shift(),t.current.push({cx:M,cy:d,radius:0,strength:c}),p.current={x:r,y:i}},[a]),g=o.useCallback(r=>{const i=p.current;if(i){const c=r.clientX-i.x,f=r.clientY-i.y;if(Math.sqrt(c*c+f*f){l(r.clientX,r.clientY,1)},[l]),u=o.useCallback(r=>{p.current=null,l(r.clientX,r.clientY,.6)},[l]),C=o.useCallback(r=>{if(r.touches.length>0){const i=r.touches[0],c=p.current;if(c){const f=i.clientX-c.x,m=i.clientY-c.y;if(Math.sqrt(f*f+m*m)e.jsx("span",{className:"text-white/20 text-xs","aria-hidden":"true",children:"•"}),be=o.memo(function(){return e.jsx("div",{className:"fixed inset-0 -z-10",style:{backgroundColor:V[950]},"aria-hidden":"true"})}),ve=o.memo(function(){return e.jsxs(L.footer,{variants:v.footer,initial:"hidden",animate:"visible",className:"fixed bottom-0 inset-x-0 px-4 py-6",children:[e.jsx("p",{className:"text-center type-badge text-white/40 mb-3",children:"Powered By"}),e.jsx("div",{className:"mx-auto max-w-xs",children:e.jsxs("div",{className:"flex items-center justify-center gap-4",children:[e.jsx(E,{href:"https://github.com/rightup/pyMC_Repeater",children:e.jsx("img",{src:Le,alt:"pyMC",className:"h-14"})}),e.jsx(D,{}),e.jsx(E,{href:"https://meshcore.co.uk",children:e.jsx(xe,{height:12,className:"text-white"})}),e.jsx(D,{}),e.jsxs(E,{href:"https://wcmesh.com",children:[e.jsx("div",{className:"size-14 overflow-hidden radius-badge border border-white/10 -translate-y-1",children:e.jsx("img",{src:ge,alt:"",className:"size-full object-cover"})}),e.jsx("span",{className:"font-mono text-sm font-semibold tracking-tight text-white",children:"WCM"})]})]})})]})}),je={session_expired:"Your session has expired. Please sign in again.",no_token:"Authentication required. Please sign in.",token_expired_away:"Your session expired while you were away."};function Ne(){const s=F(),[t,n]=o.useState("admin"),[a,x]=o.useState(""),[p,l]=o.useState(Y),[g,h]=o.useState(!1),[u,C]=o.useState(null),[r]=o.useState(()=>{try{const d=sessionStorage.getItem("auth_redirect_reason");return sessionStorage.removeItem("auth_redirect_reason"),d?je[d]??null:null}catch{return null}}),i=t.length>0&&a.length>0&&!g;o.useEffect(()=>{$()&&s("/",{replace:!0})},[s]);const c=o.useCallback(()=>C(null),[]),f=o.useCallback(d=>{n(d.target.value),u&&c()},[u,c]),m=o.useCallback(d=>{x(d.target.value),u&&c()},[u,c]),b=o.useCallback(d=>{l(d),Z(d)},[]),j=o.useCallback(async d=>{if(d.preventDefault(),!i)return;h(!0),C(null);const N=await X(t,a,p);h(!1),N.success?window.location.href="/":C(N.error??"Login failed")},[i,t,a,p]),M=o.useCallback(d=>{d.key==="Enter"&&i&&d.target.tagName==="INPUT"&&(d.preventDefault(),d.currentTarget.requestSubmit())},[i]);return e.jsxs(e.Fragment,{children:[e.jsx(be,{}),e.jsx("main",{className:"flex min-h-svh items-center justify-center px-4 py-6 sm:px-6 lg:px-8 -mt-6",children:e.jsxs(L.div,{variants:v.container,initial:"hidden",animate:"visible",className:"w-full max-w-sm space-y-10",children:[e.jsx(L.div,{variants:v.item,className:"flex justify-center",children:e.jsx(fe,{})}),r&&!u&&e.jsx(L.div,{variants:v.item,className:"rounded-md bg-sys-amber/10 px-3 py-2.5 text-center",children:e.jsx("p",{className:"text-sm text-sys-amber",children:r})}),e.jsxs(L.form,{variants:v.item,onSubmit:j,onKeyDown:M,className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"username",className:B,children:"Username"}),e.jsx("div",{className:"mt-2",children:e.jsx(A,{id:"username",name:"username",type:"text",value:t,onChange:f,required:!0,autoComplete:"username",className:"font-mono text-sm font-semibold"})})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"password",className:B,children:"Password"}),e.jsx("div",{className:"mt-2",children:e.jsx(A,{id:"password",name:"password",type:"password",value:a,onChange:m,required:!0,autoComplete:"current-password",autoFocus:!0,className:"font-mono text-sm font-semibold"})})]}),e.jsx("div",{className:"-mt-2",children:e.jsx(O,{checked:p,onChange:b,label:e.jsx("span",{className:"type-badge text-fg-secondary",children:"Remember me"}),size:"sm"})}),e.jsx(z,{mode:"wait",children:u&&e.jsx(L.div,{variants:v.error,initial:"hidden",animate:"visible",exit:"exit",role:"alert",className:"rounded-md bg-sys-red/10 p-3 overflow-hidden",children:e.jsx("p",{className:"text-sm text-sys-red text-center",children:u})},"error")}),e.jsx(L.div,{whileTap:i?{scale:.98}:void 0,children:e.jsx(U,{type:"submit",disabled:!i,className:"w-full py-3 radius-pill font-mono text-sm font-semibold uppercase tracking-wide text-white bg-sys-indigo hover:bg-sys-blue shadow-sm transition-colors",children:g?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ye,{className:"size-4"}),"Signing in…"]}):"Sign in"})})]}),e.jsxs(L.p,{variants:v.item,className:"text-center text-sm/6 text-fg-muted",children:["A ",e.jsx("span",{className:"text-sys-blue",children:"@RightUp"})," X"," ",e.jsx("span",{className:"text-sys-blue",children:"@Treehouse⚡"})," Collab"]})]})}),e.jsx(ve,{})]})}export{Ne as default}; diff --git a/frontend/dist/assets/Logs-BebUdPuw.js b/frontend/dist/assets/Logs-COCuHgwW.js similarity index 63% rename from frontend/dist/assets/Logs-BebUdPuw.js rename to frontend/dist/assets/Logs-COCuHgwW.js index 77000a07..638a789f 100644 --- a/frontend/dist/assets/Logs-BebUdPuw.js +++ b/frontend/dist/assets/Logs-COCuHgwW.js @@ -1,4 +1,4 @@ -import{d as g,d6 as y,d7 as f,D as j,d8 as L,d9 as v,r as o,da as N,j as e,db as m,F as w,B as b,c as n,dc as k,cX as C,m as S,dd as E}from"./index-C8IY8K2r.js";import{P,a as R,B,C as I}from"./PageLayout-NQBVrM09.js";/** +import{d as g,db as y,dc as f,D as j,dd as L,de as v,r as o,df as N,j as e,dg as m,F as w,B as b,c as n,dh as k,d0 as C,m as S,di as E}from"./index-BwGHI0A_.js";import{P,a as R,B,C as I}from"./PageLayout-BIcqC04y.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -8,4 +8,4 @@ import{d as g,d6 as y,d7 as f,D as j,d8 as L,d9 as v,r as o,da as N,j as e,db as * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const T=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],_=g("circle-stop",T),F=o.memo(function({log:a}){return e.jsx(S.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:"easeOut"},className:"p-3 bg-subtle-fill/80 radius-inner depth-stroke-raised hover:bg-subtle-fill-strong transition-base",children:e.jsxs("div",{className:"flex items-baseline gap-3",children:[e.jsx("span",{className:n("type-data-sm w-14 shrink-0",E(a.level)),children:a.level}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"type-data-sm text-fg-primary break-words whitespace-pre-wrap",children:a.message}),e.jsx("p",{className:"type-data-xs text-fg-muted mt-1",children:new Date(a.timestamp).toLocaleString()})]})]})})});function G({showDebug:s,onToggle:a}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:n("type-data-sm",s?"text-sys-orange":"text-sys-cyan"),children:s?"DEBUG":"INFO"}),e.jsx(C,{enabled:s,onChange:a,size:"sm"})]})}function $(){const s=y(),a=f(),c=j(),i=L(),x=v(),[r,u]=o.useState(!1),h=o.useCallback(()=>{u(t=>!t)},[]),d=r?s:s.filter(t=>t.level!=="DEBUG"),l=o.useRef(i);return l.current=i,o.useEffect(()=>{if(!c)return;l.current();const t=setInterval(()=>l.current(),N.logs);return()=>clearInterval(t)},[c]),e.jsxs(P,{children:[e.jsx(R,{title:"System Logs",icon:e.jsx(m,{}),controls:e.jsx(G,{showDebug:r,onToggle:h})}),e.jsx(B,{children:e.jsxs(I,{neomorphic:!0,noPadding:!0,children:[e.jsx(w,{listHeader:!0,icon:e.jsx(m,{className:"icon-sm"}),title:"Log Entries",actions:e.jsx(b,{plain:!0,color:c?"danger":"primary",onClick:()=>x(!c),title:c?"Pause":"Resume",className:n(!c&&"animate-pulse-slow"),children:c?e.jsx(_,{"data-slot":"icon",className:"!w-5 !h-5"}):e.jsx(M,{"data-slot":"icon",className:"!w-5 !h-5"})})}),e.jsx("div",{className:"space-y-2 max-h-[calc(100dvh-226px)] sm:max-h-[calc(100dvh-234px)] lg:max-h-[calc(100vh-194px)] overflow-y-auto p-4",children:a&&s.length===0?e.jsx(k,{count:10}):d.length===0?e.jsx("div",{className:"text-center py-12 text-fg-muted",children:s.length===0?"No logs available":"No logs match selected filters"}):d.map((t,p)=>e.jsx(F,{log:t},`${t.timestamp}-${p}`))})]})})]})}export{$ as default}; + */const T=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],_=g("circle-stop",T),F=o.memo(function({log:t}){return e.jsx(S.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.15,ease:"easeOut"},className:"p-3 bg-subtle-fill/80 radius-inner depth-stroke-raised hover:bg-subtle-fill-strong transition-base",children:e.jsxs("div",{className:"flex items-baseline gap-3",children:[e.jsx("span",{className:n("type-data-sm w-14 shrink-0",E(t.level)),children:t.level}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"type-data-sm text-fg-primary break-words whitespace-pre-wrap",children:t.message}),e.jsx("p",{className:"type-data-xs text-fg-muted mt-1",children:new Date(t.timestamp).toLocaleString()})]})]})})});function G({showDebug:s,onToggle:t}){return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:n("type-data-sm",s?"text-sys-orange":"text-sys-cyan"),children:s?"DEBUG":"INFO"}),e.jsx(C,{enabled:s,onChange:t,size:"sm"})]})}function $(){const s=y(),t=f(),c=j(),i=L(),x=v(),[r,h]=o.useState(!1),u=o.useCallback(()=>{h(a=>!a)},[]),d=r?s:s.filter(a=>a.level!=="DEBUG"),l=o.useRef(i);return l.current=i,o.useEffect(()=>{if(!c)return;l.current();const a=setInterval(()=>l.current(),N.logs);return()=>clearInterval(a)},[c]),e.jsxs(P,{children:[e.jsx(R,{title:"System Logs",icon:e.jsx(m,{}),controls:e.jsx(G,{showDebug:r,onToggle:u})}),e.jsx(B,{children:e.jsxs(I,{neomorphic:!0,noPadding:!0,children:[e.jsx(w,{listHeader:!0,icon:e.jsx(m,{className:"icon-sm"}),title:"Log Entries",actions:e.jsx(b,{plain:!0,color:c?"danger":"primary",onClick:()=>x(!c),title:c?"Pause":"Resume",className:n(!c&&"animate-pulse-slow"),children:c?e.jsx(_,{"data-slot":"icon",className:"!w-5 !h-5"}):e.jsx(M,{"data-slot":"icon",className:"!w-5 !h-5"})})}),e.jsx("div",{className:"space-y-2 max-h-[calc(100dvh-226px)] sm:max-h-[calc(100dvh-234px)] lg:max-h-[calc(100vh-194px)] overflow-y-auto p-4",children:t&&s.length===0?e.jsx(k,{count:10}):d.length===0?e.jsx("div",{className:"text-center py-12 text-fg-muted",children:s.length===0?"No logs available":"No logs match selected filters"}):d.map((a,p)=>e.jsx(F,{log:a},`${a.timestamp}-${p}`))})]})})]})}export{$ as default}; diff --git a/frontend/dist/assets/MeshGraph-TagJOEOk.js b/frontend/dist/assets/MeshGraph-CElh2Drl.js similarity index 98% rename from frontend/dist/assets/MeshGraph-TagJOEOk.js rename to frontend/dist/assets/MeshGraph-CElh2Drl.js index 0dc58125..2a8af169 100644 --- a/frontend/dist/assets/MeshGraph-TagJOEOk.js +++ b/frontend/dist/assets/MeshGraph-CElh2Drl.js @@ -1,5 +1,5 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/webgl-device-QoBMYpnS-BzCsS41F.js","assets/index-C8IY8K2r.js","assets/DeepAnalysisModal-B2m7JxOp.js","assets/geo-utils-BP1zBK9h.js","assets/download-IUkhheKK.js","assets/database-BEyHF_p_.js","assets/consumer-registry-lDKP4bcU.js","assets/DataBox-W2v3wy8k.js","assets/badge-colors-BNUqIXCA.js","assets/meshcore-tx-constants-DgpFTAmf.js","assets/target-DviLCm8U.js","assets/layers-Oxzfug7f.js","assets/search-zALFwCS4.js","assets/settings-2-BUdn2-nA.js","assets/chevron-right-DUgYTR6d.js","assets/network-DBkquEPb.js","assets/index-DUfCykEc.css"])))=>i.map(i=>d[i]); -var tL=Object.defineProperty;var iL=(i,e,t)=>e in i?tL(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var b=(i,e,t)=>iL(i,typeof e!="symbol"?e+"":e,t);import{d as Vl,r as $,bo as l0,aX as cn,cG as CS,cH as nL,bX as sL,j as f,A as Qc,m as Sl,cI as rL,bc as $u,bT as oL,cJ as aL,cK as lL,cL,cM as uL,cN as dL,cO as hL,cP as fL,E as pL,c7 as mL,cQ as gL,cR as Ge,Z as qt,cS as c0,q as Di,a0 as be,cT as _L,cU as yL,R as dg,cV as bL,ae as Rc,L as u0,cW as vL,aw as xL,cX as wL,cY as SL,B as q_,w as EL,x as CL,cZ as TL,bN as d0}from"./index-C8IY8K2r.js";import{m as h0,t as hg,a as kL,b as AL,e as Rn,u as IL,G as LL,M as TS,c as RL,E as PL,d as f0,D as NL,s as X_}from"./DeepAnalysisModal-B2m7JxOp.js";import{u as DL,r as ML,f as p0,g as OL,e as BL}from"./consumer-registry-lDKP4bcU.js";import{D as FL}from"./DataBox-W2v3wy8k.js";import{h as Uh,c as kS}from"./geo-utils-BP1zBK9h.js";import{N as zL,a as UL}from"./badge-colors-BNUqIXCA.js";import{e as $L,f as m0,g as jL}from"./meshcore-tx-constants-DgpFTAmf.js";import{E as HL,T as VL}from"./target-DviLCm8U.js";import{L as g0}from"./layers-Oxzfug7f.js";import{S as _0}from"./search-zALFwCS4.js";import{D as y0}from"./download-IUkhheKK.js";import{S as b0}from"./settings-2-BUdn2-nA.js";import{C as Hp}from"./chevron-right-DUgYTR6d.js";import{N as GL}from"./network-DBkquEPb.js";/** +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/webgl-device-QoBMYpnS-CGfZSI9d.js","assets/index-BwGHI0A_.js","assets/DeepAnalysisModal-CaP_TRSd.js","assets/download-BbqYTv8j.js","assets/database-CDN_R6oC.js","assets/consumer-registry-DPYvsBcc.js","assets/DataBox-CQS-Zhu0.js","assets/badge-colors-BNUqIXCA.js","assets/meshcore-tx-constants-DgpFTAmf.js","assets/target-LdPtzGwl.js","assets/layers-C8ICjJ-w.js","assets/search-B7iMjmGm.js","assets/settings-2-B_NiASQG.js","assets/chevron-right-DqpRZiGf.js","assets/network-9doWJxcL.js","assets/index-DUfCykEc.css"])))=>i.map(i=>d[i]); +var tL=Object.defineProperty;var iL=(i,e,t)=>e in i?tL(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var b=(i,e,t)=>iL(i,typeof e!="symbol"?e+"":e,t);import{d as Vl,r as $,bo as l0,aX as cn,cJ as CS,cK as Uh,cL as TS,cM as nL,b_ as sL,j as f,A as Qc,m as Sl,cN as rL,bc as $u,bW as oL,cO as aL,cP as lL,cQ as cL,cR as uL,cS as dL,cT as hL,cU as fL,E as pL,ca as mL,cV as gL,cW as Ge,Z as qt,cX as c0,q as Di,a0 as be,cY as _L,cZ as yL,R as dg,c_ as bL,ae as Rc,L as u0,c$ as vL,aw as xL,d0 as wL,d1 as SL,B as q_,w as EL,x as CL,d2 as TL,bQ as d0}from"./index-BwGHI0A_.js";import{m as h0,t as hg,a as kL,b as AL,e as Rn,u as IL,G as LL,M as kS,c as RL,E as PL,d as f0,D as NL,s as X_}from"./DeepAnalysisModal-CaP_TRSd.js";import{u as DL,r as ML,f as p0,g as OL,e as BL}from"./consumer-registry-DPYvsBcc.js";import{D as FL}from"./DataBox-CQS-Zhu0.js";import{N as zL,a as UL}from"./badge-colors-BNUqIXCA.js";import{e as $L,f as m0,g as jL}from"./meshcore-tx-constants-DgpFTAmf.js";import{E as HL,T as VL}from"./target-LdPtzGwl.js";import{L as g0}from"./layers-C8ICjJ-w.js";import{S as _0}from"./search-B7iMjmGm.js";import{D as y0}from"./download-BbqYTv8j.js";import{S as b0}from"./settings-2-B_NiASQG.js";import{C as Hp}from"./chevron-right-DqpRZiGf.js";import{N as GL}from"./network-9doWJxcL.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -29,7 +29,7 @@ var tL=Object.defineProperty;var iL=(i,e,t)=>e in i?tL(i,e,{enumerable:!0,config * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const eR=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],hd=Vl("shield-alert",eR),tR=$.createContext(null);function K_(){return $.useContext(tR)}var iR=Object.defineProperty,nR=(i,e,t)=>e in i?iR(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,U=(i,e,t)=>nR(i,typeof e!="symbol"?e+"":e,t),fg="http://www.w3.org/1999/xhtml";const x0={svg:"http://www.w3.org/2000/svg",xhtml:fg,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function np(i){var e=i+="",t=e.indexOf(":");return t>=0&&(e=i.slice(0,t))!=="xmlns"&&(i=i.slice(t+1)),x0.hasOwnProperty(e)?{space:x0[e],local:i}:i}function sR(i){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===fg&&e.documentElement.namespaceURI===fg?e.createElement(i):e.createElementNS(t,i)}}function rR(i){return function(){return this.ownerDocument.createElementNS(i.space,i.local)}}function IS(i){var e=np(i);return(e.local?rR:sR)(e)}function oR(){}function Z_(i){return i==null?oR:function(){return this.querySelector(i)}}function aR(i){typeof i!="function"&&(i=Z_(i));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s=C&&(C=S+1);!(A=g[C])&&++C=0;)(o=n[s])&&(r&&o.compareDocumentPosition(r)^4&&r.parentNode.insertBefore(o,r),r=o);return this}function PR(i){i||(i=NR);function e(d,h){return d&&h?i(d.__data__,h.__data__):!d-!h}for(var t=this._groups,n=t.length,s=new Array(n),r=0;re?1:i>=e?0:NaN}function DR(){var i=arguments[0];return arguments[0]=this,i.apply(null,arguments),this}function MR(){return Array.from(this)}function OR(){for(var i=this._groups,e=0,t=i.length;e1?this.each((e==null?YR:typeof e=="function"?XR:qR)(i,e,t??"")):El(this.node(),i)}function El(i,e){return i.style.getPropertyValue(e)||DS(i).getComputedStyle(i,null).getPropertyValue(e)}function ZR(i){return function(){delete this[i]}}function QR(i,e){return function(){this[i]=e}}function JR(i,e){return function(){var t=e.apply(this,arguments);t==null?delete this[i]:this[i]=t}}function e4(i,e){return arguments.length>1?this.each((e==null?ZR:typeof e=="function"?JR:QR)(i,e)):this.node()[i]}function MS(i){return i.trim().split(/^|\s+/)}function Q_(i){return i.classList||new OS(i)}function OS(i){this._node=i,this._names=MS(i.getAttribute("class")||"")}OS.prototype={add:function(i){var e=this._names.indexOf(i);e<0&&(this._names.push(i),this._node.setAttribute("class",this._names.join(" ")))},remove:function(i){var e=this._names.indexOf(i);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(i){return this._names.indexOf(i)>=0}};function BS(i,e){for(var t=Q_(i),n=-1,s=e.length;++n=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function A4(i){return function(){var e=this.__on;if(e){for(var t=0,n=-1,s=e.length,r;t{}};function sp(){for(var i=0,e=arguments.length,t={},n;i=0&&(n=t.slice(s+1),t=t.slice(0,s)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}rh.prototype=sp.prototype={constructor:rh,on:function(i,e){var t=this._,n=F4(i+"",t),s,r=-1,o=n.length;if(arguments.length<2){for(;++r0)for(var t=new Array(s),n=0,s,r;n=0&&i._call.call(null,e),i=i._next;--Cl}function S0(){ga=(Hh=uu.now())+rp,Cl=Pc=0;try{$4()}finally{Cl=0,H4(),ga=0}}function j4(){var i=uu.now(),e=i-Hh;e>$S&&(rp-=e,Hh=i)}function H4(){for(var i,e=jh,t,n=1/0;e;)e._call?(n>e._time&&(n=e._time),i=e,e=e._next):(t=e._next,e._next=null,e=i?i._next=t:jh=t);Nc=i,pg(n)}function pg(i){if(!Cl){Pc&&(Pc=clearTimeout(Pc));var e=i-ga;e>24?(i<1/0&&(Pc=setTimeout(S0,i-uu.now()-rp)),rc&&(rc=clearInterval(rc))):(rc||(Hh=uu.now(),rc=setInterval(j4,$S)),Cl=1,jS(S0))}}function E0(i,e,t){var n=new Vh;return e=e==null?0:+e,n.restart(s=>{n.stop(),i(s+e)},e,t),n}var V4=sp("start","end","cancel","interrupt"),G4=[],VS=0,C0=1,mg=2,oh=3,T0=4,gg=5,ah=6;function op(i,e,t,n,s,r){var o=i.__transition;if(!o)i.__transition={};else if(t in o)return;W4(i,t,{name:e,index:n,group:s,on:V4,tween:G4,time:r.time,delay:r.delay,duration:r.duration,ease:r.ease,timer:null,state:VS})}function ey(i,e){var t=Gs(i,e);if(t.state>VS)throw new Error("too late; already scheduled");return t}function Tr(i,e){var t=Gs(i,e);if(t.state>oh)throw new Error("too late; already running");return t}function Gs(i,e){var t=i.__transition;if(!t||!(t=t[e]))throw new Error("transition not found");return t}function W4(i,e,t){var n=i.__transition,s;n[e]=t,t.timer=HS(r,0,t.time);function r(c){t.state=C0,t.timer.restart(o,t.delay,t.time),t.delay<=c&&o(c-t.delay)}function o(c){var u,d,h,p;if(t.state!==C0)return l();for(u in n)if(p=n[u],p.name===t.name){if(p.state===oh)return E0(o);p.state===T0?(p.state=ah,p.timer.stop(),p.on.call("interrupt",i,i.__data__,p.index,p.group),delete n[u]):+umg&&n.state>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?fd(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?fd(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=X4.exec(i))?new In(e[1],e[2],e[3],1):(e=K4.exec(i))?new In(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Z4.exec(i))?fd(e[1],e[2],e[3],e[4]):(e=Q4.exec(i))?fd(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=J4.exec(i))?N0(e[1],e[2]/100,e[3]/100,1):(e=e5.exec(i))?N0(e[1],e[2]/100,e[3]/100,e[4]):k0.hasOwnProperty(i)?L0(k0[i]):i==="transparent"?new In(NaN,NaN,NaN,0):null}function L0(i){return new In(i>>16&255,i>>8&255,i&255,1)}function fd(i,e,t,n){return n<=0&&(i=e=t=NaN),new In(i,e,t,n)}function n5(i){return i instanceof Hu||(i=Uo(i)),i?(i=i.rgb(),new In(i.r,i.g,i.b,i.opacity)):new In}function _g(i,e,t,n){return arguments.length===1?n5(i):new In(i,e,t,n??1)}function In(i,e,t,n){this.r=+i,this.g=+e,this.b=+t,this.opacity=+n}ty(In,_g,GS(Hu,{brighter(i){return i=i==null?Gh:Math.pow(Gh,i),new In(this.r*i,this.g*i,this.b*i,this.opacity)},darker(i){return i=i==null?du:Math.pow(du,i),new In(this.r*i,this.g*i,this.b*i,this.opacity)},rgb(){return this},clamp(){return new In(ua(this.r),ua(this.g),ua(this.b),Wh(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:R0,formatHex:R0,formatHex8:s5,formatRgb:P0,toString:P0}));function R0(){return`#${oa(this.r)}${oa(this.g)}${oa(this.b)}`}function s5(){return`#${oa(this.r)}${oa(this.g)}${oa(this.b)}${oa((isNaN(this.opacity)?1:this.opacity)*255)}`}function P0(){const i=Wh(this.opacity);return`${i===1?"rgb(":"rgba("}${ua(this.r)}, ${ua(this.g)}, ${ua(this.b)}${i===1?")":`, ${i})`}`}function Wh(i){return isNaN(i)?1:Math.max(0,Math.min(1,i))}function ua(i){return Math.max(0,Math.min(255,Math.round(i)||0))}function oa(i){return i=ua(i),(i<16?"0":"")+i.toString(16)}function N0(i,e,t,n){return n<=0?i=e=t=NaN:t<=0||t>=1?i=e=NaN:e<=0&&(i=NaN),new Us(i,e,t,n)}function WS(i){if(i instanceof Us)return new Us(i.h,i.s,i.l,i.opacity);if(i instanceof Hu||(i=Uo(i)),!i)return new Us;if(i instanceof Us)return i;i=i.rgb();var e=i.r/255,t=i.g/255,n=i.b/255,s=Math.min(e,t,n),r=Math.max(e,t,n),o=NaN,a=r-s,l=(r+s)/2;return a?(e===r?o=(t-n)/a+(t0&&l<1?0:o,new Us(o,a,l,i.opacity)}function r5(i,e,t,n){return arguments.length===1?WS(i):new Us(i,e,t,n??1)}function Us(i,e,t,n){this.h=+i,this.s=+e,this.l=+t,this.opacity=+n}ty(Us,r5,GS(Hu,{brighter(i){return i=i==null?Gh:Math.pow(Gh,i),new Us(this.h,this.s,this.l*i,this.opacity)},darker(i){return i=i==null?du:Math.pow(du,i),new Us(this.h,this.s,this.l*i,this.opacity)},rgb(){var i=this.h%360+(this.h<0)*360,e=isNaN(i)||isNaN(this.s)?0:this.s,t=this.l,n=t+(t<.5?t:1-t)*e,s=2*t-n;return new In(Vp(i>=240?i-240:i+120,s,n),Vp(i,s,n),Vp(i<120?i+240:i-120,s,n),this.opacity)},clamp(){return new Us(D0(this.h),pd(this.s),pd(this.l),Wh(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const i=Wh(this.opacity);return`${i===1?"hsl(":"hsla("}${D0(this.h)}, ${pd(this.s)*100}%, ${pd(this.l)*100}%${i===1?")":`, ${i})`}`}}));function D0(i){return i=(i||0)%360,i<0?i+360:i}function pd(i){return Math.max(0,Math.min(1,i||0))}function Vp(i,e,t){return(i<60?e+(t-e)*i/60:i<180?t:i<240?e+(t-e)*(240-i)/60:e)*255}const iy=i=>()=>i;function o5(i,e){return function(t){return i+t*e}}function a5(i,e,t){return i=Math.pow(i,t),e=Math.pow(e,t)-i,t=1/t,function(n){return Math.pow(i+n*e,t)}}function l5(i){return(i=+i)==1?YS:function(e,t){return t-e?a5(e,t,i):iy(isNaN(e)?t:e)}}function YS(i,e){var t=e-i;return t?o5(i,t):iy(isNaN(i)?e:i)}const Yh=(function i(e){var t=l5(e);function n(s,r){var o=t((s=_g(s)).r,(r=_g(r)).r),a=t(s.g,r.g),l=t(s.b,r.b),c=YS(s.opacity,r.opacity);return function(u){return s.r=o(u),s.g=a(u),s.b=l(u),s.opacity=c(u),s+""}}return n.gamma=i,n})(1);function c5(i,e){e||(e=[]);var t=i?Math.min(e.length,i.length):0,n=e.slice(),s;return function(r){for(s=0;st&&(r=e.slice(t,r),a[o]?a[o]+=r:a[++o]=r),(n=n[0])===(s=s[0])?a[o]?a[o]+=s:a[++o]=s:(a[++o]=null,l.push({i:o,x:Fs(n,s)})),t=Gp.lastIndex;return t180?u+=360:u-c>180&&(c+=360),h.push({i:d.push(s(d)+"rotate(",null,n)-2,x:Fs(c,u)})):u&&d.push(s(d)+"rotate("+u+n)}function a(c,u,d,h){c!==u?h.push({i:d.push(s(d)+"skewX(",null,n)-2,x:Fs(c,u)}):u&&d.push(s(d)+"skewX("+u+n)}function l(c,u,d,h,p,m){if(c!==d||u!==h){var y=p.push(s(p)+"scale(",null,",",null,")");m.push({i:y-4,x:Fs(c,d)},{i:y-2,x:Fs(u,h)})}else(d!==1||h!==1)&&p.push(s(p)+"scale("+d+","+h+")")}return function(c,u){var d=[],h=[];return c=i(c),u=i(u),r(c.translateX,c.translateY,u.translateX,u.translateY,d,h),o(c.rotate,u.rotate,d,h),a(c.skewX,u.skewX,d,h),l(c.scaleX,c.scaleY,u.scaleX,u.scaleY,d,h),c=u=null,function(p){for(var m=-1,y=h.length,g;++m=0&&(e=e.slice(0,t)),!e||e==="start"})}function J5(i,e,t){var n,s,r=Q5(e)?ey:Tr;return function(){var o=r(this,i),a=o.on;a!==n&&(s=(n=a).copy()).on(e,t),o.on=s}}function eP(i,e){var t=this._id;return arguments.length<2?Gs(this.node(),t).on.on(i):this.each(J5(t,i,e))}function tP(i){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==i)return;e&&e.removeChild(this)}}function iP(){return this.on("end.remove",tP(this._id))}function nP(i){var e=this._name,t=this._id;typeof i!="function"&&(i=Z_(i));for(var n=this._groups,s=n.length,r=new Array(s),o=0;o0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}class RP{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(const e of Object.values(this.stats))e.reset();return this}forEach(e){for(const t of Object.values(this.stats))e(t)}getTable(){const e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(t=>this._getOrCreate(t))}_getOrCreate(e){const{name:t,type:n}=e;let s=this.stats[t];return s||(e instanceof F0?s=e:s=new F0(t,n),this.stats[t]=s),s}}class PP{constructor(){U(this,"stats",new Map)}getStats(e){return this.get(e)}get(e){return this.stats.has(e)||this.stats.set(e,new RP({id:e})),this.stats.get(e)}}const t2=new PP,Wp=globalThis,gd=globalThis.process||{},dte=globalThis.navigator||{};function NP(i){var e,t;if(typeof window<"u"&&((e=window.process)==null?void 0:e.type)==="renderer"||typeof process<"u"&&(t=process.versions)!=null&&t.electron)return!0;const n=typeof navigator<"u"&&navigator.userAgent;return!!(n&&n.indexOf("Electron")>=0)}function Vu(){return!(typeof process=="object"&&String(process)==="[object process]"&&!(process!=null&&process.browser))||NP()}const i2="4.1.0";function DP(i){try{const e=window[i],t="__storage_test__";return e.setItem(t,t),e.removeItem(t),e}catch{return null}}class MP{constructor(e,t,n="sessionStorage"){this.storage=DP(n),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){const t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}}_loadConfiguration(){let e={};if(this.storage){const t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}function OP(i){let e;return i<10?e=`${i.toFixed(2)}ms`:i<100?e=`${i.toFixed(1)}ms`:i<1e3?e=`${i.toFixed(0)}ms`:e=`${(i/1e3).toFixed(2)}s`,e}function BP(i,e=8){const t=Math.max(e-i.length,0);return`${" ".repeat(t)}${i}`}var qh;(function(i){i[i.BLACK=30]="BLACK",i[i.RED=31]="RED",i[i.GREEN=32]="GREEN",i[i.YELLOW=33]="YELLOW",i[i.BLUE=34]="BLUE",i[i.MAGENTA=35]="MAGENTA",i[i.CYAN=36]="CYAN",i[i.WHITE=37]="WHITE",i[i.BRIGHT_BLACK=90]="BRIGHT_BLACK",i[i.BRIGHT_RED=91]="BRIGHT_RED",i[i.BRIGHT_GREEN=92]="BRIGHT_GREEN",i[i.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",i[i.BRIGHT_BLUE=94]="BRIGHT_BLUE",i[i.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",i[i.BRIGHT_CYAN=96]="BRIGHT_CYAN",i[i.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(qh||(qh={}));const FP=10;function z0(i){return typeof i!="string"?i:(i=i.toUpperCase(),qh[i]||qh.WHITE)}function zP(i,e,t){return!Vu&&typeof i=="string"&&(e&&(i=`\x1B[${z0(e)}m${i}\x1B[39m`),t&&(i=`\x1B[${z0(t)+FP}m${i}\x1B[49m`)),i}function UP(i,e=["constructor"]){const t=Object.getPrototypeOf(i),n=Object.getOwnPropertyNames(t),s=i;for(const r of n){const o=s[r];typeof o=="function"&&(e.find(a=>r===a)||(s[r]=o.bind(i)))}}function ry(i,e){if(!i)throw new Error("Assertion failed")}function Pa(){var i,e,t;let n;if(Vu()&&Wp.performance)n=(e=(i=Wp==null?void 0:Wp.performance)==null?void 0:i.now)==null?void 0:e.call(i);else if("hrtime"in gd){const s=(t=gd==null?void 0:gd.hrtime)==null?void 0:t.call(gd);n=s[0]*1e3+s[1]/1e6}else n=Date.now();return n}const Na={debug:Vu()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},$P={enabled:!0,level:0};function Da(){}const U0={},$0={once:!0};class n2{constructor({id:e}={id:""}){this.VERSION=i2,this._startTs=Pa(),this._deltaTs=Pa(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new MP(`__probe-${this.id}__`,$P),this.timeStamp(`${this.id} started`),UP(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((Pa()-this._startTs).toPrecision(10))}getDelta(){return Number((Pa()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,t){this._storage.setConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw new Error(t||"Assertion failed")}warn(e){return this._getLogFunction(0,e,Na.warn,arguments,$0)}error(e){return this._getLogFunction(0,e,Na.error,arguments)}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t){return this._getLogFunction(e,t,Na.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,Na.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,Na.debug||Na.info,arguments,$0)}table(e,t,n){return t?this._getLogFunction(e,t,console.table||Da,n&&[n],{tag:HP(t)}):Da}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||Da)}group(e,t,n={collapsed:!1}){const s=j0({logLevel:e,message:t,opts:n}),{collapsed:r}=n;return s.method=(r?console.groupCollapsed:console.group)||console.info,this._getLogFunction(s)}groupCollapsed(e,t,n={}){return this.group(e,t,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||Da)}withGroup(e,t,n){this.group(e,t)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=s2(e)}_getLogFunction(e,t,n,s,r){if(this._shouldLog(e)){r=j0({logLevel:e,message:t,args:s,opts:r}),n=n||r.method,ry(n),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=Pa();const o=r.tag||r.message;if(r.once&&o)if(!U0[o])U0[o]=Pa();else return Da;return t=jP(this.id,r.message,r),n.bind(console,t,...r.args)}return Da}}n2.VERSION=i2;function s2(i){if(!i)return 0;let e;switch(typeof i){case"number":e=i;break;case"object":e=i.logLevel||i.priority||0;break;default:return 0}return ry(Number.isFinite(e)&&e>=0),e}function j0(i){const{logLevel:e,message:t}=i;i.logLevel=s2(e);const n=i.args?Array.from(i.args):[];for(;n.length&&n.shift()!==t;);switch(typeof e){case"string":case"function":t!==void 0&&n.unshift(t),i.message=e;break;case"object":Object.assign(i,e);break}typeof i.message=="function"&&(i.message=i.message());const s=typeof i.message;return ry(s==="string"||s==="object"),Object.assign(i,{args:n},i.opts)}function jP(i,e,t){if(typeof e=="string"){const n=t.time?BP(OP(t.total)):"";e=t.time?`${i}: ${n} ${e}`:`${i}: ${e}`,e=zP(e,t.color,t.background)}return e}function HP(i){for(const e in i)for(const t in i[e])return t||"untitled";return"empty"}const le=new n2({id:"luma.gl"}),Yp={};function oy(i="id"){Yp[i]=Yp[i]||1;const e=Yp[i]++;return`${i}-${e}`}class _n{constructor(e,t,n){if(U(this,"id"),U(this,"props"),U(this,"userData",{}),U(this,"_device"),U(this,"destroyed",!1),U(this,"allocatedBytes",0),U(this,"_attachedResources",new Set),!e)throw new Error("no device");this._device=e,this.props=VP(t,n);const s=this.props.id!=="undefined"?this.props.id:oy(this[Symbol.toStringTag]);this.props.id=s,this.id=s,this.userData=this.props.userData||{},this.addStats()}toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}destroy(){this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(const e of Object.values(this._attachedResources))e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}removeStats(){const e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get(`${t}s Active`).decrementCount()}trackAllocatedMemory(e,t=this[Symbol.toStringTag]){const n=this._device.statsManager.getStats("Resource Counts");n.get("GPU Memory").addCount(e),n.get(`${t} Memory`).addCount(e),this.allocatedBytes=e}trackDeallocatedMemory(e=this[Symbol.toStringTag]){const t=this._device.statsManager.getStats("Resource Counts");t.get("GPU Memory").subtractCount(this.allocatedBytes),t.get(`${e} Memory`).subtractCount(this.allocatedBytes),this.allocatedBytes=0}addStats(){const e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get("Resources Created").incrementCount(),e.get(`${t}s Created`).incrementCount(),e.get(`${t}s Active`).incrementCount()}}U(_n,"defaultProps",{id:"undefined",handle:void 0,userData:void 0});function VP(i,e){const t={...e};for(const n in i)i[n]!==void 0&&(t[n]=i[n]);return t}const Un=class ch extends _n{constructor(e,t){const n={...t};(t.usage||0)&ch.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?n.indexType="uint32":t.data instanceof Uint16Array&&(n.indexType="uint16")),delete n.data,super(e,n,ch.defaultProps),U(this,"usage"),U(this,"indexType"),U(this,"updateTimestamp"),U(this,"debugData",new ArrayBuffer(0)),this.usage=n.usage||0,this.indexType=n.indexType,this.updateTimestamp=e.incrementTimestamp()}get[Symbol.toStringTag](){return"Buffer"}clone(e){return this.device.createBuffer({...this.props,...e})}_setDebugData(e,t,n){const s=ArrayBuffer.isView(e)?e.buffer:e,r=Math.min(e?e.byteLength:n,ch.DEBUG_DATA_MAX_LENGTH);s===null?this.debugData=new ArrayBuffer(r):t===0&&n===s.byteLength?this.debugData=s.slice(0,r):this.debugData=s.slice(t,t+r)}};U(Un,"INDEX",16),U(Un,"VERTEX",32),U(Un,"UNIFORM",64),U(Un,"STORAGE",128),U(Un,"INDIRECT",256),U(Un,"QUERY_RESOLVE",512),U(Un,"MAP_READ",1),U(Un,"MAP_WRITE",2),U(Un,"COPY_SRC",4),U(Un,"COPY_DST",8),U(Un,"DEBUG_DATA_MAX_LENGTH",32),U(Un,"defaultProps",{..._n.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0});let ge=Un;function r2(i){const[e,t,n]=ay[i],s=i.includes("norm"),r=!s&&!i.startsWith("float"),o=i.startsWith("s");return{signedType:e,primitiveType:t,byteLength:n,normalized:s,integer:r,signed:o}}function GP(i){const e=i;switch(e){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return e}}function WP(i,e){switch(e){case 1:return i;case 2:return i+i%2;default:return i+(4-i%4)%4}}function YP(i){const e=ArrayBuffer.isView(i)?i.constructor:i;if(e===Uint8ClampedArray)return"uint8";const t=Object.values(ay).find(n=>e===n[4]);if(!t)throw new Error(e.name);return t[0]}function qP(i){const[,,,,e]=ay[i];return e}const ay={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]};function ly(i){let e;i.endsWith("-webgl")&&(i.replace("-webgl",""),e=!0);const[t,n]=i.split("x"),s=t,r=n?parseInt(n):1,o=r2(s),a={type:s,components:r,byteLength:o.byteLength*r,integer:o.integer,signed:o.signed,normalized:o.normalized};return e&&(a.webglOnly=!0),a}function XP(i,e,t){const n=t?GP(i):i;switch(n){case"unorm8":return e===1?"unorm8":e===3?"unorm8x3-webgl":`${n}x${e}`;case"snorm8":case"uint8":case"sint8":case"uint16":case"sint16":case"unorm16":case"snorm16":case"float16":if(e===1||e===3)throw new Error(`size: ${e}`);return`${n}x${e}`;default:return e===1?n:`${n}x${e}`}}function KP(i,e,t){if(!e||e>4)throw new Error(`size ${e}`);const n=e,s=YP(i);return XP(s,n,t)}function ZP(i){let e;switch(i.primitiveType){case"f32":e="float32";break;case"i32":e="sint32";break;case"u32":e="uint32";break;case"f16":return i.components<=2?"float16x2":"float16x4"}return i.components===1?e:`${e}x${i.components}`}const Hi="texture-compression-bc",Ft="texture-compression-astc",ir="texture-compression-etc2",QP="texture-compression-etc1-webgl",_d="texture-compression-pvrtc-webgl",qp="texture-compression-atc-webgl",yd="float32-renderable-webgl",Xp="float16-renderable-webgl",JP="rgb9e5ufloat-renderable-webgl",Kp="snorm8-renderable-webgl",oc="norm16-renderable-webgl",Zp="snorm16-renderable-webgl",bd="float32-filterable",H0="float16-filterable-webgl";function o2(i){const e=iN[i];if(!e)throw new Error(`Unsupported texture format ${i}`);return e}const eN={r8unorm:{},rg8unorm:{},"rgb8unorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},r8snorm:{render:Kp},rg8snorm:{render:Kp},"rgb8snorm-webgl":{},rgba8snorm:{render:Kp},r8uint:{},rg8uint:{},rgba8uint:{},r8sint:{},rg8sint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},r16unorm:{f:oc},rg16unorm:{render:oc},"rgb16unorm-webgl":{f:oc},rgba16unorm:{render:oc},r16snorm:{f:Zp},rg16snorm:{render:Zp},"rgb16snorm-webgl":{f:oc},rgba16snorm:{render:Zp},r16uint:{},rg16uint:{},rgba16uint:{},r16sint:{},rg16sint:{},rgba16sint:{},r16float:{render:Xp,filter:"float16-filterable-webgl"},rg16float:{render:Xp,filter:H0},rgba16float:{render:Xp,filter:H0},r32uint:{},rg32uint:{},rgba32uint:{},r32sint:{},rg32sint:{},rgba32sint:{},r32float:{render:yd,filter:bd},rg32float:{render:!1,filter:bd},"rgb32float-webgl":{render:yd,filter:bd},rgba32float:{render:yd,filter:bd},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:"rgb",packed:!0,render:JP},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:yd},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8"},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16"},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32"},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32"},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0}},tN={"bc1-rgb-unorm-webgl":{f:Hi},"bc1-rgb-unorm-srgb-webgl":{f:Hi},"bc1-rgba-unorm":{f:Hi},"bc1-rgba-unorm-srgb":{f:Hi},"bc2-rgba-unorm":{f:Hi},"bc2-rgba-unorm-srgb":{f:Hi},"bc3-rgba-unorm":{f:Hi},"bc3-rgba-unorm-srgb":{f:Hi},"bc4-r-unorm":{f:Hi},"bc4-r-snorm":{f:Hi},"bc5-rg-unorm":{f:Hi},"bc5-rg-snorm":{f:Hi},"bc6h-rgb-ufloat":{f:Hi},"bc6h-rgb-float":{f:Hi},"bc7-rgba-unorm":{f:Hi},"bc7-rgba-unorm-srgb":{f:Hi},"etc2-rgb8unorm":{f:ir},"etc2-rgb8unorm-srgb":{f:ir},"etc2-rgb8a1unorm":{f:ir},"etc2-rgb8a1unorm-srgb":{f:ir},"etc2-rgba8unorm":{f:ir},"etc2-rgba8unorm-srgb":{f:ir},"eac-r11unorm":{f:ir},"eac-r11snorm":{f:ir},"eac-rg11unorm":{f:ir},"eac-rg11snorm":{f:ir},"astc-4x4-unorm":{f:Ft},"astc-4x4-unorm-srgb":{f:Ft},"astc-5x4-unorm":{f:Ft},"astc-5x4-unorm-srgb":{f:Ft},"astc-5x5-unorm":{f:Ft},"astc-5x5-unorm-srgb":{f:Ft},"astc-6x5-unorm":{f:Ft},"astc-6x5-unorm-srgb":{f:Ft},"astc-6x6-unorm":{f:Ft},"astc-6x6-unorm-srgb":{f:Ft},"astc-8x5-unorm":{f:Ft},"astc-8x5-unorm-srgb":{f:Ft},"astc-8x6-unorm":{f:Ft},"astc-8x6-unorm-srgb":{f:Ft},"astc-8x8-unorm":{f:Ft},"astc-8x8-unorm-srgb":{f:Ft},"astc-10x5-unorm":{f:Ft},"astc-10x5-unorm-srgb":{f:Ft},"astc-10x6-unorm":{f:Ft},"astc-10x6-unorm-srgb":{f:Ft},"astc-10x8-unorm":{f:Ft},"astc-10x8-unorm-srgb":{f:Ft},"astc-10x10-unorm":{f:Ft},"astc-10x10-unorm-srgb":{f:Ft},"astc-12x10-unorm":{f:Ft},"astc-12x10-unorm-srgb":{f:Ft},"astc-12x12-unorm":{f:Ft},"astc-12x12-unorm-srgb":{f:Ft},"pvrtc-rgb4unorm-webgl":{f:_d},"pvrtc-rgba4unorm-webgl":{f:_d},"pvrtc-rbg2unorm-webgl":{f:_d},"pvrtc-rgba2unorm-webgl":{f:_d},"etc1-rbg-unorm-webgl":{f:QP},"atc-rgb-unorm-webgl":{f:qp},"atc-rgba-unorm-webgl":{f:qp},"atc-rgbai-unorm-webgl":{f:qp}},iN={...eN,...tN},nN=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],sN=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/;class rN{getInfo(e){return V0(e)}isColor(e){return e.startsWith("rgba")||e.startsWith("bgra")||e.startsWith("rgb")}isDepthStencil(e){return e.startsWith("depth")||e.startsWith("stencil")}isCompressed(e){return nN.some(t=>e.startsWith(t))}getCapabilities(e){const t=o2(e),n={format:e,create:t.f??!0,render:t.render??!0,filter:t.filter??!0,blend:t.blend??!0,store:t.store??!0},s=V0(e),r=e.startsWith("depth")||e.startsWith("stencil"),o=s==null?void 0:s.signed,a=s==null?void 0:s.integer,l=s==null?void 0:s.webgl;return n.render&&(n.render=!o),n.filter&&(n.filter=!r&&!o&&!a&&!l),n}}const Jc=new rN;function V0(i){let e=oN(i);if(Jc.isCompressed(i)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0;const n=aN(i);n&&(e.blockWidth=n.blockWidth,e.blockHeight=n.blockHeight)}const t=sN.exec(i);if(t){const[,n,s,r,o,a]=t,l=`${r}${s}`,c=r2(l),u=c.byteLength*8,d=n.length,h=[u,d>=2?u:0,d>=3?u:0,d>=4?u:0];e={format:i,attachment:e.attachment,dataType:c.signedType,components:d,channels:n,integer:c.integer,signed:c.signed,normalized:c.normalized,bitsPerChannel:h,bytesPerPixel:c.byteLength*n.length,packed:e.packed,srgb:e.srgb},a==="-webgl"&&(e.webgl=!0),o==="-srgb"&&(e.srgb=!0)}return i.endsWith("-webgl")&&(e.webgl=!0),i.endsWith("-srgb")&&(e.srgb=!0),e}function oN(i){var e;const t=o2(i),n=t.bytesPerPixel||1,s=t.bitsPerChannel||[8,8,8,8];return delete t.bitsPerChannel,delete t.bytesPerPixel,delete t.f,delete t.render,delete t.filter,delete t.blend,delete t.store,{...t,format:i,attachment:t.attachment||"color",channels:t.channels||"r",components:t.components||((e=t.channels)==null?void 0:e.length)||1,bytesPerPixel:n,bitsPerChannel:s,dataType:t.dataType||"uint8",srgb:t.srgb??!1,packed:t.packed??!1,webgl:t.webgl??!1,integer:t.integer??!1,signed:t.signed??!1,normalized:t.normalized??!1,compressed:t.compressed??!1}}function aN(i){const e=/.*-(\d+)x(\d+)-.*/.exec(i);if(e){const[,t,n]=e;return{blockWidth:Number(t),blockHeight:Number(n)}}return null}function lN(i){return typeof ImageData<"u"&&i instanceof ImageData||typeof ImageBitmap<"u"&&i instanceof ImageBitmap||typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&i instanceof HTMLVideoElement||typeof VideoFrame<"u"&&i instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas}function cN(i){if(typeof ImageData<"u"&&i instanceof ImageData||typeof ImageBitmap<"u"&&i instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas)return{width:i.width,height:i.height};if(typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement)return{width:i.naturalWidth,height:i.naturalHeight};if(typeof HTMLVideoElement<"u"&&i instanceof HTMLVideoElement)return{width:i.videoWidth,height:i.videoHeight};if(typeof VideoFrame<"u"&&i instanceof VideoFrame)return{width:i.displayWidth,height:i.displayHeight};throw new Error("Unknown image type")}class hte{}class fte{constructor(e=[],t){U(this,"features"),U(this,"disabledFeatures"),this.features=new Set(e),this.disabledFeatures=t||{}}*[Symbol.iterator](){yield*this.features}has(e){var t;return!((t=this.disabledFeatures)!=null&&t[e])&&this.features.has(e)}}const a2=class l2{constructor(e){U(this,"id"),U(this,"props"),U(this,"userData",{}),U(this,"statsManager",t2),U(this,"timestamp",0),U(this,"_reused",!1),U(this,"_lumaData",{}),U(this,"_textureCaps",{}),this.props={...l2.defaultProps,...e},this.id=this.props.id||oy(this[Symbol.toStringTag].toLowerCase())}get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}getVertexFormatInfo(e){return ly(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return Jc.getInfo(e)}getTextureFormatCapabilities(e){let t=this._textureCaps[e];if(!t){const n=this._getDeviceTextureFormatCapabilities(e);t=this._getDeviceSpecificTextureFormatCapabilities(n),this._textureCaps[e]=t}return t}getMipLevelCount(e,t,n=1){const s=Math.max(e,t,n);return 1+Math.floor(Math.log2(s))}isExternalImage(e){return lN(e)}getExternalImageSize(e){return cN(e)}isTextureFormatSupported(e){return this.getTextureFormatCapabilities(e).create}isTextureFormatFilterable(e){return this.getTextureFormatCapabilities(e).filter}isTextureFormatRenderable(e){return this.getTextureFormatCapabilities(e).render}isTextureFormatCompressed(e){return Jc.isCompressed(e)}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){var e;(e=this.commandEncoder)==null||e.popDebugGroup()}insertDebugMarker(e){var t;(t=this.commandEncoder)==null||t.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,t,...n){return this.props.onError(e,t)?()=>{}:le.error(e.message,t,...n)}debug(){if(this.props.debug)debugger;else le.once(0,`'Type luma.log.set({debug: true}) in console to enable debug breakpoints', + */const eR=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]],hd=Vl("shield-alert",eR),tR=$.createContext(null);function K_(){return $.useContext(tR)}var iR=Object.defineProperty,nR=(i,e,t)=>e in i?iR(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,U=(i,e,t)=>nR(i,typeof e!="symbol"?e+"":e,t),fg="http://www.w3.org/1999/xhtml";const x0={svg:"http://www.w3.org/2000/svg",xhtml:fg,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function np(i){var e=i+="",t=e.indexOf(":");return t>=0&&(e=i.slice(0,t))!=="xmlns"&&(i=i.slice(t+1)),x0.hasOwnProperty(e)?{space:x0[e],local:i}:i}function sR(i){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===fg&&e.documentElement.namespaceURI===fg?e.createElement(i):e.createElementNS(t,i)}}function rR(i){return function(){return this.ownerDocument.createElementNS(i.space,i.local)}}function IS(i){var e=np(i);return(e.local?rR:sR)(e)}function oR(){}function Z_(i){return i==null?oR:function(){return this.querySelector(i)}}function aR(i){typeof i!="function"&&(i=Z_(i));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s=C&&(C=S+1);!(A=g[C])&&++C=0;)(o=n[s])&&(r&&o.compareDocumentPosition(r)^4&&r.parentNode.insertBefore(o,r),r=o);return this}function PR(i){i||(i=NR);function e(d,h){return d&&h?i(d.__data__,h.__data__):!d-!h}for(var t=this._groups,n=t.length,s=new Array(n),r=0;re?1:i>=e?0:NaN}function DR(){var i=arguments[0];return arguments[0]=this,i.apply(null,arguments),this}function MR(){return Array.from(this)}function OR(){for(var i=this._groups,e=0,t=i.length;e1?this.each((e==null?YR:typeof e=="function"?XR:qR)(i,e,t??"")):El(this.node(),i)}function El(i,e){return i.style.getPropertyValue(e)||DS(i).getComputedStyle(i,null).getPropertyValue(e)}function ZR(i){return function(){delete this[i]}}function QR(i,e){return function(){this[i]=e}}function JR(i,e){return function(){var t=e.apply(this,arguments);t==null?delete this[i]:this[i]=t}}function e4(i,e){return arguments.length>1?this.each((e==null?ZR:typeof e=="function"?JR:QR)(i,e)):this.node()[i]}function MS(i){return i.trim().split(/^|\s+/)}function Q_(i){return i.classList||new OS(i)}function OS(i){this._node=i,this._names=MS(i.getAttribute("class")||"")}OS.prototype={add:function(i){var e=this._names.indexOf(i);e<0&&(this._names.push(i),this._node.setAttribute("class",this._names.join(" ")))},remove:function(i){var e=this._names.indexOf(i);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(i){return this._names.indexOf(i)>=0}};function BS(i,e){for(var t=Q_(i),n=-1,s=e.length;++n=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function A4(i){return function(){var e=this.__on;if(e){for(var t=0,n=-1,s=e.length,r;t{}};function sp(){for(var i=0,e=arguments.length,t={},n;i=0&&(n=t.slice(s+1),t=t.slice(0,s)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}rh.prototype=sp.prototype={constructor:rh,on:function(i,e){var t=this._,n=F4(i+"",t),s,r=-1,o=n.length;if(arguments.length<2){for(;++r0)for(var t=new Array(s),n=0,s,r;n=0&&i._call.call(null,e),i=i._next;--Cl}function S0(){ga=(Hh=uu.now())+rp,Cl=Pc=0;try{$4()}finally{Cl=0,H4(),ga=0}}function j4(){var i=uu.now(),e=i-Hh;e>$S&&(rp-=e,Hh=i)}function H4(){for(var i,e=jh,t,n=1/0;e;)e._call?(n>e._time&&(n=e._time),i=e,e=e._next):(t=e._next,e._next=null,e=i?i._next=t:jh=t);Nc=i,pg(n)}function pg(i){if(!Cl){Pc&&(Pc=clearTimeout(Pc));var e=i-ga;e>24?(i<1/0&&(Pc=setTimeout(S0,i-uu.now()-rp)),rc&&(rc=clearInterval(rc))):(rc||(Hh=uu.now(),rc=setInterval(j4,$S)),Cl=1,jS(S0))}}function E0(i,e,t){var n=new Vh;return e=e==null?0:+e,n.restart(s=>{n.stop(),i(s+e)},e,t),n}var V4=sp("start","end","cancel","interrupt"),G4=[],VS=0,C0=1,mg=2,oh=3,T0=4,gg=5,ah=6;function op(i,e,t,n,s,r){var o=i.__transition;if(!o)i.__transition={};else if(t in o)return;W4(i,t,{name:e,index:n,group:s,on:V4,tween:G4,time:r.time,delay:r.delay,duration:r.duration,ease:r.ease,timer:null,state:VS})}function ey(i,e){var t=Gs(i,e);if(t.state>VS)throw new Error("too late; already scheduled");return t}function Tr(i,e){var t=Gs(i,e);if(t.state>oh)throw new Error("too late; already running");return t}function Gs(i,e){var t=i.__transition;if(!t||!(t=t[e]))throw new Error("transition not found");return t}function W4(i,e,t){var n=i.__transition,s;n[e]=t,t.timer=HS(r,0,t.time);function r(c){t.state=C0,t.timer.restart(o,t.delay,t.time),t.delay<=c&&o(c-t.delay)}function o(c){var u,d,h,p;if(t.state!==C0)return l();for(u in n)if(p=n[u],p.name===t.name){if(p.state===oh)return E0(o);p.state===T0?(p.state=ah,p.timer.stop(),p.on.call("interrupt",i,i.__data__,p.index,p.group),delete n[u]):+umg&&n.state>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?fd(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?fd(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=X4.exec(i))?new In(e[1],e[2],e[3],1):(e=K4.exec(i))?new In(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Z4.exec(i))?fd(e[1],e[2],e[3],e[4]):(e=Q4.exec(i))?fd(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=J4.exec(i))?N0(e[1],e[2]/100,e[3]/100,1):(e=e5.exec(i))?N0(e[1],e[2]/100,e[3]/100,e[4]):k0.hasOwnProperty(i)?L0(k0[i]):i==="transparent"?new In(NaN,NaN,NaN,0):null}function L0(i){return new In(i>>16&255,i>>8&255,i&255,1)}function fd(i,e,t,n){return n<=0&&(i=e=t=NaN),new In(i,e,t,n)}function n5(i){return i instanceof Hu||(i=Uo(i)),i?(i=i.rgb(),new In(i.r,i.g,i.b,i.opacity)):new In}function _g(i,e,t,n){return arguments.length===1?n5(i):new In(i,e,t,n??1)}function In(i,e,t,n){this.r=+i,this.g=+e,this.b=+t,this.opacity=+n}ty(In,_g,GS(Hu,{brighter(i){return i=i==null?Gh:Math.pow(Gh,i),new In(this.r*i,this.g*i,this.b*i,this.opacity)},darker(i){return i=i==null?du:Math.pow(du,i),new In(this.r*i,this.g*i,this.b*i,this.opacity)},rgb(){return this},clamp(){return new In(ua(this.r),ua(this.g),ua(this.b),Wh(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:R0,formatHex:R0,formatHex8:s5,formatRgb:P0,toString:P0}));function R0(){return`#${oa(this.r)}${oa(this.g)}${oa(this.b)}`}function s5(){return`#${oa(this.r)}${oa(this.g)}${oa(this.b)}${oa((isNaN(this.opacity)?1:this.opacity)*255)}`}function P0(){const i=Wh(this.opacity);return`${i===1?"rgb(":"rgba("}${ua(this.r)}, ${ua(this.g)}, ${ua(this.b)}${i===1?")":`, ${i})`}`}function Wh(i){return isNaN(i)?1:Math.max(0,Math.min(1,i))}function ua(i){return Math.max(0,Math.min(255,Math.round(i)||0))}function oa(i){return i=ua(i),(i<16?"0":"")+i.toString(16)}function N0(i,e,t,n){return n<=0?i=e=t=NaN:t<=0||t>=1?i=e=NaN:e<=0&&(i=NaN),new Us(i,e,t,n)}function WS(i){if(i instanceof Us)return new Us(i.h,i.s,i.l,i.opacity);if(i instanceof Hu||(i=Uo(i)),!i)return new Us;if(i instanceof Us)return i;i=i.rgb();var e=i.r/255,t=i.g/255,n=i.b/255,s=Math.min(e,t,n),r=Math.max(e,t,n),o=NaN,a=r-s,l=(r+s)/2;return a?(e===r?o=(t-n)/a+(t0&&l<1?0:o,new Us(o,a,l,i.opacity)}function r5(i,e,t,n){return arguments.length===1?WS(i):new Us(i,e,t,n??1)}function Us(i,e,t,n){this.h=+i,this.s=+e,this.l=+t,this.opacity=+n}ty(Us,r5,GS(Hu,{brighter(i){return i=i==null?Gh:Math.pow(Gh,i),new Us(this.h,this.s,this.l*i,this.opacity)},darker(i){return i=i==null?du:Math.pow(du,i),new Us(this.h,this.s,this.l*i,this.opacity)},rgb(){var i=this.h%360+(this.h<0)*360,e=isNaN(i)||isNaN(this.s)?0:this.s,t=this.l,n=t+(t<.5?t:1-t)*e,s=2*t-n;return new In(Vp(i>=240?i-240:i+120,s,n),Vp(i,s,n),Vp(i<120?i+240:i-120,s,n),this.opacity)},clamp(){return new Us(D0(this.h),pd(this.s),pd(this.l),Wh(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const i=Wh(this.opacity);return`${i===1?"hsl(":"hsla("}${D0(this.h)}, ${pd(this.s)*100}%, ${pd(this.l)*100}%${i===1?")":`, ${i})`}`}}));function D0(i){return i=(i||0)%360,i<0?i+360:i}function pd(i){return Math.max(0,Math.min(1,i||0))}function Vp(i,e,t){return(i<60?e+(t-e)*i/60:i<180?t:i<240?e+(t-e)*(240-i)/60:e)*255}const iy=i=>()=>i;function o5(i,e){return function(t){return i+t*e}}function a5(i,e,t){return i=Math.pow(i,t),e=Math.pow(e,t)-i,t=1/t,function(n){return Math.pow(i+n*e,t)}}function l5(i){return(i=+i)==1?YS:function(e,t){return t-e?a5(e,t,i):iy(isNaN(e)?t:e)}}function YS(i,e){var t=e-i;return t?o5(i,t):iy(isNaN(i)?e:i)}const Yh=(function i(e){var t=l5(e);function n(s,r){var o=t((s=_g(s)).r,(r=_g(r)).r),a=t(s.g,r.g),l=t(s.b,r.b),c=YS(s.opacity,r.opacity);return function(u){return s.r=o(u),s.g=a(u),s.b=l(u),s.opacity=c(u),s+""}}return n.gamma=i,n})(1);function c5(i,e){e||(e=[]);var t=i?Math.min(e.length,i.length):0,n=e.slice(),s;return function(r){for(s=0;st&&(r=e.slice(t,r),a[o]?a[o]+=r:a[++o]=r),(n=n[0])===(s=s[0])?a[o]?a[o]+=s:a[++o]=s:(a[++o]=null,l.push({i:o,x:Fs(n,s)})),t=Gp.lastIndex;return t180?u+=360:u-c>180&&(c+=360),h.push({i:d.push(s(d)+"rotate(",null,n)-2,x:Fs(c,u)})):u&&d.push(s(d)+"rotate("+u+n)}function a(c,u,d,h){c!==u?h.push({i:d.push(s(d)+"skewX(",null,n)-2,x:Fs(c,u)}):u&&d.push(s(d)+"skewX("+u+n)}function l(c,u,d,h,p,m){if(c!==d||u!==h){var y=p.push(s(p)+"scale(",null,",",null,")");m.push({i:y-4,x:Fs(c,d)},{i:y-2,x:Fs(u,h)})}else(d!==1||h!==1)&&p.push(s(p)+"scale("+d+","+h+")")}return function(c,u){var d=[],h=[];return c=i(c),u=i(u),r(c.translateX,c.translateY,u.translateX,u.translateY,d,h),o(c.rotate,u.rotate,d,h),a(c.skewX,u.skewX,d,h),l(c.scaleX,c.scaleY,u.scaleX,u.scaleY,d,h),c=u=null,function(p){for(var m=-1,y=h.length,g;++m=0&&(e=e.slice(0,t)),!e||e==="start"})}function J5(i,e,t){var n,s,r=Q5(e)?ey:Tr;return function(){var o=r(this,i),a=o.on;a!==n&&(s=(n=a).copy()).on(e,t),o.on=s}}function eP(i,e){var t=this._id;return arguments.length<2?Gs(this.node(),t).on.on(i):this.each(J5(t,i,e))}function tP(i){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==i)return;e&&e.removeChild(this)}}function iP(){return this.on("end.remove",tP(this._id))}function nP(i){var e=this._name,t=this._id;typeof i!="function"&&(i=Z_(i));for(var n=this._groups,s=n.length,r=new Array(s),o=0;o0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}class RP{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(const e of Object.values(this.stats))e.reset();return this}forEach(e){for(const t of Object.values(this.stats))e(t)}getTable(){const e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(t=>this._getOrCreate(t))}_getOrCreate(e){const{name:t,type:n}=e;let s=this.stats[t];return s||(e instanceof F0?s=e:s=new F0(t,n),this.stats[t]=s),s}}class PP{constructor(){U(this,"stats",new Map)}getStats(e){return this.get(e)}get(e){return this.stats.has(e)||this.stats.set(e,new RP({id:e})),this.stats.get(e)}}const t2=new PP,Wp=globalThis,gd=globalThis.process||{},ute=globalThis.navigator||{};function NP(i){var e,t;if(typeof window<"u"&&((e=window.process)==null?void 0:e.type)==="renderer"||typeof process<"u"&&(t=process.versions)!=null&&t.electron)return!0;const n=typeof navigator<"u"&&navigator.userAgent;return!!(n&&n.indexOf("Electron")>=0)}function Vu(){return!(typeof process=="object"&&String(process)==="[object process]"&&!(process!=null&&process.browser))||NP()}const i2="4.1.0";function DP(i){try{const e=window[i],t="__storage_test__";return e.setItem(t,t),e.removeItem(t),e}catch{return null}}class MP{constructor(e,t,n="sessionStorage"){this.storage=DP(n),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){const t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}}_loadConfiguration(){let e={};if(this.storage){const t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}function OP(i){let e;return i<10?e=`${i.toFixed(2)}ms`:i<100?e=`${i.toFixed(1)}ms`:i<1e3?e=`${i.toFixed(0)}ms`:e=`${(i/1e3).toFixed(2)}s`,e}function BP(i,e=8){const t=Math.max(e-i.length,0);return`${" ".repeat(t)}${i}`}var qh;(function(i){i[i.BLACK=30]="BLACK",i[i.RED=31]="RED",i[i.GREEN=32]="GREEN",i[i.YELLOW=33]="YELLOW",i[i.BLUE=34]="BLUE",i[i.MAGENTA=35]="MAGENTA",i[i.CYAN=36]="CYAN",i[i.WHITE=37]="WHITE",i[i.BRIGHT_BLACK=90]="BRIGHT_BLACK",i[i.BRIGHT_RED=91]="BRIGHT_RED",i[i.BRIGHT_GREEN=92]="BRIGHT_GREEN",i[i.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",i[i.BRIGHT_BLUE=94]="BRIGHT_BLUE",i[i.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",i[i.BRIGHT_CYAN=96]="BRIGHT_CYAN",i[i.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(qh||(qh={}));const FP=10;function z0(i){return typeof i!="string"?i:(i=i.toUpperCase(),qh[i]||qh.WHITE)}function zP(i,e,t){return!Vu&&typeof i=="string"&&(e&&(i=`\x1B[${z0(e)}m${i}\x1B[39m`),t&&(i=`\x1B[${z0(t)+FP}m${i}\x1B[49m`)),i}function UP(i,e=["constructor"]){const t=Object.getPrototypeOf(i),n=Object.getOwnPropertyNames(t),s=i;for(const r of n){const o=s[r];typeof o=="function"&&(e.find(a=>r===a)||(s[r]=o.bind(i)))}}function ry(i,e){if(!i)throw new Error("Assertion failed")}function Pa(){var i,e,t;let n;if(Vu()&&Wp.performance)n=(e=(i=Wp==null?void 0:Wp.performance)==null?void 0:i.now)==null?void 0:e.call(i);else if("hrtime"in gd){const s=(t=gd==null?void 0:gd.hrtime)==null?void 0:t.call(gd);n=s[0]*1e3+s[1]/1e6}else n=Date.now();return n}const Na={debug:Vu()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},$P={enabled:!0,level:0};function Da(){}const U0={},$0={once:!0};class n2{constructor({id:e}={id:""}){this.VERSION=i2,this._startTs=Pa(),this._deltaTs=Pa(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new MP(`__probe-${this.id}__`,$P),this.timeStamp(`${this.id} started`),UP(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((Pa()-this._startTs).toPrecision(10))}getDelta(){return Number((Pa()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,t){this._storage.setConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw new Error(t||"Assertion failed")}warn(e){return this._getLogFunction(0,e,Na.warn,arguments,$0)}error(e){return this._getLogFunction(0,e,Na.error,arguments)}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t){return this._getLogFunction(e,t,Na.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,Na.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,Na.debug||Na.info,arguments,$0)}table(e,t,n){return t?this._getLogFunction(e,t,console.table||Da,n&&[n],{tag:HP(t)}):Da}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||Da)}group(e,t,n={collapsed:!1}){const s=j0({logLevel:e,message:t,opts:n}),{collapsed:r}=n;return s.method=(r?console.groupCollapsed:console.group)||console.info,this._getLogFunction(s)}groupCollapsed(e,t,n={}){return this.group(e,t,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||Da)}withGroup(e,t,n){this.group(e,t)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=s2(e)}_getLogFunction(e,t,n,s,r){if(this._shouldLog(e)){r=j0({logLevel:e,message:t,args:s,opts:r}),n=n||r.method,ry(n),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=Pa();const o=r.tag||r.message;if(r.once&&o)if(!U0[o])U0[o]=Pa();else return Da;return t=jP(this.id,r.message,r),n.bind(console,t,...r.args)}return Da}}n2.VERSION=i2;function s2(i){if(!i)return 0;let e;switch(typeof i){case"number":e=i;break;case"object":e=i.logLevel||i.priority||0;break;default:return 0}return ry(Number.isFinite(e)&&e>=0),e}function j0(i){const{logLevel:e,message:t}=i;i.logLevel=s2(e);const n=i.args?Array.from(i.args):[];for(;n.length&&n.shift()!==t;);switch(typeof e){case"string":case"function":t!==void 0&&n.unshift(t),i.message=e;break;case"object":Object.assign(i,e);break}typeof i.message=="function"&&(i.message=i.message());const s=typeof i.message;return ry(s==="string"||s==="object"),Object.assign(i,{args:n},i.opts)}function jP(i,e,t){if(typeof e=="string"){const n=t.time?BP(OP(t.total)):"";e=t.time?`${i}: ${n} ${e}`:`${i}: ${e}`,e=zP(e,t.color,t.background)}return e}function HP(i){for(const e in i)for(const t in i[e])return t||"untitled";return"empty"}const le=new n2({id:"luma.gl"}),Yp={};function oy(i="id"){Yp[i]=Yp[i]||1;const e=Yp[i]++;return`${i}-${e}`}class _n{constructor(e,t,n){if(U(this,"id"),U(this,"props"),U(this,"userData",{}),U(this,"_device"),U(this,"destroyed",!1),U(this,"allocatedBytes",0),U(this,"_attachedResources",new Set),!e)throw new Error("no device");this._device=e,this.props=VP(t,n);const s=this.props.id!=="undefined"?this.props.id:oy(this[Symbol.toStringTag]);this.props.id=s,this.id=s,this.userData=this.props.userData||{},this.addStats()}toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}destroy(){this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(const e of Object.values(this._attachedResources))e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}removeStats(){const e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get(`${t}s Active`).decrementCount()}trackAllocatedMemory(e,t=this[Symbol.toStringTag]){const n=this._device.statsManager.getStats("Resource Counts");n.get("GPU Memory").addCount(e),n.get(`${t} Memory`).addCount(e),this.allocatedBytes=e}trackDeallocatedMemory(e=this[Symbol.toStringTag]){const t=this._device.statsManager.getStats("Resource Counts");t.get("GPU Memory").subtractCount(this.allocatedBytes),t.get(`${e} Memory`).subtractCount(this.allocatedBytes),this.allocatedBytes=0}addStats(){const e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get("Resources Created").incrementCount(),e.get(`${t}s Created`).incrementCount(),e.get(`${t}s Active`).incrementCount()}}U(_n,"defaultProps",{id:"undefined",handle:void 0,userData:void 0});function VP(i,e){const t={...e};for(const n in i)i[n]!==void 0&&(t[n]=i[n]);return t}const Un=class ch extends _n{constructor(e,t){const n={...t};(t.usage||0)&ch.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?n.indexType="uint32":t.data instanceof Uint16Array&&(n.indexType="uint16")),delete n.data,super(e,n,ch.defaultProps),U(this,"usage"),U(this,"indexType"),U(this,"updateTimestamp"),U(this,"debugData",new ArrayBuffer(0)),this.usage=n.usage||0,this.indexType=n.indexType,this.updateTimestamp=e.incrementTimestamp()}get[Symbol.toStringTag](){return"Buffer"}clone(e){return this.device.createBuffer({...this.props,...e})}_setDebugData(e,t,n){const s=ArrayBuffer.isView(e)?e.buffer:e,r=Math.min(e?e.byteLength:n,ch.DEBUG_DATA_MAX_LENGTH);s===null?this.debugData=new ArrayBuffer(r):t===0&&n===s.byteLength?this.debugData=s.slice(0,r):this.debugData=s.slice(t,t+r)}};U(Un,"INDEX",16),U(Un,"VERTEX",32),U(Un,"UNIFORM",64),U(Un,"STORAGE",128),U(Un,"INDIRECT",256),U(Un,"QUERY_RESOLVE",512),U(Un,"MAP_READ",1),U(Un,"MAP_WRITE",2),U(Un,"COPY_SRC",4),U(Un,"COPY_DST",8),U(Un,"DEBUG_DATA_MAX_LENGTH",32),U(Un,"defaultProps",{..._n.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0});let ge=Un;function r2(i){const[e,t,n]=ay[i],s=i.includes("norm"),r=!s&&!i.startsWith("float"),o=i.startsWith("s");return{signedType:e,primitiveType:t,byteLength:n,normalized:s,integer:r,signed:o}}function GP(i){const e=i;switch(e){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return e}}function WP(i,e){switch(e){case 1:return i;case 2:return i+i%2;default:return i+(4-i%4)%4}}function YP(i){const e=ArrayBuffer.isView(i)?i.constructor:i;if(e===Uint8ClampedArray)return"uint8";const t=Object.values(ay).find(n=>e===n[4]);if(!t)throw new Error(e.name);return t[0]}function qP(i){const[,,,,e]=ay[i];return e}const ay={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]};function ly(i){let e;i.endsWith("-webgl")&&(i.replace("-webgl",""),e=!0);const[t,n]=i.split("x"),s=t,r=n?parseInt(n):1,o=r2(s),a={type:s,components:r,byteLength:o.byteLength*r,integer:o.integer,signed:o.signed,normalized:o.normalized};return e&&(a.webglOnly=!0),a}function XP(i,e,t){const n=t?GP(i):i;switch(n){case"unorm8":return e===1?"unorm8":e===3?"unorm8x3-webgl":`${n}x${e}`;case"snorm8":case"uint8":case"sint8":case"uint16":case"sint16":case"unorm16":case"snorm16":case"float16":if(e===1||e===3)throw new Error(`size: ${e}`);return`${n}x${e}`;default:return e===1?n:`${n}x${e}`}}function KP(i,e,t){if(!e||e>4)throw new Error(`size ${e}`);const n=e,s=YP(i);return XP(s,n,t)}function ZP(i){let e;switch(i.primitiveType){case"f32":e="float32";break;case"i32":e="sint32";break;case"u32":e="uint32";break;case"f16":return i.components<=2?"float16x2":"float16x4"}return i.components===1?e:`${e}x${i.components}`}const Hi="texture-compression-bc",Ft="texture-compression-astc",ir="texture-compression-etc2",QP="texture-compression-etc1-webgl",_d="texture-compression-pvrtc-webgl",qp="texture-compression-atc-webgl",yd="float32-renderable-webgl",Xp="float16-renderable-webgl",JP="rgb9e5ufloat-renderable-webgl",Kp="snorm8-renderable-webgl",oc="norm16-renderable-webgl",Zp="snorm16-renderable-webgl",bd="float32-filterable",H0="float16-filterable-webgl";function o2(i){const e=iN[i];if(!e)throw new Error(`Unsupported texture format ${i}`);return e}const eN={r8unorm:{},rg8unorm:{},"rgb8unorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},r8snorm:{render:Kp},rg8snorm:{render:Kp},"rgb8snorm-webgl":{},rgba8snorm:{render:Kp},r8uint:{},rg8uint:{},rgba8uint:{},r8sint:{},rg8sint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},r16unorm:{f:oc},rg16unorm:{render:oc},"rgb16unorm-webgl":{f:oc},rgba16unorm:{render:oc},r16snorm:{f:Zp},rg16snorm:{render:Zp},"rgb16snorm-webgl":{f:oc},rgba16snorm:{render:Zp},r16uint:{},rg16uint:{},rgba16uint:{},r16sint:{},rg16sint:{},rgba16sint:{},r16float:{render:Xp,filter:"float16-filterable-webgl"},rg16float:{render:Xp,filter:H0},rgba16float:{render:Xp,filter:H0},r32uint:{},rg32uint:{},rgba32uint:{},r32sint:{},rg32sint:{},rgba32sint:{},r32float:{render:yd,filter:bd},rg32float:{render:!1,filter:bd},"rgb32float-webgl":{render:yd,filter:bd},rgba32float:{render:yd,filter:bd},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:"rgb",packed:!0,render:JP},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:yd},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8"},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16"},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32"},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32"},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0}},tN={"bc1-rgb-unorm-webgl":{f:Hi},"bc1-rgb-unorm-srgb-webgl":{f:Hi},"bc1-rgba-unorm":{f:Hi},"bc1-rgba-unorm-srgb":{f:Hi},"bc2-rgba-unorm":{f:Hi},"bc2-rgba-unorm-srgb":{f:Hi},"bc3-rgba-unorm":{f:Hi},"bc3-rgba-unorm-srgb":{f:Hi},"bc4-r-unorm":{f:Hi},"bc4-r-snorm":{f:Hi},"bc5-rg-unorm":{f:Hi},"bc5-rg-snorm":{f:Hi},"bc6h-rgb-ufloat":{f:Hi},"bc6h-rgb-float":{f:Hi},"bc7-rgba-unorm":{f:Hi},"bc7-rgba-unorm-srgb":{f:Hi},"etc2-rgb8unorm":{f:ir},"etc2-rgb8unorm-srgb":{f:ir},"etc2-rgb8a1unorm":{f:ir},"etc2-rgb8a1unorm-srgb":{f:ir},"etc2-rgba8unorm":{f:ir},"etc2-rgba8unorm-srgb":{f:ir},"eac-r11unorm":{f:ir},"eac-r11snorm":{f:ir},"eac-rg11unorm":{f:ir},"eac-rg11snorm":{f:ir},"astc-4x4-unorm":{f:Ft},"astc-4x4-unorm-srgb":{f:Ft},"astc-5x4-unorm":{f:Ft},"astc-5x4-unorm-srgb":{f:Ft},"astc-5x5-unorm":{f:Ft},"astc-5x5-unorm-srgb":{f:Ft},"astc-6x5-unorm":{f:Ft},"astc-6x5-unorm-srgb":{f:Ft},"astc-6x6-unorm":{f:Ft},"astc-6x6-unorm-srgb":{f:Ft},"astc-8x5-unorm":{f:Ft},"astc-8x5-unorm-srgb":{f:Ft},"astc-8x6-unorm":{f:Ft},"astc-8x6-unorm-srgb":{f:Ft},"astc-8x8-unorm":{f:Ft},"astc-8x8-unorm-srgb":{f:Ft},"astc-10x5-unorm":{f:Ft},"astc-10x5-unorm-srgb":{f:Ft},"astc-10x6-unorm":{f:Ft},"astc-10x6-unorm-srgb":{f:Ft},"astc-10x8-unorm":{f:Ft},"astc-10x8-unorm-srgb":{f:Ft},"astc-10x10-unorm":{f:Ft},"astc-10x10-unorm-srgb":{f:Ft},"astc-12x10-unorm":{f:Ft},"astc-12x10-unorm-srgb":{f:Ft},"astc-12x12-unorm":{f:Ft},"astc-12x12-unorm-srgb":{f:Ft},"pvrtc-rgb4unorm-webgl":{f:_d},"pvrtc-rgba4unorm-webgl":{f:_d},"pvrtc-rbg2unorm-webgl":{f:_d},"pvrtc-rgba2unorm-webgl":{f:_d},"etc1-rbg-unorm-webgl":{f:QP},"atc-rgb-unorm-webgl":{f:qp},"atc-rgba-unorm-webgl":{f:qp},"atc-rgbai-unorm-webgl":{f:qp}},iN={...eN,...tN},nN=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],sN=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/;class rN{getInfo(e){return V0(e)}isColor(e){return e.startsWith("rgba")||e.startsWith("bgra")||e.startsWith("rgb")}isDepthStencil(e){return e.startsWith("depth")||e.startsWith("stencil")}isCompressed(e){return nN.some(t=>e.startsWith(t))}getCapabilities(e){const t=o2(e),n={format:e,create:t.f??!0,render:t.render??!0,filter:t.filter??!0,blend:t.blend??!0,store:t.store??!0},s=V0(e),r=e.startsWith("depth")||e.startsWith("stencil"),o=s==null?void 0:s.signed,a=s==null?void 0:s.integer,l=s==null?void 0:s.webgl;return n.render&&(n.render=!o),n.filter&&(n.filter=!r&&!o&&!a&&!l),n}}const Jc=new rN;function V0(i){let e=oN(i);if(Jc.isCompressed(i)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0;const n=aN(i);n&&(e.blockWidth=n.blockWidth,e.blockHeight=n.blockHeight)}const t=sN.exec(i);if(t){const[,n,s,r,o,a]=t,l=`${r}${s}`,c=r2(l),u=c.byteLength*8,d=n.length,h=[u,d>=2?u:0,d>=3?u:0,d>=4?u:0];e={format:i,attachment:e.attachment,dataType:c.signedType,components:d,channels:n,integer:c.integer,signed:c.signed,normalized:c.normalized,bitsPerChannel:h,bytesPerPixel:c.byteLength*n.length,packed:e.packed,srgb:e.srgb},a==="-webgl"&&(e.webgl=!0),o==="-srgb"&&(e.srgb=!0)}return i.endsWith("-webgl")&&(e.webgl=!0),i.endsWith("-srgb")&&(e.srgb=!0),e}function oN(i){var e;const t=o2(i),n=t.bytesPerPixel||1,s=t.bitsPerChannel||[8,8,8,8];return delete t.bitsPerChannel,delete t.bytesPerPixel,delete t.f,delete t.render,delete t.filter,delete t.blend,delete t.store,{...t,format:i,attachment:t.attachment||"color",channels:t.channels||"r",components:t.components||((e=t.channels)==null?void 0:e.length)||1,bytesPerPixel:n,bitsPerChannel:s,dataType:t.dataType||"uint8",srgb:t.srgb??!1,packed:t.packed??!1,webgl:t.webgl??!1,integer:t.integer??!1,signed:t.signed??!1,normalized:t.normalized??!1,compressed:t.compressed??!1}}function aN(i){const e=/.*-(\d+)x(\d+)-.*/.exec(i);if(e){const[,t,n]=e;return{blockWidth:Number(t),blockHeight:Number(n)}}return null}function lN(i){return typeof ImageData<"u"&&i instanceof ImageData||typeof ImageBitmap<"u"&&i instanceof ImageBitmap||typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&i instanceof HTMLVideoElement||typeof VideoFrame<"u"&&i instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas}function cN(i){if(typeof ImageData<"u"&&i instanceof ImageData||typeof ImageBitmap<"u"&&i instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas)return{width:i.width,height:i.height};if(typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement)return{width:i.naturalWidth,height:i.naturalHeight};if(typeof HTMLVideoElement<"u"&&i instanceof HTMLVideoElement)return{width:i.videoWidth,height:i.videoHeight};if(typeof VideoFrame<"u"&&i instanceof VideoFrame)return{width:i.displayWidth,height:i.displayHeight};throw new Error("Unknown image type")}class dte{}class hte{constructor(e=[],t){U(this,"features"),U(this,"disabledFeatures"),this.features=new Set(e),this.disabledFeatures=t||{}}*[Symbol.iterator](){yield*this.features}has(e){var t;return!((t=this.disabledFeatures)!=null&&t[e])&&this.features.has(e)}}const a2=class l2{constructor(e){U(this,"id"),U(this,"props"),U(this,"userData",{}),U(this,"statsManager",t2),U(this,"timestamp",0),U(this,"_reused",!1),U(this,"_lumaData",{}),U(this,"_textureCaps",{}),this.props={...l2.defaultProps,...e},this.id=this.props.id||oy(this[Symbol.toStringTag].toLowerCase())}get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}getVertexFormatInfo(e){return ly(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return Jc.getInfo(e)}getTextureFormatCapabilities(e){let t=this._textureCaps[e];if(!t){const n=this._getDeviceTextureFormatCapabilities(e);t=this._getDeviceSpecificTextureFormatCapabilities(n),this._textureCaps[e]=t}return t}getMipLevelCount(e,t,n=1){const s=Math.max(e,t,n);return 1+Math.floor(Math.log2(s))}isExternalImage(e){return lN(e)}getExternalImageSize(e){return cN(e)}isTextureFormatSupported(e){return this.getTextureFormatCapabilities(e).create}isTextureFormatFilterable(e){return this.getTextureFormatCapabilities(e).filter}isTextureFormatRenderable(e){return this.getTextureFormatCapabilities(e).render}isTextureFormatCompressed(e){return Jc.isCompressed(e)}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){var e;(e=this.commandEncoder)==null||e.popDebugGroup()}insertDebugMarker(e){var t;(t=this.commandEncoder)==null||t.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,t,...n){return this.props.onError(e,t)?()=>{}:le.error(e.message,t,...n)}debug(){if(this.props.debug)debugger;else le.once(0,`'Type luma.log.set({debug: true}) in console to enable debug breakpoints', or create a device with the 'debug: true' prop.`)()}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,t){throw new Error("not implemented")}readPixelsToBufferWebGL(e,t){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,t){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}static _getCanvasContextProps(e){return e.createCanvasContext===!0?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){const t=Jc.getCapabilities(e),n=r=>(typeof r=="string"?this.features.has(r):r)??!0,s=n(t.create);return{format:e,create:s,render:s&&n(t.render),filter:s&&n(t.filter),blend:s&&n(t.blend),store:s&&n(t.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});const t={...e};if((e.usage||0)&ge.INDEX&&(e.indexType||(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array&&(t.indexType="uint16")),!t.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return t}};U(a2,"defaultProps",{id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:(i,e)=>{},onResize:(i,e)=>{const[t,n]=i.getDevicePixelSize();le.log(1,`${i} resized => ${t}x${n}px`)()},onPositionChange:(i,e)=>{const[t,n]=i.getPosition();le.log(1,`${i} repositioned => ${t},${n}`)()},onVisibilityChange:i=>le.log(1,`${i} Visibility changed ${i.isVisible}`)(),onDevicePixelRatioChange:(i,e)=>le.log(1,`${i} DPR changed ${e.oldRatio} => ${i.devicePixelRatio}`)(),debug:le.get("debug")||void 0,debugShaders:le.get("debug-shaders")||void 0,debugFramebuffers:!!le.get("debug-framebuffers"),debugFactories:!!le.get("debug-factories"),debugWebGL:!!le.get("debug-webgl"),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_requestMaxLimits:!0,_cacheShaders:!1,_cachePipelines:!1,_cacheDestroyPolicy:"unused",_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0});let bg=a2;const uN="set luma.log.level=1 (or higher) to trace rendering",G0="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",c2=class vg{constructor(){if(U(this,"stats",t2),U(this,"log",le),U(this,"VERSION","9.2.5"),U(this,"spector"),U(this,"preregisteredAdapters",new Map),globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw le.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),le.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");le.error("This version of luma.gl has already been initialized")()}le.log(1,`${this.VERSION} - ${uN}`)(),globalThis.luma=this}async createDevice(e={}){const t={...vg.defaultProps,...e},n=this.selectAdapter(t.type,t.adapters);if(!n)throw new Error(G0);return t.waitForPageLoad&&await n.pageLoaded,await n.create(t)}async attachDevice(e,t){var n;const s=this._getTypeFromHandle(e,t.adapters),r=s&&this.selectAdapter(s,t.adapters);if(!r)throw new Error(G0);return await((n=r==null?void 0:r.attach)==null?void 0:n.call(r,e,t))}registerAdapters(e){for(const t of e)this.preregisteredAdapters.set(t.type,t)}getSupportedAdapters(e=[]){const t=this._getAdapterMap(e);return Array.from(t).map(([,n])=>n).filter(n=>{var s;return(s=n.isSupported)==null?void 0:s.call(n)}).map(n=>n.type)}getBestAvailableAdapterType(e=[]){var t,n;const s=["webgpu","webgl","null"],r=this._getAdapterMap(e);for(const o of s)if((n=(t=r.get(o))==null?void 0:t.isSupported)!=null&&n.call(t))return o;return null}selectAdapter(e,t=[]){let n=e;e==="best-available"&&(n=this.getBestAvailableAdapterType(t));const s=this._getAdapterMap(t);return n&&s.get(n)||null}enforceWebGL2(e=!0,t=[]){var n;const s=this._getAdapterMap(t).get("webgl");s||le.warn("enforceWebGL2: webgl adapter not found")(),(n=s==null?void 0:s.enforceWebGL2)==null||n.call(s,e)}setDefaultDeviceProps(e){Object.assign(vg.defaultProps,e)}_getAdapterMap(e=[]){const t=new Map(this.preregisteredAdapters);for(const n of e)t.set(n.type,n);return t}_getTypeFromHandle(e,t=[]){return e instanceof WebGL2RenderingContext?"webgl":typeof GPUDevice<"u"&&e instanceof GPUDevice||e!=null&&e.queue?"webgpu":e===null?"null":(e instanceof WebGLRenderingContext?le.warn("WebGL1 is not supported",e)():le.warn("Unknown handle type",e)(),null)}};U(c2,"defaultProps",{...bg.defaultProps,type:"best-available",adapters:void 0,waitForPageLoad:!0});let dN=c2;const hN=new dN;class fN{get pageLoaded(){return gN()}}const pN=Vu()&&typeof document<"u",mN=()=>pN&&document.readyState==="complete";let vd=null;function gN(){return vd||(mN()||typeof window>"u"?vd=Promise.resolve():vd=new Promise(i=>window.addEventListener("load",()=>i()))),vd}const u2=class xg extends _n{get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){t=xg.normalizeProps(e,t),super(e,t,xg.defaultProps)}static normalizeProps(e,t){return t}};U(u2,"defaultProps",{..._n.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1});let cy=u2;const _N={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},En=class Dc extends _n{constructor(e,t){if(t=Dc.normalizeProps(e,t),super(e,t,Dc.defaultProps),U(this,"dimension"),U(this,"baseDimension"),U(this,"format"),U(this,"width"),U(this,"height"),U(this,"depth"),U(this,"mipLevels"),U(this,"updateTimestamp"),this.dimension=this.props.dimension,this.baseDimension=_N[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.props.width===void 0||this.props.height===void 0)if(e.isExternalImage(t.data)){const n=e.getExternalImageSize(t.data);this.width=(n==null?void 0:n.width)||1,this.height=(n==null?void 0:n.height)||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&le.warn(`${this} created with undefined width or height. This is deprecated. Use AsyncTexture instead.`)();this.updateTimestamp=e.incrementTimestamp()}get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}setSampler(e){this.sampler=e instanceof cy?e:this.device.createSampler(e)}clone(e){return this.device.createTexture({...this.props,...e})}static normalizeProps(e,t){const n={...t},{width:s,height:r}=n;return typeof s=="number"&&(n.width=Math.max(1,Math.ceil(s))),typeof r=="number"&&(n.height=Math.max(1,Math.ceil(r))),n}_initializeData(e){this.device.isExternalImage(e)?this.copyExternalImage({image:e,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):e&&this.copyImageData({data:e,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(e){const{width:t,height:n,depth:s}=this,r={...Dc.defaultCopyDataOptions,width:t,height:n,depth:s,...e},o=this.device.getTextureFormatInfo(this.format);if(!e.bytesPerRow&&!o.bytesPerPixel)throw new Error(`bytesPerRow must be provided for texture format ${this.format}`);return r.bytesPerRow=e.bytesPerRow||t*(o.bytesPerPixel||4),r.rowsPerImage=e.rowsPerImage||n,r}_normalizeCopyExternalImageOptions(e){const t=this.device.getExternalImageSize(e.image),n={...Dc.defaultCopyExternalImageOptions,...t,...e};return n.width=Math.min(n.width,this.width-n.x),n.height=Math.min(n.height,this.height-n.y),n}};U(En,"SAMPLE",4),U(En,"STORAGE",8),U(En,"RENDER",16),U(En,"COPY_SRC",1),U(En,"COPY_DST",2),U(En,"TEXTURE",4),U(En,"RENDER_ATTACHMENT",16),U(En,"defaultProps",{..._n.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:En.TEXTURE|En.RENDER_ATTACHMENT|En.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0}),U(En,"defaultCopyDataOptions",{data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,mipLevel:0,x:0,y:0,z:0,aspect:"all"}),U(En,"defaultCopyExternalImageOptions",{image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1});let ct=En;const d2=class h2 extends _n{get[Symbol.toStringTag](){return"TextureView"}constructor(e,t){super(e,t,h2.defaultProps)}};U(d2,"defaultProps",{..._n.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0});let yN=d2;function bN(i,e,t){let n="";const s=e.split(/\r?\n/),r=i.slice().sort((o,a)=>o.lineNum-a.lineNum);switch((t==null?void 0:t.showSourceCode)||"no"){case"all":let o=0;for(let a=1;a<=s.length;a++)for(n+=f2(s[a-1],a,t);r.length>o&&r[o].lineNum===a;){const l=r[o++];n+=Qp(l,s,l.lineNum,{...t,inlineSource:!1})}for(;r.length>o;){const a=r[o++];n+=Qp(a,[],0,{...t,inlineSource:!1})}return n;case"issues":case"no":for(const a of i)n+=Qp(a,s,a.lineNum,{inlineSource:(t==null?void 0:t.showSourceCode)!=="no"});return n}}function Qp(i,e,t,n){if(n!=null&&n.inlineSource){const r=vN(e,t),o=i.linePos>0?`${" ".repeat(i.linePos+5)}^^^ `:"";return` ${r}${o}${i.type.toUpperCase()}: ${i.message} @@ -39,7 +39,7 @@ ${r}${o}${i.type.toUpperCase()}: ${i.message}

Compilation error in ${r}



 ${o}
-
`,l.style.top="10px",l.style.left="10px",l.style.position="absolute",l.style.zIndex="9999",l.style.width="100%",l.style.textAlign="left",document.body.appendChild(l),(n=document.getElementsByClassName("luma-compiler-log-error")[0])==null||n.scrollIntoView(),l.onclick=()=>{const c=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(c)}}};U(p2,"defaultProps",{..._n.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0});let SN=p2;function EN(i){return CN(i.source)||i.id||oy(`unnamed ${i.stage}-shader`)}function CN(i,e="unnamed"){const t=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(i);return t?t[1]:e}const g2=class _2 extends _n{constructor(e,t){super(e,t,_2.defaultProps),U(this,"shaderLayout"),U(this,"bufferLayout"),U(this,"linkStatus","pending"),U(this,"hash",""),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}get[Symbol.toStringTag](){return"RenderPipeline"}};U(g2,"defaultProps",{..._n.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},bindings:{},uniforms:{}});let Xh=g2;const y2=class b2 extends _n{constructor(e,t){super(e,t,b2.defaultProps),U(this,"hash",""),U(this,"shaderLayout"),this.shaderLayout=t.shaderLayout}get[Symbol.toStringTag](){return"ComputePipeline"}};U(y2,"defaultProps",{..._n.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0});let W0=y2;function TN(i){return LN[i]}function kN(i){const[e,t]=IN[i],n=e==="i32"||e==="u32",s=e!=="u32",r=AN[e]*t;return{primitiveType:e,components:t,byteLength:r,integer:n,signed:s}}const AN={f32:4,f16:2,i32:4,u32:4},IN={f32:["f32",1],"vec2":["f32",2],"vec3":["f32",3],"vec4":["f32",4],f16:["f16",1],"vec2":["f16",2],"vec3":["f16",3],"vec4":["f16",4],i32:["i32",1],"vec2":["i32",2],"vec3":["i32",3],"vec4":["i32",4],u32:["u32",1],"vec2":["u32",2],"vec3":["u32",3],"vec4":["u32",4]},LN={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2":{type:"f32",components:2},"vec3":{type:"f32",components:3},"vec4":{type:"f32",components:4},"vec2":{type:"f16",components:2},"vec3":{type:"f16",components:3},"vec4":{type:"f16",components:4},"vec2":{type:"i32",components:2},"vec3":{type:"i32",components:3},"vec4":{type:"i32",components:4},"vec2":{type:"u32",components:2},"vec3":{type:"u32",components:3},"vec4":{type:"u32",components:4},"mat2x2":{type:"f32",components:4},"mat2x3":{type:"f32",components:6},"mat2x4":{type:"f32",components:8},"mat3x2":{type:"f32",components:6},"mat3x3":{type:"f32",components:9},"mat3x4":{type:"f32",components:12},"mat4x2":{type:"f32",components:8},"mat4x3":{type:"f32",components:12},"mat4x4":{type:"f32",components:16},"mat2x2":{type:"f16",components:4},"mat2x3":{type:"f16",components:6},"mat2x4":{type:"f16",components:8},"mat3x2":{type:"f16",components:6},"mat3x3":{type:"f16",components:9},"mat3x4":{type:"f16",components:12},"mat4x2":{type:"f16",components:8},"mat4x3":{type:"f16",components:12},"mat4x4":{type:"f16",components:16},"mat2x2":{type:"i32",components:4},"mat2x3":{type:"i32",components:6},"mat2x4":{type:"i32",components:8},"mat3x2":{type:"i32",components:6},"mat3x3":{type:"i32",components:9},"mat3x4":{type:"i32",components:12},"mat4x2":{type:"i32",components:8},"mat4x3":{type:"i32",components:12},"mat4x4":{type:"i32",components:16},"mat2x2":{type:"u32",components:4},"mat2x3":{type:"u32",components:6},"mat2x4":{type:"u32",components:8},"mat3x2":{type:"u32",components:6},"mat3x3":{type:"u32",components:9},"mat3x4":{type:"u32",components:12},"mat4x2":{type:"u32",components:8},"mat4x3":{type:"u32",components:12},"mat4x4":{type:"u32",components:16}};function v2(i,e){const t={};for(const n of i.attributes){const s=RN(i,e,n.name);s&&(t[n.name]=s)}return t}function pte(i,e,t=16){const n=v2(i,e),s=new Array(t).fill(null);for(const r of Object.values(n))s[r.location]=r;return s}function RN(i,e,t){const n=PN(i,t),s=NN(e,t);if(!n)return null;const r=kN(n.type),o=ZP(r),a=(s==null?void 0:s.vertexFormat)||o,l=ly(a);return{attributeName:(s==null?void 0:s.attributeName)||n.name,bufferName:(s==null?void 0:s.bufferName)||n.name,location:n.location,shaderType:n.type,primitiveType:r.primitiveType,shaderComponents:r.components,vertexFormat:a,bufferDataType:l.type,bufferComponents:l.components,normalized:l.normalized,integer:r.integer,stepMode:(s==null?void 0:s.stepMode)||n.stepMode||"vertex",byteOffset:(s==null?void 0:s.byteOffset)||0,byteStride:(s==null?void 0:s.byteStride)||0}}function PN(i,e){const t=i.attributes.find(n=>n.name===e);return t||le.warn(`shader layout attribute "${e}" not present in shader`),t||null}function NN(i,e){DN(i);let t=MN(i,e);return t||(t=ON(i,e),t)?t:(le.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function DN(i){for(const e of i)(e.attributes&&e.format||!e.attributes&&!e.format)&&le.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function MN(i,e){for(const t of i)if(t.format&&t.name===e)return{attributeName:t.name,bufferName:e,stepMode:t.stepMode,vertexFormat:t.format,byteOffset:0,byteStride:t.byteStride||0};return null}function ON(i,e){var t;for(const n of i){let s=n.byteStride;if(typeof n.byteStride!="number")for(const o of n.attributes||[]){const a=ly(o.format);s+=a.byteLength}const r=(t=n.attributes)==null?void 0:t.find(o=>o.attribute===e);if(r)return{attributeName:r.attribute,bufferName:n.name,stepMode:n.stepMode,vertexFormat:r.format,byteOffset:r.byteOffset,byteStride:s}}return null}let xd;function x2(i){return(!xd||xd.byteLengthr.type==="uniform"&&r.name===(e==null?void 0:e.name));if(!n)throw new Error(e==null?void 0:e.name);const s=n;for(const r of s.uniforms||[])this.bindingLayout[r.name]=r}}setUniforms(e){for(const[t,n]of Object.entries(e))this._setUniform(t,n),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${n}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){UN(this.uniforms[e],t)||(this.uniforms[e]=$N(t),this.modifiedUniforms[e]=!0,this.modified=!0)}}let ri=class{constructor(e){U(this,"uniformBlocks",new Map),U(this,"uniformBufferLayouts",new Map),U(this,"uniformBuffers",new Map);for(const[t,n]of Object.entries(e)){const s=t,r=new zN(n.uniformTypes??{},n.uniformSizes??{});this.uniformBufferLayouts.set(s,r);const o=new jN({name:t});o.setUniforms(n.defaultUniforms||{}),this.uniformBlocks.set(s,o)}}destroy(){for(const e of this.uniformBuffers.values())e.destroy()}setUniforms(e){var t;for(const[n,s]of Object.entries(e))(t=this.uniformBlocks.get(n))==null||t.setUniforms(s);this.updateUniformBuffers()}getUniformBufferByteLength(e){var t;return((t=this.uniformBufferLayouts.get(e))==null?void 0:t.byteLength)||0}getUniformBufferData(e){var t,n;const s=((t=this.uniformBlocks.get(e))==null?void 0:t.getAllUniforms())||{};return(n=this.uniformBufferLayouts.get(e))==null?void 0:n.getData(s)}createUniformBuffer(e,t,n){n&&this.setUniforms(n);const s=this.getUniformBufferByteLength(t),r=e.createBuffer({usage:ge.UNIFORM|ge.COPY_DST,byteLength:s}),o=this.getUniformBufferData(t);return r.write(o),r}getManagedUniformBuffer(e,t){if(!this.uniformBuffers.get(t)){const n=this.getUniformBufferByteLength(t),s=e.createBuffer({usage:ge.UNIFORM|ge.COPY_DST,byteLength:n});this.uniformBuffers.set(t,s)}return this.uniformBuffers.get(t)}updateUniformBuffers(){let e=!1;for(const t of this.uniformBlocks.keys()){const n=this.updateUniformBuffer(t);e||(e=n)}return e&&le.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){var t;const n=this.uniformBlocks.get(e);let s=this.uniformBuffers.get(e),r=!1;if(s&&n!=null&&n.needsRedraw){r||(r=n.needsRedraw);const o=this.getUniformBufferData(e);s=this.uniformBuffers.get(e),s==null||s.write(o);const a=(t=this.uniformBlocks.get(e))==null?void 0:t.getAllUniforms();le.log(4,`Writing to uniform buffer ${String(e)}`,o,a)()}return r}};var Do;(function(i){i[i.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",i[i.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",i[i.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",i[i.POINTS=0]="POINTS",i[i.LINES=1]="LINES",i[i.LINE_LOOP=2]="LINE_LOOP",i[i.LINE_STRIP=3]="LINE_STRIP",i[i.TRIANGLES=4]="TRIANGLES",i[i.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",i[i.TRIANGLE_FAN=6]="TRIANGLE_FAN",i[i.ZERO=0]="ZERO",i[i.ONE=1]="ONE",i[i.SRC_COLOR=768]="SRC_COLOR",i[i.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",i[i.SRC_ALPHA=770]="SRC_ALPHA",i[i.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",i[i.DST_ALPHA=772]="DST_ALPHA",i[i.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",i[i.DST_COLOR=774]="DST_COLOR",i[i.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",i[i.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",i[i.CONSTANT_COLOR=32769]="CONSTANT_COLOR",i[i.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",i[i.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",i[i.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",i[i.FUNC_ADD=32774]="FUNC_ADD",i[i.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",i[i.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",i[i.BLEND_EQUATION=32777]="BLEND_EQUATION",i[i.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",i[i.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",i[i.BLEND_DST_RGB=32968]="BLEND_DST_RGB",i[i.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",i[i.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",i[i.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",i[i.BLEND_COLOR=32773]="BLEND_COLOR",i[i.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",i[i.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",i[i.LINE_WIDTH=2849]="LINE_WIDTH",i[i.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",i[i.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",i[i.CULL_FACE_MODE=2885]="CULL_FACE_MODE",i[i.FRONT_FACE=2886]="FRONT_FACE",i[i.DEPTH_RANGE=2928]="DEPTH_RANGE",i[i.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",i[i.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",i[i.DEPTH_FUNC=2932]="DEPTH_FUNC",i[i.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",i[i.STENCIL_FUNC=2962]="STENCIL_FUNC",i[i.STENCIL_FAIL=2964]="STENCIL_FAIL",i[i.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",i[i.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",i[i.STENCIL_REF=2967]="STENCIL_REF",i[i.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",i[i.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",i[i.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",i[i.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",i[i.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",i[i.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",i[i.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",i[i.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",i[i.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",i[i.VIEWPORT=2978]="VIEWPORT",i[i.SCISSOR_BOX=3088]="SCISSOR_BOX",i[i.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",i[i.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",i[i.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",i[i.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",i[i.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",i[i.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",i[i.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",i[i.RED_BITS=3410]="RED_BITS",i[i.GREEN_BITS=3411]="GREEN_BITS",i[i.BLUE_BITS=3412]="BLUE_BITS",i[i.ALPHA_BITS=3413]="ALPHA_BITS",i[i.DEPTH_BITS=3414]="DEPTH_BITS",i[i.STENCIL_BITS=3415]="STENCIL_BITS",i[i.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",i[i.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",i[i.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",i[i.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",i[i.SAMPLES=32937]="SAMPLES",i[i.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",i[i.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",i[i.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",i[i.VENDOR=7936]="VENDOR",i[i.RENDERER=7937]="RENDERER",i[i.VERSION=7938]="VERSION",i[i.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",i[i.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",i[i.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",i[i.STATIC_DRAW=35044]="STATIC_DRAW",i[i.STREAM_DRAW=35040]="STREAM_DRAW",i[i.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",i[i.ARRAY_BUFFER=34962]="ARRAY_BUFFER",i[i.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",i[i.BUFFER_SIZE=34660]="BUFFER_SIZE",i[i.BUFFER_USAGE=34661]="BUFFER_USAGE",i[i.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",i[i.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",i[i.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",i[i.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",i[i.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",i[i.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",i[i.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",i[i.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",i[i.CULL_FACE=2884]="CULL_FACE",i[i.FRONT=1028]="FRONT",i[i.BACK=1029]="BACK",i[i.FRONT_AND_BACK=1032]="FRONT_AND_BACK",i[i.BLEND=3042]="BLEND",i[i.DEPTH_TEST=2929]="DEPTH_TEST",i[i.DITHER=3024]="DITHER",i[i.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",i[i.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",i[i.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",i[i.SCISSOR_TEST=3089]="SCISSOR_TEST",i[i.STENCIL_TEST=2960]="STENCIL_TEST",i[i.NO_ERROR=0]="NO_ERROR",i[i.INVALID_ENUM=1280]="INVALID_ENUM",i[i.INVALID_VALUE=1281]="INVALID_VALUE",i[i.INVALID_OPERATION=1282]="INVALID_OPERATION",i[i.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",i[i.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",i[i.CW=2304]="CW",i[i.CCW=2305]="CCW",i[i.DONT_CARE=4352]="DONT_CARE",i[i.FASTEST=4353]="FASTEST",i[i.NICEST=4354]="NICEST",i[i.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",i[i.BYTE=5120]="BYTE",i[i.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",i[i.SHORT=5122]="SHORT",i[i.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",i[i.INT=5124]="INT",i[i.UNSIGNED_INT=5125]="UNSIGNED_INT",i[i.FLOAT=5126]="FLOAT",i[i.DOUBLE=5130]="DOUBLE",i[i.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",i[i.ALPHA=6406]="ALPHA",i[i.RGB=6407]="RGB",i[i.RGBA=6408]="RGBA",i[i.LUMINANCE=6409]="LUMINANCE",i[i.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",i[i.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",i[i.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",i[i.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",i[i.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",i[i.VERTEX_SHADER=35633]="VERTEX_SHADER",i[i.COMPILE_STATUS=35713]="COMPILE_STATUS",i[i.DELETE_STATUS=35712]="DELETE_STATUS",i[i.LINK_STATUS=35714]="LINK_STATUS",i[i.VALIDATE_STATUS=35715]="VALIDATE_STATUS",i[i.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",i[i.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",i[i.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",i[i.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",i[i.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",i[i.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",i[i.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",i[i.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",i[i.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",i[i.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",i[i.SHADER_TYPE=35663]="SHADER_TYPE",i[i.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",i[i.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",i[i.NEVER=512]="NEVER",i[i.LESS=513]="LESS",i[i.EQUAL=514]="EQUAL",i[i.LEQUAL=515]="LEQUAL",i[i.GREATER=516]="GREATER",i[i.NOTEQUAL=517]="NOTEQUAL",i[i.GEQUAL=518]="GEQUAL",i[i.ALWAYS=519]="ALWAYS",i[i.KEEP=7680]="KEEP",i[i.REPLACE=7681]="REPLACE",i[i.INCR=7682]="INCR",i[i.DECR=7683]="DECR",i[i.INVERT=5386]="INVERT",i[i.INCR_WRAP=34055]="INCR_WRAP",i[i.DECR_WRAP=34056]="DECR_WRAP",i[i.NEAREST=9728]="NEAREST",i[i.LINEAR=9729]="LINEAR",i[i.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",i[i.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",i[i.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",i[i.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",i[i.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",i[i.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",i[i.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",i[i.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",i[i.TEXTURE_2D=3553]="TEXTURE_2D",i[i.TEXTURE=5890]="TEXTURE",i[i.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",i[i.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",i[i.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",i[i.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",i[i.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",i[i.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",i[i.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",i[i.TEXTURE0=33984]="TEXTURE0",i[i.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",i[i.REPEAT=10497]="REPEAT",i[i.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",i[i.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",i[i.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",i[i.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",i[i.FLOAT_VEC2=35664]="FLOAT_VEC2",i[i.FLOAT_VEC3=35665]="FLOAT_VEC3",i[i.FLOAT_VEC4=35666]="FLOAT_VEC4",i[i.INT_VEC2=35667]="INT_VEC2",i[i.INT_VEC3=35668]="INT_VEC3",i[i.INT_VEC4=35669]="INT_VEC4",i[i.BOOL=35670]="BOOL",i[i.BOOL_VEC2=35671]="BOOL_VEC2",i[i.BOOL_VEC3=35672]="BOOL_VEC3",i[i.BOOL_VEC4=35673]="BOOL_VEC4",i[i.FLOAT_MAT2=35674]="FLOAT_MAT2",i[i.FLOAT_MAT3=35675]="FLOAT_MAT3",i[i.FLOAT_MAT4=35676]="FLOAT_MAT4",i[i.SAMPLER_2D=35678]="SAMPLER_2D",i[i.SAMPLER_CUBE=35680]="SAMPLER_CUBE",i[i.LOW_FLOAT=36336]="LOW_FLOAT",i[i.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",i[i.HIGH_FLOAT=36338]="HIGH_FLOAT",i[i.LOW_INT=36339]="LOW_INT",i[i.MEDIUM_INT=36340]="MEDIUM_INT",i[i.HIGH_INT=36341]="HIGH_INT",i[i.FRAMEBUFFER=36160]="FRAMEBUFFER",i[i.RENDERBUFFER=36161]="RENDERBUFFER",i[i.RGBA4=32854]="RGBA4",i[i.RGB5_A1=32855]="RGB5_A1",i[i.RGB565=36194]="RGB565",i[i.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",i[i.STENCIL_INDEX=6401]="STENCIL_INDEX",i[i.STENCIL_INDEX8=36168]="STENCIL_INDEX8",i[i.DEPTH_STENCIL=34041]="DEPTH_STENCIL",i[i.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",i[i.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",i[i.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",i[i.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",i[i.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",i[i.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",i[i.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",i[i.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",i[i.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",i[i.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",i[i.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",i[i.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",i[i.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",i[i.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",i[i.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",i[i.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",i[i.NONE=0]="NONE",i[i.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",i[i.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",i[i.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",i[i.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",i[i.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",i[i.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",i[i.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",i[i.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",i[i.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",i[i.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",i[i.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",i[i.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",i[i.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",i[i.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",i[i.READ_BUFFER=3074]="READ_BUFFER",i[i.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",i[i.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",i[i.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",i[i.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",i[i.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",i[i.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",i[i.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",i[i.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",i[i.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",i[i.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",i[i.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",i[i.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",i[i.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",i[i.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",i[i.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",i[i.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",i[i.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",i[i.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",i[i.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",i[i.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",i[i.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",i[i.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",i[i.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",i[i.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",i[i.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",i[i.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",i[i.RED=6403]="RED",i[i.RGB8=32849]="RGB8",i[i.RGBA8=32856]="RGBA8",i[i.RGB10_A2=32857]="RGB10_A2",i[i.TEXTURE_3D=32879]="TEXTURE_3D",i[i.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",i[i.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",i[i.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",i[i.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",i[i.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",i[i.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",i[i.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",i[i.SRGB=35904]="SRGB",i[i.SRGB8=35905]="SRGB8",i[i.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",i[i.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",i[i.RGBA32F=34836]="RGBA32F",i[i.RGB32F=34837]="RGB32F",i[i.RGBA16F=34842]="RGBA16F",i[i.RGB16F=34843]="RGB16F",i[i.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",i[i.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",i[i.R11F_G11F_B10F=35898]="R11F_G11F_B10F",i[i.RGB9_E5=35901]="RGB9_E5",i[i.RGBA32UI=36208]="RGBA32UI",i[i.RGB32UI=36209]="RGB32UI",i[i.RGBA16UI=36214]="RGBA16UI",i[i.RGB16UI=36215]="RGB16UI",i[i.RGBA8UI=36220]="RGBA8UI",i[i.RGB8UI=36221]="RGB8UI",i[i.RGBA32I=36226]="RGBA32I",i[i.RGB32I=36227]="RGB32I",i[i.RGBA16I=36232]="RGBA16I",i[i.RGB16I=36233]="RGB16I",i[i.RGBA8I=36238]="RGBA8I",i[i.RGB8I=36239]="RGB8I",i[i.RED_INTEGER=36244]="RED_INTEGER",i[i.RGB_INTEGER=36248]="RGB_INTEGER",i[i.RGBA_INTEGER=36249]="RGBA_INTEGER",i[i.R8=33321]="R8",i[i.RG8=33323]="RG8",i[i.R16F=33325]="R16F",i[i.R32F=33326]="R32F",i[i.RG16F=33327]="RG16F",i[i.RG32F=33328]="RG32F",i[i.R8I=33329]="R8I",i[i.R8UI=33330]="R8UI",i[i.R16I=33331]="R16I",i[i.R16UI=33332]="R16UI",i[i.R32I=33333]="R32I",i[i.R32UI=33334]="R32UI",i[i.RG8I=33335]="RG8I",i[i.RG8UI=33336]="RG8UI",i[i.RG16I=33337]="RG16I",i[i.RG16UI=33338]="RG16UI",i[i.RG32I=33339]="RG32I",i[i.RG32UI=33340]="RG32UI",i[i.R8_SNORM=36756]="R8_SNORM",i[i.RG8_SNORM=36757]="RG8_SNORM",i[i.RGB8_SNORM=36758]="RGB8_SNORM",i[i.RGBA8_SNORM=36759]="RGBA8_SNORM",i[i.RGB10_A2UI=36975]="RGB10_A2UI",i[i.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",i[i.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",i[i.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",i[i.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",i[i.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",i[i.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",i[i.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",i[i.HALF_FLOAT=5131]="HALF_FLOAT",i[i.RG=33319]="RG",i[i.RG_INTEGER=33320]="RG_INTEGER",i[i.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",i[i.CURRENT_QUERY=34917]="CURRENT_QUERY",i[i.QUERY_RESULT=34918]="QUERY_RESULT",i[i.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",i[i.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",i[i.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",i[i.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",i[i.DRAW_BUFFER0=34853]="DRAW_BUFFER0",i[i.DRAW_BUFFER1=34854]="DRAW_BUFFER1",i[i.DRAW_BUFFER2=34855]="DRAW_BUFFER2",i[i.DRAW_BUFFER3=34856]="DRAW_BUFFER3",i[i.DRAW_BUFFER4=34857]="DRAW_BUFFER4",i[i.DRAW_BUFFER5=34858]="DRAW_BUFFER5",i[i.DRAW_BUFFER6=34859]="DRAW_BUFFER6",i[i.DRAW_BUFFER7=34860]="DRAW_BUFFER7",i[i.DRAW_BUFFER8=34861]="DRAW_BUFFER8",i[i.DRAW_BUFFER9=34862]="DRAW_BUFFER9",i[i.DRAW_BUFFER10=34863]="DRAW_BUFFER10",i[i.DRAW_BUFFER11=34864]="DRAW_BUFFER11",i[i.DRAW_BUFFER12=34865]="DRAW_BUFFER12",i[i.DRAW_BUFFER13=34866]="DRAW_BUFFER13",i[i.DRAW_BUFFER14=34867]="DRAW_BUFFER14",i[i.DRAW_BUFFER15=34868]="DRAW_BUFFER15",i[i.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",i[i.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",i[i.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",i[i.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",i[i.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",i[i.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",i[i.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",i[i.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",i[i.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",i[i.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",i[i.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",i[i.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",i[i.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",i[i.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",i[i.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",i[i.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",i[i.SAMPLER_3D=35679]="SAMPLER_3D",i[i.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",i[i.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",i[i.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",i[i.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",i[i.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",i[i.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",i[i.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",i[i.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",i[i.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",i[i.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",i[i.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",i[i.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",i[i.MAX_SAMPLES=36183]="MAX_SAMPLES",i[i.SAMPLER_BINDING=35097]="SAMPLER_BINDING",i[i.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",i[i.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",i[i.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",i[i.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",i[i.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",i[i.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",i[i.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",i[i.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",i[i.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",i[i.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",i[i.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",i[i.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",i[i.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",i[i.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",i[i.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",i[i.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",i[i.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",i[i.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",i[i.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",i[i.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",i[i.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",i[i.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",i[i.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",i[i.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",i[i.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",i[i.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",i[i.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",i[i.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",i[i.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",i[i.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",i[i.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",i[i.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",i[i.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",i[i.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",i[i.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",i[i.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",i[i.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",i[i.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",i[i.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",i[i.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",i[i.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",i[i.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",i[i.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",i[i.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",i[i.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",i[i.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",i[i.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",i[i.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",i[i.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",i[i.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",i[i.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",i[i.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",i[i.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",i[i.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",i[i.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",i[i.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",i[i.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",i[i.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",i[i.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",i[i.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",i[i.UNIFORM_TYPE=35383]="UNIFORM_TYPE",i[i.UNIFORM_SIZE=35384]="UNIFORM_SIZE",i[i.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",i[i.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",i[i.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",i[i.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",i[i.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",i[i.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",i[i.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",i[i.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",i[i.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",i[i.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",i[i.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",i[i.OBJECT_TYPE=37138]="OBJECT_TYPE",i[i.SYNC_CONDITION=37139]="SYNC_CONDITION",i[i.SYNC_STATUS=37140]="SYNC_STATUS",i[i.SYNC_FLAGS=37141]="SYNC_FLAGS",i[i.SYNC_FENCE=37142]="SYNC_FENCE",i[i.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",i[i.UNSIGNALED=37144]="UNSIGNALED",i[i.SIGNALED=37145]="SIGNALED",i[i.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",i[i.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",i[i.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",i[i.WAIT_FAILED=37149]="WAIT_FAILED",i[i.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",i[i.COLOR=6144]="COLOR",i[i.DEPTH=6145]="DEPTH",i[i.STENCIL=6146]="STENCIL",i[i.MIN=32775]="MIN",i[i.MAX=32776]="MAX",i[i.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",i[i.STREAM_READ=35041]="STREAM_READ",i[i.STREAM_COPY=35042]="STREAM_COPY",i[i.STATIC_READ=35045]="STATIC_READ",i[i.STATIC_COPY=35046]="STATIC_COPY",i[i.DYNAMIC_READ=35049]="DYNAMIC_READ",i[i.DYNAMIC_COPY=35050]="DYNAMIC_COPY",i[i.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",i[i.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",i[i.INVALID_INDEX=4294967295]="INVALID_INDEX",i[i.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",i[i.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",i[i.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",i[i.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",i[i.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",i[i.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",i[i.R16_EXT=33322]="R16_EXT",i[i.RG16_EXT=33324]="RG16_EXT",i[i.RGB16_EXT=32852]="RGB16_EXT",i[i.RGBA16_EXT=32859]="RGBA16_EXT",i[i.R16_SNORM_EXT=36760]="R16_SNORM_EXT",i[i.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",i[i.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",i[i.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",i[i.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",i[i.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",i[i.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",i[i.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",i[i.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",i[i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",i[i.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",i[i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",i[i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",i[i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",i[i.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",i[i.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",i[i.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",i[i.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",i[i.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",i[i.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",i[i.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",i[i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",i[i.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",i[i.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",i[i.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",i[i.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",i[i.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",i[i.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",i[i.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",i[i.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",i[i.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",i[i.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",i[i.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",i[i.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",i[i.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",i[i.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",i[i.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",i[i.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",i[i.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",i[i.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",i[i.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",i[i.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",i[i.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",i[i.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",i[i.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",i[i.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",i[i.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",i[i.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",i[i.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",i[i.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",i[i.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",i[i.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",i[i.LINE_WEBGL=6913]="LINE_WEBGL",i[i.FILL_WEBGL=6914]="FILL_WEBGL",i[i.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",i[i.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",i[i.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",i[i.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",i[i.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",i[i.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",i[i.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",i[i.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",i[i.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",i[i.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",i[i.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",i[i.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",i[i.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",i[i.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",i[i.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",i[i.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",i[i.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",i[i.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",i[i.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",i[i.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",i[i.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",i[i.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",i[i.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",i[i.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"})(Do||(Do={}));const HN={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},VN=i=>({drawBuffersWEBGL(e){return i.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),GN=i=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return i.createVertexArray()},deleteVertexArrayOES(e){return i.deleteVertexArray(e)},isVertexArrayOES(e){return i.isVertexArray(e)},bindVertexArrayOES(e){return i.bindVertexArray(e)}}),WN=i=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return i.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return i.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return i.vertexAttribDivisor(...e)}});function YN(i=!0){const e=HTMLCanvasElement.prototype;if(!i&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(t,n){if(t==="webgl"||t==="experimental-webgl"){const s=this.originalGetContext("webgl2",n);return s instanceof HTMLElement&&qN(s),s}return this.originalGetContext(t,n)}}function qN(i){i.getExtension("EXT_color_buffer_float");const e={...HN,WEBGL_disjoint_timer_query:i.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:VN(i),OES_vertex_array_object:GN(i),ANGLE_instanced_arrays:WN(i)},t=i.getExtension;i.getExtension=function(s){return t.call(i,s)||(s in e?e[s]:null)};const n=i.getSupportedExtensions;i.getSupportedExtensions=function(){const s=n.apply(i)||[];return s==null?void 0:s.concat(Object.keys(e))}}async function w2(i,e){const t=document.getElementsByTagName("head")[0];if(!t)throw new Error("loadScript");const n=document.createElement("script");return n.setAttribute("type","text/javascript"),n.setAttribute("src",i),new Promise((s,r)=>{n.onload=s,n.onerror=o=>r(new Error(`Unable to load script '${i}': ${o}`)),t.appendChild(n)})}const XN=1;let hi=null,Y0=!1;const uy={debugSpectorJS:le.get("debug-spectorjs"),debugSpectorJSUrl:"https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js",gl:void 0};async function KN(i){if(!globalThis.SPECTOR)try{await w2(i.debugSpectorJSUrl||uy.debugSpectorJSUrl)}catch(e){le.warn(String(e))}}function _te(i){var e;if(i={...uy,...i},!i.debugSpectorJS)return null;if(!hi&&globalThis.SPECTOR&&!((e=globalThis.luma)!=null&&e.spector)){le.probe(XN,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();const{Spector:t}=globalThis.SPECTOR;hi=new t,globalThis.luma&&(globalThis.luma.spector=hi)}if(!hi)return null;if(Y0||(Y0=!0,hi.spyCanvases(),hi==null||hi.onCaptureStarted.add(t=>le.info("Spector capture started:",t)()),hi==null||hi.onCapture.add(t=>{le.info("Spector capture complete:",t)(),hi==null||hi.getResultUI(),hi==null||hi.resultView.display(),hi==null||hi.resultView.addCapture(t)})),i.gl){const t=i.gl,n=t.device;hi==null||hi.startCapture(i.gl,500),t.device=n,new Promise(s=>setTimeout(s,2e3)).then(s=>{le.info("Spector capture stopped after 2 seconds")(),hi==null||hi.stopCapture()})}return hi}const ZN="https://unpkg.com/webgl-debug@2.0.1/index.js";function S2(i){return i.luma=i.luma||{},i.luma}async function QN(){Vu()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await w2(ZN))}function yte(i,e={}){return e.debugWebGL||e.traceWebGL?eD(i,e):JN(i)}function JN(i){const e=S2(i);return e.realContext?e.realContext:i}function eD(i,e){if(!globalThis.WebGLDebugUtils)return le.warn("webgl-debug not loaded")(),i;const t=S2(i);if(t.debugContext)return t.debugContext;globalThis.WebGLDebugUtils.init({...Do,...i});const n=globalThis.WebGLDebugUtils.makeDebugContext(i,tD.bind(null,e),iD.bind(null,e));for(const o in Do)!(o in n)&&typeof Do[o]=="number"&&(n[o]=Do[o]);class s{}Object.setPrototypeOf(n,Object.getPrototypeOf(i)),Object.setPrototypeOf(s,n);const r=Object.create(s);return t.realContext=i,t.debugContext=r,r.debug=!0,r}function q0(i,e){e=Array.from(e).map(n=>n===void 0?"undefined":n);let t=globalThis.WebGLDebugUtils.glFunctionArgsToString(i,e);return t=`${t.slice(0,100)}${t.length>100?"...":""}`,`gl.${i}(${t})`}function tD(i,e,t,n){n=Array.from(n).map(a=>a===void 0?"undefined":a);const s=globalThis.WebGLDebugUtils.glEnumToString(e),r=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,n),o=`${s} in gl.${t}(${r})`;le.error(o)();debugger}function iD(i,e,t){let n="";le.level>=1&&(n=q0(e,t),i.traceWebGL&&le.log(1,n)());for(const s of t)if(s===void 0){n=n||q0(e,t);debugger}}const wd=1;class nD extends fN{constructor(){super(),U(this,"type","webgl"),bg.defaultProps={...bg.defaultProps,...uy}}enforceWebGL2(e){YN(e)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&e instanceof WebGLRenderingContext&&le.warn("WebGL1 is not supported",e)(),!1)}async attach(e,t={}){const{WebGLDevice:n}=await l0(async()=>{const{WebGLDevice:r}=await import("./webgl-device-QoBMYpnS-BzCsS41F.js");return{WebGLDevice:r}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]));if(e instanceof n)return e;if((e==null?void 0:e.device)instanceof n)return e.device;if(!sD(e))throw new Error("Invalid WebGL2RenderingContext");const s=t.createCanvasContext===!0?{}:t.createCanvasContext;return new n({...t,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...s}})}async create(e={}){const{WebGLDevice:t}=await l0(async()=>{const{WebGLDevice:n}=await import("./webgl-device-QoBMYpnS-BzCsS41F.js");return{WebGLDevice:n}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]));le.groupCollapsed(wd,"WebGLDevice created")();try{const n=[];(e.debugWebGL||e.debug)&&n.push(QN()),e.debugSpectorJS&&n.push(KN(e));const s=await Promise.allSettled(n);for(const a of s)a.status==="rejected"&&le.error(`Failed to initialize debug libraries ${a.reason}`)();const r=new t(e),o=`${r._reused?"Reusing":"Created"} device with WebGL2 ${r.props.debug?"debug ":""}context: ${r.info.vendor}, ${r.info.renderer} for canvas: ${r.canvasContext.id}`;return le.probe(wd,o)(),le.table(wd,r.info)(),r}finally{le.groupEnd(wd)()}}}function sD(i){return typeof WebGL2RenderingContext<"u"&&i instanceof WebGL2RenderingContext?!0:!!(i&&Number.isFinite(i._version))}const rD=new nD,oD="#b3b3b3",aD=void 0,wg=void 0,lD=1,cD=4,uD="#666666",dD=.1,hD=1,fD=1,E2="#222222",pe={enableSimulation:!0,spaceSize:8192,pointSizeScale:1,linkWidthScale:1,linkArrowsSizeScale:1,renderLinks:!0,curvedLinks:!1,curvedLinkSegments:19,curvedLinkWeight:.8,curvedLinkControlPointDistance:.5,linkArrows:!1,linkVisibilityDistanceRange:[50,150],linkVisibilityMinTransparency:.25,hoveredPointCursor:"auto",hoveredLinkCursor:"auto",renderHoveredPointRing:!1,hoveredPointRingColor:"white",hoveredLinkColor:void 0,hoveredLinkWidthIncrease:5,focusedPointRingColor:"white",focusedPointIndex:void 0,simulation:{decay:5e3,gravity:.25,center:0,repulsion:1,repulsionTheta:1.15,linkSpring:1,linkDistance:10,linkDistRandomVariationRange:[1,1.2],repulsionFromMouse:2,friction:.85,cluster:.1},showFPSMonitor:!1,pixelRatio:typeof window<"u"&&window.devicePixelRatio||2,scalePointsOnZoom:!1,scaleLinksOnZoom:!1,enableZoom:!0,enableSimulationDuringZoom:!1,enableDrag:!1,fitViewOnInit:!0,fitViewDelay:250,fitViewPadding:.1,fitViewDuration:250,pointSamplingDistance:150,attribution:"",rescalePositions:void 0,enableRightClickRepulsion:!1},pD=.7,mD=.95,gD=3;/*! @license DOMPurify 3.2.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.6/LICENSE */const{entries:C2,setPrototypeOf:X0,isFrozen:_D,getPrototypeOf:yD,getOwnPropertyDescriptor:bD}=Object;let{freeze:hn,seal:_s,create:T2}=Object,{apply:Sg,construct:Eg}=typeof Reflect<"u"&&Reflect;hn||(hn=function(i){return i});_s||(_s=function(i){return i});Sg||(Sg=function(i,e,t){return i.apply(e,t)});Eg||(Eg=function(i,e){return new i(...e)});const Sd=fn(Array.prototype.forEach),vD=fn(Array.prototype.lastIndexOf),K0=fn(Array.prototype.pop),ac=fn(Array.prototype.push),xD=fn(Array.prototype.splice),uh=fn(String.prototype.toLowerCase),Jp=fn(String.prototype.toString),Z0=fn(String.prototype.match),lc=fn(String.prototype.replace),wD=fn(String.prototype.indexOf),SD=fn(String.prototype.trim),Ms=fn(Object.prototype.hasOwnProperty),sn=fn(RegExp.prototype.test),cc=ED(TypeError);function fn(i){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s2&&arguments[2]!==void 0?arguments[2]:uh;X0&&X0(i,null);let n=e.length;for(;n--;){let s=e[n];if(typeof s=="string"){const r=t(s);r!==s&&(_D(e)||(e[n]=r),s=r)}i[s]=!0}return i}function CD(i){for(let e=0;e/gm),LD=_s(/\$\{[\w\W]*/gm),RD=_s(/^data-[\-\w.\u00B7-\uFFFF]+$/),PD=_s(/^aria-[\-\w]+$/),k2=_s(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ND=_s(/^(?:\w+script|data):/i),DD=_s(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),A2=_s(/^html$/i),MD=_s(/^[a-z][.\w]*(-[.\w]+)+$/i);var ix=Object.freeze({__proto__:null,ARIA_ATTR:PD,ATTR_WHITESPACE:DD,CUSTOM_ELEMENT:MD,DATA_ATTR:RD,DOCTYPE_NAME:A2,ERB_EXPR:ID,IS_ALLOWED_URI:k2,IS_SCRIPT_OR_DATA:ND,MUSTACHE_EXPR:AD,TMPLIT_EXPR:LD});const dc={element:1,text:3,progressingInstruction:7,comment:8,document:9},OD=function(){return typeof window>"u"?null:window},BD=function(i,e){if(typeof i!="object"||typeof i.createPolicy!="function")return null;let t=null;const n="data-tt-policy-suffix";e&&e.hasAttribute(n)&&(t=e.getAttribute(n));const s="dompurify"+(t?"#"+t:"");try{return i.createPolicy(s,{createHTML(r){return r},createScriptURL(r){return r}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},nx=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function I2(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:OD();const e=I=>I2(I);if(e.version="3.2.6",e.removed=[],!i||!i.document||i.document.nodeType!==dc.document||!i.Element)return e.isSupported=!1,e;let{document:t}=i;const n=t,s=n.currentScript,{DocumentFragment:r,HTMLTemplateElement:o,Node:a,Element:l,NodeFilter:c,NamedNodeMap:u=i.NamedNodeMap||i.MozNamedAttrMap,HTMLFormElement:d,DOMParser:h,trustedTypes:p}=i,m=l.prototype,y=uc(m,"cloneNode"),g=uc(m,"remove"),_=uc(m,"nextSibling"),S=uc(m,"childNodes"),C=uc(m,"parentNode");if(typeof o=="function"){const I=t.createElement("template");I.content&&I.content.ownerDocument&&(t=I.content.ownerDocument)}let x,A="";const{implementation:L,createNodeIterator:B,createDocumentFragment:H,getElementsByTagName:Q}=t,{importNode:te}=n;let M=nx();e.isSupported=typeof C2=="function"&&typeof C=="function"&&L&&L.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:he,ERB_EXPR:se,TMPLIT_EXPR:R,DATA_ATTR:J,ARIA_ATTR:F,IS_SCRIPT_OR_DATA:X,ATTR_WHITESPACE:ie,CUSTOM_ELEMENT:ee}=ix;let{IS_ALLOWED_URI:ae}=ix,Z=null;const Se=ot({},[...Q0,...em,...tm,...im,...J0]);let xe=null;const Je=ot({},[...ex,...nm,...tx,...Ed]);let de=Object.seal(T2(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),bt=null,Xe=null,ht=!0,re=!0,Te=!1,Pe=!0,q=!1,We=!0,He=!1,it=!1,Vt=!1,me=!1,nt=!1,ui=!1,_i=!0,Zn=!1;const Qo="user-content-";let Zs=!0,Li=!1,en={},Ri=null;const ai=ot({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let vo=null;const Es=ot({},["audio","video","img","source","image","track"]);let Qn=null;const Jn=ot({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Cs="http://www.w3.org/1998/Math/MathML",zi="http://www.w3.org/2000/svg",Ei="http://www.w3.org/1999/xhtml";let ii=Ei,bn=!1,vn=null;const Ts=ot({},[Cs,zi,Ei],Jp);let On=ot({},["mi","mo","mn","ms","mtext"]),es=ot({},["annotation-xml"]);const Dr=ot({},["title","style","font","a","script"]);let xn=null;const Qs=["application/xhtml+xml","text/html"],Jo="text/html";let Zt=null,Ot=null;const ks=t.createElement("form"),xo=function(I){return I instanceof RegExp||I instanceof Function},Js=function(){let I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ot&&Ot===I)){if((!I||typeof I!="object")&&(I={}),I=Hr(I),xn=Qs.indexOf(I.PARSER_MEDIA_TYPE)===-1?Jo:I.PARSER_MEDIA_TYPE,Zt=xn==="application/xhtml+xml"?Jp:uh,Z=Ms(I,"ALLOWED_TAGS")?ot({},I.ALLOWED_TAGS,Zt):Se,xe=Ms(I,"ALLOWED_ATTR")?ot({},I.ALLOWED_ATTR,Zt):Je,vn=Ms(I,"ALLOWED_NAMESPACES")?ot({},I.ALLOWED_NAMESPACES,Jp):Ts,Qn=Ms(I,"ADD_URI_SAFE_ATTR")?ot(Hr(Jn),I.ADD_URI_SAFE_ATTR,Zt):Jn,vo=Ms(I,"ADD_DATA_URI_TAGS")?ot(Hr(Es),I.ADD_DATA_URI_TAGS,Zt):Es,Ri=Ms(I,"FORBID_CONTENTS")?ot({},I.FORBID_CONTENTS,Zt):ai,bt=Ms(I,"FORBID_TAGS")?ot({},I.FORBID_TAGS,Zt):Hr({}),Xe=Ms(I,"FORBID_ATTR")?ot({},I.FORBID_ATTR,Zt):Hr({}),en=Ms(I,"USE_PROFILES")?I.USE_PROFILES:!1,ht=I.ALLOW_ARIA_ATTR!==!1,re=I.ALLOW_DATA_ATTR!==!1,Te=I.ALLOW_UNKNOWN_PROTOCOLS||!1,Pe=I.ALLOW_SELF_CLOSE_IN_ATTR!==!1,q=I.SAFE_FOR_TEMPLATES||!1,We=I.SAFE_FOR_XML!==!1,He=I.WHOLE_DOCUMENT||!1,me=I.RETURN_DOM||!1,nt=I.RETURN_DOM_FRAGMENT||!1,ui=I.RETURN_TRUSTED_TYPE||!1,Vt=I.FORCE_BODY||!1,_i=I.SANITIZE_DOM!==!1,Zn=I.SANITIZE_NAMED_PROPS||!1,Zs=I.KEEP_CONTENT!==!1,Li=I.IN_PLACE||!1,ae=I.ALLOWED_URI_REGEXP||k2,ii=I.NAMESPACE||Ei,On=I.MATHML_TEXT_INTEGRATION_POINTS||On,es=I.HTML_INTEGRATION_POINTS||es,de=I.CUSTOM_ELEMENT_HANDLING||{},I.CUSTOM_ELEMENT_HANDLING&&xo(I.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(de.tagNameCheck=I.CUSTOM_ELEMENT_HANDLING.tagNameCheck),I.CUSTOM_ELEMENT_HANDLING&&xo(I.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(de.attributeNameCheck=I.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),I.CUSTOM_ELEMENT_HANDLING&&typeof I.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(de.allowCustomizedBuiltInElements=I.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),q&&(re=!1),nt&&(me=!0),en&&(Z=ot({},J0),xe=[],en.html===!0&&(ot(Z,Q0),ot(xe,ex)),en.svg===!0&&(ot(Z,em),ot(xe,nm),ot(xe,Ed)),en.svgFilters===!0&&(ot(Z,tm),ot(xe,nm),ot(xe,Ed)),en.mathMl===!0&&(ot(Z,im),ot(xe,tx),ot(xe,Ed))),I.ADD_TAGS&&(Z===Se&&(Z=Hr(Z)),ot(Z,I.ADD_TAGS,Zt)),I.ADD_ATTR&&(xe===Je&&(xe=Hr(xe)),ot(xe,I.ADD_ATTR,Zt)),I.ADD_URI_SAFE_ATTR&&ot(Qn,I.ADD_URI_SAFE_ATTR,Zt),I.FORBID_CONTENTS&&(Ri===ai&&(Ri=Hr(Ri)),ot(Ri,I.FORBID_CONTENTS,Zt)),Zs&&(Z["#text"]=!0),He&&ot(Z,["html","head","body"]),Z.table&&(ot(Z,["tbody"]),delete bt.tbody),I.TRUSTED_TYPES_POLICY){if(typeof I.TRUSTED_TYPES_POLICY.createHTML!="function")throw cc('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof I.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw cc('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');x=I.TRUSTED_TYPES_POLICY,A=x.createHTML("")}else x===void 0&&(x=BD(p,s)),x!==null&&typeof A=="string"&&(A=x.createHTML(""));hn&&hn(I),Ot=I}},Rt=ot({},[...em,...tm,...TD]),Mr=ot({},[...im,...kD]),ea=function(I){let V=C(I);(!V||!V.tagName)&&(V={namespaceURI:ii,tagName:"template"});const E=uh(I.tagName),G=uh(V.tagName);return vn[I.namespaceURI]?I.namespaceURI===zi?V.namespaceURI===Ei?E==="svg":V.namespaceURI===Cs?E==="svg"&&(G==="annotation-xml"||On[G]):!!Rt[E]:I.namespaceURI===Cs?V.namespaceURI===Ei?E==="math":V.namespaceURI===zi?E==="math"&&es[G]:!!Mr[E]:I.namespaceURI===Ei?V.namespaceURI===zi&&!es[G]||V.namespaceURI===Cs&&!On[G]?!1:!Mr[E]&&(Dr[E]||!Rt[E]):!!(xn==="application/xhtml+xml"&&vn[I.namespaceURI]):!1},ts=function(I){ac(e.removed,{element:I});try{C(I).removeChild(I)}catch{g(I)}},di=function(I,V){try{ac(e.removed,{attribute:V.getAttributeNode(I),from:V})}catch{ac(e.removed,{attribute:null,from:V})}if(V.removeAttribute(I),I==="is")if(me||nt)try{ts(V)}catch{}else try{V.setAttribute(I,"")}catch{}},Bn=function(I){let V=null,E=null;if(Vt)I=""+I;else{const Ce=Z0(I,/^[\r\n\t ]+/);E=Ce&&Ce[0]}xn==="application/xhtml+xml"&&ii===Ei&&(I=''+I+"");const G=x?x.createHTML(I):I;if(ii===Ei)try{V=new h().parseFromString(G,xn)}catch{}if(!V||!V.documentElement){V=L.createDocument(ii,"template",null);try{V.documentElement.innerHTML=bn?A:G}catch{}}const ne=V.body||V.documentElement;return I&&E&&ne.insertBefore(t.createTextNode(E),ne.childNodes[0]||null),ii===Ei?Q.call(V,He?"html":"body")[0]:He?V.documentElement:ne},wo=function(I){return B.call(I.ownerDocument||I,I,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},ut=function(I){return I instanceof d&&(typeof I.nodeName!="string"||typeof I.textContent!="string"||typeof I.removeChild!="function"||!(I.attributes instanceof u)||typeof I.removeAttribute!="function"||typeof I.setAttribute!="function"||typeof I.namespaceURI!="string"||typeof I.insertBefore!="function"||typeof I.hasChildNodes!="function")},Or=function(I){return typeof a=="function"&&I instanceof a};function st(I,V,E){Sd(I,G=>{G.call(e,V,E,Ot)})}const wn=function(I){let V=null;if(st(M.beforeSanitizeElements,I,null),ut(I))return ts(I),!0;const E=Zt(I.nodeName);if(st(M.uponSanitizeElement,I,{tagName:E,allowedTags:Z}),We&&I.hasChildNodes()&&!Or(I.firstElementChild)&&sn(/<[/\w!]/g,I.innerHTML)&&sn(/<[/\w!]/g,I.textContent)||I.nodeType===dc.progressingInstruction||We&&I.nodeType===dc.comment&&sn(/<[/\w]/g,I.data))return ts(I),!0;if(!Z[E]||bt[E]){if(!bt[E]&&er(E)&&(de.tagNameCheck instanceof RegExp&&sn(de.tagNameCheck,E)||de.tagNameCheck instanceof Function&&de.tagNameCheck(E)))return!1;if(Zs&&!Ri[E]){const G=C(I)||I.parentNode,ne=S(I)||I.childNodes;if(ne&&G){const Ce=ne.length;for(let At=Ce-1;At>=0;--At){const rt=y(ne[At],!0);rt.__removalCount=(I.__removalCount||0)+1,G.insertBefore(rt,_(I))}}}return ts(I),!0}return I instanceof l&&!ea(I)||(E==="noscript"||E==="noembed"||E==="noframes")&&sn(/<\/no(script|embed|frames)/i,I.innerHTML)?(ts(I),!0):(q&&I.nodeType===dc.text&&(V=I.textContent,Sd([he,se,R],G=>{V=lc(V,G," ")}),I.textContent!==V&&(ac(e.removed,{element:I.cloneNode()}),I.textContent=V)),st(M.afterSanitizeElements,I,null),!1)},Br=function(I,V,E){if(_i&&(V==="id"||V==="name")&&(E in t||E in ks))return!1;if(!(re&&!Xe[V]&&sn(J,V))&&!(ht&&sn(F,V))){if(!xe[V]||Xe[V]){if(!(er(I)&&(de.tagNameCheck instanceof RegExp&&sn(de.tagNameCheck,I)||de.tagNameCheck instanceof Function&&de.tagNameCheck(I))&&(de.attributeNameCheck instanceof RegExp&&sn(de.attributeNameCheck,V)||de.attributeNameCheck instanceof Function&&de.attributeNameCheck(V))||V==="is"&&de.allowCustomizedBuiltInElements&&(de.tagNameCheck instanceof RegExp&&sn(de.tagNameCheck,E)||de.tagNameCheck instanceof Function&&de.tagNameCheck(E))))return!1}else if(!Qn[V]&&!sn(ae,lc(E,ie,""))&&!((V==="src"||V==="xlink:href"||V==="href")&&I!=="script"&&wD(E,"data:")===0&&vo[I])&&!(Te&&!sn(X,lc(E,ie,"")))&&E)return!1}return!0},er=function(I){return I!=="annotation-xml"&&Z0(I,ee)},Fn=function(I){st(M.beforeSanitizeAttributes,I,null);const{attributes:V}=I;if(!V||ut(I))return;const E={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:xe,forceKeepAttr:void 0};let G=V.length;for(;G--;){const ne=V[G],{name:Ce,namespaceURI:At,value:rt}=ne,et=Zt(Ce),yi=rt;let ft=Ce==="value"?yi:SD(yi);if(E.attrName=et,E.attrValue=ft,E.keepAttr=!0,E.forceKeepAttr=void 0,st(M.uponSanitizeAttribute,I,E),ft=E.attrValue,Zn&&(et==="id"||et==="name")&&(di(Ce,I),ft=Qo+ft),We&&sn(/((--!?|])>)|<\/(style|title)/i,ft)){di(Ce,I);continue}if(E.forceKeepAttr)continue;if(!E.keepAttr){di(Ce,I);continue}if(!Pe&&sn(/\/>/i,ft)){di(Ce,I);continue}q&&Sd([he,se,R],Bt=>{ft=lc(ft,Bt," ")});const tr=Zt(I.nodeName);if(!Br(tr,et,ft)){di(Ce,I);continue}if(x&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!At)switch(p.getAttributeType(tr,et)){case"TrustedHTML":{ft=x.createHTML(ft);break}case"TrustedScriptURL":{ft=x.createScriptURL(ft);break}}if(ft!==yi)try{At?I.setAttributeNS(At,Ce,ft):I.setAttribute(Ce,ft),ut(I)?ts(I):K0(e.removed)}catch{di(Ce,I)}}st(M.afterSanitizeAttributes,I,null)},tn=function I(V){let E=null;const G=wo(V);for(st(M.beforeSanitizeShadowDOM,V,null);E=G.nextNode();)st(M.uponSanitizeShadowNode,E,null),wn(E),Fn(E),E.content instanceof r&&I(E.content);st(M.afterSanitizeShadowDOM,V,null)};return e.sanitize=function(I){let V=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},E=null,G=null,ne=null,Ce=null;if(bn=!I,bn&&(I=""),typeof I!="string"&&!Or(I))if(typeof I.toString=="function"){if(I=I.toString(),typeof I!="string")throw cc("dirty is not a string, aborting")}else throw cc("toString is not a function");if(!e.isSupported)return I;if(it||Js(V),e.removed=[],typeof I=="string"&&(Li=!1),Li){if(I.nodeName){const et=Zt(I.nodeName);if(!Z[et]||bt[et])throw cc("root node is forbidden and cannot be sanitized in-place")}}else if(I instanceof a)E=Bn(""),G=E.ownerDocument.importNode(I,!0),G.nodeType===dc.element&&G.nodeName==="BODY"||G.nodeName==="HTML"?E=G:E.appendChild(G);else{if(!me&&!q&&!He&&I.indexOf("<")===-1)return x&&ui?x.createHTML(I):I;if(E=Bn(I),!E)return me?null:ui?A:""}E&&Vt&&ts(E.firstChild);const At=wo(Li?I:E);for(;ne=At.nextNode();)wn(ne),Fn(ne),ne.content instanceof r&&tn(ne.content);if(Li)return I;if(me){if(nt)for(Ce=H.call(E.ownerDocument);E.firstChild;)Ce.appendChild(E.firstChild);else Ce=E;return(xe.shadowroot||xe.shadowrootmode)&&(Ce=te.call(n,Ce,!0)),Ce}let rt=He?E.outerHTML:E.innerHTML;return He&&Z["!doctype"]&&E.ownerDocument&&E.ownerDocument.doctype&&E.ownerDocument.doctype.name&&sn(A2,E.ownerDocument.doctype.name)&&(rt=" +`,l.style.top="10px",l.style.left="10px",l.style.position="absolute",l.style.zIndex="9999",l.style.width="100%",l.style.textAlign="left",document.body.appendChild(l),(n=document.getElementsByClassName("luma-compiler-log-error")[0])==null||n.scrollIntoView(),l.onclick=()=>{const c=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(c)}}};U(p2,"defaultProps",{..._n.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0});let SN=p2;function EN(i){return CN(i.source)||i.id||oy(`unnamed ${i.stage}-shader`)}function CN(i,e="unnamed"){const t=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(i);return t?t[1]:e}const g2=class _2 extends _n{constructor(e,t){super(e,t,_2.defaultProps),U(this,"shaderLayout"),U(this,"bufferLayout"),U(this,"linkStatus","pending"),U(this,"hash",""),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}get[Symbol.toStringTag](){return"RenderPipeline"}};U(g2,"defaultProps",{..._n.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},bindings:{},uniforms:{}});let Xh=g2;const y2=class b2 extends _n{constructor(e,t){super(e,t,b2.defaultProps),U(this,"hash",""),U(this,"shaderLayout"),this.shaderLayout=t.shaderLayout}get[Symbol.toStringTag](){return"ComputePipeline"}};U(y2,"defaultProps",{..._n.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0});let W0=y2;function TN(i){return LN[i]}function kN(i){const[e,t]=IN[i],n=e==="i32"||e==="u32",s=e!=="u32",r=AN[e]*t;return{primitiveType:e,components:t,byteLength:r,integer:n,signed:s}}const AN={f32:4,f16:2,i32:4,u32:4},IN={f32:["f32",1],"vec2":["f32",2],"vec3":["f32",3],"vec4":["f32",4],f16:["f16",1],"vec2":["f16",2],"vec3":["f16",3],"vec4":["f16",4],i32:["i32",1],"vec2":["i32",2],"vec3":["i32",3],"vec4":["i32",4],u32:["u32",1],"vec2":["u32",2],"vec3":["u32",3],"vec4":["u32",4]},LN={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2":{type:"f32",components:2},"vec3":{type:"f32",components:3},"vec4":{type:"f32",components:4},"vec2":{type:"f16",components:2},"vec3":{type:"f16",components:3},"vec4":{type:"f16",components:4},"vec2":{type:"i32",components:2},"vec3":{type:"i32",components:3},"vec4":{type:"i32",components:4},"vec2":{type:"u32",components:2},"vec3":{type:"u32",components:3},"vec4":{type:"u32",components:4},"mat2x2":{type:"f32",components:4},"mat2x3":{type:"f32",components:6},"mat2x4":{type:"f32",components:8},"mat3x2":{type:"f32",components:6},"mat3x3":{type:"f32",components:9},"mat3x4":{type:"f32",components:12},"mat4x2":{type:"f32",components:8},"mat4x3":{type:"f32",components:12},"mat4x4":{type:"f32",components:16},"mat2x2":{type:"f16",components:4},"mat2x3":{type:"f16",components:6},"mat2x4":{type:"f16",components:8},"mat3x2":{type:"f16",components:6},"mat3x3":{type:"f16",components:9},"mat3x4":{type:"f16",components:12},"mat4x2":{type:"f16",components:8},"mat4x3":{type:"f16",components:12},"mat4x4":{type:"f16",components:16},"mat2x2":{type:"i32",components:4},"mat2x3":{type:"i32",components:6},"mat2x4":{type:"i32",components:8},"mat3x2":{type:"i32",components:6},"mat3x3":{type:"i32",components:9},"mat3x4":{type:"i32",components:12},"mat4x2":{type:"i32",components:8},"mat4x3":{type:"i32",components:12},"mat4x4":{type:"i32",components:16},"mat2x2":{type:"u32",components:4},"mat2x3":{type:"u32",components:6},"mat2x4":{type:"u32",components:8},"mat3x2":{type:"u32",components:6},"mat3x3":{type:"u32",components:9},"mat3x4":{type:"u32",components:12},"mat4x2":{type:"u32",components:8},"mat4x3":{type:"u32",components:12},"mat4x4":{type:"u32",components:16}};function v2(i,e){const t={};for(const n of i.attributes){const s=RN(i,e,n.name);s&&(t[n.name]=s)}return t}function fte(i,e,t=16){const n=v2(i,e),s=new Array(t).fill(null);for(const r of Object.values(n))s[r.location]=r;return s}function RN(i,e,t){const n=PN(i,t),s=NN(e,t);if(!n)return null;const r=kN(n.type),o=ZP(r),a=(s==null?void 0:s.vertexFormat)||o,l=ly(a);return{attributeName:(s==null?void 0:s.attributeName)||n.name,bufferName:(s==null?void 0:s.bufferName)||n.name,location:n.location,shaderType:n.type,primitiveType:r.primitiveType,shaderComponents:r.components,vertexFormat:a,bufferDataType:l.type,bufferComponents:l.components,normalized:l.normalized,integer:r.integer,stepMode:(s==null?void 0:s.stepMode)||n.stepMode||"vertex",byteOffset:(s==null?void 0:s.byteOffset)||0,byteStride:(s==null?void 0:s.byteStride)||0}}function PN(i,e){const t=i.attributes.find(n=>n.name===e);return t||le.warn(`shader layout attribute "${e}" not present in shader`),t||null}function NN(i,e){DN(i);let t=MN(i,e);return t||(t=ON(i,e),t)?t:(le.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function DN(i){for(const e of i)(e.attributes&&e.format||!e.attributes&&!e.format)&&le.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function MN(i,e){for(const t of i)if(t.format&&t.name===e)return{attributeName:t.name,bufferName:e,stepMode:t.stepMode,vertexFormat:t.format,byteOffset:0,byteStride:t.byteStride||0};return null}function ON(i,e){var t;for(const n of i){let s=n.byteStride;if(typeof n.byteStride!="number")for(const o of n.attributes||[]){const a=ly(o.format);s+=a.byteLength}const r=(t=n.attributes)==null?void 0:t.find(o=>o.attribute===e);if(r)return{attributeName:r.attribute,bufferName:n.name,stepMode:n.stepMode,vertexFormat:r.format,byteOffset:r.byteOffset,byteStride:s}}return null}let xd;function x2(i){return(!xd||xd.byteLengthr.type==="uniform"&&r.name===(e==null?void 0:e.name));if(!n)throw new Error(e==null?void 0:e.name);const s=n;for(const r of s.uniforms||[])this.bindingLayout[r.name]=r}}setUniforms(e){for(const[t,n]of Object.entries(e))this._setUniform(t,n),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${n}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){UN(this.uniforms[e],t)||(this.uniforms[e]=$N(t),this.modifiedUniforms[e]=!0,this.modified=!0)}}let ri=class{constructor(e){U(this,"uniformBlocks",new Map),U(this,"uniformBufferLayouts",new Map),U(this,"uniformBuffers",new Map);for(const[t,n]of Object.entries(e)){const s=t,r=new zN(n.uniformTypes??{},n.uniformSizes??{});this.uniformBufferLayouts.set(s,r);const o=new jN({name:t});o.setUniforms(n.defaultUniforms||{}),this.uniformBlocks.set(s,o)}}destroy(){for(const e of this.uniformBuffers.values())e.destroy()}setUniforms(e){var t;for(const[n,s]of Object.entries(e))(t=this.uniformBlocks.get(n))==null||t.setUniforms(s);this.updateUniformBuffers()}getUniformBufferByteLength(e){var t;return((t=this.uniformBufferLayouts.get(e))==null?void 0:t.byteLength)||0}getUniformBufferData(e){var t,n;const s=((t=this.uniformBlocks.get(e))==null?void 0:t.getAllUniforms())||{};return(n=this.uniformBufferLayouts.get(e))==null?void 0:n.getData(s)}createUniformBuffer(e,t,n){n&&this.setUniforms(n);const s=this.getUniformBufferByteLength(t),r=e.createBuffer({usage:ge.UNIFORM|ge.COPY_DST,byteLength:s}),o=this.getUniformBufferData(t);return r.write(o),r}getManagedUniformBuffer(e,t){if(!this.uniformBuffers.get(t)){const n=this.getUniformBufferByteLength(t),s=e.createBuffer({usage:ge.UNIFORM|ge.COPY_DST,byteLength:n});this.uniformBuffers.set(t,s)}return this.uniformBuffers.get(t)}updateUniformBuffers(){let e=!1;for(const t of this.uniformBlocks.keys()){const n=this.updateUniformBuffer(t);e||(e=n)}return e&&le.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){var t;const n=this.uniformBlocks.get(e);let s=this.uniformBuffers.get(e),r=!1;if(s&&n!=null&&n.needsRedraw){r||(r=n.needsRedraw);const o=this.getUniformBufferData(e);s=this.uniformBuffers.get(e),s==null||s.write(o);const a=(t=this.uniformBlocks.get(e))==null?void 0:t.getAllUniforms();le.log(4,`Writing to uniform buffer ${String(e)}`,o,a)()}return r}};var Do;(function(i){i[i.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",i[i.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",i[i.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",i[i.POINTS=0]="POINTS",i[i.LINES=1]="LINES",i[i.LINE_LOOP=2]="LINE_LOOP",i[i.LINE_STRIP=3]="LINE_STRIP",i[i.TRIANGLES=4]="TRIANGLES",i[i.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",i[i.TRIANGLE_FAN=6]="TRIANGLE_FAN",i[i.ZERO=0]="ZERO",i[i.ONE=1]="ONE",i[i.SRC_COLOR=768]="SRC_COLOR",i[i.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",i[i.SRC_ALPHA=770]="SRC_ALPHA",i[i.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",i[i.DST_ALPHA=772]="DST_ALPHA",i[i.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",i[i.DST_COLOR=774]="DST_COLOR",i[i.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",i[i.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",i[i.CONSTANT_COLOR=32769]="CONSTANT_COLOR",i[i.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",i[i.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",i[i.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",i[i.FUNC_ADD=32774]="FUNC_ADD",i[i.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",i[i.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",i[i.BLEND_EQUATION=32777]="BLEND_EQUATION",i[i.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",i[i.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",i[i.BLEND_DST_RGB=32968]="BLEND_DST_RGB",i[i.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",i[i.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",i[i.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",i[i.BLEND_COLOR=32773]="BLEND_COLOR",i[i.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",i[i.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",i[i.LINE_WIDTH=2849]="LINE_WIDTH",i[i.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",i[i.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",i[i.CULL_FACE_MODE=2885]="CULL_FACE_MODE",i[i.FRONT_FACE=2886]="FRONT_FACE",i[i.DEPTH_RANGE=2928]="DEPTH_RANGE",i[i.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",i[i.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",i[i.DEPTH_FUNC=2932]="DEPTH_FUNC",i[i.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",i[i.STENCIL_FUNC=2962]="STENCIL_FUNC",i[i.STENCIL_FAIL=2964]="STENCIL_FAIL",i[i.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",i[i.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",i[i.STENCIL_REF=2967]="STENCIL_REF",i[i.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",i[i.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",i[i.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",i[i.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",i[i.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",i[i.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",i[i.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",i[i.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",i[i.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",i[i.VIEWPORT=2978]="VIEWPORT",i[i.SCISSOR_BOX=3088]="SCISSOR_BOX",i[i.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",i[i.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",i[i.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",i[i.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",i[i.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",i[i.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",i[i.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",i[i.RED_BITS=3410]="RED_BITS",i[i.GREEN_BITS=3411]="GREEN_BITS",i[i.BLUE_BITS=3412]="BLUE_BITS",i[i.ALPHA_BITS=3413]="ALPHA_BITS",i[i.DEPTH_BITS=3414]="DEPTH_BITS",i[i.STENCIL_BITS=3415]="STENCIL_BITS",i[i.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",i[i.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",i[i.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",i[i.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",i[i.SAMPLES=32937]="SAMPLES",i[i.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",i[i.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",i[i.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",i[i.VENDOR=7936]="VENDOR",i[i.RENDERER=7937]="RENDERER",i[i.VERSION=7938]="VERSION",i[i.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",i[i.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",i[i.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",i[i.STATIC_DRAW=35044]="STATIC_DRAW",i[i.STREAM_DRAW=35040]="STREAM_DRAW",i[i.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",i[i.ARRAY_BUFFER=34962]="ARRAY_BUFFER",i[i.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",i[i.BUFFER_SIZE=34660]="BUFFER_SIZE",i[i.BUFFER_USAGE=34661]="BUFFER_USAGE",i[i.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",i[i.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",i[i.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",i[i.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",i[i.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",i[i.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",i[i.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",i[i.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",i[i.CULL_FACE=2884]="CULL_FACE",i[i.FRONT=1028]="FRONT",i[i.BACK=1029]="BACK",i[i.FRONT_AND_BACK=1032]="FRONT_AND_BACK",i[i.BLEND=3042]="BLEND",i[i.DEPTH_TEST=2929]="DEPTH_TEST",i[i.DITHER=3024]="DITHER",i[i.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",i[i.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",i[i.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",i[i.SCISSOR_TEST=3089]="SCISSOR_TEST",i[i.STENCIL_TEST=2960]="STENCIL_TEST",i[i.NO_ERROR=0]="NO_ERROR",i[i.INVALID_ENUM=1280]="INVALID_ENUM",i[i.INVALID_VALUE=1281]="INVALID_VALUE",i[i.INVALID_OPERATION=1282]="INVALID_OPERATION",i[i.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",i[i.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",i[i.CW=2304]="CW",i[i.CCW=2305]="CCW",i[i.DONT_CARE=4352]="DONT_CARE",i[i.FASTEST=4353]="FASTEST",i[i.NICEST=4354]="NICEST",i[i.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",i[i.BYTE=5120]="BYTE",i[i.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",i[i.SHORT=5122]="SHORT",i[i.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",i[i.INT=5124]="INT",i[i.UNSIGNED_INT=5125]="UNSIGNED_INT",i[i.FLOAT=5126]="FLOAT",i[i.DOUBLE=5130]="DOUBLE",i[i.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",i[i.ALPHA=6406]="ALPHA",i[i.RGB=6407]="RGB",i[i.RGBA=6408]="RGBA",i[i.LUMINANCE=6409]="LUMINANCE",i[i.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",i[i.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",i[i.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",i[i.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",i[i.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",i[i.VERTEX_SHADER=35633]="VERTEX_SHADER",i[i.COMPILE_STATUS=35713]="COMPILE_STATUS",i[i.DELETE_STATUS=35712]="DELETE_STATUS",i[i.LINK_STATUS=35714]="LINK_STATUS",i[i.VALIDATE_STATUS=35715]="VALIDATE_STATUS",i[i.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",i[i.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",i[i.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",i[i.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",i[i.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",i[i.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",i[i.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",i[i.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",i[i.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",i[i.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",i[i.SHADER_TYPE=35663]="SHADER_TYPE",i[i.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",i[i.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",i[i.NEVER=512]="NEVER",i[i.LESS=513]="LESS",i[i.EQUAL=514]="EQUAL",i[i.LEQUAL=515]="LEQUAL",i[i.GREATER=516]="GREATER",i[i.NOTEQUAL=517]="NOTEQUAL",i[i.GEQUAL=518]="GEQUAL",i[i.ALWAYS=519]="ALWAYS",i[i.KEEP=7680]="KEEP",i[i.REPLACE=7681]="REPLACE",i[i.INCR=7682]="INCR",i[i.DECR=7683]="DECR",i[i.INVERT=5386]="INVERT",i[i.INCR_WRAP=34055]="INCR_WRAP",i[i.DECR_WRAP=34056]="DECR_WRAP",i[i.NEAREST=9728]="NEAREST",i[i.LINEAR=9729]="LINEAR",i[i.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",i[i.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",i[i.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",i[i.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",i[i.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",i[i.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",i[i.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",i[i.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",i[i.TEXTURE_2D=3553]="TEXTURE_2D",i[i.TEXTURE=5890]="TEXTURE",i[i.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",i[i.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",i[i.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",i[i.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",i[i.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",i[i.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",i[i.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",i[i.TEXTURE0=33984]="TEXTURE0",i[i.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",i[i.REPEAT=10497]="REPEAT",i[i.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",i[i.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",i[i.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",i[i.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",i[i.FLOAT_VEC2=35664]="FLOAT_VEC2",i[i.FLOAT_VEC3=35665]="FLOAT_VEC3",i[i.FLOAT_VEC4=35666]="FLOAT_VEC4",i[i.INT_VEC2=35667]="INT_VEC2",i[i.INT_VEC3=35668]="INT_VEC3",i[i.INT_VEC4=35669]="INT_VEC4",i[i.BOOL=35670]="BOOL",i[i.BOOL_VEC2=35671]="BOOL_VEC2",i[i.BOOL_VEC3=35672]="BOOL_VEC3",i[i.BOOL_VEC4=35673]="BOOL_VEC4",i[i.FLOAT_MAT2=35674]="FLOAT_MAT2",i[i.FLOAT_MAT3=35675]="FLOAT_MAT3",i[i.FLOAT_MAT4=35676]="FLOAT_MAT4",i[i.SAMPLER_2D=35678]="SAMPLER_2D",i[i.SAMPLER_CUBE=35680]="SAMPLER_CUBE",i[i.LOW_FLOAT=36336]="LOW_FLOAT",i[i.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",i[i.HIGH_FLOAT=36338]="HIGH_FLOAT",i[i.LOW_INT=36339]="LOW_INT",i[i.MEDIUM_INT=36340]="MEDIUM_INT",i[i.HIGH_INT=36341]="HIGH_INT",i[i.FRAMEBUFFER=36160]="FRAMEBUFFER",i[i.RENDERBUFFER=36161]="RENDERBUFFER",i[i.RGBA4=32854]="RGBA4",i[i.RGB5_A1=32855]="RGB5_A1",i[i.RGB565=36194]="RGB565",i[i.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",i[i.STENCIL_INDEX=6401]="STENCIL_INDEX",i[i.STENCIL_INDEX8=36168]="STENCIL_INDEX8",i[i.DEPTH_STENCIL=34041]="DEPTH_STENCIL",i[i.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",i[i.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",i[i.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",i[i.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",i[i.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",i[i.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",i[i.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",i[i.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",i[i.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",i[i.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",i[i.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",i[i.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",i[i.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",i[i.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",i[i.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",i[i.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",i[i.NONE=0]="NONE",i[i.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",i[i.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",i[i.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",i[i.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",i[i.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",i[i.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",i[i.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",i[i.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",i[i.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",i[i.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",i[i.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",i[i.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",i[i.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",i[i.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",i[i.READ_BUFFER=3074]="READ_BUFFER",i[i.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",i[i.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",i[i.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",i[i.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",i[i.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",i[i.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",i[i.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",i[i.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",i[i.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",i[i.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",i[i.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",i[i.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",i[i.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",i[i.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",i[i.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",i[i.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",i[i.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",i[i.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",i[i.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",i[i.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",i[i.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",i[i.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",i[i.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",i[i.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",i[i.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",i[i.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",i[i.RED=6403]="RED",i[i.RGB8=32849]="RGB8",i[i.RGBA8=32856]="RGBA8",i[i.RGB10_A2=32857]="RGB10_A2",i[i.TEXTURE_3D=32879]="TEXTURE_3D",i[i.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",i[i.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",i[i.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",i[i.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",i[i.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",i[i.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",i[i.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",i[i.SRGB=35904]="SRGB",i[i.SRGB8=35905]="SRGB8",i[i.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",i[i.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",i[i.RGBA32F=34836]="RGBA32F",i[i.RGB32F=34837]="RGB32F",i[i.RGBA16F=34842]="RGBA16F",i[i.RGB16F=34843]="RGB16F",i[i.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",i[i.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",i[i.R11F_G11F_B10F=35898]="R11F_G11F_B10F",i[i.RGB9_E5=35901]="RGB9_E5",i[i.RGBA32UI=36208]="RGBA32UI",i[i.RGB32UI=36209]="RGB32UI",i[i.RGBA16UI=36214]="RGBA16UI",i[i.RGB16UI=36215]="RGB16UI",i[i.RGBA8UI=36220]="RGBA8UI",i[i.RGB8UI=36221]="RGB8UI",i[i.RGBA32I=36226]="RGBA32I",i[i.RGB32I=36227]="RGB32I",i[i.RGBA16I=36232]="RGBA16I",i[i.RGB16I=36233]="RGB16I",i[i.RGBA8I=36238]="RGBA8I",i[i.RGB8I=36239]="RGB8I",i[i.RED_INTEGER=36244]="RED_INTEGER",i[i.RGB_INTEGER=36248]="RGB_INTEGER",i[i.RGBA_INTEGER=36249]="RGBA_INTEGER",i[i.R8=33321]="R8",i[i.RG8=33323]="RG8",i[i.R16F=33325]="R16F",i[i.R32F=33326]="R32F",i[i.RG16F=33327]="RG16F",i[i.RG32F=33328]="RG32F",i[i.R8I=33329]="R8I",i[i.R8UI=33330]="R8UI",i[i.R16I=33331]="R16I",i[i.R16UI=33332]="R16UI",i[i.R32I=33333]="R32I",i[i.R32UI=33334]="R32UI",i[i.RG8I=33335]="RG8I",i[i.RG8UI=33336]="RG8UI",i[i.RG16I=33337]="RG16I",i[i.RG16UI=33338]="RG16UI",i[i.RG32I=33339]="RG32I",i[i.RG32UI=33340]="RG32UI",i[i.R8_SNORM=36756]="R8_SNORM",i[i.RG8_SNORM=36757]="RG8_SNORM",i[i.RGB8_SNORM=36758]="RGB8_SNORM",i[i.RGBA8_SNORM=36759]="RGBA8_SNORM",i[i.RGB10_A2UI=36975]="RGB10_A2UI",i[i.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",i[i.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",i[i.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",i[i.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",i[i.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",i[i.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",i[i.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",i[i.HALF_FLOAT=5131]="HALF_FLOAT",i[i.RG=33319]="RG",i[i.RG_INTEGER=33320]="RG_INTEGER",i[i.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",i[i.CURRENT_QUERY=34917]="CURRENT_QUERY",i[i.QUERY_RESULT=34918]="QUERY_RESULT",i[i.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",i[i.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",i[i.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",i[i.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",i[i.DRAW_BUFFER0=34853]="DRAW_BUFFER0",i[i.DRAW_BUFFER1=34854]="DRAW_BUFFER1",i[i.DRAW_BUFFER2=34855]="DRAW_BUFFER2",i[i.DRAW_BUFFER3=34856]="DRAW_BUFFER3",i[i.DRAW_BUFFER4=34857]="DRAW_BUFFER4",i[i.DRAW_BUFFER5=34858]="DRAW_BUFFER5",i[i.DRAW_BUFFER6=34859]="DRAW_BUFFER6",i[i.DRAW_BUFFER7=34860]="DRAW_BUFFER7",i[i.DRAW_BUFFER8=34861]="DRAW_BUFFER8",i[i.DRAW_BUFFER9=34862]="DRAW_BUFFER9",i[i.DRAW_BUFFER10=34863]="DRAW_BUFFER10",i[i.DRAW_BUFFER11=34864]="DRAW_BUFFER11",i[i.DRAW_BUFFER12=34865]="DRAW_BUFFER12",i[i.DRAW_BUFFER13=34866]="DRAW_BUFFER13",i[i.DRAW_BUFFER14=34867]="DRAW_BUFFER14",i[i.DRAW_BUFFER15=34868]="DRAW_BUFFER15",i[i.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",i[i.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",i[i.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",i[i.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",i[i.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",i[i.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",i[i.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",i[i.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",i[i.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",i[i.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",i[i.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",i[i.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",i[i.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",i[i.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",i[i.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",i[i.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",i[i.SAMPLER_3D=35679]="SAMPLER_3D",i[i.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",i[i.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",i[i.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",i[i.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",i[i.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",i[i.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",i[i.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",i[i.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",i[i.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",i[i.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",i[i.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",i[i.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",i[i.MAX_SAMPLES=36183]="MAX_SAMPLES",i[i.SAMPLER_BINDING=35097]="SAMPLER_BINDING",i[i.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",i[i.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",i[i.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",i[i.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",i[i.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",i[i.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",i[i.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",i[i.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",i[i.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",i[i.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",i[i.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",i[i.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",i[i.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",i[i.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",i[i.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",i[i.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",i[i.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",i[i.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",i[i.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",i[i.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",i[i.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",i[i.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",i[i.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",i[i.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",i[i.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",i[i.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",i[i.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",i[i.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",i[i.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",i[i.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",i[i.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",i[i.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",i[i.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",i[i.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",i[i.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",i[i.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",i[i.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",i[i.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",i[i.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",i[i.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",i[i.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",i[i.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",i[i.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",i[i.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",i[i.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",i[i.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",i[i.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",i[i.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",i[i.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",i[i.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",i[i.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",i[i.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",i[i.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",i[i.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",i[i.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",i[i.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",i[i.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",i[i.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",i[i.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",i[i.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",i[i.UNIFORM_TYPE=35383]="UNIFORM_TYPE",i[i.UNIFORM_SIZE=35384]="UNIFORM_SIZE",i[i.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",i[i.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",i[i.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",i[i.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",i[i.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",i[i.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",i[i.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",i[i.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",i[i.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",i[i.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",i[i.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",i[i.OBJECT_TYPE=37138]="OBJECT_TYPE",i[i.SYNC_CONDITION=37139]="SYNC_CONDITION",i[i.SYNC_STATUS=37140]="SYNC_STATUS",i[i.SYNC_FLAGS=37141]="SYNC_FLAGS",i[i.SYNC_FENCE=37142]="SYNC_FENCE",i[i.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",i[i.UNSIGNALED=37144]="UNSIGNALED",i[i.SIGNALED=37145]="SIGNALED",i[i.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",i[i.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",i[i.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",i[i.WAIT_FAILED=37149]="WAIT_FAILED",i[i.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",i[i.COLOR=6144]="COLOR",i[i.DEPTH=6145]="DEPTH",i[i.STENCIL=6146]="STENCIL",i[i.MIN=32775]="MIN",i[i.MAX=32776]="MAX",i[i.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",i[i.STREAM_READ=35041]="STREAM_READ",i[i.STREAM_COPY=35042]="STREAM_COPY",i[i.STATIC_READ=35045]="STATIC_READ",i[i.STATIC_COPY=35046]="STATIC_COPY",i[i.DYNAMIC_READ=35049]="DYNAMIC_READ",i[i.DYNAMIC_COPY=35050]="DYNAMIC_COPY",i[i.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",i[i.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",i[i.INVALID_INDEX=4294967295]="INVALID_INDEX",i[i.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",i[i.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",i[i.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",i[i.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",i[i.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",i[i.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",i[i.R16_EXT=33322]="R16_EXT",i[i.RG16_EXT=33324]="RG16_EXT",i[i.RGB16_EXT=32852]="RGB16_EXT",i[i.RGBA16_EXT=32859]="RGBA16_EXT",i[i.R16_SNORM_EXT=36760]="R16_SNORM_EXT",i[i.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",i[i.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",i[i.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",i[i.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",i[i.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",i[i.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",i[i.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",i[i.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",i[i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",i[i.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",i[i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",i[i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",i[i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",i[i.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",i[i.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",i[i.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",i[i.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",i[i.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",i[i.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",i[i.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",i[i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",i[i.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",i[i.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",i[i.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",i[i.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",i[i.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",i[i.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",i[i.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",i[i.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",i[i.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",i[i.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",i[i.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",i[i.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",i[i.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",i[i.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",i[i.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",i[i.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",i[i.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",i[i.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",i[i.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",i[i.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",i[i.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",i[i.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",i[i.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",i[i.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",i[i.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",i[i.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",i[i.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",i[i.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",i[i.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",i[i.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",i[i.LINE_WEBGL=6913]="LINE_WEBGL",i[i.FILL_WEBGL=6914]="FILL_WEBGL",i[i.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",i[i.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",i[i.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",i[i.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",i[i.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",i[i.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",i[i.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",i[i.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",i[i.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",i[i.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",i[i.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",i[i.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",i[i.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",i[i.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",i[i.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",i[i.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",i[i.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",i[i.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",i[i.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",i[i.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",i[i.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",i[i.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",i[i.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",i[i.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"})(Do||(Do={}));const HN={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},VN=i=>({drawBuffersWEBGL(e){return i.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),GN=i=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return i.createVertexArray()},deleteVertexArrayOES(e){return i.deleteVertexArray(e)},isVertexArrayOES(e){return i.isVertexArray(e)},bindVertexArrayOES(e){return i.bindVertexArray(e)}}),WN=i=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return i.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return i.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return i.vertexAttribDivisor(...e)}});function YN(i=!0){const e=HTMLCanvasElement.prototype;if(!i&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(t,n){if(t==="webgl"||t==="experimental-webgl"){const s=this.originalGetContext("webgl2",n);return s instanceof HTMLElement&&qN(s),s}return this.originalGetContext(t,n)}}function qN(i){i.getExtension("EXT_color_buffer_float");const e={...HN,WEBGL_disjoint_timer_query:i.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:VN(i),OES_vertex_array_object:GN(i),ANGLE_instanced_arrays:WN(i)},t=i.getExtension;i.getExtension=function(s){return t.call(i,s)||(s in e?e[s]:null)};const n=i.getSupportedExtensions;i.getSupportedExtensions=function(){const s=n.apply(i)||[];return s==null?void 0:s.concat(Object.keys(e))}}async function w2(i,e){const t=document.getElementsByTagName("head")[0];if(!t)throw new Error("loadScript");const n=document.createElement("script");return n.setAttribute("type","text/javascript"),n.setAttribute("src",i),new Promise((s,r)=>{n.onload=s,n.onerror=o=>r(new Error(`Unable to load script '${i}': ${o}`)),t.appendChild(n)})}const XN=1;let hi=null,Y0=!1;const uy={debugSpectorJS:le.get("debug-spectorjs"),debugSpectorJSUrl:"https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js",gl:void 0};async function KN(i){if(!globalThis.SPECTOR)try{await w2(i.debugSpectorJSUrl||uy.debugSpectorJSUrl)}catch(e){le.warn(String(e))}}function gte(i){var e;if(i={...uy,...i},!i.debugSpectorJS)return null;if(!hi&&globalThis.SPECTOR&&!((e=globalThis.luma)!=null&&e.spector)){le.probe(XN,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();const{Spector:t}=globalThis.SPECTOR;hi=new t,globalThis.luma&&(globalThis.luma.spector=hi)}if(!hi)return null;if(Y0||(Y0=!0,hi.spyCanvases(),hi==null||hi.onCaptureStarted.add(t=>le.info("Spector capture started:",t)()),hi==null||hi.onCapture.add(t=>{le.info("Spector capture complete:",t)(),hi==null||hi.getResultUI(),hi==null||hi.resultView.display(),hi==null||hi.resultView.addCapture(t)})),i.gl){const t=i.gl,n=t.device;hi==null||hi.startCapture(i.gl,500),t.device=n,new Promise(s=>setTimeout(s,2e3)).then(s=>{le.info("Spector capture stopped after 2 seconds")(),hi==null||hi.stopCapture()})}return hi}const ZN="https://unpkg.com/webgl-debug@2.0.1/index.js";function S2(i){return i.luma=i.luma||{},i.luma}async function QN(){Vu()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await w2(ZN))}function _te(i,e={}){return e.debugWebGL||e.traceWebGL?eD(i,e):JN(i)}function JN(i){const e=S2(i);return e.realContext?e.realContext:i}function eD(i,e){if(!globalThis.WebGLDebugUtils)return le.warn("webgl-debug not loaded")(),i;const t=S2(i);if(t.debugContext)return t.debugContext;globalThis.WebGLDebugUtils.init({...Do,...i});const n=globalThis.WebGLDebugUtils.makeDebugContext(i,tD.bind(null,e),iD.bind(null,e));for(const o in Do)!(o in n)&&typeof Do[o]=="number"&&(n[o]=Do[o]);class s{}Object.setPrototypeOf(n,Object.getPrototypeOf(i)),Object.setPrototypeOf(s,n);const r=Object.create(s);return t.realContext=i,t.debugContext=r,r.debug=!0,r}function q0(i,e){e=Array.from(e).map(n=>n===void 0?"undefined":n);let t=globalThis.WebGLDebugUtils.glFunctionArgsToString(i,e);return t=`${t.slice(0,100)}${t.length>100?"...":""}`,`gl.${i}(${t})`}function tD(i,e,t,n){n=Array.from(n).map(a=>a===void 0?"undefined":a);const s=globalThis.WebGLDebugUtils.glEnumToString(e),r=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,n),o=`${s} in gl.${t}(${r})`;le.error(o)();debugger}function iD(i,e,t){let n="";le.level>=1&&(n=q0(e,t),i.traceWebGL&&le.log(1,n)());for(const s of t)if(s===void 0){n=n||q0(e,t);debugger}}const wd=1;class nD extends fN{constructor(){super(),U(this,"type","webgl"),bg.defaultProps={...bg.defaultProps,...uy}}enforceWebGL2(e){YN(e)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&e instanceof WebGLRenderingContext&&le.warn("WebGL1 is not supported",e)(),!1)}async attach(e,t={}){const{WebGLDevice:n}=await l0(async()=>{const{WebGLDevice:r}=await import("./webgl-device-QoBMYpnS-CGfZSI9d.js");return{WebGLDevice:r}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]));if(e instanceof n)return e;if((e==null?void 0:e.device)instanceof n)return e.device;if(!sD(e))throw new Error("Invalid WebGL2RenderingContext");const s=t.createCanvasContext===!0?{}:t.createCanvasContext;return new n({...t,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...s}})}async create(e={}){const{WebGLDevice:t}=await l0(async()=>{const{WebGLDevice:n}=await import("./webgl-device-QoBMYpnS-CGfZSI9d.js");return{WebGLDevice:n}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]));le.groupCollapsed(wd,"WebGLDevice created")();try{const n=[];(e.debugWebGL||e.debug)&&n.push(QN()),e.debugSpectorJS&&n.push(KN(e));const s=await Promise.allSettled(n);for(const a of s)a.status==="rejected"&&le.error(`Failed to initialize debug libraries ${a.reason}`)();const r=new t(e),o=`${r._reused?"Reusing":"Created"} device with WebGL2 ${r.props.debug?"debug ":""}context: ${r.info.vendor}, ${r.info.renderer} for canvas: ${r.canvasContext.id}`;return le.probe(wd,o)(),le.table(wd,r.info)(),r}finally{le.groupEnd(wd)()}}}function sD(i){return typeof WebGL2RenderingContext<"u"&&i instanceof WebGL2RenderingContext?!0:!!(i&&Number.isFinite(i._version))}const rD=new nD,oD="#b3b3b3",aD=void 0,wg=void 0,lD=1,cD=4,uD="#666666",dD=.1,hD=1,fD=1,E2="#222222",pe={enableSimulation:!0,spaceSize:8192,pointSizeScale:1,linkWidthScale:1,linkArrowsSizeScale:1,renderLinks:!0,curvedLinks:!1,curvedLinkSegments:19,curvedLinkWeight:.8,curvedLinkControlPointDistance:.5,linkArrows:!1,linkVisibilityDistanceRange:[50,150],linkVisibilityMinTransparency:.25,hoveredPointCursor:"auto",hoveredLinkCursor:"auto",renderHoveredPointRing:!1,hoveredPointRingColor:"white",hoveredLinkColor:void 0,hoveredLinkWidthIncrease:5,focusedPointRingColor:"white",focusedPointIndex:void 0,simulation:{decay:5e3,gravity:.25,center:0,repulsion:1,repulsionTheta:1.15,linkSpring:1,linkDistance:10,linkDistRandomVariationRange:[1,1.2],repulsionFromMouse:2,friction:.85,cluster:.1},showFPSMonitor:!1,pixelRatio:typeof window<"u"&&window.devicePixelRatio||2,scalePointsOnZoom:!1,scaleLinksOnZoom:!1,enableZoom:!0,enableSimulationDuringZoom:!1,enableDrag:!1,fitViewOnInit:!0,fitViewDelay:250,fitViewPadding:.1,fitViewDuration:250,pointSamplingDistance:150,attribution:"",rescalePositions:void 0,enableRightClickRepulsion:!1},pD=.7,mD=.95,gD=3;/*! @license DOMPurify 3.2.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.6/LICENSE */const{entries:C2,setPrototypeOf:X0,isFrozen:_D,getPrototypeOf:yD,getOwnPropertyDescriptor:bD}=Object;let{freeze:hn,seal:_s,create:T2}=Object,{apply:Sg,construct:Eg}=typeof Reflect<"u"&&Reflect;hn||(hn=function(i){return i});_s||(_s=function(i){return i});Sg||(Sg=function(i,e,t){return i.apply(e,t)});Eg||(Eg=function(i,e){return new i(...e)});const Sd=fn(Array.prototype.forEach),vD=fn(Array.prototype.lastIndexOf),K0=fn(Array.prototype.pop),ac=fn(Array.prototype.push),xD=fn(Array.prototype.splice),uh=fn(String.prototype.toLowerCase),Jp=fn(String.prototype.toString),Z0=fn(String.prototype.match),lc=fn(String.prototype.replace),wD=fn(String.prototype.indexOf),SD=fn(String.prototype.trim),Ms=fn(Object.prototype.hasOwnProperty),sn=fn(RegExp.prototype.test),cc=ED(TypeError);function fn(i){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s2&&arguments[2]!==void 0?arguments[2]:uh;X0&&X0(i,null);let n=e.length;for(;n--;){let s=e[n];if(typeof s=="string"){const r=t(s);r!==s&&(_D(e)||(e[n]=r),s=r)}i[s]=!0}return i}function CD(i){for(let e=0;e/gm),LD=_s(/\$\{[\w\W]*/gm),RD=_s(/^data-[\-\w.\u00B7-\uFFFF]+$/),PD=_s(/^aria-[\-\w]+$/),k2=_s(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ND=_s(/^(?:\w+script|data):/i),DD=_s(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),A2=_s(/^html$/i),MD=_s(/^[a-z][.\w]*(-[.\w]+)+$/i);var ix=Object.freeze({__proto__:null,ARIA_ATTR:PD,ATTR_WHITESPACE:DD,CUSTOM_ELEMENT:MD,DATA_ATTR:RD,DOCTYPE_NAME:A2,ERB_EXPR:ID,IS_ALLOWED_URI:k2,IS_SCRIPT_OR_DATA:ND,MUSTACHE_EXPR:AD,TMPLIT_EXPR:LD});const dc={element:1,text:3,progressingInstruction:7,comment:8,document:9},OD=function(){return typeof window>"u"?null:window},BD=function(i,e){if(typeof i!="object"||typeof i.createPolicy!="function")return null;let t=null;const n="data-tt-policy-suffix";e&&e.hasAttribute(n)&&(t=e.getAttribute(n));const s="dompurify"+(t?"#"+t:"");try{return i.createPolicy(s,{createHTML(r){return r},createScriptURL(r){return r}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},nx=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function I2(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:OD();const e=I=>I2(I);if(e.version="3.2.6",e.removed=[],!i||!i.document||i.document.nodeType!==dc.document||!i.Element)return e.isSupported=!1,e;let{document:t}=i;const n=t,s=n.currentScript,{DocumentFragment:r,HTMLTemplateElement:o,Node:a,Element:l,NodeFilter:c,NamedNodeMap:u=i.NamedNodeMap||i.MozNamedAttrMap,HTMLFormElement:d,DOMParser:h,trustedTypes:p}=i,m=l.prototype,y=uc(m,"cloneNode"),g=uc(m,"remove"),_=uc(m,"nextSibling"),S=uc(m,"childNodes"),C=uc(m,"parentNode");if(typeof o=="function"){const I=t.createElement("template");I.content&&I.content.ownerDocument&&(t=I.content.ownerDocument)}let x,A="";const{implementation:L,createNodeIterator:B,createDocumentFragment:H,getElementsByTagName:Q}=t,{importNode:te}=n;let M=nx();e.isSupported=typeof C2=="function"&&typeof C=="function"&&L&&L.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:he,ERB_EXPR:se,TMPLIT_EXPR:R,DATA_ATTR:J,ARIA_ATTR:F,IS_SCRIPT_OR_DATA:X,ATTR_WHITESPACE:ie,CUSTOM_ELEMENT:ee}=ix;let{IS_ALLOWED_URI:ae}=ix,Z=null;const Se=ot({},[...Q0,...em,...tm,...im,...J0]);let xe=null;const Je=ot({},[...ex,...nm,...tx,...Ed]);let de=Object.seal(T2(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),bt=null,Xe=null,ht=!0,re=!0,Te=!1,Pe=!0,q=!1,We=!0,He=!1,it=!1,Vt=!1,me=!1,nt=!1,ui=!1,_i=!0,Zn=!1;const Qo="user-content-";let Zs=!0,Li=!1,en={},Ri=null;const ai=ot({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let vo=null;const Es=ot({},["audio","video","img","source","image","track"]);let Qn=null;const Jn=ot({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Cs="http://www.w3.org/1998/Math/MathML",zi="http://www.w3.org/2000/svg",Ei="http://www.w3.org/1999/xhtml";let ii=Ei,bn=!1,vn=null;const Ts=ot({},[Cs,zi,Ei],Jp);let On=ot({},["mi","mo","mn","ms","mtext"]),es=ot({},["annotation-xml"]);const Dr=ot({},["title","style","font","a","script"]);let xn=null;const Qs=["application/xhtml+xml","text/html"],Jo="text/html";let Zt=null,Ot=null;const ks=t.createElement("form"),xo=function(I){return I instanceof RegExp||I instanceof Function},Js=function(){let I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ot&&Ot===I)){if((!I||typeof I!="object")&&(I={}),I=Hr(I),xn=Qs.indexOf(I.PARSER_MEDIA_TYPE)===-1?Jo:I.PARSER_MEDIA_TYPE,Zt=xn==="application/xhtml+xml"?Jp:uh,Z=Ms(I,"ALLOWED_TAGS")?ot({},I.ALLOWED_TAGS,Zt):Se,xe=Ms(I,"ALLOWED_ATTR")?ot({},I.ALLOWED_ATTR,Zt):Je,vn=Ms(I,"ALLOWED_NAMESPACES")?ot({},I.ALLOWED_NAMESPACES,Jp):Ts,Qn=Ms(I,"ADD_URI_SAFE_ATTR")?ot(Hr(Jn),I.ADD_URI_SAFE_ATTR,Zt):Jn,vo=Ms(I,"ADD_DATA_URI_TAGS")?ot(Hr(Es),I.ADD_DATA_URI_TAGS,Zt):Es,Ri=Ms(I,"FORBID_CONTENTS")?ot({},I.FORBID_CONTENTS,Zt):ai,bt=Ms(I,"FORBID_TAGS")?ot({},I.FORBID_TAGS,Zt):Hr({}),Xe=Ms(I,"FORBID_ATTR")?ot({},I.FORBID_ATTR,Zt):Hr({}),en=Ms(I,"USE_PROFILES")?I.USE_PROFILES:!1,ht=I.ALLOW_ARIA_ATTR!==!1,re=I.ALLOW_DATA_ATTR!==!1,Te=I.ALLOW_UNKNOWN_PROTOCOLS||!1,Pe=I.ALLOW_SELF_CLOSE_IN_ATTR!==!1,q=I.SAFE_FOR_TEMPLATES||!1,We=I.SAFE_FOR_XML!==!1,He=I.WHOLE_DOCUMENT||!1,me=I.RETURN_DOM||!1,nt=I.RETURN_DOM_FRAGMENT||!1,ui=I.RETURN_TRUSTED_TYPE||!1,Vt=I.FORCE_BODY||!1,_i=I.SANITIZE_DOM!==!1,Zn=I.SANITIZE_NAMED_PROPS||!1,Zs=I.KEEP_CONTENT!==!1,Li=I.IN_PLACE||!1,ae=I.ALLOWED_URI_REGEXP||k2,ii=I.NAMESPACE||Ei,On=I.MATHML_TEXT_INTEGRATION_POINTS||On,es=I.HTML_INTEGRATION_POINTS||es,de=I.CUSTOM_ELEMENT_HANDLING||{},I.CUSTOM_ELEMENT_HANDLING&&xo(I.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(de.tagNameCheck=I.CUSTOM_ELEMENT_HANDLING.tagNameCheck),I.CUSTOM_ELEMENT_HANDLING&&xo(I.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(de.attributeNameCheck=I.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),I.CUSTOM_ELEMENT_HANDLING&&typeof I.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(de.allowCustomizedBuiltInElements=I.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),q&&(re=!1),nt&&(me=!0),en&&(Z=ot({},J0),xe=[],en.html===!0&&(ot(Z,Q0),ot(xe,ex)),en.svg===!0&&(ot(Z,em),ot(xe,nm),ot(xe,Ed)),en.svgFilters===!0&&(ot(Z,tm),ot(xe,nm),ot(xe,Ed)),en.mathMl===!0&&(ot(Z,im),ot(xe,tx),ot(xe,Ed))),I.ADD_TAGS&&(Z===Se&&(Z=Hr(Z)),ot(Z,I.ADD_TAGS,Zt)),I.ADD_ATTR&&(xe===Je&&(xe=Hr(xe)),ot(xe,I.ADD_ATTR,Zt)),I.ADD_URI_SAFE_ATTR&&ot(Qn,I.ADD_URI_SAFE_ATTR,Zt),I.FORBID_CONTENTS&&(Ri===ai&&(Ri=Hr(Ri)),ot(Ri,I.FORBID_CONTENTS,Zt)),Zs&&(Z["#text"]=!0),He&&ot(Z,["html","head","body"]),Z.table&&(ot(Z,["tbody"]),delete bt.tbody),I.TRUSTED_TYPES_POLICY){if(typeof I.TRUSTED_TYPES_POLICY.createHTML!="function")throw cc('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof I.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw cc('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');x=I.TRUSTED_TYPES_POLICY,A=x.createHTML("")}else x===void 0&&(x=BD(p,s)),x!==null&&typeof A=="string"&&(A=x.createHTML(""));hn&&hn(I),Ot=I}},Rt=ot({},[...em,...tm,...TD]),Mr=ot({},[...im,...kD]),ea=function(I){let V=C(I);(!V||!V.tagName)&&(V={namespaceURI:ii,tagName:"template"});const E=uh(I.tagName),G=uh(V.tagName);return vn[I.namespaceURI]?I.namespaceURI===zi?V.namespaceURI===Ei?E==="svg":V.namespaceURI===Cs?E==="svg"&&(G==="annotation-xml"||On[G]):!!Rt[E]:I.namespaceURI===Cs?V.namespaceURI===Ei?E==="math":V.namespaceURI===zi?E==="math"&&es[G]:!!Mr[E]:I.namespaceURI===Ei?V.namespaceURI===zi&&!es[G]||V.namespaceURI===Cs&&!On[G]?!1:!Mr[E]&&(Dr[E]||!Rt[E]):!!(xn==="application/xhtml+xml"&&vn[I.namespaceURI]):!1},ts=function(I){ac(e.removed,{element:I});try{C(I).removeChild(I)}catch{g(I)}},di=function(I,V){try{ac(e.removed,{attribute:V.getAttributeNode(I),from:V})}catch{ac(e.removed,{attribute:null,from:V})}if(V.removeAttribute(I),I==="is")if(me||nt)try{ts(V)}catch{}else try{V.setAttribute(I,"")}catch{}},Bn=function(I){let V=null,E=null;if(Vt)I=""+I;else{const Ce=Z0(I,/^[\r\n\t ]+/);E=Ce&&Ce[0]}xn==="application/xhtml+xml"&&ii===Ei&&(I=''+I+"");const G=x?x.createHTML(I):I;if(ii===Ei)try{V=new h().parseFromString(G,xn)}catch{}if(!V||!V.documentElement){V=L.createDocument(ii,"template",null);try{V.documentElement.innerHTML=bn?A:G}catch{}}const ne=V.body||V.documentElement;return I&&E&&ne.insertBefore(t.createTextNode(E),ne.childNodes[0]||null),ii===Ei?Q.call(V,He?"html":"body")[0]:He?V.documentElement:ne},wo=function(I){return B.call(I.ownerDocument||I,I,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},ut=function(I){return I instanceof d&&(typeof I.nodeName!="string"||typeof I.textContent!="string"||typeof I.removeChild!="function"||!(I.attributes instanceof u)||typeof I.removeAttribute!="function"||typeof I.setAttribute!="function"||typeof I.namespaceURI!="string"||typeof I.insertBefore!="function"||typeof I.hasChildNodes!="function")},Or=function(I){return typeof a=="function"&&I instanceof a};function st(I,V,E){Sd(I,G=>{G.call(e,V,E,Ot)})}const wn=function(I){let V=null;if(st(M.beforeSanitizeElements,I,null),ut(I))return ts(I),!0;const E=Zt(I.nodeName);if(st(M.uponSanitizeElement,I,{tagName:E,allowedTags:Z}),We&&I.hasChildNodes()&&!Or(I.firstElementChild)&&sn(/<[/\w!]/g,I.innerHTML)&&sn(/<[/\w!]/g,I.textContent)||I.nodeType===dc.progressingInstruction||We&&I.nodeType===dc.comment&&sn(/<[/\w]/g,I.data))return ts(I),!0;if(!Z[E]||bt[E]){if(!bt[E]&&er(E)&&(de.tagNameCheck instanceof RegExp&&sn(de.tagNameCheck,E)||de.tagNameCheck instanceof Function&&de.tagNameCheck(E)))return!1;if(Zs&&!Ri[E]){const G=C(I)||I.parentNode,ne=S(I)||I.childNodes;if(ne&&G){const Ce=ne.length;for(let At=Ce-1;At>=0;--At){const rt=y(ne[At],!0);rt.__removalCount=(I.__removalCount||0)+1,G.insertBefore(rt,_(I))}}}return ts(I),!0}return I instanceof l&&!ea(I)||(E==="noscript"||E==="noembed"||E==="noframes")&&sn(/<\/no(script|embed|frames)/i,I.innerHTML)?(ts(I),!0):(q&&I.nodeType===dc.text&&(V=I.textContent,Sd([he,se,R],G=>{V=lc(V,G," ")}),I.textContent!==V&&(ac(e.removed,{element:I.cloneNode()}),I.textContent=V)),st(M.afterSanitizeElements,I,null),!1)},Br=function(I,V,E){if(_i&&(V==="id"||V==="name")&&(E in t||E in ks))return!1;if(!(re&&!Xe[V]&&sn(J,V))&&!(ht&&sn(F,V))){if(!xe[V]||Xe[V]){if(!(er(I)&&(de.tagNameCheck instanceof RegExp&&sn(de.tagNameCheck,I)||de.tagNameCheck instanceof Function&&de.tagNameCheck(I))&&(de.attributeNameCheck instanceof RegExp&&sn(de.attributeNameCheck,V)||de.attributeNameCheck instanceof Function&&de.attributeNameCheck(V))||V==="is"&&de.allowCustomizedBuiltInElements&&(de.tagNameCheck instanceof RegExp&&sn(de.tagNameCheck,E)||de.tagNameCheck instanceof Function&&de.tagNameCheck(E))))return!1}else if(!Qn[V]&&!sn(ae,lc(E,ie,""))&&!((V==="src"||V==="xlink:href"||V==="href")&&I!=="script"&&wD(E,"data:")===0&&vo[I])&&!(Te&&!sn(X,lc(E,ie,"")))&&E)return!1}return!0},er=function(I){return I!=="annotation-xml"&&Z0(I,ee)},Fn=function(I){st(M.beforeSanitizeAttributes,I,null);const{attributes:V}=I;if(!V||ut(I))return;const E={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:xe,forceKeepAttr:void 0};let G=V.length;for(;G--;){const ne=V[G],{name:Ce,namespaceURI:At,value:rt}=ne,et=Zt(Ce),yi=rt;let ft=Ce==="value"?yi:SD(yi);if(E.attrName=et,E.attrValue=ft,E.keepAttr=!0,E.forceKeepAttr=void 0,st(M.uponSanitizeAttribute,I,E),ft=E.attrValue,Zn&&(et==="id"||et==="name")&&(di(Ce,I),ft=Qo+ft),We&&sn(/((--!?|])>)|<\/(style|title)/i,ft)){di(Ce,I);continue}if(E.forceKeepAttr)continue;if(!E.keepAttr){di(Ce,I);continue}if(!Pe&&sn(/\/>/i,ft)){di(Ce,I);continue}q&&Sd([he,se,R],Bt=>{ft=lc(ft,Bt," ")});const tr=Zt(I.nodeName);if(!Br(tr,et,ft)){di(Ce,I);continue}if(x&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!At)switch(p.getAttributeType(tr,et)){case"TrustedHTML":{ft=x.createHTML(ft);break}case"TrustedScriptURL":{ft=x.createScriptURL(ft);break}}if(ft!==yi)try{At?I.setAttributeNS(At,Ce,ft):I.setAttribute(Ce,ft),ut(I)?ts(I):K0(e.removed)}catch{di(Ce,I)}}st(M.afterSanitizeAttributes,I,null)},tn=function I(V){let E=null;const G=wo(V);for(st(M.beforeSanitizeShadowDOM,V,null);E=G.nextNode();)st(M.uponSanitizeShadowNode,E,null),wn(E),Fn(E),E.content instanceof r&&I(E.content);st(M.afterSanitizeShadowDOM,V,null)};return e.sanitize=function(I){let V=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},E=null,G=null,ne=null,Ce=null;if(bn=!I,bn&&(I=""),typeof I!="string"&&!Or(I))if(typeof I.toString=="function"){if(I=I.toString(),typeof I!="string")throw cc("dirty is not a string, aborting")}else throw cc("toString is not a function");if(!e.isSupported)return I;if(it||Js(V),e.removed=[],typeof I=="string"&&(Li=!1),Li){if(I.nodeName){const et=Zt(I.nodeName);if(!Z[et]||bt[et])throw cc("root node is forbidden and cannot be sanitized in-place")}}else if(I instanceof a)E=Bn(""),G=E.ownerDocument.importNode(I,!0),G.nodeType===dc.element&&G.nodeName==="BODY"||G.nodeName==="HTML"?E=G:E.appendChild(G);else{if(!me&&!q&&!He&&I.indexOf("<")===-1)return x&&ui?x.createHTML(I):I;if(E=Bn(I),!E)return me?null:ui?A:""}E&&Vt&&ts(E.firstChild);const At=wo(Li?I:E);for(;ne=At.nextNode();)wn(ne),Fn(ne),ne.content instanceof r&&tn(ne.content);if(Li)return I;if(me){if(nt)for(Ce=H.call(E.ownerDocument);E.firstChild;)Ce.appendChild(E.firstChild);else Ce=E;return(xe.shadowroot||xe.shadowrootmode)&&(Ce=te.call(n,Ce,!0)),Ce}let rt=He?E.outerHTML:E.innerHTML;return He&&Z["!doctype"]&&E.ownerDocument&&E.ownerDocument.doctype&&E.ownerDocument.doctype.name&&sn(A2,E.ownerDocument.doctype.name)&&(rt=" `+rt),q&&Sd([he,se,R],et=>{rt=lc(rt,et," ")}),x&&ui?x.createHTML(rt):rt},e.setConfig=function(){let I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Js(I),it=!0},e.clearConfig=function(){Ot=null,it=!1},e.isValidAttribute=function(I,V,E){Ot||Js({});const G=Zt(I),ne=Zt(V);return Br(G,ne,E)},e.addHook=function(I,V){typeof V=="function"&&ac(M[I],V)},e.removeHook=function(I,V){if(V!==void 0){const E=vD(M[I],V);return E===-1?void 0:xD(M[I],E,1)[0]}return K0(M[I])},e.removeHooks=function(I){M[I]=[]},e.removeAllHooks=function(){M=nx()},e}var FD=I2();const zD=i=>typeof i=="function",L2=i=>Array.isArray(i),UD=i=>i instanceof Object,$D=i=>i instanceof Object?i.constructor.name!=="Function"&&i.constructor.name!=="Object":!1,sx=i=>UD(i)&&!L2(i)&&!zD(i)&&!$D(i);function Mo(i){let e;if(L2(i))e=i;else{const t=Uo(i),n=t==null?void 0:t.rgb();e=[(n==null?void 0:n.r)||0,(n==null?void 0:n.g)||0,(n==null?void 0:n.b)||0,(t==null?void 0:t.opacity)??1]}return[e[0]/255,e[1]/255,e[2]/255,e[3]]}function jD(i,e,t){return .2126*i+.7152*e+.0722*t}function jn(i,e,t=0,n=0,s,r){return i.readPixelsToArrayWebGL(e,{sourceX:t,sourceY:n,sourceWidth:s,sourceHeight:r})}function HD(i,e,t){return Math.min(Math.max(i,e),t)}function rs(i){return i!=null&&!Number.isNaN(i)}function VD(i,e){return FD.sanitize(i,{ALLOWED_TAGS:["a","b","i","em","strong","span","div","p","br"],ALLOWED_ATTR:["href","target","class","id","style"],ALLOW_DATA_ATTR:!1,...e})}class GD{constructor(){this.enableSimulation=pe.enableSimulation,this.backgroundColor=E2,this.spaceSize=pe.spaceSize,this.pointColor=oD,this.pointDefaultColor=void 0,this.pointGreyoutOpacity=aD,this.pointGreyoutColor=wg,this.pointSize=cD,this.pointDefaultSize=void 0,this.pointOpacity=lD,this.pointSizeScale=pe.pointSizeScale,this.hoveredPointCursor=pe.hoveredPointCursor,this.hoveredLinkCursor=pe.hoveredLinkCursor,this.renderHoveredPointRing=pe.renderHoveredPointRing,this.hoveredPointRingColor=pe.hoveredPointRingColor,this.focusedPointRingColor=pe.focusedPointRingColor,this.focusedPointIndex=pe.focusedPointIndex,this.linkColor=uD,this.linkDefaultColor=void 0,this.linkOpacity=hD,this.linkGreyoutOpacity=dD,this.linkWidth=fD,this.linkDefaultWidth=void 0,this.linkWidthScale=pe.linkWidthScale,this.hoveredLinkColor=pe.hoveredLinkColor,this.hoveredLinkWidthIncrease=pe.hoveredLinkWidthIncrease,this.renderLinks=pe.renderLinks,this.curvedLinks=pe.curvedLinks,this.curvedLinkSegments=pe.curvedLinkSegments,this.curvedLinkWeight=pe.curvedLinkWeight,this.curvedLinkControlPointDistance=pe.curvedLinkControlPointDistance,this.linkArrows=pe.linkArrows,this.linkDefaultArrows=void 0,this.linkArrowsSizeScale=pe.linkArrowsSizeScale,this.scaleLinksOnZoom=pe.scaleLinksOnZoom,this.linkVisibilityDistanceRange=pe.linkVisibilityDistanceRange,this.linkVisibilityMinTransparency=pe.linkVisibilityMinTransparency,this.simulationDecay=pe.simulation.decay,this.simulationGravity=pe.simulation.gravity,this.simulationCenter=pe.simulation.center,this.simulationRepulsion=pe.simulation.repulsion,this.simulationRepulsionTheta=pe.simulation.repulsionTheta,this.simulationLinkSpring=pe.simulation.linkSpring,this.simulationLinkDistance=pe.simulation.linkDistance,this.simulationLinkDistRandomVariationRange=pe.simulation.linkDistRandomVariationRange,this.simulationRepulsionFromMouse=pe.simulation.repulsionFromMouse,this.enableRightClickRepulsion=pe.enableRightClickRepulsion,this.simulationFriction=pe.simulation.friction,this.simulationCluster=pe.simulation.cluster,this.onSimulationStart=void 0,this.onSimulationTick=void 0,this.onSimulationEnd=void 0,this.onSimulationPause=void 0,this.onSimulationRestart=void 0,this.onSimulationUnpause=void 0,this.onClick=void 0,this.onPointClick=void 0,this.onLinkClick=void 0,this.onBackgroundClick=void 0,this.onMouseMove=void 0,this.onPointMouseOver=void 0,this.onPointMouseOut=void 0,this.onLinkMouseOver=void 0,this.onLinkMouseOut=void 0,this.onZoomStart=void 0,this.onZoom=void 0,this.onZoomEnd=void 0,this.onDragStart=void 0,this.onDrag=void 0,this.onDragEnd=void 0,this.showFPSMonitor=pe.showFPSMonitor,this.pixelRatio=pe.pixelRatio,this.scalePointsOnZoom=pe.scalePointsOnZoom,this.initialZoomLevel=void 0,this.enableZoom=pe.enableZoom,this.enableSimulationDuringZoom=pe.enableSimulationDuringZoom,this.enableDrag=pe.enableDrag,this.fitViewOnInit=pe.fitViewOnInit,this.fitViewDelay=pe.fitViewDelay,this.fitViewPadding=pe.fitViewPadding,this.fitViewDuration=pe.fitViewDuration,this.fitViewByPointsInRect=void 0,this.fitViewByPointIndices=void 0,this.randomSeed=void 0,this.pointSamplingDistance=pe.pointSamplingDistance,this.attribution=pe.attribution,this.rescalePositions=pe.rescalePositions}init(e){Object.keys(e).forEach(t=>{this.deepMergeConfig(this.getConfig(),e,t)})}deepMergeConfig(e,t,n){sx(e[n])&&sx(t[n])?Object.keys(t[n]).forEach(s=>{this.deepMergeConfig(e[n],t[n],s)}):e[n]=t[n]}getConfig(){return this}}function dy(i,e){if(!i)throw new Error(e||"shadertools: assertion failed.")}const sm={number:{type:"number",validate(i,e){return Number.isFinite(i)&&typeof e=="object"&&(e.max===void 0||i<=e.max)&&(e.min===void 0||i>=e.min)}},array:{type:"array",validate(i,e){return Array.isArray(i)||ArrayBuffer.isView(i)}}};function WD(i){const e={};for(const[t,n]of Object.entries(i))e[t]=YD(n);return e}function YD(i){let e=rx(i);if(e!=="object")return{value:i,...sm[e],type:e};if(typeof i=="object")return i?i.type!==void 0?{...i,...sm[i.type],type:i.type}:i.value===void 0?{type:"object",value:i}:(e=rx(i.value),{...i,...sm[e],type:e}):{type:"object",value:null};throw new Error("props")}function rx(i){return Array.isArray(i)||ArrayBuffer.isView(i)?"array":typeof i}const qD=`#ifdef MODULE_LOGDEPTH logdepth_adjustPosition(gl_Position); #endif @@ -2630,5 +2630,5 @@ Missing columns: ${C.map(L=>`'${L.name}' (\`${L.prop}\`)`).join(", ")}.`,"data-k `,og={onZoomInClick:void 0,onZoomOutClick:void 0,zoomInIconSvg:SJ,zoomOutIconSvg:EJ,duration:250,zoomIncrement:1.4};var CJ=".style_module_zoomButtons__738b35dc{height:50px;margin:3px;width:25px}.style_module_zoomButton__738b35dc{height:50%;margin:0;width:100%}.style_module_zoomInButton__738b35dc{border-radius:2px 2px 0 0}.style_module_zoomOutButton__738b35dc{border-radius:0 0 2px 2px}",Lc={zoomButtons:"style_module_zoomButtons__738b35dc",zoomButton:"style_module_zoomButton__738b35dc",zoomInButton:"style_module_zoomInButton__738b35dc",zoomOutButton:"style_module_zoomOutButton__738b35dc"};Nr(CJ,{});let TJ=class{constructor(e,t,n){b(this,"_internalApi");b(this,"_config");b(this,"_zoomInButtonConfig");b(this,"_zoomOutButtonConfig");b(this,"_zoomInButton");b(this,"_zoomOutButton");b(this,"_zoomInButtonDiv");b(this,"_zoomOutButtonDiv");b(this,"_show",()=>{this._zoomInButton.show(),this._zoomOutButton.show()});this._internalApi=La(e),t.classList.add(Lc.zoomButtons),this._zoomInButtonDiv=document.createElement("div"),this._zoomInButtonDiv.classList.add(Lc.zoomButton,Lc.zoomInButton),this._zoomOutButtonDiv=document.createElement("div"),this._zoomOutButtonDiv.classList.add(Lc.zoomButton,Lc.zoomOutButton),t.appendChild(this._zoomInButtonDiv),t.appendChild(this._zoomOutButtonDiv),this._zoomInButton=new Ca(this._zoomInButtonDiv),this._zoomOutButton=new Ca(this._zoomOutButtonDiv),this._internalApi.addEventListener("graphRebuilt",this._show),this.setConfig(n??{})}setConfig(e){this._config=Wt(og,e??{}),this._zoomInButtonConfig={onClick:()=>{var n,s;const t=this._internalApi.public.getZoomLevel();if(t){const r=this._config.zoomIncrement??og.zoomIncrement;this._internalApi.public.setZoomLevel(t*r,this._config.duration)}(s=(n=this._config).onZoomInClick)==null||s.call(n)},iconSvg:this._config.zoomInIconSvg},this._zoomOutButtonConfig={onClick:()=>{var n,s;const t=this._internalApi.public.getZoomLevel();if(t){const r=this._config.zoomIncrement??og.zoomIncrement;this._internalApi.public.setZoomLevel(t/r,this._config.duration)}(s=(n=this._config).onZoomOutClick)==null||s.call(n)},iconSvg:this._config.zoomOutIconSvg},this._zoomInButton.setConfig(this._zoomInButtonConfig),this._zoomOutButton.setConfig(this._zoomOutButtonConfig)}remove(){this._zoomInButton.destroy(),this._zoomOutButton.destroy(),this._internalApi.removeEventListener("graphRebuilt",this._show)}};class kJ{constructor(e,t,n={}){b(this,"_button");this._button=new Ca(t,n)}setConfig(e={}){this._button.setConfig(e)}remove(){this._button.destroy()}show(){this._button.show()}hide(){this._button.hide()}}function AJ({style:i,className:e,onMount:t,duckDBConnection:n,...s},r){const o=K_(),a=$.useRef(null),l=$.useRef(),c=$.useRef(!1),u=$.useRef(!1),[d,h]=$.useState(!1);return c.current&&(u.current=!0),$.useEffect(()=>{if(!c.current&&a.current){const p=new xQ(a.current,s,n);l.current=p,c.current=!0,o==null||o.initCosmograph(l.current),h(!0),t&&t(l.current)}return()=>{var p;u.current&&((p=l.current)==null||p.destroy(),h(!1))}},[]),$.useEffect(()=>{(async()=>l.current&&d&&await l.current.setConfig(s))()},[s,d]),$.useImperativeHandle(r,()=>l.current,[d]),cn.createElement("div",{style:i,className:e,ref:a})}const uS=cn.memo(cn.forwardRef(AJ)),vI={display:"flex",justifyContent:"center",alignItems:"center",height:"100%",width:"100%",opacity:.25,fontSize:12,fontWeight:300,whiteSpace:"pre-wrap"},ip=(i,e,t=new Set)=>{if(Array.isArray(i)){if(!Array.isArray(e)||i.length!==e.length)return!1;if(t.has(i))return!0;t.add(i);for(let n=0;n{const r=K_(),o=$.useRef(null),a=$.useRef(),l=$.useRef({}),[c,u]=$.useState(!1);return $.useEffect(()=>{if(o.current&&(r!=null&&r.cosmograph)){const{style:d,className:h,...p}=n;a.current=new i(r.cosmograph,o.current,p),l.current=n,u(!0)}return()=>{var d,h;(h=(d=a.current)==null?void 0:d.remove)==null||h.call(d)}},[r==null?void 0:r.cosmograph]),$.useEffect(()=>{var d,h;if(!ip(n,l.current)){const{style:p,className:m,...y}=n;(h=(d=a.current)==null?void 0:d.setConfig)==null||h.call(d,y),l.current=n}},[n]),$.useImperativeHandle(s,()=>a.current,[c]),r?cn.createElement("div",{id:e,style:n.style,className:n.className,ref:o}):cn.createElement("div",{style:n.style,className:n.className},cn.createElement("div",{style:vI},"⚠️ ",cn.createElement("b",null,e)," should be used under ",cn.createElement("b",null,"CosmographProvider")))});return t.displayName=e,cn.memo(t)}Kn(RQ);Kn(kQ);Kn(AQ);Kn(NQ);const xI=cn.forwardRef((i,e)=>{const t=K_(),n=$.useRef(),s=$.useRef(i),[r,o]=$.useState(!1);return $.useEffect(()=>(t!=null&&t.cosmograph&&(n.current=new sJ(t.cosmograph,i),s.current=i,o(!0)),()=>{var a;(a=n.current)==null||a.remove()}),[t==null?void 0:t.cosmograph]),$.useEffect(()=>{var a;ip(i,s.current)||((a=n.current)==null||a.setConfig(i),s.current=i)},[i]),$.useImperativeHandle(e,()=>n.current,[r]),t?null:cn.createElement("div",{style:vI},"⚠️ ",cn.createElement("b",null,"CosmographPopup")," should be used under ",cn.createElement("b",null,"CosmographProvider"))});xI.displayName="CosmographPopup";cn.memo(xI);Kn(aJ);Kn(uJ);Kn(fJ);Kn(kJ);Kn(gJ);Kn(yJ);Kn(vJ);Kn(wJ);Kn(TJ);function IJ(i,e=1e3){const[t,n]=$.useState(i),s=$.useRef(Date.now()),r=$.useRef(null);return $.useEffect(()=>{const o=Date.now(),a=e-(o-s.current);return a<=0?(n(i),s.current=o):(r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{n(i),s.current=Date.now()},a)),()=>{r.current&&clearTimeout(r.current)}},[i,e]),t}function LJ(i){if(i==null)return"";const e=String(i);return e.includes(",")||e.includes('"')||e.includes(` `)?`"${e.replace(/"/g,'""')}"`:e}function jp(i,e){const t=[i.join(",")];for(const n of e)t.push(n.map(LJ).join(","));return t.join(` `)}function sa(i){return i.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function wI(i){return!i||i<=0?"":new Date(i*1e3).toISOString()}function ag(i,e){const n=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19);return`${i}-${n}.${e}`}const RJ=["hash","prefix","name","nodeClass","communityId","degree","inDegree","outDegree","betweenness","pathDiversity","packetCount","lastSeen","activityLevel","recencyScore","avgRssi","avgSnr","isZeroHop","prefixConfidence","hasCollision","collisionCandidates","isLocal","isHub","isGateway","isBackbone","isMobile","isGhost","isInLoop","latitude","longitude","contactType"];function PJ(i){var e,t;return[i.hash,i.prefix,i.name??"",i.nodeClass,i.communityId,i.degree,i.inDegree,i.outDegree,i.betweenness.toFixed(6),i.pathDiversity,i.packetCount,wI(i.lastSeen),i.activityLevel,i.recencyScore.toFixed(4),((e=i.avgRssi)==null?void 0:e.toFixed(1))??"",((t=i.avgSnr)==null?void 0:t.toFixed(1))??"",i.isZeroHop,i.prefixConfidence.toFixed(4),i.hasCollision,i.collisionCandidates,i.isLocal,i.isHub,i.isGateway,i.isBackbone,i.isMobile,i.isGhost,i.isInLoop,i.latitude??"",i.longitude??"",i.contactType??""]}function dS(i,e){const t=[];for(const n of i.nodeMetrics.values())!e&&n.isGhost||t.push(PJ(n));return jp(RJ,t)}function NJ(i,e){const t=[];for(const n of i.nodeMetrics.values())!e&&n.isGhost||t.push({hash:n.hash,prefix:n.prefix,name:n.name,nodeClass:n.nodeClass,communityId:n.communityId,degree:n.degree,inDegree:n.inDegree,outDegree:n.outDegree,betweenness:n.betweenness,pathDiversity:n.pathDiversity,packetCount:n.packetCount,lastSeen:n.lastSeen,activityLevel:n.activityLevel,recencyScore:n.recencyScore,avgRssi:n.avgRssi,avgSnr:n.avgSnr,isZeroHop:n.isZeroHop,prefixConfidence:n.prefixConfidence,hasCollision:n.hasCollision,isLocal:n.isLocal,isHub:n.isHub,isGateway:n.isGateway,isBackbone:n.isBackbone,isMobile:n.isMobile,isGhost:n.isGhost,isInLoop:n.isInLoop,latitude:n.latitude,longitude:n.longitude,contactType:n.contactType});return t}const DJ=["fromHash","toHash","key","packetCount","certainCount","avgConfidence","strength","forwardCount","reverseCount","symmetryRatio","dominantDirection","floodCount","directCount","isDirectPathEdge","isZeroHop","isLoopEdge","isCertain","avgRssi","avgSnr","avgRecency","hopDistanceFromLocal","edgeBetweenness","isBackbone"];function MJ(i,e,t){var n,s;return[i.fromHash,i.toHash,i.key,i.packetCount,i.certainCount,i.avgConfidence.toFixed(4),i.strength.toFixed(4),i.forwardCount,i.reverseCount,i.symmetryRatio.toFixed(4),i.dominantDirection,i.floodCount,i.directCount,i.isDirectPathEdge,i.isZeroHop??!1,i.isLoopEdge??!1,i.isCertain,((n=i.avgRssi)==null?void 0:n.toFixed(1))??"",((s=i.avgSnr)==null?void 0:s.toFixed(1))??"",i.avgRecency.toFixed(4),i.hopDistanceFromLocal,(e.get(i.key)??0).toFixed(6),t.has(i.key)]}function OJ(i,e){const t=e?i.edges:i.validatedEdges,n=new Set(i.backboneEdges),s=t.map(r=>MJ(r,i.edgeBetweenness,n));return jp(DJ,s)}function BJ(i,e){const t=e?i.edges:i.validatedEdges,n=new Set(i.backboneEdges);return t.map(s=>({fromHash:s.fromHash,toHash:s.toHash,key:s.key,packetCount:s.packetCount,certainCount:s.certainCount,avgConfidence:s.avgConfidence,strength:s.strength,forwardCount:s.forwardCount,reverseCount:s.reverseCount,symmetryRatio:s.symmetryRatio,dominantDirection:s.dominantDirection,floodCount:s.floodCount,directCount:s.directCount,isDirectPathEdge:s.isDirectPathEdge,isZeroHop:s.isZeroHop??!1,isLoopEdge:s.isLoopEdge??!1,isCertain:s.isCertain,avgRssi:s.avgRssi??null,avgSnr:s.avgSnr??null,avgRecency:s.avgRecency,hopDistanceFromLocal:s.hopDistanceFromLocal,edgeBetweenness:i.edgeBetweenness.get(s.key)??0,isBackbone:n.has(s.key)}))}const FJ=["pathKey","hops","hopCount","healthScore","weakestLinkKey","weakestLinkConfidence","avgEdgeCertainty","observationTrend","alternatePathsCount","estimatedLatencyMs","observationCount","routeType","lastSeen","involvesHub"];function zJ(i){return[i.pathKey,i.hops.join(">"),i.hops.length,i.healthScore.toFixed(4),i.weakestLinkKey??"",i.weakestLinkConfidence.toFixed(4),i.avgEdgeCertainty.toFixed(4),i.observationTrend.toFixed(4),i.alternatePathsCount,i.estimatedLatencyMs.toFixed(0),i.observationCount,i.routeType,wI(i.lastSeen),i.involvesHub]}function UJ(i){const e=i.pathHealth.map(zJ);return jp(FJ,e)}const $J=["nodeHash","nodePrefix","nodeName","networkRole","floodFactor","directFactor","floodSlots","directSlots","trafficIntensity","directNeighborCount","collisionRisk","confidence","adjustment","dataConfidence","observationSymmetry","rationale"];function jJ(i,e,t){const n=t.get(i);return[i,(n==null?void 0:n.prefix)??"",(n==null?void 0:n.name)??"",e.networkRole,e.floodFactor.toFixed(2),e.directFactor.toFixed(2),e.floodSlots,e.directSlots,e.trafficIntensity.toFixed(4),e.directNeighborCount,e.collisionRisk.toFixed(4),e.confidence.toFixed(4),e.adjustment,e.dataConfidence,e.observationSymmetry.toFixed(4),e.rationale]}function HJ(i){const e=[];for(const[t,n]of i.txDelayRecommendations)e.push(jJ(t,n,i.nodeMetrics));return jp($J,e)}function VJ(i,e){var r,o;const t=new Set(i.backboneEdges),s=['','',` `,` pymc_console v${CS}`," MeshCore LoRa Mesh Network Topology"," ",' ',""," ",' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '," ",""," ",' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '," ",""," "];for(const a of i.nodeMetrics.values()){if(!e&&a.isGhost)continue;const l=sa(a.name??a.prefix);s.push(` `),s.push(" "),s.push(` `),s.push(` `),s.push(` `),s.push(` `),s.push(` `),s.push(` `),s.push(` `),s.push(` `),s.push(` `),s.push(` `),s.push(` `),s.push(` `),s.push(` `),s.push(` `),s.push(` `),a.avgRssi!=null&&s.push(` `),a.avgSnr!=null&&s.push(` `),s.push(" "),a.latitude!=null&&a.longitude!=null&&(a.latitude!==0||a.longitude!==0)&&s.push(` `),s.push(" ")}s.push(" "),s.push(""),s.push(" ");for(const a of i.validatedEdges){const l=i.nodeMetrics;if(!e&&((r=l.get(a.fromHash))!=null&&r.isGhost||(o=l.get(a.toHash))!=null&&o.isGhost))continue;const c=i.edgeBetweenness.get(a.key)??0;s.push(` `),s.push(" "),s.push(` `),s.push(` `),s.push(` `),s.push(` `),s.push(` `),s.push(` `),s.push(` `),s.push(` `),s.push(` `),s.push(` `),s.push(` `),s.push(` `),s.push(" "),s.push(" ")}return s.push(" "),s.push(" "),s.push(""),s.join(` -`)}function GJ(i,e,t){const n={meta:{exportedAt:new Date().toISOString(),pymcConsoleVersion:CS,nodeCount:i.nodeMetrics.size,edgeCount:i.validatedEdges.length,communityCount:i.communityCount,loopCount:i.loops.length,backboneEdgeCount:i.backboneEdges.length,hubNodes:i.hubNodes.length,gatewayNodes:i.gatewayNodes.length,mobileNodes:i.mobileNodes.length,ghostNodes:i.discoveredNodes.filter(s=>s.isLikelyReal).length},nodes:NJ(i,e),edges:BJ(i,t),pathHealth:i.pathHealth.map(s=>({pathKey:s.pathKey,hops:s.hops,healthScore:s.healthScore,weakestLinkKey:s.weakestLinkKey,weakestLinkConfidence:s.weakestLinkConfidence,avgEdgeCertainty:s.avgEdgeCertainty,observationTrend:s.observationTrend,alternatePathsCount:s.alternatePathsCount,estimatedLatencyMs:s.estimatedLatencyMs,observationCount:s.observationCount,routeType:s.routeType,lastSeen:s.lastSeen,involvesHub:s.involvesHub})),txDelayRecommendations:Array.from(i.txDelayRecommendations.entries()).map(([s,r])=>{var o,a;return{nodeHash:s,nodePrefix:((o=i.nodeMetrics.get(s))==null?void 0:o.prefix)??"",nodeName:((a=i.nodeMetrics.get(s))==null?void 0:a.name)??null,networkRole:r.networkRole,floodFactor:r.floodFactor,directFactor:r.directFactor,floodSlots:r.floodSlots,directSlots:r.directSlots,trafficIntensity:r.trafficIntensity,collisionRisk:r.collisionRisk,confidence:r.confidence,adjustment:r.adjustment,dataConfidence:r.dataConfidence,rationale:r.rationale}}),loops:i.loops.map(s=>({id:s.id,nodes:s.nodes,edgeKeys:s.edgeKeys,size:s.size,avgCertainCount:s.avgCertainCount,minCertainCount:s.minCertainCount,includesLocal:s.includesLocal,strength:s.strength})),disambiguationStats:{totalPrefixes:i.disambiguationStats.totalPrefixes,unambiguousPrefixes:i.disambiguationStats.unambiguousPrefixes,collisionPrefixes:i.disambiguationStats.collisionPrefixes,collisionRate:i.disambiguationStats.collisionRate,avgConfidence:i.disambiguationStats.avgConfidence},viterbiStats:{totalPaths:i.viterbiStats.totalPaths,pathsWithGhosts:i.viterbiStats.pathsWithGhosts,avgPathConfidence:i.viterbiStats.avgPathConfidence,tracePacketsProcessed:i.viterbiStats.tracePacketsProcessed,pathPacketsProcessed:i.viterbiStats.pathPacketsProcessed,distantEdgesDiscovered:i.viterbiStats.distantEdgesDiscovered,duplicateGroupsFound:i.viterbiStats.duplicateGroupsFound,echolocationEdgesInferred:i.viterbiStats.echolocationEdgesInferred}};return JSON.stringify(n,null,2)}function WJ(i,e){const t=e.includeGhosts??!0,n=e.includeWeakEdges??!1;switch(e.format){case"csv":{let s,r;switch(e.dataset){case"nodes":s=dS(i,t),r="mesh-nodes";break;case"edges":s=OJ(i,n),r="mesh-edges";break;case"pathHealth":s=UJ(i),r="mesh-path-health";break;case"txDelay":s=HJ(i),r="mesh-tx-delay";break;case"full":default:s=dS(i,t),r="mesh-nodes";break}return{content:s,filename:ag(r,"csv"),mimeType:"text/csv"}}case"gexf":return{content:VJ(i,t),filename:ag("mesh-topology","gexf"),mimeType:"application/xml"};case"json":default:return{content:GJ(i,t,n),filename:ag("mesh-topology","json"),mimeType:"application/json"}}}function YJ(i){const e=new Blob([i.content],{type:i.mimeType}),t=URL.createObjectURL(e),n=document.createElement("a");n.href=t,n.download=i.filename,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}function qJ(i,e){const t=WJ(i,e);YJ(t)}const XJ=1e-7,KJ=10;function ZJ(i,e,t=1){const n=e.length,s=new Map;for(let l=0;l[]),o=new Array(n).fill(0);let a=0;for(const l of i){const c=s.get(l.fromHash),u=s.get(l.toHash);if(c===void 0||u===void 0||c===u)continue;const d=Math.max(.01,(l.certainCount+1)*l.avgConfidence*l.strength),h=t===1?d:Math.pow(d,t);r[c].push({j:u,w:h}),r[u].push({j:c,w:h}),o[c]+=h,o[u]+=h,a+=h}return{graph:{n,adjList:r,totalWeight:a,degree:o},hashToIdx:s}}function QJ(i,e,t=1){const{n,adjList:s,totalWeight:r,degree:o}=i;if(r===0)return!1;const a=2*r,l=new Float64Array(n);for(let d=0;dC+XJ&&(C=B,S=x)}S!==h&&(l[h]-=p,l[S]+=p,e[d]=S,u=!0,c=!0)}}return c}function JJ(i,e){const{n:t,adjList:n}=i,s=new Set;for(let p=0;pp-m),o=new Map;for(let p=0;p[]);for(const[p,m]of c){const[y,g]=p.split("-").map(Number),_=m/2;h[y].push({j:g,w:_}),h[g].push({j:y,w:_}),u[y]+=_,u[g]+=_,d+=_}return{newGraph:{n:a,adjList:h,totalWeight:d,degree:Array.from(u)},mapping:l}}function eee(i,e,t=1){const{n,adjList:s,totalWeight:r,degree:o}=i;if(r===0)return 0;const a=2*r;let l=0;for(let c=0;c=a.n)break;a=C,l=new Int32Array(C.n);for(let A=0;AS-C),m=new Map;for(let S=0;S=th.EXCELLENT?"excellent":i>=th.GOOD?"good":i>=th.FAIR?"fair":i>=th.MARGINAL?"marginal":"critical"}function II(i){return i>=ih.ANOMALOUS_GOOD?"anomalous-good":i>=ih.BETTER?"better":i>=ih.EXPECTED_LOWER?"expected":i>=ih.WORSE?"worse":"anomalous-bad"}function oee(i,e,t,n,s){const r=n.tx_power??22,o=n.spreading_factor??12,a=n.coding_rate??5,l=n.frequency??0,c=l>1e5?l/1e6:l||SI,u=n.bandwidth??0,d=u>1e3?u/1e3:u||125,h=(s==null?void 0:s.sensitivityOverrideDbm)??kv(o,d,a);let p=null,m=null;e&&t&&Uh(e.latitude??void 0,e.longitude??void 0)&&Uh(t.latitude??void 0,t.longitude??void 0)&&(p=kS(e.latitude,e.longitude,t.latitude,t.longitude),m=p/1e3);let y=null,g=null;p!=null&&p>0&&(y=TI(p,c),g=r+EI+CI-y);const _=i.avgRssi??null,S=i.avgSnr??null;let C=null,x=null;_!=null&&g!=null&&(C=_-g,x=II(C));let A=null,L=null;_!=null&&(A=_-h,L=AI(A));const B=_!=null,H=x==="anomalous-good"||x==="anomalous-bad";return{edgeKey:i.key,fromHash:i.fromHash,toHash:i.toHash,distanceM:p,distanceKm:m,fsplDb:y,theoreticalRxPowerDbm:g,observedRssiDbm:_,observedSnrDb:S,deviationDb:C,deviationClass:x,marginDb:A,marginClass:L,sensitivityDbm:h,txPowerDbm:r,frequencyMhz:c,spreadingFactor:o,bandwidthKhz:d,noiseFloorDbm:null,isZeroHop:i.isZeroHop??!1,isTraceEstimated:!1,hasData:B,isAnomalous:H}}function aee(i,e,t,n,s=22,r){var te,M;const o=i.traceQuality;if(!o)return null;let a=null;if(o.forward!=null&&o.reverse!=null?a=Math.min(o.forward.mean,o.reverse.mean):a=((te=o.forward)==null?void 0:te.mean)??((M=o.reverse)==null?void 0:M.mean)??null,a==null)return null;const l=n.spreading_factor??12,c=n.coding_rate??5,u=n.bandwidth??0,d=u>1e3?u/1e3:u||125,h=d*1e3,p=n.frequency??0,m=p>1e5?p/1e6:p||SI,y=(r==null?void 0:r.sensitivityOverrideDbm)??kv(l,d,c),g=(r==null?void 0:r.observedNoiseFloorDbm)??kI(h),_=g+a;let S=null,C=null;e&&t&&Uh(e.latitude??void 0,e.longitude??void 0)&&Uh(t.latitude??void 0,t.longitude??void 0)&&(S=kS(e.latitude,e.longitude,t.latitude,t.longitude),C=S/1e3);let x=null,A=null;S!=null&&S>0&&(x=TI(S,m),A=s+EI+CI-x);let L=null,B=null;A!=null&&(L=_-A,B=II(L));const H=_-y,Q=AI(H);return{edgeKey:i.key,fromHash:i.fromHash,toHash:i.toHash,distanceM:S,distanceKm:C,fsplDb:x,theoreticalRxPowerDbm:A,observedRssiDbm:_,observedSnrDb:a,deviationDb:L,deviationClass:B,marginDb:H,marginClass:Q,sensitivityDbm:y,noiseFloorDbm:g,txPowerDbm:s,frequencyMhz:m,spreadingFactor:l,bandwidthKhz:d,isZeroHop:!1,isTraceEstimated:!0,hasData:!0,isAnomalous:B==="anomalous-good"||B==="anomalous-bad"}}function lee(i,e,t){const n=[],s=i.nodeMetrics,r=new Set,o=e.tx_power??22;for(const a of i.edges){if(!a.isZeroHop)continue;const l=s.get(a.fromHash),c=s.get(a.toHash);n.push(oee(a,l,c,e,t)),r.add(a.key)}for(const a of i.edges){if(r.has(a.key)||!a.traceQuality)continue;const l=s.get(a.fromHash),c=s.get(a.toHash),u=aee(a,l,c,e,o,t);u&&(n.push(u),r.add(a.key))}return n}function cee(i){const e={"anomalous-good":0,better:0,expected:0,worse:0,"anomalous-bad":0},t={excellent:0,good:0,fair:0,marginal:0,critical:0};let n=0,s=0,r=null,o=null,a=0,l=0;for(const c of i)c.hasData&&(c.marginDb!=null&&(n+=c.marginDb,s++,(!r||c.marginDb<(r.marginDb??1/0))&&(r=c),(!o||c.marginDb>(o.marginDb??-1/0))&&(o=c)),c.marginClass&&t[c.marginClass]++,c.deviationDb!=null&&c.deviationClass?(e[c.deviationClass]++,l++):a++);return{totalEdges:i.length,analyzedEdges:l,rssiOnlyEdges:a,avgMarginDb:s>0?n/s:null,worstMargin:r,bestMargin:o,deviationCounts:e,marginCounts:t,anomalousCount:e["anomalous-good"]+e["anomalous-bad"]}}const uee={"anomalous-good":"#2DD4BF",better:"#34D399",expected:"#9CA3AF",worse:"#FB923C","anomalous-bad":"#EF4444"},Av={excellent:"#34D399",good:"#A3E635",fair:"#FBBF24",marginal:"#FB923C",critical:"#EF4444"};function dee(i,e="margin"){return i.hasData?e==="deviation"?i.deviationClass?uee[i.deviationClass]:"#505058":i.marginClass?Av[i.marginClass]:"#505058":"#505058"}function hee(i,e=.5,t=4){if(i.marginDb==null)return e;const n=Math.max(0,Math.min(1,i.marginDb/40));return e+n*(t-e)}const fee=.15,pee=200;let mee=0;function Ns(){return`ta-${++mee}-${Date.now()}`}function gee(i){var c,u;const e=new Set;for(const d of i.edges)e.add(d.key);const t=new Map,n=new Map,s=new Map,r=new Set;for(const[d,h]of i.nodeMetrics)t.set(d,h.betweenness),n.set(d,h.communityId),s.set(d,h.nodeClass),r.add(d);const o=new Set;for(const d of i.discoveredNodes)d.isLikelyReal&&o.add(d.prefix);const a=new Map,l=new Map;for(const d of i.edges)(c=d.traceQuality)!=null&&c.composite&&a.set(d.key,d.traceQuality.composite.mean),((u=d.traceQuality)==null?void 0:u.asymmetryDb)!=null&&l.set(d.key,d.traceQuality.asymmetryDb);return{timestamp:Date.now(),edgeKeys:e,betweenness:t,communities:n,nodeClasses:s,ghostPrefixes:o,nodeHashes:r,traceSnr:a,traceAsymmetry:l}}function _ee(i,e,t){const n=Date.now(),s=[],r=h=>(t==null?void 0:t.get(h))??null;for(const h of e.edgeKeys)if(!i.edgeKeys.has(h)){const[p,m]=h.split("-"),y=r(p)??(p==null?void 0:p.slice(0,6)),g=r(m)??(m==null?void 0:m.slice(0,6));s.push({id:Ns(),detectedAt:n,category:"edge-appeared",severity:"info",description:`New edge: ${y} ↔ ${g}`,edgeKey:h})}for(const h of i.edgeKeys)if(!e.edgeKeys.has(h)){const[p,m]=h.split("-"),y=r(p)??(p==null?void 0:p.slice(0,6)),g=r(m)??(m==null?void 0:m.slice(0,6));s.push({id:Ns(),detectedAt:n,category:"edge-disappeared",severity:"warning",description:`Edge lost: ${y} ↔ ${g}`,edgeKey:h})}for(const h of e.nodeHashes)if(!i.nodeHashes.has(h)){const p=r(h);s.push({id:Ns(),detectedAt:n,category:"node-appeared",severity:"info",description:`Node appeared: ${p??h.slice(0,8)}`,nodeHash:h,nodeName:p??void 0})}for(const h of i.nodeHashes)if(!e.nodeHashes.has(h)){const p=r(h);s.push({id:Ns(),detectedAt:n,category:"node-disappeared",severity:"warning",description:`Node dropped: ${p??h.slice(0,8)}`,nodeHash:h,nodeName:p??void 0})}for(const h of e.ghostPrefixes)i.ghostPrefixes.has(h)||s.push({id:Ns(),detectedAt:n,category:"ghost-appeared",severity:"info",description:`Ghost node discovered: ${h.toUpperCase()}`});for(const h of i.ghostPrefixes)e.ghostPrefixes.has(h)||s.push({id:Ns(),detectedAt:n,category:"ghost-disappeared",severity:"info",description:`Ghost node resolved: ${h.toUpperCase()}`});const o=3;for(const[h,p]of e.traceSnr){const m=i.traceSnr.get(h);if(m===void 0)continue;const y=m-p;y>=o&&s.push({id:Ns(),detectedAt:n,category:"snr-degradation",severity:y>=6?"critical":"warning",description:`SNR dropped ${y.toFixed(1)} dB on edge ${h.slice(0,13)}`,edgeKey:h,previousValue:m,currentValue:p})}const a=4;for(const[h,p]of e.traceAsymmetry){const m=i.traceAsymmetry.get(h);if(m===void 0)continue;const y=p-m;y>=a&&s.push({id:Ns(),detectedAt:n,category:"asymmetry-shift",severity:y>=8?"critical":"warning",description:`Asymmetry grew ${y.toFixed(1)} dB on edge ${h.slice(0,13)}`,edgeKey:h,previousValue:m,currentValue:p})}for(const[h,p]of e.betweenness){const m=i.betweenness.get(h);if(m===void 0)continue;const y=Math.abs(p-m);if(y>=fee){const g=r(h),_=p>m?"increased":"decreased";s.push({id:Ns(),detectedAt:n,category:"betweenness-shift",severity:y>=.3?"critical":"warning",description:`${g??h.slice(0,8)} betweenness ${_}: ${m.toFixed(3)} → ${p.toFixed(3)}`,nodeHash:h,nodeName:g??void 0,previousValue:m,currentValue:p})}}for(const[h,p]of e.communities){const m=i.communities.get(h);if(m!==void 0&&p!==m){const y=r(h);s.push({id:Ns(),detectedAt:n,category:"community-change",severity:"info",description:`${y??h.slice(0,8)} moved: community #${m} → #${p}`,nodeHash:h,nodeName:y??void 0,previousValue:m,currentValue:p})}}for(const[h,p]of e.nodeClasses){const m=i.nodeClasses.get(h);if(m!==void 0&&p!==m){const y=r(h),g=pS(p)>pS(m);s.push({id:Ns(),detectedAt:n,category:"class-change",severity:g?"warning":"info",description:`${y??h.slice(0,8)} ${g?"promoted":"changed"}: ${m} → ${p}`,nodeHash:h,nodeName:y??void 0,previousValue:m,currentValue:p})}}const l={},c={},u=["edge-appeared","edge-disappeared","ghost-appeared","ghost-disappeared","betweenness-shift","community-change","class-change","node-appeared","node-disappeared","snr-degradation","asymmetry-shift"],d=["info","warning","critical"];for(const h of u)l[h]=0;for(const h of d)c[h]=0;for(const h of s)l[h.category]++,c[h.severity]++;return s.sort((h,p)=>p.detectedAt-h.detectedAt),{anomalies:s,categoryCounts:l,severityCounts:c,totalCount:s.length,timestamp:n}}function pS(i){return{standard:0,ghost:1,mobile:2,neighbor:3,backbone:4,gateway:5,hub:6,local:7}[i]??0}class yee{constructor(e=pee){b(this,"prevSnapshot",null);b(this,"log",[]);b(this,"maxLog");this.maxLog=e}update(e,t){const n=gee(e);if(!this.prevSnapshot)return this.prevSnapshot=n,{anomalies:[],categoryCounts:xee(),severityCounts:wee(),totalCount:0,timestamp:Date.now()};const s=_ee(this.prevSnapshot,n,t);this.prevSnapshot=n;try{vee(s.anomalies,e)}catch(r){console.warn("[TopologyAnomalyTracker] Enrichment failed, anomalies logged without detail:",r)}return this.log.unshift(...s.anomalies),this.log.length>this.maxLog&&(this.log.length=this.maxLog),s}getLog(){return this.log}getFiltered(e){const t=Date.now();return this.log.filter(n=>!(e.category&&n.category!==e.category||e.severity&&n.severity!==e.severity||e.nodeHash&&n.nodeHash!==e.nodeHash||e.maxAge&&t-n.detectedAt>e.maxAge))}clear(){this.log=[],this.prevSnapshot=null}}function bee(i){return{nodeClass:i.nodeClass,degree:i.degree,betweenness:i.betweenness,activityLevel:i.activityLevel,isZeroHop:i.isZeroHop,avgRssi:i.avgRssi,avgSnr:i.avgSnr,communityId:i.communityId,packetCount:i.packetCount,connectionCount:i.degree}}function vee(i,e){var r,o,a;const t=e.edgeMap,n=e.nodeMetrics,s=new Set(e.backboneEdges??[]);for(const l of i){if(l.edgeKey&&(l.category==="edge-appeared"||l.category==="edge-disappeared")){const c=t==null?void 0:t.get(l.edgeKey),u=l.edgeKey.split("-"),d=u[0],h=u[1],p=d?n==null?void 0:n.get(d):void 0,m=h?n==null?void 0:n.get(h):void 0;c?l.edgeDetail={fromName:(p==null?void 0:p.name)??null,toName:(m==null?void 0:m.name)??null,fromClass:(p==null?void 0:p.nodeClass)??null,toClass:(m==null?void 0:m.nodeClass)??null,packetCount:c.packetCount,confidence:c.avgConfidence,symmetryRatio:c.symmetryRatio,isBackbone:s.has(l.edgeKey),isLoop:c.isLoopEdge??!1,isZeroHop:c.isZeroHop??!1,isDirectPath:c.isDirectPathEdge,avgRssi:c.avgRssi??null,avgSnr:c.avgSnr??null,fromBetweenness:(p==null?void 0:p.betweenness)??null,toBetweenness:(m==null?void 0:m.betweenness)??null,traceCompositeSnr:((o=(r=c.traceQuality)==null?void 0:r.composite)==null?void 0:o.mean)??null,traceAsymmetryDb:((a=c.traceQuality)==null?void 0:a.asymmetryDb)??null}:l.edgeDetail={fromName:(p==null?void 0:p.name)??null,toName:(m==null?void 0:m.name)??null,fromClass:(p==null?void 0:p.nodeClass)??null,toClass:(m==null?void 0:m.nodeClass)??null,packetCount:0,confidence:0,symmetryRatio:0,isBackbone:!1,isLoop:!1,isZeroHop:!1,isDirectPath:!1,avgRssi:null,avgSnr:null,fromBetweenness:(p==null?void 0:p.betweenness)??null,toBetweenness:(m==null?void 0:m.betweenness)??null,traceCompositeSnr:null,traceAsymmetryDb:null}}if(l.nodeHash){const c=n==null?void 0:n.get(l.nodeHash);c&&(l.nodeDetail=bee(c))}}}function xee(){return{"edge-appeared":0,"edge-disappeared":0,"ghost-appeared":0,"ghost-disappeared":0,"betweenness-shift":0,"community-change":0,"class-change":0,"node-appeared":0,"node-disappeared":0,"snr-degradation":0,"asymmetry-shift":0}}function wee(){return{info:0,warning:0,critical:0}}const LI=24,See=3;function Eee(i,e,t,n){var o;const s=[],r=e.replace(/^0x/i,"").slice(0,2).toLowerCase();for(const a of i){if(a.transmitted||a.rssi==null||a.snr==null||a.rssi===0&&a.snr===0)continue;const l=((o=a.src_hash)==null?void 0:o.replace(/^0x/i,""))??"";if(l.slice(0,2).toLowerCase()!==r&&l!==e.replace(/^0x/i,""))continue;const u=a.original_path??a.forwarded_path??[],d=nL(u,n),h=(d==null?void 0:d.effectiveLength)??0,p=a.route??a.route_type;let m=!1;p!=null&&sL(p)?m=h<=1:m=h===0,m&&s.push({timestamp:a.timestamp*1e3,rssi:a.rssi,snr:a.snr})}if(s.sort((a,l)=>a.timestamp-l.timestamp),s.length>0&&s[0].timestamp<4102444800)for(const a of s)a.timestamp*=1e3;return s}function Cee(i,e=LI){if(i.length===0)return[];const t=i[0].timestamp,s=i[i.length-1].timestamp-t;if(s<=0){const l=i.reduce((u,d)=>u+d.rssi,0)/i.length,c=i.reduce((u,d)=>u+d.snr,0)/i.length;return[{timestamp:t,avgRssi:l,avgSnr:c,minRssi:Math.min(...i.map(u=>u.rssi)),maxRssi:Math.max(...i.map(u=>u.rssi)),minSnr:Math.min(...i.map(u=>u.snr)),maxSnr:Math.max(...i.map(u=>u.snr)),count:i.length}]}const r=s/e,o=[];for(let l=0;l0&&(l.avgRssi/=l.count,l.avgSnr/=l.count,a.push(l));return a}function mS(i){if(i.length<2)return 0;const e=i.length;let t=0,n=0,s=0,r=0;for(let a=0;a_.avgRssi)),m=mS(o.map(_=>_.avgSnr)),y=r[0].timestamp,g=r[r.length-1].timestamp;return{buckets:o,totalSamples:r.length,rssiRange:[c,u],snrRange:[d,h],avgRssi:a/r.length,avgSnr:l/r.length,rssiTrend:p,snrTrend:m,timeSpanMs:g-y}}const an={observationTrend:.3,edgeCertainty:.25,redundancy:.15,signalMargin:.15,traceSnrTrend:.15},lg={critical:.75,high:.55,moderate:.35},kee=-137,Aee=5;function Iee(i,e,t){if(i.observationCount.3&&n.push({name:"Weak link certainty",description:i.weakestLinkKey?`Weakest: ${i.weakestLinkConfidence<.3?"very low":"low"} confidence`:`Average certainty: ${(i.avgEdgeCertainty*100).toFixed(0)}%`,score:r,weight:an.edgeCertainty});let o=0;i.alternatePathsCount===0?(o=1,n.push({name:"No alternate paths",description:"Single route to destination — no failover available",score:o,weight:an.redundancy})):i.alternatePathsCount===1&&(o=.5,n.push({name:"Limited redundancy",description:"Only 1 alternate path available",score:o,weight:an.redundancy}));let a=0;if(i.weakestLinkKey){const h=e.get(i.weakestLinkKey),p=(h==null?void 0:h.avgRssi)??null,m=i.weakestLinkTraceSnr;if(p!=null){const y=p-t;y<3?(a=1,n.push({name:"Signal near sensitivity",description:`Weakest link: ${y.toFixed(1)} dB margin (< 3 dB)`,score:a,weight:an.signalMargin})):y<10&&(a=1-(y-3)/7,n.push({name:"Low signal margin",description:`Weakest link: ${y.toFixed(1)} dB margin`,score:a,weight:an.signalMargin}))}else m!=null&&m<5&&(a=m<-5?1:m<0?.7:.4,n.push({name:"Low trace SNR",description:`Weakest link trace SNR: ${m.toFixed(1)} dB`,score:a,weight:an.signalMargin}))}let l=0;if(i.weakestLinkKey){const h=e.get(i.weakestLinkKey),p=h==null?void 0:h.traceQuality;p!=null&&p.composite&&(p.composite.mean<0?(l=.8,n.push({name:"Trace SNR negative",description:`Composite trace SNR: ${p.composite.mean.toFixed(1)} dB (negative)`,score:l,weight:an.traceSnrTrend})):p.composite.stdDev>4?(l=.6,n.push({name:"Unstable trace SNR",description:`High variance: σ=${p.composite.stdDev.toFixed(1)} dB`,score:l,weight:an.traceSnrTrend})):p.asymmetryDb!=null&&p.asymmetryDb>8&&(l=.5,n.push({name:"High SNR asymmetry",description:`Bidirectional asymmetry: ${p.asymmetryDb.toFixed(1)} dB`,score:l,weight:an.traceSnrTrend})))}const c=s*an.observationTrend+r*an.edgeCertainty+o*an.redundancy+a*an.signalMargin+l*an.traceSnrTrend;if(c=lg.critical?(u="critical",d="imminent"):c>=lg.high?(u="high",d="near-term"):(u="moderate",d="watch"),{pathKey:i.pathKey,hops:i.hops,riskScore:Math.round(c*100)/100,riskLevel:u,factors:n,weakestEdgeKey:i.weakestLinkKey,healthScore:i.healthScore,observationTrend:i.observationTrend,alternatePathsCount:i.alternatePathsCount,urgency:d}}function Lee(i,e,t=kee){const n=new Map;for(const o of e)n.set(o.key,o);const s=e.filter(o=>o.avgRssi!=null).length,r=[];for(const o of i){const a=Iee(o,n,t);a&&r.push(a)}return r.sort((o,a)=>a.riskScore-o.riskScore),{atRiskPaths:r,criticalCount:r.filter(o=>o.riskLevel==="critical").length,highCount:r.filter(o=>o.riskLevel==="high").length,moderateCount:r.filter(o=>o.riskLevel==="moderate").length,edgesAnalyzed:e.length,edgesWithSignal:s}}let Ree=100;function gS(){return++Ree}const RI="meshgraph-panel-";function _S(i){try{const e=localStorage.getItem(RI+i);return e?JSON.parse(e):null}catch{return null}}function Pee(i,e){try{localStorage.setItem(RI+i,JSON.stringify(e))}catch{}}function Nee(i,e,t,n,s){return{x:Math.max(8,Math.min(i,Math.max(8,n-t-8))),y:Math.max(8,Math.min(e,Math.max(8,s-36)))}}function nh({id:i,title:e,icon:t,open:n,onClose:s,defaultPosition:r,defaultSize:o,minSize:a={width:180,height:120},maxSize:l,autoHeight:c=!1,headerActions:u,children:d}){const h=IL(),p=$.useRef(null),m=$.useRef(null),y=$.useMemo(()=>{const F=_S(i);return F?{x:F.x,y:F.y,w:F.w,h:c?o.height:F.h,minimized:F.minimized}:{x:r.x,y:r.y,w:o.width,h:o.height,minimized:!1}},[i]),[g,_]=$.useState({w:y.w,h:y.h}),[S,C]=$.useState(y.minimized),[x,A]=$.useState(()=>gS()),[L,B]=$.useState({x:y.x,y:y.y});$.useLayoutEffect(()=>{const F=p.current;if(!n||!F)return;const X=F.getBoundingClientRect();if(X.width<1||X.height<1)return;const ie=_S(i),ee=(ie==null?void 0:ie.x)??y.x,ae=(ie==null?void 0:ie.y)??y.y,Z=(ie==null?void 0:ie.w)??g.w,Se=Nee(ee,ae,Z,X.width,X.height);B(Se)},[n,i]);const[H,Q]=$.useState(!1),te=$.useRef({startX:0,startY:0,startW:0,startH:0,edge:""}),M=$.useRef(),he=$.useCallback(()=>{M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{const F=m.current;if(!F)return;const X=window.getComputedStyle(F),ie=new DOMMatrix(X.transform);Pee(i,{x:ie.m41,y:ie.m42,w:g.w,h:g.h,minimized:S})},300)},[i,g.w,g.h,S]);$.useEffect(()=>{he()},[g,S,he]);const se=$.useCallback(()=>{A(gS())},[]),R=$.useCallback(()=>{C(F=>!F)},[]),J=$.useCallback((F,X)=>{F.preventDefault(),F.stopPropagation(),Q(!0),te.current={startX:F.clientX,startY:F.clientY,startW:g.w,startH:g.h,edge:X},se();const ie=ae=>{const{startX:Z,startY:Se,startW:xe,startH:Je,edge:de}=te.current,bt=ae.clientX-Z,Xe=ae.clientY-Se;let ht=xe,re=Je;(de==="e"||de==="se")&&(ht=Math.max(a.width,xe+bt),l&&(ht=Math.min(l.width,ht))),(de==="s"||de==="se")&&(re=Math.max(a.height,Je+Xe),l&&(re=Math.min(l.height,re))),_({w:ht,h:re})},ee=()=>{Q(!1),window.removeEventListener("pointermove",ie),window.removeEventListener("pointerup",ee)};window.addEventListener("pointermove",ie),window.addEventListener("pointerup",ee)},[g,a,l,se]);return f.jsx("div",{ref:p,className:"absolute inset-0 pointer-events-none",style:{zIndex:x},children:f.jsx(Qc,{children:n&&f.jsxs(Sl.div,{ref:m,drag:!H,dragControls:h,dragConstraints:p,dragElastic:.05,dragMomentum:!1,dragListener:!1,initial:{opacity:0,scale:.96,x:L.x,y:L.y},animate:{opacity:1,scale:1,x:L.x,y:L.y},exit:{opacity:0,scale:.96},transition:{duration:.15},onPointerDown:se,className:"absolute top-0 left-0 pointer-events-auto",style:{width:g.w,touchAction:"none"},children:[f.jsxs("div",{className:"surface-elevated radius-inset shadow-xl overflow-hidden flex flex-col",style:{maxHeight:S?void 0:c?"80vh":g.h},children:[f.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 border-b border-edge-subtle cursor-grab active:cursor-grabbing select-none shrink-0",onPointerDown:F=>{se(),h.start(F)},children:[f.jsx(LL,{className:"w-3 h-3 text-fg-muted/50 shrink-0"}),t&&f.jsx("span",{className:"text-fg-muted shrink-0 [&>svg]:w-3 [&>svg]:h-3",children:t}),f.jsx("span",{className:"text-[11px] font-medium text-fg-primary flex-1 truncate",children:e}),u,f.jsx("button",{onClick:R,className:"p-0.5 radius-badge hover-bg transition-base",title:S?"Expand":"Minimize",children:S?f.jsx(TS,{className:"w-2.5 h-2.5 text-fg-muted"}):f.jsx(rL,{className:"w-2.5 h-2.5 text-fg-muted"})}),f.jsx("button",{onClick:s,className:"p-0.5 radius-badge hover-bg transition-base",title:"Close",children:f.jsx($u,{className:"w-2.5 h-2.5 text-fg-muted"})})]}),f.jsx(Qc,{initial:!1,children:!S&&f.jsx(Sl.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},className:"overflow-hidden",children:f.jsx("div",{className:"overflow-y-auto",style:{maxHeight:c?"70vh":void 0},children:d})})})]}),!S&&!c&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"absolute top-0 -right-1 w-2 h-full cursor-ew-resize",onPointerDown:F=>J(F,"e")}),f.jsx("div",{className:"absolute -bottom-1 left-0 w-full h-2 cursor-ns-resize",onPointerDown:F=>J(F,"s")}),f.jsx("div",{className:"absolute -bottom-1 -right-1 w-3 h-3 cursor-nwse-resize",onPointerDown:F=>J(F,"se"),children:f.jsxs("svg",{className:"w-full h-full text-fg-muted/30",viewBox:"0 0 12 12",children:[f.jsx("path",{d:"M10 2 L10 10 L2 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5"}),f.jsx("path",{d:"M7 5 L7 7 L5 7",fill:"none",stroke:"currentColor",strokeWidth:"1"})]})})]})]})})})}const PI=[{target:"Graph",fn:"topology.edges",minStage:2,when:p0},{target:"Graph",fn:"topology.edges",minStage:2,when:OL},{target:"Graph",fn:"nodeMetrics",minStage:2},{target:"Graph",fn:"ghostNodes",minStage:2,when:p0},{target:"Graph",fn:"_advertNodeType",minStage:1,when:BL},{target:"Graph",fn:"pathHealth",minStage:2}];ML(PI);const Dee=400,sh=800,el={critical:[Ge.red,Ge.red],poor:[Ge.orange,Ge.orange],fair:[Ge.amber,Ge.amber],good:[Ge.green,Ge.green],excellent:[Ge.blue,Ge.blue]};function Mee(i,e){if(i==null)return null;const t=Math.max(0,i),n=t>0?(Math.log10(t)+4)/4.5:0,s=Math.round(Math.max(0,Math.min(100,n*100)));let r,o;s<10?(r="critical",o="Partition risk"):s<30?(r="poor",o="Weak connectivity"):s<55?(r="fair",o="Moderate resilience"):s<80?(r="good",o="Well connected"):(r="excellent",o="Highly resilient");const[a,l]=el[r];return{score:s,grade:r,label:o,color:e?a:l}}const yS=5,cg=28,bS=6,Oee=6,Bee={active:1,recent:.85,stale:.45,inactive:.25},Fee=[Ge.purple,Ge.green,Ge.amber,Ge.red,Ge.blue,Ge.pink,Ge.teal,Ge.orange],zee=[Ge.purple,Ge.green,Ge.amber,Ge.red,Ge.blue,Ge.pink,Ge.teal,Ge.orange];function wl(i,e,t){const n=(r,o)=>parseInt(r.slice(1+o*2,3+o*2),16),s=r=>Math.round(n(i,r)*t+n(e,r)*(1-t));return`#${[0,1,2].map(r=>s(r).toString(16).padStart(2,"0")).join("")}`}const NI={zeroHop:wl(Ge.amber,qt[500],.55),directPath:wl(Ge.teal,qt[500],.55),loop:wl(Ge.purple,qt[500],.55),backbone:qt[300],standard:qt[500],standardDim:qt[600],ghost:qt[600]},DI={zeroHop:wl(Ge.amber,qt[700],.5),directPath:wl(Ge.teal,qt[700],.5),loop:wl(Ge.purple,qt[700],.5),backbone:qt[700],standard:qt[400],standardDim:qt[300],ghost:qt[400]},Ne={simulationDecay:2e4,simulationGravity:.05,simulationCenter:.05,simulationRepulsion:5,simulationRepulsionTheta:.4,simulationLinkSpring:.05,simulationLinkDistance:78,simulationFriction:.72,simulationRepulsionFromMouse:0,pointSizeScale:.4,pointOpacity:1,pointGreyoutOpacity:.1,linkWidthScale:.06,linkOpacity:.95,linkGreyoutOpacity:.1,curvedLinks:!1,curvedLinkWeight:.8,linkDefaultArrows:!0,linkArrowsSizeScale:1.7,scalePointsOnZoom:!0,scaleLinksOnZoom:!0,renderLinks:!0,renderHoveredPointRing:!0,fitViewPadding:.15,spaceSize:4096};function Uee(i){if(typeof document>"u")return i?qt[950]:"#EFF0F1";const e=getComputedStyle(document.documentElement).getPropertyValue("--bg-body").trim();return e.startsWith("#")?e:i?qt[950]:"#EFF0F1"}function $ee(i){if(typeof document>"u")return i?qt[400]:qt[500];const e=getComputedStyle(document.documentElement).getPropertyValue("--text-secondary").trim();return e.startsWith("#")?e:i?qt[400]:qt[500]}const MI={local:Ge.amber,hub:Ge.purple,gateway:Ge.blue,backbone:Ge.green,neighbor:Ge.pink,mobile:Ge.orange,ghost:qt[400],standard:qt[300]},OI={local:Ge.amber,hub:Ge.purple,gateway:Ge.blue,backbone:Ge.green,neighbor:Ge.pink,mobile:Ge.orange,ghost:qt[500],standard:qt[600]},jee={local:"Your repeater — the home node running this dashboard",hub:"≥10% of last-hop traffic — dominant forwarder for your local node",gateway:"7-10% of last-hop traffic — significant relay node",backbone:"High betweenness centrality — critical path node connecting clusters",neighbor:"Zero-hop direct RF contact — no intermediate forwarders",mobile:"High path volatility — node appears and disappears frequently",ghost:"Unresolved prefix inferred by Viterbi HMM from path patterns",standard:"<7% of traffic — normal mesh participant"};function vS(i){const e=i.replace("#","");return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}function ug(i,e,t){const[n,s,r]=vS(i),[o,a,l]=vS(e),c=Math.max(0,Math.min(1,t)),u=Math.round(n*c+o*(1-c)),d=Math.round(s*c+a*(1-c)),h=Math.round(r*c+l*(1-c));return`#${u.toString(16).padStart(2,"0")}${d.toString(16).padStart(2,"0")}${h.toString(16).padStart(2,"0")}`}function Hee(i,e){return i.isZeroHop?"zero-hop":i.isDirectPathEdge?"direct-path":i.isLoopEdge?"loop":e.has(i.key)?"backbone":"standard"}function xS(i,e,t){const n=t?NI:DI;switch(i){case"zero-hop":return n.zeroHop;case"direct-path":return n.directPath;case"loop":return n.loop;case"backbone":return n.backbone;case"ghost":return n.ghost;case"standard":default:return e>=.7?n.standard:n.standardDim}}const Vee={"zero-hop":"Zero-Hop (Direct RF)","direct-path":"Direct Path (Unicast)",loop:"Redundant Loop",backbone:"Backbone",standard:"Standard",ghost:"Ghost (Inferred)"},Gee={"zero-hop":"Direct radio contact — no intermediate forwarders in path","direct-path":"Unicast-routed edge — verified via DIRECT route type packets",loop:"Redundant path — alternate route between the same endpoints exists",backbone:"High betweenness centrality — critical traffic flow edge",standard:"Normal mesh edge with moderate-to-high confidence",ghost:"Inferred connection from Viterbi HMM ghost node analysis"};function Wee(i){const e=i.rssiTrend<-.1,t=i.snrTrend<-.1,n=i.rssiTrend>.1,s=i.snrTrend>.1,r=i.rssiRange[1]-i.rssiRange[0],o=i.snrRange[1]-i.snrRange[0];return e&&t?{text:"Both RSSI and SNR declining — possible antenna degradation or increasing distance",color:"#EF4444"}:t&&!e?{text:"SNR declining while RSSI stable — likely RF interference or noise floor increase",color:"#F97316"}:e&&!t?{text:"RSSI declining while SNR stable — possible path obstruction or power change",color:"#F97316"}:n&&s?{text:"Signal improving — conditions favorable or antenna adjustment working",color:"#34D399"}:r>15||o>10?{text:"High signal variance — intermittent obstruction or multipath fading",color:"#FBBF24"}:{text:"Signal stable — no significant degradation detected",color:"#9CA3AF"}}const Yee=$.memo(function({timeline:e}){const t=e.buckets;if(t.length<2)return null;const n=200,s=36,r=1,[o,a]=e.rssiRange,l=Math.max(1,a-o),[c,u]=e.snrRange,d=Math.max(1,u-c),h=(n-r*2)/(t.length-1),p=t.map((A,L)=>{const B=r+L*h,H=r+(1-(A.avgRssi-o)/l)*(s-r*2);return`${B.toFixed(1)},${H.toFixed(1)}`}).join(" "),m=t.map((A,L)=>{const B=r+L*h,H=r+(1-(A.avgSnr-c)/d)*(s-r*2);return`${B.toFixed(1)},${H.toFixed(1)}`}).join(" "),y=e.rssiTrend>.1?"↑":e.rssiTrend<-.1?"↓":"→",g=e.snrTrend>.1?"↑":e.snrTrend<-.1?"↓":"→",_=e.rssiTrend>.1?"#34D399":e.rssiTrend<-.1?"#EF4444":"#9CA3AF",S=e.snrTrend>.1?"#34D399":e.snrTrend<-.1?"#EF4444":"#9CA3AF",C=(e.timeSpanMs/36e5).toFixed(1),x=Wee(e);return f.jsxs("div",{className:"mt-2 pt-2 border-t border-edge-subtle/50",children:[f.jsxs("div",{className:"flex items-center justify-between mb-1",children:[f.jsx(be,{content:f.jsxs("div",{className:"max-w-xs space-y-1.5",children:[f.jsx("div",{className:"font-semibold text-fg-primary",children:"Signal Quality Over Time"}),f.jsx("div",{className:"text-fg-secondary text-[11px]",children:"Tracks RSSI (signal power) and SNR (signal-to-noise ratio) for zero-hop packets received directly from this neighbor. Reveals weather effects, interference, and antenna degradation."}),f.jsxs("div",{className:"pt-1 border-t border-edge-subtle/30 space-y-0.5 font-mono text-[10px]",children:[f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Samples"}),f.jsx("span",{className:"text-fg-primary tabular-nums",children:e.totalSamples})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Time span"}),f.jsxs("span",{className:"text-fg-primary tabular-nums",children:[C,"h"]})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Avg RSSI"}),f.jsxs("span",{className:"text-fg-primary tabular-nums",children:[e.avgRssi.toFixed(1)," dBm"]})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Avg SNR"}),f.jsxs("span",{className:"text-fg-primary tabular-nums",children:[e.avgSnr.toFixed(1)," dB"]})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"RSSI trend"}),f.jsxs("span",{className:"tabular-nums",style:{color:_},children:[e.rssiTrend>0?"+":"",e.rssiTrend.toFixed(3)," dBm/bucket"]})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"SNR trend"}),f.jsxs("span",{className:"tabular-nums",style:{color:S},children:[e.snrTrend>0?"+":"",e.snrTrend.toFixed(3)," dB/bucket"]})]})]}),f.jsxs("div",{className:"text-[10px] text-fg-muted italic",children:["Trend is linear regression slope across ",t.length," time buckets. ↑ = improving, ↓ = degrading, → = stable."]})]}),children:f.jsx("span",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Signal Timeline"})}),f.jsxs("span",{className:"text-[9px] text-fg-muted tabular-nums",children:[e.totalSamples," samples · ",C,"h"]})]}),f.jsxs("svg",{viewBox:`0 0 ${n} ${s}`,className:"w-full h-9",preserveAspectRatio:"none",children:[f.jsx("polyline",{points:p,fill:"none",stroke:"#60A5FA",strokeWidth:"1.5",strokeLinejoin:"round",strokeLinecap:"round",opacity:"0.8"}),f.jsx("polyline",{points:m,fill:"none",stroke:"#34D399",strokeWidth:"1",strokeLinejoin:"round",strokeLinecap:"round",opacity:"0.5",strokeDasharray:"3 2"})]}),f.jsxs("div",{className:"flex items-center justify-between text-[9px] mt-0.5",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("span",{className:"flex items-center gap-0.5",children:[f.jsx("span",{className:"w-2.5 h-[1.5px] bg-[#60A5FA] rounded-full inline-block"}),f.jsx("span",{className:"text-fg-muted",children:"RSSI"}),f.jsx("span",{className:"tabular-nums",style:{color:_},children:y})]}),f.jsxs("span",{className:"flex items-center gap-0.5",children:[f.jsx("span",{className:"w-2.5 h-[1px] bg-[#34D399] rounded-full inline-block opacity-50",style:{borderTop:"1px dashed #34D399"}}),f.jsx("span",{className:"text-fg-muted",children:"SNR"}),f.jsx("span",{className:"tabular-nums",style:{color:S},children:g})]})]}),f.jsxs("div",{className:"flex items-center gap-2 text-fg-muted tabular-nums",children:[f.jsxs("span",{children:[o.toFixed(0),"…",a.toFixed(0)," dBm"]}),f.jsxs("span",{children:[c.toFixed(0),"…",u.toFixed(0)," dB"]})]})]}),f.jsx("div",{className:"mt-1 text-[9px] leading-tight",style:{color:x.color},children:x.text})]})}),wS=$.memo(function({edge:e,onClose:t}){const[n,s]=$.useState(null);return $.useEffect(()=>{if(!e.isZeroHop&&e.edgeType!=="zero-hop"){s(null);return}const r=d0.getState().packets,o=d0.getState().cachedLocalHash??void 0,a=Tee(r,e.source,e.target,o);s(a)},[e.source,e.target,e.isZeroHop,e.edgeType]),f.jsxs(Sl.div,{variants:X_,initial:"hidden",animate:"visible",exit:"exit",className:"absolute inset-x-3 bottom-3 z-20 surface-elevated radius-inset shadow-xl",children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-edge-subtle/50",children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.jsx(YL,{className:"size-3.5 text-fg-muted shrink-0"}),f.jsxs("span",{className:"text-sm font-semibold text-fg-primary truncate",children:[e.fromName??e.source.slice(0,6)," → ",e.toName??e.target.slice(0,6)]}),f.jsxs("div",{className:"flex gap-1 shrink-0",children:[f.jsx(Di,{color:"zinc",compact:!0,children:Vee[e.edgeType]}),e.isBackbone&&f.jsx(Di,{color:"emerald",compact:!0,children:"BONE"}),e.isLoopEdge&&f.jsx(Di,{color:"indigo",compact:!0,children:"LOOP"}),e.isGhost&&f.jsx(Di,{color:"zinc",compact:!0,children:"GHOST"})]})]}),f.jsx(q_,{plain:!0,onClick:t,title:"Close",className:"shrink-0",children:f.jsx($u,{className:"size-4"})})]}),f.jsxs("div",{className:"p-3 font-mono text-[11px]",children:[f.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[f.jsxs("div",{children:[f.jsx(be,{content:"Average disambiguation confidence across all observations of this edge",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Confidence"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[(e.confidence*100).toFixed(0),"%"]})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Observations where both endpoints had high-confidence disambiguation",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Certain"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.certainCount.toLocaleString()})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Total packets observed traversing this edge",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Packets"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.packetCount.toLocaleString()})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Combined certainCount × confidence metric for edge ranking",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Strength"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.strength.toFixed(2)})]})]}),f.jsxs("div",{className:"grid grid-cols-4 gap-3 mt-2",children:[f.jsxs("div",{children:[f.jsx(be,{content:"Bidirectional balance (min/max) — 0 = one-way traffic, 1 = perfectly balanced",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Symmetry"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.symmetryRatio.toFixed(2)})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Dominant traffic flow direction between these nodes",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Direction"})}),f.jsx("div",{className:"text-fg-primary capitalize",children:e.dominantDirection})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Forward (A→B) vs reverse (B→A) observation counts",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Fwd / Rev"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.forwardCount," / ",e.reverseCount]})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Routing method — broadcast flood vs unicast direct routing",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Flood / Direct"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.floodCount," / ",e.directCount]})]})]}),(e.avgRssi!=null||e.avgSnr!=null)&&f.jsxs("div",{className:"grid grid-cols-2 gap-3 mt-2 pt-2 border-t border-edge-subtle/50",children:[e.avgRssi!=null&&f.jsxs("div",{children:[f.jsx("div",{className:"text-[9px] text-fg-muted uppercase",children:"RSSI"}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.avgRssi.toFixed(1)," dBm"]})]}),e.avgSnr!=null&&f.jsxs("div",{children:[f.jsx("div",{className:"text-[9px] text-fg-muted uppercase",children:"SNR"}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.avgSnr.toFixed(1)," dB"]})]})]}),e.linkBudget&&f.jsxs("div",{className:"grid grid-cols-4 gap-3 mt-2 pt-2 border-t border-edge-subtle/50",children:[e.linkBudget.distanceKm!=null&&f.jsxs("div",{children:[f.jsx(be,{content:"Haversine distance between endpoint locations",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Distance"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.linkBudget.distanceKm.toFixed(2)," km"]})]}),e.linkBudget.fsplDb!=null&&f.jsxs("div",{children:[f.jsx(be,{content:"Free Space Path Loss — theoretical signal attenuation over this distance at configured frequency",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"FSPL"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.linkBudget.fsplDb.toFixed(1)," dB"]})]}),e.linkBudget.marginDb!=null&&f.jsxs("div",{children:[f.jsx(be,{content:"Link margin — observed RSSI minus receiver sensitivity. Positive = signal headroom above minimum.",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Margin"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",style:{color:e.linkBudget.marginClass?Av[e.linkBudget.marginClass]:void 0},children:[e.linkBudget.marginDb>0?"+":"",e.linkBudget.marginDb.toFixed(1)," dB"]})]}),e.linkBudget.deviationDb!=null&&f.jsxs("div",{children:[f.jsx(be,{content:"Deviation from theoretical FSPL — positive means better signal than free-space prediction",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"vs Theory"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.linkBudget.deviationDb>0?"+":"",e.linkBudget.deviationDb.toFixed(1)," dB"]})]})]}),n&&f.jsx(Yee,{timeline:n})]})]})}),SS=$.memo(function({node:e,onClose:t,egoMetrics:n,onExpandEgo:s,neighbors:r,onSelectNeighbor:o,txDelayRec:a}){const[l,c]=$.useState(!1),[u,d]=$.useState(!1);return f.jsxs(Sl.div,{variants:X_,initial:"hidden",animate:"visible",exit:"exit",className:"absolute inset-x-3 bottom-3 z-20 surface-elevated radius-inset shadow-xl max-h-[60vh] flex flex-col",children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-edge-subtle/50",children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.jsx("span",{className:"size-2 shrink-0 rounded-full",style:{backgroundColor:(SL()?MI:OI)[e.nodeClass]}}),f.jsx("code",{className:"text-sm font-semibold text-fg-primary shrink-0",children:e.prefix}),e.name&&f.jsx("span",{className:"text-sm text-fg-secondary truncate",children:e.name}),f.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.isLocal&&f.jsx(Di,{color:"yellow",compact:!0,children:"LOCAL"}),e.isHub&&f.jsx(Di,{color:"violet",compact:!0,children:"HUB"}),e.isGateway&&f.jsx(Di,{color:"sky",compact:!0,children:"GW"}),e.isBackbone&&f.jsx(Di,{color:"emerald",compact:!0,children:"BONE"}),e.isMobile&&f.jsx(Di,{color:"orange",compact:!0,children:"MOB"}),e.isZeroHop&&f.jsx(Di,{color:"amber",compact:!0,children:"RF"}),e.isGhost&&f.jsx(Di,{color:"zinc",compact:!0,children:"GHOST"}),e.isInLoop&&f.jsx(Di,{color:"indigo",compact:!0,children:"LOOP"})]})]}),f.jsx(q_,{plain:!0,onClick:t,title:"Close",className:"shrink-0",children:f.jsx($u,{className:"size-4"})})]}),f.jsxs("div",{className:"p-3 font-mono text-[11px]",children:[f.jsx(FL,{copy:!0,size:"compact",truncate:[10,6],className:"w-full mb-3",children:e.hash}),f.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[f.jsxs("div",{children:[f.jsx(be,{content:"Total connections (edges) to this node",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Degree"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.degree})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Inbound vs outbound edge count — indicates traffic directionality",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"In / Out"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.inDegree," / ",e.outDegree]})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Betweenness centrality (0–1) — how often this node lies on shortest paths. High value = critical relay.",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Between."})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.betweenness.toFixed(3)})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Total packets observed involving this node",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Packets"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.packetCount.toLocaleString()})]})]}),f.jsxs("div",{className:"grid grid-cols-4 gap-3 mt-2",children:[f.jsxs("div",{children:[f.jsx(be,{content:"Number of topology edges connected to this node",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Edges"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.edgeCount})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Community cluster assignment from graph partitioning algorithm",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Community"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:["#",e.communityId]})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Prefix disambiguation confidence — how certain the 2-char prefix→node mapping is (multi-factor scoring)",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Confidence"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[(e.prefixConfidence*100).toFixed(0),"%"]})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Recency level — active (<1h), recent (<6h), stale (<24h), inactive (>24h)",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Activity"})}),f.jsx("div",{className:"text-fg-primary capitalize",children:e.activityLevel})]})]}),(e.avgRssi!=null||e.avgSnr!=null)&&f.jsxs("div",{className:"grid grid-cols-2 gap-3 mt-2 pt-2 border-t border-edge-subtle/50",children:[e.avgRssi!=null&&f.jsxs("div",{children:[f.jsx("div",{className:"text-[9px] text-fg-muted uppercase",children:"RSSI"}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.avgRssi.toFixed(1)," dBm"]})]}),e.avgSnr!=null&&f.jsxs("div",{children:[f.jsx("div",{className:"text-[9px] text-fg-muted uppercase",children:"SNR"}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.avgSnr.toFixed(1)," dB"]})]})]}),n&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"grid grid-cols-3 gap-3 mt-2 pt-2 border-t border-edge-subtle/50",children:[f.jsxs("div",{children:[f.jsx(be,{content:"Number of direct 1-hop neighbors in the topology",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Ego Size"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:n.neighborCount})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Local clustering coefficient — how interconnected this node's neighbors are (0 = none, 1 = fully connected)",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Clustering"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:n.clusteringCoeff.toFixed(3)})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Average betweenness centrality of this node's direct neighbors",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Avg Nbr Btw."})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:n.avgNeighborBetweenness.toFixed(3)})]})]}),f.jsxs("div",{className:"grid grid-cols-3 gap-3 mt-2",children:[f.jsxs("div",{children:[f.jsx(be,{content:"Average disambiguation confidence across all connected edges",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Edge Conf."})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[(n.avgEdgeConfidence*100).toFixed(0),"%"]})]}),n.avgRssi!=null&&f.jsxs("div",{children:[f.jsx("div",{className:"text-[9px] text-fg-muted uppercase",children:"Avg RSSI"}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[n.avgRssi.toFixed(1)," dBm"]})]}),n.avgSnr!=null&&f.jsxs("div",{children:[f.jsx("div",{className:"text-[9px] text-fg-muted uppercase",children:"Avg SNR"}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[n.avgSnr.toFixed(1)," dB"]})]})]})]}),a&&!a.insufficientData&&f.jsxs("div",{className:"mt-2 pt-2 border-t border-edge-subtle/50",children:[f.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[f.jsx(be,{content:"RF-grounded TX delay recommendation from centralized topology engine. Anchored to MeshCore firmware defaults with observer bias correction.",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase tracking-wide cursor-help",children:"TX Delay Recommendation"})}),f.jsxs("div",{className:"flex items-center gap-1",children:[a.networkRole&&f.jsx(Di,{color:zL[a.networkRole],compact:!0,children:a.networkRole}),a.dataConfidence&&f.jsx(Di,{color:UL[a.dataConfidence],compact:!0,children:a.dataConfidence})]})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[f.jsxs("div",{children:[f.jsx(be,{content:`Flood TX delay factor (firmware default: ×${$L})`,children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Flood"})}),f.jsx("div",{className:"text-fg-primary tabular-nums text-sys-amber",children:m0(a.floodFactor)})]}),f.jsxs("div",{children:[f.jsx(be,{content:`Direct TX delay factor (firmware default: ×${jL})`,children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Direct"})}),f.jsx("div",{className:"text-fg-primary tabular-nums text-sys-amber",children:m0(a.directFactor)})]})]}),a.rationale&&f.jsx("div",{className:"mt-1 text-[9px] text-fg-muted leading-snug",children:a.rationale}),a.observationSymmetry!=null&&a.observationSymmetry<.6&&f.jsxs("div",{className:"mt-1 text-[9px] text-sys-amber/70 leading-snug",children:["⚠ Low observation symmetry (",(a.observationSymmetry*100).toFixed(0),"%) — recommendation damped toward firmware defaults"]}),f.jsxs("button",{onClick:async()=>{const h=`set txdelay ${a.floodFactor.toFixed(1)} -set direct.txdelay ${a.directFactor.toFixed(1)}`;try{await navigator.clipboard.writeText(h)}catch{}d(!0),setTimeout(()=>d(!1),1500)},className:"mt-1.5 flex items-center gap-1 text-[9px] text-sys-blue hover:text-sys-blue/80 transition-base",children:[u?f.jsx(EL,{className:"w-3 h-3 text-sys-green"}):f.jsx(CL,{className:"w-3 h-3"}),u?"Copied!":"Copy CLI commands"]})]}),s&&f.jsx("div",{className:"mt-2 pt-2 border-t border-edge-subtle/50",children:f.jsxs("button",{onClick:s,className:"flex items-center gap-1.5 text-[10px] text-sys-blue hover:text-sys-blue/80 transition-base",children:[f.jsx(TL,{className:"w-3 h-3"}),"Expand 2-hop neighborhood"]})}),r&&r.length>0&&f.jsxs("div",{className:"mt-2 pt-2 border-t border-edge-subtle/50",children:[f.jsxs("button",{onClick:()=>c(h=>!h),className:"flex items-center justify-between w-full text-[9px] text-fg-muted uppercase tracking-wide cursor-pointer hover:text-fg-secondary transition-base",children:[f.jsxs("span",{children:["Neighbors (",r.length,")"]}),f.jsx(Rc,{className:`w-3 h-3 transition-transform ${l?"rotate-180":""}`})]}),l&&f.jsx("div",{className:"mt-1.5 max-h-32 overflow-y-auto space-y-0.5",children:r.map(h=>f.jsxs("button",{onClick:()=>o==null?void 0:o(h.hash),className:"w-full flex items-center gap-2 px-1.5 py-1 radius-badge hover-bg transition-base text-left group",children:[f.jsx("code",{className:"text-[10px] text-sys-blue shrink-0 tabular-nums",children:h.prefix}),f.jsx("span",{className:"text-[10px] text-fg-secondary truncate flex-1",children:h.name||"—"}),h.avgSnr!=null&&f.jsxs("span",{className:"text-[9px] text-fg-muted tabular-nums shrink-0",children:[h.avgSnr.toFixed(0)," dB"]}),h.avgRssi!=null&&f.jsx("span",{className:"text-[9px] text-fg-muted tabular-nums shrink-0",children:h.avgRssi.toFixed(0)}),f.jsxs("span",{className:"text-[9px] text-fg-muted/60 tabular-nums shrink-0",children:[(h.edgeConfidence*100).toFixed(0),"%"]})]},h.hash))})]})]})]})}),ES=$.memo(function({metrics:e,onClose:t}){const n=Object.entries(e.communities).sort(([,r],[,o])=>o-r),s=Object.entries(e.nodeClasses).sort(([,r],[,o])=>o-r);return f.jsxs(Sl.div,{variants:X_,initial:"hidden",animate:"visible",exit:"exit",className:"absolute inset-x-3 bottom-3 z-20 surface-elevated radius-inset shadow-xl",children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-edge-subtle/50",children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.jsx(AS,{className:"size-3.5 text-fg-muted shrink-0"}),f.jsx("span",{className:"text-sm font-semibold text-fg-primary",children:"Subgraph Analysis"}),f.jsxs(Di,{color:"violet",compact:!0,children:[e.nodeCount," nodes"]})]}),f.jsx(q_,{plain:!0,onClick:t,title:"Close",className:"shrink-0",children:f.jsx($u,{className:"size-4"})})]}),f.jsxs("div",{className:"p-3 font-mono text-[11px]",children:[f.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[f.jsxs("div",{children:[f.jsx("div",{className:"text-[9px] text-fg-muted uppercase",children:"Nodes"}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.nodeCount})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Edges where both endpoints are within the lasso selection",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Internal Edges"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.edgeCount})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Mean betweenness centrality of selected nodes",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Avg Between."})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.avgBetweenness.toFixed(3)})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Mean edge disambiguation confidence for internal edges",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Avg Confidence"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[(e.avgConfidence*100).toFixed(0),"%"]})]})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-3 mt-2 pt-2 border-t border-edge-subtle/50",children:[f.jsxs("div",{children:[f.jsx("div",{className:"text-[9px] text-fg-muted uppercase mb-1",children:"Communities"}),f.jsx("div",{className:"flex flex-wrap gap-1",children:n.map(([r,o])=>f.jsxs("span",{className:"text-fg-secondary",children:["#",r,"×",o]},r))})]}),f.jsxs("div",{children:[f.jsx("div",{className:"text-[9px] text-fg-muted uppercase mb-1",children:"Node Types"}),f.jsx("div",{className:"flex flex-wrap gap-1",children:s.map(([r,o])=>f.jsxs("span",{className:"text-fg-secondary capitalize",children:[r,"×",o]},r))})]})]}),e.nodeCount>1&&f.jsx("div",{className:"mt-2 pt-2 border-t border-edge-subtle/50",children:f.jsxs("div",{className:"text-[9px] text-fg-muted flex items-center gap-1 flex-wrap",children:[f.jsx(be,{content:"Fraction of possible edges that exist — 2E / N(N-1)",children:f.jsxs("span",{className:"cursor-help",children:["Density: ",(2*e.edgeCount/(e.nodeCount*(e.nodeCount-1))*100).toFixed(1),"%"]})}),f.jsx("span",{children:"·"}),f.jsx(be,{content:"Mean connections per node — 2E / N",children:f.jsxs("span",{className:"cursor-help",children:["Avg Degree: ",(2*e.edgeCount/e.nodeCount).toFixed(1)]})}),e.avgPathHealth!=null&&f.jsxs(f.Fragment,{children:[f.jsx("span",{children:"·"}),f.jsx(be,{content:"Average health score of paths within the selection",children:f.jsxs("span",{className:"cursor-help",children:["Path Health: ",(e.avgPathHealth*100).toFixed(0),"%"]})})]})]})})]})]})});function qee(){return f.jsxs("div",{className:"flex flex-col items-center justify-center gap-6 text-center px-8",children:[f.jsx("div",{className:"p-4 radius-pill bg-subtle-fill",children:f.jsx(GL,{className:"w-8 h-8 text-fg-muted"})}),f.jsxs("div",{className:"space-y-2",children:[f.jsx("h2",{className:"type-subheading text-fg-primary",children:"No Topology Data"}),f.jsx("p",{className:"type-body text-fg-muted max-w-sm",children:"The mesh topology will appear here once packets are received and processed."})]}),f.jsxs("div",{className:"flex items-center gap-2 type-data-xs text-fg-muted",children:[f.jsx(dg,{className:"w-4 h-4 animate-pulse"}),f.jsx("span",{children:"Waiting for mesh traffic..."})]})]})}const fi=$.memo(function({label:e,value:t,onChange:n,min:s,max:r,step:o}){const[a,l]=$.useState(!1),[c,u]=$.useState(""),d=$.useRef(null),h=$.useCallback(()=>{const m=parseFloat(c);isNaN(m)||n(Math.min(r,Math.max(s,Math.round(m/o)*o))),l(!1)},[c,n,s,r,o]),p=$.useCallback(()=>{u(t.toFixed(2)),l(!0),setTimeout(()=>{var m;return(m=d.current)==null?void 0:m.select()},0)},[t]);return f.jsxs("div",{className:"space-y-1",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-[10px] text-fg-muted",children:e}),a?f.jsx("input",{ref:d,type:"number",value:c,onChange:m=>u(m.target.value),onBlur:h,onKeyDown:m=>{m.key==="Enter"&&h(),m.key==="Escape"&&l(!1)},min:s,max:r,step:o,className:"w-14 text-right text-[10px] text-fg-secondary tabular-nums bg-subtle-fill radius-badge px-1 py-0.5 border border-edge-subtle focus:outline-none focus:border-sys-blue"}):f.jsx("button",{onClick:p,className:"text-[10px] text-fg-secondary tabular-nums hover:text-sys-blue cursor-text transition-colors",title:"Click to type a value",children:t.toFixed(2)})]}),f.jsx("input",{type:"range",min:s,max:r,step:o,value:t,onChange:m=>n(parseFloat(m.target.value)),className:"w-full h-1 bg-subtle-fill rounded appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-sys-blue [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:cursor-pointer"})]})}),Va=$.memo(function({label:e,checked:t,onChange:n}){return f.jsxs(vL,{className:"flex items-center justify-between",children:[f.jsx(xL,{className:"text-[10px] text-fg-muted cursor-pointer select-none",children:e}),f.jsx(wL,{enabled:t,onChange:n,size:"sm"})]})});function Xee(){var Yv,qv,Xv,Kv,Zv,Qv,Jv,e0,t0,i0,n0,s0,r0,o0,a0;DL(PI);const i=oL(),[e,t]=$.useState(!1),[n,s]=$.useState(!1),r=$.useRef(!1);$.useEffect(()=>{!i||r.current||(r.current=!0,s(!0))},[i]);const o=$.useCallback(()=>{s(!1),t(!0)},[]),a=aL(),l=lL(),c=IJ(l,2e3),u=cL(),d=uL(),h=dL(),p=hL(),m=fL(),y=pL(),g=mL(),_=g?MI:OI,S=g?Fee:zee,C=$.useMemo(()=>Uee(g),[g]),x=$.useMemo(()=>$ee(g),[g]),[A,L]=$.useState(!0),[B,H]=$.useState(null),[Q,te]=$.useState(null),[M,he]=$.useState(!1),[se,R]=$.useState(""),[J,F]=$.useState(!1),[X,ie]=$.useState(!1),[ee,ae]=$.useState("simulation"),[Z,Se]=$.useState(!0),[xe,Je]=$.useState(!1),[de,bt]=$.useState(!0),[Xe,ht]=$.useState(!1),[re,Te]=$.useState(!1),[Pe,q]=$.useState(new Set),[We,He]=$.useState(!1),[it,Vt]=$.useState("spectral"),[me,nt]=$.useState(1),[ui,_i]=$.useState(1),[Zn,Qo]=$.useState(!1),[Zs,Li]=$.useState(null),[en,Ri]=$.useState(!1),[ai,vo]=$.useState(!1),[Es,Qn]=$.useState(null),[Jn,Cs]=$.useState(null),[zi,Ei]=$.useState(null),[ii,bn]=$.useState(null),[vn,Ts]=$.useState(null),On=gL(),[es,Dr]=$.useState(!1),[xn,Qs]=$.useState([]),[Jo,Zt]=$.useState(0),[Ot,ks]=$.useState(null),xo=$.useRef(new yee),Js=$.useRef(null),Rt=$.useRef(null),[Mr,ea]=$.useState(null),[ts,di]=$.useState(null),[Bn,wo]=$.useState({}),[ut,Or]=$.useState({simulationDecay:Ne.simulationDecay,simulationGravity:Ne.simulationGravity,simulationCenter:Ne.simulationCenter,simulationRepulsion:Ne.simulationRepulsion,simulationRepulsionTheta:Ne.simulationRepulsionTheta,simulationLinkSpring:Ne.simulationLinkSpring,simulationLinkDistance:Ne.simulationLinkDistance,simulationFriction:Ne.simulationFriction,simulationRepulsionFromMouse:Ne.simulationRepulsionFromMouse,pointSizeScale:Ne.pointSizeScale,pointOpacity:Ne.pointOpacity,pointGreyoutOpacity:Ne.pointGreyoutOpacity,linkWidthScale:Ne.linkWidthScale,linkOpacity:Ne.linkOpacity,linkGreyoutOpacity:Ne.linkGreyoutOpacity,curvedLinks:Ne.curvedLinks,curvedLinkWeight:Ne.curvedLinkWeight,linkDefaultArrows:Ne.linkDefaultArrows,linkArrowsSizeScale:Ne.linkArrowsSizeScale,scalePointsOnZoom:Ne.scalePointsOnZoom,scaleLinksOnZoom:Ne.scaleLinksOnZoom,renderLinks:Ne.renderLinks,renderHoveredPointRing:Ne.renderHoveredPointRing,spaceSize:Ne.spaceSize}),st=$.useCallback((v,j)=>{Or(W=>({...W,[v]:j}))},[]),wn=$.useCallback(()=>{Or({simulationDecay:Ne.simulationDecay,simulationGravity:Ne.simulationGravity,simulationCenter:Ne.simulationCenter,simulationRepulsion:Ne.simulationRepulsion,simulationRepulsionTheta:Ne.simulationRepulsionTheta,simulationLinkSpring:Ne.simulationLinkSpring,simulationLinkDistance:Ne.simulationLinkDistance,simulationFriction:Ne.simulationFriction,simulationRepulsionFromMouse:Ne.simulationRepulsionFromMouse,pointSizeScale:Ne.pointSizeScale,pointOpacity:Ne.pointOpacity,pointGreyoutOpacity:Ne.pointGreyoutOpacity,linkWidthScale:Ne.linkWidthScale,linkOpacity:Ne.linkOpacity,linkGreyoutOpacity:Ne.linkGreyoutOpacity,curvedLinks:Ne.curvedLinks,curvedLinkWeight:Ne.curvedLinkWeight,linkDefaultArrows:Ne.linkDefaultArrows,linkArrowsSizeScale:Ne.linkArrowsSizeScale,scalePointsOnZoom:Ne.scalePointsOnZoom,scaleLinksOnZoom:Ne.scaleLinksOnZoom,renderLinks:Ne.renderLinks,renderHoveredPointRing:Ne.renderHoveredPointRing,spaceSize:Ne.spaceSize})},[]);$.useEffect(()=>()=>{var v;try{(v=Rt.current)==null||v.destroy()}catch{}Rt.current=null},[]),$.useEffect(()=>{const v=j=>{var W,ce;if(!(j.target instanceof HTMLInputElement||j.target instanceof HTMLSelectElement))switch(j.key.toLowerCase()){case"f":!j.metaKey&&!j.ctrlKey&&(j.preventDefault(),(W=Rt.current)==null||W.fitView(sh));break;case"escape":J?(F(!1),R("")):B&&(H(null),(ce=Rt.current)==null||ce.unselectAllPoints());break;case"/":J||(j.preventDefault(),F(!0),setTimeout(()=>{var oe;return(oe=Js.current)==null?void 0:oe.focus()},50));break;case" ":j.preventDefault(),Rt.current&&(A?Rt.current.pause():Rt.current.start(),L(oe=>!oe));break;case"l":Se(oe=>!oe);break}};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[J,B,A]);const Br=$.useMemo(()=>new Set((a==null?void 0:a.backboneEdges)??[]),[a==null?void 0:a.backboneEdges]),er=$.useMemo(()=>({resolution:me,kWeight:ui}),[me,ui]),Fn=$.useMemo(()=>{if(it!=="louvain")return null;const v=a==null?void 0:a.edges;if(!v||v.length===0||!c||c.size<3)return null;const j=Array.from(c.keys());return hS(v,j,er).communities},[it,a==null?void 0:a.edges,c,er]),tn=$.useMemo(()=>{var oe;if(!c||c.size===0||!e)return[];const v=[],j=(y==null?void 0:y.node_name)??((oe=y==null?void 0:y.config)==null?void 0:oe.node_name)??null,W=g?"#171717":"#EFF0F1";let ce=1;for(const Ze of c.values())Ze.degree>ce&&(ce=Ze.degree);for(const Ze of c.values()){const fe=Ze,Ee=fe.degree>0?Math.log10(fe.degree+1)/Math.log10(ce+1):0,ji=yS+Math.min(1,Ee)*(cg-yS),nn=fe.betweenness*bS,ns=fe.isLocal?cg:Math.min(cg+bS,ji+nn),ss=(Fn==null?void 0:Fn.get(fe.hash))??fe.communityId,Ut=We&&ss>=0?S[ss%S.length]:_[fe.nodeClass],ye=Bee[fe.activityLevel]??1,Yt=fe.isLocal?_.local:ye<1?ug(Ut,W,ye):Ut,sc=fe.isLocal?j??fe.name:fe.name;v.push({id:fe.hash,label:sc?`${fe.prefix} ${sc}`:fe.prefix,color:Yt,size:ns,nodeClass:fe.nodeClass,name:sc,prefix:fe.prefix,packetCount:fe.packetCount,isLocal:fe.isLocal,isHub:fe.isHub,isGateway:fe.isGateway,isBackbone:fe.isBackbone,isMobile:fe.isMobile,isZeroHop:fe.isZeroHop,isGhost:fe.isGhost,degree:fe.degree,betweenness:fe.betweenness,communityId:(Fn==null?void 0:Fn.get(fe.hash))??fe.communityId,activityLevel:fe.activityLevel,prefixConfidence:fe.prefixConfidence,hasCollision:fe.hasCollision,inDegree:fe.inDegree,outDegree:fe.outDegree,isInLoop:fe.isInLoop,avgRssi:fe.avgRssi,avgSnr:fe.avgSnr})}for(const Ze of u){const fe=`ghost-${Ze.prefix}`;if(v.some(ji=>ji.id===fe))continue;const Ee=ug(_.ghost,W,.6);v.push({id:fe,label:`? ${Ze.prefix.toUpperCase()}`,color:Ee,size:Oee,nodeClass:"ghost",name:null,prefix:Ze.prefix,packetCount:Ze.observationCount,isLocal:!1,isHub:!1,isGateway:!1,isBackbone:!1,isMobile:!1,isZeroHop:!1,isGhost:!0,degree:Ze.commonNeighbors.size,betweenness:0,communityId:-1,activityLevel:"active",prefixConfidence:Ze.confidence,hasCollision:!1,inDegree:0,outDegree:0,isInLoop:!1,avgRssi:null,avgSnr:null})}return v},[c,e,y==null?void 0:y.node_name,(Yv=y==null?void 0:y.config)==null?void 0:Yv.node_name,_,g,u,S,We,it,Fn]),I=$.useMemo(()=>new Set(tn.map(v=>v.id)),[tn]),V=$.useMemo(()=>{const v=new Map;if(!c)return v;for(const j of c.values())v.set(j.hash,j.name);return v},[c]),E=$.useMemo(()=>{const v=(a==null?void 0:a.edges)??[];if(!v.length||!e)return[];const j=[],W=(a==null?void 0:a.edgeBetweenness)??new Map;for(const oe of v){if(!I.has(oe.fromHash)||!I.has(oe.toHash))continue;const Ze=Hee(oe,Br),fe=xS(Ze,oe.avgConfidence,g),Ee=W.get(oe.key)??0,ji=Ee>0?.5+Ee*4:.5+Math.min(1,oe.certainCount/50)*2;j.push({source:oe.fromHash,target:oe.toHash,color:fe,width:ji,key:oe.key,packetCount:oe.packetCount,certainCount:oe.certainCount,confidence:oe.avgConfidence,symmetryRatio:oe.symmetryRatio,dominantDirection:oe.dominantDirection,isBackbone:Br.has(oe.key),isLoopEdge:oe.isLoopEdge??!1,isDirectPath:oe.isDirectPathEdge,isZeroHop:oe.isZeroHop??!1,isGhost:!1,forwardCount:oe.forwardCount,reverseCount:oe.reverseCount,floodCount:oe.floodCount,directCount:oe.directCount,avgRssi:oe.avgRssi??null,avgSnr:oe.avgSnr??null,strength:oe.strength,fromName:V.get(oe.fromHash)??null,toName:V.get(oe.toHash)??null,edgeType:Ze})}const ce=g?NI:DI;for(const oe of u){const Ze=`ghost-${oe.prefix}`;if(I.has(Ze))for(const fe of oe.commonNeighbors)I.has(fe)&&j.push({source:Ze,target:fe,color:ce.ghost,width:.4,key:`ghost-${oe.prefix}-${fe}`,packetCount:oe.observationCount,certainCount:0,confidence:oe.confidence,symmetryRatio:0,dominantDirection:"balanced",isBackbone:!1,isLoopEdge:!1,isDirectPath:!1,isZeroHop:!1,isGhost:!0,forwardCount:0,reverseCount:0,floodCount:0,directCount:0,avgRssi:null,avgSnr:null,strength:oe.confidence,fromName:null,toName:V.get(fe)??null,edgeType:"ghost"})}return j},[a==null?void 0:a.edges,a==null?void 0:a.edgeBetweenness,e,I,g,Br,V,u]),G=(Xv=(qv=y==null?void 0:y.config)==null?void 0:qv.radio)==null?void 0:Xv.frequency,ne=(Zv=(Kv=y==null?void 0:y.config)==null?void 0:Kv.radio)==null?void 0:Zv.bandwidth,Ce=(Jv=(Qv=y==null?void 0:y.config)==null?void 0:Qv.radio)==null?void 0:Jv.spreading_factor,At=(t0=(e0=y==null?void 0:y.config)==null?void 0:e0.radio)==null?void 0:t0.tx_power,rt=(n0=(i0=y==null?void 0:y.config)==null?void 0:i0.radio)==null?void 0:n0.coding_rate,et=$.useMemo(()=>{if(!a||!ai)return null;const v={frequency:G,bandwidth:zi!=null?zi*1e3:ne,spreading_factor:Jn??Ce,tx_power:Es??At,coding_rate:ii??rt},j={};return vn!=null&&(j.sensitivityOverrideDbm=vn),On!=null&&(j.observedNoiseFloorDbm=On),lee(a,v,j)},[a,ai,G,ne,Ce,At,rt,Es,Jn,zi,ii,vn,On]),yi=$.useMemo(()=>{if(!et)return null;const v=new Map;for(const j of et)v.set(j.edgeKey,j);return v},[et]),ft=$.useMemo(()=>!et||et.length===0?null:cee(et),[et]),tr=$.useMemo(()=>{if(!ai||!yi)return E;const v=g?"#303038":"#D0D0D8";return E.map(j=>{const W=yi.get(j.key);return!W||!W.hasData?{...j,color:v,width:.3}:{...j,color:dee(W,"margin"),width:hee(W),linkBudget:W}})},[E,ai,yi,g]),Bt=$.useMemo(()=>Pe.size===0?tn:tn.filter(v=>!Pe.has(v.nodeClass)),[tn,Pe]),Ui=$.useMemo(()=>{if(Pe.size===0)return tr;const v=new Set(Bt.map(j=>j.id));return tr.filter(j=>v.has(j.source)&&v.has(j.target))},[tr,Bt,Pe]),Ra=$.useRef([]);$.useEffect(()=>{Ra.current=Ui},[Ui]);const ld=$.useMemo(()=>{const v=new Map;for(const j of E)v.set(j.source,(v.get(j.source)??0)+1),v.set(j.target,(v.get(j.target)??0)+1);return v},[E]),As=$.useMemo(()=>{const v=new Map;for(const j of tn)v.set(j.id,j);return v},[tn]);$.useEffect(()=>{if(Bt.length===0){ea(null),di(null),wo({});return}let v=!1;const W=setTimeout(async()=>{try{const ce=Bt.map(Ee=>({id:Ee.id,label:Ee.label,color:Ee.color,size:Ee.size,communityId:String(Ee.communityId)})),oe=Ui.map(Ee=>({source:Ee.source,target:Ee.target,color:Ee.color,width:Ee.width})),fe=await TQ({points:{pointIdBy:"id",pointColorBy:"color",pointColorStrategy:"direct",pointDefaultColor:g?"#9CA3AF":"#374151",pointLabelBy:"label",pointSizeBy:"size",pointSizeStrategy:"direct",pointDefaultSize:8,pointSizeScale:1,pointGreyoutOpacity:.3,pointIncludeColumns:["communityId"]},links:{linkSourceBy:"source",linkTargetsBy:["target"],linkColorBy:"color",linkColorStrategy:"direct",linkDefaultColor:g?"#6B7280":"#9CA3AF",linkWidthBy:"width",linkWidthStrategy:"direct",linkDefaultWidth:1,linkWidthScale:1,linkGreyoutOpacity:.1}},ce,oe);if(v||!fe)return;console.log("[MeshGraph] Prepared data:",{points:fe.points,links:fe.links,config:fe.cosmographConfig}),ea(fe.points??null),di(fe.links??null),wo(fe.cosmographConfig??{})}catch(ce){console.error("[MeshGraph] Data preparation failed:",ce)}},100);return()=>{v=!0,clearTimeout(W)}},[Bt,Ui,g]);const Iv=$.useCallback(v=>{v&&(Rt.current=v,v.start(),setTimeout(()=>{v.fitView(sh)},1500))},[]),BI=$.useCallback(()=>{var v;(v=Rt.current)==null||v.fitView(sh)},[]),FI=$.useCallback(()=>{const v=Rt.current;v&&(A?v.pause():v.start(),L(!A))},[A]),cd=$.useCallback(async v=>{const j=Rt.current,W=As.get(v);if(W){if(j)try{const ce=await j.getPointIndicesByIds([v]);ce&&ce.length>0&&ce[0]!==void 0&&(j.zoomToPoint(ce[0],Dee,2.5),j.selectPoint(ce[0],!1,!0))}catch{}te(null),H({hash:v,name:W.name,prefix:W.prefix,nodeClass:W.nodeClass,packetCount:W.packetCount,edgeCount:ld.get(v)??0,degree:W.degree,betweenness:W.betweenness,communityId:W.communityId,isLocal:W.isLocal,isHub:W.isHub,isGateway:W.isGateway,isBackbone:W.isBackbone,isMobile:W.isMobile,isZeroHop:W.isZeroHop,isGhost:W.isGhost,isInLoop:W.isInLoop,activityLevel:W.activityLevel,prefixConfidence:W.prefixConfidence,hasCollision:W.hasCollision,inDegree:W.inDegree,outDegree:W.outDegree,avgRssi:W.avgRssi,avgSnr:W.avgSnr})}},[As,ld]),Lv=$.useRef(null);$.useEffect(()=>{Lv.current=yi},[yi]);const Rv=$.useCallback(v=>{var ce;if(v===void 0){te(null);return}const j=Ra.current[v];if(!j)return;const W=(ce=Lv.current)==null?void 0:ce.get(j.key);te(W&&!j.linkBudget?{...j,linkBudget:W}:j),H(null)},[]),Pv=$.useCallback(async(v,j,W)=>{var oe;if(v===void 0){H(null),Li(null),(oe=Rt.current)==null||oe.unselectAllPoints();return}te(null);const ce=Rt.current;if(ce)try{const Ze=await ce.getPointIdsByIndices([v]);if(!Ze||Ze.length===0)return;const fe=Ze[0],Ee=As.get(fe);if(!Ee)return;ce.selectPoint(v,!1,!0),H({hash:fe,name:Ee.name,prefix:Ee.prefix,nodeClass:Ee.nodeClass,packetCount:Ee.packetCount,edgeCount:ld.get(fe)??0,degree:Ee.degree,betweenness:Ee.betweenness,communityId:Ee.communityId,isLocal:Ee.isLocal,isHub:Ee.isHub,isGateway:Ee.isGateway,isBackbone:Ee.isBackbone,isMobile:Ee.isMobile,isZeroHop:Ee.isZeroHop,isGhost:Ee.isGhost,isInLoop:Ee.isInLoop,activityLevel:Ee.activityLevel,prefixConfidence:Ee.prefixConfidence,hasCollision:Ee.hasCollision,inDegree:Ee.inDegree,outDegree:Ee.outDegree,avgRssi:Ee.avgRssi,avgSnr:Ee.avgSnr})}catch{}},[As,ld]),ic=$.useMemo(()=>{if(!J||!se.trim())return[];const v=se.toLowerCase();return tn.filter(j=>{var W;return j.prefix.toLowerCase().includes(v)||((W=j.name)==null?void 0:W.toLowerCase().includes(v))||j.id.toLowerCase().includes(v)}).slice(0,8)},[tn,se,J]),Nv=$.useCallback(v=>{F(!1),R(""),cd(v.id)},[cd]),Dv=$.useCallback(()=>{he(v=>!v)},[]),zI=$.useCallback(v=>{q(j=>{const W=new Set(j);return W.has(v)?W.delete(v):W.add(v),W})},[]),UI=$.useCallback(()=>{He(v=>{const j=!v,W=Rt.current;return W&&W.start(.5),j})},[]),$I=$.useCallback(()=>{Qo(v=>{const j=!v,W=Rt.current;return W&&(j?W.activatePolygonalSelection():(W.deactivatePolygonalSelection(),Li(null),W.unselectAllPoints())),j})},[]),Mv=$.useCallback(async()=>{const v=Rt.current;if(!v)return;await new Promise(Ut=>setTimeout(Ut,80));const j=v.getSelectedPointIndices();if(!j||j.length===0){Li(null);return}const W=await v.getPointIdsByIndices(j);if(!W||W.length===0){Li(null);return}const ce=new Set(W);let oe=0,Ze=0;for(const Ut of Ra.current)ce.has(Ut.source)&&ce.has(Ut.target)&&(oe++,Ze+=Ut.confidence);let fe=0;const Ee={},ji={};for(const Ut of W){const ye=As.get(Ut);ye&&(fe+=ye.betweenness,Ee[ye.communityId]=(Ee[ye.communityId]??0)+1,ji[ye.nodeClass]=(ji[ye.nodeClass]??0)+1)}const nn=new Set;for(const Ut of W){const ye=As.get(Ut);ye&&nn.add(ye.prefix.toLowerCase())}let ns=0,ss=0;for(const Ut of p)if(Ut.hops.length>=2){const ye=Ut.hops[0].toLowerCase(),Yt=Ut.hops[Ut.hops.length-1].toLowerCase();nn.has(ye)&&nn.has(Yt)&&(ns+=Ut.healthScore,ss++)}Li({nodeCount:W.length,edgeCount:oe,avgBetweenness:W.length>0?fe/W.length:0,avgConfidence:oe>0?Ze/oe:0,avgPathHealth:ss>0?ns/ss:null,communities:Ee,nodeClasses:ji}),H(null),te(null)},[As,p]),Ov=$.useCallback(()=>{var v;Li(null),(v=Rt.current)==null||v.unselectAllPoints()},[]),Bv=$.useMemo(()=>{var Ut;if(!B)return null;const v=B.hash,j=new Set;for(const ye of Ui)ye.source===v?j.add(ye.target):ye.target===v&&j.add(ye.source);if(j.size===0)return{clusteringCoeff:0,avgNeighborBetweenness:0,neighborCount:0,avgEdgeConfidence:0,avgRssi:null,avgSnr:null};let W=0;for(const ye of Ui)j.has(ye.source)&&j.has(ye.target)&&W++;const ce=j.size,oe=ce>1?2*W/(ce*(ce-1)):0;let Ze=0;for(const ye of j)Ze+=((Ut=As.get(ye))==null?void 0:Ut.betweenness)??0;let fe=0,Ee=0,ji=0,nn=0,ns=0,ss=0;for(const ye of Ui)(ye.source===v||ye.target===v)&&(fe+=ye.confidence,Ee++,ye.avgRssi!=null&&(ji+=ye.avgRssi,nn++),ye.avgSnr!=null&&(ns+=ye.avgSnr,ss++));return{clusteringCoeff:Math.min(1,oe),avgNeighborBetweenness:Ze/ce,neighborCount:ce,avgEdgeConfidence:Ee>0?fe/Ee:0,avgRssi:nn>0?ji/nn:null,avgSnr:ss>0?ns/ss:null}},[B,Ui,As]),Fv=$.useMemo(()=>!B||!m?null:m.get(B.hash)??null,[B,m]),zv=$.useMemo(()=>{if(!B)return[];const v=B.hash,j=[],W=new Set;for(const ce of Ui){let oe=null;if(ce.source===v?oe=ce.target:ce.target===v&&(oe=ce.source),!oe||W.has(oe))continue;W.add(oe);const Ze=As.get(oe);j.push({hash:oe,prefix:(Ze==null?void 0:Ze.prefix)??oe.slice(2,4).toUpperCase(),name:(Ze==null?void 0:Ze.name)??null,edgeConfidence:ce.confidence,edgeType:ce.edgeType,avgRssi:ce.avgRssi,avgSnr:ce.avgSnr})}return j.sort((ce,oe)=>oe.edgeConfidence-ce.edgeConfidence),j},[B,Ui,As]),Uv=$.useCallback(async()=>{const v=Rt.current;if(!v||!B)return;const j=await v.getPointIndicesByIds([B.hash]);if(!j||j[0]===void 0)return;const W=j[0],ce=v.getConnectedPointIndices(W)??[],oe=new Set([W,...ce]);for(const fe of ce){const Ee=v.getConnectedPointIndices(fe)??[];for(const ji of Ee)oe.add(ji)}const Ze=Array.from(oe);v.selectPoints(Ze),v.fitViewByIndices(Ze,sh,.15)},[B]);$.useEffect(()=>{if(!Zn)return;const v=j=>{var W,ce;j.key==="Escape"&&(Qo(!1),(W=Rt.current)==null||W.deactivatePolygonalSelection(),Li(null),(ce=Rt.current)==null||ce.unselectAllPoints())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[Zn]);const jI=$.useCallback((v,j)=>{a&&(qJ(a,{format:v,dataset:j}),Ri(!1))},[a]),$i=$.useMemo(()=>{if(!a||!p.length)return null;const v=a.edges??[];return v.length===0?null:Lee(p,v)},[a,p]),So=$.useMemo(()=>{const v=a==null?void 0:a.edges;if(!v||v.length===0||!c||c.size<3)return null;const j=Array.from(c.keys());return RL(v,j)},[a==null?void 0:a.edges,c]),ud=$.useMemo(()=>{if(it!=="louvain")return null;const v=a==null?void 0:a.edges;if(!v||v.length===0||!c||c.size<3)return null;const j=Array.from(c.keys());return hS(v,j,er)},[it,a==null?void 0:a.edges,c,er]);$.useEffect(()=>{if(!a)return;const v=new Map;for(const[W,ce]of a.nodeMetrics)v.set(W,ce.name);const j=xo.current.update(a,v);j.totalCount>0&&(Qs(xo.current.getLog()),Zt(W=>W+j.totalCount))},[a]);const HI=$.useCallback(()=>{Zt(0),Dr(v=>!v)},[]),Fr=$.useMemo(()=>Mee(So,g),[So,g]),dd=f.jsxs("div",{className:"absolute top-0 left-0 right-0 z-20 px-4 py-3 pointer-events-none flex items-start justify-between",children:[f.jsxs("h1",{className:"type-title text-fg-primary flex items-center gap-2 sm:gap-3 pointer-events-auto",children:[f.jsx(c0,{className:"w-5 h-5 sm:w-6 sm:h-6 text-icon-page-title"}),f.jsx("span",{children:"MeshGraph"}),f.jsx(Di,{color:"violet",compact:!0,children:"Analytics"})]}),Fr&&f.jsx(be,{content:f.jsxs("div",{className:"max-w-xs space-y-2",children:[f.jsx("div",{className:"font-semibold text-fg-primary",children:"Mesh Resilience Score"}),f.jsx("div",{className:"text-fg-secondary",children:"Derived from the Fiedler eigenvalue (λ₂) — the second-smallest eigenvalue of the graph Laplacian. Measures how well-connected the mesh is and how resistant it is to partitioning."}),f.jsxs("div",{className:"space-y-0.5 font-mono text-[10px]",children:[f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Raw λ₂"}),f.jsx("span",{className:"text-fg-primary tabular-nums",children:(So==null?void 0:So.toFixed(6))??"—"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Score"}),f.jsxs("span",{className:"tabular-nums",style:{color:Fr.color},children:[Fr.score,"/100"]})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Grade"}),f.jsx("span",{className:"capitalize",style:{color:Fr.color},children:Fr.grade})]})]}),f.jsxs("div",{className:"pt-1 border-t border-edge-subtle/30 space-y-0.5 text-[10px]",children:[f.jsx("div",{className:"text-fg-muted font-medium",children:"Grade thresholds"}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{style:{color:el.excellent[0]},children:"Excellent"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"80-100 (λ₂ > 0.3)"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{style:{color:el.good[0]},children:"Good"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"55-79 (λ₂ 0.03-0.3)"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{style:{color:el.fair[0]},children:"Fair"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"30-54 (λ₂ 0.003-0.03)"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{style:{color:el.poor[0]},children:"Poor"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"10-29 (λ₂ 0.0001-0.003)"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{style:{color:el.critical[0]},children:"Critical"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"<10 (λ₂ ≈ 0)"})]})]}),f.jsx("div",{className:"text-[10px] text-fg-muted italic",children:"Near-zero λ₂ = one bridge away from network partition. Log-scale mapping: small λ₂ changes at low values have outsized impact."})]}),children:f.jsxs("div",{className:"pointer-events-auto surface-control radius-inner px-3 py-1.5 flex items-center gap-2 cursor-help",children:[f.jsxs("div",{className:"flex items-baseline gap-1.5",children:[f.jsx("span",{className:"text-[10px] text-fg-muted uppercase tracking-wider",children:"Resilience"}),f.jsx("span",{className:"text-lg font-semibold tabular-nums leading-none",style:{color:Fr.color},children:Fr.score})]}),f.jsx("div",{className:"w-12 h-1.5 rounded-full bg-subtle-fill overflow-hidden",children:f.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${Fr.score}%`,backgroundColor:Fr.color}})})]})})]}),is=(v,j=!1)=>{const W="flex flex-col items-center gap-0.5 px-1.5 py-1 radius-inner transition-all duration-100 active:scale-95";return v&&j?`${W} bg-status-warning/15 text-status-warning shadow-inner`:v?`${W} bg-sys-blue/20 text-sys-blue shadow-inner`:`${W} hover:bg-white/5 hover:scale-105 text-fg-secondary`},nc=f.jsx("div",{className:"w-px h-6 bg-border-subtle/40 mx-0.5 shrink-0"}),$v=f.jsxs("div",{className:"absolute top-12 right-3 z-10 flex items-center gap-0.5 surface-control radius-inner px-1.5 py-1",children:[f.jsx(be,{content:"Visible nodes / edges in the graph",children:f.jsxs("span",{className:"text-[9px] text-fg-muted tabular-nums mr-1.5 leading-none cursor-help",children:[Bt.length,f.jsx("br",{}),Ui.length]})}),nc,f.jsx(be,{content:Z?"Hide labels (L)":"Show labels (L)",children:f.jsxs("button",{onClick:()=>Se(v=>!v),className:is(!Z,!0),children:[Z?f.jsx(HL,{className:"w-3.5 h-3.5"}):f.jsx(PL,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Lbl"})]})}),f.jsx(be,{content:We?"Disable clustering":"Community clustering",children:f.jsxs("button",{onClick:UI,className:is(We),children:[f.jsx(ZL,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Grp"})]})}),f.jsx(be,{content:Zn?"Exit lasso (Esc)":"Lasso selection",children:f.jsxs("button",{onClick:$I,className:is(Zn,!0),children:[f.jsx(AS,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Sel"})]})}),nc,f.jsx(be,{content:"Legend",children:f.jsxs("button",{onClick:()=>Je(v=>!v),className:is(xe),children:[f.jsx(g0,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Map"})]})}),f.jsx(be,{content:"Search (/)",children:f.jsxs("button",{onClick:()=>{F(!0),setTimeout(()=>{var v;return(v=Js.current)==null?void 0:v.focus()},50)},className:is(J),children:[f.jsx(_0,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Fnd"})]})}),nc,f.jsx(be,{content:A?"Pause (Space)":"Play (Space)",children:f.jsxs("button",{onClick:FI,className:is(!A),children:[A?f.jsx(_L,{className:"w-3.5 h-3.5 text-sys-green"}):f.jsx(yL,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:A?"Run":"Stop"})]})}),f.jsx(be,{content:"Fit view (F)",children:f.jsxs("button",{onClick:BI,className:is(!1),children:[f.jsx(XL,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Fit"})]})}),nc,f.jsx(be,{content:ai?"Disable link budget":"Link budget overlay",children:f.jsxs("button",{onClick:()=>vo(v=>!v),className:is(ai),children:[f.jsx(dg,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"RF"})]})}),f.jsx(be,{content:"Anomaly log",children:f.jsxs("button",{onClick:HI,className:`relative ${is(es,!0)}`,children:[f.jsx(hd,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Alert"}),Jo>0&&f.jsx("span",{className:"absolute -top-1 -right-0.5 w-3 h-3 rounded-full bg-status-danger text-[7px] font-bold text-white flex items-center justify-center",children:Jo>9?"9+":Jo})]})}),f.jsx(be,{content:"Export topology",children:f.jsxs("button",{onClick:()=>Ri(v=>!v),className:is(en),children:[f.jsx(y0,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Exp"})]})}),f.jsx(be,{content:"Settings",children:f.jsxs("button",{onClick:()=>ie(v=>!v),className:is(X),children:[f.jsx(b0,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Cfg"})]})}),nc,f.jsx(be,{content:M?"Exit fullscreen":"Fullscreen",children:f.jsxs("button",{onClick:Dv,className:is(M),children:[M?f.jsx(f0,{className:"w-3.5 h-3.5"}):f.jsx(TS,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Max"})]})})]}),jv=f.jsxs(nh,{id:"settings",title:"Graph Settings",icon:f.jsx(b0,{}),open:X,onClose:()=>ie(!1),defaultPosition:{x:typeof window<"u"?window.innerWidth-308:600,y:60},defaultSize:{width:288,height:420},minSize:{width:260,height:200},maxSize:{width:400,height:600},headerActions:f.jsx(be,{content:"Reset to defaults",children:f.jsx("button",{onClick:wn,className:"p-0.5 radius-badge hover-bg transition-base",children:f.jsx(v0,{className:"w-2.5 h-2.5 text-fg-muted"})})}),children:[f.jsx("div",{className:"flex border-b border-edge-subtle",children:["simulation","points","links","rendering"].map(v=>f.jsx("button",{onClick:()=>ae(v),className:`flex-1 px-2 py-1.5 text-[10px] font-medium capitalize transition-colors ${ee===v?"text-sys-blue border-b-2 border-sys-blue":"text-fg-muted hover:text-fg-secondary"}`,children:v},v))}),f.jsxs("div",{className:"p-3 space-y-3",children:[ee==="simulation"&&f.jsxs(f.Fragment,{children:[f.jsx(fi,{label:"Gravity",value:ut.simulationGravity,onChange:v=>st("simulationGravity",v),min:0,max:1,step:.01}),f.jsx(fi,{label:"Repulsion",value:ut.simulationRepulsion,onChange:v=>st("simulationRepulsion",v),min:0,max:5,step:.1}),f.jsx(fi,{label:"Link Spring",value:ut.simulationLinkSpring,onChange:v=>st("simulationLinkSpring",v),min:0,max:2,step:.05}),f.jsx(fi,{label:"Link Distance",value:ut.simulationLinkDistance,onChange:v=>st("simulationLinkDistance",v),min:1,max:100,step:1}),f.jsx(fi,{label:"Friction",value:ut.simulationFriction,onChange:v=>st("simulationFriction",v),min:0,max:1,step:.01}),f.jsx(fi,{label:"Center Force",value:ut.simulationCenter,onChange:v=>st("simulationCenter",v),min:0,max:1,step:.01}),f.jsx(fi,{label:"Decay",value:ut.simulationDecay,onChange:v=>st("simulationDecay",v),min:100,max:2e4,step:100}),f.jsx(fi,{label:"Repulsion Theta",value:ut.simulationRepulsionTheta,onChange:v=>st("simulationRepulsionTheta",v),min:.1,max:3,step:.05}),f.jsx(fi,{label:"Mouse Repulsion",value:ut.simulationRepulsionFromMouse,onChange:v=>st("simulationRepulsionFromMouse",v),min:0,max:10,step:.5})]}),ee==="points"&&f.jsxs(f.Fragment,{children:[f.jsx(fi,{label:"Size Scale",value:ut.pointSizeScale,onChange:v=>st("pointSizeScale",v),min:.1,max:5,step:.1}),f.jsx(fi,{label:"Opacity",value:ut.pointOpacity,onChange:v=>st("pointOpacity",v),min:0,max:1,step:.05}),f.jsx(fi,{label:"Greyout Opacity",value:ut.pointGreyoutOpacity,onChange:v=>st("pointGreyoutOpacity",v),min:0,max:1,step:.05}),f.jsx(Va,{label:"Scale on Zoom",checked:ut.scalePointsOnZoom,onChange:v=>st("scalePointsOnZoom",v)}),f.jsx(Va,{label:"Hover Ring",checked:ut.renderHoveredPointRing,onChange:v=>st("renderHoveredPointRing",v)})]}),ee==="links"&&f.jsxs(f.Fragment,{children:[f.jsx(Va,{label:"Show Links",checked:ut.renderLinks,onChange:v=>st("renderLinks",v)}),f.jsx(Va,{label:"Curved Links",checked:ut.curvedLinks,onChange:v=>st("curvedLinks",v)}),f.jsx(Va,{label:"Show Arrows",checked:ut.linkDefaultArrows,onChange:v=>st("linkDefaultArrows",v)}),f.jsx(fi,{label:"Width Scale",value:ut.linkWidthScale,onChange:v=>st("linkWidthScale",v),min:.1,max:5,step:.1}),f.jsx(fi,{label:"Opacity",value:ut.linkOpacity,onChange:v=>st("linkOpacity",v),min:0,max:1,step:.05}),f.jsx(fi,{label:"Greyout Opacity",value:ut.linkGreyoutOpacity,onChange:v=>st("linkGreyoutOpacity",v),min:0,max:1,step:.05}),ut.curvedLinks&&f.jsx(fi,{label:"Curve Weight",value:ut.curvedLinkWeight,onChange:v=>st("curvedLinkWeight",v),min:0,max:1,step:.05}),ut.linkDefaultArrows&&f.jsx(fi,{label:"Arrow Size",value:ut.linkArrowsSizeScale,onChange:v=>st("linkArrowsSizeScale",v),min:.1,max:3,step:.1}),f.jsx(Va,{label:"Scale on Zoom",checked:ut.scaleLinksOnZoom,onChange:v=>st("scaleLinksOnZoom",v)})]}),ee==="rendering"&&f.jsxs(f.Fragment,{children:[f.jsx(fi,{label:"Space Size",value:ut.spaceSize,onChange:v=>st("spaceSize",v),min:1024,max:16384,step:512}),f.jsx("div",{className:"pt-2 border-t border-edge-subtle/50",children:f.jsx("p",{className:"text-[9px] text-fg-muted",children:"Space size defines the simulation boundary. Larger values allow more spread."})})]})]})]}),VI=[{label:"Full Topology (JSON)",format:"json",dataset:"full",desc:"All data: nodes, edges, paths, TX delay"},{label:"Gephi Graph (GEXF)",format:"gexf",dataset:"full",desc:"Import into Gephi for advanced analysis"},{label:"Nodes (CSV)",format:"csv",dataset:"nodes",desc:"Node metrics: centrality, class, signal"},{label:"Edges (CSV)",format:"csv",dataset:"edges",desc:"Edge metrics: confidence, symmetry, type"},{label:"Path Health (CSV)",format:"csv",dataset:"pathHealth",desc:"Route health scores and trends"},{label:"TX Delay (CSV)",format:"csv",dataset:"txDelay",desc:"TX delay recommendations per node"}],Hv=f.jsxs(nh,{id:"export",title:"Export Topology",icon:f.jsx(y0,{}),open:en,onClose:()=>Ri(!1),defaultPosition:{x:typeof window<"u"?window.innerWidth-280:600,y:100},defaultSize:{width:256,height:320},minSize:{width:220,height:150},autoHeight:!0,children:[f.jsx("div",{className:"py-1",children:VI.map(({label:v,format:j,dataset:W,desc:ce})=>f.jsxs("button",{onClick:()=>jI(j,W),className:"w-full flex flex-col px-3 py-2 text-left hover-bg transition-base",children:[f.jsx("span",{className:"text-[11px] font-medium text-fg-primary",children:v}),f.jsx("span",{className:"text-[9px] text-fg-muted",children:ce})]},`${j}-${W}`))}),f.jsx("div",{className:"px-3 py-1.5 border-t border-edge-subtle",children:f.jsxs("span",{className:"text-[9px] text-fg-muted",children:[((s0=a==null?void 0:a.nodeMetrics)==null?void 0:s0.size)??0," nodes · ",((r0=a==null?void 0:a.validatedEdges)==null?void 0:r0.length)??0," edges"]})})]}),GI={info:{dot:"bg-sys-blue",text:"text-fg-secondary"},warning:{dot:"bg-status-warning",text:"text-status-warning"},critical:{dot:"bg-status-danger",text:"text-status-danger"}},WI={"edge-appeared":"Link Discovered","edge-disappeared":"Link Lost","ghost-appeared":"Ghost Discovered","ghost-disappeared":"Ghost Resolved","betweenness-shift":"Traffic Rerouting","community-change":"Community Change","class-change":"Role Change","node-appeared":"Node Appeared","node-disappeared":"Node Dropped","snr-degradation":"SNR Degradation","asymmetry-shift":"Asymmetry Shift"},Pi=(v,j,W)=>j==null||j===""?null:f.jsxs("div",{className:"flex justify-between gap-2",children:[f.jsx("span",{className:"text-fg-muted",children:v}),f.jsx("span",{className:`tabular-nums text-right ${W??"text-fg-secondary"}`,children:j})]}),YI=v=>{const j=[];return v.isZeroHop&&j.push({label:"Zero-Hop",color:"text-status-warning"}),v.isDirectPath&&j.push({label:"Direct",color:"text-sys-blue"}),v.isBackbone&&j.push({label:"Backbone",color:"text-fg-primary"}),v.isLoop&&j.push({label:"Loop",color:"text-sys-indigo"}),j.length===0?null:f.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:j.map(W=>f.jsx("span",{className:`text-[8px] font-medium uppercase tracking-wider px-1 py-px radius-badge bg-subtle-fill ${W.color}`,children:W.label},W.label))})},qI=(v,j)=>f.jsxs("div",{className:"text-[9px] space-y-0.5",children:[(v.fromClass||v.toClass)&&f.jsxs("div",{className:"flex items-center gap-1 text-fg-muted",children:[f.jsx("span",{className:"capitalize",children:v.fromClass??"?"}),f.jsx("span",{className:"text-fg-muted/40",children:"↔"}),f.jsx("span",{className:"capitalize",children:v.toClass??"?"})]}),j==="edge-appeared"&&v.packetCount>0&&f.jsxs(f.Fragment,{children:[Pi("Packets",v.packetCount),Pi("Confidence",`${(v.confidence*100).toFixed(0)}%`,v.confidence>=.8?"text-sys-green":v.confidence>=.5?"text-sys-indigo":"text-signal-poor"),Pi("Symmetry",`${(v.symmetryRatio*100).toFixed(0)}%`)]}),v.isZeroHop&&v.avgRssi!=null&&Pi("RSSI",`${v.avgRssi.toFixed(0)} dBm`),v.isZeroHop&&v.avgSnr!=null&&Pi("SNR",`${v.avgSnr.toFixed(1)} dB`),v.fromBetweenness!=null&&v.fromBetweenness>.01&&Pi(`${v.fromName??"A"} centrality`,v.fromBetweenness.toFixed(3)),v.toBetweenness!=null&&v.toBetweenness>.01&&Pi(`${v.toName??"B"} centrality`,v.toBetweenness.toFixed(3)),YI(v)]}),XI=v=>f.jsxs("div",{className:"text-[9px] space-y-0.5",children:[f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("span",{className:"capitalize font-medium text-fg-secondary",children:v.nodeClass}),v.isZeroHop&&f.jsx("span",{className:"text-[8px] font-medium uppercase tracking-wider px-1 py-px radius-badge bg-subtle-fill text-status-warning",children:"Neighbor"})]}),Pi("Degree",v.degree),v.betweenness>.01&&Pi("Betweenness",v.betweenness.toFixed(3)),Pi("Packets",v.packetCount),Pi("Community",`#${v.communityId}`),Pi("Activity",v.activityLevel),v.avgRssi!=null&&Pi("RSSI",`${v.avgRssi.toFixed(0)} dBm`),v.avgSnr!=null&&Pi("SNR",`${v.avgSnr.toFixed(1)} dB`)]}),KI=v=>f.jsxs("div",{className:"text-[9px] space-y-0.5",children:[v.previousValue!=null&&v.currentValue!=null&&f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"text-fg-muted font-mono",children:typeof v.previousValue=="number"?v.previousValue.toFixed(3):v.previousValue}),f.jsx("span",{className:"text-fg-muted/40",children:"→"}),f.jsx("span",{className:"text-fg-secondary font-mono",children:typeof v.currentValue=="number"?v.currentValue.toFixed(3):v.currentValue}),typeof v.previousValue=="number"&&typeof v.currentValue=="number"&&f.jsxs("span",{className:v.currentValue>v.previousValue?"text-sys-green":"text-signal-poor",children:["(",v.currentValue>v.previousValue?"+":"",(v.currentValue-v.previousValue).toFixed(3),")"]})]}),v.nodeDetail&&f.jsxs(f.Fragment,{children:[Pi("Class",v.nodeDetail.nodeClass),Pi("Degree",v.nodeDetail.degree),v.nodeDetail.betweenness>.01&&Pi("Betweenness",v.nodeDetail.betweenness.toFixed(3))]})]}),ZI=$.useCallback(v=>{ks(j=>j===v?null:v)},[]),Vv=f.jsxs(nh,{id:"anomaly",title:"Anomaly Log",icon:f.jsx(hd,{}),open:es,onClose:()=>Dr(!1),defaultPosition:{x:typeof window<"u"?window.innerWidth-328:600,y:100},defaultSize:{width:308,height:400},minSize:{width:260,height:180},maxSize:{width:440,height:700},headerActions:xn.length>0?f.jsx("button",{onClick:()=>{xo.current.clear(),Qs([]),ks(null)},className:"p-0.5 radius-badge hover-bg transition-base",title:"Clear all",children:f.jsx(v0,{className:"w-2.5 h-2.5 text-fg-muted"})}):void 0,children:[xn.length===0?f.jsxs("div",{className:"px-3 py-6 text-center",children:[f.jsx(hd,{className:"w-5 h-5 text-fg-muted mx-auto mb-1.5"}),f.jsx("p",{className:"text-[11px] text-fg-muted",children:"No anomalies detected yet"}),f.jsx("p",{className:"text-[9px] text-fg-muted/60 mt-0.5",children:"Changes appear after topology recomputes"})]}):f.jsx("div",{className:"overflow-y-auto",children:xn.slice(0,50).map(v=>{const j=GI[v.severity],W=bL(v.detectedAt/1e3),ce=Ot===v.id,oe=!!(v.edgeDetail||v.nodeDetail||v.previousValue!=null);return f.jsxs("div",{className:`border-b border-edge-subtle/50 last:border-0 transition-colors ${oe?"cursor-pointer hover-bg":""} ${ce?"bg-subtle-fill/50":""}`,onClick:oe?()=>ZI(v.id):void 0,children:[f.jsxs("div",{className:"flex items-start gap-2 px-3 py-1.5",children:[f.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 mt-1.5 ${j.dot}`}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("p",{className:`text-[10px] leading-tight ${j.text}`,children:v.description}),f.jsxs("p",{className:"text-[9px] text-fg-muted/60 mt-0.5",children:[WI[v.category]??v.category," · ",W]})]}),oe&&f.jsx(Rc,{className:`w-3 h-3 text-fg-muted/40 shrink-0 mt-0.5 transition-transform duration-150 ${ce?"rotate-180":""}`})]}),ce&&f.jsx("div",{className:"px-3 pb-2 pl-6",children:f.jsxs("div",{className:"border-l-2 border-edge-subtle/60 pl-2 py-0.5",children:[v.edgeDetail&&qI(v.edgeDetail,v.category),v.nodeDetail&&!v.edgeDetail&&(v.category==="node-appeared"||v.category==="node-disappeared")&&XI(v.nodeDetail),(v.category==="betweenness-shift"||v.category==="community-change"||v.category==="class-change")&&KI(v)]})})]},v.id)})}),xn.length>0&&f.jsx("div",{className:"px-3 py-1.5 border-t border-edge-subtle",children:f.jsxs("span",{className:"text-[9px] text-fg-muted",children:[xn.length," total · showing ",Math.min(xn.length,50)]})})]}),QI=[["local","Local"],["hub","Hub"],["gateway","Gateway"],["backbone","Backbone"],["neighbor","Neighbor"],["mobile","Mobile"],["ghost","Ghost"],["standard","Standard"]],JI=[{type:"zero-hop",label:"Zero-Hop RF"},{type:"direct-path",label:"Direct Path"},{type:"loop",label:"Loop"},{type:"backbone",label:"Backbone"},{type:"standard",label:"Standard"},{type:"ghost",label:"Ghost"}],eL=$.useMemo(()=>{const v={};for(const j of E)v[j.edgeType]=(v[j.edgeType]??0)+1;return v},[E]),Gv=f.jsxs(nh,{id:"legend",title:"Legend",icon:f.jsx(g0,{}),open:xe,onClose:()=>Je(!1),defaultPosition:{x:12,y:60},defaultSize:{width:224,height:400},minSize:{width:200,height:150},maxSize:{width:360,height:700},autoHeight:!0,children:[f.jsxs("div",{className:"border-b border-edge-subtle",children:[f.jsxs("button",{onClick:()=>bt(v=>!v),className:"w-full flex items-center gap-1.5 px-3 py-1.5 text-[10px] font-medium text-fg-secondary hover-bg transition-base",children:[de?f.jsx(Rc,{className:"w-3 h-3"}):f.jsx(Hp,{className:"w-3 h-3"}),"Nodes",f.jsx("span",{className:"text-fg-muted ml-auto tabular-nums",children:Bt.length})]}),de&&f.jsx("div",{className:"px-2 pb-2 space-y-0.5",children:QI.map(([v,j])=>{const W=d[v]??0;if(W===0&&v!=="local")return null;const ce=Pe.has(v);return f.jsx(be,{content:jee[v],children:f.jsxs("button",{onClick:()=>zI(v),className:`w-full flex items-center gap-2 px-2 py-1 radius-badge transition-base text-left ${ce?"opacity-40":"hover-bg"}`,children:[f.jsx("span",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{backgroundColor:_[v]}}),f.jsx("span",{className:"text-[10px] text-fg-secondary flex-1",children:j}),f.jsx("span",{className:"text-[10px] text-fg-muted tabular-nums",children:W})]})},v)})})]}),f.jsxs("div",{className:"border-b border-edge-subtle",children:[f.jsxs("button",{onClick:()=>ht(v=>!v),className:"w-full flex items-center gap-1.5 px-3 py-1.5 text-[10px] font-medium text-fg-secondary hover-bg transition-base",children:[Xe?f.jsx(Rc,{className:"w-3 h-3"}):f.jsx(Hp,{className:"w-3 h-3"}),"Edges",f.jsx("span",{className:"text-fg-muted ml-auto tabular-nums",children:Ui.length})]}),Xe&&f.jsx("div",{className:"px-2 pb-2 space-y-0.5",children:JI.map(({type:v,label:j})=>{const W=eL[v]??0;if(W===0)return null;const ce=xS(v,.8,g);return f.jsx(be,{content:Gee[v],children:f.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 cursor-help",children:[f.jsx("span",{className:"w-4 h-0.5 shrink-0 rounded-full",style:{backgroundColor:ce}}),f.jsx("span",{className:"text-[10px] text-fg-secondary flex-1",children:j}),f.jsx("span",{className:"text-[10px] text-fg-muted tabular-nums",children:W})]})},v)})})]}),ai&&ft&&f.jsxs("div",{className:"border-b border-edge-subtle",children:[f.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-medium text-sys-green flex items-center gap-1.5",children:[f.jsx(dg,{className:"w-3 h-3"}),"Link Budget",f.jsxs("span",{className:"text-fg-muted ml-auto tabular-nums",children:[ft.analyzedEdges+ft.rssiOnlyEdges,"/",ft.totalEdges]})]}),f.jsxs("div",{className:"px-3 pb-2 space-y-0.5",children:[(()=>{const v=G&&G>1e5?G/1e6:G||915,j=Jn??Ce??12,W=zi??(ne&&ne>1e3?ne/1e3:ne||125),ce=ii??rt??5,oe=Es??At??22,Ze=kv(j,W,ce),fe=vn??Ze,Ee=kI(W*1e3),ji=On??Ee,nn=(et==null?void 0:et.filter(ye=>ye.isTraceEstimated).length)??0,ns=(et==null?void 0:et.filter(ye=>ye.isZeroHop).length)??0,ss=Es!=null||Jn!=null||zi!=null||ii!=null||vn!=null,Ut="w-10 px-1 py-0 text-[10px] text-right tabular-nums bg-subtle-fill border border-edge-subtle rounded text-fg-secondary focus:outline-none focus:border-sys-blue";return f.jsxs("div",{className:"pb-1 mb-1 border-b border-edge-subtle space-y-0.5",children:[f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx("span",{className:"text-fg-muted",children:"Frequency"}),f.jsxs("span",{className:"text-fg-secondary tabular-nums",children:[v.toFixed(3)," MHz"]})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px] gap-1",children:[f.jsx("span",{className:"text-fg-muted",children:"SF"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("select",{value:j,onChange:ye=>{const Yt=parseInt(ye.target.value,10);Cs(Yt===(Ce??12)?null:Yt)},className:Ut+" w-12 appearance-none",children:[7,8,9,10,11,12].map(ye=>f.jsxs("option",{value:ye,children:["SF",ye]},ye))}),Jn!=null&&f.jsx("button",{onClick:()=>Cs(null),className:"text-[8px] text-sys-blue hover:underline",title:"Reset",children:"↺"})]})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px] gap-1",children:[f.jsx("span",{className:"text-fg-muted",children:"BW"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("select",{value:W,onChange:ye=>{const Yt=parseFloat(ye.target.value),sc=ne&&ne>1e3?ne/1e3:ne||125;Ei(Yt===sc?null:Yt)},className:Ut+" w-14 appearance-none",children:[62.5,125,250,500].map(ye=>f.jsxs("option",{value:ye,children:[ye," kHz"]},ye))}),zi!=null&&f.jsx("button",{onClick:()=>Ei(null),className:"text-[8px] text-sys-blue hover:underline",title:"Reset",children:"↺"})]})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px] gap-1",children:[f.jsx("span",{className:"text-fg-muted",children:"CR"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("select",{value:ce,onChange:ye=>{const Yt=parseInt(ye.target.value,10);bn(Yt===(rt??5)?null:Yt)},className:Ut+" w-12 appearance-none",children:[5,6,7,8].map(ye=>f.jsxs("option",{value:ye,children:["4/",ye]},ye))}),ii!=null&&f.jsx("button",{onClick:()=>bn(null),className:"text-[8px] text-sys-blue hover:underline",title:"Reset",children:"↺"})]})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px] gap-1",children:[f.jsx("span",{className:"text-fg-muted",children:"TX Power"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("input",{type:"number",min:1,max:36,step:1,value:oe,onChange:ye=>{const Yt=parseInt(ye.target.value,10);isNaN(Yt)||Qn(Yt)},onBlur:ye=>{const Yt=parseInt(ye.target.value,10);if(isNaN(Yt)){Qn(null);return}Qn(Math.max(1,Math.min(36,Yt)))},className:Ut}),f.jsx("span",{className:"text-fg-muted",children:"dBm"}),Es!=null&&f.jsx("button",{onClick:()=>Qn(null),className:"text-[8px] text-sys-blue hover:underline",title:"Reset",children:"↺"})]})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px] gap-1",children:[f.jsx("span",{className:"text-fg-muted",children:"Sensitivity"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("input",{type:"number",min:-150,max:-80,step:.5,value:Math.round(fe*10)/10,onChange:ye=>{const Yt=parseFloat(ye.target.value);isNaN(Yt)||Ts(Yt)},onBlur:ye=>{const Yt=parseFloat(ye.target.value);if(isNaN(Yt)){Ts(null);return}Ts(Math.max(-150,Math.min(-80,Yt)))},className:Ut+" w-12"}),f.jsx("span",{className:"text-fg-muted",children:"dBm"}),vn!=null&&f.jsx("button",{onClick:()=>Ts(null),className:"text-[8px] text-sys-blue hover:underline",title:"Reset",children:"↺"})]})]}),nn>0&&f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx("span",{className:"text-fg-muted",children:"Noise Floor"}),f.jsxs("span",{className:`text-fg-secondary tabular-nums ${On!=null?"":"italic text-fg-muted"}`,children:[ji.toFixed(1)," dBm",On!=null?"":" (est.)"]})]}),ss&&f.jsx("button",{onClick:()=>{Qn(null),Cs(null),Ei(null),bn(null),Ts(null)},className:"w-full text-[9px] text-sys-blue hover:underline text-center pt-0.5",children:"Reset all to radio config"}),(ns>0||nn>0)&&f.jsxs("div",{className:"flex items-center justify-between text-[10px] pt-0.5",children:[f.jsx("span",{className:"text-fg-muted",children:"Sources"}),f.jsxs("span",{className:"text-fg-secondary tabular-nums",children:[ns>0&&f.jsxs("span",{children:[ns," direct"]}),ns>0&&nn>0&&f.jsx("span",{className:"text-fg-muted",children:" · "}),nn>0&&f.jsxs("span",{className:"text-sys-indigo",children:[nn," trace"]})]})]})]})})(),ft.avgMarginDb!=null&&f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx("span",{className:"text-fg-muted",children:"Avg Margin"}),f.jsxs("span",{className:"text-fg-secondary tabular-nums",children:[ft.avgMarginDb>0?"+":"",ft.avgMarginDb.toFixed(1)," dB"]})]}),["excellent","good","fair","marginal","critical"].map(v=>{const j=ft.marginCounts[v];return j===0?null:f.jsxs("div",{className:"flex items-center gap-2 px-1 py-0.5",children:[f.jsx("span",{className:"w-3 h-0.5 shrink-0 rounded-full",style:{backgroundColor:Av[v]}}),f.jsx("span",{className:"text-[10px] text-fg-secondary flex-1 capitalize",children:v}),f.jsx("span",{className:"text-[10px] text-fg-muted tabular-nums",children:j})]},v)}),ft.anomalousCount>0&&f.jsxs("div",{className:"flex items-center justify-between text-[10px] pt-0.5",children:[f.jsx("span",{className:"text-status-warning",children:"Anomalous"}),f.jsx("span",{className:"text-status-warning tabular-nums",children:ft.anomalousCount})]})]})]}),$i&&$i.atRiskPaths.length>0&&f.jsxs("div",{className:"border-b border-edge-subtle",children:[f.jsxs("div",{className:"flex items-center",children:[f.jsxs("button",{onClick:()=>Te(v=>!v),className:"flex-1 flex items-center gap-1.5 px-3 py-1.5 text-[10px] font-medium text-status-warning hover-bg transition-base",children:[re?f.jsx(Rc,{className:"w-3 h-3"}):f.jsx(Hp,{className:"w-3 h-3"}),"At-Risk Paths",f.jsxs("span",{className:"text-fg-muted ml-auto tabular-nums",children:[$i.criticalCount>0&&f.jsxs("span",{className:"text-status-danger",children:[$i.criticalCount,"c"]}),$i.criticalCount>0&&$i.highCount>0&&" ",$i.highCount>0&&f.jsxs("span",{className:"text-status-warning",children:[$i.highCount,"h"]}),($i.criticalCount>0||$i.highCount>0)&&$i.moderateCount>0&&" ",$i.moderateCount>0&&f.jsxs("span",{className:"text-fg-muted",children:[$i.moderateCount,"m"]})]})]}),f.jsx(be,{content:f.jsxs("div",{className:"max-w-xs space-y-1.5",children:[f.jsx("div",{className:"font-semibold text-fg-primary",children:"Predictive Path Failure"}),f.jsx("div",{className:"text-fg-secondary text-[11px]",children:"Identifies paths at risk of failure by combining four weighted factors. Paths below the moderate threshold (35%) are not shown."}),f.jsxs("div",{className:"pt-1 border-t border-edge-subtle/30 space-y-0.5 text-[10px]",children:[f.jsx("div",{className:"text-fg-muted font-medium",children:"Factor weights"}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-secondary",children:"Declining usage"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"35%"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-secondary",children:"Weak link certainty"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"30%"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-secondary",children:"No alternate paths"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"20%"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-secondary",children:"Low signal margin"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"15%"})]})]}),f.jsxs("div",{className:"pt-1 border-t border-edge-subtle/30 space-y-0.5 text-[10px]",children:[f.jsx("div",{className:"text-fg-muted font-medium",children:"Risk thresholds"}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-status-danger",children:"Critical"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"≥75% — failure likely imminent"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-status-warning",children:"High"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"55-74% — significant risk"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Moderate"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"35-54% — worth monitoring"})]})]}),f.jsxs("div",{className:"pt-1 border-t border-edge-subtle/30 text-[10px] text-fg-muted font-mono space-y-0.5",children:[f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{children:"Edges analyzed"}),f.jsx("span",{className:"tabular-nums",children:$i.edgesAnalyzed})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{children:"With signal data"}),f.jsx("span",{className:"tabular-nums",children:$i.edgesWithSignal})]})]})]}),children:f.jsx("span",{className:"px-2 py-1.5 text-fg-muted cursor-help",children:f.jsx(hd,{className:"w-3 h-3"})})})]}),re&&f.jsx("div",{className:"px-2 pb-2 space-y-1",children:$i.atRiskPaths.slice(0,8).map(v=>{const j=v.riskLevel==="critical"?"#EF4444":v.riskLevel==="high"?"#F97316":"#FBBF24",W=v.urgency==="imminent"?"IMM":v.urgency==="near-term"?"NEAR":"WATCH";return f.jsx(be,{content:f.jsxs("div",{className:"max-w-xs space-y-1.5",children:[f.jsx("div",{className:"font-semibold text-fg-primary font-mono text-[11px]",children:v.hops.join(" → ")}),f.jsxs("div",{className:"space-y-0.5 text-[10px]",children:[f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Risk score"}),f.jsxs("span",{className:"font-semibold tabular-nums",style:{color:j},children:[(v.riskScore*100).toFixed(1),"%"]})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Health score"}),f.jsxs("span",{className:"text-fg-primary tabular-nums",children:[(v.healthScore*100).toFixed(0),"%"]})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Obs. trend"}),f.jsxs("span",{className:`tabular-nums ${v.observationTrend<0?"text-status-danger":"text-fg-secondary"}`,children:[v.observationTrend>0?"+":"",v.observationTrend.toFixed(3)]})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Alt. paths"}),f.jsx("span",{className:`tabular-nums ${v.alternatePathsCount===0?"text-status-danger":"text-fg-secondary"}`,children:v.alternatePathsCount})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Urgency"}),f.jsx("span",{className:"capitalize",style:{color:j},children:v.urgency})]})]}),v.factors.length>0&&f.jsxs("div",{className:"pt-1 border-t border-edge-subtle/30 space-y-0.5 text-[10px]",children:[f.jsx("div",{className:"text-fg-muted font-medium",children:"Contributing factors"}),v.factors.map((ce,oe)=>f.jsxs("div",{className:"space-y-0.5",children:[f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-secondary",children:ce.name}),f.jsxs("span",{className:"text-fg-muted tabular-nums",children:[(ce.score*ce.weight*100).toFixed(1),"% (",(ce.weight*100).toFixed(0),"w × ",(ce.score*100).toFixed(0),"s)"]})]}),f.jsx("div",{className:"text-fg-muted pl-1",children:ce.description})]},oe))]})]}),children:f.jsxs("div",{className:"px-2 py-1 radius-badge bg-subtle-fill/30 cursor-help",children:[f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{backgroundColor:j}}),f.jsx("span",{className:"text-[10px] text-fg-secondary font-mono truncate flex-1",children:v.hops.join(" → ")}),f.jsx("span",{className:"text-[8px] uppercase tracking-wide px-1 py-px radius-badge",style:{backgroundColor:`${j}20`,color:j},children:W}),f.jsxs("span",{className:"text-[10px] tabular-nums font-semibold",style:{color:j},children:[(v.riskScore*100).toFixed(0),"%"]})]}),f.jsx("div",{className:"flex flex-wrap gap-1 mt-0.5 pl-3",children:v.factors.map((ce,oe)=>f.jsxs("span",{className:"text-[8px] text-fg-muted",children:[ce.name," (",(ce.score*ce.weight*100).toFixed(0),"%)",oeVt(v=>v==="spectral"?"louvain":"spectral"),className:"text-sys-blue hover:underline cursor-pointer",children:it==="spectral"?"Spectral":"Louvain"})]}),it==="louvain"&&ud&&f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx(be,{content:"Louvain modularity score — quality of community partition (higher = better defined communities)",children:f.jsx("span",{className:"text-fg-muted cursor-help",children:"Modularity Q"})}),f.jsx("span",{className:"text-fg-secondary tabular-nums",children:ud.modularity.toFixed(4)})]}),it==="louvain"&&f.jsxs("div",{className:"mt-1.5 pt-1.5 border-t border-edge-subtle space-y-1.5",children:[f.jsx(fi,{label:"Resolution γ",value:me,onChange:nt,min:.01,max:5,step:.01}),f.jsx(fi,{label:"K-weight",value:ui,onChange:_i,min:.01,max:5,step:.01}),(me!==1||ui!==1)&&f.jsx("button",{onClick:()=>{nt(1),_i(1)},className:"w-full text-[10px] text-sys-blue hover:underline text-center",children:"Reset defaults"})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx(be,{content:"Redundant path cycles in the topology — indicates alternate routing options",children:f.jsx("span",{className:"text-fg-muted cursor-help",children:"Loops"})}),f.jsx("span",{className:"text-fg-secondary tabular-nums",children:((o0=a==null?void 0:a.loops)==null?void 0:o0.length)??0})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx(be,{content:"High-betweenness edges that carry disproportionate traffic flow",children:f.jsx("span",{className:"text-fg-muted cursor-help",children:"Backbone"})}),f.jsx("span",{className:"text-fg-secondary tabular-nums",children:((a0=a==null?void 0:a.backboneEdges)==null?void 0:a0.length)??0})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx(be,{content:"Unresolved prefix nodes inferred by Viterbi HMM from repeated path patterns",children:f.jsx("span",{className:"text-fg-muted cursor-help",children:"Ghosts"})}),f.jsx("span",{className:"text-fg-secondary tabular-nums",children:u.length})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx(be,{content:"Community-aware node coloring — groups nodes by cluster assignment",children:f.jsx("span",{className:"text-fg-muted cursor-help",children:"Clustering"})}),f.jsx("span",{className:`tabular-nums ${We?"text-sys-blue":"text-fg-muted"}`,children:We?"On":"Off"})]}),So!=null&&f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx(be,{content:"Algebraic connectivity — 2nd-smallest eigenvalue of the graph Laplacian. Near-zero = one bridge from network partition.",children:f.jsx("span",{className:"text-fg-muted cursor-help",children:"Fiedler λ₂"})}),f.jsx("span",{className:`tabular-nums ${So<.01?"text-status-warning":"text-fg-secondary"}`,children:So.toFixed(4)})]}),Pe.size>0&&f.jsxs("button",{onClick:()=>q(new Set),className:"w-full mt-1 text-[10px] text-sys-blue hover:underline text-center",children:["Clear filters (",Pe.size,")"]})]})]}),Wv=f.jsx(Qc,{children:J&&f.jsx(Sl.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.15},className:"absolute top-4 left-1/2 -translate-x-1/2 z-30 w-80",children:f.jsxs("div",{className:"surface-elevated radius-inset shadow-2xl overflow-hidden",children:[f.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 border-b border-edge-subtle",children:[f.jsx(_0,{className:"w-4 h-4 text-fg-muted shrink-0"}),f.jsx("input",{ref:Js,type:"text",value:se,onChange:v=>R(v.target.value),placeholder:"Search by name or prefix...",className:"flex-1 bg-transparent text-sm text-fg-primary placeholder:text-fg-muted focus:outline-none",onKeyDown:v=>{v.key==="Escape"?(F(!1),R("")):v.key==="Enter"&&ic.length>0&&Nv(ic[0])}}),se&&f.jsx("button",{onClick:()=>R(""),className:"p-0.5 radius-badge hover-bg transition-base",children:f.jsx($u,{className:"w-3 h-3 text-fg-muted"})})]}),ic.length>0&&f.jsx("div",{className:"max-h-64 overflow-y-auto",children:ic.map((v,j)=>f.jsxs("button",{onClick:()=>Nv(v),className:`w-full flex items-center gap-3 px-3 py-2 text-left hover-bg transition-base ${j===0?"bg-subtle-fill/50":""}`,children:[f.jsx("span",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{backgroundColor:_[v.nodeClass]}}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("div",{className:"text-sm text-fg-primary truncate",children:v.name||v.prefix}),v.name&&f.jsx("div",{className:"text-[10px] text-fg-muted",children:v.prefix})]}),f.jsx(VL,{className:"w-3 h-3 text-fg-muted shrink-0"})]},v.id))}),se&&ic.length===0&&f.jsx("div",{className:"px-3 py-4 text-center text-sm text-fg-muted",children:"No nodes found"}),!se&&f.jsx("div",{className:"px-3 py-2 type-data-xs text-fg-muted",children:"Type to search • Enter to select • Esc to close"})]})})});return e?tn.length===0?f.jsxs("div",{className:"relative h-[calc(100dvh-56px)] lg:h-dvh min-h-[500px] -mx-4 sm:-mx-6 lg:-mx-8 -mt-5 -mb-4 sm:-mb-6 lg:-mb-8 overflow-hidden",children:[dd,f.jsx("div",{className:"absolute inset-0 bg-body flex items-center justify-center",children:f.jsx(qee,{})})]}):Mr?M?f.jsxs("div",{className:"fixed inset-0 z-50 bg-body flex flex-col overflow-hidden",children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 surface-header z-10",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx(c0,{className:"w-5 h-5 text-icon-page-title"}),f.jsxs("h1",{className:"type-title text-fg-primary flex items-center gap-2",children:["MeshGraph",f.jsx(Di,{color:"violet",compact:!0,children:"Analytics"})]}),f.jsxs("span",{className:"text-[10px] text-fg-muted tabular-nums",children:[Bt.length," nodes • ",Ui.length," edges"]})]}),f.jsx(be,{content:"Exit fullscreen",children:f.jsx("button",{onClick:Dv,className:"p-1.5 radius-inner hover-bg transition-base",children:f.jsx(f0,{className:"w-4 h-4 text-fg-muted"})})})]}),f.jsxs("div",{className:"flex-1 relative min-h-0 m-2 surface-base radius-inset overflow-hidden border border-edge-subtle",children:[f.jsx(uS,{className:"absolute inset-0",points:Mr,links:ts,...Bn,...ut,backgroundColor:C,fitViewOnInit:!0,fitViewPadding:Ne.fitViewPadding,showLabels:Z,showDynamicLabels:!1,showTopLabels:Z,showTopLabelsLimit:200,showHoveredPointLabel:!0,pointLabelColor:x,pointClusterBy:We?"communityId":void 0,onPolygonSelected:Zn?Mv:void 0,polygonalSelectorStrokeColor:g?"#FBBF24":"#D97706",onClick:Pv,onLinkClick:Rv,onMount:Iv,hoveredPointRingColor:g?"#FBBF24":"#D97706",hoveredPointCursor:"pointer",hoveredLinkCursor:"pointer"}),Wv,Gv,$v,jv,Hv,Vv,f.jsxs(Qc,{children:[B&&f.jsx(SS,{node:B,egoMetrics:Bv,onExpandEgo:Uv,neighbors:zv,onSelectNeighbor:cd,txDelayRec:Fv,onClose:()=>{var v;H(null),(v=Rt.current)==null||v.unselectAllPoints()}}),Q&&!B&&f.jsx(wS,{edge:Q,onClose:()=>te(null)}),Zs&&!B&&!Q&&f.jsx(ES,{metrics:Zs,onClose:Ov})]})]})]}):f.jsxs("div",{className:"relative h-[calc(100dvh-56px)] lg:h-dvh min-h-[500px] -mx-4 sm:-mx-6 lg:-mx-8 -mt-5 -mb-4 sm:-mb-6 lg:-mb-8 overflow-hidden",children:[dd,f.jsxs("div",{className:"absolute inset-0",children:[f.jsx(uS,{className:"absolute inset-0",points:Mr,links:ts,...Bn,...ut,backgroundColor:C,fitViewOnInit:!0,fitViewPadding:Ne.fitViewPadding,showLabels:Z,showDynamicLabels:!1,showTopLabels:Z,showTopLabelsLimit:200,showHoveredPointLabel:!0,pointLabelColor:x,pointClusterBy:We?"communityId":void 0,onPolygonSelected:Zn?Mv:void 0,polygonalSelectorStrokeColor:g?"#FBBF24":"#D97706",onClick:Pv,onLinkClick:Rv,onMount:Iv,hoveredPointRingColor:g?"#FBBF24":"#D97706",hoveredPointCursor:"pointer",hoveredLinkCursor:"pointer"}),Wv,Gv,$v,jv,Hv,Vv,f.jsxs("div",{className:"absolute bottom-4 right-4 z-10 hidden lg:flex items-center gap-3 type-data-xs text-fg-muted/60",children:[f.jsxs("span",{children:[f.jsx("kbd",{className:"px-1 py-0.5 radius-badge bg-subtle-fill/50 font-mono",children:"/"})," Search"]}),f.jsxs("span",{children:[f.jsx("kbd",{className:"px-1 py-0.5 radius-badge bg-subtle-fill/50 font-mono",children:"F"})," Fit"]}),f.jsxs("span",{children:[f.jsx("kbd",{className:"px-1 py-0.5 radius-badge bg-subtle-fill/50 font-mono",children:"L"})," Labels"]}),f.jsxs("span",{children:[f.jsx("kbd",{className:"px-1 py-0.5 radius-badge bg-subtle-fill/50 font-mono",children:"Space"})," Pause"]}),f.jsxs("span",{children:[f.jsx("kbd",{className:"px-1 py-0.5 radius-badge bg-subtle-fill/50 font-mono",children:"Esc"})," Clear"]})]}),f.jsxs(Qc,{children:[B&&f.jsx(SS,{node:B,egoMetrics:Bv,onExpandEgo:Uv,neighbors:zv,onSelectNeighbor:cd,txDelayRec:Fv,onClose:()=>{var v;H(null),(v=Rt.current)==null||v.unselectAllPoints()}}),Q&&!B&&f.jsx(wS,{edge:Q,onClose:()=>te(null)}),Zs&&!B&&!Q&&f.jsx(ES,{metrics:Zs,onClose:Ov})]})]})]}):f.jsxs("div",{className:"relative h-[calc(100dvh-56px)] lg:h-dvh min-h-[500px] -mx-4 sm:-mx-6 lg:-mx-8 -mt-5 -mb-4 sm:-mb-6 lg:-mb-8 overflow-hidden",children:[dd,f.jsxs("div",{className:"absolute inset-0 bg-body flex flex-col items-center justify-center gap-3",children:[f.jsx(u0,{className:"w-8 h-8 text-sys-blue animate-spin"}),f.jsx("span",{className:"type-body text-fg-muted",children:"Preparing graph..."})]})]}):f.jsxs("div",{className:"relative h-[calc(100dvh-56px)] lg:h-dvh min-h-[500px] -mx-4 sm:-mx-6 lg:-mx-8 -mt-5 -mb-4 sm:-mb-6 lg:-mb-8 overflow-hidden",children:[dd,f.jsxs("div",{className:"absolute inset-0 bg-body flex items-center justify-center",children:[f.jsx(NL,{isOpen:n,onClose:o}),!n&&f.jsx(u0,{className:"w-8 h-8 text-sys-blue animate-spin"})]})]})}const fie=Object.freeze(Object.defineProperty({__proto__:null,default:Xee},Symbol.toStringTag,{value:"Module"}));export{ge as $,le as B,cy as D,TN as H,oy as I,NP as J,SN as K,fie as M,bg as N,Jc as T,Vu as U,Xh as a,_n as b,_te as c,qP as d,ct as e,pte as f,YP as h,yN as j,mte as l,fte as o,dte as r,hte as s,yte as u}; +`)}function GJ(i,e,t){const n={meta:{exportedAt:new Date().toISOString(),pymcConsoleVersion:CS,nodeCount:i.nodeMetrics.size,edgeCount:i.validatedEdges.length,communityCount:i.communityCount,loopCount:i.loops.length,backboneEdgeCount:i.backboneEdges.length,hubNodes:i.hubNodes.length,gatewayNodes:i.gatewayNodes.length,mobileNodes:i.mobileNodes.length,ghostNodes:i.discoveredNodes.filter(s=>s.isLikelyReal).length},nodes:NJ(i,e),edges:BJ(i,t),pathHealth:i.pathHealth.map(s=>({pathKey:s.pathKey,hops:s.hops,healthScore:s.healthScore,weakestLinkKey:s.weakestLinkKey,weakestLinkConfidence:s.weakestLinkConfidence,avgEdgeCertainty:s.avgEdgeCertainty,observationTrend:s.observationTrend,alternatePathsCount:s.alternatePathsCount,estimatedLatencyMs:s.estimatedLatencyMs,observationCount:s.observationCount,routeType:s.routeType,lastSeen:s.lastSeen,involvesHub:s.involvesHub})),txDelayRecommendations:Array.from(i.txDelayRecommendations.entries()).map(([s,r])=>{var o,a;return{nodeHash:s,nodePrefix:((o=i.nodeMetrics.get(s))==null?void 0:o.prefix)??"",nodeName:((a=i.nodeMetrics.get(s))==null?void 0:a.name)??null,networkRole:r.networkRole,floodFactor:r.floodFactor,directFactor:r.directFactor,floodSlots:r.floodSlots,directSlots:r.directSlots,trafficIntensity:r.trafficIntensity,collisionRisk:r.collisionRisk,confidence:r.confidence,adjustment:r.adjustment,dataConfidence:r.dataConfidence,rationale:r.rationale}}),loops:i.loops.map(s=>({id:s.id,nodes:s.nodes,edgeKeys:s.edgeKeys,size:s.size,avgCertainCount:s.avgCertainCount,minCertainCount:s.minCertainCount,includesLocal:s.includesLocal,strength:s.strength})),disambiguationStats:{totalPrefixes:i.disambiguationStats.totalPrefixes,unambiguousPrefixes:i.disambiguationStats.unambiguousPrefixes,collisionPrefixes:i.disambiguationStats.collisionPrefixes,collisionRate:i.disambiguationStats.collisionRate,avgConfidence:i.disambiguationStats.avgConfidence},viterbiStats:{totalPaths:i.viterbiStats.totalPaths,pathsWithGhosts:i.viterbiStats.pathsWithGhosts,avgPathConfidence:i.viterbiStats.avgPathConfidence,tracePacketsProcessed:i.viterbiStats.tracePacketsProcessed,pathPacketsProcessed:i.viterbiStats.pathPacketsProcessed,distantEdgesDiscovered:i.viterbiStats.distantEdgesDiscovered,duplicateGroupsFound:i.viterbiStats.duplicateGroupsFound,echolocationEdgesInferred:i.viterbiStats.echolocationEdgesInferred}};return JSON.stringify(n,null,2)}function WJ(i,e){const t=e.includeGhosts??!0,n=e.includeWeakEdges??!1;switch(e.format){case"csv":{let s,r;switch(e.dataset){case"nodes":s=dS(i,t),r="mesh-nodes";break;case"edges":s=OJ(i,n),r="mesh-edges";break;case"pathHealth":s=UJ(i),r="mesh-path-health";break;case"txDelay":s=HJ(i),r="mesh-tx-delay";break;case"full":default:s=dS(i,t),r="mesh-nodes";break}return{content:s,filename:ag(r,"csv"),mimeType:"text/csv"}}case"gexf":return{content:VJ(i,t),filename:ag("mesh-topology","gexf"),mimeType:"application/xml"};case"json":default:return{content:GJ(i,t,n),filename:ag("mesh-topology","json"),mimeType:"application/json"}}}function YJ(i){const e=new Blob([i.content],{type:i.mimeType}),t=URL.createObjectURL(e),n=document.createElement("a");n.href=t,n.download=i.filename,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}function qJ(i,e){const t=WJ(i,e);YJ(t)}const XJ=1e-7,KJ=10;function ZJ(i,e,t=1){const n=e.length,s=new Map;for(let l=0;l[]),o=new Array(n).fill(0);let a=0;for(const l of i){const c=s.get(l.fromHash),u=s.get(l.toHash);if(c===void 0||u===void 0||c===u)continue;const d=Math.max(.01,(l.certainCount+1)*l.avgConfidence*l.strength),h=t===1?d:Math.pow(d,t);r[c].push({j:u,w:h}),r[u].push({j:c,w:h}),o[c]+=h,o[u]+=h,a+=h}return{graph:{n,adjList:r,totalWeight:a,degree:o},hashToIdx:s}}function QJ(i,e,t=1){const{n,adjList:s,totalWeight:r,degree:o}=i;if(r===0)return!1;const a=2*r,l=new Float64Array(n);for(let d=0;dC+XJ&&(C=B,S=x)}S!==h&&(l[h]-=p,l[S]+=p,e[d]=S,u=!0,c=!0)}}return c}function JJ(i,e){const{n:t,adjList:n}=i,s=new Set;for(let p=0;pp-m),o=new Map;for(let p=0;p[]);for(const[p,m]of c){const[y,g]=p.split("-").map(Number),_=m/2;h[y].push({j:g,w:_}),h[g].push({j:y,w:_}),u[y]+=_,u[g]+=_,d+=_}return{newGraph:{n:a,adjList:h,totalWeight:d,degree:Array.from(u)},mapping:l}}function eee(i,e,t=1){const{n,adjList:s,totalWeight:r,degree:o}=i;if(r===0)return 0;const a=2*r;let l=0;for(let c=0;c=a.n)break;a=C,l=new Int32Array(C.n);for(let A=0;AS-C),m=new Map;for(let S=0;S=th.EXCELLENT?"excellent":i>=th.GOOD?"good":i>=th.FAIR?"fair":i>=th.MARGINAL?"marginal":"critical"}function II(i){return i>=ih.ANOMALOUS_GOOD?"anomalous-good":i>=ih.BETTER?"better":i>=ih.EXPECTED_LOWER?"expected":i>=ih.WORSE?"worse":"anomalous-bad"}function oee(i,e,t,n,s){const r=n.tx_power??22,o=n.spreading_factor??12,a=n.coding_rate??5,l=n.frequency??0,c=l>1e5?l/1e6:l||SI,u=n.bandwidth??0,d=u>1e3?u/1e3:u||125,h=(s==null?void 0:s.sensitivityOverrideDbm)??kv(o,d,a);let p=null,m=null;e&&t&&Uh(e.latitude??void 0,e.longitude??void 0)&&Uh(t.latitude??void 0,t.longitude??void 0)&&(p=TS(e.latitude,e.longitude,t.latitude,t.longitude),m=p/1e3);let y=null,g=null;p!=null&&p>0&&(y=TI(p,c),g=r+EI+CI-y);const _=i.avgRssi??null,S=i.avgSnr??null;let C=null,x=null;_!=null&&g!=null&&(C=_-g,x=II(C));let A=null,L=null;_!=null&&(A=_-h,L=AI(A));const B=_!=null,H=x==="anomalous-good"||x==="anomalous-bad";return{edgeKey:i.key,fromHash:i.fromHash,toHash:i.toHash,distanceM:p,distanceKm:m,fsplDb:y,theoreticalRxPowerDbm:g,observedRssiDbm:_,observedSnrDb:S,deviationDb:C,deviationClass:x,marginDb:A,marginClass:L,sensitivityDbm:h,txPowerDbm:r,frequencyMhz:c,spreadingFactor:o,bandwidthKhz:d,noiseFloorDbm:null,isZeroHop:i.isZeroHop??!1,isTraceEstimated:!1,hasData:B,isAnomalous:H}}function aee(i,e,t,n,s=22,r){var te,M;const o=i.traceQuality;if(!o)return null;let a=null;if(o.forward!=null&&o.reverse!=null?a=Math.min(o.forward.mean,o.reverse.mean):a=((te=o.forward)==null?void 0:te.mean)??((M=o.reverse)==null?void 0:M.mean)??null,a==null)return null;const l=n.spreading_factor??12,c=n.coding_rate??5,u=n.bandwidth??0,d=u>1e3?u/1e3:u||125,h=d*1e3,p=n.frequency??0,m=p>1e5?p/1e6:p||SI,y=(r==null?void 0:r.sensitivityOverrideDbm)??kv(l,d,c),g=(r==null?void 0:r.observedNoiseFloorDbm)??kI(h),_=g+a;let S=null,C=null;e&&t&&Uh(e.latitude??void 0,e.longitude??void 0)&&Uh(t.latitude??void 0,t.longitude??void 0)&&(S=TS(e.latitude,e.longitude,t.latitude,t.longitude),C=S/1e3);let x=null,A=null;S!=null&&S>0&&(x=TI(S,m),A=s+EI+CI-x);let L=null,B=null;A!=null&&(L=_-A,B=II(L));const H=_-y,Q=AI(H);return{edgeKey:i.key,fromHash:i.fromHash,toHash:i.toHash,distanceM:S,distanceKm:C,fsplDb:x,theoreticalRxPowerDbm:A,observedRssiDbm:_,observedSnrDb:a,deviationDb:L,deviationClass:B,marginDb:H,marginClass:Q,sensitivityDbm:y,noiseFloorDbm:g,txPowerDbm:s,frequencyMhz:m,spreadingFactor:l,bandwidthKhz:d,isZeroHop:!1,isTraceEstimated:!0,hasData:!0,isAnomalous:B==="anomalous-good"||B==="anomalous-bad"}}function lee(i,e,t){const n=[],s=i.nodeMetrics,r=new Set,o=e.tx_power??22;for(const a of i.edges){if(!a.isZeroHop)continue;const l=s.get(a.fromHash),c=s.get(a.toHash);n.push(oee(a,l,c,e,t)),r.add(a.key)}for(const a of i.edges){if(r.has(a.key)||!a.traceQuality)continue;const l=s.get(a.fromHash),c=s.get(a.toHash),u=aee(a,l,c,e,o,t);u&&(n.push(u),r.add(a.key))}return n}function cee(i){const e={"anomalous-good":0,better:0,expected:0,worse:0,"anomalous-bad":0},t={excellent:0,good:0,fair:0,marginal:0,critical:0};let n=0,s=0,r=null,o=null,a=0,l=0;for(const c of i)c.hasData&&(c.marginDb!=null&&(n+=c.marginDb,s++,(!r||c.marginDb<(r.marginDb??1/0))&&(r=c),(!o||c.marginDb>(o.marginDb??-1/0))&&(o=c)),c.marginClass&&t[c.marginClass]++,c.deviationDb!=null&&c.deviationClass?(e[c.deviationClass]++,l++):a++);return{totalEdges:i.length,analyzedEdges:l,rssiOnlyEdges:a,avgMarginDb:s>0?n/s:null,worstMargin:r,bestMargin:o,deviationCounts:e,marginCounts:t,anomalousCount:e["anomalous-good"]+e["anomalous-bad"]}}const uee={"anomalous-good":"#2DD4BF",better:"#34D399",expected:"#9CA3AF",worse:"#FB923C","anomalous-bad":"#EF4444"},Av={excellent:"#34D399",good:"#A3E635",fair:"#FBBF24",marginal:"#FB923C",critical:"#EF4444"};function dee(i,e="margin"){return i.hasData?e==="deviation"?i.deviationClass?uee[i.deviationClass]:"#505058":i.marginClass?Av[i.marginClass]:"#505058":"#505058"}function hee(i,e=.5,t=4){if(i.marginDb==null)return e;const n=Math.max(0,Math.min(1,i.marginDb/40));return e+n*(t-e)}const fee=.15,pee=200;let mee=0;function Ns(){return`ta-${++mee}-${Date.now()}`}function gee(i){var c,u;const e=new Set;for(const d of i.edges)e.add(d.key);const t=new Map,n=new Map,s=new Map,r=new Set;for(const[d,h]of i.nodeMetrics)t.set(d,h.betweenness),n.set(d,h.communityId),s.set(d,h.nodeClass),r.add(d);const o=new Set;for(const d of i.discoveredNodes)d.isLikelyReal&&o.add(d.prefix);const a=new Map,l=new Map;for(const d of i.edges)(c=d.traceQuality)!=null&&c.composite&&a.set(d.key,d.traceQuality.composite.mean),((u=d.traceQuality)==null?void 0:u.asymmetryDb)!=null&&l.set(d.key,d.traceQuality.asymmetryDb);return{timestamp:Date.now(),edgeKeys:e,betweenness:t,communities:n,nodeClasses:s,ghostPrefixes:o,nodeHashes:r,traceSnr:a,traceAsymmetry:l}}function _ee(i,e,t){const n=Date.now(),s=[],r=h=>(t==null?void 0:t.get(h))??null;for(const h of e.edgeKeys)if(!i.edgeKeys.has(h)){const[p,m]=h.split("-"),y=r(p)??(p==null?void 0:p.slice(0,6)),g=r(m)??(m==null?void 0:m.slice(0,6));s.push({id:Ns(),detectedAt:n,category:"edge-appeared",severity:"info",description:`New edge: ${y} ↔ ${g}`,edgeKey:h})}for(const h of i.edgeKeys)if(!e.edgeKeys.has(h)){const[p,m]=h.split("-"),y=r(p)??(p==null?void 0:p.slice(0,6)),g=r(m)??(m==null?void 0:m.slice(0,6));s.push({id:Ns(),detectedAt:n,category:"edge-disappeared",severity:"warning",description:`Edge lost: ${y} ↔ ${g}`,edgeKey:h})}for(const h of e.nodeHashes)if(!i.nodeHashes.has(h)){const p=r(h);s.push({id:Ns(),detectedAt:n,category:"node-appeared",severity:"info",description:`Node appeared: ${p??h.slice(0,8)}`,nodeHash:h,nodeName:p??void 0})}for(const h of i.nodeHashes)if(!e.nodeHashes.has(h)){const p=r(h);s.push({id:Ns(),detectedAt:n,category:"node-disappeared",severity:"warning",description:`Node dropped: ${p??h.slice(0,8)}`,nodeHash:h,nodeName:p??void 0})}for(const h of e.ghostPrefixes)i.ghostPrefixes.has(h)||s.push({id:Ns(),detectedAt:n,category:"ghost-appeared",severity:"info",description:`Ghost node discovered: ${h.toUpperCase()}`});for(const h of i.ghostPrefixes)e.ghostPrefixes.has(h)||s.push({id:Ns(),detectedAt:n,category:"ghost-disappeared",severity:"info",description:`Ghost node resolved: ${h.toUpperCase()}`});const o=3;for(const[h,p]of e.traceSnr){const m=i.traceSnr.get(h);if(m===void 0)continue;const y=m-p;y>=o&&s.push({id:Ns(),detectedAt:n,category:"snr-degradation",severity:y>=6?"critical":"warning",description:`SNR dropped ${y.toFixed(1)} dB on edge ${h.slice(0,13)}`,edgeKey:h,previousValue:m,currentValue:p})}const a=4;for(const[h,p]of e.traceAsymmetry){const m=i.traceAsymmetry.get(h);if(m===void 0)continue;const y=p-m;y>=a&&s.push({id:Ns(),detectedAt:n,category:"asymmetry-shift",severity:y>=8?"critical":"warning",description:`Asymmetry grew ${y.toFixed(1)} dB on edge ${h.slice(0,13)}`,edgeKey:h,previousValue:m,currentValue:p})}for(const[h,p]of e.betweenness){const m=i.betweenness.get(h);if(m===void 0)continue;const y=Math.abs(p-m);if(y>=fee){const g=r(h),_=p>m?"increased":"decreased";s.push({id:Ns(),detectedAt:n,category:"betweenness-shift",severity:y>=.3?"critical":"warning",description:`${g??h.slice(0,8)} betweenness ${_}: ${m.toFixed(3)} → ${p.toFixed(3)}`,nodeHash:h,nodeName:g??void 0,previousValue:m,currentValue:p})}}for(const[h,p]of e.communities){const m=i.communities.get(h);if(m!==void 0&&p!==m){const y=r(h);s.push({id:Ns(),detectedAt:n,category:"community-change",severity:"info",description:`${y??h.slice(0,8)} moved: community #${m} → #${p}`,nodeHash:h,nodeName:y??void 0,previousValue:m,currentValue:p})}}for(const[h,p]of e.nodeClasses){const m=i.nodeClasses.get(h);if(m!==void 0&&p!==m){const y=r(h),g=pS(p)>pS(m);s.push({id:Ns(),detectedAt:n,category:"class-change",severity:g?"warning":"info",description:`${y??h.slice(0,8)} ${g?"promoted":"changed"}: ${m} → ${p}`,nodeHash:h,nodeName:y??void 0,previousValue:m,currentValue:p})}}const l={},c={},u=["edge-appeared","edge-disappeared","ghost-appeared","ghost-disappeared","betweenness-shift","community-change","class-change","node-appeared","node-disappeared","snr-degradation","asymmetry-shift"],d=["info","warning","critical"];for(const h of u)l[h]=0;for(const h of d)c[h]=0;for(const h of s)l[h.category]++,c[h.severity]++;return s.sort((h,p)=>p.detectedAt-h.detectedAt),{anomalies:s,categoryCounts:l,severityCounts:c,totalCount:s.length,timestamp:n}}function pS(i){return{standard:0,ghost:1,mobile:2,neighbor:3,backbone:4,gateway:5,hub:6,local:7}[i]??0}class yee{constructor(e=pee){b(this,"prevSnapshot",null);b(this,"log",[]);b(this,"maxLog");this.maxLog=e}update(e,t){const n=gee(e);if(!this.prevSnapshot)return this.prevSnapshot=n,{anomalies:[],categoryCounts:xee(),severityCounts:wee(),totalCount:0,timestamp:Date.now()};const s=_ee(this.prevSnapshot,n,t);this.prevSnapshot=n;try{vee(s.anomalies,e)}catch(r){console.warn("[TopologyAnomalyTracker] Enrichment failed, anomalies logged without detail:",r)}return this.log.unshift(...s.anomalies),this.log.length>this.maxLog&&(this.log.length=this.maxLog),s}getLog(){return this.log}getFiltered(e){const t=Date.now();return this.log.filter(n=>!(e.category&&n.category!==e.category||e.severity&&n.severity!==e.severity||e.nodeHash&&n.nodeHash!==e.nodeHash||e.maxAge&&t-n.detectedAt>e.maxAge))}clear(){this.log=[],this.prevSnapshot=null}}function bee(i){return{nodeClass:i.nodeClass,degree:i.degree,betweenness:i.betweenness,activityLevel:i.activityLevel,isZeroHop:i.isZeroHop,avgRssi:i.avgRssi,avgSnr:i.avgSnr,communityId:i.communityId,packetCount:i.packetCount,connectionCount:i.degree}}function vee(i,e){var r,o,a;const t=e.edgeMap,n=e.nodeMetrics,s=new Set(e.backboneEdges??[]);for(const l of i){if(l.edgeKey&&(l.category==="edge-appeared"||l.category==="edge-disappeared")){const c=t==null?void 0:t.get(l.edgeKey),u=l.edgeKey.split("-"),d=u[0],h=u[1],p=d?n==null?void 0:n.get(d):void 0,m=h?n==null?void 0:n.get(h):void 0;c?l.edgeDetail={fromName:(p==null?void 0:p.name)??null,toName:(m==null?void 0:m.name)??null,fromClass:(p==null?void 0:p.nodeClass)??null,toClass:(m==null?void 0:m.nodeClass)??null,packetCount:c.packetCount,confidence:c.avgConfidence,symmetryRatio:c.symmetryRatio,isBackbone:s.has(l.edgeKey),isLoop:c.isLoopEdge??!1,isZeroHop:c.isZeroHop??!1,isDirectPath:c.isDirectPathEdge,avgRssi:c.avgRssi??null,avgSnr:c.avgSnr??null,fromBetweenness:(p==null?void 0:p.betweenness)??null,toBetweenness:(m==null?void 0:m.betweenness)??null,traceCompositeSnr:((o=(r=c.traceQuality)==null?void 0:r.composite)==null?void 0:o.mean)??null,traceAsymmetryDb:((a=c.traceQuality)==null?void 0:a.asymmetryDb)??null}:l.edgeDetail={fromName:(p==null?void 0:p.name)??null,toName:(m==null?void 0:m.name)??null,fromClass:(p==null?void 0:p.nodeClass)??null,toClass:(m==null?void 0:m.nodeClass)??null,packetCount:0,confidence:0,symmetryRatio:0,isBackbone:!1,isLoop:!1,isZeroHop:!1,isDirectPath:!1,avgRssi:null,avgSnr:null,fromBetweenness:(p==null?void 0:p.betweenness)??null,toBetweenness:(m==null?void 0:m.betweenness)??null,traceCompositeSnr:null,traceAsymmetryDb:null}}if(l.nodeHash){const c=n==null?void 0:n.get(l.nodeHash);c&&(l.nodeDetail=bee(c))}}}function xee(){return{"edge-appeared":0,"edge-disappeared":0,"ghost-appeared":0,"ghost-disappeared":0,"betweenness-shift":0,"community-change":0,"class-change":0,"node-appeared":0,"node-disappeared":0,"snr-degradation":0,"asymmetry-shift":0}}function wee(){return{info:0,warning:0,critical:0}}const LI=24,See=3;function Eee(i,e,t,n){var o;const s=[],r=e.replace(/^0x/i,"").slice(0,2).toLowerCase();for(const a of i){if(a.transmitted||a.rssi==null||a.snr==null||a.rssi===0&&a.snr===0)continue;const l=((o=a.src_hash)==null?void 0:o.replace(/^0x/i,""))??"";if(l.slice(0,2).toLowerCase()!==r&&l!==e.replace(/^0x/i,""))continue;const u=a.original_path??a.forwarded_path??[],d=nL(u,n),h=(d==null?void 0:d.effectiveLength)??0,p=a.route??a.route_type;let m=!1;p!=null&&sL(p)?m=h<=1:m=h===0,m&&s.push({timestamp:a.timestamp*1e3,rssi:a.rssi,snr:a.snr})}if(s.sort((a,l)=>a.timestamp-l.timestamp),s.length>0&&s[0].timestamp<4102444800)for(const a of s)a.timestamp*=1e3;return s}function Cee(i,e=LI){if(i.length===0)return[];const t=i[0].timestamp,s=i[i.length-1].timestamp-t;if(s<=0){const l=i.reduce((u,d)=>u+d.rssi,0)/i.length,c=i.reduce((u,d)=>u+d.snr,0)/i.length;return[{timestamp:t,avgRssi:l,avgSnr:c,minRssi:Math.min(...i.map(u=>u.rssi)),maxRssi:Math.max(...i.map(u=>u.rssi)),minSnr:Math.min(...i.map(u=>u.snr)),maxSnr:Math.max(...i.map(u=>u.snr)),count:i.length}]}const r=s/e,o=[];for(let l=0;l0&&(l.avgRssi/=l.count,l.avgSnr/=l.count,a.push(l));return a}function mS(i){if(i.length<2)return 0;const e=i.length;let t=0,n=0,s=0,r=0;for(let a=0;a_.avgRssi)),m=mS(o.map(_=>_.avgSnr)),y=r[0].timestamp,g=r[r.length-1].timestamp;return{buckets:o,totalSamples:r.length,rssiRange:[c,u],snrRange:[d,h],avgRssi:a/r.length,avgSnr:l/r.length,rssiTrend:p,snrTrend:m,timeSpanMs:g-y}}const an={observationTrend:.3,edgeCertainty:.25,redundancy:.15,signalMargin:.15,traceSnrTrend:.15},lg={critical:.75,high:.55,moderate:.35},kee=-137,Aee=5;function Iee(i,e,t){if(i.observationCount.3&&n.push({name:"Weak link certainty",description:i.weakestLinkKey?`Weakest: ${i.weakestLinkConfidence<.3?"very low":"low"} confidence`:`Average certainty: ${(i.avgEdgeCertainty*100).toFixed(0)}%`,score:r,weight:an.edgeCertainty});let o=0;i.alternatePathsCount===0?(o=1,n.push({name:"No alternate paths",description:"Single route to destination — no failover available",score:o,weight:an.redundancy})):i.alternatePathsCount===1&&(o=.5,n.push({name:"Limited redundancy",description:"Only 1 alternate path available",score:o,weight:an.redundancy}));let a=0;if(i.weakestLinkKey){const h=e.get(i.weakestLinkKey),p=(h==null?void 0:h.avgRssi)??null,m=i.weakestLinkTraceSnr;if(p!=null){const y=p-t;y<3?(a=1,n.push({name:"Signal near sensitivity",description:`Weakest link: ${y.toFixed(1)} dB margin (< 3 dB)`,score:a,weight:an.signalMargin})):y<10&&(a=1-(y-3)/7,n.push({name:"Low signal margin",description:`Weakest link: ${y.toFixed(1)} dB margin`,score:a,weight:an.signalMargin}))}else m!=null&&m<5&&(a=m<-5?1:m<0?.7:.4,n.push({name:"Low trace SNR",description:`Weakest link trace SNR: ${m.toFixed(1)} dB`,score:a,weight:an.signalMargin}))}let l=0;if(i.weakestLinkKey){const h=e.get(i.weakestLinkKey),p=h==null?void 0:h.traceQuality;p!=null&&p.composite&&(p.composite.mean<0?(l=.8,n.push({name:"Trace SNR negative",description:`Composite trace SNR: ${p.composite.mean.toFixed(1)} dB (negative)`,score:l,weight:an.traceSnrTrend})):p.composite.stdDev>4?(l=.6,n.push({name:"Unstable trace SNR",description:`High variance: σ=${p.composite.stdDev.toFixed(1)} dB`,score:l,weight:an.traceSnrTrend})):p.asymmetryDb!=null&&p.asymmetryDb>8&&(l=.5,n.push({name:"High SNR asymmetry",description:`Bidirectional asymmetry: ${p.asymmetryDb.toFixed(1)} dB`,score:l,weight:an.traceSnrTrend})))}const c=s*an.observationTrend+r*an.edgeCertainty+o*an.redundancy+a*an.signalMargin+l*an.traceSnrTrend;if(c=lg.critical?(u="critical",d="imminent"):c>=lg.high?(u="high",d="near-term"):(u="moderate",d="watch"),{pathKey:i.pathKey,hops:i.hops,riskScore:Math.round(c*100)/100,riskLevel:u,factors:n,weakestEdgeKey:i.weakestLinkKey,healthScore:i.healthScore,observationTrend:i.observationTrend,alternatePathsCount:i.alternatePathsCount,urgency:d}}function Lee(i,e,t=kee){const n=new Map;for(const o of e)n.set(o.key,o);const s=e.filter(o=>o.avgRssi!=null).length,r=[];for(const o of i){const a=Iee(o,n,t);a&&r.push(a)}return r.sort((o,a)=>a.riskScore-o.riskScore),{atRiskPaths:r,criticalCount:r.filter(o=>o.riskLevel==="critical").length,highCount:r.filter(o=>o.riskLevel==="high").length,moderateCount:r.filter(o=>o.riskLevel==="moderate").length,edgesAnalyzed:e.length,edgesWithSignal:s}}let Ree=100;function gS(){return++Ree}const RI="meshgraph-panel-";function _S(i){try{const e=localStorage.getItem(RI+i);return e?JSON.parse(e):null}catch{return null}}function Pee(i,e){try{localStorage.setItem(RI+i,JSON.stringify(e))}catch{}}function Nee(i,e,t,n,s){return{x:Math.max(8,Math.min(i,Math.max(8,n-t-8))),y:Math.max(8,Math.min(e,Math.max(8,s-36)))}}function nh({id:i,title:e,icon:t,open:n,onClose:s,defaultPosition:r,defaultSize:o,minSize:a={width:180,height:120},maxSize:l,autoHeight:c=!1,headerActions:u,children:d}){const h=IL(),p=$.useRef(null),m=$.useRef(null),y=$.useMemo(()=>{const F=_S(i);return F?{x:F.x,y:F.y,w:F.w,h:c?o.height:F.h,minimized:F.minimized}:{x:r.x,y:r.y,w:o.width,h:o.height,minimized:!1}},[i]),[g,_]=$.useState({w:y.w,h:y.h}),[S,C]=$.useState(y.minimized),[x,A]=$.useState(()=>gS()),[L,B]=$.useState({x:y.x,y:y.y});$.useLayoutEffect(()=>{const F=p.current;if(!n||!F)return;const X=F.getBoundingClientRect();if(X.width<1||X.height<1)return;const ie=_S(i),ee=(ie==null?void 0:ie.x)??y.x,ae=(ie==null?void 0:ie.y)??y.y,Z=(ie==null?void 0:ie.w)??g.w,Se=Nee(ee,ae,Z,X.width,X.height);B(Se)},[n,i]);const[H,Q]=$.useState(!1),te=$.useRef({startX:0,startY:0,startW:0,startH:0,edge:""}),M=$.useRef(),he=$.useCallback(()=>{M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{const F=m.current;if(!F)return;const X=window.getComputedStyle(F),ie=new DOMMatrix(X.transform);Pee(i,{x:ie.m41,y:ie.m42,w:g.w,h:g.h,minimized:S})},300)},[i,g.w,g.h,S]);$.useEffect(()=>{he()},[g,S,he]);const se=$.useCallback(()=>{A(gS())},[]),R=$.useCallback(()=>{C(F=>!F)},[]),J=$.useCallback((F,X)=>{F.preventDefault(),F.stopPropagation(),Q(!0),te.current={startX:F.clientX,startY:F.clientY,startW:g.w,startH:g.h,edge:X},se();const ie=ae=>{const{startX:Z,startY:Se,startW:xe,startH:Je,edge:de}=te.current,bt=ae.clientX-Z,Xe=ae.clientY-Se;let ht=xe,re=Je;(de==="e"||de==="se")&&(ht=Math.max(a.width,xe+bt),l&&(ht=Math.min(l.width,ht))),(de==="s"||de==="se")&&(re=Math.max(a.height,Je+Xe),l&&(re=Math.min(l.height,re))),_({w:ht,h:re})},ee=()=>{Q(!1),window.removeEventListener("pointermove",ie),window.removeEventListener("pointerup",ee)};window.addEventListener("pointermove",ie),window.addEventListener("pointerup",ee)},[g,a,l,se]);return f.jsx("div",{ref:p,className:"absolute inset-0 pointer-events-none",style:{zIndex:x},children:f.jsx(Qc,{children:n&&f.jsxs(Sl.div,{ref:m,drag:!H,dragControls:h,dragConstraints:p,dragElastic:.05,dragMomentum:!1,dragListener:!1,initial:{opacity:0,scale:.96,x:L.x,y:L.y},animate:{opacity:1,scale:1,x:L.x,y:L.y},exit:{opacity:0,scale:.96},transition:{duration:.15},onPointerDown:se,className:"absolute top-0 left-0 pointer-events-auto",style:{width:g.w,touchAction:"none"},children:[f.jsxs("div",{className:"surface-elevated radius-inset shadow-xl overflow-hidden flex flex-col",style:{maxHeight:S?void 0:c?"80vh":g.h},children:[f.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 border-b border-edge-subtle cursor-grab active:cursor-grabbing select-none shrink-0",onPointerDown:F=>{se(),h.start(F)},children:[f.jsx(LL,{className:"w-3 h-3 text-fg-muted/50 shrink-0"}),t&&f.jsx("span",{className:"text-fg-muted shrink-0 [&>svg]:w-3 [&>svg]:h-3",children:t}),f.jsx("span",{className:"text-[11px] font-medium text-fg-primary flex-1 truncate",children:e}),u,f.jsx("button",{onClick:R,className:"p-0.5 radius-badge hover-bg transition-base",title:S?"Expand":"Minimize",children:S?f.jsx(kS,{className:"w-2.5 h-2.5 text-fg-muted"}):f.jsx(rL,{className:"w-2.5 h-2.5 text-fg-muted"})}),f.jsx("button",{onClick:s,className:"p-0.5 radius-badge hover-bg transition-base",title:"Close",children:f.jsx($u,{className:"w-2.5 h-2.5 text-fg-muted"})})]}),f.jsx(Qc,{initial:!1,children:!S&&f.jsx(Sl.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},className:"overflow-hidden",children:f.jsx("div",{className:"overflow-y-auto",style:{maxHeight:c?"70vh":void 0},children:d})})})]}),!S&&!c&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"absolute top-0 -right-1 w-2 h-full cursor-ew-resize",onPointerDown:F=>J(F,"e")}),f.jsx("div",{className:"absolute -bottom-1 left-0 w-full h-2 cursor-ns-resize",onPointerDown:F=>J(F,"s")}),f.jsx("div",{className:"absolute -bottom-1 -right-1 w-3 h-3 cursor-nwse-resize",onPointerDown:F=>J(F,"se"),children:f.jsxs("svg",{className:"w-full h-full text-fg-muted/30",viewBox:"0 0 12 12",children:[f.jsx("path",{d:"M10 2 L10 10 L2 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5"}),f.jsx("path",{d:"M7 5 L7 7 L5 7",fill:"none",stroke:"currentColor",strokeWidth:"1"})]})})]})]})})})}const PI=[{target:"Graph",fn:"topology.edges",minStage:2,when:p0},{target:"Graph",fn:"topology.edges",minStage:2,when:OL},{target:"Graph",fn:"nodeMetrics",minStage:2},{target:"Graph",fn:"ghostNodes",minStage:2,when:p0},{target:"Graph",fn:"_advertNodeType",minStage:1,when:BL},{target:"Graph",fn:"pathHealth",minStage:2}];ML(PI);const Dee=400,sh=800,el={critical:[Ge.red,Ge.red],poor:[Ge.orange,Ge.orange],fair:[Ge.amber,Ge.amber],good:[Ge.green,Ge.green],excellent:[Ge.blue,Ge.blue]};function Mee(i,e){if(i==null)return null;const t=Math.max(0,i),n=t>0?(Math.log10(t)+4)/4.5:0,s=Math.round(Math.max(0,Math.min(100,n*100)));let r,o;s<10?(r="critical",o="Partition risk"):s<30?(r="poor",o="Weak connectivity"):s<55?(r="fair",o="Moderate resilience"):s<80?(r="good",o="Well connected"):(r="excellent",o="Highly resilient");const[a,l]=el[r];return{score:s,grade:r,label:o,color:e?a:l}}const yS=5,cg=28,bS=6,Oee=6,Bee={active:1,recent:.85,stale:.45,inactive:.25},Fee=[Ge.purple,Ge.green,Ge.amber,Ge.red,Ge.blue,Ge.pink,Ge.teal,Ge.orange],zee=[Ge.purple,Ge.green,Ge.amber,Ge.red,Ge.blue,Ge.pink,Ge.teal,Ge.orange];function wl(i,e,t){const n=(r,o)=>parseInt(r.slice(1+o*2,3+o*2),16),s=r=>Math.round(n(i,r)*t+n(e,r)*(1-t));return`#${[0,1,2].map(r=>s(r).toString(16).padStart(2,"0")).join("")}`}const NI={zeroHop:wl(Ge.amber,qt[500],.55),directPath:wl(Ge.teal,qt[500],.55),loop:wl(Ge.purple,qt[500],.55),backbone:qt[300],standard:qt[500],standardDim:qt[600],ghost:qt[600]},DI={zeroHop:wl(Ge.amber,qt[700],.5),directPath:wl(Ge.teal,qt[700],.5),loop:wl(Ge.purple,qt[700],.5),backbone:qt[700],standard:qt[400],standardDim:qt[300],ghost:qt[400]},Ne={simulationDecay:2e4,simulationGravity:.05,simulationCenter:.05,simulationRepulsion:5,simulationRepulsionTheta:.4,simulationLinkSpring:.05,simulationLinkDistance:78,simulationFriction:.72,simulationRepulsionFromMouse:0,pointSizeScale:.4,pointOpacity:1,pointGreyoutOpacity:.1,linkWidthScale:.06,linkOpacity:.95,linkGreyoutOpacity:.1,curvedLinks:!1,curvedLinkWeight:.8,linkDefaultArrows:!0,linkArrowsSizeScale:1.7,scalePointsOnZoom:!0,scaleLinksOnZoom:!0,renderLinks:!0,renderHoveredPointRing:!0,fitViewPadding:.15,spaceSize:4096};function Uee(i){if(typeof document>"u")return i?qt[950]:"#EFF0F1";const e=getComputedStyle(document.documentElement).getPropertyValue("--bg-body").trim();return e.startsWith("#")?e:i?qt[950]:"#EFF0F1"}function $ee(i){if(typeof document>"u")return i?qt[400]:qt[500];const e=getComputedStyle(document.documentElement).getPropertyValue("--text-secondary").trim();return e.startsWith("#")?e:i?qt[400]:qt[500]}const MI={local:Ge.amber,hub:Ge.purple,gateway:Ge.blue,backbone:Ge.green,neighbor:Ge.pink,mobile:Ge.orange,ghost:qt[400],standard:qt[300]},OI={local:Ge.amber,hub:Ge.purple,gateway:Ge.blue,backbone:Ge.green,neighbor:Ge.pink,mobile:Ge.orange,ghost:qt[500],standard:qt[600]},jee={local:"Your repeater — the home node running this dashboard",hub:"≥10% of last-hop traffic — dominant forwarder for your local node",gateway:"7-10% of last-hop traffic — significant relay node",backbone:"High betweenness centrality — critical path node connecting clusters",neighbor:"Zero-hop direct RF contact — no intermediate forwarders",mobile:"High path volatility — node appears and disappears frequently",ghost:"Unresolved prefix inferred by Viterbi HMM from path patterns",standard:"<7% of traffic — normal mesh participant"};function vS(i){const e=i.replace("#","");return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}function ug(i,e,t){const[n,s,r]=vS(i),[o,a,l]=vS(e),c=Math.max(0,Math.min(1,t)),u=Math.round(n*c+o*(1-c)),d=Math.round(s*c+a*(1-c)),h=Math.round(r*c+l*(1-c));return`#${u.toString(16).padStart(2,"0")}${d.toString(16).padStart(2,"0")}${h.toString(16).padStart(2,"0")}`}function Hee(i,e){return i.isZeroHop?"zero-hop":i.isDirectPathEdge?"direct-path":i.isLoopEdge?"loop":e.has(i.key)?"backbone":"standard"}function xS(i,e,t){const n=t?NI:DI;switch(i){case"zero-hop":return n.zeroHop;case"direct-path":return n.directPath;case"loop":return n.loop;case"backbone":return n.backbone;case"ghost":return n.ghost;case"standard":default:return e>=.7?n.standard:n.standardDim}}const Vee={"zero-hop":"Zero-Hop (Direct RF)","direct-path":"Direct Path (Unicast)",loop:"Redundant Loop",backbone:"Backbone",standard:"Standard",ghost:"Ghost (Inferred)"},Gee={"zero-hop":"Direct radio contact — no intermediate forwarders in path","direct-path":"Unicast-routed edge — verified via DIRECT route type packets",loop:"Redundant path — alternate route between the same endpoints exists",backbone:"High betweenness centrality — critical traffic flow edge",standard:"Normal mesh edge with moderate-to-high confidence",ghost:"Inferred connection from Viterbi HMM ghost node analysis"};function Wee(i){const e=i.rssiTrend<-.1,t=i.snrTrend<-.1,n=i.rssiTrend>.1,s=i.snrTrend>.1,r=i.rssiRange[1]-i.rssiRange[0],o=i.snrRange[1]-i.snrRange[0];return e&&t?{text:"Both RSSI and SNR declining — possible antenna degradation or increasing distance",color:"#EF4444"}:t&&!e?{text:"SNR declining while RSSI stable — likely RF interference or noise floor increase",color:"#F97316"}:e&&!t?{text:"RSSI declining while SNR stable — possible path obstruction or power change",color:"#F97316"}:n&&s?{text:"Signal improving — conditions favorable or antenna adjustment working",color:"#34D399"}:r>15||o>10?{text:"High signal variance — intermittent obstruction or multipath fading",color:"#FBBF24"}:{text:"Signal stable — no significant degradation detected",color:"#9CA3AF"}}const Yee=$.memo(function({timeline:e}){const t=e.buckets;if(t.length<2)return null;const n=200,s=36,r=1,[o,a]=e.rssiRange,l=Math.max(1,a-o),[c,u]=e.snrRange,d=Math.max(1,u-c),h=(n-r*2)/(t.length-1),p=t.map((A,L)=>{const B=r+L*h,H=r+(1-(A.avgRssi-o)/l)*(s-r*2);return`${B.toFixed(1)},${H.toFixed(1)}`}).join(" "),m=t.map((A,L)=>{const B=r+L*h,H=r+(1-(A.avgSnr-c)/d)*(s-r*2);return`${B.toFixed(1)},${H.toFixed(1)}`}).join(" "),y=e.rssiTrend>.1?"↑":e.rssiTrend<-.1?"↓":"→",g=e.snrTrend>.1?"↑":e.snrTrend<-.1?"↓":"→",_=e.rssiTrend>.1?"#34D399":e.rssiTrend<-.1?"#EF4444":"#9CA3AF",S=e.snrTrend>.1?"#34D399":e.snrTrend<-.1?"#EF4444":"#9CA3AF",C=(e.timeSpanMs/36e5).toFixed(1),x=Wee(e);return f.jsxs("div",{className:"mt-2 pt-2 border-t border-edge-subtle/50",children:[f.jsxs("div",{className:"flex items-center justify-between mb-1",children:[f.jsx(be,{content:f.jsxs("div",{className:"max-w-xs space-y-1.5",children:[f.jsx("div",{className:"font-semibold text-fg-primary",children:"Signal Quality Over Time"}),f.jsx("div",{className:"text-fg-secondary text-[11px]",children:"Tracks RSSI (signal power) and SNR (signal-to-noise ratio) for zero-hop packets received directly from this neighbor. Reveals weather effects, interference, and antenna degradation."}),f.jsxs("div",{className:"pt-1 border-t border-edge-subtle/30 space-y-0.5 font-mono text-[10px]",children:[f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Samples"}),f.jsx("span",{className:"text-fg-primary tabular-nums",children:e.totalSamples})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Time span"}),f.jsxs("span",{className:"text-fg-primary tabular-nums",children:[C,"h"]})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Avg RSSI"}),f.jsxs("span",{className:"text-fg-primary tabular-nums",children:[e.avgRssi.toFixed(1)," dBm"]})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Avg SNR"}),f.jsxs("span",{className:"text-fg-primary tabular-nums",children:[e.avgSnr.toFixed(1)," dB"]})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"RSSI trend"}),f.jsxs("span",{className:"tabular-nums",style:{color:_},children:[e.rssiTrend>0?"+":"",e.rssiTrend.toFixed(3)," dBm/bucket"]})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"SNR trend"}),f.jsxs("span",{className:"tabular-nums",style:{color:S},children:[e.snrTrend>0?"+":"",e.snrTrend.toFixed(3)," dB/bucket"]})]})]}),f.jsxs("div",{className:"text-[10px] text-fg-muted italic",children:["Trend is linear regression slope across ",t.length," time buckets. ↑ = improving, ↓ = degrading, → = stable."]})]}),children:f.jsx("span",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Signal Timeline"})}),f.jsxs("span",{className:"text-[9px] text-fg-muted tabular-nums",children:[e.totalSamples," samples · ",C,"h"]})]}),f.jsxs("svg",{viewBox:`0 0 ${n} ${s}`,className:"w-full h-9",preserveAspectRatio:"none",children:[f.jsx("polyline",{points:p,fill:"none",stroke:"#60A5FA",strokeWidth:"1.5",strokeLinejoin:"round",strokeLinecap:"round",opacity:"0.8"}),f.jsx("polyline",{points:m,fill:"none",stroke:"#34D399",strokeWidth:"1",strokeLinejoin:"round",strokeLinecap:"round",opacity:"0.5",strokeDasharray:"3 2"})]}),f.jsxs("div",{className:"flex items-center justify-between text-[9px] mt-0.5",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsxs("span",{className:"flex items-center gap-0.5",children:[f.jsx("span",{className:"w-2.5 h-[1.5px] bg-[#60A5FA] rounded-full inline-block"}),f.jsx("span",{className:"text-fg-muted",children:"RSSI"}),f.jsx("span",{className:"tabular-nums",style:{color:_},children:y})]}),f.jsxs("span",{className:"flex items-center gap-0.5",children:[f.jsx("span",{className:"w-2.5 h-[1px] bg-[#34D399] rounded-full inline-block opacity-50",style:{borderTop:"1px dashed #34D399"}}),f.jsx("span",{className:"text-fg-muted",children:"SNR"}),f.jsx("span",{className:"tabular-nums",style:{color:S},children:g})]})]}),f.jsxs("div",{className:"flex items-center gap-2 text-fg-muted tabular-nums",children:[f.jsxs("span",{children:[o.toFixed(0),"…",a.toFixed(0)," dBm"]}),f.jsxs("span",{children:[c.toFixed(0),"…",u.toFixed(0)," dB"]})]})]}),f.jsx("div",{className:"mt-1 text-[9px] leading-tight",style:{color:x.color},children:x.text})]})}),wS=$.memo(function({edge:e,onClose:t}){const[n,s]=$.useState(null);return $.useEffect(()=>{if(!e.isZeroHop&&e.edgeType!=="zero-hop"){s(null);return}const r=d0.getState().packets,o=d0.getState().cachedLocalHash??void 0,a=Tee(r,e.source,e.target,o);s(a)},[e.source,e.target,e.isZeroHop,e.edgeType]),f.jsxs(Sl.div,{variants:X_,initial:"hidden",animate:"visible",exit:"exit",className:"absolute inset-x-3 bottom-3 z-20 surface-elevated radius-inset shadow-xl",children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-edge-subtle/50",children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.jsx(YL,{className:"size-3.5 text-fg-muted shrink-0"}),f.jsxs("span",{className:"text-sm font-semibold text-fg-primary truncate",children:[e.fromName??e.source.slice(0,6)," → ",e.toName??e.target.slice(0,6)]}),f.jsxs("div",{className:"flex gap-1 shrink-0",children:[f.jsx(Di,{color:"zinc",compact:!0,children:Vee[e.edgeType]}),e.isBackbone&&f.jsx(Di,{color:"emerald",compact:!0,children:"BONE"}),e.isLoopEdge&&f.jsx(Di,{color:"indigo",compact:!0,children:"LOOP"}),e.isGhost&&f.jsx(Di,{color:"zinc",compact:!0,children:"GHOST"})]})]}),f.jsx(q_,{plain:!0,onClick:t,title:"Close",className:"shrink-0",children:f.jsx($u,{className:"size-4"})})]}),f.jsxs("div",{className:"p-3 font-mono text-[11px]",children:[f.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[f.jsxs("div",{children:[f.jsx(be,{content:"Average disambiguation confidence across all observations of this edge",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Confidence"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[(e.confidence*100).toFixed(0),"%"]})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Observations where both endpoints had high-confidence disambiguation",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Certain"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.certainCount.toLocaleString()})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Total packets observed traversing this edge",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Packets"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.packetCount.toLocaleString()})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Combined certainCount × confidence metric for edge ranking",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Strength"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.strength.toFixed(2)})]})]}),f.jsxs("div",{className:"grid grid-cols-4 gap-3 mt-2",children:[f.jsxs("div",{children:[f.jsx(be,{content:"Bidirectional balance (min/max) — 0 = one-way traffic, 1 = perfectly balanced",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Symmetry"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.symmetryRatio.toFixed(2)})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Dominant traffic flow direction between these nodes",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Direction"})}),f.jsx("div",{className:"text-fg-primary capitalize",children:e.dominantDirection})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Forward (A→B) vs reverse (B→A) observation counts",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Fwd / Rev"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.forwardCount," / ",e.reverseCount]})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Routing method — broadcast flood vs unicast direct routing",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Flood / Direct"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.floodCount," / ",e.directCount]})]})]}),(e.avgRssi!=null||e.avgSnr!=null)&&f.jsxs("div",{className:"grid grid-cols-2 gap-3 mt-2 pt-2 border-t border-edge-subtle/50",children:[e.avgRssi!=null&&f.jsxs("div",{children:[f.jsx("div",{className:"text-[9px] text-fg-muted uppercase",children:"RSSI"}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.avgRssi.toFixed(1)," dBm"]})]}),e.avgSnr!=null&&f.jsxs("div",{children:[f.jsx("div",{className:"text-[9px] text-fg-muted uppercase",children:"SNR"}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.avgSnr.toFixed(1)," dB"]})]})]}),e.linkBudget&&f.jsxs("div",{className:"grid grid-cols-4 gap-3 mt-2 pt-2 border-t border-edge-subtle/50",children:[e.linkBudget.distanceKm!=null&&f.jsxs("div",{children:[f.jsx(be,{content:"Haversine distance between endpoint locations",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Distance"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.linkBudget.distanceKm.toFixed(2)," km"]})]}),e.linkBudget.fsplDb!=null&&f.jsxs("div",{children:[f.jsx(be,{content:"Free Space Path Loss — theoretical signal attenuation over this distance at configured frequency",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"FSPL"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.linkBudget.fsplDb.toFixed(1)," dB"]})]}),e.linkBudget.marginDb!=null&&f.jsxs("div",{children:[f.jsx(be,{content:"Link margin — observed RSSI minus receiver sensitivity. Positive = signal headroom above minimum.",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Margin"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",style:{color:e.linkBudget.marginClass?Av[e.linkBudget.marginClass]:void 0},children:[e.linkBudget.marginDb>0?"+":"",e.linkBudget.marginDb.toFixed(1)," dB"]})]}),e.linkBudget.deviationDb!=null&&f.jsxs("div",{children:[f.jsx(be,{content:"Deviation from theoretical FSPL — positive means better signal than free-space prediction",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"vs Theory"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.linkBudget.deviationDb>0?"+":"",e.linkBudget.deviationDb.toFixed(1)," dB"]})]})]}),n&&f.jsx(Yee,{timeline:n})]})]})}),SS=$.memo(function({node:e,onClose:t,egoMetrics:n,onExpandEgo:s,neighbors:r,onSelectNeighbor:o,txDelayRec:a}){const[l,c]=$.useState(!1),[u,d]=$.useState(!1);return f.jsxs(Sl.div,{variants:X_,initial:"hidden",animate:"visible",exit:"exit",className:"absolute inset-x-3 bottom-3 z-20 surface-elevated radius-inset shadow-xl max-h-[60vh] flex flex-col",children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-edge-subtle/50",children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.jsx("span",{className:"size-2 shrink-0 rounded-full",style:{backgroundColor:(SL()?MI:OI)[e.nodeClass]}}),f.jsx("code",{className:"text-sm font-semibold text-fg-primary shrink-0",children:e.prefix}),e.name&&f.jsx("span",{className:"text-sm text-fg-secondary truncate",children:e.name}),f.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.isLocal&&f.jsx(Di,{color:"yellow",compact:!0,children:"LOCAL"}),e.isHub&&f.jsx(Di,{color:"violet",compact:!0,children:"HUB"}),e.isGateway&&f.jsx(Di,{color:"sky",compact:!0,children:"GW"}),e.isBackbone&&f.jsx(Di,{color:"emerald",compact:!0,children:"BONE"}),e.isMobile&&f.jsx(Di,{color:"orange",compact:!0,children:"MOB"}),e.isZeroHop&&f.jsx(Di,{color:"amber",compact:!0,children:"RF"}),e.isGhost&&f.jsx(Di,{color:"zinc",compact:!0,children:"GHOST"}),e.isInLoop&&f.jsx(Di,{color:"indigo",compact:!0,children:"LOOP"})]})]}),f.jsx(q_,{plain:!0,onClick:t,title:"Close",className:"shrink-0",children:f.jsx($u,{className:"size-4"})})]}),f.jsxs("div",{className:"p-3 font-mono text-[11px]",children:[f.jsx(FL,{copy:!0,size:"compact",truncate:[10,6],className:"w-full mb-3",children:e.hash}),f.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[f.jsxs("div",{children:[f.jsx(be,{content:"Total connections (edges) to this node",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Degree"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.degree})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Inbound vs outbound edge count — indicates traffic directionality",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"In / Out"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.inDegree," / ",e.outDegree]})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Betweenness centrality (0–1) — how often this node lies on shortest paths. High value = critical relay.",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Between."})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.betweenness.toFixed(3)})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Total packets observed involving this node",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Packets"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.packetCount.toLocaleString()})]})]}),f.jsxs("div",{className:"grid grid-cols-4 gap-3 mt-2",children:[f.jsxs("div",{children:[f.jsx(be,{content:"Number of topology edges connected to this node",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Edges"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.edgeCount})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Community cluster assignment from graph partitioning algorithm",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Community"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:["#",e.communityId]})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Prefix disambiguation confidence — how certain the 2-char prefix→node mapping is (multi-factor scoring)",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Confidence"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[(e.prefixConfidence*100).toFixed(0),"%"]})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Recency level — active (<1h), recent (<6h), stale (<24h), inactive (>24h)",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Activity"})}),f.jsx("div",{className:"text-fg-primary capitalize",children:e.activityLevel})]})]}),(e.avgRssi!=null||e.avgSnr!=null)&&f.jsxs("div",{className:"grid grid-cols-2 gap-3 mt-2 pt-2 border-t border-edge-subtle/50",children:[e.avgRssi!=null&&f.jsxs("div",{children:[f.jsx("div",{className:"text-[9px] text-fg-muted uppercase",children:"RSSI"}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.avgRssi.toFixed(1)," dBm"]})]}),e.avgSnr!=null&&f.jsxs("div",{children:[f.jsx("div",{className:"text-[9px] text-fg-muted uppercase",children:"SNR"}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[e.avgSnr.toFixed(1)," dB"]})]})]}),n&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"grid grid-cols-3 gap-3 mt-2 pt-2 border-t border-edge-subtle/50",children:[f.jsxs("div",{children:[f.jsx(be,{content:"Number of direct 1-hop neighbors in the topology",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Ego Size"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:n.neighborCount})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Local clustering coefficient — how interconnected this node's neighbors are (0 = none, 1 = fully connected)",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Clustering"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:n.clusteringCoeff.toFixed(3)})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Average betweenness centrality of this node's direct neighbors",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Avg Nbr Btw."})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:n.avgNeighborBetweenness.toFixed(3)})]})]}),f.jsxs("div",{className:"grid grid-cols-3 gap-3 mt-2",children:[f.jsxs("div",{children:[f.jsx(be,{content:"Average disambiguation confidence across all connected edges",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Edge Conf."})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[(n.avgEdgeConfidence*100).toFixed(0),"%"]})]}),n.avgRssi!=null&&f.jsxs("div",{children:[f.jsx("div",{className:"text-[9px] text-fg-muted uppercase",children:"Avg RSSI"}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[n.avgRssi.toFixed(1)," dBm"]})]}),n.avgSnr!=null&&f.jsxs("div",{children:[f.jsx("div",{className:"text-[9px] text-fg-muted uppercase",children:"Avg SNR"}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[n.avgSnr.toFixed(1)," dB"]})]})]})]}),a&&!a.insufficientData&&f.jsxs("div",{className:"mt-2 pt-2 border-t border-edge-subtle/50",children:[f.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[f.jsx(be,{content:"RF-grounded TX delay recommendation from centralized topology engine. Anchored to MeshCore firmware defaults with observer bias correction.",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase tracking-wide cursor-help",children:"TX Delay Recommendation"})}),f.jsxs("div",{className:"flex items-center gap-1",children:[a.networkRole&&f.jsx(Di,{color:zL[a.networkRole],compact:!0,children:a.networkRole}),a.dataConfidence&&f.jsx(Di,{color:UL[a.dataConfidence],compact:!0,children:a.dataConfidence})]})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[f.jsxs("div",{children:[f.jsx(be,{content:`Flood TX delay factor (firmware default: ×${$L})`,children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Flood"})}),f.jsx("div",{className:"text-fg-primary tabular-nums text-sys-amber",children:m0(a.floodFactor)})]}),f.jsxs("div",{children:[f.jsx(be,{content:`Direct TX delay factor (firmware default: ×${jL})`,children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Direct"})}),f.jsx("div",{className:"text-fg-primary tabular-nums text-sys-amber",children:m0(a.directFactor)})]})]}),a.rationale&&f.jsx("div",{className:"mt-1 text-[9px] text-fg-muted leading-snug",children:a.rationale}),a.observationSymmetry!=null&&a.observationSymmetry<.6&&f.jsxs("div",{className:"mt-1 text-[9px] text-sys-amber/70 leading-snug",children:["⚠ Low observation symmetry (",(a.observationSymmetry*100).toFixed(0),"%) — recommendation damped toward firmware defaults"]}),f.jsxs("button",{onClick:async()=>{const h=`set txdelay ${a.floodFactor.toFixed(1)} +set direct.txdelay ${a.directFactor.toFixed(1)}`;try{await navigator.clipboard.writeText(h)}catch{}d(!0),setTimeout(()=>d(!1),1500)},className:"mt-1.5 flex items-center gap-1 text-[9px] text-sys-blue hover:text-sys-blue/80 transition-base",children:[u?f.jsx(EL,{className:"w-3 h-3 text-sys-green"}):f.jsx(CL,{className:"w-3 h-3"}),u?"Copied!":"Copy CLI commands"]})]}),s&&f.jsx("div",{className:"mt-2 pt-2 border-t border-edge-subtle/50",children:f.jsxs("button",{onClick:s,className:"flex items-center gap-1.5 text-[10px] text-sys-blue hover:text-sys-blue/80 transition-base",children:[f.jsx(TL,{className:"w-3 h-3"}),"Expand 2-hop neighborhood"]})}),r&&r.length>0&&f.jsxs("div",{className:"mt-2 pt-2 border-t border-edge-subtle/50",children:[f.jsxs("button",{onClick:()=>c(h=>!h),className:"flex items-center justify-between w-full text-[9px] text-fg-muted uppercase tracking-wide cursor-pointer hover:text-fg-secondary transition-base",children:[f.jsxs("span",{children:["Neighbors (",r.length,")"]}),f.jsx(Rc,{className:`w-3 h-3 transition-transform ${l?"rotate-180":""}`})]}),l&&f.jsx("div",{className:"mt-1.5 max-h-32 overflow-y-auto space-y-0.5",children:r.map(h=>f.jsxs("button",{onClick:()=>o==null?void 0:o(h.hash),className:"w-full flex items-center gap-2 px-1.5 py-1 radius-badge hover-bg transition-base text-left group",children:[f.jsx("code",{className:"text-[10px] text-sys-blue shrink-0 tabular-nums",children:h.prefix}),f.jsx("span",{className:"text-[10px] text-fg-secondary truncate flex-1",children:h.name||"—"}),h.avgSnr!=null&&f.jsxs("span",{className:"text-[9px] text-fg-muted tabular-nums shrink-0",children:[h.avgSnr.toFixed(0)," dB"]}),h.avgRssi!=null&&f.jsx("span",{className:"text-[9px] text-fg-muted tabular-nums shrink-0",children:h.avgRssi.toFixed(0)}),f.jsxs("span",{className:"text-[9px] text-fg-muted/60 tabular-nums shrink-0",children:[(h.edgeConfidence*100).toFixed(0),"%"]})]},h.hash))})]})]})]})}),ES=$.memo(function({metrics:e,onClose:t}){const n=Object.entries(e.communities).sort(([,r],[,o])=>o-r),s=Object.entries(e.nodeClasses).sort(([,r],[,o])=>o-r);return f.jsxs(Sl.div,{variants:X_,initial:"hidden",animate:"visible",exit:"exit",className:"absolute inset-x-3 bottom-3 z-20 surface-elevated radius-inset shadow-xl",children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-edge-subtle/50",children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.jsx(AS,{className:"size-3.5 text-fg-muted shrink-0"}),f.jsx("span",{className:"text-sm font-semibold text-fg-primary",children:"Subgraph Analysis"}),f.jsxs(Di,{color:"violet",compact:!0,children:[e.nodeCount," nodes"]})]}),f.jsx(q_,{plain:!0,onClick:t,title:"Close",className:"shrink-0",children:f.jsx($u,{className:"size-4"})})]}),f.jsxs("div",{className:"p-3 font-mono text-[11px]",children:[f.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[f.jsxs("div",{children:[f.jsx("div",{className:"text-[9px] text-fg-muted uppercase",children:"Nodes"}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.nodeCount})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Edges where both endpoints are within the lasso selection",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Internal Edges"})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.edgeCount})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Mean betweenness centrality of selected nodes",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Avg Between."})}),f.jsx("div",{className:"text-fg-primary tabular-nums",children:e.avgBetweenness.toFixed(3)})]}),f.jsxs("div",{children:[f.jsx(be,{content:"Mean edge disambiguation confidence for internal edges",children:f.jsx("div",{className:"text-[9px] text-fg-muted uppercase cursor-help",children:"Avg Confidence"})}),f.jsxs("div",{className:"text-fg-primary tabular-nums",children:[(e.avgConfidence*100).toFixed(0),"%"]})]})]}),f.jsxs("div",{className:"grid grid-cols-2 gap-3 mt-2 pt-2 border-t border-edge-subtle/50",children:[f.jsxs("div",{children:[f.jsx("div",{className:"text-[9px] text-fg-muted uppercase mb-1",children:"Communities"}),f.jsx("div",{className:"flex flex-wrap gap-1",children:n.map(([r,o])=>f.jsxs("span",{className:"text-fg-secondary",children:["#",r,"×",o]},r))})]}),f.jsxs("div",{children:[f.jsx("div",{className:"text-[9px] text-fg-muted uppercase mb-1",children:"Node Types"}),f.jsx("div",{className:"flex flex-wrap gap-1",children:s.map(([r,o])=>f.jsxs("span",{className:"text-fg-secondary capitalize",children:[r,"×",o]},r))})]})]}),e.nodeCount>1&&f.jsx("div",{className:"mt-2 pt-2 border-t border-edge-subtle/50",children:f.jsxs("div",{className:"text-[9px] text-fg-muted flex items-center gap-1 flex-wrap",children:[f.jsx(be,{content:"Fraction of possible edges that exist — 2E / N(N-1)",children:f.jsxs("span",{className:"cursor-help",children:["Density: ",(2*e.edgeCount/(e.nodeCount*(e.nodeCount-1))*100).toFixed(1),"%"]})}),f.jsx("span",{children:"·"}),f.jsx(be,{content:"Mean connections per node — 2E / N",children:f.jsxs("span",{className:"cursor-help",children:["Avg Degree: ",(2*e.edgeCount/e.nodeCount).toFixed(1)]})}),e.avgPathHealth!=null&&f.jsxs(f.Fragment,{children:[f.jsx("span",{children:"·"}),f.jsx(be,{content:"Average health score of paths within the selection",children:f.jsxs("span",{className:"cursor-help",children:["Path Health: ",(e.avgPathHealth*100).toFixed(0),"%"]})})]})]})})]})]})});function qee(){return f.jsxs("div",{className:"flex flex-col items-center justify-center gap-6 text-center px-8",children:[f.jsx("div",{className:"p-4 radius-pill bg-subtle-fill",children:f.jsx(GL,{className:"w-8 h-8 text-fg-muted"})}),f.jsxs("div",{className:"space-y-2",children:[f.jsx("h2",{className:"type-subheading text-fg-primary",children:"No Topology Data"}),f.jsx("p",{className:"type-body text-fg-muted max-w-sm",children:"The mesh topology will appear here once packets are received and processed."})]}),f.jsxs("div",{className:"flex items-center gap-2 type-data-xs text-fg-muted",children:[f.jsx(dg,{className:"w-4 h-4 animate-pulse"}),f.jsx("span",{children:"Waiting for mesh traffic..."})]})]})}const fi=$.memo(function({label:e,value:t,onChange:n,min:s,max:r,step:o}){const[a,l]=$.useState(!1),[c,u]=$.useState(""),d=$.useRef(null),h=$.useCallback(()=>{const m=parseFloat(c);isNaN(m)||n(Math.min(r,Math.max(s,Math.round(m/o)*o))),l(!1)},[c,n,s,r,o]),p=$.useCallback(()=>{u(t.toFixed(2)),l(!0),setTimeout(()=>{var m;return(m=d.current)==null?void 0:m.select()},0)},[t]);return f.jsxs("div",{className:"space-y-1",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-[10px] text-fg-muted",children:e}),a?f.jsx("input",{ref:d,type:"number",value:c,onChange:m=>u(m.target.value),onBlur:h,onKeyDown:m=>{m.key==="Enter"&&h(),m.key==="Escape"&&l(!1)},min:s,max:r,step:o,className:"w-14 text-right text-[10px] text-fg-secondary tabular-nums bg-subtle-fill radius-badge px-1 py-0.5 border border-edge-subtle focus:outline-none focus:border-sys-blue"}):f.jsx("button",{onClick:p,className:"text-[10px] text-fg-secondary tabular-nums hover:text-sys-blue cursor-text transition-colors",title:"Click to type a value",children:t.toFixed(2)})]}),f.jsx("input",{type:"range",min:s,max:r,step:o,value:t,onChange:m=>n(parseFloat(m.target.value)),className:"w-full h-1 bg-subtle-fill rounded appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-sys-blue [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:cursor-pointer"})]})}),Va=$.memo(function({label:e,checked:t,onChange:n}){return f.jsxs(vL,{className:"flex items-center justify-between",children:[f.jsx(xL,{className:"text-[10px] text-fg-muted cursor-pointer select-none",children:e}),f.jsx(wL,{enabled:t,onChange:n,size:"sm"})]})});function Xee(){var Yv,qv,Xv,Kv,Zv,Qv,Jv,e0,t0,i0,n0,s0,r0,o0,a0;DL(PI);const i=oL(),[e,t]=$.useState(!1),[n,s]=$.useState(!1),r=$.useRef(!1);$.useEffect(()=>{!i||r.current||(r.current=!0,s(!0))},[i]);const o=$.useCallback(()=>{s(!1),t(!0)},[]),a=aL(),l=lL(),c=IJ(l,2e3),u=cL(),d=uL(),h=dL(),p=hL(),m=fL(),y=pL(),g=mL(),_=g?MI:OI,S=g?Fee:zee,C=$.useMemo(()=>Uee(g),[g]),x=$.useMemo(()=>$ee(g),[g]),[A,L]=$.useState(!0),[B,H]=$.useState(null),[Q,te]=$.useState(null),[M,he]=$.useState(!1),[se,R]=$.useState(""),[J,F]=$.useState(!1),[X,ie]=$.useState(!1),[ee,ae]=$.useState("simulation"),[Z,Se]=$.useState(!0),[xe,Je]=$.useState(!1),[de,bt]=$.useState(!0),[Xe,ht]=$.useState(!1),[re,Te]=$.useState(!1),[Pe,q]=$.useState(new Set),[We,He]=$.useState(!1),[it,Vt]=$.useState("spectral"),[me,nt]=$.useState(1),[ui,_i]=$.useState(1),[Zn,Qo]=$.useState(!1),[Zs,Li]=$.useState(null),[en,Ri]=$.useState(!1),[ai,vo]=$.useState(!1),[Es,Qn]=$.useState(null),[Jn,Cs]=$.useState(null),[zi,Ei]=$.useState(null),[ii,bn]=$.useState(null),[vn,Ts]=$.useState(null),On=gL(),[es,Dr]=$.useState(!1),[xn,Qs]=$.useState([]),[Jo,Zt]=$.useState(0),[Ot,ks]=$.useState(null),xo=$.useRef(new yee),Js=$.useRef(null),Rt=$.useRef(null),[Mr,ea]=$.useState(null),[ts,di]=$.useState(null),[Bn,wo]=$.useState({}),[ut,Or]=$.useState({simulationDecay:Ne.simulationDecay,simulationGravity:Ne.simulationGravity,simulationCenter:Ne.simulationCenter,simulationRepulsion:Ne.simulationRepulsion,simulationRepulsionTheta:Ne.simulationRepulsionTheta,simulationLinkSpring:Ne.simulationLinkSpring,simulationLinkDistance:Ne.simulationLinkDistance,simulationFriction:Ne.simulationFriction,simulationRepulsionFromMouse:Ne.simulationRepulsionFromMouse,pointSizeScale:Ne.pointSizeScale,pointOpacity:Ne.pointOpacity,pointGreyoutOpacity:Ne.pointGreyoutOpacity,linkWidthScale:Ne.linkWidthScale,linkOpacity:Ne.linkOpacity,linkGreyoutOpacity:Ne.linkGreyoutOpacity,curvedLinks:Ne.curvedLinks,curvedLinkWeight:Ne.curvedLinkWeight,linkDefaultArrows:Ne.linkDefaultArrows,linkArrowsSizeScale:Ne.linkArrowsSizeScale,scalePointsOnZoom:Ne.scalePointsOnZoom,scaleLinksOnZoom:Ne.scaleLinksOnZoom,renderLinks:Ne.renderLinks,renderHoveredPointRing:Ne.renderHoveredPointRing,spaceSize:Ne.spaceSize}),st=$.useCallback((v,j)=>{Or(W=>({...W,[v]:j}))},[]),wn=$.useCallback(()=>{Or({simulationDecay:Ne.simulationDecay,simulationGravity:Ne.simulationGravity,simulationCenter:Ne.simulationCenter,simulationRepulsion:Ne.simulationRepulsion,simulationRepulsionTheta:Ne.simulationRepulsionTheta,simulationLinkSpring:Ne.simulationLinkSpring,simulationLinkDistance:Ne.simulationLinkDistance,simulationFriction:Ne.simulationFriction,simulationRepulsionFromMouse:Ne.simulationRepulsionFromMouse,pointSizeScale:Ne.pointSizeScale,pointOpacity:Ne.pointOpacity,pointGreyoutOpacity:Ne.pointGreyoutOpacity,linkWidthScale:Ne.linkWidthScale,linkOpacity:Ne.linkOpacity,linkGreyoutOpacity:Ne.linkGreyoutOpacity,curvedLinks:Ne.curvedLinks,curvedLinkWeight:Ne.curvedLinkWeight,linkDefaultArrows:Ne.linkDefaultArrows,linkArrowsSizeScale:Ne.linkArrowsSizeScale,scalePointsOnZoom:Ne.scalePointsOnZoom,scaleLinksOnZoom:Ne.scaleLinksOnZoom,renderLinks:Ne.renderLinks,renderHoveredPointRing:Ne.renderHoveredPointRing,spaceSize:Ne.spaceSize})},[]);$.useEffect(()=>()=>{var v;try{(v=Rt.current)==null||v.destroy()}catch{}Rt.current=null},[]),$.useEffect(()=>{const v=j=>{var W,ce;if(!(j.target instanceof HTMLInputElement||j.target instanceof HTMLSelectElement))switch(j.key.toLowerCase()){case"f":!j.metaKey&&!j.ctrlKey&&(j.preventDefault(),(W=Rt.current)==null||W.fitView(sh));break;case"escape":J?(F(!1),R("")):B&&(H(null),(ce=Rt.current)==null||ce.unselectAllPoints());break;case"/":J||(j.preventDefault(),F(!0),setTimeout(()=>{var oe;return(oe=Js.current)==null?void 0:oe.focus()},50));break;case" ":j.preventDefault(),Rt.current&&(A?Rt.current.pause():Rt.current.start(),L(oe=>!oe));break;case"l":Se(oe=>!oe);break}};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[J,B,A]);const Br=$.useMemo(()=>new Set((a==null?void 0:a.backboneEdges)??[]),[a==null?void 0:a.backboneEdges]),er=$.useMemo(()=>({resolution:me,kWeight:ui}),[me,ui]),Fn=$.useMemo(()=>{if(it!=="louvain")return null;const v=a==null?void 0:a.edges;if(!v||v.length===0||!c||c.size<3)return null;const j=Array.from(c.keys());return hS(v,j,er).communities},[it,a==null?void 0:a.edges,c,er]),tn=$.useMemo(()=>{var oe;if(!c||c.size===0||!e)return[];const v=[],j=(y==null?void 0:y.node_name)??((oe=y==null?void 0:y.config)==null?void 0:oe.node_name)??null,W=g?"#171717":"#EFF0F1";let ce=1;for(const Ze of c.values())Ze.degree>ce&&(ce=Ze.degree);for(const Ze of c.values()){const fe=Ze,Ee=fe.degree>0?Math.log10(fe.degree+1)/Math.log10(ce+1):0,ji=yS+Math.min(1,Ee)*(cg-yS),nn=fe.betweenness*bS,ns=fe.isLocal?cg:Math.min(cg+bS,ji+nn),ss=(Fn==null?void 0:Fn.get(fe.hash))??fe.communityId,Ut=We&&ss>=0?S[ss%S.length]:_[fe.nodeClass],ye=Bee[fe.activityLevel]??1,Yt=fe.isLocal?_.local:ye<1?ug(Ut,W,ye):Ut,sc=fe.isLocal?j??fe.name:fe.name;v.push({id:fe.hash,label:sc?`${fe.prefix} ${sc}`:fe.prefix,color:Yt,size:ns,nodeClass:fe.nodeClass,name:sc,prefix:fe.prefix,packetCount:fe.packetCount,isLocal:fe.isLocal,isHub:fe.isHub,isGateway:fe.isGateway,isBackbone:fe.isBackbone,isMobile:fe.isMobile,isZeroHop:fe.isZeroHop,isGhost:fe.isGhost,degree:fe.degree,betweenness:fe.betweenness,communityId:(Fn==null?void 0:Fn.get(fe.hash))??fe.communityId,activityLevel:fe.activityLevel,prefixConfidence:fe.prefixConfidence,hasCollision:fe.hasCollision,inDegree:fe.inDegree,outDegree:fe.outDegree,isInLoop:fe.isInLoop,avgRssi:fe.avgRssi,avgSnr:fe.avgSnr})}for(const Ze of u){const fe=`ghost-${Ze.prefix}`;if(v.some(ji=>ji.id===fe))continue;const Ee=ug(_.ghost,W,.6);v.push({id:fe,label:`? ${Ze.prefix.toUpperCase()}`,color:Ee,size:Oee,nodeClass:"ghost",name:null,prefix:Ze.prefix,packetCount:Ze.observationCount,isLocal:!1,isHub:!1,isGateway:!1,isBackbone:!1,isMobile:!1,isZeroHop:!1,isGhost:!0,degree:Ze.commonNeighbors.size,betweenness:0,communityId:-1,activityLevel:"active",prefixConfidence:Ze.confidence,hasCollision:!1,inDegree:0,outDegree:0,isInLoop:!1,avgRssi:null,avgSnr:null})}return v},[c,e,y==null?void 0:y.node_name,(Yv=y==null?void 0:y.config)==null?void 0:Yv.node_name,_,g,u,S,We,it,Fn]),I=$.useMemo(()=>new Set(tn.map(v=>v.id)),[tn]),V=$.useMemo(()=>{const v=new Map;if(!c)return v;for(const j of c.values())v.set(j.hash,j.name);return v},[c]),E=$.useMemo(()=>{const v=(a==null?void 0:a.edges)??[];if(!v.length||!e)return[];const j=[],W=(a==null?void 0:a.edgeBetweenness)??new Map;for(const oe of v){if(!I.has(oe.fromHash)||!I.has(oe.toHash))continue;const Ze=Hee(oe,Br),fe=xS(Ze,oe.avgConfidence,g),Ee=W.get(oe.key)??0,ji=Ee>0?.5+Ee*4:.5+Math.min(1,oe.certainCount/50)*2;j.push({source:oe.fromHash,target:oe.toHash,color:fe,width:ji,key:oe.key,packetCount:oe.packetCount,certainCount:oe.certainCount,confidence:oe.avgConfidence,symmetryRatio:oe.symmetryRatio,dominantDirection:oe.dominantDirection,isBackbone:Br.has(oe.key),isLoopEdge:oe.isLoopEdge??!1,isDirectPath:oe.isDirectPathEdge,isZeroHop:oe.isZeroHop??!1,isGhost:!1,forwardCount:oe.forwardCount,reverseCount:oe.reverseCount,floodCount:oe.floodCount,directCount:oe.directCount,avgRssi:oe.avgRssi??null,avgSnr:oe.avgSnr??null,strength:oe.strength,fromName:V.get(oe.fromHash)??null,toName:V.get(oe.toHash)??null,edgeType:Ze})}const ce=g?NI:DI;for(const oe of u){const Ze=`ghost-${oe.prefix}`;if(I.has(Ze))for(const fe of oe.commonNeighbors)I.has(fe)&&j.push({source:Ze,target:fe,color:ce.ghost,width:.4,key:`ghost-${oe.prefix}-${fe}`,packetCount:oe.observationCount,certainCount:0,confidence:oe.confidence,symmetryRatio:0,dominantDirection:"balanced",isBackbone:!1,isLoopEdge:!1,isDirectPath:!1,isZeroHop:!1,isGhost:!0,forwardCount:0,reverseCount:0,floodCount:0,directCount:0,avgRssi:null,avgSnr:null,strength:oe.confidence,fromName:null,toName:V.get(fe)??null,edgeType:"ghost"})}return j},[a==null?void 0:a.edges,a==null?void 0:a.edgeBetweenness,e,I,g,Br,V,u]),G=(Xv=(qv=y==null?void 0:y.config)==null?void 0:qv.radio)==null?void 0:Xv.frequency,ne=(Zv=(Kv=y==null?void 0:y.config)==null?void 0:Kv.radio)==null?void 0:Zv.bandwidth,Ce=(Jv=(Qv=y==null?void 0:y.config)==null?void 0:Qv.radio)==null?void 0:Jv.spreading_factor,At=(t0=(e0=y==null?void 0:y.config)==null?void 0:e0.radio)==null?void 0:t0.tx_power,rt=(n0=(i0=y==null?void 0:y.config)==null?void 0:i0.radio)==null?void 0:n0.coding_rate,et=$.useMemo(()=>{if(!a||!ai)return null;const v={frequency:G,bandwidth:zi!=null?zi*1e3:ne,spreading_factor:Jn??Ce,tx_power:Es??At,coding_rate:ii??rt},j={};return vn!=null&&(j.sensitivityOverrideDbm=vn),On!=null&&(j.observedNoiseFloorDbm=On),lee(a,v,j)},[a,ai,G,ne,Ce,At,rt,Es,Jn,zi,ii,vn,On]),yi=$.useMemo(()=>{if(!et)return null;const v=new Map;for(const j of et)v.set(j.edgeKey,j);return v},[et]),ft=$.useMemo(()=>!et||et.length===0?null:cee(et),[et]),tr=$.useMemo(()=>{if(!ai||!yi)return E;const v=g?"#303038":"#D0D0D8";return E.map(j=>{const W=yi.get(j.key);return!W||!W.hasData?{...j,color:v,width:.3}:{...j,color:dee(W,"margin"),width:hee(W),linkBudget:W}})},[E,ai,yi,g]),Bt=$.useMemo(()=>Pe.size===0?tn:tn.filter(v=>!Pe.has(v.nodeClass)),[tn,Pe]),Ui=$.useMemo(()=>{if(Pe.size===0)return tr;const v=new Set(Bt.map(j=>j.id));return tr.filter(j=>v.has(j.source)&&v.has(j.target))},[tr,Bt,Pe]),Ra=$.useRef([]);$.useEffect(()=>{Ra.current=Ui},[Ui]);const ld=$.useMemo(()=>{const v=new Map;for(const j of E)v.set(j.source,(v.get(j.source)??0)+1),v.set(j.target,(v.get(j.target)??0)+1);return v},[E]),As=$.useMemo(()=>{const v=new Map;for(const j of tn)v.set(j.id,j);return v},[tn]);$.useEffect(()=>{if(Bt.length===0){ea(null),di(null),wo({});return}let v=!1;const W=setTimeout(async()=>{try{const ce=Bt.map(Ee=>({id:Ee.id,label:Ee.label,color:Ee.color,size:Ee.size,communityId:String(Ee.communityId)})),oe=Ui.map(Ee=>({source:Ee.source,target:Ee.target,color:Ee.color,width:Ee.width})),fe=await TQ({points:{pointIdBy:"id",pointColorBy:"color",pointColorStrategy:"direct",pointDefaultColor:g?"#9CA3AF":"#374151",pointLabelBy:"label",pointSizeBy:"size",pointSizeStrategy:"direct",pointDefaultSize:8,pointSizeScale:1,pointGreyoutOpacity:.3,pointIncludeColumns:["communityId"]},links:{linkSourceBy:"source",linkTargetsBy:["target"],linkColorBy:"color",linkColorStrategy:"direct",linkDefaultColor:g?"#6B7280":"#9CA3AF",linkWidthBy:"width",linkWidthStrategy:"direct",linkDefaultWidth:1,linkWidthScale:1,linkGreyoutOpacity:.1}},ce,oe);if(v||!fe)return;console.log("[MeshGraph] Prepared data:",{points:fe.points,links:fe.links,config:fe.cosmographConfig}),ea(fe.points??null),di(fe.links??null),wo(fe.cosmographConfig??{})}catch(ce){console.error("[MeshGraph] Data preparation failed:",ce)}},100);return()=>{v=!0,clearTimeout(W)}},[Bt,Ui,g]);const Iv=$.useCallback(v=>{v&&(Rt.current=v,v.start(),setTimeout(()=>{v.fitView(sh)},1500))},[]),BI=$.useCallback(()=>{var v;(v=Rt.current)==null||v.fitView(sh)},[]),FI=$.useCallback(()=>{const v=Rt.current;v&&(A?v.pause():v.start(),L(!A))},[A]),cd=$.useCallback(async v=>{const j=Rt.current,W=As.get(v);if(W){if(j)try{const ce=await j.getPointIndicesByIds([v]);ce&&ce.length>0&&ce[0]!==void 0&&(j.zoomToPoint(ce[0],Dee,2.5),j.selectPoint(ce[0],!1,!0))}catch{}te(null),H({hash:v,name:W.name,prefix:W.prefix,nodeClass:W.nodeClass,packetCount:W.packetCount,edgeCount:ld.get(v)??0,degree:W.degree,betweenness:W.betweenness,communityId:W.communityId,isLocal:W.isLocal,isHub:W.isHub,isGateway:W.isGateway,isBackbone:W.isBackbone,isMobile:W.isMobile,isZeroHop:W.isZeroHop,isGhost:W.isGhost,isInLoop:W.isInLoop,activityLevel:W.activityLevel,prefixConfidence:W.prefixConfidence,hasCollision:W.hasCollision,inDegree:W.inDegree,outDegree:W.outDegree,avgRssi:W.avgRssi,avgSnr:W.avgSnr})}},[As,ld]),Lv=$.useRef(null);$.useEffect(()=>{Lv.current=yi},[yi]);const Rv=$.useCallback(v=>{var ce;if(v===void 0){te(null);return}const j=Ra.current[v];if(!j)return;const W=(ce=Lv.current)==null?void 0:ce.get(j.key);te(W&&!j.linkBudget?{...j,linkBudget:W}:j),H(null)},[]),Pv=$.useCallback(async(v,j,W)=>{var oe;if(v===void 0){H(null),Li(null),(oe=Rt.current)==null||oe.unselectAllPoints();return}te(null);const ce=Rt.current;if(ce)try{const Ze=await ce.getPointIdsByIndices([v]);if(!Ze||Ze.length===0)return;const fe=Ze[0],Ee=As.get(fe);if(!Ee)return;ce.selectPoint(v,!1,!0),H({hash:fe,name:Ee.name,prefix:Ee.prefix,nodeClass:Ee.nodeClass,packetCount:Ee.packetCount,edgeCount:ld.get(fe)??0,degree:Ee.degree,betweenness:Ee.betweenness,communityId:Ee.communityId,isLocal:Ee.isLocal,isHub:Ee.isHub,isGateway:Ee.isGateway,isBackbone:Ee.isBackbone,isMobile:Ee.isMobile,isZeroHop:Ee.isZeroHop,isGhost:Ee.isGhost,isInLoop:Ee.isInLoop,activityLevel:Ee.activityLevel,prefixConfidence:Ee.prefixConfidence,hasCollision:Ee.hasCollision,inDegree:Ee.inDegree,outDegree:Ee.outDegree,avgRssi:Ee.avgRssi,avgSnr:Ee.avgSnr})}catch{}},[As,ld]),ic=$.useMemo(()=>{if(!J||!se.trim())return[];const v=se.toLowerCase();return tn.filter(j=>{var W;return j.prefix.toLowerCase().includes(v)||((W=j.name)==null?void 0:W.toLowerCase().includes(v))||j.id.toLowerCase().includes(v)}).slice(0,8)},[tn,se,J]),Nv=$.useCallback(v=>{F(!1),R(""),cd(v.id)},[cd]),Dv=$.useCallback(()=>{he(v=>!v)},[]),zI=$.useCallback(v=>{q(j=>{const W=new Set(j);return W.has(v)?W.delete(v):W.add(v),W})},[]),UI=$.useCallback(()=>{He(v=>{const j=!v,W=Rt.current;return W&&W.start(.5),j})},[]),$I=$.useCallback(()=>{Qo(v=>{const j=!v,W=Rt.current;return W&&(j?W.activatePolygonalSelection():(W.deactivatePolygonalSelection(),Li(null),W.unselectAllPoints())),j})},[]),Mv=$.useCallback(async()=>{const v=Rt.current;if(!v)return;await new Promise(Ut=>setTimeout(Ut,80));const j=v.getSelectedPointIndices();if(!j||j.length===0){Li(null);return}const W=await v.getPointIdsByIndices(j);if(!W||W.length===0){Li(null);return}const ce=new Set(W);let oe=0,Ze=0;for(const Ut of Ra.current)ce.has(Ut.source)&&ce.has(Ut.target)&&(oe++,Ze+=Ut.confidence);let fe=0;const Ee={},ji={};for(const Ut of W){const ye=As.get(Ut);ye&&(fe+=ye.betweenness,Ee[ye.communityId]=(Ee[ye.communityId]??0)+1,ji[ye.nodeClass]=(ji[ye.nodeClass]??0)+1)}const nn=new Set;for(const Ut of W){const ye=As.get(Ut);ye&&nn.add(ye.prefix.toLowerCase())}let ns=0,ss=0;for(const Ut of p)if(Ut.hops.length>=2){const ye=Ut.hops[0].toLowerCase(),Yt=Ut.hops[Ut.hops.length-1].toLowerCase();nn.has(ye)&&nn.has(Yt)&&(ns+=Ut.healthScore,ss++)}Li({nodeCount:W.length,edgeCount:oe,avgBetweenness:W.length>0?fe/W.length:0,avgConfidence:oe>0?Ze/oe:0,avgPathHealth:ss>0?ns/ss:null,communities:Ee,nodeClasses:ji}),H(null),te(null)},[As,p]),Ov=$.useCallback(()=>{var v;Li(null),(v=Rt.current)==null||v.unselectAllPoints()},[]),Bv=$.useMemo(()=>{var Ut;if(!B)return null;const v=B.hash,j=new Set;for(const ye of Ui)ye.source===v?j.add(ye.target):ye.target===v&&j.add(ye.source);if(j.size===0)return{clusteringCoeff:0,avgNeighborBetweenness:0,neighborCount:0,avgEdgeConfidence:0,avgRssi:null,avgSnr:null};let W=0;for(const ye of Ui)j.has(ye.source)&&j.has(ye.target)&&W++;const ce=j.size,oe=ce>1?2*W/(ce*(ce-1)):0;let Ze=0;for(const ye of j)Ze+=((Ut=As.get(ye))==null?void 0:Ut.betweenness)??0;let fe=0,Ee=0,ji=0,nn=0,ns=0,ss=0;for(const ye of Ui)(ye.source===v||ye.target===v)&&(fe+=ye.confidence,Ee++,ye.avgRssi!=null&&(ji+=ye.avgRssi,nn++),ye.avgSnr!=null&&(ns+=ye.avgSnr,ss++));return{clusteringCoeff:Math.min(1,oe),avgNeighborBetweenness:Ze/ce,neighborCount:ce,avgEdgeConfidence:Ee>0?fe/Ee:0,avgRssi:nn>0?ji/nn:null,avgSnr:ss>0?ns/ss:null}},[B,Ui,As]),Fv=$.useMemo(()=>!B||!m?null:m.get(B.hash)??null,[B,m]),zv=$.useMemo(()=>{if(!B)return[];const v=B.hash,j=[],W=new Set;for(const ce of Ui){let oe=null;if(ce.source===v?oe=ce.target:ce.target===v&&(oe=ce.source),!oe||W.has(oe))continue;W.add(oe);const Ze=As.get(oe);j.push({hash:oe,prefix:(Ze==null?void 0:Ze.prefix)??oe.slice(2,4).toUpperCase(),name:(Ze==null?void 0:Ze.name)??null,edgeConfidence:ce.confidence,edgeType:ce.edgeType,avgRssi:ce.avgRssi,avgSnr:ce.avgSnr})}return j.sort((ce,oe)=>oe.edgeConfidence-ce.edgeConfidence),j},[B,Ui,As]),Uv=$.useCallback(async()=>{const v=Rt.current;if(!v||!B)return;const j=await v.getPointIndicesByIds([B.hash]);if(!j||j[0]===void 0)return;const W=j[0],ce=v.getConnectedPointIndices(W)??[],oe=new Set([W,...ce]);for(const fe of ce){const Ee=v.getConnectedPointIndices(fe)??[];for(const ji of Ee)oe.add(ji)}const Ze=Array.from(oe);v.selectPoints(Ze),v.fitViewByIndices(Ze,sh,.15)},[B]);$.useEffect(()=>{if(!Zn)return;const v=j=>{var W,ce;j.key==="Escape"&&(Qo(!1),(W=Rt.current)==null||W.deactivatePolygonalSelection(),Li(null),(ce=Rt.current)==null||ce.unselectAllPoints())};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[Zn]);const jI=$.useCallback((v,j)=>{a&&(qJ(a,{format:v,dataset:j}),Ri(!1))},[a]),$i=$.useMemo(()=>{if(!a||!p.length)return null;const v=a.edges??[];return v.length===0?null:Lee(p,v)},[a,p]),So=$.useMemo(()=>{const v=a==null?void 0:a.edges;if(!v||v.length===0||!c||c.size<3)return null;const j=Array.from(c.keys());return RL(v,j)},[a==null?void 0:a.edges,c]),ud=$.useMemo(()=>{if(it!=="louvain")return null;const v=a==null?void 0:a.edges;if(!v||v.length===0||!c||c.size<3)return null;const j=Array.from(c.keys());return hS(v,j,er)},[it,a==null?void 0:a.edges,c,er]);$.useEffect(()=>{if(!a)return;const v=new Map;for(const[W,ce]of a.nodeMetrics)v.set(W,ce.name);const j=xo.current.update(a,v);j.totalCount>0&&(Qs(xo.current.getLog()),Zt(W=>W+j.totalCount))},[a]);const HI=$.useCallback(()=>{Zt(0),Dr(v=>!v)},[]),Fr=$.useMemo(()=>Mee(So,g),[So,g]),dd=f.jsxs("div",{className:"absolute top-0 left-0 right-0 z-20 px-4 py-3 pointer-events-none flex items-start justify-between",children:[f.jsxs("h1",{className:"type-title text-fg-primary flex items-center gap-2 sm:gap-3 pointer-events-auto",children:[f.jsx(c0,{className:"w-5 h-5 sm:w-6 sm:h-6 text-icon-page-title"}),f.jsx("span",{children:"MeshGraph"}),f.jsx(Di,{color:"violet",compact:!0,children:"Analytics"})]}),Fr&&f.jsx(be,{content:f.jsxs("div",{className:"max-w-xs space-y-2",children:[f.jsx("div",{className:"font-semibold text-fg-primary",children:"Mesh Resilience Score"}),f.jsx("div",{className:"text-fg-secondary",children:"Derived from the Fiedler eigenvalue (λ₂) — the second-smallest eigenvalue of the graph Laplacian. Measures how well-connected the mesh is and how resistant it is to partitioning."}),f.jsxs("div",{className:"space-y-0.5 font-mono text-[10px]",children:[f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Raw λ₂"}),f.jsx("span",{className:"text-fg-primary tabular-nums",children:(So==null?void 0:So.toFixed(6))??"—"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Score"}),f.jsxs("span",{className:"tabular-nums",style:{color:Fr.color},children:[Fr.score,"/100"]})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Grade"}),f.jsx("span",{className:"capitalize",style:{color:Fr.color},children:Fr.grade})]})]}),f.jsxs("div",{className:"pt-1 border-t border-edge-subtle/30 space-y-0.5 text-[10px]",children:[f.jsx("div",{className:"text-fg-muted font-medium",children:"Grade thresholds"}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{style:{color:el.excellent[0]},children:"Excellent"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"80-100 (λ₂ > 0.3)"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{style:{color:el.good[0]},children:"Good"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"55-79 (λ₂ 0.03-0.3)"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{style:{color:el.fair[0]},children:"Fair"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"30-54 (λ₂ 0.003-0.03)"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{style:{color:el.poor[0]},children:"Poor"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"10-29 (λ₂ 0.0001-0.003)"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{style:{color:el.critical[0]},children:"Critical"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"<10 (λ₂ ≈ 0)"})]})]}),f.jsx("div",{className:"text-[10px] text-fg-muted italic",children:"Near-zero λ₂ = one bridge away from network partition. Log-scale mapping: small λ₂ changes at low values have outsized impact."})]}),children:f.jsxs("div",{className:"pointer-events-auto surface-control radius-inner px-3 py-1.5 flex items-center gap-2 cursor-help",children:[f.jsxs("div",{className:"flex items-baseline gap-1.5",children:[f.jsx("span",{className:"text-[10px] text-fg-muted uppercase tracking-wider",children:"Resilience"}),f.jsx("span",{className:"text-lg font-semibold tabular-nums leading-none",style:{color:Fr.color},children:Fr.score})]}),f.jsx("div",{className:"w-12 h-1.5 rounded-full bg-subtle-fill overflow-hidden",children:f.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${Fr.score}%`,backgroundColor:Fr.color}})})]})})]}),is=(v,j=!1)=>{const W="flex flex-col items-center gap-0.5 px-1.5 py-1 radius-inner transition-all duration-100 active:scale-95";return v&&j?`${W} bg-status-warning/15 text-status-warning shadow-inner`:v?`${W} bg-sys-blue/20 text-sys-blue shadow-inner`:`${W} hover:bg-white/5 hover:scale-105 text-fg-secondary`},nc=f.jsx("div",{className:"w-px h-6 bg-border-subtle/40 mx-0.5 shrink-0"}),$v=f.jsxs("div",{className:"absolute top-12 right-3 z-10 flex items-center gap-0.5 surface-control radius-inner px-1.5 py-1",children:[f.jsx(be,{content:"Visible nodes / edges in the graph",children:f.jsxs("span",{className:"text-[9px] text-fg-muted tabular-nums mr-1.5 leading-none cursor-help",children:[Bt.length,f.jsx("br",{}),Ui.length]})}),nc,f.jsx(be,{content:Z?"Hide labels (L)":"Show labels (L)",children:f.jsxs("button",{onClick:()=>Se(v=>!v),className:is(!Z,!0),children:[Z?f.jsx(HL,{className:"w-3.5 h-3.5"}):f.jsx(PL,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Lbl"})]})}),f.jsx(be,{content:We?"Disable clustering":"Community clustering",children:f.jsxs("button",{onClick:UI,className:is(We),children:[f.jsx(ZL,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Grp"})]})}),f.jsx(be,{content:Zn?"Exit lasso (Esc)":"Lasso selection",children:f.jsxs("button",{onClick:$I,className:is(Zn,!0),children:[f.jsx(AS,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Sel"})]})}),nc,f.jsx(be,{content:"Legend",children:f.jsxs("button",{onClick:()=>Je(v=>!v),className:is(xe),children:[f.jsx(g0,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Map"})]})}),f.jsx(be,{content:"Search (/)",children:f.jsxs("button",{onClick:()=>{F(!0),setTimeout(()=>{var v;return(v=Js.current)==null?void 0:v.focus()},50)},className:is(J),children:[f.jsx(_0,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Fnd"})]})}),nc,f.jsx(be,{content:A?"Pause (Space)":"Play (Space)",children:f.jsxs("button",{onClick:FI,className:is(!A),children:[A?f.jsx(_L,{className:"w-3.5 h-3.5 text-sys-green"}):f.jsx(yL,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:A?"Run":"Stop"})]})}),f.jsx(be,{content:"Fit view (F)",children:f.jsxs("button",{onClick:BI,className:is(!1),children:[f.jsx(XL,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Fit"})]})}),nc,f.jsx(be,{content:ai?"Disable link budget":"Link budget overlay",children:f.jsxs("button",{onClick:()=>vo(v=>!v),className:is(ai),children:[f.jsx(dg,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"RF"})]})}),f.jsx(be,{content:"Anomaly log",children:f.jsxs("button",{onClick:HI,className:`relative ${is(es,!0)}`,children:[f.jsx(hd,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Alert"}),Jo>0&&f.jsx("span",{className:"absolute -top-1 -right-0.5 w-3 h-3 rounded-full bg-status-danger text-[7px] font-bold text-white flex items-center justify-center",children:Jo>9?"9+":Jo})]})}),f.jsx(be,{content:"Export topology",children:f.jsxs("button",{onClick:()=>Ri(v=>!v),className:is(en),children:[f.jsx(y0,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Exp"})]})}),f.jsx(be,{content:"Settings",children:f.jsxs("button",{onClick:()=>ie(v=>!v),className:is(X),children:[f.jsx(b0,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Cfg"})]})}),nc,f.jsx(be,{content:M?"Exit fullscreen":"Fullscreen",children:f.jsxs("button",{onClick:Dv,className:is(M),children:[M?f.jsx(f0,{className:"w-3.5 h-3.5"}):f.jsx(kS,{className:"w-3.5 h-3.5"}),f.jsx("span",{className:"text-[7px] uppercase tracking-wider leading-none",children:"Max"})]})})]}),jv=f.jsxs(nh,{id:"settings",title:"Graph Settings",icon:f.jsx(b0,{}),open:X,onClose:()=>ie(!1),defaultPosition:{x:typeof window<"u"?window.innerWidth-308:600,y:60},defaultSize:{width:288,height:420},minSize:{width:260,height:200},maxSize:{width:400,height:600},headerActions:f.jsx(be,{content:"Reset to defaults",children:f.jsx("button",{onClick:wn,className:"p-0.5 radius-badge hover-bg transition-base",children:f.jsx(v0,{className:"w-2.5 h-2.5 text-fg-muted"})})}),children:[f.jsx("div",{className:"flex border-b border-edge-subtle",children:["simulation","points","links","rendering"].map(v=>f.jsx("button",{onClick:()=>ae(v),className:`flex-1 px-2 py-1.5 text-[10px] font-medium capitalize transition-colors ${ee===v?"text-sys-blue border-b-2 border-sys-blue":"text-fg-muted hover:text-fg-secondary"}`,children:v},v))}),f.jsxs("div",{className:"p-3 space-y-3",children:[ee==="simulation"&&f.jsxs(f.Fragment,{children:[f.jsx(fi,{label:"Gravity",value:ut.simulationGravity,onChange:v=>st("simulationGravity",v),min:0,max:1,step:.01}),f.jsx(fi,{label:"Repulsion",value:ut.simulationRepulsion,onChange:v=>st("simulationRepulsion",v),min:0,max:5,step:.1}),f.jsx(fi,{label:"Link Spring",value:ut.simulationLinkSpring,onChange:v=>st("simulationLinkSpring",v),min:0,max:2,step:.05}),f.jsx(fi,{label:"Link Distance",value:ut.simulationLinkDistance,onChange:v=>st("simulationLinkDistance",v),min:1,max:100,step:1}),f.jsx(fi,{label:"Friction",value:ut.simulationFriction,onChange:v=>st("simulationFriction",v),min:0,max:1,step:.01}),f.jsx(fi,{label:"Center Force",value:ut.simulationCenter,onChange:v=>st("simulationCenter",v),min:0,max:1,step:.01}),f.jsx(fi,{label:"Decay",value:ut.simulationDecay,onChange:v=>st("simulationDecay",v),min:100,max:2e4,step:100}),f.jsx(fi,{label:"Repulsion Theta",value:ut.simulationRepulsionTheta,onChange:v=>st("simulationRepulsionTheta",v),min:.1,max:3,step:.05}),f.jsx(fi,{label:"Mouse Repulsion",value:ut.simulationRepulsionFromMouse,onChange:v=>st("simulationRepulsionFromMouse",v),min:0,max:10,step:.5})]}),ee==="points"&&f.jsxs(f.Fragment,{children:[f.jsx(fi,{label:"Size Scale",value:ut.pointSizeScale,onChange:v=>st("pointSizeScale",v),min:.1,max:5,step:.1}),f.jsx(fi,{label:"Opacity",value:ut.pointOpacity,onChange:v=>st("pointOpacity",v),min:0,max:1,step:.05}),f.jsx(fi,{label:"Greyout Opacity",value:ut.pointGreyoutOpacity,onChange:v=>st("pointGreyoutOpacity",v),min:0,max:1,step:.05}),f.jsx(Va,{label:"Scale on Zoom",checked:ut.scalePointsOnZoom,onChange:v=>st("scalePointsOnZoom",v)}),f.jsx(Va,{label:"Hover Ring",checked:ut.renderHoveredPointRing,onChange:v=>st("renderHoveredPointRing",v)})]}),ee==="links"&&f.jsxs(f.Fragment,{children:[f.jsx(Va,{label:"Show Links",checked:ut.renderLinks,onChange:v=>st("renderLinks",v)}),f.jsx(Va,{label:"Curved Links",checked:ut.curvedLinks,onChange:v=>st("curvedLinks",v)}),f.jsx(Va,{label:"Show Arrows",checked:ut.linkDefaultArrows,onChange:v=>st("linkDefaultArrows",v)}),f.jsx(fi,{label:"Width Scale",value:ut.linkWidthScale,onChange:v=>st("linkWidthScale",v),min:.1,max:5,step:.1}),f.jsx(fi,{label:"Opacity",value:ut.linkOpacity,onChange:v=>st("linkOpacity",v),min:0,max:1,step:.05}),f.jsx(fi,{label:"Greyout Opacity",value:ut.linkGreyoutOpacity,onChange:v=>st("linkGreyoutOpacity",v),min:0,max:1,step:.05}),ut.curvedLinks&&f.jsx(fi,{label:"Curve Weight",value:ut.curvedLinkWeight,onChange:v=>st("curvedLinkWeight",v),min:0,max:1,step:.05}),ut.linkDefaultArrows&&f.jsx(fi,{label:"Arrow Size",value:ut.linkArrowsSizeScale,onChange:v=>st("linkArrowsSizeScale",v),min:.1,max:3,step:.1}),f.jsx(Va,{label:"Scale on Zoom",checked:ut.scaleLinksOnZoom,onChange:v=>st("scaleLinksOnZoom",v)})]}),ee==="rendering"&&f.jsxs(f.Fragment,{children:[f.jsx(fi,{label:"Space Size",value:ut.spaceSize,onChange:v=>st("spaceSize",v),min:1024,max:16384,step:512}),f.jsx("div",{className:"pt-2 border-t border-edge-subtle/50",children:f.jsx("p",{className:"text-[9px] text-fg-muted",children:"Space size defines the simulation boundary. Larger values allow more spread."})})]})]})]}),VI=[{label:"Full Topology (JSON)",format:"json",dataset:"full",desc:"All data: nodes, edges, paths, TX delay"},{label:"Gephi Graph (GEXF)",format:"gexf",dataset:"full",desc:"Import into Gephi for advanced analysis"},{label:"Nodes (CSV)",format:"csv",dataset:"nodes",desc:"Node metrics: centrality, class, signal"},{label:"Edges (CSV)",format:"csv",dataset:"edges",desc:"Edge metrics: confidence, symmetry, type"},{label:"Path Health (CSV)",format:"csv",dataset:"pathHealth",desc:"Route health scores and trends"},{label:"TX Delay (CSV)",format:"csv",dataset:"txDelay",desc:"TX delay recommendations per node"}],Hv=f.jsxs(nh,{id:"export",title:"Export Topology",icon:f.jsx(y0,{}),open:en,onClose:()=>Ri(!1),defaultPosition:{x:typeof window<"u"?window.innerWidth-280:600,y:100},defaultSize:{width:256,height:320},minSize:{width:220,height:150},autoHeight:!0,children:[f.jsx("div",{className:"py-1",children:VI.map(({label:v,format:j,dataset:W,desc:ce})=>f.jsxs("button",{onClick:()=>jI(j,W),className:"w-full flex flex-col px-3 py-2 text-left hover-bg transition-base",children:[f.jsx("span",{className:"text-[11px] font-medium text-fg-primary",children:v}),f.jsx("span",{className:"text-[9px] text-fg-muted",children:ce})]},`${j}-${W}`))}),f.jsx("div",{className:"px-3 py-1.5 border-t border-edge-subtle",children:f.jsxs("span",{className:"text-[9px] text-fg-muted",children:[((s0=a==null?void 0:a.nodeMetrics)==null?void 0:s0.size)??0," nodes · ",((r0=a==null?void 0:a.validatedEdges)==null?void 0:r0.length)??0," edges"]})})]}),GI={info:{dot:"bg-sys-blue",text:"text-fg-secondary"},warning:{dot:"bg-status-warning",text:"text-status-warning"},critical:{dot:"bg-status-danger",text:"text-status-danger"}},WI={"edge-appeared":"Link Discovered","edge-disappeared":"Link Lost","ghost-appeared":"Ghost Discovered","ghost-disappeared":"Ghost Resolved","betweenness-shift":"Traffic Rerouting","community-change":"Community Change","class-change":"Role Change","node-appeared":"Node Appeared","node-disappeared":"Node Dropped","snr-degradation":"SNR Degradation","asymmetry-shift":"Asymmetry Shift"},Pi=(v,j,W)=>j==null||j===""?null:f.jsxs("div",{className:"flex justify-between gap-2",children:[f.jsx("span",{className:"text-fg-muted",children:v}),f.jsx("span",{className:`tabular-nums text-right ${W??"text-fg-secondary"}`,children:j})]}),YI=v=>{const j=[];return v.isZeroHop&&j.push({label:"Zero-Hop",color:"text-status-warning"}),v.isDirectPath&&j.push({label:"Direct",color:"text-sys-blue"}),v.isBackbone&&j.push({label:"Backbone",color:"text-fg-primary"}),v.isLoop&&j.push({label:"Loop",color:"text-sys-indigo"}),j.length===0?null:f.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:j.map(W=>f.jsx("span",{className:`text-[8px] font-medium uppercase tracking-wider px-1 py-px radius-badge bg-subtle-fill ${W.color}`,children:W.label},W.label))})},qI=(v,j)=>f.jsxs("div",{className:"text-[9px] space-y-0.5",children:[(v.fromClass||v.toClass)&&f.jsxs("div",{className:"flex items-center gap-1 text-fg-muted",children:[f.jsx("span",{className:"capitalize",children:v.fromClass??"?"}),f.jsx("span",{className:"text-fg-muted/40",children:"↔"}),f.jsx("span",{className:"capitalize",children:v.toClass??"?"})]}),j==="edge-appeared"&&v.packetCount>0&&f.jsxs(f.Fragment,{children:[Pi("Packets",v.packetCount),Pi("Confidence",`${(v.confidence*100).toFixed(0)}%`,v.confidence>=.8?"text-sys-green":v.confidence>=.5?"text-sys-indigo":"text-signal-poor"),Pi("Symmetry",`${(v.symmetryRatio*100).toFixed(0)}%`)]}),v.isZeroHop&&v.avgRssi!=null&&Pi("RSSI",`${v.avgRssi.toFixed(0)} dBm`),v.isZeroHop&&v.avgSnr!=null&&Pi("SNR",`${v.avgSnr.toFixed(1)} dB`),v.fromBetweenness!=null&&v.fromBetweenness>.01&&Pi(`${v.fromName??"A"} centrality`,v.fromBetweenness.toFixed(3)),v.toBetweenness!=null&&v.toBetweenness>.01&&Pi(`${v.toName??"B"} centrality`,v.toBetweenness.toFixed(3)),YI(v)]}),XI=v=>f.jsxs("div",{className:"text-[9px] space-y-0.5",children:[f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("span",{className:"capitalize font-medium text-fg-secondary",children:v.nodeClass}),v.isZeroHop&&f.jsx("span",{className:"text-[8px] font-medium uppercase tracking-wider px-1 py-px radius-badge bg-subtle-fill text-status-warning",children:"Neighbor"})]}),Pi("Degree",v.degree),v.betweenness>.01&&Pi("Betweenness",v.betweenness.toFixed(3)),Pi("Packets",v.packetCount),Pi("Community",`#${v.communityId}`),Pi("Activity",v.activityLevel),v.avgRssi!=null&&Pi("RSSI",`${v.avgRssi.toFixed(0)} dBm`),v.avgSnr!=null&&Pi("SNR",`${v.avgSnr.toFixed(1)} dB`)]}),KI=v=>f.jsxs("div",{className:"text-[9px] space-y-0.5",children:[v.previousValue!=null&&v.currentValue!=null&&f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"text-fg-muted font-mono",children:typeof v.previousValue=="number"?v.previousValue.toFixed(3):v.previousValue}),f.jsx("span",{className:"text-fg-muted/40",children:"→"}),f.jsx("span",{className:"text-fg-secondary font-mono",children:typeof v.currentValue=="number"?v.currentValue.toFixed(3):v.currentValue}),typeof v.previousValue=="number"&&typeof v.currentValue=="number"&&f.jsxs("span",{className:v.currentValue>v.previousValue?"text-sys-green":"text-signal-poor",children:["(",v.currentValue>v.previousValue?"+":"",(v.currentValue-v.previousValue).toFixed(3),")"]})]}),v.nodeDetail&&f.jsxs(f.Fragment,{children:[Pi("Class",v.nodeDetail.nodeClass),Pi("Degree",v.nodeDetail.degree),v.nodeDetail.betweenness>.01&&Pi("Betweenness",v.nodeDetail.betweenness.toFixed(3))]})]}),ZI=$.useCallback(v=>{ks(j=>j===v?null:v)},[]),Vv=f.jsxs(nh,{id:"anomaly",title:"Anomaly Log",icon:f.jsx(hd,{}),open:es,onClose:()=>Dr(!1),defaultPosition:{x:typeof window<"u"?window.innerWidth-328:600,y:100},defaultSize:{width:308,height:400},minSize:{width:260,height:180},maxSize:{width:440,height:700},headerActions:xn.length>0?f.jsx("button",{onClick:()=>{xo.current.clear(),Qs([]),ks(null)},className:"p-0.5 radius-badge hover-bg transition-base",title:"Clear all",children:f.jsx(v0,{className:"w-2.5 h-2.5 text-fg-muted"})}):void 0,children:[xn.length===0?f.jsxs("div",{className:"px-3 py-6 text-center",children:[f.jsx(hd,{className:"w-5 h-5 text-fg-muted mx-auto mb-1.5"}),f.jsx("p",{className:"text-[11px] text-fg-muted",children:"No anomalies detected yet"}),f.jsx("p",{className:"text-[9px] text-fg-muted/60 mt-0.5",children:"Changes appear after topology recomputes"})]}):f.jsx("div",{className:"overflow-y-auto",children:xn.slice(0,50).map(v=>{const j=GI[v.severity],W=bL(v.detectedAt/1e3),ce=Ot===v.id,oe=!!(v.edgeDetail||v.nodeDetail||v.previousValue!=null);return f.jsxs("div",{className:`border-b border-edge-subtle/50 last:border-0 transition-colors ${oe?"cursor-pointer hover-bg":""} ${ce?"bg-subtle-fill/50":""}`,onClick:oe?()=>ZI(v.id):void 0,children:[f.jsxs("div",{className:"flex items-start gap-2 px-3 py-1.5",children:[f.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 mt-1.5 ${j.dot}`}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("p",{className:`text-[10px] leading-tight ${j.text}`,children:v.description}),f.jsxs("p",{className:"text-[9px] text-fg-muted/60 mt-0.5",children:[WI[v.category]??v.category," · ",W]})]}),oe&&f.jsx(Rc,{className:`w-3 h-3 text-fg-muted/40 shrink-0 mt-0.5 transition-transform duration-150 ${ce?"rotate-180":""}`})]}),ce&&f.jsx("div",{className:"px-3 pb-2 pl-6",children:f.jsxs("div",{className:"border-l-2 border-edge-subtle/60 pl-2 py-0.5",children:[v.edgeDetail&&qI(v.edgeDetail,v.category),v.nodeDetail&&!v.edgeDetail&&(v.category==="node-appeared"||v.category==="node-disappeared")&&XI(v.nodeDetail),(v.category==="betweenness-shift"||v.category==="community-change"||v.category==="class-change")&&KI(v)]})})]},v.id)})}),xn.length>0&&f.jsx("div",{className:"px-3 py-1.5 border-t border-edge-subtle",children:f.jsxs("span",{className:"text-[9px] text-fg-muted",children:[xn.length," total · showing ",Math.min(xn.length,50)]})})]}),QI=[["local","Local"],["hub","Hub"],["gateway","Gateway"],["backbone","Backbone"],["neighbor","Neighbor"],["mobile","Mobile"],["ghost","Ghost"],["standard","Standard"]],JI=[{type:"zero-hop",label:"Zero-Hop RF"},{type:"direct-path",label:"Direct Path"},{type:"loop",label:"Loop"},{type:"backbone",label:"Backbone"},{type:"standard",label:"Standard"},{type:"ghost",label:"Ghost"}],eL=$.useMemo(()=>{const v={};for(const j of E)v[j.edgeType]=(v[j.edgeType]??0)+1;return v},[E]),Gv=f.jsxs(nh,{id:"legend",title:"Legend",icon:f.jsx(g0,{}),open:xe,onClose:()=>Je(!1),defaultPosition:{x:12,y:60},defaultSize:{width:224,height:400},minSize:{width:200,height:150},maxSize:{width:360,height:700},autoHeight:!0,children:[f.jsxs("div",{className:"border-b border-edge-subtle",children:[f.jsxs("button",{onClick:()=>bt(v=>!v),className:"w-full flex items-center gap-1.5 px-3 py-1.5 text-[10px] font-medium text-fg-secondary hover-bg transition-base",children:[de?f.jsx(Rc,{className:"w-3 h-3"}):f.jsx(Hp,{className:"w-3 h-3"}),"Nodes",f.jsx("span",{className:"text-fg-muted ml-auto tabular-nums",children:Bt.length})]}),de&&f.jsx("div",{className:"px-2 pb-2 space-y-0.5",children:QI.map(([v,j])=>{const W=d[v]??0;if(W===0&&v!=="local")return null;const ce=Pe.has(v);return f.jsx(be,{content:jee[v],children:f.jsxs("button",{onClick:()=>zI(v),className:`w-full flex items-center gap-2 px-2 py-1 radius-badge transition-base text-left ${ce?"opacity-40":"hover-bg"}`,children:[f.jsx("span",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{backgroundColor:_[v]}}),f.jsx("span",{className:"text-[10px] text-fg-secondary flex-1",children:j}),f.jsx("span",{className:"text-[10px] text-fg-muted tabular-nums",children:W})]})},v)})})]}),f.jsxs("div",{className:"border-b border-edge-subtle",children:[f.jsxs("button",{onClick:()=>ht(v=>!v),className:"w-full flex items-center gap-1.5 px-3 py-1.5 text-[10px] font-medium text-fg-secondary hover-bg transition-base",children:[Xe?f.jsx(Rc,{className:"w-3 h-3"}):f.jsx(Hp,{className:"w-3 h-3"}),"Edges",f.jsx("span",{className:"text-fg-muted ml-auto tabular-nums",children:Ui.length})]}),Xe&&f.jsx("div",{className:"px-2 pb-2 space-y-0.5",children:JI.map(({type:v,label:j})=>{const W=eL[v]??0;if(W===0)return null;const ce=xS(v,.8,g);return f.jsx(be,{content:Gee[v],children:f.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 cursor-help",children:[f.jsx("span",{className:"w-4 h-0.5 shrink-0 rounded-full",style:{backgroundColor:ce}}),f.jsx("span",{className:"text-[10px] text-fg-secondary flex-1",children:j}),f.jsx("span",{className:"text-[10px] text-fg-muted tabular-nums",children:W})]})},v)})})]}),ai&&ft&&f.jsxs("div",{className:"border-b border-edge-subtle",children:[f.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-medium text-sys-green flex items-center gap-1.5",children:[f.jsx(dg,{className:"w-3 h-3"}),"Link Budget",f.jsxs("span",{className:"text-fg-muted ml-auto tabular-nums",children:[ft.analyzedEdges+ft.rssiOnlyEdges,"/",ft.totalEdges]})]}),f.jsxs("div",{className:"px-3 pb-2 space-y-0.5",children:[(()=>{const v=G&&G>1e5?G/1e6:G||915,j=Jn??Ce??12,W=zi??(ne&&ne>1e3?ne/1e3:ne||125),ce=ii??rt??5,oe=Es??At??22,Ze=kv(j,W,ce),fe=vn??Ze,Ee=kI(W*1e3),ji=On??Ee,nn=(et==null?void 0:et.filter(ye=>ye.isTraceEstimated).length)??0,ns=(et==null?void 0:et.filter(ye=>ye.isZeroHop).length)??0,ss=Es!=null||Jn!=null||zi!=null||ii!=null||vn!=null,Ut="w-10 px-1 py-0 text-[10px] text-right tabular-nums bg-subtle-fill border border-edge-subtle rounded text-fg-secondary focus:outline-none focus:border-sys-blue";return f.jsxs("div",{className:"pb-1 mb-1 border-b border-edge-subtle space-y-0.5",children:[f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx("span",{className:"text-fg-muted",children:"Frequency"}),f.jsxs("span",{className:"text-fg-secondary tabular-nums",children:[v.toFixed(3)," MHz"]})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px] gap-1",children:[f.jsx("span",{className:"text-fg-muted",children:"SF"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("select",{value:j,onChange:ye=>{const Yt=parseInt(ye.target.value,10);Cs(Yt===(Ce??12)?null:Yt)},className:Ut+" w-12 appearance-none",children:[7,8,9,10,11,12].map(ye=>f.jsxs("option",{value:ye,children:["SF",ye]},ye))}),Jn!=null&&f.jsx("button",{onClick:()=>Cs(null),className:"text-[8px] text-sys-blue hover:underline",title:"Reset",children:"↺"})]})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px] gap-1",children:[f.jsx("span",{className:"text-fg-muted",children:"BW"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("select",{value:W,onChange:ye=>{const Yt=parseFloat(ye.target.value),sc=ne&&ne>1e3?ne/1e3:ne||125;Ei(Yt===sc?null:Yt)},className:Ut+" w-14 appearance-none",children:[62.5,125,250,500].map(ye=>f.jsxs("option",{value:ye,children:[ye," kHz"]},ye))}),zi!=null&&f.jsx("button",{onClick:()=>Ei(null),className:"text-[8px] text-sys-blue hover:underline",title:"Reset",children:"↺"})]})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px] gap-1",children:[f.jsx("span",{className:"text-fg-muted",children:"CR"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("select",{value:ce,onChange:ye=>{const Yt=parseInt(ye.target.value,10);bn(Yt===(rt??5)?null:Yt)},className:Ut+" w-12 appearance-none",children:[5,6,7,8].map(ye=>f.jsxs("option",{value:ye,children:["4/",ye]},ye))}),ii!=null&&f.jsx("button",{onClick:()=>bn(null),className:"text-[8px] text-sys-blue hover:underline",title:"Reset",children:"↺"})]})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px] gap-1",children:[f.jsx("span",{className:"text-fg-muted",children:"TX Power"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("input",{type:"number",min:1,max:36,step:1,value:oe,onChange:ye=>{const Yt=parseInt(ye.target.value,10);isNaN(Yt)||Qn(Yt)},onBlur:ye=>{const Yt=parseInt(ye.target.value,10);if(isNaN(Yt)){Qn(null);return}Qn(Math.max(1,Math.min(36,Yt)))},className:Ut}),f.jsx("span",{className:"text-fg-muted",children:"dBm"}),Es!=null&&f.jsx("button",{onClick:()=>Qn(null),className:"text-[8px] text-sys-blue hover:underline",title:"Reset",children:"↺"})]})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px] gap-1",children:[f.jsx("span",{className:"text-fg-muted",children:"Sensitivity"}),f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("input",{type:"number",min:-150,max:-80,step:.5,value:Math.round(fe*10)/10,onChange:ye=>{const Yt=parseFloat(ye.target.value);isNaN(Yt)||Ts(Yt)},onBlur:ye=>{const Yt=parseFloat(ye.target.value);if(isNaN(Yt)){Ts(null);return}Ts(Math.max(-150,Math.min(-80,Yt)))},className:Ut+" w-12"}),f.jsx("span",{className:"text-fg-muted",children:"dBm"}),vn!=null&&f.jsx("button",{onClick:()=>Ts(null),className:"text-[8px] text-sys-blue hover:underline",title:"Reset",children:"↺"})]})]}),nn>0&&f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx("span",{className:"text-fg-muted",children:"Noise Floor"}),f.jsxs("span",{className:`text-fg-secondary tabular-nums ${On!=null?"":"italic text-fg-muted"}`,children:[ji.toFixed(1)," dBm",On!=null?"":" (est.)"]})]}),ss&&f.jsx("button",{onClick:()=>{Qn(null),Cs(null),Ei(null),bn(null),Ts(null)},className:"w-full text-[9px] text-sys-blue hover:underline text-center pt-0.5",children:"Reset all to radio config"}),(ns>0||nn>0)&&f.jsxs("div",{className:"flex items-center justify-between text-[10px] pt-0.5",children:[f.jsx("span",{className:"text-fg-muted",children:"Sources"}),f.jsxs("span",{className:"text-fg-secondary tabular-nums",children:[ns>0&&f.jsxs("span",{children:[ns," direct"]}),ns>0&&nn>0&&f.jsx("span",{className:"text-fg-muted",children:" · "}),nn>0&&f.jsxs("span",{className:"text-sys-indigo",children:[nn," trace"]})]})]})]})})(),ft.avgMarginDb!=null&&f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx("span",{className:"text-fg-muted",children:"Avg Margin"}),f.jsxs("span",{className:"text-fg-secondary tabular-nums",children:[ft.avgMarginDb>0?"+":"",ft.avgMarginDb.toFixed(1)," dB"]})]}),["excellent","good","fair","marginal","critical"].map(v=>{const j=ft.marginCounts[v];return j===0?null:f.jsxs("div",{className:"flex items-center gap-2 px-1 py-0.5",children:[f.jsx("span",{className:"w-3 h-0.5 shrink-0 rounded-full",style:{backgroundColor:Av[v]}}),f.jsx("span",{className:"text-[10px] text-fg-secondary flex-1 capitalize",children:v}),f.jsx("span",{className:"text-[10px] text-fg-muted tabular-nums",children:j})]},v)}),ft.anomalousCount>0&&f.jsxs("div",{className:"flex items-center justify-between text-[10px] pt-0.5",children:[f.jsx("span",{className:"text-status-warning",children:"Anomalous"}),f.jsx("span",{className:"text-status-warning tabular-nums",children:ft.anomalousCount})]})]})]}),$i&&$i.atRiskPaths.length>0&&f.jsxs("div",{className:"border-b border-edge-subtle",children:[f.jsxs("div",{className:"flex items-center",children:[f.jsxs("button",{onClick:()=>Te(v=>!v),className:"flex-1 flex items-center gap-1.5 px-3 py-1.5 text-[10px] font-medium text-status-warning hover-bg transition-base",children:[re?f.jsx(Rc,{className:"w-3 h-3"}):f.jsx(Hp,{className:"w-3 h-3"}),"At-Risk Paths",f.jsxs("span",{className:"text-fg-muted ml-auto tabular-nums",children:[$i.criticalCount>0&&f.jsxs("span",{className:"text-status-danger",children:[$i.criticalCount,"c"]}),$i.criticalCount>0&&$i.highCount>0&&" ",$i.highCount>0&&f.jsxs("span",{className:"text-status-warning",children:[$i.highCount,"h"]}),($i.criticalCount>0||$i.highCount>0)&&$i.moderateCount>0&&" ",$i.moderateCount>0&&f.jsxs("span",{className:"text-fg-muted",children:[$i.moderateCount,"m"]})]})]}),f.jsx(be,{content:f.jsxs("div",{className:"max-w-xs space-y-1.5",children:[f.jsx("div",{className:"font-semibold text-fg-primary",children:"Predictive Path Failure"}),f.jsx("div",{className:"text-fg-secondary text-[11px]",children:"Identifies paths at risk of failure by combining four weighted factors. Paths below the moderate threshold (35%) are not shown."}),f.jsxs("div",{className:"pt-1 border-t border-edge-subtle/30 space-y-0.5 text-[10px]",children:[f.jsx("div",{className:"text-fg-muted font-medium",children:"Factor weights"}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-secondary",children:"Declining usage"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"35%"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-secondary",children:"Weak link certainty"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"30%"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-secondary",children:"No alternate paths"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"20%"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-secondary",children:"Low signal margin"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"15%"})]})]}),f.jsxs("div",{className:"pt-1 border-t border-edge-subtle/30 space-y-0.5 text-[10px]",children:[f.jsx("div",{className:"text-fg-muted font-medium",children:"Risk thresholds"}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-status-danger",children:"Critical"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"≥75% — failure likely imminent"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-status-warning",children:"High"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"55-74% — significant risk"})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Moderate"}),f.jsx("span",{className:"text-fg-muted tabular-nums",children:"35-54% — worth monitoring"})]})]}),f.jsxs("div",{className:"pt-1 border-t border-edge-subtle/30 text-[10px] text-fg-muted font-mono space-y-0.5",children:[f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{children:"Edges analyzed"}),f.jsx("span",{className:"tabular-nums",children:$i.edgesAnalyzed})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{children:"With signal data"}),f.jsx("span",{className:"tabular-nums",children:$i.edgesWithSignal})]})]})]}),children:f.jsx("span",{className:"px-2 py-1.5 text-fg-muted cursor-help",children:f.jsx(hd,{className:"w-3 h-3"})})})]}),re&&f.jsx("div",{className:"px-2 pb-2 space-y-1",children:$i.atRiskPaths.slice(0,8).map(v=>{const j=v.riskLevel==="critical"?"#EF4444":v.riskLevel==="high"?"#F97316":"#FBBF24",W=v.urgency==="imminent"?"IMM":v.urgency==="near-term"?"NEAR":"WATCH";return f.jsx(be,{content:f.jsxs("div",{className:"max-w-xs space-y-1.5",children:[f.jsx("div",{className:"font-semibold text-fg-primary font-mono text-[11px]",children:v.hops.join(" → ")}),f.jsxs("div",{className:"space-y-0.5 text-[10px]",children:[f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Risk score"}),f.jsxs("span",{className:"font-semibold tabular-nums",style:{color:j},children:[(v.riskScore*100).toFixed(1),"%"]})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Health score"}),f.jsxs("span",{className:"text-fg-primary tabular-nums",children:[(v.healthScore*100).toFixed(0),"%"]})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Obs. trend"}),f.jsxs("span",{className:`tabular-nums ${v.observationTrend<0?"text-status-danger":"text-fg-secondary"}`,children:[v.observationTrend>0?"+":"",v.observationTrend.toFixed(3)]})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Alt. paths"}),f.jsx("span",{className:`tabular-nums ${v.alternatePathsCount===0?"text-status-danger":"text-fg-secondary"}`,children:v.alternatePathsCount})]}),f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-muted",children:"Urgency"}),f.jsx("span",{className:"capitalize",style:{color:j},children:v.urgency})]})]}),v.factors.length>0&&f.jsxs("div",{className:"pt-1 border-t border-edge-subtle/30 space-y-0.5 text-[10px]",children:[f.jsx("div",{className:"text-fg-muted font-medium",children:"Contributing factors"}),v.factors.map((ce,oe)=>f.jsxs("div",{className:"space-y-0.5",children:[f.jsxs("div",{className:"flex justify-between",children:[f.jsx("span",{className:"text-fg-secondary",children:ce.name}),f.jsxs("span",{className:"text-fg-muted tabular-nums",children:[(ce.score*ce.weight*100).toFixed(1),"% (",(ce.weight*100).toFixed(0),"w × ",(ce.score*100).toFixed(0),"s)"]})]}),f.jsx("div",{className:"text-fg-muted pl-1",children:ce.description})]},oe))]})]}),children:f.jsxs("div",{className:"px-2 py-1 radius-badge bg-subtle-fill/30 cursor-help",children:[f.jsxs("div",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{backgroundColor:j}}),f.jsx("span",{className:"text-[10px] text-fg-secondary font-mono truncate flex-1",children:v.hops.join(" → ")}),f.jsx("span",{className:"text-[8px] uppercase tracking-wide px-1 py-px radius-badge",style:{backgroundColor:`${j}20`,color:j},children:W}),f.jsxs("span",{className:"text-[10px] tabular-nums font-semibold",style:{color:j},children:[(v.riskScore*100).toFixed(0),"%"]})]}),f.jsx("div",{className:"flex flex-wrap gap-1 mt-0.5 pl-3",children:v.factors.map((ce,oe)=>f.jsxs("span",{className:"text-[8px] text-fg-muted",children:[ce.name," (",(ce.score*ce.weight*100).toFixed(0),"%)",oeVt(v=>v==="spectral"?"louvain":"spectral"),className:"text-sys-blue hover:underline cursor-pointer",children:it==="spectral"?"Spectral":"Louvain"})]}),it==="louvain"&&ud&&f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx(be,{content:"Louvain modularity score — quality of community partition (higher = better defined communities)",children:f.jsx("span",{className:"text-fg-muted cursor-help",children:"Modularity Q"})}),f.jsx("span",{className:"text-fg-secondary tabular-nums",children:ud.modularity.toFixed(4)})]}),it==="louvain"&&f.jsxs("div",{className:"mt-1.5 pt-1.5 border-t border-edge-subtle space-y-1.5",children:[f.jsx(fi,{label:"Resolution γ",value:me,onChange:nt,min:.01,max:5,step:.01}),f.jsx(fi,{label:"K-weight",value:ui,onChange:_i,min:.01,max:5,step:.01}),(me!==1||ui!==1)&&f.jsx("button",{onClick:()=>{nt(1),_i(1)},className:"w-full text-[10px] text-sys-blue hover:underline text-center",children:"Reset defaults"})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx(be,{content:"Redundant path cycles in the topology — indicates alternate routing options",children:f.jsx("span",{className:"text-fg-muted cursor-help",children:"Loops"})}),f.jsx("span",{className:"text-fg-secondary tabular-nums",children:((o0=a==null?void 0:a.loops)==null?void 0:o0.length)??0})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx(be,{content:"High-betweenness edges that carry disproportionate traffic flow",children:f.jsx("span",{className:"text-fg-muted cursor-help",children:"Backbone"})}),f.jsx("span",{className:"text-fg-secondary tabular-nums",children:((a0=a==null?void 0:a.backboneEdges)==null?void 0:a0.length)??0})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx(be,{content:"Unresolved prefix nodes inferred by Viterbi HMM from repeated path patterns",children:f.jsx("span",{className:"text-fg-muted cursor-help",children:"Ghosts"})}),f.jsx("span",{className:"text-fg-secondary tabular-nums",children:u.length})]}),f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx(be,{content:"Community-aware node coloring — groups nodes by cluster assignment",children:f.jsx("span",{className:"text-fg-muted cursor-help",children:"Clustering"})}),f.jsx("span",{className:`tabular-nums ${We?"text-sys-blue":"text-fg-muted"}`,children:We?"On":"Off"})]}),So!=null&&f.jsxs("div",{className:"flex items-center justify-between text-[10px]",children:[f.jsx(be,{content:"Algebraic connectivity — 2nd-smallest eigenvalue of the graph Laplacian. Near-zero = one bridge from network partition.",children:f.jsx("span",{className:"text-fg-muted cursor-help",children:"Fiedler λ₂"})}),f.jsx("span",{className:`tabular-nums ${So<.01?"text-status-warning":"text-fg-secondary"}`,children:So.toFixed(4)})]}),Pe.size>0&&f.jsxs("button",{onClick:()=>q(new Set),className:"w-full mt-1 text-[10px] text-sys-blue hover:underline text-center",children:["Clear filters (",Pe.size,")"]})]})]}),Wv=f.jsx(Qc,{children:J&&f.jsx(Sl.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.15},className:"absolute top-4 left-1/2 -translate-x-1/2 z-30 w-80",children:f.jsxs("div",{className:"surface-elevated radius-inset shadow-2xl overflow-hidden",children:[f.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 border-b border-edge-subtle",children:[f.jsx(_0,{className:"w-4 h-4 text-fg-muted shrink-0"}),f.jsx("input",{ref:Js,type:"text",value:se,onChange:v=>R(v.target.value),placeholder:"Search by name or prefix...",className:"flex-1 bg-transparent text-sm text-fg-primary placeholder:text-fg-muted focus:outline-none",onKeyDown:v=>{v.key==="Escape"?(F(!1),R("")):v.key==="Enter"&&ic.length>0&&Nv(ic[0])}}),se&&f.jsx("button",{onClick:()=>R(""),className:"p-0.5 radius-badge hover-bg transition-base",children:f.jsx($u,{className:"w-3 h-3 text-fg-muted"})})]}),ic.length>0&&f.jsx("div",{className:"max-h-64 overflow-y-auto",children:ic.map((v,j)=>f.jsxs("button",{onClick:()=>Nv(v),className:`w-full flex items-center gap-3 px-3 py-2 text-left hover-bg transition-base ${j===0?"bg-subtle-fill/50":""}`,children:[f.jsx("span",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{backgroundColor:_[v.nodeClass]}}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("div",{className:"text-sm text-fg-primary truncate",children:v.name||v.prefix}),v.name&&f.jsx("div",{className:"text-[10px] text-fg-muted",children:v.prefix})]}),f.jsx(VL,{className:"w-3 h-3 text-fg-muted shrink-0"})]},v.id))}),se&&ic.length===0&&f.jsx("div",{className:"px-3 py-4 text-center text-sm text-fg-muted",children:"No nodes found"}),!se&&f.jsx("div",{className:"px-3 py-2 type-data-xs text-fg-muted",children:"Type to search • Enter to select • Esc to close"})]})})});return e?tn.length===0?f.jsxs("div",{className:"relative h-[calc(100dvh-56px)] lg:h-dvh min-h-[500px] -mx-4 sm:-mx-6 lg:-mx-8 -mt-5 -mb-4 sm:-mb-6 lg:-mb-8 overflow-hidden",children:[dd,f.jsx("div",{className:"absolute inset-0 bg-body flex items-center justify-center",children:f.jsx(qee,{})})]}):Mr?M?f.jsxs("div",{className:"fixed inset-0 z-50 bg-body flex flex-col overflow-hidden",children:[f.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 surface-header z-10",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx(c0,{className:"w-5 h-5 text-icon-page-title"}),f.jsxs("h1",{className:"type-title text-fg-primary flex items-center gap-2",children:["MeshGraph",f.jsx(Di,{color:"violet",compact:!0,children:"Analytics"})]}),f.jsxs("span",{className:"text-[10px] text-fg-muted tabular-nums",children:[Bt.length," nodes • ",Ui.length," edges"]})]}),f.jsx(be,{content:"Exit fullscreen",children:f.jsx("button",{onClick:Dv,className:"p-1.5 radius-inner hover-bg transition-base",children:f.jsx(f0,{className:"w-4 h-4 text-fg-muted"})})})]}),f.jsxs("div",{className:"flex-1 relative min-h-0 m-2 surface-base radius-inset overflow-hidden border border-edge-subtle",children:[f.jsx(uS,{className:"absolute inset-0",points:Mr,links:ts,...Bn,...ut,backgroundColor:C,fitViewOnInit:!0,fitViewPadding:Ne.fitViewPadding,showLabels:Z,showDynamicLabels:!1,showTopLabels:Z,showTopLabelsLimit:200,showHoveredPointLabel:!0,pointLabelColor:x,pointClusterBy:We?"communityId":void 0,onPolygonSelected:Zn?Mv:void 0,polygonalSelectorStrokeColor:g?"#FBBF24":"#D97706",onClick:Pv,onLinkClick:Rv,onMount:Iv,hoveredPointRingColor:g?"#FBBF24":"#D97706",hoveredPointCursor:"pointer",hoveredLinkCursor:"pointer"}),Wv,Gv,$v,jv,Hv,Vv,f.jsxs(Qc,{children:[B&&f.jsx(SS,{node:B,egoMetrics:Bv,onExpandEgo:Uv,neighbors:zv,onSelectNeighbor:cd,txDelayRec:Fv,onClose:()=>{var v;H(null),(v=Rt.current)==null||v.unselectAllPoints()}}),Q&&!B&&f.jsx(wS,{edge:Q,onClose:()=>te(null)}),Zs&&!B&&!Q&&f.jsx(ES,{metrics:Zs,onClose:Ov})]})]})]}):f.jsxs("div",{className:"relative h-[calc(100dvh-56px)] lg:h-dvh min-h-[500px] -mx-4 sm:-mx-6 lg:-mx-8 -mt-5 -mb-4 sm:-mb-6 lg:-mb-8 overflow-hidden",children:[dd,f.jsxs("div",{className:"absolute inset-0",children:[f.jsx(uS,{className:"absolute inset-0",points:Mr,links:ts,...Bn,...ut,backgroundColor:C,fitViewOnInit:!0,fitViewPadding:Ne.fitViewPadding,showLabels:Z,showDynamicLabels:!1,showTopLabels:Z,showTopLabelsLimit:200,showHoveredPointLabel:!0,pointLabelColor:x,pointClusterBy:We?"communityId":void 0,onPolygonSelected:Zn?Mv:void 0,polygonalSelectorStrokeColor:g?"#FBBF24":"#D97706",onClick:Pv,onLinkClick:Rv,onMount:Iv,hoveredPointRingColor:g?"#FBBF24":"#D97706",hoveredPointCursor:"pointer",hoveredLinkCursor:"pointer"}),Wv,Gv,$v,jv,Hv,Vv,f.jsxs("div",{className:"absolute bottom-4 right-4 z-10 hidden lg:flex items-center gap-3 type-data-xs text-fg-muted/60",children:[f.jsxs("span",{children:[f.jsx("kbd",{className:"px-1 py-0.5 radius-badge bg-subtle-fill/50 font-mono",children:"/"})," Search"]}),f.jsxs("span",{children:[f.jsx("kbd",{className:"px-1 py-0.5 radius-badge bg-subtle-fill/50 font-mono",children:"F"})," Fit"]}),f.jsxs("span",{children:[f.jsx("kbd",{className:"px-1 py-0.5 radius-badge bg-subtle-fill/50 font-mono",children:"L"})," Labels"]}),f.jsxs("span",{children:[f.jsx("kbd",{className:"px-1 py-0.5 radius-badge bg-subtle-fill/50 font-mono",children:"Space"})," Pause"]}),f.jsxs("span",{children:[f.jsx("kbd",{className:"px-1 py-0.5 radius-badge bg-subtle-fill/50 font-mono",children:"Esc"})," Clear"]})]}),f.jsxs(Qc,{children:[B&&f.jsx(SS,{node:B,egoMetrics:Bv,onExpandEgo:Uv,neighbors:zv,onSelectNeighbor:cd,txDelayRec:Fv,onClose:()=>{var v;H(null),(v=Rt.current)==null||v.unselectAllPoints()}}),Q&&!B&&f.jsx(wS,{edge:Q,onClose:()=>te(null)}),Zs&&!B&&!Q&&f.jsx(ES,{metrics:Zs,onClose:Ov})]})]})]}):f.jsxs("div",{className:"relative h-[calc(100dvh-56px)] lg:h-dvh min-h-[500px] -mx-4 sm:-mx-6 lg:-mx-8 -mt-5 -mb-4 sm:-mb-6 lg:-mb-8 overflow-hidden",children:[dd,f.jsxs("div",{className:"absolute inset-0 bg-body flex flex-col items-center justify-center gap-3",children:[f.jsx(u0,{className:"w-8 h-8 text-sys-blue animate-spin"}),f.jsx("span",{className:"type-body text-fg-muted",children:"Preparing graph..."})]})]}):f.jsxs("div",{className:"relative h-[calc(100dvh-56px)] lg:h-dvh min-h-[500px] -mx-4 sm:-mx-6 lg:-mx-8 -mt-5 -mb-4 sm:-mb-6 lg:-mb-8 overflow-hidden",children:[dd,f.jsxs("div",{className:"absolute inset-0 bg-body flex items-center justify-center",children:[f.jsx(NL,{isOpen:n,onClose:o}),!n&&f.jsx(u0,{className:"w-8 h-8 text-sys-blue animate-spin"})]})]})}const hie=Object.freeze(Object.defineProperty({__proto__:null,default:Xee},Symbol.toStringTag,{value:"Module"}));export{ge as $,le as B,cy as D,TN as H,oy as I,NP as J,SN as K,hie as M,bg as N,Jc as T,Vu as U,Xh as a,_n as b,gte as c,qP as d,ct as e,fte as f,YP as h,yN as j,pte as l,hte as o,ute as r,dte as s,_te as u}; diff --git a/frontend/dist/assets/NodeInformationCard-p2ujbtr-.js b/frontend/dist/assets/NodeInformationCard-BLxCCOW5.js similarity index 90% rename from frontend/dist/assets/NodeInformationCard-p2ujbtr-.js rename to frontend/dist/assets/NodeInformationCard-BLxCCOW5.js index 608e144c..639e55b1 100644 --- a/frontend/dist/assets/NodeInformationCard-p2ujbtr-.js +++ b/frontend/dist/assets/NodeInformationCard-BLxCCOW5.js @@ -1 +1 @@ -import{j as s,F as i,R as d,cG as c}from"./index-C8IY8K2r.js";import{C as n}from"./PageLayout-NQBVrM09.js";import{D as m}from"./DataBox-W2v3wy8k.js";function j({nodeName:e,repeaterVersion:a,coreVersion:t,localHash:r,publicKey:l}){return s.jsxs(n,{neomorphic:!0,children:[s.jsx(i,{icon:s.jsx(d,{}),title:"Node Information"}),s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3 sm:gap-4",children:[s.jsxs("div",{className:"min-w-0 col-span-2 sm:col-span-1",children:[s.jsx("span",{className:"type-label text-fg-secondary",children:"Node Name"}),s.jsx("p",{className:"type-body text-fg-primary mt-0.5 sm:mt-1 truncate",title:e,children:e})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"type-label text-fg-secondary",children:"Repeater"}),s.jsxs("p",{className:"type-data text-fg-primary mt-0.5 sm:mt-1 truncate",title:`v${a}`,children:["v",a]})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"type-label text-fg-secondary",children:"Core"}),s.jsxs("p",{className:"type-data text-fg-primary mt-0.5 sm:mt-1 truncate",title:`v${t}`,children:["v",t]})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"type-label text-fg-secondary",children:"Console"}),s.jsxs("p",{className:"type-data text-fg-primary mt-0.5 sm:mt-1 truncate",title:`v${c}`,children:["v",c]})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"type-label text-fg-secondary",children:"Local Hash"}),s.jsx("div",{className:"mt-0.5 sm:mt-1",children:r?s.jsx(m,{copy:!0,size:"compact",children:r}):s.jsx("span",{className:"type-data-sm text-fg-secondary",children:"N/A"})})]})]}),l&&s.jsxs("div",{className:"mt-3 sm:mt-4 pt-3 sm:pt-4 border-t border-edge-subtle",children:[s.jsx("span",{className:"type-label text-fg-secondary",children:"Public Key"}),s.jsx("div",{className:"mt-0.5 sm:mt-1",children:s.jsx(m,{copy:!0,size:"responsive",children:l})})]})]})}export{j as N}; +import{j as s,F as i,R as d,cJ as c}from"./index-BwGHI0A_.js";import{C as n}from"./PageLayout-BIcqC04y.js";import{D as m}from"./DataBox-CQS-Zhu0.js";function j({nodeName:e,repeaterVersion:a,coreVersion:t,localHash:r,publicKey:l}){return s.jsxs(n,{neomorphic:!0,children:[s.jsx(i,{icon:s.jsx(d,{}),title:"Node Information"}),s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3 sm:gap-4",children:[s.jsxs("div",{className:"min-w-0 col-span-2 sm:col-span-1",children:[s.jsx("span",{className:"type-label text-fg-secondary",children:"Node Name"}),s.jsx("p",{className:"type-body text-fg-primary mt-0.5 sm:mt-1 truncate",title:e,children:e})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"type-label text-fg-secondary",children:"Repeater"}),s.jsxs("p",{className:"type-data text-fg-primary mt-0.5 sm:mt-1 truncate",title:`v${a}`,children:["v",a]})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"type-label text-fg-secondary",children:"Core"}),s.jsxs("p",{className:"type-data text-fg-primary mt-0.5 sm:mt-1 truncate",title:`v${t}`,children:["v",t]})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"type-label text-fg-secondary",children:"Console"}),s.jsxs("p",{className:"type-data text-fg-primary mt-0.5 sm:mt-1 truncate",title:`v${c}`,children:["v",c]})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"type-label text-fg-secondary",children:"Local Hash"}),s.jsx("div",{className:"mt-0.5 sm:mt-1",children:r?s.jsx(m,{copy:!0,size:"compact",children:r}):s.jsx("span",{className:"type-data-sm text-fg-secondary",children:"N/A"})})]})]}),l&&s.jsxs("div",{className:"mt-3 sm:mt-4 pt-3 sm:pt-4 border-t border-edge-subtle",children:[s.jsx("span",{className:"type-label text-fg-secondary",children:"Public Key"}),s.jsx("div",{className:"mt-0.5 sm:mt-1",children:s.jsx(m,{copy:!0,size:"responsive",children:l})})]})]})}export{j as N}; diff --git a/frontend/dist/assets/PacketList-CnGGHFuk.js b/frontend/dist/assets/PacketList-CnGGHFuk.js new file mode 100644 index 00000000..a65dece6 --- /dev/null +++ b/frontend/dist/assets/PacketList-CnGGHFuk.js @@ -0,0 +1,67 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PathMapMapLibre-CUvyj6hi.js","assets/index-BwGHI0A_.js","assets/BasemapLayer-Bm_seLWQ.js","assets/useMapViewStore-CPURakCb.js","assets/index-OH01SZkk.js","assets/index-DUfCykEc.css","assets/BasemapLayer-B1CfjdFi.css"])))=>i.map(i=>d[i]); +import{r as p,aD as ds,d as me,bd as xs,be as zt,bf as ms,bg as hs,j as e,c as R,B as rt,bh as us,x as it,q as B,bi as Ft,R as de,bj as It,bk as At,bl as Dt,bm as ue,bn as Ze,$ as De,bo as ps,bp as fs,bq as gs,br as ys,bs as js,m as oe,a7 as re,w as bs,bt as Ns,bu as ie,bv as ut,bw as vs,bx as ws,by as ks,bz as Cs,bA as Ss,bB as _s,bC as Je,bD as Ms,a3 as Ts,E as Ht,bE as Ps,bF as Bs,bG as Ls,bH as Rs,ac as Ot,ad as $t,A as Ke,bI as Es,ae as zs,bJ as Fs,bK as lt}from"./index-BwGHI0A_.js";import{p as Is,d as As,e as Ut,g as Ds,b as Hs}from"./primitives-Cgn8YJud.js";import{u as Os,r as $s,a as Us,b as Vs,c as Ws,d as Gs,i as Qs}from"./consumer-registry-DPYvsBcc.js";import{D as Pe,R as He,P as Be,g as qs}from"./badge-colors-BNUqIXCA.js";import{g as Vt,e as _e,a as Wt}from"./chat-utils-Di4-nywi.js";import{P as Gt,d as Qt,a as Ks,b as Ys}from"./payload-decoders-7zyi-Y-D.js";import{A as pe,S as Oe,i as $e,C as xe,a as Xs,g as pt}from"./SignalIndicator-LNOR_5YF.js";import{a as Zs,A as qt}from"./arrow-up-DJuSVUZI.js";import{C as ct}from"./chevron-right-DqpRZiGf.js";import{M as Ue}from"./map-pin-VRY_TOuh.js";import{C as Js}from"./circle-question-mark-DC7QfrVK.js";import{T as et}from"./triangle-alert-B4kC1YDk.js";import{D as X}from"./DataBox-CQS-Zhu0.js";import{L as ea}from"./layers-C8ICjJ-w.js";import{H as Kt}from"./hash-9uwO8S8N.js";import{A as ta}from"./activity-Dr_TPIps.js";import{C as sa}from"./circle-check-CBI-CiRo.js";import{D as aa}from"./database-CDN_R6oC.js";import{H as na,D as tt,Z as ft,u as ra}from"./useMapViewStore-CPURakCb.js";import{S as we}from"./shield-DOTPcYJ1.js";import{C as Yt}from"./TimeRangeStepper-Dh4JEQ42.js";function ke(t,n,s){let a=s.initialDeps??[],r,i=!0;function l(){var c,o,u;let x;s.key&&((c=s.debug)!=null&&c.call(s))&&(x=Date.now());const g=t();if(!(g.length!==a.length||g.some((m,v)=>a[v]!==m)))return r;a=g;let y;if(s.key&&((o=s.debug)!=null&&o.call(s))&&(y=Date.now()),r=n(...g),s.key&&((u=s.debug)!=null&&u.call(s))){const m=Math.round((Date.now()-x)*100)/100,v=Math.round((Date.now()-y)*100)/100,T=v/16,h=(N,j)=>{for(N=String(N);N.length{a=c},l}function gt(t,n){if(t===void 0)throw new Error("Unexpected undefined");return t}const ia=(t,n)=>Math.abs(t-n)<1.01,la=(t,n,s)=>{let a;return function(...r){t.clearTimeout(a),a=t.setTimeout(()=>n.apply(this,r),s)}},yt=t=>{const{offsetWidth:n,offsetHeight:s}=t;return{width:n,height:s}},ca=t=>t,oa=t=>{const n=Math.max(t.startIndex-t.overscan,0),s=Math.min(t.endIndex+t.overscan,t.count-1),a=[];for(let r=n;r<=s;r++)a.push(r);return a},da=(t,n)=>{const s=t.scrollElement;if(!s)return;const a=t.targetWindow;if(!a)return;const r=l=>{const{width:c,height:o}=l;n({width:Math.round(c),height:Math.round(o)})};if(r(yt(s)),!a.ResizeObserver)return()=>{};const i=new a.ResizeObserver(l=>{const c=()=>{const o=l[0];if(o!=null&&o.borderBoxSize){const u=o.borderBoxSize[0];if(u){r({width:u.inlineSize,height:u.blockSize});return}}r(yt(s))};t.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()});return i.observe(s,{box:"border-box"}),()=>{i.unobserve(s)}},jt={passive:!0},bt=typeof window>"u"?!0:"onscrollend"in window,xa=(t,n)=>{const s=t.scrollElement;if(!s)return;const a=t.targetWindow;if(!a)return;let r=0;const i=t.options.useScrollendEvent&&bt?()=>{}:la(a,()=>{n(r,!1)},t.options.isScrollingResetDelay),l=x=>()=>{const{horizontal:g,isRtl:f}=t.options;r=g?s.scrollLeft*(f&&-1||1):s.scrollTop,i(),n(r,x)},c=l(!0),o=l(!1);s.addEventListener("scroll",c,jt);const u=t.options.useScrollendEvent&&bt;return u&&s.addEventListener("scrollend",o,jt),()=>{s.removeEventListener("scroll",c),u&&s.removeEventListener("scrollend",o)}},ma=(t,n,s)=>{if(n!=null&&n.borderBoxSize){const a=n.borderBoxSize[0];if(a)return Math.round(a[s.options.horizontal?"inlineSize":"blockSize"])}return t[s.options.horizontal?"offsetWidth":"offsetHeight"]},ha=(t,{adjustments:n=0,behavior:s},a)=>{var r,i;const l=t+n;(i=(r=a.scrollElement)==null?void 0:r.scrollTo)==null||i.call(r,{[a.options.horizontal?"left":"top"]:l,behavior:s})};class ua{constructor(n){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.currentScrollToIndex=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let s=null;const a=()=>s||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:s=new this.targetWindow.ResizeObserver(r=>{r.forEach(i=>{const l=()=>{this._measureElement(i.target,i)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()})}));return{disconnect:()=>{var r;(r=a())==null||r.disconnect(),s=null},observe:r=>{var i;return(i=a())==null?void 0:i.observe(r,{box:"border-box"})},unobserve:r=>{var i;return(i=a())==null?void 0:i.unobserve(r)}}})(),this.range=null,this.setOptions=s=>{Object.entries(s).forEach(([a,r])=>{typeof r>"u"&&delete s[a]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:ca,rangeExtractor:oa,onChange:()=>{},measureElement:ma,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...s}},this.notify=s=>{var a,r;(r=(a=this.options).onChange)==null||r.call(a,this,s)},this.maybeNotify=ke(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),s=>{this.notify(s)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(s=>s()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var s;const a=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==a){if(this.cleanup(),!a){this.maybeNotify();return}this.scrollElement=a,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((s=this.scrollElement)==null?void 0:s.window)??null,this.elementsCache.forEach(r=>{this.observer.observe(r)}),this.unsubs.push(this.options.observeElementRect(this,r=>{this.scrollRect=r,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(r,i)=>{this.scrollAdjustments=0,this.scrollDirection=i?this.getScrollOffset()this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(s,a)=>{const r=new Map,i=new Map;for(let l=a-1;l>=0;l--){const c=s[l];if(r.has(c.lane))continue;const o=i.get(c.lane);if(o==null||c.end>o.end?i.set(c.lane,c):c.endl.end===c.end?l.index-c.index:l.end-c.end)[0]:void 0},this.getMeasurementOptions=ke(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(s,a,r,i,l,c)=>(this.prevLanes!==void 0&&this.prevLanes!==c&&(this.lanesChangedFlag=!0),this.prevLanes=c,this.pendingMeasuredCacheIndexes=[],{count:s,paddingStart:a,scrollMargin:r,getItemKey:i,enabled:l,lanes:c}),{key:!1}),this.getMeasurements=ke(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:s,paddingStart:a,scrollMargin:r,getItemKey:i,enabled:l,lanes:c},o)=>{if(!l)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>s)for(const f of this.laneAssignments.keys())f>=s&&this.laneAssignments.delete(f);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(f=>{this.itemSizeCache.set(f.key,f.size)}));const u=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===s&&(this.lanesSettling=!1);const x=this.measurementsCache.slice(0,u),g=new Array(c).fill(void 0);for(let f=0;f1){v=m;const C=g[v],k=C!==void 0?x[C]:void 0;T=k?k.end+this.options.gap:a+r}else{const C=this.options.lanes===1?x[f-1]:this.getFurthestMeasurement(x,f);T=C?C.end+this.options.gap:a+r,v=C?C.lane:f%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(f,v)}const h=o.get(y),N=typeof h=="number"?h:this.options.estimateSize(f),j=T+N;x[f]={index:f,start:T,size:N,end:j,key:y,lane:v},g[v]=f}return this.measurementsCache=x,x},{key:!1,debug:()=>this.options.debug}),this.calculateRange=ke(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(s,a,r,i)=>this.range=s.length>0&&a>0?pa({measurements:s,outerSize:a,scrollOffset:r,lanes:i}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=ke(()=>{let s=null,a=null;const r=this.calculateRange();return r&&(s=r.startIndex,a=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,s,a]),[this.options.rangeExtractor,this.options.overscan,this.options.count,s,a]},(s,a,r,i,l)=>i===null||l===null?[]:s({startIndex:i,endIndex:l,overscan:a,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=s=>{const a=this.options.indexAttribute,r=s.getAttribute(a);return r?parseInt(r,10):(console.warn(`Missing attribute name '${a}={index}' on measured element.`),-1)},this._measureElement=(s,a)=>{const r=this.indexFromElement(s),i=this.measurementsCache[r];if(!i)return;const l=i.key,c=this.elementsCache.get(l);c!==s&&(c&&this.observer.unobserve(c),this.observer.observe(s),this.elementsCache.set(l,s)),s.isConnected&&this.resizeItem(r,this.options.measureElement(s,a,this))},this.resizeItem=(s,a)=>{const r=this.measurementsCache[s];if(!r)return;const i=this.itemSizeCache.get(r.key)??r.size,l=a-i;l!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(r,l,this):r.start{if(!s){this.elementsCache.forEach((a,r)=>{a.isConnected||(this.observer.unobserve(a),this.elementsCache.delete(r))});return}this._measureElement(s,void 0)},this.getVirtualItems=ke(()=>[this.getVirtualIndexes(),this.getMeasurements()],(s,a)=>{const r=[];for(let i=0,l=s.length;ithis.options.debug}),this.getVirtualItemForOffset=s=>{const a=this.getMeasurements();if(a.length!==0)return gt(a[Xt(0,a.length-1,r=>gt(a[r]).start,s)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const s=this.scrollElement.document.documentElement;return this.options.horizontal?s.scrollWidth-this.scrollElement.innerWidth:s.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(s,a,r=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),l=this.getScrollOffset();a==="auto"&&(a=s>=l+i?"end":"start"),a==="center"?s+=(r-i)/2:a==="end"&&(s-=i);const c=this.getMaxScrollOffset();return Math.max(Math.min(c,s),0)},this.getOffsetForIndex=(s,a="auto")=>{s=Math.max(0,Math.min(s,this.options.count-1));const r=this.measurementsCache[s];if(!r)return;const i=this.getSize(),l=this.getScrollOffset();if(a==="auto")if(r.end>=l+i-this.options.scrollPaddingEnd)a="end";else if(r.start<=l+this.options.scrollPaddingStart)a="start";else return[l,a];if(a==="end"&&s===this.options.count-1)return[this.getMaxScrollOffset(),a];const c=a==="end"?r.end+this.options.scrollPaddingEnd:r.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(c,a,r.size),a]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(s,{align:a="start",behavior:r}={})=>{r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(s,a),{adjustments:void 0,behavior:r})},this.scrollToIndex=(s,{align:a="auto",behavior:r}={})=>{r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),s=Math.max(0,Math.min(s,this.options.count-1)),this.currentScrollToIndex=s;let i=0;const l=10,c=u=>{if(!this.targetWindow)return;const x=this.getOffsetForIndex(s,u);if(!x){console.warn("Failed to get offset for index:",s);return}const[g,f]=x;this._scrollToOffset(g,{adjustments:void 0,behavior:r}),this.targetWindow.requestAnimationFrame(()=>{const y=()=>{if(this.currentScrollToIndex!==s)return;const m=this.getScrollOffset(),v=this.getOffsetForIndex(s,f);if(!v){console.warn("Failed to get offset for index:",s);return}ia(v[0],m)||o(f)};this.isDynamicMode()?this.targetWindow.requestAnimationFrame(y):y()})},o=u=>{this.targetWindow&&this.currentScrollToIndex===s&&(i++,ic(u)):console.warn(`Failed to scroll to index ${s} after ${l} attempts.`))};c(a)},this.scrollBy=(s,{behavior:a}={})=>{a==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+s,{adjustments:void 0,behavior:a})},this.getTotalSize=()=>{var s;const a=this.getMeasurements();let r;if(a.length===0)r=this.options.paddingStart;else if(this.options.lanes===1)r=((s=a[a.length-1])==null?void 0:s.end)??0;else{const i=Array(this.options.lanes).fill(null);let l=a.length-1;for(;l>=0&&i.some(c=>c===null);){const c=a[l];i[c.lane]===null&&(i[c.lane]=c.end),l--}r=Math.max(...i.filter(c=>c!==null))}return Math.max(r-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(s,{adjustments:a,behavior:r})=>{this.options.scrollToFn(s,{behavior:r,adjustments:a},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(n)}}const Xt=(t,n,s,a)=>{for(;t<=n;){const r=(t+n)/2|0,i=s(r);if(ia)n=r-1;else return r}return t>0?t-1:0};function pa({measurements:t,outerSize:n,scrollOffset:s,lanes:a}){const r=t.length-1,i=o=>t[o].start;if(t.length<=a)return{startIndex:0,endIndex:r};let l=Xt(0,r,i,s),c=l;if(a===1)for(;c1){const o=Array(a).fill(0);for(;cx=0&&u.some(x=>x>=s);){const x=t[l];u[x.lane]=x.start,l--}l=Math.max(0,l-l%a),c=Math.min(r,c+(a-1-c%a))}return{startIndex:l,endIndex:c}}const Nt=typeof document<"u"?p.useLayoutEffect:p.useEffect;function fa({useFlushSync:t=!0,...n}){const s=p.useReducer(()=>({}),{})[1],a={...n,onChange:(i,l)=>{var c;t&&l?ds.flushSync(s):s(),(c=n.onChange)==null||c.call(n,i,l)}},[r]=p.useState(()=>new ua(a));return r.setOptions(a),Nt(()=>r._didMount(),[]),Nt(()=>r._willUpdate()),r}function ga(t){return fa({observeElementRect:da,observeElementOffset:xa,scrollToFn:ha,...t})}/** + * @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 ya=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],ja=me("chevron-up",ya);/** + * @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 ba=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Tr=me("circle-x",ba);/** + * @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 Na=[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]],va=me("corner-down-right",Na);/** + * @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 wa=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],ot=me("lock",wa);/** + * @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 ka=[["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"}]],Zt=me("message-circle-question-mark",ka);/** + * @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:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}],["path",{d:"m9 17-5-5 5-5",key:"nvlc11"}]],Sa=me("reply",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 _a=[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15",key:"1d8sl"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]],Ma=me("route",_a);/** + * @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 Ta=[["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"}]],vt=me("stethoscope",Ta);/** + * @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 Pa=[["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"}]],wt=me("trophy",Pa);/** + * @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 Ba=[["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"}]],Ce=me("user",Ba);function La(t){t.values.forEach(n=>n.stop())}function st(t,n){[...n].reverse().forEach(a=>{const r=t.getVariant(a);r&&zt(t,r),t.variantChildren&&t.variantChildren.forEach(i=>{st(i,n)})})}function Ra(t,n){if(Array.isArray(n))return st(t,n);if(typeof n=="string")return st(t,[n]);zt(t,n)}function Ea(){const t=new Set,n={subscribe(s){return t.add(s),()=>void t.delete(s)},start(s,a){const r=[];return t.forEach(i=>{r.push(xs(i,s,{transitionOverride:a}))}),Promise.all(r)},set(s){return t.forEach(a=>{Ra(a,s)})},stop(){t.forEach(s=>{La(s)})},mount(){return()=>{n.stop()}}};return n}function za(){const t=ms(Ea);return hs(t.mount,[]),t}function Fa({"aria-label":t="Page navigation",className:n,...s}){return e.jsx("nav",{"aria-label":t,...s,className:R("flex gap-x-2",n)})}function Ia({onClick:t,disabled:n=!1,className:s,children:a="Previous"}){return e.jsx("span",{className:R("grow basis-0",s),children:e.jsxs(rt,{plain:!0,onClick:t,disabled:n,"aria-label":"Previous page",className:R("gap-1",n&&"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"})}),a]})})}function Aa({onClick:t,disabled:n=!1,className:s,children:a="Next"}){return e.jsx("span",{className:R("flex grow basis-0 justify-end",s),children:e.jsxs(rt,{plain:!0,onClick:t,disabled:n,"aria-label":"Next page",className:R("gap-1",n&&"invisible"),children:[a,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 Da({className:t,...n}){return e.jsx("span",{...n,className:R("hidden items-baseline gap-x-2 sm:flex",t)})}function Ha({page:t,current:n=!1,onClick:s,className:a,children:r}){return e.jsx(rt,{plain:!n,outline:n,onClick:()=>s==null?void 0:s(t),"aria-label":`Page ${t}`,"aria-current":n?"page":void 0,className:R("min-w-[2.25rem] before:absolute before:-inset-px before:rounded-lg",n&&"before:bg-subtle-fill",a),children:r??t})}function Oa({className:t,...n}){return e.jsx("span",{"aria-hidden":"true",...n,className:R("w-[2.25rem] select-none text-center text-sm text-fg-muted",t),children:"…"})}function $a(t,n,s=1){if(n<=7)return Array.from({length:n},(o,u)=>u+1);const a=Math.max(t-s,1),r=Math.min(t+s,n),i=a>2,l=rg+1),"gap",n]}if(i&&!l){const o=3+2*s;return[1,"gap",...Array.from({length:o},(x,g)=>n-o+g+1)]}return[1,"gap",...Array.from({length:r-a+1},(o,u)=>a+u),"gap",n]}const Pr=us(t=>({requestedHash:null,requestChannel:n=>t({requestedHash:n}),clearRequest:()=>t({requestedHash:null})}));function Ua(t){if(t.length===0)return[];const n=[];let s=0;for(;s{const l=i===t.length-1,c=a&&r.toUpperCase()===a;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:r.toUpperCase()}),!l&&e.jsx(ct,{className:"w-2.5 h-2.5 text-fg-muted mx-0.5 flex-shrink-0"})]},`${r}-${i}`)})})}const es=p.memo(qa);function ts({channelName:t,onClick:n,active:s,compact:a,className:r}){const i=t.startsWith("#")?t:`#${t}`,l=R("inline-flex items-center flex-shrink-0","font-medium",a?"px-1.5 h-4 leading-4 rounded text-[10px]":"px-2 h-5 leading-5 rounded text-xs",s?"bg-sys-blue/20 text-sys-blue":"bg-sys-blue/10 text-sys-blue",n&&!s&&"hover:bg-sys-blue/20 cursor-pointer",r);return n?e.jsx("button",{type:"button",onClick:n,className:l,children:i}):e.jsx("span",{className:l,children:i})}function Me(t){return{"--data-box-accent":ue[t]}}function ss(t){const n=t.payload_type_name||At(t.payload_type??t.type),s=t.route_type_name||Dt(t.route_type??t.route),a=Be[n]??"zinc",r=He[s]??"zinc";return{payloadType:n,routeType:s,payloadColor:a,routeColor:r}}function Ve(t){if(!t)return[];if(Array.isArray(t))return t;try{const n=JSON.parse(t);return Array.isArray(n)?n:[]}catch{return[]}}function as(t,n){if(n){const s=n(t);return{name:s.name,isCompanion:s.isCompanion,isRepeater:s.isRepeater}}return{name:null,isCompanion:!1,isRepeater:!1}}function Ka({packet:t,onClick:n,localHash:s,neighbors:a,resolveSource:r,isFlashing:i=!1,isTraceHighlighted:l,onTraceHover:c,traceTag:o,onViewTraceReport:u,dupeGroupPosition:x,isDupeGroupHovered:g=!1,onDupeGroupHover:f,dupeCount:y,getDecodedContent:m,onChannelClick:v}){const T=y?!1:Ft(t.is_duplicate),h=x!==void 0,{payloadType:N,routeType:j,payloadColor:C,routeColor:k}=ss(t),b=t.packet_origin==="tx_local",A=N==="TRACE",U=Ve(t.original_path),W=Ve(t.forwarded_path),K=W.length>0?W:U,F=t.src_hash?(t.src_hash.startsWith("0x")?t.src_hash.slice(2,6):t.src_hash.slice(0,4)).toUpperCase():null,{name:Y,isRepeater:D}=as(t,r);let E=null,O=null,$=null,J=null;if(N==="GRP_TXT"&&m){const _=m(t);_!=null&&_.decrypted&&(O=_.senderName,$=_.channelName,J=_.channelHash,_.text&&(E=_.text))}else if(N==="TXT_MSG"&&t.raw_packet)try{const _=Gt.fromHex(t.raw_packet);if(_.success&&_.packet){const ce=Qt(_.packet.payload);ce&&!ce.encrypted&&(E=ce.text)}}catch{}const M=O||(D?null:Y),H=!!M,te=!H&&D&&!!Y,se=!H&&!te&&N==="GRP_TXT"&&!E,d=t.payload_length??t.length??0;t.lbt_attempts;const Z=p.useCallback(()=>{A&&o&&u?u(o):n(t)},[A,o,u,n,t]),q=p.useCallback(()=>{A&&o&&c&&c(o),h&&f&&t.packet_hash&&f(t.packet_hash)},[A,o,c,h,f,t.packet_hash]),le=p.useCallback(()=>{c&&c(null),f&&f(null)},[c,f]),P=ue[C]||ue.zinc,z=g,ae=()=>{const _={pointerEvents:"none"};return x==="first"?{..._,borderTop:`2px solid ${P}`,borderLeft:`2px solid ${P}`,borderRight:`2px solid ${P}`,borderBottom:"none",borderRadius:"8px 8px 0 0",inset:"-2px -2px 0 -2px"}:x==="middle"?{..._,borderTop:"none",borderLeft:`2px solid ${P}`,borderRight:`2px solid ${P}`,borderBottom:"none",borderRadius:0,inset:"0 -2px"}:x==="last"?{..._,borderTop:"none",borderLeft:`2px solid ${P}`,borderRight:`2px solid ${P}`,borderBottom:`2px solid ${P}`,borderRadius:"0 0 8px 8px",inset:"0 -2px -2px -2px"}:{..._,border:`2px solid ${P}`,borderRadius:"8px",inset:"-2px"}};return e.jsxs("div",{onClick:Z,onMouseEnter:q,onMouseLeave:le,className:R("group relative cursor-pointer","hover:bg-subtle-fill",T&&!g&&"opacity-40",i&&"flash-row",b&&"bg-sys-indigo/5",l&&"bg-sys-teal/10"),children:[e.jsx("div",{className:R("absolute pointer-events-none transition-opacity duration-75",h?z?"opacity-100":"opacity-0":"opacity-0 group-hover:opacity-100"),style:ae()}),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:H?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-1 ring-edge-subtle",style:{backgroundColor:Vt(_e(M).cleanName)},children:_e(M).emoji?e.jsx("span",{className:"text-base leading-none",children:_e(M).emoji}):e.jsx("span",{className:"text-white text-[10px] font-bold tracking-tighter",children:Wt(M)})}):te?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-[1.5px] ring-sys-blue",children:e.jsx(de,{className:"size-5 text-sys-blue"})}):se?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(Zt,{className:"size-4 text-fg-muted"})}):e.jsx(Jt,{packet:t,variant:"avatar",size:"sm"})}),e.jsx("div",{className:"min-w-0",children:H?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-[13px] text-fg-primary font-sans truncate max-w-[90px]",children:M}),F&&e.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-fg-muted truncate",children:F})]}):te?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-[13px] text-fg-primary font-sans truncate max-w-[90px]",children:Y}),F&&e.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-fg-muted truncate",children:F})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-bold text-[13px] text-fg-primary font-sans truncate",children:F||"—"}),Y&&e.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-fg-muted truncate max-w-[70px]",children:Y})]})})]}),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:Me(C),children:N}),b&&e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:Me("indigo"),children:"LOCAL"}),y&&y>1&&e.jsxs("span",{className:"data-box data-box-compact flex-shrink-0",children:["×",y]}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:Me(k),children:j}),e.jsxs("span",{className:"hidden min-[520px]:inline type-data-xs text-fg-muted flex-shrink-0",children:[d,"B"]}),e.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:E||$?e.jsxs("span",{className:"text-[11px] text-fg-secondary truncate block flex items-center gap-1",children:[$&&e.jsx(ts,{channelName:$,compact:!0,onClick:v&&J?_=>{_.stopPropagation(),v(J)}:void 0}),E&&e.jsx("span",{className:"italic truncate",children:E})]}):e.jsx(es,{path:K,localHash:s})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("span",{className:"data-box data-box-compact",children:It(t.timestamp)}),e.jsx(Oe,{rssi:t.rssi,snr:t.snr,compact:!0,showValues:!0,validated:$e(t)})]})]})]})}function Ya({packet:t,onClick:n,localHash:s,neighbors:a,resolveSource:r,isFlashing:i=!1,isTraceHighlighted:l,traceTag:c,onViewTraceReport:o,dupeGroupPosition:u,isDupeGroupHovered:x=!1,onDupeGroupHover:g,dupeCount:f,getDecodedContent:y,onChannelClick:m}){const{payloadType:v,routeType:T,payloadColor:h,routeColor:N}=ss(t),j=t.packet_origin==="tx_local",C=v==="TRACE",k=f?!1:Ft(t.is_duplicate),b=Ve(t.original_path),A=Ve(t.forwarded_path),U=A.length>0?A:b,W=t._hopCount??U.length,K=t.src_hash?(t.src_hash.startsWith("0x")?t.src_hash.slice(2,6):t.src_hash.slice(0,4)).toUpperCase():null,{name:F,isRepeater:Y}=as(t,r);let D=null,E=null,O=null,$=null;if(v==="GRP_TXT"&&y){const P=y(t);P!=null&&P.decrypted&&(E=P.senderName,O=P.channelName,$=P.channelHash,P.text&&(D=P.text))}else if(v==="TXT_MSG"&&t.raw_packet)try{const P=Gt.fromHex(t.raw_packet);if(P.success&&P.packet){const z=Qt(P.packet.payload);z&&!z.encrypted&&(D=z.text)}}catch{}const J=E||(Y?null:F),M=!!J,H=!M&&Y&&!!F,te=!M&&!H&&v==="GRP_TXT"&&!D,se=t.payload_length??t.length??0,d=t.lbt_attempts??0,Z=()=>{C&&c&&o?o(c):n(t)},q=ue[h]||ue.zinc,le=()=>{if(!u)return{opacity:0};const P=x?1:.4,z=x?"3px":"2px";return u==="first"?{backgroundColor:q,opacity:P,width:z,top:"6px",bottom:0,borderRadius:"0 9999px 0 0"}:u==="middle"?{backgroundColor:q,opacity:P,width:z,top:0,bottom:0,borderRadius:0}:u==="last"?{backgroundColor:q,opacity:P,width:z,top:0,bottom:"6px",borderRadius:"0 0 9999px 0"}:{backgroundColor:q,opacity:P,width:z,top:"6px",bottom:"6px",borderRadius:"9999px"}};return e.jsxs("div",{onClick:Z,className:R("relative pl-3 pr-2.5 py-2 cursor-pointer","active:bg-subtle-fill-hover",k&&"opacity-40",i&&"flash-row",j&&"bg-sys-indigo/5",l&&"bg-sys-teal/10"),children:[e.jsx("div",{className:"absolute left-0 transition-all",style:le()}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"relative flex-shrink-0 mt-0.5",children:M?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-1 ring-edge-subtle",style:{backgroundColor:Vt(_e(J).cleanName)},children:_e(J).emoji?e.jsx("span",{className:"text-base leading-none",children:_e(J).emoji}):e.jsx("span",{className:"text-white text-[10px] font-bold tracking-tighter",children:Wt(J)})}):H?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-[1.5px] ring-sys-blue",children:e.jsx(de,{className:"size-5 text-sys-blue"})}):te?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(Zt,{className:"size-4 text-fg-muted"})}):e.jsx(Jt,{packet:t,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:[M?e.jsx("span",{className:"font-medium text-[14px] text-fg-primary tracking-tight truncate min-w-0",children:J}):H?e.jsx("span",{className:"font-medium text-[14px] text-fg-primary tracking-tight truncate min-w-0",children:F}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold text-[14px] text-fg-primary tracking-tight flex-shrink-0",children:K||"—"}),F&&e.jsx("span",{className:"text-[12px] text-fg-muted truncate min-w-0",children:F})]}),e.jsx("div",{className:"flex-1"}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:Me(h),children:v}),j&&e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:Me("indigo"),children:"LOCAL"}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:Me(N),children:T}),f&&f>1&&e.jsxs("span",{className:"data-box data-box-compact flex-shrink-0",children:["×",f]}),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:t.rssi}),e.jsx(Oe,{rssi:t.rssi,compact:!0,showValues:!1,validated:$e(t)})]})]}),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:It(t.timestamp)}),se>0&&e.jsxs("span",{children:[se,"B"]}),d>0&&e.jsxs("span",{className:d>1?"text-sys-amber/60":void 0,children:["LBT:",d]}),t.snr!=null&&e.jsxs("span",{children:[t.snr.toFixed(0),"dB"]}),D||O?e.jsxs("span",{className:"text-[11px] text-fg-secondary truncate flex items-center gap-1 min-w-0",children:[O&&e.jsx(ts,{channelName:O,compact:!0,onClick:m&&$?P=>{P.stopPropagation(),m($)}:void 0}),D&&e.jsx("span",{className:"italic truncate",children:D})]}):W>0?e.jsx(es,{path:U,localHash:s}):null]})]})]})]})}const Xa=p.memo(Ka),Za=p.memo(Ya);function Ja(t,n,s,a,r=!1){const i=t.toUpperCase(),l=[],c=s&&Ze(i,s);c&&l.push(s);for(const y of Object.keys(n))Ze(i,y)&&l.push(y);if(r&&c&&s&&l.length===1)return{matches:l,probability:1,bestMatch:s};if(r&&c&&l.length>1){const y=l.filter(m=>m!==s);if(y.length===1)return{matches:l,probability:1,bestMatch:y[0]}}const o=l.length>0?1/l.length:0,u=[...l].sort();let x=null,g=-1;if(u.length===1)x=u[0];else if(u.length>1&&a){for(const y of u){const m=a.get(y),v=m?typeof m=="number"?m:m.combinedScore:0;v>g&&(g=v,x=y)}x||(x=u[0])}else u.length>0&&(x=u[0]);let f=o;if(l.length>1&&a&&g>0){let y=0;for(const m of l){const v=a.get(m);y+=v?typeof v=="number"?v:v.combinedScore:0}y>0&&(f=Math.min(.95,g/y))}return{matches:l,probability:f,bestMatch:x}}function en(t,n,s,a){const i=(s-t)*Math.PI/180,l=(a-n)*Math.PI/180,c=Math.sin(i/2)*Math.sin(i/2)+Math.cos(t*Math.PI/180)*Math.cos(s*Math.PI/180)*Math.sin(l/2)*Math.sin(l/2);return 6371e3*(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)))}function tn(t){return t<100?1:t<500?.9:t<1e3?.7:t<5e3?.5:t<1e4?.3:.1}const sn=p.lazy(()=>ps(()=>import("./PathMapMapLibre-CUvyj6hi.js"),__vite__mapDeps([0,1,2,3,4,5,6])));function an(t,n,s,a,r=!1,i,l,c){const o=fs(n);let u;l&&(u=gs(l,t,{position:c,isLastHop:r}).confidence);const{matches:x,probability:g}=Ja(t,o,a,i,r),f=x.length,y=[],m=t.toUpperCase(),v=s&&s.latitude!==void 0&&s.longitude!==void 0&&(s.latitude!==0||s.longitude!==0);for(const h of x){if(a&&Ze(m,a)&&h===a&&v&&s){y.push({hash:h,name:s.name||"Local Node",latitude:s.latitude,longitude:s.longitude,probability:r?1:g,isLocal:!0});continue}const N=o[h];N!=null&&N.latitude&&(N!=null&&N.longitude)&&!(N.latitude===0&&N.longitude===0)&&y.push({hash:h,name:N.node_name||N.name||"Unknown",latitude:N.latitude,longitude:N.longitude,probability:g,isLocal:!1,isDirectNeighbor:N.zero_hop===!0})}const T=y.length;if(T===1)y[0].probability=u??1;else if(T>1)if(u!==void 0&&u>0){const h=y[0];h.probability=u;const N=1-u,j=T-1;y.slice(1).forEach(C=>{C.probability=N/j})}else{let h=0;const N=y.map(j=>{if(j.isLocal)return{candidate:j,score:1};const C=i==null?void 0:i.get(j.hash);let k=.5;if(v&&s){const A=en(s.latitude,s.longitude,j.latitude,j.longitude);k=tn(A)}let b;return C?b=k*.3+C.hopConsistencyScore*.3+C.frequencyScore*.4:(b=k,j.isDirectNeighbor&&(b=Math.max(b,.8))),h+=b,{candidate:j,score:b}});if(h>0)N.forEach(({candidate:j,score:C})=>{j.probability=Math.min(.95,C/h)});else{const j=1/T;y.forEach(C=>C.probability=j)}}return{candidates:y,totalMatches:f}}function nn(t,n,s,a,r,i){if(!t||t.length===0)return{hops:[],overallConfidence:0,hasValidPath:!1};const l=t.length-1,c=t.map((x,g)=>{const f=g===l,y=t.length-g,{candidates:m,totalMatches:v}=an(x,n,s,a,f,r,i,y),T=m.length>0?Math.max(...m.map(h=>h.probability)):0;return{prefix:x,candidates:m,confidence:T,totalMatches:v}}),o=c.reduce((x,g)=>g.confidence===0?0:x*g.confidence,1),u=c.some(x=>x.candidates.length>0);return{hops:c,overallConfidence:o,hasValidPath:u}}function rn(t){return`${(t*100).toFixed(0)}%`}function ln(t){return t>=1?"text-sys-green":t>=.5?"text-sys-indigo":t>=.25?"text-signal-poor":t>0?"text-sys-red":"text-fg-muted"}function cn(t,n,s){let a;return n===0?a=s.muted:t>=1?a=s.success:t>=.5?a=s.secondary:t>=.25?a=s.poor:t>0?a=s.danger:a=s.muted,{color:a}}class on extends p.Component{constructor(n){super(n),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(et,{className:"w-4 h-4 mr-2"}),"Map failed to load"]}):this.props.children}}function We({path:t,neighbors:n,localNode:s,localHash:a,srcHash:r,dstHash:i,neighborAffinity:l,prefixLookup:c,hubNodes:o,traceSnr:u,advertiserSource:x}){const[g,f]=p.useState(null),y=p.useMemo(()=>{if(!x)return null;const j=x.nodeType==="wardrive";return{prefix:x.prefix||"??",candidates:[{hash:x.publicKey||x.prefix||"source",name:x.name,latitude:x.latitude,longitude:x.longitude,probability:1,isLocal:!1,isWardrive:j}],confidence:1,totalMatches:1,isSource:!0}},[x]),m=p.useMemo(()=>{if(x||!r)return null;const j=De(r),C=n[r];if((C==null?void 0:C.latitude)&&(C==null?void 0:C.longitude)&&!(C.latitude===0&&C.longitude===0))return{prefix:j,candidates:[{hash:r,name:C.node_name||C.name||"Source",latitude:C.latitude,longitude:C.longitude,probability:1,isLocal:!1,isDirectNeighbor:C.zero_hop===!0}],confidence:1,totalMatches:1,isSource:!0};const b=(C==null?void 0:C.node_name)||(C==null?void 0:C.name)||r.slice(0,8);return{prefix:j,candidates:[{hash:r,name:b,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isSource:!0}},[x,r,n]),v=p.useMemo(()=>{const j=i!=null&&i.startsWith("0x")?i.slice(2):i;if((!j||j==="00"||j==="0000000000000000")&&s&&a){const W=De(a),K=s.latitude!==0||s.longitude!==0;return{prefix:W,candidates:[{hash:a,name:s.name||"Local Node",latitude:K?s.latitude:0,longitude:K?s.longitude:0,probability:1,isLocal:!0}],confidence:1,totalMatches:1,isDestination:!0}}if(!i)return null;const k=De(i);if(a&&i===a&&s){const W=s.latitude!==0||s.longitude!==0;return{prefix:k,candidates:[{hash:i,name:s.name||"Local Node",latitude:W?s.latitude:0,longitude:W?s.longitude:0,probability:1,isLocal:!0}],confidence:1,totalMatches:1,isDestination:!0}}const b=n[i];if((b==null?void 0:b.latitude)&&(b==null?void 0:b.longitude)&&!(b.latitude===0&&b.longitude===0))return{prefix:k,candidates:[{hash:i,name:b.node_name||b.name||"Destination",latitude:b.latitude,longitude:b.longitude,probability:1,isLocal:!1,isDirectNeighbor:b.zero_hop===!0}],confidence:1,totalMatches:1,isDestination:!0};const U=(b==null?void 0:b.node_name)||(b==null?void 0:b.name)||i.slice(0,8);return{prefix:k,candidates:[{hash:i,name:U,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isDestination:!0}},[i,n,s,a]),T=p.useMemo(()=>nn(t,n,s,a,l,c),[t,n,s,a,l,c]),h=p.useMemo(()=>{const j=[];y?j.push(y):m&&j.push(m),j.push(...T.hops),v&&j.push(v);const C=j.reduce((b,A)=>A.confidence===0?0:b*A.confidence,1),k=j.some(b=>b.candidates.some(A=>A.latitude!==0||A.longitude!==0));return{hops:j,overallConfidence:C,hasValidPath:k}},[y,m,T,v]),N=p.useMemo(()=>{const j=getComputedStyle(document.documentElement);return{success:j.getPropertyValue("--sys-green").trim()||"#39D98A",secondary:j.getPropertyValue("--sys-indigo").trim()||"#F9D26F",poor:j.getPropertyValue("--signal-poor").trim()||"#FF8A5C",danger:j.getPropertyValue("--sys-red").trim()||"#FF5C7A",muted:j.getPropertyValue("--text-muted").trim()||"#767688"}},[]);return h.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:ln(h.overallConfidence),children:rn(h.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(Js,{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(on,{children:e.jsx(p.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(sn,{resolvedPath:h,localNode:s,hubNodes:o,hoveredHopIndex:g,onHoverHop:f,traceSnr:u})})})}),e.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:h.hops.map((j,C)=>{var W,K,F;const k=j.isSource===!0,b=j.isDestination===!0,A=g===C;let U;return k?U=`Source: ${((W=j.candidates[0])==null?void 0:W.name)||"Unknown"}`:b?U=`Destination: ${((K=j.candidates[0])==null?void 0:K.name)||"Unknown"}`:j.totalMatches===0?U="No matching nodes found":j.totalMatches===1?U=`Exact match: ${((F=j.candidates[0])==null?void 0:F.name)||"Unknown"}`:U=`${j.totalMatches} possible matches (${(j.confidence*100).toFixed(0)}% confidence)`,e.jsxs("div",{className:R("flex items-center gap-1 px-1.5 py-0.5 rounded type-data-xs cursor-pointer transition-all",A?"bg-sys-blue/20 ring-1 ring-sys-blue/50":"bg-elevated hover:bg-subtle",k&&"border border-sys-green/30",b&&"border border-sys-blue/30"),title:U,onMouseEnter:()=>f(C),onMouseLeave:()=>f(null),children:[k&&e.jsx("span",{className:"text-sys-green text-[8px] mr-0.5",children:"SRC"}),b&&e.jsx("span",{className:"text-sys-blue text-[8px] mr-0.5",children:"DST"}),e.jsx("span",{style:cn(j.confidence,j.totalMatches,N),children:j.prefix}),!k&&!b&&j.totalMatches>1&&e.jsxs("span",{className:"text-fg-muted",children:["×",j.totalMatches]}),!k&&!b&&j.totalMatches===0&&e.jsx("span",{className:"text-fg-muted",children:"?"})]},C)})})]}):e.jsxs("div",{className:"flex items-center justify-center text-fg-muted text-xs py-4",children:[e.jsx(Ue,{className:"w-3.5 h-3.5 mr-1.5 opacity-50"}),"No location data available for path nodes"]})}const Ye=16;function Ge(t){return t.match(/.{1,2}/g)||[]}function je(t){return t!==null&&t.startsWith("payload:")}const Te={hexRestOpacity:15,cardRestBg:"color-mix(in srgb, var(--elevated) 60%, var(--body))",cardRestShadow:` + 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) + `,selectionBorderWidth:2},at={type:"tween",duration:.25,ease:[.25,.1,.25,1]};function dn(t,n){return t?`inset 0 0 0 ${Te.selectionBorderWidth}px ${ue[n]}`:Te.cardRestShadow}function xn(t,n){return t?n:`color-mix(in srgb, ${n} ${Te.hexRestOpacity}%, transparent)`}function mn({segments:t,selectedSegment:n,onSegmentClick:s}){const[a,r]=p.useState(null),[i,l]=p.useState(null),c=t.some(x=>x.id!==void 0)&&s,o=[];for(const x of t){const g=Ge(x.hex);for(const f of g)o.push({byte:f.toUpperCase(),color:x.color,id:x.id})}const u=[];for(let x=0;x{const f=x.length{const h=T===x.length-1,N=f&&h,j=ue[m],b=(v?a===v:i===m)||!!(v&&n===v);return e.jsx("span",{className:`w-[1.75rem] text-xs text-center py-0.5 font-mono select-text ${c?"cursor-pointer":""}`,style:{backgroundColor:xn(b,j),color:b?"rgba(255,255,255,0.95)":j,transition:b?"none":"background-color 0.15s ease-out, color 0.15s ease-out",touchAction:"manipulation",...N?{borderRadius:"0 0.375rem 0.375rem 0"}:{}},onMouseEnter:()=>{v?r(v):l(m)},onMouseLeave:()=>{r(null),l(null)},onClick:()=>v&&(s==null?void 0:s(v)),onTouchStart:()=>{v?r(v):l(m)},onTouchEnd:()=>{r(null),l(null)},children:y},T)})},g)})})}function hn({rawHex:t,hexSegments:n,selectedSegment:s,onSegmentClick:a}){const[r,i]=p.useState(!1),l=p.useCallback(async()=>{try{await navigator.clipboard.writeText(t.toUpperCase()),i(!0),setTimeout(()=>i(!1),2e3)}catch(c){console.error("Failed to copy:",c)}},[t]);return e.jsxs("div",{className:"bg-black rounded-2xl p-6 relative",children:[e.jsx(mn,{segments:n,selectedSegment:s,onSegmentClick:a}),e.jsx("button",{onClick:l,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:r?e.jsxs(e.Fragment,{children:[e.jsx(bs,{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(it,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Copy"})]})})]})}function un(t,n){const s=[];let a=0;const r=n.slice(0,64);s.push({id:"payload:publicKey",title:"Public Key",color:"pink",hex:r,startByte:a,endByte:a+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:t.publicKey.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Ed25519 public key (32 bytes)"})]})}),a+=32;const i=n.slice(64,72);s.push({id:"payload:timestamp",title:"Timestamp",color:"orange",hex:i,startByte:a,endByte:a+3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:i.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:[t.timestamp," (",ie(t.timestamp),")"]})]})}),a+=4;const l=n.slice(72,200);s.push({id:"payload:signature",title:"Signature",color:"teal",hex:l,startByte:a,endByte:a+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:t.signature.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Ed25519 signature (64 bytes)"})]})}),a+=64;const c=n.slice(200,202);if(s.push({id:"payload:flags",title:"Flags",color:"blue",hex:c,startByte:a,endByte:a,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(X,{size:"standard",copy:!0,children:["0x",t.flags.toString(16).padStart(2,"0").toUpperCase()]}),e.jsx("p",{className:"text-xs text-fg-primary mt-1",children:t.flagsDescription}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["Node Type: ",t.nodeType]})]})}),a+=1,t.latitude!==void 0){const o=n.slice(a*2,a*2+8);s.push({id:"payload:latitude",title:"Latitude",color:"green",hex:o,startByte:a,endByte:a+3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:o.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:[t.latitude.toFixed(6),"°"]})]})}),a+=4}if(t.longitude!==void 0){const o=n.slice(a*2,a*2+8);s.push({id:"payload:longitude",title:"Longitude",color:"indigo",hex:o,startByte:a,endByte:a+3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:o.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:[t.longitude.toFixed(6),"°"]})]})}),a+=4}if(t.name){const o=n.slice(a*2),u=o.length/2;s.push({id:"payload:name",title:"Name",color:"amber",hex:o,startByte:a,endByte:a+u-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:o.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:['"',t.name,'"']})]})})}return s}function pn(t,n){return[{id:"payload:crc",title:"CRC",color:"green",hex:n.slice(0,8),startByte:0,endByte:3,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(X,{size:"standard",copy:!0,children:["0x",t.crc]}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"CRC32 of acknowledged packet"})]})}]}function fn(t,n){const s=[];s.push({id:"payload:channelHash",title:"Channel Hash",color:"blue",hex:n.slice(0,2),startByte:0,endByte:0,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(X,{size:"standard",copy:!0,children:["0x",t.channelHash]}),t.channelName&&e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:["Channel: ",t.channelName]})]})}),t.macHex&&s.push({id:"payload:mac",title:"MAC",color:"indigo",hex:n.slice(2,6),startByte:1,endByte:2,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:t.macHex.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Truncated HMAC-SHA256"})]})});const a=n.slice(6);return a&&s.push({id:"payload:ciphertext",title:t.decrypted?"Message":"Ciphertext",color:t.decrypted?"green":"zinc",hex:a,startByte:3,endByte:3+a.length/2-1,decoded:t.decrypted?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-sm text-fg-primary",children:['"',t.text,'"']}),t.senderName&&e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:["From: ",t.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:a.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"AES-128-ECB encrypted"})]})}),s}function gn(t,n){const s=[];s.push({id:"payload:channelHash",title:"Channel Hash",color:"blue",hex:n.slice(0,2),startByte:0,endByte:0,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(X,{size:"standard",copy:!0,children:["0x",t.channelHash]}),t.channelName&&e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:["Channel: ",t.channelName]})]})}),t.macHex&&s.push({id:"payload:mac",title:"MAC",color:"indigo",hex:n.slice(2,6),startByte:1,endByte:2,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:t.macHex.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Truncated HMAC-SHA256"})]})});const a=n.slice(6);return a&&s.push({id:"payload:ciphertext",title:t.decrypted?"Decrypted Data":"Encrypted Data",color:t.decrypted?"green":"zinc",hex:a,startByte:3,endByte:3+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:(t.decryptedHex||a).toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[t.dataLength," bytes",t.decrypted?"":" (AES-128-ECB encrypted)"]})]})}),s}function yn(t,n){const s=[];if(s.push({id:"payload:pathLength",title:"Path Length",color:"blue",hex:n.slice(0,2),startByte:0,endByte:0,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",children:t.pathLength}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[t.pathLength," hop",t.pathLength!==1?"s":""]})]})}),t.path.length>0){const a=n.slice(2,2+t.pathLength*2);s.push({id:"payload:path",title:"Path Hops",color:"amber",hex:a,startByte:1,endByte:t.pathLength,decoded:e.jsx(e.Fragment,{children:e.jsx("div",{className:"flex flex-wrap items-center gap-1",children:t.path.map((r,i)=>e.jsxs("span",{className:"flex items-center gap-1",children:[i>0&&e.jsx(pe,{className:"w-3 h-3 text-fg-muted"}),e.jsx(B,{color:"amber",className:"font-mono",children:r})]},i))})})})}if(t.extraType!=null){const a=1+t.pathLength;s.push({id:"payload:extraType",title:"Extra Type",color:"indigo",hex:n.slice(a*2,a*2+2),startByte:a,endByte:a,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",children:t.extraTypeName??`0x${t.extraType.toString(16).padStart(2,"0")}`}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Bundled payload type"})]})})}if(t.extraData){const a=1+t.pathLength+1,r=n.slice(a*2);r&&s.push({id:"payload:extraData",title:"Extra Data",color:"indigo",hex:r,startByte:a,endByte:a+r.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:r.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[r.length/2," bytes"]})]})})}return s}function jn(t,n){const s=[];s.push({id:"payload:crc",title:"Trace Tag",color:"blue",hex:n.slice(0,8),startByte:0,endByte:3,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(X,{size:"standard",copy:!0,children:["0x",t.traceTag]}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Unique trace request identifier"})]})}),s.push({id:"payload:mac",title:"Auth Code",color:"indigo",hex:n.slice(8,16),startByte:4,endByte:7,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:t.authCode}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Authentication/verification code"})]})}),s.push({id:"payload:flags",title:"Flags",color:"amber",hex:n.slice(16,18),startByte:8,endByte:8,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(X,{size:"standard",copy:!0,children:["0x",t.flags.toString(16).toUpperCase().padStart(2,"0")]}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:t.flags===0?"No flags set":`Flags: ${t.flags.toString(2).padStart(8,"0")}b`})]})});const a=n.slice(18);return a&&s.push({id:"payload:path",title:"Target Path",color:"indigo",hex:a,startByte:9,endByte:9+a.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap items-center gap-1",children:t.pathHashes.map((r,i)=>{const l=t.snrValues[i],c=l!==void 0?qs(l):"zinc";return e.jsxs("span",{className:"flex items-center gap-1",children:[i>0&&e.jsx(pe,{className:"w-3 h-3 text-fg-muted"}),e.jsx(B,{color:"indigo",className:"font-mono",children:r}),l!==void 0&&e.jsxs(B,{color:c,className:"font-mono",children:[l>=0?"+":"",Number.isInteger(l)?l:l.toFixed(1),"dB"]})]},i)})}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[t.pathHashes.length," target ",t.pathHashes.length===1?"hop":"hops",t.snrValues.length>0&&` • ${t.snrValues.length} SNR ${t.snrValues.length===1?"value":"values"} collected`,t.isComplete&&" • ✓ Complete"]})]})}),s}function bn(t,n){const s=[];s.push({id:"payload:msgId",title:"Message ID",color:"blue",hex:n.slice(0,4),startByte:0,endByte:1,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:t.messageId.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Unique message identifier"})]})}),s.push({id:"payload:partNum",title:"Part Number",color:"amber",hex:n.slice(4,6),startByte:2,endByte:2,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:t.partNumber}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"0-indexed part number"})]})}),s.push({id:"payload:totalParts",title:"Total Parts",color:"orange",hex:n.slice(6,8),startByte:3,endByte:3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(X,{size:"standard",copy:!0,children:t.totalParts}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:["Part ",t.partNumber+1," of ",t.totalParts]})]})});const a=n.slice(8);return a&&s.push({id:"payload:partData",title:"Part Data",color:"cyan",hex:a,startByte:4,endByte:4+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"]})]})}),s}function Nn(t,n){switch(t.type){case"advert":return un(t,n);case"ack":return pn(t,n);case"grp_txt":return fn(t,n);case"grp_data":return gn(t,n);case"path":return yn(t,n);case"trace":return jn(t,n);case"multipart":return bn(t,n);default:return[{id:"payload:ciphertext",title:"Raw Data",color:"zinc",hex:n,startByte:0,endByte: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"]})]})}]}}function vn(t){return t.map(n=>({id:n.id,hex:n.hex,color:n.color}))}function wn({bits:t,field:n,value:s,binary:a}){const r=()=>{if(n==="Payload Type"){const i=Be[s]||"zinc";return e.jsx(B,{color:i,children:s})}if(n==="Route Type"){const i=He[s]||"zinc";return e.jsx(B,{color:i,children:s})}return e.jsx("span",{className:"text-sm text-fg-primary",children:s})};return e.jsxs("tr",{children:[e.jsx("td",{className:"py-1.5 text-xs text-fg-muted tabular-nums",children:t}),e.jsx("td",{className:"py-1.5 text-sm text-fg-secondary",children:n}),e.jsx("td",{className:"py-1.5",children:r()}),e.jsx("td",{className:"py-1.5 type-data-xs text-sys-cyan",children:a})]})}function Ct({id:t,title:n,color:s,hexBytes:a,startByte:r,endByte:i,isSelected:l,children:c}){const o=a?Ge(a):[];return e.jsxs(oe.div,{layout:"position",layoutId:t,transition:at,className:"w-full min-w-0 overflow-hidden rounded-xl p-4 sm:p-5 space-y-4",style:{backgroundColor:Te.cardRestBg,boxShadow:dn(l,s)},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:s,children:n}),o.length>0&&o.length<=16&&o.map((u,x)=>e.jsx(B,{color:s,className:"font-mono",children:u.toUpperCase()},x))]}),e.jsxs("span",{className:"type-data-xs text-fg-muted flex-shrink-0",children:["Bytes ",r,"-",i]})]}),e.jsx("div",{className:"min-w-0 overflow-hidden",children:c})]})}function kn({advert:t,timestamp:n}){const s=n?ie(n):ie(t.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(de,{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:t.name||"Unknown Node"}),e.jsx("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:t.nodeType})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-2",children:[t.latitude!==void 0&&t.longitude!==void 0&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ue,{className:"w-4 h-4 text-sys-indigo flex-shrink-0"}),e.jsxs("span",{className:"text-sm text-fg-secondary font-mono",children:[t.latitude.toFixed(5),"°, ",t.longitude.toFixed(5),"°"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(xe,{className:"w-4 h-4 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:s})]})]})]})})}function Cn({decoded:t,timestamp:n}){const s=n?ie(n):"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:t.channelName||"Channel Data"}),e.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:[t.dataLength," bytes • ",t.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(Kt,{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",t.channelHash]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(xe,{className:"w-4 h-4 text-sys-teal flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:s})]}),t.decrypted&&t.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(X,{size:"compact",copy:!0,className:"inline-block",children:e.jsx("span",{className:"break-all text-xs",children:t.decryptedHex.toUpperCase()})})})]})]})]})})}function Sn({decoded:t,timestamp:n,isLoading:s=!1,onDecrypted:a}){const r=n?ie(n):"Unknown",[i,l]=p.useState(""),[c,o]=p.useState(!1),[u,x]=p.useState(null),[g,f]=p.useState(!1),y=p.useCallback(async()=>{if(!(!i.trim()||!t.ciphertextHex||!t.macHex)){o(!0),x(null);try{const m=parseInt(t.channelHash,16),v=ut(t.macHex),T=ut(t.ciphertextHex),h=await vs(i.trim(),m,v,T);if(h.success){const N=h.result.plaintext,j=new TextDecoder("utf-8",{fatal:!1}).decode(N.slice(5)),C=j.indexOf(": "),k={...t,channelName:h.result.channelName,decrypted:!0,timestamp:N[0]|N[1]<<8|N[2]<<16|N[3]<<24,flags:N[4],senderName:C>0?j.slice(0,C):void 0,text:C>0?j.slice(C+2):j};a==null||a(k),l(""),f(!1)}else x(h.error)}catch(m){x(m instanceof Error?m.message:"Unknown error")}finally{o(!1)}}},[i,t,a]);return s?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"})]})})]})}):t.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:[t.senderName&&e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:["From ",e.jsx("span",{className:"text-fg-secondary font-medium",children:t.senderName})]}),t.channelName&&e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:["in ",e.jsx("span",{className:"text-sys-cyan font-medium",children:t.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:t.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(ot,{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:t.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",t.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(xe,{className:"w-4 h-4 text-zinc-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:r})]}),t.ciphertextHex&&t.macHex&&e.jsx("div",{className:"space-y-2",children:g?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:i,onChange:m=>l(m.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:m=>m.key==="Enter"&&y(),disabled:c}),e.jsx("button",{onClick:y,disabled:c||!i.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:()=>{f(!1),x(null),l("")},className:"px-2 py-1.5 text-sm rounded-lg hover:bg-subtle-fill-strong text-fg-muted transition-colors",children:"×"})]}),u&&e.jsx("p",{className:"text-xs text-sys-red",children:u})]}):e.jsx("button",{onClick:()=>f(!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"})}),!g&&e.jsx("p",{className:"text-xs text-fg-muted",children:t.isPublicHashChannel?"Public hash channel message. Key not in common channel list.":"Unknown hash channel. Channel name required for decryption."})]})]})})}function _n({decoded:t,timestamp:n}){const s=n?ie(n):"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(sa,{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",t.crc]})," · ",s]})]})]})}function Mn({decoded:t,timestamp:n}){const s=n?ie(n):"Unknown",a=t.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(Ma,{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:[a," ",a===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(xe,{className:"w-4 h-4 text-sys-amber flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:s})]}),t.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:t.path.map((r,i)=>e.jsxs("div",{className:"flex items-center gap-2",children:[i>0&&e.jsx(pe,{className:"w-4 h-4 text-sys-amber"}),e.jsx(B,{color:"amber",className:"font-mono",children:r})]},i))})})]})]})})}function Tn({decoded:t,timestamp:n}){const s=n?ie(n):"Unknown",a=t.pathHashes.length,r=t.snrValues.length,i=l=>l>=7?"green":l>=0?"yellow":l>=-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 ",t.isComplete?"Complete":"In Progress"]}),e.jsxs("p",{className:"text-sm text-fg-muted mt-0.5",children:["Tag: 0x",t.traceTag.slice(0,8),t.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(xe,{className:"w-4 h-4 text-sys-blue flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary",children:s})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-fg-muted",children:[e.jsxs("span",{children:[a," target ",a===1?"hop":"hops"]}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:[r," SNR ",r===1?"sample":"samples"]}),t.authCode!==0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs("span",{children:["Auth: ",t.authCode]})]})]}),t.pathHashes.length>0&&e.jsx("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:t.pathHashes.map((l,c)=>{const o=t.snrValues[c],u=o!==void 0?i(o):"zinc",x=o!==void 0;return e.jsxs("div",{className:"flex items-center gap-2",children:[c>0&&e.jsx(pe,{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:x?"blue":"zinc",className:"font-mono",children:l}),x&&e.jsxs(B,{color:u,className:"font-mono",children:[o>=0?"+":"",Number.isInteger(o)?o:o.toFixed(1),"dB"]})]})]},c)})})]})]})})}function Pn({decoded:t,timestamp:n}){const s=n?ie(n):"Unknown";return t.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(ot,{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:[t.srcHash," → ",t.destHash," · ",s]})]})]}):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:t.srcHash})," → ",e.jsx("span",{className:"font-mono text-fg-secondary",children:t.destHash})]}),e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:["· ",s]})]}),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:t.text})})]})}function Bn({decoded:t,timestamp:n}){const s=n?ie(n):"Unknown",a=(t.partNumber+1)/t.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 ",t.partNumber+1," of ",t.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:`${a}%`,background:"linear-gradient(90deg, var(--sys-yellow), var(--sys-amber))"}})})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Kt,{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:t.messageId})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(xe,{className:"w-4 h-4 text-sys-yellow flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:s})]})]})]})})}function Ln({decoded:t,timestamp:n,payloadType:s}){const a=n?ie(n):"Unknown",i=(()=>{switch(s){case re.REQ:return{icon:ws,gradient:"var(--sys-orange), var(--sys-red)",bg:"rgba(249, 115, 22, 0.15)",label:"Request"};case re.RESPONSE:return{icon:Sa,gradient:"var(--sys-green), var(--sys-teal)",bg:"rgba(34, 197, 94, 0.15)",label:"Response"};case re.ANON_REQ:return{icon:ot,gradient:"var(--sys-indigo), var(--sys-pink)",bg:"rgba(91, 91, 214, 0.15)",label:"Anonymous Request"};default:return{icon:Xs,gradient:"var(--sys-gray), var(--sys-slate)",bg:"rgba(107, 114, 128, 0.15)",label:t.payloadTypeName}}})(),l=i.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, ${i.gradient})`},children:e.jsx(l,{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:i.label}),e.jsxs("p",{className:"text-xs text-fg-muted font-sans mt-0.5",children:[t.length," bytes · ",a]})]})]})}function Rn({pathHex:t}){if(!t)return null;const n=Ge(t);return e.jsx("div",{className:"flex flex-wrap items-center gap-2 py-2",children:n.map((s,a)=>e.jsxs("div",{className:"flex items-center gap-2",children:[a>0&&e.jsx(pe,{className:"w-4 h-4 text-sys-amber flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(X,{size:"compact",copy:!0,children:s.toUpperCase()}),e.jsx("span",{className:"text-xs text-fg-muted font-sans tabular-nums w-4 text-left",children:a+1})]})]},a))})}function En({decoded:t,payloadType:n}){const s=Ns[n]||`TYPE_${n}`;switch(t.type){case"advert":{const a=t.nodeType==="chat"?"companion":t.nodeType.replace("_"," "),r=t.latitude!==void 0&&t.longitude!==void 0&&!(t.latitude===0&&t.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:"})," ",a]}),t.name&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Name:"})," ",t.name]}),r&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Location:"})," ",t.latitude.toFixed(4),"°, ",t.longitude.toFixed(4),"°"]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Time:"})," ",ie(t.timestamp)]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Flags:"})," ",t.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",t.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:"})," ",t.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",t.traceTag]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Target Path:"})," ",t.pathString||"(empty)"]}),t.snrValues.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"SNR:"})," ",t.snrValues.map(a=>`${a>=0?"+":""}${Number.isInteger(a)?a:a.toFixed(1)}dB`).join(" → ")]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Status:"})," ",t.isComplete?"✓ Complete":`In progress (${t.snrValues.length}/${t.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:"})," ",t.destHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Src:"})," ",t.srcHash]}),t.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:"})," ",t.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:"})," ",t.channelName?e.jsx("span",{className:"text-sys-green",children:t.channelName}):t.isPublicHashChannel?e.jsx("span",{className:"text-sys-indigo",children:"Public Hash Channel"}):e.jsxs("span",{className:"font-mono",children:["0x",t.channelHash]})]}),t.decrypted?e.jsxs(e.Fragment,{children:[t.senderName&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"From:"})," ",t.senderName]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Text:"})," ",t.text]})]}):t.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:"})," ",t.channelName?e.jsx("span",{className:"text-sys-teal",children:t.channelName}):e.jsxs("span",{className:"font-mono",children:["0x",t.channelHash]})]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Data:"})," ",t.dataLength," bytes ",t.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:"})," ",t.partNumber+1,"/",t.totalParts]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Message ID:"})," ",t.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:"})," ",t.subtypeName]}),t.dataLength>0&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Data:"})," ",t.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:"})," ",t.destHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Src:"})," ",t.srcHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Ciphertext:"})," ",t.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:"})," ",t.destHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Pub Key:"})," ",e.jsxs("span",{className:"font-mono break-all",children:[t.senderPublicKey.slice(0,16),"…"]})]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Ciphertext:"})," ",t.ciphertextLength," bytes"]})]});default:return e.jsxs("p",{className:"text-xs text-fg-secondary",children:[s," (","length"in t?t.length:0," bytes)"]})}}function zn({packet:t,decodedGrpTxt:n}){var F,Y;const s=t.raw_packet||"",a=s.length/2,r=ys(),[i,l]=p.useState(null),[c,o]=p.useState(null),[u,x]=p.useState(!1),[g,f]=p.useState(null),y=p.useCallback(D=>{f(E=>E===D?null:D)},[]),m=p.useMemo(()=>Is(s),[s]),v=(F=m==null?void 0:m.packet)==null?void 0:F.payloadType,T=(m==null?void 0:m.payloadHex)||"",h=(Y=m==null?void 0:m.packet)==null?void 0:Y.payload,N=v===re.GRP_TXT,j=v===re.GRP_DATA,C=N&&!n&&(!r||u);if(p.useEffect(()=>{if(l(null),x(!1),n||!N||!h||h.length<4)return;if(!r){x(!0);return}x(!0);let D=!1;return Ks(h).then(E=>{D||(l(E),x(!1))}),()=>{D=!0}},[T,N,r,n]),p.useEffect(()=>{if(o(null),!j||!h||h.length<4||!r)return;let D=!1;return Ys(h).then(E=>{D||o(E)}),()=>{D=!0}},[T,j,r]),!m||s.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:k}=m;let b=m.decoded;n&&m.decoded.type==="grp_txt"?b=n:i&&m.decoded.type==="grp_txt"?b=i:c&&m.decoded.type==="grp_data"&&(b=c);const A=()=>{switch(b.type){case"advert":return e.jsx(kn,{advert:b,timestamp:t.timestamp});case"grp_data":return e.jsx(Cn,{decoded:b,timestamp:t.timestamp});case"grp_txt":return e.jsx(Sn,{decoded:b,timestamp:t.timestamp,isLoading:C,onDecrypted:l});case"ack":return e.jsx(_n,{decoded:b,timestamp:t.timestamp});case"path":return e.jsx(Mn,{decoded:b,timestamp:t.timestamp});case"trace":return e.jsx(Tn,{decoded:b,timestamp:t.timestamp});case"txt_msg":return e.jsx(Pn,{decoded:b,timestamp:t.timestamp});case"multipart":return e.jsx(Bn,{decoded:b,timestamp:t.timestamp});case"generic":return k.payloadType===re.REQ||k.payloadType===re.RESPONSE||k.payloadType===re.ANON_REQ?e.jsx(Ln,{decoded:b,timestamp:t.timestamp,payloadType:k.payloadType}):null;default:return null}},U=p.useMemo(()=>Nn(b,m.payloadHex),[b,m.payloadHex]),W=g==="payload"||je(g),K=p.useMemo(()=>{const D=[{id:"header",hex:m.headerHex,color:"red"},...m.transportCodesHex?[{id:"transportCodes",hex:m.transportCodesHex,color:"indigo"}]:[],{id:"pathLength",hex:m.pathLengthHex,color:"green"},...m.pathDataHex?[{id:"pathData",hex:m.pathDataHex,color:"amber"}]:[]];return W?[...D,...vn(U)]:[...D,{id:"payload",hex:m.payloadHex,color:"cyan"}]},[m,W,U]);return e.jsxs("div",{className:"font-mono space-y-2 min-w-0 overflow-hidden",children:[A(),e.jsx(hn,{rawHex:s,hexSegments:K,selectedSegment:g,onSegmentClick:y}),e.jsx(js,{children:e.jsx(oe.div,{layout:!0,transition:at,className:"space-y-2 min-w-0",children:(()=>{var M,H,te,se;const E=[{id:"header",title:"Header",color:"red",startByte:0,endByte:0,hexBytes:`0x${m.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 border-b border-edge-subtle font-sans",children:[e.jsx("th",{className:"py-1 font-medium",children:"Bits"}),e.jsx("th",{className:"py-1 font-medium",children:"Field"}),e.jsx("th",{className:"py-1 font-medium",children:"Value"}),e.jsx("th",{className:"py-1 font-medium",children:"Binary"})]})}),e.jsx("tbody",{children:m.headerFields.map(d=>e.jsx(wn,{...d},d.bits))})]})},{id:"transportCodes",title:"Transport Codes",color:"indigo",startByte:1,endByte:4,hexBytes:((M=m.transportCodesHex)==null?void 0:M.toUpperCase())||"",condition:!!m.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",(H=m.transportCodesHex)==null?void 0:H.slice(0,4).toUpperCase()," | Code 2: 0x",(te=m.transportCodesHex)==null?void 0:te.slice(4,8).toUpperCase()]})]})},{id:"pathLength",title:"Path Length",color:"green",startByte:m.transportCodesHex?5:1,endByte:m.transportCodesHex?5:1,hexBytes:`0x${m.pathLengthHex.toUpperCase()}`,condition:!0,content:e.jsxs("p",{className:"text-xs text-fg-muted pt-1",children:[k.pathLen," bytes showing route taken (increases as packet floods)"]})},{id:"pathData",title:"Path Data",color:"amber",startByte:m.transportCodesHex?6:2,endByte:(m.transportCodesHex?5:1)+k.pathLen,hexBytes:((se=m.pathDataHex)==null?void 0:se.toUpperCase())||"",condition:k.pathLen>0,content:e.jsxs("div",{className:"space-y-3",children:[e.jsx(Rn,{pathHex:m.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:m.payloadStartByte,endByte:a-1,hexBytes:m.payloadHex.toUpperCase(),condition:!0,content:e.jsxs(e.Fragment,{children:[!je(g)&&e.jsxs("div",{className:"p-3 rounded-lg bg-black",children:[e.jsx("p",{className:"type-micro text-fg-muted mb-1.5 font-sans",children:"Decoded"}),e.jsx(En,{decoded:b,payloadType:k.payloadType})]}),!je(g)&&U.length>0&&e.jsx("p",{className:"type-micro text-fg-muted mt-3 font-sans",children:"Click a field below to highlight its bytes"}),je(g)&&e.jsx("p",{className:"type-micro text-fg-muted font-sans",children:"↑ Selected field above • Other fields below ↓"})]})}].filter(d=>d.condition),O=je(g)?U.find(d=>d.id===g):null,$=je(g)?[...E].sort((d,Z)=>d.id==="payload"?-1:Z.id==="payload"?1:0):[...E].sort((d,Z)=>d.id===g?-1:Z.id===g?1:0),J=je(g)?U.filter(d=>d.id!==g):[];return e.jsxs(e.Fragment,{children:[O&&e.jsx(Ct,{id:`subfield-${O.id}`,title:O.title,color:O.color,startByte:m.payloadStartByte+O.startByte,endByte:m.payloadStartByte+O.endByte,hexBytes:O.hex.toUpperCase(),isSelected:!0,children:O.decoded},O.id),$.map(d=>e.jsx(Ct,{id:`section-${d.id}`,title:d.title,color:d.color,startByte:d.startByte,endByte:d.endByte,hexBytes:d.hexBytes,isSelected:d.id===g,children:d.content},d.id)),J.map(d=>e.jsxs(oe.div,{layout:"position",layoutId:`subfield-${d.id}`,transition:at,className:"w-full min-w-0 overflow-hidden rounded-xl p-4 sm:p-5 space-y-4",style:{backgroundColor:Te.cardRestBg,boxShadow:Te.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:d.color,children:d.title}),d.hex.length<=32&&Ge(d.hex).map((Z,q)=>e.jsx(B,{color:d.color,className:"font-mono",children:Z.toUpperCase()},q))]}),e.jsxs("span",{className:"type-data-xs text-fg-muted flex-shrink-0",children:["Bytes ",m.payloadStartByte+d.startByte,"-",m.payloadStartByte+d.endByte]})]}),e.jsx("div",{className:"min-w-0 overflow-hidden p-3 rounded-lg bg-black",children:d.decoded})]},d.id))]})})()})})]})}const St=p.memo(zn);function _t(t){if(!t)return[];if(Array.isArray(t))return t;try{const n=JSON.parse(t);return Array.isArray(n)?n:[]}catch{return[]}}function nt({hop:t,compact:n=!1,index:s=0,highlightIndex:a=-1,isTrace:r=!1}){var c;const i=s===a,l=za();return p.useEffect(()=>{i&&r&&l.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"}})},[i,r,l]),e.jsxs(oe.div,{className:R("flex items-center gap-1.5",n?"flex-row":"flex-col"),animate:{scale:i?1.05:1,opacity:i?1:.85},transition:{duration:.3,ease:"easeInOut"},children:[e.jsxs(oe.div,{className:R("flex items-center gap-1.5 px-2.5 py-1 rounded-md","font-mono text-xs font-semibold",t.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:l,initial:{boxShadow:"0 0 0 0px rgba(113, 156, 223, 0)"},children:[t.isLocal&&e.jsx(na,{className:"w-3 h-3"}),e.jsx("span",{children:t.prefix}),t.confidence!==void 0&&t.confidence<.9&&e.jsxs("span",{className:"text-[9px] opacity-70",children:[(t.confidence*100).toFixed(0),"%"]})]}),!n&&((c=t.neighborInfo)==null?void 0:c.name)&&e.jsx("span",{className:"text-xs text-fg-muted truncate max-w-[80px]",children:t.neighborInfo.name})]})}function Fn({snr:t,sf:n}){const s=_s(t,n),r=Ss()[s]||"#6b7280",i=Number.isInteger(t)?t.toString():t.toFixed(1);return e.jsxs(B,{customColor:r,compact:!0,className:"font-mono",children:[t>=0?"+":"",i,"dB"]})}function In({hops:t,compact:n,isTrace:s=!1,sf:a}){const[r,i]=p.useState(-1);return p.useEffect(()=>{if(t.length===0)return;const l=setTimeout(()=>{i(0)},400),c=setInterval(()=>{i(o=>{const u=o+1;return u>=t.length?(clearInterval(c),-1):u})},s?500:600);return()=>{clearTimeout(l),clearInterval(c)}},[t.length,s]),e.jsx("div",{className:"p-6",style:{display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:"4px 8px"},children:t.map((l,c)=>{const o=c%2===0,u=c===t.length-1;return e.jsxs("div",{className:"contents",children:[e.jsx("div",{className:R("flex items-center","justify-end"),children:o&&e.jsx(nt,{hop:l,compact:n,index:c,highlightIndex:r,isTrace:s})}),e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[28px]",children:!u&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px flex-1 bg-border-strong/40 min-h-[8px]"}),l.snr!==void 0&&e.jsx(Fn,{snr:l.snr,sf:a}),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:R("flex items-center","justify-start"),children:!o&&e.jsx(nt,{hop:l,compact:n,index:c,highlightIndex:r,isTrace:s})})]},`${l.prefix}-${c}`)})})}function An({packet:t,neighbors:n,localHash:s,neighborAffinity:a,ghostPrefixes:r,direction:i="horizontal",compact:l=!1,traceSnr:c,overridePath:o}){const u=c!==void 0&&c.length>0,x=ks(),g=_t(t.original_path),f=_t(t.forwarded_path),y=o??(f.length>0?f:g),m=s?De(s):"",v=p.useMemo(()=>y.map((h,N)=>{const j=h.toUpperCase(),C=j===m,k=(r==null?void 0:r.has(j))??!1,b=Cs(j,n,a);return{prefix:j,fullHash:b==null?void 0:b.hash,neighborInfo:b==null?void 0:b.info,isLocal:C,isGhost:k,confidence:b==null?void 0:b.confidence,snr:c==null?void 0:c[N]}}),[y,n,a,m,r,c]);if(v.length===0)return e.jsxs("div",{className:"flex items-center gap-2 text-fg-muted text-xs",children:[e.jsx(de,{className:"w-4 h-4 opacity-50"}),e.jsx("span",{children:"Direct / No path data"})]});if(i==="flowchart")return e.jsx(In,{hops:v,compact:l,isTrace:u,sf:x});const T=i==="horizontal"?pe:qt;return e.jsx("div",{className:R("flex gap-1.5",i==="horizontal"?"flex-row flex-wrap items-center":"flex-col items-start"),children:v.map((h,N)=>e.jsxs("div",{className:R("flex items-center gap-1.5",i==="vertical"&&"flex-col"),children:[e.jsx(nt,{hop:h,compact:l}),N"blue",Dn=[{fn:"id",group:"identity",fmt:"int",read:t=>ee(t.id),color:V},{fn:"packet_hash",group:"identity",fmt:"hex",read:t=>t.packet_hash||void 0,color:V},{fn:"timestamp",group:"identity",fmt:"epoch",read:t=>t.timestamp?String(t.timestamp):void 0,color:V,annotate:t=>t.timestamp>0?Je(t.timestamp):void 0},{fn:"type",group:"classification",fmt:"enum",read:t=>ee(t.type??t.payload_type),color:V},{fn:"route",group:"classification",fmt:"enum",read:t=>ee(t.route??t.route_type),color:V},{fn:"rssi",group:"signal",fmt:"int",read:t=>ee(t.rssi,"dBm"),color:V},{fn:"snr",group:"signal",fmt:"float",read:t=>ee(t.snr,"dB"),color:V},{fn:"path_length",group:"size",fmt:"int",read:t=>{if(t.path_length!=null)return t.path_length===0?"zero-hop":`${t.path_length} hops`},color:V},{fn:"payload_length",group:"size",fmt:"int",read:t=>ee(t.payload_length,"B"),color:V},{fn:"airtime",group:"size",fmt:"float",read:t=>ee(t.airtime_ms,"ms"),color:V},{fn:"src_hash",group:"addressing",fmt:"hex<2>",read:t=>t.src_hash??void 0,color:V},{fn:"dst_hash",group:"addressing",fmt:"hex<2>",read:t=>t.dst_hash??void 0,color:V},{fn:"path_hash",group:"addressing",fmt:"hex[]|hex",read:t=>Array.isArray(t.path_hash)?`[${t.path_hash.join(", ")}]`:ee(t.path_hash),color:V,renderValue:t=>Array.isArray(t.path_hash)?Xe(t.path_hash):null},{fn:"score",group:"addressing",fmt:"int",read:t=>ee(t.score),color:V},{fn:"original_path",group:"paths",fmt:"hex[]",read:t=>Array.isArray(t.original_path)?`[${t.original_path.join(", ")}]`:void 0,color:V,renderValue:t=>Array.isArray(t.original_path)&&t.original_path.length>0?Xe(t.original_path,t.src_hash||void 0,t.dst_hash||void 0,!0):null},{fn:"forwarded_path",group:"paths",fmt:"hex[]",read:t=>Array.isArray(t.forwarded_path)?`[${t.forwarded_path.join(", ")}]`:void 0,color:V,renderValue:t=>Array.isArray(t.forwarded_path)&&t.forwarded_path.length>0?Xe(t.forwarded_path):null},{fn:"transmitted",group:"status",fmt:"bool",read:t=>ee(t.transmitted),color:V},{fn:"is_duplicate",group:"status",fmt:"bool",read:t=>ee(t.is_duplicate),color:V},{fn:"drop_reason",group:"status",fmt:"string|null",read:t=>t.drop_reason??void 0,color:V},{fn:"tx_delay",group:"status",fmt:"int",read:t=>ee(t.tx_delay_ms,"ms"),color:V},{fn:"origin",group:"status",fmt:"enum",read:t=>t.packet_origin??void 0,color:V},{fn:"duplicates",group:"status",fmt:"PacketDuplicate[]",read:t=>t.duplicates!=null&&t.duplicates.length>0?`${t.duplicates.length}`:ee(t.duplicates),color:V},{fn:"lbt_attempts",group:"lbt",fmt:"int",read:t=>ee(t.lbt_attempts),color:V},{fn:"lbt_backoff",group:"lbt",fmt:"json",read:t=>ee(t.lbt_backoff_delays_ms),color:V},{fn:"lbt_busy",group:"lbt",fmt:"bool|int",read:t=>ee(t.lbt_channel_busy),color:V}];function Xe(t,n,s,a){const r=t.length>0,i=n||a,l=s||a;return e.jsxs("span",{className:"inline-flex items-center gap-1 flex-wrap",children:[i&&e.jsxs(e.Fragment,{children:[n?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:n}):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"}),(r||l)&&e.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"})]}),t.map((c,o)=>e.jsxs(p.Fragment,{children:[o>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})]},o)),l&&e.jsxs(e.Fragment,{children:[r&&e.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"}),s?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:s}):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 Ie=null;function Hn(){if(!Ie){Ie=new Map;for(const t of Dn)Ie.set(t.fn,t)}return Ie}function Mt(t,n){var l;const s=Hn().get(n);if(!s)return null;const a=s.read(t);if(a===void 0)return null;const r=s.color(t),i=(l=s.annotate)==null?void 0:l.call(s,t);return i?{text:a,color:r,annotation:i}:{text:a,color:r}}function Tt(t){if(!t)return[];if(Array.isArray(t))return t;try{const n=JSON.parse(t);return Array.isArray(n)?n:[]}catch{return[]}}function Pt({packets:t,selectedIndex:n,onSelect:s,compact:a=!1}){if(t.length<=1)return null;const r=n>0,i=nr&&s(n-1),disabled:!r,className:R("p-0.5 radius-badge transition-base",r?"text-fg-muted hover:text-fg-primary hover-bg":"text-fg-muted cursor-not-allowed"),"aria-label":"Previous observation",children:e.jsx(Yt,{className:a?"size-3":"size-4"})}),e.jsx("div",{className:"flex items-center gap-0.5",children:t.map((l,c)=>{const o=c===n,x=new Date(l.timestamp*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"});return e.jsx(Es,{color:o?"cyan":"zinc",filled:o,compact:a,onClick:()=>s(c),title:`Observation ${c+1} at ${x}`,className:R("transition-all duration-150",!o&&"opacity-60 hover:opacity-100"),children:a?e.jsx("span",{className:"tabular-nums",children:c+1}):e.jsxs("span",{className:"tabular-nums text-xs",children:["#",c+1,l.rssi!=null&&e.jsx("span",{className:"ml-1 opacity-70",children:l.rssi})]})},`${l.timestamp}_${c}`)})}),e.jsx("button",{onClick:()=>i&&s(n+1),disabled:!i,className:R("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":"Next observation",children:e.jsx(ct,{className:a?"size-3":"size-4"})}),e.jsxs("span",{className:R("text-fg-muted ml-1",a?"text-[9px]":"text-xs"),children:[e.jsx(it,{className:"inline size-3 mr-0.5 opacity-50"}),t.length]})]})}function Ae({icon:t,label:n,disabled:s=!1}){return e.jsx(oe.div,{className:"flex items-center gap-1 text-xs",title:n,animate:{opacity:s?.25:.6},transition:{duration:.15,ease:[.4,0,.2,1]},children:e.jsx("span",{className:R("flex items-center justify-center size-5 radius-badge border-control transition-base",s?"bg-subtle-fill border-edge-subtle":"bg-subtle-fill"),children:t})})}function On({hasDuplicates:t,hasPrev:n,hasNext:s,canPrevDupe:a,canNextDupe:r}){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(Ae,{icon:e.jsx(ja,{className:"size-3"}),label:"Previous packet (↑)",disabled:!n}),e.jsx(Ae,{icon:e.jsx(zs,{className:"size-3"}),label:"Next packet (↓)",disabled:!s})]}),t&&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(Ae,{icon:e.jsx(Yt,{className:"size-3"}),label:"Previous observation (←)",disabled:!a}),e.jsx(Ae,{icon:e.jsx(ct,{className:"size-3"}),label:"Next observation (→)",disabled:!r})]})]})]})}function $n({packets:t,initialIndex:n=0,onClose:s,onNavigatePrev:a,onNavigateNext:r,hasPrev:i=!1,hasNext:l=!1,resolveSource:c,getDecodedContent:o}){var ze;const[u,x]=p.useState(n),g=t[u]??t[0],f=t.length>1,[y,m]=p.useState(null),[v,T]=p.useState(!1);p.useEffect(()=>{if(!g._stripped){m(null);return}let G=!1;T(!0);const w=g.packet_hash;if(!w){T(!1);return}return Ms(w).then(S=>{G||(S.success&&S.data&&(m(S.data),(S.data.type??S.data.payload_type)===re.GRP_TXT&&S.data.raw_packet&&Ts.getState().queueDecryption([S.data])),T(!1))}).catch(()=>{G||T(!1)}),()=>{G=!0}},[g]);const h=y??g,N=u>0,j=u{x(Math.max(0,Math.min(G,t.length-1)))},[t.length]);p.useEffect(()=>{const G=w=>{if(!(w.target instanceof HTMLInputElement||w.target instanceof HTMLTextAreaElement))switch(w.key){case"ArrowUp":w.preventDefault(),a==null||a();break;case"ArrowDown":w.preventDefault(),r==null||r();break;case"ArrowLeft":w.preventDefault(),N&&x(S=>S-1);break;case"ArrowRight":w.preventDefault(),j&&x(S=>S+1);break}};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[a,r,N,j]);const k=Ht(),b=Ps(),A=Bs(),U=Ls(),W=p.useMemo(()=>new Set(U.map(G=>G.prefix.toUpperCase())),[U]),K=h.payload_type_name||At(h.payload_type??h.type),F=h.route_type_name||Dt(h.route_type??h.route),Y=h.payload_length??h.length??0,D=Tt(h.original_path),E=Tt(h.forwarded_path),O=D.length>0||E.length>0,$=E.length>0?E:D,J=p.useMemo(()=>{var G;if((G=k==null?void 0:k.config)!=null&&G.repeater)return{latitude:k.config.repeater.latitude,longitude:k.config.repeater.longitude,name:k.config.node_name||"Local Node"}},[k]),M=(k==null?void 0:k.neighbors)??{},H=A.size>0?A:void 0,te=h.raw_packet&&h.raw_packet.length>0,se=g._stripped&&v,d=p.useMemo(()=>c?c(h):null,[c,h]),Z=Rs(h.packet_hash),q=p.useMemo(()=>!o||(h.payload_type??h.type)!==re.GRP_TXT?null:o(h),[o,h]),le=p.useMemo(()=>{if((h.payload_type??h.type)!==re.GRP_TXT)return null;if(Z!=null&&Z.decoded){const w=Z.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 q!=null&&q.decrypted?{type:"grp_txt",channelHash:q.channelHash??"",channelName:q.channelName??"",text:q.text??"",decrypted:!0,senderName:q.senderName??"",timestamp:0,flags:0,macCorrupted:q.corrupted}:null},[h,Z,q]),P=p.useMemo(()=>As(h,le),[h,le]),z=P.kind==="trace"?P.data:null,ae=P.kind==="trace"?P.snrValues:void 0,_=P.kind==="advert"?P.data:null,ce=P.kind==="advert"?P.sourceNode:void 0,fe=P.kind==="grp_txt"?P.wardriveSourceNode??void 0:void 0,ne=P.kind==="anon_req"?P.data:null,Le=G=>!G||G===0?"Unknown":new Date(G*1e3).toLocaleString(),be=(h.payload_type??h.type)===re.ADVERT&&(ce!==void 0||O),Re=fe!==void 0,Ne=ce??fe,qe=Be[K]??"zinc",Ee=ue[qe]||ue.zinc;return e.jsxs(Ot,{open:!0,onClose:s,size:"5xl",motionPlus:!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[K]??"zinc",className:"!text-[9px] !px-1.5 !py-0",children:K}),e.jsx(B,{color:He[F]??"zinc",className:"!text-[9px] !px-1.5 !py-0",children:F}),e.jsxs(B,{color:"zinc",className:"!text-[9px] !px-1.5 !py-0",children:[Y,"B"]})]}),e.jsx("button",{onClick:s,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"})]}),f&&e.jsx("div",{className:"px-3 pb-2",children:e.jsx(Pt,{packets:t,selectedIndex:u,onSelect:C,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[K]??"zinc",children:K}),e.jsx(B,{color:He[F]??"zinc",children:F}),e.jsxs(B,{color:"zinc",children:[Y,"B"]}),f&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-4 bg-subtle-fill-strong"}),e.jsx(Pt,{packets:t,selectedIndex:u,onSelect:C})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(On,{hasDuplicates:f,hasPrev:i,hasNext:l,canPrevDupe:N,canNextDupe:j}),e.jsx("button",{onClick:s,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:Ee,opacity:.6}}),e.jsxs($t,{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:"p-2 space-y-2",children:[(h.rssi!=null||h.snr!=null)&&e.jsxs("div",{className:"relative flex items-center justify-between px-2 py-1.5 radius-inner bg-subtle-fill",children:[e.jsx(Ke,{mode:"popLayout",initial:!1,children:e.jsxs(oe.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(Oe,{rssi:h.rssi,snr:h.snr,compact:!0,showValues:!0,validated:$e(h)}),e.jsx("span",{className:"text-[11px] text-fg-muted",children:pt(h.rssi)})]},u)}),$.length>0&&e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[$.length," hop",$.length!==1?"s":""]})]}),(O&&$.length>0||be||Re)&&e.jsx("div",{className:"overflow-hidden radius-inset",children:e.jsx("div",{className:"aspect-[4/3] w-full",children:e.jsx(We,{path:$,neighbors:M,localNode:J,localHash:k==null?void 0:k.local_hash,srcHash:h.src_hash,dstHash:h.dst_hash,neighborAffinity:H,hubNodes:[...b],traceSnr:ae,advertiserSource:Ne})})}),z&&z.pathHashes.length>0&&e.jsxs("div",{className:"radius-inset bg-black overflow-hidden",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:z.isComplete?"green":"amber",compact:!0,children:z.isComplete?"Complete":"In Progress"})})]})}),e.jsx(Se,{packet:h,neighbors:M,localHash:k==null?void 0:k.local_hash,neighborAffinity:H,ghostPrefixes:W,direction:"flowchart",compact:!0,overridePath:z.pathHashes,traceSnr:z.snrValues})]}),O&&!z&&e.jsxs("div",{className:"radius-inset bg-black overflow-hidden",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:[$.length," hop",$.length!==1?"s":""]})]}),e.jsx(Se,{packet:h,neighbors:M,localHash:k==null?void 0:k.local_hash,neighborAffinity:H,ghostPrefixes:W,direction:"flowchart",compact:!0,traceSnr:ae})]}),d&&(d.name||d.hash)&&!_&&!ne&&e.jsxs("div",{className:"radius-inset bg-subtle-fill 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:"type-micro text-fg-muted",children:"Source"}),e.jsx(B,{color:d.isRepeater?"blue":d.isCompanion?"violet":d.type==="room_server"?"lime":"zinc",compact:!0,children:d.type==="room_server"?"room server":d.type})]}),e.jsxs("div",{className:"p-3 space-y-1.5",children:[d.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:d.name}),!d.confident&&e.jsx("span",{className:"text-[9px] text-fg-muted/60 italic",children:"ambiguous"})]}),d.hash&&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-data-xs text-fg-muted truncate font-mono",children:d.hash.length>16?`${d.hash.slice(0,16)}…${d.hash.slice(-8)}`:d.hash.startsWith("0x")?d.hash.slice(2,10)+"…":d.hash.slice(0,8)+"…"})]})]})]}),ne&&e.jsxs("div",{className:"radius-inset bg-subtle-fill 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:"type-micro text-fg-muted",children:"Sender Identity"}),e.jsx(B,{color:d!=null&&d.isRepeater?"blue":d!=null&&d.isCompanion?"violet":(d==null?void 0:d.type)==="room_server"?"lime":"amber",compact:!0,children:d!=null&&d.type&&d.type!=="unknown"?d.type==="room_server"?"room server":d.type:"companion"})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[(d==null?void 0:d.name)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:d.name}),!d.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(de,{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:ne.destHash})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(we,{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:ne.senderPublicKey})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:[ne.ciphertextLength,"B encrypted payload"]})]})]})]}),_&&e.jsxs("div",{className:"radius-inset bg-subtle-fill 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:"type-micro text-fg-muted",children:"Advertiser Info"}),e.jsx(B,{color:"lime",compact:!0,children:_.nodeType})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[_.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:_.name})]}),_.latitude&&_.longitude&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ue,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"type-data-xs text-fg-secondary",children:[_.latitude.toFixed(5),", ",_.longitude.toFixed(5)]})]}),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.jsxs("span",{className:"type-data-xs text-fg-muted truncate",children:[_.publicKey.slice(0,16),"...",_.publicKey.slice(-8)]})]}),_.timestamp>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-xs text-fg-muted",children:Le(_.timestamp)})]}),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:_.flagsDescription||`Flags: 0x${_.flags.toString(16).padStart(2,"0")}`})]})]})]}),se?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…"})}):te?e.jsx("div",{className:"pt-1",children:e.jsx(St,{packet:h,decodedGrpTxt:le})}):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 p-4 border-r border-edge-subtle",children:se?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…"})}):te?e.jsx(St,{packet:h,decodedGrpTxt:le}):null}),e.jsxs("div",{className:"grid overflow-hidden",style:{gridTemplateRows:"minmax(280px, 1fr) auto"},children:[e.jsx("div",{className:"overflow-hidden p-2",children:O&&$.length>0||be||Re?e.jsx("div",{className:"h-full w-full",children:e.jsx(We,{path:$,neighbors:M,localNode:J,localHash:k==null?void 0:k.local_hash,srcHash:h.src_hash,dstHash:h.dst_hash,neighborAffinity:H,hubNodes:[...b],traceSnr:ae,advertiserSource:Ne})}):e.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center text-center px-4",children:[e.jsx(de,{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:[!z&&$.length<=1&&(h.rssi!=null||h.snr!=null)&&e.jsx("div",{className:"surface-base radius-inset p-4",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(Ke,{mode:"popLayout",initial:!1,children:e.jsxs(oe.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(Oe,{rssi:h.rssi,snr:h.snr,validated:$e(h)}),e.jsx("span",{className:"font-medium text-fg-primary",children:pt(h.rssi)})]},u)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-fg-muted mb-1",children:"RF"}),e.jsx(Ke,{mode:"popLayout",initial:!1,children:e.jsxs(oe.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:[(ze=Mt(h,"rssi"))==null?void 0:ze.text,(()=>{const G=Mt(h,"snr");return G?` · ${G.text}`:null})()]},u)})]})]})}),d&&(d.name||d.hash)&&!_&&!ne&&e.jsxs("div",{className:"radius-inset bg-subtle-fill overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-edge-subtle",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Source"}),e.jsx(B,{color:d.isRepeater?"blue":d.isCompanion?"violet":d.type==="room_server"?"lime":"zinc",compact:!0,children:d.type==="room_server"?"room server":d.type})]}),e.jsxs("div",{className:"p-4 space-y-2",children:[d.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:d.name}),!d.confident&&e.jsx("span",{className:"text-[10px] text-fg-muted/60 italic",children:"ambiguous"})]}),d.hash&&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:"text-[11px] font-mono text-fg-muted truncate",children:d.hash.length>16?`${d.hash.slice(0,16)}…${d.hash.slice(-8)}`:d.hash.startsWith("0x")?d.hash.slice(2,10)+"…":d.hash.slice(0,8)+"…"})]})]})]}),ne&&e.jsxs("div",{className:"radius-inset bg-subtle-fill overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-edge-subtle",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Sender Identity"}),e.jsx(B,{color:d!=null&&d.isRepeater?"blue":d!=null&&d.isCompanion?"violet":(d==null?void 0:d.type)==="room_server"?"lime":"amber",compact:!0,children:d!=null&&d.type&&d.type!=="unknown"?d.type==="room_server"?"room server":d.type:"companion"})]}),e.jsxs("div",{className:"p-4 space-y-2.5",children:[(d==null?void 0:d.name)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:d.name}),!d.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(de,{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:ne.destHash})]})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(we,{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:ne.senderPublicKey})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-xs text-fg-muted",children:[ne.ciphertextLength,"B encrypted payload"]})]})]})]}),_&&e.jsxs("div",{className:"radius-inset bg-subtle-fill overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-edge-subtle",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Advertiser"}),e.jsx(B,{color:"lime",compact:!0,children:_.nodeType})]}),e.jsxs("div",{className:"p-4 space-y-2.5",children:[_.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:_.name})]}),_.latitude&&_.longitude&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ue,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"type-data-xs text-fg-secondary",children:[_.latitude.toFixed(5),", ",_.longitude.toFixed(5)]})]}),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.jsxs("span",{className:"text-[11px] font-mono text-fg-muted truncate",children:[_.publicKey.slice(0,16),"...",_.publicKey.slice(-8)]})]}),_.timestamp>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-xs text-fg-muted",children:Le(_.timestamp)})]}),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-[11px] text-fg-muted",children:_.flagsDescription||`Flags: 0x${_.flags.toString(16).padStart(2,"0")}`})]})]})]}),z&&z.pathHashes.length>0&&e.jsxs("div",{className:"radius-inset bg-black overflow-hidden",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:z.isComplete?"green":"amber",compact:!0,children:z.isComplete?"Complete":"In Progress"}),e.jsxs(B,{color:"teal",compact:!0,children:[z.pathHashes.length,"h"]})]})]}),e.jsx(Se,{packet:h,neighbors:M,localHash:k==null?void 0:k.local_hash,neighborAffinity:H,ghostPrefixes:W,direction:"flowchart",compact:!0,overridePath:z.pathHashes,traceSnr:z.snrValues})]}),O&&!z&&e.jsxs("div",{className:"radius-inset bg-black overflow-hidden",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:[$.length,"h"]})]}),e.jsx(Se,{packet:h,neighbors:M,localHash:k==null?void 0:k.local_hash,neighborAffinity:H,ghostPrefixes:W,direction:"flowchart",compact:!0,traceSnr:ae})]})]})]})]})]})]})}const Un=p.memo($n);function Bt({label:t,numericValue:n,unit:s,icon:a,subtext:r,showSign:i=!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:t})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(tt,{value:n,format:{minimumFractionDigits:1,maximumFractionDigits:1,signDisplay:i?"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(a,{className:"w-[14px] h-[14px] text-fg-muted"}),s&&e.jsx("span",{className:"text-xs font-medium leading-tight text-fg-muted",children:s})]})]}),r&&e.jsx("p",{className:"mt-1.5 sm:mt-2 type-data-xs sm:text-[11px] text-fg-muted/80 truncate",children:r})]})}function Vn({snr:t}){const n=t>=5?"bg-sys-teal":t>=0?"bg-sys-green":t>=-5?"bg-sys-amber":t>=-10?"bg-sys-orange":"bg-sys-red";return e.jsx("span",{className:R("w-1.5 h-1.5 rounded-full flex-shrink-0",n),title:`SNR: ${t.toFixed(1)} dB`})}function Lt({fromPrefix:t,toPrefix:n,fromName:s,toName:a,snr:r,maxSnr:i,isWeakest:l,isStrongest:c,index:o=0}){const x=Math.max(i+5,15),g=Math.max(0,Math.min(100,(r- -20)/(x- -20)*100)),f="bg-[#0074BE]",y=r>=5?"bg-sys-teal":r>=0?"bg-sys-green":r>=-5?"bg-sys-amber":r>=-10?"bg-sys-orange":"bg-sys-red",m=.3+o*.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:R("absolute left-0 top-1/2 -translate-y-1/2 h-4 w-0.5 rounded-full",y)}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5",children:e.jsx(Vn,{snr:r})}),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:s||t}),e.jsx(pe,{className:"w-3 h-3 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-[13px] font-semibold text-fg-primary truncate",children:a||n})]}),e.jsxs("div",{className:"flex items-center gap-1.5 ml-2 flex-shrink-0",children:[l&&e.jsx(B,{color:"red",compact:!0,children:"Low"}),c&&!l&&e.jsxs(B,{color:"amber",compact:!0,children:[e.jsx(wt,{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:[r>=0?"+":"−",Math.abs(r).toFixed(1)]})]})]}),e.jsx("div",{className:"h-1.5 bg-subtle-fill-strong rounded-full overflow-hidden",children:e.jsx(oe.div,{className:R("h-full rounded-full",f),initial:{width:0},animate:{width:`${g}%`},transition:{duration:1.5,delay:m,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:t}),s&&e.jsx("span",{className:"text-xs text-fg-secondary truncate max-w-[100px]",children:s})]}),e.jsx(pe,{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:n}),a&&e.jsx("span",{className:"text-xs text-fg-secondary truncate max-w-[100px]",children:a})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[l&&e.jsx(B,{color:"red",compact:!0,children:"Bottleneck"}),c&&!l&&e.jsxs(B,{color:"amber",compact:!0,children:[e.jsx(wt,{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:[r>=0?"+":"−",Math.abs(r).toFixed(1)]})]})]}),e.jsx("div",{className:"h-1.5 bg-elevated rounded-full overflow-hidden",children:e.jsx(oe.div,{className:R("h-full rounded-full",f),initial:{width:0},animate:{width:`${g}%`},transition:{duration:1.5,delay:m,ease:[.25,.1,.25,1]}})})]})]})}function ye(t,n){if(t==="You")return"You";const s=t.toUpperCase();for(const[a,r]of Object.entries(n))if((a.startsWith("0x")?a.slice(2,4):a.slice(0,2)).toUpperCase()===s)return r.name||r.node_name||void 0}function Wn({report:t,onClose:n}){var u,x;const s=Ht(),a=(s==null?void 0:s.neighbors)??{},r=(u=s==null?void 0:s.config)!=null&&u.repeater?{latitude:s.config.repeater.latitude,longitude:s.config.repeater.longitude,name:s.config.node_name||"Local Node"}:void 0,i=(x=t.bestObservation)==null?void 0:x.decoded.snrValues,l=t.linkQuality?t.linkQuality.avgSnr>=5?"excellent":t.linkQuality.avgSnr>=0?"good":t.linkQuality.avgSnr>=-5?"fair":"poor":"unknown",o={excellent:"var(--signal-excellent)",good:"var(--signal-good)",fair:"var(--signal-fair)",poor:"var(--signal-poor)",unknown:"var(--fg-muted)"}[l];return e.jsxs(Ot,{open:!0,onClose:n,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:n,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:o,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:l==="excellent"||l==="good"?"green":l==="fair"?"amber":"red",children:[e.jsx(vt,{className:"w-3 h-3 mr-1"}),l==="excellent"?"Excellent":l==="good"?"Good":l==="fair"?"Fair":"Poor"]})]}),e.jsx("p",{className:"mt-1 text-xs sm:text-sm font-mono text-fg-muted tabular-nums",children:t.traceTag})]}),e.jsx("button",{onClick:n,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:t.targetHopCount}),e.jsxs("span",{className:"ml-1",children:["hop",t.targetHopCount!==1?"s":""]})]}),e.jsxs(B,{color:"zinc",children:[e.jsx("span",{className:"font-mono tabular-nums",children:t.observationCount}),e.jsx("span",{className:"ml-1",children:"obs"})]}),t.linkQuality&&e.jsxs(B,{color:"indigo",children:[e.jsx("span",{className:"font-mono tabular-nums",children:t.linkQuality.avgSnr.toFixed(1)}),e.jsx("span",{className:"ml-1",children:"dB avg"})]}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:Fs(t.duration)}),t.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:t.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:t.linkQuality.maxSnr.toFixed(1)})]})]})]})]}),e.jsxs($t,{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:[t.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(tt,{value:Math.abs(t.linkQuality.minSnr),format:{maximumFractionDigits:0,signDisplay:"never"},prefix:t.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(et,{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(tt,{value:t.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(ft,{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:l==="excellent"||l==="good"?"green":l==="fair"?"amber":"red",compact:!0,children:[e.jsx(vt,{className:"w-2.5 h-2.5 mr-0.5"}),l==="excellent"?"Excellent":l==="good"?"Good":l==="fair"?"Fair":"Poor"]}),e.jsxs(B,{color:"teal",compact:!0,children:[t.targetHopCount," hops"]}),e.jsxs(B,{color:"zinc",compact:!0,children:[t.observationCount," obs"]}),e.jsx("span",{className:"type-data-xs text-fg-muted ml-auto",children:t.traceTag.slice(0,8)})]}),t.targetPath.length>0&&e.jsx("div",{className:"overflow-hidden radius-inset",children:e.jsx("div",{className:"aspect-[4/3] w-full",children:e.jsx(We,{path:t.targetPath,neighbors:a,localNode:r,localHash:s==null?void 0:s.local_hash,srcHash:t.srcHash,dstHash:t.dstHash,traceSnr:i})})}),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"}),t.linkQuality&&e.jsxs("span",{className:"type-data-xs text-fg-muted",children:["SNR ",t.linkQuality.minSnr.toFixed(1)," → ",t.linkQuality.maxSnr.toFixed(1)," dB"]})]}),t.bestObservation?e.jsx(Se,{packet:t.bestObservation.packet,neighbors:a,localHash:s==null?void 0:s.local_hash,direction:"flowchart",compact:!0,overridePath:t.targetPath,traceSnr:t.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 · ",t.hopStats.length," hops"]}),e.jsx("div",{className:"space-y-1.5",children:t.hopStats.length>0?t.hopStats.map((g,f)=>{var T,h,N;const y=f{const g=t.targetPath[t.linkQuality.weakestLinkPosition],f=t.targetPath[t.linkQuality.weakestLinkPosition+1]||"You",y=ye(g,a),m=ye(f,a),v=t.targetPath[t.linkQuality.strongestLinkPosition],T=t.targetPath[t.linkQuality.strongestLinkPosition+1]||"You",h=ye(v,a),N=ye(T,a);return e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Bt,{label:"Weakest Link",numericValue:t.linkQuality.minSnr,unit:"dB",icon:et,subtext:`${y||g} → ${m||f}`}),e.jsx(Bt,{label:"Best Link",numericValue:t.linkQuality.maxSnr,showSign:!0,unit:"dB",icon:ft,subtext:`${h||v} → ${N||T}`})]})})(),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:t.hopStats.length>0?t.hopStats.map((g,f)=>{var T,h,N;const y=f0&&e.jsx("div",{className:"overflow-hidden",children:e.jsx("div",{className:"aspect-square w-full",children:e.jsx(We,{path:t.targetPath,neighbors:a,localNode:r,localHash:s==null?void 0:s.local_hash,srcHash:t.srcHash,dstHash:t.dstHash,traceSnr:i})})}),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:t.isComplete?"green":"amber",compact:!0,children:t.isComplete?"Complete":`${t.maxHopsObserved}/${t.targetHopCount}`}),e.jsxs(B,{color:"teal",compact:!0,children:[t.targetHopCount," hop",t.targetHopCount!==1?"s":""]})]})]}),t.linkQuality&&t.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:t.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:[t.linkQuality.minSnr.toFixed(1),"–",t.linkQuality.maxSnr.toFixed(1)]}),e.jsx("span",{className:"opacity-60",children:" dB"})]})]}),t.bestObservation?e.jsx(Se,{packet:t.bestObservation.packet,neighbors:a,localHash:s==null?void 0:s.local_hash,direction:"flowchart",compact:!0,overridePath:t.targetPath,traceSnr:t.bestObservation.decoded.snrValues}):e.jsx("div",{className:"p-8 text-center text-fg-muted text-xs",children:"No path data available"})]})]})]})]})]})}const Gn=p.memo(Wn),ns=[{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:Us},{target:"PacketList",fn:"src_hash",minStage:1,when:Vs},{target:"PacketList",fn:"text",minStage:1,when:Ws},{target:"PacketList",fn:"ack",minStage:1,when:Gs},{target:"PacketList",fn:"decrypt",minStage:2,when:Qs},{target:"PacketList",fn:"duplicates",minStage:1}];$s(ns);const Qn=48,qn=72,Kn=100,Yn=5,Xn=600,rs="(min-width: 640px)";let he=null;function Zn(t){return typeof window>"u"?()=>{}:(he||(he=window.matchMedia(rs)),he.addEventListener("change",t),()=>he==null?void 0:he.removeEventListener("change",t))}function Jn(){return typeof window>"u"?!0:(he||(he=window.matchMedia(rs)),he.matches)}function er(){return p.useSyncExternalStore(Zn,Jn,()=>!0)}function tr(t,n,s){const[a,r]=p.useState(1),i=s?Math.ceil(t/n):1;p.useEffect(()=>{a>i&&i>0&&queueMicrotask(()=>r(1))},[i,a]);const l=p.useCallback(o=>r(Math.max(1,Math.min(o,i))),[i]),c=p.useMemo(()=>$a(a,i),[a,i]);return{currentPage:a,totalPages:i,goToPage:l,pageRange:c}}function sr(t,n){const[s,a]=p.useState(null),r=p.useRef(0);return p.useEffect(()=>{var x,g;if(!n||!t.length)return;const i=((x=t[0])==null?void 0:x.timestamp)??0,l=i>r.current&&r.current>0;if(r.current=i,!l)return;const c=(g=t[0])==null?void 0:g.packet_hash;if(!c)return;const o=requestAnimationFrame(()=>a(c)),u=setTimeout(()=>a(null),600);return()=>{cancelAnimationFrame(o),clearTimeout(u)}},[t,n]),s}function ar(t){if(!t||t.length<6)return null;const n=t,s=parseInt(n.slice(0,2),16);if(isNaN(s))return null;const a=s&3;let r=2;if((a===0||a===3)&&(r=10),r+2>n.length)return null;const i=parseInt(n.slice(r,r+2),16);if(isNaN(i)||(r+=2+i*2,r>=n.length))return null;const l=n.slice(r);return l.length>=38?l.slice(0,38):l}function nr(t){if(t.length<=1)return t;const n=new Map,s=new Map,a=new Map;for(let l=0;l0?{packet:t[l].packet,dupeCount:t[l].dupeCount+c}:t[l])}return i}function rr(t){const n=new Map;for(const s of t)if((s.payload_type??s.type)===lt.TRACE&&s.packet_hash){const r=s._traceTag??(s.payload?Ut(s.payload):null);r&&n.set(s.packet_hash,r)}return n}function ir(t){const n=new Map;if(t.length===0)return n;for(let s=0;sw.setModalMapOpen);p.useEffect(()=>(W(!!N),()=>W(!1)),[N,W]),p.useLayoutEffect(()=>{A({traceTag:null,dupeGroup:null})},[t]);const K=n??t,F=p.useMemo(()=>i&&i>0&&!y?t.slice(0,i):t,[t,i,y]),Y=p.useMemo(()=>{if(!y)return null;const w=Ua(F),S=nr(w);return i&&i>0?S.slice(0,i):S},[F,y,i]),D=Y?Y.length:F.length,{currentPage:E,totalPages:O,goToPage:$,pageRange:J}=tr(D,l,c),M=p.useMemo(()=>{if(y||!c)return F;const w=(E-1)*l;return F.slice(w,w+l)},[F,c,E,l,y]),H=p.useMemo(()=>{if(!Y)return null;if(!c)return Y;const w=(E-1)*l;return Y.slice(w,w+l)},[Y,c,E,l]),te=p.useMemo(()=>rr(M),[M]),se=p.useMemo(()=>ir(M),[M]),d=sr(t,u),Z=er(),q=p.useMemo(()=>y&&H?H:M,[y,H,M]),le=h&&q.length>Kn,P=Z?Qn:qn,z=ga({count:le?q.length:0,getScrollElement:()=>U.current,estimateSize:()=>P,overscan:Yn}),ae=p.useCallback((w,S)=>{var ve,Fe;const L=w.packet_hash;if(!L)return[w];let I=S;for(;I>0&&((ve=M[I-1])==null?void 0:ve.packet_hash)===L;)I--;let Q=S;for(;Q{var I,Q;const S=(I=M[w])==null?void 0:I.packet_hash;if(!S)return w;let L=w;for(;L>0&&((Q=M[L-1])==null?void 0:Q.packet_hash)===S;)L--;return L},[M]),ce=p.useCallback(w=>{var I,Q;const S=(I=M[w])==null?void 0:I.packet_hash;if(!S)return w;let L=w;for(;L{if(o){o(w);return}if(S!==void 0){const L=ae(w,S),I=L.indexOf(w);j({packets:L,initialIndex:I>=0?I:0,rowIndex:S})}else j({packets:[w],initialIndex:0,rowIndex:0})},[o,ae]),ne=p.useCallback(()=>{if(!N)return;const S=_(N.rowIndex)-1;if(S<0)return;const L=M[S];if(!L)return;const I=ae(L,S);j({packets:I,initialIndex:0,rowIndex:S})},[N,M,_,ae]),Le=p.useCallback(()=>{if(!N)return;const S=ce(N.rowIndex)+1;if(S>=M.length)return;const L=M[S];if(!L)return;const I=ae(L,S);j({packets:I,initialIndex:0,rowIndex:S})},[N,M,ce,ae]),dt=p.useMemo(()=>N?_(N.rowIndex)>0:!1,[N,_]),xt=p.useMemo(()=>N?ce(N.rowIndex)A(S=>({...S,traceTag:w})),[]),Qe=p.useCallback(w=>A(S=>({...S,dupeGroup:w})),[]),Re=p.useCallback(()=>{A({traceTag:null,dupeGroup:null})},[]),Ne=p.useCallback(w=>{const S=K.filter(Q=>(Q.payload_type??Q.type)===lt.TRACE&&Q.payload&&Ut(Q.payload)===w);if(S.length===0)return;const I=Ds(S).get(w);I!=null&&I.length&&k(Hs(w,I))},[K]),qe=p.useCallback(w=>{const S=K.find(L=>L.packet_hash===w);S&&(k(null),fe(S))},[K,fe]),Ee=p.useCallback((w,S,L)=>{const I=Z?Xa:Za;if(L){const{packet:ge,dupeCount:ls}=w,ht=ge.packet_hash?te.get(ge.packet_hash):void 0,cs=b.traceTag!==null&&ht===b.traceTag;return e.jsx(I,{packet:ge,onClick:os=>fe(os,S),localHash:s,neighbors:a,resolveSource:T,isFlashing:u&&d===ge.packet_hash,traceTag:ht,isTraceHighlighted:cs,onTraceHover:be,onViewTraceReport:Ne,dupeCount:ls,getDecodedContent:m,onChannelClick:v},`${ge.packet_hash}_${ge.timestamp}_${S}`)}const Q=w,ve=Q.packet_hash?te.get(Q.packet_hash):void 0,Fe=b.traceTag!==null&&ve===b.traceTag,mt=se.get(S),is=mt!==void 0&&b.dupeGroup!==null&&Q.packet_hash===b.dupeGroup;return e.jsx(I,{packet:Q,onClick:ge=>fe(ge,S),localHash:s,neighbors:a,resolveSource:T,isFlashing:u&&d===Q.packet_hash,traceTag:ve,isTraceHighlighted:Fe,onTraceHover:be,onViewTraceReport:Ne,dupeGroupPosition:mt,isDupeGroupHovered:is,onDupeGroupHover:Qe,getDecodedContent:m,onChannelClick:v},`${Q.packet_hash}_${Q.timestamp}_${S}`)},[Z,te,b.traceTag,b.dupeGroup,fe,s,a,T,u,d,be,Ne,se,Qe,m,v]),ze=()=>{if(r&&t.length===0)return e.jsx(Et,{});if(M.length===0)return e.jsx(Rt,{message:x});const w=y&&H!==null;return(w?H:M).map((L,I)=>Ee(L,I,w))},G=()=>{if(r&&t.length===0)return e.jsx(Et,{});if(q.length===0)return e.jsx(Rt,{message:x});const w=y&&H!==null,S=z.getVirtualItems();return e.jsx("div",{style:{height:`${z.getTotalSize()}px`,width:"100%",position:"relative"},children:S.map(L=>{const I=q[L.index];return e.jsx("div",{"data-index":L.index,ref:z.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${L.start}px)`},children:Ee(I,L.index,w)},L.key)})})};return e.jsxs("div",{className:R("flex flex-col",g),onMouseLeave:Re,children:[le?e.jsx("div",{ref:U,className:"divide-y divide-edge-subtle overflow-auto",style:{maxHeight:Xn},children:G()}):e.jsx("div",{className:"divide-y divide-edge-subtle py-1",children:ze()}),c&&O>1&&e.jsx("nav",{className:"border-t border-edge-subtle px-4 py-3",children:e.jsxs(Fa,{className:"justify-center",children:[e.jsx(Ia,{onClick:()=>$(E-1),disabled:E===1}),e.jsx(Da,{children:J.map((w,S)=>w==="gap"?e.jsx(Oa,{},`gap-${S}`):e.jsx(Ha,{page:w,current:w===E,onClick:$},w))}),e.jsx(Aa,{onClick:()=>$(E+1),disabled:E===O})]})}),e.jsx(lr,{showPagination:c,currentPage:E,perPage:l,displayCount:H?H.length:M.length,totalCount:c?D:t.length,action:f}),!o&&N&&e.jsx(Un,{packets:N.packets,initialIndex:N.initialIndex,onClose:()=>j(null),onNavigatePrev:ne,onNavigateNext:Le,hasPrev:dt,hasNext:xt,resolveSource:T,getDecodedContent:m}),C&&e.jsx(Gn,{report:C,onClose:()=>k(null),onViewPacket:qe})]})}export{ts as C,Br as P,vt as S,wt as T,Tr as a,ga as b,Ga as g,Pr as u}; diff --git a/frontend/dist/assets/PacketList-DNy8yTeL.js b/frontend/dist/assets/PacketList-DNy8yTeL.js deleted file mode 100644 index 53e645ad..00000000 --- a/frontend/dist/assets/PacketList-DNy8yTeL.js +++ /dev/null @@ -1,67 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PathMapMapLibre-ANGN4-cP.js","assets/index-C8IY8K2r.js","assets/BasemapLayer-D5WYHXmJ.js","assets/useMapViewStore-ax-BqDpg.js","assets/index-B-prVW1V.js","assets/index-DUfCykEc.css","assets/BasemapLayer-B1CfjdFi.css"])))=>i.map(i=>d[i]); -import{r as m,aD as xs,d as xe,bd as hs,be as Ft,bf as ms,bg as us,j as e,c as z,B as rt,bh as ps,x as it,q as P,bi as It,R as ge,bj as At,bk as Dt,bl as Ht,bm as me,bn as Xe,$ as Qe,bo as fs,bp as gs,bq as ys,m as de,a7 as oe,w as js,br as bs,bs as ie,bt as pt,bu as Ns,bv as vs,bw as ws,bx as ks,by as Cs,bz as Ze,bA as Ss,a3 as _s,E as Ot,bB as Ms,bC as Ts,bD as Ps,bE as Bs,ac as $t,ad as Ut,A as qe,bF as Ls,ae as Rs,bG as Es,bH as lt}from"./index-C8IY8K2r.js";import{p as zs,d as Fs,e as Vt,g as Is,b as As}from"./primitives-Ca8Zb5cD.js";import{u as Ds,r as Hs,a as Os,b as $s,c as Us,d as Vs,i as Ws}from"./consumer-registry-lDKP4bcU.js";import{D as Me,R as Ae,P as Te,g as Gs}from"./badge-colors-BNUqIXCA.js";import{g as Wt,e as Se,a as Gt}from"./chat-utils-D1Q4VWjO.js";import{P as Qt,d as qt,a as Qs,b as qs}from"./payload-decoders-BX6pSxwl.js";import{A as ue,S as De,i as He,C as ye,a as Ks,g as ft}from"./SignalIndicator-Dw_bfp50.js";import{a as Ys,A as Kt}from"./arrow-up-DbeeGdHO.js";import{C as ct}from"./chevron-right-DUgYTR6d.js";import{f as Xs,r as Zs}from"./usePipelineStore-CyFB3GIy.js";import{M as Oe}from"./map-pin-DMVHq6j8.js";import{C as Js}from"./circle-question-mark-C7l07_IA.js";import{T as Je}from"./triangle-alert-8k00uu7o.js";import{D as ee}from"./DataBox-W2v3wy8k.js";import{L as en}from"./layers-Oxzfug7f.js";import{H as Yt}from"./hash-BkZp0AKy.js";import{A as tn}from"./activity-2-g8m4_g.js";import{C as sn}from"./circle-check-BOp4wLxA.js";import{D as nn}from"./database-BEyHF_p_.js";import{H as an,D as et,Z as gt,u as rn}from"./useMapViewStore-ax-BqDpg.js";import{S as Ee}from"./shield-DlHwWwz2.js";import{C as Xt}from"./TimeRangeStepper-BlC9rlkV.js";function ke(t,a,s){let n=s.initialDeps??[],r,i=!0;function l(){var c,o,h;let d;s.key&&((c=s.debug)!=null&&c.call(s))&&(d=Date.now());const g=t();if(!(g.length!==n.length||g.some((x,v)=>n[v]!==x)))return r;n=g;let y;if(s.key&&((o=s.debug)!=null&&o.call(s))&&(y=Date.now()),r=a(...g),s.key&&((h=s.debug)!=null&&h.call(s))){const x=Math.round((Date.now()-d)*100)/100,v=Math.round((Date.now()-y)*100)/100,p=v/16,w=(j,b)=>{for(j=String(j);j.length{n=c},l}function yt(t,a){if(t===void 0)throw new Error("Unexpected undefined");return t}const ln=(t,a)=>Math.abs(t-a)<1.01,cn=(t,a,s)=>{let n;return function(...r){t.clearTimeout(n),n=t.setTimeout(()=>a.apply(this,r),s)}},jt=t=>{const{offsetWidth:a,offsetHeight:s}=t;return{width:a,height:s}},on=t=>t,dn=t=>{const a=Math.max(t.startIndex-t.overscan,0),s=Math.min(t.endIndex+t.overscan,t.count-1),n=[];for(let r=a;r<=s;r++)n.push(r);return n},xn=(t,a)=>{const s=t.scrollElement;if(!s)return;const n=t.targetWindow;if(!n)return;const r=l=>{const{width:c,height:o}=l;a({width:Math.round(c),height:Math.round(o)})};if(r(jt(s)),!n.ResizeObserver)return()=>{};const i=new n.ResizeObserver(l=>{const c=()=>{const o=l[0];if(o!=null&&o.borderBoxSize){const h=o.borderBoxSize[0];if(h){r({width:h.inlineSize,height:h.blockSize});return}}r(jt(s))};t.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()});return i.observe(s,{box:"border-box"}),()=>{i.unobserve(s)}},bt={passive:!0},Nt=typeof window>"u"?!0:"onscrollend"in window,hn=(t,a)=>{const s=t.scrollElement;if(!s)return;const n=t.targetWindow;if(!n)return;let r=0;const i=t.options.useScrollendEvent&&Nt?()=>{}:cn(n,()=>{a(r,!1)},t.options.isScrollingResetDelay),l=d=>()=>{const{horizontal:g,isRtl:u}=t.options;r=g?s.scrollLeft*(u&&-1||1):s.scrollTop,i(),a(r,d)},c=l(!0),o=l(!1);s.addEventListener("scroll",c,bt);const h=t.options.useScrollendEvent&&Nt;return h&&s.addEventListener("scrollend",o,bt),()=>{s.removeEventListener("scroll",c),h&&s.removeEventListener("scrollend",o)}},mn=(t,a,s)=>{if(a!=null&&a.borderBoxSize){const n=a.borderBoxSize[0];if(n)return Math.round(n[s.options.horizontal?"inlineSize":"blockSize"])}return t[s.options.horizontal?"offsetWidth":"offsetHeight"]},un=(t,{adjustments:a=0,behavior:s},n)=>{var r,i;const l=t+a;(i=(r=n.scrollElement)==null?void 0:r.scrollTo)==null||i.call(r,{[n.options.horizontal?"left":"top"]:l,behavior:s})};class pn{constructor(a){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.currentScrollToIndex=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let s=null;const n=()=>s||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:s=new this.targetWindow.ResizeObserver(r=>{r.forEach(i=>{const l=()=>{this._measureElement(i.target,i)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()})}));return{disconnect:()=>{var r;(r=n())==null||r.disconnect(),s=null},observe:r=>{var i;return(i=n())==null?void 0:i.observe(r,{box:"border-box"})},unobserve:r=>{var i;return(i=n())==null?void 0:i.unobserve(r)}}})(),this.range=null,this.setOptions=s=>{Object.entries(s).forEach(([n,r])=>{typeof r>"u"&&delete s[n]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:on,rangeExtractor:dn,onChange:()=>{},measureElement:mn,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...s}},this.notify=s=>{var n,r;(r=(n=this.options).onChange)==null||r.call(n,this,s)},this.maybeNotify=ke(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),s=>{this.notify(s)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(s=>s()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var s;const n=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==n){if(this.cleanup(),!n){this.maybeNotify();return}this.scrollElement=n,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((s=this.scrollElement)==null?void 0:s.window)??null,this.elementsCache.forEach(r=>{this.observer.observe(r)}),this.unsubs.push(this.options.observeElementRect(this,r=>{this.scrollRect=r,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(r,i)=>{this.scrollAdjustments=0,this.scrollDirection=i?this.getScrollOffset()this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(s,n)=>{const r=new Map,i=new Map;for(let l=n-1;l>=0;l--){const c=s[l];if(r.has(c.lane))continue;const o=i.get(c.lane);if(o==null||c.end>o.end?i.set(c.lane,c):c.endl.end===c.end?l.index-c.index:l.end-c.end)[0]:void 0},this.getMeasurementOptions=ke(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(s,n,r,i,l,c)=>(this.prevLanes!==void 0&&this.prevLanes!==c&&(this.lanesChangedFlag=!0),this.prevLanes=c,this.pendingMeasuredCacheIndexes=[],{count:s,paddingStart:n,scrollMargin:r,getItemKey:i,enabled:l,lanes:c}),{key:!1}),this.getMeasurements=ke(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:s,paddingStart:n,scrollMargin:r,getItemKey:i,enabled:l,lanes:c},o)=>{if(!l)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>s)for(const u of this.laneAssignments.keys())u>=s&&this.laneAssignments.delete(u);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(u=>{this.itemSizeCache.set(u.key,u.size)}));const h=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===s&&(this.lanesSettling=!1);const d=this.measurementsCache.slice(0,h),g=new Array(c).fill(void 0);for(let u=0;u1){v=x;const f=g[v],T=f!==void 0?d[f]:void 0;p=T?T.end+this.options.gap:n+r}else{const f=this.options.lanes===1?d[u-1]:this.getFurthestMeasurement(d,u);p=f?f.end+this.options.gap:n+r,v=f?f.lane:u%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(u,v)}const w=o.get(y),j=typeof w=="number"?w:this.options.estimateSize(u),b=p+j;d[u]={index:u,start:p,size:j,end:b,key:y,lane:v},g[v]=u}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=ke(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(s,n,r,i)=>this.range=s.length>0&&n>0?fn({measurements:s,outerSize:n,scrollOffset:r,lanes:i}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=ke(()=>{let s=null,n=null;const r=this.calculateRange();return r&&(s=r.startIndex,n=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,s,n]),[this.options.rangeExtractor,this.options.overscan,this.options.count,s,n]},(s,n,r,i,l)=>i===null||l===null?[]:s({startIndex:i,endIndex:l,overscan:n,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=s=>{const n=this.options.indexAttribute,r=s.getAttribute(n);return r?parseInt(r,10):(console.warn(`Missing attribute name '${n}={index}' on measured element.`),-1)},this._measureElement=(s,n)=>{const r=this.indexFromElement(s),i=this.measurementsCache[r];if(!i)return;const l=i.key,c=this.elementsCache.get(l);c!==s&&(c&&this.observer.unobserve(c),this.observer.observe(s),this.elementsCache.set(l,s)),s.isConnected&&this.resizeItem(r,this.options.measureElement(s,n,this))},this.resizeItem=(s,n)=>{const r=this.measurementsCache[s];if(!r)return;const i=this.itemSizeCache.get(r.key)??r.size,l=n-i;l!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(r,l,this):r.start{if(!s){this.elementsCache.forEach((n,r)=>{n.isConnected||(this.observer.unobserve(n),this.elementsCache.delete(r))});return}this._measureElement(s,void 0)},this.getVirtualItems=ke(()=>[this.getVirtualIndexes(),this.getMeasurements()],(s,n)=>{const r=[];for(let i=0,l=s.length;ithis.options.debug}),this.getVirtualItemForOffset=s=>{const n=this.getMeasurements();if(n.length!==0)return yt(n[Zt(0,n.length-1,r=>yt(n[r]).start,s)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const s=this.scrollElement.document.documentElement;return this.options.horizontal?s.scrollWidth-this.scrollElement.innerWidth:s.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(s,n,r=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),l=this.getScrollOffset();n==="auto"&&(n=s>=l+i?"end":"start"),n==="center"?s+=(r-i)/2:n==="end"&&(s-=i);const c=this.getMaxScrollOffset();return Math.max(Math.min(c,s),0)},this.getOffsetForIndex=(s,n="auto")=>{s=Math.max(0,Math.min(s,this.options.count-1));const r=this.measurementsCache[s];if(!r)return;const i=this.getSize(),l=this.getScrollOffset();if(n==="auto")if(r.end>=l+i-this.options.scrollPaddingEnd)n="end";else if(r.start<=l+this.options.scrollPaddingStart)n="start";else return[l,n];if(n==="end"&&s===this.options.count-1)return[this.getMaxScrollOffset(),n];const c=n==="end"?r.end+this.options.scrollPaddingEnd:r.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(c,n,r.size),n]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(s,{align:n="start",behavior:r}={})=>{r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(s,n),{adjustments:void 0,behavior:r})},this.scrollToIndex=(s,{align:n="auto",behavior:r}={})=>{r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),s=Math.max(0,Math.min(s,this.options.count-1)),this.currentScrollToIndex=s;let i=0;const l=10,c=h=>{if(!this.targetWindow)return;const d=this.getOffsetForIndex(s,h);if(!d){console.warn("Failed to get offset for index:",s);return}const[g,u]=d;this._scrollToOffset(g,{adjustments:void 0,behavior:r}),this.targetWindow.requestAnimationFrame(()=>{const y=()=>{if(this.currentScrollToIndex!==s)return;const x=this.getScrollOffset(),v=this.getOffsetForIndex(s,u);if(!v){console.warn("Failed to get offset for index:",s);return}ln(v[0],x)||o(u)};this.isDynamicMode()?this.targetWindow.requestAnimationFrame(y):y()})},o=h=>{this.targetWindow&&this.currentScrollToIndex===s&&(i++,ic(h)):console.warn(`Failed to scroll to index ${s} after ${l} attempts.`))};c(n)},this.scrollBy=(s,{behavior:n}={})=>{n==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+s,{adjustments:void 0,behavior:n})},this.getTotalSize=()=>{var s;const n=this.getMeasurements();let r;if(n.length===0)r=this.options.paddingStart;else if(this.options.lanes===1)r=((s=n[n.length-1])==null?void 0:s.end)??0;else{const i=Array(this.options.lanes).fill(null);let l=n.length-1;for(;l>=0&&i.some(c=>c===null);){const c=n[l];i[c.lane]===null&&(i[c.lane]=c.end),l--}r=Math.max(...i.filter(c=>c!==null))}return Math.max(r-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(s,{adjustments:n,behavior:r})=>{this.options.scrollToFn(s,{behavior:r,adjustments:n},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(a)}}const Zt=(t,a,s,n)=>{for(;t<=a;){const r=(t+a)/2|0,i=s(r);if(in)a=r-1;else return r}return t>0?t-1:0};function fn({measurements:t,outerSize:a,scrollOffset:s,lanes:n}){const r=t.length-1,i=o=>t[o].start;if(t.length<=n)return{startIndex:0,endIndex:r};let l=Zt(0,r,i,s),c=l;if(n===1)for(;c1){const o=Array(n).fill(0);for(;cd=0&&h.some(d=>d>=s);){const d=t[l];h[d.lane]=d.start,l--}l=Math.max(0,l-l%n),c=Math.min(r,c+(n-1-c%n))}return{startIndex:l,endIndex:c}}const vt=typeof document<"u"?m.useLayoutEffect:m.useEffect;function gn({useFlushSync:t=!0,...a}){const s=m.useReducer(()=>({}),{})[1],n={...a,onChange:(i,l)=>{var c;t&&l?xs.flushSync(s):s(),(c=a.onChange)==null||c.call(a,i,l)}},[r]=m.useState(()=>new pn(n));return r.setOptions(n),vt(()=>r._didMount(),[]),vt(()=>r._willUpdate()),r}function yn(t){return gn({observeElementRect:xn,observeElementOffset:hn,scrollToFn:un,...t})}/** - * @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 jn=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],bn=xe("chevron-up",jn);/** - * @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 Nn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Br=xe("circle-x",Nn);/** - * @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 vn=[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]],wn=xe("corner-down-right",vn);/** - * @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 kn=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],ot=xe("lock",kn);/** - * @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 Cn=[["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"}]],Jt=xe("message-circle-question-mark",Cn);/** - * @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 Sn=[["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}],["path",{d:"m9 17-5-5 5-5",key:"nvlc11"}]],_n=xe("reply",Sn);/** - * @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 Mn=[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15",key:"1d8sl"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]],Tn=xe("route",Mn);/** - * @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 Pn=[["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"}]],wt=xe("stethoscope",Pn);/** - * @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 Bn=[["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"}]],kt=xe("trophy",Bn);/** - * @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 Ln=[["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"}]],ze=xe("user",Ln);function Rn(t){t.values.forEach(a=>a.stop())}function tt(t,a){[...a].reverse().forEach(n=>{const r=t.getVariant(n);r&&Ft(t,r),t.variantChildren&&t.variantChildren.forEach(i=>{tt(i,a)})})}function En(t,a){if(Array.isArray(a))return tt(t,a);if(typeof a=="string")return tt(t,[a]);Ft(t,a)}function zn(){const t=new Set,a={subscribe(s){return t.add(s),()=>void t.delete(s)},start(s,n){const r=[];return t.forEach(i=>{r.push(hs(i,s,{transitionOverride:n}))}),Promise.all(r)},set(s){return t.forEach(n=>{En(n,s)})},stop(){t.forEach(s=>{Rn(s)})},mount(){return()=>{a.stop()}}};return a}function Fn(){const t=ms(zn);return us(t.mount,[]),t}function In({"aria-label":t="Page navigation",className:a,...s}){return e.jsx("nav",{"aria-label":t,...s,className:z("flex gap-x-2",a)})}function An({onClick:t,disabled:a=!1,className:s,children:n="Previous"}){return e.jsx("span",{className:z("grow basis-0",s),children:e.jsxs(rt,{plain:!0,onClick:t,disabled:a,"aria-label":"Previous page",className:z("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 Dn({onClick:t,disabled:a=!1,className:s,children:n="Next"}){return e.jsx("span",{className:z("flex grow basis-0 justify-end",s),children:e.jsxs(rt,{plain:!0,onClick:t,disabled:a,"aria-label":"Next page",className:z("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 Hn({className:t,...a}){return e.jsx("span",{...a,className:z("hidden items-baseline gap-x-2 sm:flex",t)})}function On({page:t,current:a=!1,onClick:s,className:n,children:r}){return e.jsx(rt,{plain:!a,outline:a,onClick:()=>s==null?void 0:s(t),"aria-label":`Page ${t}`,"aria-current":a?"page":void 0,className:z("min-w-[2.25rem] before:absolute before:-inset-px before:rounded-lg",a&&"before:bg-subtle-fill",n),children:r??t})}function $n({className:t,...a}){return e.jsx("span",{"aria-hidden":"true",...a,className:z("w-[2.25rem] select-none text-center text-sm text-fg-muted",t),children:"…"})}function Un(t,a,s=1){if(a<=7)return Array.from({length:a},(o,h)=>h+1);const n=Math.max(t-s,1),r=Math.min(t+s,a),i=n>2,l=rg+1),"gap",a]}if(i&&!l){const o=3+2*s;return[1,"gap",...Array.from({length:o},(d,g)=>a-o+g+1)]}return[1,"gap",...Array.from({length:r-n+1},(o,h)=>n+h),"gap",a]}const Lr=ps(t=>({requestedHash:null,requestChannel:a=>t({requestedHash:a}),clearRequest:()=>t({requestedHash:null})})),Vn={rx:{icon:Kt,label:"Rx",badgeColor:Me.rx,avatarBg:"bg-sys-green/15",avatarText:"text-sys-green"},forward:{icon:ue,label:"Fwd",badgeColor:Me.forward,avatarBg:"bg-sys-cyan/15",avatarText:"text-sys-cyan"},duplicate:{icon:it,label:"Dupe",badgeColor:Me.duplicate,avatarBg:"bg-fg-muted/15",avatarText:"text-fg-secondary"},tx:{icon:Ys,label:"Tx",badgeColor:Me.tx,avatarBg:"bg-sys-indigo/15",avatarText:"text-sys-indigo"},dropped:{icon:wn,label:"Drop",badgeColor:Me.dropped,avatarBg:"bg-sys-amber/15",avatarText:"text-sys-amber"}},Ct={sm:"w-3.5 h-3.5",md:"w-4 h-4",lg:"w-5 h-5"},Wn={sm:"w-8 h-8",md:"w-9 h-9",lg:"w-10 h-10"};function Gn(t){return t.packet_origin==="tx_local"?"tx":t.packet_origin==="tx_forward"?"forward":t.is_duplicate?"duplicate":t.transmitted?"forward":t.drop_reason?"dropped":"rx"}function Qn({packet:t,showLabel:a=!0,variant:s="avatar",size:n="sm"}){const r=Gn(t),i=Vn[r],l=i.icon;return s==="avatar"?e.jsx("div",{className:z("flex items-center justify-center rounded-full flex-shrink-0",i.avatarBg,Wn[n]),children:e.jsx(l,{className:z(Ct[n],i.avatarText)})}):e.jsxs(P,{color:i.badgeColor,children:[e.jsx(l,{className:Ct[n]}),a&&i.label]})}const es=m.memo(Qn);function qn({path:t,localHash:a,className:s}){if(!t||t.length===0)return e.jsx("span",{className:z("text-fg-muted text-xs",s),children:"—"});const n=a?(a.startsWith("0x")?a.slice(2,4):a.slice(0,2)).toUpperCase():null;return e.jsx("span",{className:z("flex items-center gap-0.5 type-data-xs overflow-hidden",s),children:t.map((r,i)=>{const l=i===t.length-1,c=n&&r.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:r.toUpperCase()}),!l&&e.jsx(ct,{className:"w-2.5 h-2.5 text-fg-muted mx-0.5 flex-shrink-0"})]},`${r}-${i}`)})})}const ts=m.memo(qn);function ss({channelName:t,onClick:a,active:s,compact:n,className:r}){const i=t.startsWith("#")?t:`#${t}`,l=z("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",s?"bg-sys-blue/20 text-sys-blue":"bg-sys-blue/10 text-sys-blue",a&&!s&&"hover:bg-sys-blue/20 cursor-pointer",r);return a?e.jsx("button",{type:"button",onClick:a,className:l,children:i}):e.jsx("span",{className:l,children:i})}function $e(t){return{"--data-box-accent":me[t]}}function ns(t){const a=t.payload_type_name||Dt(t.payload_type??t.type),s=t.route_type_name||Ht(t.route_type??t.route),n=Te[a]??"zinc",r=Ae[s]??"zinc";return{payloadType:a,routeType:s,payloadColor:n,routeColor:r}}function Ue(t){if(!t)return[];if(Array.isArray(t))return t;try{const a=JSON.parse(t);return Array.isArray(a)?a:[]}catch{return[]}}function as(t,a){if(a){const s=a(t);return{name:s.name,isCompanion:s.isCompanion,isRepeater:s.isRepeater}}return{name:null,isCompanion:!1,isRepeater:!1}}function Kn({packet:t,onClick:a,localHash:s,neighbors:n,resolveSource:r,isFlashing:i=!1,isTraceHighlighted:l,onTraceHover:c,traceTag:o,onViewTraceReport:h,dupeGroupPosition:d,isDupeGroupHovered:g=!1,onDupeGroupHover:u,dupeCount:y,getDecodedContent:x,onChannelClick:v}){const p=y?!1:It(t.is_duplicate),w=d!==void 0,{payloadType:j,routeType:b,payloadColor:f,routeColor:T}=ns(t),N=t.packet_origin==="tx_local",D=j==="TRACE",O=Ue(t.original_path),U=Ue(t.forwarded_path),X=U.length>0?U:O,H=t.src_hash?(t.src_hash.startsWith("0x")?t.src_hash.slice(2,6):t.src_hash.slice(0,4)).toUpperCase():null,{name:Z,isRepeater:A}=as(t,r);let R=null,F=null,se=null,J=null;if(j==="GRP_TXT"&&x){const $=x(t);$!=null&&$.decrypted&&(F=$.senderName,se=$.channelName,J=$.channelHash,$.text&&(R=$.text))}else if(j==="TXT_MSG"&&t.raw_packet)try{const $=Qt.fromHex(t.raw_packet);if($.success&&$.packet){const ce=qt($.packet.payload);ce&&!ce.encrypted&&(R=ce.text)}}catch{}const C=F||(A?null:Z),Q=!!C,ae=!Q&&A&&!!Z,B=!Q&&!ae&&j==="GRP_TXT"&&!R,S=t.payload_length??t.length??0;t.lbt_attempts;const te=m.useCallback(()=>{D&&o&&h?h(o):a(t)},[D,o,h,a,t]),W=m.useCallback(()=>{D&&o&&c&&c(o),w&&u&&t.packet_hash&&u(t.packet_hash)},[D,o,c,w,u,t.packet_hash]),q=m.useCallback(()=>{c&&c(null),u&&u(null)},[c,u]),L=me[f]||me.zinc,M=g,le=()=>{const $={pointerEvents:"none"};return d==="first"?{...$,borderTop:`2px solid ${L}`,borderLeft:`2px solid ${L}`,borderRight:`2px solid ${L}`,borderBottom:"none",borderRadius:"8px 8px 0 0",inset:"-2px -2px 0 -2px"}:d==="middle"?{...$,borderTop:"none",borderLeft:`2px solid ${L}`,borderRight:`2px solid ${L}`,borderBottom:"none",borderRadius:0,inset:"0 -2px"}:d==="last"?{...$,borderTop:"none",borderLeft:`2px solid ${L}`,borderRight:`2px solid ${L}`,borderBottom:`2px solid ${L}`,borderRadius:"0 0 8px 8px",inset:"0 -2px -2px -2px"}:{...$,border:`2px solid ${L}`,borderRadius:"8px",inset:"-2px"}};return e.jsxs("div",{onClick:te,onMouseEnter:W,onMouseLeave:q,className:z("group relative cursor-pointer","hover:bg-subtle-fill",p&&!g&&"opacity-40",i&&"flash-row",N&&"bg-sys-indigo/5",l&&"bg-sys-teal/10"),children:[e.jsx("div",{className:z("absolute pointer-events-none transition-opacity duration-75",w?M?"opacity-100":"opacity-0":"opacity-0 group-hover:opacity-100"),style:le()}),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:Q?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-1 ring-edge-subtle",style:{backgroundColor:Wt(Se(C).cleanName)},children:Se(C).emoji?e.jsx("span",{className:"text-base leading-none",children:Se(C).emoji}):e.jsx("span",{className:"text-white text-[10px] font-bold tracking-tighter",children:Gt(C)})}):ae?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-[1.5px] ring-sys-blue",children:e.jsx(ge,{className:"size-5 text-sys-blue"})}):B?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(Jt,{className:"size-4 text-fg-muted"})}):e.jsx(es,{packet:t,variant:"avatar",size:"sm"})}),e.jsx("div",{className:"min-w-0",children:Q?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-[13px] text-fg-primary font-sans truncate max-w-[90px]",children:C}),H&&e.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-fg-muted truncate",children:H})]}):ae?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-[13px] text-fg-primary font-sans truncate max-w-[90px]",children:Z}),H&&e.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-fg-muted truncate",children:H})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-bold text-[13px] text-fg-primary font-sans truncate",children:H||"—"}),Z&&e.jsx("div",{className:"hidden min-[900px]:block text-[9px] text-fg-muted truncate max-w-[70px]",children:Z})]})})]}),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:$e(f),children:j}),y&&y>1&&e.jsxs("span",{className:"data-box data-box-compact flex-shrink-0",children:["×",y]}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:$e(T),children:b}),e.jsxs("span",{className:"hidden min-[520px]:inline type-data-xs text-fg-muted flex-shrink-0",children:[S,"B"]}),e.jsx("div",{className:"flex-1 min-w-0 overflow-hidden",children:R||se?e.jsxs("span",{className:"text-[11px] text-fg-secondary truncate block flex items-center gap-1",children:[se&&e.jsx(ss,{channelName:se,compact:!0,onClick:v&&J?$=>{$.stopPropagation(),v(J)}:void 0}),R&&e.jsx("span",{className:"italic truncate",children:R})]}):e.jsx(ts,{path:X,localHash:s})})]}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("span",{className:"data-box data-box-compact",children:At(t.timestamp)}),e.jsx(De,{rssi:t.rssi,snr:t.snr,compact:!0,showValues:!0,validated:He(t)})]})]})]})}function Yn({packet:t,onClick:a,localHash:s,neighbors:n,resolveSource:r,isFlashing:i=!1,isTraceHighlighted:l,traceTag:c,onViewTraceReport:o,dupeGroupPosition:h,isDupeGroupHovered:d=!1,onDupeGroupHover:g,dupeCount:u,getDecodedContent:y,onChannelClick:x}){const{payloadType:v,routeType:p,payloadColor:w,routeColor:j}=ns(t),b=t.packet_origin==="tx_local",f=v==="TRACE",T=u?!1:It(t.is_duplicate),N=Ue(t.original_path),D=Ue(t.forwarded_path),O=D.length>0?D:N,U=t._hopCount??O.length,X=t.src_hash?(t.src_hash.startsWith("0x")?t.src_hash.slice(2,6):t.src_hash.slice(0,4)).toUpperCase():null,{name:H,isRepeater:Z}=as(t,r);let A=null,R=null,F=null,se=null;if(v==="GRP_TXT"&&y){const L=y(t);L!=null&&L.decrypted&&(R=L.senderName,F=L.channelName,se=L.channelHash,L.text&&(A=L.text))}else if(v==="TXT_MSG"&&t.raw_packet)try{const L=Qt.fromHex(t.raw_packet);if(L.success&&L.packet){const M=qt(L.packet.payload);M&&!M.encrypted&&(A=M.text)}}catch{}const J=R||(Z?null:H),C=!!J,Q=!C&&Z&&!!H,ae=!C&&!Q&&v==="GRP_TXT"&&!A,B=t.payload_length??t.length??0,S=t.lbt_attempts??0,te=()=>{f&&c&&o?o(c):a(t)},W=me[w]||me.zinc,q=()=>{if(!h)return{opacity:0};const L=d?1:.4,M=d?"3px":"2px";return h==="first"?{backgroundColor:W,opacity:L,width:M,top:"6px",bottom:0,borderRadius:"0 9999px 0 0"}:h==="middle"?{backgroundColor:W,opacity:L,width:M,top:0,bottom:0,borderRadius:0}:h==="last"?{backgroundColor:W,opacity:L,width:M,top:0,bottom:"6px",borderRadius:"0 0 9999px 0"}:{backgroundColor:W,opacity:L,width:M,top:"6px",bottom:"6px",borderRadius:"9999px"}};return e.jsxs("div",{onClick:te,className:z("relative pl-3 pr-2.5 py-2 cursor-pointer","active:bg-subtle-fill-hover",T&&"opacity-40",i&&"flash-row",b&&"bg-sys-indigo/5",l&&"bg-sys-teal/10"),children:[e.jsx("div",{className:"absolute left-0 transition-all",style:q()}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"relative flex-shrink-0 mt-0.5",children:C?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-1 ring-edge-subtle",style:{backgroundColor:Wt(Se(J).cleanName)},children:Se(J).emoji?e.jsx("span",{className:"text-base leading-none",children:Se(J).emoji}):e.jsx("span",{className:"text-white text-[10px] font-bold tracking-tighter",children:Gt(J)})}):Q?e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center ring-[1.5px] ring-sys-blue",children:e.jsx(ge,{className:"size-5 text-sys-blue"})}):ae?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(Jt,{className:"size-4 text-fg-muted"})}):e.jsx(es,{packet:t,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:[C?e.jsx("span",{className:"font-medium text-[14px] text-fg-primary tracking-tight truncate min-w-0",children:J}):Q?e.jsx("span",{className:"font-medium text-[14px] text-fg-primary tracking-tight truncate min-w-0",children:H}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold text-[14px] text-fg-primary tracking-tight flex-shrink-0",children:X||"—"}),H&&e.jsx("span",{className:"text-[12px] text-fg-muted truncate min-w-0",children:H})]}),e.jsx("div",{className:"flex-1"}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:$e(w),children:v}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined flex-shrink-0",style:$e(j),children:p}),u&&u>1&&e.jsxs("span",{className:"data-box data-box-compact flex-shrink-0",children:["×",u]}),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:t.rssi}),e.jsx(De,{rssi:t.rssi,compact:!0,showValues:!1,validated:He(t)})]})]}),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:At(t.timestamp)}),B>0&&e.jsxs("span",{children:[B,"B"]}),S>0&&e.jsxs("span",{className:S>1?"text-sys-amber/60":void 0,children:["LBT:",S]}),t.snr!=null&&e.jsxs("span",{children:[t.snr.toFixed(0),"dB"]}),A||F?e.jsxs("span",{className:"text-[11px] text-fg-secondary truncate flex items-center gap-1 min-w-0",children:[F&&e.jsx(ss,{channelName:F,compact:!0,onClick:x&&se?L=>{L.stopPropagation(),x(se)}:void 0}),A&&e.jsx("span",{className:"italic truncate",children:A})]}):U>0?e.jsx(ts,{path:O,localHash:s}):null]})]})]})]})}const Xn=m.memo(Kn),Zn=m.memo(Yn);function Jn(t,a,s,n,r=!1){const i=t.toUpperCase(),l=[],c=s&&Xe(i,s);c&&l.push(s);for(const y of Object.keys(a))Xe(i,y)&&l.push(y);if(r&&c&&s&&l.length===1)return{matches:l,probability:1,bestMatch:s};if(r&&c&&l.length>1){const y=l.filter(x=>x!==s);if(y.length===1)return{matches:l,probability:1,bestMatch:y[0]}}const o=l.length>0?1/l.length:0,h=[...l].sort();let d=null,g=-1;if(h.length===1)d=h[0];else if(h.length>1&&n){for(const y of h){const x=n.get(y),v=x?typeof x=="number"?x:x.combinedScore:0;v>g&&(g=v,d=y)}d||(d=h[0])}else h.length>0&&(d=h[0]);let u=o;if(l.length>1&&n&&g>0){let y=0;for(const x of l){const v=n.get(x);y+=v?typeof v=="number"?v:v.combinedScore:0}y>0&&(u=Math.min(.95,g/y))}return{matches:l,probability:u,bestMatch:d}}function ea(t,a,s,n){const i=(s-t)*Math.PI/180,l=(n-a)*Math.PI/180,c=Math.sin(i/2)*Math.sin(i/2)+Math.cos(t*Math.PI/180)*Math.cos(s*Math.PI/180)*Math.sin(l/2)*Math.sin(l/2);return 6371e3*(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)))}function ta(t){return t<100?1:t<500?.9:t<1e3?.7:t<5e3?.5:t<1e4?.3:.1}const sa=m.lazy(()=>fs(()=>import("./PathMapMapLibre-ANGN4-cP.js"),__vite__mapDeps([0,1,2,3,4,5,6])));function na(t,a,s,n,r=!1,i,l,c){const o=Xs(a);let h;l&&(h=Zs(l,t,{position:c,isLastHop:r}).confidence);const{matches:d,probability:g}=Jn(t,o,n,i,r),u=d.length,y=[],x=t.toUpperCase(),v=s&&s.latitude!==void 0&&s.longitude!==void 0&&(s.latitude!==0||s.longitude!==0);for(const w of d){if(n&&Xe(x,n)&&w===n&&v&&s){y.push({hash:w,name:s.name||"Local Node",latitude:s.latitude,longitude:s.longitude,probability:r?1:g,isLocal:!0});continue}const j=o[w];j!=null&&j.latitude&&(j!=null&&j.longitude)&&!(j.latitude===0&&j.longitude===0)&&y.push({hash:w,name:j.node_name||j.name||"Unknown",latitude:j.latitude,longitude:j.longitude,probability:g,isLocal:!1,isDirectNeighbor:j.zero_hop===!0})}const p=y.length;if(p===1)y[0].probability=h??1;else if(p>1)if(h!==void 0&&h>0){const w=y[0];w.probability=h;const j=1-h,b=p-1;y.slice(1).forEach(f=>{f.probability=j/b})}else{let w=0;const j=y.map(b=>{if(b.isLocal)return{candidate:b,score:1};const f=i==null?void 0:i.get(b.hash);let T=.5;if(v&&s){const D=ea(s.latitude,s.longitude,b.latitude,b.longitude);T=ta(D)}let N;return f?N=T*.3+f.hopConsistencyScore*.3+f.frequencyScore*.4:(N=T,b.isDirectNeighbor&&(N=Math.max(N,.8))),w+=N,{candidate:b,score:N}});if(w>0)j.forEach(({candidate:b,score:f})=>{b.probability=Math.min(.95,f/w)});else{const b=1/p;y.forEach(f=>f.probability=b)}}return{candidates:y,totalMatches:u}}function aa(t,a,s,n,r,i){if(!t||t.length===0)return{hops:[],overallConfidence:0,hasValidPath:!1};const l=t.length-1,c=t.map((d,g)=>{const u=g===l,y=t.length-g,{candidates:x,totalMatches:v}=na(d,a,s,n,u,r,i,y),p=x.length>0?Math.max(...x.map(w=>w.probability)):0;return{prefix:d,candidates:x,confidence:p,totalMatches:v}}),o=c.reduce((d,g)=>g.confidence===0?0:d*g.confidence,1),h=c.some(d=>d.candidates.length>0);return{hops:c,overallConfidence:o,hasValidPath:h}}function ra(t){return`${(t*100).toFixed(0)}%`}function ia(t){return t>=1?"text-sys-green":t>=.5?"text-sys-indigo":t>=.25?"text-signal-poor":t>0?"text-sys-red":"text-fg-muted"}function la(t,a,s){let n;return a===0?n=s.muted:t>=1?n=s.success:t>=.5?n=s.secondary:t>=.25?n=s.poor:t>0?n=s.danger:n=s.muted,{color:n}}class ca 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(Je,{className:"w-4 h-4 mr-2"}),"Map failed to load"]}):this.props.children}}function Ve({path:t,neighbors:a,localNode:s,localHash:n,srcHash:r,dstHash:i,neighborAffinity:l,prefixLookup:c,hubNodes:o,traceSnr:h,advertiserSource:d}){const[g,u]=m.useState(null),y=m.useMemo(()=>{if(!d)return null;const b=d.nodeType==="wardrive";return{prefix:d.prefix||"??",candidates:[{hash:d.publicKey||d.prefix||"source",name:d.name,latitude:d.latitude,longitude:d.longitude,probability:1,isLocal:!1,isWardrive:b}],confidence:1,totalMatches:1,isSource:!0}},[d]),x=m.useMemo(()=>{if(d||!r)return null;const b=Qe(r),f=a[r];if((f==null?void 0:f.latitude)&&(f==null?void 0:f.longitude)&&!(f.latitude===0&&f.longitude===0))return{prefix:b,candidates:[{hash:r,name:f.node_name||f.name||"Source",latitude:f.latitude,longitude:f.longitude,probability:1,isLocal:!1,isDirectNeighbor:f.zero_hop===!0}],confidence:1,totalMatches:1,isSource:!0};const N=(f==null?void 0:f.node_name)||(f==null?void 0:f.name)||r.slice(0,8);return{prefix:b,candidates:[{hash:r,name:N,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isSource:!0}},[d,r,a]),v=m.useMemo(()=>{const b=i!=null&&i.startsWith("0x")?i.slice(2):i;if((!b||b==="00"||b==="0000000000000000")&&s&&n){const U=Qe(n),X=s.latitude!==0||s.longitude!==0;return{prefix:U,candidates:[{hash:n,name:s.name||"Local Node",latitude:X?s.latitude:0,longitude:X?s.longitude:0,probability:1,isLocal:!0}],confidence:1,totalMatches:1,isDestination:!0}}if(!i)return null;const T=Qe(i);if(n&&i===n&&s){const U=s.latitude!==0||s.longitude!==0;return{prefix:T,candidates:[{hash:i,name:s.name||"Local Node",latitude:U?s.latitude:0,longitude:U?s.longitude:0,probability:1,isLocal:!0}],confidence:1,totalMatches:1,isDestination:!0}}const N=a[i];if((N==null?void 0:N.latitude)&&(N==null?void 0:N.longitude)&&!(N.latitude===0&&N.longitude===0))return{prefix:T,candidates:[{hash:i,name:N.node_name||N.name||"Destination",latitude:N.latitude,longitude:N.longitude,probability:1,isLocal:!1,isDirectNeighbor:N.zero_hop===!0}],confidence:1,totalMatches:1,isDestination:!0};const O=(N==null?void 0:N.node_name)||(N==null?void 0:N.name)||i.slice(0,8);return{prefix:T,candidates:[{hash:i,name:O,latitude:0,longitude:0,probability:1,isLocal:!1}],confidence:1,totalMatches:1,isDestination:!0}},[i,a,s,n]),p=m.useMemo(()=>aa(t,a,s,n,l,c),[t,a,s,n,l,c]),w=m.useMemo(()=>{const b=[];y?b.push(y):x&&b.push(x),b.push(...p.hops),v&&b.push(v);const f=b.reduce((N,D)=>D.confidence===0?0:N*D.confidence,1),T=b.some(N=>N.candidates.some(D=>D.latitude!==0||D.longitude!==0));return{hops:b,overallConfidence:f,hasValidPath:T}},[y,x,p,v]),j=m.useMemo(()=>{const b=getComputedStyle(document.documentElement);return{success:b.getPropertyValue("--sys-green").trim()||"#39D98A",secondary:b.getPropertyValue("--sys-indigo").trim()||"#F9D26F",poor:b.getPropertyValue("--signal-poor").trim()||"#FF8A5C",danger:b.getPropertyValue("--sys-red").trim()||"#FF5C7A",muted:b.getPropertyValue("--text-muted").trim()||"#767688"}},[]);return w.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:ia(w.overallConfidence),children:ra(w.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(Js,{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(ca,{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(sa,{resolvedPath:w,localNode:s,hubNodes:o,hoveredHopIndex:g,onHoverHop:u,traceSnr:h})})})}),e.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:w.hops.map((b,f)=>{var U,X,H;const T=b.isSource===!0,N=b.isDestination===!0,D=g===f;let O;return T?O=`Source: ${((U=b.candidates[0])==null?void 0:U.name)||"Unknown"}`:N?O=`Destination: ${((X=b.candidates[0])==null?void 0:X.name)||"Unknown"}`:b.totalMatches===0?O="No matching nodes found":b.totalMatches===1?O=`Exact match: ${((H=b.candidates[0])==null?void 0:H.name)||"Unknown"}`:O=`${b.totalMatches} possible matches (${(b.confidence*100).toFixed(0)}% confidence)`,e.jsxs("div",{className:z("flex items-center gap-1 px-1.5 py-0.5 rounded type-data-xs cursor-pointer transition-all",D?"bg-sys-blue/20 ring-1 ring-sys-blue/50":"bg-elevated hover:bg-subtle",T&&"border border-sys-green/30",N&&"border border-sys-blue/30"),title:O,onMouseEnter:()=>u(f),onMouseLeave:()=>u(null),children:[T&&e.jsx("span",{className:"text-sys-green text-[8px] mr-0.5",children:"SRC"}),N&&e.jsx("span",{className:"text-sys-blue text-[8px] mr-0.5",children:"DST"}),e.jsx("span",{style:la(b.confidence,b.totalMatches,j),children:b.prefix}),!T&&!N&&b.totalMatches>1&&e.jsxs("span",{className:"text-fg-muted",children:["×",b.totalMatches]}),!T&&!N&&b.totalMatches===0&&e.jsx("span",{className:"text-fg-muted",children:"?"})]},f)})})]}):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 We(t){return t.match(/.{1,2}/g)||[]}function je(t){return t!==null&&t.startsWith("payload:")}const _e={hexRestOpacity:15,cardRestBg:"color-mix(in srgb, var(--elevated) 60%, var(--body))",cardRestShadow:` - 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) - `,selectionBorderWidth:2},st={type:"tween",duration:.25,ease:[.25,.1,.25,1]};function oa(t,a){return t?`inset 0 0 0 ${_e.selectionBorderWidth}px ${me[a]}`:_e.cardRestShadow}function da(t,a){return t?a:`color-mix(in srgb, ${a} ${_e.hexRestOpacity}%, transparent)`}function xa({segments:t,selectedSegment:a,onSegmentClick:s}){const[n,r]=m.useState(null),[i,l]=m.useState(null),c=t.some(d=>d.id!==void 0)&&s,o=[];for(const d of t){const g=We(d.hex);for(const u of g)o.push({byte:u.toUpperCase(),color:d.color,id:d.id})}const h=[];for(let d=0;d{const u=d.length{const w=p===d.length-1,j=u&&w,b=me[x],N=(v?n===v:i===x)||!!(v&&a===v);return e.jsx("span",{className:`w-[1.75rem] text-xs text-center py-0.5 font-mono select-text ${c?"cursor-pointer":""}`,style:{backgroundColor:da(N,b),color:N?"rgba(255,255,255,0.95)":b,transition:N?"none":"background-color 0.15s ease-out, color 0.15s ease-out",touchAction:"manipulation",...j?{borderRadius:"0 0.375rem 0.375rem 0"}:{}},onMouseEnter:()=>{v?r(v):l(x)},onMouseLeave:()=>{r(null),l(null)},onClick:()=>v&&(s==null?void 0:s(v)),onTouchStart:()=>{v?r(v):l(x)},onTouchEnd:()=>{r(null),l(null)},children:y},p)})},g)})})}function ha({rawHex:t,hexSegments:a,selectedSegment:s,onSegmentClick:n}){const[r,i]=m.useState(!1),l=m.useCallback(async()=>{try{await navigator.clipboard.writeText(t.toUpperCase()),i(!0),setTimeout(()=>i(!1),2e3)}catch(c){console.error("Failed to copy:",c)}},[t]);return e.jsxs("div",{className:"bg-black rounded-2xl p-6 relative",children:[e.jsx(xa,{segments:a,selectedSegment:s,onSegmentClick:n}),e.jsx("button",{onClick:l,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:r?e.jsxs(e.Fragment,{children:[e.jsx(js,{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(it,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Copy"})]})})]})}function ma(t,a){const s=[];let n=0;const r=a.slice(0,64);s.push({id:"payload:publicKey",title:"Public Key",color:"pink",hex:r,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:t.publicKey.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Ed25519 public key (32 bytes)"})]})}),n+=32;const i=a.slice(64,72);s.push({id:"payload:timestamp",title:"Timestamp",color:"orange",hex:i,startByte:n,endByte:n+3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(ee,{size:"standard",copy:!0,children:i.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:[t.timestamp," (",ie(t.timestamp),")"]})]})}),n+=4;const l=a.slice(72,200);s.push({id:"payload:signature",title:"Signature",color:"teal",hex:l,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:t.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(s.push({id:"payload:flags",title:"Flags",color:"blue",hex:c,startByte:n,endByte:n,decoded:e.jsxs(e.Fragment,{children:[e.jsxs(ee,{size:"standard",copy:!0,children:["0x",t.flags.toString(16).padStart(2,"0").toUpperCase()]}),e.jsx("p",{className:"text-xs text-fg-primary mt-1",children:t.flagsDescription}),e.jsxs("p",{className:"text-xs text-fg-muted",children:["Node Type: ",t.nodeType]})]})}),n+=1,t.latitude!==void 0){const o=a.slice(n*2,n*2+8);s.push({id:"payload:latitude",title:"Latitude",color:"green",hex:o,startByte:n,endByte:n+3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(ee,{size:"standard",copy:!0,children:o.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:[t.latitude.toFixed(6),"°"]})]})}),n+=4}if(t.longitude!==void 0){const o=a.slice(n*2,n*2+8);s.push({id:"payload:longitude",title:"Longitude",color:"indigo",hex:o,startByte:n,endByte:n+3,decoded:e.jsxs(e.Fragment,{children:[e.jsx(ee,{size:"standard",copy:!0,children:o.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:[t.longitude.toFixed(6),"°"]})]})}),n+=4}if(t.name){const o=a.slice(n*2),h=o.length/2;s.push({id:"payload:name",title:"Name",color:"amber",hex:o,startByte:n,endByte:n+h-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx(ee,{size:"standard",copy:!0,children:o.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:['"',t.name,'"']})]})})}return s}function ua(t,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(ee,{size:"standard",copy:!0,children:["0x",t.crc]}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"CRC32 of acknowledged packet"})]})}]}function pa(t,a){const s=[];s.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(ee,{size:"standard",copy:!0,children:["0x",t.channelHash]}),t.channelName&&e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:["Channel: ",t.channelName]})]})}),t.macHex&&s.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(ee,{size:"standard",copy:!0,children:t.macHex.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Truncated HMAC-SHA256"})]})});const n=a.slice(6);return n&&s.push({id:"payload:ciphertext",title:t.decrypted?"Message":"Ciphertext",color:t.decrypted?"green":"zinc",hex:n,startByte:3,endByte:3+n.length/2-1,decoded:t.decrypted?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-sm text-fg-primary",children:['"',t.text,'"']}),t.senderName&&e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:["From: ",t.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"})]})}),s}function fa(t,a){const s=[];s.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(ee,{size:"standard",copy:!0,children:["0x",t.channelHash]}),t.channelName&&e.jsxs("p",{className:"text-xs text-fg-primary mt-1",children:["Channel: ",t.channelName]})]})}),t.macHex&&s.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(ee,{size:"standard",copy:!0,children:t.macHex.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Truncated HMAC-SHA256"})]})});const n=a.slice(6);return n&&s.push({id:"payload:ciphertext",title:t.decrypted?"Decrypted Data":"Encrypted Data",color:t.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:(t.decryptedHex||n).toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[t.dataLength," bytes",t.decrypted?"":" (AES-128-ECB encrypted)"]})]})}),s}function ga(t,a){const s=[];if(s.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(ee,{size:"standard",children:t.pathLength}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[t.pathLength," hop",t.pathLength!==1?"s":""]})]})}),t.path.length>0){const n=a.slice(2,2+t.pathLength*2);s.push({id:"payload:path",title:"Path Hops",color:"amber",hex:n,startByte:1,endByte:t.pathLength,decoded:e.jsx(e.Fragment,{children:e.jsx("div",{className:"flex flex-wrap items-center gap-1",children:t.path.map((r,i)=>e.jsxs("span",{className:"flex items-center gap-1",children:[i>0&&e.jsx(ue,{className:"w-3 h-3 text-fg-muted"}),e.jsx(P,{color:"amber",className:"font-mono",children:r})]},i))})})})}if(t.extraType!=null){const n=1+t.pathLength;s.push({id:"payload:extraType",title:"Extra Type",color:"indigo",hex:a.slice(n*2,n*2+2),startByte:n,endByte:n,decoded:e.jsxs(e.Fragment,{children:[e.jsx(ee,{size:"standard",children:t.extraTypeName??`0x${t.extraType.toString(16).padStart(2,"0")}`}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Bundled payload type"})]})})}if(t.extraData){const n=1+t.pathLength+1,r=a.slice(n*2);r&&s.push({id:"payload:extraData",title:"Extra Data",color:"indigo",hex:r,startByte:n,endByte:n+r.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:r.toUpperCase()}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[r.length/2," bytes"]})]})})}return s}function ya(t,a){const s=[];s.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(ee,{size:"standard",copy:!0,children:["0x",t.traceTag]}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Unique trace request identifier"})]})}),s.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(ee,{size:"standard",copy:!0,children:t.authCode}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Authentication/verification code"})]})}),s.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(ee,{size:"standard",copy:!0,children:["0x",t.flags.toString(16).toUpperCase().padStart(2,"0")]}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:t.flags===0?"No flags set":`Flags: ${t.flags.toString(2).padStart(8,"0")}b`})]})});const n=a.slice(18);return n&&s.push({id:"payload:path",title:"Target Path",color:"indigo",hex:n,startByte:9,endByte:9+n.length/2-1,decoded:e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap items-center gap-1",children:t.pathHashes.map((r,i)=>{const l=t.snrValues[i],c=l!==void 0?Gs(l):"zinc";return e.jsxs("span",{className:"flex items-center gap-1",children:[i>0&&e.jsx(ue,{className:"w-3 h-3 text-fg-muted"}),e.jsx(P,{color:"indigo",className:"font-mono",children:r}),l!==void 0&&e.jsxs(P,{color:c,className:"font-mono",children:[l>=0?"+":"",Number.isInteger(l)?l:l.toFixed(1),"dB"]})]},i)})}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:[t.pathHashes.length," target ",t.pathHashes.length===1?"hop":"hops",t.snrValues.length>0&&` • ${t.snrValues.length} SNR ${t.snrValues.length===1?"value":"values"} collected`,t.isComplete&&" • ✓ Complete"]})]})}),s}function ja(t,a){const s=[];s.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(ee,{size:"standard",copy:!0,children:t.messageId.toUpperCase()}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Unique message identifier"})]})}),s.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(ee,{size:"standard",copy:!0,children:t.partNumber}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"0-indexed part number"})]})}),s.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(ee,{size:"standard",copy:!0,children:t.totalParts}),e.jsxs("p",{className:"text-xs text-fg-muted mt-1",children:["Part ",t.partNumber+1," of ",t.totalParts]})]})});const n=a.slice(8);return n&&s.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"]})]})}),s}function ba(t,a){switch(t.type){case"advert":return ma(t,a);case"ack":return ua(t,a);case"grp_txt":return pa(t,a);case"grp_data":return fa(t,a);case"path":return ga(t,a);case"trace":return ya(t,a);case"multipart":return ja(t,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 Na(t){return t.map(a=>({id:a.id,hex:a.hex,color:a.color}))}function va({bits:t,field:a,value:s,binary:n}){const r=()=>{if(a==="Payload Type"){const i=Te[s]||"zinc";return e.jsx(P,{color:i,children:s})}if(a==="Route Type"){const i=Ae[s]||"zinc";return e.jsx(P,{color:i,children:s})}return e.jsx("span",{className:"text-sm text-fg-primary",children:s})};return e.jsxs("tr",{children:[e.jsx("td",{className:"py-1.5 text-xs text-fg-muted tabular-nums",children:t}),e.jsx("td",{className:"py-1.5 text-sm text-fg-secondary",children:a}),e.jsx("td",{className:"py-1.5",children:r()}),e.jsx("td",{className:"py-1.5 type-data-xs text-sys-cyan",children:n})]})}function St({id:t,title:a,color:s,hexBytes:n,startByte:r,endByte:i,isSelected:l,children:c}){const o=n?We(n):[];return e.jsxs(de.div,{layout:"position",layoutId:t,transition:st,className:"w-full min-w-0 overflow-hidden rounded-xl p-4 sm:p-5 space-y-4",style:{backgroundColor:_e.cardRestBg,boxShadow:oa(l,s)},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(P,{color:s,children:a}),o.length>0&&o.length<=16&&o.map((h,d)=>e.jsx(P,{color:s,className:"font-mono",children:h.toUpperCase()},d))]}),e.jsxs("span",{className:"type-data-xs text-fg-muted flex-shrink-0",children:["Bytes ",r,"-",i]})]}),e.jsx("div",{className:"min-w-0 overflow-hidden",children:c})]})}function wa({advert:t,timestamp:a}){const s=a?ie(a):ie(t.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(ge,{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:t.name||"Unknown Node"}),e.jsx("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:t.nodeType})]})]}),e.jsx("div",{className:"mx-4 border-t border-edge-subtle"}),e.jsxs("div",{className:"px-4 py-3 space-y-2",children:[t.latitude!==void 0&&t.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:[t.latitude.toFixed(5),"°, ",t.longitude.toFixed(5),"°"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ye,{className:"w-4 h-4 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:s})]})]})]})})}function ka({decoded:t,timestamp:a}){const s=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(nn,{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:t.channelName||"Channel Data"}),e.jsxs("p",{className:"text-sm text-fg-muted font-sans mt-0.5",children:[t.dataLength," bytes • ",t.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(Yt,{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",t.channelHash]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ye,{className:"w-4 h-4 text-sys-teal flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:s})]}),t.decrypted&&t.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(ee,{size:"compact",copy:!0,className:"inline-block",children:e.jsx("span",{className:"break-all text-xs",children:t.decryptedHex.toUpperCase()})})})]})]})]})})}function Ca({decoded:t,timestamp:a,isLoading:s=!1,onDecrypted:n}){const r=a?ie(a):"Unknown",[i,l]=m.useState(""),[c,o]=m.useState(!1),[h,d]=m.useState(null),[g,u]=m.useState(!1),y=m.useCallback(async()=>{if(!(!i.trim()||!t.ciphertextHex||!t.macHex)){o(!0),d(null);try{const x=parseInt(t.channelHash,16),v=pt(t.macHex),p=pt(t.ciphertextHex),w=await Ns(i.trim(),x,v,p);if(w.success){const j=w.result.plaintext,b=new TextDecoder("utf-8",{fatal:!1}).decode(j.slice(5)),f=b.indexOf(": "),T={...t,channelName:w.result.channelName,decrypted:!0,timestamp:j[0]|j[1]<<8|j[2]<<16|j[3]<<24,flags:j[4],senderName:f>0?b.slice(0,f):void 0,text:f>0?b.slice(f+2):b};n==null||n(T),l(""),u(!1)}else d(w.error)}catch(x){d(x instanceof Error?x.message:"Unknown error")}finally{o(!1)}}},[i,t,n]);return s?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"})]})})]})}):t.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:[t.senderName&&e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:["From ",e.jsx("span",{className:"text-fg-secondary font-medium",children:t.senderName})]}),t.channelName&&e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:["in ",e.jsx("span",{className:"text-sys-cyan font-medium",children:t.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:t.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(ot,{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:t.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",t.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(ye,{className:"w-4 h-4 text-zinc-400 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:r})]}),t.ciphertextHex&&t.macHex&&e.jsx("div",{className:"space-y-2",children:g?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:i,onChange:x=>l(x.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:x=>x.key==="Enter"&&y(),disabled:c}),e.jsx("button",{onClick:y,disabled:c||!i.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:()=>{u(!1),d(null),l("")},className:"px-2 py-1.5 text-sm rounded-lg hover:bg-subtle-fill-strong text-fg-muted transition-colors",children:"×"})]}),h&&e.jsx("p",{className:"text-xs text-sys-red",children:h})]}):e.jsx("button",{onClick:()=>u(!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"})}),!g&&e.jsx("p",{className:"text-xs text-fg-muted",children:t.isPublicHashChannel?"Public hash channel message. Key not in common channel list.":"Unknown hash channel. Channel name required for decryption."})]})]})})}function Sa({decoded:t,timestamp:a}){const s=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(sn,{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",t.crc]})," · ",s]})]})]})}function _a({decoded:t,timestamp:a}){const s=a?ie(a):"Unknown",n=t.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(Tn,{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(ye,{className:"w-4 h-4 text-sys-amber flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:s})]}),t.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:t.path.map((r,i)=>e.jsxs("div",{className:"flex items-center gap-2",children:[i>0&&e.jsx(ue,{className:"w-4 h-4 text-sys-amber"}),e.jsx(P,{color:"amber",className:"font-mono",children:r})]},i))})})]})]})})}function Ma({decoded:t,timestamp:a}){const s=a?ie(a):"Unknown",n=t.pathHashes.length,r=t.snrValues.length,i=l=>l>=7?"green":l>=0?"yellow":l>=-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(tn,{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 ",t.isComplete?"Complete":"In Progress"]}),e.jsxs("p",{className:"text-sm text-fg-muted mt-0.5",children:["Tag: 0x",t.traceTag.slice(0,8),t.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(ye,{className:"w-4 h-4 text-sys-blue flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary",children:s})]}),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:[r," SNR ",r===1?"sample":"samples"]}),t.authCode!==0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs("span",{children:["Auth: ",t.authCode]})]})]}),t.pathHashes.length>0&&e.jsx("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:t.pathHashes.map((l,c)=>{const o=t.snrValues[c],h=o!==void 0?i(o):"zinc",d=o!==void 0;return e.jsxs("div",{className:"flex items-center gap-2",children:[c>0&&e.jsx(ue,{className:"w-4 h-4 text-sys-blue flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(P,{color:d?"blue":"zinc",className:"font-mono",children:l}),d&&e.jsxs(P,{color:h,className:"font-mono",children:[o>=0?"+":"",Number.isInteger(o)?o:o.toFixed(1),"dB"]})]})]},c)})})]})]})})}function Ta({decoded:t,timestamp:a}){const s=a?ie(a):"Unknown";return t.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(ot,{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:[t.srcHash," → ",t.destHash," · ",s]})]})]}):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:t.srcHash})," → ",e.jsx("span",{className:"font-mono text-fg-secondary",children:t.destHash})]}),e.jsxs("span",{className:"text-[11px] text-fg-muted font-sans",children:["· ",s]})]}),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:t.text})})]})}function Pa({decoded:t,timestamp:a}){const s=a?ie(a):"Unknown",n=(t.partNumber+1)/t.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(en,{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 ",t.partNumber+1," of ",t.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(Yt,{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:t.messageId})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ye,{className:"w-4 h-4 text-sys-yellow flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-secondary font-sans",children:s})]})]})]})})}function Ba({decoded:t,timestamp:a,payloadType:s}){const n=a?ie(a):"Unknown",i=(()=>{switch(s){case oe.REQ:return{icon:vs,gradient:"var(--sys-orange), var(--sys-red)",bg:"rgba(249, 115, 22, 0.15)",label:"Request"};case oe.RESPONSE:return{icon:_n,gradient:"var(--sys-green), var(--sys-teal)",bg:"rgba(34, 197, 94, 0.15)",label:"Response"};case oe.ANON_REQ:return{icon:ot,gradient:"var(--sys-indigo), var(--sys-pink)",bg:"rgba(91, 91, 214, 0.15)",label:"Anonymous Request"};default:return{icon:Ks,gradient:"var(--sys-gray), var(--sys-slate)",bg:"rgba(107, 114, 128, 0.15)",label:t.payloadTypeName}}})(),l=i.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, ${i.gradient})`},children:e.jsx(l,{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:i.label}),e.jsxs("p",{className:"text-xs text-fg-muted font-sans mt-0.5",children:[t.length," bytes · ",n]})]})]})}function La({pathHex:t}){if(!t)return null;const a=We(t);return e.jsx("div",{className:"flex flex-wrap items-center gap-2 py-2",children:a.map((s,n)=>e.jsxs("div",{className:"flex items-center gap-2",children:[n>0&&e.jsx(ue,{className:"w-4 h-4 text-sys-amber flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ee,{size:"compact",copy:!0,children:s.toUpperCase()}),e.jsx("span",{className:"text-xs text-fg-muted font-sans tabular-nums w-4 text-left",children:n+1})]})]},n))})}function Ra({decoded:t,payloadType:a}){const s=bs[a]||`TYPE_${a}`;switch(t.type){case"advert":{const n=t.nodeType==="chat"?"companion":t.nodeType.replace("_"," "),r=t.latitude!==void 0&&t.longitude!==void 0&&!(t.latitude===0&&t.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]}),t.name&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Name:"})," ",t.name]}),r&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Location:"})," ",t.latitude.toFixed(4),"°, ",t.longitude.toFixed(4),"°"]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Time:"})," ",ie(t.timestamp)]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Flags:"})," ",t.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",t.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:"})," ",t.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",t.traceTag]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Target Path:"})," ",t.pathString||"(empty)"]}),t.snrValues.length>0&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"SNR:"})," ",t.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:"})," ",t.isComplete?"✓ Complete":`In progress (${t.snrValues.length}/${t.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:"})," ",t.destHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Src:"})," ",t.srcHash]}),t.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:"})," ",t.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:"})," ",t.channelName?e.jsx("span",{className:"text-sys-green",children:t.channelName}):t.isPublicHashChannel?e.jsx("span",{className:"text-sys-indigo",children:"Public Hash Channel"}):e.jsxs("span",{className:"font-mono",children:["0x",t.channelHash]})]}),t.decrypted?e.jsxs(e.Fragment,{children:[t.senderName&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"From:"})," ",t.senderName]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Text:"})," ",t.text]})]}):t.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:"})," ",t.channelName?e.jsx("span",{className:"text-sys-teal",children:t.channelName}):e.jsxs("span",{className:"font-mono",children:["0x",t.channelHash]})]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Data:"})," ",t.dataLength," bytes ",t.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:"})," ",t.partNumber+1,"/",t.totalParts]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Message ID:"})," ",t.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:"})," ",t.subtypeName]}),t.dataLength>0&&e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Data:"})," ",t.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:"})," ",t.destHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Src:"})," ",t.srcHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Ciphertext:"})," ",t.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:"})," ",t.destHash]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Pub Key:"})," ",e.jsxs("span",{className:"font-mono break-all",children:[t.senderPublicKey.slice(0,16),"…"]})]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-muted",children:"Ciphertext:"})," ",t.ciphertextLength," bytes"]})]});default:return e.jsxs("p",{className:"text-xs text-fg-secondary",children:[s," (","length"in t?t.length:0," bytes)"]})}}function Ea({packet:t,decodedGrpTxt:a}){var H,Z;const s=t.raw_packet||"",n=s.length/2,r=gs(),[i,l]=m.useState(null),[c,o]=m.useState(null),[h,d]=m.useState(!1),[g,u]=m.useState(null),y=m.useCallback(A=>{u(R=>R===A?null:A)},[]),x=m.useMemo(()=>zs(s),[s]),v=(H=x==null?void 0:x.packet)==null?void 0:H.payloadType,p=(x==null?void 0:x.payloadHex)||"",w=(Z=x==null?void 0:x.packet)==null?void 0:Z.payload,j=v===oe.GRP_TXT,b=v===oe.GRP_DATA,f=j&&!a&&(!r||h);if(m.useEffect(()=>{if(l(null),d(!1),a||!j||!w||w.length<4)return;if(!r){d(!0);return}d(!0);let A=!1;return Qs(w).then(R=>{A||(l(R),d(!1))}),()=>{A=!0}},[p,j,r,a]),m.useEffect(()=>{if(o(null),!b||!w||w.length<4||!r)return;let A=!1;return qs(w).then(R=>{A||o(R)}),()=>{A=!0}},[p,b,r]),!x||s.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:T}=x;let N=x.decoded;a&&x.decoded.type==="grp_txt"?N=a:i&&x.decoded.type==="grp_txt"?N=i:c&&x.decoded.type==="grp_data"&&(N=c);const D=()=>{switch(N.type){case"advert":return e.jsx(wa,{advert:N,timestamp:t.timestamp});case"grp_data":return e.jsx(ka,{decoded:N,timestamp:t.timestamp});case"grp_txt":return e.jsx(Ca,{decoded:N,timestamp:t.timestamp,isLoading:f,onDecrypted:l});case"ack":return e.jsx(Sa,{decoded:N,timestamp:t.timestamp});case"path":return e.jsx(_a,{decoded:N,timestamp:t.timestamp});case"trace":return e.jsx(Ma,{decoded:N,timestamp:t.timestamp});case"txt_msg":return e.jsx(Ta,{decoded:N,timestamp:t.timestamp});case"multipart":return e.jsx(Pa,{decoded:N,timestamp:t.timestamp});case"generic":return T.payloadType===oe.REQ||T.payloadType===oe.RESPONSE||T.payloadType===oe.ANON_REQ?e.jsx(Ba,{decoded:N,timestamp:t.timestamp,payloadType:T.payloadType}):null;default:return null}},O=m.useMemo(()=>ba(N,x.payloadHex),[N,x.payloadHex]),U=g==="payload"||je(g),X=m.useMemo(()=>{const A=[{id:"header",hex:x.headerHex,color:"red"},...x.transportCodesHex?[{id:"transportCodes",hex:x.transportCodesHex,color:"indigo"}]:[],{id:"pathLength",hex:x.pathLengthHex,color:"green"},...x.pathDataHex?[{id:"pathData",hex:x.pathDataHex,color:"amber"}]:[]];return U?[...A,...Na(O)]:[...A,{id:"payload",hex:x.payloadHex,color:"cyan"}]},[x,U,O]);return e.jsxs("div",{className:"font-mono space-y-2 min-w-0 overflow-hidden",children:[D(),e.jsx(ha,{rawHex:s,hexSegments:X,selectedSegment:g,onSegmentClick:y}),e.jsx(ys,{children:e.jsx(de.div,{layout:!0,transition:st,className:"space-y-2 min-w-0",children:(()=>{var C,Q,ae,B;const R=[{id:"header",title:"Header",color:"red",startByte:0,endByte:0,hexBytes:`0x${x.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 border-b border-edge-subtle font-sans",children:[e.jsx("th",{className:"py-1 font-medium",children:"Bits"}),e.jsx("th",{className:"py-1 font-medium",children:"Field"}),e.jsx("th",{className:"py-1 font-medium",children:"Value"}),e.jsx("th",{className:"py-1 font-medium",children:"Binary"})]})}),e.jsx("tbody",{children:x.headerFields.map(S=>e.jsx(va,{...S},S.bits))})]})},{id:"transportCodes",title:"Transport Codes",color:"indigo",startByte:1,endByte:4,hexBytes:((C=x.transportCodesHex)==null?void 0:C.toUpperCase())||"",condition:!!x.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",(Q=x.transportCodesHex)==null?void 0:Q.slice(0,4).toUpperCase()," | Code 2: 0x",(ae=x.transportCodesHex)==null?void 0:ae.slice(4,8).toUpperCase()]})]})},{id:"pathLength",title:"Path Length",color:"green",startByte:x.transportCodesHex?5:1,endByte:x.transportCodesHex?5:1,hexBytes:`0x${x.pathLengthHex.toUpperCase()}`,condition:!0,content:e.jsxs("p",{className:"text-xs text-fg-muted pt-1",children:[T.pathLen," bytes showing route taken (increases as packet floods)"]})},{id:"pathData",title:"Path Data",color:"amber",startByte:x.transportCodesHex?6:2,endByte:(x.transportCodesHex?5:1)+T.pathLen,hexBytes:((B=x.pathDataHex)==null?void 0:B.toUpperCase())||"",condition:T.pathLen>0,content:e.jsxs("div",{className:"space-y-3",children:[e.jsx(La,{pathHex:x.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:x.payloadStartByte,endByte:n-1,hexBytes:x.payloadHex.toUpperCase(),condition:!0,content:e.jsxs(e.Fragment,{children:[!je(g)&&e.jsxs("div",{className:"p-3 rounded-lg bg-black",children:[e.jsx("p",{className:"type-micro text-fg-muted mb-1.5 font-sans",children:"Decoded"}),e.jsx(Ra,{decoded:N,payloadType:T.payloadType})]}),!je(g)&&O.length>0&&e.jsx("p",{className:"type-micro text-fg-muted mt-3 font-sans",children:"Click a field below to highlight its bytes"}),je(g)&&e.jsx("p",{className:"type-micro text-fg-muted font-sans",children:"↑ Selected field above • Other fields below ↓"})]})}].filter(S=>S.condition),F=je(g)?O.find(S=>S.id===g):null,se=je(g)?[...R].sort((S,te)=>S.id==="payload"?-1:te.id==="payload"?1:0):[...R].sort((S,te)=>S.id===g?-1:te.id===g?1:0),J=je(g)?O.filter(S=>S.id!==g):[];return e.jsxs(e.Fragment,{children:[F&&e.jsx(St,{id:`subfield-${F.id}`,title:F.title,color:F.color,startByte:x.payloadStartByte+F.startByte,endByte:x.payloadStartByte+F.endByte,hexBytes:F.hex.toUpperCase(),isSelected:!0,children:F.decoded},F.id),se.map(S=>e.jsx(St,{id:`section-${S.id}`,title:S.title,color:S.color,startByte:S.startByte,endByte:S.endByte,hexBytes:S.hexBytes,isSelected:S.id===g,children:S.content},S.id)),J.map(S=>e.jsxs(de.div,{layout:"position",layoutId:`subfield-${S.id}`,transition:st,className:"w-full min-w-0 overflow-hidden rounded-xl 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(P,{color:S.color,children:S.title}),S.hex.length<=32&&We(S.hex).map((te,W)=>e.jsx(P,{color:S.color,className:"font-mono",children:te.toUpperCase()},W))]}),e.jsxs("span",{className:"type-data-xs text-fg-muted flex-shrink-0",children:["Bytes ",x.payloadStartByte+S.startByte,"-",x.payloadStartByte+S.endByte]})]}),e.jsx("div",{className:"min-w-0 overflow-hidden p-3 rounded-lg bg-black",children:S.decoded})]},S.id))]})})()})})]})}const _t=m.memo(Ea);function Mt(t){if(!t)return[];if(Array.isArray(t))return t;try{const a=JSON.parse(t);return Array.isArray(a)?a:[]}catch{return[]}}function nt(t){return t?(t.startsWith("0x")?t.slice(2):t).slice(0,2).toUpperCase():""}function za(t,a,s){const n=t.toUpperCase();if(s){let r=null,i=0;if(s.forEach((l,c)=>{if(nt(c)===n){const o=l.combinedScore??0;o>i&&(i=o,r=c)}}),r&&a[r])return{hash:r,info:a[r],confidence:i}}for(const[r,i]of Object.entries(a))if(nt(r)===n)return{hash:r,info:i,confidence:void 0};return null}function at({hop:t,compact:a=!1,index:s=0,highlightIndex:n=-1,isTrace:r=!1}){var c;const i=s===n,l=Fn();return m.useEffect(()=>{i&&r&&l.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"}})},[i,r,l]),e.jsxs(de.div,{className:z("flex items-center gap-1.5",a?"flex-row":"flex-col"),animate:{scale:i?1.05:1,opacity:i?1:.85},transition:{duration:.3,ease:"easeInOut"},children:[e.jsxs(de.div,{className:z("flex items-center gap-1.5 px-2.5 py-1 rounded-md","font-mono text-xs font-semibold",t.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:l,initial:{boxShadow:"0 0 0 0px rgba(113, 156, 223, 0)"},children:[t.isLocal&&e.jsx(an,{className:"w-3 h-3"}),e.jsx("span",{children:t.prefix}),t.confidence!==void 0&&t.confidence<.9&&e.jsxs("span",{className:"text-[9px] opacity-70",children:[(t.confidence*100).toFixed(0),"%"]})]}),!a&&((c=t.neighborInfo)==null?void 0:c.name)&&e.jsx("span",{className:"text-xs text-fg-muted truncate max-w-[80px]",children:t.neighborInfo.name})]})}function Fa({snr:t,sf:a}){const s=Cs(t,a),r=ks()[s]||"#6b7280",i=Number.isInteger(t)?t.toString():t.toFixed(1);return e.jsxs(P,{customColor:r,compact:!0,className:"font-mono",children:[t>=0?"+":"",i,"dB"]})}function Ia({hops:t,compact:a,isTrace:s=!1,sf:n}){const[r,i]=m.useState(-1);return m.useEffect(()=>{if(t.length===0)return;const l=setTimeout(()=>{i(0)},400),c=setInterval(()=>{i(o=>{const h=o+1;return h>=t.length?(clearInterval(c),-1):h})},s?500:600);return()=>{clearTimeout(l),clearInterval(c)}},[t.length,s]),e.jsx("div",{className:"p-6",style:{display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:"4px 8px"},children:t.map((l,c)=>{const o=c%2===0,h=c===t.length-1;return e.jsxs("div",{className:"contents",children:[e.jsx("div",{className:z("flex items-center","justify-end"),children:o&&e.jsx(at,{hop:l,compact:a,index:c,highlightIndex:r,isTrace:s})}),e.jsx("div",{className:"flex flex-col items-center justify-center min-h-[28px]",children:!h&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px flex-1 bg-border-strong/40 min-h-[8px]"}),l.snr!==void 0&&e.jsx(Fa,{snr:l.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:z("flex items-center","justify-start"),children:!o&&e.jsx(at,{hop:l,compact:a,index:c,highlightIndex:r,isTrace:s})})]},`${l.prefix}-${c}`)})})}function Aa({packet:t,neighbors:a,localHash:s,neighborAffinity:n,ghostPrefixes:r,direction:i="horizontal",compact:l=!1,traceSnr:c,overridePath:o}){const h=c!==void 0&&c.length>0,d=ws(),g=Mt(t.original_path),u=Mt(t.forwarded_path),y=o??(u.length>0?u:g),x=nt(s),v=m.useMemo(()=>y.map((w,j)=>{const b=w.toUpperCase(),f=b===x,T=(r==null?void 0:r.has(b))??!1,N=za(b,a,n);return{prefix:b,fullHash:N==null?void 0:N.hash,neighborInfo:N==null?void 0:N.info,isLocal:f,isGhost:T,confidence:N==null?void 0:N.confidence,snr:c==null?void 0:c[j]}}),[y,a,n,x,r,c]);if(v.length===0)return e.jsxs("div",{className:"flex items-center gap-2 text-fg-muted text-xs",children:[e.jsx(ge,{className:"w-4 h-4 opacity-50"}),e.jsx("span",{children:"Direct / No path data"})]});if(i==="flowchart")return e.jsx(Ia,{hops:v,compact:l,isTrace:h,sf:d});const p=i==="horizontal"?ue:Kt;return e.jsx("div",{className:z("flex gap-1.5",i==="horizontal"?"flex-row flex-wrap items-center":"flex-col items-start"),children:v.map((w,j)=>e.jsxs("div",{className:z("flex items-center gap-1.5",i==="vertical"&&"flex-col"),children:[e.jsx(at,{hop:w,compact:l}),j"blue",Da=[{fn:"id",group:"identity",fmt:"int",read:t=>ne(t.id),color:V},{fn:"packet_hash",group:"identity",fmt:"hex",read:t=>t.packet_hash||void 0,color:V},{fn:"timestamp",group:"identity",fmt:"epoch",read:t=>t.timestamp?String(t.timestamp):void 0,color:V,annotate:t=>t.timestamp>0?Ze(t.timestamp):void 0},{fn:"type",group:"classification",fmt:"enum",read:t=>ne(t.type??t.payload_type),color:V},{fn:"route",group:"classification",fmt:"enum",read:t=>ne(t.route??t.route_type),color:V},{fn:"rssi",group:"signal",fmt:"int",read:t=>ne(t.rssi,"dBm"),color:V},{fn:"snr",group:"signal",fmt:"float",read:t=>ne(t.snr,"dB"),color:V},{fn:"path_length",group:"size",fmt:"int",read:t=>{if(t.path_length!=null)return t.path_length===0?"zero-hop":`${t.path_length} hops`},color:V},{fn:"payload_length",group:"size",fmt:"int",read:t=>ne(t.payload_length,"B"),color:V},{fn:"airtime",group:"size",fmt:"float",read:t=>ne(t.airtime_ms,"ms"),color:V},{fn:"src_hash",group:"addressing",fmt:"hex<2>",read:t=>t.src_hash??void 0,color:V},{fn:"dst_hash",group:"addressing",fmt:"hex<2>",read:t=>t.dst_hash??void 0,color:V},{fn:"path_hash",group:"addressing",fmt:"hex[]|hex",read:t=>Array.isArray(t.path_hash)?`[${t.path_hash.join(", ")}]`:ne(t.path_hash),color:V,renderValue:t=>Array.isArray(t.path_hash)?Ye(t.path_hash):null},{fn:"score",group:"addressing",fmt:"int",read:t=>ne(t.score),color:V},{fn:"original_path",group:"paths",fmt:"hex[]",read:t=>Array.isArray(t.original_path)?`[${t.original_path.join(", ")}]`:void 0,color:V,renderValue:t=>Array.isArray(t.original_path)&&t.original_path.length>0?Ye(t.original_path,t.src_hash||void 0,t.dst_hash||void 0,!0):null},{fn:"forwarded_path",group:"paths",fmt:"hex[]",read:t=>Array.isArray(t.forwarded_path)?`[${t.forwarded_path.join(", ")}]`:void 0,color:V,renderValue:t=>Array.isArray(t.forwarded_path)&&t.forwarded_path.length>0?Ye(t.forwarded_path):null},{fn:"transmitted",group:"status",fmt:"bool",read:t=>ne(t.transmitted),color:V},{fn:"is_duplicate",group:"status",fmt:"bool",read:t=>ne(t.is_duplicate),color:V},{fn:"drop_reason",group:"status",fmt:"string|null",read:t=>t.drop_reason??void 0,color:V},{fn:"tx_delay",group:"status",fmt:"int",read:t=>ne(t.tx_delay_ms,"ms"),color:V},{fn:"origin",group:"status",fmt:"enum",read:t=>t.packet_origin??void 0,color:V},{fn:"duplicates",group:"status",fmt:"PacketDuplicate[]",read:t=>t.duplicates!=null&&t.duplicates.length>0?`${t.duplicates.length}`:ne(t.duplicates),color:V},{fn:"lbt_attempts",group:"lbt",fmt:"int",read:t=>ne(t.lbt_attempts),color:V},{fn:"lbt_backoff",group:"lbt",fmt:"json",read:t=>ne(t.lbt_backoff_delays_ms),color:V},{fn:"lbt_busy",group:"lbt",fmt:"bool|int",read:t=>ne(t.lbt_channel_busy),color:V}];function Ye(t,a,s,n){const r=t.length>0,i=a||n,l=s||n;return e.jsxs("span",{className:"inline-flex items-center gap-1 flex-wrap",children:[i&&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"}),(r||l)&&e.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"})]}),t.map((c,o)=>e.jsxs(m.Fragment,{children:[o>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})]},o)),l&&e.jsxs(e.Fragment,{children:[r&&e.jsx("span",{className:"text-fg-muted/40 text-[10px]",children:"→"}),s?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:s}):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 Fe=null;function Ha(){if(!Fe){Fe=new Map;for(const t of Da)Fe.set(t.fn,t)}return Fe}function Tt(t,a){var l;const s=Ha().get(a);if(!s)return null;const n=s.read(t);if(n===void 0)return null;const r=s.color(t),i=(l=s.annotate)==null?void 0:l.call(s,t);return i?{text:n,color:r,annotation:i}:{text:n,color:r}}function Pt(t){if(!t)return[];if(Array.isArray(t))return t;try{const a=JSON.parse(t);return Array.isArray(a)?a:[]}catch{return[]}}function Bt({packets:t,selectedIndex:a,onSelect:s,compact:n=!1}){if(t.length<=1)return null;const r=a>0,i=ar&&s(a-1),disabled:!r,className:z("p-0.5 radius-badge transition-base",r?"text-fg-muted hover:text-fg-primary hover-bg":"text-fg-muted cursor-not-allowed"),"aria-label":"Previous observation",children:e.jsx(Xt,{className:n?"size-3":"size-4"})}),e.jsx("div",{className:"flex items-center gap-0.5",children:t.map((l,c)=>{const o=c===a,d=new Date(l.timestamp*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"});return e.jsx(Ls,{color:o?"cyan":"zinc",filled:o,compact:n,onClick:()=>s(c),title:`Observation ${c+1} at ${d}`,className:z("transition-all duration-150",!o&&"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,l.rssi!=null&&e.jsx("span",{className:"ml-1 opacity-70",children:l.rssi})]})},`${l.timestamp}_${c}`)})}),e.jsx("button",{onClick:()=>i&&s(a+1),disabled:!i,className:z("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":"Next observation",children:e.jsx(ct,{className:n?"size-3":"size-4"})}),e.jsxs("span",{className:z("text-fg-muted ml-1",n?"text-[9px]":"text-xs"),children:[e.jsx(it,{className:"inline size-3 mr-0.5 opacity-50"}),t.length]})]})}function Ie({icon:t,label:a,disabled:s=!1}){return e.jsx(de.div,{className:"flex items-center gap-1 text-xs",title:a,animate:{opacity:s?.25:.6},transition:{duration:.15,ease:[.4,0,.2,1]},children:e.jsx("span",{className:z("flex items-center justify-center size-5 radius-badge border-control transition-base",s?"bg-subtle-fill border-edge-subtle":"bg-subtle-fill"),children:t})})}function Oa({hasDuplicates:t,hasPrev:a,hasNext:s,canPrevDupe:n,canNextDupe:r}){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(Ie,{icon:e.jsx(bn,{className:"size-3"}),label:"Previous packet (↑)",disabled:!a}),e.jsx(Ie,{icon:e.jsx(Rs,{className:"size-3"}),label:"Next packet (↓)",disabled:!s})]}),t&&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(Ie,{icon:e.jsx(Xt,{className:"size-3"}),label:"Previous observation (←)",disabled:!n}),e.jsx(Ie,{icon:e.jsx(ct,{className:"size-3"}),label:"Next observation (→)",disabled:!r})]})]})]})}function $a({packets:t,initialIndex:a=0,onClose:s,onNavigatePrev:n,onNavigateNext:r,hasPrev:i=!1,hasNext:l=!1,resolveSource:c}){var ve;const[o,h]=m.useState(a),d=t[o]??t[0],g=t.length>1,[u,y]=m.useState(null),[x,v]=m.useState(!1);m.useEffect(()=>{if(!d._stripped){y(null);return}let K=!1;v(!0);const Y=d.packet_hash;if(!Y){v(!1);return}return Ss(Y).then(re=>{K||(re.success&&re.data&&(y(re.data),(re.data.type??re.data.payload_type)===oe.GRP_TXT&&re.data.raw_packet&&_s.getState().queueDecryption([re.data])),v(!1))}).catch(()=>{K||v(!1)}),()=>{K=!0}},[d]);const p=u??d,w=o>0,j=o{h(Math.max(0,Math.min(K,t.length-1)))},[t.length]);m.useEffect(()=>{const K=Y=>{if(!(Y.target instanceof HTMLInputElement||Y.target instanceof HTMLTextAreaElement))switch(Y.key){case"ArrowUp":Y.preventDefault(),n==null||n();break;case"ArrowDown":Y.preventDefault(),r==null||r();break;case"ArrowLeft":Y.preventDefault(),w&&h(re=>re-1);break;case"ArrowRight":Y.preventDefault(),j&&h(re=>re+1);break}};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[n,r,w,j]);const f=Ot(),T=Ms(),N=Ts(),D=Ps(),O=m.useMemo(()=>new Set(D.map(K=>K.prefix.toUpperCase())),[D]),U=p.payload_type_name||Dt(p.payload_type??p.type),X=p.route_type_name||Ht(p.route_type??p.route),H=p.payload_length??p.length??0,Z=Pt(p.original_path),A=Pt(p.forwarded_path),R=Z.length>0||A.length>0,F=A.length>0?A:Z,se=m.useMemo(()=>{var K;if((K=f==null?void 0:f.config)!=null&&K.repeater)return{latitude:f.config.repeater.latitude,longitude:f.config.repeater.longitude,name:f.config.node_name||"Local Node"}},[f]),J=(f==null?void 0:f.neighbors)??{},C=N.size>0?N:void 0,Q=p.raw_packet&&p.raw_packet.length>0,ae=d._stripped&&x,B=m.useMemo(()=>c?c(p):null,[c,p]),S=Bs(p.packet_hash),te=m.useMemo(()=>{if((p.payload_type??p.type)!==oe.GRP_TXT||!(S!=null&&S.decoded))return null;const Y=S.decoded;return{type:"grp_txt",channelHash:Y.channelHash,channelName:Y.channelName,text:Y.text??"",decrypted:Y.decrypted,senderName:Y.senderName,timestamp:Y.timestamp,flags:Y.flags,macCorrupted:Y.macCorrupted}},[p,S]),W=m.useMemo(()=>Fs(p,te),[p,te]),q=W.kind==="trace"?W.data:null,L=W.kind==="trace"?W.snrValues:void 0,M=W.kind==="advert"?W.data:null,le=W.kind==="advert"?W.sourceNode:void 0,$=W.kind==="grp_txt"?W.wardriveSourceNode??void 0:void 0,ce=K=>!K||K===0?"Unknown":new Date(K*1e3).toLocaleString(),Pe=(p.payload_type??p.type)===oe.ADVERT&&(le!==void 0||R),Be=$!==void 0,Ne=le??$,Le=Te[U]??"zinc",Ge=me[Le]||me.zinc;return e.jsxs($t,{open:!0,onClose:s,size:"5xl",motionPlus:!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(P,{color:Te[U]??"zinc",className:"!text-[9px] !px-1.5 !py-0",children:U}),e.jsx(P,{color:Ae[X]??"zinc",className:"!text-[9px] !px-1.5 !py-0",children:X}),e.jsxs(P,{color:"zinc",className:"!text-[9px] !px-1.5 !py-0",children:[H,"B"]})]}),e.jsx("button",{onClick:s,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"})]}),g&&e.jsx("div",{className:"px-3 pb-2",children:e.jsx(Bt,{packets:t,selectedIndex:o,onSelect:b,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(P,{color:Te[U]??"zinc",children:U}),e.jsx(P,{color:Ae[X]??"zinc",children:X}),e.jsxs(P,{color:"zinc",children:[H,"B"]}),g&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-4 bg-subtle-fill-strong"}),e.jsx(Bt,{packets:t,selectedIndex:o,onSelect:b})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Oa,{hasDuplicates:g,hasPrev:i,hasNext:l,canPrevDupe:w,canNextDupe:j}),e.jsx("button",{onClick:s,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:Ge,opacity:.6}}),e.jsxs(Ut,{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:"p-2 space-y-2",children:[(p.rssi!=null||p.snr!=null)&&e.jsxs("div",{className:"relative flex items-center justify-between px-2 py-1.5 radius-inner bg-subtle-fill",children:[e.jsx(qe,{mode:"popLayout",initial:!1,children:e.jsxs(de.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(De,{rssi:p.rssi,snr:p.snr,compact:!0,showValues:!0,validated:He(p)}),e.jsx("span",{className:"text-[11px] text-fg-muted",children:ft(p.rssi)})]},o)}),F.length>0&&e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[F.length," hop",F.length!==1?"s":""]})]}),(R&&F.length>0||Pe||Be)&&e.jsx("div",{className:"overflow-hidden radius-inset",children:e.jsx("div",{className:"aspect-[4/3] w-full",children:e.jsx(Ve,{path:F,neighbors:J,localNode:se,localHash:f==null?void 0:f.local_hash,srcHash:p.src_hash,dstHash:p.dst_hash,neighborAffinity:C,hubNodes:[...T],traceSnr:L,advertiserSource:Ne})})}),q&&q.pathHashes.length>0&&e.jsxs("div",{className:"radius-inset bg-black overflow-hidden",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(P,{color:q.isComplete?"green":"amber",compact:!0,children:q.isComplete?"Complete":"In Progress"})})]})}),e.jsx(Ce,{packet:p,neighbors:J,localHash:f==null?void 0:f.local_hash,neighborAffinity:C,ghostPrefixes:O,direction:"flowchart",compact:!0,overridePath:q.pathHashes,traceSnr:q.snrValues})]}),R&&!q&&e.jsxs("div",{className:"radius-inset bg-black overflow-hidden",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(P,{color:"zinc",compact:!0,children:[F.length," hop",F.length!==1?"s":""]})]}),e.jsx(Ce,{packet:p,neighbors:J,localHash:f==null?void 0:f.local_hash,neighborAffinity:C,ghostPrefixes:O,direction:"flowchart",compact:!0,traceSnr:L})]}),B&&(B.name||B.hash)&&!M&&e.jsxs("div",{className:"radius-inset bg-subtle-fill 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:"type-micro text-fg-muted",children:"Source"}),e.jsx(P,{color:B.isRepeater?"blue":B.isCompanion?"violet":B.type==="room_server"?"lime":"zinc",compact:!0,children:B.type==="room_server"?"room server":B.type})]}),e.jsxs("div",{className:"p-3 space-y-1.5",children:[B.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:B.name}),!B.confident&&e.jsx("span",{className:"text-[9px] text-fg-muted/60 italic",children:"ambiguous"})]}),B.hash&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ee,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"type-data-xs text-fg-muted truncate font-mono",children:[B.hash.startsWith("0x")?B.hash.slice(2,10):B.hash.slice(0,8),"…"]})]})]})]}),M&&e.jsxs("div",{className:"radius-inset bg-subtle-fill 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:"type-micro text-fg-muted",children:"Advertiser Info"}),e.jsx(P,{color:"lime",compact:!0,children:M.nodeType})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[M.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:M.name})]}),M.latitude&&M.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:[M.latitude.toFixed(5),", ",M.longitude.toFixed(5)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ee,{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:[M.publicKey.slice(0,16),"...",M.publicKey.slice(-8)]})]}),M.timestamp>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ye,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-xs text-fg-muted",children:ce(M.timestamp)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ge,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-xs text-fg-muted",children:M.flagsDescription||`Flags: 0x${M.flags.toString(16).padStart(2,"0")}`})]})]})]}),ae?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…"})}):Q?e.jsx("div",{className:"pt-1",children:e.jsx(_t,{packet:p,decodedGrpTxt:te})}):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 p-4 border-r border-edge-subtle",children:ae?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…"})}):Q?e.jsx(_t,{packet:p,decodedGrpTxt:te}):null}),e.jsxs("div",{className:"grid overflow-hidden",style:{gridTemplateRows:"minmax(280px, 1fr) auto"},children:[e.jsx("div",{className:"overflow-hidden p-2",children:R&&F.length>0||Pe||Be?e.jsx("div",{className:"h-full w-full",children:e.jsx(Ve,{path:F,neighbors:J,localNode:se,localHash:f==null?void 0:f.local_hash,srcHash:p.src_hash,dstHash:p.dst_hash,neighborAffinity:C,hubNodes:[...T],traceSnr:L,advertiserSource:Ne})}):e.jsxs("div",{className:"h-full w-full flex flex-col items-center justify-center text-center px-4",children:[e.jsx(ge,{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:[!q&&F.length<=1&&(p.rssi!=null||p.snr!=null)&&e.jsx("div",{className:"surface-base radius-inset p-4",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(qe,{mode:"popLayout",initial:!1,children:e.jsxs(de.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(De,{rssi:p.rssi,snr:p.snr,validated:He(p)}),e.jsx("span",{className:"font-medium text-fg-primary",children:ft(p.rssi)})]},o)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-fg-muted mb-1",children:"RF"}),e.jsx(qe,{mode:"popLayout",initial:!1,children:e.jsxs(de.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:[(ve=Tt(p,"rssi"))==null?void 0:ve.text,(()=>{const K=Tt(p,"snr");return K?` · ${K.text}`:null})()]},o)})]})]})}),B&&(B.name||B.hash)&&!M&&e.jsxs("div",{className:"radius-inset bg-subtle-fill overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-edge-subtle",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Source"}),e.jsx(P,{color:B.isRepeater?"blue":B.isCompanion?"violet":B.type==="room_server"?"lime":"zinc",compact:!0,children:B.type==="room_server"?"room server":B.type})]}),e.jsxs("div",{className:"p-4 space-y-2",children:[B.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:B.name}),!B.confident&&e.jsx("span",{className:"text-[10px] text-fg-muted/60 italic",children:"ambiguous"})]}),B.hash&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ee,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-[11px] font-mono text-fg-muted truncate",children:[B.hash.startsWith("0x")?B.hash.slice(2,10):B.hash.slice(0,8),"…"]})]})]})]}),M&&e.jsxs("div",{className:"radius-inset bg-subtle-fill overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-edge-subtle",children:[e.jsx("span",{className:"type-micro text-fg-muted",children:"Advertiser"}),e.jsx(P,{color:"lime",compact:!0,children:M.nodeType})]}),e.jsxs("div",{className:"p-4 space-y-2.5",children:[M.name&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-label text-fg-primary truncate",children:M.name})]}),M.latitude&&M.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:[M.latitude.toFixed(5),", ",M.longitude.toFixed(5)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ee,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsxs("span",{className:"text-[11px] font-mono text-fg-muted truncate",children:[M.publicKey.slice(0,16),"...",M.publicKey.slice(-8)]})]}),M.timestamp>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ye,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-xs text-fg-muted",children:ce(M.timestamp)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ge,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-[11px] text-fg-muted",children:M.flagsDescription||`Flags: 0x${M.flags.toString(16).padStart(2,"0")}`})]})]})]}),q&&q.pathHashes.length>0&&e.jsxs("div",{className:"radius-inset bg-black overflow-hidden",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(P,{color:q.isComplete?"green":"amber",compact:!0,children:q.isComplete?"Complete":"In Progress"}),e.jsxs(P,{color:"teal",compact:!0,children:[q.pathHashes.length,"h"]})]})]}),e.jsx(Ce,{packet:p,neighbors:J,localHash:f==null?void 0:f.local_hash,neighborAffinity:C,ghostPrefixes:O,direction:"flowchart",compact:!0,overridePath:q.pathHashes,traceSnr:q.snrValues})]}),R&&!q&&e.jsxs("div",{className:"radius-inset bg-black overflow-hidden",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(P,{color:"zinc",compact:!0,children:[F.length,"h"]})]}),e.jsx(Ce,{packet:p,neighbors:J,localHash:f==null?void 0:f.local_hash,neighborAffinity:C,ghostPrefixes:O,direction:"flowchart",compact:!0,traceSnr:L})]})]})]})]})]})]})}const Ua=m.memo($a);function Lt({label:t,numericValue:a,unit:s,icon:n,subtext:r,showSign:i=!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:t})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(et,{value:a,format:{minimumFractionDigits:1,maximumFractionDigits:1,signDisplay:i?"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"}),s&&e.jsx("span",{className:"text-xs font-medium leading-tight text-fg-muted",children:s})]})]}),r&&e.jsx("p",{className:"mt-1.5 sm:mt-2 type-data-xs sm:text-[11px] text-fg-muted/80 truncate",children:r})]})}function Va({snr:t}){const a=t>=5?"bg-sys-teal":t>=0?"bg-sys-green":t>=-5?"bg-sys-amber":t>=-10?"bg-sys-orange":"bg-sys-red";return e.jsx("span",{className:z("w-1.5 h-1.5 rounded-full flex-shrink-0",a),title:`SNR: ${t.toFixed(1)} dB`})}function Rt({fromPrefix:t,toPrefix:a,fromName:s,toName:n,snr:r,maxSnr:i,isWeakest:l,isStrongest:c,index:o=0}){const d=Math.max(i+5,15),g=Math.max(0,Math.min(100,(r- -20)/(d- -20)*100)),u="bg-[#0074BE]",y=r>=5?"bg-sys-teal":r>=0?"bg-sys-green":r>=-5?"bg-sys-amber":r>=-10?"bg-sys-orange":"bg-sys-red",x=.3+o*.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:z("absolute left-0 top-1/2 -translate-y-1/2 h-4 w-0.5 rounded-full",y)}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5",children:e.jsx(Va,{snr:r})}),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:s||t}),e.jsx(ue,{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:[l&&e.jsx(P,{color:"red",compact:!0,children:"Low"}),c&&!l&&e.jsxs(P,{color:"amber",compact:!0,children:[e.jsx(kt,{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:[r>=0?"+":"−",Math.abs(r).toFixed(1)]})]})]}),e.jsx("div",{className:"h-1.5 bg-subtle-fill-strong rounded-full overflow-hidden",children:e.jsx(de.div,{className:z("h-full rounded-full",u),initial:{width:0},animate:{width:`${g}%`},transition:{duration:1.5,delay:x,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:t}),s&&e.jsx("span",{className:"text-xs text-fg-secondary truncate max-w-[100px]",children:s})]}),e.jsx(ue,{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:[l&&e.jsx(P,{color:"red",compact:!0,children:"Bottleneck"}),c&&!l&&e.jsxs(P,{color:"amber",compact:!0,children:[e.jsx(kt,{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:[r>=0?"+":"−",Math.abs(r).toFixed(1)]})]})]}),e.jsx("div",{className:"h-1.5 bg-elevated rounded-full overflow-hidden",children:e.jsx(de.div,{className:z("h-full rounded-full",u),initial:{width:0},animate:{width:`${g}%`},transition:{duration:1.5,delay:x,ease:[.25,.1,.25,1]}})})]})]})}function fe(t,a){if(t==="You")return"You";const s=t.toUpperCase();for(const[n,r]of Object.entries(a))if((n.startsWith("0x")?n.slice(2,4):n.slice(0,2)).toUpperCase()===s)return r.name||r.node_name||void 0}function Wa({report:t,onClose:a}){var h,d;const s=Ot(),n=(s==null?void 0:s.neighbors)??{},r=(h=s==null?void 0:s.config)!=null&&h.repeater?{latitude:s.config.repeater.latitude,longitude:s.config.repeater.longitude,name:s.config.node_name||"Local Node"}:void 0,i=(d=t.bestObservation)==null?void 0:d.decoded.snrValues,l=t.linkQuality?t.linkQuality.avgSnr>=5?"excellent":t.linkQuality.avgSnr>=0?"good":t.linkQuality.avgSnr>=-5?"fair":"poor":"unknown",o={excellent:"var(--signal-excellent)",good:"var(--signal-good)",fair:"var(--signal-fair)",poor:"var(--signal-poor)",unknown:"var(--fg-muted)"}[l];return e.jsxs($t,{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:o,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(P,{color:l==="excellent"||l==="good"?"green":l==="fair"?"amber":"red",children:[e.jsx(wt,{className:"w-3 h-3 mr-1"}),l==="excellent"?"Excellent":l==="good"?"Good":l==="fair"?"Fair":"Poor"]})]}),e.jsx("p",{className:"mt-1 text-xs sm:text-sm font-mono text-fg-muted tabular-nums",children:t.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(P,{color:"teal",children:[e.jsx("span",{className:"font-mono tabular-nums",children:t.targetHopCount}),e.jsxs("span",{className:"ml-1",children:["hop",t.targetHopCount!==1?"s":""]})]}),e.jsxs(P,{color:"zinc",children:[e.jsx("span",{className:"font-mono tabular-nums",children:t.observationCount}),e.jsx("span",{className:"ml-1",children:"obs"})]}),t.linkQuality&&e.jsxs(P,{color:"indigo",children:[e.jsx("span",{className:"font-mono tabular-nums",children:t.linkQuality.avgSnr.toFixed(1)}),e.jsx("span",{className:"ml-1",children:"dB avg"})]}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:Es(t.duration)}),t.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:t.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:t.linkQuality.maxSnr.toFixed(1)})]})]})]})]}),e.jsxs(Ut,{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:[t.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(et,{value:Math.abs(t.linkQuality.minSnr),format:{maximumFractionDigits:0,signDisplay:"never"},prefix:t.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(Je,{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(et,{value:t.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(gt,{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(P,{color:l==="excellent"||l==="good"?"green":l==="fair"?"amber":"red",compact:!0,children:[e.jsx(wt,{className:"w-2.5 h-2.5 mr-0.5"}),l==="excellent"?"Excellent":l==="good"?"Good":l==="fair"?"Fair":"Poor"]}),e.jsxs(P,{color:"teal",compact:!0,children:[t.targetHopCount," hops"]}),e.jsxs(P,{color:"zinc",compact:!0,children:[t.observationCount," obs"]}),e.jsx("span",{className:"type-data-xs text-fg-muted ml-auto",children:t.traceTag.slice(0,8)})]}),t.targetPath.length>0&&e.jsx("div",{className:"overflow-hidden radius-inset",children:e.jsx("div",{className:"aspect-[4/3] w-full",children:e.jsx(Ve,{path:t.targetPath,neighbors:n,localNode:r,localHash:s==null?void 0:s.local_hash,srcHash:t.srcHash,dstHash:t.dstHash,traceSnr:i})})}),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"}),t.linkQuality&&e.jsxs("span",{className:"type-data-xs text-fg-muted",children:["SNR ",t.linkQuality.minSnr.toFixed(1)," → ",t.linkQuality.maxSnr.toFixed(1)," dB"]})]}),t.bestObservation?e.jsx(Ce,{packet:t.bestObservation.packet,neighbors:n,localHash:s==null?void 0:s.local_hash,direction:"flowchart",compact:!0,overridePath:t.targetPath,traceSnr:t.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 · ",t.hopStats.length," hops"]}),e.jsx("div",{className:"space-y-1.5",children:t.hopStats.length>0?t.hopStats.map((g,u)=>{var p,w,j;const y=u{const g=t.targetPath[t.linkQuality.weakestLinkPosition],u=t.targetPath[t.linkQuality.weakestLinkPosition+1]||"You",y=fe(g,n),x=fe(u,n),v=t.targetPath[t.linkQuality.strongestLinkPosition],p=t.targetPath[t.linkQuality.strongestLinkPosition+1]||"You",w=fe(v,n),j=fe(p,n);return e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Lt,{label:"Weakest Link",numericValue:t.linkQuality.minSnr,unit:"dB",icon:Je,subtext:`${y||g} → ${x||u}`}),e.jsx(Lt,{label:"Best Link",numericValue:t.linkQuality.maxSnr,showSign:!0,unit:"dB",icon:gt,subtext:`${w||v} → ${j||p}`})]})})(),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:t.hopStats.length>0?t.hopStats.map((g,u)=>{var p,w,j;const y=u0&&e.jsx("div",{className:"overflow-hidden",children:e.jsx("div",{className:"aspect-square w-full",children:e.jsx(Ve,{path:t.targetPath,neighbors:n,localNode:r,localHash:s==null?void 0:s.local_hash,srcHash:t.srcHash,dstHash:t.dstHash,traceSnr:i})})}),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(P,{color:t.isComplete?"green":"amber",compact:!0,children:t.isComplete?"Complete":`${t.maxHopsObserved}/${t.targetHopCount}`}),e.jsxs(P,{color:"teal",compact:!0,children:[t.targetHopCount," hop",t.targetHopCount!==1?"s":""]})]})]}),t.linkQuality&&t.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:t.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:[t.linkQuality.minSnr.toFixed(1),"–",t.linkQuality.maxSnr.toFixed(1)]}),e.jsx("span",{className:"opacity-60",children:" dB"})]})]}),t.bestObservation?e.jsx(Ce,{packet:t.bestObservation.packet,neighbors:n,localHash:s==null?void 0:s.local_hash,direction:"flowchart",compact:!0,overridePath:t.targetPath,traceSnr:t.bestObservation.decoded.snrValues}):e.jsx("div",{className:"p-8 text-center text-fg-muted text-xs",children:"No path data available"})]})]})]})]})]})}const Ga=m.memo(Wa),rs=[{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:Os},{target:"PacketList",fn:"src_hash",minStage:1,when:$s},{target:"PacketList",fn:"text",minStage:1,when:Us},{target:"PacketList",fn:"ack",minStage:1,when:Vs},{target:"PacketList",fn:"decrypt",minStage:2,when:Ws},{target:"PacketList",fn:"duplicates",minStage:1}];Hs(rs);const Qa=48,qa=72,Ka=100,Ya=5,Xa=600,is="(min-width: 640px)";let he=null;function Za(t){return typeof window>"u"?()=>{}:(he||(he=window.matchMedia(is)),he.addEventListener("change",t),()=>he==null?void 0:he.removeEventListener("change",t))}function Ja(){return typeof window>"u"?!0:(he||(he=window.matchMedia(is)),he.matches)}function er(){return m.useSyncExternalStore(Za,Ja,()=>!0)}function tr(t,a,s){const[n,r]=m.useState(1),i=s?Math.ceil(t/a):1;m.useEffect(()=>{n>i&&i>0&&queueMicrotask(()=>r(1))},[i,n]);const l=m.useCallback(o=>r(Math.max(1,Math.min(o,i))),[i]),c=m.useMemo(()=>Un(n,i),[n,i]);return{currentPage:n,totalPages:i,goToPage:l,pageRange:c}}function sr(t,a){const[s,n]=m.useState(null),r=m.useRef(0);return m.useEffect(()=>{var d,g;if(!a||!t.length)return;const i=((d=t[0])==null?void 0:d.timestamp)??0,l=i>r.current&&r.current>0;if(r.current=i,!l)return;const c=(g=t[0])==null?void 0:g.packet_hash;if(!c)return;const o=requestAnimationFrame(()=>n(c)),h=setTimeout(()=>n(null),600);return()=>{cancelAnimationFrame(o),clearTimeout(h)}},[t,a]),s}function nr(t){if(!t||t.length<6)return null;const a=t,s=parseInt(a.slice(0,2),16);if(isNaN(s))return null;const n=s&3;let r=2;if((n===0||n===3)&&(r=10),r+2>a.length)return null;const i=parseInt(a.slice(r,r+2),16);if(isNaN(i)||(r+=2+i*2,r>=a.length))return null;const l=a.slice(r);return l.length>=38?l.slice(0,38):l}function ar(t){if(t.length<=1)return t;const a=new Map,s=new Map,n=new Map;for(let l=0;l0?{packet:t[l].packet,dupeCount:t[l].dupeCount+c}:t[l])}return i}function rr(t){const a=new Map;for(const s of t)if((s.payload_type??s.type)===lt.TRACE&&s.packet_hash){const r=s._traceTag??(s.payload?Vt(s.payload):null);r&&a.set(s.packet_hash,r)}return a}function ir(t){if(t.length===0)return[];const a=[];let s=0;for(;sk.setModalMapOpen);m.useEffect(()=>(U(!!j),()=>U(!1)),[j,U]),m.useLayoutEffect(()=>{D({traceTag:null,dupeGroup:null})},[t]);const X=a??t,H=m.useMemo(()=>i&&i>0&&!y?t.slice(0,i):t,[t,i,y]),Z=m.useMemo(()=>{if(!y)return null;const k=ir(H),_=ar(k);return i&&i>0?_.slice(0,i):_},[H,y,i]),A=Z?Z.length:H.length,{currentPage:R,totalPages:F,goToPage:se,pageRange:J}=tr(A,l,c),C=m.useMemo(()=>{if(y||!c)return H;const k=(R-1)*l;return H.slice(k,k+l)},[H,c,R,l,y]),Q=m.useMemo(()=>{if(!Z)return null;if(!c)return Z;const k=(R-1)*l;return Z.slice(k,k+l)},[Z,c,R,l]),ae=m.useMemo(()=>rr(C),[C]),B=m.useMemo(()=>lr(C),[C]),S=sr(t,h),te=er(),W=m.useMemo(()=>y&&Q?Q:C,[y,Q,C]),q=w&&W.length>Ka,L=te?Qa:qa,M=yn({count:q?W.length:0,getScrollElement:()=>O.current,estimateSize:()=>L,overscan:Ya}),le=m.useCallback((k,_)=>{var we,Re;const E=k.packet_hash;if(!E)return[k];let I=_;for(;I>0&&((we=C[I-1])==null?void 0:we.packet_hash)===E;)I--;let G=_;for(;G{var I,G;const _=(I=C[k])==null?void 0:I.packet_hash;if(!_)return k;let E=k;for(;E>0&&((G=C[E-1])==null?void 0:G.packet_hash)===_;)E--;return E},[C]),ce=m.useCallback(k=>{var I,G;const _=(I=C[k])==null?void 0:I.packet_hash;if(!_)return k;let E=k;for(;E{if(o){o(k);return}if(_!==void 0){const E=le(k,_),I=E.indexOf(k);b({packets:E,initialIndex:I>=0?I:0,rowIndex:_})}else b({packets:[k],initialIndex:0,rowIndex:0})},[o,le]),dt=m.useCallback(()=>{if(!j)return;const _=$(j.rowIndex)-1;if(_<0)return;const E=C[_];if(!E)return;const I=le(E,_);b({packets:I,initialIndex:0,rowIndex:_})},[j,C,$,le]),Pe=m.useCallback(()=>{if(!j)return;const _=ce(j.rowIndex)+1;if(_>=C.length)return;const E=C[_];if(!E)return;const I=le(E,_);b({packets:I,initialIndex:0,rowIndex:_})},[j,C,ce,le]),xt=m.useMemo(()=>j?$(j.rowIndex)>0:!1,[j,$]),Be=m.useMemo(()=>j?ce(j.rowIndex)D(_=>({..._,traceTag:k})),[]),Le=m.useCallback(k=>D(_=>({..._,dupeGroup:k})),[]),Ge=m.useCallback(()=>{D({traceTag:null,dupeGroup:null})},[]),ve=m.useCallback(k=>{const _=X.filter(G=>(G.payload_type??G.type)===lt.TRACE&&G.payload&&Vt(G.payload)===k);if(_.length===0)return;const I=Is(_).get(k);I!=null&&I.length&&T(As(k,I))},[X]),K=m.useCallback(k=>{const _=X.find(E=>E.packet_hash===k);_&&(T(null),be(_))},[X,be]),Y=m.useCallback((k,_,E)=>{const I=te?Xn:Zn;if(E){const{packet:pe,dupeCount:cs}=k,ut=pe.packet_hash?ae.get(pe.packet_hash):void 0,os=N.traceTag!==null&&ut===N.traceTag;return e.jsx(I,{packet:pe,onClick:ds=>be(ds,_),localHash:s,neighbors:n,resolveSource:p,isFlashing:h&&S===pe.packet_hash,traceTag:ut,isTraceHighlighted:os,onTraceHover:Ne,onViewTraceReport:ve,dupeCount:cs,getDecodedContent:x,onChannelClick:v},`${pe.packet_hash}_${pe.timestamp}_${_}`)}const G=k,we=G.packet_hash?ae.get(G.packet_hash):void 0,Re=N.traceTag!==null&&we===N.traceTag,mt=B.get(_),ls=mt!==void 0&&N.dupeGroup!==null&&G.packet_hash===N.dupeGroup;return e.jsx(I,{packet:G,onClick:pe=>be(pe,_),localHash:s,neighbors:n,resolveSource:p,isFlashing:h&&S===G.packet_hash,traceTag:we,isTraceHighlighted:Re,onTraceHover:Ne,onViewTraceReport:ve,dupeGroupPosition:mt,isDupeGroupHovered:ls,onDupeGroupHover:Le,getDecodedContent:x,onChannelClick:v},`${G.packet_hash}_${G.timestamp}_${_}`)},[te,ae,N.traceTag,N.dupeGroup,be,s,n,p,h,S,Ne,ve,B,Le,x,v]),re=()=>{if(r&&t.length===0)return e.jsx(zt,{});if(C.length===0)return e.jsx(Et,{message:d});const k=y&&Q!==null;return(k?Q:C).map((E,I)=>Y(E,I,k))},ht=()=>{if(r&&t.length===0)return e.jsx(zt,{});if(W.length===0)return e.jsx(Et,{message:d});const k=y&&Q!==null,_=M.getVirtualItems();return e.jsx("div",{style:{height:`${M.getTotalSize()}px`,width:"100%",position:"relative"},children:_.map(E=>{const I=W[E.index];return e.jsx("div",{"data-index":E.index,ref:M.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${E.start}px)`},children:Y(I,E.index,k)},E.key)})})};return e.jsxs("div",{className:z("flex flex-col",g),onMouseLeave:Ge,children:[q?e.jsx("div",{ref:O,className:"divide-y divide-edge-subtle overflow-auto",style:{maxHeight:Xa},children:ht()}):e.jsx("div",{className:"divide-y divide-edge-subtle py-1",children:re()}),c&&F>1&&e.jsx("nav",{className:"border-t border-edge-subtle px-4 py-3",children:e.jsxs(In,{className:"justify-center",children:[e.jsx(An,{onClick:()=>se(R-1),disabled:R===1}),e.jsx(Hn,{children:J.map((k,_)=>k==="gap"?e.jsx($n,{},`gap-${_}`):e.jsx(On,{page:k,current:k===R,onClick:se},k))}),e.jsx(Dn,{onClick:()=>se(R+1),disabled:R===F})]})}),e.jsx(cr,{showPagination:c,currentPage:R,perPage:l,displayCount:Q?Q.length:C.length,totalCount:c?A:t.length,action:u}),!o&&j&&e.jsx(Ua,{packets:j.packets,initialIndex:j.initialIndex,onClose:()=>b(null),onNavigatePrev:dt,onNavigateNext:Pe,hasPrev:xt,hasNext:Be,resolveSource:p}),f&&e.jsx(Ga,{report:f,onClose:()=>T(null),onViewPacket:K})]})}export{ss as C,Rr as P,wt as S,kt as T,Br as a,yn as b,Gn as g,Lr as u}; diff --git a/frontend/dist/assets/PacketObservatory-CaTxuw1q.js b/frontend/dist/assets/PacketObservatory-CaTxuw1q.js new file mode 100644 index 00000000..109ea70c --- /dev/null +++ b/frontend/dist/assets/PacketObservatory-CaTxuw1q.js @@ -0,0 +1,5 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/usePipelineStore-11oXtutw.js","assets/index-BwGHI0A_.js","assets/node-types-DmTOZWT4.js","assets/index-DUfCykEc.css"])))=>i.map(i=>d[i]); +import{bK as O,r as T,e4 as Fe,e5 as Ee,e6 as Oe,e7 as ze,bl as Be,e8 as Ie,e9 as Ge,ea as Ke,eb as Ve,bk as Ne,bo as ue,ec as qe,ed as we,bq as pe,j as e,ee as G,ef as K,eg as V,dE as xe,eh as Ue,q as M,bw as We,bH as Ce,bQ as Ye,ei as Ze,ej as Xe,ek as Qe,el as Je,em as et,en as J,eo as tt,ep as st,eq as nt,er as he,a3 as me,$ as Se,bh as rt,es as at,y as lt,E as ot,et as ct,b9 as it,c_ as dt}from"./index-BwGHI0A_.js";import{usePipelineStore as Y}from"./usePipelineStore-11oXtutw.js";import{e as Te,p as ut,a as pt,A as I,S as q,c as se,f as E,K as i,H as A,B as xt,R as F,T as d,P as re,h as ht,i as S,C as _e,s as ee,j as mt}from"./primitives-Cgn8YJud.js";import{m as ke,i as gt}from"./node-types-DmTOZWT4.js";import"./payload-decoders-7zyi-Y-D.js";function ft(t){const s=t.type??t.payload_type,r=t.duplicates??[],c=t.is_duplicate,a=r.length;let n=null,l=null;if(a>0){const x=[t.rssi,...r.map(g=>g.rssi).filter(g=>g!=null)],m=[t.snr,...r.map(g=>g.snr).filter(g=>g!=null)];x.length>1&&(n=[Math.min(...x),Math.max(...x)]),m.length>1&&(l=[Math.min(...m),Math.max(...m)])}const o=s===O.TRACE;return{isDuplicate:c,dupeCount:a,rssiRange:n,snrRange:l,hashIncludesPathLen:o}}function bt(t,s,r){const c={traceTag:null,siblingCount:0,isLocallyOriginated:!1,method:"none",confidence:"none",inferredSrc:null,inferredName:null,evidence:[],thisPathLen:0,minPathLen:0,firstHopPrefix:null};let a=t._traceTag;if(!a&&t.payload&&(a=Te(t.payload)),!a)return{...c,evidence:["no traceTag — cannot correlate"]};const n=s.get(a)??[],l=N=>N.path_length!=null?N.path_length:Array.isArray(N.original_path)?N.original_path.length:0,o=l(t),x=n.length>0?Math.min(...n.map(l)):o,m=t.payload?t.payload.slice(18):"",g=m.length>=2?m.slice(0,2).toUpperCase():null,u=[];if(u.push(`traceTag: ${a}`),u.push(`siblings: ${n.length} observation${n.length!==1?"s":""}`),t.packet_origin==="tx_local")return u.push("packet_origin = tx_local → we initiated this trace"),{traceTag:a,siblingCount:n.length,isLocallyOriginated:!0,method:"tx_local",confidence:"certain",inferredSrc:"LOCAL",inferredName:null,evidence:u,thisPathLen:o,minPathLen:x,firstHopPrefix:g};const v=n.find(N=>N.packet_origin==="tx_local");if(v)return u.push(`sibling (hash ${v.packet_hash}) has packet_origin = tx_local`),{traceTag:a,siblingCount:n.length,isLocallyOriginated:!0,method:"tx_local",confidence:"certain",inferredSrc:"LOCAL",inferredName:null,evidence:u,thisPathLen:o,minPathLen:x,firstHopPrefix:g};if(u.push(`this observation: path_len=${o}, min across siblings: ${x}`),g){if(u.push(`first hop in target path: ${g}`),o===0)return u.push("path_len = 0 → heard directly from initiator (no SNR appended yet)"),u.push("initiator is a direct RF neighbor"),{traceTag:a,siblingCount:n.length,isLocallyOriginated:!1,method:"min_path_len",confidence:"speculative",inferredSrc:null,inferredName:null,evidence:[...u,"initiator is within direct RF range (zero forwarding hops)"],thisPathLen:o,minPathLen:x,firstHopPrefix:g};const f=Object.entries(r).filter(([k])=>k.replace(/^0x/i,"").slice(0,2).toUpperCase()===g);if(f.length===1){const[k,$]=f[0],h=$.name||$.node_name||null;return u.push(`first hop ${g} → unique neighbor: ${h??k}`),u.push("initiator is whoever sent TO this first hop"),{traceTag:a,siblingCount:n.length,isLocallyOriginated:!1,method:"first_hop_neighbor",confidence:"likely",inferredSrc:g,inferredName:h,evidence:u,thisPathLen:o,minPathLen:x,firstHopPrefix:g}}else f.length>1?u.push(`first hop ${g} matches ${f.length} neighbors (ambiguous)`):u.push(`first hop ${g} is not a known neighbor`)}return u.push("insufficient data to identify initiator"),{traceTag:a,siblingCount:n.length,isLocallyOriginated:!1,method:"none",confidence:"none",inferredSrc:null,inferredName:null,evidence:u,thisPathLen:o,minPathLen:x,firstHopPrefix:g}}let ne=null,ce=null;typeof window<"u"&&setTimeout(()=>{ue(()=>import("./usePipelineStore-11oXtutw.js"),__vite__mapDeps([0,1,2,3])).then(t=>{ne=t}),ue(()=>import("./index-BwGHI0A_.js").then(t=>t.g1),__vite__mapDeps([1,3])).then(t=>{ce=t})},0);const He={advertSender:null,advertNodeType:null,advertFlags:null,advertHasLocation:null,advertHasName:null,advertName:null,advertLatitude:null,advertLongitude:null,channelHash:null,byteLength:void 0,hopCount:0,isZeroHop:!0,preComputed:!1};function yt(t,s){const r=t.type??t.payload_type,c=Ne(r),a=Be(t.route),n=r===O.ADVERT,l=r===O.TRACE,o=r===O.PATH,x=r===O.GRP_TXT||r===O.GRP_DATA,m=Ie(t.snr,t.rssi),g=(m==null?void 0:m.finalGrade)??"critical",u=Ge(t.route),v=Ke(t.route),N=Ve(t.route),f=t.route==null?"unknown":u?"flood":v?"direct":"unknown",k=N?`transport-${f}`:f,$=!!s.advertSender;let h="none";$?h="pubkey":x?h="encrypted":t.src_hash&&(h="prefix");const y=gt(r),p=s.advertNodeType!=null?ke(s.advertNodeType):"unknown",_=y!=="unknown"?y:p,H=t.packet_origin??"rx",C=Math.floor(Date.now()/1e3)-t.timestamp,D=C<10?"live":C<300?"recent":C<3600?"warm":C<86400?"stale":"historic",L=t.path_length??(Array.isArray(t.original_path)?t.original_path.length:void 0),P=Array.isArray(t.original_path)&&t.original_path.length>0,R=L??0,b=s.byteLength??(t.raw_packet?Math.floor(t.raw_packet.length/2):0),w=ft(t);return{pType:r,payloadTypeName:c,routeTypeName:a,isAdvert:n,isTrace:l,isPath:o,isGrp:x,signalClass:g,routeClass:k,isFlood:u,isDirect:v,hasTransport:N,senderTier:h,hasPubkey:$,inferredType:y,advertType:p,effectiveType:_,origin:H,age:D,pathLen:L,pathAvail:P,pathHopCount:R,byteLen:b,dupeAnalysis:w}}function jt(t){var f,k,$,h,y,p;const s=pt(t);if(!s||s.pathHashes.length===0)return null;const{pathHashes:r,snrValues:c}=s;if(r.length<2||!ne||!ce)return null;const a=ne.usePipelineStore.getState().srcHashResolverMap,n=ne.usePipelineStore.getState().neighborContext,l=(n==null?void 0:n.hashToName)??new Map,o=ce.useStore.getState().stats,x=(o==null?void 0:o.neighbors)??{},m=o==null?void 0:o.local_hash,g=(k=(f=o==null?void 0:o.config)==null?void 0:f.repeater)==null?void 0:k.latitude,u=(h=($=o==null?void 0:o.config)==null?void 0:$.repeater)==null?void 0:h.longitude,v=Object.keys(x).length>0?qe([],x,m,g,u):null,N=[];for(let _=0;_0?[r[_-1].toUpperCase()]:[]],P=ge(H,_,L,a,v),R=[H,..._+20?N:null}function ge(t,s,r,c,a){if(s===0){const l=c==null?void 0:c.get(t);if(l)return{hash:l,confidence:.8};if(a){const o=pe(a,t,{position:s,adjacentPrefixes:r});if(o.hash)return{hash:o.hash,confidence:o.confidence}}}else{if(a){const o=pe(a,t,{position:s,adjacentPrefixes:r});if(o.hash)return{hash:o.hash,confidence:o.confidence}}const l=c==null?void 0:c.get(t);if(l)return{hash:l,confidence:.6}}return{hash:null,confidence:0}}function vt(t){var l;const s=t.raw_packet;if(!s||s.length<2)return null;const r=s.replace(/\s/g,""),c=Math.floor(r.length/2),a=((l=r.match(/.{1,2}/g))==null?void 0:l.join(" "))??"";let n="";for(let o=0;o=32&&x<=126?String.fromCharCode(x):"·"}return{hexBytes:a,utf8:n,byteCount:c}}function Nt(t){const s=new Map;let r=0,c="";for(const a of t){if((a.type??a.payload_type)!==O.TRACE)continue;r++,c=a.packet_hash;const l=a._traceTag??(a.payload?Te(a.payload):null);if(!l)continue;let o=s.get(l);o||(o=[],s.set(l,o)),o.push(a)}return{index:s,fingerprint:`${r}:${c}`}}function wt(t,s,r){const c=T.useRef({parse:0,decode:0,enrich:0,traceIndex:0,total:0}),a=T.useMemo(()=>t?vt(t):null,[t]),n=T.useMemo(()=>{if(!s||s.length<4)return c.current.parse=0,c.current.decode=0,null;const h=performance.now(),y=ut(s),p=performance.now()-h;return y?(c.current.parse=p,c.current.decode=0,{protocolPacket:y.packet,display:{headerFields:y.headerFields,transportCodesHex:y.transportCodesHex,pathLengthHex:y.pathLengthHex,pathDataHex:y.pathDataHex,payloadHex:y.payloadHex,payloadByteOffset:y.payloadStartByte,pathByteOffset:y.pathByteOffset,pathLenByteOffset:y.pathLenByteOffset},decoded:y.decoded,error:null}):(c.current.parse=p,c.current.decode=0,{protocolPacket:null,display:null,decoded:null,error:"Packet.fromHex() returned failure"})},[s]),l=T.useMemo(()=>{if(!t)return c.current.enrich=0,He;const h=performance.now();if(t._advertSender!==void 0)return c.current.enrich=performance.now()-h,{advertSender:t._advertSender??null,advertNodeType:t._advertNodeType??null,advertFlags:t._advertFlags??null,advertHasLocation:t._advertHasLocation??null,advertHasName:t._advertHasName??null,advertName:t._advertName??null,advertLatitude:t._advertLatitude??null,advertLongitude:t._advertLongitude??null,channelHash:t._channelHash??null,byteLength:t._byteLength,hopCount:t._hopCount??0,isZeroHop:t._isZeroHop??!0,preComputed:!0};const y=t.type??t.payload_type,p=Fe(s,y),_=Ee(s,y),H=Oe(s,t),C=ze(t);return c.current.enrich=performance.now()-h,{...p,channelHash:_,byteLength:H,...C,preComputed:!1}},[t,s]),o=T.useRef({fingerprint:"",index:new Map}),x=T.useMemo(()=>{const h=performance.now(),{index:y,fingerprint:p}=Nt(r);return c.current.traceIndex=performance.now()-h,p===o.current.fingerprint?o.current.index:(o.current={fingerprint:p,index:y},y)},[r]),m=T.useMemo(()=>{const h=c.current;return{parse:h.parse,decode:h.decode,enrich:h.enrich,traceIndex:h.traceIndex,total:h.parse+h.decode+h.enrich+h.traceIndex}},[n,l,x]);if(!t)return null;const g=s?n?n.error:"rawHex too short":"No raw_packet (warm-tier)",u=(n==null?void 0:n.protocolPacket)??null,v=u?u.payloadVersion:null,N=v===0,f=v===1,k=yt(t,l);let $=null;return k.isTrace&&($=jt(t)),{wire:a,display:(n==null?void 0:n.display)??null,parseError:g,protocolPacket:u,decoded:(n==null?void 0:n.decoded)??null,payloadVersion:v,isV1:N,isV2:f,enrichment:l,traceTagIndex:x,analysis:k,traceHopDetail:$,timing:m}}function ae({options:t,nextFn:s}){var n;const r=t.find(l=>l.active),c=(r==null?void 0:r.color)??"green",a=((n=I[c])==null?void 0:n.stem)??"bg-edge-subtle";return e.jsxs("div",{className:"flex flex-col items-start py-1 gap-0 px-2",children:[e.jsx("div",{className:`w-px h-2 ml-4 ${a}`}),e.jsxs("div",{className:"border border-dashed border-edge-subtle rounded-md overflow-hidden w-full",children:[t.map((l,o)=>{const x=I[l.color??"green"]??I.green;return e.jsxs("div",{className:`flex items-center gap-1.5 px-2 py-px font-mono text-[10px] leading-relaxed transition-opacity ${l.active?x.row:"opacity-25"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${l.active?x.dot:"border border-zinc-500/40"}`}),e.jsx("span",{className:`w-16 shrink-0 font-medium ${l.active?"text-fg-primary":"text-fg-muted"}`,children:l.label}),l.detail&&e.jsx("span",{className:l.active?"text-fg-primary/70":"text-fg-muted",children:l.detail})]},o)}),s&&e.jsx("div",{className:"flex items-center px-2 py-0.5 border-t border-edge-subtle",children:e.jsxs("span",{className:"text-[10px] text-fg-muted font-mono",children:["→ ",s]})})]}),e.jsx("div",{className:`w-px h-2 ml-4 ${a}`})]})}function Ct({tokens:t,nextFn:s}){var n;const r=t.find(l=>l.active),c=(r==null?void 0:r.color)??"green",a=((n=I[c])==null?void 0:n.stem)??"bg-edge-subtle";return e.jsxs("div",{className:"flex flex-col items-start py-1 gap-0 px-2",children:[e.jsx("div",{className:`w-px h-2 ml-4 ${a}`}),e.jsxs("div",{className:"border border-dashed border-edge-subtle rounded-md overflow-hidden w-full",children:[t.map((l,o)=>{const x=I[l.color??"green"]??I.green;return e.jsxs("div",{className:`flex items-center gap-1 px-2 py-px font-mono text-[10px] leading-relaxed transition-opacity ${l.active?x.row:"opacity-25"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${l.active?x.dot:"border border-zinc-500/40"}`}),e.jsx("span",{className:"text-fg-muted shrink-0",children:l.fn}),e.jsxs("span",{className:l.active?"text-fg-primary":"text-fg-muted",children:["(",l.value??"",")"]})]},o)}),s&&e.jsx("div",{className:"flex items-center px-2 py-0.5 border-t border-edge-subtle",children:e.jsxs("span",{className:"text-[10px] text-fg-muted font-mono",children:["→ ",s]})})]}),e.jsx("div",{className:`w-px h-2 ml-4 ${a}`})]})}const St={0:"border-l-sys-green",1:"border-l-sys-blue",2:"border-l-sys-teal",3:"border-l-sys-purple"};function le({stage:t,name:s,fn:r,verdict:c,timeMs:a,skipped:n,skipReason:l,children:o}){const x=St[t]??"";return e.jsx(e.Fragment,{children:e.jsx(G,{defaultOpen:!n,children:e.jsxs("div",{className:`surface-base rounded-lg border border-edge-subtle overflow-hidden border-l-2 ${x}`,children:[e.jsxs(K,{className:"px-3 py-2 w-full",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"font-mono text-xs font-bold text-sys-blue shrink-0",children:t}),e.jsx("span",{className:"font-mono text-xs font-medium text-fg-primary truncate",children:s}),r&&!c&&e.jsx("span",{className:"font-mono text-[11px] text-fg-muted truncate hidden sm:inline",children:r}),c&&e.jsx("span",{className:"font-mono text-[11px] text-fg-muted/70 truncate hidden sm:inline",children:c})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[n&&e.jsx("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-zinc-500/20 text-fg-muted",children:"N/A"}),a!=null&&!n&&e.jsx("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-sys-green/15 text-sys-green",children:a<1?`${(a*1e3).toFixed(0)}µs`:`${a.toFixed(2)}ms`})]})]}),e.jsx(V,{children:e.jsx("div",{className:"px-3 pb-3 font-mono text-xs",children:n?e.jsx("p",{className:"text-fg-muted italic",children:l??"Not applicable for this packet type"}):o})})]})})})}function Tt(t,s){return s?"manual":t._stripped?"bulk-tier":Ue.isConnected()?"ws-push":"rest-poll"}const _t={connected:"green",degraded:"amber",offline:"red"};function kt({packet:t,isSynthetic:s}){const r=xe(g=>g.wsState),c=xe(g=>g.health),a=Tt(t,s),l=!!t._stripped?"WARM":"HOT",o=[{label:"ws-push",detail:"wsConnected && onPacket()",active:a==="ws-push",color:"green"},{label:"rest-poll",detail:"!wsConnected, 3s interval",active:a==="rest-poll",color:"amber"},{label:"catchup",detail:"wsReconnected, delta > 50",active:a==="catchup",color:"amber"},{label:"bulk-tier",detail:"user extends time range → gzip",active:a==="bulk-tier",color:"blue"},{label:"manual",detail:"hex input — no transport",active:a==="manual",color:"zinc"}],x=[{fn:"transport",value:a,group:"transport",color:a==="ws-push"?"green":a==="bulk-tier"?"blue":"amber"},{fn:"tier",value:l,group:"transport",color:"blue"},{fn:"wsState",value:r,group:"transport",color:r==="connected"?"green":"amber"},{fn:"health",value:c,group:"transport",color:_t[c]}],m=s?"manual hex input":`${a} (${c})`;return e.jsx(le,{stage:0,name:"TRANSPORT",fn:"websocketService / useStore.startPolling",verdict:m,children:s?e.jsx("p",{className:"text-fg-muted italic",children:"Manual hex input — no transport context"}):e.jsx(q,{prefix:"transport",children:e.jsxs("div",{className:"space-y-0",children:[e.jsx(ae,{options:o,nextFn:"ingest()"}),e.jsx(se,{tokens:x})]})})})}function U({start:t,end:s}){const r=s!=null&&s!==t?`[${t}..${s}]`:`[${t}]`;return e.jsx("span",{className:"text-fg-muted text-[9px] font-mono mr-1 select-none",children:r})}const Ht={advert:"decodeAdvert()",ack:"decodeAck()",path:"decodePath()",trace:"decodeTraceWithSnr()",txt_msg:"decodeTextMessage()",grp_txt:"decodeGroupText()",grp_data:"decodeGroupData()",multipart:"decodeMultipart()",control:"decodeControl()",req:"decodeRequest()",response:"decodeResponse()",anon_req:"decodeAnonReq()",generic:"decodeGeneric()"};function $t({rawHex:t,display:s,protocolPacket:r,parseError:c,parseTimeMs:a,payloadVersion:n,isV1:l,isV2:o}){return e.jsx("dl",{className:"space-y-0.5",children:s&&r&&t?e.jsxs(e.Fragment,{children:[e.jsx(E,{title:"A. Parse — Packet.fromHex()"}),a>0&&e.jsx("div",{className:"flex justify-end",children:e.jsx("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-sys-green/15 text-sys-green",children:a<1?`${(a*1e3).toFixed(0)}µs`:`${a.toFixed(2)}ms`})}),e.jsxs(i,{label:"header byte",children:[e.jsx(U,{start:0}),e.jsx(A,{value:t.slice(0,2)})," ",e.jsx(xt,{value:parseInt(t.slice(0,2),16)})]}),s.headerFields.map(x=>e.jsx(i,{label:` ${x.field}`,children:e.jsx(F,{raw:e.jsxs("span",{className:"text-[10px]",children:["bits[",x.bits,"] = ",x.binary]}),children:e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-2 py-0.5 font-mono text-[11px] text-sys-amber",children:x.value})})},x.field)),e.jsx(i,{label:" version",children:n!=null?e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(d,{fn:"payloadVer",value:`${n}`,color:"amber"}),e.jsx(M,{color:l?"green":o?"blue":"zinc",children:l?"v1":o?"v2":`v${n}`}),l&&e.jsx("span",{className:"text-fg-muted text-[10px]",children:"1-byte hashes, 2-byte MAC"}),o&&e.jsx("span",{className:"text-sys-blue text-[10px]",children:"2-byte hashes, 4-byte MAC (speculative)"})]}):e.jsx("span",{className:"text-fg-muted",children:"unknown"})}),e.jsx(E,{title:"Wire Framing"}),e.jsx(i,{label:"transportCodes",children:s.transportCodesHex?e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(U,{start:1,end:4}),e.jsx(d,{fn:"transport",value:s.transportCodesHex,color:"amber"})]}):e.jsx("span",{className:"text-fg-muted",children:"N/A (non-transport route)"})}),e.jsx(i,{label:"pathLen",children:e.jsx(F,{raw:e.jsxs(e.Fragment,{children:[e.jsx(U,{start:s.pathLenByteOffset}),e.jsx(A,{value:s.pathLengthHex})]}),children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(U,{start:s.pathLenByteOffset}),e.jsx(d,{fn:"pathLen",value:`${r.pathLen} hop${r.pathLen!==1?"s":""}`,color:"amber"})]})})}),e.jsx(i,{label:"path",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[r.pathLen>0&&e.jsx(U,{start:s.pathByteOffset,end:s.pathByteOffset+r.pathLen-1}),e.jsx(re,{hops:r.pathHexArray,hexPrefix:s.pathDataHex||void 0})]})}),e.jsx(i,{label:"payloadLen",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(U,{start:s.payloadByteOffset,end:s.payloadByteOffset+s.payloadHex.length/2-1}),e.jsx(d,{fn:"payloadLen",value:`${s.payloadHex.length/2} bytes`,color:"amber"})]})}),e.jsx(i,{label:"payloadHex",children:e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-2 py-0.5 font-mono text-[11px] text-sys-amber break-all",children:s.payloadHex})})]}):e.jsxs(e.Fragment,{children:[e.jsx(E,{title:"A. Parse"}),e.jsxs(i,{label:"result",children:[e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-2 py-0.5 font-mono text-[11px] text-sys-amber",children:"Skipped"}),e.jsx("span",{className:"ml-1 text-fg-muted",children:c??"No raw_packet (warm-tier)"})]})]})})}function Dt({decoded:t,packet:s}){if(!t)return e.jsxs(e.Fragment,{children:[e.jsx(E,{title:"B. Decode"}),e.jsx("p",{className:"text-fg-muted italic text-[10px]",children:"No decoded payload"})]});const r=Ht[t.type]??`decode${t.type}()`;return e.jsxs(e.Fragment,{children:[e.jsx(E,{title:"B. Decode — decodePayload()"}),e.jsx(q,{prefix:"decodePayload",children:e.jsxs("dl",{className:"space-y-0.5",children:[e.jsx(i,{label:"dispatched",children:r}),e.jsx(E,{}),e.jsx(Lt,{decoded:t,packet:s})]})})]})}function Lt({decoded:t,packet:s}){var r;switch(t.type){case"advert":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"publicKey",children:e.jsx(F,{raw:e.jsx("span",{className:"text-[10px] break-all",children:t.publicKey}),children:e.jsx(d,{fn:"publicKey",value:t.publicKey,color:"green"})})}),e.jsx(i,{label:"timestamp",children:e.jsx(d,{fn:"timestamp",value:String(t.timestamp),color:"green"})}),e.jsx(i,{label:"flags",children:e.jsx(F,{raw:e.jsx(A,{value:t.flags}),children:e.jsx(d,{fn:"flags",value:t.flagsDescription,color:"green"})})}),e.jsx(i,{label:"nodeType",children:e.jsx(d,{fn:"nodeType",value:t.nodeType,color:"green"})}),t.latitude!=null&&e.jsx(i,{label:"latitude",children:e.jsx(d,{fn:"lat",value:t.latitude.toFixed(6),color:"green"})}),t.longitude!=null&&e.jsx(i,{label:"longitude",children:e.jsx(d,{fn:"lon",value:t.longitude.toFixed(6),color:"green"})}),t.name&&e.jsx(i,{label:"name",children:e.jsx(d,{fn:"name",value:t.name,color:"green"})})]});case"ack":return e.jsx(i,{label:"crc",children:e.jsx(F,{raw:e.jsx("span",{className:"text-[10px]",children:t.crc}),children:e.jsx(d,{fn:"crc",value:t.crc,color:"green"})})});case"trace":{const c=s!=null&&s.src_hash?s.src_hash.replace(/^0x/i,"").slice(0,2).toUpperCase():null;return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"traceTag",children:e.jsx(d,{fn:"traceTag",value:t.traceTag,color:"green"})}),e.jsx(i,{label:"authCode",children:e.jsx(d,{fn:"authCode",value:String(t.authCode),color:"green"})}),e.jsx(i,{label:"flags",children:e.jsx(A,{value:t.flags})}),e.jsx(i,{label:"target path",children:t.pathHashes.length>0?e.jsx(re,{hops:t.pathHashes.map(a=>a.toUpperCase()),color:"green"}):e.jsx("span",{className:"text-fg-muted italic",children:"∅ empty"})}),e.jsx(i,{label:"complete",children:t.isComplete?e.jsxs("span",{className:"text-sys-green",children:["✓ all ",t.pathHashes.length," hops reported SNR"]}):e.jsxs("span",{className:"text-sys-amber",children:["✗ ",t.snrValues.length,"/",t.pathHashes.length," hops reported"]})}),e.jsx(E,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-fg-muted mb-1 text-[10px]",children:"Directional Edge SNR — per-hop link quality"}),t.snrValues.length===0?e.jsx("p",{className:"text-fg-muted italic text-[11px] ml-2",children:"No SNR values in path field"}):e.jsx("div",{className:"space-y-0.5 ml-2",children:t.snrValues.map((a,n)=>{var g,u,v,N,f;const l=((g=t.pathHashes[n])==null?void 0:g.toUpperCase())??"??",o=n===0?c??"SRC":((u=t.pathHashes[n-1])==null?void 0:u.toUpperCase())??"??",x=(f=(N=(v=Ye.getState().stats)==null?void 0:v.config)==null?void 0:N.radio)==null?void 0:f.spreading_factor,m=we(a,x);return e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-mono",children:[e.jsx("span",{className:"text-fg-muted w-3 text-right",children:n}),e.jsx("span",{className:"text-fg-primary",children:o}),e.jsx("span",{className:"text-fg-muted",children:"→"}),e.jsx("span",{className:"text-fg-primary",children:l}),e.jsx("span",{className:"text-fg-muted",children:"@"}),e.jsxs("span",{className:"font-bold text-sys-green",children:[a>0?"+":"",a.toFixed(1)," dB"]}),e.jsx(M,{color:"green",children:m})]},n)})})]})]})}case"path":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"pathLength",children:e.jsx(d,{fn:"pathLength",value:String(t.pathLength),color:"green"})}),e.jsx(i,{label:"path",children:t.path&&t.path.length>0?e.jsx(re,{hops:t.path.map(c=>c.toUpperCase()),color:"green"}):e.jsx("span",{className:"text-fg-muted italic",children:"∅ empty"})}),t.extraType!=null&&e.jsx(i,{label:"extraType",children:e.jsx(d,{fn:"extraType",value:t.extraTypeName??String(t.extraType),color:"purple"})}),t.extraData&&e.jsxs(i,{label:"extraData",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.extraData}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.extraData.length/2,"B)"]})]})]});case"txt_msg":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"destHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.destHash}),children:e.jsx(d,{fn:"destHash",value:t.destHash,color:"green"})})}),e.jsx(i,{label:"srcHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.srcHash}),children:e.jsx(d,{fn:"srcHash",value:t.srcHash,color:"green"})})}),e.jsx(i,{label:"cipherMac",children:e.jsx(d,{fn:"cipherMac",value:t.cipherMac,color:"purple"})}),e.jsx(i,{label:"timestamp",children:e.jsx(d,{fn:"timestamp",value:String(t.timestamp),color:"green"})}),e.jsx(i,{label:"text",children:e.jsx(d,{fn:"text",value:t.text,color:"green"})}),e.jsx(i,{label:"encrypted",children:e.jsx(d,{fn:"encrypted",value:String(t.encrypted),color:"green"})})]});case"grp_txt":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"channelHash",children:e.jsx(A,{value:t.channelHash})}),t.channelName&&e.jsx(i,{label:"channelName",children:e.jsx(d,{fn:"channel",value:t.channelName,color:"green"})}),e.jsx(i,{label:"decrypted",children:e.jsx(d,{fn:"decrypted",value:String(t.decrypted),color:"green"})}),t.text&&e.jsx(i,{label:"text",children:e.jsx(d,{fn:"text",value:t.text,color:"green"})}),t.senderName&&e.jsx(i,{label:"senderName",children:e.jsx(d,{fn:"sender",value:t.senderName,color:"green"})}),t.macCorrupted&&e.jsx(i,{label:"macCorrupted",children:e.jsx(d,{fn:"macCorrupted",value:"true",color:"green"})})]});case"grp_data":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"channelHash",children:e.jsx(A,{value:t.channelHash})}),e.jsx(i,{label:"dataLength",children:t.dataLength}),e.jsx(i,{label:"decrypted",children:String(t.decrypted)})]});case"multipart":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"messageId",children:t.messageId}),e.jsxs(i,{label:"part",children:[t.partNumber+1," / ",t.totalParts]})]});case"control":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"controlType",children:e.jsx(F,{raw:e.jsx(A,{value:t.controlType}),children:e.jsx(d,{fn:"controlType",value:t.subtypeName,color:"green"})})}),e.jsx(i,{label:"subtype",children:e.jsx(d,{fn:"subtype",value:`0x${t.subtype.toString(16).padStart(2,"0")}`,color:"green"})}),t.nodeTypeName&&e.jsxs(i,{label:"nodeType",children:[e.jsx(d,{fn:"nodeType",value:t.nodeTypeName,color:"green"}),e.jsxs("span",{className:"text-fg-muted text-[10px] ml-1",children:["(flags & 0x0F = 0x",(r=t.nodeType)==null?void 0:r.toString(16).padStart(2,"0"),")"]})]}),t.snrDb!=null&&e.jsxs(i,{label:"snr",children:[e.jsxs("span",{className:"font-bold text-sys-green",children:[t.snrDb>0?"+":"",t.snrDb.toFixed(1)," dB"]}),e.jsx(M,{color:"green",children:t.snrDb>=5?"strong":t.snrDb>=0?"fair":"weak"})]}),t.tag&&e.jsx(i,{label:"tag",children:e.jsx(d,{fn:"tag",value:t.tag,color:"green"})}),t.publicKey&&e.jsxs(i,{label:"publicKey",children:[e.jsx("span",{className:"break-all text-[10px] font-mono text-sys-green",children:t.publicKey}),e.jsx(M,{color:t.publicKeyFull?"green":"amber",children:t.publicKeyFull?"32B full":`${t.publicKey.length/2}B prefix`})]}),t.typeFilter!=null&&e.jsx(i,{label:"typeFilter",children:e.jsx(F,{raw:e.jsx(A,{value:t.typeFilter}),children:e.jsx(d,{fn:"typeFilter",value:t.typeFilterDescription??"none",color:"green"})})}),t.prefixOnly!=null&&e.jsx(i,{label:"prefixOnly",children:e.jsx(d,{fn:"prefixOnly",value:String(t.prefixOnly),color:"green"})}),t.since!=null&&e.jsx(i,{label:"since",children:e.jsx(d,{fn:"since",value:t.since===0?"all (0)":String(t.since),color:"green"})}),!t.nodeTypeName&&t.typeFilter==null&&t.dataLength>0&&e.jsxs(i,{label:"data",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.dataHex}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.dataLength,"B)"]})]})]});case"req":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"destHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.destHash}),children:e.jsx(d,{fn:"destHash",value:t.destHash,color:"green"})})}),e.jsx(i,{label:"srcHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.srcHash}),children:e.jsx(d,{fn:"srcHash",value:t.srcHash,color:"green"})})}),e.jsx(i,{label:"cipherMac",children:e.jsx(d,{fn:"cipherMac",value:t.cipherMac,color:"purple"})}),e.jsxs(i,{label:"ciphertext",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.ciphertextHex}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.ciphertextLength,"B)"]})]})]});case"response":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"destHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.destHash}),children:e.jsx(d,{fn:"destHash",value:t.destHash,color:"green"})})}),e.jsx(i,{label:"srcHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.srcHash}),children:e.jsx(d,{fn:"srcHash",value:t.srcHash,color:"green"})})}),e.jsx(i,{label:"cipherMac",children:e.jsx(d,{fn:"cipherMac",value:t.cipherMac,color:"purple"})}),e.jsxs(i,{label:"ciphertext",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.ciphertextHex}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.ciphertextLength,"B)"]})]})]});case"anon_req":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"destHash",children:e.jsx(F,{raw:e.jsx(A,{value:t.destHash}),children:e.jsx(d,{fn:"destHash",value:t.destHash,color:"green"})})}),e.jsx(i,{label:"senderPubKey",children:e.jsx("span",{className:"break-all text-[10px] font-mono text-sys-green",children:t.senderPublicKey})}),e.jsx(i,{label:"cipherMac",children:e.jsx(d,{fn:"cipherMac",value:t.cipherMac,color:"purple"})}),e.jsxs(i,{label:"ciphertext",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.ciphertextHex}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.ciphertextLength,"B)"]})]})]});case"generic":return e.jsxs(e.Fragment,{children:[e.jsxs(i,{label:"payloadType",children:[e.jsx(ht,{value:t.payloadType})," (",t.payloadTypeName,")"]}),e.jsx(i,{label:"length",children:t.length}),e.jsx(i,{label:"rawHex",children:e.jsx("span",{className:"break-all",children:t.rawHex})})]});default:return e.jsx("p",{className:"text-fg-muted",children:"Unknown decoded type"})}}function Pt({protocolPacket:t,packetHash:s}){const r=t==null?void 0:t.payloadType,c=r===Ze||r===Xe,a=T.useMemo(()=>{if(!c||!t)return null;const p=t.payload;return p.length<4?null:{channelHash:p[0],mac:p.slice(1,3),ciphertext:p.slice(3)}},[t,c]),[n,l]=T.useState("pending"),[o,x]=T.useState([]),[m,g]=T.useState(0);T.useEffect(()=>{if(!a){l(null);return}let p=!1;return(async()=>{const H=performance.now(),C=await Qe(a.channelHash,a.mac,a.ciphertext);p||(l(C),g(performance.now()-H));const D=await Je(a.channelHash);p||x(D)})(),()=>{p=!0}},[a]);const[u,v]=T.useState(""),[N,f]=T.useState(null),[k,$]=T.useState(!1),h=T.useCallback(async()=>{if(!(!a||!u.trim())){$(!0);try{const p=await We(u.trim(),a.channelHash,a.mac,a.ciphertext);if(p.success){const _=new TextDecoder("utf-8",{fatal:!1}).decode(p.result.plaintext.slice(5));f({success:!0,text:_})}else f({success:!1,error:p.error})}catch(p){f({success:!1,error:String(p)})}finally{$(!1)}}},[a,u]),y=Ce(s);return!c||!a?null:e.jsxs(e.Fragment,{children:[e.jsx(E,{title:"C. Decrypt — tryDecryptGroupMessage()"}),m>0&&e.jsx("div",{className:"flex justify-end",children:e.jsx("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-sys-green/15 text-sys-green",children:m<1?`${(m*1e3).toFixed(0)}µs`:`${m.toFixed(2)}ms`})}),e.jsx(q,{prefix:"tryDecryptGroupMessage",children:e.jsxs("dl",{className:"space-y-0.5",children:[e.jsx(i,{label:"channelHash",children:e.jsx(d,{fn:"channelHash",value:`0x${a.channelHash.toString(16).toUpperCase().padStart(2,"0")}`,color:"teal"})}),e.jsx(i,{label:"mac",children:e.jsx(d,{fn:"mac",value:Array.from(a.mac).map(p=>p.toString(16).padStart(2,"0")).join(""),color:"teal"})}),e.jsx(i,{label:"cipherLen",children:e.jsx(d,{fn:"cipherLen",value:`${a.ciphertext.length}B`,color:"teal"})}),e.jsx(i,{label:"candidates",children:e.jsx(d,{fn:"candidates",value:o.length>0?`${o.length} names`:"0",color:o.length>0?"teal":"zinc"})}),o.length>0&&e.jsxs("details",{className:"mt-1",children:[e.jsx("summary",{className:"text-fg-muted cursor-pointer hover:text-fg-primary text-[10px]",children:"show candidate names"}),e.jsx("div",{className:"mt-1 text-[10px] text-fg-muted break-all max-h-24 overflow-y-auto",children:o.join(", ")})]}),e.jsx(E,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-fg-muted mb-1",children:"Result:"}),n==="pending"?e.jsx("p",{className:"text-fg-muted italic",children:"decrypting…"}):n?e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"channel",children:e.jsx(d,{fn:"channel",value:n.channelName,color:"teal"})}),e.jsx(i,{label:"plaintext",children:e.jsx(d,{fn:"plaintext",value:new TextDecoder("utf-8",{fatal:!1}).decode(n.plaintext.slice(5)).trim()||"(empty)",color:"teal"})}),e.jsx(i,{label:"macValid",children:e.jsx(d,{fn:"macValid",value:n.macCorrupted?"false":"true",color:"teal"})})]}):e.jsxs(i,{label:"decrypt",children:[e.jsx(d,{fn:"decrypt",value:"failed",color:"red"}),e.jsx("span",{className:"text-fg-muted ml-1",children:"channel not in known list"})]})]}),e.jsx(E,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-fg-muted mb-1",children:"testChannelName() — manual test:"}),e.jsxs("div",{className:"flex gap-1.5 items-center",children:[e.jsx("input",{type:"text",value:u,onChange:p=>{v(p.target.value),f(null)},onKeyDown:p=>p.key==="Enter"&&h(),placeholder:"channel name",className:"surface-input px-2 py-1 rounded text-[11px] font-mono text-fg-primary w-40"}),e.jsx("button",{onClick:h,disabled:k||!u.trim(),className:"px-2 py-1 rounded text-[10px] font-mono bg-sys-blue/20 text-sys-blue hover:bg-sys-blue/30 disabled:opacity-40 transition-colors",children:k?"…":"Try"})]}),N&&e.jsx("div",{className:"mt-1",children:N.success?e.jsx(i,{label:"result",children:e.jsx(d,{fn:"plaintext",value:N.text??"(empty)",color:"teal"})}):e.jsx(i,{label:"error",children:e.jsx(d,{fn:"error",value:N.error??"unknown",color:"red"})})})]}),e.jsx(E,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-fg-muted mb-1",children:"useDecodedMessage() store result:"}),y?y.decoded?e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"channel",children:e.jsx(d,{fn:"channel",value:y.decoded.channelName??"?",color:"teal"})}),e.jsx(i,{label:"text",children:e.jsx(d,{fn:"text",value:y.decoded.text,color:"teal"})})]}):e.jsx(i,{label:"decrypt",children:e.jsx(d,{fn:"decrypt",value:"failed",color:"red"})}):e.jsx(i,{label:"decrypt",children:e.jsx(d,{fn:"decrypt",value:"pending",color:"zinc"})})]})]})})]})}function Mt(t){const{rawHex:s,display:r,protocolPacket:c,decoded:a,parseError:n,parseTimeMs:l,payloadVersion:o,isV1:x,isV2:m,packetHash:g,packet:u}=t,v=!!s&&s.length>=4;return e.jsxs(G,{children:[e.jsx(K,{className:"w-full mt-2 mb-1",children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-[10px] font-mono text-fg-muted",children:"🔬"}),e.jsx("span",{className:"text-[10px] font-mono font-medium text-fg-muted",children:"Wire Inspection"}),e.jsx("span",{className:"text-[9px] text-fg-muted/50",children:"observatory diagnostic — not a runtime stage"})]})}),e.jsx(V,{children:e.jsxs("div",{className:"border border-dashed border-edge-subtle rounded-lg p-3 space-y-1 bg-surface/30",children:[e.jsx("p",{className:"text-[9px] text-fg-muted/50 mb-2",children:"The backend parsed these fields server-side. This panel verifies the wire-level encoding client-side."}),v?e.jsxs(e.Fragment,{children:[e.jsx($t,{rawHex:s,display:r,protocolPacket:c,parseError:n,parseTimeMs:l,payloadVersion:o,isV1:x,isV2:m}),e.jsx(Dt,{decoded:a,packet:u}),e.jsx(Pt,{protocolPacket:c,packetHash:g})]}):e.jsx("p",{className:"text-fg-muted italic text-[10px]",children:n??"No raw_packet — wire inspection unavailable (warm-tier packet)"})]})})]})}function fe(t){if(!t)return[{fn:"decode",value:"no raw_packet",group:"decode",color:"zinc"}];switch(t.type){case"advert":{const s=t,r=[{fn:"decode.nodeType",value:s.nodeType,group:"decode",color:"blue"}];return s.name&&r.push({fn:"decode.name",value:s.name,group:"decode",color:"blue"}),s.latitude!=null&&s.longitude!=null&&r.push({fn:"decode.location",value:`${s.latitude.toFixed(4)}, ${s.longitude.toFixed(4)}`,group:"decode",color:"blue"}),r.push({fn:"decode.publicKey",value:s.publicKey,group:"decode",color:"blue"}),r}case"trace":{const s=t;return[{fn:"decode.traceTag",value:s.traceTag,group:"decode",color:"blue"},{fn:"decode.hops",value:s.pathHashes.length>0?s.pathString:"empty",group:"decode",color:"blue"},{fn:"decode.snr",value:s.snrValues.length>0?`${s.snrValues.length} values`:"none",group:"decode",color:s.snrValues.length>0?"blue":"zinc"},{fn:"decode.complete",value:s.isComplete?"yes":"partial",group:"decode",color:s.isComplete?"green":"amber"}]}case"path":{const s=t,r=[{fn:"decode.pathLength",value:String(s.pathLength),group:"decode",color:"blue"},{fn:"decode.path",value:s.path.length>0?s.pathString:"empty",group:"decode",color:"blue"}];return s.extraType!=null&&r.push({fn:"decode.extraType",value:s.extraTypeName??String(s.extraType),group:"decode",color:"purple"}),s.extraData&&r.push({fn:"decode.extraData",value:`${s.extraData.length/2}B`,group:"decode",color:"purple"}),r}case"ack":return[{fn:"decode.crc",value:t.crc,group:"decode",color:"blue"}];case"grp_txt":return[{fn:"decode.channelHash",value:t.channelHash,group:"decode",color:"blue"},{fn:"decode.encrypted",value:"true — decrypt at cascade",group:"decode",color:"zinc"}];case"grp_data":{const s=t;return[{fn:"decode.channelHash",value:s.channelHash,group:"decode",color:"blue"},{fn:"decode.dataLength",value:`${s.dataLength}B`,group:"decode",color:"blue"}]}case"txt_msg":{const s=t;return[{fn:"decode.srcHash",value:s.srcHash,group:"decode",color:"blue"},{fn:"decode.destHash",value:s.destHash,group:"decode",color:"blue"},{fn:"decode.encrypted",value:s.encrypted?"true":"false",group:"decode",color:s.encrypted?"zinc":"green"},...s.encrypted?[]:[{fn:"decode.text",value:s.text,group:"decode",color:"blue"}]]}case"multipart":{const s=t;return[{fn:"decode.part",value:`${s.partNumber+1}/${s.totalParts}`,group:"decode",color:"blue"},{fn:"decode.msgId",value:s.messageId,group:"decode",color:"blue"}]}case"control":{const s=t,r=[{fn:"decode.subtype",value:s.subtypeName,group:"decode",color:"blue"}];return s.nodeTypeName&&r.push({fn:"decode.nodeType",value:s.nodeTypeName,group:"decode",color:"blue"}),s.snrDb!=null&&r.push({fn:"decode.snr",value:`${s.snrDb>0?"+":""}${s.snrDb.toFixed(1)} dB`,group:"decode",color:"blue"}),s.tag&&r.push({fn:"decode.tag",value:s.tag,group:"decode",color:"blue"}),s.publicKey&&r.push({fn:"decode.publicKey",value:s.publicKey,group:"decode",color:s.publicKeyFull?"green":"blue"}),s.typeFilter!=null&&r.push({fn:"decode.typeFilter",value:s.typeFilterDescription??`0x${s.typeFilter.toString(16)}`,group:"decode",color:"blue"}),s.prefixOnly!=null&&r.push({fn:"decode.prefixOnly",value:String(s.prefixOnly),group:"decode",color:"blue"}),!s.nodeTypeName&&!s.tag&&(r.push({fn:"decode.subtypeFlags",value:`0x${s.subtypeFlags.toString(16)}`,group:"decode",color:"blue"}),r.push({fn:"decode.dataLength",value:`${s.dataLength}B`,group:"decode",color:"blue"})),r}case"req":{const s=t;return[{fn:"decode.destHash",value:s.destHash,group:"decode",color:"blue"},{fn:"decode.srcHash",value:s.srcHash,group:"decode",color:"blue"},{fn:"decode.cipherMac",value:s.cipherMac,group:"decode",color:"purple"},{fn:"decode.ciphertext",value:`${s.ciphertextLength}B`,group:"decode",color:"zinc"}]}case"response":{const s=t;return[{fn:"decode.destHash",value:s.destHash,group:"decode",color:"blue"},{fn:"decode.srcHash",value:s.srcHash,group:"decode",color:"blue"},{fn:"decode.cipherMac",value:s.cipherMac,group:"decode",color:"purple"},{fn:"decode.ciphertext",value:`${s.ciphertextLength}B`,group:"decode",color:"zinc"}]}case"anon_req":{const s=t;return[{fn:"decode.destHash",value:s.destHash,group:"decode",color:"blue"},{fn:"decode.senderPubKey",value:s.senderPublicKey,group:"decode",color:"green"},{fn:"decode.cipherMac",value:s.cipherMac,group:"decode",color:"purple"},{fn:"decode.ciphertext",value:`${s.ciphertextLength}B`,group:"decode",color:"zinc"}]}case"generic":return[{fn:"decode.raw",value:`${t.length}B`,group:"decode",color:"zinc"}];default:return[]}}function Rt({packet:t,pipeline:s,rawHex:r,traceTagIndex:c,neighbors:a}){const{enrichment:n,timing:l,display:o,protocolPacket:x,decoded:m,parseError:g,payloadVersion:u,isV1:v,isV2:N,analysis:f}=s,$=(t.type??t.payload_type)===et,h=f.dupeAnalysis,y=T.useRef(0),p=T.useMemo(()=>{if(!$)return null;const D=performance.now(),L=bt(t,c,a);return y.current=performance.now()-D,L},[t,c,a,$]),_=l.enrich+y.current,H=[];f.byteLen&&H.push(`${f.byteLen}B`),H.push(f.payloadTypeName),n.advertName&&H.push(`"${n.advertName}"`),n.isZeroHop?H.push("zero-hop"):f.pathHopCount>0&&H.push(`${f.pathHopCount}h`),H.push(`${t.rssi}dBm`),h.isDuplicate&&H.push("DUPE");const C=H.join(" — ");return e.jsxs(le,{stage:1,name:"INGEST",fn:n.preComputed?"PacketCache.mergePackets()":"extractAdvertData() + extractHopData() + ...",verdict:C,timeMs:_,children:[e.jsx(Mt,{rawHex:r,display:o,protocolPacket:x,decoded:m,parseError:g,parseTimeMs:l.parse,payloadVersion:u,isV1:v,isV2:N,packetHash:t.packet_hash,packet:t}),e.jsx(E,{title:"Cache Enrichment"}),e.jsx(q,{prefix:"packetCache",children:e.jsxs("dl",{className:"space-y-0.5",children:[e.jsxs("div",{className:"mb-1.5",children:[n.preComputed?e.jsx(M,{color:"green",children:"PacketCache"}):e.jsx(M,{color:"amber",children:"computed"}),e.jsx("span",{className:"text-[10px] text-fg-muted ml-1.5",children:n.preComputed?"pre-enriched by real pipeline":"synthetic — computed on the fly"})]}),e.jsxs("div",{className:"flex flex-wrap gap-x-2 gap-y-1 mb-1",children:[e.jsx(d,{fn:"_byteLength",value:n.byteLength!=null?`${n.byteLength}B`:void 0,color:"blue"}),e.jsx(d,{fn:"_hopCount",value:String(n.hopCount),color:"blue"}),e.jsx(d,{fn:"_isZeroHop",value:String(n.isZeroHop),color:n.isZeroHop?"green":"blue"}),n.isZeroHop&&e.jsx(M,{color:"blue",children:"direct"}),n.channelHash!=null&&e.jsx(d,{fn:"_channelHash",value:n.channelHash,color:"blue"}),$&&t._traceTag&&e.jsx(d,{fn:"_traceTag",value:t._traceTag,color:"blue"})]}),n.advertSender||n.advertNodeType!=null||n.advertName!=null?e.jsxs("div",{className:"mt-1 mb-1",children:[e.jsx("p",{className:"text-[10px] text-sys-blue font-medium mb-0.5",children:"ADVERT Enrichment"}),e.jsxs("div",{className:"flex flex-wrap gap-x-2 gap-y-1",children:[n.advertSender&&e.jsx(d,{fn:"_advertSender",value:n.advertSender.slice(0,16)+"…",color:"blue"}),n.advertNodeType!=null&&e.jsx(d,{fn:"_advertNodeType",value:ke(n.advertNodeType),color:"blue"}),n.advertName!=null&&e.jsx(d,{fn:"_advertName",value:n.advertName,color:"blue"}),n.advertFlags!=null&&e.jsx(d,{fn:"_advertFlags",value:`0x${n.advertFlags.toString(16).padStart(2,"0")}`,color:"blue"}),n.advertHasLocation!=null&&e.jsx(d,{fn:"_advertHasLocation",value:String(n.advertHasLocation),color:"blue"}),n.advertHasName!=null&&e.jsx(d,{fn:"_advertHasName",value:String(n.advertHasName),color:"blue"}),n.advertLatitude!=null&&n.advertLongitude!=null&&e.jsx(d,{fn:"location",value:`${n.advertLatitude.toFixed(4)}, ${n.advertLongitude.toFixed(4)}`,color:"blue"})]})]}):e.jsx("p",{className:"text-[10px] text-fg-muted/30 mb-1",children:"ADVERT fields: N/A (non-ADVERT packet)"}),e.jsx(E,{title:"Payload Decode"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${m?"bg-sys-blue":"bg-zinc-500/40"}`}),e.jsx("span",{className:"font-mono text-[10px] font-medium text-fg-primary",children:"decodePayload()"}),e.jsx("span",{className:"text-[9px] text-fg-muted",children:"sync — wire data only, no crypto"})]}),e.jsx("div",{className:"ml-3",children:m?e.jsx("div",{className:"flex flex-wrap gap-x-1.5 gap-y-1",children:fe(m).map((D,L)=>e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5",children:e.jsx(d,{fn:D.fn,value:D.value,color:D.color})},L))}):e.jsx(S,{children:"no raw_packet — warm-tier packet, decode unavailable"})})]}),e.jsx(E,{}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] font-mono",children:[e.jsx("span",{className:"text-fg-muted",children:"dupe:"}),h.isDuplicate?e.jsx(d,{fn:"is_duplicate",value:"true",color:"purple"}):e.jsx(S,{children:"none"}),h.dupeCount>0&&e.jsx(d,{fn:"dupeCount",value:`×${h.dupeCount}`,color:"purple"}),h.rssiRange&&e.jsxs(S,{c:"text-fg-primary",children:["Δ",Math.abs(h.rssiRange[1]-h.rssiRange[0]),"dB RSSI"]})]}),p&&e.jsxs(e.Fragment,{children:[e.jsx(E,{}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] font-mono",children:[e.jsx("span",{className:"text-fg-muted",children:"TRACE SRC:"}),p.inferredSrc?e.jsxs(e.Fragment,{children:[e.jsx(d,{fn:"inferredSrc",value:p.inferredSrc,color:"purple"}),p.inferredName&&e.jsx(d,{fn:"name",value:p.inferredName,color:"purple"})]}):e.jsx(S,{children:"unresolvable"}),e.jsx(_e,{color:"purple",children:p.method}),e.jsxs(S,{children:["(",p.confidence,")"]}),e.jsxs(S,{children:["siblings=",p.siblingCount]})]})]}),(()=>{const D=f.pType!=null?`0x${f.pType.toString(16).toUpperCase().padStart(2,"0")}`:void 0,L=t.route!=null?`0x${t.route.toString(16).toUpperCase().padStart(2,"0")}`:void 0,P=fe(m),R=f.signalClass==="excellent"||f.signalClass==="good"?"green":f.signalClass==="fair"?"amber":"red",b=f.senderTier==="pubkey"?"green":f.senderTier==="prefix"?"amber":f.senderTier==="encrypted"?"teal":"zinc",w=[{fn:"type",value:f.payloadTypeName,raw:D,group:"wire",color:"blue"},{fn:"route",value:f.routeTypeName,raw:L,group:"wire",color:"blue"},{fn:"src_hash",value:t.src_hash||void 0,group:"wire",color:"blue"},{fn:"rssi",value:`${t.rssi}dBm`,group:"wire",color:"blue"},{fn:"snr",value:`${t.snr}dB`,group:"wire",color:"blue"},{fn:"_byteLength",value:f.byteLen?`${f.byteLen}B`:void 0,group:"enrichment",color:"blue"},{fn:"_hopCount",value:String(n.hopCount),group:"enrichment",color:"blue"},{fn:"_isZeroHop",value:String(n.isZeroHop),group:"enrichment",color:"blue"},{fn:"_advertSender",value:n.advertSender||void 0,group:"enrichment",color:"blue"},{fn:"_advertNodeType",value:f.advertType!=="unknown"?f.advertType:void 0,group:"enrichment",color:"blue"},{fn:"_advertName",value:n.advertName||void 0,group:"enrichment",color:"blue"},{fn:"_channelHash",value:n.channelHash||void 0,group:"enrichment",color:"blue"},...P,{fn:"is_duplicate",value:String(h.isDuplicate),group:"analysis",color:"purple"},p!=null&&p.inferredSrc?{fn:"traceSrc",value:p.inferredSrc,group:"analysis",color:"purple"}:{fn:"traceSrc"},{fn:"_signalClass",value:f.signalClass,group:"analysis",color:R},{fn:"_routeClass",value:f.routeClass,group:"analysis",color:"purple"},{fn:"_senderTier",value:f.senderTier,group:"analysis",color:b},{fn:"_origin",value:f.origin,group:"analysis",color:f.origin==="tx_local"?"green":f.origin==="tx_forward"?"amber":"purple"},{fn:"_pathAvail",value:f.pathAvail?`${f.pathHopCount} hops`:"none",group:"analysis",color:f.pathAvail?"green":"zinc"},{fn:"_age",value:f.age,group:"analysis",color:f.age==="live"||f.age==="recent"?"green":"zinc"},...h.dupeCount>0?[{fn:"_dupeCount",value:`×${h.dupeCount}`,group:"analysis",color:"purple"},...h.rssiRange?[{fn:"_multipath",value:`Δ${Math.abs(h.rssiRange[1]-h.rssiRange[0])}dB`,group:"analysis",color:Math.abs(h.rssiRange[1]-h.rssiRange[0])>6?"amber":"green"}]:[]]:[],...t.lbt_attempts!=null?[{fn:"_lbt",value:`${t.lbt_attempts} attempt${t.lbt_attempts!==1?"s":""}`,group:"analysis",color:(t.lbt_attempts??0)>1?"amber":"green"}]:[],...t.drop_reason?[{fn:"_dropReason",value:t.drop_reason,group:"analysis",color:"red"}]:[]];return e.jsx(se,{tokens:w})})()]})})]})}function be(t){switch(t){case"excellent":return"green";case"good":return"green";case"fair":return"amber";case"poor":return"red";case"critical":return"red";default:return"zinc"}}function ye(t){return`${Math.round(t*100)}%`}function je(t,s,r){return t||(s?s.slice(0,12):`~${r}`)}function At({hops:t}){return t.length===0?null:e.jsxs("div",{className:"mt-2 pt-2 border-t border-edge-subtle/40",children:[e.jsx("p",{className:"text-[9px] text-fg-muted/40 uppercase tracking-widest font-mono mb-1.5",children:"per-hop trace inspection"}),e.jsx("div",{className:"space-y-1",children:t.map(s=>e.jsx(q,{prefix:`trace.hop[${s.hopIndex}]`,children:e.jsxs("div",{className:"border border-edge-subtle/40 rounded px-2 py-1.5",children:[e.jsxs(i,{label:"link",children:[e.jsx(re,{hops:[s.fromPrefix,s.toPrefix],color:"blue"}),e.jsx("span",{className:"ml-1.5",children:e.jsx(_e,{color:be(s.quality),children:s.quality})})]}),e.jsx(i,{label:"snr",children:e.jsx(F,{raw:e.jsx("span",{className:"text-sys-blue",children:s.snrRaw}),children:e.jsx(d,{fn:"snr",value:`${s.snrRaw.toFixed(1)} dB`,color:be(s.quality)})})}),e.jsxs(i,{label:"from",children:[e.jsx(d,{fn:"resolve",value:je(s.fromName,s.fromHash,s.fromPrefix),color:s.fromHash?s.fromConfidence>=.8?"green":"amber":"purple"}),e.jsx("span",{className:"ml-1",children:e.jsx(d,{fn:"conf",value:ye(s.fromConfidence),color:"zinc"})})]}),e.jsxs(i,{label:"to",children:[e.jsx(d,{fn:"resolve",value:je(s.toName,s.toHash,s.toPrefix),color:s.toHash?s.toConfidence>=.8?"green":"amber":"purple"}),e.jsx("span",{className:"ml-1",children:e.jsx(d,{fn:"conf",value:ye(s.toConfidence),color:"zinc"})})]})]})},s.hopIndex))}),e.jsx(se,{label:"trace contributes",tokens:Ft(t)})]})}function Ft(t){const s=t.reduce((n,l)=>n+(l.fromHash?1:0)+(l.toHash?1:0),0),r=t.length*2,c=r-s,a=t.length>0?t.reduce((n,l)=>n+l.snrRaw,0)/t.length:0;return[{fn:"hops",value:String(t.length),group:"wire",color:"blue"},{fn:"resolved",value:`${s}/${r}`,group:"worker",color:"green"},...c>0?[{fn:"ghosts",value:String(c),group:"worker",color:"purple"}]:[],{fn:"avgSnr",value:`${a.toFixed(1)} dB`,group:"analysis",color:a>=5?"green":a>=0?"amber":"red"}]}function Et(t){if(!t)return"never";const s=Math.floor((Date.now()-t)/1e3);return s<60?`${s}s ago`:s<3600?`${Math.floor(s/60)}m ago`:`${Math.floor(s/3600)}h ago`}function Ot(t){if(!t)return[];const s=t.decoded;if(!s)return[{fn:"decrypt.result",value:"failed",group:"crypto",color:"red"}];if(!s.decrypted)return[{fn:"decrypt.result",value:"no key match",group:"crypto",color:"zinc"}];const r=[];return s.channelName&&r.push({fn:"decrypt.channelName",value:s.channelName,group:"crypto",color:"teal"}),s.senderName&&r.push({fn:"decrypt.senderName",value:s.senderName,group:"crypto",color:"teal"}),s.text&&r.push({fn:"decrypt.text",value:s.text,group:"crypto",color:"teal"}),s.timestamp&&r.push({fn:"decrypt.timestamp",value:new Date(s.timestamp*1e3).toISOString().slice(11,19),group:"crypto",color:"teal"}),s.macCorrupted&&r.push({fn:"decrypt.macCorrupted",value:"true",group:"crypto",color:"amber"}),r}function zt({packet:t,decrypted:s,pipeline:r}){var b;const c=J(w=>w.isComputing),a=J(w=>w.lastUpdated),n=J(w=>w.lastComputeTimeMs),l=J(w=>w.topology.edges.length),o=J(w=>w.topology.discoveredNodes.length),x=tt(),m=st(),g=nt(),u=he(w=>w.isComputing),v=he(w=>w.nodeCount),N=me(w=>w.progress),f=me(w=>w.initialDecodeComplete),k=t.type??t.payload_type,$=k===O.GRP_TXT||k===O.GRP_DATA,h=k===O.TRACE,y=k===O.PATH,p=$,_=[{label:"full",detail:"all GRP_TXT → decryption worker",active:p&&f,color:"teal"},{label:"quick",detail:"100 most recent (initial load)",active:p&&!f,color:"amber"},{label:"skip",detail:"non-GRP or catchup path",active:!p,color:"zinc"}],H=Ot(s),C=((b=s==null?void 0:s.decoded)==null?void 0:b.decrypted)===!0,D=c?"running":`${l}e ${o}g`,L=u?"running":`${v}n`,P=p?C?"decrypted":N.isDecoding?`${N.percent}%`:"pending":"N/A",R=`topo ${c?"○":"✓"} ${D} · spark ${u?"○":"✓"} ${L} · decrypt ${P}`;return e.jsx(le,{stage:2,name:"CASCADE",fn:"hydrateDownstream()",verdict:R,children:e.jsx(q,{prefix:"cascade",children:e.jsxs("div",{className:"space-y-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 py-1.5 text-[11px] font-mono",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c?"bg-sys-amber animate-pulse":"bg-sys-green"}`}),e.jsx("span",{className:"text-fg-primary",children:"topology"}),e.jsxs("span",{className:"text-fg-muted",children:[l,"e ",o,"g"]}),(h||y)&&e.jsx("span",{className:"text-sys-green text-[9px]",children:"↑signal"})]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${u?"bg-sys-amber animate-pulse":"bg-sys-green"}`}),e.jsx("span",{className:"text-fg-primary",children:"sparkline"}),e.jsxs("span",{className:"text-fg-muted",children:[v,"n"]})]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${N.isDecoding?"bg-sys-amber animate-pulse":p?"bg-sys-teal":"bg-zinc-500/40"}`}),e.jsx("span",{className:"text-fg-primary",children:"decrypt"}),e.jsx("span",{className:p?"text-sys-teal":"text-fg-muted",children:p?C?"decrypted":N.isDecoding?`${N.percent}%`:"pending":"N/A"})]})]}),e.jsxs(G,{defaultOpen:h||y,children:[e.jsx(K,{className:"text-[10px] w-full border-t border-edge-subtle pt-1.5",children:e.jsx("span",{className:"font-mono text-fg-muted/50",children:"topology detail…"})}),e.jsx(V,{children:e.jsxs("div",{className:"ml-3 pb-2",children:[e.jsx(i,{label:"status",children:e.jsx(d,{fn:"isComputing",value:c?"running":"idle",color:c?"amber":"green"})}),e.jsxs(i,{label:"last",children:[e.jsx(d,{fn:"lastUpdated",value:Et(a),color:"zinc"}),n>0&&e.jsxs("span",{className:"ml-2 text-fg-muted text-[10px]",children:["(",n<1e3?`${n.toFixed(0)}ms`:`${(n/1e3).toFixed(1)}s`,")"]})]}),e.jsxs(i,{label:"output",children:[e.jsx(d,{fn:"edges",value:String(l),color:"green"}),e.jsx(d,{fn:"ghostNodes",value:String(o),color:"purple"})]}),m&&e.jsxs(e.Fragment,{children:[e.jsxs(i,{label:"trace links",children:[e.jsx(d,{fn:"directed",value:String(x.totalDirectedLinks),color:"teal"}),e.jsx(d,{fn:"bidir",value:String(x.bidirectionalLinks),color:"teal"}),e.jsx(d,{fn:"traces",value:String(x.totalTraces),color:"zinc"})]}),e.jsxs(i,{label:"trace SNR",children:[e.jsx(d,{fn:"mean",value:`${x.meanSnr.toFixed(1)} dB`,color:x.meanSnr>=5?"green":x.meanSnr>=0?"amber":"red"}),e.jsx(d,{fn:"median",value:`${x.medianSnr.toFixed(1)} dB`,color:"zinc"}),e.jsx(d,{fn:"confidence",value:`${Math.round(x.avgConfidence*100)}%`,color:"zinc"})]}),h&&e.jsxs(i,{label:"quality",children:[e.jsx(d,{fn:"excellent",value:String(x.qualityCounts.excellent),color:"green"}),e.jsx(d,{fn:"good",value:String(x.qualityCounts.good),color:"green"}),e.jsx(d,{fn:"fair",value:String(x.qualityCounts.fair),color:"amber"}),e.jsx(d,{fn:"poor",value:String(x.qualityCounts.poor),color:"red"}),e.jsx(d,{fn:"critical",value:String(x.qualityCounts.critical),color:"red"})]}),g.confirmedResolutions.size>0&&e.jsxs(i,{label:"feedback",children:[e.jsx(d,{fn:"feedback.confirmed",value:String(g.confirmedResolutions.size),color:"teal"}),e.jsx(d,{fn:"feedback.links",value:String(g.confirmedLinks.length),color:"teal"})]})]}),h&&(r==null?void 0:r.traceHopDetail)&&e.jsx(At,{hops:r.traceHopDetail})]})})]}),p&&e.jsx("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:e.jsxs("div",{className:"ml-3",children:[e.jsx(i,{label:"mode",children:e.jsx(ae,{options:_,nextFn:"queueDecryption()"})}),e.jsx(i,{label:"result",children:e.jsx(d,{fn:"decrypt",value:C?"decrypted":s?"failed":"pending",color:C?"teal":s?"red":"zinc"})}),C&&e.jsx("div",{className:"mt-1 flex flex-wrap gap-x-1.5 gap-y-1",children:H.map((w,oe)=>e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5",children:e.jsx(d,{fn:w.fn,value:w.value,color:w.color})},oe))})]})}),(()=>{const w=[{fn:"topology.edges",value:String(l),group:"worker",color:"green"},{fn:"topology.ghostNodes",value:String(o),group:"worker",color:"purple"},{fn:"sparkline.nodes",value:`${v}`,group:"worker",color:"green"},...m?[{fn:"trace.directedLinks",value:String(x.totalDirectedLinks),group:"worker",color:"teal"},{fn:"trace.meanSnr",value:`${x.meanSnr.toFixed(1)} dB`,group:"worker",color:"teal"}]:[],...H];return e.jsx(se,{tokens:w})})()]})})})}function Bt(t,s,r,c){var n;const a=t.src_hash?Se(t.src_hash):"";if(t._advertSender&&s.hash&&s.confident)return{tier:1,label:"_advertSender → pubkey",detail:"ADVERT carried full 32-byte public key — definitive match"};if(c&&s.confident&&((n=s.name)==null?void 0:n.toLowerCase())===c.toLowerCase())return{tier:1.5,label:"decrypt.senderName → nameToHash",detail:`Decrypted sender name “${c}” matched neighbor — high-confidence`};if(a&&r.crossClassPrefixes.has(a))return{tier:2,label:"cross-class prefix",detail:"Prefix has mixed types (repeater + non-repeater); payload type narrows to one class"};if(s.confident){const l=r.prefixIndex.get(a);return(l==null?void 0:l.length)===1?{tier:3,label:"single candidate",detail:"Only one node matches this prefix — unambiguous"}:{tier:3,label:"resolver",detail:"Multi-signal scoring selected best candidate from collision set"}}return{tier:4,label:"ambiguous",detail:"Cannot confidently resolve — multiple same-class candidates, insufficient scoring separation"}}function It(t,s){const r=t.original_path??t.forwarded_path,c=new Set;if(r&&Array.isArray(r))for(const a of r){const n=String(a).toUpperCase().slice(0,2);n.length>=2&&n!==s&&c.add(n)}return c}function Gt(t,s,r,c,a,n,l){const o=Math.floor(Date.now()/1e3),x=new Map(r.map(m=>[m.hash,m]));return t.map(m=>{const g=s[m.hash],u=x.get(m.hash);let v=!0,N="";c!=="unknown"?m.type!=="unknown"&&m.type!==c?(v=!1,N=`${m.type} ≠ required ${c}`):m.type===c?N="type matches":N="type unknown — not ruled out":N="payload ambiguous — all types eligible";const f=!!(g!=null&&g.zero_hop),k=(g==null?void 0:g.last_seen)??0;let $=0;if(f&&k>0){const b=(o-k)/3600;$=50*Math.exp(-b/l)}let h=0;if(k>0){const b=(o-k)/3600;h=Math.exp(-b/n)}const y=h*20,p=!!(g!=null&&g.latitude&&(g!=null&&g.longitude)&&(g.latitude!==0||g.longitude!==0)),_=p?5:0,H=(u==null?void 0:u.advertCount)??0,C=Math.min(H*2,30),D=(u==null?void 0:u.forwarderPrefixes.size)??0,L=Math.min(D*3,15);let P=0;if(u&&u.totalForwarderObservations>0&&a.size>0){let b=0;for(const w of a)u.forwarderPrefixes.has(w)&&b++;P=b/a.size}const R=$+y+_+C+L;return{hash:m.hash,name:m.name,type:m.type,roleCompatible:v,roleReason:N,zeroHop:f,zeroHopScore:$,lastSeen:k,recencyScore:h,recencyPoints:y,hasGps:p,gpsScore:_,advertCount:H,advertScore:C,topoWidth:D,topoScore:L,affinity:P,total:R}}).sort((m,g)=>g.total-m.total)}function Kt({packet:t,pipeline:s,resolved:r,resolveTimeMs:c,advertName:a,neighbors:n,decrypted:l}){var ie,de;const o=Y(j=>j.neighborContext),x=Y(j=>j.topologyProfiles),m=Y(j=>j.config),{analysis:g}=s,u=r??{hash:null,type:"unknown",name:null,confident:!1},v=t.src_hash?Se(t.src_hash):"",N=v?o.prefixIndex.get(v)??[]:[],f=v?x.get(v)??[]:[],k=g.pType??-1,$=k>=0?k.toString(16).toUpperCase().padStart(2,"0"):"??",h=g.inferredType,y=g.advertType,p=g.effectiveType,_=t._advertNodeType!=null?t._advertNodeType.toString(16).padStart(2,"0").toUpperCase():"",H=((ie=l==null?void 0:l.decoded)==null?void 0:ie.senderName)??null,C=Bt(t,u,o,H),D=T.useMemo(()=>It(t,v),[t,v]),L=g.pathLen,P=T.useMemo(()=>Gt(N,n,f,p,D,m.recencyDecayHours,m.zeroHopDecayHours),[N,n,f,p,D,m.recencyDecayHours,m.zeroHopDecayHours]),R=P.filter(j=>!j.roleCompatible),b=P.filter(j=>j.roleCompatible),w=t._advertSender?o.pubKeyMap.get(t._advertSender)??null:null,oe=C.tier===1,De=[{fn:"src_hash",value:v||"",active:!!v,color:"blue"},{fn:"_advertSender",value:t._advertSender?t._advertSender.slice(0,12)+"…":"",active:!!t._advertSender,color:"blue"},{fn:"_advertNodeType",value:_?`0x${_}`:"",active:t._advertNodeType!=null,color:"blue"},{fn:"path_length",value:L!=null?L===0?"zero-hop":String(L):"",active:L!=null,color:"blue"},{fn:"decrypt.senderName",value:H??"",active:!!H,color:"teal"}],Le=[{label:"hit",detail:"pubKeyMap.get(_advertSender) → definitive",active:!!w,color:"green"},{label:"miss",detail:t._advertSender?"pubkey not in neighbor table":"no _advertSender",active:!w,color:"zinc"}],Pe=[{label:"payload",detail:`inferDeviceType(0x${$}) → ${h}`,active:h!=="unknown",color:"amber"},{label:"flags",detail:_?`mapAdvertTypeCode(0x${_}) → ${y}`:"no _advertNodeType",active:h==="unknown"&&y!=="unknown",color:"green"},{label:"ambiguous",detail:"all types eligible",active:p==="unknown",color:"zinc"}],Me=u.name??((de=u.hash)==null?void 0:de.slice(0,12))??"?",Re=u.confident?"confident":"ambiguous",Ae=`→ ${Me} (${Re}, Tier ${C.tier})`;return e.jsx(le,{stage:3,name:"RESOLVE",fn:"usePipelineStore.resolveSource()",verdict:Ae,timeMs:c,children:e.jsx(q,{prefix:"resolvePacketSource",children:e.jsxs("div",{className:"space-y-0",children:[e.jsx("div",{className:"pt-1 pb-1",children:e.jsx(Ct,{tokens:De,nextFn:"resolvePacketSource()"})}),t.src_hash?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"1"})," ","PUBKEY LOOKUP"]}),e.jsx(ae,{options:Le,nextFn:"pubKeyMap.get()"}),e.jsx("div",{className:"ml-3 mt-1",children:w?e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"resolved",children:e.jsx(d,{fn:"hash",value:w,color:"green"})}),a&&e.jsxs(i,{label:"name",children:[e.jsx(d,{fn:"name",value:a,color:"green"}),u.name&&a===u.name&&e.jsx(S,{c:"text-sys-green ml-1",children:"✓ neighbor match"})]}),e.jsxs(i,{label:"result",children:[e.jsx(M,{color:"green",children:"Tier 1"}),e.jsx(S,{c:"text-fg-primary ml-1",children:"definitive — scoring bypassed"})]})]}):t._advertSender?e.jsx(i,{label:"status",children:e.jsx(S,{c:"text-sys-amber",children:"✗ pubkey not in neighbor table"})}):e.jsx(i,{label:"status",children:e.jsx(S,{children:"no _advertSender — skip to prefix resolution"})})})]}),oe?e.jsx("div",{className:"border-t border-edge-subtle py-2",children:e.jsx("p",{className:"text-[11px] text-fg-muted/40 font-mono ml-3",children:"Steps 2–5 bypassed — pubkey definitive"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"2"})," ","CANDIDATE POOL — ",N.length," node",N.length!==1?"s":"",' match "',v,'"']}),e.jsxs("div",{className:"space-y-0.5 ml-3",children:[P.map(j=>e.jsxs("div",{className:"flex gap-2 items-center text-[11px]",children:[e.jsx("span",{className:"break-all text-[10px]",children:j.hash}),e.jsx(M,{color:"zinc",children:j.type||"unknown"}),j.name&&e.jsx(S,{children:j.name})]},j.hash)),N.length===0&&e.jsx(S,{children:"no known nodes for this prefix"})]})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"3"})," ","TYPE INFERENCE"]}),e.jsx(ae,{options:Pe,nextFn:"effectiveType()"}),e.jsx("div",{className:"ml-3 mt-1",children:e.jsx(i,{label:"effective",children:e.jsx(d,{fn:"effectiveType",value:p,color:p!=="unknown"?h!=="unknown"?"amber":"green":"zinc"})})})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"4"})," ","ROLE-TYPE SCRUB"]}),e.jsx("div",{className:"space-y-0.5 ml-3",children:P.map(j=>e.jsxs("div",{className:"flex gap-2 items-center text-[11px]",children:[e.jsx("span",{className:j.roleCompatible?"text-sys-green":"text-sys-red",children:j.roleCompatible?"✓":"✗"}),e.jsx("span",{className:`break-all text-[10px] ${j.roleCompatible?"":"line-through text-fg-muted"}`,children:j.hash}),e.jsx(M,{color:j.roleCompatible?"zinc":"red",children:j.type||"unknown"}),e.jsx(S,{c:j.roleCompatible?"text-fg-muted":"text-sys-red",children:j.roleReason})]},j.hash))}),R.length>0&&e.jsxs("p",{className:"text-[10px] text-fg-muted mt-1 ml-3",children:[R.length," eliminated, ",b.length," surviving"]})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"5"})," ","CANDIDATE SCORING"]}),b.length===0?e.jsx("p",{className:"text-fg-muted italic ml-3",children:"No surviving candidates"}):b.length===1?e.jsxs("div",{className:"ml-3 text-[11px]",children:[e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(S,{c:"text-sys-green",children:"→"}),e.jsx("span",{className:"break-all text-[10px]",children:b[0].hash}),b[0].name&&e.jsx(S,{c:"text-fg-muted ml-1",children:b[0].name})]}),e.jsx("p",{className:"text-fg-muted ml-4",children:"single survivor — scoring not needed"})]}):e.jsxs(G,{children:[e.jsx(K,{className:"text-[10px] ml-3",children:e.jsxs("span",{className:"font-mono text-fg-muted/50",children:[b.length," candidates scored…"]})}),e.jsx(V,{children:e.jsx("div",{className:"space-y-2 ml-3 mt-1",children:b.map(j=>{const Q=j.hash===u.hash;return e.jsxs("div",{className:`text-[11px] leading-relaxed rounded px-2 py-1 ${Q?"bg-sys-green/8 border border-sys-green/20":"bg-zinc-500/5"}`,children:[e.jsxs("div",{className:"flex gap-2 items-center mb-0.5",children:[e.jsx(S,{c:Q?"text-sys-green":"text-fg-muted",children:Q?"→":" "}),e.jsx("span",{className:`break-all text-[10px] ${Q?"text-fg-primary":"text-fg-muted"}`,children:j.hash}),e.jsx(M,{color:Q?"green":"zinc",children:j.type||"unknown"}),j.name&&e.jsx(S,{children:j.name})]}),e.jsxs("div",{className:"ml-4 flex flex-wrap gap-x-3 gap-y-0.5",children:[e.jsxs("span",{children:[e.jsx(S,{children:"zero_hop:"})," ",e.jsx(S,{c:j.zeroHop?"text-sys-green":"text-fg-muted",children:j.zeroHop?"✓":"✗"})," ",e.jsxs(M,{color:ee(j.zeroHopScore),children:["+",j.zeroHopScore]})]}),e.jsxs("span",{children:[e.jsx(S,{children:"recency:"})," ",e.jsx(S,{c:"text-fg-primary",children:mt(j.lastSeen)})," ",e.jsxs(M,{color:ee(j.recencyPoints),children:["+",j.recencyPoints.toFixed(1)]})]}),e.jsxs("span",{children:[e.jsx(S,{children:"gps:"})," ",e.jsx(S,{c:j.hasGps?"text-sys-green":"text-fg-muted",children:j.hasGps?"✓":"✗"})," ",e.jsxs(M,{color:ee(j.gpsScore),children:["+",j.gpsScore]})]}),e.jsxs("span",{children:[e.jsx(S,{children:"adverts:"})," ",e.jsx(S,{c:"text-fg-primary",children:j.advertCount})," ",e.jsxs(M,{color:ee(j.advertScore),children:["+",j.advertScore]})]}),e.jsxs("span",{children:[e.jsx(S,{children:"topo:"})," ",e.jsx(S,{c:"text-fg-primary",children:j.topoWidth})," ",e.jsxs(M,{color:ee(j.topoScore),children:["+",j.topoScore]})]})]}),e.jsxs("div",{className:"ml-4 mt-0.5",children:[e.jsx(S,{children:"score ≈"})," ",e.jsx(S,{c:"text-fg-primary font-bold",children:j.total.toFixed(1)})]})]},j.hash)})})})]})]})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-green font-bold",children:"✓"})," ","RESOLUTION"]}),e.jsxs("div",{className:"ml-3",children:[e.jsx(i,{label:"hash",children:u.hash?e.jsx(d,{fn:"resolved.hash",value:u.hash,color:"green"}):e.jsx(S,{children:"null"})}),e.jsx(i,{label:"type",children:e.jsx(d,{fn:"resolved.type",value:u.type,color:u.confident?"green":"zinc"})}),e.jsx(i,{label:"name",children:u.name?e.jsx(d,{fn:"resolved.name",value:u.name,color:u.confident?"green":"amber"}):e.jsx(S,{children:"null"})}),e.jsx(i,{label:"confident",children:e.jsx(S,{c:u.confident?"text-sys-green":"text-sys-red",children:String(u.confident)})}),e.jsxs(i,{label:"tier",children:[e.jsx(M,{color:C.tier<=2?"green":C.tier===3?"amber":"red",children:C.tier}),e.jsx(S,{c:"text-fg-primary ml-1",children:C.label})]})]})]})]}):e.jsx("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] font-mono",children:[e.jsx(S,{c:"text-sys-amber",children:"⚠ no src_hash"}),H&&e.jsx(d,{fn:"decrypt.senderName",value:H,color:"teal"}),u.confident?e.jsxs(S,{c:"text-sys-green",children:["→ resolved via ",C.label]}):e.jsx(S,{c:"text-sys-red",children:"ambiguous"})]})}),(()=>{const j=[{fn:"resolved.hash",value:u.hash??"null",group:"resolution",color:u.confident?"green":"zinc"},{fn:"resolved.type",value:u.type,group:"resolution",color:u.type!=="unknown"?u.confident?"green":"amber":"zinc"},{fn:"resolved.name",value:u.name??"null",group:"resolution",color:u.confident?"green":u.name?"amber":"zinc"},{fn:"resolved.confident",value:String(u.confident),group:"resolution",color:u.confident?"green":"red"}];return e.jsx(se,{tokens:j})})()]})})})}const Vt={id:"packet-parse",label:"Packet Parse",inputs:["rawPacket"],outputs:["parsedPacket","decoded","headerFields"],emits:[{fn:"routeType",group:"wire",color:"blue"},{fn:"payloadType",group:"wire",color:"blue"},{fn:"pathLength",group:"wire",color:"blue"},{fn:"version",group:"wire",color:"blue"}],async:!1,observatoryStage:0},qt={id:"enrichment",label:"Ingestion Enrichment",inputs:["parsedPacket"],outputs:["advertSender","channelHash","hopData","byteLength"],emits:[{fn:"_advertSender",group:"enrichment",color:"blue"},{fn:"_advertNodeType",group:"enrichment",color:"blue"},{fn:"_channelHash",group:"enrichment",color:"blue"},{fn:"_hopCount",group:"enrichment",color:"blue"},{fn:"_isZeroHop",group:"enrichment",color:"blue"},{fn:"_byteLength",group:"enrichment",color:"blue"}],async:!1,observatoryStage:1},Ut={id:"topology",label:"Topology Analysis",inputs:["packets","neighbors","srcHashResolver"],outputs:["edges","nodeMetrics","pathHealth","ghostNodes","centrality","loops"],emits:[{fn:"edges",group:"worker",color:"green"},{fn:"ghostNodes",group:"worker",color:"purple"},{fn:"loops",group:"analysis",color:"amber"},{fn:"nodeMetrics",group:"worker",color:"green"},{fn:"pathHealth",group:"worker",color:"green"},{fn:"centrality",group:"worker",color:"green"}],async:!0,worker:"topology.worker.ts",observatoryStage:2},Wt={id:"trace-enrichment",label:"Trace Link Quality",inputs:["packets","prefixLookup","srcHashResolver","edges","pathHealth","nodeMetrics"],outputs:["traceLinks","traceLinkSummary","traceDisambiguationFeedback"],emits:[{fn:"traceLinks.directed",group:"worker",color:"teal"},{fn:"traceLinks.bidir",group:"worker",color:"teal"},{fn:"traceSummary.meanSnr",group:"analysis",color:"green"},{fn:"traceSummary.medianSnr",group:"analysis",color:"zinc"},{fn:"traceSummary.confidence",group:"analysis",color:"zinc"},{fn:"feedback.confirmed",group:"worker",color:"teal"},{fn:"feedback.links",group:"worker",color:"teal"}],async:!1,observatoryStage:2},Yt={id:"disambiguation",label:"Source Disambiguation",inputs:["packets","neighbors","decodedMessages"],outputs:["srcHashResolverMap","neighborContext"],emits:[{fn:"resolvedHash",group:"resolution",color:"purple"},{fn:"resolvedName",group:"resolution",color:"purple"},{fn:"resolvedType",group:"resolution",color:"purple"},{fn:"confidence",group:"resolution",color:"green"}],async:!1,observatoryStage:3},Zt={id:"sparkline",label:"Sparkline Computation",inputs:["packets","neighbors"],outputs:["sparklineData"],emits:[{fn:"sparklines",group:"worker",color:"blue"}],async:!0,worker:"sparkline.worker.ts"},Xt={id:"decryption",label:"Channel Decryption",inputs:["packets","channelKeys"],outputs:["decodedMessages"],emits:[{fn:"decrypt.text",group:"crypto",color:"teal"},{fn:"decrypt.senderName",group:"crypto",color:"teal"},{fn:"decrypt.channelName",group:"crypto",color:"teal"},{fn:"decrypt.macCorrupted",group:"crypto",color:"amber"}],async:!0,worker:"decryption.worker.ts",observatoryStage:2},Qt={id:"decoded-content",label:"Decoded Content Policy",inputs:["decodedMessages","packets"],outputs:["decodedContent","contentInheritance"],emits:[{fn:"content.senderName",group:"crypto",color:"teal"},{fn:"content.text",group:"crypto",color:"teal"},{fn:"content.channelName",group:"crypto",color:"teal"},{fn:"content.corrupted",group:"crypto",color:"amber"},{fn:"content.inherited",group:"analysis",color:"purple"}],async:!1},Z=[Vt,qt,Ut,Wt,Yt,Zt,Xt,Qt],Jt=new Map(Z.map(t=>[t.id,t])),es=new Map;for(const t of Z)for(const s of t.emits)es.set(s.fn,t);const $e=new Map;for(const t of Z)for(const s of t.outputs)$e.set(s,t);function ts(){const t=new Map,s=new Map;for(const a of Z)t.has(a.id)||t.set(a.id,0),s.has(a.id)||s.set(a.id,new Set);for(const a of Z)for(const n of a.inputs){const l=$e.get(n);if(l&&l.id!==a.id){const o=s.get(l.id);o.has(a.id)||(o.add(a.id),t.set(a.id,(t.get(a.id)??0)+1))}}const r=[];for(const[a,n]of t)n===0&&r.push(a);const c=[];for(;r.length>0;){const a=r.shift(),n=Jt.get(a);n&&c.push(n);for(const l of s.get(a)??[]){const o=(t.get(l)??1)-1;t.set(l,o),o===0&&r.push(l)}}for(const a of Z)c.includes(a)||c.push(a);return c}const ss={0:"text-sys-green",1:"text-sys-blue",2:"text-sys-teal",3:"text-sys-purple"};function ns({stage:t,isActive:s,onClick:r}){const c=t.observatoryStage!=null?ss[t.observatoryStage]??"text-fg-muted":"text-fg-muted/40";return e.jsxs("button",{type:"button",onClick:r,className:` + flex items-center gap-1.5 w-full px-1.5 py-1 rounded transition-base text-left + ${s?"bg-sys-blue/10 ring-1 ring-sys-blue/30":"hover:bg-zinc-500/5"} + `,children:[e.jsx("span",{className:`font-mono text-[9px] font-bold w-3 shrink-0 text-center ${c}`,children:t.observatoryStage??"·"}),e.jsx("span",{className:"font-mono text-[9px] text-fg-primary truncate flex-1",children:t.label}),t.async&&e.jsx("span",{className:"font-mono text-[7px] px-1 py-px rounded bg-sys-amber/15 text-sys-amber shrink-0 leading-tight",children:"⚡"}),t.emits.length>0&&e.jsxs("span",{className:"flex items-center gap-px shrink-0",children:[t.emits.slice(0,6).map(a=>{var n;return e.jsx("span",{className:`inline-block w-1 h-1 rounded-full ${((n=I[a.color])==null?void 0:n.dot)??"bg-zinc-500"}`,title:`${a.fn} [${a.group}]`},a.fn)}),t.emits.length>6&&e.jsxs("span",{className:"font-mono text-[7px] text-fg-muted/40 ml-0.5",children:["+",t.emits.length-6]})]})]})}function rs({activeStageId:t,onStageClick:s}){const r=T.useMemo(()=>ts(),[]),c=T.useMemo(()=>{const a=new Map;for(const l of r){const o=l.observatoryStage??"other";let x=a.get(o);x||(x=[],a.set(o,x)),x.push(l)}const n=[];for(const l of[0,1,2,3,"other"]){const o=a.get(l);o!=null&&o.length&&n.push({key:l,stages:o})}return n},[r]);return e.jsxs("div",{className:"surface-base rounded-lg border border-edge-subtle p-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-mono text-[8px] text-fg-muted/40 uppercase tracking-widest",children:"Pipeline DAG"}),e.jsxs("span",{className:"font-mono text-[8px] text-fg-muted/30",children:[r.length," stages"]})]}),e.jsx("div",{className:"space-y-px",children:c.map((a,n)=>e.jsxs("div",{children:[n>0&&e.jsx("div",{className:"flex items-center pl-2.5 py-px",children:e.jsx("svg",{width:"6",height:"8",viewBox:"0 0 6 8",className:"text-fg-muted/20",children:e.jsx("path",{d:"M3 0 L3 6 M1 4 L3 6 L5 4",fill:"none",stroke:"currentColor",strokeWidth:"1"})})}),a.stages.map(l=>e.jsx(ns,{stage:l,isActive:t===l.id,onClick:s?()=>s(l.id):void 0},l.id))]},String(a.key)))})]})}const ve=200,z={status:"idle",lastDurationMs:null,lastTs:null,runCount:0};function as(t,s,r){var c,a,n;switch(t.type){case"transport:ws:state":s.wsState=((c=t.data)==null?void 0:c.state)??r.wsState;break;case"transport:ws:packet":s.wsPacketCount=(s.wsPacketCount??r.wsPacketCount)+1;break;case"transport:ws:stats":s.wsStatsCount=(s.wsStatsCount??r.wsStatsCount)+1;break;case"transport:rest:stats":s.restStatsCount=(s.restStatsCount??r.restStatsCount)+1;break;case"transport:rest:packets":s.restPacketsCount=(s.restPacketsCount??r.restPacketsCount)+1;break;case"store:packets:ws-merge":s.wsMergeCount=(s.wsMergeCount??r.wsMergeCount)+1;break;case"cascade:hydrate":s.lastHydrateTs=t.ts,s.hydrateCount=(s.hydrateCount??r.hydrateCount)+1;break;case"worker:topology:start":case"worker:sparkline:start":{const l=t.type.split(":")[1],o=s.workers??r.workers,x=o[l]??{...z};s.workers={...o,[l]:{...x,status:"running",lastTs:t.ts}}}break;case"worker:topology:done":case"worker:sparkline:done":{const l=t.type.split(":")[1],o=s.workers??r.workers,x=o[l]??{...z},m=((a=t.data)==null?void 0:a.ms)??null;s.workers={...o,[l]:{...x,status:"done",lastDurationMs:m,lastTs:t.ts,runCount:x.runCount+1}}}break;case"worker:decryption:batch":{const l=s.workers??r.workers,o=l.decryption??{...z},x=((n=t.data)==null?void 0:n.ms)??null;s.workers={...l,decryption:{...o,status:"done",lastDurationMs:x,lastTs:t.ts,runCount:o.runCount+1}}}break;case"pipeline:disambig:recompute":s.disambigCount=(s.disambigCount??r.disambigCount)+1;break}}const te=rt(t=>({events:[],eventCount:0,wsState:"disconnected",wsPacketCount:0,wsStatsCount:0,restStatsCount:0,restPacketsCount:0,workers:{topology:{...z},sparkline:{...z},decryption:{...z}},wsMergeCount:0,lastHydrateTs:null,hydrateCount:0,disambigCount:0,lastDisambigMs:null,_pushBatch:s=>t(r=>{if(s.length===0)return r;let c=[...r.events,...s];c.length>ve&&(c=c.slice(c.length-ve));const a={events:c,eventCount:r.eventCount+s.length};for(const n of s)as(n,a,r);return a}),clear:()=>t({events:[],eventCount:0,wsState:"disconnected",wsPacketCount:0,wsStatsCount:0,restStatsCount:0,restPacketsCount:0,workers:{topology:{...z},sparkline:{...z},decryption:{...z}},wsMergeCount:0,lastHydrateTs:null,hydrateCount:0,disambigCount:0,lastDisambigMs:null})}));let W=null,B=[],X=null;function ls(){if(X=null,B.length===0)return;const t=B;B=[],te.getState()._pushBatch(t)}function os(){W||(B=[],W=at.subscribe(t=>{B.push(t),X===null&&(X=requestAnimationFrame(ls))}))}function cs(){if(W==null||W(),W=null,X!==null&&(cancelAnimationFrame(X),X=null),B.length>0){const t=B;B=[],te.getState()._pushBatch(t)}}function is(t){switch(t){case"active":return"●";case"skipped":return"○";case"inferred":return"◌"}}function ds(t){switch(t){case"active":return"text-sys-green";case"skipped":return"text-fg-muted/30";case"inferred":return"text-sys-amber"}}function us(t){switch(t){case"transport":return"text-sys-blue";case"store":return"text-sys-amber";case"worker":return"text-sys-violet";case"pipeline":return"text-sys-green";case"consumer":return"text-sys-teal"}}function ps(t,s,r,c,a){var m,g;const n=[];if(a?n.push({label:"Hex Input",detail:"Manual hex — no transport",status:"skipped",lane:"transport"}):s.age==="live"||s.age==="recent"?n.push({label:"WebSocket",detail:"ws:packet → real-time push",status:"active",lane:"transport"}):n.push({label:"REST Poll",detail:"fetchPackets → packetCache.poll()",status:"inferred",lane:"transport"}),!a){n.push({label:"Cache Merge",detail:"packetCache.mergePacketsDirectly()",status:"active",lane:"store"});const u=s.age==="live"||s.age==="recent";n.push({label:"Flash",detail:u?"flashReceived++ → sidebar blink":"Not newest — no flash",status:u?"active":"skipped",lane:"store"}),n.push({label:"Hydrate Cascade",detail:"hydrateDownstream() → schedule workers",status:"active",lane:"store"})}const l=s.pathAvail||s.pathHopCount>0;n.push({label:"Topology Worker",detail:l?`Path data (${s.pathHopCount} hops) → edge extraction`:"No path data — still included in batch recompute",status:"active",lane:"worker"}),n.push({label:"Sparkline Worker",detail:`Contributes to sparkline for src ${((m=t.src_hash)==null?void 0:m.slice(0,4))??"??"}`,status:"active",lane:"worker"});const o=s.isGrp;n.push({label:"Decryption Worker",detail:o?`GRP_TXT → queued for channel key search${c?" → decrypted ✓":""}`:`${s.payloadTypeName} — not encrypted, skipped`,status:o?"active":"skipped",lane:"worker"}),n.push({label:"Source Disambiguation",detail:r?`→ ${r.name??((g=r.hash)==null?void 0:g.slice(0,8))??"?"} (${r.type}${r.confident?", confident":", ambiguous"})`:"Pending recompute",status:r?"active":"inferred",lane:"pipeline"}),s.isAdvert&&n.push({label:"ADVERT Discovery",detail:"pubkey → extended hash-to-type + name extraction",status:"active",lane:"pipeline"}),o&&(c!=null&&c.decoded)&&n.push({label:"Decoded Content Policy",detail:`macCorrupted=${c.decoded.macCorrupted?"true":"false"} → cross-hash inheritance`,status:"active",lane:"pipeline"});const x=["Packets","Dashboard","Statistics"];return l&&x.push("Map","Graph"),s.isTrace&&x.push("Trace Detail"),n.push({label:"Page Hydration",detail:x.join(", "),status:"active",lane:"consumer"}),n}const xs=[],hs=["transport","store","worker","pipeline","consumer"],ms={transport:"Transport",store:"Store",worker:"Workers",pipeline:"Pipeline",consumer:"Consumers"};function gs(t){return t.replace("transport:","").replace("store:packets:","").replace("cascade:","").replace("worker:","w:").replace("pipeline:","p:").replace("packet","pkt").replace("sparkline","spark").replace("topology","topo").replace("decryption","dec").replace("disambig","dis").replace("recompute","recomp")}function fs(t){return t.startsWith("transport:")?"text-sys-blue":t.startsWith("store:")||t.startsWith("cascade:")?"text-sys-amber":t.startsWith("worker:")?"text-sys-violet":t.startsWith("pipeline:")?"text-sys-green":"text-fg-muted"}const bs=T.memo(function({event:s}){const r=`${(s.ts/1e3).toFixed(1)}s`,c=s.data?Object.entries(s.data).map(([a,n])=>{var l;return`${a}=${typeof n=="number"?((l=n.toFixed)==null?void 0:l.call(n,1))??n:n}`}).join(" "):"";return e.jsxs("div",{className:"flex gap-2 text-[9px] font-mono leading-tight",children:[e.jsx("span",{className:"text-fg-muted/40 w-12 shrink-0 text-right",children:r}),e.jsx("span",{className:`w-20 shrink-0 ${fs(s.type)}`,children:gs(s.type)}),e.jsx("span",{className:"text-fg-muted/60 truncate",children:c})]})});function ys({packet:t,pipeline:s,resolved:r,decrypted:c,isSynthetic:a,liveMode:n}){const[l,o]=T.useState(!1);T.useEffect(()=>{if(l)return os(),()=>{cs()}},[l]);const x=s==null?void 0:s.analysis,m=T.useMemo(()=>!t||!x?null:ps(t,x,r,c,a),[t,x,r,c,a]),g=T.useMemo(()=>{if(!m)return null;const h=new Map;for(const y of m){let p=h.get(y.lane);p||(p=[],h.set(y.lane,p)),p.push(y)}return h},[m]),u=te(h=>l?h.events:xs),v=te(h=>l?h.eventCount:0),N=te(h=>h.clear),f=T.useRef(null);T.useEffect(()=>{l&&f.current&&(f.current.scrollTop=f.current.scrollHeight)},[v,l]);const k=(m==null?void 0:m.filter(h=>h.status==="active").length)??0,$=(m==null?void 0:m.length)??0;return e.jsxs(G,{defaultOpen:!0,children:[e.jsx(K,{className:"text-[10px]",children:e.jsxs("span",{className:"flex items-center gap-2 font-mono",children:[e.jsx("span",{className:"text-sys-green",children:"CFT"}),e.jsx("span",{className:"text-fg-muted/40",children:"Control Flow Trace"}),t&&e.jsxs("span",{className:"text-fg-muted/30",children:["— ",k,"/",$," stages active"]})]})}),e.jsx(V,{children:e.jsxs("div",{className:"surface-base rounded-lg border border-edge-subtle p-3 space-y-3",children:[t?g?e.jsx("div",{className:"space-y-2",children:hs.map(h=>{const y=g.get(h);return y?e.jsxs("div",{children:[e.jsx("div",{className:`text-[8px] uppercase tracking-widest font-mono mb-0.5 ${us(h)}`,children:ms[h]}),y.map((p,_)=>e.jsxs("div",{className:"flex items-start gap-1.5 text-[10px] font-mono leading-snug ml-1",children:[e.jsx("span",{className:`shrink-0 ${ds(p.status)}`,children:is(p.status)}),e.jsx("span",{className:"text-fg-primary",children:p.label}),e.jsx("span",{className:"text-fg-muted/50 truncate",children:p.detail})]},_))]},h):null})}):null:e.jsx("div",{className:"text-[9px] text-fg-muted/30 font-mono py-2 text-center",children:"Select a packet to trace its flow"}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 flex items-center gap-2",children:[e.jsx("button",{onClick:()=>o(h=>!h),className:`px-2 py-0.5 rounded text-[9px] font-mono transition-colors ${l?"bg-sys-green/20 text-sys-green":"bg-zinc-500/20 text-fg-muted hover:text-fg-primary"}`,children:l?"● LIVE":"○ LIVE"}),e.jsx("span",{className:"text-[9px] text-fg-muted/40 font-mono",children:l?`${v} events`:"Subscribe to all pipeline events"}),l&&e.jsx("button",{onClick:N,className:"text-[9px] text-fg-muted/40 hover:text-fg-muted font-mono transition-colors ml-auto",children:"clear"})]}),l&&e.jsx("div",{ref:f,className:"max-h-32 overflow-y-auto space-y-px",children:u.length===0?e.jsx("div",{className:"text-[9px] text-fg-muted/30 font-mono py-1 text-center",children:"Waiting for events…"}):u.map((h,y)=>e.jsx(bs,{event:h},`${h.ts}-${y}`))})]})})]})}function js(t){const s=Ne(t.type??t.payload_type??-1).padEnd(7),r=t.packet_hash.slice(0,8),c=(t.src_hash??"—").replace(/^0x/i,"").slice(0,4).toUpperCase(),a=t._hopCount!=null?`${t._hopCount}h`:"",n=dt(t.timestamp);return`${r} ${s} ←${c} ${t.rssi}dBm ${a} ${n}`}function Ts(){const t=lt(),s=ot(),r=ct(),c=(s==null?void 0:s.neighbors)??{},a=Y(b=>b.resolveSource),n=Y(b=>b.config),l=Y(b=>b.setConfig),[o,x]=T.useState(-1),m=T.useMemo(()=>{let b=t;return o!==-1&&(b=t.filter(w=>(w.type??w.payload_type)===o)),b.slice(-50).reverse()},[t,o]),[g,u]=T.useState(""),[v,N]=T.useState(""),[f,k]=T.useState(!1),$=T.useRef(r);T.useEffect(()=>{f&&r!==$.current&&m.length>0&&(u(m[0].packet_hash),N("")),$.current=r},[r,f,m]),T.useEffect(()=>{!g&&m.length>0&&!v&&u(m[0].packet_hash)},[g,m,v]);const h=T.useMemo(()=>v.trim()?null:m.find(b=>b.packet_hash===g)??null,[g,m,v]),y=T.useMemo(()=>{const b=v.replace(/\s+/g,"").trim();return b?{packet_hash:"manual-hex-input",timestamp:0,rssi:0,snr:0,transmitted:!1,drop_reason:null,is_duplicate:!1,raw_packet:b}:null},[v]),p=h??y,_=!!v.trim(),H=v.trim().replace(/\s+/g,"")||(p==null?void 0:p.raw_packet),C=wt(p,H,t),D=(C==null?void 0:C.enrichment)??He,L=Ce((p==null?void 0:p.packet_hash)??""),P=T.useRef(0),R=T.useMemo(()=>{if(!p)return null;const b=performance.now(),w=a(p);return P.current=performance.now()-b,w},[p,a]);return e.jsxs("div",{className:"max-w-[960px] mx-auto",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("h1",{className:"text-sm font-bold text-fg-primary tracking-wide font-mono",children:"PACKET OBSERVATORY"}),e.jsx("p",{className:"text-[11px] text-fg-muted font-mono",children:"Pipeline introspection — select a packet to trace its journey"})]}),e.jsxs("div",{className:"surface-base rounded-lg border border-edge-subtle p-3 mb-3",children:[e.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[e.jsxs("select",{value:o,onChange:b=>{x(Number(b.target.value)),u("")},className:"surface-input px-2 py-1 rounded text-[11px] font-mono text-fg-primary w-36",children:[e.jsx("option",{value:-1,children:"ALL TYPES"}),Object.entries(it).map(([b,w])=>e.jsxs("option",{value:Number(b),children:["0x",Number(b).toString(16).toUpperCase().padStart(2,"0")," ",w]},b))]}),e.jsxs("select",{value:g,onChange:b=>{u(b.target.value),N("")},className:"surface-input flex-1 min-w-0 px-2 py-1 rounded text-[11px] font-mono text-fg-primary truncate",children:[m.map((b,w)=>e.jsx("option",{value:b.packet_hash,children:js(b)},`${b.packet_hash}-${w}`)),m.length===0&&e.jsxs("option",{value:"",children:["No packets",o!==-1?" matching filter":" loaded"]})]}),e.jsx("button",{onClick:()=>k(b=>!b),className:`px-2 py-1 rounded text-[11px] font-mono transition-colors shrink-0 ${f?"bg-sys-green/20 text-sys-green":"bg-zinc-500/20 text-fg-muted hover:text-fg-primary"}`,children:f?"● LIVE":"○ LIVE"})]}),e.jsxs(G,{children:[e.jsx(K,{className:"text-[10px] text-fg-muted/50 hover:text-fg-muted mt-1.5",children:e.jsx("span",{className:"font-mono",children:"Paste hex…"})}),e.jsx(V,{children:e.jsx("textarea",{value:v,onChange:b=>N(b.target.value),placeholder:"Paste raw packet hex (overrides dropdown)",rows:2,className:"surface-input w-full mt-1 px-2 py-1 rounded text-[11px] font-mono text-fg-primary resize-y"})})]})]}),e.jsxs(G,{children:[e.jsx(K,{className:"text-[11px] mb-3 w-full",children:e.jsxs("span",{className:"flex items-center gap-2 font-mono",children:[e.jsx("span",{className:"text-fg-muted/50",children:"⚙"}),e.jsx("span",{className:"text-fg-muted/50",children:"Pipeline Config & Dev Tools"}),e.jsxs("span",{className:"text-fg-muted/30 text-[10px]",children:["disambig=",n.disambiguationEnabled?"on":"off"," mac=",n.macCorruptedPolicy," decay=",n.recencyDecayHours,"h"]})]})}),e.jsx(V,{children:e.jsxs("div",{className:"space-y-3 mb-4",children:[e.jsxs("div",{className:"surface-base rounded-lg border border-edge-subtle p-3",children:[e.jsx("h2",{className:"text-[10px] text-fg-muted/50 uppercase tracking-widest font-mono mb-2",children:"Pipeline Config"}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-[11px] text-fg-muted w-24 shrink-0",children:"Disambiguation"}),e.jsx("button",{onClick:()=>l({disambiguationEnabled:!n.disambiguationEnabled}),className:`px-2 py-0.5 rounded text-[11px] font-mono transition-colors ${n.disambiguationEnabled?"bg-sys-green/20 text-sys-green":"bg-sys-red/20 text-sys-red"}`,children:n.disambiguationEnabled?"● ON":"○ OFF"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-[11px] text-fg-muted w-24 shrink-0",children:"MAC policy"}),e.jsxs("select",{value:n.macCorruptedPolicy,onChange:b=>l({macCorruptedPolicy:b.target.value}),className:"surface-input px-1.5 py-0.5 rounded text-[11px] font-mono text-fg-primary",children:[e.jsx("option",{value:"strict",children:"strict (drop)"}),e.jsx("option",{value:"name-only",children:"name-only"}),e.jsx("option",{value:"permissive",children:"permissive"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-[11px] text-fg-muted w-24 shrink-0",children:"Recency decay"}),e.jsx("input",{type:"range",min:1,max:48,step:1,value:n.recencyDecayHours,onChange:b=>l({recencyDecayHours:Number(b.target.value)}),className:"flex-1 h-1 accent-sys-blue"}),e.jsxs("span",{className:"text-[11px] font-mono text-fg-primary w-8 text-right",children:[n.recencyDecayHours,"h"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-[11px] text-fg-muted w-24 shrink-0",children:"Zero-hop decay"}),e.jsx("input",{type:"range",min:12,max:168,step:6,value:n.zeroHopDecayHours,onChange:b=>l({zeroHopDecayHours:Number(b.target.value)}),className:"flex-1 h-1 accent-sys-blue"}),e.jsxs("span",{className:"text-[11px] font-mono text-fg-primary w-10 text-right",children:[n.zeroHopDecayHours,"h"]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsx(ys,{packet:p,pipeline:C,resolved:R,decrypted:L??null,isSynthetic:_,liveMode:f}),e.jsx(rs,{})]})]})})]}),p?e.jsxs("div",{className:"space-y-1",children:[e.jsx(kt,{packet:p,isSynthetic:_}),e.jsx(Rt,{packet:p,pipeline:C,rawHex:H,traceTagIndex:(C==null?void 0:C.traceTagIndex)??new Map,neighbors:c}),e.jsx(zt,{packet:p,decrypted:L??void 0,pipeline:C}),e.jsx(Kt,{packet:p,pipeline:C,resolved:R,decrypted:L??void 0,resolveTimeMs:P.current,neighbors:c,advertName:D.advertName})]}):e.jsx("div",{className:"surface-base rounded-lg border border-edge-subtle p-8 text-center",children:e.jsx("p",{className:"text-fg-muted text-xs",children:"Select a packet from the dropdown or paste hex above"})})]})}export{Ts as default}; diff --git a/frontend/dist/assets/PacketObservatory-CcMk90ki.js b/frontend/dist/assets/PacketObservatory-CcMk90ki.js deleted file mode 100644 index 782655f5..00000000 --- a/frontend/dist/assets/PacketObservatory-CcMk90ki.js +++ /dev/null @@ -1,5 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/usePipelineStore-CyFB3GIy.js","assets/index-C8IY8K2r.js","assets/node-types-3T9Wr7vI.js","assets/geo-utils-BP1zBK9h.js","assets/index-DUfCykEc.css"])))=>i.map(i=>d[i]); -import{bH as z,r as T,d$ as Ee,e0 as Fe,e1 as ze,e2 as Oe,bl as Be,e3 as Ie,e4 as Ge,e5 as Ve,e6 as Ue,bk as Ne,bo as ue,e7 as we,j as e,e8 as G,e9 as V,ea as U,dz as pe,eb as qe,q as R,bu as Ke,bE as Ce,bN as We,ec as Ye,ed as Ze,ee as Xe,ef as Qe,eg as Je,eh as J,ei as et,ej as tt,ek as st,el as xe,a3 as he,$ as Se,bh as nt,em as rt,y as at,E as lt,en as ot,b9 as ct,cV as it}from"./index-C8IY8K2r.js";import{b as dt,r as me,c as Y}from"./usePipelineStore-CyFB3GIy.js";import{e as Te,p as ut,a as pt,A as I,S as q,c as se,f as A,K as i,H as E,B as xt,R as F,T as d,P as re,h as ht,i as S,C as _e,s as ee,j as mt}from"./primitives-Ca8Zb5cD.js";import{m as ke,i as gt}from"./node-types-3T9Wr7vI.js";import"./geo-utils-BP1zBK9h.js";import"./payload-decoders-BX6pSxwl.js";function ft(t){const s=t.type??t.payload_type,a=t.duplicates??[],c=t.is_duplicate,r=a.length;let n=null,l=null;if(r>0){const x=[t.rssi,...a.map(g=>g.rssi).filter(g=>g!=null)],m=[t.snr,...a.map(g=>g.snr).filter(g=>g!=null)];x.length>1&&(n=[Math.min(...x),Math.max(...x)]),m.length>1&&(l=[Math.min(...m),Math.max(...m)])}const o=s===z.TRACE;return{isDuplicate:c,dupeCount:r,rssiRange:n,snrRange:l,hashIncludesPathLen:o}}function bt(t,s,a){const c={traceTag:null,siblingCount:0,isLocallyOriginated:!1,method:"none",confidence:"none",inferredSrc:null,inferredName:null,evidence:[],thisPathLen:0,minPathLen:0,firstHopPrefix:null};let r=t._traceTag;if(!r&&t.payload&&(r=Te(t.payload)),!r)return{...c,evidence:["no traceTag — cannot correlate"]};const n=s.get(r)??[],l=N=>N.path_length!=null?N.path_length:Array.isArray(N.original_path)?N.original_path.length:0,o=l(t),x=n.length>0?Math.min(...n.map(l)):o,m=t.payload?t.payload.slice(18):"",g=m.length>=2?m.slice(0,2).toUpperCase():null,u=[];if(u.push(`traceTag: ${r}`),u.push(`siblings: ${n.length} observation${n.length!==1?"s":""}`),t.packet_origin==="tx_local")return u.push("packet_origin = tx_local → we initiated this trace"),{traceTag:r,siblingCount:n.length,isLocallyOriginated:!0,method:"tx_local",confidence:"certain",inferredSrc:"LOCAL",inferredName:null,evidence:u,thisPathLen:o,minPathLen:x,firstHopPrefix:g};const v=n.find(N=>N.packet_origin==="tx_local");if(v)return u.push(`sibling (hash ${v.packet_hash}) has packet_origin = tx_local`),{traceTag:r,siblingCount:n.length,isLocallyOriginated:!0,method:"tx_local",confidence:"certain",inferredSrc:"LOCAL",inferredName:null,evidence:u,thisPathLen:o,minPathLen:x,firstHopPrefix:g};if(u.push(`this observation: path_len=${o}, min across siblings: ${x}`),g){if(u.push(`first hop in target path: ${g}`),o===0)return u.push("path_len = 0 → heard directly from initiator (no SNR appended yet)"),u.push("initiator is a direct RF neighbor"),{traceTag:r,siblingCount:n.length,isLocallyOriginated:!1,method:"min_path_len",confidence:"speculative",inferredSrc:null,inferredName:null,evidence:[...u,"initiator is within direct RF range (zero forwarding hops)"],thisPathLen:o,minPathLen:x,firstHopPrefix:g};const f=Object.entries(a).filter(([k])=>k.replace(/^0x/i,"").slice(0,2).toUpperCase()===g);if(f.length===1){const[k,$]=f[0],h=$.name||$.node_name||null;return u.push(`first hop ${g} → unique neighbor: ${h??k}`),u.push("initiator is whoever sent TO this first hop"),{traceTag:r,siblingCount:n.length,isLocallyOriginated:!1,method:"first_hop_neighbor",confidence:"likely",inferredSrc:g,inferredName:h,evidence:u,thisPathLen:o,minPathLen:x,firstHopPrefix:g}}else f.length>1?u.push(`first hop ${g} matches ${f.length} neighbors (ambiguous)`):u.push(`first hop ${g} is not a known neighbor`)}return u.push("insufficient data to identify initiator"),{traceTag:r,siblingCount:n.length,isLocallyOriginated:!1,method:"none",confidence:"none",inferredSrc:null,inferredName:null,evidence:u,thisPathLen:o,minPathLen:x,firstHopPrefix:g}}let ne=null,ce=null;typeof window<"u"&&setTimeout(()=>{ue(()=>import("./usePipelineStore-CyFB3GIy.js").then(t=>t.d),__vite__mapDeps([0,1,2,3,4])).then(t=>{ne=t}),ue(()=>import("./index-C8IY8K2r.js").then(t=>t.fW),__vite__mapDeps([1,4])).then(t=>{ce=t})},0);const He={advertSender:null,advertNodeType:null,advertFlags:null,advertHasLocation:null,advertHasName:null,advertName:null,advertLatitude:null,advertLongitude:null,channelHash:null,byteLength:void 0,hopCount:0,isZeroHop:!0,preComputed:!1};function yt(t,s){const a=t.type??t.payload_type,c=Ne(a),r=Be(t.route),n=a===z.ADVERT,l=a===z.TRACE,o=a===z.PATH,x=a===z.GRP_TXT||a===z.GRP_DATA,m=Ie(t.snr,t.rssi),g=(m==null?void 0:m.finalGrade)??"critical",u=Ge(t.route),v=Ve(t.route),N=Ue(t.route),f=t.route==null?"unknown":u?"flood":v?"direct":"unknown",k=N?`transport-${f}`:f,$=!!s.advertSender;let h="none";$?h="pubkey":x?h="encrypted":t.src_hash&&(h="prefix");const y=gt(a),p=s.advertNodeType!=null?ke(s.advertNodeType):"unknown",_=y!=="unknown"?y:p,H=t.packet_origin??"rx",C=Math.floor(Date.now()/1e3)-t.timestamp,L=C<10?"live":C<300?"recent":C<3600?"warm":C<86400?"stale":"historic",D=t.path_length??(Array.isArray(t.original_path)?t.original_path.length:void 0),P=Array.isArray(t.original_path)&&t.original_path.length>0,M=D??0,b=s.byteLength??(t.raw_packet?Math.floor(t.raw_packet.length/2):0),w=ft(t);return{pType:a,payloadTypeName:c,routeTypeName:r,isAdvert:n,isTrace:l,isPath:o,isGrp:x,signalClass:g,routeClass:k,isFlood:u,isDirect:v,hasTransport:N,senderTier:h,hasPubkey:$,inferredType:y,advertType:p,effectiveType:_,origin:H,age:L,pathLen:D,pathAvail:P,pathHopCount:M,byteLen:b,dupeAnalysis:w}}function jt(t){var f,k,$,h,y,p;const s=pt(t);if(!s||s.pathHashes.length===0)return null;const{pathHashes:a,snrValues:c}=s;if(a.length<2||!ne||!ce)return null;const r=ne.usePipelineStore.getState().srcHashResolverMap,n=ne.usePipelineStore.getState().neighborContext,l=(n==null?void 0:n.hashToName)??new Map,o=ce.useStore.getState().stats,x=(o==null?void 0:o.neighbors)??{},m=o==null?void 0:o.local_hash,g=(k=(f=o==null?void 0:o.config)==null?void 0:f.repeater)==null?void 0:k.latitude,u=(h=($=o==null?void 0:o.config)==null?void 0:$.repeater)==null?void 0:h.longitude,v=Object.keys(x).length>0?dt([],x,m,g,u):null,N=[];for(let _=0;_0?[a[_-1].toUpperCase()]:[]],P=ge(H,_,D,r,v),M=[H,..._+20?N:null}function ge(t,s,a,c,r){if(s===0){const l=c==null?void 0:c.get(t);if(l)return{hash:l,confidence:.8};if(r){const o=me(r,t,{position:s,adjacentPrefixes:a});if(o.hash)return{hash:o.hash,confidence:o.confidence}}}else{if(r){const o=me(r,t,{position:s,adjacentPrefixes:a});if(o.hash)return{hash:o.hash,confidence:o.confidence}}const l=c==null?void 0:c.get(t);if(l)return{hash:l,confidence:.6}}return{hash:null,confidence:0}}function vt(t){var l;const s=t.raw_packet;if(!s||s.length<2)return null;const a=s.replace(/\s/g,""),c=Math.floor(a.length/2),r=((l=a.match(/.{1,2}/g))==null?void 0:l.join(" "))??"";let n="";for(let o=0;o=32&&x<=126?String.fromCharCode(x):"·"}return{hexBytes:r,utf8:n,byteCount:c}}function Nt(t){const s=new Map;let a=0,c="";for(const r of t){if((r.type??r.payload_type)!==z.TRACE)continue;a++,c=r.packet_hash;const l=r._traceTag??(r.payload?Te(r.payload):null);if(!l)continue;let o=s.get(l);o||(o=[],s.set(l,o)),o.push(r)}return{index:s,fingerprint:`${a}:${c}`}}function wt(t,s,a){const c=T.useRef({parse:0,decode:0,enrich:0,traceIndex:0,total:0}),r=T.useMemo(()=>t?vt(t):null,[t]),n=T.useMemo(()=>{if(!s||s.length<4)return c.current.parse=0,c.current.decode=0,null;const h=performance.now(),y=ut(s),p=performance.now()-h;return y?(c.current.parse=p,c.current.decode=0,{protocolPacket:y.packet,display:{headerFields:y.headerFields,transportCodesHex:y.transportCodesHex,pathLengthHex:y.pathLengthHex,pathDataHex:y.pathDataHex,payloadHex:y.payloadHex,payloadByteOffset:y.payloadStartByte,pathByteOffset:y.pathByteOffset,pathLenByteOffset:y.pathLenByteOffset},decoded:y.decoded,error:null}):(c.current.parse=p,c.current.decode=0,{protocolPacket:null,display:null,decoded:null,error:"Packet.fromHex() returned failure"})},[s]),l=T.useMemo(()=>{if(!t)return c.current.enrich=0,He;const h=performance.now();if(t._advertSender!==void 0)return c.current.enrich=performance.now()-h,{advertSender:t._advertSender??null,advertNodeType:t._advertNodeType??null,advertFlags:t._advertFlags??null,advertHasLocation:t._advertHasLocation??null,advertHasName:t._advertHasName??null,advertName:t._advertName??null,advertLatitude:t._advertLatitude??null,advertLongitude:t._advertLongitude??null,channelHash:t._channelHash??null,byteLength:t._byteLength,hopCount:t._hopCount??0,isZeroHop:t._isZeroHop??!0,preComputed:!0};const y=t.type??t.payload_type,p=Ee(s,y),_=Fe(s,y),H=ze(s,t),C=Oe(t);return c.current.enrich=performance.now()-h,{...p,channelHash:_,byteLength:H,...C,preComputed:!1}},[t,s]),o=T.useRef({fingerprint:"",index:new Map}),x=T.useMemo(()=>{const h=performance.now(),{index:y,fingerprint:p}=Nt(a);return c.current.traceIndex=performance.now()-h,p===o.current.fingerprint?o.current.index:(o.current={fingerprint:p,index:y},y)},[a]),m=T.useMemo(()=>{const h=c.current;return{parse:h.parse,decode:h.decode,enrich:h.enrich,traceIndex:h.traceIndex,total:h.parse+h.decode+h.enrich+h.traceIndex}},[n,l,x]);if(!t)return null;const g=s?n?n.error:"rawHex too short":"No raw_packet (warm-tier)",u=(n==null?void 0:n.protocolPacket)??null,v=u?u.payloadVersion:null,N=v===0,f=v===1,k=yt(t,l);let $=null;return k.isTrace&&($=jt(t)),{wire:r,display:(n==null?void 0:n.display)??null,parseError:g,protocolPacket:u,decoded:(n==null?void 0:n.decoded)??null,payloadVersion:v,isV1:N,isV2:f,enrichment:l,traceTagIndex:x,analysis:k,traceHopDetail:$,timing:m}}function ae({options:t,nextFn:s}){var n;const a=t.find(l=>l.active),c=(a==null?void 0:a.color)??"green",r=((n=I[c])==null?void 0:n.stem)??"bg-edge-subtle";return e.jsxs("div",{className:"flex flex-col items-start py-1 gap-0 px-2",children:[e.jsx("div",{className:`w-px h-2 ml-4 ${r}`}),e.jsxs("div",{className:"border border-dashed border-edge-subtle rounded-md overflow-hidden w-full",children:[t.map((l,o)=>{const x=I[l.color??"green"]??I.green;return e.jsxs("div",{className:`flex items-center gap-1.5 px-2 py-px font-mono text-[10px] leading-relaxed transition-opacity ${l.active?x.row:"opacity-25"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${l.active?x.dot:"border border-zinc-500/40"}`}),e.jsx("span",{className:`w-16 shrink-0 font-medium ${l.active?"text-fg-primary":"text-fg-muted"}`,children:l.label}),l.detail&&e.jsx("span",{className:l.active?"text-fg-primary/70":"text-fg-muted",children:l.detail})]},o)}),s&&e.jsx("div",{className:"flex items-center px-2 py-0.5 border-t border-edge-subtle",children:e.jsxs("span",{className:"text-[10px] text-fg-muted font-mono",children:["→ ",s]})})]}),e.jsx("div",{className:`w-px h-2 ml-4 ${r}`})]})}function Ct({tokens:t,nextFn:s}){var n;const a=t.find(l=>l.active),c=(a==null?void 0:a.color)??"green",r=((n=I[c])==null?void 0:n.stem)??"bg-edge-subtle";return e.jsxs("div",{className:"flex flex-col items-start py-1 gap-0 px-2",children:[e.jsx("div",{className:`w-px h-2 ml-4 ${r}`}),e.jsxs("div",{className:"border border-dashed border-edge-subtle rounded-md overflow-hidden w-full",children:[t.map((l,o)=>{const x=I[l.color??"green"]??I.green;return e.jsxs("div",{className:`flex items-center gap-1 px-2 py-px font-mono text-[10px] leading-relaxed transition-opacity ${l.active?x.row:"opacity-25"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${l.active?x.dot:"border border-zinc-500/40"}`}),e.jsx("span",{className:"text-fg-muted shrink-0",children:l.fn}),e.jsxs("span",{className:l.active?"text-fg-primary":"text-fg-muted",children:["(",l.value??"",")"]})]},o)}),s&&e.jsx("div",{className:"flex items-center px-2 py-0.5 border-t border-edge-subtle",children:e.jsxs("span",{className:"text-[10px] text-fg-muted font-mono",children:["→ ",s]})})]}),e.jsx("div",{className:`w-px h-2 ml-4 ${r}`})]})}const St={0:"border-l-sys-green",1:"border-l-sys-blue",2:"border-l-sys-teal",3:"border-l-sys-purple"};function le({stage:t,name:s,fn:a,verdict:c,timeMs:r,skipped:n,skipReason:l,children:o}){const x=St[t]??"";return e.jsx(e.Fragment,{children:e.jsx(G,{defaultOpen:!n,children:e.jsxs("div",{className:`surface-base rounded-lg border border-edge-subtle overflow-hidden border-l-2 ${x}`,children:[e.jsxs(V,{className:"px-3 py-2 w-full",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"font-mono text-xs font-bold text-sys-blue shrink-0",children:t}),e.jsx("span",{className:"font-mono text-xs font-medium text-fg-primary truncate",children:s}),a&&!c&&e.jsx("span",{className:"font-mono text-[11px] text-fg-muted truncate hidden sm:inline",children:a}),c&&e.jsx("span",{className:"font-mono text-[11px] text-fg-muted/70 truncate hidden sm:inline",children:c})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[n&&e.jsx("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-zinc-500/20 text-fg-muted",children:"N/A"}),r!=null&&!n&&e.jsx("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-sys-green/15 text-sys-green",children:r<1?`${(r*1e3).toFixed(0)}µs`:`${r.toFixed(2)}ms`})]})]}),e.jsx(U,{children:e.jsx("div",{className:"px-3 pb-3 font-mono text-xs",children:n?e.jsx("p",{className:"text-fg-muted italic",children:l??"Not applicable for this packet type"}):o})})]})})})}function Tt(t,s){return s?"manual":t._stripped?"bulk-tier":qe.isConnected()?"ws-push":"rest-poll"}const _t={connected:"green",degraded:"amber",offline:"red"};function kt({packet:t,isSynthetic:s}){const a=pe(g=>g.wsState),c=pe(g=>g.health),r=Tt(t,s),l=!!t._stripped?"WARM":"HOT",o=[{label:"ws-push",detail:"wsConnected && onPacket()",active:r==="ws-push",color:"green"},{label:"rest-poll",detail:"!wsConnected, 3s interval",active:r==="rest-poll",color:"amber"},{label:"catchup",detail:"wsReconnected, delta > 50",active:r==="catchup",color:"amber"},{label:"bulk-tier",detail:"user extends time range → gzip",active:r==="bulk-tier",color:"blue"},{label:"manual",detail:"hex input — no transport",active:r==="manual",color:"zinc"}],x=[{fn:"transport",value:r,group:"transport",color:r==="ws-push"?"green":r==="bulk-tier"?"blue":"amber"},{fn:"tier",value:l,group:"transport",color:"blue"},{fn:"wsState",value:a,group:"transport",color:a==="connected"?"green":"amber"},{fn:"health",value:c,group:"transport",color:_t[c]}],m=s?"manual hex input":`${r} (${c})`;return e.jsx(le,{stage:0,name:"TRANSPORT",fn:"websocketService / useStore.startPolling",verdict:m,children:s?e.jsx("p",{className:"text-fg-muted italic",children:"Manual hex input — no transport context"}):e.jsx(q,{prefix:"transport",children:e.jsxs("div",{className:"space-y-0",children:[e.jsx(ae,{options:o,nextFn:"ingest()"}),e.jsx(se,{tokens:x})]})})})}function K({start:t,end:s}){const a=s!=null&&s!==t?`[${t}..${s}]`:`[${t}]`;return e.jsx("span",{className:"text-fg-muted text-[9px] font-mono mr-1 select-none",children:a})}const Ht={advert:"decodeAdvert()",ack:"decodeAck()",path:"decodePath()",trace:"decodeTraceWithSnr()",txt_msg:"decodeTextMessage()",grp_txt:"decodeGroupText()",grp_data:"decodeGroupData()",multipart:"decodeMultipart()",control:"decodeControl()",req:"decodeRequest()",response:"decodeResponse()",anon_req:"decodeAnonReq()",generic:"decodeGeneric()"};function $t({rawHex:t,display:s,protocolPacket:a,parseError:c,parseTimeMs:r,payloadVersion:n,isV1:l,isV2:o}){return e.jsx("dl",{className:"space-y-0.5",children:s&&a&&t?e.jsxs(e.Fragment,{children:[e.jsx(A,{title:"A. Parse — Packet.fromHex()"}),r>0&&e.jsx("div",{className:"flex justify-end",children:e.jsx("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-sys-green/15 text-sys-green",children:r<1?`${(r*1e3).toFixed(0)}µs`:`${r.toFixed(2)}ms`})}),e.jsxs(i,{label:"header byte",children:[e.jsx(K,{start:0}),e.jsx(E,{value:t.slice(0,2)})," ",e.jsx(xt,{value:parseInt(t.slice(0,2),16)})]}),s.headerFields.map(x=>e.jsx(i,{label:` ${x.field}`,children:e.jsx(F,{raw:e.jsxs("span",{className:"text-[10px]",children:["bits[",x.bits,"] = ",x.binary]}),children:e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-2 py-0.5 font-mono text-[11px] text-sys-amber",children:x.value})})},x.field)),e.jsx(i,{label:" version",children:n!=null?e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(d,{fn:"payloadVer",value:`${n}`,color:"amber"}),e.jsx(R,{color:l?"green":o?"blue":"zinc",children:l?"v1":o?"v2":`v${n}`}),l&&e.jsx("span",{className:"text-fg-muted text-[10px]",children:"1-byte hashes, 2-byte MAC"}),o&&e.jsx("span",{className:"text-sys-blue text-[10px]",children:"2-byte hashes, 4-byte MAC (speculative)"})]}):e.jsx("span",{className:"text-fg-muted",children:"unknown"})}),e.jsx(A,{title:"Wire Framing"}),e.jsx(i,{label:"transportCodes",children:s.transportCodesHex?e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(K,{start:1,end:4}),e.jsx(d,{fn:"transport",value:s.transportCodesHex,color:"amber"})]}):e.jsx("span",{className:"text-fg-muted",children:"N/A (non-transport route)"})}),e.jsx(i,{label:"pathLen",children:e.jsx(F,{raw:e.jsxs(e.Fragment,{children:[e.jsx(K,{start:s.pathLenByteOffset}),e.jsx(E,{value:s.pathLengthHex})]}),children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(K,{start:s.pathLenByteOffset}),e.jsx(d,{fn:"pathLen",value:`${a.pathLen} hop${a.pathLen!==1?"s":""}`,color:"amber"})]})})}),e.jsx(i,{label:"path",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[a.pathLen>0&&e.jsx(K,{start:s.pathByteOffset,end:s.pathByteOffset+a.pathLen-1}),e.jsx(re,{hops:a.pathHexArray,hexPrefix:s.pathDataHex||void 0})]})}),e.jsx(i,{label:"payloadLen",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(K,{start:s.payloadByteOffset,end:s.payloadByteOffset+s.payloadHex.length/2-1}),e.jsx(d,{fn:"payloadLen",value:`${s.payloadHex.length/2} bytes`,color:"amber"})]})}),e.jsx(i,{label:"payloadHex",children:e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-2 py-0.5 font-mono text-[11px] text-sys-amber break-all",children:s.payloadHex})})]}):e.jsxs(e.Fragment,{children:[e.jsx(A,{title:"A. Parse"}),e.jsxs(i,{label:"result",children:[e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-2 py-0.5 font-mono text-[11px] text-sys-amber",children:"Skipped"}),e.jsx("span",{className:"ml-1 text-fg-muted",children:c??"No raw_packet (warm-tier)"})]})]})})}function Lt({decoded:t,packet:s}){if(!t)return e.jsxs(e.Fragment,{children:[e.jsx(A,{title:"B. Decode"}),e.jsx("p",{className:"text-fg-muted italic text-[10px]",children:"No decoded payload"})]});const a=Ht[t.type]??`decode${t.type}()`;return e.jsxs(e.Fragment,{children:[e.jsx(A,{title:"B. Decode — decodePayload()"}),e.jsx(q,{prefix:"decodePayload",children:e.jsxs("dl",{className:"space-y-0.5",children:[e.jsx(i,{label:"dispatched",children:a}),e.jsx(A,{}),e.jsx(Dt,{decoded:t,packet:s})]})})]})}function Dt({decoded:t,packet:s}){switch(t.type){case"advert":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"publicKey",children:e.jsx(F,{raw:e.jsx("span",{className:"text-[10px] break-all",children:t.publicKey}),children:e.jsx(d,{fn:"publicKey",value:t.publicKey,color:"green"})})}),e.jsx(i,{label:"timestamp",children:e.jsx(d,{fn:"timestamp",value:String(t.timestamp),color:"green"})}),e.jsx(i,{label:"flags",children:e.jsx(F,{raw:e.jsx(E,{value:t.flags}),children:e.jsx(d,{fn:"flags",value:t.flagsDescription,color:"green"})})}),e.jsx(i,{label:"nodeType",children:e.jsx(d,{fn:"nodeType",value:t.nodeType,color:"green"})}),t.latitude!=null&&e.jsx(i,{label:"latitude",children:e.jsx(d,{fn:"lat",value:t.latitude.toFixed(6),color:"green"})}),t.longitude!=null&&e.jsx(i,{label:"longitude",children:e.jsx(d,{fn:"lon",value:t.longitude.toFixed(6),color:"green"})}),t.name&&e.jsx(i,{label:"name",children:e.jsx(d,{fn:"name",value:t.name,color:"green"})})]});case"ack":return e.jsx(i,{label:"crc",children:e.jsx(F,{raw:e.jsx("span",{className:"text-[10px]",children:t.crc}),children:e.jsx(d,{fn:"crc",value:t.crc,color:"green"})})});case"trace":{const a=s!=null&&s.src_hash?s.src_hash.replace(/^0x/i,"").slice(0,2).toUpperCase():null;return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"traceTag",children:e.jsx(d,{fn:"traceTag",value:t.traceTag,color:"green"})}),e.jsx(i,{label:"authCode",children:e.jsx(d,{fn:"authCode",value:String(t.authCode),color:"green"})}),e.jsx(i,{label:"flags",children:e.jsx(E,{value:t.flags})}),e.jsx(i,{label:"target path",children:t.pathHashes.length>0?e.jsx(re,{hops:t.pathHashes.map(c=>c.toUpperCase()),color:"green"}):e.jsx("span",{className:"text-fg-muted italic",children:"∅ empty"})}),e.jsx(i,{label:"complete",children:t.isComplete?e.jsxs("span",{className:"text-sys-green",children:["✓ all ",t.pathHashes.length," hops reported SNR"]}):e.jsxs("span",{className:"text-sys-amber",children:["✗ ",t.snrValues.length,"/",t.pathHashes.length," hops reported"]})}),e.jsx(A,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-fg-muted mb-1 text-[10px]",children:"Directional Edge SNR — per-hop link quality"}),t.snrValues.length===0?e.jsx("p",{className:"text-fg-muted italic text-[11px] ml-2",children:"No SNR values in path field"}):e.jsx("div",{className:"space-y-0.5 ml-2",children:t.snrValues.map((c,r)=>{var m,g,u,v,N;const n=((m=t.pathHashes[r])==null?void 0:m.toUpperCase())??"??",l=r===0?a??"SRC":((g=t.pathHashes[r-1])==null?void 0:g.toUpperCase())??"??",o=(N=(v=(u=We.getState().stats)==null?void 0:u.config)==null?void 0:v.radio)==null?void 0:N.spreading_factor,x=we(c,o);return e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-mono",children:[e.jsx("span",{className:"text-fg-muted w-3 text-right",children:r}),e.jsx("span",{className:"text-fg-primary",children:l}),e.jsx("span",{className:"text-fg-muted",children:"→"}),e.jsx("span",{className:"text-fg-primary",children:n}),e.jsx("span",{className:"text-fg-muted",children:"@"}),e.jsxs("span",{className:"font-bold text-sys-green",children:[c>0?"+":"",c.toFixed(1)," dB"]}),e.jsx(R,{color:"green",children:x})]},r)})})]})]})}case"path":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"pathLength",children:e.jsx(d,{fn:"pathLength",value:String(t.pathLength),color:"green"})}),e.jsx(i,{label:"path",children:t.path&&t.path.length>0?e.jsx(re,{hops:t.path.map(a=>a.toUpperCase()),color:"green"}):e.jsx("span",{className:"text-fg-muted italic",children:"∅ empty"})}),t.extraType!=null&&e.jsx(i,{label:"extraType",children:e.jsx(d,{fn:"extraType",value:t.extraTypeName??String(t.extraType),color:"purple"})}),t.extraData&&e.jsxs(i,{label:"extraData",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.extraData}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.extraData.length/2,"B)"]})]})]});case"txt_msg":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"destHash",children:e.jsx(F,{raw:e.jsx(E,{value:t.destHash}),children:e.jsx(d,{fn:"destHash",value:t.destHash,color:"green"})})}),e.jsx(i,{label:"srcHash",children:e.jsx(F,{raw:e.jsx(E,{value:t.srcHash}),children:e.jsx(d,{fn:"srcHash",value:t.srcHash,color:"green"})})}),e.jsx(i,{label:"cipherMac",children:e.jsx(d,{fn:"cipherMac",value:t.cipherMac,color:"purple"})}),e.jsx(i,{label:"timestamp",children:e.jsx(d,{fn:"timestamp",value:String(t.timestamp),color:"green"})}),e.jsx(i,{label:"text",children:e.jsx(d,{fn:"text",value:t.text,color:"green"})}),e.jsx(i,{label:"encrypted",children:e.jsx(d,{fn:"encrypted",value:String(t.encrypted),color:"green"})})]});case"grp_txt":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"channelHash",children:e.jsx(E,{value:t.channelHash})}),t.channelName&&e.jsx(i,{label:"channelName",children:e.jsx(d,{fn:"channel",value:t.channelName,color:"green"})}),e.jsx(i,{label:"decrypted",children:e.jsx(d,{fn:"decrypted",value:String(t.decrypted),color:"green"})}),t.text&&e.jsx(i,{label:"text",children:e.jsx(d,{fn:"text",value:t.text,color:"green"})}),t.senderName&&e.jsx(i,{label:"senderName",children:e.jsx(d,{fn:"sender",value:t.senderName,color:"green"})}),t.macCorrupted&&e.jsx(i,{label:"macCorrupted",children:e.jsx(d,{fn:"macCorrupted",value:"true",color:"green"})})]});case"grp_data":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"channelHash",children:e.jsx(E,{value:t.channelHash})}),e.jsx(i,{label:"dataLength",children:t.dataLength}),e.jsx(i,{label:"decrypted",children:String(t.decrypted)})]});case"multipart":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"messageId",children:t.messageId}),e.jsxs(i,{label:"part",children:[t.partNumber+1," / ",t.totalParts]})]});case"control":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"controlType",children:e.jsx(F,{raw:e.jsx(E,{value:t.controlType}),children:e.jsx(d,{fn:"controlType",value:t.subtypeName,color:"green"})})}),e.jsx(i,{label:"subtype",children:e.jsx(d,{fn:"subtype",value:`0x${t.subtype.toString(16).padStart(2,"0")}`,color:"green"})}),e.jsx(i,{label:"subtypeFlags",children:e.jsx(d,{fn:"subtypeFlags",value:`0x${t.subtypeFlags.toString(16).padStart(2,"0")}`,color:"green"})}),t.dataLength>0&&e.jsxs(i,{label:"data",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.dataHex}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.dataLength,"B)"]})]})]});case"req":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"destHash",children:e.jsx(F,{raw:e.jsx(E,{value:t.destHash}),children:e.jsx(d,{fn:"destHash",value:t.destHash,color:"green"})})}),e.jsx(i,{label:"srcHash",children:e.jsx(F,{raw:e.jsx(E,{value:t.srcHash}),children:e.jsx(d,{fn:"srcHash",value:t.srcHash,color:"green"})})}),e.jsx(i,{label:"cipherMac",children:e.jsx(d,{fn:"cipherMac",value:t.cipherMac,color:"purple"})}),e.jsxs(i,{label:"ciphertext",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.ciphertextHex}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.ciphertextLength,"B)"]})]})]});case"response":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"destHash",children:e.jsx(F,{raw:e.jsx(E,{value:t.destHash}),children:e.jsx(d,{fn:"destHash",value:t.destHash,color:"green"})})}),e.jsx(i,{label:"srcHash",children:e.jsx(F,{raw:e.jsx(E,{value:t.srcHash}),children:e.jsx(d,{fn:"srcHash",value:t.srcHash,color:"green"})})}),e.jsx(i,{label:"cipherMac",children:e.jsx(d,{fn:"cipherMac",value:t.cipherMac,color:"purple"})}),e.jsxs(i,{label:"ciphertext",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.ciphertextHex}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.ciphertextLength,"B)"]})]})]});case"anon_req":return e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"destHash",children:e.jsx(F,{raw:e.jsx(E,{value:t.destHash}),children:e.jsx(d,{fn:"destHash",value:t.destHash,color:"green"})})}),e.jsx(i,{label:"senderPubKey",children:e.jsx("span",{className:"break-all text-[10px] font-mono text-sys-green",children:t.senderPublicKey})}),e.jsx(i,{label:"cipherMac",children:e.jsx(d,{fn:"cipherMac",value:t.cipherMac,color:"purple"})}),e.jsxs(i,{label:"ciphertext",children:[e.jsx("span",{className:"break-all text-[10px] font-mono",children:t.ciphertextHex}),e.jsxs("span",{className:"text-fg-muted ml-1",children:["(",t.ciphertextLength,"B)"]})]})]});case"generic":return e.jsxs(e.Fragment,{children:[e.jsxs(i,{label:"payloadType",children:[e.jsx(ht,{value:t.payloadType})," (",t.payloadTypeName,")"]}),e.jsx(i,{label:"length",children:t.length}),e.jsx(i,{label:"rawHex",children:e.jsx("span",{className:"break-all",children:t.rawHex})})]});default:return e.jsx("p",{className:"text-fg-muted",children:"Unknown decoded type"})}}function Pt({protocolPacket:t,packetHash:s}){const a=t==null?void 0:t.payloadType,c=a===Ye||a===Ze,r=T.useMemo(()=>{if(!c||!t)return null;const p=t.payload;return p.length<4?null:{channelHash:p[0],mac:p.slice(1,3),ciphertext:p.slice(3)}},[t,c]),[n,l]=T.useState("pending"),[o,x]=T.useState([]),[m,g]=T.useState(0);T.useEffect(()=>{if(!r){l(null);return}let p=!1;return(async()=>{const H=performance.now(),C=await Xe(r.channelHash,r.mac,r.ciphertext);p||(l(C),g(performance.now()-H));const L=await Qe(r.channelHash);p||x(L)})(),()=>{p=!0}},[r]);const[u,v]=T.useState(""),[N,f]=T.useState(null),[k,$]=T.useState(!1),h=T.useCallback(async()=>{if(!(!r||!u.trim())){$(!0);try{const p=await Ke(u.trim(),r.channelHash,r.mac,r.ciphertext);if(p.success){const _=new TextDecoder("utf-8",{fatal:!1}).decode(p.result.plaintext.slice(5));f({success:!0,text:_})}else f({success:!1,error:p.error})}catch(p){f({success:!1,error:String(p)})}finally{$(!1)}}},[r,u]),y=Ce(s);return!c||!r?null:e.jsxs(e.Fragment,{children:[e.jsx(A,{title:"C. Decrypt — tryDecryptGroupMessage()"}),m>0&&e.jsx("div",{className:"flex justify-end",children:e.jsx("span",{className:"font-mono text-[10px] px-1.5 py-0.5 rounded bg-sys-green/15 text-sys-green",children:m<1?`${(m*1e3).toFixed(0)}µs`:`${m.toFixed(2)}ms`})}),e.jsx(q,{prefix:"tryDecryptGroupMessage",children:e.jsxs("dl",{className:"space-y-0.5",children:[e.jsx(i,{label:"channelHash",children:e.jsx(d,{fn:"channelHash",value:`0x${r.channelHash.toString(16).toUpperCase().padStart(2,"0")}`,color:"teal"})}),e.jsx(i,{label:"mac",children:e.jsx(d,{fn:"mac",value:Array.from(r.mac).map(p=>p.toString(16).padStart(2,"0")).join(""),color:"teal"})}),e.jsx(i,{label:"cipherLen",children:e.jsx(d,{fn:"cipherLen",value:`${r.ciphertext.length}B`,color:"teal"})}),e.jsx(i,{label:"candidates",children:e.jsx(d,{fn:"candidates",value:o.length>0?`${o.length} names`:"0",color:o.length>0?"teal":"zinc"})}),o.length>0&&e.jsxs("details",{className:"mt-1",children:[e.jsx("summary",{className:"text-fg-muted cursor-pointer hover:text-fg-primary text-[10px]",children:"show candidate names"}),e.jsx("div",{className:"mt-1 text-[10px] text-fg-muted break-all max-h-24 overflow-y-auto",children:o.join(", ")})]}),e.jsx(A,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-fg-muted mb-1",children:"Result:"}),n==="pending"?e.jsx("p",{className:"text-fg-muted italic",children:"decrypting…"}):n?e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"channel",children:e.jsx(d,{fn:"channel",value:n.channelName,color:"teal"})}),e.jsx(i,{label:"plaintext",children:e.jsx(d,{fn:"plaintext",value:new TextDecoder("utf-8",{fatal:!1}).decode(n.plaintext.slice(5)).trim()||"(empty)",color:"teal"})}),e.jsx(i,{label:"macValid",children:e.jsx(d,{fn:"macValid",value:n.macCorrupted?"false":"true",color:"teal"})})]}):e.jsxs(i,{label:"decrypt",children:[e.jsx(d,{fn:"decrypt",value:"failed",color:"red"}),e.jsx("span",{className:"text-fg-muted ml-1",children:"channel not in known list"})]})]}),e.jsx(A,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-fg-muted mb-1",children:"testChannelName() — manual test:"}),e.jsxs("div",{className:"flex gap-1.5 items-center",children:[e.jsx("input",{type:"text",value:u,onChange:p=>{v(p.target.value),f(null)},onKeyDown:p=>p.key==="Enter"&&h(),placeholder:"channel name",className:"surface-input px-2 py-1 rounded text-[11px] font-mono text-fg-primary w-40"}),e.jsx("button",{onClick:h,disabled:k||!u.trim(),className:"px-2 py-1 rounded text-[10px] font-mono bg-sys-blue/20 text-sys-blue hover:bg-sys-blue/30 disabled:opacity-40 transition-colors",children:k?"…":"Try"})]}),N&&e.jsx("div",{className:"mt-1",children:N.success?e.jsx(i,{label:"result",children:e.jsx(d,{fn:"plaintext",value:N.text??"(empty)",color:"teal"})}):e.jsx(i,{label:"error",children:e.jsx(d,{fn:"error",value:N.error??"unknown",color:"red"})})})]}),e.jsx(A,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-fg-muted mb-1",children:"useDecodedMessage() store result:"}),y?y.decoded?e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"channel",children:e.jsx(d,{fn:"channel",value:y.decoded.channelName??"?",color:"teal"})}),e.jsx(i,{label:"text",children:e.jsx(d,{fn:"text",value:y.decoded.text,color:"teal"})})]}):e.jsx(i,{label:"decrypt",children:e.jsx(d,{fn:"decrypt",value:"failed",color:"red"})}):e.jsx(i,{label:"decrypt",children:e.jsx(d,{fn:"decrypt",value:"pending",color:"zinc"})})]})]})})]})}function Mt(t){const{rawHex:s,display:a,protocolPacket:c,decoded:r,parseError:n,parseTimeMs:l,payloadVersion:o,isV1:x,isV2:m,packetHash:g,packet:u}=t,v=!!s&&s.length>=4;return e.jsxs(G,{children:[e.jsx(V,{className:"w-full mt-2 mb-1",children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-[10px] font-mono text-fg-muted",children:"🔬"}),e.jsx("span",{className:"text-[10px] font-mono font-medium text-fg-muted",children:"Wire Inspection"}),e.jsx("span",{className:"text-[9px] text-fg-muted/50",children:"observatory diagnostic — not a runtime stage"})]})}),e.jsx(U,{children:e.jsxs("div",{className:"border border-dashed border-edge-subtle rounded-lg p-3 space-y-1 bg-surface/30",children:[e.jsx("p",{className:"text-[9px] text-fg-muted/50 mb-2",children:"The backend parsed these fields server-side. This panel verifies the wire-level encoding client-side."}),v?e.jsxs(e.Fragment,{children:[e.jsx($t,{rawHex:s,display:a,protocolPacket:c,parseError:n,parseTimeMs:l,payloadVersion:o,isV1:x,isV2:m}),e.jsx(Lt,{decoded:r,packet:u}),e.jsx(Pt,{protocolPacket:c,packetHash:g})]}):e.jsx("p",{className:"text-fg-muted italic text-[10px]",children:n??"No raw_packet — wire inspection unavailable (warm-tier packet)"})]})})]})}function fe(t){if(!t)return[{fn:"decode",value:"no raw_packet",group:"decode",color:"zinc"}];switch(t.type){case"advert":{const s=t,a=[{fn:"decode.nodeType",value:s.nodeType,group:"decode",color:"blue"}];return s.name&&a.push({fn:"decode.name",value:s.name,group:"decode",color:"blue"}),s.latitude!=null&&s.longitude!=null&&a.push({fn:"decode.location",value:`${s.latitude.toFixed(4)}, ${s.longitude.toFixed(4)}`,group:"decode",color:"blue"}),a.push({fn:"decode.publicKey",value:s.publicKey,group:"decode",color:"blue"}),a}case"trace":{const s=t;return[{fn:"decode.traceTag",value:s.traceTag,group:"decode",color:"blue"},{fn:"decode.hops",value:s.pathHashes.length>0?s.pathString:"empty",group:"decode",color:"blue"},{fn:"decode.snr",value:s.snrValues.length>0?`${s.snrValues.length} values`:"none",group:"decode",color:s.snrValues.length>0?"blue":"zinc"},{fn:"decode.complete",value:s.isComplete?"yes":"partial",group:"decode",color:s.isComplete?"green":"amber"}]}case"path":{const s=t,a=[{fn:"decode.pathLength",value:String(s.pathLength),group:"decode",color:"blue"},{fn:"decode.path",value:s.path.length>0?s.pathString:"empty",group:"decode",color:"blue"}];return s.extraType!=null&&a.push({fn:"decode.extraType",value:s.extraTypeName??String(s.extraType),group:"decode",color:"purple"}),s.extraData&&a.push({fn:"decode.extraData",value:`${s.extraData.length/2}B`,group:"decode",color:"purple"}),a}case"ack":return[{fn:"decode.crc",value:t.crc,group:"decode",color:"blue"}];case"grp_txt":return[{fn:"decode.channelHash",value:t.channelHash,group:"decode",color:"blue"},{fn:"decode.encrypted",value:"true — decrypt at cascade",group:"decode",color:"zinc"}];case"grp_data":{const s=t;return[{fn:"decode.channelHash",value:s.channelHash,group:"decode",color:"blue"},{fn:"decode.dataLength",value:`${s.dataLength}B`,group:"decode",color:"blue"}]}case"txt_msg":{const s=t;return[{fn:"decode.srcHash",value:s.srcHash,group:"decode",color:"blue"},{fn:"decode.destHash",value:s.destHash,group:"decode",color:"blue"},{fn:"decode.encrypted",value:s.encrypted?"true":"false",group:"decode",color:s.encrypted?"zinc":"green"},...s.encrypted?[]:[{fn:"decode.text",value:s.text,group:"decode",color:"blue"}]]}case"multipart":{const s=t;return[{fn:"decode.part",value:`${s.partNumber+1}/${s.totalParts}`,group:"decode",color:"blue"},{fn:"decode.msgId",value:s.messageId,group:"decode",color:"blue"}]}case"control":{const s=t;return[{fn:"decode.subtype",value:s.subtypeName,group:"decode",color:"blue"},{fn:"decode.subtypeFlags",value:`0x${s.subtypeFlags.toString(16)}`,group:"decode",color:"blue"},{fn:"decode.dataLength",value:`${s.dataLength}B`,group:"decode",color:"blue"}]}case"req":{const s=t;return[{fn:"decode.destHash",value:s.destHash,group:"decode",color:"blue"},{fn:"decode.srcHash",value:s.srcHash,group:"decode",color:"blue"},{fn:"decode.cipherMac",value:s.cipherMac,group:"decode",color:"purple"},{fn:"decode.ciphertext",value:`${s.ciphertextLength}B`,group:"decode",color:"zinc"}]}case"response":{const s=t;return[{fn:"decode.destHash",value:s.destHash,group:"decode",color:"blue"},{fn:"decode.srcHash",value:s.srcHash,group:"decode",color:"blue"},{fn:"decode.cipherMac",value:s.cipherMac,group:"decode",color:"purple"},{fn:"decode.ciphertext",value:`${s.ciphertextLength}B`,group:"decode",color:"zinc"}]}case"anon_req":{const s=t;return[{fn:"decode.destHash",value:s.destHash,group:"decode",color:"blue"},{fn:"decode.senderPubKey",value:s.senderPublicKey,group:"decode",color:"green"},{fn:"decode.cipherMac",value:s.cipherMac,group:"decode",color:"purple"},{fn:"decode.ciphertext",value:`${s.ciphertextLength}B`,group:"decode",color:"zinc"}]}case"generic":return[{fn:"decode.raw",value:`${t.length}B`,group:"decode",color:"zinc"}];default:return[]}}function Rt({packet:t,pipeline:s,rawHex:a,traceTagIndex:c,neighbors:r}){const{enrichment:n,timing:l,display:o,protocolPacket:x,decoded:m,parseError:g,payloadVersion:u,isV1:v,isV2:N,analysis:f}=s,$=(t.type??t.payload_type)===Je,h=f.dupeAnalysis,y=T.useRef(0),p=T.useMemo(()=>{if(!$)return null;const L=performance.now(),D=bt(t,c,r);return y.current=performance.now()-L,D},[t,c,r,$]),_=l.enrich+y.current,H=[];f.byteLen&&H.push(`${f.byteLen}B`),H.push(f.payloadTypeName),n.advertName&&H.push(`"${n.advertName}"`),n.isZeroHop?H.push("zero-hop"):f.pathHopCount>0&&H.push(`${f.pathHopCount}h`),H.push(`${t.rssi}dBm`),h.isDuplicate&&H.push("DUPE");const C=H.join(" — ");return e.jsxs(le,{stage:1,name:"INGEST",fn:n.preComputed?"PacketCache.mergePackets()":"extractAdvertData() + extractHopData() + ...",verdict:C,timeMs:_,children:[e.jsx(Mt,{rawHex:a,display:o,protocolPacket:x,decoded:m,parseError:g,parseTimeMs:l.parse,payloadVersion:u,isV1:v,isV2:N,packetHash:t.packet_hash,packet:t}),e.jsx(A,{title:"Cache Enrichment"}),e.jsx(q,{prefix:"packetCache",children:e.jsxs("dl",{className:"space-y-0.5",children:[e.jsxs("div",{className:"mb-1.5",children:[n.preComputed?e.jsx(R,{color:"green",children:"PacketCache"}):e.jsx(R,{color:"amber",children:"computed"}),e.jsx("span",{className:"text-[10px] text-fg-muted ml-1.5",children:n.preComputed?"pre-enriched by real pipeline":"synthetic — computed on the fly"})]}),e.jsxs("div",{className:"flex flex-wrap gap-x-2 gap-y-1 mb-1",children:[e.jsx(d,{fn:"_byteLength",value:n.byteLength!=null?`${n.byteLength}B`:void 0,color:"blue"}),e.jsx(d,{fn:"_hopCount",value:String(n.hopCount),color:"blue"}),e.jsx(d,{fn:"_isZeroHop",value:String(n.isZeroHop),color:n.isZeroHop?"green":"blue"}),n.isZeroHop&&e.jsx(R,{color:"blue",children:"direct"}),n.channelHash!=null&&e.jsx(d,{fn:"_channelHash",value:n.channelHash,color:"blue"}),$&&t._traceTag&&e.jsx(d,{fn:"_traceTag",value:t._traceTag,color:"blue"})]}),n.advertSender||n.advertNodeType!=null||n.advertName!=null?e.jsxs("div",{className:"mt-1 mb-1",children:[e.jsx("p",{className:"text-[10px] text-sys-blue font-medium mb-0.5",children:"ADVERT Enrichment"}),e.jsxs("div",{className:"flex flex-wrap gap-x-2 gap-y-1",children:[n.advertSender&&e.jsx(d,{fn:"_advertSender",value:n.advertSender.slice(0,16)+"…",color:"blue"}),n.advertNodeType!=null&&e.jsx(d,{fn:"_advertNodeType",value:ke(n.advertNodeType),color:"blue"}),n.advertName!=null&&e.jsx(d,{fn:"_advertName",value:n.advertName,color:"blue"}),n.advertFlags!=null&&e.jsx(d,{fn:"_advertFlags",value:`0x${n.advertFlags.toString(16).padStart(2,"0")}`,color:"blue"}),n.advertHasLocation!=null&&e.jsx(d,{fn:"_advertHasLocation",value:String(n.advertHasLocation),color:"blue"}),n.advertHasName!=null&&e.jsx(d,{fn:"_advertHasName",value:String(n.advertHasName),color:"blue"}),n.advertLatitude!=null&&n.advertLongitude!=null&&e.jsx(d,{fn:"location",value:`${n.advertLatitude.toFixed(4)}, ${n.advertLongitude.toFixed(4)}`,color:"blue"})]})]}):e.jsx("p",{className:"text-[10px] text-fg-muted/30 mb-1",children:"ADVERT fields: N/A (non-ADVERT packet)"}),e.jsx(A,{title:"Payload Decode"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${m?"bg-sys-blue":"bg-zinc-500/40"}`}),e.jsx("span",{className:"font-mono text-[10px] font-medium text-fg-primary",children:"decodePayload()"}),e.jsx("span",{className:"text-[9px] text-fg-muted",children:"sync — wire data only, no crypto"})]}),e.jsx("div",{className:"ml-3",children:m?e.jsx("div",{className:"flex flex-wrap gap-x-1.5 gap-y-1",children:fe(m).map((L,D)=>e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5",children:e.jsx(d,{fn:L.fn,value:L.value,color:L.color})},D))}):e.jsx(S,{children:"no raw_packet — warm-tier packet, decode unavailable"})})]}),e.jsx(A,{}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] font-mono",children:[e.jsx("span",{className:"text-fg-muted",children:"dupe:"}),h.isDuplicate?e.jsx(d,{fn:"is_duplicate",value:"true",color:"purple"}):e.jsx(S,{children:"none"}),h.dupeCount>0&&e.jsx(d,{fn:"dupeCount",value:`×${h.dupeCount}`,color:"purple"}),h.rssiRange&&e.jsxs(S,{c:"text-fg-primary",children:["Δ",Math.abs(h.rssiRange[1]-h.rssiRange[0]),"dB RSSI"]})]}),p&&e.jsxs(e.Fragment,{children:[e.jsx(A,{}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] font-mono",children:[e.jsx("span",{className:"text-fg-muted",children:"TRACE SRC:"}),p.inferredSrc?e.jsxs(e.Fragment,{children:[e.jsx(d,{fn:"inferredSrc",value:p.inferredSrc,color:"purple"}),p.inferredName&&e.jsx(d,{fn:"name",value:p.inferredName,color:"purple"})]}):e.jsx(S,{children:"unresolvable"}),e.jsx(_e,{color:"purple",children:p.method}),e.jsxs(S,{children:["(",p.confidence,")"]}),e.jsxs(S,{children:["siblings=",p.siblingCount]})]})]}),(()=>{const L=f.pType!=null?`0x${f.pType.toString(16).toUpperCase().padStart(2,"0")}`:void 0,D=t.route!=null?`0x${t.route.toString(16).toUpperCase().padStart(2,"0")}`:void 0,P=fe(m),M=f.signalClass==="excellent"||f.signalClass==="good"?"green":f.signalClass==="fair"?"amber":"red",b=f.senderTier==="pubkey"?"green":f.senderTier==="prefix"?"amber":f.senderTier==="encrypted"?"teal":"zinc",w=[{fn:"type",value:f.payloadTypeName,raw:L,group:"wire",color:"blue"},{fn:"route",value:f.routeTypeName,raw:D,group:"wire",color:"blue"},{fn:"src_hash",value:t.src_hash||void 0,group:"wire",color:"blue"},{fn:"rssi",value:`${t.rssi}dBm`,group:"wire",color:"blue"},{fn:"snr",value:`${t.snr}dB`,group:"wire",color:"blue"},{fn:"_byteLength",value:f.byteLen?`${f.byteLen}B`:void 0,group:"enrichment",color:"blue"},{fn:"_hopCount",value:String(n.hopCount),group:"enrichment",color:"blue"},{fn:"_isZeroHop",value:String(n.isZeroHop),group:"enrichment",color:"blue"},{fn:"_advertSender",value:n.advertSender||void 0,group:"enrichment",color:"blue"},{fn:"_advertNodeType",value:f.advertType!=="unknown"?f.advertType:void 0,group:"enrichment",color:"blue"},{fn:"_advertName",value:n.advertName||void 0,group:"enrichment",color:"blue"},{fn:"_channelHash",value:n.channelHash||void 0,group:"enrichment",color:"blue"},...P,{fn:"is_duplicate",value:String(h.isDuplicate),group:"analysis",color:"purple"},p!=null&&p.inferredSrc?{fn:"traceSrc",value:p.inferredSrc,group:"analysis",color:"purple"}:{fn:"traceSrc"},{fn:"_signalClass",value:f.signalClass,group:"analysis",color:M},{fn:"_routeClass",value:f.routeClass,group:"analysis",color:"purple"},{fn:"_senderTier",value:f.senderTier,group:"analysis",color:b},{fn:"_origin",value:f.origin,group:"analysis",color:f.origin==="tx_local"?"green":f.origin==="tx_forward"?"amber":"purple"},{fn:"_pathAvail",value:f.pathAvail?`${f.pathHopCount} hops`:"none",group:"analysis",color:f.pathAvail?"green":"zinc"},{fn:"_age",value:f.age,group:"analysis",color:f.age==="live"||f.age==="recent"?"green":"zinc"},...h.dupeCount>0?[{fn:"_dupeCount",value:`×${h.dupeCount}`,group:"analysis",color:"purple"},...h.rssiRange?[{fn:"_multipath",value:`Δ${Math.abs(h.rssiRange[1]-h.rssiRange[0])}dB`,group:"analysis",color:Math.abs(h.rssiRange[1]-h.rssiRange[0])>6?"amber":"green"}]:[]]:[],...t.lbt_attempts!=null?[{fn:"_lbt",value:`${t.lbt_attempts} attempt${t.lbt_attempts!==1?"s":""}`,group:"analysis",color:(t.lbt_attempts??0)>1?"amber":"green"}]:[],...t.drop_reason?[{fn:"_dropReason",value:t.drop_reason,group:"analysis",color:"red"}]:[]];return e.jsx(se,{tokens:w})})()]})})]})}function be(t){switch(t){case"excellent":return"green";case"good":return"green";case"fair":return"amber";case"poor":return"red";case"critical":return"red";default:return"zinc"}}function ye(t){return`${Math.round(t*100)}%`}function je(t,s,a){return t||(s?s.slice(0,12):`~${a}`)}function At({hops:t}){return t.length===0?null:e.jsxs("div",{className:"mt-2 pt-2 border-t border-edge-subtle/40",children:[e.jsx("p",{className:"text-[9px] text-fg-muted/40 uppercase tracking-widest font-mono mb-1.5",children:"per-hop trace inspection"}),e.jsx("div",{className:"space-y-1",children:t.map(s=>e.jsx(q,{prefix:`trace.hop[${s.hopIndex}]`,children:e.jsxs("div",{className:"border border-edge-subtle/40 rounded px-2 py-1.5",children:[e.jsxs(i,{label:"link",children:[e.jsx(re,{hops:[s.fromPrefix,s.toPrefix],color:"blue"}),e.jsx("span",{className:"ml-1.5",children:e.jsx(_e,{color:be(s.quality),children:s.quality})})]}),e.jsx(i,{label:"snr",children:e.jsx(F,{raw:e.jsx("span",{className:"text-sys-blue",children:s.snrRaw}),children:e.jsx(d,{fn:"snr",value:`${s.snrRaw.toFixed(1)} dB`,color:be(s.quality)})})}),e.jsxs(i,{label:"from",children:[e.jsx(d,{fn:"resolve",value:je(s.fromName,s.fromHash,s.fromPrefix),color:s.fromHash?s.fromConfidence>=.8?"green":"amber":"purple"}),e.jsx("span",{className:"ml-1",children:e.jsx(d,{fn:"conf",value:ye(s.fromConfidence),color:"zinc"})})]}),e.jsxs(i,{label:"to",children:[e.jsx(d,{fn:"resolve",value:je(s.toName,s.toHash,s.toPrefix),color:s.toHash?s.toConfidence>=.8?"green":"amber":"purple"}),e.jsx("span",{className:"ml-1",children:e.jsx(d,{fn:"conf",value:ye(s.toConfidence),color:"zinc"})})]})]})},s.hopIndex))}),e.jsx(se,{label:"trace contributes",tokens:Et(t)})]})}function Et(t){const s=t.reduce((n,l)=>n+(l.fromHash?1:0)+(l.toHash?1:0),0),a=t.length*2,c=a-s,r=t.length>0?t.reduce((n,l)=>n+l.snrRaw,0)/t.length:0;return[{fn:"hops",value:String(t.length),group:"wire",color:"blue"},{fn:"resolved",value:`${s}/${a}`,group:"worker",color:"green"},...c>0?[{fn:"ghosts",value:String(c),group:"worker",color:"purple"}]:[],{fn:"avgSnr",value:`${r.toFixed(1)} dB`,group:"analysis",color:r>=5?"green":r>=0?"amber":"red"}]}function Ft(t){if(!t)return"never";const s=Math.floor((Date.now()-t)/1e3);return s<60?`${s}s ago`:s<3600?`${Math.floor(s/60)}m ago`:`${Math.floor(s/3600)}h ago`}function zt(t){if(!t)return[];const s=t.decoded;if(!s)return[{fn:"decrypt.result",value:"failed",group:"crypto",color:"red"}];if(!s.decrypted)return[{fn:"decrypt.result",value:"no key match",group:"crypto",color:"zinc"}];const a=[];return s.channelName&&a.push({fn:"decrypt.channelName",value:s.channelName,group:"crypto",color:"teal"}),s.senderName&&a.push({fn:"decrypt.senderName",value:s.senderName,group:"crypto",color:"teal"}),s.text&&a.push({fn:"decrypt.text",value:s.text,group:"crypto",color:"teal"}),s.timestamp&&a.push({fn:"decrypt.timestamp",value:new Date(s.timestamp*1e3).toISOString().slice(11,19),group:"crypto",color:"teal"}),s.macCorrupted&&a.push({fn:"decrypt.macCorrupted",value:"true",group:"crypto",color:"amber"}),a}function Ot({packet:t,decrypted:s,pipeline:a}){var b;const c=J(w=>w.isComputing),r=J(w=>w.lastUpdated),n=J(w=>w.lastComputeTimeMs),l=J(w=>w.topology.edges.length),o=J(w=>w.topology.discoveredNodes.length),x=et(),m=tt(),g=st(),u=xe(w=>w.isComputing),v=xe(w=>w.nodeCount),N=he(w=>w.progress),f=he(w=>w.initialDecodeComplete),k=t.type??t.payload_type,$=k===z.GRP_TXT||k===z.GRP_DATA,h=k===z.TRACE,y=k===z.PATH,p=$,_=[{label:"full",detail:"all GRP_TXT → decryption worker",active:p&&f,color:"teal"},{label:"quick",detail:"100 most recent (initial load)",active:p&&!f,color:"amber"},{label:"skip",detail:"non-GRP or catchup path",active:!p,color:"zinc"}],H=zt(s),C=((b=s==null?void 0:s.decoded)==null?void 0:b.decrypted)===!0,L=c?"running":`${l}e ${o}g`,D=u?"running":`${v}n`,P=p?C?"decrypted":N.isDecoding?`${N.percent}%`:"pending":"N/A",M=`topo ${c?"○":"✓"} ${L} · spark ${u?"○":"✓"} ${D} · decrypt ${P}`;return e.jsx(le,{stage:2,name:"CASCADE",fn:"hydrateDownstream()",verdict:M,children:e.jsx(q,{prefix:"cascade",children:e.jsxs("div",{className:"space-y-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 py-1.5 text-[11px] font-mono",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c?"bg-sys-amber animate-pulse":"bg-sys-green"}`}),e.jsx("span",{className:"text-fg-primary",children:"topology"}),e.jsxs("span",{className:"text-fg-muted",children:[l,"e ",o,"g"]}),(h||y)&&e.jsx("span",{className:"text-sys-green text-[9px]",children:"↑signal"})]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${u?"bg-sys-amber animate-pulse":"bg-sys-green"}`}),e.jsx("span",{className:"text-fg-primary",children:"sparkline"}),e.jsxs("span",{className:"text-fg-muted",children:[v,"n"]})]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${N.isDecoding?"bg-sys-amber animate-pulse":p?"bg-sys-teal":"bg-zinc-500/40"}`}),e.jsx("span",{className:"text-fg-primary",children:"decrypt"}),e.jsx("span",{className:p?"text-sys-teal":"text-fg-muted",children:p?C?"decrypted":N.isDecoding?`${N.percent}%`:"pending":"N/A"})]})]}),e.jsxs(G,{defaultOpen:h||y,children:[e.jsx(V,{className:"text-[10px] w-full border-t border-edge-subtle pt-1.5",children:e.jsx("span",{className:"font-mono text-fg-muted/50",children:"topology detail…"})}),e.jsx(U,{children:e.jsxs("div",{className:"ml-3 pb-2",children:[e.jsx(i,{label:"status",children:e.jsx(d,{fn:"isComputing",value:c?"running":"idle",color:c?"amber":"green"})}),e.jsxs(i,{label:"last",children:[e.jsx(d,{fn:"lastUpdated",value:Ft(r),color:"zinc"}),n>0&&e.jsxs("span",{className:"ml-2 text-fg-muted text-[10px]",children:["(",n<1e3?`${n.toFixed(0)}ms`:`${(n/1e3).toFixed(1)}s`,")"]})]}),e.jsxs(i,{label:"output",children:[e.jsx(d,{fn:"edges",value:String(l),color:"green"}),e.jsx(d,{fn:"ghostNodes",value:String(o),color:"purple"})]}),m&&e.jsxs(e.Fragment,{children:[e.jsxs(i,{label:"trace links",children:[e.jsx(d,{fn:"directed",value:String(x.totalDirectedLinks),color:"teal"}),e.jsx(d,{fn:"bidir",value:String(x.bidirectionalLinks),color:"teal"}),e.jsx(d,{fn:"traces",value:String(x.totalTraces),color:"zinc"})]}),e.jsxs(i,{label:"trace SNR",children:[e.jsx(d,{fn:"mean",value:`${x.meanSnr.toFixed(1)} dB`,color:x.meanSnr>=5?"green":x.meanSnr>=0?"amber":"red"}),e.jsx(d,{fn:"median",value:`${x.medianSnr.toFixed(1)} dB`,color:"zinc"}),e.jsx(d,{fn:"confidence",value:`${Math.round(x.avgConfidence*100)}%`,color:"zinc"})]}),h&&e.jsxs(i,{label:"quality",children:[e.jsx(d,{fn:"excellent",value:String(x.qualityCounts.excellent),color:"green"}),e.jsx(d,{fn:"good",value:String(x.qualityCounts.good),color:"green"}),e.jsx(d,{fn:"fair",value:String(x.qualityCounts.fair),color:"amber"}),e.jsx(d,{fn:"poor",value:String(x.qualityCounts.poor),color:"red"}),e.jsx(d,{fn:"critical",value:String(x.qualityCounts.critical),color:"red"})]}),g.confirmedResolutions.size>0&&e.jsxs(i,{label:"feedback",children:[e.jsx(d,{fn:"feedback.confirmed",value:String(g.confirmedResolutions.size),color:"teal"}),e.jsx(d,{fn:"feedback.links",value:String(g.confirmedLinks.length),color:"teal"})]})]}),h&&(a==null?void 0:a.traceHopDetail)&&e.jsx(At,{hops:a.traceHopDetail})]})})]}),p&&e.jsx("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:e.jsxs("div",{className:"ml-3",children:[e.jsx(i,{label:"mode",children:e.jsx(ae,{options:_,nextFn:"queueDecryption()"})}),e.jsx(i,{label:"result",children:e.jsx(d,{fn:"decrypt",value:C?"decrypted":s?"failed":"pending",color:C?"teal":s?"red":"zinc"})}),C&&e.jsx("div",{className:"mt-1 flex flex-wrap gap-x-1.5 gap-y-1",children:H.map((w,oe)=>e.jsx("span",{className:"inline-block border border-edge-subtle rounded px-1.5 py-0.5",children:e.jsx(d,{fn:w.fn,value:w.value,color:w.color})},oe))})]})}),(()=>{const w=[{fn:"topology.edges",value:String(l),group:"worker",color:"green"},{fn:"topology.ghostNodes",value:String(o),group:"worker",color:"purple"},{fn:"sparkline.nodes",value:`${v}`,group:"worker",color:"green"},...m?[{fn:"trace.directedLinks",value:String(x.totalDirectedLinks),group:"worker",color:"teal"},{fn:"trace.meanSnr",value:`${x.meanSnr.toFixed(1)} dB`,group:"worker",color:"teal"}]:[],...H];return e.jsx(se,{tokens:w})})()]})})})}function Bt(t,s,a,c){var n;const r=t.src_hash?Se(t.src_hash):"";if(t._advertSender&&s.hash&&s.confident)return{tier:1,label:"_advertSender → pubkey",detail:"ADVERT carried full 32-byte public key — definitive match"};if(c&&s.confident&&((n=s.name)==null?void 0:n.toLowerCase())===c.toLowerCase())return{tier:1.5,label:"decrypt.senderName → nameToHash",detail:`Decrypted sender name “${c}” matched neighbor — high-confidence`};if(r&&a.crossClassPrefixes.has(r))return{tier:2,label:"cross-class prefix",detail:"Prefix has mixed types (repeater + non-repeater); payload type narrows to one class"};if(s.confident){const l=a.prefixIndex.get(r);return(l==null?void 0:l.length)===1?{tier:3,label:"single candidate",detail:"Only one node matches this prefix — unambiguous"}:{tier:3,label:"resolver",detail:"Multi-signal scoring selected best candidate from collision set"}}return{tier:4,label:"ambiguous",detail:"Cannot confidently resolve — multiple same-class candidates, insufficient scoring separation"}}function It(t,s){const a=t.original_path??t.forwarded_path,c=new Set;if(a&&Array.isArray(a))for(const r of a){const n=String(r).toUpperCase().slice(0,2);n.length>=2&&n!==s&&c.add(n)}return c}function Gt(t,s,a,c,r,n,l){const o=Math.floor(Date.now()/1e3),x=new Map(a.map(m=>[m.hash,m]));return t.map(m=>{const g=s[m.hash],u=x.get(m.hash);let v=!0,N="";c!=="unknown"?m.type!=="unknown"&&m.type!==c?(v=!1,N=`${m.type} ≠ required ${c}`):m.type===c?N="type matches":N="type unknown — not ruled out":N="payload ambiguous — all types eligible";const f=!!(g!=null&&g.zero_hop),k=(g==null?void 0:g.last_seen)??0;let $=0;if(f&&k>0){const b=(o-k)/3600;$=50*Math.exp(-b/l)}let h=0;if(k>0){const b=(o-k)/3600;h=Math.exp(-b/n)}const y=h*20,p=!!(g!=null&&g.latitude&&(g!=null&&g.longitude)&&(g.latitude!==0||g.longitude!==0)),_=p?5:0,H=(u==null?void 0:u.advertCount)??0,C=Math.min(H*2,30),L=(u==null?void 0:u.forwarderPrefixes.size)??0,D=Math.min(L*3,15);let P=0;if(u&&u.totalForwarderObservations>0&&r.size>0){let b=0;for(const w of r)u.forwarderPrefixes.has(w)&&b++;P=b/r.size}const M=$+y+_+C+D;return{hash:m.hash,name:m.name,type:m.type,roleCompatible:v,roleReason:N,zeroHop:f,zeroHopScore:$,lastSeen:k,recencyScore:h,recencyPoints:y,hasGps:p,gpsScore:_,advertCount:H,advertScore:C,topoWidth:L,topoScore:D,affinity:P,total:M}}).sort((m,g)=>g.total-m.total)}function Vt({packet:t,pipeline:s,resolved:a,resolveTimeMs:c,advertName:r,neighbors:n,decrypted:l}){var ie,de;const o=Y(j=>j.neighborContext),x=Y(j=>j.topologyProfiles),m=Y(j=>j.config),{analysis:g}=s,u=a??{hash:null,type:"unknown",name:null,confident:!1},v=t.src_hash?Se(t.src_hash):"",N=v?o.prefixIndex.get(v)??[]:[],f=v?x.get(v)??[]:[],k=g.pType??-1,$=k>=0?k.toString(16).toUpperCase().padStart(2,"0"):"??",h=g.inferredType,y=g.advertType,p=g.effectiveType,_=t._advertNodeType!=null?t._advertNodeType.toString(16).padStart(2,"0").toUpperCase():"",H=((ie=l==null?void 0:l.decoded)==null?void 0:ie.senderName)??null,C=Bt(t,u,o,H),L=T.useMemo(()=>It(t,v),[t,v]),D=g.pathLen,P=T.useMemo(()=>Gt(N,n,f,p,L,m.recencyDecayHours,m.zeroHopDecayHours),[N,n,f,p,L,m.recencyDecayHours,m.zeroHopDecayHours]),M=P.filter(j=>!j.roleCompatible),b=P.filter(j=>j.roleCompatible),w=t._advertSender?o.pubKeyMap.get(t._advertSender)??null:null,oe=C.tier===1,Le=[{fn:"src_hash",value:v||"",active:!!v,color:"blue"},{fn:"_advertSender",value:t._advertSender?t._advertSender.slice(0,12)+"…":"",active:!!t._advertSender,color:"blue"},{fn:"_advertNodeType",value:_?`0x${_}`:"",active:t._advertNodeType!=null,color:"blue"},{fn:"path_length",value:D!=null?D===0?"zero-hop":String(D):"",active:D!=null,color:"blue"},{fn:"decrypt.senderName",value:H??"",active:!!H,color:"teal"}],De=[{label:"hit",detail:"pubKeyMap.get(_advertSender) → definitive",active:!!w,color:"green"},{label:"miss",detail:t._advertSender?"pubkey not in neighbor table":"no _advertSender",active:!w,color:"zinc"}],Pe=[{label:"payload",detail:`inferDeviceType(0x${$}) → ${h}`,active:h!=="unknown",color:"amber"},{label:"flags",detail:_?`mapAdvertTypeCode(0x${_}) → ${y}`:"no _advertNodeType",active:h==="unknown"&&y!=="unknown",color:"green"},{label:"ambiguous",detail:"all types eligible",active:p==="unknown",color:"zinc"}],Me=u.name??((de=u.hash)==null?void 0:de.slice(0,12))??"?",Re=u.confident?"confident":"ambiguous",Ae=`→ ${Me} (${Re}, Tier ${C.tier})`;return e.jsx(le,{stage:3,name:"RESOLVE",fn:"usePipelineStore.resolveSource()",verdict:Ae,timeMs:c,children:e.jsx(q,{prefix:"resolvePacketSource",children:e.jsxs("div",{className:"space-y-0",children:[e.jsx("div",{className:"pt-1 pb-1",children:e.jsx(Ct,{tokens:Le,nextFn:"resolvePacketSource()"})}),t.src_hash?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"1"})," ","PUBKEY LOOKUP"]}),e.jsx(ae,{options:De,nextFn:"pubKeyMap.get()"}),e.jsx("div",{className:"ml-3 mt-1",children:w?e.jsxs(e.Fragment,{children:[e.jsx(i,{label:"resolved",children:e.jsx(d,{fn:"hash",value:w,color:"green"})}),r&&e.jsxs(i,{label:"name",children:[e.jsx(d,{fn:"name",value:r,color:"green"}),u.name&&r===u.name&&e.jsx(S,{c:"text-sys-green ml-1",children:"✓ neighbor match"})]}),e.jsxs(i,{label:"result",children:[e.jsx(R,{color:"green",children:"Tier 1"}),e.jsx(S,{c:"text-fg-primary ml-1",children:"definitive — scoring bypassed"})]})]}):t._advertSender?e.jsx(i,{label:"status",children:e.jsx(S,{c:"text-sys-amber",children:"✗ pubkey not in neighbor table"})}):e.jsx(i,{label:"status",children:e.jsx(S,{children:"no _advertSender — skip to prefix resolution"})})})]}),oe?e.jsx("div",{className:"border-t border-edge-subtle py-2",children:e.jsx("p",{className:"text-[11px] text-fg-muted/40 font-mono ml-3",children:"Steps 2–5 bypassed — pubkey definitive"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"2"})," ","CANDIDATE POOL — ",N.length," node",N.length!==1?"s":"",' match "',v,'"']}),e.jsxs("div",{className:"space-y-0.5 ml-3",children:[P.map(j=>e.jsxs("div",{className:"flex gap-2 items-center text-[11px]",children:[e.jsx("span",{className:"break-all text-[10px]",children:j.hash}),e.jsx(R,{color:"zinc",children:j.type||"unknown"}),j.name&&e.jsx(S,{children:j.name})]},j.hash)),N.length===0&&e.jsx(S,{children:"no known nodes for this prefix"})]})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"3"})," ","TYPE INFERENCE"]}),e.jsx(ae,{options:Pe,nextFn:"effectiveType()"}),e.jsx("div",{className:"ml-3 mt-1",children:e.jsx(i,{label:"effective",children:e.jsx(d,{fn:"effectiveType",value:p,color:p!=="unknown"?h!=="unknown"?"amber":"green":"zinc"})})})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"4"})," ","ROLE-TYPE SCRUB"]}),e.jsx("div",{className:"space-y-0.5 ml-3",children:P.map(j=>e.jsxs("div",{className:"flex gap-2 items-center text-[11px]",children:[e.jsx("span",{className:j.roleCompatible?"text-sys-green":"text-sys-red",children:j.roleCompatible?"✓":"✗"}),e.jsx("span",{className:`break-all text-[10px] ${j.roleCompatible?"":"line-through text-fg-muted"}`,children:j.hash}),e.jsx(R,{color:j.roleCompatible?"zinc":"red",children:j.type||"unknown"}),e.jsx(S,{c:j.roleCompatible?"text-fg-muted":"text-sys-red",children:j.roleReason})]},j.hash))}),M.length>0&&e.jsxs("p",{className:"text-[10px] text-fg-muted mt-1 ml-3",children:[M.length," eliminated, ",b.length," surviving"]})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-blue font-bold",children:"5"})," ","CANDIDATE SCORING"]}),b.length===0?e.jsx("p",{className:"text-fg-muted italic ml-3",children:"No surviving candidates"}):b.length===1?e.jsxs("div",{className:"ml-3 text-[11px]",children:[e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(S,{c:"text-sys-green",children:"→"}),e.jsx("span",{className:"break-all text-[10px]",children:b[0].hash}),b[0].name&&e.jsx(S,{c:"text-fg-muted ml-1",children:b[0].name})]}),e.jsx("p",{className:"text-fg-muted ml-4",children:"single survivor — scoring not needed"})]}):e.jsxs(G,{children:[e.jsx(V,{className:"text-[10px] ml-3",children:e.jsxs("span",{className:"font-mono text-fg-muted/50",children:[b.length," candidates scored…"]})}),e.jsx(U,{children:e.jsx("div",{className:"space-y-2 ml-3 mt-1",children:b.map(j=>{const Q=j.hash===u.hash;return e.jsxs("div",{className:`text-[11px] leading-relaxed rounded px-2 py-1 ${Q?"bg-sys-green/8 border border-sys-green/20":"bg-zinc-500/5"}`,children:[e.jsxs("div",{className:"flex gap-2 items-center mb-0.5",children:[e.jsx(S,{c:Q?"text-sys-green":"text-fg-muted",children:Q?"→":" "}),e.jsx("span",{className:`break-all text-[10px] ${Q?"text-fg-primary":"text-fg-muted"}`,children:j.hash}),e.jsx(R,{color:Q?"green":"zinc",children:j.type||"unknown"}),j.name&&e.jsx(S,{children:j.name})]}),e.jsxs("div",{className:"ml-4 flex flex-wrap gap-x-3 gap-y-0.5",children:[e.jsxs("span",{children:[e.jsx(S,{children:"zero_hop:"})," ",e.jsx(S,{c:j.zeroHop?"text-sys-green":"text-fg-muted",children:j.zeroHop?"✓":"✗"})," ",e.jsxs(R,{color:ee(j.zeroHopScore),children:["+",j.zeroHopScore]})]}),e.jsxs("span",{children:[e.jsx(S,{children:"recency:"})," ",e.jsx(S,{c:"text-fg-primary",children:mt(j.lastSeen)})," ",e.jsxs(R,{color:ee(j.recencyPoints),children:["+",j.recencyPoints.toFixed(1)]})]}),e.jsxs("span",{children:[e.jsx(S,{children:"gps:"})," ",e.jsx(S,{c:j.hasGps?"text-sys-green":"text-fg-muted",children:j.hasGps?"✓":"✗"})," ",e.jsxs(R,{color:ee(j.gpsScore),children:["+",j.gpsScore]})]}),e.jsxs("span",{children:[e.jsx(S,{children:"adverts:"})," ",e.jsx(S,{c:"text-fg-primary",children:j.advertCount})," ",e.jsxs(R,{color:ee(j.advertScore),children:["+",j.advertScore]})]}),e.jsxs("span",{children:[e.jsx(S,{children:"topo:"})," ",e.jsx(S,{c:"text-fg-primary",children:j.topoWidth})," ",e.jsxs(R,{color:ee(j.topoScore),children:["+",j.topoScore]})]})]}),e.jsxs("div",{className:"ml-4 mt-0.5",children:[e.jsx(S,{children:"score ≈"})," ",e.jsx(S,{c:"text-fg-primary font-bold",children:j.total.toFixed(1)})]})]},j.hash)})})})]})]})]}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:[e.jsxs("p",{className:"text-fg-muted mb-1",children:[e.jsx(S,{c:"text-sys-green font-bold",children:"✓"})," ","RESOLUTION"]}),e.jsxs("div",{className:"ml-3",children:[e.jsx(i,{label:"hash",children:u.hash?e.jsx(d,{fn:"resolved.hash",value:u.hash,color:"green"}):e.jsx(S,{children:"null"})}),e.jsx(i,{label:"type",children:e.jsx(d,{fn:"resolved.type",value:u.type,color:u.confident?"green":"zinc"})}),e.jsx(i,{label:"name",children:u.name?e.jsx(d,{fn:"resolved.name",value:u.name,color:u.confident?"green":"amber"}):e.jsx(S,{children:"null"})}),e.jsx(i,{label:"confident",children:e.jsx(S,{c:u.confident?"text-sys-green":"text-sys-red",children:String(u.confident)})}),e.jsxs(i,{label:"tier",children:[e.jsx(R,{color:C.tier<=2?"green":C.tier===3?"amber":"red",children:C.tier}),e.jsx(S,{c:"text-fg-primary ml-1",children:C.label})]})]})]})]}):e.jsx("div",{className:"border-t border-edge-subtle pt-2 pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] font-mono",children:[e.jsx(S,{c:"text-sys-amber",children:"⚠ no src_hash"}),H&&e.jsx(d,{fn:"decrypt.senderName",value:H,color:"teal"}),u.confident?e.jsxs(S,{c:"text-sys-green",children:["→ resolved via ",C.label]}):e.jsx(S,{c:"text-sys-red",children:"ambiguous"})]})}),(()=>{const j=[{fn:"resolved.hash",value:u.hash??"null",group:"resolution",color:u.confident?"green":"zinc"},{fn:"resolved.type",value:u.type,group:"resolution",color:u.type!=="unknown"?u.confident?"green":"amber":"zinc"},{fn:"resolved.name",value:u.name??"null",group:"resolution",color:u.confident?"green":u.name?"amber":"zinc"},{fn:"resolved.confident",value:String(u.confident),group:"resolution",color:u.confident?"green":"red"}];return e.jsx(se,{tokens:j})})()]})})})}const Ut={id:"packet-parse",label:"Packet Parse",inputs:["rawPacket"],outputs:["parsedPacket","decoded","headerFields"],emits:[{fn:"routeType",group:"wire",color:"blue"},{fn:"payloadType",group:"wire",color:"blue"},{fn:"pathLength",group:"wire",color:"blue"},{fn:"version",group:"wire",color:"blue"}],async:!1,observatoryStage:0},qt={id:"enrichment",label:"Ingestion Enrichment",inputs:["parsedPacket"],outputs:["advertSender","channelHash","hopData","byteLength"],emits:[{fn:"_advertSender",group:"enrichment",color:"blue"},{fn:"_advertNodeType",group:"enrichment",color:"blue"},{fn:"_channelHash",group:"enrichment",color:"blue"},{fn:"_hopCount",group:"enrichment",color:"blue"},{fn:"_isZeroHop",group:"enrichment",color:"blue"},{fn:"_byteLength",group:"enrichment",color:"blue"}],async:!1,observatoryStage:1},Kt={id:"topology",label:"Topology Analysis",inputs:["packets","neighbors","srcHashResolver"],outputs:["edges","nodeMetrics","pathHealth","ghostNodes","centrality","loops"],emits:[{fn:"edges",group:"worker",color:"green"},{fn:"ghostNodes",group:"worker",color:"purple"},{fn:"loops",group:"analysis",color:"amber"},{fn:"nodeMetrics",group:"worker",color:"green"},{fn:"pathHealth",group:"worker",color:"green"},{fn:"centrality",group:"worker",color:"green"}],async:!0,worker:"topology.worker.ts",observatoryStage:2},Wt={id:"trace-enrichment",label:"Trace Link Quality",inputs:["packets","prefixLookup","srcHashResolver","edges","pathHealth","nodeMetrics"],outputs:["traceLinks","traceLinkSummary","traceDisambiguationFeedback"],emits:[{fn:"traceLinks.directed",group:"worker",color:"teal"},{fn:"traceLinks.bidir",group:"worker",color:"teal"},{fn:"traceSummary.meanSnr",group:"analysis",color:"green"},{fn:"traceSummary.medianSnr",group:"analysis",color:"zinc"},{fn:"traceSummary.confidence",group:"analysis",color:"zinc"},{fn:"feedback.confirmed",group:"worker",color:"teal"},{fn:"feedback.links",group:"worker",color:"teal"}],async:!1,observatoryStage:2},Yt={id:"disambiguation",label:"Source Disambiguation",inputs:["packets","neighbors","decodedMessages"],outputs:["srcHashResolverMap","neighborContext"],emits:[{fn:"resolvedHash",group:"resolution",color:"purple"},{fn:"resolvedName",group:"resolution",color:"purple"},{fn:"resolvedType",group:"resolution",color:"purple"},{fn:"confidence",group:"resolution",color:"green"}],async:!1,observatoryStage:3},Zt={id:"sparkline",label:"Sparkline Computation",inputs:["packets","neighbors"],outputs:["sparklineData"],emits:[{fn:"sparklines",group:"worker",color:"blue"}],async:!0,worker:"sparkline.worker.ts"},Xt={id:"decryption",label:"Channel Decryption",inputs:["packets","channelKeys"],outputs:["decodedMessages"],emits:[{fn:"decrypt.text",group:"crypto",color:"teal"},{fn:"decrypt.senderName",group:"crypto",color:"teal"},{fn:"decrypt.channelName",group:"crypto",color:"teal"},{fn:"decrypt.macCorrupted",group:"crypto",color:"amber"}],async:!0,worker:"decryption.worker.ts",observatoryStage:2},Qt={id:"decoded-content",label:"Decoded Content Policy",inputs:["decodedMessages","packets"],outputs:["decodedContent","contentInheritance"],emits:[{fn:"content.senderName",group:"crypto",color:"teal"},{fn:"content.text",group:"crypto",color:"teal"},{fn:"content.channelName",group:"crypto",color:"teal"},{fn:"content.corrupted",group:"crypto",color:"amber"},{fn:"content.inherited",group:"analysis",color:"purple"}],async:!1},Z=[Ut,qt,Kt,Wt,Yt,Zt,Xt,Qt],Jt=new Map(Z.map(t=>[t.id,t])),es=new Map;for(const t of Z)for(const s of t.emits)es.set(s.fn,t);const $e=new Map;for(const t of Z)for(const s of t.outputs)$e.set(s,t);function ts(){const t=new Map,s=new Map;for(const r of Z)t.has(r.id)||t.set(r.id,0),s.has(r.id)||s.set(r.id,new Set);for(const r of Z)for(const n of r.inputs){const l=$e.get(n);if(l&&l.id!==r.id){const o=s.get(l.id);o.has(r.id)||(o.add(r.id),t.set(r.id,(t.get(r.id)??0)+1))}}const a=[];for(const[r,n]of t)n===0&&a.push(r);const c=[];for(;a.length>0;){const r=a.shift(),n=Jt.get(r);n&&c.push(n);for(const l of s.get(r)??[]){const o=(t.get(l)??1)-1;t.set(l,o),o===0&&a.push(l)}}for(const r of Z)c.includes(r)||c.push(r);return c}const ss={0:"text-sys-green",1:"text-sys-blue",2:"text-sys-teal",3:"text-sys-purple"};function ns({stage:t,isActive:s,onClick:a}){const c=t.observatoryStage!=null?ss[t.observatoryStage]??"text-fg-muted":"text-fg-muted/40";return e.jsxs("button",{type:"button",onClick:a,className:` - flex items-center gap-1.5 w-full px-1.5 py-1 rounded transition-base text-left - ${s?"bg-sys-blue/10 ring-1 ring-sys-blue/30":"hover:bg-zinc-500/5"} - `,children:[e.jsx("span",{className:`font-mono text-[9px] font-bold w-3 shrink-0 text-center ${c}`,children:t.observatoryStage??"·"}),e.jsx("span",{className:"font-mono text-[9px] text-fg-primary truncate flex-1",children:t.label}),t.async&&e.jsx("span",{className:"font-mono text-[7px] px-1 py-px rounded bg-sys-amber/15 text-sys-amber shrink-0 leading-tight",children:"⚡"}),t.emits.length>0&&e.jsxs("span",{className:"flex items-center gap-px shrink-0",children:[t.emits.slice(0,6).map(r=>{var n;return e.jsx("span",{className:`inline-block w-1 h-1 rounded-full ${((n=I[r.color])==null?void 0:n.dot)??"bg-zinc-500"}`,title:`${r.fn} [${r.group}]`},r.fn)}),t.emits.length>6&&e.jsxs("span",{className:"font-mono text-[7px] text-fg-muted/40 ml-0.5",children:["+",t.emits.length-6]})]})]})}function rs({activeStageId:t,onStageClick:s}){const a=T.useMemo(()=>ts(),[]),c=T.useMemo(()=>{const r=new Map;for(const l of a){const o=l.observatoryStage??"other";let x=r.get(o);x||(x=[],r.set(o,x)),x.push(l)}const n=[];for(const l of[0,1,2,3,"other"]){const o=r.get(l);o!=null&&o.length&&n.push({key:l,stages:o})}return n},[a]);return e.jsxs("div",{className:"surface-base rounded-lg border border-edge-subtle p-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-mono text-[8px] text-fg-muted/40 uppercase tracking-widest",children:"Pipeline DAG"}),e.jsxs("span",{className:"font-mono text-[8px] text-fg-muted/30",children:[a.length," stages"]})]}),e.jsx("div",{className:"space-y-px",children:c.map((r,n)=>e.jsxs("div",{children:[n>0&&e.jsx("div",{className:"flex items-center pl-2.5 py-px",children:e.jsx("svg",{width:"6",height:"8",viewBox:"0 0 6 8",className:"text-fg-muted/20",children:e.jsx("path",{d:"M3 0 L3 6 M1 4 L3 6 L5 4",fill:"none",stroke:"currentColor",strokeWidth:"1"})})}),r.stages.map(l=>e.jsx(ns,{stage:l,isActive:t===l.id,onClick:s?()=>s(l.id):void 0},l.id))]},String(r.key)))})]})}const ve=200,O={status:"idle",lastDurationMs:null,lastTs:null,runCount:0};function as(t,s,a){var c,r,n;switch(t.type){case"transport:ws:state":s.wsState=((c=t.data)==null?void 0:c.state)??a.wsState;break;case"transport:ws:packet":s.wsPacketCount=(s.wsPacketCount??a.wsPacketCount)+1;break;case"transport:ws:stats":s.wsStatsCount=(s.wsStatsCount??a.wsStatsCount)+1;break;case"transport:rest:stats":s.restStatsCount=(s.restStatsCount??a.restStatsCount)+1;break;case"transport:rest:packets":s.restPacketsCount=(s.restPacketsCount??a.restPacketsCount)+1;break;case"store:packets:ws-merge":s.wsMergeCount=(s.wsMergeCount??a.wsMergeCount)+1;break;case"cascade:hydrate":s.lastHydrateTs=t.ts,s.hydrateCount=(s.hydrateCount??a.hydrateCount)+1;break;case"worker:topology:start":case"worker:sparkline:start":{const l=t.type.split(":")[1],o=s.workers??a.workers,x=o[l]??{...O};s.workers={...o,[l]:{...x,status:"running",lastTs:t.ts}}}break;case"worker:topology:done":case"worker:sparkline:done":{const l=t.type.split(":")[1],o=s.workers??a.workers,x=o[l]??{...O},m=((r=t.data)==null?void 0:r.ms)??null;s.workers={...o,[l]:{...x,status:"done",lastDurationMs:m,lastTs:t.ts,runCount:x.runCount+1}}}break;case"worker:decryption:batch":{const l=s.workers??a.workers,o=l.decryption??{...O},x=((n=t.data)==null?void 0:n.ms)??null;s.workers={...l,decryption:{...o,status:"done",lastDurationMs:x,lastTs:t.ts,runCount:o.runCount+1}}}break;case"pipeline:disambig:recompute":s.disambigCount=(s.disambigCount??a.disambigCount)+1;break}}const te=nt(t=>({events:[],eventCount:0,wsState:"disconnected",wsPacketCount:0,wsStatsCount:0,restStatsCount:0,restPacketsCount:0,workers:{topology:{...O},sparkline:{...O},decryption:{...O}},wsMergeCount:0,lastHydrateTs:null,hydrateCount:0,disambigCount:0,lastDisambigMs:null,_pushBatch:s=>t(a=>{if(s.length===0)return a;let c=[...a.events,...s];c.length>ve&&(c=c.slice(c.length-ve));const r={events:c,eventCount:a.eventCount+s.length};for(const n of s)as(n,r,a);return r}),clear:()=>t({events:[],eventCount:0,wsState:"disconnected",wsPacketCount:0,wsStatsCount:0,restStatsCount:0,restPacketsCount:0,workers:{topology:{...O},sparkline:{...O},decryption:{...O}},wsMergeCount:0,lastHydrateTs:null,hydrateCount:0,disambigCount:0,lastDisambigMs:null})}));let W=null,B=[],X=null;function ls(){if(X=null,B.length===0)return;const t=B;B=[],te.getState()._pushBatch(t)}function os(){W||(B=[],W=rt.subscribe(t=>{B.push(t),X===null&&(X=requestAnimationFrame(ls))}))}function cs(){if(W==null||W(),W=null,X!==null&&(cancelAnimationFrame(X),X=null),B.length>0){const t=B;B=[],te.getState()._pushBatch(t)}}function is(t){switch(t){case"active":return"●";case"skipped":return"○";case"inferred":return"◌"}}function ds(t){switch(t){case"active":return"text-sys-green";case"skipped":return"text-fg-muted/30";case"inferred":return"text-sys-amber"}}function us(t){switch(t){case"transport":return"text-sys-blue";case"store":return"text-sys-amber";case"worker":return"text-sys-violet";case"pipeline":return"text-sys-green";case"consumer":return"text-sys-teal"}}function ps(t,s,a,c,r){var m,g;const n=[];if(r?n.push({label:"Hex Input",detail:"Manual hex — no transport",status:"skipped",lane:"transport"}):s.age==="live"||s.age==="recent"?n.push({label:"WebSocket",detail:"ws:packet → real-time push",status:"active",lane:"transport"}):n.push({label:"REST Poll",detail:"fetchPackets → packetCache.poll()",status:"inferred",lane:"transport"}),!r){n.push({label:"Cache Merge",detail:"packetCache.mergePacketsDirectly()",status:"active",lane:"store"});const u=s.age==="live"||s.age==="recent";n.push({label:"Flash",detail:u?"flashReceived++ → sidebar blink":"Not newest — no flash",status:u?"active":"skipped",lane:"store"}),n.push({label:"Hydrate Cascade",detail:"hydrateDownstream() → schedule workers",status:"active",lane:"store"})}const l=s.pathAvail||s.pathHopCount>0;n.push({label:"Topology Worker",detail:l?`Path data (${s.pathHopCount} hops) → edge extraction`:"No path data — still included in batch recompute",status:"active",lane:"worker"}),n.push({label:"Sparkline Worker",detail:`Contributes to sparkline for src ${((m=t.src_hash)==null?void 0:m.slice(0,4))??"??"}`,status:"active",lane:"worker"});const o=s.isGrp;n.push({label:"Decryption Worker",detail:o?`GRP_TXT → queued for channel key search${c?" → decrypted ✓":""}`:`${s.payloadTypeName} — not encrypted, skipped`,status:o?"active":"skipped",lane:"worker"}),n.push({label:"Source Disambiguation",detail:a?`→ ${a.name??((g=a.hash)==null?void 0:g.slice(0,8))??"?"} (${a.type}${a.confident?", confident":", ambiguous"})`:"Pending recompute",status:a?"active":"inferred",lane:"pipeline"}),s.isAdvert&&n.push({label:"ADVERT Discovery",detail:"pubkey → extended hash-to-type + name extraction",status:"active",lane:"pipeline"}),o&&(c!=null&&c.decoded)&&n.push({label:"Decoded Content Policy",detail:`macCorrupted=${c.decoded.macCorrupted?"true":"false"} → cross-hash inheritance`,status:"active",lane:"pipeline"});const x=["Packets","Dashboard","Statistics"];return l&&x.push("Map","Graph"),s.isTrace&&x.push("Trace Detail"),n.push({label:"Page Hydration",detail:x.join(", "),status:"active",lane:"consumer"}),n}const xs=[],hs=["transport","store","worker","pipeline","consumer"],ms={transport:"Transport",store:"Store",worker:"Workers",pipeline:"Pipeline",consumer:"Consumers"};function gs(t){return t.replace("transport:","").replace("store:packets:","").replace("cascade:","").replace("worker:","w:").replace("pipeline:","p:").replace("packet","pkt").replace("sparkline","spark").replace("topology","topo").replace("decryption","dec").replace("disambig","dis").replace("recompute","recomp")}function fs(t){return t.startsWith("transport:")?"text-sys-blue":t.startsWith("store:")||t.startsWith("cascade:")?"text-sys-amber":t.startsWith("worker:")?"text-sys-violet":t.startsWith("pipeline:")?"text-sys-green":"text-fg-muted"}const bs=T.memo(function({event:s}){const a=`${(s.ts/1e3).toFixed(1)}s`,c=s.data?Object.entries(s.data).map(([r,n])=>{var l;return`${r}=${typeof n=="number"?((l=n.toFixed)==null?void 0:l.call(n,1))??n:n}`}).join(" "):"";return e.jsxs("div",{className:"flex gap-2 text-[9px] font-mono leading-tight",children:[e.jsx("span",{className:"text-fg-muted/40 w-12 shrink-0 text-right",children:a}),e.jsx("span",{className:`w-20 shrink-0 ${fs(s.type)}`,children:gs(s.type)}),e.jsx("span",{className:"text-fg-muted/60 truncate",children:c})]})});function ys({packet:t,pipeline:s,resolved:a,decrypted:c,isSynthetic:r,liveMode:n}){const[l,o]=T.useState(!1);T.useEffect(()=>{if(l)return os(),()=>{cs()}},[l]);const x=s==null?void 0:s.analysis,m=T.useMemo(()=>!t||!x?null:ps(t,x,a,c,r),[t,x,a,c,r]),g=T.useMemo(()=>{if(!m)return null;const h=new Map;for(const y of m){let p=h.get(y.lane);p||(p=[],h.set(y.lane,p)),p.push(y)}return h},[m]),u=te(h=>l?h.events:xs),v=te(h=>l?h.eventCount:0),N=te(h=>h.clear),f=T.useRef(null);T.useEffect(()=>{l&&f.current&&(f.current.scrollTop=f.current.scrollHeight)},[v,l]);const k=(m==null?void 0:m.filter(h=>h.status==="active").length)??0,$=(m==null?void 0:m.length)??0;return e.jsxs(G,{defaultOpen:!0,children:[e.jsx(V,{className:"text-[10px]",children:e.jsxs("span",{className:"flex items-center gap-2 font-mono",children:[e.jsx("span",{className:"text-sys-green",children:"CFT"}),e.jsx("span",{className:"text-fg-muted/40",children:"Control Flow Trace"}),t&&e.jsxs("span",{className:"text-fg-muted/30",children:["— ",k,"/",$," stages active"]})]})}),e.jsx(U,{children:e.jsxs("div",{className:"surface-base rounded-lg border border-edge-subtle p-3 space-y-3",children:[t?g?e.jsx("div",{className:"space-y-2",children:hs.map(h=>{const y=g.get(h);return y?e.jsxs("div",{children:[e.jsx("div",{className:`text-[8px] uppercase tracking-widest font-mono mb-0.5 ${us(h)}`,children:ms[h]}),y.map((p,_)=>e.jsxs("div",{className:"flex items-start gap-1.5 text-[10px] font-mono leading-snug ml-1",children:[e.jsx("span",{className:`shrink-0 ${ds(p.status)}`,children:is(p.status)}),e.jsx("span",{className:"text-fg-primary",children:p.label}),e.jsx("span",{className:"text-fg-muted/50 truncate",children:p.detail})]},_))]},h):null})}):null:e.jsx("div",{className:"text-[9px] text-fg-muted/30 font-mono py-2 text-center",children:"Select a packet to trace its flow"}),e.jsxs("div",{className:"border-t border-edge-subtle pt-2 flex items-center gap-2",children:[e.jsx("button",{onClick:()=>o(h=>!h),className:`px-2 py-0.5 rounded text-[9px] font-mono transition-colors ${l?"bg-sys-green/20 text-sys-green":"bg-zinc-500/20 text-fg-muted hover:text-fg-primary"}`,children:l?"● LIVE":"○ LIVE"}),e.jsx("span",{className:"text-[9px] text-fg-muted/40 font-mono",children:l?`${v} events`:"Subscribe to all pipeline events"}),l&&e.jsx("button",{onClick:N,className:"text-[9px] text-fg-muted/40 hover:text-fg-muted font-mono transition-colors ml-auto",children:"clear"})]}),l&&e.jsx("div",{ref:f,className:"max-h-32 overflow-y-auto space-y-px",children:u.length===0?e.jsx("div",{className:"text-[9px] text-fg-muted/30 font-mono py-1 text-center",children:"Waiting for events…"}):u.map((h,y)=>e.jsx(bs,{event:h},`${h.ts}-${y}`))})]})})]})}function js(t){const s=Ne(t.type??t.payload_type??-1).padEnd(7),a=t.packet_hash.slice(0,8),c=(t.src_hash??"—").replace(/^0x/i,"").slice(0,4).toUpperCase(),r=t._hopCount!=null?`${t._hopCount}h`:"",n=it(t.timestamp);return`${a} ${s} ←${c} ${t.rssi}dBm ${r} ${n}`}function _s(){const t=at(),s=lt(),a=ot(),c=(s==null?void 0:s.neighbors)??{},r=Y(b=>b.resolveSource),n=Y(b=>b.config),l=Y(b=>b.setConfig),[o,x]=T.useState(-1),m=T.useMemo(()=>{let b=t;return o!==-1&&(b=t.filter(w=>(w.type??w.payload_type)===o)),b.slice(-50).reverse()},[t,o]),[g,u]=T.useState(""),[v,N]=T.useState(""),[f,k]=T.useState(!1),$=T.useRef(a);T.useEffect(()=>{f&&a!==$.current&&m.length>0&&(u(m[0].packet_hash),N("")),$.current=a},[a,f,m]),T.useEffect(()=>{!g&&m.length>0&&!v&&u(m[0].packet_hash)},[g,m,v]);const h=T.useMemo(()=>v.trim()?null:m.find(b=>b.packet_hash===g)??null,[g,m,v]),y=T.useMemo(()=>{const b=v.replace(/\s+/g,"").trim();return b?{packet_hash:"manual-hex-input",timestamp:0,rssi:0,snr:0,transmitted:!1,drop_reason:null,is_duplicate:!1,raw_packet:b}:null},[v]),p=h??y,_=!!v.trim(),H=v.trim().replace(/\s+/g,"")||(p==null?void 0:p.raw_packet),C=wt(p,H,t),L=(C==null?void 0:C.enrichment)??He,D=Ce((p==null?void 0:p.packet_hash)??""),P=T.useRef(0),M=T.useMemo(()=>{if(!p)return null;const b=performance.now(),w=r(p);return P.current=performance.now()-b,w},[p,r]);return e.jsxs("div",{className:"max-w-[960px] mx-auto",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("h1",{className:"text-sm font-bold text-fg-primary tracking-wide font-mono",children:"PACKET OBSERVATORY"}),e.jsx("p",{className:"text-[11px] text-fg-muted font-mono",children:"Pipeline introspection — select a packet to trace its journey"})]}),e.jsxs("div",{className:"surface-base rounded-lg border border-edge-subtle p-3 mb-3",children:[e.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[e.jsxs("select",{value:o,onChange:b=>{x(Number(b.target.value)),u("")},className:"surface-input px-2 py-1 rounded text-[11px] font-mono text-fg-primary w-36",children:[e.jsx("option",{value:-1,children:"ALL TYPES"}),Object.entries(ct).map(([b,w])=>e.jsxs("option",{value:Number(b),children:["0x",Number(b).toString(16).toUpperCase().padStart(2,"0")," ",w]},b))]}),e.jsxs("select",{value:g,onChange:b=>{u(b.target.value),N("")},className:"surface-input flex-1 min-w-0 px-2 py-1 rounded text-[11px] font-mono text-fg-primary truncate",children:[m.map((b,w)=>e.jsx("option",{value:b.packet_hash,children:js(b)},`${b.packet_hash}-${w}`)),m.length===0&&e.jsxs("option",{value:"",children:["No packets",o!==-1?" matching filter":" loaded"]})]}),e.jsx("button",{onClick:()=>k(b=>!b),className:`px-2 py-1 rounded text-[11px] font-mono transition-colors shrink-0 ${f?"bg-sys-green/20 text-sys-green":"bg-zinc-500/20 text-fg-muted hover:text-fg-primary"}`,children:f?"● LIVE":"○ LIVE"})]}),e.jsxs(G,{children:[e.jsx(V,{className:"text-[10px] text-fg-muted/50 hover:text-fg-muted mt-1.5",children:e.jsx("span",{className:"font-mono",children:"Paste hex…"})}),e.jsx(U,{children:e.jsx("textarea",{value:v,onChange:b=>N(b.target.value),placeholder:"Paste raw packet hex (overrides dropdown)",rows:2,className:"surface-input w-full mt-1 px-2 py-1 rounded text-[11px] font-mono text-fg-primary resize-y"})})]})]}),e.jsxs(G,{children:[e.jsx(V,{className:"text-[11px] mb-3 w-full",children:e.jsxs("span",{className:"flex items-center gap-2 font-mono",children:[e.jsx("span",{className:"text-fg-muted/50",children:"⚙"}),e.jsx("span",{className:"text-fg-muted/50",children:"Pipeline Config & Dev Tools"}),e.jsxs("span",{className:"text-fg-muted/30 text-[10px]",children:["disambig=",n.disambiguationEnabled?"on":"off"," mac=",n.macCorruptedPolicy," decay=",n.recencyDecayHours,"h"]})]})}),e.jsx(U,{children:e.jsxs("div",{className:"space-y-3 mb-4",children:[e.jsxs("div",{className:"surface-base rounded-lg border border-edge-subtle p-3",children:[e.jsx("h2",{className:"text-[10px] text-fg-muted/50 uppercase tracking-widest font-mono mb-2",children:"Pipeline Config"}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-[11px] text-fg-muted w-24 shrink-0",children:"Disambiguation"}),e.jsx("button",{onClick:()=>l({disambiguationEnabled:!n.disambiguationEnabled}),className:`px-2 py-0.5 rounded text-[11px] font-mono transition-colors ${n.disambiguationEnabled?"bg-sys-green/20 text-sys-green":"bg-sys-red/20 text-sys-red"}`,children:n.disambiguationEnabled?"● ON":"○ OFF"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-[11px] text-fg-muted w-24 shrink-0",children:"MAC policy"}),e.jsxs("select",{value:n.macCorruptedPolicy,onChange:b=>l({macCorruptedPolicy:b.target.value}),className:"surface-input px-1.5 py-0.5 rounded text-[11px] font-mono text-fg-primary",children:[e.jsx("option",{value:"strict",children:"strict (drop)"}),e.jsx("option",{value:"name-only",children:"name-only"}),e.jsx("option",{value:"permissive",children:"permissive"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-[11px] text-fg-muted w-24 shrink-0",children:"Recency decay"}),e.jsx("input",{type:"range",min:1,max:48,step:1,value:n.recencyDecayHours,onChange:b=>l({recencyDecayHours:Number(b.target.value)}),className:"flex-1 h-1 accent-sys-blue"}),e.jsxs("span",{className:"text-[11px] font-mono text-fg-primary w-8 text-right",children:[n.recencyDecayHours,"h"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-[11px] text-fg-muted w-24 shrink-0",children:"Zero-hop decay"}),e.jsx("input",{type:"range",min:12,max:168,step:6,value:n.zeroHopDecayHours,onChange:b=>l({zeroHopDecayHours:Number(b.target.value)}),className:"flex-1 h-1 accent-sys-blue"}),e.jsxs("span",{className:"text-[11px] font-mono text-fg-primary w-10 text-right",children:[n.zeroHopDecayHours,"h"]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsx(ys,{packet:p,pipeline:C,resolved:M,decrypted:D??null,isSynthetic:_,liveMode:f}),e.jsx(rs,{})]})]})})]}),p?e.jsxs("div",{className:"space-y-1",children:[e.jsx(kt,{packet:p,isSynthetic:_}),e.jsx(Rt,{packet:p,pipeline:C,rawHex:H,traceTagIndex:(C==null?void 0:C.traceTagIndex)??new Map,neighbors:c}),e.jsx(Ot,{packet:p,decrypted:D??void 0,pipeline:C}),e.jsx(Vt,{packet:p,pipeline:C,resolved:M,decrypted:D??void 0,resolveTimeMs:P.current,neighbors:c,advertName:L.advertName})]}):e.jsx("div",{className:"surface-base rounded-lg border border-edge-subtle p-8 text-center",children:e.jsx("p",{className:"text-fg-muted text-xs",children:"Select a packet from the dropdown or paste hex above"})})]})}export{_s as default}; diff --git a/frontend/dist/assets/Packets-CPDPqpOg.js b/frontend/dist/assets/Packets-CPDPqpOg.js deleted file mode 100644 index 260914d2..00000000 --- a/frontend/dist/assets/Packets-CPDPqpOg.js +++ /dev/null @@ -1 +0,0 @@ -import{r as d,aj as D,ak as at,al as Ve,am as Pe,an as te,ao as ot,ap as nt,aq as le,ar as Be,as as st,at as lt,au as it,av as me,aw as rt,ax as ut,ay as xe,az as B,aA as ct,aB as Ee,aC as W,aD as se,aE as Te,aF as Se,aG as dt,aH as ze,aI as He,aJ as be,aK as Ce,aL as ve,aM as pt,aN as mt,aO as bt,aP as Re,aQ as vt,aR as ft,aS as ge,aT as gt,aU as xt,aV as ht,aW as yt,aX as G,aY as St,aZ as Ct,a_ as Ot,a$ as Pt,b0 as Et,b1 as Tt,b2 as Rt,b3 as $t,b4 as wt,b5 as jt,b6 as It,b7 as $e,j as l,c as ne,ae as Nt,w as kt,x as Mt,b8 as Ft,y as Dt,E as At,J as _t,K as Lt,aa as Vt,ah as Bt,N as we,b9 as je,ba as Ie,B as Ne,bb as ke,F as Me,bc as zt,T as Ht}from"./index-C8IY8K2r.js";import{b as Ut,g as Ue,a as Kt,u as Gt,P as qt}from"./PacketList-DNy8yTeL.js";import{c as V,p as Wt,a as de,f as Fe,b as Yt,L as Xt,S as ue,s as Jt,u as De,d as Qt,g as Zt,e as ea,h as ta}from"./element-movement-D4o83B2Z.js";import{F as aa,y as oa,R as na,T as sa,w as Ae,A as la}from"./map-pin-DMVHq6j8.js";import{u as ia,a as ra}from"./usePipelineStore-CyFB3GIy.js";import{c as ua,a as ca,A as da}from"./AnalyzerFilterPanel-BPawhC5X.js";import{u as pa,r as ma}from"./consumer-registry-lDKP4bcU.js";import{A as ba}from"./arrow-up-DbeeGdHO.js";import{A as va}from"./SignalIndicator-Dw_bfp50.js";import{P as fa,a as ga,B as xa,C as he}from"./PageLayout-NQBVrM09.js";import{T as ha}from"./TimeRangeStepper-BlC9rlkV.js";import{F as _e}from"./funnel-BDRRJl0y.js";import{R as ya}from"./Grid-CEGkNRmt.js";import"./primitives-Ca8Zb5cD.js";import"./payload-decoders-BX6pSxwl.js";import"./badge-colors-BNUqIXCA.js";import"./chat-utils-D1Q4VWjO.js";import"./chevron-right-DUgYTR6d.js";import"./circle-question-mark-C7l07_IA.js";import"./triangle-alert-8k00uu7o.js";import"./DataBox-W2v3wy8k.js";import"./layers-Oxzfug7f.js";import"./hash-BkZp0AKy.js";import"./activity-2-g8m4_g.js";import"./circle-check-BOp4wLxA.js";import"./database-BEyHF_p_.js";import"./useMapViewStore-ax-BqDpg.js";import"./index-B-prVW1V.js";import"./shield-DlHwWwz2.js";import"./node-types-3T9Wr7vI.js";import"./geo-utils-BP1zBK9h.js";import"./monitor-smartphone-DF_mmgOV.js";import"./search-zALFwCS4.js";function Ke(e){let a=d.useRef({value:"",selectionStart:null,selectionEnd:null});return at(e,"blur",t=>{let n=t.target;Pe(n)&&(a.current={value:n.value,selectionStart:n.selectionStart,selectionEnd:n.selectionEnd})}),D(()=>{if(!Ve(e)&&Pe(e)&&e.isConnected){if(e.focus({preventScroll:!0}),e.value!==a.current.value)e.setSelectionRange(e.value.length,e.value.length);else{let{selectionStart:t,selectionEnd:n}=a.current;t!==null&&n!==null&&e.setSelectionRange(t,n)}a.current={value:"",selectionStart:null,selectionEnd:null}}})}function Sa(e,{container:a,accept:t,walk:n}){let o=d.useRef(t),s=d.useRef(n);d.useEffect(()=>{o.current=t,s.current=n},[t,n]),te(()=>{if(!a||!e)return;let i=ot(a);if(!i)return;let v=o.current,c=s.current,m=Object.assign(y=>v(y),{acceptNode:v}),g=i.createTreeWalker(a,NodeFilter.SHOW_ELEMENT,m,!1);for(;g.nextNode();)c(g.currentNode)},[a,e,o,s])}var Ca=Object.defineProperty,Oa=(e,a,t)=>a in e?Ca(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t,Le=(e,a,t)=>(Oa(e,typeof a!="symbol"?a+"":a,t),t),x=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(x||{}),J=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(J||{}),ee=(e=>(e[e.Pointer=0]="Pointer",e[e.Focus=1]="Focus",e[e.Other=2]="Other",e))(ee||{}),Ge=(e=>(e[e.OpenCombobox=0]="OpenCombobox",e[e.CloseCombobox=1]="CloseCombobox",e[e.GoToOption=2]="GoToOption",e[e.SetTyping=3]="SetTyping",e[e.RegisterOption=4]="RegisterOption",e[e.UnregisterOption=5]="UnregisterOption",e[e.DefaultToFirstOption=6]="DefaultToFirstOption",e[e.SetActivationTrigger=7]="SetActivationTrigger",e[e.UpdateVirtualConfiguration=8]="UpdateVirtualConfiguration",e[e.SetInputElement=9]="SetInputElement",e[e.SetButtonElement=10]="SetButtonElement",e[e.SetOptionsElement=11]="SetOptionsElement",e[e.MarkInputAsMoved=12]="MarkInputAsMoved",e))(Ge||{});function ye(e,a=t=>t){let t=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,n=a(e.options.slice()),o=n.length>0&&n[0].dataRef.current.order!==null?n.sort((i,v)=>i.dataRef.current.order-v.dataRef.current.order):lt(n,i=>i.dataRef.current.domRef.current),s=t?o.indexOf(t):null;return s===-1&&(s=null),{options:o,activeOptionIndex:s}}let Pa={1(e){var a;if((a=e.dataRef.current)!=null&&a.disabled||e.comboboxState===1)return e;let t=e.inputElement?de.Tracked(Yt(e.inputElement)):e.inputPositionState;return{...e,activeOptionIndex:null,comboboxState:1,isTyping:!1,activationTrigger:2,inputPositionState:t,__demoMode:!1}},0(e){var a,t;if((a=e.dataRef.current)!=null&&a.disabled||e.comboboxState===0)return e;if((t=e.dataRef.current)!=null&&t.value){let n=e.dataRef.current.calculateIndex(e.dataRef.current.value);if(n!==-1)return{...e,activeOptionIndex:n,comboboxState:0,__demoMode:!1,inputPositionState:de.Idle}}return{...e,comboboxState:0,inputPositionState:de.Idle,__demoMode:!1}},3(e,a){return e.isTyping===a.isTyping?e:{...e,isTyping:a.isTyping}},2(e,a){var t,n,o,s;if((t=e.dataRef.current)!=null&&t.disabled||e.optionsElement&&!((n=e.dataRef.current)!=null&&n.optionsPropsRef.current.static)&&e.comboboxState===1)return e;if(e.virtual){let{options:m,disabled:g}=e.virtual,y=a.focus===V.Specific?a.idx:Fe(a,{resolveItems:()=>m,resolveActiveIndex:()=>{var b,p;return(p=(b=e.activeOptionIndex)!=null?b:m.findIndex(P=>!g(P)))!=null?p:null},resolveDisabled:g,resolveId(){throw new Error("Function not implemented.")}}),h=(o=a.trigger)!=null?o:2;return e.activeOptionIndex===y&&e.activationTrigger===h?e:{...e,activeOptionIndex:y,activationTrigger:h,isTyping:!1,__demoMode:!1}}let i=ye(e);if(i.activeOptionIndex===null){let m=i.options.findIndex(g=>!g.dataRef.current.disabled);m!==-1&&(i.activeOptionIndex=m)}let v=a.focus===V.Specific?a.idx:Fe(a,{resolveItems:()=>i.options,resolveActiveIndex:()=>i.activeOptionIndex,resolveId:m=>m.id,resolveDisabled:m=>m.dataRef.current.disabled}),c=(s=a.trigger)!=null?s:2;return e.activeOptionIndex===v&&e.activationTrigger===c?e:{...e,...i,isTyping:!1,activeOptionIndex:v,activationTrigger:c,__demoMode:!1}},4:(e,a)=>{var t,n,o,s;if((t=e.dataRef.current)!=null&&t.virtual)return{...e,options:[...e.options,a.payload]};let i=a.payload,v=ye(e,m=>(m.push(i),m));e.activeOptionIndex===null&&(o=(n=e.dataRef.current).isSelected)!=null&&o.call(n,a.payload.dataRef.current.value)&&(v.activeOptionIndex=v.options.indexOf(i));let c={...e,...v,activationTrigger:2};return(s=e.dataRef.current)!=null&&s.__demoMode&&e.dataRef.current.value===void 0&&(c.activeOptionIndex=0),c},5:(e,a)=>{var t;if((t=e.dataRef.current)!=null&&t.virtual)return{...e,options:e.options.filter(o=>o.id!==a.id)};let n=ye(e,o=>{let s=o.findIndex(i=>i.id===a.id);return s!==-1&&o.splice(s,1),o});return{...e,...n,activationTrigger:2}},6:(e,a)=>e.defaultToFirstOption===a.value?e:{...e,defaultToFirstOption:a.value},7:(e,a)=>e.activationTrigger===a.trigger?e:{...e,activationTrigger:a.trigger},8:(e,a)=>{var t,n;if(e.virtual===null)return{...e,virtual:{options:a.options,disabled:(t=a.disabled)!=null?t:()=>!1}};if(e.virtual.options===a.options&&e.virtual.disabled===a.disabled)return e;let o=e.activeOptionIndex;if(e.activeOptionIndex!==null){let s=a.options.indexOf(e.virtual.options[e.activeOptionIndex]);s!==-1?o=s:o=null}return{...e,activeOptionIndex:o,virtual:{options:a.options,disabled:(n=a.disabled)!=null?n:()=>!1}}},9:(e,a)=>e.inputElement===a.element?e:{...e,inputElement:a.element},10:(e,a)=>e.buttonElement===a.element?e:{...e,buttonElement:a.element},11:(e,a)=>e.optionsElement===a.element?e:{...e,optionsElement:a.element},12(e){return e.inputPositionState.kind!=="Tracked"?e:{...e,inputPositionState:de.Moved}}};class Oe extends nt{constructor(a){super(a),Le(this,"actions",{onChange:t=>{let{onChange:n,compare:o,mode:s,value:i}=this.state.dataRef.current;return le(s,{0:()=>n==null?void 0:n(t),1:()=>{let v=i.slice(),c=v.findIndex(m=>o(m,t));return c===-1?v.push(t):v.splice(c,1),n==null?void 0:n(v)}})},registerOption:(t,n)=>(this.send({type:4,payload:{id:t,dataRef:n}}),()=>{this.state.activeOptionIndex===this.state.dataRef.current.calculateIndex(n.current.value)&&this.send({type:6,value:!0}),this.send({type:5,id:t})}),goToOption:(t,n)=>(this.send({type:6,value:!1}),this.send({type:2,...t,trigger:n})),setIsTyping:t=>{this.send({type:3,isTyping:t})},closeCombobox:()=>{var t,n;this.send({type:1}),this.send({type:6,value:!1}),(n=(t=this.state.dataRef.current).onClose)==null||n.call(t)},openCombobox:()=>{this.send({type:0}),this.send({type:6,value:!0})},setActivationTrigger:t=>{this.send({type:7,trigger:t})},selectActiveOption:()=>{let t=this.selectors.activeOptionIndex(this.state);if(t!==null){if(this.actions.setIsTyping(!1),this.state.virtual)this.actions.onChange(this.state.virtual.options[t]);else{let{dataRef:n}=this.state.options[t];this.actions.onChange(n.current.value)}this.actions.goToOption({focus:V.Specific,idx:t})}},setInputElement:t=>{this.send({type:9,element:t})},setButtonElement:t=>{this.send({type:10,element:t})},setOptionsElement:t=>{this.send({type:11,element:t})}}),Le(this,"selectors",{activeDescendantId:t=>{var n,o;let s=this.selectors.activeOptionIndex(t);if(s!==null)return t.virtual?(o=t.options.find(i=>!i.dataRef.current.disabled&&t.dataRef.current.compare(i.dataRef.current.value,t.virtual.options[s])))==null?void 0:o.id:(n=t.options[s])==null?void 0:n.id},activeOptionIndex:t=>{if(t.defaultToFirstOption&&t.activeOptionIndex===null&&(t.virtual?t.virtual.options.length>0:t.options.length>0)){if(t.virtual){let{options:o,disabled:s}=t.virtual,i=o.findIndex(v=>{var c;return!((c=s==null?void 0:s(v))!=null&&c)});if(i!==-1)return i}let n=t.options.findIndex(o=>!o.dataRef.current.disabled);if(n!==-1)return n}return t.activeOptionIndex},activeOption:t=>{var n,o;let s=this.selectors.activeOptionIndex(t);return s===null?null:t.virtual?t.virtual.options[s??0]:(o=(n=t.options[s])==null?void 0:n.dataRef.current.value)!=null?o:null},isActive:(t,n,o)=>{var s;let i=this.selectors.activeOptionIndex(t);return i===null?!1:t.virtual?i===t.dataRef.current.calculateIndex(n):((s=t.options[i])==null?void 0:s.id)===o},shouldScrollIntoView:(t,n,o)=>!(t.virtual||t.__demoMode||t.comboboxState!==0||t.activationTrigger===0||!this.selectors.isActive(t,n,o)),didInputMove(t){return t.inputPositionState.kind==="Moved"}});{let t=this.state.id,n=Be.get(null);this.disposables.add(n.on(st.Push,o=>{!n.selectors.isTop(o,t)&&this.state.comboboxState===0&&this.actions.closeCombobox()})),this.on(0,()=>n.actions.push(t)),this.on(1,()=>n.actions.pop(t))}this.disposables.group(t=>{this.on(1,n=>{n.inputElement&&(t.dispose(),t.add(Wt(n.inputElement,n.inputPositionState,()=>{this.send({type:12})})))})})}static new({id:a,virtual:t=null,__demoMode:n=!1}){var o;return new Oe({id:a,dataRef:{current:{}},comboboxState:n?0:1,isTyping:!1,options:[],virtual:t?{options:t.options,disabled:(o=t.disabled)!=null?o:()=>!1}:null,activeOptionIndex:null,activationTrigger:2,inputElement:null,buttonElement:null,optionsElement:null,__demoMode:n,inputPositionState:de.Idle})}reduce(a,t){return le(t.type,Pa,a,t)}}const qe=d.createContext(null);function fe(e){let a=d.useContext(qe);if(a===null){let t=new Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,We),t}return a}function We({id:e,virtual:a=null,__demoMode:t=!1}){let n=d.useMemo(()=>Oe.new({id:e,virtual:a,__demoMode:t}),[]);return it(()=>n.dispose()),n}let pe=d.createContext(null);pe.displayName="ComboboxDataContext";function ie(e){let a=d.useContext(pe);if(a===null){let t=new Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,ie),t}return a}let Ye=d.createContext(null);function Ea(e){let a=fe("VirtualProvider"),t=ie("VirtualProvider"),{options:n}=t.virtual,o=B(a,b=>b.optionsElement),[s,i]=d.useMemo(()=>{let b=o;if(!b)return[0,0];let p=window.getComputedStyle(b);return[parseFloat(p.paddingBlockStart||p.paddingTop),parseFloat(p.paddingBlockEnd||p.paddingBottom)]},[o]),v=Ut({enabled:n.length!==0,scrollPaddingStart:s,scrollPaddingEnd:i,count:n.length,estimateSize(){return 40},getScrollElement(){return a.state.optionsElement},overscan:12}),[c,m]=d.useState(0);te(()=>{m(b=>b+1)},[n]);let g=v.getVirtualItems(),y=B(a,b=>b.activationTrigger===ee.Pointer),h=B(a,a.selectors.activeOptionIndex);return g.length===0?null:G.createElement(Ye.Provider,{value:v},G.createElement("div",{style:{position:"relative",width:"100%",height:`${v.getTotalSize()}px`},ref:b=>{b&&(y||h!==null&&n.length>h&&v.scrollToIndex(h))}},g.map(b=>{var p;return G.createElement(d.Fragment,{key:b.key},G.cloneElement((p=e.children)==null?void 0:p.call(e,{...e.slot,option:n[b.index]}),{key:`${c}-${b.key}`,"data-index":b.index,"aria-setsize":n.length,"aria-posinset":b.index+1,style:{position:"absolute",top:0,left:0,transform:`translateY(${b.start}px)`,overflowAnchor:"none"}}))})))}let Ta=d.Fragment;function Ra(e,a){let t=d.useId(),n=Et(),{value:o,defaultValue:s,onChange:i,form:v,name:c,by:m,invalid:g=!1,disabled:y=n||!1,onClose:h,__demoMode:b=!1,multiple:p=!1,immediate:P=!1,virtual:r=null,nullable:M,...A}=e,E=Tt(s),[T=p?[]:void 0,z]=Rt(o,i,E),S=We({id:t,virtual:r,__demoMode:b}),_=d.useRef({static:!1,hold:!1}),I=ta(m),F=D($=>r?m===null?r.options.indexOf($):r.options.findIndex(ae=>I(ae,$)):S.state.options.findIndex(ae=>I(ae.dataRef.current.value,$))),q=d.useCallback($=>le(w.mode,{[J.Multi]:()=>T.some(ae=>I(ae,$)),[J.Single]:()=>I(T,$)}),[T]),Y=B(S,$=>$.virtual),C=D(()=>h==null?void 0:h()),w=d.useMemo(()=>({__demoMode:b,immediate:P,optionsPropsRef:_,value:T,defaultValue:E,disabled:y,invalid:g,mode:p?J.Multi:J.Single,virtual:r?Y:null,onChange:z,isSelected:q,calculateIndex:F,compare:I,onClose:C}),[b,P,_,T,E,y,g,p,r,Y,z,q,F,I,C]);te(()=>{var $;r&&S.send({type:Ge.UpdateVirtualConfiguration,options:r.options,disabled:($=r.disabled)!=null?$:null})},[r,r==null?void 0:r.options,r==null?void 0:r.disabled]),te(()=>{S.state.dataRef.current=w},[w]);let[H,O,u,R]=B(S,$=>[$.comboboxState,$.buttonElement,$.inputElement,$.optionsElement]),N=Be.get(null),Q=B(N,d.useCallback($=>N.selectors.isTop($,t),[N,t]));$t(Q,[O,u,R],()=>S.actions.closeCombobox());let Z=B(S,S.selectors.activeOptionIndex),re=B(S,S.selectors.activeOption),f=be({open:H===x.Open,disabled:y,invalid:g,activeIndex:Z,activeOption:re,value:T}),[X,k]=wt(),U=a===null?{}:{ref:a},j=d.useCallback(()=>{if(E!==void 0)return z==null?void 0:z(E)},[z,E]),K=ve();return G.createElement(k,{value:X,props:{htmlFor:u==null?void 0:u.id},slot:{open:H===x.Open,disabled:y}},G.createElement(la,null,G.createElement(pe.Provider,{value:w},G.createElement(qe.Provider,{value:S},G.createElement(jt,{value:le(H,{[x.Open]:ge.Open,[x.Closed]:ge.Closed})},c!=null&&G.createElement(It,{disabled:y,data:T!=null?{[c]:T}:{},form:v,onReset:j}),K({ourProps:U,theirProps:A,slot:f,defaultTag:Ta,name:"Combobox"}))))))}let $a="input";function wa(e,a){var t,n;let o=fe("Combobox.Input"),s=ie("Combobox.Input"),i=d.useId(),v=ut(),{id:c=v||`headlessui-combobox-input-${i}`,onChange:m,displayValue:g,disabled:y=s.disabled||!1,autoFocus:h=!1,type:b="text",...p}=e,P=d.useRef(null),r=xe(P,a,aa(),o.actions.setInputElement),[M,A]=B(o,f=>[f.comboboxState,f.isTyping]),E=ct(),T=D(()=>{o.actions.onChange(null),o.state.optionsElement&&(o.state.optionsElement.scrollTop=0),o.actions.goToOption({focus:V.Nothing})}),z=d.useMemo(()=>{var f;return typeof g=="function"&&s.value!==void 0?(f=g(s.value))!=null?f:"":typeof s.value=="string"?s.value:""},[s.value,g]);Ee(([f,X],[k,U])=>{if(o.state.isTyping)return;let j=P.current;j&&((U===x.Open&&X===x.Closed||f!==k)&&(j.value=f),requestAnimationFrame(()=>{if(o.state.isTyping||!j||Ve(j))return;let{selectionStart:K,selectionEnd:$}=j;Math.abs(($??0)-(K??0))===0&&K===0&&j.setSelectionRange(j.value.length,j.value.length)}))},[z,M,A]),Ee(([f],[X])=>{if(f===x.Open&&X===x.Closed){if(o.state.isTyping)return;let k=P.current;if(!k)return;let U=k.value,{selectionStart:j,selectionEnd:K,selectionDirection:$}=k;k.value="",k.value=U,$!==null?k.setSelectionRange(j,K,$):k.setSelectionRange(j,K)}},[M]);let S=d.useRef(!1),_=D(()=>{S.current=!0}),I=D(()=>{E.nextFrame(()=>{S.current=!1})}),F=D(f=>{switch(o.actions.setIsTyping(!0),f.key){case W.Enter:if(o.state.comboboxState!==x.Open||S.current)return;if(f.preventDefault(),f.stopPropagation(),o.selectors.activeOptionIndex(o.state)===null){o.actions.closeCombobox();return}o.actions.selectActiveOption(),s.mode===J.Single&&o.actions.closeCombobox();break;case W.ArrowDown:return f.preventDefault(),f.stopPropagation(),le(o.state.comboboxState,{[x.Open]:()=>o.actions.goToOption({focus:V.Next}),[x.Closed]:()=>o.actions.openCombobox()});case W.ArrowUp:return f.preventDefault(),f.stopPropagation(),le(o.state.comboboxState,{[x.Open]:()=>o.actions.goToOption({focus:V.Previous}),[x.Closed]:()=>{se.flushSync(()=>o.actions.openCombobox()),s.value||o.actions.goToOption({focus:V.Last})}});case W.Home:if(o.state.comboboxState===x.Closed||f.shiftKey)break;return f.preventDefault(),f.stopPropagation(),o.actions.goToOption({focus:V.First});case W.PageUp:return f.preventDefault(),f.stopPropagation(),o.actions.goToOption({focus:V.First});case W.End:if(o.state.comboboxState===x.Closed||f.shiftKey)break;return f.preventDefault(),f.stopPropagation(),o.actions.goToOption({focus:V.Last});case W.PageDown:return f.preventDefault(),f.stopPropagation(),o.actions.goToOption({focus:V.Last});case W.Escape:return o.state.comboboxState!==x.Open?void 0:(f.preventDefault(),o.state.optionsElement&&!s.optionsPropsRef.current.static&&f.stopPropagation(),s.mode===J.Single&&s.value===null&&T(),o.actions.closeCombobox());case W.Tab:if(o.actions.setIsTyping(!1),o.state.comboboxState!==x.Open)return;s.mode===J.Single&&o.state.activationTrigger!==ee.Focus&&o.actions.selectActiveOption(),o.actions.closeCombobox();break}}),q=D(f=>{m==null||m(f),s.mode===J.Single&&f.target.value===""&&T(),o.actions.openCombobox()}),Y=D(f=>{var X,k,U;let j=(X=f.relatedTarget)!=null?X:Te.find(K=>K!==f.currentTarget);if(!((k=o.state.optionsElement)!=null&&k.contains(j))&&!((U=o.state.buttonElement)!=null&&U.contains(j))&&o.state.comboboxState===x.Open)return f.preventDefault(),s.mode===J.Single&&s.value===null&&T(),o.actions.closeCombobox()}),C=D(f=>{var X,k,U;let j=(X=f.relatedTarget)!=null?X:Te.find(K=>K!==f.currentTarget);(k=o.state.buttonElement)!=null&&k.contains(j)||(U=o.state.optionsElement)!=null&&U.contains(j)||s.disabled||s.immediate&&o.state.comboboxState!==x.Open&&E.microTask(()=>{se.flushSync(()=>o.actions.openCombobox()),o.actions.setActivationTrigger(ee.Focus)})}),w=Se(),H=dt(),{isFocused:O,focusProps:u}=ze({autoFocus:h}),{isHovered:R,hoverProps:N}=He({isDisabled:y}),Q=B(o,f=>f.optionsElement),Z=be({open:M===x.Open,disabled:y,invalid:s.invalid,hover:R,focus:O,autofocus:h}),re=Ce({ref:r,id:c,role:"combobox",type:b,"aria-controls":Q==null?void 0:Q.id,"aria-expanded":M===x.Open,"aria-activedescendant":B(o,o.selectors.activeDescendantId),"aria-labelledby":w,"aria-describedby":H,"aria-autocomplete":"list",defaultValue:(n=(t=e.defaultValue)!=null?t:s.defaultValue!==void 0?g==null?void 0:g(s.defaultValue):null)!=null?n:s.defaultValue,disabled:y||void 0,autoFocus:h,onCompositionStart:_,onCompositionEnd:I,onKeyDown:F,onChange:q,onFocus:C,onBlur:Y},u,N);return ve()({ourProps:re,theirProps:p,slot:Z,defaultTag:$a,name:"Combobox.Input"})}let ja="button";function Ia(e,a){let t=fe("Combobox.Button"),n=ie("Combobox.Button"),[o,s]=d.useState(null),i=xe(a,s,t.actions.setButtonElement),v=d.useId(),{id:c=`headlessui-combobox-button-${v}`,disabled:m=n.disabled||!1,autoFocus:g=!1,...y}=e,[h,b,p]=B(t,C=>[C.comboboxState,C.inputElement,C.optionsElement]),P=Ke(b),r=h===x.Open;Xt(r,{trigger:o,action:d.useCallback(C=>{if(o!=null&&o.contains(C.target))return ue.Ignore;if(b!=null&&b.contains(C.target))return ue.Ignore;let w=C.target.closest('[role="option"]:not([data-disabled])');return pt(w)?ue.Select(w):p!=null&&p.contains(C.target)?ue.Ignore:ue.Close},[o,b,p]),close:t.actions.closeCombobox,select:t.actions.selectActiveOption});let M=D(C=>{switch(C.key){case W.Space:case W.Enter:C.preventDefault(),C.stopPropagation(),t.state.comboboxState===x.Closed&&se.flushSync(()=>t.actions.openCombobox()),P();return;case W.ArrowDown:C.preventDefault(),C.stopPropagation(),t.state.comboboxState===x.Closed&&(se.flushSync(()=>t.actions.openCombobox()),t.state.dataRef.current.value||t.actions.goToOption({focus:V.First})),P();return;case W.ArrowUp:C.preventDefault(),C.stopPropagation(),t.state.comboboxState===x.Closed&&(se.flushSync(()=>t.actions.openCombobox()),t.state.dataRef.current.value||t.actions.goToOption({focus:V.Last})),P();return;case W.Escape:if(t.state.comboboxState!==x.Open)return;C.preventDefault(),t.state.optionsElement&&!n.optionsPropsRef.current.static&&C.stopPropagation(),se.flushSync(()=>t.actions.closeCombobox()),P();return;default:return}}),A=Jt(()=>{t.state.comboboxState===x.Open?t.actions.closeCombobox():t.actions.openCombobox(),P()}),E=Se([c]),{isFocusVisible:T,focusProps:z}=ze({autoFocus:g}),{isHovered:S,hoverProps:_}=He({isDisabled:m}),{pressed:I,pressProps:F}=mt({disabled:m}),q=be({open:h===x.Open,active:I||h===x.Open,disabled:m,invalid:n.invalid,value:n.value,hover:S,focus:T}),Y=Ce({ref:i,id:c,type:bt(e,o),tabIndex:-1,"aria-haspopup":"listbox","aria-controls":p==null?void 0:p.id,"aria-expanded":h===x.Open,"aria-labelledby":E,disabled:m||void 0,autoFocus:g,onKeyDown:M},A,z,_,F);return ve()({ourProps:Y,theirProps:y,slot:q,defaultTag:ja,name:"Combobox.Button"})}let Na="div",ka=$e.RenderStrategy|$e.Static;function Ma(e,a){var t,n,o;let s=d.useId(),{id:i=`headlessui-combobox-options-${s}`,hold:v=!1,anchor:c,portal:m=!1,modal:g=!0,transition:y=!1,...h}=e,b=fe("Combobox.Options"),p=ie("Combobox.Options"),P=oa(c);P&&(m=!0);let[r,M]=na(P),[A,E]=d.useState(null),T=sa(),z=xe(a,P?r:null,b.actions.setOptionsElement,E),[S,_,I,F,q]=B(b,L=>[L.comboboxState,L.inputElement,L.buttonElement,L.optionsElement,L.activationTrigger]),Y=Re(_||I),C=Re(F),w=vt(),[H,O]=ft(y,A,w!==null?(w&ge.Open)===ge.Open:S===x.Open);gt(H,_,b.actions.closeCombobox);let u=p.__demoMode?!1:g&&S===x.Open;xt(u,C);let R=p.__demoMode?!1:g&&S===x.Open;ht(R,{allowed:d.useCallback(()=>[_,I,F],[_,I,F])});let N=B(b,b.selectors.didInputMove)?!1:H;te(()=>{var L;p.optionsPropsRef.current.static=(L=e.static)!=null?L:!1},[p.optionsPropsRef,e.static]),te(()=>{p.optionsPropsRef.current.hold=v},[p.optionsPropsRef,v]),Sa(S===x.Open,{container:F,accept(L){return L.getAttribute("role")==="option"?NodeFilter.FILTER_REJECT:L.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(L){L.setAttribute("role","none")}});let Q=Se([I==null?void 0:I.id]),Z=be({open:S===x.Open,option:void 0}),re=D(()=>{b.actions.setActivationTrigger(ee.Pointer)}),f=D(L=>{L.preventDefault(),b.actions.setActivationTrigger(ee.Pointer)}),X=Ce(P?T():{},{"aria-labelledby":Q,role:"listbox","aria-multiselectable":p.mode===J.Multi?!0:void 0,id:i,ref:z,style:{...h.style,...M,"--input-width":Ae(H,_,!0).width,"--button-width":Ae(H,I,!0).width},onWheel:q===ee.Pointer?void 0:re,onMouseDown:f,...yt(O)}),k=H&&S===x.Closed&&!e.static,U=De(k,(t=p.virtual)==null?void 0:t.options),j=De(k,p.value),K=d.useCallback(L=>p.compare(j,L),[p.compare,j]),$=d.useMemo(()=>{if(!p.virtual)return p;if(U===void 0)throw new Error("Missing `options` in virtual mode");return U!==p.virtual.options?{...p,virtual:{...p.virtual,options:U}}:p},[p,U,(n=p.virtual)==null?void 0:n.options]);p.virtual&&Object.assign(h,{children:G.createElement(pe.Provider,{value:$},G.createElement(Ea,{slot:Z},h.children))});let ae=ve(),tt=d.useMemo(()=>p.mode===J.Multi?p:{...p,isSelected:K},[p,K]);return G.createElement(St,{enabled:m?e.static||H:!1,ownerDocument:Y},G.createElement(pe.Provider,{value:tt},ae({ourProps:X,theirProps:{...h,children:G.createElement(Qt,{freeze:k},typeof h.children=="function"?(o=h.children)==null?void 0:o.call(h,Z):h.children)},slot:Z,defaultTag:Na,features:ka,visible:N,name:"Combobox.Options"})))}let Fa="div";function Da(e,a){var t,n,o;let s=ie("Combobox.Option"),i=fe("Combobox.Option"),v=d.useId(),{id:c=`headlessui-combobox-option-${v}`,value:m,disabled:g=(o=(n=(t=s.virtual)==null?void 0:t.disabled)==null?void 0:n.call(t,m))!=null?o:!1,order:y=null,...h}=e,[b]=B(i,O=>[O.inputElement]),p=Ke(b),P=B(i,d.useCallback(O=>i.selectors.isActive(O,m,c),[m,c])),r=s.isSelected(m),M=d.useRef(null),A=Ct({disabled:g,value:m,domRef:M,order:y}),E=d.useContext(Ye),T=xe(a,M,E?E.measureElement:null),z=D(()=>{i.actions.setIsTyping(!1),i.actions.onChange(m)});te(()=>i.actions.registerOption(c,A),[A,c]);let S=B(i,d.useCallback(O=>i.selectors.shouldScrollIntoView(O,m,c),[m,c]));te(()=>{if(S)return Ot().requestAnimationFrame(()=>{var O,u;(u=(O=M.current)==null?void 0:O.scrollIntoView)==null||u.call(O,{block:"nearest"})})},[S,M]);let _=D(O=>{O.preventDefault(),O.button===Zt.Left&&(g||(z(),Pt()||requestAnimationFrame(()=>p()),s.mode===J.Single&&i.actions.closeCombobox()))}),I=D(()=>{if(g)return i.actions.goToOption({focus:V.Nothing});let O=s.calculateIndex(m);i.actions.goToOption({focus:V.Specific,idx:O})}),F=ea(),q=D(O=>F.update(O)),Y=D(O=>{if(!F.wasMoved(O)||g||P&&i.state.activationTrigger===ee.Pointer)return;let u=s.calculateIndex(m);i.actions.goToOption({focus:V.Specific,idx:u},ee.Pointer)}),C=D(O=>{F.wasMoved(O)&&(g||P&&(s.optionsPropsRef.current.hold||i.state.activationTrigger===ee.Pointer&&i.actions.goToOption({focus:V.Nothing})))}),w=be({active:P,focus:P,selected:r,disabled:g}),H={id:c,ref:T,role:"option",tabIndex:g===!0?void 0:-1,"aria-disabled":g===!0?!0:void 0,"aria-selected":r,disabled:void 0,onMouseDown:_,onFocus:I,onPointerEnter:q,onMouseEnter:q,onPointerMove:Y,onMouseMove:Y,onPointerLeave:C,onMouseLeave:C};return ve()({ourProps:H,theirProps:h,slot:w,defaultTag:Fa,name:"Combobox.Option"})}let Aa=me(Ra),Xe=me(Ia),Je=me(wa),_a=rt,Qe=me(Ma),Ze=me(Da),La=Object.assign(Aa,{Input:Je,Button:Xe,Label:_a,Options:Qe,Option:Ze});function Va({options:e,value:a,onChange:t,defaultValue:n,displayValue:o,filter:s,placeholder:i,disabled:v,invalid:c,name:m,"aria-label":g,className:y,children:h}){const[b,p]=d.useState(""),P=o??(E=>E!=null?String(E):""),M=s??((E,T)=>P(E).toLowerCase().includes(T.toLowerCase())),A=d.useMemo(()=>b?e.filter(E=>M(E,b)):e,[e,b,M]);return l.jsx(La,{value:a,onChange:t,defaultValue:n,disabled:v,name:m,onClose:()=>p(""),children:l.jsxs("div",{className:ne("relative",y),children:[l.jsxs("div",{className:"relative",children:[l.jsx(Je,{"aria-label":g,displayValue:P,onChange:E=>p(E.target.value),placeholder:i,className:ne(["w-full radius-inner py-2 pl-3 pr-10","text-sm text-fg-primary placeholder:text-fg-muted","bg-input-bg",c?"border border-sys-red":"border border-input-border","ring-focus-inset","hover:border-edge-strong","disabled:opacity-40 disabled:pointer-events-none disabled:cursor-not-allowed","transition-colors"])}),l.jsx(Xe,{className:"absolute inset-y-0 right-0 flex items-center pr-3 group",children:l.jsx(Nt,{className:"w-4 h-4 text-fg-muted transition-transform duration-200 group-data-[open]:rotate-180"})})]}),l.jsx(Qe,{anchor:"bottom start",transition:!0,className:ne(["w-[var(--input-width)] min-w-[180px]","max-h-60 overflow-y-auto overscroll-contain scroll-py-1","radius-inset p-1 mt-1","surface-elevated","focus:outline-none","transition-opacity","data-[closed]:opacity-0","data-[enter]:duration-150 data-[leave]:duration-100","z-50"]),children:A.length===0&&b!==""?l.jsx("div",{className:"px-3 py-2 text-sm text-fg-muted",children:"No results found"}):A.map((E,T)=>l.jsx(d.Fragment,{children:h(E)},T))})]})})}function Ba({value:e,disabled:a,className:t,children:n}){return l.jsx(Ze,{as:d.Fragment,value:e,disabled:a,children:({selected:o,focus:s})=>l.jsxs("div",{className:ne("flex items-center gap-2 px-3 py-2 radius-control cursor-default","text-sm",s&&"bg-sys-blue text-white",!s&&"text-fg-primary",o&&!s&&"text-sys-blue",a&&"opacity-50 cursor-not-allowed",t),children:[l.jsx("span",{className:"w-4 flex-shrink-0",children:o&&l.jsx(kt,{className:"w-4 h-4"})}),l.jsx("span",{className:"truncate flex-1",children:n})]})})}function za({className:e,...a}){return l.jsx("span",{...a,className:ne("truncate",e)})}function oe({value:e,onChange:a,options:t,placeholder:n,disabled:o,className:s,"aria-label":i}){const v=t.find(c=>c.value===e);return l.jsx(Va,{options:t,value:v,onChange:c=>{c&&a(c.value)},displayValue:c=>(c==null?void 0:c.label)??"",filter:(c,m)=>c.label.toLowerCase().includes(m.toLowerCase()),placeholder:n,disabled:o,className:s,"aria-label":i,children:c=>l.jsx(Ba,{value:c,disabled:c.disabled,children:l.jsx(za,{children:c.label})})})}const et=[{target:"PacketStats",fn:"type",minStage:1}];ma(et);function ce({icon:e,label:a,value:t,color:n,percentage:o}){return l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:ne("p-1.5 rounded-md",n),children:e}),l.jsxs("div",{className:"flex flex-col",children:[l.jsx("span",{className:"text-sm font-semibold text-fg-primary",children:t.toLocaleString()}),l.jsxs("span",{className:"text-xs text-fg-muted leading-tight",children:[a,o!==void 0&&l.jsxs("span",{className:"ml-1 opacity-70",children:["(",o,"%)"]})]})]})]})}function Ha({packets:e}){pa(et);const a=d.useMemo(()=>{let t=0,n=0,o=0;const s=new Set;let i=0,v=0;for(const y of e){switch(Ue(y)){case"forward":t++;break;case"dropped":n++;break;case"duplicate":o++;break}y.src_hash&&s.add(y.src_hash),y.rssi&&(i+=y.rssi,v++)}const c=e.length,m=v>0?Math.round(i/v):0;return{total:c,rx:c,fwd:t,dropped:n,duplicate:o,uniqueSources:s.size,avgRssi:m,rxPercent:100,fwdPercent:c>0?Math.round(t/c*100):0,droppedPercent:c>0?Math.round(n/c*100):0}},[e]);return e.length===0?null:l.jsx("div",{className:"surface-base depth-raised rounded-2xl p-3 pr-4",children:l.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:flex sm:items-center sm:justify-between sm:gap-6",children:[l.jsx(ce,{icon:l.jsx(ba,{className:"w-3.5 h-3.5 text-sys-blue"}),label:"Received",value:a.rx,color:"bg-sys-blue/10",percentage:a.rxPercent}),l.jsx(ce,{icon:l.jsx(va,{className:"w-3.5 h-3.5 text-sys-green"}),label:"Forwarded",value:a.fwd,color:"bg-sys-green/10",percentage:a.fwdPercent}),l.jsx(ce,{icon:l.jsx(Kt,{className:"w-3.5 h-3.5 text-sys-red"}),label:"Dropped",value:a.dropped,color:"bg-sys-red/10",percentage:a.droppedPercent}),l.jsx(ce,{icon:l.jsx(Mt,{className:"w-3.5 h-3.5 text-fg-muted"}),label:"Duplicates",value:a.duplicate,color:"bg-subtle-fill"}),l.jsxs("div",{className:"hidden sm:flex items-center gap-6 ml-auto",children:[l.jsx(ce,{icon:l.jsx(Ft,{className:"w-3.5 h-3.5 text-sys-indigo"}),label:"Sources",value:a.uniqueSources,color:"bg-sys-indigo/10"}),l.jsxs("div",{className:"flex flex-col items-end pr-1",children:[l.jsxs("span",{className:"type-data-sm text-fg-secondary",children:[a.avgRssi," dBm"]}),l.jsx("span",{className:"text-xs text-fg-muted",children:"Avg Signal"})]})]})]})})}const Ua=d.memo(Ha);function Eo(){const e=Dt(),a=At(),t=ia(),n=Gt(u=>u.requestChannel),o=_t(),s=a==null?void 0:a.local_hash,i=a==null?void 0:a.neighbors,v=Lt(),c=Vt(),g=Bt().isBackgroundLoading&&v>=5,[y,h]=d.useState(!1),[b,p]=d.useState(!0),P=d.useCallback(u=>p(u),[]),[r,M]=d.useState({limit:500,status:"all"}),[A,E]=d.useState(ua),T=d.useMemo(()=>{const u=Math.floor(Date.now()/1e3),R=we[v].minutes;return{start:u-R*60,end:u}},[v]),z=d.useMemo(()=>{const u=(a==null?void 0:a.neighbors)??{};return Object.fromEntries(Object.entries(u).filter(([R])=>!o.has(R)))},[a==null?void 0:a.neighbors,o]),S=ra(),[_,I]=d.useState(Date.now);d.useEffect(()=>{r.timeRange&&r.timeRange>0&&queueMicrotask(()=>I(Date.now()))},[r.timeRange,e]);const F=d.useMemo(()=>ca(e,A,S,T),[e,A,S,T]),q=d.useMemo(()=>{const u=r.limit??500;return[...F.length<=u?F:F.slice(-u)].sort((N,Q)=>(Q.timestamp??0)-(N.timestamp??0))},[F,r.limit]),Y=e.length===0,C=d.useMemo(()=>{let u=q;if(r.type!==void 0){const R=je[r.type];u=u.filter(N=>{const Q=N.type??N.payload_type,Z=N.payload_type_name;return Q===r.type||Z===R})}if(r.route!==void 0){const R=Ie[r.route];u=u.filter(N=>{const Q=N.route??N.route_type,Z=N.route_type_name;return Q===r.route||Z===R})}if(r.status&&r.status!=="all"&&(u=u.filter(R=>Ue(R)===r.status)),r.signalMin!==void 0&&(u=u.filter(R=>R.rssi>=r.signalMin)),r.timeRange&&r.timeRange>0){const R=_/1e3-r.timeRange*3600;u=u.filter(N=>N.timestamp>=R)}return u},[q,r.type,r.route,r.status,r.signalMin,r.timeRange,_]),w=(u,R)=>M(N=>({...N,[u]:R})),H=()=>M({limit:r.limit,status:"all"}),O=r.type!==void 0||r.route!==void 0||r.status&&r.status!=="all"||r.signalMin!==void 0||r.timeRange&&r.timeRange>0;return l.jsxs(fa,{children:[l.jsx(ga,{title:"Packet History",icon:l.jsx(ke,{}),controls:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(Ne,{outline:!0,color:O?"primary":"muted",onClick:()=>h(!y),className:"sm:hidden",children:[l.jsx(_e,{"data-slot":"icon"}),O&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-sys-blue"})]}),l.jsx(ha,{ranges:we,selectedIndex:v,onSelect:c,isPending:g})]})}),l.jsxs(xa,{children:[l.jsx(ya,{template:"auto",className:"relative z-10",children:l.jsx(he,{neomorphic:!0,className:"overflow-visible",children:l.jsx(da,{parentStartTs:T.start,parentEndTs:T.end,neighbors:z,filter:A,onChange:E})})}),l.jsxs(he,{neomorphic:!0,noPadding:!0,className:ne("overflow-hidden transition-all duration-200",y?"max-h-96 opacity-100":"max-h-0 opacity-0 sm:max-h-96 sm:opacity-100"),children:[l.jsx(Me,{listHeader:!0,icon:l.jsx(_e,{className:"icon-sm"}),title:"Filters",actions:O?l.jsxs(Ne,{plain:!0,color:"muted",onClick:H,className:"!text-xs !py-0.5 !px-1.5",children:[l.jsx(zt,{"data-slot":"icon",className:"!w-3 !h-3"}),"Clear"]}):void 0}),l.jsx("div",{className:"p-3 sm:p-4",children:l.jsxs("div",{className:"grid grid-cols-2 sm:flex sm:flex-wrap gap-3",children:[l.jsxs("div",{className:"flex-1 min-w-[140px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Type"}),l.jsx(oe,{value:r.type??"",onChange:u=>w("type",u===""?void 0:Number(u)),options:[{value:"",label:"All Types"},...Object.entries(je).map(([u,R])=>({value:Number(u),label:R}))],placeholder:"Search types...","aria-label":"Filter by packet type"})]}),l.jsxs("div",{className:"flex-1 min-w-[140px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Route"}),l.jsx(oe,{value:r.route??"",onChange:u=>w("route",u===""?void 0:Number(u)),options:[{value:"",label:"All Routes"},...Object.entries(Ie).map(([u,R])=>({value:Number(u),label:R}))],placeholder:"Search routes...","aria-label":"Filter by route type"})]}),l.jsxs("div",{className:"flex-1 min-w-[140px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Status"}),l.jsx(oe,{value:r.status??"all",onChange:u=>w("status",u),options:[{value:"all",label:"All Status"},{value:"rx",label:"Received"},{value:"forward",label:"Forwarded"},{value:"dropped",label:"Dropped"},{value:"duplicate",label:"Duplicate"}],placeholder:"Search status...","aria-label":"Filter by status"})]}),l.jsxs("div",{className:"flex-1 min-w-[120px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Time"}),l.jsx(oe,{value:r.timeRange??0,onChange:u=>w("timeRange",u===0?void 0:u),options:[{value:0,label:"All Time"},{value:1,label:"Last 1h"},{value:6,label:"Last 6h"},{value:24,label:"Last 24h"},{value:168,label:"Last 7d"}],placeholder:"Search time...","aria-label":"Filter by time range"})]}),l.jsxs("div",{className:"flex-1 min-w-[130px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Signal"}),l.jsx(oe,{value:r.signalMin??"",onChange:u=>w("signalMin",u===""?void 0:Number(u)),options:[{value:"",label:"Any Signal"},{value:-90,label:"Strong (≥-90)"},{value:-100,label:"Good (≥-100)"},{value:-110,label:"Fair (≥-110)"},{value:-120,label:"Weak (≥-120)"}],placeholder:"Search signal...","aria-label":"Filter by signal strength"})]}),l.jsxs("div",{className:"flex-1 min-w-[100px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Limit"}),l.jsx(oe,{value:r.limit??500,onChange:u=>w("limit",u),options:[{value:100,label:"100"},{value:200,label:"200"},{value:500,label:"500"},{value:1e3,label:"1K"},{value:2e3,label:"2K"},{value:5e3,label:"5K"},{value:1e4,label:"10K"}],placeholder:"Limit...","aria-label":"Packet limit"})]}),l.jsxs("div",{className:"flex-1 min-w-[100px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Per Page"}),l.jsx(oe,{value:r.perPage??50,onChange:u=>w("perPage",u),options:[{value:25,label:"25"},{value:50,label:"50"},{value:100,label:"100"},{value:200,label:"200"},{value:500,label:"500"}],placeholder:"Per page...","aria-label":"Packets per page"})]})]})})]}),l.jsx(Ua,{packets:C}),l.jsxs(he,{neomorphic:!0,noPadding:!0,className:"!overflow-visible",children:[l.jsx(Me,{listHeader:!0,icon:l.jsx(ke,{className:"icon-sm"}),title:"Packet History",actions:l.jsx(Ht,{enabled:b,onChange:P,label:"Hide Dupes",size:"sm"})}),l.jsx(qt,{packets:C,allPackets:e,localHash:s,neighbors:i,resolveSource:S,getDecodedContent:t,onChannelClick:n,loading:Y,showPagination:!0,perPage:r.perPage??50,hideDupes:b,emptyMessage:"No packets found"})]})]})]})}export{Eo as default}; diff --git a/frontend/dist/assets/Packets-aeMTl269.js b/frontend/dist/assets/Packets-aeMTl269.js new file mode 100644 index 00000000..9628f346 --- /dev/null +++ b/frontend/dist/assets/Packets-aeMTl269.js @@ -0,0 +1 @@ +import{r as d,aj as D,ak as at,al as Ve,am as Pe,an as te,ao as ot,ap as nt,aq as le,ar as Be,as as st,at as lt,au as it,av as me,aw as rt,ax as ut,ay as xe,az as B,aA as ct,aB as Ee,aC as W,aD as se,aE as Te,aF as Se,aG as dt,aH as ze,aI as He,aJ as be,aK as Ce,aL as ve,aM as pt,aN as mt,aO as bt,aP as Re,aQ as vt,aR as ft,aS as ge,aT as gt,aU as xt,aV as ht,aW as yt,aX as G,aY as St,aZ as Ct,a_ as Ot,a$ as Pt,b0 as Et,b1 as Tt,b2 as Rt,b3 as $t,b4 as wt,b5 as jt,b6 as It,b7 as $e,j as l,c as ne,ae as Nt,w as kt,x as Mt,b8 as Ft,y as Dt,E as At,J as _t,K as Lt,aa as Vt,ah as Bt,N as we,b9 as je,ba as Ie,B as Ne,bb as ke,F as Me,bc as zt,T as Ht}from"./index-BwGHI0A_.js";import{b as Ut,g as Ue,a as Kt,u as Gt,P as qt}from"./PacketList-CnGGHFuk.js";import{c as V,p as Wt,a as de,f as Fe,b as Yt,L as Xt,S as ue,s as Jt,u as De,d as Qt,g as Zt,e as ea,h as ta}from"./element-movement-BqZOD4DT.js";import{F as aa,y as oa,R as na,T as sa,w as Ae,A as la}from"./map-pin-VRY_TOuh.js";import{useGetDecodedContent as ia,useResolveSource as ra}from"./usePipelineStore-11oXtutw.js";import{c as ua,a as ca,A as da}from"./AnalyzerFilterPanel-BIfh-GdY.js";import{u as pa,r as ma}from"./consumer-registry-DPYvsBcc.js";import{A as ba}from"./arrow-up-DJuSVUZI.js";import{A as va}from"./SignalIndicator-LNOR_5YF.js";import{P as fa,a as ga,B as xa,C as he}from"./PageLayout-BIcqC04y.js";import{T as ha}from"./TimeRangeStepper-Dh4JEQ42.js";import{F as _e}from"./funnel-D4Wxq-Fx.js";import{R as ya}from"./Grid-BoZ-SJB7.js";import"./primitives-Cgn8YJud.js";import"./payload-decoders-7zyi-Y-D.js";import"./badge-colors-BNUqIXCA.js";import"./chat-utils-Di4-nywi.js";import"./chevron-right-DqpRZiGf.js";import"./circle-question-mark-DC7QfrVK.js";import"./triangle-alert-B4kC1YDk.js";import"./DataBox-CQS-Zhu0.js";import"./layers-C8ICjJ-w.js";import"./hash-9uwO8S8N.js";import"./activity-Dr_TPIps.js";import"./circle-check-CBI-CiRo.js";import"./database-CDN_R6oC.js";import"./useMapViewStore-CPURakCb.js";import"./index-OH01SZkk.js";import"./shield-DOTPcYJ1.js";import"./node-types-DmTOZWT4.js";import"./monitor-smartphone-BxljwdQV.js";import"./search-B7iMjmGm.js";function Ke(e){let a=d.useRef({value:"",selectionStart:null,selectionEnd:null});return at(e,"blur",t=>{let n=t.target;Pe(n)&&(a.current={value:n.value,selectionStart:n.selectionStart,selectionEnd:n.selectionEnd})}),D(()=>{if(!Ve(e)&&Pe(e)&&e.isConnected){if(e.focus({preventScroll:!0}),e.value!==a.current.value)e.setSelectionRange(e.value.length,e.value.length);else{let{selectionStart:t,selectionEnd:n}=a.current;t!==null&&n!==null&&e.setSelectionRange(t,n)}a.current={value:"",selectionStart:null,selectionEnd:null}}})}function Sa(e,{container:a,accept:t,walk:n}){let o=d.useRef(t),s=d.useRef(n);d.useEffect(()=>{o.current=t,s.current=n},[t,n]),te(()=>{if(!a||!e)return;let i=ot(a);if(!i)return;let v=o.current,c=s.current,m=Object.assign(y=>v(y),{acceptNode:v}),g=i.createTreeWalker(a,NodeFilter.SHOW_ELEMENT,m,!1);for(;g.nextNode();)c(g.currentNode)},[a,e,o,s])}var Ca=Object.defineProperty,Oa=(e,a,t)=>a in e?Ca(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t,Le=(e,a,t)=>(Oa(e,typeof a!="symbol"?a+"":a,t),t),x=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(x||{}),J=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(J||{}),ee=(e=>(e[e.Pointer=0]="Pointer",e[e.Focus=1]="Focus",e[e.Other=2]="Other",e))(ee||{}),Ge=(e=>(e[e.OpenCombobox=0]="OpenCombobox",e[e.CloseCombobox=1]="CloseCombobox",e[e.GoToOption=2]="GoToOption",e[e.SetTyping=3]="SetTyping",e[e.RegisterOption=4]="RegisterOption",e[e.UnregisterOption=5]="UnregisterOption",e[e.DefaultToFirstOption=6]="DefaultToFirstOption",e[e.SetActivationTrigger=7]="SetActivationTrigger",e[e.UpdateVirtualConfiguration=8]="UpdateVirtualConfiguration",e[e.SetInputElement=9]="SetInputElement",e[e.SetButtonElement=10]="SetButtonElement",e[e.SetOptionsElement=11]="SetOptionsElement",e[e.MarkInputAsMoved=12]="MarkInputAsMoved",e))(Ge||{});function ye(e,a=t=>t){let t=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,n=a(e.options.slice()),o=n.length>0&&n[0].dataRef.current.order!==null?n.sort((i,v)=>i.dataRef.current.order-v.dataRef.current.order):lt(n,i=>i.dataRef.current.domRef.current),s=t?o.indexOf(t):null;return s===-1&&(s=null),{options:o,activeOptionIndex:s}}let Pa={1(e){var a;if((a=e.dataRef.current)!=null&&a.disabled||e.comboboxState===1)return e;let t=e.inputElement?de.Tracked(Yt(e.inputElement)):e.inputPositionState;return{...e,activeOptionIndex:null,comboboxState:1,isTyping:!1,activationTrigger:2,inputPositionState:t,__demoMode:!1}},0(e){var a,t;if((a=e.dataRef.current)!=null&&a.disabled||e.comboboxState===0)return e;if((t=e.dataRef.current)!=null&&t.value){let n=e.dataRef.current.calculateIndex(e.dataRef.current.value);if(n!==-1)return{...e,activeOptionIndex:n,comboboxState:0,__demoMode:!1,inputPositionState:de.Idle}}return{...e,comboboxState:0,inputPositionState:de.Idle,__demoMode:!1}},3(e,a){return e.isTyping===a.isTyping?e:{...e,isTyping:a.isTyping}},2(e,a){var t,n,o,s;if((t=e.dataRef.current)!=null&&t.disabled||e.optionsElement&&!((n=e.dataRef.current)!=null&&n.optionsPropsRef.current.static)&&e.comboboxState===1)return e;if(e.virtual){let{options:m,disabled:g}=e.virtual,y=a.focus===V.Specific?a.idx:Fe(a,{resolveItems:()=>m,resolveActiveIndex:()=>{var b,p;return(p=(b=e.activeOptionIndex)!=null?b:m.findIndex(P=>!g(P)))!=null?p:null},resolveDisabled:g,resolveId(){throw new Error("Function not implemented.")}}),h=(o=a.trigger)!=null?o:2;return e.activeOptionIndex===y&&e.activationTrigger===h?e:{...e,activeOptionIndex:y,activationTrigger:h,isTyping:!1,__demoMode:!1}}let i=ye(e);if(i.activeOptionIndex===null){let m=i.options.findIndex(g=>!g.dataRef.current.disabled);m!==-1&&(i.activeOptionIndex=m)}let v=a.focus===V.Specific?a.idx:Fe(a,{resolveItems:()=>i.options,resolveActiveIndex:()=>i.activeOptionIndex,resolveId:m=>m.id,resolveDisabled:m=>m.dataRef.current.disabled}),c=(s=a.trigger)!=null?s:2;return e.activeOptionIndex===v&&e.activationTrigger===c?e:{...e,...i,isTyping:!1,activeOptionIndex:v,activationTrigger:c,__demoMode:!1}},4:(e,a)=>{var t,n,o,s;if((t=e.dataRef.current)!=null&&t.virtual)return{...e,options:[...e.options,a.payload]};let i=a.payload,v=ye(e,m=>(m.push(i),m));e.activeOptionIndex===null&&(o=(n=e.dataRef.current).isSelected)!=null&&o.call(n,a.payload.dataRef.current.value)&&(v.activeOptionIndex=v.options.indexOf(i));let c={...e,...v,activationTrigger:2};return(s=e.dataRef.current)!=null&&s.__demoMode&&e.dataRef.current.value===void 0&&(c.activeOptionIndex=0),c},5:(e,a)=>{var t;if((t=e.dataRef.current)!=null&&t.virtual)return{...e,options:e.options.filter(o=>o.id!==a.id)};let n=ye(e,o=>{let s=o.findIndex(i=>i.id===a.id);return s!==-1&&o.splice(s,1),o});return{...e,...n,activationTrigger:2}},6:(e,a)=>e.defaultToFirstOption===a.value?e:{...e,defaultToFirstOption:a.value},7:(e,a)=>e.activationTrigger===a.trigger?e:{...e,activationTrigger:a.trigger},8:(e,a)=>{var t,n;if(e.virtual===null)return{...e,virtual:{options:a.options,disabled:(t=a.disabled)!=null?t:()=>!1}};if(e.virtual.options===a.options&&e.virtual.disabled===a.disabled)return e;let o=e.activeOptionIndex;if(e.activeOptionIndex!==null){let s=a.options.indexOf(e.virtual.options[e.activeOptionIndex]);s!==-1?o=s:o=null}return{...e,activeOptionIndex:o,virtual:{options:a.options,disabled:(n=a.disabled)!=null?n:()=>!1}}},9:(e,a)=>e.inputElement===a.element?e:{...e,inputElement:a.element},10:(e,a)=>e.buttonElement===a.element?e:{...e,buttonElement:a.element},11:(e,a)=>e.optionsElement===a.element?e:{...e,optionsElement:a.element},12(e){return e.inputPositionState.kind!=="Tracked"?e:{...e,inputPositionState:de.Moved}}};class Oe extends nt{constructor(a){super(a),Le(this,"actions",{onChange:t=>{let{onChange:n,compare:o,mode:s,value:i}=this.state.dataRef.current;return le(s,{0:()=>n==null?void 0:n(t),1:()=>{let v=i.slice(),c=v.findIndex(m=>o(m,t));return c===-1?v.push(t):v.splice(c,1),n==null?void 0:n(v)}})},registerOption:(t,n)=>(this.send({type:4,payload:{id:t,dataRef:n}}),()=>{this.state.activeOptionIndex===this.state.dataRef.current.calculateIndex(n.current.value)&&this.send({type:6,value:!0}),this.send({type:5,id:t})}),goToOption:(t,n)=>(this.send({type:6,value:!1}),this.send({type:2,...t,trigger:n})),setIsTyping:t=>{this.send({type:3,isTyping:t})},closeCombobox:()=>{var t,n;this.send({type:1}),this.send({type:6,value:!1}),(n=(t=this.state.dataRef.current).onClose)==null||n.call(t)},openCombobox:()=>{this.send({type:0}),this.send({type:6,value:!0})},setActivationTrigger:t=>{this.send({type:7,trigger:t})},selectActiveOption:()=>{let t=this.selectors.activeOptionIndex(this.state);if(t!==null){if(this.actions.setIsTyping(!1),this.state.virtual)this.actions.onChange(this.state.virtual.options[t]);else{let{dataRef:n}=this.state.options[t];this.actions.onChange(n.current.value)}this.actions.goToOption({focus:V.Specific,idx:t})}},setInputElement:t=>{this.send({type:9,element:t})},setButtonElement:t=>{this.send({type:10,element:t})},setOptionsElement:t=>{this.send({type:11,element:t})}}),Le(this,"selectors",{activeDescendantId:t=>{var n,o;let s=this.selectors.activeOptionIndex(t);if(s!==null)return t.virtual?(o=t.options.find(i=>!i.dataRef.current.disabled&&t.dataRef.current.compare(i.dataRef.current.value,t.virtual.options[s])))==null?void 0:o.id:(n=t.options[s])==null?void 0:n.id},activeOptionIndex:t=>{if(t.defaultToFirstOption&&t.activeOptionIndex===null&&(t.virtual?t.virtual.options.length>0:t.options.length>0)){if(t.virtual){let{options:o,disabled:s}=t.virtual,i=o.findIndex(v=>{var c;return!((c=s==null?void 0:s(v))!=null&&c)});if(i!==-1)return i}let n=t.options.findIndex(o=>!o.dataRef.current.disabled);if(n!==-1)return n}return t.activeOptionIndex},activeOption:t=>{var n,o;let s=this.selectors.activeOptionIndex(t);return s===null?null:t.virtual?t.virtual.options[s??0]:(o=(n=t.options[s])==null?void 0:n.dataRef.current.value)!=null?o:null},isActive:(t,n,o)=>{var s;let i=this.selectors.activeOptionIndex(t);return i===null?!1:t.virtual?i===t.dataRef.current.calculateIndex(n):((s=t.options[i])==null?void 0:s.id)===o},shouldScrollIntoView:(t,n,o)=>!(t.virtual||t.__demoMode||t.comboboxState!==0||t.activationTrigger===0||!this.selectors.isActive(t,n,o)),didInputMove(t){return t.inputPositionState.kind==="Moved"}});{let t=this.state.id,n=Be.get(null);this.disposables.add(n.on(st.Push,o=>{!n.selectors.isTop(o,t)&&this.state.comboboxState===0&&this.actions.closeCombobox()})),this.on(0,()=>n.actions.push(t)),this.on(1,()=>n.actions.pop(t))}this.disposables.group(t=>{this.on(1,n=>{n.inputElement&&(t.dispose(),t.add(Wt(n.inputElement,n.inputPositionState,()=>{this.send({type:12})})))})})}static new({id:a,virtual:t=null,__demoMode:n=!1}){var o;return new Oe({id:a,dataRef:{current:{}},comboboxState:n?0:1,isTyping:!1,options:[],virtual:t?{options:t.options,disabled:(o=t.disabled)!=null?o:()=>!1}:null,activeOptionIndex:null,activationTrigger:2,inputElement:null,buttonElement:null,optionsElement:null,__demoMode:n,inputPositionState:de.Idle})}reduce(a,t){return le(t.type,Pa,a,t)}}const qe=d.createContext(null);function fe(e){let a=d.useContext(qe);if(a===null){let t=new Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,We),t}return a}function We({id:e,virtual:a=null,__demoMode:t=!1}){let n=d.useMemo(()=>Oe.new({id:e,virtual:a,__demoMode:t}),[]);return it(()=>n.dispose()),n}let pe=d.createContext(null);pe.displayName="ComboboxDataContext";function ie(e){let a=d.useContext(pe);if(a===null){let t=new Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,ie),t}return a}let Ye=d.createContext(null);function Ea(e){let a=fe("VirtualProvider"),t=ie("VirtualProvider"),{options:n}=t.virtual,o=B(a,b=>b.optionsElement),[s,i]=d.useMemo(()=>{let b=o;if(!b)return[0,0];let p=window.getComputedStyle(b);return[parseFloat(p.paddingBlockStart||p.paddingTop),parseFloat(p.paddingBlockEnd||p.paddingBottom)]},[o]),v=Ut({enabled:n.length!==0,scrollPaddingStart:s,scrollPaddingEnd:i,count:n.length,estimateSize(){return 40},getScrollElement(){return a.state.optionsElement},overscan:12}),[c,m]=d.useState(0);te(()=>{m(b=>b+1)},[n]);let g=v.getVirtualItems(),y=B(a,b=>b.activationTrigger===ee.Pointer),h=B(a,a.selectors.activeOptionIndex);return g.length===0?null:G.createElement(Ye.Provider,{value:v},G.createElement("div",{style:{position:"relative",width:"100%",height:`${v.getTotalSize()}px`},ref:b=>{b&&(y||h!==null&&n.length>h&&v.scrollToIndex(h))}},g.map(b=>{var p;return G.createElement(d.Fragment,{key:b.key},G.cloneElement((p=e.children)==null?void 0:p.call(e,{...e.slot,option:n[b.index]}),{key:`${c}-${b.key}`,"data-index":b.index,"aria-setsize":n.length,"aria-posinset":b.index+1,style:{position:"absolute",top:0,left:0,transform:`translateY(${b.start}px)`,overflowAnchor:"none"}}))})))}let Ta=d.Fragment;function Ra(e,a){let t=d.useId(),n=Et(),{value:o,defaultValue:s,onChange:i,form:v,name:c,by:m,invalid:g=!1,disabled:y=n||!1,onClose:h,__demoMode:b=!1,multiple:p=!1,immediate:P=!1,virtual:r=null,nullable:M,...A}=e,E=Tt(s),[T=p?[]:void 0,z]=Rt(o,i,E),S=We({id:t,virtual:r,__demoMode:b}),_=d.useRef({static:!1,hold:!1}),I=ta(m),F=D($=>r?m===null?r.options.indexOf($):r.options.findIndex(ae=>I(ae,$)):S.state.options.findIndex(ae=>I(ae.dataRef.current.value,$))),q=d.useCallback($=>le(w.mode,{[J.Multi]:()=>T.some(ae=>I(ae,$)),[J.Single]:()=>I(T,$)}),[T]),Y=B(S,$=>$.virtual),C=D(()=>h==null?void 0:h()),w=d.useMemo(()=>({__demoMode:b,immediate:P,optionsPropsRef:_,value:T,defaultValue:E,disabled:y,invalid:g,mode:p?J.Multi:J.Single,virtual:r?Y:null,onChange:z,isSelected:q,calculateIndex:F,compare:I,onClose:C}),[b,P,_,T,E,y,g,p,r,Y,z,q,F,I,C]);te(()=>{var $;r&&S.send({type:Ge.UpdateVirtualConfiguration,options:r.options,disabled:($=r.disabled)!=null?$:null})},[r,r==null?void 0:r.options,r==null?void 0:r.disabled]),te(()=>{S.state.dataRef.current=w},[w]);let[H,O,u,R]=B(S,$=>[$.comboboxState,$.buttonElement,$.inputElement,$.optionsElement]),N=Be.get(null),Q=B(N,d.useCallback($=>N.selectors.isTop($,t),[N,t]));$t(Q,[O,u,R],()=>S.actions.closeCombobox());let Z=B(S,S.selectors.activeOptionIndex),re=B(S,S.selectors.activeOption),f=be({open:H===x.Open,disabled:y,invalid:g,activeIndex:Z,activeOption:re,value:T}),[X,k]=wt(),U=a===null?{}:{ref:a},j=d.useCallback(()=>{if(E!==void 0)return z==null?void 0:z(E)},[z,E]),K=ve();return G.createElement(k,{value:X,props:{htmlFor:u==null?void 0:u.id},slot:{open:H===x.Open,disabled:y}},G.createElement(la,null,G.createElement(pe.Provider,{value:w},G.createElement(qe.Provider,{value:S},G.createElement(jt,{value:le(H,{[x.Open]:ge.Open,[x.Closed]:ge.Closed})},c!=null&&G.createElement(It,{disabled:y,data:T!=null?{[c]:T}:{},form:v,onReset:j}),K({ourProps:U,theirProps:A,slot:f,defaultTag:Ta,name:"Combobox"}))))))}let $a="input";function wa(e,a){var t,n;let o=fe("Combobox.Input"),s=ie("Combobox.Input"),i=d.useId(),v=ut(),{id:c=v||`headlessui-combobox-input-${i}`,onChange:m,displayValue:g,disabled:y=s.disabled||!1,autoFocus:h=!1,type:b="text",...p}=e,P=d.useRef(null),r=xe(P,a,aa(),o.actions.setInputElement),[M,A]=B(o,f=>[f.comboboxState,f.isTyping]),E=ct(),T=D(()=>{o.actions.onChange(null),o.state.optionsElement&&(o.state.optionsElement.scrollTop=0),o.actions.goToOption({focus:V.Nothing})}),z=d.useMemo(()=>{var f;return typeof g=="function"&&s.value!==void 0?(f=g(s.value))!=null?f:"":typeof s.value=="string"?s.value:""},[s.value,g]);Ee(([f,X],[k,U])=>{if(o.state.isTyping)return;let j=P.current;j&&((U===x.Open&&X===x.Closed||f!==k)&&(j.value=f),requestAnimationFrame(()=>{if(o.state.isTyping||!j||Ve(j))return;let{selectionStart:K,selectionEnd:$}=j;Math.abs(($??0)-(K??0))===0&&K===0&&j.setSelectionRange(j.value.length,j.value.length)}))},[z,M,A]),Ee(([f],[X])=>{if(f===x.Open&&X===x.Closed){if(o.state.isTyping)return;let k=P.current;if(!k)return;let U=k.value,{selectionStart:j,selectionEnd:K,selectionDirection:$}=k;k.value="",k.value=U,$!==null?k.setSelectionRange(j,K,$):k.setSelectionRange(j,K)}},[M]);let S=d.useRef(!1),_=D(()=>{S.current=!0}),I=D(()=>{E.nextFrame(()=>{S.current=!1})}),F=D(f=>{switch(o.actions.setIsTyping(!0),f.key){case W.Enter:if(o.state.comboboxState!==x.Open||S.current)return;if(f.preventDefault(),f.stopPropagation(),o.selectors.activeOptionIndex(o.state)===null){o.actions.closeCombobox();return}o.actions.selectActiveOption(),s.mode===J.Single&&o.actions.closeCombobox();break;case W.ArrowDown:return f.preventDefault(),f.stopPropagation(),le(o.state.comboboxState,{[x.Open]:()=>o.actions.goToOption({focus:V.Next}),[x.Closed]:()=>o.actions.openCombobox()});case W.ArrowUp:return f.preventDefault(),f.stopPropagation(),le(o.state.comboboxState,{[x.Open]:()=>o.actions.goToOption({focus:V.Previous}),[x.Closed]:()=>{se.flushSync(()=>o.actions.openCombobox()),s.value||o.actions.goToOption({focus:V.Last})}});case W.Home:if(o.state.comboboxState===x.Closed||f.shiftKey)break;return f.preventDefault(),f.stopPropagation(),o.actions.goToOption({focus:V.First});case W.PageUp:return f.preventDefault(),f.stopPropagation(),o.actions.goToOption({focus:V.First});case W.End:if(o.state.comboboxState===x.Closed||f.shiftKey)break;return f.preventDefault(),f.stopPropagation(),o.actions.goToOption({focus:V.Last});case W.PageDown:return f.preventDefault(),f.stopPropagation(),o.actions.goToOption({focus:V.Last});case W.Escape:return o.state.comboboxState!==x.Open?void 0:(f.preventDefault(),o.state.optionsElement&&!s.optionsPropsRef.current.static&&f.stopPropagation(),s.mode===J.Single&&s.value===null&&T(),o.actions.closeCombobox());case W.Tab:if(o.actions.setIsTyping(!1),o.state.comboboxState!==x.Open)return;s.mode===J.Single&&o.state.activationTrigger!==ee.Focus&&o.actions.selectActiveOption(),o.actions.closeCombobox();break}}),q=D(f=>{m==null||m(f),s.mode===J.Single&&f.target.value===""&&T(),o.actions.openCombobox()}),Y=D(f=>{var X,k,U;let j=(X=f.relatedTarget)!=null?X:Te.find(K=>K!==f.currentTarget);if(!((k=o.state.optionsElement)!=null&&k.contains(j))&&!((U=o.state.buttonElement)!=null&&U.contains(j))&&o.state.comboboxState===x.Open)return f.preventDefault(),s.mode===J.Single&&s.value===null&&T(),o.actions.closeCombobox()}),C=D(f=>{var X,k,U;let j=(X=f.relatedTarget)!=null?X:Te.find(K=>K!==f.currentTarget);(k=o.state.buttonElement)!=null&&k.contains(j)||(U=o.state.optionsElement)!=null&&U.contains(j)||s.disabled||s.immediate&&o.state.comboboxState!==x.Open&&E.microTask(()=>{se.flushSync(()=>o.actions.openCombobox()),o.actions.setActivationTrigger(ee.Focus)})}),w=Se(),H=dt(),{isFocused:O,focusProps:u}=ze({autoFocus:h}),{isHovered:R,hoverProps:N}=He({isDisabled:y}),Q=B(o,f=>f.optionsElement),Z=be({open:M===x.Open,disabled:y,invalid:s.invalid,hover:R,focus:O,autofocus:h}),re=Ce({ref:r,id:c,role:"combobox",type:b,"aria-controls":Q==null?void 0:Q.id,"aria-expanded":M===x.Open,"aria-activedescendant":B(o,o.selectors.activeDescendantId),"aria-labelledby":w,"aria-describedby":H,"aria-autocomplete":"list",defaultValue:(n=(t=e.defaultValue)!=null?t:s.defaultValue!==void 0?g==null?void 0:g(s.defaultValue):null)!=null?n:s.defaultValue,disabled:y||void 0,autoFocus:h,onCompositionStart:_,onCompositionEnd:I,onKeyDown:F,onChange:q,onFocus:C,onBlur:Y},u,N);return ve()({ourProps:re,theirProps:p,slot:Z,defaultTag:$a,name:"Combobox.Input"})}let ja="button";function Ia(e,a){let t=fe("Combobox.Button"),n=ie("Combobox.Button"),[o,s]=d.useState(null),i=xe(a,s,t.actions.setButtonElement),v=d.useId(),{id:c=`headlessui-combobox-button-${v}`,disabled:m=n.disabled||!1,autoFocus:g=!1,...y}=e,[h,b,p]=B(t,C=>[C.comboboxState,C.inputElement,C.optionsElement]),P=Ke(b),r=h===x.Open;Xt(r,{trigger:o,action:d.useCallback(C=>{if(o!=null&&o.contains(C.target))return ue.Ignore;if(b!=null&&b.contains(C.target))return ue.Ignore;let w=C.target.closest('[role="option"]:not([data-disabled])');return pt(w)?ue.Select(w):p!=null&&p.contains(C.target)?ue.Ignore:ue.Close},[o,b,p]),close:t.actions.closeCombobox,select:t.actions.selectActiveOption});let M=D(C=>{switch(C.key){case W.Space:case W.Enter:C.preventDefault(),C.stopPropagation(),t.state.comboboxState===x.Closed&&se.flushSync(()=>t.actions.openCombobox()),P();return;case W.ArrowDown:C.preventDefault(),C.stopPropagation(),t.state.comboboxState===x.Closed&&(se.flushSync(()=>t.actions.openCombobox()),t.state.dataRef.current.value||t.actions.goToOption({focus:V.First})),P();return;case W.ArrowUp:C.preventDefault(),C.stopPropagation(),t.state.comboboxState===x.Closed&&(se.flushSync(()=>t.actions.openCombobox()),t.state.dataRef.current.value||t.actions.goToOption({focus:V.Last})),P();return;case W.Escape:if(t.state.comboboxState!==x.Open)return;C.preventDefault(),t.state.optionsElement&&!n.optionsPropsRef.current.static&&C.stopPropagation(),se.flushSync(()=>t.actions.closeCombobox()),P();return;default:return}}),A=Jt(()=>{t.state.comboboxState===x.Open?t.actions.closeCombobox():t.actions.openCombobox(),P()}),E=Se([c]),{isFocusVisible:T,focusProps:z}=ze({autoFocus:g}),{isHovered:S,hoverProps:_}=He({isDisabled:m}),{pressed:I,pressProps:F}=mt({disabled:m}),q=be({open:h===x.Open,active:I||h===x.Open,disabled:m,invalid:n.invalid,value:n.value,hover:S,focus:T}),Y=Ce({ref:i,id:c,type:bt(e,o),tabIndex:-1,"aria-haspopup":"listbox","aria-controls":p==null?void 0:p.id,"aria-expanded":h===x.Open,"aria-labelledby":E,disabled:m||void 0,autoFocus:g,onKeyDown:M},A,z,_,F);return ve()({ourProps:Y,theirProps:y,slot:q,defaultTag:ja,name:"Combobox.Button"})}let Na="div",ka=$e.RenderStrategy|$e.Static;function Ma(e,a){var t,n,o;let s=d.useId(),{id:i=`headlessui-combobox-options-${s}`,hold:v=!1,anchor:c,portal:m=!1,modal:g=!0,transition:y=!1,...h}=e,b=fe("Combobox.Options"),p=ie("Combobox.Options"),P=oa(c);P&&(m=!0);let[r,M]=na(P),[A,E]=d.useState(null),T=sa(),z=xe(a,P?r:null,b.actions.setOptionsElement,E),[S,_,I,F,q]=B(b,L=>[L.comboboxState,L.inputElement,L.buttonElement,L.optionsElement,L.activationTrigger]),Y=Re(_||I),C=Re(F),w=vt(),[H,O]=ft(y,A,w!==null?(w&ge.Open)===ge.Open:S===x.Open);gt(H,_,b.actions.closeCombobox);let u=p.__demoMode?!1:g&&S===x.Open;xt(u,C);let R=p.__demoMode?!1:g&&S===x.Open;ht(R,{allowed:d.useCallback(()=>[_,I,F],[_,I,F])});let N=B(b,b.selectors.didInputMove)?!1:H;te(()=>{var L;p.optionsPropsRef.current.static=(L=e.static)!=null?L:!1},[p.optionsPropsRef,e.static]),te(()=>{p.optionsPropsRef.current.hold=v},[p.optionsPropsRef,v]),Sa(S===x.Open,{container:F,accept(L){return L.getAttribute("role")==="option"?NodeFilter.FILTER_REJECT:L.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(L){L.setAttribute("role","none")}});let Q=Se([I==null?void 0:I.id]),Z=be({open:S===x.Open,option:void 0}),re=D(()=>{b.actions.setActivationTrigger(ee.Pointer)}),f=D(L=>{L.preventDefault(),b.actions.setActivationTrigger(ee.Pointer)}),X=Ce(P?T():{},{"aria-labelledby":Q,role:"listbox","aria-multiselectable":p.mode===J.Multi?!0:void 0,id:i,ref:z,style:{...h.style,...M,"--input-width":Ae(H,_,!0).width,"--button-width":Ae(H,I,!0).width},onWheel:q===ee.Pointer?void 0:re,onMouseDown:f,...yt(O)}),k=H&&S===x.Closed&&!e.static,U=De(k,(t=p.virtual)==null?void 0:t.options),j=De(k,p.value),K=d.useCallback(L=>p.compare(j,L),[p.compare,j]),$=d.useMemo(()=>{if(!p.virtual)return p;if(U===void 0)throw new Error("Missing `options` in virtual mode");return U!==p.virtual.options?{...p,virtual:{...p.virtual,options:U}}:p},[p,U,(n=p.virtual)==null?void 0:n.options]);p.virtual&&Object.assign(h,{children:G.createElement(pe.Provider,{value:$},G.createElement(Ea,{slot:Z},h.children))});let ae=ve(),tt=d.useMemo(()=>p.mode===J.Multi?p:{...p,isSelected:K},[p,K]);return G.createElement(St,{enabled:m?e.static||H:!1,ownerDocument:Y},G.createElement(pe.Provider,{value:tt},ae({ourProps:X,theirProps:{...h,children:G.createElement(Qt,{freeze:k},typeof h.children=="function"?(o=h.children)==null?void 0:o.call(h,Z):h.children)},slot:Z,defaultTag:Na,features:ka,visible:N,name:"Combobox.Options"})))}let Fa="div";function Da(e,a){var t,n,o;let s=ie("Combobox.Option"),i=fe("Combobox.Option"),v=d.useId(),{id:c=`headlessui-combobox-option-${v}`,value:m,disabled:g=(o=(n=(t=s.virtual)==null?void 0:t.disabled)==null?void 0:n.call(t,m))!=null?o:!1,order:y=null,...h}=e,[b]=B(i,O=>[O.inputElement]),p=Ke(b),P=B(i,d.useCallback(O=>i.selectors.isActive(O,m,c),[m,c])),r=s.isSelected(m),M=d.useRef(null),A=Ct({disabled:g,value:m,domRef:M,order:y}),E=d.useContext(Ye),T=xe(a,M,E?E.measureElement:null),z=D(()=>{i.actions.setIsTyping(!1),i.actions.onChange(m)});te(()=>i.actions.registerOption(c,A),[A,c]);let S=B(i,d.useCallback(O=>i.selectors.shouldScrollIntoView(O,m,c),[m,c]));te(()=>{if(S)return Ot().requestAnimationFrame(()=>{var O,u;(u=(O=M.current)==null?void 0:O.scrollIntoView)==null||u.call(O,{block:"nearest"})})},[S,M]);let _=D(O=>{O.preventDefault(),O.button===Zt.Left&&(g||(z(),Pt()||requestAnimationFrame(()=>p()),s.mode===J.Single&&i.actions.closeCombobox()))}),I=D(()=>{if(g)return i.actions.goToOption({focus:V.Nothing});let O=s.calculateIndex(m);i.actions.goToOption({focus:V.Specific,idx:O})}),F=ea(),q=D(O=>F.update(O)),Y=D(O=>{if(!F.wasMoved(O)||g||P&&i.state.activationTrigger===ee.Pointer)return;let u=s.calculateIndex(m);i.actions.goToOption({focus:V.Specific,idx:u},ee.Pointer)}),C=D(O=>{F.wasMoved(O)&&(g||P&&(s.optionsPropsRef.current.hold||i.state.activationTrigger===ee.Pointer&&i.actions.goToOption({focus:V.Nothing})))}),w=be({active:P,focus:P,selected:r,disabled:g}),H={id:c,ref:T,role:"option",tabIndex:g===!0?void 0:-1,"aria-disabled":g===!0?!0:void 0,"aria-selected":r,disabled:void 0,onMouseDown:_,onFocus:I,onPointerEnter:q,onMouseEnter:q,onPointerMove:Y,onMouseMove:Y,onPointerLeave:C,onMouseLeave:C};return ve()({ourProps:H,theirProps:h,slot:w,defaultTag:Fa,name:"Combobox.Option"})}let Aa=me(Ra),Xe=me(Ia),Je=me(wa),_a=rt,Qe=me(Ma),Ze=me(Da),La=Object.assign(Aa,{Input:Je,Button:Xe,Label:_a,Options:Qe,Option:Ze});function Va({options:e,value:a,onChange:t,defaultValue:n,displayValue:o,filter:s,placeholder:i,disabled:v,invalid:c,name:m,"aria-label":g,className:y,children:h}){const[b,p]=d.useState(""),P=o??(E=>E!=null?String(E):""),M=s??((E,T)=>P(E).toLowerCase().includes(T.toLowerCase())),A=d.useMemo(()=>b?e.filter(E=>M(E,b)):e,[e,b,M]);return l.jsx(La,{value:a,onChange:t,defaultValue:n,disabled:v,name:m,onClose:()=>p(""),children:l.jsxs("div",{className:ne("relative",y),children:[l.jsxs("div",{className:"relative",children:[l.jsx(Je,{"aria-label":g,displayValue:P,onChange:E=>p(E.target.value),placeholder:i,className:ne(["w-full radius-inner py-2 pl-3 pr-10","text-sm text-fg-primary placeholder:text-fg-muted","bg-input-bg",c?"border border-sys-red":"border border-input-border","ring-focus-inset","hover:border-edge-strong","disabled:opacity-40 disabled:pointer-events-none disabled:cursor-not-allowed","transition-colors"])}),l.jsx(Xe,{className:"absolute inset-y-0 right-0 flex items-center pr-3 group",children:l.jsx(Nt,{className:"w-4 h-4 text-fg-muted transition-transform duration-200 group-data-[open]:rotate-180"})})]}),l.jsx(Qe,{anchor:"bottom start",transition:!0,className:ne(["w-[var(--input-width)] min-w-[180px]","max-h-60 overflow-y-auto overscroll-contain scroll-py-1","radius-inset p-1 mt-1","surface-elevated","focus:outline-none","transition-opacity","data-[closed]:opacity-0","data-[enter]:duration-150 data-[leave]:duration-100","z-50"]),children:A.length===0&&b!==""?l.jsx("div",{className:"px-3 py-2 text-sm text-fg-muted",children:"No results found"}):A.map((E,T)=>l.jsx(d.Fragment,{children:h(E)},T))})]})})}function Ba({value:e,disabled:a,className:t,children:n}){return l.jsx(Ze,{as:d.Fragment,value:e,disabled:a,children:({selected:o,focus:s})=>l.jsxs("div",{className:ne("flex items-center gap-2 px-3 py-2 radius-control cursor-default","text-sm",s&&"bg-sys-blue text-white",!s&&"text-fg-primary",o&&!s&&"text-sys-blue",a&&"opacity-50 cursor-not-allowed",t),children:[l.jsx("span",{className:"w-4 flex-shrink-0",children:o&&l.jsx(kt,{className:"w-4 h-4"})}),l.jsx("span",{className:"truncate flex-1",children:n})]})})}function za({className:e,...a}){return l.jsx("span",{...a,className:ne("truncate",e)})}function oe({value:e,onChange:a,options:t,placeholder:n,disabled:o,className:s,"aria-label":i}){const v=t.find(c=>c.value===e);return l.jsx(Va,{options:t,value:v,onChange:c=>{c&&a(c.value)},displayValue:c=>(c==null?void 0:c.label)??"",filter:(c,m)=>c.label.toLowerCase().includes(m.toLowerCase()),placeholder:n,disabled:o,className:s,"aria-label":i,children:c=>l.jsx(Ba,{value:c,disabled:c.disabled,children:l.jsx(za,{children:c.label})})})}const et=[{target:"PacketStats",fn:"type",minStage:1}];ma(et);function ce({icon:e,label:a,value:t,color:n,percentage:o}){return l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:ne("p-1.5 rounded-md",n),children:e}),l.jsxs("div",{className:"flex flex-col",children:[l.jsx("span",{className:"text-sm font-semibold text-fg-primary",children:t.toLocaleString()}),l.jsxs("span",{className:"text-xs text-fg-muted leading-tight",children:[a,o!==void 0&&l.jsxs("span",{className:"ml-1 opacity-70",children:["(",o,"%)"]})]})]})]})}function Ha({packets:e}){pa(et);const a=d.useMemo(()=>{let t=0,n=0,o=0;const s=new Set;let i=0,v=0;for(const y of e){switch(Ue(y)){case"forward":t++;break;case"dropped":n++;break;case"duplicate":o++;break}y.src_hash&&s.add(y.src_hash),y.rssi&&(i+=y.rssi,v++)}const c=e.length,m=v>0?Math.round(i/v):0;return{total:c,rx:c,fwd:t,dropped:n,duplicate:o,uniqueSources:s.size,avgRssi:m,rxPercent:100,fwdPercent:c>0?Math.round(t/c*100):0,droppedPercent:c>0?Math.round(n/c*100):0}},[e]);return e.length===0?null:l.jsx("div",{className:"surface-base depth-raised rounded-2xl p-3 pr-4",children:l.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:flex sm:items-center sm:justify-between sm:gap-6",children:[l.jsx(ce,{icon:l.jsx(ba,{className:"w-3.5 h-3.5 text-sys-blue"}),label:"Received",value:a.rx,color:"bg-sys-blue/10",percentage:a.rxPercent}),l.jsx(ce,{icon:l.jsx(va,{className:"w-3.5 h-3.5 text-sys-green"}),label:"Forwarded",value:a.fwd,color:"bg-sys-green/10",percentage:a.fwdPercent}),l.jsx(ce,{icon:l.jsx(Kt,{className:"w-3.5 h-3.5 text-sys-red"}),label:"Dropped",value:a.dropped,color:"bg-sys-red/10",percentage:a.droppedPercent}),l.jsx(ce,{icon:l.jsx(Mt,{className:"w-3.5 h-3.5 text-fg-muted"}),label:"Duplicates",value:a.duplicate,color:"bg-subtle-fill"}),l.jsxs("div",{className:"hidden sm:flex items-center gap-6 ml-auto",children:[l.jsx(ce,{icon:l.jsx(Ft,{className:"w-3.5 h-3.5 text-sys-indigo"}),label:"Sources",value:a.uniqueSources,color:"bg-sys-indigo/10"}),l.jsxs("div",{className:"flex flex-col items-end pr-1",children:[l.jsxs("span",{className:"type-data-sm text-fg-secondary",children:[a.avgRssi," dBm"]}),l.jsx("span",{className:"text-xs text-fg-muted",children:"Avg Signal"})]})]})]})})}const Ua=d.memo(Ha);function Po(){const e=Dt(),a=At(),t=ia(),n=Gt(u=>u.requestChannel),o=_t(),s=a==null?void 0:a.local_hash,i=a==null?void 0:a.neighbors,v=Lt(),c=Vt(),g=Bt().isBackgroundLoading&&v>=5,[y,h]=d.useState(!1),[b,p]=d.useState(!0),P=d.useCallback(u=>p(u),[]),[r,M]=d.useState({limit:500,status:"all"}),[A,E]=d.useState(ua),T=d.useMemo(()=>{const u=Math.floor(Date.now()/1e3),R=we[v].minutes;return{start:u-R*60,end:u}},[v]),z=d.useMemo(()=>{const u=(a==null?void 0:a.neighbors)??{};return Object.fromEntries(Object.entries(u).filter(([R])=>!o.has(R)))},[a==null?void 0:a.neighbors,o]),S=ra(),[_,I]=d.useState(Date.now);d.useEffect(()=>{r.timeRange&&r.timeRange>0&&queueMicrotask(()=>I(Date.now()))},[r.timeRange,e]);const F=d.useMemo(()=>ca(e,A,S,T),[e,A,S,T]),q=d.useMemo(()=>{const u=r.limit??500;return[...F.length<=u?F:F.slice(-u)].sort((N,Q)=>(Q.timestamp??0)-(N.timestamp??0))},[F,r.limit]),Y=e.length===0,C=d.useMemo(()=>{let u=q;if(r.type!==void 0){const R=je[r.type];u=u.filter(N=>{const Q=N.type??N.payload_type,Z=N.payload_type_name;return Q===r.type||Z===R})}if(r.route!==void 0){const R=Ie[r.route];u=u.filter(N=>{const Q=N.route??N.route_type,Z=N.route_type_name;return Q===r.route||Z===R})}if(r.status&&r.status!=="all"&&(u=u.filter(R=>Ue(R)===r.status)),r.signalMin!==void 0&&(u=u.filter(R=>R.rssi>=r.signalMin)),r.timeRange&&r.timeRange>0){const R=_/1e3-r.timeRange*3600;u=u.filter(N=>N.timestamp>=R)}return u},[q,r.type,r.route,r.status,r.signalMin,r.timeRange,_]),w=(u,R)=>M(N=>({...N,[u]:R})),H=()=>M({limit:r.limit,status:"all"}),O=r.type!==void 0||r.route!==void 0||r.status&&r.status!=="all"||r.signalMin!==void 0||r.timeRange&&r.timeRange>0;return l.jsxs(fa,{children:[l.jsx(ga,{title:"Packet History",icon:l.jsx(ke,{}),controls:l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(Ne,{outline:!0,color:O?"primary":"muted",onClick:()=>h(!y),className:"sm:hidden",children:[l.jsx(_e,{"data-slot":"icon"}),O&&l.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-sys-blue"})]}),l.jsx(ha,{ranges:we,selectedIndex:v,onSelect:c,isPending:g})]})}),l.jsxs(xa,{children:[l.jsx(ya,{template:"auto",className:"relative z-10",children:l.jsx(he,{neomorphic:!0,className:"overflow-visible",children:l.jsx(da,{parentStartTs:T.start,parentEndTs:T.end,neighbors:z,filter:A,onChange:E})})}),l.jsxs(he,{neomorphic:!0,noPadding:!0,className:ne("overflow-hidden transition-all duration-200",y?"max-h-96 opacity-100":"max-h-0 opacity-0 sm:max-h-96 sm:opacity-100"),children:[l.jsx(Me,{listHeader:!0,icon:l.jsx(_e,{className:"icon-sm"}),title:"Filters",actions:O?l.jsxs(Ne,{plain:!0,color:"muted",onClick:H,className:"!text-xs !py-0.5 !px-1.5",children:[l.jsx(zt,{"data-slot":"icon",className:"!w-3 !h-3"}),"Clear"]}):void 0}),l.jsx("div",{className:"p-3 sm:p-4",children:l.jsxs("div",{className:"grid grid-cols-2 sm:flex sm:flex-wrap gap-3",children:[l.jsxs("div",{className:"flex-1 min-w-[140px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Type"}),l.jsx(oe,{value:r.type??"",onChange:u=>w("type",u===""?void 0:Number(u)),options:[{value:"",label:"All Types"},...Object.entries(je).map(([u,R])=>({value:Number(u),label:R}))],placeholder:"Search types...","aria-label":"Filter by packet type"})]}),l.jsxs("div",{className:"flex-1 min-w-[140px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Route"}),l.jsx(oe,{value:r.route??"",onChange:u=>w("route",u===""?void 0:Number(u)),options:[{value:"",label:"All Routes"},...Object.entries(Ie).map(([u,R])=>({value:Number(u),label:R}))],placeholder:"Search routes...","aria-label":"Filter by route type"})]}),l.jsxs("div",{className:"flex-1 min-w-[140px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Status"}),l.jsx(oe,{value:r.status??"all",onChange:u=>w("status",u),options:[{value:"all",label:"All Status"},{value:"rx",label:"Received"},{value:"forward",label:"Forwarded"},{value:"dropped",label:"Dropped"},{value:"duplicate",label:"Duplicate"}],placeholder:"Search status...","aria-label":"Filter by status"})]}),l.jsxs("div",{className:"flex-1 min-w-[120px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Time"}),l.jsx(oe,{value:r.timeRange??0,onChange:u=>w("timeRange",u===0?void 0:u),options:[{value:0,label:"All Time"},{value:1,label:"Last 1h"},{value:6,label:"Last 6h"},{value:24,label:"Last 24h"},{value:168,label:"Last 7d"}],placeholder:"Search time...","aria-label":"Filter by time range"})]}),l.jsxs("div",{className:"flex-1 min-w-[130px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Signal"}),l.jsx(oe,{value:r.signalMin??"",onChange:u=>w("signalMin",u===""?void 0:Number(u)),options:[{value:"",label:"Any Signal"},{value:-90,label:"Strong (≥-90)"},{value:-100,label:"Good (≥-100)"},{value:-110,label:"Fair (≥-110)"},{value:-120,label:"Weak (≥-120)"}],placeholder:"Search signal...","aria-label":"Filter by signal strength"})]}),l.jsxs("div",{className:"flex-1 min-w-[100px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Limit"}),l.jsx(oe,{value:r.limit??500,onChange:u=>w("limit",u),options:[{value:100,label:"100"},{value:200,label:"200"},{value:500,label:"500"},{value:1e3,label:"1K"},{value:2e3,label:"2K"},{value:5e3,label:"5K"},{value:1e4,label:"10K"}],placeholder:"Limit...","aria-label":"Packet limit"})]}),l.jsxs("div",{className:"flex-1 min-w-[100px]",children:[l.jsx("label",{className:"type-micro block mb-1",children:"Per Page"}),l.jsx(oe,{value:r.perPage??50,onChange:u=>w("perPage",u),options:[{value:25,label:"25"},{value:50,label:"50"},{value:100,label:"100"},{value:200,label:"200"},{value:500,label:"500"}],placeholder:"Per page...","aria-label":"Packets per page"})]})]})})]}),l.jsx(Ua,{packets:C}),l.jsxs(he,{neomorphic:!0,noPadding:!0,className:"!overflow-visible",children:[l.jsx(Me,{listHeader:!0,icon:l.jsx(ke,{className:"icon-sm"}),title:"Packet History",actions:l.jsx(Ht,{enabled:b,onChange:P,label:"Hide Dupes",size:"sm"})}),l.jsx(qt,{packets:C,allPackets:e,localHash:s,neighbors:i,resolveSource:S,getDecodedContent:t,onChannelClick:n,loading:Y,showPagination:!0,perPage:r.perPage??50,hideDupes:b,emptyMessage:"No packets found"})]})]})]})}export{Po as default}; diff --git a/frontend/dist/assets/PageLayout-NQBVrM09.js b/frontend/dist/assets/PageLayout-BIcqC04y.js similarity index 93% rename from frontend/dist/assets/PageLayout-NQBVrM09.js rename to frontend/dist/assets/PageLayout-BIcqC04y.js index f0d84d46..e9ddd312 100644 --- a/frontend/dist/assets/PageLayout-NQBVrM09.js +++ b/frontend/dist/assets/PageLayout-BIcqC04y.js @@ -1 +1 @@ -import{j as e,o as r,c as t}from"./index-C8IY8K2r.js";function l({children:a,className:s}){return e.jsx("div",{className:t("section-gap",s),children:a})}function x({children:a,className:s}){return e.jsx("div",{className:t("bento-section",s),children:a})}function m({title:a,icon:s,controls:n,subtitle:i}){return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 min-h-9",children:[e.jsxs("h1",{className:"type-title text-fg-primary flex items-baseline gap-2 sm:gap-3 min-w-0",children:[s&&e.jsx("span",{className:"text-icon-page-title flex-shrink-0 translate-y-[0.1em] [&>svg]:h-[1em] [&>svg]:w-[1em] [&>svg]:stroke-[1.5]",children:s}),e.jsx("span",{className:"truncate",children:a})]}),n&&e.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:n})]}),i&&e.jsx("div",{children:i})]})}function d({size:a,...s}){return e.jsx(r,{...s})}export{x as B,d as C,l as P,m as a}; +import{j as e,o as r,c as t}from"./index-BwGHI0A_.js";function l({children:a,className:s}){return e.jsx("div",{className:t("section-gap",s),children:a})}function x({children:a,className:s}){return e.jsx("div",{className:t("bento-section",s),children:a})}function m({title:a,icon:s,controls:n,subtitle:i}){return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 min-h-9",children:[e.jsxs("h1",{className:"type-title text-fg-primary flex items-baseline gap-2 sm:gap-3 min-w-0",children:[s&&e.jsx("span",{className:"text-icon-page-title flex-shrink-0 translate-y-[0.1em] [&>svg]:h-[1em] [&>svg]:w-[1em] [&>svg]:stroke-[1.5]",children:s}),e.jsx("span",{className:"truncate",children:a})]}),n&&e.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:n})]}),i&&e.jsx("div",{children:i})]})}function d({size:a,...s}){return e.jsx(r,{...s})}export{x as B,d as C,l as P,m as a}; diff --git a/frontend/dist/assets/PathMapMapLibre-ANGN4-cP.js b/frontend/dist/assets/PathMapMapLibre-ANGN4-cP.js deleted file mode 100644 index e173e990..00000000 --- a/frontend/dist/assets/PathMapMapLibre-ANGN4-cP.js +++ /dev/null @@ -1,6 +0,0 @@ -import{d as re,r as a,bw as ae,bp as ie,f8 as le,Z as Q,by as de,j as t,q as K,c as G,f9 as ce}from"./index-C8IY8K2r.js";import{u as ue,M as pe,B as me,S as fe,L as ge,a as O,P as xe}from"./BasemapLayer-D5WYHXmJ.js";import{H as he}from"./useMapViewStore-ax-BqDpg.js";import"./index-B-prVW1V.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 ye=[["path",{d:"M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2",key:"5owen"}],["circle",{cx:"7",cy:"17",r:"2",key:"u2ysq9"}],["path",{d:"M9 17h6",key:"r8uit2"}],["circle",{cx:"17",cy:"17",r:"2",key:"axvx0g"}]],be=re("car",ye),Ce={version:8,sources:{},layers:[],glyphs:"https://tiles.basemaps.cartocdn.com/fonts/{fontstack}/{range}.pbf"},h={nodeColor:"#4338CA",localColor:"#4F46E5",hubColor:"#6366F1",edgeColor:"#3B3F4A",ambiguousColor:"#F9D26F",highlightColor:"#B49DFF",sourceColor:"#39D98A",destinationColor:"#B49DFF"};function C(c,r){if(!c)return r;if(c.startsWith("#"))return c;const m=ce(c);return m?`#${m.r.toString(16).padStart(2,"0")}${m.g.toString(16).padStart(2,"0")}${m.b.toString(16).padStart(2,"0")}`:r}function z(){if(typeof document>"u")return h;const c=document.documentElement,r=getComputedStyle(c);return{nodeColor:C(r.getPropertyValue("--map-node-stroke").trim(),h.nodeColor),localColor:C(r.getPropertyValue("--map-local-color").trim(),h.localColor),hubColor:C(r.getPropertyValue("--map-hub-color").trim(),h.hubColor),edgeColor:C(r.getPropertyValue("--map-edge-rest").trim(),h.edgeColor),ambiguousColor:C(r.getPropertyValue("--sys-indigo").trim(),h.ambiguousColor),highlightColor:C(r.getPropertyValue("--sys-blue").trim(),h.highlightColor),sourceColor:C(r.getPropertyValue("--sys-green").trim(),h.sourceColor),destinationColor:C(r.getPropertyValue("--sys-blue").trim(),h.destinationColor)}}function ve({prefix:c,isLocal:r,isSource:m,isDestination:$,isLastHop:y,isHighlighted:g,isWardrive:F,candidate:x,onHover:E,onLeave:N,onClick:S}){const[n,w]=a.useState(!1),I=a.useCallback(()=>{w(!0),E()},[E]),v=a.useCallback(()=>{w(!1),N()},[N]),P=()=>F?"orange":r?"amber":m?"green":y?"amber":$?"purple":"blue";return F?t.jsxs("div",{className:G("flex items-center cursor-pointer","transition-all duration-150",g&&"ring-2 ring-sys-blue/50 rounded-full",n&&"relative z-50"),onMouseEnter:I,onMouseLeave:v,onClick:S,style:{pointerEvents:"auto"},children:[t.jsx("div",{className:G("flex items-center justify-center","w-7 h-7 rounded-full","bg-sys-orange text-white","shadow-lg border-2 border-sys-orange/50","transition-transform duration-150",n&&"scale-110"),children:t.jsx(be,{className:"w-4 h-4",strokeWidth:2.5})}),n&&t.jsxs(K,{color:"orange",filled:!0,className:"ml-1 type-data-xs shadow-lg",children:[c,x.name&&t.jsx("span",{className:"ml-1 opacity-75",children:x.name})]})]}):t.jsx("div",{className:G("flex items-center cursor-pointer","transition-all duration-150",g&&"ring-2 ring-sys-blue/50 rounded",n&&"relative z-50"),onMouseEnter:I,onMouseLeave:v,onClick:S,style:{pointerEvents:"auto"},children:t.jsxs(K,{color:P(),filled:!0,className:"type-data-xs shadow-lg border border-current/30",children:[r&&t.jsx(he,{className:"w-2.5 h-2.5 mr-1"}),c,n&&x.name&&t.jsx("span",{className:"ml-1 opacity-75",children:x.name})]})})}function je({hopNumber:c,snr:r,edgeColor:m}){return t.jsxs("div",{className:"flex flex-col items-center gap-0.5 pointer-events-none",children:[t.jsx("span",{className:"w-3.5 h-3.5 rounded-full flex items-center justify-center font-mono font-bold tabular-nums shadow-md",style:{backgroundColor:m||Q[500],color:"#fff",fontSize:"8px",lineHeight:1,textShadow:"0 1px 1px rgba(0,0,0,0.4)"},children:c}),r!==void 0&&t.jsx(K,{color:"zinc",compact:!0,className:"!text-[9px] font-mono tabular-nums shadow-sm",children:r.toFixed(1)})]})}function Fe({resolvedPath:c,localNode:r,hubNodes:m=[],hoveredHopIndex:$,onHoverHop:y,traceSnr:g}){const F=g!==void 0&&g.length>0,x=a.useRef(null),E=ue(),N=ae(),S=a.useMemo(()=>new Set(m),[m]),[n,w]=a.useState(null),I=ie(),[v,P]=a.useState(!1),[Z,Y]=a.useState(0);a.useEffect(()=>{var f;const e=(f=x.current)==null?void 0:f.getMap();if(!e)return;const o=e.getCanvas();if(!o)return;const s=l=>{l.preventDefault(),console.warn("[PathMapMapLibre] WebGL context lost")},i=()=>{console.info("[PathMapMapLibre] WebGL context restored, remounting..."),Y(l=>l+1)};return o.addEventListener("webglcontextlost",s),o.addEventListener("webglcontextrestored",i),()=>{o.removeEventListener("webglcontextlost",s),o.removeEventListener("webglcontextrestored",i)}},[Z]);const{positions:j,markers:R,edges:D}=a.useMemo(()=>{const e=[],o=[],s=[],i=[],f=(p,V)=>p!==0||V!==0;let l=0,b=!1;return c.hops.forEach((p,V)=>{const B=p.candidates.filter(d=>f(d.latitude,d.longitude));if(B.length===0)return;const A=[...B].sort((d,k)=>k.probability-d.probability)[0],L=[A.longitude,A.latitude];if(i.push(L),i.length>=2){const d=i[i.length-2],k=i.length-2,M=g==null?void 0:g[k],T=L[0]-d[0],oe=L[1]-d[1],se=Math.atan2(T,oe)*(180/Math.PI),ne=z();let W;b?W="#F97316":M!==void 0?W=le()[de(M,N)]||Q[500]:W=ne.edgeColor,s.push({from:d,to:L,snrFwd:M,midpoint:[(d[0]+L[0])/2,(d[1]+L[1])/2],bearing:se,color:W,isFromWardrive:b})}const ee=p.isSource===!0,te=p.isDestination===!0;b=A.isWardrive===!0,B.forEach((d,k)=>{const M=[d.latitude,d.longitude];e.push(M);const T=k===0;o.push({position:M,prefix:p.prefix,confidence:p.confidence,candidateCount:B.length,hopIndex:V,candidate:d,isHub:S.has(d.hash),isPrimary:T,isSource:ee,isDestination:te,validIndex:l})}),l++}),{positions:e,markers:o,edges:s}},[c,S,g,N]),H=a.useMemo(()=>D.map(e=>({type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[e.from,e.to]}}]})),[D]),u=a.useMemo(()=>{const e=R.filter(l=>l.isPrimary&&(l.confidence>=.5||l.isSource||l.isDestination));if(e.length===0)return null;let o=1/0,s=-1/0,i=1/0,f=-1/0;for(const l of e){const[b,p]=l.position;bs&&(s=b),pf&&(f=p)}return[[i,o],[f,s]]},[R]),_=a.useMemo(()=>{if(j.length===0)return r?[r.longitude,r.latitude]:[0,0];let e=0,o=0;for(const[s,i]of j)e+=s,o+=i;return[o/j.length,e/j.length]},[j,r]),J=a.useCallback(()=>{var o;const e=(o=x.current)==null?void 0:o.getMap();if(!e||!u){P(!0);return}e.fitBounds(u,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:15,duration:0}),setTimeout(()=>{P(!0)},50)},[u]),U=a.useMemo(()=>u?`${u[0][0].toFixed(5)},${u[0][1].toFixed(5)},${u[1][0].toFixed(5)},${u[1][1].toFixed(5)}`:"",[u]);a.useEffect(()=>{var o;if(!v)return;const e=(o=x.current)==null?void 0:o.getMap();!e||!u||e.fitBounds(u,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:15,duration:300})},[U,v,u]);const q=I&&v,X=a.useCallback(e=>{w({longitude:e.position[1],latitude:e.position[0],marker:e})},[]);return j.length===0?t.jsx("div",{className:"h-full flex items-center justify-center text-fg-muted text-sm bg-elevated",children:"No mappable path data"}):t.jsxs("div",{className:"h-full w-full relative",children:[!q&&t.jsx("div",{className:"absolute inset-0 bg-elevated flex items-center justify-center pointer-events-none",children:t.jsx("div",{className:"w-5 h-5 border-2 border-text-muted/30 border-t-text-muted rounded-full animate-spin"})}),t.jsx("div",{className:"h-full w-full transition-opacity duration-300 ease-out",style:{opacity:q?1:0},children:t.jsxs(pe,{ref:x,initialViewState:{longitude:_[0],latitude:_[1],zoom:10},onLoad:J,style:{height:"100%",width:"100%"},mapStyle:Ce,attributionControl:!1,children:[t.jsx(me,{mode:E}),D.map((e,o)=>t.jsx(fe,{id:`edge-${o}`,type:"geojson",data:H[o],children:t.jsx(ge,{id:`edge-line-${o}`,type:"line",paint:{"line-color":e.color,"line-width":4,"line-opacity":1},layout:{"line-cap":"round","line-join":"round"}})},`edge-${o}`)),D.map((e,o)=>t.jsx(O,{longitude:e.midpoint[0],latitude:e.midpoint[1],anchor:"center",children:t.jsx(je,{hopNumber:o+1,snr:F?e.snrFwd:void 0,edgeColor:e.color})},`hop-${o}`)),(()=>{const e=R.filter(s=>s.isPrimary),o=e.length>1?e.length-2:-1;return e.map((s,i)=>{const f=$===s.hopIndex,l=i===o&&!s.candidate.isLocal&&!s.isDestination;return t.jsx(O,{longitude:s.position[1],latitude:s.position[0],anchor:"center",children:t.jsx(ve,{prefix:s.prefix,isLocal:s.candidate.isLocal||!1,isSource:s.isSource,isDestination:s.isDestination,isLastHop:l,isHighlighted:f,isWardrive:s.candidate.isWardrive||!1,candidate:s.candidate,onHover:()=>y==null?void 0:y(s.hopIndex),onLeave:()=>y==null?void 0:y(null),onClick:()=>X(s)})},`${s.hopIndex}-${s.candidate.hash}`)})})(),n&&t.jsx(xe,{longitude:n.longitude,latitude:n.latitude,anchor:"bottom",offset:[0,-12],closeOnClick:!1,onClose:()=>w(null),className:"maplibre-popup",children:t.jsxs("div",{className:"text-xs",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"font-semibold",children:n.marker.candidate.name}),(()=>{const e=z();return t.jsxs(t.Fragment,{children:[n.marker.isSource&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.sourceColor,color:"#000"},children:"SRC"}),n.marker.isDestination&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.destinationColor,color:"#000"},children:"DST"}),n.marker.isHub&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.hubColor,color:"#000"},children:"HUB"}),n.marker.candidate.isLocal&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.localColor,color:"#fff"},children:"LOCAL"}),n.marker.candidate.isWardrive&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:"#F97316",color:"#fff"},children:"WARDRIVE"})]})})()]}),t.jsxs("div",{className:"text-fg-muted type-data-xs",children:[n.marker.prefix," • ",n.marker.candidate.hash.slice(0,10),"..."]}),!n.marker.isPrimary&&n.marker.candidateCount>1&&t.jsxs("div",{style:{color:z().ambiguousColor},children:["Alternative (",(n.marker.candidate.probability*100).toFixed(0),"%)"]}),n.marker.isPrimary&&n.marker.candidateCount>1&&t.jsxs("div",{className:"text-fg-muted",children:[n.marker.candidateCount," candidates"]})]})})]},Z)})]})}export{Fe as default}; diff --git a/frontend/dist/assets/PathMapMapLibre-CUvyj6hi.js b/frontend/dist/assets/PathMapMapLibre-CUvyj6hi.js new file mode 100644 index 00000000..8707715c --- /dev/null +++ b/frontend/dist/assets/PathMapMapLibre-CUvyj6hi.js @@ -0,0 +1,6 @@ +import{d as ae,r as a,by as ie,br as le,fe as de,Z as Y,bB as ce,j as t,q as K,c as G,ff as ue}from"./index-BwGHI0A_.js";import{u as pe,M as me,B as fe,S as ge,L as xe,a as Q,P as he}from"./BasemapLayer-Bm_seLWQ.js";import{H as ye}from"./useMapViewStore-CPURakCb.js";import"./index-OH01SZkk.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 be=[["path",{d:"M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2",key:"5owen"}],["circle",{cx:"7",cy:"17",r:"2",key:"u2ysq9"}],["path",{d:"M9 17h6",key:"r8uit2"}],["circle",{cx:"17",cy:"17",r:"2",key:"axvx0g"}]],Ce=ae("car",be),ve={version:8,sources:{},layers:[],glyphs:"https://tiles.basemaps.cartocdn.com/fonts/{fontstack}/{range}.pbf"},h={nodeColor:"#4338CA",localColor:"#4F46E5",hubColor:"#6366F1",edgeColor:"#3B3F4A",ambiguousColor:"#F9D26F",highlightColor:"#B49DFF",sourceColor:"#39D98A",destinationColor:"#B49DFF"};function C(c,r){if(!c)return r;if(c.startsWith("#"))return c;const m=ue(c);return m?`#${m.r.toString(16).padStart(2,"0")}${m.g.toString(16).padStart(2,"0")}${m.b.toString(16).padStart(2,"0")}`:r}function z(){if(typeof document>"u")return h;const c=document.documentElement,r=getComputedStyle(c);return{nodeColor:C(r.getPropertyValue("--map-node-stroke").trim(),h.nodeColor),localColor:C(r.getPropertyValue("--map-local-color").trim(),h.localColor),hubColor:C(r.getPropertyValue("--map-hub-color").trim(),h.hubColor),edgeColor:C(r.getPropertyValue("--map-edge-rest").trim(),h.edgeColor),ambiguousColor:C(r.getPropertyValue("--sys-indigo").trim(),h.ambiguousColor),highlightColor:C(r.getPropertyValue("--sys-blue").trim(),h.highlightColor),sourceColor:C(r.getPropertyValue("--sys-green").trim(),h.sourceColor),destinationColor:C(r.getPropertyValue("--sys-blue").trim(),h.destinationColor)}}function je({prefix:c,isLocal:r,isSource:m,isDestination:W,isLastHop:y,isHighlighted:g,isWardrive:F,candidate:x,onHover:E,onLeave:N,onClick:S}){const[n,k]=a.useState(!1),I=a.useCallback(()=>{k(!0),E()},[E]),v=a.useCallback(()=>{k(!1),N()},[N]),P=()=>F?"orange":r?"amber":m?"green":y?"amber":W?"purple":"blue";return F?t.jsxs("div",{className:G("flex items-center cursor-pointer","transition-all duration-150",g&&"ring-2 ring-sys-blue/50 rounded-full",n&&"relative z-50"),onMouseEnter:I,onMouseLeave:v,onClick:S,style:{pointerEvents:"auto"},children:[t.jsx("div",{className:G("flex items-center justify-center","w-7 h-7 rounded-full","bg-sys-orange text-white","shadow-lg border-2 border-sys-orange/50","transition-transform duration-150",n&&"scale-110"),children:t.jsx(Ce,{className:"w-4 h-4",strokeWidth:2.5})}),n&&t.jsxs(K,{color:"orange",filled:!0,className:"ml-1 type-data-xs shadow-lg",children:[c,x.name&&t.jsx("span",{className:"ml-1 opacity-75",children:x.name})]})]}):t.jsx("div",{className:G("flex items-center cursor-pointer","transition-all duration-150",g&&"ring-2 ring-sys-blue/50 rounded",n&&"relative z-50"),onMouseEnter:I,onMouseLeave:v,onClick:S,style:{pointerEvents:"auto"},children:t.jsxs(K,{color:P(),filled:!0,className:"type-data-xs shadow-lg border border-current/30",children:[r&&t.jsx(ye,{className:"w-2.5 h-2.5 mr-1"}),c,n&&x.name&&t.jsx("span",{className:"ml-1 opacity-75",children:x.name})]})})}function Le({hopNumber:c,snr:r,edgeColor:m}){return t.jsxs("div",{className:"flex flex-col items-center gap-0.5 pointer-events-none",children:[t.jsx("span",{className:"w-3.5 h-3.5 rounded-full flex items-center justify-center font-mono font-bold tabular-nums shadow-md",style:{backgroundColor:m||Y[500],color:"#fff",fontSize:"8px",lineHeight:1,textShadow:"0 1px 1px rgba(0,0,0,0.4)"},children:c}),r!==void 0&&t.jsx(K,{color:"zinc",compact:!0,className:"!text-[9px] font-mono tabular-nums shadow-sm",children:r.toFixed(1)})]})}function Fe({resolvedPath:c,localNode:r,hubNodes:m=[],hoveredHopIndex:W,onHoverHop:y,traceSnr:g}){const F=g!==void 0&&g.length>0,x=a.useRef(null),E=pe(),N=ie(),S=a.useMemo(()=>new Set(m),[m]),[n,k]=a.useState(null),I=le(),[v,P]=a.useState(!1),[Z,H]=a.useState(0);a.useEffect(()=>{var f;const e=(f=x.current)==null?void 0:f.getMap();if(!e)return;const o=e.getCanvas();if(!o)return;const s=l=>{l.preventDefault(),console.warn("[PathMapMapLibre] WebGL context lost")},i=()=>{console.info("[PathMapMapLibre] WebGL context restored, remounting..."),H(l=>l+1)};return o.addEventListener("webglcontextlost",s),o.addEventListener("webglcontextrestored",i),()=>{o.removeEventListener("webglcontextlost",s),o.removeEventListener("webglcontextrestored",i)}},[Z]);const{positions:j,markers:$,edges:D}=a.useMemo(()=>{const e=[],o=[],s=[],i=[],f=(p,R)=>p!==0||R!==0;let l=0,b=!1;return c.hops.forEach((p,R)=>{const O=p.candidates.filter(d=>f(d.latitude,d.longitude));if(O.length===0)return;const V=[...O].sort((d,w)=>w.probability-d.probability),A=V[0],L=[A.longitude,A.latitude];if(i.push(L),i.length>=2){const d=i[i.length-2],w=i.length-2,M=g==null?void 0:g[w],T=L[0]-d[0],se=L[1]-d[1],ne=Math.atan2(T,se)*(180/Math.PI),re=z();let B;b?B="#F97316":M!==void 0?B=de()[ce(M,N)]||Y[500]:B=re.edgeColor,s.push({from:d,to:L,snrFwd:M,midpoint:[(d[0]+L[0])/2,(d[1]+L[1])/2],bearing:ne,color:B,isFromWardrive:b})}const te=p.isSource===!0,oe=p.isDestination===!0;b=A.isWardrive===!0,V.forEach((d,w)=>{const M=[d.latitude,d.longitude];e.push(M);const T=w===0;o.push({position:M,prefix:p.prefix,confidence:p.confidence,candidateCount:V.length,hopIndex:R,candidate:d,isHub:S.has(d.hash),isPrimary:T,isSource:te,isDestination:oe,validIndex:l})}),l++}),{positions:e,markers:o,edges:s}},[c,S,g,N]),J=a.useMemo(()=>D.map(e=>({type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[e.from,e.to]}}]})),[D]),u=a.useMemo(()=>{const e=$.filter(l=>l.isPrimary&&(l.confidence>=.5||l.isSource||l.isDestination));if(e.length===0)return null;let o=1/0,s=-1/0,i=1/0,f=-1/0;for(const l of e){const[b,p]=l.position;bs&&(s=b),pf&&(f=p)}return[[i,o],[f,s]]},[$]),_=a.useMemo(()=>{if(j.length===0)return r?[r.longitude,r.latitude]:[0,0];let e=0,o=0;for(const[s,i]of j)e+=s,o+=i;return[o/j.length,e/j.length]},[j,r]),U=a.useCallback(()=>{var o;const e=(o=x.current)==null?void 0:o.getMap();if(!e||!u){P(!0);return}e.fitBounds(u,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:15,duration:0}),setTimeout(()=>{P(!0)},50)},[u]),X=a.useMemo(()=>u?`${u[0][0].toFixed(5)},${u[0][1].toFixed(5)},${u[1][0].toFixed(5)},${u[1][1].toFixed(5)}`:"",[u]);a.useEffect(()=>{var o;if(!v)return;const e=(o=x.current)==null?void 0:o.getMap();!e||!u||e.fitBounds(u,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:15,duration:300})},[X,v,u]);const q=I&&v,ee=a.useCallback(e=>{k({longitude:e.position[1],latitude:e.position[0],marker:e})},[]);return j.length===0?t.jsx("div",{className:"h-full flex items-center justify-center text-fg-muted text-sm bg-elevated",children:"No mappable path data"}):t.jsxs("div",{className:"h-full w-full relative",children:[!q&&t.jsx("div",{className:"absolute inset-0 bg-elevated flex items-center justify-center pointer-events-none",children:t.jsx("div",{className:"w-5 h-5 border-2 border-text-muted/30 border-t-text-muted rounded-full animate-spin"})}),t.jsx("div",{className:"h-full w-full transition-opacity duration-300 ease-out",style:{opacity:q?1:0},children:t.jsxs(me,{ref:x,initialViewState:{longitude:_[0],latitude:_[1],zoom:10},onLoad:U,style:{height:"100%",width:"100%"},mapStyle:ve,attributionControl:!1,children:[t.jsx(fe,{mode:E}),D.map((e,o)=>t.jsx(ge,{id:`edge-${o}`,type:"geojson",data:J[o],children:t.jsx(xe,{id:`edge-line-${o}`,type:"line",paint:{"line-color":e.color,"line-width":4,"line-opacity":1},layout:{"line-cap":"round","line-join":"round"}})},`edge-${o}`)),D.map((e,o)=>t.jsx(Q,{longitude:e.midpoint[0],latitude:e.midpoint[1],anchor:"center",children:t.jsx(Le,{hopNumber:o+1,snr:F?e.snrFwd:void 0,edgeColor:e.color})},`hop-${o}`)),(()=>{const e=$.filter(s=>s.isPrimary),o=e.length>1?e.length-2:-1;return e.map((s,i)=>{const f=W===s.hopIndex,l=i===o&&!s.candidate.isLocal&&!s.isDestination;return t.jsx(Q,{longitude:s.position[1],latitude:s.position[0],anchor:"center",children:t.jsx(je,{prefix:s.prefix,isLocal:s.candidate.isLocal||!1,isSource:s.isSource,isDestination:s.isDestination,isLastHop:l,isHighlighted:f,isWardrive:s.candidate.isWardrive||!1,candidate:s.candidate,onHover:()=>y==null?void 0:y(s.hopIndex),onLeave:()=>y==null?void 0:y(null),onClick:()=>ee(s)})},`${s.hopIndex}-${s.candidate.hash}`)})})(),n&&t.jsx(he,{longitude:n.longitude,latitude:n.latitude,anchor:"bottom",offset:[0,-12],closeOnClick:!1,onClose:()=>k(null),className:"maplibre-popup",children:t.jsxs("div",{className:"text-xs",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"font-semibold",children:n.marker.candidate.name}),(()=>{const e=z();return t.jsxs(t.Fragment,{children:[n.marker.isSource&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.sourceColor,color:"#000"},children:"SRC"}),n.marker.isDestination&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.destinationColor,color:"#000"},children:"DST"}),n.marker.isHub&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.hubColor,color:"#000"},children:"HUB"}),n.marker.candidate.isLocal&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:e.localColor,color:"#fff"},children:"LOCAL"}),n.marker.candidate.isWardrive&&t.jsx("span",{className:"px-1 py-0.5 text-[8px] font-bold rounded",style:{backgroundColor:"#F97316",color:"#fff"},children:"WARDRIVE"})]})})()]}),t.jsxs("div",{className:"text-fg-muted type-data-xs",children:[n.marker.prefix," • ",n.marker.candidate.hash.slice(0,10),"..."]}),!n.marker.isPrimary&&n.marker.candidateCount>1&&t.jsxs("div",{style:{color:z().ambiguousColor},children:["Alternative (",(n.marker.candidate.probability*100).toFixed(0),"%)"]}),n.marker.isPrimary&&n.marker.candidateCount>1&&t.jsxs("div",{className:"text-fg-muted",children:[n.marker.candidateCount," candidates"]})]})})]},Z)})]})}export{Fe as default}; diff --git a/frontend/dist/assets/RoomServer-IEGP0mqy.js b/frontend/dist/assets/RoomServer-BJlrNokH.js similarity index 94% rename from frontend/dist/assets/RoomServer-IEGP0mqy.js rename to frontend/dist/assets/RoomServer-BJlrNokH.js index ed4d72aa..280cef37 100644 --- a/frontend/dist/assets/RoomServer-IEGP0mqy.js +++ b/frontend/dist/assets/RoomServer-BJlrNokH.js @@ -1,4 +1,4 @@ -import{d as V,j as e,cW as Ke,c as L,aw as Fe,dJ as Oe,r as o,bL as Y,R as qe,ac as Be,dr as ze,ad as He,q as W,I as B,dK as Ue,B as F,bv as Me,ae as ue,cR as Ve,F as se,w as G,x as We,dL as Re,dM as Ge,b8 as Te,dN as Ye,dO as Ie,dP as Je,dQ as Qe,dR as Xe,dS as Ze,dT as es,dU as ss,E as ts,y as as,dE as ns,bN as xe}from"./index-C8IY8K2r.js";import{C as U,P as pe,a as he,B as rs}from"./PageLayout-NQBVrM09.js";import{R as ls,C as ge}from"./Grid-CEGkNRmt.js";import{c as os,m as is}from"./node-types-3T9Wr7vI.js";import{L as cs,a as ds,b as ms}from"./listbox-BhQdM5DY.js";import{P as us}from"./plus-PWV57wbr.js";import{M as X}from"./map-pin-DMVHq6j8.js";import{T as Le,C as fe}from"./ConfirmModal-CNsW1W2q.js";import{S as Z,K as I}from"./KeycapButton-BJvlGsWZ.js";import{S as xs,C as ps,M as hs}from"./ChatBubble-0UYYugYB.js";import{e as gs,g as fs,a as js}from"./chat-utils-D1Q4VWjO.js";import{W as ee}from"./wifi-Cq9uCDyf.js";import{K as vs}from"./key-round-CQ-pu-yY.js";import"./element-movement-D4o83B2Z.js";import"./triangle-alert-8k00uu7o.js";import"./keycap-sfx-ByZp-njj.js";/** +import{d as V,j as e,c$ as Ke,c as L,aw as Fe,dO as Oe,r as o,bO as Y,R as qe,ac as Be,dw as ze,ad as He,q as W,I as B,dP as Ue,B as F,bx as Me,ae as ue,cW as Ve,F as se,w as G,x as We,dQ as Re,dR as Ge,b8 as Te,dS as Ye,dT as Ie,dU as Qe,dV as Xe,dW as Ze,dX as Je,dY as es,dZ as ss,E as ts,y as as,dJ as ns,bQ as xe}from"./index-BwGHI0A_.js";import{C as U,P as pe,a as he,B as rs}from"./PageLayout-BIcqC04y.js";import{R as ls,C as ge}from"./Grid-BoZ-SJB7.js";import{c as os,m as is}from"./node-types-DmTOZWT4.js";import{L as cs,a as ds,b as ms}from"./listbox-_tsR-2yL.js";import{P as us}from"./plus-C0xom_iW.js";import{M as Z}from"./map-pin-VRY_TOuh.js";import{T as Le,C as fe}from"./ConfirmModal-B0nTD1Q0.js";import{S as J,K as I}from"./KeycapButton-CT5jwzf3.js";import{S as xs,C as ps,M as hs}from"./ChatBubble-Bxq40Qnq.js";import{e as gs,g as fs,a as js}from"./chat-utils-Di4-nywi.js";import{W as ee}from"./wifi-BaASFkdf.js";import{K as vs}from"./key-round-DKeM0xKx.js";import"./element-movement-BqZOD4DT.js";import"./triangle-alert-B4kC1YDk.js";import"./keycap-sfx-ByZp-njj.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -23,4 +23,4 @@ import{d as V,j as e,cW as Ke,c as L,aw as Fe,dJ as Oe,r as o,bL as Y,R as qe,ac * * 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:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]],_s=V("user-x",Ss);function z({disabled:s,className:t,children:l}){return e.jsx(Ke,{disabled:s,className:L("flex flex-col gap-2",t),children:l})}function H({required:s,className:t,children:l,...a}){return e.jsxs(Fe,{className:L("text-sm font-medium text-fg-primary select-none","data-[disabled]:opacity-50",a.title&&"cursor-help",t),...a,children:[l,s&&e.jsx("span",{className:"text-sys-red ml-0.5","aria-hidden":"true",children:"*"})]})}function Ms({className:s,children:t,...l}){return e.jsx(Oe,{className:L("text-sm text-fg-muted","data-[disabled]:opacity-50",s),...l,children:t})}function Rs(s,t){return o.useMemo(()=>{const a=new Map;for(const[n,c]of Object.entries(s)){const m=c.name||c.node_name||null,{type:d}=os(c);a.set(n.toLowerCase(),{name:m,type:d})}const r=new Map;for(let n=t.length-1;n>=0;n--){const c=t[n];if(!c._advertSender)continue;const m=c._advertSender.toLowerCase();if(r.has(m))continue;const d=c._advertName??null,i=c._advertNodeType!=null?is(c._advertNodeType):"companion";r.set(m,{name:d,type:i})}return function(c){const m=c.toLowerCase(),d=a.get(m);if(d!=null&&d.name)return d;const i=r.get(m);return i!=null&&i.name?i:d||i||{name:null,type:"companion"}}},[s,t])}function ve({icon:s,title:t,description:l,onClick:a,accent:r}){return e.jsxs("button",{onClick:a,className:L("flex flex-col items-center gap-3 p-6 rounded-2xl text-center","ring-1 ring-edge-subtle hover:ring-2 transition-all duration-150","w-full max-w-[260px]",r==="primary"?"hover:ring-sys-blue hover:bg-sys-blue/5":"hover:ring-sys-indigo hover:bg-sys-indigo/5"),children:[e.jsx("div",{className:L("p-3 rounded-xl",r==="primary"?"bg-sys-blue/10 text-sys-blue":"bg-sys-indigo/10 text-sys-indigo"),children:s}),e.jsx("p",{className:"type-body-sm font-medium text-fg-primary",children:t}),e.jsx("p",{className:"type-data-xs text-fg-muted leading-relaxed",children:l})]})}function Ts({onCreateRoom:s}){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-4",children:[e.jsx(Y,{className:"w-12 h-12 text-fg-muted opacity-30 mb-4"}),e.jsx("p",{className:"type-subheading text-fg-secondary mb-1",children:"Add a Room Server"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-8",children:"Choose how this device should operate."}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-4",children:[e.jsx(ve,{icon:e.jsx(ws,{className:"w-6 h-6"}),title:"Repeater + Room Server",description:"Keep forwarding packets and add group messaging.",onClick:()=>s("hybrid"),accent:"primary"}),e.jsx(ve,{icon:e.jsx(qe,{className:"w-6 h-6"}),title:"Dedicated Room Server",description:"Stop repeating. Focus entirely on room server duties.",onClick:()=>s("dedicated"),accent:"secondary"})]})]})}function Ls({rooms:s,selected:t,onSelect:l,onAdd:a}){const r=a?e.jsx("button",{onClick:a,className:L("flex items-center justify-center px-2 py-1 rounded-md","text-fg-muted hover:text-fg-primary hover:bg-surface/60","transition-all duration-150"),title:"Add room server",children:e.jsx(us,{className:"w-4 h-4"})}):null;return s.length<=1?r:s.length<=3?e.jsxs("div",{className:"flex items-center gap-0.5 p-0.5 rounded-lg bg-subtle-fill",children:[s.map(n=>e.jsx("button",{onClick:()=>l(n.room_name),className:L("px-3 py-1 rounded-md text-sm font-medium transition-all duration-150",n.room_name===t?"bg-surface text-fg-primary shadow-sm":"text-fg-muted hover:text-fg-secondary"),children:n.room_name},n.room_name)),r]}):e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(cs,{value:t??"",onChange:l,children:s.map(n=>e.jsx(ds,{value:n.room_name,children:e.jsx(ms,{children:n.room_name})},n.room_name))}),r]})}function Es(s){if(!s)return"";const t=s.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");return t?`${t}-room`:""}function ye({open:s,onClose:t,mode:l,identity:a,repeaterConfig:r,onCreate:n,onUpdate:c,onDelete:m,onSendAdvert:d}){var te,ae,ne,re,le,oe,ie,ce,de;const i=l==="edit"&&a,u=`${s}-${(a==null?void 0:a.name)??""}-${l}`,[x,f]=o.useState(""),[j,y]=o.useState(""),[g,E]=o.useState(!1),[C,S]=o.useState(""),[b,_]=o.useState(""),[N,M]=o.useState(""),[k,R]=o.useState(""),[w,P]=o.useState(!1),[D,A]=o.useState(!1),[O,$]=o.useState(!1),[K,T]=o.useState(null),[q,h]=o.useState(u);if(u!==q)if(h(u),T(null),P(!1),A(!1),$(!1),i)f(((te=a.settings)==null?void 0:te.node_name)??a.name),y(a.identity_key??""),E(!1),S(((ae=a.settings)==null?void 0:ae.admin_password)??""),_(((ne=a.settings)==null?void 0:ne.guest_password)??""),M(((le=(re=a.settings)==null?void 0:re.latitude)==null?void 0:le.toString())??""),R(((ie=(oe=a.settings)==null?void 0:oe.longitude)==null?void 0:ie.toString())??"");else{const p=r;f(""),y(""),E(!1),S(""),_(""),M(((ce=p==null?void 0:p.repeater)==null?void 0:ce.latitude)!=null?p.repeater.latitude.toString():""),R(((de=p==null?void 0:p.repeater)==null?void 0:de.longitude)!=null?p.repeater.longitude.toString():"")}const v=o.useCallback(()=>{const p={};return x&&(p.node_name=x),C&&(p.admin_password=C),b&&(p.guest_password=b),N!==""&&(p.latitude=parseFloat(N)),k!==""&&(p.longitude=parseFloat(k)),p},[x,C,b,N,k]),De=o.useCallback(async()=>{if(!x.trim()){T("Room name is required");return}P(!0),T(null);const p=i?a.name:Es(x);let Q;if(i)Q=await c({name:a.name,settings:v()});else{const me={name:p,type:"room_server",settings:v()};j.trim()&&(me.identity_key=j.trim()),Q=await n(me)}P(!1),Q?t():T("Failed to save. Check that the name is unique and passwords differ.")},[x,i,a,v,n,c,t]),Ae=o.useCallback(async()=>{if(!i)return;A(!0);const p=await m(a.name);A(!1),p&&t()},[i,a,m,t]),$e=o.useCallback(async()=>{i&&($(!0),await d(a.name),$(!1))},[i,a,d]);return e.jsxs(Be,{open:s,onClose:t,size:"md",children:[e.jsx(ze,{icon:i?void 0:e.jsx(bs,{className:"w-5 h-5"}),title:i?"Edit Room Server":"Add Room Server",onClose:t}),e.jsx(He,{children:e.jsxs("div",{className:"space-y-5",children:[i&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{color:a.registered?"green":"red",children:a.registered?"Active":"Inactive"}),a.identity_key&&e.jsxs("span",{className:"type-data-xs text-fg-muted truncate",title:a.identity_key,children:["Key: ",a.identity_key.slice(0,16),"…"]})]}),e.jsxs(z,{children:[e.jsx(H,{title:"What people see on the mesh",children:"Room Name"}),e.jsx(B,{value:x,onChange:p=>f(p.target.value),placeholder:"Room Name"})]}),!i&&e.jsxs(z,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(H,{title:"The unique hex public ID",children:["Identity Key ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(Optional)"})]}),e.jsx("button",{type:"button",onClick:()=>E(p=>!p),className:"type-data-xs text-fg-muted underline hover:text-fg-secondary",children:g?"Hide":"Show"})]}),g&&e.jsxs(e.Fragment,{children:[e.jsx(B,{value:j,onChange:p=>y(p.target.value),placeholder:"Leave empty to auto-generate"}),e.jsx(Ms,{children:"Leave empty to automatically generate a secure key"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs(z,{children:[e.jsxs(H,{children:[e.jsx(X,{className:"inline w-3.5 h-3.5 -mt-0.5 mr-1 text-fg-muted"}),"Latitude"]}),e.jsx(B,{type:"number",step:"any",value:N,onChange:p=>M(p.target.value),placeholder:"0"})]}),e.jsxs(z,{children:[e.jsxs(H,{children:[e.jsx(X,{className:"inline w-3.5 h-3.5 -mt-0.5 mr-1 text-fg-muted"}),"Longitude"]}),e.jsx(B,{type:"number",step:"any",value:k,onChange:p=>R(p.target.value),placeholder:"0"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs(z,{children:[e.jsxs(H,{title:"Full access to room server",children:["Admin Password ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(Optional)"})]}),e.jsx(B,{type:"password",value:C,onChange:p=>S(p.target.value),placeholder:"None Set"})]}),e.jsxs(z,{children:[e.jsxs(H,{title:"Can post and read, but not administer the room",children:["Guest Password ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(Optional)"})]}),e.jsx(B,{type:"password",value:b,onChange:p=>_(p.target.value),placeholder:"None Set"})]})]}),K&&e.jsx("p",{className:"type-data-xs text-sys-red",children:K})]})}),e.jsxs(Ue,{children:[i&&e.jsxs("div",{className:"flex items-center gap-2 mr-auto",children:[e.jsxs(F,{color:"danger",plain:!0,onClick:Ae,disabled:D,children:[e.jsx(Le,{"data-slot":"icon"}),D?"Deleting…":"Delete"]}),e.jsxs(F,{color:"primary",plain:!0,onClick:$e,disabled:O,children:[e.jsx(Me,{"data-slot":"icon"}),O?"Sending…":"Send Advert"]})]}),e.jsx(F,{plain:!0,onClick:t,children:"Cancel"}),e.jsx(F,{color:"primary",onClick:De,disabled:w,children:w?"Saving…":i?"Save Changes":"Create"})]})]})}const Pe=o.createContext(null),Ne="room-tui";function be({children:s}){const[t,l]=o.useState(()=>localStorage.getItem(Ne)!=="0"),a=o.useCallback(()=>{l(r=>{const n=!r;return localStorage.setItem(Ne,n?"1":"0"),n})},[]);return e.jsx(Pe.Provider,{value:{terminalMode:t,toggleTerminalMode:a},children:s})}function J(){const s=o.useContext(Pe);if(!s)throw new Error("useTerminalMode must be used within RoomTerminalProvider");return s}const ke=s=>s.author_pubkey==="server"||s.author_pubkey==="system";function we({messages:s,onDelete:t,terminalMode:l,serverName:a}){const r=o.useRef(null),[n,c]=o.useState(!1),m=o.useMemo(()=>[...s].sort((u,x)=>u.post_timestamp-x.post_timestamp),[s]);o.useEffect(()=>{!n&&r.current&&(r.current.scrollTop=0)},[m.length,n]);const d=o.useCallback(()=>{r.current&&c(r.current.scrollTop<-100)},[]),i=o.useCallback(()=>{r.current&&r.current.scrollTo({top:0,behavior:"smooth"}),c(!1)},[]);return m.length===0?e.jsx("div",{className:`flex-1 flex flex-col items-center justify-center py-12 min-h-0${l?" font-mono":""}`,children:l?e.jsx("p",{className:"text-sm font-mono",style:{color:"var(--tui-accent)",opacity:.4},children:"> no messages in buffer_"}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{className:"w-10 h-10 text-fg-muted opacity-20 mb-2"}),e.jsx("p",{className:"type-data-sm text-fg-muted",children:"No messages yet"})]})}):l?e.jsxs("div",{className:"relative flex-1 min-h-0",children:[e.jsx("div",{ref:r,onScroll:d,className:"h-full overflow-y-auto scroll-smooth p-4 font-mono text-sm leading-relaxed flex flex-col-reverse",children:e.jsx("div",{children:m.map(u=>{const x=ke(u),f=new Date(u.post_timestamp*1e3).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),j=x?"SYS":u.author_name||u.author_prefix,y=!x&&a&&j===a;return e.jsxs("div",{className:"group flex items-start gap-0 -mx-4 px-4 py-px",style:{"--tw-hover-bg":"var(--tui-hover-bg)"},onMouseEnter:g=>g.currentTarget.style.background="var(--tui-hover-bg)",onMouseLeave:g=>g.currentTarget.style.background="",children:[e.jsxs("span",{className:"select-none shrink-0",style:{color:"var(--tui-muted)"},children:["[",f,"]"]}),e.jsxs("span",{className:"mx-1.5 shrink-0",style:{color:y?"var(--tui-accent-local)":"var(--tui-accent)"},children:["<",j,">"]}),e.jsx("span",{style:{color:x?"var(--tui-system)":y?"var(--tui-body)":"var(--tui-accent)"},className:x?"italic":"",children:u.message_text}),e.jsx("button",{onClick:()=>t(u.id),className:"opacity-0 group-hover:opacity-100 ml-auto pl-2 shrink-0 transition-colors",style:{color:"var(--tui-muted)"},onMouseEnter:g=>g.currentTarget.style.color="var(--tui-danger)",onMouseLeave:g=>g.currentTarget.style.color="var(--tui-muted)",title:"Delete",children:"×"})]},u.id)})})}),n&&e.jsxs("button",{onClick:i,className:"absolute bottom-3 left-1/2 -translate-x-1/2 flex items-center gap-1.5 px-3 py-1 font-mono text-xs transition-colors duration-150",style:{background:"var(--tui-hover-bg)",border:"1px solid var(--tui-muted)",color:"var(--tui-accent)"},children:[e.jsx(ue,{className:"w-3 h-3"}),"↓ scroll"]})]}):e.jsxs("div",{className:"relative flex-1 min-h-0",children:[e.jsx("div",{ref:r,onScroll:d,className:"h-full overflow-y-auto scroll-smooth flex flex-col-reverse",children:e.jsx("div",{className:"space-y-3 p-4",children:m.map(u=>ke(u)?e.jsx(xs,{text:u.message_text},u.id):e.jsx(ps,{senderName:u.author_name||u.author_prefix,text:u.message_text,timestamp:u.post_timestamp,bubbleAccessory:e.jsx("button",{onClick:()=>t(u.id),className:"opacity-0 group-hover:opacity-100 transition-opacity duration-150 p-1 text-fg-muted hover:text-sys-red flex-shrink-0",title:"Delete message",children:e.jsx(Le,{className:"w-3.5 h-3.5"})})},u.id))})}),n&&e.jsxs("button",{onClick:i,className:"absolute bottom-3 left-1/2 -translate-x-1/2 flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-surface/90 backdrop-blur-sm ring-1 ring-edge-subtle shadow-md text-fg-secondary hover:text-fg-primary transition-colors duration-150",children:[e.jsx(ue,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-data-xs",children:"New messages"})]})]})}function Ce({roomName:s,onSend:t,disabled:l,terminalMode:a}){const[r,n]=o.useState(""),[c,m]=o.useState(!1),d=o.useRef(null),i=o.useCallback(async()=>{var j;const x=r.trim();if(!x||c)return;m(!0);const f=await t(x);m(!1),f&&(n(""),(j=d.current)==null||j.focus())},[r,c,t]),u=o.useCallback(x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),i())},[i]);return a?e.jsxs("div",{className:"flex items-center gap-0 px-4 py-2 type-data-sm",children:[e.jsx("input",{ref:d,type:"text",value:r,onChange:x=>n(x.target.value),onKeyDown:u,placeholder:"type message...",disabled:l||c,className:"flex-1 bg-transparent outline-none ring-0 shadow-none border-none focus:outline-none focus:ring-0 font-mono tui-input",style:{color:"var(--tui-body)"}}),e.jsx("button",{onClick:i,disabled:!r.trim()||c||l,className:"transition-colors duration-100 px-1 font-mono text-xs disabled:opacity-30",style:{color:"var(--tui-accent)"},title:"Send",children:"[↵]"})]}):e.jsxs("div",{className:"flex items-center gap-2 p-3 border-t border-edge-subtle",children:[e.jsx("input",{ref:d,type:"text",value:r,onChange:x=>n(x.target.value),onKeyDown:u,placeholder:`Message ${s}…`,disabled:l||c,className:"flex-1 surface-input radius-inner px-3 py-2 type-body-sm text-fg-primary placeholder:text-fg-muted outline-none ring-focus"}),e.jsx("button",{onClick:i,disabled:!r.trim()||c||l,className:"p-2 rounded-lg text-sys-blue hover:bg-sys-blue/10 disabled:opacity-30 disabled:hover:bg-transparent transition-colors duration-150",title:"Send message",children:e.jsx(Me,{className:"w-4.5 h-4.5"})})]})}function Ps({selectedName:s,selectedIdentity:t,messages:l,onSend:a,onDelete:r,onClear:n}){var f;const{terminalMode:c,toggleTerminalMode:m}=J(),[d,i]=o.useState(!1),u=((f=t==null?void 0:t.settings)==null?void 0:f.node_name)??s??void 0,x=o.useCallback(()=>{i(!1),n()},[n]);return c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[e.jsxs("div",{className:"card-terminal-header flex-shrink-0",children:[e.jsx("span",{className:"seven-seg-panel",children:e.jsx(Z,{text:"chat",minChars:7,size:24})}),e.jsx("div",{className:"card-terminal-ridge flex-1"}),e.jsxs("div",{className:"header-well",children:[e.jsx(I,{icon:e.jsx(je,{className:"!w-5.5 !h-5.5 translate-y-px"}),onClick:m,title:"Exit terminal mode"}),l.length>0&&e.jsx(I,{icon:e.jsx("span",{className:"text-[13px] font-bold font-mono leading-none translate-y-px",children:"DEL"}),onClick:()=>i(!0),title:"Clear all messages",variant:"red",iconActiveColor:Ve.red})]})]}),e.jsx(U,{noPadding:!0,className:"flex flex-col flex-1 min-h-0 overflow-hidden card-terminal",children:e.jsxs("div",{className:"card-terminal-well flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsx(we,{messages:l,onDelete:r,terminalMode:!0,serverName:u}),e.jsx("div",{className:"card-terminal-divider"}),s&&e.jsx(Ce,{roomName:s,onSend:a,disabled:!(t!=null&&t.registered),terminalMode:!0})]})})]}),e.jsx(fe,{isOpen:d,title:"Clear All Messages",message:`This will permanently delete all ${l.length} message${l.length===1?"":"s"} from this room. This cannot be undone.`,confirmLabel:"Clear Messages",variant:"danger",onConfirm:x,onCancel:()=>i(!1)})]}):e.jsxs(e.Fragment,{children:[e.jsxs(U,{noPadding:!0,className:"flex flex-col h-full overflow-hidden",children:[e.jsx(se,{listHeader:!0,icon:e.jsx(Ee,{className:"icon-sm"}),title:"Messages",actions:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(F,{plain:!0,onClick:m,title:"Terminal mode",children:e.jsx(je,{"data-slot":"icon",className:"!w-5 !h-5 translate-y-px"})}),l.length>0&&e.jsx(F,{plain:!0,onClick:()=>i(!0),title:"Clear all messages",children:e.jsx("span",{"data-slot":"icon",className:"text-[12px] font-bold font-mono leading-none translate-y-px text-sys-red",children:"DEL"})})]})}),e.jsx(we,{messages:l,onDelete:r,terminalMode:!1,serverName:u}),s&&e.jsx(Ce,{roomName:s,onSend:a,disabled:!(t!=null&&t.registered),terminalMode:!1})]}),e.jsx(fe,{isOpen:d,title:"Clear All Messages",message:`This will permanently delete all ${l.length} message${l.length===1?"":"s"} from this room. This cannot be undone.`,confirmLabel:"Clear Messages",variant:"danger",onConfirm:x,onCancel:()=>i(!1)})]})}function Ds({pubkey:s,className:t}){const[l,a]=o.useState(!1),r=o.useCallback(()=>{navigator.clipboard.writeText(s),a(!0),setTimeout(()=>a(!1),1500)},[s]);return e.jsxs("button",{onClick:r,title:l?"Copied!":"Copy public key",className:`inline-flex items-center gap-1 type-data-xs leading-tight text-fg-muted hover:text-fg-secondary transition-colors duration-150 cursor-copy ${t??""}`,children:[e.jsx("span",{className:"truncate min-w-0",children:s.slice(0,8)}),l&&e.jsx(G,{className:"w-2.5 h-2.5 text-sys-green flex-shrink-0"})]})}const As=o.memo(function({client:t,resolvedName:l,onRemove:a}){const r=t.name||l,n=t.unsynced_count===0,c=t.last_activity?new Date(t.last_activity*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"Never",{emoji:m,cleanName:d}=r?gs(r):{emoji:null,cleanName:t.pubkey_prefix},i=r?fs(d):void 0,u=r?js(r):t.pubkey_prefix.slice(0,2).toUpperCase();return e.jsxs("div",{className:"group flex items-center gap-3 px-3 py-2.5 radius-inner row-hover transition-base",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx("div",{className:L("w-8 h-8 rounded-full flex items-center justify-center",!i&&"bg-sys-blue/12"),style:i?{backgroundColor:i}:void 0,children:m?e.jsx("span",{className:"text-base leading-none",children:m}):e.jsx("span",{className:L("leading-none",i?"text-white text-[11px] font-bold tracking-tight":"text-sys-blue font-mono text-[11px]"),children:u})}),e.jsx("span",{className:`absolute -bottom-0.5 -right-0.5 w-2.5 h-2.5 rounded-sm ring-2 ring-surface ${n?"bg-sys-green":"bg-sys-indigo"}`})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[r?e.jsx("p",{className:"text-[13px] font-medium leading-tight text-fg-primary truncate",children:r}):e.jsx("p",{className:"font-mono text-[13px] leading-tight text-fg-primary truncate",children:t.pubkey_prefix}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[r&&e.jsx(Ds,{pubkey:t.pubkey}),r&&e.jsx("span",{className:"text-xs text-fg-muted/40",children:"·"}),e.jsxs("span",{className:"text-xs leading-tight text-fg-muted truncate",children:[!n&&e.jsxs("span",{className:"text-sys-indigo",children:[t.unsynced_count," unsynced · "]}),c]})]})]}),e.jsx("button",{onClick:()=>a(t.pubkey),className:"opacity-0 group-hover:opacity-100 transition-opacity duration-150 p-1.5 -mr-1 rounded-md text-fg-muted hover:text-sys-red hover:bg-sys-red/8",title:"Remove client",children:e.jsx(_s,{className:"w-3.5 h-3.5"})})]})});function Se({clients:s,onRemove:t,messages:l,terminalMode:a}){const r=o.useMemo(()=>{const n=new Map;if(!l)return n;for(let c=l.length-1;c>=0;c--){const m=l[c];m.author_name&&m.author_pubkey&&m.author_pubkey!=="server"&&m.author_pubkey!=="system"&&n.set(m.author_pubkey,m.author_name)}return n},[l]);return s.length===0?a?e.jsx("p",{className:"type-data-sm text-left px-4 py-4",style:{color:"var(--tui-accent)"},children:"< NO CLIENTS CONNECTED >"}):e.jsx("p",{className:"type-data-xs text-fg-muted text-center py-4",children:"No clients connected"}):a?e.jsx("div",{className:"type-data-sm pt-2",children:s.map(n=>{const c=n.name||r.get(n.pubkey),m=n.unsynced_count===0,d=n.pubkey_prefix;return e.jsxs("div",{className:"group flex items-center gap-0 -mx-0 px-4 py-0.5",onMouseEnter:i=>i.currentTarget.style.background="var(--tui-hover-bg)",onMouseLeave:i=>i.currentTarget.style.background="",children:[e.jsx("span",{style:{color:m?"var(--tui-accent)":"var(--tui-warn)"},children:"■"}),e.jsx("span",{className:"ml-2 shrink-0",style:{color:"var(--tui-accent)"},children:c||d}),c&&e.jsxs("span",{className:"ml-1.5 shrink-0",style:{color:"var(--tui-accent)"},children:["[",d,"]"]}),!m&&e.jsxs("span",{className:"ml-1.5",style:{color:"var(--tui-warn)"},children:[n.unsynced_count,"unsync"]}),e.jsx("button",{onClick:()=>t(n.pubkey),className:"opacity-0 group-hover:opacity-100 ml-auto pl-2 shrink-0 transition-colors",style:{color:"var(--tui-muted)"},onMouseEnter:i=>i.currentTarget.style.color="var(--tui-danger)",onMouseLeave:i=>i.currentTarget.style.color="var(--tui-muted)",title:"Remove",children:"×"})]},n.pubkey)})}):e.jsx("div",{className:"space-y-0.5 pt-1",children:s.map(n=>e.jsx(As,{client:n,resolvedName:r.get(n.pubkey),onRemove:t},n.pubkey))})}function $s({name:s,onSend:t}){const{terminalMode:l}=J(),[a,r]=o.useState("idle"),n=o.useRef(),c=o.useCallback(async()=>{if(a==="sending")return;r("sending");const m=await t(s);r(m?"sent":"idle"),m&&(n.current=setTimeout(()=>r("idle"),2e3))},[s,t,a]);return o.useEffect(()=>()=>clearTimeout(n.current),[]),l?e.jsxs("button",{className:"btn-terminal",onClick:c,disabled:a==="sending",children:[a==="idle"&&"[ send_advert ]",a==="sending"&&"[ broadcasting... ]",a==="sent"&&"[ sent ✓ ]"]}):e.jsxs(F,{color:a==="sent"?"success":"primary",className:"w-full",onClick:c,disabled:a==="sending",children:[e.jsx(ee,{"data-slot":"icon"}),a==="idle"&&"Send Advert",a==="sending"&&"Broadcasting…",a==="sent"&&"Advert Sent"]})}function _e({identity:s,onSendAdvert:t}){var c,m,d,i,u,x,f,j,y,g,E,C,S,b,_,N,M,k,R,w,P,D,A,O,$,K,T,q,h,v;const{terminalMode:l}=J(),[a,r]=o.useState(!1),n=o.useCallback(()=>{s!=null&&s.identity_key&&(navigator.clipboard.writeText(s.identity_key),r(!0),setTimeout(()=>r(!1),1500))},[s==null?void 0:s.identity_key]);return l?s?e.jsxs("div",{className:"space-y-1",children:[((c=s.settings)==null?void 0:c.node_name)&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"node"}),e.jsx("span",{style:{color:"var(--tui-accent)"},children:s.settings.node_name})]}),(s.address||((m=s.runtime)==null?void 0:m.address))&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"addr"}),e.jsx("span",{style:{color:"var(--tui-accent)"},children:s.address||((d=s.runtime)==null?void 0:d.address)})]}),s.identity_key&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"key"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"truncate max-w-[140px]",style:{color:"var(--tui-accent)"},title:s.identity_key,children:[s.identity_key.slice(0,16),"…"]}),e.jsx("button",{type:"button",onClick:n,className:"text-xs",style:{color:"var(--tui-muted)"},children:a?"[copied ✓]":"[copy]"})]})]}),(((i=s.settings)==null?void 0:i.latitude)!=null||((u=s.settings)==null?void 0:u.longitude)!=null)&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"loc"}),e.jsxs("span",{style:{color:"var(--tui-accent)"},title:`${((x=s.settings)==null?void 0:x.latitude)??"—"}, ${((f=s.settings)==null?void 0:f.longitude)??"—"}`,children:[((y=(j=s.settings)==null?void 0:j.latitude)==null?void 0:y.toFixed(4))??"—",", ",((E=(g=s.settings)==null?void 0:g.longitude)==null?void 0:E.toFixed(4))??"—"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"pass"}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{color:(C=s.settings)!=null&&C.admin_password?"var(--tui-accent)":"var(--tui-muted)"},children:(S=s.settings)!=null&&S.admin_password?"[✓ admin]":"[— admin]"}),e.jsx("span",{style:{color:(b=s.settings)!=null&&b.guest_password?"var(--tui-accent)":"var(--tui-muted)"},children:(_=s.settings)!=null&&_.guest_password?"[✓ guest]":"[— guest]"})]})]})]}):e.jsx("span",{style:{color:"var(--tui-muted)"},children:"no identity configured"}):e.jsxs("div",{className:"flex-shrink-0 border-t border-edge-subtle",children:[e.jsx(se,{listHeader:!0,icon:e.jsx(hs,{className:"icon-sm"}),title:"Room Info"}),s?e.jsxs("div",{className:"space-y-2 px-4 py-3",children:[((N=s.settings)==null?void 0:N.node_name)&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-data-xs text-fg-muted",children:"Node"}),e.jsx("span",{className:"type-data-sm text-fg-primary",children:s.settings.node_name})]}),(s.address||((M=s.runtime)==null?void 0:M.address))&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-data-xs text-fg-muted",children:"Address"}),e.jsx("span",{className:"type-data-sm font-mono text-fg-primary",children:s.address||((k=s.runtime)==null?void 0:k.address)})]}),s.identity_key&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"type-data-xs text-fg-muted flex items-center gap-1",title:"The unique hex public ID",children:[e.jsx(vs,{className:"w-3 h-3"}),"Key"]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"type-data-sm font-mono text-fg-primary truncate max-w-[140px]",title:s.identity_key,children:[s.identity_key.slice(0,16),"…"]}),e.jsx("button",{type:"button",onClick:n,className:"inline-flex items-center gap-0.5",children:e.jsx(W,{color:a?"green":"zinc",children:a?e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"w-3 h-3"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(We,{className:"w-3 h-3"}),"Copy"]})})})]})]}),(((R=s.settings)==null?void 0:R.latitude)!=null||((w=s.settings)==null?void 0:w.longitude)!=null)&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"type-data-xs text-fg-muted flex items-center gap-1",children:[e.jsx(X,{className:"w-3 h-3"}),"Location"]}),e.jsxs("span",{className:"type-data-sm font-mono text-fg-primary",title:`${((P=s.settings)==null?void 0:P.latitude)??"—"}, ${((D=s.settings)==null?void 0:D.longitude)??"—"}`,children:[((O=(A=s.settings)==null?void 0:A.latitude)==null?void 0:O.toFixed(4))??"—",", ",((K=($=s.settings)==null?void 0:$.longitude)==null?void 0:K.toFixed(4))??"—"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-data-xs text-fg-muted",children:"Passwords"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(W,{color:(T=s.settings)!=null&&T.admin_password?"green":"zinc",children:[((q=s.settings)==null?void 0:q.admin_password)&&e.jsx(G,{className:"w-3 h-3"}),"Admin"]}),e.jsxs(W,{color:(h=s.settings)!=null&&h.guest_password?"green":"zinc",children:[((v=s.settings)==null?void 0:v.guest_password)&&e.jsx(G,{className:"w-3 h-3"}),"Guest"]})]})]}),e.jsx("div",{className:"pt-3",children:e.jsx($s,{name:s.name,onSend:t})})]}):e.jsx("p",{className:"type-data-xs text-fg-muted text-center py-3",children:"No identity configured"})]})}function Ks({selectedIdentity:s,clients:t,messages:l,onSendAdvert:a}){const{terminalMode:r}=J(),n=o.useCallback(async c=>{Re.setState(m=>({clients:m.clients.filter(d=>d.pubkey!==c)})),await Ge({public_key:c})},[]);return r?e.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[s&&e.jsx("div",{className:"hidden lg:block",children:e.jsx("div",{className:"card-terminal-header flex-shrink-0",children:e.jsx("div",{className:"header-well flex-1",children:e.jsx(I,{icon:e.jsx(ee,{}),onPress:()=>a(s.name),title:"Send room server advert",indicators:[{label:"ADVERTISE",trackPress:!0},{label:"ACTIVE",active:s.registered}]})})})}),e.jsxs("div",{className:"flex flex-col flex-1 min-h-0 gap-1.5",children:[e.jsx("div",{className:"card-terminal-header flex-shrink-0",children:e.jsx("span",{className:"seven-seg-panel",children:e.jsx(Z,{text:`OnLInE ${String(t.length).padStart(3,"0")}`,size:24})})}),e.jsx(U,{noPadding:!0,className:"!h-auto flex flex-col flex-1 min-h-0 overflow-hidden card-terminal",children:e.jsx("div",{className:"card-terminal-well flex-1 min-h-0 overflow-y-auto",children:e.jsx(Se,{clients:t,onRemove:n,messages:l,terminalMode:!0})})}),e.jsxs("div",{className:"card-terminal-header flex-shrink-0",children:[e.jsx("span",{className:"seven-seg-panel",children:e.jsx(Z,{text:`StAtUS ${s!=null&&s.registered?"On":"OFF"}`,size:24})}),s&&e.jsx("div",{className:"lg:hidden flex-1 flex min-w-0",children:e.jsx("div",{className:"header-well flex-1 !flex-shrink",children:e.jsx(I,{icon:e.jsx(ee,{}),onPress:()=>a(s.name),title:"Send room server advert",className:"flex-row-reverse",indicators:[{label:"ACTIVE",active:s.registered},{label:"ADVERTISE",trackPress:!0}]})})})]}),e.jsx(U,{noPadding:!0,className:"!h-auto flex-shrink-0 overflow-hidden card-terminal",children:e.jsx("div",{className:"card-terminal-well px-4 py-3 type-data-sm",children:e.jsx(_e,{identity:s,onSendAdvert:a})})})]})]}):e.jsxs(U,{compact:!0,className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsx(se,{listHeader:!0,icon:e.jsx(Te,{className:"icon-sm"}),title:"Clients",actions:t.length>0?e.jsx("span",{className:"type-data-xs text-fg-muted",children:t.length}):void 0}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:e.jsx(Se,{clients:t,onRemove:n,messages:l,terminalMode:!1})}),e.jsx(_e,{identity:s,onSendAdvert:a})]})}function et(){const s=Ye(),t=Ie(),l=Je(),a=Qe(),r=Xe(),n=Ze(),c=es(),m=ss(),d=ts(),i=as(),u=o.useMemo(()=>(d==null?void 0:d.neighbors)??{},[d==null?void 0:d.neighbors]),x=Rs(u,i),f=o.useMemo(()=>n.map(h=>{if(h.name)return h;const v=x(h.pubkey);return v.name?{...h,name:v.name}:h}),[n,x]),j=o.useMemo(()=>r.map(h=>{if(h.author_name||h.author_pubkey==="server"||h.author_pubkey==="system")return h;const v=x(h.author_pubkey);return v.name?{...h,author_name:v.name}:h}),[r,x]),{selectRoom:y,postMessage:g,deleteMessage:E,clearMessages:C,createRoom:S,updateRoom:b,deleteRoom:_,sendAdvert:N,markAsRead:M,startActivePolling:k}=Re.getState(),[R,w]=o.useState(!1),[P,D]=o.useState("create"),[A,O]=o.useState("hybrid");o.useEffect(()=>{M()},[t,M]),o.useEffect(()=>k(),[k]);const $=o.useCallback(async h=>t?g({room_name:t,message:h,author_pubkey:"server"}):!1,[t,g]),K=o.useCallback((h="hybrid")=>{O(h),D("create"),w(!0)},[]),T=o.useCallback(()=>{D("edit"),w(!0)},[]),q=e.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-shrink-0",children:[l&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:`${l.total_messages} message${l.total_messages!==1?"s":""} in this room`,children:[e.jsx(Ee,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:l.total_messages})]}),e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:`${l.total_clients} client${l.total_clients!==1?"s":""} connected`,children:[e.jsx(Te,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:l.total_clients})]})]}),e.jsx(Ls,{rooms:s,selected:t,onSelect:y,onAdd:()=>K("hybrid")}),s.length>0&&e.jsx(F,{plain:!0,onClick:T,title:"Manage room server",children:e.jsx(ns,{"data-slot":"icon"})})]});return s.length===0&&c.length===0&&!m?e.jsx(be,{children:e.jsxs(pe,{children:[e.jsx(he,{title:"Room Server",icon:e.jsx(Y,{})}),e.jsx(Ts,{onCreateRoom:h=>K(h)}),e.jsx(ye,{open:R,onClose:()=>w(!1),mode:"create",repeaterConfig:d==null?void 0:d.config,onCreate:async h=>{const v=await S(h);return v&&A==="dedicated"&&(await xe.getState().setMode("monitor"),xe.getState().clearModeMutation()),v},onUpdate:b,onDelete:_,onSendAdvert:N})]})}):e.jsx(be,{children:e.jsxs(pe,{children:[e.jsx(he,{title:"Room Server",icon:e.jsx(Y,{}),controls:q}),e.jsx(rs,{children:e.jsxs(ls,{template:"hero-tall",className:"!h-[calc(100vh-11rem)] !min-h-[400px]",children:[e.jsx(ge,{span:12,lg:8,className:"h-full",children:e.jsx(Ps,{selectedName:t,selectedIdentity:a,messages:j,onSend:$,onDelete:E,onClear:C})}),e.jsx(ge,{span:12,lg:4,className:"h-full",children:e.jsx(Ks,{selectedIdentity:a,clients:f,messages:j,onSendAdvert:N})})]})}),e.jsx(ye,{open:R,onClose:()=>w(!1),mode:P,identity:a,repeaterConfig:d==null?void 0:d.config,onCreate:S,onUpdate:b,onDelete:_,onSendAdvert:N})]})})}export{et as default}; + */const Ss=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]],_s=V("user-x",Ss);function z({disabled:s,className:t,children:l}){return e.jsx(Ke,{disabled:s,className:L("flex flex-col gap-2",t),children:l})}function H({required:s,className:t,children:l,...a}){return e.jsxs(Fe,{className:L("text-sm font-medium text-fg-primary select-none","data-[disabled]:opacity-50",a.title&&"cursor-help",t),...a,children:[l,s&&e.jsx("span",{className:"text-sys-red ml-0.5","aria-hidden":"true",children:"*"})]})}function Ms({className:s,children:t,...l}){return e.jsx(Oe,{className:L("text-sm text-fg-muted","data-[disabled]:opacity-50",s),...l,children:t})}function Rs(s,t){return o.useMemo(()=>{const a=new Map;for(const[n,c]of Object.entries(s)){const m=c.name||c.node_name||null,{type:d}=os(c);a.set(n.toLowerCase(),{name:m,type:d})}const r=new Map;for(let n=t.length-1;n>=0;n--){const c=t[n];if(!c._advertSender)continue;const m=c._advertSender.toLowerCase();if(r.has(m))continue;const d=c._advertName??null,i=c._advertNodeType!=null?is(c._advertNodeType):"companion";r.set(m,{name:d,type:i})}return function(c){const m=c.toLowerCase(),d=a.get(m);if(d!=null&&d.name)return d;const i=r.get(m);return i!=null&&i.name?i:d||i||{name:null,type:"companion"}}},[s,t])}function ve({icon:s,title:t,description:l,onClick:a,accent:r}){return e.jsxs("button",{onClick:a,className:L("flex flex-col items-center gap-3 p-6 rounded-2xl text-center","ring-1 ring-edge-subtle hover:ring-2 transition-all duration-150","w-full max-w-[260px]",r==="primary"?"hover:ring-sys-blue hover:bg-sys-blue/5":"hover:ring-sys-indigo hover:bg-sys-indigo/5"),children:[e.jsx("div",{className:L("p-3 rounded-xl",r==="primary"?"bg-sys-blue/10 text-sys-blue":"bg-sys-indigo/10 text-sys-indigo"),children:s}),e.jsx("p",{className:"type-body-sm font-medium text-fg-primary",children:t}),e.jsx("p",{className:"type-data-xs text-fg-muted leading-relaxed",children:l})]})}function Ts({onCreateRoom:s}){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-4",children:[e.jsx(Y,{className:"w-12 h-12 text-fg-muted opacity-30 mb-4"}),e.jsx("p",{className:"type-subheading text-fg-secondary mb-1",children:"Add a Room Server"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-8",children:"Choose how this device should operate."}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-center gap-4",children:[e.jsx(ve,{icon:e.jsx(ws,{className:"w-6 h-6"}),title:"Repeater + Room Server",description:"Keep forwarding packets and add group messaging.",onClick:()=>s("hybrid"),accent:"primary"}),e.jsx(ve,{icon:e.jsx(qe,{className:"w-6 h-6"}),title:"Dedicated Room Server",description:"Stop repeating. Focus entirely on room server duties.",onClick:()=>s("dedicated"),accent:"secondary"})]})]})}function Ls({rooms:s,selected:t,onSelect:l,onAdd:a}){const r=a?e.jsx("button",{onClick:a,className:L("flex items-center justify-center px-2 py-1 rounded-md","text-fg-muted hover:text-fg-primary hover:bg-surface/60","transition-all duration-150"),title:"Add room server",children:e.jsx(us,{className:"w-4 h-4"})}):null;return s.length<=1?r:s.length<=3?e.jsxs("div",{className:"flex items-center gap-0.5 p-0.5 rounded-lg bg-subtle-fill",children:[s.map(n=>e.jsx("button",{onClick:()=>l(n.room_name),className:L("px-3 py-1 rounded-md text-sm font-medium transition-all duration-150",n.room_name===t?"bg-surface text-fg-primary shadow-sm":"text-fg-muted hover:text-fg-secondary"),children:n.room_name},n.room_name)),r]}):e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(cs,{value:t??"",onChange:l,children:s.map(n=>e.jsx(ds,{value:n.room_name,children:e.jsx(ms,{children:n.room_name})},n.room_name))}),r]})}function Es(s){if(!s)return"";const t=s.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");return t?`${t}-room`:""}function ye({open:s,onClose:t,mode:l,identity:a,repeaterConfig:r,onCreate:n,onUpdate:c,onDelete:m,onSendAdvert:d}){var te,ae,ne,re,le,oe,ie,ce,de;const i=l==="edit"&&a,u=`${s}-${(a==null?void 0:a.name)??""}-${l}`,[x,f]=o.useState(""),[j,y]=o.useState(""),[g,E]=o.useState(!1),[C,S]=o.useState(""),[b,_]=o.useState(""),[N,M]=o.useState(""),[k,R]=o.useState(""),[w,P]=o.useState(!1),[D,A]=o.useState(!1),[O,$]=o.useState(!1),[K,T]=o.useState(null),[q,h]=o.useState(u);if(u!==q)if(h(u),T(null),P(!1),A(!1),$(!1),i)f(((te=a.settings)==null?void 0:te.node_name)??a.name),y(a.identity_key??""),E(!1),S(((ae=a.settings)==null?void 0:ae.admin_password)??""),_(((ne=a.settings)==null?void 0:ne.guest_password)??""),M(((le=(re=a.settings)==null?void 0:re.latitude)==null?void 0:le.toString())??""),R(((ie=(oe=a.settings)==null?void 0:oe.longitude)==null?void 0:ie.toString())??"");else{const p=r;f(""),y(""),E(!1),S(""),_(""),M(((ce=p==null?void 0:p.repeater)==null?void 0:ce.latitude)!=null?p.repeater.latitude.toString():""),R(((de=p==null?void 0:p.repeater)==null?void 0:de.longitude)!=null?p.repeater.longitude.toString():"")}const v=o.useCallback(()=>{const p={};return x&&(p.node_name=x),C&&(p.admin_password=C),b&&(p.guest_password=b),N!==""&&(p.latitude=parseFloat(N)),k!==""&&(p.longitude=parseFloat(k)),p},[x,C,b,N,k]),De=o.useCallback(async()=>{if(!x.trim()){T("Room name is required");return}P(!0),T(null);const p=i?a.name:Es(x);let X;if(i)X=await c({name:a.name,settings:v()});else{const me={name:p,type:"room_server",settings:v()};j.trim()&&(me.identity_key=j.trim()),X=await n(me)}P(!1),X?t():T("Failed to save. Check that the name is unique and passwords differ.")},[x,i,a,v,n,c,t]),Ae=o.useCallback(async()=>{if(!i)return;A(!0);const p=await m(a.name);A(!1),p&&t()},[i,a,m,t]),$e=o.useCallback(async()=>{i&&($(!0),await d(a.name),$(!1))},[i,a,d]);return e.jsxs(Be,{open:s,onClose:t,size:"md",children:[e.jsx(ze,{icon:i?void 0:e.jsx(bs,{className:"w-5 h-5"}),title:i?"Edit Room Server":"Add Room Server",onClose:t}),e.jsx(He,{children:e.jsxs("div",{className:"space-y-5",children:[i&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{color:a.registered?"green":"red",children:a.registered?"Active":"Inactive"}),a.identity_key&&e.jsxs("span",{className:"type-data-xs text-fg-muted truncate",title:a.identity_key,children:["Key: ",a.identity_key.slice(0,16),"…"]})]}),e.jsxs(z,{children:[e.jsx(H,{title:"What people see on the mesh",children:"Room Name"}),e.jsx(B,{value:x,onChange:p=>f(p.target.value),placeholder:"Room Name"})]}),!i&&e.jsxs(z,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(H,{title:"The unique hex public ID",children:["Identity Key ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(Optional)"})]}),e.jsx("button",{type:"button",onClick:()=>E(p=>!p),className:"type-data-xs text-fg-muted underline hover:text-fg-secondary",children:g?"Hide":"Show"})]}),g&&e.jsxs(e.Fragment,{children:[e.jsx(B,{value:j,onChange:p=>y(p.target.value),placeholder:"Leave empty to auto-generate"}),e.jsx(Ms,{children:"Leave empty to automatically generate a secure key"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs(z,{children:[e.jsxs(H,{children:[e.jsx(Z,{className:"inline w-3.5 h-3.5 -mt-0.5 mr-1 text-fg-muted"}),"Latitude"]}),e.jsx(B,{type:"number",step:"any",value:N,onChange:p=>M(p.target.value),placeholder:"0"})]}),e.jsxs(z,{children:[e.jsxs(H,{children:[e.jsx(Z,{className:"inline w-3.5 h-3.5 -mt-0.5 mr-1 text-fg-muted"}),"Longitude"]}),e.jsx(B,{type:"number",step:"any",value:k,onChange:p=>R(p.target.value),placeholder:"0"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs(z,{children:[e.jsxs(H,{title:"Full access to room server",children:["Admin Password ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(Optional)"})]}),e.jsx(B,{type:"password",value:C,onChange:p=>S(p.target.value),placeholder:"None Set"})]}),e.jsxs(z,{children:[e.jsxs(H,{title:"Can post and read, but not administer the room",children:["Guest Password ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(Optional)"})]}),e.jsx(B,{type:"password",value:b,onChange:p=>_(p.target.value),placeholder:"None Set"})]})]}),K&&e.jsx("p",{className:"type-data-xs text-sys-red",children:K})]})}),e.jsxs(Ue,{children:[i&&e.jsxs("div",{className:"flex items-center gap-2 mr-auto",children:[e.jsxs(F,{color:"danger",plain:!0,onClick:Ae,disabled:D,children:[e.jsx(Le,{"data-slot":"icon"}),D?"Deleting…":"Delete"]}),e.jsxs(F,{color:"primary",plain:!0,onClick:$e,disabled:O,children:[e.jsx(Me,{"data-slot":"icon"}),O?"Sending…":"Send Advert"]})]}),e.jsx(F,{plain:!0,onClick:t,children:"Cancel"}),e.jsx(F,{color:"primary",onClick:De,disabled:w,children:w?"Saving…":i?"Save Changes":"Create"})]})]})}const Pe=o.createContext(null),Ne="room-tui";function be({children:s}){const[t,l]=o.useState(()=>localStorage.getItem(Ne)!=="0"),a=o.useCallback(()=>{l(r=>{const n=!r;return localStorage.setItem(Ne,n?"1":"0"),n})},[]);return e.jsx(Pe.Provider,{value:{terminalMode:t,toggleTerminalMode:a},children:s})}function Q(){const s=o.useContext(Pe);if(!s)throw new Error("useTerminalMode must be used within RoomTerminalProvider");return s}const ke=s=>s.author_pubkey==="server"||s.author_pubkey==="system";function we({messages:s,onDelete:t,terminalMode:l,serverName:a}){const r=o.useRef(null),[n,c]=o.useState(!1),m=o.useMemo(()=>[...s].sort((u,x)=>u.post_timestamp-x.post_timestamp),[s]);o.useEffect(()=>{!n&&r.current&&(r.current.scrollTop=0)},[m.length,n]);const d=o.useCallback(()=>{r.current&&c(r.current.scrollTop<-100)},[]),i=o.useCallback(()=>{r.current&&r.current.scrollTo({top:0,behavior:"smooth"}),c(!1)},[]);return m.length===0?e.jsx("div",{className:`flex-1 flex flex-col items-center justify-center py-12 min-h-0${l?" font-mono":""}`,children:l?e.jsx("p",{className:"text-sm font-mono",style:{color:"var(--tui-accent)",opacity:.4},children:"> no messages in buffer_"}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{className:"w-10 h-10 text-fg-muted opacity-20 mb-2"}),e.jsx("p",{className:"type-data-sm text-fg-muted",children:"No messages yet"})]})}):l?e.jsxs("div",{className:"relative flex-1 min-h-0",children:[e.jsx("div",{ref:r,onScroll:d,className:"h-full overflow-y-auto scroll-smooth p-4 font-mono text-sm leading-relaxed flex flex-col-reverse",children:e.jsx("div",{children:m.map(u=>{const x=ke(u),f=new Date(u.post_timestamp*1e3).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),j=x?"SYS":u.author_name||u.author_prefix,y=!x&&a&&j===a;return e.jsxs("div",{className:"group flex items-start gap-0 -mx-4 px-4 py-px",style:{"--tw-hover-bg":"var(--tui-hover-bg)"},onMouseEnter:g=>g.currentTarget.style.background="var(--tui-hover-bg)",onMouseLeave:g=>g.currentTarget.style.background="",children:[e.jsxs("span",{className:"select-none shrink-0",style:{color:"var(--tui-muted)"},children:["[",f,"]"]}),e.jsxs("span",{className:"mx-1.5 shrink-0",style:{color:y?"var(--tui-accent-local)":"var(--tui-accent)"},children:["<",j,">"]}),e.jsx("span",{style:{color:x?"var(--tui-system)":y?"var(--tui-body)":"var(--tui-accent)"},className:x?"italic":"",children:u.message_text}),e.jsx("button",{onClick:()=>t(u.id),className:"opacity-0 group-hover:opacity-100 ml-auto pl-2 shrink-0 transition-colors",style:{color:"var(--tui-muted)"},onMouseEnter:g=>g.currentTarget.style.color="var(--tui-danger)",onMouseLeave:g=>g.currentTarget.style.color="var(--tui-muted)",title:"Delete",children:"×"})]},u.id)})})}),n&&e.jsxs("button",{onClick:i,className:"absolute bottom-3 left-1/2 -translate-x-1/2 flex items-center gap-1.5 px-3 py-1 font-mono text-xs transition-colors duration-150",style:{background:"var(--tui-hover-bg)",border:"1px solid var(--tui-muted)",color:"var(--tui-accent)"},children:[e.jsx(ue,{className:"w-3 h-3"}),"↓ scroll"]})]}):e.jsxs("div",{className:"relative flex-1 min-h-0",children:[e.jsx("div",{ref:r,onScroll:d,className:"h-full overflow-y-auto scroll-smooth flex flex-col-reverse",children:e.jsx("div",{className:"space-y-3 p-4",children:m.map(u=>ke(u)?e.jsx(xs,{text:u.message_text},u.id):e.jsx(ps,{senderName:u.author_name||u.author_prefix,text:u.message_text,timestamp:u.post_timestamp,bubbleAccessory:e.jsx("button",{onClick:()=>t(u.id),className:"opacity-0 group-hover:opacity-100 transition-opacity duration-150 p-1 text-fg-muted hover:text-sys-red flex-shrink-0",title:"Delete message",children:e.jsx(Le,{className:"w-3.5 h-3.5"})})},u.id))})}),n&&e.jsxs("button",{onClick:i,className:"absolute bottom-3 left-1/2 -translate-x-1/2 flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-surface/90 backdrop-blur-sm ring-1 ring-edge-subtle shadow-md text-fg-secondary hover:text-fg-primary transition-colors duration-150",children:[e.jsx(ue,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-data-xs",children:"New messages"})]})]})}function Ce({roomName:s,onSend:t,disabled:l,terminalMode:a}){const[r,n]=o.useState(""),[c,m]=o.useState(!1),d=o.useRef(null),i=o.useCallback(async()=>{var j;const x=r.trim();if(!x||c)return;m(!0);const f=await t(x);m(!1),f&&(n(""),(j=d.current)==null||j.focus())},[r,c,t]),u=o.useCallback(x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),i())},[i]);return a?e.jsxs("div",{className:"flex items-center gap-0 px-4 py-2 type-data-sm",children:[e.jsx("input",{ref:d,type:"text",value:r,onChange:x=>n(x.target.value),onKeyDown:u,placeholder:"type message...",disabled:l||c,className:"flex-1 bg-transparent outline-none ring-0 shadow-none border-none focus:outline-none focus:ring-0 font-mono tui-input",style:{color:"var(--tui-body)"}}),e.jsx("button",{onClick:i,disabled:!r.trim()||c||l,className:"transition-colors duration-100 px-1 font-mono text-xs disabled:opacity-30",style:{color:"var(--tui-accent)"},title:"Send",children:"[↵]"})]}):e.jsxs("div",{className:"flex items-center gap-2 p-3 border-t border-edge-subtle",children:[e.jsx("input",{ref:d,type:"text",value:r,onChange:x=>n(x.target.value),onKeyDown:u,placeholder:`Message ${s}…`,disabled:l||c,className:"flex-1 surface-input radius-inner px-3 py-2 type-body-sm text-fg-primary placeholder:text-fg-muted outline-none ring-focus"}),e.jsx("button",{onClick:i,disabled:!r.trim()||c||l,className:"p-2 rounded-lg text-sys-blue hover:bg-sys-blue/10 disabled:opacity-30 disabled:hover:bg-transparent transition-colors duration-150",title:"Send message",children:e.jsx(Me,{className:"w-4.5 h-4.5"})})]})}function Ps({selectedName:s,selectedIdentity:t,messages:l,onSend:a,onDelete:r,onClear:n}){var f;const{terminalMode:c,toggleTerminalMode:m}=Q(),[d,i]=o.useState(!1),u=((f=t==null?void 0:t.settings)==null?void 0:f.node_name)??s??void 0,x=o.useCallback(()=>{i(!1),n()},[n]);return c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[e.jsxs("div",{className:"card-terminal-header flex-shrink-0",children:[e.jsx("span",{className:"seven-seg-panel",children:e.jsx(J,{text:"chat",minChars:7,size:24})}),e.jsx("div",{className:"card-terminal-ridge flex-1"}),e.jsxs("div",{className:"header-well",children:[e.jsx(I,{icon:e.jsx(je,{className:"!w-5.5 !h-5.5 translate-y-px"}),onClick:m,title:"Exit terminal mode"}),l.length>0&&e.jsx(I,{icon:e.jsx("span",{className:"text-[13px] font-bold font-mono leading-none translate-y-px",children:"DEL"}),onClick:()=>i(!0),title:"Clear all messages",variant:"red",iconActiveColor:Ve.red})]})]}),e.jsx(U,{noPadding:!0,className:"flex flex-col flex-1 min-h-0 overflow-hidden card-terminal",children:e.jsxs("div",{className:"card-terminal-well flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsx(we,{messages:l,onDelete:r,terminalMode:!0,serverName:u}),e.jsx("div",{className:"card-terminal-divider"}),s&&e.jsx(Ce,{roomName:s,onSend:a,disabled:!(t!=null&&t.registered),terminalMode:!0})]})})]}),e.jsx(fe,{isOpen:d,title:"Clear All Messages",message:`This will permanently delete all ${l.length} message${l.length===1?"":"s"} from this room. This cannot be undone.`,confirmLabel:"Clear Messages",variant:"danger",onConfirm:x,onCancel:()=>i(!1)})]}):e.jsxs(e.Fragment,{children:[e.jsxs(U,{noPadding:!0,className:"flex flex-col h-full overflow-hidden",children:[e.jsx(se,{listHeader:!0,icon:e.jsx(Ee,{className:"icon-sm"}),title:"Messages",actions:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(F,{plain:!0,onClick:m,title:"Terminal mode",children:e.jsx(je,{"data-slot":"icon",className:"!w-5 !h-5 translate-y-px"})}),l.length>0&&e.jsx(F,{plain:!0,onClick:()=>i(!0),title:"Clear all messages",children:e.jsx("span",{"data-slot":"icon",className:"text-[12px] font-bold font-mono leading-none translate-y-px text-sys-red",children:"DEL"})})]})}),e.jsx(we,{messages:l,onDelete:r,terminalMode:!1,serverName:u}),s&&e.jsx(Ce,{roomName:s,onSend:a,disabled:!(t!=null&&t.registered),terminalMode:!1})]}),e.jsx(fe,{isOpen:d,title:"Clear All Messages",message:`This will permanently delete all ${l.length} message${l.length===1?"":"s"} from this room. This cannot be undone.`,confirmLabel:"Clear Messages",variant:"danger",onConfirm:x,onCancel:()=>i(!1)})]})}function Ds({pubkey:s,className:t}){const[l,a]=o.useState(!1),r=o.useCallback(()=>{navigator.clipboard.writeText(s),a(!0),setTimeout(()=>a(!1),1500)},[s]);return e.jsxs("button",{onClick:r,title:l?"Copied!":"Copy public key",className:`inline-flex items-center gap-1 type-data-xs leading-tight text-fg-muted hover:text-fg-secondary transition-colors duration-150 cursor-copy ${t??""}`,children:[e.jsx("span",{className:"truncate min-w-0",children:s.slice(0,8)}),l&&e.jsx(G,{className:"w-2.5 h-2.5 text-sys-green flex-shrink-0"})]})}const As=o.memo(function({client:t,resolvedName:l,onRemove:a}){const r=t.name||l,n=t.unsynced_count===0,c=t.last_activity?new Date(t.last_activity*1e3).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"Never",{emoji:m,cleanName:d}=r?gs(r):{emoji:null,cleanName:t.pubkey_prefix},i=r?fs(d):void 0,u=r?js(r):t.pubkey_prefix.slice(0,2).toUpperCase();return e.jsxs("div",{className:"group flex items-center gap-3 px-3 py-2.5 radius-inner row-hover transition-base",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx("div",{className:L("w-8 h-8 rounded-full flex items-center justify-center",!i&&"bg-sys-blue/12"),style:i?{backgroundColor:i}:void 0,children:m?e.jsx("span",{className:"text-base leading-none",children:m}):e.jsx("span",{className:L("leading-none",i?"text-white text-[11px] font-bold tracking-tight":"text-sys-blue font-mono text-[11px]"),children:u})}),e.jsx("span",{className:`absolute -bottom-0.5 -right-0.5 w-2.5 h-2.5 rounded-sm ring-2 ring-surface ${n?"bg-sys-green":"bg-sys-indigo"}`})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[r?e.jsx("p",{className:"text-[13px] font-medium leading-tight text-fg-primary truncate",children:r}):e.jsx("p",{className:"font-mono text-[13px] leading-tight text-fg-primary truncate",children:t.pubkey_prefix}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[r&&e.jsx(Ds,{pubkey:t.pubkey}),r&&e.jsx("span",{className:"text-xs text-fg-muted/40",children:"·"}),e.jsxs("span",{className:"text-xs leading-tight text-fg-muted truncate",children:[!n&&e.jsxs("span",{className:"text-sys-indigo",children:[t.unsynced_count," unsynced · "]}),c]})]})]}),e.jsx("button",{onClick:()=>a(t.pubkey),className:"opacity-0 group-hover:opacity-100 transition-opacity duration-150 p-1.5 -mr-1 rounded-md text-fg-muted hover:text-sys-red hover:bg-sys-red/8",title:"Remove client",children:e.jsx(_s,{className:"w-3.5 h-3.5"})})]})});function Se({clients:s,onRemove:t,messages:l,terminalMode:a}){const r=o.useMemo(()=>{const n=new Map;if(!l)return n;for(let c=l.length-1;c>=0;c--){const m=l[c];m.author_name&&m.author_pubkey&&m.author_pubkey!=="server"&&m.author_pubkey!=="system"&&n.set(m.author_pubkey,m.author_name)}return n},[l]);return s.length===0?a?e.jsx("p",{className:"type-data-sm text-left px-4 py-4",style:{color:"var(--tui-accent)"},children:"< NO CLIENTS CONNECTED >"}):e.jsx("p",{className:"type-data-xs text-fg-muted text-center py-4",children:"No clients connected"}):a?e.jsx("div",{className:"type-data-sm pt-2",children:s.map(n=>{const c=n.name||r.get(n.pubkey),m=n.unsynced_count===0,d=n.pubkey_prefix;return e.jsxs("div",{className:"group flex items-center gap-0 -mx-0 px-4 py-0.5",onMouseEnter:i=>i.currentTarget.style.background="var(--tui-hover-bg)",onMouseLeave:i=>i.currentTarget.style.background="",children:[e.jsx("span",{style:{color:m?"var(--tui-accent)":"var(--tui-warn)"},children:"■"}),e.jsx("span",{className:"ml-2 shrink-0",style:{color:"var(--tui-accent)"},children:c||d}),c&&e.jsxs("span",{className:"ml-1.5 shrink-0",style:{color:"var(--tui-accent)"},children:["[",d,"]"]}),!m&&e.jsxs("span",{className:"ml-1.5",style:{color:"var(--tui-warn)"},children:[n.unsynced_count,"unsync"]}),e.jsx("button",{onClick:()=>t(n.pubkey),className:"opacity-0 group-hover:opacity-100 ml-auto pl-2 shrink-0 transition-colors",style:{color:"var(--tui-muted)"},onMouseEnter:i=>i.currentTarget.style.color="var(--tui-danger)",onMouseLeave:i=>i.currentTarget.style.color="var(--tui-muted)",title:"Remove",children:"×"})]},n.pubkey)})}):e.jsx("div",{className:"space-y-0.5 pt-1",children:s.map(n=>e.jsx(As,{client:n,resolvedName:r.get(n.pubkey),onRemove:t},n.pubkey))})}function $s({name:s,onSend:t}){const{terminalMode:l}=Q(),[a,r]=o.useState("idle"),n=o.useRef(),c=o.useCallback(async()=>{if(a==="sending")return;r("sending");const m=await t(s);r(m?"sent":"idle"),m&&(n.current=setTimeout(()=>r("idle"),2e3))},[s,t,a]);return o.useEffect(()=>()=>clearTimeout(n.current),[]),l?e.jsxs("button",{className:"btn-terminal",onClick:c,disabled:a==="sending",children:[a==="idle"&&"[ send_advert ]",a==="sending"&&"[ broadcasting... ]",a==="sent"&&"[ sent ✓ ]"]}):e.jsxs(F,{color:a==="sent"?"success":"primary",className:"w-full",onClick:c,disabled:a==="sending",children:[e.jsx(ee,{"data-slot":"icon"}),a==="idle"&&"Send Advert",a==="sending"&&"Broadcasting…",a==="sent"&&"Advert Sent"]})}function _e({identity:s,onSendAdvert:t}){var c,m,d,i,u,x,f,j,y,g,E,C,S,b,_,N,M,k,R,w,P,D,A,O,$,K,T,q,h,v;const{terminalMode:l}=Q(),[a,r]=o.useState(!1),n=o.useCallback(()=>{s!=null&&s.identity_key&&(navigator.clipboard.writeText(s.identity_key),r(!0),setTimeout(()=>r(!1),1500))},[s==null?void 0:s.identity_key]);return l?s?e.jsxs("div",{className:"space-y-1",children:[((c=s.settings)==null?void 0:c.node_name)&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"node"}),e.jsx("span",{style:{color:"var(--tui-accent)"},children:s.settings.node_name})]}),(s.address||((m=s.runtime)==null?void 0:m.address))&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"addr"}),e.jsx("span",{style:{color:"var(--tui-accent)"},children:s.address||((d=s.runtime)==null?void 0:d.address)})]}),s.identity_key&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"key"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"truncate max-w-[140px]",style:{color:"var(--tui-accent)"},title:s.identity_key,children:[s.identity_key.slice(0,16),"…"]}),e.jsx("button",{type:"button",onClick:n,className:"text-xs",style:{color:"var(--tui-muted)"},children:a?"[copied ✓]":"[copy]"})]})]}),(((i=s.settings)==null?void 0:i.latitude)!=null||((u=s.settings)==null?void 0:u.longitude)!=null)&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"loc"}),e.jsxs("span",{style:{color:"var(--tui-accent)"},title:`${((x=s.settings)==null?void 0:x.latitude)??"—"}, ${((f=s.settings)==null?void 0:f.longitude)??"—"}`,children:[((y=(j=s.settings)==null?void 0:j.latitude)==null?void 0:y.toFixed(4))??"—",", ",((E=(g=s.settings)==null?void 0:g.longitude)==null?void 0:E.toFixed(4))??"—"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{style:{color:"var(--tui-muted)"},children:"pass"}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{style:{color:(C=s.settings)!=null&&C.admin_password?"var(--tui-accent)":"var(--tui-muted)"},children:(S=s.settings)!=null&&S.admin_password?"[✓ admin]":"[— admin]"}),e.jsx("span",{style:{color:(b=s.settings)!=null&&b.guest_password?"var(--tui-accent)":"var(--tui-muted)"},children:(_=s.settings)!=null&&_.guest_password?"[✓ guest]":"[— guest]"})]})]})]}):e.jsx("span",{style:{color:"var(--tui-muted)"},children:"no identity configured"}):e.jsxs("div",{className:"flex-shrink-0 border-t border-edge-subtle",children:[e.jsx(se,{listHeader:!0,icon:e.jsx(hs,{className:"icon-sm"}),title:"Room Info"}),s?e.jsxs("div",{className:"space-y-2 px-4 py-3",children:[((N=s.settings)==null?void 0:N.node_name)&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-data-xs text-fg-muted",children:"Node"}),e.jsx("span",{className:"type-data-sm text-fg-primary",children:s.settings.node_name})]}),(s.address||((M=s.runtime)==null?void 0:M.address))&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-data-xs text-fg-muted",children:"Address"}),e.jsx("span",{className:"type-data-sm font-mono text-fg-primary",children:s.address||((k=s.runtime)==null?void 0:k.address)})]}),s.identity_key&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"type-data-xs text-fg-muted flex items-center gap-1",title:"The unique hex public ID",children:[e.jsx(vs,{className:"w-3 h-3"}),"Key"]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"type-data-sm font-mono text-fg-primary truncate max-w-[140px]",title:s.identity_key,children:[s.identity_key.slice(0,16),"…"]}),e.jsx("button",{type:"button",onClick:n,className:"inline-flex items-center gap-0.5",children:e.jsx(W,{color:a?"green":"zinc",children:a?e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"w-3 h-3"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(We,{className:"w-3 h-3"}),"Copy"]})})})]})]}),(((R=s.settings)==null?void 0:R.latitude)!=null||((w=s.settings)==null?void 0:w.longitude)!=null)&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"type-data-xs text-fg-muted flex items-center gap-1",children:[e.jsx(Z,{className:"w-3 h-3"}),"Location"]}),e.jsxs("span",{className:"type-data-sm font-mono text-fg-primary",title:`${((P=s.settings)==null?void 0:P.latitude)??"—"}, ${((D=s.settings)==null?void 0:D.longitude)??"—"}`,children:[((O=(A=s.settings)==null?void 0:A.latitude)==null?void 0:O.toFixed(4))??"—",", ",((K=($=s.settings)==null?void 0:$.longitude)==null?void 0:K.toFixed(4))??"—"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"type-data-xs text-fg-muted",children:"Passwords"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs(W,{color:(T=s.settings)!=null&&T.admin_password?"green":"zinc",children:[((q=s.settings)==null?void 0:q.admin_password)&&e.jsx(G,{className:"w-3 h-3"}),"Admin"]}),e.jsxs(W,{color:(h=s.settings)!=null&&h.guest_password?"green":"zinc",children:[((v=s.settings)==null?void 0:v.guest_password)&&e.jsx(G,{className:"w-3 h-3"}),"Guest"]})]})]}),e.jsx("div",{className:"pt-3",children:e.jsx($s,{name:s.name,onSend:t})})]}):e.jsx("p",{className:"type-data-xs text-fg-muted text-center py-3",children:"No identity configured"})]})}function Ks({selectedIdentity:s,clients:t,messages:l,onSendAdvert:a}){const{terminalMode:r}=Q(),n=o.useCallback(async c=>{Re.setState(m=>({clients:m.clients.filter(d=>d.pubkey!==c)})),await Ge({public_key:c})},[]);return r?e.jsxs("div",{className:"flex flex-col h-full gap-1.5",children:[s&&e.jsx("div",{className:"hidden lg:block",children:e.jsx("div",{className:"card-terminal-header flex-shrink-0",children:e.jsx("div",{className:"header-well flex-1",children:e.jsx(I,{icon:e.jsx(ee,{}),onPress:()=>a(s.name),title:"Send room server advert",indicators:[{label:"ADVERTISE",trackPress:!0},{label:"ACTIVE",active:s.registered}]})})})}),e.jsxs("div",{className:"flex flex-col flex-1 min-h-0 gap-1.5",children:[e.jsx("div",{className:"card-terminal-header flex-shrink-0",children:e.jsx("span",{className:"seven-seg-panel",children:e.jsx(J,{text:`OnLInE ${String(t.length).padStart(3,"0")}`,size:24})})}),e.jsx(U,{noPadding:!0,className:"!h-auto flex flex-col flex-1 min-h-0 overflow-hidden card-terminal",children:e.jsx("div",{className:"card-terminal-well flex-1 min-h-0 overflow-y-auto",children:e.jsx(Se,{clients:t,onRemove:n,messages:l,terminalMode:!0})})}),e.jsxs("div",{className:"card-terminal-header flex-shrink-0",children:[e.jsx("span",{className:"seven-seg-panel",children:e.jsx(J,{text:`StAtUS ${s!=null&&s.registered?"On":"OFF"}`,size:24})}),s&&e.jsx("div",{className:"lg:hidden flex-1 flex min-w-0",children:e.jsx("div",{className:"header-well flex-1 !flex-shrink",children:e.jsx(I,{icon:e.jsx(ee,{}),onPress:()=>a(s.name),title:"Send room server advert",className:"flex-row-reverse",indicators:[{label:"ACTIVE",active:s.registered},{label:"ADVERTISE",trackPress:!0}]})})})]}),e.jsx(U,{noPadding:!0,className:"!h-auto flex-shrink-0 overflow-hidden card-terminal",children:e.jsx("div",{className:"card-terminal-well px-4 py-3 type-data-sm",children:e.jsx(_e,{identity:s,onSendAdvert:a})})})]})]}):e.jsxs(U,{compact:!0,className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsx(se,{listHeader:!0,icon:e.jsx(Te,{className:"icon-sm"}),title:"Clients",actions:t.length>0?e.jsx("span",{className:"type-data-xs text-fg-muted",children:t.length}):void 0}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:e.jsx(Se,{clients:t,onRemove:n,messages:l,terminalMode:!1})}),e.jsx(_e,{identity:s,onSendAdvert:a})]})}function et(){const s=Ye(),t=Ie(),l=Qe(),a=Xe(),r=Ze(),n=Je(),c=es(),m=ss(),d=ts(),i=as(),u=o.useMemo(()=>(d==null?void 0:d.neighbors)??{},[d==null?void 0:d.neighbors]),x=Rs(u,i),f=o.useMemo(()=>n.map(h=>{if(h.name)return h;const v=x(h.pubkey);return v.name?{...h,name:v.name}:h}),[n,x]),j=o.useMemo(()=>r.map(h=>{if(h.author_name||h.author_pubkey==="server"||h.author_pubkey==="system")return h;const v=x(h.author_pubkey);return v.name?{...h,author_name:v.name}:h}),[r,x]),{selectRoom:y,postMessage:g,deleteMessage:E,clearMessages:C,createRoom:S,updateRoom:b,deleteRoom:_,sendAdvert:N,markAsRead:M,startActivePolling:k}=Re.getState(),[R,w]=o.useState(!1),[P,D]=o.useState("create"),[A,O]=o.useState("hybrid");o.useEffect(()=>{M()},[t,M]),o.useEffect(()=>k(),[k]);const $=o.useCallback(async h=>t?g({room_name:t,message:h,author_pubkey:"server"}):!1,[t,g]),K=o.useCallback((h="hybrid")=>{O(h),D("create"),w(!0)},[]),T=o.useCallback(()=>{D("edit"),w(!0)},[]),q=e.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-shrink-0",children:[l&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:`${l.total_messages} message${l.total_messages!==1?"s":""} in this room`,children:[e.jsx(Ee,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:l.total_messages})]}),e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:`${l.total_clients} client${l.total_clients!==1?"s":""} connected`,children:[e.jsx(Te,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:l.total_clients})]})]}),e.jsx(Ls,{rooms:s,selected:t,onSelect:y,onAdd:()=>K("hybrid")}),s.length>0&&e.jsx(F,{plain:!0,onClick:T,title:"Manage room server",children:e.jsx(ns,{"data-slot":"icon"})})]});return s.length===0&&c.length===0&&!m?e.jsx(be,{children:e.jsxs(pe,{children:[e.jsx(he,{title:"Room Server",icon:e.jsx(Y,{})}),e.jsx(Ts,{onCreateRoom:h=>K(h)}),e.jsx(ye,{open:R,onClose:()=>w(!1),mode:"create",repeaterConfig:d==null?void 0:d.config,onCreate:async h=>{const v=await S(h);return v&&A==="dedicated"&&(await xe.getState().setMode("monitor"),xe.getState().clearModeMutation()),v},onUpdate:b,onDelete:_,onSendAdvert:N})]})}):e.jsx(be,{children:e.jsxs(pe,{children:[e.jsx(he,{title:"Room Server",icon:e.jsx(Y,{}),controls:q}),e.jsx(rs,{children:e.jsxs(ls,{template:"hero-tall",className:"!h-[calc(100vh-11rem)] !min-h-[400px]",children:[e.jsx(ge,{span:12,lg:8,className:"h-full",children:e.jsx(Ps,{selectedName:t,selectedIdentity:a,messages:j,onSend:$,onDelete:E,onClear:C})}),e.jsx(ge,{span:12,lg:4,className:"h-full",children:e.jsx(Ks,{selectedIdentity:a,clients:f,messages:j,onSendAdvert:N})})]})}),e.jsx(ye,{open:R,onClose:()=>w(!1),mode:P,identity:a,repeaterConfig:d==null?void 0:d.config,onCreate:S,onUpdate:b,onDelete:_,onSendAdvert:N})]})})}export{et as default}; diff --git a/frontend/dist/assets/Sessions-Dynaz1Ws.js b/frontend/dist/assets/Sessions-BctisK9q.js similarity index 90% rename from frontend/dist/assets/Sessions-Dynaz1Ws.js rename to frontend/dist/assets/Sessions-BctisK9q.js index 63ef3b01..25408dba 100644 --- a/frontend/dist/assets/Sessions-Dynaz1Ws.js +++ b/frontend/dist/assets/Sessions-BctisK9q.js @@ -1,4 +1,4 @@ -import{d as x,r as l,f6 as G,f7 as O,dn as U,j as e,B as g,L as M,w as V,b8 as C,c as N,dM as J,cd as Q,bL as Z}from"./index-C8IY8K2r.js";import{C as W,T as P}from"./ConfirmModal-CNsW1W2q.js";import{D as X}from"./DataBox-W2v3wy8k.js";import{P as Y,a as ee,B as se,C as D}from"./PageLayout-NQBVrM09.js";import{R as ae}from"./refresh-cw-BqACEANM.js";import{R as T,C as j}from"./Grid-CEGkNRmt.js";import{C as te}from"./circle-question-mark-C7l07_IA.js";import{T as le}from"./triangle-alert-8k00uu7o.js";import{S as ie}from"./shield-DlHwWwz2.js";import{A as ne}from"./antenna-DOuH490Q.js";/** +import{d as x,r as l,fc as O,fd as G,dt as U,j as e,B as b,L as M,w as V,b8 as C,c as N,dR as J,cg as Q,bO as Z}from"./index-BwGHI0A_.js";import{C as W,T as P}from"./ConfirmModal-B0nTD1Q0.js";import{D as X}from"./DataBox-CQS-Zhu0.js";import{P as Y,a as ee,B as se,C as D}from"./PageLayout-BIcqC04y.js";import{R as ae}from"./refresh-cw-DYpAqCT4.js";import{R as T,C as j}from"./Grid-BoZ-SJB7.js";import{C as te}from"./circle-question-mark-DC7QfrVK.js";import{T as le}from"./triangle-alert-B4kC1YDk.js";import{S as ie}from"./shield-DOTPcYJ1.js";import{A as ne}from"./antenna-zVXb9cuG.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -23,4 +23,4 @@ import{d as x,r as l,f6 as G,f7 as O,dn as U,j as e,B as g,L as M,w as V,b8 as C * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const ue=[["path",{d:"m16 11 2 2 4-4",key:"9rsbq5"}],["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],pe=x("user-check",ue),fe=[{id:"overview",label:"Overview",icon:oe},{id:"clients",label:"Authenticated Clients",icon:pe},{id:"identities",label:"By Identity",icon:de}];function B(s){return s?new Date(s*1e3).toLocaleString():"Never"}function ye(s){if(!s)return"Never";const t=Date.now()-s*1e3,i=Math.floor(t/6e4),h=Math.floor(t/36e5),d=Math.floor(t/864e5);return i<1?"Just now":i<60?`${i}m ago`:h<24?`${h}h ago`:d<365?`${d}d ago`:`${Math.floor(d/365)}y ago`}function b({label:s,value:t,icon:i}){return e.jsxs(D,{neomorphic:!0,children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 mb-2 sm:mb-3",children:[i&&e.jsx("span",{className:"icon-sm text-icon-card-title",children:i}),e.jsx("span",{className:"type-micro",children:s})]}),e.jsx(Q,{centered:!0,children:e.jsx("span",{className:"type-data-xl text-fg-primary font-mono font-normal tabular-nums",children:t})})]})}function je({identity:s}){const t=s.type==="repeater";return e.jsxs("div",{className:"bg-subtle-fill/80 radius-inner depth-stroke-raised p-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 mb-3",children:[e.jsx("span",{className:"icon-sm text-icon-card-title",children:t?e.jsx(ne,{className:"w-4 h-4"}):e.jsx(Z,{className:"w-4 h-4"})}),e.jsx("span",{className:"type-micro",children:s.name}),e.jsx(X,{copy:!0,size:"compact",truncate:[8,6],color:"text-fg-muted",children:s.hash}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined ml-auto",style:{"--data-box-accent":t?"var(--sys-blue)":"var(--sys-pink)"},children:s.type})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Max Clients"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:s.max_clients})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Authenticated"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:s.authenticated_clients})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Admin Password"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",style:{"--data-box-color":s.has_admin_password?"var(--sys-green)":"var(--sys-red)"},children:s.has_admin_password?"✓ Set":"✗ Not Set"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Guest Password"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",style:{"--data-box-color":s.has_guest_password?"var(--sys-green)":"var(--sys-red)"},children:s.has_guest_password?"✓ Set":"✗ Not Set"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Read-Only Access"}),e.jsx("div",{className:N("data-box data-box-fill data-box-left",s.allow_read_only?"text-sys-green":"text-sys-red"),children:s.allow_read_only?"Allowed":"Disabled"})]})]})]})}function be({client:s,onRemove:t}){return e.jsx("div",{className:"bg-subtle-fill/80 radius-inner depth-stroke-raised p-4 transition-base hover:bg-subtle-fill-strong",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0 grid grid-cols-1 sm:grid-cols-5 gap-2 sm:gap-4 items-center",children:[e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Client"}),e.jsx("span",{className:"type-data-sm text-fg-primary font-mono truncate block",children:s.public_key})]}),e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Address"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-mono truncate block",children:s.address})]}),e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Identity"}),e.jsx("span",{className:"type-data-sm text-fg-primary block truncate",children:s.identity_name}),e.jsx("span",{className:"type-data-xs text-fg-muted block truncate",children:s.identity_hash})]}),e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Permissions"}),e.jsx("span",{className:N("type-data-xs px-2 py-0.5 rounded-full font-medium inline-block",s.permissions==="admin"?"bg-sys-green/15 text-sys-green":"bg-sys-amber/15 text-sys-amber"),children:s.permissions})]}),e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Last Activity"}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:ye(s.last_activity)})]})]}),e.jsxs(g,{color:"danger",outline:!0,onClick:t,className:"flex-shrink-0",children:[e.jsx(P,{"data-slot":"icon"}),"Remove"]})]})})}function ge({client:s,onRemove:t}){return e.jsx("div",{className:"bg-subtle-fill/80 radius-inner depth-stroke-raised p-4 transition-base hover:bg-subtle-fill-strong",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 items-center gap-2 mb-3",children:[e.jsx("span",{className:N("type-data-xs px-2 py-0.5 rounded-full font-medium",s.permissions==="admin"?"bg-sys-green/15 text-sys-green":"bg-sys-amber/15 text-sys-amber"),children:s.permissions}),e.jsx("span",{className:"type-data-sm text-fg-primary font-mono truncate",children:s.public_key})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-muted",children:"Address: "}),e.jsx("span",{className:"text-fg-primary/90 font-mono",children:s.address})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-muted",children:"Identity: "}),e.jsxs("span",{className:"text-fg-primary/90",children:[s.identity_name," (",s.identity_hash,")"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-muted",children:"Last Activity: "}),e.jsx("span",{className:"text-fg-primary/90",children:B(s.last_activity)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-muted",children:"Last Login: "}),e.jsx("span",{className:"text-fg-primary/90",children:B(s.last_login_success)})]})]})]}),e.jsx(g,{color:"danger",outline:!0,onClick:t,className:"flex-shrink-0",children:e.jsx(P,{"data-slot":"icon"})})]})})}function Ie(){const[s,t]=l.useState("overview"),[i,h]=l.useState(!0),[d,S]=l.useState(!1),[u,v]=l.useState("idle"),[A,p]=l.useState(null),[w,K]=l.useState(null),[c,E]=l.useState([]),[r,F]=l.useState(null),[o,H]=l.useState(null),[n,f]=l.useState(null),[q,R]=l.useState(!1),k=(w==null?void 0:w.acls)??[],L=l.useMemo(()=>o?c.filter(a=>a.identity_name===o):c,[c,o]),y=l.useCallback(async()=>{p(null);try{const[a,m,_]=await Promise.all([G(),O(),U()]);a.success&&a.data&&K(a.data),m.success&&m.data&&E(m.data.clients||[]),_.success&&_.data&&F(_.data)}catch(a){p(a instanceof Error?a.message:"Failed to load session data")}},[]);l.useEffect(()=>{y().finally(()=>h(!1))},[y]);const I=async()=>{S(!0),v("loading"),await y(),S(!1),v("success"),setTimeout(()=>v("idle"),1500)},z=async()=>{if(n){R(!0);try{const a=await J({public_key:n.publicKey,identity_hash:n.identityHash});a.success?await y():p(`Failed to remove client: ${a.error}`)}catch(a){p(a instanceof Error?a.message:"Failed to remove client")}finally{R(!1),f(null)}}};return e.jsxs(Y,{children:[e.jsx(ee,{title:"Sessions",icon:e.jsx(C,{}),controls:e.jsxs(g,{color:u==="success"?"success":"primary",outline:!0,onClick:I,disabled:d,children:[u==="loading"?e.jsx(M,{"data-slot":"icon",className:"animate-spin"}):u==="success"?e.jsx(V,{"data-slot":"icon"}):e.jsx(ae,{"data-slot":"icon"}),u==="success"?"Done":"Refresh"]}),subtitle:e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Manage authenticated clients and access control lists"})}),e.jsxs(se,{children:[r&&e.jsxs(T,{template:"widget",children:[e.jsx(j,{span:6,md:3,children:e.jsx(b,{label:"Identities",value:r.total_identities,icon:e.jsx(C,{className:"w-4 h-4"})})}),e.jsx(j,{span:6,md:3,children:e.jsx(b,{label:"Authenticated",value:r.total_clients,icon:e.jsx(xe,{className:"w-4 h-4"})})}),e.jsx(j,{span:6,md:3,children:e.jsx(b,{label:"Admin",value:r.admin_clients,icon:e.jsx($,{className:"w-4 h-4"})})}),e.jsx(j,{span:6,md:3,children:e.jsx(b,{label:"Guest",value:r.guest_clients,icon:e.jsx(te,{className:"w-4 h-4"})})})]}),e.jsx(T,{template:"auto",children:e.jsxs(D,{neomorphic:!0,children:[e.jsx("div",{className:"flex flex-wrap gap-1 mb-5",children:e.jsx("div",{className:"toggle-group",children:fe.map(a=>{const m=s===a.id;return e.jsxs("button",{onClick:()=>t(a.id),className:N("toggle-group-item flex items-center gap-1.5",m&&"active"),children:[e.jsx(a.icon,{className:"w-3.5 h-3.5"}),a.label]},a.id)})})}),e.jsx("div",{className:"min-h-[300px]",children:i?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(M,{className:"w-6 h-6 animate-spin text-sys-blue mr-3"}),e.jsx("span",{className:"type-body text-fg-muted",children:"Loading session data..."})]}):A?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-sys-red/10 mx-auto mb-3 flex items-center justify-center",children:e.jsx(le,{className:"w-6 h-6 text-sys-red"})}),e.jsx("p",{className:"type-body text-sys-red mb-2",children:"Failed to load session data"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:A}),e.jsx(g,{color:"primary",outline:!0,onClick:I,children:"Retry"})]}):e.jsxs(e.Fragment,{children:[s==="overview"&&e.jsx("div",{className:"space-y-4",children:k.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-subtle-fill mx-auto mb-4 flex items-center justify-center",children:e.jsx($,{className:"w-7 h-7 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted",children:"No identities configured"})]}):k.map(a=>e.jsx(je,{identity:a},a.hash))}),s==="clients"&&e.jsxs("div",{className:"space-y-3",children:[c.length>0&&e.jsxs("div",{className:"hidden sm:grid grid-cols-5 gap-4 px-4 pb-2 border-b border-edge-subtle",children:[e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Client"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Address"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Identity"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Permissions"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Last Activity"})]}),c.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-subtle-fill mx-auto mb-4 flex items-center justify-center",children:e.jsx(C,{className:"w-7 h-7 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted",children:"No authenticated clients"})]}):c.map(a=>e.jsx(be,{client:a,onRemove:()=>f({publicKey:a.public_key_full,identityHash:a.identity_hash,displayKey:a.public_key})},a.public_key_full))]}),s==="identities"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Filter by Identity"}),e.jsxs("select",{value:o??"",onChange:a=>H(a.target.value||null),className:"w-full sm:w-auto bg-subtle-fill border border-edge-subtle radius-inner px-4 py-2 type-data text-fg-primary focus:outline-none focus:border-sys-blue/50 transition-colors",children:[e.jsx("option",{value:"",children:"All Identities"}),k.map(a=>e.jsxs("option",{value:a.name,children:[a.name," (",a.authenticated_clients," clients)"]},a.name))]})]}),L.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-subtle-fill mx-auto mb-4 flex items-center justify-center",children:e.jsx(ie,{className:"w-7 h-7 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted",children:o?"No clients for selected identity":"No clients found"})]}):e.jsx("div",{className:"space-y-3",children:L.map(a=>e.jsx(ge,{client:a,onRemove:()=>f({publicKey:a.public_key_full,identityHash:a.identity_hash,displayKey:a.public_key})},a.public_key_full))})]})]})})]})})]}),e.jsx(W,{isOpen:!!n,title:"Remove Client",message:`Are you sure you want to remove client '${n==null?void 0:n.displayKey}' from the ACL? This will disconnect the client.`,confirmLabel:q?"Removing...":"Remove",cancelLabel:"Cancel",variant:"danger",onConfirm:z,onCancel:()=>f(null)})]})}export{Ie as default}; + */const ue=[["path",{d:"m16 11 2 2 4-4",key:"9rsbq5"}],["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]],pe=x("user-check",ue),fe=[{id:"overview",label:"Overview",icon:oe},{id:"clients",label:"Authenticated Clients",icon:pe},{id:"identities",label:"By Identity",icon:de}];function B(s){return s?new Date(s*1e3).toLocaleString():"Never"}function ye(s){if(!s)return"Never";const t=Date.now()-s*1e3,i=Math.floor(t/6e4),h=Math.floor(t/36e5),d=Math.floor(t/864e5);return i<1?"Just now":i<60?`${i}m ago`:h<24?`${h}h ago`:d<365?`${d}d ago`:`${Math.floor(d/365)}y ago`}function g({label:s,value:t,icon:i}){return e.jsxs(D,{neomorphic:!0,children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 mb-2 sm:mb-3",children:[i&&e.jsx("span",{className:"icon-sm text-icon-card-title",children:i}),e.jsx("span",{className:"type-micro",children:s})]}),e.jsx(Q,{centered:!0,children:e.jsx("span",{className:"type-data-xl text-fg-primary font-mono font-normal tabular-nums",children:t})})]})}function je({identity:s}){const t=s.type==="repeater";return e.jsxs("div",{className:"bg-subtle-fill/80 radius-inner depth-stroke-raised p-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 mb-3",children:[e.jsx("span",{className:"icon-sm text-icon-card-title",children:t?e.jsx(ne,{className:"w-4 h-4"}):e.jsx(Z,{className:"w-4 h-4"})}),e.jsx("span",{className:"type-micro",children:s.name}),e.jsx(X,{copy:!0,size:"compact",truncate:[8,6],color:"text-fg-muted",children:s.hash}),e.jsx("span",{className:"data-box data-box-compact data-box-outlined ml-auto",style:{"--data-box-accent":t?"var(--sys-blue)":"var(--sys-pink)"},children:s.type})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Max Clients"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:s.max_clients})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Authenticated"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:s.authenticated_clients})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Admin Password"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",style:{"--data-box-color":s.has_admin_password?"var(--sys-green)":"var(--sys-red)"},children:s.has_admin_password?"✓ Set":"✗ Not Set"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Guest Password"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",style:{"--data-box-color":s.has_guest_password?"var(--sys-green)":"var(--sys-red)"},children:s.has_guest_password?"✓ Set":"✗ Not Set"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Read-Only Access"}),e.jsx("div",{className:N("data-box data-box-fill data-box-left",s.allow_read_only?"text-sys-green":"text-sys-red"),children:s.allow_read_only?"Allowed":"Disabled"})]})]})]})}function ge({client:s,onRemove:t}){return e.jsx("div",{className:"bg-subtle-fill/80 radius-inner depth-stroke-raised p-4 transition-base hover:bg-subtle-fill-strong",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0 grid grid-cols-1 sm:grid-cols-5 gap-2 sm:gap-4 items-center",children:[e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Client"}),e.jsx("span",{className:"type-data-sm text-fg-primary font-mono truncate block",children:s.public_key})]}),e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Address"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-mono truncate block",children:s.address})]}),e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Identity"}),e.jsx("span",{className:"type-data-sm text-fg-primary block truncate",children:s.identity_name}),e.jsx("span",{className:"type-data-xs text-fg-muted block truncate",children:s.identity_hash})]}),e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Permissions"}),e.jsx("span",{className:N("type-data-xs px-2 py-0.5 rounded-full font-medium inline-block",s.permissions==="admin"?"bg-sys-green/15 text-sys-green":"bg-sys-amber/15 text-sys-amber"),children:s.permissions})]}),e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("span",{className:"type-data-xs text-fg-muted block sm:hidden mb-0.5",children:"Last Activity"}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:ye(s.last_activity)})]})]}),e.jsxs(b,{color:"danger",outline:!0,onClick:t,className:"flex-shrink-0",children:[e.jsx(P,{"data-slot":"icon"}),"Remove"]})]})})}function be({client:s,onRemove:t}){return e.jsx("div",{className:"bg-subtle-fill/80 radius-inner depth-stroke-raised p-4 transition-base hover:bg-subtle-fill-strong",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 items-center gap-2 mb-3",children:[e.jsx("span",{className:N("type-data-xs px-2 py-0.5 rounded-full font-medium",s.permissions==="admin"?"bg-sys-green/15 text-sys-green":"bg-sys-amber/15 text-sys-amber"),children:s.permissions}),e.jsx("span",{className:"type-data-sm text-fg-primary font-mono truncate",children:s.public_key})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-muted",children:"Address: "}),e.jsx("span",{className:"text-fg-primary/90 font-mono",children:s.address})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-muted",children:"Identity: "}),e.jsxs("span",{className:"text-fg-primary/90",children:[s.identity_name," (",s.identity_hash,")"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-muted",children:"Last Activity: "}),e.jsx("span",{className:"text-fg-primary/90",children:B(s.last_activity)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-muted",children:"Last Login: "}),e.jsx("span",{className:"text-fg-primary/90",children:B(s.last_login_success)})]})]})]}),e.jsx(b,{color:"danger",outline:!0,onClick:t,className:"flex-shrink-0",children:e.jsx(P,{"data-slot":"icon"})})]})})}function Ie(){const[s,t]=l.useState("overview"),[i,h]=l.useState(!0),[d,S]=l.useState(!1),[u,v]=l.useState("idle"),[A,p]=l.useState(null),[w,K]=l.useState(null),[c,E]=l.useState([]),[r,F]=l.useState(null),[o,H]=l.useState(null),[n,f]=l.useState(null),[q,R]=l.useState(!1),k=(w==null?void 0:w.acls)??[],L=l.useMemo(()=>o?c.filter(a=>a.identity_name===o):c,[c,o]),y=l.useCallback(async()=>{p(null);try{const[a,m,_]=await Promise.all([O(),G(),U()]);a.success&&a.data&&K(a.data),m.success&&m.data&&E(m.data.clients||[]),_.success&&_.data&&F(_.data)}catch(a){p(a instanceof Error?a.message:"Failed to load session data")}},[]);l.useEffect(()=>{y().finally(()=>h(!1))},[y]);const I=async()=>{S(!0),v("loading"),await y(),S(!1),v("success"),setTimeout(()=>v("idle"),1500)},z=async()=>{if(n){R(!0);try{const a=await J({public_key:n.publicKey,identity_hash:n.identityHash});a.success?await y():p(`Failed to remove client: ${a.error}`)}catch(a){p(a instanceof Error?a.message:"Failed to remove client")}finally{R(!1),f(null)}}};return e.jsxs(Y,{children:[e.jsx(ee,{title:"Sessions",icon:e.jsx(C,{}),controls:e.jsxs(b,{color:u==="success"?"success":"primary",outline:!0,onClick:I,disabled:d,children:[u==="loading"?e.jsx(M,{"data-slot":"icon",className:"animate-spin"}):u==="success"?e.jsx(V,{"data-slot":"icon"}):e.jsx(ae,{"data-slot":"icon"}),u==="success"?"Done":"Refresh"]}),subtitle:e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Manage authenticated clients and access control lists"})}),e.jsxs(se,{children:[r&&e.jsxs(T,{template:"widget",children:[e.jsx(j,{span:6,md:3,children:e.jsx(g,{label:"Identities",value:r.total_identities,icon:e.jsx(C,{className:"w-4 h-4"})})}),e.jsx(j,{span:6,md:3,children:e.jsx(g,{label:"Authenticated",value:r.total_clients,icon:e.jsx(xe,{className:"w-4 h-4"})})}),e.jsx(j,{span:6,md:3,children:e.jsx(g,{label:"Admin",value:r.admin_clients,icon:e.jsx($,{className:"w-4 h-4"})})}),e.jsx(j,{span:6,md:3,children:e.jsx(g,{label:"Guest",value:r.guest_clients,icon:e.jsx(te,{className:"w-4 h-4"})})})]}),e.jsx(T,{template:"auto",children:e.jsxs(D,{neomorphic:!0,children:[e.jsx("div",{className:"flex flex-wrap gap-1 mb-5",children:e.jsx("div",{className:"toggle-group",children:fe.map(a=>{const m=s===a.id;return e.jsxs("button",{onClick:()=>t(a.id),className:N("toggle-group-item flex items-center gap-1.5",m&&"active"),children:[e.jsx(a.icon,{className:"w-3.5 h-3.5"}),a.label]},a.id)})})}),e.jsx("div",{className:"min-h-[300px]",children:i?e.jsxs("div",{className:"flex items-center justify-center py-12",children:[e.jsx(M,{className:"w-6 h-6 animate-spin text-sys-blue mr-3"}),e.jsx("span",{className:"type-body text-fg-muted",children:"Loading session data..."})]}):A?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-sys-red/10 mx-auto mb-3 flex items-center justify-center",children:e.jsx(le,{className:"w-6 h-6 text-sys-red"})}),e.jsx("p",{className:"type-body text-sys-red mb-2",children:"Failed to load session data"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:A}),e.jsx(b,{color:"primary",outline:!0,onClick:I,children:"Retry"})]}):e.jsxs(e.Fragment,{children:[s==="overview"&&e.jsx("div",{className:"space-y-4",children:k.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-subtle-fill mx-auto mb-4 flex items-center justify-center",children:e.jsx($,{className:"w-7 h-7 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted",children:"No identities configured"})]}):k.map(a=>e.jsx(je,{identity:a},a.hash))}),s==="clients"&&e.jsxs("div",{className:"space-y-3",children:[c.length>0&&e.jsxs("div",{className:"hidden sm:grid grid-cols-5 gap-4 px-4 pb-2 border-b border-edge-subtle",children:[e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Client"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Address"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Identity"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Permissions"}),e.jsx("span",{className:"type-data-xs text-fg-muted font-medium",children:"Last Activity"})]}),c.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-subtle-fill mx-auto mb-4 flex items-center justify-center",children:e.jsx(C,{className:"w-7 h-7 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted",children:"No authenticated clients"})]}):c.map(a=>e.jsx(ge,{client:a,onRemove:()=>f({publicKey:a.public_key_full,identityHash:a.identity_hash,displayKey:a.public_key})},a.public_key_full))]}),s==="identities"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Filter by Identity"}),e.jsxs("select",{value:o??"",onChange:a=>H(a.target.value||null),className:"w-full sm:w-auto bg-subtle-fill border border-edge-subtle radius-inner px-4 py-2 type-data text-fg-primary focus:outline-none focus:border-sys-blue/50 transition-colors",children:[e.jsx("option",{value:"",children:"All Identities"}),k.map(a=>e.jsxs("option",{value:a.name,children:[a.name," (",a.authenticated_clients," clients)"]},a.name))]})]}),L.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-subtle-fill mx-auto mb-4 flex items-center justify-center",children:e.jsx(ie,{className:"w-7 h-7 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted",children:o?"No clients for selected identity":"No clients found"})]}):e.jsx("div",{className:"space-y-3",children:L.map(a=>e.jsx(be,{client:a,onRemove:()=>f({publicKey:a.public_key_full,identityHash:a.identity_hash,displayKey:a.public_key})},a.public_key_full))})]})]})})]})})]}),e.jsx(W,{isOpen:!!n,title:"Remove Client",message:`Are you sure you want to remove client '${n==null?void 0:n.displayKey}' from the ACL? This will disconnect the client.`,confirmLabel:q?"Removing...":"Remove",cancelLabel:"Cancel",variant:"danger",onConfirm:z,onCancel:()=>f(null)})]})}export{Ie as default}; diff --git a/frontend/dist/assets/SignalIndicator-Dw_bfp50.js b/frontend/dist/assets/SignalIndicator-LNOR_5YF.js similarity index 87% rename from frontend/dist/assets/SignalIndicator-Dw_bfp50.js rename to frontend/dist/assets/SignalIndicator-LNOR_5YF.js index ef0da08a..44758397 100644 --- a/frontend/dist/assets/SignalIndicator-Dw_bfp50.js +++ b/frontend/dist/assets/SignalIndicator-LNOR_5YF.js @@ -1,4 +1,4 @@ -import{d as s,r as m,c as l,j as r,bW as j,bX as k,bY as _}from"./index-C8IY8K2r.js";/** +import{d as s,r as m,c as l,j as r,bZ as j,b_ as k,b$ as _}from"./index-BwGHI0A_.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -33,4 +33,4 @@ import{d as s,r as m,c as l,j as r,bW as j,bX as k,bY as _}from"./index-C8IY8K2r * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const L=[["path",{d:"M2 20h.01",key:"4haj6o"}],["path",{d:"M7 20v-4",key:"j294jx"}],["path",{d:"M12 20v-8",key:"i3yub9"}],["path",{d:"M17 20V8",key:"1tkaf5"}],["path",{d:"M22 4v16",key:"sih9yq"}]],$=s("signal",L),E={excellent:"color(display-p3 0.00 1.00 0.00)",good:"color(display-p3 0.55 0.90 0.15)",fair:"color(display-p3 1.00 0.85 0.00)",weak:"color(display-p3 1.00 0.55 0.15)",poor:"color(display-p3 1.00 0.20 0.20)"},F={excellent:"#4ADE80",good:"#A3E635",fair:"#FACC15",weak:"#FB923C",poor:"#EF4444"};function d(e){return e>=-90?"excellent":e>=-100?"good":e>=-110?"fair":e>=-120?"weak":"poor"}function I(e,t,a,c=0){const n=_(t,e,a,c);return n?O(n.finalGrade):d(e)}function O(e){switch(e){case"excellent":return"excellent";case"good":return"good";case"fair":return"fair";case"poor":return"weak";case"critical":return"poor"}}function D(e){switch(e){case"excellent":return"text-signal-excellent";case"good":return"text-signal-good";case"fair":return"text-signal-fair";case"weak":return"text-signal-poor";case"poor":return"text-signal-critical";default:return"text-fg-muted"}}function p(e,t,a=!0){return t?a?{backgroundColor:F[e],"--p3-color":E[e]}:{backgroundColor:"rgba(255, 255, 255, 0.25)"}:{backgroundColor:"rgba(255, 255, 255, 0.1)"}}function f(e,t=!0){return e&&t?"signal-bar-active":""}function W({rssi:e,className:t="w-4 h-4"}){const a=d(e),c=D(a),n=l(c,t);switch(a){case"excellent":return r.jsx($,{className:n});case"good":return r.jsx(S,{className:n});case"fair":return r.jsx(b,{className:n});case"weak":return r.jsx(A,{className:n});case"poor":default:return r.jsx(B,{className:n})}}function H({rssi:e,snr:t,compact:a=!1,showValues:c=!0,radioConfig:n,nfPenalty:h=0,validated:i=!0}){const g=t!==void 0?I(e,t,n,h):d(e),x=4,u={excellent:4,good:3,fair:2,weak:1,poor:0}[g];return a?r.jsxs("div",{className:"flex items-center gap-1.5",children:[c&&r.jsx("span",{className:l("type-data-xs w-[32px] text-left",i?"text-fg-secondary":"text-fg-muted"),children:e}),r.jsx("div",{className:"flex items-center gap-[2px] h-3 w-[14px]",children:Array.from({length:x}).map((y,o)=>r.jsx("div",{className:l("w-[3px] h-full rounded-[1px] transition-colors",f(or.jsx("div",{className:l("w-[3px] h-full rounded-[1px] transition-colors",f(o=-90?"excellent":e>=-100?"good":e>=-110?"fair":e>=-120?"weak":"poor"}function I(e,t,a,c=0){const n=_(t,e,a,c);return n?O(n.finalGrade):d(e)}function O(e){switch(e){case"excellent":return"excellent";case"good":return"good";case"fair":return"fair";case"poor":return"weak";case"critical":return"poor"}}function Z(e){switch(e){case"excellent":return"text-signal-excellent";case"good":return"text-signal-good";case"fair":return"text-signal-fair";case"weak":return"text-signal-poor";case"poor":return"text-signal-critical";default:return"text-fg-muted"}}function p(e,t,a=!0){return t?a?{backgroundColor:F[e],"--p3-color":E[e]}:{backgroundColor:"rgba(255, 255, 255, 0.25)"}:{backgroundColor:"rgba(255, 255, 255, 0.1)"}}function f(e,t=!0){return e&&t?"signal-bar-active":""}function J({rssi:e,className:t="w-4 h-4"}){const a=d(e),c=Z(a),n=l(c,t);switch(a){case"excellent":return r.jsx($,{className:n});case"good":return r.jsx(S,{className:n});case"fair":return r.jsx(b,{className:n});case"weak":return r.jsx(A,{className:n});case"poor":default:return r.jsx(B,{className:n})}}function D({rssi:e,snr:t,compact:a=!1,showValues:c=!0,radioConfig:n,nfPenalty:h=0,validated:i=!0}){const g=t!==void 0?I(e,t,n,h):d(e),x=4,u={excellent:4,good:3,fair:2,weak:1,poor:0}[g];return a?r.jsxs("div",{className:"flex items-center gap-1.5",children:[c&&r.jsx("span",{className:l("type-data-xs w-[32px] text-left",i?"text-fg-secondary":"text-fg-muted"),children:e}),r.jsx("div",{className:"flex items-center gap-[2px] h-3 w-[14px]",children:Array.from({length:x}).map((y,o)=>r.jsx("div",{className:l("w-[3px] h-full rounded-[1px] transition-colors",f(or.jsx("div",{className:l("w-[3px] h-full rounded-[1px] transition-colors",f(on in t?Mt(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s;var xe=(t,n,s)=>Ct(t,typeof n!="symbol"?n+"":n,s);import{d as Ae,r as c,j as e,k as Ce,c as nt,b9 as yt,bZ as bt,b_ as Je,b$ as ve,c0 as At,q as Fe,c1 as _t,c2 as Rt,e as Lt,c3 as Dt,c4 as Et,c5 as Tt,c6 as It,c7 as Pt,bw as Ot,c8 as Be,by as Ft,c9 as Ht,ca as Bt,F as Ne,cb as $t,cc as zt,cd as Wt,E as Ut,J as Gt,H as qt,y as Vt,ag as Kt,ah as Yt,K as Xt,aa as Zt,ce as Qt,cf as $e,cg as at,a2 as Jt,R as es,ch as ts}from"./index-C8IY8K2r.js";import{L as Se}from"./layers-Oxzfug7f.js";import{u as et,h as ss,r as tt}from"./consumer-registry-lDKP4bcU.js";import{C as ze,e as ns}from"./easing-CXN4GmUW.js";import{T as as}from"./TimeRangeStepper-BlC9rlkV.js";import{C as le,P as rs,a as is,B as os}from"./PageLayout-NQBVrM09.js";import{D as ls}from"./DataBox-W2v3wy8k.js";import{E as cs,A as Oe}from"./AnimatedNumber-BmJRWt4U.js";import{C as ms}from"./CollisionExplorerModal-DeHgfjGl.js";import{H as rt}from"./hash-BkZp0AKy.js";import{T as Ze}from"./triangle-alert-8k00uu7o.js";import{L as ds}from"./LightSparkline-CkL4j4OZ.js";import{A as us}from"./activity-2-g8m4_g.js";import{c as hs,a as xs,A as ps}from"./AnalyzerFilterPanel-BPawhC5X.js";import{a as fs}from"./usePipelineStore-CyFB3GIy.js";import{R as ge,C as we}from"./Grid-CEGkNRmt.js";import{S as gs}from"./settings-2-BUdn2-nA.js";import{N as ys}from"./network-DBkquEPb.js";import"./chevron-right-DUgYTR6d.js";import"./map-pin-DMVHq6j8.js";import"./index-B-prVW1V.js";import"./BasemapLayer-D5WYHXmJ.js";import"./monitor-smartphone-DF_mmgOV.js";import"./node-types-3T9Wr7vI.js";import"./funnel-BDRRJl0y.js";import"./circle-question-mark-C7l07_IA.js";import"./search-zALFwCS4.js";import"./geo-utils-BP1zBK9h.js";/** +var Mt=Object.defineProperty;var Ct=(t,n,s)=>n in t?Mt(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s;var xe=(t,n,s)=>Ct(t,typeof n!="symbol"?n+"":n,s);import{d as Ae,r as c,j as e,k as Ce,c as nt,b9 as yt,c0 as bt,c1 as Je,c2 as ve,c3 as At,q as Fe,c4 as _t,c5 as Rt,e as Lt,c6 as Dt,c7 as Et,c8 as Tt,c9 as It,ca as Pt,by as Ot,cb as Be,bB as Ft,cc as Ht,cd as Bt,F as Ne,ce as $t,cf as zt,cg as Wt,E as Ut,J as Gt,H as qt,y as Vt,ag as Kt,ah as Yt,K as Xt,aa as Zt,ch as Qt,ci as $e,cj as at,a2 as Jt,R as es,ck as ts}from"./index-BwGHI0A_.js";import{L as Se}from"./layers-C8ICjJ-w.js";import{u as et,h as ss,r as tt}from"./consumer-registry-DPYvsBcc.js";import{C as ze,e as ns}from"./easing-DSebI9nw.js";import{T as as}from"./TimeRangeStepper-Dh4JEQ42.js";import{C as le,P as rs,a as is,B as os}from"./PageLayout-BIcqC04y.js";import{D as ls}from"./DataBox-CQS-Zhu0.js";import{E as cs,A as Oe}from"./AnimatedNumber-BAXz0cmM.js";import{C as ms}from"./CollisionExplorerModal-Cm5c7tcU.js";import{H as rt}from"./hash-9uwO8S8N.js";import{T as Ze}from"./triangle-alert-B4kC1YDk.js";import{L as ds}from"./LightSparkline-5OIe9Q0M.js";import{A as us}from"./activity-Dr_TPIps.js";import{c as hs,a as xs,A as ps}from"./AnalyzerFilterPanel-BIfh-GdY.js";import{useResolveSource as fs}from"./usePipelineStore-11oXtutw.js";import{R as ge,C as we}from"./Grid-BoZ-SJB7.js";import{S as gs}from"./settings-2-B_NiASQG.js";import{N as ys}from"./network-9doWJxcL.js";import"./chevron-right-DqpRZiGf.js";import"./map-pin-VRY_TOuh.js";import"./index-OH01SZkk.js";import"./BasemapLayer-Bm_seLWQ.js";import"./monitor-smartphone-BxljwdQV.js";import"./node-types-DmTOZWT4.js";import"./funnel-D4Wxq-Fx.js";import"./circle-question-mark-DC7QfrVK.js";import"./search-B7iMjmGm.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -38,4 +38,4 @@ var Mt=Object.defineProperty;var Ct=(t,n,s)=>n in t?Mt(t,n,{enumerable:!0,config transform-origin: center; animation: neighbor-blink-scale ${Ke.BLINK_DURATION}ms ease-out forwards; } - `}),e.jsx("clipPath",{id:ue,children:e.jsx("circle",{cx:S,cy:A,r:I})})]}),(()=>{const u=I+oe.LABEL_INSET+12,E=f?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.15)",C=f?"rgba(59, 130, 246, 0.4)":"rgba(59, 130, 246, 0.5)",_=6,F=16,X=4,K=[0,90,180,270],ee=[45,135,225,315];return e.jsxs("g",{className:"radar-frame","aria-hidden":"true",children:[e.jsx("circle",{cx:S,cy:A,r:u,fill:"none",stroke:E,strokeWidth:1,strokeDasharray:"2 6"}),ee.map(Z=>{const ie=Z*Math.PI/180,me=Math.cos(ie),de=Math.sin(ie),he=u+X,M=u+X+F,G=S+he*de,ye=A-he*me,Ie=S+M*de,He=A-M*me;return e.jsxs("g",{children:[e.jsx("line",{x1:G,y1:ye,x2:Ie,y2:He,stroke:C,strokeWidth:1}),e.jsx("line",{x1:Ie-4*me,y1:He-4*de,x2:Ie+4*me,y2:He+4*de,stroke:C,strokeWidth:1})]},`corner-${Z}`)}),K.map(Z=>{const ie=Z*Math.PI/180,me=S+(u-_)*Math.sin(ie),de=A-(u-_)*Math.cos(ie),he=S+(u+2)*Math.sin(ie),M=A-(u+2)*Math.cos(ie);return e.jsx("line",{x1:me,y1:de,x2:he,y2:M,stroke:E,strokeWidth:1},`tick-cardinal-${Z}`)}),ee.map(Z=>{const ie=Z*Math.PI/180,me=S+(u-4)*Math.sin(ie),de=A-(u-4)*Math.cos(ie),he=S+(u+1)*Math.sin(ie),M=A-(u+1)*Math.cos(ie);return e.jsx("line",{x1:me,y1:de,x2:he,y2:M,stroke:E,strokeWidth:1},`tick-intercardinal-${Z}`)})]})})(),(()=>{const E=[(I+oe.LABEL_INSET+4)/I,...ae.map(C=>Le(C)).filter(C=>C>.02&&C<=1.05).sort((C,_)=>_-C),0];return E.slice(0,-1).map((C,_)=>{const F=E[_+1],X=I*C,K=I*F,ee=X-K;return ee<=0||_%2!==0?null:e.jsx("circle",{cx:S,cy:A,r:(X+K)/2,fill:"none",stroke:"var(--subtle-fill)",strokeWidth:ee,opacity:.8},`band-${_}`)})})(),ae.map(u=>{const E=Le(u);if(E>1.05||E<.02)return null;const C=Ee.some(X=>X.km===u),_=S+I*E*pt,F=A-I*E*ft;return e.jsxs("g",{children:[e.jsx("circle",{cx:S,cy:A,r:I*E,fill:"none",stroke:B,strokeOpacity:R,strokeWidth:1}),C&&e.jsx("text",{x:_+4,y:F-2,textAnchor:"start",dominantBaseline:"auto",fill:m.secondary,fontSize:10,fontFamily:Be,children:De(u)})]},`ring-${u}`)}),["N","E","S","W"].map(u=>{const C={N:0,E:90,S:180,W:270}[u]*Math.PI/180;return e.jsx("line",{x1:S,y1:A,x2:S+I*Math.sin(C),y2:A-I*Math.cos(C),stroke:B,strokeOpacity:R,strokeWidth:1,strokeDasharray:"4 4"},u)}),["NE","SE","SW","NW"].map(u=>{const C={NE:45,SE:135,SW:225,NW:315}[u]*Math.PI/180;return e.jsx("line",{x1:S,y1:A,x2:S+I*Math.sin(C),y2:A-I*Math.cos(C),stroke:B,strokeOpacity:W,strokeWidth:1,strokeDasharray:"4 4"},`diag-${u}`)}),["N","E","S","W"].map(u=>{const E=fe(u),C=u==="E"?"end":u==="W"?"start":"middle",_=u==="N"?"hanging":u==="S"?"auto":"middle";return e.jsx("text",{x:E.x,y:E.y,textAnchor:C,dominantBaseline:_,fill:q,fontSize:oe.CARDINAL_FONT_SIZE,fontWeight:700,fontFamily:Be,"aria-hidden":"true",children:u},u)}),["NE","SE","SW","NW"].map(u=>{const E=fe(u),C=u==="NE"||u==="SE"?"end":"start",_=u==="NE"||u==="NW"?"hanging":"auto";return e.jsx("text",{x:E.x,y:E.y,textAnchor:C,dominantBaseline:_,fill:q,fontSize:oe.INTERCARDINAL_FONT_SIZE,fontWeight:600,fontFamily:Be,"aria-hidden":"true",children:u},u)}),e.jsx("circle",{cx:S,cy:A,r:oe.LOCAL_DOT_RADIUS,fill:N.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(#${ue})`,children:U.map(u=>{const E=D>0?u.distance/D*k:0;if(E>1)return null;const{x:C,y:_}=pe(u.bearing,E),F=u.snr!==null?gt(u.snr,O,T):"#808080",X=(o==null?void 0:o.hash)===u.hash,K=d.has(u.hash),ee=oe.DOT_RADIUS_HOVERED*1.5;return e.jsxs("g",{role:"img","aria-label":`${u.name}: ${u.distance.toFixed(1)}km ${u.bearing.toFixed(0)}°`,children:[K&&e.jsx("circle",{cx:C,cy:_,r:ee,fill:"none",stroke:f?"rgba(255,255,255,0.9)":"rgba(0,0,0,0.7)",strokeWidth:2,className:"neighbor-blink-ring"}),X&&e.jsx("circle",{cx:C,cy:_,r:ee,fill:F,opacity:.3}),e.jsx("circle",{cx:C,cy:_,r:X?oe.DOT_RADIUS_HOVERED:oe.DOT_RADIUS,fill:F,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(u),onMouseLeave:()=>_e(null)})]},u.hash)})})]})]}),o&&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:o.name}),e.jsx("div",{className:"type-data-xs text-fg-secondary",children:o.hash}),o.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:gt(o.snr,O,T)},children:[o.snr.toFixed(1)," dB"]}),e.jsxs("span",{className:"text-fg-secondary ml-1",children:["(",xn(o.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:[o.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:[o.bearing.toFixed(0),"°"]})]})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 px-1.5 py-2 flex-shrink-0 depth-raised radius-inset self-stretch",style:{width:"calc(100% / 6)"},children:[r&&e.jsxs("div",{className:"flex flex-col items-center gap-1 pb-2 border-b border-edge-subtle 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(ze,{className:"w-3.5 h-3.5"})}),l&&e.jsx(Fe,{color:"zinc",children:l})]}),e.jsx("span",{className:"type-micro text-center text-[10px] leading-tight",children:r})]}),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(u=>e.jsx("button",{onClick:()=>Re(u),"aria-pressed":j===u,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 ${j===u?"bg-sys-blue/20 text-sys-blue":"bg-subtle-fill/80 text-fg-secondary hover:bg-subtle-fill-strong hover:text-fg-primary"}`,children:u},u))})]})]}):e.jsxs("div",{ref:H,className:"flex flex-col items-center justify-center h-full text-fg-secondary",children:[e.jsx(ze,{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 fn=c.memo(pn),Ye={repeater:"var(--sys-blue)",companion:"var(--sys-cyan)",room_server:"var(--sys-indigo)"};function gn(t){if(t.contact_type){const n=t.contact_type.toLowerCase();if(n==="repeater"||n==="rep")return"repeater";if(n==="room server"||n==="room_server"||n==="room"||n==="server")return"room_server";if(n==="companion"||n==="client"||n==="cli")return"companion"}return t.is_repeater?"repeater":"companion"}function yn({neighbors:t}){const n=c.useMemo(()=>{const s={repeater:0,companion:0,room_server:0};for(const r of Object.values(t)){const l=gn(r);s[l]=(s[l]||0)+1}const a=Object.values(s).reduce((r,l)=>r+l,0);return{items:[{label:"Repeaters",count:s.repeater,percent:0,color:Ye.repeater},{label:"Companions",count:s.companion,percent:0,color:Ye.companion},{label:"Room Servers",count:s.room_server,percent:0,color:Ye.room_server}].map(r=>({...r,percent:a>0?r.count/a*100:0})).filter(r=>r.count>0).sort((r,l)=>l.count-r.count),total:a}},[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(s=>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:s.label}),e.jsxs("span",{className:"type-data-sm text-fg-secondary tabular-nums",children:[s.count," ",e.jsxs("span",{className:"text-fg-secondary/60",children:["(",s.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:`${s.percent}%`,backgroundColor:s.color,minWidth:s.count>0?"4px":"0"}})})]},s.label))}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-edge-subtle",children:[e.jsx("span",{className:"type-data-xs text-fg-secondary",children:"Total Nodes"}),e.jsx("span",{className:"type-data-sm text-fg-primary font-medium tabular-nums",children:n.total})]})]})}const bn=c.memo(yn);function Xe({children:t,minHeight:n="100%",rootMargin:s="200px 0px",keepMounted:a=!0,className:i=""}){const r=c.useRef(null),[l,x]=c.useState(!1),[o,p]=c.useState(!1);c.useEffect(()=>{const h=r.current;if(!h)return;const w=new IntersectionObserver(([g])=>{const j=g.isIntersecting;p(j),j&&x(!0)},{rootMargin:s,threshold:0});return w.observe(h),()=>{w.disconnect()}},[s]);const d=o||a&&l;return e.jsx("div",{ref:r,className:`h-full w-full ${i}`,style:{minHeight:n},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 kt=[{target:"DisambiguationCard",fn:"disambiguation.collisions",minStage:2}];tt(kt);const jn=.9,Nn=.7,vn=.5,Sn=10,kn=25,Pe={excellent:"text-signal-excellent",good:"text-signal-good",fair:"text-signal-fair",poor:"text-sys-blue"},wn={excellent:"bg-signal-excellent/10",good:"bg-signal-good/10",fair:"bg-signal-fair/10",poor:"bg-sys-blue/10"};function Mn(t){return t>=jn?"excellent":t>=Nn?"good":t>=vn?"fair":"poor"}function Cn(t){return t<=Sn?"excellent":t<=kn?"good":"poor"}function An(){et(kt);const t=Ht(),n=Bt(),[s,a]=c.useState(null),i=c.useCallback((d,h)=>{a({prefix:d,candidateHashes:h})},[]),r=c.useCallback(()=>{a(null)},[]);if(!n)return e.jsxs(le,{neomorphic:!0,children:[e.jsx(Ne,{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($t,{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 l=Mn(t.avgConfidence),x=Cn(t.collisionRate),o=l==="poor"||x==="poor"?"poor":l==="fair"||x==="fair"?"fair":l==="good"||x==="good"?"good":"excellent",p=o==="excellent"||o==="good"?it:Ze;return e.jsxs(le,{neomorphic:!0,className:"flex flex-col overflow-hidden",children:[e.jsx(Ne,{icon:e.jsx(rt,{}),title:"Prefix Conflicts",badgeColor:"zinc",actions:o==="poor"?e.jsxs(Fe,{color:"red",children:[e.jsx(Ze,{className:"w-3 h-3"}),"Needs Attention"]}):e.jsxs("div",{className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full ${wn[o]}`,children:[e.jsx(p,{className:`w-3.5 h-3.5 ${Pe[o]}`}),e.jsx("span",{className:`type-data-xs font-medium ${Pe[o]}`,children:o==="excellent"?"Excellent":o==="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 py-3 sm:py-4",children:[e.jsxs("div",{className:"flex-1 flex flex-col radius-inner depth-stroke-raised bg-subtle-fill/80 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(Oe,{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-raised bg-subtle-fill/80 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(Oe,{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-raised bg-subtle-fill/80 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(Oe,{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-2",children:[e.jsx("div",{className:"type-data-xs text-fg-secondary mb-1.5",children:"Problem Prefixes"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 content-start",children:t.highCollisionPrefixes.map(({prefix:d,candidateCount:h,candidateHashes:w})=>e.jsxs("button",{type:"button",onClick:()=>i(d,w),className:"inline-flex items-center gap-0.5 group",title:`${h} candidates - click to explore`,children:[e.jsx(ls,{children:d}),e.jsxs("span",{className:"text-fg-muted type-data-xs group-hover:text-fg-secondary transition-colors",children:["×",h]})]},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(it,{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 flex-col sm:flex-row sm:items-center gap-2 sm:gap-4 mt-auto pt-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2 cursor-help",title:"Average confidence score across all disambiguated prefixes. Higher = more certain node identification.",children:[e.jsx("span",{className:"type-data-xs text-fg-secondary",children:"Confidence"}),e.jsxs("span",{className:`data-box ${Pe[l]}`,children:[(t.avgConfidence*100).toFixed(1),"%"]})]}),e.jsxs("div",{className:"flex items-center gap-2 cursor-help",title:"Percentage of 2-character prefixes that match multiple known nodes. Lower is better.",children:[e.jsx("span",{className:"type-data-xs text-fg-secondary",children:"Collisions"}),e.jsxs("span",{className:`data-box ${Pe[x]}`,children:[t.collisionRate.toFixed(1),"%"]})]})]})]}),e.jsx(ms,{isOpen:!!s,prefix:(s==null?void 0:s.prefix)||"",candidateHashes:(s==null?void 0:s.candidateHashes)||[],onClose:r})]})}const wt=[{target:"PacketHealth",fn:"type",minStage:1},{target:"PacketHealth",fn:"duplicates",minStage:1}];tt(wt);const _n=new Set(["Duplicate","Empty payload","Path too long","Unknown"]),Me=24;function Rn(t,n){const s=Date.now()/1e3,a=n*60,i=s-a,r=a/Me,l=new Array(Me).fill(0),x=new Array(Me).fill(0);let o=0,p=0,d=0,h=0;for(const g of t){if(g.packet_origin==="tx_local")continue;const j=g.timestamp;if(js)continue;o++;const b=Math.min(Me-1,Math.floor((j-i)/r));x[b]++,g.transmitted||g.packet_origin==="tx_forward"?(p++,l[b]++):(g.is_duplicate||g.drop_reason==="Duplicate")&&d++,g.drop_reason&&_n.has(g.drop_reason)&&h++}const w=[];for(let g=0;g0?Math.round(b/j*100):0,timestamp:(i+g*r)*1e3})}return{totalRx:o,forwarded:p,duplicates:d,waste:h,efficiency:o>0?p/o*100:0,duplicateRate:o>0?d/o*100:0,wasteRate:o>0?h/o*100:0,sparkline:w}}function Ln(t){return t>=90?"excellent":t>=75?"good":t>=60?"fair":"poor"}const Dn={excellent:"bg-status-success",good:"bg-sys-blue",fair:"bg-status-warning",poor:"bg-status-danger"};function En({packets:t,rangeMinutes:n,rangeHours:s,timeRangeLabel:a,isLoaded:i=!0}){et(wt);const r=c.useMemo(()=>Rn(t,n),[t,n]),[l,x]=c.useState(null),o=c.useCallback(async()=>{try{const h=await zt(s);h.success&&h.data&&x(h.data.count)}catch{}},[s]);c.useEffect(()=>{o()},[o]);const p=Ln(r.efficiency),d=r.totalRx>0;return e.jsx(le,{neomorphic:!0,isLoaded:i,skeletonType:"chart",children:i&&e.jsxs(e.Fragment,{children:[e.jsx(Ne,{icon:e.jsx(us,{}),title:"Packet Health",badge:a,badgeColor:"zinc"}),e.jsx(Wt,{children:e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsxs("div",{className:"type-data-xl text-fg-primary",children:[d?e.jsx(Oe,{value:Math.round(r.efficiency*10)/10,className:"font-mono tabular-nums",priority:"medium",format:{minimumFractionDigits:1,maximumFractionDigits:1}}):e.jsx("span",{className:"opacity-30",children:"—"}),e.jsx("span",{className:"type-data-sm text-fg-muted ml-0.5",children:"%"})]}),d&&e.jsx("div",{className:`w-2 h-2 rounded-full ${Dn[p]}`})]}),e.jsx("div",{className:"type-micro mb-2 cursor-help",title:"Forwarded packets / total received. CRC failures, garbled packets, and RF collisions that destroy packets before reaching software are not included in this ratio — see CRC Errors for hardware-level failures.",children:"FORWARDING RATE"}),e.jsx("div",{className:"flex-1 min-h-[28px] max-h-[48px] mb-2",children:e.jsx(ds,{data:r.sparkline,width:9999,height:36,color:"var(--sys-blue)",className:"w-full"})}),e.jsxs("div",{className:"flex gap-2 sm:gap-3 mt-auto",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Dupes"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:d?`${r.duplicateRate.toFixed(1)}%`:"—"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Waste"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:d?`${r.wasteRate.toFixed(1)}%`:"—"})]}),l!==null&&l>0&&e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"data-box-label flex items-center gap-1",children:[e.jsx(Ze,{className:"w-3 h-3 text-status-warning"}),"CRC"]}),e.jsx("div",{className:"data-box data-box-fill data-box-left text-status-warning",children:l})]})]})]})})]})})}function ca(){var De,ke,Ee,Te,u,E,C,_,F,X,K,ee,Z,ie,me,de,he;const t=Ut(),n=Gt(),s=qt(),a=Vt(),i=Kt(),r=Yt(),l=t!==null&&i,x=c.useRef(!1);l&&!x.current&&(x.current=!0);const o=x.current,p=Xt(),d=Zt(),h=Qt(),[w,g]=c.useState(null),[,j]=c.useState(null),[b]=c.useState(null),[k,L]=c.useState(()=>{const M=localStorage.getItem("statistics-view-mode");return M==="share"||M==="airtime"?M:"airtime"});c.useEffect(()=>{localStorage.setItem("statistics-view-mode",k)},[k]);const[P,z]=c.useState(()=>{const M=localStorage.getItem("statistics-smoothing-mode");return["ema","ultra","mosaic","stats","trend"].includes(M)?M:"stats"});c.useEffect(()=>{localStorage.setItem("statistics-smoothing-mode",P)},[P]);const[H,V]=c.useState(!1),[O,N]=c.useState(!1),[m,f]=c.useState(jt),[v,T]=c.useState(.5),[B,R]=c.useState(hs),[W,q]=c.useState(.8),[te,J]=c.useState(50),U=c.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]),D=$e[U].hours,Y=D*60,se=$e[U],re=at(D),ae=r.isBackgroundLoading,ne=c.useCallback(M=>{const ye={0:1,1:2,2:3,3:4,4:5,5:6,6:7,7:8,8:9,9:10}[M]??4;d(ye)},[d]),ce=c.useMemo(()=>{var G;if(!((G=t==null?void 0:t.config)!=null&&G.radio))return null;const M=t.config.radio;return{sf:M.spreading_factor??10,bw:M.bandwidth??25e4,cr:M.coding_rate??5,preamble:M.preamble_length??8}},[(ke=(De=t==null?void 0:t.config)==null?void 0:De.radio)==null?void 0:ke.spreading_factor,(Te=(Ee=t==null?void 0:t.config)==null?void 0:Ee.radio)==null?void 0:Te.bandwidth,(E=(u=t==null?void 0:t.config)==null?void 0:u.radio)==null?void 0:E.coding_rate,(_=(C=t==null?void 0:t.config)==null?void 0:C.radio)==null?void 0:_.preamble_length]),$=c.useMemo(()=>h.length===0?{timestamps:[],values:[]}:{timestamps:h.map(M=>M.timestamp),values:h.map(M=>M.noise_floor_dbm)},[h]),y=c.useMemo(()=>{if(h.length<10)return{anomalies:[],debug:void 0};const M=As(h,m);return{anomalies:M.anomalies,debug:M.debug}},[h,m]),S=y.anomalies,A=c.useMemo(()=>{const M=(t==null?void 0:t.neighbors)??{};return Object.fromEntries(Object.entries(M).filter(([G])=>!n.has(G)))},[t==null?void 0:t.neighbors,n]),I=c.useMemo(()=>{const M=Date.now()/1e3-D*3600;return Object.fromEntries(Object.entries(A).filter(([,G])=>G.last_seen>=M))},[A,D]),Q=c.useMemo(()=>{const M=Y*60/re,G=Math.floor(Date.now()/1e3),ye=Math.floor(G/M)*M;return{start:ye-Y*60,end:ye}},[Y,re]),ue=B.timeStart??Q.start,pe=B.timeEnd??Q.end,fe=(pe-ue)/3600,_e=at(fe),Re=fs(),Le=c.useMemo(()=>xs(a,B,Re,Q),[a,B,Re,Q]);return e.jsxs(rs,{children:[e.jsx(is,{title:"Statistics",icon:e.jsx(Jt,{}),controls:e.jsx(as,{ranges:$e,selectedIndex:U,onSelect:ne,isPending:ae})}),b&&e.jsx(le,{className:"border border-sys-red/50 bg-sys-red/10",children:e.jsx("p",{className:"text-sys-red",children:b})}),H&&O&&e.jsxs(le,{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:["(",se.label,")"]})]}),e.jsx("button",{onClick:()=>f(M=>({...M,useAbsoluteThresholds:!M.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:[((X=(F=y.debug)==null?void 0:F.baselineCutoff)==null?void 0:X.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:[((ee=(K=y.debug)==null?void 0:K.spikeCutoff)==null?void 0:ee.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:((Z=y.debug)==null?void 0:Z.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:S.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:M=>f(G=>({...G,baselineDbm:Number(M.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:M=>f(G=>({...G,spikeDbm:Number(M.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:M=>f(G=>({...G,mergeGapSeconds:Number(M.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:M=>f(G=>({...G,minSequenceLength:Number(M.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:M=>f(G=>({...G,similarityToleranceDbm:Number(M.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(v*100),"%)"]}),e.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:v,onChange:M=>T(Number(M.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:M=>f(G=>({...G,baselinePercentile:Number(M.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:M=>f(G=>({...G,spikePercentile:Number(M.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:M=>f(G=>({...G,mergeGapSeconds:Number(M.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:M=>f(G=>({...G,minSequenceLength:Number(M.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:M=>f(G=>({...G,similarityToleranceDbm:Number(M.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(v*100),"%)"]}),e.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:v,onChange:M=>T(Number(M.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(os,{children:[e.jsx("div",{className:"sm:hidden",children:ae&&e.jsx(ge,{template:"auto",children:e.jsx(le,{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 ",se.label," data..."]}),r.loadProgress&&e.jsxs("p",{className:"type-data-xs text-fg-muted mt-0.5",children:[r.loadProgress.loaded.toLocaleString()," packets (",r.loadProgress.percent,"%)"]})]})]})})})}),o?e.jsxs(e.Fragment,{children:[e.jsx(ge,{template:"hero-auto",children:e.jsx(le,{neomorphic:!0,isLoaded:o,skeletonType:"chart",children:o&&e.jsxs(e.Fragment,{children:[e.jsx(Ne,{icon:e.jsx(Se,{}),title:"Packet Analyzer",badge:se.label,badgeColor:"zinc",stackActionsOnMobile:!0,actions:e.jsxs("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:[P==="stats"&&e.jsx(qs,{enabled:H,onChange:V,anomalyCount:S.length,showTuning:O,onTuningChange:N}),e.jsx(Gs,{smoothing:P,onChange:z}),e.jsx(Us,{mode:k,onChange:L})]})}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(on,{packets:Le,allPackets:a,startTs:ue,endTs:pe,parentStartTs:Q.start,parentEndTs:Q.end,bucketCount:_e,radioConfig:ce??void 0,mode:k,smoothing:P,noiseFloorAnomalies:S,showNoiseFloorOverlay:H,overlayOpacity:v,dotSize:W,dotOpacity:te/100})})]})})}),e.jsx(ge,{template:"auto",className:"relative z-10",children:e.jsx(le,{neomorphic:!0,noPadding:!0,isLoaded:o,className:"overflow-visible",children:o&&e.jsx(ps,{parentStartTs:Q.start,parentEndTs:Q.end,neighbors:A,filter:B,onChange:R,...P==="stats"?{scatterDotSize:W,onScatterDotSizeChange:q,scatterOpacity:te,onScatterOpacityChange:J}:{}})})}),e.jsxs(ge,{template:"panel",children:[e.jsx(we,{span:12,md:6,children:e.jsx(le,{neomorphic:!1,isLoaded:o,skeletonType:"chart",noPadding:o,className:"!bg-transparent !ring-0 !shadow-none !overflow-visible -mx-4 sm:mx-0 !px-0 !pr-0",children:o&&e.jsx(Xe,{children:e.jsx(fn,{neighbors:I,quickNeighbors:s,localLat:((me=(ie=t==null?void 0:t.config)==null?void 0:ie.repeater)==null?void 0:me.latitude)??0,localLon:((he=(de=t==null?void 0:t.config)==null?void 0:de.repeater)==null?void 0:he.longitude)??0,onStatsChange:j,title:"Link Quality",badge:se.label})})})}),e.jsx(we,{span:12,md:6,children:e.jsx(le,{neomorphic:!0,isLoaded:o,skeletonType:"chart",children:o&&e.jsxs(e.Fragment,{children:[e.jsx(Ne,{icon:e.jsx(ys,{}),title:"Network Composition",badge:se.label,badgeColor:"zinc"}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Xe,{children:e.jsx(bn,{neighbors:I})})})]})})})]}),e.jsxs(ge,{template:"panel",children:[e.jsx(we,{span:12,md:6,children:e.jsx(An,{})}),e.jsx(we,{span:12,md:6,children:e.jsx(En,{packets:a,rangeMinutes:Y,rangeHours:D,timeRangeLabel:se.label,isLoaded:o})})]}),e.jsx(ge,{template:"panel",children:e.jsx(we,{span:12,children:e.jsx(le,{neomorphic:!0,isLoaded:o,skeletonType:"chart",children:o&&e.jsxs(e.Fragment,{children:[e.jsx(Ne,{icon:e.jsx(es,{}),title:"NOISE FLOOR dBm",stackActionsOnMobile:!0,actions:w?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:w.min.toFixed(0)})]}),e.jsxs("span",{className:"type-data-xs text-fg-muted whitespace-nowrap",children:["avg ",e.jsx("span",{className:"data-box",children:w.avg.toFixed(0)})]}),e.jsxs("span",{className:"type-data-xs text-fg-muted whitespace-nowrap",children:["max ",e.jsx("span",{className:"data-box",children:w.max.toFixed(0)})]})]}):null}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Xe,{children:e.jsx(ts,{timestamps:$.timestamps,values:$.values,onStatsChange:g})})})]})})})})]}):e.jsx(ge,{template:"auto",children:e.jsx(le,{neomorphic:!0,className:"text-center py-12",children:e.jsx("div",{className:"animate-pulse text-fg-muted",children:"Loading statistics..."})})})]})]})}export{ca as default}; + `}),e.jsx("clipPath",{id:ue,children:e.jsx("circle",{cx:S,cy:A,r:I})})]}),(()=>{const u=I+oe.LABEL_INSET+12,E=f?"rgba(255, 255, 255, 0.12)":"rgba(0, 0, 0, 0.15)",C=f?"rgba(59, 130, 246, 0.4)":"rgba(59, 130, 246, 0.5)",_=6,F=16,X=4,K=[0,90,180,270],ee=[45,135,225,315];return e.jsxs("g",{className:"radar-frame","aria-hidden":"true",children:[e.jsx("circle",{cx:S,cy:A,r:u,fill:"none",stroke:E,strokeWidth:1,strokeDasharray:"2 6"}),ee.map(Z=>{const ie=Z*Math.PI/180,me=Math.cos(ie),de=Math.sin(ie),he=u+X,M=u+X+F,G=S+he*de,ye=A-he*me,Ie=S+M*de,He=A-M*me;return e.jsxs("g",{children:[e.jsx("line",{x1:G,y1:ye,x2:Ie,y2:He,stroke:C,strokeWidth:1}),e.jsx("line",{x1:Ie-4*me,y1:He-4*de,x2:Ie+4*me,y2:He+4*de,stroke:C,strokeWidth:1})]},`corner-${Z}`)}),K.map(Z=>{const ie=Z*Math.PI/180,me=S+(u-_)*Math.sin(ie),de=A-(u-_)*Math.cos(ie),he=S+(u+2)*Math.sin(ie),M=A-(u+2)*Math.cos(ie);return e.jsx("line",{x1:me,y1:de,x2:he,y2:M,stroke:E,strokeWidth:1},`tick-cardinal-${Z}`)}),ee.map(Z=>{const ie=Z*Math.PI/180,me=S+(u-4)*Math.sin(ie),de=A-(u-4)*Math.cos(ie),he=S+(u+1)*Math.sin(ie),M=A-(u+1)*Math.cos(ie);return e.jsx("line",{x1:me,y1:de,x2:he,y2:M,stroke:E,strokeWidth:1},`tick-intercardinal-${Z}`)})]})})(),(()=>{const E=[(I+oe.LABEL_INSET+4)/I,...ae.map(C=>Le(C)).filter(C=>C>.02&&C<=1.05).sort((C,_)=>_-C),0];return E.slice(0,-1).map((C,_)=>{const F=E[_+1],X=I*C,K=I*F,ee=X-K;return ee<=0||_%2!==0?null:e.jsx("circle",{cx:S,cy:A,r:(X+K)/2,fill:"none",stroke:"var(--subtle-fill)",strokeWidth:ee,opacity:.8},`band-${_}`)})})(),ae.map(u=>{const E=Le(u);if(E>1.05||E<.02)return null;const C=Ee.some(X=>X.km===u),_=S+I*E*pt,F=A-I*E*ft;return e.jsxs("g",{children:[e.jsx("circle",{cx:S,cy:A,r:I*E,fill:"none",stroke:B,strokeOpacity:R,strokeWidth:1}),C&&e.jsx("text",{x:_+4,y:F-2,textAnchor:"start",dominantBaseline:"auto",fill:m.secondary,fontSize:10,fontFamily:Be,children:De(u)})]},`ring-${u}`)}),["N","E","S","W"].map(u=>{const C={N:0,E:90,S:180,W:270}[u]*Math.PI/180;return e.jsx("line",{x1:S,y1:A,x2:S+I*Math.sin(C),y2:A-I*Math.cos(C),stroke:B,strokeOpacity:R,strokeWidth:1,strokeDasharray:"4 4"},u)}),["NE","SE","SW","NW"].map(u=>{const C={NE:45,SE:135,SW:225,NW:315}[u]*Math.PI/180;return e.jsx("line",{x1:S,y1:A,x2:S+I*Math.sin(C),y2:A-I*Math.cos(C),stroke:B,strokeOpacity:W,strokeWidth:1,strokeDasharray:"4 4"},`diag-${u}`)}),["N","E","S","W"].map(u=>{const E=fe(u),C=u==="E"?"end":u==="W"?"start":"middle",_=u==="N"?"hanging":u==="S"?"auto":"middle";return e.jsx("text",{x:E.x,y:E.y,textAnchor:C,dominantBaseline:_,fill:q,fontSize:oe.CARDINAL_FONT_SIZE,fontWeight:700,fontFamily:Be,"aria-hidden":"true",children:u},u)}),["NE","SE","SW","NW"].map(u=>{const E=fe(u),C=u==="NE"||u==="SE"?"end":"start",_=u==="NE"||u==="NW"?"hanging":"auto";return e.jsx("text",{x:E.x,y:E.y,textAnchor:C,dominantBaseline:_,fill:q,fontSize:oe.INTERCARDINAL_FONT_SIZE,fontWeight:600,fontFamily:Be,"aria-hidden":"true",children:u},u)}),e.jsx("circle",{cx:S,cy:A,r:oe.LOCAL_DOT_RADIUS,fill:N.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(#${ue})`,children:U.map(u=>{const E=D>0?u.distance/D*k:0;if(E>1)return null;const{x:C,y:_}=pe(u.bearing,E),F=u.snr!==null?gt(u.snr,O,T):"#808080",X=(o==null?void 0:o.hash)===u.hash,K=d.has(u.hash),ee=oe.DOT_RADIUS_HOVERED*1.5;return e.jsxs("g",{role:"img","aria-label":`${u.name}: ${u.distance.toFixed(1)}km ${u.bearing.toFixed(0)}°`,children:[K&&e.jsx("circle",{cx:C,cy:_,r:ee,fill:"none",stroke:f?"rgba(255,255,255,0.9)":"rgba(0,0,0,0.7)",strokeWidth:2,className:"neighbor-blink-ring"}),X&&e.jsx("circle",{cx:C,cy:_,r:ee,fill:F,opacity:.3}),e.jsx("circle",{cx:C,cy:_,r:X?oe.DOT_RADIUS_HOVERED:oe.DOT_RADIUS,fill:F,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(u),onMouseLeave:()=>_e(null)})]},u.hash)})})]})]}),o&&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:o.name}),e.jsx("div",{className:"type-data-xs text-fg-secondary",children:o.hash}),o.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:gt(o.snr,O,T)},children:[o.snr.toFixed(1)," dB"]}),e.jsxs("span",{className:"text-fg-secondary ml-1",children:["(",xn(o.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:[o.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:[o.bearing.toFixed(0),"°"]})]})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 px-1.5 py-2 flex-shrink-0 depth-raised radius-inset self-stretch",style:{width:"calc(100% / 6)"},children:[r&&e.jsxs("div",{className:"flex flex-col items-center gap-1 pb-2 border-b border-edge-subtle 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(ze,{className:"w-3.5 h-3.5"})}),l&&e.jsx(Fe,{color:"zinc",children:l})]}),e.jsx("span",{className:"type-micro text-center text-[10px] leading-tight",children:r})]}),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(u=>e.jsx("button",{onClick:()=>Re(u),"aria-pressed":j===u,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 ${j===u?"bg-sys-blue/20 text-sys-blue":"bg-subtle-fill/80 text-fg-secondary hover:bg-subtle-fill-strong hover:text-fg-primary"}`,children:u},u))})]})]}):e.jsxs("div",{ref:H,className:"flex flex-col items-center justify-center h-full text-fg-secondary",children:[e.jsx(ze,{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 fn=c.memo(pn),Ye={repeater:"var(--sys-blue)",companion:"var(--sys-cyan)",room_server:"var(--sys-indigo)"};function gn(t){if(t.contact_type){const n=t.contact_type.toLowerCase();if(n==="repeater"||n==="rep")return"repeater";if(n==="room server"||n==="room_server"||n==="room"||n==="server")return"room_server";if(n==="companion"||n==="client"||n==="cli")return"companion"}return t.is_repeater?"repeater":"companion"}function yn({neighbors:t}){const n=c.useMemo(()=>{const s={repeater:0,companion:0,room_server:0};for(const r of Object.values(t)){const l=gn(r);s[l]=(s[l]||0)+1}const a=Object.values(s).reduce((r,l)=>r+l,0);return{items:[{label:"Repeaters",count:s.repeater,percent:0,color:Ye.repeater},{label:"Companions",count:s.companion,percent:0,color:Ye.companion},{label:"Room Servers",count:s.room_server,percent:0,color:Ye.room_server}].map(r=>({...r,percent:a>0?r.count/a*100:0})).filter(r=>r.count>0).sort((r,l)=>l.count-r.count),total:a}},[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(s=>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:s.label}),e.jsxs("span",{className:"type-data-sm text-fg-secondary tabular-nums",children:[s.count," ",e.jsxs("span",{className:"text-fg-secondary/60",children:["(",s.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:`${s.percent}%`,backgroundColor:s.color,minWidth:s.count>0?"4px":"0"}})})]},s.label))}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-edge-subtle",children:[e.jsx("span",{className:"type-data-xs text-fg-secondary",children:"Total Nodes"}),e.jsx("span",{className:"type-data-sm text-fg-primary font-medium tabular-nums",children:n.total})]})]})}const bn=c.memo(yn);function Xe({children:t,minHeight:n="100%",rootMargin:s="200px 0px",keepMounted:a=!0,className:i=""}){const r=c.useRef(null),[l,x]=c.useState(!1),[o,p]=c.useState(!1);c.useEffect(()=>{const h=r.current;if(!h)return;const w=new IntersectionObserver(([g])=>{const j=g.isIntersecting;p(j),j&&x(!0)},{rootMargin:s,threshold:0});return w.observe(h),()=>{w.disconnect()}},[s]);const d=o||a&&l;return e.jsx("div",{ref:r,className:`h-full w-full ${i}`,style:{minHeight:n},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 kt=[{target:"DisambiguationCard",fn:"disambiguation.collisions",minStage:2}];tt(kt);const jn=.9,Nn=.7,vn=.5,Sn=10,kn=25,Pe={excellent:"text-signal-excellent",good:"text-signal-good",fair:"text-signal-fair",poor:"text-sys-blue"},wn={excellent:"bg-signal-excellent/10",good:"bg-signal-good/10",fair:"bg-signal-fair/10",poor:"bg-sys-blue/10"};function Mn(t){return t>=jn?"excellent":t>=Nn?"good":t>=vn?"fair":"poor"}function Cn(t){return t<=Sn?"excellent":t<=kn?"good":"poor"}function An(){et(kt);const t=Ht(),n=Bt(),[s,a]=c.useState(null),i=c.useCallback((d,h)=>{a({prefix:d,candidateHashes:h})},[]),r=c.useCallback(()=>{a(null)},[]);if(!n)return e.jsxs(le,{neomorphic:!0,children:[e.jsx(Ne,{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($t,{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 l=Mn(t.avgConfidence),x=Cn(t.collisionRate),o=l==="poor"||x==="poor"?"poor":l==="fair"||x==="fair"?"fair":l==="good"||x==="good"?"good":"excellent",p=o==="excellent"||o==="good"?it:Ze;return e.jsxs(le,{neomorphic:!0,className:"flex flex-col overflow-hidden",children:[e.jsx(Ne,{icon:e.jsx(rt,{}),title:"Prefix Conflicts",badgeColor:"zinc",actions:o==="poor"?e.jsxs(Fe,{color:"red",children:[e.jsx(Ze,{className:"w-3 h-3"}),"Needs Attention"]}):e.jsxs("div",{className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full ${wn[o]}`,children:[e.jsx(p,{className:`w-3.5 h-3.5 ${Pe[o]}`}),e.jsx("span",{className:`type-data-xs font-medium ${Pe[o]}`,children:o==="excellent"?"Excellent":o==="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 py-3 sm:py-4",children:[e.jsxs("div",{className:"flex-1 flex flex-col radius-inner depth-stroke-raised bg-subtle-fill/80 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(Oe,{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-raised bg-subtle-fill/80 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(Oe,{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-raised bg-subtle-fill/80 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(Oe,{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-2",children:[e.jsx("div",{className:"type-data-xs text-fg-secondary mb-1.5",children:"Problem Prefixes"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 content-start",children:t.highCollisionPrefixes.map(({prefix:d,candidateCount:h,candidateHashes:w})=>e.jsxs("button",{type:"button",onClick:()=>i(d,w),className:"inline-flex items-center gap-0.5 group",title:`${h} candidates - click to explore`,children:[e.jsx(ls,{children:d}),e.jsxs("span",{className:"text-fg-muted type-data-xs group-hover:text-fg-secondary transition-colors",children:["×",h]})]},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(it,{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 flex-col sm:flex-row sm:items-center gap-2 sm:gap-4 mt-auto pt-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2 cursor-help",title:"Average confidence score across all disambiguated prefixes. Higher = more certain node identification.",children:[e.jsx("span",{className:"type-data-xs text-fg-secondary",children:"Confidence"}),e.jsxs("span",{className:`data-box ${Pe[l]}`,children:[(t.avgConfidence*100).toFixed(1),"%"]})]}),e.jsxs("div",{className:"flex items-center gap-2 cursor-help",title:"Percentage of 2-character prefixes that match multiple known nodes. Lower is better.",children:[e.jsx("span",{className:"type-data-xs text-fg-secondary",children:"Collisions"}),e.jsxs("span",{className:`data-box ${Pe[x]}`,children:[t.collisionRate.toFixed(1),"%"]})]})]})]}),e.jsx(ms,{isOpen:!!s,prefix:(s==null?void 0:s.prefix)||"",candidateHashes:(s==null?void 0:s.candidateHashes)||[],onClose:r})]})}const wt=[{target:"PacketHealth",fn:"type",minStage:1},{target:"PacketHealth",fn:"duplicates",minStage:1}];tt(wt);const _n=new Set(["Duplicate","Empty payload","Path too long","Unknown"]),Me=24;function Rn(t,n){const s=Date.now()/1e3,a=n*60,i=s-a,r=a/Me,l=new Array(Me).fill(0),x=new Array(Me).fill(0);let o=0,p=0,d=0,h=0;for(const g of t){if(g.packet_origin==="tx_local")continue;const j=g.timestamp;if(js)continue;o++;const b=Math.min(Me-1,Math.floor((j-i)/r));x[b]++,g.transmitted||g.packet_origin==="tx_forward"?(p++,l[b]++):(g.is_duplicate||g.drop_reason==="Duplicate")&&d++,g.drop_reason&&_n.has(g.drop_reason)&&h++}const w=[];for(let g=0;g0?Math.round(b/j*100):0,timestamp:(i+g*r)*1e3})}return{totalRx:o,forwarded:p,duplicates:d,waste:h,efficiency:o>0?p/o*100:0,duplicateRate:o>0?d/o*100:0,wasteRate:o>0?h/o*100:0,sparkline:w}}function Ln(t){return t>=90?"excellent":t>=75?"good":t>=60?"fair":"poor"}const Dn={excellent:"bg-status-success",good:"bg-sys-blue",fair:"bg-status-warning",poor:"bg-status-danger"};function En({packets:t,rangeMinutes:n,rangeHours:s,timeRangeLabel:a,isLoaded:i=!0}){et(wt);const r=c.useMemo(()=>Rn(t,n),[t,n]),[l,x]=c.useState(null),o=c.useCallback(async()=>{try{const h=await zt(s);h.success&&h.data&&x(h.data.count)}catch{}},[s]);c.useEffect(()=>{o()},[o]);const p=Ln(r.efficiency),d=r.totalRx>0;return e.jsx(le,{neomorphic:!0,isLoaded:i,skeletonType:"chart",children:i&&e.jsxs(e.Fragment,{children:[e.jsx(Ne,{icon:e.jsx(us,{}),title:"Packet Health",badge:a,badgeColor:"zinc"}),e.jsx(Wt,{children:e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsxs("div",{className:"type-data-xl text-fg-primary",children:[d?e.jsx(Oe,{value:Math.round(r.efficiency*10)/10,className:"font-mono tabular-nums",priority:"medium",format:{minimumFractionDigits:1,maximumFractionDigits:1}}):e.jsx("span",{className:"opacity-30",children:"—"}),e.jsx("span",{className:"type-data-sm text-fg-muted ml-0.5",children:"%"})]}),d&&e.jsx("div",{className:`w-2 h-2 rounded-full ${Dn[p]}`})]}),e.jsx("div",{className:"type-micro mb-2 cursor-help",title:"Forwarded packets / total received. CRC failures, garbled packets, and RF collisions that destroy packets before reaching software are not included in this ratio — see CRC Errors for hardware-level failures.",children:"FORWARDING RATE"}),e.jsx("div",{className:"flex-1 min-h-[28px] max-h-[48px] mb-2",children:e.jsx(ds,{data:r.sparkline,width:9999,height:36,color:"var(--sys-blue)",className:"w-full"})}),e.jsxs("div",{className:"flex gap-2 sm:gap-3 mt-auto",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Dupes"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:d?`${r.duplicateRate.toFixed(1)}%`:"—"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Waste"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:d?`${r.wasteRate.toFixed(1)}%`:"—"})]}),l!==null&&l>0&&e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"data-box-label flex items-center gap-1",children:[e.jsx(Ze,{className:"w-3 h-3 text-status-warning"}),"CRC"]}),e.jsx("div",{className:"data-box data-box-fill data-box-left text-status-warning",children:l})]})]})]})})]})})}function la(){var De,ke,Ee,Te,u,E,C,_,F,X,K,ee,Z,ie,me,de,he;const t=Ut(),n=Gt(),s=qt(),a=Vt(),i=Kt(),r=Yt(),l=t!==null&&i,x=c.useRef(!1);l&&!x.current&&(x.current=!0);const o=x.current,p=Xt(),d=Zt(),h=Qt(),[w,g]=c.useState(null),[,j]=c.useState(null),[b]=c.useState(null),[k,L]=c.useState(()=>{const M=localStorage.getItem("statistics-view-mode");return M==="share"||M==="airtime"?M:"airtime"});c.useEffect(()=>{localStorage.setItem("statistics-view-mode",k)},[k]);const[P,z]=c.useState(()=>{const M=localStorage.getItem("statistics-smoothing-mode");return["ema","ultra","mosaic","stats","trend"].includes(M)?M:"stats"});c.useEffect(()=>{localStorage.setItem("statistics-smoothing-mode",P)},[P]);const[H,V]=c.useState(!1),[O,N]=c.useState(!1),[m,f]=c.useState(jt),[v,T]=c.useState(.5),[B,R]=c.useState(hs),[W,q]=c.useState(.8),[te,J]=c.useState(50),U=c.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]),D=$e[U].hours,Y=D*60,se=$e[U],re=at(D),ae=r.isBackgroundLoading,ne=c.useCallback(M=>{const ye={0:1,1:2,2:3,3:4,4:5,5:6,6:7,7:8,8:9,9:10}[M]??4;d(ye)},[d]),ce=c.useMemo(()=>{var G;if(!((G=t==null?void 0:t.config)!=null&&G.radio))return null;const M=t.config.radio;return{sf:M.spreading_factor??10,bw:M.bandwidth??25e4,cr:M.coding_rate??5,preamble:M.preamble_length??8}},[(ke=(De=t==null?void 0:t.config)==null?void 0:De.radio)==null?void 0:ke.spreading_factor,(Te=(Ee=t==null?void 0:t.config)==null?void 0:Ee.radio)==null?void 0:Te.bandwidth,(E=(u=t==null?void 0:t.config)==null?void 0:u.radio)==null?void 0:E.coding_rate,(_=(C=t==null?void 0:t.config)==null?void 0:C.radio)==null?void 0:_.preamble_length]),$=c.useMemo(()=>h.length===0?{timestamps:[],values:[]}:{timestamps:h.map(M=>M.timestamp),values:h.map(M=>M.noise_floor_dbm)},[h]),y=c.useMemo(()=>{if(h.length<10)return{anomalies:[],debug:void 0};const M=As(h,m);return{anomalies:M.anomalies,debug:M.debug}},[h,m]),S=y.anomalies,A=c.useMemo(()=>{const M=(t==null?void 0:t.neighbors)??{};return Object.fromEntries(Object.entries(M).filter(([G])=>!n.has(G)))},[t==null?void 0:t.neighbors,n]),I=c.useMemo(()=>{const M=Date.now()/1e3-D*3600;return Object.fromEntries(Object.entries(A).filter(([,G])=>G.last_seen>=M))},[A,D]),Q=c.useMemo(()=>{const M=Y*60/re,G=Math.floor(Date.now()/1e3),ye=Math.floor(G/M)*M;return{start:ye-Y*60,end:ye}},[Y,re]),ue=B.timeStart??Q.start,pe=B.timeEnd??Q.end,fe=(pe-ue)/3600,_e=at(fe),Re=fs(),Le=c.useMemo(()=>xs(a,B,Re,Q),[a,B,Re,Q]);return e.jsxs(rs,{children:[e.jsx(is,{title:"Statistics",icon:e.jsx(Jt,{}),controls:e.jsx(as,{ranges:$e,selectedIndex:U,onSelect:ne,isPending:ae})}),b&&e.jsx(le,{className:"border border-sys-red/50 bg-sys-red/10",children:e.jsx("p",{className:"text-sys-red",children:b})}),H&&O&&e.jsxs(le,{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:["(",se.label,")"]})]}),e.jsx("button",{onClick:()=>f(M=>({...M,useAbsoluteThresholds:!M.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:[((X=(F=y.debug)==null?void 0:F.baselineCutoff)==null?void 0:X.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:[((ee=(K=y.debug)==null?void 0:K.spikeCutoff)==null?void 0:ee.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:((Z=y.debug)==null?void 0:Z.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:S.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:M=>f(G=>({...G,baselineDbm:Number(M.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:M=>f(G=>({...G,spikeDbm:Number(M.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:M=>f(G=>({...G,mergeGapSeconds:Number(M.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:M=>f(G=>({...G,minSequenceLength:Number(M.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:M=>f(G=>({...G,similarityToleranceDbm:Number(M.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(v*100),"%)"]}),e.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:v,onChange:M=>T(Number(M.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:M=>f(G=>({...G,baselinePercentile:Number(M.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:M=>f(G=>({...G,spikePercentile:Number(M.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:M=>f(G=>({...G,mergeGapSeconds:Number(M.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:M=>f(G=>({...G,minSequenceLength:Number(M.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:M=>f(G=>({...G,similarityToleranceDbm:Number(M.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(v*100),"%)"]}),e.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.05",value:v,onChange:M=>T(Number(M.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(os,{children:[e.jsx("div",{className:"sm:hidden",children:ae&&e.jsx(ge,{template:"auto",children:e.jsx(le,{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 ",se.label," data..."]}),r.loadProgress&&e.jsxs("p",{className:"type-data-xs text-fg-muted mt-0.5",children:[r.loadProgress.loaded.toLocaleString()," packets (",r.loadProgress.percent,"%)"]})]})]})})})}),o?e.jsxs(e.Fragment,{children:[e.jsx(ge,{template:"hero-auto",children:e.jsx(le,{neomorphic:!0,isLoaded:o,skeletonType:"chart",children:o&&e.jsxs(e.Fragment,{children:[e.jsx(Ne,{icon:e.jsx(Se,{}),title:"Packet Analyzer",badge:se.label,badgeColor:"zinc",stackActionsOnMobile:!0,actions:e.jsxs("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:[P==="stats"&&e.jsx(qs,{enabled:H,onChange:V,anomalyCount:S.length,showTuning:O,onTuningChange:N}),e.jsx(Gs,{smoothing:P,onChange:z}),e.jsx(Us,{mode:k,onChange:L})]})}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(on,{packets:Le,allPackets:a,startTs:ue,endTs:pe,parentStartTs:Q.start,parentEndTs:Q.end,bucketCount:_e,radioConfig:ce??void 0,mode:k,smoothing:P,noiseFloorAnomalies:S,showNoiseFloorOverlay:H,overlayOpacity:v,dotSize:W,dotOpacity:te/100})})]})})}),e.jsx(ge,{template:"auto",className:"relative z-10",children:e.jsx(le,{neomorphic:!0,noPadding:!0,isLoaded:o,className:"overflow-visible",children:o&&e.jsx(ps,{parentStartTs:Q.start,parentEndTs:Q.end,neighbors:A,filter:B,onChange:R,...P==="stats"?{scatterDotSize:W,onScatterDotSizeChange:q,scatterOpacity:te,onScatterOpacityChange:J}:{}})})}),e.jsxs(ge,{template:"panel",children:[e.jsx(we,{span:12,md:6,children:e.jsx(le,{neomorphic:!1,isLoaded:o,skeletonType:"chart",noPadding:o,className:"!bg-transparent !ring-0 !shadow-none !overflow-visible -mx-4 sm:mx-0 !px-0 !pr-0",children:o&&e.jsx(Xe,{children:e.jsx(fn,{neighbors:I,quickNeighbors:s,localLat:((me=(ie=t==null?void 0:t.config)==null?void 0:ie.repeater)==null?void 0:me.latitude)??0,localLon:((he=(de=t==null?void 0:t.config)==null?void 0:de.repeater)==null?void 0:he.longitude)??0,onStatsChange:j,title:"Link Quality",badge:se.label})})})}),e.jsx(we,{span:12,md:6,children:e.jsx(le,{neomorphic:!0,isLoaded:o,skeletonType:"chart",children:o&&e.jsxs(e.Fragment,{children:[e.jsx(Ne,{icon:e.jsx(ys,{}),title:"Network Composition",badge:se.label,badgeColor:"zinc"}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Xe,{children:e.jsx(bn,{neighbors:I})})})]})})})]}),e.jsxs(ge,{template:"panel",children:[e.jsx(we,{span:12,md:6,children:e.jsx(An,{})}),e.jsx(we,{span:12,md:6,children:e.jsx(En,{packets:a,rangeMinutes:Y,rangeHours:D,timeRangeLabel:se.label,isLoaded:o})})]}),e.jsx(ge,{template:"panel",children:e.jsx(we,{span:12,children:e.jsx(le,{neomorphic:!0,isLoaded:o,skeletonType:"chart",children:o&&e.jsxs(e.Fragment,{children:[e.jsx(Ne,{icon:e.jsx(es,{}),title:"NOISE FLOOR dBm",stackActionsOnMobile:!0,actions:w?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:w.min.toFixed(0)})]}),e.jsxs("span",{className:"type-data-xs text-fg-muted whitespace-nowrap",children:["avg ",e.jsx("span",{className:"data-box",children:w.avg.toFixed(0)})]}),e.jsxs("span",{className:"type-data-xs text-fg-muted whitespace-nowrap",children:["max ",e.jsx("span",{className:"data-box",children:w.max.toFixed(0)})]})]}):null}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Xe,{children:e.jsx(ts,{timestamps:$.timestamps,values:$.values,onStatsChange:g})})})]})})})})]}):e.jsx(ge,{template:"auto",children:e.jsx(le,{neomorphic:!0,className:"text-center py-12",children:e.jsx("div",{className:"animate-pulse text-fg-muted",children:"Loading statistics..."})})})]})]})}export{la as default}; diff --git a/frontend/dist/assets/System-CWAaClFq.js b/frontend/dist/assets/System-Dl7BjZT4.js similarity index 95% rename from frontend/dist/assets/System-CWAaClFq.js rename to frontend/dist/assets/System-Dl7BjZT4.js index 0846baf8..a834f63d 100644 --- a/frontend/dist/assets/System-CWAaClFq.js +++ b/frontend/dist/assets/System-Dl7BjZT4.js @@ -1,4 +1,4 @@ -import{d as Y,c_ as A,cR as F,r as l,h as J,j as e,n as G,c as H,F as B,c$ as te,d0 as se,d1 as ne,d2 as re,d3 as ae,bZ as oe,B as le,d4 as ce,d5 as W}from"./index-C8IY8K2r.js";import{C as E,P as ie,a as de,B as me}from"./PageLayout-NQBVrM09.js";import{T as ue}from"./triangle-alert-8k00uu7o.js";import{a as xe,A as pe}from"./arrow-up-DbeeGdHO.js";import{N as fe}from"./network-DBkquEPb.js";import{A as O}from"./activity-2-g8m4_g.js";import{R as he}from"./refresh-cw-BqACEANM.js";import{R as $,C as L}from"./Grid-CEGkNRmt.js";/** +import{d as Y,d3 as A,cW as F,r as l,h as J,j as e,n as G,c as H,F as B,d4 as te,d5 as se,d6 as ne,d7 as re,d8 as ae,c0 as oe,B as le,d9 as ce,da as W}from"./index-BwGHI0A_.js";import{C as E,P as ie,a as de,B as me}from"./PageLayout-BIcqC04y.js";import{T as ue}from"./triangle-alert-B4kC1YDk.js";import{a as xe,A as pe}from"./arrow-up-DJuSVUZI.js";import{N as fe}from"./network-9doWJxcL.js";import{A as O}from"./activity-Dr_TPIps.js";import{R as he}from"./refresh-cw-DYpAqCT4.js";import{R as $,C as L}from"./Grid-BoZ-SJB7.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -13,4 +13,4 @@ import{d as Y,c_ as A,cR as F,r as l,h as J,j as e,n as G,c as H,F as B,c$ as te * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const be=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],Ne=Y("thermometer",be),P=[{pos:0,color:A(F.purple)},{pos:.25,color:A(F.indigo)},{pos:.5,color:A(F.cyan)},{pos:.75,color:A(F.amber)},{pos:1,color:A(F.red)}];function ve(t,s,o){const r=.45454545454545453,n=Math.pow(t.r/255,2.2),i=Math.pow(t.g/255,2.2),x=Math.pow(t.b/255,2.2),d=Math.pow(s.r/255,2.2),m=Math.pow(s.g/255,2.2),c=Math.pow(s.b/255,2.2);return{r:Math.round(Math.pow(n+o*(d-n),r)*255),g:Math.round(Math.pow(i+o*(m-i),r)*255),b:Math.round(Math.pow(x+o*(c-x),r)*255)}}function Q(t){const s=Math.max(0,Math.min(1,t));let o=P[0],a=P[P.length-1];for(let i=0;i=P[i].pos&&s<=P[i+1].pos){o=P[i],a=P[i+1];break}const r=a.pos-o.pos,n=r>0?(s-o.pos)/r:0;return ve(o.color,a.color,n)}const V=G.hero,Me=36;function X(){const t=getComputedStyle(document.documentElement);return{fontFamily:t.getPropertyValue("--font-data").trim()||'"JetBrains Mono", ui-monospace, monospace',textPrimary:t.getPropertyValue("--text-primary").trim()||"#FFFFFF",textMuted:t.getPropertyValue("--text-muted").trim()||"#727272",gridColor:t.getPropertyValue("--chart-grid").trim()||"rgba(255, 255, 255, 0.06)"}}function Re(t){const s=[],o=Math.max(0,V-t.length);for(let r=0;ri+(u+.5)*R,f=u=>{const y=Math.min(Math.max(u/100,0),1);return x+m*(1-y)};n.save(),n.strokeStyle=r.textPrimary,n.globalAlpha=.1,n.lineWidth=1*c,n.setLineDash([4*c,4*c]);for(const u of[25,50,75]){const y=Math.round(f(u))+.5;n.beginPath(),n.moveTo(Math.round(i),y),n.lineTo(Math.round(i+d),y),n.stroke()}n.restore(),n.save(),n.font=`bold ${10*c}px ${r.fontFamily}`,n.fillStyle=r.textMuted,n.textBaseline="middle",n.textAlign="left";const p=8*c;for(const u of[0,25,50,75,100]){const y=f(u),v=Math.max(x+p,Math.min(x+m-p,y));n.fillText(`${u}%`,4*c,v)}n.restore(),n.save();for(let u=0;u0){const u=s[g-1];u!=null&&u.time&&(n.textAlign="right",n.fillText(u.time,j(g-1),N))}n.restore()}function Ce({data:t,cpuColor:s,memoryColor:o}){const a=l.useRef(null),r=l.useRef(null),n=l.useRef([]),i=l.useRef(s),x=l.useRef(o),d=l.useRef(null),m=l.useRef(t.length);l.useLayoutEffect(()=>{i.current=s,x.current=o}),l.useEffect(()=>{d.current=X()},[]);const c=l.useMemo(()=>Re(t),[t]);l.useLayoutEffect(()=>{n.current=c},[c]);const g=l.useMemo(()=>{const f=c.map(h=>h.timestamp),p=new Array(c.length).fill(1);return[f,p]},[c]),R=l.useMemo(()=>({hooks:{draw:f=>{const p=d.current||X();ke(f,n.current,i.current,x.current,p)}}}),[]),j=l.useMemo(()=>({width:400,height:240,padding:[4,8,4,Me],cursor:{show:!1,x:!1,y:!1,drag:{x:!1,y:!1},points:{show:!1}},scales:{x:{time:!1},y:{range:[0,100]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1}],plugins:[R]}),[R]);return l.useEffect(()=>{const f=a.current;if(!f||c.length===0)return;const p=m.current,h=t.length,w=Math.abs(h-p);if(!(!r.current||w>50||p>0&&w/p>.2)&&r.current){r.current.setData(g),m.current=h;return}r.current&&r.current.destroy();const k=f.getBoundingClientRect(),u=Math.floor(k.width)||400,y=Math.floor(k.height)||240,v=new J({...j,width:u,height:y},g,f);return r.current=v,m.current=h,()=>{v.destroy(),r.current=null}},[j,g,c.length,t.length]),l.useEffect(()=>{const f=a.current;if(!f)return;const p=new ResizeObserver(h=>{const w=h[0];if(!w||!r.current)return;const{width:N,height:k}=w.contentRect;N>0&&k>0&&r.current.setSize({width:Math.floor(N),height:Math.floor(k)})});return p.observe(f),()=>{p.disconnect()}},[]),l.useEffect(()=>{r.current&&r.current.redraw()},[s,o,c]),t.length===0?e.jsx("div",{className:"flex-1 min-h-[180px] flex items-center justify-center text-fg-muted",children:"Collecting data..."}):e.jsx("div",{className:"relative flex-1 min-h-[180px]",children:e.jsx("div",{ref:a,className:"absolute inset-0 radius-inner overflow-hidden"})})}const Se=l.memo(Ce),_e=1024*1024;function Te(t,s,o,a,r){const n=t.ctx,{left:i,top:x,width:d,height:m}=t.bbox;if(d<=0||m<=0)return;const c=[...Array(Math.max(0,r-s.length)).fill(0),...s.slice(-r)],g=Math.max(...c,1),R=c.length,j=d/R,f=m*.03;n.save();for(let p=0;p{i.current=t,x.current=s,d.current=o,m.current=a});const c=l.useMemo(()=>{const j=Array.from({length:a},(p,h)=>h),f=new Array(a).fill(1);return[j,f]},[a]),g=l.useMemo(()=>({hooks:{draw:j=>{Te(j,i.current,x.current,d.current,m.current)}}}),[]),R=l.useMemo(()=>({width:400,height:40,padding:[0,0,0,0],legend:{show:!1},cursor:{show:!1,x:!1,y:!1,drag:{x:!1,y:!1},points:{show:!1}},scales:{x:{time:!1},y:{range:[0,1]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1,label:""}],plugins:[g]}),[g]);return l.useEffect(()=>{const j=r.current;if(!j)return;n.current&&n.current.destroy();const f=j.getBoundingClientRect(),p=Math.floor(f.width)||400,h=Math.floor(f.height)||40,w=new J({...R,width:p,height:h},c,j);return n.current=w,()=>{w.destroy(),n.current=null}},[R,c]),l.useEffect(()=>{const j=r.current;if(!j)return;const f=new ResizeObserver(p=>{const h=p[0];if(!h||!n.current)return;const{width:w,height:N}=h.contentRect;w>0&&N>0&&n.current.setSize({width:Math.floor(w),height:Math.floor(N)})});return f.observe(j),()=>{f.disconnect()}},[]),l.useEffect(()=>{n.current&&n.current.redraw()},[t,s,o]),e.jsx("div",{ref:r,className:"w-full h-full"})}const Z=l.memo(Pe),C={cold:30,normal:50,warm:65,hot:80},I={cpu:{warning:80,danger:95},memory:{warning:85,danger:95},temp:{warning:70,danger:85}},Ee=[{threshold:C.cold,color:"var(--sys-cyan)"},{threshold:C.normal,color:"var(--sys-blue)"},{threshold:C.warm,color:"var(--sys-indigo)"},{threshold:C.hot,color:"var(--signal-poor)"}];function Be(t){return t{const d=t>0?x.pos/t*100:0;return`${x.color} ${Math.min(d,100)}%`}).join(", ")})`}function U(t,s){return t>=s.danger?"danger":t>=s.warning?"warning":"none"}function Fe(t){let s="none";for(const o of Object.values(t)){const a=U(o,I.temp);if(a==="danger")return"danger";a==="warning"&&(s="warning")}return s}function K(t){let s,o;t>=1024*1024*1024?(s=t/(1024*1024*1024),o="GB/s"):t>=1024*1024?(s=t/(1024*1024),o="MB/s"):t>=1024?(s=t/1024,o="KB/s"):(s=t,o="B/s");let a;return s>=100?a=s.toFixed(0):(s>=10,a=s.toFixed(1)),`${a} ${o}`}function D(t){return t>=1024*1024*1024?{value:(t/(1024*1024*1024)).toFixed(1),unit:"GiB"}:t>=1024*1024?{value:(t/(1024*1024)).toFixed(1),unit:"MiB"}:t>=1024?{value:(t/1024).toFixed(1),unit:"KiB"}:{value:String(t),unit:"B"}}const z=l.memo(function({level:s}){return s==="none"?null:e.jsxs("span",{className:H("inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium",s==="danger"&&"bg-sys-red/20 text-sys-red",s==="warning"&&"bg-sys-indigo/20 text-sys-indigo"),children:[e.jsx(ue,{className:"w-3 h-3"}),s==="danger"?"High":"Warn"]})}),ee=l.memo(function({value:s,max:o=100,width:a=10,color:r="primary"}){const n=Math.min(s/o,1),i=Math.round(n*a),x=a-i,d="■".repeat(i),m="·".repeat(x),c={primary:"text-sys-blue",secondary:"text-sys-indigo",success:"text-sys-green",danger:"text-sys-red"}[r];return e.jsxs("span",{className:"font-mono text-[10px] tracking-tight",children:[e.jsx("span",{className:c,children:d}),e.jsx("span",{className:"text-fg-muted/40",children:m})]})}),He=l.memo(function({index:s,usage:o}){const a=o>90?"danger":o>70?"secondary":"primary";return e.jsxs("div",{className:"flex items-center gap-1 type-data-xs",children:[e.jsxs("span",{className:"text-fg-muted w-5",children:["C",s]}),e.jsx(ee,{value:o,width:8,color:a}),e.jsxs("span",{className:H("w-7 text-right tabular-nums",o>90?"text-sys-red":o>70?"text-sys-indigo":"text-sys-green"),children:[o.toFixed(0),"%"]})]})}),$e=l.memo(function({pid:s,name:o,cpu:a,mem:r,isTopCpu:n=!1,isTopMem:i=!1}){return e.jsxs("div",{className:"flex items-center gap-2 py-1 type-data-sm hover:bg-subtle-fill -mx-1 px-1 rounded",children:[e.jsx("span",{className:"text-fg-muted w-10 sm:w-14 tabular-nums",children:s}),e.jsx("span",{className:"flex-1 truncate text-fg-primary",children:o}),e.jsx("span",{className:"hidden sm:inline-flex",children:e.jsx(ee,{value:a,max:100,width:6,color:a>50?"danger":a>20?"secondary":"success"})}),e.jsx("span",{className:H("w-10 sm:w-12 text-right tabular-nums",n?"text-fg-primary":a>50?"text-sys-red":a>20?"text-sys-indigo":"text-fg-muted"),children:a.toFixed(1)}),e.jsx("span",{className:H("w-10 sm:w-12 text-right tabular-nums",i?"text-fg-primary":r>50?"text-sys-red":r>20?"text-sys-indigo":"text-fg-muted"),children:r.toFixed(1)})]})}),q=l.memo(function({value:s,label:o,min:a=20,max:r=100}){const n=Math.min(Math.max((s-a)/(r-a)*100,0),100),i=Be(s),x=r-a;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"type-data-sm text-fg-muted",children:o}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"type-data-sm text-fg-muted",children:i.text}),e.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded type-data-sm",children:[e.jsx("span",{className:i.color,children:s.toFixed(1)}),e.jsx("span",{className:"text-fg-primary",children:"°C"})]})]})]}),e.jsxs("div",{className:"relative h-3 rounded-full bg-subtle-fill/80 depth-stroke-inset overflow-hidden",children:[e.jsx("div",{className:"absolute inset-y-0 left-0 rounded-full transition-all duration-300 ease-out",style:{background:Ae(n,a,r),width:`${n}%`}}),e.jsx("div",{className:"absolute inset-0 flex items-center pointer-events-none",children:Ee.map(({threshold:d,color:m})=>{const c=(d-a)/x*100;return c<0||c>100?null:e.jsx("div",{className:"absolute w-px h-full",style:{left:`${c}%`,backgroundColor:m}},d)})})]})]})});l.memo(function({data:s,color:o,flipped:a=!1,fixedSlots:r}){const n=[...Array(Math.max(0,r-s.length)).fill(0),...s.slice(-r)],i=Math.max(...n,1),x=n.map(d=>d===0?0:Math.max(d/i*100,3));return e.jsx("div",{className:"w-full h-full flex items-end",style:{transform:a?"scaleY(-1)":void 0},children:x.map((d,m)=>e.jsx("div",{className:"flex-1 min-w-0",style:{height:d>0?`${d}%`:"0%",backgroundColor:d>0?o:"transparent"}},m))})});function Le({networkHistory:t,txRate:s,rxRate:o,totalBytesSent:a,totalBytesRecv:r,cpuColor:n,memoryColor:i,networkSlots:x}){return e.jsxs(E,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(B,{icon:e.jsx(fe,{}),title:"Network",actions:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(xe,{className:"w-3.5 h-3.5",style:{color:i}}),e.jsx("span",{className:"type-data-xs",style:{color:i},children:"TX"}),e.jsx("span",{className:"px-2 py-1 bg-subtle-fill-strong rounded type-data-sm text-fg-primary",children:K(s)})]})}),e.jsxs("div",{className:"flex flex-col h-[120px]",children:[e.jsx("div",{className:"h-[60px]",children:e.jsx(Z,{data:t.map((d,m,c)=>{if(m===0)return 0;const g=(d.timestamp-c[m-1].timestamp)/1e3;return g>0?(d.bytesSent-c[m-1].bytesSent)/g:0}),color:i,fixedSlots:x})}),e.jsx("div",{className:"h-[60px]",children:e.jsx(Z,{data:t.map((d,m,c)=>{if(m===0)return 0;const g=(d.timestamp-c[m-1].timestamp)/1e3;return g>0?(d.bytesRecv-c[m-1].bytesRecv)/g:0}),color:n,flipped:!0,fixedSlots:x})})]}),e.jsxs("div",{className:"pt-2 flex flex-wrap justify-between items-center gap-2 type-data-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsx("span",{className:"text-fg-muted",children:"Total"}),e.jsxs("span",{className:"px-1.5 sm:px-2 py-1 bg-subtle-fill-strong rounded tabular-nums",children:[e.jsx("span",{style:{color:i},children:D(a).value})," ",e.jsx("span",{className:"text-fg-muted",children:D(a).unit})]}),e.jsxs("span",{className:"px-1.5 sm:px-2 py-1 bg-subtle-fill-strong rounded tabular-nums",children:[e.jsx("span",{style:{color:n},children:D(r).value})," ",e.jsx("span",{className:"text-fg-muted",children:D(r).unit})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(pe,{className:"w-3.5 h-3.5",style:{color:n}}),e.jsx("span",{className:"type-data-xs",style:{color:n},children:"RX"}),e.jsx("span",{className:"px-1.5 sm:px-2 py-1 bg-subtle-fill-strong rounded tabular-nums text-fg-primary",children:K(o)})]})]})]})}const De=l.memo(Le);function Oe({temperatures:t}){return e.jsxs(E,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(B,{icon:e.jsx(Ne,{}),title:"Temperature",actions:t&&e.jsx(z,{level:Fe(t)})}),e.jsx("div",{className:"flex-1 flex flex-col justify-center min-h-0",children:t&&Object.keys(t).length>0?e.jsxs("div",{className:"space-y-3",children:[t.cpu_thermal!==void 0&&e.jsx(q,{value:t.cpu_thermal,label:"CPU",min:20,max:100}),Object.entries(t).filter(([s])=>s!=="cpu_thermal").slice(0,2).map(([s,o])=>e.jsx(q,{value:o,label:s.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase()),min:20,max:100},s))]}):e.jsxs("div",{className:"flex items-center justify-center text-fg-muted text-sm",children:[e.jsx(O,{className:"w-4 h-4 mr-2"}),"No sensors"]})})]})}const Ie=l.memo(Oe);function Ue({usagePercent:t,used:s,available:o,memoryColor:a}){return e.jsxs(E,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(B,{icon:e.jsx(O,{}),title:"Memory",actions:e.jsxs("span",{className:"px-2 py-0.5 bg-subtle-fill-strong rounded type-data",style:{color:a},children:[t.toFixed(0),"%"]})}),e.jsxs("div",{className:"flex-1 flex flex-col justify-center min-h-0",children:[e.jsxs("div",{className:"flex gap-1 h-12 radius-inner bg-subtle-fill/80 depth-stroke-inset overflow-hidden",children:[e.jsx("div",{className:"h-full transition-all duration-300 bg-sys-blue",style:{width:`${t}%`}}),e.jsx("div",{className:"h-full transition-all duration-300 bg-subtle-fill/80",style:{width:`${100-t}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between type-data-xs pt-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-sys-blue"}),e.jsx("span",{className:"text-fg-muted",children:"Used"}),e.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-fg-primary",children:[(s/(1024*1024)).toFixed(0)," MB"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-subtle-fill-strong depth-stroke-raised"}),e.jsx("span",{className:"text-fg-muted",children:"Avail"}),e.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-fg-muted",children:[(o/(1024*1024)).toFixed(0)," MB"]})]})]})]})]})}const ze=l.memo(Ue);function Ye({usagePercent:t,used:s,free:o,cpuColor:a}){return e.jsxs(E,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(B,{icon:e.jsx(we,{}),title:"Disk",actions:e.jsxs("span",{className:"px-2 py-0.5 bg-subtle-fill-strong rounded type-data",style:{color:a},children:[t.toFixed(0),"%"]})}),e.jsxs("div",{className:"flex-1 flex flex-col justify-center min-h-0",children:[e.jsxs("div",{className:"flex gap-1 h-12 radius-inner bg-subtle-fill/80 depth-stroke-inset overflow-hidden",children:[e.jsx("div",{className:"h-full transition-all duration-300 bg-sys-blue",style:{width:`${t}%`}}),e.jsx("div",{className:"h-full transition-all duration-300 bg-subtle-fill/80",style:{width:`${100-t}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between type-data-xs pt-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-sys-blue"}),e.jsx("span",{className:"text-fg-muted",children:"Used"}),e.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-fg-primary",children:[(s/(1024*1024*1024)).toFixed(1)," GB"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-subtle-fill-strong depth-stroke-raised"}),e.jsx("span",{className:"text-fg-muted",children:"Free"}),e.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-fg-muted",children:[(o/(1024*1024*1024)).toFixed(1)," GB"]})]})]})]})]})}const Ge=l.memo(Ye);function We({processes:t}){if(t.length===0)return null;const s=t.slice(0,10),o=Math.max(...s.map(r=>r.cpu_percent)),a=Math.max(...s.map(r=>r.memory_percent));return e.jsx(E,{neomorphic:!0,noPadding:!0,children:e.jsxs("div",{className:"px-4 py-3",children:[e.jsx(B,{icon:e.jsx(O,{}),title:"Processes"}),e.jsxs("div",{className:"flex items-center gap-2 py-1.5 type-data-sm text-fg-muted",children:[e.jsx("span",{className:"w-10 sm:w-14",children:"PID"}),e.jsx("span",{className:"flex-1",children:"Program"}),e.jsx("span",{className:"hidden sm:block w-[52px]"}),e.jsx("span",{className:"w-10 sm:w-12 text-right",children:"CPU%"}),e.jsx("span",{className:"w-10 sm:w-12 text-right",children:"MEM%"})]}),s.map(r=>e.jsx($e,{pid:r.pid,name:r.name,cpu:r.cpu_percent,mem:r.memory_percent,isTopCpu:r.cpu_percent===o&&o>0,isTopMem:r.memory_percent===a&&a>0},r.pid))]})})}const Ve=l.memo(We),Xe=G.hero;function Ze(){const[t,s]=l.useState(typeof window<"u"?window.matchMedia("(max-width: 767px)").matches:!1);return l.useEffect(()=>{const o=window.matchMedia("(max-width: 767px)");s(o.matches);const a=r=>s(r.matches);return o.addEventListener("change",a),()=>o.removeEventListener("change",a)},[]),t?G.hero:40}function rt(){var v;const t=te(),s=se(),o=ne(),a=re(),r=ae(),[n,i]=l.useState([]),[x,d]=l.useState(!1),[m,c]=l.useState([]),[g,R]=l.useState(0),[j,f]=l.useState(0),p=l.useRef(null),h=oe(),w=h.blue,N=h.amber,k=Ze();l.useEffect(()=>{if(!t)return;const b=Date.now(),M={timestamp:b,bytesRecv:t.network.bytes_recv,bytesSent:t.network.bytes_sent};if(p.current){const S=(b-p.current.timestamp)/1e3;if(S>0){const _=(M.bytesRecv-p.current.bytesRecv)/S,T=(M.bytesSent-p.current.bytesSent)/S;_>=0&&T>=0&&(R(_),f(T))}}p.current=M,c(S=>[...S,M].slice(-Xe))},[t]);const u=5e3;l.useEffect(()=>{let b=!0;const M=async()=>{var T;const _=await W();b&&_.success&&((T=_.data)!=null&&T.processes)&&i(_.data.processes)};M();const S=setInterval(M,u);return()=>{b=!1,clearInterval(S)}},[]);const y=async()=>{var M;d(!0),await a();const b=await W();b.success&&((M=b.data)!=null&&M.processes)&&i(b.data.processes),d(!1)};return e.jsxs(ie,{children:[e.jsx(de,{title:"System Stats",icon:e.jsx(ye,{}),controls:e.jsxs(le,{color:"muted",onClick:y,disabled:x,children:[e.jsx(he,{"data-slot":"icon",className:H(x&&"animate-spin")}),"Refresh"]})}),e.jsxs(me,{children:[o&&e.jsx(E,{className:"border border-sys-red/50 bg-sys-red/10",children:e.jsx("p",{className:"text-sys-red",children:o})}),s?e.jsx(E,{neomorphic:!0,className:"p-12 text-center",children:e.jsx("div",{className:"animate-pulse text-fg-muted",children:"Loading system stats..."})}):t?e.jsxs(e.Fragment,{children:[e.jsx($,{template:"hero",children:e.jsxs(E,{neomorphic:!0,className:"pb-2 sm:pb-3",children:[e.jsx(B,{icon:e.jsx(O,{}),title:"System Resources",stackActionsOnMobile:!0,actions:e.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-wrap",children:[((v=t.system)==null?void 0:v.uptime)&&e.jsx("span",{className:"px-2 py-0.5 bg-subtle-fill rounded type-data-sm text-fg-primary",children:ce(t.system.uptime)}),e.jsx(z,{level:U(t.cpu.usage_percent,I.cpu)}),e.jsx(z,{level:U(t.memory.usage_percent,I.memory)}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsx("span",{className:"type-data-sm text-fg-muted",children:"CPU"}),e.jsxs("span",{className:"text-sm sm:text-base font-mono font-semibold tabular-nums",style:{color:w},children:[t.cpu.usage_percent.toFixed(0),"%"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsx("span",{className:"type-data-sm text-fg-muted",children:"MEM"}),e.jsxs("span",{className:"text-sm sm:text-base font-mono font-semibold tabular-nums",style:{color:N},children:[t.memory.usage_percent.toFixed(0),"%"]})]})]})}),e.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:e.jsx(Se,{data:r,cpuColor:w,memoryColor:N})}),t.cpu.per_core_percent&&t.cpu.per_core_percent.length>0&&e.jsx("div",{className:"mt-3 pt-3 border-t border-edge-subtle",children:e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-8 gap-x-3 gap-y-0.5",children:t.cpu.per_core_percent.map((b,M)=>e.jsx(He,{index:M,usage:b},M))})})]})}),e.jsxs($,{template:"compact",children:[e.jsx(L,{span:12,md:6,children:e.jsx(De,{networkHistory:m,txRate:j,rxRate:g,totalBytesSent:t.network.bytes_sent,totalBytesRecv:t.network.bytes_recv,cpuColor:w,memoryColor:N,networkSlots:k})}),e.jsx(L,{span:12,md:6,children:e.jsx(Ie,{temperatures:t.temperatures})})]}),e.jsxs($,{template:"compact",children:[e.jsx(L,{span:12,sm:6,children:e.jsx(ze,{usagePercent:t.memory.usage_percent,used:t.memory.used,available:t.memory.available,memoryColor:N})}),e.jsx(L,{span:12,sm:6,children:e.jsx(Ge,{usagePercent:t.disk.usage_percent,used:t.disk.used,free:t.disk.free,cpuColor:w})})]}),e.jsx($,{template:"auto",children:e.jsx(Ve,{processes:n})})]}):null]})]})}export{rt as default}; + */const be=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],Ne=Y("thermometer",be),P=[{pos:0,color:A(F.purple)},{pos:.25,color:A(F.indigo)},{pos:.5,color:A(F.cyan)},{pos:.75,color:A(F.amber)},{pos:1,color:A(F.red)}];function ve(t,s,o){const r=.45454545454545453,n=Math.pow(t.r/255,2.2),i=Math.pow(t.g/255,2.2),x=Math.pow(t.b/255,2.2),d=Math.pow(s.r/255,2.2),m=Math.pow(s.g/255,2.2),c=Math.pow(s.b/255,2.2);return{r:Math.round(Math.pow(n+o*(d-n),r)*255),g:Math.round(Math.pow(i+o*(m-i),r)*255),b:Math.round(Math.pow(x+o*(c-x),r)*255)}}function Q(t){const s=Math.max(0,Math.min(1,t));let o=P[0],a=P[P.length-1];for(let i=0;i=P[i].pos&&s<=P[i+1].pos){o=P[i],a=P[i+1];break}const r=a.pos-o.pos,n=r>0?(s-o.pos)/r:0;return ve(o.color,a.color,n)}const V=G.hero,Me=36;function X(){const t=getComputedStyle(document.documentElement);return{fontFamily:t.getPropertyValue("--font-data").trim()||'"JetBrains Mono", ui-monospace, monospace',textPrimary:t.getPropertyValue("--text-primary").trim()||"#FFFFFF",textMuted:t.getPropertyValue("--text-muted").trim()||"#727272",gridColor:t.getPropertyValue("--chart-grid").trim()||"rgba(255, 255, 255, 0.06)"}}function Re(t){const s=[],o=Math.max(0,V-t.length);for(let r=0;ri+(u+.5)*R,f=u=>{const y=Math.min(Math.max(u/100,0),1);return x+m*(1-y)};n.save(),n.strokeStyle=r.textPrimary,n.globalAlpha=.1,n.lineWidth=1*c,n.setLineDash([4*c,4*c]);for(const u of[25,50,75]){const y=Math.round(f(u))+.5;n.beginPath(),n.moveTo(Math.round(i),y),n.lineTo(Math.round(i+d),y),n.stroke()}n.restore(),n.save(),n.font=`bold ${10*c}px ${r.fontFamily}`,n.fillStyle=r.textMuted,n.textBaseline="middle",n.textAlign="left";const p=8*c;for(const u of[0,25,50,75,100]){const y=f(u),v=Math.max(x+p,Math.min(x+m-p,y));n.fillText(`${u}%`,4*c,v)}n.restore(),n.save();for(let u=0;u0){const u=s[g-1];u!=null&&u.time&&(n.textAlign="right",n.fillText(u.time,j(g-1),N))}n.restore()}function Ce({data:t,cpuColor:s,memoryColor:o}){const a=l.useRef(null),r=l.useRef(null),n=l.useRef([]),i=l.useRef(s),x=l.useRef(o),d=l.useRef(null),m=l.useRef(t.length);l.useLayoutEffect(()=>{i.current=s,x.current=o}),l.useEffect(()=>{d.current=X()},[]);const c=l.useMemo(()=>Re(t),[t]);l.useLayoutEffect(()=>{n.current=c},[c]);const g=l.useMemo(()=>{const f=c.map(h=>h.timestamp),p=new Array(c.length).fill(1);return[f,p]},[c]),R=l.useMemo(()=>({hooks:{draw:f=>{const p=d.current||X();ke(f,n.current,i.current,x.current,p)}}}),[]),j=l.useMemo(()=>({width:400,height:240,padding:[4,8,4,Me],cursor:{show:!1,x:!1,y:!1,drag:{x:!1,y:!1},points:{show:!1}},scales:{x:{time:!1},y:{range:[0,100]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1}],plugins:[R]}),[R]);return l.useEffect(()=>{const f=a.current;if(!f||c.length===0)return;const p=m.current,h=t.length,w=Math.abs(h-p);if(!(!r.current||w>50||p>0&&w/p>.2)&&r.current){r.current.setData(g),m.current=h;return}r.current&&r.current.destroy();const k=f.getBoundingClientRect(),u=Math.floor(k.width)||400,y=Math.floor(k.height)||240,v=new J({...j,width:u,height:y},g,f);return r.current=v,m.current=h,()=>{v.destroy(),r.current=null}},[j,g,c.length,t.length]),l.useEffect(()=>{const f=a.current;if(!f)return;const p=new ResizeObserver(h=>{const w=h[0];if(!w||!r.current)return;const{width:N,height:k}=w.contentRect;N>0&&k>0&&r.current.setSize({width:Math.floor(N),height:Math.floor(k)})});return p.observe(f),()=>{p.disconnect()}},[]),l.useEffect(()=>{r.current&&r.current.redraw()},[s,o,c]),t.length===0?e.jsx("div",{className:"flex-1 min-h-[180px] flex items-center justify-center text-fg-muted",children:"Collecting data..."}):e.jsx("div",{className:"relative flex-1 min-h-[180px]",children:e.jsx("div",{ref:a,className:"absolute inset-0 radius-inner overflow-hidden"})})}const Se=l.memo(Ce),_e=1024*1024;function Te(t,s,o,a,r){const n=t.ctx,{left:i,top:x,width:d,height:m}=t.bbox;if(d<=0||m<=0)return;const c=[...Array(Math.max(0,r-s.length)).fill(0),...s.slice(-r)],g=Math.max(...c,1),R=c.length,j=d/R,f=m*.03;n.save();for(let p=0;p{i.current=t,x.current=s,d.current=o,m.current=a});const c=l.useMemo(()=>{const j=Array.from({length:a},(p,h)=>h),f=new Array(a).fill(1);return[j,f]},[a]),g=l.useMemo(()=>({hooks:{draw:j=>{Te(j,i.current,x.current,d.current,m.current)}}}),[]),R=l.useMemo(()=>({width:400,height:40,padding:[0,0,0,0],legend:{show:!1},cursor:{show:!1,x:!1,y:!1,drag:{x:!1,y:!1},points:{show:!1}},scales:{x:{time:!1},y:{range:[0,1]}},axes:[{show:!1},{show:!1}],series:[{},{show:!1,label:""}],plugins:[g]}),[g]);return l.useEffect(()=>{const j=r.current;if(!j)return;n.current&&n.current.destroy();const f=j.getBoundingClientRect(),p=Math.floor(f.width)||400,h=Math.floor(f.height)||40,w=new J({...R,width:p,height:h},c,j);return n.current=w,()=>{w.destroy(),n.current=null}},[R,c]),l.useEffect(()=>{const j=r.current;if(!j)return;const f=new ResizeObserver(p=>{const h=p[0];if(!h||!n.current)return;const{width:w,height:N}=h.contentRect;w>0&&N>0&&n.current.setSize({width:Math.floor(w),height:Math.floor(N)})});return f.observe(j),()=>{f.disconnect()}},[]),l.useEffect(()=>{n.current&&n.current.redraw()},[t,s,o]),e.jsx("div",{ref:r,className:"w-full h-full"})}const K=l.memo(Pe),C={cold:30,normal:50,warm:65,hot:80},I={cpu:{warning:80,danger:95},memory:{warning:85,danger:95},temp:{warning:70,danger:85}},Ee=[{threshold:C.cold,color:"var(--sys-cyan)"},{threshold:C.normal,color:"var(--sys-blue)"},{threshold:C.warm,color:"var(--sys-indigo)"},{threshold:C.hot,color:"var(--signal-poor)"}];function Be(t){return t{const d=t>0?x.pos/t*100:0;return`${x.color} ${Math.min(d,100)}%`}).join(", ")})`}function U(t,s){return t>=s.danger?"danger":t>=s.warning?"warning":"none"}function Fe(t){let s="none";for(const o of Object.values(t)){const a=U(o,I.temp);if(a==="danger")return"danger";a==="warning"&&(s="warning")}return s}function Z(t){let s,o;t>=1024*1024*1024?(s=t/(1024*1024*1024),o="GB/s"):t>=1024*1024?(s=t/(1024*1024),o="MB/s"):t>=1024?(s=t/1024,o="KB/s"):(s=t,o="B/s");let a;return s>=100?a=s.toFixed(0):(s>=10,a=s.toFixed(1)),`${a} ${o}`}function D(t){return t>=1024*1024*1024?{value:(t/(1024*1024*1024)).toFixed(1),unit:"GiB"}:t>=1024*1024?{value:(t/(1024*1024)).toFixed(1),unit:"MiB"}:t>=1024?{value:(t/1024).toFixed(1),unit:"KiB"}:{value:String(t),unit:"B"}}const z=l.memo(function({level:s}){return s==="none"?null:e.jsxs("span",{className:H("inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-medium",s==="danger"&&"bg-sys-red/20 text-sys-red",s==="warning"&&"bg-sys-indigo/20 text-sys-indigo"),children:[e.jsx(ue,{className:"w-3 h-3"}),s==="danger"?"High":"Warn"]})}),ee=l.memo(function({value:s,max:o=100,width:a=10,color:r="primary"}){const n=Math.min(s/o,1),i=Math.round(n*a),x=a-i,d="■".repeat(i),m="·".repeat(x),c={primary:"text-sys-blue",secondary:"text-sys-indigo",success:"text-sys-green",danger:"text-sys-red"}[r];return e.jsxs("span",{className:"font-mono text-[10px] tracking-tight",children:[e.jsx("span",{className:c,children:d}),e.jsx("span",{className:"text-fg-muted/40",children:m})]})}),He=l.memo(function({index:s,usage:o}){const a=o>90?"danger":o>70?"secondary":"primary";return e.jsxs("div",{className:"flex items-center gap-1 type-data-xs",children:[e.jsxs("span",{className:"text-fg-muted w-5",children:["C",s]}),e.jsx(ee,{value:o,width:8,color:a}),e.jsxs("span",{className:H("w-7 text-right tabular-nums",o>90?"text-sys-red":o>70?"text-sys-indigo":"text-sys-green"),children:[o.toFixed(0),"%"]})]})}),$e=l.memo(function({pid:s,name:o,cpu:a,mem:r,isTopCpu:n=!1,isTopMem:i=!1}){return e.jsxs("div",{className:"flex items-center gap-2 py-1 type-data-sm hover:bg-subtle-fill -mx-1 px-1 rounded",children:[e.jsx("span",{className:"text-fg-muted w-10 sm:w-14 tabular-nums",children:s}),e.jsx("span",{className:"flex-1 truncate text-fg-primary",children:o}),e.jsx("span",{className:"hidden sm:inline-flex",children:e.jsx(ee,{value:a,max:100,width:6,color:a>50?"danger":a>20?"secondary":"success"})}),e.jsx("span",{className:H("w-10 sm:w-12 text-right tabular-nums",n?"text-fg-primary":a>50?"text-sys-red":a>20?"text-sys-indigo":"text-fg-muted"),children:a.toFixed(1)}),e.jsx("span",{className:H("w-10 sm:w-12 text-right tabular-nums",i?"text-fg-primary":r>50?"text-sys-red":r>20?"text-sys-indigo":"text-fg-muted"),children:r.toFixed(1)})]})}),q=l.memo(function({value:s,label:o,min:a=20,max:r=100}){const n=Math.min(Math.max((s-a)/(r-a)*100,0),100),i=Be(s),x=r-a;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"type-data-sm text-fg-muted",children:o}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"type-data-sm text-fg-muted",children:i.text}),e.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded type-data-sm",children:[e.jsx("span",{className:i.color,children:s.toFixed(1)}),e.jsx("span",{className:"text-fg-primary",children:"°C"})]})]})]}),e.jsxs("div",{className:"relative h-3 rounded-full bg-subtle-fill/80 depth-stroke-inset overflow-hidden",children:[e.jsx("div",{className:"absolute inset-y-0 left-0 rounded-full transition-all duration-300 ease-out",style:{background:Ae(n,a,r),width:`${n}%`}}),e.jsx("div",{className:"absolute inset-0 flex items-center pointer-events-none",children:Ee.map(({threshold:d,color:m})=>{const c=(d-a)/x*100;return c<0||c>100?null:e.jsx("div",{className:"absolute w-px h-full",style:{left:`${c}%`,backgroundColor:m}},d)})})]})]})});l.memo(function({data:s,color:o,flipped:a=!1,fixedSlots:r}){const n=[...Array(Math.max(0,r-s.length)).fill(0),...s.slice(-r)],i=Math.max(...n,1),x=n.map(d=>d===0?0:Math.max(d/i*100,3));return e.jsx("div",{className:"w-full h-full flex items-end",style:{transform:a?"scaleY(-1)":void 0},children:x.map((d,m)=>e.jsx("div",{className:"flex-1 min-w-0",style:{height:d>0?`${d}%`:"0%",backgroundColor:d>0?o:"transparent"}},m))})});function Le({networkHistory:t,txRate:s,rxRate:o,totalBytesSent:a,totalBytesRecv:r,cpuColor:n,memoryColor:i,networkSlots:x}){return e.jsxs(E,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(B,{icon:e.jsx(fe,{}),title:"Network",actions:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(xe,{className:"w-3.5 h-3.5",style:{color:i}}),e.jsx("span",{className:"type-data-xs",style:{color:i},children:"TX"}),e.jsx("span",{className:"px-2 py-1 bg-subtle-fill-strong rounded type-data-sm text-fg-primary",children:Z(s)})]})}),e.jsxs("div",{className:"flex flex-col h-[120px]",children:[e.jsx("div",{className:"h-[60px]",children:e.jsx(K,{data:t.map((d,m,c)=>{if(m===0)return 0;const g=(d.timestamp-c[m-1].timestamp)/1e3;return g>0?(d.bytesSent-c[m-1].bytesSent)/g:0}),color:i,fixedSlots:x})}),e.jsx("div",{className:"h-[60px]",children:e.jsx(K,{data:t.map((d,m,c)=>{if(m===0)return 0;const g=(d.timestamp-c[m-1].timestamp)/1e3;return g>0?(d.bytesRecv-c[m-1].bytesRecv)/g:0}),color:n,flipped:!0,fixedSlots:x})})]}),e.jsxs("div",{className:"pt-2 flex flex-wrap justify-between items-center gap-2 type-data-sm",children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsx("span",{className:"text-fg-muted",children:"Total"}),e.jsxs("span",{className:"px-1.5 sm:px-2 py-1 bg-subtle-fill-strong rounded tabular-nums",children:[e.jsx("span",{style:{color:i},children:D(a).value})," ",e.jsx("span",{className:"text-fg-muted",children:D(a).unit})]}),e.jsxs("span",{className:"px-1.5 sm:px-2 py-1 bg-subtle-fill-strong rounded tabular-nums",children:[e.jsx("span",{style:{color:n},children:D(r).value})," ",e.jsx("span",{className:"text-fg-muted",children:D(r).unit})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(pe,{className:"w-3.5 h-3.5",style:{color:n}}),e.jsx("span",{className:"type-data-xs",style:{color:n},children:"RX"}),e.jsx("span",{className:"px-1.5 sm:px-2 py-1 bg-subtle-fill-strong rounded tabular-nums text-fg-primary",children:Z(o)})]})]})]})}const De=l.memo(Le);function Oe({temperatures:t}){return e.jsxs(E,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(B,{icon:e.jsx(Ne,{}),title:"Temperature",actions:t&&e.jsx(z,{level:Fe(t)})}),e.jsx("div",{className:"flex-1 flex flex-col justify-center min-h-0",children:t&&Object.keys(t).length>0?e.jsxs("div",{className:"space-y-3",children:[t.cpu_thermal!==void 0&&e.jsx(q,{value:t.cpu_thermal,label:"CPU",min:20,max:100}),Object.entries(t).filter(([s])=>s!=="cpu_thermal").slice(0,2).map(([s,o])=>e.jsx(q,{value:o,label:s.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase()),min:20,max:100},s))]}):e.jsxs("div",{className:"flex items-center justify-center text-fg-muted text-sm",children:[e.jsx(O,{className:"w-4 h-4 mr-2"}),"No sensors"]})})]})}const Ie=l.memo(Oe);function Ue({usagePercent:t,used:s,available:o,memoryColor:a}){return e.jsxs(E,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(B,{icon:e.jsx(O,{}),title:"Memory",actions:e.jsxs("span",{className:"px-2 py-0.5 bg-subtle-fill-strong rounded type-data",style:{color:a},children:[t.toFixed(0),"%"]})}),e.jsxs("div",{className:"flex-1 flex flex-col justify-center min-h-0",children:[e.jsxs("div",{className:"flex gap-1 h-12 radius-inner bg-subtle-fill/80 depth-stroke-inset overflow-hidden",children:[e.jsx("div",{className:"h-full transition-all duration-300 bg-sys-blue",style:{width:`${t}%`}}),e.jsx("div",{className:"h-full transition-all duration-300 bg-subtle-fill/80",style:{width:`${100-t}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between type-data-xs pt-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-sys-blue"}),e.jsx("span",{className:"text-fg-muted",children:"Used"}),e.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-fg-primary",children:[(s/(1024*1024)).toFixed(0)," MB"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-subtle-fill-strong depth-stroke-raised"}),e.jsx("span",{className:"text-fg-muted",children:"Avail"}),e.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-fg-muted",children:[(o/(1024*1024)).toFixed(0)," MB"]})]})]})]})]})}const ze=l.memo(Ue);function Ye({usagePercent:t,used:s,free:o,cpuColor:a}){return e.jsxs(E,{neomorphic:!0,className:"flex flex-col",children:[e.jsx(B,{icon:e.jsx(we,{}),title:"Disk",actions:e.jsxs("span",{className:"px-2 py-0.5 bg-subtle-fill-strong rounded type-data",style:{color:a},children:[t.toFixed(0),"%"]})}),e.jsxs("div",{className:"flex-1 flex flex-col justify-center min-h-0",children:[e.jsxs("div",{className:"flex gap-1 h-12 radius-inner bg-subtle-fill/80 depth-stroke-inset overflow-hidden",children:[e.jsx("div",{className:"h-full transition-all duration-300 bg-sys-blue",style:{width:`${t}%`}}),e.jsx("div",{className:"h-full transition-all duration-300 bg-subtle-fill/80",style:{width:`${100-t}%`}})]}),e.jsxs("div",{className:"flex items-center justify-between type-data-xs pt-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-sys-blue"}),e.jsx("span",{className:"text-fg-muted",children:"Used"}),e.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-fg-primary",children:[(s/(1024*1024*1024)).toFixed(1)," GB"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-sm bg-subtle-fill-strong depth-stroke-raised"}),e.jsx("span",{className:"text-fg-muted",children:"Free"}),e.jsxs("span",{className:"px-1.5 py-0.5 bg-subtle-fill-strong rounded tabular-nums text-fg-muted",children:[(o/(1024*1024*1024)).toFixed(1)," GB"]})]})]})]})]})}const Ge=l.memo(Ye);function We({processes:t}){if(t.length===0)return null;const s=t.slice(0,10),o=Math.max(...s.map(r=>r.cpu_percent)),a=Math.max(...s.map(r=>r.memory_percent));return e.jsx(E,{neomorphic:!0,noPadding:!0,children:e.jsxs("div",{className:"px-4 py-3",children:[e.jsx(B,{icon:e.jsx(O,{}),title:"Processes"}),e.jsxs("div",{className:"flex items-center gap-2 py-1.5 type-data-sm text-fg-muted",children:[e.jsx("span",{className:"w-10 sm:w-14",children:"PID"}),e.jsx("span",{className:"flex-1",children:"Program"}),e.jsx("span",{className:"hidden sm:block w-[52px]"}),e.jsx("span",{className:"w-10 sm:w-12 text-right",children:"CPU%"}),e.jsx("span",{className:"w-10 sm:w-12 text-right",children:"MEM%"})]}),s.map(r=>e.jsx($e,{pid:r.pid,name:r.name,cpu:r.cpu_percent,mem:r.memory_percent,isTopCpu:r.cpu_percent===o&&o>0,isTopMem:r.memory_percent===a&&a>0},r.pid))]})})}const Ve=l.memo(We),Xe=G.hero;function Ke(){const[t,s]=l.useState(typeof window<"u"?window.matchMedia("(max-width: 767px)").matches:!1);return l.useEffect(()=>{const o=window.matchMedia("(max-width: 767px)");s(o.matches);const a=r=>s(r.matches);return o.addEventListener("change",a),()=>o.removeEventListener("change",a)},[]),t?G.hero:40}function rt(){var v;const t=te(),s=se(),o=ne(),a=re(),r=ae(),[n,i]=l.useState([]),[x,d]=l.useState(!1),[m,c]=l.useState([]),[g,R]=l.useState(0),[j,f]=l.useState(0),p=l.useRef(null),h=oe(),w=h.blue,N=h.amber,k=Ke();l.useEffect(()=>{if(!t)return;const b=Date.now(),M={timestamp:b,bytesRecv:t.network.bytes_recv,bytesSent:t.network.bytes_sent};if(p.current){const S=(b-p.current.timestamp)/1e3;if(S>0){const _=(M.bytesRecv-p.current.bytesRecv)/S,T=(M.bytesSent-p.current.bytesSent)/S;_>=0&&T>=0&&(R(_),f(T))}}p.current=M,c(S=>[...S,M].slice(-Xe))},[t]);const u=5e3;l.useEffect(()=>{let b=!0;const M=async()=>{var T;const _=await W();b&&_.success&&((T=_.data)!=null&&T.processes)&&i(_.data.processes)};M();const S=setInterval(M,u);return()=>{b=!1,clearInterval(S)}},[]);const y=async()=>{var M;d(!0),await a();const b=await W();b.success&&((M=b.data)!=null&&M.processes)&&i(b.data.processes),d(!1)};return e.jsxs(ie,{children:[e.jsx(de,{title:"System Stats",icon:e.jsx(ye,{}),controls:e.jsxs(le,{color:"muted",onClick:y,disabled:x,children:[e.jsx(he,{"data-slot":"icon",className:H(x&&"animate-spin")}),"Refresh"]})}),e.jsxs(me,{children:[o&&e.jsx(E,{className:"border border-sys-red/50 bg-sys-red/10",children:e.jsx("p",{className:"text-sys-red",children:o})}),s?e.jsx(E,{neomorphic:!0,className:"p-12 text-center",children:e.jsx("div",{className:"animate-pulse text-fg-muted",children:"Loading system stats..."})}):t?e.jsxs(e.Fragment,{children:[e.jsx($,{template:"hero",children:e.jsxs(E,{neomorphic:!0,className:"pb-2 sm:pb-3",children:[e.jsx(B,{icon:e.jsx(O,{}),title:"System Resources",stackActionsOnMobile:!0,actions:e.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-wrap",children:[((v=t.system)==null?void 0:v.uptime)&&e.jsx("span",{className:"px-2 py-0.5 bg-subtle-fill rounded type-data-sm text-fg-primary",children:ce(t.system.uptime)}),e.jsx(z,{level:U(t.cpu.usage_percent,I.cpu)}),e.jsx(z,{level:U(t.memory.usage_percent,I.memory)}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsx("span",{className:"type-data-sm text-fg-muted",children:"CPU"}),e.jsxs("span",{className:"text-sm sm:text-base font-mono font-semibold tabular-nums",style:{color:w},children:[t.cpu.usage_percent.toFixed(0),"%"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsx("span",{className:"type-data-sm text-fg-muted",children:"MEM"}),e.jsxs("span",{className:"text-sm sm:text-base font-mono font-semibold tabular-nums",style:{color:N},children:[t.memory.usage_percent.toFixed(0),"%"]})]})]})}),e.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:e.jsx(Se,{data:r,cpuColor:w,memoryColor:N})}),t.cpu.per_core_percent&&t.cpu.per_core_percent.length>0&&e.jsx("div",{className:"mt-3 pt-3 border-t border-edge-subtle",children:e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 lg:grid-cols-8 gap-x-3 gap-y-0.5",children:t.cpu.per_core_percent.map((b,M)=>e.jsx(He,{index:M,usage:b},M))})})]})}),e.jsxs($,{template:"compact",children:[e.jsx(L,{span:12,md:6,children:e.jsx(De,{networkHistory:m,txRate:j,rxRate:g,totalBytesSent:t.network.bytes_sent,totalBytesRecv:t.network.bytes_recv,cpuColor:w,memoryColor:N,networkSlots:k})}),e.jsx(L,{span:12,md:6,children:e.jsx(Ie,{temperatures:t.temperatures})})]}),e.jsxs($,{template:"compact",children:[e.jsx(L,{span:12,sm:6,children:e.jsx(ze,{usagePercent:t.memory.usage_percent,used:t.memory.used,available:t.memory.available,memoryColor:N})}),e.jsx(L,{span:12,sm:6,children:e.jsx(Ge,{usagePercent:t.disk.usage_percent,used:t.disk.used,free:t.disk.free,cpuColor:w})})]}),e.jsx($,{template:"auto",children:e.jsx(Ve,{processes:n})})]}):null]})]})}export{rt as default}; diff --git a/frontend/dist/assets/Terminal-iUtnCprU.js b/frontend/dist/assets/Terminal-Bs4pn1qU.js similarity index 99% rename from frontend/dist/assets/Terminal-iUtnCprU.js rename to frontend/dist/assets/Terminal-Bs4pn1qU.js index 9aa6f6a0..51a788f5 100644 --- a/frontend/dist/assets/Terminal-iUtnCprU.js +++ b/frontend/dist/assets/Terminal-Bs4pn1qU.js @@ -1,4 +1,4 @@ -var za=Object.defineProperty;var Ua=(e,t,i)=>t in e?za(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var D=(e,t,i)=>Ua(e,typeof t!="symbol"?t+"":t,i);import{d as as,Z as ii,cR as pe,de as ja,df as rt,dg as Qi,dh as Ka,bY as wo,v as Co,di as qa,dj as Va,dk as Ga,bh as xo,cG as Ya,bt as ko,dl as ge,ba as Xa,b9 as Ja,bN as wt,dm as Za,dn as Qa,dp as el,dq as tl,d5 as Wr,j as m,ac as Eo,dr as Ro,ad as Bo,B as il,r as U,A as _s,m as Ti,ds as zr,dt as Ur,cj as sl,du as rl,c as es,dv as nl,dw as ol,E as al,dx as ll,dy as hl,dz as cl}from"./index-C8IY8K2r.js";import{h as Mo,c as dl}from"./geo-utils-BP1zBK9h.js";import{a as ul}from"./ping-lLlOzF2r.js";import{P as _l,c as fl}from"./payload-decoders-BX6pSxwl.js";import{g as pl,r as ml}from"./system-D5HdVkRh.js";import{g as gi,B as Do,r as Lo,T as To}from"./ascii-burst-DN6etEs5.js";import{P as gl,B as vl,C as Sl}from"./PageLayout-NQBVrM09.js";import{K as $o,S as yl}from"./KeycapButton-BJvlGsWZ.js";import{D as jr}from"./download-IUkhheKK.js";import{S as Kr}from"./search-zALFwCS4.js";import{C as bl}from"./chevron-right-DUgYTR6d.js";import"./keycap-sfx-ByZp-njj.js";/** +var za=Object.defineProperty;var Ua=(e,t,i)=>t in e?za(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var D=(e,t,i)=>Ua(e,typeof t!="symbol"?t+"":t,i);import{d as as,Z as ii,cW as pe,dj as ja,dk as rt,dl as Qi,dm as Ka,b$ as wo,cK as Co,cL as qa,v as xo,dn as Va,dp as Ga,dq as Ya,bh as ko,cJ as Xa,bv as Eo,dr as ge,ba as Ja,b9 as Za,bQ as wt,ds as Qa,dt as el,du as tl,dv as il,da as Wr,j as m,ac as Ro,dw as Bo,ad as Mo,B as sl,r as U,A as _s,m as Ti,dx as zr,dy as Ur,cm as rl,dz as nl,c as es,dA as ol,dB as al,E as ll,dC as hl,dD as cl,dE as dl}from"./index-BwGHI0A_.js";import{a as ul}from"./ping-DW5e4gor.js";import{P as _l,c as fl}from"./payload-decoders-7zyi-Y-D.js";import{g as pl,r as ml}from"./system-oD9MKxRy.js";import{g as gi,B as Do,r as Lo,T as To}from"./ascii-burst-DN6etEs5.js";import{P as gl,B as vl,C as Sl}from"./PageLayout-BIcqC04y.js";import{K as $o,S as yl}from"./KeycapButton-CT5jwzf3.js";import{D as jr}from"./download-BbqYTv8j.js";import{S as Kr}from"./search-B7iMjmGm.js";import{C as bl}from"./chevron-right-DqpRZiGf.js";import"./keycap-sfx-ByZp-njj.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. @@ -78,8 +78,8 @@ WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){t `),"value")}catch(o){i.update(r,`Error: ${o instanceof Error?o.message:"Failed to load hardware stats"}`,"error")}}}const Gi="\x1B[0m",Yi="\x1B[1m",br="\x1B[2m",Gn="\x1B[36m",Yn="\x1B[96m",Bu="\x1B[97m",Mu="\x1B[93m",qe=48,Du=14,St=22,mi=5,Xi=22,Lu=5,Tu=St+mi+Xi+Lu,$u=50;function La(e,t,i,s){return r=>{if(r<=0)return 0;if(r>=1)return 1;let n=r;for(let o=0;o<8;o++){const a=3*(1-n)*(1-n)*n*e+3*(1-n)*n*n*i+n*n*n-r,h=3*(1-n)*(1-n)*e+6*(1-n)*n*(i-e)+3*n*n*(1-i);if(Math.abs(h)<1e-7)break;n=Math.max(0,Math.min(1,n-a/h))}return 3*(1-n)*(1-n)*n*t+3*(1-n)*n*n*s+n*n*n}}const Au=La(.25,1,.5,1),Pu=La(.4,0,1,1);function Nu(e,t){const i=e%Du;return Math.sin(.45*i+.04*i*i+t*.25)}const Iu=[1,2,4,64],Ou=[8,16,32,128],Xn=Iu.map((e,t)=>e|Ou[t]);function qt(e,t,i,s){s<4?e[i]|=Xn[s]:t[i]|=Xn[s-4]}function Fu(e){return e>.8?Bu+Yi:e>.6?Mu+Yi:e>.4?Yn+Yi:e>.2?Yn:e>.08?Gn:Gn+br}function Jn(e,t,i){const s=new Uint8Array(qe),r=new Uint8Array(qe),n=new Float32Array(qe),o=e*.35;for(let a=0;a=t)continue;const l=t-h,c=Math.min(1,l/3),d=Math.min(1,h/2),u=l<5?1+.3*(1-l/5):1,f=Math.min(1,c*d*u);if(f<.04)continue;const _=1+.06*Math.sin(e*.7+h*.3),g=Nu(h,o)*f*_*3.5+3.5,E=Math.abs(g-3.5)/3.5,z=l<6?1-l/6:0;n[a]=Math.min(1,E*.65+z*.35)*f;const O=Math.max(0,Math.min(7,Math.round(g)));if(g>=3.5){for(let $=3;$<=O;$++)qt(s,r,a,$);const M=Math.round((g-3.5)*.4);for(let $=Math.max(0,3-M);$<3;$++)qt(s,r,a,$)}else{for(let $=O;$<=4;$++)qt(s,r,a,$);const M=Math.round((3.5-g)*.4);for(let $=5;$<=Math.min(7,4+M);$++)qt(s,r,a,$)}}return{top:s,bot:r,heat:n}}function Zn(e,t,i){const s=new Uint8Array(qe),r=new Uint8Array(qe),n=new Float32Array(qe),o=Math.exp(-t*.5),a=Math.max(0,10-t*2.5),h=.7+t*.2;for(let l=0;l=qe)continue;const d=o*(1-l/a);if(d<.04)continue;n[c]=d;const f=Math.sin(l*h+i*.6)*d*3.5+3.5,_=Math.max(0,Math.min(7,Math.round(f)));if(f>=3.5)for(let p=3;p<=_;p++)qt(s,r,c,p);else for(let p=_;p<=4;p++)qt(s,r,c,p)}return{top:s,bot:r,heat:n}}function Qn(e,t){let i="",s="";for(let r=0;r{s++,e.update(r,eo(s,t,Date.now()-i).join(` `))},$u);return{id:r,stop:()=>clearInterval(n)}}class Hu extends ee{constructor(){super(...arguments);D(this,"name","advert");D(this,"description","Send repeater advertisement")}async execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("advert"),` ${b("Broadcast a repeater advertisement to the mesh network.")}`,"",R("advert","send advert now"),"",st("Adverts announce this repeater's presence to neighbors.")].join(` -`));return}const r=Ta(i,"broadcast");try{const n=await Ka();r.stop(),n.success?i.update(r.id,`✓ ${y("Advert sent")}`,"success"):i.update(r.id,`Error: ${n.error||"Failed"}`,"error")}catch(n){r.stop(),i.update(r.id,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}const Wu=["sig","name","rssi","snr","dist","heard"],to={excellent:5,good:4,fair:3,poor:2,critical:1};function io(e){const t=Math.floor(Date.now()/1e3-e);return t<60?`${t}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function zu(e,t){return e.length>=t?e.slice(0,t):e+" ".repeat(t-e.length)}function so(e){return e<1e3?`${Math.round(e)}m`:`${(e/1e3).toFixed(1)}km`}const Uu={excellent:5,good:4,fair:3,poor:2,critical:1};function ro(e){const t=Uu[e]??0,i=Nr(e),s=t>0?`${i}${"█".repeat(t)}${Q}`:"",r=b("⣿".repeat(5-t));return s+r}const no=3.5;function ju(e){var i;const t=(i=e.config)==null?void 0:i.radio;return!(t!=null&&t.spreading_factor)||!(t!=null&&t.bandwidth)?null:{sf:t.spreading_factor,bwHz:t.bandwidth}}function Ku(e){var i;const t=(i=e.config)==null?void 0:i.repeater;return!t||!Mo(t.latitude,t.longitude)?null:{lat:t.latitude,lon:t.longitude}}function Ut(e,t=i=>i){return{text:e,color:t}}function qu(e,t){return{text:e,color:i=>i,rendered:t}}function Ls(e){return b("+"+e.map(t=>"-".repeat(t+2)).join("+")+"+")}function oo(e,t){const i=e.map((s,r)=>{if(s.rendered!=null){const n=Math.max(0,t[r]-s.text.length);return" "+s.rendered+" ".repeat(n)+" "}return" "+s.color(zu(s.text,t[r]))+" "});return b("|")+i.join(b("|"))+b("|")}const Vu=70,Gu=55;class Yu extends ee{constructor(){super(...arguments);D(this,"name","neighbors");D(this,"description","Show direct RF neighbors with signal stats");D(this,"aliases",["nb","get neighbors","get neighbor"]);D(this,"params","[sig|name|rssi|snr|dist|heard]")}async execute(i){const{output:s,cols:r}=i,n=this.argsAfterName(i.rawInput).toLowerCase().trim();if(n==="help"){this.printUsage(s);return}const o=Wu.includes(n)?n:null,a=s.write("processing...","system");try{const h=await rt(),l=h.neighbors||{},c=Object.entries(l).filter(([,g])=>g.zero_hop);if(c.length===0){const g=Object.keys(l).length;s.update(a,g>0?`No direct neighbors. ${g} relayed neighbor${g!==1?"s":""} known.`:"No neighbors discovered yet.","warning");return}const d=ju(h),u=Ku(h),f=h.noise_floor_dbm;this.sortNeighbors(c,o,d,u,f);const _=o?` ${Ae(`sorted by ${o}`)}`:"",p=[W(`Direct Neighbors (${c.length})`)+_,""];if(r=Vu&&u!=null,E=c.map(([J,Fe])=>this.buildRow(J,Fe,d,u,f,g)),z=g?["SIG","NAME","RSSI","SNR","DIST","HEARD"]:["SIG","NAME","RSSI","SNR","HEARD"],O=z.slice(1).map((J,Fe)=>Math.max(J.length,...E.map(Y=>Y[Fe+1].text.length))),M=5,$=O.reduce((J,Fe)=>J+Fe+3,0),K=Math.max(4,r-$-M-7),ae=Math.min(K,Math.max(4,...E.map(J=>J[1].text.length))),ne=[M,ae,...O.slice(1)];p.push(Ls(ne),...E.map(J=>oo(J,ne)),Ls(ne),oo(z.map(J=>Ut(J,it)),ne),Ls(ne)),p.push(this.footer(d,f))}s.update(a,p.join(` -`))}catch(h){s.update(a,`Error: ${h instanceof Error?h.message:"Command failed"}`,"error")}}sortNeighbors(i,s,r,n,o){switch(s){case"sig":i.sort(([,a],[,h])=>{const l=to[this.gradeNeighbor(a,r,o)]??0,c=to[this.gradeNeighbor(h,r,o)]??0;return l-c});break;case"name":i.sort(([a,h],[l,c])=>{const d=(h.name||h.node_name||a.slice(0,8)).toLowerCase(),u=(c.name||c.node_name||l.slice(0,8)).toLowerCase();return d.localeCompare(u)});break;case"rssi":i.sort(([,a],[,h])=>(a.rssi??-999)-(h.rssi??-999));break;case"snr":i.sort(([,a],[,h])=>(a.snr??-999)-(h.snr??-999));break;case"dist":i.sort(([,a],[,h])=>{const l=this.distTo(a,n)??1/0,c=this.distTo(h,n)??1/0;return l-c});break;case"heard":i.sort(([,a],[,h])=>(a.last_seen||0)-(h.last_seen||0));break;default:i.sort(([,a],[,h])=>(h.last_seen||0)-(a.last_seen||0))}}gradeNeighbor(i,s,r){const n=i.rssi!=null?i.rssi-no:null,o=r!=null&&r>-100?1:0,a=wo(i.snr??null,n,s,o);return(a==null?void 0:a.finalGrade)??"critical"}distTo(i,s){return!s||!Mo(i.latitude,i.longitude)?null:dl(s.lat,s.lon,i.latitude,i.longitude)}buildRow(i,s,r,n,o,a){const h=this.gradeNeighbor(s,r,o),l=zn(s.name||s.node_name||i.slice(0,8))||i.slice(0,8),c=s.rssi!=null?`${s.rssi} dBm`:"-",d=s.snr!=null?`${s.snr} dB`:"-",u=s.last_seen?io(s.last_seen):"-",f=ro(h),_=[qu("|||||",f),Ut(l,it),Ut(c,y),Ut(d,y)];if(a){const p=this.distTo(s,n);_.push(Ut(p!=null?so(p):"-",Ae))}return _.push(Ut(u,Ae)),_}cardLayout(i,s,r,n,o){const a=this.gradeNeighbor(s,r,o),h=zn(s.name||s.node_name||i.slice(0,8))||i.slice(0,8),l=s.rssi!=null?`${s.rssi}`:"-",c=s.snr!=null?`${s.snr}`:"-",d=s.last_seen?io(s.last_seen):"-",u=this.distTo(s,n),f=u!=null?` ${b("dist")} ${y(so(u))}`:"";return[`${ro(a)} ${it(h)}`,` ${b("rssi")} ${y(l)} ${b("snr")} ${y(c)}${f} ${Ae(d)}`,""]}footer(i,s){const r=[];return i&&r.push(`SF${i.sf}/${i.bwHz>=1e3?i.bwHz/1e3+"kHz":i.bwHz+"Hz"}`),r.push(`ant ${no}dBi`),s!=null&&r.push(`nf ${s}dBm`),b(r.join(" "))}printUsage(i){const s=[W("neighbors"),` ${b("Show direct RF neighbors with signal quality, RSSI, SNR, and distance.")}`,"",W("Usage"),R("neighbors","default sort (most recent)"),R("neighbors sig","sort by signal grade (weakest first)"),R("neighbors name","sort alphabetically"),R("neighbors rssi","sort by RSSI (weakest first)"),R("neighbors snr","sort by SNR (lowest first)"),R("neighbors dist","sort by distance (closest first)"),R("neighbors heard","sort by last seen (oldest first)"),R("neighbors help","show this help"),"",W("Aliases"),` ${b("nb, get neighbors, get neighbor")}`,"",st("Signal bars factor radio config, noise floor, and 3.5 dBi antenna gain."),st("Only zero-hop (direct RF) neighbors are shown.")];i.write(s.join(` +`));return}const r=Ta(i,"broadcast");try{const n=await Ka();r.stop(),n.success?i.update(r.id,`✓ ${y("Advert sent")}`,"success"):i.update(r.id,`Error: ${n.error||"Failed"}`,"error")}catch(n){r.stop(),i.update(r.id,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}const Wu=["sig","name","rssi","snr","dist","heard"],to={excellent:5,good:4,fair:3,poor:2,critical:1};function io(e){const t=Math.floor(Date.now()/1e3-e);return t<60?`${t}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function zu(e,t){return e.length>=t?e.slice(0,t):e+" ".repeat(t-e.length)}function so(e){return e<1e3?`${Math.round(e)}m`:`${(e/1e3).toFixed(1)}km`}const Uu={excellent:5,good:4,fair:3,poor:2,critical:1};function ro(e){const t=Uu[e]??0,i=Nr(e),s=t>0?`${i}${"█".repeat(t)}${Q}`:"",r=b("⣿".repeat(5-t));return s+r}const no=3.5;function ju(e){var i;const t=(i=e.config)==null?void 0:i.radio;return!(t!=null&&t.spreading_factor)||!(t!=null&&t.bandwidth)?null:{sf:t.spreading_factor,bwHz:t.bandwidth}}function Ku(e){var i;const t=(i=e.config)==null?void 0:i.repeater;return!t||!Co(t.latitude,t.longitude)?null:{lat:t.latitude,lon:t.longitude}}function Ut(e,t=i=>i){return{text:e,color:t}}function qu(e,t){return{text:e,color:i=>i,rendered:t}}function Ls(e){return b("+"+e.map(t=>"-".repeat(t+2)).join("+")+"+")}function oo(e,t){const i=e.map((s,r)=>{if(s.rendered!=null){const n=Math.max(0,t[r]-s.text.length);return" "+s.rendered+" ".repeat(n)+" "}return" "+s.color(zu(s.text,t[r]))+" "});return b("|")+i.join(b("|"))+b("|")}const Vu=70,Gu=55;class Yu extends ee{constructor(){super(...arguments);D(this,"name","neighbors");D(this,"description","Show direct RF neighbors with signal stats");D(this,"aliases",["nb","get neighbors","get neighbor"]);D(this,"params","[sig|name|rssi|snr|dist|heard]")}async execute(i){const{output:s,cols:r}=i,n=this.argsAfterName(i.rawInput).toLowerCase().trim();if(n==="help"){this.printUsage(s);return}const o=Wu.includes(n)?n:null,a=s.write("processing...","system");try{const h=await rt(),l=h.neighbors||{},c=Object.entries(l).filter(([,g])=>g.zero_hop);if(c.length===0){const g=Object.keys(l).length;s.update(a,g>0?`No direct neighbors. ${g} relayed neighbor${g!==1?"s":""} known.`:"No neighbors discovered yet.","warning");return}const d=ju(h),u=Ku(h),f=h.noise_floor_dbm;this.sortNeighbors(c,o,d,u,f);const _=o?` ${Ae(`sorted by ${o}`)}`:"",p=[W(`Direct Neighbors (${c.length})`)+_,""];if(r=Vu&&u!=null,E=c.map(([J,Fe])=>this.buildRow(J,Fe,d,u,f,g)),z=g?["SIG","NAME","RSSI","SNR","DIST","HEARD"]:["SIG","NAME","RSSI","SNR","HEARD"],O=z.slice(1).map((J,Fe)=>Math.max(J.length,...E.map(Y=>Y[Fe+1].text.length))),M=5,$=O.reduce((J,Fe)=>J+Fe+3,0),K=Math.max(4,r-$-M-7),ae=Math.min(K,Math.max(4,...E.map(J=>J[1].text.length))),ne=[M,ae,...O.slice(1)];p.push(Ls(ne),...E.map(J=>oo(J,ne)),Ls(ne),oo(z.map(J=>Ut(J,it)),ne),Ls(ne)),p.push(this.footer(d,f))}s.update(a,p.join(` +`))}catch(h){s.update(a,`Error: ${h instanceof Error?h.message:"Command failed"}`,"error")}}sortNeighbors(i,s,r,n,o){switch(s){case"sig":i.sort(([,a],[,h])=>{const l=to[this.gradeNeighbor(a,r,o)]??0,c=to[this.gradeNeighbor(h,r,o)]??0;return l-c});break;case"name":i.sort(([a,h],[l,c])=>{const d=(h.name||h.node_name||a.slice(0,8)).toLowerCase(),u=(c.name||c.node_name||l.slice(0,8)).toLowerCase();return d.localeCompare(u)});break;case"rssi":i.sort(([,a],[,h])=>(a.rssi??-999)-(h.rssi??-999));break;case"snr":i.sort(([,a],[,h])=>(a.snr??-999)-(h.snr??-999));break;case"dist":i.sort(([,a],[,h])=>{const l=this.distTo(a,n)??1/0,c=this.distTo(h,n)??1/0;return l-c});break;case"heard":i.sort(([,a],[,h])=>(a.last_seen||0)-(h.last_seen||0));break;default:i.sort(([,a],[,h])=>(h.last_seen||0)-(a.last_seen||0))}}gradeNeighbor(i,s,r){const n=i.rssi!=null?i.rssi-no:null,o=r!=null&&r>-100?1:0,a=wo(i.snr??null,n,s,o);return(a==null?void 0:a.finalGrade)??"critical"}distTo(i,s){return!s||!Co(i.latitude,i.longitude)?null:qa(s.lat,s.lon,i.latitude,i.longitude)}buildRow(i,s,r,n,o,a){const h=this.gradeNeighbor(s,r,o),l=zn(s.name||s.node_name||i.slice(0,8))||i.slice(0,8),c=s.rssi!=null?`${s.rssi} dBm`:"-",d=s.snr!=null?`${s.snr} dB`:"-",u=s.last_seen?io(s.last_seen):"-",f=ro(h),_=[qu("|||||",f),Ut(l,it),Ut(c,y),Ut(d,y)];if(a){const p=this.distTo(s,n);_.push(Ut(p!=null?so(p):"-",Ae))}return _.push(Ut(u,Ae)),_}cardLayout(i,s,r,n,o){const a=this.gradeNeighbor(s,r,o),h=zn(s.name||s.node_name||i.slice(0,8))||i.slice(0,8),l=s.rssi!=null?`${s.rssi}`:"-",c=s.snr!=null?`${s.snr}`:"-",d=s.last_seen?io(s.last_seen):"-",u=this.distTo(s,n),f=u!=null?` ${b("dist")} ${y(so(u))}`:"";return[`${ro(a)} ${it(h)}`,` ${b("rssi")} ${y(l)} ${b("snr")} ${y(c)}${f} ${Ae(d)}`,""]}footer(i,s){const r=[];return i&&r.push(`SF${i.sf}/${i.bwHz>=1e3?i.bwHz/1e3+"kHz":i.bwHz+"Hz"}`),r.push(`ant ${no}dBi`),s!=null&&r.push(`nf ${s}dBm`),b(r.join(" "))}printUsage(i){const s=[W("neighbors"),` ${b("Show direct RF neighbors with signal quality, RSSI, SNR, and distance.")}`,"",W("Usage"),R("neighbors","default sort (most recent)"),R("neighbors sig","sort by signal grade (weakest first)"),R("neighbors name","sort alphabetically"),R("neighbors rssi","sort by RSSI (weakest first)"),R("neighbors snr","sort by SNR (lowest first)"),R("neighbors dist","sort by distance (closest first)"),R("neighbors heard","sort by last seen (oldest first)"),R("neighbors help","show this help"),"",W("Aliases"),` ${b("nb, get neighbors, get neighbor")}`,"",st("Signal bars factor radio config, noise floor, and 3.5 dBi antenna gain."),st("Only zero-hop (direct RF) neighbors are shown.")];i.write(s.join(` `))}}class Xu extends ee{constructor(){super(...arguments);D(this,"name","get");D(this,"description","Get repeater parameter");D(this,"params","{parameter}")}async execute({output:i,rawInput:s}){const r=this.argsAfterName(s).toLowerCase().trim();if(r==="help"||!r){i.write([W("get"),` ${b("Read a repeater configuration parameter.")}`,"",W("Identity"),R("get name","node name"),R("get role","node role"),R("get public.key","public key"),"",W("Location"),R("get lat","latitude"),R("get lon","longitude"),"",W("Radio"),R("get radio","full radio summary"),R("get freq","frequency (MHz)"),R("get tx","TX power (dBm)"),R("get bw","bandwidth (kHz)"),R("get sf","spreading factor"),R("get cr","coding rate"),"",W("Timing"),R("get af","airtime factor (pending backend)"),R("get txdelay","TX delay factor"),R("get direct.txdelay","direct TX delay"),R("get rxdelay","RX delay base"),"",W("Repeater"),R("get mode","forward or monitor"),R("get flood.max","max flood hops"),R("get advert.interval","advert interval"),R("get duty","duty cycle state"),"",W("Advanced"),R("get multi.acks","multi-ack count"),R("get int.thresh","interference threshold (dBm)"),R("get agc.reset.interval","AGC reset interval")].join(` `));return}const n=i.write("processing...","system");try{const o=await rt(),{result:a,type:h}=Ju(r,o);i.update(n,a,h)}catch(o){i.update(n,`Error: ${o instanceof Error?o.message:"Command failed"}`,"error")}}}function Ju(e,t){const i=t.config||{},s=i.radio||{},r=i.repeater||{},n=i.delays||{},o=i.duty_cycle||{},a=(h,l)=>({result:w(h,y(l)),type:"value"});switch(e){case"name":return a("name",i.node_name||"Unknown");case"role":return a("role","repeater");case"lat":return a("lat",r.latitude!=null?String(r.latitude):"not set");case"lon":return a("lon",r.longitude!=null?String(r.longitude):"not set");case"freq":return a("freq",s.frequency?`${(s.frequency/1e6).toFixed(3)} MHz`:"?");case"tx":return a("tx",s.tx_power!=null?`${s.tx_power} dBm`:"?");case"bw":return a("bw",s.bandwidth?`${s.bandwidth/1e3} kHz`:"?");case"sf":return a("sf",String(s.spreading_factor??"?"));case"cr":return a("cr",s.coding_rate?`4/${s.coding_rate}`:"?");case"radio":return s.frequency?{result:[` ${w("freq",y(`${(s.frequency/1e6).toFixed(3)} MHz`))}`,` ${w("bw",y(`${s.bandwidth/1e3} kHz`))}`,` ${w("sf",y(String(s.spreading_factor)))}`,` ${w("cr",y(`4/${s.coding_rate}`))}`,` ${w("tx",y(`${s.tx_power} dBm`))}`].join(` `),type:"value"}:a("radio","?");case"af":case"airtime.factor":return{result:`${b("airtime_factor is not yet exposed by the pyMC_Repeater API.")} @@ -95,9 +95,9 @@ Firmware range: 0-9. Tracked in CLI-Alignment.md — needs backend support.`,typ sudo ./convert_firmware_key.sh ${s} -Then restart: sudo systemctl restart pymc-repeater`,type:"info"}:de("Private key must be a hex string"):de("Private key cannot be empty")}default:return de(`Unknown parameter: ${e}`)}}async function e_(e){const t=e.toLowerCase();return t!=="forward"&&t!=="monitor"?de('Mode must be "forward" or "monitor"'):(await Ga(t)).success?Li(`OK - Mode set to ${t}`):de("Failed")}async function t_(e){const t=e.toLowerCase()==="on"||e==="1";return(await Va(t)).success?Li(`OK - Duty cycle ${t?"enabled":"disabled"}`):de("Failed")}async function i_(e){const t=e.toUpperCase();if(!["DEBUG","INFO","WARNING","ERROR"].includes(t))return de("Level must be debug, info, warning, or error");const i=await qa(t);return i.success?Li(`OK - Log level set to ${t}`):de(i.error||"Failed")}async function Ue(e,t){if(!t.ok)return de(t.error);const i=await Co({[e]:t.value});if(!i.success)return de(i.error||"Failed");let s=`OK - ${e} set to ${t.value}`;return i.restart_required&&(s+=` +Then restart: sudo systemctl restart pymc-repeater`,type:"info"}:de("Private key must be a hex string"):de("Private key cannot be empty")}default:return de(`Unknown parameter: ${e}`)}}async function e_(e){const t=e.toLowerCase();return t!=="forward"&&t!=="monitor"?de('Mode must be "forward" or "monitor"'):(await Ya(t)).success?Li(`OK - Mode set to ${t}`):de("Failed")}async function t_(e){const t=e.toLowerCase()==="on"||e==="1";return(await Ga(t)).success?Li(`OK - Duty cycle ${t?"enabled":"disabled"}`):de("Failed")}async function i_(e){const t=e.toUpperCase();if(!["DEBUG","INFO","WARNING","ERROR"].includes(t))return de("Level must be debug, info, warning, or error");const i=await Va(t);return i.success?Li(`OK - Log level set to ${t}`):de(i.error||"Failed")}async function Ue(e,t){if(!t.ok)return de(t.error);const i=await xo({[e]:t.value});if(!i.success)return de(i.error||"Failed");let s=`OK - ${e} set to ${t.value}`;return i.restart_required&&(s+=` ⚠ Service restart required for changes to take effect -Run: sudo systemctl restart pymc_repeater`),Li(s)}async function Ts(e,t,i){const s=await Co({[e]:t});if(!s.success)return de(s.error||"Failed");let r=i;return s.restart_required&&(r+=` +Run: sudo systemctl restart pymc_repeater`),Li(s)}async function Ts(e,t,i){const s=await xo({[e]:t});if(!s.success)return de(s.error||"Failed");let r=i;return s.restart_required&&(r+=` ⚠ Service restart required for changes to take effect Run: sudo systemctl restart pymc_repeater`),Li(r)}function jt(e,t,i,s){const r=parseInt(e);return isNaN(r)||ri?{ok:!1,error:`Error: ${s}`}:{ok:!0,value:r}}function hi(e,t,i,s){const r=parseFloat(e);return isNaN(r)||ri?{ok:!1,error:`Error: ${s}`}:{ok:!0,value:r}}function s_(e,t,i){const s=parseFloat(e);return isNaN(s)||s0?`${i}${"█".repeat(t)}${Q}`:"")+b("·".repeat(5-t))}const ao=3.5;class o_ extends ee{constructor(){super(...arguments);D(this,"name","ping");D(this,"description","Ping neighbor (name or 0xXX)");D(this,"params","{target} [timeout]")}async execute({output:i,rawInput:s}){var u,f,_,p;const r=this.argsAfterName(s).trim(),n=r.split(/\s+/);if(((u=n[0])==null?void 0:u.toLowerCase())==="help"){i.write([W("ping"),` ${b("Send a ping to a neighbor and measure round-trip time, signal quality, and path.")}`,"",R("ping ","ping by node name"),R("ping 0xAB","ping by hex prefix"),R("ping 60","ping with custom timeout (seconds)"),"",st("Default timeout: 30s. Signal bars factor radio config and noise floor.")].join(` `));return}const o=n[n.length-1],a=parseInt(o),h=n.length>1&&!isNaN(a)&&a>0,l=h?n.slice(0,-1).join(" "):r,c=h?a:30;if(!l){i.write([W("ping"),` ${b("Send a ping to a neighbor and measure round-trip time.")}`,"",R("ping ","ping by node name"),R("ping 60","with custom timeout"),"",st('Run "ping help" for full usage.')].join(` @@ -106,7 +106,7 @@ Run: sudo systemctl restart pymc_repeater`),Li(r)}function jt(e,t,i,s){const r=p `));return}r==="hex"?this.hexToBase64(i,n):r==="base64"?this.base64ToHex(i,n):i.write([W("convert"),` ${b("Convert between hex and base64 encodings.")}`,"",R("convert hex ","hex → base64"),R("convert base64 ","base64 → hex")].join(` `))}hexToBase64(i,s){if(!s){i.write("Usage: convert hex ","error");return}if(!/^[0-9a-fA-F]+$/.test(s)){i.write("Error: Input must be a hex string","error");return}if(s.length%2!==0){i.write("Error: Hex string must have even length","error");return}try{const r=new Uint8Array(s.length/2);for(let h=0;h","error");return}try{const r=typeof globalThis.atob=="function"?globalThis.atob(s):Buffer.from(s,"base64").toString("binary");let n="";for(let o=0;o({isCapturing:!1,captureStartTime:null,captureStartPacketHashes:new Set,captureTimer:null,reports:[],startCapture:i=>{const{captureTimer:s}=t();s&&clearTimeout(s),e({isCapturing:!0,captureStartTime:new Date,captureStartPacketHashes:new Set(i.map(r=>r.packet_hash))})},stopCapture:i=>{const{isCapturing:s,captureStartTime:r,captureStartPacketHashes:n,captureTimer:o}=t();if(!s||!r)return null;o&&clearTimeout(o);const a=new Date,h=Math.round((a.getTime()-r.getTime())/1e3),l=r.getTime()/1e3,c=i.filter(u=>!n.has(u.packet_hash)&&u.timestamp>=l).sort((u,f)=>u.timestamp-f.timestamp),d={id:c_(),filename:d_(r,h),startTime:r,endTime:a,durationSec:h,packetCount:c.length,packets:c,sizeBytes:c.length*h_};return e(u=>({isCapturing:!1,captureStartTime:null,captureStartPacketHashes:new Set,captureTimer:null,reports:[d,...u.reports].slice(0,l_)})),d},getReport:i=>t().reports.find(s=>s.id===i),_setTimer:i=>e({captureTimer:i})})),$a=()=>yt(e=>e.reports);function Se(e){var t;return((t=e.match(/.{1,2}/g))==null?void 0:t.join(" ").toUpperCase())||""}function Aa(e){return e===void 0?"UNKNOWN":Ja[e]??`TYPE_${e}`}function Pa(e){return e===void 0?"UNKNOWN":Xa[e]??`ROUTE_${e}`}function u_(e){const t=[];let i=0;if(e.length>=32&&(t.push({name:"public_key",offset:i,length:32,bytes:Se(ge(e.slice(i,i+32))),decoded:{value:ge(e.slice(i,i+32))}}),i+=32),e.length>=i+4){const s=e.slice(i,i+4),r=s[0]|s[1]<<8|s[2]<<16|s[3]<<24;t.push({name:"timestamp",offset:i,length:4,bytes:Se(ge(s)),decoded:{value:r>>>0,iso:new Date(r*1e3).toISOString()}}),i+=4}if(e.length>=i+64&&(t.push({name:"signature",offset:i,length:64,bytes:Se(ge(e.slice(i,i+64))),decoded:{value:ge(e.slice(i,i+64))}}),i+=64),e.length>i){const s=e[i],r=[];if(s&1&&r.push("CHAT_NODE"),s&2&&r.push("REPEATER"),s&3&&r.push("ROOM_SERVER"),s&16&&r.push("HAS_LOCATION"),s&128&&r.push("HAS_NAME"),t.push({name:"flags",offset:i,length:1,bytes:Se(ge(e.slice(i,i+1))),decoded:{value:s,binary:s.toString(2).padStart(8,"0"),flags:r}}),i+=1,s&16&&e.length>=i+8){const n=e.slice(i,i+8),o=new ArrayBuffer(8);new Uint8Array(o).set(n);const a=new DataView(o),h=a.getInt32(0,!0),l=a.getInt32(4,!0);t.push({name:"location",offset:i,length:8,bytes:Se(ge(n)),decoded:{lat_raw:h,lon_raw:l,latitude:h/1e6,longitude:l/1e6}}),i+=8}if(s&128&&e.length>i){const n=e.slice(i);let o=n.indexOf(0);o===-1&&(o=n.length);const a=new TextDecoder().decode(n.slice(0,o));t.push({name:"name",offset:i,length:o+(n[o]===0?1:0),bytes:Se(ge(n.slice(0,o+1))),decoded:{value:a,encoding:"utf-8",null_terminated:n[o]===0}})}}return t}function __(e){if(e.length<4)return[];const t=e.slice(0,4),i=t[0]|t[1]<<8|t[2]<<16|t[3]<<24;return[{name:"crc",offset:0,length:4,bytes:Se(ge(t)),decoded:{value:i>>>0,hex:(i>>>0).toString(16).toUpperCase().padStart(8,"0"),note:"CRC of the acknowledged packet (little-endian)"}}]}function f_(e){const t=[];if(e.length<9)return t;const i=e.slice(0,4),s=i[0]|i[1]<<8|i[2]<<16|i[3]<<24;t.push({name:"trace_tag",offset:0,length:4,bytes:Se(ge(i)),decoded:{value:s>>>0,hex:(s>>>0).toString(16).toUpperCase().padStart(8,"0")}});const r=e.slice(4,8),n=r[0]|r[1]<<8|r[2]<<16|r[3]<<24;if(t.push({name:"auth_code",offset:4,length:4,bytes:Se(ge(r)),decoded:{value:n>>>0}}),t.push({name:"flags",offset:8,length:1,bytes:Se(ge(e.slice(8,9))),decoded:{value:e[8],binary:e[8].toString(2).padStart(8,"0")}}),e.length>9){const o=e.slice(9),a=Array.from(o).map(h=>h.toString(16).toUpperCase().padStart(2,"0"));t.push({name:"target_path",offset:9,length:o.length,bytes:Se(ge(o)),decoded:{hops:a,path_string:a.join("->")}})}return t}function p_(e){if(e.length===0)return[];const t=Array.from(e).map(i=>i.toString(16).toUpperCase().padStart(2,"0"));return[{name:"path_hops",offset:0,length:e.length,bytes:Se(ge(e)),decoded:{hops:t,path_string:t.join("->")}}]}function m_(e){const t=[];if(e.length<1)return t;if(t.push({name:"channel_hash",offset:0,length:1,bytes:Se(ge(e.slice(0,1))),decoded:{value:e[0].toString(16).toUpperCase().padStart(2,"0")}}),e.length>13){const s=e.length-1-12;t.push({name:"ciphertext",offset:1,length:s,bytes:Se(ge(e.slice(1,1+s))),decoded:{length:s,note:"Encrypted message content"}}),t.push({name:"mac",offset:1+s,length:12,bytes:Se(ge(e.slice(-12))),decoded:{note:"Message authentication code"}})}return t}function g_(e){return e.length===0?[]:[{name:"raw_data",offset:0,length:e.length,bytes:Se(ge(e)),decoded:{length:e.length}}]}function Na(e,t){switch(e){case 4:return u_(t);case 3:return __(t);case 9:return f_(t);case 8:return p_(t);case 5:return m_(t);default:return g_(t)}}function v_(e){const t=e.type??e.payload_type??0,i=e.route??e.route_type??0,s=e.raw_packet||"";let r,n=null;if(s){const o=_l.fromHex(s);if(o.success&&o.packet){const a=o.packet;try{n=fl(a)}catch{n=null}const h=ko(s);let l=0;const c={offset:0,length:1,bytes:Se(s.slice(0,2)),decoded:{route_type:a.routeType,route_name:a.routeTypeName,payload_type:a.payloadType,payload_name:a.payloadTypeName,version:a.payloadVersion}};l+=1,a.hasTransportCodes()&&(l+=4);const u={offset:l,length:1,bytes:Se(ge(h.slice(l,l+1))),decoded:{value:a.pathLen}};l+=1;const f=l,_=h.slice(l,l+a.pathLen),p=Array.from(a.path).map(M=>M.toString(16).toUpperCase().padStart(2,"0")),g=a.payloadType===9,E={offset:f,length:a.pathLen,bytes:Se(ge(_)),decoded:{hops:p,path_string:p.length>0?p.join("->"):"(direct)",...g&&{note:"For TRACE packets, path bytes are SNR×4 values, not node hashes",snr_values:Array.from(a.path).map(M=>{let $=M;return $>127&&($-=256),$/4})}}};l+=a.pathLen;const O={offset:l,length:a.payload.length,bytes:Se(a.payloadHex),sections:Na(a.payloadType,a.payload)};r={header:c,path_length:u,path:E,payload:O}}else r=lo(e)}else r=lo(e);return{timestamp:e.timestamp,packet_hash:e.packet_hash,type:t,type_name:Aa(t),route:i,route_name:Pa(i),rssi:e.rssi,snr:e.snr,length:e.length??0,src_hash:e.src_hash,dst_hash:e.dst_hash,transmitted:e.transmitted,drop_reason:e.drop_reason,is_duplicate:e.is_duplicate,lbt_attempts:e.lbt_attempts,lbt_backoff_delays_ms:e.lbt_backoff_delays_ms,lbt_channel_busy:e.lbt_channel_busy,raw_packet:s,structure:r,decoded:n}}function lo(e){var r;const t=e.type??e.payload_type??0,i=e.route??e.route_type??0,s=e.original_path??e.forwarded_path??[];return{header:{offset:0,length:1,bytes:"??",decoded:{route_type:i,route_name:Pa(i),payload_type:t,payload_name:Aa(t),version:0}},path_length:{offset:1,length:1,bytes:s.length.toString(16).toUpperCase().padStart(2,"0"),decoded:{value:s.length}},path:{offset:2,length:s.length,bytes:s.join(" "),decoded:{hops:s,path_string:s.length>0?s.join("->"):"(direct)"}},payload:{offset:2+s.length,length:((r=e.payload)==null?void 0:r.length)??0,bytes:e.payload??"",sections:e.payload?Na(t,ko(e.payload)):[]}}}function S_(e,t){var i;return{capture:{start:e.startTime.toISOString(),end:e.endTime.toISOString(),duration_sec:e.durationSec,packet_count:e.packetCount,node_name:(t==null?void 0:t.node_name)??"unknown",local_hash:(t==null?void 0:t.local_hash)??"unknown",pymc_console_version:Ya,pymc_repeater_version:(t==null?void 0:t.version)??"unknown",radio_config:(i=t==null?void 0:t.config)!=null&&i.radio?{frequency:t.config.radio.frequency,tx_power:t.config.radio.tx_power,bandwidth:t.config.radio.bandwidth,spreading_factor:t.config.radio.spreading_factor}:null},packets:e.packets.map(v_)}}function Ia(e,t){const i=S_(e,t),s=JSON.stringify(i,null,2),r=new Blob([s],{type:"application/json"}),n=URL.createObjectURL(r),o=document.createElement("a");o.href=n,o.download=e.filename,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)}function Ji(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}class y_ extends ee{constructor(){super(...arguments);D(this,"name","cap");D(this,"description","Packet capture (start/end/list/export)")}matches(i){const s=i.toLowerCase().trim();return s==="cap"||s==="cap help"||s.startsWith("start cap")||s.startsWith("end cap")||s.startsWith("list cap")||s.startsWith("export cap")}async execute({output:i,rawInput:s}){const r=s.toLowerCase().trim();if(r==="cap"||r==="cap help")return this.showHelp(i);if(r.startsWith("start cap"))return this.startCapture(i,r);if(r==="end cap")return this.endCapture(i);if(r==="list cap")return this.listCaptures(i);if(r.startsWith("export cap"))return this.exportCapture(i,r);this.showHelp(i)}showHelp(i){const s=yt.getState(),r=s.isCapturing?` + ${w("hex",y(n.toUpperCase()))}`)}catch(r){i.write(`Error: Invalid base64 string - ${r instanceof Error?r.message:"unknown error"}`,"error")}}}const l_=10,h_=500;function c_(){const e=new Date;return`${e.toISOString().slice(0,10)}_${e.toTimeString().slice(0,8).replace(/:/g,"-")}`}function d_(e,t){const i=e.toISOString().slice(0,10),s=e.toTimeString().slice(0,5).replace(":","");return`pymc-${i}-${s}-${t}s.json`}const yt=ko((e,t)=>({isCapturing:!1,captureStartTime:null,captureStartPacketHashes:new Set,captureTimer:null,reports:[],startCapture:i=>{const{captureTimer:s}=t();s&&clearTimeout(s),e({isCapturing:!0,captureStartTime:new Date,captureStartPacketHashes:new Set(i.map(r=>r.packet_hash))})},stopCapture:i=>{const{isCapturing:s,captureStartTime:r,captureStartPacketHashes:n,captureTimer:o}=t();if(!s||!r)return null;o&&clearTimeout(o);const a=new Date,h=Math.round((a.getTime()-r.getTime())/1e3),l=r.getTime()/1e3,c=i.filter(u=>!n.has(u.packet_hash)&&u.timestamp>=l).sort((u,f)=>u.timestamp-f.timestamp),d={id:c_(),filename:d_(r,h),startTime:r,endTime:a,durationSec:h,packetCount:c.length,packets:c,sizeBytes:c.length*h_};return e(u=>({isCapturing:!1,captureStartTime:null,captureStartPacketHashes:new Set,captureTimer:null,reports:[d,...u.reports].slice(0,l_)})),d},getReport:i=>t().reports.find(s=>s.id===i),_setTimer:i=>e({captureTimer:i})})),$a=()=>yt(e=>e.reports);function Se(e){var t;return((t=e.match(/.{1,2}/g))==null?void 0:t.join(" ").toUpperCase())||""}function Aa(e){return e===void 0?"UNKNOWN":Za[e]??`TYPE_${e}`}function Pa(e){return e===void 0?"UNKNOWN":Ja[e]??`ROUTE_${e}`}function u_(e){const t=[];let i=0;if(e.length>=32&&(t.push({name:"public_key",offset:i,length:32,bytes:Se(ge(e.slice(i,i+32))),decoded:{value:ge(e.slice(i,i+32))}}),i+=32),e.length>=i+4){const s=e.slice(i,i+4),r=s[0]|s[1]<<8|s[2]<<16|s[3]<<24;t.push({name:"timestamp",offset:i,length:4,bytes:Se(ge(s)),decoded:{value:r>>>0,iso:new Date(r*1e3).toISOString()}}),i+=4}if(e.length>=i+64&&(t.push({name:"signature",offset:i,length:64,bytes:Se(ge(e.slice(i,i+64))),decoded:{value:ge(e.slice(i,i+64))}}),i+=64),e.length>i){const s=e[i],r=[];if(s&1&&r.push("CHAT_NODE"),s&2&&r.push("REPEATER"),s&3&&r.push("ROOM_SERVER"),s&16&&r.push("HAS_LOCATION"),s&128&&r.push("HAS_NAME"),t.push({name:"flags",offset:i,length:1,bytes:Se(ge(e.slice(i,i+1))),decoded:{value:s,binary:s.toString(2).padStart(8,"0"),flags:r}}),i+=1,s&16&&e.length>=i+8){const n=e.slice(i,i+8),o=new ArrayBuffer(8);new Uint8Array(o).set(n);const a=new DataView(o),h=a.getInt32(0,!0),l=a.getInt32(4,!0);t.push({name:"location",offset:i,length:8,bytes:Se(ge(n)),decoded:{lat_raw:h,lon_raw:l,latitude:h/1e6,longitude:l/1e6}}),i+=8}if(s&128&&e.length>i){const n=e.slice(i);let o=n.indexOf(0);o===-1&&(o=n.length);const a=new TextDecoder().decode(n.slice(0,o));t.push({name:"name",offset:i,length:o+(n[o]===0?1:0),bytes:Se(ge(n.slice(0,o+1))),decoded:{value:a,encoding:"utf-8",null_terminated:n[o]===0}})}}return t}function __(e){if(e.length<4)return[];const t=e.slice(0,4),i=t[0]|t[1]<<8|t[2]<<16|t[3]<<24;return[{name:"crc",offset:0,length:4,bytes:Se(ge(t)),decoded:{value:i>>>0,hex:(i>>>0).toString(16).toUpperCase().padStart(8,"0"),note:"CRC of the acknowledged packet (little-endian)"}}]}function f_(e){const t=[];if(e.length<9)return t;const i=e.slice(0,4),s=i[0]|i[1]<<8|i[2]<<16|i[3]<<24;t.push({name:"trace_tag",offset:0,length:4,bytes:Se(ge(i)),decoded:{value:s>>>0,hex:(s>>>0).toString(16).toUpperCase().padStart(8,"0")}});const r=e.slice(4,8),n=r[0]|r[1]<<8|r[2]<<16|r[3]<<24;if(t.push({name:"auth_code",offset:4,length:4,bytes:Se(ge(r)),decoded:{value:n>>>0}}),t.push({name:"flags",offset:8,length:1,bytes:Se(ge(e.slice(8,9))),decoded:{value:e[8],binary:e[8].toString(2).padStart(8,"0")}}),e.length>9){const o=e.slice(9),a=Array.from(o).map(h=>h.toString(16).toUpperCase().padStart(2,"0"));t.push({name:"target_path",offset:9,length:o.length,bytes:Se(ge(o)),decoded:{hops:a,path_string:a.join("->")}})}return t}function p_(e){if(e.length===0)return[];const t=Array.from(e).map(i=>i.toString(16).toUpperCase().padStart(2,"0"));return[{name:"path_hops",offset:0,length:e.length,bytes:Se(ge(e)),decoded:{hops:t,path_string:t.join("->")}}]}function m_(e){const t=[];if(e.length<1)return t;if(t.push({name:"channel_hash",offset:0,length:1,bytes:Se(ge(e.slice(0,1))),decoded:{value:e[0].toString(16).toUpperCase().padStart(2,"0")}}),e.length>13){const s=e.length-1-12;t.push({name:"ciphertext",offset:1,length:s,bytes:Se(ge(e.slice(1,1+s))),decoded:{length:s,note:"Encrypted message content"}}),t.push({name:"mac",offset:1+s,length:12,bytes:Se(ge(e.slice(-12))),decoded:{note:"Message authentication code"}})}return t}function g_(e){return e.length===0?[]:[{name:"raw_data",offset:0,length:e.length,bytes:Se(ge(e)),decoded:{length:e.length}}]}function Na(e,t){switch(e){case 4:return u_(t);case 3:return __(t);case 9:return f_(t);case 8:return p_(t);case 5:return m_(t);default:return g_(t)}}function v_(e){const t=e.type??e.payload_type??0,i=e.route??e.route_type??0,s=e.raw_packet||"";let r,n=null;if(s){const o=_l.fromHex(s);if(o.success&&o.packet){const a=o.packet;try{n=fl(a)}catch{n=null}const h=Eo(s);let l=0;const c={offset:0,length:1,bytes:Se(s.slice(0,2)),decoded:{route_type:a.routeType,route_name:a.routeTypeName,payload_type:a.payloadType,payload_name:a.payloadTypeName,version:a.payloadVersion}};l+=1,a.hasTransportCodes()&&(l+=4);const u={offset:l,length:1,bytes:Se(ge(h.slice(l,l+1))),decoded:{value:a.pathLen}};l+=1;const f=l,_=h.slice(l,l+a.pathLen),p=Array.from(a.path).map(M=>M.toString(16).toUpperCase().padStart(2,"0")),g=a.payloadType===9,E={offset:f,length:a.pathLen,bytes:Se(ge(_)),decoded:{hops:p,path_string:p.length>0?p.join("->"):"(direct)",...g&&{note:"For TRACE packets, path bytes are SNR×4 values, not node hashes",snr_values:Array.from(a.path).map(M=>{let $=M;return $>127&&($-=256),$/4})}}};l+=a.pathLen;const O={offset:l,length:a.payload.length,bytes:Se(a.payloadHex),sections:Na(a.payloadType,a.payload)};r={header:c,path_length:u,path:E,payload:O}}else r=lo(e)}else r=lo(e);return{timestamp:e.timestamp,packet_hash:e.packet_hash,type:t,type_name:Aa(t),route:i,route_name:Pa(i),rssi:e.rssi,snr:e.snr,length:e.length??0,src_hash:e.src_hash,dst_hash:e.dst_hash,transmitted:e.transmitted,drop_reason:e.drop_reason,is_duplicate:e.is_duplicate,lbt_attempts:e.lbt_attempts,lbt_backoff_delays_ms:e.lbt_backoff_delays_ms,lbt_channel_busy:e.lbt_channel_busy,raw_packet:s,structure:r,decoded:n}}function lo(e){var r;const t=e.type??e.payload_type??0,i=e.route??e.route_type??0,s=e.original_path??e.forwarded_path??[];return{header:{offset:0,length:1,bytes:"??",decoded:{route_type:i,route_name:Pa(i),payload_type:t,payload_name:Aa(t),version:0}},path_length:{offset:1,length:1,bytes:s.length.toString(16).toUpperCase().padStart(2,"0"),decoded:{value:s.length}},path:{offset:2,length:s.length,bytes:s.join(" "),decoded:{hops:s,path_string:s.length>0?s.join("->"):"(direct)"}},payload:{offset:2+s.length,length:((r=e.payload)==null?void 0:r.length)??0,bytes:e.payload??"",sections:e.payload?Na(t,Eo(e.payload)):[]}}}function S_(e,t){var i;return{capture:{start:e.startTime.toISOString(),end:e.endTime.toISOString(),duration_sec:e.durationSec,packet_count:e.packetCount,node_name:(t==null?void 0:t.node_name)??"unknown",local_hash:(t==null?void 0:t.local_hash)??"unknown",pymc_console_version:Xa,pymc_repeater_version:(t==null?void 0:t.version)??"unknown",radio_config:(i=t==null?void 0:t.config)!=null&&i.radio?{frequency:t.config.radio.frequency,tx_power:t.config.radio.tx_power,bandwidth:t.config.radio.bandwidth,spreading_factor:t.config.radio.spreading_factor}:null},packets:e.packets.map(v_)}}function Ia(e,t){const i=S_(e,t),s=JSON.stringify(i,null,2),r=new Blob([s],{type:"application/json"}),n=URL.createObjectURL(r),o=document.createElement("a");o.href=n,o.download=e.filename,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)}function Ji(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}class y_ extends ee{constructor(){super(...arguments);D(this,"name","cap");D(this,"description","Packet capture (start/end/list/export)")}matches(i){const s=i.toLowerCase().trim();return s==="cap"||s==="cap help"||s.startsWith("start cap")||s.startsWith("end cap")||s.startsWith("list cap")||s.startsWith("export cap")}async execute({output:i,rawInput:s}){const r=s.toLowerCase().trim();if(r==="cap"||r==="cap help")return this.showHelp(i);if(r.startsWith("start cap"))return this.startCapture(i,r);if(r==="end cap")return this.endCapture(i);if(r==="list cap")return this.listCaptures(i);if(r.startsWith("export cap"))return this.exportCapture(i,r);this.showHelp(i)}showHelp(i){const s=yt.getState(),r=s.isCapturing?` ${Rs('Recording in progress... use "end cap" to stop')}`:"",n=s.reports.length,o=n>0?` (${n} saved)`:"",a=[W("Packet Capture"),"",R("start cap","Start capture (default: 120s)"),R("end cap","Stop capture early"),R("list cap",`List saved captures${o}`),R("export cap","Download capture by ID"),"",st("Captures stored in session memory. JSON includes decoded payloads."),r].filter(Boolean);i.write(a.join(` `))}startCapture(i,s){const r=s.slice(9).trim(),n=r?parseInt(r):120;if(isNaN(n)||n<1||n>3600){i.write("Error: Duration must be 1-3600 seconds","error");return}const o=yt.getState();if(o.isCapturing){i.write('Error: Capture already in progress. Use "end cap" first.',"error");return}const a=wt.getState().packets;o.startCapture(a);let h=n;const l=i.write(Rs(`Capturing... ${h}s remaining`),"system"),c=setInterval(()=>{h--;const u=yt.getState();if(h>=0&&u.isCapturing){const _=wt.getState().packets.filter(g=>{if(!u.captureStartTime)return!1;const E=u.captureStartTime.getTime()/1e3;return g.timestamp>=E&&!u.captureStartPacketHashes.has(g.packet_hash)}).length,p=h>0?`${h}s remaining`:"finishing...";i.update(l,Rs(`Capturing... ${p} (${_} captured)`),"system")}},1e3),d=setTimeout(()=>{clearInterval(c);const u=yt.getState();if(u.isCapturing){const f=wt.getState().packets,_=u.stopCapture(f);_?i.write(`✓ Capture complete! Captured: ${_.packetCount} packets @@ -128,21 +128,21 @@ Available reports: ${h.join(` `)}`,"info")}return}let a=n.getReport(r);if(!a){const h=parseInt(r)-1;a=n.reports[h]}if(!a){i.write(`Error: Report "${r}" not found. Use "list cap" to see available reports.`,"error");return}Ia(a,o),i.write(`✓ Downloading ${a.filename}...`,"value")}}class b_ extends ee{constructor(){super(...arguments);D(this,"name","identities");D(this,"description","List configured identities");D(this,"aliases",["id","ids"])}async execute({output:i,rawInput:s}){var n;if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("identities"),` ${b("List all configured repeater and room server identities.")}`,"",R("identities","list identities"),"",W("Aliases"),` ${b("id, ids")}`].join(` -`));return}const r=i.write("processing...","system");try{const o=await Za();if(!o.success||!o.data){i.update(r,o.error||"Failed to fetch identities","error");return}const a=o.data,h=(n=a.configured)!=null&&n.length?a.configured:a.registered||[];if(h.length===0){i.update(r,"No identities configured.","warning");return}const l=[W(`Identities (${h.length})`),"",...h.map((c,d)=>{var p;const u=c.name||"Unnamed",f=c.type||"unknown",_=((p=c.hash)==null?void 0:p.slice(0,8))||"—";return` ${b(`${d+1}.`)} ${it(u)} ${Ae(f)} ${y(_)}`})];i.update(r,l.join(` +`));return}const r=i.write("processing...","system");try{const o=await Qa();if(!o.success||!o.data){i.update(r,o.error||"Failed to fetch identities","error");return}const a=o.data,h=(n=a.configured)!=null&&n.length?a.configured:a.registered||[];if(h.length===0){i.update(r,"No identities configured.","warning");return}const l=[W(`Identities (${h.length})`),"",...h.map((c,d)=>{var p;const u=c.name||"Unnamed",f=c.type||"unknown",_=((p=c.hash)==null?void 0:p.slice(0,8))||"—";return` ${b(`${d+1}.`)} ${it(u)} ${Ae(f)} ${y(_)}`})];i.update(r,l.join(` `))}catch(o){i.update(r,`Error: ${o instanceof Error?o.message:"Command failed"}`,"error")}}}class w_ extends ee{constructor(){super(...arguments);D(this,"name","keys");D(this,"description","List transport keys")}async execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("keys"),` ${b("List configured transport encryption keys.")}`,"",R("keys","list transport keys")].join(` `));return}const r=i.write("processing...","system");try{const n=await pl();if(!n.success||!n.data){i.update(r,n.error||"Failed to fetch transport keys","error");return}const o=n.data;if(o.length===0){i.update(r,"No transport keys configured.","warning");return}const a=[W(`Transport Keys (${o.length})`),"",...o.map(h=>{const l=h.parent_id?` ${Ae(`parent: ${h.parent_id}`)}`:"";return` ${it(h.name)} ${w("flood",y(h.flood_policy))}${l}`})];i.update(r,a.join(` `))}catch(n){i.update(r,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}class C_ extends ee{constructor(){super(...arguments);D(this,"name","acl");D(this,"description","Show ACL statistics")}async execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("acl"),` ${b("Display access control list statistics.")}`,"",R("acl","show ACL stats")].join(` -`));return}const r=i.write("processing...","system");try{const n=await Qa();if(!n.success||!n.data){i.update(r,n.error||"Failed to fetch ACL stats","error");return}const o=n.data,a=[W("ACL Stats"),"",` ${w("Identities",y(String(o.total_identities)))}`,` ${w("Total clients",y(String(o.total_clients)))}`,` ${w("Admin",y(String(o.admin_clients)))}`,` ${w("Guest",y(String(o.guest_clients)))}`];if(o.by_identity_type){const h=o.by_identity_type.repeater,l=o.by_identity_type.room_server;h&&a.push(` ${w("Repeater",`${y(String(h.count))} ids ${b(`${h.clients} clients`)}`)}`),l&&a.push(` ${w("Room Server",`${y(String(l.count))} ids ${b(`${l.clients} clients`)}`)}`)}i.update(r,a.join(` +`));return}const r=i.write("processing...","system");try{const n=await el();if(!n.success||!n.data){i.update(r,n.error||"Failed to fetch ACL stats","error");return}const o=n.data,a=[W("ACL Stats"),"",` ${w("Identities",y(String(o.total_identities)))}`,` ${w("Total clients",y(String(o.total_clients)))}`,` ${w("Admin",y(String(o.admin_clients)))}`,` ${w("Guest",y(String(o.guest_clients)))}`];if(o.by_identity_type){const h=o.by_identity_type.repeater,l=o.by_identity_type.room_server;h&&a.push(` ${w("Repeater",`${y(String(h.count))} ids ${b(`${h.clients} clients`)}`)}`),l&&a.push(` ${w("Room Server",`${y(String(l.count))} ids ${b(`${l.clients} clients`)}`)}`)}i.update(r,a.join(` `))}catch(n){i.update(r,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}class x_ extends ee{constructor(){super(...arguments);D(this,"name","rooms");D(this,"description","Show room server statistics")}async execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("rooms"),` ${b("Display room server statistics and sync status.")}`,"",R("rooms","list rooms")].join(` -`));return}const r=i.write("processing...","system");try{const n=await el();if(!n.success||!n.data){i.update(r,n.error||"Failed to fetch room stats","error");return}const o=n.data.rooms||[];if(o.length===0){i.update(r,"No room servers configured.","warning");return}const a=[W(`Rooms (${o.length})`),"",...o.map(h=>[` ${it(h.room_name)}`,` ${w("msgs",y(String(h.total_messages)))} ${w("clients",`${y(String(h.active_clients))}${Ae(`/${h.total_clients}`)}`)} ${w("sync",h.sync_running?y("running"):Ae("idle"))}`]).flat()];i.update(r,a.join(` +`));return}const r=i.write("processing...","system");try{const n=await tl();if(!n.success||!n.data){i.update(r,n.error||"Failed to fetch room stats","error");return}const o=n.data.rooms||[];if(o.length===0){i.update(r,"No room servers configured.","warning");return}const a=[W(`Rooms (${o.length})`),"",...o.map(h=>[` ${it(h.room_name)}`,` ${w("msgs",y(String(h.total_messages)))} ${w("clients",`${y(String(h.active_clients))}${Ae(`/${h.total_clients}`)}`)} ${w("sync",h.sync_running?y("running"):Ae("idle"))}`]).flat()];i.update(r,a.join(` `))}catch(n){i.update(r,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}class k_ extends ee{constructor(){super(...arguments);D(this,"name","restart");D(this,"description","Restart pymc-repeater service");D(this,"aliases",["reboot"])}async execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("restart"),` ${b("Restart the pymc-repeater systemd service.")}`,"",R("restart","restart the service"),"",W("Aliases"),` ${b("reboot")}`,"",st("Requires polkit permissions for the web user."),st("The page will need a manual refresh after restart.")].join(` `));return}const r=i.write("Restarting service...","system");try{const n=await ml(AbortSignal.timeout(8e3));if(n.success){i.update(r,"Service restart initiated.","success"),await this.waitForService(i);return}const o=n.status;if(o===403||o===401){i.update(r,`Error: Permission denied. The web user needs polkit permissions to restart the service. -See: /etc/polkit-1/localauthority/50-local.d/pymc-repeater.pkla`,"error");return}i.update(r,n.error||"Restart failed","error")}catch(n){const o=n instanceof Error?n.message:"";o.includes("ERR_NETWORK")||o.includes("ECONNRESET")||o.includes("Failed to fetch")||o.includes("Load failed")||o.includes("network connection was lost")||o.includes("abort")||o.includes("timeout")||n instanceof DOMException&&n.name==="TimeoutError"||n instanceof DOMException&&n.name==="AbortError"?(i.update(r,"Service is restarting (connection dropped).","success"),await this.waitForService(i)):i.update(r,`Error: ${o||"Restart failed"}`,"error")}}waitForService(i){return new Promise(s=>{const r=i.write("Waiting for service...","system");let n=0;const o=30;setTimeout(()=>{const a=setInterval(async()=>{n++,i.update(r,`Waiting for service... ${n}s`,"system");try{const h=new AbortController,l=setTimeout(()=>h.abort(),3e3);await fetch(`${tl}/api/stats`,{signal:h.signal}),clearTimeout(l),clearInterval(a),i.update(r,`Service connected. (${n+4}s)`,"success"),s();return}catch{}n>=o&&(clearInterval(a),i.update(r,`Service did not respond within ${o+4}s. Check manually.`,"warning"),s())},1e3)},4e3)})}}const Ot="\x1B[",Ne=`${Ot}0m`,Oa=`${Ot}32m`,Or=`${Ot}33m`,Fr=`${Ot}31m`,E_=`${Ot}36m`,Rt=`${Ot}90m`,Fa=`${Ot}1m`;function Vt(e){return e>=1073741824?`${(e/1073741824).toFixed(1)}G`:e>=1048576?`${(e/1048576).toFixed(0)}M`:e>=1024?`${(e/1024).toFixed(0)}K`:`${e}B`}function ho(e){const t=Math.floor(e/86400),i=Math.floor(e%86400/3600),s=Math.floor(e%3600/60);return t>0?`${t}d ${i}h ${s}m`:i>0?`${i}h ${s}m`:`${s}m`}function R_(e,t){const i=Math.max(0,Math.min(100,e)),s=Math.round(i/100*t),r=t-s,n=i>=90?Fr:i>=70?Or:Oa,o=`${n}${"█".repeat(s)}${Ne}${Rt}${"░".repeat(r)}${Ne}`,a=`${i.toFixed(1)}%`.padStart(6);return`[${o}] ${n}${a}${Ne}`}function B_(e){return e>=80?`${Fr}${Fa}${e.toFixed(1)}°C${Ne}`:e>=60?`${Or}${e.toFixed(1)}°C${Ne}`:`${Oa}${e.toFixed(1)}°C${Ne}`}const wi=2,co=" ";function Gt(e,t){const i=" ".repeat(wi),s=t-wi,r=co.length,n=[];let o="",a=0;for(const h of e){const l=hu(h);a===0?(o=h,a=l):a+r+l<=s?(o+=co+h,a+=r+l):(n.push(i+o),o=h,a=l)}return a>0&&n.push(i+o),n}function M_(e,t,i){var d,u;const s=e.node_name||"unknown",r=e.version?`v${e.version}`:"",n=(d=t.system)!=null&&d.uptime?ho(t.system.uptime):"?",o=ho(e.uptime_seconds||0),a=Math.max(3,i-wi*2),h=((u=t.cpu.load_avg)==null?void 0:u["1min"].toFixed(2))??"?",l=t.cpu.load_avg?`${h} ${t.cpu.load_avg["5min"].toFixed(2)} ${t.cpu.load_avg["15min"].toFixed(2)}`:"?",c=i>=60?l:h;return[` ${E_}${Fa}${s}${Ne} ${Rt}${r}${Ne}`,` ${Rt}${"─".repeat(a)}${Ne}`,...Gt([w("Sys",y(n)),w("Svc",y(o)),w("Load",y(c))],i)]}function D_(e,t){const s=wi+4+1+2+6,r=Math.max(6,Math.min(30,t-s)),n=s+r,o=t-n-2,a=[""],h=`${e.cpu.count} core${e.cpu.count>1?"s":""}`,l=`${Vt(e.memory.used)}/${Vt(e.memory.total)}`,c=`${Vt(e.disk.used)}/${Vt(e.disk.total)}`,d=(f,_,p)=>{const g=R_(_,r),E=o>=p.length?` ${Ae(p)}`:"";return` ${b(f.padEnd(4))}${g}${E}`};a.push(d("CPU",e.cpu.usage_percent,h)),a.push(d("Mem",e.memory.usage_percent,l)),a.push(d("Dsk",e.disk.usage_percent,c));const u=Object.entries(e.temperatures||{});if(u.length>0){const f=u.map(([_,p])=>`${Ae(_+":")} ${B_(p)}`);a.push(...Gt(f,t))}return a}function L_(e,t){var l,c;const i=e.neighbors||{},s=Object.keys(i).length,r=Object.values(i).filter(d=>d.zero_hop).length,n=((c=(l=e.config)==null?void 0:l.repeater)==null?void 0:c.mode)||"?",o=e.noise_floor_dbm!=null?`${e.noise_floor_dbm}dBm`:"?",a=e.duty_cycle_percent??0,h=["",` ${Rt}MESH${Ne}`];return h.push(...Gt([w("Mode",y(n)),w("Nbrs",`${y(String(r))}${Ae(`/${s}`)}`),w("Noise",y(o)),w("Air",y(`${a.toFixed(1)}%`))],t)),h.push(...Gt([w("RX",y(String(e.rx_count??0))),w("TX",y(String(e.tx_count??0))),w("FWD",y(String(e.forwarded_count??0))),w("Drop",y(String(e.dropped_count??0)))],t)),h.push(...Gt([w("RX/h",y(String(Math.round(e.rx_per_hour??0)))),w("FWD/h",y(String(Math.round(e.forwarded_per_hour??0))))],t)),h}function T_(e,t){if(!e.network)return[];const i=["",` ${Rt}NET${Ne}`];return i.push(...Gt([w("TX",y(Vt(e.network.bytes_sent))),w("RX",y(Vt(e.network.bytes_recv))),w("Pkt",`${y(String(e.network.packets_sent))}${Ae("/")}${y(String(e.network.packets_recv))}`)],t)),i}function $_(e,t,i){if(e.length===0)return[];const s=t>=50,r=t>=50?6:5,n=t>=50?6:5,o=s?7:0,a=wi+0,h=Math.max(4,t-a-o-r-n-4),l=3,c=t>=50?8:5,d=i!=null?Math.max(0,Math.min(c,i-l)):c;if(d<=0)return[];const u=["",` ${Rt}PROCS${Ne}`],f=(s?"PID".padEnd(o):"")+"CPU".padStart(r)+"MEM".padStart(n)+" NAME";u.push(` ${Ae(f)}`);for(const _ of e.slice(0,d)){const p=s?Ae(String(_.pid).padEnd(o)):"",g=(t>=50?_.cpu_percent.toFixed(1):_.cpu_percent.toFixed(0)).padStart(r),E=(t>=50?_.memory_percent.toFixed(1):_.memory_percent.toFixed(0)).padStart(n),z=_.name.length>h?_.name.slice(0,h-1)+"…":_.name,O=_.cpu_percent>=50?Fr:_.cpu_percent>=20?Or:"",M=O?`${O}${g}${Ne}`:g;u.push(` ${p}${M}${Ae(E)} ${z}`)}return u}function A_(){return new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}function uo(e,t,i,s,r){if(!e||!t)return` ${Rt}Waiting for data…${Ne}`;const n=M_(e,t,s),o=D_(t,s),a=L_(e,s),h=T_(t,s),l=["",` ${Rt}${A_()} · Ctrl+C to exit${Ne}`],c=[...n,...o,...a,...h,...l],d=r?yr(c,s):0,u=r?Math.max(0,r-d):void 0,f=$_(i,s,u),_=[...c.slice(0,-l.length),...f,...l];return r&&_.length>r&&(_.length=r),_.join(` +See: /etc/polkit-1/localauthority/50-local.d/pymc-repeater.pkla`,"error");return}i.update(r,n.error||"Restart failed","error")}catch(n){const o=n instanceof Error?n.message:"";o.includes("ERR_NETWORK")||o.includes("ECONNRESET")||o.includes("Failed to fetch")||o.includes("Load failed")||o.includes("network connection was lost")||o.includes("abort")||o.includes("timeout")||n instanceof DOMException&&n.name==="TimeoutError"||n instanceof DOMException&&n.name==="AbortError"?(i.update(r,"Service is restarting (connection dropped).","success"),await this.waitForService(i)):i.update(r,`Error: ${o||"Restart failed"}`,"error")}}waitForService(i){return new Promise(s=>{const r=i.write("Waiting for service...","system");let n=0;const o=30;setTimeout(()=>{const a=setInterval(async()=>{n++,i.update(r,`Waiting for service... ${n}s`,"system");try{const h=new AbortController,l=setTimeout(()=>h.abort(),3e3);await fetch(`${il}/api/stats`,{signal:h.signal}),clearTimeout(l),clearInterval(a),i.update(r,`Service connected. (${n+4}s)`,"success"),s();return}catch{}n>=o&&(clearInterval(a),i.update(r,`Service did not respond within ${o+4}s. Check manually.`,"warning"),s())},1e3)},4e3)})}}const Ot="\x1B[",Ne=`${Ot}0m`,Oa=`${Ot}32m`,Or=`${Ot}33m`,Fr=`${Ot}31m`,E_=`${Ot}36m`,Rt=`${Ot}90m`,Fa=`${Ot}1m`;function Vt(e){return e>=1073741824?`${(e/1073741824).toFixed(1)}G`:e>=1048576?`${(e/1048576).toFixed(0)}M`:e>=1024?`${(e/1024).toFixed(0)}K`:`${e}B`}function ho(e){const t=Math.floor(e/86400),i=Math.floor(e%86400/3600),s=Math.floor(e%3600/60);return t>0?`${t}d ${i}h ${s}m`:i>0?`${i}h ${s}m`:`${s}m`}function R_(e,t){const i=Math.max(0,Math.min(100,e)),s=Math.round(i/100*t),r=t-s,n=i>=90?Fr:i>=70?Or:Oa,o=`${n}${"█".repeat(s)}${Ne}${Rt}${"░".repeat(r)}${Ne}`,a=`${i.toFixed(1)}%`.padStart(6);return`[${o}] ${n}${a}${Ne}`}function B_(e){return e>=80?`${Fr}${Fa}${e.toFixed(1)}°C${Ne}`:e>=60?`${Or}${e.toFixed(1)}°C${Ne}`:`${Oa}${e.toFixed(1)}°C${Ne}`}const wi=2,co=" ";function Gt(e,t){const i=" ".repeat(wi),s=t-wi,r=co.length,n=[];let o="",a=0;for(const h of e){const l=hu(h);a===0?(o=h,a=l):a+r+l<=s?(o+=co+h,a+=r+l):(n.push(i+o),o=h,a=l)}return a>0&&n.push(i+o),n}function M_(e,t,i){var d,u;const s=e.node_name||"unknown",r=e.version?`v${e.version}`:"",n=(d=t.system)!=null&&d.uptime?ho(t.system.uptime):"?",o=ho(e.uptime_seconds||0),a=Math.max(3,i-wi*2),h=((u=t.cpu.load_avg)==null?void 0:u["1min"].toFixed(2))??"?",l=t.cpu.load_avg?`${h} ${t.cpu.load_avg["5min"].toFixed(2)} ${t.cpu.load_avg["15min"].toFixed(2)}`:"?",c=i>=60?l:h;return[` ${E_}${Fa}${s}${Ne} ${Rt}${r}${Ne}`,` ${Rt}${"─".repeat(a)}${Ne}`,...Gt([w("Sys",y(n)),w("Svc",y(o)),w("Load",y(c))],i)]}function D_(e,t){const s=wi+4+1+2+6,r=Math.max(6,Math.min(30,t-s)),n=s+r,o=t-n-2,a=[""],h=`${e.cpu.count} core${e.cpu.count>1?"s":""}`,l=`${Vt(e.memory.used)}/${Vt(e.memory.total)}`,c=`${Vt(e.disk.used)}/${Vt(e.disk.total)}`,d=(f,_,p)=>{const g=R_(_,r),E=o>=p.length?` ${Ae(p)}`:"";return` ${b(f.padEnd(4))}${g}${E}`};a.push(d("CPU",e.cpu.usage_percent,h)),a.push(d("Mem",e.memory.usage_percent,l)),a.push(d("Dsk",e.disk.usage_percent,c));const u=Object.entries(e.temperatures||{});if(u.length>0){const f=u.map(([_,p])=>`${Ae(_+":")} ${B_(p)}`);a.push(...Gt(f,t))}return a}function L_(e,t){var l,c;const i=e.neighbors||{},s=Object.keys(i).length,r=Object.values(i).filter(d=>d.zero_hop).length,n=((c=(l=e.config)==null?void 0:l.repeater)==null?void 0:c.mode)||"?",o=e.noise_floor_dbm!=null?`${e.noise_floor_dbm}dBm`:"?",a=e.duty_cycle_percent??0,h=["",` ${Rt}MESH${Ne}`];return h.push(...Gt([w("Mode",y(n)),w("Nbrs",`${y(String(r))}${Ae(`/${s}`)}`),w("Noise",y(o)),w("Air",y(`${a.toFixed(1)}%`))],t)),h.push(...Gt([w("RX",y(String(e.rx_count??0))),w("TX",y(String(e.tx_count??0))),w("FWD",y(String(e.forwarded_count??0))),w("Drop",y(String(e.dropped_count??0)))],t)),h.push(...Gt([w("RX/h",y(String(Math.round(e.rx_per_hour??0)))),w("FWD/h",y(String(Math.round(e.forwarded_per_hour??0))))],t)),h}function T_(e,t){if(!e.network)return[];const i=["",` ${Rt}NET${Ne}`];return i.push(...Gt([w("TX",y(Vt(e.network.bytes_sent))),w("RX",y(Vt(e.network.bytes_recv))),w("Pkt",`${y(String(e.network.packets_sent))}${Ae("/")}${y(String(e.network.packets_recv))}`)],t)),i}function $_(e,t,i){if(e.length===0)return[];const s=t>=50,r=t>=50?6:5,n=t>=50?6:5,o=s?7:0,a=wi+0,h=Math.max(4,t-a-o-r-n-4),l=3,c=t>=50?8:5,d=i!=null?Math.max(0,Math.min(c,i-l)):c;if(d<=0)return[];const u=["",` ${Rt}PROCS${Ne}`],f=(s?"PID".padEnd(o):"")+"CPU".padStart(r)+"MEM".padStart(n)+" NAME";u.push(` ${Ae(f)}`);for(const _ of e.slice(0,d)){const p=s?Ae(String(_.pid).padEnd(o)):"",g=(t>=50?_.cpu_percent.toFixed(1):_.cpu_percent.toFixed(0)).padStart(r),E=(t>=50?_.memory_percent.toFixed(1):_.memory_percent.toFixed(0)).padStart(n),z=_.name.length>h?_.name.slice(0,h-1)+"…":_.name,O=_.cpu_percent>=50?Fr:_.cpu_percent>=20?Or:"",M=O?`${O}${g}${Ne}`:g;u.push(` ${p}${M}${Ae(E)} ${z}`)}return u}function A_(){return new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}function uo(e,t,i,s,r){if(!e||!t)return` ${Rt}Waiting for data…${Ne}`;const n=M_(e,t,s),o=D_(t,s),a=L_(e,s),h=T_(t,s),l=["",` ${Rt}${A_()} · Ctrl+C to exit${Ne}`],c=[...n,...o,...a,...h,...l],d=r?yr(c,s):0,u=r?Math.max(0,r-d):void 0,f=$_(i,s,u),_=[...c.slice(0,-l.length),...f,...l];return r&&_.length>r&&(_.length=r),_.join(` `)}const P_=3e3;class N_ extends ee{constructor(){super(...arguments);D(this,"name","top");D(this,"description","Live system overview (Ctrl+C to exit)");D(this,"aliases",["htop"])}async execute({output:i,rawInput:s,cols:r,signal:n}){var l,c;if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("top"),` ${b("Live-updating system overview combining hardware")}`,` ${b("stats, mesh metrics, and running processes.")}`,` ${b("Refreshes every 3s. Press Ctrl+C to exit.")}`,"",R("top","start live display"),"",W("Sections"),` ${b("Header Node name, version, uptime, load average")}`,` ${b("Gauges CPU, memory, disk usage with bar charts")}`,` ${b("Mesh Mode, neighbors, packet counts, airtime")}`,` ${b("Network TCP/IP bytes and packet counters")}`,` ${b("Processes Top 8 processes by CPU usage")}`,"",W("Aliases"),` ${b("htop")}`].join(` `));return}let o=null,a=[],h=wt.getState().stats;try{const[d,u]=await Promise.all([Qi(),Wr()]);d.success&&d.data&&(o=d.data),u.success&&u.data&&(a=u.data.processes.sort((f,_)=>_.cpu_percent-f.cpu_percent))}catch{}if(!n.aborted){(l=i.enterFullscreen)==null||l.call(i);try{const d=i.write(uo(h,o,a,i.cols??r,i.rows));await new Promise(u=>{if(n.aborted){u();return}const f=async()=>{h=wt.getState().stats;try{const[p,g]=await Promise.all([Qi(),Wr()]);p.success&&p.data&&(o=p.data),g.success&&g.data&&(a=g.data.processes.sort((E,z)=>z.cpu_percent-E.cpu_percent))}catch{}n.aborted||i.update(d,uo(h,o,a,i.cols??r,i.rows))},_=setInterval(()=>{if(n.aborted){clearInterval(_),u();return}f()},P_);n.addEventListener("abort",()=>{clearInterval(_),u()},{once:!0})})}finally{(c=i.exitFullscreen)==null||c.call(i)}}}}const _o=["DONT PANIC","C0FFEE","FEED C0DE","LOL","I CANNOT DO THAT"];function Hr(){return _o[Math.floor(Math.random()*_o.length)]}const wr=new EventTarget,Cr="shell-phrase";function Ha(e){wr.dispatchEvent(new CustomEvent(Cr,{detail:e??Hr()}))}function I_(e){const t=i=>e(i.detail);return wr.addEventListener(Cr,t),()=>wr.removeEventListener(Cr,t)}class O_ extends ee{constructor(){super(...arguments);D(this,"name","fortune");D(this,"description","Display a fortune on the header");D(this,"aliases",["lol"])}execute({output:i}){const s=Hr();Ha(s),i.write(b(` ${s}`))}}const xr=new EventTarget,kr="party-time";function F_(){xr.dispatchEvent(new Event(kr))}function H_(e){return xr.addEventListener(kr,e),()=>xr.removeEventListener(kr,e)}class W_ extends ee{constructor(){super(...arguments);D(this,"name","partytime");D(this,"description","Party on, Garth!");D(this,"aliases",["party","excellent","waynesworld"])}execute({output:i}){F_(),Ha("PARTY 0N GARTH"),i.write(b(" SCHWING!"))}}class z_ extends ee{constructor(){super(...arguments);D(this,"name","ver");D(this,"description","Show version info");D(this,"aliases",["version"])}async execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("ver"),` ${b("Display pyMC_Repeater, core, and console version.")}`,` ${b('Equivalent to firmware serial CLI "ver" command.')}`,"",R("ver","show version"),"",W("Aliases"),` ${b("version")}`].join(` -`));return}const r=i.write("processing...","system");try{const n=await rt();i.update(r,[` ${w("pyMC_Repeater",y(`v${n.version||"?"}`))}`,` ${w("pyMC_Core",y(n.core_version||"?"))}`,` ${w("pyMC_Console",y("v0.9.290"))}`].join(` +`));return}const r=i.write("processing...","system");try{const n=await rt();i.update(r,[` ${w("pyMC_Repeater",y(`v${n.version||"?"}`))}`,` ${w("pyMC_Core",y(n.core_version||"?"))}`,` ${w("pyMC_Console",y("v0.9.291"))}`].join(` `),"value")}catch(n){i.update(r,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}class U_ extends ee{constructor(){super(...arguments);D(this,"name","clock");D(this,"description","Show system UTC time")}execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("clock"),` ${b("Display the current system UTC time.")}`,` ${b('Equivalent to firmware serial CLI "clock" command.')}`,` ${b("Use to verify NTP sync and correlate packet timestamps.")}`,"",R("clock","show UTC time")].join(` `));return}const r=new Date;i.write([` ${w("UTC",y(r.toUTCString()))}`,` ${w("ISO",y(r.toISOString()))}`,` ${w("Unix",y(String(Math.floor(r.getTime()/1e3))))}`].join(` `),"value")}}class j_ extends ee{constructor(){super(...arguments);D(this,"name","stats-packets");D(this,"description","Packet counters")}async execute({output:i,rawInput:s}){if(this.argsAfterName(s).toLowerCase().trim()==="help"){i.write([W("stats-packets"),` ${b("Display packet counters: sent, received, forwarded, dropped.")}`,` ${b('Equivalent to firmware serial CLI "stats-packets" command.')}`,"",R("stats-packets","show packet counters")].join(` @@ -154,9 +154,9 @@ See: /etc/polkit-1/localauthority/50-local.d/pymc-repeater.pkla`,"error");return `),"value")}catch(n){i.update(r,`Error: ${n instanceof Error?n.message:"Command failed"}`,"error")}}}const Ps=["@@@@@@@ @@@ @@@ @@@@@@@@@@ @@@@@@@ ","@@@@@@@@ @@@ @@@ @@@@@@@@@@@ @@@@@@@@ ","@@! @@@ @@! !@@ @@! @@! @@! !@@ ","!@! @!@ !@! @!! !@! !@! !@! !@! ","@!@@!@! !@!@! @!! !!@ @!@ !@! ","!!@!!! @!!! !@! ! !@! !!! ","!!: !!: !!: !!: :!! ",":!: :!: :!: :!: :!: "," :: :: ::: :: ::: ::: "," : : : : :: :: : "],po=To-1;class V_ extends ee{constructor(){super(...arguments);D(this,"name","hello");D(this,"description","Play the PYMC burst intro");D(this,"aliases",["hi","intro"])}async execute({output:i,signal:s}){if(s.aborted)return;let r=0;const n=i.write(gi(Ps,0).join(` `));try{await new Promise(o=>{const a=setInterval(()=>{if(s.aborted||r>=po){clearInterval(a),s.aborted||i.update(n,gi(Ps,po).join(` `)),o();return}r++,i.update(n,gi(Ps,r).join(` -`))},Do);s.addEventListener("abort",()=>{clearInterval(a),o()},{once:!0})})}finally{Lo()}}}function G_(){const e=new Vd,t=new wu(e);return e.register(t,new Cu,new xu,new z_,new U_,new ku,new Eu,new Ru,new j_,new K_,new q_,new Hu,new Yu,new o_,new Xu,new Zu,new a_,new y_,new b_,new w_,new C_,new x_,new k_,new N_,new O_,new W_,new V_),e}const Y_=()=>typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),mo=xo(e=>({entries:[],commandHistory:[],isInitialized:!1,addEntry:t=>{const i=Y_(),s={...t,id:i,timestamp:Date.now()};return e(r=>({entries:[...r.entries,s]})),i},updateEntry:(t,i)=>{e(s=>({entries:s.entries.map(r=>r.id===t?{...r,...i}:r)}))},addCommand:t=>{e(i=>({commandHistory:[...i.commandHistory,t]}))},clearEntries:()=>{e({entries:[],commandHistory:[]})},setInitialized:t=>{e({isInitialized:t})}}));function X_({isOpen:e,onClose:t}){const i=$a(),s=wt(n=>n.stats),r=n=>{const o=i.find(a=>a.id===n);o&&Ia(o,s)};return m.jsxs(Eo,{open:e,onClose:t,size:"sm",children:[m.jsx(Ro,{icon:m.jsx(jr,{size:20}),title:"Download Captures",onClose:t}),m.jsx(Bo,{className:"flex flex-col gap-2",children:i.length===0?m.jsxs("div",{className:"flex flex-col items-center gap-2 py-6 text-fg-muted",children:[m.jsx(Bl,{className:"w-8 h-8 opacity-40"}),m.jsx("p",{className:"text-sm",children:"No captures available."})]}):i.map(n=>m.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 radius-inset bg-elevated/50 border border-edge-subtle",children:[m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("p",{className:"type-label text-fg-primary truncate",children:n.filename}),m.jsxs("p",{className:"text-xs text-fg-muted mt-0.5",children:[n.packetCount," packets · ",n.durationSec,"s · ~",Ji(n.sizeBytes)]})]}),m.jsx(il,{plain:!0,color:"primary",onClick:()=>r(n.id),title:"Download",className:"flex-shrink-0",children:m.jsx(jr,{"data-slot":"icon"})})]},n.id))})]})}function J_(){const e=$a(),[t,i]=U.useState(!1);return m.jsxs(m.Fragment,{children:[m.jsx($o,{icon:m.jsx(El,{size:20}),onClick:()=>i(!0),title:e.length>0?`Download captures (${e.length})`:"Captures",variant:"red",iconActiveColor:pe.red}),m.jsx(X_,{isOpen:t,onClose:()=>i(!1)})]})}const go=[{name:"acl",description:"Access control list statistics — identity and client counts.",body:["```","> acl","ACL Stats",""," Identities 2"," Total clients 5"," Admin 2"," Guest 3"," Repeater 1 ids 3 clients"," Room Server 1 ids 2 clients","```"],searchText:"acl access control list statistics identity client"},{name:"advert",description:"Broadcast a repeater advertisement to the mesh.",body:["```","> advert","✓ Advert sent","```"],searchText:"advert advertisement broadcast mesh"},{name:"board",description:"Hardware and platform info — CPU, memory, disk, temperatures, network I/O.",body:["```","> board"," Node Local-Node"," Runtime pyMC_Repeater v1.0.0"," Core v1.12.0",""," CPU 12.3% 4 cores"," Load 0.42 / 0.38 / 0.35"," Temp 48.2°C",""," Memory 412 MB / 664 MB 62%"," Disk 5.2 GB / 28.7 GB 18%",""," System uptime 14d 3h 22m"," Service uptime 2d 14h 32m"," Net TX/RX 128 MB / 342 MB","```"],searchText:"board hardware platform cpu memory disk temperature network"},{name:"cap",description:"Packet capture — start, stop, list, and export captures.",body:["**Sub-commands:** `start cap [sec]` · `end cap` · `list cap` · `export cap [id]`","","**`start cap [seconds]`** — Begin capture (default 120s, max 3600):","```","> start cap","Capturing... 118s remaining (4 captured)","","✓ Capture complete!"," Captured: 23 packets"," Duration: 120s"," Size: ~14.2 KB","```","","**`end cap`** — Stop capture early:","```","> end cap","✓ Capture stopped!"," Captured: 12 packets","```","","**`list cap`** — List saved captures:","```","> list cap","Capture Reports (2):"," 1. 23 pkts • 120s • ~14.2 KB (id: abc123)"," 2. 12 pkts • 34s • ~7.1 KB (id: def456)","```","","**`export cap [id]`** — Download by ID or index:","```","> export cap 1","✓ Downloading capture-abc123.json...","```"],searchText:"cap capture packet start end list export download diagnostic"},{name:"clear",description:"Clear the terminal screen.",body:["**Alias:** `cls`","```","> clear","```"],searchText:"clear cls screen"},{name:"clock",description:"Current system UTC time. Useful for NTP sync and packet timestamp correlation.",body:["```","> clock"," UTC Wed, 12 Feb 2026 00:01:34 GMT"," ISO 2026-02-12T00:01:34.000Z"," Unix 1770768094","```"],searchText:"clock time utc ntp unix iso timestamp"},{name:"convert",description:"Convert between hex and base64 encodings.",body:["**Usage:** `convert hex ` · `convert base64 `","```","> convert hex 48656C6C6F"," hex 48656C6C6F"," base64 SGVsbG8=","","> convert base64 SGVsbG8="," base64 SGVsbG8="," hex 48656C6C6F","```"],searchText:"convert hex base64 encoding decode"},{name:"get",description:"Read a configuration parameter.",body:[],interactive:"get",searchText:"get read config parameter name role lat lon radio freq tx bw sf cr txdelay mode duty flood advert"},{name:"help",description:"Show all commands, or detailed help for a specific command.",body:["**Alias:** `?` · `h`","```","> help Full command listing","> help ping Detailed help for ping","> ping help Same thing","```"],searchText:"help commands reference guide"},{name:"identities",description:"List all configured repeater and room server identities.",body:["**Alias:** `id` · `ids`","```","> identities","Identities (2)",""," 1. Local-Node repeater 0A1B2C3D"," 2. local-room room_server 0E5F6A7B","```"],searchText:"identities id ids repeater room server identity"},{name:"keys",description:"List configured transport encryption keys.",body:["```","> keys","Transport Keys (1)",""," main-transport flood: allow","```"],searchText:"keys transport encryption"},{name:"neighbors",description:"Direct RF neighbors with signal quality, RSSI, SNR, distance, and last-heard.",body:["**Alias:** `nb`","","**Sort qualifiers:** `sig` · `name` · `rssi` · `snr` · `dist` · `heard`","```","> neighbors","Direct Neighbors (4)","","+-------+-----------+-----------+--------+-------+--------+","| ▁▃▅▇█ | Node-1 | -87 dBm | 8.5 dB | 2.1km | 3m ago |","| ▁▃▅▇. | Relay-2 | -94 dBm | 5.2 dB | 4.8km | 1m ago |","| ▁▃▅.. | Node-3 | -108 dBm | 1.0 dB | 8.3km | 5m ago |","| ▁▃... | Node-4 | -118 dBm | -3 dB | 14km | 12m ago|","+-------+-----------+-----------+--------+-------+--------+","| SIG | NAME | RSSI | SNR | DIST | HEARD |","+-------+-----------+-----------+--------+-------+--------+","SF11/250kHz ant 3.5dBi nf -112dBm","```","","- **sig** — signal grade (weakest first)","- **name** — alphabetical","- **rssi** — RSSI (weakest first)","- **snr** — SNR (lowest first)","- **dist** — distance (closest first)","- **heard** — last seen (oldest first)"],searchText:"neighbors nb signal rssi snr distance sort direct rf"},{name:"packets",description:"Packet counters — received, transmitted, forwarded, dropped.",body:["```","> packets","Packet Stats 1321 total",""," Received 1284"," Transmitted 37"," Forwarded 891"," Dropped 14","```"],searchText:"packets received transmitted forwarded dropped counter"},{name:"ping",description:"Ping a neighbor by name or hex prefix. Shows RTT, signal quality, and path.",body:["**Usage:** `ping [timeout]`","```","> ping Node-1","▁▃▅▇█ Reply from Node-1",""," RTT 342ms"," RSSI -87 dBm"," SNR 8.5 dB"," Path direct"," Quality Excellent","```","","Custom timeout (default 30s):","```","> ping Node-4 60","```"],searchText:"ping rtt round trip time signal quality path neighbor"},{name:"restart",description:"Restart the pymc-repeater systemd service.",body:["**Alias:** `reboot`","```","> restart","Service is restarting (connection dropped).","Waiting for service... 8s","Service connected. (12s)","```","","The terminal polls automatically until the service comes back up."],searchText:"restart reboot service systemd"},{name:"rooms",description:"Room server statistics — message counts, active clients, sync status.",body:["```","> rooms","Rooms (1)",""," Local Room"," msgs 142 clients 3/5 sync running","```"],searchText:"rooms room server messages clients sync"},{name:"set",description:"Write a configuration parameter.",body:[],interactive:"set",searchText:"set write config parameter name lat lon freq tx bw sf cr txdelay mode duty log flood advert"},{name:"stats-core",description:"Engine vitals — uptime, duplicate cache, CPU, memory, temperature.",body:["```","> stats-core"," Core Stats",""," Uptime 2d 14h 32m"," Dup cache 128 entries TTL 900s",""," CPU 12.3% 4 cores"," Load 0.42 / 0.38 / 0.35"," Memory 412 MB / 664 MB 62%"," Temp 48.2°C","```"],searchText:"stats core engine vitals uptime cache cpu memory temperature"},{name:"stats-packets",description:"Firmware-compatible packet counters with rates and duplicate cache depth.",body:["```","> stats-packets"," Packet Counters",""," RX 1284 22.4/hr"," TX 37"," Forwarded 891 15.2/hr"," Dropped 14",""," Dup cache 128","```"],searchText:"stats packets firmware counter rate duplicate cache"},{name:"stats-radio",description:"Radio health — noise floor, airtime, duty cycle, and radio configuration.",body:["```","> stats-radio"," Radio Stats",""," Radio 906.875 MHz SF11 BW 250 kHz CR 4/5 22 dBm",""," Noise floor -112 dBm"," Airtime used 4.2s remaining: 55.8m"," Total airtime 1.2m"," Duty cycle 1.2%"," Utilization 0.8%","```"],searchText:"stats radio noise floor airtime duty cycle utilization"},{name:"status",description:"Quick summary of mode, neighbors, and uptime.",body:["**Alias:** `st`","```","> status","Local-Node repeater",""," Mode forward"," Neighbors 4 direct 12 total"," RX / TX 1284 / 37"," Uptime 2d 14h 32m","```"],searchText:"status st summary mode neighbors uptime"},{name:"top",description:"Live-updating system overview — CPU/memory gauges, mesh counters, processes.",body:["**Alias:** `htop`","","Refreshes every 3s. Press **Ctrl+C** to exit.","```","> top","Local-Node v1.0.0","──────────────────────────────────"," Sys 14d 3h 22m Svc 2d 14h 32m Load 0.42 0.38 0.35",""," CPU [████░░░░░░░░░░░░] 12.3% 4 cores"," Mem [██████████░░░░░░] 62.1% 412M/664M"," Dsk [███░░░░░░░░░░░░░] 18.4% 5.2G/28.7G"," cpu_thermal: 48.2°C",""," MESH"," Mode forward Nbrs 4/12 Noise -112dBm Air 1.2%"," RX 1284 TX 37 FWD 891 Drop 14"," RX/h 22 FWD/h 15",""," PROCS"," CPU MEM NAME"," 8.2 3.1 python3"," 2.1 1.4 cherrypy",""," 14:32:08 · Ctrl+C to exit","```","","Uses alternate screen buffer — scrollback is preserved."],searchText:"top htop live system overview cpu memory gauges mesh processes"},{name:"uptime",description:"How long the repeater service has been running.",body:["```","> uptime","Uptime 2d 14h 32m","```"],searchText:"uptime service running duration"},{name:"ver",description:"Version info for all three components.",body:["**Alias:** `version`","```","> ver"," pyMC_Repeater v1.0.0"," pyMC_Core v1.12.0"," pyMC_Console v1.0.0","```"],searchText:"ver version pymc repeater core console"}],Z_=[{param:"name",category:"Identity",example:["> get name","name Local-Node"]},{param:"role",category:"Identity",example:["> get role","role repeater"]},{param:"lat",category:"Identity",example:["> get lat","lat 34.0522"],range:"-90 to 90"},{param:"lon",category:"Identity",example:["> get lon","lon -118.2437"],range:"-180 to 180"},{param:"public.key",category:"Identity",example:["> get public.key","public.key 0A1B2C3D4E5F..."]},{param:"radio",category:"Radio",example:["> get radio"," freq 906.875 MHz"," bw 250 kHz"," sf 11"," cr 4/5"," tx 22 dBm"]},{param:"freq",category:"Radio",example:["> get freq","freq 906.875 MHz"],range:"100–1000 MHz"},{param:"tx",category:"Radio",example:["> get tx","tx 22 dBm"],range:"2–22 dBm"},{param:"bw",category:"Radio",example:["> get bw","bw 250 kHz"],range:"7.8–500 kHz"},{param:"sf",category:"Radio",example:["> get sf","sf 11"],range:"5–12"},{param:"cr",category:"Radio",example:["> get cr","cr 4/5"],range:"5–8"},{param:"af",category:"Timing",example:["> get af","⚠ airtime_factor not yet exposed by pyMC_Repeater API."," Firmware range: 0-9. Tracked in CLI-Alignment.md."],range:"0–9 (pending)"},{param:"txdelay",category:"Timing",example:["> get txdelay","txdelay 1.0"],range:"0.0–5.0"},{param:"direct.txdelay",category:"Timing",example:["> get direct.txdelay","direct.txdelay 0.5"],range:"0.0–5.0"},{param:"rxdelay",category:"Timing",example:["> get rxdelay","rxdelay 0.0"],range:"≥ 0"},{param:"mode",category:"Repeater",example:["> get mode","mode forward"],range:"forward / monitor"},{param:"duty",category:"Repeater",example:["> get duty","duty on"],range:"on / off"},{param:"flood.max",category:"Repeater",example:["> get flood.max","flood.max 3"],range:"0–64"},{param:"advert.interval",category:"Repeater",example:["> get advert.interval","advert.interval 120m"],range:"0 (off) or 1–10080 min"},{param:"multi.acks",category:"Advanced",example:["> get multi.acks","multi.acks 0"],range:"0–255"},{param:"int.thresh",category:"Advanced",example:["> get int.thresh","int.thresh -120 dBm"],range:"-200 to 0 dBm"},{param:"agc.reset.interval",category:"Advanced",example:["> get agc.reset.interval","agc.reset.interval 0"],range:"≥ 0 (×4)"}],Q_=[{param:"name",category:"Identity",example:["> set name Local-Node","OK - node_name set to Local-Node"],range:"text (no [ ] \\ / : , ? *)"},{param:"lat",category:"Identity",example:["> set lat 34.0522","OK - latitude set to 34.0522"],range:"-90 to 90"},{param:"lon",category:"Identity",example:["> set lon -118.2437","OK - longitude set to -118.2437"],range:"-180 to 180"},{param:"freq",category:"Radio",example:["> set freq 906.875","OK - frequency set to 906875000"],range:"100–1000 MHz"},{param:"tx",category:"Radio",example:["> set tx 22","OK - tx_power set to 22"],range:"2–22 dBm"},{param:"bw",category:"Radio",example:["> set bw 250","OK - bandwidth set to 250000"],range:"7.8, 10.4, 15.6, 20.8, 31.25, 41.7, 62.5, 125, 250, 500 kHz"},{param:"sf",category:"Radio",example:["> set sf 11","OK - spreading_factor set to 11"],range:"5–12"},{param:"cr",category:"Radio",example:["> set cr 5","OK - coding_rate set to 5"],range:"5–8"},{param:"af",category:"Timing",example:["> set af 2","⚠ airtime_factor not yet exposed by pyMC_Repeater API."," Firmware range: 0-9. Needs backend support."],range:"0–9 (pending)"},{param:"txdelay",category:"Timing",example:["> set txdelay 1.0","OK - tx_delay_factor set to 1"],range:"0.0–5.0"},{param:"direct.txdelay",category:"Timing",example:["> set direct.txdelay 0.5","OK - direct_tx_delay_factor set to 0.5"],range:"0.0–5.0"},{param:"rxdelay",category:"Timing",example:["> set rxdelay 0","OK - rx_delay_base set to 0"],range:"≥ 0"},{param:"mode",category:"Repeater",example:["> set mode forward","OK - Mode set to forward"],range:"forward / monitor"},{param:"flood.max",category:"Repeater",example:["> set flood.max 3","OK - max_flood_hops set to 3"],range:"0–64"},{param:"advert.interval",category:"Repeater",example:["> set advert.interval 120","OK - Local advert interval set to 120m"],range:"0 (off) or 1–10080 min"},{param:"duty",category:"Repeater",example:["> set duty on","OK - Duty cycle enabled"],range:"on / off"},{param:"log",category:"Repeater",example:["> set log info","OK - Log level set to INFO"],range:"debug, info, warning, error"},{param:"multi.acks",category:"Advanced",example:["> set multi.acks 0","OK - multi_acks set to 0"],range:"0–255"},{param:"int.thresh",category:"Advanced",example:["> set int.thresh -120","OK - interference_threshold set to -120"],range:"-200 to 0 dBm"},{param:"agc.reset.interval",category:"Advanced",example:["> set agc.reset.interval 8","OK - AGC reset interval set to 8"],range:"≥ 0 (rounded to ×4)"},{param:"prv.key",category:"Advanced",example:["> set prv.key <128-hex>","To set this key, run on the Pi:",""," sudo ./convert_firmware_key.sh ","","Then restart: sudo systemctl restart pymc-repeater"],range:"128-char hex (SSH only)"}];function ef({mode:e}){const t=e==="get"?Z_:Q_,[i,s]=U.useState(0),r=t[i],n=U.useMemo(()=>{const o=new Map;for(const a of t){const h=o.get(a.category)||[];h.push(a),o.set(a.category,h)}return Array.from(o.entries())},[t]);return m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsx("div",{className:"flex flex-col gap-1.5",children:n.map(([o,a])=>m.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[m.jsx("span",{className:"text-xs text-fg-muted w-16 shrink-0 text-right pr-1",children:o}),a.map(h=>{const l=t.indexOf(h),c=l===i;return m.jsx("button",{onClick:()=>s(l),className:es("px-1.5 py-0.5 type-data-xs radius-badge transition-colors cursor-pointer",c?"bg-sys-blue text-fg-invert font-semibold":"bg-elevated text-fg-secondary hover:bg-elevated/80 hover:text-sys-blue"),children:h.param},h.param)})]},o))}),m.jsx("pre",{className:"px-3 py-2.5 radius-inner bg-body text-fg-secondary type-code overflow-x-auto border border-edge-subtle",children:r.example.map((o,a)=>m.jsx("div",{children:o||" "},a))}),r.range&&m.jsxs("p",{className:"text-xs text-fg-muted",children:[m.jsx("span",{className:"text-fg-secondary font-medium",children:r.param})," — ",r.range]})]})}function vo(e,t){const i=e.split(/(\*\*[^*]+\*\*)/g);return m.jsx("span",{children:i.map((s,r)=>s.startsWith("**")&&s.endsWith("**")?m.jsx("strong",{className:"text-fg-primary font-semibold",children:s.slice(2,-2)},r):s.split(/(`[^`]+`)/g).map((o,a)=>o.startsWith("`")&&o.endsWith("`")?m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue type-data-xs",children:o.slice(1,-1)},`${r}-${a}`):m.jsx("span",{children:o},`${r}-${a}`)))},t)}function tf({lines:e}){const t=[];let i=0;for(;im.jsx("div",{children:n||" "},o))},t.length));continue}if(!s.trim()){t.push(m.jsx("div",{className:"h-1.5"},t.length)),i++;continue}if(s.startsWith("- ")){t.push(m.jsxs("div",{className:"flex gap-2 text-sm text-fg-secondary pl-2 py-0.5",children:[m.jsx("span",{className:"text-fg-muted shrink-0",children:"•"}),m.jsx("span",{children:vo(s.slice(2),0)})]},t.length)),i++;continue}t.push(m.jsx("p",{className:"text-sm text-fg-secondary py-0.5",children:vo(s,0)},t.length)),i++}return m.jsx(m.Fragment,{children:t})}function sf({isOpen:e,onClose:t,onUseCommand:i}){const[s,r]=U.useState(""),n=U.useMemo(()=>{if(!s.trim())return go;const a=s.toLowerCase();return go.filter(h=>h.name.includes(a)||h.searchText.includes(a)||h.description.toLowerCase().includes(a))},[s]),o=s.trim().length>0;return m.jsxs(Eo,{open:e,onClose:t,size:"3xl",motionPlus:!0,className:"sm:min-w-[540px] md:min-w-[680px]",children:[m.jsx(Ro,{icon:m.jsx(Ao,{size:20}),title:"Terminal Command Guide",onClose:t}),m.jsxs(Bo,{className:"flex flex-col gap-0 !px-0 !py-0",children:[m.jsx("div",{className:"sticky top-0 z-10 px-5 py-3 border-b border-edge-subtle bg-surface/95 backdrop-blur-sm",children:m.jsxs("div",{className:"relative",children:[m.jsx(Kr,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-fg-muted"}),m.jsx("input",{type:"text",value:s,onChange:a=>r(a.target.value),placeholder:"Search commands...",className:"w-full pl-8 pr-3 py-1.5 text-sm bg-elevated border border-edge-subtle radius-inner text-fg-primary placeholder:text-fg-muted focus:outline-none focus:ring-1 focus:ring-sys-blue/50",autoFocus:!0})]})}),m.jsxs("div",{className:"overflow-y-auto px-5 py-3 h-[420px] sm:h-[520px] md:h-[600px]",children:[m.jsx(_s,{mode:"popLayout",children:n.length===0?m.jsxs(Ti.div,{initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:Ur.normal,ease:zr.easeOut},className:"flex flex-col items-center gap-2 py-10 text-fg-muted",children:[m.jsx(Kr,{className:"w-6 h-6 opacity-40"}),m.jsxs("p",{className:"text-sm",children:['No commands match "',s,'"']})]},"empty"):m.jsx(Ti.div,{initial:!1,className:"flex flex-col gap-1",children:m.jsx(_s,{initial:!1,children:n.map(a=>m.jsx(Ti.div,{layout:"position",initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:sl.fade,className:"min-w-0",children:m.jsx(rl,{children:({open:h})=>m.jsxs("div",{className:es("radius-inner border transition-colors",h?"border-edge-subtle bg-elevated/50":"border-transparent hover:bg-elevated/30"),children:[m.jsxs("div",{className:"flex items-center w-full min-w-0",children:[m.jsxs(nl,{className:"flex items-center gap-3 flex-1 min-w-0 px-3 py-2 text-left cursor-pointer",children:[m.jsx(bl,{size:14,className:es("shrink-0 text-fg-muted transition-transform duration-150",h&&"rotate-90")}),m.jsx("code",{className:"text-sm font-semibold text-sys-blue font-mono shrink-0",children:a.name}),m.jsx("span",{className:"text-xs text-fg-muted truncate min-w-0",children:a.description})]}),i&&m.jsx("button",{onClick:l=>{l.stopPropagation(),i(a.name)},className:"shrink-0 mr-2 px-2 py-0.5 text-xs font-semibold uppercase tracking-wider radius-badge bg-elevated text-fg-muted hover:text-sys-blue hover:bg-elevated/80 transition-colors cursor-pointer",title:`Use "${a.name}" in terminal`,children:"use"})]}),m.jsx(ol,{className:"px-3 pb-3 pt-0 pl-9",children:a.interactive?m.jsx(ef,{mode:a.interactive}):m.jsx(tf,{lines:a.body})})]})})},a.name))})},"list")}),m.jsx(_s,{children:!o&&m.jsxs(Ti.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:6},transition:{duration:Ur.normal,ease:zr.easeOut},className:"mt-4 px-3 py-3 radius-inner border border-edge-subtle bg-elevated/30",children:[m.jsx("p",{className:"text-xs font-semibold text-fg-muted mb-2",children:"Tips"}),m.jsxs("div",{className:"flex flex-col gap-1 text-xs text-fg-muted",children:[m.jsxs("p",{children:["Type ",m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue font-mono",children:" help"})," in the terminal for detailed usage."]}),m.jsxs("p",{children:["Most commands have shorter aliases (e.g. ",m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue font-mono",children:"st"}),", ",m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue font-mono",children:"nb"}),", ",m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue font-mono",children:"id"}),")."]}),m.jsxs("p",{children:["Signal bars ",m.jsx("span",{className:"font-mono",children:"▁▃▅▇█"})," are colored by link quality grade based on RSSI, SNR, and radio config."]}),m.jsx("p",{children:"Captures are stored in browser session only — export before closing the tab."})]})]})})]})]})]})}function rf({onUseCommand:e}){const[t,i]=U.useState(!1),s=e?r=>{i(!1),e(r)}:void 0;return m.jsxs(m.Fragment,{children:[m.jsx($o,{icon:m.jsx(Ao,{size:17,className:"translate-y-px"}),onClick:()=>i(!0),title:"CLI Command Guide"}),m.jsx(sf,{isOpen:t,onClose:()=>i(!1),onUseCommand:s})]})}const Wa=G_(),Zi=Wa.all().flatMap(e=>[{cmd:e.name,desc:e.description,params:e.params,required:!!e.params},...e.aliases.filter(t=>t.includes(" ")).map(t=>({cmd:t,desc:e.description,params:e.params,required:!!e.params}))]);Zi.push({cmd:"start cap",desc:"Start packet capture",params:"[seconds]",required:!0},{cmd:"end cap",desc:"Stop capture"},{cmd:"list cap",desc:"List captures"},{cmd:"export cap",desc:"Download capture",params:"[id]",required:!0});const Hi=["sig","name","rssi","snr","dist","heard"],nf={get:["name","role","lat","lon","radio","freq","tx","bw","sf","cr","af","txdelay","direct.txdelay","rxdelay","mode","repeat","flood.max","flood.advert.interval","advert.interval","duty","duty.max","multi.acks","int.thresh","agc.reset.interval","public.key","prv.key"],set:["name","lat","lon","freq","tx","bw","sf","cr","af","txdelay","direct.txdelay","rxdelay","mode","repeat","flood.max","flood.advert.interval","advert.interval","duty","log","multi.acks","int.thresh","agc.reset.interval","prv.key"],convert:["hex","base64"],neighbors:Hi,nb:Hi,"get neighbors":Hi,"get neighbor":Hi,"set mode":["forward","monitor"],"set duty":["on","off"],"set repeat":["on","off"],"set tx":["10","14","17","20","22"],"set sf":["7","8","9","10","11","12"],"set bw":["125","250","500"],"set cr":["5","6","7","8"],"set af":["0.5","1.0","1.5","2.0"],"set txdelay":["0.5","0.7","1.0","1.5"],"set direct.txdelay":["0.3","0.5","0.7"],"set log":["debug","info","warning","error"],"start cap":["30","60","120","300"]},Ns=["@@@@@@@ @@@ @@@ @@@@@@@@@@ @@@@@@@ ","@@@@@@@@ @@@ @@@ @@@@@@@@@@@ @@@@@@@@ ","@@! @@@ @@! !@@ @@! @@! @@! !@@ ","!@! @!@ !@! @!! !@! !@! !@! !@! ","@!@@!@! !@!@! @!! !!@ @!@ !@! ","!!@!!! @!!! !@! ! !@! !!! ","!!: !!: !!: !!: :!! ",":!: :!: :!: :!: :!: "," :: :: ::: :: ::: ::: "," : : : : :: :: : "];function ci(){return/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)||window.innerWidth<640}function of(e,t){const i=e.toLowerCase(),s=i.trim();if(!s)return[];const r=i.length>s.length&&i.endsWith(" ");if(!s.includes(" ")&&!r)return Zi.filter(h=>h.cmd.toLowerCase().startsWith(s));const n=r?s:s.substring(0,s.lastIndexOf(" ")),o=r?"":s.substring(s.lastIndexOf(" ")+1);if(n==="ping"&&t.length>0)return t.filter(h=>h.toLowerCase().startsWith(o)).slice(0,10).map(h=>({cmd:`ping ${h}`,desc:`→ ${h}`}));const a=nf[n];if(a){const h=a.filter(l=>l.toLowerCase().startsWith(o)).map(l=>({cmd:`${n} ${l}`,desc:`→ ${l}`}));if(!r&&o){const l=new Set(h.map(c=>c.cmd));for(const c of Zi){const d=c.cmd.toLowerCase();d.startsWith(s)&&!l.has(d)&&(h.push(c),l.add(d))}}return h}return Zi.filter(h=>h.cmd.toLowerCase().startsWith(s))}function xf(){const e=al(),{addCommand:t}=mo(),i=U.useRef(null),s=U.useRef(null),r=U.useRef(null),n=U.useRef(null),o=U.useRef(""),a=U.useRef(-1),h=U.useRef(""),l=U.useRef(!1),c=U.useRef(null),d=U.useRef(!1),u=U.useRef(!1),f=U.useRef(!1),_=U.useRef([]),p=U.useRef(()=>{}),g=ll(),[E,z]=U.useState("C0dE"),[O,M]=U.useState(!1),$=U.useRef(null),K=7,ae=280,ne="C0dE",J=U.useCallback(C=>{$.current&&(clearInterval($.current),$.current=null);const P=ne.padEnd(K),H=P+" "+C+" "+P;let q=0;const I=H.length-K;M(!0),z(H.slice(0,K)),$.current=setInterval(()=>{if(q++,q>I){clearInterval($.current),$.current=null,M(!1),z(ne);return}z(H.slice(q,q+K))},ae)},[]);U.useEffect(()=>{const C=I_(J),P=setInterval(()=>{Math.random()<.02&&J(Hr())},45e3);return()=>{C(),clearInterval(P),$.current&&clearInterval($.current)}},[J]);const[Fe,Y]=U.useState(!1),N=U.useRef(null);U.useEffect(()=>{const C=H_(()=>{N.current&&clearTimeout(N.current),Y(!0),N.current=setTimeout(()=>Y(!1),5e3)});return()=>{C(),N.current&&clearTimeout(N.current)}},[]);const[S,L]=U.useState({show:!1,options:[],selectedIndex:0,input:""}),x=U.useRef([]),A=U.useRef(0);U.useEffect(()=>{e!=null&&e.neighbors&&(_.current=Object.values(e.neighbors).map(C=>C.node_name||C.name).filter(C=>!!C).sort())},[e==null?void 0:e.neighbors]);const F=U.useCallback(()=>{var C;(C=s.current)==null||C.write(Qd(hl()))},[]),B=U.useCallback(()=>{const C=s.current;C&&(C.write(Fi),F(),C.write(o.current))},[F]),X=U.useCallback(C=>{const P=of(C,_.current);x.current=P,A.current=0;const H=P.length>0&&C.trim().length>0;L({show:H,options:P,selectedIndex:0,input:C.trim()})},[]),te=U.useCallback(()=>{x.current=[],A.current=0,L({show:!1,options:[],selectedIndex:0,input:""})},[]),He=U.useCallback(C=>{var H;const P=x.current[C];P&&(o.current=P.required?P.cmd+" ":P.cmd,B(),P.required?X(o.current):te(),(H=s.current)==null||H.focus())},[B,X,te]),Qe=U.useCallback(async C=>{const P=s.current;if(!P)return;const H=C.trim();if(!H){F();return}l.current=!0;const q=new AbortController;c.current=q,t(H),a.current=-1;let I=0;const ie={get cols(){return P.cols},get rows(){return P.rows},write(se,xe="default"){const ti=(xe==="default"?se:Wn(se,xe)).split(` +`))},Do);s.addEventListener("abort",()=>{clearInterval(a),o()},{once:!0})})}finally{Lo()}}}function G_(){const e=new Vd,t=new wu(e);return e.register(t,new Cu,new xu,new z_,new U_,new ku,new Eu,new Ru,new j_,new K_,new q_,new Hu,new Yu,new o_,new Xu,new Zu,new a_,new y_,new b_,new w_,new C_,new x_,new k_,new N_,new O_,new W_,new V_),e}const Y_=()=>typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)}),mo=ko(e=>({entries:[],commandHistory:[],isInitialized:!1,addEntry:t=>{const i=Y_(),s={...t,id:i,timestamp:Date.now()};return e(r=>({entries:[...r.entries,s]})),i},updateEntry:(t,i)=>{e(s=>({entries:s.entries.map(r=>r.id===t?{...r,...i}:r)}))},addCommand:t=>{e(i=>({commandHistory:[...i.commandHistory,t]}))},clearEntries:()=>{e({entries:[],commandHistory:[]})},setInitialized:t=>{e({isInitialized:t})}}));function X_({isOpen:e,onClose:t}){const i=$a(),s=wt(n=>n.stats),r=n=>{const o=i.find(a=>a.id===n);o&&Ia(o,s)};return m.jsxs(Ro,{open:e,onClose:t,size:"sm",children:[m.jsx(Bo,{icon:m.jsx(jr,{size:20}),title:"Download Captures",onClose:t}),m.jsx(Mo,{className:"flex flex-col gap-2",children:i.length===0?m.jsxs("div",{className:"flex flex-col items-center gap-2 py-6 text-fg-muted",children:[m.jsx(Bl,{className:"w-8 h-8 opacity-40"}),m.jsx("p",{className:"text-sm",children:"No captures available."})]}):i.map(n=>m.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 radius-inset bg-elevated/50 border border-edge-subtle",children:[m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("p",{className:"type-label text-fg-primary truncate",children:n.filename}),m.jsxs("p",{className:"text-xs text-fg-muted mt-0.5",children:[n.packetCount," packets · ",n.durationSec,"s · ~",Ji(n.sizeBytes)]})]}),m.jsx(sl,{plain:!0,color:"primary",onClick:()=>r(n.id),title:"Download",className:"flex-shrink-0",children:m.jsx(jr,{"data-slot":"icon"})})]},n.id))})]})}function J_(){const e=$a(),[t,i]=U.useState(!1);return m.jsxs(m.Fragment,{children:[m.jsx($o,{icon:m.jsx(El,{size:20}),onClick:()=>i(!0),title:e.length>0?`Download captures (${e.length})`:"Captures",variant:"red",iconActiveColor:pe.red}),m.jsx(X_,{isOpen:t,onClose:()=>i(!1)})]})}const go=[{name:"acl",description:"Access control list statistics — identity and client counts.",body:["```","> acl","ACL Stats",""," Identities 2"," Total clients 5"," Admin 2"," Guest 3"," Repeater 1 ids 3 clients"," Room Server 1 ids 2 clients","```"],searchText:"acl access control list statistics identity client"},{name:"advert",description:"Broadcast a repeater advertisement to the mesh.",body:["```","> advert","✓ Advert sent","```"],searchText:"advert advertisement broadcast mesh"},{name:"board",description:"Hardware and platform info — CPU, memory, disk, temperatures, network I/O.",body:["```","> board"," Node Local-Node"," Runtime pyMC_Repeater v1.0.0"," Core v1.12.0",""," CPU 12.3% 4 cores"," Load 0.42 / 0.38 / 0.35"," Temp 48.2°C",""," Memory 412 MB / 664 MB 62%"," Disk 5.2 GB / 28.7 GB 18%",""," System uptime 14d 3h 22m"," Service uptime 2d 14h 32m"," Net TX/RX 128 MB / 342 MB","```"],searchText:"board hardware platform cpu memory disk temperature network"},{name:"cap",description:"Packet capture — start, stop, list, and export captures.",body:["**Sub-commands:** `start cap [sec]` · `end cap` · `list cap` · `export cap [id]`","","**`start cap [seconds]`** — Begin capture (default 120s, max 3600):","```","> start cap","Capturing... 118s remaining (4 captured)","","✓ Capture complete!"," Captured: 23 packets"," Duration: 120s"," Size: ~14.2 KB","```","","**`end cap`** — Stop capture early:","```","> end cap","✓ Capture stopped!"," Captured: 12 packets","```","","**`list cap`** — List saved captures:","```","> list cap","Capture Reports (2):"," 1. 23 pkts • 120s • ~14.2 KB (id: abc123)"," 2. 12 pkts • 34s • ~7.1 KB (id: def456)","```","","**`export cap [id]`** — Download by ID or index:","```","> export cap 1","✓ Downloading capture-abc123.json...","```"],searchText:"cap capture packet start end list export download diagnostic"},{name:"clear",description:"Clear the terminal screen.",body:["**Alias:** `cls`","```","> clear","```"],searchText:"clear cls screen"},{name:"clock",description:"Current system UTC time. Useful for NTP sync and packet timestamp correlation.",body:["```","> clock"," UTC Wed, 12 Feb 2026 00:01:34 GMT"," ISO 2026-02-12T00:01:34.000Z"," Unix 1770768094","```"],searchText:"clock time utc ntp unix iso timestamp"},{name:"convert",description:"Convert between hex and base64 encodings.",body:["**Usage:** `convert hex ` · `convert base64 `","```","> convert hex 48656C6C6F"," hex 48656C6C6F"," base64 SGVsbG8=","","> convert base64 SGVsbG8="," base64 SGVsbG8="," hex 48656C6C6F","```"],searchText:"convert hex base64 encoding decode"},{name:"get",description:"Read a configuration parameter.",body:[],interactive:"get",searchText:"get read config parameter name role lat lon radio freq tx bw sf cr txdelay mode duty flood advert"},{name:"help",description:"Show all commands, or detailed help for a specific command.",body:["**Alias:** `?` · `h`","```","> help Full command listing","> help ping Detailed help for ping","> ping help Same thing","```"],searchText:"help commands reference guide"},{name:"identities",description:"List all configured repeater and room server identities.",body:["**Alias:** `id` · `ids`","```","> identities","Identities (2)",""," 1. Local-Node repeater 0A1B2C3D"," 2. local-room room_server 0E5F6A7B","```"],searchText:"identities id ids repeater room server identity"},{name:"keys",description:"List configured transport encryption keys.",body:["```","> keys","Transport Keys (1)",""," main-transport flood: allow","```"],searchText:"keys transport encryption"},{name:"neighbors",description:"Direct RF neighbors with signal quality, RSSI, SNR, distance, and last-heard.",body:["**Alias:** `nb`","","**Sort qualifiers:** `sig` · `name` · `rssi` · `snr` · `dist` · `heard`","```","> neighbors","Direct Neighbors (4)","","+-------+-----------+-----------+--------+-------+--------+","| ▁▃▅▇█ | Node-1 | -87 dBm | 8.5 dB | 2.1km | 3m ago |","| ▁▃▅▇. | Relay-2 | -94 dBm | 5.2 dB | 4.8km | 1m ago |","| ▁▃▅.. | Node-3 | -108 dBm | 1.0 dB | 8.3km | 5m ago |","| ▁▃... | Node-4 | -118 dBm | -3 dB | 14km | 12m ago|","+-------+-----------+-----------+--------+-------+--------+","| SIG | NAME | RSSI | SNR | DIST | HEARD |","+-------+-----------+-----------+--------+-------+--------+","SF11/250kHz ant 3.5dBi nf -112dBm","```","","- **sig** — signal grade (weakest first)","- **name** — alphabetical","- **rssi** — RSSI (weakest first)","- **snr** — SNR (lowest first)","- **dist** — distance (closest first)","- **heard** — last seen (oldest first)"],searchText:"neighbors nb signal rssi snr distance sort direct rf"},{name:"packets",description:"Packet counters — received, transmitted, forwarded, dropped.",body:["```","> packets","Packet Stats 1321 total",""," Received 1284"," Transmitted 37"," Forwarded 891"," Dropped 14","```"],searchText:"packets received transmitted forwarded dropped counter"},{name:"ping",description:"Ping a neighbor by name or hex prefix. Shows RTT, signal quality, and path.",body:["**Usage:** `ping [timeout]`","```","> ping Node-1","▁▃▅▇█ Reply from Node-1",""," RTT 342ms"," RSSI -87 dBm"," SNR 8.5 dB"," Path direct"," Quality Excellent","```","","Custom timeout (default 30s):","```","> ping Node-4 60","```"],searchText:"ping rtt round trip time signal quality path neighbor"},{name:"restart",description:"Restart the pymc-repeater systemd service.",body:["**Alias:** `reboot`","```","> restart","Service is restarting (connection dropped).","Waiting for service... 8s","Service connected. (12s)","```","","The terminal polls automatically until the service comes back up."],searchText:"restart reboot service systemd"},{name:"rooms",description:"Room server statistics — message counts, active clients, sync status.",body:["```","> rooms","Rooms (1)",""," Local Room"," msgs 142 clients 3/5 sync running","```"],searchText:"rooms room server messages clients sync"},{name:"set",description:"Write a configuration parameter.",body:[],interactive:"set",searchText:"set write config parameter name lat lon freq tx bw sf cr txdelay mode duty log flood advert"},{name:"stats-core",description:"Engine vitals — uptime, duplicate cache, CPU, memory, temperature.",body:["```","> stats-core"," Core Stats",""," Uptime 2d 14h 32m"," Dup cache 128 entries TTL 900s",""," CPU 12.3% 4 cores"," Load 0.42 / 0.38 / 0.35"," Memory 412 MB / 664 MB 62%"," Temp 48.2°C","```"],searchText:"stats core engine vitals uptime cache cpu memory temperature"},{name:"stats-packets",description:"Firmware-compatible packet counters with rates and duplicate cache depth.",body:["```","> stats-packets"," Packet Counters",""," RX 1284 22.4/hr"," TX 37"," Forwarded 891 15.2/hr"," Dropped 14",""," Dup cache 128","```"],searchText:"stats packets firmware counter rate duplicate cache"},{name:"stats-radio",description:"Radio health — noise floor, airtime, duty cycle, and radio configuration.",body:["```","> stats-radio"," Radio Stats",""," Radio 906.875 MHz SF11 BW 250 kHz CR 4/5 22 dBm",""," Noise floor -112 dBm"," Airtime used 4.2s remaining: 55.8m"," Total airtime 1.2m"," Duty cycle 1.2%"," Utilization 0.8%","```"],searchText:"stats radio noise floor airtime duty cycle utilization"},{name:"status",description:"Quick summary of mode, neighbors, and uptime.",body:["**Alias:** `st`","```","> status","Local-Node repeater",""," Mode forward"," Neighbors 4 direct 12 total"," RX / TX 1284 / 37"," Uptime 2d 14h 32m","```"],searchText:"status st summary mode neighbors uptime"},{name:"top",description:"Live-updating system overview — CPU/memory gauges, mesh counters, processes.",body:["**Alias:** `htop`","","Refreshes every 3s. Press **Ctrl+C** to exit.","```","> top","Local-Node v1.0.0","──────────────────────────────────"," Sys 14d 3h 22m Svc 2d 14h 32m Load 0.42 0.38 0.35",""," CPU [████░░░░░░░░░░░░] 12.3% 4 cores"," Mem [██████████░░░░░░] 62.1% 412M/664M"," Dsk [███░░░░░░░░░░░░░] 18.4% 5.2G/28.7G"," cpu_thermal: 48.2°C",""," MESH"," Mode forward Nbrs 4/12 Noise -112dBm Air 1.2%"," RX 1284 TX 37 FWD 891 Drop 14"," RX/h 22 FWD/h 15",""," PROCS"," CPU MEM NAME"," 8.2 3.1 python3"," 2.1 1.4 cherrypy",""," 14:32:08 · Ctrl+C to exit","```","","Uses alternate screen buffer — scrollback is preserved."],searchText:"top htop live system overview cpu memory gauges mesh processes"},{name:"uptime",description:"How long the repeater service has been running.",body:["```","> uptime","Uptime 2d 14h 32m","```"],searchText:"uptime service running duration"},{name:"ver",description:"Version info for all three components.",body:["**Alias:** `version`","```","> ver"," pyMC_Repeater v1.0.0"," pyMC_Core v1.12.0"," pyMC_Console v1.0.0","```"],searchText:"ver version pymc repeater core console"}],Z_=[{param:"name",category:"Identity",example:["> get name","name Local-Node"]},{param:"role",category:"Identity",example:["> get role","role repeater"]},{param:"lat",category:"Identity",example:["> get lat","lat 34.0522"],range:"-90 to 90"},{param:"lon",category:"Identity",example:["> get lon","lon -118.2437"],range:"-180 to 180"},{param:"public.key",category:"Identity",example:["> get public.key","public.key 0A1B2C3D4E5F..."]},{param:"radio",category:"Radio",example:["> get radio"," freq 906.875 MHz"," bw 250 kHz"," sf 11"," cr 4/5"," tx 22 dBm"]},{param:"freq",category:"Radio",example:["> get freq","freq 906.875 MHz"],range:"100–1000 MHz"},{param:"tx",category:"Radio",example:["> get tx","tx 22 dBm"],range:"2–22 dBm"},{param:"bw",category:"Radio",example:["> get bw","bw 250 kHz"],range:"7.8–500 kHz"},{param:"sf",category:"Radio",example:["> get sf","sf 11"],range:"5–12"},{param:"cr",category:"Radio",example:["> get cr","cr 4/5"],range:"5–8"},{param:"af",category:"Timing",example:["> get af","⚠ airtime_factor not yet exposed by pyMC_Repeater API."," Firmware range: 0-9. Tracked in CLI-Alignment.md."],range:"0–9 (pending)"},{param:"txdelay",category:"Timing",example:["> get txdelay","txdelay 1.0"],range:"0.0–5.0"},{param:"direct.txdelay",category:"Timing",example:["> get direct.txdelay","direct.txdelay 0.5"],range:"0.0–5.0"},{param:"rxdelay",category:"Timing",example:["> get rxdelay","rxdelay 0.0"],range:"≥ 0"},{param:"mode",category:"Repeater",example:["> get mode","mode forward"],range:"forward / monitor"},{param:"duty",category:"Repeater",example:["> get duty","duty on"],range:"on / off"},{param:"flood.max",category:"Repeater",example:["> get flood.max","flood.max 3"],range:"0–64"},{param:"advert.interval",category:"Repeater",example:["> get advert.interval","advert.interval 120m"],range:"0 (off) or 1–10080 min"},{param:"multi.acks",category:"Advanced",example:["> get multi.acks","multi.acks 0"],range:"0–255"},{param:"int.thresh",category:"Advanced",example:["> get int.thresh","int.thresh -120 dBm"],range:"-200 to 0 dBm"},{param:"agc.reset.interval",category:"Advanced",example:["> get agc.reset.interval","agc.reset.interval 0"],range:"≥ 0 (×4)"}],Q_=[{param:"name",category:"Identity",example:["> set name Local-Node","OK - node_name set to Local-Node"],range:"text (no [ ] \\ / : , ? *)"},{param:"lat",category:"Identity",example:["> set lat 34.0522","OK - latitude set to 34.0522"],range:"-90 to 90"},{param:"lon",category:"Identity",example:["> set lon -118.2437","OK - longitude set to -118.2437"],range:"-180 to 180"},{param:"freq",category:"Radio",example:["> set freq 906.875","OK - frequency set to 906875000"],range:"100–1000 MHz"},{param:"tx",category:"Radio",example:["> set tx 22","OK - tx_power set to 22"],range:"2–22 dBm"},{param:"bw",category:"Radio",example:["> set bw 250","OK - bandwidth set to 250000"],range:"7.8, 10.4, 15.6, 20.8, 31.25, 41.7, 62.5, 125, 250, 500 kHz"},{param:"sf",category:"Radio",example:["> set sf 11","OK - spreading_factor set to 11"],range:"5–12"},{param:"cr",category:"Radio",example:["> set cr 5","OK - coding_rate set to 5"],range:"5–8"},{param:"af",category:"Timing",example:["> set af 2","⚠ airtime_factor not yet exposed by pyMC_Repeater API."," Firmware range: 0-9. Needs backend support."],range:"0–9 (pending)"},{param:"txdelay",category:"Timing",example:["> set txdelay 1.0","OK - tx_delay_factor set to 1"],range:"0.0–5.0"},{param:"direct.txdelay",category:"Timing",example:["> set direct.txdelay 0.5","OK - direct_tx_delay_factor set to 0.5"],range:"0.0–5.0"},{param:"rxdelay",category:"Timing",example:["> set rxdelay 0","OK - rx_delay_base set to 0"],range:"≥ 0"},{param:"mode",category:"Repeater",example:["> set mode forward","OK - Mode set to forward"],range:"forward / monitor"},{param:"flood.max",category:"Repeater",example:["> set flood.max 3","OK - max_flood_hops set to 3"],range:"0–64"},{param:"advert.interval",category:"Repeater",example:["> set advert.interval 120","OK - Local advert interval set to 120m"],range:"0 (off) or 1–10080 min"},{param:"duty",category:"Repeater",example:["> set duty on","OK - Duty cycle enabled"],range:"on / off"},{param:"log",category:"Repeater",example:["> set log info","OK - Log level set to INFO"],range:"debug, info, warning, error"},{param:"multi.acks",category:"Advanced",example:["> set multi.acks 0","OK - multi_acks set to 0"],range:"0–255"},{param:"int.thresh",category:"Advanced",example:["> set int.thresh -120","OK - interference_threshold set to -120"],range:"-200 to 0 dBm"},{param:"agc.reset.interval",category:"Advanced",example:["> set agc.reset.interval 8","OK - AGC reset interval set to 8"],range:"≥ 0 (rounded to ×4)"},{param:"prv.key",category:"Advanced",example:["> set prv.key <128-hex>","To set this key, run on the Pi:",""," sudo ./convert_firmware_key.sh ","","Then restart: sudo systemctl restart pymc-repeater"],range:"128-char hex (SSH only)"}];function ef({mode:e}){const t=e==="get"?Z_:Q_,[i,s]=U.useState(0),r=t[i],n=U.useMemo(()=>{const o=new Map;for(const a of t){const h=o.get(a.category)||[];h.push(a),o.set(a.category,h)}return Array.from(o.entries())},[t]);return m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsx("div",{className:"flex flex-col gap-1.5",children:n.map(([o,a])=>m.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[m.jsx("span",{className:"text-xs text-fg-muted w-16 shrink-0 text-right pr-1",children:o}),a.map(h=>{const l=t.indexOf(h),c=l===i;return m.jsx("button",{onClick:()=>s(l),className:es("px-1.5 py-0.5 type-data-xs radius-badge transition-colors cursor-pointer",c?"bg-sys-blue text-fg-invert font-semibold":"bg-elevated text-fg-secondary hover:bg-elevated/80 hover:text-sys-blue"),children:h.param},h.param)})]},o))}),m.jsx("pre",{className:"px-3 py-2.5 radius-inner bg-body text-fg-secondary type-code overflow-x-auto border border-edge-subtle",children:r.example.map((o,a)=>m.jsx("div",{children:o||" "},a))}),r.range&&m.jsxs("p",{className:"text-xs text-fg-muted",children:[m.jsx("span",{className:"text-fg-secondary font-medium",children:r.param})," — ",r.range]})]})}function vo(e,t){const i=e.split(/(\*\*[^*]+\*\*)/g);return m.jsx("span",{children:i.map((s,r)=>s.startsWith("**")&&s.endsWith("**")?m.jsx("strong",{className:"text-fg-primary font-semibold",children:s.slice(2,-2)},r):s.split(/(`[^`]+`)/g).map((o,a)=>o.startsWith("`")&&o.endsWith("`")?m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue type-data-xs",children:o.slice(1,-1)},`${r}-${a}`):m.jsx("span",{children:o},`${r}-${a}`)))},t)}function tf({lines:e}){const t=[];let i=0;for(;im.jsx("div",{children:n||" "},o))},t.length));continue}if(!s.trim()){t.push(m.jsx("div",{className:"h-1.5"},t.length)),i++;continue}if(s.startsWith("- ")){t.push(m.jsxs("div",{className:"flex gap-2 text-sm text-fg-secondary pl-2 py-0.5",children:[m.jsx("span",{className:"text-fg-muted shrink-0",children:"•"}),m.jsx("span",{children:vo(s.slice(2),0)})]},t.length)),i++;continue}t.push(m.jsx("p",{className:"text-sm text-fg-secondary py-0.5",children:vo(s,0)},t.length)),i++}return m.jsx(m.Fragment,{children:t})}function sf({isOpen:e,onClose:t,onUseCommand:i}){const[s,r]=U.useState(""),n=U.useMemo(()=>{if(!s.trim())return go;const a=s.toLowerCase();return go.filter(h=>h.name.includes(a)||h.searchText.includes(a)||h.description.toLowerCase().includes(a))},[s]),o=s.trim().length>0;return m.jsxs(Ro,{open:e,onClose:t,size:"3xl",motionPlus:!0,className:"sm:min-w-[540px] md:min-w-[680px]",children:[m.jsx(Bo,{icon:m.jsx(Ao,{size:20}),title:"Terminal Command Guide",onClose:t}),m.jsxs(Mo,{className:"flex flex-col gap-0 !px-0 !py-0",children:[m.jsx("div",{className:"sticky top-0 z-10 px-5 py-3 border-b border-edge-subtle bg-surface/95 backdrop-blur-sm",children:m.jsxs("div",{className:"relative",children:[m.jsx(Kr,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-fg-muted"}),m.jsx("input",{type:"text",value:s,onChange:a=>r(a.target.value),placeholder:"Search commands...",className:"w-full pl-8 pr-3 py-1.5 text-sm bg-elevated border border-edge-subtle radius-inner text-fg-primary placeholder:text-fg-muted focus:outline-none focus:ring-1 focus:ring-sys-blue/50",autoFocus:!0})]})}),m.jsxs("div",{className:"overflow-y-auto px-5 py-3 h-[420px] sm:h-[520px] md:h-[600px]",children:[m.jsx(_s,{mode:"popLayout",children:n.length===0?m.jsxs(Ti.div,{initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:Ur.normal,ease:zr.easeOut},className:"flex flex-col items-center gap-2 py-10 text-fg-muted",children:[m.jsx(Kr,{className:"w-6 h-6 opacity-40"}),m.jsxs("p",{className:"text-sm",children:['No commands match "',s,'"']})]},"empty"):m.jsx(Ti.div,{initial:!1,className:"flex flex-col gap-1",children:m.jsx(_s,{initial:!1,children:n.map(a=>m.jsx(Ti.div,{layout:"position",initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:rl.fade,className:"min-w-0",children:m.jsx(nl,{children:({open:h})=>m.jsxs("div",{className:es("radius-inner border transition-colors",h?"border-edge-subtle bg-elevated/50":"border-transparent hover:bg-elevated/30"),children:[m.jsxs("div",{className:"flex items-center w-full min-w-0",children:[m.jsxs(ol,{className:"flex items-center gap-3 flex-1 min-w-0 px-3 py-2 text-left cursor-pointer",children:[m.jsx(bl,{size:14,className:es("shrink-0 text-fg-muted transition-transform duration-150",h&&"rotate-90")}),m.jsx("code",{className:"text-sm font-semibold text-sys-blue font-mono shrink-0",children:a.name}),m.jsx("span",{className:"text-xs text-fg-muted truncate min-w-0",children:a.description})]}),i&&m.jsx("button",{onClick:l=>{l.stopPropagation(),i(a.name)},className:"shrink-0 mr-2 px-2 py-0.5 text-xs font-semibold uppercase tracking-wider radius-badge bg-elevated text-fg-muted hover:text-sys-blue hover:bg-elevated/80 transition-colors cursor-pointer",title:`Use "${a.name}" in terminal`,children:"use"})]}),m.jsx(al,{className:"px-3 pb-3 pt-0 pl-9",children:a.interactive?m.jsx(ef,{mode:a.interactive}):m.jsx(tf,{lines:a.body})})]})})},a.name))})},"list")}),m.jsx(_s,{children:!o&&m.jsxs(Ti.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:6},transition:{duration:Ur.normal,ease:zr.easeOut},className:"mt-4 px-3 py-3 radius-inner border border-edge-subtle bg-elevated/30",children:[m.jsx("p",{className:"text-xs font-semibold text-fg-muted mb-2",children:"Tips"}),m.jsxs("div",{className:"flex flex-col gap-1 text-xs text-fg-muted",children:[m.jsxs("p",{children:["Type ",m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue font-mono",children:" help"})," in the terminal for detailed usage."]}),m.jsxs("p",{children:["Most commands have shorter aliases (e.g. ",m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue font-mono",children:"st"}),", ",m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue font-mono",children:"nb"}),", ",m.jsx("code",{className:"px-1 py-0.5 radius-badge bg-elevated text-sys-blue font-mono",children:"id"}),")."]}),m.jsxs("p",{children:["Signal bars ",m.jsx("span",{className:"font-mono",children:"▁▃▅▇█"})," are colored by link quality grade based on RSSI, SNR, and radio config."]}),m.jsx("p",{children:"Captures are stored in browser session only — export before closing the tab."})]})]})})]})]})]})}function rf({onUseCommand:e}){const[t,i]=U.useState(!1),s=e?r=>{i(!1),e(r)}:void 0;return m.jsxs(m.Fragment,{children:[m.jsx($o,{icon:m.jsx(Ao,{size:17,className:"translate-y-px"}),onClick:()=>i(!0),title:"CLI Command Guide"}),m.jsx(sf,{isOpen:t,onClose:()=>i(!1),onUseCommand:s})]})}const Wa=G_(),Zi=Wa.all().flatMap(e=>[{cmd:e.name,desc:e.description,params:e.params,required:!!e.params},...e.aliases.filter(t=>t.includes(" ")).map(t=>({cmd:t,desc:e.description,params:e.params,required:!!e.params}))]);Zi.push({cmd:"start cap",desc:"Start packet capture",params:"[seconds]",required:!0},{cmd:"end cap",desc:"Stop capture"},{cmd:"list cap",desc:"List captures"},{cmd:"export cap",desc:"Download capture",params:"[id]",required:!0});const Hi=["sig","name","rssi","snr","dist","heard"],nf={get:["name","role","lat","lon","radio","freq","tx","bw","sf","cr","af","txdelay","direct.txdelay","rxdelay","mode","repeat","flood.max","flood.advert.interval","advert.interval","duty","duty.max","multi.acks","int.thresh","agc.reset.interval","public.key","prv.key"],set:["name","lat","lon","freq","tx","bw","sf","cr","af","txdelay","direct.txdelay","rxdelay","mode","repeat","flood.max","flood.advert.interval","advert.interval","duty","log","multi.acks","int.thresh","agc.reset.interval","prv.key"],convert:["hex","base64"],neighbors:Hi,nb:Hi,"get neighbors":Hi,"get neighbor":Hi,"set mode":["forward","monitor"],"set duty":["on","off"],"set repeat":["on","off"],"set tx":["10","14","17","20","22"],"set sf":["7","8","9","10","11","12"],"set bw":["125","250","500"],"set cr":["5","6","7","8"],"set af":["0.5","1.0","1.5","2.0"],"set txdelay":["0.5","0.7","1.0","1.5"],"set direct.txdelay":["0.3","0.5","0.7"],"set log":["debug","info","warning","error"],"start cap":["30","60","120","300"]},Ns=["@@@@@@@ @@@ @@@ @@@@@@@@@@ @@@@@@@ ","@@@@@@@@ @@@ @@@ @@@@@@@@@@@ @@@@@@@@ ","@@! @@@ @@! !@@ @@! @@! @@! !@@ ","!@! @!@ !@! @!! !@! !@! !@! !@! ","@!@@!@! !@!@! @!! !!@ @!@ !@! ","!!@!!! @!!! !@! ! !@! !!! ","!!: !!: !!: !!: :!! ",":!: :!: :!: :!: :!: "," :: :: ::: :: ::: ::: "," : : : : :: :: : "];function ci(){return/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)||window.innerWidth<640}function of(e,t){const i=e.toLowerCase(),s=i.trim();if(!s)return[];const r=i.length>s.length&&i.endsWith(" ");if(!s.includes(" ")&&!r)return Zi.filter(h=>h.cmd.toLowerCase().startsWith(s));const n=r?s:s.substring(0,s.lastIndexOf(" ")),o=r?"":s.substring(s.lastIndexOf(" ")+1);if(n==="ping"&&t.length>0)return t.filter(h=>h.toLowerCase().startsWith(o)).slice(0,10).map(h=>({cmd:`ping ${h}`,desc:`→ ${h}`}));const a=nf[n];if(a){const h=a.filter(l=>l.toLowerCase().startsWith(o)).map(l=>({cmd:`${n} ${l}`,desc:`→ ${l}`}));if(!r&&o){const l=new Set(h.map(c=>c.cmd));for(const c of Zi){const d=c.cmd.toLowerCase();d.startsWith(s)&&!l.has(d)&&(h.push(c),l.add(d))}}return h}return Zi.filter(h=>h.cmd.toLowerCase().startsWith(s))}function Cf(){const e=ll(),{addCommand:t}=mo(),i=U.useRef(null),s=U.useRef(null),r=U.useRef(null),n=U.useRef(null),o=U.useRef(""),a=U.useRef(-1),h=U.useRef(""),l=U.useRef(!1),c=U.useRef(null),d=U.useRef(!1),u=U.useRef(!1),f=U.useRef(!1),_=U.useRef([]),p=U.useRef(()=>{}),g=hl(),[E,z]=U.useState("C0dE"),[O,M]=U.useState(!1),$=U.useRef(null),K=7,ae=280,ne="C0dE",J=U.useCallback(C=>{$.current&&(clearInterval($.current),$.current=null);const P=ne.padEnd(K),H=P+" "+C+" "+P;let q=0;const I=H.length-K;M(!0),z(H.slice(0,K)),$.current=setInterval(()=>{if(q++,q>I){clearInterval($.current),$.current=null,M(!1),z(ne);return}z(H.slice(q,q+K))},ae)},[]);U.useEffect(()=>{const C=I_(J),P=setInterval(()=>{Math.random()<.02&&J(Hr())},45e3);return()=>{C(),clearInterval(P),$.current&&clearInterval($.current)}},[J]);const[Fe,Y]=U.useState(!1),N=U.useRef(null);U.useEffect(()=>{const C=H_(()=>{N.current&&clearTimeout(N.current),Y(!0),N.current=setTimeout(()=>Y(!1),5e3)});return()=>{C(),N.current&&clearTimeout(N.current)}},[]);const[S,L]=U.useState({show:!1,options:[],selectedIndex:0,input:""}),x=U.useRef([]),A=U.useRef(0);U.useEffect(()=>{e!=null&&e.neighbors&&(_.current=Object.values(e.neighbors).map(C=>C.node_name||C.name).filter(C=>!!C).sort())},[e==null?void 0:e.neighbors]);const F=U.useCallback(()=>{var C;(C=s.current)==null||C.write(Qd(cl()))},[]),B=U.useCallback(()=>{const C=s.current;C&&(C.write(Fi),F(),C.write(o.current))},[F]),X=U.useCallback(C=>{const P=of(C,_.current);x.current=P,A.current=0;const H=P.length>0&&C.trim().length>0;L({show:H,options:P,selectedIndex:0,input:C.trim()})},[]),te=U.useCallback(()=>{x.current=[],A.current=0,L({show:!1,options:[],selectedIndex:0,input:""})},[]),He=U.useCallback(C=>{var H;const P=x.current[C];P&&(o.current=P.required?P.cmd+" ":P.cmd,B(),P.required?X(o.current):te(),(H=s.current)==null||H.focus())},[B,X,te]),Qe=U.useCallback(async C=>{const P=s.current;if(!P)return;const H=C.trim();if(!H){F();return}l.current=!0;const q=new AbortController;c.current=q,t(H),a.current=-1;let I=0;const ie={get cols(){return P.cols},get rows(){return P.rows},write(se,xe="default"){const ti=(xe==="default"?se:Wn(se,xe)).split(` `);for(const Bt of ti)P.writeln(Bt);return I=yr(ti,P.cols),String(I)},update(se,xe,ei){if(f.current)P.write(nu);else if(I>0)for(let Ft=0;Ft{const P=s.current;if(!P||!u.current)return;if(l.current){for(let I=0;IrequestAnimationFrame(()=>{var ie;return(ie=document.querySelector(`[data-ac-index="${I}"]`))==null?void 0:ie.scrollIntoView({block:"nearest"})});for(let I=0;I0){const se=x.current[A.current];se&&(o.current=se.cmd,B())}te();const Ce=o.current;o.current="",P.writeln(""),Qe(Ce);continue}if(ie===127||ie===8){o.current.length>0&&(o.current=o.current.slice(0,-1),P.write("\b \b"),X(o.current));continue}if(ie===3){o.current="",te(),P.writeln("^C"),F();continue}if(ie===12){P.clear(),te(),B();continue}if(ie===9){x.current.length>0&&He(A.current);continue}if(ie===27){if(C.charCodeAt(I+1)===91){const Ce=C.charCodeAt(I+2);if(I+=2,Ce===65){if(x.current.length>0){const se=Math.max(A.current-1,0);A.current=se,L(xe=>({...xe,selectedIndex:se})),q(se)}else H.length>0&&(a.current===-1&&(h.current=o.current),a.current0){const se=Math.min(A.current+1,x.current.length-1);A.current=se,L(xe=>({...xe,selectedIndex:se})),q(se)}else a.current>0?(a.current--,o.current=H[H.length-1-a.current]||"",B()):a.current===0&&(a.current=-1,o.current=h.current,B());continue}if(Ce===67||Ce===68)continue;continue}x.current.length>0&&te();continue}ie>=32&&(o.current+=C[I],P.write(C[I]),a.current=-1,X(o.current))}},[te,X,He,F,B,Qe]);U.useEffect(()=>{p.current=le},[le]);const Te=U.useCallback(async()=>{const C=s.current;if(!C||d.current)return;d.current=!0;const P="\x1B[94m",H="\x1B[0m",q=Ns.length,I=To-1;try{const Ce=gi(Ns,0);for(const se of Ce)C.writeln(se);await new Promise(se=>{let xe=0;const ei=setInterval(()=>{if(xe>=I){clearInterval(ei),se();return}xe++,C.write(`\x1B[${q}F`);const ti=gi(Ns,xe);for(const Bt of ti)C.write(`\x1B[2K${Bt} -`)},Do)})}finally{Lo()}C.writeln(""),C.write(b("● Initializing terminal...")),await new Promise(Ce=>setTimeout(Ce,300)),C.write(Fi),C.writeln(`${P}✓ Initializing terminal...${H}`),C.write(b("● Connecting to repeater...")),await new Promise(Ce=>setTimeout(Ce,500)),C.write(Fi),cl.getState().health==="connected"?C.writeln(`${P}✓ Connected to repeater${H}`):C.writeln(Zd("~ Connection status unknown")),C.writeln(b("Ready. Type 'help' for commands.")),C.writeln(""),F(),u.current=!0},[F]);U.useEffect(()=>{const C=i.current;if(!C)return;const P=ci()?12:13,H=new Id({theme:Ra(),fontFamily:'"JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace',fontSize:P,lineHeight:ci()?1.1:.65,cursorBlink:!1,cursorStyle:"underline",scrollback:1e4,convertEol:!0,allowTransparency:!0,rightClickSelectsWord:!1}),q=new Hd;H.loadAddon(q),H.loadAddon(new qd),H.open(C),q.fit(),s.current=H,r.current=q;const I=H.onData(se=>p.current(se)),ie=uu(H),Ce=new ResizeObserver(()=>{requestAnimationFrame(()=>q.fit())});return Ce.observe(C),Te(),ci()||H.focus(),()=>{var se;(se=c.current)==null||se.abort(),f.current&&(H.write(jn+Un),f.current=!1),I.dispose(),ie(),Ce.disconnect(),H.dispose(),s.current=null,r.current=null}},[]);const Ve=U.useCallback(C=>{const P=C.target.value;P.length>0&&(le(P),C.target.value="")},[le]),We=U.useCallback(C=>{C.key==="Enter"?(C.preventDefault(),le("\r")):C.key==="Backspace"?(C.preventDefault(),le("")):C.key==="ArrowUp"?(C.preventDefault(),le("\x1B[A")):C.key==="ArrowDown"&&(C.preventDefault(),le("\x1B[B"))},[le]),dt=U.useCallback(()=>{var C,P;ci()?(C=n.current)==null||C.focus():(P=s.current)==null||P.focus()},[]);U.useEffect(()=>{if(!ci())return;const C=()=>{var I;const q=(I=i.current)==null?void 0:I.querySelector(".xterm-viewport");q&&(q.scrollTop=q.scrollHeight),requestAnimationFrame(()=>{var ie;return(ie=r.current)==null?void 0:ie.fit()})},P=window.visualViewport;if(P){const q=()=>{P.heightP.removeEventListener("resize",q)}const H=n.current;if(H){const q=()=>setTimeout(C,300);return H.addEventListener("focus",q),()=>H.removeEventListener("focus",q)}},[]);const Qt=U.useCallback(C=>{o.current=C+" ",B(),X(o.current),setTimeout(()=>{var P;(P=i.current)==null||P.click()},400)},[B,X]);return m.jsx(gl,{children:m.jsx(vl,{children:m.jsxs("div",{className:"terminal-card flex flex-col gap-1 sm:gap-1.5",children:[m.jsxs("div",{className:"card-terminal-header flex-wrap",children:[m.jsx("span",{className:"seven-seg-panel",children:m.jsx(yl,{text:E,minChars:7,size:24,noCycle:O})}),m.jsx("div",{className:"header-well self-stretch flex-col sm:order-first",children:m.jsxs("div",{className:`indicator-key${g==="connected"?" indicator-key--active":g==="degraded"?" indicator-key--sending":""}`,children:[m.jsx("span",{className:"indicator-key__label",children:"ONLINE"}),m.jsx("span",{className:"indicator-key__led"})]})}),m.jsx("div",{className:"card-terminal-ridge flex-1 min-w-4 sm:hidden"}),m.jsxs("div",{className:"header-well flex items-center gap-1 sm:order-last",children:[m.jsx(rf,{onUseCommand:Qt}),m.jsx(J_,{})]}),m.jsx("div",{className:"card-terminal-ridge flex-1 min-w-8 hidden sm:block"})]}),m.jsx(Sl,{noPadding:!0,className:"flex flex-col flex-1 min-h-0 overflow-hidden card-terminal",onClick:dt,children:m.jsxs("div",{className:"card-terminal-well flex-1 min-h-0 flex flex-col overflow-hidden",children:[m.jsxs("div",{className:"flex-1 min-h-0 terminal-gutter relative",children:[m.jsx("div",{ref:i,className:"h-full w-full"}),Fe&&m.jsxs("div",{className:"absolute inset-0 z-10 flex items-center justify-center",onClick:()=>Y(!1),children:[m.jsx("div",{className:"absolute inset-0 animate-[partytime-bg_5s_ease-out_forwards]",style:{background:"rgba(0,0,0,0.82)"}}),m.jsxs("div",{className:"relative z-10 animate-[partytime-crt_5s_ease-out_forwards] partytime-glow",children:[m.jsx("img",{src:"/assets/partytime.gif",alt:"No way.",className:"max-h-[60vh] max-w-[70vw] object-contain rounded"}),m.jsx("div",{className:"absolute inset-0 pointer-events-none rounded partytime-scanlines"})]})]})]}),S.show&&S.options.length>0&&m.jsxs("div",{className:"flex-shrink-0 overflow-hidden terminal-completions",style:{borderTop:"1px solid var(--terminal-border)",background:"var(--terminal-bg-input)"},children:[m.jsx("div",{className:"overflow-y-auto",style:{maxHeight:"176px"},children:S.options.map((C,P)=>{const H=P===S.selectedIndex,q=S.input.length;return m.jsxs("div",{"data-ac-index":P,onClick:()=>He(P),className:es("terminal-ac-option",H?"text-sys-blue":"text-fg-primary"),style:{background:H?"var(--terminal-autocomplete-hover)":void 0},onMouseEnter:I=>{H||(I.currentTarget.style.background="var(--terminal-autocomplete-hover)")},onMouseLeave:I=>{H||(I.currentTarget.style.background="")},children:[m.jsx("span",{className:"terminal-ac-option__indicator",children:H?"▸":""}),m.jsxs("span",{className:"terminal-ac-option__cmd",children:[m.jsx("span",{className:"font-semibold text-sys-blue",children:C.cmd.substring(0,q)}),C.cmd.substring(q)]}),m.jsx("span",{className:"terminal-ac-option__desc",children:C.desc})]},C.cmd)})}),m.jsxs("div",{className:"terminal-ac-hints",children:[m.jsx("span",{className:"hidden sm:inline",children:"Tab · ↑↓ · Esc"}),m.jsx("span",{className:"sm:hidden",children:"Tap to select"}),m.jsxs("span",{children:[S.options.length," match",S.options.length!==1?"es":""]})]})]}),m.jsxs("div",{className:"terminal-mobile-input-bar sm:hidden",children:[m.jsx("input",{ref:n,type:"text",className:"terminal-mobile-input",onChange:Ve,onKeyDown:We,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,enterKeyHint:"send","aria-label":"Terminal input",placeholder:"Type command..."}),m.jsx("button",{type:"button",className:"terminal-send-btn",onClick:()=>le("\r"),"aria-label":"Run command",children:m.jsx(xl,{})})]}),m.jsxs("div",{className:"terminal-status-bar",children:[m.jsx("span",{className:"hidden sm:inline",children:"↑↓ History · Tab · Esc"}),m.jsx("span",{className:"sm:hidden",children:"Tap input to type"}),(e==null?void 0:e.version)&&m.jsxs("span",{children:["pyMC v",e.version]})]})]})})]})})})}export{xf as default}; +`)},Do)})}finally{Lo()}C.writeln(""),C.write(b("● Initializing terminal...")),await new Promise(Ce=>setTimeout(Ce,300)),C.write(Fi),C.writeln(`${P}✓ Initializing terminal...${H}`),C.write(b("● Connecting to repeater...")),await new Promise(Ce=>setTimeout(Ce,500)),C.write(Fi),dl.getState().health==="connected"?C.writeln(`${P}✓ Connected to repeater${H}`):C.writeln(Zd("~ Connection status unknown")),C.writeln(b("Ready. Type 'help' for commands.")),C.writeln(""),F(),u.current=!0},[F]);U.useEffect(()=>{const C=i.current;if(!C)return;const P=ci()?12:13,H=new Id({theme:Ra(),fontFamily:'"JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace',fontSize:P,lineHeight:ci()?1.1:.65,cursorBlink:!1,cursorStyle:"underline",scrollback:1e4,convertEol:!0,allowTransparency:!0,rightClickSelectsWord:!1}),q=new Hd;H.loadAddon(q),H.loadAddon(new qd),H.open(C),q.fit(),s.current=H,r.current=q;const I=H.onData(se=>p.current(se)),ie=uu(H),Ce=new ResizeObserver(()=>{requestAnimationFrame(()=>q.fit())});return Ce.observe(C),Te(),ci()||H.focus(),()=>{var se;(se=c.current)==null||se.abort(),f.current&&(H.write(jn+Un),f.current=!1),I.dispose(),ie(),Ce.disconnect(),H.dispose(),s.current=null,r.current=null}},[]);const Ve=U.useCallback(C=>{const P=C.target.value;P.length>0&&(le(P),C.target.value="")},[le]),We=U.useCallback(C=>{C.key==="Enter"?(C.preventDefault(),le("\r")):C.key==="Backspace"?(C.preventDefault(),le("")):C.key==="ArrowUp"?(C.preventDefault(),le("\x1B[A")):C.key==="ArrowDown"&&(C.preventDefault(),le("\x1B[B"))},[le]),dt=U.useCallback(()=>{var C,P;ci()?(C=n.current)==null||C.focus():(P=s.current)==null||P.focus()},[]);U.useEffect(()=>{if(!ci())return;const C=()=>{var I;const q=(I=i.current)==null?void 0:I.querySelector(".xterm-viewport");q&&(q.scrollTop=q.scrollHeight),requestAnimationFrame(()=>{var ie;return(ie=r.current)==null?void 0:ie.fit()})},P=window.visualViewport;if(P){const q=()=>{P.heightP.removeEventListener("resize",q)}const H=n.current;if(H){const q=()=>setTimeout(C,300);return H.addEventListener("focus",q),()=>H.removeEventListener("focus",q)}},[]);const Qt=U.useCallback(C=>{o.current=C+" ",B(),X(o.current),setTimeout(()=>{var P;(P=i.current)==null||P.click()},400)},[B,X]);return m.jsx(gl,{children:m.jsx(vl,{children:m.jsxs("div",{className:"terminal-card flex flex-col gap-1 sm:gap-1.5",children:[m.jsxs("div",{className:"card-terminal-header flex-wrap",children:[m.jsx("span",{className:"seven-seg-panel",children:m.jsx(yl,{text:E,minChars:7,size:24,noCycle:O})}),m.jsx("div",{className:"header-well self-stretch flex-col sm:order-first",children:m.jsxs("div",{className:`indicator-key${g==="connected"?" indicator-key--active":g==="degraded"?" indicator-key--sending":""}`,children:[m.jsx("span",{className:"indicator-key__label",children:"ONLINE"}),m.jsx("span",{className:"indicator-key__led"})]})}),m.jsx("div",{className:"card-terminal-ridge flex-1 min-w-4 sm:hidden"}),m.jsxs("div",{className:"header-well flex items-center gap-1 sm:order-last",children:[m.jsx(rf,{onUseCommand:Qt}),m.jsx(J_,{})]}),m.jsx("div",{className:"card-terminal-ridge flex-1 min-w-8 hidden sm:block"})]}),m.jsx(Sl,{noPadding:!0,className:"flex flex-col flex-1 min-h-0 overflow-hidden card-terminal",onClick:dt,children:m.jsxs("div",{className:"card-terminal-well flex-1 min-h-0 flex flex-col overflow-hidden",children:[m.jsxs("div",{className:"flex-1 min-h-0 terminal-gutter relative",children:[m.jsx("div",{ref:i,className:"h-full w-full"}),Fe&&m.jsxs("div",{className:"absolute inset-0 z-10 flex items-center justify-center",onClick:()=>Y(!1),children:[m.jsx("div",{className:"absolute inset-0 animate-[partytime-bg_5s_ease-out_forwards]",style:{background:"rgba(0,0,0,0.82)"}}),m.jsxs("div",{className:"relative z-10 animate-[partytime-crt_5s_ease-out_forwards] partytime-glow",children:[m.jsx("img",{src:"/assets/partytime.gif",alt:"No way.",className:"max-h-[60vh] max-w-[70vw] object-contain rounded"}),m.jsx("div",{className:"absolute inset-0 pointer-events-none rounded partytime-scanlines"})]})]})]}),S.show&&S.options.length>0&&m.jsxs("div",{className:"flex-shrink-0 overflow-hidden terminal-completions",style:{borderTop:"1px solid var(--terminal-border)",background:"var(--terminal-bg-input)"},children:[m.jsx("div",{className:"overflow-y-auto",style:{maxHeight:"176px"},children:S.options.map((C,P)=>{const H=P===S.selectedIndex,q=S.input.length;return m.jsxs("div",{"data-ac-index":P,onClick:()=>He(P),className:es("terminal-ac-option",H?"text-sys-blue":"text-fg-primary"),style:{background:H?"var(--terminal-autocomplete-hover)":void 0},onMouseEnter:I=>{H||(I.currentTarget.style.background="var(--terminal-autocomplete-hover)")},onMouseLeave:I=>{H||(I.currentTarget.style.background="")},children:[m.jsx("span",{className:"terminal-ac-option__indicator",children:H?"▸":""}),m.jsxs("span",{className:"terminal-ac-option__cmd",children:[m.jsx("span",{className:"font-semibold text-sys-blue",children:C.cmd.substring(0,q)}),C.cmd.substring(q)]}),m.jsx("span",{className:"terminal-ac-option__desc",children:C.desc})]},C.cmd)})}),m.jsxs("div",{className:"terminal-ac-hints",children:[m.jsx("span",{className:"hidden sm:inline",children:"Tab · ↑↓ · Esc"}),m.jsx("span",{className:"sm:hidden",children:"Tap to select"}),m.jsxs("span",{children:[S.options.length," match",S.options.length!==1?"es":""]})]})]}),m.jsxs("div",{className:"terminal-mobile-input-bar sm:hidden",children:[m.jsx("input",{ref:n,type:"text",className:"terminal-mobile-input",onChange:Ve,onKeyDown:We,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,enterKeyHint:"send","aria-label":"Terminal input",placeholder:"Type command..."}),m.jsx("button",{type:"button",className:"terminal-send-btn",onClick:()=>le("\r"),"aria-label":"Run command",children:m.jsx(xl,{})})]}),m.jsxs("div",{className:"terminal-status-bar",children:[m.jsx("span",{className:"hidden sm:inline",children:"↑↓ History · Tab · Esc"}),m.jsx("span",{className:"sm:hidden",children:"Tap input to type"}),(e==null?void 0:e.version)&&m.jsxs("span",{children:["pyMC v",e.version]})]})]})})]})})})}export{Cf as default}; diff --git a/frontend/dist/assets/TimeRangeStepper-BlC9rlkV.js b/frontend/dist/assets/TimeRangeStepper-Dh4JEQ42.js similarity index 95% rename from frontend/dist/assets/TimeRangeStepper-BlC9rlkV.js rename to frontend/dist/assets/TimeRangeStepper-Dh4JEQ42.js index fee769d5..eb13191c 100644 --- a/frontend/dist/assets/TimeRangeStepper-BlC9rlkV.js +++ b/frontend/dist/assets/TimeRangeStepper-Dh4JEQ42.js @@ -1,4 +1,4 @@ -import{ap as Ge,aM as be,ao as Le,ck as $e,ar as He,aq as q,r as l,au as Ke,av as ee,az as z,ay as U,aj as k,aC as K,cl as se,cm as Be,aH as We,aI as Ye,aN as Ve,aJ as re,aO as Xe,aK as me,cn as _e,co as W,cp as M,cq as he,cr as A,cs as xe,aL as le,aX as g,ct as ye,cu as Pe,aP as we,an as Qe,aQ as Fe,aR as Oe,aT as Ze,aU as qe,aW as Ee,cv as ze,cw as Te,aY as Ue,cx as Je,cy as et,aZ as Ie,cz as tt,cA as nt,cB as at,ak as ot,b3 as st,aS as J,cC as je,b5 as rt,b7 as ie,cD as lt,cE as ut,cF as ct,d as it,j as I,c as H,A as pt,m as dt,cj as ft}from"./index-C8IY8K2r.js";import{C as vt}from"./chevron-right-DUgYTR6d.js";import{F as bt,y as mt,R as ht,T as yt,w as Pt,A as $t}from"./map-pin-DMVHq6j8.js";var xt=Object.defineProperty,gt=(e,n,t)=>n in e?xt(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,ke=(e,n,t)=>(gt(e,typeof n!="symbol"?n+"":n,t),t),$=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))($||{}),St=(e=>(e[e.OpenPopover=0]="OpenPopover",e[e.ClosePopover=1]="ClosePopover",e[e.SetButton=2]="SetButton",e[e.SetButtonId=3]="SetButtonId",e[e.SetPanel=4]="SetPanel",e[e.SetPanelId=5]="SetPanelId",e))(St||{});let Ct={0:e=>e.popoverState===0?e:{...e,popoverState:0,__demoMode:!1},1(e){return e.popoverState===1?e:{...e,popoverState:1,__demoMode:!1}},2(e,n){return e.button===n.button?e:{...e,button:n.button}},3(e,n){return e.buttonId===n.buttonId?e:{...e,buttonId:n.buttonId}},4(e,n){return e.panel===n.panel?e:{...e,panel:n.panel}},5(e,n){return e.panelId===n.panelId?e:{...e,panelId:n.panelId}}};class ge extends Ge{constructor(n){super(n),ke(this,"actions",{close:()=>this.send({type:1}),refocusableClose:t=>{this.actions.close();let v=t?be(t)?t:"current"in t&&be(t.current)?t.current:this.state.button:this.state.button;v==null||v.focus()},open:()=>this.send({type:0}),setButtonId:t=>this.send({type:3,buttonId:t}),setButton:t=>this.send({type:2,button:t}),setPanelId:t=>this.send({type:5,panelId:t}),setPanel:t=>this.send({type:4,panel:t})}),ke(this,"selectors",{isPortalled:t=>{var v;if(!t.button||!t.panel)return!1;let h=(v=Le(t.button))!=null?v:document;for(let x of h.querySelectorAll("body > *"))if(Number(x==null?void 0:x.contains(t.button))^Number(x==null?void 0:x.contains(t.panel)))return!0;let b=$e(h),r=b.indexOf(t.button),a=(r+b.length-1)%b.length,C=(r+1)%b.length,y=b[a],s=b[C];return!t.panel.contains(y)&&!t.panel.contains(s)}});{let t=this.state.id,v=He.get(null);this.on(0,()=>v.actions.push(t)),this.on(1,()=>v.actions.pop(t))}}static new({id:n,__demoMode:t=!1}){return new ge({id:n,__demoMode:t,popoverState:t?0:1,buttons:{current:[]},button:null,buttonId:null,panel:null,panelId:null,beforePanelSentinel:{current:null},afterPanelSentinel:{current:null},afterButtonSentinel:{current:null}})}reduce(n,t){return q(t.type,Ct,n,t)}}const Ne=l.createContext(null);function pe(e){let n=l.useContext(Ne);if(n===null){let t=new Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,pe),t}return n}function wt({id:e,__demoMode:n=!1}){let t=l.useMemo(()=>ge.new({id:e,__demoMode:n}),[]);return Ke(()=>t.dispose()),t}let Se=l.createContext(null);Se.displayName="PopoverGroupContext";function De(){return l.useContext(Se)}let de=l.createContext(null);de.displayName="PopoverPanelContext";function It(){return l.useContext(de)}let kt="div";function Bt(e,n){var t;let v=l.useId(),{__demoMode:h=!1,...b}=e,r=wt({id:v,__demoMode:h}),a=l.useRef(null),C=U(n,Je(u=>{a.current=u})),[y,s,x,S,B]=z(r,l.useCallback(u=>[u.popoverState,u.button,u.panel,u.buttonId,u.panelId],[])),w=et((t=a.current)!=null?t:s),d=Ie(S),p=Ie(B),f=l.useMemo(()=>({buttonId:d,panelId:p,close:r.actions.close}),[d,p,r]),P=De(),c=P==null?void 0:P.registerPopover,_=k(()=>{var u,F;let E=se((u=a.current)!=null?u:s);return(F=P==null?void 0:P.isFocusWithinPopoverGroup())!=null?F:E&&((s==null?void 0:s.contains(E))||(x==null?void 0:x.contains(E)))});l.useEffect(()=>c==null?void 0:c(f),[c,f]);let[te,ne]=tt(),G=nt(s),D=at({mainTreeNode:G,portals:te,defaultContainers:[{get current(){return r.state.button}},{get current(){return r.state.panel}}]});ot(w,"focus",u=>{var F,E,j,Q,N,Z;u.target!==window&<(u.target)&&r.state.popoverState===$.Open&&(_()||r.state.button&&r.state.panel&&(D.contains(u.target)||(E=(F=r.state.beforePanelSentinel.current)==null?void 0:F.contains)!=null&&E.call(F,u.target)||(Q=(j=r.state.afterPanelSentinel.current)==null?void 0:j.contains)!=null&&Q.call(j,u.target)||(Z=(N=r.state.afterButtonSentinel.current)==null?void 0:N.contains)!=null&&Z.call(N,u.target)||r.actions.close()))},!0);let Y=y===$.Open;st(Y,D.resolveContainers,(u,F)=>{r.actions.close(),ut(F,ct.Loose)||(u.preventDefault(),s==null||s.focus())});let ae=re({open:y===$.Open,close:r.actions.refocusableClose}),oe=z(r,l.useCallback(u=>q(u.popoverState,{[$.Open]:J.Open,[$.Closed]:J.Closed}),[])),V={ref:C},X=le();return g.createElement(je,{node:G},g.createElement($t,null,g.createElement(de.Provider,{value:null},g.createElement(Ne.Provider,{value:r},g.createElement(Te,{value:r.actions.refocusableClose},g.createElement(rt,{value:oe},g.createElement(ne,null,X({ourProps:V,theirProps:b,slot:ae,defaultTag:kt,name:"Popover"}))))))))}let _t="button";function Ft(e,n){let t=l.useId(),{id:v=`headlessui-popover-button-${t}`,disabled:h=!1,autoFocus:b=!1,...r}=e,a=pe("Popover.Button"),[C,y,s,x,S,B,w]=z(a,l.useCallback(o=>[o.popoverState,a.selectors.isPortalled(o),o.button,o.buttonId,o.panel,o.panelId,o.afterButtonSentinel],[])),d=l.useRef(null),p=`headlessui-focus-sentinel-${l.useId()}`,f=De(),P=f==null?void 0:f.closeOthers,c=It()!==null;l.useEffect(()=>{if(!c)return a.actions.setButtonId(v),()=>a.actions.setButtonId(null)},[c,v,a]);let[_]=l.useState(()=>Symbol()),te=U(d,n,bt(),k(o=>{if(!c){if(o)a.state.buttons.current.push(_);else{let i=a.state.buttons.current.indexOf(_);i!==-1&&a.state.buttons.current.splice(i,1)}a.state.buttons.current.length>1&&console.warn("You are already using a but only 1 is supported."),o&&a.actions.setButton(o)}})),ne=U(d,n),G=k(o=>{var i,O,T;if(c){if(a.state.popoverState===$.Closed)return;switch(o.key){case K.Space:case K.Enter:o.preventDefault(),(O=(i=o.target).click)==null||O.call(i),a.actions.close(),(T=a.state.button)==null||T.focus();break}}else switch(o.key){case K.Space:case K.Enter:o.preventDefault(),o.stopPropagation(),a.state.popoverState===$.Closed?(P==null||P(a.state.buttonId),a.actions.open()):a.actions.close();break;case K.Escape:if(a.state.popoverState!==$.Open)return P==null?void 0:P(a.state.buttonId);if(!d.current)return;let R=se(d.current);if(R&&!d.current.contains(R))return;o.preventDefault(),o.stopPropagation(),a.actions.close();break}}),D=k(o=>{c||o.key===K.Space&&o.preventDefault()}),Y=k(o=>{var i,O;Be(o.currentTarget)||h||(c?(a.actions.close(),(i=a.state.button)==null||i.focus()):(o.preventDefault(),o.stopPropagation(),a.state.popoverState===$.Closed?(P==null||P(a.state.buttonId),a.actions.open()):a.actions.close(),(O=a.state.button)==null||O.focus()))}),ae=k(o=>{o.preventDefault(),o.stopPropagation()}),{isFocusVisible:oe,focusProps:V}=We({autoFocus:b}),{isHovered:X,hoverProps:u}=Ye({isDisabled:h}),{pressed:F,pressProps:E}=Ve({disabled:h}),j=C===$.Open,Q=re({open:j,active:F||j,disabled:h,hover:X,focus:oe,autofocus:b}),N=Xe(e,s),Z=c?me({ref:ne,type:N,onKeyDown:G,onClick:Y,disabled:h||void 0,autoFocus:b},V,u,E):me({ref:te,id:x,type:N,"aria-expanded":C===$.Open,"aria-controls":S?B:void 0,disabled:h||void 0,autoFocus:b,onKeyDown:G,onKeyUp:D,onClick:Y,onMouseDown:ae},V,u,E),ue=_e(),fe=k(()=>{if(!be(a.state.panel))return;let o=a.state.panel;function i(){q(ue.current,{[M.Forwards]:()=>W(o,A.First),[M.Backwards]:()=>W(o,A.Last)})===he.Error&&W($e(xe(a.state.button)).filter(O=>O.dataset.headlessuiFocusGuard!=="true"),q(ue.current,{[M.Forwards]:A.Next,[M.Backwards]:A.Previous}),{relativeTo:a.state.button})}i()}),m=le();return g.createElement(g.Fragment,null,m({ourProps:Z,theirProps:r,slot:Q,defaultTag:_t,name:"Popover.Button"}),j&&!c&&y&&g.createElement(ye,{id:p,ref:w,features:Pe.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:fe}))}let Ot="div",Et=ie.RenderStrategy|ie.Static;function Re(e,n){let t=l.useId(),{id:v=`headlessui-popover-backdrop-${t}`,transition:h=!1,...b}=e,r=pe("Popover.Backdrop"),a=z(r,l.useCallback(f=>f.popoverState,[])),[C,y]=l.useState(null),s=U(n,y),x=Fe(),[S,B]=Oe(h,C,x!==null?(x&J.Open)===J.Open:a===$.Open),w=k(f=>{if(Be(f.currentTarget))return f.preventDefault();r.actions.close()}),d=re({open:a===$.Open}),p={ref:s,id:v,"aria-hidden":!0,onClick:w,...Ee(B)};return le()({ourProps:p,theirProps:b,slot:d,defaultTag:Ot,features:Et,visible:S,name:"Popover.Backdrop"})}let Tt="div",jt=ie.RenderStrategy|ie.Static;function Nt(e,n){let t=l.useId(),{id:v=`headlessui-popover-panel-${t}`,focus:h=!1,anchor:b,portal:r=!1,modal:a=!1,transition:C=!1,...y}=e,s=pe("Popover.Panel"),x=z(s,s.selectors.isPortalled),[S,B,w,d,p]=z(s,l.useCallback(m=>[m.popoverState,m.button,m.__demoMode,m.beforePanelSentinel,m.afterPanelSentinel],[])),f=`headlessui-focus-sentinel-before-${t}`,P=`headlessui-focus-sentinel-after-${t}`,c=l.useRef(null),_=mt(b),[te,ne]=ht(_),G=yt();_&&(r=!0);let[D,Y]=l.useState(null),ae=U(c,n,_?te:null,s.actions.setPanel,Y),oe=we(B),V=we(c.current);Qe(()=>(s.actions.setPanelId(v),()=>s.actions.setPanelId(null)),[v,s]);let X=Fe(),[u,F]=Oe(C,D,X!==null?(X&J.Open)===J.Open:S===$.Open);Ze(u,B,s.actions.close),qe(w?!1:a&&u,V);let E=k(m=>{var o;switch(m.key){case K.Escape:if(s.state.popoverState!==$.Open||!c.current)return;let i=se(c.current);if(i&&!c.current.contains(i))return;m.preventDefault(),m.stopPropagation(),s.actions.close(),(o=s.state.button)==null||o.focus();break}});l.useEffect(()=>{var m;e.static||S===$.Closed&&((m=e.unmount)==null||m)&&s.actions.setPanel(null)},[S,e.unmount,e.static,s]),l.useEffect(()=>{if(w||!h||S!==$.Open||!c.current)return;let m=se(c.current);c.current.contains(m)||W(c.current,A.First)},[w,h,c.current,S]);let j=re({open:S===$.Open,close:s.actions.refocusableClose}),Q=me(_?G():{},{ref:ae,id:v,onKeyDown:E,onBlur:h&&S===$.Open?m=>{var o,i,O,T,R;let L=m.relatedTarget;L&&c.current&&((o=c.current)!=null&&o.contains(L)||(s.actions.close(),((O=(i=d.current)==null?void 0:i.contains)!=null&&O.call(i,L)||(R=(T=p.current)==null?void 0:T.contains)!=null&&R.call(T,L))&&L.focus({preventScroll:!0})))}:void 0,tabIndex:-1,style:{...y.style,...ne,"--button-width":Pt(u,B,!0).width},...Ee(F)}),N=_e(),Z=k(()=>{let m=c.current;if(!m)return;function o(){q(N.current,{[M.Forwards]:()=>{var i;W(m,A.First)===he.Error&&((i=s.state.afterPanelSentinel.current)==null||i.focus())},[M.Backwards]:()=>{var i;(i=s.state.button)==null||i.focus({preventScroll:!0})}})}o()}),ue=k(()=>{let m=c.current;if(!m)return;function o(){q(N.current,{[M.Forwards]:()=>{var i;if(!s.state.button)return;let O=(i=xe(s.state.button))!=null?i:document.body,T=$e(O),R=T.indexOf(s.state.button),L=T.slice(0,R+1),ce=[...T.slice(R+1),...L];for(let ve of ce.slice())if(ve.dataset.headlessuiFocusGuard==="true"||D!=null&&D.contains(ve)){let Ce=ce.indexOf(ve);Ce!==-1&&ce.splice(Ce,1)}W(ce,A.First,{sorted:!1})},[M.Backwards]:()=>{var i;W(m,A.Previous)===he.Error&&((i=s.state.button)==null||i.focus())}})}o()}),fe=le();return g.createElement(ze,null,g.createElement(de.Provider,{value:v},g.createElement(Te,{value:s.actions.refocusableClose},g.createElement(Ue,{enabled:r?e.static||u:!1,ownerDocument:oe},u&&x&&g.createElement(ye,{id:f,ref:d,features:Pe.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:Z}),fe({ourProps:Q,theirProps:y,slot:j,defaultTag:Tt,features:jt,visible:u,name:"Popover.Panel"}),u&&x&&g.createElement(ye,{id:P,ref:p,features:Pe.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:ue})))))}let Dt="div";function Rt(e,n){let t=l.useRef(null),v=U(t,n),[h,b]=l.useState([]),r=k(d=>{b(p=>{let f=p.indexOf(d);if(f!==-1){let P=p.slice();return P.splice(f,1),P}return p})}),a=k(d=>(b(p=>[...p,d]),()=>r(d))),C=k(()=>{var d;let p=xe(t.current);if(!p)return!1;let f=se(t.current);return(d=t.current)!=null&&d.contains(f)?!0:h.some(P=>{var c,_;return((c=p.getElementById(P.buttonId.current))==null?void 0:c.contains(f))||((_=p.getElementById(P.panelId.current))==null?void 0:_.contains(f))})}),y=k(d=>{for(let p of h)p.buttonId.current!==d&&p.close()}),s=l.useMemo(()=>({registerPopover:a,unregisterPopover:r,isFocusWithinPopoverGroup:C,closeOthers:y}),[a,r,C,y]),x=re({}),S=e,B={ref:v},w=le();return g.createElement(je,null,g.createElement(Se.Provider,{value:s},w({ourProps:B,theirProps:S,slot:x,defaultTag:Dt,name:"Popover.Group"})))}let Mt=ee(Bt),Me=ee(Ft),At=ee(Re),Gt=ee(Re),Ae=ee(Nt),Lt=ee(Rt),Ht=Object.assign(Mt,{Button:Me,Backdrop:Gt,Overlay:At,Panel:Ae,Group:Lt});/** +import{ap as Ge,aM as be,ao as Le,cn as $e,ar as He,aq as q,r as l,au as Ke,av as ee,az as z,ay as U,aj as k,aC as K,co as se,cp as Be,aH as We,aI as Ye,aN as Ve,aJ as re,aO as Xe,aK as me,cq as _e,cr as W,cs as M,ct as he,cu as A,cv as xe,aL as le,aX as g,cw as ye,cx as Pe,aP as we,an as Qe,aQ as Fe,aR as Oe,aT as Ze,aU as qe,aW as Ee,cy as ze,cz as Te,aY as Ue,cA as Je,cB as et,aZ as Ie,cC as tt,cD as nt,cE as at,ak as ot,b3 as st,aS as J,cF as je,b5 as rt,b7 as ie,cG as lt,cH as ut,cI as ct,d as it,j as I,c as H,A as pt,m as dt,cm as ft}from"./index-BwGHI0A_.js";import{C as vt}from"./chevron-right-DqpRZiGf.js";import{F as bt,y as mt,R as ht,T as yt,w as Pt,A as $t}from"./map-pin-VRY_TOuh.js";var xt=Object.defineProperty,gt=(e,n,t)=>n in e?xt(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,ke=(e,n,t)=>(gt(e,typeof n!="symbol"?n+"":n,t),t),$=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))($||{}),St=(e=>(e[e.OpenPopover=0]="OpenPopover",e[e.ClosePopover=1]="ClosePopover",e[e.SetButton=2]="SetButton",e[e.SetButtonId=3]="SetButtonId",e[e.SetPanel=4]="SetPanel",e[e.SetPanelId=5]="SetPanelId",e))(St||{});let Ct={0:e=>e.popoverState===0?e:{...e,popoverState:0,__demoMode:!1},1(e){return e.popoverState===1?e:{...e,popoverState:1,__demoMode:!1}},2(e,n){return e.button===n.button?e:{...e,button:n.button}},3(e,n){return e.buttonId===n.buttonId?e:{...e,buttonId:n.buttonId}},4(e,n){return e.panel===n.panel?e:{...e,panel:n.panel}},5(e,n){return e.panelId===n.panelId?e:{...e,panelId:n.panelId}}};class ge extends Ge{constructor(n){super(n),ke(this,"actions",{close:()=>this.send({type:1}),refocusableClose:t=>{this.actions.close();let v=t?be(t)?t:"current"in t&&be(t.current)?t.current:this.state.button:this.state.button;v==null||v.focus()},open:()=>this.send({type:0}),setButtonId:t=>this.send({type:3,buttonId:t}),setButton:t=>this.send({type:2,button:t}),setPanelId:t=>this.send({type:5,panelId:t}),setPanel:t=>this.send({type:4,panel:t})}),ke(this,"selectors",{isPortalled:t=>{var v;if(!t.button||!t.panel)return!1;let h=(v=Le(t.button))!=null?v:document;for(let x of h.querySelectorAll("body > *"))if(Number(x==null?void 0:x.contains(t.button))^Number(x==null?void 0:x.contains(t.panel)))return!0;let b=$e(h),r=b.indexOf(t.button),a=(r+b.length-1)%b.length,C=(r+1)%b.length,y=b[a],s=b[C];return!t.panel.contains(y)&&!t.panel.contains(s)}});{let t=this.state.id,v=He.get(null);this.on(0,()=>v.actions.push(t)),this.on(1,()=>v.actions.pop(t))}}static new({id:n,__demoMode:t=!1}){return new ge({id:n,__demoMode:t,popoverState:t?0:1,buttons:{current:[]},button:null,buttonId:null,panel:null,panelId:null,beforePanelSentinel:{current:null},afterPanelSentinel:{current:null},afterButtonSentinel:{current:null}})}reduce(n,t){return q(t.type,Ct,n,t)}}const Ne=l.createContext(null);function pe(e){let n=l.useContext(Ne);if(n===null){let t=new Error(`<${e} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,pe),t}return n}function wt({id:e,__demoMode:n=!1}){let t=l.useMemo(()=>ge.new({id:e,__demoMode:n}),[]);return Ke(()=>t.dispose()),t}let Se=l.createContext(null);Se.displayName="PopoverGroupContext";function De(){return l.useContext(Se)}let de=l.createContext(null);de.displayName="PopoverPanelContext";function It(){return l.useContext(de)}let kt="div";function Bt(e,n){var t;let v=l.useId(),{__demoMode:h=!1,...b}=e,r=wt({id:v,__demoMode:h}),a=l.useRef(null),C=U(n,Je(u=>{a.current=u})),[y,s,x,S,B]=z(r,l.useCallback(u=>[u.popoverState,u.button,u.panel,u.buttonId,u.panelId],[])),w=et((t=a.current)!=null?t:s),d=Ie(S),p=Ie(B),f=l.useMemo(()=>({buttonId:d,panelId:p,close:r.actions.close}),[d,p,r]),P=De(),c=P==null?void 0:P.registerPopover,_=k(()=>{var u,F;let E=se((u=a.current)!=null?u:s);return(F=P==null?void 0:P.isFocusWithinPopoverGroup())!=null?F:E&&((s==null?void 0:s.contains(E))||(x==null?void 0:x.contains(E)))});l.useEffect(()=>c==null?void 0:c(f),[c,f]);let[te,ne]=tt(),G=nt(s),D=at({mainTreeNode:G,portals:te,defaultContainers:[{get current(){return r.state.button}},{get current(){return r.state.panel}}]});ot(w,"focus",u=>{var F,E,j,Q,N,Z;u.target!==window&<(u.target)&&r.state.popoverState===$.Open&&(_()||r.state.button&&r.state.panel&&(D.contains(u.target)||(E=(F=r.state.beforePanelSentinel.current)==null?void 0:F.contains)!=null&&E.call(F,u.target)||(Q=(j=r.state.afterPanelSentinel.current)==null?void 0:j.contains)!=null&&Q.call(j,u.target)||(Z=(N=r.state.afterButtonSentinel.current)==null?void 0:N.contains)!=null&&Z.call(N,u.target)||r.actions.close()))},!0);let Y=y===$.Open;st(Y,D.resolveContainers,(u,F)=>{r.actions.close(),ut(F,ct.Loose)||(u.preventDefault(),s==null||s.focus())});let ae=re({open:y===$.Open,close:r.actions.refocusableClose}),oe=z(r,l.useCallback(u=>q(u.popoverState,{[$.Open]:J.Open,[$.Closed]:J.Closed}),[])),V={ref:C},X=le();return g.createElement(je,{node:G},g.createElement($t,null,g.createElement(de.Provider,{value:null},g.createElement(Ne.Provider,{value:r},g.createElement(Te,{value:r.actions.refocusableClose},g.createElement(rt,{value:oe},g.createElement(ne,null,X({ourProps:V,theirProps:b,slot:ae,defaultTag:kt,name:"Popover"}))))))))}let _t="button";function Ft(e,n){let t=l.useId(),{id:v=`headlessui-popover-button-${t}`,disabled:h=!1,autoFocus:b=!1,...r}=e,a=pe("Popover.Button"),[C,y,s,x,S,B,w]=z(a,l.useCallback(o=>[o.popoverState,a.selectors.isPortalled(o),o.button,o.buttonId,o.panel,o.panelId,o.afterButtonSentinel],[])),d=l.useRef(null),p=`headlessui-focus-sentinel-${l.useId()}`,f=De(),P=f==null?void 0:f.closeOthers,c=It()!==null;l.useEffect(()=>{if(!c)return a.actions.setButtonId(v),()=>a.actions.setButtonId(null)},[c,v,a]);let[_]=l.useState(()=>Symbol()),te=U(d,n,bt(),k(o=>{if(!c){if(o)a.state.buttons.current.push(_);else{let i=a.state.buttons.current.indexOf(_);i!==-1&&a.state.buttons.current.splice(i,1)}a.state.buttons.current.length>1&&console.warn("You are already using a but only 1 is supported."),o&&a.actions.setButton(o)}})),ne=U(d,n),G=k(o=>{var i,O,T;if(c){if(a.state.popoverState===$.Closed)return;switch(o.key){case K.Space:case K.Enter:o.preventDefault(),(O=(i=o.target).click)==null||O.call(i),a.actions.close(),(T=a.state.button)==null||T.focus();break}}else switch(o.key){case K.Space:case K.Enter:o.preventDefault(),o.stopPropagation(),a.state.popoverState===$.Closed?(P==null||P(a.state.buttonId),a.actions.open()):a.actions.close();break;case K.Escape:if(a.state.popoverState!==$.Open)return P==null?void 0:P(a.state.buttonId);if(!d.current)return;let R=se(d.current);if(R&&!d.current.contains(R))return;o.preventDefault(),o.stopPropagation(),a.actions.close();break}}),D=k(o=>{c||o.key===K.Space&&o.preventDefault()}),Y=k(o=>{var i,O;Be(o.currentTarget)||h||(c?(a.actions.close(),(i=a.state.button)==null||i.focus()):(o.preventDefault(),o.stopPropagation(),a.state.popoverState===$.Closed?(P==null||P(a.state.buttonId),a.actions.open()):a.actions.close(),(O=a.state.button)==null||O.focus()))}),ae=k(o=>{o.preventDefault(),o.stopPropagation()}),{isFocusVisible:oe,focusProps:V}=We({autoFocus:b}),{isHovered:X,hoverProps:u}=Ye({isDisabled:h}),{pressed:F,pressProps:E}=Ve({disabled:h}),j=C===$.Open,Q=re({open:j,active:F||j,disabled:h,hover:X,focus:oe,autofocus:b}),N=Xe(e,s),Z=c?me({ref:ne,type:N,onKeyDown:G,onClick:Y,disabled:h||void 0,autoFocus:b},V,u,E):me({ref:te,id:x,type:N,"aria-expanded":C===$.Open,"aria-controls":S?B:void 0,disabled:h||void 0,autoFocus:b,onKeyDown:G,onKeyUp:D,onClick:Y,onMouseDown:ae},V,u,E),ue=_e(),fe=k(()=>{if(!be(a.state.panel))return;let o=a.state.panel;function i(){q(ue.current,{[M.Forwards]:()=>W(o,A.First),[M.Backwards]:()=>W(o,A.Last)})===he.Error&&W($e(xe(a.state.button)).filter(O=>O.dataset.headlessuiFocusGuard!=="true"),q(ue.current,{[M.Forwards]:A.Next,[M.Backwards]:A.Previous}),{relativeTo:a.state.button})}i()}),m=le();return g.createElement(g.Fragment,null,m({ourProps:Z,theirProps:r,slot:Q,defaultTag:_t,name:"Popover.Button"}),j&&!c&&y&&g.createElement(ye,{id:p,ref:w,features:Pe.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:fe}))}let Ot="div",Et=ie.RenderStrategy|ie.Static;function Re(e,n){let t=l.useId(),{id:v=`headlessui-popover-backdrop-${t}`,transition:h=!1,...b}=e,r=pe("Popover.Backdrop"),a=z(r,l.useCallback(f=>f.popoverState,[])),[C,y]=l.useState(null),s=U(n,y),x=Fe(),[S,B]=Oe(h,C,x!==null?(x&J.Open)===J.Open:a===$.Open),w=k(f=>{if(Be(f.currentTarget))return f.preventDefault();r.actions.close()}),d=re({open:a===$.Open}),p={ref:s,id:v,"aria-hidden":!0,onClick:w,...Ee(B)};return le()({ourProps:p,theirProps:b,slot:d,defaultTag:Ot,features:Et,visible:S,name:"Popover.Backdrop"})}let Tt="div",jt=ie.RenderStrategy|ie.Static;function Nt(e,n){let t=l.useId(),{id:v=`headlessui-popover-panel-${t}`,focus:h=!1,anchor:b,portal:r=!1,modal:a=!1,transition:C=!1,...y}=e,s=pe("Popover.Panel"),x=z(s,s.selectors.isPortalled),[S,B,w,d,p]=z(s,l.useCallback(m=>[m.popoverState,m.button,m.__demoMode,m.beforePanelSentinel,m.afterPanelSentinel],[])),f=`headlessui-focus-sentinel-before-${t}`,P=`headlessui-focus-sentinel-after-${t}`,c=l.useRef(null),_=mt(b),[te,ne]=ht(_),G=yt();_&&(r=!0);let[D,Y]=l.useState(null),ae=U(c,n,_?te:null,s.actions.setPanel,Y),oe=we(B),V=we(c.current);Qe(()=>(s.actions.setPanelId(v),()=>s.actions.setPanelId(null)),[v,s]);let X=Fe(),[u,F]=Oe(C,D,X!==null?(X&J.Open)===J.Open:S===$.Open);Ze(u,B,s.actions.close),qe(w?!1:a&&u,V);let E=k(m=>{var o;switch(m.key){case K.Escape:if(s.state.popoverState!==$.Open||!c.current)return;let i=se(c.current);if(i&&!c.current.contains(i))return;m.preventDefault(),m.stopPropagation(),s.actions.close(),(o=s.state.button)==null||o.focus();break}});l.useEffect(()=>{var m;e.static||S===$.Closed&&((m=e.unmount)==null||m)&&s.actions.setPanel(null)},[S,e.unmount,e.static,s]),l.useEffect(()=>{if(w||!h||S!==$.Open||!c.current)return;let m=se(c.current);c.current.contains(m)||W(c.current,A.First)},[w,h,c.current,S]);let j=re({open:S===$.Open,close:s.actions.refocusableClose}),Q=me(_?G():{},{ref:ae,id:v,onKeyDown:E,onBlur:h&&S===$.Open?m=>{var o,i,O,T,R;let L=m.relatedTarget;L&&c.current&&((o=c.current)!=null&&o.contains(L)||(s.actions.close(),((O=(i=d.current)==null?void 0:i.contains)!=null&&O.call(i,L)||(R=(T=p.current)==null?void 0:T.contains)!=null&&R.call(T,L))&&L.focus({preventScroll:!0})))}:void 0,tabIndex:-1,style:{...y.style,...ne,"--button-width":Pt(u,B,!0).width},...Ee(F)}),N=_e(),Z=k(()=>{let m=c.current;if(!m)return;function o(){q(N.current,{[M.Forwards]:()=>{var i;W(m,A.First)===he.Error&&((i=s.state.afterPanelSentinel.current)==null||i.focus())},[M.Backwards]:()=>{var i;(i=s.state.button)==null||i.focus({preventScroll:!0})}})}o()}),ue=k(()=>{let m=c.current;if(!m)return;function o(){q(N.current,{[M.Forwards]:()=>{var i;if(!s.state.button)return;let O=(i=xe(s.state.button))!=null?i:document.body,T=$e(O),R=T.indexOf(s.state.button),L=T.slice(0,R+1),ce=[...T.slice(R+1),...L];for(let ve of ce.slice())if(ve.dataset.headlessuiFocusGuard==="true"||D!=null&&D.contains(ve)){let Ce=ce.indexOf(ve);Ce!==-1&&ce.splice(Ce,1)}W(ce,A.First,{sorted:!1})},[M.Backwards]:()=>{var i;W(m,A.Previous)===he.Error&&((i=s.state.button)==null||i.focus())}})}o()}),fe=le();return g.createElement(ze,null,g.createElement(de.Provider,{value:v},g.createElement(Te,{value:s.actions.refocusableClose},g.createElement(Ue,{enabled:r?e.static||u:!1,ownerDocument:oe},u&&x&&g.createElement(ye,{id:f,ref:d,features:Pe.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:Z}),fe({ourProps:Q,theirProps:y,slot:j,defaultTag:Tt,features:jt,visible:u,name:"Popover.Panel"}),u&&x&&g.createElement(ye,{id:P,ref:p,features:Pe.Focusable,"data-headlessui-focus-guard":!0,as:"button",type:"button",onFocus:ue})))))}let Dt="div";function Rt(e,n){let t=l.useRef(null),v=U(t,n),[h,b]=l.useState([]),r=k(d=>{b(p=>{let f=p.indexOf(d);if(f!==-1){let P=p.slice();return P.splice(f,1),P}return p})}),a=k(d=>(b(p=>[...p,d]),()=>r(d))),C=k(()=>{var d;let p=xe(t.current);if(!p)return!1;let f=se(t.current);return(d=t.current)!=null&&d.contains(f)?!0:h.some(P=>{var c,_;return((c=p.getElementById(P.buttonId.current))==null?void 0:c.contains(f))||((_=p.getElementById(P.panelId.current))==null?void 0:_.contains(f))})}),y=k(d=>{for(let p of h)p.buttonId.current!==d&&p.close()}),s=l.useMemo(()=>({registerPopover:a,unregisterPopover:r,isFocusWithinPopoverGroup:C,closeOthers:y}),[a,r,C,y]),x=re({}),S=e,B={ref:v},w=le();return g.createElement(je,null,g.createElement(Se.Provider,{value:s},w({ourProps:B,theirProps:S,slot:x,defaultTag:Dt,name:"Popover.Group"})))}let Mt=ee(Bt),Me=ee(Ft),At=ee(Re),Gt=ee(Re),Ae=ee(Nt),Lt=ee(Rt),Ht=Object.assign(Mt,{Button:Me,Backdrop:Gt,Overlay:At,Panel:Ae,Group:Lt});/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/activity-2-g8m4_g.js b/frontend/dist/assets/activity-Dr_TPIps.js similarity index 89% rename from frontend/dist/assets/activity-2-g8m4_g.js rename to frontend/dist/assets/activity-Dr_TPIps.js index 2294bc9d..268626ad 100644 --- a/frontend/dist/assets/activity-2-g8m4_g.js +++ b/frontend/dist/assets/activity-Dr_TPIps.js @@ -1,4 +1,4 @@ -import{d as t}from"./index-C8IY8K2r.js";/** +import{d as t}from"./index-BwGHI0A_.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/antenna-DOuH490Q.js b/frontend/dist/assets/antenna-zVXb9cuG.js similarity index 90% rename from frontend/dist/assets/antenna-DOuH490Q.js rename to frontend/dist/assets/antenna-zVXb9cuG.js index 8bf3d944..28cebfb6 100644 --- a/frontend/dist/assets/antenna-DOuH490Q.js +++ b/frontend/dist/assets/antenna-zVXb9cuG.js @@ -1,4 +1,4 @@ -import{d as e}from"./index-C8IY8K2r.js";/** +import{d as e}from"./index-BwGHI0A_.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/arrow-up-DbeeGdHO.js b/frontend/dist/assets/arrow-up-DJuSVUZI.js similarity index 92% rename from frontend/dist/assets/arrow-up-DbeeGdHO.js rename to frontend/dist/assets/arrow-up-DJuSVUZI.js index 255dfba2..78695b87 100644 --- a/frontend/dist/assets/arrow-up-DbeeGdHO.js +++ b/frontend/dist/assets/arrow-up-DJuSVUZI.js @@ -1,4 +1,4 @@ -import{d as o}from"./index-C8IY8K2r.js";/** +import{d as o}from"./index-BwGHI0A_.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/chat-utils-D1Q4VWjO.js b/frontend/dist/assets/chat-utils-Di4-nywi.js similarity index 94% rename from frontend/dist/assets/chat-utils-D1Q4VWjO.js rename to frontend/dist/assets/chat-utils-Di4-nywi.js index a27b581a..a04cbe27 100644 --- a/frontend/dist/assets/chat-utils-D1Q4VWjO.js +++ b/frontend/dist/assets/chat-utils-Di4-nywi.js @@ -1 +1 @@ -import{cR as a,r as l}from"./index-C8IY8K2r.js";const s=[a.green,a.blue,a.amber,a.pink,a.purple,a.cyan,a.orange,a.teal];function m(e){let n=0;for(let t=0;t0){const t=n[0],o=e.replace(i,"").trim();return{emoji:t,cleanName:o||e}}return{emoji:null,cleanName:e}}function f(e){const{cleanName:n}=u(e),t=n.split(/[\s-_]+/).filter(Boolean);if(t.length>=2){const r=Array.from(t[0])[0]||"",c=Array.from(t[1])[0]||"";return(r+c).toUpperCase()}return Array.from(n).slice(0,2).join("").toUpperCase()}function p(e){return new Date(e*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})}function g(e){const n=/@\[([^\]]+)\]/g,t=[];let o=0,r;for(;(r=n.exec(e))!==null;)r.index>o&&t.push(e.slice(o,r.index)),t.push(l.createElement("span",{key:r.index,className:"font-extrabold text-white"},r[1])),o=r.index+r[0].length;return o0?t:e}export{f as a,p as b,u as e,g as f,m as g}; +import{cW as a,r as l}from"./index-BwGHI0A_.js";const s=[a.green,a.blue,a.amber,a.pink,a.purple,a.cyan,a.orange,a.teal];function m(e){let n=0;for(let t=0;t0){const t=n[0],o=e.replace(i,"").trim();return{emoji:t,cleanName:o||e}}return{emoji:null,cleanName:e}}function f(e){const{cleanName:n}=u(e),t=n.split(/[\s-_]+/).filter(Boolean);if(t.length>=2){const r=Array.from(t[0])[0]||"",c=Array.from(t[1])[0]||"";return(r+c).toUpperCase()}return Array.from(n).slice(0,2).join("").toUpperCase()}function p(e){return new Date(e*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1})}function g(e){const n=/@\[([^\]]+)\]/g,t=[];let o=0,r;for(;(r=n.exec(e))!==null;)r.index>o&&t.push(e.slice(o,r.index)),t.push(l.createElement("span",{key:r.index,className:"font-extrabold text-white"},r[1])),o=r.index+r[0].length;return o0?t:e}export{f as a,p as b,u as e,g as f,m as g}; diff --git a/frontend/dist/assets/chevron-right-DUgYTR6d.js b/frontend/dist/assets/chevron-right-DqpRZiGf.js similarity index 85% rename from frontend/dist/assets/chevron-right-DUgYTR6d.js rename to frontend/dist/assets/chevron-right-DqpRZiGf.js index a64aee82..e9d17ef3 100644 --- a/frontend/dist/assets/chevron-right-DUgYTR6d.js +++ b/frontend/dist/assets/chevron-right-DqpRZiGf.js @@ -1,4 +1,4 @@ -import{d as o}from"./index-C8IY8K2r.js";/** +import{d as o}from"./index-BwGHI0A_.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/circle-check-BOp4wLxA.js b/frontend/dist/assets/circle-check-CBI-CiRo.js similarity index 87% rename from frontend/dist/assets/circle-check-BOp4wLxA.js rename to frontend/dist/assets/circle-check-CBI-CiRo.js index bd30b844..9c17a076 100644 --- a/frontend/dist/assets/circle-check-BOp4wLxA.js +++ b/frontend/dist/assets/circle-check-CBI-CiRo.js @@ -1,4 +1,4 @@ -import{d as c}from"./index-C8IY8K2r.js";/** +import{d as c}from"./index-BwGHI0A_.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/circle-question-mark-C7l07_IA.js b/frontend/dist/assets/circle-question-mark-DC7QfrVK.js similarity index 89% rename from frontend/dist/assets/circle-question-mark-C7l07_IA.js rename to frontend/dist/assets/circle-question-mark-DC7QfrVK.js index 88cab46f..c772800d 100644 --- a/frontend/dist/assets/circle-question-mark-C7l07_IA.js +++ b/frontend/dist/assets/circle-question-mark-DC7QfrVK.js @@ -1,4 +1,4 @@ -import{d as c}from"./index-C8IY8K2r.js";/** +import{d as c}from"./index-BwGHI0A_.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/consumer-registry-lDKP4bcU.js b/frontend/dist/assets/consumer-registry-DPYvsBcc.js similarity index 92% rename from frontend/dist/assets/consumer-registry-lDKP4bcU.js rename to frontend/dist/assets/consumer-registry-DPYvsBcc.js index 7330fd98..7b2e93b9 100644 --- a/frontend/dist/assets/consumer-registry-lDKP4bcU.js +++ b/frontend/dist/assets/consumer-registry-DPYvsBcc.js @@ -1 +1 @@ -import{a7 as n,r as i}from"./index-C8IY8K2r.js";const p=t=>(t.type??t.payload_type)===n.ADVERT,l=t=>(t.type??t.payload_type)===n.TRACE,h=t=>(t.type??t.payload_type)===n.TXT_MSG,_=t=>(t.type??t.payload_type)===n.PATH,d=t=>(t.type??t.payload_type)===n.ACK,g=t=>{const e=t.type??t.payload_type;return e===n.GRP_TXT||e===n.GRP_DATA},m=t=>(t.path_length??(Array.isArray(t.original_path)?t.original_path.length:0))>0,A=t=>!!t.src_hash,T=t=>t.airtime_ms!=null,c=new Set,o=new Map;function a(t,e){return`${t}|${e}`}function u(t,e){const s=a(t,e);o.set(s,(o.get(s)??0)+1)}function y(t,e){const s=a(t,e),r=o.get(s)??0;r>1?o.set(s,r-1):o.delete(s)}function C(t){for(const e of t){const s=a(e.target,e.fn);c.has(s)||c.add(s)}}function P(t){i.useEffect(()=>{for(const e of t)u(e.target,e.fn);return()=>{for(const e of t)y(e.target,e.fn)}},[t])}export{m as a,A as b,h as c,d,p as e,l as f,_ as g,T as h,g as i,C as r,P as u}; +import{a7 as n,r as i}from"./index-BwGHI0A_.js";const p=t=>(t.type??t.payload_type)===n.ADVERT,l=t=>(t.type??t.payload_type)===n.TRACE,h=t=>(t.type??t.payload_type)===n.TXT_MSG,_=t=>(t.type??t.payload_type)===n.PATH,d=t=>(t.type??t.payload_type)===n.ACK,g=t=>{const e=t.type??t.payload_type;return e===n.GRP_TXT||e===n.GRP_DATA},m=t=>(t.path_length??(Array.isArray(t.original_path)?t.original_path.length:0))>0,A=t=>!!t.src_hash,T=t=>t.airtime_ms!=null,c=new Set,o=new Map;function a(t,e){return`${t}|${e}`}function u(t,e){const s=a(t,e);o.set(s,(o.get(s)??0)+1)}function y(t,e){const s=a(t,e),r=o.get(s)??0;r>1?o.set(s,r-1):o.delete(s)}function C(t){for(const e of t){const s=a(e.target,e.fn);c.has(s)||c.add(s)}}function P(t){i.useEffect(()=>{for(const e of t)u(e.target,e.fn);return()=>{for(const e of t)y(e.target,e.fn)}},[t])}export{m as a,A as b,h as c,d,p as e,l as f,_ as g,T as h,g as i,C as r,P as u}; diff --git a/frontend/dist/assets/database-BEyHF_p_.js b/frontend/dist/assets/database-CDN_R6oC.js similarity index 89% rename from frontend/dist/assets/database-BEyHF_p_.js rename to frontend/dist/assets/database-CDN_R6oC.js index 272e09a1..b831896b 100644 --- a/frontend/dist/assets/database-BEyHF_p_.js +++ b/frontend/dist/assets/database-CDN_R6oC.js @@ -1,4 +1,4 @@ -import{d as e}from"./index-C8IY8K2r.js";/** +import{d as e}from"./index-BwGHI0A_.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/decryption.worker-B7tVWyZU.js b/frontend/dist/assets/decryption.worker-CmMB-xKW.js similarity index 59% rename from frontend/dist/assets/decryption.worker-B7tVWyZU.js rename to frontend/dist/assets/decryption.worker-CmMB-xKW.js index 993589b0..ca19acbe 100644 --- a/frontend/dist/assets/decryption.worker-B7tVWyZU.js +++ b/frontend/dist/assets/decryption.worker-CmMB-xKW.js @@ -1 +1 @@ -(function(){"use strict";function k(a){const e=a.replace(/^0x/i,"").replace(/\s/g,"");if(e.length%2!==0)throw new Error("Invalid hex string: odd number of characters");const n=new Uint8Array(e.length/2);for(let o=0;o>>e|a<<32-e)>>>0}function Y(a,e){let n=a[0],o=a[1],s=a[2],t=a[3],l=a[4],i=a[5],r=a[6],h=a[7];for(let c=0;c<64;c++){if(c>=16){const C=g(e[c-15&15],7)^g(e[c-15&15],18)^e[c-15&15]>>>3,ha=g(e[c-2&15],17)^g(e[c-2&15],19)^e[c-2&15]>>>10;e[c&15]=e[c&15]+C+e[c-7&15]+ha>>>0}const y=g(l,6)^g(l,11)^g(l,25),w=l&i^~l&r,f=h+y+w+O[c]+e[c&15]>>>0,b=g(n,2)^g(n,13)^g(n,22),m=n&o^n&s^o&s,p=b+m>>>0;h=r,r=i,i=l,l=t+f>>>0,t=s,s=o,o=n,n=f+p>>>0}a[0]=a[0]+n>>>0,a[1]=a[1]+o>>>0,a[2]=a[2]+s>>>0,a[3]=a[3]+t>>>0,a[4]=a[4]+l>>>0,a[5]=a[5]+i>>>0,a[6]=a[6]+r>>>0,a[7]=a[7]+h>>>0}function x(a){const e=new Uint32Array(V),n=new Uint32Array(16),o=a.length*8,s=a.length+9+63&-64,t=new Uint8Array(s);t.set(a),t[a.length]=128;const l=new DataView(t.buffer);l.setUint32(s-4,o,!1);for(let h=0;h64?(o=new Uint8Array(64),o.set(x(a))):(o=new Uint8Array(64),o.set(a));const s=new Uint8Array(64),t=new Uint8Array(64);for(let h=0;h<64;h++)s[h]=o[h]^54,t[h]=o[h]^92;const l=new Uint8Array(64+e.length);l.set(s),l.set(e,64);const i=x(l),r=new Uint8Array(96);return r.set(t),r.set(i,64),x(r)}async function X(a,e){if(K())try{const n=new ArrayBuffer(a.length);new Uint8Array(n).set(a);const o=new ArrayBuffer(e.length);new Uint8Array(o).set(e);const s=await crypto.subtle.importKey("raw",n,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),t=await crypto.subtle.sign("HMAC",s,o);return new Uint8Array(t)}catch{}return $(a,e)}const z=new Uint8Array([99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22]),G=new Uint8Array([82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125]),J=new Uint8Array([1,2,4,8,16,32,64,128,27,54]);function d(a,e){let n=0;for(let o=0;o<8;o++){e&1&&(n^=a);const s=a&128;a=a<<1&255,s&&(a^=27),e>>=1}return n}function Z(a){const e=[],n=new Uint8Array(176);n.set(a.slice(0,16));for(let o=16;o<176;o+=4){let s=n[o-4],t=n[o-3],l=n[o-2],i=n[o-1];if(o%16===0){const r=s;s=z[t]^J[o/16-1],t=z[l],l=z[i],i=z[r]}n[o]=n[o-16]^s,n[o+1]=n[o-15]^t,n[o+2]=n[o-14]^l,n[o+3]=n[o-13]^i}for(let o=0;o<11;o++)e.push(n.slice(o*16,(o+1)*16));return e}function P(a){let e=a[13];a[13]=a[9],a[9]=a[5],a[5]=a[1],a[1]=e,e=a[2],a[2]=a[10],a[10]=e,e=a[6],a[6]=a[14],a[14]=e,e=a[3],a[3]=a[7],a[7]=a[11],a[11]=a[15],a[15]=e}function B(a){for(let e=0;e<16;e++)a[e]=G[a[e]]}function U(a,e){for(let n=0;n<16;n++)a[n]^=e[n]}function Q(a){for(let e=0;e<4;e++){const n=e*4,o=a[n],s=a[n+1],t=a[n+2],l=a[n+3];a[n]=d(14,o)^d(11,s)^d(13,t)^d(9,l),a[n+1]=d(9,o)^d(14,s)^d(11,t)^d(13,l),a[n+2]=d(13,o)^d(9,s)^d(14,t)^d(11,l),a[n+3]=d(11,o)^d(13,s)^d(9,t)^d(14,l)}}function W(a,e){const n=new Uint8Array(a);U(n,e[10]);for(let o=9;o>=1;o--)P(n),B(n),U(n,e[o]),Q(n);return P(n),B(n),U(n,e[0]),n}function j(a,e){const o=Z(a),s=new Uint8Array(e.length);for(let t=0;t>>0}const H=["alameda","alpine","amador","butte","calaveras","colusa","contracosta","contra-costa","delnorte","del-norte","eldorado","el-dorado","fresno","glenn","humboldt","imperial","inyo","kern","kings","lake","lassen","losangeles","los-angeles","la-county","madera","marin","mariposa","mendocino","merced","modoc","mono","monterey","napa","nevada","orange","oc","placer","plumas","riverside","sacramento","sac","sanbenito","san-benito","sanbernardino","san-bernardino","sandiego","san-diego","sd","sanfrancisco","san-francisco","sf","sanjoaquin","san-joaquin","sanluisobispo","san-luis-obispo","slo","sanmateo","san-mateo","santabarbara","santa-barbara","sb","santaclara","santa-clara","santacruz","santa-cruz","shasta","sierra","siskiyou","solano","sonoma","stanislaus","sutter","tehama","trinity","tulare","tuolumne","ventura","yolo","yuba","losangeles","los-angeles","la","hollywood","westhollywood","west-hollywood","weho","beverlyhills","beverly-hills","santamonica","santa-monica","culvercity","culver-city","marinadelrey","marina-del-rey","venice","venicebeach","venice-beach","malibu","palisades","pacificpalisades","pacific-palisades","brentwood","westwood","westla","west-la","dtla","downtown","downtownla","downtown-la","koreatown","ktown","silverlake","silver-lake","losfeliz","los-feliz","echopark","echo-park","eastla","east-la","boyleheights","boyle-heights","highlandpark","highland-park","eaglerock","eagle-rock","pasadena","southpasadena","south-pasadena","glendale","burbank","tolucalake","toluca-lake","studiocity","studio-city","shermanoaks","sherman-oaks","encino","tarzana","reseda","vannuys","van-nuys","northhollywood","north-hollywood","noho","woodlandhills","woodland-hills","calabasas","topanga","agourahills","agoura-hills","thousandoaks","thousand-oaks","simivalley","simi-valley","simi","moorpark","camarillo","oxnard","porthueneme","port-hueneme","ventura","ojai","sfv","sfvalley","sf-valley","thevalley","the-valley","sanfernando","san-fernando","sanfernandovalley","san-fernando-valley","pacoima","sylmar","sunland","tujunga","sunlandtujunga","lakeviewterrace","lakeview-terrace","shadowhills","shadow-hills","chatsworth","northridge","granadahills","granada-hills","missionhills","mission-hills","panoramacity","panorama-city","arleta","sunvalley","sun-valley","santaclarita","santa-clarita","scv","valencia","newhall","saugus","canyoncountry","canyon-country","castaic","stevenson","stevensonranch","stevenson-ranch","acton","agua-dulce","aguadulce","palmdale","lancaster","antelopevalley","antelope-valley","av","avmesh","av-mesh","quartz-hill","quartzhill","littlerock","little-rock","pearblossom","pear-blossom","lakelosangeles","lake-los-angeles","highdesert","high-desert","hd","hdmesh","hd-mesh","victorville","hesperia","applevalley","apple-valley","barstow","adelanto","phelan","pinon-hills","pinonhills","wrightwood","bigbear","big-bear","lakeisabella","lake-isabella","inlandempire","inland-empire","ie","riverside","corona","moreno-valley","morenovalley","fontana","ontario","rancho","ranchocucamonga","rancho-cucamonga","upland","claremont","pomona","azusa","glendora","covina","westcovina","west-covina","diamondbar","diamond-bar","chino","chinohills","chino-hills","sanbernardinocity","rialto","colton","redlands","yuciapa","yucaipa","beaumont","banning","hemet","perris","menifee","temecula","murrieta","wildomar","lakeland","lakeelsinore","lake-elsinore","orangecounty","orange-county","oc","anaheim","fullerton","santaana","santa-ana","irvine","costamesa","costa-mesa","newportbeach","newport-beach","newport","huntingtonbeach","huntington-beach","hb","surfcity","surf-city","lagunabeach","laguna-beach","lagunaniguel","laguna-niguel","sanclemente","san-clemente","danapoint","dana-point","missionviejo","mission-viejo","lakeforest","lake-forest","rsm","ranchosantamargarita","rancho-santa-margarita","alisoviejo","aliso-viejo","tustin","orange","yorbalinda","yorba-linda","brea","lahabra","la-habra","placentia","buenapark","buena-park","cypress","losalamitojos","sealbeach","seal-beach","gardengrove","garden-grove","westminster","stanton","fountainvalley","sandiego","san-diego","sd","sdmesh","sd-mesh","lajolla","la-jolla","pacificbeach","pacific-beach","pb","missionbeach","mission-beach","oceanbeach","ocean-beach","ob","pointloma","point-loma","coronado","hillcrest","northpark","north-park","southpark","south-park","normalheights","normal-heights","cityheights","city-heights","lamesa","la-mesa","elcajon","el-cajon","santee","lakeside","poway","ramona","julian","alpine","escondido","sanmarcos","san-marcos","vista","oceanside","carlsbad","encinitas","delmar","del-mar","solanabeanch","solana-beach","chulavista","chula-vista","nationalcity","national-city","imperialbeach","imperial-beach","ib","southbay","south-bay","torrance","gardena","hawthorne","lawndale","redondo","redondobeach","hermosa","hermosabeach","manhattan","manhattanbeach","manhattan-beach","elsegundo","el-segundo","palosverdes","palos-verdes","pv","ranchopalosverdes","rancho-palos-verdes","sanpedro","san-pedro","wilmington","carson","compton","longbeach","long-beach","lb","signalhill","signal-hill","lakewood","cerritos","artesia","lamirada","la-mirada","norwalk","whittier","lahabra","la-habra-heights","downey","bellflower","paramount","southgate","south-gate","lynwood","bellgardens","bell-gardens","cudahy","huntingtonpark","maywood","vernon","commerce","montebello","picorivera","pico-rivera","montereypark","monterey-park","alhambra","sanmarinno","san-marino","arcadia","monrovia","duarte","azusa","irwindale","baldwinpark","baldwin-park","elmonbte","el-monte","southelmonte","south-el-monte","rosemead","temple-city","templecity","sangabriel","san-gabriel","santabarbara","santa-barbara","sb","goleta","carpinteria","montecito","islavista","isla-vista","iv","ucsb","slo","sanluisobispo","san-luis-obispo","morrobay","morro-bay","pismobeach","pismo-beach","pismo","shellbeach","shell-beach","arroyogrande","arroyo-grande","groverbeach","grover-beach","oceano","santamaria","santa-maria","lompoc","vandenberg","solvang","buellton","losalamos","los-alamos","atascadero","pasorobles","paso-robles","paso","cambria","cayucos","sansiemon","san-simeon","hearst","fresno","clovis","visalia","tulare","hanford","porterville","bakersfield","bako","delano","wasco","shafter","taft","tehachapi","stockton","tracy","manteca","lodi","modesto","turlock","merced","madera","chowchilla","losabnos","los-banos","sacramento","sac","sactown","westsacramento","west-sacramento","westsac","elkgrove","elk-grove","folsom","ranchocordova","rancho-cordova","roseville","rocklin","lincoln","citrus-heights","citrusheights","fair-oaks","fairoaks","carmichael","orangevale","davis","woodland","dixon","vacaville","fairfield","vallejo","bayarea","bay-area","sfbay","sf-bay","sanfrancisco","san-francisco","sf","sfmesh","sf-mesh","oakland","eastbay","east-bay","berkeley","emeryville","alameda","sanleandro","san-leandro","hayward","fremont","unioncity","union-city","newark","milpitas","sanjose","san-jose","sj","campbell","saratoga","losgartos","los-gatos","sunnyvale","santaclara","santa-clara","cupertino","mountainview","mountain-view","paloalto","palo-alto","menlopark","menlo-park","atherton","redwoodcity","redwood-city","sancarlos","san-carlos","belmont","sanmateo","san-mateo","fostercity","foster-city","burlingame","sanbruno","san-bruno","southsanfrancisco","ssf","dalycity","daly-city","pacifica","halfmoonbay","half-moon-bay","hmb","santacruz","santa-cruz","capitola","scottsvalley","scotts-valley","watsonville","aptos","soquel","concord","walnutcreek","walnut-creek","pleasant-hill","pleasanthill","martinez","antioch","pittsburg","brentwood","oakley","discovery-bay","livermore","pleasanton","dublin","sanramon","san-ramon","danville","richmond","sanpablo","san-pablo","pinole","hercules","napa","sonoma","petaluma","santarosa","santa-rosa","rohnertpark","novato","sanrafael","san-rafael","sausalito","tiburon","millvalley","mill-valley","redding","chico","oroville","paradise","reddingbluff","redbluff","red-bluff","shasta","mtshasta","mt-shasta","eureka","arcata","fortuna","mckibleyville","ukiah","fortbragg","fort-bragg","willits","yreka","weed","dunsmuir","tahoe","laketahoe","lake-tahoe","southlaketahoe","south-lake-tahoe","truckee","squaw","squawvalley","squaw-valley","northstar","mammoth","mammothlakes","mammoth-lakes","bishopca","bishop","placerville","tahoe-city","tahoecity","kings-beach","kingsbeach","incline","inclinevillage","incline-village","maricopa","pima","pinal","yavapai","yuma","mohave","coconino","cochise","navajo","apache","gila","santacruzaz","graham","lapaz","la-paz","greenlee","arizona","az","azmesh","az-mesh","phoenix","phx","phoenixmesh","phoenix-mesh","scottsdale","tempe","mesa","gilbert","chandler","glendale","peoria","surprize","avondale","goodyear","buckeye","litchfieldpark","litchfield-park","tolleson","laveen","paradisevalley","paradise-valley","pv","carefree","cavekreek","cave-creek","fountainhills","fountain-hills","rioverde","rio-verde","queencreek","queen-creek","santan","san-tan","santanvalley","ahwatukee","southmountain","south-mountain","anthem","newriver","new-river","apachejunction","apache-junction","aj","goldcanyon","gold-canyon","tucson","tucsomesh","tucson-mesh","orovalley","oro-valley","marana","catalina","catalinafoothills","saddlebrooke","casagrande","casa-grande","eloy","coolidge","florence","sierravista","sierra-vista","bisbee","tombstone","benson","douglas","nogales","tubac","greenvalley","green-valley","sahuarita","flagstaff","flag","flagmesh","sedona","cottonwood","clarkdale","prescott","prescottvalley","prescott-valley","dewey","chino-valley","chinovalley","williams","grandcanyon","grand-canyon","tusayan","page","marble-canyon","showlow","show-low","pinetop","pinetoplakeside","lakeside","snowflake","taylor","payson","pine","strawberry","camp-verde","campverde","winslow","holbrook","stjohns","springerville","eagar","yuma","yumamesh","fortuna-foothills","sanluisaz","san-luis","lakehavasu","lake-havasu","havasu","havasucity","lake-havasu-city","bullheadcity","bullhead-city","bullhead","laughlin","kingman","goldenkvalley","golden-valley","parker","quartzsite","wickenburg","lasvegas","las-vegas","vegas","vegasmesh","vegas-mesh","lv","henderson","boulder-city","bouldercity","northlasvegas","north-las-vegas","nlv","summerlin","enterprise","pahrump","mesquite","reno","sparks","carsoncity","carson-city","incline","bajacalifornia","baja-california","baja","bajamesh","tijuana","tj","mexicali","ensenada","tecate","rosarito","sanfelipe","san-felipe","sanluis","sanluisriocoalorado","brabant","flevoland","gelderland","noordbrabant","noordholland","zuid-holland","zuidholland","zeeland","twente","alkmaar","almere","amsterdam","amstelland","capelleaandenijssel","denhaag","dordrecht","drechtsteden","eindhoven","haarlem","hellevoetsluis","hilversum","katwijk","lelystad","maassluis","middelburg","rijnmond","rotterdam","tilburg","utrecht","vlissingen","voorburg","voorne-putten","walcheren","west-friesland","zaandam","zaanstreek-waterland","024-bot","afrithonbot","ai","amradio","analyser","angrynerds","bemesh","bot","buch","burgernet","chat","chatgpt","dares","dekroeg","dtis","emergency","english","evenvroegopstaan","fosdem","gezellig","gmr","gmrbot","goedemorgen","gyverbot","haagscourant","hackerspacenijmegen","hamradio","hamradionederland","hetweerinjegemeente","hsnl","jokes","kanalen","koffie","linux","meshcore","nerd","nl-alert","nl-prio","noodkanaal","nsagov","pi4hm","pi4utr","pingbot","sensemakers","sports","survival","test","testing","uitdagingen","valleibot","valleirug","vleesboek","wardrive","weer","swl","qso","qrz","cq","dx","sstv","aprs","winlink","aredn","hamnet","emcomm","races","ares","auxcomm","simplex","repeater","uhf","vhf","2m","70cm","440"];new Set(H);const aa=k("8b3387e9c5cdea6ac9e5edbaa115cd72"),ea=["southbay","south-bay","bot","ventura","weather","wardrive","test","icewatch","sbcountymesh","sb-county-mesh","sbcounty","sb-county","meshbud","mesh-bud","ai-bot","aibot","hdmesh","hd-mesh","hdme","hdme7","hdme7yard","hdmeyard","hdmeshtayrd","hdmestayrd","hdmestyard","hdmetayrd","hdmeshtnyard","mustard","socalmesh","socal-mesh","meshla","mesh-la","lamesh","la-mesh","westcoast","west-coast","wcmesh","wc-mesh","eastcoast","east-coast","midwest","southwest","northwest","northeast","southeast","california","cali","santaclarita","santa-clarita","scv","newhall","valencia","saugus","castaic","palmdale","lancaster","antelopevalley","antelope-valley","avmesh","av-mesh","highdesert","high-desert","mojave","victorville","hesperia","barstow","pomona","claremont","glendora","azusa","covina","westcovina","west-covina","walnut","diamondbar","diamond-bar","whittier","brea","yorbalinda","yorba-linda","montebello","montereypark","monterey-park","alhambra","arcadia","monrovia","duarte","hermosabeach","hermosa-beach","manhattanbeach","manhattan-beach","redondobeach","redondo-beach","palosverdes","palos-verdes","sanpedro","san-pedro","ojai","fillmore","santapaula","santa-paula","porthueneme","port-hueneme","general","public","main","default","chat","local","mesh","network","emergency","sos","help","news","info","status","alerts","announce","random","offtopic","off-topic","lobby","lounge","hangout","testing","dev","development","beta","alpha","experimental","meshcore","mesh-core","meshtastic","lora","lo-ra","lorawan","lora-wan","radio","ham","amateur","hamradio","ham-radio","amateurradio","repeater","repeaters","gateway","node","nodes","rf","rfmesh","offgrid","off-grid","prepper","preppers","emcomm","ares","races","socal","so-cal","southerncalifornia","southern-california","losangeles","los-angeles","la","laarea","la-area","greaterla","sfv","sfvalley","sf-valley","sanfernandovalley","san-fernando-valley","sanfernando","san-fernando","valley","thevalley","the-valley","westla","west-la","eastla","east-la","southla","south-la","dtla","downtown","downtownla","downtown-la","hollywood","beverlyhills","beverly-hills","santamonica","santa-monica","culvercity","culver-city","marinadelrey","marina-del-rey","longbeach","long-beach","torrance","carson","compton","inglewood","pasadena","glendale","burbank","noho","northhollywood","north-hollywood","encino","tarzana","woodland","woodlandhills","woodland-hills","calabasas","malibu","topanga","agoura","agourahills","agoura-hills","thousandoaks","thousand-oaks","simivalley","simi-valley","simi","venturacounty","ventura-county","oxnard","camarillo","moorpark","santabarbara","santa-barbara","sb","goleta","carpinteria","orangecounty","orange-county","oc","irvine","anaheim","fullerton","costamesa","costa-mesa","newportbeach","newport-beach","huntingtonbeach","inlandempire","inland-empire","ie","riverside","sanbernardino","san-bernardino","ontario","rancho","ranchocucamonga","rancho-cucamonga","fontana","corona","palmsprings","palm-springs","palmdesert","palm-desert","coachella","temecula","murrieta","hemet","perris","menifee","sandiego","san-diego","sd","sdmesh","sd-mesh","norcal","nor-cal","northerncalifornia","northern-california","bayarea","bay-area","sfbay","sf-bay","sfbayarea","sf-bay-area","sanfrancisco","san-francisco","sf","sfmesh","sf-mesh","oakland","berkeley","eastbay","east-bay","alameda","sanjose","san-jose","sj","siliconvalley","silicon-valley","santaclara","santa-clara","sunnyvale","mountainview","mountain-view","paloalto","palo-alto","menlopark","menlo-park","redwoodcity","redwood-city","fremont","hayward","unioncity","union-city","newark","milpitas","santacruz","santa-cruz","watsonville","monterey","montereybay","monterey-bay","sacramento","sac","sactown","roseville","folsom","fresno","bakersfield","stockton","modesto","visalia","seattle","seattlemesh","seattle-mesh","pnw","pacificnorthwest","portland","pdx","portlandmesh","portland-mesh","oregon","denver","denvermesh","denver-mesh","colorado","boulder","austin","austinmesh","austin-mesh","atx","texas","sanantonio","san-antonio","dallas","dfw","dallasmesh","dallas-mesh","fortworth","fort-worth","houston","houstonmesh","houston-mesh","htx","phoenix","phoenixmesh","phoenix-mesh","arizona","az","tucson","mesa","tempe","lasvegas","las-vegas","vegas","vegasmesh","vegas-mesh","nevada","henderson","saltlake","salt-lake","slc","saltlakecity","salt-lake-city","utah","chicago","chicagomesh","chicago-mesh","illinois","detroit","detroitmesh","detroit-mesh","michigan","annarbor","minneapolis","twincities","twin-cities","minnesota","atlanta","atlantamesh","atlanta-mesh","atl","georgia","miami","miamimesh","miami-mesh","florida","tampa","orlando","jacksonville","boston","bostonmesh","boston-mesh","massachusetts","newyork","new-york","nyc","nycmesh","nyc-mesh","brooklyn","manhattan","queens","newjersey","new-jersey","nj","jersey","philly","philadelphia","pennsylvania","dc","washingtondc","washington-dc","dmv","nova","maryland","virginia","raleigh","durham","rdu","triangle","northcarolina","charlotte","clt","southcarolina","nashville","tennessee","memphis","knoxville","neworleans","new-orleans","nola","louisiana","hawaii","oahu","honolulu","maui","alaska","anchorage","fairbanks","canada","toronto","vancouver","montreal","calgary","edmonton","ottawa","uk","london","manchester","birmingham","edinburgh","glasgow","germany","berlin","munich","hamburg","frankfurt","france","paris","lyon","marseille","spain","madrid","barcelona","italy","rome","milan","netherlands","amsterdam","rotterdam","brabant","flevoland","gelderland","noordbrabant","noordholland","zuid-holland","zuidholland","zeeland","twente","alkmaar","almere","amstelland","capelleaandenijssel","denhaag","dordrecht","drechtsteden","eindhoven","haarlem","hellevoetsluis","hilversum","katwijk","lelystad","maassluis","middelburg","rijnmond","tilburg","utrecht","vlissingen","voorburg","voorne-putten","walcheren","west-friesland","zaandam","zaanstreek-waterland","024-bot","afrithonbot","ai","amradio","analyser","angrynerds","bemesh","buch","burgernet","chatgpt","dares","dekroeg","dtis","english","evenvroegopstaan","fosdem","gezellig","gmr","gmrbot","goedemorgen","gyverbot","haagscourant","hackerspacenijmegen","hamradionederland","hetweerinjegemeente","hsnl","jokes","kanalen","koffie","linux","nerd","nl-alert","nl-prio","noodkanaal","nsagov","pi4hm","pi4utr","pingbot","sensemakers","sports","survival","uitdagingen","valleibot","valleirug","vleesboek","wardrive","weer","australia","sydney","melbourne","brisbane","perth","adelaide","newzealand","new-zealand","auckland","wellington","japan","tokyo","osaka","kyoto","korea","seoul","taiwan","taipei","singapore","hongkong","hong-kong","india","mumbai","delhi","bangalore","brazil","saopaulo","sao-paulo","rio","mexico","mexicocity","mexico-city","guadalajara","tijuana"];function na(a){let e=a.startsWith("#")?a.slice(1):a;return e=e.toLowerCase().replace(/[^a-z0-9-]/g,""),e=e.replace(/-+/g,"-"),e=e.replace(/^-+|-+$/g,""),e}const u=new Map;let q=!1;const _=new Map;function T(a){const e=_.get(a)??0;_.set(a,e+1)}function D(a){return _.get(a)??0}async function L(a){const e=na(a),n="#"+e,o=new TextEncoder,t=(await S(o.encode(n))).slice(0,16),i=(await S(t))[0],r=new Uint8Array(32);return r.set(t),{name:"#"+e,channelHash:i,aesKey:t,hmacKey:r}}async function oa(){if(q)return;const a=aa,n=(await S(a))[0],o=new Uint8Array(32);o.set(a);const s={name:"Public",channelHash:n,aesKey:a.slice(0,16),hmacKey:o};u.has(s.channelHash)||u.set(s.channelHash,[]),u.get(s.channelHash).push(s);for(const i of ea)try{const r=await L(i);u.has(r.channelHash)||u.set(r.channelHash,[]),u.get(r.channelHash).push(r)}catch{}for(const i of H)try{const r=await L(i);u.has(r.channelHash)||u.set(r.channelHash,[]);const h=u.get(r.channelHash);h.some(c=>c.name===r.name)||h.push(r)}catch{}q=!0;let t=0,l=0;for(const i of u.values())t+=i.length,l=Math.max(l,i.length);console.log(`[DecryptWorker] Cache initialized: ${t} channels, ${u.size} unique hashes, max ${l} collisions`)}function sa(a){const e=u.get(a);return!e||e.length<=1?e??[]:[...e].sort((n,o)=>D(o.name)-D(n.name))}function F(a){if(!a||a.length<4)return null;const n=parseInt(a.slice(0,2),16)&3;let o=2;(n===0||n===3)&&(o=10);const s=parseInt(a.slice(o,o+2),16);o+=2,o+=s*2;const t=a.slice(o);return t.length<8?null:k(t)}async function R(a,e,n){const o=await X(a.hmacKey,n);return e[0]===o[0]&&e[1]===o[1]}function N(a){if(a.length<6)return{valid:!1,confidence:"low"};const e=a[0]|a[1]<<8|a[2]<<16|a[3]<<24,o=new Date(e*1e3).getFullYear(),s=o>=2024&&o<=2030;if(!s)return{valid:!1,confidence:"low"};const t=a.slice(5);if(t.length===0)return{valid:!1,confidence:"low"};let l=0,i=!1;for(let h=0;h=32&&c<=126||c===0||c===10||c===13||c===9)&&l++,c===58&&(i=!0)}const r=l/t.length;return r>=.85&&i&&s?{valid:!0,confidence:"high"}:r>=.7&&s?{valid:!0,confidence:"medium"}:{valid:!1,confidence:"low"}}async function ta(a,e,n){const o=sa(a),s=[];for(const l of o){if(await R(l,e,n)){T(l.name);const r=j(l.aesKey,n);return{keys:l,plaintext:r}}s.push(l)}let t=null;for(const l of s)try{const i=j(l.aesKey,n),r=N(i);if(r.valid){if(r.confidence==="high")return T(l.name),{keys:l,plaintext:i,macCorrupted:!0};r.confidence==="medium"&&!t&&(t={keys:l,plaintext:i,confidence:"medium"})}}catch{}return t?(T(t.keys.name),{keys:t.keys,plaintext:t.plaintext,macCorrupted:!0}):null}async function la(a,e){const n={packetHash:a.packet_hash,success:!1,channelHash:"",packetTimestamp:a.timestamp,rssi:a.rssi,snr:a.snr};if((a.type??a.payload_type)!==5)return n;const s=F(a.raw_packet);if(!s||s.length<4)return n;const t=s[0],l=s.slice(1,3),i=s.slice(3);if(n.channelHash=E(t,!0),t!==e.channelHash)return n;const r={name:e.name,channelHash:e.channelHash,aesKey:k(e.aesKeyHex),hmacKey:k(e.hmacKeyHex)},h=await R(r,l,i);let c,y=!1;if(h)c=j(r.aesKey,i);else try{c=j(r.aesKey,i);const C=N(c);if(!C.valid||C.confidence==="low")return n;y=!0}catch{return n}if(c.length<5)return n;const w=M(c,0),f=c[4],m=new TextDecoder("utf-8",{fatal:!1}).decode(c.slice(5)).replace(/\uFFFD/g,"").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F]/g,"").replace(/\x00+$/,"").trim();n.success=!0,n.channelName=r.name,n.timestamp=w,n.flags=f,n.macCorrupted=y;const p=m.indexOf(": ");return p>0?(n.senderName=m.slice(0,p),n.text=m.slice(p+2)):n.text=m,n}async function ra(a){const e={packetHash:a.packet_hash,success:!1,channelHash:"",packetTimestamp:a.timestamp,rssi:a.rssi,snr:a.snr};if((a.type??a.payload_type)!==5)return e;const o=F(a.raw_packet);if(!o||o.length<4)return e;const s=o[0],t=o.slice(1,3),l=o.slice(3);e.channelHash=E(s,!0);const i=await ta(s,t,l);if(!i)return e;const{keys:r,plaintext:h,macCorrupted:c}=i;if(h.length<5)return e;const y=M(h,0),w=h[4],b=new TextDecoder("utf-8",{fatal:!1}).decode(h.slice(5)).replace(/\uFFFD/g,"").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F]/g,"").replace(/\x00+$/,"").trim();e.success=!0,e.channelName=r.name,e.timestamp=y,e.flags=w,e.macCorrupted=c;const m=b.indexOf(": ");return m>0?(e.senderName=b.slice(0,m),e.text=b.slice(m+2)):e.text=b,e}let A=!1,v=null;function ia(){return A?new Promise(a=>{v=a}):Promise.resolve()}const I=32,ca=100;self.onmessage=async a=>{const e=a.data;switch(e.type){case"decrypt":{const n=performance.now();e.knownKey||await oa();const o=e.packets,s=e.knownKey;let t=0,l=0,i=0,r=[];const h=()=>{r.length>0&&(self.postMessage({type:"results",results:r}),r=[])};for(let y=0;ys?la(p,s):ra(p)));for(const p of b)p.success&&(t++,r.push(p),r.length>=ca&&h());l+=f.length;const m=performance.now();m-i>100&&(self.postMessage({type:"progress",processed:l,total:o.length}),i=m)}h();const c=performance.now()-n;self.postMessage({type:"batchComplete",successCount:t,totalCount:o.length,computeTimeMs:c});break}case"pause":A=!0;break;case"resume":A=!1,v&&(v(),v=null);break;case"stop":A=!1,v&&(v(),v=null);break}},self.postMessage({type:"ready"})})(); +(function(){"use strict";function k(a){const e=a.replace(/^0x/i,"").replace(/\s/g,"");if(e.length%2!==0)throw new Error("Invalid hex string: odd number of characters");const n=new Uint8Array(e.length/2);for(let o=0;o>>e|a<<32-e)>>>0}function Y(a,e){let n=a[0],o=a[1],s=a[2],t=a[3],l=a[4],i=a[5],r=a[6],h=a[7];for(let c=0;c<64;c++){if(c>=16){const C=g(e[c-15&15],7)^g(e[c-15&15],18)^e[c-15&15]>>>3,ha=g(e[c-2&15],17)^g(e[c-2&15],19)^e[c-2&15]>>>10;e[c&15]=e[c&15]+C+e[c-7&15]+ha>>>0}const y=g(l,6)^g(l,11)^g(l,25),w=l&i^~l&r,f=h+y+w+O[c]+e[c&15]>>>0,b=g(n,2)^g(n,13)^g(n,22),m=n&o^n&s^o&s,p=b+m>>>0;h=r,r=i,i=l,l=t+f>>>0,t=s,s=o,o=n,n=f+p>>>0}a[0]=a[0]+n>>>0,a[1]=a[1]+o>>>0,a[2]=a[2]+s>>>0,a[3]=a[3]+t>>>0,a[4]=a[4]+l>>>0,a[5]=a[5]+i>>>0,a[6]=a[6]+r>>>0,a[7]=a[7]+h>>>0}function x(a){const e=new Uint32Array(V),n=new Uint32Array(16),o=a.length*8,s=a.length+9+63&-64,t=new Uint8Array(s);t.set(a),t[a.length]=128;const l=new DataView(t.buffer);l.setUint32(s-4,o,!1);for(let h=0;h64?(o=new Uint8Array(64),o.set(x(a))):(o=new Uint8Array(64),o.set(a));const s=new Uint8Array(64),t=new Uint8Array(64);for(let h=0;h<64;h++)s[h]=o[h]^54,t[h]=o[h]^92;const l=new Uint8Array(64+e.length);l.set(s),l.set(e,64);const i=x(l),r=new Uint8Array(96);return r.set(t),r.set(i,64),x(r)}async function X(a,e){if(K())try{const n=new ArrayBuffer(a.length);new Uint8Array(n).set(a);const o=new ArrayBuffer(e.length);new Uint8Array(o).set(e);const s=await crypto.subtle.importKey("raw",n,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),t=await crypto.subtle.sign("HMAC",s,o);return new Uint8Array(t)}catch{}return $(a,e)}const z=new Uint8Array([99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22]),G=new Uint8Array([82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125]),J=new Uint8Array([1,2,4,8,16,32,64,128,27,54]);function d(a,e){let n=0;for(let o=0;o<8;o++){e&1&&(n^=a);const s=a&128;a=a<<1&255,s&&(a^=27),e>>=1}return n}function Z(a){const e=[],n=new Uint8Array(176);n.set(a.slice(0,16));for(let o=16;o<176;o+=4){let s=n[o-4],t=n[o-3],l=n[o-2],i=n[o-1];if(o%16===0){const r=s;s=z[t]^J[o/16-1],t=z[l],l=z[i],i=z[r]}n[o]=n[o-16]^s,n[o+1]=n[o-15]^t,n[o+2]=n[o-14]^l,n[o+3]=n[o-13]^i}for(let o=0;o<11;o++)e.push(n.slice(o*16,(o+1)*16));return e}function P(a){let e=a[13];a[13]=a[9],a[9]=a[5],a[5]=a[1],a[1]=e,e=a[2],a[2]=a[10],a[10]=e,e=a[6],a[6]=a[14],a[14]=e,e=a[3],a[3]=a[7],a[7]=a[11],a[11]=a[15],a[15]=e}function B(a){for(let e=0;e<16;e++)a[e]=G[a[e]]}function U(a,e){for(let n=0;n<16;n++)a[n]^=e[n]}function Q(a){for(let e=0;e<4;e++){const n=e*4,o=a[n],s=a[n+1],t=a[n+2],l=a[n+3];a[n]=d(14,o)^d(11,s)^d(13,t)^d(9,l),a[n+1]=d(9,o)^d(14,s)^d(11,t)^d(13,l),a[n+2]=d(13,o)^d(9,s)^d(14,t)^d(11,l),a[n+3]=d(11,o)^d(13,s)^d(9,t)^d(14,l)}}function W(a,e){const n=new Uint8Array(a);U(n,e[10]);for(let o=9;o>=1;o--)P(n),B(n),U(n,e[o]),Q(n);return P(n),B(n),U(n,e[0]),n}function j(a,e){const o=Z(a),s=new Uint8Array(e.length);for(let t=0;t>>0}const H=["alameda","alpine","amador","butte","calaveras","colusa","contracosta","contra-costa","delnorte","del-norte","eldorado","el-dorado","fresno","glenn","humboldt","imperial","inyo","kern","kings","lake","lassen","losangeles","los-angeles","la-county","madera","marin","mariposa","mendocino","merced","modoc","mono","monterey","napa","nevada","orange","oc","placer","plumas","riverside","sacramento","sac","sanbenito","san-benito","sanbernardino","san-bernardino","sandiego","san-diego","sd","sanfrancisco","san-francisco","sf","sanjoaquin","san-joaquin","sanluisobispo","san-luis-obispo","slo","sanmateo","san-mateo","santabarbara","santa-barbara","sb","santaclara","santa-clara","santacruz","santa-cruz","shasta","sierra","siskiyou","solano","sonoma","stanislaus","sutter","tehama","trinity","tulare","tuolumne","ventura","yolo","yuba","losangeles","los-angeles","la","hollywood","westhollywood","west-hollywood","weho","beverlyhills","beverly-hills","santamonica","santa-monica","culvercity","culver-city","marinadelrey","marina-del-rey","venice","venicebeach","venice-beach","malibu","palisades","pacificpalisades","pacific-palisades","brentwood","westwood","westla","west-la","dtla","downtown","downtownla","downtown-la","koreatown","ktown","silverlake","silver-lake","losfeliz","los-feliz","echopark","echo-park","eastla","east-la","boyleheights","boyle-heights","highlandpark","highland-park","eaglerock","eagle-rock","pasadena","southpasadena","south-pasadena","glendale","burbank","tolucalake","toluca-lake","studiocity","studio-city","shermanoaks","sherman-oaks","encino","tarzana","reseda","vannuys","van-nuys","northhollywood","north-hollywood","noho","woodlandhills","woodland-hills","calabasas","topanga","agourahills","agoura-hills","thousandoaks","thousand-oaks","simivalley","simi-valley","simi","moorpark","camarillo","oxnard","porthueneme","port-hueneme","ventura","ojai","sfv","sfvalley","sf-valley","thevalley","the-valley","sanfernando","san-fernando","sanfernandovalley","san-fernando-valley","pacoima","sylmar","sunland","tujunga","sunlandtujunga","lakeviewterrace","lakeview-terrace","shadowhills","shadow-hills","chatsworth","northridge","granadahills","granada-hills","missionhills","mission-hills","panoramacity","panorama-city","arleta","sunvalley","sun-valley","santaclarita","santa-clarita","scv","valencia","newhall","saugus","canyoncountry","canyon-country","castaic","stevenson","stevensonranch","stevenson-ranch","acton","agua-dulce","aguadulce","palmdale","lancaster","antelopevalley","antelope-valley","av","avmesh","av-mesh","quartz-hill","quartzhill","littlerock","little-rock","pearblossom","pear-blossom","lakelosangeles","lake-los-angeles","highdesert","high-desert","hd","hdmesh","hd-mesh","victorville","hesperia","applevalley","apple-valley","barstow","adelanto","phelan","pinon-hills","pinonhills","wrightwood","bigbear","big-bear","lakeisabella","lake-isabella","inlandempire","inland-empire","ie","riverside","corona","moreno-valley","morenovalley","fontana","ontario","rancho","ranchocucamonga","rancho-cucamonga","upland","claremont","pomona","azusa","glendora","covina","westcovina","west-covina","diamondbar","diamond-bar","chino","chinohills","chino-hills","sanbernardinocity","rialto","colton","redlands","yuciapa","yucaipa","beaumont","banning","hemet","perris","menifee","temecula","murrieta","wildomar","lakeland","lakeelsinore","lake-elsinore","orangecounty","orange-county","oc","anaheim","fullerton","santaana","santa-ana","irvine","costamesa","costa-mesa","newportbeach","newport-beach","newport","huntingtonbeach","huntington-beach","hb","surfcity","surf-city","lagunabeach","laguna-beach","lagunaniguel","laguna-niguel","sanclemente","san-clemente","danapoint","dana-point","missionviejo","mission-viejo","lakeforest","lake-forest","rsm","ranchosantamargarita","rancho-santa-margarita","alisoviejo","aliso-viejo","tustin","orange","yorbalinda","yorba-linda","brea","lahabra","la-habra","placentia","buenapark","buena-park","cypress","losalamitojos","sealbeach","seal-beach","gardengrove","garden-grove","westminster","stanton","fountainvalley","sandiego","san-diego","sd","sdmesh","sd-mesh","lajolla","la-jolla","pacificbeach","pacific-beach","pb","missionbeach","mission-beach","oceanbeach","ocean-beach","ob","pointloma","point-loma","coronado","hillcrest","northpark","north-park","southpark","south-park","normalheights","normal-heights","cityheights","city-heights","lamesa","la-mesa","elcajon","el-cajon","santee","lakeside","poway","ramona","julian","alpine","escondido","sanmarcos","san-marcos","vista","oceanside","carlsbad","encinitas","delmar","del-mar","solanabeanch","solana-beach","chulavista","chula-vista","nationalcity","national-city","imperialbeach","imperial-beach","ib","southbay","south-bay","torrance","gardena","hawthorne","lawndale","redondo","redondobeach","hermosa","hermosabeach","manhattan","manhattanbeach","manhattan-beach","elsegundo","el-segundo","palosverdes","palos-verdes","pv","ranchopalosverdes","rancho-palos-verdes","sanpedro","san-pedro","wilmington","carson","compton","longbeach","long-beach","lb","signalhill","signal-hill","lakewood","cerritos","artesia","lamirada","la-mirada","norwalk","whittier","lahabra","la-habra-heights","downey","bellflower","paramount","southgate","south-gate","lynwood","bellgardens","bell-gardens","cudahy","huntingtonpark","maywood","vernon","commerce","montebello","picorivera","pico-rivera","montereypark","monterey-park","alhambra","sanmarinno","san-marino","arcadia","monrovia","duarte","azusa","irwindale","baldwinpark","baldwin-park","elmonbte","el-monte","southelmonte","south-el-monte","rosemead","temple-city","templecity","sangabriel","san-gabriel","santabarbara","santa-barbara","sb","goleta","carpinteria","montecito","islavista","isla-vista","iv","ucsb","slo","sanluisobispo","san-luis-obispo","morrobay","morro-bay","pismobeach","pismo-beach","pismo","shellbeach","shell-beach","arroyogrande","arroyo-grande","groverbeach","grover-beach","oceano","santamaria","santa-maria","lompoc","vandenberg","solvang","buellton","losalamos","los-alamos","atascadero","pasorobles","paso-robles","paso","cambria","cayucos","sansiemon","san-simeon","hearst","fresno","clovis","visalia","tulare","hanford","porterville","bakersfield","bako","delano","wasco","shafter","taft","tehachapi","stockton","tracy","manteca","lodi","modesto","turlock","merced","madera","chowchilla","losabnos","los-banos","sacramento","sac","sactown","westsacramento","west-sacramento","westsac","elkgrove","elk-grove","folsom","ranchocordova","rancho-cordova","roseville","rocklin","lincoln","citrus-heights","citrusheights","fair-oaks","fairoaks","carmichael","orangevale","davis","woodland","dixon","vacaville","fairfield","vallejo","bayarea","bay-area","sfbay","sf-bay","sanfrancisco","san-francisco","sf","sfmesh","sf-mesh","oakland","eastbay","east-bay","berkeley","emeryville","alameda","sanleandro","san-leandro","hayward","fremont","unioncity","union-city","newark","milpitas","sanjose","san-jose","sj","campbell","saratoga","losgartos","los-gatos","sunnyvale","santaclara","santa-clara","cupertino","mountainview","mountain-view","paloalto","palo-alto","menlopark","menlo-park","atherton","redwoodcity","redwood-city","sancarlos","san-carlos","belmont","sanmateo","san-mateo","fostercity","foster-city","burlingame","sanbruno","san-bruno","southsanfrancisco","ssf","dalycity","daly-city","pacifica","halfmoonbay","half-moon-bay","hmb","santacruz","santa-cruz","capitola","scottsvalley","scotts-valley","watsonville","aptos","soquel","concord","walnutcreek","walnut-creek","pleasant-hill","pleasanthill","martinez","antioch","pittsburg","brentwood","oakley","discovery-bay","livermore","pleasanton","dublin","sanramon","san-ramon","danville","richmond","sanpablo","san-pablo","pinole","hercules","napa","sonoma","petaluma","santarosa","santa-rosa","rohnertpark","novato","sanrafael","san-rafael","sausalito","tiburon","millvalley","mill-valley","redding","chico","oroville","paradise","reddingbluff","redbluff","red-bluff","shasta","mtshasta","mt-shasta","eureka","arcata","fortuna","mckibleyville","ukiah","fortbragg","fort-bragg","willits","yreka","weed","dunsmuir","tahoe","laketahoe","lake-tahoe","southlaketahoe","south-lake-tahoe","truckee","squaw","squawvalley","squaw-valley","northstar","mammoth","mammothlakes","mammoth-lakes","bishopca","bishop","placerville","tahoe-city","tahoecity","kings-beach","kingsbeach","incline","inclinevillage","incline-village","maricopa","pima","pinal","yavapai","yuma","mohave","coconino","cochise","navajo","apache","gila","santacruzaz","graham","lapaz","la-paz","greenlee","arizona","az","azmesh","az-mesh","phoenix","phx","phoenixmesh","phoenix-mesh","scottsdale","tempe","mesa","gilbert","chandler","glendale","peoria","surprize","avondale","goodyear","buckeye","litchfieldpark","litchfield-park","tolleson","laveen","paradisevalley","paradise-valley","pv","carefree","cavekreek","cave-creek","fountainhills","fountain-hills","rioverde","rio-verde","queencreek","queen-creek","santan","san-tan","santanvalley","ahwatukee","southmountain","south-mountain","anthem","newriver","new-river","apachejunction","apache-junction","aj","goldcanyon","gold-canyon","tucson","tucsomesh","tucson-mesh","orovalley","oro-valley","marana","catalina","catalinafoothills","saddlebrooke","casagrande","casa-grande","eloy","coolidge","florence","sierravista","sierra-vista","bisbee","tombstone","benson","douglas","nogales","tubac","greenvalley","green-valley","sahuarita","flagstaff","flag","flagmesh","sedona","cottonwood","clarkdale","prescott","prescottvalley","prescott-valley","dewey","chino-valley","chinovalley","williams","grandcanyon","grand-canyon","tusayan","page","marble-canyon","showlow","show-low","pinetop","pinetoplakeside","lakeside","snowflake","taylor","payson","pine","strawberry","camp-verde","campverde","winslow","holbrook","stjohns","springerville","eagar","yuma","yumamesh","fortuna-foothills","sanluisaz","san-luis","lakehavasu","lake-havasu","havasu","havasucity","lake-havasu-city","bullheadcity","bullhead-city","bullhead","laughlin","kingman","goldenkvalley","golden-valley","parker","quartzsite","wickenburg","lasvegas","las-vegas","vegas","vegasmesh","vegas-mesh","lv","henderson","boulder-city","bouldercity","northlasvegas","north-las-vegas","nlv","summerlin","enterprise","pahrump","mesquite","reno","sparks","carsoncity","carson-city","incline","bajacalifornia","baja-california","baja","bajamesh","tijuana","tj","mexicali","ensenada","tecate","rosarito","sanfelipe","san-felipe","sanluis","sanluisriocoalorado","brabant","flevoland","gelderland","noordbrabant","noordholland","zuid-holland","zuidholland","zeeland","twente","alkmaar","almere","amsterdam","amstelland","capelleaandenijssel","denhaag","dordrecht","drechtsteden","eindhoven","haarlem","hellevoetsluis","hilversum","katwijk","lelystad","maassluis","middelburg","rijnmond","rotterdam","tilburg","utrecht","vlissingen","voorburg","voorne-putten","walcheren","west-friesland","zaandam","zaanstreek-waterland","024-bot","afrithonbot","ai","amradio","analyser","angrynerds","bemesh","bot","buch","burgernet","chat","chatgpt","dares","dekroeg","dtis","emergency","english","evenvroegopstaan","fosdem","gezellig","gmr","gmrbot","goedemorgen","gyverbot","haagscourant","hackerspacenijmegen","hamradio","hamradionederland","hetweerinjegemeente","hsnl","jokes","kanalen","koffie","linux","meshcore","nerd","nl-alert","nl-prio","noodkanaal","nsagov","pi4hm","pi4utr","pingbot","sensemakers","sports","survival","test","testing","uitdagingen","valleibot","valleirug","vleesboek","wardrive","weer","swl","qso","qrz","cq","dx","sstv","aprs","winlink","aredn","hamnet","emcomm","emcommplanning","races","ares","auxcomm","simplex","repeater","uhf","vhf","2m","70cm","440"];new Set(H);const aa=k("8b3387e9c5cdea6ac9e5edbaa115cd72"),ea=["southbay","south-bay","bot","ventura","weather","wardrive","test","icewatch","sbcountymesh","sb-county-mesh","sbcounty","sb-county","meshbud","mesh-bud","ai-bot","aibot","hdmesh","hd-mesh","hdme","hdme7","hdme7yard","hdmeyard","hdmeshtayrd","hdmestayrd","hdmestyard","hdmetayrd","hdmeshtnyard","mustard","socalmesh","socal-mesh","meshla","mesh-la","lamesh","la-mesh","westcoast","west-coast","wcmesh","wc-mesh","eastcoast","east-coast","midwest","southwest","northwest","northeast","southeast","california","cali","santaclarita","santa-clarita","scv","newhall","valencia","saugus","castaic","palmdale","lancaster","antelopevalley","antelope-valley","avmesh","av-mesh","highdesert","high-desert","mojave","victorville","hesperia","barstow","pomona","claremont","glendora","azusa","covina","westcovina","west-covina","walnut","diamondbar","diamond-bar","whittier","brea","yorbalinda","yorba-linda","montebello","montereypark","monterey-park","alhambra","arcadia","monrovia","duarte","hermosabeach","hermosa-beach","manhattanbeach","manhattan-beach","redondobeach","redondo-beach","palosverdes","palos-verdes","sanpedro","san-pedro","ojai","fillmore","santapaula","santa-paula","porthueneme","port-hueneme","general","public","main","default","chat","local","mesh","network","emergency","sos","help","news","info","status","alerts","announce","random","offtopic","off-topic","lobby","lounge","hangout","testing","dev","development","beta","alpha","experimental","meshcore","mesh-core","meshtastic","lora","lo-ra","lorawan","lora-wan","radio","ham","amateur","hamradio","ham-radio","amateurradio","repeater","repeaters","gateway","node","nodes","rf","rfmesh","offgrid","off-grid","prepper","preppers","emcomm","ares","races","socal","so-cal","southerncalifornia","southern-california","losangeles","los-angeles","la","laarea","la-area","greaterla","sfv","sfvalley","sf-valley","sanfernandovalley","san-fernando-valley","sanfernando","san-fernando","valley","thevalley","the-valley","westla","west-la","eastla","east-la","southla","south-la","dtla","downtown","downtownla","downtown-la","hollywood","beverlyhills","beverly-hills","santamonica","santa-monica","culvercity","culver-city","marinadelrey","marina-del-rey","longbeach","long-beach","torrance","carson","compton","inglewood","pasadena","glendale","burbank","noho","northhollywood","north-hollywood","encino","tarzana","woodland","woodlandhills","woodland-hills","calabasas","malibu","topanga","agoura","agourahills","agoura-hills","thousandoaks","thousand-oaks","simivalley","simi-valley","simi","venturacounty","ventura-county","oxnard","camarillo","moorpark","santabarbara","santa-barbara","sb","goleta","carpinteria","orangecounty","orange-county","oc","irvine","anaheim","fullerton","costamesa","costa-mesa","newportbeach","newport-beach","huntingtonbeach","inlandempire","inland-empire","ie","riverside","sanbernardino","san-bernardino","ontario","rancho","ranchocucamonga","rancho-cucamonga","fontana","corona","palmsprings","palm-springs","palmdesert","palm-desert","coachella","temecula","murrieta","hemet","perris","menifee","sandiego","san-diego","sd","sdmesh","sd-mesh","norcal","nor-cal","northerncalifornia","northern-california","bayarea","bay-area","sfbay","sf-bay","sfbayarea","sf-bay-area","sanfrancisco","san-francisco","sf","sfmesh","sf-mesh","oakland","berkeley","eastbay","east-bay","alameda","sanjose","san-jose","sj","siliconvalley","silicon-valley","santaclara","santa-clara","sunnyvale","mountainview","mountain-view","paloalto","palo-alto","menlopark","menlo-park","redwoodcity","redwood-city","fremont","hayward","unioncity","union-city","newark","milpitas","santacruz","santa-cruz","watsonville","monterey","montereybay","monterey-bay","sacramento","sac","sactown","roseville","folsom","fresno","bakersfield","stockton","modesto","visalia","seattle","seattlemesh","seattle-mesh","pnw","pacificnorthwest","portland","pdx","portlandmesh","portland-mesh","oregon","denver","denvermesh","denver-mesh","colorado","boulder","austin","austinmesh","austin-mesh","atx","texas","sanantonio","san-antonio","dallas","dfw","dallasmesh","dallas-mesh","fortworth","fort-worth","houston","houstonmesh","houston-mesh","htx","phoenix","phoenixmesh","phoenix-mesh","arizona","az","tucson","mesa","tempe","lasvegas","las-vegas","vegas","vegasmesh","vegas-mesh","nevada","henderson","saltlake","salt-lake","slc","saltlakecity","salt-lake-city","utah","chicago","chicagomesh","chicago-mesh","illinois","detroit","detroitmesh","detroit-mesh","michigan","annarbor","minneapolis","twincities","twin-cities","minnesota","atlanta","atlantamesh","atlanta-mesh","atl","georgia","miami","miamimesh","miami-mesh","florida","tampa","orlando","jacksonville","boston","bostonmesh","boston-mesh","massachusetts","newyork","new-york","nyc","nycmesh","nyc-mesh","brooklyn","manhattan","queens","newjersey","new-jersey","nj","jersey","philly","philadelphia","pennsylvania","dc","washingtondc","washington-dc","dmv","nova","maryland","virginia","raleigh","durham","rdu","triangle","northcarolina","charlotte","clt","southcarolina","nashville","tennessee","memphis","knoxville","neworleans","new-orleans","nola","louisiana","hawaii","oahu","honolulu","maui","alaska","anchorage","fairbanks","canada","toronto","vancouver","montreal","calgary","edmonton","ottawa","uk","london","manchester","birmingham","edinburgh","glasgow","germany","berlin","munich","hamburg","frankfurt","france","paris","lyon","marseille","spain","madrid","barcelona","italy","rome","milan","netherlands","amsterdam","rotterdam","brabant","flevoland","gelderland","noordbrabant","noordholland","zuid-holland","zuidholland","zeeland","twente","alkmaar","almere","amstelland","capelleaandenijssel","denhaag","dordrecht","drechtsteden","eindhoven","haarlem","hellevoetsluis","hilversum","katwijk","lelystad","maassluis","middelburg","rijnmond","tilburg","utrecht","vlissingen","voorburg","voorne-putten","walcheren","west-friesland","zaandam","zaanstreek-waterland","024-bot","afrithonbot","ai","amradio","analyser","angrynerds","bemesh","buch","burgernet","chatgpt","dares","dekroeg","dtis","english","evenvroegopstaan","fosdem","gezellig","gmr","gmrbot","goedemorgen","gyverbot","haagscourant","hackerspacenijmegen","hamradionederland","hetweerinjegemeente","hsnl","jokes","kanalen","koffie","linux","nerd","nl-alert","nl-prio","noodkanaal","nsagov","pi4hm","pi4utr","pingbot","sensemakers","sports","survival","uitdagingen","valleibot","valleirug","vleesboek","wardrive","weer","australia","sydney","melbourne","brisbane","perth","adelaide","newzealand","new-zealand","auckland","wellington","japan","tokyo","osaka","kyoto","korea","seoul","taiwan","taipei","singapore","hongkong","hong-kong","india","mumbai","delhi","bangalore","brazil","saopaulo","sao-paulo","rio","mexico","mexicocity","mexico-city","guadalajara","tijuana"];function na(a){let e=a.startsWith("#")?a.slice(1):a;return e=e.toLowerCase().replace(/[^a-z0-9-]/g,""),e=e.replace(/-+/g,"-"),e=e.replace(/^-+|-+$/g,""),e}const u=new Map;let q=!1;const _=new Map;function T(a){const e=_.get(a)??0;_.set(a,e+1)}function D(a){return _.get(a)??0}async function L(a){const e=na(a),n="#"+e,o=new TextEncoder,t=(await S(o.encode(n))).slice(0,16),i=(await S(t))[0],r=new Uint8Array(32);return r.set(t),{name:"#"+e,channelHash:i,aesKey:t,hmacKey:r}}async function oa(){if(q)return;const a=aa,n=(await S(a))[0],o=new Uint8Array(32);o.set(a);const s={name:"Public",channelHash:n,aesKey:a.slice(0,16),hmacKey:o};u.has(s.channelHash)||u.set(s.channelHash,[]),u.get(s.channelHash).push(s);for(const i of ea)try{const r=await L(i);u.has(r.channelHash)||u.set(r.channelHash,[]),u.get(r.channelHash).push(r)}catch{}for(const i of H)try{const r=await L(i);u.has(r.channelHash)||u.set(r.channelHash,[]);const h=u.get(r.channelHash);h.some(c=>c.name===r.name)||h.push(r)}catch{}q=!0;let t=0,l=0;for(const i of u.values())t+=i.length,l=Math.max(l,i.length);console.log(`[DecryptWorker] Cache initialized: ${t} channels, ${u.size} unique hashes, max ${l} collisions`)}function sa(a){const e=u.get(a);return!e||e.length<=1?e??[]:[...e].sort((n,o)=>D(o.name)-D(n.name))}function F(a){if(!a||a.length<4)return null;const n=parseInt(a.slice(0,2),16)&3;let o=2;(n===0||n===3)&&(o=10);const s=parseInt(a.slice(o,o+2),16);o+=2,o+=s*2;const t=a.slice(o);return t.length<8?null:k(t)}async function R(a,e,n){const o=await X(a.hmacKey,n);return e[0]===o[0]&&e[1]===o[1]}function N(a){if(a.length<6)return{valid:!1,confidence:"low"};const e=a[0]|a[1]<<8|a[2]<<16|a[3]<<24,o=new Date(e*1e3).getFullYear(),s=o>=2024&&o<=2030;if(!s)return{valid:!1,confidence:"low"};const t=a.slice(5);if(t.length===0)return{valid:!1,confidence:"low"};let l=0,i=!1;for(let h=0;h=32&&c<=126||c===0||c===10||c===13||c===9)&&l++,c===58&&(i=!0)}const r=l/t.length;return r>=.85&&i&&s?{valid:!0,confidence:"high"}:r>=.7&&s?{valid:!0,confidence:"medium"}:{valid:!1,confidence:"low"}}async function ta(a,e,n){const o=sa(a),s=[];for(const l of o){if(await R(l,e,n)){T(l.name);const r=j(l.aesKey,n);return{keys:l,plaintext:r}}s.push(l)}let t=null;for(const l of s)try{const i=j(l.aesKey,n),r=N(i);if(r.valid){if(r.confidence==="high")return T(l.name),{keys:l,plaintext:i,macCorrupted:!0};r.confidence==="medium"&&!t&&(t={keys:l,plaintext:i,confidence:"medium"})}}catch{}return t?(T(t.keys.name),{keys:t.keys,plaintext:t.plaintext,macCorrupted:!0}):null}async function la(a,e){const n={packetHash:a.packet_hash,success:!1,channelHash:"",packetTimestamp:a.timestamp,rssi:a.rssi,snr:a.snr};if((a.type??a.payload_type)!==5)return n;const s=F(a.raw_packet);if(!s||s.length<4)return n;const t=s[0],l=s.slice(1,3),i=s.slice(3);if(n.channelHash=E(t,!0),t!==e.channelHash)return n;const r={name:e.name,channelHash:e.channelHash,aesKey:k(e.aesKeyHex),hmacKey:k(e.hmacKeyHex)},h=await R(r,l,i);let c,y=!1;if(h)c=j(r.aesKey,i);else try{c=j(r.aesKey,i);const C=N(c);if(!C.valid||C.confidence==="low")return n;y=!0}catch{return n}if(c.length<5)return n;const w=M(c,0),f=c[4],m=new TextDecoder("utf-8",{fatal:!1}).decode(c.slice(5)).replace(/\uFFFD/g,"").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F]/g,"").replace(/\x00+$/,"").trim();n.success=!0,n.channelName=r.name,n.timestamp=w,n.flags=f,n.macCorrupted=y;const p=m.indexOf(": ");return p>0?(n.senderName=m.slice(0,p),n.text=m.slice(p+2)):n.text=m,n}async function ra(a){const e={packetHash:a.packet_hash,success:!1,channelHash:"",packetTimestamp:a.timestamp,rssi:a.rssi,snr:a.snr};if((a.type??a.payload_type)!==5)return e;const o=F(a.raw_packet);if(!o||o.length<4)return e;const s=o[0],t=o.slice(1,3),l=o.slice(3);e.channelHash=E(s,!0);const i=await ta(s,t,l);if(!i)return e;const{keys:r,plaintext:h,macCorrupted:c}=i;if(h.length<5)return e;const y=M(h,0),w=h[4],b=new TextDecoder("utf-8",{fatal:!1}).decode(h.slice(5)).replace(/\uFFFD/g,"").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F]/g,"").replace(/\x00+$/,"").trim();e.success=!0,e.channelName=r.name,e.timestamp=y,e.flags=w,e.macCorrupted=c;const m=b.indexOf(": ");return m>0?(e.senderName=b.slice(0,m),e.text=b.slice(m+2)):e.text=b,e}let A=!1,v=null;function ia(){return A?new Promise(a=>{v=a}):Promise.resolve()}const I=32,ca=100;self.onmessage=async a=>{const e=a.data;switch(e.type){case"decrypt":{const n=performance.now();e.knownKey||await oa();const o=e.packets,s=e.knownKey;let t=0,l=0,i=0,r=[];const h=()=>{r.length>0&&(self.postMessage({type:"results",results:r}),r=[])};for(let y=0;ys?la(p,s):ra(p)));for(const p of b)p.success&&(t++,r.push(p),r.length>=ca&&h());l+=f.length;const m=performance.now();m-i>100&&(self.postMessage({type:"progress",processed:l,total:o.length}),i=m)}h();const c=performance.now()-n;self.postMessage({type:"batchComplete",successCount:t,totalCount:o.length,computeTimeMs:c});break}case"pause":A=!0;break;case"resume":A=!1,v&&(v(),v=null);break;case"stop":A=!1,v&&(v(),v=null);break}},self.postMessage({type:"ready"})})(); diff --git a/frontend/dist/assets/download-IUkhheKK.js b/frontend/dist/assets/download-BbqYTv8j.js similarity index 89% rename from frontend/dist/assets/download-IUkhheKK.js rename to frontend/dist/assets/download-BbqYTv8j.js index 78eff74a..2b76df57 100644 --- a/frontend/dist/assets/download-IUkhheKK.js +++ b/frontend/dist/assets/download-BbqYTv8j.js @@ -1,4 +1,4 @@ -import{d as o}from"./index-C8IY8K2r.js";/** +import{d as o}from"./index-BwGHI0A_.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/easing-CXN4GmUW.js b/frontend/dist/assets/easing-DSebI9nw.js similarity index 90% rename from frontend/dist/assets/easing-CXN4GmUW.js rename to frontend/dist/assets/easing-DSebI9nw.js index 31145294..b907b472 100644 --- a/frontend/dist/assets/easing-CXN4GmUW.js +++ b/frontend/dist/assets/easing-DSebI9nw.js @@ -1,4 +1,4 @@ -import{d as s,fo as a}from"./index-C8IY8K2r.js";/** +import{d as s,fv as a}from"./index-BwGHI0A_.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/element-movement-D4o83B2Z.js b/frontend/dist/assets/element-movement-BqZOD4DT.js similarity index 67% rename from frontend/dist/assets/element-movement-D4o83B2Z.js rename to frontend/dist/assets/element-movement-BqZOD4DT.js index 9c2c7091..4962f0d7 100644 --- a/frontend/dist/assets/element-movement-D4o83B2Z.js +++ b/frontend/dist/assets/element-movement-BqZOD4DT.js @@ -1 +1 @@ -import{r as o,aj as v,cm as h,dY as b,dZ as w,cD as x,aX as c,a_ as R}from"./index-C8IY8K2r.js";function y(e,t){return e!==null&&t!==null&&typeof e=="object"&&typeof t=="object"&&"id"in e&&"id"in t?e.id===t.id:e===t}function j(e=y){return o.useCallback((t,r)=>{if(typeof e=="string"){let u=e;return(t==null?void 0:t[u])===(r==null?void 0:r[u])}return e(t,r)},[e])}var $=(e=>(e[e.Left=0]="Left",e[e.Right=2]="Right",e))($||{});function N(e){let t=o.useRef(null),r=v(l=>{t.current=l.pointerType,!h(l.currentTarget)&&l.pointerType==="mouse"&&l.button===$.Left&&(l.preventDefault(),e(l))}),u=v(l=>{t.current!=="mouse"&&(h(l.currentTarget)||e(l))});return{onPointerDown:r,onClick:u}}var S=(e=>(e[e.Ignore=0]="Ignore",e[e.Select=1]="Select",e[e.Close=2]="Close",e))(S||{});const z={Ignore:{kind:0},Select:e=>({kind:1,target:e}),Close:{kind:2}},I=200,k=5;function F(e,{trigger:t,action:r,close:u,select:l}){let n=o.useRef(null),i=o.useRef(null),a=o.useRef(null);b(e&&t!==null,"pointerdown",s=>{w(s==null?void 0:s.target)&&t!=null&&t.contains(s.target)&&(i.current=s.x,a.current=s.y,n.current=s.timeStamp)}),b(e&&t!==null,"pointerup",s=>{var d,f;let g=n.current;if(g===null||(n.current=null,!x(s.target))||Math.abs(s.x-((d=i.current)!=null?d:s.x))I&&(l(p.target),u());break}case 2:{u();break}}},{capture:!0})}function m(e){return[e.screenX,e.screenY]}function P(){let e=o.useRef([-1,-1]);return{wasMoved(t){let r=m(t);return e.current[0]===r[0]&&e.current[1]===r[1]?!1:(e.current=r,!0)},update(t){e.current=m(t)}}}function L({children:e,freeze:t},r){let u=D(t,e);return o.isValidElement(u)?o.cloneElement(u,{ref:r}):c.createElement(c.Fragment,null,u)}const X=c.forwardRef(L);function D(e,t){let[r,u]=o.useState(t);return!e&&r!==t&&u(t),e?r:t}function E(e){throw new Error("Unexpected object: "+e)}var T=(e=>(e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing",e))(T||{});function Y(e,t){let r=t.resolveItems();if(r.length<=0)return null;let u=t.resolveActiveIndex(),l=u??-1;switch(e.focus){case 0:{for(let n=0;n=0;--n)if(!t.resolveDisabled(r[n],n,r))return n;return u}case 2:{for(let n=l+1;n=0;--n)if(!t.resolveDisabled(r[n],n,r))return n;return u}case 4:{for(let n=0;n({kind:"Tracked",position:e}),Moved:{kind:"Moved"}};function C(e){let t=e.getBoundingClientRect();return`${t.x},${t.y}`}function B(e,t,r){let u=R();if(t.kind==="Tracked"){let l=function(){n!==C(e)&&(u.dispose(),r())},{position:n}=t,i=new ResizeObserver(l);i.observe(e),u.add(()=>i.disconnect()),u.addEventListener(window,"scroll",l,{passive:!0}),u.addEventListener(window,"resize",l)}return()=>u.dispose()}export{F as L,z as S,A as a,C as b,T as c,X as d,P as e,Y as f,$ as g,j as h,B as p,N as s,D as u}; +import{r as o,aj as v,cp as h,e1 as b,e2 as w,cG as x,aX as c,a_ as R}from"./index-BwGHI0A_.js";function y(e,t){return e!==null&&t!==null&&typeof e=="object"&&typeof t=="object"&&"id"in e&&"id"in t?e.id===t.id:e===t}function j(e=y){return o.useCallback((t,r)=>{if(typeof e=="string"){let u=e;return(t==null?void 0:t[u])===(r==null?void 0:r[u])}return e(t,r)},[e])}var $=(e=>(e[e.Left=0]="Left",e[e.Right=2]="Right",e))($||{});function N(e){let t=o.useRef(null),r=v(l=>{t.current=l.pointerType,!h(l.currentTarget)&&l.pointerType==="mouse"&&l.button===$.Left&&(l.preventDefault(),e(l))}),u=v(l=>{t.current!=="mouse"&&(h(l.currentTarget)||e(l))});return{onPointerDown:r,onClick:u}}var S=(e=>(e[e.Ignore=0]="Ignore",e[e.Select=1]="Select",e[e.Close=2]="Close",e))(S||{});const z={Ignore:{kind:0},Select:e=>({kind:1,target:e}),Close:{kind:2}},I=200,k=5;function F(e,{trigger:t,action:r,close:u,select:l}){let n=o.useRef(null),i=o.useRef(null),a=o.useRef(null);b(e&&t!==null,"pointerdown",s=>{w(s==null?void 0:s.target)&&t!=null&&t.contains(s.target)&&(i.current=s.x,a.current=s.y,n.current=s.timeStamp)}),b(e&&t!==null,"pointerup",s=>{var d,f;let p=n.current;if(p===null||(n.current=null,!x(s.target))||Math.abs(s.x-((d=i.current)!=null?d:s.x))I&&(l(g.target),u());break}case 2:{u();break}}},{capture:!0})}function m(e){return[e.screenX,e.screenY]}function P(){let e=o.useRef([-1,-1]);return{wasMoved(t){let r=m(t);return e.current[0]===r[0]&&e.current[1]===r[1]?!1:(e.current=r,!0)},update(t){e.current=m(t)}}}function L({children:e,freeze:t},r){let u=E(t,e);return o.isValidElement(u)?o.cloneElement(u,{ref:r}):c.createElement(c.Fragment,null,u)}const X=c.forwardRef(L);function E(e,t){let[r,u]=o.useState(t);return!e&&r!==t&&u(t),e?r:t}function T(e){throw new Error("Unexpected object: "+e)}var C=(e=>(e[e.First=0]="First",e[e.Previous=1]="Previous",e[e.Next=2]="Next",e[e.Last=3]="Last",e[e.Specific=4]="Specific",e[e.Nothing=5]="Nothing",e))(C||{});function A(e,t){let r=t.resolveItems();if(r.length<=0)return null;let u=t.resolveActiveIndex(),l=u??-1;switch(e.focus){case 0:{for(let n=0;n=0;--n)if(!t.resolveDisabled(r[n],n,r))return n;return u}case 2:{for(let n=l+1;n=0;--n)if(!t.resolveDisabled(r[n],n,r))return n;return u}case 4:{for(let n=0;n({kind:"Tracked",position:e}),Moved:{kind:"Moved"}};function D(e){let t=e.getBoundingClientRect();return`${t.x},${t.y}`}function G(e,t,r){let u=R();if(t.kind==="Tracked"){let l=function(){n!==D(e)&&(u.dispose(),r())},{position:n}=t,i=new ResizeObserver(l);i.observe(e),u.add(()=>i.disconnect()),u.addEventListener(window,"scroll",l,{passive:!0}),u.addEventListener(window,"resize",l)}return()=>u.dispose()}export{F as L,z as S,B as a,D as b,C as c,X as d,P as e,A as f,$ as g,j as h,G as p,N as s,E as u}; diff --git a/frontend/dist/assets/funnel-BDRRJl0y.js b/frontend/dist/assets/funnel-D4Wxq-Fx.js similarity index 89% rename from frontend/dist/assets/funnel-BDRRJl0y.js rename to frontend/dist/assets/funnel-D4Wxq-Fx.js index 5effea25..30bbc350 100644 --- a/frontend/dist/assets/funnel-BDRRJl0y.js +++ b/frontend/dist/assets/funnel-D4Wxq-Fx.js @@ -1,4 +1,4 @@ -import{d as e}from"./index-C8IY8K2r.js";/** +import{d as e}from"./index-BwGHI0A_.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/geo-utils-BP1zBK9h.js b/frontend/dist/assets/geo-utils-BP1zBK9h.js deleted file mode 100644 index c7e63ac1..00000000 --- a/frontend/dist/assets/geo-utils-BP1zBK9h.js +++ /dev/null @@ -1 +0,0 @@ -const i={VERY_CLOSE:500,CLOSE:2e3,MEDIUM:5e3,FAR:1e4,VERY_FAR:2e4};function r(t,a,s,h){const n=(s-t)*Math.PI/180,c=(h-a)*Math.PI/180,M=Math.sin(n/2)*Math.sin(n/2)+Math.cos(t*Math.PI/180)*Math.cos(s*Math.PI/180)*Math.sin(c/2)*Math.sin(c/2);return 6371e3*(2*Math.atan2(Math.sqrt(M),Math.sqrt(1-M)))}function I(t,a){return t!==void 0&&a!==void 0&&(t!==0||a!==0)}export{i as P,r as c,I as h}; diff --git a/frontend/dist/assets/hash-BkZp0AKy.js b/frontend/dist/assets/hash-9uwO8S8N.js similarity index 90% rename from frontend/dist/assets/hash-BkZp0AKy.js rename to frontend/dist/assets/hash-9uwO8S8N.js index 5b0cf7c8..a0741811 100644 --- a/frontend/dist/assets/hash-BkZp0AKy.js +++ b/frontend/dist/assets/hash-9uwO8S8N.js @@ -1,4 +1,4 @@ -import{d as e}from"./index-C8IY8K2r.js";/** +import{d as e}from"./index-BwGHI0A_.js";/** * @license lucide-react v0.559.0 - ISC * * This source code is licensed under the ISC license. diff --git a/frontend/dist/assets/index-BwGHI0A_.js b/frontend/dist/assets/index-BwGHI0A_.js new file mode 100644 index 00000000..764f9b33 --- /dev/null +++ b/frontend/dist/assets/index-BwGHI0A_.js @@ -0,0 +1,266 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Login-DH5OEqBN.js","assets/ascii-burst-DN6etEs5.js","assets/Dashboard-Da3hQ53f.js","assets/PageLayout-BIcqC04y.js","assets/consumer-registry-DPYvsBcc.js","assets/AnimatedNumber-BAXz0cmM.js","assets/index-OH01SZkk.js","assets/node-types-DmTOZWT4.js","assets/meshcore-tx-constants-DgpFTAmf.js","assets/PacketList-CnGGHFuk.js","assets/primitives-Cgn8YJud.js","assets/payload-decoders-7zyi-Y-D.js","assets/badge-colors-BNUqIXCA.js","assets/chat-utils-Di4-nywi.js","assets/SignalIndicator-LNOR_5YF.js","assets/arrow-up-DJuSVUZI.js","assets/chevron-right-DqpRZiGf.js","assets/map-pin-VRY_TOuh.js","assets/circle-question-mark-DC7QfrVK.js","assets/triangle-alert-B4kC1YDk.js","assets/DataBox-CQS-Zhu0.js","assets/layers-C8ICjJ-w.js","assets/hash-9uwO8S8N.js","assets/activity-Dr_TPIps.js","assets/circle-check-CBI-CiRo.js","assets/database-CDN_R6oC.js","assets/useMapViewStore-CPURakCb.js","assets/shield-DOTPcYJ1.js","assets/TimeRangeStepper-Dh4JEQ42.js","assets/usePipelineStore-11oXtutw.js","assets/LightSparkline-5OIe9Q0M.js","assets/link-scoring-BSZA-fkH.js","assets/NodeInformationCard-BLxCCOW5.js","assets/ChatBubble-Bxq40Qnq.js","assets/Grid-BoZ-SJB7.js","assets/Packets-aeMTl269.js","assets/element-movement-BqZOD4DT.js","assets/AnalyzerFilterPanel-BIfh-GdY.js","assets/funnel-D4Wxq-Fx.js","assets/monitor-smartphone-BxljwdQV.js","assets/search-B7iMjmGm.js","assets/Contacts-CcwYnw5c.js","assets/ping-DW5e4gor.js","assets/listbox-_tsR-2yL.js","assets/CollisionExplorerModal-Cm5c7tcU.js","assets/BasemapLayer-Bm_seLWQ.js","assets/target-LdPtzGwl.js","assets/network-9doWJxcL.js","assets/ConfirmModal-B0nTD1Q0.js","assets/BasemapLayer-B1CfjdFi.css","assets/Statistics-BV-givjs.js","assets/easing-DSebI9nw.js","assets/settings-2-B_NiASQG.js","assets/MeshGraph-CElh2Drl.js","assets/DeepAnalysisModal-CaP_TRSd.js","assets/download-BbqYTv8j.js","assets/System-Dl7BjZT4.js","assets/refresh-cw-DYpAqCT4.js","assets/Logs-COCuHgwW.js","assets/Terminal-Bs4pn1qU.js","assets/system-oD9MKxRy.js","assets/KeycapButton-CT5jwzf3.js","assets/keycap-sfx-ByZp-njj.js","assets/Terminal-6GBZ9nXN.css","assets/Configuration-eqZcR8dI.js","assets/antenna-zVXb9cuG.js","assets/plus-C0xom_iW.js","assets/key-round-DKeM0xKx.js","assets/RoomServer-BJlrNokH.js","assets/wifi-BaASFkdf.js","assets/PacketObservatory-CaTxuw1q.js","assets/Sessions-BctisK9q.js"])))=>i.map(i=>d[i]); +var I6=Object.defineProperty;var O6=(e,t,n)=>t in e?I6(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Te=(e,t,n)=>O6(e,typeof t!="symbol"?t+"":t,n);function $6(e,t){for(var n=0;nr[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();function z6(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var um={exports:{}},bc={},dm={exports:{}},Ye={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var lb;function V6(){if(lb)return Ye;lb=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),m=Symbol.iterator;function g(_){return _===null||typeof _!="object"?null:(_=m&&_[m]||_["@@iterator"],typeof _=="function"?_:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,w={};function x(_,G,K){this.props=_,this.context=G,this.refs=w,this.updater=K||b}x.prototype.isReactComponent={},x.prototype.setState=function(_,G){if(typeof _!="object"&&typeof _!="function"&&_!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,_,G,"setState")},x.prototype.forceUpdate=function(_){this.updater.enqueueForceUpdate(this,_,"forceUpdate")};function D(){}D.prototype=x.prototype;function S(_,G,K){this.props=_,this.context=G,this.refs=w,this.updater=K||b}var F=S.prototype=new D;F.constructor=S,C(F,x.prototype),F.isPureReactComponent=!0;var P=Array.isArray,M=Object.prototype.hasOwnProperty,L={current:null},O={key:!0,ref:!0,__self:!0,__source:!0};function I(_,G,K){var me,de={},be=null,ue=null;if(G!=null)for(me in G.ref!==void 0&&(ue=G.ref),G.key!==void 0&&(be=""+G.key),G)M.call(G,me)&&!O.hasOwnProperty(me)&&(de[me]=G[me]);var ke=arguments.length-2;if(ke===1)de.children=K;else if(1>>1,G=Q[_];if(0>>1;_s(de,ne))bes(ue,de)?(Q[_]=ue,Q[be]=ne,_=be):(Q[_]=de,Q[me]=ne,_=me);else if(bes(ue,ne))Q[_]=ue,Q[be]=ne,_=be;else break e}}return ie}function s(Q,ie){var ne=Q.sortIndex-ie.sortIndex;return ne!==0?ne:Q.id-ie.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var l=Date,c=l.now();e.unstable_now=function(){return l.now()-c}}var d=[],f=[],h=1,m=null,g=3,b=!1,C=!1,w=!1,x=typeof setTimeout=="function"?setTimeout:null,D=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function F(Q){for(var ie=n(f);ie!==null;){if(ie.callback===null)r(f);else if(ie.startTime<=Q)r(f),ie.sortIndex=ie.expirationTime,t(d,ie);else break;ie=n(f)}}function P(Q){if(w=!1,F(Q),!C)if(n(d)!==null)C=!0,ae(M);else{var ie=n(f);ie!==null&&re(P,ie.startTime-Q)}}function M(Q,ie){C=!1,w&&(w=!1,D(I),I=-1),b=!0;var ne=g;try{for(F(ie),m=n(d);m!==null&&(!(m.expirationTime>ie)||Q&&!j());){var _=m.callback;if(typeof _=="function"){m.callback=null,g=m.priorityLevel;var G=_(m.expirationTime<=ie);ie=e.unstable_now(),typeof G=="function"?m.callback=G:m===n(d)&&r(d),F(ie)}else r(d);m=n(d)}if(m!==null)var K=!0;else{var me=n(f);me!==null&&re(P,me.startTime-ie),K=!1}return K}finally{m=null,g=ne,b=!1}}var L=!1,O=null,I=-1,V=5,U=-1;function j(){return!(e.unstable_now()-UQ||125_?(Q.sortIndex=ne,t(f,Q),n(d)===null&&Q===n(f)&&(w?(D(I),I=-1):w=!0,re(P,ne-_))):(Q.sortIndex=G,t(d,Q),C||b||(C=!0,ae(M))),Q},e.unstable_shouldYield=j,e.unstable_wrapCallback=function(Q){var ie=g;return function(){var ne=g;g=ie;try{return Q.apply(this,arguments)}finally{g=ne}}}})(pm)),pm}var pb;function q6(){return pb||(pb=1,hm.exports=W6()),hm.exports}/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var mb;function G6(){if(mb)return br;mb=1;var e=uh(),t=q6();function n(o){for(var a="https://reactjs.org/docs/error-decoder.html?invariant="+o,u=1;u"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),d=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,h={},m={};function g(o){return d.call(m,o)?!0:d.call(h,o)?!1:f.test(o)?m[o]=!0:(h[o]=!0,!1)}function b(o,a,u,p){if(u!==null&&u.type===0)return!1;switch(typeof a){case"function":case"symbol":return!0;case"boolean":return p?!1:u!==null?!u.acceptsBooleans:(o=o.toLowerCase().slice(0,5),o!=="data-"&&o!=="aria-");default:return!1}}function C(o,a,u,p){if(a===null||typeof a>"u"||b(o,a,u,p))return!0;if(p)return!1;if(u!==null)switch(u.type){case 3:return!a;case 4:return a===!1;case 5:return isNaN(a);case 6:return isNaN(a)||1>a}return!1}function w(o,a,u,p,y,E,B){this.acceptsBooleans=a===2||a===3||a===4,this.attributeName=p,this.attributeNamespace=y,this.mustUseProperty=u,this.propertyName=o,this.type=a,this.sanitizeURL=E,this.removeEmptyString=B}var x={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(o){x[o]=new w(o,0,!1,o,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(o){var a=o[0];x[a]=new w(a,1,!1,o[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(o){x[o]=new w(o,2,!1,o.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(o){x[o]=new w(o,2,!1,o,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(o){x[o]=new w(o,3,!1,o.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(o){x[o]=new w(o,3,!0,o,null,!1,!1)}),["capture","download"].forEach(function(o){x[o]=new w(o,4,!1,o,null,!1,!1)}),["cols","rows","size","span"].forEach(function(o){x[o]=new w(o,6,!1,o,null,!1,!1)}),["rowSpan","start"].forEach(function(o){x[o]=new w(o,5,!1,o.toLowerCase(),null,!1,!1)});var D=/[\-:]([a-z])/g;function S(o){return o[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(o){var a=o.replace(D,S);x[a]=new w(a,1,!1,o,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(o){var a=o.replace(D,S);x[a]=new w(a,1,!1,o,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(o){var a=o.replace(D,S);x[a]=new w(a,1,!1,o,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(o){x[o]=new w(o,1,!1,o.toLowerCase(),null,!1,!1)}),x.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(o){x[o]=new w(o,1,!1,o.toLowerCase(),null,!0,!0)});function F(o,a,u,p){var y=x.hasOwnProperty(a)?x[a]:null;(y!==null?y.type!==0:p||!(2z||y[B]!==E[z]){var W=` +`+y[B].replace(" at new "," at ");return o.displayName&&W.includes("")&&(W=W.replace("",o.displayName)),W}while(1<=B&&0<=z);break}}}finally{K=!1,Error.prepareStackTrace=u}return(o=o?o.displayName||o.name:"")?G(o):""}function de(o){switch(o.tag){case 5:return G(o.type);case 16:return G("Lazy");case 13:return G("Suspense");case 19:return G("SuspenseList");case 0:case 2:case 15:return o=me(o.type,!1),o;case 11:return o=me(o.type.render,!1),o;case 1:return o=me(o.type,!0),o;default:return""}}function be(o){if(o==null)return null;if(typeof o=="function")return o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case O:return"Fragment";case L:return"Portal";case V:return"Profiler";case I:return"StrictMode";case $:return"Suspense";case H:return"SuspenseList"}if(typeof o=="object")switch(o.$$typeof){case j:return(o.displayName||"Context")+".Consumer";case U:return(o._context.displayName||"Context")+".Provider";case X:var a=o.render;return o=o.displayName,o||(o=a.displayName||a.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case oe:return a=o.displayName||null,a!==null?a:be(o.type)||"Memo";case ae:a=o._payload,o=o._init;try{return be(o(a))}catch{}}return null}function ue(o){var a=o.type;switch(o.tag){case 24:return"Cache";case 9:return(a.displayName||"Context")+".Consumer";case 10:return(a._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return o=a.render,o=o.displayName||o.name||"",a.displayName||(o!==""?"ForwardRef("+o+")":"ForwardRef");case 7:return"Fragment";case 5:return a;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return be(a);case 8:return a===I?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a}return null}function ke(o){switch(typeof o){case"boolean":case"number":case"string":case"undefined":return o;case"object":return o;default:return""}}function Pe(o){var a=o.type;return(o=o.nodeName)&&o.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function je(o){var a=Pe(o)?"checked":"value",u=Object.getOwnPropertyDescriptor(o.constructor.prototype,a),p=""+o[a];if(!o.hasOwnProperty(a)&&typeof u<"u"&&typeof u.get=="function"&&typeof u.set=="function"){var y=u.get,E=u.set;return Object.defineProperty(o,a,{configurable:!0,get:function(){return y.call(this)},set:function(B){p=""+B,E.call(this,B)}}),Object.defineProperty(o,a,{enumerable:u.enumerable}),{getValue:function(){return p},setValue:function(B){p=""+B},stopTracking:function(){o._valueTracker=null,delete o[a]}}}}function tt(o){o._valueTracker||(o._valueTracker=je(o))}function Lt(o){if(!o)return!1;var a=o._valueTracker;if(!a)return!0;var u=a.getValue(),p="";return o&&(p=Pe(o)?o.checked?"true":"false":o.value),o=p,o!==u?(a.setValue(o),!0):!1}function Ee(o){if(o=o||(typeof document<"u"?document:void 0),typeof o>"u")return null;try{return o.activeElement||o.body}catch{return o.body}}function He(o,a){var u=a.checked;return ne({},a,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:u??o._wrapperState.initialChecked})}function Xe(o,a){var u=a.defaultValue==null?"":a.defaultValue,p=a.checked!=null?a.checked:a.defaultChecked;u=ke(a.value!=null?a.value:u),o._wrapperState={initialChecked:p,initialValue:u,controlled:a.type==="checkbox"||a.type==="radio"?a.checked!=null:a.value!=null}}function Ie(o,a){a=a.checked,a!=null&&F(o,"checked",a,!1)}function et(o,a){Ie(o,a);var u=ke(a.value),p=a.type;if(u!=null)p==="number"?(u===0&&o.value===""||o.value!=u)&&(o.value=""+u):o.value!==""+u&&(o.value=""+u);else if(p==="submit"||p==="reset"){o.removeAttribute("value");return}a.hasOwnProperty("value")?St(o,a.type,u):a.hasOwnProperty("defaultValue")&&St(o,a.type,ke(a.defaultValue)),a.checked==null&&a.defaultChecked!=null&&(o.defaultChecked=!!a.defaultChecked)}function gt(o,a,u){if(a.hasOwnProperty("value")||a.hasOwnProperty("defaultValue")){var p=a.type;if(!(p!=="submit"&&p!=="reset"||a.value!==void 0&&a.value!==null))return;a=""+o._wrapperState.initialValue,u||a===o.value||(o.value=a),o.defaultValue=a}u=o.name,u!==""&&(o.name=""),o.defaultChecked=!!o._wrapperState.initialChecked,u!==""&&(o.name=u)}function St(o,a,u){(a!=="number"||Ee(o.ownerDocument)!==o)&&(u==null?o.defaultValue=""+o._wrapperState.initialValue:o.defaultValue!==""+u&&(o.defaultValue=""+u))}var dt=Array.isArray;function Fn(o,a,u,p){if(o=o.options,a){a={};for(var y=0;y"+a.valueOf().toString()+"",a=lo.firstChild;o.firstChild;)o.removeChild(o.firstChild);for(;a.firstChild;)o.appendChild(a.firstChild)}});function Bn(o,a){if(a){var u=o.firstChild;if(u&&u===o.lastChild&&u.nodeType===3){u.nodeValue=a;return}}o.textContent=a}var xr={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},$n=["Webkit","ms","Moz","O"];Object.keys(xr).forEach(function(o){$n.forEach(function(a){a=a+o.charAt(0).toUpperCase()+o.substring(1),xr[a]=xr[o]})});function zn(o,a,u){return a==null||typeof a=="boolean"||a===""?"":u||typeof a!="number"||a===0||xr.hasOwnProperty(o)&&xr[o]?(""+a).trim():a+"px"}function kn(o,a){o=o.style;for(var u in a)if(a.hasOwnProperty(u)){var p=u.indexOf("--")===0,y=zn(u,a[u],p);u==="float"&&(u="cssFloat"),p?o.setProperty(u,y):o[u]=y}}var Ar=ne({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ca(o,a){if(a){if(Ar[o]&&(a.children!=null||a.dangerouslySetInnerHTML!=null))throw Error(n(137,o));if(a.dangerouslySetInnerHTML!=null){if(a.children!=null)throw Error(n(60));if(typeof a.dangerouslySetInnerHTML!="object"||!("__html"in a.dangerouslySetInnerHTML))throw Error(n(61))}if(a.style!=null&&typeof a.style!="object")throw Error(n(62))}}function Ss(o,a){if(o.indexOf("-")===-1)return typeof a.is=="string";switch(o){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Po=null;function co(o){return o=o.target||o.srcElement||window,o.correspondingUseElement&&(o=o.correspondingUseElement),o.nodeType===3?o.parentNode:o}var Fs=null,un=null,Mo=null;function Il(o){if(o=oc(o)){if(typeof Fs!="function")throw Error(n(280));var a=o.stateNode;a&&(a=sd(a),Fs(o.stateNode,o.type,a))}}function Fu(o){un?Mo?Mo.push(o):Mo=[o]:un=o}function Bu(){if(un){var o=un,a=Mo;if(Mo=un=null,Il(o),a)for(o=0;o>>=0,o===0?32:31-(Vl(o)/Tn|0)|0}var xa=64,Ms=4194304;function Ls(o){switch(o&-o){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return o&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return o&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return o}}function bi(o,a){var u=o.pendingLanes;if(u===0)return 0;var p=0,y=o.suspendedLanes,E=o.pingedLanes,B=u&268435455;if(B!==0){var z=B&~y;z!==0?p=Ls(z):(E&=B,E!==0&&(p=Ls(E)))}else B=u&~y,B!==0?p=Ls(B):E!==0&&(p=Ls(E));if(p===0)return 0;if(a!==0&&a!==p&&(a&y)===0&&(y=p&-p,E=a&-a,y>=E||y===16&&(E&4194240)!==0))return a;if((p&4)!==0&&(p|=u&16),a=o.entangledLanes,a!==0)for(o=o.entanglements,a&=p;0u;u++)a.push(o);return a}function Rs(o,a,u){o.pendingLanes|=a,a!==536870912&&(o.suspendedLanes=0,o.pingedLanes=0),o=o.eventTimes,a=31-Hn(a),o[a]=u}function Wl(o,a){var u=o.pendingLanes&~a;o.pendingLanes=a,o.suspendedLanes=0,o.pingedLanes=0,o.expiredLanes&=a,o.mutableReadLanes&=a,o.entangledLanes&=a,a=o.entanglements;var p=o.eventTimes;for(o=o.expirationTimes;0=as),Ju=" ",Bi=!1;function A(o,a){switch(o){case"keyup":return Kt.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function T(o){return o=o.detail,typeof o=="object"&&"data"in o?o.data:null}var R=!1;function N(o,a){switch(o){case"compositionend":return T(a);case"keypress":return a.which!==32?null:(Bi=!0,Ju);case"textInput":return o=a.data,o===Ju&&Bi?null:o;default:return null}}function q(o,a){if(R)return o==="compositionend"||!Fi&&A(o,a)?(o=Br(),Fr=Yl=Sr=null,R=!1,o):null;switch(o){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1=a)return{node:u,offset:a-o};o=p}e:{for(;u;){if(u.nextSibling){u=u.nextSibling;break e}u=u.parentNode}u=void 0}u=hr(u)}}function Mn(o,a){return o&&a?o===a?!0:o&&o.nodeType===3?!1:a&&a.nodeType===3?Mn(o,a.parentNode):"contains"in o?o.contains(a):o.compareDocumentPosition?!!(o.compareDocumentPosition(a)&16):!1:!1}function Gn(){for(var o=window,a=Ee();a instanceof o.HTMLIFrameElement;){try{var u=typeof a.contentWindow.location.href=="string"}catch{u=!1}if(u)o=a.contentWindow;else break;a=Ee(o.document)}return a}function Kn(o){var a=o&&o.nodeName&&o.nodeName.toLowerCase();return a&&(a==="input"&&(o.type==="text"||o.type==="search"||o.type==="tel"||o.type==="url"||o.type==="password")||a==="textarea"||o.contentEditable==="true")}function Hr(o){var a=Gn(),u=o.focusedElem,p=o.selectionRange;if(a!==u&&u&&u.ownerDocument&&Mn(u.ownerDocument.documentElement,u)){if(p!==null&&Kn(u)){if(a=p.start,o=p.end,o===void 0&&(o=a),"selectionStart"in u)u.selectionStart=a,u.selectionEnd=Math.min(o,u.value.length);else if(o=(a=u.ownerDocument||document)&&a.defaultView||window,o.getSelection){o=o.getSelection();var y=u.textContent.length,E=Math.min(p.start,y);p=p.end===void 0?E:Math.min(p.end,y),!o.extend&&E>p&&(y=p,p=E,E=y),y=Pr(u,E);var B=Pr(u,p);y&&B&&(o.rangeCount!==1||o.anchorNode!==y.node||o.anchorOffset!==y.offset||o.focusNode!==B.node||o.focusOffset!==B.offset)&&(a=a.createRange(),a.setStart(y.node,y.offset),o.removeAllRanges(),E>p?(o.addRange(a),o.extend(B.node,B.offset)):(a.setEnd(B.node,B.offset),o.addRange(a)))}}for(a=[],o=u;o=o.parentNode;)o.nodeType===1&&a.push({element:o,left:o.scrollLeft,top:o.scrollTop});for(typeof u.focus=="function"&&u.focus(),u=0;u=document.documentMode,sn=null,mo=null,en=null,Ti=!1;function m1(o,a,u){var p=u.window===u?u.document:u.nodeType===9?u:u.ownerDocument;Ti||sn==null||sn!==Ee(p)||(p=sn,"selectionStart"in p&&Kn(p)?p={start:p.selectionStart,end:p.selectionEnd}:(p=(p.ownerDocument&&p.ownerDocument.defaultView||window).getSelection(),p={anchorNode:p.anchorNode,anchorOffset:p.anchorOffset,focusNode:p.focusNode,focusOffset:p.focusOffset}),en&&bn(en,p)||(en=p,p=nd(mo,"onSelect"),0_i||(o.current=ip[_i],ip[_i]=null,_i--)}function Ft(o,a){_i++,ip[_i]=o.current,o.current=a}var Ks={},Ln=Gs(Ks),pr=Gs(!1),_a=Ks;function Ni(o,a){var u=o.type.contextTypes;if(!u)return Ks;var p=o.stateNode;if(p&&p.__reactInternalMemoizedUnmaskedChildContext===a)return p.__reactInternalMemoizedMaskedChildContext;var y={},E;for(E in u)y[E]=a[E];return p&&(o=o.stateNode,o.__reactInternalMemoizedUnmaskedChildContext=a,o.__reactInternalMemoizedMaskedChildContext=y),y}function mr(o){return o=o.childContextTypes,o!=null}function ad(){Pt(pr),Pt(Ln)}function T1(o,a,u){if(Ln.current!==Ks)throw Error(n(168));Ft(Ln,a),Ft(pr,u)}function P1(o,a,u){var p=o.stateNode;if(a=a.childContextTypes,typeof p.getChildContext!="function")return u;p=p.getChildContext();for(var y in p)if(!(y in a))throw Error(n(108,ue(o)||"Unknown",y));return ne({},u,p)}function id(o){return o=(o=o.stateNode)&&o.__reactInternalMemoizedMergedChildContext||Ks,_a=Ln.current,Ft(Ln,o),Ft(pr,pr.current),!0}function M1(o,a,u){var p=o.stateNode;if(!p)throw Error(n(169));u?(o=P1(o,a,_a),p.__reactInternalMemoizedMergedChildContext=o,Pt(pr),Pt(Ln),Ft(Ln,o)):Pt(pr),Ft(pr,u)}var ls=null,ld=!1,lp=!1;function L1(o){ls===null?ls=[o]:ls.push(o)}function r6(o){ld=!0,L1(o)}function Ys(){if(!lp&&ls!==null){lp=!0;var o=0,a=nt;try{var u=ls;for(nt=1;o>=B,y-=B,cs=1<<32-Hn(a)+y|u<We?(En=ze,ze=null):En=ze.sibling;var it=fe(J,ze,te[We],ve);if(it===null){ze===null&&(ze=En);break}o&&ze&&it.alternate===null&&a(J,ze),Y=E(it,Y,We),$e===null?Ne=it:$e.sibling=it,$e=it,ze=En}if(We===te.length)return u(J,ze),Nt&&ja(J,We),Ne;if(ze===null){for(;WeWe?(En=ze,ze=null):En=ze.sibling;var oa=fe(J,ze,it.value,ve);if(oa===null){ze===null&&(ze=En);break}o&&ze&&oa.alternate===null&&a(J,ze),Y=E(oa,Y,We),$e===null?Ne=oa:$e.sibling=oa,$e=oa,ze=En}if(it.done)return u(J,ze),Nt&&ja(J,We),Ne;if(ze===null){for(;!it.done;We++,it=te.next())it=ge(J,it.value,ve),it!==null&&(Y=E(it,Y,We),$e===null?Ne=it:$e.sibling=it,$e=it);return Nt&&ja(J,We),Ne}for(ze=p(J,ze);!it.done;We++,it=te.next())it=Se(ze,J,We,it.value,ve),it!==null&&(o&&it.alternate!==null&&ze.delete(it.key===null?We:it.key),Y=E(it,Y,We),$e===null?Ne=it:$e.sibling=it,$e=it);return o&&ze.forEach(function(j6){return a(J,j6)}),Nt&&ja(J,We),Ne}function tn(J,Y,te,ve){if(typeof te=="object"&&te!==null&&te.type===O&&te.key===null&&(te=te.props.children),typeof te=="object"&&te!==null){switch(te.$$typeof){case M:e:{for(var Ne=te.key,$e=Y;$e!==null;){if($e.key===Ne){if(Ne=te.type,Ne===O){if($e.tag===7){u(J,$e.sibling),Y=y($e,te.props.children),Y.return=J,J=Y;break e}}else if($e.elementType===Ne||typeof Ne=="object"&&Ne!==null&&Ne.$$typeof===ae&&O1(Ne)===$e.type){u(J,$e.sibling),Y=y($e,te.props),Y.ref=sc(J,$e,te),Y.return=J,J=Y;break e}u(J,$e);break}else a(J,$e);$e=$e.sibling}te.type===O?(Y=Wa(te.props.children,J.mode,ve,te.key),Y.return=J,J=Y):(ve=Nd(te.type,te.key,te.props,null,J.mode,ve),ve.ref=sc(J,Y,te),ve.return=J,J=ve)}return B(J);case L:e:{for($e=te.key;Y!==null;){if(Y.key===$e)if(Y.tag===4&&Y.stateNode.containerInfo===te.containerInfo&&Y.stateNode.implementation===te.implementation){u(J,Y.sibling),Y=y(Y,te.children||[]),Y.return=J,J=Y;break e}else{u(J,Y);break}else a(J,Y);Y=Y.sibling}Y=sm(te,J.mode,ve),Y.return=J,J=Y}return B(J);case ae:return $e=te._init,tn(J,Y,$e(te._payload),ve)}if(dt(te))return Me(J,Y,te,ve);if(ie(te))return Re(J,Y,te,ve);fd(J,te)}return typeof te=="string"&&te!==""||typeof te=="number"?(te=""+te,Y!==null&&Y.tag===6?(u(J,Y.sibling),Y=y(Y,te),Y.return=J,J=Y):(u(J,Y),Y=om(te,J.mode,ve),Y.return=J,J=Y),B(J)):u(J,Y)}return tn}var $i=$1(!0),z1=$1(!1),hd=Gs(null),pd=null,zi=null,pp=null;function mp(){pp=zi=pd=null}function gp(o){var a=hd.current;Pt(hd),o._currentValue=a}function yp(o,a,u){for(;o!==null;){var p=o.alternate;if((o.childLanes&a)!==a?(o.childLanes|=a,p!==null&&(p.childLanes|=a)):p!==null&&(p.childLanes&a)!==a&&(p.childLanes|=a),o===u)break;o=o.return}}function Vi(o,a){pd=o,pp=zi=null,o=o.dependencies,o!==null&&o.firstContext!==null&&((o.lanes&a)!==0&&(gr=!0),o.firstContext=null)}function qr(o){var a=o._currentValue;if(pp!==o)if(o={context:o,memoizedValue:a,next:null},zi===null){if(pd===null)throw Error(n(308));zi=o,pd.dependencies={lanes:0,firstContext:o}}else zi=zi.next=o;return a}var Ia=null;function vp(o){Ia===null?Ia=[o]:Ia.push(o)}function V1(o,a,u,p){var y=a.interleaved;return y===null?(u.next=u,vp(a)):(u.next=y.next,y.next=u),a.interleaved=u,ds(o,p)}function ds(o,a){o.lanes|=a;var u=o.alternate;for(u!==null&&(u.lanes|=a),u=o,o=o.return;o!==null;)o.childLanes|=a,u=o.alternate,u!==null&&(u.childLanes|=a),u=o,o=o.return;return u.tag===3?u.stateNode:null}var Xs=!1;function bp(o){o.updateQueue={baseState:o.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function H1(o,a){o=o.updateQueue,a.updateQueue===o&&(a.updateQueue={baseState:o.baseState,firstBaseUpdate:o.firstBaseUpdate,lastBaseUpdate:o.lastBaseUpdate,shared:o.shared,effects:o.effects})}function fs(o,a){return{eventTime:o,lane:a,tag:0,payload:null,callback:null,next:null}}function Qs(o,a,u){var p=o.updateQueue;if(p===null)return null;if(p=p.shared,(ot&2)!==0){var y=p.pending;return y===null?a.next=a:(a.next=y.next,y.next=a),p.pending=a,ds(o,u)}return y=p.interleaved,y===null?(a.next=a,vp(p)):(a.next=y.next,y.next=a),p.interleaved=a,ds(o,u)}function md(o,a,u){if(a=a.updateQueue,a!==null&&(a=a.shared,(u&4194240)!==0)){var p=a.lanes;p&=o.pendingLanes,u|=p,a.lanes=u,_s(o,u)}}function U1(o,a){var u=o.updateQueue,p=o.alternate;if(p!==null&&(p=p.updateQueue,u===p)){var y=null,E=null;if(u=u.firstBaseUpdate,u!==null){do{var B={eventTime:u.eventTime,lane:u.lane,tag:u.tag,payload:u.payload,callback:u.callback,next:null};E===null?y=E=B:E=E.next=B,u=u.next}while(u!==null);E===null?y=E=a:E=E.next=a}else y=E=a;u={baseState:p.baseState,firstBaseUpdate:y,lastBaseUpdate:E,shared:p.shared,effects:p.effects},o.updateQueue=u;return}o=u.lastBaseUpdate,o===null?u.firstBaseUpdate=a:o.next=a,u.lastBaseUpdate=a}function gd(o,a,u,p){var y=o.updateQueue;Xs=!1;var E=y.firstBaseUpdate,B=y.lastBaseUpdate,z=y.shared.pending;if(z!==null){y.shared.pending=null;var W=z,se=W.next;W.next=null,B===null?E=se:B.next=se,B=W;var pe=o.alternate;pe!==null&&(pe=pe.updateQueue,z=pe.lastBaseUpdate,z!==B&&(z===null?pe.firstBaseUpdate=se:z.next=se,pe.lastBaseUpdate=W))}if(E!==null){var ge=y.baseState;B=0,pe=se=W=null,z=E;do{var fe=z.lane,Se=z.eventTime;if((p&fe)===fe){pe!==null&&(pe=pe.next={eventTime:Se,lane:0,tag:z.tag,payload:z.payload,callback:z.callback,next:null});e:{var Me=o,Re=z;switch(fe=a,Se=u,Re.tag){case 1:if(Me=Re.payload,typeof Me=="function"){ge=Me.call(Se,ge,fe);break e}ge=Me;break e;case 3:Me.flags=Me.flags&-65537|128;case 0:if(Me=Re.payload,fe=typeof Me=="function"?Me.call(Se,ge,fe):Me,fe==null)break e;ge=ne({},ge,fe);break e;case 2:Xs=!0}}z.callback!==null&&z.lane!==0&&(o.flags|=64,fe=y.effects,fe===null?y.effects=[z]:fe.push(z))}else Se={eventTime:Se,lane:fe,tag:z.tag,payload:z.payload,callback:z.callback,next:null},pe===null?(se=pe=Se,W=ge):pe=pe.next=Se,B|=fe;if(z=z.next,z===null){if(z=y.shared.pending,z===null)break;fe=z,z=fe.next,fe.next=null,y.lastBaseUpdate=fe,y.shared.pending=null}}while(!0);if(pe===null&&(W=ge),y.baseState=W,y.firstBaseUpdate=se,y.lastBaseUpdate=pe,a=y.shared.interleaved,a!==null){y=a;do B|=y.lane,y=y.next;while(y!==a)}else E===null&&(y.shared.lanes=0);za|=B,o.lanes=B,o.memoizedState=ge}}function W1(o,a,u){if(o=a.effects,a.effects=null,o!==null)for(a=0;au?u:4,o(!0);var p=xp.transition;xp.transition={};try{o(!1),a()}finally{nt=u,xp.transition=p}}function uv(){return Gr().memoizedState}function i6(o,a,u){var p=ta(o);if(u={lane:p,action:u,hasEagerState:!1,eagerState:null,next:null},dv(o))fv(a,u);else if(u=V1(o,a,u,p),u!==null){var y=Xn();wo(u,o,p,y),hv(u,a,p)}}function l6(o,a,u){var p=ta(o),y={lane:p,action:u,hasEagerState:!1,eagerState:null,next:null};if(dv(o))fv(a,y);else{var E=o.alternate;if(o.lanes===0&&(E===null||E.lanes===0)&&(E=a.lastRenderedReducer,E!==null))try{var B=a.lastRenderedState,z=E(B,u);if(y.hasEagerState=!0,y.eagerState=z,xt(z,B)){var W=a.interleaved;W===null?(y.next=y,vp(a)):(y.next=W.next,W.next=y),a.interleaved=y;return}}catch{}finally{}u=V1(o,a,y,p),u!==null&&(y=Xn(),wo(u,o,p,y),hv(u,a,p))}}function dv(o){var a=o.alternate;return o===Vt||a!==null&&a===Vt}function fv(o,a){cc=bd=!0;var u=o.pending;u===null?a.next=a:(a.next=u.next,u.next=a),o.pending=a}function hv(o,a,u){if((u&4194240)!==0){var p=a.lanes;p&=o.pendingLanes,u|=p,a.lanes=u,_s(o,u)}}var Ed={readContext:qr,useCallback:Rn,useContext:Rn,useEffect:Rn,useImperativeHandle:Rn,useInsertionEffect:Rn,useLayoutEffect:Rn,useMemo:Rn,useReducer:Rn,useRef:Rn,useState:Rn,useDebugValue:Rn,useDeferredValue:Rn,useTransition:Rn,useMutableSource:Rn,useSyncExternalStore:Rn,useId:Rn,unstable_isNewReconciler:!1},c6={readContext:qr,useCallback:function(o,a){return Oo().memoizedState=[o,a===void 0?null:a],o},useContext:qr,useEffect:nv,useImperativeHandle:function(o,a,u){return u=u!=null?u.concat([o]):null,wd(4194308,4,sv.bind(null,a,o),u)},useLayoutEffect:function(o,a){return wd(4194308,4,o,a)},useInsertionEffect:function(o,a){return wd(4,2,o,a)},useMemo:function(o,a){var u=Oo();return a=a===void 0?null:a,o=o(),u.memoizedState=[o,a],o},useReducer:function(o,a,u){var p=Oo();return a=u!==void 0?u(a):a,p.memoizedState=p.baseState=a,o={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:o,lastRenderedState:a},p.queue=o,o=o.dispatch=i6.bind(null,Vt,o),[p.memoizedState,o]},useRef:function(o){var a=Oo();return o={current:o},a.memoizedState=o},useState:ev,useDebugValue:Pp,useDeferredValue:function(o){return Oo().memoizedState=o},useTransition:function(){var o=ev(!1),a=o[0];return o=a6.bind(null,o[1]),Oo().memoizedState=o,[a,o]},useMutableSource:function(){},useSyncExternalStore:function(o,a,u){var p=Vt,y=Oo();if(Nt){if(u===void 0)throw Error(n(407));u=u()}else{if(u=a(),Cn===null)throw Error(n(349));($a&30)!==0||Y1(p,a,u)}y.memoizedState=u;var E={value:u,getSnapshot:a};return y.queue=E,nv(Q1.bind(null,p,E,o),[o]),p.flags|=2048,fc(9,X1.bind(null,p,E,u,a),void 0,null),u},useId:function(){var o=Oo(),a=Cn.identifierPrefix;if(Nt){var u=us,p=cs;u=(p&~(1<<32-Hn(p)-1)).toString(32)+u,a=":"+a+"R"+u,u=uc++,0<\/script>",o=o.removeChild(o.firstChild)):typeof p.is=="string"?o=B.createElement(u,{is:p.is}):(o=B.createElement(u),u==="select"&&(B=o,p.multiple?B.multiple=!0:p.size&&(B.size=p.size))):o=B.createElementNS(o,u),o[jo]=a,o[rc]=p,Lv(o,a,!1,!1),a.stateNode=o;e:{switch(B=Ss(u,p),u){case"dialog":Tt("cancel",o),Tt("close",o),y=p;break;case"iframe":case"object":case"embed":Tt("load",o),y=p;break;case"video":case"audio":for(y=0;yGi&&(a.flags|=128,p=!0,hc(E,!1),a.lanes=4194304)}else{if(!p)if(o=yd(B),o!==null){if(a.flags|=128,p=!0,u=o.updateQueue,u!==null&&(a.updateQueue=u,a.flags|=4),hc(E,!0),E.tail===null&&E.tailMode==="hidden"&&!B.alternate&&!Nt)return _n(a),null}else 2*kt()-E.renderingStartTime>Gi&&u!==1073741824&&(a.flags|=128,p=!0,hc(E,!1),a.lanes=4194304);E.isBackwards?(B.sibling=a.child,a.child=B):(u=E.last,u!==null?u.sibling=B:a.child=B,E.last=B)}return E.tail!==null?(a=E.tail,E.rendering=a,E.tail=a.sibling,E.renderingStartTime=kt(),a.sibling=null,u=zt.current,Ft(zt,p?u&1|2:u&1),a):(_n(a),null);case 22:case 23:return tm(),p=a.memoizedState!==null,o!==null&&o.memoizedState!==null!==p&&(a.flags|=8192),p&&(a.mode&1)!==0?(Rr&1073741824)!==0&&(_n(a),a.subtreeFlags&6&&(a.flags|=8192)):_n(a),null;case 24:return null;case 25:return null}throw Error(n(156,a.tag))}function y6(o,a){switch(up(a),a.tag){case 1:return mr(a.type)&&ad(),o=a.flags,o&65536?(a.flags=o&-65537|128,a):null;case 3:return Hi(),Pt(pr),Pt(Ln),kp(),o=a.flags,(o&65536)!==0&&(o&128)===0?(a.flags=o&-65537|128,a):null;case 5:return Cp(a),null;case 13:if(Pt(zt),o=a.memoizedState,o!==null&&o.dehydrated!==null){if(a.alternate===null)throw Error(n(340));Oi()}return o=a.flags,o&65536?(a.flags=o&-65537|128,a):null;case 19:return Pt(zt),null;case 4:return Hi(),null;case 10:return gp(a.type._context),null;case 22:case 23:return tm(),null;case 24:return null;default:return null}}var Dd=!1,Nn=!1,v6=typeof WeakSet=="function"?WeakSet:Set,Be=null;function Wi(o,a){var u=o.ref;if(u!==null)if(typeof u=="function")try{u(null)}catch(p){Yt(o,a,p)}else u.current=null}function Hp(o,a,u){try{u()}catch(p){Yt(o,a,p)}}var Nv=!1;function b6(o,a){if(tp=vt,o=Gn(),Kn(o)){if("selectionStart"in o)var u={start:o.selectionStart,end:o.selectionEnd};else e:{u=(u=o.ownerDocument)&&u.defaultView||window;var p=u.getSelection&&u.getSelection();if(p&&p.rangeCount!==0){u=p.anchorNode;var y=p.anchorOffset,E=p.focusNode;p=p.focusOffset;try{u.nodeType,E.nodeType}catch{u=null;break e}var B=0,z=-1,W=-1,se=0,pe=0,ge=o,fe=null;t:for(;;){for(var Se;ge!==u||y!==0&&ge.nodeType!==3||(z=B+y),ge!==E||p!==0&&ge.nodeType!==3||(W=B+p),ge.nodeType===3&&(B+=ge.nodeValue.length),(Se=ge.firstChild)!==null;)fe=ge,ge=Se;for(;;){if(ge===o)break t;if(fe===u&&++se===y&&(z=B),fe===E&&++pe===p&&(W=B),(Se=ge.nextSibling)!==null)break;ge=fe,fe=ge.parentNode}ge=Se}u=z===-1||W===-1?null:{start:z,end:W}}else u=null}u=u||{start:0,end:0}}else u=null;for(np={focusedElem:o,selectionRange:u},vt=!1,Be=a;Be!==null;)if(a=Be,o=a.child,(a.subtreeFlags&1028)!==0&&o!==null)o.return=a,Be=o;else for(;Be!==null;){a=Be;try{var Me=a.alternate;if((a.flags&1024)!==0)switch(a.tag){case 0:case 11:case 15:break;case 1:if(Me!==null){var Re=Me.memoizedProps,tn=Me.memoizedState,J=a.stateNode,Y=J.getSnapshotBeforeUpdate(a.elementType===a.type?Re:yo(a.type,Re),tn);J.__reactInternalSnapshotBeforeUpdate=Y}break;case 3:var te=a.stateNode.containerInfo;te.nodeType===1?te.textContent="":te.nodeType===9&&te.documentElement&&te.removeChild(te.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(ve){Yt(a,a.return,ve)}if(o=a.sibling,o!==null){o.return=a.return,Be=o;break}Be=a.return}return Me=Nv,Nv=!1,Me}function pc(o,a,u){var p=a.updateQueue;if(p=p!==null?p.lastEffect:null,p!==null){var y=p=p.next;do{if((y.tag&o)===o){var E=y.destroy;y.destroy=void 0,E!==void 0&&Hp(a,u,E)}y=y.next}while(y!==p)}}function Sd(o,a){if(a=a.updateQueue,a=a!==null?a.lastEffect:null,a!==null){var u=a=a.next;do{if((u.tag&o)===o){var p=u.create;u.destroy=p()}u=u.next}while(u!==a)}}function Up(o){var a=o.ref;if(a!==null){var u=o.stateNode;switch(o.tag){case 5:o=u;break;default:o=u}typeof a=="function"?a(o):a.current=o}}function jv(o){var a=o.alternate;a!==null&&(o.alternate=null,jv(a)),o.child=null,o.deletions=null,o.sibling=null,o.tag===5&&(a=o.stateNode,a!==null&&(delete a[jo],delete a[rc],delete a[ap],delete a[t6],delete a[n6])),o.stateNode=null,o.return=null,o.dependencies=null,o.memoizedProps=null,o.memoizedState=null,o.pendingProps=null,o.stateNode=null,o.updateQueue=null}function Iv(o){return o.tag===5||o.tag===3||o.tag===4}function Ov(o){e:for(;;){for(;o.sibling===null;){if(o.return===null||Iv(o.return))return null;o=o.return}for(o.sibling.return=o.return,o=o.sibling;o.tag!==5&&o.tag!==6&&o.tag!==18;){if(o.flags&2||o.child===null||o.tag===4)continue e;o.child.return=o,o=o.child}if(!(o.flags&2))return o.stateNode}}function Wp(o,a,u){var p=o.tag;if(p===5||p===6)o=o.stateNode,a?u.nodeType===8?u.parentNode.insertBefore(o,a):u.insertBefore(o,a):(u.nodeType===8?(a=u.parentNode,a.insertBefore(o,u)):(a=u,a.appendChild(o)),u=u._reactRootContainer,u!=null||a.onclick!==null||(a.onclick=od));else if(p!==4&&(o=o.child,o!==null))for(Wp(o,a,u),o=o.sibling;o!==null;)Wp(o,a,u),o=o.sibling}function qp(o,a,u){var p=o.tag;if(p===5||p===6)o=o.stateNode,a?u.insertBefore(o,a):u.appendChild(o);else if(p!==4&&(o=o.child,o!==null))for(qp(o,a,u),o=o.sibling;o!==null;)qp(o,a,u),o=o.sibling}var An=null,vo=!1;function Js(o,a,u){for(u=u.child;u!==null;)$v(o,a,u),u=u.sibling}function $v(o,a,u){if(ur&&typeof ur.onCommitFiberUnmount=="function")try{ur.onCommitFiberUnmount(Ps,u)}catch{}switch(u.tag){case 5:Nn||Wi(u,a);case 6:var p=An,y=vo;An=null,Js(o,a,u),An=p,vo=y,An!==null&&(vo?(o=An,u=u.stateNode,o.nodeType===8?o.parentNode.removeChild(u):o.removeChild(u)):An.removeChild(u.stateNode));break;case 18:An!==null&&(vo?(o=An,u=u.stateNode,o.nodeType===8?sp(o.parentNode,u):o.nodeType===1&&sp(o,u),Vs(o)):sp(An,u.stateNode));break;case 4:p=An,y=vo,An=u.stateNode.containerInfo,vo=!0,Js(o,a,u),An=p,vo=y;break;case 0:case 11:case 14:case 15:if(!Nn&&(p=u.updateQueue,p!==null&&(p=p.lastEffect,p!==null))){y=p=p.next;do{var E=y,B=E.destroy;E=E.tag,B!==void 0&&((E&2)!==0||(E&4)!==0)&&Hp(u,a,B),y=y.next}while(y!==p)}Js(o,a,u);break;case 1:if(!Nn&&(Wi(u,a),p=u.stateNode,typeof p.componentWillUnmount=="function"))try{p.props=u.memoizedProps,p.state=u.memoizedState,p.componentWillUnmount()}catch(z){Yt(u,a,z)}Js(o,a,u);break;case 21:Js(o,a,u);break;case 22:u.mode&1?(Nn=(p=Nn)||u.memoizedState!==null,Js(o,a,u),Nn=p):Js(o,a,u);break;default:Js(o,a,u)}}function zv(o){var a=o.updateQueue;if(a!==null){o.updateQueue=null;var u=o.stateNode;u===null&&(u=o.stateNode=new v6),a.forEach(function(p){var y=F6.bind(null,o,p);u.has(p)||(u.add(p),p.then(y,y))})}}function bo(o,a){var u=a.deletions;if(u!==null)for(var p=0;py&&(y=B),p&=~E}if(p=y,p=kt()-p,p=(120>p?120:480>p?480:1080>p?1080:1920>p?1920:3e3>p?3e3:4320>p?4320:1960*C6(p/1960))-p,10o?16:o,ea===null)var p=!1;else{if(o=ea,ea=null,Md=0,(ot&6)!==0)throw Error(n(331));var y=ot;for(ot|=4,Be=o.current;Be!==null;){var E=Be,B=E.child;if((Be.flags&16)!==0){var z=E.deletions;if(z!==null){for(var W=0;Wkt()-Yp?Ha(o,0):Kp|=u),vr(o,a)}function eb(o,a){a===0&&((o.mode&1)===0?a=1:(a=Ms,Ms<<=1,(Ms&130023424)===0&&(Ms=4194304)));var u=Xn();o=ds(o,a),o!==null&&(Rs(o,a,u),vr(o,u))}function S6(o){var a=o.memoizedState,u=0;a!==null&&(u=a.retryLane),eb(o,u)}function F6(o,a){var u=0;switch(o.tag){case 13:var p=o.stateNode,y=o.memoizedState;y!==null&&(u=y.retryLane);break;case 19:p=o.stateNode;break;default:throw Error(n(314))}p!==null&&p.delete(a),eb(o,u)}var tb;tb=function(o,a,u){if(o!==null)if(o.memoizedProps!==a.pendingProps||pr.current)gr=!0;else{if((o.lanes&u)===0&&(a.flags&128)===0)return gr=!1,m6(o,a,u);gr=(o.flags&131072)!==0}else gr=!1,Nt&&(a.flags&1048576)!==0&&R1(a,ud,a.index);switch(a.lanes=0,a.tag){case 2:var p=a.type;Ad(o,a),o=a.pendingProps;var y=Ni(a,Ln.current);Vi(a,u),y=Dp(null,a,p,o,y,u);var E=Sp();return a.flags|=1,typeof y=="object"&&y!==null&&typeof y.render=="function"&&y.$$typeof===void 0?(a.tag=1,a.memoizedState=null,a.updateQueue=null,mr(p)?(E=!0,id(a)):E=!1,a.memoizedState=y.state!==null&&y.state!==void 0?y.state:null,bp(a),y.updater=kd,a.stateNode=y,y._reactInternals=a,Lp(a,p,o,u),a=jp(null,a,p,!0,E,u)):(a.tag=0,Nt&&E&&cp(a),Yn(null,a,y,u),a=a.child),a;case 16:p=a.elementType;e:{switch(Ad(o,a),o=a.pendingProps,y=p._init,p=y(p._payload),a.type=p,y=a.tag=T6(p),o=yo(p,o),y){case 0:a=Np(null,a,p,o,u);break e;case 1:a=Sv(null,a,p,o,u);break e;case 11:a=Ev(null,a,p,o,u);break e;case 14:a=kv(null,a,p,yo(p.type,o),u);break e}throw Error(n(306,p,""))}return a;case 0:return p=a.type,y=a.pendingProps,y=a.elementType===p?y:yo(p,y),Np(o,a,p,y,u);case 1:return p=a.type,y=a.pendingProps,y=a.elementType===p?y:yo(p,y),Sv(o,a,p,y,u);case 3:e:{if(Fv(a),o===null)throw Error(n(387));p=a.pendingProps,E=a.memoizedState,y=E.element,H1(o,a),gd(a,p,null,u);var B=a.memoizedState;if(p=B.element,E.isDehydrated)if(E={element:p,isDehydrated:!1,cache:B.cache,pendingSuspenseBoundaries:B.pendingSuspenseBoundaries,transitions:B.transitions},a.updateQueue.baseState=E,a.memoizedState=E,a.flags&256){y=Ui(Error(n(423)),a),a=Bv(o,a,p,u,y);break e}else if(p!==y){y=Ui(Error(n(424)),a),a=Bv(o,a,p,u,y);break e}else for(Lr=qs(a.stateNode.containerInfo.firstChild),Mr=a,Nt=!0,go=null,u=z1(a,null,p,u),a.child=u;u;)u.flags=u.flags&-3|4096,u=u.sibling;else{if(Oi(),p===y){a=hs(o,a,u);break e}Yn(o,a,p,u)}a=a.child}return a;case 5:return q1(a),o===null&&fp(a),p=a.type,y=a.pendingProps,E=o!==null?o.memoizedProps:null,B=y.children,rp(p,y)?B=null:E!==null&&rp(p,E)&&(a.flags|=32),Dv(o,a),Yn(o,a,B,u),a.child;case 6:return o===null&&fp(a),null;case 13:return Tv(o,a,u);case 4:return wp(a,a.stateNode.containerInfo),p=a.pendingProps,o===null?a.child=$i(a,null,p,u):Yn(o,a,p,u),a.child;case 11:return p=a.type,y=a.pendingProps,y=a.elementType===p?y:yo(p,y),Ev(o,a,p,y,u);case 7:return Yn(o,a,a.pendingProps,u),a.child;case 8:return Yn(o,a,a.pendingProps.children,u),a.child;case 12:return Yn(o,a,a.pendingProps.children,u),a.child;case 10:e:{if(p=a.type._context,y=a.pendingProps,E=a.memoizedProps,B=y.value,Ft(hd,p._currentValue),p._currentValue=B,E!==null)if(xt(E.value,B)){if(E.children===y.children&&!pr.current){a=hs(o,a,u);break e}}else for(E=a.child,E!==null&&(E.return=a);E!==null;){var z=E.dependencies;if(z!==null){B=E.child;for(var W=z.firstContext;W!==null;){if(W.context===p){if(E.tag===1){W=fs(-1,u&-u),W.tag=2;var se=E.updateQueue;if(se!==null){se=se.shared;var pe=se.pending;pe===null?W.next=W:(W.next=pe.next,pe.next=W),se.pending=W}}E.lanes|=u,W=E.alternate,W!==null&&(W.lanes|=u),yp(E.return,u,a),z.lanes|=u;break}W=W.next}}else if(E.tag===10)B=E.type===a.type?null:E.child;else if(E.tag===18){if(B=E.return,B===null)throw Error(n(341));B.lanes|=u,z=B.alternate,z!==null&&(z.lanes|=u),yp(B,u,a),B=E.sibling}else B=E.child;if(B!==null)B.return=E;else for(B=E;B!==null;){if(B===a){B=null;break}if(E=B.sibling,E!==null){E.return=B.return,B=E;break}B=B.return}E=B}Yn(o,a,y.children,u),a=a.child}return a;case 9:return y=a.type,p=a.pendingProps.children,Vi(a,u),y=qr(y),p=p(y),a.flags|=1,Yn(o,a,p,u),a.child;case 14:return p=a.type,y=yo(p,a.pendingProps),y=yo(p.type,y),kv(o,a,p,y,u);case 15:return xv(o,a,a.type,a.pendingProps,u);case 17:return p=a.type,y=a.pendingProps,y=a.elementType===p?y:yo(p,y),Ad(o,a),a.tag=1,mr(p)?(o=!0,id(a)):o=!1,Vi(a,u),mv(a,p,y),Lp(a,p,y,u),jp(null,a,p,!0,o,u);case 19:return Mv(o,a,u);case 22:return Av(o,a,u)}throw Error(n(156,a.tag))};function nb(o,a){return Jt(o,a)}function B6(o,a,u,p){this.tag=o,this.key=u,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=a,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=p,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Yr(o,a,u,p){return new B6(o,a,u,p)}function rm(o){return o=o.prototype,!(!o||!o.isReactComponent)}function T6(o){if(typeof o=="function")return rm(o)?1:0;if(o!=null){if(o=o.$$typeof,o===X)return 11;if(o===oe)return 14}return 2}function ra(o,a){var u=o.alternate;return u===null?(u=Yr(o.tag,a,o.key,o.mode),u.elementType=o.elementType,u.type=o.type,u.stateNode=o.stateNode,u.alternate=o,o.alternate=u):(u.pendingProps=a,u.type=o.type,u.flags=0,u.subtreeFlags=0,u.deletions=null),u.flags=o.flags&14680064,u.childLanes=o.childLanes,u.lanes=o.lanes,u.child=o.child,u.memoizedProps=o.memoizedProps,u.memoizedState=o.memoizedState,u.updateQueue=o.updateQueue,a=o.dependencies,u.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},u.sibling=o.sibling,u.index=o.index,u.ref=o.ref,u}function Nd(o,a,u,p,y,E){var B=2;if(p=o,typeof o=="function")rm(o)&&(B=1);else if(typeof o=="string")B=5;else e:switch(o){case O:return Wa(u.children,y,E,a);case I:B=8,y|=8;break;case V:return o=Yr(12,u,a,y|2),o.elementType=V,o.lanes=E,o;case $:return o=Yr(13,u,a,y),o.elementType=$,o.lanes=E,o;case H:return o=Yr(19,u,a,y),o.elementType=H,o.lanes=E,o;case re:return jd(u,y,E,a);default:if(typeof o=="object"&&o!==null)switch(o.$$typeof){case U:B=10;break e;case j:B=9;break e;case X:B=11;break e;case oe:B=14;break e;case ae:B=16,p=null;break e}throw Error(n(130,o==null?o:typeof o,""))}return a=Yr(B,u,a,y),a.elementType=o,a.type=p,a.lanes=E,a}function Wa(o,a,u,p){return o=Yr(7,o,p,a),o.lanes=u,o}function jd(o,a,u,p){return o=Yr(22,o,p,a),o.elementType=re,o.lanes=u,o.stateNode={isHidden:!1},o}function om(o,a,u){return o=Yr(6,o,null,a),o.lanes=u,o}function sm(o,a,u){return a=Yr(4,o.children!==null?o.children:[],o.key,a),a.lanes=u,a.stateNode={containerInfo:o.containerInfo,pendingChildren:null,implementation:o.implementation},a}function P6(o,a,u,p,y){this.tag=a,this.containerInfo=o,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ul(0),this.expirationTimes=Ul(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ul(0),this.identifierPrefix=p,this.onRecoverableError=y,this.mutableSourceEagerHydrationData=null}function am(o,a,u,p,y,E,B,z,W){return o=new P6(o,a,u,z,W),a===1?(a=1,E===!0&&(a|=8)):a=0,E=Yr(3,null,null,a),o.current=E,E.stateNode=o,E.memoizedState={element:p,isDehydrated:u,cache:null,transitions:null,pendingSuspenseBoundaries:null},bp(E),o}function M6(o,a,u){var p=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),fm.exports=G6(),fm.exports}var yb;function K6(){if(yb)return Ud;yb=1;var e=c5();return Ud.createRoot=e.createRoot,Ud.hydrateRoot=e.hydrateRoot,Ud}var Y6=K6();/** + * react-router v7.10.1 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */var vb="popstate";function X6(e={}){function t(r,s){let{pathname:i,search:l,hash:c}=r.location;return kg("",{pathname:i,search:l,hash:c},s.state&&s.state.usr||null,s.state&&s.state.key||"default")}function n(r,s){return typeof s=="string"?s:tu(s)}return J6(t,n,null,e)}function jt(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function ro(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Q6(){return Math.random().toString(36).substring(2,10)}function bb(e,t){return{usr:e.state,key:e.key,idx:t}}function kg(e,t,n=null,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?kl(t):t,state:n,key:t&&t.key||r||Q6()}}function tu({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function kl(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function J6(e,t,n,r={}){let{window:s=document.defaultView,v5Compat:i=!1}=r,l=s.history,c="POP",d=null,f=h();f==null&&(f=0,l.replaceState({...l.state,idx:f},""));function h(){return(l.state||{idx:null}).idx}function m(){c="POP";let x=h(),D=x==null?null:x-f;f=x,d&&d({action:c,location:w.location,delta:D})}function g(x,D){c="PUSH";let S=kg(w.location,x,D);f=h()+1;let F=bb(S,f),P=w.createHref(S);try{l.pushState(F,"",P)}catch(M){if(M instanceof DOMException&&M.name==="DataCloneError")throw M;s.location.assign(P)}i&&d&&d({action:c,location:w.location,delta:1})}function b(x,D){c="REPLACE";let S=kg(w.location,x,D);f=h();let F=bb(S,f),P=w.createHref(S);l.replaceState(F,"",P),i&&d&&d({action:c,location:w.location,delta:0})}function C(x){return Z6(x)}let w={get action(){return c},get location(){return e(s,l)},listen(x){if(d)throw new Error("A history only accepts one active listener");return s.addEventListener(vb,m),d=x,()=>{s.removeEventListener(vb,m),d=null}},createHref(x){return t(s,x)},createURL:C,encodeLocation(x){let D=C(x);return{pathname:D.pathname,search:D.search,hash:D.hash}},push:g,replace:b,go(x){return l.go(x)}};return w}function Z6(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),jt(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:tu(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function u5(e,t,n="/"){return e4(e,t,n,!1)}function e4(e,t,n,r){let s=typeof t=="string"?kl(t):t,i=xs(s.pathname||"/",n);if(i==null)return null;let l=d5(e);t4(l);let c=null;for(let d=0;c==null&&d{let h={relativePath:f===void 0?l.path||"":f,caseSensitive:l.caseSensitive===!0,childrenIndex:c,route:l};if(h.relativePath.startsWith("/")){if(!h.relativePath.startsWith(r)&&d)return;jt(h.relativePath.startsWith(r),`Absolute route path "${h.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),h.relativePath=h.relativePath.slice(r.length)}let m=vs([r,h.relativePath]),g=n.concat(h);l.children&&l.children.length>0&&(jt(l.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${m}".`),d5(l.children,t,g,m,d)),!(l.path==null&&!l.index)&&t.push({path:m,score:l4(m,l.index),routesMeta:g})};return e.forEach((l,c)=>{var d;if(l.path===""||!((d=l.path)!=null&&d.includes("?")))i(l,c);else for(let f of f5(l.path))i(l,c,!0,f)}),t}function f5(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,s=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return s?[i,""]:[i];let l=f5(r.join("/")),c=[];return c.push(...l.map(d=>d===""?i:[i,d].join("/"))),s&&c.push(...l),c.map(d=>e.startsWith("/")&&d===""?"/":d)}function t4(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:c4(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var n4=/^:[\w-]+$/,r4=3,o4=2,s4=1,a4=10,i4=-2,wb=e=>e==="*";function l4(e,t){let n=e.split("/"),r=n.length;return n.some(wb)&&(r+=i4),t&&(r+=o4),n.filter(s=>!wb(s)).reduce((s,i)=>s+(n4.test(i)?r4:i===""?s4:a4),r)}function c4(e,t){return e.length===t.length&&e.slice(0,-1).every((r,s)=>r===t[s])?e[e.length-1]-t[t.length-1]:0}function u4(e,t,n=!1){let{routesMeta:r}=e,s={},i="/",l=[];for(let c=0;c{if(h==="*"){let C=c[g]||"";l=i.slice(0,i.length-C.length).replace(/(.)\/+$/,"$1")}const b=c[g];return m&&!b?f[h]=void 0:f[h]=(b||"").replace(/%2F/g,"/"),f},{}),pathname:i,pathnameBase:l,pattern:e}}function d4(e,t=!1,n=!0){ro(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,c,d)=>(r.push({paramName:c,isOptional:d!=null}),d?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),r]}function f4(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return ro(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function xs(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}var h4=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,p4=e=>h4.test(e);function m4(e,t="/"){let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?kl(e):e,i;if(n)if(p4(n))i=n;else{if(n.includes("//")){let l=n;n=n.replace(/\/\/+/g,"/"),ro(!1,`Pathnames cannot have embedded double slashes - normalizing ${l} -> ${n}`)}n.startsWith("/")?i=Cb(n.substring(1),"/"):i=Cb(n,t)}else i=t;return{pathname:i,search:v4(r),hash:b4(s)}}function Cb(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function mm(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in and the router will parse it for you.`}function g4(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function B0(e){let t=g4(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function T0(e,t,n,r=!1){let s;typeof e=="string"?s=kl(e):(s={...e},jt(!s.pathname||!s.pathname.includes("?"),mm("?","pathname","search",s)),jt(!s.pathname||!s.pathname.includes("#"),mm("#","pathname","hash",s)),jt(!s.search||!s.search.includes("#"),mm("#","search","hash",s)));let i=e===""||s.pathname==="",l=i?"/":s.pathname,c;if(l==null)c=n;else{let m=t.length-1;if(!r&&l.startsWith("..")){let g=l.split("/");for(;g[0]==="..";)g.shift(),m-=1;s.pathname=g.join("/")}c=m>=0?t[m]:"/"}let d=m4(s,c),f=l&&l!=="/"&&l.endsWith("/"),h=(i||l===".")&&n.endsWith("/");return!d.pathname.endsWith("/")&&(f||h)&&(d.pathname+="/"),d}var vs=e=>e.join("/").replace(/\/\/+/g,"/"),y4=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),v4=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,b4=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function w4(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function C4(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var h5=["POST","PUT","PATCH","DELETE"];new Set(h5);var E4=["GET",...h5];new Set(E4);var xl=v.createContext(null);xl.displayName="DataRouter";var dh=v.createContext(null);dh.displayName="DataRouterState";v.createContext(!1);var p5=v.createContext({isTransitioning:!1});p5.displayName="ViewTransition";var k4=v.createContext(new Map);k4.displayName="Fetchers";var x4=v.createContext(null);x4.displayName="Await";var ao=v.createContext(null);ao.displayName="Navigation";var fu=v.createContext(null);fu.displayName="Location";var Jo=v.createContext({outlet:null,matches:[],isDataRoute:!1});Jo.displayName="Route";var P0=v.createContext(null);P0.displayName="RouteError";function A4(e,{relative:t}={}){jt(Al(),"useHref() may be used only in the context of a component.");let{basename:n,navigator:r}=v.useContext(ao),{hash:s,pathname:i,search:l}=hu(e,{relative:t}),c=i;return n!=="/"&&(c=i==="/"?n:vs([n,i])),r.createHref({pathname:c,search:l,hash:s})}function Al(){return v.useContext(fu)!=null}function Zo(){return jt(Al(),"useLocation() may be used only in the context of a component."),v.useContext(fu).location}var m5="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function g5(e){v.useContext(ao).static||v.useLayoutEffect(e)}function fh(){let{isDataRoute:e}=v.useContext(Jo);return e?I4():D4()}function D4(){jt(Al(),"useNavigate() may be used only in the context of a component.");let e=v.useContext(xl),{basename:t,navigator:n}=v.useContext(ao),{matches:r}=v.useContext(Jo),{pathname:s}=Zo(),i=JSON.stringify(B0(r)),l=v.useRef(!1);return g5(()=>{l.current=!0}),v.useCallback((d,f={})=>{if(ro(l.current,m5),!l.current)return;if(typeof d=="number"){n.go(d);return}let h=T0(d,JSON.parse(i),s,f.relative==="path");e==null&&t!=="/"&&(h.pathname=h.pathname==="/"?t:vs([t,h.pathname])),(f.replace?n.replace:n.push)(h,f.state,f)},[t,n,i,s,e])}v.createContext(null);function hu(e,{relative:t}={}){let{matches:n}=v.useContext(Jo),{pathname:r}=Zo(),s=JSON.stringify(B0(n));return v.useMemo(()=>T0(e,JSON.parse(s),r,t==="path"),[e,s,r,t])}function S4(e,t){return y5(e,t)}function y5(e,t,n,r,s){var S;jt(Al(),"useRoutes() may be used only in the context of a component.");let{navigator:i}=v.useContext(ao),{matches:l}=v.useContext(Jo),c=l[l.length-1],d=c?c.params:{},f=c?c.pathname:"/",h=c?c.pathnameBase:"/",m=c&&c.route;{let F=m&&m.path||"";v5(f,!m||F.endsWith("*")||F.endsWith("*?"),`You rendered descendant (or called \`useRoutes()\`) at "${f}" (under ) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render. + +Please change the parent to .`)}let g=Zo(),b;if(t){let F=typeof t=="string"?kl(t):t;jt(h==="/"||((S=F.pathname)==null?void 0:S.startsWith(h)),`When overriding the location using \`\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${h}" but pathname "${F.pathname}" was given in the \`location\` prop.`),b=F}else b=g;let C=b.pathname||"/",w=C;if(h!=="/"){let F=h.replace(/^\//,"").split("/");w="/"+C.replace(/^\//,"").split("/").slice(F.length).join("/")}let x=u5(e,{pathname:w});ro(m||x!=null,`No routes matched location "${b.pathname}${b.search}${b.hash}" `),ro(x==null||x[x.length-1].route.element!==void 0||x[x.length-1].route.Component!==void 0||x[x.length-1].route.lazy!==void 0,`Matched leaf route at location "${b.pathname}${b.search}${b.hash}" does not have an element or Component. This means it will render an with a null value by default resulting in an "empty" page.`);let D=M4(x&&x.map(F=>Object.assign({},F,{params:Object.assign({},d,F.params),pathname:vs([h,i.encodeLocation?i.encodeLocation(F.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:F.pathname]),pathnameBase:F.pathnameBase==="/"?h:vs([h,i.encodeLocation?i.encodeLocation(F.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:F.pathnameBase])})),l,n,r,s);return t&&D?v.createElement(fu.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...b},navigationType:"POP"}},D):D}function F4(){let e=j4(),t=w4(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",s={padding:"0.5rem",backgroundColor:r},i={padding:"2px 4px",backgroundColor:r},l=null;return console.error("Error handled by React Router default ErrorBoundary:",e),l=v.createElement(v.Fragment,null,v.createElement("p",null,"💿 Hey developer 👋"),v.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",v.createElement("code",{style:i},"ErrorBoundary")," or"," ",v.createElement("code",{style:i},"errorElement")," prop on your route.")),v.createElement(v.Fragment,null,v.createElement("h2",null,"Unexpected Application Error!"),v.createElement("h3",{style:{fontStyle:"italic"}},t),n?v.createElement("pre",{style:s},n):null,l)}var B4=v.createElement(F4,null),T4=class extends v.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){return this.state.error!==void 0?v.createElement(Jo.Provider,{value:this.props.routeContext},v.createElement(P0.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function P4({routeContext:e,match:t,children:n}){let r=v.useContext(xl);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),v.createElement(Jo.Provider,{value:e},n)}function M4(e,t=[],n=null,r=null,s=null){if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let i=e,l=n==null?void 0:n.errors;if(l!=null){let h=i.findIndex(m=>m.route.id&&(l==null?void 0:l[m.route.id])!==void 0);jt(h>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(l).join(",")}`),i=i.slice(0,Math.min(i.length,h+1))}let c=!1,d=-1;if(n)for(let h=0;h=0?i=i.slice(0,d+1):i=[i[0]];break}}}let f=n&&r?(h,m)=>{var g,b;r(h,{location:n.location,params:((b=(g=n.matches)==null?void 0:g[0])==null?void 0:b.params)??{},unstable_pattern:C4(n.matches),errorInfo:m})}:void 0;return i.reduceRight((h,m,g)=>{let b,C=!1,w=null,x=null;n&&(b=l&&m.route.id?l[m.route.id]:void 0,w=m.route.errorElement||B4,c&&(d<0&&g===0?(v5("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),C=!0,x=null):d===g&&(C=!0,x=m.route.hydrateFallbackElement||null)));let D=t.concat(i.slice(0,g+1)),S=()=>{let F;return b?F=w:C?F=x:m.route.Component?F=v.createElement(m.route.Component,null):m.route.element?F=m.route.element:F=h,v.createElement(P4,{match:m,routeContext:{outlet:h,matches:D,isDataRoute:n!=null},children:F})};return n&&(m.route.ErrorBoundary||m.route.errorElement||g===0)?v.createElement(T4,{location:n.location,revalidation:n.revalidation,component:w,error:b,children:S(),routeContext:{outlet:null,matches:D,isDataRoute:!0},onError:f}):S()},null)}function M0(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function L4(e){let t=v.useContext(xl);return jt(t,M0(e)),t}function R4(e){let t=v.useContext(dh);return jt(t,M0(e)),t}function _4(e){let t=v.useContext(Jo);return jt(t,M0(e)),t}function L0(e){let t=_4(e),n=t.matches[t.matches.length-1];return jt(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function N4(){return L0("useRouteId")}function j4(){var r;let e=v.useContext(P0),t=R4("useRouteError"),n=L0("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function I4(){let{router:e}=L4("useNavigate"),t=L0("useNavigate"),n=v.useRef(!1);return g5(()=>{n.current=!0}),v.useCallback(async(s,i={})=>{ro(n.current,m5),n.current&&(typeof s=="number"?await e.navigate(s):await e.navigate(s,{fromRouteId:t,...i}))},[e,t])}var Eb={};function v5(e,t,n){!t&&!Eb[e]&&(Eb[e]=!0,ro(!1,n))}v.memo(O4);function O4({routes:e,future:t,state:n,unstable_onError:r}){return y5(e,void 0,n,r,t)}function $4({to:e,replace:t,state:n,relative:r}){jt(Al()," may be used only in the context of a component.");let{static:s}=v.useContext(ao);ro(!s," must not be used on the initial render in a . This is a no-op, but you should modify your code so the is only ever rendered in response to some user interaction or state change.");let{matches:i}=v.useContext(Jo),{pathname:l}=Zo(),c=fh(),d=T0(e,B0(i),l,r==="path"),f=JSON.stringify(d);return v.useEffect(()=>{c(JSON.parse(f),{replace:t,state:n,relative:r})},[c,f,r,t,n]),null}function Jn(e){jt(!1,"A is only ever to be used as the child of element, never rendered directly. Please wrap your in a .")}function z4({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:s,static:i=!1,unstable_useTransitions:l}){jt(!Al(),"You cannot render a inside another . You should never have more than one in your app.");let c=e.replace(/^\/*/,"/"),d=v.useMemo(()=>({basename:c,navigator:s,static:i,unstable_useTransitions:l,future:{}}),[c,s,i,l]);typeof n=="string"&&(n=kl(n));let{pathname:f="/",search:h="",hash:m="",state:g=null,key:b="default"}=n,C=v.useMemo(()=>{let w=xs(f,c);return w==null?null:{location:{pathname:w,search:h,hash:m,state:g,key:b},navigationType:r}},[c,f,h,m,g,b,r]);return ro(C!=null,` is not able to match the URL "${f}${h}${m}" because it does not start with the basename, so the won't render anything.`),C==null?null:v.createElement(ao.Provider,{value:d},v.createElement(fu.Provider,{children:t,value:C}))}function kb({children:e,location:t}){return S4(xg(e),t)}function xg(e,t=[]){let n=[];return v.Children.forEach(e,(r,s)=>{if(!v.isValidElement(r))return;let i=[...t,s];if(r.type===v.Fragment){n.push.apply(n,xg(r.props.children,i));return}jt(r.type===Jn,`[${typeof r.type=="string"?r.type:r.type.name}] is not a component. All component children of must be a or `),jt(!r.props.index||!r.props.children,"An index route cannot have child routes.");let l={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(l.children=xg(r.props.children,i)),n.push(l)}),n}var Ff="get",Bf="application/x-www-form-urlencoded";function hh(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function V4(e){return hh(e)&&e.tagName.toLowerCase()==="button"}function H4(e){return hh(e)&&e.tagName.toLowerCase()==="form"}function U4(e){return hh(e)&&e.tagName.toLowerCase()==="input"}function W4(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function q4(e,t){return e.button===0&&(!t||t==="_self")&&!W4(e)}var Wd=null;function G4(){if(Wd===null)try{new FormData(document.createElement("form"),0),Wd=!1}catch{Wd=!0}return Wd}var K4=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function gm(e){return e!=null&&!K4.has(e)?(ro(!1,`"${e}" is not a valid \`encType\` for \`
\`/\`\` and will default to "${Bf}"`),null):e}function Y4(e,t){let n,r,s,i,l;if(H4(e)){let c=e.getAttribute("action");r=c?xs(c,t):null,n=e.getAttribute("method")||Ff,s=gm(e.getAttribute("enctype"))||Bf,i=new FormData(e)}else if(V4(e)||U4(e)&&(e.type==="submit"||e.type==="image")){let c=e.form;if(c==null)throw new Error('Cannot submit a