local-operator-ui 0.44.0 → 0.44.2

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 (112) hide show
  1. package/out/main/index.js +32506 -27973
  2. package/out/preload/index.js +84 -6
  3. package/out/renderer/assets/{_basePickBy-D3VtwrNY.js → _basePickBy-LPJBKSk3.js} +1 -1
  4. package/out/renderer/assets/{_baseUniq-D5X85E0S.js → _baseUniq-D8M8HOYM.js} +1 -1
  5. package/out/renderer/assets/agent-details-page-CZuUDIS7.js +6 -0
  6. package/out/renderer/assets/agent-hub-page-B2h53zmZ.js +6 -0
  7. package/out/renderer/assets/agents-page-DxPAtB0k.js +7 -0
  8. package/out/renderer/assets/{approvalsOverlay-BUwR8zXi.js → approvalsOverlay-BjR3EVfg.js} +1 -1
  9. package/out/renderer/assets/{arc-C5lHNCVd.js → arc-Blq81BHO.js} +1 -1
  10. package/out/renderer/assets/{architectureDiagram-IEHRJDOE-DMuNgh30.js → architectureDiagram-IEHRJDOE-BKX_zyB3.js} +1 -1
  11. package/out/renderer/assets/{blockDiagram-JOT3LUYC-DBulh7Ye.js → blockDiagram-JOT3LUYC-DesagpJf.js} +1 -1
  12. package/out/renderer/assets/{book-open-YbPNmvto.js → book-open-BGI5fs27.js} +1 -1
  13. package/out/renderer/assets/browser-page-C156D5SG.js +1 -0
  14. package/out/renderer/assets/{browser-webauthn-prompt-YVU9CDM6.js → browser-webauthn-prompt-dv7y6_dA.js} +1 -1
  15. package/out/renderer/assets/{building-2-Dk-t19G0.js → building-2-D2OTMmkt.js} +1 -1
  16. package/out/renderer/assets/{c4Diagram-VJAJSXHY-L3-9aXQh.js → c4Diagram-VJAJSXHY-CWsH54Hv.js} +1 -1
  17. package/out/renderer/assets/channel-DEPypRI4.js +1 -0
  18. package/out/renderer/assets/{chunk-4BMEZGHF-CgXFdlYf.js → chunk-4BMEZGHF-B0-zmu4b.js} +1 -1
  19. package/out/renderer/assets/{chunk-A2AXSNBT-DT1C_gy2.js → chunk-A2AXSNBT-RQCYYGRS.js} +1 -1
  20. package/out/renderer/assets/{chunk-AEK57VVT-YwH-fCeY.js → chunk-AEK57VVT-DwkZ07Wr.js} +1 -1
  21. package/out/renderer/assets/{chunk-D6G4REZN-CPspVwrW.js → chunk-D6G4REZN-BWg_1fD9.js} +1 -1
  22. package/out/renderer/assets/{chunk-RZ5BOZE2-BEbcJaEy.js → chunk-RZ5BOZE2-3EjCkn2h.js} +1 -1
  23. package/out/renderer/assets/{chunk-XZIHB7SX-BZPybVmi.js → chunk-XZIHB7SX-DoadzlFd.js} +1 -1
  24. package/out/renderer/assets/classDiagram-GIVACNV2-D64NGwBp.js +1 -0
  25. package/out/renderer/assets/classDiagram-v2-COTLJTTW-D64NGwBp.js +1 -0
  26. package/out/renderer/assets/clone-BrsLxtaK.js +1 -0
  27. package/out/renderer/assets/{console-mirror-BiNs1Fcs.js → console-mirror-Cx1_mcwT.js} +10 -10
  28. package/out/renderer/assets/{consoleCapture-C6-j0c5S.js → consoleCapture-CBiwH6qH.js} +1 -1
  29. package/out/renderer/assets/{conversation-input-sync-BNDyyAZz.js → conversation-input-sync-6W6mDd5c.js} +225 -225
  30. package/out/renderer/assets/{dagre-OKDRZEBW-WqN1d2Ic.js → dagre-OKDRZEBW-CkNv39Aw.js} +1 -1
  31. package/out/renderer/assets/{diagram-SSKATNLV-DYfmB1X1.js → diagram-SSKATNLV-DKGhEDc0.js} +1 -1
  32. package/out/renderer/assets/{diagram-VNBRO52H-Bfu4SDNY.js → diagram-VNBRO52H-2dRMMinF.js} +1 -1
  33. package/out/renderer/assets/{en-US-CHJkXXr4.js → en-US-CW_dDnkH.js} +1 -1
  34. package/out/renderer/assets/{erDiagram-Q7BY3M3F-IWOis8-U.js → erDiagram-Q7BY3M3F-BaZqUE9f.js} +1 -1
  35. package/out/renderer/assets/{error-boundary-Bq37z0Vv.js → error-boundary-BhcUnSSp.js} +2 -2
  36. package/out/renderer/assets/{flowDiagram-4HSFHLVR-DG_QDSF3.js → flowDiagram-4HSFHLVR-DO71jsf7.js} +1 -1
  37. package/out/renderer/assets/{ganttDiagram-APWFNJXF-BN03PoHm.js → ganttDiagram-APWFNJXF-aaChmBo1.js} +1 -1
  38. package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-Bif0BK48.js → gitGraphDiagram-7IBYFJ6S-DH2o95aG.js} +1 -1
  39. package/out/renderer/assets/{graph-C-tc8AsB.js → graph-BzuMIyA9.js} +1 -1
  40. package/out/renderer/assets/{hash-C3PLrCW5.js → hash-Bof-oLZ7.js} +1 -1
  41. package/out/renderer/assets/{heart-DDY0lTmm.js → heart-Bd5kZnjR.js} +1 -1
  42. package/out/renderer/assets/{index-IM2mLpeL.js → index-B0Ue5RBi.js} +1 -1
  43. package/out/renderer/assets/index-BABrnwf5.css +1 -0
  44. package/out/renderer/assets/{index-C1xioNnx.js → index-Bf_5C9hH.js} +198 -198
  45. package/out/renderer/assets/{index-B4nU7SY-.js → index-CNnTZGuV.js} +1 -1
  46. package/out/renderer/assets/{index-OcjLnSVT.js → index-CxK1ypFa.js} +1 -1
  47. package/out/renderer/assets/infoDiagram-PH2N3AL5-DZJ-3Hbl.js +2 -0
  48. package/out/renderer/assets/{installer-DVWaW2Cw.js → installer-BTKc-9AM.js} +1 -1
  49. package/out/renderer/assets/{journeyDiagram-U35MCT3I-_OmkcLjc.js → journeyDiagram-U35MCT3I-B1iYgquG.js} +1 -1
  50. package/out/renderer/assets/{kanban-definition-NDS4AKOZ-DUSiV5yR.js → kanban-definition-NDS4AKOZ-D6b_9SBk.js} +1 -1
  51. package/out/renderer/assets/{layout-BwlaoNdS.js → layout-BYe1V9vC.js} +1 -1
  52. package/out/renderer/assets/legacy-agents-page-B4QsRAZI.js +33 -0
  53. package/out/renderer/assets/{library-page-ckanGPFY.js → library-page-VgK0BSR2.js} +3 -3
  54. package/out/renderer/assets/{mermaid.core-CrjcyFIw.js → mermaid.core-CENNKUw2.js} +5 -5
  55. package/out/renderer/assets/mesh-page-CEgyAVW-.js +1 -0
  56. package/out/renderer/assets/{messages-Bsgf6o-p.js → messages-Bst4VOU3.js} +10 -10
  57. package/out/renderer/assets/{mindmap-definition-ALO5MXBD-B-X_MKbg.js → mindmap-definition-ALO5MXBD-DPYnshtf.js} +1 -1
  58. package/out/renderer/assets/{mini-_lgzfzw2.js → mini-DjdzboAc.js} +1 -1
  59. package/out/renderer/assets/{notebook-pen-BYY7185A.js → notebook-pen-CZVJiq5R.js} +1 -1
  60. package/out/renderer/assets/org-access-DZc8cPye.js +1 -0
  61. package/out/renderer/assets/org-surface-gate-Bj7rZIwL.js +1 -0
  62. package/out/renderer/assets/{page-header-CSOT2M6K.js → page-header-Dtg6CqtK.js} +1 -1
  63. package/out/renderer/assets/parseISO-CxPiCKvF.js +1 -0
  64. package/out/renderer/assets/path-utils-CzhWDDSj.js +58 -0
  65. package/out/renderer/assets/{pieDiagram-IB7DONF6-KbwgG4tn.js → pieDiagram-IB7DONF6-1_U-X3IZ.js} +1 -1
  66. package/out/renderer/assets/{projects-page-CVNMOB_d.js → projects-page-Bw-AAZ11.js} +6 -6
  67. package/out/renderer/assets/publication-validation-Iutn5hzY.js +1 -0
  68. package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-Bjz4TG3c.js → quadrantDiagram-7GDLP6J5-kbwdrehe.js} +1 -1
  69. package/out/renderer/assets/{radar-MK3ICKWK-BKRNfIwb.js → radar-MK3ICKWK-DpsIZo-R.js} +1 -1
  70. package/out/renderer/assets/{radient-auth-buttons-OK28kSbr.js → radient-auth-buttons-C1Juzc0D.js} +1 -1
  71. package/out/renderer/assets/{requirementDiagram-KVF5MWMF-D4k7IA0L.js → requirementDiagram-KVF5MWMF-qtUg8gWV.js} +1 -1
  72. package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-Dd96CGIr.js → sankeyDiagram-QLVOVGJD-B6i8Lf5L.js} +1 -1
  73. package/out/renderer/assets/{schedules-page-Bf3w5M5d.js → schedules-page-DjiYevaS.js} +2 -2
  74. package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-dLuGQfA8.js → sequenceDiagram-X6HHIX6F-B3NVLrcT.js} +1 -1
  75. package/out/renderer/assets/settings-page-BUpTYpEG.js +287 -0
  76. package/out/renderer/assets/{smartart-BKb_WKE6.js → smartart-BTOCcWLh.js} +1 -1
  77. package/out/renderer/assets/{stateDiagram-DGXRK772-xdA_EMO3.js → stateDiagram-DGXRK772-nACatGwh.js} +1 -1
  78. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-LbiD2EL_.js +1 -0
  79. package/out/renderer/assets/team-bridge-page-BW45aiP2.js +21 -0
  80. package/out/renderer/assets/{timeline-definition-BDJGKUSR-DJcCw_S5.js → timeline-definition-BDJGKUSR-BXO43hMG.js} +1 -1
  81. package/out/renderer/assets/use-default-on-banner-DjHLTfeK.js +1 -0
  82. package/out/renderer/assets/use-download-agent-mutation-D6QgUMMQ.js +56 -0
  83. package/out/renderer/assets/{use-session-snapshot-1Qr287OF.js → use-session-snapshot-CI2ND9fV.js} +1 -1
  84. package/out/renderer/assets/{xychartDiagram-VJFVF3MP-AN9BWRc1.js → xychartDiagram-VJFVF3MP-CA90n1Qk.js} +1 -1
  85. package/out/renderer/browser-approvals-overlay.html +2 -2
  86. package/out/renderer/console-capture.html +6 -6
  87. package/out/renderer/index.html +8 -8
  88. package/out/renderer/installer.html +5 -5
  89. package/out/renderer/mini.html +8 -8
  90. package/package.json +2 -2
  91. package/out/renderer/assets/agent-details-page-DuT7ksQQ.js +0 -6
  92. package/out/renderer/assets/agent-hub-page-Ql4T_UHE.js +0 -6
  93. package/out/renderer/assets/agents-page-b9zRicwX.js +0 -7
  94. package/out/renderer/assets/browser-page-B3tf6s7R.js +0 -1
  95. package/out/renderer/assets/channel-DL0ftT8O.js +0 -1
  96. package/out/renderer/assets/classDiagram-GIVACNV2-jy6TeuKv.js +0 -1
  97. package/out/renderer/assets/classDiagram-v2-COTLJTTW-jy6TeuKv.js +0 -1
  98. package/out/renderer/assets/clone-CxDM6XKV.js +0 -1
  99. package/out/renderer/assets/format-esAOn2VS.js +0 -1
  100. package/out/renderer/assets/index-CJBIsxq7.css +0 -1
  101. package/out/renderer/assets/infoDiagram-PH2N3AL5-BSH7k17A.js +0 -2
  102. package/out/renderer/assets/legacy-agents-page-oa1T18xF.js +0 -33
  103. package/out/renderer/assets/mesh-page-DUvJxJjk.js +0 -1
  104. package/out/renderer/assets/org-access-M6CGnpV0.js +0 -1
  105. package/out/renderer/assets/org-surface-gate-BwyP7jwt.js +0 -1
  106. package/out/renderer/assets/parseISO-BHJWTxrA.js +0 -1
  107. package/out/renderer/assets/path-utils-Dy8qomEz.js +0 -58
  108. package/out/renderer/assets/publication-validation-DaTmgJDa.js +0 -1
  109. package/out/renderer/assets/settings-page-CfM3A9yR.js +0 -287
  110. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-eb84WKtw.js +0 -1
  111. package/out/renderer/assets/team-bridge-page-Bq0clyqS.js +0 -21
  112. package/out/renderer/assets/use-download-agent-mutation-BsUnGrAQ.js +0 -56
