@tickernelz/wardmote-ui 2026.1118.0 → 2026.1118.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 (164) hide show
  1. package/dist/assets/{AdapterManager-Cz1qnS9X.js → AdapterManager-DvntZ2AW.js} +1 -1
  2. package/dist/assets/{AdvancedToolsRoute-7YTRdxju.js → AdvancedToolsRoute-CUW8D9Ux.js} +1 -1
  3. package/dist/assets/{AgentActionButtons-CE0nmrqG.js → AgentActionButtons-CQLGCtfu.js} +1 -1
  4. package/dist/assets/{AgentBubbleActionRow-Dqrx638X.js → AgentBubbleActionRow-CnkfFlB3.js} +1 -1
  5. package/dist/assets/{AgentChat-AunGdpGT.js → AgentChat-DCwwZA2b.js} +1 -1
  6. package/dist/assets/{AgentChats-T9fzOwzH.js → AgentChats-DMMLdo-o.js} +1 -1
  7. package/dist/assets/{AgentDefaults-C0WFwQky.js → AgentDefaults-Cu8O2iTJ.js} +1 -1
  8. package/dist/assets/{AgentDetail-DEmzneVa.js → AgentDetail-BMVWOVp-.js} +7 -7
  9. package/dist/assets/{AgentIconPicker-BJerBmcL.js → AgentIconPicker-DJaVz-Vx.js} +1 -1
  10. package/dist/assets/{AgentTodoCard-D1lORgGy.js → AgentTodoCard-C4BfJg4x.js} +1 -1
  11. package/dist/assets/Agents-C0IDC6KD.js +3 -0
  12. package/dist/assets/{AppDetail-BX1FNfWC.js → AppDetail-DzEGsx94.js} +1 -1
  13. package/dist/assets/{AppNotConnected-7VCE3fbW.js → AppNotConnected-BVL32B49.js} +1 -1
  14. package/dist/assets/{ApprovalCard-BFjlBJIl.js → ApprovalCard-DCQ49PuW.js} +1 -1
  15. package/dist/assets/{ApprovalDetail-nh-aAVQ1.js → ApprovalDetail-B0J70llD.js} +1 -1
  16. package/dist/assets/{ApprovalPayload-CrxNpWYr.js → ApprovalPayload-8lqBw-XQ.js} +1 -1
  17. package/dist/assets/{Approvals-T3qTJIwh.js → Approvals-BkiVjx0M.js} +1 -1
  18. package/dist/assets/{AppsConnect-D7l2xnv-.js → AppsConnect-B_hvpdTB.js} +1 -1
  19. package/dist/assets/{AppsReview-BQpLs2ic.js → AppsReview-CeXp22cE.js} +1 -1
  20. package/dist/assets/{ArtifactCard-9vsmkZzO.js → ArtifactCard-BV82tDLI.js} +1 -1
  21. package/dist/assets/{Artifacts-DN7vvCse.js → Artifacts-CL5ZmZ3m.js} +1 -1
  22. package/dist/assets/{AssistantConnection-DFVB49U5.js → AssistantConnection-C5rmoEsm.js} +1 -1
  23. package/dist/assets/{AttentionInteractionResolver-61BN1ky5.js → AttentionInteractionResolver-DxZpuIIF.js} +1 -1
  24. package/dist/assets/AuditHub-DDPFGvHG.js +1 -0
  25. package/dist/assets/{Auth-D0lGuVnd.js → Auth-CkILt4fl.js} +1 -1
  26. package/dist/assets/{BoardChat-CMIqWEbi.js → BoardChat-DlaNGzcQ.js} +3 -3
  27. package/dist/assets/{BoardClaim-CbYY66Qd.js → BoardClaim-B135Nebr.js} +1 -1
  28. package/dist/assets/{BootstrapSetupUxLab-M3IOGjXI.js → BootstrapSetupUxLab-B2tOIzXd.js} +1 -1
  29. package/dist/assets/{Browse-AYCtuCFi.js → Browse-xEc9mGl7.js} +1 -1
  30. package/dist/assets/{BudgetPolicyCard-Cwm5wpvU.js → BudgetPolicyCard-Ccr3EX5M.js} +1 -1
  31. package/dist/assets/{CaseDetail-CgZ4u934.js → CaseDetail-CvMk_M-F.js} +2 -2
  32. package/dist/assets/{Cases-BvCHo_JJ.js → Cases-H1Y4Oipe.js} +2 -2
  33. package/dist/assets/{ChatEndpointDetail-CM83nK2S.js → ChatEndpointDetail-CjDVQWl8.js} +1 -1
  34. package/dist/assets/{ChatEndpointSetup-Dzm1h4LA.js → ChatEndpointSetup-BfohtKVM.js} +1 -1
  35. package/dist/assets/{ChatIdentityConfirm-Dc4AnYX8.js → ChatIdentityConfirm-tOTIxwjm.js} +1 -1
  36. package/dist/assets/{CliAuth-CatEsBxW.js → CliAuth-CE0EwTW_.js} +1 -1
  37. package/dist/assets/{Companies-BBdNER6U.js → Companies-C4ObCu9j.js} +1 -1
  38. package/dist/assets/{CompanyAccess-CX4qyiXc.js → CompanyAccess-J5Vwnko2.js} +1 -1
  39. package/dist/assets/{CompanyActivity-Csqqnldg.js → CompanyActivity-B7-kMNmz.js} +1 -1
  40. package/dist/assets/{CompanyConnections-Ds1e8fjb.js → CompanyConnections-D2N6UWXk.js} +1 -1
  41. package/dist/assets/{CompanyEnvironments-BQGpdLk1.js → CompanyEnvironments-ChSu4gxW.js} +1 -1
  42. package/dist/assets/{CompanyExport-CBJU6SZ5.js → CompanyExport-B_opHRSJ.js} +1 -1
  43. package/dist/assets/{CompanyImport-BtODUy1v.js → CompanyImport-DZAMEBBy.js} +1 -1
  44. package/dist/assets/{CompanySettings-x6CbuKeE.js → CompanySettings-Rz8cwgKC.js} +1 -1
  45. package/dist/assets/{CompanySettingsPluginPage-CEDKNwLY.js → CompanySettingsPluginPage-CM-ViPwj.js} +1 -1
  46. package/dist/assets/{CompanySkills-C32TKvfI.js → CompanySkills-BnwPuZze.js} +2 -2
  47. package/dist/assets/{ComposerAddMenu-BPPkbm0o.js → ComposerAddMenu-jKf-6Yli.js} +1 -1
  48. package/dist/assets/{ConfigureBuiltInAgentModal-v8kbSAuE.js → ConfigureBuiltInAgentModal-BAfoTveX.js} +1 -1
  49. package/dist/assets/{ConnectionSetupFlow-g6asOGFg.js → ConnectionSetupFlow-8alK3I_h.js} +1 -1
  50. package/dist/assets/{CopyableGatewayUrl-DM4I2CJE.js → CopyableGatewayUrl-D90Bjxj0.js} +1 -1
  51. package/dist/assets/{Dashboard-4TvnZKHQ.js → Dashboard-DepIxrje.js} +2 -2
  52. package/dist/assets/{DecisionDateChips-H3AqvYWG.js → DecisionDateChips-89KkV4mo.js} +1 -1
  53. package/dist/assets/{DecisionModelSettings-HEZJ0E6n.js → DecisionModelSettings-CvVCBVCM.js} +1 -1
  54. package/dist/assets/{DecisionQueuePage-C--TNteA.js → DecisionQueuePage-nU9qXzln.js} +1 -1
  55. package/dist/assets/{DesignGuide-PDM2oacG.js → DesignGuide-40TixHZ-.js} +4 -4
  56. package/dist/assets/{EmailEndpointSetup-B0haS5AA.js → EmailEndpointSetup-D7-8f1XV.js} +1 -1
  57. package/dist/assets/{EntityRow-B24YmFE7.js → EntityRow-jUxCK6IM.js} +1 -1
  58. package/dist/assets/ExecutionWorkspaceDetail-CnUD3jLO.js +19 -0
  59. package/dist/assets/{GatewayDetail-CtpVgcnJ.js → GatewayDetail-Bg7GU-1a.js} +2 -2
  60. package/dist/assets/{GatewaysList-DCuMJisg.js → GatewaysList-4vvZCBkY.js} +1 -1
  61. package/dist/assets/{GoalDetail-B4Iw4vhL.js → GoalDetail-h7WsjaOO.js} +1 -1
  62. package/dist/assets/{GoalTree-Bxei53eI.js → GoalTree-yPtfejUx.js} +1 -1
  63. package/dist/assets/{Goals-CszzFpXF.js → Goals-DOi3E4DX.js} +1 -1
  64. package/dist/assets/{ImageGalleryModal-7mN3BVkG.js → ImageGalleryModal-D_VQgcBt.js} +1 -1
  65. package/dist/assets/{Inbox-Dzj03JZw.js → Inbox-COKxRKhR.js} +2 -2
  66. package/dist/assets/{InlineBanner-DYx7A02D.js → InlineBanner-DeTqU5Gp.js} +1 -1
  67. package/dist/assets/{InlineEditor-BJTE1pyF.js → InlineEditor-4ew5gxf0.js} +1 -1
  68. package/dist/assets/{InstanceAdvanced-HzNvpWAC.js → InstanceAdvanced-DlMlwZbU.js} +1 -1
  69. package/dist/assets/{InstanceFeatures-C1eqcxDI.js → InstanceFeatures-BbDE9waY.js} +1 -1
  70. package/dist/assets/{InviteLanding-BHDk8eVb.js → InviteLanding-BGvJMHKw.js} +1 -1
  71. package/dist/assets/{IssueChatLongThreadPerf-E61LYLEE.js → IssueChatLongThreadPerf-C3U2FZKJ.js} +1 -1
  72. package/dist/assets/{IssueChatThread-DERjeWcT.js → IssueChatThread-CDKaIB6v.js} +10 -10
  73. package/dist/assets/{IssueDetail--oKqoH82.js → IssueDetail-BCwHANTn.js} +6 -6
  74. package/dist/assets/{IssueDocumentAnnotations-DjcRXcEw.js → IssueDocumentAnnotations-DpFXlkRb.js} +1 -1
  75. package/dist/assets/{IssueOutputSection-Dvul0VAn.js → IssueOutputSection-BzXRmoV7.js} +1 -1
  76. package/dist/assets/{IssueRecoveryActionCard-DpJjLu9A.js → IssueRecoveryActionCard-BYtbaP-M.js} +1 -1
  77. package/dist/assets/{IssueReferencePill-DIqTKSRc.js → IssueReferencePill-BT7NBEy_.js} +1 -1
  78. package/dist/assets/{IssueThreadInteractionCard-PnjBaM8M.js → IssueThreadInteractionCard-Btd0rZ23.js} +1 -1
  79. package/dist/assets/{Issues-Dwcvbvvw.js → Issues-XKf7zemQ.js} +3 -3
  80. package/dist/assets/{LiveNowTodoLine-B3GKP4a7.js → LiveNowTodoLine-CoL6ZNuK.js} +1 -1
  81. package/dist/assets/ManagedAiConnectionDetails-CebBi-Tw.js +1 -0
  82. package/dist/assets/{MarkdownBody-D7qCQaU_.js → MarkdownBody-cPGkwwjq.js} +1 -1
  83. package/dist/assets/{McpConnect-CYz1a9lA.js → McpConnect-ByorZN7G.js} +1 -1
  84. package/dist/assets/{MembershipAction-BCf-FK7R.js → MembershipAction-De0MBfgb.js} +1 -1
  85. package/dist/assets/{MetricCard-DlcBTKQs.js → MetricCard-CTOmJVRL.js} +1 -1
  86. package/dist/assets/{MissingPluginTabPlaceholder-l1R-Q4nh.js → MissingPluginTabPlaceholder-D3N0rd-p.js} +1 -1
  87. package/dist/assets/{ModelsAndProviders-CI6zoBD9.js → ModelsAndProviders-BqM4UJc7.js} +1 -1
  88. package/dist/assets/{NewAgent-BWaZTy_v.js → NewAgent-pMTQYNxn.js} +1 -1
  89. package/dist/assets/{OmpAllSettings-DTJLATQL.js → OmpAllSettings-BeXrdLBc.js} +1 -1
  90. package/dist/assets/{PipelineSettings-pFkHM2Ns.js → PipelineSettings-C2k3BzLQ.js} +2 -2
  91. package/dist/assets/Pipelines-Cr6Xs32p.js +1 -0
  92. package/dist/assets/PixelsOffice-Dfd4XKSj.js +2 -0
  93. package/dist/assets/{PluginManager-DkADWuR8.js → PluginManager-7ZdeHrGQ.js} +1 -1
  94. package/dist/assets/{PluginPage-CBAkPwZs.js → PluginPage-fPlWyFSc.js} +1 -1
  95. package/dist/assets/{PluginSettings-CsXh8PMi.js → PluginSettings-X_VHvvo5.js} +1 -1
  96. package/dist/assets/{ProfileDetailRoute-B6mZqIhS.js → ProfileDetailRoute-PAsWmN-1.js} +1 -1
  97. package/dist/assets/{ProfileSettings-BZG_OvIh.js → ProfileSettings-BACxlGZS.js} +1 -1
  98. package/dist/assets/{ProfileWizardRoute-yUXZqjqr.js → ProfileWizardRoute-Dbq0n7If.js} +1 -1
  99. package/dist/assets/ProjectDetail-DOJZUIWu.js +1 -0
  100. package/dist/assets/{ProjectWorkspaceDetail-rSo7mMQc.js → ProjectWorkspaceDetail-ZNnaHnuA.js} +1 -1
  101. package/dist/assets/{ProjectWorkspacesContent-DnGszD3v.js → ProjectWorkspacesContent-DrWfnTJY.js} +1 -1
  102. package/dist/assets/{Projects-kZ7Li_8n.js → Projects-CCzxmEZ8.js} +1 -1
  103. package/dist/assets/{PublicIssueSharePage-DMy8nXt2.js → PublicIssueSharePage-BUSkP1Js.js} +1 -1
  104. package/dist/assets/{QuestionForm-DF6R7lYE.js → QuestionForm-MfSDsey7.js} +1 -1
  105. package/dist/assets/{RepositoryEditor-BuV4JRgV.js → RepositoryEditor-2QyuT99t.js} +1 -1
  106. package/dist/assets/{ReviewQueueCard-Bz8uXwnD.js → ReviewQueueCard-CrCN_30c.js} +1 -1
  107. package/dist/assets/{RichWorkProductCard-BCB8SaZp.js → RichWorkProductCard-DndJn4LV.js} +1 -1
  108. package/dist/assets/{RoutineDetail-C-gt9_NY.js → RoutineDetail-B5MzV_74.js} +2 -2
  109. package/dist/assets/{RoutineRunVariablesDialog-CrKptoDW.js → RoutineRunVariablesDialog-kGyQVBid.js} +1 -1
  110. package/dist/assets/Routines-B2zX9h3J.js +1 -0
  111. package/dist/assets/ScrollToBottom-Dd3SpeJi.js +1 -0
  112. package/dist/assets/{Search-B-8DqpI2.js → Search-D4W3cZZf.js} +1 -1
  113. package/dist/assets/{Secrets-CPNzZnuu.js → Secrets-C4nbuMIh.js} +3 -3
  114. package/dist/assets/{SidebarNavItem-afEXEFeo.js → SidebarNavItem-kYI7H9f3.js} +1 -1
  115. package/dist/assets/{SkillSourceTree-CR8rC1PY.js → SkillSourceTree-BvGzMa2u.js} +1 -1
  116. package/dist/assets/{SkillSources-3haDckt2.js → SkillSources-DL2tNkcr.js} +1 -1
  117. package/dist/assets/{SkillStudio-CXzQR1ws.js → SkillStudio-BnZ2cfDq.js} +1 -1
  118. package/dist/assets/{SourceTrustBadge-DNvpVd9i.js → SourceTrustBadge-CCPQEGrC.js} +1 -1
  119. package/dist/assets/{StatusCards-D-O7dS5f.js → StatusCards-BkE-9R8F.js} +1 -1
  120. package/dist/assets/{StatusIcon-Bx4H7RuA.js → StatusIcon-Cs1RbJGu.js} +1 -1
  121. package/dist/assets/{SummarySlotCard-CYpYMfTa.js → SummarySlotCard-D1EyiciB.js} +1 -1
  122. package/dist/assets/{TaskChatLab-BfxurxKS.js → TaskChatLab-D3PsNRr5.js} +1 -1
  123. package/dist/assets/{TaskChatMarker-Cj8k3l9N.js → TaskChatMarker-DEF88_sr.js} +2 -2
  124. package/dist/assets/{TaskChatProtocolCard-BsdB1fYv.js → TaskChatProtocolCard-Ba_vhDxn.js} +1 -1
  125. package/dist/assets/{TaskChatThreadView-B90tQ4X1.js → TaskChatThreadView-BsPvbxiA.js} +1 -1
  126. package/dist/assets/{TaskTreeControls-zoH_P07l.js → TaskTreeControls-BKOIbilg.js} +2 -2
  127. package/dist/assets/{Terminal-y6EdGsxY.js → Terminal-1uPX7VEe.js} +1 -1
  128. package/dist/assets/{TerminalView-CWvRC4uL.js → TerminalView-DDv6s-R_.js} +1 -1
  129. package/dist/assets/{ToolsAdminGate-C5dQpL4C.js → ToolsAdminGate-BzvfSwod.js} +1 -1
  130. package/dist/assets/{TrustPresetSection-gUExLKOq.js → TrustPresetSection-BDb0N4Pe.js} +1 -1
  131. package/dist/assets/{UserProfile-uUu_7SHc.js → UserProfile-DqPRuGWk.js} +1 -1
  132. package/dist/assets/{WebhookUrlWarning-CbkWHsPb.js → WebhookUrlWarning-CHx5gr2m.js} +1 -1
  133. package/dist/assets/WhatNeedsMe-DtBxgH24.js +1 -0
  134. package/dist/assets/{WorkspaceRuntimeControls-Cp5E1FME.js → WorkspaceRuntimeControls-Clk2nzU6.js} +1 -1
  135. package/dist/assets/{Workspaces-MhwqOigu.js → Workspaces-BQOyG5HK.js} +1 -1
  136. package/dist/assets/{connection-owner-CslVCQSM.js → connection-owner-CPrMcD3t.js} +1 -1
  137. package/dist/assets/{index-D1wQsid4.js → index-QhteFtm-.js} +16 -16
  138. package/dist/assets/{issue-properties-BXissCm1.js → issue-properties--M7WE6Ot.js} +3 -3
  139. package/dist/assets/{issue-workspace-selection-Ey-jzxzA.js → issue-workspace-selection-pUdSkrJA.js} +1 -1
  140. package/dist/assets/{pipeline-stage-presentation-B_etSYde.js → pipeline-stage-presentation-Dv1xgEPW.js} +1 -1
  141. package/dist/assets/router-CJbFZfVR.js +1 -0
  142. package/dist/assets/{shared-CSvxoeyx.js → shared-B75ClBUg.js} +1 -1
  143. package/dist/assets/{slots-DZ1hj5sG.js → slots-B7lwlN1w.js} +1 -1
  144. package/dist/assets/system-notice-comment-D0I6rz8Y.js +1 -0
  145. package/dist/assets/{task-chat-attachments-DNPQ-jOG.js → task-chat-attachments-2KmZkOL7.js} +1 -1
  146. package/dist/assets/{transcript-adapter-CppFOMQA.js → transcript-adapter-ClaGWYVL.js} +1 -1
  147. package/dist/assets/useSummaryDraftStream-BDuMgNcA.js +3 -0
  148. package/dist/index.html +12 -13
  149. package/dist/sw.js +1 -1
  150. package/package.json +1 -1
  151. package/dist/assets/Agents-BwRQ91d5.js +0 -3
  152. package/dist/assets/AuditHub-CPsJe_Bl.js +0 -1
  153. package/dist/assets/ExecutionWorkspaceDetail-BI4rAhvY.js +0 -19
  154. package/dist/assets/ManagedAiConnectionDetails-D7zoLLKJ.js +0 -1
  155. package/dist/assets/Pipelines-C8_wN0Sv.js +0 -1
  156. package/dist/assets/PixelsOffice-GHMNmVjR.js +0 -2
  157. package/dist/assets/ProjectDetail-CTwwSUZn.js +0 -1
  158. package/dist/assets/Routines-D3JG-gCI.js +0 -1
  159. package/dist/assets/ScrollToBottom-CYzcByH1.js +0 -1
  160. package/dist/assets/WhatNeedsMe-JNJ5uJyH.js +0 -1
  161. package/dist/assets/heartbeats-D96c9g2n.js +0 -1
  162. package/dist/assets/router-BKzUF9uf.js +0 -1
  163. package/dist/assets/system-notice-comment-DPCHQ4-Y.js +0 -1
  164. package/dist/assets/useSummaryDraftStream-DQYbVHb7.js +0 -3
