From 9cd88a8344a802d1dce89bfdc274534ded645ec4 Mon Sep 17 00:00:00 2001 From: GitHub Actions Bot Date: Sun, 15 Mar 2026 07:25:37 +0000 Subject: [PATCH] Release v0.9.309 Automated sync from private repository. Built with obfuscation enabled. --- frontend/dist/VERSION | 2 +- .../assets/AnalyzerFilterPanel-DPT1vjKV.js | 14 + .../assets/AnalyzerFilterPanel-DX4fviv1.js | 14 - .../assets/AutoConfigureDialog-C9ytM4jL.js | 1 + .../assets/AutoConfigureDialog-D-tiCDMu.js | 6 - frontend/dist/assets/BasemapLayer--gGy0d8r.js | 2 - frontend/dist/assets/BasemapLayer-Bv4kYAcR.js | 1 + frontend/dist/assets/ChatBubble-DL8lfbnv.js | 1 + frontend/dist/assets/ChatBubble-fzIllzhe.js | 6 - .../assets/CollisionExplorerModal-DAlBzVhS.js | 1 + .../assets/CollisionExplorerModal-J7HE0WX3.js | 6 - frontend/dist/assets/Companion-CSLLhavp.js | 72 ++++ .../dist/assets/CompanionEchoMap-BcAn2gmm.js | 1 + .../dist/assets/CompanionPathMap-D5FruuYA.js | 1 + .../dist/assets/Configuration-C6MYk4Vr.js | 27 ++ .../dist/assets/Configuration-CUBGWMgN.js | 32 -- frontend/dist/assets/ConfirmModal-CsrIdG-V.js | 1 - frontend/dist/assets/ConfirmModal-CtS0orbM.js | 1 + frontend/dist/assets/Contacts-CkDqsspC.js | 23 ++ frontend/dist/assets/Contacts-DgMcpPLG.js | 52 --- .../assets/ContactsMapMapLibre-C3aIIydk.js | 125 +++++++ .../assets/ContactsMapMapLibre-DqVXnaaM.js | 125 ------- frontend/dist/assets/Dashboard-B603mHUm.js | 65 ---- frontend/dist/assets/Dashboard-CDloj9Ii.js | 65 ++++ frontend/dist/assets/DataBox-CCBd3sT4.js | 1 - ...alue-Ddo4mrzf.js => DataValue-Cj0a0QCM.js} | 2 +- .../{Grid-CbgS5PRh.js => Grid-BhoD4aLU.js} | 2 +- ...n-DPkSXt-J.js => KeycapButton-BjL5Ht30.js} | 2 +- ...DTXOFhS4.js => LightSparkline-DC33xzFq.js} | 2 +- frontend/dist/assets/Login-BPAK_Nkc.js | 3 - frontend/dist/assets/Login-CzKupPAb.js | 1 + frontend/dist/assets/Logs-DSUXpt-n.js | 1 - frontend/dist/assets/Logs-DxRQJIYV.js | 1 + ...raph-BrnySJao.js => MeshGraph-DWjajU3T.js} | 202 +++++----- .../{Mqtt-CaCE2AxE.js => Mqtt-DoM7Zof1.js} | 19 +- .../dist/assets/MqttModeBadge-Bgn-nTpu.js | 6 - .../dist/assets/MqttModeBadge-Dhi11STL.js | 6 + ...ist-CO1EDTYK.js => PacketList-CbchJDnI.js} | 30 +- .../dist/assets/PacketObservatory-CbUj8V1_.js | 5 + .../dist/assets/PacketObservatory-cGIEJnyK.js | 5 - frontend/dist/assets/Packets-BMtxtCyl.js | 6 + frontend/dist/assets/Packets-BTBFZZN3.js | 6 - frontend/dist/assets/PageLayout-B4RCJ-XT.js | 1 + frontend/dist/assets/PageLayout-Da0xfaXb.js | 1 - .../dist/assets/PathMapMapLibre-63u_fpZD.js | 6 - .../dist/assets/PathMapMapLibre-BsgVWepx.js | 1 + frontend/dist/assets/RoomServer-DiCPtnmR.js | 21 ++ frontend/dist/assets/RoomServer-y-ltkQOG.js | 21 -- frontend/dist/assets/Sessions-CqZugS72.js | 21 ++ frontend/dist/assets/Sessions-D0mPmO8l.js | 21 -- ...AKXIHs1.js => SignalIndicator-D8uG_rJC.js} | 4 +- ...ics-CltP1h12.js => Statistics-xvNcJQ3I.js} | 6 +- frontend/dist/assets/System-Bl4s4lrg.js | 11 - frontend/dist/assets/System-Cocq8BLz.js | 6 + ...minal-D7cLoYyV.js => Terminal-aB_59Bcc.js} | 166 ++++----- .../{Test-DRRytjEQ.js => Test-COE9gN1S.js} | 6 +- ...ivity-CcUqK62Y.js => activity-DQoaymFw.js} | 4 +- ...ntenna-DHhoJnxo.js => antenna-C7FNplvf.js} | 2 +- frontend/dist/assets/arrow-down-SlBTV0Nc.js | 6 + ...ht-BbRfzTpf.js => arrow-right-BZS-u7CW.js} | 4 +- frontend/dist/assets/arrow-up-1am5_GF2.js | 11 - frontend/dist/assets/arrow-up-D_sZeyuo.js | 6 + frontend/dist/assets/ascii-burst-DN6etEs5.js | 1 - frontend/dist/assets/badge-colors-BNUqIXCA.js | 1 - frontend/dist/assets/badge-colors-Dl76Mz8m.js | 1 + frontend/dist/assets/car-aFMoKQAR.js | 6 + frontend/dist/assets/chat-utils-BdAUDg3r.js | 1 + frontend/dist/assets/chat-utils-CXtTpLY5.js | 1 - frontend/dist/assets/check-check-AfNqagLY.js | 6 + ...-jwX-OOTu.js => chevron-right-DsOuIRi8.js} | 4 +- ...-up-DvNDOaHb.js => chevron-up-BVzq549_.js} | 2 +- frontend/dist/assets/circle-alert-PnLnz8pa.js | 6 + frontend/dist/assets/circle-check-m0ROsc83.js | 6 - ...2v.js => circle-question-mark-CJCLhkb9.js} | 2 +- ...op-CO5AnAxr.js => circle-stop--JH-Omkf.js} | 2 +- frontend/dist/assets/circle-x-i9YQ1o9T.js | 6 - .../{clock-CCOO2GB9.js => clock-F-4SScS_.js} | 2 +- frontend/dist/assets/compass-0fhguiKE.js | 6 + ...YsmHo.js => consumer-registry-5uDLywpC.js} | 2 +- .../{cpu-lxveD9wi.js => cpu-BxgsQ0OY.js} | 2 +- ...abase-CSUiI1CG.js => database-gsjgeKE3.js} | 2 +- .../dist/assets/decryption.worker-0KDkyq11.js | 1 - .../dist/assets/decryption.worker-CGbIqr1j.js | 1 + frontend/dist/assets/download-BaEmSLqY.js | 6 - frontend/dist/assets/easing-BdzuOPcT.js | 1 + frontend/dist/assets/easing-VuIK-HqT.js | 6 - frontend/dist/assets/ed25519-AGEPjp-_.js | 1 + .../dist/assets/element-movement-BD3SL-GU.js | 1 + .../dist/assets/element-movement-C8Yd7NWa.js | 1 - frontend/dist/assets/fieldset-DCj-Bavz.js | 1 + frontend/dist/assets/frozen-D4mEoVft.js | 1 + ...{funnel-DOec69-r.js => funnel-CitfWrkD.js} | 2 +- frontend/dist/assets/git-branch-DrsZ9sUq.js | 6 + .../{hash-fRZDKNyT.js => hash-CyK-Kad6.js} | 2 +- frontend/dist/assets/index-B9Nfzawy.js | 318 ---------------- frontend/dist/assets/index-BCuGA4PV.js | 1 + frontend/dist/assets/index-BSz_JZ6w.css | 1 - frontend/dist/assets/index-CBEGRHd5.js | 1 + frontend/dist/assets/index-CHkxpv0k.js | 1 - frontend/dist/assets/index-i0xzpXop.js | 351 ++++++++++++++++++ frontend/dist/assets/index-oOga43RI.css | 1 + frontend/dist/assets/key-round-BpDWKeL5.js | 6 + ...{layers-DHyjQOGN.js => layers-LQ5jNXOV.js} | 2 +- frontend/dist/assets/link-scoring-353AdDOu.js | 1 - frontend/dist/assets/link-scoring-BqsMOwtz.js | 1 + frontend/dist/assets/listbox-C1gGOelh.js | 1 + frontend/dist/assets/listbox-DV2L-QZw.js | 1 - ...ap-pin-Z2xK57U6.js => map-pin-C051lstq.js} | 4 +- frontend/dist/assets/map-pin-off-CPSqCYZk.js | 6 + ...-B1CfjdFi.css => maplibre-gl-B1CfjdFi.css} | 0 frontend/dist/assets/maplibre-gl-B20pCOz8.js | 2 + ...gl-DisS89O_.js => maplibre-gl-BcToCqGO.js} | 2 +- frontend/dist/assets/max-BFwmL_H9.js | 26 -- frontend/dist/assets/max-C_kLXH5u.js | 11 + ...C9xeBmVh.js => message-square-BzLgyIjH.js} | 4 +- .../assets/message-square-text-CIgRIHv3.js | 6 + .../assets/monitor-smartphone-zVB5GYa6.js | 6 - ...etwork-BCB-csrZ.js => network-CeKhSsIh.js} | 2 +- ...pes-D2DQet2e.js => node-types-rVJPSDxd.js} | 2 +- .../dist/assets/payload-detail-Bh2WvEK0.js | 1 + frontend/dist/assets/pencil-8q_J08l4.js | 11 + frontend/dist/assets/ping-kFEBCmQp.js | 1 - .../{plus-B7jylh_n.js => plus-Bb8eT78f.js} | 2 +- frontend/dist/assets/primitives-DkuSh1mR.js | 1 - frontend/dist/assets/primitives-QKpQyH4U.js | 1 + frontend/dist/assets/refresh-cw-hB3ADAmy.js | 6 - frontend/dist/assets/repeat-BSIxXQ81.js | 6 + frontend/dist/assets/repeat-C00vzJTj.js | 11 - ...ccw-BwcqAp9U.js => rotate-ccw-DqV8JyUZ.js} | 4 +- frontend/dist/assets/route-Df1YhBTq.js | 11 + ...{search-BrfwwyYC.js => search-DsTk_ZsM.js} | 2 +- ...s-2-DYzgUEwY.js => settings-2-B0xGzDNd.js} | 2 +- frontend/dist/assets/share-2-B5yQaExh.js | 6 + ...{shield-5eYUHkwt.js => shield-CxmFjMfw.js} | 2 +- ...k-Bx84Eo-l.js => shield-check-DlsLo8Eo.js} | 2 +- ...{system-D2aLg2mB.js => system-Xia4FpjC.js} | 2 +- ...{target-74Dm2pEA.js => target-BAeWmUfa.js} | 2 +- frontend/dist/assets/thermometer-DhPCT8Cn.js | 6 + .../dist/assets/topology.worker-CfQt1cXG.js | 9 + .../dist/assets/topology.worker-D9nzH303.js | 9 - ...rash-2-BxrPvo_t.js => trash-2-DCqpUdF7.js} | 2 +- .../dist/assets/triangle-alert-_KPqiYkd.js | 6 - .../dist/assets/use-text-value-T4f0bwXS.js | 1 + .../dist/assets/use-tree-walker-B4ov8RnQ.js | 1 + ...AlaFCdd.js => useMapViewStore-DZlzQmak.js} | 4 +- .../dist/assets/usePipelineStore-BqTRxIqB.js | 2 + .../dist/assets/usePipelineStore-Dto_OrsT.js | 2 - frontend/dist/assets/variants-Bbq7uzV_.js | 11 + .../dist/assets/wand-sparkles-DBzA3PXL.js | 6 + ...6.js => webgl-device-QoBMYpnS-D6oZ9mRP.js} | 4 +- .../{wifi-BpM3uttU.js => wifi-DYlEDPZY.js} | 2 +- ...i-off-DoZXnx54.js => wifi-off-CQ0s_9cO.js} | 4 +- .../{zap-DME89Nfc.js => zap-tuTM-Jsw.js} | 4 +- frontend/dist/index.html | 4 +- frontend/package.json | 3 +- 155 files changed, 1172 insertions(+), 1096 deletions(-) create mode 100644 frontend/dist/assets/AnalyzerFilterPanel-DPT1vjKV.js delete mode 100644 frontend/dist/assets/AnalyzerFilterPanel-DX4fviv1.js create mode 100644 frontend/dist/assets/AutoConfigureDialog-C9ytM4jL.js delete mode 100644 frontend/dist/assets/AutoConfigureDialog-D-tiCDMu.js delete mode 100644 frontend/dist/assets/BasemapLayer--gGy0d8r.js create mode 100644 frontend/dist/assets/BasemapLayer-Bv4kYAcR.js create mode 100644 frontend/dist/assets/ChatBubble-DL8lfbnv.js delete mode 100644 frontend/dist/assets/ChatBubble-fzIllzhe.js create mode 100644 frontend/dist/assets/CollisionExplorerModal-DAlBzVhS.js delete mode 100644 frontend/dist/assets/CollisionExplorerModal-J7HE0WX3.js create mode 100644 frontend/dist/assets/Companion-CSLLhavp.js create mode 100644 frontend/dist/assets/CompanionEchoMap-BcAn2gmm.js create mode 100644 frontend/dist/assets/CompanionPathMap-D5FruuYA.js create mode 100644 frontend/dist/assets/Configuration-C6MYk4Vr.js delete mode 100644 frontend/dist/assets/Configuration-CUBGWMgN.js delete mode 100644 frontend/dist/assets/ConfirmModal-CsrIdG-V.js create mode 100644 frontend/dist/assets/ConfirmModal-CtS0orbM.js create mode 100644 frontend/dist/assets/Contacts-CkDqsspC.js delete mode 100644 frontend/dist/assets/Contacts-DgMcpPLG.js create mode 100644 frontend/dist/assets/ContactsMapMapLibre-C3aIIydk.js delete mode 100644 frontend/dist/assets/ContactsMapMapLibre-DqVXnaaM.js delete mode 100644 frontend/dist/assets/Dashboard-B603mHUm.js create mode 100644 frontend/dist/assets/Dashboard-CDloj9Ii.js delete mode 100644 frontend/dist/assets/DataBox-CCBd3sT4.js rename frontend/dist/assets/{DataValue-Ddo4mrzf.js => DataValue-Cj0a0QCM.js} (87%) rename frontend/dist/assets/{Grid-CbgS5PRh.js => Grid-BhoD4aLU.js} (95%) rename frontend/dist/assets/{KeycapButton-DPkSXt-J.js => KeycapButton-BjL5Ht30.js} (98%) rename frontend/dist/assets/{LightSparkline-DTXOFhS4.js => LightSparkline-DC33xzFq.js} (96%) delete mode 100644 frontend/dist/assets/Login-BPAK_Nkc.js create mode 100644 frontend/dist/assets/Login-CzKupPAb.js delete mode 100644 frontend/dist/assets/Logs-DSUXpt-n.js create mode 100644 frontend/dist/assets/Logs-DxRQJIYV.js rename frontend/dist/assets/{MeshGraph-BrnySJao.js => MeshGraph-DWjajU3T.js} (77%) rename frontend/dist/assets/{Mqtt-CaCE2AxE.js => Mqtt-DoM7Zof1.js} (81%) delete mode 100644 frontend/dist/assets/MqttModeBadge-Bgn-nTpu.js create mode 100644 frontend/dist/assets/MqttModeBadge-Dhi11STL.js rename frontend/dist/assets/{PacketList-CO1EDTYK.js => PacketList-CbchJDnI.js} (53%) create mode 100644 frontend/dist/assets/PacketObservatory-CbUj8V1_.js delete mode 100644 frontend/dist/assets/PacketObservatory-cGIEJnyK.js create mode 100644 frontend/dist/assets/Packets-BMtxtCyl.js delete mode 100644 frontend/dist/assets/Packets-BTBFZZN3.js create mode 100644 frontend/dist/assets/PageLayout-B4RCJ-XT.js delete mode 100644 frontend/dist/assets/PageLayout-Da0xfaXb.js delete mode 100644 frontend/dist/assets/PathMapMapLibre-63u_fpZD.js create mode 100644 frontend/dist/assets/PathMapMapLibre-BsgVWepx.js create mode 100644 frontend/dist/assets/RoomServer-DiCPtnmR.js delete mode 100644 frontend/dist/assets/RoomServer-y-ltkQOG.js create mode 100644 frontend/dist/assets/Sessions-CqZugS72.js delete mode 100644 frontend/dist/assets/Sessions-D0mPmO8l.js rename frontend/dist/assets/{SignalIndicator-BAKXIHs1.js => SignalIndicator-D8uG_rJC.js} (96%) rename frontend/dist/assets/{Statistics-CltP1h12.js => Statistics-xvNcJQ3I.js} (83%) delete mode 100644 frontend/dist/assets/System-Bl4s4lrg.js create mode 100644 frontend/dist/assets/System-Cocq8BLz.js rename frontend/dist/assets/{Terminal-D7cLoYyV.js => Terminal-aB_59Bcc.js} (68%) rename frontend/dist/assets/{Test-DRRytjEQ.js => Test-COE9gN1S.js} (84%) rename frontend/dist/assets/{activity-CcUqK62Y.js => activity-DQoaymFw.js} (73%) rename frontend/dist/assets/{antenna-DHhoJnxo.js => antenna-C7FNplvf.js} (90%) create mode 100644 frontend/dist/assets/arrow-down-SlBTV0Nc.js rename frontend/dist/assets/{arrow-right-BbRfzTpf.js => arrow-right-BZS-u7CW.js} (68%) delete mode 100644 frontend/dist/assets/arrow-up-1am5_GF2.js create mode 100644 frontend/dist/assets/arrow-up-D_sZeyuo.js delete mode 100644 frontend/dist/assets/ascii-burst-DN6etEs5.js delete mode 100644 frontend/dist/assets/badge-colors-BNUqIXCA.js create mode 100644 frontend/dist/assets/badge-colors-Dl76Mz8m.js create mode 100644 frontend/dist/assets/car-aFMoKQAR.js create mode 100644 frontend/dist/assets/chat-utils-BdAUDg3r.js delete mode 100644 frontend/dist/assets/chat-utils-CXtTpLY5.js create mode 100644 frontend/dist/assets/check-check-AfNqagLY.js rename frontend/dist/assets/{chevron-right-jwX-OOTu.js => chevron-right-DsOuIRi8.js} (54%) rename frontend/dist/assets/{chevron-up-DvNDOaHb.js => chevron-up-BVzq549_.js} (99%) create mode 100644 frontend/dist/assets/circle-alert-PnLnz8pa.js delete mode 100644 frontend/dist/assets/circle-check-m0ROsc83.js rename frontend/dist/assets/{circle-question-mark-Br2ku42v.js => circle-question-mark-CJCLhkb9.js} (89%) rename frontend/dist/assets/{circle-stop-CO5AnAxr.js => circle-stop--JH-Omkf.js} (94%) delete mode 100644 frontend/dist/assets/circle-x-i9YQ1o9T.js rename frontend/dist/assets/{clock-CCOO2GB9.js => clock-F-4SScS_.js} (87%) create mode 100644 frontend/dist/assets/compass-0fhguiKE.js rename frontend/dist/assets/{consumer-registry-B_rYsmHo.js => consumer-registry-5uDLywpC.js} (92%) rename frontend/dist/assets/{cpu-lxveD9wi.js => cpu-BxgsQ0OY.js} (94%) rename frontend/dist/assets/{database-CSUiI1CG.js => database-gsjgeKE3.js} (89%) delete mode 100644 frontend/dist/assets/decryption.worker-0KDkyq11.js create mode 100644 frontend/dist/assets/decryption.worker-CGbIqr1j.js delete mode 100644 frontend/dist/assets/download-BaEmSLqY.js create mode 100644 frontend/dist/assets/easing-BdzuOPcT.js delete mode 100644 frontend/dist/assets/easing-VuIK-HqT.js create mode 100644 frontend/dist/assets/ed25519-AGEPjp-_.js create mode 100644 frontend/dist/assets/element-movement-BD3SL-GU.js delete mode 100644 frontend/dist/assets/element-movement-C8Yd7NWa.js create mode 100644 frontend/dist/assets/fieldset-DCj-Bavz.js create mode 100644 frontend/dist/assets/frozen-D4mEoVft.js rename frontend/dist/assets/{funnel-DOec69-r.js => funnel-CitfWrkD.js} (89%) create mode 100644 frontend/dist/assets/git-branch-DrsZ9sUq.js rename frontend/dist/assets/{hash-fRZDKNyT.js => hash-CyK-Kad6.js} (90%) delete mode 100644 frontend/dist/assets/index-B9Nfzawy.js create mode 100644 frontend/dist/assets/index-BCuGA4PV.js delete mode 100644 frontend/dist/assets/index-BSz_JZ6w.css create mode 100644 frontend/dist/assets/index-CBEGRHd5.js delete mode 100644 frontend/dist/assets/index-CHkxpv0k.js create mode 100644 frontend/dist/assets/index-i0xzpXop.js create mode 100644 frontend/dist/assets/index-oOga43RI.css create mode 100644 frontend/dist/assets/key-round-BpDWKeL5.js rename frontend/dist/assets/{layers-DHyjQOGN.js => layers-LQ5jNXOV.js} (92%) delete mode 100644 frontend/dist/assets/link-scoring-353AdDOu.js create mode 100644 frontend/dist/assets/link-scoring-BqsMOwtz.js create mode 100644 frontend/dist/assets/listbox-C1gGOelh.js delete mode 100644 frontend/dist/assets/listbox-DV2L-QZw.js rename frontend/dist/assets/{map-pin-Z2xK57U6.js => map-pin-C051lstq.js} (93%) create mode 100644 frontend/dist/assets/map-pin-off-CPSqCYZk.js rename frontend/dist/assets/{BasemapLayer-B1CfjdFi.css => maplibre-gl-B1CfjdFi.css} (100%) create mode 100644 frontend/dist/assets/maplibre-gl-B20pCOz8.js rename frontend/dist/assets/{maplibre-gl-DisS89O_.js => maplibre-gl-BcToCqGO.js} (99%) delete mode 100644 frontend/dist/assets/max-BFwmL_H9.js create mode 100644 frontend/dist/assets/max-C_kLXH5u.js rename frontend/dist/assets/{message-square-C9xeBmVh.js => message-square-BzLgyIjH.js} (57%) create mode 100644 frontend/dist/assets/message-square-text-CIgRIHv3.js delete mode 100644 frontend/dist/assets/monitor-smartphone-zVB5GYa6.js rename frontend/dist/assets/{network-BCB-csrZ.js => network-CeKhSsIh.js} (92%) rename frontend/dist/assets/{node-types-D2DQet2e.js => node-types-rVJPSDxd.js} (85%) create mode 100644 frontend/dist/assets/payload-detail-Bh2WvEK0.js create mode 100644 frontend/dist/assets/pencil-8q_J08l4.js delete mode 100644 frontend/dist/assets/ping-kFEBCmQp.js rename frontend/dist/assets/{plus-B7jylh_n.js => plus-Bb8eT78f.js} (86%) delete mode 100644 frontend/dist/assets/primitives-DkuSh1mR.js create mode 100644 frontend/dist/assets/primitives-QKpQyH4U.js delete mode 100644 frontend/dist/assets/refresh-cw-hB3ADAmy.js create mode 100644 frontend/dist/assets/repeat-BSIxXQ81.js delete mode 100644 frontend/dist/assets/repeat-C00vzJTj.js rename frontend/dist/assets/{rotate-ccw-BwcqAp9U.js => rotate-ccw-DqV8JyUZ.js} (61%) create mode 100644 frontend/dist/assets/route-Df1YhBTq.js rename frontend/dist/assets/{search-BrfwwyYC.js => search-DsTk_ZsM.js} (87%) rename frontend/dist/assets/{settings-2-DYzgUEwY.js => settings-2-B0xGzDNd.js} (89%) create mode 100644 frontend/dist/assets/share-2-B5yQaExh.js rename frontend/dist/assets/{shield-5eYUHkwt.js => shield-CxmFjMfw.js} (90%) rename frontend/dist/assets/{shield-check-Bx84Eo-l.js => shield-check-DlsLo8Eo.js} (91%) rename frontend/dist/assets/{system-D2aLg2mB.js => system-Xia4FpjC.js} (91%) rename frontend/dist/assets/{target-74Dm2pEA.js => target-BAeWmUfa.js} (94%) create mode 100644 frontend/dist/assets/thermometer-DhPCT8Cn.js create mode 100644 frontend/dist/assets/topology.worker-CfQt1cXG.js delete mode 100644 frontend/dist/assets/topology.worker-D9nzH303.js rename frontend/dist/assets/{trash-2-BxrPvo_t.js => trash-2-DCqpUdF7.js} (91%) delete mode 100644 frontend/dist/assets/triangle-alert-_KPqiYkd.js create mode 100644 frontend/dist/assets/use-text-value-T4f0bwXS.js create mode 100644 frontend/dist/assets/use-tree-walker-B4ov8RnQ.js rename frontend/dist/assets/{useMapViewStore-CAlaFCdd.js => useMapViewStore-DZlzQmak.js} (86%) create mode 100644 frontend/dist/assets/usePipelineStore-BqTRxIqB.js delete mode 100644 frontend/dist/assets/usePipelineStore-Dto_OrsT.js create mode 100644 frontend/dist/assets/variants-Bbq7uzV_.js create mode 100644 frontend/dist/assets/wand-sparkles-DBzA3PXL.js rename frontend/dist/assets/{webgl-device-QoBMYpnS-BYCL_Wh6.js => webgl-device-QoBMYpnS-D6oZ9mRP.js} (53%) rename frontend/dist/assets/{wifi-BpM3uttU.js => wifi-DYlEDPZY.js} (90%) rename frontend/dist/assets/{wifi-off-DoZXnx54.js => wifi-off-CQ0s_9cO.js} (76%) rename frontend/dist/assets/{zap-DME89Nfc.js => zap-tuTM-Jsw.js} (82%) diff --git a/frontend/dist/VERSION b/frontend/dist/VERSION index 0032cd80..6b8d0d2f 100644 --- a/frontend/dist/VERSION +++ b/frontend/dist/VERSION @@ -1 +1 @@ -0.9.308 +0.9.309 diff --git a/frontend/dist/assets/AnalyzerFilterPanel-DPT1vjKV.js b/frontend/dist/assets/AnalyzerFilterPanel-DPT1vjKV.js new file mode 100644 index 00000000..ca334321 --- /dev/null +++ b/frontend/dist/assets/AnalyzerFilterPanel-DPT1vjKV.js @@ -0,0 +1,14 @@ +import{e as U,c_ as J,ao as q,aa as G,cE as Q,cs as V,r as d,j as n,bM as K,B as Y}from"./index-i0xzpXop.js";import{c as Z}from"./node-types-rVJPSDxd.js";import{C as W}from"./circle-question-mark-CJCLhkb9.js";import{F as ee}from"./funnel-CitfWrkD.js";import{S as te}from"./search-DsTk_ZsM.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 se=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ne=U("circle",se);/** + * @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 oe=[["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"}]],re=U("droplets",oe);function xe(){return{timeStart:null,timeEnd:null,deviceTypes:new Set,nodeIds:new Set,disabledNodeIds:new Set,nodeFilterMode:"source"}}function ae(c,l){const{timeStart:u,timeEnd:t,deviceTypes:o,nodeIds:m,disabledNodeIds:v,nodeFilterMode:w}=c,p=!0,N=o.size>0;let h;if(v.size>0){h=new Set;for(const S of m)v.has(S)||h.add(S)}else h=m;const k=h.size>0;let M=null;return k&&(M=J(h)),{hasTime:p,hasDevice:N,hasNode:k,tStart:u??l.start,tEnd:t??l.end,deviceTypes:o,effectiveNodeIds:h,nodeIdPrefixes:M,nodeFilterMode:w,needsDisambiguation:N||k}}function le(c,l,u){if(c.timestampl.tEnd)return!1;if(l.needsDisambiguation){const t=u(c);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&&c.dst_hash)if(l.effectiveNodeIds.has(c.dst_hash))o=!0;else{const m=q(c.dst_hash);l.nodeIdPrefixes.has(m)&&(o=!0)}if(!o){const m=c.forwarded_path??c.original_path;if(m&&Array.isArray(m))for(const v of m){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(c,l,u,t){const o=ae(l,t);return c.filter(m=>le(m,o,u))}function X(c,l){const u=new Date(c*1e3),t=v=>v.toString().padStart(2,"0"),o=`${t(u.getHours())}:${t(u.getMinutes())}`;return l<24?o:`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][u.getMonth()]} ${u.getDate()} ${o}`}const ie=[{type:"repeater",label:"Repeater",icon:G,buttonColor:"primary",iconColor:"text-sys-blue",hoverClass:"hover:border-sys-blue hover:text-sys-blue hover:!bg-transparent"},{type:"companion",label:"Companion",icon:Q,buttonColor:"indigo",iconColor:"text-sys-indigo",hoverClass:"hover:border-sys-indigo hover:text-sys-indigo hover:!bg-transparent"},{type:"room_server",label:"Room",icon:V,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 de({min:c,max:l,valueStart:u,valueEnd:t,onChange:o}){const m=d.useRef(null),[v,w]=d.useState(null),p=d.useRef({valueStart:u,valueEnd:t,min:c,max:l});p.current={valueStart:u,valueEnd:t,min:c,max:l};const N=d.useRef({offset:0,width:0}),h=l-c||1,k=h/3600,M=u??c,S=t??l,C=(M-c)/h*100,_=(S-c)/h*100,F=u!==null||t!==null,I=d.useCallback(i=>{const a=m.current.getBoundingClientRect(),e=Math.max(0,Math.min(1,(i-a.left)/a.width)),{min:s,max:r}=p.current;return Math.round(s+e*(r-s||1))},[]),P=d.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:x,min:b,max:L}=p.current,z=L-b||1;if(i==="start"){const j=Math.min(g,(x??L)-D);o(j<=b+z*E?null:j,x)}else{const j=Math.max(g,(y??b)+D);o(y,j>=L-z*E?null:j)}},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]),$=d.useCallback(i=>{i.preventDefault(),i.stopPropagation();const a=i.currentTarget;a.setPointerCapture(i.pointerId),w("range");const e=p.current.valueStart??p.current.min,s=p.current.valueEnd??p.current.max;N.current={offset:I(i.clientX)-e,width:s-e};const r=g=>{const y=I(g.clientX),{min:x,max:b}=p.current,{offset:L,width:z}=N.current;let j=y-L;j=Math.max(x,Math.min(b-z,j));const O=j+z;o(Math.round(j)<=x?null:Math.round(j),Math.round(O)>=b?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=d.useCallback(i=>{const a=I(i.clientX),{valueStart:e,valueEnd:s,min:r,max:f}=p.current,g=f-r||1,y=e??r,x=s??f;if(Math.abs(a-y)<=Math.abs(a-x)){const b=Math.min(a,x-D);o(b<=r+g*E?null:b,s)}else{const b=Math.max(a,y+D);o(e,b>=f-g*E?null:b)}},[I,o]),A=d.useCallback(()=>o(null,null),[o]),R=d.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}=p.current,x=y-g||1;if(i==="start"){const b=Math.max(g,Math.min((r??g)+e*s,(f??y)-D));o(b<=g+x*E?null:b,f)}else{const b=Math.min(y,Math.max((f??y)+e*s,(r??g)+D));o(r,b>=y-x*E?null:b)}},[h,o]),T=i=>{const a=i==="start"?u!==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:F&&u!==null?"text-sys-blue":"",children:X(M,k)}),n.jsx("span",{className:F&&t!==null?"text-sys-blue":"",children:X(S,k)})]}),n.jsxs("div",{ref:m,className:"relative h-5 select-none",onPointerDown:H,onDoubleClick:A,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"}),F?n.jsx("div",{className:["group/band absolute inset-y-0 touch-none",v==="range"?"cursor-grabbing":"cursor-grab"].join(" "),style:{left:`${C}%`,right:`${100-_}%`},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":M,className:T("start"),style:{left:`${C}%`},onPointerDown:i=>P("start",i),onKeyDown:i=>R("start",i)}),n.jsx("div",{role:"slider",tabIndex:0,"aria-label":"Range end","aria-valuenow":S,className:T("end"),style:{left:`${_}%`},onPointerDown:i=>P("end",i),onKeyDown:i=>R("end",i)})]})]})}function fe({parentStartTs:c,parentEndTs:l,neighbors:u,filter:t,onChange:o,scatterDotSize:m,onScatterDotSizeChange:v,scatterOpacity:w,onScatterOpacityChange:p}){const[N,h]=d.useState(""),[k,M]=d.useState(!1),S=d.useRef(null);d.useEffect(()=>{function e(s){S.current&&!S.current.contains(s.target)&&M(!1)}if(k)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[k]);const C=d.useMemo(()=>Object.entries(u).map(([e,s])=>{const r=Z(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)),[u]),_=d.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]),F=t.timeStart!==null||t.timeEnd!==null||t.deviceTypes.size>0||t.nodeIds.size>0,I=d.useCallback((e,s)=>{o({...t,timeStart:e,timeEnd:s})},[t,o]),P=d.useCallback(e=>{const s=new Set(t.deviceTypes);s.has(e)?s.delete(e):s.add(e),o({...t,deviceTypes:s})},[t,o]),$=d.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=d.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]),A=d.useCallback(e=>{const s=new Set(t.disabledNodeIds);s.has(e)?s.delete(e):s.add(e),o({...t,disabledNodeIds:s})},[t,o]),R=d.useCallback(()=>{o({...t,nodeFilterMode:t.nodeFilterMode==="source"?"observed":"source"})},[t,o]),T=d.useCallback(()=>{o({timeStart:null,timeEnd:null,deviceTypes:new Set,nodeIds:new Set,disabledNodeIds:new Set,nodeFilterMode:"source"}),h("")},[o]),i=d.useMemo(()=>{const e=new Map;for(const s of t.nodeIds){const r=u[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,u]),a=!!(v&&p);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(ne,{className:"w-3 h-3"}),label:"Size",value:m??.8,onChange:v,min:.3,max:3,step:.1,format:e=>e.toFixed(1)}),n.jsx(B,{icon:n.jsx(re,{className:"w-3 h-3"}),label:"Opacity",value:w??50,onChange:p,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(ee,{className:"w-3.5 h-3.5"})}),n.jsx("div",{className:"flex-1 min-w-[120px]",children:n.jsx(de,{min:c,max:l,valueStart:t.timeStart,valueEnd:t.timeEnd,onChange:I})}),F&&n.jsxs("button",{type:"button",onClick:T,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:ie.map(({type:e,label:s,icon:r,buttonColor:f,iconColor:g,hoverClass:y})=>{const x=t.deviceTypes.has(e);return n.jsxs(Y,{color:x?f:"zinc",outline:!x,className:`!h-8 !py-0 ${x?"":y}`,onClick:()=>P(e),title:`Filter by ${s}`,children:[n.jsx(r,{"data-slot":"icon",className:x?"":g}),n.jsx("span",{className:`hidden sm:inline ${x?"":"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:S,children:[n.jsx(te,{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),M(!0)},onFocus:()=>M(!0)}),k&&_.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:_.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:()=>A(e),onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),A(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:R,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=d.memo(function({icon:l,label:u,value:t,onChange:o,min:m,max:v,step:w,format:p}){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:u})]}),n.jsx("input",{type:"range",min:m,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:p?p(t):t})]})});export{fe as A,ie as D,he as a,de as b,xe as c}; diff --git a/frontend/dist/assets/AnalyzerFilterPanel-DX4fviv1.js b/frontend/dist/assets/AnalyzerFilterPanel-DX4fviv1.js deleted file mode 100644 index d657f7c7..00000000 --- a/frontend/dist/assets/AnalyzerFilterPanel-DX4fviv1.js +++ /dev/null @@ -1,14 +0,0 @@ -import{d as U,am as J,a8 as q,ck as G,r as d,j as n,bK as K,B as Q}from"./index-B9Nfzawy.js";import{c as V}from"./node-types-D2DQet2e.js";import{M as Y}from"./monitor-smartphone-zVB5GYa6.js";import{C as Z}from"./circle-question-mark-Br2ku42v.js";import{F as W}from"./funnel-DOec69-r.js";import{S as ee}from"./search-BrfwwyYC.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 te=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],se=U("circle",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:"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(c,l){const{timeStart:u,timeEnd:t,deviceTypes:o,nodeIds:x,disabledNodeIds:v,nodeFilterMode:w}=c,m=!0,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:u??l.start,tEnd:t??l.end,deviceTypes:o,effectiveNodeIds:h,nodeIdPrefixes:k,nodeFilterMode:w,needsDisambiguation:N||S}}function ae(c,l,u){if(c.timestampl.tEnd)return!1;if(l.needsDisambiguation){const t=u(c);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&&c.dst_hash&&(l.effectiveNodeIds.has(c.dst_hash)||l.nodeIdPrefixes.has(J(c.dst_hash)))&&(o=!0),!o){const x=c.forwarded_path??c.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(c,l,u,t){const o=re(l,t);return c.filter(x=>ae(x,o,u))}function X(c,l){const u=new Date(c*1e3),t=v=>v.toString().padStart(2,"0"),o=`${t(u.getHours())}:${t(u.getMinutes())}`;return l<24?o:`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][u.getMonth()]} ${u.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:Y,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:Z,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:c,max:l,valueStart:u,valueEnd:t,onChange:o}){const x=d.useRef(null),[v,w]=d.useState(null),m=d.useRef({valueStart:u,valueEnd:t,min:c,max:l});m.current={valueStart:u,valueEnd:t,min:c,max:l};const N=d.useRef({offset:0,width:0}),h=l-c||1,S=h/3600,k=u??c,j=t??l,C=(k-c)/h*100,F=(j-c)/h*100,_=u!==null||t!==null,I=d.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))},[]),A=d.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]),$=d.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=d.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=d.useCallback(()=>o(null,null),[o]),T=d.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"?u!==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:_&&u!==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=>A("start",i),onKeyDown:i=>T("start",i)}),n.jsx("div",{role:"slider",tabIndex:0,"aria-label":"Range end","aria-valuenow":j,className:P("end"),style:{left:`${F}%`},onPointerDown:i=>A("end",i),onKeyDown:i=>T("end",i)})]})]})}function fe({parentStartTs:c,parentEndTs:l,neighbors:u,filter:t,onChange:o,scatterDotSize:x,onScatterDotSizeChange:v,scatterOpacity:w,onScatterOpacityChange:m}){const[N,h]=d.useState(""),[S,k]=d.useState(!1),j=d.useRef(null);d.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=d.useMemo(()=>Object.entries(u).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)),[u]),F=d.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=d.useCallback((e,s)=>{o({...t,timeStart:e,timeEnd:s})},[t,o]),A=d.useCallback(e=>{const s=new Set(t.deviceTypes);s.has(e)?s.delete(e):s.add(e),o({...t,deviceTypes:s})},[t,o]),$=d.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=d.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=d.useCallback(e=>{const s=new Set(t.disabledNodeIds);s.has(e)?s.delete(e):s.add(e),o({...t,disabledNodeIds:s})},[t,o]),T=d.useCallback(()=>{o({...t,nodeFilterMode:t.nodeFilterMode==="source"?"observed":"source"})},[t,o]),P=d.useCallback(()=>{o({timeStart:null,timeEnd:null,deviceTypes:new Set,nodeIds:new Set,disabledNodeIds:new Set,nodeFilterMode:"source"}),h("")},[o]),i=d.useMemo(()=>{const e=new Map;for(const s of t.nodeIds){const r=u[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,u]),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(W,{className:"w-3.5 h-3.5"})}),n.jsx("div",{className:"flex-1 min-w-[120px]",children:n.jsx(ie,{min:c,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:()=>A(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:T,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=d.memo(function({icon:l,label:u,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:u})]}),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,le as D,he as a,ie as b,xe as c}; diff --git a/frontend/dist/assets/AutoConfigureDialog-C9ytM4jL.js b/frontend/dist/assets/AutoConfigureDialog-C9ytM4jL.js new file mode 100644 index 00000000..065e568e --- /dev/null +++ b/frontend/dist/assets/AutoConfigureDialog-C9ytM4jL.js @@ -0,0 +1 @@ +import{r as f,ef as Q,j as e,a7 as X,aa as Z,c3 as M,cs as U,cE as V,ew as G,eB as ee,aC as ae,aK as se,aD as te,a2 as J,bY as ne,B as w,c as g,aE as le}from"./index-i0xzpXop.js";import{C as ie}from"./PageLayout-B4RCJ-XT.js";import{W as re}from"./wand-sparkles-DBzA3PXL.js";import{A as oe}from"./arrow-right-BZS-u7CW.js";const ce={0:"1-byte",1:"2-byte",2:"3-byte"};function de(s){return ce[s]??`${s+1}-byte`}function ke({nodeName:s,publicKey:a,pathHashMode:r}){const[c,n]=f.useState(null),[o,m]=f.useState(null);f.useEffect(()=>{let l=!1;return(async()=>{try{const p=await Q();if(l)return;if(p.success&&p.data){const h=p.data;n(Array.isArray(h.configured)?h.configured:[]),m(Array.isArray(h.configured_companions)?h.configured_companions:[])}}catch{}})(),()=>{l=!0}},[]);const y=l=>{var p;return((p=l.settings)==null?void 0:p.node_name)||l.name};return e.jsxs(ie,{neomorphic:!0,children:[e.jsx(X,{icon:e.jsx(Z,{}),title:"Node Information"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4 sm:gap-6",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-fg-secondary",children:"Repeater Name"}),e.jsx("div",{className:"mt-0.5 sm:mt-1 space-y-2",children:e.jsxs("div",{children:[e.jsx("p",{className:"type-data text-fg-primary truncate font-mono",title:s,children:s}),a&&e.jsx("div",{className:"mt-1 min-w-0",children:e.jsx(M,{copy:!0,truncate:"css",className:"w-full",size:"responsive",children:a})})]})}),r!=null&&e.jsxs("div",{className:"mt-4",children:[e.jsx("span",{className:"type-label text-fg-secondary",children:"Path Hash Size"}),e.jsx("p",{className:"type-data text-fg-primary mt-0.5 font-mono",children:de(r)})]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-fg-secondary",children:"Room Servers"}),e.jsx("div",{className:"mt-0.5 sm:mt-1 space-y-2",children:c===null?e.jsx("span",{className:"type-data text-fg-muted",children:"—"}):c.length===0?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(U,{className:"w-3.5 h-3.5 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-muted",children:"None"})]}):c.map(l=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(U,{className:"w-3.5 h-3.5 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-primary truncate",title:y(l),children:y(l)})]}),(l.public_key||l.identity_key)&&e.jsx("div",{className:"mt-1 pl-5 min-w-0",children:e.jsx(M,{copy:!0,truncate:"css",className:"w-full",size:"responsive",children:l.public_key||l.identity_key})})]},l.name))})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-fg-secondary",children:"Companions"}),e.jsx("div",{className:"mt-0.5 sm:mt-1 space-y-2",children:o===null?e.jsx("span",{className:"type-data text-fg-muted",children:"—"}):o.length===0?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(V,{className:"w-3.5 h-3.5 text-sys-cyan flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-muted",children:"None"})]}):o.map(l=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(V,{className:"w-3.5 h-3.5 text-sys-cyan flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-primary truncate",title:y(l),children:y(l)})]}),(l.public_key||l.identity_key)&&e.jsx("div",{className:"mt-1 pl-5 min-w-0",children:e.jsx(M,{copy:!0,truncate:"css",className:"w-full",size:"responsive",children:l.public_key||l.identity_key})})]},l.name))})]})]})]})}const j=168,S={sparse:50,light:200,moderate:500,dense:1e3},me={sparse:{bucketCapacity:3,refillTokens:1,refillIntervalHours:1,minIntervalSeconds:15,violationThreshold:2,basePenaltyMinutes:30,penaltyMultiplier:2,maxPenaltyHours:12,violationDecayHours:2,ewmaAlpha:.15,hysteresisMinutes:8},light:{bucketCapacity:2,refillTokens:1,refillIntervalHours:1,minIntervalSeconds:20,violationThreshold:2,basePenaltyMinutes:60,penaltyMultiplier:3,maxPenaltyHours:24,violationDecayHours:2,ewmaAlpha:.12,hysteresisMinutes:6},moderate:{bucketCapacity:2,refillTokens:1,refillIntervalHours:2,minIntervalSeconds:30,violationThreshold:1,basePenaltyMinutes:120,penaltyMultiplier:4,maxPenaltyHours:48,violationDecayHours:4,ewmaAlpha:.1,hysteresisMinutes:5},dense:{bucketCapacity:1,refillTokens:1,refillIntervalHours:4,minIntervalSeconds:60,violationThreshold:1,basePenaltyMinutes:180,penaltyMultiplier:4,maxPenaltyHours:72,violationDecayHours:6,ewmaAlpha:.08,hysteresisMinutes:3},congested:{bucketCapacity:1,refillTokens:1,refillIntervalHours:8,minIntervalSeconds:120,violationThreshold:1,basePenaltyMinutes:360,penaltyMultiplier:4,maxPenaltyHours:168,violationDecayHours:12,ewmaAlpha:.03,hysteresisMinutes:2}};function pe(s){return si.type===4))==null?void 0:h.count)??0,c=a.drop_reasons??[],n=((N=c.find(i=>i.reason==="advert rate limit exceeded"))==null?void 0:N.count)??0,o=c.filter(i=>i.reason.startsWith("advert penalty box")).reduce((i,d)=>i+d.count,0),m=((_=c.find(i=>i.reason==="Duplicate"))==null?void 0:_.count)??0;let y=0;try{const i=await G("/api/advert_rate_limit_stats");i.success&&i.data&&(y=i.data.tracked_pubkeys??Object.keys(i.data.bucket_states??{}).length)}catch{y=Math.max(1,Math.round(r/j/12))}const l=a.total_packets/j,p=r/j;return{hours:j,totalPackets:a.total_packets,transmittedPackets:a.transmitted_packets,droppedPackets:a.dropped_packets,packetsPerHour:l,advertsPerHour:p,advertPercent:a.total_packets>0?r/a.total_packets*100:0,advertCount:r,trackedSources:Math.max(1,y),advertsPerSourcePerHour:p/Math.max(1,y),rateLimitDrops:n,penaltyBoxDrops:o,duplicateDrops:m,meshDensity:pe(l)}}function ue(s){const a=me[s.meshDensity],r=s.packetsPerHour/60,c=Math.max(.01,B(r*.2)),n=Math.max(c+.01,B(r*.5)),o=Math.max(n+.01,B(r*.9));return{tokenBucket:{enabled:!0,bucket_capacity:a.bucketCapacity,refill_tokens:a.refillTokens,refill_interval_seconds:a.refillIntervalHours*3600,min_interval_seconds:a.minIntervalSeconds},penaltyBox:{enabled:!0,violation_threshold:a.violationThreshold,base_penalty_seconds:a.basePenaltyMinutes*60,penalty_multiplier:a.penaltyMultiplier,max_penalty_seconds:a.maxPenaltyHours*3600,violation_decay_seconds:a.violationDecayHours*3600},adaptive:{enabled:!0,ewma_alpha:a.ewmaAlpha,hysteresis_seconds:a.hysteresisMinutes*60,thresholds:{quiet_max:c,normal_max:n,busy_max:o}}}}async function ye(s){const a=await xe(),r=ue(a);return{analysis:a,recommended:r,current:{tokenBucket:s.tokenBucket??null,penaltyBox:s.penaltyBox??null,adaptive:s.adaptive??null}}}function B(s){return Math.round(s*100)/100}function k(s){if(s<60)return`${s}s`;if(s<3600)return`${Math.floor(s/60)}m`;const a=s/3600;return a===Math.floor(a)?`${a}h`:`${a.toFixed(1)}h`}function A(s){return s.toLocaleString(void 0,{maximumFractionDigits:1})}const he={sparse:"Sparse",light:"Light",moderate:"Moderate",dense:"Dense",congested:"Congested"},fe={sparse:"text-sys-green",light:"text-sys-cyan",moderate:"text-sys-blue",dense:"text-sys-amber",congested:"text-sys-red"},ge={rate_limit_enabled:!1,bucket_capacity:10,refill_tokens:5,refill_interval_seconds:3600,min_interval_seconds:0,penalty_enabled:!1,violation_threshold:5,base_penalty_seconds:1800,penalty_multiplier:2,max_penalty_seconds:86400,violation_decay_seconds:21600,adaptive_enabled:!1,ewma_alpha:.1,hysteresis_seconds:300,quiet_max:2,normal_max:6,busy_max:10},Ne=["rate_limit_enabled","bucket_capacity","refill_tokens","refill_interval_seconds","min_interval_seconds","penalty_enabled","violation_threshold","base_penalty_seconds","penalty_multiplier","max_penalty_seconds","violation_decay_seconds","adaptive_enabled","ewma_alpha","hysteresis_seconds","quiet_max","normal_max","busy_max"];function D({title:s,enabled:a,defaultOpen:r=!1,children:c}){const[n,o]=f.useState(r);return e.jsxs("div",{className:"bg-subtle-fill radius-inner overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>o(!n),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-subtle-fill-hover transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"type-label text-fg-muted",children:s}),e.jsx("span",{className:g("type-data-xs px-1.5 py-0.5 rounded-full font-medium uppercase tracking-wide",a?"bg-sys-green/15 text-sys-green":"bg-sys-red/15 text-sys-red"),children:a?"On":"Off"})]}),e.jsx(le,{className:g("w-4 h-4 text-fg-muted transition-transform",n&&"rotate-180")})]}),n&&e.jsx("div",{className:"px-4 pb-4 pt-1 space-y-1",children:c})]})}function u({label:s,current:a,recommended:r,format:c=n=>String(n)}){const n=a!=null?c(a):"—",o=c(r),m=a!=null&&n!==o;return e.jsxs("div",{className:"flex items-center justify-between gap-2 py-1",children:[e.jsx("span",{className:"type-body-sm text-fg-muted flex-1 min-w-0 truncate",children:s}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("span",{className:g("data-box data-box-compact",m?"text-fg-muted line-through opacity-60":"text-fg-secondary"),children:n}),m&&e.jsxs(e.Fragment,{children:[e.jsx(oe,{className:"w-3 h-3 text-fg-muted"}),e.jsx("span",{className:"data-box data-box-compact text-sys-blue font-medium",children:o})]})]})]})}function we({open:s,onClose:a,currentConfig:r,onApplied:c}){var C,H,P,T,I,R,E,L,$,z,F,O,q,Y;const[n,o]=f.useState("idle"),[m,y]=f.useState(null),[l,p]=f.useState(null),h=f.useCallback(async()=>{o("analyzing"),p(null);try{const t=await ye(r);y(t),o("ready")}catch(t){p(t instanceof Error?t.message:"Analysis failed"),o("error")}},[r]),N=f.useCallback(async()=>{if(!m)return;o("applying"),p(null);const{tokenBucket:t,penaltyBox:b,adaptive:v}=m.recommended,K={rate_limit_enabled:t.enabled,bucket_capacity:t.bucket_capacity,refill_tokens:t.refill_tokens,refill_interval_seconds:t.refill_interval_seconds,min_interval_seconds:t.min_interval_seconds,penalty_enabled:b.enabled,violation_threshold:b.violation_threshold,base_penalty_seconds:b.base_penalty_seconds,penalty_multiplier:b.penalty_multiplier,max_penalty_seconds:b.max_penalty_seconds,violation_decay_seconds:b.violation_decay_seconds,adaptive_enabled:v.enabled,ewma_alpha:v.ewma_alpha,hysteresis_seconds:v.hysteresis_seconds,quiet_max:v.thresholds.quiet_max,normal_max:v.thresholds.normal_max,busy_max:v.thresholds.busy_max};try{const W=await ee(K);W.success?(o("applied"),c==null||c()):(p(W.error||"Failed to apply settings"),o("error"))}catch{p("Failed to apply settings"),o("error")}},[m,c]),_=f.useCallback(()=>{a(),setTimeout(()=>{o("idle"),y(null),p(null)},300)},[a]);s&&n==="idle"&&h();const i=m==null?void 0:m.analysis,d=m==null?void 0:m.recommended,x=m==null?void 0:m.current;return e.jsxs(ae,{open:s,onClose:_,size:"lg",children:[e.jsx(se,{icon:e.jsx(re,{size:20}),title:"Auto-Configure",onClose:_}),e.jsxs(te,{className:"flex flex-col gap-5 max-h-[70vh] overflow-y-auto",children:[n==="analyzing"&&e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-12",children:[e.jsx(J,{className:"w-6 h-6 text-sys-blue animate-spin"}),e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Analyzing 7 days of mesh traffic…"})]}),n==="error"&&e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-8",children:[e.jsx(ne,{className:"w-6 h-6 text-sys-amber"}),e.jsx("p",{className:"type-body-sm text-fg-secondary",children:l}),e.jsx(w,{plain:!0,onClick:h,className:"text-sys-blue",children:"Retry"})]}),(n==="ready"||n==="applying"||n==="applied")&&i&&d&&x&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("div",{className:"type-micro mb-3",children:"7-DAY ANALYSIS"}),e.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"data-box-label",children:"Pkts/hr"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:A(i.packetsPerHour)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"data-box-label",children:"Adverts/hr"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:A(i.advertsPerHour)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"data-box-label",children:"Sources"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:i.trackedSources})]}),e.jsxs("div",{children:[e.jsx("div",{className:"data-box-label",children:"Density"}),e.jsx("div",{className:g("data-box data-box-fill data-box-left",fe[i.meshDensity]),children:he[i.meshDensity]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(D,{title:"Token Bucket of Shame",enabled:d.tokenBucket.enabled,defaultOpen:!0,children:[e.jsx(u,{label:"Bucket Capacity",current:(C=x.tokenBucket)==null?void 0:C.bucket_capacity,recommended:d.tokenBucket.bucket_capacity,format:t=>`${t} tokens`}),e.jsx(u,{label:"Refill Tokens",current:(H=x.tokenBucket)==null?void 0:H.refill_tokens,recommended:d.tokenBucket.refill_tokens,format:t=>`${t} tokens`}),e.jsx(u,{label:"Refill Interval",current:(P=x.tokenBucket)==null?void 0:P.refill_interval_seconds,recommended:d.tokenBucket.refill_interval_seconds,format:t=>k(t)}),e.jsx(u,{label:"Min Interval",current:(T=x.tokenBucket)==null?void 0:T.min_interval_seconds,recommended:d.tokenBucket.min_interval_seconds,format:t=>`${t}s`})]}),e.jsxs(D,{title:"Jail",enabled:d.penaltyBox.enabled,children:[e.jsx(u,{label:"Violation Threshold",current:(I=x.penaltyBox)==null?void 0:I.violation_threshold,recommended:d.penaltyBox.violation_threshold,format:t=>`${t} violations`}),e.jsx(u,{label:"Base Penalty",current:(R=x.penaltyBox)==null?void 0:R.base_penalty_seconds,recommended:d.penaltyBox.base_penalty_seconds,format:t=>k(t)}),e.jsx(u,{label:"Multiplier",current:(E=x.penaltyBox)==null?void 0:E.penalty_multiplier,recommended:d.penaltyBox.penalty_multiplier,format:t=>`${t}×`}),e.jsx(u,{label:"Max Penalty",current:(L=x.penaltyBox)==null?void 0:L.max_penalty_seconds,recommended:d.penaltyBox.max_penalty_seconds,format:t=>k(t)}),e.jsx(u,{label:"Violation Decay",current:($=x.penaltyBox)==null?void 0:$.violation_decay_seconds,recommended:d.penaltyBox.violation_decay_seconds,format:t=>k(t)})]}),e.jsxs(D,{title:"Adaptive Tiers",enabled:d.adaptive.enabled,children:[e.jsx(u,{label:"EWMA α",current:(z=x.adaptive)==null?void 0:z.ewma_alpha,recommended:d.adaptive.ewma_alpha}),e.jsx(u,{label:"Hysteresis",current:(F=x.adaptive)==null?void 0:F.hysteresis_seconds,recommended:d.adaptive.hysteresis_seconds,format:t=>k(t)}),e.jsx(u,{label:"Quiet Max",current:(O=x.adaptive)==null?void 0:O.thresholds.quiet_max,recommended:d.adaptive.thresholds.quiet_max,format:t=>`${t} pkts/min`}),e.jsx(u,{label:"Normal Max",current:(q=x.adaptive)==null?void 0:q.thresholds.normal_max,recommended:d.adaptive.thresholds.normal_max,format:t=>`${t} pkts/min`}),e.jsx(u,{label:"Busy Max",current:(Y=x.adaptive)==null?void 0:Y.thresholds.busy_max,recommended:d.adaptive.thresholds.busy_max,format:t=>`${t} pkts/min`})]})]}),e.jsxs("div",{className:g("flex justify-between gap-4 pt-1",n==="applied"?"items-center":"items-end"),children:[n==="applied"?e.jsx("span",{className:"type-body-sm text-zinc-500",children:"Settings applied"}):e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Analyzed"}),e.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[A(i.totalPackets)," packets"]})]}),e.jsx("div",{className:"flex items-center gap-2",children:n==="applied"?e.jsx(w,{color:"primary",onClick:_,children:"Done"}):e.jsxs(e.Fragment,{children:[e.jsx(w,{plain:!0,onClick:_,children:"Cancel"}),e.jsx(w,{color:"primary",onClick:N,disabled:n==="applying",children:n==="applying"?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(J,{className:"w-4 h-4 animate-spin"}),"Applying…"]}):"Apply All"})]})})]})]})]})]})}export{we as A,ke as N,ge as S,Ne as a}; diff --git a/frontend/dist/assets/AutoConfigureDialog-D-tiCDMu.js b/frontend/dist/assets/AutoConfigureDialog-D-tiCDMu.js deleted file mode 100644 index 892d0a13..00000000 --- a/frontend/dist/assets/AutoConfigureDialog-D-tiCDMu.js +++ /dev/null @@ -1,6 +0,0 @@ -import{d as J,j as e,a5 as V,a8 as X,dh as W,ec as U,r as h,ei as Z,aA as ee,aI as ae,aB as te,a0 as G,B as M,c as k,aC as se}from"./index-B9Nfzawy.js";import{C as le}from"./PageLayout-Da0xfaXb.js";import{D as K}from"./DataBox-CCBd3sT4.js";import{T as ne}from"./triangle-alert-_KPqiYkd.js";import{A as re}from"./arrow-right-BbRfzTpf.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 ie=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],oe=J("wand-sparkles",ie);function je({nodeName:s,repeaterVersion:a,coreVersion:r,localHash:o,publicKey:l}){return e.jsxs(le,{neomorphic:!0,children:[e.jsx(V,{icon:e.jsx(X,{}),title:"Node Information"}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3 sm:gap-4",children:[e.jsxs("div",{className:"min-w-0 col-span-2 sm:col-span-1",children:[e.jsx("span",{className:"type-label text-fg-secondary",children:"Node Name"}),e.jsx("p",{className:"type-body text-fg-primary mt-0.5 sm:mt-1 truncate",title:s,children:s})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-fg-secondary",children:"Repeater"}),e.jsxs("p",{className:"type-data text-fg-primary mt-0.5 sm:mt-1 truncate",title:`v${a}`,children:["v",a]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-fg-secondary",children:"Core"}),e.jsxs("p",{className:"type-data text-fg-primary mt-0.5 sm:mt-1 truncate",title:`v${r}`,children:["v",r]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-fg-secondary",children:"Console"}),e.jsxs("p",{className:"type-data text-fg-primary mt-0.5 sm:mt-1 truncate",title:`v${W}`,children:["v",W]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-fg-secondary",children:"Local Hash"}),e.jsx("div",{className:"mt-0.5 sm:mt-1",children:o?e.jsx(K,{copy:!0,size:"compact",children:o}):e.jsx("span",{className:"type-data-sm text-fg-secondary",children:"N/A"})})]})]}),l&&e.jsxs("div",{className:"mt-3 sm:mt-4 pt-3 sm:pt-4 border-t border-edge-subtle",children:[e.jsx("span",{className:"type-label text-fg-secondary",children:"Public Key"}),e.jsx("div",{className:"mt-0.5 sm:mt-1",children:e.jsx(K,{copy:!0,size:"responsive",children:l})})]})]})}const v=168,w={sparse:50,light:200,moderate:500,dense:1e3},ce={sparse:{bucketCapacity:3,refillTokens:1,refillIntervalHours:1,minIntervalSeconds:15,violationThreshold:2,basePenaltyMinutes:30,penaltyMultiplier:2,maxPenaltyHours:12,violationDecayHours:2,ewmaAlpha:.15,hysteresisMinutes:8},light:{bucketCapacity:2,refillTokens:1,refillIntervalHours:1,minIntervalSeconds:20,violationThreshold:2,basePenaltyMinutes:60,penaltyMultiplier:3,maxPenaltyHours:24,violationDecayHours:2,ewmaAlpha:.12,hysteresisMinutes:6},moderate:{bucketCapacity:2,refillTokens:1,refillIntervalHours:2,minIntervalSeconds:30,violationThreshold:1,basePenaltyMinutes:120,penaltyMultiplier:4,maxPenaltyHours:48,violationDecayHours:4,ewmaAlpha:.1,hysteresisMinutes:5},dense:{bucketCapacity:1,refillTokens:1,refillIntervalHours:4,minIntervalSeconds:60,violationThreshold:1,basePenaltyMinutes:180,penaltyMultiplier:4,maxPenaltyHours:72,violationDecayHours:6,ewmaAlpha:.08,hysteresisMinutes:3},congested:{bucketCapacity:1,refillTokens:1,refillIntervalHours:8,minIntervalSeconds:120,violationThreshold:1,basePenaltyMinutes:360,penaltyMultiplier:4,maxPenaltyHours:168,violationDecayHours:12,ewmaAlpha:.03,hysteresisMinutes:2}};function de(s){return sn.type===4))==null?void 0:b.count)??0,o=a.drop_reasons??[],l=((N=o.find(n=>n.reason==="advert rate limit exceeded"))==null?void 0:N.count)??0,c=o.filter(n=>n.reason.startsWith("advert penalty box")).reduce((n,i)=>n+i.count,0),d=((y=o.find(n=>n.reason==="Duplicate"))==null?void 0:y.count)??0;let u=0;try{const n=await U("/api/advert_rate_limit_stats");n.success&&n.data&&(u=n.data.tracked_pubkeys??Object.keys(n.data.bucket_states??{}).length)}catch{u=Math.max(1,Math.round(r/v/12))}const g=a.total_packets/v,x=r/v;return{hours:v,totalPackets:a.total_packets,transmittedPackets:a.transmitted_packets,droppedPackets:a.dropped_packets,packetsPerHour:g,advertsPerHour:x,advertPercent:a.total_packets>0?r/a.total_packets*100:0,advertCount:r,trackedSources:Math.max(1,u),advertsPerSourcePerHour:x/Math.max(1,u),rateLimitDrops:l,penaltyBoxDrops:c,duplicateDrops:d,meshDensity:de(g)}}function pe(s){const a=ce[s.meshDensity],r=s.packetsPerHour/60,o=Math.max(.01,S(r*.2)),l=Math.max(o+.01,S(r*.5)),c=Math.max(l+.01,S(r*.9));return{tokenBucket:{enabled:!0,bucket_capacity:a.bucketCapacity,refill_tokens:a.refillTokens,refill_interval_seconds:a.refillIntervalHours*3600,min_interval_seconds:a.minIntervalSeconds},penaltyBox:{enabled:!0,violation_threshold:a.violationThreshold,base_penalty_seconds:a.basePenaltyMinutes*60,penalty_multiplier:a.penaltyMultiplier,max_penalty_seconds:a.maxPenaltyHours*3600,violation_decay_seconds:a.violationDecayHours*3600},adaptive:{enabled:!0,ewma_alpha:a.ewmaAlpha,hysteresis_seconds:a.hysteresisMinutes*60,thresholds:{quiet_max:o,normal_max:l,busy_max:c}}}}async function xe(s){const a=await me(),r=pe(a);return{analysis:a,recommended:r,current:{tokenBucket:s.tokenBucket??null,penaltyBox:s.penaltyBox??null,adaptive:s.adaptive??null}}}function S(s){return Math.round(s*100)/100}function j(s){if(s<60)return`${s}s`;if(s<3600)return`${Math.floor(s/60)}m`;const a=s/3600;return a===Math.floor(a)?`${a}h`:`${a.toFixed(1)}h`}function B(s){return s.toLocaleString(void 0,{maximumFractionDigits:1})}const ue={sparse:"Sparse",light:"Light",moderate:"Moderate",dense:"Dense",congested:"Congested"},ye={sparse:"text-sys-green",light:"text-sys-cyan",moderate:"text-sys-blue",dense:"text-sys-amber",congested:"text-sys-red"},ke={rate_limit_enabled:!1,bucket_capacity:10,refill_tokens:5,refill_interval_seconds:3600,min_interval_seconds:0,penalty_enabled:!1,violation_threshold:5,base_penalty_seconds:1800,penalty_multiplier:2,max_penalty_seconds:86400,violation_decay_seconds:21600,adaptive_enabled:!1,ewma_alpha:.1,hysteresis_seconds:300,quiet_max:2,normal_max:6,busy_max:10},ge=["rate_limit_enabled","bucket_capacity","refill_tokens","refill_interval_seconds","min_interval_seconds","penalty_enabled","violation_threshold","base_penalty_seconds","penalty_multiplier","max_penalty_seconds","violation_decay_seconds","adaptive_enabled","ewma_alpha","hysteresis_seconds","quiet_max","normal_max","busy_max"];function D({title:s,enabled:a,defaultOpen:r=!1,children:o}){const[l,c]=h.useState(r);return e.jsxs("div",{className:"bg-subtle-fill radius-inner overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>c(!l),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-subtle-fill-hover transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"type-label text-fg-muted",children:s}),e.jsx("span",{className:k("type-data-xs px-1.5 py-0.5 rounded-full font-medium uppercase tracking-wide",a?"bg-sys-green/15 text-sys-green":"bg-sys-red/15 text-sys-red"),children:a?"On":"Off"})]}),e.jsx(se,{className:k("w-4 h-4 text-fg-muted transition-transform",l&&"rotate-180")})]}),l&&e.jsx("div",{className:"px-4 pb-4 pt-1 space-y-1",children:o})]})}function p({label:s,current:a,recommended:r,format:o=l=>String(l)}){const l=a!=null?o(a):"—",c=o(r),d=a!=null&&l!==c;return e.jsxs("div",{className:"flex items-center justify-between gap-2 py-1",children:[e.jsx("span",{className:"type-body-sm text-fg-muted flex-1 min-w-0 truncate",children:s}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("span",{className:k("data-box data-box-compact",d?"text-fg-muted line-through opacity-60":"text-fg-secondary"),children:l}),d&&e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"w-3 h-3 text-fg-muted"}),e.jsx("span",{className:"data-box data-box-compact text-sys-blue font-medium",children:c})]})]})]})}function Ne({open:s,onClose:a,currentConfig:r,onApplied:o}){var C,A,H,P,T,I,R,L,$,E,z,F,O,q;const[l,c]=h.useState("idle"),[d,u]=h.useState(null),[g,x]=h.useState(null),b=h.useCallback(async()=>{c("analyzing"),x(null);try{const t=await xe(r);u(t),c("ready")}catch(t){x(t instanceof Error?t.message:"Analysis failed"),c("error")}},[r]),N=h.useCallback(async()=>{if(!d)return;c("applying"),x(null);const{tokenBucket:t,penaltyBox:_,adaptive:f}=d.recommended,Q={rate_limit_enabled:t.enabled,bucket_capacity:t.bucket_capacity,refill_tokens:t.refill_tokens,refill_interval_seconds:t.refill_interval_seconds,min_interval_seconds:t.min_interval_seconds,penalty_enabled:_.enabled,violation_threshold:_.violation_threshold,base_penalty_seconds:_.base_penalty_seconds,penalty_multiplier:_.penalty_multiplier,max_penalty_seconds:_.max_penalty_seconds,violation_decay_seconds:_.violation_decay_seconds,adaptive_enabled:f.enabled,ewma_alpha:f.ewma_alpha,hysteresis_seconds:f.hysteresis_seconds,quiet_max:f.thresholds.quiet_max,normal_max:f.thresholds.normal_max,busy_max:f.thresholds.busy_max};try{const Y=await Z(Q);Y.success?(c("applied"),o==null||o()):(x(Y.error||"Failed to apply settings"),c("error"))}catch{x("Failed to apply settings"),c("error")}},[d,o]),y=h.useCallback(()=>{a(),setTimeout(()=>{c("idle"),u(null),x(null)},300)},[a]);s&&l==="idle"&&b();const n=d==null?void 0:d.analysis,i=d==null?void 0:d.recommended,m=d==null?void 0:d.current;return e.jsxs(ee,{open:s,onClose:y,size:"lg",children:[e.jsx(ae,{icon:e.jsx(oe,{size:20}),title:"Auto-Configure",onClose:y}),e.jsxs(te,{className:"flex flex-col gap-5 max-h-[70vh] overflow-y-auto",children:[l==="analyzing"&&e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-12",children:[e.jsx(G,{className:"w-6 h-6 text-sys-blue animate-spin"}),e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Analyzing 7 days of mesh traffic…"})]}),l==="error"&&e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-8",children:[e.jsx(ne,{className:"w-6 h-6 text-sys-amber"}),e.jsx("p",{className:"type-body-sm text-fg-secondary",children:g}),e.jsx(M,{plain:!0,onClick:b,className:"text-sys-blue",children:"Retry"})]}),(l==="ready"||l==="applying"||l==="applied")&&n&&i&&m&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("div",{className:"type-micro mb-3",children:"7-DAY ANALYSIS"}),e.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"data-box-label",children:"Pkts/hr"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:B(n.packetsPerHour)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"data-box-label",children:"Adverts/hr"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:B(n.advertsPerHour)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"data-box-label",children:"Sources"}),e.jsx("div",{className:"data-box data-box-fill data-box-left",children:n.trackedSources})]}),e.jsxs("div",{children:[e.jsx("div",{className:"data-box-label",children:"Density"}),e.jsx("div",{className:k("data-box data-box-fill data-box-left",ye[n.meshDensity]),children:ue[n.meshDensity]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(D,{title:"Token Bucket of Shame",enabled:i.tokenBucket.enabled,defaultOpen:!0,children:[e.jsx(p,{label:"Bucket Capacity",current:(C=m.tokenBucket)==null?void 0:C.bucket_capacity,recommended:i.tokenBucket.bucket_capacity,format:t=>`${t} tokens`}),e.jsx(p,{label:"Refill Tokens",current:(A=m.tokenBucket)==null?void 0:A.refill_tokens,recommended:i.tokenBucket.refill_tokens,format:t=>`${t} tokens`}),e.jsx(p,{label:"Refill Interval",current:(H=m.tokenBucket)==null?void 0:H.refill_interval_seconds,recommended:i.tokenBucket.refill_interval_seconds,format:t=>j(t)}),e.jsx(p,{label:"Min Interval",current:(P=m.tokenBucket)==null?void 0:P.min_interval_seconds,recommended:i.tokenBucket.min_interval_seconds,format:t=>`${t}s`})]}),e.jsxs(D,{title:"Penalty Box",enabled:i.penaltyBox.enabled,children:[e.jsx(p,{label:"Violation Threshold",current:(T=m.penaltyBox)==null?void 0:T.violation_threshold,recommended:i.penaltyBox.violation_threshold,format:t=>`${t} violations`}),e.jsx(p,{label:"Base Penalty",current:(I=m.penaltyBox)==null?void 0:I.base_penalty_seconds,recommended:i.penaltyBox.base_penalty_seconds,format:t=>j(t)}),e.jsx(p,{label:"Multiplier",current:(R=m.penaltyBox)==null?void 0:R.penalty_multiplier,recommended:i.penaltyBox.penalty_multiplier,format:t=>`${t}×`}),e.jsx(p,{label:"Max Penalty",current:(L=m.penaltyBox)==null?void 0:L.max_penalty_seconds,recommended:i.penaltyBox.max_penalty_seconds,format:t=>j(t)}),e.jsx(p,{label:"Violation Decay",current:($=m.penaltyBox)==null?void 0:$.violation_decay_seconds,recommended:i.penaltyBox.violation_decay_seconds,format:t=>j(t)})]}),e.jsxs(D,{title:"Adaptive Tiers",enabled:i.adaptive.enabled,children:[e.jsx(p,{label:"EWMA α",current:(E=m.adaptive)==null?void 0:E.ewma_alpha,recommended:i.adaptive.ewma_alpha}),e.jsx(p,{label:"Hysteresis",current:(z=m.adaptive)==null?void 0:z.hysteresis_seconds,recommended:i.adaptive.hysteresis_seconds,format:t=>j(t)}),e.jsx(p,{label:"Quiet Max",current:(F=m.adaptive)==null?void 0:F.thresholds.quiet_max,recommended:i.adaptive.thresholds.quiet_max,format:t=>`${t} pkts/min`}),e.jsx(p,{label:"Normal Max",current:(O=m.adaptive)==null?void 0:O.thresholds.normal_max,recommended:i.adaptive.thresholds.normal_max,format:t=>`${t} pkts/min`}),e.jsx(p,{label:"Busy Max",current:(q=m.adaptive)==null?void 0:q.thresholds.busy_max,recommended:i.adaptive.thresholds.busy_max,format:t=>`${t} pkts/min`})]})]}),e.jsxs("div",{className:k("flex justify-between gap-4 pt-1",l==="applied"?"items-center":"items-end"),children:[l==="applied"?e.jsx("span",{className:"type-body-sm text-zinc-500",children:"Settings applied"}):e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"data-box-label",children:"Analyzed"}),e.jsxs("div",{className:"data-box data-box-fill data-box-left",children:[B(n.totalPackets)," packets"]})]}),e.jsx("div",{className:"flex items-center gap-2",children:l==="applied"?e.jsx(M,{color:"primary",onClick:y,children:"Done"}):e.jsxs(e.Fragment,{children:[e.jsx(M,{plain:!0,onClick:y,children:"Cancel"}),e.jsx(M,{color:"primary",onClick:N,disabled:l==="applying",children:l==="applying"?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(G,{className:"w-4 h-4 animate-spin"}),"Applying…"]}):"Apply All"})]})})]})]})]})]})}export{Ne as A,je as N,ke as S,oe as W,ge as a}; diff --git a/frontend/dist/assets/BasemapLayer--gGy0d8r.js b/frontend/dist/assets/BasemapLayer--gGy0d8r.js deleted file mode 100644 index 1e4a74ff..00000000 --- a/frontend/dist/assets/BasemapLayer--gGy0d8r.js +++ /dev/null @@ -1,2 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-B9Nfzawy.js","assets/index-BSz_JZ6w.css"])))=>i.map(i=>d[i]); -import{r as a,_ as Z,b9 as j}from"./index-B9Nfzawy.js";const W=a.createContext(null);function B(){var s;const e=(s=a.useContext(W))==null?void 0:s.maps,t=a.useContext(b);return a.useMemo(()=>({...e,current:t==null?void 0:t.map}),[e,t])}function V(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 i of q)i in r&&(o[i]=r[i])}return o||s});return{...e,layers:n}}const U={version:8,sources:{},layers:[]},A={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"},N={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"},F={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"},$=["minZoom","maxZoom","minPitch","maxPitch","maxBounds","projection","renderWorldCopies"],G=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate","touchPitch"];class M{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[F[o.type]];r?r(o):o.type==="error"&&console.error(o.error)},this._onCameraEvent=o=>{if(this._internalUpdate)return;o.viewState=this._propsedCameraUpdate||T(this._map.transform);const r=this.props[N[o.type]];r&&r(o)},this._onCameraUpdate=o=>this._internalUpdate?o:(this._propsedCameraUpdate=T(o),z(o,this.props)),this._onPointerEvent=o=>{(o.type==="mousemove"||o.type==="mouseout")&&this._updateHover(o);const r=this.props[A[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=M.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 i=o._resizeObserver;i&&(i.disconnect(),i.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=U}=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 i=new this._MapClass(o);r.padding&&i.setPadding(r.padding),n.cursor&&(i.getCanvas().style.cursor=n.cursor),i.transformCameraUpdate=this._onCameraUpdate,i.on("style.load",()=>{var c;this._styleComponents={light:i.getLight(),sky:i.getSky(),projection:(c=i.getProjection)==null?void 0:c.call(i),terrain:i.getTerrain()},this._updateStyleComponents(this.props)}),i.on("sourcedata",()=>{this._updateStyleComponents(this.props)});for(const c in A)i.on(c,this._onPointerEvent);for(const c in N)i.on(c,this._onCameraEvent);for(const c in F)i.on(c,this._onEvent);this._map=i}recycle(){const n=this.map.getContainer().querySelector("[mapboxgl-children]");n==null||n.remove(),M.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 $)if(r in t&&!v(t[r],n[r])){o=!0;const i=s[`set${r[0].toUpperCase()}${r.slice(1)}`];i==null||i.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=U,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,i=this._styleComponents;r.style._loaded&&(t&&!v(t,i.light)&&(i.light=t,r.setLight(t)),n&&!v(n,i.projection)&&n!==((c=i.projection)==null?void 0:c.type)&&(i.projection=typeof n=="string"?{type:n}:n,(u=r.setProjection)==null||u.call(r,i.projection)),s&&!v(s,i.sky)&&(i.sky=s,r.setSky(s)),o!==void 0&&!v(o,i.terrain)&&(!o||r.getSource(o.source))&&(i.terrain=o,r.setTerrain(o)))}_updateHandlers(t,n){const s=this._map;for(const o of G){const r=t[o]??!0,i=n[o]??!0;v(r,i)||(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,i=((o=this._hoveredFeatures)==null?void 0:o.length)>0,c=this._queryRenderedFeatures(t.point),u=c.length>0;!u&&i&&(t.type="mouseleave",this._onPointerEvent(t)),this._hoveredFeatures=c,u&&!i&&(t.type="mouseenter",this._onPointerEvent(t)),t.type=r}else this._hoveredFeatures=null}}M.savedMaps=[];const K=["setMaxBounds","setMinZoom","setMaxZoom","setMinPitch","setMaxPitch","setRenderWorldCopies","setProjection","setStyle","addSource","removeSource","addLayer","removeLayer","setLayerZoomRange","setFilter","setPaintProperty","setLayoutProperty","setLight","setTerrain","setFog","remove"];function J(e){if(!e)return null;const t=e.map,n={getMap:()=>t};for(const s of Y(t))!(s in n)&&!K.includes(s)&&(n[s]=t[s].bind(t));return n}function Y(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 X=typeof document<"u"?a.useLayoutEffect:a.useEffect;function Q(e,t){const{RTLTextPlugin:n,maxParallelImageRequests:s,workerCount:o,workerUrl:r}=t;if(n&&e.getRTLTextPluginStatus&&e.getRTLTextPluginStatus()==="unavailable"){const{pluginUrl:i,lazy:c=!0}=typeof n=="string"?{pluginUrl:n}:n;e.setRTLTextPlugin(i,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 b=a.createContext(null);function ee(e,t){const n=a.useContext(W),[s,o]=a.useState(null),r=a.useRef(),{current:i}=a.useRef({mapLib:null,map:null});a.useEffect(()=>{const l=e.mapLib;let d=!0,f;return Promise.resolve(l||Z(()=>import("./maplibre-gl-DisS89O_.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");Q(y,e),e.reuseMaps&&(f=M.reuse(e,r.current)),f||(f=new M(y.Map,e,r.current)),i.map=J(f),i.mapLib=y,o(f),n==null||n.onMapMount(i.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())}},[]),X(()=>{s&&s.setProps(e)}),a.useImperativeHandle(t,()=>i.map,[s]);const c=a.useMemo(()=>({position:"relative",width:"100%",height:"100%",...e.style}),[e.style]),u={height:"100%"};return a.createElement("div",{id:e.id,ref:r,style:c},s&&a.createElement(b.Provider,{value:i},a.createElement("div",{"mapboxgl-children":"",style:u},e.children)))}const _e=a.forwardRef(ee),te=/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)&&!te.test(s)?n[s]=`${o}px`:n[s]=o}}function H(e,t){if(e===t)return null;const n=D(e),s=D(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 D(e){return new Set(e?e.trim().split(/\s+/):[])}const Le=a.memo(a.forwardRef((e,t)=>{const{map:n,mapLib:s}=a.useContext(b),o=a.useRef({props:e}),r=a.useMemo(()=>{let E=!1;a.Children.forEach(e.children,g=>{g&&(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",g=>{var h,_;(_=(h=o.current.props).onClick)==null||_.call(h,{type:"click",target:p,originalEvent:g})}),p.on("dragstart",g=>{var _,S;const h=g;h.lngLat=r.getLngLat(),(S=(_=o.current.props).onDragStart)==null||S.call(_,h)}),p.on("drag",g=>{var _,S;const h=g;h.lngLat=r.getLngLat(),(S=(_=o.current.props).onDrag)==null||S.call(_,h)}),p.on("dragend",g=>{var _,S;const h=g;h.lngLat=r.getLngLat(),(S=(_=o.current.props).onDragEnd)==null||S.call(_,h)}),p},[]);a.useEffect(()=>(r.addTo(n.getMap()),()=>{r.remove()}),[]);const{longitude:i,latitude:c,offset:u,style:l,draggable:d=!1,popup:f=null,rotation:m=0,rotationAlignment:y="auto",pitchAlignment:C="auto"}=e;a.useEffect(()=>{L(r.getElement(),l)},[l]),a.useImperativeHandle(t,()=>r,[]);const P=o.current.props;(r.getLngLat().lng!==i||r.getLngLat().lat!==c)&&r.setLngLat([i,c]),u&&!V(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=H(P.className,e.className);if(x)for(const E of x)r.toggleClassName(E);return o.current.props=e,j.createPortal(e.children,r.getElement())})),Ce=a.memo(a.forwardRef((e,t)=>{const{map:n,mapLib:s}=a.useContext(b),o=a.useMemo(()=>document.createElement("div"),[]),r=a.useRef({props:e}),i=a.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(a.useEffect(()=>{const c=u=>{var l,d;(d=(l=r.current.props).onClose)==null||d.call(l,u)};return i.on("close",c),i.setDOMContent(o).addTo(n.getMap()),()=>{i.off("close",c),i.isOpen()&&i.remove()}},[]),a.useEffect(()=>{L(i.getElement(),e.style)},[e.style]),a.useImperativeHandle(t,()=>i,[]),i.isOpen()){const c=r.current.props;(i.getLngLat().lng!==e.longitude||i.getLngLat().lat!==e.latitude)&&i.setLngLat([e.longitude,e.latitude]),e.offset&&!v(c.offset,e.offset)&&i.setOffset(e.offset),(c.anchor!==e.anchor||c.maxWidth!==e.maxWidth)&&(i.options.anchor=e.anchor,i.setMaxWidth(e.maxWidth));const u=H(c.className,e.className);if(u)for(const l of u)i.toggleClassName(l);r.current.props=e}return j.createPortal(e.children,o)}));function w(e,t,n,s){const o=a.useContext(b),r=a.useMemo(()=>e(o),[]);return a.useEffect(()=>{const i=t,c=null,u=typeof t=="function"?t:null,{map:l}=o;return l.hasControl(r)||(l.addControl(r,i==null?void 0:i.position),c&&c(o)),()=>{u&&u(o),l.hasControl(r)&&l.removeControl(r)}},[]),r}function ne(e){const t=w(({mapLib:n})=>new n.AttributionControl(e),{position:e.position});return a.useEffect(()=>{L(t._container,e.style)},[e.style]),null}a.memo(ne);function oe(e){const t=w(({mapLib:n})=>new n.FullscreenControl({container:e.containerId&&document.getElementById(e.containerId)}),{position:e.position});return a.useEffect(()=>{L(t._controlContainer,e.style)},[e.style]),null}a.memo(oe);function re(e,t){const n=a.useRef({props:e}),s=w(({mapLib:o})=>{const r=new o.GeolocateControl(e),i=r._setupUI;return r._setupUI=()=>{r._container.hasChildNodes()||i()},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,a.useImperativeHandle(t,()=>s,[]),a.useEffect(()=>{L(s._container,e.style)},[e.style]),null}a.memo(a.forwardRef(re));function se(e){const t=w(({mapLib:n})=>new n.NavigationControl(e),{position:e.position});return a.useEffect(()=>{L(t._container,e.style)},[e.style]),null}a.memo(se);function ie(e){const t=w(({mapLib:r})=>new r.ScaleControl(e),{position:e.position}),n=a.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),a.useEffect(()=>{L(t._container,o)},[o]),null}const Se=a.memo(ie);function ae(e){const t=w(({mapLib:n})=>new n.TerrainControl(e),{position:e.position});return a.useEffect(()=>{L(t._container,e.style)},[e.style]),null}a.memo(ae);function ce(e){const t=w(({mapLib:n})=>new n.LogoControl(e),{position:e.position});return a.useEffect(()=>{L(t._container,e.style)},[e.style]),null}a.memo(ce);function R(e,t){if(!e)throw new Error(t)}let le=0;function ue(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 fe(e,t,n){var i,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":(i=e.setCoordinates)==null||i.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 Ee(e){const t=a.useContext(b).map.getMap(),n=a.useRef(e),[,s]=a.useState(0),o=a.useMemo(()=>e.id||`jsx-source-${le++}`,[]);a.useEffect(()=>{if(t){const i=()=>setTimeout(()=>s(c=>c+1),0);return t.on("styledata",i),i(),()=>{var c;if(t.off("styledata",i),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?fe(r,e,n.current):r=ue(t,o,e),n.current=e,r&&a.Children.map(e.children,i=>i&&a.cloneElement(i,{source:o}))||null}function de(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:i,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(i,s.filter)||e.setFilter(t,i),(c!==s.minzoom||u!==s.maxzoom)&&e.setLayerZoomRange(t,c,u)}function me(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 ye=0;function be(e){const t=a.useContext(b).map.getMap(),n=a.useRef(e),[,s]=a.useState(0),o=a.useMemo(()=>e.id||`jsx-layer-${ye++}`,[]);if(a.useEffect(()=>{if(t){const i=()=>s(c=>c+1);return t.on("styledata",i),i(),()=>{t.off("styledata",i),t.style&&t.style._loaded&&t.getLayer(o)&&t.removeLayer(o)}}},[t]),t&&t.style&&t.getLayer(o))try{de(t,o,e,n.current)}catch(i){console.warn(i)}else me(t,o,e);return n.current=e,null}const he={light:"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",dark:"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json"},ge={light:"basemap-light-",dark:"basemap-dark-"},I={};async function pe(e){if(I[e])return I[e];const n=await(await fetch(he[e])).json();return I[e]=n,n}function we({mode:e}){const{current:t}=B(),[n,s]=a.useState(null),o=a.useRef({light:!1,dark:!1}),r=a.useRef({light:[],dark:[]});a.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 i=a.useCallback(async(l,d,f)=>{var E,k;if(o.current[d])return;const m=ge[d],y=await pe(d),C=[];for(const[p,g]of Object.entries(y.sources||{})){const h=m+p;l.getSource(h)||l.addSource(h,g)}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 g=m+p.id;if(C.push(g),l.getLayer(g))continue;const h={...p,id:g};"source"in h&&typeof h.source=="string"&&(h.source=m+h.source),h.layout||(h.layout={}),h.layout.visibility=f?"visible":"none";try{l.addLayer(h,x)}catch(_){console.warn(`[BasemapLayer] Failed to add layer ${g}:`,_)}}r.current[d]=C,o.current[d]=!0},[]),c=a.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=a.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 a.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]),a.useEffect(()=>{if(!n)return;let l=!1;const d=async()=>{if(!l)try{await Promise.all([i(n,"light",e==="light"),i(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,i,u,e]),a.useEffect(()=>{n&&(!o.current.light||!o.current.dark||(c(n,"light",e==="light"),c(n,"dark",e==="dark")))},[n,e,c]),null}export{we as B,be as L,_e as M,Ce as P,Ee as S,Le as a,Se as b,B as u}; diff --git a/frontend/dist/assets/BasemapLayer-Bv4kYAcR.js b/frontend/dist/assets/BasemapLayer-Bv4kYAcR.js new file mode 100644 index 00000000..bc4432fe --- /dev/null +++ b/frontend/dist/assets/BasemapLayer-Bv4kYAcR.js @@ -0,0 +1 @@ +import{r as o}from"./index-i0xzpXop.js";import{u as w}from"./maplibre-gl-B20pCOz8.js";const C={light:"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",dark:"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json"},x={light:"basemap-light-",dark:"basemap-dark-"},k={};async function E(i){if(k[i])return k[i];const t=await(await fetch(C[i])).json();return k[i]=t,t}function R({mode:i}){const{current:l}=w(),[t,b]=o.useState(null),u=o.useRef({light:!1,dark:!1}),m=o.useRef({light:[],dark:[]});o.useEffect(()=>{const e=()=>{var a;const s=(a=l==null?void 0:l.getMap)==null?void 0:a.call(l);s&&!t&&b(s)};e();const r=setInterval(e,50),c=setTimeout(()=>clearInterval(r),5e3);return()=>{clearInterval(r),clearTimeout(c)}},[l,t]);const g=o.useCallback(async(e,r,c)=>{var L,I;if(u.current[r])return;const s=x[r],a=await E(r),d=[];for(const[y,f]of Object.entries(a.sources||{})){const n=s+y;e.getSource(n)||e.addSource(n,f)}const v=(I=(((L=e.getStyle())==null?void 0:L.layers)||[]).find(y=>!y.id.startsWith("basemap-light-")&&!y.id.startsWith("basemap-dark-")))==null?void 0:I.id;for(const y of a.layers||[]){const f=s+y.id;if(d.push(f),e.getLayer(f))continue;const n={...y,id:f};"source"in n&&typeof n.source=="string"&&(n.source=s+n.source),n.layout||(n.layout={}),n.layout.visibility=c?"visible":"none";try{e.addLayer(n,v)}catch(S){console.warn(`[BasemapLayer] Failed to add layer ${f}:`,S)}}m.current[r]=d,u.current[r]=!0},[]),h=o.useCallback((e,r,c)=>{const s=m.current[r],a=c?"visible":"none";for(const d of s)if(e.getLayer(d))try{e.setLayoutProperty(d,"visibility",a)}catch{}},[]),p=o.useCallback(e=>{var s;const c=(((s=e.getStyle())==null?void 0:s.layers)||[]).filter(a=>!a.id.startsWith("basemap-light-")&&!a.id.startsWith("basemap-dark-"));for(const a of c)try{e.moveLayer(a.id)}catch{}},[]);return o.useEffect(()=>{if(!t)return;const e=r=>{t.hasImage(r.id)||t.addImage(r.id,{width:1,height:1,data:new Uint8Array([0,0,0,0])})};return t.on("styleimagemissing",e),()=>{t.off("styleimagemissing",e)}},[t]),o.useEffect(()=>{if(!t)return;let e=!1;const r=async()=>{if(!e)try{await Promise.all([g(t,"light",i==="light"),g(t,"dark",i==="dark")]),e||p(t)}catch(s){console.error("[BasemapLayer] Setup error:",s)}};t.isStyleLoaded()?r():(t.once("style.load",r),t.once("load",()=>{!e&&!u.current.light&&r()}));const c=()=>{e||setTimeout(()=>{!e&&u.current.light&&u.current.dark&&p(t)},100)};return t.on("styledata",c),()=>{e=!0,t.off("styledata",c)}},[t,g,p,i]),o.useEffect(()=>{t&&(!u.current.light||!u.current.dark||(h(t,"light",i==="light"),h(t,"dark",i==="dark")))},[t,i,h]),null}export{R as B}; diff --git a/frontend/dist/assets/ChatBubble-DL8lfbnv.js b/frontend/dist/assets/ChatBubble-DL8lfbnv.js new file mode 100644 index 00000000..cabfc38d --- /dev/null +++ b/frontend/dist/assets/ChatBubble-DL8lfbnv.js @@ -0,0 +1 @@ +import{r as B,j as e,c as s}from"./index-i0xzpXop.js";import{e as M,g as W,a as E,b as S,f as g,c as b}from"./chat-utils-BdAUDg3r.js";const v=["","text-[42px]","text-[36px]","text-[30px]"],O=B.memo(function({senderName:x,text:n,timestamp:d,nameAccessory:y,bubbleAccessory:c,className:o,isOutgoing:N,status:t,onRetry:m,onRetryAsFlood:h,retryAttempt:p,maxRetries:l,signed:w,echoCount:r,bubbleVariant:V="accent",onMentionClick:f}){const{emoji:u,cleanName:j}=M(x),k=W(j),C=E(x),a=S(n);return N?e.jsxs("div",{className:s("group flex flex-col items-end w-full p-2",o),children:[e.jsxs("div",{className:"flex items-end gap-1.5 max-w-[80%]",children:[c,a>0?e.jsx("p",{className:s("leading-none",v[a]),children:n.trim()}):e.jsx("div",{className:s("inline-block px-3.5 py-2.5","rounded-2xl rounded-br-md",t==="failed"?"bg-sys-red depth-raised-soft":"bg-sys-blue depth-raised-soft"),children:e.jsx("p",{className:"text-sm text-white leading-relaxed tracking-wide whitespace-pre-wrap break-words",children:g(n,{isOutgoing:!0,onMentionClick:f})})})]}),e.jsxs("div",{className:"flex items-center justify-end gap-1.5 mt-0.5 mr-1",children:[r!=null&&r>0&&e.jsxs("span",{className:"flex items-center gap-0.5 text-[10px] text-sys-green tabular-nums font-medium",children:[e.jsxs("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("path",{d:"M17 1l4 4-4 4"}),e.jsx("path",{d:"M3 11V9a4 4 0 0 1 4-4h14"}),e.jsx("path",{d:"M7 23l-4-4 4-4"}),e.jsx("path",{d:"M21 13v2a4 4 0 0 1-4 4H3"})]}),r]}),t==="confirmed"&&e.jsxs("svg",{className:"w-3 h-3 text-sys-green",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("polyline",{points:"3 12 8 17 14 6"}),e.jsx("polyline",{points:"10 12 15 17 21 6"})]}),t==="sent"&&e.jsx("svg",{className:"w-3 h-3 text-fg-muted",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}),t==="pending"&&e.jsx("svg",{className:"w-3 h-3 text-chat-timestamp animate-spin",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:e.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),t==="retrying"&&e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-3 h-3 text-sys-amber animate-spin",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:e.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}),p!=null&&l!=null&&e.jsxs("span",{className:"text-[10px] text-sys-amber font-medium tabular-nums",children:["Retry ",p,"/",l]})]}),t==="unconfirmed"&&e.jsx("span",{className:"w-2 h-2 rounded-full bg-sys-amber flex-shrink-0"}),t==="failed"&&e.jsxs(e.Fragment,{children:[e.jsxs("svg",{className:"w-3 h-3 text-sys-red",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),l!=null&&l>0&&e.jsxs("span",{className:"text-[10px] text-sys-red/70",children:["after ",l," ",l===1?"retry":"retries"]}),m&&e.jsx("button",{onClick:m,className:"text-[10px] font-medium text-sys-red hover:text-sys-red/80 underline underline-offset-2 transition-colors",children:"Retry"}),h&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[10px] text-fg-muted/50",children:"·"}),e.jsx("button",{onClick:h,className:"text-[10px] font-medium text-sys-amber hover:text-sys-amber/80 underline underline-offset-2 transition-colors",children:"Flood"})]})]}),e.jsx("span",{className:"text-[10px] text-chat-timestamp tabular-nums",children:b(d)})]})]}):e.jsxs("div",{className:s("group flex items-start gap-4 w-full p-2",o),children:[e.jsxs("div",{className:"flex-shrink-0 w-9 flex flex-col items-center gap-1",children:[e.jsx("div",{className:s("clay-avatar w-9 h-9",u?"text-lg":"text-white text-[13px] font-bold tracking-tight"),style:{"--avatar-color":k},children:u||C}),e.jsx("span",{className:"text-xs text-chat-timestamp tabular-nums h-4 leading-4",children:b(d)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 -mt-[3px] mb-1",children:[e.jsx("span",{className:"text-[13px] font-normal text-chat-incoming-name truncate leading-tight tabular-nums",children:j}),w&&e.jsxs("svg",{className:"w-3.5 h-3.5 text-sys-green flex-shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("title",{children:"Ed25519 signed message"}),e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"}),e.jsx("polyline",{points:"9 12 11 14 15 10"})]}),y]}),e.jsxs("div",{className:"flex items-end gap-1.5",children:[a>0?e.jsx("p",{className:s("leading-none",v[a]),children:n.trim()}):e.jsx("div",{className:s("inline-block px-3.5 py-2.5 max-w-full","rounded-2xl rounded-tl-md","bg-chat-incoming depth-raised-soft"),children:e.jsx("p",{className:"text-sm text-fg-primary leading-relaxed tracking-wide whitespace-pre-wrap break-words",children:g(n,{onMentionClick:f})})}),c]})]})]})});function T({text:i}){return e.jsx("div",{className:"flex justify-center my-1",children:e.jsx("span",{className:s("px-3 py-1 rounded-full","bg-subtle-fill text-[11px] text-fg-muted/80 font-medium","ring-1 ring-edge-subtle"),children:i})})}export{O as C,T as S}; diff --git a/frontend/dist/assets/ChatBubble-fzIllzhe.js b/frontend/dist/assets/ChatBubble-fzIllzhe.js deleted file mode 100644 index 80700bdd..00000000 --- a/frontend/dist/assets/ChatBubble-fzIllzhe.js +++ /dev/null @@ -1,6 +0,0 @@ -import{d as h,r as u,j as e,c as t}from"./index-B9Nfzawy.js";import{e as f,g as p,a as g,b as j,f as b}from"./chat-utils-CXtTpLY5.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 w=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]],k=h("message-square-text",w),v=u.memo(function({senderName:a,text:n,timestamp:c,nameAccessory:d,bubbleAccessory:x,className:o}){const{emoji:l,cleanName:i}=f(a),r=p(i),m=g(a);return e.jsxs("div",{className:t("group flex items-start gap-3 w-full",o),children:[e.jsxs("div",{className:"flex-shrink-0 w-9 flex flex-col items-center gap-1",children:[e.jsx("div",{className:t("w-9 h-9 rounded-full flex items-center justify-center","shadow-md ring-1 ring-edge-subtle",l?"text-lg":"text-white text-[13px] font-bold tracking-tight"),style:{backgroundColor:r},children:l||m}),e.jsx("span",{className:"text-xs text-fg-muted tabular-nums h-4 leading-4",children:j(c)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 h-5 mb-1",children:[e.jsx("span",{className:"text-[13px] font-medium truncate",style:{color:r,lineHeight:"20px"},children:i}),d]}),e.jsxs("div",{className:"flex items-end gap-1.5",children:[e.jsx("div",{className:t("inline-block px-3.5 py-2.5 max-w-full","rounded-2xl rounded-tl-md","bg-[#007AFF]"),children:e.jsx("p",{className:"text-sm text-white leading-relaxed tracking-wide whitespace-pre-wrap break-words",children:b(n)})}),x]})]})]})});function C({text:s}){return e.jsx("div",{className:"flex justify-center my-1",children:e.jsx("span",{className:t("px-3 py-1 rounded-full","bg-subtle-fill text-[11px] text-fg-muted/80 font-medium","ring-1 ring-edge-subtle"),children:s})})}export{v as C,k as M,C as S}; diff --git a/frontend/dist/assets/CollisionExplorerModal-DAlBzVhS.js b/frontend/dist/assets/CollisionExplorerModal-DAlBzVhS.js new file mode 100644 index 00000000..d750ae8b --- /dev/null +++ b/frontend/dist/assets/CollisionExplorerModal-DAlBzVhS.js @@ -0,0 +1 @@ +import{r as c,a6 as L,ch as S,ab as H,j as e,aC as k,bY as R,aD as B,c$ as E,b$ as T,c as N,ao as D,V as M,a3 as P,a0 as _,a1 as z,cs as I,cE as W}from"./index-i0xzpXop.js";import{M as $,S as F,L as Y,a as q}from"./maplibre-gl-B20pCOz8.js";import{B as A}from"./BasemapLayer-Bv4kYAcR.js";import{M as U}from"./map-pin-C051lstq.js";import{S as V}from"./share-2-B5yQaExh.js";const G={version:8,sources:{},layers:[],glyphs:"https://tiles.basemaps.cartocdn.com/fonts/{fontstack}/{range}.pbf"};function w({node:o,isHovered:v,onHover:f}){const[g,p]=c.useState(!1),y=c.useCallback(async d=>{d.stopPropagation(),await P(o.hash),p(!0),setTimeout(()=>p(!1),2e3)},[o.hash]),h=o.contactType.toLowerCase(),m=h.includes("room")||h.includes("server"),l=h==="companion"||h==="client";let n=V,r="text-sys-blue";return m?(n=I,r="text-signal-fair"):l?(n=W,r="text-fg-muted"):o.isNeighbor&&(r="text-sys-green"),e.jsxs("div",{className:N("flex items-center gap-3 px-3 py-2.5 radius-inner transition-base cursor-pointer",v?"bg-sys-blue/10":"hover:bg-subtle-fill"),onMouseEnter:()=>f(o.hash),onMouseLeave:()=>f(null),children:[e.jsx(n,{className:N("w-4 h-4 flex-shrink-0",r)}),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:o.name}),o.isNeighbor&&e.jsx(M,{color:"green",compact:!0,children:"NBR"}),o.isRepeater&&e.jsx(M,{color:"zinc",compact:!0,children:"RPT"}),o.isHub&&e.jsx(M,{color:"indigo",compact:!0,children:"HUB"})]}),e.jsxs("button",{onClick:y,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",g?"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: ${o.hash}`,children:[o.hash.slice(0,12),"…",g?e.jsx(_,{className:"w-2.5 h-2.5"}):e.jsx(z,{className:"w-2.5 h-2.5 opacity-50"})]})]})]})}function C({nodes:o,hoveredHash:v,onHover:f}){const g=E(),p=c.useRef(null),y=T(),[h,m]=c.useState(!1),l=c.useMemo(()=>o.filter(a=>a.latitude!=null&&a.longitude!=null&&(a.latitude!==0||a.longitude!==0)),[o]),n=c.useMemo(()=>{if(l.length===0)return null;let a=1/0,s=-1/0,t=1/0,i=-1/0;for(const x of l)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-tn?{longitude:(n[0][0]+n[1][0])/2,latitude:(n[0][1]+n[1][1])/2}:{longitude:0,latitude:0},[n]),d=c.useMemo(()=>{if(l.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||!n){m(!0);return}a.fitBounds(n,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:13,duration:0}),setTimeout(()=>m(!0),50)},[n]),b=y&&h;return l.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(U,{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($,{ref:p,initialViewState:{longitude:r.longitude,latitude:r.latitude,zoom:10},style:{height:"100%",width:"100%"},mapStyle:G,attributionControl:!1,onLoad:j,children:[e.jsx(A,{mode:g}),d&&e.jsx(F,{id:"collision-edges",type:"geojson",data:d,children:e.jsx(Y,{id:"collision-edges-line",type:"line",paint:{"line-color":"#3B3F4A","line-width":2,"line-opacity":.8},layout:{"line-cap":"round","line-join":"round"}})}),l.map(a=>{const s=a.hash===v,t=D(a.hash);return e.jsx(q,{longitude:a.longitude,latitude:a.latitude,anchor:"center",children:e.jsx("div",{className:"cursor-pointer transition-all duration-150",onMouseEnter:()=>f(a.hash),onMouseLeave:()=>f(null),style:{pointerEvents:"auto"},children:e.jsxs(M,{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 J({isOpen:o,prefix:v,candidateHashes:f,onClose:g}){const p=L(),y=S(),h=H(),[m,l]=c.useState(null),n=c.useMemo(()=>new Set(h.map(s=>s.hash)),[h]),r=(p==null?void 0:p.neighbors)??{},d=c.useMemo(()=>{const s=t=>{if(r[t])return r[t];if(!t.startsWith("0x")&&r["0x"+t])return r["0x"+t];if(t.startsWith("0x")&&r[t.slice(2)])return r[t.slice(2)]};return f.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:n.has(t)||n.has("0x"+t)||n.has(t.replace(/^0x/,"")),isHub:y.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))},[f,r,n,y]),j=c.useMemo(()=>d.some(s=>s.latitude!=null&&s.longitude!=null&&(s.latitude!==0||s.longitude!==0)),[d]),b=c.useCallback(s=>{l(s)},[]),a=j?"4xl":"lg";return o?e.jsxs(k,{open:o,onClose:g,size:a,motionPlus:!0,className:j?"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(R,{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:v})]}),e.jsxs("p",{className:"text-xs text-fg-secondary",children:[d.length," nodes share this prefix"]})]})]}),e.jsx("button",{onClick:g,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:g,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(B,{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:[j&&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(w,{node:s,isHovered:m===s.hash,onHover:b},s.hash))})]}),j?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(w,{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(w,{node:s,isHovered:m===s.hash,onHover:b},s.hash))})})]})]}):null}const ee=c.memo(J);export{ee as C}; diff --git a/frontend/dist/assets/CollisionExplorerModal-J7HE0WX3.js b/frontend/dist/assets/CollisionExplorerModal-J7HE0WX3.js deleted file mode 100644 index 3f31eb5e..00000000 --- a/frontend/dist/assets/CollisionExplorerModal-J7HE0WX3.js +++ /dev/null @@ -1,6 +0,0 @@ -import{d as k,r as c,a4 as L,ca as S,a9 as H,j as e,aA as R,aB as B,cS as T,bX as E,c as N,R as w,a1 as _,Y as D,$ as I,ck as P}from"./index-B9Nfzawy.js";import{M as z,B as W,S as q,L as U,a as A}from"./BasemapLayer--gGy0d8r.js";import{T as F}from"./triangle-alert-_KPqiYkd.js";import{M as Y}from"./map-pin-Z2xK57U6.js";import{M as $}from"./monitor-smartphone-zVB5GYa6.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 G=[["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"}]],J=k("share-2",G),Q={version:8,sources:{},layers:[],glyphs:"https://tiles.basemaps.cartocdn.com/fonts/{fontstack}/{range}.pbf"};function M({node:o,isHovered:v,onHover:f}){const[g,p]=c.useState(!1),b=c.useCallback(async d=>{d.stopPropagation(),await _(o.hash),p(!0),setTimeout(()=>p(!1),2e3)},[o.hash]),h=o.contactType.toLowerCase(),m=h.includes("room")||h.includes("server"),l=h==="companion"||h==="client";let n=J,r="text-sys-blue";return m?(n=P,r="text-signal-fair"):l?(n=$,r="text-fg-muted"):o.isNeighbor&&(r="text-sys-green"),e.jsxs("div",{className:N("flex items-center gap-3 px-3 py-2.5 radius-inner transition-base cursor-pointer",v?"bg-sys-blue/10":"hover:bg-subtle-fill"),onMouseEnter:()=>f(o.hash),onMouseLeave:()=>f(null),children:[e.jsx(n,{className:N("w-4 h-4 flex-shrink-0",r)}),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:o.name}),o.isNeighbor&&e.jsx(w,{color:"green",compact:!0,children:"NBR"}),o.isRepeater&&e.jsx(w,{color:"zinc",compact:!0,children:"RPT"}),o.isHub&&e.jsx(w,{color:"indigo",compact:!0,children:"HUB"})]}),e.jsxs("button",{onClick:b,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",g?"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: ${o.hash}`,children:[o.hash.slice(0,12),"…",g?e.jsx(D,{className:"w-2.5 h-2.5"}):e.jsx(I,{className:"w-2.5 h-2.5 opacity-50"})]})]})]})}function C({nodes:o,hoveredHash:v,onHover:f}){const g=T(),p=c.useRef(null),b=E(),[h,m]=c.useState(!1),l=c.useMemo(()=>o.filter(a=>a.latitude!=null&&a.longitude!=null&&(a.latitude!==0||a.longitude!==0)),[o]),n=c.useMemo(()=>{if(l.length===0)return null;let a=1/0,s=-1/0,t=1/0,i=-1/0;for(const x of l)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-tn?{longitude:(n[0][0]+n[1][0])/2,latitude:(n[0][1]+n[1][1])/2}:{longitude:0,latitude:0},[n]),d=c.useMemo(()=>{if(l.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||!n){m(!0);return}a.fitBounds(n,{padding:{top:50,bottom:50,left:50,right:50},maxZoom:13,duration:0}),setTimeout(()=>m(!0),50)},[n]),y=b&&h;return l.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(Y,{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",y?"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",y?"opacity-100":"opacity-0"),children:e.jsxs(z,{ref:p,initialViewState:{longitude:r.longitude,latitude:r.latitude,zoom:10},style:{height:"100%",width:"100%"},mapStyle:Q,attributionControl:!1,onLoad:j,children:[e.jsx(W,{mode:g}),d&&e.jsx(q,{id:"collision-edges",type:"geojson",data:d,children:e.jsx(U,{id:"collision-edges-line",type:"line",paint:{"line-color":"#3B3F4A","line-width":2,"line-opacity":.8},layout:{"line-cap":"round","line-join":"round"}})}),l.map(a=>{const s=a.hash===v,t=a.hash.startsWith("0x")?a.hash.slice(2,4).toUpperCase():a.hash.slice(0,2).toUpperCase();return e.jsx(A,{longitude:a.longitude,latitude:a.latitude,anchor:"center",children:e.jsx("div",{className:"cursor-pointer transition-all duration-150",onMouseEnter:()=>f(a.hash),onMouseLeave:()=>f(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:o,prefix:v,candidateHashes:f,onClose:g}){const p=L(),b=S(),h=H(),[m,l]=c.useState(null),n=c.useMemo(()=>new Set(h.map(s=>s.hash)),[h]),r=(p==null?void 0:p.neighbors)??{},d=c.useMemo(()=>{const s=t=>{if(r[t])return r[t];if(!t.startsWith("0x")&&r["0x"+t])return r["0x"+t];if(t.startsWith("0x")&&r[t.slice(2)])return r[t.slice(2)]};return f.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:n.has(t)||n.has("0x"+t)||n.has(t.replace(/^0x/,"")),isHub:b.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))},[f,r,n,b]),j=c.useMemo(()=>d.some(s=>s.latitude!=null&&s.longitude!=null&&(s.latitude!==0||s.longitude!==0)),[d]),y=c.useCallback(s=>{l(s)},[]),a=j?"4xl":"lg";return o?e.jsxs(R,{open:o,onClose:g,size:a,motionPlus:!0,className:j?"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:v})]}),e.jsxs("p",{className:"text-xs text-fg-secondary",children:[d.length," nodes share this prefix"]})]})]}),e.jsx("button",{onClick:g,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:g,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(B,{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:[j&&e.jsx("div",{className:"h-64 p-2 border-b border-edge-subtle",children:e.jsx(C,{nodes:d,hoveredHash:m,onHover:y})}),e.jsx("div",{className:"p-2",children:d.map(s=>e.jsx(M,{node:s,isHovered:m===s.hash,onHover:y},s.hash))})]}),j?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:y},s.hash))})}),e.jsx("div",{className:"overflow-hidden p-2",children:e.jsx(C,{nodes:d,hoveredHash:m,onHover:y})})]}):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:y},s.hash))})})]})]}):null}const se=c.memo(V);export{se as C,J as S}; diff --git a/frontend/dist/assets/Companion-CSLLhavp.js b/frontend/dist/assets/Companion-CSLLhavp.js new file mode 100644 index 00000000..cbcdab60 --- /dev/null +++ b/frontend/dist/assets/Companion-CSLLhavp.js @@ -0,0 +1,72 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CompanionPathMap-D5FruuYA.js","assets/index-i0xzpXop.js","assets/usePipelineStore-BqTRxIqB.js","assets/node-types-rVJPSDxd.js","assets/car-aFMoKQAR.js","assets/map-pin-off-CPSqCYZk.js","assets/index-oOga43RI.css","assets/maplibre-gl-B1CfjdFi.css","assets/CompanionEchoMap-BcAn2gmm.js"])))=>i.map(i=>d[i]); +import{aX as nn,fB as gs,aZ as Zs,a_ as rn,aY as Ct,a$ as ea,r as n,b0 as ln,b1 as he,b4 as Ce,aT as Q,b8 as q,b5 as xe,bi as on,b9 as jt,bd as St,be as _t,bj as cn,bf as Se,bg as ot,bk as dn,bh as fe,bl as ys,bm as un,bn as mn,bo as at,bp as pn,bq as xn,br as hn,aW as Ze,b6 as fn,fD as gn,d7 as Te,fE as ta,bt as yn,bu as te,bv as bn,bC as vn,dk as jn,dl as wn,bE as Nn,fF as kn,bs as $e,bD as it,bx as Cn,fG as Rt,bG as bs,fH as ct,b2 as qe,bz as sa,bA as Sn,bB as _n,d5 as vs,d8 as js,fC as Rn,bF as In,b3 as En,bb as Mn,bc as Pn,bw as aa,d3 as na,e as ae,j as e,c as P,a0 as be,fI as Tn,cZ as de,fJ as se,cE as ye,cs as dt,aa as ze,bM as ut,f2 as _e,f3 as Re,f4 as Ie,d as ge,fK as $n,fL as Dn,m as ue,fM as Fn,cT as nt,aC as je,aK as Ee,dK as He,aD as we,a2 as oe,bY as Be,eJ as Me,B as H,fN as Ln,fO as mt,au as On,Q as An,fP as zn,_ as ra,ca as Hn,V as De,fQ as Bn,dy as Gn,fR as It,fS as Kn,fT as Un,bI as wt,fU as qn,fV as Vn,fW as Wn,dJ as Qn,a1 as Et,ef as Yn,fX as Xn,fY as Jn,fZ as la,fq as Zn,f_ as er,f$ as tr,I as pe,C as ws,g0 as oa,g1 as sr,g2 as ar,g3 as nr,g4 as rr,g5 as lr,g6 as or,g7 as ir,g8 as cr,g9 as dr,ga as ur,gb as mr,a6 as pr,gc as xr,gd as hr,ge as fr,gf as gr,gg as yr,gh as br,gi as vr,gj as jr,gk as wr,gl as Nr,eE as kr}from"./index-i0xzpXop.js";import{P as Ns,a as ks,B as Cs,C as Ss}from"./PageLayout-B4RCJ-XT.js";import{e as Mt,g as Pt,a as Tt}from"./chat-utils-BdAUDg3r.js";import{c as _s,S as Cr,a as Sr}from"./SignalIndicator-D8uG_rJC.js";import{b as _r,F as Rr,y as Ir,R as Er,T as Mr,w as Pr,A as Tr,M as ia}from"./map-pin-C051lstq.js";import{p as $r,a as et,c as W,f as Xe,b as Dr,L as Fr,S as Je,s as Lr,u as Or,d as Ar}from"./element-movement-BD3SL-GU.js";import{s as zr}from"./use-text-value-T4f0bwXS.js";import{F as Hr}from"./use-tree-walker-B4ov8RnQ.js";import{a as tt}from"./index-CBEGRHd5.js";import{S as Rs}from"./search-DsTk_ZsM.js";import{S as Br}from"./share-2-B5yQaExh.js";import{R as Ge,L as Gr}from"./route-Df1YhBTq.js";import{R as ca}from"./rotate-ccw-DqV8JyUZ.js";import{T as Ke}from"./trash-2-DCqpUdF7.js";import{H as Fe}from"./hash-CyK-Kad6.js";import{C as Kr}from"./check-check-AfNqagLY.js";import{P as Ue}from"./plus-Bb8eT78f.js";import{S as Ur,C as qr}from"./ChatBubble-DL8lfbnv.js";import{p as Vr}from"./payload-detail-Bh2WvEK0.js";import{A as Wr}from"./arrow-down-SlBTV0Nc.js";import{C as Qr}from"./chevron-right-DsOuIRi8.js";import{C as da}from"./circle-alert-PnLnz8pa.js";import{f as Yr,c as Xr,a as Jr,M as Zr}from"./variants-Bbq7uzV_.js";import{C as ua}from"./clock-F-4SScS_.js";import{A as ma}from"./activity-DQoaymFw.js";import{T as pa}from"./thermometer-DhPCT8Cn.js";import{S as el}from"./shield-check-DlsLo8Eo.js";import{W as Is}from"./wand-sparkles-DBzA3PXL.js";import{C as tl}from"./compass-0fhguiKE.js";import{G as Es}from"./git-branch-DrsZ9sUq.js";import{F as re,L as le,D as ke}from"./fieldset-DCj-Bavz.js";import{C as xa}from"./ConfirmModal-CtS0orbM.js";import{K as ha}from"./key-round-BpDWKeL5.js";import{F as fa,P as sl}from"./pencil-8q_J08l4.js";var al=Object.defineProperty,nl=(t,s,a)=>s in t?al(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a,Ms=(t,s,a)=>(nl(t,typeof s!="symbol"?s+"":s,a),a),Z=(t=>(t[t.Open=0]="Open",t[t.Closed=1]="Closed",t))(Z||{}),rt=(t=>(t[t.Pointer=0]="Pointer",t[t.Other=1]="Other",t))(rt||{}),G=(t=>(t[t.OpenMenu=0]="OpenMenu",t[t.CloseMenu=1]="CloseMenu",t[t.GoToItem=2]="GoToItem",t[t.Search=3]="Search",t[t.ClearSearch=4]="ClearSearch",t[t.RegisterItems=5]="RegisterItems",t[t.UnregisterItems=6]="UnregisterItems",t[t.SetButtonElement=7]="SetButtonElement",t[t.SetItemsElement=8]="SetItemsElement",t[t.SortItems=9]="SortItems",t[t.MarkButtonAsMoved=10]="MarkButtonAsMoved",t))(G||{});function Ps(t,s=a=>a){let a=t.activeItemIndex!==null?t.items[t.activeItemIndex]:null,r=ea(s(t.items.slice()),i=>i.dataRef.current.domRef.current),l=a?r.indexOf(a):null;return l===-1&&(l=null),{items:r,activeItemIndex:l}}let rl={1(t){if(t.menuState===1)return t;let s=t.buttonElement?et.Tracked(Dr(t.buttonElement)):t.buttonPositionState;return{...t,activeItemIndex:null,pendingFocus:{focus:W.Nothing},menuState:1,buttonPositionState:s}},0(t,s){return t.menuState===0?t:{...t,__demoMode:!1,pendingFocus:s.focus,menuState:0,buttonPositionState:et.Idle}},2:(t,s)=>{var a,r,l,i,o;if(t.menuState===1)return t;let x={...t,searchQuery:"",activationTrigger:(a=s.trigger)!=null?a:1,__demoMode:!1};if(s.focus===W.Nothing)return{...x,activeItemIndex:null};if(s.focus===W.Specific)return{...x,activeItemIndex:t.items.findIndex(c=>c.id===s.id)};if(s.focus===W.Previous){let c=t.activeItemIndex;if(c!==null){let b=t.items[c].dataRef.current.domRef,y=Xe(s,{resolveItems:()=>t.items,resolveActiveIndex:()=>t.activeItemIndex,resolveId:g=>g.id,resolveDisabled:g=>g.dataRef.current.disabled});if(y!==null){let g=t.items[y].dataRef.current.domRef;if(((r=b.current)==null?void 0:r.previousElementSibling)===g.current||((l=g.current)==null?void 0:l.previousElementSibling)===null)return{...x,activeItemIndex:y}}}}else if(s.focus===W.Next){let c=t.activeItemIndex;if(c!==null){let b=t.items[c].dataRef.current.domRef,y=Xe(s,{resolveItems:()=>t.items,resolveActiveIndex:()=>t.activeItemIndex,resolveId:g=>g.id,resolveDisabled:g=>g.dataRef.current.disabled});if(y!==null){let g=t.items[y].dataRef.current.domRef;if(((i=b.current)==null?void 0:i.nextElementSibling)===g.current||((o=g.current)==null?void 0:o.nextElementSibling)===null)return{...x,activeItemIndex:y}}}}let p=Ps(t),C=Xe(s,{resolveItems:()=>p.items,resolveActiveIndex:()=>p.activeItemIndex,resolveId:c=>c.id,resolveDisabled:c=>c.dataRef.current.disabled});return{...x,...p,activeItemIndex:C}},3:(t,s)=>{let a=t.searchQuery!==""?0:1,r=t.searchQuery+s.value.toLowerCase(),l=(t.activeItemIndex!==null?t.items.slice(t.activeItemIndex+a).concat(t.items.slice(0,t.activeItemIndex+a)):t.items).find(o=>{var x;return((x=o.dataRef.current.textValue)==null?void 0:x.startsWith(r))&&!o.dataRef.current.disabled}),i=l?t.items.indexOf(l):-1;return i===-1||i===t.activeItemIndex?{...t,searchQuery:r}:{...t,searchQuery:r,activeItemIndex:i,activationTrigger:1}},4(t){return t.searchQuery===""?t:{...t,searchQuery:"",searchActiveItemIndex:null}},5:(t,s)=>{let a=t.items.concat(s.items.map(l=>l)),r=t.activeItemIndex;return t.pendingFocus.focus!==W.Nothing&&(r=Xe(t.pendingFocus,{resolveItems:()=>a,resolveActiveIndex:()=>t.activeItemIndex,resolveId:l=>l.id,resolveDisabled:l=>l.dataRef.current.disabled})),{...t,items:a,activeItemIndex:r,pendingFocus:{focus:W.Nothing},pendingShouldSort:!0}},6:(t,s)=>{let a=t.items,r=[],l=new Set(s.items);for(let[i,o]of a.entries())if(l.has(o.id)&&(r.push(i),l.delete(o.id),l.size===0))break;if(r.length>0){a=a.slice();for(let i of r.reverse())a.splice(i,1)}return{...t,items:a,activationTrigger:1}},7:(t,s)=>t.buttonElement===s.element?t:{...t,buttonElement:s.element},8:(t,s)=>t.itemsElement===s.element?t:{...t,itemsElement:s.element},9:t=>t.pendingShouldSort?{...t,...Ps(t),pendingShouldSort:!1}:t,10(t){return t.buttonPositionState.kind!=="Tracked"?t:{...t,buttonPositionState:et.Moved}}};class $t extends nn{constructor(s){super(s),Ms(this,"actions",{registerItem:gs(()=>{let a=[],r=new Set;return[(l,i)=>{r.has(i)||(r.add(i),a.push({id:l,dataRef:i}))},()=>(r.clear(),this.send({type:5,items:a.splice(0)}))]}),unregisterItem:gs(()=>{let a=[];return[r=>a.push(r),()=>this.send({type:6,items:a.splice(0)})]})}),Ms(this,"selectors",{activeDescendantId(a){var r;let l=a.activeItemIndex,i=a.items;return l===null||(r=i[l])==null?void 0:r.id},isActive(a,r){var l;let i=a.activeItemIndex,o=a.items;return i!==null?((l=o[i])==null?void 0:l.id)===r:!1},shouldScrollIntoView(a,r){return a.__demoMode||a.menuState!==0||a.activationTrigger===0?!1:this.isActive(a,r)},didButtonMove(a){return a.buttonPositionState.kind==="Moved"}}),this.on(5,()=>{this.disposables.requestAnimationFrame(()=>{this.send({type:9})})});{let a=this.state.id,r=Zs.get(null);this.disposables.add(r.on(rn.Push,l=>{!r.selectors.isTop(l,a)&&this.state.menuState===0&&this.send({type:1})})),this.on(0,()=>r.actions.push(a)),this.on(1,()=>r.actions.pop(a))}this.disposables.group(a=>{this.on(1,r=>{r.buttonElement&&(a.dispose(),a.add($r(r.buttonElement,r.buttonPositionState,()=>{this.send({type:10})})))})})}static new({id:s,__demoMode:a=!1}){return new $t({id:s,__demoMode:a,menuState:a?0:1,buttonElement:null,itemsElement:null,items:[],searchQuery:"",activeItemIndex:null,activationTrigger:1,pendingShouldSort:!1,pendingFocus:{focus:W.Nothing},buttonPositionState:et.Idle})}reduce(s,a){return Ct(a.type,rl,s,a)}}const ga=n.createContext(null);function Dt(t){let s=n.useContext(ga);if(s===null){let a=new Error(`<${t} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(a,ya),a}return s}function ya({id:t,__demoMode:s=!1}){let a=n.useMemo(()=>$t.new({id:t,__demoMode:s}),[]);return ln(()=>a.dispose()),a}let ll=n.Fragment;function ol(t,s){let a=n.useId(),{__demoMode:r=!1,...l}=t,i=ya({id:a,__demoMode:r}),[o,x,p]=xe(i,w=>[w.menuState,w.itemsElement,w.buttonElement]),C=Ce(s),c=Zs.get(null),b=xe(c,n.useCallback(w=>c.selectors.isTop(w,a),[c,a]));vn(b,[p,x],(w,f)=>{var M;i.send({type:G.CloseMenu}),jn(f,wn.Loose)||(w.preventDefault(),(M=i.state.buttonElement)==null||M.focus())});let y=Q(()=>{i.send({type:G.CloseMenu})}),g=Se({open:o===Z.Open,close:y}),d={ref:C},v=fe();return te.createElement(Tr,null,te.createElement(ga.Provider,{value:i},te.createElement(Nn,{value:Ct(o,{[Z.Open]:at.Open,[Z.Closed]:at.Closed})},v({ourProps:d,theirProps:l,slot:g,defaultTag:ll,name:"Menu"}))))}let il="button";function cl(t,s){let a=Dt("Menu.Button"),r=n.useId(),{id:l=`headlessui-menu-button-${r}`,disabled:i=!1,autoFocus:o=!1,...x}=t,p=n.useRef(null),C=_r(),c=Ce(s,p,Rr(),Q(m=>a.send({type:G.SetButtonElement,element:m}))),b=Q(m=>{switch(m.key){case q.Space:case q.Enter:case q.ArrowDown:m.preventDefault(),m.stopPropagation(),a.send({type:G.OpenMenu,focus:{focus:W.First}});break;case q.ArrowUp:m.preventDefault(),m.stopPropagation(),a.send({type:G.OpenMenu,focus:{focus:W.Last}});break}}),y=Q(m=>{switch(m.key){case q.Space:m.preventDefault();break}}),[g,d,v]=xe(a,m=>[m.menuState,m.buttonElement,m.itemsElement]),w=g===Z.Open;Fr(w,{trigger:d,action:n.useCallback(m=>{if(d!=null&&d.contains(m.target))return Je.Ignore;let _=m.target.closest('[role="menuitem"]:not([data-disabled])');return on(_)?Je.Select(_):v!=null&&v.contains(m.target)?Je.Ignore:Je.Close},[d,v]),close:n.useCallback(()=>a.send({type:G.CloseMenu}),[]),select:n.useCallback(m=>m.click(),[])});let f=Lr(m=>{var _;i||(g===Z.Open?(jt.flushSync(()=>a.send({type:G.CloseMenu})),(_=p.current)==null||_.focus({preventScroll:!0})):(m.preventDefault(),a.send({type:G.OpenMenu,focus:{focus:W.Nothing},trigger:rt.Pointer})))}),{isFocusVisible:M,focusProps:I}=St({autoFocus:o}),{isHovered:R,hoverProps:j}=_t({isDisabled:i}),{pressed:k,pressProps:$}=cn({disabled:i}),N=Se({open:g===Z.Open,active:k||g===Z.Open,disabled:i,hover:R,focus:M,autofocus:o}),u=ot(C(),{ref:c,id:l,type:dn(t,p.current),"aria-haspopup":"menu","aria-controls":v==null?void 0:v.id,"aria-expanded":g===Z.Open,disabled:i||void 0,autoFocus:o,onKeyDown:b,onKeyUp:y},f,I,j,$);return fe()({ourProps:u,theirProps:x,slot:N,defaultTag:il,name:"Menu.Button"})}let dl="div",ul=bs.RenderStrategy|bs.Static;function ml(t,s){let a=n.useId(),{id:r=`headlessui-menu-items-${a}`,anchor:l,portal:i=!1,modal:o=!0,transition:x=!1,...p}=t,C=Ir(l),c=Dt("Menu.Items"),[b,y]=Er(C),g=Mr(),[d,v]=n.useState(null),w=Ce(s,C?b:null,Q(D=>c.send({type:G.SetItemsElement,element:D})),v),[f,M]=xe(c,D=>[D.menuState,D.buttonElement]),I=ys(M),R=ys(d);C&&(i=!0);let j=un(),[k,$]=mn(x,d,j!==null?(j&at.Open)===at.Open:f===Z.Open);pn(k,M,()=>{c.send({type:G.CloseMenu})});let N=xe(c,D=>D.__demoMode),u=N?!1:o&&f===Z.Open;xn(u,R);let m=N?!1:o&&f===Z.Open;hn(m,{allowed:n.useCallback(()=>[M,d],[M,d])});let _=xe(c,c.selectors.didButtonMove)?!1:k;n.useEffect(()=>{let D=d;D&&f===Z.Open&&(Ze(D)||D.focus({preventScroll:!0}))},[f,d]),Hr(f===Z.Open,{container:d,accept(D){return D.getAttribute("role")==="menuitem"?NodeFilter.FILTER_REJECT:D.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(D){D.setAttribute("role","none")}});let h=fn(),T=Q(D=>{var K,ee,V;switch(h.dispose(),D.key){case q.Space:if(c.state.searchQuery!=="")return D.preventDefault(),D.stopPropagation(),c.send({type:G.Search,value:D.key});case q.Enter:if(D.preventDefault(),D.stopPropagation(),c.state.activeItemIndex!==null){let{dataRef:F}=c.state.items[c.state.activeItemIndex];(ee=(K=F.current)==null?void 0:K.domRef.current)==null||ee.click()}c.send({type:G.CloseMenu}),ta(c.state.buttonElement);break;case q.ArrowDown:return D.preventDefault(),D.stopPropagation(),c.send({type:G.GoToItem,focus:W.Next});case q.ArrowUp:return D.preventDefault(),D.stopPropagation(),c.send({type:G.GoToItem,focus:W.Previous});case q.Home:case q.PageUp:return D.preventDefault(),D.stopPropagation(),c.send({type:G.GoToItem,focus:W.First});case q.End:case q.PageDown:return D.preventDefault(),D.stopPropagation(),c.send({type:G.GoToItem,focus:W.Last});case q.Escape:D.preventDefault(),D.stopPropagation(),jt.flushSync(()=>c.send({type:G.CloseMenu})),(V=c.state.buttonElement)==null||V.focus({preventScroll:!0});break;case q.Tab:D.preventDefault(),D.stopPropagation(),jt.flushSync(()=>c.send({type:G.CloseMenu})),gn(c.state.buttonElement,D.shiftKey?Te.Previous:Te.Next);break;default:D.key.length===1&&(c.send({type:G.Search,value:D.key}),h.setTimeout(()=>c.send({type:G.ClearSearch}),350));break}}),S=Q(D=>{switch(D.key){case q.Space:D.preventDefault();break}}),O=Se({open:f===Z.Open}),ie=ot(C?g():{},{"aria-activedescendant":xe(c,c.selectors.activeDescendantId),"aria-labelledby":xe(c,D=>{var K;return(K=D.buttonElement)==null?void 0:K.id}),id:r,onKeyDown:T,onKeyUp:S,role:"menu",tabIndex:f===Z.Open?0:void 0,ref:w,style:{...p.style,...y,"--button-width":Pr(k,M,!0).width},...yn($)}),Y=fe();return te.createElement(bn,{enabled:i?t.static||k:!1,ownerDocument:I},Y({ourProps:ie,theirProps:p,slot:O,defaultTag:dl,features:ul,visible:_,name:"Menu.Items"}))}let pl=n.Fragment;function xl(t,s){let a=n.useId(),{id:r=`headlessui-menu-item-${a}`,disabled:l=!1,...i}=t,o=Dt("Menu.Item"),x=xe(o,_=>o.selectors.isActive(_,r)),p=n.useRef(null),C=Ce(s,p),c=xe(o,_=>o.selectors.shouldScrollIntoView(_,r));$e(()=>{if(c)return Cn().requestAnimationFrame(()=>{var _,h;(h=(_=p.current)==null?void 0:_.scrollIntoView)==null||h.call(_,{block:"nearest"})})},[c,p]);let b=zr(p),y=n.useRef({disabled:l,domRef:p,get textValue(){return b()}});$e(()=>{y.current.disabled=l},[y,l]),$e(()=>(o.actions.registerItem(r,y),()=>o.actions.unregisterItem(r)),[y,r]);let g=Q(()=>{o.send({type:G.CloseMenu})}),d=Q(_=>{if(l)return _.preventDefault();o.send({type:G.CloseMenu}),ta(o.state.buttonElement)}),v=Q(()=>{if(l)return o.send({type:G.GoToItem,focus:W.Nothing});o.send({type:G.GoToItem,focus:W.Specific,id:r})}),w=Or(),f=Q(_=>w.update(_)),M=Q(_=>{w.wasMoved(_)&&(l||x||o.send({type:G.GoToItem,focus:W.Specific,id:r,trigger:rt.Pointer}))}),I=Q(_=>{w.wasMoved(_)&&(l||x&&o.state.activationTrigger===rt.Pointer&&o.send({type:G.GoToItem,focus:W.Nothing}))}),[R,j]=it(),[k,$]=Rt(),N=Se({active:x,focus:x,disabled:l,close:g}),u={id:r,ref:C,role:"menuitem",tabIndex:l===!0?void 0:-1,"aria-disabled":l===!0?!0:void 0,"aria-labelledby":R,"aria-describedby":k,disabled:void 0,onClick:d,onFocus:v,onPointerEnter:f,onMouseEnter:f,onPointerMove:M,onMouseMove:M,onPointerLeave:I,onMouseLeave:I},m=fe();return te.createElement(j,null,te.createElement($,null,m({ourProps:u,theirProps:i,slot:N,defaultTag:pl,name:"Menu.Item"})))}let hl="div";function fl(t,s){let[a,r]=it(),l=t,i={ref:s,"aria-labelledby":a,role:"group"},o=fe();return te.createElement(r,null,o({ourProps:i,theirProps:l,slot:{},defaultTag:hl,name:"Menu.Section"}))}let gl="header";function yl(t,s){let a=n.useId(),{id:r=`headlessui-menu-heading-${a}`,...l}=t,i=kn();$e(()=>i.register(r),[r,i.register]);let o={id:r,ref:s,role:"presentation",...i.props};return fe()({ourProps:o,theirProps:l,slot:{},defaultTag:gl,name:"Menu.Heading"})}let bl="div";function vl(t,s){let a=t,r={ref:s,role:"separator"};return fe()({ourProps:r,theirProps:a,slot:{},defaultTag:bl,name:"Menu.Separator"})}let jl=he(ol),ba=he(cl),va=he(ml),Nt=he(xl),wl=he(fl),Nl=he(yl),ja=he(vl),kl=Object.assign(jl,{Button:ba,Items:va,Item:Nt,Section:wl,Heading:Nl,Separator:ja});var Cl=(t=>(t[t.RegisterOption=0]="RegisterOption",t[t.UnregisterOption=1]="UnregisterOption",t))(Cl||{});let Sl={0(t,s){let a=[...t.options,{id:s.id,element:s.element,propsRef:s.propsRef}];return{...t,options:ea(a,r=>r.element.current)}},1(t,s){let a=t.options.slice(),r=t.options.findIndex(l=>l.id===s.id);return r===-1?t:(a.splice(r,1),{...t,options:a})}},Ft=n.createContext(null);Ft.displayName="RadioGroupDataContext";function Lt(t){let s=n.useContext(Ft);if(s===null){let a=new Error(`<${t} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(a,Lt),a}return s}let Ot=n.createContext(null);Ot.displayName="RadioGroupActionsContext";function At(t){let s=n.useContext(Ot);if(s===null){let a=new Error(`<${t} /> is missing a parent component.`);throw Error.captureStackTrace&&Error.captureStackTrace(a,At),a}return s}function _l(t,s){return Ct(s.type,Sl,t,s)}let Rl="div";function Il(t,s){let a=n.useId(),r=sa(),{id:l=`headlessui-radiogroup-${a}`,value:i,form:o,name:x,onChange:p,by:C,disabled:c=r||!1,defaultValue:b,tabIndex:y=0,...g}=t,d=Ar(C),[v,w]=n.useReducer(_l,{options:[]}),f=v.options,[M,I]=it(),[R,j]=Rt(),k=n.useRef(null),$=Ce(k,s),N=Sn(b),[u,m]=_n(i,p,N),_=n.useMemo(()=>f.find(F=>!F.propsRef.current.disabled),[f]),h=n.useMemo(()=>f.some(F=>d(F.propsRef.current.value,u)),[f,u]),T=Q(F=>{var A;if(c||d(F,u))return!1;let z=(A=f.find(U=>d(U.propsRef.current.value,F)))==null?void 0:A.propsRef.current;return z!=null&&z.disabled?!1:(m==null||m(F),!0)}),S=Q(F=>{if(!k.current)return;let A=f.filter(z=>z.propsRef.current.disabled===!1).map(z=>z.element.current);switch(F.key){case q.Enter:Rn(F.currentTarget);break;case q.ArrowLeft:case q.ArrowUp:if(F.preventDefault(),F.stopPropagation(),vs(A,Te.Previous|Te.WrapAround)===js.Success){let z=f.find(U=>Ze(U.element.current));z&&T(z.propsRef.current.value)}break;case q.ArrowRight:case q.ArrowDown:if(F.preventDefault(),F.stopPropagation(),vs(A,Te.Next|Te.WrapAround)===js.Success){let z=f.find(U=>Ze(U.element.current));z&&T(z.propsRef.current.value)}break;case q.Space:{F.preventDefault(),F.stopPropagation();let z=f.find(U=>Ze(U.element.current));z&&T(z.propsRef.current.value)}break}}),O=Q(F=>(w({type:0,...F}),()=>w({type:1,id:F.id}))),ie=n.useMemo(()=>({value:u,firstOption:_,containsCheckedOption:h,disabled:c,compare:d,tabIndex:y,...v}),[u,_,h,c,d,y,v]),Y=n.useMemo(()=>({registerOption:O,change:T}),[O,T]),D={ref:$,id:l,role:"radiogroup","aria-labelledby":M,"aria-describedby":R,onKeyDown:S},K=Se({value:u}),ee=n.useCallback(()=>{if(N!==void 0)return T(N)},[T,N]),V=fe();return te.createElement(j,{name:"RadioGroup.Description"},te.createElement(I,{name:"RadioGroup.Label"},te.createElement(Ot.Provider,{value:Y},te.createElement(Ft.Provider,{value:ie},x!=null&&te.createElement(In,{disabled:c,data:{[x]:u||"on"},overrides:{type:"radio",checked:u!=null},form:o,onReset:ee}),V({ourProps:D,theirProps:g,slot:K,defaultTag:Rl,name:"RadioGroup"})))))}let El="div";function Ml(t,s){var a;let r=Lt("RadioGroup.Option"),l=At("RadioGroup.Option"),i=n.useId(),{id:o=`headlessui-radiogroup-option-${i}`,value:x,disabled:p=r.disabled||!1,autoFocus:C=!1,...c}=t,b=n.useRef(null),y=Ce(b,s),[g,d]=it(),[v,w]=Rt(),f=aa({value:x,disabled:p});$e(()=>l.registerOption({id:o,element:b,propsRef:f}),[o,l,b,f]);let M=Q(h=>{var T;if(na(h.currentTarget))return h.preventDefault();l.change(x)&&((T=b.current)==null||T.focus())}),I=((a=r.firstOption)==null?void 0:a.id)===o,{isFocusVisible:R,focusProps:j}=St({autoFocus:C}),{isHovered:k,hoverProps:$}=_t({isDisabled:p}),N=r.compare(r.value,x),u=ot({ref:y,id:o,role:"radio","aria-checked":N?"true":"false","aria-labelledby":g,"aria-describedby":v,"aria-disabled":p?!0:void 0,tabIndex:p?-1:N||!r.containsCheckedOption&&I?r.tabIndex:-1,onClick:p?void 0:M,autoFocus:C},j,$),m=Se({checked:N,disabled:p,active:R,hover:k,focus:R,autofocus:C}),_=fe();return te.createElement(w,{name:"RadioGroup.Description"},te.createElement(d,{name:"RadioGroup.Label"},_({ourProps:u,theirProps:c,slot:m,defaultTag:El,name:"RadioGroup.Option"})))}let Pl="span";function Tl(t,s){var a;let r=Lt("Radio"),l=At("Radio"),i=n.useId(),o=En(),x=sa(),{id:p=o||`headlessui-radio-${i}`,value:C,disabled:c=r.disabled||x||!1,autoFocus:b=!1,...y}=t,g=n.useRef(null),d=Ce(g,s),v=Mn(),w=Pn(),f=aa({value:C,disabled:c});$e(()=>l.registerOption({id:p,element:g,propsRef:f}),[p,l,g,f]);let M=Q(_=>{var h;if(na(_.currentTarget))return _.preventDefault();l.change(C)&&((h=g.current)==null||h.focus())}),{isFocusVisible:I,focusProps:R}=St({autoFocus:b}),{isHovered:j,hoverProps:k}=_t({isDisabled:c}),$=((a=r.firstOption)==null?void 0:a.id)===p,N=r.compare(r.value,C),u=ot({ref:d,id:p,role:"radio","aria-checked":N?"true":"false","aria-labelledby":v,"aria-describedby":w,"aria-disabled":c?!0:void 0,tabIndex:c?-1:N||!r.containsCheckedOption&&$?r.tabIndex:-1,autoFocus:b,onClick:c?void 0:M},R,k),m=Se({checked:N,disabled:c,hover:j,focus:I,autofocus:b});return fe()({ourProps:u,theirProps:y,slot:m,defaultTag:Pl,name:"Radio"})}let $l=he(Il),Dl=he(Ml),pt=he(Tl),Fl=qe,Ll=ct,Ol=Object.assign($l,{Option:Dl,Radio:pt,Label:Fl,Description:Ll});/** + * @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 Al=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],zl=ae("arrow-left",Al);/** + * @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 Hl=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],wa=ae("circle-dot",Hl);/** + * @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 Bl=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]],Gl=ae("crosshair",Bl);/** + * @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 Kl=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],Ul=ae("ellipsis-vertical",Kl);/** + * @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 ql=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],Vl=ae("key",ql);/** + * @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 Wl=[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]],kt=ae("log-in",Wl);/** + * @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 Ql=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],Yl=ae("panel-left-close",Ql);/** + * @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 Xl=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],Jl=ae("panel-left-open",Xl);/** + * @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 Zl=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],Ts=ae("panel-right-close",Zl);/** + * @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 eo=[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]],to=ae("radar",eo);/** + * @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 so=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],ao=ae("save",so);/** + * @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 no=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],ro=ae("star",no);/** + * @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 lo=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],zt=ae("upload",lo);/** + * @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 oo=[["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:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],io=ae("user-plus",oo),Ve={sm:{radio:"h-4 w-4",dot:"h-1.5 w-1.5",text:"text-sm",descText:"text-xs",padding:"py-2 px-3",segmentPadding:"py-1.5 px-2.5"},md:{radio:"h-5 w-5",dot:"h-2 w-2",text:"text-sm",descText:"text-xs",padding:"py-3 px-4",segmentPadding:"py-2 px-3"},lg:{radio:"h-6 w-6",dot:"h-2.5 w-2.5",text:"text-base",descText:"text-sm",padding:"py-4 px-5",segmentPadding:"py-2.5 px-4"}};function Na({checked:t,size:s,disabled:a}){const r=Ve[s];return e.jsx("span",{className:P("relative flex shrink-0 items-center justify-center rounded-full border-2 transition-all duration-150",r.radio,t?"border-sys-blue bg-sys-blue":"border-edge-subtle bg-subtle",!t&&!a&&"group-hover:border-edge-strong",a&&"opacity-50"),children:t&&e.jsx("span",{className:P(r.dot,"rounded-full bg-white")})})}function co({option:t,size:s}){const a=Ve[s];return e.jsx(pt,{value:t.value,disabled:t.disabled,className:"group flex items-start gap-3 cursor-pointer ring-focus rounded-lg",children:({checked:r,disabled:l})=>e.jsxs(e.Fragment,{children:[e.jsx(Na,{checked:r,size:s,disabled:l}),e.jsxs("div",{className:"flex-1 min-w-0 select-none",children:[e.jsx(qe,{className:P(a.text,"font-medium cursor-pointer",l?"text-fg-muted":"text-fg-primary"),children:t.label}),t.description&&e.jsx(ct,{className:P(a.descText,"text-fg-muted mt-0.5"),children:t.description})]})]})})}function uo({option:t,size:s}){const a=Ve[s];return e.jsx(pt,{value:t.value,disabled:t.disabled,className:P("group relative flex cursor-pointer ring-focus","radius-inset border-2 transition-all duration-150",a.padding),children:({checked:r,disabled:l})=>e.jsxs(e.Fragment,{children:[e.jsx("span",{className:P("absolute inset-0 radius-inset transition-colors",r?"border-sys-blue bg-sys-blue/5":"border-edge-subtle bg-subtle",!r&&!l&&"group-hover:border-edge-strong group-hover:bg-elevated",l&&"opacity-50"),style:{borderWidth:"inherit"}}),e.jsxs("div",{className:"relative flex items-start gap-3 w-full",children:[t.icon&&e.jsx("span",{className:P("shrink-0",r?"text-sys-blue":"text-fg-muted"),children:t.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(qe,{className:P(a.text,"font-medium cursor-pointer",l?"text-fg-muted":r?"text-sys-blue":"text-fg-primary"),children:t.label}),t.description&&e.jsx(ct,{className:P(a.descText,"text-fg-muted mt-0.5"),children:t.description})]}),e.jsx(Na,{checked:r,size:s,disabled:l})]})]})})}function mo({option:t,size:s,isFirst:a,isLast:r}){const l=Ve[s];return e.jsx(pt,{value:t.value,disabled:t.disabled,className:P("group relative flex items-center justify-center cursor-pointer ring-focus","transition-all duration-150",l.segmentPadding,a&&"rounded-l-lg",r&&"rounded-r-lg"),children:({checked:i,disabled:o})=>e.jsxs(e.Fragment,{children:[e.jsx("span",{className:P("absolute inset-0 transition-colors",i?"bg-sys-blue":"bg-transparent",!i&&!o&&"group-hover:bg-subtle-fill",a&&"rounded-l-lg",r&&"rounded-r-lg",o&&"opacity-50")}),e.jsxs(qe,{className:P("relative z-10 font-medium cursor-pointer select-none",l.text,i?"text-white":o?"text-fg-muted":"text-fg-primary"),children:[t.icon&&e.jsx("span",{className:"mr-1.5 inline-flex",children:t.icon}),t.label]})]})})}function po({label:t,description:s,options:a,value:r,onChange:l,size:i="md",variant:o="simple",orientation:x="vertical",name:p,disabled:C,className:c}){const b=Ve[i];return e.jsxs(Ol,{value:r,onChange:l,name:p,disabled:C,className:P("space-y-3",c),children:[t&&e.jsx(qe,{className:P(b.text,"font-medium text-fg-primary"),children:t}),s&&e.jsx(ct,{className:P(b.descText,"text-fg-muted -mt-1"),children:s}),o==="segmented"?e.jsx("div",{className:"inline-flex rounded-lg bg-subtle-fill-strong p-0.5",children:a.map((y,g)=>e.jsx(mo,{option:y,size:i,isFirst:g===0,isLast:g===a.length-1},y.value))}):e.jsx("div",{className:P(o==="card"&&x==="horizontal"&&"grid grid-cols-2 gap-3 sm:grid-cols-3",o==="card"&&x==="vertical"&&"space-y-3",o==="simple"&&x==="horizontal"&&"flex flex-wrap gap-4",o==="simple"&&x==="vertical"&&"space-y-2"),children:a.map(y=>o==="card"?e.jsx(uo,{option:y,size:i},y.value):e.jsx(co,{option:y,size:i},y.value))})]})}function Ne({children:t,className:s,onClick:a,disabled:r=!1,destructive:l=!1,icon:i,trailing:o,href:x,checked:p}){const C=e.jsxs(e.Fragment,{children:[(i||p!==void 0)&&e.jsx("span",{className:P("flex-shrink-0 w-4 h-4 flex items-center justify-center","text-fg-muted",l&&"text-sys-red","group-data-[focus]:text-white"),children:p!==void 0?p?e.jsx(be,{className:"h-4 w-4 text-sys-blue group-data-[focus]:text-white"}):null:i}),e.jsx("span",{className:"flex-1 truncate",children:t}),o&&e.jsx("span",{className:"flex-shrink-0 text-fg-muted group-data-[focus]:text-white/70 text-xs",children:o})]}),c=P("group flex items-center gap-2 w-full","px-3 py-2 radius-control cursor-default","text-sm text-left","transition-colors","focus:outline-none",r?"opacity-50 cursor-not-allowed":[l?["text-sys-red","data-[focus]:bg-sys-red data-[focus]:text-white"]:["text-fg-primary","data-[focus]:bg-sys-blue data-[focus]:text-white"]],s);return x&&!r?e.jsx(Nt,{children:e.jsx("a",{href:x,className:c,children:C})}):e.jsx(Nt,{disabled:r,children:e.jsx("button",{type:"button",onClick:a,disabled:r,className:c,children:C})})}function xo({className:t}){return e.jsx(ja,{className:P("my-1 h-px bg-border-subtle",t)})}const ho=100,fo=101,go=102,yo=103,bo=104,vo=115,jo=116,wo=117,No=120,ko=125,Co=128,So=136;function _o(t){const s=new Tn(t),a=[];for(;s.getRemainingBytesCount()>=2;){const r=s.readUInt8(),l=s.readUInt8();if(r===0&&l===0)break;switch(l){case ho:a.push({channel:r,type:l,value:s.readUInt32BE()});break;case fo:a.push({channel:r,type:l,value:s.readInt16BE()});break;case go:a.push({channel:r,type:l,value:s.readUInt8()});break;case yo:a.push({channel:r,type:l,value:s.readInt16BE()/10});break;case bo:a.push({channel:r,type:l,value:s.readUInt8()/2});break;case vo:a.push({channel:r,type:l,value:s.readUInt16BE()/10});break;case jo:a.push({channel:r,type:l,value:s.readInt16BE()/100});break;case wo:a.push({channel:r,type:l,value:s.readInt16BE()/1e3});break;case No:a.push({channel:r,type:l,value:s.readUInt8()});break;case ko:a.push({channel:r,type:l,value:s.readUInt16BE()});break;case Co:a.push({channel:r,type:l,value:s.readUInt16BE()});break;case So:a.push({channel:r,type:l,value:{latitude:s.readInt24BE()/1e4,longitude:s.readInt24BE()/1e4,altitude:s.readInt24BE()/100}});break;default:return a}}return a}const ka="pymc_companion_contacts_micro",Ca="pymc_companion_favorites",yt=56;function $s(){try{return localStorage.getItem(ka)==="1"}catch{return!1}}function Ro(t){try{localStorage.setItem(ka,t?"1":"0")}catch{}}function Io(){try{const t=localStorage.getItem(Ca);return t?new Set(JSON.parse(t)):new Set}catch{return new Set}}function Eo(t){try{localStorage.setItem(Ca,JSON.stringify([...t]))}catch{}}function Mo({name:t,pubkey:s,advType:a,size:r="md",signal:l}){const i=(a??0)&15,o=r==="sm"?"w-5 h-5":"w-6 h-6",x=r==="sm"?"size-3":"size-3.5";if(i===2){const b=l&&l.rssi!==0,y=b?`RSSI: ${l.rssi} dBm · SNR: ${l.snr.toFixed(1)} dB${l.rtt_ms!=null?` · RTT: ${l.rtt_ms} ms`:""}`:void 0;return e.jsx("div",{className:P(o,"relative rounded-full flex items-center justify-center flex-shrink-0 ring-[1.5px]",b?"ring-transparent":"ring-sys-blue"),title:y,children:b?e.jsx(Cr,{rssi:l.rssi,snr:l.snr,compact:!0,showValues:!1}):e.jsx(ze,{className:P(x,"text-sys-blue")})})}if(i===3)return e.jsx("div",{className:P(o,"relative rounded-full flex items-center justify-center flex-shrink-0 ring-[1.5px] ring-sys-pink"),children:e.jsx(dt,{className:P(x,"text-sys-pink")})});if(!t)return e.jsx("div",{className:P(o,"relative rounded-full bg-sys-blue/12 flex items-center justify-center flex-shrink-0"),children:e.jsx("span",{className:"text-sys-blue font-mono text-[10px] font-bold",children:s.slice(0,4)})});const{emoji:p}=Mt(t),C=Pt(t),c=Tt(t);return e.jsx("div",{className:P(o,"relative clay-avatar",p?"text-base":"text-white text-[11px] font-bold"),style:{"--avatar-color":C},children:p||c})}const Ds=[{key:"companion",label:"Companions",icon:ye,color:"text-sys-blue"},{key:"room",label:"Room Servers",icon:dt,color:"text-sys-pink"},{key:"repeater",label:"Repeaters",icon:ze,color:"text-sys-blue"}];function Po(t){const s=(t.adv_type??0)&15;return s===3?"room":s===2?"repeater":"companion"}const To=4e3,$o=5e3,Do=2e3,Fo=8;function Lo({contact:t,isActive:s,unread:a,lastMsg:r,isFav:l,microContent:i,onSelect:o,onShowDetails:x,onShareContact:p,onResetPath:C,onRemoveContact:c,onPingContact:b,repeaterNeighborHashes:y,repeaterSignal:g,toggleFavorite:d}){const v=$n(t.public_key),w=Dn(t.public_key),[f,M]=n.useState(!1),[I,R]=n.useState(!1),j=n.useRef(null),[k,$]=n.useState("idle"),N=n.useRef(!1),u=n.useRef(null),[m,_]=n.useState({w:0,h:0});n.useEffect(()=>{if(v)N.current=!0,$("idle");else if(N.current){N.current=!1;const D=se.getState().pingResults.get(t.public_key),K=D!=null&&D.rssi!==0;$(K?"success":"failed")}},[v,t.public_key]),n.useEffect(()=>{if(k==="idle")return;const K=setTimeout(()=>$("idle"),k==="success"?$o:Do);return()=>clearTimeout(K)},[k]);const h=(v||k!=="idle")&&!f;n.useEffect(()=>{if(!h)return;const D=u.current;if(!D)return;const K=()=>{const V=D.offsetWidth,F=D.offsetHeight;_(A=>A.w===V&&A.h===F?A:{w:V,h:F})};K();const ee=new ResizeObserver(K);return ee.observe(D),()=>ee.disconnect()},[h]);const T=n.useCallback(()=>{M(!0),j.current&&clearTimeout(j.current),j.current=setTimeout(()=>M(!1),To)},[]),S=n.useCallback(()=>{M(!1),j.current&&clearTimeout(j.current)},[]),O=n.useCallback(async()=>{c&&(j.current&&clearTimeout(j.current),R(!0),await c(t.public_key),R(!1),M(!1))},[c,t.public_key]),ie=n.useMemo(()=>{const D=w&&w.rssi!==0,K=g&&g.rssi!==0;if(!D&&!K)return null;if(D&&!K)return{rssi:w.rssi,snr:w.snr_db,rtt_ms:w.rtt_ms};if(!D&&K)return{rssi:g.rssi,snr:g.snr};const ee=g.advertCount,V=3,F=ee+V;return{rssi:Math.round((g.rssi*ee+w.rssi*V)/F),snr:(g.snr*ee+w.snr_db*V)/F,rtt_ms:w.rtt_ms}},[w,g]),Y=f?"":k==="success"?"bg-sys-green/5":k==="failed"?"bg-sys-red/5":v?"bg-sys-blue/5":s?"bg-sys-blue":"hover:bg-elevated";return e.jsxs(ue.div,{ref:u,layout:"position",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:de.fade,className:P("group relative w-full flex items-center gap-2.5 px-2.5 py-[3px] radius-inner overflow-hidden","transition-[background-color,box-shadow] duration-150",Y),children:[e.jsx(ge,{children:h&&m.w>0&&(k!=="idle"?e.jsx(ue.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{opacity:{duration:.15}},className:P("absolute inset-0 radius-inner ring-2 ring-inset pointer-events-none z-[2]",k==="success"?"ring-sys-green":"ring-sys-red")},`ping-${k}`):e.jsx(Fn,{borderRadius:Fo,width:m.w,height:m.h,color:"blue"},"ping-crawl"))}),e.jsxs("div",{className:"grid flex-1 min-w-0 [&>*]:col-start-1 [&>*]:row-start-1",children:[e.jsxs("div",{className:P("flex items-center gap-2.5",f&&!i&&"invisible pointer-events-none"),children:[e.jsxs("button",{onClick:()=>o({type:"contact",id:t.public_key}),className:"flex items-center gap-2.5 flex-1 min-w-0 text-left",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Mo,{name:t.name,pubkey:t.public_key,advType:t.adv_type,signal:ie}),a>0&&e.jsx("span",{className:"absolute -top-0.5 -right-0.5 h-2.5 w-2.5 rounded-full bg-sys-red ring-2 ring-body"})]}),!i&&e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-1",children:e.jsx("span",{className:P("text-sm truncate flex-1",s?"text-white font-medium":l?"text-sys-amber font-bold":"text-fg-primary font-medium"),children:t.name||t.public_key.slice(0,12)+"…"})}),k==="success"&&w?e.jsxs("div",{className:"text-[11px] text-sys-green font-medium truncate tabular-nums",children:[w.rssi," dBm · ",w.snr_db.toFixed(1)," dB",w.rtt_ms!=null&&` · ${w.rtt_ms} ms`]}):k==="failed"?e.jsx("div",{className:"text-[11px] text-sys-red font-medium truncate",children:"No response"}):r?e.jsx("div",{className:P("text-[11px] truncate",s?"text-white/70":"text-fg-muted"),children:r.text}):null]})]}),!i&&e.jsx("div",{className:"relative flex-shrink-0 w-[18px] h-[18px] flex items-center justify-center",children:e.jsx(kl,{as:"div",className:"absolute inset-0",children:({open:D})=>e.jsxs(e.Fragment,{children:[e.jsx(ba,{className:P("absolute inset-0 flex items-center justify-center rounded transition-[opacity,background-color] duration-100","focus:outline-none",s?"hover:bg-white/15":"hover:bg-subtle-fill",D?"opacity-100":"opacity-0 group-hover:opacity-100"),"aria-label":"Contact options",children:e.jsx(Ul,{className:P("h-3.5 w-3.5 transition-colors",s?"text-white/60 hover:text-white":"text-fg-muted hover:text-sys-blue")})}),e.jsxs(va,{anchor:"right start",transition:!0,className:P("min-w-[10rem] max-w-[20rem]","radius-inset p-1 ml-1","surface-elevated","focus:outline-none z-50","transition-[opacity,transform]","data-[closed]:opacity-0 data-[closed]:scale-[0.98] data-[closed]:translate-x-[-4px]","data-[enter]:duration-150 data-[leave]:duration-100","data-[enter]:ease-out data-[leave]:ease-in"),children:[e.jsx(Ne,{icon:e.jsx(nt,{className:"w-4 h-4"}),onClick:()=>{x==null||x({type:"contact",id:t.public_key})},children:"Details"}),p&&e.jsx(Ne,{icon:e.jsx(Br,{className:"w-4 h-4"}),onClick:()=>p(t.public_key),children:"Share"}),e.jsx(Ne,{icon:e.jsx(Ge,{className:"w-4 h-4"}),onClick:()=>o({type:"contact",id:t.public_key}),children:"Set Path"}),C&&e.jsx(Ne,{icon:e.jsx(ca,{className:"w-4 h-4"}),onClick:()=>C(t.public_key),children:"Reset Path"}),b&&e.jsx(Ne,{icon:e.jsx(Gl,{className:"w-4 h-4"}),onClick:()=>b(t.public_key),disabled:!(y!=null&&y.has(t.public_key)),children:"Ping"}),c&&e.jsx(Ne,{icon:e.jsx(Ke,{className:"w-4 h-4"}),destructive:!0,onClick:T,children:"Remove Contact"}),e.jsx(xo,{}),e.jsx(Ne,{icon:e.jsx(ro,{className:P("w-4 h-4 group-data-[focus]:text-white group-data-[focus]:fill-white",l?"text-sys-amber fill-sys-amber":"text-fg-muted")}),onClick:()=>d(t.public_key),children:l?"Unfavorite":"Favorite"})]})]})})})]}),!i&&e.jsx("div",{className:P("flex items-center gap-1.5 self-center",!f&&"invisible pointer-events-none"),children:I?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("div",{className:"w-3.5 h-3.5 animate-spin rounded-full border-2 border-white border-t-transparent"})}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:S,className:"flex-1 flex items-center justify-center py-1 radius-inner bg-zinc-500/80 hover:bg-zinc-500 depth-stroke-raised transition-colors",children:e.jsx("span",{className:"text-[11px] font-semibold text-white",children:"Cancel"})}),e.jsx("button",{onClick:O,className:"flex-1 flex items-center justify-center py-1 radius-inner bg-sys-red/80 hover:bg-sys-red depth-stroke-raised transition-colors",children:e.jsx(Ke,{className:"w-4 h-4 text-white"})})]})})]})]},t.public_key)}const Fs={excellent:4,good:3,fair:2,weak:1,poor:0};function Ls(t,s,a){const r=s==null?void 0:s.get(t),l=r&&r.rssi!==0,i=a==null?void 0:a.get(t),o=i&&typeof i.rssi=="number"&&i.rssi!==0;if(!l&&!o)return null;if(o&&!l)return i.rssi;if(!o&&l)return r.rssi;const x=r.advertCount,p=3;return Math.round((r.rssi*x+i.rssi*p)/(x+p))}function Oo(t,s,a,r,l){return[...t].sort((i,o)=>{var C,c,b,y;const x=s.has(i.public_key)?0:1,p=s.has(o.public_key)?0:1;if(x!==p)return x-p;if(a){const g=((c=(C=a.get(i.public_key))==null?void 0:C.at(-1))==null?void 0:c.timestamp)??0,d=((y=(b=a.get(o.public_key))==null?void 0:b.at(-1))==null?void 0:y.timestamp)??0;if(g!==d)return d-g}if(r){const g=Ls(i.public_key,r,l),d=Ls(o.public_key,r,l);if(g!=null&&d==null)return-1;if(g==null&&d!=null)return 1;if(g!=null&&d!=null){const v=Fs[_s(g)]??0,w=Fs[_s(d)]??0;if(v!==w)return w-v}}return(i.name||"").localeCompare(o.name||"")})}const Ao=n.memo(n.forwardRef(function({contacts:s,selectedConversation:a,unreadMap:r,messages:l,onSelect:i,onShowDetails:o,onShareContact:x,onResetPath:p,onRemoveContact:C,onPingContact:c,repeaterNeighborHashes:b,repeaterSignalMap:y,isLoading:g,splitPercent:d=50,onMicroChange:v,className:w},f){const[M,I]=n.useState($s),[R,j]=n.useState($s),[k,$]=n.useState(""),[N,u]=n.useState(!1),[m,_]=n.useState(Io),h=n.useRef(null),T=n.useRef(null),S=n.useCallback(F=>{T.current=F,typeof f=="function"?f(F):f&&(f.current=F)},[f]),O=n.useCallback(()=>{I(F=>{const A=!F;Ro(A);const z=T.current;if(A&&j(!0),z){let U=0;const ne=z.parentElement;if(A)U=(ne==null?void 0:ne.offsetWidth)??z.offsetWidth;else if(ne){const We=ne.style.width;ne.style.width="var(--companion-side)",U=ne.offsetWidth,ne.style.width=We}const xt=A?yt:Math.round(d/100*U);tt(z,{width:`${xt}px`},{...de.layoutResize,onComplete(){z.style.width=A?`${yt}px`:`${d}%`,A||j(!1)}})}return v==null||v(A),A})},[d,v]),ie=n.useCallback(F=>{_(A=>{const z=new Set(A);return z.has(F)?z.delete(F):z.add(F),Eo(z),z})},[]),Y=N||k.length>0,D=n.useMemo(()=>{const F=new Set,A=s.filter(U=>F.has(U.public_key)?!1:(F.add(U.public_key),!0));if(!k.trim())return A;const z=k.toLowerCase();return A.filter(U=>{var ne;return((ne=U.name)==null?void 0:ne.toLowerCase().includes(z))||U.public_key.toLowerCase().includes(z)})},[s,k]),K=se(F=>F.pingResults),ee=n.useMemo(()=>{const F=new Map;for(const A of Ds)F.set(A.key,[]);for(const A of D)F.get(Po(A)).push(A);return Ds.map(A=>({...A,items:Oo(F.get(A.key),m,l,A.key==="repeater"?y:void 0,A.key==="repeater"?K:void 0)})).filter(A=>A.items.length>0)},[D,m,l,y,K]),V=(a==null?void 0:a.type)==="contact"?a.id:null;return e.jsxs("div",{ref:S,className:P("flex-shrink-0 overflow-hidden flex flex-col h-full",w),style:{width:M?yt:`${d}%`},children:[e.jsx("div",{className:P("flex items-center border-b border-edge-subtle flex-shrink-0",R?"justify-center p-2":"gap-2 px-3 py-2"),children:R?e.jsx("button",{onClick:O,className:"p-1 hover:bg-subtle-fill rounded transition-colors",title:"Expand contacts",children:e.jsx(Jl,{className:"w-3.5 h-3.5 text-fg-muted"})}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wide flex-shrink-0",children:"Contacts"}),e.jsxs("div",{className:"flex items-center gap-1 ml-auto flex-shrink-0",children:[e.jsx("button",{onClick:()=>{Y?($(""),u(!1)):(u(!0),setTimeout(()=>{var F;return(F=h.current)==null?void 0:F.focus()},50))},className:P("p-1 rounded transition-colors flex-shrink-0",Y?"bg-sys-blue/10 text-sys-blue":"hover:bg-subtle-fill text-fg-muted"),title:Y?"Close search":"Search contacts",children:e.jsx(Rs,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:O,className:"p-1 hover:bg-subtle-fill rounded transition-colors flex-shrink-0",title:"Collapse contacts",children:e.jsx(Yl,{className:"w-3.5 h-3.5 text-fg-muted"})})]})]})}),!R&&Y&&e.jsxs("div",{className:"relative px-2.5 py-2 border-b border-edge-subtle/50 flex-shrink-0",children:[e.jsx(Rs,{className:"absolute left-5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-fg-muted pointer-events-none"}),e.jsx("input",{ref:h,type:"text",value:k,onChange:F=>$(F.target.value),onFocus:()=>u(!0),onBlur:()=>u(!1),placeholder:"Search contacts…",className:"w-full pl-8 pr-8 py-1.5 text-sm radius-inner bg-input-bg border border-input-border text-fg-primary placeholder:text-fg-muted/50 ring-focus-inset hover:border-edge-strong transition-colors",autoFocus:!0}),e.jsx("button",{onClick:()=>{$(""),u(!1)},className:"absolute right-5 top-1/2 -translate-y-1/2 p-0.5 hover:bg-subtle-fill rounded",children:e.jsx(ut,{className:"w-3.5 h-3.5 text-fg-muted"})})]}),g&&e.jsx("div",{className:"flex items-center justify-center flex-1",children:e.jsx("div",{className:"w-5 h-5 animate-spin rounded-full border-2 border-sys-blue border-t-transparent"})}),!g&&e.jsxs("div",{className:P("flex-1 overflow-y-auto min-h-0",R?"px-0":"px-1.5"),style:{contain:"layout style paint"},children:[ee.map(F=>{const A=F.icon;return e.jsxs(_e,{defaultOpen:!0,className:"mb-1",children:[e.jsxs(Re,{className:P("px-2 py-1 flex items-center gap-1.5 w-full","text-left radius-inner hover:bg-subtle-fill-strong transition-colors"),children:[e.jsx(A,{className:P("w-3.5 h-3.5",F.color)}),!R&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wide",children:F.label}),e.jsx("span",{className:"type-data-xs text-fg-muted/50 ml-auto",children:F.items.length})]})]}),e.jsx(Ie,{children:e.jsx(ge,{initial:!1,mode:"popLayout",children:F.items.map(z=>{var U;return e.jsx(Lo,{contact:z,isActive:V===z.public_key,unread:r.get(z.public_key)??0,lastMsg:(U=l.get(z.public_key))==null?void 0:U.at(-1),isFav:m.has(z.public_key),microContent:R,onSelect:i,onShowDetails:o,onShareContact:x,onResetPath:p,onRemoveContact:C,onPingContact:c,repeaterNeighborHashes:b,repeaterSignal:y==null?void 0:y.get(z.public_key),toggleFavorite:ie},z.public_key)})})})]},F.key)}),D.length===0&&e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{className:"text-sm text-fg-muted",children:k?"No matches":"No contacts yet"})})]})]})}));function zo({open:t,onClose:s}){const a=se(u=>u.discoverImportableChannels),r=se(u=>u.getEmptyChannelSlots),l=se(u=>u.importChannel),i=se(u=>u.refreshChannels),[o,x]=n.useState("discover"),[p,C]=n.useState([]),[c,b]=n.useState([]),[y,g]=n.useState(null),d=n.useRef(!1);n.useEffect(()=>{if(!t)return;x("discover"),C([]),b([]),g(null),d.current=!1;let u=!1;return(async()=>{try{const[m,_]=await Promise.all([a(),r()]);if(u)return;if(b(_),m.length===0){g("No channels found in repeater history. Decoded messages may still be loading."),x("select");return}_.length===0&&g("No empty channel slots on device. Delete a channel first to make room."),C(m.map(h=>({name:h.name,alreadyOnDevice:h.alreadyOnDevice,selected:!h.alreadyOnDevice,status:"pending"}))),x("select")}catch(m){u||(g(m instanceof Error?m.message:"Discovery failed"),x("select"))}})(),()=>{u=!0}},[t,a,r]);const v=n.useCallback(u=>{C(m=>m.map(_=>_.name===u&&!_.alreadyOnDevice?{..._,selected:!_.selected}:_))},[]),w=n.useCallback(()=>{C(u=>u.map(m=>m.alreadyOnDevice?m:{...m,selected:!0}))},[]),f=n.useCallback(()=>{C(u=>u.map(m=>m.alreadyOnDevice?m:{...m,selected:!1}))},[]),M=n.useMemo(()=>p.filter(u=>!u.alreadyOnDevice).length,[p]),I=n.useMemo(()=>p.filter(u=>u.selected&&!u.alreadyOnDevice).length,[p]),R=n.useMemo(()=>p.filter(u=>u.status==="done").length,[p]),j=n.useMemo(()=>p.filter(u=>u.status==="failed").length,[p]),k=n.useCallback(async()=>{x("import"),d.current=!1;const u=p.filter(_=>_.selected&&!_.alreadyOnDevice),m=[...c];for(const _ of u){if(d.current)break;const h=m.shift();if(h===void 0){C(S=>S.map(O=>O.name===_.name&&O.status==="pending"?{...O,status:"failed"}:O));continue}C(S=>S.map(O=>O.name===_.name?{...O,status:"sending"}:O)),await new Promise(S=>setTimeout(S,150));const T=await l(_.name,h);C(S=>S.map(O=>O.name===_.name?{...O,status:T?"done":"failed"}:O)),T||m.unshift(h),d.current||await new Promise(S=>setTimeout(S,300))}await i(),x("complete")},[p,c,l,i]),$=n.useCallback(()=>{d.current=!0},[]),N=u=>{switch(u){case"pending":return e.jsx(wa,{className:"w-3.5 h-3.5 text-fg-muted"});case"sending":return e.jsx(oe,{className:"w-3.5 h-3.5 text-sys-blue animate-spin"});case"done":return e.jsx(be,{className:"w-3.5 h-3.5 text-sys-green"});case"failed":return e.jsx(ut,{className:"w-3.5 h-3.5 text-sys-red"})}};return e.jsxs(je,{open:t,onClose:o==="import"?()=>{}:s,size:"sm",children:[e.jsx(Ee,{icon:e.jsx(He,{className:"w-5 h-5"}),title:"Import Channels",onClose:o==="import"?void 0:s}),e.jsxs(we,{className:"!py-3 !px-0",children:[o==="discover"&&e.jsxs("div",{className:"flex flex-col items-center gap-3 py-8 px-6",children:[e.jsx(oe,{className:"w-6 h-6 text-sys-blue animate-spin"}),e.jsx("p",{className:"text-sm text-fg-secondary",children:"Scanning repeater history…"}),e.jsx("p",{className:"text-[11px] text-fg-muted",children:"Waiting for decoded messages"})]}),o==="select"&&e.jsxs(e.Fragment,{children:[y&&e.jsxs("div",{className:"flex items-start gap-2 mx-4 mb-3 p-2.5 radius-inner bg-sys-amber/8 border border-sys-amber/20",children:[e.jsx(Be,{className:"w-3.5 h-3.5 text-sys-amber flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-xs text-fg-secondary",children:y})]}),p.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between px-4 pb-2 border-b border-edge-subtle",children:[e.jsxs("span",{className:"text-[11px] text-fg-muted",children:[M," discoverable · ",c.length," slot",c.length!==1?"s":""," free"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:w,className:"text-[11px] text-sys-blue hover:underline",children:"All"}),e.jsx("span",{className:"text-fg-muted/40",children:"·"}),e.jsx("button",{onClick:f,className:"text-[11px] text-sys-blue hover:underline",children:"None"})]})]}),e.jsx("div",{className:"max-h-[320px] overflow-y-auto",children:p.map(u=>e.jsxs("button",{onClick:()=>v(u.name),disabled:u.alreadyOnDevice,className:P("w-full flex items-center gap-3 px-4 py-2 transition-colors",u.alreadyOnDevice?"opacity-40 cursor-default":"hover:bg-subtle-fill"),children:[e.jsx("div",{className:P("w-4 h-4 rounded border flex items-center justify-center flex-shrink-0 transition-colors",u.alreadyOnDevice?"border-fg-muted/30 bg-fg-muted/10":u.selected?"border-sys-blue bg-sys-blue":"border-edge-subtle"),children:(u.selected||u.alreadyOnDevice)&&e.jsx(be,{className:"w-3 h-3 text-white"})}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx(Fe,{className:"w-3.5 h-3.5 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:"text-sm text-fg-primary truncate",children:u.name})]}),u.alreadyOnDevice&&e.jsx("span",{className:"text-[10px] text-fg-muted bg-subtle-fill px-1.5 py-0.5 rounded flex-shrink-0",children:"on device"})]},u.name))})]})]}),(o==="import"||o==="complete")&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between px-4 pb-2 border-b border-edge-subtle",children:[e.jsx("span",{className:"text-[11px] text-fg-muted",children:o==="import"?"Importing channels…":"Import complete"}),e.jsxs("span",{className:"text-[11px] tabular-nums text-fg-secondary",children:[R+j," / ",p.filter(u=>u.selected&&!u.alreadyOnDevice).length]})]}),e.jsx("div",{className:"max-h-[320px] overflow-y-auto",children:p.filter(u=>u.selected&&!u.alreadyOnDevice).map(u=>e.jsxs("div",{className:P("flex items-center gap-3 px-4 py-2",u.status==="sending"&&"bg-sys-blue/5",u.status==="done"&&"bg-sys-green/5",u.status==="failed"&&"bg-sys-red/5"),children:[e.jsx("div",{className:"w-5 h-5 flex items-center justify-center flex-shrink-0",children:N(u.status)}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx(Fe,{className:"w-3.5 h-3.5 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:P("text-sm truncate",u.status==="done"?"text-fg-primary":"text-fg-secondary"),children:u.name})]}),e.jsx("span",{className:P("text-[10px] flex-shrink-0",u.status==="sending"&&"text-sys-blue",u.status==="done"&&"text-sys-green",u.status==="failed"&&"text-sys-red",u.status==="pending"&&"text-fg-muted"),children:u.status==="sending"?"sending…":u.status==="done"?"added":u.status==="failed"?"failed":"waiting"})]},u.name))})]})]}),e.jsxs(Me,{children:[o==="select"&&e.jsxs(e.Fragment,{children:[e.jsx(H,{plain:!0,onClick:s,children:"Cancel"}),e.jsxs(H,{color:"primary",onClick:k,disabled:I===0||c.length===0,children:[e.jsx(He,{className:"w-4 h-4"}),"Import ",I," ",I===1?"Channel":"Channels"]})]}),o==="import"&&e.jsx(H,{plain:!0,onClick:$,children:"Stop"}),o==="complete"&&e.jsxs(e.Fragment,{children:[j>0&&e.jsxs("span",{className:"text-xs text-sys-red flex items-center gap-1 mr-auto",children:[e.jsx(Be,{className:"w-3.5 h-3.5"}),j," failed"]}),e.jsxs(H,{color:"primary",onClick:s,children:[e.jsx(Kr,{className:"w-4 h-4"}),"Done — ",R," imported"]})]})]})]})}const Ho=4e3;function Bo(t){const s=t.frequency_hz/1e3,a=t.bandwidth_hz/1e3;return`${s} · SF${t.spreading_factor} · ${a}k`}function Go({channel:t,isActive:s,unread:a,lastMsg:r,isLoadingMessages:l,selfInfo:i,onSelect:o,onDeleteChannel:x}){const[p,C]=n.useState(!1),[c,b]=n.useState(!1),y=n.useRef(null),g=n.useCallback(()=>{C(!0),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>C(!1),Ho)},[]),d=n.useCallback(()=>{C(!1),y.current&&clearTimeout(y.current)},[]),v=n.useCallback(async()=>{x&&(y.current&&clearTimeout(y.current),b(!0),await x(t.index),b(!1),C(!1))},[x,t.index]),w=t.name.toLowerCase()==="public",f=x&&!w;return e.jsx(ue.div,{layout:"position",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:de.fade,className:P("group w-full flex items-center gap-2.5 px-2.5 py-1 radius-inner","transition-[background-color] duration-150",p?"":s?"bg-sys-blue":"hover:bg-subtle-fill-strong"),children:e.jsxs("div",{className:"grid flex-1 min-w-0 [&>*]:col-start-1 [&>*]:row-start-1",children:[e.jsxs("div",{className:P("flex items-center gap-2.5 min-w-0",p&&"invisible pointer-events-none"),children:[e.jsx("button",{onClick:()=>o({type:"channel",id:String(t.index)}),className:"flex items-center gap-2.5 flex-1 min-w-0 text-left",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:P("text-sm flex-shrink-0",s?"text-white font-semibold":r?"text-fg-primary font-semibold":"text-fg-secondary font-normal"),children:t.name}),w&&i&&e.jsx("span",{className:P("text-[9px] font-medium px-1.5 py-px rounded-full whitespace-nowrap truncate",s?"text-white/80 bg-white/15":"text-fg-muted/70 bg-subtle-fill"),children:Bo(i)})]}),r&&e.jsx("div",{className:P("text-[11px] truncate pl-2",s?"text-white/70":"text-fg-muted"),children:r.text})]})}),e.jsx("div",{className:"flex items-center flex-shrink-0",children:l?e.jsx("span",{className:"h-1.5 w-6 rounded-full bg-fg-muted/20 animate-pulse"}):f?e.jsxs("div",{className:"relative w-[18px] h-[18px] flex items-center justify-center",children:[a>0&&e.jsx("span",{className:"absolute inset-0 flex items-center justify-center min-w-[18px] h-[18px] px-1 rounded-full bg-sys-red text-white text-[10px] font-bold leading-none group-hover:invisible transition-[visibility] duration-100",children:a>99?"99+":a}),e.jsx("button",{onClick:g,className:P("absolute inset-0 flex items-center justify-center rounded opacity-0 group-hover:opacity-100 transition-[opacity,background-color] duration-100",s?"hover:bg-white/15":"hover:bg-subtle-fill"),title:"Remove channel",children:e.jsx(Ke,{className:P("w-3 h-3 transition-colors",s?"text-white/60 hover:text-white":"text-fg-muted hover:text-sys-red")})})]}):a>0?e.jsx("span",{className:"min-w-[18px] h-[18px] px-1 rounded-full bg-sys-red text-white text-[10px] font-bold flex items-center justify-center leading-none",children:a>99?"99+":a}):null})]}),e.jsx("div",{className:P("flex items-center gap-1.5 self-center",!p&&"invisible pointer-events-none"),children:c?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx("div",{className:"w-3.5 h-3.5 animate-spin rounded-full border-2 border-white border-t-transparent"})}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:d,className:"flex-1 flex items-center justify-center py-1 radius-inner bg-zinc-500/80 hover:bg-zinc-500 depth-stroke-raised transition-colors",children:e.jsx("span",{className:"text-[11px] font-semibold text-white",children:"Cancel"})}),e.jsx("button",{onClick:v,className:"flex-1 flex items-center justify-center py-1 radius-inner bg-sys-red/80 hover:bg-sys-red depth-stroke-raised transition-colors",children:e.jsx(Ke,{className:"w-4 h-4 text-white"})})]})})]})})}const Ko=n.memo(n.forwardRef(function({channels:s,selectedConversation:a,unreadMap:r,messages:l,onSelect:i,onAddChannel:o,onDeleteChannel:x,className:p},C){const c=Ln(),b=mt(),[y,g]=n.useState(!1),d=n.useMemo(()=>{const w=new Set,f=s.filter(M=>w.has(M.index)?!1:(w.add(M.index),!0));return f.sort((M,I)=>{var N,u,m,_;const R=M.name.toLowerCase()==="public",j=I.name.toLowerCase()==="public";if(R&&!j)return-1;if(!R&&j)return 1;const k=((u=(N=l.get(`ch:${M.index}`))==null?void 0:N.at(-1))==null?void 0:u.timestamp)??0,$=((_=(m=l.get(`ch:${I.index}`))==null?void 0:m.at(-1))==null?void 0:_.timestamp)??0;return k!==$?$-k:M.name.localeCompare(I.name)}),f},[s,l]),v=(a==null?void 0:a.type)==="channel"?a.id:null;return e.jsxs("div",{ref:C,className:P("flex-1 min-w-0 overflow-hidden flex flex-col h-full",p),children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-edge-subtle flex-shrink-0 overflow-hidden whitespace-nowrap",children:[e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wide flex-shrink-0",children:"Channels"}),e.jsxs("div",{className:"flex items-center gap-1 ml-auto flex-shrink-0",children:[e.jsx("button",{onClick:()=>g(!0),className:"p-1 rounded hover:bg-subtle-fill transition-colors flex-shrink-0",title:"Import channels from repeater history",children:e.jsx(He,{className:"w-3.5 h-3.5 text-fg-muted"})}),o&&e.jsx("button",{onClick:o,className:"p-1 rounded hover:bg-subtle-fill transition-colors flex-shrink-0",title:"Add channel",children:e.jsx(Ue,{className:"w-3.5 h-3.5 text-fg-muted"})})]})]}),e.jsx(zo,{open:y,onClose:()=>g(!1)}),e.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 px-1.5 py-1",style:{contain:"layout style paint"},children:d.length===0?e.jsxs("div",{className:"px-1.5 py-4 space-y-2",children:[e.jsx("p",{className:"text-sm text-fg-muted",children:"No channels"}),o&&e.jsxs("button",{onClick:o,className:"inline-flex items-center gap-1.5 px-2 py-1.5 text-xs font-medium text-sys-blue hover:bg-sys-blue/8 rounded transition-colors",children:[e.jsx(Ue,{className:"w-3.5 h-3.5"}),"Add Channel"]})]}):e.jsx(ge,{initial:!1,mode:"popLayout",children:d.map(w=>{var f;return e.jsx(Go,{channel:w,isActive:v===String(w.index),unread:r.get(`ch:${w.index}`)??0,lastMsg:(f=l.get(`ch:${w.index}`))==null?void 0:f.at(-1),isLoadingMessages:c,selfInfo:b,onSelect:i,onDeleteChannel:x},w.index)})})})]})}));function Uo(t,s){const a=new Map;for(const[r,l]of t){const i=l.decoded;if(!(i!=null&&i.decrypted)||i.senderName!==s)continue;const o=i.timestamp??l.timestamp,x=Math.floor(o/30),p=`${i.text}:${x}`;a.has(p)||a.set(p,r)}return a}function qo(t){const s=mt(),a=On(),r=An(),l=s==null?void 0:s.node_name,i=n.useMemo(()=>l?Uo(a,l):new Map,[a,l]);return n.useMemo(()=>{const o=new Map;if(!l||i.size===0)return o;const x=new Map;for(const c of t){if(!c.is_outgoing||!c.is_channel)continue;const b=Math.floor(c.timestamp/30);let y=!1;for(const g of[b-1,b,b+1]){const d=i.get(`${c.text}:${g}`);if(d){const v=x.get(d)??[];v.push(c.id),x.set(d,v),y=!0;break}}}if(x.size===0)return o;const p=new Set(x.keys()),C=new Map;for(const c of r)p.has(c.packet_hash)&&C.set(c.packet_hash,(C.get(c.packet_hash)??0)+1);for(const[c,b]of x){const y=C.get(c)??0,g=Math.max(0,y-1);for(const d of b)o.set(d,g)}return o},[t,l,i,r])}const Vo=n.lazy(()=>ra(()=>import("./CompanionPathMap-D5FruuYA.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])).then(t=>({default:t.CompanionPathMap}))),Wo=n.lazy(()=>ra(()=>import("./CompanionEchoMap-BcAn2gmm.js"),__vite__mapDeps([8,1,2,3,5,6,7])).then(t=>({default:t.CompanionEchoMap}))),Os=e.jsx("div",{className:"rounded-lg bg-elevated flex items-center justify-center",style:{aspectRatio:"16 / 10"},children:e.jsx("div",{className:"w-4 h-4 border-2 border-fg-muted/30 border-t-fg-muted rounded-full animate-spin"})});function Qo(t){const s=new Date(t*1e3),r=Math.floor((new Date().getTime()-s.getTime())/864e5);return r===0?"Today":r===1?"Yesterday":s.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function Yo(t){const s=new Date(t*1e3);return`${s.getFullYear()}-${s.getMonth()}-${s.getDate()}`}function Xo(t){const s=new Map;for(const a of t)a.name&&s.set(a.public_key,a.name);return s}function Jo(t){const s=new Map;for(const a of t)s.set(a.public_key,a);return s}function Zo(t){if(!t)return[];const s=[];for(let a=0;ar.public_key.startsWith(t));return(a==null?void 0:a.name)||null}function ti(t,s){return t.is_outgoing?"You":t.sender_name?t.sender_name:s.get(t.sender_key)??t.sender_key.slice(0,8)}const si=n.memo(function({msg:s,contact:a,contacts:r,selfInfo:l,echoCount:i,channelName:o,children:x}){const[p,C]=n.useState(!1),[c,b]=n.useState(!1),[y,g]=n.useState(0),d=n.useRef(null),v=s.path_len,w=!s.is_outgoing,f=w&&v!=null,M=s.is_outgoing&&s.is_channel&&(i??0)>0,I=(o==null?void 0:o.toLowerCase().includes("wardrive"))??!1,R=n.useMemo(()=>I&&w?Vr(s.text):null,[I,w,s.text]),j=f||M,k=n.useMemo(()=>{const T=[];if(s.path_hops&&s.path_hops.length>0)T.push({hops:s.path_hops,snr:s.path_snr,rssi:s.path_rssi});else if(w&&(a!=null&&a.out_path)){const S=Zo(a.out_path);S.length>0&&T.push({hops:S})}if(s.alternate_paths)for(const S of s.alternate_paths)T.push(S);return T},[s.path_hops,s.path_snr,s.path_rssi,s.alternate_paths,w,a==null?void 0:a.out_path]),$=y1,m=(N==null?void 0:N.snr)??s.msg_snr,_=()=>{b(!0),C(T=>!T)},h=n.useCallback(T=>{var S;T.propertyName==="grid-template-rows"&&(p?(S=d.current)==null||S.scrollIntoView({block:"nearest",behavior:"smooth"}):b(!1))},[p]);return e.jsxs("div",{ref:d,className:P("rounded-xl px-2 py-1 -mx-2 transition-colors duration-150",j&&"hover:bg-subtle-fill cursor-pointer"),onClick:()=>j&&_(),children:[x,j&&e.jsx("div",{className:"grid transition-[grid-template-rows] duration-300 ease-[cubic-bezier(0.83,0,0.17,1)]",style:{gridTemplateRows:p?"1fr":"0fr"},onTransitionEnd:h,children:e.jsxs("div",{className:"overflow-hidden",children:[c&&f&&e.jsxs("div",{className:"mt-1.5 ml-13 space-y-1",children:[u&&e.jsx("div",{className:"flex items-center gap-1 flex-wrap",onClick:T=>T.stopPropagation(),children:k.map((T,S)=>e.jsxs("button",{onClick:()=>g(S),className:P("flex items-center gap-0.5 px-1.5 py-0.5 rounded text-[10px] transition-colors",S===$?"bg-sys-blue/15 text-sys-blue font-semibold":"bg-subtle-fill text-fg-muted hover:text-fg-secondary"),children:[e.jsx(Ge,{className:"w-2.5 h-2.5"}),T.hops.length||v,T.snr!=null&&e.jsxs("span",{className:"ml-0.5 opacity-70",children:[T.snr>0?"+":"",T.snr.toFixed(1)]})]},S))}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx(Ge,{className:"w-3 h-3 text-fg-muted flex-shrink-0"}),v===0&&!N?e.jsx("span",{className:"text-[10px] text-fg-muted font-medium",children:"Direct"}):N&&N.hops.length>0?N.hops.map((T,S)=>{const O=ei(T,r);return e.jsxs("span",{className:"contents",children:[S>0&&e.jsx(Qr,{className:"w-2.5 h-2.5 text-fg-muted/50 flex-shrink-0"}),e.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded bg-subtle-fill text-[10px]",children:[e.jsx("span",{className:"font-mono text-fg-primary",children:T}),O&&e.jsxs("span",{className:"text-fg-muted",children:["(",O,")"]})]})]},S)}):e.jsxs("span",{className:"text-[10px] text-fg-muted font-medium",children:[v," hop",v>1?"s":""]}),m!=null&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[10px] text-fg-muted ml-0.5",children:[e.jsx(Sr,{className:"w-2.5 h-2.5"}),m>0?"+":"",m.toFixed(1),"dB"]}),(N==null?void 0:N.rssi)!=null&&e.jsxs("span",{className:"text-[10px] text-fg-muted",children:[N.rssi,"dBm"]})]}),N&&N.hops.length>=1&&e.jsx(n.Suspense,{fallback:Os,children:e.jsx(Vo,{hops:N.hops,contacts:r,selfInfo:l,snr:m,wardriveCoords:R??void 0,wardriveSenderName:s.sender_name})})]}),c&&M&&e.jsx("div",{className:"mt-1.5",children:e.jsx(n.Suspense,{fallback:Os,children:e.jsx(Wo,{text:s.text,timestamp:s.timestamp,contacts:r})})})]})})]})}),ai=n.memo(function({messages:s,contacts:a,className:r,conversationKey:l,onRetry:i,onRetryAsFlood:o,onMentionClick:x,historyLoading:p,historyExhausted:C,onLoadOlder:c,channelName:b}){const y=n.useRef(null),g=n.useRef(null),[d,v]=n.useState(!1),w=n.useRef(s.length),f=n.useRef(0),M=n.useRef(l);n.useEffect(()=>{if(l!==M.current){M.current=l,w.current=s.length,f.current=0,v(!1);const m=y.current;m&&(m.scrollTop=m.scrollHeight)}},[l,s.length]);const I=n.useMemo(()=>Xo(a),[a]),R=n.useMemo(()=>Jo(a),[a]),j=mt(),k=qo(s);n.useEffect(()=>{var _;const m=y.current;if(m){if(s.length>w.current&&f.current>0){const h=m.scrollHeight-f.current;if(h>0&&m.scrollTop<200){m.scrollTop+=h,w.current=s.length,f.current=0;return}}w.current=s.length,d||(_=g.current)==null||_.scrollIntoView({behavior:"smooth"})}},[s.length,d]);const $=n.useCallback(()=>{const m=y.current;if(!m)return;const _=m.scrollHeight-m.scrollTop-m.clientHeight;v(_>100),m.scrollTop<80&&c&&!p&&!C&&(f.current=m.scrollHeight,c())},[c,p,C]),N=n.useCallback(()=>{var m;(m=g.current)==null||m.scrollIntoView({behavior:"smooth"}),v(!1)},[]);let u="";return e.jsxs("div",{className:P("relative flex flex-col",r),children:[e.jsxs("div",{ref:y,onScroll:$,className:"flex-1 overflow-y-auto min-h-0 px-4 py-3",children:[p&&e.jsx("div",{className:"flex items-center justify-center py-3",children:e.jsx(oe,{className:"w-4 h-4 text-fg-muted animate-spin"})}),s.length===0?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("p",{className:"text-sm text-fg-muted",children:C?"No messages yet":"Loading messages…"})}):s.map(m=>{const _=Yo(m.timestamp),h=_!==u;u=_;const T=m.is_outgoing?m.failed?"failed":m.confirmed?"confirmed":m.unconfirmed?"unconfirmed":(m.retryAttempt??0)>0?"retrying":m.sent?"sent":"pending":void 0,S=m.is_channel&&m.channel_idx!=null?`ch:${m.channel_idx}`:m.sender_key;return e.jsxs("div",{children:[h&&e.jsx(Ur,{text:Qo(m.timestamp)}),e.jsx(si,{msg:m,contact:R.get(m.sender_key),contacts:a,selfInfo:j,echoCount:k.get(m.id),channelName:b,children:e.jsx(qr,{senderName:ti(m,I),text:m.text,timestamp:m.timestamp,isOutgoing:m.is_outgoing,status:T,onRetry:i&&m.failed?()=>i(S,m.id):void 0,onRetryAsFlood:o&&m.failed&&!m.is_channel?()=>o(S,m.id):void 0,retryAttempt:m.retryAttempt,maxRetries:m.maxRetries,echoCount:k.get(m.id),signed:!m.is_outgoing&&m.txt_type===zn.SignedPlain,bubbleVariant:"subtle",onMentionClick:x})})]},m.id)}),e.jsx("div",{ref:g})]}),e.jsx("button",{onClick:N,className:P("absolute bottom-4 right-4 w-8 h-8 rounded-full bg-sys-blue flex items-center justify-center shadow-lg","hover:bg-sys-blue/90 transition-all duration-200",d?"opacity-100 translate-y-0":"opacity-0 translate-y-2 pointer-events-none"),children:e.jsx(Wr,{className:"w-4 h-4 text-white"})})]})}),ni=6,ri=n.memo(function({onSend:s,disabled:a,placeholder:r="Type a message…",className:l,mentionNames:i=[]}){const[o,x]=n.useState(""),[p,C]=n.useState(!1),c=n.useRef(null),[b,y]=n.useState(null),[g,d]=n.useState(-1),[v,w]=n.useState(0),f=n.useMemo(()=>{if(b==null)return[];const N=b.toLowerCase();return i.filter(u=>u.toLowerCase().includes(N)).slice(0,ni)},[b,i]),M=f.length>0;n.useEffect(()=>{w(0)},[f]);const I=n.useCallback(()=>{y(null),d(-1),w(0)},[]),R=n.useCallback(N=>{var S;if(g<0)return;const u=o.slice(0,g),m=((S=c.current)==null?void 0:S.selectionStart)??o.length,_=o.slice(m),h=`@[${N}] `,T=u+h+_;x(T),I(),requestAnimationFrame(()=>{var ie,Y;const O=u.length+h.length;(ie=c.current)==null||ie.setSelectionRange(O,O),(Y=c.current)==null||Y.focus()})},[o,g,I]),j=n.useCallback(async()=>{var u;const N=o.trim();!N||p||a||(C(!0),I(),x(""),await s(N),C(!1),(u=c.current)==null||u.focus())},[o,p,a,s,I]),k=n.useCallback(N=>{const u=N.target.value;x(u);const m=N.target.selectionStart??u.length,_=u.slice(0,m),h=_.lastIndexOf("@");if(h>=0){const T=h>0?_[h-1]:" ";if(/\s/.test(T)||h===0){const S=_.slice(h+1);if(!S.includes(" ")&&!S.includes("[")){y(S),d(h);return}}}I()},[I]),$=n.useCallback(N=>{if(M){if(N.key==="ArrowDown"){N.preventDefault(),w(u=>(u+1)%f.length);return}if(N.key==="ArrowUp"){N.preventDefault(),w(u=>(u-1+f.length)%f.length);return}if(N.key==="Enter"||N.key==="Tab"){N.preventDefault(),R(f[v]);return}if(N.key==="Escape"){N.preventDefault(),I();return}}N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),j())},[j,M,f,v,R,I]);return e.jsxs("div",{className:P("relative flex items-center gap-2 p-3 border-t border-edge-subtle",l),children:[M&&e.jsx("div",{className:"absolute bottom-full left-3 right-3 mb-1 radius-inset surface-elevated depth-raised overflow-hidden z-50",children:f.map((N,u)=>{const m=Pt(N),{emoji:_,cleanName:h}=Mt(N),T=Tt(N);return e.jsxs("button",{onMouseDown:S=>{S.preventDefault(),R(N)},className:P("w-full flex items-center gap-2.5 px-3 py-1.5 text-left transition-colors",u===v?"bg-sys-blue/10":"hover:bg-subtle-fill"),children:[e.jsx("div",{className:P("clay-avatar w-5 h-5",_?"text-xs":"text-white text-[9px] font-bold"),style:{"--avatar-color":m},children:_||T}),e.jsx("span",{className:"text-sm text-fg-primary truncate",children:h})]},N)})}),e.jsx("input",{ref:c,type:"text",value:o,onChange:k,onKeyDown:$,onBlur:()=>{setTimeout(I,150)},placeholder:r,disabled:a,className:"flex-1 min-w-0 w-full px-4 py-3 text-sm radius-inner bg-input-bg border border-input-border text-fg-primary placeholder:text-fg-muted/50 ring-focus-inset hover:border-edge-strong transition-colors"}),e.jsx("button",{onClick:j,disabled:!o.trim()||p||a,className:P("flex-shrink-0 w-10 h-10 rounded-full flex items-center justify-center transition-colors",o.trim()&&!a?"clay-send text-white":"bg-subtle-fill text-fg-muted cursor-not-allowed"),children:e.jsx(Hn,{className:"w-4.5 h-4.5 -translate-x-[0.5px] translate-y-[0.5px]",strokeWidth:2.5})})]})}),Ht="pymc_companion_room_pwd_";function li(t){try{return localStorage.getItem(`${Ht}${t}`)}catch{return null}}function oi(t,s){try{localStorage.setItem(`${Ht}${t}`,s)}catch{}}function As(t){try{localStorage.removeItem(`${Ht}${t}`)}catch{}}const ii=n.memo(function({contact:s,loginStatus:a,onLogin:r,className:l}){const[i,o]=n.useState(""),[x,p]=n.useState(!0),[C,c]=n.useState(null),[b,y]=n.useState(!1),g=n.useRef(null),d=n.useRef(!0),v=s.public_key,w=n.useRef(v);w.current!==v&&(w.current=v,y(!1),c(null),o("")),n.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]),n.useEffect(()=>{if(b||a==="success")return;const R=li(v);if(!R){y(!0);return}y(!0),(async()=>{const j=await r(v,R);d.current&&(j||(As(v),c("Saved password rejected — please re-enter.")))})()},[v,b,a,r]);const f=n.useCallback(async()=>{c(null);const R=await r(v,i);d.current&&(R?x&&i?oi(v,i):As(v):c("Login failed — check your password and try again."))},[v,i,x,r]),M=n.useCallback(R=>{R.key==="Enter"&&(R.preventDefault(),f())},[f]),I=a==="pending";return I&&!i?e.jsxs("div",{className:P("flex-1 flex flex-col items-center justify-center gap-3",l),children:[e.jsx(oe,{className:"w-6 h-6 text-sys-pink animate-spin"}),e.jsxs("p",{className:"text-sm text-fg-muted",children:["Connecting to ",s.name||"room server","…"]})]}):e.jsx(ue.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.2},className:P("flex-1 flex flex-col items-center justify-center px-6",l),children:e.jsxs("div",{className:"w-full max-w-xs space-y-5",children:[e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[e.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center ring-[1.5px] ring-sys-pink bg-sys-pink/8",children:e.jsx(dt,{className:"size-7 text-sys-pink"})}),e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"type-body font-medium text-fg-primary",children:s.name||"Room Server"}),e.jsx("p",{className:"text-xs text-fg-muted mt-1",children:"Enter the room password to join, or try logging in without one — some servers allow open access."})]})]}),(C||a==="failed")&&e.jsxs("div",{className:"flex items-start gap-2 p-2.5 rounded-lg bg-sys-red/8 border border-sys-red/15",children:[e.jsx(da,{className:"w-3.5 h-3.5 text-sys-red flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[11px] text-sys-red leading-relaxed",children:C||"Login failed — check your password and try again."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("input",{ref:g,type:"password",value:i,onChange:R=>o(R.target.value),onKeyDown:M,placeholder:"Room password",disabled:I,autoFocus:!0,className:"w-full surface-input rounded-lg px-3 py-2.5 text-sm text-fg-primary placeholder:text-fg-muted/50 focus:outline-none focus:ring-1 focus:ring-sys-pink/40"}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[e.jsx("input",{type:"checkbox",checked:x,onChange:R=>p(R.target.checked),disabled:I,className:"surface-checkbox w-3.5 h-3.5 rounded accent-sys-pink"}),e.jsx("span",{className:"text-xs text-fg-muted",children:"Remember password"})]}),e.jsxs(H,{color:"pink",className:"w-full justify-center",disabled:I,onClick:f,children:[I?e.jsx(oe,{"data-slot":"icon",className:"animate-spin"}):e.jsx(kt,{"data-slot":"icon"}),I?"Connecting…":"Login"]})]}),e.jsx("p",{className:"text-[10px] text-fg-muted/60 text-center leading-relaxed",children:"The server determines your permissions based on the password. Admin and guest passwords grant different access levels."})]})})});function zs(t,s){return[t,s].sort().join("-")}function st(t){return t.substring(0,2)}function ci(t){var a,r;const s=(r=(a=t.traceQuality)==null?void 0:a.composite)==null?void 0:r.mean;return s!=null&&s!==0?Math.max(.1,s+20):Math.max(.1,t.strength*20)}function di(t,s,a,r){const{edgeMap:l}=a;if(l.size===0)return null;const i=new Map;for(const[,j]of l){const k=j.fromHash,$=j.toHash;i.has(k)||i.set(k,[]),i.has($)||i.set($,[]),i.get(k).push({neighbor:$,edge:j}),i.get($).push({neighbor:k,edge:j})}const o=new Set(i.keys()),x=Hs(t,o),p=Hs(s,o);if(!x||!p||x===p)return null;const C=new Map,c=new Map,b=new Set,y=[];for(C.set(x,0),c.set(x,null),y.push({node:x,cost:0});y.length>0;){y.sort(($,N)=>$.cost-N.cost);const j=y.shift();if(b.has(j.node))continue;if(b.add(j.node),j.node===p)break;const k=i.get(j.node)??[];for(const{neighbor:$,edge:N}of k){if(b.has($))continue;const u=ci(N),m=j.cost+1/u,_=C.get($)??1/0;m<_&&(C.set($,m),c.set($,j.node),y.push({node:$,cost:m}))}}if(!c.has(p))return null;const g=[];let d=p;for(;d!==null;)g.unshift(d),d=c.get(d)??null;if(g[0]!==x||g.length<2)return null;const v=new Map;for(const j of r)v.set(st(j.public_key),j);const w=g.slice(1,-1),f=w.map((j,k)=>{var T,S;const $=st(j),N=v.get($);let u=0;const m=g[k],_=zs(m,j),h=l.get(_);return(S=(T=h==null?void 0:h.traceQuality)==null?void 0:T.composite)!=null&&S.mean?u=h.traceQuality.composite.mean:(h==null?void 0:h.avgSnr)!=null&&(u=h.avgSnr),{hash:j,prefix:$,name:(N==null?void 0:N.name)||null,snr:u}});let M=0,I=0;for(let j=0;j0?M/I:0;return{hops:w.map(st),confidence:R,via:f}}function Hs(t,s){if(s.has(t))return t;const a=st(t);let r=null,l=0;for(const i of s)if(i.startsWith(a)||t.startsWith(i.substring(0,2))){let o=0;const x=Math.min(t.length,i.length);for(let p=0;pl&&(l=o,r=i)}return r}function Bs(t){switch(t&15){case 1:return"Companion";case 2:return"Repeater";case 3:return"Room Server";default:return"Unknown"}}function Gs(t){switch(t&15){case 1:return"blue";case 2:return"green";case 3:return"indigo";default:return"zinc"}}function ui(t){return(t&15)===2}const Ks=n.memo(function({contact:s,channel:a,contacts:r=[],selfPubKey:l,embedded:i=!1,onResetPath:o,onRequestStatus:x,onRequestTelemetry:p,onLoginToRepeater:C,onLogoutFromRepeater:c,onGetNeighbours:b,onTraceContactPath:y,onDiscoverPath:g,onExportContact:d,onSetContactPath:v,className:w}){const[f,M]=n.useState({}),I=(s==null?void 0:s.public_key)??null,[R,j]=n.useState(I);if(I!==R&&(j(I),M({})),!s&&!a)return i?null:e.jsx("div",{className:P("flex items-center justify-center h-full",w),children:e.jsx("p",{className:"text-sm text-fg-muted",children:"Select a conversation"})});async function k(m,_){M(T=>({...T,[m]:"loading"}));const h=await _();M(T=>({...T,[m]:h?"done":"error"})),setTimeout(()=>M(T=>({...T,[m]:"idle"})),2e3)}const $=a?e.jsxs("div",{className:"space-y-4",children:[!i&&e.jsxs("div",{className:"flex flex-col items-center gap-2 pb-3 border-b border-edge-subtle",children:[e.jsx("div",{className:"w-14 h-14 rounded-full bg-sys-indigo/15 flex items-center justify-center shadow-md",children:e.jsx(Fe,{className:"size-7 text-sys-indigo"})}),e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"type-body font-medium text-fg-primary",children:a.name}),e.jsxs(De,{color:"indigo",children:["Channel ",a.index]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 type-data-xs",children:[e.jsx("span",{className:"text-fg-muted w-20",children:"Index"}),e.jsx("span",{className:"font-mono text-fg-primary",children:a.index})]}),e.jsxs("div",{className:"flex items-center gap-2 type-data-xs",children:[e.jsx("span",{className:"text-fg-muted w-20",children:"Type"}),e.jsx("span",{className:"text-fg-primary",children:"Broadcast"})]})]}),e.jsx("div",{className:"pt-2 border-t border-edge-subtle",children:e.jsx("p",{className:"type-data-xs text-fg-muted/70",children:"Channel messages are broadcast-encrypted. Sender identity is not available due to MeshCore protocol limitations."})})]}):null,N=s?e.jsxs("div",{className:"space-y-4",children:[!i&&e.jsxs("div",{className:"flex flex-col items-center gap-2 pb-3 border-b border-edge-subtle",children:[e.jsx(fi,{contact:s}),e.jsxs("div",{className:"text-center",children:[e.jsxs("h3",{className:"type-body font-medium text-fg-primary flex items-center justify-center gap-1",children:[s.name||"Unknown",e.jsx(qs,{pubkey:s.public_key})]}),e.jsx(De,{color:Gs(s.adv_type),children:Bs(s.adv_type)})]})]}),i&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De,{color:Gs(s.adv_type),children:Bs(s.adv_type)}),e.jsx(qs,{pubkey:s.public_key})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 type-data-xs",children:[e.jsx("span",{className:"text-fg-muted w-20",children:"Public Key"}),e.jsx("span",{className:"font-mono text-fg-primary break-all text-[10px]",children:s.public_key})]}),e.jsxs("div",{className:"flex items-center gap-2 type-data-xs",children:[e.jsx(Ge,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-fg-muted",children:"Path Length"}),e.jsx("span",{className:"text-fg-primary ml-auto",children:s.out_path_len})]}),(s.gps_lat!==0||s.gps_lon!==0)&&e.jsxs("div",{className:"flex items-center gap-2 type-data-xs",children:[e.jsx(ia,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-fg-muted",children:"GPS"}),e.jsxs("span",{className:"text-fg-primary ml-auto font-mono text-[10px]",children:[s.gps_lat.toFixed(5),", ",s.gps_lon.toFixed(5)]})]}),(s.lastmod>0||s.last_advert_timestamp>0)&&e.jsxs("div",{className:"flex items-center gap-2 type-data-xs",children:[e.jsx(ua,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"text-fg-muted",children:"Last Heard"}),e.jsx("span",{className:"text-fg-primary ml-auto",children:new Date((s.lastmod||s.last_advert_timestamp)*1e3).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]}),s.last_advert_timestamp>0&&e.jsxs("div",{className:"flex items-center gap-2 type-data-xs",children:[e.jsx("span",{className:"text-fg-muted",children:"Last Advert"}),e.jsx("span",{className:"text-fg-primary ml-auto",children:new Date(s.last_advert_timestamp*1e3).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})]}),e.jsx(yi,{contact:s,contacts:r,selfPubKey:l,onSetContactPath:v,onDiscoverPath:g,actionState:f,setActionState:M,runAction:k}),e.jsxs("div",{className:"space-y-2 pt-2 border-t border-edge-subtle",children:[e.jsxs(H,{color:f.reset==="done"?"success":f.reset==="error"?"danger":"primary",outline:!0,className:"w-full justify-center",disabled:f.reset==="loading",onClick:()=>k("reset",()=>o(s.public_key)),children:[e.jsx(ca,{"data-slot":"icon"}),f.reset==="loading"?"Resetting…":f.reset==="done"?"Reset!":"Reset Path"]}),e.jsxs(H,{color:f.status==="done"?"success":f.status==="error"?"danger":"primary",outline:!0,className:"w-full justify-center",disabled:f.status==="loading",onClick:()=>k("status",()=>x(s.public_key)),children:[e.jsx(ma,{"data-slot":"icon"}),f.status==="loading"?"Requesting…":"Request Status"]}),e.jsxs(H,{color:f.telemetry==="done"?"success":f.telemetry==="error"?"danger":"primary",outline:!0,className:"w-full justify-center",disabled:f.telemetry==="loading",onClick:()=>k("telemetry",()=>p(s.public_key)),children:[e.jsx(pa,{"data-slot":"icon"}),f.telemetry==="loading"?"Requesting…":"Request Telemetry"]})]}),d&&e.jsxs(H,{color:"primary",outline:!0,className:"w-full justify-center",onClick:()=>d(s.public_key),children:[e.jsx(zt,{"data-slot":"icon"}),"Export Contact"]}),ui(s.adv_type)&&e.jsxs(e.Fragment,{children:[e.jsx(bi,{pubkey:s.public_key,onLogin:C,onLogout:c,actionState:f,runAction:k}),e.jsx(vi,{pubkey:s.public_key,onGetNeighbours:b,actionState:f,runAction:k}),e.jsx(ji,{pubkey:s.public_key,contact:s,onTrace:y,actionState:f,runAction:k})]}),e.jsx(mi,{pubkey:s.public_key}),e.jsx(hi,{pubkey:s.public_key})]}):null,u=$??N;return i?e.jsx("div",{className:w,children:u}):e.jsx("div",{className:P("flex flex-col h-full overflow-y-auto",w),children:e.jsx(ge,{mode:"wait",children:a?e.jsx(ue.div,{variants:Yr,initial:"hidden",animate:"visible",exit:"exit",className:"p-4",children:$},`ch-${a.index}`):s?e.jsx(ue.div,{variants:Xr,initial:"hidden",animate:"visible",exit:"exit",className:"p-4",children:N},`contact-${s.public_key}`):null})})});function Us(t){const s=Math.floor(t/86400),a=Math.floor(t%86400/3600),r=Math.floor(t%3600/60);return s>0?`${s}d ${a}h`:a>0?`${a}h ${r}m`:`${r}m`}function mi({pubkey:t}){const s=Vn(t);return s?e.jsxs(_e,{defaultOpen:!0,className:"pt-2 border-t border-edge-subtle",children:[e.jsxs(Re,{className:"px-0 py-1 flex items-center gap-1.5 w-full text-left",children:[e.jsx(ma,{className:"w-3.5 h-3.5 text-sys-green"}),e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wide",children:"Status"})]}),e.jsx(Ie,{children:e.jsxs("div",{className:"space-y-1.5 py-1",children:[e.jsx(J,{label:"Battery",value:`${(s.battMilliVolts/1e3).toFixed(2)}V`}),e.jsx(J,{label:"Noise Floor",value:`${s.noiseFloor} dBm`}),e.jsx(J,{label:"Last RSSI",value:`${s.lastRssi} dBm`}),e.jsx(J,{label:"Last SNR",value:`${(s.lastSnr/4).toFixed(1)} dB`}),e.jsx(J,{label:"Uptime",value:Us(s.totalUpTimeSecs)}),e.jsx(J,{label:"Air Time",value:Us(s.totalAirTimeSecs)}),e.jsx(J,{label:"TX Queue",value:String(s.currTxQueueLen)}),e.jsx(J,{label:"Packets Rx",value:String(s.nPacketsRecv)}),e.jsx(J,{label:"Packets Tx",value:String(s.nPacketsSent)}),e.jsx(J,{label:"Flood Rx/Tx",value:`${s.nRecvFlood}/${s.nSentFlood}`}),e.jsx(J,{label:"Direct Rx/Tx",value:`${s.nRecvDirect}/${s.nSentDirect}`}),e.jsx(J,{label:"Dups (D/F)",value:`${s.nDirectDups}/${s.nFloodDups}`}),s.errEvents>0&&e.jsx(J,{label:"Errors",value:String(s.errEvents)})]})})]}):null}function J({label:t,value:s}){return e.jsxs("div",{className:"flex items-center justify-between type-data-xs",children:[e.jsx("span",{className:"text-fg-muted",children:t}),e.jsx("span",{className:"text-fg-primary font-mono text-[10px]",children:s})]})}function pi(t){switch(t){case 100:return"Generic";case 101:return"Luminosity";case 102:return"Presence";case 103:return"Temperature";case 104:return"Humidity";case 115:return"Pressure";case 116:return"Voltage";case 117:return"Current";case 120:return"Percentage";case 125:return"Concentration";case 128:return"Power";case 136:return"GPS";default:return`Type ${t}`}}function xi(t){switch(t){case 103:return"°C";case 104:return"%";case 115:return" hPa";case 116:return"V";case 117:return"A";case 120:return"%";case 125:return" ppm";case 128:return"W";default:return""}}function hi({pubkey:t}){const s=Wn(t);if(!s)return null;const a=_o(s.lppSensorData);return a.length===0?null:e.jsxs(_e,{defaultOpen:!0,className:"pt-2 border-t border-edge-subtle",children:[e.jsxs(Re,{className:"px-0 py-1 flex items-center gap-1.5 w-full text-left",children:[e.jsx(pa,{className:"w-3.5 h-3.5 text-sys-amber"}),e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wide",children:"Telemetry"})]}),e.jsx(Ie,{children:e.jsx("div",{className:"space-y-1.5 py-1",children:a.map((r,l)=>typeof r.value=="object"?e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(J,{label:`Ch${r.channel} GPS Lat`,value:r.value.latitude.toFixed(5)}),e.jsx(J,{label:`Ch${r.channel} GPS Lon`,value:r.value.longitude.toFixed(5)}),e.jsx(J,{label:`Ch${r.channel} GPS Alt`,value:`${r.value.altitude.toFixed(1)}m`})]},l):e.jsx(J,{label:`Ch${r.channel} ${pi(r.type)}`,value:`${typeof r.value=="number"?r.value.toFixed(r.type===103||r.type===116?2:0):r.value}${xi(r.type)}`},l))})})]})}function fi({contact:t}){const{emoji:s}=Mt(t.name||""),a=Pt(t.name||t.public_key),r=t.name?Tt(t.name):t.public_key.slice(0,2).toUpperCase();return(t.adv_type&15)===2?e.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center shadow-md ring-[1.5px] ring-sys-blue",children:e.jsx(ze,{className:"size-7 text-sys-blue"})}):(t.adv_type&15)===3?e.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center shadow-md ring-[1.5px] ring-sys-pink",children:e.jsx(dt,{className:"size-7 text-sys-pink"})}):e.jsx("div",{className:P("w-14 h-14 clay-avatar",s?"text-2xl":"text-white text-lg font-bold"),style:{"--avatar-color":a},children:s||r})}function qs({pubkey:t}){return Bn().get(t)!==!0?null:e.jsx("span",{title:"Ed25519 verified identity",children:e.jsx(el,{className:"w-4 h-4 text-sys-green flex-shrink-0"})})}const bt=64;function gi(t){if(!t)return[];const s=[];for(let a=0;a0,j=gi(t.out_path),k=n.useCallback(async()=>{if(!r)return;const u=c.split(",").map(h=>h.trim()).filter(Boolean);if(u.length===0){g("Enter at least one hop");return}if(u.length>bt){g(`Max ${bt} hops`);return}if(!u.every(h=>/^[0-9a-fA-F]{1,2}$/.test(h))){g("Each hop must be 1-2 hex characters");return}g(null),o(h=>({...h,path:"loading"}));const _=await r(t.public_key,u);o(h=>({...h,path:_?"done":"error"})),_&&C(!1),setTimeout(()=>o(h=>({...h,path:"idle"})),2e3)},[r,c,t.public_key,o]),$=n.useCallback(()=>{if(!a){f("Self identity not available");return}const u=di(a,t.public_key,M,s);u?(v(u),f(null)):(v(null),f("No route found in topology"))},[a,t.public_key,M,s]),N=n.useCallback(async()=>{if(!r||!d)return;o(m=>({...m,path:"loading"}));const u=await r(t.public_key,d.hops);o(m=>({...m,path:u?"done":"error"})),u&&(v(null),f(null)),setTimeout(()=>o(m=>({...m,path:"idle"})),2e3)},[r,d,t.public_key,o]);return e.jsxs(_e,{className:"pt-2 border-t border-edge-subtle",children:[e.jsxs(Re,{className:"px-0 py-1 flex items-center gap-1.5 w-full text-left",children:[e.jsx(Ge,{className:"w-3.5 h-3.5 text-sys-blue"}),e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wide",children:"Path"}),e.jsx("span",{className:"ml-auto text-[10px] text-fg-muted font-mono",children:R?`${I} hop${I>1?"s":""}`:"direct"})]}),e.jsx(Ie,{children:e.jsxs("div",{className:"space-y-2 py-1",children:[j.length>0&&e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[e.jsx("span",{className:"text-fg-muted type-data-xs",children:"Route"}),j.map((u,m)=>e.jsx("span",{className:"px-1 py-0.5 rounded bg-subtle-fill font-mono text-[10px] text-fg-primary",children:u},m))]}),d&&e.jsxs("div",{className:"space-y-1.5 p-2 rounded-md bg-sys-green/5 border border-sys-green/20",children:[e.jsxs("div",{className:"flex items-center gap-1 type-data-xs text-sys-green",children:[e.jsx(Is,{className:"w-3 h-3"}),e.jsxs("span",{children:["Auto-route (",d.via.length," hop",d.via.length!==1?"s":"",", ",Math.round(d.confidence*100),"% confidence)"]})]}),e.jsx("div",{className:"flex items-center gap-1 flex-wrap",children:d.via.map((u,m)=>e.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded bg-subtle-fill text-[10px]",children:[e.jsx("span",{className:"font-mono text-fg-primary",children:u.prefix}),u.name&&e.jsxs("span",{className:"text-fg-muted",children:["(",u.name,")"]}),u.snr!==0&&e.jsx("span",{className:P("font-mono",lt(u.snr)),children:u.snr.toFixed(1)})]},m))}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs(H,{color:i.path==="done"?"success":"primary",outline:!0,className:"flex-1 justify-center text-xs",disabled:i.path==="loading",onClick:N,children:[e.jsx(be,{"data-slot":"icon"}),i.path==="loading"?"Saving…":"Accept"]}),e.jsxs(H,{plain:!0,className:"text-xs",onClick:()=>{v(null),f(null)},children:[e.jsx(ut,{"data-slot":"icon"}),"Dismiss"]})]})]}),w&&!d&&e.jsx("p",{className:"text-[9px] text-sys-amber",children:w}),r&&!d&&e.jsx("div",{className:"flex items-center gap-2",children:p?e.jsxs("div",{className:"space-y-1.5 flex-1",children:[e.jsx("input",{type:"text",value:c,onChange:u=>{b(u.target.value),g(null)},placeholder:"e.g. a3, f7, 1b",className:"w-full surface-input rounded-md px-2 py-1 text-[10px] font-mono text-fg-primary placeholder:text-fg-muted/50"}),e.jsxs("p",{className:"text-[9px] text-fg-muted/60",children:["Comma-separated hex hop bytes (max ",bt,")"]}),y&&e.jsx("p",{className:"text-[9px] text-sys-red",children:y}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs(H,{color:i.path==="done"?"success":i.path==="error"?"danger":"primary",outline:!0,className:"flex-1 justify-center text-xs",disabled:i.path==="loading"||!c.trim(),onClick:k,children:[e.jsx(ao,{"data-slot":"icon"}),i.path==="loading"?"Saving…":"Save"]}),e.jsx(H,{plain:!0,className:"text-xs",onClick:()=>{C(!1),g(null)},children:"Cancel"})]})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{C(!0),b(j.length>0?j.join(", "):""),g(null)},className:"text-[10px] text-sys-blue hover:text-sys-blue/80 transition-colors",children:"Edit path…"}),a&&M.edgeMap.size>0&&e.jsxs("button",{onClick:$,className:"inline-flex items-center gap-0.5 text-[10px] text-sys-indigo hover:text-sys-indigo/80 transition-colors",children:[e.jsx(Is,{className:"w-3 h-3"}),"Auto-route"]}),l&&e.jsxs("button",{onClick:()=>x("discover",()=>l(t.public_key)),disabled:i.discover==="loading",className:P("inline-flex items-center gap-0.5 text-[10px] transition-colors disabled:opacity-50",i.discover==="error"?"text-sys-red":"text-sys-green hover:text-sys-green/80"),children:[e.jsx(tl,{className:"w-3 h-3"}),i.discover==="loading"?"Discovering…":i.discover==="done"?"Discovered!":i.discover==="error"?"Failed":"Discover"]})]})})]})})]})}function bi({pubkey:t,onLogin:s,onLogout:a,actionState:r,runAction:l}){const[i,o]=n.useState(""),x=It(t);return s?e.jsxs(_e,{className:"pt-2 border-t border-edge-subtle",children:[e.jsxs(Re,{className:"px-0 py-1 flex items-center gap-1.5 w-full text-left",children:[e.jsx(kt,{className:"w-3.5 h-3.5 text-sys-amber"}),e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wide",children:"Login"}),x!=="idle"&&e.jsx(De,{color:x==="success"?"green":x==="failed"?"red":"amber",className:"ml-auto text-[9px]",children:x})]}),e.jsx(Ie,{children:e.jsx("div",{className:"space-y-1.5 py-1",children:x==="success"&&a?e.jsxs(H,{color:r.logout==="done"?"success":r.logout==="error"?"danger":"primary",outline:!0,className:"w-full justify-center text-xs",disabled:r.logout==="loading",onClick:()=>l("logout",()=>a(t)),children:[e.jsx(Kn,{"data-slot":"icon"}),r.logout==="loading"?"Disconnecting…":"Disconnect"]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"password",value:i,onChange:p=>o(p.target.value),placeholder:"Repeater password",className:"w-full surface-input rounded-md px-2 py-1 text-[10px] text-fg-primary placeholder:text-fg-muted/50"}),e.jsxs(H,{color:x==="failed"?"danger":"primary",outline:!0,className:"w-full justify-center text-xs",disabled:r.login==="loading"||!i.trim(),onClick:()=>l("login",()=>s(t,i)),children:[e.jsx(kt,{"data-slot":"icon"}),r.login==="loading"?"Logging in…":"Login"]})]})})})]}):null}function vi({pubkey:t,onGetNeighbours:s,actionState:a,runAction:r}){const l=Un(t),i=It(t);return s?e.jsxs(_e,{className:"pt-2 border-t border-edge-subtle",children:[e.jsxs(Re,{className:"px-0 py-1 flex items-center gap-1.5 w-full text-left",children:[e.jsx(wt,{className:"w-3.5 h-3.5 text-sys-green"}),e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wide",children:"Neighbours"}),l&&e.jsx("span",{className:"ml-auto text-[10px] text-fg-muted",children:l.total})]}),e.jsx(Ie,{children:e.jsxs("div",{className:"space-y-1.5 py-1",children:[e.jsxs(H,{color:"primary",outline:!0,className:"w-full justify-center text-xs",disabled:a.neighbours==="loading"||i!=="success",onClick:()=>r("neighbours",()=>s(t)),children:[e.jsx(wt,{"data-slot":"icon"}),a.neighbours==="loading"?"Loading…":"Get Neighbours"]}),i!=="success"&&e.jsx("p",{className:"text-[9px] text-fg-muted/60",children:"Login required to query neighbours"}),l&&l.neighbours.length>0&&e.jsx("div",{className:"space-y-1",children:[...l.neighbours].sort((o,x)=>x.snr-o.snr).map((o,x)=>e.jsxs("div",{className:"flex items-center gap-2 type-data-xs",children:[e.jsx("span",{className:"text-fg-primary font-mono text-[10px] w-16 truncate",children:o.name||o.prefixHex.slice(0,8)}),e.jsx("span",{className:"text-fg-muted text-[9px]",children:Ni(o.heardAgo)}),e.jsxs("div",{className:"flex-1 flex items-center gap-1 ml-auto",children:[e.jsx("div",{className:"flex-1 h-1.5 rounded-full bg-subtle-fill overflow-hidden",children:e.jsx("div",{className:P("h-full rounded-full",wi(o.snr)),style:{width:`${Math.min(100,Math.max(5,(o.snr+20)/35*100))}%`}})}),e.jsx("span",{className:P("font-mono text-[9px] w-8 text-right",lt(o.snr)),children:o.snr.toFixed(1)})]})]},x))})]})})]}):null}function ji({pubkey:t,contact:s,onTrace:a,actionState:r,runAction:l}){const i=qn(t);if(!a)return null;const o=s.out_path_len>0;return e.jsxs(_e,{className:"pt-2 border-t border-edge-subtle",children:[e.jsxs(Re,{className:"px-0 py-1 flex items-center gap-1.5 w-full text-left",children:[e.jsx(Es,{className:"w-3.5 h-3.5 text-sys-indigo"}),e.jsx("span",{className:"type-data-xs text-fg-muted uppercase tracking-wide",children:"Trace"}),i&&e.jsxs("span",{className:"ml-auto text-[10px] text-fg-muted",children:[i.pathLen," hops"]})]}),e.jsx(Ie,{children:e.jsxs("div",{className:"space-y-1.5 py-1",children:[e.jsxs(H,{color:"primary",outline:!0,className:"w-full justify-center text-xs",disabled:r.trace==="loading"||!o,onClick:()=>l("trace",()=>a(t)),children:[e.jsx(Es,{"data-slot":"icon"}),r.trace==="loading"?"Tracing…":"Trace Path"]}),!o&&e.jsx("p",{className:"text-[9px] text-fg-muted/60",children:"Direct neighbour — no path to trace"}),i&&i.hops.length>0&&e.jsxs("div",{className:"space-y-1",children:[i.hops.map((x,p)=>e.jsxs("div",{className:"flex items-center gap-2 type-data-xs",children:[e.jsx("span",{className:"text-fg-muted text-[9px] w-3",children:p+1}),e.jsx("span",{className:"px-1 py-0.5 rounded bg-subtle-fill font-mono text-[10px] text-fg-primary",children:x.hash}),x.name&&e.jsx("span",{className:"text-fg-muted text-[10px] truncate",children:x.name}),e.jsxs("span",{className:P("font-mono text-[10px] ml-auto",lt(x.snr)),children:[x.snr.toFixed(1)," dB"]})]},p)),e.jsxs("div",{className:"flex items-center justify-between type-data-xs pt-1 border-t border-edge-subtle",children:[e.jsx("span",{className:"text-fg-muted",children:"Last SNR"}),e.jsxs("span",{className:P("font-mono text-[10px]",lt(i.lastSnr)),children:[i.lastSnr.toFixed(1)," dB"]})]})]})]})})]})}function lt(t){return t>5?"text-sys-green":t>0?"text-sys-amber":"text-sys-red"}function wi(t){return t>5?"bg-sys-green":t>0?"bg-sys-amber":"bg-sys-red"}function Ni(t){return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:`${Math.floor(t/86400)}d`}const Vs=128,Ws=/^[0-9a-fA-F]+$/;function ki({open:t,onClose:s}){const a=se(S=>S.exportPrivateKey),r=se(S=>S.importPrivateKey),[l,i]=n.useState("export"),[o,x]=n.useState(null),[p,C]=n.useState(!1),[c,b]=n.useState(!1),[y,g]=n.useState(""),[d,v]=n.useState(!1),[w,f]=n.useState(!1),[M,I]=n.useState(!1),[R,j]=n.useState(!1),[k,$]=n.useState(null),[N,u]=n.useState(!1);t!==N&&(u(t),t&&(i("export"),x(null),C(!1),b(!1),g(""),v(!1),f(!1),I(!1),j(!1),$(null)));const m=n.useCallback(async()=>{C(!0),$(null),j(!1);try{const S=await a();S==="disabled"?j(!0):x(S.hex)}catch(S){$(S instanceof Error?S.message:"Export failed")}finally{C(!1)}},[a]),_=n.useCallback(async()=>{if(o)try{await navigator.clipboard.writeText(o),b(!0),setTimeout(()=>b(!1),2e3)}catch{$("Failed to copy to clipboard")}},[o]),h=y.length===Vs&&Ws.test(y),T=n.useCallback(async()=>{f(!1),v(!0),$(null),j(!1);try{await r(y)==="disabled"?j(!0):I(!0)}catch(S){$(S instanceof Error?S.message:"Import failed")}finally{v(!1)}},[r,y]);return e.jsxs(e.Fragment,{children:[e.jsxs(je,{open:t,onClose:s,size:"md",children:[e.jsx(Ee,{icon:e.jsx(ha,{className:"w-5 h-5"}),title:"Key Management",onClose:s}),e.jsxs(we,{children:[R&&e.jsxs("div",{className:"flex items-start gap-2.5 p-3 mb-4 rounded-lg bg-sys-amber/10 border border-sys-amber/20",children:[e.jsx(Qn,{className:"w-4 h-4 text-sys-amber flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"type-body-sm font-medium text-sys-amber",children:"Key operations disabled"}),e.jsx("p",{className:"type-data-xs text-fg-muted mt-0.5",children:"This device's firmware has disabled private key export/import. This is a security setting configured at build time and cannot be changed remotely."})]})]}),e.jsx("div",{className:"flex gap-1 mb-4 p-0.5 rounded-lg bg-subtle-fill",children:["export","import"].map(S=>e.jsxs("button",{onClick:()=>{i(S),$(null)},className:P("flex-1 flex items-center justify-center gap-1.5 py-1.5 px-3 rounded-md text-sm font-medium transition-colors",l===S?"bg-surface text-fg-primary shadow-sm":"text-fg-muted hover:text-fg-secondary"),children:[S==="export"?e.jsx(He,{className:"w-3.5 h-3.5"}):e.jsx(zt,{className:"w-3.5 h-3.5"}),S==="export"?"Export":"Import"]},S))}),l==="export"&&e.jsx("div",{className:"space-y-4",children:o?e.jsxs(re,{children:[e.jsx(le,{children:"Private Key (64 bytes)"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"p-3 rounded-lg bg-subtle-fill border border-edge-subtle font-mono text-xs break-all select-all leading-relaxed",children:o}),e.jsx("button",{onClick:_,className:"absolute top-2 right-2 p-1.5 rounded-md hover:bg-subtle-fill-strong transition-colors",title:"Copy to clipboard",children:c?e.jsx(be,{className:"w-3.5 h-3.5 text-sys-green"}):e.jsx(Et,{className:"w-3.5 h-3.5 text-fg-muted"})})]}),e.jsx(ke,{children:e.jsxs("span",{className:"flex items-start gap-1.5 mt-1",children:[e.jsx(Be,{className:"w-3 h-3 text-sys-amber flex-shrink-0 mt-0.5"}),"This key controls your mesh identity. Never share it."]})})]}):e.jsxs("div",{className:"text-center py-4",children:[e.jsx("p",{className:"type-body-sm text-fg-muted mb-3",children:"Export your device's private key for backup. Keep it secret — anyone with this key can impersonate your mesh identity."}),e.jsx(H,{color:"primary",onClick:m,disabled:p||R,children:p?"Exporting…":"Export Private Key"})]})}),l==="import"&&e.jsx("div",{className:"space-y-4",children:M?e.jsxs("div",{className:"text-center py-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-sys-green/10 mx-auto mb-3 flex items-center justify-center",children:e.jsx(be,{className:"w-5 h-5 text-sys-green"})}),e.jsx("p",{className:"type-body-sm font-medium text-fg-primary",children:"Key imported successfully"}),e.jsx("p",{className:"type-data-xs text-fg-muted mt-1",children:"The device identity has been updated. You may need to reconnect."})]}):e.jsxs(e.Fragment,{children:[e.jsxs(re,{children:[e.jsx(le,{children:"Private Key (128 hex characters)"}),e.jsx("textarea",{value:y,onChange:S=>g(S.target.value.replace(/\s/g,"")),placeholder:"Paste your 128-character hex private key here…",rows:3,className:"w-full p-3 rounded-lg bg-subtle-fill border border-edge-subtle font-mono text-xs resize-none focus:outline-none focus:ring-2 focus:ring-sys-blue/50 placeholder:text-fg-muted/40"}),e.jsxs(ke,{children:[y.length>0&&!h&&e.jsx("span",{className:"text-sys-red",children:Ws.test(y)?`${y.length}/${Vs} characters`:"Invalid characters — hex only (0-9, a-f)"}),y.length>0&&h&&e.jsx("span",{className:"text-sys-green",children:"Valid key format ✓"})]})]}),e.jsxs("div",{className:"flex items-start gap-2.5 p-3 rounded-lg bg-sys-red/5 border border-sys-red/10",children:[e.jsx(Be,{className:"w-4 h-4 text-sys-red flex-shrink-0 mt-0.5"}),e.jsxs("p",{className:"type-data-xs text-fg-muted",children:["Importing a key ",e.jsx("strong",{className:"text-fg-secondary",children:"permanently replaces"})," the device's current identity. All existing contacts will see you as a new node."]})]})]})}),k&&e.jsx("p",{className:"type-data-xs text-sys-red mt-3",children:k})]}),e.jsxs(Me,{children:[e.jsx(H,{plain:!0,onClick:s,children:"Close"}),l==="import"&&!M&&e.jsx(H,{color:"danger",onClick:()=>f(!0),disabled:!h||d||R,children:d?"Importing…":"Import Key"})]})]}),e.jsx(xa,{isOpen:w,title:"Replace Device Identity?",message:"This will permanently replace the device's Ed25519 private key. The current identity cannot be recovered unless you have a backup. Continue?",confirmLabel:"Replace Key",cancelLabel:"Cancel",variant:"danger",onConfirm:T,onCancel:()=>f(!1)})]})}function Sa(t){return t.settings??{}}const _a="pymc_companion_recent_regions",Bt=8;function Ra(){try{const t=localStorage.getItem(_a);return t?JSON.parse(t).slice(0,Bt):[]}catch{return[]}}function Ci(t){try{localStorage.setItem(_a,JSON.stringify(t.slice(0,Bt)))}catch{}}function Si(t){const s=Ra().filter(r=>r!==t);s.unshift(t);const a=s.slice(0,Bt);return Ci(a),a}function Qs(t){return t.toLowerCase().replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"")}function _i({open:t,onClose:s,mode:a,identity:r,onSave:l}){const i=a==="edit"&&r,[o,x]=n.useState(""),[p,C]=n.useState(""),[c,b]=n.useState(""),[y,g]=n.useState(!1),[d,v]=n.useState(""),[w,f]=n.useState(5e3),[M,I]=n.useState("0.0.0.0"),[R,j]=n.useState(!1),[k,$]=n.useState(null),[N,u]=n.useState(""),m=`${t}-${(r==null?void 0:r.name)??""}-${a}`;if(m!==N)if(u(m),$(null),j(!1),g(!1),i){const h=Sa(r);x(r.name),C(""),b(r.identity_key??""),v(h.node_name??r.name),f(h.tcp_port??5e3),I(h.bind_address??"0.0.0.0")}else x(""),C(""),b(""),v(""),f(5e3),I("0.0.0.0");const _=n.useCallback(async()=>{var h,T;if(!i&&!o.trim()){$("Name is required");return}j(!0),$(null);try{if(i){const S={name:r.name,new_name:p,identity_key:c,type:"companion",settings:{node_name:d,tcp_port:w,bind_address:M}},O=await er(S);if(!O.success&&!((h=O.data)!=null&&h.message))throw new Error(O.error||"Failed")}else{const S={name:o.trim(),identity_key:c,type:"companion",settings:{node_name:d||o.trim(),tcp_port:w??5e3,bind_address:M||"0.0.0.0"}},O=await tr(S);if(!O.success&&!((T=O.data)!=null&&T.message))throw new Error(O.error||"Failed")}await l(),s()}catch(S){$(S instanceof Error?S.message:"Operation failed")}finally{j(!1)}},[i,r,o,p,c,d,w,M,l,s]);return e.jsxs(je,{open:t,onClose:s,size:"md",children:[e.jsx(Ee,{icon:i?void 0:e.jsx(ye,{className:"w-5 h-5"}),title:i?"Edit Companion":"Add Companion",onClose:s}),e.jsx(we,{children:e.jsxs("div",{className:"space-y-5",children:[i&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De,{color:r.registered?"green":"red",children:r.registered?"Active":"Inactive"}),r.hash&&e.jsx("span",{className:"type-data-xs text-fg-muted",children:r.hash})]}),i?e.jsxs(e.Fragment,{children:[e.jsxs(re,{children:[e.jsx(le,{children:"Current Name"}),e.jsx(pe,{value:r.name,disabled:!0})]}),e.jsxs(re,{children:[e.jsxs(le,{children:["New Name ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(Optional)"})]}),e.jsx(pe,{value:p,onChange:h=>C(h.target.value),placeholder:"Leave empty to keep current name"})]})]}):e.jsxs(re,{children:[e.jsx(le,{children:"Name"}),e.jsx(pe,{value:o,onChange:h=>x(h.target.value),placeholder:"e.g., TestCompanion",autoFocus:!0})]}),e.jsxs(re,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(le,{children:["Identity Key ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(Optional)"})]}),e.jsx("button",{type:"button",onClick:()=>g(h=>!h),className:"type-data-xs text-fg-muted underline hover:text-fg-secondary",children:y?"Hide":"Show"})]}),y&&e.jsxs(e.Fragment,{children:[e.jsx(pe,{value:c,onChange:h=>b(h.target.value),placeholder:i?"Leave empty to keep current key":"Leave empty to auto-generate",className:"font-mono"}),e.jsx(ke,{children:"32 or 64 bytes hex."})]})]}),e.jsxs(re,{children:[e.jsx(le,{children:"Node Name"}),e.jsx(pe,{value:d,onChange:h=>v(h.target.value),placeholder:"Display name"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs(re,{children:[e.jsx(le,{children:"TCP Port"}),e.jsx(pe,{type:"number",min:1,max:65535,value:w,onChange:h=>f(parseInt(h.target.value,10)||5e3)})]}),e.jsxs(re,{children:[e.jsx(le,{children:"Bind Address"}),e.jsx(pe,{value:M,onChange:h=>I(h.target.value),placeholder:"0.0.0.0"})]})]}),k&&e.jsx("p",{className:"type-data-xs text-sys-red",children:k})]})}),e.jsxs(Me,{children:[e.jsx(H,{plain:!0,onClick:s,children:"Cancel"}),e.jsx(H,{color:"primary",onClick:_,disabled:R,children:R?"Saving…":i?"Save":"Create"})]})]})}function Ri(){const t=Jn(),s=la(),{setFloodScope:a,clearFloodScope:r}=se.getState(),[l,i]=n.useState(""),[o,x]=n.useState(!1),[p,C]=n.useState(Ra),[c,b]=n.useState(null),y=n.useRef(null),g=l.trim()?Qs(l.trim()):"",d=n.useCallback(async f=>{const M=Qs(f);if(!M)return;x(!0),b(null),i(""),C(Si(M)),await a(M)||b("Failed to set transport key on device"),x(!1)},[a]),v=n.useCallback(async()=>{x(!0),b(null),await r()||b("Failed to clear transport key on device"),x(!1)},[r]),w=n.useCallback(f=>{f.key==="Enter"&&g&&(f.preventDefault(),d(g))},[g,d]);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-2.5 p-3 rounded-lg bg-sys-blue/5 border border-sys-blue/10",children:[e.jsx(nt,{className:"w-4 h-4 text-sys-blue flex-shrink-0 mt-0.5"}),e.jsxs("p",{className:"type-data-xs text-fg-muted",children:["A transport key filters which flood packets the companion device forwards. Set a region name to derive a SHA-256 transport key from ",e.jsx("code",{className:"text-fg-secondary",children:"#name"}),". Only one transport key can be active at a time."]})]}),e.jsx("div",{className:"bg-subtle-fill radius-inner p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fa,{className:"w-4 h-4 text-fg-muted"}),e.jsx("span",{className:"type-body-sm text-fg-muted",children:"Active Transport Key"})]}),t?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-sys-green/10 text-sys-green type-data font-medium",children:[e.jsx(ia,{className:"w-3.5 h-3.5"}),"#",t]}),e.jsx("button",{onClick:v,disabled:o||!s,className:"p-1.5 rounded-lg hover:bg-sys-red/10 transition-colors disabled:opacity-50",title:"Clear transport key",children:o?e.jsx(oe,{className:"w-3.5 h-3.5 text-fg-muted animate-spin"}):e.jsx(ut,{className:"w-3.5 h-3.5 text-fg-muted hover:text-sys-red"})})]}):e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-subtle-fill-strong text-fg-muted type-data",children:[e.jsx(Zn,{className:"w-3.5 h-3.5"}),"Global (no filter)"]})]})}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Set Region"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-fg-muted/50 type-data",children:"#"}),e.jsx("input",{ref:y,type:"text",value:l,onChange:f=>i(f.target.value),onKeyDown:w,placeholder:"e.g., south-bay",disabled:!s,className:"w-full pl-7 pr-3 py-2 rounded-lg bg-subtle-fill border border-edge-subtle text-sm text-fg-primary placeholder:text-fg-muted/40 focus:outline-none focus:ring-2 focus:ring-sys-blue/50 disabled:opacity-50"})]}),e.jsxs(H,{color:"primary",onClick:()=>d(g),disabled:!g||o||!s,children:[o?e.jsx(oe,{"data-slot":"icon",className:"animate-spin"}):null,"Set"]})]}),g&&g!==l.trim().toLowerCase()&&e.jsxs("p",{className:"type-data-xs text-fg-muted mt-1",children:["Will set as ",e.jsxs("span",{className:"font-mono text-fg-secondary",children:["#",g]})]})]}),p.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx(ua,{className:"w-3.5 h-3.5 text-fg-muted/50"}),e.jsx("span",{className:"type-label text-fg-muted",children:"Recent Regions"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:p.map(f=>e.jsx("button",{onClick:()=>d(f),disabled:o||!s,className:P("inline-flex items-center gap-1 px-2.5 py-1 rounded-full text-xs font-medium transition-colors","disabled:opacity-50 disabled:cursor-not-allowed",f===t?"bg-sys-green/10 text-sys-green":"bg-subtle-fill hover:bg-subtle-fill-strong text-fg-secondary"),children:e.jsxs("span",{className:"font-mono",children:["#",f]})},f))})]}),!s&&e.jsx("p",{className:"type-data-xs text-sys-amber",children:"Companion device is not connected. Connect to a companion to manage transport keys."}),c&&e.jsx("p",{className:"type-data-xs text-sys-red",children:c})]})}function Ys({open:t,onClose:s,onRefresh:a}){const[r,l]=n.useState("companions"),[i,o]=n.useState(null),[x,p]=n.useState(!0),[C,c]=n.useState(!1),[b,y]=n.useState("create"),[g,d]=n.useState(null),[v,w]=n.useState(null),[f,M]=n.useState(!1),[I,R]=n.useState(!1),j=n.useRef(!0);n.useEffect(()=>(j.current=!0,()=>{j.current=!1}),[]);const[k,$]=n.useState(!1);t!==k&&($(t),t&&l("companions"));const N=n.useCallback(async()=>{p(!0);try{const h=await Yn();j.current&&h.success&&h.data&&o(h.data)}catch{}finally{j.current&&p(!1)}},[]);n.useEffect(()=>{t&&N()},[t,N]);const u=(i==null?void 0:i.configured_companions)??[],m=n.useCallback(async()=>{await N(),a==null||a()},[N,a]),_=n.useCallback(async()=>{if(v){M(!0);try{await Xn(v.name,"companion"),await m()}catch{}finally{j.current&&(M(!1),w(null))}}},[v,m]);return e.jsxs(e.Fragment,{children:[e.jsxs(je,{open:t,onClose:s,size:"md",children:[e.jsx(Ee,{icon:e.jsx(ye,{className:"w-5 h-5"}),title:"Companion Configuration",onClose:s}),e.jsxs(we,{children:[e.jsx("div",{className:"flex gap-1 mb-4 p-0.5 rounded-lg bg-subtle-fill",children:[["companions","Companions",ye],["transport","Transport Key",fa]].map(([h,T,S])=>e.jsxs("button",{onClick:()=>l(h),className:P("flex-1 flex items-center justify-center gap-1.5 py-1.5 px-3 rounded-md text-sm font-medium transition-colors",r===h?"bg-surface text-fg-primary shadow-sm":"text-fg-muted hover:text-fg-secondary"),children:[e.jsx(S,{className:"w-3.5 h-3.5"}),T]},h))}),r==="companions"&&e.jsx(e.Fragment,{children:x?e.jsxs("div",{className:"flex items-center justify-center py-8",children:[e.jsx(oe,{className:"w-5 h-5 animate-spin text-sys-blue mr-2"}),e.jsx("span",{className:"text-sm text-fg-muted",children:"Loading…"})]}):u.length>0?e.jsx("div",{className:"space-y-3",children:u.map(h=>{const T=Sa(h);return e.jsxs("div",{className:"bg-subtle-fill radius-inner p-3 hover:bg-subtle-fill-strong transition-base",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:P("h-2 w-2 rounded-full flex-shrink-0",h.registered?"bg-sys-green":"bg-sys-red")}),e.jsx("h3",{className:"type-body-sm text-fg-primary font-medium truncate flex-1",children:h.name}),e.jsx(De,{color:h.registered?"green":"red",children:h.registered?"Active":"Inactive"}),e.jsx(H,{color:"primary",plain:!0,onClick:()=>{d(h),y("edit"),c(!0)},children:e.jsx(sl,{"data-slot":"icon"})}),e.jsx(H,{color:"danger",plain:!0,onClick:()=>w(h),children:e.jsx(Ke,{"data-slot":"icon"})})]}),e.jsxs("div",{className:"mt-1.5 type-data-xs text-fg-muted pl-5",children:[T.node_name||h.name," · Port ",T.tcp_port??5e3," · ",T.bind_address||"0.0.0.0"]})]},h.name)})}):e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-subtle-fill mx-auto mb-3 flex items-center justify-center",children:e.jsx(ye,{className:"w-5 h-5 text-fg-muted/50"})}),e.jsx("p",{className:"text-sm text-fg-muted",children:"No companions configured"})]})}),r==="transport"&&e.jsx(Ri,{})]}),e.jsxs(Me,{children:[r==="companions"&&e.jsx(H,{plain:!0,onClick:()=>R(!0),title:"Key Management",children:e.jsx(ha,{"data-slot":"icon"})}),e.jsx("div",{className:"flex-1"}),e.jsx(H,{plain:!0,onClick:s,children:"Close"}),r==="companions"&&e.jsxs(H,{color:"primary",onClick:()=>{d(null),y("create"),c(!0)},children:[e.jsx(Ue,{"data-slot":"icon"})," Add Companion"]})]})]}),e.jsx(_i,{open:C,onClose:()=>c(!1),mode:b,identity:g,onSave:m}),e.jsx(xa,{isOpen:!!v,title:"Delete Companion",message:`Delete '${v==null?void 0:v.name}'? A service restart is required.`,confirmLabel:f?"Deleting…":"Delete",cancelLabel:"Cancel",variant:"danger",onConfirm:_,onCancel:()=>w(null)}),e.jsx(ki,{open:I,onClose:()=>R(!1)})]})}const Ii=n.memo(function({companions:s,selected:a,onSelect:r}){return s.length<2?null:e.jsx("select",{value:a??"",onChange:l=>r(l.target.value),className:"px-2 py-1 text-sm bg-transparent border border-edge-subtle radius-inner text-fg-primary focus:outline-none focus:ring-1 focus:ring-sys-blue/40",children:s.map(l=>e.jsx("option",{value:l.companion_name,children:l.node_name||l.companion_name},l.companion_name))})}),Ae=[{value:"Chat Node",label:"Companions"},{value:"Room Server",label:"Room Servers"},{value:"Repeater",label:"Repeaters"}],Ei=[{value:"all",label:"All time"},{value:"24h",label:"Last 24 hours"},{value:"7d",label:"Last 7 days"},{value:"30d",label:"Last 30 days"}];function Mi(t){switch(t){case"24h":return 24;case"7d":return 168;case"30d":return 720;default:return}}function Pi({open:t,onClose:s,companionName:a,onImport:r}){const[l,i]=n.useState(()=>new Set(Ae.map(R=>R.value))),[o,x]=n.useState("all"),[p,C]=n.useState(""),[c,b]=n.useState(!1),[y,g]=n.useState(null),[d,v]=n.useState(t);t!==d&&(v(t),t&&(i(new Set(Ae.map(R=>R.value))),x("all"),C(""),b(!1),g(null)));const w=l.size===Ae.length;function f(R){i(j=>{const k=new Set(j);return k.has(R)?k.delete(R):k.add(R),k})}function M(){i(w?new Set:new Set(Ae.map(R=>R.value)))}const I=n.useCallback(async()=>{if(!(l.size===0||c)){b(!0),g(null);try{const R={types:[...l],hours:Mi(o)},j=parseInt(p,10);j>0&&(R.limit=j);const k=await r(R);g(k)}finally{b(!1)}}},[l,o,p,c,r]);return e.jsxs(je,{open:t,onClose:s,size:"sm",children:[e.jsx(Ee,{title:"Import repeater contacts",onClose:s}),e.jsx(we,{children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("p",{className:"text-sm text-fg-secondary",children:["Seed ",e.jsx("strong",{className:"text-fg-primary",children:a})," with contacts from the repeater's adverts. Results are ordered by most recent first."]}),e.jsxs(re,{children:[e.jsx(le,{children:"Contact types"}),e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsx(ws,{checked:w,indeterminate:l.size>0&&!w,onChange:M,label:"All types",size:"sm"}),e.jsx("div",{className:"ml-6 space-y-1.5",children:Ae.map(R=>e.jsx(ws,{checked:l.has(R.value),onChange:()=>f(R.value),label:R.label,size:"sm"},R.value))})]})]}),e.jsx(po,{label:"Recency",value:o,onChange:x,options:Ei,orientation:"horizontal",size:"sm"}),e.jsxs(re,{children:[e.jsxs(le,{children:["Import at most ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(optional)"})]}),e.jsx(pe,{type:"number",min:1,value:p,onChange:R=>C(R.target.value),placeholder:"No limit",className:"mt-1"}),e.jsx(ke,{children:"Leave empty for no cap."})]}),y&&e.jsxs("p",{className:"text-sm text-sys-green font-medium",children:["Imported ",y.added," new contact",y.added!==1?"s":""," (",y.total," total)"]})]})}),e.jsxs(Me,{children:[e.jsx(H,{plain:!0,onClick:s,children:"Cancel"}),e.jsx(H,{color:"primary",onClick:I,disabled:c||l.size===0,children:c?e.jsxs(e.Fragment,{children:[e.jsx(oe,{"data-slot":"icon",className:"animate-spin"}),"Importing…"]}):"Import"})]})]})}const Ti=["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"],$i=new Set(Ti);function Di(){return crypto.getRandomValues(new Uint8Array(16))}function Xs(t){return Array.from(t).map(s=>s.toString(16).padStart(2,"0")).join("")}function vt(t){const s=t.replace(/\s/g,"");if(s.length!==32||!/^[0-9a-fA-F]+$/.test(s))return null;const a=new Uint8Array(16);for(let r=0;r<16;r++)a[r]=parseInt(s.slice(r*2,r*2+2),16);return a}async function Fi(t){const a=`#${oa(t)}`,r=new TextEncoder().encode(a);return(await sr(r)).slice(0,16)}const Js=[{key:"create-private",label:"Create Private",icon:Gr,desc:"Generate a new private channel with a random key"},{key:"join-private",label:"Join Private",icon:Vl,desc:"Join an existing private channel using a shared key"},{key:"join-hashtag",label:"Join Hashtag",icon:Fe,desc:"Join a public hashtag channel (key derived from name)"}];function Li({open:t,onClose:s,channels:a,onAddChannel:r}){var _;const[l,i]=n.useState("join-hashtag"),[o,x]=n.useState(""),[p,C]=n.useState(""),[c,b]=n.useState(null),[y,g]=n.useState(!1),[d,v]=n.useState(""),[w,f]=n.useState(!1),[M,I]=n.useState(t);t!==M&&(I(t),t&&(i("join-hashtag"),x(""),C(""),b(null),g(!1),v(""),f(!1)));const R=n.useMemo(()=>a.length===0?0:Math.max(...a.map(h=>h.index))+1,[a]),j=n.useMemo(()=>l!=="join-hashtag"?"":oa(o),[l,o]),k=n.useMemo(()=>{if(!o.trim())return null;const h=l==="join-hashtag"&&j?`#${j}`:o.trim();return a.find(T=>T.name===h)??null},[o,l,j,a]),$=n.useMemo(()=>l==="join-hashtag"&&j?$i.has(j):!1,[l,j]),N=n.useMemo(()=>{if(!o.trim()||k)return!1;switch(l){case"create-private":return o.trim().length>0&&o.trim().length<=32;case"join-private":return o.trim().length>0&&vt(p)!==null;case"join-hashtag":return j.length>0;default:return!1}},[l,o,p,j,k]),u=n.useCallback(async()=>{c&&(await navigator.clipboard.writeText(Xs(c)),f(!0),setTimeout(()=>f(!1),2e3))},[c]),m=n.useCallback(async()=>{if(!(!N||y)){g(!0),v("");try{let h,T;switch(l){case"create-private":{h=Di(),T=o.trim();break}case"join-private":{const O=vt(p);if(!O){v("Invalid hex key (must be 32 hex chars = 16 bytes)");return}h=O,T=o.trim();break}case"join-hashtag":{h=await Fi(o),T=`#${j}`;break}default:return}if(await r(R,T,h)){if(l==="create-private"){b(h);return}s()}else v("Failed to add channel — device may be unreachable")}catch(h){v(h instanceof Error?h.message:"Unknown error")}finally{g(!1)}}},[N,y,l,o,p,j,R,r,s]);return e.jsxs(je,{open:t,onClose:s,size:"sm",children:[e.jsx(Ee,{title:"Add Channel",onClose:s}),e.jsx(we,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex gap-1 p-0.5 radius-inner bg-zinc-950/5",children:Js.map(h=>{const T=h.icon,S=l===h.key;return e.jsxs("button",{onClick:()=>{i(h.key),v(""),b(null)},className:P("flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors",S?"bg-surface text-fg-primary shadow-sm":"text-fg-muted hover:text-fg-secondary"),children:[e.jsx(T,{className:"w-3.5 h-3.5"}),h.label]},h.key)})}),e.jsx("p",{className:"text-xs text-fg-muted",children:(_=Js.find(h=>h.key===l))==null?void 0:_.desc}),c&&l==="create-private"&&e.jsxs("div",{className:"p-3 radius-inner bg-sys-green/8 border border-sys-green/20 space-y-2",children:[e.jsx("p",{className:"text-xs text-sys-green font-medium",children:"Channel created! Share this key with others:"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 text-[11px] font-mono text-fg-primary bg-zinc-950/10 px-2 py-1 rounded break-all",children:Xs(c)}),e.jsx("button",{onClick:u,className:"p-1.5 rounded hover:bg-subtle-fill transition-colors flex-shrink-0",title:"Copy key",children:w?e.jsx(be,{className:"w-3.5 h-3.5 text-sys-green"}):e.jsx(Et,{className:"w-3.5 h-3.5 text-fg-muted"})})]}),e.jsx("p",{className:"text-[11px] text-fg-muted",children:"Save this key — it cannot be recovered later."})]}),e.jsxs(re,{children:[e.jsx(le,{children:l==="join-hashtag"?"Hashtag name":"Channel name"}),e.jsx(pe,{type:"text",value:o,onChange:h=>x(h.target.value),placeholder:l==="join-hashtag"?"e.g. south-bay":"e.g. My Channel",maxLength:32,className:"mt-1",disabled:!!c}),l==="join-hashtag"&&j&&j!==o&&e.jsxs(ke,{className:"mt-1",children:["Will be registered as ",e.jsxs("code",{className:"text-fg-primary font-mono text-[11px]",children:["#",j]})]}),l==="join-hashtag"&&$&&e.jsx(ke,{className:"mt-1 text-sys-green",children:"Known region channel"})]}),k&&e.jsxs("div",{className:"flex items-start gap-2 p-2.5 radius-inner bg-sys-red/8 border border-sys-red/20",children:[e.jsx(Be,{className:"w-3.5 h-3.5 text-sys-red flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-xs text-fg-secondary",children:["Channel ",e.jsx("strong",{className:"text-fg-primary",children:k.name})," already exists at slot ",k.index,". Remove it first to re-add."]})]}),l==="join-private"&&e.jsxs(re,{children:[e.jsxs(le,{children:["Channel key ",e.jsx("span",{className:"text-fg-muted font-normal",children:"(32 hex chars)"})]}),e.jsx(pe,{type:"text",value:p,onChange:h=>C(h.target.value),placeholder:"e.g. a1b2c3d4e5f6...",maxLength:32,className:"mt-1 font-mono text-xs"}),p&&!vt(p)&&e.jsx(ke,{className:"mt-1 text-sys-red",children:"Must be exactly 32 hex characters (16 bytes)"})]}),e.jsxs("p",{className:"text-[11px] text-fg-muted",children:["Will be assigned to channel slot ",e.jsx("strong",{className:"text-fg-primary",children:R})]}),d&&e.jsx("p",{className:"text-xs text-sys-red font-medium",children:d})]})}),e.jsxs(Me,{children:[e.jsx(H,{plain:!0,onClick:s,children:c?"Done":"Cancel"}),!c&&e.jsx(H,{color:"primary",onClick:m,disabled:!N||y,children:y?e.jsxs(e.Fragment,{children:[e.jsx(oe,{className:"w-4 h-4 animate-spin"}),"Adding…"]}):l==="create-private"?"Create Channel":"Join Channel"})]})]})}const Oi=202,Ai=/^[0-9a-fA-F]+$/;function zi(t){const s=t.replace(/\s/g,"");return s.length>=Oi&&s.length%2===0&&Ai.test(s)}const Hi=n.memo(function({open:s,onClose:a,contacts:r,exportPubKey:l,onExport:i,onImport:o}){const[x,p]=n.useState(l?"export":"import"),[C,c]=n.useState(l??""),[b,y]=n.useState(""),[g,d]=n.useState(""),[v,w]=n.useState(!1),[f,M]=n.useState(!1),[I,R]=n.useState(!1),[j,k]=n.useState(null),[$,N]=n.useState(!1),u=n.useRef(null);n.useEffect(()=>{s&&(p(l?"export":"import"),c(l??""),y(""),d(""),w(!1),M(!1),R(!1),k(null),N(!1))},[s,l]);const m=n.useCallback(()=>{a()},[a]),_=n.useCallback(async()=>{if(!C)return;w(!0),k(null),y("");const S=await i(C);w(!1),S?y(S):k("Failed to export contact advert")},[C,i]),h=n.useCallback(async()=>{if(b)try{await navigator.clipboard.writeText(b),R(!0),setTimeout(()=>R(!1),2e3)}catch{k("Failed to copy to clipboard")}},[b]),T=n.useCallback(async()=>{const S=g.replace(/\s/g,"");if(!zi(S)){k("Invalid hex — must be at least 202 hex characters (101 bytes)");return}M(!0),k(null);const O=await o(S);M(!1),O?(N(!0),d(""),setTimeout(()=>m(),1500)):k("Import failed — check the hex string and try again")},[g,o,m]);return e.jsxs(je,{open:s,onClose:m,children:[e.jsx(ar,{children:"Contact Import / Export"}),e.jsxs(we,{children:[e.jsxs("div",{className:"flex gap-1 p-0.5 rounded-lg bg-subtle-fill mb-4",children:[e.jsxs("button",{onClick:()=>{p("export"),k(null)},className:P("flex-1 flex items-center justify-center gap-1.5 py-1.5 rounded-md text-xs font-medium transition-colors",x==="export"?"bg-surface shadow-sm text-fg-primary":"text-fg-muted hover:text-fg-secondary"),children:[e.jsx(zt,{className:"w-3.5 h-3.5"}),"Export"]}),e.jsxs("button",{onClick:()=>{p("import"),k(null)},className:P("flex-1 flex items-center justify-center gap-1.5 py-1.5 rounded-md text-xs font-medium transition-colors",x==="import"?"bg-surface shadow-sm text-fg-primary":"text-fg-muted hover:text-fg-secondary"),children:[e.jsx(He,{className:"w-3.5 h-3.5"}),"Import"]})]}),x==="export"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-fg-muted mb-1",children:"Select contact"}),e.jsxs("select",{value:C,onChange:S=>{c(S.target.value),y(""),k(null)},className:"w-full surface-input rounded-lg px-3 py-2 text-sm text-fg-primary",children:[e.jsx("option",{value:"",children:"Choose a contact…"}),r.map(S=>e.jsx("option",{value:S.public_key,children:S.name||S.public_key.slice(0,12)},S.public_key))]})]}),e.jsx(H,{color:"primary",outline:!0,className:"w-full justify-center",disabled:!C||v,onClick:_,children:v?"Exporting…":"Export Advert"}),b&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("textarea",{readOnly:!0,value:b,rows:4,className:"w-full surface-input rounded-lg px-3 py-2 text-[10px] font-mono text-fg-primary break-all resize-none"}),e.jsxs(H,{color:I?"success":"primary",outline:!0,className:"w-full justify-center",onClick:h,children:[I?e.jsx(be,{"data-slot":"icon"}):e.jsx(Et,{"data-slot":"icon"}),I?"Copied!":"Copy to Clipboard"]})]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-fg-muted mb-1",children:"Paste advert hex string"}),e.jsx("textarea",{ref:u,value:g,onChange:S=>{d(S.target.value),k(null),N(!1)},placeholder:"Paste exported advert hex here…",rows:4,className:"w-full surface-input rounded-lg px-3 py-2 text-[10px] font-mono text-fg-primary break-all resize-none placeholder:text-fg-muted/50"}),e.jsx("p",{className:"text-[10px] text-fg-muted/70 mt-1",children:"Minimum 101 bytes (202 hex characters): 32B pubkey + 4B timestamp + 64B signature + appData"})]}),$&&e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-sys-green/10 text-sys-green text-xs font-medium",children:[e.jsx(be,{className:"w-3.5 h-3.5"}),"Contact imported successfully"]}),e.jsx(H,{color:"primary",outline:!0,className:"w-full justify-center",disabled:!g.trim()||f,onClick:T,children:f?"Importing…":"Import Contact"})]}),j&&e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 mt-3 rounded-lg bg-sys-red/10 text-sys-red text-xs",children:[e.jsx(da,{className:"w-3.5 h-3.5 flex-shrink-0"}),j]})]}),e.jsx(Me,{children:e.jsx(H,{plain:!0,onClick:m,children:"Close"})})]})});function wc(){var us,ms,ps,xs,hs,fs;const t=nr(),s=rr(),a=lr(),r=or(),l=ir(),i=cr(),o=mt(),x=dr(),p=ur(),C=mr(),c=pr(),b=n.useMemo(()=>{if(l.length===0)return r;const E=new Set(r.map(L=>L.public_key));return[...r,...l.filter(L=>!E.has(L.public_key))]},[r,l]),y=n.useMemo(()=>{const E=new Set;if(!(c!=null&&c.neighbors))return E;const L=[];for(const[B,X]of Object.entries(c.neighbors))X.zero_hop&&L.push((B.startsWith("0x")?B.slice(2):B).toLowerCase());for(const B of b){const X=B.public_key.toLowerCase();for(const ce of L)if(X===ce||X.startsWith(ce)){E.add(B.public_key);break}}return E},[c==null?void 0:c.neighbors,b]),g=n.useMemo(()=>{const E=new Map;if(!(c!=null&&c.neighbors))return E;const L=[];for(const[B,X]of Object.entries(c.neighbors))X.zero_hop&&X.rssi!=null&&X.snr!=null&&X.rssi!==0&&L.push({hash:(B.startsWith("0x")?B.slice(2):B).toLowerCase(),rssi:X.rssi,snr:X.snr,advertCount:X.advert_count??1});if(L.length===0)return E;for(const B of b){const X=B.public_key.toLowerCase();for(const ce of L)if(X===ce.hash||X.startsWith(ce.hash)){E.set(B.public_key,{rssi:ce.rssi,snr:ce.snr,advertCount:ce.advertCount});break}}return E},[c==null?void 0:c.neighbors,b]),d=xr(),v=hr(),w=la(),f=fr(),M=gr(),I=yr(),R=br(),j=vr(),[k,$]=jr(),[N,u]=n.useState(!1),[m,_]=n.useState(!1),[h,T]=n.useState(!1),[S,O]=n.useState(!1),[ie,Y]=n.useState(null),[D,K]=n.useState(!1),[ee,V]=n.useState(!1),[F,A]=n.useState(!0),z="pymc_companion_contacts_micro",U="pymc_companion_split",[ne,xt]=n.useState(()=>{try{return localStorage.getItem(z)==="1"}catch{return!1}}),We=25,Gt=75,[ht,Kt]=n.useState(()=>{try{const E=Number(localStorage.getItem(U));return E>=We&&E<=Gt?E:50}catch{return 50}}),Qe=n.useRef(null),Le=n.useRef(null),Ut=n.useRef(null),Ye=n.useRef(!1),Oe=n.useRef(ht);Oe.current=ht;const Ia=n.useCallback(E=>{E.preventDefault(),E.target.setPointerCapture(E.pointerId),Ye.current=!0},[]),Ea=n.useCallback(E=>{if(!Ye.current||!Qe.current)return;const L=Qe.current.getBoundingClientRect(),B=Math.round(Math.min(Gt,Math.max(We,(E.clientX-L.left)/L.width*100)));Oe.current=B,Le.current&&(Le.current.style.width=`${B}%`)},[]),qt=n.useCallback(()=>{if(!Ye.current)return;Ye.current=!1;const E=Oe.current;Kt(E);try{localStorage.setItem(U,String(E))}catch{}},[]),Ma=n.useCallback(()=>{Oe.current=50,Le.current&&tt(Le.current,{width:"50%"},de.layoutResize),Kt(50);try{localStorage.setItem(U,String(50))}catch{}},[]),Pa=n.useCallback(E=>{xt(E);const L=Qe.current,B=Ut.current;if(!L)return;const X=L.getBoundingClientRect().width;L.style.width=E?"var(--companion-side-micro)":"var(--companion-side)";const ce=L.getBoundingClientRect().width;if(L.style.width=`${X}px`,B){const tn=E?56:Oe.current/100*ce,sn=B.offsetWidth,an=Math.max(0,ce-tn-12);B.style.flex="none",B.style.width=`${sn}px`,tt(B,{width:`${an}px`},{...de.layoutResize,onComplete(){B.style.flex="",B.style.width=""}})}tt(L,{width:`${ce}px`},{...de.layoutResize,onComplete(){L.style.width=E?"var(--companion-side-micro)":"var(--companion-side)"}})},[]),{selectCompanion:Ta,selectConversation:ve,sendMessage:Vt,sendChannelMessage:Wt,retryMessage:$a,retryMessageAsFlood:Da,resetPath:ft,shareContact:Fa,removeContact:La,addChannel:Oa,requestStatus:Qt,requestTelemetry:Yt,loginToRepeater:gt,logoutFromRepeater:Xt,getNeighbours:Jt,traceContactPath:Zt,discoverPath:es,pingContact:Aa,markAsRead:ts,fetchCompanions:ss,seedFromRepeater:za,exportContactAdvert:Ha,importContactAdvert:Ba,setContactPath:as,deleteChannel:Ga,loadOlderMessages:Ka}=se.getState(),Ua=n.useCallback(E=>{ve(E),window.innerWidth>=1280?K(!0):V(!0)},[ve]),ns=se(E=>E.messages),rs=se(E=>E.unreadMap);n.useEffect(()=>{ts()},[d,ts]),n.useEffect(()=>{const E=k.get("dm");E&&b.length>0&&b.find(B=>B.public_key===E)&&(ve({type:"contact",id:E}),$({},{replace:!0}))},[k,b,ve,$]);const qa=n.useMemo(()=>{const E=new Set;for(const L of b)L.name&&E.add(L.name);for(const L of v)L.sender_name&&!L.is_outgoing&&E.add(L.sender_name);return[...E].sort((L,B)=>L.localeCompare(B))},[b,v]),ls=n.useMemo(()=>{const E=new Map;for(const L of b)L.name&&E.set(L.name.toLowerCase(),L.public_key);for(const L of v)if(L.sender_name&&L.sender_key&&L.sender_key!=="unknown"&&!L.is_outgoing){const B=L.sender_name.toLowerCase();E.has(B)||E.set(B,L.sender_key)}return E},[b,v]),Va=n.useCallback(E=>{const L=ls.get(E.toLowerCase());L&&(ve({type:"contact",id:L}),K(!0))},[ls,ve]),Wa=n.useCallback(async E=>d?d.type==="channel"?Wt(Number(d.id),E):Vt(d.id,E):!1,[d,Vt,Wt]),Qa=w&&!f,os=I!=null&&(I.adv_type&15)===3,is=It(os?I.public_key:null),Ya=os&&is!=="success",cs=wr(),[me,Pe]=n.useState("idle"),Xa=n.useCallback(async()=>{Pe("flood-sending");const E=await se.getState().sendFloodAdvert();Pe(E?"flood-done":"idle"),E&&setTimeout(()=>Pe(L=>L==="flood-done"?"idle":L),2e3)},[]),Ja=n.useCallback(async()=>{Pe("zero-sending");const E=await se.getState().sendZeroHopAdvert();Pe(E?"zero-done":"idle"),E&&setTimeout(()=>Pe(L=>L==="zero-done"?"idle":L),2e3)},[]),Za=e.jsxs("div",{className:"flex items-center gap-2",children:[w&&a&&e.jsxs("div",{className:"hidden sm:flex items-center gap-2",children:[e.jsxs("button",{onClick:Xa,disabled:me!=="idle"&&me!=="zero-done",className:P("inline-flex items-center gap-2 px-3.5 py-2 rounded-xl text-xs font-semibold transition-all duration-150","bg-surface depth-raised-soft hover:depth-raised active:depth-inset","disabled:opacity-50 disabled:cursor-not-allowed",me==="flood-done"?"text-sys-green":"text-fg-secondary hover:text-fg-primary"),title:"A Flood Advert will announce your presence and broadcast your node ID and name anywhere a repeater will repeat it",children:[me==="flood-sending"?e.jsx(oe,{className:"w-4 h-4 animate-spin"}):e.jsx(to,{className:"w-4 h-4"}),e.jsx("span",{children:me==="flood-done"?"Sent!":"Flood Advert"})]}),e.jsxs("button",{onClick:Ja,disabled:me!=="idle"&&me!=="flood-done",className:P("inline-flex items-center gap-2 px-3.5 py-2 rounded-xl text-xs font-semibold transition-all duration-150","bg-surface depth-raised-soft hover:depth-raised active:depth-inset","disabled:opacity-50 disabled:cursor-not-allowed",me==="zero-done"?"text-sys-green":"text-fg-secondary hover:text-fg-primary"),title:"A Local Advert, or “Zero Hop” advert will not be repeated by local repeaters, but will be heard by those within range",children:[me==="zero-sending"?e.jsx(oe,{className:"w-4 h-4 animate-spin"}):e.jsx(wa,{className:"w-4 h-4"}),e.jsx("span",{children:me==="zero-done"?"Sent!":"Local Advert"})]})]}),e.jsx("button",{onClick:()=>Nr.getState().toggleFocusMode(),className:"hidden lg:flex p-1.5 hover:bg-subtle-fill rounded transition-colors",title:cs?"Collapse view":"Expand view",children:cs?e.jsx(Jr,{className:"w-4 h-4 text-fg-muted"}):e.jsx(Zr,{className:"w-4 h-4 text-fg-muted"})})]}),en=e.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 flex-shrink-0",children:[e.jsx(ge,{children:C.length>0&&e.jsx(ue.div,{layout:!0,initial:{opacity:0,scale:.9,width:0},animate:{opacity:1,scale:1,width:"auto"},exit:{opacity:0,scale:.9,width:0},transition:de.fade,className:"flex items-center gap-1 overflow-hidden",children:C.map(E=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-sys-green/10 text-[11px] text-sys-green font-medium whitespace-nowrap",children:[e.jsx(ze,{className:"w-2.5 h-2.5"}),E.name]},E.pubHex))},"advert-notifs")}),e.jsx(ge,{children:!w&&e.jsxs(ue.span,{initial:{opacity:0,scale:.9,width:0},animate:{opacity:1,scale:1,width:"auto"},exit:{opacity:0,scale:.9,width:0},transition:de.fade,className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-sys-amber/10 text-[11px] text-sys-amber font-medium whitespace-nowrap overflow-hidden",children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5 flex-shrink-0",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-sys-amber opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5 bg-sys-amber"})]}),"Reconnecting…"]},"disconnected")}),a&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>_(!0),disabled:x,className:"data-box flex items-center gap-1 cursor-pointer hover:bg-subtle-fill-strong transition-colors disabled:opacity-50",title:p>0?`${p} contacts seeded from repeater — click to refresh`:"Seed contacts from repeater adverts",children:[x?e.jsx(oe,{className:"w-3.5 h-3.5 text-sys-blue animate-spin"}):e.jsx(io,{className:"w-3.5 h-3.5 text-sys-blue"}),p>0&&e.jsxs("span",{className:"text-sys-blue",children:["+",p]})]}),e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:`${b.length} contacts${p>0?` (${p} from repeater)`:""}`,children:[e.jsx(wt,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:b.length})]}),e.jsxs("span",{className:"data-box flex items-center gap-1.5 cursor-default",title:`${a.channels_count} channels`,children:[e.jsx(Fe,{className:"w-3.5 h-3.5 text-fg-secondary"}),e.jsx("span",{children:a.channels_count})]})]}),e.jsx(Ii,{companions:t,selected:s,onSelect:Ta}),e.jsx(H,{plain:!0,onClick:()=>u(!0),title:"Companion configuration",children:e.jsx(kr,{"data-slot":"icon"})})]});if(t.length===0&&!f)return e.jsxs(Ns,{children:[e.jsx(ks,{title:"Companion",icon:e.jsx(ye,{}),controls:e.jsxs(H,{color:"primary",outline:!0,onClick:()=>u(!0),children:[e.jsx(Ue,{"data-slot":"icon"}),"Add Companion"]})}),e.jsx(Cs,{ready:!0,children:e.jsxs("div",{className:"text-center py-16",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(ye,{className:"w-7 h-7 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted mb-1",children:"No companions configured"}),e.jsx("p",{className:"type-body-sm text-fg-muted/70 mb-4",children:"Add a companion to start messaging mesh contacts"}),e.jsxs(H,{color:"primary",outline:!0,onClick:()=>u(!0),children:[e.jsx(Ue,{"data-slot":"icon"}),"Add Companion"]})]})}),e.jsx(Ys,{open:N,onClose:()=>u(!1),onRefresh:ss})]});const ds=d?d.type==="channel"?((us=i.find(E=>String(E.index)===d.id))==null?void 0:us.name)??"Channel":((ms=b.find(E=>E.public_key===d.id))==null?void 0:ms.name)??d.id.slice(0,8):null;return e.jsxs(Ns,{children:[e.jsx(ks,{title:(o==null?void 0:o.node_name)||"Companion",icon:e.jsx(ye,{}),leading:Za,controls:en}),e.jsx(Cs,{children:e.jsxs("div",{className:"companion-layout flex gap-4",style:{height:"calc(100vh - 11rem)",minHeight:400},children:[e.jsxs("div",{ref:Qe,className:P("flex-shrink-0 flex h-full overflow-hidden radius-inner bg-surface/80 backdrop-blur-lg depth-raised",F?"":"hidden md:flex"),style:{width:ne?"var(--companion-side-micro)":"var(--companion-side)"},children:[e.jsx(Ao,{ref:Le,contacts:b,selectedConversation:d,unreadMap:rs,messages:ns,onSelect:E=>{ve(E),window.innerWidth<768&&A(!1)},onShowDetails:Ua,onShareContact:Fa,onResetPath:ft,onRemoveContact:La,onPingContact:Aa,repeaterNeighborHashes:y,repeaterSignalMap:g,isLoading:f,splitPercent:ht,onMicroChange:Pa}),e.jsx("div",{className:"group/divider flex-shrink-0 self-stretch flex items-center justify-center w-3 cursor-col-resize select-none touch-none",onPointerDown:Ia,onPointerMove:Ea,onPointerUp:qt,onPointerCancel:qt,onDoubleClick:Ma,children:e.jsx("div",{className:"w-px h-full my-2 bg-edge-subtle/50 group-hover/divider:bg-sys-blue/50 group-active/divider:bg-sys-blue transition-colors"})}),e.jsx(Ko,{ref:Ut,channels:i,selectedConversation:d,unreadMap:rs,messages:ns,onSelect:E=>{ve(E),window.innerWidth<768&&A(!1)},onAddChannel:()=>T(!0),onDeleteChannel:Ga})]}),e.jsxs(Ss,{noPadding:!0,radius:"sm",className:"flex-1 flex flex-col min-w-0 overflow-hidden relative",children:[e.jsx(ge,{children:M&&e.jsxs(ue.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:de.fade,className:"flex items-center justify-center gap-2 px-3 py-1.5 bg-sys-red/10 border-b border-sys-red/20",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-sys-red flex-shrink-0"}),e.jsx("span",{className:"text-[11px] text-sys-red font-medium truncate",children:M})]},"error-banner")}),!F&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-edge-subtle md:hidden",children:[e.jsx("button",{onClick:()=>A(!0),className:"p-1 hover:bg-subtle-fill rounded transition-colors",children:e.jsx(zl,{className:"w-4 h-4 text-fg-secondary"})}),e.jsx("span",{className:"text-sm text-fg-primary font-medium truncate flex-1",children:ds}),d&&e.jsx("button",{onClick:()=>V(!0),className:"p-1 hover:bg-subtle-fill rounded transition-colors",title:"Details",children:e.jsx(nt,{className:"w-4 h-4 text-fg-muted"})})]}),e.jsxs("div",{className:"hidden md:flex items-center justify-between px-3 py-1.5 border-b border-edge-subtle",children:[e.jsx("span",{className:"text-sm text-fg-primary font-medium truncate",children:ds??"Select a conversation"}),e.jsx(ge,{children:d&&e.jsx(ue.button,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:de.fade,onClick:()=>{window.innerWidth>=1280?K(E=>!E):V(!0)},className:"p-1 hover:bg-subtle-fill rounded transition-colors",title:D?"Hide detail panel":"Show details",children:D&&window.innerWidth>=1280?e.jsx(Ts,{className:"w-4 h-4 text-fg-muted"}):e.jsx(nt,{className:"w-4 h-4 text-fg-muted"})},"ctx-toggle")})]}),Ya&&I?e.jsx(ii,{contact:I,loginStatus:is,onLogin:gt}):e.jsxs(e.Fragment,{children:[e.jsx(ai,{messages:v,contacts:b,className:"flex-1 min-h-0",conversationKey:d?d.type==="channel"?`ch:${d.id}`:d.id:void 0,onRetry:$a,onRetryAsFlood:Da,onMentionClick:Va,historyLoading:R,historyExhausted:d?j.get(d.type==="channel"?`ch:${d.id}`:d.id)??!1:!0,onLoadOlder:d?()=>Ka(d.type==="channel"?`ch:${d.id}`:d.id):void 0,channelName:(d==null?void 0:d.type)==="channel"?(ps=i.find(E=>String(E.index)===d.id))==null?void 0:ps.name:void 0}),d&&e.jsx(ri,{onSend:Wa,disabled:!Qa,mentionNames:qa,placeholder:d.type==="channel"?`Message ${((xs=i.find(E=>String(E.index)===d.id))==null?void 0:xs.name)??"channel"}`:`Message ${((hs=b.find(E=>E.public_key===d.id))==null?void 0:hs.name)??"contact"}`})]})]}),e.jsx(ue.div,{initial:!1,animate:{width:D&&d?"var(--companion-context)":"0px",opacity:D&&d?1:0},transition:de.layoutResize,className:"hidden xl:block flex-shrink-0 overflow-hidden",style:{pointerEvents:D&&d?"auto":"none"},children:d&&e.jsxs(Ss,{neomorphic:!0,noPadding:!0,radius:"sm",className:"h-full relative",children:[e.jsx(ge,{children:D&&e.jsx(ue.button,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:de.fade,onClick:()=>K(!1),className:"absolute top-2 left-2 z-10 p-1 hover:bg-subtle-fill rounded-lg transition-colors",title:"Hide detail panel",children:e.jsx(Ts,{className:"w-4 h-4 text-fg-muted"})},"ctx-close")}),e.jsx(Ks,{contact:d.type==="contact"?I:null,channel:d.type==="channel"?i.find(E=>String(E.index)===d.id)??null:null,contacts:b,selfPubKey:(o==null?void 0:o.public_key)??null,onResetPath:ft,onRequestStatus:Qt,onRequestTelemetry:Yt,onLoginToRepeater:gt,onLogoutFromRepeater:Xt,onGetNeighbours:Jt,onTraceContactPath:Zt,onDiscoverPath:es,onExportContact:E=>{Y(E),O(!0)},onSetContactPath:as})]})})]})}),e.jsx(Ys,{open:N,onClose:()=>u(!1),onRefresh:ss}),e.jsx(Pi,{open:m,onClose:()=>_(!1),companionName:s??"companion",onImport:za}),e.jsx(Hi,{open:S,onClose:()=>{O(!1),Y(null)},contacts:b,exportPubKey:ie,onExport:Ha,onImport:Ba}),e.jsx(Li,{open:h,onClose:()=>T(!1),channels:i,onAddChannel:Oa}),e.jsxs(je,{open:ee,onClose:()=>V(!1),size:"md",children:[e.jsx(Ee,{icon:(d==null?void 0:d.type)==="channel"?e.jsx(Fe,{className:"w-5 h-5"}):I&&(I.adv_type&15)===2?e.jsx(ze,{className:"w-5 h-5"}):e.jsx(ye,{className:"w-5 h-5"}),title:(d==null?void 0:d.type)==="channel"?((fs=i.find(E=>String(E.index)===d.id))==null?void 0:fs.name)??"Channel":(I==null?void 0:I.name)||"Contact Details",onClose:()=>V(!1)}),e.jsx(we,{className:"max-h-[70vh] overflow-y-auto",children:e.jsx(Ks,{embedded:!0,contact:(d==null?void 0:d.type)==="contact"?I:null,channel:(d==null?void 0:d.type)==="channel"?i.find(E=>String(E.index)===d.id)??null:null,contacts:b,selfPubKey:(o==null?void 0:o.public_key)??null,onResetPath:ft,onRequestStatus:Qt,onRequestTelemetry:Yt,onLoginToRepeater:gt,onLogoutFromRepeater:Xt,onGetNeighbours:Jt,onTraceContactPath:Zt,onDiscoverPath:es,onExportContact:E=>{Y(E),O(!0)},onSetContactPath:as})})]})]})}export{wc as default}; diff --git a/frontend/dist/assets/CompanionEchoMap-BcAn2gmm.js b/frontend/dist/assets/CompanionEchoMap-BcAn2gmm.js new file mode 100644 index 00000000..f269d3b3 --- /dev/null +++ b/frontend/dist/assets/CompanionEchoMap-BcAn2gmm.js @@ -0,0 +1 @@ +import{r as i,c$ as K,a6 as T,Q as Y,fO as D,au as I,cB as J,g5 as Q,Z as q,O as X,j as a,c as V,V as k,cE as ee}from"./index-i0xzpXop.js";import{M as te,S as ne,L as se,a as R}from"./maplibre-gl-B20pCOz8.js";import{useSrcHashResolverMap as ae,useDiscoveredNodes as oe}from"./usePipelineStore-BqTRxIqB.js";import{M as re}from"./map-pin-off-CPSqCYZk.js";import"./node-types-rVJPSDxd.js";const le={light:"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",dark:"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json"},A=X.amber,O=q[400],U=i.memo(function({prefix:c,name:o,isLocal:f,color:n}){const[r,u]=i.useState(!1);return a.jsx("div",{onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),style:{pointerEvents:"auto"},children:a.jsxs(k,{color:n,filled:!0,className:V("type-data-xs shadow-lg border border-current/30 transition-all duration-150 cursor-default",r&&"relative z-50"),children:[f&&a.jsx(ee,{className:"w-2.5 h-2.5 mr-0.5"}),c&&a.jsx("span",{className:"font-mono",children:c}),r&&o&&a.jsx("span",{className:c?"ml-0.5 opacity-75":"",children:o})]})})});function N(p,c){return p==null||c==null?!1:p!==0||c!==0}function ie(p,c,o){var u;const f=p.toUpperCase(),n=c.find(l=>l.public_key.toUpperCase().startsWith(f));if(n&&N(n.gps_lat,n.gps_lon))return{name:n.name||null,lat:n.gps_lat,lng:n.gps_lon,hasGps:!0};if(o.neighbors){const l=Object.entries(o.neighbors).find(([t])=>t.toUpperCase().startsWith(f));if(l){const[,t]=l;if(N(t.latitude,t.longitude))return{name:t.node_name||t.name||null,lat:t.latitude,lng:t.longitude,hasGps:!0}}}const r=o.srcHashMap.get(f);if(r){const l=o.discoveredNodes.get(r);if(l&&N(l.latitude,l.longitude))return{name:l.name||null,lat:l.latitude,lng:l.longitude,hasGps:!0};if(o.neighbors){const t=o.neighbors[r];if(t&&N(t.latitude,t.longitude))return{name:t.node_name||t.name||null,lat:t.latitude,lng:t.longitude,hasGps:!0}}}return{name:(n==null?void 0:n.name)||(r?((u=o.discoveredNodes.get(r))==null?void 0:u.name)??null:null),lat:0,lng:0,hasGps:!1}}function ce(p,c,o,f){const n=Math.floor(c/30);for(const r of[n-1,n,n+1])for(const[u,l]of o){const t=l.decoded;if(!(t!=null&&t.decrypted)||t.senderName!==f)continue;const v=t.timestamp??l.timestamp;if(Math.floor(v/30)===r&&t.text===p)return u}return null}function ue(p,c){const o=new Set,f=[];for(const n of c){if(n.packet_hash!==p||n.packet_origin==="tx_local")continue;const r=n.original_path??n.forwarded_path;if(!r||r.length===0)continue;const u=r[r.length-1].toUpperCase();o.has(u)||(o.add(u),f.push({prefix:u,snr:n.snr}))}return f}function he({text:p,timestamp:c,contacts:o,className:f}){const n=i.useRef(null),r=K(),u=T(),l=Y(),[t,v]=i.useState(!1),m=D(),C=I(),z=u==null?void 0:u.neighbors,E=ae(),B=oe(),M=J(),g=Q(),w=(m==null?void 0:m.node_name)??(g==null?void 0:g.node_name)??null,F=i.useMemo(()=>({neighbors:z,srcHashMap:E,discoveredNodes:B}),[z,E,B]),d=i.useMemo(()=>{const e=(m==null?void 0:m.node_name)||(g==null?void 0:g.node_name)||(g==null?void 0:g.companion_name)||"Me";return m&&N(m.latitude,m.longitude)?{prefix:m.public_key.slice(0,2).toUpperCase(),name:e,lat:m.latitude,lng:m.longitude}:M&&N(M.latitude,M.longitude)?{prefix:"",name:e,lat:M.latitude,lng:M.longitude}:null},[m,g,M]),L=i.useMemo(()=>w?ce(p,c,C,w):null,[p,c,C,w]),G=i.useMemo(()=>L?ue(L,l):[],[L,l]),j=i.useMemo(()=>G.map(e=>{const s=ie(e.prefix,o,F);return{prefix:e.prefix,snr:e.snr,...s}}),[G,o,F]),y=i.useMemo(()=>j.filter(e=>e.hasGps),[j]),$=i.useMemo(()=>j.filter(e=>!e.hasGps),[j]),_=i.useMemo(()=>{if(!d||y.length===0)return[];const e=[d.lng,d.lat];return y.map(s=>{const h=[s.lng,s.lat];return{from:e,to:h,midpoint:[(e[0]+h[0])/2,(e[1]+h[1])/2]}})},[d,y]),W=i.useMemo(()=>_.map(e=>({type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[e.from,e.to]}}]})),[_]),H=i.useMemo(()=>{if(typeof document>"u")return{amber:A,zinc:O};const e=getComputedStyle(document.documentElement),s=e.getPropertyValue("--sys-amber").trim(),h=e.getPropertyValue("--zinc-400").trim();return{amber:s.startsWith("#")?s:A,zinc:h.startsWith("#")?h:O}},[]),x=i.useMemo(()=>{if(!d||y.length===0)return null;let e=d.lat,s=d.lat,h=d.lng,S=d.lng;for(const b of y)b.lats&&(s=b.lat),b.lngS&&(S=b.lng);return[[h,e],[S,s]]},[d,y]),Z=i.useCallback(()=>{var s;const e=(s=n.current)==null?void 0:s.getMap();e&&x&&e.fitBounds(x,{padding:{top:40,bottom:44,left:56,right:56},maxZoom:14,duration:0}),v(!0)},[x]);if(!x||!d)return null;const P=[(x[0][0]+x[1][0])/2,(x[0][1]+x[1][1])/2];return a.jsxs("div",{className:V("relative rounded-lg overflow-hidden",f),style:{aspectRatio:"16 / 10"},children:[!t&&a.jsx("div",{className:"absolute inset-0 bg-subtle-fill flex items-center justify-center pointer-events-none z-10",children:a.jsx("div",{className:"w-4 h-4 border-2 border-fg-muted/30 border-t-fg-muted rounded-full animate-spin"})}),a.jsx("div",{className:"h-full w-full transition-opacity duration-200",style:{opacity:t?1:0},children:a.jsxs(te,{ref:n,initialViewState:{longitude:P[0],latitude:P[1],zoom:10},onLoad:Z,style:{height:"100%",width:"100%"},mapStyle:le[r],attributionControl:!1,interactive:!1,children:[_.map((e,s)=>a.jsx(ne,{id:`cecho-${s}`,type:"geojson",data:W[s],lineMetrics:!0,children:a.jsx(se,{id:`cecho-line-${s}`,type:"line",paint:{"line-width":2,"line-gradient":["interpolate",["linear"],["line-progress"],0,H.amber,1,H.zinc]},layout:{"line-cap":"round","line-join":"round"}})},`cecho-${s}`)),a.jsx(R,{longitude:d.lng,latitude:d.lat,anchor:"center",children:a.jsx(U,{prefix:d.prefix,name:d.name,isLocal:!0,color:"amber"})}),y.map((e,s)=>a.jsx(R,{longitude:e.lng,latitude:e.lat,anchor:"center",children:a.jsx(U,{prefix:e.prefix,name:e.name,isLocal:!1,color:"zinc"})},`cecho-node-${e.prefix}-${s}`))]})}),$.length>0&&a.jsx("div",{className:"absolute bottom-1.5 left-1.5 z-10 flex items-center gap-1 flex-wrap max-w-[60%]",children:$.map((e,s)=>a.jsxs(k,{color:"zinc",className:"type-data-xs shadow-sm opacity-70",children:[a.jsx(re,{className:"w-2 h-2 mr-0.5"}),e.prefix,e.name&&a.jsx("span",{className:"ml-0.5 opacity-60",children:e.name})]},`cecho-unmap-${e.prefix}-${s}`))}),a.jsx("div",{className:"absolute bottom-1.5 right-1.5 z-10",children:a.jsxs(k,{color:"green",className:"type-data-xs shadow-sm",children:[j.length," echo",j.length!==1?"es":""]})})]})}export{he as CompanionEchoMap}; diff --git a/frontend/dist/assets/CompanionPathMap-D5FruuYA.js b/frontend/dist/assets/CompanionPathMap-D5FruuYA.js new file mode 100644 index 00000000..c5b1cc3e --- /dev/null +++ b/frontend/dist/assets/CompanionPathMap-D5FruuYA.js @@ -0,0 +1 @@ +import{r,c$ as X,a6 as I,cB as ee,g5 as te,Z,O as J,j as n,c as K,V as H,cE as ne}from"./index-i0xzpXop.js";import{M as se,S as C,L as U,a as G}from"./maplibre-gl-B20pCOz8.js";import{useSrcHashResolverMap as oe,useDiscoveredNodes as ae}from"./usePipelineStore-BqTRxIqB.js";import{C as le}from"./car-aFMoKQAR.js";import{M as ie}from"./map-pin-off-CPSqCYZk.js";import"./node-types-rVJPSDxd.js";const re={light:"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",dark:"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json"},ce=Z[500],D=J.orange,T=J.green,ue=r.memo(function({prefix:a,name:o,isLocal:u,color:s}){const[m,b]=r.useState(!1);return n.jsx("div",{onMouseEnter:()=>b(!0),onMouseLeave:()=>b(!1),style:{pointerEvents:"auto"},children:n.jsxs(H,{color:s,filled:!0,className:K("type-data-xs shadow-lg border border-current/30 transition-all duration-150 cursor-default",m&&"relative z-50"),children:[u&&n.jsx(ne,{className:"w-2.5 h-2.5 mr-0.5"}),a&&n.jsx("span",{className:"font-mono",children:a}),m&&o&&n.jsx("span",{className:a?"ml-0.5 opacity-75":"",children:o})]})})});function L(d,a){return d==null||a==null?!1:d!==0||a!==0}function de(d,a,o){var s;const u=[];for(const m of d){const b=m.toUpperCase(),p=a.find(c=>c.public_key.toUpperCase().startsWith(b));if(p&&L(p.gps_lat,p.gps_lon)){u.push({prefix:m,name:p.name||null,lat:p.gps_lat,lng:p.gps_lon,isLocal:!1,hasGps:!0});continue}if(o.neighbors){const c=Object.entries(o.neighbors).find(([i])=>i.toUpperCase().startsWith(b));if(c){const[,i]=c;if(L(i.latitude,i.longitude)){u.push({prefix:m,name:i.node_name||i.name||null,lat:i.latitude,lng:i.longitude,isLocal:!1,hasGps:!0});continue}}}const N=o.srcHashMap.get(b);if(N){const c=o.discoveredNodes.get(N);if(c&&L(c.latitude,c.longitude)){u.push({prefix:m,name:c.name||null,lat:c.latitude,lng:c.longitude,isLocal:!1,hasGps:!0});continue}if(o.neighbors){const i=o.neighbors[N];if(i&&L(i.latitude,i.longitude)){u.push({prefix:m,name:i.node_name||i.name||null,lat:i.latitude,lng:i.longitude,isLocal:!1,hasGps:!0});continue}}}u.push({prefix:m,name:(p==null?void 0:p.name)||(N?((s=o.discoveredNodes.get(N))==null?void 0:s.name)??null:null),lat:0,lng:0,isLocal:!1,hasGps:!1})}return u}function me(d,a,o,u){const s=(a==null?void 0:a.node_name)||u||(o==null?void 0:o.name)||"Me";if(a&&L(a.latitude,a.longitude)){const m=a.public_key.slice(0,2).toUpperCase();return[...d,{prefix:m,name:s,lat:a.latitude,lng:a.longitude,isLocal:!0,hasGps:!0}]}return o&&L(o.latitude,o.longitude)?[...d,{prefix:"",name:s,lat:o.latitude,lng:o.longitude,isLocal:!0,hasGps:!0}]:d}function be({hops:d,contacts:a,selfInfo:o,snr:u,wardriveCoords:s,wardriveSenderName:m,className:b}){const p=r.useRef(null),N=X(),c=I(),[i,Y]=r.useState(!1),w=c==null?void 0:c.neighbors,z=oe(),R=ae(),B=ee(),M=te(),$=r.useMemo(()=>({neighbors:w,srcHashMap:z,discoveredNodes:R}),[w,z,R]),k=(M==null?void 0:M.node_name)??(M==null?void 0:M.companion_name)??null,h=r.useMemo(()=>{const e=de(d,a,$);return me(e,o,B,k)},[d,a,$,o,B,k]),g=r.useMemo(()=>h.filter(e=>e.hasGps),[h]),F=r.useMemo(()=>h.filter(e=>!e.hasGps),[h]),S=r.useMemo(()=>{const e=[];if(g.length<2)return e;const t=[];for(let l=0;lS.map(e=>({type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[e.from,e.to]}}]})),[S]),O=r.useMemo(()=>{if(typeof document>"u")return ce;const e=getComputedStyle(document.documentElement).getPropertyValue("--zinc-400").trim();return e.startsWith("#")?e:Z[400]},[]),v=r.useMemo(()=>{if(!s||g.length===0)return null;const e=[s.lon,s.lat],t=g[0];return{from:e,to:[t.lng,t.lat]}},[s,g]),P=r.useMemo(()=>v?{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:[v.from,v.to]}}]}:null,[v]),A=r.useMemo(()=>{if(typeof document>"u")return{orange:D,green:T};const e=getComputedStyle(document.documentElement),t=e.getPropertyValue("--sys-orange").trim(),l=e.getPropertyValue("--sys-green").trim();return{orange:t.startsWith("#")?t:D,green:l.startsWith("#")?l:T}},[]),j=r.useMemo(()=>{if(g.length<2&&!s||g.length+(s?1:0)<2)return null;let t=1/0,l=-1/0,x=1/0,y=-1/0;for(const f of g)f.latl&&(l=f.lat),f.lngy&&(y=f.lng);return s&&(s.latl&&(l=s.lat),s.lony&&(y=s.lon)),[[x,t],[y,l]]},[g,s]),Q=r.useCallback(()=>{var t;const e=(t=p.current)==null?void 0:t.getMap();e&&j&&e.fitBounds(j,{padding:{top:40,bottom:44,left:56,right:56},maxZoom:14,duration:0}),Y(!0)},[j]);if(!j)return null;const W=[(j[0][0]+j[1][0])/2,(j[0][1]+j[1][1])/2];return n.jsxs("div",{className:K("relative rounded-lg overflow-hidden",b),style:{aspectRatio:"16 / 10"},children:[!i&&n.jsx("div",{className:"absolute inset-0 bg-subtle-fill flex items-center justify-center pointer-events-none z-10",children:n.jsx("div",{className:"w-4 h-4 border-2 border-fg-muted/30 border-t-fg-muted rounded-full animate-spin"})}),n.jsx("div",{className:"h-full w-full transition-opacity duration-200",style:{opacity:i?1:0},children:n.jsxs(se,{ref:p,initialViewState:{longitude:W[0],latitude:W[1],zoom:10},onLoad:Q,style:{height:"100%",width:"100%"},mapStyle:re[N],attributionControl:!1,interactive:!1,children:[P&&n.jsx(C,{id:"cwd-edge",type:"geojson",data:P,lineMetrics:!0,children:n.jsx(U,{id:"cwd-edge-line",type:"line",paint:{"line-width":2,"line-gradient":["interpolate",["linear"],["line-progress"],0,A.orange,1,A.green]},layout:{"line-cap":"round","line-join":"round"}})}),s&&n.jsx(G,{longitude:s.lon,latitude:s.lat,anchor:"center",children:n.jsx("div",{className:"flex items-center",style:{pointerEvents:"auto"},children:n.jsx("div",{className:"flex items-center justify-center w-7 h-7 rounded-full bg-sys-orange text-white shadow-lg border-2 border-sys-orange/50",children:n.jsx(le,{className:"w-4 h-4",strokeWidth:2.5})})})}),S.map((e,t)=>n.jsx(C,{id:`cedge-${t}`,type:"geojson",data:q[t],children:n.jsx(U,{id:`cedge-line-${t}`,type:"line",paint:{"line-color":O,"line-width":2,"line-opacity":.85},layout:{"line-cap":"round","line-join":"round"}})},`cedge-${t}`)),S.map((e,t)=>n.jsx(G,{longitude:e.midpoint[0],latitude:e.midpoint[1],anchor:"center",children:n.jsx("span",{className:"w-4.5 h-4.5 rounded-full flex items-center justify-center font-mono font-extrabold tabular-nums shadow-md pointer-events-none",style:{backgroundColor:O,color:"#fff",fontSize:"10px",lineHeight:1,textShadow:"0 1px 1px rgba(0,0,0,0.4)"},children:e.hopNumber})},`chop-${t}`)),g.map((e,t)=>{const l=t===0,x=t===g.length-1,y=e.isLocal?"amber":l?"green":x?"amber":"zinc";return n.jsx(G,{longitude:e.lng,latitude:e.lat,anchor:"center",children:n.jsx(ue,{prefix:e.prefix,name:e.name,isLocal:e.isLocal,color:y})},`cnode-${e.prefix}-${t}`)})]})}),F.length>0&&n.jsx("div",{className:"absolute bottom-1.5 left-1.5 z-10 flex items-center gap-1 flex-wrap max-w-[60%]",children:F.map((e,t)=>n.jsxs(H,{color:"zinc",className:"type-data-xs shadow-sm opacity-70",children:[n.jsx(ie,{className:"w-2 h-2 mr-0.5"}),e.prefix,e.name&&n.jsx("span",{className:"ml-0.5 opacity-60",children:e.name})]},`cunmap-${e.prefix}-${t}`))}),u!=null&&n.jsx("div",{className:"absolute bottom-1.5 right-1.5 z-10",children:n.jsxs(H,{color:"zinc",className:"type-data-xs shadow-sm",children:[u>0?"+":"",u.toFixed(1)," dB"]})})]})}export{be as CompanionPathMap}; diff --git a/frontend/dist/assets/Configuration-C6MYk4Vr.js b/frontend/dist/assets/Configuration-C6MYk4Vr.js new file mode 100644 index 00000000..8fb70dbd --- /dev/null +++ b/frontend/dist/assets/Configuration-C6MYk4Vr.js @@ -0,0 +1,27 @@ +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{e as ke,r as a,j as e,c as m,ev as Is,cT as oe,a2 as U,a0 as J,bM as Z,aE as Ke,ew as ze,ex as os,ey as as,_ as De,a8 as xe,E as jt,S as vt,ez as Nt,a7 as X,cu as cs,eA as wt,B as L,V as ns,eB as Ks,bY as Le,X as Ws,eC as kt,a6 as _t,dK as Os,c3 as St,c7 as ls,dV as Xs,eD as Ct,eE as zs,eF as Tt,eG as Ft,eH as Et,aa as Rt,eI as Je,I as Mt,a1 as Dt,a3 as At}from"./index-i0xzpXop.js";import{g as Pt,a as Lt,c as It,r as Kt,s as Ot,b as zt,u as Vt,d as $t}from"./system-Xia4FpjC.js";import{C as Ht}from"./ConfirmModal-CtS0orbM.js";import{S as qt,A as Bt,a as Gt,N as Ut}from"./AutoConfigureDialog-C9ytM4jL.js";import{W as rs}from"./wand-sparkles-DBzA3PXL.js";import{P as is,F as Vs}from"./pencil-8q_J08l4.js";import{i as Wt,g as Xt,s as Yt,a as Jt,k as Qt}from"./keycap-sfx-ByZp-njj.js";import{C as Y,P as Zt,a as ea,B as sa}from"./PageLayout-B4RCJ-XT.js";import{T as Ys}from"./trash-2-DCqpUdF7.js";import{R as ta}from"./rotate-ccw-DqV8JyUZ.js";import{S as aa}from"./shield-CxmFjMfw.js";import{R as na}from"./repeat-BSIxXQ81.js";import{G as la}from"./git-branch-DrsZ9sUq.js";import{C as ra}from"./clock-F-4SScS_.js";import{C as Js}from"./chevron-right-DsOuIRi8.js";import{R as se,C as me}from"./Grid-BhoD4aLU.js";import{A as ia}from"./antenna-C7FNplvf.js";import{P as $s}from"./plus-Bb8eT78f.js";import{K as Hs}from"./key-round-BpDWKeL5.js";import"./arrow-right-BZS-u7CW.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 oa=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Qs=ke("external-link",oa);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ca=[["circle",{cx:"16",cy:"20",r:"2",key:"1vifvg"}],["path",{d:"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2",key:"3hgo9p"}],["path",{d:"m22 14-4.5 4.5",key:"1ef6z8"}],["path",{d:"m21 15 1 1",key:"1ejcpy"}]],da=ke("folder-key",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 ua=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],ma=ke("git-commit-horizontal",ua);/** + * @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 fa=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],xa=ke("monitor",fa);/** + * @license lucide-react v0.559.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ha=[["path",{d:"M10.17 4.193a2 2 0 0 1 3.666.013",key:"pltmmw"}],["path",{d:"M14 21h2",key:"v4qezv"}],["path",{d:"m15.874 7.743 1 1.732",key:"10m0iw"}],["path",{d:"m18.849 12.952 1 1.732",key:"zadnam"}],["path",{d:"M21.824 18.18a2 2 0 0 1-1.835 2.824",key:"fvwuk4"}],["path",{d:"M4.024 21a2 2 0 0 1-1.839-2.839",key:"1e1kah"}],["path",{d:"m5.136 12.952-1 1.732",key:"1u4ldi"}],["path",{d:"M8 21h2",key:"i9zjee"}],["path",{d:"m8.102 7.743-1 1.732",key:"1zzo4u"}]],pa=ke("triangle-dashed",ha),Oe=1500,he={stacked:"h-[38px]",inline:"h-[32px]"},pe={stacked:"px-3",inline:"px-2.5"},ye="rounded-lg";function P({label:t,value:l,editValue:n,onSave:c,type:i="text",suffix:o,placeholder:j,readOnly:p=!1,layout:y="stacked",min:u,max:r,step:h,maxLength:F,description:b,tooltip:E,autoConfigured:k,className:N}){const[x,g]=a.useState(!1),[v,R]=a.useState(""),[M,w]=a.useState("idle"),_=a.useRef(null),C=a.useRef(!0),f=a.useRef(null),A=!p&&!!c;a.useEffect(()=>(C.current=!0,()=>{C.current=!1,f.current&&clearTimeout(f.current)}),[]);const S=a.useCallback(()=>{A&&(R(n??l),g(!0),w("idle"),requestAnimationFrame(()=>{var K;return(K=_.current)==null?void 0:K.select()}))},[A,n,l]),I=a.useCallback(()=>{g(!1),R(""),w("idle")},[]),V=a.useCallback(async()=>{if(!c||M==="loading")return;if(v===(n??l)){I();return}f.current&&clearTimeout(f.current),w("loading");try{if(await c(v),!C.current)return;w("success"),g(!1),f.current=setTimeout(()=>{C.current&&w("idle")},Oe)}catch{if(!C.current)return;w("error"),f.current=setTimeout(()=>{C.current&&w("idle")},Oe)}},[c,v,n,l,I,M]),H=a.useCallback(K=>{K.key==="Enter"?(K.preventDefault(),V()):K.key==="Escape"&&(K.preventDefault(),I())},[V,I]);return y==="inline"?e.jsxs("div",{className:m("group flex items-center justify-between gap-3",N),children:[e.jsxs("div",{className:"flex items-center gap-1 truncate",children:[e.jsx("label",{className:"type-label text-fg-muted truncate",children:t}),E&&e.jsx(Is,{content:E,placement:"top",children:e.jsx("span",{className:"text-fg-muted/50 hover:text-fg-muted cursor-help transition-colors flex-shrink-0",children:e.jsx(oe,{className:"w-3 h-3"})})})]}),x?e.jsxs("div",{className:m(he.inline,ye,pe.inline,"flex items-center transition-all","bg-transparent border border-sys-blue/50 ring-1 ring-sys-blue/20","min-w-[100px]"),children:[e.jsx("input",{ref:_,type:i,value:v,onChange:K=>R(K.target.value),onKeyDown:H,placeholder:j,min:u,max:r,step:h,maxLength:F,disabled:M==="loading",className:m("bg-transparent text-fg-primary focus:outline-none type-data flex-1 min-w-0",o?"w-12 text-right":"w-full")}),o&&e.jsx("span",{className:"text-fg-muted type-data ml-1 shrink-0",children:o}),e.jsx("div",{className:"flex items-center gap-0.5 ml-2 shrink-0",children:M==="loading"?e.jsx(U,{className:"w-3.5 h-3.5 text-fg-muted animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:V,className:"p-0.5 rounded hover:bg-sys-green/15 text-sys-green transition-colors",title:"Save (Enter)",children:e.jsx(J,{className:"w-3 h-3"})}),e.jsx("button",{onClick:I,className:"p-0.5 rounded hover:bg-sys-red/15 text-fg-muted hover:text-sys-red transition-colors",title:"Cancel (Esc)",children:e.jsx(Z,{className:"w-3 h-3"})})]})})]}):e.jsxs("div",{className:m(he.inline,ye,pe.inline,"flex items-center justify-end transition-all min-w-[80px]","bg-input-bg border border-input-border",A&&"cursor-pointer hover:border-edge-strong"),onClick:A?S:void 0,children:[e.jsx("span",{className:"type-data text-fg-primary",children:l}),M==="success"&&e.jsx(J,{className:"w-3 h-3 text-sys-green ml-1.5 shrink-0"}),M==="error"&&e.jsx(Z,{className:"w-3 h-3 text-sys-red ml-1.5 shrink-0"}),M==="idle"&&k&&e.jsx(rs,{className:"w-3 h-3 text-sys-blue ml-1.5 shrink-0"}),M==="idle"&&!k&&A&&e.jsx(is,{className:"w-3 h-3 text-fg-muted ml-1.5 opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]})]}):e.jsxs("div",{className:m("group",N),children:[e.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[e.jsx("label",{className:"type-label text-fg-muted",children:t}),E&&e.jsx(Is,{content:E,placement:"top",children:e.jsx("span",{className:"text-fg-muted/50 hover:text-fg-muted cursor-help transition-colors flex-shrink-0",children:e.jsx(oe,{className:"w-3 h-3"})})})]}),x?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:m(he.stacked,ye,pe.stacked,"flex items-center transition-all","bg-transparent border border-sys-blue/50 ring-1 ring-sys-blue/20"),children:[e.jsx("input",{ref:_,type:i,value:v,onChange:K=>R(K.target.value),onKeyDown:H,placeholder:j,min:u,max:r,step:h,maxLength:F,disabled:M==="loading",className:"w-full bg-transparent text-fg-primary focus:outline-none type-data flex-1 min-w-0"}),o&&e.jsx("span",{className:"text-fg-muted type-data ml-1 shrink-0",children:o}),e.jsx("div",{className:"flex items-center gap-0.5 ml-2 shrink-0",children:M==="loading"?e.jsx(U,{className:"w-3.5 h-3.5 text-fg-muted animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:V,className:"p-1 rounded hover:bg-sys-green/15 text-sys-green transition-colors",title:"Save (Enter)",children:e.jsx(J,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:I,className:"p-1 rounded hover:bg-sys-red/15 text-fg-muted hover:text-sys-red transition-colors",title:"Cancel (Esc)",children:e.jsx(Z,{className:"w-3.5 h-3.5"})})]})})]}),b&&e.jsx("p",{className:"type-data-xs text-fg-muted mt-1 ml-3",children:b})]}):e.jsxs("div",{className:m(he.stacked,ye,pe.stacked,"flex items-center transition-all","bg-input-bg border border-input-border",A&&"cursor-pointer hover:border-edge-strong"),onClick:A?S:void 0,children:[e.jsx("span",{className:"type-data text-fg-primary flex-1 whitespace-nowrap",children:l}),M==="success"&&e.jsx(J,{className:"w-3.5 h-3.5 text-sys-green shrink-0"}),M==="error"&&e.jsx(Z,{className:"w-3.5 h-3.5 text-sys-red shrink-0"}),M==="idle"&&k&&e.jsx(rs,{className:"w-3.5 h-3.5 text-sys-blue shrink-0"}),M==="idle"&&!k&&A&&e.jsx(is,{className:"w-3.5 h-3.5 text-fg-muted opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]})]})}function Ae({label:t,value:l,editValue:n,options:c,onSave:i,readOnly:o=!1,layout:j="stacked",className:p}){const[y,u]=a.useState(!1),[r,h]=a.useState(""),[F,b]=a.useState("idle"),E=a.useRef(null),k=a.useRef(!0),N=a.useRef(null),x=!o&&!!i;a.useEffect(()=>(k.current=!0,()=>{k.current=!1,N.current&&clearTimeout(N.current)}),[]);const g=a.useCallback(()=>{x&&(h(String(n)),u(!0),b("idle"),requestAnimationFrame(()=>{var S;return(S=E.current)==null?void 0:S.focus()}))},[x,n]),v=a.useCallback(()=>{u(!1),h(""),b("idle")},[]),R=a.useCallback(async()=>{if(!(!i||F==="loading")){if(r===String(n)){v();return}N.current&&clearTimeout(N.current),b("loading");try{if(await i(r),!k.current)return;b("success"),u(!1),N.current=setTimeout(()=>{k.current&&b("idle")},Oe)}catch{if(!k.current)return;b("error"),N.current=setTimeout(()=>{k.current&&b("idle")},Oe)}}},[i,r,n,v,F]),M=a.useCallback(S=>{S.key==="Escape"&&(S.preventDefault(),v())},[v]),w=j==="inline",_=w?he.inline:he.stacked,C=w?pe.inline:pe.stacked,f=e.jsxs("div",{className:m(_,ye,C,"flex items-center transition-all relative","bg-transparent border border-sys-blue/50 ring-1 ring-sys-blue/20",w&&"min-w-[100px]"),children:[e.jsx("select",{ref:E,value:r,onChange:S=>h(S.target.value),onKeyDown:M,disabled:F==="loading",className:m("bg-transparent text-fg-primary focus:outline-none appearance-none cursor-pointer type-data flex-1 min-w-0","pr-6"),children:c.map(S=>e.jsx("option",{value:S.value,children:S.label},String(S.value)))}),e.jsx(Ke,{className:"absolute right-auto w-3.5 h-3.5 text-fg-muted pointer-events-none",style:{right:F==="loading"?"2rem":"3.5rem"}}),e.jsx("div",{className:"flex items-center gap-0.5 ml-1 shrink-0",children:F==="loading"?e.jsx(U,{className:m("text-fg-muted animate-spin",w?"w-3 h-3":"w-3.5 h-3.5")}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:R,className:m("rounded hover:bg-sys-green/15 text-sys-green transition-colors",w?"p-0.5":"p-1"),title:"Save",children:e.jsx(J,{className:w?"w-3 h-3":"w-3.5 h-3.5"})}),e.jsx("button",{onClick:v,className:m("rounded hover:bg-sys-red/15 text-fg-muted hover:text-sys-red transition-colors",w?"p-0.5":"p-1"),title:"Cancel (Esc)",children:e.jsx(Z,{className:w?"w-3 h-3":"w-3.5 h-3.5"})})]})})]}),A=e.jsxs("div",{className:m(_,ye,C,"flex items-center transition-all","bg-input-bg border border-input-border",x&&"cursor-pointer hover:border-edge-strong",w?"justify-end min-w-[80px]":""),onClick:x?g:void 0,children:[e.jsx("span",{className:m("type-data text-fg-primary",!w&&"flex-1"),children:l}),F==="success"&&e.jsx(J,{className:m("text-sys-green shrink-0",w?"w-3 h-3 ml-1.5":"w-3.5 h-3.5")}),F==="error"&&e.jsx(Z,{className:m("text-sys-red shrink-0",w?"w-3 h-3 ml-1.5":"w-3.5 h-3.5")}),F==="idle"&&x&&e.jsx(Ke,{className:m("text-fg-muted opacity-0 group-hover:opacity-100 transition-opacity shrink-0",w?"w-3 h-3 ml-1.5":"w-3.5 h-3.5")})]});return w?e.jsxs("div",{className:m("group flex items-center justify-between",p),children:[e.jsx("label",{className:"type-label text-fg-muted shrink-0",children:t}),y?f:A]}):e.jsxs("div",{className:m("group",p),children:[e.jsx("label",{className:"type-label text-fg-muted block mb-1",children:t}),y?f:A]})}async function ya(){try{return await ze("/api/auth/tokens")}catch{return{tokens:[]}}}async function ga(t){return ze("/api/auth/tokens",{method:"POST",body:JSON.stringify({name:t})})}async function ba(t){return ze(`/api/auth/tokens/${t}`,{method:"DELETE"})}async function qs(t){return ze("/api/update_web_config",{method:"POST",body:JSON.stringify(t)})}a.memo(function(){const{theme:l}=os(),{themeId:n}=l,c=as.find(i=>i.meta.id===n)??as[0];return e.jsx("div",{className:"h-10 flex items-center justify-center",children:e.jsx("span",{className:"font-medium transition-all duration-300 leading-none text-center text-fg-secondary",style:{fontFamily:"Inter, system-ui, sans-serif",fontSize:"clamp(0.75rem, 0.6rem + 1.5vw, 1.1rem)",letterSpacing:"-0.02em"},children:c.meta.name})})});const Qe=a.memo(function({compact:l=!1}){const{theme:n,setTheme:c}=os(),{themeId:i}=n;return e.jsx("div",{className:m("grid grid-cols-2 gap-2",l?"w-full min-w-0 self-stretch":"w-full"),children:[...as].reverse().map(o=>{const j=i===o.meta.id,p=o.meta.isDark;return e.jsxs("button",{type:"button",title:o.meta.name,className:m("flex flex-row items-stretch radius-inner transition-all duration-200 ease-out overflow-hidden cursor-pointer",l&&"h-6",j?"ring-2 ring-sys-blue scale-[1.02]":"opacity-70 hover:opacity-100"),onClick:()=>c(o.meta.id),children:[e.jsx("div",{className:m("flex-1 h-full",p?"bg-[#18181b]":"bg-[#EFF0F1]")}),e.jsx("div",{className:"flex flex-col h-full",children:o.display.palette.map((y,u)=>e.jsx("div",{className:"flex flex-1",children:y.map((r,h)=>e.jsx("div",{className:"w-2 h-full",style:{backgroundColor:r}},h))},u))})]},o.meta.id)})})});let Bs=!1,Pe=null;async function ja(){if(!Bs)return Pe||(Pe=(async()=>{try{await Promise.all([De(()=>Promise.resolve({}),__vite__mapDeps([0])),De(()=>Promise.resolve({}),__vite__mapDeps([1])),De(()=>Promise.resolve({}),__vite__mapDeps([2])),De(()=>Promise.resolve({}),__vite__mapDeps([3]))]),Bs=!0}catch(t){console.warn("Failed to load theme fonts:",t)}})(),Pe)}const Ze=a.memo(function(){const{theme:l,setTheme:n}=os(),{themeId:c}=l,i=c==="breeze dark",o=a.useCallback(j=>{n(j?"breeze dark":"breeze light")},[n]);return e.jsx(xe,{enabled:i,onChange:o,label:e.jsxs(e.Fragment,{children:["Dark Mode: ",i?e.jsx(jt,{className:"w-3.5 h-3.5 text-sys-blue inline"}):e.jsx(vt,{className:"w-3.5 h-3.5 text-[#e8a517] inline"})]}),tooltip:"Switch between dark and light mode",size:"md"})}),va=a.memo(function({layout:l="horizontal"}){return a.useEffect(()=>{ja()},[]),l==="toggle-only"?e.jsx(Ze,{}):l==="thumbnails-only"?e.jsx(Qe,{}):l==="vertical"?e.jsxs("div",{className:"flex flex-col items-start gap-3",children:[e.jsx(Ze,{}),e.jsx(Qe,{})]}):e.jsxs("div",{className:"flex items-stretch gap-4",children:[e.jsx("div",{className:"flex-shrink-0 flex items-start",children:e.jsx(Ze,{})}),e.jsx(Qe,{compact:!0})]})}),Na=1e4,es=2e3;function ss(t,l,n){const[c,i]=a.useState("idle"),[o,j]=a.useState(null),p=a.useRef(!0),y=a.useRef(null),u=a.useRef(null),r=a.useRef(!1),h=a.useRef("idle"),F=a.useRef(t),b=a.useRef(l),E=a.useRef(n);h.current=c,F.current=t,b.current=l,E.current=n,a.useEffect(()=>(p.current=!0,()=>{p.current=!1,y.current&&clearTimeout(y.current),u.current&&clearTimeout(u.current)}),[]);const k=a.useCallback(async x=>{if(h.current==="loading")return;const g=F.current;y.current&&clearTimeout(y.current),u.current&&clearTimeout(u.current),r.current=!1,j(x),i("loading"),y.current=setTimeout(()=>{r.current||!p.current||(j(g),i("error"),u.current=setTimeout(()=>{p.current&&(i("idle"),j(null))},es))},Na);try{if(await b.current(x),r.current=!0,y.current&&clearTimeout(y.current),!p.current)return;i("success"),u.current=setTimeout(()=>{var v;p.current&&(i("idle"),j(null),(v=E.current)==null||v.call(E))},es)}catch{if(r.current=!0,y.current&&clearTimeout(y.current),!p.current)return;j(g),i("error"),u.current=setTimeout(()=>{p.current&&(i("idle"),j(null))},es)}},[]);return{enabled:o!==null?o:t,status:c,toggle:k}}function wa(){const{latitude:t,longitude:l,enabled:n,setLocation:c,enable:i,disable:o,clear:j}=Nt(),[p,y]=a.useState(!1),[u,r]=a.useState(""),[h,F]=a.useState(""),[b,E]=a.useState("idle"),[k,N]=a.useState(null),x=a.useRef(null),g=a.useRef(null),v=a.useRef(!0);a.useEffect(()=>(v.current=!0,()=>{v.current=!1,g.current&&clearTimeout(g.current)}),[]);const R=()=>{r((t==null?void 0:t.toFixed(6))??""),F((l==null?void 0:l.toFixed(6))??""),N(null),y(!0)},M=()=>{y(!1),N(null)};a.useEffect(()=>{if(!p)return;const S=I=>{b!=="loading"&&x.current&&!x.current.contains(I.target)&&M()};return document.addEventListener("mouseup",S),()=>document.removeEventListener("mouseup",S)},[p,b]);const w=(S,I)=>{const V=parseFloat(S),H=parseFloat(I);return isNaN(V)||isNaN(H)?"Please enter valid numbers":V<-90||V>90?"Latitude must be between -90 and 90":H<-180||H>180?"Longitude must be between -180 and 180":V===0&&H===0?"Coordinates (0, 0) are invalid":null},_=()=>{if(b==="loading")return;g.current&&clearTimeout(g.current);const S=w(u,h);if(S){N(S);return}E("loading"),N(null);const I=parseFloat(u),V=parseFloat(h);c(I,V),n||i(),E("success"),g.current=setTimeout(()=>{v.current&&(E("idle"),y(!1))},1e3)},C=()=>{n?o():i()},f=()=>{j(),y(!1)},A=t!==null&&l!==null;return e.jsx(Y,{children:e.jsxs("div",{ref:x,children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx(X,{icon:e.jsx(pa,{}),title:"Stealth"}),e.jsxs("div",{className:"flex items-center gap-1",children:[A&&!p&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:C,className:m("relative inline-flex h-6 w-11 items-center rounded-full transition-colors border-2 mr-2",n?"bg-toggle-on border-toggle-on":"bg-toggle-off border-edge-subtle"),title:n?"Disable stealth location":"Enable stealth location",children:e.jsx("span",{className:m("inline-block h-4 w-4 transform rounded-full bg-white transition-transform shadow-lg",n?"translate-x-5":"translate-x-0.5")})}),e.jsx("button",{onClick:f,className:"p-2 rounded-lg transition-colors text-fg-muted hover:text-sys-red hover:bg-sys-red/10",title:"Clear stealth location",children:e.jsx(Ys,{className:"w-4 h-4"})})]}),p?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:M,disabled:b==="loading",className:m("p-2 rounded-lg transition-colors",b==="loading"?"text-fg-muted cursor-not-allowed":"text-fg-muted hover:text-sys-red hover:bg-sys-red/10"),title:"Cancel",children:e.jsx(Z,{className:"w-4 h-4"})}),e.jsx("button",{onClick:_,disabled:b==="loading",className:m("p-2 rounded-lg transition-colors",b==="loading"?"text-sys-blue cursor-wait":b==="success"?"text-sys-green":b==="error"?"text-sys-red":"text-sys-green hover:bg-sys-green/10"),title:"Save",children:b==="loading"?e.jsx(U,{className:"w-4 h-4 animate-spin"}):b==="success"?e.jsx(J,{className:"w-4 h-4"}):b==="error"?e.jsx(Z,{className:"w-4 h-4"}):e.jsx(J,{className:"w-4 h-4"})})]}):e.jsx("button",{onClick:R,className:"p-2 rounded-lg transition-colors text-fg-muted hover:text-fg-primary hover:bg-subtle",title:A?"Edit stealth location":"Set stealth location",children:e.jsx(is,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"bg-sys-cyan/5 rounded-xl p-3 mb-4",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(oe,{className:"w-4 h-4 text-sys-cyan flex-shrink-0 mt-0.5"}),e.jsxs("p",{className:"type-body-sm text-fg-muted",children:[e.jsx("span",{className:"text-fg-secondary",children:"Stealth mode"})," allows you to appear on the map and in topology analysis without broadcasting your location. Coordinates are stored locally in your browser only — ",e.jsx("span",{className:"text-sys-cyan",children:"never sent to config.yaml or the mesh"}),"."]})]})}),k&&e.jsx("div",{className:"text-xs mb-3 px-2 py-1.5 rounded-md text-sys-red bg-sys-red/10",children:k}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-1",children:p?"Latitude (°)":"Latitude"}),e.jsx("div",{className:m("h-[38px] rounded-full px-4 flex items-center transition-colors","bg-subtle-fill"),children:p?e.jsx("input",{type:"number",value:u,onChange:S=>r(S.target.value),step:"0.000001",min:"-90",max:"90",placeholder:"e.g. 34.052234",className:"w-full bg-transparent text-fg-primary focus:outline-none type-data placeholder:text-fg-muted/50"}):e.jsx("span",{className:m("type-data",A&&n?"text-fg-primary":"text-fg-muted"),children:A?t.toFixed(6):"Not set"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-1",children:p?"Longitude (°)":"Longitude"}),e.jsx("div",{className:m("h-[38px] rounded-full px-4 flex items-center transition-colors","bg-subtle-fill"),children:p?e.jsx("input",{type:"number",value:h,onChange:S=>F(S.target.value),step:"0.000001",min:"-180",max:"180",placeholder:"e.g. -118.243685",className:"w-full bg-transparent text-fg-primary focus:outline-none type-data placeholder:text-fg-muted/50"}):e.jsx("span",{className:m("type-data",A&&n?"text-fg-primary":"text-fg-muted"),children:A?l.toFixed(6):"Not set"})})]})]}),A&&!p&&e.jsx("div",{className:"mt-3 pt-3 border-t border-edge-subtle",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:m("w-2 h-2 rounded-full",n?"bg-sys-green":"bg-fg-muted")}),e.jsx("span",{className:"type-body-sm text-fg-muted",children:n?"Stealth location active — you appear on maps with these coordinates":"Stealth location disabled — coordinates saved but not in use"})]})})]})})}function fe(t){if(t<60)return`${t}s`;if(t<3600){const c=Math.floor(t/60),i=t%60;return i>0?`${c}m ${i}s`:`${c}m`}const l=Math.floor(t/3600),n=Math.floor(t%3600/60);return n>0?`${l}h ${n}m`:`${l}h`}function ts({title:t,defaultOpen:l=!1,children:n}){const[c,i]=a.useState(l);return e.jsxs("div",{className:"bg-subtle-fill radius-inner overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>i(!c),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-subtle-fill-hover transition-colors",children:[e.jsx("span",{className:"type-label text-fg-muted",children:t}),e.jsx(Ke,{className:m("w-4 h-4 text-fg-muted transition-transform",c&&"rotate-180")})]}),c&&e.jsx("div",{className:"px-4 pb-4 pt-1",children:n})]})}const Ie={off:{label:"Off",description:"All rate limiting disabled. Every advert is forwarded unconditionally.",color:"text-fg-muted",config:qt},light:{label:"Light",description:"Gentle throttling for sparse meshes. Allows short bursts but penalizes repeat offenders. Good for small networks with few nodes.",color:"text-sys-green",config:{rate_limit_enabled:!0,bucket_capacity:3,refill_tokens:1,refill_interval_seconds:3600,min_interval_seconds:15,penalty_enabled:!0,violation_threshold:2,base_penalty_seconds:1800,penalty_multiplier:2,max_penalty_seconds:43200,violation_decay_seconds:7200,adaptive_enabled:!0,ewma_alpha:.15,hysteresis_seconds:480,quiet_max:2,normal_max:6,busy_max:10}},standard:{label:"Standard",description:"Balanced protection for most meshes. One advert per source is enough for discovery — repeated adverts are suppressed to protect channel capacity.",color:"text-sys-blue",recommended:!0,config:{rate_limit_enabled:!0,bucket_capacity:2,refill_tokens:1,refill_interval_seconds:7200,min_interval_seconds:30,penalty_enabled:!0,violation_threshold:1,base_penalty_seconds:7200,penalty_multiplier:4,max_penalty_seconds:172800,violation_decay_seconds:14400,adaptive_enabled:!0,ewma_alpha:.1,hysteresis_seconds:300,quiet_max:1,normal_max:3,busy_max:8}},strict:{label:"Strict",description:"Maximum suppression for dense or congested meshes. One token, long refill, immediate jail. Protects GRP_TXT capacity at all costs.",color:"text-sys-amber",config:{rate_limit_enabled:!0,bucket_capacity:1,refill_tokens:1,refill_interval_seconds:14400,min_interval_seconds:60,penalty_enabled:!0,violation_threshold:1,base_penalty_seconds:10800,penalty_multiplier:4,max_penalty_seconds:259200,violation_decay_seconds:21600,adaptive_enabled:!0,ewma_alpha:.05,hysteresis_seconds:180,quiet_max:.5,normal_max:2,busy_max:5}}},Zs=["off","light","standard","strict"];function ka(t,l,n){if(!t&&!l&&!n||!((t==null?void 0:t.enabled)||(l==null?void 0:l.enabled)||(n==null?void 0:n.enabled)))return"off";for(const i of Zs){if(i==="off")continue;const o=Ie[i].config;if((t==null?void 0:t.bucket_capacity)===o.bucket_capacity&&(t==null?void 0:t.refill_tokens)===o.refill_tokens&&(t==null?void 0:t.refill_interval_seconds)===o.refill_interval_seconds&&(t==null?void 0:t.min_interval_seconds)===o.min_interval_seconds&&(l==null?void 0:l.violation_threshold)===o.violation_threshold&&(l==null?void 0:l.base_penalty_seconds)===o.base_penalty_seconds&&(l==null?void 0:l.penalty_multiplier)===o.penalty_multiplier&&(l==null?void 0:l.max_penalty_seconds)===o.max_penalty_seconds&&(l==null?void 0:l.violation_decay_seconds)===o.violation_decay_seconds&&(n==null?void 0:n.ewma_alpha)===o.ewma_alpha&&(n==null?void 0:n.hysteresis_seconds)===o.hysteresis_seconds)return i}return null}function _a(){var S,I,V,H,K,ee;const{stats:t,fetchStats:l}=cs(),n=a.useRef(!0),[c,i]=a.useState(!0),[o,j]=a.useState(!1),[p,y]=a.useState(null),[u,r]=a.useState("idle"),h=a.useRef(null),[F,b]=a.useState(!1),[E,k]=a.useState(new Set);a.useEffect(()=>(n.current=!0,()=>{n.current=!1,h.current&&clearTimeout(h.current)}),[]);const N=a.useCallback(async()=>{var d;try{const O=await wt();if(!n.current)return;O.success&&O.data&&((d=O.data.adaptive)!=null&&d.current_tier)?i(!0):i(!1)}catch{n.current&&i(!1)}},[]);a.useEffect(()=>{N();const d=setInterval(N,3e4);return()=>clearInterval(d)},[N]);const x=(I=(S=t==null?void 0:t.config)==null?void 0:S.repeater)==null?void 0:I.advert_rate_limit,g=(H=(V=t==null?void 0:t.config)==null?void 0:V.repeater)==null?void 0:H.advert_penalty_box,v=(ee=(K=t==null?void 0:t.config)==null?void 0:K.repeater)==null?void 0:ee.advert_adaptive;if(!c&&!x&&!g&&!v)return null;const R=d=>E.has(d),M=d=>{k(O=>{if(!O.has(d))return O;const W=new Set(O);return W.delete(d),W})},w=ka(x,g,v),_=w?Ie[w]:null,C=async(d,O)=>{M(d),j(!0),y(null),h.current&&clearTimeout(h.current);try{const W=await Ks({[d]:O});if(!n.current)return;W.success?(r("success"),await Promise.all([l({force:!0}).catch(()=>{}),N()])):(r("error"),y(W.error||"Failed to save"))}catch{n.current&&(r("error"),y("Failed to save"))}finally{n.current&&(j(!1),h.current=setTimeout(()=>{n.current&&(r("idle"),y(null))},1500))}},f=async d=>{if(!(d===w||o)){j(!0),y(null),k(new Set),h.current&&clearTimeout(h.current);try{const O=await Ks(Ie[d].config);if(!n.current)return;O.success?(r("success"),await Promise.all([l({force:!0}).catch(()=>{}),N()])):(r("error"),y(O.error||"Failed to save"))}catch{n.current&&(r("error"),y("Failed to save"))}finally{n.current&&(j(!1),h.current=setTimeout(()=>{n.current&&r("idle")},1500))}}},A=()=>f("off");return e.jsxs(Y,{neomorphic:!0,children:[e.jsx(X,{icon:e.jsx(aa,{}),title:"Advert Rate Limiting",actions:e.jsxs("div",{className:"flex items-center gap-3",children:[u!=="idle"&&e.jsxs("span",{className:"flex items-center",children:[u==="success"&&e.jsx(J,{className:"w-4 h-4 text-sys-green"}),u==="error"&&e.jsx(Z,{className:"w-4 h-4 text-sys-red"})]}),e.jsxs(L,{plain:!0,onClick:A,className:"flex items-center gap-1.5 text-zinc-500 hover:text-zinc-400 transition-colors",children:[e.jsx(ta,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-body-xs font-medium hidden sm:inline",children:"Reset"})]}),e.jsxs(L,{plain:!0,onClick:()=>b(!0),className:"flex items-center gap-1.5 text-sys-blue hover:text-sys-blue/80 transition-colors",children:[e.jsx(rs,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-body-xs font-medium",children:"Auto"})]})]})}),p&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:p}),e.jsx("div",{className:"toggle-group w-full mb-4",children:Zs.map(d=>{const O=Ie[d],W=d===w;return e.jsx("button",{onClick:()=>f(d),disabled:o,className:m("toggle-group-item flex-1",W&&"active",W&&O.color),children:O.label},d)})}),e.jsx("div",{className:"bg-subtle-fill radius-inner p-4 mb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-sys-blue/20 flex items-center justify-center flex-shrink-0",children:e.jsx(oe,{className:"w-4 h-4 text-sys-blue"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:m("type-data-xs font-medium uppercase tracking-wide",(_==null?void 0:_.color)??"text-fg-muted"),children:(_==null?void 0:_.label)??"Custom"}),(_==null?void 0:_.recommended)&&e.jsx(ns,{color:"green",children:"Recommended"}),!w&&e.jsx(ns,{color:"zinc",children:"Custom"})]}),e.jsx("p",{className:"type-body-sm text-fg-muted mt-1",children:(_==null?void 0:_.description)??"Settings have been manually tuned and don’t match any preset."})]})]})}),e.jsxs("div",{className:m("space-y-3",w==="off"&&"opacity-40 pointer-events-none"),children:[e.jsx(ts,{title:"Token Rules",children:x?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(P,{label:"Bucket Capacity",value:String(x.bucket_capacity),type:"number",suffix:"tokens",min:1,max:100,tooltip:"Max tokens a source can hold — determines burst capacity. Each advert costs one token; tokens refill over time.",autoConfigured:R("bucket_capacity"),onSave:async d=>C("bucket_capacity",parseInt(d,10))}),e.jsx(P,{label:"Refill Tokens",value:String(x.refill_tokens),type:"number",suffix:"tokens",min:1,max:50,tooltip:"Tokens added back each refill cycle. Higher = more forgiving over time.",autoConfigured:R("refill_tokens"),onSave:async d=>C("refill_tokens",parseInt(d,10))}),e.jsx(P,{label:"Refill Interval",value:fe(x.refill_interval_seconds),editValue:String(parseFloat((x.refill_interval_seconds/3600).toFixed(2))),type:"number",suffix:"hr",step:.5,min:.5,max:24,tooltip:"How often the bucket gets topped up. Shorter = faster recovery from bursts.",autoConfigured:R("refill_interval_seconds"),onSave:async d=>C("refill_interval_seconds",Math.round(parseFloat(d)*3600))}),e.jsx(P,{label:"Min Interval",value:fe(x.min_interval_seconds),editValue:String(x.min_interval_seconds),type:"number",suffix:"sec",min:0,max:3600,tooltip:"Minimum gap between adverts from the same source, even if tokens are available. 0 = no minimum.",autoConfigured:R("min_interval_seconds"),onSave:async d=>C("min_interval_seconds",parseInt(d,10))})]}):e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Not configured on this backend."})}),e.jsx(ts,{title:"Jail Settings",children:g?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(P,{label:"Violation Threshold",value:String(g.violation_threshold),type:"number",suffix:"violations",min:1,max:100,tooltip:"How many rate-limit violations before a source gets penalized. Think of it as strikes before timeout.",autoConfigured:R("violation_threshold"),onSave:async d=>C("violation_threshold",parseInt(d,10))}),e.jsx(P,{label:"Base Penalty",value:fe(g.base_penalty_seconds),editValue:String(parseFloat((g.base_penalty_seconds/3600).toFixed(2))),type:"number",suffix:"hr",step:.5,min:.5,max:24,tooltip:"First offense penalty duration. Repeat offenders get this multiplied.",autoConfigured:R("base_penalty_seconds"),onSave:async d=>C("base_penalty_seconds",Math.round(parseFloat(d)*3600))}),e.jsx(P,{label:"Multiplier",value:`${g.penalty_multiplier}x`,editValue:String(g.penalty_multiplier),type:"number",suffix:"x",step:.5,min:1,max:10,tooltip:"Each repeat offense multiplies the penalty by this factor. 2x means penalties double each time.",autoConfigured:R("penalty_multiplier"),onSave:async d=>C("penalty_multiplier",parseFloat(d))}),e.jsx(P,{label:"Max Penalty",value:fe(g.max_penalty_seconds),editValue:String(parseFloat((g.max_penalty_seconds/3600).toFixed(2))),type:"number",suffix:"hr",step:1,min:1,max:168,tooltip:"Upper limit on penalty duration. No matter how many offenses, it won't exceed this.",autoConfigured:R("max_penalty_seconds"),onSave:async d=>C("max_penalty_seconds",Math.round(parseFloat(d)*3600))}),e.jsx(P,{label:"Violation Decay",value:fe(g.violation_decay_seconds),editValue:String(parseFloat((g.violation_decay_seconds/3600).toFixed(2))),type:"number",suffix:"hr",step:1,min:1,max:168,tooltip:"How long until a source's violation count resets. Good behavior earns a clean slate.",autoConfigured:R("violation_decay_seconds"),onSave:async d=>C("violation_decay_seconds",Math.round(parseFloat(d)*3600))})]}):e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Not configured on this backend."})}),e.jsx(ts,{title:"Traffic Tiers",children:v?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(P,{label:"EWMA α",value:String(v.ewma_alpha),type:"number",step:.01,min:.01,max:1,tooltip:"How quickly the system reacts to traffic changes. Lower = smoother, higher = more responsive.",autoConfigured:R("ewma_alpha"),onSave:async d=>C("ewma_alpha",parseFloat(d))}),e.jsx(P,{label:"Hysteresis",value:fe(v.hysteresis_seconds),editValue:String(parseFloat((v.hysteresis_seconds/60).toFixed(2))),type:"number",suffix:"min",step:.5,min:0,max:60,tooltip:"Cooldown before switching tiers again. Prevents rapid flip-flopping during traffic spikes.",autoConfigured:R("hysteresis_seconds"),onSave:async d=>C("hysteresis_seconds",Math.round(parseFloat(d)*60))}),e.jsx(P,{label:"Quiet Max",value:String(v.thresholds.quiet_max),type:"number",min:0,max:1e4,suffix:"pkts/hr",tooltip:"Traffic below this = quiet mesh. Rate limits are most relaxed here.",autoConfigured:R("quiet_max"),onSave:async d=>C("quiet_max",parseFloat(d))}),e.jsx(P,{label:"Normal Max",value:String(v.thresholds.normal_max),type:"number",min:0,max:1e4,suffix:"pkts/hr",tooltip:"Traffic below this = normal activity. Standard rate limits apply.",autoConfigured:R("normal_max"),onSave:async d=>C("normal_max",parseFloat(d))}),e.jsx(P,{label:"Busy Max",value:String(v.thresholds.busy_max),type:"number",min:0,max:1e4,suffix:"pkts/hr",tooltip:"Traffic above this = congested mesh. Strictest rate limits kick in.",autoConfigured:R("busy_max"),onSave:async d=>C("busy_max",parseFloat(d))})]}):e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Not configured on this backend."})})]}),e.jsx("div",{className:"bg-sys-blue/5 radius-inner p-4 mt-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-sys-blue/20 flex items-center justify-center flex-shrink-0",children:e.jsx(oe,{className:"w-4 h-4 text-sys-blue"})}),e.jsx("div",{className:"type-body-sm text-fg-muted",children:e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-secondary",children:"Three layers"})," work together: the ",e.jsx("span",{className:"text-sys-blue",children:"Token Rules"})," throttle per-source adverts, the ",e.jsx("span",{className:"text-sys-amber",children:"Jail"})," escalates penalties for repeat violators, and ",e.jsx("span",{className:"text-sys-green",children:"Traffic Tiers"})," adjust limits based on overall mesh activity. The ",e.jsx("span",{className:"text-sys-blue",children:"“Auto”"})," button analyzes 1 week of mesh traffic to suggest optimal settings."]})})]})}),e.jsx(Bt,{open:F,onClose:()=>b(!1),currentConfig:{tokenBucket:x,penaltyBox:g,adaptive:v},onApplied:async()=>{k(new Set(Gt)),await Promise.all([l({force:!0}).catch(()=>{}),N()])}})]})}const Gs={off:{label:"Off",threshold:null,description:"No loop detection. All flood packets forwarded regardless of path history.",color:"text-fg-muted"},minimal:{label:"Minimal",threshold:4,description:"Drops flood packets when your local hash appears 4+ times in the path. Catches only the most obvious routing loops.",color:"text-sys-green",recommended:!0},moderate:{label:"Moderate",threshold:2,description:"Drops flood packets when your local hash appears 2+ times in the path. Good balance for most networks.",color:"text-sys-blue"},strict:{label:"Strict",threshold:1,description:"Drops flood packets if your local hash appears even once in the path. Strongest loop prevention — may drop some legitimate retransmissions in dense meshes.",color:"text-sys-amber"}},Sa=["off","minimal","moderate","strict"];function Ca(){var N;const{stats:t,fetchStats:l}=cs(),n=a.useRef(!0),c=(N=t==null?void 0:t.config)==null?void 0:N.mesh,i=!!c,o=(c==null?void 0:c.loop_detect)??"off",j=Gs[o],p=t==null?void 0:t.local_hash,[y,u]=a.useState(!1),[r,h]=a.useState(null),[F,b]=a.useState("idle"),E=a.useRef(null);if(a.useEffect(()=>(n.current=!0,()=>{n.current=!1,E.current&&clearTimeout(E.current)}),[]),a.useEffect(()=>{if(!r)return;const x=setTimeout(()=>{n.current&&h(null)},4e3);return()=>clearTimeout(x)},[r]),!t)return null;const k=async x=>{if(!(!i||x===o||y)){u(!0),h(null),E.current&&clearTimeout(E.current);try{const g=await Ws({loop_detect:x});if(!n.current)return;g.success?(b("success"),await l({force:!0}).catch(()=>{})):(b("error"),h(g.error||"Failed to save"))}catch{n.current&&(b("error"),h("Failed to save"))}finally{n.current&&(u(!1),E.current=setTimeout(()=>{n.current&&b("idle")},1500))}}};return e.jsxs(Y,{neomorphic:!0,children:[e.jsx(X,{icon:e.jsx(na,{}),title:"Flood Loop Detection",actions:F!=="idle"?e.jsxs("span",{className:"flex items-center",children:[F==="success"&&e.jsx(J,{className:"w-4 h-4 text-sys-green"}),F==="error"&&e.jsx(Z,{className:"w-4 h-4 text-sys-red"})]}):void 0}),!i&&e.jsxs("div",{className:"flex items-start gap-2.5 mb-3 px-3 py-2.5 radius-inner bg-sys-amber/10 text-sys-amber",children:[e.jsx(Le,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),e.jsxs("p",{className:"type-body-sm",children:["Backend does not expose mesh config. Update pyMC_Repeater to enable live configuration. Set ",e.jsx("code",{className:"font-mono text-fg-secondary",children:"loop_detect"})," in"," ",e.jsx("code",{className:"font-mono text-fg-secondary",children:"config.yaml"})," manually."]})]}),r&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:r}),e.jsx("div",{className:m("toggle-group w-full mb-4",!i&&"opacity-50 pointer-events-none"),children:Sa.map(x=>{const g=Gs[x],v=x===o;return e.jsx("button",{onClick:()=>k(x),disabled:y||!i,className:m("toggle-group-item flex-1",v&&"active",v&&g.color),children:g.label},x)})}),e.jsx("div",{className:"bg-subtle-fill radius-inner p-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-sys-blue/20 flex items-center justify-center flex-shrink-0",children:e.jsx(oe,{className:"w-4 h-4 text-sys-blue"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:m("type-data-xs font-medium uppercase tracking-wide",j.color),children:j.label}),j.threshold!==null&&e.jsxs("span",{className:"data-box data-box-compact text-fg-secondary tabular-nums",children:["≥",j.threshold,"× → drop"]}),j.recommended&&e.jsx(ns,{color:"green",children:"Recommended"})]}),e.jsx("p",{className:"type-body-sm text-fg-muted mt-1",children:j.description}),p&&o!=="off"&&e.jsxs("p",{className:"type-data-xs text-fg-muted/60 mt-2 font-mono",children:["Local hash: ",p]})]})]})})]})}function Ta(t){if(!t)return"Never";const l=new Date(t).getTime();if(isNaN(l))return"Never";const c=(Date.now()-l)/1e3;return c<60?"Just now":c<3600?`${Math.floor(c/60)}m ago`:c<86400?`${Math.floor(c/3600)}h ago`:`${Math.floor(c/86400)}d ago`}function Fa(){const{status:t,updateAvailable:l,isChecking:n,channels:c,changelog:i,error:o,available:j,checkForUpdate:p,fetchChannels:y,fetchChangelog:u,setChannel:r,openModal:h}=kt(),F=_t(),[b,E]=a.useState(!1),[k,N]=a.useState(!1);if(a.useEffect(()=>{y(),u()},[y,u]),!j)return null;const x=f=>f.split("+")[0],g=f=>f!=null&&f.includes("+")?f.split("+")[1]:null,v=(t==null?void 0:t.current_version)??(F==null?void 0:F.version)??null,R=(t==null?void 0:t.latest_version)??null,M=v?x(v):null,w=R?x(R):null,_=g(v);g(R);const C=(t==null?void 0:t.channel)??"main";return e.jsxs(Y,{neomorphic:!0,children:[e.jsx(X,{icon:e.jsx(Os,{}),title:"Software Update"}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4 mb-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-fg-secondary",children:"Installed"}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx("p",{className:"type-data text-fg-primary truncate font-mono",children:M?`v${M}`:"—"}),_&&e.jsx(St,{copy:!0,copyValue:_,title:`Build: ${_}`,children:_})]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-fg-secondary",children:"Git Branch"}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5",children:[e.jsx(la,{className:"w-3.5 h-3.5 text-sys-indigo flex-shrink-0"}),e.jsx("span",{className:"type-data text-sys-indigo truncate",children:C})]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"type-label text-fg-secondary",children:"Last Checked"}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5",children:[e.jsx(ra,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-muted",children:Ta((t==null?void 0:t.last_checked)??null)})]})]})]}),c.length>0&&e.jsxs("div",{className:"bg-subtle-fill radius-inner p-4 mb-4",children:[e.jsx("div",{className:"flex items-center justify-between gap-3",children:e.jsxs("div",{children:[e.jsx("h4",{className:"type-body-sm text-fg-primary font-medium",children:"Release Channel"}),e.jsx("p",{className:"type-data-xs text-fg-muted mt-0.5",children:"Switch between stable and development branches"})]})}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-3",children:c.map(f=>e.jsxs("button",{onClick:async()=>{f.active||k||(N(!0),await r(f.name),N(!1))},disabled:f.active||k,className:m("px-3 py-1.5 radius-inner type-data-xs font-medium transition-colors",f.active?"bg-sys-indigo/15 text-sys-indigo ring-1 ring-sys-indigo/30":"bg-subtle-fill-strong text-fg-muted hover:text-fg-primary hover:bg-subtle-fill-hover",k&&!f.active&&"opacity-50 cursor-not-allowed"),children:[f.name,f.active&&e.jsx(ls,{className:"w-3 h-3 ml-1.5 inline-block"})]},f.name))})]}),i.length>0&&e.jsxs("div",{className:"bg-subtle-fill radius-inner mb-4",children:[e.jsxs("button",{onClick:()=>E(!b),className:"w-full flex items-center gap-2 px-4 py-3 text-left hover:bg-subtle-fill-hover transition-colors radius-inner",children:[b?e.jsx(Ke,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}):e.jsx(Js,{className:"w-4 h-4 text-fg-muted flex-shrink-0"}),e.jsx("span",{className:"type-body-sm text-fg-primary font-medium flex-1",children:"Changelog"}),e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[i.length," commit",i.length!==1?"s":""]})]}),b&&e.jsx("div",{className:"px-4 pb-3 space-y-1 max-h-[300px] overflow-y-auto",children:i.map(f=>e.jsxs("div",{className:"flex items-start gap-2 py-1.5 group",children:[e.jsx(ma,{className:"w-3.5 h-3.5 text-fg-muted flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[f.url?e.jsx("a",{href:f.url,target:"_blank",rel:"noopener noreferrer",className:"type-data-xs text-fg-primary truncate hover:text-sys-blue transition-colors",children:f.title}):e.jsx("p",{className:"type-data-xs text-fg-primary truncate",children:f.title}),f.url&&e.jsx("a",{href:f.url,target:"_blank",rel:"noopener noreferrer",className:"opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",children:e.jsx(Qs,{className:"w-3 h-3 text-fg-muted"})})]}),f.body&&e.jsx("p",{className:"type-data-xs text-fg-muted mt-0.5 line-clamp-2 whitespace-pre-line",children:f.body}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:"type-data-xs text-fg-muted font-mono",children:f.short_sha}),e.jsx("span",{className:"text-fg-muted/30",children:"·"}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:f.author}),e.jsx("span",{className:"text-fg-muted/30",children:"·"}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:f.date?new Date(f.date).toLocaleDateString():""})]})]})]},f.sha))})]}),o&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:o}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[l&&e.jsxs(L,{color:"danger",onClick:h,children:[e.jsx(Os,{"data-slot":"icon"}),"Update to v",w]}),e.jsx("div",{className:"flex-1"}),!l&&t&&e.jsxs("span",{className:"flex items-center gap-1.5 type-data-xs text-sys-green",children:[e.jsx(ls,{className:"w-3.5 h-3.5"}),"Up to date"]}),e.jsx(L,{color:"primary",outline:!0,onClick:()=>p(!0),disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(U,{"data-slot":"icon",className:"animate-spin"}),"Checking..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Xs,{"data-slot":"icon"}),"Check for Updates"]})})]})]})}const Ea=[{value:7.8,label:"7.8 kHz"},{value:10.4,label:"10.4 kHz"},{value:15.6,label:"15.6 kHz"},{value:20.8,label:"20.8 kHz"},{value:31.25,label:"31.25 kHz"},{value:41.7,label:"41.7 kHz"},{value:62.5,label:"62.5 kHz"},{value:125,label:"125 kHz"},{value:250,label:"250 kHz"},{value:500,label:"500 kHz"}],Ra=[5,6,7,8,9,10,11,12],Ma=[{value:5,label:"4/5"},{value:6,label:"4/6"},{value:7,label:"4/7"},{value:8,label:"4/8"}],Da=[{value:0,label:"1-byte — 0x00"},{value:1,label:"2-byte — 0x0000"},{value:2,label:"3-byte — 0x000000"}],Us={RADIO_CONFIG:"radioConfig"};function Aa(t){if(!t)return"Never";const n=Date.now()-t*1e3,c=Math.floor(n/6e4),i=Math.floor(n/36e5),o=Math.floor(n/864e5);return c<1?"Just now":c<60?`${c}m ago`:i<24?`${i}h ago`:o<365?`${o}d ago`:`${Math.floor(o/365)}y ago`}function et({node:t,level:l,expandedKeys:n,selectedKeyId:c,globalFloodPolicy:i,onSelect:o,onToggle:j}){const p=n.has(t.id),y=c===t.id,u=t.children&&t.children.length>0,r=i==="allow";return e.jsxs("div",{children:[e.jsxs("div",{className:m("flex items-center gap-2 h-[36px] px-3 rounded-full cursor-pointer transition-colors",y?"bg-sys-blue/15":"hover:bg-subtle-fill",r&&"opacity-50 cursor-not-allowed"),style:{marginLeft:`${l*16}px`},onClick:()=>!r&&o(t.id),children:[u?e.jsx("button",{onClick:h=>{h.stopPropagation(),j(t.id)},className:"p-1 hover:bg-subtle-fill-hover rounded-full transition-colors",children:e.jsx(Js,{className:m("w-3.5 h-3.5 text-fg-muted transition-transform",p&&"rotate-90")})}):e.jsx("span",{className:"w-5"}),e.jsx(da,{className:"w-4 h-4 text-sys-blue flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-primary flex-1 truncate",children:t.name}),e.jsx("span",{className:"type-data-xs text-fg-muted hidden sm:inline",title:t.last_used?new Date(t.last_used*1e3).toLocaleString():void 0,children:Aa(t.last_used)}),e.jsx("span",{className:m("type-data-xs px-2 py-0.5 rounded-full",t.floodPolicy==="allow"?"bg-sys-green/15 text-sys-green":"bg-sys-red/15 text-sys-red"),children:t.floodPolicy==="allow"?"Allow":"Deny"})]}),u&&p&&e.jsx("div",{children:t.children.map(h=>e.jsx(et,{node:h,level:l+1,expandedKeys:n,selectedKeyId:c,globalFloodPolicy:i,onSelect:o,onToggle:j},h.id))})]})}function Pa(){const[t,l]=a.useState(Wt),[n,c]=a.useState(Xt),[i,o]=a.useState(!1),j=a.useCallback(u=>{l(u),Yt(u)},[]),p=a.useCallback(u=>{const r=parseFloat(u.target.value);c(r),Jt(r)},[]),y=a.useCallback(async()=>{i||(o(!0),await Qt(),o(!1))},[i]);return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(xe,{enabled:t,onChange:j,label:e.jsxs(e.Fragment,{children:["Sound: ",e.jsx("span",{className:t?"text-sys-green":"text-sys-red",children:t?"On":"Off"})]}),tooltip:"Enable or disable UI sound effects and haptic audio feedback",size:"md"}),e.jsx(L,{color:"primary",outline:!0,onClick:y,disabled:!t||i,className:"w-16 justify-center",children:i?"…":"Test"})]}),e.jsxs("div",{className:m("flex items-center gap-3",!t&&"opacity-40 pointer-events-none"),children:[e.jsx("span",{className:"type-label text-fg-muted w-14 shrink-0",children:"Volume"}),e.jsx("input",{type:"range",min:0,max:1,step:.05,value:n,onChange:p,className:"flex-1 accent-sys-blue h-1.5 cursor-pointer"}),e.jsxs("span",{className:"data-box w-16 justify-center",children:[Math.round(n*100),"%"]})]})]})}function tn(){var Cs,Ts,Fs,Es,Rs,Ms,Ds,As,Ps,Ls;const{stats:t,setMode:l,clearModeMutation:n,setDutyCycleConfig:c,clearDutyCycleMutation:i,fetchStats:o,startMutation:j,clearMutation:p}=cs(),y=Ct(),u=(Cs=t==null?void 0:t.config)==null?void 0:Cs.radio,r=(Ts=t==null?void 0:t.config)==null?void 0:Ts.repeater,h=(Fs=t==null?void 0:t.config)==null?void 0:Fs.duty_cycle,F=(t==null?void 0:t.node_name)||((Es=t==null?void 0:t.config)==null?void 0:Es.node_name)||"Unknown Node",b=(r==null?void 0:r.mode)??"forward",E=(h==null?void 0:h.enforcement_enabled)??!1,k=(Rs=t==null?void 0:t.config)==null?void 0:Rs.delays,N=a.useRef(!0);a.useEffect(()=>(N.current=!0,()=>{N.current=!1}),[]);const x=(Ms=t==null?void 0:t.config)==null?void 0:Ms.web,[g,v]=a.useState([]),[R,M]=a.useState(!1),[w,_]=a.useState(null),[C,f]=a.useState(!1),[A,S]=a.useState(""),[I,V]=a.useState(null),[H,K]=a.useState(!1),[ee,d]=a.useState(null),[O,W]=a.useState(!1),[ds,us]=a.useState(!1),[ms,fs]=a.useState(!1),[te,st]=a.useState([]),[tt,xs]=a.useState(!1),[hs,$]=a.useState(null),[ne,at]=a.useState(()=>localStorage.getItem("pymc:globalFloodPolicy")==="allow"?"allow":"deny"),ps=a.useCallback(s=>{at(s),localStorage.setItem("pymc:globalFloodPolicy",s)},[]),[ys,gs]=a.useState(!1),[B,Ve]=a.useState(null),[nt,lt]=a.useState(new Set),[_e,ge]=a.useState(!1),[Se,ce]=a.useState(!1),[Ce,de]=a.useState(!1),[q,ae]=a.useState(null),[le,be]=a.useState(null),[Te,Fe]=a.useState(""),[$e,je]=a.useState("allow"),[Q,ue]=a.useState(!1),[Ee,bs]=a.useState(!0),[ve,He]=a.useState(!1),[rt,js]=a.useState(!0),[Ne,re]=a.useState("idle"),[it,qe]=a.useState(!1),[Be,ot]=a.useState(!1),vs=a.useCallback(()=>{const s=k==null?void 0:k.tx_delay_factor;return s&&typeof s=="object"&&"parsedValue"in s?s.parsedValue??1:typeof s=="number"?s:1},[k]),Ns=a.useCallback(()=>{const s=k==null?void 0:k.direct_tx_delay_factor;return typeof s=="number"?s:.5},[k]),Ge=a.useCallback(()=>{const s=h==null?void 0:h.max_airtime_percent;return typeof s=="number"?s:s&&typeof s=="object"&&"parsedValue"in s?s.parsedValue??6:6},[h]),Ue=ss(b==="forward",async s=>{await l(s?"forward":"monitor")},n),We=ss(E,async s=>{await c({max_airtime_percent:Ge(),enforcement_enabled:s})},i),Xe=ss((x==null?void 0:x.cors_enabled)??!1,async s=>{var D;const T=await qs({web:{cors_enabled:s}});if(!T.success&&!((D=T.data)!=null&&D.persisted))throw new Error("CORS update failed");await o()}),G=a.useCallback(async s=>{j(Us.RADIO_CONFIG);try{const T=await Ws(s);if(!T.success)throw new Error(T.error||"Failed to save");await o({force:!0}).catch(()=>{})}finally{p(Us.RADIO_CONFIG)}},[j,p,o]);a.useEffect(()=>{(async()=>{js(!0);try{const T=await It();T.success&&T.data?He(T.data.exists):He(!1);const D=x==null?void 0:x.web_path;bs(!D||D==="")}catch{He(!1)}finally{js(!1)}})()},[x==null?void 0:x.web_path]);const ws=async s=>{var T;if(Ne!=="loading"){re("loading");try{const D=await qs({web:{web_path:s?null:"/opt/pymc_console/web/html"}});if(!N.current)return;D.success||(T=D.data)!=null&&T.persisted?(bs(s),re("success"),qe(!0),setTimeout(()=>{N.current&&re("idle")},2e3)):(re("error"),setTimeout(()=>{N.current&&re("idle")},2e3))}catch{if(!N.current)return;re("error"),setTimeout(()=>{N.current&&re("idle")},2e3)}}},ct=async()=>{if(!Be){ot(!0);try{await Kt(),qe(!1),setTimeout(()=>{window.location.reload()},2e3)}catch{qe(!1),setTimeout(()=>{window.location.reload()},3e3)}}},Re=a.useCallback(async()=>{M(!0),_(null);try{const s=await ya();v(s.tokens||[])}catch(s){_(s instanceof Error?s.message:"Failed to fetch tokens")}finally{M(!1)}},[]);a.useEffect(()=>{Re()},[Re]);const ks=async()=>{if(!A.trim()){_("Token name is required");return}W(!0),_(null);try{const s=await ga(A.trim());V(s.token||null),f(!1),K(!0),S(""),await Re()}catch(s){_(s instanceof Error?s.message:"Failed to create token")}finally{W(!1)}},dt=async()=>{if(ee){us(!0),_(null);try{await ba(ee.id),await Re(),d(null)}catch(s){_(s instanceof Error?s.message:"Failed to revoke token")}finally{us(!1)}}},ut=async()=>{I&&(await At(I),fs(!0),setTimeout(()=>fs(!1),2e3))},mt=s=>s?new Date(s*1e3).toLocaleString():"Never",_s=a.useCallback(s=>{const T=new Map,D=[];return s.forEach(z=>{const Me={id:z.id,name:z.name,floodPolicy:z.flood_policy,transport_key:z.transport_key,last_used:z.last_used,parent_id:z.parent_id,children:[]};T.set(z.id,Me)}),T.forEach(z=>{z.parent_id&&T.has(z.parent_id)?T.get(z.parent_id).children.push(z):D.push(z)}),D},[]),we=a.useCallback(async()=>{xs(!0),$(null);try{const s=await Pt();if(s.success&&s.data){const T=_s(s.data);st(T),Ve(D=>{if(D===null)return null;const z=Me=>{for(const Ye of Me)if(Ye.id===D||Ye.children&&z(Ye.children))return!0;return!1};return z(T)?D:null})}else $(s.error||"Failed to load transport keys")}catch(s){$(s instanceof Error?s.message:"Unknown error occurred")}finally{xs(!1)}},[_s]);a.useEffect(()=>{we(),Lt().then(s=>{s.success&&s.data&&ps(s.data.global_flood_allow?"allow":"deny")}).catch(()=>{})},[we]);const ie=a.useCallback((s,T)=>{for(const D of s){if(D.id===T)return D;if(D.children){const z=ie(D.children,T);if(z)return z}}return null},[]),ft=a.useCallback(()=>{if(!B)return;const s=ie(te,B);return s==null?void 0:s.name},[B,te,ie]),xt=a.useCallback(s=>{lt(T=>{const D=new Set(T);return D.has(s)?D.delete(s):D.add(s),D})},[]),ht=async s=>{gs(!0),$(null);try{const T=await Ot(s==="allow");T.success?ps(s):$(T.error||"Failed to update global flood policy")}catch(T){$(T instanceof Error?T.message:"Failed to update global flood policy")}finally{gs(!1)}},Ss=async()=>{if(!Te.trim()){$("Key name is required");return}ue(!0),$(null);try{const s=await zt({name:Te.trim(),flood_policy:$e,parent_id:B??void 0});s.success?(await we(),ge(!1),Fe(""),je("allow")):$(s.error||"Failed to add transport key")}catch(s){$(s instanceof Error?s.message:"Failed to add transport key")}finally{ue(!1)}},pt=async()=>{if(q){ue(!0),$(null);try{const s=await Vt(q.id,{name:q.name,flood_policy:q.floodPolicy});s.success?(await we(),ce(!1),ae(null)):$(s.error||"Failed to update transport key")}catch(s){$(s instanceof Error?s.message:"Failed to update transport key")}finally{ue(!1)}}},yt=async()=>{if(le){ue(!0),$(null);try{const s=await $t(le.id);s.success?(await we(),de(!1),be(null),Ve(null)):$(s.error||"Failed to delete transport key")}catch(s){$(s instanceof Error?s.message:"Failed to delete transport key")}finally{ue(!1)}}},gt=a.useCallback(()=>{if(!B)return;const s=ie(te,B);s&&(ae({...s}),ce(!0))},[B,te,ie]);a.useEffect(()=>{const s=D=>{D.key==="Escape"&&(_e&&(ge(!1),Fe(""),je("allow")),Se&&(ce(!1),ae(null)),Ce&&(de(!1),be(null)),C&&(f(!1),S("")),H&&(K(!1),V(null)))};if(_e||Se||Ce||C||H)return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[_e,Se,Ce,C,H]);const bt=a.useCallback(()=>{if(!B)return;const s=ie(te,B);s&&(be(s),de(!0))},[B,te,ie]);return e.jsxs(Zt,{children:[e.jsx(ea,{title:"Configuration",icon:e.jsx(zs,{})}),e.jsxs(sa,{ready:y,children:[e.jsxs(se,{template:"standard",children:[e.jsx(me,{span:12,md:6,children:e.jsxs(Y,{neomorphic:!0,children:[e.jsx(X,{icon:e.jsx(Tt,{}),title:"Repeater Settings"}),r?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx("div",{className:"col-span-2",children:e.jsx(P,{label:"Node Name",value:F,onSave:async s=>G({node_name:s}),placeholder:"Enter node name",maxLength:50})}),e.jsx(P,{label:"Latitude",value:r.latitude!==0?r.latitude.toFixed(6):"Not set",editValue:String(r.latitude),type:"number",suffix:"°",step:1e-6,min:-90,max:90,onSave:async s=>G({latitude:parseFloat(s)})}),e.jsx(P,{label:"Longitude",value:r.longitude!==0?r.longitude.toFixed(6):"Not set",editValue:String(r.longitude),type:"number",suffix:"°",step:1e-6,min:-180,max:180,onSave:async s=>G({longitude:parseFloat(s)})}),e.jsx(P,{label:"Advert Interval",value:r.send_advert_interval_hours>0?`${r.send_advert_interval_hours}h`:"Disabled",editValue:String(r.send_advert_interval_hours),type:"number",suffix:"hours",min:0,max:48,description:"0 = disabled, 3-48 hours",onSave:async s=>G({flood_advert_interval_hours:parseInt(s,10)})}),e.jsx(P,{label:"Score-based TX",value:r.use_score_for_tx?"Enabled":"Disabled",readOnly:!0})]}):e.jsx("p",{className:"text-fg-muted",children:"Loading repeater settings..."})]})}),e.jsx(me,{span:12,md:6,children:e.jsxs(Y,{neomorphic:!0,children:[e.jsx(X,{icon:e.jsx(ia,{}),title:"Radio Configuration"}),u?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(P,{label:"Frequency",value:Ft(u.frequency),editValue:(u.frequency/1e6).toFixed(3),type:"number",suffix:"MHz",step:.001,min:400,max:930,onSave:async s=>G({frequency_mhz:parseFloat(s)})}),e.jsx(P,{label:"TX Power",value:`${u.tx_power} dBm`,editValue:String(u.tx_power),type:"number",suffix:"dBm",min:2,max:30,onSave:async s=>G({tx_power:parseInt(s,10)})}),e.jsx(Ae,{label:"Bandwidth",value:Et(u.bandwidth),editValue:u.bandwidth/1e3,options:Ea,onSave:async s=>G({bandwidth_khz:parseFloat(s)})}),e.jsx(Ae,{label:"Spreading Factor",value:`SF${u.spreading_factor}`,editValue:u.spreading_factor,options:Ra.map(s=>({value:s,label:`SF${s}`})),onSave:async s=>G({spreading_factor:parseInt(s,10)})}),e.jsx(Ae,{label:"Coding Rate",value:`4/${u.coding_rate}`,editValue:u.coding_rate,options:Ma,onSave:async s=>G({coding_rate:parseInt(s,10)})}),e.jsx(P,{label:"Preamble",value:`${u.preamble_length} symbols`,readOnly:!0})]}):e.jsx("p",{className:"text-fg-muted",children:"Loading radio configuration..."})]})})]}),e.jsxs(se,{template:"standard",children:[e.jsx(me,{span:12,md:6,children:e.jsxs(Y,{neomorphic:!0,children:[e.jsx(X,{icon:e.jsx(Rt,{}),title:"Operating Mode"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(xe,{enabled:Ue.enabled,onChange:Ue.toggle,label:"Repeat",tooltip:"Toggles repeater or monitor mode. In monitor mode, the repeater will not repeat packets from the mesh.",status:Ue.status,size:"md"}),e.jsx(xe,{enabled:We.enabled,onChange:We.toggle,label:"Duty Cycle",tooltip:"Limit transmission time to comply with airtime utilization regulations",status:We.status,size:"md"}),e.jsx(P,{label:"Max Airtime",value:`${Ge().toFixed(1)}%`,editValue:String(Ge()),type:"number",suffix:"%",step:.5,min:.1,max:100,onSave:async s=>{await c({max_airtime_percent:parseFloat(s),enforcement_enabled:E}),i()}}),e.jsx(P,{label:"Flood TX Delay",value:`${vs().toFixed(2)}x`,editValue:String(vs()),type:"number",suffix:"x",step:.1,min:0,max:5,onSave:async s=>G({tx_delay_factor:parseFloat(s)})}),e.jsx(P,{label:"Direct TX Delay",value:`${Ns().toFixed(2)}s`,editValue:String(Ns()),type:"number",suffix:"s",step:.1,min:0,max:5,onSave:async s=>G({direct_tx_delay_factor:parseFloat(s)})}),e.jsx(P,{label:"Max Flood Hops",value:String((r==null?void 0:r.max_flood_hops)??3),type:"number",min:0,max:64,description:"0–64 hops",onSave:async s=>G({max_flood_hops:parseInt(s,10)})})]}),e.jsx("div",{className:"mt-4",children:e.jsx(Ae,{label:"Path Hash Size",value:`${(((As=(Ds=t==null?void 0:t.config)==null?void 0:Ds.mesh)==null?void 0:As.path_hash_mode)??0)+1}-byte`,editValue:((Ls=(Ps=t==null?void 0:t.config)==null?void 0:Ps.mesh)==null?void 0:Ls.path_hash_mode)??0,options:Da,onSave:async s=>G({path_hash_mode:parseInt(s,10)})})})]})}),e.jsx(me,{span:12,md:6,children:e.jsxs(Y,{neomorphic:!0,children:[e.jsx(X,{icon:e.jsx(zs,{}),title:"App Settings"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:"Appearance and web server options."}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(xe,{enabled:Xe.enabled,onChange:Xe.toggle,label:"Enable CORS",tooltip:"Allow cross-origin API access",status:Xe.status,size:"md"}),e.jsx("div",{children:e.jsx(va,{})}),e.jsx(Pa,{})]})]})})]}),e.jsx(se,{template:"auto",children:e.jsx(_a,{})}),e.jsx(se,{template:"auto",children:e.jsxs(Y,{neomorphic:!0,children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-4",children:[e.jsx(X,{icon:e.jsx(Vs,{}),title:"Regions Transport Keys"}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(L,{color:"primary",outline:!0,onClick:()=>ge(!0),disabled:ne==="allow",children:[e.jsx($s,{"data-slot":"icon"}),"Add"]}),e.jsx(L,{color:"primary",outline:!0,onClick:gt,disabled:!B||ne==="allow",children:"Edit"}),e.jsx(L,{color:"danger",outline:!0,onClick:bt,disabled:!B||ne==="allow",children:"Delete"})]})]}),e.jsx("div",{className:"bg-subtle-fill radius-inner p-4 mb-4",children:e.jsx(xe,{enabled:ne==="deny",onChange:s=>ht(s?"deny":"allow"),label:e.jsxs(e.Fragment,{children:["Require Transport Keys: ",e.jsx("span",{className:ne==="deny"?"text-sys-green":"text-sys-red",children:ne==="deny"?"On":"Off"})]}),tooltip:"When enabled, only packets with matching transport keys are forwarded. When disabled, all packets flood freely.",status:ys?"loading":"idle",disabled:ys,dangerOff:!0,size:"md",className:"flex-row-reverse justify-between w-full"})}),hs&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:hs}),e.jsx("div",{className:"bg-subtle-fill radius-inner p-4 min-h-[120px]",children:tt?e.jsxs("div",{className:"flex items-center justify-center py-6",children:[e.jsx(U,{className:"w-5 h-5 animate-spin text-sys-blue mr-2"}),e.jsx("span",{className:"type-body-sm text-fg-muted",children:"Loading transport keys..."})]}):te.length===0?e.jsxs("div",{className:"text-center py-6",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-subtle-fill mx-auto mb-3 flex items-center justify-center",children:e.jsx(Vs,{className:"w-6 h-6 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted",children:"No transport keys found"}),e.jsx("p",{className:"type-body-sm text-fg-muted/70 mt-1",children:"Add your first transport key to get started"})]}):e.jsx("div",{className:"space-y-1",children:te.map(s=>e.jsx(et,{node:s,level:0,expandedKeys:nt,selectedKeyId:B,globalFloodPolicy:ne,onSelect:Ve,onToggle:xt},s.id))})})]})}),e.jsxs(se,{template:"standard",children:[e.jsx(me,{span:12,md:6,children:e.jsx(Ca,{})}),e.jsx(me,{span:12,md:6,children:e.jsxs(Y,{neomorphic:!0,className:"h-full flex flex-col",children:[e.jsx(X,{icon:e.jsx(Hs,{}),title:"API Tokens"}),w&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:w}),e.jsx("div",{className:"flex-1 flex flex-col min-h-0",children:R&&g.length===0?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(U,{className:"w-4 h-4 animate-spin text-sys-blue mr-2"}),e.jsx("span",{className:"type-body-sm text-fg-muted",children:"Loading tokens..."})]}):g.length>0?e.jsx("div",{className:"space-y-1.5 flex-1 overflow-y-auto mb-3",children:g.map(s=>e.jsxs("div",{className:"bg-subtle-fill hover:bg-subtle-fill-strong radius-inner px-3 py-2 transition-base flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"type-body-sm text-fg-primary font-medium truncate",children:s.name}),e.jsxs("span",{className:"type-data-xs text-fg-muted truncate",children:["Last used: ",mt(s.last_used)]})]}),e.jsx("button",{type:"button",onClick:()=>d({id:s.id,name:s.name}),disabled:ds,className:"text-sys-red/70 hover:text-sys-red transition-colors flex-shrink-0 p-1",title:"Revoke token",children:e.jsx(Ys,{className:"w-3.5 h-3.5"})})]},s.id))}):e.jsxs("div",{className:"bg-subtle-fill radius-inner flex-1 flex flex-col items-center justify-center mb-3",children:[e.jsx(Hs,{className:"w-5 h-5 text-fg-muted/50 mb-2"}),e.jsx("p",{className:"type-body-sm text-fg-muted",children:"No API tokens"})]})}),e.jsxs(L,{color:"primary",outline:!0,onClick:()=>f(!0),className:"w-full justify-center mt-auto",children:[e.jsx($s,{"data-slot":"icon"}),"Create Token"]})]})})]}),e.jsx(se,{template:"auto",children:e.jsxs(Y,{neomorphic:!0,children:[e.jsx(X,{icon:e.jsx(xa,{}),title:"Web Frontend"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:m("flex items-start gap-3 p-4 bg-subtle-fill radius-card border-2 cursor-pointer transition-base",Ee?"border-sys-blue bg-sys-blue/5":"border-transparent hover:border-sys-blue/30",Ne==="loading"&&"opacity-50 pointer-events-none"),children:[e.jsx("input",{type:"radio",name:"frontend",checked:Ee,onChange:()=>ws(!0),disabled:Ne==="loading",className:"mt-1 h-4 w-4 text-sys-blue focus:ring-sys-blue focus:ring-offset-bg-elevated"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"type-body text-fg-primary font-medium",children:"Default Frontend"}),e.jsx("a",{href:"https://github.com/rightup/pyMC_Repeater",target:"_blank",rel:"noopener noreferrer",onClick:s=>s.stopPropagation(),className:"type-data-xs bg-sys-cyan/15 text-sys-cyan px-2.5 py-0.5 rounded-full font-medium hover:bg-sys-cyan/25 transition-colors",children:"@RightUp"})]}),e.jsx("div",{className:"type-body-sm text-fg-muted mt-1",children:"Built-in pyMC Repeater web interface"}),e.jsx("div",{className:"type-data-xs text-fg-muted/60 mt-1",children:"/opt/pymc_repeater/repeater/web/html"})]})]}),e.jsxs("label",{className:m("flex items-start gap-3 p-4 bg-subtle-fill radius-card border-2 cursor-pointer transition-base",Ee?"border-transparent hover:border-sys-blue/30":"border-sys-blue bg-sys-blue/5",Ne==="loading"&&"opacity-50 pointer-events-none"),children:[e.jsx("input",{type:"radio",name:"frontend",checked:!Ee,onChange:()=>ws(!1),disabled:Ne==="loading",className:"mt-1 h-4 w-4 text-sys-blue focus:ring-sys-blue focus:ring-offset-bg-elevated"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"type-body text-fg-primary font-medium",children:"PyMC Console"}),e.jsx("span",{className:"type-data-xs bg-sys-indigo/15 text-sys-indigo px-2.5 py-0.5 rounded-full font-medium",children:"@Treehouse ⚡"})]}),e.jsx("div",{className:"type-body-sm text-fg-muted mt-1",children:"Alternative web interface for pyMC Repeater"}),e.jsx("div",{className:"type-data-xs text-fg-muted/60 mt-1",children:"/opt/pymc_console/web/html"})]})]})]}),!rt&&e.jsx("div",{className:m("bg-subtle-fill radius-card p-4",ve?"border border-sys-green/20":"border border-sys-cyan/20"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:m("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0",ve?"bg-sys-green/20":"bg-sys-cyan/20"),children:ve?e.jsx(ls,{className:"w-4 h-4 text-sys-green"}):e.jsx(oe,{className:"w-4 h-4 text-sys-cyan"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"type-body text-fg-primary font-medium",children:ve?"PyMC Console has been detected":"PyMC Console Not Installed"}),ve?e.jsxs("p",{className:"type-body-sm text-fg-muted mt-1",children:["PyMC Console is installed at ",e.jsx("code",{className:"type-code bg-sys-green/10 px-1.5 py-0.5 rounded-full text-sys-green",children:"/opt/pymc_console/web/html"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"type-body-sm text-fg-muted mt-1 mb-3",children:["PyMC Console must be installed at ",e.jsx("code",{className:"type-code bg-sys-cyan/10 px-1.5 py-0.5 rounded-full text-sys-cyan",children:"/opt/pymc_console/web/html"})," before selecting this option."]}),e.jsxs(L,{color:"primary",outline:!0,href:"https://github.com/dmduran12/pymc_console-dist",children:[e.jsx(Qs,{"data-slot":"icon"}),"PyMC Console Install Instructions"]})]})]})]})}),it&&e.jsx("div",{className:"bg-subtle-fill radius-card p-4 border border-sys-indigo/30",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 items-start gap-3 flex-1",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-sys-indigo/20 flex items-center justify-center flex-shrink-0",children:e.jsx(Le,{className:"w-4 h-4 text-sys-indigo"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"type-body text-fg-primary font-medium",children:"Service restart required"}),e.jsx("p",{className:"type-body-sm text-fg-muted mt-1",children:"Web frontend changes will take effect after restarting the pymc-repeater service."})]})]}),e.jsx(L,{color:"warning",outline:!0,onClick:ct,disabled:Be,children:Be?e.jsxs(e.Fragment,{children:[e.jsx(U,{"data-slot":"icon",className:"animate-spin"}),"Restarting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Xs,{"data-slot":"icon"}),"Restart Now"]})})]})})]})]})}),e.jsx(se,{template:"auto",children:e.jsx(Fa,{})}),t&&e.jsx(se,{template:"auto",children:e.jsx(Ut,{nodeName:F,publicKey:t.public_key})}),t&&((r==null?void 0:r.latitude)===0||!(r!=null&&r.latitude))&&((r==null?void 0:r.longitude)===0||!(r!=null&&r.longitude))&&e.jsx(se,{template:"auto",children:e.jsx(wa,{})})]}),C&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&f(!1),role:"dialog","aria-modal":"true","aria-labelledby":"create-token-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"create-token-modal-title",className:"type-micro mb-4",children:"Create API Token"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Je,{label:"Token Name",type:"text",value:A,onChange:s=>S(s.target.value),placeholder:"e.g., Production Server, CI/CD Pipeline",description:"Give your token a descriptive name to identify its purpose",onKeyDown:s=>s.key==="Enter"&&ks(),autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[e.jsx(L,{color:"muted",outline:!0,onClick:()=>{f(!1),S(""),_(null)},disabled:O,children:"Cancel"}),e.jsx(L,{color:"primary",onClick:ks,disabled:O||!A.trim(),children:O?e.jsxs(e.Fragment,{children:[e.jsx(U,{"data-slot":"icon",className:"animate-spin"}),"Creating..."]}):"Create Token"})]})]})]})}),H&&I&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&K(!1),role:"dialog","aria-modal":"true","aria-labelledby":"show-token-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-lg w-full",children:[e.jsx("h3",{id:"show-token-modal-title",className:"type-micro mb-4",children:"Token Created Successfully"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-sys-indigo/10 border border-sys-indigo/30 radius-inner p-3",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{className:"w-4 h-4 text-sys-indigo flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-fg-secondary",children:[e.jsx("strong",{children:"Save this token now!"})," For security reasons, it will not be shown again."]})]})}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-primary block mb-1.5",children:"Your API Token"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Mt,{value:I,readOnly:!0,className:"flex-1 font-mono"}),e.jsxs(L,{color:"primary",outline:!0,onClick:ut,children:[ms?e.jsx(J,{"data-slot":"icon",className:"text-sys-green"}):e.jsx(Dt,{"data-slot":"icon"}),ms?"Copied!":"Copy"]})]})]}),e.jsxs("div",{className:"bg-sys-cyan/10 border border-sys-cyan/30 radius-inner p-3",children:[e.jsx("p",{className:"text-sm text-fg-secondary mb-2",children:e.jsx("strong",{children:"Usage Example:"})}),e.jsxs("code",{className:"block bg-sys-cyan/20 px-3 py-2 rounded type-code text-sys-cyan overflow-x-auto",children:['curl -H "X-API-Key: ',I.slice(0,12),'..." ',window.location.origin,"/api/stats"]})]}),e.jsx("div",{className:"flex justify-end mt-6",children:e.jsx(L,{color:"primary",onClick:()=>{K(!1),V(null)},children:"Done"})})]})]})}),e.jsx(Ht,{isOpen:!!ee,title:"Revoke API Token",message:`Are you sure you want to revoke the token '${ee==null?void 0:ee.name}'? This action cannot be undone.`,confirmLabel:ds?"Revoking...":"Revoke",cancelLabel:"Cancel",variant:"danger",onConfirm:dt,onCancel:()=>d(null)}),_e&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&ge(!1),role:"dialog","aria-modal":"true","aria-labelledby":"add-key-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"add-key-modal-title",className:"type-micro mb-4",children:"Add Transport Key"}),e.jsxs("div",{className:"space-y-4",children:[B&&e.jsxs("div",{className:"bg-sys-cyan/10 border border-sys-cyan/30 radius-inner p-3 text-sm text-fg-secondary",children:["Adding as child of: ",e.jsx("strong",{className:"text-fg-primary",children:ft()})]}),e.jsx(Je,{label:"Key Name",type:"text",value:Te,onChange:s=>Fe(s.target.value),placeholder:"e.g., Region Name, Group Key",onKeyDown:s=>s.key==="Enter"&&Ss(),autoFocus:!0}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Flood Policy"}),e.jsxs("div",{className:"toggle-group w-full",children:[e.jsx("button",{onClick:()=>je("deny"),className:m("toggle-group-item flex-1",$e==="deny"&&"active !text-sys-red"),children:"Deny"}),e.jsx("button",{onClick:()=>je("allow"),className:m("toggle-group-item flex-1",$e==="allow"&&"active !text-sys-green"),children:"Allow"})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[e.jsx(L,{color:"muted",outline:!0,onClick:()=>{ge(!1),Fe(""),je("allow")},disabled:Q,children:"Cancel"}),e.jsx(L,{color:"primary",onClick:Ss,disabled:Q||!Te.trim(),children:Q?e.jsxs(e.Fragment,{children:[e.jsx(U,{"data-slot":"icon",className:"animate-spin"}),"Adding..."]}):"Add Key"})]})]})]})}),Se&&q&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&ce(!1),role:"dialog","aria-modal":"true","aria-labelledby":"edit-key-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"edit-key-modal-title",className:"type-micro mb-4",children:"Edit Transport Key"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Je,{label:"Key Name",type:"text",value:q.name,onChange:s=>ae({...q,name:s.target.value}),autoFocus:!0}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Flood Policy"}),e.jsxs("div",{className:"toggle-group w-full",children:[e.jsx("button",{onClick:()=>ae({...q,floodPolicy:"deny"}),className:m("toggle-group-item flex-1",q.floodPolicy==="deny"&&"active !text-sys-red"),children:"Deny"}),e.jsx("button",{onClick:()=>ae({...q,floodPolicy:"allow"}),className:m("toggle-group-item flex-1",q.floodPolicy==="allow"&&"active !text-sys-green"),children:"Allow"})]})]}),q.transport_key&&e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Transport Key"}),e.jsx("code",{className:"block bg-input-bg px-3 py-2 radius-inner border border-input-border type-code text-fg-muted overflow-x-auto",children:q.transport_key})]}),e.jsxs("div",{className:"flex justify-between gap-3 mt-6",children:[e.jsx(L,{color:"danger",outline:!0,onClick:()=>{ce(!1),be(q),de(!0),ae(null)},disabled:Q,children:"Delete"}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(L,{color:"muted",outline:!0,onClick:()=>{ce(!1),ae(null)},disabled:Q,children:"Cancel"}),e.jsx(L,{color:"primary",onClick:pt,disabled:Q||!q.name.trim(),children:Q?e.jsxs(e.Fragment,{children:[e.jsx(U,{"data-slot":"icon",className:"animate-spin"}),"Saving..."]}):"Save"})]})]})]})]})}),Ce&&le&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:s=>s.target===s.currentTarget&&de(!1),role:"dialog","aria-modal":"true","aria-labelledby":"delete-key-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"delete-key-modal-title",className:"type-micro mb-4",children:"Delete Transport Key"}),e.jsxs("p",{className:"text-fg-secondary mb-4",children:["Are you sure you want to delete ",e.jsxs("strong",{className:"text-fg-primary",children:["'",le.name,"'"]}),"?"]}),le.children&&le.children.length>0&&e.jsx("div",{className:"bg-sys-indigo/10 border border-sys-indigo/30 radius-inner p-3 mb-4",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Le,{className:"w-4 h-4 text-sys-indigo flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-fg-secondary",children:["This key has ",le.children.length," child key(s). Deleting will also remove all children."]})]})}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx(L,{color:"muted",outline:!0,onClick:()=>{de(!1),be(null)},disabled:Q,children:"Cancel"}),e.jsx(L,{color:"danger",onClick:yt,disabled:Q,children:Q?e.jsxs(e.Fragment,{children:[e.jsx(U,{"data-slot":"icon",className:"animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})}export{tn as default}; diff --git a/frontend/dist/assets/Configuration-CUBGWMgN.js b/frontend/dist/assets/Configuration-CUBGWMgN.js deleted file mode 100644 index 87f40679..00000000 --- a/frontend/dist/assets/Configuration-CUBGWMgN.js +++ /dev/null @@ -1,32 +0,0 @@ -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 pe,r as s,j as e,c,ed as Et,cL as fe,a0 as B,Y as X,bK as Y,aC as et,ec as Ae,ee as nt,ef as tt,_ as Ee,a6 as J,D as cs,S as ds,eg as us,a5 as U,cm as lt,eh as ms,B as I,ei as Rt,R as xs,V as Vt,ej as fs,ek as Mt,el as ps,em as hs,en as ys,a8 as gs,eo as Ue,I as bs,$ as js,a1 as vs}from"./index-B9Nfzawy.js";import{g as Ns,a as ks,c as ws,r as Ss,s as _s,b as Cs,u as Ts,d as Fs}from"./system-D2aLg2mB.js";import{C as Es}from"./ConfirmModal-CsrIdG-V.js";import{W as st,A as Rs,a as Ms,S as Ds,N as As}from"./AutoConfigureDialog-D-tiCDMu.js";import{i as Is,g as Ps,s as Ls,a as Ks,k as Os}from"./keycap-sfx-ByZp-njj.js";import{C as W,P as zs,a as Vs,B as Hs}from"./PageLayout-Da0xfaXb.js";import{T as Ht}from"./trash-2-BxrPvo_t.js";import{R as $s}from"./rotate-ccw-BwcqAp9U.js";import{S as qs}from"./shield-5eYUHkwt.js";import{R as Bs,K as Dt}from"./repeat-C00vzJTj.js";import{T as Me}from"./triangle-alert-_KPqiYkd.js";import{R as ee,C as ce}from"./Grid-CbgS5PRh.js";import{A as Gs}from"./antenna-DHhoJnxo.js";import{P as At}from"./plus-B7jylh_n.js";import{C as Us}from"./circle-check-m0ROsc83.js";import{R as Ws}from"./refresh-cw-hB3ADAmy.js";import{C as Xs}from"./chevron-right-jwX-OOTu.js";import"./DataBox-CCBd3sT4.js";import"./arrow-right-BbRfzTpf.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 Ys=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Js=pe("external-link",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 Qs=[["circle",{cx:"16",cy:"20",r:"2",key:"1vifvg"}],["path",{d:"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2",key:"3hgo9p"}],["path",{d:"m22 14-4.5 4.5",key:"1ef6z8"}],["path",{d:"m21 15 1 1",key:"1ejcpy"}]],Zs=pe("folder-key",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 ea=[["rect",{width:"8",height:"5",x:"14",y:"17",rx:"1",key:"19aais"}],["path",{d:"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2.5",key:"1w6v7t"}],["path",{d:"M20 17v-2a2 2 0 1 0-4 0v2",key:"pwaxnr"}]],It=pe("folder-lock",ea);/** - * @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=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],sa=pe("monitor",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 aa=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],at=pe("pencil",aa);/** - * @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:"M10.17 4.193a2 2 0 0 1 3.666.013",key:"pltmmw"}],["path",{d:"M14 21h2",key:"v4qezv"}],["path",{d:"m15.874 7.743 1 1.732",key:"10m0iw"}],["path",{d:"m18.849 12.952 1 1.732",key:"zadnam"}],["path",{d:"M21.824 18.18a2 2 0 0 1-1.835 2.824",key:"fvwuk4"}],["path",{d:"M4.024 21a2 2 0 0 1-1.839-2.839",key:"1e1kah"}],["path",{d:"m5.136 12.952-1 1.732",key:"1u4ldi"}],["path",{d:"M8 21h2",key:"i9zjee"}],["path",{d:"m8.102 7.743-1 1.732",key:"1zzo4u"}]],la=pe("triangle-dashed",na),De=1500,ue={stacked:"h-[38px]",inline:"h-[32px]"},me={stacked:"px-3",inline:"px-2.5"},xe="rounded-lg";function R({label:a,value:d,editValue:l,onSave:m,type:o="text",suffix:p,placeholder:j,readOnly:x=!1,layout:k="stacked",min:i,max:r,step:v,maxLength:F,description:b,tooltip:w,autoConfigured:h,className:f}){const[u,g]=s.useState(!1),[M,$]=s.useState(""),[y,_]=s.useState("idle"),D=s.useRef(null),P=s.useRef(!0),A=s.useRef(null),C=!x&&!!m;s.useEffect(()=>(P.current=!0,()=>{P.current=!1,A.current&&clearTimeout(A.current)}),[]);const N=s.useCallback(()=>{C&&($(l??d),g(!0),_("idle"),requestAnimationFrame(()=>{var O;return(O=D.current)==null?void 0:O.select()}))},[C,l,d]),n=s.useCallback(()=>{g(!1),$(""),_("idle")},[]),E=s.useCallback(async()=>{if(!m||y==="loading")return;if(M===(l??d)){n();return}A.current&&clearTimeout(A.current),_("loading");try{if(await m(M),!P.current)return;_("success"),g(!1),A.current=setTimeout(()=>{P.current&&_("idle")},De)}catch{if(!P.current)return;_("error"),A.current=setTimeout(()=>{P.current&&_("idle")},De)}},[m,M,l,d,n,y]),K=s.useCallback(O=>{O.key==="Enter"?(O.preventDefault(),E()):O.key==="Escape"&&(O.preventDefault(),n())},[E,n]);return k==="inline"?e.jsxs("div",{className:c("group flex items-center justify-between gap-3",f),children:[e.jsxs("div",{className:"flex items-center gap-1 truncate",children:[e.jsx("label",{className:"type-label text-fg-muted truncate",children:a}),w&&e.jsx(Et,{content:w,placement:"top",children:e.jsx("span",{className:"text-fg-muted/50 hover:text-fg-muted cursor-help transition-colors flex-shrink-0",children:e.jsx(fe,{className:"w-3 h-3"})})})]}),u?e.jsxs("div",{className:c(ue.inline,xe,me.inline,"flex items-center transition-all","bg-transparent border border-sys-blue/50 ring-1 ring-sys-blue/20","min-w-[100px]"),children:[e.jsx("input",{ref:D,type:o,value:M,onChange:O=>$(O.target.value),onKeyDown:K,placeholder:j,min:i,max:r,step:v,maxLength:F,disabled:y==="loading",className:c("bg-transparent text-fg-primary focus:outline-none type-data flex-1 min-w-0",p?"w-12 text-right":"w-full")}),p&&e.jsx("span",{className:"text-fg-muted type-data ml-1 shrink-0",children:p}),e.jsx("div",{className:"flex items-center gap-0.5 ml-2 shrink-0",children:y==="loading"?e.jsx(B,{className:"w-3.5 h-3.5 text-fg-muted animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:E,className:"p-0.5 rounded hover:bg-sys-green/15 text-sys-green transition-colors",title:"Save (Enter)",children:e.jsx(X,{className:"w-3 h-3"})}),e.jsx("button",{onClick:n,className:"p-0.5 rounded hover:bg-sys-red/15 text-fg-muted hover:text-sys-red transition-colors",title:"Cancel (Esc)",children:e.jsx(Y,{className:"w-3 h-3"})})]})})]}):e.jsxs("div",{className:c(ue.inline,xe,me.inline,"flex items-center justify-end transition-all min-w-[80px]","bg-input-bg border border-input-border",C&&"cursor-pointer hover:border-edge-strong"),onClick:C?N:void 0,children:[e.jsx("span",{className:"type-data text-fg-primary",children:d}),y==="success"&&e.jsx(X,{className:"w-3 h-3 text-sys-green ml-1.5 shrink-0"}),y==="error"&&e.jsx(Y,{className:"w-3 h-3 text-sys-red ml-1.5 shrink-0"}),y==="idle"&&h&&e.jsx(st,{className:"w-3 h-3 text-sys-blue ml-1.5 shrink-0"}),y==="idle"&&!h&&C&&e.jsx(at,{className:"w-3 h-3 text-fg-muted ml-1.5 opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]})]}):e.jsxs("div",{className:c("group",f),children:[e.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[e.jsx("label",{className:"type-label text-fg-muted",children:a}),w&&e.jsx(Et,{content:w,placement:"top",children:e.jsx("span",{className:"text-fg-muted/50 hover:text-fg-muted cursor-help transition-colors flex-shrink-0",children:e.jsx(fe,{className:"w-3 h-3"})})})]}),u?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:c(ue.stacked,xe,me.stacked,"flex items-center transition-all","bg-transparent border border-sys-blue/50 ring-1 ring-sys-blue/20"),children:[e.jsx("input",{ref:D,type:o,value:M,onChange:O=>$(O.target.value),onKeyDown:K,placeholder:j,min:i,max:r,step:v,maxLength:F,disabled:y==="loading",className:"w-full bg-transparent text-fg-primary focus:outline-none type-data flex-1 min-w-0"}),p&&e.jsx("span",{className:"text-fg-muted type-data ml-1 shrink-0",children:p}),e.jsx("div",{className:"flex items-center gap-0.5 ml-2 shrink-0",children:y==="loading"?e.jsx(B,{className:"w-3.5 h-3.5 text-fg-muted animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:E,className:"p-1 rounded hover:bg-sys-green/15 text-sys-green transition-colors",title:"Save (Enter)",children:e.jsx(X,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:n,className:"p-1 rounded hover:bg-sys-red/15 text-fg-muted hover:text-sys-red transition-colors",title:"Cancel (Esc)",children:e.jsx(Y,{className:"w-3.5 h-3.5"})})]})})]}),b&&e.jsx("p",{className:"type-data-xs text-fg-muted mt-1 ml-3",children:b})]}):e.jsxs("div",{className:c(ue.stacked,xe,me.stacked,"flex items-center transition-all","bg-input-bg border border-input-border",C&&"cursor-pointer hover:border-edge-strong"),onClick:C?N:void 0,children:[e.jsx("span",{className:"type-data text-fg-primary flex-1 whitespace-nowrap",children:d}),y==="success"&&e.jsx(X,{className:"w-3.5 h-3.5 text-sys-green shrink-0"}),y==="error"&&e.jsx(Y,{className:"w-3.5 h-3.5 text-sys-red shrink-0"}),y==="idle"&&h&&e.jsx(st,{className:"w-3.5 h-3.5 text-sys-blue shrink-0"}),y==="idle"&&!h&&C&&e.jsx(at,{className:"w-3.5 h-3.5 text-fg-muted opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]})]})}function We({label:a,value:d,editValue:l,options:m,onSave:o,readOnly:p=!1,layout:j="stacked",className:x}){const[k,i]=s.useState(!1),[r,v]=s.useState(""),[F,b]=s.useState("idle"),w=s.useRef(null),h=s.useRef(!0),f=s.useRef(null),u=!p&&!!o;s.useEffect(()=>(h.current=!0,()=>{h.current=!1,f.current&&clearTimeout(f.current)}),[]);const g=s.useCallback(()=>{u&&(v(String(l)),i(!0),b("idle"),requestAnimationFrame(()=>{var N;return(N=w.current)==null?void 0:N.focus()}))},[u,l]),M=s.useCallback(()=>{i(!1),v(""),b("idle")},[]),$=s.useCallback(async()=>{if(!(!o||F==="loading")){if(r===String(l)){M();return}f.current&&clearTimeout(f.current),b("loading");try{if(await o(r),!h.current)return;b("success"),i(!1),f.current=setTimeout(()=>{h.current&&b("idle")},De)}catch{if(!h.current)return;b("error"),f.current=setTimeout(()=>{h.current&&b("idle")},De)}}},[o,r,l,M,F]),y=s.useCallback(N=>{N.key==="Escape"&&(N.preventDefault(),M())},[M]),_=j==="inline",D=_?ue.inline:ue.stacked,P=_?me.inline:me.stacked,A=e.jsxs("div",{className:c(D,xe,P,"flex items-center transition-all relative","bg-transparent border border-sys-blue/50 ring-1 ring-sys-blue/20",_&&"min-w-[100px]"),children:[e.jsx("select",{ref:w,value:r,onChange:N=>v(N.target.value),onKeyDown:y,disabled:F==="loading",className:c("bg-transparent text-fg-primary focus:outline-none appearance-none cursor-pointer type-data flex-1 min-w-0","pr-6"),children:m.map(N=>e.jsx("option",{value:N.value,children:N.label},String(N.value)))}),e.jsx(et,{className:"absolute right-auto w-3.5 h-3.5 text-fg-muted pointer-events-none",style:{right:F==="loading"?"2rem":"3.5rem"}}),e.jsx("div",{className:"flex items-center gap-0.5 ml-1 shrink-0",children:F==="loading"?e.jsx(B,{className:c("text-fg-muted animate-spin",_?"w-3 h-3":"w-3.5 h-3.5")}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:$,className:c("rounded hover:bg-sys-green/15 text-sys-green transition-colors",_?"p-0.5":"p-1"),title:"Save",children:e.jsx(X,{className:_?"w-3 h-3":"w-3.5 h-3.5"})}),e.jsx("button",{onClick:M,className:c("rounded hover:bg-sys-red/15 text-fg-muted hover:text-sys-red transition-colors",_?"p-0.5":"p-1"),title:"Cancel (Esc)",children:e.jsx(Y,{className:_?"w-3 h-3":"w-3.5 h-3.5"})})]})})]}),C=e.jsxs("div",{className:c(D,xe,P,"flex items-center transition-all","bg-input-bg border border-input-border",u&&"cursor-pointer hover:border-edge-strong",_?"justify-end min-w-[80px]":""),onClick:u?g:void 0,children:[e.jsx("span",{className:c("type-data text-fg-primary",!_&&"flex-1"),children:d}),F==="success"&&e.jsx(X,{className:c("text-sys-green shrink-0",_?"w-3 h-3 ml-1.5":"w-3.5 h-3.5")}),F==="error"&&e.jsx(Y,{className:c("text-sys-red shrink-0",_?"w-3 h-3 ml-1.5":"w-3.5 h-3.5")}),F==="idle"&&u&&e.jsx(et,{className:c("text-fg-muted opacity-0 group-hover:opacity-100 transition-opacity shrink-0",_?"w-3 h-3 ml-1.5":"w-3.5 h-3.5")})]});return _?e.jsxs("div",{className:c("group flex items-center justify-between",x),children:[e.jsx("label",{className:"type-label text-fg-muted shrink-0",children:a}),k?A:C]}):e.jsxs("div",{className:c("group",x),children:[e.jsx("label",{className:"type-label text-fg-muted block mb-1",children:a}),k?A:C]})}async function ra(){try{return await Ae("/api/auth/tokens")}catch{return{tokens:[]}}}async function ia(a){return Ae("/api/auth/tokens",{method:"POST",body:JSON.stringify({name:a})})}async function oa(a){return Ae(`/api/auth/tokens/${a}`,{method:"DELETE"})}async function Pt(a){return Ae("/api/update_web_config",{method:"POST",body:JSON.stringify(a)})}s.memo(function(){const{theme:d}=nt(),{themeId:l}=d,m=tt.find(o=>o.meta.id===l)??tt[0];return e.jsx("div",{className:"h-10 flex items-center justify-center",children:e.jsx("span",{className:"font-medium transition-all duration-300 leading-none text-center text-fg-secondary",style:{fontFamily:"Inter, system-ui, sans-serif",fontSize:"clamp(0.75rem, 0.6rem + 1.5vw, 1.1rem)",letterSpacing:"-0.02em"},children:m.meta.name})})});const Xe=s.memo(function({compact:d=!1}){const{theme:l,setTheme:m}=nt(),{themeId:o}=l;return e.jsx("div",{className:c("grid grid-cols-2 gap-2",d?"w-full min-w-0 self-stretch":"w-full"),children:[...tt].reverse().map(p=>{const j=o===p.meta.id,x=p.meta.isDark;return e.jsxs("button",{type:"button",title:p.meta.name,className:c("flex flex-row items-stretch radius-inner transition-all duration-200 ease-out overflow-hidden cursor-pointer",d&&"h-6",j?"ring-2 ring-sys-blue scale-[1.02]":"opacity-70 hover:opacity-100"),onClick:()=>m(p.meta.id),children:[e.jsx("div",{className:c("flex-1 h-full",x?"bg-[#18181b]":"bg-[#EFF0F1]")}),e.jsx("div",{className:"flex flex-col h-full",children:p.display.palette.map((k,i)=>e.jsx("div",{className:"flex flex-1",children:k.map((r,v)=>e.jsx("div",{className:"w-2 h-full",style:{backgroundColor:r}},v))},i))})]},p.meta.id)})})});let Lt=!1,Re=null;async function ca(){if(!Lt)return Re||(Re=(async()=>{try{await Promise.all([Ee(()=>Promise.resolve({}),__vite__mapDeps([0])),Ee(()=>Promise.resolve({}),__vite__mapDeps([1])),Ee(()=>Promise.resolve({}),__vite__mapDeps([2])),Ee(()=>Promise.resolve({}),__vite__mapDeps([3]))]),Lt=!0}catch(a){console.warn("Failed to load theme fonts:",a)}})(),Re)}const Ye=s.memo(function(){const{theme:d,setTheme:l}=nt(),{themeId:m}=d,o=m==="breeze dark",p=s.useCallback(j=>{l(j?"breeze dark":"breeze light")},[l]);return e.jsx(J,{enabled:o,onChange:p,label:e.jsxs(e.Fragment,{children:["Dark Mode: ",o?e.jsx(cs,{className:"w-3.5 h-3.5 text-sys-blue inline"}):e.jsx(ds,{className:"w-3.5 h-3.5 text-[#e8a517] inline"})]}),tooltip:"Switch between dark and light mode",size:"md"})}),da=s.memo(function({layout:d="horizontal"}){return s.useEffect(()=>{ca()},[]),d==="toggle-only"?e.jsx(Ye,{}):d==="thumbnails-only"?e.jsx(Xe,{}):d==="vertical"?e.jsxs("div",{className:"flex flex-col items-start gap-3",children:[e.jsx(Ye,{}),e.jsx(Xe,{})]}):e.jsxs("div",{className:"flex items-stretch gap-4",children:[e.jsx("div",{className:"flex-shrink-0 flex items-start",children:e.jsx(Ye,{})}),e.jsx(Xe,{compact:!0})]})}),ua=1e4,Je=2e3;function Qe(a,d,l){const[m,o]=s.useState("idle"),[p,j]=s.useState(null),x=s.useRef(!0),k=s.useRef(null),i=s.useRef(null),r=s.useRef(!1),v=s.useRef("idle"),F=s.useRef(a),b=s.useRef(d),w=s.useRef(l);v.current=m,F.current=a,b.current=d,w.current=l,s.useEffect(()=>(x.current=!0,()=>{x.current=!1,k.current&&clearTimeout(k.current),i.current&&clearTimeout(i.current)}),[]);const h=s.useCallback(async u=>{if(v.current==="loading")return;const g=F.current;k.current&&clearTimeout(k.current),i.current&&clearTimeout(i.current),r.current=!1,j(u),o("loading"),k.current=setTimeout(()=>{r.current||!x.current||(j(g),o("error"),i.current=setTimeout(()=>{x.current&&(o("idle"),j(null))},Je))},ua);try{if(await b.current(u),r.current=!0,k.current&&clearTimeout(k.current),!x.current)return;o("success"),i.current=setTimeout(()=>{var M;x.current&&(o("idle"),j(null),(M=w.current)==null||M.call(w))},Je)}catch{if(r.current=!0,k.current&&clearTimeout(k.current),!x.current)return;j(g),o("error"),i.current=setTimeout(()=>{x.current&&(o("idle"),j(null))},Je)}},[]);return{enabled:p!==null?p:a,status:m,toggle:h}}function ma(){const{latitude:a,longitude:d,enabled:l,setLocation:m,enable:o,disable:p,clear:j}=us(),[x,k]=s.useState(!1),[i,r]=s.useState(""),[v,F]=s.useState(""),[b,w]=s.useState("idle"),[h,f]=s.useState(null),u=s.useRef(null),g=s.useRef(null),M=s.useRef(!0);s.useEffect(()=>(M.current=!0,()=>{M.current=!1,g.current&&clearTimeout(g.current)}),[]);const $=()=>{r((a==null?void 0:a.toFixed(6))??""),F((d==null?void 0:d.toFixed(6))??""),f(null),k(!0)},y=()=>{k(!1),f(null)};s.useEffect(()=>{if(!x)return;const N=n=>{b!=="loading"&&u.current&&!u.current.contains(n.target)&&y()};return document.addEventListener("mouseup",N),()=>document.removeEventListener("mouseup",N)},[x,b]);const _=(N,n)=>{const E=parseFloat(N),K=parseFloat(n);return isNaN(E)||isNaN(K)?"Please enter valid numbers":E<-90||E>90?"Latitude must be between -90 and 90":K<-180||K>180?"Longitude must be between -180 and 180":E===0&&K===0?"Coordinates (0, 0) are invalid":null},D=()=>{if(b==="loading")return;g.current&&clearTimeout(g.current);const N=_(i,v);if(N){f(N);return}w("loading"),f(null);const n=parseFloat(i),E=parseFloat(v);m(n,E),l||o(),w("success"),g.current=setTimeout(()=>{M.current&&(w("idle"),k(!1))},1e3)},P=()=>{l?p():o()},A=()=>{j(),k(!1)},C=a!==null&&d!==null;return e.jsx(W,{children:e.jsxs("div",{ref:u,children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx(U,{icon:e.jsx(la,{}),title:"Stealth"}),e.jsxs("div",{className:"flex items-center gap-1",children:[C&&!x&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:P,className:c("relative inline-flex h-6 w-11 items-center rounded-full transition-colors border-2 mr-2",l?"bg-toggle-on border-toggle-on":"bg-toggle-off border-edge-subtle"),title:l?"Disable stealth location":"Enable stealth location",children:e.jsx("span",{className:c("inline-block h-4 w-4 transform rounded-full bg-white transition-transform shadow-lg",l?"translate-x-5":"translate-x-0.5")})}),e.jsx("button",{onClick:A,className:"p-2 rounded-lg transition-colors text-fg-muted hover:text-sys-red hover:bg-sys-red/10",title:"Clear stealth location",children:e.jsx(Ht,{className:"w-4 h-4"})})]}),x?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:y,disabled:b==="loading",className:c("p-2 rounded-lg transition-colors",b==="loading"?"text-fg-muted cursor-not-allowed":"text-fg-muted hover:text-sys-red hover:bg-sys-red/10"),title:"Cancel",children:e.jsx(Y,{className:"w-4 h-4"})}),e.jsx("button",{onClick:D,disabled:b==="loading",className:c("p-2 rounded-lg transition-colors",b==="loading"?"text-sys-blue cursor-wait":b==="success"?"text-sys-green":b==="error"?"text-sys-red":"text-sys-green hover:bg-sys-green/10"),title:"Save",children:b==="loading"?e.jsx(B,{className:"w-4 h-4 animate-spin"}):b==="success"?e.jsx(X,{className:"w-4 h-4"}):b==="error"?e.jsx(Y,{className:"w-4 h-4"}):e.jsx(X,{className:"w-4 h-4"})})]}):e.jsx("button",{onClick:$,className:"p-2 rounded-lg transition-colors text-fg-muted hover:text-fg-primary hover:bg-subtle",title:C?"Edit stealth location":"Set stealth location",children:e.jsx(at,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"bg-sys-cyan/5 rounded-xl p-3 mb-4",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(fe,{className:"w-4 h-4 text-sys-cyan flex-shrink-0 mt-0.5"}),e.jsxs("p",{className:"type-body-sm text-fg-muted",children:[e.jsx("span",{className:"text-fg-secondary",children:"Stealth mode"})," allows you to appear on the map and in topology analysis without broadcasting your location. Coordinates are stored locally in your browser only — ",e.jsx("span",{className:"text-sys-cyan",children:"never sent to config.yaml or the mesh"}),"."]})]})}),h&&e.jsx("div",{className:"text-xs mb-3 px-2 py-1.5 rounded-md text-sys-red bg-sys-red/10",children:h}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-1",children:x?"Latitude (°)":"Latitude"}),e.jsx("div",{className:c("h-[38px] rounded-full px-4 flex items-center transition-colors","bg-subtle-fill"),children:x?e.jsx("input",{type:"number",value:i,onChange:N=>r(N.target.value),step:"0.000001",min:"-90",max:"90",placeholder:"e.g. 34.052234",className:"w-full bg-transparent text-fg-primary focus:outline-none type-data placeholder:text-fg-muted/50"}):e.jsx("span",{className:c("type-data",C&&l?"text-fg-primary":"text-fg-muted"),children:C?a.toFixed(6):"Not set"})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-1",children:x?"Longitude (°)":"Longitude"}),e.jsx("div",{className:c("h-[38px] rounded-full px-4 flex items-center transition-colors","bg-subtle-fill"),children:x?e.jsx("input",{type:"number",value:v,onChange:N=>F(N.target.value),step:"0.000001",min:"-180",max:"180",placeholder:"e.g. -118.243685",className:"w-full bg-transparent text-fg-primary focus:outline-none type-data placeholder:text-fg-muted/50"}):e.jsx("span",{className:c("type-data",C&&l?"text-fg-primary":"text-fg-muted"),children:C?d.toFixed(6):"Not set"})})]})]}),C&&!x&&e.jsx("div",{className:"mt-3 pt-3 border-t border-edge-subtle",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:c("w-2 h-2 rounded-full",l?"bg-sys-green":"bg-fg-muted")}),e.jsx("span",{className:"type-body-sm text-fg-muted",children:l?"Stealth location active — you appear on maps with these coordinates":"Stealth location disabled — coordinates saved but not in use"})]})})]})})}const Kt={quiet:{bg:"bg-sys-green/15",text:"text-sys-green"},normal:{bg:"bg-sys-blue/15",text:"text-sys-blue"},busy:{bg:"bg-sys-amber/15",text:"text-sys-amber"},congested:{bg:"bg-sys-red/15",text:"text-sys-red"}};function xa({tier:a}){const d=Kt[a]??Kt.normal;return e.jsx("span",{className:c("type-data-xs px-2.5 py-0.5 rounded-full font-medium uppercase tracking-wide",d.bg,d.text),children:a})}function de(a){if(a<60)return`${a}s`;if(a<3600){const m=Math.floor(a/60),o=a%60;return o>0?`${m}m ${o}s`:`${m}m`}const d=Math.floor(a/3600),l=Math.floor(a%3600/60);return l>0?`${d}h ${l}m`:`${d}h`}function Ze({title:a,defaultOpen:d=!1,children:l}){const[m,o]=s.useState(d);return e.jsxs("div",{className:"bg-subtle-fill radius-inner overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>o(!m),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-subtle-fill-hover transition-colors",children:[e.jsx("span",{className:"type-label text-fg-muted",children:a}),e.jsx(et,{className:c("w-4 h-4 text-fg-muted transition-transform",m&&"rotate-180")})]}),m&&e.jsx("div",{className:"px-4 pb-4 pt-1",children:l})]})}function fa(){var _,D,P,A,C,N;const{stats:a,fetchStats:d}=lt(),l=s.useRef(!0),[m,o]=s.useState(null),[p,j]=s.useState(!0),[,x]=s.useState("idle"),[k,i]=s.useState(null),[r,v]=s.useState(!1),[F,b]=s.useState(new Set);s.useEffect(()=>(l.current=!0,()=>{l.current=!1}),[]);const w=s.useCallback(async()=>{var n;try{const E=await ms();if(!l.current)return;E.success&&E.data&&((n=E.data.adaptive)!=null&&n.current_tier)?(o(E.data),j(!0)):j(!1)}catch{l.current&&j(!1)}},[]);s.useEffect(()=>{w();const n=setInterval(w,3e4);return()=>clearInterval(n)},[w]);const h=(D=(_=a==null?void 0:a.config)==null?void 0:_.repeater)==null?void 0:D.advert_rate_limit,f=(A=(P=a==null?void 0:a.config)==null?void 0:P.repeater)==null?void 0:A.advert_penalty_box,u=(N=(C=a==null?void 0:a.config)==null?void 0:C.repeater)==null?void 0:N.advert_adaptive;if(!p&&!h&&!f&&!u)return null;const g=n=>F.has(n),M=n=>{b(E=>{if(!E.has(n))return E;const K=new Set(E);return K.delete(n),K})},$=async()=>{x("loading"),i(null);try{const n=await Rt(Ds);if(!l.current)return;n.success?(b(new Set),await Promise.all([d({force:!0}).catch(()=>{}),w()])):i(n.error||"Reset failed")}catch{l.current&&i("Reset failed")}finally{l.current&&setTimeout(()=>{l.current&&(x("idle"),i(null))},2e3)}},y=async(n,E)=>{M(n),x("loading"),i(null);try{const K=await Rt({[n]:E});if(!l.current)return;K.success?(x("success"),await Promise.all([d({force:!0}).catch(()=>{}),w()])):(x("error"),i(K.error||"Failed to save"))}catch{l.current&&(x("error"),i("Failed to save"))}finally{l.current&&setTimeout(()=>{l.current&&(x("idle"),i(null))},2e3)}};return e.jsxs(W,{neomorphic:!0,children:[e.jsx(U,{icon:e.jsx(qs,{}),title:"Advert Rate Limiting",subtitle:"Token bucket, penalty box & adaptive tier controls",actions:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(I,{plain:!0,onClick:$,className:"flex items-center gap-1.5 text-zinc-500 hover:text-zinc-400 transition-colors",children:[e.jsx($s,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-body-xs font-medium hidden sm:inline",children:"Reset"})]}),e.jsxs(I,{plain:!0,onClick:()=>v(!0),className:"flex items-center gap-1.5 text-sys-blue hover:text-sys-blue/80 transition-colors",children:[e.jsx(st,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-body-xs font-medium hidden sm:inline",children:"Auto"})]})]})}),k&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:k}),m&&e.jsx("div",{className:"bg-subtle-fill radius-inner p-4 mb-4",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx(xa,{tier:m.adaptive.current_tier}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4 ml-auto",children:[e.jsxs("span",{className:"type-data-xs text-fg-muted tabular-nums",children:["OK ",e.jsx("span",{className:"data-box ml-1",children:(m.stats.adverts_allowed??0).toLocaleString()})]}),e.jsxs("span",{className:"type-data-xs text-fg-muted tabular-nums",children:["Drop ",e.jsx("span",{className:"data-box ml-1 text-sys-red",children:(m.stats.adverts_dropped??0).toLocaleString()})]}),Object.keys(m.active_penalties??{}).length>0&&e.jsxs("span",{className:"type-data-xs px-2 py-0.5 rounded-full bg-sys-red/15 text-sys-red font-medium",children:[Object.keys(m.active_penalties).length," penalized"]})]})]})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(Ze,{title:"Token Bucket of Shame",defaultOpen:!0,children:h?e.jsxs("div",{className:"space-y-4",children:[e.jsx(J,{enabled:h.enabled,onChange:async n=>y("rate_limit_enabled",n),label:e.jsxs(e.Fragment,{children:["Rate Limiting: ",e.jsx("span",{className:h.enabled?"text-sys-green":"text-sys-red",children:h.enabled?"On":"Off"})]}),tooltip:"Enable per-source token bucket rate limiting for adverts",size:"md"}),e.jsxs("div",{className:c("grid grid-cols-2 gap-4",!h.enabled&&"opacity-40 pointer-events-none"),children:[e.jsx(R,{label:"Bucket Capacity",value:String(h.bucket_capacity),type:"number",suffix:"tokens",min:1,max:100,tooltip:"How many adverts a source can send before being throttled. Each advert costs one token.",autoConfigured:g("bucket_capacity"),onSave:async n=>y("bucket_capacity",parseInt(n,10))}),e.jsx(R,{label:"Refill Tokens",value:String(h.refill_tokens),type:"number",suffix:"tokens",min:1,max:50,tooltip:"Tokens added back each refill cycle. Higher = more forgiving over time.",autoConfigured:g("refill_tokens"),onSave:async n=>y("refill_tokens",parseInt(n,10))}),e.jsx(R,{label:"Refill Interval",value:de(h.refill_interval_seconds),editValue:String(parseFloat((h.refill_interval_seconds/3600).toFixed(2))),type:"number",suffix:"hr",step:.5,min:.5,max:24,tooltip:"How often the bucket gets topped up. Shorter = faster recovery from bursts.",autoConfigured:g("refill_interval_seconds"),onSave:async n=>y("refill_interval_seconds",Math.round(parseFloat(n)*3600))}),e.jsx(R,{label:"Min Interval",value:de(h.min_interval_seconds),editValue:String(h.min_interval_seconds),type:"number",suffix:"sec",min:0,max:3600,tooltip:"Minimum gap between adverts from the same source, even if tokens are available. 0 = no minimum.",autoConfigured:g("min_interval_seconds"),onSave:async n=>y("min_interval_seconds",parseInt(n,10))})]})]}):e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Not configured on this backend."})}),e.jsx(Ze,{title:"Penalty Box",children:f?e.jsxs("div",{className:"space-y-4",children:[e.jsx(J,{enabled:f.enabled,onChange:async n=>y("penalty_enabled",n),label:e.jsxs(e.Fragment,{children:["Penalty Box: ",e.jsx("span",{className:f.enabled?"text-sys-green":"text-sys-red",children:f.enabled?"On":"Off"})]}),tooltip:"Enable escalating penalties for repeat advert violators",size:"md"}),e.jsxs("div",{className:c("grid grid-cols-2 gap-4",!f.enabled&&"opacity-40 pointer-events-none"),children:[e.jsx(R,{label:"Violation Threshold",value:String(f.violation_threshold),type:"number",suffix:"violations",min:1,max:100,tooltip:"How many rate-limit violations before a source gets penalized. Think of it as strikes before timeout.",autoConfigured:g("violation_threshold"),onSave:async n=>y("violation_threshold",parseInt(n,10))}),e.jsx(R,{label:"Base Penalty",value:de(f.base_penalty_seconds),editValue:String(parseFloat((f.base_penalty_seconds/3600).toFixed(2))),type:"number",suffix:"hr",step:.5,min:.5,max:24,tooltip:"First offense penalty duration. Repeat offenders get this multiplied.",autoConfigured:g("base_penalty_seconds"),onSave:async n=>y("base_penalty_seconds",Math.round(parseFloat(n)*3600))}),e.jsx(R,{label:"Multiplier",value:`${f.penalty_multiplier}x`,editValue:String(f.penalty_multiplier),type:"number",suffix:"x",step:.5,min:1,max:10,tooltip:"Each repeat offense multiplies the penalty by this factor. 2x means penalties double each time.",autoConfigured:g("penalty_multiplier"),onSave:async n=>y("penalty_multiplier",parseFloat(n))}),e.jsx(R,{label:"Max Penalty",value:de(f.max_penalty_seconds),editValue:String(parseFloat((f.max_penalty_seconds/3600).toFixed(2))),type:"number",suffix:"hr",step:1,min:1,max:168,tooltip:"Upper limit on penalty duration. No matter how many offenses, it won't exceed this.",autoConfigured:g("max_penalty_seconds"),onSave:async n=>y("max_penalty_seconds",Math.round(parseFloat(n)*3600))}),e.jsx(R,{label:"Violation Decay",value:de(f.violation_decay_seconds),editValue:String(parseFloat((f.violation_decay_seconds/3600).toFixed(2))),type:"number",suffix:"hr",step:1,min:1,max:168,tooltip:"How long until a source's violation count resets. Good behavior earns a clean slate.",autoConfigured:g("violation_decay_seconds"),onSave:async n=>y("violation_decay_seconds",Math.round(parseFloat(n)*3600))})]})]}):e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Not configured on this backend."})}),e.jsx(Ze,{title:"Adaptive Tiers",children:u?e.jsxs("div",{className:"space-y-4",children:[e.jsx(J,{enabled:u.enabled,onChange:async n=>y("adaptive_enabled",n),label:e.jsxs(e.Fragment,{children:["Adaptive: ",e.jsx("span",{className:u.enabled?"text-sys-green":"text-sys-red",children:u.enabled?"On":"Off"})]}),tooltip:"Dynamically adjust rate limits based on mesh activity level using EWMA smoothing",size:"md"}),e.jsxs("div",{className:c("grid grid-cols-2 gap-4",!u.enabled&&"opacity-40 pointer-events-none"),children:[e.jsx(R,{label:"EWMA α",value:String(u.ewma_alpha),type:"number",step:.01,min:.01,max:1,tooltip:"How quickly the system reacts to traffic changes. Lower = smoother, higher = more responsive.",autoConfigured:g("ewma_alpha"),onSave:async n=>y("ewma_alpha",parseFloat(n))}),e.jsx(R,{label:"Hysteresis",value:de(u.hysteresis_seconds),editValue:String(parseFloat((u.hysteresis_seconds/60).toFixed(2))),type:"number",suffix:"min",step:.5,min:0,max:60,tooltip:"Cooldown before switching tiers again. Prevents rapid flip-flopping during traffic spikes.",autoConfigured:g("hysteresis_seconds"),onSave:async n=>y("hysteresis_seconds",Math.round(parseFloat(n)*60))}),e.jsx(R,{label:"Quiet Max",value:String(u.thresholds.quiet_max),type:"number",min:0,max:1e4,suffix:"pkts/hr",tooltip:"Traffic below this = quiet mesh. Rate limits are most relaxed here.",autoConfigured:g("quiet_max"),onSave:async n=>y("quiet_max",parseFloat(n))}),e.jsx(R,{label:"Normal Max",value:String(u.thresholds.normal_max),type:"number",min:0,max:1e4,suffix:"pkts/hr",tooltip:"Traffic below this = normal activity. Standard rate limits apply.",autoConfigured:g("normal_max"),onSave:async n=>y("normal_max",parseFloat(n))}),e.jsx(R,{label:"Busy Max",value:String(u.thresholds.busy_max),type:"number",min:0,max:1e4,suffix:"pkts/hr",tooltip:"Traffic above this = congested mesh. Strictest rate limits kick in.",autoConfigured:g("busy_max"),onSave:async n=>y("busy_max",parseFloat(n))})]})]}):e.jsx("p",{className:"type-body-sm text-fg-muted",children:"Not configured on this backend."})})]}),e.jsx(Rs,{open:r,onClose:()=>v(!1),currentConfig:{tokenBucket:h,penaltyBox:f,adaptive:u},onApplied:async()=>{b(new Set(Ms)),await Promise.all([d({force:!0}).catch(()=>{}),w()])}}),e.jsx("div",{className:"bg-sys-blue/5 radius-inner p-4 mt-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-sys-blue/20 flex items-center justify-center flex-shrink-0",children:e.jsx(fe,{className:"w-4 h-4 text-sys-blue"})}),e.jsx("div",{className:"type-body-sm text-fg-muted",children:e.jsxs("p",{children:[e.jsx("span",{className:"text-fg-secondary",children:"Three layers"})," work together: the ",e.jsx("span",{className:"text-sys-blue",children:"token bucket"})," throttles per-source adverts, the ",e.jsx("span",{className:"text-sys-amber",children:"penalty box"})," escalates penalties for repeat violators, and ",e.jsx("span",{className:"text-sys-green",children:"adaptive tiers"})," adjust limits based on overall mesh activity."]})})]})})]})}const Ot={off:{label:"Off",threshold:null,description:"No loop detection. All flood packets forwarded regardless of path history.",color:"text-fg-muted"},minimal:{label:"Minimal",threshold:4,description:"Drops flood packets when your local hash appears 4+ times in the path. Catches only the most obvious routing loops.",color:"text-sys-green",recommended:!0},moderate:{label:"Moderate",threshold:2,description:"Drops flood packets when your local hash appears 2+ times in the path. Good balance for most networks.",color:"text-sys-blue"},strict:{label:"Strict",threshold:1,description:"Drops flood packets if your local hash appears even once in the path. Strongest loop prevention — may drop some legitimate retransmissions in dense meshes.",color:"text-sys-amber"}},pa=["off","minimal","moderate","strict"];function ha(){var f;const{stats:a,fetchStats:d}=lt(),l=s.useRef(!0),m=(f=a==null?void 0:a.config)==null?void 0:f.mesh,o=!!m,p=(m==null?void 0:m.loop_detect)??"off",j=Ot[p],x=a==null?void 0:a.local_hash,[k,i]=s.useState(!1),[r,v]=s.useState(null),[F,b]=s.useState("idle"),w=s.useRef(null);if(s.useEffect(()=>(l.current=!0,()=>{l.current=!1,w.current&&clearTimeout(w.current)}),[]),!a)return null;const h=async u=>{if(!(!o||u===p||k)){i(!0),v(null),w.current&&clearTimeout(w.current);try{const g=await Vt({loop_detect:u});if(!l.current)return;g.success?(b("success"),await d({force:!0}).catch(()=>{})):(b("error"),v(g.error||"Failed to save"))}catch{l.current&&(b("error"),v("Failed to save"))}finally{l.current&&(i(!1),w.current=setTimeout(()=>{l.current&&b("idle")},1500))}}};return s.useEffect(()=>{if(!r)return;const u=setTimeout(()=>{l.current&&v(null)},4e3);return()=>clearTimeout(u)},[r]),e.jsxs(W,{neomorphic:!0,children:[e.jsx(U,{icon:e.jsx(Bs,{}),title:"Flood Loop Detection",actions:F!=="idle"?e.jsxs("span",{className:"flex items-center",children:[F==="success"&&e.jsx(X,{className:"w-4 h-4 text-sys-green"}),F==="error"&&e.jsx(Y,{className:"w-4 h-4 text-sys-red"})]}):void 0}),e.jsx("p",{className:"type-label text-fg-muted mb-3",children:"Detect and drop looped flood packets in the mesh"}),!o&&e.jsxs("div",{className:"flex items-start gap-2.5 mb-3 px-3 py-2.5 radius-inner bg-sys-amber/10 text-sys-amber",children:[e.jsx(Me,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),e.jsxs("p",{className:"type-body-sm",children:["Backend does not expose mesh config. Update pyMC_Repeater to enable live configuration. Set ",e.jsx("code",{className:"font-mono text-fg-secondary",children:"loop_detect"})," in"," ",e.jsx("code",{className:"font-mono text-fg-secondary",children:"config.yaml"})," manually."]})]}),r&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:r}),e.jsx("div",{className:c("toggle-group w-full mb-4",!o&&"opacity-50 pointer-events-none"),children:pa.map(u=>{const g=Ot[u],M=u===p;return e.jsx("button",{onClick:()=>h(u),disabled:k||!o,className:c("toggle-group-item flex-1",M&&"active",M&&g.color),children:g.label},u)})}),e.jsx("div",{className:"bg-subtle-fill radius-inner p-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-sys-blue/20 flex items-center justify-center flex-shrink-0",children:e.jsx(fe,{className:"w-4 h-4 text-sys-blue"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:c("type-data-xs font-medium uppercase tracking-wide",j.color),children:j.label}),j.threshold!==null&&e.jsxs("span",{className:"data-box data-box-compact text-fg-secondary tabular-nums",children:["≥",j.threshold,"× → drop"]}),j.recommended&&e.jsx(xs,{color:"green",children:"Recommended"})]}),e.jsx("p",{className:"type-body-sm text-fg-muted mt-1",children:j.description}),x&&p!=="off"&&e.jsxs("p",{className:"type-data-xs text-fg-muted/60 mt-2 font-mono",children:["Local hash: ",x]})]})]})})]})}const ya=[{value:7.8,label:"7.8 kHz"},{value:10.4,label:"10.4 kHz"},{value:15.6,label:"15.6 kHz"},{value:20.8,label:"20.8 kHz"},{value:31.25,label:"31.25 kHz"},{value:41.7,label:"41.7 kHz"},{value:62.5,label:"62.5 kHz"},{value:125,label:"125 kHz"},{value:250,label:"250 kHz"},{value:500,label:"500 kHz"}],ga=[5,6,7,8,9,10,11,12],ba=[{value:5,label:"4/5"},{value:6,label:"4/6"},{value:7,label:"4/7"},{value:8,label:"4/8"}],zt={RADIO_CONFIG:"radioConfig"};function ja(a){if(!a)return"Never";const l=Date.now()-a*1e3,m=Math.floor(l/6e4),o=Math.floor(l/36e5),p=Math.floor(l/864e5);return m<1?"Just now":m<60?`${m}m ago`:o<24?`${o}h ago`:p<365?`${p}d ago`:`${Math.floor(p/365)}y ago`}function $t({node:a,level:d,expandedKeys:l,selectedKeyId:m,globalFloodPolicy:o,onSelect:p,onToggle:j}){const x=l.has(a.id),k=m===a.id,i=a.children&&a.children.length>0,r=o==="allow";return e.jsxs("div",{children:[e.jsxs("div",{className:c("flex items-center gap-2 h-[36px] px-3 rounded-full cursor-pointer transition-colors",k?"bg-sys-blue/15":"hover:bg-subtle-fill",r&&"opacity-50 cursor-not-allowed"),style:{marginLeft:`${d*16}px`},onClick:()=>!r&&p(a.id),children:[i?e.jsx("button",{onClick:v=>{v.stopPropagation(),j(a.id)},className:"p-1 hover:bg-subtle-fill-hover rounded-full transition-colors",children:e.jsx(Xs,{className:c("w-3.5 h-3.5 text-fg-muted transition-transform",x&&"rotate-90")})}):e.jsx("span",{className:"w-5"}),e.jsx(Zs,{className:"w-4 h-4 text-sys-blue flex-shrink-0"}),e.jsx("span",{className:"type-data text-fg-primary flex-1 truncate",children:a.name}),e.jsx("span",{className:"type-data-xs text-fg-muted hidden sm:inline",title:a.last_used?new Date(a.last_used*1e3).toLocaleString():void 0,children:ja(a.last_used)}),e.jsx("span",{className:c("type-data-xs px-2 py-0.5 rounded-full",a.floodPolicy==="allow"?"bg-sys-green/15 text-sys-green":"bg-sys-red/15 text-sys-red"),children:a.floodPolicy==="allow"?"Allow":"Deny"})]}),i&&x&&e.jsx("div",{children:a.children.map(v=>e.jsx($t,{node:v,level:d+1,expandedKeys:l,selectedKeyId:m,globalFloodPolicy:o,onSelect:p,onToggle:j},v.id))})]})}function va(){const[a,d]=s.useState(Is),[l,m]=s.useState(Ps),[o,p]=s.useState(!1),j=s.useCallback(i=>{d(i),Ls(i)},[]),x=s.useCallback(i=>{const r=parseFloat(i.target.value);m(r),Ks(r)},[]),k=s.useCallback(async()=>{o||(p(!0),await Os(),p(!1))},[o]);return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(J,{enabled:a,onChange:j,label:e.jsxs(e.Fragment,{children:["Sound: ",e.jsx("span",{className:a?"text-sys-green":"text-sys-red",children:a?"On":"Off"})]}),tooltip:"Enable or disable UI sound effects and haptic audio feedback",size:"md"}),e.jsx(I,{color:"primary",outline:!0,onClick:k,disabled:!a||o,className:"w-16 justify-center",children:o?"…":"Test"})]}),e.jsxs("div",{className:c("flex items-center gap-3",!a&&"opacity-40 pointer-events-none"),children:[e.jsx("span",{className:"type-label text-fg-muted w-14 shrink-0",children:"Volume"}),e.jsx("input",{type:"range",min:0,max:1,step:.05,value:l,onChange:x,className:"flex-1 accent-sys-blue h-1.5 cursor-pointer"}),e.jsxs("span",{className:"data-box w-16 justify-center",children:[Math.round(l*100),"%"]})]})]})}function Va(){var wt,St,_t,Ct,Tt,Ft;const{stats:a,setMode:d,clearModeMutation:l,setDutyCycleConfig:m,clearDutyCycleMutation:o,fetchStats:p,startMutation:j,clearMutation:x}=lt(),k=fs(),i=(wt=a==null?void 0:a.config)==null?void 0:wt.radio,r=(St=a==null?void 0:a.config)==null?void 0:St.repeater,v=(_t=a==null?void 0:a.config)==null?void 0:_t.duty_cycle,F=(a==null?void 0:a.node_name)||((Ct=a==null?void 0:a.config)==null?void 0:Ct.node_name)||"Unknown Node",b=(r==null?void 0:r.mode)??"forward",w=(v==null?void 0:v.enforcement_enabled)??!1,h=(Tt=a==null?void 0:a.config)==null?void 0:Tt.delays,f=s.useRef(!0);s.useEffect(()=>(f.current=!0,()=>{f.current=!1}),[]);const u=(Ft=a==null?void 0:a.config)==null?void 0:Ft.web,[g,M]=s.useState([]),[$,y]=s.useState(!1),[_,D]=s.useState(null),[P,A]=s.useState(!1),[C,N]=s.useState(""),[n,E]=s.useState(null),[K,O]=s.useState(!1),[le,Ie]=s.useState(null),[Pe,rt]=s.useState(!1),[it,ot]=s.useState(!1),[ct,dt]=s.useState(!1),[Q,qt]=s.useState([]),[Bt,ut]=s.useState(!1),[mt,z]=s.useState(null),[te,Gt]=s.useState(()=>localStorage.getItem("pymc:globalFloodPolicy")==="allow"?"allow":"deny"),xt=s.useCallback(t=>{Gt(t),localStorage.setItem("pymc:globalFloodPolicy",t)},[]),[ft,pt]=s.useState(!1),[H,Le]=s.useState(null),[Ut,Wt]=s.useState(new Set),[Ne,he]=s.useState(!1),[ke,re]=s.useState(!1),[we,ie]=s.useState(!1),[V,Z]=s.useState(null),[se,ye]=s.useState(null),[Se,_e]=s.useState(""),[Ke,ge]=s.useState("allow"),[G,oe]=s.useState(!1),[Ce,ht]=s.useState(!0),[be,Oe]=s.useState(!1),[Xt,yt]=s.useState(!0),[je,ae]=s.useState("idle"),[Yt,ze]=s.useState(!1),[Ve,Jt]=s.useState(!1),gt=s.useCallback(()=>{const t=h==null?void 0:h.tx_delay_factor;return t&&typeof t=="object"&&"parsedValue"in t?t.parsedValue??1:typeof t=="number"?t:1},[h]),bt=s.useCallback(()=>{const t=h==null?void 0:h.direct_tx_delay_factor;return typeof t=="number"?t:.5},[h]),He=s.useCallback(()=>{const t=v==null?void 0:v.max_airtime_percent;return typeof t=="number"?t:t&&typeof t=="object"&&"parsedValue"in t?t.parsedValue??6:6},[v]),$e=Qe(b==="forward",async t=>{await d(t?"forward":"monitor")},l),qe=Qe(w,async t=>{await m({max_airtime_percent:He(),enforcement_enabled:t})},o),Be=Qe((u==null?void 0:u.cors_enabled)??!1,async t=>{var T;const S=await Pt({web:{cors_enabled:t}});if(!S.success&&!((T=S.data)!=null&&T.persisted))throw new Error("CORS update failed");await p()}),q=s.useCallback(async t=>{j(zt.RADIO_CONFIG);try{const S=await Vt(t);if(!S.success)throw new Error(S.error||"Failed to save");await p({force:!0}).catch(()=>{})}finally{x(zt.RADIO_CONFIG)}},[j,x,p]);s.useEffect(()=>{(async()=>{yt(!0);try{const S=await ws();S.success&&S.data?Oe(S.data.exists):Oe(!1);const T=u==null?void 0:u.web_path;ht(!T||T==="")}catch{Oe(!1)}finally{yt(!1)}})()},[u==null?void 0:u.web_path]);const jt=async t=>{var S;if(je!=="loading"){ae("loading");try{const T=await Pt({web:{web_path:t?null:"/opt/pymc_console/web/html"}});if(!f.current)return;T.success||(S=T.data)!=null&&S.persisted?(ht(t),ae("success"),ze(!0),setTimeout(()=>{f.current&&ae("idle")},2e3)):(ae("error"),setTimeout(()=>{f.current&&ae("idle")},2e3))}catch{if(!f.current)return;ae("error"),setTimeout(()=>{f.current&&ae("idle")},2e3)}}},Qt=async()=>{if(!Ve){Jt(!0);try{await Ss(),ze(!1),setTimeout(()=>{window.location.reload()},2e3)}catch{ze(!1),setTimeout(()=>{window.location.reload()},3e3)}}},Te=s.useCallback(async()=>{y(!0),D(null);try{const t=await ra();M(t.tokens||[])}catch(t){D(t instanceof Error?t.message:"Failed to fetch tokens")}finally{y(!1)}},[]);s.useEffect(()=>{Te()},[Te]);const vt=async()=>{if(!C.trim()){D("Token name is required");return}rt(!0),D(null);try{const t=await ia(C.trim());E(t.token||null),A(!1),O(!0),N(""),await Te()}catch(t){D(t instanceof Error?t.message:"Failed to create token")}finally{rt(!1)}},Zt=async()=>{if(le){ot(!0),D(null);try{await oa(le.id),await Te(),Ie(null)}catch(t){D(t instanceof Error?t.message:"Failed to revoke token")}finally{ot(!1)}}},es=async()=>{n&&(await vs(n),dt(!0),setTimeout(()=>dt(!1),2e3))},ts=t=>t?new Date(t*1e3).toLocaleString():"Never",Nt=s.useCallback(t=>{const S=new Map,T=[];return t.forEach(L=>{const Fe={id:L.id,name:L.name,floodPolicy:L.flood_policy,transport_key:L.transport_key,last_used:L.last_used,parent_id:L.parent_id,children:[]};S.set(L.id,Fe)}),S.forEach(L=>{L.parent_id&&S.has(L.parent_id)?S.get(L.parent_id).children.push(L):T.push(L)}),T},[]),ve=s.useCallback(async()=>{ut(!0),z(null);try{const t=await Ns();if(t.success&&t.data){const S=Nt(t.data);qt(S),Le(T=>{if(T===null)return null;const L=Fe=>{for(const Ge of Fe)if(Ge.id===T||Ge.children&&L(Ge.children))return!0;return!1};return L(S)?T:null})}else z(t.error||"Failed to load transport keys")}catch(t){z(t instanceof Error?t.message:"Unknown error occurred")}finally{ut(!1)}},[Nt]);s.useEffect(()=>{ve(),ks().then(t=>{t.success&&t.data&&xt(t.data.global_flood_allow?"allow":"deny")}).catch(()=>{})},[ve]);const ne=s.useCallback((t,S)=>{for(const T of t){if(T.id===S)return T;if(T.children){const L=ne(T.children,S);if(L)return L}}return null},[]),ss=s.useCallback(()=>{if(!H)return;const t=ne(Q,H);return t==null?void 0:t.name},[H,Q,ne]),as=s.useCallback(t=>{Wt(S=>{const T=new Set(S);return T.has(t)?T.delete(t):T.add(t),T})},[]),ns=async t=>{pt(!0),z(null);try{const S=await _s(t==="allow");S.success?xt(t):z(S.error||"Failed to update global flood policy")}catch(S){z(S instanceof Error?S.message:"Failed to update global flood policy")}finally{pt(!1)}},kt=async()=>{if(!Se.trim()){z("Key name is required");return}oe(!0),z(null);try{const t=await Cs({name:Se.trim(),flood_policy:Ke,parent_id:H??void 0});t.success?(await ve(),he(!1),_e(""),ge("allow")):z(t.error||"Failed to add transport key")}catch(t){z(t instanceof Error?t.message:"Failed to add transport key")}finally{oe(!1)}},ls=async()=>{if(V){oe(!0),z(null);try{const t=await Ts(V.id,{name:V.name,flood_policy:V.floodPolicy});t.success?(await ve(),re(!1),Z(null)):z(t.error||"Failed to update transport key")}catch(t){z(t instanceof Error?t.message:"Failed to update transport key")}finally{oe(!1)}}},rs=async()=>{if(se){oe(!0),z(null);try{const t=await Fs(se.id);t.success?(await ve(),ie(!1),ye(null),Le(null)):z(t.error||"Failed to delete transport key")}catch(t){z(t instanceof Error?t.message:"Failed to delete transport key")}finally{oe(!1)}}},is=s.useCallback(()=>{if(!H)return;const t=ne(Q,H);t&&(Z({...t}),re(!0))},[H,Q,ne]);s.useEffect(()=>{const t=T=>{T.key==="Escape"&&(Ne&&(he(!1),_e(""),ge("allow")),ke&&(re(!1),Z(null)),we&&(ie(!1),ye(null)),P&&(A(!1),N("")),K&&(O(!1),E(null)))};if(Ne||ke||we||P||K)return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[Ne,ke,we,P,K]);const os=s.useCallback(()=>{if(!H)return;const t=ne(Q,H);t&&(ye(t),ie(!0))},[H,Q,ne]);return e.jsxs(zs,{children:[e.jsx(Vs,{title:"Configuration",icon:e.jsx(Mt,{})}),e.jsxs(Hs,{ready:k,children:[e.jsxs(ee,{template:"standard",children:[e.jsx(ce,{span:12,md:6,children:e.jsxs(W,{neomorphic:!0,children:[e.jsx(U,{icon:e.jsx(ps,{}),title:"Repeater Settings"}),r?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx("div",{className:"col-span-2",children:e.jsx(R,{label:"Node Name",value:F,onSave:async t=>q({node_name:t}),placeholder:"Enter node name",maxLength:50})}),e.jsx(R,{label:"Latitude",value:r.latitude!==0?r.latitude.toFixed(6):"Not set",editValue:String(r.latitude),type:"number",suffix:"°",step:1e-6,min:-90,max:90,onSave:async t=>q({latitude:parseFloat(t)})}),e.jsx(R,{label:"Longitude",value:r.longitude!==0?r.longitude.toFixed(6):"Not set",editValue:String(r.longitude),type:"number",suffix:"°",step:1e-6,min:-180,max:180,onSave:async t=>q({longitude:parseFloat(t)})}),e.jsx(R,{label:"Advert Interval",value:r.send_advert_interval_hours>0?`${r.send_advert_interval_hours}h`:"Disabled",editValue:String(r.send_advert_interval_hours),type:"number",suffix:"hours",min:0,max:48,description:"0 = disabled, 3-48 hours",onSave:async t=>q({flood_advert_interval_hours:parseInt(t,10)})}),e.jsx(R,{label:"Score-based TX",value:r.use_score_for_tx?"Enabled":"Disabled",readOnly:!0})]}):e.jsx("p",{className:"text-fg-muted",children:"Loading repeater settings..."})]})}),e.jsx(ce,{span:12,md:6,children:e.jsxs(W,{neomorphic:!0,children:[e.jsx(U,{icon:e.jsx(Gs,{}),title:"Radio Configuration"}),i?e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(R,{label:"Frequency",value:hs(i.frequency),editValue:(i.frequency/1e6).toFixed(3),type:"number",suffix:"MHz",step:.001,min:400,max:930,onSave:async t=>q({frequency_mhz:parseFloat(t)})}),e.jsx(R,{label:"TX Power",value:`${i.tx_power} dBm`,editValue:String(i.tx_power),type:"number",suffix:"dBm",min:2,max:30,onSave:async t=>q({tx_power:parseInt(t,10)})}),e.jsx(We,{label:"Bandwidth",value:ys(i.bandwidth),editValue:i.bandwidth/1e3,options:ya,onSave:async t=>q({bandwidth_khz:parseFloat(t)})}),e.jsx(We,{label:"Spreading Factor",value:`SF${i.spreading_factor}`,editValue:i.spreading_factor,options:ga.map(t=>({value:t,label:`SF${t}`})),onSave:async t=>q({spreading_factor:parseInt(t,10)})}),e.jsx(We,{label:"Coding Rate",value:`4/${i.coding_rate}`,editValue:i.coding_rate,options:ba,onSave:async t=>q({coding_rate:parseInt(t,10)})}),e.jsx(R,{label:"Preamble",value:`${i.preamble_length} symbols`,readOnly:!0})]}):e.jsx("p",{className:"text-fg-muted",children:"Loading radio configuration..."})]})})]}),e.jsxs(ee,{template:"standard",children:[e.jsx(ce,{span:12,md:6,children:e.jsxs(W,{neomorphic:!0,children:[e.jsx(U,{icon:e.jsx(gs,{}),title:"Operating Mode"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(J,{enabled:$e.enabled,onChange:$e.toggle,label:"Repeat",tooltip:"Toggles repeater or monitor mode. In monitor mode, the repeater will not repeat packets from the mesh.",status:$e.status,size:"md"}),e.jsx(J,{enabled:qe.enabled,onChange:qe.toggle,label:"Duty Cycle",tooltip:"Limit transmission time to comply with airtime utilization regulations",status:qe.status,size:"md"}),e.jsx(R,{label:"Max Airtime",value:`${He().toFixed(1)}%`,editValue:String(He()),type:"number",suffix:"%",step:.5,min:.1,max:100,onSave:async t=>{await m({max_airtime_percent:parseFloat(t),enforcement_enabled:w}),o()}}),e.jsx(R,{label:"Flood TX Delay",value:`${gt().toFixed(2)}x`,editValue:String(gt()),type:"number",suffix:"x",step:.1,min:0,max:5,onSave:async t=>q({tx_delay_factor:parseFloat(t)})}),e.jsx(R,{label:"Direct TX Delay",value:`${bt().toFixed(2)}s`,editValue:String(bt()),type:"number",suffix:"s",step:.1,min:0,max:5,onSave:async t=>q({direct_tx_delay_factor:parseFloat(t)})}),e.jsx(R,{label:"Max Flood Hops",value:String((r==null?void 0:r.max_flood_hops)??3),type:"number",min:0,max:64,description:"0–64 hops",onSave:async t=>q({max_flood_hops:parseInt(t,10)})})]})]})}),e.jsx(ce,{span:12,md:6,children:e.jsxs(W,{neomorphic:!0,children:[e.jsx(U,{icon:e.jsx(Mt,{}),title:"App Settings"}),e.jsx("p",{className:"type-body-sm text-fg-muted mb-4",children:"Appearance and web server options."}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(J,{enabled:Be.enabled,onChange:Be.toggle,label:"Enable CORS",tooltip:"Allow cross-origin API access",status:Be.status,size:"md"}),e.jsx("div",{children:e.jsx(da,{})}),e.jsx(va,{})]})]})})]}),e.jsx(ee,{template:"auto",children:e.jsx(fa,{})}),e.jsx(ee,{template:"auto",children:e.jsxs(W,{neomorphic:!0,children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-4",children:[e.jsx(U,{icon:e.jsx(It,{}),title:"Regions Transport Keys",subtitle:"Manage regional key hierarchy for flood control"}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(I,{color:"primary",outline:!0,onClick:()=>he(!0),disabled:te==="allow",children:[e.jsx(At,{"data-slot":"icon"}),"Add"]}),e.jsx(I,{color:"primary",outline:!0,onClick:is,disabled:!H||te==="allow",children:"Edit"}),e.jsx(I,{color:"danger",outline:!0,onClick:os,disabled:!H||te==="allow",children:"Delete"})]})]}),e.jsx("div",{className:"bg-subtle-fill radius-inner p-4 mb-4",children:e.jsx(J,{enabled:te==="deny",onChange:t=>ns(t?"deny":"allow"),label:e.jsxs(e.Fragment,{children:["Require Transport Keys: ",e.jsx("span",{className:te==="deny"?"text-sys-green":"text-sys-red",children:te==="deny"?"On":"Off"})]}),tooltip:"When enabled, only packets with matching transport keys are forwarded. When disabled, all packets flood freely.",status:ft?"loading":"idle",disabled:ft,dangerOff:!0,size:"md",className:"flex-row-reverse justify-between w-full"})}),mt&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:mt}),e.jsx("div",{className:"bg-subtle-fill radius-inner p-4 min-h-[120px]",children:Bt?e.jsxs("div",{className:"flex items-center justify-center py-6",children:[e.jsx(B,{className:"w-5 h-5 animate-spin text-sys-blue mr-2"}),e.jsx("span",{className:"type-body-sm text-fg-muted",children:"Loading transport keys..."})]}):Q.length===0?e.jsxs("div",{className:"text-center py-6",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-subtle-fill mx-auto mb-3 flex items-center justify-center",children:e.jsx(It,{className:"w-6 h-6 text-fg-muted/50"})}),e.jsx("p",{className:"type-body text-fg-muted",children:"No transport keys found"}),e.jsx("p",{className:"type-body-sm text-fg-muted/70 mt-1",children:"Add your first transport key to get started"})]}):e.jsx("div",{className:"space-y-1",children:Q.map(t=>e.jsx($t,{node:t,level:0,expandedKeys:Ut,selectedKeyId:H,globalFloodPolicy:te,onSelect:Le,onToggle:as},t.id))})})]})}),e.jsxs(ee,{template:"standard",children:[e.jsx(ce,{span:12,md:6,children:e.jsx(ha,{})}),e.jsx(ce,{span:12,md:6,children:e.jsxs(W,{neomorphic:!0,className:"h-full flex flex-col",children:[e.jsx(U,{icon:e.jsx(Dt,{}),title:"API Tokens"}),e.jsxs("p",{className:"type-body-sm text-fg-muted mb-3",children:["Use ",e.jsx("code",{className:"type-code bg-sys-blue/20 px-1.5 py-0.5 rounded-full text-sys-blue",children:"X-API-Key"})," header for machine-to-machine auth."]}),_&&e.jsx("div",{className:"type-body-sm mb-3 px-3 py-2 rounded-full text-sys-red bg-sys-red/10",children:_}),e.jsx("div",{className:"flex-1 flex flex-col min-h-0",children:$&&g.length===0?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(B,{className:"w-4 h-4 animate-spin text-sys-blue mr-2"}),e.jsx("span",{className:"type-body-sm text-fg-muted",children:"Loading tokens..."})]}):g.length>0?e.jsx("div",{className:"space-y-1.5 flex-1 overflow-y-auto mb-3",children:g.map(t=>e.jsxs("div",{className:"bg-subtle-fill hover:bg-subtle-fill-strong radius-inner px-3 py-2 transition-base flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"type-body-sm text-fg-primary font-medium truncate",children:t.name}),e.jsxs("span",{className:"type-data-xs text-fg-muted truncate",children:["Last used: ",ts(t.last_used)]})]}),e.jsx("button",{type:"button",onClick:()=>Ie({id:t.id,name:t.name}),disabled:it,className:"text-sys-red/70 hover:text-sys-red transition-colors flex-shrink-0 p-1",title:"Revoke token",children:e.jsx(Ht,{className:"w-3.5 h-3.5"})})]},t.id))}):e.jsxs("div",{className:"bg-subtle-fill radius-inner flex-1 flex flex-col items-center justify-center mb-3",children:[e.jsx(Dt,{className:"w-5 h-5 text-fg-muted/50 mb-2"}),e.jsx("p",{className:"type-body-sm text-fg-muted",children:"No API tokens"})]})}),e.jsxs(I,{color:"primary",outline:!0,onClick:()=>A(!0),className:"w-full justify-center mt-auto",children:[e.jsx(At,{"data-slot":"icon"}),"Create Token"]})]})})]}),e.jsx(ee,{template:"auto",children:e.jsxs(W,{neomorphic:!0,children:[e.jsx(U,{icon:e.jsx(sa,{}),title:"Web Frontend",subtitle:"Choose which web interface to use",className:"mb-4"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:c("flex items-start gap-3 p-4 bg-subtle-fill radius-card border-2 cursor-pointer transition-base",Ce?"border-sys-blue bg-sys-blue/5":"border-transparent hover:border-sys-blue/30",je==="loading"&&"opacity-50 pointer-events-none"),children:[e.jsx("input",{type:"radio",name:"frontend",checked:Ce,onChange:()=>jt(!0),disabled:je==="loading",className:"mt-1 h-4 w-4 text-sys-blue focus:ring-sys-blue focus:ring-offset-bg-elevated"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"type-body text-fg-primary font-medium",children:"Default Frontend"}),e.jsx("a",{href:"https://github.com/rightup/pyMC_Repeater",target:"_blank",rel:"noopener noreferrer",onClick:t=>t.stopPropagation(),className:"type-data-xs bg-sys-cyan/15 text-sys-cyan px-2.5 py-0.5 rounded-full font-medium hover:bg-sys-cyan/25 transition-colors",children:"@RightUp"})]}),e.jsx("div",{className:"type-body-sm text-fg-muted mt-1",children:"Built-in pyMC Repeater web interface"}),e.jsx("div",{className:"type-data-xs text-fg-muted/60 mt-1",children:"/opt/pymc_repeater/repeater/web/html"})]})]}),e.jsxs("label",{className:c("flex items-start gap-3 p-4 bg-subtle-fill radius-card border-2 cursor-pointer transition-base",Ce?"border-transparent hover:border-sys-blue/30":"border-sys-blue bg-sys-blue/5",je==="loading"&&"opacity-50 pointer-events-none"),children:[e.jsx("input",{type:"radio",name:"frontend",checked:!Ce,onChange:()=>jt(!1),disabled:je==="loading",className:"mt-1 h-4 w-4 text-sys-blue focus:ring-sys-blue focus:ring-offset-bg-elevated"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"type-body text-fg-primary font-medium",children:"PyMC Console"}),e.jsx("span",{className:"type-data-xs bg-sys-indigo/15 text-sys-indigo px-2.5 py-0.5 rounded-full font-medium",children:"@Treehouse ⚡"})]}),e.jsx("div",{className:"type-body-sm text-fg-muted mt-1",children:"Alternative web interface for pyMC Repeater"}),e.jsx("div",{className:"type-data-xs text-fg-muted/60 mt-1",children:"/opt/pymc_console/web/html"})]})]})]}),!Xt&&e.jsx("div",{className:c("bg-subtle-fill radius-card p-4",be?"border border-sys-green/20":"border border-sys-cyan/20"),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:c("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0",be?"bg-sys-green/20":"bg-sys-cyan/20"),children:be?e.jsx(Us,{className:"w-4 h-4 text-sys-green"}):e.jsx(fe,{className:"w-4 h-4 text-sys-cyan"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"type-body text-fg-primary font-medium",children:be?"PyMC Console has been detected":"PyMC Console Not Installed"}),be?e.jsxs("p",{className:"type-body-sm text-fg-muted mt-1",children:["PyMC Console is installed at ",e.jsx("code",{className:"type-code bg-sys-green/10 px-1.5 py-0.5 rounded-full text-sys-green",children:"/opt/pymc_console/web/html"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"type-body-sm text-fg-muted mt-1 mb-3",children:["PyMC Console must be installed at ",e.jsx("code",{className:"type-code bg-sys-cyan/10 px-1.5 py-0.5 rounded-full text-sys-cyan",children:"/opt/pymc_console/web/html"})," before selecting this option."]}),e.jsxs(I,{color:"primary",outline:!0,href:"https://github.com/dmduran12/pymc_console-dist",children:[e.jsx(Js,{"data-slot":"icon"}),"PyMC Console Install Instructions"]})]})]})]})}),Yt&&e.jsx("div",{className:"bg-subtle-fill radius-card p-4 border border-sys-indigo/30",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 items-start gap-3 flex-1",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-sys-indigo/20 flex items-center justify-center flex-shrink-0",children:e.jsx(Me,{className:"w-4 h-4 text-sys-indigo"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"type-body text-fg-primary font-medium",children:"Service restart required"}),e.jsx("p",{className:"type-body-sm text-fg-muted mt-1",children:"Web frontend changes will take effect after restarting the pymc-repeater service."})]})]}),e.jsx(I,{color:"warning",outline:!0,onClick:Qt,disabled:Ve,children:Ve?e.jsxs(e.Fragment,{children:[e.jsx(B,{"data-slot":"icon",className:"animate-spin"}),"Restarting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ws,{"data-slot":"icon"}),"Restart Now"]})})]})})]})]})}),a&&e.jsx(ee,{template:"auto",children:e.jsx(As,{nodeName:F,repeaterVersion:a.version,coreVersion:a.core_version,localHash:a.local_hash,publicKey:a.public_key})}),a&&((r==null?void 0:r.latitude)===0||!(r!=null&&r.latitude))&&((r==null?void 0:r.longitude)===0||!(r!=null&&r.longitude))&&e.jsx(ee,{template:"auto",children:e.jsx(ma,{})})]}),P&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:t=>t.target===t.currentTarget&&A(!1),role:"dialog","aria-modal":"true","aria-labelledby":"create-token-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"create-token-modal-title",className:"type-micro mb-4",children:"Create API Token"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ue,{label:"Token Name",type:"text",value:C,onChange:t=>N(t.target.value),placeholder:"e.g., Production Server, CI/CD Pipeline",description:"Give your token a descriptive name to identify its purpose",onKeyDown:t=>t.key==="Enter"&&vt(),autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[e.jsx(I,{color:"muted",outline:!0,onClick:()=>{A(!1),N(""),D(null)},disabled:Pe,children:"Cancel"}),e.jsx(I,{color:"primary",onClick:vt,disabled:Pe||!C.trim(),children:Pe?e.jsxs(e.Fragment,{children:[e.jsx(B,{"data-slot":"icon",className:"animate-spin"}),"Creating..."]}):"Create Token"})]})]})]})}),K&&n&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:t=>t.target===t.currentTarget&&O(!1),role:"dialog","aria-modal":"true","aria-labelledby":"show-token-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-lg w-full",children:[e.jsx("h3",{id:"show-token-modal-title",className:"type-micro mb-4",children:"Token Created Successfully"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-sys-indigo/10 border border-sys-indigo/30 radius-inner p-3",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Me,{className:"w-4 h-4 text-sys-indigo flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-fg-secondary",children:[e.jsx("strong",{children:"Save this token now!"})," For security reasons, it will not be shown again."]})]})}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-primary block mb-1.5",children:"Your API Token"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(bs,{value:n,readOnly:!0,className:"flex-1 font-mono"}),e.jsxs(I,{color:"primary",outline:!0,onClick:es,children:[ct?e.jsx(X,{"data-slot":"icon",className:"text-sys-green"}):e.jsx(js,{"data-slot":"icon"}),ct?"Copied!":"Copy"]})]})]}),e.jsxs("div",{className:"bg-sys-cyan/10 border border-sys-cyan/30 radius-inner p-3",children:[e.jsx("p",{className:"text-sm text-fg-secondary mb-2",children:e.jsx("strong",{children:"Usage Example:"})}),e.jsxs("code",{className:"block bg-sys-cyan/20 px-3 py-2 rounded type-code text-sys-cyan overflow-x-auto",children:['curl -H "X-API-Key: ',n.slice(0,12),'..." ',window.location.origin,"/api/stats"]})]}),e.jsx("div",{className:"flex justify-end mt-6",children:e.jsx(I,{color:"primary",onClick:()=>{O(!1),E(null)},children:"Done"})})]})]})}),e.jsx(Es,{isOpen:!!le,title:"Revoke API Token",message:`Are you sure you want to revoke the token '${le==null?void 0:le.name}'? This action cannot be undone.`,confirmLabel:it?"Revoking...":"Revoke",cancelLabel:"Cancel",variant:"danger",onConfirm:Zt,onCancel:()=>Ie(null)}),Ne&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:t=>t.target===t.currentTarget&&he(!1),role:"dialog","aria-modal":"true","aria-labelledby":"add-key-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"add-key-modal-title",className:"type-micro mb-4",children:"Add Transport Key"}),e.jsxs("div",{className:"space-y-4",children:[H&&e.jsxs("div",{className:"bg-sys-cyan/10 border border-sys-cyan/30 radius-inner p-3 text-sm text-fg-secondary",children:["Adding as child of: ",e.jsx("strong",{className:"text-fg-primary",children:ss()})]}),e.jsx(Ue,{label:"Key Name",type:"text",value:Se,onChange:t=>_e(t.target.value),placeholder:"e.g., Region Name, Group Key",onKeyDown:t=>t.key==="Enter"&&kt(),autoFocus:!0}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Flood Policy"}),e.jsxs("div",{className:"toggle-group w-full",children:[e.jsx("button",{onClick:()=>ge("deny"),className:c("toggle-group-item flex-1",Ke==="deny"&&"active !text-sys-red"),children:"Deny"}),e.jsx("button",{onClick:()=>ge("allow"),className:c("toggle-group-item flex-1",Ke==="allow"&&"active !text-sys-green"),children:"Allow"})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[e.jsx(I,{color:"muted",outline:!0,onClick:()=>{he(!1),_e(""),ge("allow")},disabled:G,children:"Cancel"}),e.jsx(I,{color:"primary",onClick:kt,disabled:G||!Se.trim(),children:G?e.jsxs(e.Fragment,{children:[e.jsx(B,{"data-slot":"icon",className:"animate-spin"}),"Adding..."]}):"Add Key"})]})]})]})}),ke&&V&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:t=>t.target===t.currentTarget&&re(!1),role:"dialog","aria-modal":"true","aria-labelledby":"edit-key-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"edit-key-modal-title",className:"type-micro mb-4",children:"Edit Transport Key"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ue,{label:"Key Name",type:"text",value:V.name,onChange:t=>Z({...V,name:t.target.value}),autoFocus:!0}),e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Flood Policy"}),e.jsxs("div",{className:"toggle-group w-full",children:[e.jsx("button",{onClick:()=>Z({...V,floodPolicy:"deny"}),className:c("toggle-group-item flex-1",V.floodPolicy==="deny"&&"active !text-sys-red"),children:"Deny"}),e.jsx("button",{onClick:()=>Z({...V,floodPolicy:"allow"}),className:c("toggle-group-item flex-1",V.floodPolicy==="allow"&&"active !text-sys-green"),children:"Allow"})]})]}),V.transport_key&&e.jsxs("div",{children:[e.jsx("label",{className:"type-label text-fg-muted block mb-2",children:"Transport Key"}),e.jsx("code",{className:"block bg-input-bg px-3 py-2 radius-inner border border-input-border type-code text-fg-muted overflow-x-auto",children:V.transport_key})]}),e.jsxs("div",{className:"flex justify-between gap-3 mt-6",children:[e.jsx(I,{color:"danger",outline:!0,onClick:()=>{re(!1),ye(V),ie(!0),Z(null)},disabled:G,children:"Delete"}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(I,{color:"muted",outline:!0,onClick:()=>{re(!1),Z(null)},disabled:G,children:"Cancel"}),e.jsx(I,{color:"primary",onClick:ls,disabled:G||!V.name.trim(),children:G?e.jsxs(e.Fragment,{children:[e.jsx(B,{"data-slot":"icon",className:"animate-spin"}),"Saving..."]}):"Save"})]})]})]})]})}),we&&se&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onClick:t=>t.target===t.currentTarget&&ie(!1),role:"dialog","aria-modal":"true","aria-labelledby":"delete-key-modal-title",children:e.jsxs("div",{className:"surface-modal radius-card p-6 max-w-md w-full",children:[e.jsx("h3",{id:"delete-key-modal-title",className:"type-micro mb-4",children:"Delete Transport Key"}),e.jsxs("p",{className:"text-fg-secondary mb-4",children:["Are you sure you want to delete ",e.jsxs("strong",{className:"text-fg-primary",children:["'",se.name,"'"]}),"?"]}),se.children&&se.children.length>0&&e.jsx("div",{className:"bg-sys-indigo/10 border border-sys-indigo/30 radius-inner p-3 mb-4",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Me,{className:"w-4 h-4 text-sys-indigo flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-fg-secondary",children:["This key has ",se.children.length," child key(s). Deleting will also remove all children."]})]})}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx(I,{color:"muted",outline:!0,onClick:()=>{ie(!1),ye(null)},disabled:G,children:"Cancel"}),e.jsx(I,{color:"danger",onClick:rs,disabled:G,children:G?e.jsxs(e.Fragment,{children:[e.jsx(B,{"data-slot":"icon",className:"animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})}export{Va as default}; diff --git a/frontend/dist/assets/ConfirmModal-CsrIdG-V.js b/frontend/dist/assets/ConfirmModal-CsrIdG-V.js deleted file mode 100644 index 63806c50..00000000 --- a/frontend/dist/assets/ConfirmModal-CsrIdG-V.js +++ /dev/null @@ -1 +0,0 @@ -import{r as d,j as s,aA as m,aI as x,c as f,aB as g,eq as C,B as a}from"./index-B9Nfzawy.js";import{T as j}from"./triangle-alert-_KPqiYkd.js";const p={danger:"text-sys-red",warning:"text-sys-indigo",default:"text-sys-blue"},u={danger:"danger",warning:"warning",default:"primary"};function N({isOpen:n,title:r="Confirm",message:l,confirmLabel:t="Confirm",cancelLabel:i="Cancel",variant:o="default",onConfirm:c,onCancel:e}){return s.jsxs(m,{open:n,onClose:e,size:"sm",children:[s.jsx(x,{icon:s.jsx(j,{className:f("w-5 h-5",p[o])}),title:r,onClose:e}),s.jsx(g,{children:s.jsx("p",{className:"text-sm text-fg-secondary",children:l})}),s.jsxs(C,{children:[s.jsx(a,{color:"muted",onClick:e,className:"flex-1",children:i}),s.jsx(a,{color:u[o],onClick:c,className:"flex-1",children:t})]})]})}const y=d.memo(N);export{y as C}; diff --git a/frontend/dist/assets/ConfirmModal-CtS0orbM.js b/frontend/dist/assets/ConfirmModal-CtS0orbM.js new file mode 100644 index 00000000..423f6f42 --- /dev/null +++ b/frontend/dist/assets/ConfirmModal-CtS0orbM.js @@ -0,0 +1 @@ +import{r as d,j as s,aC as x,aK as m,bY as g,c as C,aD as f,eJ as j,B as o}from"./index-i0xzpXop.js";const u={danger:"text-sys-red",warning:"text-sys-indigo",default:"text-sys-blue"},p={danger:"danger",warning:"warning",default:"primary"};function N({isOpen:n,title:r="Confirm",message:l,confirmLabel:t="Confirm",cancelLabel:i="Cancel",variant:a="default",onConfirm:c,onCancel:e}){return s.jsxs(x,{open:n,onClose:e,size:"sm",children:[s.jsx(m,{icon:s.jsx(g,{className:C("w-5 h-5",u[a])}),title:r,onClose:e}),s.jsx(f,{children:s.jsx("p",{className:"text-sm text-fg-secondary",children:l})}),s.jsxs(j,{children:[s.jsx(o,{color:"muted",onClick:e,className:"flex-1",children:i}),s.jsx(o,{color:p[a],onClick:c,className:"flex-1",children:t})]})]})}const y=d.memo(N);export{y as C}; diff --git a/frontend/dist/assets/Contacts-CkDqsspC.js b/frontend/dist/assets/Contacts-CkDqsspC.js new file mode 100644 index 00000000..c29f745f --- /dev/null +++ b/frontend/dist/assets/Contacts-CkDqsspC.js @@ -0,0 +1,23 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ContactsMapMapLibre-C3aIIydk.js","assets/index-i0xzpXop.js","assets/consumer-registry-5uDLywpC.js","assets/link-scoring-BqsMOwtz.js","assets/ConfirmModal-CtS0orbM.js","assets/variants-Bbq7uzV_.js","assets/git-branch-DrsZ9sUq.js","assets/database-gsjgeKE3.js","assets/useMapViewStore-DZlzQmak.js","assets/index-BCuGA4PV.js","assets/index-CBEGRHd5.js","assets/target-BAeWmUfa.js","assets/funnel-CitfWrkD.js","assets/plus-Bb8eT78f.js","assets/compass-0fhguiKE.js","assets/zap-tuTM-Jsw.js","assets/max-C_kLXH5u.js","assets/trash-2-DCqpUdF7.js","assets/wifi-off-CQ0s_9cO.js","assets/wifi-DYlEDPZY.js","assets/circle-alert-PnLnz8pa.js","assets/clock-F-4SScS_.js","assets/chevron-right-DsOuIRi8.js","assets/LightSparkline-DC33xzFq.js","assets/badge-colors-Dl76Mz8m.js","assets/map-pin-C051lstq.js","assets/node-types-rVJPSDxd.js","assets/BasemapLayer-Bv4kYAcR.js","assets/easing-BdzuOPcT.js","assets/usePipelineStore-BqTRxIqB.js","assets/PageLayout-B4RCJ-XT.js","assets/listbox-C1gGOelh.js","assets/element-movement-BD3SL-GU.js","assets/use-text-value-T4f0bwXS.js","assets/frozen-D4mEoVft.js","assets/MqttModeBadge-Dhi11STL.js","assets/chat-utils-BdAUDg3r.js","assets/SignalIndicator-D8uG_rJC.js","assets/CollisionExplorerModal-DAlBzVhS.js","assets/share-2-B5yQaExh.js","assets/circle-question-mark-CJCLhkb9.js","assets/map-pin-off-CPSqCYZk.js","assets/activity-DQoaymFw.js","assets/search-DsTk_ZsM.js","assets/index-oOga43RI.css","assets/maplibre-gl-B1CfjdFi.css","assets/ContactsMapMapLibre-BwWOEply.css"])))=>i.map(i=>d[i]); +import{e as xe,ar as cs,j as e,r as n,_ as is,cp as He,cq as Ie,ao as W,a0 as Ce,cr as ls,cs as me,aa as de,c3 as ds,az as Oe,ct as ye,a2 as ze,cu as ms,ac as xs,cv as us,cw as ps,cx as hs,ab as fs,cy as gs,cz as js,ad as bs,aA as ys,ae as Ne,cA as Ns,cB as vs,cC as ws,cD as Cs,bI as ee,cE as $e,Y as ks,I as Ms,bM as Ss,c as we}from"./index-i0xzpXop.js";import{useDiscoveredNodes as Ps}from"./usePipelineStore-BqTRxIqB.js";import{c as ke}from"./node-types-rVJPSDxd.js";import{P as _s,a as Rs,B as Ls}from"./PageLayout-B4RCJ-XT.js";import{L as Ts,a as le}from"./listbox-C1gGOelh.js";import{T as Fe,M as $s}from"./MqttModeBadge-Dhi11STL.js";import{u as Fs,e as Es,f as Hs,r as Is}from"./consumer-registry-5uDLywpC.js";import{e as Os,g as zs,a as Ds}from"./chat-utils-BdAUDg3r.js";import{b as Bs}from"./SignalIndicator-D8uG_rJC.js";import{C as As}from"./CollisionExplorerModal-DAlBzVhS.js";import{E as qs,T as Vs}from"./target-BAeWmUfa.js";import{S as Us}from"./share-2-B5yQaExh.js";import{C as De}from"./circle-question-mark-CJCLhkb9.js";import{M as Ws}from"./map-pin-off-CPSqCYZk.js";import{A as Be}from"./activity-DQoaymFw.js";import{T as Gs}from"./trash-2-DCqpUdF7.js";import{C as Qs}from"./ConfirmModal-CtS0orbM.js";import{M as Xs}from"./map-pin-C051lstq.js";import{S as Ys}from"./search-DsTk_ZsM.js";import{C as Zs}from"./clock-F-4SScS_.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 Js=[["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=xe("arrow-up-down",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:"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"}]],st=xe("file-digit",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:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]],at=xe("list-filter",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:"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"}]],Ae=xe("ruler",nt);class rt extends n.Component{constructor(l){super(l),this.state={hasError:!1}}static getDerivedStateFromError(l){return{hasError:!0,error:l}}render(){var l;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:((l=this.state.error)==null?void 0:l.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 ot=n.lazy(()=>is(()=>import("./ContactsMapMapLibre-C3aIIydk.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,41,42,43,44,45,46]))),Ee=()=>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..."})]})});function ct({neighbors:o,localNode:l,localHash:g,onRemoveNode:u,selectedNodeHash:j,onNodeSelected:N,highlightedEdgeKey:c,highlightedGhost:T}){return cs()===!1?e.jsx(Ee,{}):e.jsx(rt,{children:e.jsx(n.Suspense,{fallback:e.jsx(Ee,{}),children:e.jsx(ot,{neighbors:o,localNode:l,localHash:g,onRemoveNode:u,selectedNodeHash:j,onNodeSelected:N,highlightedEdgeKey:c,highlightedGhost:T})})})}function it({hash:o,className:l="",size:g="sm",collisionInfo:u,isViterbiResolved:j}){const N=He(),c=Ie(),[T,$]=n.useState(!1),w=n.useMemo(()=>W(o),[o]),p=n.useMemo(()=>u!==void 0?u:w?N.find(P=>P.prefix===w)??null:null,[w,N,u]),C=j??(c.totalPaths>0&&c.avgPathConfidence>=.7),D=n.useCallback(P=>{P.preventDefault(),P.stopPropagation(),$(!0)},[]),B=n.useCallback(()=>{$(!1)},[]);if(!p)return null;const A=g==="sm"?"w-3.5 h-3.5":"w-4 h-4",q=C?"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",S=C?`Prefix conflict resolved by Viterbi HMM (${(c.avgPathConfidence*100).toFixed(0)}% confidence)`:`Prefix conflict: ${p.candidateCount} nodes share prefix "${w}"`;return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:D,className:`inline-flex items-center justify-center p-0.5 rounded focus:outline-none focus:ring-2 transition-colors cursor-pointer touch-manipulation ${q} ${l}`,title:S,"aria-label":`View prefix conflict for ${w}${C?" (Viterbi resolved)":""}`,children:C?e.jsxs("span",{className:"relative",children:[e.jsx(qs,{className:A}),e.jsx(Ce,{className:"absolute -bottom-0.5 -right-0.5 w-2 h-2 text-sys-green"})]}):e.jsx(st,{className:A})}),T&&e.jsx(As,{isOpen:!0,prefix:p.prefix,candidateHashes:p.candidateHashes,onClose:B})]})}const lt=n.memo(it),qe=[{target:"Contacts",fn:"name",minStage:1,when:Es},{target:"Contacts",fn:"traceLinks.directed",minStage:2,when:Hs}];Is(qe);function dt(o){return o<1e3?`${Math.round(o)}m`:`${(o/1e3).toFixed(1)}km`}function mt({hash:o,contact:l,isHub:g,isNeighbor:u,distance:j,centrality:N,neighborSignal:c,collisionInfo:T,isViterbiResolved:$,pingingHash:w,pingResult:p,pingError:C,isMobile:D,metaSummary:B,metaTooltip:A,onRowClick:q,onPing:S,onRemove:P}){Fs(qe);const _=l.latitude&&l.longitude&&l.latitude!==0&&l.longitude!==0,H=l.node_name||l.name||"Unknown",I=u&&c,se=ke(l),{isRepeater:v,isCompanion:G,isRoomServer:R,isClient:Q,label:b}=se,te=u?`${b} — Direct RF contact (zero-hop neighbor)`:`${b} — Flood routing (multi-hop via mesh)`,ae=n.useCallback(()=>q(o),[q,o]);return e.jsxs("div",{className:`contacts-grid-row ${g?"bg-sys-amber/5 border-l-2 border-l-sys-amber":""} ${_?"cursor-pointer":""}`,onClick:ae,children:[e.jsxs("div",{className:"contacts-col-node flex items-center gap-2 min-w-0",children:[I&&(c==null?void 0:c.avgSnr)!==null?e.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 self-center ${ls(c.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:te,children:(()=>{if(R&&v)return e.jsxs("div",{className:"relative w-5 h-5",children:[e.jsx(me,{className:"w-5 h-5 absolute inset-0 text-sys-pink"}),e.jsx(Us,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-sys-teal"})]});if(R)return e.jsx(me,{className:"w-5 h-5 text-sys-pink"});if(v)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(de,{className:"w-3.5 h-3.5 text-sys-blue"})});if((G||Q)&&H!=="Unknown"){const{emoji:F,cleanName:ue}=Os(H);return e.jsx("div",{className:"w-6 h-6 clay-avatar",style:{"--avatar-color":zs(ue)},children:F?e.jsx("span",{className:"text-sm leading-none",children:F}):e.jsx("span",{className:"text-white text-[9px] font-bold tracking-tighter",children:Ds(H)})})}return e.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center bg-zinc-500/20",children:e.jsx(De,{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:H,children:H}),u&&e.jsx("span",{className:"contact-tag contact-tag--nbr",children:"NBR"}),g&&e.jsx("span",{className:"contact-tag contact-tag--hub",children:"HUB"}),v&&e.jsx("span",{className:"contact-tag contact-tag--rpt",children:"RPT"}),R&&e.jsx("span",{className:"contact-tag contact-tag--room",children:"ROOM"}),G&&e.jsx("span",{className:"contact-tag contact-tag--comp",children:"COMP"}),Q&&e.jsx("span",{className:"contact-tag contact-tag--client",children:"CLIENT"}),D&&e.jsx("span",{className:"contact-tag contact-tag--mobile",children:"MOB"}),!_&&e.jsx(Ws,{className:"w-3 h-3 flex-shrink-0 text-fg-muted/50"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsx(ds,{copy:!0,size:"compact",truncate:[8,6],children:o}),e.jsx(lt,{hash:o,collisionInfo:T,isViterbiResolved:$}),B&&e.jsx("span",{className:"contact-meta",title:A,children:B})]})]})]}),e.jsxs("div",{className:"contacts-col-signal flex items-center justify-end gap-2",children:[I&&(c==null?void 0:c.avgRssi)!==null&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Bs,{rssi:c.avgRssi,className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-data-xs text-fg-muted",children:Math.round(c.avgRssi)})]}),I&&(c==null?void 0:c.avgSnr)!==null&&e.jsxs("span",{className:"type-data-xs text-fg-muted",children:[c.avgSnr.toFixed(1)," dB"]})]}),e.jsx("div",{className:"contacts-col-distance flex items-center justify-end gap-1 text-fg-muted",children:j!=null&&e.jsxs(e.Fragment,{children:[e.jsx(Ae,{className:"w-3 h-3"}),e.jsx("span",{className:"type-data-xs",children:dt(j)})]})}),e.jsx("div",{className:"contacts-col-centrality flex items-center justify-end gap-1",children:N>0&&e.jsxs(e.Fragment,{children:[e.jsx(Be,{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:l.last_seen?Oe(l.last_seen):"—"})}),e.jsxs("div",{className:"contacts-col-actions flex items-center justify-end gap-1",children:[u&&e.jsx(e.Fragment,{children:p?e.jsxs("div",{className:`flex items-center gap-1 ${ye(p)?"text-sys-green":"text-fg-muted"}`,title:`RTT: ${p.rtt_ms.toFixed(0)}ms${ye(p)?` · SNR: ${p.snr_db.toFixed(1)}dB · RSSI: ${p.rssi}dBm`:""}`,children:[e.jsx(Ce,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"type-data-xs hidden sm:inline",children:ye(p)?`${p.snr_db.toFixed(1)}dB`:`${(p.rtt_ms/1e3).toFixed(1)}s`})]}):C?e.jsxs("span",{className:"text-sys-red text-xs font-medium",title:C,children:[e.jsx("span",{className:"hidden sm:inline",children:C}),e.jsx("span",{className:"sm:hidden",children:"✗"})]}):e.jsx("button",{onClick:F=>S(o,F),disabled:w!==null,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:w===o?e.jsx(ze,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4 animate-spin"}):e.jsx(Vs,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})}),e.jsx("button",{onClick:F=>{F.stopPropagation(),P(o,H)},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(Gs,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})]})]})}const xt=n.memo(mt),ut=6371e3,pt=[{field:"lastHeard",icon:Zs,label:"Recent"},{field:"distance",icon:Ae,label:"Distance"},{field:"centrality",icon:Be,label:"Centrality"}];function ht(o){switch(o){case"room_server":return"room";case"repeater":return"repeater";case"companion":return"companion";case"unknown":return"companion"}}function ft(o){const l=ke(o);return ht(l.type)}function ve(o,l){const{color:g="primary",border:u=!1}=l??{};return we("flex items-center gap-1.5 px-2 py-1.5 text-sm radius-inner transition-base",o?g==="success"?"bg-sys-green/20 text-sys-green":"bg-sys-blue/20 text-sys-blue":"text-fg-muted hover:text-fg-secondary hover-bg",u&&(o?g==="success"?"border border-sys-green/30":"border border-sys-blue/30":"border border-transparent"))}function gt(o,l,g,u){const j=(g-o)*Math.PI/180,N=(u-l)*Math.PI/180,c=Math.sin(j/2)*Math.sin(j/2)+Math.cos(o*Math.PI/180)*Math.cos(g*Math.PI/180)*Math.sin(N/2)*Math.sin(N/2),T=2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c));return ut*T}function jt(){var Le,Te;const{stats:o}=ms(),l=xs(),g=us(),u=ps(),j=hs(),N=fs(),c=gs(),T=js(),$=bs(),w=ys(),p=Ne[$],C=He(),D=Ie(),B=Ns(),A=D.totalPaths>0&&D.avgPathConfidence>=.7,q=n.useMemo(()=>{const s=new Map;for(const a of C)s.set(a.prefix,a);return s},[C]),[S,P]=n.useState(null),[_,H]=n.useState("lastHeard"),[I,se]=n.useState("desc"),[v,G]=n.useState(""),[R,Q]=n.useState(!1),[b,te]=n.useState(new Set),[ae,F]=n.useState(!1),[ue,Me]=n.useState(null),[pe,Se]=n.useState(null),[Ve,he]=n.useState(new Map),[Ue,X]=n.useState(new Map),[k,We]=n.useState(25),[V,ne]=n.useState(25),fe=n.useRef(null),Y=n.useMemo(()=>(o==null?void 0:o.neighbors)??{},[o==null?void 0:o.neighbors]),ge=Ps(),re=n.useMemo(()=>{if(ge.size===0)return Y;const s=new Set;for(const t of Object.keys(Y))s.add((t.startsWith("0x")?t.slice(2):t).toLowerCase());let a=null;for(const[t,r]of ge){const i=(t.startsWith("0x")?t.slice(2):t).toLowerCase();s.has(i)||(a||(a={...Y}),a[t]={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 a??Y},[Y,ge]),O=n.useMemo(()=>{const a=Date.now()/1e3-p.minutes*60;return Object.fromEntries(Object.entries(re).filter(([t,r])=>l.has(t)?!1:(r.last_seen??0)>=a))},[re,l,p.minutes]),L=vs(),z=o==null?void 0:o.local_hash,Ge=n.useMemo(()=>{const s=new Map;if(!z||c.size===0)return s;for(const[a,t]of c)if(a.endsWith(`→${z}`)&&t.hops.length>1){const r=a.split("→")[0],i=t.hops[t.hops.length-1];s.set(r,i)}return s},[c,z]),Qe=n.useMemo(()=>{const s=new Map;if(!z||c.size===0)return s;const a=new Map;for(const[t,r]of Object.entries(re)){const i=(t.startsWith("0x")?t.slice(2):t).toLowerCase();a.set(i,r)}for(const[t,r]of c){if(!t.endsWith(`→${z}`)||r.hops.length===0)continue;const i=t.split("→")[0],d=r.hops[0];let h=null;for(const[f,y]of a)if(f.startsWith(d.toLowerCase())){h=y.node_name??y.name??null;break}s.set(i,{prefix:d,name:h,hopCount:r.hopCount})}return s},[c,z,re]),oe=n.useMemo(()=>{const s=new Map;if(!(L!=null&&L.latitude)||!(L!=null&&L.longitude))return s;for(const[a,t]of Object.entries(O))t.latitude&&t.longitude&&t.latitude!==0&&t.longitude!==0?s.set(a,gt(L.latitude,L.longitude,t.latitude,t.longitude)):s.set(a,null);return s},[O,L]),{neighborHashSet:ce,neighborSignalMap:Xe}=n.useMemo(()=>{const s=new Set,a=new Map;for(const t of N)s.add(t.hash),a.set(t.hash,{avgRssi:t.avgRssi,avgSnr:t.avgSnr});return{neighborHashSet:s,neighborSignalMap:a}},[N]),Pe=n.useMemo(()=>{const s=v.toLowerCase().trim(),a=s==="neighbor"||s==="neighbors",t=R||a,r=b.size>0;return Object.fromEntries(Object.entries(O).filter(([i,d])=>{if(r){const y=ft(d);if(!b.has(y))return!1}if(t&&!ce.has(i))return!1;if(a||!s)return!0;const h=(d.node_name||d.name||"").toLowerCase(),f=W(i).toLowerCase();return h.includes(s)||f.includes(s)||i.toLowerCase().includes(s)}))},[O,v,R,ce,b]),x=n.useMemo(()=>{const s=Object.entries(Pe),a=v.toLowerCase().trim(),t=/^[0-9a-f]{2}(?:[0-9a-f]{2}){0,2}$/i.test(a);return s.sort(([r,i],[d,h])=>{if(t){const y=W(r).toLowerCase(),E=W(d).toLowerCase(),M=y===a,U=E===a;if(M&&!U)return-1;if(U&&!M)return 1}let f=0;switch(_){case"lastHeard":f=(i.last_seen||0)-(h.last_seen||0);break;case"distance":{const y=oe.get(r)??null,E=oe.get(d)??null;y===null&&E===null?f=0:y===null?f=1:E===null?f=-1:f=y-E;break}case"centrality":{const y=j.get(r)||0,E=j.get(d)||0;f=y-E;break}}return I==="desc"?-f:f})},[Pe,_,I,oe,j,v]),m=n.useMemo(()=>{let s=0,a=0,t=0,r=0,i=0;for(const[,d]of x){const h=ke(d),f=d.latitude&&d.longitude&&d.latitude!==0&&d.longitude!==0;switch(h.type){case"room_server":t++;break;case"repeater":a++;break;case"companion":s++;break;case"unknown":i++;break}f&&r++}return{companions:s,repeaters:a,roomServers:t,total:x.length,withLocation:r,unknown:i}},[x]),Ye=n.useMemo(()=>new Set(u),[u]),_e=n.useMemo(()=>k===0?x:x.slice(0,V),[x,V,k]);n.useEffect(()=>{ne(k||x.length)},[_,I,v,R,b,k,x.length]),n.useEffect(()=>{const s=a=>{a.target.closest("[data-dropdown]")||F(!1)};return document.addEventListener("click",s),()=>document.removeEventListener("click",s)},[]),n.useEffect(()=>{if(k===0)return;const s=new IntersectionObserver(a=>{a[0].isIntersecting&&VMath.min(t+k,x.length))},{threshold:.1,rootMargin:"100px"});return fe.current&&s.observe(fe.current),()=>s.disconnect()},[k,V,x.length]);const Ze=n.useCallback(s=>{We(s),ne(s||x.length)},[x.length]),Je=n.useCallback(s=>{_===s?se(a=>a==="desc"?"asc":"desc"):(H(s),se("desc"))},[_]),Ke=n.useCallback(s=>{const a=O[s];a!=null&&a.latitude&&(a!=null&&a.longitude)&&a.latitude!==0&&a.longitude!==0&&Me(s)},[O]),es=n.useCallback(()=>{Me(null)},[]),ss=n.useCallback((s,a)=>{P({hash:s,name:a})},[]),Re=ws((Te=(Le=o==null?void 0:o.config)==null?void 0:Le.mesh)==null?void 0:Te.path_hash_mode),ts=n.useCallback(async(s,a)=>{if(a.stopPropagation(),!pe){Se(s),he(t=>{const r=new Map(t);return r.delete(s),r}),X(t=>{const r=new Map(t);return r.delete(s),r});try{const r=`0x${W(s,Re)}`,i=await Cs(r,30);i.success&&i.data?(he(d=>new Map(d).set(s,i.data)),setTimeout(()=>{he(d=>{const h=new Map(d);return h.delete(s),h})},1e4)):(X(d=>new Map(d).set(s,i.error||"Ping failed")),setTimeout(()=>{X(d=>{const h=new Map(d);return h.delete(s),h})},5e3))}catch(t){const r=t instanceof Error?t.message:"Ping failed";X(i=>new Map(i).set(s,r)),setTimeout(()=>{X(i=>{const d=new Map(i);return d.delete(s),d})},5e3)}finally{Se(null)}}},[pe,Re]);return e.jsxs(_s,{children:[e.jsx(Rs,{title:"Contacts",icon:e.jsx(ee,{}),subtitle:e.jsx($s,{}),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(ee,{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(de,{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(me,{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(Xs,{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(De,{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(ee,{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(de,{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(me,{className:"w-3 h-3 text-sys-pink"}),e.jsx("span",{children:m.roomServers})]}),e.jsx(Fe,{ranges:Ne,selectedIndex:$,onSelect:w,size:"sm"})]}),e.jsx("div",{className:"hidden sm:block",children:e.jsx(Fe,{ranges:Ne,selectedIndex:$,onSelect:w})})]})}),e.jsxs(Ls,{children:[e.jsx(ct,{neighbors:O,localNode:L??void 0,localHash:z,onRemoveNode:g,selectedNodeHash:ue,onNodeSelected:es}),e.jsxs(ks,{noPadding:!0,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(ee,{})}),e.jsx("span",{className:"type-micro flex-shrink-0 mr-auto hidden sm:block",children:"Discovered Contacts"}),e.jsx(Ms,{type:"search",size:"sm",value:v,onChange:s=>G(s.target.value),placeholder:"Search...",leadingIcon:e.jsx(Ys,{className:"w-3.5 h-3.5"}),trailingIcon:v?e.jsx("button",{onClick:()=>{G(""),(v.toLowerCase().trim()==="neighbor"||v.toLowerCase().trim()==="neighbors")&&Q(!1)},className:"text-fg-muted hover:text-fg-secondary",children:e.jsx(Ss,{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:()=>F(!ae),className:ve(b.size>0,{border:!0}),title:"Filter by contact type",children:[e.jsx(at,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:"Filter"}),b.size>0&&e.jsx("span",{className:"tabular-nums text-xs bg-sys-blue/30 px-1 rounded",children:b.size})]}),ae&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 z-50 surface-elevated radius-inner py-1 min-w-[140px]",children:[[{key:"repeater",label:"Repeaters"},{key:"companion",label:"Companions"},{key:"room",label:"Rooms"}].map(({key:s,label:a})=>e.jsxs("button",{onClick:()=>{te(t=>{const r=new Set(t);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:we("w-4 h-4 flex items-center justify-center radius-badge border",b.has(s)?"bg-sys-blue border-sys-blue text-white":"border-edge-subtle"),children:b.has(s)&&e.jsx(Ce,{className:"w-3 h-3"})}),e.jsx("span",{className:b.has(s)?"text-fg-primary":"text-fg-secondary",children:a})]},s)),b.size>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t border-edge-subtle my-1"}),e.jsx("button",{onClick:()=>te(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"})]})]})]}),ce.size>0&&e.jsxs("button",{onClick:()=>Q(!R),className:ve(R,{color:"success",border:!0}),title:R?"Show all contacts":"Show only MeshCore neighbors (direct RF contact)",children:[e.jsx(de,{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:[pt.map(({field:s,icon:a,label:t})=>e.jsxs("button",{onClick:()=>Je(s),className:ve(_===s),title:`Sort by ${t.toLowerCase()}`,children:[e.jsx(a,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:t}),_===s&&e.jsx(Ks,{className:we("w-3 h-3",I==="asc"&&"rotate-180")})]},s)),e.jsx("div",{className:"h-4 w-px bg-border-subtle"}),e.jsxs(Ts,{value:k,onChange:Ze,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(le,{value:25,children:"25"}),e.jsx(le,{value:50,children:"50"}),e.jsx(le,{value:100,children:"100"}),e.jsx(le,{value:0,children:"All"})]})]})]}),x.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",style:{contain:"layout paint"},children:_e.map(([s,a])=>{const t=W(s),r=Ye.has(s),i=ce.has(s),d=oe.get(s)??null,h=j.get(s)||0,f=i?Xe.get(s):void 0,y=t?q.get(t)??null:null,E=T.has(s),M=i?null:Qe.get(s)??null,U=Ge.get(s)??null,je=B.get(s);let Z=null;if(je&&je.length>0){const ie=je.reduce((rs,os)=>rs+os.count,0);ie>0&&(Z=ie/24)}const be=a.first_seen?Oe(a.first_seen).replace(/ ago$/i,""):null,J=[],K=[];if(M){const ie=M.name??M.prefix;J.push(`→${ie} +${M.hopCount}`),K.push(`Gateway: ${M.name??M.prefix} (${M.hopCount} hop${M.hopCount!==1?"s":""})`)}U&&(J.push(`↙${U}`),K.push(`Last forwarder: ${U}`)),Z!==null&&(J.push(`${Z<1?"<1":Math.round(Z)}/hr`),K.push(`Packet rate: ${Z.toFixed(1)}/hr`)),be&&(J.push(be),K.push(`First seen: ${be} ago`));const as=J.join(" · "),ns=K.join(` +`);return e.jsx(xt,{hash:s,contact:a,isHub:r,isNeighbor:i,distance:d,centrality:h,neighborSignal:f,collisionInfo:y,isViterbiResolved:A,pingingHash:pe,pingResult:Ve.get(s),pingError:Ue.get(s),isMobile:E,metaSummary:as,metaTooltip:ns,onRowClick:Ke,onPing:ts,onRemove:ss},s)})}),k>0&&V0&&Vne(s=>Math.min(s+k,x.length)),className:"text-sys-blue hover:text-sys-blue/80 transition-base",children:"Load more"})]})]}):e.jsxs("div",{className:"roster-empty",children:[e.jsx(ee,{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.jsx(Qs,{isOpen:!!S,title:"Remove Contact",message:`Remove ${(S==null?void 0:S.name)||"this contact"} from the contacts list? The node will reappear if it advertises again.`,confirmLabel:"Remove",cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{S&&g(S.hash),P(null)},onCancel:()=>P(null)})]})}const zt=Object.freeze(Object.defineProperty({__proto__:null,default:jt},Symbol.toStringTag,{value:"Module"}));export{zt as C,lt as P,Ae as R}; diff --git a/frontend/dist/assets/Contacts-DgMcpPLG.js b/frontend/dist/assets/Contacts-DgMcpPLG.js deleted file mode 100644 index 5c778a3b..00000000 --- a/frontend/dist/assets/Contacts-DgMcpPLG.js +++ /dev/null @@ -1,52 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ContactsMapMapLibre-DqVXnaaM.js","assets/index-B9Nfzawy.js","assets/BasemapLayer--gGy0d8r.js","assets/consumer-registry-B_rYsmHo.js","assets/link-scoring-353AdDOu.js","assets/ConfirmModal-CsrIdG-V.js","assets/triangle-alert-_KPqiYkd.js","assets/max-BFwmL_H9.js","assets/download-BaEmSLqY.js","assets/database-CSUiI1CG.js","assets/useMapViewStore-CAlaFCdd.js","assets/index-CHkxpv0k.js","assets/refresh-cw-hB3ADAmy.js","assets/target-74Dm2pEA.js","assets/funnel-DOec69-r.js","assets/plus-B7jylh_n.js","assets/easing-VuIK-HqT.js","assets/zap-DME89Nfc.js","assets/trash-2-BxrPvo_t.js","assets/wifi-off-DoZXnx54.js","assets/wifi-BpM3uttU.js","assets/clock-CCOO2GB9.js","assets/chevron-right-jwX-OOTu.js","assets/LightSparkline-DTXOFhS4.js","assets/badge-colors-BNUqIXCA.js","assets/map-pin-Z2xK57U6.js","assets/node-types-D2DQet2e.js","assets/usePipelineStore-Dto_OrsT.js","assets/ping-kFEBCmQp.js","assets/PageLayout-Da0xfaXb.js","assets/listbox-DV2L-QZw.js","assets/element-movement-C8Yd7NWa.js","assets/MqttModeBadge-Bgn-nTpu.js","assets/chat-utils-CXtTpLY5.js","assets/SignalIndicator-BAKXIHs1.js","assets/CollisionExplorerModal-J7HE0WX3.js","assets/monitor-smartphone-zVB5GYa6.js","assets/DataBox-CCBd3sT4.js","assets/circle-question-mark-Br2ku42v.js","assets/network-BCB-csrZ.js","assets/arrow-right-BbRfzTpf.js","assets/activity-CcUqK62Y.js","assets/search-BrfwwyYC.js","assets/index-BSz_JZ6w.css","assets/BasemapLayer-B1CfjdFi.css","assets/ContactsMapMapLibre-BwWOEply.css"])))=>i.map(i=>d[i]); -import{d as P,ap as ss,j as e,r as a,_ as ts,ch as Ee,ci as Fe,am as oe,Y as ke,ax as Pe,cj as ns,ck as he,a8 as ue,R as k,cl as as,a0 as Oe,cm as rs,aa as os,cn as cs,co as is,cp as ls,a9 as ds,cq as ms,cr as xs,ab as ps,ay as us,ac as Ne,cs as hs,ct as fs,bG as re,W as gs,I as js,bK as ys,c as we}from"./index-B9Nfzawy.js";import{useDiscoveredNodes as bs}from"./usePipelineStore-Dto_OrsT.js";import{p as Ns}from"./ping-kFEBCmQp.js";import{c as Ce}from"./node-types-D2DQet2e.js";import{P as vs,a as ws,B as ks}from"./PageLayout-Da0xfaXb.js";import{L as Cs,a as pe}from"./listbox-DV2L-QZw.js";import{T as Te,M as Ms}from"./MqttModeBadge-Bgn-nTpu.js";import{u as Ss,e as _s,f as Rs,r as Ps}from"./consumer-registry-B_rYsmHo.js";import{e as Ts,g as Ls,a as $s}from"./chat-utils-CXtTpLY5.js";import{b as Es}from"./SignalIndicator-BAKXIHs1.js";import{C as Fs,S as Os}from"./CollisionExplorerModal-J7HE0WX3.js";import{E as zs,T as Hs}from"./target-74Dm2pEA.js";import{D as Ds}from"./DataBox-CCBd3sT4.js";import{C as X}from"./badge-colors-BNUqIXCA.js";import{C as ze}from"./circle-question-mark-Br2ku42v.js";import{N as As}from"./network-BCB-csrZ.js";import{A as Is}from"./arrow-right-BbRfzTpf.js";import{A as He}from"./activity-CcUqK62Y.js";import{T as Bs}from"./trash-2-BxrPvo_t.js";import{C as qs}from"./ConfirmModal-CsrIdG-V.js";import{M as Le}from"./monitor-smartphone-zVB5GYa6.js";import{M as Vs}from"./map-pin-Z2xK57U6.js";import{S as Us}from"./search-BrfwwyYC.js";import{C as Ws}from"./clock-CCOO2GB9.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 Gs=[["path",{d:"M17 7 7 17",key:"15tmo1"}],["path",{d:"M17 17H7V7",key:"1org7z"}]],Qs=P("arrow-down-left",Gs);/** - * @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:"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"}]],Ys=P("arrow-up-down",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 Xs=[["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"}]],Zs=P("calendar",Xs);/** - * @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"}]],et=P("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 st=[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]],tt=P("list-filter",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 nt=[["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=P("map-pin-off",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 rt=[["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"}]],ot=P("move",rt);/** - * @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:"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=P("radio-tower",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:"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=P("ruler",lt);/** - * @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 dt=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],mt=P("trending-down",dt);class xt extends a.Component{constructor(c){super(c),this.state={hasError:!1}}static getDerivedStateFromError(c){return{hasError:!0,error:c}}render(){var c;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:((c=this.state.error)==null?void 0:c.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 pt=a.lazy(()=>ts(()=>import("./ContactsMapMapLibre-DqVXnaaM.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,41,42,43,44,45]))),$e=()=>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..."})]})});function ut({neighbors:o,localNode:c,localHash:f,onRemoveNode:x,selectedNodeHash:g,onNodeSelected:v,highlightedEdgeKey:u,highlightedGhost:d}){return ss()===!1?e.jsx($e,{}):e.jsx(xt,{children:e.jsx(a.Suspense,{fallback:e.jsx($e,{}),children:e.jsx(pt,{neighbors:o,localNode:c,localHash:f,onRemoveNode:x,selectedNodeHash:g,onNodeSelected:v,highlightedEdgeKey:u,highlightedGhost:d})})})}function ht({hash:o,className:c="",size:f="sm",collisionInfo:x,isViterbiResolved:g}){const v=Ee(),u=Fe(),[d,T]=a.useState(!1),S=a.useMemo(()=>oe(o),[o]),L=a.useMemo(()=>x!==void 0?x:S?v.find(j=>j.prefix===S)??null:null,[S,v,x]),$=g??(u.totalPaths>0&&u.avgPathConfidence>=.7),O=a.useCallback(j=>{j.preventDefault(),j.stopPropagation(),T(!0)},[]),B=a.useCallback(()=>{T(!1)},[]);if(!L)return null;const w=f==="sm"?"w-3.5 h-3.5":"w-4 h-4",D=$?"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",_=$?`Prefix conflict resolved by Viterbi HMM (${(u.avgPathConfidence*100).toFixed(0)}% confidence)`:`Prefix conflict: ${L.candidateCount} nodes share prefix "${S}"`;return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:O,className:`inline-flex items-center justify-center p-0.5 rounded focus:outline-none focus:ring-2 transition-colors cursor-pointer touch-manipulation ${D} ${c}`,title:_,"aria-label":`View prefix conflict for ${S}${$?" (Viterbi resolved)":""}`,children:$?e.jsxs("span",{className:"relative",children:[e.jsx(zs,{className:w}),e.jsx(ke,{className:"absolute -bottom-0.5 -right-0.5 w-2 h-2 text-sys-green"})]}):e.jsx(et,{className:w})}),e.jsx(Fs,{isOpen:d,prefix:L.prefix,candidateHashes:L.candidateHashes,onClose:B})]})}const ft=a.memo(ht),Ae=[{target:"Contacts",fn:"name",minStage:1,when:_s},{target:"Contacts",fn:"traceLinks.directed",minStage:2,when:Rs}];Ps(Ae);function gt(o){return o<1e3?`${Math.round(o)}m`:`${(o/1e3).toFixed(1)}km`}function jt({hash:o,contact:c,isHub:f,isNeighbor:x,distance:g,centrality:v,sparklineData:u,neighborSignal:d,collisionInfo:T,isViterbiResolved:S,isPinging:L,isPingingThis:$,pingResult:O,pingError:B,gatewayInfo:w,lastForwarderPrefix:D,isMobile:_,pathStability:j,onRowClick:E,onPing:fe,onRemove:q}){Ss(Ae);const Z=c.latitude&&c.longitude&&c.latitude!==0&&c.longitude!==0,h=c.node_name||c.name||"Unknown",V=x&&d,z=Ce(c),{isRepeater:U,isCompanion:b,isRoomServer:W,isClient:J,label:ee}=z,ge=x?`${ee} — Direct RF contact (zero-hop neighbor)`:`${ee} — Flood routing (multi-hop via mesh)`,G=c.first_seen?Pe(c.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":""} ${Z?"cursor-pointer hover:bg-subtle-fill":""}`,onClick:()=>E(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 ${ns(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:ge,children:(()=>{if(W&&U)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(Os,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-sys-teal"})]});if(W)return e.jsx(he,{className:"w-5 h-5 text-sys-pink"});if(U)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(ue,{className:"w-3.5 h-3.5 text-sys-blue"})});if((b||J)&&h!=="Unknown"){const{emoji:y,cleanName:H}=Ts(h);return e.jsx("div",{className:"w-6 h-6 rounded-full flex items-center justify-center",style:{backgroundColor:Ls(H)},children:y?e.jsx("span",{className:"text-sm leading-none",children:y}):e.jsx("span",{className:"text-white text-[9px] font-bold tracking-tighter",children:$s(h)})})}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:h,children:h}),x&&e.jsx(k,{color:X.neighbor,compact:!0,className:"flex-shrink-0",children:"NBR"}),f&&e.jsxs(k,{color:X.hub,compact:!0,className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(As,{className:"w-3 h-3"}),"HUB"]}),U&&e.jsx(k,{color:X.repeater,compact:!0,className:"flex-shrink-0",children:"RPT"}),W&&e.jsx(k,{color:X.room,compact:!0,className:"flex-shrink-0",children:"ROOM"}),b&&e.jsx(k,{color:X.companion,compact:!0,className:"flex-shrink-0",children:"COMP"}),J&&e.jsx(k,{color:X.client,compact:!0,className:"flex-shrink-0",children:"CLIENT"}),_&&e.jsxs(k,{color:"cyan",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",children:[e.jsx(ot,{className:"w-2.5 h-2.5"}),"MOBILE"]}),!Z&&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(Ds,{copy:!0,size:"compact",truncate:[8,6],children:o}),e.jsx(ft,{hash:o,collisionInfo:T,isViterbiResolved:S}),!x&&w&&e.jsxs(k,{color:"zinc",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",title:`Via ${w.name||w.prefix} (${w.hopCount} hop${w.hopCount!==1?"s":""})`,children:[e.jsx(Is,{className:"w-2.5 h-2.5"}),e.jsx("span",{className:"font-mono",children:w.prefix}),w.hopCount>1&&e.jsxs("span",{className:"opacity-60",children:["+",w.hopCount-1]})]}),D&&!x&&e.jsxs(k,{color:"zinc",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",title:`Last forwarded by ${D}`,children:[e.jsx(Qs,{className:"w-2.5 h-2.5"}),e.jsx("span",{className:"font-mono",children:D})]}),j!=null&&j!==0&&e.jsx(k,{color:j>0?"green":"amber",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",title:j>0?"Path stability improving":"Path stability declining",children:j>0?e.jsx(as,{className:"w-2.5 h-2.5"}):e.jsx(mt,{className:"w-2.5 h-2.5"})}),u.length>0&&(()=>{const y=u.reduce((je,se)=>je+se.count,0);if(y===0)return null;const H=y/24;return e.jsxs(k,{color:"zinc",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0",title:`${y} packets in last 24h (~${H.toFixed(1)}/hr)`,children:[e.jsx(it,{className:"w-2.5 h-2.5"}),e.jsxs("span",{children:[H<1?"<1":H.toFixed(0),"/hr"]})]})})(),G&&e.jsxs(k,{color:"zinc",compact:!0,className:"flex items-center gap-0.5 flex-shrink-0 opacity-70",title:`First discovered ${G}`,children:[e.jsx(Zs,{className:"w-2.5 h-2.5"}),e.jsx("span",{children:G})]})]})]})]}),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:gt(g)})]})}),e.jsx("div",{className:"contacts-col-centrality flex items-center justify-end gap-1",children:v>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:[(v*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:c.last_seen?Pe(c.last_seen):"—"})}),e.jsxs("div",{className:"contacts-col-actions flex items-center justify-end gap-1",children:[x&&e.jsx(e.Fragment,{children:O?e.jsxs("div",{className:"flex items-center gap-1 text-sys-green",title:`RTT: ${O.rtt_ms.toFixed(0)}ms`,children:[e.jsx(ke,{className:"w-3.5 h-3.5"}),e.jsxs("span",{className:"type-data-xs hidden sm:inline",children:[O.snr_db.toFixed(1),"dB"]})]}):B?e.jsx("span",{className:"text-sys-red text-xs",title:B,children:"✗"}):e.jsx("button",{onClick:y=>fe(o,y),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:$?e.jsx(Oe,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4 animate-spin"}):e.jsx(Hs,{className:"w-3.5 h-3.5 sm:w-4 sm:h-4"})})}),e.jsx("button",{onClick:y=>{y.stopPropagation(),q(o,h)},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 yt=a.memo(jt),bt=6371e3,Nt=[],vt=[{field:"lastHeard",icon:Ws,label:"Recent"},{field:"distance",icon:De,label:"Distance"},{field:"centrality",icon:He,label:"Centrality"}];function wt(o){switch(o){case"room_server":return"room";case"repeater":return"repeater";case"companion":return"companion";case"unknown":return"companion"}}function kt(o){const c=Ce(o);return wt(c.type)}function ve(o,c){const{color:f="primary",border:x=!1}=c??{};return we("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 Ct(o,c,f,x){const g=(f-o)*Math.PI/180,v=(x-c)*Math.PI/180,u=Math.sin(g/2)*Math.sin(g/2)+Math.cos(o*Math.PI/180)*Math.cos(f*Math.PI/180)*Math.sin(v/2)*Math.sin(v/2),d=2*Math.atan2(Math.sqrt(u),Math.sqrt(1-u));return bt*d}function Mt(){const{stats:o}=rs(),c=os(),f=cs(),x=is(),g=ls(),v=ds(),u=ms(),d=xs(),T=ps(),S=us(),L=Ne[T],$=Ee(),O=Fe(),B=hs(),w=O.totalPaths>0&&O.avgPathConfidence>=.7,D=a.useMemo(()=>{const s=new Map;for(const t of $)s.set(t.prefix,t);return s},[$]),[_,j]=a.useState(null),[E,fe]=a.useState("lastHeard"),[q,Z]=a.useState("desc"),[h,V]=a.useState(""),[z,U]=a.useState(!1),[b,W]=a.useState(new Set),[J,ee]=a.useState(!1),[ge,G]=a.useState(null),[y,H]=a.useState(null),[je,se]=a.useState(new Map),[Ie,te]=a.useState(new Map),[C,Be]=a.useState(25),[Q,ce]=a.useState(25),ye=a.useRef(null),ne=a.useMemo(()=>(o==null?void 0:o.neighbors)??{},[o==null?void 0:o.neighbors]),be=bs(),ie=a.useMemo(()=>{if(be.size===0)return ne;const s=new Set;for(const n of Object.keys(ne))s.add((n.startsWith("0x")?n.slice(2):n).toLowerCase());let t=null;for(const[n,r]of be){const i=(n.startsWith("0x")?n.slice(2):n).toLowerCase();s.has(i)||(t||(t={...ne}),t[n]={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??ne},[ne,be]),A=a.useMemo(()=>{const t=Date.now()/1e3-L.minutes*60;return Object.fromEntries(Object.entries(ie).filter(([n,r])=>c.has(n)?!1:(r.last_seen??0)>=t))},[ie,c,L.minutes]),R=fs(),K=o==null?void 0:o.local_hash,qe=a.useMemo(()=>{const s=new Map;if(!K||u.size===0)return s;for(const[t,n]of u)if(t.endsWith(`→${K}`)&&n.hops.length>1){const r=t.split("→")[0],i=n.hops[n.hops.length-1];s.set(r,i)}return s},[u,K]),le=a.useMemo(()=>{const s=new Map;if(!(R!=null&&R.latitude)||!(R!=null&&R.longitude))return s;for(const[t,n]of Object.entries(A))n.latitude&&n.longitude&&n.latitude!==0&&n.longitude!==0?s.set(t,Ct(R.latitude,R.longitude,n.latitude,n.longitude)):s.set(t,null);return s},[A,R]),{neighborHashSet:de,neighborSignalMap:Ve}=a.useMemo(()=>{const s=new Set,t=new Map;for(const n of v)s.add(n.hash),t.set(n.hash,{avgRssi:n.avgRssi,avgSnr:n.avgSnr});return{neighborHashSet:s,neighborSignalMap:t}},[v]),Me=a.useMemo(()=>{const s=h.toLowerCase().trim(),t=s==="neighbor"||s==="neighbors",n=z||t,r=b.size>0;return Object.fromEntries(Object.entries(A).filter(([i,l])=>{if(r){const M=kt(l);if(!b.has(M))return!1}if(n&&!de.has(i))return!1;if(t||!s)return!0;const I=(l.node_name||l.name||"").toLowerCase(),N=oe(i).toLowerCase();return I.includes(s)||N.includes(s)||i.toLowerCase().includes(s)}))},[A,h,z,de,b]),p=a.useMemo(()=>{const s=Object.entries(Me),t=h.toLowerCase().trim(),n=t.length===2&&/^[0-9a-f]{2}$/i.test(t);return s.sort(([r,i],[l,I])=>{if(n){const M=oe(r).toLowerCase(),F=oe(l).toLowerCase(),ae=M===t,me=F===t;if(ae&&!me)return-1;if(me&&!ae)return 1}let N=0;switch(E){case"lastHeard":N=(i.last_seen||0)-(I.last_seen||0);break;case"distance":{const M=le.get(r)??null,F=le.get(l)??null;M===null&&F===null?N=0:M===null?N=1:F===null?N=-1:N=M-F;break}case"centrality":{const M=g.get(r)||0,F=g.get(l)||0;N=M-F;break}}return q==="desc"?-N:N})},[Me,E,q,le,g,h]),m=a.useMemo(()=>{let s=0,t=0,n=0,r=0,i=0;for(const[,l]of p){const I=Ce(l),N=l.latitude&&l.longitude&&l.latitude!==0&&l.longitude!==0;switch(I.type){case"room_server":n++;break;case"repeater":t++;break;case"companion":s++;break;case"unknown":i++;break}N&&r++}return{companions:s,repeaters:t,roomServers:n,total:p.length,withLocation:r,unknown:i}},[p]),Ue=a.useMemo(()=>new Set(x),[x]),Se=a.useMemo(()=>C===0?p:p.slice(0,Q),[p,Q,C]);a.useEffect(()=>{ce(C||p.length)},[E,q,h,z,b,C,p.length]),a.useEffect(()=>{const s=t=>{t.target.closest("[data-dropdown]")||ee(!1)};return document.addEventListener("click",s),()=>document.removeEventListener("click",s)},[]),a.useEffect(()=>{if(C===0)return;const s=new IntersectionObserver(t=>{t[0].isIntersecting&&QMath.min(n+C,p.length))},{threshold:.1,rootMargin:"100px"});return ye.current&&s.observe(ye.current),()=>s.disconnect()},[C,Q,p.length]);const We=a.useCallback(s=>{Be(s),ce(s||p.length)},[p.length]),Ge=a.useCallback(s=>{E===s?Z(t=>t==="desc"?"asc":"desc"):(fe(s),Z("desc"))},[E]),Qe=a.useCallback(s=>{const t=A[s];t!=null&&t.latitude&&(t!=null&&t.longitude)&&t.latitude!==0&&t.longitude!==0&&G(s)},[A]),Ke=a.useCallback(()=>{G(null)},[]),Ye=a.useCallback((s,t)=>{j({hash:s,name:t})},[]),Xe=a.useCallback(async(s,t)=>{if(t.stopPropagation(),!y){H(s),se(n=>{const r=new Map(n);return r.delete(s),r}),te(n=>{const r=new Map(n);return r.delete(s),r});try{const n=s.startsWith("0x")?s.slice(0,4):`0x${s.slice(0,2)}`,r=await Ns(n,30);r.success&&r.data?(se(i=>new Map(i).set(s,r.data)),setTimeout(()=>{se(i=>{const l=new Map(i);return l.delete(s),l})},1e4)):(te(i=>new Map(i).set(s,r.error||"Ping failed")),setTimeout(()=>{te(i=>{const l=new Map(i);return l.delete(s),l})},5e3))}catch(n){const r=n instanceof Error?n.message:"Ping failed";te(i=>new Map(i).set(s,r)),setTimeout(()=>{te(i=>{const l=new Map(i);return l.delete(s),l})},5e3)}finally{H(null)}}},[y]);return e.jsxs(vs,{children:[e.jsx(ws,{title:"Contacts",icon:e.jsx(re,{}),subtitle:e.jsx(Ms,{}),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(re,{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(ue,{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(Vs,{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(re,{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(ue,{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(Te,{ranges:Ne,selectedIndex:T,onSelect:S,size:"sm"})]}),e.jsx("div",{className:"hidden sm:block",children:e.jsx(Te,{ranges:Ne,selectedIndex:T,onSelect:S})})]})}),e.jsxs(ks,{children:[e.jsx(ut,{neighbors:A,localNode:R??void 0,localHash:K,onRemoveNode:f,selectedNodeHash:ge,onNodeSelected:Ke}),e.jsxs(gs,{noPadding:!0,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(re,{})}),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:h,onChange:s=>V(s.target.value),placeholder:"Search...",leadingIcon:e.jsx(Us,{className:"w-3.5 h-3.5"}),trailingIcon:h?e.jsx("button",{onClick:()=>{V(""),(h.toLowerCase().trim()==="neighbor"||h.toLowerCase().trim()==="neighbors")&&U(!1)},className:"text-fg-muted hover:text-fg-secondary",children:e.jsx(ys,{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:()=>ee(!J),className:ve(b.size>0,{border:!0}),title:"Filter by contact type",children:[e.jsx(tt,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:"Filter"}),b.size>0&&e.jsx("span",{className:"tabular-nums text-xs bg-sys-blue/30 px-1 rounded",children:b.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:()=>{W(n=>{const r=new Set(n);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:we("w-4 h-4 flex items-center justify-center radius-badge border",b.has(s)?"bg-sys-blue border-sys-blue text-white":"border-edge-subtle"),children:b.has(s)&&e.jsx(ke,{className:"w-3 h-3"})}),e.jsx("span",{className:b.has(s)?"text-fg-primary":"text-fg-secondary",children:t})]},s)),b.size>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t border-edge-subtle my-1"}),e.jsx("button",{onClick:()=>W(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:()=>U(!z),className:ve(z,{color:"success",border:!0}),title:z?"Show all contacts":"Show only MeshCore neighbors (direct RF contact)",children:[e.jsx(ue,{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:[vt.map(({field:s,icon:t,label:n})=>e.jsxs("button",{onClick:()=>Ge(s),className:ve(E===s),title:`Sort by ${n.toLowerCase()}`,children:[e.jsx(t,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden xl:inline",children:n}),E===s&&e.jsx(Ys,{className:we("w-3 h-3",q==="asc"&&"rotate-180")})]},s)),e.jsx("div",{className:"h-4 w-px bg-border-subtle"}),e.jsxs(Cs,{value:C,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:Se.map(([s,t])=>{const n=oe(s),r=Ue.has(s),i=de.has(s),l=le.get(s)??null,I=g.get(s)||0,N=i?Ve.get(s):void 0,M=n?D.get(n)??null:null,F=B.get(s)??Nt;let ae=null;if(!i&&K&&u.size>0){const Je=`${s}→${K}`,xe=u.get(Je);if(xe&&xe.hops.length>0){const _e=xe.hops[0],Re=Object.keys(ie).find(es=>es.toUpperCase().startsWith(_e.toUpperCase())),Y=Re?ie[Re]:null;ae={prefix:_e,name:(Y==null?void 0:Y.node_name)??(Y==null?void 0:Y.name)??null,hopCount:xe.hopCount}}}const me=d.has(s),Ze=qe.get(s)??null;return e.jsx(yt,{hash:s,contact:t,isHub:r,isNeighbor:i,distance:l,centrality:I,sparklineData:F,neighborSignal:N,collisionInfo:M,isViterbiResolved:w,isPinging:y!==null,isPingingThis:y===s,pingResult:je.get(s),pingError:Ie.get(s),gatewayInfo:ae,lastForwarderPrefix:Ze,isMobile:me,onRowClick:Qe,onPing:Xe,onRemove:Ye},s)})}),C>0&&Q0&&Qce(s=>Math.min(s+C,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(re,{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.jsx(qs,{isOpen:!!_,title:"Remove Contact",message:`Remove ${(_==null?void 0:_.name)||"this contact"} from the contacts list? The node will reappear if it advertises again.`,confirmLabel:"Remove",cancelLabel:"Cancel",variant:"danger",onConfirm:()=>{_&&f(_.hash),j(null)},onCancel:()=>j(null)})]})}const Xt=Object.freeze(Object.defineProperty({__proto__:null,default:Mt},Symbol.toStringTag,{value:"Module"}));export{Xt as C,ft as P,De as R,mt as T}; diff --git a/frontend/dist/assets/ContactsMapMapLibre-C3aIIydk.js b/frontend/dist/assets/ContactsMapMapLibre-C3aIIydk.js new file mode 100644 index 00000000..7e710a4f --- /dev/null +++ b/frontend/dist/assets/ContactsMapMapLibre-C3aIIydk.js @@ -0,0 +1,125 @@ +import{e as N0,an as na,r as j,gA as ia,cu as sa,dp as oa,dq as la,j as m,aC as co,dr as aa,aD as fo,m as qt,a0 as Hr,dK as ho,c as zr,a2 as Gn,O as i0,Z as dr,gB as Un,gC as mo,gD as ua,cj as ca,cq as fa,cs as ha,dV as go,ap as po,aE as yo,d as v0,b as pr,B as Lt,dG as da,cl as li,E as Li,S as Ni,dx as xo,t as wo,c$ as vo,aa as bo,bM as Gr,bI as as,gE as ko,Q as ma,a6 as ga,dF as pa,gF as ya,az as Co,bT as us,bV as xa,a1 as Vn,a3 as Wn,cn as wa,b9 as va,f1 as Eo,gG as ba,gH as ka,gI as Ca,gJ as Ea,aR as So,V as mt,gK as Sa,gL as Mo,gM as Ma,ao as b0,bP as Bo,dw as Ba,gN as Do,gO as _o,cb as Da,gy as _a,ce as Ta,du as To,dy as ja,ab as Ra,gP as Ia,fd as La,gQ as ai,gR as Na}from"./index-i0xzpXop.js";import{u as J0,S as L0,L as $t,M as Fa,b as Pa}from"./maplibre-gl-B20pCOz8.js";import{u as jo,r as Ro,e as cs,f as fs,g as Qa}from"./consumer-registry-5uDLywpC.js";import{L as Fn,c as Oa}from"./link-scoring-BqsMOwtz.js";import{C as za}from"./ConfirmModal-CtS0orbM.js";import{s as Ha,a as Ga,M as Ua}from"./variants-Bbq7uzV_.js";import{G as xi}from"./git-branch-DrsZ9sUq.js";import{D as Va}from"./database-gsjgeKE3.js";import{H as Wa,A as un,D as hs,p as Ya,c as Ka,u as lr}from"./useMapViewStore-DZlzQmak.js";import{E as Io}from"./target-BAeWmUfa.js";import{F as Za}from"./funnel-CitfWrkD.js";import{P as $a}from"./plus-Bb8eT78f.js";import{C as qa}from"./compass-0fhguiKE.js";import{Z as Ja}from"./zap-tuTM-Jsw.js";import{b as Xa,e as Au,a as Lo,m as ds,E as eu,u as tu,G as ru,g as nu,d as iu,f as su}from"./max-C_kLXH5u.js";import{T as ou}from"./trash-2-DCqpUdF7.js";import{W as lu}from"./wifi-off-CQ0s_9cO.js";import{W as au}from"./wifi-DYlEDPZY.js";import{C as uu}from"./circle-alert-PnLnz8pa.js";import{C as No}from"./clock-F-4SScS_.js";import{C as cu}from"./chevron-right-DsOuIRi8.js";import{L as fu}from"./LightSparkline-DC33xzFq.js";import{P as Fo,R as hu}from"./Contacts-CkDqsspC.js";import{H as On,C as s0,N as du,a as mu}from"./badge-colors-Dl76Mz8m.js";import{M as gu}from"./map-pin-C051lstq.js";import{c as ms}from"./node-types-rVJPSDxd.js";import{B as pu}from"./BasemapLayer-Bv4kYAcR.js";import{a as Po,b as wi,c as yu}from"./easing-BdzuOPcT.js";import"./index-BCuGA4PV.js";import"./index-CBEGRHd5.js";import"./usePipelineStore-BqTRxIqB.js";import"./PageLayout-B4RCJ-XT.js";import"./listbox-C1gGOelh.js";import"./element-movement-BD3SL-GU.js";import"./use-text-value-T4f0bwXS.js";import"./frozen-D4mEoVft.js";import"./MqttModeBadge-Dhi11STL.js";import"./chat-utils-BdAUDg3r.js";import"./SignalIndicator-D8uG_rJC.js";import"./CollisionExplorerModal-DAlBzVhS.js";import"./share-2-B5yQaExh.js";import"./circle-question-mark-CJCLhkb9.js";import"./map-pin-off-CPSqCYZk.js";import"./activity-DQoaymFw.js";import"./search-DsTk_ZsM.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 xu=[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]],vi=N0("boxes",xu);/** + * @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 wu=[["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"}]],Qo=N0("ghost",wu);/** + * @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 vu=[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]],bu=N0("map",vu);/** + * @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 ku=[["path",{d:"m8 3 4 8 5-5 5 15H2L8 3z",key:"otkl63"}]],Cu=N0("mountain",ku);/** + * @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 Eu=[["path",{d:"M6 8.32a7.43 7.43 0 0 1 0 7.36",key:"9iaqei"}],["path",{d:"M9.46 6.21a11.76 11.76 0 0 1 0 11.58",key:"1yha7l"}],["path",{d:"M12.91 4.1a15.91 15.91 0 0 1 .01 15.8",key:"4iu2gk"}],["path",{d:"M16.37 2a20.16 20.16 0 0 1 0 20",key:"sap9u2"}]],Oo=N0("nfc",Eu);/** + * @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 Su=[["path",{d:"M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2",key:"wuwx1p"}]],Mu=N0("sigma",Su);/** + * @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 Bu=[["polyline",{points:"14.5 17.5 3 6 3 3 6 3 17.5 14.5",key:"1hfsw2"}],["line",{x1:"13",x2:"19",y1:"19",y2:"13",key:"1vrmhu"}],["line",{x1:"16",x2:"20",y1:"16",y2:"20",key:"1bron3"}],["line",{x1:"19",x2:"21",y1:"21",y2:"19",key:"13pww6"}],["polyline",{points:"14.5 6.5 18 3 21 3 21 6 17.5 9.5",key:"hbey2j"}],["line",{x1:"5",x2:"9",y1:"14",y2:"18",key:"1hf58s"}],["line",{x1:"7",x2:"4",y1:"17",y2:"20",key:"pidxm4"}],["line",{x1:"3",x2:"5",y1:"19",y2:"21",key:"1pehsh"}]],Du=N0("swords",Bu);/** + * @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:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],Tu=N0("trending-down",_u);/** + * @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 ju=[["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=N0("wrench",ju);function Iu(u,c){return c.filter(y=>y.nodes.includes(u)).sort((y,x)=>x.avgCertainCount-y.avgCertainCount)}function Lu(u,c,p){const y=Iu(u,c),x=new Set,C=[];for(const T of y)for(const Q of T.edgeKeys)if(!x.has(Q)){x.add(Q);const D=p.get(Q);C.push({key:Q,certainCount:(D==null?void 0:D.certainCount)??0})}return C.sort((T,Q)=>Q.certainCount-T.certainCount),{loops:y,highlightedEdgeKeys:x,sortedEdges:C}}function Nu(u){const c=new Map;for(const p of u)for(const y of p.edgeKeys){const x=c.get(y)??[];x.push(p),c.set(y,x)}return c}const Cn={MAX_THICKNESS_AT:300,MIN_VALIDATIONS:5},Fu=6,gs=1;function bi(u,c){const p=Math.max(Cn.MIN_VALIDATIONS,Math.min(u,Cn.MAX_THICKNESS_AT)),y=Math.log(Cn.MIN_VALIDATIONS),x=Math.log(Cn.MAX_THICKNESS_AT),T=(Math.log(p)-y)/(x-y);return gs+(Fu-gs)*T}const Pu=Qu(Ou);function Qu(u){return function(c,p,y=p){if(!((p=+p)>=0))throw new RangeError("invalid rx");if(!((y=+y)>=0))throw new RangeError("invalid ry");let{data:x,width:C,height:T}=c;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||!p&&!y)return c;const Q=p&&u(p),D=y&&u(y),E=x.slice();return Q&&D?(Rr(Q,E,x,C,T),Rr(Q,x,E,C,T),Rr(Q,E,x,C,T),Ir(D,x,E,C,T),Ir(D,E,x,C,T),Ir(D,x,E,C,T)):Q?(Rr(Q,x,E,C,T),Rr(Q,E,x,C,T),Rr(Q,x,E,C,T)):D&&(Ir(D,x,E,C,T),Ir(D,E,x,C,T),Ir(D,x,E,C,T)),c}}function Rr(u,c,p,y,x){for(let C=0,T=y*x;C{if(!((Q-=D)>=T))return;let E=c*C[T];const L=D*c,O=L+D;for(let z=T,Z=T+L;z{if(!((C-=T)>=x))return;let Q=u*y[x];const D=T*u;for(let E=x,L=x+D;E=y&&++p;return p}function Gu(u,c,p){let y;for(;;){const x=Xa(u,c,p);if(x===y||x===0||!isFinite(x))return[u,c];x>0?(u=Math.floor(u/x)*x,c=Math.ceil(c/x)*x):x<0&&(u=Math.ceil(u*x)/x,c=Math.floor(c*x)/x),y=x}}function Uu(u){return Math.max(1,Math.ceil(Math.log(Hu(u))/Math.LN2)+1)}var Vu=Array.prototype,zo=Vu.slice;function Wu(u,c){return u-c}function Yu(u){for(var c=0,p=u.length,y=u[p-1][1]*u[0][0]-u[p-1][0]*u[0][1];++c()=>u;function Ku(u,c){for(var p=-1,y=c.length,x;++py!=Z>y&&p<(z-E)*(y-L)/(Z-L)+E&&(x=-x)}return x}function $u(u,c,p){var y;return qu(u,c,p)&&Ju(u[y=+(u[0]===c[0])],p[y],c[y])}function qu(u,c,p){return(c[0]-u[0])*(p[1]-u[1])===(p[0]-u[0])*(c[1]-u[1])}function Ju(u,c,p){return u<=c&&c<=p||p<=c&&c<=u}function Xu(){}var I0=[[],[[[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 ps(){var u=1,c=1,p=Uu,y=D;function x(E){var L=p(E);if(Array.isArray(L))L=L.slice().sort(Wu);else{const O=Au(E,Ac);for(L=Lo(...Gu(O[0],O[1],L),L);L[L.length-1]>=O[1];)L.pop();for(;L[1]C(E,O))}function C(E,L){const O=L==null?NaN:+L;if(isNaN(O))throw new Error(`invalid value: ${L}`);var z=[],Z=[];return T(E,O,function(V){y(V,E,O),Yu(V)>0?z.push([V]):Z.push(V)}),Z.forEach(function(V){for(var AA=0,oA=z.length,eA;AA=L,I0[Y<<2].forEach(lA);++V0&&Z0&&V=0&&O>=0))throw new Error("invalid size");return u=L,c=O,x},x.thresholds=function(E){return arguments.length?(p=typeof E=="function"?E:Array.isArray(E)?q0(zo.call(E)):q0(E),x):p},x.smooth=function(E){return arguments.length?(y=E?D:Xu,x):y===D},x}function Ac(u){return isFinite(u)?u:NaN}function ar(u,c){return u==null?!1:+u>=c}function ui(u){return u==null||isNaN(u=+u)?-1/0:u}function ys(u,c,p,y){const x=y-c,C=p-c,T=isFinite(x)||isFinite(C)?x/C:Math.sign(x)/Math.sign(C);return isNaN(T)?u:u+T-.5}function ec(u){return u[0]}function tc(u){return u[1]}function rc(){return 1}function nc(){var u=ec,c=tc,p=rc,y=960,x=500,C=20,T=2,Q=C*3,D=y+Q*2>>T,E=x+Q*2>>T,L=q0(20);function O(Y){var cA=new Float32Array(D*E),lA=Math.pow(2,-T),bA=-1;for(const NA of Y){var sA=(u(NA,++bA,Y)+Q)*lA,fA=(c(NA,bA,Y)+Q)*lA,DA=+p(NA,bA,Y);if(DA&&sA>=0&&sA=0&&fAsA*bA))(cA).map((sA,fA)=>(sA.value=+lA[fA],Z(sA)))}z.contours=function(Y){var cA=O(Y),lA=ps().size([D,E]),bA=Math.pow(2,2*T),sA=fA=>{fA=+fA;var DA=Z(lA.contour(cA,fA*bA));return DA.value=fA,DA};return Object.defineProperty(sA,"max",{get:()=>ds(cA)/bA}),sA};function Z(Y){return Y.coordinates.forEach(V),Y}function V(Y){Y.forEach(AA)}function AA(Y){Y.forEach(oA)}function oA(Y){Y[0]=Y[0]*Math.pow(2,T)-Q,Y[1]=Y[1]*Math.pow(2,T)-Q}function eA(){return Q=C*3,D=y+Q*2>>T,E=x+Q*2>>T,z}return z.x=function(Y){return arguments.length?(u=typeof Y=="function"?Y:q0(+Y),z):u},z.y=function(Y){return arguments.length?(c=typeof Y=="function"?Y:q0(+Y),z):c},z.weight=function(Y){return arguments.length?(p=typeof Y=="function"?Y:q0(+Y),z):p},z.size=function(Y){if(!arguments.length)return[y,x];var cA=+Y[0],lA=+Y[1];if(!(cA>=0&&lA>=0))throw new Error("invalid size");return y=cA,x=lA,eA()},z.cellSize=function(Y){if(!arguments.length)return 1<=1))throw new Error("invalid cell size");return T=Math.floor(Math.log(Y)/Math.LN2),eA()},z.thresholds=function(Y){return arguments.length?(L=typeof Y=="function"?Y:Array.isArray(Y)?q0(zo.call(Y)):q0(Y),z):L},z.bandwidth=function(Y){if(!arguments.length)return Math.sqrt(C*(C+1));if(!((Y=+Y)>=0))throw new Error("invalid bandwidth");return C=(Math.sqrt(4*Y*Y+1)-1)/2,eA()},z}function ki(){const u=na();return j.useMemo(()=>ia.getPackets(),[u])}function En({label:u,icon:c,status:p,detail:y}){return m.jsxs("div",{className:zr("flex items-center gap-3 py-3 px-4 radius-inset transition-base",p==="active"&&"bg-sys-blue/10",p==="complete"&&"bg-sys-blue/10 ring-2 ring-inset ring-sys-blue",p==="pending"&&"opacity-40"),children:[m.jsx("div",{className:zr("w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 transition-all duration-300",p==="active"&&"bg-sys-blue/20",p==="complete"&&"bg-sys-blue/20",p==="pending"&&"bg-subtle-fill"),children:p==="complete"?m.jsx(Hr,{className:"w-4 h-4 text-sys-blue"}):p==="active"?m.jsx(Gn,{className:"w-4 h-4 animate-spin text-sys-blue"}):m.jsx("span",{className:"text-fg-muted",children:c})}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("div",{className:zr("text-sm font-medium transition-colors",p==="active"&&"text-sys-blue",p==="complete"&&"text-sys-blue",p==="pending"&&"text-fg-muted"),children:u}),y&&p!=="pending"&&m.jsx("div",{className:"text-xs text-fg-muted mt-0.5 truncate",children:y})]})]})}function ic({isOpen:u,onClose:c}){const{packetCacheState:p,triggerDeepAnalysis:y}=sa(),x=oa(),C=la(),T=p.packetCount,[Q,D]=j.useState("fetching");j.useEffect(()=>{u&&y()},[u,y]),j.useEffect(()=>{if(u){if(p.isTopologyLoading)D("fetching");else if(x)D("analyzing"),setTimeout(()=>D("building"),500),setTimeout(()=>D("discovering"),1e3);else if(C>0&&!p.isTopologyLoading){D("complete");const V=setTimeout(()=>{c()},1500);return()=>clearTimeout(V)}}},[u,p.isTopologyLoading,x,C,c]);const E=Q==="complete",L=p.loadProgress,O=j.useMemo(()=>{if(L&&L.target>0){const V=(L.loaded/1e3).toFixed(1),AA=(L.target/1e3).toFixed(1);return`Loading... ${V}k / ${AA}k packets (${L.percent}%)`}return T>0?`${T.toLocaleString()} packets loaded`:"Connecting to database..."},[L,T]),z=V=>{const AA=["fetching","analyzing","building","discovering","complete"],oA=AA.indexOf(Q),eA=AA.indexOf(V);return eA{};return m.jsx(co,{open:u,onClose:Z,size:"sm",bottomSheet:!1,children:m.jsx(aa,{isLoading:!E,borderRadius:16,children:m.jsx(fo,{className:"p-6 radius-card overflow-hidden",children:E?m.jsxs("div",{className:"flex flex-col items-center py-6",children:[m.jsx(qt.div,{variants:Ha,initial:"hidden",animate:"visible",className:"w-16 h-16 rounded-full flex items-center justify-center mb-4 bg-sys-blue/20",children:m.jsx(Hr,{className:"w-8 h-8 text-sys-blue"})}),m.jsx("h3",{className:"type-micro text-sys-blue",children:"Ready!"}),m.jsx("button",{onClick:c,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"})]}):m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[m.jsx("div",{className:"w-10 h-10 radius-inset flex items-center justify-center bg-sys-blue/15",children:m.jsx(xi,{className:"w-5 h-5 text-sys-blue"})}),m.jsxs("div",{children:[m.jsx("h3",{className:"type-micro",children:"Deep Analysis"}),m.jsx("p",{className:"text-xs text-fg-muted",children:"Building mesh topology"})]})]}),m.jsxs("div",{className:"space-y-2",children:[m.jsx(En,{label:"Fetching Packets",icon:m.jsx(ho,{className:"w-4 h-4"}),status:z("fetching"),detail:O}),m.jsx(En,{label:"Analyzing Database",icon:m.jsx(Va,{className:"w-4 h-4"}),status:z("analyzing"),detail:"Processing packet paths"}),m.jsx(En,{label:"Building Topology",icon:m.jsx(xi,{className:"w-4 h-4"}),status:z("building"),detail:"Computing mesh edges"}),m.jsx(En,{label:"Discovering Nodes",icon:m.jsx(Qo,{className:"w-4 h-4"}),status:z("discovering"),detail:"Viterbi HMM ghost detection"})]}),m.jsx("p",{className:"text-xs text-fg-muted text-center mt-5",children:"This may take a few seconds..."})]})})})})}const sc=j.memo(ic),Ho=16,Ci=24,oc=Ho,lc=5,mr={nodeFill:i0.blue,nodeStroke:"rgba(255,255,255,0.9)",nodeColor:i0.indigo,localColor:i0.amber,hubColor:i0.purple,gatewayColor:i0.indigo,mobileColor:i0.orange,roomServerColor:i0.pink,neighborColor:i0.amber,edges:{rest:dr[700],restBright:dr[600],restDim:dr[800],hoverDirect:"#6FBCBD",hoverLoop:"#8B7BAD",hoverStandard:dr[400],hoverNeighbor:i0.amber,neighborRest:dr[500],neighborHover:i0.amber,highlight:"#FFD700"},edgeOpacity:.82};function Fi(){if(typeof window>"u")return mr;const u=Un(),c=mo();return{nodeFill:u.nodeFill,nodeStroke:u.nodeStroke,nodeColor:mr.nodeColor,localColor:u.localColor,hubColor:u.hubColor,gatewayColor:u.gatewayColor,mobileColor:u.mobileColor,roomServerColor:u.roomColor,neighborColor:u.neighborColor,edges:{rest:c.rest,restBright:c.restBright,restDim:c.restDim,hoverDirect:c.hoverDirect,hoverLoop:c.hoverLoop,hoverStandard:c.hoverStandard,hoverNeighbor:c.hoverNeighbor,neighborRest:mr.edges.neighborRest,neighborHover:mr.edges.neighborHover,highlight:c.highlight},edgeOpacity:mr.edgeOpacity}}const Sn=2e3,Mn=750,ac="#00FF00",uc=500,xs=500,ws=250,cc=150,Go=200,fc=pr.snappy;function Lr({color:u,ring:c}){const p=oc-2;return m.jsx("span",{className:"shrink-0 rounded-full","aria-hidden":"true",style:{width:p,height:p,backgroundColor:c?"transparent":u,border:c?`${lc-1}px solid ${u}`:void 0,boxSizing:"border-box"}})}function ci({color:u,pattern:c="solid"}){return m.jsx("svg",{className:"shrink-0","aria-hidden":"true",width:18,height:6,viewBox:"0 0 18 6",children:m.jsx("line",{x1:0,y1:3,x2:18,y2:3,stroke:u,strokeWidth:3,strokeLinecap:"round",strokeDasharray:c==="dashed"?"5,3":c==="dotted"?"2,3":void 0})})}function n0({indicator:u,label:c,tooltip:p}){return m.jsxs("div",{className:"flex items-center gap-1.5",children:[u,m.jsx("span",{className:"text-fg-secondary",children:c}),p&&m.jsx(po,{content:p,delay:Go,children:m.jsx("span",{className:"cursor-help text-[11px] text-fg-muted opacity-75 hover:opacity-100 transition-opacity",children:"ⓘ"})})]})}function hc(u){return`legend-section-${u.toLowerCase().replace(/\s+/g,"-")}`}function fi({title:u,tooltip:c,isOpen:p,onToggle:y,showDivider:x,children:C}){const T=hc(u);return m.jsxs("div",{className:x?"mt-2 pt-2 border-t border-edge-subtle":"",children:[m.jsxs("button",{type:"button",onClick:y,"aria-expanded":p,"aria-controls":T,className:"group w-full flex items-center justify-between py-1 min-h-[44px] sm:min-h-0 font-medium text-fg-secondary hover:text-fg-primary transition-colors",children:[m.jsxs("span",{className:"flex items-center gap-1",children:[u,m.jsx(po,{content:c,delay:Go,children:m.jsx("span",{className:"cursor-help text-[11px] text-fg-muted opacity-75 group-hover:opacity-100 transition-opacity",children:"ⓘ"})})]}),m.jsx(qt.span,{animate:{rotate:p?0:-90},transition:{duration:.15},"aria-hidden":"true",children:m.jsx(yo,{className:"w-3 h-3 text-fg-muted"})})]}),m.jsx(v0,{initial:!1,children:p&&m.jsx(qt.div,{id:T,role:"region","aria-label":u,initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:fc,className:"overflow-hidden",children:m.jsx("div",{className:"flex flex-col gap-1 pt-1.5",children:C})})})]})}function vs({label:u,value:c,color:p}){return m.jsxs("div",{className:"flex justify-between tabular-nums text-fg-muted",children:[m.jsx("span",{children:u}),m.jsx("span",{className:p?"":"text-fg-secondary",style:p?{color:p}:void 0,children:c})]})}function bs({icon:u,color:c,title:p,subtitle:y}){return m.jsx("div",{className:"mt-1.5 pt-1.5 border-t border-edge-subtle",children:m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx("span",{className:"shrink-0",style:{color:c},children:u}),m.jsxs("div",{className:"flex flex-col min-w-0",children:[m.jsx("span",{className:"font-medium truncate",style:{color:c},children:p}),m.jsx("span",{className:"text-[10px] leading-tight text-fg-muted",children:y})]})]})})}function dc(u){return u.some(([,c])=>{var y;const p=(y=c.contact_type)==null?void 0:y.toLowerCase();return p==="room server"||p==="room_server"||p==="room"||p==="server"})}function mc(u){let c=0;for(const p of u.txDelayRecommendations.values())p.networkRole==="backbone"&&c++;return c}function gc({showTopology:u,validatedPolylineCount:c,filteredNeighborCount:p,hasLocalNode:y,meshTopology:x,zeroHopNeighbors:C,neighborsWithLocation:T,basemapMode:Q="dark"}){const D=ua(),E=ca(),L=fa(),O=E.filter(lA=>lA.isLikelyReal).length,z=mc(x),Z=C.size>0,[V,AA]=j.useState(!0),[oA,eA]=j.useState(!0),[Y,cA]=j.useState(!0);return m.jsxs("div",{className:"map-control-surface p-2.5 text-xs",children:[m.jsxs(fi,{title:"Nodes",tooltip:"Node type shown by shape + color. Yellow = direct RF neighbor.",isOpen:V,onToggle:()=>AA(lA=>!lA),children:[m.jsx(n0,{indicator:m.jsx(Lr,{color:D.nodeFill}),label:"Node",tooltip:"Standard mesh node. Repeater, client, or companion device."}),m.jsx(n0,{indicator:m.jsx(Lr,{color:D.hubColor}),label:"Hub",tooltip:"Network hub (≥10% of last-hop traffic)."}),dc(T)&&m.jsx(n0,{indicator:m.jsx(ha,{className:"w-3 h-3 shrink-0",style:{color:D.roomColor},strokeWidth:2.5}),label:"Room",tooltip:"Room Server identity for client sync."}),m.jsx(n0,{indicator:m.jsx(Wa,{className:"w-3 h-3 shrink-0",style:{color:D.localColor},strokeWidth:2.5}),label:"Local",tooltip:"Your repeater running pyMC_Repeater."}),Z&&m.jsx(n0,{indicator:m.jsx(Lr,{color:D.neighborColor}),label:"Neighbor",tooltip:"Zero-hop direct RF contact."}),x.gatewayNodes.length>0&&m.jsx(n0,{indicator:m.jsx(Lr,{color:D.gatewayColor}),label:"Gateway",tooltip:"Significant forwarder (7-10% traffic)."}),z>0&&m.jsx(n0,{indicator:m.jsx(Lr,{color:D.hubColor}),label:"Backbone",tooltip:"Critical relay with high centrality."}),x.mobileNodes.length>0&&m.jsx(n0,{indicator:m.jsx(Lr,{color:D.mobileColor,ring:!0}),label:"Mobile",tooltip:"Volatile node that appears/disappears."}),O>0&&m.jsx(n0,{indicator:m.jsx(Qo,{className:"w-3 h-3 shrink-0",style:{color:D.ghostColor},strokeWidth:2.5}),label:`Ghost (${O})`,tooltip:"Unknown repeater from Viterbi analysis."})]}),Z&&m.jsxs(fi,{title:"Link Quality",tooltip:"Neighbor edge colors based on bidirectional balance.",isOpen:oA,onToggle:()=>eA(lA=>!lA),showDivider:!0,children:[m.jsx(n0,{indicator:m.jsx(ci,{color:Fn.YELLOW,pattern:"solid"}),label:"2-Way",tooltip:"33-67% balanced. Ideal bidirectional link."}),m.jsx(n0,{indicator:m.jsx(ci,{color:Fn.GREEN,pattern:"dashed"}),label:"Listener",tooltip:">67% listener. They hear us well."}),m.jsx(n0,{indicator:m.jsx(ci,{color:Fn.RED,pattern:"dotted"}),label:"Loud",tooltip:"<33% listener. They route more to us."})]}),u&&c>0&&m.jsxs(fi,{title:"Topology",tooltip:"Links with 5+ validations. Thickness = strength.",isOpen:Y,onToggle:()=>cA(lA=>!lA),showDivider:!0,children:[m.jsx(vs,{label:"Nodes",value:p+(y?1:0)}),x.hubNodes.length>0&&m.jsx(vs,{label:"Hubs",value:x.hubNodes.length,color:mr.hubColor}),x.loops.length>0&&m.jsx(bs,{icon:m.jsx(go,{className:"w-3 h-3"}),color:mr.edges.hoverLoop,title:`${x.loops.length} ${x.loops.length===1?"Loop":"Loops"}`,subtitle:"Redundant paths"}),L.totalPaths>0&&m.jsx(bs,{icon:m.jsx(Io,{className:"w-3 h-3"}),color:D.ghostColor,title:`${L.totalPaths.toLocaleString()} Viterbi`,subtitle:"HMM decoded paths"})]})]})}const ks={repeater:"blue",companion:"cyan",room_server:"pink",hubs:"indigo",direct:"green"},Bn={repeater:"Repeaters",companion:"Companions",room_server:"Rooms",hubs:"Hubs",direct:"Direct"},Cs={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"},pc=["repeater","companion","room_server"],Es=["hubs","direct"],Nr="!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",Dn="!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",yc=()=>typeof window>"u"?!1:window.innerWidth<640;function xc({mapRef:u,showNeighborLines:c,onToggleNeighborLines:p,hasNeighborPolylines:y,nodeFilters:x,onToggleFilter:C,onToggleAll:T,filterCounts:Q,showCoverage:D,onToggleCoverage:E,showMinCut:L=!1,onToggleMinCut:O,hasMinCutData:z=!1,show3DTerrain:Z,onToggle3DTerrain:V,basemapMode:AA,onToggleBasemap:oA,isFullscreen:eA,onToggleFullscreen:Y,showLinkQuality:cA=!1,onToggleLinkQuality:lA,hasTraceLinks:bA=!1}){const[sA,fA]=j.useState(()=>!yc()),DA=()=>{var FA,GA;(GA=(FA=u.current)==null?void 0:FA.getMap())==null||GA.zoomIn()},TA=()=>{var FA,GA;(GA=(FA=u.current)==null?void 0:FA.getMap())==null||GA.zoomOut()},CA=()=>{var GA;const FA=(GA=u.current)==null?void 0:GA.getMap();FA&&FA.easeTo({bearing:0,pitch:0,duration:300})},mA="w-4 h-4",IA=AA==="light"?"#525252":"var(--fg-secondary)",NA=x.length>=un.length;return m.jsx(m.Fragment,{children:m.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:[m.jsxs("div",{className:"map-control-surface flex flex-nowrap items-center gap-0.5 sm:gap-1 p-1 overflow-hidden",children:[y&&m.jsx(Lt,{plain:!0,color:c?"warning":"muted",onClick:p,title:c?"Hide edge lines":"Show edge lines","aria-label":c?"Hide edge lines":"Show edge lines","aria-pressed":c,className:Nr,"data-tint":c?"warning":void 0,children:m.jsx(da,{className:mA})}),m.jsx(Lt,{plain:!0,color:"muted",onClick:()=>fA(FA=>!FA),title:sA?"Hide node filters":"Show node filters","aria-label":sA?"Collapse node filters":"Expand node filters","aria-expanded":sA,className:Nr,children:m.jsx(Za,{className:mA})}),m.jsx(v0,{initial:!1,children:sA&&m.jsxs(qt.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:[m.jsx(li,{color:NA?"green":"zinc",customColor:NA?void 0:IA,onClick:T,title:"Show all nodes","aria-pressed":NA,"aria-label":"Show all node types",className:"shrink-0",children:"All"}),pc.map(FA=>{const GA=Q[FA];if(GA===0)return null;const vA=!NA&&x.includes(FA);return m.jsx(li,{color:vA?ks[FA]:"zinc",customColor:vA?void 0:IA,onClick:()=>C(FA),title:Cs[FA],"aria-pressed":vA,"aria-label":`${Bn[FA]} (${GA})`,className:"shrink-0",children:Bn[FA]},FA)}),Es.some(FA=>Q[FA]>0)&&m.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"}),Es.map(FA=>{const GA=Q[FA];if(GA===0)return null;const vA=!NA&&x.includes(FA);return m.jsx(li,{color:vA?ks[FA]:"zinc",customColor:vA?void 0:IA,onClick:()=>C(FA),title:Cs[FA],"aria-pressed":vA,"aria-label":`${Bn[FA]} (${GA})`,className:"shrink-0",children:Bn[FA]},FA)})]})}),z&&O&&m.jsx(Lt,{plain:!0,color:L?"primary":"muted",onClick:O,title:L?"Hide community partition":"Show community partition","aria-label":L?"Hide community partition":"Show community partition","aria-pressed":L,className:Nr,"data-tint":L?"primary":void 0,children:m.jsx(vi,{className:mA})}),m.jsx(Lt,{plain:!0,color:AA==="light"?"primary":"muted",onClick:oA,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:Nr,"data-tint":AA==="light"?"primary":void 0,children:AA==="light"?m.jsx(Li,{className:mA}):m.jsx(Ni,{className:mA})}),m.jsx(Lt,{plain:!0,color:Z?"success":"muted",onClick:V,title:Z?"Disable 3D terrain":"Enable 3D terrain","aria-label":Z?"Disable 3D terrain":"Enable 3D terrain","aria-pressed":Z,className:Nr,"data-tint":Z?"success":void 0,children:m.jsx(Cu,{className:mA})}),m.jsx(Lt,{plain:!0,color:"muted",onClick:Y,title:eA?"Exit fullscreen":"Fullscreen","aria-label":eA?"Exit fullscreen":"Enter fullscreen","aria-pressed":eA,className:Nr,children:eA?m.jsx(Ga,{className:mA}):m.jsx(Ua,{className:mA})})]}),m.jsxs("div",{className:"map-control-surface flex flex-col items-stretch !overflow-hidden self-end !p-0",children:[m.jsx(Lt,{plain:!0,color:"muted",onClick:DA,title:"Zoom in","aria-label":"Zoom in",className:Dn,children:m.jsx($a,{className:mA})}),m.jsx("div",{className:"h-px bg-border-subtle","aria-hidden":"true"}),m.jsx(Lt,{plain:!0,color:"muted",onClick:TA,title:"Zoom out","aria-label":"Zoom out",className:Dn,children:m.jsx(xo,{className:mA})}),m.jsx("div",{className:"h-px bg-border-subtle","aria-hidden":"true"}),m.jsx(Lt,{plain:!0,color:"muted",onClick:CA,title:"Reset bearing to north","aria-label":"Reset bearing to north",className:Dn,children:m.jsx(qa,{className:mA})})]}),bA&&lA&&m.jsx("div",{className:"map-control-surface flex flex-col items-stretch !overflow-hidden self-end !p-0",children:m.jsx(Lt,{plain:!0,color:cA?"success":"muted",onClick:lA,title:cA?"Hide link quality overlay":"Show link quality overlay","aria-label":cA?"Hide link quality overlay":"Show link quality overlay","aria-pressed":cA,className:Dn,"data-tint":cA?"success":void 0,children:m.jsx(Oo,{className:mA})})})]})})}const wc="#4ADE80",vc="#16A34A",bc="rgba(10, 26, 10, 1)",kc="rgba(220, 252, 231, 1)",ur="DeepAnalysis",Cc=700,Ss="abcdefghijklmnopqrstuvwxyz0123456789";function Ec(){return Ss[Math.floor(Math.random()*Ss.length)]}function Sc({isActive:u,hasAnalyzed:c,isLoading:p,onClick:y,basemapMode:x="dark"}){const C=x==="light",T=C?vc:wc,[Q,D]=j.useState(!1),[E,L]=j.useState(ur),O=j.useRef(!1),z=j.useRef(null),[Z]=j.useState(()=>{var eA;return typeof window<"u"&&(((eA=window.matchMedia)==null?void 0:eA.call(window,"(hover: hover)").matches)??!1)}),V=Q&&!u&&!p&&Z;j.useEffect(()=>{if(Q&&!u&&!p&&!O.current){O.current=!0;const eA=performance.now(),Y=cA=>{const lA=cA-eA,bA=Math.min(lA/Cc,1),sA=Math.floor(bA*ur.length);let fA="";for(let DA=0;DA{z.current&&cancelAnimationFrame(z.current)}},[Q,u,p]);const AA=p?"Analyzing...":E,oA=p?"Analyzing packet history":c?u?"Hide topology edges":"Show topology edges":"Load full packet history and build topology";return m.jsxs("button",{onClick:y,onMouseEnter:()=>Z&&D(!0),onMouseLeave:()=>Z&&D(!1),onPointerEnter:()=>Z&&D(!0),onPointerLeave:()=>Z&&D(!1),disabled:p,className:`map-tool-btn flex items-center gap-2 w-full text-left radius-inner transition-base ${p?"cursor-wait":""}`,style:{padding:"0.5rem 0.625rem",...u&&{backgroundColor:C?kc:bc}},title:oA,"aria-label":oA,"aria-pressed":u,children:[p?m.jsx(Gn,{className:"w-3.5 h-3.5 shrink-0 animate-spin",style:{color:T}}):m.jsx(xi,{className:`w-3.5 h-3.5 shrink-0 transition-colors ${u?"":"text-fg-secondary"}`,style:{...u&&{color:T},...V&&{color:T}}}),m.jsx("span",{className:`${u?"":"text-fg-secondary"}`,"aria-hidden":"true",style:{fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:"0.6875rem",fontWeight:u||V?700:500,letterSpacing:"-0.01em",lineHeight:1,...u&&{color:T},...V&&{color:T}},children:AA})]})}const Mc=i0.teal,Bc="#0D7377",Dc="rgba(10, 36, 32, 1)",_c="rgba(204, 251, 241, 1)",Ms="LiveTrace",Tc=400,Bs=100;function jc({isActive:u,onClick:c,basemapMode:p="dark"}){const y=p==="light",x=y?Bc:Mc,[C,T]=j.useState(!1),[Q,D]=j.useState(0),E=j.useRef(!1),L=j.useRef(null),[O,z]=j.useState(0),Z=j.useRef(!1),[V]=j.useState(()=>{var Y;return typeof window<"u"&&(((Y=window.matchMedia)==null?void 0:Y.call(window,"(hover: hover)").matches)??!1)}),AA=C&&!u&&V;j.useEffect(()=>{AA&&!Z.current&&(Z.current=!0,z(1),setTimeout(()=>z(2),Bs),setTimeout(()=>z(3),Bs*2)),C||(Z.current=!1,z(0))},[AA,C]),j.useEffect(()=>{if(C&&!u&&!E.current){E.current=!0;const Y=performance.now(),cA=lA=>{const bA=lA-Y,sA=Math.min(bA/Tc,1);D(sA),sA<1&&(L.current=requestAnimationFrame(cA))};L.current=requestAnimationFrame(cA)}return C||(L.current&&(cancelAnimationFrame(L.current),L.current=null),E.current=!1,D(0)),()=>{L.current&&cancelAnimationFrame(L.current)}},[C,u]);const oA=Y=>{if(u)return x;if(!AA)return;const cA=Ms.length,lA=Q*(cA+2);return Y>=lA-2&&YV&&T(!0),onMouseLeave:()=>V&&T(!1),onPointerEnter:()=>V&&T(!0),onPointerLeave:()=>V&&T(!1),className:"map-tool-btn flex items-center gap-2 w-full text-left radius-inner transition-base",style:{padding:"0.5rem 0.625rem",...u&&{backgroundColor:y?_c:Dc}},title:u?"Disable live packet tracing (reduces CPU usage)":"Enable live packet tracing","aria-label":eA,"aria-pressed":u,children:[m.jsx(Ja,{className:`w-3.5 h-3.5 shrink-0 ${u?"":"text-fg-secondary"}`,fill:O===1?"#FFFFFF":O===3?x:"none",stroke:O===1||O===2?"#FFFFFF":u||AA?x:"currentColor",style:{transition:"fill 0.05s, stroke 0.05s"}}),m.jsx("span",{className:`${u?"":"text-fg-secondary"}`,"aria-hidden":"true",style:{fontFamily:"ui-monospace, SFMono-Regular, monospace",fontSize:"0.6875rem",fontWeight:u||AA?700:500,letterSpacing:"-0.01em",lineHeight:1},children:Ms.split("").map((Y,cA)=>m.jsx("span",{style:{color:oA(cA)||void 0},children:Y},cA))})]})}const Ds=.2,Rc="rgba(26, 20, 8, 1)",Ic="rgba(254, 243, 199, 1)",hi=.01,di=1,_s="#fe8019",Lc="'Wardrive', serif",Ei=1.45,Nc=Ei*1.1,Fc=80;function Pc({isActive:u,onClick:c,brightness:p=.7,onBrightnessChange:y,basemapMode:x="dark"}){const C=x==="light",[T,Q]=j.useState(!1),[D,E]=j.useState(!1),[L]=j.useState(()=>{var Y;return typeof window<"u"&&(((Y=window.matchMedia)==null?void 0:Y.call(window,"(hover: hover)").matches)??!1)});j.useEffect(()=>{if(!T||u)return;const Y=requestAnimationFrame(()=>E(!0)),cA=setTimeout(()=>E(!1),Fc);return()=>{cancelAnimationFrame(Y),clearTimeout(cA)}},[T,u]);const O=Math.max(hi,Math.min(di,p)),z=Y=>{Y.stopPropagation();const cA=Math.min(di,O+Ds);y==null||y(cA)},Z=Y=>{Y.stopPropagation();const cA=Math.max(hi,O-Ds);y==null||y(cA)},V=Ohi+.001,oA=T&&!u&&L,eA=u?"Configure wardriving coverage":"Show wardriving coverage";return m.jsxs("button",{onClick:c,onMouseEnter:()=>L&&Q(!0),onMouseLeave:()=>L&&Q(!1),onPointerEnter:()=>L&&Q(!0),onPointerLeave:()=>L&&Q(!1),className:"map-tool-btn flex items-center gap-2 w-full text-left radius-inner transition-base",style:{padding:"0.5rem 0.625rem",...u&&{backgroundColor:C?Ic:Rc}},title:eA,"aria-label":eA,"aria-pressed":u,children:[m.jsx(Du,{className:`w-3.5 h-3.5 shrink-0 transition-colors ${u?"text-sys-amber":"text-fg-secondary"}`,style:oA?{color:_s}:void 0}),m.jsx("span",{className:`${u?"text-sys-amber":"text-fg-secondary"}`,"aria-hidden":"true",style:{fontFamily:u||oA?Lc:"ui-monospace, SFMono-Regular, monospace",fontSize:u||oA?"0.75rem":"0.6875rem",fontWeight:500,letterSpacing:"-0.01em",lineHeight:1,transition:"none",transform:u?`scale(${Ei})`:oA?`scale(${D?Nc:Ei})`:void 0,transformOrigin:"left center",...oA?{color:_s}:{}},children:"Wardrive"}),u&&y&&m.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[m.jsx("button",{onClick:Z,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?"rgba(0, 0, 0, 0.25)":"rgba(251, 191, 36, 0.3)"},title:`Decrease opacity (${Math.round(O*100)}%)`,"aria-label":`Decrease opacity, currently ${Math.round(O*100)}%`,children:m.jsx(Li,{className:"w-3.5 h-3.5"})}),m.jsx("button",{onClick:z,disabled:!V,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 ${V?"text-sys-amber hover:bg-[var(--map-ui-hover,var(--elevated))] active:bg-[var(--map-ui-active,var(--subtle))]":"cursor-not-allowed"}`,style:V?void 0:{color:C?"rgba(0, 0, 0, 0.25)":"rgba(251, 191, 36, 0.3)"},title:`Increase opacity (${Math.round(O*100)}%)`,"aria-label":`Increase opacity, currently ${Math.round(O*100)}%`,children:m.jsx(Ni,{className:"w-3.5 h-3.5"})})]})]})}const Qc="0123456789bcdefghjkmnpqrstuvwxyz";function Oc(u){let c=!0,p=-90,y=90,x=-180,C=180;for(const T of u.toLowerCase()){const Q=Qc.indexOf(T);if(Q!==-1)for(let D=4;D>=0;D--){const E=Q>>D&1;if(c){const L=(x+C)/2;E?x=L:C=L}else{const L=(p+y)/2;E?p=L:y=L}c=!c}}return{lat:(p+y)/2,lon:(x+C)/2}}function zc(u){return Math.exp(-u*Math.LN2/7)}const Si="pymc-wardriving-url",Uo="pymc-wardriving-enabled",Vo="pymc-wardriving-brightness",Ts=.7;function Hc(){return typeof localStorage>"u"?"":localStorage.getItem(Si)||""}function js(u){typeof localStorage>"u"||(u?localStorage.setItem(Si,u):localStorage.removeItem(Si))}function Gc(){return typeof localStorage>"u"?!1:localStorage.getItem(Uo)==="true"}function _n(u){typeof localStorage>"u"||localStorage.setItem(Uo,String(u))}function Uc(){if(typeof localStorage>"u")return Ts;const u=localStorage.getItem(Vo);if(u){const c=parseFloat(u);if(!isNaN(c)&&c>=.01&&c<=1)return c}return Ts}function Vc(u){if(typeof localStorage>"u")return;const c=Math.max(.01,Math.min(1,u));localStorage.setItem(Vo,String(c))}const Wc=8e3;async function Yc(u,c={},p=Wc){const y=new AbortController,x=setTimeout(()=>y.abort(),p);try{return await fetch(u,{...c,signal:y.signal})}catch(C){throw C instanceof Error&&C.name==="AbortError"?new Error(`Connection timed out after ${p/1e3}s`):C}finally{clearTimeout(x)}}async function Kc(u){const p=`${u.replace(/\/+$/,"").replace(/\/get-nodes$/,"").replace(/\/get-samples$/,"")}/get-samples`,y=await Yc(p,{headers:{Accept:"application/json"}});if(!y.ok)throw new Error(`Failed to fetch precise samples: ${y.status}`);return y.json()}function Zc(u,c=null){if(u!==null){const y=(Math.max(-12,Math.min(12,u))+12)/24;if(c!==null){const C=(Math.max(-120,Math.min(-50,c))+120)/70;return y*.8+C*.2}return y}return c!==null?(Math.max(-120,Math.min(-50,c))+120)/70:.5}function $c(u){var p;const c=[];for(const y of u.keys){if(!y.observed)continue;const{lat:x,lon:C}=Oc(y.hash),T=parseInt(y.time,10),Q=isNaN(T)?30:(Date.now()-T)/(1e3*60*60*24),D=zc(Q),L=Zc(y.snr,y.rssi)*(.3+D*.7);c.push({lat:x,lon:C,successRate:y.observed?1:0,weight:L,totalSamples:1,ageDays:Q,geohash:y.hash,repeaters:((p=y.path)==null?void 0:p.map(O=>O.toLowerCase()))||[]})}return c}const cn=wo((u,c)=>({status:"idle",isVisible:Gc(),coveragePoints:[],repeaters:[],error:null,stats:{coverageCount:0,repeaterCount:0,lastUpdated:null},url:Hc(),brightness:Uc(),isModalOpen:!1,openModal:()=>u({isModalOpen:!0}),closeModal:()=>u({isModalOpen:!1}),setUrl:p=>u({url:p}),setBrightness:p=>{const y=Math.max(.01,Math.min(1,p));Vc(y),u({brightness:y})},toggleVisibility:()=>{const p=!c().isVisible;_n(p),u({isVisible:p})},setVisible:p=>{_n(p),u({isVisible:p})},loadCoverage:async p=>{if(!p.trim())return u({error:"Please enter a URL",status:"error"}),!1;try{new URL(p.trim())}catch{return u({error:"Invalid URL format",status:"error"}),!1}u({error:null,status:"connecting"});try{u({status:"loading"});const y=await Kc(p.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");u({status:"processing"});const x=$c(y);if(x.length===0)throw new Error("No valid coverage points found");return u({coveragePoints:x,repeaters:[],stats:{coverageCount:x.length,repeaterCount:0,lastUpdated:new Date},status:"success",isVisible:!0,url:p.trim()}),js(p.trim()),_n(!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."),u({error:C,status:"error"}),!1}},clearCoverage:()=>{u({coveragePoints:[],repeaters:[],stats:{coverageCount:0,repeaterCount:0,lastUpdated:null},status:"idle",error:null,isVisible:!1,url:""}),js(""),_n(!1)}})),qc={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"},Wo={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)"},Yo=j.createContext({theme:Wo,isLight:!1});function yr(){return j.useContext(Yo)}function Jc({status:u,hasData:c}){const{theme:p,isLight:y}=yr(),x=j.useMemo(()=>u==="connecting"||u==="loading"||u==="processing"?{icon:m.jsx(Gn,{className:"w-3.5 h-3.5 animate-spin"}),label:u==="connecting"?"Connecting...":u==="loading"?"Loading...":"Processing...",color:p.warning,bg:p.warningBg}:u==="error"?{icon:m.jsx(lu,{className:"w-3.5 h-3.5"}),label:"Disconnected",color:p.error,bg:p.errorBg}:c?{icon:m.jsx(au,{className:"w-3.5 h-3.5"}),label:"Connected",color:p.success,bg:p.successBg}:{icon:m.jsx(bo,{className:"w-3.5 h-3.5"}),label:"Ready",color:p.textMuted,bg:y?"rgba(0,0,0,0.04)":"rgba(255,255,255,0.04)"},[u,c,p,y]);return m.jsxs(qt.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,m.jsx("span",{children:x.label})]},x.label)}function Xc({status:u}){const{theme:c}=yr(),p=j.useMemo(()=>{switch(u){case"connecting":return 25;case"loading":return 60;case"processing":return 90;default:return 0}},[u]);return p===0?null:m.jsx(qt.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:c.sliderTrack},children:m.jsx(qt.div,{className:"h-full rounded-full",style:{backgroundColor:c.primary},initial:{width:0},animate:{width:`${p}%`},transition:{duration:.4,ease:"easeOut"}})})}function Rs({variant:u,title:c,description:p,onDismiss:y}){const{theme:x}=yr(),C=j.useMemo(()=>{switch(u){case"success":return{icon:m.jsx(Hr,{className:"w-4 h-4"}),color:x.success,bg:x.successBg,border:x.successBorder};case"error":return{icon:m.jsx(uu,{className:"w-4 h-4"}),color:x.error,bg:x.errorBg,border:x.errorBorder};case"info":return{icon:m.jsx(bu,{className:"w-4 h-4"}),color:x.info,bg:x.infoBg,border:x.infoBorder}}},[u,x]);return m.jsxs(qt.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:pr.snappy,className:"flex items-start gap-3 p-3 rounded-lg border",style:{backgroundColor:C.bg,borderColor:C.border,color:C.color},children:[m.jsx("div",{className:"shrink-0 mt-0.5",children:C.icon}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("p",{className:"text-sm font-medium",children:c}),p&&m.jsx("p",{className:"text-xs mt-0.5 opacity-80",children:p})]}),y&&m.jsx("button",{onClick:y,className:"shrink-0 p-1 rounded hover:bg-black/10 transition-colors","aria-label":"Dismiss",children:m.jsx(Gr,{className:"w-3.5 h-3.5"})})]})}function Af({value:u,onChange:c,onSubmit:p,disabled:y}){const{theme:x,isLight:C}=yr(),[T,Q]=j.useState(!1),D=E=>{E.key==="Enter"&&!E.shiftKey&&!y&&(E.preventDefault(),p())};return m.jsxs("div",{className:"space-y-1.5",children:[m.jsx("label",{className:"block text-sm font-medium",style:{color:x.textSecondary},children:"Coverage Server URL"}),m.jsxs("div",{className:"relative",children:[m.jsx("input",{type:"url",value:u,onChange:E=>c(E.target.value),onKeyDown:D,onFocus:()=>Q(!0),onBlur:()=>Q(!1),placeholder:"https://coverage.wcmesh.com",disabled:y,className:zr("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"}}),u&&!y&&m.jsx("button",{onClick:()=>c(""),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:m.jsx(Gr,{className:"w-4 h-4"})})]}),m.jsx("p",{className:"text-xs",style:{color:x.textMuted},children:"Press Enter to connect, or use the Connect button below"})]})}function ef({value:u,onChange:c}){const{theme:p,isLight:y}=yr(),x=Math.round(u*100);return m.jsx(qt.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:pr.gentle,className:"overflow-hidden",children:m.jsx("div",{className:"p-3 rounded-lg border",style:{backgroundColor:p.bgSubtle,borderColor:p.border},children:m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsxs("div",{className:"relative w-4 h-4",children:[m.jsx(Li,{className:"w-4 h-4 absolute inset-0 transition-opacity",style:{color:p.textMuted,opacity:u<.5?1:0}}),m.jsx(Ni,{className:"w-4 h-4 absolute inset-0 transition-opacity",style:{color:p.primary,opacity:u>=.5?1:0}})]}),m.jsxs("div",{className:"flex-1",children:[m.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[m.jsx("span",{className:"text-xs font-medium",style:{color:p.textSecondary},children:"Layer Opacity"}),m.jsxs("span",{className:"text-xs font-mono tabular-nums px-1.5 py-0.5 rounded",style:{color:p.text,backgroundColor:y?"rgba(0,0,0,0.06)":"rgba(255,255,255,0.06)"},children:[x,"%"]})]}),m.jsx("input",{type:"range",min:5,max:100,value:x,onChange:C=>c(Number(C.target.value)/100),className:zr("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, ${p.primary} ${x}%, ${p.sliderTrack} ${x}%)`,"--thumb-color":p.sliderThumb}}),m.jsx("style",{children:` + input[type="range"]::-webkit-slider-thumb { + background-color: ${p.sliderThumb}; + } + input[type="range"]::-moz-range-thumb { + background-color: ${p.sliderThumb}; + } + `})]})]})})})}function tf({coverageCount:u,repeaterCount:c,lastUpdated:p}){const{theme:y}=yr();return m.jsxs("div",{className:"grid grid-cols-3 gap-2 p-3 rounded-lg border",style:{backgroundColor:y.bgSubtle,borderColor:y.border},children:[m.jsxs("div",{className:"text-center",children:[m.jsx(hs,{value:u,format:{useGrouping:!0,maximumFractionDigits:0},className:"text-lg font-semibold tabular-nums block",style:{color:y.text}}),m.jsx("div",{className:"text-xs mt-0.5",style:{color:y.textMuted},children:"Points"})]}),m.jsxs("div",{className:"text-center border-x",style:{borderColor:y.border},children:[m.jsx(hs,{value:c,format:{useGrouping:!0,maximumFractionDigits:0},className:"text-lg font-semibold tabular-nums block",style:{color:y.text}}),m.jsx("div",{className:"text-xs mt-0.5",style:{color:y.textMuted},children:"Repeaters"})]}),m.jsxs("div",{className:"text-center",children:[m.jsxs("div",{className:"flex items-center justify-center gap-1",children:[m.jsx(No,{className:"w-3.5 h-3.5",style:{color:y.textMuted}}),m.jsx("span",{className:"text-lg font-semibold tabular-nums",style:{color:y.text},children:p?p.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"—"})]}),m.jsx("div",{className:"text-xs mt-0.5",style:{color:y.textMuted},children:"Updated"})]})]})}function Is({icon:u,label:c,onClick:p,disabled:y,variant:x="default",active:C}){const{theme:T,isLight:Q}=yr(),D=j.useMemo(()=>x==="danger"?{text:T.error,hoverBg:Q?"rgba(220, 38, 38, 0.08)":"rgba(239, 68, 68, 0.15)"}:{text:C?T.primary:T.textSecondary,hoverBg:T.hoverBg},[x,C,T,Q]);return m.jsxs("button",{onClick:p,disabled:y,className:zr("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:D.text},onMouseEnter:E=>!y&&(E.currentTarget.style.backgroundColor=D.hoverBg),onMouseLeave:E=>E.currentTarget.style.backgroundColor="transparent",children:[u,m.jsx("span",{children:c})]})}function rf(){const u=vo(),c=u==="light",p=c?qc:Wo,{isModalOpen:y,closeModal:x,status:C,isVisible:T,stats:Q,error:D,url:E,brightness:L,loadCoverage:O,clearCoverage:z,toggleVisibility:Z,setUrl:V,setBrightness:AA}=cn(),oA=C==="connecting"||C==="loading"||C==="processing",eA=Q.coverageCount>0,[Y,cA]=j.useState(!0),[lA,bA]=j.useState(E);j.useEffect(()=>{bA(E)},[E]),j.useEffect(()=>{C==="error"&&cA(!0)},[C]);const sA=j.useCallback(async()=>{await O(lA)},[lA,O]),fA=j.useCallback(()=>{bA(""),z()},[z]),DA=j.useCallback(mA=>{bA(mA),V(mA)},[V]),TA=j.useCallback(()=>{oA||x()},[oA,x]),CA=lA.trim().length>0&&!oA;return m.jsx(Yo.Provider,{value:{theme:p,isLight:c},children:m.jsxs(co,{open:y,onClose:TA,size:"md",bottomSheet:!0,basemapMode:u,children:[m.jsxs("div",{className:"flex items-center justify-between p-4 border-b",style:{borderColor:p.border},children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx("div",{className:"p-2 rounded-lg",style:{backgroundColor:p.bgSubtle,color:p.primary},children:m.jsx(bo,{className:"w-5 h-5"})}),m.jsxs("div",{children:[m.jsx("h2",{className:"type-micro",style:{color:p.text},children:"Wardriving Coverage"}),m.jsx("p",{className:"text-xs",style:{color:p.textMuted},children:"RF coverage heatmap overlay"})]})]}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(Jc,{status:C,hasData:eA}),!oA&&m.jsxs(m.Fragment,{children:[m.jsx("button",{onClick:TA,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:p.primary},children:"Done"}),m.jsx("button",{onClick:TA,className:"hidden sm:flex items-center justify-center p-2 rounded-lg transition-colors",style:{color:p.textMuted},onMouseEnter:mA=>{mA.currentTarget.style.color=p.text,mA.currentTarget.style.backgroundColor=p.hoverBg},onMouseLeave:mA=>{mA.currentTarget.style.color=p.textMuted,mA.currentTarget.style.backgroundColor="transparent"},"aria-label":"Close",children:m.jsx(Gr,{className:"w-5 h-5"})})]})]})]}),m.jsx(v0,{children:oA&&m.jsx(Xc,{status:C})}),m.jsxs(fo,{className:"space-y-4",children:[m.jsx(Af,{value:lA,onChange:DA,onSubmit:sA,disabled:oA}),m.jsx(v0,{children:C==="error"&&D&&Y&&m.jsx(Rs,{variant:"error",title:"Connection Failed",description:D,onDismiss:()=>cA(!1)})}),m.jsx(v0,{children:C==="success"&&eA&&m.jsx(Rs,{variant:"success",title:"Coverage Data Loaded",description:"Adjust opacity below, then close to view on map"})}),m.jsx(v0,{children:eA&&!oA&&m.jsx(qt.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:8},transition:pr.snappy,children:m.jsx(tf,{coverageCount:Q.coverageCount,repeaterCount:Q.repeaterCount,lastUpdated:Q.lastUpdated})})}),m.jsx(v0,{children:eA&&!oA&&m.jsx(ef,{value:L,onChange:AA})})]}),m.jsxs("div",{className:"flex items-center justify-between p-4 border-t",style:{borderColor:p.border},children:[m.jsx("div",{className:"flex items-center gap-1",children:m.jsx(v0,{children:eA&&m.jsxs(qt.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},exit:{opacity:0,x:-10},transition:pr.snappy,className:"flex items-center gap-1",children:[m.jsx(Is,{icon:T?m.jsx(eu,{className:"w-4 h-4"}):m.jsx(Io,{className:"w-4 h-4"}),label:T?"Hide":"Show",onClick:Z,disabled:oA,active:T}),m.jsx(Is,{icon:m.jsx(ou,{className:"w-4 h-4"}),label:"Clear",onClick:fA,disabled:oA,variant:"danger"})]})})}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(Lt,{plain:!0,color:"muted",onClick:TA,disabled:oA,children:eA?"Done":"Cancel"}),m.jsx(Lt,{color:"warning",onClick:sA,disabled:!CA,children:oA?m.jsxs(m.Fragment,{children:[m.jsx(Gn,{"data-slot":"icon",className:"animate-spin"}),C==="connecting"?"Connecting...":C==="loading"?"Loading...":"Processing..."]}):eA?m.jsxs(m.Fragment,{children:[m.jsx(go,{"data-slot":"icon"}),"Refresh"]}):m.jsxs(m.Fragment,{children:[m.jsx(ho,{"data-slot":"icon"}),"Connect"]})})]})]})]})})}const nf={bandwidth:.07,threshold:.1,opacity:1,strokeWidth:4.5};function Tn({label:u,value:c,min:p,max:y,step:x,unit:C,formatValue:T,onChange:Q}){const D=T?T(c):c.toFixed(2);return m.jsxs("div",{className:"flex items-center gap-2 sm:gap-2",children:[m.jsx("span",{className:"text-xs font-medium w-14 sm:w-16 shrink-0 text-fg-secondary",children:u}),m.jsx("input",{type:"range",min:p,max:y,step:x,value:c,onChange:E=>Q(parseFloat(E.target.value)),className:`flex-1 h-1.5 rounded-full appearance-none cursor-pointer bg-elevated + [&::-webkit-slider-thumb]:appearance-none + [&::-webkit-slider-thumb]:w-3.5 + [&::-webkit-slider-thumb]:h-3.5 + [&::-webkit-slider-thumb]:rounded-full + [&::-webkit-slider-thumb]:bg-sys-indigo + [&::-webkit-slider-thumb]:cursor-pointer + [&::-webkit-slider-thumb]:transition-transform + [&::-webkit-slider-thumb]:hover:scale-110 + [&::-webkit-slider-thumb]:shadow-md`}),m.jsxs("span",{className:"text-xs font-mono tabular-nums w-12 sm:w-14 text-right shrink-0 text-fg-muted",children:[D,C&&m.jsx("span",{className:"ml-0.5 opacity-70",children:C})]})]})}function jn({icon:u,label:c,value:p,subtext:y}){return m.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 py-0.5 sm:py-1",children:[m.jsx("div",{className:"text-fg-muted",children:u}),m.jsx("div",{className:"flex-1 min-w-0",children:m.jsx("div",{className:"text-[10px] sm:text-xs truncate text-fg-secondary",children:c})}),m.jsxs("div",{className:"text-right",children:[m.jsx("div",{className:"text-xs font-mono tabular-nums text-fg-primary",children:p}),y&&m.jsx("div",{className:"text-[9px] leading-tight opacity-70 text-fg-muted",children:y})]})]})}function sf({visible:u,onClose:c,settings:p,onSettingsChange:y,partition:x,totalNodes:C,basemapMode:T="dark"}){const Q=tu(),D=j.useRef(null),E=j.useMemo(()=>{if(!x)return{numCommunities:0,avgCommunitySize:0,minCommunitySize:0,maxCommunitySize:0,fiedlerValue:0,modularity:0,coveragePercent:0};const z=Array.from(x.communities.values()).map(V=>V.length),Z=z.reduce((V,AA)=>V+AA,0);return{numCommunities:x.numCommunities,avgCommunitySize:z.length>0?Math.round(Z/z.length):0,minCommunitySize:z.length>0?Math.min(...z):0,maxCommunitySize:z.length>0?Math.max(...z):0,fiedlerValue:x.fiedlerValue,modularity:0,coveragePercent:C>0?Math.round(Z/C*100):0}},[x,C]),L=(z,Z)=>{y({...p,[z]:Z})},O=(p.bandwidth*111).toFixed(1);return m.jsx("div",{ref:D,className:"absolute inset-0 z-[600] pointer-events-none",children:m.jsx(v0,{children:u&&m.jsx(qt.div,{drag:!0,dragControls:Q,dragConstraints:D,dragElastic:.1,dragMomentum:!1,initial:{opacity:0,scale:.95,y:10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:10},transition:pr.smooth,className:` + absolute pointer-events-auto + /* Mobile: bottom sheet style, full width with margins */ + bottom-2 left-2 right-2 + /* sm+: floating panel in bottom-right */ + sm:bottom-16 sm:left-auto sm:right-3 sm:w-64 + /* md+: slightly wider */ + md:w-72 + `,style:{touchAction:"none"},children:m.jsxs("div",{className:` + map-control-surface rounded-lg overflow-hidden shadow-lg + /* Mobile: limit height, allow scroll */ + max-h-[45vh] sm:max-h-[calc(100vh-180px)] overflow-y-auto + /* iOS momentum scrolling */ + overscroll-contain + `,children:[m.jsxs("div",{className:` + flex items-center justify-between + px-3 py-2 sm:px-2.5 sm:py-1.5 + border-b border-edge-subtle + cursor-grab active:cursor-grabbing + min-h-[44px] sm:min-h-0 + `,onPointerDown:z=>Q.start(z),children:[m.jsxs("div",{className:"flex items-center gap-2 sm:gap-1.5",children:[m.jsx(ru,{className:"w-4 h-4 sm:w-3 sm:h-3 text-fg-muted"}),m.jsx(vi,{className:"w-4 h-4 sm:w-3.5 sm:h-3.5 text-sys-blue"}),m.jsx("span",{className:"text-sm sm:text-xs font-medium text-fg-primary",children:"Partition"})]}),m.jsx(Lt,{plain:!0,color:"muted",onClick:c,className:"!p-1.5 sm:!p-0.5 !rounded min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 flex items-center justify-center","aria-label":"Close toolbox",children:m.jsx(Gr,{className:"w-4 h-4 sm:w-3 sm:h-3"})})]}),m.jsx("div",{className:"px-3 py-2 sm:px-2.5 sm:py-1.5 border-b border-edge-subtle",children:m.jsxs("div",{className:"grid grid-cols-2 gap-x-4 sm:gap-x-3 gap-y-1 sm:gap-y-0.5",children:[m.jsx(jn,{icon:m.jsx(vi,{className:"w-3.5 h-3.5 sm:w-3 sm:h-3"}),label:"Communities",value:E.numCommunities}),m.jsx(jn,{icon:m.jsx(as,{className:"w-3.5 h-3.5 sm:w-3 sm:h-3"}),label:"Avg Size",value:E.avgCommunitySize,subtext:`${E.minCommunitySize}–${E.maxCommunitySize}`}),m.jsx(jn,{icon:m.jsx(Mu,{className:"w-3.5 h-3.5 sm:w-3 sm:h-3"}),label:"Fiedler λ₂",value:E.fiedlerValue.toFixed(3)}),m.jsx(jn,{icon:m.jsx(as,{className:"w-3.5 h-3.5 sm:w-3 sm:h-3"}),label:"Coverage",value:`${E.coveragePercent}%`,subtext:`of ${C}`})]})}),m.jsx("div",{className:"px-3 py-2 sm:px-2.5 sm:py-1.5",children:m.jsxs("div",{className:"space-y-3 sm:space-y-1.5",children:[m.jsx(Tn,{label:"Bandwidth",value:p.bandwidth,min:.01,max:.15,step:.005,formatValue:()=>O,unit:"km",onChange:z=>L("bandwidth",z)}),m.jsx(Tn,{label:"Threshold",value:p.threshold,min:.05,max:.5,step:.01,formatValue:z=>`${Math.round((1-z)*100)}%`,unit:"cov",onChange:z=>L("threshold",z)}),m.jsx(Tn,{label:"Opacity",value:p.opacity,min:.1,max:1,step:.05,formatValue:z=>`${Math.round(z*100)}%`,onChange:z=>L("opacity",z)}),m.jsx(Tn,{label:"Stroke",value:p.strokeWidth,min:0,max:5,step:.5,unit:"px",formatValue:z=>z.toFixed(1),onChange:z=>L("strokeWidth",z)})]})})]})})})})}const of={excellent:"text-signal-excellent",good:"text-signal-good",fair:"text-signal-fair",poor:"text-signal-poor",critical:"text-signal-critical"};function fn(u,c){return of[Eo(u,c)]}const lf={backgroundColor:"var(--map-ui-hover, var(--elevated))",color:"var(--map-ui-text, var(--fg-primary))",boxShadow:"inset 0 0 0 1px var(--map-ui-border-strong, var(--edge-strong))"},af={backgroundColor:"var(--map-ui-bg, var(--body))",color:"var(--map-ui-text, var(--fg-primary))",boxShadow:"0 1px 4px rgba(0,0,0,0.15), inset 0 0 0 1px var(--map-ui-border, var(--edge-subtle))"};function Fr({prefix:u,name:c}){const p=j.useRef(null),[y,x]=j.useState(!1),[C,T]=j.useState({top:0,left:0}),Q=()=>{if(!c||!p.current)return;const D=p.current.getBoundingClientRect();T({top:D.top-4,left:D.left+D.width/2}),x(!0)};return m.jsxs(m.Fragment,{children:[m.jsx("span",{ref:p,className:"inline-flex items-center px-1.5 py-0.5 rounded font-mono text-[10px] font-semibold transition-opacity hover:opacity-80 cursor-default",style:lf,onMouseEnter:Q,onMouseLeave:()=>x(!1),children:u}),c&&y&&va.createPortal(m.jsx("span",{className:"fixed z-[9999] pointer-events-none -translate-x-1/2 -translate-y-full whitespace-nowrap rounded px-1.5 py-0.5 text-[10px] font-medium",style:{...af,top:C.top,left:C.left},children:c}),document.body)]})}function Ko(u){if(u._tracePathHashes)return u._tracePathHashes;if(u.payload&&u.payload.length>=20){const c=u.payload.slice(18),p=[];for(let y=0;y0?p:null}return null}function Zo(u,c){return u.src_hash?[u.src_hash.replace(/^0x/i,"").slice(0,2).toUpperCase(),...c.map(y=>y.toUpperCase())]:c.map(p=>p.toUpperCase())}function uf(u,c,p,y=15){const x=[],C=c.toUpperCase(),T=p.toUpperCase();for(const Q of u){if((Q.type??Q.payload_type)!==wa.TRACE)continue;const E=Ko(Q);if(!E||E.length<1)continue;const L=Zo(Q,E);if(!(L.length<2)){for(let O=0;O=y)break}}return x}function cf(u){switch(u){case"improving":return m.jsx(ka,{className:"w-3 h-3 text-sys-green"});case"degrading":return m.jsx(Tu,{className:"w-3 h-3 text-sys-red"});case"stable":return m.jsx(xo,{className:"w-3 h-3 text-fg-muted"});default:return null}}const ff={backgroundColor:"var(--map-ui-stripe)"};function Pn({label:u,value:c,unit:p,color:y,tooltip:x}){return m.jsxs("div",{className:`flex items-center justify-between gap-2 py-[3px] ${x?"cursor-help":""}`,title:x,children:[m.jsx("span",{className:"type-data-xs text-fg-muted",children:u}),m.jsxs("span",{className:`data-box data-box-compact ${y||""}`,children:[c,p&&m.jsx("span",{className:"text-fg-muted ml-0.5",children:p})]})]})}function Ls({stats:u,direction:c,sf:p,noiseFloor:y}){if(!u)return m.jsxs("div",{className:"min-w-0",children:[m.jsx("div",{className:"flex items-center justify-between mb-1.5",children:m.jsx("p",{className:"type-data-xs text-fg-secondary font-medium",children:c})}),m.jsx("p",{className:"type-data-xs text-fg-muted italic px-1.5",children:"No data"})]});const x=u.max-u.min,C=u.median-u.mean,T=ba(p),Q=u.mean-T,D=Eo(u.mean,p),E=[`Mean SNR: ${u.mean.toFixed(1)} dB (${D}) from ${u.count} measurement${u.count!==1?"s":""}`,`Variability: ±${u.stdDev.toFixed(1)} dB`,"",`Link budget (SF${p}, 3.5 dBi omni):`,` Demod threshold: ${T.toFixed(1)} dB`,` SNR margin: ${Q>=0?"+":""}${Q.toFixed(1)} dB`];return y!=null&&E.push(` Noise floor: ${y} dBm`),m.jsxs("div",{className:"min-w-0",children:[m.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[m.jsx("p",{className:"type-data-xs text-fg-secondary font-medium",children:c}),m.jsxs("span",{className:"type-data-xs text-fg-muted tabular-nums",title:`${u.count} measurement${u.count!==1?"s":""}`,children:["n=",u.count]})]}),m.jsx(Pn,{label:"Mean",value:u.mean.toFixed(1),unit:"dB",color:fn(u.mean,p),tooltip:E.join(` +`)}),m.jsx(Pn,{label:"Median",value:u.median.toFixed(1),unit:"dB",tooltip:`Middle value — less affected by unusual readings than the average.${Math.abs(C)>=.15?` +Differs from mean by ${C>0?"+":""}${C.toFixed(1)} dB`:""}`}),m.jsx(Pn,{label:"Range",value:`${u.min.toFixed(1)}–${u.max.toFixed(1)}`,unit:"dB",tooltip:`Best to worst signal observed. Total spread: ${x.toFixed(1)} dB.`})]})}function hf({pair:u,onClose:c,prefixToName:p}){var bA,sA,fA,DA,TA,CA,mA,IA,NA,FA,GA,vA;const y=ko(),x=ma(),C=ga(),T=pa(),[Q,D]=j.useState(null),E=((sA=(bA=C==null?void 0:C.config)==null?void 0:bA.radio)==null?void 0:sA.spreading_factor)??ya,L=j.useMemo(()=>{const uA=`${u.nodeA.hash}>${u.nodeB.hash}`,hA=`${u.nodeB.hash}>${u.nodeA.hash}`;return{forward:y.get(uA)??null,reverse:y.get(hA)??null}},[y,u.nodeA.hash,u.nodeB.hash]),O=j.useMemo(()=>!x||x.length===0?[]:uf(x,u.nodeA.prefix,u.nodeB.prefix),[x,u.nodeA.prefix,u.nodeB.prefix]),z=u.nodeA.name||(p==null?void 0:p.get(u.nodeA.prefix.toUpperCase()))||null,Z=u.nodeB.name||(p==null?void 0:p.get(u.nodeB.prefix.toUpperCase()))||null,V=((fA=L.forward)==null?void 0:fA.trend)??((DA=L.reverse)==null?void 0:DA.trend)??"insufficient",AA=Math.max(((TA=L.forward)==null?void 0:TA.lastSeen)??0,((CA=L.reverse)==null?void 0:CA.lastSeen)??0),oA=(((mA=L.forward)==null?void 0:mA.uniqueTraceCount)??0)+(((IA=L.reverse)==null?void 0:IA.uniqueTraceCount)??0),eA=V==="insufficient"?"Not enough data to determine trend (need at least 4 measurements).":`Whether signal quality is getting better or worse over time. +Compares older measurements to newer ones.`,Y=((NA=L.forward)==null?void 0:NA.uniqueTraceCount)??0,cA=((FA=L.reverse)==null?void 0:FA.uniqueTraceCount)??0,lA=["Number of trace packets that traveled through this link.",`${u.nodeA.prefix}→${u.nodeB.prefix}: ${Y}`,`${u.nodeB.prefix}→${u.nodeA.prefix}: ${cA}`].join(` +`);return m.jsx("div",{className:` + absolute z-[700] overflow-hidden + /* Mobile: full-width bottom sheet with breathing room */ + bottom-2 left-2 right-2 + /* sm+: right-aligned floating panel */ + sm:bottom-16 sm:left-auto sm:right-4 sm:w-[280px] + `,children:m.jsxs("div",{className:` + map-control-surface flex flex-col + /* Mobile: cap at 45vh so map stays visible */ + max-h-[45vh] + /* sm+: taller allowance */ + sm:max-h-[420px] + `,children:[m.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:[m.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[m.jsx(Oo,{className:"w-4 h-4 sm:w-3.5 sm:h-3.5 text-sys-green shrink-0"}),m.jsx(Fr,{prefix:u.nodeA.prefix,name:z}),m.jsx("span",{className:"type-data-xs text-fg-muted",children:"↔"}),m.jsx(Fr,{prefix:u.nodeB.prefix,name:Z})]}),m.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[AA>0&&m.jsx("span",{className:"type-data-xs text-fg-muted",title:us(AA),children:Co(AA)}),m.jsx(Lt,{plain:!0,color:"muted",onClick:c,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:m.jsx(Gr,{className:"w-4 h-4 sm:w-3.5 sm:h-3.5"})})]})]}),m.jsxs("div",{className:"px-3 py-2.5 border-b border-edge-subtle",children:[m.jsxs("div",{className:"space-y-1.5 mb-2",children:[m.jsxs("div",{className:"flex items-center justify-between cursor-help",title:`${u.nodeA.prefix}→${u.nodeB.prefix}: mean of ${((GA=u.aToB)==null?void 0:GA.count)??0} measurements`,children:[m.jsxs("span",{className:"flex items-center gap-1",children:[m.jsx(Fr,{prefix:u.nodeA.prefix,name:z}),m.jsx("span",{className:"type-data-xs text-fg-muted",children:"→"}),m.jsx(Fr,{prefix:u.nodeB.prefix,name:Z})]}),u.aToB?m.jsxs("span",{className:`type-data-sm tabular-nums font-semibold ${fn(u.aToB.mean,E)}`,children:[u.aToB.mean.toFixed(1),m.jsx("span",{className:"text-fg-muted font-normal ml-0.5",children:"dB"})]}):m.jsx("span",{className:"type-data-sm text-fg-muted",children:"—"})]}),m.jsxs("div",{className:"flex items-center justify-between cursor-help",title:`${u.nodeB.prefix}→${u.nodeA.prefix}: mean of ${((vA=u.bToA)==null?void 0:vA.count)??0} measurements`,children:[m.jsxs("span",{className:"flex items-center gap-1",children:[m.jsx(Fr,{prefix:u.nodeB.prefix,name:Z}),m.jsx("span",{className:"type-data-xs text-fg-muted",children:"→"}),m.jsx(Fr,{prefix:u.nodeA.prefix,name:z})]}),u.bToA?m.jsxs("span",{className:`type-data-sm tabular-nums font-semibold ${fn(u.bToA.mean,E)}`,children:[u.bToA.mean.toFixed(1),m.jsx("span",{className:"text-fg-muted font-normal ml-0.5",children:"dB"})]}):m.jsx("span",{className:"type-data-sm text-fg-muted",children:"—"})]})]}),m.jsxs("div",{className:"grid grid-cols-2 gap-0 -mx-3 border-t border-edge-subtle",children:[m.jsx("div",{className:"px-3 pt-2 pb-1 border-r border-edge-subtle",children:m.jsx(Ls,{stats:u.aToB,direction:`${u.nodeA.prefix}→${u.nodeB.prefix}`,sf:E,noiseFloor:T})}),m.jsx("div",{className:"px-3 pt-2 pb-1",children:m.jsx(Ls,{stats:u.bToA,direction:`${u.nodeB.prefix}→${u.nodeA.prefix}`,sf:E,noiseFloor:T})})]})]}),m.jsxs("div",{className:"px-3 py-1.5 border-b border-edge-subtle",children:[V!=="insufficient"&&m.jsxs("div",{className:"flex items-center justify-between gap-2 py-[3px] cursor-help",title:eA,children:[m.jsx("span",{className:"type-data-xs text-fg-muted",children:"Trend"}),m.jsx("span",{className:"data-box data-box-compact",children:m.jsxs("span",{className:"flex items-center gap-1",children:[cf(V),m.jsx("span",{className:"text-fg-secondary capitalize",children:V})]})})]}),oA>0&&m.jsx(Pn,{label:"Unique traces",value:oA.toString(),tooltip:lA})]}),O.length>0&&m.jsxs("div",{className:"px-3 py-2 flex-1 min-h-0 flex flex-col",children:[m.jsxs("p",{className:"type-micro text-fg-secondary mb-1 shrink-0",children:["Source packets (",O.length,")"]}),m.jsx("div",{className:"overflow-y-auto flex-1 min-h-0 overscroll-contain",style:{scrollbarGutter:"stable"},children:O.map((uA,hA)=>{const jA=Ko(uA),BA=jA?Zo(uA,jA):null,VA=BA?Math.max(0,BA.length-1):0,ue=BA?BA.map(UA=>(p==null?void 0:p.get(UA))??UA).join(" → "):null,JA=Q===hA,KA=uA.id??`${uA.packet_hash}-${uA.timestamp}`;return m.jsxs("div",{className:"rounded-sm",style:hA%2===1?ff:void 0,children:[m.jsxs("button",{onClick:()=>D(JA?null:hA),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?m.jsx(yo,{className:"w-2.5 h-2.5 text-fg-muted shrink-0"}):m.jsx(cu,{className:"w-2.5 h-2.5 text-fg-muted shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"}),m.jsx("span",{className:"text-fg-muted w-[52px] shrink-0",children:us(uA.timestamp)}),ue?m.jsx("span",{className:"text-fg-secondary truncate min-w-0",title:BA.join(" → "),children:ue}):m.jsx("span",{className:"text-fg-muted truncate min-w-0 italic",children:"path n/a"}),m.jsxs("span",{className:"text-fg-muted shrink-0",children:[VA,"h"]}),uA.snr!=null&&m.jsx("span",{className:`shrink-0 tabular-nums ${fn(uA.snr,E)}`,children:uA.snr.toFixed(1)})]}),JA&&m.jsxs("div",{className:"mb-1 mt-0.5 mx-1 pl-2 border-l border-edge-subtle space-y-0.5 text-[10px]",children:[uA.rssi!=null&&m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsx("span",{className:"text-fg-muted",children:"RSSI"}),m.jsxs("span",{className:"font-mono tabular-nums text-fg-secondary",children:[uA.rssi," dBm"]})]}),uA.snr!=null&&m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsx("span",{className:"text-fg-muted",children:"SNR"}),m.jsxs("span",{className:`font-mono tabular-nums ${fn(uA.snr,E)}`,children:[uA.snr.toFixed(1)," dB"]})]}),m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsx("span",{className:"text-fg-muted",children:"Route"}),m.jsx("span",{className:"font-mono text-fg-secondary",children:xa(uA.route??uA.route_type)})]}),uA.packet_hash&&m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsx("span",{className:"text-fg-muted",children:"Hash"}),m.jsxs("button",{onClick:UA=>{UA.stopPropagation(),Wn(uA.packet_hash)},className:"flex items-center gap-1 font-mono text-fg-secondary hover:text-fg-primary transition-colors",title:"Copy packet hash",children:[m.jsx("span",{className:"truncate max-w-[120px]",children:uA.packet_hash}),m.jsx(Vn,{className:"w-2.5 h-2.5 text-fg-muted shrink-0"})]})]}),uA.src_hash&&m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsx("span",{className:"text-fg-muted",children:"Source"}),m.jsx("span",{className:"font-mono text-fg-secondary truncate max-w-[140px]",title:uA.src_hash,children:uA.src_hash})]}),BA&&BA.length>0&&m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsx("span",{className:"text-fg-muted",children:"Path"}),m.jsx("span",{className:"font-mono text-fg-secondary truncate max-w-[140px]",title:BA.join(" → "),children:BA.join(" → ")})]})]})]},KA)})})]})]})})}const $o=[{target:"Sparklines",fn:"sparklines",minStage:2}];Ro($o);const qo=j.memo(function({nodeHash:c,width:p=60,height:y=20,color:x,showArea:C=!0,showTooltip:T=!1,className:Q=""}){jo($o);const D=Ca(c),E=Ea(),O=!So().backgroundLoadComplete||E,z=typeof p=="number"?p:60;return m.jsx(fu,{data:D,width:z,height:y,color:x,isLoading:O,className:Q})});function df(u){return u===null?"—":u<1e3?`${Math.round(u)}m`:`${(u/1e3).toFixed(1)}km`}function mf(u){const c=new Date(u*1e3);return`${(c.getMonth()+1).toString().padStart(2,"0")}/${c.getDate().toString().padStart(2,"0")}`}function gf({txDelayRec:u,networkRole:c,roleTitles:p,dataConfidence:y,dataQualityTitles:x}){const[C,T]=j.useState(!1),Q=u.floodFactor??u.txDelayFactor,D=u.directFactor??u.directTxDelayFactor,E=async()=>{const L=`set txdelay ${Q.toFixed(1)} +set direct.txdelay ${D.toFixed(1)}`;await Wn(L),T(!0),setTimeout(()=>T(!1),1500)};return m.jsxs("div",{className:"flex flex-col gap-1.5 text-sm",children:[(c||y)&&m.jsxs("div",{className:"flex items-center gap-2",children:[c&&m.jsx(mt,{color:du[c],compact:!0,title:p[c],children:c}),y&&m.jsxs(mt,{color:mu[y],compact:!0,title:x[y],children:[y," data"]})]}),m.jsxs("button",{onClick:E,className:"flex items-center gap-2 py-1.5 px-2 bg-subtle-fill hover:bg-subtle-fill-hover rounded transition-colors group",title:"Click to copy CLI commands",children:[m.jsx(Ru,{className:"w-3.5 h-3.5 text-sys-amber shrink-0"}),m.jsx("span",{className:"text-fg-muted",children:"TxDelay"}),m.jsxs("div",{className:"flex gap-2",children:[m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx("span",{className:"text-fg-muted",children:"F"}),m.jsxs("span",{className:"data-box text-sys-amber",children:["×",Q.toFixed(1)]})]}),m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx("span",{className:"text-fg-muted",children:"D"}),m.jsxs("span",{className:"data-box text-sys-amber",children:["×",D.toFixed(1)]})]})]}),C?m.jsx(Hr,{className:"w-3.5 h-3.5 text-sys-green ml-auto"}):m.jsx(Vn,{className:"w-3.5 h-3.5 text-fg-muted opacity-0 group-hover:opacity-100 transition-opacity ml-auto"})]})]})}function pf({hash:u,hashPrefix:c,name:p,isHub:y,isGateway:x,isBackbone:C,isZeroHop:T,isMobile:Q,isRoomServer:D,isStale:E,lastSeenTimestamp:L,centrality:O,affinity:z,meanSnr:Z,meanRssi:V,neighbor:AA,onRemove:oA,txDelayRec:eA,hideHeader:Y=!1}){const[cA,lA]=j.useState(!1),bA=async()=>{await Wn(u),lA(!0),setTimeout(()=>lA(!1),1500)},sA=T?"Direct":z!=null&&z.typicalHopPosition?`${z.typicalHopPosition}-hop`:null,fA=eA&&!eA.insufficientData,DA={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"},TA={high:"1000+ packets",medium:"500-999 packets",low:"100-499 packets",insufficient:"Insufficient data"};return m.jsxs("div",{children:[!Y&&m.jsx("div",{className:"text-[14px] font-semibold text-fg-primary leading-tight truncate mb-1",children:p}),!Y&&m.jsxs("div",{className:"flex items-center gap-1 flex-wrap mb-1.5",children:[m.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:c}),m.jsx("button",{onClick:bA,className:"p-0.5 hover:bg-subtle-fill-hover rounded transition-colors",title:"Copy full hash",children:cA?m.jsx(Hr,{className:"w-3 h-3 text-sys-green"}):m.jsx(Vn,{className:"w-3 h-3 text-fg-secondary"})}),m.jsx(Fo,{hash:u,size:"sm"}),sA&&m.jsx(mt,{color:T?On.direct:On.multihop,compact:!0,children:sA}),AA.is_repeater&&m.jsx(mt,{color:s0.repeater,compact:!0,children:"Rptr"}),y&&m.jsx(mt,{color:s0.hub,compact:!0,title:"Hub: ≥10% of last-hop traffic",children:"Hub"}),x&&!y&&m.jsx(mt,{color:s0.gateway,compact:!0,title:"Gateway: 7-10% of last-hop traffic",children:"Gate"}),C&&m.jsx(mt,{color:s0.backbone,compact:!0,title:"Backbone",children:"Bone"}),Q&&m.jsx(mt,{color:s0.mobile,compact:!0,children:"Mobile"}),D&&m.jsx(mt,{color:s0.room,compact:!0,children:"Room"}),E&&L&&m.jsxs(mt,{compact:!0,title:"Neighbor not heard in 7+ days",children:["Idle ",mf(L)]})]}),m.jsx("div",{title:"7-day activity trend (6-hour buckets)",children:m.jsx(qo,{nodeHash:u,width:224,height:28,showArea:!0,showTooltip:!0,className:"w-full"})}),m.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-0.5 text-sm text-fg-secondary mt-2",children:[m.jsxs("span",{className:"flex items-center gap-0.5",title:AA.last_seen?`Last heard: ${new Date(AA.last_seen*1e3).toLocaleString()}`:"Last heard time",children:[m.jsx(No,{className:"w-3 h-3 text-fg-muted shrink-0"}),m.jsx("span",{className:"font-mono",children:Co(AA.last_seen)})]}),(z==null?void 0:z.distanceMeters)&&m.jsxs("span",{className:"flex items-center gap-0.5",title:"Line-of-sight distance from local node",children:[m.jsx(hu,{className:"w-3 h-3 text-fg-muted shrink-0"}),m.jsx("span",{className:"font-mono font-semibold text-fg-primary",children:df(z.distanceMeters)})]}),AA.latitude&&AA.longitude&&AA.latitude!==0&&AA.longitude!==0&&m.jsxs("span",{className:"flex items-center gap-0.5",title:"GPS coordinates (lat, lon)",children:[m.jsx(gu,{className:"w-3 h-3 text-fg-muted shrink-0"}),m.jsxs("span",{className:"font-mono text-fg-muted",children:[AA.latitude.toFixed(2),", ",AA.longitude.toFixed(2)]})]})]}),m.jsxs("div",{className:"grid grid-cols-2 gap-x-3 gap-y-1.5 text-sm mt-2",children:[m.jsxs("div",{className:"flex justify-between items-center gap-2",title:"Total packets seen from this node",children:[m.jsx("span",{className:"text-fg-muted",children:"Packets"}),m.jsx("span",{className:"data-box",children:(z==null?void 0:z.frequency)||0})]}),m.jsxs("div",{className:"flex justify-between items-center gap-2",title:"ADVERT beacon packets received",children:[m.jsx("span",{className:"text-fg-muted",children:"Adverts"}),m.jsx("span",{className:"data-box",children:AA.advert_count||0})]}),T&&Z!==void 0&&m.jsxs("div",{className:"flex justify-between items-center gap-2",title:"Average Signal-to-Noise Ratio (direct zero-hop)",children:[m.jsx("span",{className:"text-fg-muted",children:"SNR"}),m.jsxs("span",{className:"data-box",children:[Z.toFixed(1)," dB"]})]}),T&&V!==void 0&&m.jsxs("div",{className:"flex justify-between items-center gap-2",title:"Average Received Signal Strength (direct zero-hop)",children:[m.jsx("span",{className:"text-fg-muted",children:"RSSI"}),m.jsxs("span",{className:"data-box",children:[Math.round(V)," dBm"]})]})]}),fA&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"border-t border-edge-subtle mt-2.5 mb-2"}),m.jsx(gf,{txDelayRec:eA,networkRole:eA.networkRole,roleTitles:DA,dataConfidence:eA.dataConfidence,dataQualityTitles:TA})]}),oA&&m.jsx("button",{onClick:oA,className:"w-full text-center text-sm mt-2 py-3 sm:py-1.5 rounded text-fg-muted hover:text-sys-red hover:bg-sys-red/10 transition-colors",children:"Remove from Contacts"})]})}function yf(u){const c=new Date(u*1e3);return`${(c.getMonth()+1).toString().padStart(2,"0")}/${c.getDate().toString().padStart(2,"0")}`}function xf({data:u,localNode:c,localColor:p,onClose:y,onRemove:x}){var E,L,O,z;const[C,T]=j.useState(!1);j.useEffect(()=>{if(!u)return;const Z=V=>{V.key==="Escape"&&y()};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[u,y]);const Q=async()=>{u!=null&&u.hash&&(await Wn(u.hash),T(!0),setTimeout(()=>T(!1),1500))},D=u!=null&&u.isZeroHop?"Direct":(E=u==null?void 0:u.affinity)!=null&&E.typicalHopPosition?`${u.affinity.typicalHopPosition}-hop`:null;return m.jsx(v0,{children:u&&m.jsx(qt.div,{className:"map-node-panel",initial:{opacity:0,y:16},animate:{opacity:1,y:0},exit:{opacity:0,y:16},transition:pr.smooth,children:m.jsxs("div",{className:"map-control-surface flex flex-col max-h-[38dvh] sm:max-h-[50vh]",children:[m.jsx("div",{className:"map-node-panel-drag-handle sm:hidden"}),m.jsxs("div",{className:"flex flex-col gap-1.5 px-3 py-2.5 shrink-0",children:[m.jsxs("div",{className:"flex items-start justify-between gap-2",children:[m.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[m.jsx("span",{className:"text-sm font-semibold truncate text-fg-primary",children:u.name||"Unknown"}),u.hash&&m.jsxs(m.Fragment,{children:[m.jsx("code",{className:"type-data-xs text-fg-secondary bg-data-box-bg border border-data-box-border px-1 py-0.5 rounded ml-1",children:u.hashPrefix||u.hash.substring(0,2)}),m.jsx("button",{onClick:Q,className:"p-2 -m-1.5 sm:p-0.5 sm:m-0 hover:bg-subtle-fill-hover rounded transition-colors",title:"Copy full hash",children:C?m.jsx(Hr,{className:"w-3 h-3 text-sys-green"}):m.jsx(Vn,{className:"w-3 h-3 text-fg-secondary"})}),m.jsx(Fo,{hash:u.hash,size:"sm"})]})]}),m.jsx(Lt,{plain:!0,color:"muted",onClick:y,className:"!p-1 !rounded-md -mr-1 -mt-1 hover:bg-subtle-fill-hover min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-0 flex items-center justify-center","aria-label":"Close node detail",children:m.jsx(Gr,{className:"w-4 h-4"})})]}),(D||((L=u.neighbor)==null?void 0:L.is_repeater)||u.isHub||u.isGateway&&!u.isHub||u.isBackbone||u.isMobile||u.isRoomServer||u.isStale&&u.lastSeenTimestamp)&&m.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[D&&m.jsx(mt,{color:u.isZeroHop?On.direct:On.multihop,compact:!0,title:u.isZeroHop?"Direct RF contact (zero-hop)":`${((O=u.affinity)==null?void 0:O.typicalHopPosition)??"?"} hops from local node`,children:D}),((z=u.neighbor)==null?void 0:z.is_repeater)&&m.jsx(mt,{color:s0.repeater,compact:!0,title:"Repeater node (forwards packets)",children:"Rptr"}),u.isHub&&m.jsx(mt,{color:s0.hub,compact:!0,title:"Hub: ≥10% of last-hop traffic",children:"Hub"}),u.isGateway&&!u.isHub&&m.jsx(mt,{color:s0.gateway,compact:!0,title:"Gateway: 7-10% of last-hop traffic",children:"Gate"}),u.isBackbone&&m.jsx(mt,{color:s0.backbone,compact:!0,title:"Backbone: critical relay with high traffic",children:"Bone"}),u.isMobile&&m.jsx(mt,{color:s0.mobile,compact:!0,title:"Mobile repeater (path volatility detected)",children:"Mobile"}),u.isRoomServer&&m.jsx(mt,{color:s0.room,compact:!0,title:"Room server node",children:"Room"}),u.isStale&&u.lastSeenTimestamp&&m.jsxs(mt,{compact:!0,title:"Neighbor not heard in 7+ days",children:["Idle ",yf(u.lastSeenTimestamp)]})]})]}),m.jsx("div",{className:"overflow-y-auto flex-1 min-h-0 overscroll-contain px-3 pt-2 pb-3",children:u.isLocal?m.jsxs("div",{className:"text-sm",children:[m.jsx("div",{className:"mb-2",children:m.jsx("span",{style:{color:p},className:"font-medium",children:"This Node (Local)"})}),u.hash&&m.jsx("div",{className:"mb-2",children:m.jsx(qo,{nodeHash:u.hash,width:224,height:28,showArea:!0,showTooltip:!0,className:"w-full"})}),c&&m.jsxs("div",{className:"text-xs text-fg-muted font-mono border-t border-edge-subtle pt-2",children:[c.latitude.toFixed(5),", ",c.longitude.toFixed(5)]})]}):u.neighbor&&u.hash?m.jsx(pf,{hash:u.hash,hashPrefix:u.hashPrefix,name:u.name,isHub:u.isHub,isGateway:u.isGateway,isBackbone:u.isBackbone,isZeroHop:u.isZeroHop,isMobile:u.isMobile,isRoomServer:u.isRoomServer,isStale:u.isStale,lastSeenTimestamp:u.lastSeenTimestamp,centrality:u.centrality,affinity:u.affinity,meanSnr:u.meanSnr,meanRssi:u.meanRssi,neighbor:u.neighbor,txDelayRec:u.txDelayRec,onRemove:x?()=>x(u.hash,u.name):void 0,hideHeader:!0}):null})]})})})}const wf={getItem:u=>{try{return localStorage.getItem(u)}catch{return null}},setItem:(u,c)=>{try{localStorage.setItem(u,c)}catch{}},removeItem:u=>{try{localStorage.removeItem(u)}catch{}}},Jo=wo()(Ya(u=>({isEnabled:!1,toggle:()=>u(c=>({isEnabled:!c.isEnabled})),setEnabled:c=>u({isEnabled:c})}),{name:"pymc-live-trace",storage:Ka(()=>wf)})),vf=()=>Jo(u=>u.isEnabled),bf=()=>Jo(u=>u.toggle);var Nt=(function(u){u=u||{};var c=typeof u<"u"?u:{},p={},y;for(y in c)c.hasOwnProperty(y)&&(p[y]=c[y]);var x="";function C(rA){return c.locateFile?c.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,RA,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){RA(t.response);return}var pe=c0(pA);if(pe){RA(pe.buffer);return}xA()},t.onerror=xA,t.send(null)};var Q=c.print||console.log.bind(console),D=c.printErr||console.warn.bind(console);for(y in p)p.hasOwnProperty(y)&&(c[y]=p[y]);p=null,c.arguments&&c.arguments;var E=0,L=function(rA){E=rA},O=function(){return E},z=8;function Z(rA,pA,RA,xA){switch(RA=RA||"i8",RA.charAt(RA.length-1)==="*"&&(RA="i32"),RA){case"i1":IA[rA>>0]=pA;break;case"i8":IA[rA>>0]=pA;break;case"i16":FA[rA>>1]=pA;break;case"i32":GA[rA>>2]=pA;break;case"i64":ot=[pA>>>0,(Ge=pA,+Ee(Ge)>=1?Ge>0?($e(+ye(Ge/4294967296),4294967295)|0)>>>0:~~+Me((Ge-+(~~Ge>>>0))/4294967296)>>>0:0)],GA[rA>>2]=ot[0],GA[rA+4>>2]=ot[1];break;case"float":vA[rA>>2]=pA;break;case"double":uA[rA>>3]=pA;break;default:gt("invalid type for setValue: "+RA)}}function V(rA,pA,RA){switch(pA=pA||"i8",pA.charAt(pA.length-1)==="*"&&(pA="i32"),pA){case"i1":return IA[rA>>0];case"i8":return IA[rA>>0];case"i16":return FA[rA>>1];case"i32":return GA[rA>>2];case"i64":return GA[rA>>2];case"float":return vA[rA>>2];case"double":return uA[rA>>3];default:gt("invalid type for getValue: "+pA)}return null}var AA=!1;function oA(rA,pA){rA||gt("Assertion failed: "+pA)}function eA(rA){var pA=c["_"+rA];return oA(pA,"Cannot call unknown function "+rA+", make sure it is exported"),pA}function Y(rA,pA,RA,xA,t){var b={string:function(se){var rt=0;if(se!=null&&se!==0){var Qt=(se.length<<2)+1;rt=ut(Qt),DA(se,rt,Qt)}return rt},array:function(se){var rt=ut(se.length);return TA(se,rt),rt}};function pe(se){return pA==="string"?sA(se):pA==="boolean"?!!se:se}var De=eA(rA),Ve=[],ZA=0;if(xA)for(var xe=0;xe=xA);)++t;if(t-pA>16&&rA.subarray&&lA)return lA.decode(rA.subarray(pA,t));for(var b="";pA>10,56320|ZA&1023)}}return b}function sA(rA,pA){return rA?bA(NA,rA,pA):""}function fA(rA,pA,RA,xA){if(!(xA>0))return 0;for(var t=RA,b=RA+xA-1,pe=0;pe=55296&&De<=57343){var Ve=rA.charCodeAt(++pe);De=65536+((De&1023)<<10)|Ve&1023}if(De<=127){if(RA>=b)break;pA[RA++]=De}else if(De<=2047){if(RA+1>=b)break;pA[RA++]=192|De>>6,pA[RA++]=128|De&63}else if(De<=65535){if(RA+2>=b)break;pA[RA++]=224|De>>12,pA[RA++]=128|De>>6&63,pA[RA++]=128|De&63}else{if(RA+3>=b)break;pA[RA++]=240|De>>18,pA[RA++]=128|De>>12&63,pA[RA++]=128|De>>6&63,pA[RA++]=128|De&63}}return pA[RA]=0,RA-t}function DA(rA,pA,RA){return fA(rA,NA,pA,RA)}typeof TextDecoder<"u"&&new TextDecoder("utf-16le");function TA(rA,pA){IA.set(rA,pA)}function CA(rA,pA){return rA%pA>0&&(rA+=pA-rA%pA),rA}var mA,IA,NA,FA,GA,vA,uA;function hA(rA){mA=rA,c.HEAP8=IA=new Int8Array(rA),c.HEAP16=FA=new Int16Array(rA),c.HEAP32=GA=new Int32Array(rA),c.HEAPU8=NA=new Uint8Array(rA),c.HEAPU16=new Uint16Array(rA),c.HEAPU32=new Uint32Array(rA),c.HEAPF32=vA=new Float32Array(rA),c.HEAPF64=uA=new Float64Array(rA)}var jA=5271536,BA=28624,VA=c.TOTAL_MEMORY||33554432;c.buffer?mA=c.buffer:mA=new ArrayBuffer(VA),VA=mA.byteLength,hA(mA),GA[BA>>2]=jA;function ue(rA){for(;rA.length>0;){var pA=rA.shift();if(typeof pA=="function"){pA();continue}var RA=pA.func;typeof RA=="number"?pA.arg===void 0?c.dynCall_v(RA):c.dynCall_vi(RA,pA.arg):RA(pA.arg===void 0?null:pA.arg)}}var JA=[],KA=[],UA=[],Ie=[];function Le(){if(c.preRun)for(typeof c.preRun=="function"&&(c.preRun=[c.preRun]);c.preRun.length;)Ze(c.preRun.shift());ue(JA)}function ie(){ue(KA)}function ge(){ue(UA)}function be(){if(c.postRun)for(typeof c.postRun=="function"&&(c.postRun=[c.postRun]);c.postRun.length;)Ce(c.postRun.shift());ue(Ie)}function Ze(rA){JA.unshift(rA)}function Ce(rA){Ie.unshift(rA)}var Ee=Math.abs,Me=Math.ceil,ye=Math.floor,$e=Math.min,Je=0,At=null;function nt(rA){Je++,c.monitorRunDependencies&&c.monitorRunDependencies(Je)}function kt(rA){if(Je--,c.monitorRunDependencies&&c.monitorRunDependencies(Je),Je==0&&At){var pA=At;At=null,pA()}}c.preloadedImages={},c.preloadedAudios={};var Qe=null,Xe="data:application/octet-stream;base64,";function Be(rA){return String.prototype.startsWith?rA.startsWith(Xe):rA.indexOf(Xe)===0}var Ge,ot;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 Ft=28640;function C0(rA,pA,RA,xA){gt("Assertion failed: "+sA(rA)+", at: "+[pA?sA(pA):"unknown filename",RA,xA?sA(xA):"unknown function"])}function Jt(){return IA.length}function Xt(rA,pA,RA){NA.set(NA.subarray(pA,pA+RA),rA)}function F0(rA){return c.___errno_location&&(GA[c.___errno_location()>>2]=rA),rA}function X0(rA){gt("OOM")}function E0(rA){try{var pA=new ArrayBuffer(rA);return pA.byteLength!=rA?void 0:(new Int8Array(pA).set(IA),f0(pA),hA(pA),1)}catch{}}function Ut(rA){var pA=Jt(),RA=16777216,xA=2147483648-RA;if(rA>xA)return!1;for(var t=16777216,b=Math.max(pA,t);b>4,t=(De&15)<<4|Ve>>2,b=(Ve&3)<<6|ZA,RA=RA+String.fromCharCode(xA),Ve!==64&&(RA=RA+String.fromCharCode(t)),ZA!==64&&(RA=RA+String.fromCharCode(b));while(xe13780509?(A=xn(15,A)|0,A|0):(r=((e|0)<0)<<31>>31,i=ht(e|0,r|0,3,0)|0,n=S()|0,r=YA(e|0,r|0,1,0)|0,r=ht(i|0,n|0,r|0,S()|0)|0,r=YA(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,_(e,A,r,n,0)|0}function _(e,A,r,n,i){e=e|0,A=A|0,r=r|0,n=n|0,i=i|0;var s=0,o=0,l=0,a=0,f=0;if(a=k,k=k+16|0,o=a,!(P(e,A,r,n,i)|0))return n=0,k=a,n|0;do if((r|0)>=0){if((r|0)>13780509){if(s=xn(15,o)|0,s|0)break;l=o,o=t[l>>2]|0,l=t[l+4>>2]|0}else s=((r|0)<0)<<31>>31,f=ht(r|0,s|0,3,0)|0,l=S()|0,s=YA(r|0,s|0,1,0)|0,s=ht(f|0,l|0,s|0,S()|0)|0,s=YA(s|0,S()|0,1,0)|0,l=S()|0,t[o>>2]=s,t[o+4>>2]=l,o=s;if(W0(n|0,0,o<<3|0)|0,i|0){W0(i|0,0,o<<2|0)|0,s=J(e,A,r,n,i,o,l,0)|0;break}s=Gt(o,4)|0,s?(f=J(e,A,r,n,s,o,l,0)|0,qA(s),s=f):s=13}else s=2;while(!1);return f=s,k=a,f|0}function P(e,A,r,n,i){e=e|0,A=A|0,r=r|0,n=n|0,i=i|0;var s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=0,I=0,N=0,G=0;if(G=k,k=k+16|0,I=G,N=G+8|0,R=I,t[R>>2]=e,t[R+4>>2]=A,(r|0)<0)return N=2,k=G,N|0;if(s=n,t[s>>2]=e,t[s+4>>2]=A,s=(i|0)!=0,s&&(t[i>>2]=0),He(e,A)|0)return N=9,k=G,N|0;t[N>>2]=0;A:do if((r|0)>=1)if(s)for(g=1,f=0,M=0,R=1,s=e;;){if(!(f|M)){if(s=K(s,A,4,N,I)|0,s|0)break A;if(A=I,s=t[A>>2]|0,A=t[A+4>>2]|0,He(s,A)|0){s=9;break A}}if(s=K(s,A,t[26800+(M<<2)>>2]|0,N,I)|0,s|0)break A;if(A=I,s=t[A>>2]|0,A=t[A+4>>2]|0,e=n+(g<<3)|0,t[e>>2]=s,t[e+4>>2]=A,t[i+(g<<2)>>2]=R,e=f+1|0,o=(e|0)==(R|0),l=M+1|0,a=(l|0)==6,He(s,A)|0){s=9;break A}if(R=R+(a&o&1)|0,(R|0)>(r|0)){s=0;break}else g=g+1|0,f=o?0:e,M=o?a?0:l:M}else for(g=1,f=0,M=0,R=1,s=e;;){if(!(f|M)){if(s=K(s,A,4,N,I)|0,s|0)break A;if(A=I,s=t[A>>2]|0,A=t[A+4>>2]|0,He(s,A)|0){s=9;break A}}if(s=K(s,A,t[26800+(M<<2)>>2]|0,N,I)|0,s|0)break A;if(A=I,s=t[A>>2]|0,A=t[A+4>>2]|0,e=n+(g<<3)|0,t[e>>2]=s,t[e+4>>2]=A,e=f+1|0,o=(e|0)==(R|0),l=M+1|0,a=(l|0)==6,He(s,A)|0){s=9;break A}if(R=R+(a&o&1)|0,(R|0)>(r|0)){s=0;break}else g=g+1|0,f=o?0:e,M=o?a?0:l:M}else s=0;while(!1);return N=s,k=G,N|0}function J(e,A,r,n,i,s,o,l){e=e|0,A=A|0,r=r|0,n=n|0,i=i|0,s=s|0,o=o|0,l=l|0;var a=0,f=0,g=0,M=0,R=0,I=0,N=0,G=0,W=0,nA=0;if(G=k,k=k+16|0,I=G+8|0,N=G,a=Tr(e|0,A|0,s|0,o|0)|0,g=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=YA(a|0,g|0,1,0)|0,a=_r(a|0,S()|0,s|0,o|0)|0,g=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=i+(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=K(e,A,2,I,N)|0,a|0){case 9:{R=9;break}case 0:{a=N,a=J(t[a>>2]|0,t[a+4>>2]|0,r,n,i,s,o,f)|0,a||(R=9);break}}A:do if((R|0)==9){switch(t[I>>2]=0,a=K(e,A,3,I,N)|0,a|0){case 9:break;case 0:{if(a=N,a=J(t[a>>2]|0,t[a+4>>2]|0,r,n,i,s,o,f)|0,a|0)break A;break}default:break A}switch(t[I>>2]=0,a=K(e,A,1,I,N)|0,a|0){case 9:break;case 0:{if(a=N,a=J(t[a>>2]|0,t[a+4>>2]|0,r,n,i,s,o,f)|0,a|0)break A;break}default:break A}switch(t[I>>2]=0,a=K(e,A,5,I,N)|0,a|0){case 9:break;case 0:{if(a=N,a=J(t[a>>2]|0,t[a+4>>2]|0,r,n,i,s,o,f)|0,a|0)break A;break}default:break A}switch(t[I>>2]=0,a=K(e,A,4,I,N)|0,a|0){case 9:break;case 0:{if(a=N,a=J(t[a>>2]|0,t[a+4>>2]|0,r,n,i,s,o,f)|0,a|0)break A;break}default:break A}switch(t[I>>2]=0,a=K(e,A,6,I,N)|0,a|0){case 9:break;case 0:{if(a=N,a=J(t[a>>2]|0,t[a+4>>2]|0,r,n,i,s,o,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 K(e,A,r,n,i){e=e|0,A=A|0,r=r|0,n=n|0,i=i|0;var s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=0,I=0,N=0;if(r>>>0>6)return i=1,i|0;if(M=(t[n>>2]|0)%6|0,t[n>>2]=M,(M|0)>0){s=0;do r=Wt(r)|0,s=s+1|0;while((s|0)<(t[n>>2]|0))}if(M=wA(e|0,A|0,45)|0,S()|0,g=M&127,g>>>0>121)return i=5,i|0;a=Ht(e,A)|0,s=wA(e|0,A|0,52)|0,S()|0,s=s&15;A:do if(!s)f=8;else{for(;;){if(o=(15-s|0)*3|0,l=wA(e|0,A|0,o|0)|0,S()|0,l=l&7,(l|0)==7){A=5;break}if(N=(t0(s)|0)==0,s=s+-1|0,R=kA(7,0,o|0)|0,A=A&~(S()|0),I=kA(t[(N?432:16)+(l*28|0)+(r<<2)>>2]|0,0,o|0)|0,o=S()|0,r=t[(N?640:224)+(l*28|0)+(r<<2)>>2]|0,e=I|e&~R,A=o|A,!r){r=0;break A}if(!s){f=8;break A}}return A|0}while(!1);(f|0)==8&&(N=t[848+(g*28|0)+(r<<2)>>2]|0,I=kA(N|0,0,45)|0,e=I|e,A=S()|0|A&-1040385,r=t[4272+(g*28|0)+(r<<2)>>2]|0,(N&127|0)==127&&(N=kA(t[848+(g*28|0)+20>>2]|0,0,45)|0,A=S()|0|A&-1040385,r=t[4272+(g*28|0)+20>>2]|0,e=sr(N|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(je(l)|0){e:do if((Ht(e,A)|0)==1){if((g|0)!=(l|0))if(_0(l,t[7696+(g*28|0)>>2]|0)|0){e=$n(e,A)|0,o=1,A=S()|0;break}else OA(27795,26864,533,26872);switch(a|0){case 3:{e=sr(e,A)|0,A=S()|0,t[n>>2]=(t[n>>2]|0)+1,o=0;break e}case 5:{e=$n(e,A)|0,A=S()|0,t[n>>2]=(t[n>>2]|0)+5,o=0;break e}case 0:return N=9,N|0;default:return N=1,N|0}}else o=0;while(!1);if((r|0)>0){s=0;do e=Zn(e,A)|0,A=S()|0,s=s+1|0;while((s|0)!=(r|0))}if((g|0)!=(l|0)){if(!(Bt(l)|0)){if((o|0)!=0|(Ht(e,A)|0)!=5)break;t[n>>2]=(t[n>>2]|0)+1;break}switch(M&127){case 8:case 118:break A}(Ht(e,A)|0)!=3&&(t[n>>2]=(t[n>>2]|0)+1)}}else if((r|0)>0){s=0;do e=sr(e,A)|0,A=S()|0,s=s+1|0;while((s|0)!=(r|0))}while(!1);return t[n>>2]=((t[n>>2]|0)+r|0)%6|0,N=i,t[N>>2]=e,t[N+4>>2]=A,N=0,N|0}function aA(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,_A(e,A,r,n)|0?(W0(n|0,0,r*48|0)|0,n=XA(e,A,r,n)|0,n|0):(n=0,n|0)}function _A(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=0,I=0,N=0;if(N=k,k=k+16|0,R=N,I=N+8|0,M=R,t[M>>2]=e,t[M+4>>2]=A,(r|0)<0)return I=2,k=N,I|0;if(!r)return I=n,t[I>>2]=e,t[I+4>>2]=A,I=0,k=N,I|0;t[I>>2]=0;A:do if(He(e,A)|0)e=9;else{i=0,M=e;do{if(e=K(M,A,4,I,R)|0,e|0)break A;if(A=R,M=t[A>>2]|0,A=t[A+4>>2]|0,i=i+1|0,He(M,A)|0){e=9;break A}}while((i|0)<(r|0));g=n,t[g>>2]=M,t[g+4>>2]=A,g=r+-1|0,f=0,e=1;do{if(i=26800+(f<<2)|0,(f|0)==5)for(o=t[i>>2]|0,s=0,i=e;;){if(e=R,e=K(t[e>>2]|0,t[e+4>>2]|0,o,I,R)|0,e|0)break A;if((s|0)!=(g|0))if(a=R,l=t[a>>2]|0,a=t[a+4>>2]|0,e=n+(i<<3)|0,t[e>>2]=l,t[e+4>>2]=a,!(He(l,a)|0))e=i+1|0;else{e=9;break A}else e=i;if(s=s+1|0,(s|0)>=(r|0))break;i=e}else for(o=R,a=t[i>>2]|0,l=0,i=e,s=t[o>>2]|0,o=t[o+4>>2]|0;;){if(e=K(s,o,a,I,R)|0,e|0)break A;if(o=R,s=t[o>>2]|0,o=t[o+4>>2]|0,e=n+(i<<3)|0,t[e>>2]=s,t[e+4>>2]=o,e=i+1|0,He(s,o)|0){e=9;break A}if(l=l+1|0,(l|0)>=(r|0))break;i=e}f=f+1|0}while(f>>>0<6);e=R,e=(M|0)==(t[e>>2]|0)&&(A|0)==(t[e+4>>2]|0)?0:9}while(!1);return I=e,k=N,I|0}function XA(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=0;if(M=k,k=k+16|0,o=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(i=xn(15,o)|0,i|0)break;s=o,i=t[s>>2]|0,s=t[s+4>>2]|0}else i=((r|0)<0)<<31>>31,g=ht(r|0,i|0,3,0)|0,s=S()|0,i=YA(r|0,i|0,1,0)|0,i=ht(g|0,s|0,i|0,S()|0)|0,i=YA(i|0,S()|0,1,0)|0,s=S()|0,g=o,t[g>>2]=i,t[g+4>>2]=s;if(f=Gt(i,8)|0,!f)i=13;else{if(g=Gt(i,4)|0,!g){qA(f),i=13;break}if(i=J(e,A,r,f,g,i,s,0)|0,i|0){qA(f),qA(g);break}if(A=t[o>>2]|0,o=t[o+4>>2]|0,(o|0)>0|(o|0)==0&A>>>0>0){i=0,l=0,a=0;do e=f+(l<<3)|0,s=t[e>>2]|0,e=t[e+4>>2]|0,!((s|0)==0&(e|0)==0)&&(t[g+(l<<2)>>2]|0)==(r|0)&&(R=n+(i<<3)|0,t[R>>2]=s,t[R+4>>2]=e,i=i+1|0),l=YA(l|0,a|0,1,0)|0,a=S()|0;while((a|0)<(o|0)|(a|0)==(o|0)&l>>>0>>0)}qA(f),qA(g),i=0}}else i=2;while(!1);return R=i,k=M,R|0}function Ae(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0,o=0,l=0,a=0,f=0;for(l=k,k=k+16|0,s=l,o=l+8|0,i=(He(e,A)|0)==0,i=i?1:2;;){if(t[o>>2]=0,f=(K(e,A,i,o,s)|0)==0,a=s,f&((t[a>>2]|0)==(r|0)?(t[a+4>>2]|0)==(n|0):0)){e=4;break}if(i=i+1|0,i>>>0>=7){i=7,e=4;break}}return(e|0)==4?(k=l,i|0):0}function fe(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0,o=0,l=0,a=0,f=0;if(l=k,k=k+48|0,i=l+16|0,s=l+8|0,o=l,r=nn(r)|0,r|0)return o=r,k=l,o|0;if(f=e,a=t[f+4>>2]|0,r=s,t[r>>2]=t[f>>2],t[r+4>>2]=a,Ki(s,i),r=iA(i,A,o)|0,!r){if(A=t[s>>2]|0,s=t[e+8>>2]|0,(s|0)>0){i=t[e+12>>2]|0,r=0;do A=(t[i+(r<<3)>>2]|0)+A|0,r=r+1|0;while((r|0)<(s|0))}r=o,i=t[r>>2]|0,r=t[r+4>>2]|0,s=((A|0)<0)<<31>>31,(r|0)<(s|0)|(r|0)==(s|0)&i>>>0>>0?(r=o,t[r>>2]=A,t[r+4>>2]=s,r=s):A=i,a=YA(A|0,r|0,12,0)|0,f=S()|0,r=o,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 Ue(e,A,r,n,i,s,o){e=e|0,A=A|0,r=r|0,n=n|0,i=i|0,s=s|0,o=o|0;var l=0,a=0,f=0,g=0,M=0,R=0,I=0,N=0,G=0,W=0,nA=0,q=0,$=0,U=0,SA=0,zA=0,QA=0,ce=0,de=0,Se=0,ne=0,HA=0,EA=0,ve=0,Ye=0,me=0,Ke=0,It=0,ls=0;if(Ye=k,k=k+64|0,ne=Ye+48|0,HA=Ye+32|0,EA=Ye+24|0,SA=Ye+8|0,zA=Ye,a=t[e>>2]|0,(a|0)<=0)return ve=0,k=Ye,ve|0;for(QA=e+4|0,ce=ne+8|0,de=HA+8|0,Se=SA+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=yA(ne,HA,n,EA)|0;A:do if(a)f=0,l=a;else if(a=EA,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(Ke=1/(+(f>>>0)+4294967296*+(a|0)),ls=+b[ne>>3],a=ft(f|0,a|0,nA|0,q|0)|0,It=+(a>>>0)+4294967296*+(S()|0),me=+(nA>>>0)+4294967296*+(q|0),b[SA>>3]=Ke*(ls*It)+Ke*(+b[HA>>3]*me),b[Se>>3]=Ke*(+b[ce>>3]*It)+Ke*(+b[de>>3]*me),a=qn(SA,n,zA)|0,a|0){l=a;break}W=zA,G=t[W>>2]|0,W=t[W+4>>2]|0,R=Tr(G|0,W|0,A|0,r|0)|0,g=S()|0,a=o+(R<<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,N=0;;){if((I|0)>(r|0)|(I|0)==(r|0)&N>>>0>A>>>0){l=1;break e}if((f|0)==(G|0)&(M|0)==(W|0))break t;if(a=YA(R|0,g|0,1,0)|0,R=_r(a|0,S()|0,A|0,r|0)|0,g=S()|0,N=YA(N|0,I|0,1,0)|0,I=S()|0,a=o+(R<<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))&&(N=U,t[N>>2]=G,t[N+4>>2]=W,N=s+(t[i>>2]<<3)|0,t[N>>2]=G,t[N+4>>2]=W,N=i,N=YA(t[N>>2]|0,t[N+4>>2]|0,1,0)|0,G=S()|0,W=i,t[W>>2]=N,t[W+4>>2]=G),nA=YA(nA|0,q|0,1,0)|0,q=S()|0,a=EA,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=Ye,l|0):0}function St(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=0,I=0,N=0,G=0,W=0,nA=0,q=0,$=0,U=0,SA=0,zA=0,QA=0,ce=0,de=0,Se=0,ne=0,HA=0,EA=0,ve=0,Ye=0,me=0,Ke=0,It=0;if(It=k,k=k+112|0,ve=It+80|0,a=It+72|0,Ye=It,me=It+56|0,i=nn(r)|0,i|0)return Ke=i,k=It,Ke|0;if(f=e+8|0,Ke=w0((t[f>>2]<<5)+32|0)|0,!Ke)return Ke=13,k=It,Ke|0;if(ni(e,Ke),i=nn(r)|0,!i){if(HA=e,EA=t[HA+4>>2]|0,i=a,t[i>>2]=t[HA>>2],t[i+4>>2]=EA,Ki(a,ve),i=iA(ve,A,Ye)|0,i)HA=0,EA=0;else{if(i=t[a>>2]|0,s=t[f>>2]|0,(s|0)>0){o=t[e+12>>2]|0,r=0;do i=(t[o+(r<<3)>>2]|0)+i|0,r=r+1|0;while((r|0)!=(s|0));r=i}else r=i;i=Ye,s=t[i>>2]|0,i=t[i+4>>2]|0,o=((r|0)<0)<<31>>31,(i|0)<(o|0)|(i|0)==(o|0)&s>>>0>>0?(i=Ye,t[i>>2]=r,t[i+4>>2]=o,i=o):r=s,HA=YA(r|0,i|0,12,0)|0,EA=S()|0,i=Ye,t[i>>2]=HA,t[i+4>>2]=EA,i=0}if(!i){if(r=Gt(HA,8)|0,!r)return qA(Ke),Ke=13,k=It,Ke|0;if(l=Gt(HA,8)|0,!l)return qA(Ke),qA(r),Ke=13,k=It,Ke|0;Se=ve,t[Se>>2]=0,t[Se+4>>2]=0,Se=e,ne=t[Se+4>>2]|0,i=a,t[i>>2]=t[Se>>2],t[i+4>>2]=ne,i=Ue(a,HA,EA,A,ve,r,l)|0;A:do if(i)qA(r),qA(l),qA(Ke);else{e:do if((t[f>>2]|0)>0){for(o=e+12|0,s=0;i=Ue((t[o>>2]|0)+(s<<3)|0,HA,EA,A,ve,r,l)|0,s=s+1|0,!(i|0);)if((s|0)>=(t[f>>2]|0))break e;qA(r),qA(l),qA(Ke);break A}while(!1);(EA|0)>0|(EA|0)==0&HA>>>0>0&&W0(l|0,0,HA<<3|0)|0,ne=ve,Se=t[ne+4>>2]|0;e:do if((Se|0)>0|(Se|0)==0&(t[ne>>2]|0)>>>0>0){QA=r,ce=l,de=r,Se=l,ne=r,i=r,U=r,SA=l,zA=l,r=l;t:for(;;){for(W=0,nA=0,q=0,$=0,s=0,o=0;;){l=Ye,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,P(f,A,1,Ye,0)|0){l=Ye,a=l+56|0;do t[l>>2]=0,l=l+4|0;while((l|0)<(a|0));l=Gt(7,4)|0,l|0&&(J(f,A,1,Ye,l,7,0,0)|0,qA(l))}for(G=0;;){N=Ye+(G<<3)|0,I=t[N>>2]|0,N=t[N+4>>2]|0;r:do if((I|0)==0&(N|0)==0)l=s,a=o;else{if(g=Tr(I|0,N|0,HA|0,EA|0)|0,f=S()|0,l=n+(g<<3)|0,A=l,a=t[A>>2]|0,A=t[A+4>>2]|0,!((a|0)==0&(A|0)==0)){M=0,R=0;do{if((M|0)>(EA|0)|(M|0)==(EA|0)&R>>>0>HA>>>0)break t;if((a|0)==(I|0)&(A|0)==(N|0)){l=s,a=o;break r}l=YA(g|0,f|0,1,0)|0,g=_r(l|0,S()|0,HA|0,EA|0)|0,f=S()|0,R=YA(R|0,M|0,1,0)|0,M=S()|0,l=n+(g<<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&(N|0)==0){l=s,a=o;break}or(I,N,me)|0,ii(e,Ke,me)|0&&(R=YA(s|0,o|0,1,0)|0,o=S()|0,M=l,t[M>>2]=I,t[M+4>>2]=N,s=ce+(s<<3)|0,t[s>>2]=I,t[s+4>>2]=N,s=R),l=s,a=o}while(!1);if(G=G+1|0,G>>>0>=7)break;s=l,o=a}if(W=YA(W|0,nA|0,1,0)|0,nA=S()|0,q=YA(q|0,$|0,1,0)|0,$=S()|0,o=ve,s=t[o>>2]|0,o=t[o+4>>2]|0,($|0)<(o|0)|($|0)==(o|0)&q>>>0>>0)s=l,o=a;else break}if((o|0)>0|(o|0)==0&s>>>0>0){s=0,o=0;do $=QA+(s<<3)|0,t[$>>2]=0,t[$+4>>2]=0,s=YA(s|0,o|0,1,0)|0,o=S()|0,$=ve,q=t[$+4>>2]|0;while((o|0)<(q|0)|((o|0)==(q|0)?s>>>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=SA,$=ce,r=U,zA=i,SA=de,U=G,i=W,ne=Se,Se=nA,de=q,ce=QA,QA=$;else break e}qA(de),qA(Se),qA(Ke),i=1;break A}else i=l;while(!1);qA(Ke),qA(r),qA(i),i=0}while(!1);return Ke=i,k=It,Ke|0}}return qA(Ke),Ke=i,k=It,Ke|0}function Mt(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0,o=0,l=0,a=0,f=0,g=0;if(g=k,k=k+176|0,a=g,(A|0)<1)return As(r,0,0),f=0,k=g,f|0;for(l=e,l=wA(t[l>>2]|0,t[l+4>>2]|0,52)|0,S()|0,As(r,(A|0)>6?A:6,l&15),l=0;n=e+(l<<3)|0,n=Br(t[n>>2]|0,t[n+4>>2]|0,a)|0,!(n|0);){if(n=t[a>>2]|0,(n|0)>0){o=0;do s=a+8+(o<<4)|0,o=o+1|0,n=a+8+(((o|0)%(n|0)|0)<<4)|0,i=Aa(r,n,s)|0,i?rs(r,i)|0:Xl(r,s,n)|0,n=t[a>>2]|0;while((o|0)<(n|0))}if(l=l+1|0,(l|0)>=(A|0)){n=0,f=13;break}}return(f|0)==13?(k=g,n|0):(es(r),f=n,k=g,f|0)}function xt(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0,o=0;if(s=k,k=k+32|0,n=s,i=s+16|0,e=Mt(e,A,i)|0,e|0)return r=e,k=s,r|0;if(t[r>>2]=0,t[r+4>>2]=0,t[r+8>>2]=0,e=ts(i)|0,e|0)do{A=Dl(r)|0;do _l(A,e)|0,o=e+16|0,t[n>>2]=t[o>>2],t[n+4>>2]=t[o+4>>2],t[n+8>>2]=t[o+8>>2],t[n+12>>2]=t[o+12>>2],rs(i,e)|0,e=ea(i,n)|0;while((e|0)!=0);e=ts(i)|0}while((e|0)!=0);return es(i),e=Tl(r)|0,e?(Ui(r),o=e,k=s,o|0):(o=0,k=s,o|0)}function je(e){return e=e|0,e>>>0>121?(e=0,e|0):(e=t[7696+(e*28|0)+16>>2]|0,e|0)}function Bt(e){return e=e|0,(e|0)==4|(e|0)==117|0}function g0(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 u0(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 z0(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 e0(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 _0(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 tr(e,A){return e=e|0,A=A|0,t[848+(e*28|0)+(A<<2)>>2]|0}function rr(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 Ur(){return 122}function Vr(e){e=e|0;var A=0,r=0,n=0;A=0;do kA(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 Wr(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 nr(e){return e=e|0,+(+b[e>>3]-+b[e+8>>3])}function p0(e,A){e=e|0,A=A|0;var r=0,n=0,i=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],i=+b[A+8>>3],A=i>=r,e=i<=n&1,n>3]<+b[A+8>>3]||+b[e+8>>3]>+b[A>>3]?(n=0,n|0):(s=+b[e+16>>3],r=e+24|0,g=+b[r>>3],o=s>3],i=A+24|0,a=+b[i>>3],l=f>3],A)||(g=+Kt(+b[r>>3],e),g>+Kt(+b[n>>3],A))?(l=0,l|0):(l=1,l|0))}function y0(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0,o=0,l=0,a=0;s=+b[e+16>>3],a=+b[e+24>>3],e=s>3],o=+b[A+24>>3],i=l>2]=e?i|A?1:2:0,t[n>>2]=i?e?1:A?2:1:0}function T0(e,A){e=e|0,A=A|0;var r=0,n=0,i=0,s=0,o=0,l=0,a=0,f=0,g=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],s=+b[e+24>>3],o=a>3],i=A+24|0,f=+b[i>>3],l=g>3],A)?(g=+Kt(+b[n>>3],e),l=g>=+Kt(+b[r>>3],A),l|0):(l=0,l|0))}function H(e,A){e=e|0,A=A|0;var r=0,n=0,i=0,s=0,o=0,l=0;i=k,k=k+176|0,n=i,t[n>>2]=4,l=+b[A>>3],b[n+8>>3]=l,s=+b[A+16>>3],b[n+16>>3]=s,b[n+24>>3]=l,l=+b[A+24>>3],b[n+32>>3]=l,o=+b[A+8>>3],b[n+40>>3]=o,b[n+48>>3]=l,b[n+56>>3]=o,b[n+64>>3]=s,A=n+72|0,r=A+96|0;do t[A>>2]=0,A=A+4|0;while((A|0)<(r|0));jr(e|0,n|0,168)|0,k=i}function iA(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=0,I=0,N=0,G=0,W=0;N=k,k=k+288|0,g=N+264|0,M=N+96|0,f=N,l=f,a=l+96|0;do t[l>>2]=0,l=l+4|0;while((l|0)<(a|0));return A=Xn(A,f)|0,A|0?(I=A,k=N,I|0):(a=f,f=t[a>>2]|0,a=t[a+4>>2]|0,or(f,a,g)|0,Br(f,a,M)|0,o=+tn(g,M+8|0),b[g>>3]=+b[e>>3],a=g+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],i=+tn(g,M),W=+b[a>>3]-+b[f>>3],s=+ZA(+W),G=+b[g>>3]-+b[M>>3],n=+ZA(+G),!(W==0|G==0)&&(W=+ss(+s,+n),W=+at(+(i*i/+bn(+(W/+bn(+s,+n)),3)/(o*(o*2.59807621135)*.8))),b[pe>>3]=W,R=~~W>>>0,I=+ZA(W)>=1?W>0?~~+et(+Ve(W/4294967296),4294967295)>>>0:~~+at((W-+(~~W>>>0))/4294967296)>>>0:0,(t[pe+4>>2]&2146435072|0)!=2146435072)?(M=(R|0)==0&(I|0)==0,A=r,t[A>>2]=M?1:R,t[A+4>>2]=M?0:I,A=0):A=1,I=A,k=N,I|0)}function yA(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0,o=0,l=0,a=0,f=0,g=0;f=k,k=k+288|0,o=f+264|0,l=f+96|0,a=f,i=a,s=i+96|0;do t[i>>2]=0,i=i+4|0;while((i|0)<(s|0));return r=Xn(r,a)|0,r|0?(n=r,k=f,n|0):(r=a,i=t[r>>2]|0,r=t[r+4>>2]|0,or(i,r,o)|0,Br(i,r,l)|0,g=+tn(o,l+8|0),g=+at(+(+tn(e,A)/(g*2))),b[pe>>3]=g,r=~~g>>>0,i=+ZA(g)>=1?g>0?~~+et(+Ve(g/4294967296),4294967295)>>>0:~~+at((g-+(~~g>>>0))/4294967296)>>>0:0,(t[pe+4>>2]&2146435072|0)==2146435072?(n=1,k=f,n|0):(a=(r|0)==0&(i|0)==0,t[n>>2]=a?1:r,t[n+4>>2]=a?0:i,n=0,k=f,n|0))}function LA(e,A){e=e|0,A=+A;var r=0,n=0,i=0,s=0,o=0,l=0,a=0,f=0,g=0;s=e+16|0,o=+b[s>>3],r=e+24|0,i=+b[r>>3],n=o-i,n=o>3],l=e+8|0,a=+b[l>>3],g=f-a,n=(n*A-n)*.5,A=(g*A-g)*.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=o+n,A=A>3.141592653589793?A+-6.283185307179586:A,b[s>>3]=A<-3.141592653589793?A+6.283185307179586:A,A=i-n,A=A>3.141592653589793?A+-6.283185307179586:A,b[r>>3]=A<-3.141592653589793?A+6.283185307179586:A}function WA(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 he(e,A){e=e|0,A=A|0;var r=0,n=0,i=0,s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=0;M=A+8|0,t[M>>2]=0,a=+b[e>>3],o=+ZA(+a),f=+b[e+8>>3],l=+ZA(+f)*1.1547005383792515,o=o+l*.5,r=~~o,e=~~l,o=o-+(r|0),l=l-+(e|0);do if(o<.5)if(o<.3333333333333333)if(t[A>>2]=r,l<(o+1)*.5){t[A+4>>2]=e;break}else{e=e+1|0,t[A+4>>2]=e;break}else if(R=1-o,e=(!(l>2]=e,R<=l&l>2]=r;break}else{t[A>>2]=r;break}else{if(!(o<.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-o){if(t[A+4>>2]=e,o*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){g=(e+1|0)/2|0,g=ft(r|0,((r|0)<0)<<31>>31|0,g|0,((g|0)<0)<<31>>31|0)|0,r=~~(+(r|0)-((+(g>>>0)+4294967296*+(S()|0))*2+1)),t[A>>2]=r;break}else{g=(e|0)/2|0,g=ft(r|0,((r|0)<0)<<31>>31|0,g|0,((g|0)<0)<<31>>31|0)|0,r=~~(+(r|0)-(+(g>>>0)+4294967296*+(S()|0))*2),t[A>>2]=r;break}while(!1);g=A+4|0,f<0&&(r=r-((e<<1|1|0)/2|0)|0,t[A>>2]=r,e=0-e|0,t[g>>2]=e),n=e-r|0,(r|0)<0?(i=0-r|0,t[g>>2]=n,t[M>>2]=i,t[A>>2]=0,e=n,r=0):i=0,(e|0)<0&&(r=r-e|0,t[A>>2]=r,i=i-e|0,t[M>>2]=i,t[g>>2]=0,e=0),s=r-i|0,n=e-i|0,(i|0)<0&&(t[A>>2]=s,t[g>>2]=n,t[M>>2]=0,e=n,r=s,i=0),n=(e|0)<(r|0)?e:r,n=(i|0)<(n|0)?i:n,!((n|0)<=0)&&(t[A>>2]=r-n,t[g>>2]=e-n,t[M>>2]=i-n)}function oe(e){e=e|0;var A=0,r=0,n=0,i=0,s=0,o=0;A=t[e>>2]|0,o=e+4|0,r=t[o>>2]|0,(A|0)<0&&(r=r-A|0,t[o>>2]=r,s=e+8|0,t[s>>2]=(t[s>>2]|0)-A,t[e>>2]=0,A=0),(r|0)<0?(A=A-r|0,t[e>>2]=A,s=e+8|0,i=(t[s>>2]|0)-r|0,t[s>>2]=i,t[o>>2]=0,r=0):(i=e+8|0,s=i,i=t[i>>2]|0),(i|0)<0&&(A=A-i|0,t[e>>2]=A,r=r-i|0,t[o>>2]=r,t[s>>2]=0,i=0),n=(r|0)<(A|0)?r:A,n=(i|0)<(n|0)?i:n,!((n|0)<=0)&&(t[e>>2]=A-n,t[o>>2]=r-n,t[s>>2]=i-n)}function Oe(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 wt(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 ct(e,A){e=e|0,A=A|0;var r=0,n=0;r=Ne(t[e>>2]|0,A)|0,t[e>>2]=r,r=e+4|0,n=Ne(t[r>>2]|0,A)|0,t[r>>2]=n,e=e+8|0,A=Ne(t[e>>2]|0,A)|0,t[e>>2]=A}function tt(e){e=e|0;var A=0,r=0,n=0,i=0,s=0,o=0,l=0;o=t[e>>2]|0,l=(o|0)<0,n=(t[e+4>>2]|0)-(l?o:0)|0,s=(n|0)<0,i=(s?0-n|0:0)+((t[e+8>>2]|0)-(l?o:0))|0,r=(i|0)<0,e=r?0:i,A=(s?0:n)-(r?i:0)|0,i=(l?0:o)-(s?n:0)-(r?i:0)|0,r=(A|0)<(i|0)?A:i,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(i-(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 Dt(e){e=e|0;var A=0,r=0,n=0,i=0,s=0,o=0,l=0,a=0,f=0;if(a=e+8|0,o=t[a>>2]|0,l=(t[e>>2]|0)-o|0,f=e+4|0,o=(t[f>>2]|0)-o|0,l>>>0>715827881|o>>>0>715827881){if(n=(l|0)>0,i=2147483647-l|0,s=-2147483648-l|0,(n?(i|0)<(l|0):(s|0)>(l|0))||(r=l<<1,n?(2147483647-r|0)<(l|0):(-2147483648-r|0)>(l|0))||((o|0)>0?(2147483647-o|0)<(o|0):(-2147483648-o|0)>(o|0))||(A=l*3|0,r=o<<1,(n?(i|0)<(r|0):(s|0)>(r|0))||((l|0)>-1?(A|-2147483648|0)>=(o|0):(A^-2147483648|0)<(o|0))))return f=1,f|0}else r=o<<1,A=l*3|0;return n=U0(+(A-o|0)*.14285714285714285)|0,t[e>>2]=n,i=U0(+(r+l|0)*.14285714285714285)|0,t[f>>2]=i,t[a>>2]=0,r=(i|0)<(n|0),A=r?n:i,r=r?i: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=i-n|0,(n|0)<0?(r=0-n|0,t[f>>2]=A,t[a>>2]=r,t[e>>2]=0,n=0):(A=i,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),s=n-r|0,i=A-r|0,(r|0)<0?(t[e>>2]=s,t[f>>2]=i,t[a>>2]=0,A=i,i=s,r=0):i=n,n=(A|0)<(i|0)?A:i,n=(r|0)<(n|0)?r:n,(n|0)<=0?(f=0,f|0):(t[e>>2]=i-n,t[f>>2]=A-n,t[a>>2]=r-n,f=0,f|0)}function hn(e){e=e|0;var A=0,r=0,n=0,i=0,s=0,o=0,l=0,a=0;if(o=e+8|0,i=t[o>>2]|0,s=(t[e>>2]|0)-i|0,l=e+4|0,i=(t[l>>2]|0)-i|0,s>>>0>715827881|i>>>0>715827881){if(r=(s|0)>0,(r?(2147483647-s|0)<(s|0):(-2147483648-s|0)>(s|0))||(A=s<<1,n=(i|0)>0,n?(2147483647-i|0)<(i|0):(-2147483648-i|0)>(i|0)))return l=1,l|0;if(a=i<<1,(n?(2147483647-a|0)<(i|0):(-2147483648-a|0)>(i|0))||(r?(2147483647-A|0)<(i|0):(-2147483648-A|0)>(i|0))||(r=i*3|0,(i|0)>-1?(r|-2147483648|0)>=(s|0):(r^-2147483648|0)<(s|0)))return a=1,a|0}else r=i*3|0,A=s<<1;return n=U0(+(A+i|0)*.14285714285714285)|0,t[e>>2]=n,i=U0(+(r-s|0)*.14285714285714285)|0,t[l>>2]=i,t[o>>2]=0,r=(i|0)<(n|0),A=r?n:i,r=r?i: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=i-n|0,(n|0)<0?(r=0-n|0,t[l>>2]=A,t[o>>2]=r,t[e>>2]=0,n=0):(A=i,r=0),(A|0)<0&&(n=n-A|0,t[e>>2]=n,r=r-A|0,t[o>>2]=r,t[l>>2]=0,A=0),s=n-r|0,i=A-r|0,(r|0)<0?(t[e>>2]=s,t[l>>2]=i,t[o>>2]=0,A=i,i=s,r=0):i=n,n=(A|0)<(i|0)?A:i,n=(r|0)<(n|0)?r:n,(n|0)<=0?(a=0,a|0):(t[e>>2]=i-n,t[l>>2]=A-n,t[o>>2]=r-n,a=0,a|0)}function xr(e){e=e|0;var A=0,r=0,n=0,i=0,s=0,o=0,l=0;o=e+8|0,r=t[o>>2]|0,A=(t[e>>2]|0)-r|0,l=e+4|0,r=(t[l>>2]|0)-r|0,n=U0(+((A*3|0)-r|0)*.14285714285714285)|0,t[e>>2]=n,A=U0(+((r<<1)+A|0)*.14285714285714285)|0,t[l>>2]=A,t[o>>2]=0,r=A-n|0,(n|0)<0?(s=0-n|0,t[l>>2]=r,t[o>>2]=s,t[e>>2]=0,A=r,n=0,r=s):r=0,(A|0)<0&&(n=n-A|0,t[e>>2]=n,r=r-A|0,t[o>>2]=r,t[l>>2]=0,A=0),s=n-r|0,i=A-r|0,(r|0)<0?(t[e>>2]=s,t[l>>2]=i,t[o>>2]=0,A=i,i=s,r=0):i=n,n=(A|0)<(i|0)?A:i,n=(r|0)<(n|0)?r:n,!((n|0)<=0)&&(t[e>>2]=i-n,t[l>>2]=A-n,t[o>>2]=r-n)}function wr(e){e=e|0;var A=0,r=0,n=0,i=0,s=0,o=0,l=0;o=e+8|0,r=t[o>>2]|0,A=(t[e>>2]|0)-r|0,l=e+4|0,r=(t[l>>2]|0)-r|0,n=U0(+((A<<1)+r|0)*.14285714285714285)|0,t[e>>2]=n,A=U0(+((r*3|0)-A|0)*.14285714285714285)|0,t[l>>2]=A,t[o>>2]=0,r=A-n|0,(n|0)<0?(s=0-n|0,t[l>>2]=r,t[o>>2]=s,t[e>>2]=0,A=r,n=0,r=s):r=0,(A|0)<0&&(n=n-A|0,t[e>>2]=n,r=r-A|0,t[o>>2]=r,t[l>>2]=0,A=0),s=n-r|0,i=A-r|0,(r|0)<0?(t[e>>2]=s,t[l>>2]=i,t[o>>2]=0,A=i,i=s,r=0):i=n,n=(A|0)<(i|0)?A:i,n=(r|0)<(n|0)?r:n,!((n|0)<=0)&&(t[e>>2]=i-n,t[l>>2]=A-n,t[o>>2]=r-n)}function vr(e){e=e|0;var A=0,r=0,n=0,i=0,s=0,o=0,l=0;A=t[e>>2]|0,o=e+4|0,r=t[o>>2]|0,l=e+8|0,n=t[l>>2]|0,i=r+(A*3|0)|0,t[e>>2]=i,r=n+(r*3|0)|0,t[o>>2]=r,A=(n*3|0)+A|0,t[l>>2]=A,n=r-i|0,(i|0)<0?(A=A-i|0,t[o>>2]=n,t[l>>2]=A,t[e>>2]=0,r=n,n=0):n=i,(r|0)<0&&(n=n-r|0,t[e>>2]=n,A=A-r|0,t[l>>2]=A,t[o>>2]=0,r=0),s=n-A|0,i=r-A|0,(A|0)<0?(t[e>>2]=s,t[o>>2]=i,t[l>>2]=0,n=s,A=0):i=r,r=(i|0)<(n|0)?i:n,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=n-r,t[o>>2]=i-r,t[l>>2]=A-r)}function Vt(e){e=e|0;var A=0,r=0,n=0,i=0,s=0,o=0,l=0;i=t[e>>2]|0,o=e+4|0,A=t[o>>2]|0,l=e+8|0,r=t[l>>2]|0,n=(A*3|0)+i|0,i=r+(i*3|0)|0,t[e>>2]=i,t[o>>2]=n,A=(r*3|0)+A|0,t[l>>2]=A,r=n-i|0,(i|0)<0?(A=A-i|0,t[o>>2]=r,t[l>>2]=A,t[e>>2]=0,i=0):r=n,(r|0)<0&&(i=i-r|0,t[e>>2]=i,A=A-r|0,t[l>>2]=A,t[o>>2]=0,r=0),s=i-A|0,n=r-A|0,(A|0)<0?(t[e>>2]=s,t[o>>2]=n,t[l>>2]=0,i=s,A=0):n=r,r=(n|0)<(i|0)?n:i,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=i-r,t[o>>2]=n-r,t[l>>2]=A-r)}function dn(e,A){e=e|0,A=A|0;var r=0,n=0,i=0,s=0,o=0,l=0;(A+-1|0)>>>0>=6||(i=(t[15440+(A*12|0)>>2]|0)+(t[e>>2]|0)|0,t[e>>2]=i,l=e+4|0,n=(t[15440+(A*12|0)+4>>2]|0)+(t[l>>2]|0)|0,t[l>>2]=n,o=e+8|0,A=(t[15440+(A*12|0)+8>>2]|0)+(t[o>>2]|0)|0,t[o>>2]=A,r=n-i|0,(i|0)<0?(A=A-i|0,t[l>>2]=r,t[o>>2]=A,t[e>>2]=0,n=0):(r=n,n=i),(r|0)<0&&(n=n-r|0,t[e>>2]=n,A=A-r|0,t[o>>2]=A,t[l>>2]=0,r=0),s=n-A|0,i=r-A|0,(A|0)<0?(t[e>>2]=s,t[l>>2]=i,t[o>>2]=0,n=s,A=0):i=r,r=(i|0)<(n|0)?i:n,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=n-r,t[l>>2]=i-r,t[o>>2]=A-r))}function br(e){e=e|0;var A=0,r=0,n=0,i=0,s=0,o=0,l=0;i=t[e>>2]|0,o=e+4|0,A=t[o>>2]|0,l=e+8|0,r=t[l>>2]|0,n=A+i|0,i=r+i|0,t[e>>2]=i,t[o>>2]=n,A=r+A|0,t[l>>2]=A,r=n-i|0,(i|0)<0?(A=A-i|0,t[o>>2]=r,t[l>>2]=A,t[e>>2]=0,n=0):(r=n,n=i),(r|0)<0&&(n=n-r|0,t[e>>2]=n,A=A-r|0,t[l>>2]=A,t[o>>2]=0,r=0),s=n-A|0,i=r-A|0,(A|0)<0?(t[e>>2]=s,t[o>>2]=i,t[l>>2]=0,n=s,A=0):i=r,r=(i|0)<(n|0)?i:n,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=n-r,t[o>>2]=i-r,t[l>>2]=A-r)}function j0(e){e=e|0;var A=0,r=0,n=0,i=0,s=0,o=0,l=0;A=t[e>>2]|0,o=e+4|0,n=t[o>>2]|0,l=e+8|0,r=t[l>>2]|0,i=n+A|0,t[e>>2]=i,n=r+n|0,t[o>>2]=n,A=r+A|0,t[l>>2]=A,r=n-i|0,(i|0)<0?(A=A-i|0,t[o>>2]=r,t[l>>2]=A,t[e>>2]=0,n=0):(r=n,n=i),(r|0)<0&&(n=n-r|0,t[e>>2]=n,A=A-r|0,t[l>>2]=A,t[o>>2]=0,r=0),s=n-A|0,i=r-A|0,(A|0)<0?(t[e>>2]=s,t[o>>2]=i,t[l>>2]=0,n=s,A=0):i=r,r=(i|0)<(n|0)?i:n,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=n-r,t[o>>2]=i-r,t[l>>2]=A-r)}function Wt(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 Yt(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 Yr(e){e=e|0;var A=0,r=0,n=0,i=0,s=0,o=0,l=0;A=t[e>>2]|0,o=e+4|0,r=t[o>>2]|0,l=e+8|0,n=t[l>>2]|0,i=r+(A<<1)|0,t[e>>2]=i,r=n+(r<<1)|0,t[o>>2]=r,A=(n<<1)+A|0,t[l>>2]=A,n=r-i|0,(i|0)<0?(A=A-i|0,t[o>>2]=n,t[l>>2]=A,t[e>>2]=0,r=n,n=0):n=i,(r|0)<0&&(n=n-r|0,t[e>>2]=n,A=A-r|0,t[l>>2]=A,t[o>>2]=0,r=0),s=n-A|0,i=r-A|0,(A|0)<0?(t[e>>2]=s,t[o>>2]=i,t[l>>2]=0,n=s,A=0):i=r,r=(i|0)<(n|0)?i:n,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=n-r,t[o>>2]=i-r,t[l>>2]=A-r)}function Kr(e){e=e|0;var A=0,r=0,n=0,i=0,s=0,o=0,l=0;i=t[e>>2]|0,o=e+4|0,A=t[o>>2]|0,l=e+8|0,r=t[l>>2]|0,n=(A<<1)+i|0,i=r+(i<<1)|0,t[e>>2]=i,t[o>>2]=n,A=(r<<1)+A|0,t[l>>2]=A,r=n-i|0,(i|0)<0?(A=A-i|0,t[o>>2]=r,t[l>>2]=A,t[e>>2]=0,i=0):r=n,(r|0)<0&&(i=i-r|0,t[e>>2]=i,A=A-r|0,t[l>>2]=A,t[o>>2]=0,r=0),s=i-A|0,n=r-A|0,(A|0)<0?(t[e>>2]=s,t[o>>2]=n,t[l>>2]=0,i=s,A=0):n=r,r=(n|0)<(i|0)?n:i,r=(A|0)<(r|0)?A:r,!((r|0)<=0)&&(t[e>>2]=i-r,t[o>>2]=n-r,t[l>>2]=A-r)}function kr(e,A){e=e|0,A=A|0;var r=0,n=0,i=0,s=0,o=0,l=0;return o=(t[e>>2]|0)-(t[A>>2]|0)|0,l=(o|0)<0,n=(t[e+4>>2]|0)-(t[A+4>>2]|0)-(l?o:0)|0,s=(n|0)<0,i=(l?0-o|0:0)+(t[e+8>>2]|0)-(t[A+8>>2]|0)+(s?0-n|0:0)|0,e=(i|0)<0,A=e?0:i,r=(s?0:n)-(e?i:0)|0,i=(l?0:o)-(s?n:0)-(e?i:0)|0,e=(r|0)<(i|0)?r:i,e=(A|0)<(e|0)?A:e,n=(e|0)>0,A=A-(n?e:0)|0,r=r-(n?e:0)|0,e=i-(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 Zr(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 _t(e,A){e=e|0,A=A|0;var r=0,n=0,i=0,s=0,o=0,l=0;return n=t[e>>2]|0,t[A>>2]=n,i=t[e+4>>2]|0,o=A+4|0,t[o>>2]=i,l=A+8|0,t[l>>2]=0,r=(i|0)<(n|0),e=r?n:i,r=r?i: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=i-n|0,(n|0)<0?(r=0-n|0,t[o>>2]=e,t[l>>2]=r,t[A>>2]=0,n=0):(e=i,r=0),(e|0)<0&&(n=n-e|0,t[A>>2]=n,r=r-e|0,t[l>>2]=r,t[o>>2]=0,e=0),s=n-r|0,i=e-r|0,(r|0)<0?(t[A>>2]=s,t[o>>2]=i,t[l>>2]=0,e=i,i=s,r=0):i=n,n=(e|0)<(i|0)?e:i,n=(r|0)<(n|0)?r:n,(n|0)<=0?(A=0,A|0):(t[A>>2]=i-n,t[o>>2]=e-n,t[l>>2]=r-n,A=0,A|0))}function $r(e){e=e|0;var A=0,r=0,n=0,i=0;A=e+8|0,i=t[A>>2]|0,r=i-(t[e>>2]|0)|0,t[e>>2]=r,n=e+4|0,e=(t[n>>2]|0)-i|0,t[n>>2]=e,t[A>>2]=0-(e+r)}function qr(e){e=e|0;var A=0,r=0,n=0,i=0,s=0,o=0,l=0;r=t[e>>2]|0,A=0-r|0,t[e>>2]=A,o=e+8|0,t[o>>2]=0,l=e+4|0,n=t[l>>2]|0,i=n+r|0,(r|0)>0?(t[l>>2]=i,t[o>>2]=r,t[e>>2]=0,A=0,n=i):r=0,(n|0)<0?(s=A-n|0,t[e>>2]=s,r=r-n|0,t[o>>2]=r,t[l>>2]=0,i=s-r|0,A=0-r|0,(r|0)<0?(t[e>>2]=i,t[l>>2]=A,t[o>>2]=0,n=A,r=0):(n=0,i=s)):i=A,A=(n|0)<(i|0)?n:i,A=(r|0)<(A|0)?r:A,!((A|0)<=0)&&(t[e>>2]=i-A,t[l>>2]=n-A,t[o>>2]=r-A)}function Kn(e,A,r,n,i){e=e|0,A=A|0,r=r|0,n=n|0,i=i|0;var s=0,o=0,l=0,a=0,f=0,g=0,M=0;if(M=k,k=k+64|0,g=M,l=M+56|0,!(!0&(A&2013265920|0)==134217728&(!0&(n&2013265920|0)==134217728)))return i=5,k=M,i|0;if((e|0)==(r|0)&(A|0)==(n|0))return t[i>>2]=0,i=0,k=M,i|0;if(o=wA(e|0,A|0,52)|0,S()|0,o=o&15,f=wA(r|0,n|0,52)|0,S()|0,(o|0)!=(f&15|0))return i=12,k=M,i|0;if(s=o+-1|0,o>>>0>1){Rt(e,A,s,g)|0,Rt(r,n,s,l)|0,f=g,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)){o=(o^15)*3|0,s=wA(e|0,A|0,o|0)|0,S()|0,s=s&7,o=wA(r|0,n|0,o|0)|0,S()|0,o=o&7;do if((s|0)==0|(o|0)==0)t[i>>2]=1,s=0;else if((s|0)==7)s=5;else{if((s|0)==1|(o|0)==1&&He(a,f)|0){s=5;break}if((t[15536+(s<<2)>>2]|0)!=(o|0)&&(t[15568+(s<<2)>>2]|0)!=(o|0))break A;t[i>>2]=1,s=0}while(!1);return i=s,k=M,i|0}while(!1)}s=g,o=s+56|0;do t[s>>2]=0,s=s+4|0;while((s|0)<(o|0));return v(e,A,1,g)|0,A=g,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0))&&(A=g+8|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))&&(A=g+16|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))&&(A=g+24|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))&&(A=g+32|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))&&(A=g+40|0,!((t[A>>2]|0)==(r|0)&&(t[A+4>>2]|0)==(n|0)))?(s=g+48|0,s=((t[s>>2]|0)==(r|0)?(t[s+4>>2]|0)==(n|0):0)&1):s=1,t[i>>2]=s,i=0,k=M,i|0}function mn(e,A,r,n,i){return e=e|0,A=A|0,r=r|0,n=n|0,i=i|0,r=Ae(e,A,r,n)|0,(r|0)==7?(i=11,i|0):(n=kA(r|0,0,56)|0,A=A&-2130706433|(S()|0)|268435456,t[i>>2]=e|n,t[i+4>>2]=A,i=0,i|0)}function Cr(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 gn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0;return i=k,k=k+16|0,n=i,t[n>>2]=0,!0&(A&2013265920|0)==268435456?(s=wA(e|0,A|0,56)|0,S()|0,n=K(e,A&-2130706433|134217728,s&7,n,r)|0,k=i,n|0):(n=6,k=i,n|0)}function Jr(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&(He(e,r)|0)!=0?(r=0,r|0):(r=We(e,r)|0,r|0)}function Er(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0,o=0;return i=k,k=k+16|0,n=i,!0&(A&2013265920|0)==268435456?(s=A&-2130706433|134217728,o=r,t[o>>2]=e,t[o+4>>2]=s,t[n>>2]=0,A=wA(e|0,A|0,56)|0,S()|0,n=K(e,s,A&7,n,r+8|0)|0,k=i,n|0):(n=6,k=i,n|0)}function Sr(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0;return i=(He(e,A)|0)==0,A=A&-2130706433,n=r,t[n>>2]=i?e:0,t[n+4>>2]=i?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 ir(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0,o=0;return o=k,k=k+16|0,i=o,s=A&-2130706433|134217728,!0&(A&2013265920|0)==268435456?(n=wA(e|0,A|0,56)|0,S()|0,n=$l(e,s,n&7)|0,(n|0)==-1?(t[r>>2]=0,s=6,k=o,s|0):(Mr(e,s,i)|0&&OA(27795,26932,282,26947),A=wA(e|0,A|0,52)|0,S()|0,A=A&15,He(e,s)|0?w(i,A,n,2,r):X(i,A,n,2,r),s=0,k=o,s|0)):(s=6,k=o,s|0)}function pn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0;n=k,k=k+16|0,i=n,yn(e,A,r,i),he(i,r+4|0),k=n}function yn(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0,o=0,l=0,a=0;if(l=k,k=k+16|0,a=l,Xr(e,r,a),s=+Qt(+(1-+b[a>>3]*.5)),s<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,i=+b[15920+(a*24|0)>>3],i=+en(i-+en(+xl(15600+(a<<4)|0,e))),t0(A)|0?o=+en(i+-.3334731722518321):o=i,i=+rt(+s)*2.618033988749896,(A|0)>0){e=0;do i=i*2.6457513110645907,e=e+1|0;while((e|0)!=(A|0))}s=+_e(+o)*i,b[n>>3]=s,o=+se(+o)*i,b[n+8>>3]=o,k=l}function Xr(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0;if(s=k,k=k+32|0,i=s,Zl(e,i),t[A>>2]=0,b[r>>3]=5,n=+st(16400,i),n<+b[r>>3]&&(t[A>>2]=0,b[r>>3]=n),n=+st(16424,i),n<+b[r>>3]&&(t[A>>2]=1,b[r>>3]=n),n=+st(16448,i),n<+b[r>>3]&&(t[A>>2]=2,b[r>>3]=n),n=+st(16472,i),n<+b[r>>3]&&(t[A>>2]=3,b[r>>3]=n),n=+st(16496,i),n<+b[r>>3]&&(t[A>>2]=4,b[r>>3]=n),n=+st(16520,i),n<+b[r>>3]&&(t[A>>2]=5,b[r>>3]=n),n=+st(16544,i),n<+b[r>>3]&&(t[A>>2]=6,b[r>>3]=n),n=+st(16568,i),n<+b[r>>3]&&(t[A>>2]=7,b[r>>3]=n),n=+st(16592,i),n<+b[r>>3]&&(t[A>>2]=8,b[r>>3]=n),n=+st(16616,i),n<+b[r>>3]&&(t[A>>2]=9,b[r>>3]=n),n=+st(16640,i),n<+b[r>>3]&&(t[A>>2]=10,b[r>>3]=n),n=+st(16664,i),n<+b[r>>3]&&(t[A>>2]=11,b[r>>3]=n),n=+st(16688,i),n<+b[r>>3]&&(t[A>>2]=12,b[r>>3]=n),n=+st(16712,i),n<+b[r>>3]&&(t[A>>2]=13,b[r>>3]=n),n=+st(16736,i),n<+b[r>>3]&&(t[A>>2]=14,b[r>>3]=n),n=+st(16760,i),n<+b[r>>3]&&(t[A>>2]=15,b[r>>3]=n),n=+st(16784,i),n<+b[r>>3]&&(t[A>>2]=16,b[r>>3]=n),n=+st(16808,i),n<+b[r>>3]&&(t[A>>2]=17,b[r>>3]=n),n=+st(16832,i),n<+b[r>>3]&&(t[A>>2]=18,b[r>>3]=n),n=+st(16856,i),!(n<+b[r>>3])){k=s;return}t[A>>2]=19,b[r>>3]=n,k=s}function H0(e,A,r,n,i){e=e|0,A=A|0,r=r|0,n=n|0,i=i|0;var s=0,o=0,l=0;if(s=+Kl(e),s<1e-16){A=15600+(A<<4)|0,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];return}if(o=+Te(+ +b[e+8>>3],+ +b[e>>3]),(r|0)>0){e=0;do s=s*.37796447300922725,e=e+1|0;while((e|0)!=(r|0))}l=s*.3333333333333333,n?(r=(t0(r)|0)==0,s=+pt(+((r?l:l*.37796447300922725)*.381966011250105))):(s=+pt(+(s*.381966011250105)),t0(r)|0&&(o=+en(o+.3334731722518321))),wl(15600+(A<<4)|0,+en(+b[15920+(A*24|0)>>3]-o),s,i)}function d(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0;n=k,k=k+16|0,i=n,Oe(e+4|0,i),H0(i,t[e>>2]|0,A,0,r),k=n}function w(e,A,r,n,i){e=e|0,A=A|0,r=r|0,n=n|0,i=i|0;var s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=0,I=0,N=0,G=0,W=0,nA=0,q=0,$=0,U=0,SA=0,zA=0,QA=0,ce=0,de=0,Se=0,ne=0,HA=0,EA=0,ve=0,Ye=0,me=0;if(ve=k,k=k+272|0,s=ve+256|0,q=ve+240|0,ne=ve,HA=ve+224|0,EA=ve+208|0,$=ve+176|0,U=ve+160|0,SA=ve+192|0,zA=ve+144|0,QA=ve+128|0,ce=ve+112|0,de=ve+96|0,Se=ve+80|0,t[s>>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,s,ne),t[i>>2]=0,q=n+r+((n|0)==5&1)|0,(q|0)<=(r|0)){k=ve;return}a=t[s>>2]|0,f=HA+4|0,g=$+4|0,M=r+5|0,R=16880+(a<<2)|0,I=16960+(a<<2)|0,N=QA+8|0,G=ce+8|0,W=de+8|0,nA=EA+4|0,l=r;A:for(;;){o=ne+(((l|0)%5|0)<<4)|0,t[EA>>2]=t[o>>2],t[EA+4>>2]=t[o+4>>2],t[EA+8>>2]=t[o+8>>2],t[EA+12>>2]=t[o+12>>2];do;while((F(EA,a,0,1)|0)==2);if((l|0)>(r|0)&(t0(A)|0)!=0){if(t[$>>2]=t[EA>>2],t[$+4>>2]=t[EA+4>>2],t[$+8>>2]=t[EA+8>>2],t[$+12>>2]=t[EA+12>>2],Oe(f,U),n=t[$>>2]|0,s=t[17040+(n*80|0)+(t[HA>>2]<<2)>>2]|0,t[$>>2]=t[18640+(n*80|0)+(s*20|0)>>2],o=t[18640+(n*80|0)+(s*20|0)+16>>2]|0,(o|0)>0){e=0;do br(g),e=e+1|0;while((e|0)<(o|0))}switch(o=18640+(n*80|0)+(s*20|0)+4|0,t[SA>>2]=t[o>>2],t[SA+4>>2]=t[o+4>>2],t[SA+8>>2]=t[o+8>>2],ct(SA,(t[R>>2]|0)*3|0),ze(g,SA,g),oe(g),Oe(g,zA),Ye=+(t[I>>2]|0),b[QA>>3]=Ye*3,b[N>>3]=0,me=Ye*-1.5,b[ce>>3]=me,b[G>>3]=Ye*2.598076211353316,b[de>>3]=me,b[W>>3]=Ye*-2.598076211353316,t[17040+((t[$>>2]|0)*80|0)+(t[EA>>2]<<2)>>2]|0){case 1:{e=ce,n=QA;break}case 3:{e=de,n=ce;break}case 2:{e=QA,n=de;break}default:{e=12;break A}}qi(U,zA,n,e,Se),H0(Se,t[$>>2]|0,a,1,i+8+(t[i>>2]<<4)|0),t[i>>2]=(t[i>>2]|0)+1}if((l|0)<(M|0)&&(Oe(nA,$),H0($,t[EA>>2]|0,a,1,i+8+(t[i>>2]<<4)|0),t[i>>2]=(t[i>>2]|0)+1),t[HA>>2]=t[EA>>2],t[HA+4>>2]=t[EA+4>>2],t[HA+8>>2]=t[EA+8>>2],t[HA+12>>2]=t[EA+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,i=0,s=0,o=0,l=0,a=0;a=k,k=k+128|0,n=a+64|0,i=a,s=n,o=20240,l=s+60|0;do t[s>>2]=t[o>>2],s=s+4|0,o=o+4|0;while((s|0)<(l|0));s=i,o=20304,l=s+60|0;do t[s>>2]=t[o>>2],s=s+4|0,o=o+4|0;while((s|0)<(l|0));l=(t0(t[A>>2]|0)|0)==0,n=l?n:i,i=e+4|0,Yr(i),Kr(i),t0(t[A>>2]|0)|0&&(Vt(i),t[A>>2]=(t[A>>2]|0)+1),t[r>>2]=t[e>>2],A=r+4|0,ze(i,n,A),oe(A),t[r+16>>2]=t[e>>2],A=r+20|0,ze(i,n+12|0,A),oe(A),t[r+32>>2]=t[e>>2],A=r+36|0,ze(i,n+24|0,A),oe(A),t[r+48>>2]=t[e>>2],A=r+52|0,ze(i,n+36|0,A),oe(A),t[r+64>>2]=t[e>>2],r=r+68|0,ze(i,n+48|0,r),oe(r),k=a}function F(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=0,I=0,N=0;if(N=k,k=k+32|0,R=N+12|0,l=N,I=e+4|0,M=t[16960+(A<<2)>>2]|0,g=(n|0)!=0,M=g?M*3|0:M,i=t[I>>2]|0,f=e+8|0,o=t[f>>2]|0,g){if(s=e+12|0,n=t[s>>2]|0,i=o+i+n|0,(i|0)==(M|0))return I=1,k=N,I|0;a=s}else a=e+12|0,n=t[a>>2]|0,i=o+i+n|0;if((i|0)<=(M|0))return I=0,k=N,I|0;do if((n|0)>0){if(n=t[e>>2]|0,(o|0)>0){s=18640+(n*80|0)+60|0,n=e;break}n=18640+(n*80|0)+40|0,r?(WA(R,M,0,0),wt(I,R,l),j0(l),ze(l,R,I),s=n,n=e):(s=n,n=e)}else s=18640+((t[e>>2]|0)*80|0)+20|0,n=e;while(!1);if(t[n>>2]=t[s>>2],i=s+16|0,(t[i>>2]|0)>0){n=0;do br(I),n=n+1|0;while((n|0)<(t[i>>2]|0))}return e=s+4|0,t[R>>2]=t[e>>2],t[R+4>>2]=t[e+4>>2],t[R+8>>2]=t[e+8>>2],A=t[16880+(A<<2)>>2]|0,ct(R,g?A*3|0:A),ze(I,R,I),oe(I),g?n=((t[f>>2]|0)+(t[I>>2]|0)+(t[a>>2]|0)|0)==(M|0)?1:2:n=2,I=n,k=N,I|0}function tA(e,A){e=e|0,A=A|0;var r=0;do r=F(e,A,0,1)|0;while((r|0)==2);return r|0}function X(e,A,r,n,i){e=e|0,A=A|0,r=r|0,n=n|0,i=i|0;var s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=0,I=0,N=0,G=0,W=0,nA=0,q=0,$=0,U=0,SA=0,zA=0,QA=0,ce=0,de=0,Se=0,ne=0;if(de=k,k=k+240|0,s=de+224|0,SA=de+208|0,zA=de,QA=de+192|0,ce=de+176|0,W=de+160|0,nA=de+144|0,q=de+128|0,$=de+112|0,U=de+96|0,t[s>>2]=A,t[SA>>2]=t[e>>2],t[SA+4>>2]=t[e+4>>2],t[SA+8>>2]=t[e+8>>2],t[SA+12>>2]=t[e+12>>2],dA(SA,s,zA),t[i>>2]=0,G=n+r+((n|0)==6&1)|0,(G|0)<=(r|0)){k=de;return}a=t[s>>2]|0,f=r+6|0,g=16960+(a<<2)|0,M=nA+8|0,R=q+8|0,I=$+8|0,N=QA+4|0,o=0,l=r,n=-1;A:for(;;){if(s=(l|0)%6|0,e=zA+(s<<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=o,o=F(QA,a,0,1)|0,(l|0)>(r|0)&(t0(A)|0)!=0&&(e|0)!=1&&(t[QA>>2]|0)!=(n|0)){switch(Oe(zA+(((s+5|0)%6|0)<<4)+4|0,ce),Oe(zA+(s<<4)+4|0,W),Se=+(t[g>>2]|0),b[nA>>3]=Se*3,b[M>>3]=0,ne=Se*-1.5,b[q>>3]=ne,b[R>>3]=Se*2.598076211353316,b[$>>3]=ne,b[I>>3]=Se*-2.598076211353316,s=t[SA>>2]|0,t[17040+(s*80|0)+(((n|0)==(s|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}}qi(ce,W,n,e,U),!(Ji(ce,U)|0)&&!(Ji(W,U)|0)&&(H0(U,t[SA>>2]|0,a,1,i+8+(t[i>>2]<<4)|0),t[i>>2]=(t[i>>2]|0)+1)}if((l|0)<(f|0)&&(Oe(N,ce),H0(ce,t[QA>>2]|0,a,1,i+8+(t[i>>2]<<4)|0),t[i>>2]=(t[i>>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=de;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,i=0,s=0,o=0,l=0,a=0;a=k,k=k+160|0,n=a+80|0,i=a,s=n,o=20368,l=s+72|0;do t[s>>2]=t[o>>2],s=s+4|0,o=o+4|0;while((s|0)<(l|0));s=i,o=20448,l=s+72|0;do t[s>>2]=t[o>>2],s=s+4|0,o=o+4|0;while((s|0)<(l|0));l=(t0(t[A>>2]|0)|0)==0,n=l?n:i,i=e+4|0,Yr(i),Kr(i),t0(t[A>>2]|0)|0&&(Vt(i),t[A>>2]=(t[A>>2]|0)+1),t[r>>2]=t[e>>2],A=r+4|0,ze(i,n,A),oe(A),t[r+16>>2]=t[e>>2],A=r+20|0,ze(i,n+12|0,A),oe(A),t[r+32>>2]=t[e>>2],A=r+36|0,ze(i,n+24|0,A),oe(A),t[r+48>>2]=t[e>>2],A=r+52|0,ze(i,n+36|0,A),oe(A),t[r+64>>2]=t[e>>2],A=r+68|0,ze(i,n+48|0,A),oe(A),t[r+80>>2]=t[e>>2],r=r+84|0,ze(i,n+60|0,r),oe(r),k=a}function MA(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 i=0,s=0,o=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;o=kA(e|0,0,52)|0,i=S()|0,l=kA(A|0,0,45)|0,i=i|(S()|0)|134225919;A:do if((e|0)>=1){for(l=1,o=(xA[20528+A>>0]|0)!=0,s=-1;;){if(A=t[r+(l+-1<<2)>>2]|0,A>>>0>6){i=18,A=10;break}if(!((A|0)==0|o^1))if((A|0)==1){i=19,A=10;break}else o=0;if(f=(15-l|0)*3|0,a=kA(7,0,f|0)|0,i=i&~(S()|0),A=kA(A|0,((A|0)<0)<<31>>31|0,f|0)|0,s=A|s&~a,i=S()|0|i,(l|0)<(e|0))l=l+1|0;else break A}if((A|0)==10)return i|0}else s=-1;while(!1);return f=n,t[f>>2]=s,t[f+4>>2]=i,f=0,f|0}function We(e,A){e=e|0,A=A|0;var r=0,n=0,i=0,s=0,o=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):(o=(n^15)*3|0,i=wA(e|0,A|0,o|0)|0,o=kA(i|0,S()|0,o|0)|0,i=S()|0,s=ft(-1227133514,-1171,o|0,i|0)|0,!((o&613566756&s|0)==0&(i&4681&(S()|0)|0)==0)||(o=(n*3|0)+19|0,s=kA(~e|0,~A|0,o|0)|0,o=wA(s|0,S()|0,o|0)|0,!((n|0)==15|(o|0)==0&(S()|0)==0))?(o=0,o|0):!(xA[20528+r>>0]|0)||(A=A&8191,(e|0)==0&(A|0)==0)?(o=1,o|0):(o=oi(e|0,A|0)|0,S()|0,((63-o|0)%3|0|0)!=0|0))}function Tt(e,A){e=e|0,A=A|0;var r=0,n=0,i=0,s=0,o=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)&&(o=(n^15)*3|0,i=wA(e|0,A|0,o|0)|0,o=kA(i|0,S()|0,o|0)|0,i=S()|0,s=ft(-1227133514,-1171,o|0,i|0)|0,(o&613566756&s|0)==0&(i&4681&(S()|0)|0)==0)&&(o=(n*3|0)+19|0,s=kA(~e|0,~A|0,o|0)|0,o=wA(s|0,S()|0,o|0)|0,(n|0)==15|(o|0)==0&(S()|0)==0)&&(!(xA[20528+r>>0]|0)||(r=A&8191,(e|0)==0&(r|0)==0)||(o=oi(e|0,r|0)|0,S()|0,(63-o|0)%3|0|0))||Jr(e,A)|0?(o=1,o|0):(o=(Xi(e,A)|0)!=0&1,o|0)}function jt(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0,o=0,l=0;if(i=kA(A|0,0,52)|0,s=S()|0,r=kA(r|0,0,45)|0,r=s|(S()|0)|134225919,(A|0)<1){s=-1,n=r,A=e,t[A>>2]=s,e=e+4|0,t[e>>2]=n;return}for(s=1,i=-1;o=(15-s|0)*3|0,l=kA(7,0,o|0)|0,r=r&~(S()|0),o=kA(n|0,0,o|0)|0,i=i&~l|o,r=r|(S()|0),(s|0)!=(A|0);)s=s+1|0;l=e,o=l,t[o>>2]=i,l=l+4|0,t[l>>2]=r}function Rt(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0;if(s=wA(e|0,A|0,52)|0,S()|0,s=s&15,r>>>0>15)return n=4,n|0;if((s|0)<(r|0))return n=12,n|0;if((s|0)==(r|0))return t[n>>2]=e,t[n+4>>2]=A,n=0,n|0;if(i=kA(r|0,0,52)|0,i=i|e,e=S()|0|A&-15728641,(s|0)>(r|0))do A=kA(7,0,(14-r|0)*3|0)|0,r=r+1|0,i=A|i,e=S()|0|e;while((r|0)<(s|0));return t[n>>2]=i,t[n+4>>2]=e,n=0,n|0}function x0(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0,o=0;if(s=wA(e|0,A|0,52)|0,S()|0,s=s&15,!((r|0)<16&(s|0)<=(r|0)))return n=4,n|0;i=r-s|0,r=wA(e|0,A|0,45)|0,S()|0;A:do if(!(je(r&127)|0))r=G0(7,0,i,((i|0)<0)<<31>>31)|0,i=S()|0;else{e:do if(s|0){for(r=1;o=kA(7,0,(15-r|0)*3|0)|0,!!((o&e|0)==0&((S()|0)&A|0)==0);)if(r>>>0>>0)r=r+1|0;else break e;r=G0(7,0,i,((i|0)<0)<<31>>31)|0,i=S()|0;break A}while(!1);r=G0(7,0,i,((i|0)<0)<<31>>31)|0,r=ht(r|0,S()|0,5,0)|0,r=YA(r|0,S()|0,-5,-1)|0,r=V0(r|0,S()|0,6,0)|0,r=YA(r|0,S()|0,1,0)|0,i=S()|0}while(!1);return o=n,t[o>>2]=r,t[o+4>>2]=i,o=0,o|0}function He(e,A){e=e|0,A=A|0;var r=0,n=0,i=0;if(i=wA(e|0,A|0,45)|0,S()|0,!(je(i&127)|0))return i=0,i|0;i=wA(e|0,A|0,52)|0,S()|0,i=i&15;A:do if(!i)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 i=(r|0)==0&1,i|0}function An(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0,o=0,l=0;if(o=k,k=k+16|0,s=o,Ai(s,e,A,r),A=s,e=t[A>>2]|0,A=t[A+4>>2]|0,(e|0)==0&(A|0)==0)return k=o,0;i=0,r=0;do l=n+(i<<3)|0,t[l>>2]=e,t[l+4>>2]=A,i=YA(i|0,r|0,1,0)|0,r=S()|0,ei(s),l=s,e=t[l>>2]|0,A=t[l+4>>2]|0;while(!((e|0)==0&(A|0)==0));return k=o,0}function Pi(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,$A(r|0),n|0):(r=kA(-1,-1,((n-r|0)*3|0)+3|0)|0,n=kA(~r|0,~(S()|0)|0,(15-n|0)*3|0)|0,r=~(S()|0)&A,n=~n&e,$A(r|0),n|0)}function Qi(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0;return i=wA(e|0,A|0,52)|0,S()|0,i=i&15,(r|0)<16&(i|0)<=(r|0)?((i|0)<(r|0)&&(i=kA(-1,-1,((r+-1-i|0)*3|0)+3|0)|0,i=kA(~i|0,~(S()|0)|0,(15-r|0)*3|0)|0,A=~(S()|0)&A,e=~i&e),i=kA(r|0,0,52)|0,r=A&-15728641|(S()|0),t[n>>2]=e|i,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 i=0,s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=0,I=0,N=0,G=0,W=0,nA=0,q=0,$=0,U=0,SA=0,zA=0,QA=0,ce=0,de=0,Se=0,ne=0,HA=0,EA=0;if((r|0)==0&(n|0)==0)return EA=0,EA|0;if(i=e,s=t[i>>2]|0,i=t[i+4>>2]|0,!0&(i&15728640|0)==0){if(!((n|0)>0|(n|0)==0&r>>>0>0)||(EA=A,t[EA>>2]=s,t[EA+4>>2]=i,(r|0)==1&(n|0)==0))return EA=0,EA|0;i=1,s=0;do ne=e+(i<<3)|0,HA=t[ne+4>>2]|0,EA=A+(i<<3)|0,t[EA>>2]=t[ne>>2],t[EA+4>>2]=HA,i=YA(i|0,s|0,1,0)|0,s=S()|0;while((s|0)<(n|0)|(s|0)==(n|0)&i>>>0>>0);return i=0,i|0}if(Se=r<<3,HA=w0(Se)|0,!HA)return EA=13,EA|0;if(jr(HA|0,e|0,Se|0)|0,ne=Gt(r,8)|0,!ne)return qA(HA),EA=13,EA|0;A:for(;;){i=HA,f=t[i>>2]|0,i=t[i+4>>2]|0,ce=wA(f|0,i|0,52)|0,S()|0,ce=ce&15,de=ce+-1|0,QA=(ce|0)!=0,zA=(n|0)>0|(n|0)==0&r>>>0>0;e:do if(QA&zA){if(q=kA(de|0,0,52)|0,$=S()|0,de>>>0>15){if(!((f|0)==0&(i|0)==0)){EA=16;break A}for(s=0,e=0;;){if(s=YA(s|0,e|0,1,0)|0,e=S()|0,!((e|0)<(n|0)|(e|0)==(n|0)&s>>>0>>0))break e;if(o=HA+(s<<3)|0,SA=t[o>>2]|0,o=t[o+4>>2]|0,!((SA|0)==0&(o|0)==0)){i=o,EA=16;break A}}}for(l=f,e=i,s=0,o=0;;){if(!((l|0)==0&(e|0)==0)){if(!(!0&(e&117440512|0)==0)){EA=21;break A}if(g=wA(l|0,e|0,52)|0,S()|0,g=g&15,(g|0)<(de|0)){i=12,EA=27;break A}if((g|0)!=(de|0)&&(l=l|q,e=e&-15728641|$,g>>>0>=ce>>>0)){a=de;do SA=kA(7,0,(14-a|0)*3|0)|0,a=a+1|0,l=SA|l,e=S()|0|e;while(a>>>0>>0)}if(R=Tr(l|0,e|0,r|0,n|0)|0,I=S()|0,a=ne+(R<<3)|0,g=a,M=t[g>>2]|0,g=t[g+4>>2]|0,!((M|0)==0&(g|0)==0)){W=0,nA=0;do{if((W|0)>(n|0)|(W|0)==(n|0)&nA>>>0>r>>>0){EA=31;break A}if((M|0)==(l|0)&(g&-117440513|0)==(e|0)){N=wA(M|0,g|0,56)|0,S()|0,N=N&7,G=N+1|0,SA=wA(M|0,g|0,45)|0,S()|0;t:do if(!(je(SA&127)|0))g=7;else{if(M=wA(M|0,g|0,52)|0,S()|0,M=M&15,!M){g=6;break}for(g=1;;){if(SA=kA(7,0,(15-g|0)*3|0)|0,!((SA&l|0)==0&((S()|0)&e|0)==0)){g=7;break t}if(g>>>0>>0)g=g+1|0;else{g=6;break}}}while(!1);if((N+2|0)>>>0>g>>>0){EA=41;break A}SA=kA(G|0,0,56)|0,e=S()|0|e&-117440513,U=a,t[U>>2]=0,t[U+4>>2]=0,l=SA|l}else R=YA(R|0,I|0,1,0)|0,R=_r(R|0,S()|0,r|0,n|0)|0,I=S()|0;nA=YA(nA|0,W|0,1,0)|0,W=S()|0,a=ne+(R<<3)|0,g=a,M=t[g>>2]|0,g=t[g+4>>2]|0}while(!((M|0)==0&(g|0)==0))}SA=a,t[SA>>2]=l,t[SA+4>>2]=e}if(s=YA(s|0,o|0,1,0)|0,o=S()|0,!((o|0)<(n|0)|(o|0)==(n|0)&s>>>0>>0))break e;e=HA+(s<<3)|0,l=t[e>>2]|0,e=t[e+4>>2]|0}}while(!1);if(SA=YA(r|0,n|0,5,0)|0,U=S()|0,U>>>0<0|(U|0)==0&SA>>>0<11){EA=85;break}if(SA=V0(r|0,n|0,6,0)|0,S()|0,SA=Gt(SA,8)|0,!SA){EA=48;break}do if(zA){for(G=0,e=0,N=0,W=0;;){if(g=ne+(G<<3)|0,o=g,s=t[o>>2]|0,o=t[o+4>>2]|0,(s|0)==0&(o|0)==0)U=N;else{M=wA(s|0,o|0,56)|0,S()|0,M=M&7,l=M+1|0,R=o&-117440513,U=wA(s|0,o|0,45)|0,S()|0;e:do if(je(U&127)|0){if(I=wA(s|0,o|0,52)|0,S()|0,I=I&15,I|0)for(a=1;;){if(U=kA(7,0,(15-a|0)*3|0)|0,!((s&U|0)==0&(R&(S()|0)|0)==0))break e;if(a>>>0>>0)a=a+1|0;else break}o=kA(l|0,0,56)|0,s=o|s,o=S()|0|R,l=g,t[l>>2]=s,t[l+4>>2]=o,l=M+2|0}while(!1);(l|0)==7?(U=SA+(e<<3)|0,t[U>>2]=s,t[U+4>>2]=o&-117440513,e=YA(e|0,N|0,1,0)|0,U=S()|0):U=N}if(G=YA(G|0,W|0,1,0)|0,W=S()|0,(W|0)<(n|0)|(W|0)==(n|0)&G>>>0>>0)N=U;else break}if(zA){if(nA=de>>>0>15,q=kA(de|0,0,52)|0,$=S()|0,!QA){for(s=0,a=0,l=0,o=0;(f|0)==0&(i|0)==0||(de=A+(s<<3)|0,t[de>>2]=f,t[de+4>>2]=i,s=YA(s|0,a|0,1,0)|0,a=S()|0),l=YA(l|0,o|0,1,0)|0,o=S()|0,!!((o|0)<(n|0)|(o|0)==(n|0)&l>>>0>>0);)i=HA+(l<<3)|0,f=t[i>>2]|0,i=t[i+4>>2]|0;i=U;break}for(s=0,a=0,o=0,l=0;;){do if(!((f|0)==0&(i|0)==0)){if(I=wA(f|0,i|0,52)|0,S()|0,I=I&15,nA|(I|0)<(de|0)){EA=80;break A}if((I|0)!=(de|0)){if(g=f|q,M=i&-15728641|$,I>>>0>=ce>>>0){R=de;do QA=kA(7,0,(14-R|0)*3|0)|0,R=R+1|0,g=QA|g,M=S()|0|M;while(R>>>0>>0)}}else g=f,M=i;N=Tr(g|0,M|0,r|0,n|0)|0,R=0,I=0,W=S()|0;do{if((R|0)>(n|0)|(R|0)==(n|0)&I>>>0>r>>>0){EA=81;break A}if(QA=ne+(N<<3)|0,G=t[QA+4>>2]|0,(G&-117440513|0)==(M|0)&&(t[QA>>2]|0)==(g|0)){EA=65;break}QA=YA(N|0,W|0,1,0)|0,N=_r(QA|0,S()|0,r|0,n|0)|0,W=S()|0,I=YA(I|0,R|0,1,0)|0,R=S()|0,QA=ne+(N<<3)|0}while(!((t[QA>>2]|0)==(g|0)&&(t[QA+4>>2]|0)==(M|0)));if((EA|0)==65&&(EA=0,!0&(G&117440512|0)==100663296))break;QA=A+(s<<3)|0,t[QA>>2]=f,t[QA+4>>2]=i,s=YA(s|0,a|0,1,0)|0,a=S()|0}while(!1);if(o=YA(o|0,l|0,1,0)|0,l=S()|0,!((l|0)<(n|0)|(l|0)==(n|0)&o>>>0>>0))break;i=HA+(o<<3)|0,f=t[i>>2]|0,i=t[i+4>>2]|0}i=U}else s=0,i=U}else s=0,e=0,i=0;while(!1);if(W0(ne|0,0,Se|0)|0,jr(HA|0,SA|0,e<<3|0)|0,qA(SA),(e|0)==0&(i|0)==0){EA=89;break}else A=A+(s<<3)|0,n=i,r=e}if((EA|0)==16)!0&(i&117440512|0)==0?(i=4,EA=27):EA=21;else if((EA|0)==31)OA(27795,27122,620,27132);else{if((EA|0)==41)return qA(HA),qA(ne),EA=10,EA|0;if((EA|0)==48)return qA(HA),qA(ne),EA=13,EA|0;(EA|0)==80?OA(27795,27122,711,27132):(EA|0)==81?OA(27795,27122,723,27132):(EA|0)==85&&(jr(A|0,HA|0,r<<3|0)|0,EA=89)}return(EA|0)==21?(qA(HA),qA(ne),EA=5,EA|0):(EA|0)==27?(qA(HA),qA(ne),EA=i,EA|0):(EA|0)==89?(qA(HA),qA(ne),EA=0,EA|0):0}function ll(e,A,r,n,i,s,o){e=e|0,A=A|0,r=r|0,n=n|0,i=i|0,s=s|0,o=o|0;var l=0,a=0,f=0,g=0,M=0,R=0,I=0,N=0,G=0;if(G=k,k=k+16|0,N=G,!((r|0)>0|(r|0)==0&A>>>0>0))return N=0,k=G,N|0;if((o|0)>=16)return N=12,k=G,N|0;R=0,I=0,M=0,l=0;A:for(;;){if(f=e+(R<<3)|0,a=t[f>>2]|0,f=t[f+4>>2]|0,g=wA(a|0,f|0,52)|0,S()|0,(g&15|0)>(o|0)){l=12,a=11;break}if(Ai(N,a,f,o),g=N,f=t[g>>2]|0,g=t[g+4>>2]|0,(f|0)==0&(g|0)==0)a=M;else{a=M;do{if(!((l|0)<(s|0)|(l|0)==(s|0)&a>>>0>>0)){a=10;break A}M=n+(a<<3)|0,t[M>>2]=f,t[M+4>>2]=g,a=YA(a|0,l|0,1,0)|0,l=S()|0,ei(N),M=N,f=t[M>>2]|0,g=t[M+4>>2]|0}while(!((f|0)==0&(g|0)==0))}if(R=YA(R|0,I|0,1,0)|0,I=S()|0,(I|0)<(r|0)|(I|0)==(r|0)&R>>>0>>0)M=a;else{l=0,a=11;break}}return(a|0)==10?(N=14,k=G,N|0):(a|0)==11?(k=G,l|0):0}function al(e,A,r,n,i){e=e|0,A=A|0,r=r|0,n=n|0,i=i|0;var s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=0;R=k,k=k+16|0,M=R;A:do if((r|0)>0|(r|0)==0&A>>>0>0){for(f=0,o=0,s=0,g=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=(x0(l,a,n,M)|0)==0,l=M,o=YA(t[l>>2]|0,t[l+4>>2]|0,o|0,s|0)|0,s=S()|0,!a)){s=12;break}if(f=YA(f|0,g|0,1,0)|0,g=S()|0,!((g|0)<(r|0)|(g|0)==(r|0)&f>>>0>>0))break A}return k=R,s|0}else o=0,s=0;while(!1);return t[i>>2]=o,t[i+4>>2]=s,i=0,k=R,i|0}function ul(e,A){return e=e|0,A=A|0,A=wA(e|0,A|0,52)|0,S()|0,A&1|0}function Ht(e,A){e=e|0,A=A|0;var r=0,n=0,i=0;if(i=wA(e|0,A|0,52)|0,S()|0,i=i&15,!i)return i=0,i|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 Zn(e,A){e=e|0,A=A|0;var r=0,n=0,i=0,s=0,o=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,$A(l|0),a|0;for(l=1,r=0;;){s=(15-l|0)*3|0,n=kA(7,0,s|0)|0,i=S()|0,o=wA(e|0,A|0,s|0)|0,S()|0,s=kA(Wt(o&7)|0,0,s|0)|0,o=S()|0,e=s|e&~n,A=o|A&~i;A:do if(!r)if((s&n|0)==0&(o&i|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(o=wA(e|0,A|0,(15-r|0)*3|0)|0,S()|0,o&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=wA(e|0,A|0,o|0)|0,S()|0,s=kA(7,0,o|0)|0,A=A&~(S()|0),o=kA(Wt(i&7)|0,0,o|0)|0,e=e&~s|o,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 $A(A|0),e|0}function sr(e,A){e=e|0,A=A|0;var r=0,n=0,i=0,s=0,o=0;if(n=wA(e|0,A|0,52)|0,S()|0,n=n&15,!n)return r=A,n=e,$A(r|0),n|0;for(r=1;s=(15-r|0)*3|0,o=wA(e|0,A|0,s|0)|0,S()|0,i=kA(7,0,s|0)|0,A=A&~(S()|0),s=kA(Wt(o&7)|0,0,s|0)|0,e=s|e&~i,A=S()|0|A,r>>>0>>0;)r=r+1|0;return $A(A|0),e|0}function cl(e,A){e=e|0,A=A|0;var r=0,n=0,i=0,s=0,o=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,$A(l|0),a|0;for(l=1,r=0;;){s=(15-l|0)*3|0,n=kA(7,0,s|0)|0,i=S()|0,o=wA(e|0,A|0,s|0)|0,S()|0,s=kA(Yt(o&7)|0,0,s|0)|0,o=S()|0,e=s|e&~n,A=o|A&~i;A:do if(!r)if((s&n|0)==0&(o&i|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(o=wA(e|0,A|0,(15-r|0)*3|0)|0,S()|0,o&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(i=(15-r|0)*3|0,s=kA(7,0,i|0)|0,o=A&~(S()|0),A=wA(e|0,A|0,i|0)|0,S()|0,A=kA(Yt(A&7)|0,0,i|0)|0,e=e&~s|A,A=o|(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 $A(A|0),e|0}function $n(e,A){e=e|0,A=A|0;var r=0,n=0,i=0,s=0,o=0;if(n=wA(e|0,A|0,52)|0,S()|0,n=n&15,!n)return r=A,n=e,$A(r|0),n|0;for(r=1;o=(15-r|0)*3|0,s=kA(7,0,o|0)|0,i=A&~(S()|0),A=wA(e|0,A|0,o|0)|0,S()|0,A=kA(Yt(A&7)|0,0,o|0)|0,e=A|e&~s,A=S()|0|i,r>>>0>>0;)r=r+1|0;return $A(A|0),e|0}function fl(e,A){e=e|0,A=A|0;var r=0,n=0,i=0,s=0,o=0,l=0,a=0,f=0,g=0;if(a=k,k=k+64|0,l=a+40|0,n=a+24|0,i=a+12|0,s=a,kA(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?(o=0,l=0,$A(o|0),k=a,l|0):(kA(g0(e)|0,0,45)|0,o=S()|0|r,l=-1,$A(o|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],o=l+4|0,(A|0)>0)for(e=-1;t[n>>2]=t[o>>2],t[n+4>>2]=t[o+4>>2],t[n+8>>2]=t[o+8>>2],A&1?(xr(o),t[i>>2]=t[o>>2],t[i+4>>2]=t[o+4>>2],t[i+8>>2]=t[o+8>>2],vr(i)):(wr(o),t[i>>2]=t[o>>2],t[i+4>>2]=t[o+4>>2],t[i+8>>2]=t[o+8>>2],Vt(i)),wt(n,i,s),oe(s),g=(15-A|0)*3|0,f=kA(7,0,g|0)|0,r=r&~(S()|0),g=kA(tt(s)|0,0,g|0)|0,e=g|e&~f,r=S()|0|r,(A|0)>1;)A=A+-1|0;else e=-1;A:do if((t[o>>2]|0)<=2&&(t[l+8>>2]|0)<=2&&(t[l+12>>2]|0)<=2){if(n=g0(l)|0,A=kA(n|0,0,45)|0,A=A|e,e=S()|0|r&-1040385,s=u0(l)|0,!(je(n)|0)){if((s|0)<=0)break;for(i=0;;){if(n=wA(A|0,e|0,52)|0,S()|0,n=n&15,n)for(r=1;g=(15-r|0)*3|0,l=wA(A|0,e|0,g|0)|0,S()|0,f=kA(7,0,g|0)|0,e=e&~(S()|0),g=kA(Wt(l&7)|0,0,g|0)|0,A=A&~f|g,e=e|(S()|0),r>>>0>>0;)r=r+1|0;if(i=i+1|0,(i|0)==(s|0))break A}}i=wA(A|0,e|0,52)|0,S()|0,i=i&15;e:do if(i){r=1;t:for(;;){switch(g=wA(A|0,e|0,(15-r|0)*3|0)|0,S()|0,g&7){case 1:break t;case 0:break;default:break e}if(r>>>0>>0)r=r+1|0;else break e}if(_0(n,t[l>>2]|0)|0)for(r=1;l=(15-r|0)*3|0,f=kA(7,0,l|0)|0,g=e&~(S()|0),e=wA(A|0,e|0,l|0)|0,S()|0,e=kA(Yt(e&7)|0,0,l|0)|0,A=A&~f|e,e=g|(S()|0),r>>>0>>0;)r=r+1|0;else for(r=1;g=(15-r|0)*3|0,l=wA(A|0,e|0,g|0)|0,S()|0,f=kA(7,0,g|0)|0,e=e&~(S()|0),g=kA(Wt(l&7)|0,0,g|0)|0,A=A&~f|g,e=e|(S()|0),r>>>0>>0;)r=r+1|0}while(!1);if((s|0)>0){r=0;do A=Zn(A,e)|0,e=S()|0,r=r+1|0;while((r|0)!=(s|0))}}else A=0,e=0;while(!1);return f=e,g=A,$A(f|0),k=a,g|0}function t0(e){return e=e|0,(e|0)%2|0|0}function qn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0;return i=k,k=k+16|0,n=i,A>>>0>15?(n=4,k=i,n|0):(t[e+4>>2]&2146435072|0)==2146435072||(t[e+8+4>>2]&2146435072|0)==2146435072?(n=3,k=i,n|0):(pn(e,A,n),A=fl(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=i,n|0)}function Jn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0,o=0;if(i=r+4|0,s=wA(e|0,A|0,52)|0,S()|0,s=s&15,o=wA(e|0,A|0,45)|0,S()|0,n=(s|0)==0,je(o&127)|0){if(n)return o=1,o|0;n=1}else{if(n)return o=0,o|0;(t[i>>2]|0)==0&&(t[r+8>>2]|0)==0?n=(t[r+12>>2]|0)!=0&1:n=1}for(r=1;r&1?vr(i):Vt(i),o=wA(e|0,A|0,(15-r|0)*3|0)|0,S()|0,dn(i,o&7),r>>>0>>0;)r=r+1|0;return n|0}function Mr(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0,o=0,l=0,a=0,f=0,g=0;if(g=k,k=k+16|0,a=g,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=g,f|0;A:do if((je(f)|0)!=0&&(s=wA(e|0,A|0,52)|0,S()|0,s=s&15,(s|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(i=1,n=A;A=(15-i|0)*3|0,o=kA(7,0,A|0)|0,l=n&~(S()|0),n=wA(e|0,n|0,A|0)|0,S()|0,n=kA(Yt(n&7)|0,0,A|0)|0,e=e&~o|n,n=l|(S()|0),i>>>0>>0;)i=i+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],!(Jn(e,n,r)|0))return f=0,k=g,f|0;if(o=r+4|0,t[a>>2]=t[o>>2],t[a+4>>2]=t[o+4>>2],t[a+8>>2]=t[o+8>>2],s=wA(e|0,n|0,52)|0,S()|0,l=s&15,s&1?(Vt(o),s=l+1|0):s=l,!(je(f)|0))n=0;else{A:do if(!l)n=0;else for(A=1;;){if(i=wA(e|0,n|0,(15-A|0)*3|0)|0,S()|0,i=i&7,i|0){n=i;break A}if(A>>>0>>0)A=A+1|0;else{n=0;break}}while(!1);n=(n|0)==4&1}if(!(F(r,s,n,0)|0))(s|0)!=(l|0)&&(t[o>>2]=t[a>>2],t[o+4>>2]=t[a+4>>2],t[o+8>>2]=t[a+8>>2]);else{if(je(f)|0)do;while((F(r,s,0,0)|0)!=0);(s|0)!=(l|0)&&wr(o)}return f=0,k=g,f|0}function or(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0;return s=k,k=k+16|0,n=s,i=Mr(e,A,n)|0,i|0?(k=s,i|0):(i=wA(e|0,A|0,52)|0,S()|0,d(n,i&15,r),i=0,k=s,i|0)}function Br(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0,o=0,l=0;if(o=k,k=k+16|0,s=o,n=Mr(e,A,s)|0,n|0)return s=n,k=o,s|0;n=wA(e|0,A|0,45)|0,S()|0,n=(je(n&127)|0)==0,i=wA(e|0,A|0,52)|0,S()|0,i=i&15;A:do if(!n){if(i|0)for(n=1;;){if(l=kA(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(s,i,0,5,r),l=0,k=o,l|0}while(!1);return X(s,i,0,6,r),l=0,k=o,l|0}function hl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0;if(i=wA(e|0,A|0,45)|0,S()|0,!(je(i&127)|0))return i=2,t[r>>2]=i,0;if(i=wA(e|0,A|0,52)|0,S()|0,i=i&15,!i)return i=5,t[r>>2]=i,0;for(n=1;;){if(s=kA(7,0,(15-n|0)*3|0)|0,!((s&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 Oi(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0,o=0,l=0,a=0,f=0,g=0,M=0;M=k,k=k+128|0,f=M+112|0,s=M+96|0,g=M,i=wA(e|0,A|0,52)|0,S()|0,l=i&15,t[f>>2]=l,o=wA(e|0,A|0,45)|0,S()|0,o=o&127;A:do if(je(o)|0){if(l|0)for(n=1;;){if(a=kA(7,0,(15-n|0)*3|0)|0,!((a&e|0)==0&((S()|0)&A|0)==0)){i=0;break A}if(n>>>0>>0)n=n+1|0;else break}if(i&1)i=1;else return a=kA(l+1|0,0,52)|0,g=S()|0|A&-15728641,f=kA(7,0,(14-l|0)*3|0)|0,g=Oi((a|e)&~f,g&~(S()|0),r)|0,k=M,g|0}else i=0;while(!1);if(n=Mr(e,A,s)|0,!n){i?(B(s,f,g),a=5):(dA(s,f,g),a=6);A:do if(je(o)|0)if(!l)e=5;else for(n=1;;){if(o=kA(7,0,(15-n|0)*3|0)|0,!((o&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);W0(r|0,-1,e<<2|0)|0;A:do if(i)for(s=0;;){if(o=g+(s<<4)|0,tA(o,t[f>>2]|0)|0,o=t[o>>2]|0,l=t[r>>2]|0,(l|0)==-1|(l|0)==(o|0))n=r;else{i=0;do{if(i=i+1|0,i>>>0>=e>>>0){n=1;break A}n=r+(i<<2)|0,l=t[n>>2]|0}while(!((l|0)==-1|(l|0)==(o|0)))}if(t[n>>2]=o,s=s+1|0,s>>>0>=a>>>0){n=0;break}}else for(s=0;;){if(o=g+(s<<4)|0,F(o,t[f>>2]|0,0,1)|0,o=t[o>>2]|0,l=t[r>>2]|0,(l|0)==-1|(l|0)==(o|0))n=r;else{i=0;do{if(i=i+1|0,i>>>0>=e>>>0){n=1;break A}n=r+(i<<2)|0,l=t[n>>2]|0}while(!((l|0)==-1|(l|0)==(o|0)))}if(t[n>>2]=o,s=s+1|0,s>>>0>=a>>>0){n=0;break}}while(!1)}return g=n,k=M,g|0}function dl(){return 12}function Xn(e,A){e=e|0,A=A|0;var r=0,n=0,i=0,s=0,o=0,l=0,a=0;if(e>>>0>15)return l=4,l|0;if(kA(e|0,0,52)|0,l=S()|0|134225919,!e){r=0,n=0;do je(n)|0&&(kA(n|0,0,45)|0,o=l|(S()|0),e=A+(r<<3)|0,t[e>>2]=-1,t[e+4>>2]=o,r=r+1|0),n=n+1|0;while((n|0)!=122);return r=0,r|0}r=0,o=0;do{if(je(o)|0){for(kA(o|0,0,45)|0,n=1,i=-1,s=l|(S()|0);a=kA(7,0,(15-n|0)*3|0)|0,i=i&~a,s=s&~(S()|0),(n|0)!=(e|0);)n=n+1|0;a=A+(r<<3)|0,t[a>>2]=i,t[a+4>>2]=s,r=r+1|0}o=o+1|0}while((o|0)!=122);return r=0,r|0}function ml(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=0,I=0,N=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(s=kA(r|0,0,52)|0,s=s|e,l=S()|0|A&-15728641,(nA|0)>(r|0)){a=r;do G=kA(7,0,(14-a|0)*3|0)|0,a=a+1|0,s=G|s,l=S()|0|l;while((a|0)<(nA|0));G=s}else G=s;else G=e,l=A;N=wA(G|0,l|0,45)|0,S()|0;A:do if(je(N&127)|0){if(a=wA(G|0,l|0,52)|0,S()|0,a=a&15,a|0)for(s=1;;){if(N=kA(7,0,(15-s|0)*3|0)|0,!((N&G|0)==0&((S()|0)&l|0)==0)){f=33;break A}if(s>>>0>>0)s=s+1|0;else break}if(N=n,t[N>>2]=0,t[N+4>>2]=0,(nA|0)>(r|0)){for(N=A&-15728641,I=nA;;){if(R=I,I=I+-1|0,I>>>0>15|(nA|0)<(I|0)){f=19;break}if((nA|0)!=(I|0))if(s=kA(I|0,0,52)|0,s=s|e,a=S()|0|N,(nA|0)<(R|0))M=s;else{f=I;do M=kA(7,0,(14-f|0)*3|0)|0,f=f+1|0,s=M|s,a=S()|0|a;while((f|0)<(nA|0));M=s}else M=e,a=A;if(g=wA(M|0,a|0,45)|0,S()|0,!(je(g&127)|0))s=0;else{g=wA(M|0,a|0,52)|0,S()|0,g=g&15;e:do if(!g)s=0;else for(f=1;;){if(s=wA(M|0,a|0,(15-f|0)*3|0)|0,S()|0,s=s&7,s|0)break e;if(f>>>0>>0)f=f+1|0;else{s=0;break}}while(!1);s=(s|0)==0&1}if(a=wA(e|0,A|0,(15-R|0)*3|0)|0,S()|0,a=a&7,(a|0)==7){i=5,f=42;break}if(s=(s|0)!=0,(a|0)==1&s){i=5,f=42;break}if(M=a+(((a|0)!=0&s)<<31>>31)|0,M|0&&(f=nA-R|0,f=G0(7,0,f,((f|0)<0)<<31>>31)|0,g=S()|0,s?(s=ht(f|0,g|0,5,0)|0,s=YA(s|0,S()|0,-5,-1)|0,s=V0(s|0,S()|0,6,0)|0,s=YA(s|0,S()|0,1,0)|0,a=S()|0):(s=f,a=g),R=M+-1|0,R=ht(f|0,g|0,R|0,((R|0)<0)<<31>>31|0)|0,R=YA(s|0,a|0,R|0,S()|0)|0,M=S()|0,g=n,g=YA(R|0,M|0,t[g>>2]|0,t[g+4>>2]|0)|0,M=S()|0,R=n,t[R>>2]=g,t[R+4>>2]=M),(I|0)<=(r|0)){f=37;break}}if((f|0)==19)OA(27795,27122,1367,27158);else if((f|0)==37){o=n,i=t[o+4>>2]|0,o=t[o>>2]|0;break}else if((f|0)==42)return k=q,i|0}else i=0,o=0}else f=33;while(!1);A:do if((f|0)==33)if(N=n,t[N>>2]=0,t[N+4>>2]=0,(nA|0)>(r|0)){for(s=nA;;){if(i=wA(e|0,A|0,(15-s|0)*3|0)|0,S()|0,i=i&7,(i|0)==7){i=5;break}if(o=nA-s|0,o=G0(7,0,o,((o|0)<0)<<31>>31)|0,i=ht(o|0,S()|0,i|0,0)|0,o=S()|0,N=n,o=YA(t[N>>2]|0,t[N+4>>2]|0,i|0,o|0)|0,i=S()|0,N=n,t[N>>2]=o,t[N+4>>2]=i,s=s+-1|0,(s|0)<=(r|0))break A}return k=q,i|0}else i=0,o=0;while(!1);return x0(G,l,nA,W)|0&&OA(27795,27122,1327,27173),nA=W,W=t[nA+4>>2]|0,((i|0)>-1|(i|0)==-1&o>>>0>4294967295)&((W|0)>(i|0)|((W|0)==(i|0)?(t[nA>>2]|0)>>>0>o>>>0:0))?(nA=0,k=q,nA|0):(OA(27795,27122,1407,27158),0)}function gl(e,A,r,n,i,s){e=e|0,A=A|0,r=r|0,n=n|0,i=i|0,s=s|0;var o=0,l=0,a=0,f=0,g=0,M=0,R=0,I=0,N=0,G=0;if(M=k,k=k+16|0,o=M,i>>>0>15)return s=4,k=M,s|0;if(l=wA(r|0,n|0,52)|0,S()|0,l=l&15,(l|0)>(i|0))return s=12,k=M,s|0;if(x0(r,n,i,o)|0&&OA(27795,27122,1327,27173),g=o,f=t[g+4>>2]|0,!(((A|0)>-1|(A|0)==-1&e>>>0>4294967295)&((f|0)>(A|0)|((f|0)==(A|0)?(t[g>>2]|0)>>>0>e>>>0:0))))return s=2,k=M,s|0;g=i-l|0,i=kA(i|0,0,52)|0,a=S()|0|n&-15728641,f=s,t[f>>2]=i|r,t[f+4>>2]=a,f=wA(r|0,n|0,45)|0,S()|0;A:do if(je(f&127)|0){if(l|0)for(o=1;;){if(f=kA(7,0,(15-o|0)*3|0)|0,!((f&r|0)==0&((S()|0)&n|0)==0))break A;if(o>>>0>>0)o=o+1|0;else break}if((g|0)<1)return s=0,k=M,s|0;for(f=l^15,n=-1,a=1,o=1;;){l=g-a|0,l=G0(7,0,l,((l|0)<0)<<31>>31)|0,r=S()|0;do if(o)if(o=ht(l|0,r|0,5,0)|0,o=YA(o|0,S()|0,-5,-1)|0,o=V0(o|0,S()|0,6,0)|0,i=S()|0,(A|0)>(i|0)|(A|0)==(i|0)&e>>>0>o>>>0){A=YA(e|0,A|0,-1,-1)|0,A=ft(A|0,S()|0,o|0,i|0)|0,o=S()|0,R=s,N=t[R>>2]|0,R=t[R+4>>2]|0,G=(f+n|0)*3|0,I=kA(7,0,G|0)|0,R=R&~(S()|0),n=V0(A|0,o|0,l|0,r|0)|0,e=S()|0,i=YA(n|0,e|0,2,0)|0,G=kA(i|0,S()|0,G|0)|0,R=S()|0|R,i=s,t[i>>2]=G|N&~I,t[i+4>>2]=R,e=ht(n|0,e|0,l|0,r|0)|0,e=ft(A|0,o|0,e|0,S()|0)|0,o=0,A=S()|0;break}else{G=s,I=t[G>>2]|0,G=t[G+4>>2]|0,N=kA(7,0,(f+n|0)*3|0)|0,G=G&~(S()|0),o=s,t[o>>2]=I&~N,t[o+4>>2]=G,o=1;break}else I=s,i=t[I>>2]|0,I=t[I+4>>2]|0,n=(f+n|0)*3|0,R=kA(7,0,n|0)|0,I=I&~(S()|0),G=V0(e|0,A|0,l|0,r|0)|0,o=S()|0,n=kA(G|0,o|0,n|0)|0,I=S()|0|I,N=s,t[N>>2]=n|i&~R,t[N+4>>2]=I,o=ht(G|0,o|0,l|0,r|0)|0,e=ft(e|0,A|0,o|0,S()|0)|0,o=0,A=S()|0;while(!1);if((g|0)>(a|0))n=~a,a=a+1|0;else{A=0;break}}return k=M,A|0}while(!1);if((g|0)<1)return G=0,k=M,G|0;for(i=l^15,o=1;;)if(N=g-o|0,N=G0(7,0,N,((N|0)<0)<<31>>31)|0,G=S()|0,a=s,r=t[a>>2]|0,a=t[a+4>>2]|0,l=(i-o|0)*3|0,n=kA(7,0,l|0)|0,a=a&~(S()|0),R=V0(e|0,A|0,N|0,G|0)|0,I=S()|0,l=kA(R|0,I|0,l|0)|0,a=S()|0|a,f=s,t[f>>2]=l|r&~n,t[f+4>>2]=a,G=ht(R|0,I|0,N|0,G|0)|0,e=ft(e|0,A|0,G|0,S()|0)|0,A=S()|0,(g|0)<=(o|0)){A=0;break}else o=o+1|0;return k=M,A|0}function Ai(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0,o=0;i=wA(A|0,r|0,52)|0,S()|0,i=i&15,(A|0)==0&(r|0)==0|((n|0)>15|(i|0)>(n|0))?(s=-1,A=-1,r=0,i=0):(A=Pi(A,r,i+1|0,n)|0,o=(S()|0)&-15728641,r=kA(n|0,0,52)|0,r=A|r,o=o|(S()|0),A=(He(r,o)|0)==0,s=i,A=A?-1:n,i=o),o=e,t[o>>2]=r,t[o+4>>2]=i,t[e+8>>2]=s,t[e+12>>2]=A}function zi(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0;if(i=wA(e|0,A|0,52)|0,S()|0,i=i&15,s=n+8|0,t[s>>2]=i,(e|0)==0&(A|0)==0|((r|0)>15|(i|0)>(r|0))){r=n,t[r>>2]=0,t[r+4>>2]=0,t[s>>2]=-1,t[n+12>>2]=-1;return}if(e=Pi(e,A,i+1|0,r)|0,s=(S()|0)&-15728641,i=kA(r|0,0,52)|0,i=e|i,s=s|(S()|0),e=n,t[e>>2]=i,t[e+4>>2]=s,e=n+12|0,He(i,s)|0){t[e>>2]=r;return}else{t[e>>2]=-1;return}}function ei(e){e=e|0;var A=0,r=0,n=0,i=0,s=0,o=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=kA(1,0,(n^15)*3|0)|0,A=YA(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,o=t[l>>2]|0,!((n|0)<(o|0)))){for(a=e+12|0,s=n;;){if((s|0)==(o|0)){n=5;break}if(f=(s|0)==(t[a>>2]|0),i=(15-s|0)*3|0,n=wA(A|0,r|0,i|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=kA(1,0,i|0)|0,A=YA(A|0,r|0,f|0,S()|0)|0,r=S()|0,f=e,t[f>>2]=A,t[f+4>>2]=r,(s|0)>(o|0))s=s+-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){o=kA(1,0,i|0)|0,o=YA(A|0,r|0,o|0,S()|0)|0,l=S()|0,f=e,t[f>>2]=o,t[f+4>>2]=l,t[a>>2]=s+-1;return}else if((n|0)==10)return}}function en(e){e=+e;var A=0;return A=e<0?e+6.283185307179586:e,+(e>=6.283185307179586?A+-6.283185307179586:A)}function Dr(e,A){return e=e|0,A=A|0,+ZA(+(+b[e>>3]-+b[A>>3]))<17453292519943298e-27?(A=+ZA(+(+b[e+8>>3]-+b[A+8>>3]))<17453292519943298e-27,A|0):(A=0,A|0)}function Kt(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 pl(e,A){e=e|0,A=A|0;var r=0,n=0,i=0,s=0;return i=+b[A>>3],n=+b[e>>3],s=+se(+((i-n)*.5)),r=+se(+((+b[A+8>>3]-+b[e+8>>3])*.5)),r=s*s+r*(+_e(+i)*+_e(+n)*r),+(+Te(+ +xe(+r),+ +xe(+(1-r)))*2)}function tn(e,A){e=e|0,A=A|0;var r=0,n=0,i=0,s=0;return i=+b[A>>3],n=+b[e>>3],s=+se(+((i-n)*.5)),r=+se(+((+b[A+8>>3]-+b[e+8>>3])*.5)),r=s*s+r*(+_e(+i)*+_e(+n)*r),+(+Te(+ +xe(+r),+ +xe(+(1-r)))*2*6371.007180918475)}function yl(e,A){e=e|0,A=A|0;var r=0,n=0,i=0,s=0;return i=+b[A>>3],n=+b[e>>3],s=+se(+((i-n)*.5)),r=+se(+((+b[A+8>>3]-+b[e+8>>3])*.5)),r=s*s+r*(+_e(+i)*+_e(+n)*r),+(+Te(+ +xe(+r),+ +xe(+(1-r)))*2*6371.007180918475*1e3)}function xl(e,A){e=e|0,A=A|0;var r=0,n=0,i=0,s=0,o=0;return s=+b[A>>3],n=+_e(+s),i=+b[A+8>>3]-+b[e+8>>3],o=n*+se(+i),r=+b[e>>3],+ +Te(+o,+(+se(+s)*+_e(+r)-+_e(+i)*(n*+se(+r))))}function wl(e,A,r,n){e=e|0,A=+A,r=+r,n=n|0;var i=0,s=0,o=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}s=A<0?A+6.283185307179586:A,s=A>=6.283185307179586?s+-6.283185307179586:s;do if(s<1e-16)A=+b[e>>3]+r,b[n>>3]=A,i=n;else{if(i=+ZA(+(s+-3.141592653589793))<1e-16,A=+b[e>>3],i){A=A-r,b[n>>3]=A,i=n;break}if(o=+_e(+r),r=+se(+r),A=o*+se(+A)+ +_e(+s)*(r*+_e(+A)),A=A>1?1:A,A=+h0(+(A<-1?-1:A)),b[n>>3]=A,+ZA(+(A+-1.5707963267948966))<1e-16){b[n>>3]=1.5707963267948966,b[n+8>>3]=0;return}if(+ZA(+(A+1.5707963267948966))<1e-16){b[n>>3]=-1.5707963267948966,b[n+8>>3]=0;return}if(l=1/+_e(+A),s=r*+se(+s)*l,r=+b[e>>3],A=l*((o-+se(+A)*+se(+r))/+_e(+r)),o=s>1?1:s,A=A>1?1:A,A=+b[e+8>>3]+ +Te(+(o<-1?-1:o),+(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(+ZA(+(A+-1.5707963267948966))<1e-16){b[i>>3]=1.5707963267948966,b[n+8>>3]=0;return}if(+ZA(+(A+1.5707963267948966))<1e-16){b[i>>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 Hi(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 vl(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 bl(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 kl(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 xn(e,A){e=e|0,A=A|0;var r=0;return e>>>0>15?(A=4,A|0):(r=G0(7,0,e,((e|0)<0)<<31>>31)|0,r=ht(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 Gi(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=0;return R=+b[A>>3],g=+b[e>>3],a=+se(+((R-g)*.5)),s=+b[A+8>>3],f=+b[e+8>>3],o=+se(+((s-f)*.5)),l=+_e(+g),M=+_e(+R),o=a*a+o*(M*l*o),o=+Te(+ +xe(+o),+ +xe(+(1-o)))*2,a=+b[r>>3],R=+se(+((a-R)*.5)),n=+b[r+8>>3],s=+se(+((n-s)*.5)),i=+_e(+a),s=R*R+s*(M*i*s),s=+Te(+ +xe(+s),+ +xe(+(1-s)))*2,a=+se(+((g-a)*.5)),n=+se(+((f-n)*.5)),n=a*a+n*(l*i*n),n=+Te(+ +xe(+n),+ +xe(+(1-n)))*2,i=(o+s+n)*.5,+(+pt(+ +xe(+(+rt(+(i*.5))*+rt(+((i-o)*.5))*+rt(+((i-s)*.5))*+rt(+((i-n)*.5)))))*4)}function ti(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0,o=0,l=0;if(l=k,k=k+192|0,s=l+168|0,o=l,i=or(e,A,s)|0,i|0)return r=i,k=l,r|0;if(Br(e,A,o)|0&&OA(27795,27190,415,27199),A=t[o>>2]|0,(A|0)>0){if(n=+Gi(o+8|0,o+8+(((A|0)!=1&1)<<4)|0,s)+0,(A|0)!=1){e=1;do i=e,e=e+1|0,n=n+ +Gi(o+8+(i<<4)|0,o+8+(((e|0)%(A|0)|0)<<4)|0,s);while((e|0)<(A|0))}}else n=0;return b[r>>3]=n,r=0,k=l,r|0}function Cl(e,A,r){return e=e|0,A=A|0,r=r|0,e=ti(e,A,r)|0,e|0||(b[r>>3]=+b[r>>3]*6371.007180918475*6371.007180918475),e|0}function El(e,A,r){return e=e|0,A=A|0,r=r|0,e=ti(e,A,r)|0,e|0||(b[r>>3]=+b[r>>3]*6371.007180918475*6371.007180918475*1e3*1e3),e|0}function Sl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0,o=0,l=0,a=0,f=0,g=0;if(l=k,k=k+176|0,o=l,e=ir(e,A,o)|0,e|0)return o=e,k=l,o|0;if(b[r>>3]=0,e=t[o>>2]|0,(e|0)<=1)return o=0,k=l,o|0;A=e+-1|0,e=0,n=+b[o+8>>3],i=+b[o+16>>3],s=0;do e=e+1|0,f=n,n=+b[o+8+(e<<4)>>3],g=+se(+((n-f)*.5)),a=i,i=+b[o+8+(e<<4)+8>>3],a=+se(+((i-a)*.5)),a=g*g+a*(+_e(+n)*+_e(+f)*a),s=s+ +Te(+ +xe(+a),+ +xe(+(1-a)))*2;while((e|0)<(A|0));return b[r>>3]=s,o=0,k=l,o|0}function Ml(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0,o=0,l=0,a=0,f=0,g=0;if(l=k,k=k+176|0,o=l,e=ir(e,A,o)|0,e|0)return o=e,s=+b[r>>3],s=s*6371.007180918475,b[r>>3]=s,k=l,o|0;if(b[r>>3]=0,e=t[o>>2]|0,(e|0)<=1)return o=0,s=0,s=s*6371.007180918475,b[r>>3]=s,k=l,o|0;A=e+-1|0,e=0,n=+b[o+8>>3],i=+b[o+16>>3],s=0;do e=e+1|0,f=n,n=+b[o+8+(e<<4)>>3],g=+se(+((n-f)*.5)),a=i,i=+b[o+8+(e<<4)+8>>3],a=+se(+((i-a)*.5)),a=g*g+a*(+_e(+f)*+_e(+n)*a),s=s+ +Te(+ +xe(+a),+ +xe(+(1-a)))*2;while((e|0)!=(A|0));return b[r>>3]=s,o=0,g=s,g=g*6371.007180918475,b[r>>3]=g,k=l,o|0}function Bl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0,o=0,l=0,a=0,f=0,g=0;if(l=k,k=k+176|0,o=l,e=ir(e,A,o)|0,e|0)return o=e,s=+b[r>>3],s=s*6371.007180918475,s=s*1e3,b[r>>3]=s,k=l,o|0;if(b[r>>3]=0,e=t[o>>2]|0,(e|0)<=1)return o=0,s=0,s=s*6371.007180918475,s=s*1e3,b[r>>3]=s,k=l,o|0;A=e+-1|0,e=0,n=+b[o+8>>3],i=+b[o+16>>3],s=0;do e=e+1|0,f=n,n=+b[o+8+(e<<4)>>3],g=+se(+((n-f)*.5)),a=i,i=+b[o+8+(e<<4)+8>>3],a=+se(+((i-a)*.5)),a=g*g+a*(+_e(+f)*+_e(+n)*a),s=s+ +Te(+ +xe(+a),+ +xe(+(1-a)))*2;while((e|0)!=(A|0));return b[r>>3]=s,o=0,g=s,g=g*6371.007180918475,g=g*1e3,b[r>>3]=g,k=l,o|0}function Dl(e){e=e|0;var A=0,r=0,n=0;return A=Gt(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 _l(e,A){e=e|0,A=A|0;var r=0,n=0;return n=w0(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 Ui(e){e=e|0;var A=0,r=0,n=0,i=0;if(e)for(n=1;;){if(A=t[e>>2]|0,A|0)do{if(r=t[A>>2]|0,r|0)do i=r,r=t[r+16>>2]|0,qA(i);while((r|0)!=0);i=A,A=t[A+8>>2]|0,qA(i)}while((A|0)!=0);if(A=e,e=t[e+8>>2]|0,n||qA(A),e)n=0;else break}}function Tl(e){e=e|0;var A=0,r=0,n=0,i=0,s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=0,I=0,N=0,G=0,W=0,nA=0,q=0,$=0,U=0,SA=0,zA=0,QA=0,ce=0,de=0,Se=0,ne=0,HA=0,EA=0,ve=0,Ye=0,me=0;if(i=e+8|0,t[i>>2]|0)return me=1,me|0;if(n=t[e>>2]|0,!n)return me=0,me|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 me=0,me|0;ve=w0(r<<2)|0,ve||OA(27396,27235,317,27415),EA=w0(r<<5)|0,EA||OA(27437,27235,321,27415),t[e>>2]=0,zA=e+4|0,t[zA>>2]=0,t[i>>2]=0,r=0,HA=0,SA=0,M=0;A:for(;;){if(g=t[n>>2]|0,g){s=0,o=g;do{if(a=+b[o+8>>3],A=o,o=t[o+16>>2]|0,f=(o|0)==0,i=f?g:o,l=+b[i+8>>3],+ZA(+(a-l))>3.141592653589793){me=14;break}s=s+(l-a)*(+b[A>>3]+ +b[i>>3])}while(!f);if((me|0)==14){me=0,s=0,A=g;do U=+b[A+8>>3],ne=A+16|0,Se=t[ne>>2]|0,Se=(Se|0)==0?g:Se,$=+b[Se+8>>3],s=s+(+b[A>>3]+ +b[Se>>3])*(($<0?$+6.283185307179586:$)-(U<0?U+6.283185307179586:U)),A=t[((A|0)==0?n:ne)>>2]|0;while((A|0)!=0)}s>0?(t[ve+(HA<<2)>>2]=n,HA=HA+1|0,i=SA,A=M):me=19}else me=19;if((me|0)==19){me=0;do if(r){if(A=r+8|0,t[A>>2]|0){me=21;break A}if(r=Gt(1,12)|0,!r){me=23;break A}t[A>>2]=r,i=r+4|0,o=r,A=M}else if(M){i=zA,o=M+8|0,A=n,r=e;break}else if(t[e>>2]|0){me=27;break A}else{i=zA,o=e,A=n,r=e;break}while(!1);if(t[o>>2]=n,t[i>>2]=n,o=EA+(SA<<5)|0,f=t[n>>2]|0,f){for(g=EA+(SA<<5)+8|0,b[g>>3]=17976931348623157e292,M=EA+(SA<<5)+24|0,b[M>>3]=17976931348623157e292,b[o>>3]=-17976931348623157e292,R=EA+(SA<<5)+16|0,b[R>>3]=-17976931348623157e292,nA=17976931348623157e292,q=-17976931348623157e292,i=0,I=f,a=17976931348623157e292,G=17976931348623157e292,W=-17976931348623157e292,l=-17976931348623157e292;s=+b[I>>3],U=+b[I+8>>3],I=t[I+16>>2]|0,N=(I|0)==0,$=+b[(N?f:I)+8>>3],s>3]=s,a=s),U>3]=U,G=U),s>W?b[o>>3]=s:s=W,U>l&&(b[R>>3]=U,l=U),nA=U>0&Uq?U:q,i=i|+ZA(+(U-$))>3.141592653589793,!N;)W=s;i&&(b[R>>3]=q,b[M>>3]=nA)}else t[o>>2]=0,t[o+4>>2]=0,t[o+8>>2]=0,t[o+12>>2]=0,t[o+16>>2]=0,t[o+20>>2]=0,t[o+24>>2]=0,t[o+28>>2]=0;i=SA+1|0}if(ne=n+8|0,n=t[ne>>2]|0,t[ne>>2]=0,n)SA=i,M=A;else{me=45;break}}if((me|0)==21)OA(27213,27235,35,27247);else if((me|0)==23)OA(27267,27235,37,27247);else if((me|0)==27)OA(27310,27235,61,27333);else if((me|0)==45){A:do if((HA|0)>0){for(ne=(i|0)==0,de=i<<2,Se=(e|0)==0,ce=0,A=0;;){if(QA=t[ve+(ce<<2)>>2]|0,ne)me=73;else{if(SA=w0(de)|0,!SA){me=50;break}if(zA=w0(de)|0,!zA){me=52;break}e:do if(Se)r=0;else{for(i=0,r=0,o=e;n=EA+(i<<5)|0,Vi(t[o>>2]|0,n,t[QA>>2]|0)|0?(t[SA+(r<<2)>>2]=o,t[zA+(r<<2)>>2]=n,N=r+1|0):N=r,o=t[o+8>>2]|0,o;)i=i+1|0,r=N;if((N|0)>0)if(n=t[SA>>2]|0,(N|0)==1)r=n;else for(R=0,I=-1,r=n,M=n;;){for(f=t[M>>2]|0,n=0,o=0;i=t[t[SA+(o<<2)>>2]>>2]|0,(i|0)==(f|0)?g=n:g=n+((Vi(i,t[zA+(o<<2)>>2]|0,t[f>>2]|0)|0)&1)|0,o=o+1|0,(o|0)!=(N|0);)n=g;if(i=(g|0)>(I|0),r=i?M:r,n=R+1|0,(n|0)==(N|0))break e;R=n,I=i?g:I,M=t[SA+(n<<2)>>2]|0}else r=0}while(!1);if(qA(SA),qA(zA),r){if(i=r+4|0,n=t[i>>2]|0,n)r=n+8|0;else if(t[r>>2]|0){me=70;break}t[r>>2]=QA,t[i>>2]=QA}else me=73}if((me|0)==73){if(me=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(ce=ce+1|0,(ce|0)>=(HA|0)){Ye=A;break A}}(me|0)==50?OA(27452,27235,249,27471):(me|0)==52?OA(27490,27235,252,27471):(me|0)==70&&OA(27310,27235,61,27333)}else Ye=0;while(!1);return qA(ve),qA(EA),me=Ye,me|0}return 0}function Vi(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0,o=0,l=0,a=0,f=0,g=0;if(!(p0(A,r)|0)||(A=zt(A)|0,n=+b[r>>3],i=+b[r+8>>3],i=A&i<0?i+6.283185307179586:i,e=t[e>>2]|0,!e))return e=0,e|0;if(A){A=0,f=i,r=e;A:for(;;){for(;o=+b[r>>3],i=+b[r+8>>3],r=r+16|0,g=t[r>>2]|0,g=(g|0)==0?e:g,s=+b[g>>3],l=+b[g+8>>3],o>s?(a=o,o=l):(a=s,s=o,o=i,i=l),n=n==s|n==a?n+2220446049250313e-31:n,!!(na);)if(r=t[r>>2]|0,!r){r=22;break A}if(l=o<0?o+6.283185307179586:o,o=i<0?i+6.283185307179586:i,f=l==f|o==f?f+-2220446049250313e-31:f,a=l+(o-l)*((n-s)/(a-s)),(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=i,r=e;A:for(;;){for(;o=+b[r>>3],i=+b[r+8>>3],r=r+16|0,g=t[r>>2]|0,g=(g|0)==0?e:g,s=+b[g>>3],l=+b[g+8>>3],o>s?(a=o,o=l):(a=s,s=o,o=i,i=l),n=n==s|n==a?n+2220446049250313e-31:n,!!(na);)if(r=t[r>>2]|0,!r){r=22;break A}if(f=o==f|i==f?f+-2220446049250313e-31:f,o+(i-o)*((n-s)/(a-s))>f&&(A=A^1),r=t[r>>2]|0,!r){r=22;break}}if((r|0)==22)return A|0}return 0}function R0(e,A,r,n,i){e=e|0,A=A|0,r=r|0,n=n|0,i=i|0;var s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=0,I=0,N=0,G=0,W=0,nA=0,q=0;if(q=k,k=k+32|0,nA=q+16|0,W=q,s=wA(e|0,A|0,52)|0,S()|0,s=s&15,I=wA(r|0,n|0,52)|0,S()|0,(s|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,g=wA(r|0,n|0,45)|0,S()|0,g=g&127,f>>>0>121|g>>>0>121)return nA=5,k=q,nA|0;if(I=(f|0)!=(g|0),I){if(l=rr(f,g)|0,(l|0)==7)return nA=1,k=q,nA|0;a=rr(g,f)|0,(a|0)==7?OA(27514,27538,161,27548):(N=l,o=a)}else N=0,o=0;M=je(f)|0,R=je(g)|0,t[nA>>2]=0,t[nA+4>>2]=0,t[nA+8>>2]=0,t[nA+12>>2]=0;do if(N){if(g=t[4272+(f*28|0)+(N<<2)>>2]|0,l=(g|0)>0,R)if(l){f=0,a=r,l=n;do a=cl(a,l)|0,l=S()|0,o=Yt(o)|0,(o|0)==1&&(o=Yt(1)|0),f=f+1|0;while((f|0)!=(g|0));g=o,f=a,a=l}else g=o,f=r,a=n;else if(l){f=0,a=r,l=n;do a=$n(a,l)|0,l=S()|0,o=Yt(o)|0,f=f+1|0;while((f|0)!=(g|0));g=o,f=a,a=l}else g=o,f=r,a=n;if(Jn(f,a,nA)|0,I||OA(27563,27538,191,27548),l=(M|0)!=0,o=(R|0)!=0,l&o&&OA(27590,27538,192,27548),l){if(o=Ht(e,A)|0,(o|0)==7){s=5;break}if(xA[22e3+(o*7|0)+N>>0]|0){s=1;break}a=t[21168+(o*28|0)+(N<<2)>>2]|0,f=a}else if(o){if(o=Ht(f,a)|0,(o|0)==7){s=5;break}if(xA[22e3+(o*7|0)+g>>0]|0){s=1;break}f=0,a=t[21168+(g*28|0)+(o<<2)>>2]|0}else f=0,a=0;if((f|a|0)<0)s=5;else{if((a|0)>0){l=nA+4|0,o=0;do j0(l),o=o+1|0;while((o|0)!=(a|0))}if(t[W>>2]=0,t[W+4>>2]=0,t[W+8>>2]=0,dn(W,N),s|0)for(;t0(s)|0?vr(W):Vt(W),(s|0)>1;)s=s+-1|0;if((f|0)>0){s=0;do j0(W),s=s+1|0;while((s|0)!=(f|0))}G=nA+4|0,ze(G,W,G),oe(G),G=51}}else if(Jn(r,n,nA)|0,(M|0)!=0&(R|0)!=0)if((g|0)!=(f|0)&&OA(27621,27538,261,27548),o=Ht(e,A)|0,s=Ht(r,n)|0,(o|0)==7|(s|0)==7)s=5;else if(xA[22e3+(o*7|0)+s>>0]|0)s=1;else if(o=t[21168+(o*28|0)+(s<<2)>>2]|0,(o|0)>0){l=nA+4|0,s=0;do j0(l),s=s+1|0;while((s|0)!=(o|0));G=51}else G=51;else G=51;while(!1);return(G|0)==51&&(s=nA+4|0,t[i>>2]=t[s>>2],t[i+4>>2]=t[s+4>>2],t[i+8>>2]=t[s+8>>2],s=0),nA=s,k=q,nA|0}function Wi(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=0,I=0,N=0,G=0,W=0,nA=0,q=0,$=0;if(G=k,k=k+48|0,f=G+36|0,o=G+24|0,l=G+12|0,a=G,i=wA(e|0,A|0,52)|0,S()|0,i=i&15,R=wA(e|0,A|0,45)|0,S()|0,R=R&127,R>>>0>121)return n=5,k=G,n|0;if(g=je(R)|0,kA(i|0,0,52)|0,W=S()|0|134225919,s=n,t[s>>2]=-1,t[s+4>>2]=W,!i)return i=tt(r)|0,(i|0)==7||(i=tr(R,i)|0,(i|0)==127)?(W=1,k=G,W|0):(I=kA(i|0,0,45)|0,N=S()|0,R=n,N=t[R+4>>2]&-1040385|N,W=n,t[W>>2]=t[R>>2]|I,t[W+4>>2]=N,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=i;;){if(s=r,r=r+-1|0,t[o>>2]=t[f>>2],t[o+4>>2]=t[f+4>>2],t[o+8>>2]=t[f+8>>2],t0(s)|0){if(i=Dt(f)|0,i|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],vr(l)}else{if(i=hn(f)|0,i|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],Vt(l)}if(wt(o,l,a),oe(a),i=n,q=t[i>>2]|0,i=t[i+4>>2]|0,$=(15-s|0)*3|0,nA=kA(7,0,$|0)|0,i=i&~(S()|0),$=kA(tt(a)|0,0,$|0)|0,i=S()|0|i,W=n,t[W>>2]=$|q&~nA,t[W+4>>2]=i,(s|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=tt(f)|0,i=tr(R,r)|0,(i|0)==127?a=0:a=je(i)|0;e:do if(r){if(g){if(i=Ht(e,A)|0,(i|0)==7){i=5;break A}if(s=t[21376+(i*28|0)+(r<<2)>>2]|0,(s|0)>0){i=r,r=0;do i=Wt(i)|0,r=r+1|0;while((r|0)!=(s|0))}else i=r;if((i|0)==1){i=9;break A}r=tr(R,i)|0,(r|0)==127&&OA(27648,27538,411,27678),je(r)|0?OA(27693,27538,412,27678):(N=r,I=s,M=i)}else N=i,I=0,M=r;if(l=t[4272+(R*28|0)+(M<<2)>>2]|0,(l|0)<=-1&&OA(27724,27538,419,27678),!a){if((I|0)<0){i=5;break A}if(I|0){s=n,i=0,r=t[s>>2]|0,s=t[s+4>>2]|0;do r=sr(r,s)|0,s=S()|0,$=n,t[$>>2]=r,t[$+4>>2]=s,i=i+1|0;while((i|0)<(I|0))}if((l|0)<=0){i=N,r=58;break}for(s=n,i=0,r=t[s>>2]|0,s=t[s+4>>2]|0;;)if(r=sr(r,s)|0,s=S()|0,$=n,t[$>>2]=r,t[$+4>>2]=s,i=i+1|0,(i|0)==(l|0)){i=N,r=58;break e}}if(o=rr(N,R)|0,(o|0)==7&&OA(27514,27538,428,27678),i=n,r=t[i>>2]|0,i=t[i+4>>2]|0,(l|0)>0){s=0;do r=sr(r,i)|0,i=S()|0,$=n,t[$>>2]=r,t[$+4>>2]=i,s=s+1|0;while((s|0)!=(l|0))}if(i=Ht(r,i)|0,(i|0)==7&&OA(27795,27538,440,27678),r=Bt(N)|0,r=t[(r?21792:21584)+(o*28|0)+(i<<2)>>2]|0,(r|0)<0&&OA(27795,27538,454,27678),!r)i=N,r=58;else{o=n,i=0,s=t[o>>2]|0,o=t[o+4>>2]|0;do s=Zn(s,o)|0,o=S()|0,$=n,t[$>>2]=s,t[$+4>>2]=o,i=i+1|0;while((i|0)<(r|0));i=N,r=58}}else if((g|0)!=0&(a|0)!=0){if(r=Ht(e,A)|0,s=n,s=Ht(t[s>>2]|0,t[s+4>>2]|0)|0,(r|0)==7|(s|0)==7){i=5;break A}if(s=t[21376+(r*28|0)+(s<<2)>>2]|0,(s|0)<0){i=5;break A}if(!s)r=59;else{l=n,r=0,o=t[l>>2]|0,l=t[l+4>>2]|0;do o=sr(o,l)|0,l=S()|0,$=n,t[$>>2]=o,t[$+4>>2]=l,r=r+1|0;while((r|0)<(s|0));r=58}}else r=58;while(!1);if((r|0)==58&&a&&(r=59),(r|0)==59&&($=n,(Ht(t[$>>2]|0,t[$+4>>2]|0)|0)==1)){i=9;break}$=n,nA=t[$>>2]|0,$=t[$+4>>2]&-1040385,q=kA(i|0,0,45)|0,$=$|(S()|0),i=n,t[i>>2]=nA|q,t[i+4>>2]=$,i=0}else i=1;while(!1);return $=i,k=G,$|0}function jl(e,A,r,n,i,s){e=e|0,A=A|0,r=r|0,n=n|0,i=i|0,s=s|0;var o=0,l=0;return l=k,k=k+16|0,o=l,i?e=15:(e=R0(e,A,r,n,o)|0,e||(Zr(o,s),e=0)),k=l,e|0}function Rl(e,A,r,n,i){e=e|0,A=A|0,r=r|0,n=n|0,i=i|0;var s=0,o=0;return o=k,k=k+16|0,s=o,n?r=15:(r=_t(r,s)|0,r||(r=Wi(e,A,s,i)|0)),k=o,r|0}function Il(e,A,r,n,i){e=e|0,A=A|0,r=r|0,n=n|0,i=i|0;var s=0,o=0,l=0,a=0;return a=k,k=k+32|0,o=a+12|0,l=a,s=R0(e,A,e,A,o)|0,s|0?(l=s,k=a,l|0):(e=R0(e,A,r,n,l)|0,e|0?(l=e,k=a,l|0):(o=kr(o,l)|0,l=i,t[l>>2]=o,t[l+4>>2]=((o|0)<0)<<31>>31,l=0,k=a,l|0))}function Ll(e,A,r,n,i){e=e|0,A=A|0,r=r|0,n=n|0,i=i|0;var s=0,o=0,l=0,a=0;return a=k,k=k+32|0,o=a+12|0,l=a,s=R0(e,A,e,A,o)|0,!s&&(s=R0(e,A,r,n,l)|0,!s)?(n=kr(o,l)|0,n=YA(n|0,((n|0)<0)<<31>>31|0,1,0)|0,o=S()|0,l=i,t[l>>2]=n,t[l+4>>2]=o,l=0,k=a,l|0):(l=s,k=a,l|0)}function Nl(e,A,r,n,i){e=e|0,A=A|0,r=r|0,n=n|0,i=i|0;var s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=0,I=0,N=0,G=0,W=0,nA=0,q=0,$=0,U=0,SA=0,zA=0,QA=0,ce=0;if(QA=k,k=k+48|0,SA=QA+24|0,o=QA+12|0,zA=QA,s=R0(e,A,e,A,SA)|0,!s&&(s=R0(e,A,r,n,o)|0,!s)){$=kr(SA,o)|0,U=(($|0)<0)<<31>>31,t[SA>>2]=0,t[SA+4>>2]=0,t[SA+8>>2]=0,t[o>>2]=0,t[o+4>>2]=0,t[o+8>>2]=0,R0(e,A,e,A,SA)|0&&OA(27795,27538,692,27747),R0(e,A,r,n,o)|0&&OA(27795,27538,697,27747),$r(SA),$r(o),g=($|0)==0?0:1/+($|0),r=t[SA>>2]|0,G=g*+((t[o>>2]|0)-r|0),W=SA+4|0,n=t[W>>2]|0,nA=g*+((t[o+4>>2]|0)-n|0),q=SA+8|0,s=t[q>>2]|0,g=g*+((t[o+8>>2]|0)-s|0),t[zA>>2]=r,M=zA+4|0,t[M>>2]=n,R=zA+8|0,t[R>>2]=s;A:do if(($|0)<0)s=0;else for(I=0,N=0;;){a=+(N>>>0)+4294967296*+(I|0),ce=G*a+ +(r|0),l=nA*a+ +(n|0),a=g*a+ +(s|0),r=~~+kn(+ce),o=~~+kn(+l),s=~~+kn(+a),ce=+ZA(+(+(r|0)-ce)),l=+ZA(+(+(o|0)-l)),a=+ZA(+(+(s|0)-a));do if(ce>l&ce>a)r=0-(o+s)|0,n=o;else if(f=0-r|0,l>a){n=f-s|0;break}else{n=o,s=f-o|0;break}while(!1);if(t[zA>>2]=r,t[M>>2]=n,t[R>>2]=s,qr(zA),s=Wi(e,A,zA,i+(N<<3)|0)|0,s|0)break A;if(!((I|0)<(U|0)|(I|0)==(U|0)&N>>>0<$>>>0)){s=0;break A}r=YA(N|0,I|0,1,0)|0,n=S()|0,I=n,N=r,r=t[SA>>2]|0,n=t[W>>2]|0,s=t[q>>2]|0}while(!1);return zA=s,k=QA,zA|0}return zA=s,k=QA,zA|0}function G0(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0,o=0;if((r|0)==0&(n|0)==0)return i=0,s=1,$A(i|0),s|0;s=e,i=A,e=1,A=0;do o=(r&1|0)==0&!0,e=ht((o?1:s)|0,(o?0:i)|0,e|0,A|0)|0,A=S()|0,r=is(r|0,n|0,1)|0,n=S()|0,s=ht(s|0,i|0,s|0,i|0)|0,i=S()|0;while(!((r|0)==0&(n|0)==0));return $A(A|0),e|0}function ri(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0,o=0,l=0,a=0,f=0,g=0;l=k,k=k+16|0,s=l,o=wA(e|0,A|0,52)|0,S()|0,o=o&15;do if(o){if(i=or(e,A,s)|0,!i){f=+b[s>>3],a=1/+_e(+f),g=+b[25968+(o<<3)>>3],b[r>>3]=f+g,b[r+8>>3]=f-g,f=+b[s+8>>3],a=g*a,b[r+16>>3]=a+f,b[r+24>>3]=f-a;break}return o=i,k=l,o|0}else{if(i=wA(e|0,A|0,45)|0,S()|0,i=i&127,i>>>0>121)return o=5,k=l,o|0;s=22064+(i<<5)|0,t[r>>2]=t[s>>2],t[r+4>>2]=t[s+4>>2],t[r+8>>2]=t[s+8>>2],t[r+12>>2]=t[s+12>>2],t[r+16>>2]=t[s+16>>2],t[r+20>>2]=t[s+20>>2],t[r+24>>2]=t[s+24>>2],t[r+28>>2]=t[s+28>>2];break}while(!1);return LA(r,n?1.4:1.1),n=26096+(o<<3)|0,(t[n>>2]|0)==(e|0)&&(t[n+4>>2]|0)==(A|0)&&(b[r>>3]=1.5707963267948966),o=26224+(o<<3)|0,(t[o>>2]|0)==(e|0)&&(t[o+4>>2]|0)==(A|0)&&(b[r+8>>3]=-1.5707963267948966),+b[r>>3]!=1.5707963267948966&&+b[r+8>>3]!=-1.5707963267948966?(o=0,k=l,o|0):(b[r+16>>3]=3.141592653589793,b[r+24>>3]=-3.141592653589793,o=0,k=l,o|0)}function Fl(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0,o=0,l=0,a=0,f=0,g=0;f=k,k=k+48|0,o=f+32|0,s=f+40|0,l=f,jt(o,0,0,0),a=t[o>>2]|0,o=t[o+4>>2]|0;do if(r>>>0<=15){if(i=nn(n)|0,i|0){n=l,t[n>>2]=0,t[n+4>>2]=0,t[l+8>>2]=i,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[s>>0]|0,xA[a+1>>0]=xA[s+1>>0]|0,xA[a+2>>0]=xA[s+2>>0]|0;break}if(i=Gt((t[A+8>>2]|0)+1|0,32)|0,i){ni(A,i),g=l,t[g>>2]=a,t[g+4>>2]=o,t[l+8>>2]=0,t[l+12>>2]=r,t[l+16>>2]=n,t[l+20>>2]=A,t[l+24>>2]=i,xA[l+28>>0]=0,a=l+29|0,xA[a>>0]=xA[s>>0]|0,xA[a+1>>0]=xA[s+1>>0]|0,xA[a+2>>0]=xA[s+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[s>>0]|0,xA[a+1>>0]=xA[s+1>>0]|0,xA[a+2>>0]=xA[s+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,g=l+29|0,t[a>>2]=0,t[a+4>>2]=0,t[a+8>>2]=0,xA[a+12>>0]=0,xA[g>>0]=xA[s>>0]|0,xA[g+1>>0]=xA[s+1>>0]|0,xA[g+2>>0]=xA[s+2>>0]|0;while(!1);wn(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 wn(e){e=e|0;var A=0,r=0,n=0,i=0,s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=0,I=0,N=0,G=0,W=0,nA=0,q=0,$=0,U=0;if(U=k,k=k+336|0,I=U+168|0,N=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=Yi(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,i=A&15;A:do if((r|0)==0&(n|0)==0)nA=e+24|0;else{G=e+12|0,M=(i|0)==3,g=A&255,a=(i|1|0)==3,R=e+24|0,f=(i+-1|0)>>>0<3,o=(i|2|0)==3,l=N+8|0;e:for(;;){if(s=wA(r|0,n|0,52)|0,S()|0,s=s&15,(s|0)==(t[G>>2]|0)){switch(g&15){case 0:case 2:case 3:{if(i=or(r,n,I)|0,i|0){W=15;break e}if(ii(t[$>>2]|0,t[R>>2]|0,I)|0){W=19;break e}break}}if(a&&(i=t[(t[$>>2]|0)+4>>2]|0,t[I>>2]=t[i>>2],t[I+4>>2]=t[i+4>>2],t[I+8>>2]=t[i+8>>2],t[I+12>>2]=t[i+12>>2],p0(26832,I)|0)){if(qn(t[(t[$>>2]|0)+4>>2]|0,s,N)|0){W=25;break}if(i=N,(t[i>>2]|0)==(r|0)&&(t[i+4>>2]|0)==(n|0)){W=29;break}}if(f){if(i=Br(r,n,I)|0,i|0){W=32;break}if(ri(r,n,N,0)|0){W=36;break}if(o&&Zi(t[$>>2]|0,t[R>>2]|0,I,N)|0){W=42;break}if(a&&$i(t[$>>2]|0,t[R>>2]|0,I,N)|0){W=42;break}}if(M){if(A=ri(r,n,I,1)|0,i=t[R>>2]|0,A|0){W=45;break}if(Fe(i,I)|0){if(H(N,I),T0(I,t[R>>2]|0)|0){W=53;break}if(ii(t[$>>2]|0,t[R>>2]|0,l)|0){W=53;break}if($i(t[$>>2]|0,t[R>>2]|0,N,I)|0){W=53;break}}}}do if((s|0)<(t[G>>2]|0)){if(A=ri(r,n,I,1)|0,i=t[R>>2]|0,A|0){W=58;break e}if(!(Fe(i,I)|0)){W=73;break}if(T0(t[R>>2]|0,I)|0&&(H(N,I),Zi(t[$>>2]|0,t[R>>2]|0,N,I)|0)){W=65;break e}if(r=Qi(r,n,s+1|0,N)|0,r|0){W=67;break e}n=N,r=t[n>>2]|0,n=t[n+4>>2]|0}else W=73;while(!1);if((W|0)==73&&(W=0,r=Yi(r,n)|0,n=S()|0),(r|0)==0&(n|0)==0){nA=R;break A}}switch(W|0){case 15:{A=t[R>>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[R>>2]=0,t[e+8>>2]=i,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[R>>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[R>>2]=0,t[e+8>>2]=i,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:{i|0&&qA(i),W=e,t[W>>2]=0,t[W+4>>2]=0,t[$>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[R>>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:{i|0&&qA(i),W=e,t[W>>2]=0,t[W+4>>2]=0,t[$>>2]=0,t[G>>2]=-1,t[q>>2]=0,t[R>>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[R>>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[R>>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 Yi(e,A){e=e|0,A=A|0;var r=0,n=0,i=0,s=0,o=0,l=0,a=0,f=0,g=0,M=0;M=k,k=k+16|0,g=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=kA(n+4095|0,0,52)|0,i=S()|0|A&-15728641,s=(15-n|0)*3|0,o=kA(7,0,s|0)|0,l=S()|0,r=r|e|o,i=i|l,a=wA(e|0,A|0,s|0)|0,S()|0,a=a&7,n=n+-1|0,!(a>>>0<6);)if(n)A=i,e=r;else{f=4;break}if((f|0)==4){r=wA(r|0,i|0,45)|0,S()|0;break}return g=(a|0)==0&(He(r,i)|0)!=0,g=kA((g?2:1)+a|0,0,s|0)|0,f=S()|0|A&~l,g=g|e&~o,$A(f|0),k=M,g|0}while(!1);return r=r&127,r>>>0>120?(f=0,g=0,$A(f|0),k=M,g|0):(jt(g,0,r+1|0,0),f=t[g+4>>2]|0,g=t[g>>2]|0,$A(f|0),k=M,g|0)}function Pl(e,A,r,n,i,s){e=e|0,A=A|0,r=r|0,n=n|0,i=i|0,s=s|0;var o=0,l=0,a=0,f=0,g=0,M=0,R=0,I=0,N=0,G=0,W=0;W=k,k=k+160|0,M=W+80|0,l=W+64|0,R=W+112|0,G=W,Fl(M,e,A,r),f=M,Ai(l,t[f>>2]|0,t[f+4>>2]|0,A),f=l,a=t[f>>2]|0,f=t[f+4>>2]|0,o=t[M+8>>2]|0,I=R+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]=o,e=G+12|0,A=R,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(R=G+48|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],(a|0)==0&(f|0)==0)return G=o,k=W,G|0;r=G+16|0,g=G+24|0,M=G+28|0,o=0,l=0,A=a,e=f;do{if(!((o|0)<(i|0)|(o|0)==(i|0)&l>>>0>>0)){N=4;break}if(f=l,l=YA(l|0,o|0,1,0)|0,o=S()|0,f=s+(f<<3)|0,t[f>>2]=A,t[f+4>>2]=e,ei(R),e=R,A=t[e>>2]|0,e=t[e+4>>2]|0,(A|0)==0&(e|0)==0){if(wn(r),A=r,e=t[A>>2]|0,A=t[A+4>>2]|0,(e|0)==0&(A|0)==0){N=10;break}zi(e,A,t[M>>2]|0,R),e=R,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(N|0)==4?(e=G+40|0,A=t[e>>2]|0,A|0&&qA(A),N=G+16|0,t[N>>2]=0,t[N+4>>2]=0,t[g>>2]=0,t[G+36>>2]=0,t[M>>2]=-1,t[G+32>>2]=0,t[e>>2]=0,zi(0,0,0,R),t[G>>2]=0,t[G+4>>2]=0,t[I>>2]=0,G=14,k=W,G|0):((N|0)==10&&(t[G>>2]=0,t[G+4>>2]=0,t[I>>2]=t[g>>2]),G=t[I>>2]|0,k=W,G|0)}function Ql(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=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 g=n,t[g>>2]=0,t[g+4>>2]=0,g=0,k=M,g|0;jt(a,0,0,0),o=a,i=t[o>>2]|0,o=t[o+4>>2]|0;do if(A>>>0>15)g=f,t[g>>2]=0,t[g+4>>2]=0,t[f+8>>2]=4,t[f+12>>2]=-1,g=f+16|0,r=f+29|0,t[g>>2]=0,t[g+4>>2]=0,t[g+8>>2]=0,xA[g+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,g=9;else{if(r=nn(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,g=f+29|0,t[a>>2]=0,t[a+4>>2]=0,t[a+8>>2]=0,xA[a+12>>0]=0,xA[g>>0]=xA[l>>0]|0,xA[g+1>>0]=xA[l+1>>0]|0,xA[g+2>>0]=xA[l+2>>0]|0,g=9;break}if(r=Gt((t[e+8>>2]|0)+1|0,32)|0,!r){g=f,t[g>>2]=0,t[g+4>>2]=0,t[f+8>>2]=13,t[f+12>>2]=-1,g=f+16|0,r=f+29|0,t[g>>2]=0,t[g+4>>2]=0,t[g+8>>2]=0,xA[g+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,g=9;break}ni(e,r),I=f,t[I>>2]=i,t[I+4>>2]=o,o=f+8|0,t[o>>2]=0,t[f+12>>2]=A,t[f+20>>2]=e,t[f+24>>2]=r,xA[f+28>>0]=0,i=f+29|0,xA[i>>0]=xA[l>>0]|0,xA[i+1>>0]=xA[l+1>>0]|0,xA[i+2>>0]=xA[l+2>>0]|0,t[f+16>>2]=3,R=+nr(r),R=R*+Wr(r),s=+ZA(+ +b[r>>3]),s=R/+_e(+ +bn(+s,+ +ZA(+ +b[r+8>>3])))*6371.007180918475*6371.007180918475,i=f+12|0,r=t[i>>2]|0;A:do if((r|0)>0)do{if(Hi(r+-1|0,a)|0,!(s/+b[a>>3]>10))break A;I=t[i>>2]|0,r=I+-1|0,t[i>>2]=r}while((I|0)>1);while(!1);if(wn(f),i=n,t[i>>2]=0,t[i+4>>2]=0,i=f,r=t[i>>2]|0,i=t[i+4>>2]|0,!((r|0)==0&(i|0)==0))do x0(r,i,A,a)|0,l=a,e=n,l=YA(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,wn(f),I=f,r=t[I>>2]|0,i=t[I+4>>2]|0;while(!((r|0)==0&(i|0)==0));r=t[o>>2]|0}while(!1);return I=r,k=M,I|0}function rn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=0;if(!(p0(A,r)|0)||(A=zt(A)|0,n=+b[r>>3],i=+b[r+8>>3],i=A&i<0?i+6.283185307179586:i,R=t[e>>2]|0,(R|0)<=0))return R=0,R|0;if(M=t[e+4>>2]|0,A){A=0,g=i,r=-1,e=0;A:for(;;){for(f=e;o=+b[M+(f<<4)>>3],i=+b[M+(f<<4)+8>>3],e=(r+2|0)%(R|0)|0,s=+b[M+(e<<4)>>3],l=+b[M+(e<<4)+8>>3],o>s?(a=o,o=l):(a=s,s=o,o=i,i=l),n=n==s|n==a?n+2220446049250313e-31:n,!!(na);)if(r=f+1|0,(r|0)>=(R|0)){r=22;break A}else e=f,f=r,r=e;if(l=o<0?o+6.283185307179586:o,o=i<0?i+6.283185307179586:i,g=l==g|o==g?g+-2220446049250313e-31:g,a=l+(o-l)*((n-s)/(a-s)),(a<0?a+6.283185307179586:a)>g&&(A=A^1),e=f+1|0,(e|0)>=(R|0)){r=22;break}else r=f}if((r|0)==22)return A|0}else{A=0,g=i,r=-1,e=0;A:for(;;){for(f=e;o=+b[M+(f<<4)>>3],i=+b[M+(f<<4)+8>>3],e=(r+2|0)%(R|0)|0,s=+b[M+(e<<4)>>3],l=+b[M+(e<<4)+8>>3],o>s?(a=o,o=l):(a=s,s=o,o=i,i=l),n=n==s|n==a?n+2220446049250313e-31:n,!!(na);)if(r=f+1|0,(r|0)>=(R|0)){r=22;break A}else e=f,f=r,r=e;if(g=o==g|i==g?g+-2220446049250313e-31:g,o+(i-o)*((n-s)/(a-s))>g&&(A=A^1),e=f+1|0,(e|0)>=(R|0)){r=22;break}else r=f}if((r|0)==22)return A|0}return 0}function Ki(e,A){e=e|0,A=A|0;var r=0,n=0,i=0,s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=0,I=0,N=0,G=0,W=0,nA=0,q=0;if(N=t[e>>2]|0,!N){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,!((N|0)<=0)){for(R=t[e+4>>2]|0,f=17976931348623157e292,g=-17976931348623157e292,M=0,e=-1,s=17976931348623157e292,o=17976931348623157e292,a=-17976931348623157e292,n=-17976931348623157e292,I=0;r=+b[R+(I<<4)>>3],l=+b[R+(I<<4)+8>>3],e=e+2|0,i=+b[R+(((e|0)==(N|0)?0:e)<<4)+8>>3],r>3]=r,s=r),l>3]=l,o=l),r>a?b[A>>3]=r:r=a,l>n&&(b[nA>>3]=l,n=l),f=l>0&lg?l:g,M=M|+ZA(+(l-i))>3.141592653589793,e=I+1|0,(e|0)!=(N|0);)q=I,a=r,I=e,e=q;M&&(b[nA>>3]=g,b[W>>3]=f)}}function nn(e){return e=e|0,(e>>>0<4?0:15)|0}function ni(e,A){e=e|0,A=A|0;var r=0,n=0,i=0,s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=0,I=0,N=0,G=0,W=0,nA=0,q=0,$=0,U=0,SA=0,zA=0,QA=0;if(N=t[e>>2]|0,N){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,(N|0)>0){for(i=t[e+4>>2]|0,R=17976931348623157e292,I=-17976931348623157e292,n=0,r=-1,a=17976931348623157e292,f=17976931348623157e292,M=-17976931348623157e292,o=-17976931348623157e292,q=0;s=+b[i+(q<<4)>>3],g=+b[i+(q<<4)+8>>3],zA=r+2|0,l=+b[i+(((zA|0)==(N|0)?0:zA)<<4)+8>>3],s>3]=s,a=s),g>3]=g,f=g),s>M?b[A>>3]=s:s=M,g>o&&(b[nA>>3]=g,o=g),R=g>0&gI?g:I,n=n|+ZA(+(g-l))>3.141592653589793,r=q+1|0,(r|0)!=(N|0);)zA=q,M=s,q=r,r=zA;n&&(b[nA>>3]=I,b[W>>3]=R)}}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)){SA=e+12|0,U=0;do if(i=t[SA>>2]|0,n=U,U=U+1|0,W=A+(U<<5)|0,nA=t[i+(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(N=t[i+(n<<3)+4>>2]|0,R=17976931348623157e292,I=-17976931348623157e292,i=0,n=-1,G=0,a=17976931348623157e292,f=17976931348623157e292,g=-17976931348623157e292,o=-17976931348623157e292;s=+b[N+(G<<4)>>3],M=+b[N+(G<<4)+8>>3],n=n+2|0,l=+b[N+(((n|0)==(nA|0)?0:n)<<4)+8>>3],s>3]=s,a=s),M>3]=M,f=M),s>g?b[W>>3]=s:s=g,M>o&&(b[$>>3]=M,o=M),R=M>0&MI?M:I,i=i|+ZA(+(M-l))>3.141592653589793,n=G+1|0,(n|0)!=(nA|0);)QA=G,G=n,g=s,n=QA;i&&(b[$>>3]=I,b[e>>3]=R)}}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 ii(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0;if(!(rn(e,A,r)|0))return i=0,i|0;if(i=e+8|0,(t[i>>2]|0)<=0)return i=1,i|0;for(n=e+12|0,e=0;;){if(s=e,e=e+1|0,rn((t[n>>2]|0)+(s<<3)|0,A+(e<<5)|0,r)|0){e=0,n=6;break}if((e|0)>=(t[i>>2]|0)){e=1,n=6;break}}return(n|0)==6?e|0:0}function Zi(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0,o=0,l=0,a=0,f=0,g=0;if(f=k,k=k+16|0,l=f,o=r+8|0,!(rn(e,A,o)|0))return a=0,k=f,a|0;a=e+8|0;A:do if((t[a>>2]|0)>0){for(s=e+12|0,i=0;;){if(g=i,i=i+1|0,rn((t[s>>2]|0)+(g<<3)|0,A+(i<<5)|0,o)|0){i=0;break}if((i|0)>=(t[a>>2]|0))break A}return k=f,i|0}while(!1);if(vn(e,A,r,n)|0)return g=0,k=f,g|0;t[l>>2]=t[r>>2],t[l+4>>2]=o,i=t[a>>2]|0;A:do if((i|0)>0)for(e=e+12|0,o=0,s=i;;){if(i=t[e>>2]|0,(t[i+(o<<3)>>2]|0)>0){if(rn(l,n,t[i+(o<<3)+4>>2]|0)|0){i=0;break A}if(i=o+1|0,vn((t[e>>2]|0)+(o<<3)|0,A+(i<<5)|0,r,n)|0){i=0;break A}s=t[a>>2]|0}else i=o+1|0;if((i|0)<(s|0))o=i;else{i=1;break}}else i=1;while(!1);return g=i,k=f,g|0}function vn(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=0,I=0,N=0,G=0,W=0,nA=0,q=0,$=0,U=0,SA=0,zA=0,QA=0,ce=0;if(zA=k,k=k+176|0,q=zA+172|0,i=zA+168|0,$=zA,!(Fe(A,n)|0))return e=0,k=zA,e|0;if(y0(A,n,q,i),jr($|0,r|0,168)|0,(t[r>>2]|0)>0){A=0;do QA=$+8+(A<<4)+8|0,nA=+Kt(+b[QA>>3],t[i>>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=+Kt(+b[n+16>>3],t[i>>2]|0),I=+Kt(+b[n+24>>3],t[i>>2]|0);A:do if((t[e>>2]|0)>0){if(n=e+4|0,i=t[$>>2]|0,(i|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,R=+b[A+(r<<4)>>3],N=+Kt(+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,s=+b[A+(QA<<4)>>3],o=+Kt(+b[A+(QA<<4)+8>>3],t[q>>2]|0),!(R>=G)|!(s>=G)&&!(R<=W)|!(s<=W)&&!(N<=I)|!(o<=I)&&!(N>=nA)|!(o>=nA)){M=s-R,f=o-N,A=0;do if(ce=A,A=A+1|0,QA=(A|0)==(i|0)?0:A,s=+b[$+8+(ce<<4)+8>>3],o=+b[$+8+(QA<<4)+8>>3]-s,l=+b[$+8+(ce<<4)>>3],a=+b[$+8+(QA<<4)>>3]-l,g=M*o-f*a,g!=0&&(U=N-s,SA=R-l,a=(U*a-o*SA)/g,!(a<0|a>1))&&(g=(M*U-f*SA)/g,g>=0&g<=1)){A=1;break A}while((A|0)<(i|0))}if((r|0)>=(t[e>>2]|0)){A=0;break}}}else A=0;while(!1);return ce=A,k=zA,ce|0}function $i(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0,o=0;if(vn(e,A,r,n)|0)return s=1,s|0;if(s=e+8|0,(t[s>>2]|0)<=0)return s=0,s|0;for(i=e+12|0,e=0;;){if(o=e,e=e+1|0,vn((t[i>>2]|0)+(o<<3)|0,A+(e<<5)|0,r,n)|0){e=1,i=6;break}if((e|0)>=(t[s>>2]|0)){e=0,i=6;break}}return(i|0)==6?e|0:0}function Ol(){return 8}function zl(){return 16}function Hl(){return 168}function Gl(){return 8}function Ul(){return 16}function Vl(){return 12}function Wl(){return 8}function Yl(e){return e=e|0,+(+((t[e>>2]|0)>>>0)+4294967296*+(t[e+4>>2]|0))}function Kl(e){e=e|0;var A=0,r=0;return r=+b[e>>3],A=+b[e+8>>3],+ +xe(+(r*r+A*A))}function qi(e,A,r,n,i){e=e|0,A=A|0,r=r|0,n=n|0,i=i|0;var s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=0;f=+b[e>>3],a=+b[A>>3]-f,l=+b[e+8>>3],o=+b[A+8>>3]-l,M=+b[r>>3],s=+b[n>>3]-M,R=+b[r+8>>3],g=+b[n+8>>3]-R,s=(s*(l-R)-(f-M)*g)/(a*g-o*s),b[i>>3]=f+a*s,b[i+8>>3]=l+o*s}function Ji(e,A){return e=e|0,A=A|0,+ZA(+(+b[e>>3]-+b[A>>3]))<11920928955078125e-23?(A=+ZA(+(+b[e+8>>3]-+b[A+8>>3]))<11920928955078125e-23,A|0):(A=0,A|0)}function st(e,A){e=e|0,A=A|0;var r=0,n=0,i=0;return i=+b[e>>3]-+b[A>>3],n=+b[e+8>>3]-+b[A+8>>3],r=+b[e+16>>3]-+b[A+16>>3],+(i*i+n*n+r*r)}function Zl(e,A){e=e|0,A=A|0;var r=0,n=0,i=0;r=+b[e>>3],n=+_e(+r),r=+se(+r),b[A+16>>3]=r,r=+b[e+8>>3],i=n*+_e(+r),b[A>>3]=i,r=n*+se(+r),b[A+8>>3]=r}function $l(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0;if(s=k,k=k+16|0,i=s,n=He(e,A)|0,(r+-1|0)>>>0>5||(n=(n|0)!=0,(r|0)==1&n))return i=-1,k=s,i|0;do if(sn(e,A,i)|0)n=-1;else if(n){n=((t[26352+(r<<2)>>2]|0)+5-(t[i>>2]|0)|0)%5|0;break}else{n=((t[26384+(r<<2)>>2]|0)+6-(t[i>>2]|0)|0)%6|0;break}while(!1);return i=n,k=s,i|0}function sn(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0,o=0,l=0,a=0,f=0,g=0;if(g=k,k=k+32|0,l=g+16|0,a=g,n=Mr(e,A,l)|0,n|0)return r=n,k=g,r|0;s=te(e,A)|0,f=Ht(e,A)|0,z0(s,a),n=e0(s,t[l>>2]|0)|0;do if(je(s)|0){do switch(s|0){case 4:{i=0;break}case 14:{i=1;break}case 24:{i=2;break}case 38:{i=3;break}case 49:{i=4;break}case 58:{i=5;break}case 63:{i=6;break}case 72:{i=7;break}case 83:{i=8;break}case 97:{i=9;break}case 107:{i=10;break}case 117:{i=11;break}default:OA(27795,27797,75,27806)}while(!1);if(o=t[26416+(i*24|0)+8>>2]|0,A=t[26416+(i*24|0)+16>>2]|0,e=t[l>>2]|0,(e|0)!=(t[a>>2]|0)&&(a=Bt(s)|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)==(o|0)&&(n=(n+1|0)%6|0)}while(!1);return t[r>>2]=n,r=0,k=g,r|0}function r0(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=0,I=0,N=0,G=0,W=0,nA=0,q=0,$=0;if($=k,k=k+32|0,q=$+24|0,W=$+20|0,N=$+8|0,I=$+16|0,R=$,a=(He(e,A)|0)==0,a=a?6:5,g=wA(e|0,A|0,52)|0,S()|0,g=g&15,a>>>0<=r>>>0)return n=2,k=$,n|0;M=(g|0)==0,!M&&(G=kA(7,0,(g^15)*3|0)|0,(G&e|0)==0&((S()|0)&A|0)==0)?i=r:s=4;A:do if((s|0)==4){if(i=(He(e,A)|0)!=0,((i?4:5)|0)<(r|0)||sn(e,A,q)|0||(s=(t[q>>2]|0)+r|0,i?i=26704+(((s|0)%5|0)<<2)|0:i=26736+(((s|0)%6|0)<<2)|0,G=t[i>>2]|0,(G|0)==7))return n=1,k=$,n|0;t[W>>2]=0,i=K(e,A,G,W,N)|0;do if(!i){if(l=N,f=t[l>>2]|0,l=t[l+4>>2]|0,o=l>>>0>>0|(l|0)==(A|0)&f>>>0>>0,s=o?f:e,o=o?l:A,!M&&(M=kA(7,0,(g^15)*3|0)|0,(f&M|0)==0&(l&(S()|0)|0)==0))i=r;else{if(l=(r+-1+a|0)%(a|0)|0,i=He(e,A)|0,(l|0)<0&&OA(27795,27797,248,27822),a=(i|0)!=0,((a?4:5)|0)<(l|0)&&OA(27795,27797,248,27822),sn(e,A,q)|0&&OA(27795,27797,248,27822),i=(t[q>>2]|0)+l|0,a?i=26704+(((i|0)%5|0)<<2)|0:i=26736+(((i|0)%6|0)<<2)|0,l=t[i>>2]|0,(l|0)==7&&OA(27795,27797,248,27822),t[I>>2]=0,i=K(e,A,l,I,R)|0,i|0)break;f=R,a=t[f>>2]|0,f=t[f+4>>2]|0;do if(f>>>0>>0|(f|0)==(o|0)&a>>>0>>0){if(He(a,f)|0?s=Ae(a,f,e,A)|0:s=t[26800+((((t[I>>2]|0)+(t[26768+(l<<2)>>2]|0)|0)%6|0)<<2)>>2]|0,i=He(a,f)|0,(s+-1|0)>>>0>5){i=-1,s=a,o=f;break}if(i=(i|0)!=0,(s|0)==1&i){i=-1,s=a,o=f;break}do if(sn(a,f,q)|0)i=-1;else if(i){i=((t[26352+(s<<2)>>2]|0)+5-(t[q>>2]|0)|0)%5|0;break}else{i=((t[26384+(s<<2)>>2]|0)+6-(t[q>>2]|0)|0)%6|0;break}while(!1);s=a,o=f}else i=r;while(!1);l=N,f=t[l>>2]|0,l=t[l+4>>2]|0}if((s|0)==(f|0)&(o|0)==(l|0)){if(a=(He(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,i=He(f,l)|0,(e+-1|0)>>>0<=5&&(nA=(i|0)!=0,!((e|0)==1&nA)))do if(sn(f,l,q)|0)i=-1;else if(nA){i=((t[26352+(e<<2)>>2]|0)+5-(t[q>>2]|0)|0)%5|0;break}else{i=((t[26384+(e<<2)>>2]|0)+6-(t[q>>2]|0)|0)%6|0;break}while(!1);else i=-1;i=i+1|0,i=(i|0)==6|a&(i|0)==5?0:i}A=o,e=s;break A}while(!1);return n=i,k=$,n|0}while(!1);return nA=kA(i|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 ql(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0;return s=(He(e,A)|0)==0,n=r0(e,A,0,r)|0,i=(n|0)==0,s?!i||(n=r0(e,A,1,r+8|0)|0,n|0)||(n=r0(e,A,2,r+16|0)|0,n|0)||(n=r0(e,A,3,r+24|0)|0,n|0)||(n=r0(e,A,4,r+32|0)|0,n)?(s=n,s|0):r0(e,A,5,r+40|0)|0:!i||(n=r0(e,A,1,r+8|0)|0,n|0)||(n=r0(e,A,2,r+16|0)|0,n|0)||(n=r0(e,A,3,r+24|0)|0,n|0)||(n=r0(e,A,4,r+32|0)|0,n|0)?(s=n,s|0):(s=r+40|0,t[s>>2]=0,t[s+4>>2]=0,s=0,s|0)}function Jl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0,o=0,l=0,a=0;return a=k,k=k+192|0,i=a,s=a+168|0,o=wA(e|0,A|0,56)|0,S()|0,o=o&7,l=A&-2130706433|134217728,n=Mr(e,l,s)|0,n|0?(l=n,k=a,l|0):(A=wA(e|0,A|0,52)|0,S()|0,A=A&15,He(e,l)|0?w(s,A,o,1,i):X(s,A,o,1,i),l=i+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 Xi(e,A){e=e|0,A=A|0;var r=0,n=0,i=0,s=0;return i=k,k=k+16|0,r=i,!(!0&(A&2013265920|0)==536870912)||(n=A&-2130706433|134217728,!(We(e,n)|0))?(n=0,k=i,n|0):(s=wA(e|0,A|0,56)|0,S()|0,s=(r0(e,n,s&7,r)|0)==0,n=r,n=s&((t[n>>2]|0)==(e|0)?(t[n+4>>2]|0)==(A|0):0)&1,k=i,n|0)}function As(e,A,r){e=e|0,A=A|0,r=r|0;var n=0;(A|0)>0?(n=Gt(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 es(e){e=e|0;var A=0,r=0,n=0,i=0,s=0,o=0,l=0;i=e+4|0,s=e+12|0,o=e+8|0;A:for(;;){for(r=t[i>>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+(~~(+ZA(+(+lt(10,+ +(15-(t[s>>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[o>>2]=(t[o>>2]|0)+-1}while(!1)}qA(t[e>>2]|0)}function ts(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 rs(e,A){e=e|0,A=A|0;var r=0,n=0,i=0,s=0;if(r=~~(+ZA(+(+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 s=1,s|0;s=A+32|0;do if((n|0)!=(A|0)){if(r=t[n+32>>2]|0,!r)return s=1,s|0;for(i=r;;){if((i|0)==(A|0)){i=8;break}if(r=t[i+32>>2]|0,r)n=i,i=r;else{r=1,i=10;break}}if((i|0)==8){t[n+32>>2]=t[s>>2];break}else if((i|0)==10)return r|0}else t[r>>2]=t[s>>2];while(!1);return qA(A),s=e+8|0,t[s>>2]=(t[s>>2]|0)+-1,s=0,s|0}function Xl(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0,o=0;s=w0(40)|0,s||OA(27888,27858,98,27901),t[s>>2]=t[A>>2],t[s+4>>2]=t[A+4>>2],t[s+8>>2]=t[A+8>>2],t[s+12>>2]=t[A+12>>2],i=s+16|0,t[i>>2]=t[r>>2],t[i+4>>2]=t[r+4>>2],t[i+8>>2]=t[r+8>>2],t[i+12>>2]=t[r+12>>2],t[s+32>>2]=0,i=~~(+ZA(+(+lt(10,+ +(15-(t[e+12>>2]|0)|0))*(+b[A>>3]+ +b[A+8>>3])))%+(t[e+4>>2]|0))>>>0,i=(t[e>>2]|0)+(i<<2)|0,n=t[i>>2]|0;do if(!n)t[i>>2]=s;else{for(;!(Dr(n,A)|0&&Dr(n+16|0,r)|0);)if(i=t[n+32>>2]|0,n=(i|0)==0?n:i,!(t[n+32>>2]|0)){o=10;break}if((o|0)==10){t[n+32>>2]=s;break}return qA(s),o=n,o|0}while(!1);return o=e+8|0,t[o>>2]=(t[o>>2]|0)+1,o=s,o|0}function Aa(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0;if(i=~~(+ZA(+(+lt(10,+ +(15-(t[e+12>>2]|0)|0))*(+b[A>>3]+ +b[A+8>>3])))%+(t[e+4>>2]|0))>>>0,i=t[(t[e>>2]|0)+(i<<2)>>2]|0,!i)return r=0,r|0;if(!r){for(e=i;;){if(Dr(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=i;;){if(Dr(e,A)|0&&Dr(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 ea(e,A){e=e|0,A=A|0;var r=0;if(r=~~(+ZA(+(+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(Dr(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 ta(){return 27920}function U0(e){return e=+e,~~+os(+e)|0}function w0(e){e=e|0;var A=0,r=0,n=0,i=0,s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=0,I=0,N=0,G=0,W=0,nA=0,q=0,$=0,U=0,SA=0;SA=k,k=k+16|0,R=SA;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,i=n+8|0,s=t[i>>2]|0,(s|0)==(e|0)?t[6981]=M&~(1<>2]=e,t[r>>2]=s),U=A<<3,t[n+4>>2]=U|3,U=n+U+4|0,t[U>>2]=t[U>>2]|1,U=i,k=SA,U|0;if(g=t[6983]|0,f>>>0>g>>>0){if(r|0)return A=2<>>12&16,A=A>>>l,r=A>>>5&8,A=A>>>r,s=A>>>2&4,A=A>>>s,e=A>>>1&2,A=A>>>e,n=A>>>1&1,n=(r|l|s|e|n)+(A>>>n)|0,A=27964+(n<<1<<2)|0,e=A+8|0,s=t[e>>2]|0,l=s+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,o=U-f|0,t[s+4>>2]=f|3,i=s+f|0,t[i+4>>2]=o|1,t[s+U>>2]=o,g|0&&(n=t[6986]|0,A=g>>>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]=o,t[6986]=i,U=l,k=SA,U|0;if(s=t[6982]|0,s){for(r=(s&0-s)+-1|0,i=r>>>12&16,r=r>>>i,n=r>>>5&8,r=r>>>n,o=r>>>2&4,r=r>>>o,l=r>>>1&2,r=r>>>l,a=r>>>1&1,a=t[28228+((n|i|o|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));)o=(t[e+4>>2]&-8)-f|0,i=o>>>0>>0,r=e,l=i?e:l,a=i?o:a;if(o=l+f|0,o>>>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)){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(i|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]=s&~(1<>2]|0)==(l|0)?U:i+20|0)>>2]=r,!r)break;t[r+24>>2]=i,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[o+4>>2]=a|1,t[o+a>>2]=a,g|0&&(n=t[6986]|0,A=g>>>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]=o),U=l+8|0,k=SA,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){i=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),s=0;;){if(o=(t[r+4>>2]&-8)-f|0,o>>>0>>0)if(o)e=r,i=o;else{e=r,i=0,G=65;break A}if(G=t[r+20>>2]|0,r=t[r+16+(l>>>31<<2)>>2]|0,s=(G|0)==0|(G|0)==(r|0)?s:G,r)l=l<<1;else{r=s,G=61;break}}while(!1);if((G|0)==61){if((r|0)==0&(e|0)==0){if(e=2<>>12&16,M=M>>>o,s=M>>>5&8,M=M>>>s,l=M>>>2&4,M=M>>>l,a=M>>>1&2,M=M>>>a,r=M>>>1&1,e=0,r=t[28228+((s|o|l|a|r)+(M>>>r)<<2)>>2]|0}r?G=65:(l=e,o=i)}if((G|0)==65)for(s=r;;)if(M=(t[s+4>>2]&-8)-f|0,r=M>>>0>>0,i=r?M:i,e=r?s:e,r=t[s+16>>2]|0,r||(r=t[s+20>>2]|0),r)s=r;else{l=e,o=i;break}if((l|0)!=0&&o>>>0<((t[6983]|0)-f|0)>>>0&&(g=l+f|0,g>>>0>l>>>0)){s=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(i=A+20|0,r=t[i>>2]|0,r)A=r,e=i;else if(i=A+16|0,r=t[i>>2]|0,r)A=r,e=i;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(s){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:s+20|0)>>2]=A,!A)break;t[A+24>>2]=s,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(o>>>0<16)U=o+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[g+4>>2]=o|1,t[g+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]=g,t[A+12>>2]=g,t[g+8>>2]=A,t[g+12>>2]=r;break}if(A=o>>>8,A?o>>>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=o>>>(r+7|0)&1|r<<1):r=0,A=28228+(r<<2)|0,t[g+28>>2]=r,e=g+16|0,t[e+4>>2]=0,t[e>>2]=0,e=1<>2]=g,t[g+24>>2]=A,t[g+12>>2]=g,t[g+8>>2]=g;break}A=t[A>>2]|0;e:do if((t[A+4>>2]&-8|0)!=(o|0)){for(n=o<<((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)==(o|0)){A=e;break e}else n=n<<1,A=e;t[r>>2]=g,t[g+24>>2]=A,t[g+12>>2]=g,t[g+8>>2]=g;break A}while(!1);$=A+8|0,U=t[$>>2]|0,t[U+12>>2]=g,t[$>>2]=g,t[g+8>>2]=U,t[g+12>>2]=A,t[g+24>>2]=0}while(!1);return U=l+8|0,k=SA,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=SA,U|0;if(o=t[6984]|0,o>>>0>M>>>0)return q=o-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=SA,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]=R&-16^1431655768,e=4096),l=M+48|0,a=M+47|0,s=e+a|0,i=0-e|0,f=s&i,f>>>0<=M>>>0||(e=t[7091]|0,e|0&&(g=t[7089]|0,R=g+f|0,R>>>0<=g>>>0|R>>>0>e>>>0)))return U=0,k=SA,U|0;A:do if(t[7092]&4)A=0,G=143;else{r=t[6987]|0;e:do if(r){for(n=28372;R=t[n>>2]|0,!(R>>>0<=r>>>0&&(R+(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=s-o&i,A>>>0<2147483647)if(e=Y0(A|0)|0,(e|0)==((t[n>>2]|0)+(t[n+4>>2]|0)|0)){if((e|0)!=-1){o=A,s=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=Y0(0)|0,(r|0)!=-1&&(A=r,I=t[7100]|0,N=I+-1|0,A=((N&A|0)==0?0:(N+A&0-I)-A|0)+f|0,I=t[7089]|0,N=A+I|0,A>>>0>M>>>0&A>>>0<2147483647)){if(R=t[7091]|0,R|0&&N>>>0<=I>>>0|N>>>0>R>>>0){A=0;break}if(e=Y0(A|0)|0,(e|0)==(r|0)){o=A,s=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{o=A,s=n,G=145;break A}if(e=t[7101]|0,e=a-A+e&0-e,e>>>0>=2147483647){o=A,s=n,G=145;break A}if((Y0(e|0)|0)==-1){Y0(r|0)|0,A=0;break}else{o=e+A|0,s=n,G=145;break A}}while(!1);t[7092]=t[7092]|4,G=143}while(!1);if((G|0)==143&&f>>>0<2147483647&&(q=Y0(f|0)|0,N=Y0(0)|0,W=N-q|0,nA=W>>>0>(M+40|0)>>>0,!((q|0)==-1|nA^1|q>>>0>>0&((q|0)!=-1&(N|0)!=-1)^1))&&(o=nA?W:A,s=q,G=145),(G|0)==145){A=(t[7089]|0)+o|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,(s|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)&&s>>>0>a>>>0&e>>>0<=a>>>0){t[$>>2]=r+o,U=(t[6984]|0)+o|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(s>>>0<(t[6985]|0)>>>0&&(t[6985]=s),r=s+o|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]=s,g=A+4|0,t[g>>2]=(t[g>>2]|0)+o,g=s+8|0,g=s+((g&7|0)==0?0:0-g&7)|0,A=r+8|0,A=r+((A&7|0)==0?0:0-A&7)|0,f=g+M|0,l=A-g-M|0,t[g+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){o=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{s=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(i=e+20|0,n=t[i>>2]|0,n)e=n,r=i;else if(i=e+16|0,n=t[i>>2]|0,n)e=n,r=i;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(!s)break;r=t[A+28>>2]|0,n=28228+(r<<2)|0;do if((t[n>>2]|0)!=(A|0)){if(U=s+16|0,t[((t[U>>2]|0)==(A|0)?U:s+20|0)>>2]=e,!e)break t}else{if(t[n>>2]=e,e|0)break;t[6982]=t[6982]&~(1<>2]=s,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+o|0,i=o+l|0}else i=l;if(A=A+4|0,t[A>>2]=t[A>>2]&-2,t[f+4>>2]=i|1,t[f+i>>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]=f,t[A+12>>2]=f,t[f+8>>2]=A,t[f+12>>2]=r;break}A=i>>>8;do if(!A)n=0;else{if(i>>>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=i>>>(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)!=(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 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=g+8|0,k=SA,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;i=U+-47|0,e=i+8|0,e=i+((e&7|0)==0?0:0-e&7)|0,i=a+16|0,e=e>>>0>>0?a:e,A=e+8|0,r=o+-40|0,q=s+8|0,q=(q&7|0)==0?0:0-q&7,$=s+q|0,q=r-q|0,t[6987]=$,t[6984]=q,t[$+4>>2]=q|1,t[s+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]=s,t[7094]=o,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(s=e-a|0,t[r>>2]=t[r>>2]&-2,t[a+4>>2]=s|1,t[e>>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]=a,t[A+12>>2]=a,t[a+8>>2]=A,t[a+12>>2]=r;break}if(A=s>>>8,A?s>>>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=s>>>(n+7|0)&1|n<<1):n=0,r=28228+(n<<2)|0,t[a+28>>2]=n,t[a+20>>2]=0,t[i>>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)!=(s|0)){for(n=s<<((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)==(s|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|s>>>0>>0&&(t[6985]=s),t[7093]=s,t[7094]=o,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=o+-40|0,q=s+8|0,q=(q&7|0)==0?0:0-q&7,$=s+q|0,q=U-q|0,t[6987]=$,t[6984]=q,t[$+4>>2]=q|1,t[s+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=SA,U|0}return U=ta()|0,t[U>>2]=12,U=0,k=SA,U|0}function qA(e){e=e|0;var A=0,r=0,n=0,i=0,s=0,o=0,l=0,a=0;if(e){r=e+-8|0,i=t[6985]|0,e=t[e+-4>>2]|0,A=e&-8,a=r+A|0;do if(e&1)l=r,o=r;else{if(n=t[r>>2]|0,!(e&3)||(o=r+(0-n)|0,s=n+A|0,o>>>0>>0))return;if((t[6986]|0)==(o|0)){if(e=a+4|0,A=t[e>>2]|0,(A&3|0)!=3){l=o,A=s;break}t[6983]=s,t[e>>2]=A&-2,t[o+4>>2]=s|1,t[o+s>>2]=s;return}if(r=n>>>3,n>>>0<256)if(e=t[o+8>>2]|0,A=t[o+12>>2]|0,(A|0)==(e|0)){t[6981]=t[6981]&~(1<>2]=A,t[A+8>>2]=e,l=o,A=s;break}i=t[o+24>>2]|0,e=t[o+12>>2]|0;do if((e|0)==(o|0)){if(A=o+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[o+8>>2]|0,t[l+12>>2]=e,t[e+8>>2]=l;while(!1);if(i){if(A=t[o+28>>2]|0,r=28228+(A<<2)|0,(t[r>>2]|0)==(o|0)){if(t[r>>2]=e,!e){t[6982]=t[6982]&~(1<>2]|0)==(o|0)?l:i+20|0)>>2]=e,!e){l=o,A=s;break}t[e+24>>2]=i,A=o+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=o,A=s):(l=o,A=s)}else l=o,A=s}while(!1);if(!(o>>>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[o+A>>2]=A,i=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]=o,t[l+4>>2]=a|1,t[o+a>>2]=a;return}i=(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{s=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(s|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:s+20|0)>>2]=r,!r)break;t[r+24>>2]=s,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]=i|1,t[o+i>>2]=i,(l|0)==(t[6986]|0)){t[6983]=i;return}}if(e=i>>>3,i>>>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=i>>>8,e?i>>>0>16777215?n=31:(o=(e+1048320|0)>>>16&8,a=e<>>16&4,a=a<>>16&2,n=14-(s|o|n)+(a<>>15)|0,n=i>>>(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)!=(i|0)){for(n=i<<((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)==(i|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);o=e+8|0,a=t[o>>2]|0,t[a+12>>2]=l,t[o>>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 Gt(e,A){e=e|0,A=A|0;var r=0;return e?(r=Ne(A,e)|0,(A|e)>>>0>65535&&(r=((r>>>0)/(e>>>0)|0|0)==(A|0)?r:-1)):r=0,e=w0(r)|0,!e||!(t[e+-4>>2]&3)||W0(e|0,0,r|0)|0,e|0}function YA(e,A,r,n){return e=e|0,A=A|0,r=r|0,n=n|0,r=e+r>>>0,$A(A+n+(r>>>0>>0|0)>>>0|0),r|0|0}function ft(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,$A(n|0),e-r>>>0|0|0}function ns(e){return e=e|0,(e?31-(yt(e^e-1)|0)|0:32)|0}function si(e,A,r,n,i){e=e|0,A=A|0,r=r|0,n=n|0,i=i|0;var s=0,o=0,l=0,a=0,f=0,g=0,M=0,R=0,I=0,N=0;if(g=e,a=A,f=a,o=r,R=n,l=R,!f)return s=(i|0)!=0,l?s?(t[i>>2]=e|0,t[i+4>>2]=A&0,R=0,i=0,$A(R|0),i|0):(R=0,i=0,$A(R|0),i|0):(s&&(t[i>>2]=(g>>>0)%(o>>>0),t[i+4>>2]=0),R=0,i=(g>>>0)/(o>>>0)>>>0,$A(R|0),i|0);s=(l|0)==0;do if(o){if(!s){if(s=(yt(l|0)|0)-(yt(f|0)|0)|0,s>>>0<=31){M=s+1|0,l=31-s|0,A=s-31>>31,o=M,e=g>>>(M>>>0)&A|f<>>(M>>>0)&A,s=0,l=g<>2]=e|0,t[i+4>>2]=a|A&0,R=0,i=0,$A(R|0),i|0):(R=0,i=0,$A(R|0),i|0)}if(s=o-1|0,s&o|0){l=(yt(o|0)|0)+33-(yt(f|0)|0)|0,N=64-l|0,M=32-l|0,a=M>>31,I=l-32|0,A=I>>31,o=l,e=M-1>>31&f>>>(I>>>0)|(f<>>(l>>>0))&A,A=A&f>>>(l>>>0),s=g<>>(I>>>0))&a|g<>31;break}return i|0&&(t[i>>2]=s&g,t[i+4>>2]=0),(o|0)==1?(I=a|A&0,N=e|0|0,$A(I|0),N|0):(N=ns(o|0)|0,I=f>>>(N>>>0)|0,N=f<<32-N|g>>>(N>>>0)|0,$A(I|0),N|0)}else{if(s)return i|0&&(t[i>>2]=(f>>>0)%(o>>>0),t[i+4>>2]=0),I=0,N=(f>>>0)/(o>>>0)>>>0,$A(I|0),N|0;if(!g)return i|0&&(t[i>>2]=0,t[i+4>>2]=(f>>>0)%(l>>>0)),I=0,N=(f>>>0)/(l>>>0)>>>0,$A(I|0),N|0;if(s=l-1|0,!(s&l))return i|0&&(t[i>>2]=e|0,t[i+4>>2]=s&f|A&0),I=0,N=f>>>((ns(l|0)|0)>>>0),$A(I|0),N|0;if(s=(yt(l|0)|0)-(yt(f|0)|0)|0,s>>>0<=30){A=s+1|0,l=31-s|0,o=A,e=f<>>(A>>>0),A=f>>>(A>>>0),s=0,l=g<>2]=e|0,t[i+4>>2]=a|A&0,I=0,N=0,$A(I|0),N|0):(I=0,N=0,$A(I|0),N|0)}while(!1);if(!o)f=l,a=0,l=0;else{M=r|0|0,g=R|n&0,f=YA(M|0,g|0,-1,-1)|0,r=S()|0,a=l,l=0;do n=a,a=s>>>31|a<<1,s=l|s<<1,n=e<<1|n>>>31|0,R=e>>>31|A<<1|0,ft(f|0,r|0,n|0,R|0)|0,N=S()|0,I=N>>31|((N|0)<0?-1:0)<<1,l=I&1,e=ft(n|0,R|0,I&M|0,(((N|0)<0?-1:0)>>31|((N|0)<0?-1:0)<<1)&g|0)|0,A=S()|0,o=o-1|0;while((o|0)!=0);f=a,a=0}return o=0,i|0&&(t[i>>2]=e,t[i+4>>2]=A),I=(s|0)>>>31|(f|o)<<1|(o<<1|s>>>31)&0|a,N=(s<<1|0)&-2|l,$A(I|0),N|0}function V0(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0,o=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,s=n>>31|((n|0)<0?-1:0)<<1,i=((n|0)<0?-1:0)>>31|((n|0)<0?-1:0)<<1,l=ft(f^e|0,a^A|0,f|0,a|0)|0,o=S()|0,e=s^f,A=i^a,ft((si(l,o,ft(s^r|0,i^n|0,s|0,i|0)|0,S()|0,0)|0)^e|0,(S()|0)^A|0,e|0,A|0)|0}function ra(e,A){e=e|0,A=A|0;var r=0,n=0,i=0,s=0;return s=e&65535,i=A&65535,r=Ne(i,s)|0,n=e>>>16,e=(r>>>16)+(Ne(i,n)|0)|0,i=A>>>16,A=Ne(i,s)|0,$A((e>>>16)+(Ne(i,n)|0)+(((e&65535)+A|0)>>>16)|0),e+A<<16|r&65535|0|0}function ht(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0;return i=e,s=r,r=ra(i,s)|0,e=S()|0,$A((Ne(A,s)|0)+(Ne(n,i)|0)+e|e&0|0),r|0|0|0}function _r(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0,o=0,l=0,a=0,f=0;return i=k,k=k+16|0,l=i|0,o=A>>31|((A|0)<0?-1:0)<<1,s=((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=ft(o^e|0,s^A|0,o|0,s|0)|0,A=S()|0,si(e,A,ft(f^r|0,a^n|0,f|0,a|0)|0,S()|0,l)|0,n=ft(t[l>>2]^o|0,t[l+4>>2]^s|0,o|0,s|0)|0,r=S()|0,k=i,$A(r|0),n|0}function Tr(e,A,r,n){e=e|0,A=A|0,r=r|0,n=n|0;var i=0,s=0;return s=k,k=k+16|0,i=s|0,si(e,A,r,n,i)|0,k=s,$A(t[i+4>>2]|0),t[i>>2]|0|0}function is(e,A,r){return e=e|0,A=A|0,r=r|0,(r|0)<32?($A(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?($A(A>>>r|0),e>>>r|(A&(1<>>r-32|0)}function kA(e,A,r){return e=e|0,A=A|0,r=r|0,(r|0)<32?($A(A<>>32-r|0),e<=0?+Ve(e+.5):+at(e-.5)}function jr(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0;if((r|0)>=8192)return l0(e|0,A|0,r|0)|0,e|0;if(s=e|0,i=e+r|0,(e&3)==(A&3)){for(;e&3;){if(!r)return s|0;xA[e>>0]=xA[A>>0]|0,e=e+1|0,A=A+1|0,r=r-1|0}for(r=i&-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=i-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)<(i|0);)xA[e>>0]=xA[A>>0]|0,e=e+1|0,A=A+1|0;return s|0}function W0(e,A,r){e=e|0,A=A|0,r=r|0;var n=0,i=0,s=0,o=0;if(s=e+r|0,A=A&255,(r|0)>=67){for(;e&3;)xA[e>>0]=A,e=e+1|0;for(n=s&-4|0,o=A|A<<8|A<<16|A<<24,i=n-64|0;(e|0)<=(i|0);)t[e>>2]=o,t[e+4>>2]=o,t[e+8>>2]=o,t[e+12>>2]=o,t[e+16>>2]=o,t[e+20>>2]=o,t[e+24>>2]=o,t[e+28>>2]=o,t[e+32>>2]=o,t[e+36>>2]=o,t[e+40>>2]=o,t[e+44>>2]=o,t[e+48>>2]=o,t[e+52>>2]=o,t[e+56>>2]=o,t[e+60>>2]=o,e=e+64|0;for(;(e|0)<(n|0);)t[e>>2]=o,e=e+4|0}for(;(e|0)<(s|0);)xA[e>>0]=A,e=e+1|0;return s-r|0}function os(e){return e=+e,e>=0?+Ve(e+.5):+at(e-.5)}function Y0(e){e=e|0;var A=0,r=0,n=0;return n=M0()|0,r=t[De>>2]|0,A=r+e|0,(e|0)>0&(A|0)<(r|0)|(A|0)<0?(B0(A|0)|0,Ot(12),-1):(A|0)>(n|0)&&!(a0(A|0)|0)?(Ot(12),-1):(t[De>>2]=A,r|0)}return{___divdi3:V0,___muldi3:ht,___remdi3:_r,___uremdi3:Tr,_areNeighborCells:Kn,_bitshift64Ashr:is,_bitshift64Lshr:wA,_bitshift64Shl:kA,_calloc:Gt,_cellAreaKm2:Cl,_cellAreaM2:El,_cellAreaRads2:ti,_cellToBoundary:Br,_cellToCenterChild:Qi,_cellToChildPos:ml,_cellToChildren:An,_cellToChildrenSize:x0,_cellToLatLng:or,_cellToLocalIj:jl,_cellToParent:Rt,_cellToVertex:r0,_cellToVertexes:ql,_cellsToDirectedEdge:mn,_cellsToLinkedMultiPolygon:xt,_childPosToCell:gl,_compactCells:ol,_constructCell:we,_destroyLinkedMultiPolygon:Ui,_directedEdgeToBoundary:ir,_directedEdgeToCells:Er,_edgeLengthKm:Ml,_edgeLengthM:Bl,_edgeLengthRads:Sl,_emscripten_replace_memory:Et,_free:qA,_getBaseCellNumber:te,_getDirectedEdgeDestination:gn,_getDirectedEdgeOrigin:Cr,_getHexagonAreaAvgKm2:Hi,_getHexagonAreaAvgM2:vl,_getHexagonEdgeLengthAvgKm:bl,_getHexagonEdgeLengthAvgM:kl,_getIcosahedronFaces:Oi,_getIndexDigit:ke,_getNumCells:xn,_getPentagons:Xn,_getRes0Cells:Vr,_getResolution:MA,_greatCircleDistanceKm:tn,_greatCircleDistanceM:yl,_greatCircleDistanceRads:pl,_gridDisk:v,_gridDiskDistances:_,_gridDistance:Il,_gridPathCells:Nl,_gridPathCellsSize:Ll,_gridRing:aA,_gridRingUnsafe:_A,_i64Add:YA,_i64Subtract:ft,_isPentagon:He,_isResClassIII:ul,_isValidCell:We,_isValidDirectedEdge:Jr,_isValidIndex:Tt,_isValidVertex:Xi,_latLngToCell:qn,_llvm_ctlz_i64:oi,_llvm_maxnum_f64:ss,_llvm_minnum_f64:bn,_llvm_round_f64:kn,_localIjToCell:Rl,_malloc:w0,_maxFaceCount:hl,_maxGridDiskSize:h,_maxPolygonToCellsSize:fe,_maxPolygonToCellsSizeExperimental:Ql,_memcpy:jr,_memset:W0,_originToDirectedEdges:Sr,_pentagonCount:dl,_polygonToCells:St,_polygonToCellsExperimental:Pl,_readInt64AsDoubleFromPointer:Yl,_res0CellCount:Ur,_round:os,_sbrk:Y0,_sizeOfCellBoundary:Hl,_sizeOfCoordIJ:Wl,_sizeOfGeoLoop:Gl,_sizeOfGeoPolygon:Ul,_sizeOfH3Index:Ol,_sizeOfLatLng:zl,_sizeOfLinkedGeoPolygon:Vl,_uncompactCells:ll,_uncompactCellsSize:al,_vertexToLatLng:Jl,establishStackSpace:D0,stackAlloc:d0,stackRestore:O0,stackSave:m0}})(er,P0,mA);c.___divdi3=gA.___divdi3,c.___muldi3=gA.___muldi3,c.___remdi3=gA.___remdi3,c.___uremdi3=gA.___uremdi3,c._areNeighborCells=gA._areNeighborCells,c._bitshift64Ashr=gA._bitshift64Ashr,c._bitshift64Lshr=gA._bitshift64Lshr,c._bitshift64Shl=gA._bitshift64Shl,c._calloc=gA._calloc,c._cellAreaKm2=gA._cellAreaKm2,c._cellAreaM2=gA._cellAreaM2,c._cellAreaRads2=gA._cellAreaRads2,c._cellToBoundary=gA._cellToBoundary,c._cellToCenterChild=gA._cellToCenterChild,c._cellToChildPos=gA._cellToChildPos,c._cellToChildren=gA._cellToChildren,c._cellToChildrenSize=gA._cellToChildrenSize,c._cellToLatLng=gA._cellToLatLng,c._cellToLocalIj=gA._cellToLocalIj,c._cellToParent=gA._cellToParent,c._cellToVertex=gA._cellToVertex,c._cellToVertexes=gA._cellToVertexes,c._cellsToDirectedEdge=gA._cellsToDirectedEdge,c._cellsToLinkedMultiPolygon=gA._cellsToLinkedMultiPolygon,c._childPosToCell=gA._childPosToCell,c._compactCells=gA._compactCells,c._constructCell=gA._constructCell,c._destroyLinkedMultiPolygon=gA._destroyLinkedMultiPolygon,c._directedEdgeToBoundary=gA._directedEdgeToBoundary,c._directedEdgeToCells=gA._directedEdgeToCells,c._edgeLengthKm=gA._edgeLengthKm,c._edgeLengthM=gA._edgeLengthM,c._edgeLengthRads=gA._edgeLengthRads;var f0=c._emscripten_replace_memory=gA._emscripten_replace_memory;c._free=gA._free,c._getBaseCellNumber=gA._getBaseCellNumber,c._getDirectedEdgeDestination=gA._getDirectedEdgeDestination,c._getDirectedEdgeOrigin=gA._getDirectedEdgeOrigin,c._getHexagonAreaAvgKm2=gA._getHexagonAreaAvgKm2,c._getHexagonAreaAvgM2=gA._getHexagonAreaAvgM2,c._getHexagonEdgeLengthAvgKm=gA._getHexagonEdgeLengthAvgKm,c._getHexagonEdgeLengthAvgM=gA._getHexagonEdgeLengthAvgM,c._getIcosahedronFaces=gA._getIcosahedronFaces,c._getIndexDigit=gA._getIndexDigit,c._getNumCells=gA._getNumCells,c._getPentagons=gA._getPentagons,c._getRes0Cells=gA._getRes0Cells,c._getResolution=gA._getResolution,c._greatCircleDistanceKm=gA._greatCircleDistanceKm,c._greatCircleDistanceM=gA._greatCircleDistanceM,c._greatCircleDistanceRads=gA._greatCircleDistanceRads,c._gridDisk=gA._gridDisk,c._gridDiskDistances=gA._gridDiskDistances,c._gridDistance=gA._gridDistance,c._gridPathCells=gA._gridPathCells,c._gridPathCellsSize=gA._gridPathCellsSize,c._gridRing=gA._gridRing,c._gridRingUnsafe=gA._gridRingUnsafe,c._i64Add=gA._i64Add,c._i64Subtract=gA._i64Subtract,c._isPentagon=gA._isPentagon,c._isResClassIII=gA._isResClassIII,c._isValidCell=gA._isValidCell,c._isValidDirectedEdge=gA._isValidDirectedEdge,c._isValidIndex=gA._isValidIndex,c._isValidVertex=gA._isValidVertex,c._latLngToCell=gA._latLngToCell,c._llvm_ctlz_i64=gA._llvm_ctlz_i64,c._llvm_maxnum_f64=gA._llvm_maxnum_f64,c._llvm_minnum_f64=gA._llvm_minnum_f64,c._llvm_round_f64=gA._llvm_round_f64,c._localIjToCell=gA._localIjToCell,c._malloc=gA._malloc,c._maxFaceCount=gA._maxFaceCount,c._maxGridDiskSize=gA._maxGridDiskSize,c._maxPolygonToCellsSize=gA._maxPolygonToCellsSize,c._maxPolygonToCellsSizeExperimental=gA._maxPolygonToCellsSizeExperimental,c._memcpy=gA._memcpy,c._memset=gA._memset,c._originToDirectedEdges=gA._originToDirectedEdges,c._pentagonCount=gA._pentagonCount,c._polygonToCells=gA._polygonToCells,c._polygonToCellsExperimental=gA._polygonToCellsExperimental,c._readInt64AsDoubleFromPointer=gA._readInt64AsDoubleFromPointer,c._res0CellCount=gA._res0CellCount,c._round=gA._round,c._sbrk=gA._sbrk,c._sizeOfCellBoundary=gA._sizeOfCellBoundary,c._sizeOfCoordIJ=gA._sizeOfCoordIJ,c._sizeOfGeoLoop=gA._sizeOfGeoLoop,c._sizeOfGeoPolygon=gA._sizeOfGeoPolygon,c._sizeOfH3Index=gA._sizeOfH3Index,c._sizeOfLatLng=gA._sizeOfLatLng,c._sizeOfLinkedGeoPolygon=gA._sizeOfLinkedGeoPolygon,c._uncompactCells=gA._uncompactCells,c._uncompactCellsSize=gA._uncompactCellsSize,c._vertexToLatLng=gA._vertexToLatLng,c.establishStackSpace=gA.establishStackSpace;var ut=c.stackAlloc=gA.stackAlloc,Pe=c.stackRestore=gA.stackRestore,o0=c.stackSave=gA.stackSave;if(c.asm=gA,c.cwrap=cA,c.setValue=Z,c.getValue=V,Qe){Be(Qe)||(Qe=C(Qe));{nt();var qe=function(rA){rA.byteLength&&(rA=new Uint8Array(rA)),NA.set(rA,z),c.memoryInitializerRequest&&delete c.memoryInitializerRequest.response,kt()},vt=function(){T(Qe,qe,function(){throw"could not load memory initializer "+Qe})},Ct=c0(Qe);if(Ct)qe(Ct.buffer);else if(c.memoryInitializerRequest){var A0=function(){var rA=c.memoryInitializerRequest,pA=rA.response;if(rA.status!==200&&rA.status!==0){var RA=c0(c.memoryInitializerRequestURL);if(RA)pA=RA.buffer;else{console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+rA.status+", retrying "+Qe),vt();return}}qe(pA)};c.memoryInitializerRequest.response?setTimeout(A0,0):c.memoryInitializerRequest.addEventListener("load",A0)}else vt()}}var bt;At=function rA(){bt||Pt(),bt||(At=rA)};function Pt(rA){if(Je>0||(Le(),Je>0))return;function pA(){bt||(bt=!0,!AA&&(ie(),ge(),c.onRuntimeInitialized&&c.onRuntimeInitialized(),be()))}c.setStatus?(c.setStatus("Running..."),setTimeout(function(){setTimeout(function(){c.setStatus("")},1),pA()},1)):pA()}c.run=Pt;function gt(rA){throw c.onAbort&&c.onAbort(rA),rA+="",Q(rA),D(rA),AA=!0,"abort("+rA+"). Build with -s ASSERTIONS=1 for more info."}if(c.abort=gt,c.preInit)for(typeof c.preInit=="function"&&(c.preInit=[c.preInit]);c.preInit.length>0;)c.preInit.pop()();return Pt(),u})(typeof Nt=="object"?Nt:{}),re="number",ee=re,Pr=re,le=re,ae=re,dt=re,PA=re,kf=[["sizeOfH3Index",re],["sizeOfLatLng",re],["sizeOfCellBoundary",re],["sizeOfGeoLoop",re],["sizeOfGeoPolygon",re],["sizeOfLinkedGeoPolygon",re],["sizeOfCoordIJ",re],["readInt64AsDoubleFromPointer",re],["isValidCell",Pr,[le,ae]],["isValidIndex",Pr,[le,ae]],["latLngToCell",ee,[re,re,dt,PA]],["cellToLatLng",ee,[le,ae,PA]],["cellToBoundary",ee,[le,ae,PA]],["maxGridDiskSize",ee,[re,PA]],["gridDisk",ee,[le,ae,re,PA]],["gridDiskDistances",ee,[le,ae,re,PA,PA]],["gridRing",ee,[le,ae,re,PA]],["gridRingUnsafe",ee,[le,ae,re,PA]],["maxPolygonToCellsSize",ee,[PA,dt,re,PA]],["polygonToCells",ee,[PA,dt,re,PA]],["maxPolygonToCellsSizeExperimental",ee,[PA,dt,re,PA]],["polygonToCellsExperimental",ee,[PA,dt,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,dt]],["uncompactCellsSize",ee,[PA,re,re,dt,PA]],["isPentagon",Pr,[le,ae]],["isResClassIII",Pr,[le,ae]],["getBaseCellNumber",re,[le,ae]],["getResolution",re,[le,ae]],["getIndexDigit",re,[le,ae,re]],["constructCell",ee,[re,re,PA,PA]],["maxFaceCount",ee,[le,ae,PA]],["getIcosahedronFaces",ee,[le,ae,PA]],["cellToParent",ee,[le,ae,dt,PA]],["cellToChildren",ee,[le,ae,dt,PA]],["cellToCenterChild",ee,[le,ae,dt,PA]],["cellToChildrenSize",ee,[le,ae,dt,PA]],["cellToChildPos",ee,[le,ae,dt,PA]],["childPosToCell",ee,[re,re,le,ae,dt,PA]],["areNeighborCells",ee,[le,ae,le,ae,PA]],["cellsToDirectedEdge",ee,[le,ae,le,ae,PA]],["getDirectedEdgeOrigin",ee,[le,ae,PA]],["getDirectedEdgeDestination",ee,[le,ae,PA]],["isValidDirectedEdge",Pr,[le,ae]],["directedEdgeToCells",ee,[le,ae,PA]],["originToDirectedEdges",ee,[le,ae,PA]],["directedEdgeToBoundary",ee,[le,ae,PA]],["gridDistance",ee,[le,ae,le,ae,PA]],["gridPathCells",ee,[le,ae,le,ae,PA]],["gridPathCellsSize",ee,[le,ae,le,ae,PA]],["cellToLocalIj",ee,[le,ae,le,ae,re,PA]],["localIjToCell",ee,[le,ae,PA,re,PA]],["getHexagonAreaAvgM2",ee,[dt,PA]],["getHexagonAreaAvgKm2",ee,[dt,PA]],["getHexagonEdgeLengthAvgM",ee,[dt,PA]],["getHexagonEdgeLengthAvgKm",ee,[dt,PA]],["greatCircleDistanceM",re,[PA,PA]],["greatCircleDistanceKm",re,[PA,PA]],["greatCircleDistanceRads",re,[PA,PA]],["cellAreaM2",ee,[le,ae,PA]],["cellAreaKm2",ee,[le,ae,PA]],["cellAreaRads2",ee,[le,ae,PA]],["edgeLengthM",ee,[le,ae,PA]],["edgeLengthKm",ee,[le,ae,PA]],["edgeLengthRads",ee,[le,ae,PA]],["getNumCells",ee,[dt,PA]],["getRes0Cells",ee,[PA]],["res0CellCount",re],["getPentagons",ee,[re,PA]],["pentagonCount",re],["cellToVertex",ee,[le,ae,re,PA]],["cellToVertexes",ee,[le,ae,PA]],["vertexToLatLng",ee,[le,ae,PA]],["isValidVertex",Pr,[le,ae]]],Cf=0,Ef=1,Sf=2,Mf=3,Bf=4,Df=5,_f=6,Tf=7,jf=8,Rf=9,If=10,Lf=11,Nf=12,Ff=13,Pf=14,Qf=15,Of=16,zf=17,Hf=18,Gf=19,it={};it[Cf]="Success";it[Ef]="The operation failed but a more specific error is not available";it[Sf]="Argument was outside of acceptable range";it[Mf]="Latitude or longitude arguments were outside of acceptable range";it[Bf]="Resolution argument was outside of acceptable range";it[Df]="Cell argument was not valid";it[_f]="Directed edge argument was not valid";it[Tf]="Undirected edge argument was not valid";it[jf]="Vertex argument was not valid";it[Rf]="Pentagon distortion was encountered";it[If]="Duplicate input";it[Lf]="Cell arguments were not neighbors";it[Nf]="Cell arguments had incompatible resolutions";it[Ff]="Memory allocation failed";it[Pf]="Bounds of provided memory were insufficient";it[Qf]="Mode or flags argument was not valid";it[Of]="Index argument was not valid";it[zf]="Base cell number was outside of acceptable range";it[Hf]="Child indexing digits invalid";it[Gf]="Child indexing digits refer to a deleted subsequence";var Uf=1e3,Vf=1001,Xo=1002,Yn={};Yn[Uf]="Unknown unit";Yn[Vf]="Array length out of bounds";Yn[Xo]="Got unexpected null value for H3 index";var Wf="Unknown error";function Al(u,c,p){var y=p&&"value"in p,x=new Error((u[c]||Wf)+" (code: "+c+(y?", value: "+p.value:"")+")");return x.code=c,x}function Yf(u,c){var p=arguments.length===2?{value:c}:{};return Al(it,u,p)}function Kf(u,c){var p=arguments.length===2?{value:c}:{};return Al(Yn,u,p)}function el(u){if(u!==0)throw Yf(u)}var k0={};kf.forEach(function(c){k0[c[0]]=Nt.cwrap.apply(Nt,c)});var Or=16,Zf=4,zn=8,Mi=k0.sizeOfH3Index(),$f=k0.sizeOfLatLng(),qf=k0.sizeOfCellBoundary();k0.sizeOfGeoPolygon();k0.sizeOfGeoLoop();k0.sizeOfLinkedGeoPolygon();k0.sizeOfCoordIJ();function Jf(u){if(!u)throw Kf(Xo);return u}var Xf=/[^0-9a-fA-F]/;function A2(u){if(Array.isArray(u)&&u.length===2&&Number.isInteger(u[0])&&Number.isInteger(u[1]))return u;if(typeof u!="string"||Xf.test(u))return[0,0];var c=parseInt(u.substring(0,u.length-8),Or),p=parseInt(u.substring(u.length-8),Or);return[p,c]}function Ns(u){if(u>=0)return u.toString(Or);u=u&2147483647;var c=tl(8,u.toString(Or)),p=(parseInt(c[0],Or)+8).toString(Or);return c=p+c.substring(1),c}function e2(u,c){return Ns(c)+tl(8,Ns(u))}function tl(u,c){for(var p=u-c.length,y="",x=0;x.85?.9+(u-.85)/.15*.1:.1+(u-.15)/.7*.8}function il(u,c,p,y){const x=p-c;if(x<.001)return Ps(y[12]);const C=Math.max(0,Math.min(1,(u-c)/x)),T=d2(C),Q=Math.min(23,Math.floor(T*24));return Ps(y[Q])}function m2(u){const c=new Map;for(const C of u){if(typeof C.lat!="number"||typeof C.lon!="number"||isNaN(C.lat)||isNaN(C.lon))continue;const T=i2(C.lat,C.lon,l2),Q=c.get(T),D=C.weight;Q?(Q.count++,Q.qualitySum+=D):c.set(T,{count:1,qualitySum:D})}const p=[];let y=1/0,x=-1/0;for(const[C,T]of c.entries()){const Q=T.qualitySum/T.count;p.push({hexId:C,count:T.count,avgQuality:Q}),y=Math.min(y,Q),x=Math.max(x,Q)}return{cells:p,minQuality:p.length>0?y:0,maxQuality:p.length>0?x:0}}function g2(u,c,p,y){const x=[];for(const C of u){const Q=rl(C.hexId).map(([E,L])=>[L,E]);Q.push(Q[0]);const D=il(C.avgQuality,c,p,y);x.push({type:"Feature",properties:{color:D,quality:C.avgQuality,count:C.count},geometry:{type:"Polygon",coordinates:[Q]}})}return{type:"FeatureCollection",features:x}}async function p2(u,c,p,y,x){const C=[];let T=0;for(;T[Z,z]);L.push(L[0]);const O=il(D.avgQuality,c,p,y);C.push({type:"Feature",properties:{color:O,quality:D.avgQuality,count:D.count},geometry:{type:"Polygon",coordinates:[L]}})}TrequestAnimationFrame(D))}return{type:"FeatureCollection",features:C}}function y2(u,c){const[p,y]=j.useState(u);return j.useEffect(()=>{const x=setTimeout(()=>y(u),c);return()=>clearTimeout(x)},[u,c]),p}function x2({coveragePoints:u,visible:c,terrainEnabled:p=!1,brightness:y=a2,basemapMode:x="dark"}){const{current:C}=J0(),[T,Q]=j.useState(null);j.useEffect(()=>{const Y=()=>{var sA;const bA=(sA=C==null?void 0:C.getMap)==null?void 0:sA.call(C);bA&&!T&&Q(bA)};Y();const cA=setInterval(Y,50),lA=setTimeout(()=>clearInterval(cA),5e3);return()=>{clearInterval(cA),clearTimeout(lA)}},[C,T]);const[D,E]=j.useState(null),[L,O]=j.useState(!1),z=j.useRef({aborted:!1}),Z=j.useRef(0),V=j.useRef(x),AA=y2(u,u2),oA=j.useMemo(()=>h2(x),[x]);j.useEffect(()=>{if(!AA||!Array.isArray(AA)||AA.length===0){queueMicrotask(()=>{E(null),Z.current=0});return}const Y=V.current!==x;if(AA.length===Z.current&&D&&!Y)return;Z.current=AA.length,V.current=x,z.current.aborted=!0,z.current={aborted:!1};const cA=z.current;O(!0);const{cells:lA,minQuality:bA,maxQuality:sA}=m2(AA);if(lA.length===0){E(null),O(!1);return}if(lA.length{!cA.aborted&&fA&&E(fA)}).finally(()=>{cA.aborted||O(!1)}),()=>{cA.aborted=!0}},[AA,oA]),j.useEffect(()=>{if(!T)return;const Y=()=>{var cA,lA;try{const bA=T.getLayer(fr),sA=T.getSource(cr);if(c&&D&&D.features.length>0){if(sA?T.getSource(cr).setData(D):T.addSource(cr,{type:"geojson",data:D}),!bA){const fA=T.getLayer("topology-weak-edges-native"),DA=(lA=(cA=T.getStyle())==null?void 0:cA.layers)==null?void 0:lA.find(CA=>CA.type==="symbol"),TA=fA?"topology-weak-edges-native":DA==null?void 0:DA.id;T.addLayer({id:fr,type:"fill",source:cr,paint:{"fill-color":["get","color"],"fill-opacity":y}},TA)}}else bA&&T.removeLayer(fr),sA&&T.removeSource(cr)}catch(bA){console.warn("[WardrivingHexLayerMapLibre] Layer update error:",bA)}};T.isStyleLoaded()?Y():T.once("style.load",Y)},[T,c,D,p]),j.useEffect(()=>{if(!(!T||!c))try{T.getLayer(fr)&&T.setPaintProperty(fr,"fill-opacity",y)}catch{}},[T,y,c]),j.useEffect(()=>()=>{if(T)try{T.getLayer(fr)&&T.removeLayer(fr),T.getSource(cr)&&T.removeSource(cr)}catch{}},[T]);const eA=(D==null?void 0:D.features.length)??0;return eA>0&&c?m.jsx("div",{"data-testid":"wardriving-hexlayer-maplibre-active","data-point-count":(u==null?void 0:u.length)||0,"data-cell-count":eA,"data-terrain-enabled":p,"data-is-processing":L,style:{display:"none"}}):null}const Qs="https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png",Os="terrarium",zs=256,Hs=14,on={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},K0="terrain-dem",Qr="hillshade-dem",Rn="terrain-hillshade";function w2({enabled:u,exaggeration:c=4}){const{current:p}=J0(),[y,x]=j.useState(null),C=j.useRef(null);return j.useEffect(()=>{const T=()=>{var L;const E=(L=p==null?void 0:p.getMap)==null?void 0:L.call(p);E&&!y&&x(E)};T();const Q=setInterval(T,50),D=setTimeout(()=>clearInterval(Q),5e3);return()=>{clearInterval(Q),clearTimeout(D)}},[p,y]),j.useEffect(()=>{if(!y)return;let T=!0;const Q=()=>{var D,E;if(T)try{if(y.getSource(Qr)||y.addSource(Qr,{type:"raster-dem",tiles:[Qs],encoding:Os,tileSize:zs,maxzoom:Hs}),!y.getLayer(Rn)){const L=(E=(D=y.getStyle())==null?void 0:D.layers)==null?void 0:E.find(O=>O.type==="symbol");y.addLayer({id:Rn,type:"hillshade",source:Qr,paint:{"hillshade-shadow-color":on.shadowColor,"hillshade-highlight-color":on.highlightColor,"hillshade-accent-color":on.accentColor,"hillshade-illumination-direction":on.illuminationDirection,"hillshade-exaggeration":on.exaggeration}},L==null?void 0:L.id)}y.getSource(K0)||y.addSource(K0,{type:"raster-dem",tiles:[Qs],encoding:Os,tileSize:zs,maxzoom:Hs})}catch(L){console.error("[TerrainLayer] Source/layer setup error:",L)}};return y.isStyleLoaded()?Q():(y.once("style.load",Q),y.once("load",()=>{T&&!y.getSource(Qr)&&Q()})),()=>{T=!1}},[y]),j.useEffect(()=>{if(!y)return;let T=!0,Q=!1;const D=()=>{if(!(!T||!y.getSource(K0)))try{u?(y.setCenterClampedToGround(!1),y.setTerrain({source:K0,exaggeration:c}),y.setMaxPitch(70),!Q&&y.getPitch()<30&&!y.isMoving()&&(Q=!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(K0))D();else{const E=()=>{y.getSource(K0)&&D()};y.once("idle",E)}return()=>{T=!1,C.current!==null&&(clearTimeout(C.current),C.current=null)}},[y,u,c]),j.useEffect(()=>()=>{var T;try{(T=y==null?void 0:y.getStyle)!=null&&T.call(y)&&y.isStyleLoaded()&&(y.setTerrain(null),y.getLayer(Rn)&&y.removeLayer(Rn),y.getSource(Qr)&&y.removeSource(Qr),y.getSource(K0)&&y.removeSource(K0))}catch{}},[y]),null}const v2=.03,b2=.1,k2=2,C2=3,E2=.02,S2=3;function M2(u,c=S2){if(u.length<3||c<=0)return u;let p=u;for(let y=0;y0&&x.push([x[0][0],x[0][1]]),p=x}return p}function B2(u,c){let p=1/0,y=-1/0,x=1/0,C=-1/0;for(const[T,Q]of u)Ty&&(y=T),QC&&(C=Q);return p-=c,y+=c,x-=c,C+=c,{minX:p,minY:x,maxX:y,maxY:C,width:y-p,height:C-x}}function D2(u,c={}){if(u.length(eA-C.minX)/C.width*L,Z=eA=>(eA-C.minY)/C.height*O,V=eA=>eA/L*C.width+C.minX,AA=eA=>eA/O*C.height+C.minY,oA=p/C.width*L;try{const Y=nc().x(TA=>z(TA[0])).y(TA=>Z(TA[1])).size([L,O]).bandwidth(Math.max(5,oA)).cellSize(x)(u);if(Y.length===0)return{coordinates:[],valid:!1};const lA=Math.max(...Y.map(TA=>TA.value))*y;let bA=Y[0],sA=1/0;for(const TA of Y){const CA=Math.abs(TA.value-lA);CA0){const NA=IA[0],FA=IA[IA.length-1];(NA[0]!==FA[0]||NA[1]!==FA[1])&&IA.push([NA[0],NA[1]])}if(IA.length>=4){const NA=M2(IA);CA.push(NA)}}CA.length>0&&fA.push(CA)}const DA=[];for(const TA of fA)for(const CA of TA)DA.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 _2(u,c={}){const p=D2(u,c);return!p.valid||p.coordinates.length===0?null:p.coordinates.length===1?{type:"Polygon",coordinates:p.coordinates[0]}:{type:"MultiPolygon",coordinates:p.coordinates}}const T2="mincut-partition",j2="mincut-partition-fill",R2="mincut-partition-stroke",I2=3,L2=.05,N2=.15,F2=.008,Gs=12;function Us(u,c,p){return(c[0]-u[0])*(p[1]-u[1])-(c[1]-u[1])*(p[0]-u[0])}function P2(u){if(u.length<3)return u;const c=[...u].sort((x,C)=>x[0]-C[0]||x[1]-C[1]),p=[];for(const x of c){for(;p.length>=2&&Us(p[p.length-2],p[p.length-1],x)<=0;)p.pop();p.push(x)}const y=[];for(let x=c.length-1;x>=0;x--){const C=c[x];for(;y.length>=2&&Us(y[y.length-2],y[y.length-1],C)<=0;)y.pop();y.push(C)}return p.pop(),y.pop(),p.concat(y)}function Q2(u,c){if(u.length<3)return u;let p=0,y=0;for(const[x,C]of u)p+=x,y+=C;return p/=u.length,y/=u.length,u.map(([x,C])=>{const T=x-p,Q=C-y,D=Math.sqrt(T*T+Q*Q);if(D<1e-4)return[x,C];const E=(D+c)/D;return[p+T*E,y+Q*E]})}function O2(u,c,p,y,x){const C=x*x,T=C*x;return[.5*(2*c[0]+(-u[0]+p[0])*x+(2*u[0]-5*c[0]+4*p[0]-y[0])*C+(-u[0]+3*c[0]-3*p[0]+y[0])*T),.5*(2*c[1]+(-u[1]+p[1])*x+(2*u[1]-5*c[1]+4*p[1]-y[1])*C+(-u[1]+3*c[1]-3*p[1]+y[1])*T)]}function z2(u){if(u.length<3)return u;const c=[],p=u.length;for(let y=0;yu?G2(u,c,x,C):{type:"FeatureCollection",features:[]},[u,c,x,C]),D=p?y:0,E={"fill-color":["get","color"],"fill-opacity":D},L={"line-color":["get","borderColor"],"line-width":T,"line-opacity":D};return m.jsxs(L0,{id:T2,type:"geojson",data:Q,children:[m.jsx($t,{id:j2,type:"fill",paint:E}),m.jsx($t,{id:R2,type:"line",paint:L})]})}function V2(u,c=!1,p=!1,y=!1,x=.7,C){const T=mo(C);return y?x>=.75?T.restBright:T.rest:x>=.85?T.rest:(x>=.7,T.restDim)}function Vs(u){return[u[1],u[0]]}function W2(u,c,p,y=12){const[x,C]=u,[T,Q]=c,D=[];for(let E=0;E<=y;E++){const L=E/y,O=C+(Q-C)*L,z=x+(T-x)*L,Z=4*p*L*(1-L);D.push([O,z,Z])}return D}function Ws(u,c,p,y,x,C,T,Q,D,E,L,O="dark"){const z=Fi(),Z=[];let V=1/0,AA=-1/0;const oA=[];for(const Y of u){const cA=Y.edge.avgConfidence??(c?.7:.5),lA=Y.edge.certainCount/Math.max(T,1),bA=cA*.7+lA*.3+(c?.5:0);oA.push({polyline:Y,brightnessScore:bA}),V=Math.min(V,bA),AA=Math.max(AA,bA)}if(oA.length===0)return{type:"FeatureCollection",features:[]};const eA=AA-V||1;oA.sort((Y,cA)=>Y.brightnessScore-cA.brightnessScore);for(const{polyline:Y,brightnessScore:cA}of oA){const{from:lA,to:bA,edge:sA}=Y,fA=p.get(sA.key)??0;if(fA<=0)continue;const DA=Q.has(sA.key),TA=D.has(sA.key),CA=sA.avgConfidence??(c?.7:.5),mA=E===sA.key,IA=L[sA.fromHash],NA=L[sA.toHash],FA=(IA==null?void 0:IA.node_name)||(IA==null?void 0:IA.name)||sA.fromHash.slice(0,8),GA=(NA==null?void 0:NA.node_name)||(NA==null?void 0:NA.name)||sA.toHash.slice(0,8),vA=[lA[0]+(bA[0]-lA[0])*fA,lA[1]+(bA[1]-lA[1])*fA];let uA;if(!c)uA=1.5;else{const ue=C.get(sA.key)??bi(sA.certainCount),JA=x.get(sA.key)??ue;uA=JA+(ue-JA)*y,mA?uA=Math.max(uA*1.6,4.5):TA&&(uA=uA*1.3)}let hA;mA?hA=z.edges.highlight:hA=V2(!1,sA.isDirectPathEdge??!1,DA,TA,CA,O);let jA;mA?jA=z.edges.highlight:sA.isDirectPathEdge?jA=z.edges.hoverDirect:DA?jA=z.edges.hoverLoop:jA=z.edges.hoverStandard;let BA;if(!c)BA=(.3+CA*.3)*fA;else{const ue=Math.min(fA*1.5,1)*z.edgeOpacity;BA=TA?ue*1.15:ue}mA&&(BA=.95);const VA=(cA-V)/eA;Z.push({type:"Feature",properties:{key:sA.key,baseColor:hA,hoverColor:jA,baseWidth:uA,baseOpacity:BA,brightnessScore:VA,isLoopEdge:DA,isBackbone:TA,isDirectPath:sA.isDirectPathEdge??!1,isHubConnection:sA.isHubConnection??!1,isZeroHop:sA.isZeroHop??!1,isValidated:c,certainCount:sA.certainCount,confidence:CA,symmetryRatio:sA.symmetryRatio??1,dominantDirection:sA.dominantDirection??"balanced",fromName:FA,toName:GA,fromHash:sA.fromHash,toHash:sA.toHash},geometry:{type:"LineString",coordinates:[Vs(lA),Vs(vA)]}})}return{type:"FeatureCollection",features:Z}}const Y2=150,K2=8;function Ys(u,c){const p=Fi(),y=[];let x=0;for(const C of u){const T=c.get(C.hash);T&&T.blendedScore>x&&(x=T.blendedScore)}for(const C of u){const{from:T,to:Q,hash:D,neighbor:E,lastHopData:L}=C,O=`neighbor-${D}`,z=(L==null?void 0:L.avgRssi)??E.rssi??null,Z=(L==null?void 0:L.avgSnr)??E.snr??null,V=(L==null?void 0:L.count)??0,AA=(L==null?void 0:L.confidence)??1,oA=c.get(D),eA=(oA==null?void 0:oA.listenerScore)??0,Y=(oA==null?void 0:oA.loudScore)??0,cA=(oA==null?void 0:oA.blendedScore)??0,lA=x>0?cA/x:0,bA=C.rxAdvertCount??0,sA=C.txProxyCount??0,fA=bA+sA,DA=fA>0?(sA-bA)/fA:0,TA=W2(T,Q,Y2,K2);y.push({type:"Feature",properties:{key:O,hash:D,name:E.node_name||E.name||D.slice(0,8),prefix:D.slice(2,4).toUpperCase(),color:p.neighborColor,width:2.5,opacity:.85,rssi:z,snr:Z,packetCount:V,confidence:AA,hasAvgRssi:(L==null?void 0:L.avgRssi)!==void 0,hasAvgSnr:(L==null?void 0:L.avgSnr)!==void 0,isNeighborEdge:!0,listenerScore:eA,loudScore:Y,blendedScore:cA,trafficWeight:lA,linkAsymmetry:DA,rxAdvertCount:bA,txProxyCount:sA},geometry:{type:"LineString",coordinates:TA}})}return{type:"FeatureCollection",features:y}}function Z2({map:u,showTopology:c,validatedPolylines:p,weakPolylines:y,maxCertainCount:x,loopEdgeKeys:C,backboneEdgeKeys:T,highlightedEdgeKey:Q,neighbors:D,validatedSourceId:E,weakSourceId:L,neighborPolylines:O=[],showNeighborLines:z=!0,neighborSourceId:Z,neighborLinkScores:V=new Map,basemapMode:AA}){const oA=j.useRef(null);j.useEffect(()=>{const ie=u&&"current"in u?u.current:u;oA.current=ie});const eA=j.useRef(new Map),Y=j.useRef(1),cA=j.useRef(new Map),lA=j.useRef(new Map),bA=j.useRef(!1),sA=j.useRef(null),fA=j.useRef(c),DA=j.useRef(new Set),TA=j.useRef(""),CA=j.useRef(new Map),mA=j.useRef(""),IA=j.useRef(""),NA=j.useRef(""),FA=j.useRef(p),GA=j.useRef(y),vA=j.useRef(x),uA=j.useRef(C),hA=j.useRef(T),jA=j.useRef(Q),BA=j.useRef(D),VA=j.useRef(O),ue=j.useRef(z),JA=j.useRef(V),KA=j.useRef(AA);j.useEffect(()=>{FA.current=p,GA.current=y,vA.current=x,uA.current=C,hA.current=T,jA.current=Q,BA.current=D,VA.current=O,ue.current=z,JA.current=V,KA.current=AA},[p,y,x,C,T,Q,D,O,z,V,AA]);const UA=j.useCallback((ie=!1)=>{var Ee,Me,ye,$e,Je,At,nt,kt,Qe,Xe;const ge=oA.current;if(!ge)return;const be=ge.getSource(E),Ze=ge.getSource(L),Ce=ge.getSource(Z);if(be){const Be=Ws(FA.current,!0,eA.current,Y.current,cA.current,lA.current,vA.current,uA.current,hA.current,jA.current,BA.current,KA.current),Ge=`${Be.features.length}:${((Me=(Ee=Be.features[0])==null?void 0:Ee.properties)==null?void 0:Me.key)??""}:${(($e=(ye=Be.features[Be.features.length-1])==null?void 0:ye.properties)==null?void 0:$e.key)??""}:${Array.from(eA.current.values()).reduce((ot,Ft)=>ot+Ft,0).toFixed(2)}`;(ie||Ge!==mA.current)&&(be.setData(Be),mA.current=Ge)}if(Ze){const Be=Ws(GA.current,!1,eA.current,Y.current,cA.current,lA.current,vA.current,uA.current,hA.current,jA.current,BA.current,KA.current),Ge=`${Be.features.length}:${((At=(Je=Be.features[0])==null?void 0:Je.properties)==null?void 0:At.key)??""}:${((kt=(nt=Be.features[Be.features.length-1])==null?void 0:nt.properties)==null?void 0:kt.key)??""}`;(ie||Ge!==IA.current)&&(Ze.setData(Be),IA.current=Ge)}if(Ce&&VA.current.length>0){const Be=Ys(VA.current,JA.current),Ge=`${Be.features.length}:${((Xe=(Qe=Be.features[0])==null?void 0:Qe.properties)==null?void 0:Xe.hash)??""}`;(ie||Ge!==NA.current)&&(Ce.setData(Be),NA.current=Ge)}},[E,L,Z]),Ie=j.useCallback(()=>{sA.current&&(cancelAnimationFrame(sA.current),sA.current=null),eA.current=new Map,Y.current=1,cA.current=new Map,lA.current=new Map,bA.current=!1,DA.current=new Set,TA.current="",CA.current=new Map},[]);j.useEffect(()=>{const ie=fA.current,ge=c;if(fA.current=c,!!oA.current){if(sA.current&&(cancelAnimationFrame(sA.current),sA.current=null),ie&&!ge&&!bA.current){bA.current=!0;const Ze=new Map(eA.current);let Ce=null;const Ee=Me=>{Ce||(Ce=Me);const ye=Me-Ce,$e=Math.min(ye/uc,1),Je=Po($e);for(const[At,nt]of Ze)eA.current.set(At,nt*(1-Je));UA(!0),$e<1?sA.current=requestAnimationFrame(Ee):(bA.current=!1,eA.current=new Map,DA.current=new Set,TA.current="",cA.current=new Map,lA.current=new Map,sA.current=null,UA(!0))};sA.current=requestAnimationFrame(Ee)}!ie&&ge&&(eA.current=new Map,DA.current=new Set,TA.current="")}},[c,UA]),j.useEffect(()=>{const ie=oA.current;if(!c||bA.current||!ie)return;const ge=[...p,...y],be=ge.map(ye=>`${ye.edge.key}:${ye.edge.certainCount}`).sort().join(","),Ze=DA.current.size===0,Ce=TA.current!==""&&TA.current!==be;if(!Ze&&!Ce){UA();return}const Ee=[],Me=[];for(const{edge:ye}of ge)DA.current.has(ye.key)?Me.push(ye.key):Ee.push(ye.key);Ce&&Me.length>0&&(cA.current=new Map(CA.current),Y.current=0),lA.current=new Map;for(const{edge:ye}of p){const $e=bi(ye.certainCount);lA.current.set(ye.key,$e)}for(const ye of Ee)eA.current.set(ye,0);for(const ye of Me)eA.current.has(ye)||eA.current.set(ye,1);if(Ee.length>0||Ce&&Me.length>0){sA.current&&(cancelAnimationFrame(sA.current),sA.current=null);let ye=null;const $e=Math.min(100,Sn/Math.max(Ee.length,1)/2),Je=At=>{ye||(ye=At);const nt=At-ye;for(let Qe=0;Qe0){const Qe=Math.min(nt/Sn,1);Y.current=wi(Qe)}UA(!0);const kt=Sn+(Ee.length-1)*$e;nt{const ie=oA.current;if(!ie||!Z)return;const ge=()=>{const Ce=ie.getSource(Z);if(!Ce)return!1;if(O.length>0){const Ee=Ys(O,V);Ce.setData(Ee)}else Ce.setData({type:"FeatureCollection",features:[]});return!0};if(ge())return;const be=Ce=>{Ce.sourceId===Z&&ge()&&ie.off("sourcedata",be)};ie.on("sourcedata",be);const Ze=()=>{ge()&&(ie.off("styledata",Ze),ie.off("sourcedata",be))};return ie.on("styledata",Ze),()=>{ie.off("sourcedata",be),ie.off("styledata",Ze)}},[Z,O,V]);const Le=j.useRef(AA);return j.useEffect(()=>{AA!==Le.current&&(Le.current=AA,mA.current="",IA.current="",NA.current="",UA(!0))},[AA,UA]),j.useEffect(()=>()=>{sA.current&&(cancelAnimationFrame(sA.current),sA.current=null)},[]),{isExiting:bA.current,isAnimating:sA.current!==null,resetAnimationState:Ie,weightAnimProgress:Y.current,animStartWeights:cA.current,animTargetWeights:lA.current}}function $2({activeFilters:u,neighborHashes:c,hubConnectedNodes:p,directNodeSet:y,localConnectedNodes:x,nodeTypeMap:C,showTopology:T}){const[Q,D]=j.useState(new Map),E=j.useMemo(()=>[...u].sort().join(","),[u]),L=j.useRef(E),O=j.useRef(!1),z=j.useRef(new Map),Z=j.useRef(null),V=j.useRef(p),AA=j.useRef(y),oA=j.useRef(x),eA=j.useRef(C),Y=j.useRef(T);return j.useEffect(()=>{V.current=p,AA.current=y,oA.current=x,eA.current=C,Y.current=T},[p,y,x,C,T]),j.useEffect(()=>{const lA=L.current,bA=E;if(L.current=E,lA===bA)return;Z.current&&(cancelAnimationFrame(Z.current),Z.current=null);const sA=new Set(lA?lA.split(",").filter(Boolean):[]),fA=u,DA=V.current,TA=AA.current,CA=eA.current;for(const vA of c)z.current.has(vA)||z.current.set(vA,Math.random());const mA=(vA,uA)=>{if(uA.size===0)return!1;const hA=CA.get(vA)??"unknown";return!!(uA.has("repeater")&&hA==="repeater"||uA.has("companion")&&(hA==="companion"||hA==="unknown")||uA.has("room_server")&&hA==="room_server"||uA.has("direct")&&TA.has(vA)||uA.has("hubs")&&DA.has(vA))},IA=[];for(const vA of c){const uA=mA(vA,sA),hA=mA(vA,fA);uA!==hA&&IA.push({hash:vA,startOpacity:uA?1:0,targetOpacity:hA?1:0})}if(IA.length===0)return;O.current=!0,D(vA=>{const uA=new Map(vA);for(const{hash:hA,startOpacity:jA}of IA)uA.set(hA,jA);return uA});const NA=IA;let FA=null;const GA=vA=>{FA||(FA=vA);const uA=vA-FA;let hA=!0;D(()=>{const BA=new Map;for(const{hash:VA,startOpacity:ue,targetOpacity:JA}of NA){const KA=(z.current.get(VA)??0)*ws,UA=Math.max(0,uA-KA),Ie=Math.min(UA/xs,1),Le=wi(Ie),ie=ue+(JA-ue)*Le;BA.set(VA,ie),Ie<1&&(hA=!1)}return BA});const jA=xs+ws;uA{Z.current&&(cancelAnimationFrame(Z.current),Z.current=null),O.current=!1}},[E,u,c]),{nodeOpacities:Q,getNodeOpacity:(lA,bA)=>O.current&&Q.has(lA)?Q.get(lA):bA?1:0}}const mi=240,Ks=240;function q2(u,c){if(u[c,c]))}function X2(u,c,p){const y=p?b0(p):null,x=[];for(const C of u){if(y&&Bo(C.toUpperCase(),y)){p&&x.push(p);continue}const T=c.get(C.toUpperCase());T&&x.push(T)}return x}function A1({neighbors:u,localHash:c,enabled:p=!0}){const[y,x]=j.useState(new Map),C=ki(),T=j.useRef(C);j.useEffect(()=>{T.current=C},[C]);const Q=j.useRef(0),D=j.useRef(null),E=j.useRef(new Map),L=j.useRef(new Map);j.useEffect(()=>{L.current=J2(u)},[u]);const O=j.useRef(null);return j.useEffect(()=>{const z=()=>{const Z=performance.now(),V=E.current;if(V.size===0){D.current=null,x(new Map);return}const AA=new Map,oA=[];for(const[eA,{startTime:Y,staggerDelay:cA}]of V){const lA=Z-Y-cA;if(!(lA<0))if(lA>=Mn)oA.push(eA);else{const bA=q2(lA,Mn);bA>0&&AA.set(eA,bA)}}for(const eA of oA)V.delete(eA);x(AA),V.size>0&&O.current?D.current=requestAnimationFrame(O.current):D.current=null};O.current=z},[]),j.useEffect(()=>{if(!p)return;const z=T.current;if(z.length===0)return;const Z=Q.current,V=z.filter(Y=>(Y.timestamp??0)>Z);if(Z===0){const Y=z.reduce((cA,lA)=>Math.max(cA,lA.timestamp??0),0);Q.current=Y;return}if(V.length===0)return;const AA=V.reduce((Y,cA)=>Math.max(Y,cA.timestamp??0),0);Q.current=AA;const oA=performance.now();let eA=0;for(const Y of V){const cA=Mo(Y,c);if(!cA||cA.original.length===0)continue;const lA=X2(cA.original,L.current,c);if(lA.length===0)continue;const bA=Mn*.5;for(let sA=0;sA()=>{D.current!==null&&(cancelAnimationFrame(D.current),D.current=null)},[]),{blinkingNodes:y,blinkColor:ac}}const Z0="edge-blink-source",gr="edge-blink-layer",Bi=1e3,Di=1e3,gi=150,e1=175,t1=3e4,r1=i0.teal,n1="#8B7BAD",i1=2.5,s1=1.875,o1=.5,Hn="node-markers-layer";function l1(u){if(!u.getLayer(gr))return;const c=u.getLayer(Hn)?Hn:void 0;try{u.moveLayer(gr,c)}catch{}}function a1(u,c){const p=new Map;for(const y of Object.keys(u)){const x=b0(y);p.has(x)||p.set(x,y)}if(c){const y=b0(c);p.set(y,c)}return p}function u1(u){return u<0||u>=Bi?0:1-u/Bi}function c1(u){if(u<0||u>=Di)return 0;const c=u/Di;return Math.pow(1-c,3)}function In(u){return[u[1],u[0]]}function f1({map:u,nodeCoordinates:c,packets:p,localHash:y,neighbors:x,meshTopology:C,enabled:T=!0}){const Q=j.useRef(null),D=u&&"current"in u?u.current:u;j.useEffect(()=>{Q.current=D},[D]);const E=j.useRef(!1),L=j.useRef(null),O=j.useRef([]),z=j.useRef(0),Z=j.useRef(!1),[V,AA]=j.useState(!1),oA=j.useRef(null),eA=j.useRef([]),Y=j.useRef(new Map),cA=j.useRef(c);j.useEffect(()=>{cA.current=c},[c]),j.useEffect(()=>{Y.current=a1(x,y)},[x,y]),j.useEffect(()=>{if(!T){oA.current&&(clearTimeout(oA.current),oA.current=null),eA.current=[],L.current!==null&&(cancelAnimationFrame(L.current),L.current=null),O.current=[];const fA=Q.current;if(fA&&E.current){const DA=fA.getSource(Z0);DA&&DA.setData({type:"FeatureCollection",features:[]})}Z.current=!1,z.current=0}},[T]),j.useEffect(()=>{const fA=D;if(!fA)return;let DA=null,TA=!1;const CA=()=>{if(!TA&&!E.current)try{fA.getLayer(gr)&&fA.removeLayer(gr),fA.getSource(Z0)&&fA.removeSource(Z0),fA.addSource(Z0,{type:"geojson",data:{type:"FeatureCollection",features:[]}});const mA=fA.getLayer(Hn)?Hn:void 0;fA.addLayer({id:gr,type:"line",source:Z0,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":["case",["any",["==",["get","isSpeculative"],!0],["==",["get","isSpeculative"],"true"]],n1,r1],"line-width":["case",["any",["==",["get","isSpeculative"],!0],["==",["get","isSpeculative"],"true"]],s1,i1],"line-opacity":["*",["get","opacityMult"],["interpolate",["linear"],["get","intensity"],0,0,.1,.8,.5,1,1,1]]}},mA),E.current=!0,AA(!0),DA&&(clearInterval(DA),DA=null)}catch{}};return fA.isStyleLoaded()&&CA(),fA.once("style.load",()=>{CA()}),E.current||(DA=setInterval(()=>{if(E.current){DA&&clearInterval(DA);return}CA()},100),setTimeout(()=>{DA&&(clearInterval(DA),DA=null)},5e3)),()=>{TA=!0,DA&&clearInterval(DA),L.current!==null&&(cancelAnimationFrame(L.current),L.current=null);const mA=Q.current;if(mA&&E.current){try{mA.getLayer(gr)&&mA.removeLayer(gr),mA.getSource(Z0)&&mA.removeSource(Z0)}catch{}E.current=!1,AA(!1)}}},[D]);const lA=j.useRef(()=>{});j.useEffect(()=>{lA.current=()=>{const fA=Q.current;if(!fA)return;const DA=fA.getSource(Z0);if(!DA)return;const TA=performance.now(),CA=O.current,mA=[],IA=[];for(const NA of CA){const FA=TA-NA.startTime-NA.delay,GA=NA.isSpeculative?Di:Bi;if(FA0&&mA.push({type:"Feature",properties:{intensity:vA,opacityMult:NA.isSpeculative?o1:1,isSpeculative:NA.isSpeculative??!1},geometry:{type:"LineString",coordinates:[NA.fromCoord,NA.toCoord]}})}}DA.setData({type:"FeatureCollection",features:mA}),O.current=IA,IA.length>0?L.current=requestAnimationFrame(()=>lA.current()):L.current=null}},[]);const bA=j.useCallback(()=>{const fA=Q.current;fA&&l1(fA),L.current===null&&(L.current=requestAnimationFrame(()=>lA.current()))},[]),sA=j.useCallback(()=>{if(!Q.current||!E.current)return;const DA=eA.current;if(eA.current=[],oA.current=null,DA.length===0)return;const TA=Y.current,CA=cA.current;if(TA.size===0)return;const mA=performance.now();let IA=0,NA=!1;const FA=new Set;for(const GA of DA){const vA=Mo(GA,y);if(!vA||vA.original.length<2)continue;const uA=vA.original;let hA=0,jA=null;for(let JA=0;JA0){JA.sort((Le,ie)=>ie.confidence-Le.confidence);const KA=Math.max(1,Math.ceil(JA.length*.25)),UA=JA.slice(0,KA),Ie=IA+hA*gi;for(const{edgeKey:Le,otherHash:ie}of UA){const ge=CA.get(jA),be=CA.get(ie);O.current.push({edgeKey:Le,fromCoord:In(ge),toCoord:In(be),startTime:mA,delay:Ie,isSpeculative:!0}),FA.add(Le),NA=!0}}}hA>0&&(IA+=hA*gi*.5)}NA&&bA()},[y,C,bA]);j.useEffect(()=>{const fA=Q.current;if(!T||!fA||!V||p.length===0)return;const DA=Date.now(),TA=z.current;if(!Z.current){Z.current=!0;const IA=(DA-t1)/1e3,NA=p.filter(GA=>(GA.timestamp??0)>=IA);let FA=0;for(const GA of p){const vA=GA.timestamp??0;vA>FA&&(FA=vA)}if(z.current=FA,NA.length>0){NA.sort((vA,uA)=>(vA.timestamp??0)-(uA.timestamp??0));const GA=NA.slice(-20);eA.current.push(...GA),sA()}return}const CA=p.filter(IA=>(IA.timestamp??0)>TA);if(CA.length===0)return;let mA=0;for(const IA of CA){const NA=IA.timestamp??0;NA>mA&&(mA=NA)}z.current=mA,eA.current.push(...CA),oA.current&&clearTimeout(oA.current),oA.current=setTimeout(sA,e1)},[T,p,sA,V]),j.useEffect(()=>()=>{oA.current&&clearTimeout(oA.current)},[])}var $0={},hr={};/** + * @license React + * react-dom-server-legacy.browser.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 Zs;function h1(){if(Zs)return hr;Zs=1;var u=Do();function c(h){for(var v="https://reactjs.org/docs/error-decoder.html?invariant="+h,_=1;_