local-operator-ui 0.41.0 → 0.41.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/out/main/index.js +0 -24
  2. package/out/renderer/assets/{_basePickBy--UFblcLV.js → _basePickBy-BP7Q8i4W.js} +1 -1
  3. package/out/renderer/assets/{_baseUniq-Ct7pRnI4.js → _baseUniq-D36dAcoY.js} +1 -1
  4. package/out/renderer/assets/{agent-details-page-Col1VcjS.js → agent-details-page-D3ljlPdf.js} +2 -2
  5. package/out/renderer/assets/{agent-hub-page-CTPn6yGs.js → agent-hub-page-BMyIHnNM.js} +2 -2
  6. package/out/renderer/assets/{agents-page-CBWj1DTr.js → agents-page-mMqgQd2V.js} +3 -3
  7. package/out/renderer/assets/{arc-B-YNVaQW.js → arc-GVvow4so.js} +1 -1
  8. package/out/renderer/assets/{architectureDiagram-IEHRJDOE-DCzmuMLj.js → architectureDiagram-IEHRJDOE-BjGwXAtH.js} +1 -1
  9. package/out/renderer/assets/{blockDiagram-JOT3LUYC-f1GS2_U0.js → blockDiagram-JOT3LUYC-BTuigKlt.js} +1 -1
  10. package/out/renderer/assets/{book-open-Cb4F-cRs.js → book-open-C1uak1LZ.js} +1 -1
  11. package/out/renderer/assets/browser-page-B3mjDx8k.js +1 -0
  12. package/out/renderer/assets/{browser-webauthn-prompt-ghcPWp0R.js → browser-webauthn-prompt-CzYoJfO4.js} +1 -1
  13. package/out/renderer/assets/{building-2-C_YBTC7O.js → building-2-Bpz1qaDa.js} +1 -1
  14. package/out/renderer/assets/{c4Diagram-VJAJSXHY-BlePs8Im.js → c4Diagram-VJAJSXHY-DK7eaKE8.js} +1 -1
  15. package/out/renderer/assets/channel-B05rL6In.js +1 -0
  16. package/out/renderer/assets/{chunk-4BMEZGHF-Bse1IaHb.js → chunk-4BMEZGHF-DkQrsDhM.js} +1 -1
  17. package/out/renderer/assets/{chunk-A2AXSNBT-CncpJ5It.js → chunk-A2AXSNBT-guh0INPR.js} +1 -1
  18. package/out/renderer/assets/{chunk-AEK57VVT-37Z6jWz2.js → chunk-AEK57VVT-DvgIx6-r.js} +1 -1
  19. package/out/renderer/assets/{chunk-D6G4REZN-BR9ZpBMV.js → chunk-D6G4REZN-FNdvnFYo.js} +1 -1
  20. package/out/renderer/assets/{chunk-RZ5BOZE2-KrZ6g0pV.js → chunk-RZ5BOZE2-CgCQC9Mn.js} +1 -1
  21. package/out/renderer/assets/{chunk-XZIHB7SX-BUwRYMe9.js → chunk-XZIHB7SX-D1VRTTc4.js} +1 -1
  22. package/out/renderer/assets/classDiagram-GIVACNV2-DpB8-8cT.js +1 -0
  23. package/out/renderer/assets/classDiagram-v2-COTLJTTW-DpB8-8cT.js +1 -0
  24. package/out/renderer/assets/clone-BHHjv3HP.js +1 -0
  25. package/out/renderer/assets/{console-mirror-DPVG6sWK.js → console-mirror-DRkz3vUY.js} +1 -1
  26. package/out/renderer/assets/{consoleCapture-Coky9UhD.js → consoleCapture-BJfSUatx.js} +1 -1
  27. package/out/renderer/assets/{conversation-input-sync-C2vqs6ad.js → conversation-input-sync-CJU5GIzR.js} +5 -5
  28. package/out/renderer/assets/{dagre-OKDRZEBW-CGv1CEcm.js → dagre-OKDRZEBW-DeeYQh6O.js} +1 -1
  29. package/out/renderer/assets/{diagram-SSKATNLV-u_zFGYu8.js → diagram-SSKATNLV-DD-xNxKH.js} +1 -1
  30. package/out/renderer/assets/{diagram-VNBRO52H-Bme6bFvQ.js → diagram-VNBRO52H-YAoPlXaR.js} +1 -1
  31. package/out/renderer/assets/{erDiagram-Q7BY3M3F-B-KkjVtc.js → erDiagram-Q7BY3M3F-OKzGXyMI.js} +1 -1
  32. package/out/renderer/assets/{error-boundary-DJSaJHcb.js → error-boundary-ZYkSCpZC.js} +2 -2
  33. package/out/renderer/assets/{flowDiagram-4HSFHLVR-CSZy2b_d.js → flowDiagram-4HSFHLVR-BG-3pPqS.js} +1 -1
  34. package/out/renderer/assets/{ganttDiagram-APWFNJXF-CpYOSVKU.js → ganttDiagram-APWFNJXF-CRyD5vsE.js} +1 -1
  35. package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-WOOSBsBb.js → gitGraphDiagram-7IBYFJ6S-aly2C__q.js} +1 -1
  36. package/out/renderer/assets/{graph-Du8nFp-Q.js → graph-CCWwMmhg.js} +1 -1
  37. package/out/renderer/assets/hash-BN0ECl3H.js +6 -0
  38. package/out/renderer/assets/{heart-CVGkdUzT.js → heart-tKYqMVIH.js} +1 -1
  39. package/out/renderer/assets/index-BDzV3bGH.js +57 -0
  40. package/out/renderer/assets/{index-fw54FEnm.js → index-BaNzqqGN.js} +1 -1
  41. package/out/renderer/assets/{index-D8L83jtw.js → index-CRjnV9wx.js} +199 -199
  42. package/out/renderer/assets/{index-AGCqaeOI.js → index-DaCf2W9T.js} +1 -1
  43. package/out/renderer/assets/index-ZovyVTxQ.css +1 -0
  44. package/out/renderer/assets/{infoDiagram-PH2N3AL5-BprulvMk.js → infoDiagram-PH2N3AL5-BY536sF5.js} +1 -1
  45. package/out/renderer/assets/{installer-muZhWyyS.js → installer-Dw1P6j8q.js} +1 -1
  46. package/out/renderer/assets/{journeyDiagram-U35MCT3I-DfdLRQAF.js → journeyDiagram-U35MCT3I-DGvx__t6.js} +1 -1
  47. package/out/renderer/assets/{kanban-definition-NDS4AKOZ-R6IsuYWB.js → kanban-definition-NDS4AKOZ-CG2Lgkpw.js} +1 -1
  48. package/out/renderer/assets/{layout-05Xak_7z.js → layout-vpRrwE7T.js} +1 -1
  49. package/out/renderer/assets/{legacy-agents-page-Dpl33Kla.js → legacy-agents-page-D6Yma1Gm.js} +6 -6
  50. package/out/renderer/assets/library-page-B0gC-rRh.js +157 -0
  51. package/out/renderer/assets/{mermaid.core-BzKfajYZ.js → mermaid.core-COeGB8I0.js} +5 -5
  52. package/out/renderer/assets/{mesh-page-D6ZzFOeG.js → mesh-page-PabU05tN.js} +1 -1
  53. package/out/renderer/assets/{mindmap-definition-ALO5MXBD-Dn_l0i7j.js → mindmap-definition-ALO5MXBD-B0hkjZLY.js} +1 -1
  54. package/out/renderer/assets/{mini-BgJE9L7J.js → mini-Df5C4rpd.js} +1 -1
  55. package/out/renderer/assets/{notebook-pen-CtAKsfVm.js → notebook-pen-C3CwzwGA.js} +1 -1
  56. package/out/renderer/assets/{org-access-BHt55LAw.js → org-access-BacMtLkn.js} +1 -1
  57. package/out/renderer/assets/{org-surface-gate-CqFJQYmV.js → org-surface-gate-tkB025lu.js} +1 -1
  58. package/out/renderer/assets/{page-header-BlIvE-Ti.js → page-header-6mrV9W-E.js} +1 -1
  59. package/out/renderer/assets/{path-utils-CYBk4q7C.js → path-utils-Ct0VTUZS.js} +2 -2
  60. package/out/renderer/assets/{pieDiagram-IB7DONF6-_W_OzAAk.js → pieDiagram-IB7DONF6-DfFtQXU5.js} +1 -1
  61. package/out/renderer/assets/{projects-page-DtZ_g9gZ.js → projects-page-CoHTKLZH.js} +1 -1
  62. package/out/renderer/assets/{publication-validation-D7f3xAgF.js → publication-validation-B0Mf3mmP.js} +1 -1
  63. package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-FQ5Wvxqm.js → quadrantDiagram-7GDLP6J5-C4eDJWaK.js} +1 -1
  64. package/out/renderer/assets/{radar-MK3ICKWK-BRufXucA.js → radar-MK3ICKWK-BEv1HS9Q.js} +1 -1
  65. package/out/renderer/assets/{radient-auth-buttons-7i7blC-7.js → radient-auth-buttons-BX5vf982.js} +1 -1
  66. package/out/renderer/assets/{requirementDiagram-KVF5MWMF-CHO8Cq1H.js → requirementDiagram-KVF5MWMF-B7f3qUcB.js} +1 -1
  67. package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-C4JDJOwX.js → sankeyDiagram-QLVOVGJD-xM7E-74l.js} +1 -1
  68. package/out/renderer/assets/{schedules-page-6tPgFgS_.js → schedules-page-5q7pvL1H.js} +1 -1
  69. package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-BFf3HnKw.js → sequenceDiagram-X6HHIX6F-upwR02kU.js} +1 -1
  70. package/out/renderer/assets/{settings-page-CXOFCx8w.js → settings-page-DcnGr-GP.js} +9 -9
  71. package/out/renderer/assets/{smartart-crAq3DvJ.js → smartart-CYnMNs5u.js} +1 -1
  72. package/out/renderer/assets/{stateDiagram-DGXRK772-BqFVSIKA.js → stateDiagram-DGXRK772-BqTri7Q-.js} +1 -1
  73. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-D8Sl1QhX.js +1 -0
  74. package/out/renderer/assets/team-bridge-page-vnNJdCi3.js +16 -0
  75. package/out/renderer/assets/{timeline-definition-BDJGKUSR-Cp3uYUSs.js → timeline-definition-BDJGKUSR-Bi2is17s.js} +1 -1
  76. package/out/renderer/assets/{use-download-agent-mutation-C_W8yx0C.js → use-download-agent-mutation-PHtokPlg.js} +2 -2
  77. package/out/renderer/assets/{use-session-snapshot-vFZD5qIO.js → use-session-snapshot-B5sxthdQ.js} +1 -1
  78. package/out/renderer/assets/{xychartDiagram-VJFVF3MP-DFcICu1Q.js → xychartDiagram-VJFVF3MP-B0TrjzLJ.js} +1 -1
  79. package/out/renderer/console-capture.html +5 -5
  80. package/out/renderer/index.html +7 -7
  81. package/out/renderer/installer.html +4 -4
  82. package/out/renderer/mini.html +7 -7
  83. package/package.json +2 -2
  84. package/out/renderer/assets/browser-page-BfJd3-qS.js +0 -1
  85. package/out/renderer/assets/channel-BFAjMbH6.js +0 -1
  86. package/out/renderer/assets/classDiagram-GIVACNV2-CmW0Ezdi.js +0 -1
  87. package/out/renderer/assets/classDiagram-v2-COTLJTTW-CmW0Ezdi.js +0 -1
  88. package/out/renderer/assets/clone-B_pc7cSP.js +0 -1
  89. package/out/renderer/assets/hash--PQTQMu2.js +0 -6
  90. package/out/renderer/assets/index-ALGblIL0.css +0 -1
  91. package/out/renderer/assets/index-BYeiLB51.js +0 -57
  92. package/out/renderer/assets/library-page-BNrffbLi.js +0 -157
  93. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-aaVC-oiG.js +0 -1
  94. package/out/renderer/assets/team-bridge-page-BgjJrT3v.js +0 -26