@@ -1,3 +1,3 @@
1
- var z=Object.defineProperty;var o=(s,t)=>z(s,"name",{value:t,configurable:!0});import{i as B}from"./rolldown-runtime-ZpX3ckPj.js";import{C as q,bt as M,l as O,la as K,ua as V}from"./createLucideIcon-CgrPXnTY.js";import{t as X,v as T}from"./queryKeys-BzT8CD34.js";import{Jt as U,Ut as H,ot as W,t as F,zt as G}from"./router-BKzUF9uf.js";import{n as Q,r as J,t as Y}from"./collapsible-D_rwONtV.js";import{a as Z,c as k,d as ee,f as se,i as N,o as te,p as ae,r as re,s as D,t as ne,u as ie}from"./dropdown-menu-rUbU8QKw.js";import{n as le}from"./PathInstructionsModal-BJAqF7vQ.js";import{t as oe}from"./arrow-up-right-CFNgVoQj.js";import{t as ce}from"./chevron-right-BP8JjEC_.js";import{t as de}from"./circle-x-oLE71NY3.js";import{t as me}from"./MarkdownBody-D7qCQaU_.js";import{t as he}from"./code-xml-CZhhm_-P.js";import{t as xe}from"./ellipsis-DyXbAp4P.js";import{t as ue}from"./eye-D8HiVtuU.js";import{r as pe,t as f}from"./button-DI4w5WP7.js";import{t as fe}from"./refresh-cw-CfzWP9se.js";import{t as je}from"./repeat-DzPORJjX.js";import{t as we}from"./square-CDo6rOf8.js";import{t as ge}from"./x-6E1yeU3Q.js";import{i as R,n as E,t as $}from"./tooltip-CW50mEoC.js";import{a as be,i as ve,n as ke,r as Ne,s as ye,t as Ce}from"./dialog-CeH7rDcv.js";import{u as _}from"./issue-filters-Ce8v1l6U.js";import{$a as De,Qa as P,Xa as Se,eo as Me}from"./index-D1wQsid4.js";import{l as Te,n as Re,o as Ee,s as $e,u as _e}from"./ImageGalleryModal-7mN3BVkG.js";import{a as Pe,i as Le,n as Ie}from"./IssueReferencePill-DIqTKSRc.js";var e=B(K(),1);function Be({createdFrom:s,issueLinkState:t,className:n}){if(!s)return null;const{issue:a,agent:i}=s,r=a.identifier??a.id;return(0,e.jsxs)("p",{"data-testid":"issue-created-from",className:O("flex min-w-0 items-center gap-1 text-xs text-ink-3",n),children:[(0,e.jsx)(W,{"aria-hidden":!0,className:"h-3 w-3 shrink-0"}),(0,e.jsx)("span",{className:"shrink-0",children:"Created from"}),(0,e.jsx)(F,{to:H(r),state:t,onClickCapture:o(()=>U(r,t),"onClickCapture"),className:"min-w-0 truncate hover:text-ink transition-colors",title:a.title,children:a.identifier?`${a.identifier} ${a.title}`:a.title}),i&&(0,e.jsxs)("span",{className:"shrink-0",children:["by ",i.name]})]})}o(Be,"IssueCreatedFromNote");function y({name:s,projectPath:t,children:n}){return(0,e.jsx)(Y,{defaultOpen:!0,asChild:!0,children:(0,e.jsxs)("section",{"aria-label":s,children:[(0,e.jsxs)("div",{className:"group/header flex items-center gap-1 rounded-md hover:bg-bg-3/50",children:[(0,e.jsx)("h2",{children:(0,e.jsxs)(J,{className:"group flex items-center gap-1 rounded-md py-1 text-left text-sm font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus",children:[(0,e.jsx)("span",{children:s}),(0,e.jsx)("span",{"aria-hidden":!0,className:"flex w-3.5 items-center justify-center opacity-0 transition-opacity duration-(--motion-duration-fast) ease-(--motion-ease-standard) group-hover/header:opacity-100 group-focus-within/header:opacity-100",children:(0,e.jsx)(ce,{className:"h-3.5 w-3.5 text-ink-3 transition-transform duration-(--motion-duration-fast) ease-(--motion-ease-standard) group-data-[state=open]:rotate-90"})})]})}),t&&(0,e.jsx)(F,{to:t,"aria-label":`Go to ${s} project`,title:`Go to ${s} project`,className:"ml-auto inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-ink-3 opacity-0 transition-opacity duration-(--motion-duration-fast) ease-(--motion-ease-standard) hover:bg-bg-3 hover:text-ink group-hover/header:opacity-100 group-focus-within/header:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus",children:(0,e.jsx)(oe,{"aria-hidden":!0,className:"h-3.5 w-3.5"})})]}),(0,e.jsx)(Q,{className:"pt-2",children:n})]})})}o(y,"TaskGroup");function ws({ancestors:s=[],createdFrom:t=null,subtasks:n,createdTasks:a,projects:i,isLoading:r,hasError:c,onRetry:l,issueLinkState:d}){const m=L(n),p=new Map;for(const h of L(a)){const x=h.projectId??"no-project",g=h.projectId?i.find(w=>w.id===h.projectId)??h.project:null,u=p.get(x)??{name:g?.name??(h.projectId?"Project":"No project"),path:h.projectId?`/projects/${q(g??{id:h.projectId})}/issues`:void 0,tasks:[]};u.tasks.push(h),p.set(x,u)}return(0,e.jsxs)("section",{className:"flex flex-col gap-6","aria-label":"Related tasks",children:[t&&(0,e.jsx)(y,{name:"Created from",children:(0,e.jsx)(Be,{createdFrom:t,issueLinkState:d,className:"px-2 text-sm"})}),s.length>0&&(0,e.jsx)(y,{name:"Ancestors",children:(0,e.jsx)(Ie,{items:[...s].reverse(),emptyMessage:"",ariaLabel:"Ancestor tasks, root to parent",issueLinkState:d})}),m.length>0&&(0,e.jsx)(y,{name:"Subtasks",children:(0,e.jsx)(Le,{items:m,issueLinkState:d})}),[...p.entries()].sort(([,h],[,x])=>h.name.localeCompare(x.name)).map(([h,x])=>(0,e.jsx)(y,{name:x.name,projectPath:x.path,children:(0,e.jsx)(Pe,{items:x.tasks,ariaLabel:`${x.name} tasks`,issueLinkState:d})},h)),r&&(0,e.jsx)("p",{role:"status",className:"text-sm text-ink-3",children:"Loading tasks…"}),c&&(0,e.jsxs)("div",{role:"alert",className:"flex items-center gap-2 text-sm text-bad",children:[(0,e.jsx)("span",{children:"Could not load all tasks."}),l&&(0,e.jsx)(f,{variant:"ghost",size:"sm",onClick:l,children:"Retry"})]}),!r&&!c&&!t&&s.length===0&&n.length===0&&a.length===0&&(0,e.jsx)("p",{className:"py-6 text-center text-sm text-ink-3",children:"No tasks yet."})]})}o(ws,"TaskDetailTasksPanel");function L(s){return[...new Map(s.map(t=>[t.id,t])).values()].sort((t,n)=>_.indexOf(t.status)-_.indexOf(n.status))}o(L,"sortTasks");var C=B(V(),1);function Fe(s,t=""){return/\.csv$/i.test(s)||t.split(";")[0].trim().toLowerCase()==="text/csv"}o(Fe,"isCsvFile");function Ae(s){const t=s.replace(/^\uFEFF/,"");if(!t)return[];const n=[];let a=[],i="",r=!1;for(let c=0;c<t.length;c++){const l=t[c];l==='"'?r&&t[c+1]==='"'?(i+='"',c++):r||i===""?r=!r:i+=l:!r&&l===","?(a.push(i),i=""):!r&&(l===`
1
+ var z=Object.defineProperty;var o=(s,t)=>z(s,"name",{value:t,configurable:!0});import{i as B}from"./rolldown-runtime-ZpX3ckPj.js";import{C as q,bt as M,l as O,la as K,ua as V}from"./createLucideIcon-CgrPXnTY.js";import{t as U,v as T}from"./queryKeys-BzT8CD34.js";import{Jt as X,Ut as H,ot as W,t as F,zt as G}from"./router-CJbFZfVR.js";import{n as J,r as Q,t as Y}from"./collapsible-D_rwONtV.js";import{a as Z,c as k,d as ee,f as se,i as N,o as te,p as ae,r as re,s as D,t as ne,u as ie}from"./dropdown-menu-rUbU8QKw.js";import{n as le}from"./PathInstructionsModal-BJAqF7vQ.js";import{t as oe}from"./arrow-up-right-CFNgVoQj.js";import{t as ce}from"./chevron-right-BP8JjEC_.js";import{t as de}from"./circle-x-oLE71NY3.js";import{t as me}from"./MarkdownBody-cPGkwwjq.js";import{t as he}from"./code-xml-CZhhm_-P.js";import{t as xe}from"./ellipsis-DyXbAp4P.js";import{t as ue}from"./eye-D8HiVtuU.js";import{r as pe,t as f}from"./button-DI4w5WP7.js";import{t as fe}from"./refresh-cw-CfzWP9se.js";import{t as je}from"./repeat-DzPORJjX.js";import{t as we}from"./square-CDo6rOf8.js";import{t as ge}from"./x-6E1yeU3Q.js";import{i as R,n as E,t as $}from"./tooltip-CW50mEoC.js";import{a as be,i as ve,n as ke,r as Ne,s as ye,t as Ce}from"./dialog-CeH7rDcv.js";import{u as _}from"./issue-filters-Ce8v1l6U.js";import{$a as P,Za as De,eo as Se,to as Me}from"./index-QhteFtm-.js";import{l as Te,n as Re,o as Ee,s as $e,u as _e}from"./ImageGalleryModal-D_VQgcBt.js";import{a as Pe,i as Le,n as Ie}from"./IssueReferencePill-BT7NBEy_.js";var e=B(K(),1);function Be({createdFrom:s,issueLinkState:t,className:n}){if(!s)return null;const{issue:a,agent:i}=s,r=a.identifier??a.id;return(0,e.jsxs)("p",{"data-testid":"issue-created-from",className:O("flex min-w-0 items-center gap-1 text-xs text-ink-3",n),children:[(0,e.jsx)(W,{"aria-hidden":!0,className:"h-3 w-3 shrink-0"}),(0,e.jsx)("span",{className:"shrink-0",children:"Created from"}),(0,e.jsx)(F,{to:H(r),state:t,onClickCapture:o(()=>X(r,t),"onClickCapture"),className:"min-w-0 truncate hover:text-ink transition-colors",title:a.title,children:a.identifier?`${a.identifier} ${a.title}`:a.title}),i&&(0,e.jsxs)("span",{className:"shrink-0",children:["by ",i.name]})]})}o(Be,"IssueCreatedFromNote");function y({name:s,projectPath:t,children:n}){return(0,e.jsx)(Y,{defaultOpen:!0,asChild:!0,children:(0,e.jsxs)("section",{"aria-label":s,children:[(0,e.jsxs)("div",{className:"group/header flex items-center gap-1 rounded-md hover:bg-bg-3/50",children:[(0,e.jsx)("h2",{children:(0,e.jsxs)(Q,{className:"group flex items-center gap-1 rounded-md py-1 text-left text-sm font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus",children:[(0,e.jsx)("span",{children:s}),(0,e.jsx)("span",{"aria-hidden":!0,className:"flex w-3.5 items-center justify-center opacity-0 transition-opacity duration-(--motion-duration-fast) ease-(--motion-ease-standard) group-hover/header:opacity-100 group-focus-within/header:opacity-100",children:(0,e.jsx)(ce,{className:"h-3.5 w-3.5 text-ink-3 transition-transform duration-(--motion-duration-fast) ease-(--motion-ease-standard) group-data-[state=open]:rotate-90"})})]})}),t&&(0,e.jsx)(F,{to:t,"aria-label":`Go to ${s} project`,title:`Go to ${s} project`,className:"ml-auto inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-ink-3 opacity-0 transition-opacity duration-(--motion-duration-fast) ease-(--motion-ease-standard) hover:bg-bg-3 hover:text-ink group-hover/header:opacity-100 group-focus-within/header:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus",children:(0,e.jsx)(oe,{"aria-hidden":!0,className:"h-3.5 w-3.5"})})]}),(0,e.jsx)(J,{className:"pt-2",children:n})]})})}o(y,"TaskGroup");function ws({ancestors:s=[],createdFrom:t=null,subtasks:n,createdTasks:a,projects:i,isLoading:r,hasError:c,onRetry:l,issueLinkState:d}){const m=L(n),p=new Map;for(const h of L(a)){const x=h.projectId??"no-project",g=h.projectId?i.find(w=>w.id===h.projectId)??h.project:null,u=p.get(x)??{name:g?.name??(h.projectId?"Project":"No project"),path:h.projectId?`/projects/${q(g??{id:h.projectId})}/issues`:void 0,tasks:[]};u.tasks.push(h),p.set(x,u)}return(0,e.jsxs)("section",{className:"flex flex-col gap-6","aria-label":"Related tasks",children:[t&&(0,e.jsx)(y,{name:"Created from",children:(0,e.jsx)(Be,{createdFrom:t,issueLinkState:d,className:"px-2 text-sm"})}),s.length>0&&(0,e.jsx)(y,{name:"Ancestors",children:(0,e.jsx)(Ie,{items:[...s].reverse(),emptyMessage:"",ariaLabel:"Ancestor tasks, root to parent",issueLinkState:d})}),m.length>0&&(0,e.jsx)(y,{name:"Subtasks",children:(0,e.jsx)(Le,{items:m,issueLinkState:d})}),[...p.entries()].sort(([,h],[,x])=>h.name.localeCompare(x.name)).map(([h,x])=>(0,e.jsx)(y,{name:x.name,projectPath:x.path,children:(0,e.jsx)(Pe,{items:x.tasks,ariaLabel:`${x.name} tasks`,issueLinkState:d})},h)),r&&(0,e.jsx)("p",{role:"status",className:"text-sm text-ink-3",children:"Loading tasks…"}),c&&(0,e.jsxs)("div",{role:"alert",className:"flex items-center gap-2 text-sm text-bad",children:[(0,e.jsx)("span",{children:"Could not load all tasks."}),l&&(0,e.jsx)(f,{variant:"ghost",size:"sm",onClick:l,children:"Retry"})]}),!r&&!c&&!t&&s.length===0&&n.length===0&&a.length===0&&(0,e.jsx)("p",{className:"py-6 text-center text-sm text-ink-3",children:"No tasks yet."})]})}o(ws,"TaskDetailTasksPanel");function L(s){return[...new Map(s.map(t=>[t.id,t])).values()].sort((t,n)=>_.indexOf(t.status)-_.indexOf(n.status))}o(L,"sortTasks");var C=B(V(),1);function Fe(s,t=""){return/\.csv$/i.test(s)||t.split(";")[0].trim().toLowerCase()==="text/csv"}o(Fe,"isCsvFile");function Ae(s){const t=s.replace(/^\uFEFF/,"");if(!t)return[];const n=[];let a=[],i="",r=!1;for(let c=0;c<t.length;c++){const l=t[c];l==='"'?r&&t[c+1]==='"'?(i+='"',c++):r||i===""?r=!r:i+=l:!r&&l===","?(a.push(i),i=""):!r&&(l===`
2
2
  `||l==="\r")?(a.push(i),n.push(a),a=[],i="",l==="\r"&&t[c+1]===`
3
- `&&c++):i+=l}if(r)throw new Error("A quoted field is incomplete. Switch to raw view to inspect the file.");return(i!==""||a.length||!/[\r\n]$/.test(t))&&(a.push(i),n.push(a)),n}o(Ae,"parseCsv");var S=500,I=100;function ze({text:s,title:t}){const n=(0,C.useMemo)(()=>{try{return{rows:Ae(s),error:null}}catch(l){return{rows:[],error:l.message}}},[s]);if(n.error)return(0,e.jsx)("p",{role:"alert",className:"p-4 text-sm text-ink-3",children:n.error});if(!n.rows.length)return(0,e.jsx)("p",{className:"p-4 text-sm text-ink-3",children:"File is empty."});const[a,...i]=n.rows,r=n.rows.reduce((l,d)=>Math.max(l,d.length),0),c=Array.from({length:Math.min(r,I)},(l,d)=>d);return(0,e.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col bg-bg",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-b border-line px-4 py-2 text-xs text-ink-3",role:"status",children:[(0,e.jsx)("span",{className:"font-medium text-ink",children:"CSV preview"}),(0,e.jsxs)("span",{children:[i.length.toLocaleString()," ",i.length===1?"row":"rows"]}),(0,e.jsxs)("span",{children:[r.toLocaleString()," ",r===1?"column":"columns"]}),(i.length>S||r>I)&&(0,e.jsxs)("span",{children:["Showing the first ",Math.min(i.length,S)," rows and ",c.length," columns. Download for the complete file."]})]}),(0,e.jsx)("div",{className:"min-h-0 flex-1 overflow-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus focus-visible:ring-inset",role:"region","aria-label":`${t} CSV table`,tabIndex:0,children:(0,e.jsxs)("table",{className:"w-full border-collapse text-sm",children:[(0,e.jsxs)("caption",{className:"sr-only",children:[t," — first record used as column headers"]}),(0,e.jsx)("thead",{className:"sticky top-0 z-10 bg-bg-3",children:(0,e.jsxs)("tr",{children:[(0,e.jsxs)("th",{scope:"col",className:"w-10 border-b border-line px-3 py-3 text-right font-mono text-xs text-ink-3",children:[(0,e.jsx)("span",{className:"sr-only",children:"Row"}),"#"]}),c.map(l=>(0,e.jsx)("th",{scope:"col",className:"whitespace-nowrap border-b border-line px-4 py-3 text-left font-medium",children:a[l]||`Column ${l+1}`},l))]})}),(0,e.jsx)("tbody",{children:i.slice(0,S).map((l,d)=>(0,e.jsxs)("tr",{className:"even:bg-bg-3/30 hover:bg-bg-3/50",children:[(0,e.jsx)("th",{scope:"row",className:"border-b border-line/50 px-3 py-2 text-right font-mono text-xs font-normal text-ink-3",children:d+1}),c.map(m=>(0,e.jsx)("td",{className:"whitespace-pre-wrap border-b border-line/50 px-4 py-2 align-top",children:l[m]??""},m))]},d))})]})})]})}o(ze,"CsvPreview");function qe({html:s,title:t}){const n=(0,C.useMemo)(()=>Te(s),[s]);return(0,e.jsx)("iframe",{title:`${t} rendered HTML`,srcDoc:n,sandbox:"allow-scripts",referrerPolicy:"no-referrer",allow:"camera 'none'; microphone 'none'; geolocation 'none'; clipboard-read 'none'; clipboard-write 'none'; fullscreen 'none'",className:"block h-full min-h-0 w-full flex-1 border-0 bg-bg"})}o(qe,"HtmlArtifactPreview");function Oe({mode:s,onChange:t,label:n}){return(0,e.jsxs)("div",{className:"flex gap-1",role:"group","aria-label":n,children:[(0,e.jsx)(f,{type:"button",size:"icon-sm",variant:s==="rendered"?"secondary":"ghost","aria-label":"Rendered",title:"Rendered","aria-pressed":s==="rendered",onClick:o(()=>t("rendered"),"onClick"),children:(0,e.jsx)(ue,{"aria-hidden":!0})}),(0,e.jsx)(f,{type:"button",size:"icon-sm",variant:s==="raw"?"secondary":"ghost","aria-label":"Raw",title:"Raw","aria-pressed":s==="raw",onClick:o(()=>t("raw"),"onClick"),children:(0,e.jsx)(he,{"aria-hidden":!0})})]})}o(Oe,"FilePreviewModeToggle");async function Ke(s){if(!s.ok)throw new Error(`Could not load file (${s.status}).`);if(!s.body)throw new Error("The file response is empty.");const t=s.body.getReader(),n=new TextDecoder("utf-8",{fatal:!0});let a=0,i="";try{for(;;){const r=await t.read();if(r.done)break;if(a+=r.value.byteLength,a>524288)throw new Error("This file is too large to preview. Download it instead.");i+=n.decode(r.value,{stream:!0})}if(i+=n.decode(),i.includes("\0"))throw new Error("This file contains binary data. Download it instead.");return i}finally{await t.cancel(),t.releaseLock()}}o(Ke,"readTextPreview");function Ve({title:s,text:t,markdown:n,html:a=!1,csv:i=!1,downloadUrl:r}){const[c,l]=(0,C.useState)("rendered");(0,C.useEffect)(()=>l("rendered"),[s]);const d=i&&c==="rendered"&&t.length>0,m=a&&c==="rendered"&&t.length>0;return(0,e.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,e.jsxs)("header",{className:"flex items-center gap-2 border-b border-line px-3 py-2",children:[(0,e.jsx)("h2",{className:"min-w-0 flex-1 truncate text-sm font-medium",title:s,children:s}),n||a||i?(0,e.jsx)(Oe,{mode:c,onChange:l,label:a?"HTML view":i?"CSV view":"Markdown view"}):null,(0,e.jsx)(f,{asChild:!0,variant:"ghost",size:"icon-sm",children:(0,e.jsx)("a",{href:r,download:!0,"aria-label":`Download ${s}`,title:`Download ${s}`,children:(0,e.jsx)(Se,{"aria-hidden":!0})})})]}),(0,e.jsx)("div",{className:m||d?"flex min-h-0 flex-1 flex-col overflow-hidden":"min-h-0 flex-1 overflow-auto p-4",children:t.length===0?(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"File is empty."}):d?(0,e.jsx)(ze,{text:t,title:s}):m?(0,e.jsx)(qe,{html:t,title:s}):n&&c==="rendered"?(0,e.jsx)(me,{mediaMode:"reference",children:t}):(0,e.jsx)("pre",{className:"whitespace-pre-wrap break-words font-mono text-sm","aria-label":`${s} raw text`,children:t})})]})}o(Ve,"TextAttachmentPreview");function gs({issueId:s,attachmentId:t}){const n=T({queryKey:X.issues.attachments(s),queryFn:o(()=>G.listAttachments(s),"queryFn")}),a=n.data?.find(l=>l.id===t),i=a&&$e(a)&&a.byteSize<=524288,r=T({queryKey:["task-text-attachment",s,t],queryFn:o(async({signal:l})=>Ke(await fetch(`/api/attachments/${encodeURIComponent(t)}/content`,{signal:l,credentials:"same-origin"})),"queryFn"),enabled:!!i,retry:!1});if(n.isLoading)return(0,e.jsx)("p",{className:"p-4 text-sm",role:"status",children:"Loading file…"});if(n.isError)return(0,e.jsxs)("div",{className:"p-4",role:"alert",children:["Could not load attachment details. ",(0,e.jsx)(f,{onClick:o(()=>{n.refetch()},"onClick"),children:"Retry"})]});if(!a)return(0,e.jsx)("p",{className:"p-4 text-sm",role:"status",children:"File no longer available. Close this tab or choose another file."});const c=Re(a);return!i||r.isError?(0,e.jsxs)("div",{className:"space-y-3 p-4",role:"alert",children:[(0,e.jsx)("p",{className:"text-sm",children:r.isError?"Could not preview this file. Retry or download it.":"This file is too large or is not supported for text preview. Download it instead."}),i?(0,e.jsx)(f,{onClick:o(()=>{r.refetch()},"onClick"),children:"Retry"}):null,(0,e.jsx)(f,{asChild:!0,variant:"secondary",children:(0,e.jsx)("a",{href:c,download:!0,children:"Download file"})})]}):r.data===void 0?(0,e.jsx)("p",{className:"p-4 text-sm",role:"status",children:"Loading file…"}):(0,e.jsx)(Ve,{title:a.originalFilename??a.id,text:r.data,csv:Fe(a.originalFilename??"",a.contentType),markdown:Ee(a),html:_e(a.contentType,a.originalFilename),downloadUrl:c},a.id)}o(gs,"TaskAttachmentPanel");function bs({browser:s,now:t,disabled:n=!1,onControl:a,onReconnect:i,viewport:r="fit",controlledElsewhere:c=!1,resizing:l=!1,resizeAvailable:d=!0,onResize:m}){const p=s.status==="running"||s.status==="idle",h=s.expiresAt?Date.parse(s.expiresAt):1/0,x=s.idleDeadline?Date.parse(s.idleDeadline):1/0,g=Math.min(x,h),u=Math.max(0,Math.ceil((g-t)/1e3)),w=s.status==="idle"&&u<=300,b=s.status==="idle"&&h>x&&g>t,v=`${Math.floor(u/60)}:${String(u%60).padStart(2,"0")}`,A=r==="fit"?"Fit to pane":M.find(j=>j.id===r)?.label??"Default";return p?(0,e.jsxs)("footer",{"aria-label":"Browser session",className:"flex shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-t px-3 py-2 text-xs text-ink-3",children:[w&&(0,e.jsxs)("span",{role:"timer","aria-live":"off",className:"flex items-center gap-1 whitespace-nowrap",children:[(0,e.jsx)(P,{className:"size-3","aria-hidden":"true"}),u>0?(0,e.jsxs)(e.Fragment,{children:["Closes in"," ",(0,e.jsx)("span",{className:"font-mono tabular-nums",children:v})]}):"Closing…"]}),c&&r==="fit"&&(0,e.jsx)("span",{children:"Size follows another viewer"}),l?(0,e.jsxs)("span",{role:"status",className:"flex items-center gap-1",children:[(0,e.jsx)(pe,{className:"size-3 animate-spin motion-reduce:animate-none","aria-hidden":"true"}),"Resizing…"]}):s.status==="running"&&(0,e.jsx)("span",{children:"Browsing"}),(0,e.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[w&&b&&(0,e.jsxs)($,{children:[(0,e.jsx)(R,{asChild:!0,children:(0,e.jsx)(f,{size:"xs",variant:"ghost",disabled:n,onClick:o(()=>a("keep_open"),"onClick"),children:"Keep browsing"})}),(0,e.jsxs)(E,{children:["Keep this browser open for up to ",6e5/6e4," ","more minutes."]})]}),s.status==="running"&&(0,e.jsxs)($,{children:[(0,e.jsx)(R,{asChild:!0,children:(0,e.jsxs)(f,{size:"xs",variant:"ghost",disabled:n,onClick:o(()=>a("cancel"),"onClick"),children:[(0,e.jsx)(we,{"aria-hidden":"true"})," Stop browsing"]})}),(0,e.jsx)(E,{children:"Stop the agent’s browser work and leave the browser open."})]}),p&&(0,e.jsxs)(ne,{children:[(0,e.jsx)(ae,{asChild:!0,children:(0,e.jsx)(f,{size:"icon-xs",variant:"ghost","aria-label":"Browser options",disabled:n,children:(0,e.jsx)(xe,{"aria-hidden":"true"})})}),(0,e.jsxs)(re,{side:"top",align:"end",className:"w-64",children:[(0,e.jsxs)(ie,{children:[(0,e.jsxs)(se,{disabled:l||!d,children:[(0,e.jsx)(le,{"aria-hidden":"true"}),(0,e.jsx)("span",{children:"Browser size"}),(0,e.jsx)("span",{className:"ml-auto text-xs text-ink-3",children:A})]}),(0,e.jsxs)(ee,{className:"w-64",children:[(0,e.jsx)(Z,{children:"Browser size"}),(0,e.jsxs)(te,{value:r,onValueChange:o(j=>m(j),"onValueChange"),children:[(0,e.jsx)(D,{value:"fit",onSelect:o(()=>{r==="fit"&&m("fit")},"onSelect"),children:"Fit to pane"}),c&&(0,e.jsx)(N,{onSelect:o(()=>m("fit"),"onSelect"),children:"Fit to this pane instead"}),(0,e.jsx)(k,{}),(0,e.jsx)(D,{value:"default",onSelect:o(()=>{r==="default"&&m("default")},"onSelect"),children:"Browser default"}),(0,e.jsx)(k,{}),M.map(j=>(0,e.jsxs)(D,{value:j.id,onSelect:o(()=>{r===j.id&&m(j.id)},"onSelect"),children:[(0,e.jsx)("span",{children:j.label}),(0,e.jsxs)("span",{className:"ml-auto font-mono text-xs tabular-nums text-ink-3",children:[j.width," × ",j.height]})]},j.id))]})]})]}),(0,e.jsx)(k,{}),(0,e.jsxs)(N,{onSelect:i,className:"items-start",children:[(0,e.jsx)(fe,{className:"mt-0.5","aria-hidden":"true"}),(0,e.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,e.jsx)("span",{children:"Reconnect view"}),(0,e.jsx)("span",{className:"text-xs font-normal text-ink-3",children:"Reload the live view. Browser work keeps running."})]})]}),b&&(0,e.jsxs)(N,{onSelect:o(()=>a("keep_open"),"onSelect"),className:"items-start",children:[(0,e.jsx)(P,{className:"mt-0.5","aria-hidden":"true"}),(0,e.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,e.jsx)("span",{children:"Keep browser open"}),(0,e.jsx)("span",{className:"text-xs font-normal text-ink-3",children:"Keep it open for up to 10 more minutes."})]})]}),(0,e.jsx)(k,{}),(0,e.jsxs)(N,{variant:"destructive",onSelect:o(()=>a("end"),"onSelect"),className:"items-start",children:[(0,e.jsx)(ge,{className:"mt-0.5","aria-hidden":"true"}),(0,e.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,e.jsx)("span",{children:"Close browser"}),(0,e.jsx)("span",{className:"text-xs font-normal text-ink-3",children:"End this browser and stop any browsing."})]})]})]})]})]})]}):null}o(bs,"TaskBrowserFooter");function vs({scope:s,canPause:t,canResume:n,canCancel:a,canRestore:i,pending:r,onPause:c,onResume:l,onCancel:d,onRestore:m}){const p="flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-bg-3/50 disabled:opacity-50 disabled:pointer-events-none";return(0,e.jsxs)(e.Fragment,{children:[t?(0,e.jsxs)("button",{disabled:r,className:p,onClick:c,children:[(0,e.jsx)(Me,{className:"h-3 w-3"}),s==="leaf"?"Pause work":"Pause subtree"]}):null,n?(0,e.jsxs)("button",{disabled:r,className:p,onClick:l,children:[(0,e.jsx)(De,{className:"h-3 w-3"}),s==="leaf"?"Resume work":"Resume subtree"]}):null,a?(0,e.jsxs)("button",{disabled:r,className:`${p} text-bad`,onClick:d,children:[(0,e.jsx)(de,{className:"h-3 w-3"}),"Cancel subtree..."]}):null,i?(0,e.jsxs)("button",{disabled:r,className:p,onClick:m,children:[(0,e.jsx)(je,{className:"h-3 w-3"}),"Restore subtree..."]}):null]})}o(vs,"TaskTreeControlMenuItems");function ks({open:s,onOpenChange:t,mode:n,scope:a,affectedCount:i,affectedAgentCount:r,loading:c,error:l,pending:d,valid:m,wakeAgents:p,onWakeAgentsChange:h,onRetry:x,onApply:g}){const u=n==="cancel",w=`${i} task${i===1?"":"s"}`,b=u?"Cancel subtree?":n==="restore"?"Restore subtree":a==="leaf"?"Resume work":"Resume subtree";return(0,e.jsx)(Ce,{open:s,onOpenChange:o(v=>{d||t(v)},"onOpenChange"),children:(0,e.jsxs)(ke,{showCloseButton:!d,className:"max-h-(--sz-calc-18) overflow-y-auto sm:max-w-sm",children:[(0,e.jsxs)(be,{children:[(0,e.jsx)(ye,{children:b}),(0,e.jsx)(Ne,{children:c?"Loading…":u?`${w} will be cancelled.`:`${w} will ${n==="restore"?"be restored":"resume"}.`})]}),l?(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:l}),(0,e.jsx)(f,{size:"sm",variant:"secondary",disabled:d,onClick:x,children:"Retry preview"})]}):null,u?null:(0,e.jsxs)("label",{className:"flex items-center gap-2 text-sm",children:[(0,e.jsx)("input",{type:"checkbox",checked:p,disabled:d||c||r===0,onChange:o(v=>h(v.target.checked),"onChange")}),"Wake affected agents (",r,")"]}),(0,e.jsxs)(ve,{children:[(0,e.jsx)(f,{variant:"secondary",disabled:d,onClick:o(()=>t(!1),"onClick"),children:u?"Keep tasks":"Close"}),(0,e.jsx)(f,{variant:u?"danger":"primary",disabled:d||c||!!l||!m,onClick:g,children:d?"Applying…":u?`Cancel ${w}`:n==="restore"?`Restore ${w}`:b})]})]})})}o(ks,"TaskTreeControlDialog");export{Ve as a,ze as c,gs as i,Fe as l,vs as n,Oe as o,bs as r,qe as s,ks as t,ws as u};
3
+ `&&c++):i+=l}if(r)throw new Error("A quoted field is incomplete. Switch to raw view to inspect the file.");return(i!==""||a.length||!/[\r\n]$/.test(t))&&(a.push(i),n.push(a)),n}o(Ae,"parseCsv");var S=500,I=100;function ze({text:s,title:t}){const n=(0,C.useMemo)(()=>{try{return{rows:Ae(s),error:null}}catch(l){return{rows:[],error:l.message}}},[s]);if(n.error)return(0,e.jsx)("p",{role:"alert",className:"p-4 text-sm text-ink-3",children:n.error});if(!n.rows.length)return(0,e.jsx)("p",{className:"p-4 text-sm text-ink-3",children:"File is empty."});const[a,...i]=n.rows,r=n.rows.reduce((l,d)=>Math.max(l,d.length),0),c=Array.from({length:Math.min(r,I)},(l,d)=>d);return(0,e.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col bg-bg",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-b border-line px-4 py-2 text-xs text-ink-3",role:"status",children:[(0,e.jsx)("span",{className:"font-medium text-ink",children:"CSV preview"}),(0,e.jsxs)("span",{children:[i.length.toLocaleString()," ",i.length===1?"row":"rows"]}),(0,e.jsxs)("span",{children:[r.toLocaleString()," ",r===1?"column":"columns"]}),(i.length>S||r>I)&&(0,e.jsxs)("span",{children:["Showing the first ",Math.min(i.length,S)," rows and ",c.length," columns. Download for the complete file."]})]}),(0,e.jsx)("div",{className:"min-h-0 flex-1 overflow-auto focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus focus-visible:ring-inset",role:"region","aria-label":`${t} CSV table`,tabIndex:0,children:(0,e.jsxs)("table",{className:"w-full border-collapse text-sm",children:[(0,e.jsxs)("caption",{className:"sr-only",children:[t," — first record used as column headers"]}),(0,e.jsx)("thead",{className:"sticky top-0 z-10 bg-bg-3",children:(0,e.jsxs)("tr",{children:[(0,e.jsxs)("th",{scope:"col",className:"w-10 border-b border-line px-3 py-3 text-right font-mono text-xs text-ink-3",children:[(0,e.jsx)("span",{className:"sr-only",children:"Row"}),"#"]}),c.map(l=>(0,e.jsx)("th",{scope:"col",className:"whitespace-nowrap border-b border-line px-4 py-3 text-left font-medium",children:a[l]||`Column ${l+1}`},l))]})}),(0,e.jsx)("tbody",{children:i.slice(0,S).map((l,d)=>(0,e.jsxs)("tr",{className:"even:bg-bg-3/30 hover:bg-bg-3/50",children:[(0,e.jsx)("th",{scope:"row",className:"border-b border-line/50 px-3 py-2 text-right font-mono text-xs font-normal text-ink-3",children:d+1}),c.map(m=>(0,e.jsx)("td",{className:"whitespace-pre-wrap border-b border-line/50 px-4 py-2 align-top",children:l[m]??""},m))]},d))})]})})]})}o(ze,"CsvPreview");function qe({html:s,title:t}){const n=(0,C.useMemo)(()=>Te(s),[s]);return(0,e.jsx)("iframe",{title:`${t} rendered HTML`,srcDoc:n,sandbox:"allow-scripts",referrerPolicy:"no-referrer",allow:"camera 'none'; microphone 'none'; geolocation 'none'; clipboard-read 'none'; clipboard-write 'none'; fullscreen 'none'",className:"block h-full min-h-0 w-full flex-1 border-0 bg-bg"})}o(qe,"HtmlArtifactPreview");function Oe({mode:s,onChange:t,label:n}){return(0,e.jsxs)("div",{className:"flex gap-1",role:"group","aria-label":n,children:[(0,e.jsx)(f,{type:"button",size:"icon-sm",variant:s==="rendered"?"secondary":"ghost","aria-label":"Rendered",title:"Rendered","aria-pressed":s==="rendered",onClick:o(()=>t("rendered"),"onClick"),children:(0,e.jsx)(ue,{"aria-hidden":!0})}),(0,e.jsx)(f,{type:"button",size:"icon-sm",variant:s==="raw"?"secondary":"ghost","aria-label":"Raw",title:"Raw","aria-pressed":s==="raw",onClick:o(()=>t("raw"),"onClick"),children:(0,e.jsx)(he,{"aria-hidden":!0})})]})}o(Oe,"FilePreviewModeToggle");async function Ke(s){if(!s.ok)throw new Error(`Could not load file (${s.status}).`);if(!s.body)throw new Error("The file response is empty.");const t=s.body.getReader(),n=new TextDecoder("utf-8",{fatal:!0});let a=0,i="";try{for(;;){const r=await t.read();if(r.done)break;if(a+=r.value.byteLength,a>524288)throw new Error("This file is too large to preview. Download it instead.");i+=n.decode(r.value,{stream:!0})}if(i+=n.decode(),i.includes("\0"))throw new Error("This file contains binary data. Download it instead.");return i}finally{await t.cancel(),t.releaseLock()}}o(Ke,"readTextPreview");function Ve({title:s,text:t,markdown:n,html:a=!1,csv:i=!1,downloadUrl:r}){const[c,l]=(0,C.useState)("rendered");(0,C.useEffect)(()=>l("rendered"),[s]);const d=i&&c==="rendered"&&t.length>0,m=a&&c==="rendered"&&t.length>0;return(0,e.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,e.jsxs)("header",{className:"flex items-center gap-2 border-b border-line px-3 py-2",children:[(0,e.jsx)("h2",{className:"min-w-0 flex-1 truncate text-sm font-medium",title:s,children:s}),n||a||i?(0,e.jsx)(Oe,{mode:c,onChange:l,label:a?"HTML view":i?"CSV view":"Markdown view"}):null,(0,e.jsx)(f,{asChild:!0,variant:"ghost",size:"icon-sm",children:(0,e.jsx)("a",{href:r,download:!0,"aria-label":`Download ${s}`,title:`Download ${s}`,children:(0,e.jsx)(De,{"aria-hidden":!0})})})]}),(0,e.jsx)("div",{className:m||d?"flex min-h-0 flex-1 flex-col overflow-hidden":"min-h-0 flex-1 overflow-auto p-4",children:t.length===0?(0,e.jsx)("p",{className:"text-sm text-ink-3",children:"File is empty."}):d?(0,e.jsx)(ze,{text:t,title:s}):m?(0,e.jsx)(qe,{html:t,title:s}):n&&c==="rendered"?(0,e.jsx)(me,{mediaMode:"reference",children:t}):(0,e.jsx)("pre",{className:"whitespace-pre-wrap break-words font-mono text-sm","aria-label":`${s} raw text`,children:t})})]})}o(Ve,"TextAttachmentPreview");function gs({issueId:s,attachmentId:t}){const n=T({queryKey:U.issues.attachments(s),queryFn:o(()=>G.listAttachments(s),"queryFn")}),a=n.data?.find(l=>l.id===t),i=a&&$e(a)&&a.byteSize<=524288,r=T({queryKey:["task-text-attachment",s,t],queryFn:o(async({signal:l})=>Ke(await fetch(`/api/attachments/${encodeURIComponent(t)}/content`,{signal:l,credentials:"same-origin"})),"queryFn"),enabled:!!i,retry:!1});if(n.isLoading)return(0,e.jsx)("p",{className:"p-4 text-sm",role:"status",children:"Loading file…"});if(n.isError)return(0,e.jsxs)("div",{className:"p-4",role:"alert",children:["Could not load attachment details. ",(0,e.jsx)(f,{onClick:o(()=>{n.refetch()},"onClick"),children:"Retry"})]});if(!a)return(0,e.jsx)("p",{className:"p-4 text-sm",role:"status",children:"File no longer available. Close this tab or choose another file."});const c=Re(a);return!i||r.isError?(0,e.jsxs)("div",{className:"space-y-3 p-4",role:"alert",children:[(0,e.jsx)("p",{className:"text-sm",children:r.isError?"Could not preview this file. Retry or download it.":"This file is too large or is not supported for text preview. Download it instead."}),i?(0,e.jsx)(f,{onClick:o(()=>{r.refetch()},"onClick"),children:"Retry"}):null,(0,e.jsx)(f,{asChild:!0,variant:"secondary",children:(0,e.jsx)("a",{href:c,download:!0,children:"Download file"})})]}):r.data===void 0?(0,e.jsx)("p",{className:"p-4 text-sm",role:"status",children:"Loading file…"}):(0,e.jsx)(Ve,{title:a.originalFilename??a.id,text:r.data,csv:Fe(a.originalFilename??"",a.contentType),markdown:Ee(a),html:_e(a.contentType,a.originalFilename),downloadUrl:c},a.id)}o(gs,"TaskAttachmentPanel");function bs({browser:s,now:t,disabled:n=!1,onControl:a,onReconnect:i,viewport:r="fit",controlledElsewhere:c=!1,resizing:l=!1,resizeAvailable:d=!0,onResize:m}){const p=s.status==="running"||s.status==="idle",h=s.expiresAt?Date.parse(s.expiresAt):1/0,x=s.idleDeadline?Date.parse(s.idleDeadline):1/0,g=Math.min(x,h),u=Math.max(0,Math.ceil((g-t)/1e3)),w=s.status==="idle"&&u<=300,b=s.status==="idle"&&h>x&&g>t,v=`${Math.floor(u/60)}:${String(u%60).padStart(2,"0")}`,A=r==="fit"?"Fit to pane":M.find(j=>j.id===r)?.label??"Default";return p?(0,e.jsxs)("footer",{"aria-label":"Browser session",className:"flex shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-t px-3 py-2 text-xs text-ink-3",children:[w&&(0,e.jsxs)("span",{role:"timer","aria-live":"off",className:"flex items-center gap-1 whitespace-nowrap",children:[(0,e.jsx)(P,{className:"size-3","aria-hidden":"true"}),u>0?(0,e.jsxs)(e.Fragment,{children:["Closes in"," ",(0,e.jsx)("span",{className:"font-mono tabular-nums",children:v})]}):"Closing…"]}),c&&r==="fit"&&(0,e.jsx)("span",{children:"Size follows another viewer"}),l?(0,e.jsxs)("span",{role:"status",className:"flex items-center gap-1",children:[(0,e.jsx)(pe,{className:"size-3 animate-spin motion-reduce:animate-none","aria-hidden":"true"}),"Resizing…"]}):s.status==="running"&&(0,e.jsx)("span",{children:"Browsing"}),(0,e.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[w&&b&&(0,e.jsxs)($,{children:[(0,e.jsx)(R,{asChild:!0,children:(0,e.jsx)(f,{size:"xs",variant:"ghost",disabled:n,onClick:o(()=>a("keep_open"),"onClick"),children:"Keep browsing"})}),(0,e.jsxs)(E,{children:["Keep this browser open for up to ",6e5/6e4," ","more minutes."]})]}),s.status==="running"&&(0,e.jsxs)($,{children:[(0,e.jsx)(R,{asChild:!0,children:(0,e.jsxs)(f,{size:"xs",variant:"ghost",disabled:n,onClick:o(()=>a("cancel"),"onClick"),children:[(0,e.jsx)(we,{"aria-hidden":"true"})," Stop browsing"]})}),(0,e.jsx)(E,{children:"Stop the agent’s browser work and leave the browser open."})]}),p&&(0,e.jsxs)(ne,{children:[(0,e.jsx)(ae,{asChild:!0,children:(0,e.jsx)(f,{size:"icon-xs",variant:"ghost","aria-label":"Browser options",disabled:n,children:(0,e.jsx)(xe,{"aria-hidden":"true"})})}),(0,e.jsxs)(re,{side:"top",align:"end",className:"w-64",children:[(0,e.jsxs)(ie,{children:[(0,e.jsxs)(se,{disabled:l||!d,children:[(0,e.jsx)(le,{"aria-hidden":"true"}),(0,e.jsx)("span",{children:"Browser size"}),(0,e.jsx)("span",{className:"ml-auto text-xs text-ink-3",children:A})]}),(0,e.jsxs)(ee,{className:"w-64",children:[(0,e.jsx)(Z,{children:"Browser size"}),(0,e.jsxs)(te,{value:r,onValueChange:o(j=>m(j),"onValueChange"),children:[(0,e.jsx)(D,{value:"fit",onSelect:o(()=>{r==="fit"&&m("fit")},"onSelect"),children:"Fit to pane"}),c&&(0,e.jsx)(N,{onSelect:o(()=>m("fit"),"onSelect"),children:"Fit to this pane instead"}),(0,e.jsx)(k,{}),(0,e.jsx)(D,{value:"default",onSelect:o(()=>{r==="default"&&m("default")},"onSelect"),children:"Browser default"}),(0,e.jsx)(k,{}),M.map(j=>(0,e.jsxs)(D,{value:j.id,onSelect:o(()=>{r===j.id&&m(j.id)},"onSelect"),children:[(0,e.jsx)("span",{children:j.label}),(0,e.jsxs)("span",{className:"ml-auto font-mono text-xs tabular-nums text-ink-3",children:[j.width," × ",j.height]})]},j.id))]})]})]}),(0,e.jsx)(k,{}),(0,e.jsxs)(N,{onSelect:i,className:"items-start",children:[(0,e.jsx)(fe,{className:"mt-0.5","aria-hidden":"true"}),(0,e.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,e.jsx)("span",{children:"Reconnect view"}),(0,e.jsx)("span",{className:"text-xs font-normal text-ink-3",children:"Reload the live view. Browser work keeps running."})]})]}),b&&(0,e.jsxs)(N,{onSelect:o(()=>a("keep_open"),"onSelect"),className:"items-start",children:[(0,e.jsx)(P,{className:"mt-0.5","aria-hidden":"true"}),(0,e.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,e.jsx)("span",{children:"Keep browser open"}),(0,e.jsx)("span",{className:"text-xs font-normal text-ink-3",children:"Keep it open for up to 10 more minutes."})]})]}),(0,e.jsx)(k,{}),(0,e.jsxs)(N,{variant:"destructive",onSelect:o(()=>a("end"),"onSelect"),className:"items-start",children:[(0,e.jsx)(ge,{className:"mt-0.5","aria-hidden":"true"}),(0,e.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,e.jsx)("span",{children:"Close browser"}),(0,e.jsx)("span",{className:"text-xs font-normal text-ink-3",children:"End this browser and stop any browsing."})]})]})]})]})]})]}):null}o(bs,"TaskBrowserFooter");function vs({scope:s,canPause:t,canResume:n,canCancel:a,canRestore:i,pending:r,onPause:c,onResume:l,onCancel:d,onRestore:m}){const p="flex items-center gap-2 w-full px-2 py-1.5 text-xs rounded hover:bg-bg-3/50 disabled:opacity-50 disabled:pointer-events-none";return(0,e.jsxs)(e.Fragment,{children:[t?(0,e.jsxs)("button",{disabled:r,className:p,onClick:c,children:[(0,e.jsx)(Me,{className:"h-3 w-3"}),s==="leaf"?"Pause work":"Pause subtree"]}):null,n?(0,e.jsxs)("button",{disabled:r,className:p,onClick:l,children:[(0,e.jsx)(Se,{className:"h-3 w-3"}),s==="leaf"?"Resume work":"Resume subtree"]}):null,a?(0,e.jsxs)("button",{disabled:r,className:`${p} text-bad`,onClick:d,children:[(0,e.jsx)(de,{className:"h-3 w-3"}),"Cancel subtree..."]}):null,i?(0,e.jsxs)("button",{disabled:r,className:p,onClick:m,children:[(0,e.jsx)(je,{className:"h-3 w-3"}),"Restore subtree..."]}):null]})}o(vs,"TaskTreeControlMenuItems");function ks({open:s,onOpenChange:t,mode:n,scope:a,affectedCount:i,affectedAgentCount:r,loading:c,error:l,pending:d,valid:m,wakeAgents:p,onWakeAgentsChange:h,onRetry:x,onApply:g}){const u=n==="cancel",w=`${i} task${i===1?"":"s"}`,b=u?"Cancel subtree?":n==="restore"?"Restore subtree":a==="leaf"?"Resume work":"Resume subtree";return(0,e.jsx)(Ce,{open:s,onOpenChange:o(v=>{d||t(v)},"onOpenChange"),children:(0,e.jsxs)(ke,{showCloseButton:!d,className:"max-h-(--sz-calc-18) overflow-y-auto sm:max-w-sm",children:[(0,e.jsxs)(be,{children:[(0,e.jsx)(ye,{children:b}),(0,e.jsx)(Ne,{children:c?"Loading…":u?`${w} will be cancelled.`:`${w} will ${n==="restore"?"be restored":"resume"}.`})]}),l?(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsx)("p",{role:"alert",className:"text-sm text-bad",children:l}),(0,e.jsx)(f,{size:"sm",variant:"secondary",disabled:d,onClick:x,children:"Retry preview"})]}):null,u?null:(0,e.jsxs)("label",{className:"flex items-center gap-2 text-sm",children:[(0,e.jsx)("input",{type:"checkbox",checked:p,disabled:d||c||r===0,onChange:o(v=>h(v.target.checked),"onChange")}),"Wake affected agents (",r,")"]}),(0,e.jsxs)(ve,{children:[(0,e.jsx)(f,{variant:"secondary",disabled:d,onClick:o(()=>t(!1),"onClick"),children:u?"Keep tasks":"Close"}),(0,e.jsx)(f,{variant:u?"danger":"primary",disabled:d||c||!!l||!m,onClick:g,children:d?"Applying…":u?`Cancel ${w}`:n==="restore"?`Restore ${w}`:b})]})]})})}o(ks,"TaskTreeControlDialog");export{Ve as a,ze as c,gs as i,Fe as l,vs as n,Oe as o,bs as r,qe as s,ks as t,ws as u};
@@ -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,la as St,t as st,ua as Ct}from"./createLucideIcon-CgrPXnTY.js";import{a as wt,n as At}from"./star-eem0qj3E.js";import{X as nt,_ as U,t as Ve,v as pe}from"./queryKeys-BzT8CD34.js";import{a as z,i as Et,n as K,r as V,t as Ht}from"./TerminalView-CWvRC4uL.js";import{n as Mt}from"./CompanyContext-fQCNWI_f.js";import{t as Kt}from"./router-BKzUF9uf.js";import{n as Tt,r as zt,t as Pt}from"./collapsible-D_rwONtV.js";import{t as _t}from"./label-B707hSFt.js";import{t as $t}from"./check-Bis3vECb.js";import{t as Ft}from"./chevron-down-nRcQ7bok.js";import{t as Lt}from"./circle-x-oLE71NY3.js";import{t as Ot}from"./cloud-DX1fkQ6i.js";import{t as Rt}from"./copy-C1cfcpxY.js";import{t as We}from"./key-round-CGxQxRtN.js";import{r as de,t as g}from"./button-DI4w5WP7.js";import{t as at}from"./plus-CwNlqadt.js";import{t as ee}from"./server-NjSlblAR.js";import{t as Dt}from"./shield-question-mark-Dl8dxzUU.js";import{t as Bt}from"./triangle-alert-CnHMpmva.js";import{t as qt}from"./x-6E1yeU3Q.js";import{a as it,i as Qt,n as rt,r as ot,s as lt,t as ct}from"./dialog-CeH7rDcv.js";import{t as Q}from"./input-BBNGmECW.js";import{t as Zt}from"./access-DhB95qNC.js";import{n as Jt}from"./BreadcrumbContext-DNbB7zWn.js";import{a as Ut,i as Ce,o as Te,r as Vt,s as Wt,t as Xt}from"./command-BnJHDVFJ.js";import{t as Yt}from"./textarea-CTx68BDs.js";import{t as Xe}from"./select-DNiRU1d9.js";import{t as Gt}from"./environments-xuhuvnTt.js";import{t as It}from"./use-copy-action-DFzauB4H.js";import{n as es,t as ts}from"./segmented-tuNVx49H.js";import{Ia as ss,ka as Fe}from"./index-D1wQsid4.js";import{n as ns,r as as,t as is}from"./resizable-panels-DkafPiQi.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(Ct(),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(St(),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??""),[Z,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)),[J,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:Z)??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},Ze=!!(S.alias||S.hostName||S.user||S.port||S.key||S.keepAlive||S.countMax),H=s((a,k)=>J||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")}),Je=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),!Ze&&Ne.mutate({settings:Me(),openTerminal:a})},"submit"),bt=s(()=>{re(!0),!Ze&&(he(null),ce.mutate(Me()))},"runTest"),xe=Ne.isPending||Je.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)(es,{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:J?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":!!(J&&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,J&&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?Je.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)(ss,{"aria-hidden":!0})}):null]})})},`${M}${o.id}`)},"configHostItem"),Z=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-"):Z(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=>Z(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(()=>Zt.getCurrentBoardAccess(),"queryFn")}),A=Et(X.data),E=pe({queryKey:l,queryFn:s(()=>K.list(t),"queryFn")}),Z=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)(()=>(Z.data??[]).filter(n=>n.driver==="ssh"),[Z.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"),J=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:Z.isLoading,recent:F,tests:W,busy:O||he.isPending,onOpenHost:ie,onOpenEnvironment:Ee,onAddHost:s(()=>J({kind:"add"}),"onAddHost"),onEditHost:s(n=>{n.settings&&J({kind:"edit",settings:n.settings})},"onEditHost"),onMoveSaved:s(n=>J({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 cn(){const{selectedCompanyId:t}=Mt(),{setBreadcrumbs:r}=Jt();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(cn,"Terminal");export{cn 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,la as St,t as st,ua as Ct}from"./createLucideIcon-CgrPXnTY.js";import{a as wt,n as At}from"./star-eem0qj3E.js";import{X as nt,_ as U,t as Ve,v as pe}from"./queryKeys-BzT8CD34.js";import{a as z,i as Et,n as K,r as V,t as Ht}from"./TerminalView-DDv6s-R_.js";import{n as Mt}from"./CompanyContext-fQCNWI_f.js";import{t as Kt}from"./router-CJbFZfVR.js";import{n as Tt,r as zt,t as Pt}from"./collapsible-D_rwONtV.js";import{t as _t}from"./label-B707hSFt.js";import{t as $t}from"./check-Bis3vECb.js";import{t as Ft}from"./chevron-down-nRcQ7bok.js";import{t as Lt}from"./circle-x-oLE71NY3.js";import{t as Ot}from"./cloud-DX1fkQ6i.js";import{t as Rt}from"./copy-C1cfcpxY.js";import{t as We}from"./key-round-CGxQxRtN.js";import{r as de,t as g}from"./button-DI4w5WP7.js";import{t as at}from"./plus-CwNlqadt.js";import{t as ee}from"./server-NjSlblAR.js";import{t as Dt}from"./shield-question-mark-Dl8dxzUU.js";import{t as Bt}from"./triangle-alert-CnHMpmva.js";import{t as qt}from"./x-6E1yeU3Q.js";import{a as it,i as Qt,n as rt,r as ot,s as lt,t as ct}from"./dialog-CeH7rDcv.js";import{t as Q}from"./input-BBNGmECW.js";import{t as Zt}from"./access-DhB95qNC.js";import{n as Jt}from"./BreadcrumbContext-DNbB7zWn.js";import{a as Ut,i as Ce,o as Te,r as Vt,s as Wt,t as Xt}from"./command-BnJHDVFJ.js";import{t as Yt}from"./textarea-CTx68BDs.js";import{t as Xe}from"./select-DNiRU1d9.js";import{t as Gt}from"./environments-xuhuvnTt.js";import{t as It}from"./use-copy-action-DFzauB4H.js";import{n as es,t as ts}from"./segmented-tuNVx49H.js";import{Aa as Fe,La as ss}from"./index-QhteFtm-.js";import{n as ns,r as as,t as is}from"./resizable-panels-DkafPiQi.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(Ct(),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(St(),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??""),[Z,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)),[J,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:Z)??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},Ze=!!(S.alias||S.hostName||S.user||S.port||S.key||S.keepAlive||S.countMax),H=s((a,k)=>J||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")}),Je=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),!Ze&&Ne.mutate({settings:Me(),openTerminal:a})},"submit"),bt=s(()=>{re(!0),!Ze&&(he(null),ce.mutate(Me()))},"runTest"),xe=Ne.isPending||Je.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)(es,{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:J?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":!!(J&&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,J&&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?Je.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)(ss,{"aria-hidden":!0})}):null]})})},`${M}${o.id}`)},"configHostItem"),Z=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-"):Z(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=>Z(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(()=>Zt.getCurrentBoardAccess(),"queryFn")}),A=Et(X.data),E=pe({queryKey:l,queryFn:s(()=>K.list(t),"queryFn")}),Z=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)(()=>(Z.data??[]).filter(n=>n.driver==="ssh"),[Z.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"),J=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:Z.isLoading,recent:F,tests:W,busy:O||he.isPending,onOpenHost:ie,onOpenEnvironment:Ee,onAddHost:s(()=>J({kind:"add"}),"onAddHost"),onEditHost:s(n=>{n.settings&&J({kind:"edit",settings:n.settings})},"onEditHost"),onMoveSaved:s(n=>J({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 cn(){const{selectedCompanyId:t}=Mt(),{setBreadcrumbs:r}=Jt();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(cn,"Terminal");export{cn as Terminal};