@tickernelz/wardmote-ui 2026.1115.2 → 2026.1115.3

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 (121) hide show
  1. package/dist/assets/{AdapterManager-DlCyzyMu.js → AdapterManager-DD2p5mWg.js} +1 -1
  2. package/dist/assets/{AdvancedToolsRoute-4n8ZC6o0.js → AdvancedToolsRoute-DlPZ_L6N.js} +1 -1
  3. package/dist/assets/{AgentActionButtons-LV4FbrTY.js → AgentActionButtons-sm-e5f06.js} +1 -1
  4. package/dist/assets/{AgentChat-CXR66MM4.js → AgentChat-b78UeZDu.js} +1 -1
  5. package/dist/assets/{AgentChats-C4cEfRO_.js → AgentChats-XK32PfX0.js} +1 -1
  6. package/dist/assets/{AgentDefaults-BZwFysUw.js → AgentDefaults-BZlzjR_2.js} +1 -1
  7. package/dist/assets/{AgentDetail-DPCbH362.js → AgentDetail-DwlY6mx-.js} +1 -1
  8. package/dist/assets/{AgentTodoCard-82Za1R6Y.js → AgentTodoCard-C6-lHXns.js} +1 -1
  9. package/dist/assets/{Agents-BotjqSPg.js → Agents-C1-WHkTj.js} +3 -3
  10. package/dist/assets/{AppDetail-B5T_4Bu-.js → AppDetail-9cue4nY2.js} +1 -1
  11. package/dist/assets/{AppNotConnected-eBGlritA.js → AppNotConnected-oZ4OtRZ5.js} +1 -1
  12. package/dist/assets/{ApprovalCard-CyXVBGnO.js → ApprovalCard-B1Fs4K4S.js} +1 -1
  13. package/dist/assets/{ApprovalDetail-BSNBUdim.js → ApprovalDetail-BchdkauI.js} +1 -1
  14. package/dist/assets/{ApprovalPayload-vezR61PH.js → ApprovalPayload-HdMQnZAw.js} +1 -1
  15. package/dist/assets/{Approvals-YzDki85i.js → Approvals-ecXixAXF.js} +1 -1
  16. package/dist/assets/{AppsReview-D02Q501S.js → AppsReview-DSeqYXkI.js} +1 -1
  17. package/dist/assets/{ArtifactCard-CC5aIvtf.js → ArtifactCard-B9GVJfR3.js} +1 -1
  18. package/dist/assets/{Artifacts-CnP5QapS.js → Artifacts-Cfi9iGlP.js} +1 -1
  19. package/dist/assets/{AssistantConnection-refIKgUa.js → AssistantConnection-D1H83dKT.js} +1 -1
  20. package/dist/assets/{AttentionInteractionResolver-_l8MisRg.js → AttentionInteractionResolver-K_Jeu6_2.js} +1 -1
  21. package/dist/assets/{AuditHub-CKyN1yDa.js → AuditHub-DlVx-mPL.js} +1 -1
  22. package/dist/assets/{BoardChat-Dn5D5hbo.js → BoardChat-BWW2praB.js} +1 -1
  23. package/dist/assets/{BootstrapSetupUxLab-CDn9Qoy4.js → BootstrapSetupUxLab-C4zke6Cv.js} +1 -1
  24. package/dist/assets/{Browse-BQApRQGO.js → Browse-DLwvtbXu.js} +1 -1
  25. package/dist/assets/{BudgetPolicyCard-BAwZpX0_.js → BudgetPolicyCard-B6DX8U3d.js} +1 -1
  26. package/dist/assets/{CaseDetail-CPGVCggR.js → CaseDetail-dci6PiNM.js} +1 -1
  27. package/dist/assets/{Cases-CpluIjg7.js → Cases-DySeA3ym.js} +1 -1
  28. package/dist/assets/{ChatEndpointDetail-C15kjogV.js → ChatEndpointDetail-DYg7hB9_.js} +1 -1
  29. package/dist/assets/{ChatEndpointSetup-Czgls4T4.js → ChatEndpointSetup-D82OKj2o.js} +1 -1
  30. package/dist/assets/{ChoiceControls-Dd_bVqHH.js → ChoiceControls-BCF1vPaa.js} +1 -1
  31. package/dist/assets/{Companies-DK47FHh_.js → Companies-gUbW68nN.js} +1 -1
  32. package/dist/assets/{CompanyAccess-G_ygWCdy.js → CompanyAccess-C0cDvj8M.js} +1 -1
  33. package/dist/assets/{CompanyActivity-BzF5S-ak.js → CompanyActivity-CbIPKv4K.js} +1 -1
  34. package/dist/assets/{CompanyConnections-V6QokJbP.js → CompanyConnections-BezhEQiP.js} +1 -1
  35. package/dist/assets/{CompanyEnvironments-Dtsf3CLS.js → CompanyEnvironments-6-P8NN3Q.js} +1 -1
  36. package/dist/assets/{CompanyExport-CMPWrtnT.js → CompanyExport-UdhY3JMr.js} +1 -1
  37. package/dist/assets/{CompanyImport-1brk-ZPP.js → CompanyImport-Dj5G-Ci_.js} +1 -1
  38. package/dist/assets/{CompanySettings-DXs4duFl.js → CompanySettings-ifpz0tmL.js} +1 -1
  39. package/dist/assets/{CompanySettingsPluginPage-C2DZeyFu.js → CompanySettingsPluginPage-BCK7KaI1.js} +1 -1
  40. package/dist/assets/{CompanySkills-BE6s5mI1.js → CompanySkills-mzA6IM7-.js} +1 -1
  41. package/dist/assets/{ConfigureBuiltInAgentModal-7wvPpeNM.js → ConfigureBuiltInAgentModal-DsiGg71e.js} +1 -1
  42. package/dist/assets/{CopyableGatewayUrl-i8-LiYxQ.js → CopyableGatewayUrl-DwtHLPUd.js} +1 -1
  43. package/dist/assets/{Dashboard-CU-kG6C4.js → Dashboard-CHGehxNs.js} +1 -1
  44. package/dist/assets/{DecisionDateChips-BhvEmkt1.js → DecisionDateChips-Ce1EP_35.js} +1 -1
  45. package/dist/assets/{DecisionQueuePage-CBULv6cY.js → DecisionQueuePage-B55ERukD.js} +1 -1
  46. package/dist/assets/{DesignGuide-BwncU-wB.js → DesignGuide-CoW-4sZp.js} +1 -1
  47. package/dist/assets/{EmailEndpointSetup-BPf_8pC0.js → EmailEndpointSetup-Q4I-LgnZ.js} +1 -1
  48. package/dist/assets/{ExecutionWorkspaceDetail-CqvRHX5r.js → ExecutionWorkspaceDetail-_LuHtfta.js} +1 -1
  49. package/dist/assets/{GatewayDetail-Br82oQib.js → GatewayDetail-BKCHLhcu.js} +1 -1
  50. package/dist/assets/{GatewaysList-kBD3cwdU.js → GatewaysList-CZ-_zFD_.js} +1 -1
  51. package/dist/assets/{GoalDetail-BFeUPzal.js → GoalDetail-Bd04vnyA.js} +1 -1
  52. package/dist/assets/{GoalTree-CaQSt6o5.js → GoalTree-DtvAb581.js} +1 -1
  53. package/dist/assets/{Goals-CnYUdXEo.js → Goals-BXW_WXNa.js} +1 -1
  54. package/dist/assets/{ImageGalleryModal-QrZd2HrQ.js → ImageGalleryModal-xeIIyU7g.js} +1 -1
  55. package/dist/assets/{Inbox-C6bCCEH6.js → Inbox-DmxWV98u.js} +1 -1
  56. package/dist/assets/{InstanceAdvanced-CTjlJp69.js → InstanceAdvanced-DMrEvjyY.js} +1 -1
  57. package/dist/assets/{InviteLanding-C65R08_E.js → InviteLanding-C-S7p6JM.js} +1 -1
  58. package/dist/assets/{IssueChatLongThreadPerf-mdn5NFzU.js → IssueChatLongThreadPerf-BWbJprSQ.js} +1 -1
  59. package/dist/assets/{IssueChatThread-CZ9Q-xq-.js → IssueChatThread-DmAyIOuN.js} +1 -1
  60. package/dist/assets/{IssueDetail-svM2GGnk.js → IssueDetail-issXYSBj.js} +1 -1
  61. package/dist/assets/{IssueOutputSection-Du3C5TFv.js → IssueOutputSection-BioA9Nux.js} +1 -1
  62. package/dist/assets/{IssueRecoveryActionCard-Bq2QDhQA.js → IssueRecoveryActionCard-CGWmkRkb.js} +1 -1
  63. package/dist/assets/{IssueReferencePill-Cnjk1Ugc.js → IssueReferencePill-DWL74G_c.js} +1 -1
  64. package/dist/assets/{IssueThreadInteractionCard-CAzrNSjO.js → IssueThreadInteractionCard-bP4n_lcw.js} +1 -1
  65. package/dist/assets/{Issues-D97SDuYL.js → Issues-ButYwujh.js} +1 -1
  66. package/dist/assets/{LiveNowTodoLine-Cq1ub6Gj.js → LiveNowTodoLine-CiCmi71g.js} +1 -1
  67. package/dist/assets/{ManagedAiConnectionDetails-COyNN_aD.js → ManagedAiConnectionDetails-CgCv2fqy.js} +1 -1
  68. package/dist/assets/{McpConnect-CYsPUSYV.js → McpConnect-CeT7gUW_.js} +1 -1
  69. package/dist/assets/{MembershipAction-DYMy7umB.js → MembershipAction-BX9XIExA.js} +1 -1
  70. package/dist/assets/{ModelsAndProviders-BJaNzbhV.js → ModelsAndProviders-SEGB5DIt.js} +1 -1
  71. package/dist/assets/{NewAgent-DGXol110.js → NewAgent-LKqNzfsM.js} +1 -1
  72. package/dist/assets/{OmpAllSettings-BvYkLMhp.js → OmpAllSettings-1aXWEp6h.js} +1 -1
  73. package/dist/assets/{PipelineSettings-B6Am-LrO.js → PipelineSettings-UFCz50OY.js} +1 -1
  74. package/dist/assets/{Pipelines-MgjAhzew.js → Pipelines-n5EQOzN2.js} +1 -1
  75. package/dist/assets/{PixelsOffice-DnBnPerp.js → PixelsOffice-De61dU2s.js} +1 -1
  76. package/dist/assets/{PluginPage-C1XADFT2.js → PluginPage-CBSnEw7x.js} +1 -1
  77. package/dist/assets/{PluginSettings-CapWiXsO.js → PluginSettings-D2pNKDKr.js} +1 -1
  78. package/dist/assets/{ProfileDetailRoute-PJCQrW25.js → ProfileDetailRoute-DCbTvhPd.js} +1 -1
  79. package/dist/assets/{ProfileSettings-DXbA8GQP.js → ProfileSettings-BUYIctBS.js} +1 -1
  80. package/dist/assets/{ProfileWizardRoute-DaZPFglw.js → ProfileWizardRoute-o4Kf_DhP.js} +1 -1
  81. package/dist/assets/{ProjectDetail-DQxMbc1Q.js → ProjectDetail-DOF0t71W.js} +1 -1
  82. package/dist/assets/{ProjectWorkspaceDetail-dA3zVCbf.js → ProjectWorkspaceDetail-BEbFq9oK.js} +1 -1
  83. package/dist/assets/{ProjectWorkspacesContent-DnzUTFfW.js → ProjectWorkspacesContent-DwVqtur5.js} +1 -1
  84. package/dist/assets/{Projects-D3ZC8FJk.js → Projects-BsZYs3Fo.js} +1 -1
  85. package/dist/assets/{PublicIssueSharePage-BtWc4gq4.js → PublicIssueSharePage-8uOICn1V.js} +1 -1
  86. package/dist/assets/{ReviewQueueCard-C9YVH9hi.js → ReviewQueueCard-rQxgVMx_.js} +1 -1
  87. package/dist/assets/{RichWorkProductCard-CJPI3xQY.js → RichWorkProductCard-FcmQ5fHH.js} +1 -1
  88. package/dist/assets/{RoutineDetail-DUZXGXpv.js → RoutineDetail-DWqy00zc.js} +1 -1
  89. package/dist/assets/{RoutineRunVariablesDialog-CQJpihoC.js → RoutineRunVariablesDialog-DaGovqJt.js} +1 -1
  90. package/dist/assets/{Routines-CZMUFOH1.js → Routines-BE2PduWG.js} +1 -1
  91. package/dist/assets/{ScrollToBottom-wVHhI6vr.js → ScrollToBottom-DiemLpd4.js} +1 -1
  92. package/dist/assets/{Search-8efHT3Mn.js → Search-B_dblFtf.js} +1 -1
  93. package/dist/assets/{Secrets-BZCIDLKj.js → Secrets-D8ZlRoVo.js} +1 -1
  94. package/dist/assets/{SkillSourceTree-D31jixpq.js → SkillSourceTree-CDK_UwP7.js} +1 -1
  95. package/dist/assets/{SkillSources-Bn1LRP0O.js → SkillSources-C8inxmWw.js} +1 -1
  96. package/dist/assets/{SkillStudio-C4o17_hm.js → SkillStudio-8S7xrus7.js} +1 -1
  97. package/dist/assets/{SourceTrustBadge-C0F4cAmH.js → SourceTrustBadge-DTVyCj4T.js} +1 -1
  98. package/dist/assets/{StatusCards-BIvnBXBN.js → StatusCards-BpujcoJb.js} +1 -1
  99. package/dist/assets/{SummarySlotCard-Bpu8HBIR.js → SummarySlotCard-CTolnfbx.js} +1 -1
  100. package/dist/assets/{TaskChatLab-DAEcgWdy.js → TaskChatLab-BfJcSULz.js} +1 -1
  101. package/dist/assets/{TaskChatMarker-Bbn6iq01.js → TaskChatMarker-BYJIRrTg.js} +1 -1
  102. package/dist/assets/{TaskChatProtocolCard-wllJ9P2o.js → TaskChatProtocolCard-DTsBzh1L.js} +1 -1
  103. package/dist/assets/{TaskChatThreadView-Bnyakc3A.js → TaskChatThreadView-CBwEERny.js} +1 -1
  104. package/dist/assets/{TaskTreeControls-BFz5K7U-.js → TaskTreeControls-BzPeXKPq.js} +1 -1
  105. package/dist/assets/{Terminal-DGUlqBL9.js → Terminal-DGY0GEez.js} +1 -1
  106. package/dist/assets/{TerminalView-Cz01H-I5.js → TerminalView-CZkTSDKg.js} +1 -1
  107. package/dist/assets/{TrustPresetSection-lyB0V8c9.js → TrustPresetSection-DeIvlixJ.js} +1 -1
  108. package/dist/assets/{UserProfile-5qgIbXdf.js → UserProfile-BkcJ9Wfx.js} +1 -1
  109. package/dist/assets/{WhatNeedsMe-DjxO39CR.js → WhatNeedsMe-Bg72QkYe.js} +1 -1
  110. package/dist/assets/{Workspaces-BzTr5cqx.js → Workspaces-BeS2M4CD.js} +1 -1
  111. package/dist/assets/{connection-owner-EECE9Eiz.js → connection-owner-qWfs2q4d.js} +1 -1
  112. package/dist/assets/{index-DbENFODe.js → index-CSIXA5y5.js} +3 -3
  113. package/dist/assets/{issue-properties-BmOIUOmd.js → issue-properties-D3qASSPI.js} +1 -1
  114. package/dist/assets/{issue-workspace-selection-CIvSmFv2.js → issue-workspace-selection-sfcpgxzV.js} +1 -1
  115. package/dist/assets/{pipeline-stage-presentation-DoJvVCJ3.js → pipeline-stage-presentation-C9WooPFB.js} +1 -1
  116. package/dist/assets/{shared-BMQlB2gM.js → shared-57amdu2f.js} +1 -1
  117. package/dist/assets/{transcript-adapter-DDVisW9K.js → transcript-adapter-D7nXUOr3.js} +1 -1
  118. package/dist/assets/{useSummaryDraftStream-BNKrqAT0.js → useSummaryDraftStream-1H3w75Dm.js} +1 -1
  119. package/dist/index.html +1 -1
  120. package/dist/sw.js +1 -1
  121. package/package.json +1 -1