@@ -1 +1 @@
1
- import{r as x,j as s,t as n,c as P}from"./index-BYeiLB51.js";import{G as is,H as ee,I as rs,R as ls,J as pe,K as Fe,L as qe,M as Be,N as Ye,a as os,O as _e,w as ke,T as ds}from"./path-utils-CYBk4q7C.js";import{P as cs}from"./page-header-BlIvE-Ti.js";import{u as F,B as U,A as fe,p as us,h as oe,q as ms,r as hs,s as ps,t as xs,v as Me,w as De,k as Ee}from"./error-boundary-DJSaJHcb.js";import{C as he,D as fs,E as gs,F as bs,G as vs,I as _s,J as ks,K as ws,L as js,M as ys,N as Ns,O as Is,Q as Cs,R as Ss,T as Ne,U as Ms,V as Ds,W as Ie,X as Ge,Y as Ue,Z as Es,_ as xe,$ as we,a0 as Rs,a1 as As,a2 as ge,a3 as Re,a4 as Ls,a5 as Ps,a6 as je,a7 as Ts,a8 as Ke,a9 as be,aa as $s,ab as Ve,ac as Os,ad as zs,ae as Hs,af as Ws,ag as Fs,ah as qs,ai as Bs,aj as Ys,ak as Gs,al as Us,am as Ks,an as Vs,ao as Xs,ap as Zs,aq as Js,ar as Qs,as as et,at as st,au as tt,av as me,aw as nt}from"./index-D8L83jtw.js";import{aw as Xe,ax as Ce,ay as at,az as Ze}from"./conversation-input-sync-C2vqs6ad.js";import"./console-mirror-DPVG6sWK.js";function it(e){return e==="failed"?"text-danger":he(e)?"text-ink-muted":"text-ink-dim"}function rt(e){return e==="failed"?n("ui.mesh.mesh_approvals_tray.abandon"):n("ui.mesh.mesh_approvals_tray.stop")}function lt(e){switch(e){case"requested":return[{term:n("ui.mesh.mesh_approvals_tray.signing"),text:n("ui.mesh.mesh_approvals_tray.approving_signs_with_this_machine_s_operator")}];case"approved":return[{term:n("ui.mesh.mesh_approvals_tray.next"),text:n("ui.mesh.mesh_approvals_tray.an_agent_runs_the_install_and_connect")},{term:n("ui.mesh.mesh_approvals_tray.stop"),text:n("ui.mesh.mesh_approvals_tray.stopping_now_denies_the_request_nothing_has")}];case"connecting":return[{term:n("ui.mesh.mesh_approvals_tray.stop"),text:n("ui.mesh.mesh_approvals_tray.stopping_now_denies_the_request_the_runner")}];case"failed":return[{term:n("ui.mesh.mesh_approvals_tray.after_a_stop"),text:n("ui.mesh.mesh_approvals_tray.the_runner_stopped_before_it_finished_abandoning")}];default:return[]}}const ot=({rows:e,error:t,pending:a,refusal:o,onDecide:h,onRetry:m,nowSeconds:f,networkNames:d})=>{F();const v=a!==null,b=x.useMemo(()=>e.filter(r=>he(r.state)),[e]),w=x.useMemo(()=>e.filter(r=>!he(r.state)),[e]),[E,I]=x.useState(!1),c=x.useRef(null),u=x.useRef(null),p=x.useRef(null),y=(r,N)=>{N==="deny"&&b.some(R=>R.approvalId===r&&R.kind==="credential")&&(p.current={id:r,origin:document.activeElement,sawPending:!1}),h(r,N)};x.useLayoutEffect(()=>{const r=p.current;if(!r)return;if(a?.approvalId===r.id&&(r.sawPending=!0),o?.approvalId===r.id){p.current=null;return}const N=e.find(C=>C.approvalId===r.id);if(N?.state==="requested"){!a&&r.sawPending&&(p.current=null);return}if(N?.state==="denied"&&a||(p.current=null,N?.state!=="denied"||document.activeElement!==document.body&&document.activeElement!==r.origin))return;(b.length?c.current?.querySelector('[data-tour-tag="mesh-approval-controls"] button:not(:disabled)'):u.current?.querySelector("button"))?.focus({preventScroll:!0})},[e,a,o,b.length]);const j=w.some(r=>r.state==="failed"),M=w.filter(r=>r.state==="failed").length,D=o!==null&&e.some(r=>r.approvalId===o.approvalId&&(he(r.state)||E));return b.length===0&&w.length===0&&!t&&!o?null:s.jsxs("section",{ref:c,"aria-label":n("ui.mesh.mesh_approvals_tray.approvals"),"data-tour-tag":"mesh-approvals-tray",className:"flex flex-col gap-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(fs,{"aria-hidden":"true",className:"size-4 text-ink-muted"}),s.jsx("h2",{className:"text-body-sm text-ink",children:n("ui.mesh.mesh_approvals_tray.approvals")}),b.length>0&&s.jsx("span",{className:"text-meta text-ink-dim",children:n("ui.mesh.mesh_approvals_tray.waiting_count",{count:b.length})})]}),t&&s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("p",{className:"min-w-0 flex-1 text-meta text-ink-muted",children:t}),s.jsx(U,{variant:"secondary",size:"sm",onClick:m,children:n("ui.mesh.mesh_approvals_tray.ask_again")})]}),b.length>0&&s.jsx("ul",{className:"flex flex-col divide-y divide-hairline",children:b.map(r=>s.jsx(Ae,{row:r,pending:a?.approvalId===r.approvalId?a:null,busy:v,refusal:o?.approvalId===r.approvalId?o:null,onDecide:y,nowSeconds:f,networkNames:d},r.approvalId))}),o&&!D&&s.jsx(Je,{refusal:o}),w.length>0&&s.jsx("div",{ref:u,children:s.jsx(Xe,{open:E,onOpenChange:I,chevronClassName:"text-ink-dim",className:P(b.length>0&&"border-hairline border-t pt-3"),summary:s.jsxs("span",{className:"flex items-center gap-1.5 text-meta text-ink-muted",children:[n("ui.mesh.mesh_approvals_tray.settled_approvals"),s.jsxs("span",{className:"text-ink-dim",children:["(",w.length,")"]}),j&&s.jsx("span",{"aria-hidden":"true",className:"size-1.5 rounded-full bg-danger"}),M>0&&s.jsx("span",{className:"text-danger",children:n("ui.mesh.mesh_approvals_tray.failed_count",{count:M})})]}),children:s.jsx("ul",{className:"flex flex-col divide-y divide-hairline","data-tour-tag":"mesh-approvals-records",children:w.map(r=>s.jsx(Ae,{row:r,pending:a?.approvalId===r.approvalId?a:null,busy:v,refusal:o?.approvalId===r.approvalId?o:null,onDecide:y,nowSeconds:f,networkNames:d},r.approvalId))})})})]})},Ae=({row:e,pending:t,busy:a,refusal:o,onDecide:h,nowSeconds:m,networkNames:f})=>{F();const d=he(e.state),v=gs(e),b=bs(e,f),w=vs(e,f),E=_s(e),I=ks(e),c=ws(e),u=js(e.expiresAt,m),p=e.kind==="credential"||e.kind==="unknown",y=p||e.canApproveHere===!1,j=y?[]:lt(e.state),M=ys(e),D=Ns(e.state);return s.jsxs("li",{className:"flex flex-col gap-2 py-3 first:pt-0 last:pb-0","data-tour-tag":"mesh-approval-card",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:P("text-meta",it(e.state)),children:e.kind==="credential"&&e.state==="approved"?n("ui.mesh.approval.approved_pending_apply"):Is(e.state)}),s.jsx("div",{className:"grow"}),d&&u&&s.jsx("span",{className:"text-meta text-ink-dim",children:e.kind==="credential"?n("ui.mesh.approval.request_window",{remaining:u}):u})]}),s.jsx("p",{className:"text-body-sm text-ink [overflow-wrap:anywhere]","data-tour-tag":"mesh-approval-summary",children:d?b:v}),!y&&e.state==="failed"&&s.jsx("p",{className:"text-meta text-ink-muted","data-tour-tag":"mesh-approval-stopped-note",children:n("ui.mesh.mesh_approvals_tray.the_runner_stopped_before_it_finished_it")}),d&&y&&s.jsx("p",{className:"text-meta text-ink-muted whitespace-pre-wrap [overflow-wrap:anywhere]","data-tour-tag":"mesh-approval-cli-remedy",children:e.approveRemedy||n("ui.mesh.approval.cli_review")}),e.kind==="credential"&&e.state==="approved"&&s.jsx("p",{className:"text-meta text-ink-muted","data-tour-tag":"mesh-approval-apply-hint",children:e.details?.length?n("ui.mesh.approval.approved_apply_hint"):n("ui.mesh.approval.approved_details_missing")}),(M||D)&&s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[M&&s.jsx(U,{variant:"primary",size:"sm",disabled:a,onClick:()=>h(e.approvalId,"approve"),"data-tour-tag":"mesh-approval-approve",children:n("ui.mesh.mesh_approvals_tray.approve")}),D&&s.jsx(U,{variant:"ghost",size:"sm",disabled:a,onClick:()=>h(e.approvalId,"deny"),"data-tour-tag":d?"mesh-approval-deny":"mesh-approval-stop",children:d?n("ui.mesh.mesh_approvals_tray.deny"):rt(e.state)}),t&&s.jsx("span",{className:"text-meta text-ink-dim",children:t.decision==="approve"?n("ui.mesh.mesh_approvals_tray.waiting_for_the_signing_prompt"):n("ui.mesh.mesh_approvals_tray.writing_the_decision")})]}),s.jsxs(Xe,{chevronClassName:"text-ink-dim",summary:s.jsx("span",{className:"text-meta",children:n("ui.mesh.mesh_approvals_tray.details")}),children:[p&&(e.details?.length?s.jsx("ul",{className:"flex flex-col gap-1.5 text-meta text-ink-muted [overflow-wrap:anywhere]","data-tour-tag":"mesh-approval-server-details",children:e.details.map((r,N)=>s.jsx("li",{className:"whitespace-pre-wrap",children:r},`${N}:${r}`))}):s.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.mesh.approval.details_unavailable")})),w.length>0&&s.jsx("dl",{className:"grid grid-cols-[max-content_1fr] gap-x-4 gap-y-0.5 text-meta text-ink-dim","data-tour-tag":"mesh-approval-consequences",children:w.map(r=>s.jsxs(x.Fragment,{children:[s.jsx("dt",{className:"text-ink-muted",children:r.term}),s.jsx("dd",{children:r.consequence})]},r.term))}),(E||I)&&s.jsxs("p",{className:"text-meta text-ink-muted",children:[E&&s.jsx("span",{children:E}),E&&I&&s.jsx("span",{children:" · "}),I&&s.jsx("span",{className:"font-mono",children:I})]}),c&&s.jsx("p",{className:"text-meta text-ink-dim",children:c}),j.length>0&&s.jsx("dl",{className:"grid grid-cols-[max-content_1fr] gap-x-4 gap-y-0.5 text-meta","data-tour-tag":"mesh-approval-consequence",children:j.map(r=>s.jsxs(x.Fragment,{children:[s.jsx("dt",{className:"text-ink-muted",children:r.term}),s.jsx("dd",{className:"text-ink-muted",children:r.text})]},r.term))})]}),o&&s.jsx(Je,{refusal:o})]})},Je=({refusal:e})=>(F(),s.jsx(fe,{variant:"warning",className:"text-meta","data-tour-tag":"mesh-approval-refusal",children:s.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsx("span",{className:"min-w-0 flex-1",children:e.sentence}),s.jsx("span",{className:"shrink-0 font-mono text-ink-dim",children:e.code})]})})),dt=4,ve={kind:"idle"};function ct(e){switch(e.kind){case"dragging":case"settling":return e.payload.session.id;case"pressing":return null;default:return null}}function Q(e,t){switch(t.kind){case"press":return e.kind!=="idle"?e:{kind:"pressing",payload:t.payload,originX:t.x,originY:t.y,pointerId:t.pointerId};case"move":return e.kind==="pressing"?Math.max(Math.abs(t.x-e.originX),Math.abs(t.y-e.originY))<dt?e:{kind:"dragging",payload:e.payload,x:t.x,y:t.y,target:t.target,pointerId:e.pointerId}:e.kind==="dragging"?{...e,x:t.x,y:t.y,target:t.target}:e;case"release":return e.kind==="dragging"?{kind:"settling",payload:e.payload,target:e.target}:e.kind==="pressing"?ve:e;case"cancel":case"settled":return ve;default:return e}}const ut=({edges:e,geometry:t,selectedDeviceId:a})=>s.jsx("svg",{"aria-hidden":"true",className:"pointer-events-none absolute top-0 left-0 overflow-visible",width:t.bounds.width,height:t.bounds.height,children:e.map(o=>{const h=t.networks.get(o.networkId),m=t.devices.get(o.deviceId);if(!h||!m)return null;const f=a!==null&&o.deviceId===a;return s.jsx("path",{"data-mesh-edge":o.key,d:Cs(h,m),fill:"none",strokeWidth:f?2:1.5,strokeDasharray:o.active?void 0:"4 4",className:f?"stroke-ink":"stroke-ink-dim"},o.key)})}),mt={self:"border-l-hairline",reached:"border-l-hairline","relay-down":"border-l-warning","handshake-refused":"border-l-warning","address-unreachable":"border-l-warning","no-endpoint":"border-l-hairline","not-a-member":"border-l-hairline",unanswered:"border-l-warning","not-attempted":"border-l-hairline",unknown:"border-l-hairline"};function ht(e){return e.suspect?"border-l-danger":mt[ee(e)]}const pt={self:"ring-2 ring-accent",reachable:null,relay_down:null,handshake_refused:null,unreachable:null,suspect:null},xt={accept:"border-accent bg-accent-wash",refuse:"border-warning"};function ft(e,t,a){return[e.label,Ue(e,t),a].filter(Boolean).join(", ")}function se(e){return e.name.trim()||e.id.slice(-6)}function Qe(e,t,a){if(a!=="reached"&&a!=="self"){const o=pe(a);return e.unreachable_reason?`${o} (${e.unreachable_reason})`:o}return e.live_state.trim()?e.live_state.trim():e.locality==="local"?n("ui.mesh.mesh_drop.on_this_device"):n("ui.mesh.mesh_node.on_device",{device:t})}const gt={resting:"border-l-2 border-l-hairline",attention:"border-l-2 border-l-warning"},bt=({network:e,x:t,y:a,refused:o})=>(F(),s.jsxs("li",{"data-mesh-network":e.id,"data-mesh-network-refused":o?"true":void 0,"data-glass-block":"",className:P("absolute flex items-center gap-2 rounded-md border bg-elevated px-3",o?"border-warning":"border-hairline"),style:{left:t,top:a,width:Ne,height:Ss},children:[s.jsx(Ce,{"aria-hidden":"true",className:"size-4 shrink-0 text-ink-muted"}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate text-body-sm text-ink",children:e.label}),s.jsxs("span",{title:n("ui.mesh.mesh_list.epoch",{epoch:e.epoch}),className:"block truncate text-meta text-ink-dim",children:[n("ui.mesh.mesh_graph.device_count",{count:e.memberCount}),e.revokedCount>0?n("ui.mesh.mesh_list.revoked_count",{count:e.revokedCount}):""]})]})]})),vt=({device:e,x:t,y:a,nowSeconds:o,selected:h,sessions:m,sessionTotal:f,dropState:d,movingSessionId:v,draggedSessionId:b,onOpen:w,onChipPointerDown:E,onChipClick:I,onShowAllSessions:c})=>{F();const{activity:u}=is(e,m.rows),p=u==="working",y=ft(e,o,p?"working":null),j=ee(e);return s.jsxs("li",{"data-mesh-device":e.id,"data-mesh-state":e.state,"data-mesh-drop":d??void 0,"aria-current":h?"true":void 0,"data-glass-block":"",className:P("absolute flex flex-col rounded-md border border-l-4 border-control bg-elevated","hover:bg-row-hover",h&&"border-y-ink border-r-ink bg-row-selected",ht(e),pt[e.state],d&&xt[d]),style:{left:t,top:a,width:Ne,height:Ms},children:[s.jsxs("button",{type:"button","data-mesh-device-open":e.id,"data-mesh-reach":j,"aria-label":y,title:rs(e),onClick:()=>w(e.id),className:P("flex w-full flex-col justify-between rounded-t-[5px] px-3 pt-2 pb-2 text-left","cursor-pointer","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-[-2px]"),style:{height:Ds},children:[s.jsxs("span",{className:"flex w-full min-w-0 items-center gap-2",children:[s.jsx(at,{"aria-hidden":"true",className:"size-4 shrink-0 text-ink-muted"}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",children:e.label}),e.suspect&&s.jsx(Ie,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-danger"})]}),s.jsxs("span",{className:"flex w-full min-w-0 items-baseline gap-1",children:[s.jsx("span",{className:"w-3 shrink-0 font-mono text-body-sm text-ink tabular-nums",children:e.sessionCount??"–"}),s.jsx("span",{className:P("min-w-0 truncate text-meta",e.sessionCount===null?"text-ink-dim":"text-ink-muted"),children:Ge(e.sessionCount)})]}),s.jsxs("span",{"data-mesh-state-line":"",className:"flex w-full min-w-0 items-baseline gap-1.5 text-meta",children:[s.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-ink-dim",children:ls[j]}),s.jsx("span",{className:P("shrink-0",Fe[j]),children:pe(j)}),p&&s.jsx("span",{"data-mesh-working":"",className:"shrink-0 text-info",children:n("ui.mesh.mesh_node.working")}),e.memberships.length>1&&s.jsx("span",{className:"min-w-0 truncate text-ink-dim",children:n("ui.mesh.mesh_node.memberships",{count:e.memberships.length})})]})]}),s.jsxs("ul",{"aria-label":n("ui.mesh.mesh_node.conversations_on",{device:e.label}),className:P("m-0 flex h-6 list-none items-center gap-1 overflow-hidden px-3",d==="accept"&&"opacity-40"),children:[m.shown.map(M=>s.jsx(_t,{session:M,ownerLabel:e.label,ownerReach:j,ownerReachable:e.reachable,moving:v===M.id,dragging:b===M.id,onPointerDown:E,onClick:()=>I(M)},M.id)),m.hidden>0&&s.jsx("li",{className:"shrink-0",children:s.jsxs("button",{type:"button","data-mesh-more":e.id,onClick:()=>c(e.id),className:P("flex min-h-6 items-center rounded-sm px-1.5 text-meta text-ink-dim","hover:bg-row-hover hover:text-ink","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2"),title:n("ui.mesh.mesh_node.shown_conversations",{shown:m.shown.length,total:f}),"aria-label":n("ui.mesh.mesh_node.show_all_conversations",{count:f}),children:["+",m.hidden]})})]})]})},_t=({session:e,ownerLabel:t,ownerReach:a,ownerReachable:o,moving:h,dragging:m,onPointerDown:f,onClick:d})=>{F();const v=Qe(e,t,a);return h?s.jsx("li",{role:"status","data-mesh-session":e.id,"data-mesh-moving":"true",children:s.jsx("span",{className:"flex min-h-6 items-center rounded-sm bg-sunken px-1.5 text-meta text-ink-muted",children:n("ui.mesh.mesh_card.moving")})}):s.jsx("li",{className:"min-w-0 flex-1","data-mesh-session-item":e.id,"data-mesh-dragging":m?"true":void 0,children:s.jsx("button",{type:"button","data-mesh-session":e.id,style:{touchAction:"none"},title:`${se(e)} · ${v}`,"aria-label":n("ui.mesh.mesh_node.open_conversation",{conversation:se(e),fact:v,owner:t}),onPointerDown:b=>f(b,e),onClick:()=>d(e),className:P("flex min-h-6 w-full max-w-32 items-center rounded-sm border border-hairline bg-surface px-1.5 text-left text-meta text-ink-muted","cursor-grab active:cursor-grabbing","hover:text-ink",gt[Es(e,o)],m&&"opacity-60","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2"),children:s.jsx("span",{className:"min-w-0 flex-1 truncate",children:se(e)})})})};function Le(e){const t=e.trim();if(!t)return null;if(t.startsWith("[")){const o=t.indexOf("]");if(o<=1)return null;const h=t.slice(1,o),m=t.slice(o+1);if(!m)return{host:h,port:null};if(!m.startsWith(":"))return null;const f=Number(m.slice(1));return{host:h,port:Number.isInteger(f)?f:null}}const a=t.lastIndexOf(":");if(a>0){const o=t.slice(a+1);if(/^\d+$/.test(o))return{host:t.slice(0,a),port:Number(o)}}return{host:t,port:null}}function Pe(e){const t=e.trim().split(".");if(t.length!==4)return null;for(const a of t)if(!/^\d{1,3}$/.test(a)||Number(a)>255)return null;return`${t[0]}.${t[1]}.${t[2]}`}function kt(e){return`${e}.x`}function wt(e){const t=new Map;for(const o of e.values())for(const h of o)t.set(h,(t.get(h)??0)+1);const a=new Set;for(const[o,h]of t)h>1&&a.add(o);return a}function ye(e){return new Set(e.endpoints.map(t=>t.trim()).filter(Boolean))}function jt(e,t){const a=e.filter(c=>c.id!==t),o=e.find(c=>c.id===t)??null,h=new Map;for(const c of e)h.set(c.id,ye(c));const m=wt(h),f=new Set;for(const c of o?ye(o):[]){if(m.has(c))continue;const u=Le(c),p=u?Pe(u.host):null;p&&f.add(p)}const d=c=>{const u=new Set;for(const p of ye(c)){if(m.has(p))continue;const y=Le(p),j=y?Pe(y.host):null;j&&u.add(j)}return u},v=new Map,b=new Map;for(const c of a){const u=yt(c);if(u){v.set(u,[...v.get(u)??[],c.id]);continue}for(const p of d(c))b.set(p,[...b.get(p)??[],c.id])}const w=new Map(e.map((c,u)=>[c.id,u])),E=c=>[...c].sort((u,p)=>(w.get(u)??0)-(w.get(p)??0)),I=[];for(const[c,u]of v)I.push({prefix:c,tier:"declared",deviceIds:E(u),get words(){return n("ui.mesh.mesh_scope.declared")}});for(const[c,u]of b)f.has(c)?I.push({prefix:c,tier:"shared",deviceIds:E(u),get words(){return n("ui.mesh.mesh_scope.shared_with_this_device")}}):u.length>1&&I.push({prefix:c,tier:"probable",deviceIds:E(u),get words(){return n("ui.mesh.mesh_scope.same_prefix")}});return I.sort((c,u)=>c.tier.localeCompare(u.tier)||c.prefix.localeCompare(u.prefix))}function yt(e){for(const t of e.memberships){const a=t.scope.trim();if(a)return a}return""}const Te={declared:0,shared:1,probable:2};function Nt(e,t){const a=new Map;for(const h of e){let m=null;for(const d of h.deviceIds){const v=t.get(d);v!==void 0&&(m===null||v<m.slot)&&(m={id:d,slot:v})}if(m===null)continue;const f=a.get(m.id);f===void 0?a.set(m.id,{slot:m.slot,groups:[h]}):f.groups.push(h)}const o=h=>{let m=-1;for(const f of h.deviceIds){const d=t.get(f);d!==void 0&&d>m&&(m=d)}return m};return[...a.entries()].sort((h,m)=>h[1].slot-m[1].slot).map(([h,m])=>({deviceId:h,groups:m.groups.sort((f,d)=>o(d)-o(f)||Te[f.tier]-Te[d.tier]||f.prefix.localeCompare(d.prefix))}))}function It(e){return new Map(e.map(t=>[t.deviceId,t.groups.length]))}function Ct(e){return`${e.tier==="declared"?e.prefix:kt(e.prefix)} · ${e.words}`}const $e=(e,t)=>e.deviceIds.map(a=>t.devices.get(a)).filter(a=>a!==void 0),St=({stacks:e,geometry:t})=>(F(),s.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute top-0 left-0",children:e.map(a=>{const o=a.groups.length,h=new Array(o).fill(0);let m=null;for(let d=o-1;d>=0;d-=1){const v=$e(a.groups[d],t),b=(v.length===0?0:Math.max(...v.map(w=>w.y+w.height)))+xe;m=m===null?b:Math.max(b,m+we),h[d]=m}const f=t.devices.get(a.deviceId);return a.groups.map((d,v)=>{const b=$e(d,t);if(b.length===0)return null;const w=o-1-v,E=Math.min(...b.map(j=>j.x)),I=Math.max(...b.map(j=>j.x)),u=(f?.y??Math.min(...b.map(j=>j.y)))-xe-Rs*w,p=d.tier==="declared",y=Ct(d);return s.jsx("div",{"data-mesh-scope":`${d.tier}:${d.prefix}`,"data-mesh-scope-level":v,className:P("absolute rounded-lg",d.tier==="probable"?"border border-dashed border-hairline-strong":"border border-control"),style:{left:E-xe-we*w,top:u,width:I+Ne-E+(xe+we*w)*2,height:h[v]-u},children:s.jsx("span",{"data-mesh-scope-label":"",className:P("absolute bottom-full left-1 mb-0.5 whitespace-nowrap text-meta",d.tier==="probable"?"text-ink-dim":"text-ink-muted",p&&"font-medium"),children:y})},`${d.tier}:${d.prefix}`)})})})),Oe=48,ze=1.25,Mt=.0015,Dt=({graph:e,slots:t,nowSeconds:a,selectedDeviceId:o,sessions:h,sessionTotals:m,movingSessionId:f,canMove:d,onOpenDevice:v,onAskMove:b,onDropRefused:w,onShowAllSessions:E,summaryId:I})=>{F();const c=x.useRef(null),[u,p]=x.useState({width:0,height:0,clipWidth:0,clipHeight:0,left:0,top:0}),[y,j]=x.useState({k:1,tx:0,ty:0}),M=x.useRef(!1),D=x.useRef(!1),r=x.useRef(null),N=x.useMemo(()=>jt(e.devices,e.selfDeviceId),[e.devices,e.selfDeviceId]),R=x.useMemo(()=>Nt(N,t.devices),[N,t]),C=x.useMemo(()=>As(t,It(R)),[t,R]),S=x.useMemo(()=>({selfDeviceId:e.selfDeviceId,devices:new Map(e.devices.map(i=>[i.id,i])),networks:new Map(e.networks.map(i=>[i.id,i]))}),[e]),[_,O]=x.useState(ve),de=x.useRef({kind:"ground"}),te=x.useCallback((i,l)=>{const g=document.elementFromPoint(i,l),L=g?.closest("[data-mesh-device]");if(L){const G=L.getAttribute("data-mesh-device");if(G)return{kind:"device",deviceId:G}}const H=g?.closest("[data-mesh-network]");if(H){const G=H.getAttribute("data-mesh-network");if(G)return{kind:"network",networkId:G}}return{kind:"ground"}},[]),T=x.useMemo(()=>_.kind!=="dragging"&&_.kind!=="settling"?null:ge(_.payload,_.target,S),[_,S]),K=x.useCallback(i=>{if(!T)return null;if(T.kind==="plan"){const l=_.kind==="dragging"||_.kind==="settling"?_.target:null;return l&&l.kind==="device"&&l.deviceId===i?"accept":null}if(T.kind==="refused"){const l=_.kind==="dragging"||_.kind==="settling"?_.target:null;return l&&l.kind==="device"&&l.deviceId===i?"refuse":null}return null},[T,_]),ne=x.useCallback((i,l)=>{if(!d||i.button!==0)return;D.current=!1;const g=l.locality==="local"?e.selfDeviceId??"":l.owner_device,L=S.devices.get(g),H={session:l,ownerDeviceId:g,ownerLabel:L?.label??l.owner_device_name};try{i.currentTarget.setPointerCapture(i.pointerId)}catch{}O(G=>Q(G,{kind:"press",payload:H,x:i.clientX,y:i.clientY,pointerId:i.pointerId}))},[d,S,e.selfDeviceId]),ae=i=>{if(_.kind==="pressing"||_.kind==="dragging"){const l=te(i.clientX,i.clientY);de.current=l,O(g=>Q(g,{kind:"move",x:i.clientX,y:i.clientY,target:l}));return}V(i)},ce=i=>{if(ue(i),_.kind!=="pressing"&&_.kind!=="dragging")return;if(_.kind==="pressing"){O(g=>Q(g,{kind:"cancel"}));return}const l=ge(_.payload,_.target,S);D.current=!0,O(g=>Q(g,{kind:"release"})),l.kind==="plan"?b({plan:l.plan,alternatives:l.alternatives,risky:l.risky}):l.kind==="refused"&&w({code:l.code,sentence:l.sentence,reach:l.reach,remedy:l.remedy,plan:l.plan??null}),O(g=>Q(g,{kind:"settled"}))};x.useEffect(()=>()=>O(ve),[]);const ie=x.useCallback(()=>{j(Re(C.bounds,u))},[C.bounds,u]);x.useEffect(()=>{const i=c.current;if(!i)return;const l=()=>{const L=i.getBoundingClientRect();p({width:L.width,height:L.height,clipWidth:i.clientWidth,clipHeight:i.clientHeight,left:L.left,top:L.top})};l();const g=new ResizeObserver(l);return g.observe(i),()=>g.disconnect()},[]),x.useEffect(()=>{M.current||u.width<=0||u.height<=0||(M.current=!0,j(Re(C.bounds,u)))},[u,C.bounds]),x.useEffect(()=>{const i=r.current;if(r.current={width:u.width,height:u.height},!i||!M.current||u.width<=0||u.height<=0||u.width>=i.width&&u.height>=i.height||!o)return;const l=C.devices.get(o);l&&j(g=>{const L={width:u.clipWidth,height:u.clipHeight},H=Math.max(0,Math.min(L.width-C.bounds.width*g.k,L.height-C.bounds.height*g.k));return Ls(g,l,L,Math.min(Ts,H))})},[u,o,C]);const q=_.kind==="dragging"?{x:_.x-u.left+12,y:_.y-u.top+12}:{x:0,y:0},re=T?Ps(T):null,Y=x.useRef(null),k=x.useRef(null),A=x.useRef(null),z=x.useRef(null),B=x.useCallback(()=>{A.current=null;const i=Y.current,l=k.current;if(Y.current=null,k.current=null,i){const g=z.current;if(!g)return;j({k:g.transform.k,tx:g.transform.tx+(i.x-g.x),ty:g.transform.ty+(i.y-g.y)});return}l&&j(g=>je(g,{x:l.x,y:l.y},g.k*Math.exp(-l.deltaY*Mt)))},[]),$=x.useCallback(()=>{A.current===null&&(A.current=requestAnimationFrame(B))},[B]);x.useEffect(()=>()=>{A.current!==null&&cancelAnimationFrame(A.current)},[]);const Z=i=>{!(i.target===i.currentTarget)&&i.button!==1||i.button!==0&&i.button!==1||(z.current={x:i.clientX,y:i.clientY,transform:y},i.currentTarget.setPointerCapture(i.pointerId),i.preventDefault())},V=i=>{z.current&&(Y.current={x:i.clientX,y:i.clientY},$())},ue=i=>{z.current&&(z.current=null,Y.current=null,i.currentTarget.hasPointerCapture(i.pointerId)&&i.currentTarget.releasePointerCapture(i.pointerId))},J=x.useCallback(i=>{if(i.deltaY===0)return;i.preventDefault();const l=i.currentTarget.getBoundingClientRect();k.current={x:i.clientX-l.left,y:i.clientY-l.top,deltaY:i.deltaY},$()},[$]);x.useEffect(()=>{const i=c.current;if(i)return i.addEventListener("wheel",J,{passive:!1}),()=>i.removeEventListener("wheel",J)},[J]);const le=i=>{const l=i.shiftKey?Oe*4:Oe;switch(i.key){case"Escape":if(_.kind!=="pressing"&&_.kind!=="dragging")return;i.preventDefault(),_.kind==="dragging"&&(D.current=!0),O(g=>Q(g,{kind:"cancel"}));return;case"0":i.preventDefault(),ie();return;case"+":case"=":i.preventDefault(),j(g=>je(g,{x:u.width/2,y:u.height/2},g.k*ze));return;case"-":case"_":i.preventDefault(),j(g=>je(g,{x:u.width/2,y:u.height/2},g.k/ze));return;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{i.preventDefault();const g=i.key==="ArrowLeft"?l:i.key==="ArrowRight"?-l:0,L=i.key==="ArrowUp"?l:i.key==="ArrowDown"?-l:0;j(H=>({...H,tx:H.tx+g,ty:H.ty+L}));return}}};return s.jsxs("div",{ref:c,"data-mesh-canvas":"",role:"group","aria-labelledby":I,tabIndex:0,onPointerDown:Z,onPointerMove:ae,onPointerUp:ce,onPointerCancel:i=>{_.kind==="dragging"&&(D.current=!0),O(l=>Q(l,{kind:"cancel"})),ue(i)},"data-mesh-gesture":_.kind,"data-glass-well":"clear",onKeyDown:le,onDoubleClick:i=>{i.target===i.currentTarget&&ie()},className:P("relative min-h-0 flex-1 overflow-hidden rounded-lg border border-hairline bg-sunken","[touch-action:none]","cursor-grab active:cursor-grabbing","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-[-2px]"),children:[s.jsx("div",{"data-mesh-ground":"","aria-hidden":"true",className:"mesh-ground pointer-events-none absolute inset-0",style:{backgroundPosition:`${y.tx}px ${y.ty}px`}}),s.jsxs("div",{"data-mesh-world":"",className:"absolute top-0 left-0",style:{transform:`translate3d(${y.tx}px, ${y.ty}px, 0) scale(${y.k})`,transformOrigin:"0 0",width:C.bounds.width,height:C.bounds.height},children:[s.jsx(St,{stacks:R,geometry:C}),s.jsx(ut,{edges:e.edges,geometry:C,selectedDeviceId:o}),s.jsx("ul",{"aria-label":n("ui.mesh.mesh_canvas.networks"),className:"m-0 list-none p-0",children:e.networks.map(i=>{const l=C.networks.get(i.id);return l?s.jsx(bt,{network:i,x:l.x,y:l.y,refused:T?.kind==="refused"&&_.kind==="dragging"&&_.target.kind==="network"&&_.target.networkId===i.id},i.id):null})}),s.jsx("ul",{"aria-label":n("ui.mesh.mesh_canvas.devices"),className:"m-0 list-none p-0",children:e.devices.map(i=>{const l=C.devices.get(i.id);return l?s.jsx(vt,{device:i,x:l.x,y:l.y,nowSeconds:a,selected:i.id===o,sessions:h.get(i.id)??{rows:[],shown:[],hidden:0},sessionTotal:m.get(i.id)??i.sessionCount??0,dropState:K(i.id),movingSessionId:f,draggedSessionId:ct(_),onOpen:v,onChipPointerDown:ne,onChipClick:()=>{if(D.current){D.current=!1;return}v(i.id)},onShowAllSessions:E},i.id):null})})]}),_.kind==="dragging"&&s.jsx("div",{"data-mesh-ghost":"","aria-hidden":"true",className:"pointer-events-none absolute z-10 max-w-40 truncate rounded-sm border border-ink-dim bg-surface px-1.5 py-0.5 text-meta text-ink",style:{left:q.x,top:q.y},children:_.payload.session.name||"untitled"}),_.kind==="dragging"&&re&&s.jsx("div",{"data-mesh-indicator":"",className:P("pointer-events-none absolute z-10 rounded-sm border bg-surface px-2 py-1 text-meta",T?.kind==="refused"?"border-warning text-warning":"border-control text-ink"),style:{left:q.x,maxWidth:Math.max(160,u.width-q.x-12),...q.y>u.height*.6?{bottom:Math.max(12,u.height-q.y+8)}:{top:q.y+24}},children:re})]})};function Et(e,t,a,o){const h=a.locality==="local"?t:a.owner_device,m=[];for(const f of e)if(f.id!==h){if(f.id===t){m.push({deviceId:f.id,label:o,verb:n("ui.mesh.mesh_card.recall_to_this_device"),keepVerb:n("ui.mesh.mesh_card.copy_here_leave_it_there")});continue}m.push({deviceId:f.id,label:f.label,verb:n("ui.mesh.mesh_card.move_to",{device:f.label}),keepVerb:n("ui.mesh.mesh_card.copy_to",{device:f.label})})}return m}function Rt(e,t,a){return Et(e.devices,e.selfDeviceId,t,a)}function es(e,t,a){const o=Rt(e,t,a),h={selfDeviceId:e.selfDeviceId,devices:new Map(e.devices.map(d=>[d.id,d])),networks:new Map(e.networks.map(d=>[d.id,d]))},m=t.locality==="local"?e.selfDeviceId??"":t.owner_device,f=h.devices.get(m);return o.map(d=>{const v=ge({session:t,ownerDeviceId:m,ownerLabel:f?.label??t.owner_device_name},{kind:"device",deviceId:d.deviceId},h);return{...d,refused:v.kind==="refused"&&v.code!=="busy"?v.sentence:null}})}const ss=({session:e,destinations:t,disabled:a,onChoose:o,onOpenChange:h,trigger:m,triggerLabel:f})=>(F(),s.jsxs(ms,{onOpenChange:h,children:[s.jsx(hs,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":f,"data-mesh-session-menu":e.id,disabled:a||t.length===0,className:"rounded-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2 disabled:text-ink-disabled",children:m})}),s.jsxs(ps,{align:"start",className:"min-w-56",children:[s.jsx(xs,{children:se(e)}),s.jsx(Me,{}),t.map(d=>s.jsx(De,{"data-mesh-move-to":d.deviceId,disabled:!!d.refused,title:d.refused??void 0,onSelect:()=>o(d,!1),children:d.verb},d.deviceId)),s.jsx(Me,{}),t.map(d=>s.jsx(De,{"data-mesh-copy-to":d.deviceId,disabled:!!d.refused,title:d.refused??void 0,onSelect:()=>o(d,!0),children:d.keepVerb},`keep-${d.deviceId}`))]})]})),At=({device:e,sessions:t,sessionTotal:a,nowSeconds:o,destinationsFor:h,movingSessionId:m,canMove:f,canInvite:d,onClose:v,onMove:b,onShowInList:w,onInvite:E,onRemoveMember:I})=>{F();const c=ee(e),u=qe(e),p=e.reachable?[]:e.attempts??[];x.useEffect(()=>{const r=N=>{N.key!=="Escape"||N.defaultPrevented||N.target?.closest('[role="menu"],[role="dialog"]')||(document.querySelector(`[data-mesh-device-open="${e.id}"]`)?.focus(),v())};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e.id,v]);const y=e.memberships.every(r=>!r.active),j=e.sessionCount===null?Ge(null):n("ui.mesh.mesh_card.conversation_count",{count:e.sessionCount}),M=e.suspect?Be():[y?n("ui.mesh.mesh_card.revoked_membership"):j,pe(c)].filter(Boolean).join(" · "),D=a>t.rows.length?n("ui.mesh.mesh_card.shown_of",{shown:t.rows.length,total:a}):`${t.rows.length}`;return s.jsxs("aside",{"aria-label":n("ui.mesh.mesh_card.device_details",{device:e.label}),"data-mesh-panel":e.id,"data-glass-block":"",className:"flex w-80 shrink-0 flex-col gap-3 overflow-y-auto rounded-md border border-hairline bg-surface p-4",children:[s.jsxs("header",{className:"flex flex-col gap-1",children:[s.jsx(U,{size:"sm",variant:"ghost",className:"w-fit self-end","data-mesh-panel-close":"",onClick:v,children:n("ui.mesh.mesh_actions.close")}),s.jsx("h2",{className:"text-body-sm text-ink",children:e.label}),s.jsxs("p",{className:"flex items-center gap-1.5 text-meta text-ink-muted",children:[e.suspect&&s.jsx(Ie,{"aria-hidden":"true",className:"size-3.5 text-danger"}),!e.suspect&&c==="unanswered"&&s.jsx(us,{"aria-hidden":"true",className:"size-3.5 text-warning"}),M]})]}),s.jsx(oe,{}),s.jsxs("section",{className:"flex flex-col gap-2",children:[s.jsx("h3",{className:"text-meta text-ink-dim",children:n("ui.mesh.mesh_card.memberships")}),s.jsx("ul",{className:"m-0 flex list-none flex-col gap-2 p-0",children:e.memberships.map(r=>s.jsxs("li",{className:"flex flex-col gap-1",children:[s.jsxs("span",{className:"flex items-center gap-2 text-body-sm text-ink",children:[s.jsx(Ce,{"aria-hidden":"true",className:"size-3.5 text-ink-muted"}),r.networkName]}),s.jsxs("span",{className:"text-meta text-ink-dim",children:[r.role||"member",r.capabilities.length>0?` · ${r.capabilities.join(", ")}`:"",r.active?"":n("ui.mesh.mesh_card.revoked")]}),d&&r.active&&s.jsxs(U,{size:"sm",variant:"ghost",className:"w-fit","data-mesh-remove-member":`${r.networkId}:${e.id}`,onClick:()=>I(e,r.networkId),children:[n("ui.mesh.mesh_card.remove_from"),r.networkName,"…"]})]},r.networkId))}),d&&s.jsx(U,{size:"sm",variant:"secondary",className:"w-fit","data-mesh-invite":e.id,onClick:()=>E(e),children:n("ui.mesh.mesh_actions.invite_to_a_network")})]}),s.jsx(oe,{}),s.jsxs("section",{className:"flex shrink-0 flex-col gap-2",children:[s.jsxs("h3",{className:"text-meta text-ink-dim",children:[n("ui.mesh.mesh_card.conversations"),s.jsxs("span",{className:"text-ink-disabled",children:["(",ee(e)!=="self"&&ee(e)!=="reached"?Ke(null):D,")"]})]}),be(e,o)?s.jsx("p",{className:"text-meta text-warning",children:be(e,o)}):t.rows.length===0?s.jsx("p",{className:"text-meta text-ink-dim",children:e.sessionCount===null?n("ui.mesh.mesh_card.this_device_did_not_report_its_conversations"):n("ui.mesh.mesh_card.no_conversations_here")}):s.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:t.rows.map(r=>s.jsxs("li",{"data-mesh-panel-session":r.id,className:P("flex items-center gap-2 rounded-sm px-2 py-1","border border-hairline bg-elevated",m===r.id&&"border-control"),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",title:se(r),children:se(r)}),s.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:Qe(r,e.label,ee(e))}),m===r.id?s.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:n("ui.mesh.mesh_card.moving")}):s.jsx(ss,{session:r,destinations:h(r),disabled:!f,onChoose:(N,R)=>b(r,N,R),trigger:s.jsx(Ze,{"aria-hidden":"true",className:"size-4"}),triggerLabel:n("ui.mesh.mesh_card.move_conversation",{conversation:se(r)})})]},r.id))})]}),s.jsx(oe,{}),s.jsxs("section",{className:"flex flex-col gap-2",children:[s.jsx("h3",{className:"text-meta text-ink-dim",children:n("ui.mesh.mesh_card.network_addresses")}),e.endpoints.length===0?s.jsx("p",{className:"text-meta text-ink-dim",children:n("ui.mesh.mesh_card.no_address_published")}):s.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:e.endpoints.map(r=>s.jsxs("li",{className:"flex items-baseline justify-between gap-2",children:[s.jsx("span",{className:"min-w-0 truncate font-mono text-body-sm text-ink",children:r}),s.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:n("ui.mesh.mesh_card.advertised")})]},r))})]}),s.jsx(oe,{}),s.jsxs("section",{className:"flex flex-col gap-2",children:[s.jsx("h3",{className:"text-meta text-ink-dim",children:n("ui.mesh.mesh_card.status")}),s.jsxs("dl",{className:"m-0 flex flex-col gap-1",children:[s.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[s.jsx("dt",{className:"text-meta text-ink-dim",children:n("ui.mesh.mesh_card.reach")}),s.jsx("dd",{className:"m-0 text-body-sm text-ink",children:pe(c)})]}),s.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[s.jsx("dt",{className:"text-meta text-ink-dim",children:n("ui.mesh.mesh_card.last_status_frame")}),s.jsx("dd",{className:"m-0 text-body-sm text-ink",children:e.lastSeenAt===null?n("ui.mesh.mesh_card.never"):$s(o-e.lastSeenAt)})]})]}),!e.reachable&&(u!==""||p.length>0)&&s.jsxs("div",{className:"flex flex-col gap-1",children:[u&&s.jsx("p",{className:"m-0 text-meta text-warning",children:u}),e.linkState==="handshake_refused"&&s.jsx("p",{className:"m-0 text-meta text-ink-dim",children:n("ui.mesh.mesh_reach.handshake_refused_hint")}),p.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{id:`mesh-attempts-label-${e.id}`,className:"text-meta text-ink-dim",children:n("ui.mesh.mesh_reach.addresses_tried")}),s.jsx("ul",{role:"list","aria-labelledby":`mesh-attempts-label-${e.id}`,className:"m-0 flex list-none flex-col gap-0.5 p-0",children:p.map((r,N)=>{const R=Ye(r.detail);return s.jsxs("li",{"data-mesh-attempt":r.endpoint,className:"flex items-baseline justify-between gap-2",children:[s.jsx("span",{className:"min-w-0 truncate font-mono text-meta text-ink",children:r.endpoint}),s.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:R})]},`${r.endpoint}:${N}`)})})]})]}),!u&&p.length===0&&e.reason&&s.jsx("p",{className:"text-meta text-warning",children:e.reason})]}),s.jsx(oe,{}),s.jsx(U,{size:"sm",variant:"ghost",className:"w-fit","data-mesh-show-in-list":e.id,onClick:()=>w(e.id),children:n("ui.mesh.mesh_card.show_in_list")})]})},Lt=["name","chats","state"],Pt={get name(){return n("ui.mesh.mesh_list.name")},get chats(){return n("ui.mesh.mesh_list.sort_conversations")},get state(){return n("ui.mesh.mesh_list.state")}},He={suspect:0,relay_down:1,handshake_refused:2,unreachable:3,self:4,reachable:5};function Tt(e,t){const a=[...e];switch(t){case"chats":return a.sort((o,h)=>(h.sessionCount??-1)-(o.sessionCount??-1)||o.label.localeCompare(h.label)),a;case"state":return a.sort((o,h)=>He[o.state]-He[h.state]||o.label.localeCompare(h.label)),a;default:return a.sort((o,h)=>o.label.localeCompare(h.label))}}const We=8;function $t(e,t){if(e.locality==="local")return e.live_state||"here";const a=e.owner_device_name||t,o=e.live_state?` · ${e.live_state}`:"";return e.reachable?n("ui.mesh.mesh_list.on_device_state",{device:a,state:o}):n("ui.mesh.mesh_list.on_device_no_answer",{device:a})}const Ot=({graph:e,nowSeconds:t,selectedDeviceId:a,sessions:o,selfLabel:h,canMove:m,onSelect:f,onMove:d,onInvite:v,onRemove:b})=>{F();const[w,E]=x.useState("name"),I=x.useMemo(()=>e.networks.map(c=>({network:c,members:Tt(e.devices.filter(u=>u.memberships.some(p=>p.networkId===c.id)),w)})),[e,w]);return s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto pr-1",children:[s.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[s.jsx("legend",{className:"sr-only",children:n("ui.mesh.mesh_list.sort_devices_by")}),s.jsx("div",{"data-glass-well":"",className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:Lt.map(c=>s.jsx("button",{type:"button","aria-pressed":w===c,onClick:()=>E(c),className:P("h-6 rounded-sm px-3 text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart","hover:text-ink","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2",w===c&&"bg-surface text-ink"),children:Pt[c]},c))})]}),I.map(({network:c,members:u})=>s.jsxs("section",{"data-mesh-network-group":c.id,className:"flex flex-col gap-2",children:[s.jsxs("h2",{className:"flex flex-wrap items-baseline gap-2 text-body-sm text-ink",title:n("ui.mesh.mesh_list.epoch",{epoch:c.epoch}),children:[c.label,s.jsxs("span",{className:"text-meta text-ink-dim",children:[c.trust," ·"," ",n("ui.mesh.mesh_graph.device_count",{count:c.memberCount}),c.revokedCount>0?n("ui.mesh.mesh_list.revoked_count",{count:c.revokedCount}):""]})]}),s.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:u.map(p=>{const y=p.memberships.find(S=>S.networkId===c.id),j=p.id===a,M=o.get(p.id),D=M?.rows??[],r=M?Ve(M,p.sessionCount):p.sessionCount??0,N=ee(p),R=qe(p),C=p.reachable?[]:p.attempts??[];return s.jsxs("li",{"data-mesh-device-row":p.id,"data-mesh-state":p.state,"aria-current":j?"true":void 0,className:P("flex flex-col gap-1 rounded-md px-3 py-2","border border-hairline bg-surface",j&&"border-ink bg-row-selected"),children:[s.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1",children:[s.jsx("button",{type:"button","data-mesh-device-open":p.id,onClick:()=>f(p.id),className:P("min-w-0 flex-1 truncate text-left text-body-sm text-ink","hover:text-ink-muted","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2"),children:p.label}),s.jsxs("span",{className:P("flex shrink-0 items-center gap-1 text-meta",Fe[N]),"data-mesh-reach":N,children:[p.suspect&&s.jsx(Ie,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-danger"}),p.suspect?pe(N):Ue(p,t),p.suspect&&s.jsx("span",{className:"shrink-0 rounded-sm border border-danger px-1 text-danger",children:Be()})]}),s.jsxs("span",{className:"shrink-0 text-meta text-ink-dim",children:[y?.role?`${y.role} · `:"",y&&!y.active?n("ui.mesh.mesh_list.revoked"):n("ui.mesh.mesh_list.member")]})]}),(R!==""||C.length>0)&&!p.reachable&&s.jsxs("div",{className:"flex flex-col gap-0.5",children:[R&&s.jsx("span",{className:"text-meta text-warning",children:R}),C.map((S,_)=>{const O=Ye(S.detail);return s.jsx("span",{"data-mesh-attempt":S.endpoint,className:"text-meta text-ink-dim",children:O?`${S.endpoint} — ${O}`:S.endpoint},`${S.endpoint}:${_}`)})]}),be(p,t)?s.jsxs("span",{className:"text-meta text-warning",children:[n("ui.mesh.mesh_card.conversations")," (",Ke(null),") ·"," ",be(p,t)]}):D.length>0?s.jsxs(s.Fragment,{children:[s.jsx(oe,{className:"my-1"}),s.jsx("ul",{className:"m-0 flex list-none flex-col gap-0.5 p-0",children:D.slice(0,We).map(S=>s.jsxs("li",{"data-mesh-row-session":S.id,className:"flex items-center gap-2 py-0.5",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-meta text-ink-muted",children:S.name||S.id}),s.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:$t(S,h)}),s.jsx(ss,{session:S,destinations:es(e,S,h),disabled:!m,onChoose:(_,O)=>d(S,_,O),trigger:s.jsx(Ze,{"aria-hidden":"true",className:"size-3.5"}),triggerLabel:n("ui.mesh.mesh_list.move_conversation",{conversation:S.name||S.id})})]},S.id))}),r>D.slice(0,We).length&&s.jsx("button",{type:"button",onClick:()=>f(p.id),className:"w-fit text-meta text-ink-dim hover:text-ink",children:n("ui.mesh.mesh_list.show_all_panel",{count:r})})]}):s.jsx("span",{className:"text-meta text-ink-dim",children:n("ui.mesh.mesh_list.conversation_count",{count:r})}),(y?.active||p.state!=="self")&&s.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[s.jsx(U,{size:"sm",variant:"ghost","data-mesh-invite":p.id,onClick:()=>v({deviceId:p.id,deviceLabel:p.label}),children:n("ui.mesh.mesh_actions.invite_to_a_network")}),y?.active&&s.jsxs(U,{size:"sm",variant:"ghost","data-mesh-remove-member":`${c.id}:${p.id}`,onClick:()=>b({networkId:c.id,networkLabel:c.label,deviceId:p.id,deviceLabel:p.label}),children:[n("ui.mesh.mesh_card.remove_from"),c.label,"…"]})]})]},p.id)})})]},c.id)),e.unmatchedPeers.length>0&&s.jsxs("p",{className:"text-meta text-warning",children:[n("ui.mesh.mesh_graph.device_count",{count:e.unmatchedPeers.length})," ",n("ui.mesh.mesh_list.answered_the_peer_read_but_is_in")]})]})},zt=["canvas","list"],Ht={get canvas(){return n("ui.mesh.mesh_page.canvas")},get list(){return n("ui.mesh.mesh_page.list")}},Wt=({state:e,initialPresentation:t="canvas",graph:a,nowSeconds:o,checking:h,staleError:m,onRetry:f,approvals:d,sessions:v,sessionError:b,selfLabel:w,movingSessionId:E,canMove:I,pendingMove:c,onAskMove:u,onDropRefused:p,onChooseMove:y,onCancelMove:j,moveBusy:M,moveReport:D,onDismissReport:r,onWaitForIdle:N,onUndoCopy:R,invite:C,onOpenInvite:S,onInvite:_,onCloseInvite:O,inviteBusy:de,inviteReceipt:te,inviteRefusal:T,remove:K,onOpenRemove:ne,onRemove:ae,onCloseRemove:ce,removeBusy:ie,removeRefusal:q,removed:re})=>{F();const[Y,k]=x.useState(t),[A,z]=x.useState(null),B=a?Os(a):"",$="mesh-summary",Z=zs(a),V=Hs(a,v,a?.selfDeviceId??null),ue=x.useMemo(()=>{const l=new Map;for(const g of a?.devices??[]){const L=V.byDevice.get(g.id);l.set(g.id,L?Ve(L,g.sessionCount):g.sessionCount??0)}return l},[a,V]),J=x.useCallback(l=>{z(l)},[]),le=a?a.devices.find(l=>l.id===A)??null:null,i=x.useCallback((l,g,L)=>{if(!a)return null;const H={selfDeviceId:a.selfDeviceId,devices:new Map(a.devices.map(X=>[X.id,X])),networks:new Map(a.networks.map(X=>[X.id,X]))},G=l.locality==="local"?a.selfDeviceId??"":l.owner_device,ts=H.devices.get(G),W=ge({session:l,ownerDeviceId:G,ownerLabel:ts?.label??l.owner_device_name},{kind:"device",deviceId:g.deviceId},H);if(W.kind==="refused")return p({code:W.code,sentence:W.sentence,reach:W.reach,remedy:W.remedy,plan:W.plan??null}),null;if(W.kind==="none")return null;const Se=L?W.alternatives.find(X=>X.keep)??W.plan:W.plan,ns=[W.plan,...W.alternatives].filter(X=>X.keep!==Se.keep),as={plan:Se,alternatives:ns,risky:W.risky};u(as)},[a,u,p]);return s.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-6 overflow-y-auto p-6",children:[s.jsx(cs,{title:n("ui.mesh.mesh_page.mesh"),icon:Ce,subtitle:n("ui.mesh.mesh_page.devices_this_app_is_paired_with_and"),children:s.jsxs("div",{className:"flex items-center gap-4",children:[h&&s.jsx("output",{className:"text-meta text-ink-dim",children:n("ui.mesh.mesh_page.checking")}),(e.kind==="ready"||e.kind==="loading")&&s.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[s.jsx("legend",{className:"sr-only",children:n("ui.mesh.mesh_page.presentation")}),s.jsx("div",{"data-glass-well":"",className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:zt.map(l=>s.jsx("button",{type:"button","aria-pressed":Y===l,disabled:e.kind!=="ready",onClick:()=>k(l),className:P("h-6 rounded-sm px-3 text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart","hover:text-ink","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2","disabled:text-ink-dim disabled:hover:text-ink-dim",Y===l&&"bg-surface text-ink"),children:Ht[l]},l))})]})]})}),s.jsx(ot,{rows:d.rows,error:d.error,pending:d.pending,refusal:d.decisionRefusal,onDecide:d.onDecide,onRetry:d.onRetry,nowSeconds:d.nowSeconds,networkNames:new Map((a?.networks??[]).map(l=>[l.id,l.label]))}),e.kind==="loading"&&s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[s.jsx(Ee,{className:"h-4 w-64"}),s.jsx(Ee,{className:"min-h-40 w-full flex-1"})]}),e.kind==="error"&&s.jsxs(fe,{variant:"warning",className:"flex-col items-start gap-2",children:[s.jsx("p",{children:e.message}),s.jsx(U,{variant:"secondary",size:"sm",onClick:f,className:"w-fit",children:n("ui.mesh.mesh_approvals_tray.ask_again")})]}),e.kind==="empty"&&s.jsx("div",{"data-glass-block":"",className:"flex min-h-0 flex-1 items-center justify-center rounded-lg border border-hairline bg-surface p-6",children:s.jsxs("div",{className:"flex flex-col items-start gap-3",children:[s.jsx("h2",{className:"text-heading text-ink",children:n("ui.mesh.mesh_page.no_network_on_this_device")}),s.jsx("p",{className:"max-w-140 text-body-sm text-ink-muted",children:n("ui.mesh.mesh_page.this_device_is_not_in_any_network")}),s.jsx("code",{className:"rounded-sm bg-sunken px-2 py-1 font-mono text-meta text-ink",children:"lop network init <name>"}),s.jsx("p",{className:"text-meta text-ink-dim",children:n("ui.mesh.mesh_page.a_network_appears_here_once_this_device")})]})}),e.kind==="ready"&&a&&s.jsx(s.Fragment,{children:s.jsxs("div",{className:"flex min-h-[22rem] flex-1 gap-4",children:[s.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-3",children:[s.jsx("p",{id:$,className:"text-meta text-ink-muted","data-mesh-summary":"",children:B}),m&&s.jsx(fe,{variant:"warning",children:s.jsx("p",{children:m})}),b&&s.jsx(fe,{variant:"warning",children:s.jsx("p",{children:b})}),D&&s.jsx(Ws,{receipt:D.kind==="moved"?{verb:D.verb,detail:D.detail,undo:D.undo}:null,refusal:D.kind==="refused"?D.refusal:null,canWait:D.kind==="refused"&&D.plan!==null,onWait:N,onRecheck:f,onUndo:R,onDismiss:r,pending:M}),Y==="canvas"?s.jsx(Dt,{graph:a,slots:Z,nowSeconds:o,selectedDeviceId:A,sessions:V.byDevice,sessionTotals:ue,movingSessionId:E,canMove:I,onOpenDevice:J,onAskMove:u,onDropRefused:p,onShowAllSessions:J,summaryId:$}):s.jsx(Ot,{graph:a,nowSeconds:o,selectedDeviceId:A,sessions:V.byDevice,selfLabel:w,canMove:I,onSelect:J,onMove:i,onInvite:S,onRemove:ne})]}),le&&s.jsx(At,{device:le,sessions:V.byDevice.get(le.id)??{rows:[],shown:[],hidden:0},sessionTotal:ue.get(le.id)??0,nowSeconds:o,canMove:I,canInvite:e.kind==="ready",movingSessionId:E,destinationsFor:l=>es(a,l,w),onClose:()=>z(null),onMove:i,onInvite:l=>S({deviceId:l.id,deviceLabel:l.label}),onRemoveMember:(l,g)=>{const L=a.networks.find(H=>H.id===g);ne({networkId:g,networkLabel:L?.label??g,deviceId:l.id,deviceLabel:l.label})},onShowInList:l=>{J(l),k("list")}})]})}),s.jsx(Fs,{open:c!==null,plan:c?.plan??Ft,alternatives:c?.alternatives??[],risky:c?.risky??!1,busy:M,onCancel:j,onChoose:y}),C&&s.jsx(qs,{open:C.open,options:C.options,deviceId:C.deviceId,deviceLabel:C.deviceLabel,onClose:O,onInvite:_,pending:de,receipt:te,refusal:T}),K&&s.jsx(Bs,{open:K.open,networkLabel:K.networkLabel,deviceLabel:K.deviceLabel,onClose:ce,onConfirm:ae,pending:ie,refusal:q,removed:re})]})},Ft={sessionId:"",to:"",keep:!1,verb:"",waitS:0,lost:null},Zt=({initialPresentation:e})=>{F();const t=os(),a=_e(t.data,"peers")==="enabled",o=_e(t.data,"session_transfer")==="enabled",h=Ys(a,{stamp:()=>ke.getState().beginAnswer()}),m=Gs(a),f=Us(a,{poll:!1,stamp:()=>ke.getState().beginAnswer()}),d=x.useMemo(()=>({peers:h,networks:m}),[h,m]),v=Ks(d),b=Vs(d),w=Xs(),E=_e(t.data,"approvals")==="enabled",I=Zs(a&&E,{poll:!1}),c=Js(),u=c.isError?{approvalId:c.variables?.approvalId??null,...Qs(c.error)}:null,p=x.useMemo(()=>Math.floor((I.dataUpdatedAt||Date.now())/1e3),[I.dataUpdatedAt]),y=ke(k=>k.settlePlacement),j=et(),M=st(),[D,r]=x.useState(null),[N,R]=x.useState(null),[C,S]=x.useState(null),[_,O]=x.useState(null),[de,te]=x.useState(null),[T,K]=x.useState(null),[ne,ae]=x.useState(null),ce=x.useMemo(()=>{const k=Math.max(h.dataUpdatedAt,m.dataUpdatedAt);return Math.floor((k||Date.now())/1e3)},[h.dataUpdatedAt,m.dataUpdatedAt]),ie=x.useCallback(()=>{h.refetch(),m.refetch(),f.refetch()},[h,m,f]),q=x.useCallback((k,A)=>{r(null);const z={sessionId:k.sessionId,to:k.to,keep:k.keep,waitS:A??k.waitS};w.mutate(z,{onSuccess:B=>{if(B.kind==="moved"){const{receipt:$}=B;y(k.sessionId,$);const Z=$.locality==="local"?n("ui.mesh.mesh_drop.this_device"):b?.devices.find(V=>V.id===$.owner_device)?.label??$.owner_device;R({kind:"moved",verb:$.mode==="keep"?n("ui.mesh.mesh_page.copied"):n("ui.mesh.mesh_page.moved"),detail:$.mode==="keep"?n("ui.mesh.mesh_page.copy_receipt",{destination:Z,suffix:$.new_session_id.slice(-6)}):n("ui.mesh.mesh_page.move_receipt",{destination:Z,retirement:$.source_retired?n("ui.mesh.mesh_page.the_copy_here_is_gone"):""}),undo:$.mode==="keep"?{sessionId:$.new_session_id,to:"local",keep:!1,verb:n("ui.mesh.mesh_page.bring_copy_back",{device:Z}),waitS:0,lost:tt(Z,n("ui.mesh.mesh_drop.this_device"))}:null});return}R({kind:"refused",refusal:B.refusal,plan:k})},onError:()=>{R({kind:"refused",refusal:{code:"move_failed",sentence:n("ui.mesh.mesh_page.the_move_could_not_be_sent_nothing"),status:null,unconfirmed:!1},plan:k})}})},[b,w,y]),re=x.useMemo(()=>{if(!b)return[];const k=C?.deviceId,A=k?b.devices.find(z=>z.id===k):void 0;return b.networks.filter(z=>{if(!A)return!0;const B=A.memberships.find($=>$.networkId===z.id);return!B||!B.active}).map(z=>({id:z.id,label:z.label}))},[b,C]);if(!a)return s.jsx(ds,{to:"/chat",replace:!0});const Y=v.kind==="ready"?h.error?me(h.error):m.error?me(m.error):null:null;return s.jsx(Wt,{initialPresentation:e,state:v,graph:b,nowSeconds:ce,checking:h.isFetching||m.isFetching,staleError:Y,onRetry:ie,approvals:{rows:I.data??[],error:I.isError?nt(I.error):null,pending:c.isPending?c.variables??null:null,decisionRefusal:u,onDecide:(k,A)=>c.mutate({approvalId:k,decision:A}),onRetry:()=>void I.refetch(),nowSeconds:p},sessions:f.data?.rows??[],movingSessionId:w.isPending?w.variables?.sessionId??null:null,sessionError:f.isError?me(f.error):null,selfLabel:b?.devices.find(k=>k.state==="self")?.label??n("ui.mesh.mesh_drop.this_device"),canMove:o,pendingMove:D,onAskMove:r,onDropRefused:k=>R({kind:"refused",refusal:{code:k.code,sentence:k.sentence,reach:k.reach,status:null,unconfirmed:!1},plan:k.plan}),onChooseMove:k=>q(k),onCancelMove:()=>r(null),moveBusy:w.isPending,moveReport:N,onDismissReport:()=>R(null),onWaitForIdle:()=>{N?.kind!=="refused"||!N.plan||q(N.plan,qt)},onUndoCopy:()=>{N?.kind!=="moved"||!N.undo||r({plan:N.undo,alternatives:[],risky:!1})},invite:C===null?null:{open:!0,deviceId:C.deviceId,deviceLabel:C.deviceLabel,options:re},onOpenInvite:k=>{O(null),te(null),S(k)},onInvite:k=>{j.mutate(k,{onSuccess:A=>O(A),onError:A=>te({code:"invite_refused",sentence:me(A),status:null,unconfirmed:!1})})},onCloseInvite:()=>S(null),inviteBusy:j.isPending,inviteReceipt:_,inviteRefusal:de,remove:T===null?null:{open:!0,networkId:T.networkId,networkLabel:T.networkLabel,deviceId:T.deviceId,deviceLabel:T.deviceLabel},onOpenRemove:k=>{ae(null),K(k)},onRemove:k=>{T&&M.mutate({networkId:T.networkId,deviceId:T.deviceId,confirm:k},{onSuccess:A=>ae(A)})},onCloseRemove:()=>K(null),removeBusy:M.isPending,removeRefusal:M.isError?{code:"remove_refused",sentence:me(M.error),status:null,unconfirmed:!1}:null,removed:ne})},qt=300;export{Zt as MeshPage,Wt as MeshSurface,Zt as default};
1
+ import{r as x,j as s,t as n,c as P}from"./index-BDzV3bGH.js";import{B as is,C as ee,E as rs,R as ls,F as pe,G as Fe,H as qe,I as Be,J as Ye,a as os,K as _e,q as ke,N as ds}from"./path-utils-Ct0VTUZS.js";import{P as cs}from"./page-header-6mrV9W-E.js";import{u as F,B as U,A as fe,p as us,h as oe,q as ms,r as hs,s as ps,t as xs,v as Me,w as Ee,k as De}from"./error-boundary-ZYkSCpZC.js";import{C as he,D as fs,E as gs,F as bs,G as vs,I as _s,J as ks,K as ws,L as js,M as ys,N as Ns,O as Is,Q as Cs,R as Ss,T as Ne,U as Ms,V as Es,W as Ie,X as Ge,Y as Ue,Z as Ds,_ as xe,$ as we,a0 as Rs,a1 as As,a2 as ge,a3 as Re,a4 as Ls,a5 as Ps,a6 as je,a7 as Ts,a8 as Ke,a9 as be,aa as $s,ab as Ve,ac as Os,ad as zs,ae as Hs,af as Ws,ag as Fs,ah as qs,ai as Bs,aj as Ys,ak as Gs,al as Us,am as Ks,an as Vs,ao as Xs,ap as Zs,aq as Js,ar as Qs,as as et,at as st,au as tt,av as me,aw as nt}from"./index-CRjnV9wx.js";import{aw as Xe,ax as Ce,ay as at,az as Ze}from"./conversation-input-sync-CJU5GIzR.js";import"./console-mirror-DRkz3vUY.js";function it(e){return e==="failed"?"text-danger":he(e)?"text-ink-muted":"text-ink-dim"}function rt(e){return e==="failed"?n("ui.mesh.mesh_approvals_tray.abandon"):n("ui.mesh.mesh_approvals_tray.stop")}function lt(e){switch(e){case"requested":return[{term:n("ui.mesh.mesh_approvals_tray.signing"),text:n("ui.mesh.mesh_approvals_tray.approving_signs_with_this_machine_s_operator")}];case"approved":return[{term:n("ui.mesh.mesh_approvals_tray.next"),text:n("ui.mesh.mesh_approvals_tray.an_agent_runs_the_install_and_connect")},{term:n("ui.mesh.mesh_approvals_tray.stop"),text:n("ui.mesh.mesh_approvals_tray.stopping_now_denies_the_request_nothing_has")}];case"connecting":return[{term:n("ui.mesh.mesh_approvals_tray.stop"),text:n("ui.mesh.mesh_approvals_tray.stopping_now_denies_the_request_the_runner")}];case"failed":return[{term:n("ui.mesh.mesh_approvals_tray.after_a_stop"),text:n("ui.mesh.mesh_approvals_tray.the_runner_stopped_before_it_finished_abandoning")}];default:return[]}}const ot=({rows:e,error:t,pending:a,refusal:o,onDecide:h,onRetry:m,nowSeconds:f,networkNames:d})=>{F();const v=a!==null,b=x.useMemo(()=>e.filter(r=>he(r.state)),[e]),w=x.useMemo(()=>e.filter(r=>!he(r.state)),[e]),[D,I]=x.useState(!1),c=x.useRef(null),u=x.useRef(null),p=x.useRef(null),y=(r,N)=>{N==="deny"&&b.some(R=>R.approvalId===r&&R.kind==="credential")&&(p.current={id:r,origin:document.activeElement,sawPending:!1}),h(r,N)};x.useLayoutEffect(()=>{const r=p.current;if(!r)return;if(a?.approvalId===r.id&&(r.sawPending=!0),o?.approvalId===r.id){p.current=null;return}const N=e.find(C=>C.approvalId===r.id);if(N?.state==="requested"){!a&&r.sawPending&&(p.current=null);return}if(N?.state==="denied"&&a||(p.current=null,N?.state!=="denied"||document.activeElement!==document.body&&document.activeElement!==r.origin))return;(b.length?c.current?.querySelector('[data-tour-tag="mesh-approval-controls"] button:not(:disabled)'):u.current?.querySelector("button"))?.focus({preventScroll:!0})},[e,a,o,b.length]);const j=w.some(r=>r.state==="failed"),M=w.filter(r=>r.state==="failed").length,E=o!==null&&e.some(r=>r.approvalId===o.approvalId&&(he(r.state)||D));return b.length===0&&w.length===0&&!t&&!o?null:s.jsxs("section",{ref:c,"aria-label":n("ui.mesh.mesh_approvals_tray.approvals"),"data-tour-tag":"mesh-approvals-tray",className:"flex flex-col gap-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(fs,{"aria-hidden":"true",className:"size-4 text-ink-muted"}),s.jsx("h2",{className:"text-body-sm text-ink",children:n("ui.mesh.mesh_approvals_tray.approvals")}),b.length>0&&s.jsx("span",{className:"text-meta text-ink-dim",children:n("ui.mesh.mesh_approvals_tray.waiting_count",{count:b.length})})]}),t&&s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("p",{className:"min-w-0 flex-1 text-meta text-ink-muted",children:t}),s.jsx(U,{variant:"secondary",size:"sm",onClick:m,children:n("ui.mesh.mesh_approvals_tray.ask_again")})]}),b.length>0&&s.jsx("ul",{className:"flex flex-col divide-y divide-hairline",children:b.map(r=>s.jsx(Ae,{row:r,pending:a?.approvalId===r.approvalId?a:null,busy:v,refusal:o?.approvalId===r.approvalId?o:null,onDecide:y,nowSeconds:f,networkNames:d},r.approvalId))}),o&&!E&&s.jsx(Je,{refusal:o}),w.length>0&&s.jsx("div",{ref:u,children:s.jsx(Xe,{open:D,onOpenChange:I,chevronClassName:"text-ink-dim",className:P(b.length>0&&"border-hairline border-t pt-3"),summary:s.jsxs("span",{className:"flex items-center gap-1.5 text-meta text-ink-muted",children:[n("ui.mesh.mesh_approvals_tray.settled_approvals"),s.jsxs("span",{className:"text-ink-dim",children:["(",w.length,")"]}),j&&s.jsx("span",{"aria-hidden":"true",className:"size-1.5 rounded-full bg-danger"}),M>0&&s.jsx("span",{className:"text-danger",children:n("ui.mesh.mesh_approvals_tray.failed_count",{count:M})})]}),children:s.jsx("ul",{className:"flex flex-col divide-y divide-hairline","data-tour-tag":"mesh-approvals-records",children:w.map(r=>s.jsx(Ae,{row:r,pending:a?.approvalId===r.approvalId?a:null,busy:v,refusal:o?.approvalId===r.approvalId?o:null,onDecide:y,nowSeconds:f,networkNames:d},r.approvalId))})})})]})},Ae=({row:e,pending:t,busy:a,refusal:o,onDecide:h,nowSeconds:m,networkNames:f})=>{F();const d=he(e.state),v=gs(e),b=bs(e,f),w=vs(e,f),D=_s(e),I=ks(e),c=ws(e),u=js(e.expiresAt,m),p=e.kind==="credential"||e.kind==="unknown",y=p||e.canApproveHere===!1,j=y?[]:lt(e.state),M=ys(e),E=Ns(e.state);return s.jsxs("li",{className:"flex flex-col gap-2 py-3 first:pt-0 last:pb-0","data-tour-tag":"mesh-approval-card",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:P("text-meta",it(e.state)),children:e.kind==="credential"&&e.state==="approved"?n("ui.mesh.approval.approved_pending_apply"):Is(e.state)}),s.jsx("div",{className:"grow"}),d&&u&&s.jsx("span",{className:"text-meta text-ink-dim",children:e.kind==="credential"?n("ui.mesh.approval.request_window",{remaining:u}):u})]}),s.jsx("p",{className:"text-body-sm text-ink [overflow-wrap:anywhere]","data-tour-tag":"mesh-approval-summary",children:d?b:v}),!y&&e.state==="failed"&&s.jsx("p",{className:"text-meta text-ink-muted","data-tour-tag":"mesh-approval-stopped-note",children:n("ui.mesh.mesh_approvals_tray.the_runner_stopped_before_it_finished_it")}),d&&y&&s.jsx("p",{className:"text-meta text-ink-muted whitespace-pre-wrap [overflow-wrap:anywhere]","data-tour-tag":"mesh-approval-cli-remedy",children:e.approveRemedy||n("ui.mesh.approval.cli_review")}),e.kind==="credential"&&e.state==="approved"&&s.jsx("p",{className:"text-meta text-ink-muted","data-tour-tag":"mesh-approval-apply-hint",children:e.details?.length?n("ui.mesh.approval.approved_apply_hint"):n("ui.mesh.approval.approved_details_missing")}),(M||E)&&s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[M&&s.jsx(U,{variant:"primary",size:"sm",disabled:a,onClick:()=>h(e.approvalId,"approve"),"data-tour-tag":"mesh-approval-approve",children:n("ui.mesh.mesh_approvals_tray.approve")}),E&&s.jsx(U,{variant:"ghost",size:"sm",disabled:a,onClick:()=>h(e.approvalId,"deny"),"data-tour-tag":d?"mesh-approval-deny":"mesh-approval-stop",children:d?n("ui.mesh.mesh_approvals_tray.deny"):rt(e.state)}),t&&s.jsx("span",{className:"text-meta text-ink-dim",children:t.decision==="approve"?n("ui.mesh.mesh_approvals_tray.waiting_for_the_signing_prompt"):n("ui.mesh.mesh_approvals_tray.writing_the_decision")})]}),s.jsxs(Xe,{chevronClassName:"text-ink-dim",summary:s.jsx("span",{className:"text-meta",children:n("ui.mesh.mesh_approvals_tray.details")}),children:[p&&(e.details?.length?s.jsx("ul",{className:"flex flex-col gap-1.5 text-meta text-ink-muted [overflow-wrap:anywhere]","data-tour-tag":"mesh-approval-server-details",children:e.details.map((r,N)=>s.jsx("li",{className:"whitespace-pre-wrap",children:r},`${N}:${r}`))}):s.jsx("p",{className:"text-meta text-ink-muted",children:n("ui.mesh.approval.details_unavailable")})),w.length>0&&s.jsx("dl",{className:"grid grid-cols-[max-content_1fr] gap-x-4 gap-y-0.5 text-meta text-ink-dim","data-tour-tag":"mesh-approval-consequences",children:w.map(r=>s.jsxs(x.Fragment,{children:[s.jsx("dt",{className:"text-ink-muted",children:r.term}),s.jsx("dd",{children:r.consequence})]},r.term))}),(D||I)&&s.jsxs("p",{className:"text-meta text-ink-muted",children:[D&&s.jsx("span",{children:D}),D&&I&&s.jsx("span",{children:" · "}),I&&s.jsx("span",{className:"font-mono",children:I})]}),c&&s.jsx("p",{className:"text-meta text-ink-dim",children:c}),j.length>0&&s.jsx("dl",{className:"grid grid-cols-[max-content_1fr] gap-x-4 gap-y-0.5 text-meta","data-tour-tag":"mesh-approval-consequence",children:j.map(r=>s.jsxs(x.Fragment,{children:[s.jsx("dt",{className:"text-ink-muted",children:r.term}),s.jsx("dd",{className:"text-ink-muted",children:r.text})]},r.term))})]}),o&&s.jsx(Je,{refusal:o})]})},Je=({refusal:e})=>(F(),s.jsx(fe,{variant:"warning",className:"text-meta","data-tour-tag":"mesh-approval-refusal",children:s.jsxs("span",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsx("span",{className:"min-w-0 flex-1",children:e.sentence}),s.jsx("span",{className:"shrink-0 font-mono text-ink-dim",children:e.code})]})})),dt=4,ve={kind:"idle"};function ct(e){switch(e.kind){case"dragging":case"settling":return e.payload.session.id;case"pressing":return null;default:return null}}function Q(e,t){switch(t.kind){case"press":return e.kind!=="idle"?e:{kind:"pressing",payload:t.payload,originX:t.x,originY:t.y,pointerId:t.pointerId};case"move":return e.kind==="pressing"?Math.max(Math.abs(t.x-e.originX),Math.abs(t.y-e.originY))<dt?e:{kind:"dragging",payload:e.payload,x:t.x,y:t.y,target:t.target,pointerId:e.pointerId}:e.kind==="dragging"?{...e,x:t.x,y:t.y,target:t.target}:e;case"release":return e.kind==="dragging"?{kind:"settling",payload:e.payload,target:e.target}:e.kind==="pressing"?ve:e;case"cancel":case"settled":return ve;default:return e}}const ut=({edges:e,geometry:t,selectedDeviceId:a})=>s.jsx("svg",{"aria-hidden":"true",className:"pointer-events-none absolute top-0 left-0 overflow-visible",width:t.bounds.width,height:t.bounds.height,children:e.map(o=>{const h=t.networks.get(o.networkId),m=t.devices.get(o.deviceId);if(!h||!m)return null;const f=a!==null&&o.deviceId===a;return s.jsx("path",{"data-mesh-edge":o.key,d:Cs(h,m),fill:"none",strokeWidth:f?2:1.5,strokeDasharray:o.active?void 0:"4 4",className:f?"stroke-ink":"stroke-ink-dim"},o.key)})}),mt={self:"border-l-hairline",reached:"border-l-hairline","relay-down":"border-l-warning","handshake-refused":"border-l-warning","address-unreachable":"border-l-warning","no-endpoint":"border-l-hairline","not-a-member":"border-l-hairline",unanswered:"border-l-warning","not-attempted":"border-l-hairline",unknown:"border-l-hairline"};function ht(e){return e.suspect?"border-l-danger":mt[ee(e)]}const pt={self:"ring-2 ring-accent",reachable:null,relay_down:null,handshake_refused:null,unreachable:null,suspect:null},xt={accept:"border-accent bg-accent-wash",refuse:"border-warning"};function ft(e,t,a){return[e.label,Ue(e,t),a].filter(Boolean).join(", ")}function se(e){return e.name.trim()||e.id.slice(-6)}function Qe(e,t,a){if(a!=="reached"&&a!=="self"){const o=pe(a);return e.unreachable_reason?`${o} (${e.unreachable_reason})`:o}return e.live_state.trim()?e.live_state.trim():e.locality==="local"?n("ui.mesh.mesh_drop.on_this_device"):n("ui.mesh.mesh_node.on_device",{device:t})}const gt={resting:"border-l-2 border-l-hairline",attention:"border-l-2 border-l-warning"},bt=({network:e,x:t,y:a,refused:o})=>(F(),s.jsxs("li",{"data-mesh-network":e.id,"data-mesh-network-refused":o?"true":void 0,"data-glass-block":"",className:P("absolute flex items-center gap-2 rounded-md border bg-elevated px-3",o?"border-warning":"border-hairline"),style:{left:t,top:a,width:Ne,height:Ss},children:[s.jsx(Ce,{"aria-hidden":"true",className:"size-4 shrink-0 text-ink-muted"}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate text-body-sm text-ink",children:e.label}),s.jsxs("span",{title:n("ui.mesh.mesh_list.epoch",{epoch:e.epoch}),className:"block truncate text-meta text-ink-dim",children:[n("ui.mesh.mesh_graph.device_count",{count:e.memberCount}),e.revokedCount>0?n("ui.mesh.mesh_list.revoked_count",{count:e.revokedCount}):""]})]})]})),vt=({device:e,x:t,y:a,nowSeconds:o,selected:h,sessions:m,sessionTotal:f,dropState:d,movingSessionId:v,draggedSessionId:b,onOpen:w,onChipPointerDown:D,onChipClick:I,onShowAllSessions:c})=>{F();const{activity:u}=is(e,m.rows),p=u==="working",y=ft(e,o,p?"working":null),j=ee(e);return s.jsxs("li",{"data-mesh-device":e.id,"data-mesh-state":e.state,"data-mesh-drop":d??void 0,"aria-current":h?"true":void 0,"data-glass-block":"",className:P("absolute flex flex-col rounded-md border border-l-4 border-control bg-elevated","hover:bg-row-hover",h&&"border-y-ink border-r-ink bg-row-selected",ht(e),pt[e.state],d&&xt[d]),style:{left:t,top:a,width:Ne,height:Ms},children:[s.jsxs("button",{type:"button","data-mesh-device-open":e.id,"data-mesh-reach":j,"aria-label":y,title:rs(e),onClick:()=>w(e.id),className:P("flex w-full flex-col justify-between rounded-t-[5px] px-3 pt-2 pb-2 text-left","cursor-pointer","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-[-2px]"),style:{height:Es},children:[s.jsxs("span",{className:"flex w-full min-w-0 items-center gap-2",children:[s.jsx(at,{"aria-hidden":"true",className:"size-4 shrink-0 text-ink-muted"}),s.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",children:e.label}),e.suspect&&s.jsx(Ie,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-danger"})]}),s.jsxs("span",{className:"flex w-full min-w-0 items-baseline gap-1",children:[s.jsx("span",{className:"w-3 shrink-0 font-mono text-body-sm text-ink tabular-nums",children:e.sessionCount??"–"}),s.jsx("span",{className:P("min-w-0 truncate text-meta",e.sessionCount===null?"text-ink-dim":"text-ink-muted"),children:Ge(e.sessionCount)})]}),s.jsxs("span",{"data-mesh-state-line":"",className:"flex w-full min-w-0 items-baseline gap-1.5 text-meta",children:[s.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-ink-dim",children:ls[j]}),s.jsx("span",{className:P("shrink-0",Fe[j]),children:pe(j)}),p&&s.jsx("span",{"data-mesh-working":"",className:"shrink-0 text-info",children:n("ui.mesh.mesh_node.working")}),e.memberships.length>1&&s.jsx("span",{className:"min-w-0 truncate text-ink-dim",children:n("ui.mesh.mesh_node.memberships",{count:e.memberships.length})})]})]}),s.jsxs("ul",{"aria-label":n("ui.mesh.mesh_node.conversations_on",{device:e.label}),className:P("m-0 flex h-6 list-none items-center gap-1 overflow-hidden px-3",d==="accept"&&"opacity-40"),children:[m.shown.map(M=>s.jsx(_t,{session:M,ownerLabel:e.label,ownerReach:j,ownerReachable:e.reachable,moving:v===M.id,dragging:b===M.id,onPointerDown:D,onClick:()=>I(M)},M.id)),m.hidden>0&&s.jsx("li",{className:"shrink-0",children:s.jsxs("button",{type:"button","data-mesh-more":e.id,onClick:()=>c(e.id),className:P("flex min-h-6 items-center rounded-sm px-1.5 text-meta text-ink-dim","hover:bg-row-hover hover:text-ink","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2"),title:n("ui.mesh.mesh_node.shown_conversations",{shown:m.shown.length,total:f}),"aria-label":n("ui.mesh.mesh_node.show_all_conversations",{count:f}),children:["+",m.hidden]})})]})]})},_t=({session:e,ownerLabel:t,ownerReach:a,ownerReachable:o,moving:h,dragging:m,onPointerDown:f,onClick:d})=>{F();const v=Qe(e,t,a);return h?s.jsx("li",{role:"status","data-mesh-session":e.id,"data-mesh-moving":"true",children:s.jsx("span",{className:"flex min-h-6 items-center rounded-sm bg-sunken px-1.5 text-meta text-ink-muted",children:n("ui.mesh.mesh_card.moving")})}):s.jsx("li",{className:"min-w-0 flex-1","data-mesh-session-item":e.id,"data-mesh-dragging":m?"true":void 0,children:s.jsx("button",{type:"button","data-mesh-session":e.id,style:{touchAction:"none"},title:`${se(e)} · ${v}`,"aria-label":n("ui.mesh.mesh_node.open_conversation",{conversation:se(e),fact:v,owner:t}),onPointerDown:b=>f(b,e),onClick:()=>d(e),className:P("flex min-h-6 w-full max-w-32 items-center rounded-sm border border-hairline bg-surface px-1.5 text-left text-meta text-ink-muted","cursor-grab active:cursor-grabbing","hover:text-ink",gt[Ds(e,o)],m&&"opacity-60","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2"),children:s.jsx("span",{className:"min-w-0 flex-1 truncate",children:se(e)})})})};function Le(e){const t=e.trim();if(!t)return null;if(t.startsWith("[")){const o=t.indexOf("]");if(o<=1)return null;const h=t.slice(1,o),m=t.slice(o+1);if(!m)return{host:h,port:null};if(!m.startsWith(":"))return null;const f=Number(m.slice(1));return{host:h,port:Number.isInteger(f)?f:null}}const a=t.lastIndexOf(":");if(a>0){const o=t.slice(a+1);if(/^\d+$/.test(o))return{host:t.slice(0,a),port:Number(o)}}return{host:t,port:null}}function Pe(e){const t=e.trim().split(".");if(t.length!==4)return null;for(const a of t)if(!/^\d{1,3}$/.test(a)||Number(a)>255)return null;return`${t[0]}.${t[1]}.${t[2]}`}function kt(e){return`${e}.x`}function wt(e){const t=new Map;for(const o of e.values())for(const h of o)t.set(h,(t.get(h)??0)+1);const a=new Set;for(const[o,h]of t)h>1&&a.add(o);return a}function ye(e){return new Set(e.endpoints.map(t=>t.trim()).filter(Boolean))}function jt(e,t){const a=e.filter(c=>c.id!==t),o=e.find(c=>c.id===t)??null,h=new Map;for(const c of e)h.set(c.id,ye(c));const m=wt(h),f=new Set;for(const c of o?ye(o):[]){if(m.has(c))continue;const u=Le(c),p=u?Pe(u.host):null;p&&f.add(p)}const d=c=>{const u=new Set;for(const p of ye(c)){if(m.has(p))continue;const y=Le(p),j=y?Pe(y.host):null;j&&u.add(j)}return u},v=new Map,b=new Map;for(const c of a){const u=yt(c);if(u){v.set(u,[...v.get(u)??[],c.id]);continue}for(const p of d(c))b.set(p,[...b.get(p)??[],c.id])}const w=new Map(e.map((c,u)=>[c.id,u])),D=c=>[...c].sort((u,p)=>(w.get(u)??0)-(w.get(p)??0)),I=[];for(const[c,u]of v)I.push({prefix:c,tier:"declared",deviceIds:D(u),get words(){return n("ui.mesh.mesh_scope.declared")}});for(const[c,u]of b)f.has(c)?I.push({prefix:c,tier:"shared",deviceIds:D(u),get words(){return n("ui.mesh.mesh_scope.shared_with_this_device")}}):u.length>1&&I.push({prefix:c,tier:"probable",deviceIds:D(u),get words(){return n("ui.mesh.mesh_scope.same_prefix")}});return I.sort((c,u)=>c.tier.localeCompare(u.tier)||c.prefix.localeCompare(u.prefix))}function yt(e){for(const t of e.memberships){const a=t.scope.trim();if(a)return a}return""}const Te={declared:0,shared:1,probable:2};function Nt(e,t){const a=new Map;for(const h of e){let m=null;for(const d of h.deviceIds){const v=t.get(d);v!==void 0&&(m===null||v<m.slot)&&(m={id:d,slot:v})}if(m===null)continue;const f=a.get(m.id);f===void 0?a.set(m.id,{slot:m.slot,groups:[h]}):f.groups.push(h)}const o=h=>{let m=-1;for(const f of h.deviceIds){const d=t.get(f);d!==void 0&&d>m&&(m=d)}return m};return[...a.entries()].sort((h,m)=>h[1].slot-m[1].slot).map(([h,m])=>({deviceId:h,groups:m.groups.sort((f,d)=>o(d)-o(f)||Te[f.tier]-Te[d.tier]||f.prefix.localeCompare(d.prefix))}))}function It(e){return new Map(e.map(t=>[t.deviceId,t.groups.length]))}function Ct(e){return`${e.tier==="declared"?e.prefix:kt(e.prefix)} · ${e.words}`}const $e=(e,t)=>e.deviceIds.map(a=>t.devices.get(a)).filter(a=>a!==void 0),St=({stacks:e,geometry:t})=>(F(),s.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute top-0 left-0",children:e.map(a=>{const o=a.groups.length,h=new Array(o).fill(0);let m=null;for(let d=o-1;d>=0;d-=1){const v=$e(a.groups[d],t),b=(v.length===0?0:Math.max(...v.map(w=>w.y+w.height)))+xe;m=m===null?b:Math.max(b,m+we),h[d]=m}const f=t.devices.get(a.deviceId);return a.groups.map((d,v)=>{const b=$e(d,t);if(b.length===0)return null;const w=o-1-v,D=Math.min(...b.map(j=>j.x)),I=Math.max(...b.map(j=>j.x)),u=(f?.y??Math.min(...b.map(j=>j.y)))-xe-Rs*w,p=d.tier==="declared",y=Ct(d);return s.jsx("div",{"data-mesh-scope":`${d.tier}:${d.prefix}`,"data-mesh-scope-level":v,className:P("absolute rounded-lg",d.tier==="probable"?"border border-dashed border-hairline-strong":"border border-control"),style:{left:D-xe-we*w,top:u,width:I+Ne-D+(xe+we*w)*2,height:h[v]-u},children:s.jsx("span",{"data-mesh-scope-label":"",className:P("absolute bottom-full left-1 mb-0.5 whitespace-nowrap text-meta",d.tier==="probable"?"text-ink-dim":"text-ink-muted",p&&"font-medium"),children:y})},`${d.tier}:${d.prefix}`)})})})),Oe=48,ze=1.25,Mt=.0015,Et=({graph:e,slots:t,nowSeconds:a,selectedDeviceId:o,sessions:h,sessionTotals:m,movingSessionId:f,canMove:d,onOpenDevice:v,onAskMove:b,onDropRefused:w,onShowAllSessions:D,summaryId:I})=>{F();const c=x.useRef(null),[u,p]=x.useState({width:0,height:0,clipWidth:0,clipHeight:0,left:0,top:0}),[y,j]=x.useState({k:1,tx:0,ty:0}),M=x.useRef(!1),E=x.useRef(!1),r=x.useRef(null),N=x.useMemo(()=>jt(e.devices,e.selfDeviceId),[e.devices,e.selfDeviceId]),R=x.useMemo(()=>Nt(N,t.devices),[N,t]),C=x.useMemo(()=>As(t,It(R)),[t,R]),S=x.useMemo(()=>({selfDeviceId:e.selfDeviceId,devices:new Map(e.devices.map(i=>[i.id,i])),networks:new Map(e.networks.map(i=>[i.id,i]))}),[e]),[_,O]=x.useState(ve),de=x.useRef({kind:"ground"}),te=x.useCallback((i,l)=>{const g=document.elementFromPoint(i,l),L=g?.closest("[data-mesh-device]");if(L){const G=L.getAttribute("data-mesh-device");if(G)return{kind:"device",deviceId:G}}const H=g?.closest("[data-mesh-network]");if(H){const G=H.getAttribute("data-mesh-network");if(G)return{kind:"network",networkId:G}}return{kind:"ground"}},[]),T=x.useMemo(()=>_.kind!=="dragging"&&_.kind!=="settling"?null:ge(_.payload,_.target,S),[_,S]),K=x.useCallback(i=>{if(!T)return null;if(T.kind==="plan"){const l=_.kind==="dragging"||_.kind==="settling"?_.target:null;return l&&l.kind==="device"&&l.deviceId===i?"accept":null}if(T.kind==="refused"){const l=_.kind==="dragging"||_.kind==="settling"?_.target:null;return l&&l.kind==="device"&&l.deviceId===i?"refuse":null}return null},[T,_]),ne=x.useCallback((i,l)=>{if(!d||i.button!==0)return;E.current=!1;const g=l.locality==="local"?e.selfDeviceId??"":l.owner_device,L=S.devices.get(g),H={session:l,ownerDeviceId:g,ownerLabel:L?.label??l.owner_device_name};try{i.currentTarget.setPointerCapture(i.pointerId)}catch{}O(G=>Q(G,{kind:"press",payload:H,x:i.clientX,y:i.clientY,pointerId:i.pointerId}))},[d,S,e.selfDeviceId]),ae=i=>{if(_.kind==="pressing"||_.kind==="dragging"){const l=te(i.clientX,i.clientY);de.current=l,O(g=>Q(g,{kind:"move",x:i.clientX,y:i.clientY,target:l}));return}V(i)},ce=i=>{if(ue(i),_.kind!=="pressing"&&_.kind!=="dragging")return;if(_.kind==="pressing"){O(g=>Q(g,{kind:"cancel"}));return}const l=ge(_.payload,_.target,S);E.current=!0,O(g=>Q(g,{kind:"release"})),l.kind==="plan"?b({plan:l.plan,alternatives:l.alternatives,risky:l.risky}):l.kind==="refused"&&w({code:l.code,sentence:l.sentence,reach:l.reach,remedy:l.remedy,plan:l.plan??null}),O(g=>Q(g,{kind:"settled"}))};x.useEffect(()=>()=>O(ve),[]);const ie=x.useCallback(()=>{j(Re(C.bounds,u))},[C.bounds,u]);x.useEffect(()=>{const i=c.current;if(!i)return;const l=()=>{const L=i.getBoundingClientRect();p({width:L.width,height:L.height,clipWidth:i.clientWidth,clipHeight:i.clientHeight,left:L.left,top:L.top})};l();const g=new ResizeObserver(l);return g.observe(i),()=>g.disconnect()},[]),x.useEffect(()=>{M.current||u.width<=0||u.height<=0||(M.current=!0,j(Re(C.bounds,u)))},[u,C.bounds]),x.useEffect(()=>{const i=r.current;if(r.current={width:u.width,height:u.height},!i||!M.current||u.width<=0||u.height<=0||u.width>=i.width&&u.height>=i.height||!o)return;const l=C.devices.get(o);l&&j(g=>{const L={width:u.clipWidth,height:u.clipHeight},H=Math.max(0,Math.min(L.width-C.bounds.width*g.k,L.height-C.bounds.height*g.k));return Ls(g,l,L,Math.min(Ts,H))})},[u,o,C]);const q=_.kind==="dragging"?{x:_.x-u.left+12,y:_.y-u.top+12}:{x:0,y:0},re=T?Ps(T):null,Y=x.useRef(null),k=x.useRef(null),A=x.useRef(null),z=x.useRef(null),B=x.useCallback(()=>{A.current=null;const i=Y.current,l=k.current;if(Y.current=null,k.current=null,i){const g=z.current;if(!g)return;j({k:g.transform.k,tx:g.transform.tx+(i.x-g.x),ty:g.transform.ty+(i.y-g.y)});return}l&&j(g=>je(g,{x:l.x,y:l.y},g.k*Math.exp(-l.deltaY*Mt)))},[]),$=x.useCallback(()=>{A.current===null&&(A.current=requestAnimationFrame(B))},[B]);x.useEffect(()=>()=>{A.current!==null&&cancelAnimationFrame(A.current)},[]);const Z=i=>{!(i.target===i.currentTarget)&&i.button!==1||i.button!==0&&i.button!==1||(z.current={x:i.clientX,y:i.clientY,transform:y},i.currentTarget.setPointerCapture(i.pointerId),i.preventDefault())},V=i=>{z.current&&(Y.current={x:i.clientX,y:i.clientY},$())},ue=i=>{z.current&&(z.current=null,Y.current=null,i.currentTarget.hasPointerCapture(i.pointerId)&&i.currentTarget.releasePointerCapture(i.pointerId))},J=x.useCallback(i=>{if(i.deltaY===0)return;i.preventDefault();const l=i.currentTarget.getBoundingClientRect();k.current={x:i.clientX-l.left,y:i.clientY-l.top,deltaY:i.deltaY},$()},[$]);x.useEffect(()=>{const i=c.current;if(i)return i.addEventListener("wheel",J,{passive:!1}),()=>i.removeEventListener("wheel",J)},[J]);const le=i=>{const l=i.shiftKey?Oe*4:Oe;switch(i.key){case"Escape":if(_.kind!=="pressing"&&_.kind!=="dragging")return;i.preventDefault(),_.kind==="dragging"&&(E.current=!0),O(g=>Q(g,{kind:"cancel"}));return;case"0":i.preventDefault(),ie();return;case"+":case"=":i.preventDefault(),j(g=>je(g,{x:u.width/2,y:u.height/2},g.k*ze));return;case"-":case"_":i.preventDefault(),j(g=>je(g,{x:u.width/2,y:u.height/2},g.k/ze));return;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{i.preventDefault();const g=i.key==="ArrowLeft"?l:i.key==="ArrowRight"?-l:0,L=i.key==="ArrowUp"?l:i.key==="ArrowDown"?-l:0;j(H=>({...H,tx:H.tx+g,ty:H.ty+L}));return}}};return s.jsxs("div",{ref:c,"data-mesh-canvas":"",role:"group","aria-labelledby":I,tabIndex:0,onPointerDown:Z,onPointerMove:ae,onPointerUp:ce,onPointerCancel:i=>{_.kind==="dragging"&&(E.current=!0),O(l=>Q(l,{kind:"cancel"})),ue(i)},"data-mesh-gesture":_.kind,"data-glass-well":"clear",onKeyDown:le,onDoubleClick:i=>{i.target===i.currentTarget&&ie()},className:P("relative min-h-0 flex-1 overflow-hidden rounded-lg border border-hairline bg-sunken","[touch-action:none]","cursor-grab active:cursor-grabbing","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-[-2px]"),children:[s.jsx("div",{"data-mesh-ground":"","aria-hidden":"true",className:"mesh-ground pointer-events-none absolute inset-0",style:{backgroundPosition:`${y.tx}px ${y.ty}px`}}),s.jsxs("div",{"data-mesh-world":"",className:"absolute top-0 left-0",style:{transform:`translate3d(${y.tx}px, ${y.ty}px, 0) scale(${y.k})`,transformOrigin:"0 0",width:C.bounds.width,height:C.bounds.height},children:[s.jsx(St,{stacks:R,geometry:C}),s.jsx(ut,{edges:e.edges,geometry:C,selectedDeviceId:o}),s.jsx("ul",{"aria-label":n("ui.mesh.mesh_canvas.networks"),className:"m-0 list-none p-0",children:e.networks.map(i=>{const l=C.networks.get(i.id);return l?s.jsx(bt,{network:i,x:l.x,y:l.y,refused:T?.kind==="refused"&&_.kind==="dragging"&&_.target.kind==="network"&&_.target.networkId===i.id},i.id):null})}),s.jsx("ul",{"aria-label":n("ui.mesh.mesh_canvas.devices"),className:"m-0 list-none p-0",children:e.devices.map(i=>{const l=C.devices.get(i.id);return l?s.jsx(vt,{device:i,x:l.x,y:l.y,nowSeconds:a,selected:i.id===o,sessions:h.get(i.id)??{rows:[],shown:[],hidden:0},sessionTotal:m.get(i.id)??i.sessionCount??0,dropState:K(i.id),movingSessionId:f,draggedSessionId:ct(_),onOpen:v,onChipPointerDown:ne,onChipClick:()=>{if(E.current){E.current=!1;return}v(i.id)},onShowAllSessions:D},i.id):null})})]}),_.kind==="dragging"&&s.jsx("div",{"data-mesh-ghost":"","aria-hidden":"true",className:"pointer-events-none absolute z-10 max-w-40 truncate rounded-sm border border-ink-dim bg-surface px-1.5 py-0.5 text-meta text-ink",style:{left:q.x,top:q.y},children:_.payload.session.name||"untitled"}),_.kind==="dragging"&&re&&s.jsx("div",{"data-mesh-indicator":"",className:P("pointer-events-none absolute z-10 rounded-sm border bg-surface px-2 py-1 text-meta",T?.kind==="refused"?"border-warning text-warning":"border-control text-ink"),style:{left:q.x,maxWidth:Math.max(160,u.width-q.x-12),...q.y>u.height*.6?{bottom:Math.max(12,u.height-q.y+8)}:{top:q.y+24}},children:re})]})};function Dt(e,t,a,o){const h=a.locality==="local"?t:a.owner_device,m=[];for(const f of e)if(f.id!==h){if(f.id===t){m.push({deviceId:f.id,label:o,verb:n("ui.mesh.mesh_card.recall_to_this_device"),keepVerb:n("ui.mesh.mesh_card.copy_here_leave_it_there")});continue}m.push({deviceId:f.id,label:f.label,verb:n("ui.mesh.mesh_card.move_to",{device:f.label}),keepVerb:n("ui.mesh.mesh_card.copy_to",{device:f.label})})}return m}function Rt(e,t,a){return Dt(e.devices,e.selfDeviceId,t,a)}function es(e,t,a){const o=Rt(e,t,a),h={selfDeviceId:e.selfDeviceId,devices:new Map(e.devices.map(d=>[d.id,d])),networks:new Map(e.networks.map(d=>[d.id,d]))},m=t.locality==="local"?e.selfDeviceId??"":t.owner_device,f=h.devices.get(m);return o.map(d=>{const v=ge({session:t,ownerDeviceId:m,ownerLabel:f?.label??t.owner_device_name},{kind:"device",deviceId:d.deviceId},h);return{...d,refused:v.kind==="refused"&&v.code!=="busy"?v.sentence:null}})}const ss=({session:e,destinations:t,disabled:a,onChoose:o,onOpenChange:h,trigger:m,triggerLabel:f})=>(F(),s.jsxs(ms,{onOpenChange:h,children:[s.jsx(hs,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":f,"data-mesh-session-menu":e.id,disabled:a||t.length===0,className:"rounded-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2 disabled:text-ink-disabled",children:m})}),s.jsxs(ps,{align:"start",className:"min-w-56",children:[s.jsx(xs,{children:se(e)}),s.jsx(Me,{}),t.map(d=>s.jsx(Ee,{"data-mesh-move-to":d.deviceId,disabled:!!d.refused,title:d.refused??void 0,onSelect:()=>o(d,!1),children:d.verb},d.deviceId)),s.jsx(Me,{}),t.map(d=>s.jsx(Ee,{"data-mesh-copy-to":d.deviceId,disabled:!!d.refused,title:d.refused??void 0,onSelect:()=>o(d,!0),children:d.keepVerb},`keep-${d.deviceId}`))]})]})),At=({device:e,sessions:t,sessionTotal:a,nowSeconds:o,destinationsFor:h,movingSessionId:m,canMove:f,canInvite:d,onClose:v,onMove:b,onShowInList:w,onInvite:D,onRemoveMember:I})=>{F();const c=ee(e),u=qe(e),p=e.reachable?[]:e.attempts??[];x.useEffect(()=>{const r=N=>{N.key!=="Escape"||N.defaultPrevented||N.target?.closest('[role="menu"],[role="dialog"]')||(document.querySelector(`[data-mesh-device-open="${e.id}"]`)?.focus(),v())};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e.id,v]);const y=e.memberships.every(r=>!r.active),j=e.sessionCount===null?Ge(null):n("ui.mesh.mesh_card.conversation_count",{count:e.sessionCount}),M=e.suspect?Be():[y?n("ui.mesh.mesh_card.revoked_membership"):j,pe(c)].filter(Boolean).join(" · "),E=a>t.rows.length?n("ui.mesh.mesh_card.shown_of",{shown:t.rows.length,total:a}):`${t.rows.length}`;return s.jsxs("aside",{"aria-label":n("ui.mesh.mesh_card.device_details",{device:e.label}),"data-mesh-panel":e.id,"data-glass-block":"",className:"flex w-80 shrink-0 flex-col gap-3 overflow-y-auto rounded-md border border-hairline bg-surface p-4",children:[s.jsxs("header",{className:"flex flex-col gap-1",children:[s.jsx(U,{size:"sm",variant:"ghost",className:"w-fit self-end","data-mesh-panel-close":"",onClick:v,children:n("ui.mesh.mesh_actions.close")}),s.jsx("h2",{className:"text-body-sm text-ink",children:e.label}),s.jsxs("p",{className:"flex items-center gap-1.5 text-meta text-ink-muted",children:[e.suspect&&s.jsx(Ie,{"aria-hidden":"true",className:"size-3.5 text-danger"}),!e.suspect&&c==="unanswered"&&s.jsx(us,{"aria-hidden":"true",className:"size-3.5 text-warning"}),M]})]}),s.jsx(oe,{}),s.jsxs("section",{className:"flex flex-col gap-2",children:[s.jsx("h3",{className:"text-meta text-ink-dim",children:n("ui.mesh.mesh_card.memberships")}),s.jsx("ul",{className:"m-0 flex list-none flex-col gap-2 p-0",children:e.memberships.map(r=>s.jsxs("li",{className:"flex flex-col gap-1",children:[s.jsxs("span",{className:"flex items-center gap-2 text-body-sm text-ink",children:[s.jsx(Ce,{"aria-hidden":"true",className:"size-3.5 text-ink-muted"}),r.networkName]}),s.jsxs("span",{className:"text-meta text-ink-dim",children:[r.role||"member",r.capabilities.length>0?` · ${r.capabilities.join(", ")}`:"",r.active?"":n("ui.mesh.mesh_card.revoked")]}),d&&r.active&&s.jsxs(U,{size:"sm",variant:"ghost",className:"w-fit","data-mesh-remove-member":`${r.networkId}:${e.id}`,onClick:()=>I(e,r.networkId),children:[n("ui.mesh.mesh_card.remove_from"),r.networkName,"…"]})]},r.networkId))}),d&&s.jsx(U,{size:"sm",variant:"secondary",className:"w-fit","data-mesh-invite":e.id,onClick:()=>D(e),children:n("ui.mesh.mesh_actions.invite_to_a_network")})]}),s.jsx(oe,{}),s.jsxs("section",{className:"flex shrink-0 flex-col gap-2",children:[s.jsxs("h3",{className:"text-meta text-ink-dim",children:[n("ui.mesh.mesh_card.conversations"),s.jsxs("span",{className:"text-ink-disabled",children:["(",ee(e)!=="self"&&ee(e)!=="reached"?Ke(null):E,")"]})]}),be(e,o)?s.jsx("p",{className:"text-meta text-warning",children:be(e,o)}):t.rows.length===0?s.jsx("p",{className:"text-meta text-ink-dim",children:e.sessionCount===null?n("ui.mesh.mesh_card.this_device_did_not_report_its_conversations"):n("ui.mesh.mesh_card.no_conversations_here")}):s.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:t.rows.map(r=>s.jsxs("li",{"data-mesh-panel-session":r.id,className:P("flex items-center gap-2 rounded-sm px-2 py-1","border border-hairline bg-elevated",m===r.id&&"border-control"),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",title:se(r),children:se(r)}),s.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:Qe(r,e.label,ee(e))}),m===r.id?s.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:n("ui.mesh.mesh_card.moving")}):s.jsx(ss,{session:r,destinations:h(r),disabled:!f,onChoose:(N,R)=>b(r,N,R),trigger:s.jsx(Ze,{"aria-hidden":"true",className:"size-4"}),triggerLabel:n("ui.mesh.mesh_card.move_conversation",{conversation:se(r)})})]},r.id))})]}),s.jsx(oe,{}),s.jsxs("section",{className:"flex flex-col gap-2",children:[s.jsx("h3",{className:"text-meta text-ink-dim",children:n("ui.mesh.mesh_card.network_addresses")}),e.endpoints.length===0?s.jsx("p",{className:"text-meta text-ink-dim",children:n("ui.mesh.mesh_card.no_address_published")}):s.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:e.endpoints.map(r=>s.jsxs("li",{className:"flex items-baseline justify-between gap-2",children:[s.jsx("span",{className:"min-w-0 truncate font-mono text-body-sm text-ink",children:r}),s.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:n("ui.mesh.mesh_card.advertised")})]},r))})]}),s.jsx(oe,{}),s.jsxs("section",{className:"flex flex-col gap-2",children:[s.jsx("h3",{className:"text-meta text-ink-dim",children:n("ui.mesh.mesh_card.status")}),s.jsxs("dl",{className:"m-0 flex flex-col gap-1",children:[s.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[s.jsx("dt",{className:"text-meta text-ink-dim",children:n("ui.mesh.mesh_card.reach")}),s.jsx("dd",{className:"m-0 text-body-sm text-ink",children:pe(c)})]}),s.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[s.jsx("dt",{className:"text-meta text-ink-dim",children:n("ui.mesh.mesh_card.last_status_frame")}),s.jsx("dd",{className:"m-0 text-body-sm text-ink",children:e.lastSeenAt===null?n("ui.mesh.mesh_card.never"):$s(o-e.lastSeenAt)})]})]}),!e.reachable&&(u!==""||p.length>0)&&s.jsxs("div",{className:"flex flex-col gap-1",children:[u&&s.jsx("p",{className:"m-0 text-meta text-warning",children:u}),e.linkState==="handshake_refused"&&s.jsx("p",{className:"m-0 text-meta text-ink-dim",children:n("ui.mesh.mesh_reach.handshake_refused_hint")}),p.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{id:`mesh-attempts-label-${e.id}`,className:"text-meta text-ink-dim",children:n("ui.mesh.mesh_reach.addresses_tried")}),s.jsx("ul",{role:"list","aria-labelledby":`mesh-attempts-label-${e.id}`,className:"m-0 flex list-none flex-col gap-0.5 p-0",children:p.map((r,N)=>{const R=Ye(r.detail);return s.jsxs("li",{"data-mesh-attempt":r.endpoint,className:"flex items-baseline justify-between gap-2",children:[s.jsx("span",{className:"min-w-0 truncate font-mono text-meta text-ink",children:r.endpoint}),s.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:R})]},`${r.endpoint}:${N}`)})})]})]}),!u&&p.length===0&&e.reason&&s.jsx("p",{className:"text-meta text-warning",children:e.reason})]}),s.jsx(oe,{}),s.jsx(U,{size:"sm",variant:"ghost",className:"w-fit","data-mesh-show-in-list":e.id,onClick:()=>w(e.id),children:n("ui.mesh.mesh_card.show_in_list")})]})},Lt=["name","chats","state"],Pt={get name(){return n("ui.mesh.mesh_list.name")},get chats(){return n("ui.mesh.mesh_list.sort_conversations")},get state(){return n("ui.mesh.mesh_list.state")}},He={suspect:0,relay_down:1,handshake_refused:2,unreachable:3,self:4,reachable:5};function Tt(e,t){const a=[...e];switch(t){case"chats":return a.sort((o,h)=>(h.sessionCount??-1)-(o.sessionCount??-1)||o.label.localeCompare(h.label)),a;case"state":return a.sort((o,h)=>He[o.state]-He[h.state]||o.label.localeCompare(h.label)),a;default:return a.sort((o,h)=>o.label.localeCompare(h.label))}}const We=8;function $t(e,t){if(e.locality==="local")return e.live_state||"here";const a=e.owner_device_name||t,o=e.live_state?` · ${e.live_state}`:"";return e.reachable?n("ui.mesh.mesh_list.on_device_state",{device:a,state:o}):n("ui.mesh.mesh_list.on_device_no_answer",{device:a})}const Ot=({graph:e,nowSeconds:t,selectedDeviceId:a,sessions:o,selfLabel:h,canMove:m,onSelect:f,onMove:d,onInvite:v,onRemove:b})=>{F();const[w,D]=x.useState("name"),I=x.useMemo(()=>e.networks.map(c=>({network:c,members:Tt(e.devices.filter(u=>u.memberships.some(p=>p.networkId===c.id)),w)})),[e,w]);return s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto pr-1",children:[s.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[s.jsx("legend",{className:"sr-only",children:n("ui.mesh.mesh_list.sort_devices_by")}),s.jsx("div",{"data-glass-well":"",className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:Lt.map(c=>s.jsx("button",{type:"button","aria-pressed":w===c,onClick:()=>D(c),className:P("h-6 rounded-sm px-3 text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart","hover:text-ink","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2",w===c&&"bg-surface text-ink"),children:Pt[c]},c))})]}),I.map(({network:c,members:u})=>s.jsxs("section",{"data-mesh-network-group":c.id,className:"flex flex-col gap-2",children:[s.jsxs("h2",{className:"flex flex-wrap items-baseline gap-2 text-body-sm text-ink",title:n("ui.mesh.mesh_list.epoch",{epoch:c.epoch}),children:[c.label,s.jsxs("span",{className:"text-meta text-ink-dim",children:[c.trust," ·"," ",n("ui.mesh.mesh_graph.device_count",{count:c.memberCount}),c.revokedCount>0?n("ui.mesh.mesh_list.revoked_count",{count:c.revokedCount}):""]})]}),s.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:u.map(p=>{const y=p.memberships.find(S=>S.networkId===c.id),j=p.id===a,M=o.get(p.id),E=M?.rows??[],r=M?Ve(M,p.sessionCount):p.sessionCount??0,N=ee(p),R=qe(p),C=p.reachable?[]:p.attempts??[];return s.jsxs("li",{"data-mesh-device-row":p.id,"data-mesh-state":p.state,"aria-current":j?"true":void 0,className:P("flex flex-col gap-1 rounded-md px-3 py-2","border border-hairline bg-surface",j&&"border-ink bg-row-selected"),children:[s.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1",children:[s.jsx("button",{type:"button","data-mesh-device-open":p.id,onClick:()=>f(p.id),className:P("min-w-0 flex-1 truncate text-left text-body-sm text-ink","hover:text-ink-muted","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2"),children:p.label}),s.jsxs("span",{className:P("flex shrink-0 items-center gap-1 text-meta",Fe[N]),"data-mesh-reach":N,children:[p.suspect&&s.jsx(Ie,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-danger"}),p.suspect?pe(N):Ue(p,t),p.suspect&&s.jsx("span",{className:"shrink-0 rounded-sm border border-danger px-1 text-danger",children:Be()})]}),s.jsxs("span",{className:"shrink-0 text-meta text-ink-dim",children:[y?.role?`${y.role} · `:"",y&&!y.active?n("ui.mesh.mesh_list.revoked"):n("ui.mesh.mesh_list.member")]})]}),(R!==""||C.length>0)&&!p.reachable&&s.jsxs("div",{className:"flex flex-col gap-0.5",children:[R&&s.jsx("span",{className:"text-meta text-warning",children:R}),C.map((S,_)=>{const O=Ye(S.detail);return s.jsx("span",{"data-mesh-attempt":S.endpoint,className:"text-meta text-ink-dim",children:O?`${S.endpoint} — ${O}`:S.endpoint},`${S.endpoint}:${_}`)})]}),be(p,t)?s.jsxs("span",{className:"text-meta text-warning",children:[n("ui.mesh.mesh_card.conversations")," (",Ke(null),") ·"," ",be(p,t)]}):E.length>0?s.jsxs(s.Fragment,{children:[s.jsx(oe,{className:"my-1"}),s.jsx("ul",{className:"m-0 flex list-none flex-col gap-0.5 p-0",children:E.slice(0,We).map(S=>s.jsxs("li",{"data-mesh-row-session":S.id,className:"flex items-center gap-2 py-0.5",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-meta text-ink-muted",children:S.name||S.id}),s.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:$t(S,h)}),s.jsx(ss,{session:S,destinations:es(e,S,h),disabled:!m,onChoose:(_,O)=>d(S,_,O),trigger:s.jsx(Ze,{"aria-hidden":"true",className:"size-3.5"}),triggerLabel:n("ui.mesh.mesh_list.move_conversation",{conversation:S.name||S.id})})]},S.id))}),r>E.slice(0,We).length&&s.jsx("button",{type:"button",onClick:()=>f(p.id),className:"w-fit text-meta text-ink-dim hover:text-ink",children:n("ui.mesh.mesh_list.show_all_panel",{count:r})})]}):s.jsx("span",{className:"text-meta text-ink-dim",children:n("ui.mesh.mesh_list.conversation_count",{count:r})}),(y?.active||p.state!=="self")&&s.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[s.jsx(U,{size:"sm",variant:"ghost","data-mesh-invite":p.id,onClick:()=>v({deviceId:p.id,deviceLabel:p.label}),children:n("ui.mesh.mesh_actions.invite_to_a_network")}),y?.active&&s.jsxs(U,{size:"sm",variant:"ghost","data-mesh-remove-member":`${c.id}:${p.id}`,onClick:()=>b({networkId:c.id,networkLabel:c.label,deviceId:p.id,deviceLabel:p.label}),children:[n("ui.mesh.mesh_card.remove_from"),c.label,"…"]})]})]},p.id)})})]},c.id)),e.unmatchedPeers.length>0&&s.jsxs("p",{className:"text-meta text-warning",children:[n("ui.mesh.mesh_graph.device_count",{count:e.unmatchedPeers.length})," ",n("ui.mesh.mesh_list.answered_the_peer_read_but_is_in")]})]})},zt=["canvas","list"],Ht={get canvas(){return n("ui.mesh.mesh_page.canvas")},get list(){return n("ui.mesh.mesh_page.list")}},Wt=({state:e,initialPresentation:t="canvas",graph:a,nowSeconds:o,checking:h,staleError:m,onRetry:f,approvals:d,sessions:v,sessionError:b,selfLabel:w,movingSessionId:D,canMove:I,pendingMove:c,onAskMove:u,onDropRefused:p,onChooseMove:y,onCancelMove:j,moveBusy:M,moveReport:E,onDismissReport:r,onWaitForIdle:N,onUndoCopy:R,invite:C,onOpenInvite:S,onInvite:_,onCloseInvite:O,inviteBusy:de,inviteReceipt:te,inviteRefusal:T,remove:K,onOpenRemove:ne,onRemove:ae,onCloseRemove:ce,removeBusy:ie,removeRefusal:q,removed:re})=>{F();const[Y,k]=x.useState(t),[A,z]=x.useState(null),B=a?Os(a):"",$="mesh-summary",Z=zs(a),V=Hs(a,v,a?.selfDeviceId??null),ue=x.useMemo(()=>{const l=new Map;for(const g of a?.devices??[]){const L=V.byDevice.get(g.id);l.set(g.id,L?Ve(L,g.sessionCount):g.sessionCount??0)}return l},[a,V]),J=x.useCallback(l=>{z(l)},[]),le=a?a.devices.find(l=>l.id===A)??null:null,i=x.useCallback((l,g,L)=>{if(!a)return null;const H={selfDeviceId:a.selfDeviceId,devices:new Map(a.devices.map(X=>[X.id,X])),networks:new Map(a.networks.map(X=>[X.id,X]))},G=l.locality==="local"?a.selfDeviceId??"":l.owner_device,ts=H.devices.get(G),W=ge({session:l,ownerDeviceId:G,ownerLabel:ts?.label??l.owner_device_name},{kind:"device",deviceId:g.deviceId},H);if(W.kind==="refused")return p({code:W.code,sentence:W.sentence,reach:W.reach,remedy:W.remedy,plan:W.plan??null}),null;if(W.kind==="none")return null;const Se=L?W.alternatives.find(X=>X.keep)??W.plan:W.plan,ns=[W.plan,...W.alternatives].filter(X=>X.keep!==Se.keep),as={plan:Se,alternatives:ns,risky:W.risky};u(as)},[a,u,p]);return s.jsxs("div",{className:"flex h-full min-h-0 flex-col gap-6 overflow-y-auto p-6",children:[s.jsx(cs,{title:n("ui.mesh.mesh_page.mesh"),icon:Ce,subtitle:n("ui.mesh.mesh_page.devices_this_app_is_paired_with_and"),children:s.jsxs("div",{className:"flex items-center gap-4",children:[h&&s.jsx("output",{className:"text-meta text-ink-dim",children:n("ui.mesh.mesh_page.checking")}),(e.kind==="ready"||e.kind==="loading")&&s.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[s.jsx("legend",{className:"sr-only",children:n("ui.mesh.mesh_page.presentation")}),s.jsx("div",{"data-glass-well":"",className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:zt.map(l=>s.jsx("button",{type:"button","aria-pressed":Y===l,disabled:e.kind!=="ready",onClick:()=>k(l),className:P("h-6 rounded-sm px-3 text-body-sm text-ink-muted transition-colors duration-fast ease-out-quart","hover:text-ink","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-2","disabled:text-ink-dim disabled:hover:text-ink-dim",Y===l&&"bg-surface text-ink"),children:Ht[l]},l))})]})]})}),s.jsx(ot,{rows:d.rows,error:d.error,pending:d.pending,refusal:d.decisionRefusal,onDecide:d.onDecide,onRetry:d.onRetry,nowSeconds:d.nowSeconds,networkNames:new Map((a?.networks??[]).map(l=>[l.id,l.label]))}),e.kind==="loading"&&s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[s.jsx(De,{className:"h-4 w-64"}),s.jsx(De,{className:"min-h-40 w-full flex-1"})]}),e.kind==="error"&&s.jsxs(fe,{variant:"warning",className:"flex-col items-start gap-2",children:[s.jsx("p",{children:e.message}),s.jsx(U,{variant:"secondary",size:"sm",onClick:f,className:"w-fit",children:n("ui.mesh.mesh_approvals_tray.ask_again")})]}),e.kind==="empty"&&s.jsx("div",{"data-glass-block":"",className:"flex min-h-0 flex-1 items-center justify-center rounded-lg border border-hairline bg-surface p-6",children:s.jsxs("div",{className:"flex flex-col items-start gap-3",children:[s.jsx("h2",{className:"text-heading text-ink",children:n("ui.mesh.mesh_page.no_network_on_this_device")}),s.jsx("p",{className:"max-w-140 text-body-sm text-ink-muted",children:n("ui.mesh.mesh_page.this_device_is_not_in_any_network")}),s.jsx("code",{className:"rounded-sm bg-sunken px-2 py-1 font-mono text-meta text-ink",children:"lop network init <name>"}),s.jsx("p",{className:"text-meta text-ink-dim",children:n("ui.mesh.mesh_page.a_network_appears_here_once_this_device")})]})}),e.kind==="ready"&&a&&s.jsx(s.Fragment,{children:s.jsxs("div",{className:"flex min-h-[22rem] flex-1 gap-4",children:[s.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-3",children:[s.jsx("p",{id:$,className:"text-meta text-ink-muted","data-mesh-summary":"",children:B}),m&&s.jsx(fe,{variant:"warning",children:s.jsx("p",{children:m})}),b&&s.jsx(fe,{variant:"warning",children:s.jsx("p",{children:b})}),E&&s.jsx(Ws,{receipt:E.kind==="moved"?{verb:E.verb,detail:E.detail,undo:E.undo}:null,refusal:E.kind==="refused"?E.refusal:null,canWait:E.kind==="refused"&&E.plan!==null,onWait:N,onRecheck:f,onUndo:R,onDismiss:r,pending:M}),Y==="canvas"?s.jsx(Et,{graph:a,slots:Z,nowSeconds:o,selectedDeviceId:A,sessions:V.byDevice,sessionTotals:ue,movingSessionId:D,canMove:I,onOpenDevice:J,onAskMove:u,onDropRefused:p,onShowAllSessions:J,summaryId:$}):s.jsx(Ot,{graph:a,nowSeconds:o,selectedDeviceId:A,sessions:V.byDevice,selfLabel:w,canMove:I,onSelect:J,onMove:i,onInvite:S,onRemove:ne})]}),le&&s.jsx(At,{device:le,sessions:V.byDevice.get(le.id)??{rows:[],shown:[],hidden:0},sessionTotal:ue.get(le.id)??0,nowSeconds:o,canMove:I,canInvite:e.kind==="ready",movingSessionId:D,destinationsFor:l=>es(a,l,w),onClose:()=>z(null),onMove:i,onInvite:l=>S({deviceId:l.id,deviceLabel:l.label}),onRemoveMember:(l,g)=>{const L=a.networks.find(H=>H.id===g);ne({networkId:g,networkLabel:L?.label??g,deviceId:l.id,deviceLabel:l.label})},onShowInList:l=>{J(l),k("list")}})]})}),s.jsx(Fs,{open:c!==null,plan:c?.plan??Ft,alternatives:c?.alternatives??[],risky:c?.risky??!1,busy:M,onCancel:j,onChoose:y}),C&&s.jsx(qs,{open:C.open,options:C.options,deviceId:C.deviceId,deviceLabel:C.deviceLabel,onClose:O,onInvite:_,pending:de,receipt:te,refusal:T}),K&&s.jsx(Bs,{open:K.open,networkLabel:K.networkLabel,deviceLabel:K.deviceLabel,onClose:ce,onConfirm:ae,pending:ie,refusal:q,removed:re})]})},Ft={sessionId:"",to:"",keep:!1,verb:"",waitS:0,lost:null},Zt=({initialPresentation:e})=>{F();const t=os(),a=_e(t.data,"peers")==="enabled",o=_e(t.data,"session_transfer")==="enabled",h=Ys(a,{stamp:()=>ke.getState().beginAnswer()}),m=Gs(a),f=Us(a,{poll:!1,stamp:()=>ke.getState().beginAnswer()}),d=x.useMemo(()=>({peers:h,networks:m}),[h,m]),v=Ks(d),b=Vs(d),w=Xs(),D=_e(t.data,"approvals")==="enabled",I=Zs(a&&D,{poll:!1}),c=Js(),u=c.isError?{approvalId:c.variables?.approvalId??null,...Qs(c.error)}:null,p=x.useMemo(()=>Math.floor((I.dataUpdatedAt||Date.now())/1e3),[I.dataUpdatedAt]),y=ke(k=>k.settlePlacement),j=et(),M=st(),[E,r]=x.useState(null),[N,R]=x.useState(null),[C,S]=x.useState(null),[_,O]=x.useState(null),[de,te]=x.useState(null),[T,K]=x.useState(null),[ne,ae]=x.useState(null),ce=x.useMemo(()=>{const k=Math.max(h.dataUpdatedAt,m.dataUpdatedAt);return Math.floor((k||Date.now())/1e3)},[h.dataUpdatedAt,m.dataUpdatedAt]),ie=x.useCallback(()=>{h.refetch(),m.refetch(),f.refetch()},[h,m,f]),q=x.useCallback((k,A)=>{r(null);const z={sessionId:k.sessionId,to:k.to,keep:k.keep,waitS:A??k.waitS};w.mutate(z,{onSuccess:B=>{if(B.kind==="moved"){const{receipt:$}=B;y(k.sessionId,$);const Z=$.locality==="local"?n("ui.mesh.mesh_drop.this_device"):b?.devices.find(V=>V.id===$.owner_device)?.label??$.owner_device;R({kind:"moved",verb:$.mode==="keep"?n("ui.mesh.mesh_page.copied"):n("ui.mesh.mesh_page.moved"),detail:$.mode==="keep"?n("ui.mesh.mesh_page.copy_receipt",{destination:Z,suffix:$.new_session_id.slice(-6)}):n("ui.mesh.mesh_page.move_receipt",{destination:Z,retirement:$.source_retired?n("ui.mesh.mesh_page.the_copy_here_is_gone"):""}),undo:$.mode==="keep"?{sessionId:$.new_session_id,to:"local",keep:!1,verb:n("ui.mesh.mesh_page.bring_copy_back",{device:Z}),waitS:0,lost:tt(Z,n("ui.mesh.mesh_drop.this_device"))}:null});return}R({kind:"refused",refusal:B.refusal,plan:k})},onError:()=>{R({kind:"refused",refusal:{code:"move_failed",sentence:n("ui.mesh.mesh_page.the_move_could_not_be_sent_nothing"),status:null,unconfirmed:!1},plan:k})}})},[b,w,y]),re=x.useMemo(()=>{if(!b)return[];const k=C?.deviceId,A=k?b.devices.find(z=>z.id===k):void 0;return b.networks.filter(z=>{if(!A)return!0;const B=A.memberships.find($=>$.networkId===z.id);return!B||!B.active}).map(z=>({id:z.id,label:z.label}))},[b,C]);if(!a)return s.jsx(ds,{to:"/chat",replace:!0});const Y=v.kind==="ready"?h.error?me(h.error):m.error?me(m.error):null:null;return s.jsx(Wt,{initialPresentation:e,state:v,graph:b,nowSeconds:ce,checking:h.isFetching||m.isFetching,staleError:Y,onRetry:ie,approvals:{rows:I.data??[],error:I.isError?nt(I.error):null,pending:c.isPending?c.variables??null:null,decisionRefusal:u,onDecide:(k,A)=>c.mutate({approvalId:k,decision:A}),onRetry:()=>void I.refetch(),nowSeconds:p},sessions:f.data?.rows??[],movingSessionId:w.isPending?w.variables?.sessionId??null:null,sessionError:f.isError?me(f.error):null,selfLabel:b?.devices.find(k=>k.state==="self")?.label??n("ui.mesh.mesh_drop.this_device"),canMove:o,pendingMove:E,onAskMove:r,onDropRefused:k=>R({kind:"refused",refusal:{code:k.code,sentence:k.sentence,reach:k.reach,status:null,unconfirmed:!1},plan:k.plan}),onChooseMove:k=>q(k),onCancelMove:()=>r(null),moveBusy:w.isPending,moveReport:N,onDismissReport:()=>R(null),onWaitForIdle:()=>{N?.kind!=="refused"||!N.plan||q(N.plan,qt)},onUndoCopy:()=>{N?.kind!=="moved"||!N.undo||r({plan:N.undo,alternatives:[],risky:!1})},invite:C===null?null:{open:!0,deviceId:C.deviceId,deviceLabel:C.deviceLabel,options:re},onOpenInvite:k=>{O(null),te(null),S(k)},onInvite:k=>{j.mutate(k,{onSuccess:A=>O(A),onError:A=>te({code:"invite_refused",sentence:me(A),status:null,unconfirmed:!1})})},onCloseInvite:()=>S(null),inviteBusy:j.isPending,inviteReceipt:_,inviteRefusal:de,remove:T===null?null:{open:!0,networkId:T.networkId,networkLabel:T.networkLabel,deviceId:T.deviceId,deviceLabel:T.deviceLabel},onOpenRemove:k=>{ae(null),K(k)},onRemove:k=>{T&&M.mutate({networkId:T.networkId,deviceId:T.deviceId,confirm:k},{onSuccess:A=>ae(A)})},onCloseRemove:()=>K(null),removeBusy:M.isPending,removeRefusal:M.isError?{code:"remove_refused",sentence:me(M.error),status:null,unconfirmed:!1}:null,removed:ne})},qt=300;export{Zt as MeshPage,Wt as MeshSurface,Zt as default};