@@ -1,33 +0,0 @@
1
- import{r as l,j as e,c as $}from"./index-B4nU7SY-.js";import{P as Nt}from"./page-header-CSOT2M6K.js";import{c as oe,u as P,q as Ze,r as et,B as T,s as tt,w as F,y as st,S as at,l as W,I as nt,x as Ct,a0 as je,L as ce,z as it,X as ot,a1 as St,a2 as It,a3 as Dt,A as ye,m as Se,n as le,F as Pt,G as Lt,H as Tt,J as Et,K as Ie,C as Ot,a4 as qt,i as zt,j as Ut}from"./error-boundary-Bq37z0Vv.js";import{b5 as Rt,b6 as rt,b7 as Te,b8 as Ee,b9 as $t,ba as Ge,bb as Mt,bc as Ht,aL as lt,bd as ae,be as ie,bf as Bt,bg as Wt,bh as Kt,bi as Vt,bj as De,bk as Qt,a_ as Gt,bl as Yt,y as qe,bm as ct,aK as Ft,az as At,x as Jt,aB as Xt,aI as Zt,bn as ut,bo as es,bp as dt,aO as ts,bq as ss,br as Ye}from"./index-C1xioNnx.js";import{bn as mt,as,be as ns,bo as is,a3 as ze,a4 as X,aq as ht,ar as os,bp as rs,T as ue,b3 as ls,av as ne,aw as _e,S as pt,bc as cs,bq as us,au as ds,bh as Oe,bj as ms,b7 as hs,P as ps,ap as gt,aA as gs}from"./conversation-input-sync-BNDyyAZz.js";import{h as xt,u as bt,Y as xs,a0 as bs,a4 as fs,a5 as ys,A as Ue,a as _s,c as js,O as ks,g as vs,x as ws,q as ft}from"./path-utils-Dy8qomEz.js";import{t as s}from"./messages-Bsgf6o-p.js";import{N as Ns}from"./notebook-pen-BYY7185A.js";import{n as Pe,u as Cs,b as Ss,H as Is,p as Ds}from"./org-access-M6CGnpV0.js";import{o as Ps,a as Ls}from"./org-surface-gate-BwyP7jwt.js";import{R as Fe}from"./radient-auth-buttons-OK28kSbr.js";import{c as Ts,i as Es,d as Os,e as qs,t as zs,p as Ae,P as Je}from"./publication-validation-DaTmgJDa.js";import"./console-mirror-BiNs1Fcs.js";/**
2
- * @license lucide-react v0.507.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const Us=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],Rs=oe("ellipsis-vertical",Us);/**
7
- * @license lucide-react v0.507.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const $s=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 15h10",key:"jfw4w8"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]],Xe=oe("file-input",$s);/**
12
- * @license lucide-react v0.507.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const Ms=[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 7V4a2 2 0 0 1 2-2 2 2 0 0 0-2 2",key:"1vk7w2"}],["path",{d:"M4.063 20.999a2 2 0 0 0 2 1L18 22a2 2 0 0 0 2-2V7l-5-5H6",key:"1jink5"}],["path",{d:"m5 11-3 3",key:"1dgrs4"}],["path",{d:"m5 17-3-3h10",key:"1mvvaf"}]],Hs=oe("file-output",Ms);/**
17
- * @license lucide-react v0.507.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const Bs=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],Ws=oe("git-branch",Bs);/**
22
- * @license lucide-react v0.507.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const Ks=[["path",{d:"M16 10h2",key:"8sgtl7"}],["path",{d:"M16 14h2",key:"epxaof"}],["path",{d:"M6.17 15a3 3 0 0 1 5.66 0",key:"n6f512"}],["circle",{cx:"9",cy:"11",r:"2",key:"yxgjnd"}],["rect",{x:"2",y:"5",width:"20",height:"14",rx:"2",key:"qneu4z"}]],Vs=oe("id-card",Ks);/**
27
- * @license lucide-react v0.507.0 - ISC
28
- *
29
- * This source code is licensed under the ISC license.
30
- * See the LICENSE file in the root directory of this source tree.
31
- */const Qs=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m8 11 4 4 4-4",key:"1dohi6"}],["path",{d:"M8 5H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-4",key:"1ywtjm"}]],Gs=oe("import",Qs),Ys=({agentId:t,agentName:n,onAgentDeleted:a,buttonSx:o={},isAgentsPage:i=!1,onViewAgentSettings:c,onChatWithAgent:u,onExportAgent:x,onClearConversation:f,onUploadAgentToHub:j})=>{P();const[b,k]=l.useState(!1),[r,d]=l.useState(!1),[m,y]=l.useState(!1),v=l.useRef(!1),S=Rt(),{clearAgentFromAllPages:C}=mt(),q=async()=>{try{await S.mutateAsync(t),C(t),a?.(t)}catch(N){console.error("Failed to delete agent:",N)}finally{d(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs(Ze,{open:b,onOpenChange:k,modal:!1,children:[e.jsx(et,{asChild:!0,children:e.jsx(T,{variant:"ghost",size:"icon-sm","aria-label":s("ui.agents.dialogs.menu.accessible"),"data-tour-tag":"agent-options-button",onClick:N=>{N.stopPropagation(),N.detail===0&&k(E=>!E)},style:o,children:e.jsx(Rs,{"aria-hidden":"true"})})}),e.jsxs(tt,{align:"end",className:"min-w-45",onClick:N=>N.stopPropagation(),onInteractOutside:N=>{const E=N.detail.originalEvent.target;E instanceof Element&&E.closest(".shepherd-element")&&N.preventDefault()},onCloseAutoFocus:N=>{v.current&&(v.current=!1,N.preventDefault())},children:[i&&u&&e.jsxs(F,{onSelect:u,children:[e.jsx(rt,{"aria-hidden":"true"}),e.jsx("span",{children:s("ui.agents.dialogs.menu.chat")})]}),!i&&c&&e.jsxs(F,{"data-tour-tag":"view-agent-settings-menu-item",onSelect:c,children:[e.jsx(Te,{"aria-hidden":"true"}),e.jsx("span",{children:s("ui.agents.dialogs.menu.settings")})]}),x&&e.jsxs(F,{onSelect:x,children:[e.jsx(Hs,{"aria-hidden":"true"}),e.jsx("span",{children:s("ui.agents.dialogs.menu.export")})]}),j&&e.jsxs(F,{"data-tour-tag":"upload-to-hub-menu-item",onSelect:j,children:[e.jsx(Ee,{"aria-hidden":"true"}),e.jsx("span",{children:s("ui.agents.dialogs.menu.upload")})]}),f&&e.jsxs(F,{className:"text-warning data-[highlighted]:bg-warning-wash",onSelect:()=>{v.current=!0,y(!0)},children:[e.jsx($t,{"aria-hidden":"true"}),e.jsx("span",{children:s("ui.agents.dialogs.menu.clear")})]}),e.jsxs(F,{destructive:!0,onSelect:()=>{v.current=!0,d(!0)},children:[e.jsx(as,{"aria-hidden":"true"}),e.jsx("span",{children:s("ui.agents.dialogs.menu.delete")})]})]})]}),e.jsx(Ge,{open:r,title:s("ui.agents.dialogs.delete.title"),message:e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-body text-ink",children:s("ui.agents.dialogs.delete.question",{name:n})}),e.jsx("p",{className:"mt-2 text-body-sm text-ink-muted",children:s("ui.agents.dialogs.delete.warning")})]}),confirmText:s("ui.agents.dialogs.delete.confirm"),cancelText:s("ui.agents.dialogs.delete.cancel"),isDangerous:!0,onConfirm:q,onCancel:()=>d(!1)}),e.jsx(Ge,{open:m,title:s("ui.agents.dialogs.clear.title"),message:s("ui.agents.dialogs.clear.warning"),confirmText:s("ui.agents.dialogs.clear.confirm"),cancelText:s("ui.agents.dialogs.clear.cancel"),isDangerous:!0,onConfirm:()=>{f?.(),y(!1)},onCancel:()=>y(!1)})]})},Fs=({page:t,count:n,onChange:a})=>{P();const o=()=>{t>1&&a(t-1)},i=()=>{t<n&&a(t+1)};return n<=1?null:e.jsxs("div",{className:"sticky bottom-0 left-0 right-0 z-10 flex min-h-13 items-center justify-between border-t border-hairline bg-surface px-4 py-2",children:[e.jsx(T,{variant:"ghost",size:"icon-sm",onClick:o,disabled:t<=1,"aria-label":s("ui.common.forms.compact_pagination.previous_page"),children:e.jsx(ns,{})}),e.jsx("span",{className:"select-none text-meta text-ink-dim",children:s("ui.common.forms.pagination.position",{page:String(t),count:String(n)})}),e.jsx(T,{variant:"ghost",size:"icon-sm",onClick:i,disabled:t>=n,"aria-label":s("ui.common.forms.compact_pagination.next_page"),children:e.jsx(st,{})})]})},yt=t=>["agent-system-prompt",t],_t=t=>{const{shouldEnableQuery:n}=is();return xt({enabled:n({bypassInternetCheck:!0})&&!!t,queryKey:yt(t),queryFn:async()=>{try{const o=await ze(X.baseUrl).agents.getAgentSystemPrompt(t);if(o.status>=400)throw new Error(o.message||s("ui.common.errors.agent_prompt_fetch"));return o.result?.system_prompt||""}catch(a){const o=a instanceof Error?a.message:s("ui.common.errors.agent_prompt_fetch_unknown");throw ue(o),a}},refetchOnWindowFocus:!1,staleTime:5e3})},As=t=>{const n=bt(),a=ze(X.baseUrl);return ht({mutationFn:async o=>{const i=rs(o);if(i)throw ue(i),new Error(i);try{const c=await a.agents.updateAgentSystemPrompt(t,o);if(c.status>=400)throw new Error(c.message||s("ui.common.errors.agent_prompt_update_simple"));return c}catch(c){const u=c instanceof Error?c.message:s("ui.common.errors.agent_prompt_update_unknown");throw ue(u),c}},onSuccess:async()=>{await n.invalidateQueries({queryKey:yt(t)}),os(s("ui.common.actions.agent_system_prompt_updated"))},onError:o=>{console.error("Error updating agent system prompt:",o)}})},Js=()=>{const[t,n]=ls(),a=xs(),o=()=>{const c=t.get("page");return c?Number.parseInt(c,10):1},i=c=>{const u=new URLSearchParams(t);c===1?u.delete("page"):u.set("page",c.toString()),n(u)};return{page:o(),setPage:i,isView:c=>a.pathname.startsWith(`/${c}`)}},Xs=({open:t,onClose:n,onAgentImported:a})=>{P();const[o,i]=l.useState(null),[c,u]=l.useState(!1),[x,f]=l.useState(null),j=l.useRef(null),b=Mt(),k=l.useCallback(p=>{p.preventDefault(),p.stopPropagation(),u(!0)},[]),r=l.useCallback(p=>{p.preventDefault(),p.stopPropagation(),u(!1)},[]),d=l.useCallback(p=>{p.preventDefault(),p.stopPropagation()},[]),m=l.useCallback(p=>p.name.toLowerCase().endsWith(".zip")?(f(null),!0):(f("ui.agents.dialogs.import.invalid_zip"),!1),[]),y=l.useCallback(p=>{if(p.preventDefault(),p.stopPropagation(),u(!1),p.dataTransfer.files&&p.dataTransfer.files.length>0){const I=p.dataTransfer.files[0];m(I)&&i(I)}},[m]),v=l.useCallback(p=>{if(p.target.files&&p.target.files.length>0){const I=p.target.files[0];m(I)&&i(I)}},[m]),S=l.useCallback(()=>{j.current?.click()},[]),C=async()=>{if(o)try{const p=await b.mutateAsync(o);i(null),f(null),a&&p&&a(p.id),n()}catch(p){console.error("Failed to import agent:",p)}},q=()=>{i(null),f(null),n()},N=b.isPending,E=N||!o,L=e.jsxs(e.Fragment,{children:[e.jsx(Xe,{size:19,className:"text-accent","aria-hidden":"true"}),s("ui.agents.dialogs.import.title")]}),_=e.jsxs(e.Fragment,{children:[e.jsx(ne,{onClick:q,disabled:N,children:s("ui.agents.dialogs.import.cancel")}),e.jsx(_e,{onClick:C,disabled:E,startIcon:N?e.jsx(at,{}):null,children:s("ui.agents.dialogs.import.submit")})]});return e.jsxs(pt,{open:t,onClose:q,title:L,actions:_,maxWidth:"sm",children:[e.jsx("p",{className:"mb-4 text-body-sm text-ink-muted",children:s("ui.agents.dialogs.import.intro")}),e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsx("input",{ref:j,type:"file",accept:".zip",onChange:v,disabled:N,className:"hidden"}),e.jsx("button",{type:"button",onClick:S,onDragEnter:k,onDragLeave:r,onDragOver:d,onDrop:y,disabled:N,className:$("cursor-pointer rounded-lg border-2 border-control border-dashed bg-surface p-4 text-center","transition-colors duration-base ease-out-quart","hover:bg-accent-wash","disabled:border-hairline disabled:bg-sunken disabled:text-ink-disabled",c&&"border-accent bg-accent-wash"),children:o?e.jsxs(e.Fragment,{children:[e.jsx(Xe,{size:32,className:"mx-auto mb-2 text-ink-muted","aria-hidden":"true"}),e.jsx("p",{className:"text-body text-ink",children:o.name}),e.jsx("p",{className:"text-body-sm text-ink-muted",children:s("ui.agents.dialogs.import.replace_file")})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ht,{size:32,className:"mx-auto mb-2 text-ink-muted","aria-hidden":"true"}),e.jsx("p",{className:"text-body text-ink",children:s("ui.agents.dialogs.import.drop_file")}),e.jsx("p",{className:"text-body-sm text-ink-muted",children:s("ui.agents.dialogs.import.choose_file")})]})}),x&&e.jsx("p",{role:"alert",className:"text-body-sm text-danger",children:s(x)})]})]})},Zs=({title:t,searchQuery:n,onSearchChange:a,onNewAgentClick:o,searchPlaceholder:i=s("ui.common.layout.sidebar_header.search_agents"),newAgentTooltip:c=s("ui.common.layout.sidebar_header.create_a_new_agent"),onImportAgentClick:u,importAgentTooltip:x=s("ui.common.layout.sidebar_header.import_an_agent_from_a_zip_file")})=>(P(),e.jsxs("div",{className:"p-4",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between gap-2",children:[e.jsx("h2",{className:"truncate text-heading text-ink",children:t}),e.jsxs("div",{className:"flex shrink-0 gap-1",children:[u&&e.jsx(W,{content:x,children:e.jsx(T,{variant:"ghost",size:"icon",onClick:u,"aria-label":s("ui.common.layout.sidebar_header.import_agent"),children:e.jsx(Gs,{"aria-hidden":"true"})})}),e.jsx(W,{content:c,children:e.jsx(T,{variant:"primary",size:"icon",onClick:o,"aria-label":s("ui.common.layout.sidebar_header.new_agent"),"data-tour-tag":"create-new-agent-button",children:e.jsx(lt,{"aria-hidden":"true"})})})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(cs,{size:16,"aria-hidden":"true",className:"pointer-events-none absolute top-1/2 start-3 -translate-y-1/2 text-ink-dim"}),e.jsx(nt,{type:"search",inputSize:"lg",placeholder:i,value:n,onChange:f=>a(f.target.value),"aria-label":i,className:"ps-9"})]})]})),w={temperature:.2,top_p:.9,top_k:40,max_tokens:4096,frequency_penalty:0,presence_penalty:0,seed:42},Y=({label:t,description:n,defaultLabel:a,onSet:o})=>(P(),e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-body-sm text-ink",children:t}),e.jsx("span",{className:"text-meta text-ink-dim",children:s("ui.agents.settings.chat.not_set_yet")})]}),e.jsx("p",{className:"mt-1 text-meta text-ink-dim",children:n})]}),e.jsx(T,{variant:"secondary",size:"sm",className:"shrink-0",onClick:o,children:s("ui.agents.settings.chat.set_to_default",{value:String(a)})})]})),Le=({title:t,children:n})=>e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("h3",{className:"text-body-sm font-semibold text-ink-muted",children:t}),n]}),ea=({selectedAgent:t,savingField:n,setSavingField:a,updateAgentMutation:o,refetchAgent:i,initialSelectedAgentId:c})=>{P();const[u,x]=l.useState(t);l.useEffect(()=>{x(t)},[t]);const[f,j]=l.useState(!1),b=l.useId(),k=f?Ct:st;return e.jsxs("div",{children:[e.jsxs("h2",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>j(!f),"aria-expanded":f,"aria-controls":b,className:"group flex items-center gap-2 py-1 text-start text-heading text-ink",children:[e.jsx(k,{size:14,"aria-hidden":"true",className:"shrink-0 text-ink-dim transition-colors duration-fast ease-out-quart group-hover:text-ink rtl:-scale-x-100"}),s("ui.agents.settings.chat.advanced_chat_settings")]}),e.jsx(W,{content:s("ui.agents.settings.chat.advanced_settings_to_change_how_the_agent"),children:e.jsx(T,{variant:"ghost",size:"icon-sm","aria-label":s("ui.agents.settings.chat.about_advanced_chat_settings"),children:e.jsx(je,{})})})]}),f&&e.jsxs("div",{id:b,className:"mt-3",children:[e.jsx("p",{className:"max-w-2xl text-body-sm text-ink-muted",children:s("ui.agents.settings.chat.set_custom_values_for_any_of_these")}),e.jsxs("div",{className:"mt-6 flex flex-col gap-8",children:[e.jsxs(Le,{title:s("ui.agents.settings.chat.sampling"),children:[u.temperature===null?e.jsx(Y,{label:s("ui.agents.settings.chat.temperature"),description:s("ui.agents.settings.chat.controls_randomness_in_responses_0_0_1"),defaultLabel:w.temperature,onSet:async()=>{a("temperature");try{const r={temperature:w.temperature};await o.mutateAsync({agentId:t.id,update:r}),x(d=>({...d,temperature:w.temperature})),t.id===c&&i&&await i()}catch{}finally{a(null)}}}):e.jsx(ae,{value:u.temperature??w.temperature,label:s("ui.agents.settings.chat.temperature"),description:s("ui.agents.settings.chat.controls_randomness_in_responses_0_0_1"),min:0,max:1,step:.01,isSaving:n==="temperature",onChange:async r=>{a("temperature");try{const d={temperature:r};await o.mutateAsync({agentId:t.id,update:d}),t.id===c&&i&&await i()}catch{}finally{a(null)}}}),u.top_p===null?e.jsx(Y,{label:s("ui.agents.settings.chat.top_p"),description:s("ui.agents.settings.chat.controls_cumulative_probability_of_tokens_to_sample"),defaultLabel:w.top_p,onSet:async()=>{a("top_p");try{const r={top_p:w.top_p};await o.mutateAsync({agentId:t.id,update:r}),x(d=>({...d,top_p:w.top_p})),t.id===c&&i&&await i()}catch{}finally{a(null)}}}):e.jsx(ae,{value:u.top_p??w.top_p,label:s("ui.agents.settings.chat.top_p"),description:s("ui.agents.settings.chat.controls_cumulative_probability_of_tokens_to_sample"),min:0,max:1,step:.01,isSaving:n==="top_p",onChange:async r=>{a("top_p");try{const d={top_p:r};await o.mutateAsync({agentId:t.id,update:d}),t.id===c&&i&&await i()}catch{}finally{a(null)}}}),u.top_k===null?e.jsx(Y,{label:s("ui.agents.settings.chat.top_k"),description:s("ui.agents.settings.chat.limits_tokens_to_sample_from_at_each"),defaultLabel:w.top_k,onSet:async()=>{a("top_k");try{const r={top_k:w.top_k};await o.mutateAsync({agentId:t.id,update:r}),x(d=>({...d,top_k:w.top_k})),t.id===c&&i&&await i()}catch{}finally{a(null)}}}):e.jsx(ae,{value:u.top_k??w.top_k,label:s("ui.agents.settings.chat.top_k"),description:s("ui.agents.settings.chat.limits_tokens_to_sample_from_at_each"),min:1,max:100,step:1,isSaving:n==="top_k",onChange:async r=>{a("top_k");try{const d={top_k:r};await o.mutateAsync({agentId:t.id,update:d}),t.id===c&&i&&await i()}catch{}finally{a(null)}}}),u.seed===null?e.jsx(Y,{label:s("ui.agents.settings.chat.seed"),description:s("ui.agents.settings.chat.random_number_seed_for_deterministic_generation"),defaultLabel:w.seed,onSet:async()=>{a("seed");try{const r={seed:w.seed};await o.mutateAsync({agentId:t.id,update:r}),x(d=>({...d,seed:w.seed})),t.id===c&&i&&await i()}catch{}finally{a(null)}}}):e.jsx(ie,{value:u.seed?.toString()||"",label:s("ui.agents.settings.chat.seed"),placeholder:s("ui.agents.settings.chat.random_number_seed_for_deterministic_generation_detail"),icon:e.jsx(Te,{size:16}),isSaving:n==="seed",onSave:async r=>{a("seed");try{const d=r.trim()?Number.parseInt(r,10):void 0;if(r.trim()&&Number.isNaN(d)){ue(s("ui.agents.settings.chat.error.invalid_seed"));return}const m={seed:d};await o.mutateAsync({agentId:t.id,update:m}),t.id===c&&i&&await i()}catch{}finally{a(null)}}})]}),e.jsxs(Le,{title:s("ui.agents.settings.chat.repetition"),children:[u.frequency_penalty===null?e.jsx(Y,{label:s("ui.agents.settings.chat.frequency_penalty"),description:s("ui.agents.settings.chat.reduces_repetition_by_lowering_likelihood_of_repeated"),defaultLabel:w.frequency_penalty,onSet:async()=>{a("frequency_penalty");try{const r={frequency_penalty:w.frequency_penalty};await o.mutateAsync({agentId:t.id,update:r}),x(d=>({...d,frequency_penalty:w.frequency_penalty})),t.id===c&&i&&await i()}catch{}finally{a(null)}}}):e.jsx(ae,{value:u.frequency_penalty??w.frequency_penalty,label:s("ui.agents.settings.chat.frequency_penalty"),description:s("ui.agents.settings.chat.reduces_repetition_by_lowering_likelihood_of_repeated"),min:-2,max:2,step:.01,isSaving:n==="frequency_penalty",onChange:async r=>{a("frequency_penalty");try{const d={frequency_penalty:r};await o.mutateAsync({agentId:t.id,update:d}),t.id===c&&i&&await i()}catch{}finally{a(null)}}}),u.presence_penalty===null?e.jsx(Y,{label:s("ui.agents.settings.chat.presence_penalty"),description:s("ui.agents.settings.chat.increases_diversity_by_lowering_likelihood_of_prompt"),defaultLabel:w.presence_penalty,onSet:async()=>{a("presence_penalty");try{const r={presence_penalty:w.presence_penalty};await o.mutateAsync({agentId:t.id,update:r}),x(d=>({...d,presence_penalty:w.presence_penalty})),t.id===c&&i&&await i()}catch{}finally{a(null)}}}):e.jsx(ae,{value:u.presence_penalty??w.presence_penalty,label:s("ui.agents.settings.chat.presence_penalty"),description:s("ui.agents.settings.chat.increases_diversity_by_lowering_likelihood_of_prompt"),min:-2,max:2,step:.01,isSaving:n==="presence_penalty",onChange:async r=>{a("presence_penalty");try{const d={presence_penalty:r};await o.mutateAsync({agentId:t.id,update:d}),t.id===c&&i&&await i()}catch{}finally{a(null)}}})]}),e.jsxs(Le,{title:s("ui.agents.settings.chat.length_and_stopping"),children:[u.max_tokens===null?e.jsx(Y,{label:s("ui.agents.settings.chat.max_tokens"),description:s("ui.agents.settings.chat.maximum_tokens_to_generate_in_response"),defaultLabel:w.max_tokens,onSet:async()=>{a("max_tokens");try{const r={max_tokens:w.max_tokens};await o.mutateAsync({agentId:t.id,update:r}),x(d=>({...d,max_tokens:w.max_tokens})),t.id===c&&i&&await i()}catch{}finally{a(null)}}}):e.jsx(ae,{value:u.max_tokens??w.max_tokens,label:s("ui.agents.settings.chat.max_tokens"),description:s("ui.agents.settings.chat.maximum_tokens_to_generate_in_response"),min:1,max:8192,step:1,isSaving:n==="max_tokens",onChange:async r=>{a("max_tokens");try{const d={max_tokens:r};await o.mutateAsync({agentId:t.id,update:d}),t.id===c&&i&&await i()}catch{}finally{a(null)}}}),u.stop===null?e.jsx(Y,{label:s("ui.agents.settings.chat.stop_sequences"),description:s("ui.agents.settings.chat.sequences_that_will_cause_the_model_to"),defaultLabel:s("ui.agents.settings.chat.empty"),onSet:async()=>{a("stop");try{const r={stop:[]};await o.mutateAsync({agentId:t.id,update:r}),x(d=>({...d,stop:[]})),t.id===c&&i&&await i()}catch{}finally{a(null)}}}):e.jsx(ie,{value:u.stop?.join(`
32
- `)||"",label:s("ui.agents.settings.chat.stop_sequences"),placeholder:s("ui.agents.settings.chat.enter_stop_sequences_one_per_line"),icon:e.jsx(Te,{size:16}),multiline:!0,rows:3,isSaving:n==="stop",onSave:async r=>{a("stop");try{const d=r.split(`
33
- `).map(y=>y.trim()).filter(y=>y.length>0),m={stop:d.length>0?d:void 0};await o.mutateAsync({agentId:t.id,update:m}),t.id===c&&i&&await i()}catch{}finally{a(null)}}})]})]})]})]})},ta=["investment","accounting","healthcare","legal","software","security","role_play","personal_assistance","education","marketing","sales","research","analysis","management","social_media","other"],be=t=>s("ui.common.forms.categories_input_chips.category",{category:t==="other"?"other_category":t}),sa=({value:t,label:n,onChange:a,placeholder:o=s("ui.common.forms.categories_input_chips.add_category"),disabled:i=!1,icon:c})=>{const u=P(),[x,f]=l.useState(""),[j,b]=l.useState(!1),[k,r]=l.useState(0),d=l.useRef(null),m=l.useRef([]),y=l.useId(),v=l.useId(),S=l.useMemo(()=>{const _=x.trim().toLowerCase();return ta.filter(p=>!t.includes(p)&&(!_||be(p).toLowerCase().includes(_)))},[t,x,u]);l.useEffect(()=>{j&&m.current[k]?.scrollIntoView({block:"nearest"})},[k,j]);const C=_=>{t.includes(_)||a([...t,_]),f(""),b(!1),r(0),d.current?.focus()},q=_=>{f(_.target.value),r(0),b(!0)},N=_=>{const p=S.length;switch(_.key){case"ArrowDown":if(_.preventDefault(),p===0)break;j?r((k+1)%p):(r(0),b(!0));break;case"ArrowUp":if(_.preventDefault(),p===0)break;j?r((k-1+p)%p):(r(p-1),b(!0));break;case"Enter":j&&S[k]&&(_.preventDefault(),C(S[k]));break;case"Escape":j&&(_.preventDefault(),b(!1));break;case"Home":j&&(_.preventDefault(),r(0));break;case"End":j&&(_.preventDefault(),r(S.length-1));break}},E=_=>{a(t.filter(p=>p!==_)),r(0)},L=j&&S[k]?`${v}-option-${k}`:void 0;return e.jsxs("div",{children:[e.jsxs(ce,{htmlFor:y,className:"mb-1.5 flex items-center gap-2 text-ink-muted",children:[c,n]}),e.jsxs("div",{className:$("flex min-h-11 flex-wrap items-center gap-2 rounded-sm border border-control bg-surface p-2","has-[input:focus-visible]:outline-solid has-[input:focus-visible]:outline-2","has-[input:focus-visible]:outline-accent has-[input:focus-visible]:outline-offset-2",i&&"border-hairline bg-sunken"),children:[t.map(_=>e.jsxs(it,{className:"gap-1 pe-1 text-ink",children:[be(_),e.jsx("button",{type:"button","aria-label":s("ui.common.forms.categories_input_chips.remove_category",{value:be(_)}),disabled:i,onClick:()=>E(_),className:$("rounded-xs text-ink-dim","transition-colors duration-fast ease-out-quart","hover:text-danger disabled:text-ink-disabled"),children:e.jsx(ot,{})})]},_)),e.jsxs(St,{open:j,onOpenChange:b,children:[e.jsx(It,{asChild:!0,children:e.jsx("input",{id:y,ref:d,type:"text",role:"combobox","aria-expanded":j,"aria-controls":v,"aria-autocomplete":"list","aria-activedescendant":L,autoComplete:"off",value:x,placeholder:o,disabled:i,"aria-label":n,onChange:q,onKeyDown:N,onClick:()=>{S.length>0&&b(!0)},className:$("min-w-20 flex-1 bg-transparent px-1 py-0.5 outline-none","text-body-sm text-ink placeholder:text-ink-dim","disabled:text-ink-disabled disabled:placeholder:text-ink-disabled")})}),e.jsx(Dt,{align:"start",sideOffset:4,onOpenAutoFocus:_=>_.preventDefault(),className:"max-h-60 w-(--radix-popover-trigger-width) overflow-y-auto p-1",children:e.jsx("div",{id:v,role:"listbox","aria-label":n,children:S.map((_,p)=>e.jsx("div",{id:`${v}-option-${p}`,ref:I=>{m.current[p]=I},role:"option","aria-selected":p===k,onMouseDown:I=>{I.preventDefault()},onMouseEnter:()=>r(p),onClick:()=>C(_),className:$("cursor-pointer rounded-sm px-3 py-1.5 font-medium text-body-sm",p===k?"bg-accent-wash":void 0,"text-ink"),children:be(_)},_))})})]})]}),t.length===0&&e.jsx("span",{className:"mt-1 ms-1 block text-ink-dim text-meta",children:s("ui.common.forms.categories_input_chips.no_categories_selected")})]})},aa=({value:t,label:n,onChange:a,placeholder:o=s("ui.common.forms.tags_input_chips.add_tag"),disabled:i=!1,icon:c})=>{P();const[u,x]=l.useState(""),f=l.useRef(null),j=l.useId(),b=m=>{x(m.target.value)},k=()=>{const m=u.trim().toLowerCase();m&&!t.includes(m)&&a([...t,m]),x("")},r=m=>{m.key==="Enter"&&u.trim()?(m.preventDefault(),k()):m.key==="Backspace"&&!u&&t.length>0&&a(t.slice(0,-1))},d=m=>{a(t.filter(y=>y!==m))};return e.jsxs("div",{children:[e.jsxs(ce,{htmlFor:j,className:"mb-1.5 flex items-center gap-2 text-ink-muted",children:[c,n]}),e.jsxs("div",{className:$("flex min-h-11 flex-wrap items-center gap-2 rounded-sm border border-control bg-surface p-2","has-[input:focus-visible]:outline-solid has-[input:focus-visible]:outline-2","has-[input:focus-visible]:outline-accent has-[input:focus-visible]:outline-offset-2",i&&"border-hairline bg-sunken"),children:[t.map(m=>e.jsxs(it,{className:"gap-1 pe-1 text-ink",children:[m,e.jsx("button",{type:"button","aria-label":s("ui.common.forms.tags_input_chips.remove_tag",{tag:m}),disabled:i,onClick:()=>d(m),className:$("rounded-xs text-ink-dim","transition-colors duration-fast ease-out-quart","hover:text-danger disabled:text-ink-disabled"),children:e.jsx(ot,{})})]},m)),e.jsx("input",{id:j,ref:f,type:"text",value:u,onChange:b,onKeyDown:r,placeholder:o,disabled:i,"aria-label":n,className:$("min-w-20 flex-1 bg-transparent px-1 py-0.5 outline-none","text-body-sm text-ink placeholder:text-ink-dim","disabled:text-ink-disabled disabled:placeholder:text-ink-disabled")}),u.trim()&&e.jsx(T,{variant:"ghost",size:"icon-sm","aria-label":s("ui.common.forms.tags_input_chips.add_tage0db29"),disabled:i,onClick:()=>{k(),f.current?.focus()},className:"text-accent hover:text-accent",children:e.jsx(lt,{})})]}),t.length===0&&!u&&e.jsx("span",{className:"mt-1 ms-1 block text-ink-dim text-meta",children:s("ui.common.forms.tags_input_chips.no_tags_added")})]})},na=({selectedAgent:t,savingField:n,setSavingField:a,updateAgentMutation:o,refetchAgent:i,initialSelectedAgentId:c})=>{P();const{data:u,isLoading:x}=us(),[f,j]=l.useState("");l.useEffect(()=>{!x&&u?.values?j(t.hosting||u.values.hosting||""):x||j(t.hosting||"")},[t,u,x]);const[b,k]=l.useState(!1),[r,d]=l.useState(!1);return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(ie,{value:t.name,label:s("ui.agents.settings.general.agent_name"),placeholder:s("ui.agents.settings.general.enter_agent_name"),isSaving:n==="name",onSave:async m=>{if(!m.trim()){ue(s("ui.agents.settings.general.error.empty_name"));return}a("name");try{const y={name:m};await o.mutateAsync({agentId:t.id,update:y}),t.id===c&&i&&await i()}catch{}finally{a(null)}}}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx("div",{"data-tour-tag":"agent-settings-hosting-select",children:e.jsx(Bt,{value:t.hosting||(u?.values.hosting??""),isSaving:n==="hosting",onSave:async m=>{a("hosting"),j(m);try{const y={hosting:m,model:""};await o.mutateAsync({agentId:t.id,update:y}),t.id===c&&i&&await i()}catch{j(t.hosting||"")}finally{a(null)}},filterByCredentials:!0,allowDefault:!0},`hosting-select-${t.id}-${t.hosting||(u?.values.hosting??"default")}`)}),e.jsx("div",{"data-tour-tag":"agent-settings-model-select",children:f?e.jsx(Wt,{value:t.hosting?t.model||"":t.model||(u?.values.model_name??""),hostingId:f,isSaving:n==="model",allowDefault:!0,onSave:async m=>{a("model");try{const y={model:m};await o.mutateAsync({agentId:t.id,update:y}),t.id===c&&i&&await i()}catch{}finally{a(null)}}},`model-select-${t.id}-${f}-${t.model||(!t.hosting&&u?.values.model_name?u.values.model_name:"default")}`):e.jsxs("div",{className:"relative",children:[e.jsx(W,{content:s("ui.agents.settings.general.select_a_hosting_provider_first_and_then"),children:e.jsxs("div",{className:"mb-1.5 flex w-fit items-center gap-2 text-body-sm text-ink-muted",children:[e.jsx(Kt,{size:16,"aria-hidden":"true"}),s("ui.agents.settings.general.model")]})}),e.jsx("div",{className:"flex h-8 w-full items-center rounded-sm border border-control bg-surface px-3",children:e.jsx("span",{className:"truncate text-body-sm text-ink-disabled",children:s("ui.agents.settings.general.select_a_hosting_provider_first")})})]})})]}),e.jsxs("h2",{className:"mt-4 flex items-center gap-2 text-heading text-ink",children:[e.jsx(je,{size:16,className:"shrink-0 text-ink-dim"}),s("ui.agents.settings.general.agent_information")]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(ie,{value:t.description||"",label:s("ui.agents.settings.general.description"),placeholder:s("ui.agents.settings.general.enter_agent_description"),multiline:!0,rows:3,isSaving:n==="description",onSave:async m=>{a("description");try{const y={description:m};await o.mutateAsync({agentId:t.id,update:y}),t.id===c&&i&&await i()}catch{}finally{a(null)}}}),e.jsx(aa,{value:t.tags||[],label:s("ui.agents.settings.general.tags"),placeholder:s("ui.agents.settings.general.add_tag"),disabled:b,onChange:async m=>{if(!(Array.isArray(t.tags)&&m.length===t.tags.length&&m.every((y,v)=>y===t.tags?.[v]))){k(!0);try{const y={tags:m};await o.mutateAsync({agentId:t.id,update:y}),t.id===c&&i&&await i()}catch{}finally{k(!1)}}}}),e.jsx(sa,{value:t.categories||[],label:s("ui.agents.settings.general.categories"),placeholder:s("ui.agents.settings.general.add_category"),disabled:r,onChange:async m=>{if(!(Array.isArray(t.categories)&&m.length===t.categories.length&&m.every((y,v)=>y===t.categories?.[v]))){d(!0);try{const y={categories:m};await o.mutateAsync({agentId:t.id,update:y}),t.id===c&&i&&await i()}catch{}finally{d(!1)}}}}),e.jsxs(Vt,{children:[e.jsx(De,{label:e.jsxs(e.Fragment,{children:[e.jsx(Vs,{size:12,"aria-hidden":"true"}),s("ui.agents.settings.general.id")]}),value:e.jsx("span",{className:"font-mono text-mono-sm",children:t.id})}),e.jsx(De,{label:e.jsxs(e.Fragment,{children:[e.jsx(Qt,{size:12,"aria-hidden":"true"}),s("ui.agents.settings.general.created")]}),value:ds(t.created_date)}),e.jsx(De,{label:e.jsxs(e.Fragment,{children:[e.jsx(Ws,{size:12,"aria-hidden":"true"}),s("ui.agents.settings.general.version")]}),value:t.version})]})]})]})},ia=({selectedAgent:t,savingField:n,setSavingField:a,updateAgentMutation:o,refetchAgent:i,initialSelectedAgentId:c})=>(P(),e.jsxs("div",{"data-tour-tag":"agent-settings-security",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-heading text-ink",children:[e.jsx(Gt,{size:16,className:"shrink-0 text-ink-dim"}),s("ui.agents.settings.security.security_instructions"),e.jsx(W,{content:s("ui.agents.settings.security.security_instructions_that_guide_the_agent_s"),children:e.jsx(T,{variant:"ghost",size:"icon-sm","aria-label":s("ui.agents.settings.security.about_security_instructions"),children:e.jsx(je,{})})})]}),e.jsx("p",{className:"mt-1 max-w-2xl text-body-sm text-ink-muted",children:s("ui.agents.settings.security.this_prompt_is_directed_to_the_ai")}),e.jsx("div",{className:"mt-4",children:e.jsx(ie,{value:t.security_prompt||"",label:"",placeholder:s("ui.agents.settings.security.enter_instructions_for_the_security_agent"),multiline:!0,rows:6,isSaving:n==="security_prompt",onSave:async u=>{a("security_prompt");try{const x={security_prompt:u};await o.mutateAsync({agentId:t.id,update:x}),t.id===c&&i&&await i()}catch{}finally{a(null)}}})})]})),oa=({selectedAgent:t,savingField:n,setSavingField:a,refetchAgent:o,initialSelectedAgentId:i})=>{P();const{data:c,isLoading:u}=_t(t.id),x=As(t.id),[f,j]=l.useState("");return l.useEffect(()=>{c!==void 0&&j(c)},[c]),e.jsxs("div",{"data-tour-tag":"agent-settings-system-prompt",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-heading text-ink",children:[e.jsx(Ns,{size:16,className:"shrink-0 text-ink-dim"}),s("ui.agents.settings.system_prompt.agent_instructions"),e.jsx(W,{content:s("ui.agents.settings.system_prompt.system_instructions_that_define_the_agent_s"),children:e.jsx(T,{variant:"ghost",size:"icon-sm","aria-label":s("ui.agents.settings.system_prompt.about_agent_instructions"),children:e.jsx(je,{})})})]}),e.jsx("p",{className:"mt-1 max-w-2xl text-body-sm text-ink-muted",children:s("ui.agents.settings.system_prompt.define_the_agent_s_role_personality_or")}),e.jsx("div",{className:"mt-4",children:e.jsx(ie,{value:f,label:"",placeholder:u?s("ui.agents.settings.system_prompt.loading_system_prompt"):s("ui.agents.settings.system_prompt.enter_instructions_for_the_agent"),multiline:!0,rows:6,isSaving:n==="system_prompt",onSave:async b=>{a("system_prompt");try{await x.mutateAsync(b),t.id===i&&o&&await o()}finally{a(null)}}})})]})},ra=({selectedAgent:t,refetchAgent:n,initialSelectedAgentId:a})=>{P();const[o,i]=l.useState(null),c=Yt();return e.jsx("div",{"data-tour-tag":"agent-settings-details-paper",className:"h-full overflow-hidden",children:t?e.jsx("div",{className:"h-full overflow-y-auto",children:e.jsxs("div",{className:"mx-auto flex w-full max-w-4xl flex-col gap-8 pb-8",children:[e.jsx(na,{selectedAgent:t,savingField:o,setSavingField:i,updateAgentMutation:c,refetchAgent:n,initialSelectedAgentId:a}),e.jsx(oa,{selectedAgent:t,savingField:o,setSavingField:i,refetchAgent:n,initialSelectedAgentId:a}),e.jsx(ia,{selectedAgent:t,savingField:o,setSavingField:i,updateAgentMutation:c,refetchAgent:n,initialSelectedAgentId:a}),e.jsx(ea,{selectedAgent:t,savingField:o,setSavingField:i,updateAgentMutation:c,refetchAgent:n,initialSelectedAgentId:a})]})}):e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 p-8 text-center",children:[e.jsx(qe,{size:48,className:"text-ink-dim","aria-hidden":"true"}),e.jsx("h2",{className:"text-heading text-ink",children:s("ui.agents.settings.agent.no_agent_selected")}),e.jsx("p",{className:"max-w-md text-body-sm text-ink-muted",children:s("ui.agents.settings.agent.select_an_agent_from_the_list_on")})]})})},Re=bs()(fs(t=>({listings:{},remember:(n,a)=>{t(o=>({listings:{...o.listings,[n]:a}}))},forget:n=>{t(a=>{if(!(n in a.listings))return a;const o={...a.listings};return delete o[n],{listings:o}})}}),{name:"published-listings-storage"})),la=t=>Re(n=>t?n.listings[t]??null:null),ca=400,ua=2,da=t=>[...t].length>=ua;function ma(t){if(!t)return{state:"unknown",builtinName:null};if(t.available)return{state:"available",builtinName:null};const n=t.details?.builtin_name??null;return t.code==="name_taken"?{state:"taken",builtinName:null}:t.code==="name_reserved_builtin"?{state:"reserved",builtinName:n}:{state:"unknown",builtinName:null}}const ha=(t,n)=>{const a=t.trim(),o=ct(a,ca),i=n&&o===a&&da(o)&&ys(o),c=xt({queryKey:["agent-name-availability",o],enabled:i,queryFn:async()=>(await Oe.getAgentNameAvailability(X.baseUrl,o)).result,retry:!1,staleTime:15e3,refetchOnWindowFocus:!1});return!i||c.isPending?{state:i?"checking":"idle",builtinName:null}:c.isError?{state:"unknown",builtinName:null}:ma(c.data)},pa=()=>{const t=bt();return ht({mutationFn:async({agentId:n,document:a,hubAgentId:o,target:i,policy:c})=>{if(!X.baseUrl)throw new Error("Local Operator API URL is not configured.");return o?Oe.republishAgentInstructionSet(X.baseUrl,n,o,a,i,c):Oe.publishAgentInstructionSet(X.baseUrl,n,a,i,c)},onSuccess:(n,a)=>{const o=n.result;o?.agent_id&&!a.target&&Re.getState().remember(a.agentId,{hubAgentId:o.agent_id,name:o.name,publishedAt:new Date().toISOString()}),o?.local_link_receipt&&t.invalidateQueries({queryKey:Ft}),a.target?Ts(t,a.target.tenantId):Es(t)},onError:n=>{console.error("Publishing an agent to the hub failed:",n)}})},fe="public",jt=({open:t,onClose:n,agent:a,isAuthenticated:o,onSignInSuccess:i,onPublished:c})=>{const[u,x]=l.useState(!1),[f,j]=l.useState(""),[b,k]=l.useState(null),[r,d]=l.useState(null),[m,y]=l.useState(!1),v=l.useRef(null),S=l.useRef(null),C=Ue(),q=pa();P();const[N,E]=l.useState(Pe),L=l.useRef(null),_=l.useRef({open:!1,id:null}),p=la(a?.id??null),I=_s(),z=js(I.data,"hub_links"),K=At(t&&z),ke=ms(),de=ks(I.data,"radient_org"),ve=Ls(de),me=o?Ps(de,ke??null):null,{memberships:A,isError:we}=Jt({enabled:t&&o&&ve}),Z=l.useMemo(()=>Cs(A),[A]),J=l.useMemo(()=>Ss(A),[A]),[M,he]=l.useState(fe),g=M!==fe,O=(K.data?.links??[]).filter(h=>h.kind==="agent"&&h.local_id===a?.id),D=O.find(h=>h.visibility===(g?"org":"public")&&h.tenant_id===(g?M:null)),H=O.find(h=>h.link_id!==D?.link_id),Q=K.data?.unresolved.some(h=>h.kind==="agent"&&h.local_id===a?.id),B=Z.find(h=>h.tenant_id===M),pe=g?B?.tenant_name?s("ui.hub.links.source_private",{organization:B.tenant_name}):s("ui.hub.links.source_unavailable"):s("ui.hub.links.source_public"),re=Z.find(h=>h.tenant_id===M)?.tenant_name||"this organization",ge=l.useId(),xe=l.useId(),{data:$e}=_t(t&&a?a.id:""),{data:Me}=hs(t);l.useEffect(()=>{t&&(!_.current.open||_.current.id!==(a?.id??null))&&j(a?.name??""),_.current={open:t,id:a?.id??null}},[t,a?.id,a?.name]),l.useEffect(()=>{t||(x(!1),k(null),d(null),y(!1),he(fe),E(Pe()),L.current=null)},[t]);const kt=l.useMemo(()=>(Me??[]).filter(h=>h.source==="builtin").map(h=>h.name),[Me]),He=Os(f,kt),Be=ha(f,t&&o),ee=l.useMemo(()=>{const h=qs({name:f,description:a?.description??"",instructions:$e??null,tools:zs(a?.tags)});return He&&h.unshift({field:"name",message:Ae({code:"name_reserved_builtin",message:""},{name:f,hubAgentId:null}).body}),h},[f,a?.description,a?.tags,$e,He]),U=b?Ae(b,{name:f,hubAgentId:p?.hubAgentId??null}):null,te=q.isPending,Ne=async h=>{if(!a||te||ee.length>0||g&&!B)return;k(null);const R=h?.asNewListing?null:D?.hub_id??(g?null:p?.hubAgentId??null),Ke=!!R;if(!(z&&(!K.isSuccess||H||Q)))try{const G={name:f.trim()},Ve=JSON.stringify({agent:a.id,document:G,hubAgentId:R,target:M,policy:D?null:N}),Ce=L.current?.tuple===Ve?L.current:{tuple:Ve,id:crypto.randomUUID()};L.current=Ce;const se=(await q.mutateAsync({agentId:a.id,document:G,hubAgentId:R,...z?{policy:D?{requestId:Ce.id,...D.remote_revision&&Ke?{expectedRemoteRevision:D.remote_revision}:{}}:{requestId:Ce.id,...N}}:{},target:g?{visibility:"org",tenantId:M}:void 0})).result,Qe={name:se?.name??f.trim(),hubAgentId:se?.agent_id??null,republished:Ke,orgName:g?re:null,localPolicies:se?.local_link_receipt?Ds(se)?"complete":"pending":z?"pending":null};d(Qe),se&&c?.(se,Qe.republished)}catch(G){k(ps(G)?{code:G.code,message:G.message,details:G.details}:{message:vs(G,"The agent could not be published. Try again.")})}},We=h=>{switch(h){case"focus-name":k(null),requestAnimationFrame(()=>{v.current?.focus(),v.current?.select()});break;case"update-listing":{const R=b?.details?.existing_agent_id??p?.hubAgentId;R&&(n(),C(`/agent-hub/${R}`));break}case"install-builtin":{const R=b?.details?.builtin_name??Be.builtinName;R&&(n(),C(`/agents?kind=agent&name=${encodeURIComponent(R)}`));break}case"edit-instructions":case"edit-agent":a&&(n(),C(`/agents/${a.id}`));break;case"publish-as-new":a&&Re.getState().forget(a.id),Ne({asNewListing:!0});break;case"sign-in":y(!0);break;case"refresh-hub":n(),C("/agent-hub");break;case"retry":Ne();break}},V=a?.name??"",vt=r?r.orgName?`Published "${V}" to ${r.orgName}`:r.republished?`Updated the Agent Hub listing for "${V}"`:`Published "${V}" to the Agent Hub`:g?`Publish "${V}" to ${re}?`:p?`Update the Agent Hub listing for "${V}"?`:`Publish "${V}" to the Agent Hub?`;l.useLayoutEffect(()=>{!b&&!r||S.current?.focus()},[b,r]);const wt=r?e.jsxs(e.Fragment,{children:[e.jsx(ne,{onClick:n,"data-tour-tag":"upload-agent-dialog-cancel-button",children:"Close"}),r.hubAgentId&&e.jsx(_e,{onClick:()=>{n(),C(`/agent-hub/${r.hubAgentId}`)},children:"Open the listing"})]}):U?e.jsxs(e.Fragment,{children:[e.jsx(ne,{onClick:n,"data-tour-tag":"upload-agent-dialog-cancel-button",children:"Close"}),U.actions.map((h,R)=>R===0?e.jsx(_e,{onClick:()=>We(h),disabled:te,children:Je[h]},h):e.jsx(ne,{onClick:()=>We(h),disabled:te,children:Je[h]},h))]}):e.jsxs(e.Fragment,{children:[e.jsx(ne,{onClick:n,"data-tour-tag":"upload-agent-dialog-cancel-button",children:"Cancel"}),ee.some(h=>h.field!=="name")&&e.jsx(ne,{onClick:()=>{a&&(n(),C(`/agents/${a.id}`))},children:"Edit the agent"}),o&&e.jsx(_e,{"data-testid":"publish-submit",onClick:()=>void Ne(),disabled:g&&!B||!u||ee.length>0||!f.trim()||te||z&&(!K.isSuccess||!!H||!!Q),children:te?"Publishing…":p&&!g?"Update listing":"Publish"})]});return e.jsx(pt,{open:t,onClose:n,title:vt,maxWidth:"sm",fullWidth:!0,actions:wt,dataTourTag:"upload-agent-dialog",dialogProps:{className:"outline-none"},children:e.jsxs("div",{ref:S,tabIndex:b||r?-1:void 0,className:$("flex flex-col gap-4",(b||r)&&"outline-none"),children:[o?r?e.jsxs(ye,{variant:"success","aria-live":"polite",children:[e.jsx(Se,{children:r.orgName?`Published to ${r.orgName}`:r.republished?"Listing updated":"Published to the hub"}),e.jsx(le,{children:r.orgName?`"${r.name}" is in ${r.orgName}'s shared agents as an instruction set. Its members can read and install it; nobody outside the organization can.`:r.republished?`The hub now holds the current instruction set of "${r.name}".`:`"${r.name}" is on the hub as an instruction set. Anyone can read and install it.`}),e.jsx(le,{className:"text-ink-muted",children:"Nothing else left this machine: no conversation, no execution history, no memory, no plan and no machine-specific configuration."})]}):U&&b?e.jsxs(ye,{variant:U.variant,role:"alert",children:[e.jsx(Se,{children:U.headline}),e.jsx(le,{children:U.body}),U.note&&e.jsx(le,{className:"text-ink-muted",children:U.note})]}):null:e.jsxs("div",{className:"flex flex-col items-center gap-6 text-center",children:[e.jsx("p",{className:"text-body text-ink",children:"You need to be signed in to Radient to publish agents to the Agent hub."}),e.jsx(Fe,{titleText:"Sign in to continue",descriptionText:"",onSignInSuccess:i})]}),U&&m&&e.jsxs("div",{className:"flex flex-col items-center gap-6 text-center",children:[e.jsx("p",{className:"text-body text-ink",children:"Sign in to Radient again to replace the credential the hub refused."}),e.jsx(Fe,{titleText:"Sign in again",descriptionText:"",onSignInSuccess:()=>{y(!1),k(null),i?.()}})]}),r?.localPolicies==="pending"&&e.jsx("p",{role:"alert",className:"text-body-sm text-warning",children:s("ui.hub.skills.policy_pending")}),!r&&z&&e.jsx("div",{className:"flex flex-col gap-3",children:K.isLoading?e.jsx("p",{className:"text-meta text-ink-muted",children:s("ui.hub.links.loading")}):K.error?e.jsx("p",{role:"alert",className:"text-body-sm text-warning",children:s("ui.hub.links.load_failed")}):H?e.jsx("p",{className:"text-body-sm text-warning",children:s("ui.hub.subscriptions.source_separation",{currentSource:Xt(H),newSource:pe})}):Q?e.jsx("p",{className:"text-body-sm text-warning",children:s("ui.hub.links.source_unavailable")}):D?e.jsx(Zt,{link:D}):e.jsx(Is,{value:N,onChange:E,source:pe,item:f||V,visibility:g?"org":"public",organization:g?re:null,destinationKey:`${M}:${a?.id??""}`,canEnableAutoPush:!1,disabled:te||!K.isSuccess})}),!r&&!U&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-body text-ink",children:g?`You are about to publish this agent's instruction set into ${re}, where only its members can read and install it. What is published is what describes the agent:`:"You are about to publish this agent's instruction set to the public Agent Hub. What is published is what describes the agent:"}),e.jsxs("ul",{className:"list-disc space-y-1 ps-5 text-body text-ink-muted",children:[e.jsx("li",{children:"Its name and description"}),e.jsx("li",{children:"Its instructions"}),e.jsx("li",{children:"Its tool surface, effort and delegation, when it has them"})]}),e.jsx("p",{className:"text-body text-ink",children:g?`Nothing else leaves this machine: no conversation, no execution history, no memory or learnings, no plan, and no machine-specific configuration. ${re}'s members can read and install what you publish; nobody outside it can.`:"Nothing else leaves this machine: no conversation, no execution history, no memory or learnings, no plan, and no machine-specific configuration. Anyone can read and install what you publish."}),Z.length>0||J.length>0?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(ce,{htmlFor:`${ge}-target`,children:"Publish to"}),e.jsxs(Pt,{value:M,onValueChange:h=>{he(h),E(Pe()),L.current=null},children:[e.jsx(Lt,{id:`${ge}-target`,className:"w-full","data-testid":"publish-target",children:e.jsx(Tt,{})}),e.jsxs(Et,{children:[e.jsx(Ie,{value:fe,children:"Public hub"}),Z.map(h=>e.jsx(Ie,{value:h.tenant_id,children:h.tenant_name||"Organization"},h.tenant_id)),J.map(h=>e.jsxs(Ie,{value:h.tenant_id,disabled:!0,children:[h.tenant_name||"Organization"," (upgrade needed)"]},h.tenant_id))]})]}),e.jsx("p",{className:"text-meta text-ink-muted","data-testid":"publish-target-hint",children:J.length>0?`Sharing agents inside an organization is part of the Team plan. An owner of ${J.length===1?J[0].tenant_name||"this organization":"any of the organizations marked above"} can activate it in the Radient console.`:"Public hub publications are readable by anyone. An organization's agents are readable by its members only."})]}):me?e.jsx("p",{className:"text-meta text-ink-muted","data-testid":"publish-target-unavailable",children:me}):we?e.jsx("p",{className:"text-meta text-ink-muted","data-testid":"publish-target-failed",children:"Your organizations could not be read, so this publishes to the public hub. Try again in a moment to publish into an organization."}):null,ee.length>0&&e.jsxs(ye,{variant:"danger",children:[e.jsx(Se,{children:"This agent cannot be published yet"}),e.jsx("ul",{className:"list-disc space-y-1 ps-5",children:ee.map(h=>e.jsx("li",{children:h.message},`${h.field}:${h.message}`))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(ce,{htmlFor:xe,children:"Name on the hub"}),e.jsx(nt,{id:xe,ref:v,value:f,onChange:h=>j(h.target.value),autoComplete:"off",spellCheck:!1,"aria-invalid":ee.some(h=>h.field==="name"),"aria-describedby":`${xe}-hint`}),e.jsx("p",{id:`${xe}-hint`,className:"text-meta text-ink-muted",children:'No "/", "\\" or ":". Up to 128 characters.'}),!g&&ga(Be)]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("span",{className:"flex h-5 shrink-0 items-center",children:e.jsx(Ot,{id:ge,name:"termsAgreement","data-testid":"publish-consent",checked:u,onCheckedChange:h=>x(h===!0)})}),e.jsxs(ce,{htmlFor:ge,className:"block font-normal text-body text-ink",children:["I confirm that I have read and agree to the"," ",e.jsx("a",{href:"https://radienthq.com/terms",target:"_blank",rel:"noopener noreferrer",className:"text-accent underline-offset-4 hover:text-accent-hover hover:underline",children:"terms and conditions"})," ","and that this agent does not contain malicious content or violate usage policies."]})]})]}),(r||U)&&V&&e.jsxs("p",{className:"text-meta text-ink-muted",children:["Agent: ",V]})]})})},ga=t=>{switch(t.state){case"checking":return e.jsx("p",{className:"text-meta text-ink-muted",children:"Checking whether this name is free…"});case"available":return e.jsx("p",{className:"text-meta text-ink-muted",children:"This name looks free."});case"taken":return e.jsx("p",{className:"text-meta text-ink",children:"This name is already published on the hub."});case"reserved":return e.jsx("p",{className:"text-meta text-ink-muted",children:t.builtinName?`The hub reserves "${t.builtinName}" for one of its built-in agents.`:"The hub reserves this name for one of its built-in agents."});default:return null}},xa=1200,ba=({agent:t,isSelected:n,onSelectAgent:a,onChatWithAgent:o,onExportAgent:i,onAgentDeleted:c,onUploadAgentToHub:u})=>{P();const x=t.description||s("ui.agents.navigation.sidebar.no_description");return e.jsxs("li",{className:"group relative",children:[e.jsxs("button",{type:"button",onClick:()=>a(t),"aria-current":n?"true":void 0,"data-tour-tag":"agent-list-item-button",className:$("flex w-full items-center gap-2 rounded-sm py-1.5 pe-9 ps-2 text-start","transition-colors duration-fast ease-out-quart",n?ts:"hover:bg-row-hover"),children:[e.jsx(zt,{className:"size-8 shrink-0",children:e.jsx(Ut,{className:"border border-control bg-sunken",children:e.jsx(qe,{size:16,"aria-hidden":!0})})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx(W,{content:t.name,side:"top",align:"start",children:e.jsx("span",{className:"block truncate font-medium text-body-sm text-ink",children:t.name})}),e.jsx(W,{content:x,side:"bottom",align:"start",children:e.jsx("span",{className:"block truncate text-meta text-ink-dim",children:x})})]})]}),e.jsx("div",{className:$("pointer-events-none absolute top-0 end-1 flex h-full items-center","opacity-0 transition-opacity duration-fast ease-out-quart","group-hover:pointer-events-auto group-hover:opacity-100","group-focus-within:pointer-events-auto group-focus-within:opacity-100"),children:e.jsx(W,{content:s("ui.agents.navigation.sidebar.options"),children:e.jsx("span",{children:e.jsx(Ys,{agentId:t.id,agentName:t.name,isAgentsPage:!0,onAgentDeleted:()=>c(t.id),onChatWithAgent:()=>o(t),onExportAgent:()=>i(t.id),onUploadAgentToHub:()=>u(t),buttonSx:{width:24,height:24,borderRadius:"6px",display:"flex",justifyContent:"center",alignItems:"center"}})})})})]})},fa=(t,n)=>t.isSelected===n.isSelected&&t.agent.id===n.agent.id&&t.agent.name===n.agent.name&&t.agent.description===n.agent.description&&t.onSelectAgent===n.onSelectAgent&&t.onChatWithAgent===n.onChatWithAgent&&t.onExportAgent===n.onExportAgent&&t.onAgentDeleted===n.onAgentDeleted&&t.onUploadAgentToHub===n.onUploadAgentToHub,ya=l.memo(ba,fa),_a=({selectedAgentId:t,onSelectAgent:n})=>{const a=Ue();P();const[o,i]=l.useState(""),c=ws(g=>g.openCreateAgentDialog),u=ct(o.trim(),250),[x,f]=l.useState(!1),j=50,[b,k]=l.useState(!1),[r,d]=l.useState(null),{isAuthenticated:m}=gt(),y=l.useMemo(()=>ze(X.baseUrl),[]),v=ut(),{page:S,setPage:C}=Js(),{data:q,isLoading:N,isError:E,refetch:L}=es(S,j,0,u||void 0,"created_date","desc"),_=q?.agents||[],p=q?.total||0,{data:I}=dt(t&&!_.find(g=>g.id===t)?t:void 0),z=l.useMemo(()=>{const g=[..._];return I&&!g.find(O=>O.id===I.id)&&g.push(I),g.sort((O,D)=>new Date(D.created_date).getTime()-new Date(O.created_date).getTime()),g},[_,I]),K=l.useCallback(g=>{C(g)},[C]),ke=l.useCallback(g=>{n(g)},[n]),de=l.useCallback(()=>{f(!0)},[]),ve=l.useCallback(()=>{f(!1)},[]),me=l.useCallback(async g=>{try{const O=await v.mutateAsync(g),D=z.find(pe=>pe.id===g),H=D?D.name.replace(/\s+/g,"-").toLowerCase():g,Q=URL.createObjectURL(O),B=document.createElement("a");B.href=Q,B.download=`${H}-export.zip`,document.body.appendChild(B),B.click(),URL.revokeObjectURL(Q),document.body.removeChild(B)}catch(O){console.error("Failed to export agent:",O)}},[z,v]),A=l.useCallback(g=>{d(g),k(!0)},[]),we=l.useCallback(()=>{k(!1),d(null)},[]),Z=l.useCallback(async g=>{try{const D=((await L()).data?.agents||[]).find(Q=>Q.id===g);if(D){n(D);return}const H=await y.agents.getAgent(g);H.status<400&&H.result&&n(H.result)}catch(O){console.error("Error selecting newly created agent:",O)}},[n,L,y]),J=l.useCallback(g=>{ft.getState().stageDraft({kind:"agent",name:g.name}),a("/chat")},[a]),M=l.useCallback(g=>{L(),a("/agents")},[t,L,a]),he=l.useCallback(g=>{A(g)},[A]);return e.jsxs("div",{"data-glass-region":"page-sidebar",className:"panel-top-pad flex h-full w-full flex-col overflow-hidden bg-surface",children:[e.jsx(Zs,{title:s("ui.agents.navigation.sidebar.title"),searchQuery:o,onSearchChange:g=>i(g),onNewAgentClick:c,onImportAgentClick:de,importAgentTooltip:s("ui.agents.navigation.sidebar.import_hint")}),N?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx(at,{size:"lg",label:s("ui.agents.navigation.sidebar.loading")})}):E?e.jsxs(ye,{variant:"danger",role:"alert",className:"m-4 w-auto",children:[e.jsx(le,{children:s("ui.agents.navigation.sidebar.error")}),e.jsx(T,{variant:"ghost",size:"sm",className:"self-start",onClick:()=>L(),children:s("ui.agents.navigation.sidebar.retry")})]}):z.length===0&&!N?e.jsx("p",{className:"p-6 text-center text-body-sm text-ink-muted",children:o?s("ui.agents.navigation.sidebar.search_empty"):s("ui.agents.navigation.sidebar.empty")}):e.jsx(qt,{delayDuration:xa,skipDelayDuration:0,children:e.jsx("ul",{className:"flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto p-2",children:z.map(g=>e.jsx(ya,{agent:g,isSelected:t===g.id||I?.id===g.id,onSelectAgent:ke,onChatWithAgent:J,onExportAgent:me,onAgentDeleted:M,onUploadAgentToHub:he},g.id))})}),e.jsx(Xs,{open:x,onClose:ve,onAgentImported:Z}),p>0&&e.jsx(Fs,{page:S,count:Math.max(1,Math.ceil(p/j)),onChange:K}),e.jsx(jt,{open:b,onClose:we,agent:r,isAuthenticated:m})]})},ja=l.memo(_a),za=()=>{P();const{agentId:t,navigateToAgent:n}=ss(),a=Ue(),{isAuthenticated:o}=gt(),[i,c]=l.useState(!1),u=ut(),{setLastAgentsPageAgentId:x,getLastAgentId:f}=mt(),j=t||f("agents"),{data:b,refetch:k}=dt(j||void 0);l.useEffect(()=>{t&&x(t)},[t,x]);const r=async()=>{if(b)try{const v=await u.mutateAsync(b.id),S=URL.createObjectURL(v),C=document.createElement("a");C.href=S,C.download=`${b.name.replace(/\s+/g,"-").toLowerCase()}-lo-agent.zip`,document.body.appendChild(C),C.click(),URL.revokeObjectURL(S),document.body.removeChild(C)}catch(v){console.error("Failed to export agent:",v)}},d=()=>{c(!0)},m=()=>{c(!1)},y=v=>{x(v.id),n(v.id,"agents")};return e.jsxs("div",{"data-glass-split":"",className:"panel-flush flex min-h-0 flex-1 overflow-hidden",children:[e.jsx("div",{className:"h-full w-70 shrink-0",children:e.jsx(ja,{selectedAgentId:b?.id,onSelectAgent:y})}),e.jsx("div",{"data-glass-region":"canvas-content",className:"panel-top-pad h-full grow overflow-hidden",children:e.jsxs("div",{className:"flex h-full flex-col gap-8 p-4 sm:p-6 lg:p-8",children:[e.jsx("div",{className:"mx-auto w-full max-w-4xl",children:e.jsx(Nt,{title:s("ui.agents.navigation.legacy.title"),icon:qe,subtitle:s("ui.agents.navigation.legacy.subtitle"),children:b&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Ze,{children:[e.jsx(et,{asChild:!0,children:e.jsx(T,{"data-tour-tag":"upload-to-hub-header-button",variant:"secondary",size:"icon","aria-label":s("ui.agents.navigation.legacy.more_actions"),className:"@min-[400px]:hidden",children:e.jsx(gs,{"aria-hidden":"true"})})}),e.jsxs(tt,{align:"end",className:"min-w-45",children:[e.jsxs(F,{disabled:u.isPending,onSelect:r,children:[e.jsx(Ye,{"aria-hidden":"true"}),e.jsx("span",{children:s("ui.agents.navigation.legacy.export")})]}),e.jsxs(F,{onSelect:d,children:[e.jsx(Ee,{"aria-hidden":"true"}),e.jsx("span",{children:s("ui.agents.navigation.legacy.upload")})]})]})]}),e.jsxs(T,{variant:"secondary",onClick:r,disabled:u.isPending,className:"hidden @min-[400px]:inline-flex",children:[e.jsx(Ye,{"aria-hidden":"true"}),s("ui.agents.navigation.legacy.export")]}),e.jsxs(T,{"data-tour-tag":"upload-to-hub-header-button","data-tour-action":"open-upload-dialog",variant:"secondary",onClick:d,className:"hidden @min-[400px]:inline-flex",children:[e.jsx(Ee,{"aria-hidden":"true"}),s("ui.agents.navigation.legacy.upload")]}),e.jsx(W,{content:s("ui.agents.navigation.legacy.chat_named",{name:b.name||s("ui.agents.navigation.legacy.unnamed_agent")}),children:e.jsxs(T,{variant:"primary",onClick:()=>{ft.getState().stageDraft({kind:"agent",name:b.name}),a("/chat")},children:[e.jsx(rt,{"aria-hidden":"true"}),s("ui.agents.navigation.legacy.chat")]})})]})})}),e.jsx("div",{className:"min-h-0 grow overflow-hidden",children:e.jsx(ra,{selectedAgent:b??null,refetchAgent:k,initialSelectedAgentId:t})})]})}),b&&e.jsx(jt,{open:i,onClose:m,agent:b,isAuthenticated:o})]})};export{za as LegacyAgentsPage};
@@ -1 +0,0 @@
1
- import{r as x,j as s,c as L}from"./index-B4nU7SY-.js";import{C as Ge,E as os,F as ds,G as se,H as cs,R as ms,I as xe,J as Ue,K as Q,L as Ke,M as Ve,N as Xe,a as us,O as ke,q as we,Q as hs}from"./path-utils-Dy8qomEz.js";import{P as ps}from"./page-header-CSOT2M6K.js";import{u as W,B as V,A as ge,l as xs,p as fs,h as de,q as gs,r as vs,s as bs,t as _s,v as Ae,w as Pe,k as Le}from"./error-boundary-Bq37z0Vv.js";import{t as a}from"./messages-Bsgf6o-p.js";import{C as pe,D as ks,E as ws,F as js,G as ys,I as Ns,J as Is,K as Cs,L as Ms,M as Ss,N as Ds,O as Es,Q as Rs,R as As,T as Ie,U as Ps,V as Ls,W as Ce,X as Ze,Y as Je,Z as Ts,_ as fe,$ as je,a0 as $s,a1 as Os,a2 as ve,a3 as Te,a4 as zs,a5 as Hs,a6 as ye,a7 as Ws,a8 as Qe,a9 as be,aa as Fs,ab as es,ac as qs,ad as Bs,ae as Ys,af as Gs,ag as Us,ah as Ks,ai as Vs,aj as Xs,ak as Zs,al as Js,am as Qs,an as et,ao as st,ap as tt,aq as nt,ar as at,as as it,at as rt,au as lt,av as he,aw as ot}from"./index-C1xioNnx.js";import{ax as Me,ay as Se,az as dt,aA as ss}from"./conversation-input-sync-BNDyyAZz.js";import"./console-mirror-BiNs1Fcs.js";function ct(e){return e==="failed"?"text-danger":pe(e)?"text-ink-muted":"text-ink-dim"}function mt(e){return e==="failed"?a("ui.mesh.mesh_approvals_tray.abandon"):a("ui.mesh.mesh_approvals_tray.stop")}function ut(e){switch(e){case"requested":return[{term:a("ui.mesh.mesh_approvals_tray.signing"),text:a("ui.mesh.mesh_approvals_tray.approving_signs_with_this_machine_s_operator")}];case"approved":return[{term:a("ui.mesh.mesh_approvals_tray.next"),text:a("ui.mesh.mesh_approvals_tray.an_agent_runs_the_install_and_connect")},{term:a("ui.mesh.mesh_approvals_tray.stop"),text:a("ui.mesh.mesh_approvals_tray.stopping_now_denies_the_request_nothing_has")}];case"connecting":return[{term:a("ui.mesh.mesh_approvals_tray.stop"),text:a("ui.mesh.mesh_approvals_tray.stopping_now_denies_the_request_the_runner")}];case"failed":return[{term:a("ui.mesh.mesh_approvals_tray.after_a_stop"),text:a("ui.mesh.mesh_approvals_tray.the_runner_stopped_before_it_finished_abandoning")}];default:return[]}}const ht=({rows:e,error:n,pending:t,refusal:d,onDecide:m,onRetry:h,nowSeconds:f,networkNames:l})=>{W();const b=t!==null,v=x.useMemo(()=>e.filter(o=>pe(o.state)),[e]),w=x.useMemo(()=>e.filter(o=>!pe(o.state)),[e]),[E,C]=x.useState(!1),c=x.useRef(null),u=x.useRef(null),p=x.useRef(null),j=(o,I)=>{I==="deny"&&v.some(R=>R.approvalId===o&&R.kind==="credential")&&(p.current={id:o,origin:document.activeElement,sawPending:!1}),m(o,I)};x.useLayoutEffect(()=>{const o=p.current;if(!o)return;if(t?.approvalId===o.id&&(o.sawPending=!0),d?.approvalId===o.id){p.current=null;return}const I=e.find(M=>M.approvalId===o.id);if(I?.state==="requested"){!t&&o.sawPending&&(p.current=null);return}if(I?.state==="denied"&&t||(p.current=null,I?.state!=="denied"||document.activeElement!==document.body&&document.activeElement!==o.origin))return;(v.length?c.current?.querySelector('[data-tour-tag="mesh-approval-controls"] button:not(:disabled)'):u.current?.querySelector("button"))?.focus({preventScroll:!0})},[e,t,d,v.length]);const N=w.some(o=>o.state==="failed"),D=w.filter(o=>o.state==="failed").length,y=d!==null&&e.some(o=>o.approvalId===d.approvalId&&(pe(o.state)||E));return v.length===0&&w.length===0&&!n&&!d?null:s.jsxs("section",{ref:c,"aria-label":a("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(ks,{"aria-hidden":"true",className:"size-4 text-ink-muted"}),s.jsx("h2",{className:"text-body-sm text-ink",children:a("ui.mesh.mesh_approvals_tray.approvals")}),v.length>0&&s.jsx("span",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_approvals_tray.waiting_count",{count:v.length})})]}),n&&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:n}),s.jsx(V,{variant:"secondary",size:"sm",onClick:h,children:a("ui.mesh.mesh_approvals_tray.ask_again")})]}),v.length>0&&s.jsx("ul",{className:"flex flex-col divide-y divide-hairline",children:v.map(o=>s.jsx($e,{row:o,pending:t?.approvalId===o.approvalId?t:null,busy:b,refusal:d?.approvalId===o.approvalId?d:null,onDecide:j,nowSeconds:f,networkNames:l},o.approvalId))}),d&&!y&&s.jsx(ts,{refusal:d}),w.length>0&&s.jsx("div",{ref:u,children:s.jsx(Me,{open:E,onOpenChange:C,chevronClassName:"text-ink-dim",className:L(v.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:[a("ui.mesh.mesh_approvals_tray.settled_approvals"),s.jsxs("span",{className:"text-ink-dim",children:["(",w.length,")"]}),N&&s.jsx("span",{"aria-hidden":"true",className:"size-1.5 rounded-full bg-danger"}),D>0&&s.jsx("span",{className:"text-danger",children:a("ui.mesh.mesh_approvals_tray.failed_count",{count:D})})]}),children:s.jsx("ul",{className:"flex flex-col divide-y divide-hairline","data-tour-tag":"mesh-approvals-records",children:w.map(o=>s.jsx($e,{row:o,pending:t?.approvalId===o.approvalId?t:null,busy:b,refusal:d?.approvalId===o.approvalId?d:null,onDecide:j,nowSeconds:f,networkNames:l},o.approvalId))})})})]})},$e=({row:e,pending:n,busy:t,refusal:d,onDecide:m,nowSeconds:h,networkNames:f})=>{W();const l=pe(e.state),b=ws(e),v=js(e,f),w=ys(e,f),E=Ns(e),C=Is(e),c=Cs(e),u=Ms(e.expiresAt,h),p=e.kind==="credential"||e.kind==="unknown",j=p||e.canApproveHere===!1,N=j?[]:ut(e.state),D=Ss(e),y=Ds(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:L("text-meta",ct(e.state)),children:e.kind==="credential"&&e.state==="approved"?a("ui.mesh.approval.approved_pending_apply"):Es(e.state)}),s.jsx("div",{className:"grow"}),l&&u&&s.jsx("span",{className:"text-meta text-ink-dim",children:e.kind==="credential"?a("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:l?v:b}),!j&&e.state==="failed"&&s.jsx("p",{className:"text-meta text-ink-muted","data-tour-tag":"mesh-approval-stopped-note",children:a("ui.mesh.mesh_approvals_tray.the_runner_stopped_before_it_finished_it")}),l&&j&&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||a("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?a("ui.mesh.approval.approved_apply_hint"):a("ui.mesh.approval.approved_details_missing")}),(D||y)&&s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[D&&s.jsx(V,{variant:"primary",size:"sm",disabled:t,onClick:()=>m(e.approvalId,"approve"),"data-tour-tag":"mesh-approval-approve",children:a("ui.mesh.mesh_approvals_tray.approve")}),y&&s.jsx(V,{variant:"ghost",size:"sm",disabled:t,onClick:()=>m(e.approvalId,"deny"),"data-tour-tag":l?"mesh-approval-deny":"mesh-approval-stop",children:l?a("ui.mesh.mesh_approvals_tray.deny"):mt(e.state)}),n&&s.jsx("span",{className:"text-meta text-ink-dim",children:n.decision==="approve"?a("ui.mesh.mesh_approvals_tray.waiting_for_the_signing_prompt"):a("ui.mesh.mesh_approvals_tray.writing_the_decision")})]}),s.jsxs(Me,{chevronClassName:"text-ink-dim",summary:s.jsx("span",{className:"text-meta",children:a("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((o,I)=>s.jsx("li",{className:"whitespace-pre-wrap",children:o},`${I}:${o}`))}):s.jsx("p",{className:"text-meta text-ink-muted",children:a("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(o=>s.jsxs(x.Fragment,{children:[s.jsx("dt",{className:"text-ink-muted",children:o.term}),s.jsx("dd",{children:o.consequence})]},o.term))}),(E||C)&&s.jsxs("p",{className:"text-meta text-ink-muted",children:[E&&s.jsx("span",{children:E}),E&&C&&s.jsx("span",{children:" · "}),C&&s.jsx("span",{className:"font-mono",children:C})]}),c&&s.jsx("p",{className:"text-meta text-ink-dim",children:c}),N.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:N.map(o=>s.jsxs(x.Fragment,{children:[s.jsx("dt",{className:"text-ink-muted",children:o.term}),s.jsx("dd",{className:"text-ink-muted",children:o.text})]},o.term))})]}),d&&s.jsx(ts,{refusal:d})]})},ts=({refusal:e})=>(W(),s.jsx(ge,{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})]})})),pt=4,_e={kind:"idle"};function xt(e){switch(e.kind){case"dragging":case"settling":return e.payload.session.id;case"pressing":return null;default:return null}}function ee(e,n){switch(n.kind){case"press":return e.kind!=="idle"?e:{kind:"pressing",payload:n.payload,originX:n.x,originY:n.y,pointerId:n.pointerId};case"move":return e.kind==="pressing"?Math.max(Math.abs(n.x-e.originX),Math.abs(n.y-e.originY))<pt?e:{kind:"dragging",payload:e.payload,x:n.x,y:n.y,target:n.target,pointerId:e.pointerId}:e.kind==="dragging"?{...e,x:n.x,y:n.y,target:n.target}:e;case"release":return e.kind==="dragging"?{kind:"settling",payload:e.payload,target:e.target}:e.kind==="pressing"?_e:e;case"cancel":case"settled":return _e;default:return e}}const ft=({edges:e,geometry:n,selectedDeviceId:t})=>s.jsx("svg",{"aria-hidden":"true",className:"pointer-events-none absolute top-0 left-0 overflow-visible",width:n.bounds.width,height:n.bounds.height,children:e.map(d=>{const m=n.networks.get(d.networkId),h=n.devices.get(d.deviceId);if(!m||!h)return null;const f=t!==null&&d.deviceId===t;return s.jsx("path",{"data-mesh-edge":d.key,d:Rs(m,h),fill:"none",strokeWidth:f?2:1.5,className:f?"stroke-ink":"stroke-ink-dim"},d.key)})}),De=({deviceId:e,name:n,compact:t=!1,deviceIds:d,className:m})=>{W();const h=Ge({name:n});return s.jsxs("span",{className:L("flex min-w-0 items-baseline gap-2",m),"data-mesh-device-identity":e,children:[s.jsx(xs,{content:n?.trim()?h:null,children:s.jsx("span",{className:"min-w-0 flex-1 truncate text-start","data-mesh-device-name":"",children:h})}),s.jsx("span",{className:"shrink-0 font-mono text-meta text-ink-muted","data-mesh-device-id":"",title:e,children:t?os(e,d):e})]})},gt={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 vt(e){return e.suspect?"border-l-danger":gt[se(e)]}const bt={self:"ring-2 ring-accent",reachable:null,relay_down:null,handshake_refused:null,unreachable:null,suspect:null},_t={accept:"border-accent bg-accent-wash",refuse:"border-warning"};function kt(e,n,t){return[Ge(e),e.id,Je(e,n),t].filter(Boolean).join(", ")}function te(e){return e.name.trim()||e.id.slice(-6)}function ns(e,n,t){if(t!=="reached"&&t!=="self"){const d=xe(t);return e.unreachable_reason?`${d} (${e.unreachable_reason})`:d}return e.live_state.trim()?e.live_state.trim():e.locality==="local"?a("ui.mesh.mesh_drop.on_this_device"):a("ui.mesh.mesh_node.on_device",{device:n})}const wt={resting:"border-l-2 border-l-hairline",attention:"border-l-2 border-l-warning"},jt=({network:e,x:n,y:t,refused:d})=>(W(),s.jsxs("li",{"data-mesh-network":e.id,"data-mesh-network-refused":d?"true":void 0,"data-glass-block":"",className:L("absolute flex items-center gap-2 rounded-md border bg-elevated px-3",d?"border-warning":"border-hairline"),style:{left:n,top:t,width:Ie,height:As},children:[s.jsx(Se,{"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:a("ui.mesh.mesh_list.epoch",{epoch:e.epoch}),className:"block truncate text-meta text-ink-dim",children:[a("ui.mesh.mesh_graph.device_count",{count:e.memberCount}),e.revokedCount>0?s.jsxs(s.Fragment,{children:[" · ",a("ui.mesh.mesh_list.revoked_count",{count:e.revokedCount})]}):null]})]})]})),yt=({device:e,deviceIds:n,x:t,y:d,nowSeconds:m,selected:h,sessions:f,sessionTotal:l,dropState:b,movingSessionId:v,draggedSessionId:w,onOpen:E,onChipPointerDown:C,onChipClick:c,onShowAllSessions:u})=>{W();const{activity:p}=ds(e,f.rows),j=p==="working",N=kt(e,m,j?"working":null),D=se(e);return s.jsxs("li",{"data-mesh-device":e.id,"data-mesh-state":e.state,"data-mesh-drop":b??void 0,"aria-current":h?"true":void 0,"data-glass-block":"",className:L("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",vt(e),bt[e.state],b&&_t[b]),style:{left:t,top:d,width:Ie,height:Ps},children:[s.jsxs("button",{type:"button","data-mesh-device-open":e.id,"data-mesh-reach":D,"aria-label":N,title:cs(e),onClick:()=>E(e.id),className:L("flex w-full flex-col justify-between rounded-t-[5px] px-3 pt-2 pb-2 text-start","cursor-pointer","focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent focus-visible:outline-offset-[-2px]"),style:{height:Ls},children:[s.jsxs("span",{className:"flex w-full min-w-0 items-center gap-2",children:[s.jsx(dt,{"aria-hidden":"true",className:"size-4 shrink-0 text-ink-muted"}),s.jsx(De,{className:"min-w-0 flex-1 text-body-sm text-ink",deviceId:e.id,deviceIds:n,name:e.name,compact:!0}),e.suspect&&s.jsx(Ce,{"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:L("min-w-0 truncate text-meta",e.sessionCount===null?"text-ink-dim":"text-ink-muted"),children:Ze(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:ms[D]}),s.jsx("span",{className:L("shrink-0",Ue[D]),children:xe(D)}),j&&s.jsx("span",{"data-mesh-working":"",className:"shrink-0 text-info",children:a("ui.mesh.mesh_node.working")}),e.memberships.length>1&&s.jsx("span",{className:"min-w-0 truncate text-ink-dim",children:a("ui.mesh.mesh_node.memberships",{count:e.memberships.length})})]})]}),s.jsxs("ul",{"aria-label":a("ui.mesh.mesh_node.conversations_on",{device:Q(e,n,!0)}),className:L("m-0 flex h-6 list-none items-center gap-1 overflow-hidden px-3",b==="accept"&&"opacity-40"),children:[f.shown.map(y=>s.jsx(Nt,{session:y,ownerLabel:Q(e,n,!0),ownerReach:D,ownerReachable:e.reachable,moving:v===y.id,dragging:w===y.id,onPointerDown:C,onClick:()=>c(y)},y.id)),f.hidden>0&&s.jsx("li",{className:"shrink-0",children:s.jsxs("button",{type:"button","data-mesh-more":e.id,onClick:()=>u(e.id),className:L("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:a("ui.mesh.mesh_node.shown_conversations",{shown:f.shown.length,total:l}),"aria-label":a("ui.mesh.mesh_node.show_all_conversations",{count:l}),children:["+",f.hidden]})})]})]})},Nt=({session:e,ownerLabel:n,ownerReach:t,ownerReachable:d,moving:m,dragging:h,onPointerDown:f,onClick:l})=>{W();const b=ns(e,n,t);return m?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:a("ui.mesh.mesh_card.moving")})}):s.jsx("li",{className:"min-w-0 flex-1","data-mesh-session-item":e.id,"data-mesh-dragging":h?"true":void 0,children:s.jsx("button",{type:"button","data-mesh-session":e.id,style:{touchAction:"none"},title:`${te(e)} · ${b}`,"aria-label":a("ui.mesh.mesh_node.open_conversation",{conversation:te(e),fact:b,owner:n}),onPointerDown:v=>f(v,e),onClick:()=>l(e),className:L("flex min-h-6 w-full max-w-32 items-center rounded-sm border border-hairline bg-surface px-1.5 text-start text-meta text-ink-muted","cursor-grab active:cursor-grabbing","hover:text-ink",wt[Ts(e,d)],h&&"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:te(e)})})})};function Oe(e){const n=e.trim();if(!n)return null;if(n.startsWith("[")){const d=n.indexOf("]");if(d<=1)return null;const m=n.slice(1,d),h=n.slice(d+1);if(!h)return{host:m,port:null};if(!h.startsWith(":"))return null;const f=Number(h.slice(1));return{host:m,port:Number.isInteger(f)?f:null}}const t=n.lastIndexOf(":");if(t>0){const d=n.slice(t+1);if(/^\d+$/.test(d))return{host:n.slice(0,t),port:Number(d)}}return{host:n,port:null}}function ze(e){const n=e.trim().split(".");if(n.length!==4)return null;for(const t of n)if(!/^\d{1,3}$/.test(t)||Number(t)>255)return null;return`${n[0]}.${n[1]}.${n[2]}`}function It(e){return`${e}.x`}function Ct(e){const n=new Map;for(const d of e.values())for(const m of d)n.set(m,(n.get(m)??0)+1);const t=new Set;for(const[d,m]of n)m>1&&t.add(d);return t}function Ne(e){return new Set(e.endpoints.map(n=>n.trim()).filter(Boolean))}function Mt(e,n){const t=e.filter(c=>c.id!==n),d=e.find(c=>c.id===n)??null,m=new Map;for(const c of e)m.set(c.id,Ne(c));const h=Ct(m),f=new Set;for(const c of d?Ne(d):[]){if(h.has(c))continue;const u=Oe(c),p=u?ze(u.host):null;p&&f.add(p)}const l=c=>{const u=new Set;for(const p of Ne(c)){if(h.has(p))continue;const j=Oe(p),N=j?ze(j.host):null;N&&u.add(N)}return u},b=new Map,v=new Map;for(const c of t){const u=St(c);if(u){b.set(u,[...b.get(u)??[],c.id]);continue}for(const p of l(c))v.set(p,[...v.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)),C=[];for(const[c,u]of b)C.push({prefix:c,tier:"declared",deviceIds:E(u),get words(){return a("ui.mesh.mesh_scope.declared")}});for(const[c,u]of v)f.has(c)?C.push({prefix:c,tier:"shared",deviceIds:E(u),get words(){return a("ui.mesh.mesh_scope.shared_with_this_device")}}):u.length>1&&C.push({prefix:c,tier:"probable",deviceIds:E(u),get words(){return a("ui.mesh.mesh_scope.same_prefix")}});return C.sort((c,u)=>c.tier.localeCompare(u.tier)||c.prefix.localeCompare(u.prefix))}function St(e){for(const n of e.memberships){const t=n.scope.trim();if(t)return t}return""}const He={declared:0,shared:1,probable:2};function Dt(e,n){const t=new Map;for(const m of e){let h=null;for(const l of m.deviceIds){const b=n.get(l);b!==void 0&&(h===null||b<h.slot)&&(h={id:l,slot:b})}if(h===null)continue;const f=t.get(h.id);f===void 0?t.set(h.id,{slot:h.slot,groups:[m]}):f.groups.push(m)}const d=m=>{let h=-1;for(const f of m.deviceIds){const l=n.get(f);l!==void 0&&l>h&&(h=l)}return h};return[...t.entries()].sort((m,h)=>m[1].slot-h[1].slot).map(([m,h])=>({deviceId:m,groups:h.groups.sort((f,l)=>d(l)-d(f)||He[f.tier]-He[l.tier]||f.prefix.localeCompare(l.prefix))}))}function Et(e){return new Map(e.map(n=>[n.deviceId,n.groups.length]))}function Rt(e){return`${e.tier==="declared"?e.prefix:It(e.prefix)} · ${e.words}`}const We=(e,n)=>e.deviceIds.map(t=>n.devices.get(t)).filter(t=>t!==void 0),At=({stacks:e,geometry:n})=>(W(),s.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute top-0 left-0",children:e.map(t=>{const d=t.groups.length,m=new Array(d).fill(0);let h=null;for(let l=d-1;l>=0;l-=1){const b=We(t.groups[l],n),v=(b.length===0?0:Math.max(...b.map(w=>w.y+w.height)))+fe;h=h===null?v:Math.max(v,h+je),m[l]=h}const f=n.devices.get(t.deviceId);return t.groups.map((l,b)=>{const v=We(l,n);if(v.length===0)return null;const w=d-1-b,E=Math.min(...v.map(N=>N.x)),C=Math.max(...v.map(N=>N.x)),u=(f?.y??Math.min(...v.map(N=>N.y)))-fe-$s*w,p=l.tier==="declared",j=Rt(l);return s.jsx("div",{"data-mesh-scope":`${l.tier}:${l.prefix}`,"data-mesh-scope-level":b,className:L("absolute rounded-lg",l.tier==="probable"?"border border-dashed border-hairline-strong":"border border-control"),style:{left:E-fe-je*w,top:u,width:C+Ie-E+(fe+je*w)*2,height:m[b]-u},children:s.jsx("span",{"data-mesh-scope-label":"",className:L("absolute bottom-full left-1 mb-0.5 whitespace-nowrap text-meta",l.tier==="probable"?"text-ink-dim":"text-ink-muted",p&&"font-medium"),children:j})},`${l.tier}:${l.prefix}`)})})})),Fe=48,qe=1.25,Pt=.0015,Lt=({graph:e,slots:n,nowSeconds:t,selectedDeviceId:d,sessions:m,sessionTotals:h,movingSessionId:f,canMove:l,onOpenDevice:b,onAskMove:v,onDropRefused:w,onShowAllSessions:E,summaryId:C})=>{W();const c=x.useRef(null),[u,p]=x.useState({width:0,height:0,clipWidth:0,clipHeight:0,left:0,top:0}),[j,N]=x.useState({k:1,tx:0,ty:0}),D=x.useRef(!1),y=x.useRef(!1),o=x.useRef(null),I=x.useMemo(()=>Mt(e.devices,e.selfDeviceId),[e.devices,e.selfDeviceId]),R=x.useMemo(()=>Dt(I,n.devices),[I,n]),M=x.useMemo(()=>Os(n,Et(R)),[n,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]),[_,$]=x.useState(_e),ce=x.useRef({kind:"ground"}),ne=x.useCallback((i,r)=>{const g=document.elementFromPoint(i,r),A=g?.closest("[data-mesh-device]");if(A){const K=A.getAttribute("data-mesh-device");if(K)return{kind:"device",deviceId:K}}const H=g?.closest("[data-mesh-network]");if(H){const K=H.getAttribute("data-mesh-network");if(K)return{kind:"network",networkId:K}}return{kind:"ground"}},[]),T=x.useMemo(()=>_.kind!=="dragging"&&_.kind!=="settling"?null:ve(_.payload,_.target,S),[_,S]),Y=x.useCallback(i=>{if(!T)return null;if(T.kind==="plan"){const r=_.kind==="dragging"||_.kind==="settling"?_.target:null;return r&&r.kind==="device"&&r.deviceId===i?"accept":null}if(T.kind==="refused"){const r=_.kind==="dragging"||_.kind==="settling"?_.target:null;return r&&r.kind==="device"&&r.deviceId===i?"refuse":null}return null},[T,_]),ae=x.useCallback((i,r)=>{if(!l||i.button!==0)return;y.current=!1;const g=r.locality==="local"?e.selfDeviceId??"":r.owner_device,A=S.devices.get(g),H={session:r,ownerDeviceId:g,ownerLabel:A?Q(A,[...S.devices.keys()],!0):r.owner_device_name};try{i.currentTarget.setPointerCapture(i.pointerId)}catch{}$(K=>ee(K,{kind:"press",payload:H,x:i.clientX,y:i.clientY,pointerId:i.pointerId}))},[l,S,e.selfDeviceId]),ie=i=>{if(_.kind==="pressing"||_.kind==="dragging"){const r=ne(i.clientX,i.clientY);ce.current=r,$(g=>ee(g,{kind:"move",x:i.clientX,y:i.clientY,target:r}));return}X(i)},me=i=>{if(ue(i),_.kind!=="pressing"&&_.kind!=="dragging")return;if(_.kind==="pressing"){$(g=>ee(g,{kind:"cancel"}));return}const r=ve(_.payload,_.target,S);y.current=!0,$(g=>ee(g,{kind:"release"})),r.kind==="plan"?v({plan:r.plan,alternatives:r.alternatives,risky:r.risky}):r.kind==="refused"&&w({code:r.code,sentence:r.sentence,reach:r.reach,remedy:r.remedy,plan:r.plan??null}),$(g=>ee(g,{kind:"settled"}))};x.useEffect(()=>()=>$(_e),[]);const re=x.useCallback(()=>{N(Te(M.bounds,u))},[M.bounds,u]);x.useEffect(()=>{const i=c.current;if(!i)return;const r=()=>{const A=i.getBoundingClientRect();p({width:A.width,height:A.height,clipWidth:i.clientWidth,clipHeight:i.clientHeight,left:A.left,top:A.top})};r();const g=new ResizeObserver(r);return g.observe(i),()=>g.disconnect()},[]),x.useEffect(()=>{D.current||u.width<=0||u.height<=0||(D.current=!0,N(Te(M.bounds,u)))},[u,M.bounds]),x.useEffect(()=>{const i=o.current;if(o.current={width:u.width,height:u.height},!i||!D.current||u.width<=0||u.height<=0||u.width>=i.width&&u.height>=i.height||!d)return;const r=M.devices.get(d);r&&N(g=>{const A={width:u.clipWidth,height:u.clipHeight},H=Math.max(0,Math.min(A.width-M.bounds.width*g.k,A.height-M.bounds.height*g.k));return zs(g,r,A,Math.min(Ws,H))})},[u,d,M]);const q=_.kind==="dragging"?{x:_.x-u.left+12,y:_.y-u.top+12}:{x:0,y:0},le=T?Hs(T):null,G=x.useRef(null),k=x.useRef(null),P=x.useRef(null),O=x.useRef(null),U=x.useCallback(()=>{P.current=null;const i=G.current,r=k.current;if(G.current=null,k.current=null,i){const g=O.current;if(!g)return;N({k:g.transform.k,tx:g.transform.tx+(i.x-g.x),ty:g.transform.ty+(i.y-g.y)});return}r&&N(g=>ye(g,{x:r.x,y:r.y},g.k*Math.exp(-r.deltaY*Pt)))},[]),z=x.useCallback(()=>{P.current===null&&(P.current=requestAnimationFrame(U))},[U]);x.useEffect(()=>()=>{P.current!==null&&cancelAnimationFrame(P.current)},[]);const Z=i=>{!(i.target===i.currentTarget)&&i.button!==1||i.button!==0&&i.button!==1||(O.current={x:i.clientX,y:i.clientY,transform:j},i.currentTarget.setPointerCapture(i.pointerId),i.preventDefault())},X=i=>{O.current&&(G.current={x:i.clientX,y:i.clientY},z())},ue=i=>{O.current&&(O.current=null,G.current=null,i.currentTarget.hasPointerCapture(i.pointerId)&&i.currentTarget.releasePointerCapture(i.pointerId))},J=x.useCallback(i=>{if(i.deltaY===0)return;i.preventDefault();const r=i.currentTarget.getBoundingClientRect();k.current={x:i.clientX-r.left,y:i.clientY-r.top,deltaY:i.deltaY},z()},[z]);x.useEffect(()=>{const i=c.current;if(i)return i.addEventListener("wheel",J,{passive:!1}),()=>i.removeEventListener("wheel",J)},[J]);const oe=i=>{const r=i.shiftKey?Fe*4:Fe;switch(i.key){case"Escape":if(_.kind!=="pressing"&&_.kind!=="dragging")return;i.preventDefault(),_.kind==="dragging"&&(y.current=!0),$(g=>ee(g,{kind:"cancel"}));return;case"0":i.preventDefault(),re();return;case"+":case"=":i.preventDefault(),N(g=>ye(g,{x:u.width/2,y:u.height/2},g.k*qe));return;case"-":case"_":i.preventDefault(),N(g=>ye(g,{x:u.width/2,y:u.height/2},g.k/qe));return;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":{i.preventDefault();const g=i.key==="ArrowLeft"?r:i.key==="ArrowRight"?-r:0,A=i.key==="ArrowUp"?r:i.key==="ArrowDown"?-r:0;N(H=>({...H,tx:H.tx+g,ty:H.ty+A}));return}}};return s.jsxs("div",{ref:c,"data-mesh-canvas":"",role:"group","aria-labelledby":C,tabIndex:0,onPointerDown:Z,onPointerMove:ie,onPointerUp:me,onPointerCancel:i=>{_.kind==="dragging"&&(y.current=!0),$(r=>ee(r,{kind:"cancel"})),ue(i)},"data-mesh-gesture":_.kind,"data-glass-well":"clear",onKeyDown:oe,onDoubleClick:i=>{i.target===i.currentTarget&&re()},className:L("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:`${j.tx}px ${j.ty}px`}}),s.jsxs("div",{"data-mesh-world":"",className:"absolute top-0 left-0",style:{transform:`translate3d(${j.tx}px, ${j.ty}px, 0) scale(${j.k})`,transformOrigin:"0 0",width:M.bounds.width,height:M.bounds.height},children:[s.jsx(At,{stacks:R,geometry:M}),s.jsx(ft,{edges:e.edges,geometry:M,selectedDeviceId:d}),s.jsx("ul",{"aria-label":a("ui.mesh.mesh_canvas.networks"),className:"m-0 list-none p-0",children:e.networks.map(i=>{const r=M.networks.get(i.id);return r?s.jsx(jt,{network:i,x:r.x,y:r.y,refused:T?.kind==="refused"&&_.kind==="dragging"&&_.target.kind==="network"&&_.target.networkId===i.id},i.id):null})}),s.jsx("ul",{"aria-label":a("ui.mesh.mesh_canvas.devices"),className:"m-0 list-none p-0",children:e.devices.map(i=>{const r=M.devices.get(i.id);return r?s.jsx(yt,{device:i,deviceIds:e.devices.map(g=>g.id),x:r.x,y:r.y,nowSeconds:t,selected:i.id===d,sessions:m.get(i.id)??{rows:[],shown:[],hidden:0},sessionTotal:h.get(i.id)??i.sessionCount??0,dropState:Y(i.id),movingSessionId:f,draggedSessionId:xt(_),onOpen:b,onChipPointerDown:ae,onChipClick:()=>{if(y.current){y.current=!1;return}b(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"&&le&&s.jsx("div",{"data-mesh-indicator":"",className:L("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:le})]})};function Tt(e,n,t,d){const m=t.locality==="local"?n:t.owner_device,h=[],f=e.map(l=>l.id);for(const l of e){if(l.id===m)continue;if(l.id===n){h.push({deviceId:l.id,label:d,verb:a("ui.mesh.mesh_card.recall_to_this_device"),keepVerb:a("ui.mesh.mesh_card.copy_here_leave_it_there")});continue}const b=Q(l,f,!0);h.push({deviceId:l.id,label:b,verb:a("ui.mesh.mesh_card.move_to",{device:b}),keepVerb:a("ui.mesh.mesh_card.copy_to",{device:b})})}return h}function $t(e,n,t){return Tt(e.devices,e.selfDeviceId,n,t)}function as(e,n,t){const d=$t(e,n,t),m={selfDeviceId:e.selfDeviceId,devices:new Map(e.devices.map(l=>[l.id,l])),networks:new Map(e.networks.map(l=>[l.id,l]))},h=n.locality==="local"?e.selfDeviceId??"":n.owner_device,f=m.devices.get(h);return d.map(l=>{const b=ve({session:n,ownerDeviceId:h,ownerLabel:f?Q(f,e.devices.map(v=>v.id),!0):n.owner_device_name},{kind:"device",deviceId:l.deviceId},m);return{...l,refused:b.kind==="refused"&&b.code!=="busy"?b.sentence:null}})}const is=({session:e,destinations:n,disabled:t,onChoose:d,onOpenChange:m,trigger:h,triggerLabel:f})=>(W(),s.jsxs(gs,{onOpenChange:m,children:[s.jsx(vs,{asChild:!0,children:s.jsx("button",{type:"button","aria-label":f,"data-mesh-session-menu":e.id,disabled:t||n.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:h})}),s.jsxs(bs,{align:"start",className:"min-w-56",children:[s.jsx(_s,{children:te(e)}),s.jsx(Ae,{}),n.map(l=>s.jsx(Pe,{"data-mesh-move-to":l.deviceId,disabled:!!l.refused,title:l.refused??void 0,onSelect:()=>d(l,!1),children:l.verb},l.deviceId)),s.jsx(Ae,{}),n.map(l=>s.jsx(Pe,{"data-mesh-copy-to":l.deviceId,disabled:!!l.refused,title:l.refused??void 0,onSelect:()=>d(l,!0),children:l.keepVerb},`keep-${l.deviceId}`))]})]})),Ot=({device:e,deviceIds:n,sessions:t,sessionTotal:d,nowSeconds:m,destinationsFor:h,movingSessionId:f,canMove:l,canInvite:b,onClose:v,onMove:w,onShowInList:E,onInvite:C,onRemoveMember:c})=>{W();const u=se(e),p=Ke(e),j=e.reachable?[]:e.attempts??[];x.useEffect(()=>{const o=I=>{I.key!=="Escape"||I.defaultPrevented||I.target?.closest('[role="menu"],[role="dialog"]')||(document.querySelector(`[data-mesh-device-open="${e.id}"]`)?.focus(),v())};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e.id,v]);const N=e.sessionCount===null?Ze(null):a("ui.mesh.mesh_card.conversation_count",{count:e.sessionCount}),D=e.suspect?Ve():[N,xe(u)].filter(Boolean).join(" · "),y=d>t.rows.length?a("ui.mesh.mesh_card.shown_of",{shown:t.rows.length,total:d}):`${t.rows.length}`;return s.jsxs("aside",{"aria-label":a("ui.mesh.mesh_card.device_details",{device:Q(e)}),"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(V,{size:"sm",variant:"ghost",className:"w-fit self-end","data-mesh-panel-close":"",onClick:v,children:a("ui.mesh.mesh_actions.close")}),s.jsx("h2",{className:"text-body-sm text-ink",children:s.jsx(De,{deviceId:e.id,deviceIds:n,name:e.name,compact:!0})}),s.jsxs("p",{className:"flex items-center gap-1.5 text-meta text-ink-muted",children:[e.suspect&&s.jsx(Ce,{"aria-hidden":"true",className:"size-3.5 text-danger"}),!e.suspect&&u==="unanswered"&&s.jsx(fs,{"aria-hidden":"true",className:"size-3.5 text-warning"}),D]})]}),s.jsx(de,{}),s.jsxs("section",{className:"flex flex-col gap-2",children:[s.jsx("h3",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_card.memberships")}),s.jsx("ul",{className:"m-0 flex list-none flex-col gap-2 p-0",children:e.memberships.map(o=>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(Se,{"aria-hidden":"true",className:"size-3.5 text-ink-muted"}),o.networkName]}),s.jsxs("span",{className:"text-meta text-ink-dim",children:[o.role||"member",o.capabilities.length>0?` · ${o.capabilities.join(", ")}`:""]}),b&&s.jsxs(V,{size:"sm",variant:"ghost",className:"w-fit","data-mesh-remove-member":`${o.networkId}:${e.id}`,onClick:()=>c(e,o.networkId),children:[a("ui.mesh.mesh_card.remove_from"),o.networkName,"…"]})]},o.networkId))}),b&&s.jsx(V,{size:"sm",variant:"secondary",className:"w-fit","data-mesh-invite":e.id,onClick:()=>C(e),children:a("ui.mesh.mesh_actions.invite_to_a_network")})]}),s.jsx(de,{}),s.jsxs("section",{className:"flex shrink-0 flex-col gap-2",children:[s.jsxs("h3",{className:"text-meta text-ink-dim",children:[a("ui.mesh.mesh_card.conversations"),s.jsxs("span",{className:"text-ink-disabled",children:["(",se(e)!=="self"&&se(e)!=="reached"?Qe(null):y,")"]})]}),be(e,m)?s.jsx("p",{className:"text-meta text-warning",children:be(e,m)}):t.rows.length===0?s.jsx("p",{className:"text-meta text-ink-dim",children:e.sessionCount===null?a("ui.mesh.mesh_card.this_device_did_not_report_its_conversations"):a("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(o=>s.jsxs("li",{"data-mesh-panel-session":o.id,className:L("flex items-center gap-2 rounded-sm px-2 py-1","border border-hairline bg-elevated",f===o.id&&"border-control"),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-body-sm text-ink",title:te(o),children:te(o)}),s.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:ns(o,Q(e,n,!0),se(e))}),f===o.id?s.jsx("span",{className:"shrink-0 text-meta text-ink-muted",children:a("ui.mesh.mesh_card.moving")}):s.jsx(is,{session:o,destinations:h(o),disabled:!l,onChoose:(I,R)=>w(o,I,R),trigger:s.jsx(ss,{"aria-hidden":"true",className:"size-4"}),triggerLabel:a("ui.mesh.mesh_card.move_conversation",{conversation:te(o)})})]},o.id))})]}),s.jsx(de,{}),s.jsxs("section",{className:"flex flex-col gap-2",children:[s.jsx("h3",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_card.network_addresses")}),e.endpoints.length===0?s.jsx("p",{className:"text-meta text-ink-dim",children:a("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(o=>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:o}),s.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:a("ui.mesh.mesh_card.advertised")})]},o))})]}),s.jsx(de,{}),s.jsxs("section",{className:"flex flex-col gap-2",children:[s.jsx("h3",{className:"text-meta text-ink-dim",children:a("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:a("ui.mesh.mesh_card.reach")}),s.jsx("dd",{className:"m-0 text-body-sm text-ink",children:xe(u)})]}),s.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[s.jsx("dt",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_card.last_status_frame")}),s.jsx("dd",{className:"m-0 text-body-sm text-ink",children:e.lastSeenAt===null?a("ui.mesh.mesh_card.never"):Fs(m-e.lastSeenAt)})]})]}),!e.reachable&&(p!==""||j.length>0)&&s.jsxs("div",{className:"flex flex-col gap-1",children:[p&&s.jsx("p",{className:"m-0 text-meta text-warning",children:p}),e.linkState==="handshake_refused"&&s.jsx("p",{className:"m-0 text-meta text-ink-dim",children:a("ui.mesh.mesh_reach.handshake_refused_hint")}),j.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{id:`mesh-attempts-label-${e.id}`,className:"text-meta text-ink-dim",children:a("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:j.map((o,I)=>{const R=Xe(o.detail);return s.jsxs("li",{"data-mesh-attempt":o.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:o.endpoint}),s.jsx("span",{className:"shrink-0 text-meta text-ink-dim",children:R})]},`${o.endpoint}:${I}`)})})]})]}),!p&&j.length===0&&e.reason&&s.jsx("p",{className:"text-meta text-warning",children:e.reason})]}),s.jsx(de,{}),s.jsx(V,{size:"sm",variant:"ghost",className:"w-fit","data-mesh-show-in-list":e.id,onClick:()=>E(e.id),children:a("ui.mesh.mesh_card.show_in_list")})]})},zt=["name","chats","state"],Ht={get name(){return a("ui.mesh.mesh_list.name")},get chats(){return a("ui.mesh.mesh_list.sort_conversations")},get state(){return a("ui.mesh.mesh_list.state")}},Be={suspect:0,relay_down:1,handshake_refused:2,unreachable:3,self:4,reachable:5};function Wt(e,n){const t=[...e];switch(n){case"chats":return t.sort((d,m)=>(m.sessionCount??-1)-(d.sessionCount??-1)||d.label.localeCompare(m.label)),t;case"state":return t.sort((d,m)=>Be[d.state]-Be[m.state]||d.label.localeCompare(m.label)),t;default:return t.sort((d,m)=>d.label.localeCompare(m.label))}}const Ye=8;function Ft(e,n){if(e.locality==="local")return e.live_state||"here";const t=e.owner_device_name||n,d=e.live_state?` · ${e.live_state}`:"";return e.reachable?a("ui.mesh.mesh_list.on_device_state",{device:t,state:d}):a("ui.mesh.mesh_list.on_device_no_answer",{device:t})}const qt=({graph:e,nowSeconds:n,selectedDeviceId:t,sessions:d,selfLabel:m,canMove:h,onSelect:f,onMove:l,onInvite:b,onRemove:v})=>{W();const[w,E]=x.useState("name"),C=x.useMemo(()=>e.networks.map(c=>({network:c,members:Wt(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 pe-1",children:[s.jsxs("fieldset",{className:"m-0 w-fit border-0 p-0",children:[s.jsx("legend",{className:"sr-only",children:a("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:zt.map(c=>s.jsx("button",{type:"button","aria-pressed":w===c,onClick:()=>E(c),className:L("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:Ht[c]},c))})]}),C.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:a("ui.mesh.mesh_list.epoch",{epoch:c.epoch}),children:[c.label,s.jsxs("span",{className:"text-meta text-ink-dim",children:[c.trust," ·"," ",a("ui.mesh.mesh_graph.device_count",{count:c.memberCount}),c.revokedCount>0?s.jsxs(s.Fragment,{children:[" · ",a("ui.mesh.mesh_list.revoked_count",{count:c.revokedCount})]}):null]})]}),s.jsx("ul",{className:"m-0 flex list-none flex-col gap-1 p-0",children:u.map(p=>{const j=p.memberships.find(S=>S.networkId===c.id),N=p.id===t,D=d.get(p.id),y=D?.rows??[],o=D?es(D,p.sessionCount):p.sessionCount??0,I=se(p),R=Ke(p),M=p.reachable?[]:p.attempts??[];return s.jsxs("li",{"data-mesh-device-row":p.id,"data-mesh-state":p.state,"aria-current":N?"true":void 0,className:L("flex flex-col gap-1 rounded-md px-3 py-2","border border-hairline bg-surface",N&&"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:L("min-w-0 flex-1 text-start 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:s.jsx(De,{deviceId:p.id,name:p.name})}),s.jsxs("span",{className:L("flex shrink-0 items-center gap-1 text-meta",Ue[I]),"data-mesh-reach":I,children:[p.suspect&&s.jsx(Ce,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-danger"}),p.suspect?xe(I):Je(p,n),p.suspect&&s.jsx("span",{className:"shrink-0 rounded-sm border border-danger px-1 text-danger",children:Ve()})]}),s.jsxs("span",{className:"shrink-0 text-meta text-ink-dim",children:[j?.role?`${j.role} · `:"",a("ui.mesh.mesh_list.member")]})]}),(R!==""||M.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}),M.map((S,_)=>{const $=Xe(S.detail);return s.jsx("span",{"data-mesh-attempt":S.endpoint,className:"text-meta text-ink-dim",children:$?`${S.endpoint} — ${$}`:S.endpoint},`${S.endpoint}:${_}`)})]}),be(p,n)?s.jsxs("span",{className:"text-meta text-warning",children:[a("ui.mesh.mesh_card.conversations")," (",Qe(null),") ·"," ",be(p,n)]}):y.length>0?s.jsxs(s.Fragment,{children:[s.jsx(de,{className:"my-1"}),s.jsx("ul",{className:"m-0 flex list-none flex-col gap-0.5 p-0",children:y.slice(0,Ye).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:Ft(S,m)}),s.jsx(is,{session:S,destinations:as(e,S,m),disabled:!h,onChoose:(_,$)=>l(S,_,$),trigger:s.jsx(ss,{"aria-hidden":"true",className:"size-3.5"}),triggerLabel:a("ui.mesh.mesh_list.move_conversation",{conversation:S.name||S.id})})]},S.id))}),o>y.slice(0,Ye).length&&s.jsx("button",{type:"button",onClick:()=>f(p.id),className:"w-fit text-meta text-ink-dim hover:text-ink",children:a("ui.mesh.mesh_list.show_all_panel",{count:o})})]}):s.jsx("span",{className:"text-meta text-ink-dim",children:a("ui.mesh.mesh_list.conversation_count",{count:o})}),(j||p.state!=="self")&&s.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[s.jsx(V,{size:"sm",variant:"ghost","data-mesh-invite":p.id,onClick:()=>b({deviceId:p.id,deviceName:p.name}),children:a("ui.mesh.mesh_actions.invite_to_a_network")}),j&&s.jsxs(V,{size:"sm",variant:"ghost","data-mesh-remove-member":`${c.id}:${p.id}`,onClick:()=>v({networkId:c.id,networkLabel:c.label,deviceId:p.id,deviceName:p.name}),children:[a("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:[a("ui.mesh.mesh_graph.device_count",{count:e.unmatchedPeers.length})," ",a("ui.mesh.mesh_list.answered_the_peer_read_but_is_in")]})]})},Bt=({revoked:e})=>{if(e.length===0)return null;const n=a("ui.mesh.mesh_list.revoked_count",{count:e.length});return s.jsx(Me,{className:"contents",chevron:"trailing",chevronClassName:"text-ink-dim",rowClassName:"min-h-auto py-0",triggerClassName:"inline-flex w-auto items-center gap-1 align-baseline text-meta text-ink-dim hover:text-ink",triggerData:{"data-mesh-revoked-toggle":""},triggerLabel:a("ui.mesh.mesh_list.revoked_toggle_label"),summary:s.jsxs(s.Fragment,{children:[s.jsx("span",{"aria-hidden":"true",className:"inline-block whitespace-pre",children:" · "}),n]}),children:s.jsx("ul",{"data-mesh-revoked":"",className:"m-0 flex list-none flex-col gap-1 p-0",children:e.map(t=>s.jsxs("li",{"data-mesh-revoked-member":t.deviceId,className:"flex flex-wrap items-baseline gap-x-2 text-meta text-ink-dim",children:[s.jsx("span",{children:t.networkName}),s.jsx("span",{className:"font-mono text-body-sm text-ink",children:t.deviceId}),s.jsx("span",{className:"text-body-sm text-ink-muted",children:t.label}),s.jsxs("span",{children:[t.role?`${t.role} · `:"",a("ui.mesh.mesh_graph.revoked_membership")]})]},`${t.networkId}:${t.deviceId}`))})})},Yt=["canvas","list"],Gt={get canvas(){return a("ui.mesh.mesh_page.canvas")},get list(){return a("ui.mesh.mesh_page.list")}},Ut=({state:e,initialPresentation:n="canvas",graph:t,nowSeconds:d,checking:m,staleError:h,onRetry:f,approvals:l,sessions:b,sessionError:v,selfLabel:w,movingSessionId:E,canMove:C,pendingMove:c,onAskMove:u,onDropRefused:p,onChooseMove:j,onCancelMove:N,moveBusy:D,moveReport:y,onDismissReport:o,onWaitForIdle:I,onUndoCopy:R,invite:M,onOpenInvite:S,onInvite:_,onCloseInvite:$,inviteBusy:ce,inviteReceipt:ne,inviteRefusal:T,remove:Y,onOpenRemove:ae,onRemove:ie,onCloseRemove:me,removeBusy:re,removeRefusal:q,removed:le})=>{W();const[G,k]=x.useState(n),[P,O]=x.useState(null),U=t?qs(t):"",z="mesh-summary",Z=Bs(t),X=Ys(t,b,t?.selfDeviceId??null),ue=x.useMemo(()=>{const r=new Map;for(const g of t?.devices??[]){const A=X.byDevice.get(g.id);r.set(g.id,A?es(A,g.sessionCount):g.sessionCount??0)}return r},[t,X]),J=x.useCallback(r=>{O(r)},[]),oe=t?t.devices.find(r=>r.id===P)??null:null,i=x.useCallback((r,g,A)=>{if(!t)return null;const H={selfDeviceId:t.selfDeviceId,devices:new Map(t.devices.map(B=>[B.id,B])),networks:new Map(t.networks.map(B=>[B.id,B]))},K=r.locality==="local"?t.selfDeviceId??"":r.owner_device,Ee=H.devices.get(K),F=ve({session:r,ownerDeviceId:K,ownerLabel:Ee?Q(Ee,t.devices.map(B=>B.id),!0):r.owner_device_name},{kind:"device",deviceId:g.deviceId},H);if(F.kind==="refused")return p({code:F.code,sentence:F.sentence,reach:F.reach,remedy:F.remedy,plan:F.plan??null}),null;if(F.kind==="none")return null;const Re=A?F.alternatives.find(B=>B.keep)??F.plan:F.plan,rs=[F.plan,...F.alternatives].filter(B=>B.keep!==Re.keep),ls={plan:Re,alternatives:rs,risky:F.risky};u(ls)},[t,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(ps,{title:a("ui.mesh.mesh_page.mesh"),icon:Se,subtitle:a("ui.mesh.mesh_page.devices_this_app_is_paired_with_and"),children:s.jsxs("div",{className:"flex items-center gap-4",children:[m&&s.jsx("output",{className:"text-meta text-ink-dim",children:a("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:a("ui.mesh.mesh_page.presentation")}),s.jsx("div",{"data-glass-well":"",className:"flex gap-0.5 rounded-md bg-sunken p-0.5",children:Yt.map(r=>s.jsx("button",{type:"button","data-mesh-presentation":r,"aria-pressed":G===r,disabled:e.kind!=="ready",onClick:()=>k(r),className:L("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",G===r&&"bg-surface text-ink"),children:Gt[r]},r))})]})]})}),s.jsx(ht,{rows:l.rows,error:l.error,pending:l.pending,refusal:l.decisionRefusal,onDecide:l.onDecide,onRetry:l.onRetry,nowSeconds:l.nowSeconds,networkNames:new Map((t?.networks??[]).map(r=>[r.id,r.label]))}),e.kind==="loading"&&s.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[s.jsx(Le,{className:"h-4 w-64"}),s.jsx(Le,{className:"min-h-40 w-full flex-1"})]}),e.kind==="error"&&s.jsxs(ge,{variant:"warning",className:"flex-col items-start gap-2",children:[s.jsx("p",{children:e.message}),s.jsx(V,{variant:"secondary",size:"sm",onClick:f,className:"w-fit",children:a("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:a("ui.mesh.mesh_page.no_network_on_this_device")}),s.jsx("p",{className:"max-w-140 text-body-sm text-ink-muted",children:a("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:a("ui.mesh.mesh_page.a_network_appears_here_once_this_device")})]})}),e.kind==="ready"&&t&&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.jsxs("div",{id:z,className:"text-meta text-ink-muted","data-mesh-summary":"",children:[s.jsx("span",{children:U}),s.jsx(Bt,{revoked:t.revoked})]}),h&&s.jsx(ge,{variant:"warning",children:s.jsx("p",{children:h})}),v&&s.jsx(ge,{variant:"warning",children:s.jsx("p",{children:v})}),y&&s.jsx(Gs,{receipt:y.kind==="moved"?{verb:y.verb,detail:y.detail,undo:y.undo}:null,refusal:y.kind==="refused"?y.refusal:null,canWait:y.kind==="refused"&&y.plan!==null,onWait:I,onRecheck:f,onUndo:R,onDismiss:o,pending:D}),G==="canvas"?s.jsx(Lt,{graph:t,slots:Z,nowSeconds:d,selectedDeviceId:P,sessions:X.byDevice,sessionTotals:ue,movingSessionId:E,canMove:C,onOpenDevice:J,onAskMove:u,onDropRefused:p,onShowAllSessions:J,summaryId:z}):s.jsx(qt,{graph:t,nowSeconds:d,selectedDeviceId:P,sessions:X.byDevice,selfLabel:w,canMove:C,onSelect:J,onMove:i,onInvite:S,onRemove:ae})]}),oe&&s.jsx(Ot,{device:oe,deviceIds:t.devices.map(r=>r.id),sessions:X.byDevice.get(oe.id)??{rows:[],shown:[],hidden:0},sessionTotal:ue.get(oe.id)??0,nowSeconds:d,canMove:C,canInvite:e.kind==="ready",movingSessionId:E,destinationsFor:r=>as(t,r,w),onClose:()=>O(null),onMove:i,onInvite:r=>S({deviceId:r.id,deviceName:r.name}),onRemoveMember:(r,g)=>{const A=t.networks.find(H=>H.id===g);ae({networkId:g,networkLabel:A?.label??g,deviceId:r.id,deviceName:r.name})},onShowInList:r=>{J(r),k("list")}})]})}),s.jsx(Us,{open:c!==null,plan:c?.plan??Kt,alternatives:c?.alternatives??[],risky:c?.risky??!1,busy:D,onCancel:N,onChoose:j}),M&&s.jsx(Ks,{open:M.open,options:M.options,deviceId:M.deviceId,deviceName:M.deviceName,onClose:$,onInvite:_,pending:ce,receipt:ne,refusal:T}),Y&&s.jsx(Vs,{open:Y.open,networkLabel:Y.networkLabel,deviceId:Y.deviceId,deviceName:Y.deviceName,onClose:me,onConfirm:ie,pending:re,refusal:q,removed:le})]})},Kt={sessionId:"",to:"",keep:!1,verb:"",waitS:0,lost:null},an=({initialPresentation:e})=>{W();const n=us(),t=ke(n.data,"peers")==="enabled",d=ke(n.data,"session_transfer")==="enabled",m=Xs(t,{stamp:()=>we.getState().beginAnswer()}),h=Zs(t),f=Js(t,{poll:!1,stamp:()=>we.getState().beginAnswer()}),l=x.useMemo(()=>({peers:m,networks:h}),[m,h]),b=Qs(l),v=et(l),w=st(),E=ke(n.data,"approvals")==="enabled",C=tt(t&&E,{poll:!1}),c=nt(),u=c.isError?{approvalId:c.variables?.approvalId??null,...at(c.error)}:null,p=x.useMemo(()=>Math.floor((C.dataUpdatedAt||Date.now())/1e3),[C.dataUpdatedAt]),j=we(k=>k.settlePlacement),N=it(),D=rt(),[y,o]=x.useState(null),[I,R]=x.useState(null),[M,S]=x.useState(null),[_,$]=x.useState(null),[ce,ne]=x.useState(null),[T,Y]=x.useState(null),[ae,ie]=x.useState(null),me=x.useMemo(()=>{const k=Math.max(m.dataUpdatedAt,h.dataUpdatedAt);return Math.floor((k||Date.now())/1e3)},[m.dataUpdatedAt,h.dataUpdatedAt]),re=x.useCallback(()=>{m.refetch(),h.refetch(),f.refetch()},[m,h,f]),q=x.useCallback((k,P)=>{o(null);const O={sessionId:k.sessionId,to:k.to,keep:k.keep,waitS:P??k.waitS};w.mutate(O,{onSuccess:U=>{if(U.kind==="moved"){const{receipt:z}=U;j(k.sessionId,z);const Z=z.locality==="local"?a("ui.mesh.mesh_drop.this_device"):v?.devices.find(X=>X.id===z.owner_device)?.label??z.owner_device;R({kind:"moved",verb:z.mode==="keep"?a("ui.mesh.mesh_page.copied"):a("ui.mesh.mesh_page.moved"),detail:z.mode==="keep"?a("ui.mesh.mesh_page.copy_receipt",{destination:Z,suffix:z.new_session_id.slice(-6)}):a("ui.mesh.mesh_page.move_receipt",{destination:Z,retirement:z.source_retired?a("ui.mesh.mesh_page.the_copy_here_is_gone"):""}),undo:z.mode==="keep"?{sessionId:z.new_session_id,to:"local",keep:!1,verb:a("ui.mesh.mesh_page.bring_copy_back",{device:Z}),waitS:0,lost:lt(Z,a("ui.mesh.mesh_drop.this_device"))}:null});return}R({kind:"refused",refusal:U.refusal,plan:k})},onError:()=>{R({kind:"refused",refusal:{code:"move_failed",sentence:a("ui.mesh.mesh_page.the_move_could_not_be_sent_nothing"),status:null,unconfirmed:!1},plan:k})}})},[v,w,j]),le=x.useMemo(()=>{if(!v)return[];const k=M?.deviceId,P=k?v.devices.find(O=>O.id===k):void 0;return v.networks.filter(O=>P?!P.memberships.some(U=>U.networkId===O.id):!0).map(O=>({id:O.id,label:O.label}))},[v,M]);if(!t)return s.jsx(hs,{to:"/chat",replace:!0});const G=b.kind==="ready"?m.error?he(m.error):h.error?he(h.error):null:null;return s.jsx(Ut,{initialPresentation:e,state:b,graph:v,nowSeconds:me,checking:m.isFetching||h.isFetching,staleError:G,onRetry:re,approvals:{rows:C.data??[],error:C.isError?ot(C.error):null,pending:c.isPending?c.variables??null:null,decisionRefusal:u,onDecide:(k,P)=>c.mutate({approvalId:k,decision:P}),onRetry:()=>void C.refetch(),nowSeconds:p},sessions:f.data?.rows??[],movingSessionId:w.isPending?w.variables?.sessionId??null:null,sessionError:f.isError?he(f.error):null,selfLabel:v?.devices.find(k=>k.state==="self")?.label??a("ui.mesh.mesh_drop.this_device"),canMove:d,pendingMove:y,onAskMove:o,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:()=>o(null),moveBusy:w.isPending,moveReport:I,onDismissReport:()=>R(null),onWaitForIdle:()=>{I?.kind!=="refused"||!I.plan||q(I.plan,Vt)},onUndoCopy:()=>{I?.kind!=="moved"||!I.undo||o({plan:I.undo,alternatives:[],risky:!1})},invite:M===null?null:{open:!0,deviceId:M.deviceId,deviceName:M.deviceName,options:le},onOpenInvite:k=>{$(null),ne(null),S(k)},onInvite:k=>{N.mutate(k,{onSuccess:P=>$(P),onError:P=>ne({code:"invite_refused",sentence:he(P),status:null,unconfirmed:!1})})},onCloseInvite:()=>S(null),inviteBusy:N.isPending,inviteReceipt:_,inviteRefusal:ce,remove:T===null?null:{open:!0,networkId:T.networkId,networkLabel:T.networkLabel,deviceId:T.deviceId,deviceName:T.deviceName},onOpenRemove:k=>{ie(null),Y(k)},onRemove:k=>{T&&D.mutate({networkId:T.networkId,deviceId:T.deviceId,confirm:k},{onSuccess:P=>ie(P)})},onCloseRemove:()=>Y(null),removeBusy:D.isPending,removeRefusal:D.isError?{code:"remove_refused",sentence:he(D.error),status:null,unconfirmed:!1}:null,removed:ae})},Vt=300;export{an as MeshPage,Ut as MeshSurface,an as default};
@@ -1 +0,0 @@
1
- import{r as f,j as i,c as _}from"./index-B4nU7SY-.js";import{u as w,b as D,h as P,c as C,d as I,H as W,e as E}from"./index-C1xioNnx.js";import{u as v,B as m,C as F,D as H,a as O,b as R,d as S,e as z,f as B}from"./error-boundary-Bq37z0Vv.js";import{t as a}from"./messages-Bsgf6o-p.js";import{D as $}from"./path-utils-Dy8qomEz.js";const k=e=>e==null?"":typeof e=="string"?e:JSON.stringify(e,null,2),M={available:"border-hairline",updating:"border-hairline",applied:"border-hairline",review:"border-warning-border",failed:"border-danger-border"};function T(e){const s=[];for(const o of e??[])for(const d of o.fields??[])for(const t of d.regions??[])(t.provenance==="unresolved"||k(t.local)!==k(t.remote))&&s.push({field:d.field,region:t});return s}function A({regions:e}){return v(),e.length?i.jsx("ul",{className:"space-y-3","data-testid":"hub-update-preview",children:e.map(({field:s,region:o},d)=>i.jsxs("li",{className:"space-y-1 text-meta",children:[i.jsx("p",{className:"font-medium text-ink",children:o.heading||o.name||s}),i.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-ink-muted",children:a("ui.agents.navigation.updates.preview.local")}),i.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap rounded-sm border border-hairline p-2 text-ink",children:k(o.local)||a("ui.agents.navigation.updates.preview.nothing")})]}),i.jsxs("div",{children:[i.jsx("p",{className:"text-ink-muted",children:a("ui.agents.navigation.updates.preview.remote")}),i.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap rounded-sm border border-hairline p-2 text-ink",children:k(o.remote)||a("ui.agents.navigation.updates.preview.nothing")})]})]})]},`${s}:${o.id??d}`))}):i.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.agents.navigation.updates.preview.empty")})}function V({kind:e,name:s,enabled:o}){v();const d=w(o),t=D(),[x,h]=f.useState(null),p=C(e,s),b=P(d.data).get(p),l=I(b),c=t.notes[p],n=t.pending.has(p);if(!b||!l)return c?i.jsx("section",{"data-testid":"hub-update-panel","aria-label":a("ui.agents.navigation.updates.accessible"),className:"mb-8 rounded-md border border-hairline p-3 text-body-sm",children:i.jsx("p",{role:c.tone==="error"?"alert":"status",className:c.tone==="error"?"text-danger":"text-ink",children:c.message})}):null;const u=l.kind==="review",r=b.classification==="baseline-unknown",g=j=>({prefer:j,acknowledgeUnknownBaseline:r}),N=async()=>{const j=await t.applyItem(e,s,{...g(),dryRun:!0});h(j??[])};return i.jsxs("section",{"data-testid":"hub-update-panel","aria-label":a("ui.agents.navigation.updates.accessible"),className:_("mb-8 space-y-2 rounded-md border p-3 text-body-sm",M[l.kind]),children:[i.jsxs("p",{className:"flex items-start gap-2 text-ink",children:[i.jsx(W,{mark:l,className:"mt-0.5"}),i.jsx("span",{className:_(l.kind==="failed"&&"text-danger"),children:E(b,l)})]}),t.upgradeMessage&&i.jsx("output",{className:"block text-meta text-warning","data-hub-core-upgrade":!0,children:t.upgradeMessage}),u&&r&&i.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.agents.navigation.updates.baseline_unknown")}),u&&!r&&i.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.agents.navigation.updates.merge_guidance")}),i.jsxs("div",{className:"flex flex-wrap gap-2",children:[l.kind==="available"&&i.jsx(m,{size:"sm",variant:"outline","aria-disabled":n||!t.canWrite||void 0,onClick:()=>!n&&t.canWrite&&void t.applyItem(e,s),children:n?a("ui.agents.navigation.updates.action.updating"):a("ui.agents.navigation.updates.action.update")}),l.kind==="failed"&&l.retryable&&i.jsx(m,{size:"sm",variant:"outline","aria-disabled":n||!t.canWrite||void 0,onClick:()=>!n&&t.canWrite&&void t.retryItem(e,s),children:n?a("ui.agents.navigation.updates.action.retrying"):a("ui.agents.navigation.updates.action.retry")}),u&&i.jsxs(i.Fragment,{children:[i.jsx(m,{size:"sm",variant:"outline","aria-disabled":n||!t.canWrite||void 0,onClick:()=>!n&&t.canWrite&&void N(),children:n&&!x?a("ui.agents.navigation.updates.action.loading"):a("ui.agents.navigation.updates.action.preview")}),i.jsx(m,{size:"sm",variant:"ghost","aria-disabled":n||!t.canWrite||void 0,onClick:()=>!n&&t.canWrite&&void t.applyItem(e,s,g("local")),children:a("ui.agents.navigation.updates.action.keep_local")}),i.jsx(m,{size:"sm",variant:"ghost","aria-disabled":n||!t.canWrite||void 0,onClick:()=>!n&&t.canWrite&&void t.applyItem(e,s,g("remote")),children:a("ui.agents.navigation.updates.action.use_remote")})]})]}),x&&u&&i.jsx(A,{regions:T(x)}),c&&i.jsx("p",{role:c.tone==="error"?"alert":"status",className:c.tone==="error"?"text-meta text-danger":"text-meta text-ink-muted",children:c.message})]})}const X=()=>({subscribe:!0,autoPush:!1,confirmPublicEgress:!1});function Y({value:e,onChange:s,source:o,item:d,visibility:t,organization:x,destinationKey:h,canEnableAutoPush:p,disabled:b=!1}){v();const l=f.useId(),c=f.useRef(null),[n,u]=f.useState(null);return f.useEffect(()=>{n!==null&&n!==h&&u(null)},[n,h]),i.jsxs("div",{className:"flex flex-col gap-3","data-initial-hub-policy":!0,children:[i.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.hub.skills.initial_policy_description")}),["subscribe","autoPush"].map(r=>i.jsxs("label",{htmlFor:`${l}-${r}`,className:"flex items-start gap-3 text-body-sm text-ink",children:[i.jsx(F,{id:`${l}-${r}`,checked:e[r],disabled:b||r==="autoPush"&&!p&&!e.autoPush,onCheckedChange:g=>{r==="subscribe"?s({...e,subscribe:g===!0}):g!==!0?s({...e,autoPush:!1,confirmPublicEgress:!1}):p&&u(h)}}),i.jsxs("span",{children:[i.jsx("span",{className:"block",children:a(r==="subscribe"?"ui.hub.subscriptions.subscribe":"ui.hub.subscriptions.auto_push")}),i.jsx("span",{className:"block text-meta text-ink-muted",children:a(r==="subscribe"?"ui.hub.subscriptions.subscribe_description":"ui.hub.subscriptions.auto_push_description",{source:o})})]})]},r)),!p&&i.jsx("p",{className:"text-meta text-ink-muted",children:a("ui.hub.subscriptions.unsupported")}),i.jsx(H,{open:n!==null,onOpenChange:r=>{r||u(null)},children:i.jsxs(O,{onOpenAutoFocus:r=>{r.preventDefault(),c.current?.focus()},children:[i.jsxs(R,{children:[i.jsx(S,{children:a("ui.hub.subscriptions.enable_title",{source:o})}),i.jsx(z,{children:t==="public"?a("ui.hub.subscriptions.enable_public",{item:d}):a("ui.hub.subscriptions.enable_private",{item:d,organization:x??o})})]}),i.jsx("p",{className:"text-body-sm text-ink-muted",children:a("ui.hub.subscriptions.enable_safety")}),i.jsxs(B,{children:[i.jsx(m,{ref:c,"data-testid":"hub-policy-cancel",variant:"outline",onClick:()=>u(null),children:a("ui.hub.subscriptions.cancel")}),i.jsx(m,{"data-testid":"hub-policy-enable",disabled:b||!p||n!==h,onClick:()=>{s({...e,autoPush:!0,confirmPublicEgress:t==="public"}),u(null)},children:a("ui.hub.subscriptions.enable")})]})]})})]})}function Z(e,s,o=Date.now()){return e.can_confirm===!0&&e.kind==="skill"&&e.direction==="push"&&e.publication==="create"&&e.proposal?.kind==="skill"&&e.proposal.fields?.document_version===1&&e.preview_receipt.length>0&&e.local_fingerprint.length>0&&e.draft_fingerprint.length>0&&e.proposal_fingerprint.length>0&&e.source_skill===s.sourceSkill&&e.local_alias===s.localAlias&&e.visibility===s.visibility&&e.tenant_id===s.tenantId&&e.policy?.subscribe===s.subscribe&&e.policy?.auto_push===s.autoPush&&e.policy?.confirm_public_egress===s.confirmPublicEgress&&Number.isFinite(Date.parse(e.expires_at))&&Date.parse(e.expires_at)>o}function K(e){return e.local_link_receipt?.state==="complete"&&!!e.link&&e.local_link_receipt.link_id===e.link.link_id&&typeof e.link.policy?.subscribe=="boolean"&&typeof e.link.policy.auto_push=="boolean"&&typeof e.link.policy.revision=="string"&&e.link.policy.revision.length>0}const U=e=>e==="active"||e==="past_due",y=e=>e.status!=="active"?"no_access":U(e.plan.status)?"available":"plan_inactive",ee=e=>e.filter(s=>y(s)==="available"),ie=e=>e.filter(s=>y(s)==="plan_inactive"),se=e=>{if(!(e instanceof $))return null;switch(e.code){case"team_plan_required":return"plan";case"not_a_member":case"insufficient_role":return"no_access";default:return null}};export{Y as H,V as a,ie as b,Z as i,X as n,se as o,K as p,ee as u};
@@ -1 +0,0 @@
1
- import{b as e}from"./path-utils-Dy8qomEz.js";const r="Sharing agents with an organization needs a newer Local Operator backend. Update the backend and try again.",t=n=>n==="enabled",c=(n,a)=>n==="enabled"||n==="unknown"?null:e(n,a)??r;export{t as a,c as o};
@@ -1 +0,0 @@
1
- import{t as D,c as p,m as N,a as g}from"./en-US-CHJkXXr4.js";function W(t,e,n){const r=D(t,n?.in);return isNaN(e)?p(n?.in||t,NaN):(e&&r.setDate(r.getDate()+e),r)}function $(t,e){const n=()=>p(e?.in,NaN),a=I(t);let s;if(a.date){const i=x(a.date,2);s=Y(i.restDateString,i.year)}if(!s||isNaN(+s))return n();const u=+s;let o=0,c;if(a.time&&(o=w(a.time),isNaN(o)))return n();if(a.timezone){if(c=y(a.timezone),isNaN(c))return n()}else{const i=new Date(u+o),d=D(0,e?.in);return d.setFullYear(i.getUTCFullYear(),i.getUTCMonth(),i.getUTCDate()),d.setHours(i.getUTCHours(),i.getUTCMinutes(),i.getUTCSeconds(),i.getUTCMilliseconds()),d}return D(u+o+c,e?.in)}const f={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},U=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,h=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,C=/^([+-])(\d{2})(?::?(\d{2}))?$/;function I(t){const e={},n=t.split(f.dateTimeDelimiter);let r;if(n.length>2)return e;if(/:/.test(n[0])?r=n[0]:(e.date=n[0],r=n[1],f.timeZoneDelimiter.test(e.date)&&(e.date=t.split(f.timeZoneDelimiter)[0],r=t.substr(e.date.length,t.length))),r){const a=f.timezone.exec(r);a?(e.time=r.replace(a[1],""),e.timezone=a[1]):e.time=r}return e}function x(t,e){const n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+e)+"})|(\\d{2}|[+-]\\d{"+(2+e)+"})$)"),r=t.match(n);if(!r)return{year:NaN,restDateString:""};const a=r[1]?parseInt(r[1]):null,s=r[2]?parseInt(r[2]):null;return{year:s===null?a:s*100,restDateString:t.slice((r[1]||r[2]).length)}}function Y(t,e){if(e===null)return new Date(NaN);const n=t.match(U);if(!n)return new Date(NaN);const r=!!n[4],a=l(n[1]),s=l(n[2])-1,u=l(n[3]),o=l(n[4]),c=l(n[5])-1;if(r)return Z(e,o,c)?z(e,o,c):new Date(NaN);{const i=new Date(0);return!M(e,s,u)||!O(e,a)?new Date(NaN):(i.setUTCFullYear(e,s,Math.max(a,u)),i)}}function l(t){return t?parseInt(t):1}function w(t){const e=t.match(h);if(!e)return NaN;const n=m(e[1]),r=m(e[2]),a=m(e[3]);return k(n,r,a)?n*N+r*g+a*1e3:NaN}function m(t){return t&&parseFloat(t.replace(",","."))||0}function y(t){if(t==="Z")return 0;const e=t.match(C);if(!e)return 0;const n=e[1]==="+"?-1:1,r=parseInt(e[2]),a=e[3]&&parseInt(e[3])||0;return R(r,a)?n*(r*N+a*g):NaN}function z(t,e,n){const r=new Date(0);r.setUTCFullYear(t,0,4);const a=r.getUTCDay()||7,s=(e-1)*7+n+1-a;return r.setUTCDate(r.getUTCDate()+s),r}const F=[31,null,31,30,31,30,31,31,30,31,30,31];function T(t){return t%400===0||t%4===0&&t%100!==0}function M(t,e,n){return e>=0&&e<=11&&n>=1&&n<=(F[e]||(T(t)?29:28))}function O(t,e){return e>=1&&e<=(T(t)?366:365)}function Z(t,e,n){return e>=1&&e<=53&&n>=0&&n<=6}function k(t,e,n){return t===24?e===0&&n===0:n>=0&&n<60&&e>=0&&e<60&&t>=0&&t<25}function R(t,e){return e>=0&&e<=59}export{W as a,$ as p};