@@ -1 +1 @@
1
- var Nt=Object.defineProperty;var s=(t,r)=>Nt(t,"name",{value:r,configurable:!0});import{i as tt}from"./rolldown-runtime-ZpX3ckPj.js";import{l as R,na as St,t as st,ta as Ct}from"./createLucideIcon-B-uEJvX6.js";import{a as wt,n as At}from"./star-BXywPGTx.js";import{X as nt,_ as U,t as Ve,v as pe}from"./queryKeys-yuC-YxZI.js";import{a as z,i as Et,n as K,r as V,t as Ht}from"./TerminalView-Cz01H-I5.js";import{n as Mt}from"./CompanyContext-DDgccGSs.js";import{t as Kt}from"./router-2HX_SyKK.js";import{n as Tt,r as zt,t as Pt}from"./collapsible-DfIkfd0G.js";import{t as _t}from"./label-CPQI5V7i.js";import{t as $t}from"./check-DtcbYVEc.js";import{t as Ft}from"./chevron-down-B_rMrTLq.js";import{t as Lt}from"./circle-x-BjJ9dhyd.js";import{t as Ot}from"./cloud-B-O92Qvh.js";import{t as Rt}from"./copy-B55HyIrd.js";import{t as We}from"./key-round-B3uXhHZr.js";import{r as de,t as g}from"./button-D3bYvq4T.js";import{t as at}from"./plus-BbX1VFl1.js";import{t as ee}from"./server-DnJLt7Tc.js";import{t as Dt}from"./shield-question-mark-m0tt6hs2.js";import{t as Bt}from"./triangle-alert-Cpo2fj-L.js";import{t as qt}from"./x-hMw21ejo.js";import{a as it,i as Qt,n as rt,r as ot,s as lt,t as ct}from"./dialog-DlsqN-fP.js";import{t as Q}from"./input-It0utqV7.js";import{t as Jt}from"./access-RvWIoVKp.js";import{n as Zt}from"./BreadcrumbContext-_dNLeVnD.js";import{a as Ut,i as Ce,o as Te,r as Vt,s as Wt,t as Xt}from"./command-D25L6P6V.js";import{t as Yt}from"./textarea-9ySinQRQ.js";import{t as Xe}from"./select-DKYWrP8G.js";import{t as Gt}from"./environments-DNM7-n7c.js";import{t as It}from"./use-copy-action-DTcJkzd7.js";import{Ba as es,Jt as ts,Na as Fe,Yt as ss}from"./index-DbENFODe.js";import{n as ns,r as as,t as is}from"./resizable-panels-Cfyr3j78.js";var dt={name:"arrow-right-left",size:24,node:[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]};dt.node;var rs=st(dt),ut={name:"columns-2",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],aliases:["columns"]};ut.node;var os=st(ut),u=tt(St(),1),mt=5;function ht(t){return`wardmote:terminal-ssh-recent:v1:${t}`}s(ht,"recentKey");function Re(t){return`wardmote:terminal-ssh-tests:v1:${t}`}s(Re,"testsKey");function xt(t){try{return JSON.parse(window.localStorage.getItem(t)??"null")}catch{return null}}s(xt,"read");function De(t,r){try{window.localStorage.setItem(t,JSON.stringify(r))}catch{return}}s(De,"write");function pt(t){const r=xt(ht(t));return Array.isArray(r)?r.filter(l=>typeof l=="string").slice(0,mt):[]}s(pt,"recentSshTargets");function ls(t,r){const l=[r,...pt(t).filter(i=>i!==r)].slice(0,mt);return De(ht(t),l),l}s(ls,"rememberSshTarget");function ge(t){const r=xt(Re(t));return!r||typeof r!="object"||Array.isArray(r)?{}:Object.fromEntries(Object.entries(r).filter(l=>typeof l[1]?.status=="string"&&typeof l[1]?.at=="string"))}s(ge,"rememberedTests");function cs(t,r,l,i=new Date){De(Re(t),{...ge(t),[r]:{status:l,at:i.toISOString()}})}s(cs,"rememberTest");function Ye(t,r){const{[r]:l,...i}=ge(t);De(Re(t),i)}s(Ye,"forgetTest");var e=tt(Ct(),1),ds=/^[A-Za-z0-9_][A-Za-z0-9._-]{0,62}$/,us=/^(?:[A-Za-z0-9_](?:[A-Za-z0-9_-]{0,61}[A-Za-z0-9_])?)(?:\.[A-Za-z0-9_](?:[A-Za-z0-9_-]{0,61}[A-Za-z0-9_])?)*$/,ms=/^(?=.*:)[0-9A-Fa-f:.]{2,45}$/,hs=/^[A-Za-z0-9_][A-Za-z0-9._-]{0,63}$/,xs=/^[A-Za-z0-9_][A-Za-z0-9._-]{0,63}$/,ze="Use letters, digits, dots, dashes or underscores.";function Le(t){return t.trim().replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^[^A-Za-z0-9_]+/,"").slice(0,63)||"host"}s(Le,"aliasFromName");function Ge(t){const r=t.destination.lastIndexOf("@");return{alias:Le(t.name),hostName:r>=0?t.destination.slice(r+1):t.destination,user:r>=0?t.destination.slice(0,r):null,port:t.port,identityFile:null,proxyJump:null,serverAliveInterval:null,serverAliveCountMax:null}}s(Ge,"settingsFromSavedHost");function Pe(t,r,l){const i=t.trim();if(!i)return null;if(!/^[0-9]+$/.test(i))return;const m=Number(i);return m>=r&&m<=l?m:void 0}s(Pe,"wholeNumber");function ps({text:t,label:r}){const{status:l,copy:i}=It(2e3);return(0,e.jsxs)(g,{type:"button",variant:"secondary",size:"xs",onClick:s(()=>{i(t)},"onClick"),children:[l==="copied"?(0,e.jsx)($t,{"aria-hidden":!0}):(0,e.jsx)(Rt,{"aria-hidden":!0}),(0,e.jsx)("span",{"aria-live":"polite",children:l==="copied"?"Copied":l==="failed"?"Copy failed":r})]})}s(ps,"CopyButton");function $({id:t,label:r,hint:l,error:i,children:m,className:v}){return(0,e.jsxs)("div",{className:R("flex min-w-0 flex-col gap-1.5",v),children:[(0,e.jsx)(_t,{htmlFor:t,children:r}),m,i?(0,e.jsx)("p",{id:`${t}-error`,className:"text-xs text-bad",children:i}):l?(0,e.jsx)("p",{id:`${t}-hint`,className:"text-xs text-ink-3",children:l}):null]})}s($,"Field");function fs({keyInfo:t,highlight:r}){return t.publicKey?(0,e.jsxs)("div",{className:R("flex flex-col gap-2 rounded-md border p-3",r?"border-accent/40 bg-accent/5":"border-line bg-bg-2"),children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,e.jsx)("p",{className:"text-xs font-medium text-ink",children:r?"Add this public key to ~/.ssh/authorized_keys on the server":"Public key"}),(0,e.jsx)(ps,{text:t.publicKey,label:"Copy public key"})]}),(0,e.jsx)("code",{className:"block max-h-(--sz-64) overflow-auto break-all rounded-sm bg-bg px-2 py-1.5 font-mono text-xs text-ink-2",children:t.publicKey})]}):(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"No public key file next to this key, so it cannot be shown."})}s(fs,"PublicKeyBox");function gs({result:t,trusting:r,onTrust:l}){const i=t.status==="ok",m=t.status==="host_key_unknown",v=i?wt:m?Dt:Lt;return(0,e.jsxs)("div",{className:R("flex flex-col gap-2 rounded-md border p-3 text-sm",i?"border-ok/40 bg-ok-soft":m?"border-warn/40 bg-warn-soft":"border-bad/40 bg-bad-soft"),"data-testid":"ssh-test-result",children:[(0,e.jsxs)("p",{className:"flex items-start gap-2 text-ink",children:[(0,e.jsx)(v,{className:R("mt-0.5 size-4 shrink-0",i?"text-ok":m?"text-warn":"text-bad"),"aria-hidden":!0}),(0,e.jsx)("span",{children:t.message})]}),m&&t.hostKeys.length>0?(0,e.jsxs)("div",{className:"flex flex-col gap-2 pl-6",children:[(0,e.jsx)("ul",{className:"flex flex-col gap-1",children:t.hostKeys.map(b=>(0,e.jsxs)("li",{className:"break-all font-mono text-xs text-ink-2",children:[b.type," ",b.fingerprint]},b.fingerprint))}),(0,e.jsxs)("p",{className:"text-xs text-ink-3",children:["Compare it with ",(0,e.jsx)("code",{className:"font-mono",children:"ssh-keygen -lf /etc/ssh/ssh_host_*_key.pub"})," on the server."]}),(0,e.jsx)("div",{children:(0,e.jsxs)(g,{type:"button",size:"xs",onClick:l,disabled:r,children:[r?(0,e.jsx)(de,{className:"animate-spin motion-reduce:animate-none","aria-hidden":!0}):null,"Trust this host and test again"]})})]}):null,t.detail?(0,e.jsxs)("details",{className:"pl-6 text-xs text-ink-3",children:[(0,e.jsx)("summary",{className:"cursor-pointer select-none",children:"ssh output"}),(0,e.jsx)("pre",{className:"mt-1 whitespace-pre-wrap break-all font-mono",children:t.detail})]}):null]})}s(gs,"TestResult");function vs({companyId:t,open:r,onOpenChange:l,mode:i,configHosts:m,onSaved:v,onRemoved:b}){const w=nt(),P=(0,u.useId)(),h=i.kind==="add"?null:i.settings,[N,ue]=(0,u.useState)(h?.alias??""),[y,D]=(0,u.useState)(h?.hostName??""),[C,F]=(0,u.useState)(h?.user??""),[_,W]=(0,u.useState)(h?.port===null||h?.port===void 0?"":String(h.port)),[j,X]=(0,u.useState)(i.kind==="add"||h?.identityFile?"existing":"default"),[A,E]=(0,u.useState)(h?.identityFile??""),[J,o]=(0,u.useState)(null),[M,T]=(0,u.useState)(""),[B,be]=(0,u.useState)(null),[Ae,te]=(0,u.useState)(null),[se,ne]=(0,u.useState)(h?.proxyJump??""),[Y,me]=(0,u.useState)(h?.serverAliveInterval===null||h?.serverAliveInterval===void 0?"":String(h.serverAliveInterval)),[ae,Ee]=(0,u.useState)(h?.serverAliveCountMax===null||h?.serverAliveCountMax===void 0?"":String(h.serverAliveCountMax)),[ie,ye]=(0,u.useState)(!!(h?.proxyJump||h?.serverAliveInterval||h?.serverAliveCountMax)),[Z,re]=(0,u.useState)(!1),[G,he]=(0,u.useState)(null),[je,L]=(0,u.useState)(null),[oe,He]=(0,u.useState)(!1),ke=(0,u.useRef)(null);(0,u.useEffect)(()=>{G&&ke.current?.scrollIntoView({block:"nearest"})},[G]);const I=pe({queryKey:V.sshKeys(t),queryFn:s(()=>K.listKeys(t),"queryFn"),enabled:r}),O=I.data?.keys??[],n=O.find(a=>a.path===A)??null,d=`wardmote_${Le(N||"host")}`,c=(j==="paste"?B:J)??d,p=new Set(m.filter(a=>!(i.kind==="edit"&&a.name===i.settings.alias)).map(a=>a.name.toLowerCase())),f=N.trim(),q=y.trim(),Be=Pe(_,1,65535),qe=Pe(Y,0,86400),Qe=Pe(ae,1,1e3),S={alias:f?ds.test(f)?p.has(f.toLowerCase())?"A host with this name already exists.":null:ze:"Enter a name, for example prod-web.",hostName:q?us.test(q)||ms.test(q)?null:"Enter a host name like example.com or an IP address.":"Enter the server's host name or IP address.",user:C.trim()&&!hs.test(C.trim())?ze:null,port:Be===void 0?"Port must be a number from 1 to 65535.":null,key:j==="existing"&&!A?"Pick a key, or choose another option.":j==="generate"||j==="paste"?"Create or save the key first.":null,keyName:!xs.test(c)||c.endsWith(".pub")?ze:null,keepAlive:qe===void 0?"Use whole seconds from 0 to 86400.":null,countMax:Qe===void 0?"Use a whole number from 1 to 1000.":null},Je=!!(S.alias||S.hostName||S.user||S.port||S.key||S.keepAlive||S.countMax),H=s((a,k)=>Z||k.trim()?S[a]:null,"show"),Me=s(()=>({alias:f,hostName:q,user:C.trim()||null,port:Be??null,identityFile:j==="existing"&&A?A:null,proxyJump:se||null,serverAliveInterval:qe??null,serverAliveCountMax:Qe??null}),"settings"),vt=s(()=>w.invalidateQueries({queryKey:V.sshKeys(t)}),"refreshKeys"),le=U({mutationFn:s(a=>K.createKey(t,a),"mutationFn"),onSuccess:s(async a=>{L(null),T(""),te(a.path),w.setQueryData(V.sshKeys(t),k=>k&&{...k,keys:[...k.keys.filter(kt=>kt.path!==a.path),a]}),E(a.path),X("existing"),await vt()},"onSuccess"),onError:s(a=>L(z(a,"The key could not be saved.")),"onError")}),ce=U({mutationFn:s(a=>K.testConnection(t,{host:a}),"mutationFn"),onSuccess:s((a,k)=>{L(null),he(a),cs(t,k.alias,a.status)},"onSuccess"),onError:s(a=>L(z(a,"The connection test could not run.")),"onError")}),Ke=U({mutationFn:s(async a=>(await K.trustHostKey(t,{target:{host:a},fingerprints:(G?.hostKeys??[]).map(k=>k.fingerprint)}),a),"mutationFn"),onSuccess:s(a=>ce.mutate(a),"onSuccess"),onError:s(a=>L(z(a,"The host key could not be trusted.")),"onError")}),Ne=U({mutationFn:s(async a=>(i.kind==="edit"?await K.updateConfigHost(t,i.settings.alias,a.settings):i.kind==="move"?await K.moveSshHostToConfig(t,i.saved.id,a.settings):await K.addConfigHost(t,a.settings),a),"mutationFn"),onSuccess:s(async a=>{L(null),i.kind==="edit"&&i.settings.alias!==a.settings.alias&&Ye(t,i.settings.alias),await w.invalidateQueries({queryKey:V.sshHosts(t)}),v(a.settings,a.openTerminal)},"onSuccess"),onError:s(a=>L(z(a,"The host could not be saved.")),"onError")}),Ze=U({mutationFn:s(a=>K.removeConfigHost(t,a),"mutationFn"),onSuccess:s(async(a,k)=>{Ye(t,k),await w.invalidateQueries({queryKey:V.sshHosts(t)}),b?.(k)},"onSuccess"),onError:s(a=>L(z(a,"The host could not be removed.")),"onError")}),Ue=s(a=>{re(!0),!Je&&Ne.mutate({settings:Me(),openTerminal:a})},"submit"),bt=s(()=>{re(!0),!Je&&(he(null),ce.mutate(Me()))},"runTest"),xe=Ne.isPending||Ze.isPending,yt=i.kind==="edit"?`Edit ${i.settings.alias}`:i.kind==="move"?`Move ${i.saved.name} to ssh config`:"Add SSH host",jt=m.filter(a=>a.name!==f&&(i.kind!=="edit"||a.name!==i.settings.alias)),x=s(a=>`${P}-${a}`,"fieldId"),Se=s((a,k)=>k?`${x(a)}-error`:void 0,"describedBy");return(0,e.jsx)(ct,{open:r,onOpenChange:l,children:(0,e.jsxs)(rt,{className:"max-h-(--sz-85vh) gap-0 overflow-y-auto p-0 sm:max-w-2xl","data-testid":"ssh-host-form",children:[(0,e.jsxs)(it,{className:"border-b border-line px-5 pt-5 pb-4 text-left",children:[(0,e.jsx)(lt,{children:yt}),(0,e.jsxs)(ot,{children:["Saved to ~/.ssh/config on the Wardmote server. Agents that run on this server can then use"," ",(0,e.jsxs)("code",{className:"font-mono text-ink-2",children:["ssh ",f||"<name>"]}),". Agents in a sandbox or on an SSH environment run elsewhere and do not see it."]})]}),(0,e.jsxs)("form",{className:"flex flex-col gap-5 px-5 py-4",onSubmit:s(a=>{a.preventDefault(),Ue(i.kind!=="edit")},"onSubmit"),noValidate:!0,children:[(0,e.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,e.jsx)($,{id:x("alias"),label:"Name",hint:(0,e.jsxs)(e.Fragment,{children:["Used as ",(0,e.jsx)("code",{className:"font-mono",children:"ssh name"}),"."]}),error:H("alias",N),children:(0,e.jsx)(Q,{id:x("alias"),value:N,onChange:s(a=>ue(a.target.value),"onChange"),placeholder:"prod-web",autoComplete:"off",spellCheck:!1,autoFocus:!0,"aria-invalid":!!H("alias",N),"aria-describedby":Se("alias",H("alias",N))})}),(0,e.jsx)($,{id:x("host"),label:"Host or IP address",error:H("hostName",y),children:(0,e.jsx)(Q,{id:x("host"),value:y,onChange:s(a=>D(a.target.value),"onChange"),placeholder:"203.0.113.10",autoComplete:"off",spellCheck:!1,inputMode:"url","aria-invalid":!!H("hostName",y),"aria-describedby":Se("host",H("hostName",y))})}),(0,e.jsx)($,{id:x("user"),label:"User",hint:"Leave empty to use your local user name.",error:H("user",C),children:(0,e.jsx)(Q,{id:x("user"),value:C,onChange:s(a=>F(a.target.value),"onChange"),placeholder:"root",autoComplete:"off",spellCheck:!1,"aria-invalid":!!H("user",C),"aria-describedby":Se("user",H("user",C))})}),(0,e.jsx)($,{id:x("port"),label:"Port",hint:"Leave empty for 22.",error:H("port",_),children:(0,e.jsx)(Q,{id:x("port"),value:_,onChange:s(a=>W(a.target.value),"onChange"),placeholder:"22",inputMode:"numeric",autoComplete:"off","aria-invalid":!!H("port",_),"aria-describedby":Se("port",H("port",_))})})]}),(0,e.jsxs)("fieldset",{className:"flex min-w-0 flex-col gap-3",children:[(0,e.jsxs)("legend",{className:"mb-2 flex items-center gap-2 text-sm font-medium text-ink",children:[(0,e.jsx)(We,{className:"size-4 text-ink-3","aria-hidden":!0}),"Key"]}),(0,e.jsx)(ts,{"aria-label":"How to sign in",className:"grid w-full grid-cols-2 sm:flex sm:w-fit",children:[["existing","Key in ~/.ssh"],["generate","Create new key"],["paste","Paste a key"],["default","ssh defaults"]].map(([a,k])=>(0,e.jsx)(ss,{selected:j===a,onClick:s(()=>X(a),"onClick"),children:k},a))}),j==="existing"?(0,e.jsxs)("div",{className:"flex flex-col gap-2",children:[I.isLoading?(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Loading keys…"}):I.isError?(0,e.jsx)("p",{className:"text-sm text-bad",children:z(I.error,"Keys could not be listed.")}):O.length===0?(0,e.jsxs)("p",{className:"text-sm text-ink-3",children:["No private keys in ~/.ssh yet."," ",(0,e.jsx)(g,{type:"button",variant:"link",size:"xs",className:"h-auto px-0",onClick:s(()=>X("generate"),"onClick"),children:"Create one"})]}):(0,e.jsx)($,{id:x("key"),label:"Key file",error:Z?S.key:null,children:(0,e.jsxs)(Xe,{id:x("key"),value:A,onChange:s(a=>{E(a.target.value),te(null)},"onChange"),"aria-invalid":!!(Z&&S.key),children:[(0,e.jsx)("option",{value:"",children:"Choose a key…"}),O.map(a=>(0,e.jsxs)("option",{value:a.path,children:[a.name,a.type?` · ${a.type.replace(/^ssh-/,"")}`:"",a.fingerprint?` · ${a.fingerprint.slice(7,19)}…`:"",a.encrypted?" · passphrase":""]},a.path))]})}),n?(0,e.jsxs)(e.Fragment,{children:[n.fingerprint?(0,e.jsx)("p",{className:"break-all font-mono text-xs text-ink-3",children:n.fingerprint}):null,n.encrypted?(0,e.jsxs)("p",{className:"flex items-start gap-2 rounded-md bg-warn-soft p-2 text-xs text-ink",children:[(0,e.jsx)(Bt,{className:"mt-0.5 size-3.5 shrink-0 text-warn","aria-hidden":!0}),"This key has a passphrase. Agents can only use it while ssh-agent on the server holds it unlocked."]}):null,(0,e.jsx)(fs,{keyInfo:n,highlight:Ae===n.path})]}):null]}):null,j==="generate"?(0,e.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end",children:[(0,e.jsx)($,{id:x("new-key"),label:"New key file name",error:S.keyName,className:"flex-1",children:(0,e.jsx)(Q,{id:x("new-key"),value:c,onChange:s(a=>o(a.target.value),"onChange"),autoComplete:"off",spellCheck:!1})}),(0,e.jsxs)(g,{type:"button",variant:"secondary",disabled:le.isPending||!!S.keyName,onClick:s(()=>le.mutate({mode:"generate",name:c,comment:`${Le(N||"host")}@wardmote`}),"onClick"),children:[le.isPending?(0,e.jsx)(de,{className:"animate-spin motion-reduce:animate-none","aria-hidden":!0}):(0,e.jsx)(We,{"aria-hidden":!0}),"Create ed25519 key"]})]}):null,j==="paste"?(0,e.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,e.jsx)($,{id:x("paste-name"),label:"Save as",error:S.keyName,children:(0,e.jsx)(Q,{id:x("paste-name"),value:c,onChange:s(a=>be(a.target.value),"onChange"),autoComplete:"off",spellCheck:!1})}),(0,e.jsx)($,{id:x("paste-key"),label:"Private key",hint:"Stored as ~/.ssh/<name> with mode 600. Wardmote never shows it again.",children:(0,e.jsx)(Yt,{id:x("paste-key"),value:M,onChange:s(a=>T(a.target.value),"onChange"),placeholder:"-----BEGIN OPENSSH PRIVATE KEY-----",className:"min-h-32 font-mono text-xs md:text-xs",autoComplete:"off",spellCheck:!1})}),(0,e.jsx)("div",{children:(0,e.jsxs)(g,{type:"button",variant:"secondary",disabled:le.isPending||!M.trim()||!!S.keyName,onClick:s(()=>le.mutate({mode:"import",name:c,privateKey:M}),"onClick"),children:[le.isPending?(0,e.jsx)(de,{className:"animate-spin motion-reduce:animate-none","aria-hidden":!0}):null,"Save key"]})})]}):null,j==="default"?(0,e.jsxs)("p",{className:"text-sm text-ink-3",children:["ssh tries the server's default keys and ssh-agent, as a plain ",(0,e.jsx)("code",{className:"font-mono",children:"ssh"})," would."]}):null,Z&&S.key&&!(j==="existing"&&O.length>0)?(0,e.jsx)("p",{className:"text-xs text-bad",children:S.key}):null]}),(0,e.jsxs)(Pt,{open:ie,onOpenChange:ye,children:[(0,e.jsx)(zt,{asChild:!0,children:(0,e.jsxs)(g,{type:"button",variant:"ghost",size:"sm",className:"-ml-2 w-fit text-ink-2",children:[(0,e.jsx)(Ft,{className:R("transition-transform motion-reduce:transition-none",ie&&"rotate-180"),"aria-hidden":!0}),"More options"]})}),(0,e.jsxs)(Tt,{className:"grid gap-4 pt-3 sm:grid-cols-3",children:[(0,e.jsx)($,{id:x("jump"),label:"Connect via",hint:"Reach this host through another host (ProxyJump).",children:(0,e.jsxs)(Xe,{id:x("jump"),value:se,onChange:s(a=>ne(a.target.value),"onChange"),children:[(0,e.jsx)("option",{value:"",children:"Direct"}),jt.map(a=>(0,e.jsx)("option",{value:a.name,children:a.name},a.id))]})}),(0,e.jsx)($,{id:x("keepalive"),label:"Keep-alive (seconds)",hint:"Ping the server so idle sessions stay open.",error:H("keepAlive",Y),children:(0,e.jsx)(Q,{id:x("keepalive"),value:Y,onChange:s(a=>me(a.target.value),"onChange"),placeholder:"30",inputMode:"numeric",autoComplete:"off"})}),(0,e.jsx)($,{id:x("countmax"),label:"Missed pings before giving up",error:H("countMax",ae),children:(0,e.jsx)(Q,{id:x("countmax"),value:ae,onChange:s(a=>Ee(a.target.value),"onChange"),placeholder:"3",inputMode:"numeric",autoComplete:"off"})})]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-3 border-t border-line pt-4",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,e.jsxs)(g,{type:"button",variant:"secondary",onClick:bt,disabled:ce.isPending||Ke.isPending,children:[ce.isPending?(0,e.jsx)(de,{className:"animate-spin motion-reduce:animate-none","aria-hidden":!0}):null,ce.isPending?"Testing…":"Test connection"]}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Runs ssh from the server in batch mode. Nothing is saved."})]}),(0,e.jsx)("div",{"aria-live":"polite",ref:ke,className:"scroll-mb-4",children:G?(0,e.jsx)(gs,{result:G,trusting:Ke.isPending||ce.isPending,onTrust:s(()=>Ke.mutate(Me()),"onTrust")}):null})]}),je?(0,e.jsx)("p",{className:"rounded-md border border-bad/30 bg-bad/5 px-3 py-2 text-sm text-bad",role:"alert",children:je}):null,(0,e.jsxs)(Qt,{className:"gap-2 sm:items-center sm:justify-between",children:[(0,e.jsx)("div",{className:"flex",children:i.kind==="edit"?(0,e.jsx)(g,{type:"button",variant:oe?"delete":"danger",size:"sm",disabled:xe,onClick:s(()=>oe?Ze.mutate(i.settings.alias):He(!0),"onClick"),children:oe?"Click again to remove":"Remove host"}):null}),(0,e.jsxs)("div",{className:"flex flex-col-reverse gap-2 sm:flex-row",children:[(0,e.jsx)(g,{type:"button",variant:"ghost",onClick:s(()=>l(!1),"onClick"),disabled:xe,children:"Cancel"}),i.kind==="edit"?(0,e.jsxs)(g,{type:"submit",disabled:xe,children:[Ne.isPending?(0,e.jsx)(de,{className:"animate-spin motion-reduce:animate-none","aria-hidden":!0}):null,"Save changes"]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(g,{type:"button",variant:"secondary",disabled:xe,onClick:s(()=>Ue(!1),"onClick"),children:"Save"}),(0,e.jsxs)(g,{type:"submit",disabled:xe,children:[Ne.isPending?(0,e.jsx)(de,{className:"animate-spin motion-reduce:animate-none","aria-hidden":!0}):null,"Save and connect"]})]})]})]})]})]})})}s(vs,"SshHostForm");function ve(t){return`host:${t.id}`}s(ve,"hostTargetKey");function we(t){return`env:${t.id}`}s(we,"environmentTargetKey");var bs={ok:{label:"Connected",tone:"bg-ok"},host_key_unknown:{label:"Host not trusted yet",tone:"bg-warn"}};function ys({test:t}){if(!t)return null;const r=bs[t.status]??{label:"Last test failed",tone:"bg-bad"},l=new Date(t.at),i=`${r.label} · tested ${Number.isNaN(l.getTime())?"":l.toLocaleString()}`;return(0,e.jsxs)("span",{className:"flex shrink-0 items-center gap-1 text-xs text-ink-3",title:i,children:[(0,e.jsx)("span",{className:R("size-2 rounded-full",r.tone),"aria-hidden":!0}),(0,e.jsx)("span",{className:"sr-only sm:not-sr-only",children:r.label})]})}s(ys,"TestDot");function _e({icon:t,name:r,detail:l,badge:i,trailing:m,mono:v=!0}){return(0,e.jsxs)(e.Fragment,{children:[t,(0,e.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,e.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,e.jsx)("span",{className:"truncate font-medium text-ink",children:r}),i?(0,e.jsx)("span",{className:"shrink-0 rounded-sm border border-line px-1 text-xs text-ink-3",children:i}):null]}),l?(0,e.jsx)("span",{className:R("truncate text-xs text-ink-3",v&&"font-mono"),children:l}):null]}),m]})}s(_e,"HostRow");function Ie(t){return t.port===null?t.destination:`${t.destination}:${t.port}`}s(Ie,"hostDetail");function js(t){const{open:r,onOpenChange:l,localAllowed:i,hosts:m,hostsLoading:v,hostsError:b,configError:w,environments:P,environmentsLoading:h,recent:N,tests:ue,busy:y}=t,D=(0,u.useRef)(null),C=m.filter(o=>o.source==="config"),F=m.filter(o=>o.source==="saved"),_=new Map;for(const o of C)_.set(ve(o),{kind:"host",host:o});for(const o of P)_.set(we(o),{kind:"env",environment:o});const W=N.map(o=>({key:o,entry:_.get(o)})).filter(o=>o.entry!==void 0),j=new Set(W.map(o=>o.key)),X=!v&&!h&&C.length===0&&P.length===0&&F.length===0,A=s(o=>{o.key!=="/"||o.target===D.current||(o.preventDefault(),D.current?.focus())},"onKeyDown"),E=s((o,M)=>{const T=!!(o.managed&&o.settings);return(0,e.jsx)(Te,{value:`${M}${o.id}`,keywords:[o.name,o.destination],disabled:y,onSelect:s(()=>t.onOpenHost(o),"onSelect"),className:"min-h-12 gap-3",children:(0,e.jsx)(_e,{icon:(0,e.jsx)(ee,{"aria-hidden":!0}),name:o.name,detail:Ie(o),badge:o.managed?T?null:"edited by hand":"~/.ssh/config",trailing:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(ys,{test:ue[o.name]}),T?(0,e.jsx)(g,{type:"button",variant:"ghost",size:"icon-xs","aria-label":`Edit ${o.name}`,title:"Edit",onClick:s(B=>{B.stopPropagation(),t.onEditHost(o)},"onClick"),children:(0,e.jsx)(es,{"aria-hidden":!0})}):null]})})},`${M}${o.id}`)},"configHostItem"),J=s((o,M)=>(0,e.jsx)(Te,{value:`${M}${o.id}`,keywords:[o.name,"environment"],disabled:y,onSelect:s(()=>t.onOpenEnvironment(o),"onSelect"),className:"min-h-12 gap-3",children:(0,e.jsx)(_e,{icon:(0,e.jsx)(Ot,{"aria-hidden":!0}),name:o.name,detail:"SSH environment",mono:!1})},`${M}${o.id}`),"environmentItem");return(0,e.jsx)(ct,{open:r,onOpenChange:l,children:(0,e.jsxs)(rt,{className:"gap-0 overflow-hidden p-0 sm:max-w-xl",onKeyDown:A,children:[(0,e.jsxs)(it,{className:"border-b border-line px-4 pt-4 pb-3 text-left",children:[(0,e.jsx)(lt,{children:"Open an SSH terminal"}),(0,e.jsx)(ot,{children:i?"Pick a host from the server's ~/.ssh/config or an SSH environment.":"Pick an SSH environment. Hosts in the server's ~/.ssh/config are for instance admins."})]}),(0,e.jsxs)(Xt,{loop:!0,className:"rounded-none bg-bg",children:[(0,e.jsx)(Ut,{ref:D,placeholder:"Search hosts… (press / to search)","aria-label":"Search hosts"}),(0,e.jsxs)(Wt,{className:"max-h-(--sz-70vh) min-h-(--sz-64)","aria-busy":v||h,children:[v||h?(0,e.jsx)("p",{className:"px-4 py-3 text-sm text-ink-3",children:"Loading hosts…"}):null,b?(0,e.jsx)("p",{className:"px-4 py-3 text-sm text-bad",role:"alert",children:b}):null,w?(0,e.jsx)("p",{className:"px-4 py-2 text-xs text-ink-3",children:w}):null,X?(0,e.jsxs)("div",{className:"flex flex-col items-center gap-2 px-6 py-8 text-center",children:[(0,e.jsx)(ee,{className:"size-6 text-ink-3","aria-hidden":!0}),(0,e.jsx)("p",{className:"text-sm font-medium text-ink",children:"No SSH hosts yet"}),(0,e.jsx)("p",{className:"max-w-sm text-sm text-ink-3",children:i?"Add a host once and it lands in ~/.ssh/config, ready for this terminal and for agents on this server.":"Ask an instance admin to add an SSH environment you can use."})]}):(0,e.jsx)(Vt,{children:(0,e.jsx)("span",{className:"text-ink-3",children:"No host matches your search."})}),W.length>0?(0,e.jsx)(Ce,{heading:"Recent",children:W.map(({entry:o})=>o.kind==="host"?E(o.host,"recent-"):J(o.environment,"recent-"))}):null,C.some(o=>!j.has(ve(o)))?(0,e.jsx)(Ce,{heading:"SSH hosts",children:C.filter(o=>!j.has(ve(o))).map(o=>E(o,""))}):null,P.some(o=>!j.has(we(o)))?(0,e.jsx)(Ce,{heading:"Environments",children:P.filter(o=>!j.has(we(o))).map(o=>J(o,""))}):null,F.length>0?(0,e.jsxs)(Ce,{heading:"Saved in Wardmote only (not visible to agents)",children:[F.map(o=>(0,e.jsx)(Te,{value:o.id,keywords:[o.name,o.destination],disabled:y,onSelect:s(()=>t.onOpenHost(o),"onSelect"),className:"min-h-12 gap-3",children:(0,e.jsx)(_e,{icon:(0,e.jsx)(ee,{"aria-hidden":!0}),name:o.name,detail:Ie(o),trailing:(0,e.jsxs)(g,{type:"button",variant:"secondary",size:"xs",onClick:s(M=>{M.stopPropagation(),t.onMoveSaved(o)},"onClick"),children:[(0,e.jsx)(rs,{"aria-hidden":!0}),"Move to ssh config"]})})},o.id)),F.length>1?(0,e.jsx)("div",{className:"flex justify-end px-2 pb-1",children:(0,e.jsxs)(g,{type:"button",variant:"link",size:"xs",disabled:y,onClick:t.onMoveAllSaved,children:["Move all ",F.length," to ssh config"]})}):null]}):null]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-2 border-t border-line px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,e.jsx)("p",{className:"text-xs text-ink-3",children:i?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(Kt,{to:"/company/settings/instance/environments",className:"text-ink-2 underline underline-offset-2 hover:text-ink",children:"SSH environments"})," ","connect with a key stored in Wardmote."]}):"Only instance admins can add hosts."}),i?(0,e.jsxs)(g,{type:"button",size:"sm",onClick:t.onAddHost,disabled:y,children:[(0,e.jsx)(at,{"aria-hidden":!0}),"Add host"]}):null]})]})})}s(js,"SshHostPicker");function et({icon:t,title:r,description:l,note:i,disabled:m,onClick:v,testId:b}){return(0,e.jsxs)("button",{type:"button",onClick:v,disabled:m,"aria-describedby":i?`${b}-note`:void 0,"data-testid":b,className:R("group flex min-h-36 flex-col items-start gap-3 rounded-lg border border-line bg-bg-2 p-5 text-left transition-colors motion-reduce:transition-none","outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",m?"cursor-not-allowed opacity-70":"hover:border-line-strong hover:bg-bg-3"),children:[(0,e.jsx)("span",{className:"flex size-10 items-center justify-center rounded-md border border-line bg-bg text-ink-2 group-hover:text-ink",children:t}),(0,e.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,e.jsx)("span",{className:"text-base font-medium text-ink",children:r}),(0,e.jsx)("span",{className:"text-sm text-ink-3",children:l})]}),i?(0,e.jsxs)("span",{id:`${b}-note`,className:"mt-auto flex items-center gap-1.5 text-xs text-ink-3",children:[(0,e.jsx)(At,{className:"size-3","aria-hidden":!0}),i]}):null]})}s(et,"StartOption");function ks({localAllowed:t,creating:r,onLocal:l,onSsh:i,recentHosts:m,onOpenHost:v}){return(0,e.jsx)("div",{className:"flex flex-1 items-start justify-center overflow-y-auto p-4 sm:items-center sm:p-8","data-testid":"terminal-start",children:(0,e.jsxs)("div",{className:"flex w-full max-w-2xl flex-col gap-5",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)("h2",{className:"text-lg font-semibold text-ink",children:"Open a terminal"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Choose where the shell runs. You can open more later from the toolbar."})]}),(0,e.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,e.jsx)(et,{testId:"terminal-start-local",icon:(0,e.jsx)(Fe,{className:"size-5","aria-hidden":!0}),title:"Local terminal",description:"A shell on the Wardmote server, as the user that runs Wardmote.",note:t?null:"Needs instance admin access.",disabled:!t||r,onClick:l}),(0,e.jsx)(et,{testId:"terminal-start-ssh",icon:(0,e.jsx)(ee,{className:"size-5","aria-hidden":!0}),title:"SSH terminal",description:t?"Connect to a host from ~/.ssh/config or an SSH environment, or add a new host.":"Connect to an SSH environment registered for this company.",disabled:r,onClick:i})]}),m.length>0?(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs text-ink-3",children:"Recent"}),m.map(b=>(0,e.jsxs)(g,{type:"button",variant:"secondary",size:"xs",disabled:r,onClick:s(()=>v(b),"onClick"),children:[(0,e.jsx)(ee,{"aria-hidden":!0}),b.name]},b.id))]}):null]})})}s(ks,"TerminalStartScreen");var fe=2;function ft(t){return`wardmote:terminal-layout:v1:${t}`}s(ft,"layoutKey");function Oe(t){return`wardmote:terminal-titles:v1:${t}`}s(Oe,"titlesKey");function gt(t){try{return JSON.parse(window.localStorage.getItem(t)??"null")}catch{return null}}s(gt,"readJson");function $e(t,r){try{window.localStorage.setItem(t,JSON.stringify(r))}catch{return}}s($e,"writeJson");function Ns(t){const r=gt(ft(t)),l=Array.isArray(r?.panes)?r.panes.filter(i=>typeof i=="string").slice(0,fe):[];return{panes:l,focused:typeof r?.focused=="number"&&r.focused>=0&&r.focused<l.length?r.focused:0}}s(Ns,"readLayout");function Ss(t){const r=gt(Oe(t));return!r||typeof r!="object"||Array.isArray(r)?{}:Object.fromEntries(Object.entries(r).filter(l=>typeof l[1]=="string"))}s(Ss,"readTitles");function Cs(t,r){const l=new Set(r.map(m=>m.id)),i=t.panes.filter((m,v)=>l.has(m)&&t.panes.indexOf(m)===v);return i.length===0&&r.length>0&&i.push(r[0].id),{panes:i,focused:Math.min(t.focused,Math.max(0,i.length-1))}}s(Cs,"reconcileLayout");function ws(t,r){return t.focused===r.focused&&t.panes.length===r.panes.length&&t.panes.every((l,i)=>l===r.panes[i])}s(ws,"sameLayout");function As({companyId:t}){const r=nt(),l=V.sessions(t),[i,m]=(0,u.useState)(()=>Ns(t)),[v,b]=(0,u.useState)(()=>Ss(t)),[w,P]=(0,u.useState)(null),[h,N]=(0,u.useState)(null),[ue,y]=(0,u.useState)(!1),[D,C]=(0,u.useState)(null),[F,_]=(0,u.useState)(()=>pt(t)),[W,j]=(0,u.useState)(()=>ge(t)),X=pe({queryKey:Ve.access.currentBoardAccess,queryFn:s(()=>Jt.getCurrentBoardAccess(),"queryFn")}),A=Et(X.data),E=pe({queryKey:l,queryFn:s(()=>K.list(t),"queryFn")}),J=pe({queryKey:Ve.environments.list(t),queryFn:s(()=>Gt.list(t),"queryFn"),enabled:E.isSuccess}),o=(0,u.useMemo)(()=>E.data??[],[E.data]),M=(0,u.useMemo)(()=>(J.data??[]).filter(n=>n.driver==="ssh"),[J.data]),T=pe({queryKey:V.sshHosts(t),queryFn:s(()=>K.listSshHosts(t),"queryFn"),enabled:A}),B=(0,u.useMemo)(()=>T.data?.hosts??[],[T.data]),be=(0,u.useMemo)(()=>B.filter(n=>n.source==="config"),[B]),Ae=(0,u.useMemo)(()=>B.filter(n=>n.source==="saved"),[B]);(0,u.useEffect)(()=>{E.isSuccess&&m(n=>{const d=Cs(n,o);return ws(n,d)?n:d})},[o,E.isSuccess]),(0,u.useEffect)(()=>{$e(ft(t),i)},[t,i]);const te=(0,u.useCallback)(n=>{r.setQueryData(l,(d=[])=>d.some(c=>c.id===n.id)?d.map(c=>c.id===n.id?n:c):[...d,n])},[r,l]),se=(0,u.useCallback)((n,d)=>{m(c=>{const p=c.panes.indexOf(n);if(p>=0)return{...c,focused:p};const f=d??c.focused,q=[...c.panes];return f>=q.length?q.push(n):q[f]=n,{panes:q.slice(0,fe),focused:Math.min(f,1)}})},[]),ne=U({mutationFn:s(n=>K.create(t,n.body),"mutationFn"),onSuccess:s((n,d)=>{N(null),te(n),se(n.id,d.pane)},"onSuccess"),onError:s(n=>N(z(n,"Could not open a terminal session.")),"onError")}),Y=U({mutationFn:s(n=>K.remove(t,n),"mutationFn"),onSuccess:s((n,d)=>{N(null),r.setQueryData(l,(c=[])=>c.filter(p=>p.id!==d)),m(c=>{const p=c.panes.filter(f=>f!==d);return{panes:p,focused:Math.min(c.focused,Math.max(0,p.length-1))}}),b(c=>{if(!(d in c))return c;const{[d]:p,...f}=c;return $e(Oe(t),f),f})},"onSuccess"),onError:s(n=>N(z(n,"Could not close the terminal session.")),"onError")}),me=s(n=>ne.mutate({body:{kind:"local"},pane:n}),"createLocal"),ae=s(n=>_(ls(t,n)),"remember"),Ee=s(n=>{y(!1),ae(we(n)),ne.mutate({body:{kind:"ssh",environmentId:n.id,title:n.name}})},"openEnvironment"),ie=s(n=>{y(!1),n.source==="config"&&ae(ve(n)),ne.mutate({body:{kind:"local",sshHostId:n.id,title:n.name}})},"openHost"),ye=s(()=>{j(ge(t)),y(!0)},"openPicker"),Z=s(n=>{y(!1),C({mode:n,key:Date.now()})},"openForm"),re=s(()=>{C(null),j(ge(t))},"closeForm"),G=s((n,d)=>{if(re(),!d){y(!0);return}const c={id:`config:${n.alias}`,source:"config",name:n.alias,destination:n.user?`${n.user}@${n.hostName}`:n.hostName,port:n.port};ie(c)},"onHostSaved"),he=U({mutationFn:s(async n=>{const d=[];for(const c of n)try{await K.moveSshHostToConfig(t,c.id,Ge(c))}catch(p){d.push(`${c.name}: ${z(p,"could not be moved")}`)}return d},"mutationFn"),onSettled:s(()=>r.invalidateQueries({queryKey:V.sshHosts(t)}),"onSettled"),onSuccess:s(n=>N(n.length===0?null:`Some saved hosts were not moved. Open them one by one to fix: ${n.join("; ")}`),"onSuccess"),onError:s(n=>N(z(n,"Saved hosts could not be moved.")),"onError")}),je=s(()=>{if(i.panes.length>=fe){const d=i.panes[i.focused]??i.panes[0];m({panes:[d],focused:0});return}const n=o.find(d=>!i.panes.includes(d.id));n?se(n.id,i.panes.length):A&&me(i.panes.length)},"toggleSplit"),L=s(n=>v[n.id]??n.title,"titleOf"),oe=s(()=>{if(!w)return;const n=w.value.trim();b(d=>{const{[w.id]:c,...p}=d,f=n?{...p,[w.id]:n}:p;return $e(Oe(t),f),f}),P(null)},"commitRename"),He=s(n=>{n.key==="Enter"?(n.preventDefault(),oe()):n.key==="Escape"&&(n.preventDefault(),P(null))},"onRenameKeyDown");if(E.isLoading)return(0,e.jsx)("p",{className:"p-4 text-sm text-ink-3",children:"Loading terminal sessions…"});if(E.isError)return(0,e.jsxs)("div",{className:"flex h-full min-h-(--sz-60vh) flex-col items-center justify-center gap-2 p-6 text-center","data-testid":"terminal-access-error",children:[(0,e.jsx)(Fe,{className:"size-6 text-ink-3","aria-hidden":!0}),(0,e.jsx)("p",{className:"text-sm font-medium text-ink",children:"Terminal unavailable"}),(0,e.jsx)("p",{className:"max-w-md text-sm text-ink-3",children:z(E.error,"Terminal sessions could not be loaded.")})]});const ke=i.panes[i.focused]??null,I=new Map(o.map(n=>[n.id,n])),O=ne.isPending;return(0,e.jsxs)("div",{className:"flex h-full min-h-(--sz-60vh) flex-col overflow-hidden rounded-md border border-line","data-testid":"terminal-workspace",children:[(0,e.jsxs)("div",{className:"flex shrink-0 items-center gap-1 border-b border-line px-2 py-1",children:[(0,e.jsx)("div",{role:"tablist","aria-label":"Terminal sessions",className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:o.map(n=>{const d=n.id===ke,c=i.panes.includes(n.id),p=L(n);return(0,e.jsxs)("div",{className:R("group flex shrink-0 items-center gap-1 rounded-md border px-2 py-1 text-xs",d?"border-focus bg-bg-3 text-ink":c?"border-line text-ink":"border-transparent text-ink-3 hover:bg-bg-3"),children:[n.kind==="ssh"||n.sshHost?(0,e.jsx)(ee,{className:"size-3","aria-hidden":!0}):(0,e.jsx)(Fe,{className:"size-3","aria-hidden":!0}),w?.id===n.id?(0,e.jsx)(Q,{autoFocus:!0,value:w.value,"aria-label":"Session title",onChange:s(f=>P({id:n.id,value:f.target.value}),"onChange"),onKeyDown:He,onBlur:oe,className:"h-6 w-32 px-1 text-xs md:text-xs"}):(0,e.jsxs)("button",{type:"button",role:"tab","aria-selected":d,title:"Double-click to rename",className:"max-w-48 truncate outline-none focus-visible:underline",onClick:s(()=>se(n.id),"onClick"),onDoubleClick:s(()=>P({id:n.id,value:p}),"onDoubleClick"),children:[p,n.status==="exited"?(0,e.jsx)("span",{className:"ml-1 text-ink-3",children:"(ended)"}):null]}),(0,e.jsx)("button",{type:"button","aria-label":`Close ${p}`,className:"rounded-sm text-ink-3 hover:text-ink",disabled:Y.isPending&&Y.variables===n.id,onClick:s(()=>Y.mutate(n.id),"onClick"),children:(0,e.jsx)(qt,{className:"size-3","aria-hidden":!0})})]},n.id)})}),A?(0,e.jsxs)(g,{type:"button",variant:"ghost",size:"xs",onClick:s(()=>me(),"onClick"),disabled:O,children:[(0,e.jsx)(at,{"aria-hidden":!0}),"Local"]}):null,(0,e.jsxs)(g,{type:"button",variant:"ghost",size:"xs",onClick:ye,disabled:O,"aria-haspopup":"dialog",children:[(0,e.jsx)(ee,{"aria-hidden":!0}),"SSH"]}),(0,e.jsx)(g,{type:"button",variant:"ghost",size:"icon-xs","aria-label":i.panes.length>=fe?"Close split":"Split terminal","aria-pressed":i.panes.length>=fe,onClick:je,disabled:O||i.panes.length===0,children:(0,e.jsx)(os,{"aria-hidden":!0})})]}),(0,e.jsx)(js,{open:ue,onOpenChange:y,localAllowed:A,hosts:B,hostsLoading:A&&T.isLoading,hostsError:T.isError?z(T.error,"SSH hosts could not be loaded."):null,configError:T.data?.configError??null,environments:M,environmentsLoading:J.isLoading,recent:F,tests:W,busy:O||he.isPending,onOpenHost:ie,onOpenEnvironment:Ee,onAddHost:s(()=>Z({kind:"add"}),"onAddHost"),onEditHost:s(n=>{n.settings&&Z({kind:"edit",settings:n.settings})},"onEditHost"),onMoveSaved:s(n=>Z({kind:"move",saved:n,settings:Ge(n)}),"onMoveSaved"),onMoveAllSaved:s(()=>he.mutate(Ae),"onMoveAllSaved")}),D?(0,e.jsx)(vs,{companyId:t,open:!0,onOpenChange:s(n=>{n||re()},"onOpenChange"),mode:D.mode,configHosts:be,onSaved:G,onRemoved:s(()=>{re(),y(!0)},"onRemoved")},D.key):null,h?(0,e.jsx)("p",{className:"shrink-0 border-b border-line px-3 py-1 text-xs text-bad",role:"alert",children:h}):null,i.panes.length===0?(0,e.jsx)(ks,{localAllowed:A,creating:O,onLocal:s(()=>me(),"onLocal"),onSsh:ye,recentHosts:F.map(n=>be.find(d=>ve(d)===n)??null).filter(n=>n!==null).slice(0,3),onOpenHost:ie}):(0,e.jsx)(as,{className:"min-h-0 flex-1",children:i.panes.map((n,d)=>(0,e.jsxs)(u.Fragment,{children:[d>0?(0,e.jsx)(is,{}):null,(0,e.jsx)(ns,{id:`terminal-pane-${d}`,minSize:"20%",children:(0,e.jsx)("div",{className:R("h-full min-h-0",i.panes.length>1&&d===i.focused&&"ring-1 ring-inset ring-focus"),onFocusCapture:s(()=>m(c=>c.focused===d?c:{...c,focused:d}),"onFocusCapture"),onMouseDown:s(()=>m(c=>c.focused===d?c:{...c,focused:d}),"onMouseDown"),"data-testid":`terminal-pane-${d}`,children:(0,e.jsx)(Ht,{companyId:t,sessionId:n,active:d===i.focused,onSessionChange:s(c=>{I.has(c.id)&&te(c)},"onSessionChange"),onExit:s(c=>{const p=I.get(n);p&&te({...p,status:"exited",exitCode:c.exitCode})},"onExit")})})})]},n))})]})}s(As,"TerminalWorkspace");function ln(){const{selectedCompanyId:t}=Mt(),{setBreadcrumbs:r}=Zt();return(0,u.useEffect)(()=>{r([{label:"Terminal"}])},[r]),t?(0,e.jsx)(As,{companyId:t},t):(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Select a company to open a terminal."})}s(ln,"Terminal");export{ln as Terminal};
1
+ var Nt=Object.defineProperty;var s=(t,r)=>Nt(t,"name",{value:r,configurable:!0});import{i as tt}from"./rolldown-runtime-ZpX3ckPj.js";import{l as R,na as St,t as st,ta as Ct}from"./createLucideIcon-B-uEJvX6.js";import{a as wt,n as At}from"./star-BXywPGTx.js";import{X as nt,_ as U,t as Ve,v as pe}from"./queryKeys-yuC-YxZI.js";import{a as z,i as Et,n as K,r as V,t as Ht}from"./TerminalView-CZkTSDKg.js";import{n as Mt}from"./CompanyContext-DDgccGSs.js";import{t as Kt}from"./router-2HX_SyKK.js";import{n as Tt,r as zt,t as Pt}from"./collapsible-DfIkfd0G.js";import{t as _t}from"./label-CPQI5V7i.js";import{t as $t}from"./check-DtcbYVEc.js";import{t as Ft}from"./chevron-down-B_rMrTLq.js";import{t as Lt}from"./circle-x-BjJ9dhyd.js";import{t as Ot}from"./cloud-B-O92Qvh.js";import{t as Rt}from"./copy-B55HyIrd.js";import{t as We}from"./key-round-B3uXhHZr.js";import{r as de,t as g}from"./button-D3bYvq4T.js";import{t as at}from"./plus-BbX1VFl1.js";import{t as ee}from"./server-DnJLt7Tc.js";import{t as Dt}from"./shield-question-mark-m0tt6hs2.js";import{t as Bt}from"./triangle-alert-Cpo2fj-L.js";import{t as qt}from"./x-hMw21ejo.js";import{a as it,i as Qt,n as rt,r as ot,s as lt,t as ct}from"./dialog-DlsqN-fP.js";import{t as Q}from"./input-It0utqV7.js";import{t as Jt}from"./access-RvWIoVKp.js";import{n as Zt}from"./BreadcrumbContext-_dNLeVnD.js";import{a as Ut,i as Ce,o as Te,r as Vt,s as Wt,t as Xt}from"./command-D25L6P6V.js";import{t as Yt}from"./textarea-9ySinQRQ.js";import{t as Xe}from"./select-DKYWrP8G.js";import{t as Gt}from"./environments-DNM7-n7c.js";import{t as It}from"./use-copy-action-DTcJkzd7.js";import{Ba as es,Jt as ts,Na as Fe,Yt as ss}from"./index-CSIXA5y5.js";import{n as ns,r as as,t as is}from"./resizable-panels-Cfyr3j78.js";var dt={name:"arrow-right-left",size:24,node:[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]};dt.node;var rs=st(dt),ut={name:"columns-2",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],aliases:["columns"]};ut.node;var os=st(ut),u=tt(St(),1),mt=5;function ht(t){return`wardmote:terminal-ssh-recent:v1:${t}`}s(ht,"recentKey");function Re(t){return`wardmote:terminal-ssh-tests:v1:${t}`}s(Re,"testsKey");function xt(t){try{return JSON.parse(window.localStorage.getItem(t)??"null")}catch{return null}}s(xt,"read");function De(t,r){try{window.localStorage.setItem(t,JSON.stringify(r))}catch{return}}s(De,"write");function pt(t){const r=xt(ht(t));return Array.isArray(r)?r.filter(l=>typeof l=="string").slice(0,mt):[]}s(pt,"recentSshTargets");function ls(t,r){const l=[r,...pt(t).filter(i=>i!==r)].slice(0,mt);return De(ht(t),l),l}s(ls,"rememberSshTarget");function ge(t){const r=xt(Re(t));return!r||typeof r!="object"||Array.isArray(r)?{}:Object.fromEntries(Object.entries(r).filter(l=>typeof l[1]?.status=="string"&&typeof l[1]?.at=="string"))}s(ge,"rememberedTests");function cs(t,r,l,i=new Date){De(Re(t),{...ge(t),[r]:{status:l,at:i.toISOString()}})}s(cs,"rememberTest");function Ye(t,r){const{[r]:l,...i}=ge(t);De(Re(t),i)}s(Ye,"forgetTest");var e=tt(Ct(),1),ds=/^[A-Za-z0-9_][A-Za-z0-9._-]{0,62}$/,us=/^(?:[A-Za-z0-9_](?:[A-Za-z0-9_-]{0,61}[A-Za-z0-9_])?)(?:\.[A-Za-z0-9_](?:[A-Za-z0-9_-]{0,61}[A-Za-z0-9_])?)*$/,ms=/^(?=.*:)[0-9A-Fa-f:.]{2,45}$/,hs=/^[A-Za-z0-9_][A-Za-z0-9._-]{0,63}$/,xs=/^[A-Za-z0-9_][A-Za-z0-9._-]{0,63}$/,ze="Use letters, digits, dots, dashes or underscores.";function Le(t){return t.trim().replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^[^A-Za-z0-9_]+/,"").slice(0,63)||"host"}s(Le,"aliasFromName");function Ge(t){const r=t.destination.lastIndexOf("@");return{alias:Le(t.name),hostName:r>=0?t.destination.slice(r+1):t.destination,user:r>=0?t.destination.slice(0,r):null,port:t.port,identityFile:null,proxyJump:null,serverAliveInterval:null,serverAliveCountMax:null}}s(Ge,"settingsFromSavedHost");function Pe(t,r,l){const i=t.trim();if(!i)return null;if(!/^[0-9]+$/.test(i))return;const m=Number(i);return m>=r&&m<=l?m:void 0}s(Pe,"wholeNumber");function ps({text:t,label:r}){const{status:l,copy:i}=It(2e3);return(0,e.jsxs)(g,{type:"button",variant:"secondary",size:"xs",onClick:s(()=>{i(t)},"onClick"),children:[l==="copied"?(0,e.jsx)($t,{"aria-hidden":!0}):(0,e.jsx)(Rt,{"aria-hidden":!0}),(0,e.jsx)("span",{"aria-live":"polite",children:l==="copied"?"Copied":l==="failed"?"Copy failed":r})]})}s(ps,"CopyButton");function $({id:t,label:r,hint:l,error:i,children:m,className:v}){return(0,e.jsxs)("div",{className:R("flex min-w-0 flex-col gap-1.5",v),children:[(0,e.jsx)(_t,{htmlFor:t,children:r}),m,i?(0,e.jsx)("p",{id:`${t}-error`,className:"text-xs text-bad",children:i}):l?(0,e.jsx)("p",{id:`${t}-hint`,className:"text-xs text-ink-3",children:l}):null]})}s($,"Field");function fs({keyInfo:t,highlight:r}){return t.publicKey?(0,e.jsxs)("div",{className:R("flex flex-col gap-2 rounded-md border p-3",r?"border-accent/40 bg-accent/5":"border-line bg-bg-2"),children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,e.jsx)("p",{className:"text-xs font-medium text-ink",children:r?"Add this public key to ~/.ssh/authorized_keys on the server":"Public key"}),(0,e.jsx)(ps,{text:t.publicKey,label:"Copy public key"})]}),(0,e.jsx)("code",{className:"block max-h-(--sz-64) overflow-auto break-all rounded-sm bg-bg px-2 py-1.5 font-mono text-xs text-ink-2",children:t.publicKey})]}):(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"No public key file next to this key, so it cannot be shown."})}s(fs,"PublicKeyBox");function gs({result:t,trusting:r,onTrust:l}){const i=t.status==="ok",m=t.status==="host_key_unknown",v=i?wt:m?Dt:Lt;return(0,e.jsxs)("div",{className:R("flex flex-col gap-2 rounded-md border p-3 text-sm",i?"border-ok/40 bg-ok-soft":m?"border-warn/40 bg-warn-soft":"border-bad/40 bg-bad-soft"),"data-testid":"ssh-test-result",children:[(0,e.jsxs)("p",{className:"flex items-start gap-2 text-ink",children:[(0,e.jsx)(v,{className:R("mt-0.5 size-4 shrink-0",i?"text-ok":m?"text-warn":"text-bad"),"aria-hidden":!0}),(0,e.jsx)("span",{children:t.message})]}),m&&t.hostKeys.length>0?(0,e.jsxs)("div",{className:"flex flex-col gap-2 pl-6",children:[(0,e.jsx)("ul",{className:"flex flex-col gap-1",children:t.hostKeys.map(b=>(0,e.jsxs)("li",{className:"break-all font-mono text-xs text-ink-2",children:[b.type," ",b.fingerprint]},b.fingerprint))}),(0,e.jsxs)("p",{className:"text-xs text-ink-3",children:["Compare it with ",(0,e.jsx)("code",{className:"font-mono",children:"ssh-keygen -lf /etc/ssh/ssh_host_*_key.pub"})," on the server."]}),(0,e.jsx)("div",{children:(0,e.jsxs)(g,{type:"button",size:"xs",onClick:l,disabled:r,children:[r?(0,e.jsx)(de,{className:"animate-spin motion-reduce:animate-none","aria-hidden":!0}):null,"Trust this host and test again"]})})]}):null,t.detail?(0,e.jsxs)("details",{className:"pl-6 text-xs text-ink-3",children:[(0,e.jsx)("summary",{className:"cursor-pointer select-none",children:"ssh output"}),(0,e.jsx)("pre",{className:"mt-1 whitespace-pre-wrap break-all font-mono",children:t.detail})]}):null]})}s(gs,"TestResult");function vs({companyId:t,open:r,onOpenChange:l,mode:i,configHosts:m,onSaved:v,onRemoved:b}){const w=nt(),P=(0,u.useId)(),h=i.kind==="add"?null:i.settings,[N,ue]=(0,u.useState)(h?.alias??""),[y,D]=(0,u.useState)(h?.hostName??""),[C,F]=(0,u.useState)(h?.user??""),[_,W]=(0,u.useState)(h?.port===null||h?.port===void 0?"":String(h.port)),[j,X]=(0,u.useState)(i.kind==="add"||h?.identityFile?"existing":"default"),[A,E]=(0,u.useState)(h?.identityFile??""),[J,o]=(0,u.useState)(null),[M,T]=(0,u.useState)(""),[B,be]=(0,u.useState)(null),[Ae,te]=(0,u.useState)(null),[se,ne]=(0,u.useState)(h?.proxyJump??""),[Y,me]=(0,u.useState)(h?.serverAliveInterval===null||h?.serverAliveInterval===void 0?"":String(h.serverAliveInterval)),[ae,Ee]=(0,u.useState)(h?.serverAliveCountMax===null||h?.serverAliveCountMax===void 0?"":String(h.serverAliveCountMax)),[ie,ye]=(0,u.useState)(!!(h?.proxyJump||h?.serverAliveInterval||h?.serverAliveCountMax)),[Z,re]=(0,u.useState)(!1),[G,he]=(0,u.useState)(null),[je,L]=(0,u.useState)(null),[oe,He]=(0,u.useState)(!1),ke=(0,u.useRef)(null);(0,u.useEffect)(()=>{G&&ke.current?.scrollIntoView({block:"nearest"})},[G]);const I=pe({queryKey:V.sshKeys(t),queryFn:s(()=>K.listKeys(t),"queryFn"),enabled:r}),O=I.data?.keys??[],n=O.find(a=>a.path===A)??null,d=`wardmote_${Le(N||"host")}`,c=(j==="paste"?B:J)??d,p=new Set(m.filter(a=>!(i.kind==="edit"&&a.name===i.settings.alias)).map(a=>a.name.toLowerCase())),f=N.trim(),q=y.trim(),Be=Pe(_,1,65535),qe=Pe(Y,0,86400),Qe=Pe(ae,1,1e3),S={alias:f?ds.test(f)?p.has(f.toLowerCase())?"A host with this name already exists.":null:ze:"Enter a name, for example prod-web.",hostName:q?us.test(q)||ms.test(q)?null:"Enter a host name like example.com or an IP address.":"Enter the server's host name or IP address.",user:C.trim()&&!hs.test(C.trim())?ze:null,port:Be===void 0?"Port must be a number from 1 to 65535.":null,key:j==="existing"&&!A?"Pick a key, or choose another option.":j==="generate"||j==="paste"?"Create or save the key first.":null,keyName:!xs.test(c)||c.endsWith(".pub")?ze:null,keepAlive:qe===void 0?"Use whole seconds from 0 to 86400.":null,countMax:Qe===void 0?"Use a whole number from 1 to 1000.":null},Je=!!(S.alias||S.hostName||S.user||S.port||S.key||S.keepAlive||S.countMax),H=s((a,k)=>Z||k.trim()?S[a]:null,"show"),Me=s(()=>({alias:f,hostName:q,user:C.trim()||null,port:Be??null,identityFile:j==="existing"&&A?A:null,proxyJump:se||null,serverAliveInterval:qe??null,serverAliveCountMax:Qe??null}),"settings"),vt=s(()=>w.invalidateQueries({queryKey:V.sshKeys(t)}),"refreshKeys"),le=U({mutationFn:s(a=>K.createKey(t,a),"mutationFn"),onSuccess:s(async a=>{L(null),T(""),te(a.path),w.setQueryData(V.sshKeys(t),k=>k&&{...k,keys:[...k.keys.filter(kt=>kt.path!==a.path),a]}),E(a.path),X("existing"),await vt()},"onSuccess"),onError:s(a=>L(z(a,"The key could not be saved.")),"onError")}),ce=U({mutationFn:s(a=>K.testConnection(t,{host:a}),"mutationFn"),onSuccess:s((a,k)=>{L(null),he(a),cs(t,k.alias,a.status)},"onSuccess"),onError:s(a=>L(z(a,"The connection test could not run.")),"onError")}),Ke=U({mutationFn:s(async a=>(await K.trustHostKey(t,{target:{host:a},fingerprints:(G?.hostKeys??[]).map(k=>k.fingerprint)}),a),"mutationFn"),onSuccess:s(a=>ce.mutate(a),"onSuccess"),onError:s(a=>L(z(a,"The host key could not be trusted.")),"onError")}),Ne=U({mutationFn:s(async a=>(i.kind==="edit"?await K.updateConfigHost(t,i.settings.alias,a.settings):i.kind==="move"?await K.moveSshHostToConfig(t,i.saved.id,a.settings):await K.addConfigHost(t,a.settings),a),"mutationFn"),onSuccess:s(async a=>{L(null),i.kind==="edit"&&i.settings.alias!==a.settings.alias&&Ye(t,i.settings.alias),await w.invalidateQueries({queryKey:V.sshHosts(t)}),v(a.settings,a.openTerminal)},"onSuccess"),onError:s(a=>L(z(a,"The host could not be saved.")),"onError")}),Ze=U({mutationFn:s(a=>K.removeConfigHost(t,a),"mutationFn"),onSuccess:s(async(a,k)=>{Ye(t,k),await w.invalidateQueries({queryKey:V.sshHosts(t)}),b?.(k)},"onSuccess"),onError:s(a=>L(z(a,"The host could not be removed.")),"onError")}),Ue=s(a=>{re(!0),!Je&&Ne.mutate({settings:Me(),openTerminal:a})},"submit"),bt=s(()=>{re(!0),!Je&&(he(null),ce.mutate(Me()))},"runTest"),xe=Ne.isPending||Ze.isPending,yt=i.kind==="edit"?`Edit ${i.settings.alias}`:i.kind==="move"?`Move ${i.saved.name} to ssh config`:"Add SSH host",jt=m.filter(a=>a.name!==f&&(i.kind!=="edit"||a.name!==i.settings.alias)),x=s(a=>`${P}-${a}`,"fieldId"),Se=s((a,k)=>k?`${x(a)}-error`:void 0,"describedBy");return(0,e.jsx)(ct,{open:r,onOpenChange:l,children:(0,e.jsxs)(rt,{className:"max-h-(--sz-85vh) gap-0 overflow-y-auto p-0 sm:max-w-2xl","data-testid":"ssh-host-form",children:[(0,e.jsxs)(it,{className:"border-b border-line px-5 pt-5 pb-4 text-left",children:[(0,e.jsx)(lt,{children:yt}),(0,e.jsxs)(ot,{children:["Saved to ~/.ssh/config on the Wardmote server. Agents that run on this server can then use"," ",(0,e.jsxs)("code",{className:"font-mono text-ink-2",children:["ssh ",f||"<name>"]}),". Agents in a sandbox or on an SSH environment run elsewhere and do not see it."]})]}),(0,e.jsxs)("form",{className:"flex flex-col gap-5 px-5 py-4",onSubmit:s(a=>{a.preventDefault(),Ue(i.kind!=="edit")},"onSubmit"),noValidate:!0,children:[(0,e.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,e.jsx)($,{id:x("alias"),label:"Name",hint:(0,e.jsxs)(e.Fragment,{children:["Used as ",(0,e.jsx)("code",{className:"font-mono",children:"ssh name"}),"."]}),error:H("alias",N),children:(0,e.jsx)(Q,{id:x("alias"),value:N,onChange:s(a=>ue(a.target.value),"onChange"),placeholder:"prod-web",autoComplete:"off",spellCheck:!1,autoFocus:!0,"aria-invalid":!!H("alias",N),"aria-describedby":Se("alias",H("alias",N))})}),(0,e.jsx)($,{id:x("host"),label:"Host or IP address",error:H("hostName",y),children:(0,e.jsx)(Q,{id:x("host"),value:y,onChange:s(a=>D(a.target.value),"onChange"),placeholder:"203.0.113.10",autoComplete:"off",spellCheck:!1,inputMode:"url","aria-invalid":!!H("hostName",y),"aria-describedby":Se("host",H("hostName",y))})}),(0,e.jsx)($,{id:x("user"),label:"User",hint:"Leave empty to use your local user name.",error:H("user",C),children:(0,e.jsx)(Q,{id:x("user"),value:C,onChange:s(a=>F(a.target.value),"onChange"),placeholder:"root",autoComplete:"off",spellCheck:!1,"aria-invalid":!!H("user",C),"aria-describedby":Se("user",H("user",C))})}),(0,e.jsx)($,{id:x("port"),label:"Port",hint:"Leave empty for 22.",error:H("port",_),children:(0,e.jsx)(Q,{id:x("port"),value:_,onChange:s(a=>W(a.target.value),"onChange"),placeholder:"22",inputMode:"numeric",autoComplete:"off","aria-invalid":!!H("port",_),"aria-describedby":Se("port",H("port",_))})})]}),(0,e.jsxs)("fieldset",{className:"flex min-w-0 flex-col gap-3",children:[(0,e.jsxs)("legend",{className:"mb-2 flex items-center gap-2 text-sm font-medium text-ink",children:[(0,e.jsx)(We,{className:"size-4 text-ink-3","aria-hidden":!0}),"Key"]}),(0,e.jsx)(ts,{"aria-label":"How to sign in",className:"grid w-full grid-cols-2 sm:flex sm:w-fit",children:[["existing","Key in ~/.ssh"],["generate","Create new key"],["paste","Paste a key"],["default","ssh defaults"]].map(([a,k])=>(0,e.jsx)(ss,{selected:j===a,onClick:s(()=>X(a),"onClick"),children:k},a))}),j==="existing"?(0,e.jsxs)("div",{className:"flex flex-col gap-2",children:[I.isLoading?(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Loading keys…"}):I.isError?(0,e.jsx)("p",{className:"text-sm text-bad",children:z(I.error,"Keys could not be listed.")}):O.length===0?(0,e.jsxs)("p",{className:"text-sm text-ink-3",children:["No private keys in ~/.ssh yet."," ",(0,e.jsx)(g,{type:"button",variant:"link",size:"xs",className:"h-auto px-0",onClick:s(()=>X("generate"),"onClick"),children:"Create one"})]}):(0,e.jsx)($,{id:x("key"),label:"Key file",error:Z?S.key:null,children:(0,e.jsxs)(Xe,{id:x("key"),value:A,onChange:s(a=>{E(a.target.value),te(null)},"onChange"),"aria-invalid":!!(Z&&S.key),children:[(0,e.jsx)("option",{value:"",children:"Choose a key…"}),O.map(a=>(0,e.jsxs)("option",{value:a.path,children:[a.name,a.type?` · ${a.type.replace(/^ssh-/,"")}`:"",a.fingerprint?` · ${a.fingerprint.slice(7,19)}…`:"",a.encrypted?" · passphrase":""]},a.path))]})}),n?(0,e.jsxs)(e.Fragment,{children:[n.fingerprint?(0,e.jsx)("p",{className:"break-all font-mono text-xs text-ink-3",children:n.fingerprint}):null,n.encrypted?(0,e.jsxs)("p",{className:"flex items-start gap-2 rounded-md bg-warn-soft p-2 text-xs text-ink",children:[(0,e.jsx)(Bt,{className:"mt-0.5 size-3.5 shrink-0 text-warn","aria-hidden":!0}),"This key has a passphrase. Agents can only use it while ssh-agent on the server holds it unlocked."]}):null,(0,e.jsx)(fs,{keyInfo:n,highlight:Ae===n.path})]}):null]}):null,j==="generate"?(0,e.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end",children:[(0,e.jsx)($,{id:x("new-key"),label:"New key file name",error:S.keyName,className:"flex-1",children:(0,e.jsx)(Q,{id:x("new-key"),value:c,onChange:s(a=>o(a.target.value),"onChange"),autoComplete:"off",spellCheck:!1})}),(0,e.jsxs)(g,{type:"button",variant:"secondary",disabled:le.isPending||!!S.keyName,onClick:s(()=>le.mutate({mode:"generate",name:c,comment:`${Le(N||"host")}@wardmote`}),"onClick"),children:[le.isPending?(0,e.jsx)(de,{className:"animate-spin motion-reduce:animate-none","aria-hidden":!0}):(0,e.jsx)(We,{"aria-hidden":!0}),"Create ed25519 key"]})]}):null,j==="paste"?(0,e.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,e.jsx)($,{id:x("paste-name"),label:"Save as",error:S.keyName,children:(0,e.jsx)(Q,{id:x("paste-name"),value:c,onChange:s(a=>be(a.target.value),"onChange"),autoComplete:"off",spellCheck:!1})}),(0,e.jsx)($,{id:x("paste-key"),label:"Private key",hint:"Stored as ~/.ssh/<name> with mode 600. Wardmote never shows it again.",children:(0,e.jsx)(Yt,{id:x("paste-key"),value:M,onChange:s(a=>T(a.target.value),"onChange"),placeholder:"-----BEGIN OPENSSH PRIVATE KEY-----",className:"min-h-32 font-mono text-xs md:text-xs",autoComplete:"off",spellCheck:!1})}),(0,e.jsx)("div",{children:(0,e.jsxs)(g,{type:"button",variant:"secondary",disabled:le.isPending||!M.trim()||!!S.keyName,onClick:s(()=>le.mutate({mode:"import",name:c,privateKey:M}),"onClick"),children:[le.isPending?(0,e.jsx)(de,{className:"animate-spin motion-reduce:animate-none","aria-hidden":!0}):null,"Save key"]})})]}):null,j==="default"?(0,e.jsxs)("p",{className:"text-sm text-ink-3",children:["ssh tries the server's default keys and ssh-agent, as a plain ",(0,e.jsx)("code",{className:"font-mono",children:"ssh"})," would."]}):null,Z&&S.key&&!(j==="existing"&&O.length>0)?(0,e.jsx)("p",{className:"text-xs text-bad",children:S.key}):null]}),(0,e.jsxs)(Pt,{open:ie,onOpenChange:ye,children:[(0,e.jsx)(zt,{asChild:!0,children:(0,e.jsxs)(g,{type:"button",variant:"ghost",size:"sm",className:"-ml-2 w-fit text-ink-2",children:[(0,e.jsx)(Ft,{className:R("transition-transform motion-reduce:transition-none",ie&&"rotate-180"),"aria-hidden":!0}),"More options"]})}),(0,e.jsxs)(Tt,{className:"grid gap-4 pt-3 sm:grid-cols-3",children:[(0,e.jsx)($,{id:x("jump"),label:"Connect via",hint:"Reach this host through another host (ProxyJump).",children:(0,e.jsxs)(Xe,{id:x("jump"),value:se,onChange:s(a=>ne(a.target.value),"onChange"),children:[(0,e.jsx)("option",{value:"",children:"Direct"}),jt.map(a=>(0,e.jsx)("option",{value:a.name,children:a.name},a.id))]})}),(0,e.jsx)($,{id:x("keepalive"),label:"Keep-alive (seconds)",hint:"Ping the server so idle sessions stay open.",error:H("keepAlive",Y),children:(0,e.jsx)(Q,{id:x("keepalive"),value:Y,onChange:s(a=>me(a.target.value),"onChange"),placeholder:"30",inputMode:"numeric",autoComplete:"off"})}),(0,e.jsx)($,{id:x("countmax"),label:"Missed pings before giving up",error:H("countMax",ae),children:(0,e.jsx)(Q,{id:x("countmax"),value:ae,onChange:s(a=>Ee(a.target.value),"onChange"),placeholder:"3",inputMode:"numeric",autoComplete:"off"})})]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-3 border-t border-line pt-4",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,e.jsxs)(g,{type:"button",variant:"secondary",onClick:bt,disabled:ce.isPending||Ke.isPending,children:[ce.isPending?(0,e.jsx)(de,{className:"animate-spin motion-reduce:animate-none","aria-hidden":!0}):null,ce.isPending?"Testing…":"Test connection"]}),(0,e.jsx)("p",{className:"text-xs text-ink-3",children:"Runs ssh from the server in batch mode. Nothing is saved."})]}),(0,e.jsx)("div",{"aria-live":"polite",ref:ke,className:"scroll-mb-4",children:G?(0,e.jsx)(gs,{result:G,trusting:Ke.isPending||ce.isPending,onTrust:s(()=>Ke.mutate(Me()),"onTrust")}):null})]}),je?(0,e.jsx)("p",{className:"rounded-md border border-bad/30 bg-bad/5 px-3 py-2 text-sm text-bad",role:"alert",children:je}):null,(0,e.jsxs)(Qt,{className:"gap-2 sm:items-center sm:justify-between",children:[(0,e.jsx)("div",{className:"flex",children:i.kind==="edit"?(0,e.jsx)(g,{type:"button",variant:oe?"delete":"danger",size:"sm",disabled:xe,onClick:s(()=>oe?Ze.mutate(i.settings.alias):He(!0),"onClick"),children:oe?"Click again to remove":"Remove host"}):null}),(0,e.jsxs)("div",{className:"flex flex-col-reverse gap-2 sm:flex-row",children:[(0,e.jsx)(g,{type:"button",variant:"ghost",onClick:s(()=>l(!1),"onClick"),disabled:xe,children:"Cancel"}),i.kind==="edit"?(0,e.jsxs)(g,{type:"submit",disabled:xe,children:[Ne.isPending?(0,e.jsx)(de,{className:"animate-spin motion-reduce:animate-none","aria-hidden":!0}):null,"Save changes"]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(g,{type:"button",variant:"secondary",disabled:xe,onClick:s(()=>Ue(!1),"onClick"),children:"Save"}),(0,e.jsxs)(g,{type:"submit",disabled:xe,children:[Ne.isPending?(0,e.jsx)(de,{className:"animate-spin motion-reduce:animate-none","aria-hidden":!0}):null,"Save and connect"]})]})]})]})]})]})})}s(vs,"SshHostForm");function ve(t){return`host:${t.id}`}s(ve,"hostTargetKey");function we(t){return`env:${t.id}`}s(we,"environmentTargetKey");var bs={ok:{label:"Connected",tone:"bg-ok"},host_key_unknown:{label:"Host not trusted yet",tone:"bg-warn"}};function ys({test:t}){if(!t)return null;const r=bs[t.status]??{label:"Last test failed",tone:"bg-bad"},l=new Date(t.at),i=`${r.label} · tested ${Number.isNaN(l.getTime())?"":l.toLocaleString()}`;return(0,e.jsxs)("span",{className:"flex shrink-0 items-center gap-1 text-xs text-ink-3",title:i,children:[(0,e.jsx)("span",{className:R("size-2 rounded-full",r.tone),"aria-hidden":!0}),(0,e.jsx)("span",{className:"sr-only sm:not-sr-only",children:r.label})]})}s(ys,"TestDot");function _e({icon:t,name:r,detail:l,badge:i,trailing:m,mono:v=!0}){return(0,e.jsxs)(e.Fragment,{children:[t,(0,e.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,e.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[(0,e.jsx)("span",{className:"truncate font-medium text-ink",children:r}),i?(0,e.jsx)("span",{className:"shrink-0 rounded-sm border border-line px-1 text-xs text-ink-3",children:i}):null]}),l?(0,e.jsx)("span",{className:R("truncate text-xs text-ink-3",v&&"font-mono"),children:l}):null]}),m]})}s(_e,"HostRow");function Ie(t){return t.port===null?t.destination:`${t.destination}:${t.port}`}s(Ie,"hostDetail");function js(t){const{open:r,onOpenChange:l,localAllowed:i,hosts:m,hostsLoading:v,hostsError:b,configError:w,environments:P,environmentsLoading:h,recent:N,tests:ue,busy:y}=t,D=(0,u.useRef)(null),C=m.filter(o=>o.source==="config"),F=m.filter(o=>o.source==="saved"),_=new Map;for(const o of C)_.set(ve(o),{kind:"host",host:o});for(const o of P)_.set(we(o),{kind:"env",environment:o});const W=N.map(o=>({key:o,entry:_.get(o)})).filter(o=>o.entry!==void 0),j=new Set(W.map(o=>o.key)),X=!v&&!h&&C.length===0&&P.length===0&&F.length===0,A=s(o=>{o.key!=="/"||o.target===D.current||(o.preventDefault(),D.current?.focus())},"onKeyDown"),E=s((o,M)=>{const T=!!(o.managed&&o.settings);return(0,e.jsx)(Te,{value:`${M}${o.id}`,keywords:[o.name,o.destination],disabled:y,onSelect:s(()=>t.onOpenHost(o),"onSelect"),className:"min-h-12 gap-3",children:(0,e.jsx)(_e,{icon:(0,e.jsx)(ee,{"aria-hidden":!0}),name:o.name,detail:Ie(o),badge:o.managed?T?null:"edited by hand":"~/.ssh/config",trailing:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(ys,{test:ue[o.name]}),T?(0,e.jsx)(g,{type:"button",variant:"ghost",size:"icon-xs","aria-label":`Edit ${o.name}`,title:"Edit",onClick:s(B=>{B.stopPropagation(),t.onEditHost(o)},"onClick"),children:(0,e.jsx)(es,{"aria-hidden":!0})}):null]})})},`${M}${o.id}`)},"configHostItem"),J=s((o,M)=>(0,e.jsx)(Te,{value:`${M}${o.id}`,keywords:[o.name,"environment"],disabled:y,onSelect:s(()=>t.onOpenEnvironment(o),"onSelect"),className:"min-h-12 gap-3",children:(0,e.jsx)(_e,{icon:(0,e.jsx)(Ot,{"aria-hidden":!0}),name:o.name,detail:"SSH environment",mono:!1})},`${M}${o.id}`),"environmentItem");return(0,e.jsx)(ct,{open:r,onOpenChange:l,children:(0,e.jsxs)(rt,{className:"gap-0 overflow-hidden p-0 sm:max-w-xl",onKeyDown:A,children:[(0,e.jsxs)(it,{className:"border-b border-line px-4 pt-4 pb-3 text-left",children:[(0,e.jsx)(lt,{children:"Open an SSH terminal"}),(0,e.jsx)(ot,{children:i?"Pick a host from the server's ~/.ssh/config or an SSH environment.":"Pick an SSH environment. Hosts in the server's ~/.ssh/config are for instance admins."})]}),(0,e.jsxs)(Xt,{loop:!0,className:"rounded-none bg-bg",children:[(0,e.jsx)(Ut,{ref:D,placeholder:"Search hosts… (press / to search)","aria-label":"Search hosts"}),(0,e.jsxs)(Wt,{className:"max-h-(--sz-70vh) min-h-(--sz-64)","aria-busy":v||h,children:[v||h?(0,e.jsx)("p",{className:"px-4 py-3 text-sm text-ink-3",children:"Loading hosts…"}):null,b?(0,e.jsx)("p",{className:"px-4 py-3 text-sm text-bad",role:"alert",children:b}):null,w?(0,e.jsx)("p",{className:"px-4 py-2 text-xs text-ink-3",children:w}):null,X?(0,e.jsxs)("div",{className:"flex flex-col items-center gap-2 px-6 py-8 text-center",children:[(0,e.jsx)(ee,{className:"size-6 text-ink-3","aria-hidden":!0}),(0,e.jsx)("p",{className:"text-sm font-medium text-ink",children:"No SSH hosts yet"}),(0,e.jsx)("p",{className:"max-w-sm text-sm text-ink-3",children:i?"Add a host once and it lands in ~/.ssh/config, ready for this terminal and for agents on this server.":"Ask an instance admin to add an SSH environment you can use."})]}):(0,e.jsx)(Vt,{children:(0,e.jsx)("span",{className:"text-ink-3",children:"No host matches your search."})}),W.length>0?(0,e.jsx)(Ce,{heading:"Recent",children:W.map(({entry:o})=>o.kind==="host"?E(o.host,"recent-"):J(o.environment,"recent-"))}):null,C.some(o=>!j.has(ve(o)))?(0,e.jsx)(Ce,{heading:"SSH hosts",children:C.filter(o=>!j.has(ve(o))).map(o=>E(o,""))}):null,P.some(o=>!j.has(we(o)))?(0,e.jsx)(Ce,{heading:"Environments",children:P.filter(o=>!j.has(we(o))).map(o=>J(o,""))}):null,F.length>0?(0,e.jsxs)(Ce,{heading:"Saved in Wardmote only (not visible to agents)",children:[F.map(o=>(0,e.jsx)(Te,{value:o.id,keywords:[o.name,o.destination],disabled:y,onSelect:s(()=>t.onOpenHost(o),"onSelect"),className:"min-h-12 gap-3",children:(0,e.jsx)(_e,{icon:(0,e.jsx)(ee,{"aria-hidden":!0}),name:o.name,detail:Ie(o),trailing:(0,e.jsxs)(g,{type:"button",variant:"secondary",size:"xs",onClick:s(M=>{M.stopPropagation(),t.onMoveSaved(o)},"onClick"),children:[(0,e.jsx)(rs,{"aria-hidden":!0}),"Move to ssh config"]})})},o.id)),F.length>1?(0,e.jsx)("div",{className:"flex justify-end px-2 pb-1",children:(0,e.jsxs)(g,{type:"button",variant:"link",size:"xs",disabled:y,onClick:t.onMoveAllSaved,children:["Move all ",F.length," to ssh config"]})}):null]}):null]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-2 border-t border-line px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,e.jsx)("p",{className:"text-xs text-ink-3",children:i?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(Kt,{to:"/company/settings/instance/environments",className:"text-ink-2 underline underline-offset-2 hover:text-ink",children:"SSH environments"})," ","connect with a key stored in Wardmote."]}):"Only instance admins can add hosts."}),i?(0,e.jsxs)(g,{type:"button",size:"sm",onClick:t.onAddHost,disabled:y,children:[(0,e.jsx)(at,{"aria-hidden":!0}),"Add host"]}):null]})]})})}s(js,"SshHostPicker");function et({icon:t,title:r,description:l,note:i,disabled:m,onClick:v,testId:b}){return(0,e.jsxs)("button",{type:"button",onClick:v,disabled:m,"aria-describedby":i?`${b}-note`:void 0,"data-testid":b,className:R("group flex min-h-36 flex-col items-start gap-3 rounded-lg border border-line bg-bg-2 p-5 text-left transition-colors motion-reduce:transition-none","outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",m?"cursor-not-allowed opacity-70":"hover:border-line-strong hover:bg-bg-3"),children:[(0,e.jsx)("span",{className:"flex size-10 items-center justify-center rounded-md border border-line bg-bg text-ink-2 group-hover:text-ink",children:t}),(0,e.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,e.jsx)("span",{className:"text-base font-medium text-ink",children:r}),(0,e.jsx)("span",{className:"text-sm text-ink-3",children:l})]}),i?(0,e.jsxs)("span",{id:`${b}-note`,className:"mt-auto flex items-center gap-1.5 text-xs text-ink-3",children:[(0,e.jsx)(At,{className:"size-3","aria-hidden":!0}),i]}):null]})}s(et,"StartOption");function ks({localAllowed:t,creating:r,onLocal:l,onSsh:i,recentHosts:m,onOpenHost:v}){return(0,e.jsx)("div",{className:"flex flex-1 items-start justify-center overflow-y-auto p-4 sm:items-center sm:p-8","data-testid":"terminal-start",children:(0,e.jsxs)("div",{className:"flex w-full max-w-2xl flex-col gap-5",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)("h2",{className:"text-lg font-semibold text-ink",children:"Open a terminal"}),(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Choose where the shell runs. You can open more later from the toolbar."})]}),(0,e.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,e.jsx)(et,{testId:"terminal-start-local",icon:(0,e.jsx)(Fe,{className:"size-5","aria-hidden":!0}),title:"Local terminal",description:"A shell on the Wardmote server, as the user that runs Wardmote.",note:t?null:"Needs instance admin access.",disabled:!t||r,onClick:l}),(0,e.jsx)(et,{testId:"terminal-start-ssh",icon:(0,e.jsx)(ee,{className:"size-5","aria-hidden":!0}),title:"SSH terminal",description:t?"Connect to a host from ~/.ssh/config or an SSH environment, or add a new host.":"Connect to an SSH environment registered for this company.",disabled:r,onClick:i})]}),m.length>0?(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("span",{className:"text-xs text-ink-3",children:"Recent"}),m.map(b=>(0,e.jsxs)(g,{type:"button",variant:"secondary",size:"xs",disabled:r,onClick:s(()=>v(b),"onClick"),children:[(0,e.jsx)(ee,{"aria-hidden":!0}),b.name]},b.id))]}):null]})})}s(ks,"TerminalStartScreen");var fe=2;function ft(t){return`wardmote:terminal-layout:v1:${t}`}s(ft,"layoutKey");function Oe(t){return`wardmote:terminal-titles:v1:${t}`}s(Oe,"titlesKey");function gt(t){try{return JSON.parse(window.localStorage.getItem(t)??"null")}catch{return null}}s(gt,"readJson");function $e(t,r){try{window.localStorage.setItem(t,JSON.stringify(r))}catch{return}}s($e,"writeJson");function Ns(t){const r=gt(ft(t)),l=Array.isArray(r?.panes)?r.panes.filter(i=>typeof i=="string").slice(0,fe):[];return{panes:l,focused:typeof r?.focused=="number"&&r.focused>=0&&r.focused<l.length?r.focused:0}}s(Ns,"readLayout");function Ss(t){const r=gt(Oe(t));return!r||typeof r!="object"||Array.isArray(r)?{}:Object.fromEntries(Object.entries(r).filter(l=>typeof l[1]=="string"))}s(Ss,"readTitles");function Cs(t,r){const l=new Set(r.map(m=>m.id)),i=t.panes.filter((m,v)=>l.has(m)&&t.panes.indexOf(m)===v);return i.length===0&&r.length>0&&i.push(r[0].id),{panes:i,focused:Math.min(t.focused,Math.max(0,i.length-1))}}s(Cs,"reconcileLayout");function ws(t,r){return t.focused===r.focused&&t.panes.length===r.panes.length&&t.panes.every((l,i)=>l===r.panes[i])}s(ws,"sameLayout");function As({companyId:t}){const r=nt(),l=V.sessions(t),[i,m]=(0,u.useState)(()=>Ns(t)),[v,b]=(0,u.useState)(()=>Ss(t)),[w,P]=(0,u.useState)(null),[h,N]=(0,u.useState)(null),[ue,y]=(0,u.useState)(!1),[D,C]=(0,u.useState)(null),[F,_]=(0,u.useState)(()=>pt(t)),[W,j]=(0,u.useState)(()=>ge(t)),X=pe({queryKey:Ve.access.currentBoardAccess,queryFn:s(()=>Jt.getCurrentBoardAccess(),"queryFn")}),A=Et(X.data),E=pe({queryKey:l,queryFn:s(()=>K.list(t),"queryFn")}),J=pe({queryKey:Ve.environments.list(t),queryFn:s(()=>Gt.list(t),"queryFn"),enabled:E.isSuccess}),o=(0,u.useMemo)(()=>E.data??[],[E.data]),M=(0,u.useMemo)(()=>(J.data??[]).filter(n=>n.driver==="ssh"),[J.data]),T=pe({queryKey:V.sshHosts(t),queryFn:s(()=>K.listSshHosts(t),"queryFn"),enabled:A}),B=(0,u.useMemo)(()=>T.data?.hosts??[],[T.data]),be=(0,u.useMemo)(()=>B.filter(n=>n.source==="config"),[B]),Ae=(0,u.useMemo)(()=>B.filter(n=>n.source==="saved"),[B]);(0,u.useEffect)(()=>{E.isSuccess&&m(n=>{const d=Cs(n,o);return ws(n,d)?n:d})},[o,E.isSuccess]),(0,u.useEffect)(()=>{$e(ft(t),i)},[t,i]);const te=(0,u.useCallback)(n=>{r.setQueryData(l,(d=[])=>d.some(c=>c.id===n.id)?d.map(c=>c.id===n.id?n:c):[...d,n])},[r,l]),se=(0,u.useCallback)((n,d)=>{m(c=>{const p=c.panes.indexOf(n);if(p>=0)return{...c,focused:p};const f=d??c.focused,q=[...c.panes];return f>=q.length?q.push(n):q[f]=n,{panes:q.slice(0,fe),focused:Math.min(f,1)}})},[]),ne=U({mutationFn:s(n=>K.create(t,n.body),"mutationFn"),onSuccess:s((n,d)=>{N(null),te(n),se(n.id,d.pane)},"onSuccess"),onError:s(n=>N(z(n,"Could not open a terminal session.")),"onError")}),Y=U({mutationFn:s(n=>K.remove(t,n),"mutationFn"),onSuccess:s((n,d)=>{N(null),r.setQueryData(l,(c=[])=>c.filter(p=>p.id!==d)),m(c=>{const p=c.panes.filter(f=>f!==d);return{panes:p,focused:Math.min(c.focused,Math.max(0,p.length-1))}}),b(c=>{if(!(d in c))return c;const{[d]:p,...f}=c;return $e(Oe(t),f),f})},"onSuccess"),onError:s(n=>N(z(n,"Could not close the terminal session.")),"onError")}),me=s(n=>ne.mutate({body:{kind:"local"},pane:n}),"createLocal"),ae=s(n=>_(ls(t,n)),"remember"),Ee=s(n=>{y(!1),ae(we(n)),ne.mutate({body:{kind:"ssh",environmentId:n.id,title:n.name}})},"openEnvironment"),ie=s(n=>{y(!1),n.source==="config"&&ae(ve(n)),ne.mutate({body:{kind:"local",sshHostId:n.id,title:n.name}})},"openHost"),ye=s(()=>{j(ge(t)),y(!0)},"openPicker"),Z=s(n=>{y(!1),C({mode:n,key:Date.now()})},"openForm"),re=s(()=>{C(null),j(ge(t))},"closeForm"),G=s((n,d)=>{if(re(),!d){y(!0);return}const c={id:`config:${n.alias}`,source:"config",name:n.alias,destination:n.user?`${n.user}@${n.hostName}`:n.hostName,port:n.port};ie(c)},"onHostSaved"),he=U({mutationFn:s(async n=>{const d=[];for(const c of n)try{await K.moveSshHostToConfig(t,c.id,Ge(c))}catch(p){d.push(`${c.name}: ${z(p,"could not be moved")}`)}return d},"mutationFn"),onSettled:s(()=>r.invalidateQueries({queryKey:V.sshHosts(t)}),"onSettled"),onSuccess:s(n=>N(n.length===0?null:`Some saved hosts were not moved. Open them one by one to fix: ${n.join("; ")}`),"onSuccess"),onError:s(n=>N(z(n,"Saved hosts could not be moved.")),"onError")}),je=s(()=>{if(i.panes.length>=fe){const d=i.panes[i.focused]??i.panes[0];m({panes:[d],focused:0});return}const n=o.find(d=>!i.panes.includes(d.id));n?se(n.id,i.panes.length):A&&me(i.panes.length)},"toggleSplit"),L=s(n=>v[n.id]??n.title,"titleOf"),oe=s(()=>{if(!w)return;const n=w.value.trim();b(d=>{const{[w.id]:c,...p}=d,f=n?{...p,[w.id]:n}:p;return $e(Oe(t),f),f}),P(null)},"commitRename"),He=s(n=>{n.key==="Enter"?(n.preventDefault(),oe()):n.key==="Escape"&&(n.preventDefault(),P(null))},"onRenameKeyDown");if(E.isLoading)return(0,e.jsx)("p",{className:"p-4 text-sm text-ink-3",children:"Loading terminal sessions…"});if(E.isError)return(0,e.jsxs)("div",{className:"flex h-full min-h-(--sz-60vh) flex-col items-center justify-center gap-2 p-6 text-center","data-testid":"terminal-access-error",children:[(0,e.jsx)(Fe,{className:"size-6 text-ink-3","aria-hidden":!0}),(0,e.jsx)("p",{className:"text-sm font-medium text-ink",children:"Terminal unavailable"}),(0,e.jsx)("p",{className:"max-w-md text-sm text-ink-3",children:z(E.error,"Terminal sessions could not be loaded.")})]});const ke=i.panes[i.focused]??null,I=new Map(o.map(n=>[n.id,n])),O=ne.isPending;return(0,e.jsxs)("div",{className:"flex h-full min-h-(--sz-60vh) flex-col overflow-hidden rounded-md border border-line","data-testid":"terminal-workspace",children:[(0,e.jsxs)("div",{className:"flex shrink-0 items-center gap-1 border-b border-line px-2 py-1",children:[(0,e.jsx)("div",{role:"tablist","aria-label":"Terminal sessions",className:"flex min-w-0 flex-1 items-center gap-1 overflow-x-auto",children:o.map(n=>{const d=n.id===ke,c=i.panes.includes(n.id),p=L(n);return(0,e.jsxs)("div",{className:R("group flex shrink-0 items-center gap-1 rounded-md border px-2 py-1 text-xs",d?"border-focus bg-bg-3 text-ink":c?"border-line text-ink":"border-transparent text-ink-3 hover:bg-bg-3"),children:[n.kind==="ssh"||n.sshHost?(0,e.jsx)(ee,{className:"size-3","aria-hidden":!0}):(0,e.jsx)(Fe,{className:"size-3","aria-hidden":!0}),w?.id===n.id?(0,e.jsx)(Q,{autoFocus:!0,value:w.value,"aria-label":"Session title",onChange:s(f=>P({id:n.id,value:f.target.value}),"onChange"),onKeyDown:He,onBlur:oe,className:"h-6 w-32 px-1 text-xs md:text-xs"}):(0,e.jsxs)("button",{type:"button",role:"tab","aria-selected":d,title:"Double-click to rename",className:"max-w-48 truncate outline-none focus-visible:underline",onClick:s(()=>se(n.id),"onClick"),onDoubleClick:s(()=>P({id:n.id,value:p}),"onDoubleClick"),children:[p,n.status==="exited"?(0,e.jsx)("span",{className:"ml-1 text-ink-3",children:"(ended)"}):null]}),(0,e.jsx)("button",{type:"button","aria-label":`Close ${p}`,className:"rounded-sm text-ink-3 hover:text-ink",disabled:Y.isPending&&Y.variables===n.id,onClick:s(()=>Y.mutate(n.id),"onClick"),children:(0,e.jsx)(qt,{className:"size-3","aria-hidden":!0})})]},n.id)})}),A?(0,e.jsxs)(g,{type:"button",variant:"ghost",size:"xs",onClick:s(()=>me(),"onClick"),disabled:O,children:[(0,e.jsx)(at,{"aria-hidden":!0}),"Local"]}):null,(0,e.jsxs)(g,{type:"button",variant:"ghost",size:"xs",onClick:ye,disabled:O,"aria-haspopup":"dialog",children:[(0,e.jsx)(ee,{"aria-hidden":!0}),"SSH"]}),(0,e.jsx)(g,{type:"button",variant:"ghost",size:"icon-xs","aria-label":i.panes.length>=fe?"Close split":"Split terminal","aria-pressed":i.panes.length>=fe,onClick:je,disabled:O||i.panes.length===0,children:(0,e.jsx)(os,{"aria-hidden":!0})})]}),(0,e.jsx)(js,{open:ue,onOpenChange:y,localAllowed:A,hosts:B,hostsLoading:A&&T.isLoading,hostsError:T.isError?z(T.error,"SSH hosts could not be loaded."):null,configError:T.data?.configError??null,environments:M,environmentsLoading:J.isLoading,recent:F,tests:W,busy:O||he.isPending,onOpenHost:ie,onOpenEnvironment:Ee,onAddHost:s(()=>Z({kind:"add"}),"onAddHost"),onEditHost:s(n=>{n.settings&&Z({kind:"edit",settings:n.settings})},"onEditHost"),onMoveSaved:s(n=>Z({kind:"move",saved:n,settings:Ge(n)}),"onMoveSaved"),onMoveAllSaved:s(()=>he.mutate(Ae),"onMoveAllSaved")}),D?(0,e.jsx)(vs,{companyId:t,open:!0,onOpenChange:s(n=>{n||re()},"onOpenChange"),mode:D.mode,configHosts:be,onSaved:G,onRemoved:s(()=>{re(),y(!0)},"onRemoved")},D.key):null,h?(0,e.jsx)("p",{className:"shrink-0 border-b border-line px-3 py-1 text-xs text-bad",role:"alert",children:h}):null,i.panes.length===0?(0,e.jsx)(ks,{localAllowed:A,creating:O,onLocal:s(()=>me(),"onLocal"),onSsh:ye,recentHosts:F.map(n=>be.find(d=>ve(d)===n)??null).filter(n=>n!==null).slice(0,3),onOpenHost:ie}):(0,e.jsx)(as,{className:"min-h-0 flex-1",children:i.panes.map((n,d)=>(0,e.jsxs)(u.Fragment,{children:[d>0?(0,e.jsx)(is,{}):null,(0,e.jsx)(ns,{id:`terminal-pane-${d}`,minSize:"20%",children:(0,e.jsx)("div",{className:R("h-full min-h-0",i.panes.length>1&&d===i.focused&&"ring-1 ring-inset ring-focus"),onFocusCapture:s(()=>m(c=>c.focused===d?c:{...c,focused:d}),"onFocusCapture"),onMouseDown:s(()=>m(c=>c.focused===d?c:{...c,focused:d}),"onMouseDown"),"data-testid":`terminal-pane-${d}`,children:(0,e.jsx)(Ht,{companyId:t,sessionId:n,active:d===i.focused,onSessionChange:s(c=>{I.has(c.id)&&te(c)},"onSessionChange"),onExit:s(c=>{const p=I.get(n);p&&te({...p,status:"exited",exitCode:c.exitCode})},"onExit")})})})]},n))})]})}s(As,"TerminalWorkspace");function ln(){const{selectedCompanyId:t}=Mt(),{setBreadcrumbs:r}=Zt();return(0,u.useEffect)(()=>{r([{label:"Terminal"}])},[r]),t?(0,e.jsx)(As,{companyId:t},t):(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"Select a company to open a terminal."})}s(ln,"Terminal");export{ln as Terminal};