@overlordai/server 1.0.116 → 1.0.118

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 (181) hide show
  1. package/database/migrations/006-task-source.sql +5 -0
  2. package/dist/adapters/command-parser.utils.d.ts +7 -0
  3. package/dist/adapters/command-parser.utils.d.ts.map +1 -1
  4. package/dist/adapters/command-parser.utils.js +48 -5
  5. package/dist/adapters/command-parser.utils.js.map +1 -1
  6. package/dist/adapters/help-text.d.ts.map +1 -1
  7. package/dist/adapters/help-text.js +1 -0
  8. package/dist/adapters/help-text.js.map +1 -1
  9. package/dist/adapters/lark/lark-card.builder.d.ts +4 -1
  10. package/dist/adapters/lark/lark-card.builder.d.ts.map +1 -1
  11. package/dist/adapters/lark/lark-card.builder.js +4 -1
  12. package/dist/adapters/lark/lark-card.builder.js.map +1 -1
  13. package/dist/adapters/lark/lark-message.parser.d.ts.map +1 -1
  14. package/dist/adapters/lark/lark-message.parser.js +2 -0
  15. package/dist/adapters/lark/lark-message.parser.js.map +1 -1
  16. package/dist/adapters/lark/lark.adapter.d.ts +1 -1
  17. package/dist/adapters/lark/lark.adapter.d.ts.map +1 -1
  18. package/dist/adapters/lark/lark.adapter.js +3 -20
  19. package/dist/adapters/lark/lark.adapter.js.map +1 -1
  20. package/dist/adapters/lark/lark.controller.d.ts.map +1 -1
  21. package/dist/adapters/lark/lark.controller.js +2 -1
  22. package/dist/adapters/lark/lark.controller.js.map +1 -1
  23. package/dist/adapters/slack/slack-block.builder.d.ts +4 -1
  24. package/dist/adapters/slack/slack-block.builder.d.ts.map +1 -1
  25. package/dist/adapters/slack/slack-block.builder.js +4 -1
  26. package/dist/adapters/slack/slack-block.builder.js.map +1 -1
  27. package/dist/adapters/slack/slack-message.parser.d.ts.map +1 -1
  28. package/dist/adapters/slack/slack-message.parser.js +2 -0
  29. package/dist/adapters/slack/slack-message.parser.js.map +1 -1
  30. package/dist/adapters/slack/slack.controller.d.ts.map +1 -1
  31. package/dist/adapters/slack/slack.controller.js +4 -2
  32. package/dist/adapters/slack/slack.controller.js.map +1 -1
  33. package/dist/common/string-utils.d.ts +1 -1
  34. package/dist/common/string-utils.d.ts.map +1 -1
  35. package/dist/common/string-utils.js.map +1 -1
  36. package/dist/database/repositories/task.repository.d.ts +13 -0
  37. package/dist/database/repositories/task.repository.d.ts.map +1 -1
  38. package/dist/database/repositories/task.repository.js +27 -2
  39. package/dist/database/repositories/task.repository.js.map +1 -1
  40. package/dist/dispatcher/dispatcher.service.d.ts +18 -0
  41. package/dist/dispatcher/dispatcher.service.d.ts.map +1 -1
  42. package/dist/dispatcher/dispatcher.service.js +61 -10
  43. package/dist/dispatcher/dispatcher.service.js.map +1 -1
  44. package/dist/dispatcher/scheduler.service.d.ts.map +1 -1
  45. package/dist/dispatcher/scheduler.service.js +1 -0
  46. package/dist/dispatcher/scheduler.service.js.map +1 -1
  47. package/dist/dispatcher/task-creation.service.d.ts +4 -1
  48. package/dist/dispatcher/task-creation.service.d.ts.map +1 -1
  49. package/dist/dispatcher/task-creation.service.js +87 -14
  50. package/dist/dispatcher/task-creation.service.js.map +1 -1
  51. package/dist/dispatcher/task-lifecycle.service.d.ts +5 -0
  52. package/dist/dispatcher/task-lifecycle.service.d.ts.map +1 -1
  53. package/dist/dispatcher/task-lifecycle.service.js +21 -32
  54. package/dist/dispatcher/task-lifecycle.service.js.map +1 -1
  55. package/dist/dispatcher/task-name.service.d.ts.map +1 -1
  56. package/dist/dispatcher/task-name.service.js +9 -2
  57. package/dist/dispatcher/task-name.service.js.map +1 -1
  58. package/dist/notifier/notification-consumer.d.ts.map +1 -1
  59. package/dist/notifier/notification-consumer.js +5 -0
  60. package/dist/notifier/notification-consumer.js.map +1 -1
  61. package/dist/notifier/template.service.d.ts +14 -10
  62. package/dist/notifier/template.service.d.ts.map +1 -1
  63. package/dist/notifier/template.service.js +6 -0
  64. package/dist/notifier/template.service.js.map +1 -1
  65. package/dist/web/dashboard.controller.d.ts +18 -1
  66. package/dist/web/dashboard.controller.d.ts.map +1 -1
  67. package/dist/web/dashboard.controller.js +8 -8
  68. package/dist/web/dashboard.controller.js.map +1 -1
  69. package/dist/web/dashboard.service.d.ts +4 -0
  70. package/dist/web/dashboard.service.d.ts.map +1 -1
  71. package/dist/web/dashboard.service.js +44 -8
  72. package/dist/web/dashboard.service.js.map +1 -1
  73. package/dist/web/frame-handlers/stage-choice.handler.d.ts.map +1 -1
  74. package/dist/web/frame-handlers/stage-choice.handler.js +2 -15
  75. package/dist/web/frame-handlers/stage-choice.handler.js.map +1 -1
  76. package/dist/web/frame-handlers/stage-input.handler.d.ts.map +1 -1
  77. package/dist/web/frame-handlers/stage-input.handler.js +2 -15
  78. package/dist/web/frame-handlers/stage-input.handler.js.map +1 -1
  79. package/dist/web/frame-handlers/stage-request.shared.d.ts +15 -0
  80. package/dist/web/frame-handlers/stage-request.shared.d.ts.map +1 -0
  81. package/dist/web/frame-handlers/stage-request.shared.js +23 -0
  82. package/dist/web/frame-handlers/stage-request.shared.js.map +1 -0
  83. package/dist/web/task.controller.d.ts +9 -2
  84. package/dist/web/task.controller.d.ts.map +1 -1
  85. package/dist/web/task.controller.js +50 -12
  86. package/dist/web/task.controller.js.map +1 -1
  87. package/package.json +4 -4
  88. package/public/assets/{AccessTokensPage-D-_JP0Z8.js → AccessTokensPage-B3Ki6jgv.js} +1 -1
  89. package/public/assets/{AdminPage-CySIH4U-.js → AdminPage-DSuTmiqH.js} +1 -1
  90. package/public/assets/AgentCliPage-BJ68qLD8.js +3 -0
  91. package/public/assets/ApiReferencePage-C2lpXXtB.js +1 -0
  92. package/public/assets/{ArchitecturePage-C7v0Z92r.js → ArchitecturePage-CxuPmzT4.js} +1 -1
  93. package/public/assets/{AuditLogPage-CsphA5YO.js → AuditLogPage-Dl8WOLtG.js} +2 -2
  94. package/public/assets/{BindPlatformPage-CNUW9Ksf.js → BindPlatformPage-D8pnesZ3.js} +1 -1
  95. package/public/assets/{BotIntegrationPage-nZAsD9JD.js → BotIntegrationPage-DPNm6k0v.js} +1 -1
  96. package/public/assets/{BotManage-DmXnxLHi.js → BotManage-BPVY5Pxr.js} +1 -1
  97. package/public/assets/{BotSetupPage-Cwo0we6j.js → BotSetupPage-BMiW1XQs.js} +1 -1
  98. package/public/assets/{ChangelogPage-DAEorW2o.js → ChangelogPage-C9CtG6dA.js} +1 -1
  99. package/public/assets/CliReferencePage-D_OZP4jY.js +14 -0
  100. package/public/assets/{DeploymentPage-3S7iFhaz.js → DeploymentPage-CYUEJybV.js} +1 -1
  101. package/public/assets/{DevWorkflowPage-CNJyqNjy.js → DevWorkflowPage-DnLpChdc.js} +1 -1
  102. package/public/assets/DeveloperManage-BxIKNTos.js +16 -0
  103. package/public/assets/{DeveloperSetupPage-BEHNZPRe.js → DeveloperSetupPage-CSrtR7UE.js} +1 -1
  104. package/public/assets/DocsIndexPage-yV9ar0Ls.js +31 -0
  105. package/public/assets/{DocsLayout-evXBWB6C.js → DocsLayout-B72f6RC9.js} +1 -1
  106. package/public/assets/{DocsPrimitives-Dc1wNk4g.js → DocsPrimitives-DamRKfUw.js} +1 -1
  107. package/public/assets/{EditProjectPage-BtbVjWkv.js → EditProjectPage-BIGa7GPh.js} +2 -2
  108. package/public/assets/{EmptyState-D3ZrUiqM.js → EmptyState-DSlrUDxV.js} +1 -1
  109. package/public/assets/{EnvVariablesPage-B1qD9DZR.js → EnvVariablesPage-BExxi9ZU.js} +1 -1
  110. package/public/assets/HomePage-lLL6TaUS.js +1 -0
  111. package/public/assets/{InfoRow-jft-2rwq.js → InfoRow-B0PKkcID.js} +1 -1
  112. package/public/assets/{InstallationPage-9BatqCGD.js → InstallationPage-Dp_6jq_t.js} +1 -1
  113. package/public/assets/{LandingPage-B4jOq8Yj.js → LandingPage-Ch0xRP4p.js} +1 -1
  114. package/public/assets/{LocalDevelopmentPage-DDBAQ9l3.js → LocalDevelopmentPage-Bw0z4F2f.js} +1 -1
  115. package/public/assets/{LoginPage-BUv-0LPZ.js → LoginPage-CG3UqTSX.js} +1 -1
  116. package/public/assets/{MetricBar-BdjXhynk.js → MetricBar-qvotCrRD.js} +1 -1
  117. package/public/assets/{NotFoundPage-DQ0HCSB0.js → NotFoundPage-Cd_OEZ9c.js} +1 -1
  118. package/public/assets/{OnboardingGuide-DUjDsOWd.js → OnboardingGuide-Y5FYHSft.js} +1 -1
  119. package/public/assets/{PermissionsPage-BHXwJrTQ.js → PermissionsPage-DA9ApovI.js} +1 -1
  120. package/public/assets/{PipelineConfigPage-BydzFSeF.js → PipelineConfigPage-Cl7MHbIs.js} +1 -1
  121. package/public/assets/{PipelineEditorPage-sDh0zE1O.js → PipelineEditorPage-BzF-4d7B.js} +2 -2
  122. package/public/assets/{ProfilePage-vqDLYD9D.js → ProfilePage-DExKdRAk.js} +1 -1
  123. package/public/assets/{ProjectDetailPage-DkaTA6uP.js → ProjectDetailPage-DncFVglm.js} +3 -3
  124. package/public/assets/{ProjectListPage-BmbOvxv2.js → ProjectListPage-DvrZyCHv.js} +1 -1
  125. package/public/assets/{PtyTerminal-uTPQuuyD.js → PtyTerminal-DyOs4Ihi.js} +1 -1
  126. package/public/assets/{QuickAuth-kT7FOqXf.js → QuickAuth-CR5Cvx3y.js} +1 -1
  127. package/public/assets/{RemoveMemberConfirmDialog-G_YZFN4m.js → RemoveMemberConfirmDialog-Idi4LhTn.js} +2 -2
  128. package/public/assets/{Select-DI-7imsE.js → Select-Drhq3WPg.js} +1 -1
  129. package/public/assets/{SettingsPage-DVqpQfz_.js → SettingsPage-DL8hUPnJ.js} +1 -1
  130. package/public/assets/{Skeleton-C981QVgn.js → Skeleton-C2wkNF0Q.js} +1 -1
  131. package/public/assets/{SkillPage-CIIJGGm9.js → SkillPage-CaLDOeXG.js} +1 -1
  132. package/public/assets/TaskDetailPage-B2CSp4d7.js +26 -0
  133. package/public/assets/TaskListPage-CCZSWZzh.js +1 -0
  134. package/public/assets/{TaskStatusBadge-ARdIi_Cf.js → TaskStatusBadge-ZmJh27Un.js} +1 -1
  135. package/public/assets/{TerminalHomePage-BAAfxz5X.js → TerminalHomePage-Bxtc9usu.js} +2 -2
  136. package/public/assets/TokenManage-DU2Oq2C7.js +1 -0
  137. package/public/assets/Tooltip-BdD7q141.js +1 -0
  138. package/public/assets/{TotpSetupPage-BqtF2cCA.js → TotpSetupPage-Cq5dRRhe.js} +1 -1
  139. package/public/assets/WorkerDetailPage-kFW7HF9T.js +1 -0
  140. package/public/assets/{WorkerListPage-CZQDVNRU.js → WorkerListPage-CW2SKxgY.js} +2 -2
  141. package/public/assets/{WorkerOperationsPage-DuFDjY18.js → WorkerOperationsPage-iDVSho2X.js} +1 -1
  142. package/public/assets/{WorkerSetupGuidePage-RX_HcxUB.js → WorkerSetupGuidePage-CVg9l1Wm.js} +1 -1
  143. package/public/assets/{WorkerSetupPage-BhcUZDUx.js → WorkerSetupPage-Cd07qhHw.js} +1 -1
  144. package/public/assets/{arrow-left-DsFI8vyj.js → arrow-left-BrI9Fcz8.js} +1 -1
  145. package/public/assets/{arrow-right-N9mDbkmW.js → arrow-right-CQ5YuGdQ.js} +1 -1
  146. package/public/assets/{bot-Dmw45daR.js → bot-CNtUJy5P.js} +1 -1
  147. package/public/assets/{chevron-right-CaN0g8DP.js → chevron-right-5Y_vn1kG.js} +1 -1
  148. package/public/assets/{copy-DHDPffJp.js → copy-1Kaayp-g.js} +1 -1
  149. package/public/assets/{download-DnmqfM-x.js → download-CAjpjHtL.js} +1 -1
  150. package/public/assets/{external-link-C4HDOE7N.js → external-link-CsjY7LBd.js} +1 -1
  151. package/public/assets/git-fork-BOtX0t5m.js +6 -0
  152. package/public/assets/{index-ChW26424.js → index-BZ8Ay5Q7.js} +12 -12
  153. package/public/assets/{index-BiItJ2NI.css → index-D4RS0YML.css} +1 -1
  154. package/public/assets/{key-CV1tBpjw.js → key-BK7i2VYG.js} +1 -1
  155. package/public/assets/{loader-circle-D-_56V0I.js → loader-circle-wZMLiMDW.js} +1 -1
  156. package/public/assets/{pencil-CsYReuzP.js → pencil-D9XPxmN6.js} +1 -1
  157. package/public/assets/{plus-CQMXvSQ5.js → plus-WIoVlw4A.js} +1 -1
  158. package/public/assets/{rotate-ccw-C7yub8YZ.js → rotate-ccw-BBWLasDm.js} +1 -1
  159. package/public/assets/{scroll-text-WXJHU8CZ.js → scroll-text-Cb6XTI8V.js} +1 -1
  160. package/public/assets/{settings-DhM5ZmgU.js → settings-CKdRWwOX.js} +1 -1
  161. package/public/assets/{status-colors-B_811zpf.js → status-colors-ClM8Aa8i.js} +1 -1
  162. package/public/assets/task-constants-67tyYZHJ.js +1 -0
  163. package/public/assets/{trash-2-BDksDzRX.js → trash-2-DkQiJox8.js} +1 -1
  164. package/public/assets/{useFetch-Lyui3S2c.js → useFetch-CjoCsmky.js} +1 -1
  165. package/public/assets/{users-s-R7THRt.js → users-DNKZ23nH.js} +1 -1
  166. package/public/assets/{wifi-lJpr616j.js → wifi-CEl4Ck1T.js} +1 -1
  167. package/public/assets/{workflow-DRHDZrHA.js → workflow-DckxnEQT.js} +1 -1
  168. package/public/index.html +2 -2
  169. package/public/sw.js +1 -1
  170. package/public/assets/ApiReferencePage-ENtAJGE1.js +0 -1
  171. package/public/assets/CliReferencePage-COt_rcFM.js +0 -14
  172. package/public/assets/DeveloperManage-b6olIsTU.js +0 -16
  173. package/public/assets/DocsIndexPage-CM-gCI9d.js +0 -26
  174. package/public/assets/HomePage-Dy_oJ2jn.js +0 -1
  175. package/public/assets/TaskDetailPage-DzwfIvR9.js +0 -21
  176. package/public/assets/TaskListPage-DQkWI_vh.js +0 -1
  177. package/public/assets/TokenManage-QPSNhYpL.js +0 -1
  178. package/public/assets/Tooltip-D3Tg2zpI.js +0 -1
  179. package/public/assets/WorkerDetailPage-DkeEFUeU.js +0 -1
  180. package/public/assets/task-constants-Dkd_Zl1S.js +0 -1
  181. package/public/assets/task-display-B5YOr3b8.js +0 -1
@@ -0,0 +1,26 @@
1
+ import{c as J,a as Q,r,h as b,j as e,M as rt,w as P,H as nt,t as V,p as be,x as lt,f as ct,y as it,o as ot,l as pe,k as qe,n as T,L as xt,X as ue,z as Ue,s as dt,G as mt}from"./index-BZ8Ay5Q7.js";import{u as pt,T as ut}from"./task-constants-67tyYZHJ.js";import{C as ht,H as Ge,P as ze}from"./PtyTerminal-DyOs4Ihi.js";import{a as ft,f as ae}from"./date-BdNtiQTP.js";import{S as vt}from"./Select-Drhq3WPg.js";import{a as bt}from"./status-colors-ClM8Aa8i.js";import{T as gt}from"./Tooltip-BdD7q141.js";import{A as jt}from"./arrow-left-BrI9Fcz8.js";import{R as he}from"./rotate-ccw-BBWLasDm.js";import{G as Nt}from"./git-fork-BOtX0t5m.js";import{E as yt}from"./external-link-CsjY7LBd.js";import{L as fe}from"./loader-circle-wZMLiMDW.js";/**
2
+ * @license lucide-react v0.469.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const Ke=J("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
7
+ * @license lucide-react v0.469.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const kt=J("ListOrdered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);/**
12
+ * @license lucide-react v0.469.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const wt=J("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
17
+ * @license lucide-react v0.469.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const _t=J("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
22
+ * @license lucide-react v0.469.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const Ct=J("SkipForward",[["polygon",{points:"5 4 15 12 5 20 5 4",key:"16p6eg"}],["line",{x1:"19",x2:"19",y1:"5",y2:"19",key:"futhcm"}]]);function Be({isOpen:c,onClose:i,taskId:a,stageName:n,timeoutSeconds:t,onSubmitted:x}){const{t:o}=Q(),[g,u]=r.useState(t),[D,w]=r.useState(!1);r.useEffect(()=>{if(!c)return;u(t);const d=setInterval(()=>{u(N=>N<=1?(clearInterval(d),0):N-1)},1e3);return()=>clearInterval(d)},[c,t]),r.useEffect(()=>{g===0&&c&&i()},[g,c,i]);const $=r.useCallback(async d=>{w(!0);try{await b.post(`web/tasks/${a}/confirm-stage`,{json:{stageName:n,approved:d}}),x==null||x(),i()}catch{}finally{w(!1)}},[a,n,i,x]);return c?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{backdropFilter:"blur(2px)"},children:[e.jsx("div",{className:"fixed inset-0 bg-[var(--modal-backdrop)]"}),e.jsxs("div",{className:"relative z-10 w-full max-w-[480px] rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] font-mono",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] px-5 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(rt,{className:"h-4 w-4 text-[var(--accent)]"}),e.jsxs("h3",{className:"text-sm text-[var(--text-primary)]",children:["// stage: ",n]})]}),e.jsxs("span",{className:"flex items-center gap-1 text-xs text-[var(--text-muted)]",children:[e.jsx(ht,{className:"h-3.5 w-3.5"}),ft(g)]})]}),e.jsx("div",{className:"space-y-4 px-5 py-5",children:e.jsx("p",{className:"whitespace-pre-wrap text-xs text-[var(--text-primary)]",children:o("tasks.confirm_stage_message",{name:n})})}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-[var(--border)] px-5 py-4",children:[e.jsx("button",{type:"button",className:"rounded-[4px] border border-[var(--border)] px-3 py-1.5 text-xs text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors disabled:opacity-50",disabled:D,onClick:()=>$(!1),children:o("tasks.reject")}),e.jsx("button",{type:"button",className:"rounded-[4px] bg-[var(--accent)] px-3 py-1.5 text-xs text-black hover:opacity-90 transition-opacity disabled:opacity-50",disabled:D,onClick:()=>$(!0),children:o(D?"tasks.stage_submitting":"tasks.confirm_and_proceed")})]})]})]}):null}function St(c,i){const a=new Date(c).getTime()-Date.now();if(a<=0)return i("tasks.tunnel_expired");const n=Math.floor(a/36e5),t=Math.floor(a%36e5/6e4);return n>0?i("tasks.tunnel_expires_hm",{h:n,m:t}):i("tasks.tunnel_expires_m",{m:t})}function We(c){switch(c){case"CONNECTED":return"var(--accent)";case"STARTING":return"var(--warning)";case"EXPIRED":return"var(--text-muted)";default:return"var(--text-muted)"}}function Xe(c,i){switch(c){case"IDLE":case"CLOSED":return i("tasks.tunnel_idle");case"STARTING":return i("tasks.tunnel_starting");case"CONNECTED":return i("tasks.tunnel_connected");case"EXPIRED":return i("tasks.tunnel_expired");case"CLOSING":return i("tasks.tunnel_closing");default:return String(c).toLowerCase()}}function Et({taskId:c,taskFinished:i,compact:a}){const{t:n}=Q(),[t,x]=r.useState(P.IDLE),[o,g]=r.useState(null),[u,D]=r.useState(null),[w,$]=r.useState(""),[d,N]=r.useState(!1),[ne,F]=r.useState(!1),A=r.useRef(null),I=r.useCallback(async()=>{try{const f=await b.get(`web/workspace-tunnel/${c}/status`).json();x(f.status),g(f.tunnelUrl??null),D(f.expiresAt??null),(f.status==="EXPIRED"||f.status==="IDLE"||f.status==="CLOSED")&&_()}catch{}},[c]);function le(){_(),A.current=setInterval(I,5e3)}function _(){A.current&&(clearInterval(A.current),A.current=null)}r.useEffect(()=>{i&&(t===P.STARTING||t===P.CONNECTED)&&(x(P.IDLE),g(null),_())},[i,t]),r.useEffect(()=>{if(t!=="CONNECTED"||!u)return;const f=()=>{const C=St(u,n);$(C),C===n("tasks.tunnel_expired")&&(x(P.EXPIRED),g(null),_())};f();const L=setInterval(f,3e4);return()=>clearInterval(L)},[t,u]),r.useEffect(()=>()=>_(),[]),r.useEffect(()=>{i||I()},[I,i]);async function z(){N(!0);try{await b.post(`web/workspace-tunnel/${c}/start`),x(P.STARTING),le()}catch(f){let L=n("tasks.tunnel_start_failed");try{if(f instanceof nt){const C=await f.response.json();C!=null&&C.error&&(L=C.error,/code.*not found|ENOENT.*code|spawn code/i.test(L)&&(L+=". "+n("tasks.tunnel_install_code_hint")))}}catch{}V.error(L)}finally{N(!1)}}async function K(){N(!0);try{await b.post(`web/workspace-tunnel/${c}/stop`),x(P.IDLE),g(null),_()}catch{}finally{N(!1)}}async function ce(){o&&(await navigator.clipboard.writeText(o),F(!0),setTimeout(()=>F(!1),2e3))}return a?e.jsxs("div",{className:"flex items-center gap-2 font-mono lowercase text-xs",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"ide_tunnel:"}),e.jsx("span",{style:{color:We(t)},children:Xe(t,n)}),(t==="IDLE"||t==="CLOSED"||t==="EXPIRED")&&e.jsx("button",{onClick:z,disabled:d,className:"rounded-[4px] px-2 py-1 text-[var(--info)] disabled:opacity-50",style:{backgroundColor:"rgba(59,130,246,0.12)"},children:n(d?"tasks.tunnel_starting":"tasks.tunnel_start")}),t==="CONNECTED"&&o&&e.jsx("a",{href:o.replace(/^https?:/,"cursor:"),target:"_blank",rel:"noopener noreferrer",className:"rounded-[4px] px-2 py-1 text-[var(--info)]",style:{backgroundColor:"rgba(59,130,246,0.12)"},children:n("tasks.tunnel_open_in_cursor")})]}):e.jsxs("div",{className:"rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4 font-mono lowercase",children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:n("tasks.tunnel_header")}),e.jsxs("span",{className:"text-xs",style:{color:We(t)},children:["● ",Xe(t,n)]})]}),t==="CONNECTED"&&u&&e.jsxs("p",{className:"mb-2 text-xs text-[var(--text-muted)]",children:["// ",w]}),t==="CONNECTED"&&o&&e.jsxs("div",{className:"mb-3 flex items-center gap-2 rounded-[4px] border border-[var(--border)] bg-[var(--bg-primary)] px-3 py-2",children:[e.jsx("code",{className:"flex-1 truncate text-xs text-[var(--text-primary)]",children:o}),e.jsxs("button",{onClick:ce,className:"shrink-0 text-xs text-[var(--text-muted)] hover:text-[var(--text-primary)] transition-colors","aria-label":n("tasks.tunnel_copy_url"),children:["[",n("common.copy"),"]"]})]}),ne&&e.jsx("p",{className:"mb-2 text-xs text-[var(--accent)]",children:n("tasks.tunnel_copied")}),t==="STARTING"&&e.jsx("p",{className:"mb-3 text-xs text-[var(--text-muted)]",children:n("tasks.tunnel_waiting")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[(t==="IDLE"||t==="CLOSED")&&e.jsx("button",{onClick:z,disabled:d,className:"rounded-[4px] border border-[var(--accent)]/40 px-3 py-1.5 text-[var(--accent)] hover:bg-[var(--accent)]/10 transition-colors disabled:opacity-50",children:n(d?"tasks.tunnel_starting_button":"tasks.tunnel_start_button")}),t==="STARTING"&&e.jsx("button",{onClick:K,disabled:d,className:"rounded-[4px] border border-[var(--border)] px-3 py-1.5 text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors disabled:opacity-50",children:n(d?"tasks.tunnel_stopping":"tasks.tunnel_cancel")}),t==="CONNECTED"&&o&&e.jsxs(e.Fragment,{children:[e.jsx("a",{href:o.replace(/^https?:/,"cursor:"),target:"_blank",rel:"noopener noreferrer",className:"rounded-[4px] border border-[var(--accent)]/40 px-3 py-1.5 text-[var(--accent)] hover:bg-[var(--accent)]/10 transition-colors",children:n("tasks.tunnel_open_cursor")}),e.jsx("a",{href:o.replace(/^https?:/,"vscode:"),target:"_blank",rel:"noopener noreferrer",className:"rounded-[4px] border border-[var(--border)] px-3 py-1.5 text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",children:n("tasks.tunnel_open_vscode")}),e.jsx("button",{onClick:K,disabled:d,className:"rounded-[4px] border border-[var(--destructive)]/40 px-3 py-1.5 text-[var(--destructive)] hover:bg-[var(--destructive)]/10 transition-colors disabled:opacity-50",children:n(d?"tasks.tunnel_stopping":"tasks.tunnel_stop")})]}),t==="EXPIRED"&&e.jsx("button",{onClick:z,disabled:d,className:"rounded-[4px] border border-[var(--accent)]/40 px-3 py-1.5 text-[var(--accent)] hover:bg-[var(--accent)]/10 transition-colors disabled:opacity-50",children:n(d?"tasks.tunnel_starting_button":"tasks.tunnel_restart")})]})]})}function Tt({isOpen:c,onClose:i,onConfirm:a,taskId:n,isLoading:t}){const{t:x}=Q();return e.jsx(be,{isOpen:c,onClose:i,onConfirm:a,title:x("tasks.cancel_task_title"),message:x("tasks.cancel_task_message",{id:String(n)}),confirmLabel:x("tasks.cancel_task_confirm_label"),confirmVariant:"danger",isLoading:t})}function Dt({isOpen:c,onClose:i,onConfirm:a,taskId:n,mrUrl:t,isLoading:x,reuseWorkspace:o,onReuseWorkspaceChange:g}){const{t:u}=Q(),D=t?u("tasks.retry_message_with_mr",{id:String(n),url:t}):u("tasks.retry_message_without_mr",{id:String(n)});return e.jsx(be,{isOpen:c,onClose:i,onConfirm:a,title:u("tasks.retry_title"),message:D,confirmLabel:u("tasks.retry_confirm_label"),confirmVariant:"accent",isLoading:x,children:e.jsxs("label",{className:"flex items-center gap-2 mt-3 text-[var(--text-muted)] text-xs cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:o,onChange:w=>g(w.target.checked),className:"w-3.5 h-3.5 cursor-pointer accent-[var(--accent)]"}),u("tasks.reuse_workspace_label")]})})}function Lt(c){switch(c){case"stage_change":return"text-[var(--accent)]";case"info":return"text-[var(--text-secondary)]";case"warning":return"text-[var(--warning)]";case"error":return"text-[var(--destructive)]";case"system":return"text-[var(--info)]";default:return"text-[var(--text-muted)]"}}function ve({status:c}){const i=bt(c);return e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-[4px] px-2 py-0.5 text-xs",style:{color:i},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-[3px]",style:{backgroundColor:i}}),c.toLowerCase()]})}function $t(c){let a=["implement","test","verify","review","submit"];if(c.configSnapshot)try{const t=JSON.parse(c.configSnapshot);if(t&&typeof t=="object"){const x=typeof t.pipeline=="string"?JSON.parse(t.pipeline):t.pipeline;x&&typeof x=="object"&&Array.isArray(x.stages)&&x.stages.length>0&&x.stages.every(o=>o&&typeof o=="object"&&typeof o.name=="string")&&(a=x.stages.map(o=>o.name))}}catch{}const n=c.currentStage?a.indexOf(c.currentStage):-1;return a.map((t,x)=>{let o="pending";return c.status===T.COMPLETED?o="completed":c.status===T.FAILED&&x<=n?o=x===n?"failed":"completed":n>=0&&(x<n?o="completed":x===n&&(o="running")),{name:t,status:o}})}function re(c,i){if(!c||!i)return null;const a=c.repoUrl.replace(/\.git$/,"").replace(/\/+$/,"");return c.gitPlatform===mt.GITLAB?`${a}/-/tree/${i}`:`${a}/tree/${i}`}function Bt(){var Me,Oe;const{id:c}=lt(),i=ct(),{t:a}=Q(),n=pt(s=>s.cancelTask),[t,x]=r.useState(null),[o,g]=r.useState(null),[u,D]=r.useState([]),[w,$]=r.useState(!0),[d,N]=r.useState(null),[ne,F]=r.useState(!1),[A,I]=r.useState(!1),[le,_]=r.useState(!1),[z,K]=r.useState(!1),[ce,f]=r.useState(!1),[L,C]=r.useState(!1),[ge,je]=r.useState(""),[Ne,ie]=r.useState(!1),[ye,He]=it(),[y,oe]=r.useState("terminal"),[ke,Ve]=r.useState([]),[Y,Je]=r.useState(0),[B,W]=r.useState(0),[X,we]=r.useState(""),[Z,Qe]=r.useState(""),[Ye,_e]=r.useState(!1),[Ze,Ce]=r.useState(!1),[M,Se]=r.useState(null),[S,Ee]=r.useState("disconnected"),[H,Te]=r.useState("auto"),O=r.useRef(null),De=r.useRef(null),m=Number(c),v=t?ut.includes(t.status):!1;ot(t?`#${t.id} ${pe(t,100)}`:null);const E=r.useCallback(async()=>{try{const s=await b.get(`web/tasks/${m}`).json();x(s)}catch{}},[m]),ee=r.useCallback(async()=>{try{const s=await b.get(`web/tasks/${m}/logs`).json();D(s.lines)}catch{}},[m]),q=r.useCallback(async()=>{try{const s=await b.get(`web/tasks/${m}/pending-confirm`).json();N(s.confirm)}catch{N(null)}},[m]),Le=r.useCallback(async()=>{_e(!0);try{const s=new URLSearchParams;s.set("limit","50"),s.set("offset",String(B*50)),X&&s.set("type",X),Z&&s.set("search",Z);const l=await b.get(`web/tasks/${m}/events?${s}`).json();Ve(l.events),Je(l.total)}catch{}finally{_e(!1)}},[m,B,X,Z]);r.useEffect(()=>{y==="logs"&&Le()},[y,Le]),r.useEffect(()=>{y==="pipeline"&&!v&&b.get(`web/workspaces/${m}`).json().then(Se).catch(()=>Se(null))},[y,m,v]);const U=qe(s=>s.lastEvent),$e=qe(s=>s.eventSeq);r.useEffect(()=>{$(!0),Promise.all([E(),ee(),q()]).finally(()=>$(!1))},[E,ee,q]),r.useEffect(()=>{t!=null&&t.projectKey&&b.get(`web/projects/${t.projectKey}`).json().then(g).catch(()=>g(null))},[t==null?void 0:t.projectKey]),r.useEffect(()=>{!U||$e===0||(U.event==="task_status_changed"&&U.taskId===m||U.event==="task_created"&&U.taskId===m)&&(E(),q())},[$e,U,m,E,q]),r.useEffect(()=>{if(v)return;const l=setInterval(()=>{document.visibilityState!=="hidden"&&Promise.all([E(),ee(),q()])},15e3);return()=>clearInterval(l)},[v,E,ee,q]);const Ie=r.useCallback(()=>N(null),[]),te=r.useCallback(()=>{N(null),E()},[E]);r.useEffect(()=>{ye.get("action")==="fork"&&t&&!w&&((t.status===T.COMPLETED||t.status===T.FAILED)&&Re(),He(l=>(l.delete("action"),l),{replace:!0}))},[t,w,ye]);async function et(){K(!0);try{await n(m),F(!1),await E()}finally{K(!1)}}async function tt(){f(!0);try{await b.post(`web/tasks/${m}/retry`,{json:{reuseWorkspace:Ne}}),I(!1),ie(!1),await E()}finally{f(!1)}}function Re(){je(""),_(!0)}async function st(){C(!0);try{const s=await b.post(`web/tasks/${m}/fork`,{json:{description:ge||void 0}}).json();_(!1),V.success(a("tasks.fork_success")),i(`/tasks/${s.task.id}`)}catch{V.error(a("tasks.fork_error"))}finally{C(!1)}}const j=r.useMemo(()=>t?$t(t):[],[t==null?void 0:t.configSnapshot,t==null?void 0:t.currentStage,t==null?void 0:t.status]),xe=j.findIndex(s=>s.status==="running");if(w)return e.jsx("div",{className:"flex h-full items-center justify-center font-mono",children:e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:a("tasks.loading_task")})});if(!t)return e.jsxs("div",{className:"mx-auto max-w-5xl px-6 py-8 font-mono lowercase text-center",children:[e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:a("tasks.task_not_found")}),e.jsxs("button",{onClick:()=>i("/tasks"),className:"mt-4 rounded-[4px] border border-[var(--border)] px-3 py-1.5 text-xs text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",children:["< ",a("tasks.back_to_tasks")]})]});const k=t.status===T.QUEUED&&t.queuePosition!=null&&t.queueTotal!=null?{position:t.queuePosition,total:t.queueTotal}:null,Pe=k?e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"queue"}),e.jsxs("span",{className:"text-[var(--info)]",children:["#",k.position," / ",k.total]})]}):null,Fe=e.jsxs("div",{className:"flex items-center gap-3 border-b border-[var(--border)] bg-[var(--bg-primary)] px-4 py-3 shrink-0 md:hidden",children:[e.jsx("button",{onClick:()=>i("/tasks"),className:"shrink-0 text-[var(--text-muted)]",children:e.jsx(jt,{className:"h-4 w-4"})}),e.jsxs("span",{className:"line-clamp-2 text-sm font-medium text-[var(--text-primary)]",title:`#${t.id} ${t.name??t.description}`,children:["#",t.id," ",pe(t,100)]})]}),de=e.jsxs("div",{className:"hidden md:flex items-center gap-4 border-b border-[var(--border)] bg-[var(--bg-primary)] px-5 shrink-0",style:{height:44},children:[e.jsx(ve,{status:t.status}),k&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs text-[var(--border)]",children:"|"}),e.jsx("span",{className:"text-xs text-[var(--info)]",children:a("tasks.queue_position",{position:String(k.position),total:String(k.total)})})]}),e.jsx("span",{className:"text-xs text-[var(--border)]",children:"|"}),e.jsxs(xt,{to:`/projects/${t.projectKey}`,className:"text-xs text-[var(--text-muted)] hover:text-[var(--text-primary)] transition-colors",children:["project: ",e.jsx("span",{className:"text-[var(--text-primary)]",children:t.projectKey})]}),t.branch&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs text-[var(--border)]",children:"|"}),e.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["branch: ",re(o,t.branch)?e.jsx("a",{href:re(o,t.branch),target:"_blank",rel:"noopener noreferrer",className:"text-[var(--text-primary)] hover:text-[var(--info)] hover:underline transition-colors",children:t.branch}):e.jsx("span",{className:"text-[var(--text-primary)]",children:t.branch})]})]}),t.mrUrl&&/^https?:\/\//.test(t.mrUrl)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-xs text-[var(--border)]",children:"|"}),e.jsxs("a",{href:t.mrUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[var(--info)] hover:underline",children:["MR: ",((Me=t.mrUrl.match(/!?\d+$/))==null?void 0:Me[0])??"view"]})]})]}),Ae=e.jsxs("div",{className:"flex items-center gap-3 border-t border-[var(--border)] bg-[var(--bg-primary)] px-4 md:px-5 shrink-0",style:{height:48},children:[!v&&e.jsxs("button",{onClick:()=>F(!0),className:"flex flex-1 md:flex-none items-center justify-center gap-1.5 rounded-[4px] bg-[var(--destructive)]/10 px-3 h-8 text-[11px] font-medium text-[var(--destructive)]",children:[e.jsx(ue,{className:"h-3 w-3"}),a("tasks.cancel_task")]}),t.status===T.FAILED&&e.jsxs("button",{onClick:()=>I(!0),className:"flex flex-1 md:flex-none items-center justify-center gap-1.5 rounded-[4px] bg-[var(--bg-card)] px-3 h-8 text-[11px] text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-input)] transition-colors cursor-pointer",children:[e.jsx(he,{className:"h-3 w-3"}),a("tasks.retry_task")]}),(t.status===T.COMPLETED||t.status===T.FAILED)&&e.jsxs("button",{onClick:Re,className:"flex flex-1 md:flex-none items-center justify-center gap-1.5 rounded-[4px] bg-[var(--bg-card)] px-3 h-8 text-[11px] text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-input)] transition-colors cursor-pointer",children:[e.jsx(Nt,{className:"h-3 w-3"}),a("tasks.fork_task")]}),t.workerId&&!v&&e.jsxs("button",{onClick:()=>{oe("pipeline"),setTimeout(()=>{var s,l;(l=(s=De.current)==null?void 0:s.scrollIntoView)==null||l.call(s,{behavior:"smooth",block:"center"})},50)},className:"hidden lg:flex items-center justify-center gap-1.5 rounded-[4px] px-3 h-8 text-[11px] font-medium text-[var(--info)]",style:{backgroundColor:"rgba(59,130,246,0.12)"},children:[e.jsx(yt,{className:"h-3 w-3"}),a("tasks.cursor_tunnel")]})]}),at=e.jsxs("div",{className:"hidden w-[280px] shrink-0 flex-col gap-6 overflow-y-auto border-l border-[var(--border)] bg-[var(--bg-primary)] p-4 lg:flex",children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("span",{className:"text-[11px] font-medium text-[var(--text-muted)]",children:a("tasks.pipeline_stages")}),j.map(s=>{const l=s.status==="completed",p=s.status==="running",h=s.status==="failed";return e.jsxs("div",{className:`flex items-center gap-2 rounded-[4px] px-2 py-1.5 ${p?"bg-[#1a1a1a]":""}`,children:[l&&e.jsx(Ue,{className:"h-3.5 w-3.5 shrink-0 text-[var(--accent)]"}),p&&e.jsx(fe,{className:"h-3.5 w-3.5 shrink-0 text-[var(--accent)]"}),h&&e.jsx(ue,{className:"h-3.5 w-3.5 shrink-0 text-[var(--destructive)]"}),s.status==="pending"&&e.jsx(Ke,{className:"h-3.5 w-3.5 shrink-0 text-[#525252]"}),e.jsx("span",{className:"text-xs",style:{color:l?"var(--accent)":p?"#e5e5e5":h?"var(--destructive)":"#525252",fontWeight:p?500:400},children:p?`> ${s.name}`:s.name})]},s.name)})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[11px] font-medium text-[var(--text-muted)]",children:a("tasks.activity_log")}),u.length>0?e.jsx("div",{className:"flex flex-col gap-1.5",children:u.slice(0,8).map((s,l)=>e.jsx("p",{className:"text-[11px] leading-relaxed text-[var(--text-muted)]",children:s},l))}):e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:a("tasks.no_activity")})]})]}),me=e.jsxs(e.Fragment,{children:[e.jsx(Tt,{isOpen:ne,onClose:()=>F(!1),onConfirm:et,taskId:m,isLoading:z}),e.jsx(Dt,{isOpen:A,onClose:()=>{I(!1),ie(!1)},onConfirm:tt,taskId:m,mrUrl:t.mrUrl??void 0,isLoading:ce,reuseWorkspace:Ne,onReuseWorkspaceChange:ie}),e.jsx(be,{isOpen:le,onClose:()=>_(!1),onConfirm:st,title:a("tasks.fork_task"),message:a("tasks.fork_task_desc"),confirmLabel:a("tasks.fork_task"),confirmVariant:"accent",isLoading:L,children:e.jsxs("div",{className:"mt-3 flex flex-col gap-2",children:[e.jsxs("span",{className:"text-[11px] text-[var(--text-muted)]",children:["fork of #",m]}),e.jsx("textarea",{value:ge,onChange:s=>je(s.target.value),placeholder:a("tasks.fork_description_placeholder"),rows:4,className:"w-full rounded-[4px] border border-[var(--border)] bg-[var(--bg-input)] px-3 py-2 text-xs text-[var(--text-primary)] placeholder:text-[var(--text-muted)] outline-none focus:border-[var(--accent)] resize-none"})]})})]});return Ze&&y==="terminal"?e.jsxs("div",{className:"fixed inset-0 z-50 flex flex-col bg-[var(--bg-primary)] font-mono lowercase h-screen",style:{height:"100dvh",paddingTop:"env(safe-area-inset-top, 0px)",paddingBottom:"env(safe-area-inset-bottom, 0px)"},children:[de,e.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] px-5 shrink-0",style:{height:36,backgroundColor:"#111111"},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-[11px] font-medium text-[var(--text-muted)]",children:a("tasks.pty_terminal")}),e.jsxs("span",{className:`inline-flex items-center gap-1 text-[11px] ${S==="connected"?"text-[var(--accent)]":S==="connecting"?"text-[var(--warning)]":"text-[var(--text-muted)]"}`,children:[e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${S==="connected"?"bg-[var(--accent)]":S==="connecting"?"bg-[var(--warning)]":"bg-[#525252]"}`}),a(`tasks.${S}`)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!v&&H==="auto"&&e.jsxs("button",{onClick:()=>{var s;return(s=O.current)==null?void 0:s.requestTakeover()},className:"flex items-center gap-1.5 rounded-[4px] px-2.5 h-10 md:h-8 text-[11px] font-medium text-[var(--warning)]",style:{backgroundColor:"rgba(245,158,11,0.12)"},children:[e.jsx(Ge,{className:"h-3 w-3"}),a("tasks.take_over")]}),!v&&H==="manual"&&e.jsxs("button",{onClick:()=>{var s;return(s=O.current)==null?void 0:s.releaseTakeover()},className:"flex items-center gap-1.5 rounded-[4px] px-2.5 h-10 md:h-8 text-[11px] font-medium text-[var(--accent)]",style:{backgroundColor:"rgba(34,197,94,0.12)"},children:[e.jsx(he,{className:"h-3 w-3"}),a("tasks.restore_auto")]}),t.currentStage&&e.jsxs("span",{className:"text-[11px] text-[var(--accent)]",children:[a("tasks.stage"),": ",t.currentStage]}),e.jsx("button",{onClick:()=>Ce(!1),className:"flex items-center rounded-[4px] bg-[var(--bg-card)] px-2.5 py-1 text-[var(--text-muted)]",children:e.jsx(_t,{className:"h-3 w-3"})})]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(ze,{ref:O,taskId:m,sessionId:t.currentSessionId??void 0,taskFinished:v,onStatusChange:Ee,onTakeoverChange:Te})}),Ae,me]}):t.status===T.SUSPENDED?e.jsxs("div",{className:"flex h-full flex-col font-mono lowercase",children:[Fe,de,e.jsx("div",{className:"flex items-center gap-2 border-b px-4 md:px-6 py-2 text-xs shrink-0",style:{backgroundColor:"rgba(245,158,11,0.08)",borderColor:"rgba(245,158,11,0.2)",color:"var(--warning)"},children:a("tasks.task_suspended_banner")}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col md:flex-row gap-4 md:gap-6 p-4 md:p-6 overflow-y-auto",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-4",children:[e.jsxs("div",{className:"hidden md:flex items-center gap-3",children:[e.jsxs("span",{className:"text-xl font-bold text-[var(--text-primary)]",children:["#",t.id]}),e.jsx("span",{className:"text-base text-[var(--text-secondary)] truncate max-w-[60%]",children:e.jsx(gt,{content:t.name??t.description,children:pe(t,200)})}),e.jsx("span",{className:"rounded-[4px] px-2.5 py-1 text-[11px] font-bold text-[var(--warning)]",style:{backgroundColor:"rgba(245,158,11,0.12)"},children:a("tasks.status_suspended")})]}),e.jsx("div",{className:"flex items-center gap-2 md:hidden",children:e.jsx("span",{className:"rounded-[4px] px-2.5 py-1 text-[11px] font-bold text-[var(--warning)]",style:{backgroundColor:"rgba(245,158,11,0.12)"},children:a("tasks.status_suspended")})}),d&&e.jsxs("div",{className:"rounded-[4px] border p-4",style:{borderColor:"rgba(245,158,11,0.27)",backgroundColor:"#1a1a1a"},children:[e.jsx("p",{className:"mb-2 text-[11px] font-bold text-[var(--accent)]",children:a("tasks.pending_confirmation")}),e.jsx("p",{className:"mb-3 text-xs text-[var(--text-secondary)]",children:d.prompt??a("tasks.pipeline_requires_confirmation")}),e.jsx("div",{className:"mb-3 flex flex-col gap-1.5 text-[11px]",children:e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"stage"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:d.stageName})]})}),e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:flex-wrap md:gap-3",children:[e.jsx("button",{onClick:async()=>{try{await b.post(`web/tasks/${m}/confirm-stage`,{json:{stageName:d.stageName,approved:!0}}),te()}catch{V.error(a("tasks.confirm_failed"))}},className:"flex-1 md:flex-none rounded-[4px] bg-[var(--accent)] px-4 py-2.5 md:py-2 text-[11px] font-bold text-[#0c0c0c]",children:a("tasks.confirm_and_proceed")}),e.jsx("button",{onClick:async()=>{try{await b.post(`web/tasks/${m}/confirm-stage`,{json:{stageName:d.stageName,approved:!1}}),te()}catch{V.error(a("tasks.confirm_failed"))}},className:"flex-1 md:flex-none rounded-[4px] bg-[#1a1a1a] px-4 py-2.5 md:py-2 text-[11px] text-[var(--destructive)]",style:{border:"1px solid rgba(239,68,68,0.27)"},children:a("tasks.reject")})]})]}),e.jsxs("div",{className:"flex flex-col gap-3 rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4 lg:hidden",children:[e.jsx("span",{className:"text-xs font-bold text-[var(--accent)]",children:a("tasks.task_info")}),e.jsxs("div",{className:"flex flex-col gap-1.5 text-[11px]",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"status"}),e.jsx("span",{className:"font-bold text-[var(--warning)]",children:"suspended"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"project"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:t.projectKey})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"worker"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:t.workerName??"-"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"created"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:ae(t.createdAt)})]})]})]}),e.jsx("div",{className:"hidden md:flex flex-wrap items-center gap-2 py-2",children:j.map((s,l)=>{const p=s.status==="failed",h=s.status==="completed",R=s.status==="running"&&t.status===T.SUSPENDED,G=p?"var(--destructive)":h?"var(--accent)":R?"var(--warning)":"#525252",se=p?"rgba(239,68,68,0.12)":h?"rgba(34,197,94,0.12)":R?"rgba(245,158,11,0.12)":"transparent";return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"rounded-[4px] px-2.5 py-1 text-[11px]",style:{color:G,backgroundColor:se,fontWeight:R?700:400,border:R?`1px solid ${G}`:void 0},children:R?"confirm":`${s.name}${h?" ✓":p?" ✗":""}`}),l<j.length-1&&e.jsx("div",{className:"h-px w-6 bg-[var(--border)]"})]},s.name)})}),e.jsxs("div",{className:"hidden md:block min-h-[200px] flex-1 rounded-[4px] border border-[var(--border)] bg-[#0c0c0c] p-4",children:[e.jsx("p",{className:"mb-2 text-[11px] font-bold text-[var(--accent)]",children:a("tasks.pty_output")}),e.jsxs("div",{className:"flex flex-col gap-1",children:[u.slice(-10).map((s,l)=>e.jsx("p",{className:"text-[11px] leading-relaxed text-[var(--text-secondary)]",children:s},l)),u.length===0&&e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:a("tasks.no_output")})]})]})]}),e.jsxs("div",{className:"hidden w-[280px] shrink-0 flex-col gap-4 rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4 lg:flex",children:[e.jsx("span",{className:"text-[13px] font-bold text-[var(--accent)]",children:a("tasks.task_info")}),e.jsxs("div",{className:"flex flex-col gap-1.5 text-[11px]",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"status"}),e.jsx("span",{className:"font-bold text-[var(--warning)]",children:"suspended"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"project"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:t.projectKey})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"worker"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:t.workerName??"-"})]})]}),e.jsx("div",{className:"h-px bg-[var(--border)]"}),e.jsx("span",{className:"text-xs font-bold text-[var(--accent)]",children:a("tasks.stage_timeline")}),e.jsx("div",{className:"flex flex-col gap-2",children:j.map(s=>{const l=s.status==="completed"?"var(--info)":s.status==="failed"?"var(--destructive)":s.status==="running"?"var(--warning)":"#525252",p=s.status==="failed"?"var(--destructive)":s.status==="running"?"var(--warning)":"#a3a3a3",h=s.status==="completed"?"completed":s.status==="running"?"suspended":s.status==="failed"?"failed":"pending";return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"h-2 w-2 shrink-0 rounded-[4px]",style:{backgroundColor:l}}),e.jsxs("span",{className:"text-[11px]",style:{color:p,fontWeight:s.status==="running"?700:400},children:[s.name," ",h]})]},s.name)})}),e.jsx("div",{className:"h-px bg-[var(--border)]"}),e.jsx("div",{className:"flex flex-col gap-1.5 text-[11px]",children:e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"created"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:ae(t.createdAt)})]})})]})]}),d&&e.jsx(Be,{isOpen:!!d,onClose:Ie,taskId:m,stageName:d.stageName,timeoutSeconds:Math.ceil(d.timeout/1e3),onSubmitted:te}),me]}):e.jsxs("div",{className:"flex h-full flex-col overflow-hidden font-mono lowercase",children:[Fe,e.jsxs("div",{className:"flex flex-wrap items-center gap-3 gap-y-1 border-b border-[var(--border)] bg-[var(--bg-primary)] px-4 py-2 shrink-0 md:hidden",children:[e.jsx(ve,{status:t.status}),e.jsx("span",{className:"shrink-0 text-[11px] text-[var(--text-muted)]",children:t.projectKey}),t.workerName&&e.jsx("span",{className:"shrink-0 text-[11px] text-[var(--text-muted)]",children:t.workerName}),t.branch&&(re(o,t.branch)?e.jsx("a",{href:re(o,t.branch),target:"_blank",rel:"noopener noreferrer",className:"shrink-0 text-[11px] text-[var(--text-muted)] hover:text-[var(--info)] hover:underline truncate max-w-[80px] md:max-w-[120px] transition-colors",children:t.branch}):e.jsx("span",{className:"shrink-0 text-[11px] text-[var(--text-muted)] truncate max-w-[80px] md:max-w-[120px]",children:t.branch}))]}),de,t.errorMessage&&e.jsxs("div",{className:"flex items-center gap-2 border-b px-6 py-2 text-xs shrink-0 bg-[var(--destructive)]/10 text-[var(--destructive)]",style:{borderColor:"rgba(239,68,68,0.2)"},children:["// error: ",t.errorMessage]}),k&&e.jsxs("div",{className:"flex items-center gap-2 border-b px-4 md:px-6 py-2 text-xs shrink-0 text-[var(--info)]",style:{backgroundColor:"color-mix(in srgb, var(--info) 8%, transparent)",borderColor:"color-mix(in srgb, var(--info) 20%, transparent)"},children:[e.jsx(kt,{className:"h-3.5 w-3.5 shrink-0"}),e.jsxs("span",{children:[a("tasks.queue_position_banner",{position:String(k.position),total:String(k.total)}),k.position>1?` — ${a("tasks.queue_ahead",{count:String(k.position-1)})}`:` — ${a("tasks.queue_next")}`]})]}),d&&e.jsx(Be,{isOpen:!!d,onClose:Ie,taskId:m,stageName:d.stageName,timeoutSeconds:Math.ceil(d.timeout/1e3),onSubmitted:te}),e.jsxs("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[e.jsx("div",{className:"flex items-center border-b border-[var(--border)] shrink-0 overflow-x-auto no-scrollbar",children:["terminal","pipeline","logs"].map(s=>e.jsx("button",{onClick:()=>oe(s),className:`shrink-0 whitespace-nowrap px-4 py-2.5 text-xs transition-colors ${y===s?"border-b-2 border-[var(--accent)] text-[var(--accent)] font-medium":"text-[var(--text-muted)] hover:text-[var(--text-secondary)]"}`,children:a(s==="terminal"?"tasks.terminal":s==="pipeline"?"tasks.pipeline_tab":"tasks.logs")},s))}),y==="terminal"&&e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] px-3 md:px-5 shrink-0",style:{height:36,backgroundColor:"#111111"},children:[e.jsxs("div",{className:"flex items-center gap-2 md:gap-3",children:[e.jsx("span",{className:"text-[11px] font-medium text-[var(--text-muted)]",children:a("tasks.pty_terminal")}),e.jsxs("span",{className:`inline-flex items-center gap-1 text-[11px] ${S==="connected"?"text-[var(--accent)]":S==="connecting"?"text-[var(--warning)]":"text-[var(--text-muted)]"}`,children:[e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${S==="connected"?"bg-[var(--accent)]":S==="connecting"?"bg-[var(--warning)]":"bg-[#525252]"}`}),a(`tasks.${S}`)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!v&&H==="auto"&&e.jsxs("button",{onClick:()=>{var s;return(s=O.current)==null?void 0:s.requestTakeover()},className:"flex items-center gap-1.5 rounded-[4px] px-2.5 h-10 md:h-8 text-[11px] font-medium text-[var(--warning)]",style:{backgroundColor:"rgba(245,158,11,0.12)"},children:[e.jsx(Ge,{className:"h-3 w-3"}),a("tasks.take_over")]}),!v&&H==="manual"&&e.jsxs("button",{onClick:()=>{var s;return(s=O.current)==null?void 0:s.releaseTakeover()},className:"flex items-center gap-1.5 rounded-[4px] px-2.5 h-10 md:h-8 text-[11px] font-medium text-[var(--accent)]",style:{backgroundColor:"rgba(34,197,94,0.12)"},children:[e.jsx(he,{className:"h-3 w-3"}),a("tasks.restore_auto")]}),!v&&H==="requesting"&&e.jsxs("span",{className:"flex items-center gap-1.5 px-2.5 h-10 md:h-8 text-[11px] text-[var(--warning)]",children:[e.jsx(fe,{className:"h-3 w-3 animate-spin"}),a("tasks.requesting_takeover")]}),!v&&t.currentStage&&e.jsxs("button",{className:"hidden md:flex items-center gap-1.5 rounded-[4px] bg-[var(--bg-card)] px-2.5 h-10 md:h-8 text-[11px] text-[var(--text-muted)]",children:[e.jsx(Ct,{className:"h-3 w-3"}),a("tasks.skip_stage")]}),e.jsx("button",{onClick:()=>Ce(!0),className:"hidden md:flex items-center rounded-[4px] bg-[var(--bg-card)] px-2.5 h-10 md:h-8 text-[var(--text-muted)]",children:e.jsx(wt,{className:"h-3 w-3"})})]})]}),e.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--border)] px-4 py-2 shrink-0 md:hidden",children:[e.jsx(ve,{status:t.status}),t.workerName&&e.jsxs("span",{className:"text-[11px] text-[var(--text-muted)]",children:["on ",t.workerName]})]}),e.jsxs("div",{className:"border-b border-[var(--border)] px-4 py-3 shrink-0 md:hidden",children:[e.jsx("span",{className:"text-[11px] font-bold text-[var(--accent)]",children:a("tasks.stage_progress")}),e.jsx("div",{className:"mt-2 overflow-x-auto no-scrollbar pr-4",style:{borderRadius:0},children:e.jsx("div",{className:"flex items-center gap-1 py-0.5",children:j.map((s,l)=>{const p=s.status==="completed",h=s.status==="running",G=s.status==="failed"?"var(--destructive)":p||h?"var(--accent)":"#525252";return e.jsxs("div",{className:"flex items-center",children:[e.jsxs("span",{className:"shrink-0 text-[11px] leading-normal whitespace-nowrap",style:{color:G,fontWeight:h?600:400},children:[s.name,p?" ✓":h?" ...":""]}),l<j.length-1&&e.jsx("div",{className:"mx-1.5 h-px w-4 shrink-0",style:{backgroundColor:G}})]},s.name)})})})]}),e.jsx("div",{className:"px-4 pt-3 pb-1 shrink-0 md:hidden",children:e.jsx("span",{className:"text-[11px] font-bold text-[var(--accent)]",children:a("tasks.pty_output")})}),e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:e.jsx(ze,{ref:O,taskId:m,sessionId:t.currentSessionId??void 0,taskFinished:v,onStatusChange:Ee,onTakeoverChange:Te})}),Ae]}),y==="pipeline"&&e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto p-4 md:p-6 lg:p-8",children:[e.jsx("div",{className:"mb-4 md:mb-5 overflow-x-auto no-scrollbar",style:{borderRadius:0},children:e.jsx("div",{className:"flex items-center py-5",children:j.map((s,l)=>{const p=s.status==="completed",h=s.status==="running",se=s.status==="failed"?"var(--destructive)":p||h?"var(--accent)":"#525252";return e.jsxs("div",{className:"flex items-center",style:{flex:l<j.length-1?1:void 0},children:[e.jsxs("div",{className:"flex flex-col items-center gap-1.5",children:[e.jsxs("div",{className:"flex h-6 w-6 md:h-7 md:w-7 items-center justify-center rounded-full shrink-0",style:{backgroundColor:se},children:[p&&e.jsx("span",{className:"text-[11px] md:text-xs font-semibold text-[#0c0c0c]",children:"✓"}),h&&e.jsx("span",{className:"h-2 w-2 md:h-2.5 md:w-2.5 rounded-full bg-[#0c0c0c]"})]}),e.jsx("span",{className:"text-[11px] leading-normal font-medium whitespace-nowrap",style:{color:se},children:s.name})]}),l<j.length-1&&e.jsx("div",{className:"mx-1 md:mx-2 h-0.5 flex-1 min-w-3 rounded-full",style:{backgroundColor:l<(xe>=0?xe:0)?"var(--accent)":"#525252"}})]},s.name)})})}),t.currentStage&&e.jsxs("div",{className:"mb-4 md:mb-5 rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-3 text-xs leading-relaxed",children:[e.jsxs("p",{className:"text-[var(--text-secondary)]",children:["// stage: ",t.currentStage," (",xe+1,"/",j.length,")"]}),t.startedAt&&e.jsxs("p",{className:"text-[var(--text-secondary)]",children:["// elapsed: ",ae(t.startedAt).replace(" ago","")]}),e.jsxs("p",{className:"text-[var(--text-secondary)]",children:["// retries: ",t.retryCount,"/2"]})]}),e.jsx("button",{onClick:()=>oe("terminal"),className:"flex-1 min-h-[100px] rounded-[4px] border border-dashed border-[var(--border)] flex items-center justify-center gap-2 text-[11px] text-[var(--text-muted)] hover:border-[var(--accent)] hover:text-[var(--accent)] transition-colors",children:e.jsxs("span",{children:["// ",a("tasks.view_terminal")]})}),e.jsxs("div",{className:"mt-4 rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4 lg:hidden",children:[e.jsx("span",{className:"text-[11px] font-bold text-[var(--accent)]",children:a("tasks.task_info")}),e.jsxs("div",{className:"mt-2 flex flex-col gap-1.5 text-[11px]",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"project"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:t.projectKey})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"worker"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:t.workerName??"-"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"branch"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:t.branch??"-"})]}),Pe]})]}),e.jsxs("div",{className:"flex flex-col gap-6 mt-4 lg:hidden",children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("span",{className:"text-[11px] font-medium text-[var(--text-muted)]",children:a("tasks.pipeline_stages")}),j.map(s=>{const l=s.status==="completed",p=s.status==="running",h=s.status==="failed";return e.jsxs("div",{className:`flex items-center gap-2 rounded-[4px] px-2 py-2 ${p?"bg-[var(--bg-input)]":""}`,children:[l&&e.jsx(Ue,{className:"h-3.5 w-3.5 shrink-0 text-[var(--accent)]"}),p&&e.jsx(fe,{className:"h-3.5 w-3.5 shrink-0 text-[var(--accent)]"}),h&&e.jsx(ue,{className:"h-3.5 w-3.5 shrink-0 text-[var(--destructive)]"}),s.status==="pending"&&e.jsx(Ke,{className:"h-3.5 w-3.5 shrink-0 text-[#525252]"}),e.jsx("span",{className:"text-xs leading-normal",style:{color:l?"var(--accent)":p?"var(--text-primary)":h?"var(--destructive)":"#525252",fontWeight:p?500:400},children:p?`> ${s.name}`:s.name})]},s.name)})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[11px] font-medium text-[var(--text-muted)]",children:a("tasks.activity_log")}),u.length>0?e.jsx("div",{className:"flex flex-col gap-1.5",children:u.slice(-12).map((s,l)=>e.jsx("p",{className:"text-[11px] leading-relaxed text-[var(--text-muted)]",children:s},l))}):e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:a("tasks.no_activity")})]})]})]}),y==="logs"&&e.jsxs("div",{className:"flex flex-1 flex-col gap-3 md:gap-5 overflow-y-auto p-4 md:p-6 lg:p-8",children:[e.jsx("span",{className:"text-[11px] font-bold text-[var(--accent)] md:hidden",children:a("tasks.task_logs")}),e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-center md:gap-3",children:[e.jsx("div",{className:"flex items-center gap-1 overflow-x-auto no-scrollbar md:hidden",children:["","error","system"].map(s=>e.jsx("button",{onClick:()=>{we(s),W(0)},className:`shrink-0 rounded-[4px] px-2.5 py-1 text-[11px] ${X===s?"text-[var(--accent)] bg-[var(--bg-input)]":"text-[var(--text-muted)]"}`,children:s||"all"},s))}),e.jsx("div",{className:"hidden md:block",children:e.jsx(vt,{value:X,onChange:s=>{we(s),W(0)},options:[{value:"",label:"all"},{value:"stage_change",label:"stage_change"},{value:"info",label:"info"},{value:"warning",label:"warning"},{value:"error",label:"error"},{value:"system",label:"system"}],className:"w-36"})}),e.jsxs("div",{className:"flex flex-1 items-center gap-2 rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] px-3 py-2",children:[e.jsx(dt,{className:"h-3.5 w-3.5 text-[var(--text-muted)]"}),e.jsx("input",{type:"text",placeholder:a("tasks.search_logs"),value:Z,onChange:s=>{Qe(s.target.value),W(0)},className:"flex-1 bg-transparent text-xs text-[var(--text-primary)] outline-none placeholder:text-[var(--text-muted)]"})]})]}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[ke.map((s,l)=>e.jsxs("div",{className:`flex items-start md:items-center gap-2 md:gap-4 rounded-[4px] px-2 md:px-3 py-2 text-[11px] md:text-xs ${l%2===0?"bg-[var(--bg-card)]":""}`,children:[e.jsx("span",{className:"shrink-0 text-[var(--text-muted)]",children:new Date(s.timestamp).toLocaleTimeString("en-US",{hour12:!1})}),e.jsx("span",{className:`shrink-0 font-medium ${Lt(s.type)}`,children:s.type}),e.jsx("span",{className:"min-w-0 break-words md:truncate text-[var(--text-primary)]",children:s.message})]},s.id)),ke.length===0&&!Ye&&e.jsx("p",{className:"py-8 text-center text-xs text-[var(--text-muted)]",children:a("tasks.no_log_entries")})]}),Y>50&&e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[Array.from({length:Math.ceil(Y/50)}).slice(0,5).map((s,l)=>e.jsx("button",{onClick:()=>W(l),className:`rounded-[4px] px-2 py-1 text-xs ${B===l?"bg-[var(--accent)] text-black font-medium":"text-[var(--text-muted)] hover:text-[var(--text-primary)]"}`,children:l+1},l)),Math.ceil(Y/50)>5&&e.jsx("button",{onClick:()=>W(B+1),disabled:B>=Math.ceil(Y/50)-1,className:"rounded-[4px] px-2 py-1 text-xs text-[var(--text-muted)] disabled:opacity-30",children:">"})]})]})]}),y==="terminal"&&at,y==="pipeline"&&e.jsxs("div",{className:"hidden w-[420px] shrink-0 flex-col gap-5 overflow-y-auto border-l border-[var(--border)] bg-[var(--bg-primary)] p-5 lg:flex",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[13px] font-semibold text-[var(--accent)]",children:a("tasks.task_info")}),e.jsxs("div",{className:"flex flex-col gap-1.5 text-xs",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"project"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:t.projectKey})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"creator"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:t.creatorName??"-"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:"worker"}),e.jsx("span",{className:"text-[var(--text-primary)]",children:t.workerName??"-"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:a("common.created_at")}),e.jsx("span",{className:"text-[var(--text-primary)]",children:ae(t.createdAt)})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:a("tasks.form_agent_type")}),e.jsx("span",{className:"text-[var(--text-primary)]",children:t.agentType??"claude"})]}),Pe]})]}),e.jsx("div",{className:"h-px bg-[var(--border)]"}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[13px] font-semibold text-[var(--accent)]",children:a("tasks.workspace_section")}),e.jsxs("div",{className:"flex flex-col gap-1.5 text-xs",children:[e.jsxs("div",{className:"flex min-w-0 justify-between",children:[e.jsx("span",{className:"shrink-0 text-[var(--text-muted)]",children:"branch"}),e.jsx("span",{className:"ml-4 min-w-0 truncate text-[var(--text-primary)]",children:t.branch??(M==null?void 0:M.branch)??"-"})]}),e.jsxs("div",{className:"flex min-w-0 justify-between",children:[e.jsx("span",{className:"shrink-0 text-[var(--text-muted)]",children:"worktree"}),e.jsx("span",{className:"ml-4 min-w-0 truncate text-[var(--text-primary)]",children:(M==null?void 0:M.path)??"-"})]}),t.mrUrl&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-[var(--text-muted)]",children:a("tasks.mr_link")}),e.jsx("a",{href:t.mrUrl,target:"_blank",rel:"noopener noreferrer",className:"font-medium text-[var(--info)] hover:underline",children:((Oe=t.mrUrl.match(/!?\d+$/))==null?void 0:Oe[0])??"view"})]})]})]}),e.jsx("div",{className:"h-px bg-[var(--border)]"}),e.jsxs("div",{ref:De,className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[13px] font-semibold text-[var(--accent)]",children:a("tasks.cursor_tunnel_section")}),t.workerId?e.jsx(Et,{taskId:m,taskFinished:v,compact:!0}):e.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:a("tasks.no_worker_assigned")})]}),e.jsx("div",{className:"h-px bg-[var(--border)]"}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-[13px] font-semibold text-[var(--accent)]",children:a("tasks.stage_timeline")}),e.jsx("div",{className:"flex flex-col gap-2 text-xs",children:j.map(s=>{const l=s.status==="completed"?"✓":s.status==="running"?"→":"·",p=s.status==="running"?"var(--accent)":s.status==="completed"?"var(--info)":s.status==="failed"?"var(--destructive)":"#525252",h=s.status==="completed"?"done":s.status==="running"?"running...":s.status==="failed"?"failed":"pending";return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-semibold",style:{color:p},children:l}),e.jsx("span",{className:s.status==="running"?"font-medium":"",style:{color:p},children:s.name}),e.jsxs("span",{className:"text-[11px]",style:{color:"#525252"},children:["— ",h]})]},s.name)})})]})]})]}),me]})}export{Bt as default};
@@ -0,0 +1 @@
1
+ import{R as ne,f as G,a as O,j as e,l as V,n as b,u as le,i as ce,r as a,h as S,X as ie,k as de,q as xe,H as pe,t as U,s as me,v as W}from"./index-BZ8Ay5Q7.js";import{a as ue,A as he,u as ve}from"./task-constants-67tyYZHJ.js";import{T as X}from"./TaskStatusBadge-ZmJh27Un.js";import{f as Z}from"./date-BdNtiQTP.js";import{T as be}from"./Tooltip-BdD7q141.js";import{G as ee}from"./git-fork-BOtX0t5m.js";import{S as w}from"./Select-Drhq3WPg.js";import{C as fe}from"./copy-1Kaayp-g.js";import{E as Q}from"./EmptyState-DSlrUDxV.js";import{T as Y}from"./Skeleton-C2wkNF0Q.js";import{P as ye}from"./plus-WIoVlw4A.js";import"./status-colors-ClM8Aa8i.js";const ge=ne.memo(function({task:s}){const d=G(),{t:c}=O(),x=(l,r)=>c(`common.${l}`,{n:r});return e.jsxs("tr",{onClick:()=>d(`/tasks/${s.id}`),className:"cursor-pointer border-b border-[var(--border-row)] transition-colors hover:bg-[var(--bg-input)]",children:[e.jsxs("td",{className:"w-16 py-3 pr-4 font-mono text-xs font-medium text-[var(--text-secondary)] text-right tabular-nums",children:["#",s.id]}),e.jsx("td",{className:"py-3 pr-4 text-sm text-[var(--text-primary)]",children:e.jsx(be,{content:s.name??s.description,children:V(s)})}),e.jsx("td",{className:"py-3 pr-4",children:e.jsx(X,{status:s.status})}),e.jsx("td",{className:"py-3 pr-4 font-mono text-xs text-[var(--text-secondary)]",children:s.projectKey}),e.jsx("td",{className:"py-3 pr-4 font-mono text-xs text-[var(--text-secondary)]",children:s.developerName??s.creatorName??"-"}),e.jsx("td",{className:"py-3 pr-4 font-mono text-xs text-[var(--text-secondary)]",children:s.workerName??"—"}),e.jsx("td",{className:"py-3 font-mono text-xs text-[var(--text-muted)]",children:e.jsxs("span",{className:"flex items-center gap-2",children:[Z(s.createdAt,x),(s.status===b.COMPLETED||s.status===b.FAILED)&&e.jsx("button",{onClick:l=>{l.stopPropagation(),d(`/tasks/${s.id}?action=fork`)},className:"shrink-0 rounded-[4px] p-1 text-[var(--text-muted)] hover:text-[var(--accent)] hover:bg-[var(--bg-input)] transition-colors",title:c("tasks.fork_task"),children:e.jsx(ee,{className:"h-3 w-3"})})]})})]})});function je({isOpen:n,onClose:s,projects:d,projectsLoading:c,onSubmit:x,isSubmitting:l}){const{t:r}=O();le(o=>o.user);const g=ce(),[m,D]=a.useState(""),[u,F]=a.useState(""),[p,C]=a.useState("feat"),[h,j]=a.useState(""),[k,f]=a.useState(""),[y,_]=a.useState(""),[T,E]=a.useState(""),[K,q]=a.useState([]),[I,v]=a.useState("");a.useEffect(()=>{if(!n||(D(""),F(""),C("feat"),j(""),f(""),_(""),E(""),v(""),!g))return;const o=new AbortController;return S.get("admin/developers",{signal:o.signal}).json().then(q).catch(()=>{}),()=>o.abort()},[n,g]),a.useEffect(()=>{if(!n)return;function o(N){N.key==="Escape"&&s()}return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[n,s]);async function z(o){if(o.preventDefault(),v(""),!m||!u.trim()){v(r("tasks.project_and_description_required"));return}try{await x({projectKey:m,description:u.trim(),workerId:y||void 0,developerId:T?Number(T):void 0,taskType:p,branchSlug:k.trim()||void 0,agentType:h||void 0})}catch(N){const B=N instanceof Error?N.message:r("tasks.failed_to_create_task");v(B)}}return n?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 font-mono",style:{backgroundColor:"var(--modal-backdrop, rgba(12,12,12,0.6))"},onClick:o=>{o.target===o.currentTarget&&s()},children:e.jsxs("div",{className:"w-full max-w-[480px] rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)]",onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] px-6 py-4",children:[e.jsxs("h2",{className:"text-sm text-[var(--text-primary)]",children:["// ",r("tasks.new_task")]}),e.jsx("button",{onClick:s,className:"text-[var(--text-muted)] transition-colors hover:text-[var(--text-primary)]",children:e.jsx(ie,{className:"h-4 w-4"})})]}),e.jsxs("form",{onSubmit:z,className:"px-6 py-5",children:[e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs text-[var(--text-muted)]",children:r("tasks.project")}),e.jsx(w,{value:m,onChange:D,options:d.map(o=>({value:o.key,label:o.name})),placeholder:r(c?"common.loading":"tasks.select_project"),disabled:c})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs text-[var(--text-muted)]",children:r("tasks.task_type")}),e.jsx(w,{value:p,onChange:C,options:ue})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs text-[var(--text-muted)]",children:r("tasks.form_agent_type")}),e.jsx(w,{value:h,onChange:j,options:he})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs text-[var(--text-muted)]",children:r("tasks.task_description")}),e.jsx("textarea",{value:u,onChange:o=>F(o.target.value),placeholder:r("tasks.describe_task_placeholder"),rows:4,className:"w-full resize-none rounded-[4px] border border-[var(--border)] bg-[var(--bg-input)] px-3 py-2.5 text-xs text-[var(--text-primary)] placeholder:text-[var(--text-muted)] outline-none focus:border-[var(--accent)]"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs text-[var(--text-muted)]",children:r("tasks.target_worker")}),e.jsx("input",{type:"text",value:y,onChange:o=>_(o.target.value),placeholder:r("tasks.any_able"),className:"w-full rounded-[4px] border border-[var(--border)] bg-[var(--bg-input)] px-3 py-2.5 text-xs text-[var(--text-primary)] placeholder:text-[var(--text-muted)] outline-none focus:border-[var(--accent)]"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs text-[var(--text-muted)]",children:r("tasks.branch_slug")}),e.jsx("input",{type:"text",value:k,onChange:o=>f(o.target.value),placeholder:r("tasks.branch_slug_placeholder"),className:"w-full rounded-[4px] border border-[var(--border)] bg-[var(--bg-input)] px-3 py-2.5 text-xs text-[var(--text-primary)] placeholder:text-[var(--text-muted)] outline-none focus:border-[var(--accent)]"})]}),g&&e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-xs text-[var(--text-muted)]",children:r("tasks.assign_developer")}),e.jsx(w,{value:T,onChange:E,options:K.map(o=>({value:String(o.id),label:o.name})),placeholder:r("tasks.select_developer")})]}),I&&e.jsx("div",{className:"rounded-[4px] bg-[#2a1515] border border-[var(--destructive)]/30 px-3 py-2 text-xs text-[var(--destructive)]",children:I})]}),e.jsxs("div",{className:"mt-6 flex items-center justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:s,className:"rounded-[4px] border border-[var(--border)] bg-transparent px-4 py-2 text-xs text-[var(--text-secondary)] transition-colors hover:text-[var(--text-primary)]",children:r("common.cancel")}),e.jsx("button",{type:"submit",disabled:l||!m||!u.trim(),className:"rounded-[4px] bg-[var(--accent)] px-4 py-2 text-xs text-black transition-opacity hover:opacity-90 disabled:opacity-40",children:r(l?"common.creating":"tasks.create_task")})]})]})]})}):null}function ke({isOpen:n,onClose:s,onForceCreate:d,onViewExisting:c,similarTask:x,isLoading:l}){const{t:r}=O();return!x||!n?null:e.jsx("div",{onClick:s,style:{position:"fixed",inset:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"var(--modal-backdrop, rgba(12,12,12,0.6))"},children:e.jsxs("div",{onClick:g=>g.stopPropagation(),style:{width:"100%",maxWidth:"480px",backgroundColor:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:"4px",padding:"1.5rem",fontFamily:"'JetBrains Mono', monospace"},children:[e.jsxs("div",{style:{marginBottom:"1.25rem"},children:[e.jsxs("div",{style:{color:"var(--accent)",fontSize:"0.875rem",fontWeight:600,display:"flex",alignItems:"center",gap:"0.5rem"},children:[e.jsx(fe,{style:{width:"1rem",height:"1rem"}}),r("tasks.dedup_title")]}),e.jsx("div",{style:{color:"var(--text-muted)",fontSize:"0.7rem",marginTop:"0.25rem"},children:r("tasks.dedup_description")})]}),e.jsxs("div",{style:{marginBottom:"1.25rem",padding:"0.75rem",border:"1px solid var(--border)",borderRadius:"4px",backgroundColor:"var(--bg-primary)"},children:[e.jsxs("div",{style:{color:"var(--text-muted)",fontSize:"0.65rem",fontFamily:"'JetBrains Mono', monospace"},children:["#",x.id," · ",x.status]}),e.jsx("div",{style:{color:"var(--text-primary)",fontSize:"0.75rem",marginTop:"0.375rem",lineHeight:"1.5"},children:x.description})]}),e.jsxs("div",{style:{display:"flex",gap:"0.75rem"},children:[e.jsx("button",{type:"button",onClick:s,disabled:l,className:"text-[var(--text-muted)] hover:text-[var(--text-primary)] hover:border-[var(--text-muted)]",style:{flex:1,padding:"0.5rem",backgroundColor:"transparent",border:"1px solid var(--border)",borderRadius:"4px",fontSize:"0.75rem",fontFamily:"'JetBrains Mono', monospace",cursor:l?"not-allowed":"pointer",opacity:l?.7:1,transition:"color 0.15s, border-color 0.15s"},children:r("common.cancel")}),e.jsx("button",{type:"button",onClick:()=>c(x.id),style:{flex:1,padding:"0.5rem",backgroundColor:"transparent",color:"var(--text-muted)",border:"1px solid var(--border)",borderRadius:"4px",fontSize:"0.75rem",fontFamily:"'JetBrains Mono', monospace",cursor:"pointer"},children:r("tasks.view_existing")}),e.jsx("button",{type:"button",onClick:d,disabled:l,style:{flex:1,padding:"0.5rem",backgroundColor:"var(--warning)",color:"#0C0C0C",border:"none",borderRadius:"4px",fontSize:"0.75rem",fontWeight:600,fontFamily:"'JetBrains Mono', monospace",cursor:l?"not-allowed":"pointer",opacity:l?.7:1},children:r(l?"common.creating":"tasks.dedup_create_anyway")})]})]})})}function Ne({task:n}){const s=G(),d=n.status===b.COMPLETED||n.status===b.FAILED;return e.jsxs("div",{onClick:()=>s(`/tasks/${n.id}`),className:"cursor-pointer rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-3 transition-colors active:bg-[var(--bg-input)]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("span",{className:"text-[11px] text-[var(--text-primary)] leading-tight line-clamp-2",title:`#${n.id} ${n.name??n.description}`,children:["#",n.id," ",V(n)]}),e.jsxs("span",{className:"flex items-center gap-1.5 shrink-0",children:[d&&e.jsx("button",{onClick:c=>{c.stopPropagation(),s(`/tasks/${n.id}?action=fork`)},className:"rounded-[4px] p-1 text-[var(--text-muted)] hover:text-[var(--accent)] transition-colors",children:e.jsx(ee,{className:"h-3 w-3"})}),e.jsx(X,{status:n.status})]})]}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-2 text-[11px] text-[var(--text-muted)]",children:[e.jsx("span",{children:Z(n.createdAt)}),e.jsx("span",{children:"·"}),e.jsx("span",{children:n.projectKey}),n.workerName&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("span",{children:n.workerName})]})]})]})}const Se=[{key:"all",labelKey:"tasks.tab_all"},{key:b.RUNNING,labelKey:"tasks.tab_running"},{key:b.QUEUED,labelKey:"tasks.tab_queued"},{key:b.COMPLETED,labelKey:"tasks.tab_completed"},{key:b.FAILED,labelKey:"tasks.tab_failed"},{key:b.CANCELLED,labelKey:"tasks.tab_cancelled"}],L=20;function Re(){const n=G(),{t:s}=O(),{tasks:d,loading:c,fetchTasks:x}=ve(),l=de(t=>t.taskSeq),[r,g]=a.useState("all"),[m,D]=a.useState(""),[u,F]=a.useState(""),[p,C]=a.useState(""),[h,j]=a.useState(1),[k,f]=a.useState(!1);xe(a.useMemo(()=>e.jsxs("button",{onClick:()=>f(!0),className:"flex items-center gap-1.5 rounded-[4px] bg-[var(--accent)] px-3 py-1.5 text-xs font-mono text-black transition-opacity hover:opacity-90",children:[e.jsx(ye,{className:"h-3.5 w-3.5"}),s("tasks.new_task")]}),[s]));const[y,_]=a.useState([]),[T,E]=a.useState(!1),[K,q]=a.useState([]),[I,v]=a.useState(!1),[z,o]=a.useState(!1),[N,B]=a.useState(null),[P,te]=a.useState(null);a.useEffect(()=>{const t={limit:String(L)};r!=="all"&&(t.status=r),m&&(t.projectKey=m),u&&(t.developerId=u),x(t)},[r,m,u,x,l]),a.useEffect(()=>{j(1)},[p,r,m,u]),a.useEffect(()=>{S.get("web/projects").json().then(t=>_(t)).catch(()=>{}),S.get("web/projects/-/developers").json().then(t=>q(t)).catch(()=>{})},[]),a.useEffect(()=>{!k||y.length>0||(E(!0),S.get("web/projects").json().then(t=>_(t)).catch(()=>{}).finally(()=>E(!1)))},[k,y.length]);const se=a.useCallback(async t=>{v(!0);try{const i=await S.post("web/tasks",{json:{projectKey:t.projectKey,description:t.description,workerId:t.workerId,developerId:t.developerId,taskType:t.taskType,branchSlug:t.branchSlug,agentType:t.agentType}}).json();f(!1),n(`/tasks/${i.task.id}`)}catch(i){if(i instanceof pe&&i.response.status===409){try{const A=await i.response.json();if(A.confirmRequired){B({id:A.confirmRequired.taskId,description:A.confirmRequired.message,status:"active"}),te(t),f(!1),o(!0);return}}catch{}U.error(s("tasks.similar_task_exists"))}else{const A=i instanceof Error?i.message:String(i);U.error(A)}}finally{v(!1)}},[n]),re=a.useCallback(async()=>{if(P){v(!0);try{const t=await S.post("web/tasks",{json:{projectKey:P.projectKey,description:P.description,workerId:P.workerId,force:!0}}).json();o(!1),n(`/tasks/${t.task.id}`)}finally{v(!1)}}},[P,n]),M=a.useMemo(()=>{if(!p.trim())return d;const t=p.toLowerCase();return d.filter(i=>(i.name??"").toLowerCase().includes(t)||i.description.toLowerCase().includes(t)||String(i.id).includes(p))},[d,p]),R=Math.max(1,Math.ceil(M.length/L)),$=M.slice((h-1)*L,h*L),ae=a.useMemo(()=>[{value:"",label:s("tasks.filter_project")},...y.map(t=>({value:t.key,label:t.name}))],[y,s]),oe=a.useMemo(()=>[{value:"",label:s("tasks.filter_developer")},...K.map(t=>({value:String(t.id),label:t.name}))],[K,s]),J=s(p?"tasks.try_adjusting_search":"tasks.create_first_task"),H=p?void 0:e.jsx("button",{onClick:()=>f(!0),className:"rounded-[4px] bg-[var(--accent)] px-5 py-2 text-[11px] font-bold text-black",children:s("tasks.create_task")});return e.jsxs("div",{className:"mx-auto max-w-6xl px-2 py-4 md:px-4 md:py-6 font-mono",children:[e.jsxs("div",{className:"mb-4 flex flex-col gap-3 md:gap-4 md:flex-row md:items-center",children:[e.jsx("div",{className:"flex items-center gap-1 overflow-x-auto pb-1 md:pb-0 no-scrollbar pr-4 md:pr-0",children:Se.map(t=>e.jsx("button",{onClick:()=>g(t.key),className:`shrink-0 rounded-[4px] px-3 py-2 h-10 md:h-8 text-xs transition-colors ${r===t.key?"text-[var(--accent)] bg-[var(--bg-input)]":"text-[var(--text-muted)] bg-[var(--bg-card)] hover:text-[var(--text-secondary)]"}`,children:s(t.labelKey)},t.key))}),e.jsxs("div",{className:"flex flex-col gap-2 md:ml-auto md:flex-row md:items-center",children:[e.jsxs("div",{className:"relative md:w-52",children:[e.jsx(me,{className:"absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-[var(--text-muted)]"}),e.jsx("input",{type:"text",placeholder:s("tasks.search_tasks"),value:p,onChange:t=>C(t.target.value),className:"w-full rounded-[4px] border border-[var(--border)] bg-[var(--bg-input)] py-1.5 pl-8 pr-3 text-xs text-[var(--text-primary)] placeholder:text-[var(--text-muted)] outline-none focus:border-[var(--accent)]"}),p&&e.jsx("button",{onClick:()=>C(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs text-[var(--text-muted)] hover:text-[var(--text-secondary)]",children:"x"})]}),e.jsx(w,{value:m,onChange:D,options:ae,className:"md:w-40"}),e.jsx(w,{value:u,onChange:F,options:oe,className:"md:w-40"})]})]}),e.jsx("div",{className:"hidden md:block rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)]",children:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[var(--border)] text-[11px] font-medium text-[#525252]",children:[e.jsx("th",{className:"w-16 px-4 py-2.5 text-right",children:s("tasks.id")}),e.jsx("th",{className:"px-4 py-2.5",children:s("tasks.description_col")}),e.jsx("th",{className:"px-4 py-2.5",children:s("tasks.status_col")}),e.jsx("th",{className:"px-4 py-2.5",children:s("tasks.project_col")}),e.jsx("th",{className:"px-4 py-2.5",children:s("tasks.assignee")}),e.jsx("th",{className:"px-4 py-2.5",children:s("tasks.worker")}),e.jsx("th",{className:"px-4 py-2.5",children:s("tasks.time")})]})}),e.jsxs("tbody",{children:[c&&$.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"p-4",children:e.jsx(Y,{rows:5})})}),!c&&M.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"p-4",children:e.jsx(Q,{icon:W,title:s("tasks.no_tasks_found"),description:J,action:H})})}),$.map(t=>e.jsx(ge,{task:t},t.id))]})]})}),e.jsxs("div",{className:"flex flex-col gap-2 md:hidden",children:[c&&$.length===0&&e.jsx("div",{className:"p-4",children:e.jsx(Y,{rows:5})}),!c&&M.length===0&&e.jsx(Q,{icon:W,title:s("tasks.no_tasks_found"),description:J,action:H}),$.map(t=>e.jsx(Ne,{task:t},t.id))]}),R>1&&e.jsxs("div",{className:"mt-6 flex items-center justify-center gap-1",children:[e.jsx("button",{onClick:()=>j(Math.max(1,h-1)),disabled:h===1,className:"rounded-[4px] px-2 py-1 text-xs text-[var(--text-muted)] hover:text-[var(--text-primary)] disabled:opacity-30 min-w-[44px] min-h-[44px] flex items-center justify-center",children:s("tasks.prev")}),Array.from({length:R},(t,i)=>i+1).map(t=>e.jsx("button",{onClick:()=>j(t),className:`rounded-[4px] px-2.5 py-1 text-xs transition-colors min-w-[44px] min-h-[44px] flex items-center justify-center ${h===t?"text-[var(--accent)] bg-[var(--bg-input)]":"text-[var(--text-muted)] hover:text-[var(--text-secondary)]"}`,children:t},t)),e.jsx("button",{onClick:()=>j(Math.min(R,h+1)),disabled:h===R,className:"rounded-[4px] px-2 py-1 text-xs text-[var(--text-muted)] hover:text-[var(--text-primary)] disabled:opacity-30 min-w-[44px] min-h-[44px] flex items-center justify-center",children:s("common.next")})]}),e.jsx(je,{isOpen:k,onClose:()=>f(!1),projects:y,projectsLoading:T,onSubmit:se,isSubmitting:I}),e.jsx(ke,{isOpen:z,onClose:()=>o(!1),onForceCreate:re,onViewExisting:t=>{o(!1),n(`/tasks/${t}`)},similarTask:N,isLoading:I})]})}export{Re as default};
@@ -1 +1 @@
1
- import{a as l,j as a}from"./index-ChW26424.js";import{a as u}from"./status-colors-B_811zpf.js";const r={QUEUED:"tasks.status_queued",ASSIGNED:"tasks.status_assigned",RUNNING:"tasks.status_running",SUSPENDED:"tasks.status_suspended",COMPLETED:"tasks.status_completed",FAILED:"tasks.status_failed",CANCELLED:"tasks.status_cancelled"};function E({status:s}){const{t:e}=l(),t=r[s],n=t?e(t):(s??"unknown").toLowerCase(),o=u(s);return a.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-xs",style:{color:o},children:[a.jsx("span",{style:{fontSize:"0.6rem"},children:"●"}),n]})}export{E as T};
1
+ import{a as l,j as a}from"./index-BZ8Ay5Q7.js";import{a as u}from"./status-colors-ClM8Aa8i.js";const r={QUEUED:"tasks.status_queued",ASSIGNED:"tasks.status_assigned",RUNNING:"tasks.status_running",SUSPENDED:"tasks.status_suspended",COMPLETED:"tasks.status_completed",FAILED:"tasks.status_failed",CANCELLED:"tasks.status_cancelled"};function E({status:s}){const{t:e}=l(),t=r[s],n=t?e(t):(s??"unknown").toLowerCase(),o=u(s);return a.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-xs",style:{color:o},children:[a.jsx("span",{style:{fontSize:"0.6rem"},children:"●"}),n]})}export{E as T};
@@ -1,4 +1,4 @@
1
- import{c as Q,l as ce,h as I,m as N,a as E,r as c,k as H,n as oe,j as e,X as V,o as le,f as de}from"./index-ChW26424.js";import{T as U,u as xe,a as K,A as W}from"./task-constants-Dkd_Zl1S.js";import{P as me,H as ue,C as pe}from"./PtyTerminal-uTPQuuyD.js";import{i as z,O as X}from"./OnboardingGuide-DUjDsOWd.js";import{S as w,C as he}from"./Select-DI-7imsE.js";import{a as Z}from"./status-colors-B_811zpf.js";import{a as fe}from"./date-BdNtiQTP.js";import{g as ve}from"./task-display-B5YOr3b8.js";import{u as ee}from"./useFetch-Lyui3S2c.js";import{P as $}from"./plus-CQMXvSQ5.js";import{R as ge}from"./rotate-ccw-C7yub8YZ.js";import{W as je}from"./wifi-lJpr616j.js";import"./chevron-right-CaN0g8DP.js";/**
1
+ import{c as Q,m as ce,h as I,n as N,a as E,r as c,k as H,o as oe,j as e,X as V,p as le,f as de,l as xe}from"./index-BZ8Ay5Q7.js";import{T as U,u as me,a as K,A as W}from"./task-constants-67tyYZHJ.js";import{P as ue,H as pe,C as he}from"./PtyTerminal-DyOs4Ihi.js";import{i as z,O as X}from"./OnboardingGuide-Y5FYHSft.js";import{S as w,C as fe}from"./Select-Drhq3WPg.js";import{a as Z}from"./status-colors-ClM8Aa8i.js";import{a as ve}from"./date-BdNtiQTP.js";import{u as ee}from"./useFetch-CjoCsmky.js";import{P as $}from"./plus-WIoVlw4A.js";import{R as ge}from"./rotate-ccw-BBWLasDm.js";import{W as je}from"./wifi-CEl4Ck1T.js";import"./chevron-right-5Y_vn1kG.js";/**
2
2
  * @license lucide-react v0.469.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -8,4 +8,4 @@ import{c as Q,l as ce,h as I,m as N,a as E,r as c,k as H,n as oe,j as e,X as V,o
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const ke=Q("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),te="overlord_home_terminal";function Ne(){try{const s=localStorage.getItem(te);if(s)return JSON.parse(s)}catch{}return{pinnedTaskIds:[],activeTaskId:null}}let B="";function M(s){const a=JSON.stringify(s);a!==B&&(B=a,localStorage.setItem(te,a))}const G=Ne(),ye=new Set([N.QUEUED,N.ASSIGNED,N.RUNNING,N.SUSPENDED]);let R=!1;const we=ce((s,a)=>({pinnedTaskIds:G.pinnedTaskIds,activeTaskId:G.activeTaskId,taskMetas:{},stageConfirm:null,loading:!1,setActiveTask:t=>{s({activeTaskId:t}),M({pinnedTaskIds:a().pinnedTaskIds,activeTaskId:t})},pinTask:t=>{const{pinnedTaskIds:n}=a();if(n.includes(t))return;const o=[...n,t];s({pinnedTaskIds:o}),M({pinnedTaskIds:o,activeTaskId:a().activeTaskId})},unpinTask:t=>{const{pinnedTaskIds:n,activeTaskId:o,taskMetas:m}=a(),r=n.filter(h=>h!==t),d=o===t?r[0]??null:o,{[t]:p,...i}=m;s({pinnedTaskIds:r,activeTaskId:d,taskMetas:i}),M({pinnedTaskIds:r,activeTaskId:d})},loadActiveTasks:async()=>{if(!R){R=!0,s({loading:!0});try{const n=(await I.get("web/tasks",{searchParams:{limit:"30"}}).json()).data.filter(i=>ye.has(i.status)),o={};for(const i of n)o[i.id]={id:i.id,name:i.name,description:i.description,status:i.status,projectKey:i.projectKey,currentStage:i.currentStage,currentSessionId:i.currentSessionId,updatedAt:i.updatedAt};const r=[...n].sort((i,h)=>h.updatedAt.localeCompare(i.updatedAt)).map(i=>i.id),{activeTaskId:d}=a(),p=d&&r.includes(d)?d:r[0]??null;s({taskMetas:o,pinnedTaskIds:r,activeTaskId:p}),M({pinnedTaskIds:r,activeTaskId:p})}catch{}finally{R=!1,s({loading:!1})}}},fetchStageConfirm:async t=>{try{const n=await I.get(`web/tasks/${t}/pending-confirm`).json();s({stageConfirm:n.confirm})}catch{s({stageConfirm:null})}},clearStageConfirm:()=>s({stageConfirm:null}),updateTaskMeta:(t,n)=>{const{taskMetas:o}=a(),m=o[t];m&&s({taskMetas:{...o,[t]:{...m,...n}}})}}));function Te(){const[s,a]=c.useState(()=>z());c.useEffect(()=>{const n=()=>a(!0),o=()=>a(z());return window.addEventListener("onboarding-dismissed",n),window.addEventListener("storage",o),()=>{window.removeEventListener("onboarding-dismissed",n),window.removeEventListener("storage",o)}},[]);const{data:t}=ee(()=>s?Promise.resolve(null):I.get("web/dashboard/stats").json(),[s]);return s||!t?null:{activeTasks:(t.active_tasks??0)+(t.queued_tasks??0),totalWorkers:t.online_workers??0,totalProjects:t.project_count??0,totalDevelopers:t.developer_count??0}}function Se({taskId:s,confirm:a,onSubmitted:t}){const{t:n}=E(),[o,m]=c.useState(a.timeout),[r,d]=c.useState(!1);c.useEffect(()=>{m(a.timeout);const i=setInterval(()=>{m(h=>h<=1?(clearInterval(i),0):h-1)},1e3);return()=>clearInterval(i)},[a.timeout,a.stageName]);const p=c.useCallback(async i=>{d(!0);try{await I.post(`web/tasks/${s}/confirm-stage`,{json:{stageName:a.stageName,approved:i}}),t()}catch{}finally{d(!1)}},[s,a.stageName,t]);return e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b-2 border-[var(--warning)] bg-[var(--warning)]/10 px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(pe,{className:"h-3.5 w-3.5 shrink-0 text-[var(--warning)]"}),e.jsxs("span",{className:"truncate text-xs text-[var(--text-primary)]",children:["// stage: ",a.stageName]}),e.jsx("span",{className:"shrink-0 text-xs text-[var(--warning)]",children:fe(o)})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("button",{onClick:()=>p(!1),disabled:r,className:"rounded-[4px] border border-[var(--border)] px-2 py-1 text-[11px] text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors disabled:opacity-50",children:n("tasks.reject")}),e.jsx("button",{onClick:()=>p(!0),disabled:r,className:"rounded-[4px] bg-[var(--accent)] px-2 py-1 text-[11px] text-black hover:opacity-90 transition-opacity disabled:opacity-50",children:n(r?"tasks.stage_submitting":"tasks.confirm_and_proceed")})]})]})}function Ce({projectKey:s,onProjectChange:a,onCreated:t}){const{t:n}=E(),o=xe(u=>u.createTask),[m,r]=c.useState(""),[d,p]=c.useState("feat"),[i,h]=c.useState(""),[f,T]=c.useState(!1),[S,C]=c.useState(!1),[D,A]=c.useState(!1),{data:P}=ee(()=>I.get("web/projects").json(),[]),v=c.useMemo(()=>{const u=(P??[]).map(k=>({value:k.key,label:k.key}));return[{value:"",label:n("terminal_home.all_projects")},...u]},[P,n]),y=c.useRef(!1);c.useEffect(()=>{if(!y.current){if(s){y.current=!0;return}v.length>1&&(a(v[1].value),y.current=!0)}},[s,v,a]);const g=!!s&&!!m.trim();function b(){g&&C(!0)}async function x(){if(C(!1),!!g){T(!0);try{const u=await o({projectKey:s,description:m.trim(),taskType:d,agentType:i||void 0});r(""),t(u.id)}catch{}finally{T(!1)}}}const O=n("terminal_home.confirm_create_message").replace("{taskType}",d).replace("{projectKey}",s).replace("{description}",m.trim()),_="flex-1 rounded-[4px] border border-[var(--border)] bg-[var(--bg-input)] px-2 py-1.5 text-xs text-[var(--text-primary)] placeholder:text-[var(--text-muted)] outline-none focus:border-[var(--accent)]";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hidden md:flex items-center gap-2 border-b border-[var(--border)] bg-[var(--bg-card)] px-3 py-2",children:[e.jsx("div",{className:"w-[140px]",children:e.jsx(w,{value:s,onChange:a,options:v,placeholder:n("terminal_home.select_project")})}),e.jsx("div",{className:"w-[100px]",children:e.jsx(w,{value:d,onChange:p,options:K})}),e.jsx("div",{className:"w-[120px]",children:e.jsx(w,{value:i,onChange:h,options:W})}),e.jsx("input",{type:"text",value:m,onChange:u=>r(u.target.value),onKeyDown:u=>u.key==="Enter"&&b(),placeholder:n("terminal_home.task_description_placeholder"),className:_,disabled:f}),e.jsxs("button",{onClick:b,disabled:f||!g,className:"flex items-center gap-1 rounded-[4px] bg-[var(--accent)] px-3 py-1.5 text-xs text-black hover:opacity-90 transition-opacity disabled:opacity-50",children:[e.jsx($,{className:"h-3 w-3"}),n(f?"common.creating":"terminal_home.new_task")]})]}),e.jsx("div",{className:"md:hidden border-b border-[var(--border)] bg-[var(--bg-card)]",children:D?e.jsxs("div",{className:"flex flex-col gap-2 p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1",children:e.jsx(w,{value:s,onChange:a,options:v,placeholder:n("terminal_home.select_project")})}),e.jsx("div",{className:"w-[100px]",children:e.jsx(w,{value:d,onChange:p,options:K})}),e.jsx("div",{className:"w-[120px]",children:e.jsx(w,{value:i,onChange:h,options:W})}),e.jsx("button",{onClick:()=>A(!1),className:"p-1 text-[var(--text-muted)]",children:e.jsx(V,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:m,onChange:u=>r(u.target.value),onKeyDown:u=>u.key==="Enter"&&b(),placeholder:n("terminal_home.task_description_placeholder"),className:_,disabled:f}),e.jsx("button",{onClick:b,disabled:f||!g,className:"rounded-[4px] bg-[var(--accent)] px-3 py-1.5 text-xs text-black hover:opacity-90 transition-opacity disabled:opacity-50",children:e.jsx($,{className:"h-3 w-3"})})]})]}):e.jsxs("button",{onClick:()=>A(!0),className:"flex w-full items-center justify-center gap-1 py-2 text-xs text-[var(--accent)] hover:opacity-80",children:[e.jsx($,{className:"h-3.5 w-3.5"}),n("terminal_home.new_task")]})}),e.jsx(le,{isOpen:S,onClose:()=>C(!1),onConfirm:x,title:n("terminal_home.confirm_create_title"),message:O,confirmVariant:"accent",confirmLabel:n("terminal_home.new_task"),isLoading:f})]})}function q({status:s,size:a}){const t=s===N.SUSPENDED,n=Z(s),o=a==="sm"?"h-1.5 w-1.5":"h-2 w-2";return e.jsx("span",{className:`${o} shrink-0 rounded-full ${t?"animate-pulse":""}`,style:{backgroundColor:t?"var(--warning)":n}})}function _e({tasks:s,activeId:a,onSelect:t,onUnpin:n,children:o}){const m=de();return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hidden md:flex flex-col border-r border-[var(--border)] bg-[var(--bg-card)] overflow-y-auto",style:{width:200,minWidth:200},children:[e.jsx("div",{className:"border-b border-[var(--border)] px-3 py-2",children:e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:"// active tasks"})}),s.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:"no active tasks"})}):e.jsx("div",{className:"flex-1",children:s.map(r=>{const d=r.id===a;return e.jsxs("div",{onClick:()=>t(r.id),className:`group flex items-center gap-2 px-3 py-2 cursor-pointer transition-colors ${d?"bg-[var(--accent)]/10 text-[var(--text-primary)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-input)] hover:text-[var(--text-primary)]"}`,children:[e.jsx(q,{status:r.status,size:"md"}),e.jsxs("div",{className:"flex-1 min-w-0",title:`#${r.id} ${r.name??r.description}`,children:[e.jsxs("div",{className:"truncate text-xs",children:["#",r.id," ",ve(r)]}),e.jsx("div",{className:"text-[10px] text-[var(--text-muted)]",children:r.projectKey})]}),e.jsx("button",{onClick:p=>{p.stopPropagation(),n(r.id)},className:"hidden group-hover:flex items-center justify-center shrink-0 w-5 h-5 text-[var(--text-muted)] hover:text-[var(--text-primary)]",title:"unpin",children:e.jsx(V,{className:"h-3 w-3"})}),e.jsx("button",{onClick:p=>{p.stopPropagation(),m(`/tasks/${r.id}`)},className:"hidden group-hover:flex items-center justify-center shrink-0 w-5 h-5 text-[var(--text-muted)] hover:text-[var(--accent)]",title:"open detail",children:e.jsx("span",{className:"text-[10px] leading-none",children:"→"})})]},r.id)})})]}),e.jsxs("div",{className:"flex flex-col md:hidden",children:[e.jsx("div",{className:"flex items-center gap-1 overflow-x-auto no-scrollbar border-b border-[var(--border)] bg-[var(--bg-card)] px-2",style:{height:44},children:s.length===0?e.jsx("div",{className:"flex items-center justify-center w-full",children:e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:"no active tasks"})}):s.map(r=>{const d=r.id===a;return e.jsxs("button",{onClick:()=>t(r.id),className:`flex shrink-0 items-center gap-1.5 px-3 border-b-2 transition-colors ${d?"border-[var(--accent)] text-[var(--text-primary)]":"border-transparent text-[var(--text-secondary)]"}`,style:{height:44},children:[e.jsx(q,{status:r.status,size:"sm"}),e.jsxs("span",{className:"text-[11px] whitespace-nowrap",children:["#",r.id]})]},r.id)})}),o]})]})}function Ie({task:s,takeoverState:a,onTakeover:t,onRelease:n}){const o=Z(s.status),m=a==="manual";return e.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] bg-[var(--bg-card)] px-3",style:{height:36,minHeight:36},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:s.projectKey}),e.jsx("span",{className:"text-[11px]",style:{color:o},children:s.status.toLowerCase()}),s.currentStage&&e.jsxs("span",{className:"text-[11px] text-[var(--text-muted)]",children:["// ",s.currentStage]})]}),e.jsx("div",{className:"flex items-center gap-1",children:!U.includes(s.status)&&(m?e.jsxs("button",{onClick:n,className:"flex items-center gap-1.5 rounded-[4px] px-2.5 py-0.5 text-[11px] font-medium text-[var(--accent)]",style:{backgroundColor:"rgba(34,197,94,0.12)"},children:[e.jsx(ge,{className:"h-3 w-3"}),e.jsx("span",{className:"hidden md:inline",children:"restore auto"})]}):e.jsxs("button",{onClick:t,disabled:a==="requesting",className:"flex items-center gap-1.5 rounded-[4px] px-2.5 py-0.5 text-[11px] font-medium text-[var(--warning)] disabled:opacity-50",style:{backgroundColor:"rgba(245,158,11,0.12)"},children:[e.jsx(ue,{className:"h-3 w-3"}),e.jsx("span",{className:"hidden md:inline",children:"take over"})]}))})]})}function Ee({task:s,ptyStatus:a}){const t=a==="connected";return e.jsxs("div",{className:"flex items-center justify-between border-t border-[var(--border)] bg-[var(--bg-card)] px-3",style:{height:28,minHeight:28},children:[e.jsx("span",{className:"text-[10px] text-[var(--text-muted)]",children:s.currentStage?`stage: ${s.currentStage}`:`task #${s.id}`}),e.jsxs("span",{className:`flex items-center gap-1 text-[10px] ${t?"text-[var(--accent)]":"text-[var(--text-muted)]"}`,children:[t?e.jsx(je,{className:"h-2.5 w-2.5"}):e.jsx(ke,{className:"h-2.5 w-2.5"}),t?"connected":a]})]})}function J({onboardingData:s}){const[a,t]=c.useState(!1),{t:n}=E();return s?a?e.jsxs("div",{className:"border-b border-[var(--accent)]/30",children:[e.jsxs("button",{onClick:()=>t(!1),className:"flex w-full items-center justify-between bg-[var(--bg-card)] px-3 py-1.5 transition-colors hover:bg-[var(--bg-input)]",children:[e.jsx("span",{className:"text-[11px] text-[var(--accent)]",children:n("onboarding.getting_started")}),e.jsx(be,{className:"h-3 w-3 text-[var(--text-muted)]"})]}),e.jsx("div",{className:"max-h-[300px] overflow-y-auto",children:e.jsx(X,{data:s})})]}):e.jsxs("button",{onClick:()=>t(!0),className:"flex w-full items-center justify-between border-b border-[var(--accent)]/30 bg-[var(--bg-card)] px-3 py-1.5 transition-colors hover:bg-[var(--bg-input)]",style:{height:36},children:[e.jsx("span",{className:"text-[11px] text-[var(--accent)]",children:n("onboarding.getting_started")}),e.jsx(he,{className:"h-3 w-3 text-[var(--text-muted)]"})]}):null}function Y({onboardingData:s}){const{t:a}=E();return e.jsx("div",{className:`flex flex-1 flex-col items-center p-4 md:p-6 ${s?"overflow-auto":"justify-center"}`,children:s?e.jsx("div",{className:"w-full max-w-lg",children:e.jsx(X,{data:s})}):e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"mb-3 text-3xl text-[var(--border)]",children:[">","_"]}),e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:a("terminal_home.no_active_tasks")}),e.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:a("terminal_home.create_task_hint")})]})})}function ze(){const{t:s}=E(),{pinnedTaskIds:a,activeTaskId:t,taskMetas:n,stageConfirm:o,loading:m,setActiveTask:r,pinTask:d,unpinTask:p,loadActiveTasks:i,fetchStageConfirm:h,clearStageConfirm:f,updateTaskMeta:T}=we(),S=c.useRef(null),[C,D]=c.useState("disconnected"),[A,P]=c.useState("auto"),[v,y]=c.useState(""),g=H(l=>l.lastEvent),b=H(l=>l.status),x=t?n[t]??null:null,O=x?U.includes(x.status):!1,_=c.useRef(!1);c.useEffect(()=>{!_.current&&x&&(y(x.projectKey),_.current=!0)},[x]);const u=c.useMemo(()=>{const l=a.map(j=>n[j]).filter(Boolean);return v?l.filter(j=>j.projectKey===v):l},[a,n,v]);c.useEffect(()=>{u.length>0&&t&&!u.some(l=>l.id===t)&&r(u[0].id)},[u,t,r]);const k=Te();oe(x?`#${x.id} ${x.name??x.description}`:null),c.useEffect(()=>{i()},[i]),c.useEffect(()=>{t&&(x==null?void 0:x.status)===N.SUSPENDED?h(t):f()},[t,x==null?void 0:x.status,h,f]),c.useEffect(()=>{if(g){if(g.event==="task_status_changed"){const{taskId:l,status:j,currentStage:F}=g,L={status:j,updatedAt:new Date().toISOString()};F!==void 0&&(L.currentStage=F),T(l,L),j===N.SUSPENDED&&l===t&&h(l),U.includes(j)&&l===t&&f()}g.event==="task_created"&&i()}},[g,t,h,f,T,i]),c.useEffect(()=>{if(b==="connected")return;const j=setInterval(()=>{document.visibilityState!=="hidden"&&i()},15e3);return()=>clearInterval(j)},[b,i]);const se=c.useCallback(l=>{d(l),r(l),i()},[d,r,i]),ae=c.useCallback(()=>{f(),i()},[f,i]),ne=c.useCallback(()=>{var l;(l=S.current)==null||l.requestTakeover()},[]),re=c.useCallback(()=>{var l;(l=S.current)==null||l.releaseTakeover()},[]);if(m&&a.length===0)return e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:s("common.loading")})});const ie=u.length>0;return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[e.jsx(Ce,{projectKey:v,onProjectChange:y,onCreated:se}),e.jsx("div",{className:"flex flex-col md:flex-row flex-1 overflow-hidden",children:ie?e.jsxs(e.Fragment,{children:[e.jsx(_e,{tasks:u,activeId:t,onSelect:r,onUnpin:p,children:e.jsx("div",{className:"md:hidden",children:e.jsx(J,{onboardingData:k})})}),e.jsx("div",{className:"flex flex-1 flex-col overflow-hidden",children:x?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden md:block",children:e.jsx(J,{onboardingData:k})}),e.jsx(Ie,{task:x,takeoverState:A,onTakeover:ne,onRelease:re}),o&&t&&e.jsx(Se,{taskId:t,confirm:o,onSubmitted:ae}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:e.jsx(me,{taskId:t,sessionId:x.currentSessionId??void 0,taskFinished:O,onStatusChange:D,onTakeoverChange:P,ref:S},t)}),e.jsx(Ee,{task:x,ptyStatus:C})]}):e.jsx(Y,{onboardingData:k})})]}):e.jsx(Y,{onboardingData:k})})]})}export{ze as default};
11
+ */const ke=Q("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),te="overlord_home_terminal";function Ne(){try{const s=localStorage.getItem(te);if(s)return JSON.parse(s)}catch{}return{pinnedTaskIds:[],activeTaskId:null}}let B="";function M(s){const a=JSON.stringify(s);a!==B&&(B=a,localStorage.setItem(te,a))}const G=Ne(),ye=new Set([N.QUEUED,N.ASSIGNED,N.RUNNING,N.SUSPENDED]);let R=!1;const we=ce((s,a)=>({pinnedTaskIds:G.pinnedTaskIds,activeTaskId:G.activeTaskId,taskMetas:{},stageConfirm:null,loading:!1,setActiveTask:t=>{s({activeTaskId:t}),M({pinnedTaskIds:a().pinnedTaskIds,activeTaskId:t})},pinTask:t=>{const{pinnedTaskIds:n}=a();if(n.includes(t))return;const o=[...n,t];s({pinnedTaskIds:o}),M({pinnedTaskIds:o,activeTaskId:a().activeTaskId})},unpinTask:t=>{const{pinnedTaskIds:n,activeTaskId:o,taskMetas:m}=a(),r=n.filter(h=>h!==t),d=o===t?r[0]??null:o,{[t]:p,...i}=m;s({pinnedTaskIds:r,activeTaskId:d,taskMetas:i}),M({pinnedTaskIds:r,activeTaskId:d})},loadActiveTasks:async()=>{if(!R){R=!0,s({loading:!0});try{const n=(await I.get("web/tasks",{searchParams:{limit:"30"}}).json()).data.filter(i=>ye.has(i.status)),o={};for(const i of n)o[i.id]={id:i.id,name:i.name,description:i.description,status:i.status,projectKey:i.projectKey,currentStage:i.currentStage,currentSessionId:i.currentSessionId,updatedAt:i.updatedAt};const r=[...n].sort((i,h)=>h.updatedAt.localeCompare(i.updatedAt)).map(i=>i.id),{activeTaskId:d}=a(),p=d&&r.includes(d)?d:r[0]??null;s({taskMetas:o,pinnedTaskIds:r,activeTaskId:p}),M({pinnedTaskIds:r,activeTaskId:p})}catch{}finally{R=!1,s({loading:!1})}}},fetchStageConfirm:async t=>{try{const n=await I.get(`web/tasks/${t}/pending-confirm`).json();s({stageConfirm:n.confirm})}catch{s({stageConfirm:null})}},clearStageConfirm:()=>s({stageConfirm:null}),updateTaskMeta:(t,n)=>{const{taskMetas:o}=a(),m=o[t];m&&s({taskMetas:{...o,[t]:{...m,...n}}})}}));function Te(){const[s,a]=c.useState(()=>z());c.useEffect(()=>{const n=()=>a(!0),o=()=>a(z());return window.addEventListener("onboarding-dismissed",n),window.addEventListener("storage",o),()=>{window.removeEventListener("onboarding-dismissed",n),window.removeEventListener("storage",o)}},[]);const{data:t}=ee(()=>s?Promise.resolve(null):I.get("web/dashboard/stats").json(),[s]);return s||!t?null:{activeTasks:(t.active_tasks??0)+(t.queued_tasks??0),totalWorkers:t.online_workers??0,totalProjects:t.project_count??0,totalDevelopers:t.developer_count??0}}function Se({taskId:s,confirm:a,onSubmitted:t}){const{t:n}=E(),[o,m]=c.useState(a.timeout),[r,d]=c.useState(!1);c.useEffect(()=>{m(a.timeout);const i=setInterval(()=>{m(h=>h<=1?(clearInterval(i),0):h-1)},1e3);return()=>clearInterval(i)},[a.timeout,a.stageName]);const p=c.useCallback(async i=>{d(!0);try{await I.post(`web/tasks/${s}/confirm-stage`,{json:{stageName:a.stageName,approved:i}}),t()}catch{}finally{d(!1)}},[s,a.stageName,t]);return e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b-2 border-[var(--warning)] bg-[var(--warning)]/10 px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(he,{className:"h-3.5 w-3.5 shrink-0 text-[var(--warning)]"}),e.jsxs("span",{className:"truncate text-xs text-[var(--text-primary)]",children:["// stage: ",a.stageName]}),e.jsx("span",{className:"shrink-0 text-xs text-[var(--warning)]",children:ve(o)})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("button",{onClick:()=>p(!1),disabled:r,className:"rounded-[4px] border border-[var(--border)] px-2 py-1 text-[11px] text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors disabled:opacity-50",children:n("tasks.reject")}),e.jsx("button",{onClick:()=>p(!0),disabled:r,className:"rounded-[4px] bg-[var(--accent)] px-2 py-1 text-[11px] text-black hover:opacity-90 transition-opacity disabled:opacity-50",children:n(r?"tasks.stage_submitting":"tasks.confirm_and_proceed")})]})]})}function Ce({projectKey:s,onProjectChange:a,onCreated:t}){const{t:n}=E(),o=me(u=>u.createTask),[m,r]=c.useState(""),[d,p]=c.useState("feat"),[i,h]=c.useState(""),[f,T]=c.useState(!1),[S,C]=c.useState(!1),[D,A]=c.useState(!1),{data:P}=ee(()=>I.get("web/projects").json(),[]),v=c.useMemo(()=>{const u=(P??[]).map(k=>({value:k.key,label:k.key}));return[{value:"",label:n("terminal_home.all_projects")},...u]},[P,n]),y=c.useRef(!1);c.useEffect(()=>{if(!y.current){if(s){y.current=!0;return}v.length>1&&(a(v[1].value),y.current=!0)}},[s,v,a]);const g=!!s&&!!m.trim();function b(){g&&C(!0)}async function x(){if(C(!1),!!g){T(!0);try{const u=await o({projectKey:s,description:m.trim(),taskType:d,agentType:i||void 0});r(""),t(u.id)}catch{}finally{T(!1)}}}const O=n("terminal_home.confirm_create_message").replace("{taskType}",d).replace("{projectKey}",s).replace("{description}",m.trim()),_="flex-1 rounded-[4px] border border-[var(--border)] bg-[var(--bg-input)] px-2 py-1.5 text-xs text-[var(--text-primary)] placeholder:text-[var(--text-muted)] outline-none focus:border-[var(--accent)]";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hidden md:flex items-center gap-2 border-b border-[var(--border)] bg-[var(--bg-card)] px-3 py-2",children:[e.jsx("div",{className:"w-[140px]",children:e.jsx(w,{value:s,onChange:a,options:v,placeholder:n("terminal_home.select_project")})}),e.jsx("div",{className:"w-[100px]",children:e.jsx(w,{value:d,onChange:p,options:K})}),e.jsx("div",{className:"w-[120px]",children:e.jsx(w,{value:i,onChange:h,options:W})}),e.jsx("input",{type:"text",value:m,onChange:u=>r(u.target.value),onKeyDown:u=>u.key==="Enter"&&b(),placeholder:n("terminal_home.task_description_placeholder"),className:_,disabled:f}),e.jsxs("button",{onClick:b,disabled:f||!g,className:"flex items-center gap-1 rounded-[4px] bg-[var(--accent)] px-3 py-1.5 text-xs text-black hover:opacity-90 transition-opacity disabled:opacity-50",children:[e.jsx($,{className:"h-3 w-3"}),n(f?"common.creating":"terminal_home.new_task")]})]}),e.jsx("div",{className:"md:hidden border-b border-[var(--border)] bg-[var(--bg-card)]",children:D?e.jsxs("div",{className:"flex flex-col gap-2 p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1",children:e.jsx(w,{value:s,onChange:a,options:v,placeholder:n("terminal_home.select_project")})}),e.jsx("div",{className:"w-[100px]",children:e.jsx(w,{value:d,onChange:p,options:K})}),e.jsx("div",{className:"w-[120px]",children:e.jsx(w,{value:i,onChange:h,options:W})}),e.jsx("button",{onClick:()=>A(!1),className:"p-1 text-[var(--text-muted)]",children:e.jsx(V,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:m,onChange:u=>r(u.target.value),onKeyDown:u=>u.key==="Enter"&&b(),placeholder:n("terminal_home.task_description_placeholder"),className:_,disabled:f}),e.jsx("button",{onClick:b,disabled:f||!g,className:"rounded-[4px] bg-[var(--accent)] px-3 py-1.5 text-xs text-black hover:opacity-90 transition-opacity disabled:opacity-50",children:e.jsx($,{className:"h-3 w-3"})})]})]}):e.jsxs("button",{onClick:()=>A(!0),className:"flex w-full items-center justify-center gap-1 py-2 text-xs text-[var(--accent)] hover:opacity-80",children:[e.jsx($,{className:"h-3.5 w-3.5"}),n("terminal_home.new_task")]})}),e.jsx(le,{isOpen:S,onClose:()=>C(!1),onConfirm:x,title:n("terminal_home.confirm_create_title"),message:O,confirmVariant:"accent",confirmLabel:n("terminal_home.new_task"),isLoading:f})]})}function q({status:s,size:a}){const t=s===N.SUSPENDED,n=Z(s),o=a==="sm"?"h-1.5 w-1.5":"h-2 w-2";return e.jsx("span",{className:`${o} shrink-0 rounded-full ${t?"animate-pulse":""}`,style:{backgroundColor:t?"var(--warning)":n}})}function _e({tasks:s,activeId:a,onSelect:t,onUnpin:n,children:o}){const m=de();return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"hidden md:flex flex-col border-r border-[var(--border)] bg-[var(--bg-card)] overflow-y-auto",style:{width:200,minWidth:200},children:[e.jsx("div",{className:"border-b border-[var(--border)] px-3 py-2",children:e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:"// active tasks"})}),s.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:"no active tasks"})}):e.jsx("div",{className:"flex-1",children:s.map(r=>{const d=r.id===a;return e.jsxs("div",{onClick:()=>t(r.id),className:`group flex items-center gap-2 px-3 py-2 cursor-pointer transition-colors ${d?"bg-[var(--accent)]/10 text-[var(--text-primary)]":"text-[var(--text-secondary)] hover:bg-[var(--bg-input)] hover:text-[var(--text-primary)]"}`,children:[e.jsx(q,{status:r.status,size:"md"}),e.jsxs("div",{className:"flex-1 min-w-0",title:`#${r.id} ${r.name??r.description}`,children:[e.jsxs("div",{className:"truncate text-xs",children:["#",r.id," ",xe(r)]}),e.jsx("div",{className:"text-[10px] text-[var(--text-muted)]",children:r.projectKey})]}),e.jsx("button",{onClick:p=>{p.stopPropagation(),n(r.id)},className:"hidden group-hover:flex items-center justify-center shrink-0 w-5 h-5 text-[var(--text-muted)] hover:text-[var(--text-primary)]",title:"unpin",children:e.jsx(V,{className:"h-3 w-3"})}),e.jsx("button",{onClick:p=>{p.stopPropagation(),m(`/tasks/${r.id}`)},className:"hidden group-hover:flex items-center justify-center shrink-0 w-5 h-5 text-[var(--text-muted)] hover:text-[var(--accent)]",title:"open detail",children:e.jsx("span",{className:"text-[10px] leading-none",children:"→"})})]},r.id)})})]}),e.jsxs("div",{className:"flex flex-col md:hidden",children:[e.jsx("div",{className:"flex items-center gap-1 overflow-x-auto no-scrollbar border-b border-[var(--border)] bg-[var(--bg-card)] px-2",style:{height:44},children:s.length===0?e.jsx("div",{className:"flex items-center justify-center w-full",children:e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:"no active tasks"})}):s.map(r=>{const d=r.id===a;return e.jsxs("button",{onClick:()=>t(r.id),className:`flex shrink-0 items-center gap-1.5 px-3 border-b-2 transition-colors ${d?"border-[var(--accent)] text-[var(--text-primary)]":"border-transparent text-[var(--text-secondary)]"}`,style:{height:44},children:[e.jsx(q,{status:r.status,size:"sm"}),e.jsxs("span",{className:"text-[11px] whitespace-nowrap",children:["#",r.id]})]},r.id)})}),o]})]})}function Ie({task:s,takeoverState:a,onTakeover:t,onRelease:n}){const o=Z(s.status),m=a==="manual";return e.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] bg-[var(--bg-card)] px-3",style:{height:36,minHeight:36},children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-[11px] text-[var(--text-muted)]",children:s.projectKey}),e.jsx("span",{className:"text-[11px]",style:{color:o},children:s.status.toLowerCase()}),s.currentStage&&e.jsxs("span",{className:"text-[11px] text-[var(--text-muted)]",children:["// ",s.currentStage]})]}),e.jsx("div",{className:"flex items-center gap-1",children:!U.includes(s.status)&&(m?e.jsxs("button",{onClick:n,className:"flex items-center gap-1.5 rounded-[4px] px-2.5 py-0.5 text-[11px] font-medium text-[var(--accent)]",style:{backgroundColor:"rgba(34,197,94,0.12)"},children:[e.jsx(ge,{className:"h-3 w-3"}),e.jsx("span",{className:"hidden md:inline",children:"restore auto"})]}):e.jsxs("button",{onClick:t,disabled:a==="requesting",className:"flex items-center gap-1.5 rounded-[4px] px-2.5 py-0.5 text-[11px] font-medium text-[var(--warning)] disabled:opacity-50",style:{backgroundColor:"rgba(245,158,11,0.12)"},children:[e.jsx(pe,{className:"h-3 w-3"}),e.jsx("span",{className:"hidden md:inline",children:"take over"})]}))})]})}function Ee({task:s,ptyStatus:a}){const t=a==="connected";return e.jsxs("div",{className:"flex items-center justify-between border-t border-[var(--border)] bg-[var(--bg-card)] px-3",style:{height:28,minHeight:28},children:[e.jsx("span",{className:"text-[10px] text-[var(--text-muted)]",children:s.currentStage?`stage: ${s.currentStage}`:`task #${s.id}`}),e.jsxs("span",{className:`flex items-center gap-1 text-[10px] ${t?"text-[var(--accent)]":"text-[var(--text-muted)]"}`,children:[t?e.jsx(je,{className:"h-2.5 w-2.5"}):e.jsx(ke,{className:"h-2.5 w-2.5"}),t?"connected":a]})]})}function J({onboardingData:s}){const[a,t]=c.useState(!1),{t:n}=E();return s?a?e.jsxs("div",{className:"border-b border-[var(--accent)]/30",children:[e.jsxs("button",{onClick:()=>t(!1),className:"flex w-full items-center justify-between bg-[var(--bg-card)] px-3 py-1.5 transition-colors hover:bg-[var(--bg-input)]",children:[e.jsx("span",{className:"text-[11px] text-[var(--accent)]",children:n("onboarding.getting_started")}),e.jsx(be,{className:"h-3 w-3 text-[var(--text-muted)]"})]}),e.jsx("div",{className:"max-h-[300px] overflow-y-auto",children:e.jsx(X,{data:s})})]}):e.jsxs("button",{onClick:()=>t(!0),className:"flex w-full items-center justify-between border-b border-[var(--accent)]/30 bg-[var(--bg-card)] px-3 py-1.5 transition-colors hover:bg-[var(--bg-input)]",style:{height:36},children:[e.jsx("span",{className:"text-[11px] text-[var(--accent)]",children:n("onboarding.getting_started")}),e.jsx(fe,{className:"h-3 w-3 text-[var(--text-muted)]"})]}):null}function Y({onboardingData:s}){const{t:a}=E();return e.jsx("div",{className:`flex flex-1 flex-col items-center p-4 md:p-6 ${s?"overflow-auto":"justify-center"}`,children:s?e.jsx("div",{className:"w-full max-w-lg",children:e.jsx(X,{data:s})}):e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"mb-3 text-3xl text-[var(--border)]",children:[">","_"]}),e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:a("terminal_home.no_active_tasks")}),e.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:a("terminal_home.create_task_hint")})]})})}function We(){const{t:s}=E(),{pinnedTaskIds:a,activeTaskId:t,taskMetas:n,stageConfirm:o,loading:m,setActiveTask:r,pinTask:d,unpinTask:p,loadActiveTasks:i,fetchStageConfirm:h,clearStageConfirm:f,updateTaskMeta:T}=we(),S=c.useRef(null),[C,D]=c.useState("disconnected"),[A,P]=c.useState("auto"),[v,y]=c.useState(""),g=H(l=>l.lastEvent),b=H(l=>l.status),x=t?n[t]??null:null,O=x?U.includes(x.status):!1,_=c.useRef(!1);c.useEffect(()=>{!_.current&&x&&(y(x.projectKey),_.current=!0)},[x]);const u=c.useMemo(()=>{const l=a.map(j=>n[j]).filter(Boolean);return v?l.filter(j=>j.projectKey===v):l},[a,n,v]);c.useEffect(()=>{u.length>0&&t&&!u.some(l=>l.id===t)&&r(u[0].id)},[u,t,r]);const k=Te();oe(x?`#${x.id} ${x.name??x.description}`:null),c.useEffect(()=>{i()},[i]),c.useEffect(()=>{t&&(x==null?void 0:x.status)===N.SUSPENDED?h(t):f()},[t,x==null?void 0:x.status,h,f]),c.useEffect(()=>{if(g){if(g.event==="task_status_changed"){const{taskId:l,status:j,currentStage:F}=g,L={status:j,updatedAt:new Date().toISOString()};F!==void 0&&(L.currentStage=F),T(l,L),j===N.SUSPENDED&&l===t&&h(l),U.includes(j)&&l===t&&f()}g.event==="task_created"&&i()}},[g,t,h,f,T,i]),c.useEffect(()=>{if(b==="connected")return;const j=setInterval(()=>{document.visibilityState!=="hidden"&&i()},15e3);return()=>clearInterval(j)},[b,i]);const se=c.useCallback(l=>{d(l),r(l),i()},[d,r,i]),ae=c.useCallback(()=>{f(),i()},[f,i]),ne=c.useCallback(()=>{var l;(l=S.current)==null||l.requestTakeover()},[]),re=c.useCallback(()=>{var l;(l=S.current)==null||l.releaseTakeover()},[]);if(m&&a.length===0)return e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:s("common.loading")})});const ie=u.length>0;return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[e.jsx(Ce,{projectKey:v,onProjectChange:y,onCreated:se}),e.jsx("div",{className:"flex flex-col md:flex-row flex-1 overflow-hidden",children:ie?e.jsxs(e.Fragment,{children:[e.jsx(_e,{tasks:u,activeId:t,onSelect:r,onUnpin:p,children:e.jsx("div",{className:"md:hidden",children:e.jsx(J,{onboardingData:k})})}),e.jsx("div",{className:"flex flex-1 flex-col overflow-hidden",children:x?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden md:block",children:e.jsx(J,{onboardingData:k})}),e.jsx(Ie,{task:x,takeoverState:A,onTakeover:ne,onRelease:re}),o&&t&&e.jsx(Se,{taskId:t,confirm:o,onSubmitted:ae}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:e.jsx(ue,{taskId:t,sessionId:x.currentSessionId??void 0,taskFinished:O,onStatusChange:D,onTakeoverChange:P,ref:S},t)}),e.jsx(Ee,{task:x,ptyStatus:C})]}):e.jsx(Y,{onboardingData:k})})]}):e.jsx(Y,{onboardingData:k})})]})}export{We as default};
@@ -0,0 +1 @@
1
+ import{a as C,r as n,j as e,h as w,f as M,z as O,Q as k,K as $,a0 as T,p as K}from"./index-BZ8Ay5Q7.js";import{K as E}from"./key-BK7i2VYG.js";import{C as S}from"./copy-1Kaayp-g.js";import{E as V}from"./external-link-CsjY7LBd.js";import{E as P}from"./EmptyState-DSlrUDxV.js";import{T as W}from"./Skeleton-C2wkNF0Q.js";import{u as B}from"./useFetch-CjoCsmky.js";import{e as R}from"./status-colors-ClM8Aa8i.js";import{P as J}from"./plus-WIoVlw4A.js";function z({isOpen:a,onClose:y,onCreated:b}){const{t:s}=C(),[r,c]=n.useState(""),[i,d]=n.useState(!1),[l,v]=n.useState("");function h(){c(""),v(""),y()}async function x(){if(v(""),!r.trim()){v(s("admin.pat_label_required"));return}try{d(!0);const o=await w.post("admin/worker-tokens",{json:{label:r.trim()}}).json();c(""),b({token:o.token,id:o.id})}catch(o){const m=o instanceof Error?o.message:s("admin.pat_failed_to_generate");v(m)}finally{d(!1)}}return a?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{backgroundColor:"var(--modal-backdrop, rgba(12,12,12,0.6))"},onClick:o=>{o.target===o.currentTarget&&h()},children:e.jsxs("div",{className:"w-full border border-[var(--border)] bg-[var(--bg-card)]",style:{maxWidth:"480px",borderRadius:"4px",fontFamily:"'JetBrains Mono', monospace"},children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--border)] px-5 py-4",children:[e.jsx(E,{className:"h-4 w-4 text-[var(--accent)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:s("admin.generate_worker_token_title")})]}),e.jsxs("div",{className:"space-y-4 px-5 py-4",children:[l&&e.jsx("div",{className:"border border-[var(--destructive)]/30 bg-[var(--destructive)]/10 px-3 py-2 text-xs text-[var(--destructive)]",style:{borderRadius:"4px"},children:l}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:s("admin.create_one_time_token")}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1.5 block text-xs text-[var(--text-muted)]",children:s("admin.label")}),e.jsx("input",{type:"text",placeholder:s("admin.pat_label_placeholder"),value:r,onChange:o=>c(o.target.value),className:"w-full border border-[var(--border)] bg-[var(--bg-card)] px-3 py-2 text-sm text-[var(--text-primary)] placeholder:text-[var(--text-muted)] focus:border-[var(--accent)] focus:outline-none",style:{borderRadius:"4px",fontFamily:"'JetBrains Mono', monospace"},onKeyDown:o=>{o.key==="Enter"&&x()}}),e.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:s("admin.label_identifies_worker")})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 border-t border-[var(--border)] px-5 py-3",children:[e.jsx("button",{onClick:h,className:"border border-[var(--border)] bg-transparent px-4 py-1.5 text-xs text-[var(--text-muted)] transition-colors hover:border-[var(--text-muted)] hover:text-[var(--text-primary)]",style:{borderRadius:"4px",fontFamily:"'JetBrains Mono', monospace"},children:s("common.cancel")}),e.jsx("button",{onClick:x,disabled:i,className:"bg-[var(--accent)] px-4 py-1.5 text-xs font-medium text-black transition-opacity hover:opacity-80 disabled:opacity-50",style:{borderRadius:"4px",fontFamily:"'JetBrains Mono', monospace"},children:s(i?"admin.generating":"admin.generate")})]})]})}):null}const X=3e3,q=600*1e3;function G({isOpen:a,token:y,tokenId:b,onClose:s}){const{t:r}=C(),[c,i]=n.useState("command"),[d,l]=n.useState(!1),[v,h]=n.useState(!1),[x,o]=n.useState(""),[m,g]=n.useState(null),p=n.useRef(void 0),N=n.useRef(Date.now()),_=M(),j=typeof window<"u"?window.location.origin:"https://overlord.example.com",t=`overlord setup worker --token ${y} --server ${j}`;async function D(){try{await navigator.clipboard.writeText(y),l(!0),setTimeout(()=>l(!1),2e3)}catch{}}async function L(){try{await navigator.clipboard.writeText(t),h(!0),setTimeout(()=>h(!1),2e3)}catch{}}const A=n.useCallback(async()=>{try{const f=await w.get(`admin/worker-tokens/${b}/status`).json();f.status==="used"&&f.worker_name&&(i("success"),o(f.worker_name),g(f.worker_id??null),p.current&&clearInterval(p.current))}catch{}Date.now()-N.current>q&&(i("timeout"),p.current&&clearInterval(p.current))},[b]);function F(){i("waiting"),N.current=Date.now(),p.current=setInterval(A,X)}n.useEffect(()=>()=>{p.current&&clearInterval(p.current)},[]);function I(){s(),m&&_(`/workers/${m}`)}if(!a)return null;const u={fontFamily:"'JetBrains Mono', monospace",borderRadius:"4px"};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{backgroundColor:"var(--modal-backdrop, rgba(12,12,12,0.6))"},onClick:f=>{f.target===f.currentTarget&&s()},children:e.jsxs("div",{className:"w-full border border-[var(--border)] bg-[var(--bg-card)]",style:{...u,maxWidth:"480px"},children:[e.jsx("div",{className:"flex items-center gap-2 border-b border-[var(--border)] px-5 py-4",children:c==="success"?e.jsxs(e.Fragment,{children:[e.jsx(O,{className:"h-4 w-4 text-[var(--accent)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:r("admin.worker_registered")})]}):e.jsxs(e.Fragment,{children:[e.jsx(E,{className:"h-4 w-4 text-[var(--accent)]"}),e.jsx("span",{className:"text-sm font-medium text-[var(--text-primary)]",children:r("admin.worker_token_generated")})]})}),e.jsxs("div",{className:"space-y-4 px-5 py-4",children:[c!=="success"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:r("admin.run_command_desc")}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-[11px] text-[var(--text-muted)]",children:"Token"}),e.jsxs("div",{className:"relative border border-[var(--border)] bg-[var(--bg-card)] p-3",style:{borderRadius:"4px"},children:[e.jsx("code",{className:"block break-all pr-20 text-xs text-[var(--text-primary)]",children:y}),e.jsx("button",{onClick:D,className:"absolute right-2 top-2 flex items-center gap-1 border border-[var(--border)] bg-transparent px-2 py-1 text-xs text-[var(--text-muted)] transition-colors hover:border-[var(--text-muted)] hover:text-[var(--text-primary)]",style:u,children:d?e.jsx("span",{className:"text-[var(--accent)]",children:r("common.copied")}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(S,{className:"h-3 w-3"})," ",r("common.copy")]})})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-[11px] text-[var(--text-muted)]",children:r("admin.setup_command")}),e.jsxs("div",{className:"relative border border-[var(--border)] bg-[var(--bg-card)] p-3",style:{borderRadius:"4px"},children:[e.jsxs("code",{className:"block break-all pr-20 text-xs text-[var(--accent)]",children:["$ ",t]}),e.jsx("button",{onClick:L,className:"absolute right-2 top-2 flex items-center gap-1 border border-[var(--border)] bg-transparent px-2 py-1 text-xs text-[var(--text-muted)] transition-colors hover:border-[var(--text-muted)] hover:text-[var(--text-primary)]",style:u,children:v?e.jsx("span",{className:"text-[var(--accent)]",children:r("common.copied")}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(S,{className:"h-3 w-3"})," ",r("common.copy")]})})]})]}),e.jsx("div",{className:"border border-yellow-500/30 bg-yellow-500/10 px-3 py-2 text-xs text-yellow-400",style:{borderRadius:"4px"},children:r("admin.token_shown_once")})]}),c==="waiting"&&e.jsxs("div",{className:"flex items-center gap-3 border border-[var(--border)] bg-[var(--bg-card)] px-4 py-3",style:{borderRadius:"4px"},children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-[var(--accent)] border-t-transparent"}),e.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:r("admin.waiting_for_worker")})]}),c==="timeout"&&e.jsx("div",{className:"border border-[var(--border)] bg-[var(--bg-card)] px-4 py-3 text-xs text-[var(--text-muted)]",style:{borderRadius:"4px"},children:r("admin.token_not_yet_used")}),c==="success"&&e.jsxs("div",{className:"border border-[var(--accent)]/30 bg-[var(--accent)]/10 px-4 py-3",style:{borderRadius:"4px"},children:[e.jsx("p",{className:"text-xs text-[var(--accent)]",children:r("admin.worker_registered_success")}),e.jsxs("p",{className:"mt-1 text-xs text-[var(--text-primary)]",children:[r("admin.worker"),": ",e.jsx("span",{className:"text-[var(--accent)]",children:x})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 border-t border-[var(--border)] px-5 py-3",children:[c==="command"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:s,className:"border border-[var(--border)] bg-transparent px-4 py-1.5 text-xs text-[var(--text-muted)] transition-colors hover:border-[var(--text-muted)] hover:text-[var(--text-primary)]",style:u,children:r("common.close")}),e.jsx("button",{onClick:F,className:"bg-[var(--accent)] px-4 py-1.5 text-xs font-medium text-black transition-opacity hover:opacity-80",style:u,children:r("admin.copied_wait_for_worker")})]}),c==="waiting"&&e.jsx("button",{onClick:s,className:"border border-[var(--border)] bg-transparent px-4 py-1.5 text-xs text-[var(--text-muted)] transition-colors hover:border-[var(--text-muted)] hover:text-[var(--text-primary)]",style:u,children:r("admin.close_worker_can_register")}),c==="timeout"&&e.jsx("button",{onClick:s,className:"border border-[var(--border)] bg-transparent px-4 py-1.5 text-xs text-[var(--text-muted)] transition-colors hover:border-[var(--text-muted)] hover:text-[var(--text-primary)]",style:u,children:r("common.close")}),c==="success"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:s,className:"border border-[var(--border)] bg-transparent px-4 py-1.5 text-xs text-[var(--text-muted)] transition-colors hover:border-[var(--text-muted)] hover:text-[var(--text-primary)]",style:u,children:r("common.close")}),e.jsxs("button",{onClick:I,className:"flex items-center gap-1.5 bg-[var(--accent)] px-4 py-1.5 text-xs font-medium text-black transition-opacity hover:opacity-80",style:u,children:[e.jsx(V,{className:"h-3 w-3"}),r("admin.view_worker")]})]})]})]})})}function se(){const{t:a}=C(),[y,b]=n.useState(!1),[s,r]=n.useState(null),[c,i]=n.useState(!1),[d,l]=n.useState(null),[v,h]=n.useState(!1),[x,o]=n.useState(!1),{data:m,loading:g,refetch:p}=B(()=>w.get("admin/worker-tokens").json(),[]);async function N(){if(d){h(!0);try{await w.post(`admin/worker-tokens/${d.id}/revoke`),i(!1),l(null),p()}catch{}finally{h(!1)}}}function _(t){b(!1),r(t),p()}const j=n.useMemo(()=>(m??[]).filter(t=>x||t.status!==k.REVOKED),[m,x]);return e.jsxs("div",{className:"font-mono",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm text-[var(--text-primary)]",children:a("admin.tokens_title")}),e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:a("admin.tokens_subtitle")})]}),e.jsxs("button",{type:"button",className:"flex items-center gap-1.5 rounded-[4px] bg-[var(--accent)] px-3 py-1.5 text-xs text-black hover:opacity-90 transition-opacity",onClick:()=>b(!0),children:[e.jsx(J,{className:"h-3.5 w-3.5"}),a("admin.generate_token")]})]}),!g&&(m==null?void 0:m.some(t=>t.status===k.REVOKED))&&e.jsx("div",{className:"mb-4 flex items-center gap-2",children:e.jsx("button",{type:"button",onClick:()=>o(!x),className:`text-xs transition-colors ${x?"text-[var(--text-primary)]":"text-[var(--text-muted)] hover:text-[var(--text-secondary)]"}`,children:a(x?"admin.hide_revoked":"admin.show_revoked")})}),g?e.jsx("div",{className:"rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4",children:e.jsx(W,{rows:3})}):j.length===0?e.jsx(P,{icon:$,title:a("admin.no_worker_tokens"),description:a("admin.generate_token_desc"),actionLabel:a("admin.generate_token"),onAction:()=>b(!0)}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden md:block overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[var(--border)] text-left text-[var(--text-muted)]",children:[e.jsx("th",{className:"pb-2 pr-4 font-normal",children:a("admin.label")}),e.jsx("th",{className:"pb-2 pr-4 font-normal",children:a("admin.purpose")}),e.jsx("th",{className:"pb-2 pr-4 font-normal",children:a("admin.status")}),e.jsx("th",{className:"pb-2 pr-4 font-normal",children:a("common.created_at")}),e.jsx("th",{className:"pb-2 pr-4 font-normal",children:a("admin.expires_at")}),e.jsx("th",{className:"pb-2 font-normal",children:a("common.actions")})]})}),e.jsx("tbody",{children:j.map(t=>e.jsxs("tr",{className:"border-b border-[var(--border-row)] hover:bg-white/[0.02] transition-colors",children:[e.jsx("td",{className:"py-2.5 pr-4 text-[var(--text-primary)]",children:t.label}),e.jsx("td",{className:"py-2.5 pr-4 text-[var(--text-secondary)]",children:t.purpose}),e.jsx("td",{className:"py-2.5 pr-4",children:e.jsx("span",{className:R(t.status),children:t.status})}),e.jsx("td",{className:"py-2.5 pr-4 text-[var(--text-muted)]",children:new Date(t.createdAt).toLocaleDateString()}),e.jsx("td",{className:"py-2.5 pr-4",children:t.expiresAt?e.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(t.expiresAt).toLocaleDateString()}):e.jsx("span",{className:"text-[var(--text-muted)]",children:"—"})}),e.jsx("td",{className:"py-2.5",children:t.status===k.ACTIVE&&e.jsxs("button",{type:"button",className:"flex items-center gap-1 rounded-[4px] px-2 py-1 text-red-400 hover:text-red-300 hover:bg-white/[0.05] transition-colors",onClick:()=>{l(t),i(!0)},children:[e.jsx(T,{className:"h-3.5 w-3.5"}),a("admin.revoke")]})})]},t.id))})]})}),e.jsx("div",{className:"md:hidden space-y-3",children:j.map(t=>e.jsxs("div",{className:"rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-xs text-[var(--text-primary)] font-medium truncate mr-2",children:t.label}),e.jsx("span",{className:`text-[11px] shrink-0 ${R(t.status)}`,children:t.status})]}),e.jsx("div",{className:"text-[11px] text-[var(--text-secondary)] truncate mb-1",children:t.purpose}),e.jsxs("div",{className:"flex items-center justify-between text-[11px] text-[var(--text-muted)]",children:[e.jsx("span",{children:new Date(t.createdAt).toLocaleDateString()}),t.expiresAt&&e.jsx("span",{children:new Date(t.expiresAt).toLocaleDateString()})]}),t.status===k.ACTIVE&&e.jsx("div",{className:"mt-2 pt-2 border-t border-[var(--border)]",children:e.jsxs("button",{type:"button",className:"flex items-center gap-1 rounded-[4px] px-2 py-1 text-[11px] text-red-400 hover:text-red-300 hover:bg-white/[0.05] transition-colors",onClick:()=>{l(t),i(!0)},children:[e.jsx(T,{className:"h-3.5 w-3.5"}),a("admin.revoke")]})})]},t.id))})]}),e.jsx(z,{isOpen:y,onClose:()=>b(!1),onCreated:_}),s&&e.jsx(G,{isOpen:!!s,token:s.token,tokenId:s.id,onClose:()=>r(null)}),e.jsx(K,{isOpen:c,onClose:()=>{i(!1),l(null)},onConfirm:N,title:a("admin.revoke_token"),message:a("admin.revoke_token_confirm",{label:(d==null?void 0:d.label)??""}),confirmLabel:a("admin.revoke"),confirmVariant:"danger",isLoading:v})]})}export{se as default};
@@ -0,0 +1 @@
1
+ import{I as m,r as e,j as t}from"./index-BZ8Ay5Q7.js";var b=m();function g({content:n,children:a,delay:l=100,className:i}){const[p,u]=e.useState(!1),[c,f]=e.useState({top:0,left:0}),r=e.useRef(null),o=e.useRef(null),x=e.useCallback(()=>{r.current=setTimeout(()=>{if(o.current){const s=o.current.getBoundingClientRect();f({top:s.top-4,left:s.left+s.width/2})}u(!0)},l)},[l]),d=e.useCallback(()=>{r.current&&(clearTimeout(r.current),r.current=null),u(!1)},[]);return n?t.jsxs(t.Fragment,{children:[t.jsx("span",{ref:o,onMouseEnter:x,onMouseLeave:d,className:i,children:a}),p&&b.createPortal(t.jsx("div",{role:"tooltip",style:{position:"fixed",top:c.top,left:c.left,transform:"translate(-50%, -100%)",zIndex:9999},className:"pointer-events-none max-w-sm rounded-[4px] bg-[var(--bg-card)] px-2.5 py-1.5 text-xs text-[var(--text-primary)] shadow-lg border border-[var(--border-row)]",children:n}),document.body)]}):t.jsx(t.Fragment,{children:a})}export{g as T};
@@ -1,4 +1,4 @@
1
- import{R as A,g as he,f as fe,u as Y,a as me,r as _,j as M,h as W,t as ge}from"./index-ChW26424.js";var pe=Object.defineProperty,j=Object.getOwnPropertySymbols,X=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable,V=(u,a,i)=>a in u?pe(u,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):u[a]=i,k=(u,a)=>{for(var i in a||(a={}))X.call(a,i)&&V(u,i,a[i]);if(j)for(var i of j(a))K.call(a,i)&&V(u,i,a[i]);return u},U=(u,a)=>{var i={};for(var l in u)X.call(u,l)&&a.indexOf(l)<0&&(i[l]=u[l]);if(u!=null&&j)for(var l of j(u))a.indexOf(l)<0&&K.call(u,l)&&(i[l]=u[l]);return i};/**
1
+ import{R as A,g as he,f as fe,u as Y,a as me,r as _,j as M,h as W,t as ge}from"./index-BZ8Ay5Q7.js";var pe=Object.defineProperty,j=Object.getOwnPropertySymbols,X=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable,V=(u,a,i)=>a in u?pe(u,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):u[a]=i,k=(u,a)=>{for(var i in a||(a={}))X.call(a,i)&&V(u,i,a[i]);if(j)for(var i of j(a))K.call(a,i)&&V(u,i,a[i]);return u},U=(u,a)=>{var i={};for(var l in u)X.call(u,l)&&a.indexOf(l)<0&&(i[l]=u[l]);if(u!=null&&j)for(var l of j(u))a.indexOf(l)<0&&K.call(u,l)&&(i[l]=u[l]);return i};/**
2
2
  * @license QR Code generator library (TypeScript)
3
3
  * Copyright (c) Project Nayuki.
4
4
  * SPDX-License-Identifier: MIT
@@ -0,0 +1 @@
1
+ import{a as u,j as e,p as E,x as H,f as P,r as m,u as R,k as D,q as V,W as c,D as S,L as B,B as I,h,l as z}from"./index-BZ8Ay5Q7.js";import{t as J,b as $}from"./date-BdNtiQTP.js";import{w as K,b as Q,t as X}from"./status-colors-ClM8Aa8i.js";import{I as i}from"./InfoRow-B0PKkcID.js";import{M as N}from"./MetricBar-qvotCrRD.js";import{u as Y}from"./useFetch-CjoCsmky.js";import{T as Z}from"./Tooltip-BdD7q141.js";import{T as M}from"./trash-2-DkQiJox8.js";import{A as ee}from"./arrow-left-BrI9Fcz8.js";function re({isOpen:t,onClose:o,onConfirm:r,workerName:a,isDraining:l,loading:j}){const{t:d}=u();return e.jsx(E,{isOpen:t,onClose:o,onConfirm:r,title:d(l?"workers.undrain_worker_title":"workers.drain_worker_title"),message:l?d("workers.undrain_confirm",{name:a}):d("workers.drain_confirm",{name:a}),confirmLabel:d(l?"workers.undrain":"workers.drain"),confirmVariant:l?"accent":"warning",isLoading:j})}function me(){const{id:t}=H(),o=P(),{t:r}=u(),[a,l]=m.useState(!1),[j,d]=m.useState(!1),[A,p]=m.useState(!1),[T,y]=m.useState(!1),w=R(n=>{var v;return(v=n.user)==null?void 0:v.role}),F=D(n=>n.workerSeq),U=D(n=>n.taskSeq),{data:x,loading:W,error:_,refetch:C}=Y(async()=>{if(!t)throw new Error("Missing worker ID");const[n,v]=await Promise.all([h.get(`web/workers/${t}`).json(),h.get(`web/workers/${t}/tasks`).json().catch(()=>[])]);return{worker:n,tasks:v}},[t,F,U]),s=(x==null?void 0:x.worker)??null,g=(x==null?void 0:x.tasks)??[];V(m.useMemo(()=>!s||s.status===c.DECOMMISSIONED?null:e.jsxs("div",{className:"flex items-center gap-2",children:[s.status===c.ONLINE&&e.jsxs("button",{onClick:()=>l(!0),className:"rounded-[4px] border border-[var(--warning)]/40 px-3 py-1.5 text-xs text-[var(--warning)] hover:bg-[var(--warning)]/10 transition-colors",children:["> ",r("workers.drain")]}),w===S.ADMIN&&e.jsxs("button",{onClick:()=>p(!0),className:"flex items-center gap-1 rounded-[4px] border border-[var(--destructive)]/40 px-3 py-1.5 text-xs text-[var(--destructive)] hover:bg-[var(--destructive)]/10 transition-colors",children:[e.jsx(M,{className:"h-3 w-3"}),r("workers.decommission")]})]}),[s,w,r]));async function q(){if(s){d(!0);try{const n=s.status===c.DRAINING?"undrain":"drain";await h.post(`web/workers/${s.id}/${n}`),await C()}catch{}finally{d(!1),l(!1)}}}async function G(){if(s){y(!0);try{await h.delete(`admin/workers/${s.id}`),o("/workers")}catch{}finally{y(!1),p(!1)}}}if(W)return e.jsx("div",{className:"mx-auto max-w-5xl px-4 md:px-6 py-8 font-mono",children:e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:r("workers.loading_worker")})});if(_)return e.jsxs("div",{className:"mx-auto max-w-5xl px-4 md:px-6 py-8 font-mono lowercase text-center",children:[e.jsx("p",{className:"text-sm text-[var(--destructive)]",children:_}),e.jsx("button",{onClick:()=>C(),className:"mt-4 rounded-[4px] border border-[var(--border)] px-3 py-1.5 text-xs text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",children:r("common.retry")})]});if(!s)return e.jsxs("div",{className:"mx-auto max-w-5xl px-4 md:px-6 py-8 font-mono lowercase text-center",children:[e.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:r("workers.worker_not_found")}),e.jsxs("button",{onClick:()=>o("/workers"),className:"mt-4 rounded-[4px] border border-[var(--border)] px-3 py-1.5 text-xs text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",children:["< ",r("workers.back_to_workers")]})]});const b=s.status===c.DRAINING,k=s.status!==c.DECOMMISSIONED;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mx-auto max-w-5xl font-mono lowercase",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-[var(--border)] bg-[var(--bg-primary)] px-4 shrink-0 md:hidden",style:{height:56},children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("button",{onClick:()=>o("/workers"),className:"shrink-0 text-[var(--text-muted)]",children:e.jsx(ee,{className:"h-4 w-4"})}),e.jsx("span",{className:"truncate text-sm font-medium text-[var(--text-primary)]",children:s.name})]}),!b&&s.status!==c.OFFLINE&&k&&e.jsxs("button",{onClick:()=>l(!0),className:"shrink-0 rounded-[4px] border border-[var(--warning)]/40 px-3 py-1.5 text-xs text-[var(--warning)] hover:bg-[var(--warning)]/10 transition-colors",children:["> ",r("workers.drain")]})]}),e.jsxs("div",{className:"px-4 md:px-6 py-8",children:[b?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx(B,{to:"/workers",className:"text-[var(--text-muted)] hover:text-[var(--text-secondary)] transition-colors",children:r("workers.title")}),e.jsx("span",{className:"text-[var(--text-muted)]",children:"/"}),e.jsx("span",{className:"text-[var(--text-secondary)]",children:s.name})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[k&&e.jsxs("button",{onClick:()=>l(!0),className:"rounded-[4px] border border-[var(--accent)] px-4 py-1.5 text-xs text-[var(--accent)] hover:bg-[var(--accent)]/10 transition-colors",children:["> ",r("workers.undrain")]}),w===S.ADMIN&&k&&e.jsxs("button",{onClick:()=>p(!0),className:"flex items-center gap-1 rounded-[4px] border border-[var(--destructive)]/40 px-3 py-1.5 text-xs text-[var(--destructive)] hover:bg-[var(--destructive)]/10 transition-colors",children:[e.jsx(M,{className:"h-3 w-3"}),r("workers.decommission")]})]})]}),e.jsx("div",{className:"mb-4",children:e.jsx("span",{className:"rounded-[4px] bg-[var(--warning)]/20 px-2.5 py-1 text-xs font-medium text-[var(--warning)]",children:r("workers.draining")})}),e.jsxs("div",{className:"mb-6 rounded-[4px] border border-[var(--warning)]/40 bg-[var(--warning)]/10 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(I,{className:"h-3.5 w-3.5 text-[var(--warning)]"}),e.jsx("span",{className:"text-xs text-[var(--warning)]",children:r("workers.draining_warning")})]}),e.jsx("p",{className:"text-xs text-[var(--warning)]/70 ml-5.5",children:r("workers.draining_active_tasks")})]}),e.jsxs("div",{className:"mb-6 grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(f,{label:r("workers.cpu"),value:s.cpuUsage,unit:"%"}),e.jsx(f,{label:r("workers.memory"),value:s.memoryUsage,unit:"%"}),e.jsx(f,{label:r("workers.disk"),value:s.diskUsage,unit:"%"}),e.jsxs("div",{className:"rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-5",children:[e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:r("workers.slots")}),e.jsxs("p",{className:"mt-2 text-lg font-semibold text-[var(--text-primary)]",children:[s.activeSlots,"/",s.maxSlots]})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>o("/workers"),className:"mb-4 text-xs text-[var(--text-muted)] hover:text-[var(--text-secondary)] transition-colors",children:["< ",r("workers.back_to_workers")]}),e.jsxs("h1",{className:"mb-2 text-lg font-bold text-[var(--text-primary)] flex items-center gap-2",children:[s.name,e.jsxs("span",{className:"flex items-center gap-1.5 text-sm font-normal",style:{color:K[s.status]},children:[e.jsx("span",{style:{fontSize:"0.5rem"},children:"●"}),s.status.toLowerCase()]})]}),e.jsx("p",{className:"mb-6 text-xs text-[var(--text-muted)]",children:r("workers.last_heartbeat",{time:J(s.lastHeartbeat,"never")})}),s.status===c.DECOMMISSIONED&&e.jsx("div",{className:"mb-6 rounded-[4px] border border-[var(--text-muted)]/40 bg-[var(--text-muted)]/10 p-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{className:"h-3.5 w-3.5 text-[var(--text-muted)]"}),e.jsxs("span",{className:"text-xs text-[var(--text-muted)]",children:["this worker has been decommissioned",s.decommissionedAt?` on ${$(s.decommissionedAt)}`:""," and can no longer accept tasks."]})]})}),e.jsxs("div",{className:"mb-6 grid gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4",children:[e.jsx("h2",{className:"mb-3 text-xs text-[var(--text-muted)]",children:r("workers.resource_usage")}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(N,{label:r("workers.cpu"),value:s.cpuUsage}),e.jsx(N,{label:r("workers.mem"),value:s.memoryUsage}),e.jsx(N,{label:r("workers.disk"),value:s.diskUsage})]})]}),e.jsxs("div",{className:"rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4",children:[e.jsx("h2",{className:"mb-3 text-xs text-[var(--text-muted)]",children:r("workers.connection_info")}),e.jsx(L,{worker:s})]})]})]}),b?e.jsxs(e.Fragment,{children:[e.jsx(O,{title:r("workers.active_tasks"),tasks:g,navigate:o}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"mb-4 text-sm font-medium text-[var(--accent)]",children:r("workers.capabilities")}),s.capabilities.length>0?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:s.capabilities.map(n=>e.jsx("div",{className:"rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4",children:e.jsx("p",{className:"text-xs text-[var(--text-primary)]",children:n})},n))}):e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:r("workers.no_capabilities_short")})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"mb-4 text-sm font-medium text-[var(--accent)]",children:r("workers.worker_info")}),e.jsx("div",{className:"rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-5",children:e.jsx(L,{worker:s,showExtended:!0})})]})]}):e.jsxs(e.Fragment,{children:[s.capabilities.length>0&&e.jsxs("div",{className:"mb-6 rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4",children:[e.jsx("h2",{className:"mb-3 text-xs text-[var(--text-muted)]",children:r("workers.capabilities")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:s.capabilities.map(n=>e.jsx("span",{className:"rounded-[4px] border border-[var(--border)] px-2.5 py-1 text-xs text-[var(--text-secondary)]",children:n},n))})]}),e.jsx(O,{title:`${r("workers.current_tasks")} (${g.length})`,tasks:g,navigate:o})]})]})]}),e.jsx(re,{isOpen:a,onClose:()=>l(!1),onConfirm:q,workerName:s.name,isDraining:b,loading:j}),e.jsx(E,{isOpen:A,onClose:()=>p(!1),onConfirm:G,title:r("workers.decommission_title"),message:r("workers.decommission_confirm",{name:s.name}),confirmLabel:r("workers.decommission"),confirmVariant:"danger",isLoading:T})]})}function L({worker:t,showExtended:o=!1}){const{t:r}=u();return e.jsxs("div",{className:"flex flex-col gap-2 text-xs",children:[e.jsx(i,{label:r("workers.worker_id"),value:t.id}),e.jsx(i,{label:r("workers.host"),value:t.host}),e.jsx(i,{label:r("workers.port"),value:String(t.port)}),e.jsx(i,{label:r("workers.os"),value:t.os??r("workers.unknown")}),e.jsx(i,{label:r("workers.cpu_model"),value:t.cpuModel??r("workers.n_a")}),e.jsx(i,{label:r("workers.cpu_cores"),value:t.cpuCores!=null?String(t.cpuCores):r("workers.n_a")}),e.jsx(i,{label:r("workers.memory"),value:t.memoryGb!=null?`${t.memoryGb} gb`:r("workers.n_a")}),e.jsx(i,{label:r("workers.last_heartbeat_label"),value:$(t.lastHeartbeat)}),e.jsx(i,{label:r("workers.slots"),value:`${t.activeSlots}/${t.maxSlots}`}),o&&e.jsxs(e.Fragment,{children:[e.jsx(i,{label:r("workers.status_label"),value:t.status.toLowerCase()}),e.jsx(i,{label:r("workers.worker_version"),value:t.workerVersion??r("workers.n_a")})]})]})}function O({title:t,tasks:o,navigate:r}){const{t:a}=u();return e.jsxs("div",{className:"mb-6 rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4",children:[e.jsx("h2",{className:"mb-3 text-xs text-[var(--text-muted)]",children:t}),o.length===0?e.jsxs("div",{className:"flex flex-col items-center gap-3 py-6",children:[e.jsx("span",{className:"text-xl font-bold text-[var(--border)]",children:"[ ]"}),e.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:a("workers.no_active_tasks")})]}):e.jsx(se,{tasks:o,navigate:r})]})}function se({tasks:t,navigate:o}){const{t:r}=u();return e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[var(--border-row)]",children:[e.jsx("th",{className:"py-2 pr-4 text-left font-normal text-[var(--text-muted)]",children:r("workers.id")}),e.jsx("th",{className:"py-2 pr-4 text-left font-normal text-[var(--text-muted)]",children:r("workers.description")}),e.jsx("th",{className:"py-2 pr-4 text-left font-normal text-[var(--text-muted)]",children:r("workers.status_label")}),e.jsx("th",{className:"py-2 text-left font-normal text-[var(--text-muted)]",children:r("workers.stage")})]})}),e.jsx("tbody",{children:t.map(a=>e.jsxs("tr",{onClick:()=>o(`/tasks/${a.id}`),className:"cursor-pointer border-b border-[var(--border-row)] hover:bg-[var(--bg-input)] transition-colors",children:[e.jsxs("td",{className:"py-2 pr-4 text-[var(--text-primary)]",children:["#",a.id]}),e.jsx("td",{className:"max-w-[120px] md:max-w-xs truncate py-2 pr-4 text-[var(--text-secondary)]",children:e.jsx(Z,{content:a.name??a.description,children:z(a)})}),e.jsx("td",{className:"py-2 pr-4",children:e.jsxs("span",{style:{color:X[a.status]},children:["● ",a.status.toLowerCase()]})}),e.jsx("td",{className:"py-2 text-[var(--text-secondary)]",children:a.currentStage??"-"})]},a.id))})]})})}function f({label:t,value:o,unit:r}){const a=Math.round(o*100);return e.jsxs("div",{className:"rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-5",children:[e.jsx("p",{className:"text-xs text-[var(--text-muted)]",children:t}),e.jsxs("p",{className:"mt-2 text-lg font-semibold text-[var(--text-primary)]",children:[a,r]}),e.jsx("div",{className:"mt-3 h-1.5 w-full rounded-[2px] bg-[var(--bg-input)]",children:e.jsx("div",{className:"h-full rounded-[2px] transition-all",style:{width:`${a}%`,backgroundColor:Q(o)}})})]})}export{me as default};
@@ -1,6 +1,6 @@
1
- import{c as G,R as U,a as C,j as e,r as o,h as S,X as q,x as K,f as H,u as V,k as X,W as N,p as J,D as Q,S as M}from"./index-ChW26424.js";import{w as W}from"./status-colors-B_811zpf.js";import{M as _}from"./MetricBar-BdjXhynk.js";import Y from"./WorkerSetupGuidePage-RX_HcxUB.js";import{C as z}from"./copy-DHDPffJp.js";import{L as Z}from"./loader-circle-D-_56V0I.js";import{S as ee}from"./Select-DI-7imsE.js";import{E as te}from"./EmptyState-D3ZrUiqM.js";import{C as re}from"./Skeleton-C981QVgn.js";import{u as se}from"./useFetch-Lyui3S2c.js";import{P as ae}from"./plus-CQMXvSQ5.js";import"./key-CV1tBpjw.js";import"./download-DnmqfM-x.js";import"./settings-DhM5ZmgU.js";import"./wifi-lJpr616j.js";/**
1
+ import{c as B,R as G,a as C,j as e,r as o,h as S,X as U,z as K,f as H,u as V,k as X,W as N,q as J,D as Q,S as M}from"./index-BZ8Ay5Q7.js";import{w as W}from"./status-colors-ClM8Aa8i.js";import{M as _}from"./MetricBar-qvotCrRD.js";import Y from"./WorkerSetupGuidePage-CVg9l1Wm.js";import{C as z}from"./copy-1Kaayp-g.js";import{L as Z}from"./loader-circle-wZMLiMDW.js";import{S as ee}from"./Select-Drhq3WPg.js";import{E as te}from"./EmptyState-DSlrUDxV.js";import{C as re}from"./Skeleton-C2wkNF0Q.js";import{u as se}from"./useFetch-CjoCsmky.js";import{P as ae}from"./plus-WIoVlw4A.js";import"./key-BK7i2VYG.js";import"./download-CAjpjHtL.js";import"./settings-CKdRWwOX.js";import"./wifi-CEl4Ck1T.js";/**
2
2
  * @license lucide-react v0.469.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const oe=G("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]),ne=U.memo(function({worker:r,onClick:l}){const{t}=C();return e.jsxs("div",{onClick:l,className:`rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4 font-mono lowercase transition-colors ${l?"cursor-pointer hover:border-[var(--accent)]/40 hover:bg-[var(--bg-input)]":""}`,children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsxs("h3",{className:"truncate text-sm text-[var(--text-primary)]",children:[e.jsx("span",{style:{color:W[r.status],fontSize:"0.6rem"},children:"●"})," ",r.name]}),e.jsx("span",{className:"text-xs",style:{color:W[r.status]},children:r.status})]}),e.jsxs("div",{className:"mb-3 text-xs text-[var(--text-muted)]",children:[r.host,r.os?`:${r.os}`:""]}),e.jsxs("div",{className:"mb-3 flex flex-col gap-2",children:[e.jsx(_,{label:t("workers.cpu"),value:r.cpuUsage,variant:"inline"}),e.jsx(_,{label:t("workers.mem"),value:r.memoryUsage,variant:"inline"}),e.jsx(_,{label:t("workers.disk"),value:r.diskUsage,variant:"inline"})]}),e.jsx("div",{className:"flex items-center justify-between text-xs",children:e.jsx("span",{className:"text-[var(--text-secondary)]",children:t("workers.tasks_slots",{active:String(r.activeSlots),max:String(r.maxSlots)})})}),r.capabilities.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:r.capabilities.map(s=>e.jsx("span",{className:"rounded-[4px] border border-[var(--border)] px-1.5 py-0.5 text-[11px] text-[var(--text-muted)]",children:s},s))})]})});function le({isOpen:d,onClose:r,onRegistered:l}){const{t}=C(),[s,c]=o.useState(1),[v,p]=o.useState(!1),[i,m]=o.useState(""),[u,g]=o.useState(null),[b,h]=o.useState(""),[k,a]=o.useState(""),[j,y]=o.useState(!1),[A,w]=o.useState(!1),[F,T]=o.useState(""),[I,$]=o.useState(""),x=o.useRef(null),O={1:t("workers.reg_step_generate_token"),2:t("workers.reg_step_install_worker"),3:t("workers.reg_step_waiting_activation"),4:t("workers.reg_step_activated")};o.useEffect(()=>(d&&(c(1),m(""),g(null),h(""),a(""),y(!1),w(!1),T(""),$(""),p(!1)),()=>{x.current&&clearInterval(x.current)}),[d]);const E=async()=>{const n=b.trim();if(!n){a(t("admin.pat_label_required"));return}a(""),p(!0);try{const f=await S.post("admin/worker-tokens",{json:{label:n}}).json();m(f.token),g(f.tokenId),c(2)}catch{}finally{p(!1)}},P=typeof window<"u"?window.location.origin:"https://overlord.example.com",L=i?`overlord setup worker --token ${i} --server ${P}`:"",R=()=>{navigator.clipboard.writeText(i),y(!0),setTimeout(()=>y(!1),2e3)},D=()=>{navigator.clipboard.writeText(L),w(!0),setTimeout(()=>w(!1),2e3)},B=o.useCallback(()=>{u&&(c(3),x.current=setInterval(async()=>{try{const n=await S.get(`admin/worker-tokens/${u}/status`).json();n.used&&n.workerName&&(T(n.workerName),$(n.workerId??""),c(4),x.current&&clearInterval(x.current),l==null||l())}catch{}},3e3))},[u,l]);return o.useEffect(()=>()=>{x.current&&clearInterval(x.current)},[]),d?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center font-mono lowercase",children:[e.jsx("div",{className:"absolute inset-0 bg-[var(--bg-primary)]/60 backdrop-blur-sm",onClick:r}),e.jsxs("div",{className:"relative z-10 w-full max-w-[1080px] rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-8",children:[e.jsx("button",{type:"button",onClick:r,className:"absolute right-4 top-4 text-[var(--text-muted)] hover:text-[var(--text-primary)]",children:e.jsx(q,{className:"h-4 w-4"})}),e.jsx("h2",{className:"text-lg font-bold text-[var(--accent)]",children:t("workers.reg_title")}),e.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:t("workers.reg_subtitle")}),e.jsx("div",{className:"mt-6 flex items-center justify-center gap-2",children:[1,2,3,4].map((n,f)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:`rounded-[4px] px-3 py-1.5 text-[11px] font-bold ${n===s?"bg-[var(--accent)] text-black":n<s?"bg-[var(--accent)]/20 text-[var(--accent)]":"border border-[var(--border)] bg-[var(--bg-primary)] text-[var(--text-muted)]"}`,children:[n,". ",O[n]]}),f<3&&e.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"→"})]},n))}),e.jsxs("div",{className:"mt-6 grid grid-cols-1 gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:`rounded-[4px] border p-4 ${s===1?"border-[var(--accent)] bg-[var(--bg-primary)]":"border-[var(--border)] bg-[var(--bg-primary)]"}`,children:[e.jsxs("p",{className:"text-[13px] font-bold text-[var(--accent)]",children:["> ",t("workers.reg_step_generate_token")]}),s===1&&!i?e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:t("workers.reg_click_to_generate")}),k&&e.jsx("p",{className:"text-[11px] text-red-400",children:k}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-[11px] text-[var(--text-muted)]",children:t("admin.label")}),e.jsx("input",{type:"text",placeholder:t("admin.pat_label_placeholder"),value:b,onChange:n=>h(n.target.value),onKeyDown:n=>{n.key==="Enter"&&E()},className:"w-full rounded-[4px] border border-[var(--border)] bg-[var(--bg-input)] px-3 py-1.5 text-[11px] text-[var(--text-primary)] placeholder:text-[var(--text-muted)] focus:border-[var(--accent)] focus:outline-none"})]}),e.jsx("button",{type:"button",onClick:E,disabled:v,className:"rounded-[4px] bg-[var(--accent)] px-4 py-1.5 text-xs font-bold text-black disabled:opacity-50",children:t(v?"admin.generating":"workers.reg_step_generate_token")})]}):i?e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:t("workers.reg_token_generated")}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-[11px] text-[var(--text-muted)]",children:"Token"}),e.jsxs("div",{className:"relative rounded-[4px] border border-[var(--border)] bg-[var(--bg-primary)] px-3 py-2 pr-16",children:[e.jsx("code",{className:"block break-all text-[11px] text-[var(--text-primary)]",children:i}),e.jsx("button",{type:"button",onClick:R,className:"absolute right-2 top-1.5 text-[11px] text-[var(--text-muted)] hover:text-[var(--text-primary)]",children:j?e.jsx("span",{className:"text-[var(--accent)]",children:t("common.copied")}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(z,{className:"h-3 w-3"})," ",t("common.copy")]})})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-[11px] text-[var(--text-muted)]",children:t("admin.setup_command")}),e.jsxs("div",{className:"relative rounded-[4px] border border-[var(--border)] bg-[var(--bg-primary)] px-3 py-2 pr-16",children:[e.jsxs("code",{className:"block break-all text-[11px] text-[var(--accent)]",children:["$ ",L]}),e.jsx("button",{type:"button",onClick:D,className:"absolute right-2 top-1.5 text-[11px] text-[var(--text-muted)] hover:text-[var(--text-primary)]",children:A?e.jsx("span",{className:"text-[var(--accent)]",children:t("common.copied")}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(z,{className:"h-3 w-3"})," ",t("common.copy")]})})]})]}),e.jsx("div",{className:"rounded-[4px] border border-yellow-500/30 bg-yellow-500/10 px-3 py-2 text-[11px] text-yellow-400",children:t("admin.token_shown_once")})]}):e.jsx("p",{className:"mt-2 text-[11px] text-[var(--text-muted)]",children:t("workers.reg_completed")})]}),e.jsxs("div",{className:`rounded-[4px] border p-4 ${s===2?"border-[var(--accent)] bg-[var(--bg-primary)]":"border-[var(--border)] bg-[var(--bg-primary)]"}`,children:[e.jsxs("p",{className:"text-[13px] font-bold text-[var(--text-primary)]",children:["> ",t("workers.reg_step_install_worker")]}),e.jsx("p",{className:"mt-2 text-[11px] text-[var(--text-muted)]",children:t("workers.reg_running_installation")}),s>=2&&e.jsxs("div",{className:"mt-3 space-y-1 rounded-[4px] border border-[var(--border)] bg-[var(--bg-primary)] p-3",children:[e.jsx("p",{className:"text-[11px] text-[var(--text-primary)]",children:"$ overlord setup worker"}),e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:"server url: https://..."}),e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:"worker token: ovw_..."}),e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:"worker name: my-worker"}),e.jsx("p",{className:"text-[11px] text-[var(--accent)]",children:"config written. starting worker..."}),s===2&&e.jsx("p",{className:"text-[11px] text-[var(--accent)] animate-pulse",children:"&block;"})]}),s===2&&e.jsx("button",{type:"button",onClick:B,className:"mt-3 rounded-[4px] bg-[var(--accent)] px-4 py-1.5 text-xs font-bold text-black",children:t("workers.reg_installed_wait")})]}),e.jsxs("div",{className:`rounded-[4px] border p-4 ${s===3?"border-amber-500 bg-[var(--bg-primary)]":"border-[var(--border)] bg-[var(--bg-primary)]"}`,children:[e.jsxs("p",{className:"text-[13px] font-bold text-[var(--text-primary)]",children:["> ",t("workers.reg_step_waiting_activation")]}),s>=3?e.jsx("div",{className:"mt-3 flex flex-col items-center justify-center gap-3 py-6",children:s===3?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full border-2 border-amber-500",children:e.jsx(Z,{className:"h-5 w-5 animate-spin text-amber-500"})}),e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:t("workers.reg_listening_for_worker")})]}):e.jsx("p",{className:"text-[11px] text-[var(--accent)]",children:t("workers.reg_worker_connected")})}):e.jsx("p",{className:"mt-2 text-[11px] text-[var(--text-muted)]",children:t("workers.reg_waiting_for_worker")})]}),e.jsxs("div",{className:`rounded-[4px] border p-4 ${s===4?"border-[var(--accent)] bg-[var(--bg-primary)]":"border-[var(--border)] bg-[var(--bg-primary)]"}`,children:[e.jsxs("p",{className:"text-[13px] font-bold text-[var(--text-primary)]",children:["> ",t("workers.reg_step_activated")]}),s===4?e.jsxs("div",{className:"mt-3 flex flex-col items-center justify-center gap-3 py-6",children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-[var(--accent)]/20",children:e.jsx(K,{className:"h-6 w-6 text-[var(--accent)]"})}),e.jsx("p",{className:"text-xs font-bold text-[var(--accent)]",children:t("workers.reg_worker_activated",{name:F})}),I&&e.jsxs("p",{className:"text-[11px] text-[var(--text-muted)]",children:["worker_id: ",I]})]}):e.jsx("p",{className:"mt-2 text-[11px] text-[var(--text-muted)]",children:t("workers.reg_worker_registered")})]})]}),s===4&&e.jsx("div",{className:"mt-6 flex justify-end",children:e.jsx("button",{type:"button",onClick:r,className:"rounded-[4px] bg-[var(--accent)] px-5 py-2 text-xs font-bold text-black",children:t("workers.reg_done")})})]})]}):null}function we(){const d=H(),{t:r}=C(),[l,t]=o.useState("all"),[s,c]=o.useState("fleet"),[v,p]=o.useState(!1),[i,m]=o.useState(0),u=V(a=>{var j;return(j=a.user)==null?void 0:j.role}),g=X(a=>a.workerSeq),{data:b,loading:h}=se(()=>{const a={};return l!=="all"&&(a.status=l),S.get("web/workers",{searchParams:a}).json()},[l,i,g]),k=o.useMemo(()=>[{value:"all",label:r("workers.all_statuses")},{value:N.ONLINE,label:r("workers.online")},{value:N.OFFLINE,label:r("workers.offline")},{value:N.DRAINING,label:r("workers.draining")}],[r]);return J(o.useMemo(()=>u===Q.ADMIN?e.jsxs("button",{type:"button",onClick:()=>p(!0),className:"flex items-center gap-1.5 rounded-[4px] bg-[var(--accent)] px-3 py-1.5 text-xs text-black hover:opacity-90 transition-opacity",children:[e.jsx(ae,{size:14}),r("workers.register_worker")]}):null,[u,r])),e.jsxs("div",{className:"mx-auto max-w-6xl px-4 md:px-6 py-8 font-mono lowercase",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between border-b border-[var(--border)]",children:[e.jsxs("div",{className:"flex overflow-x-auto no-scrollbar",children:[e.jsxs("button",{type:"button",onClick:()=>{c("fleet"),m(a=>a+1)},className:`flex shrink-0 whitespace-nowrap items-center gap-2 px-4 py-2.5 text-xs transition-colors ${s==="fleet"?"border-b-2 border-[var(--accent)] text-[var(--text-primary)]":"text-[var(--text-muted)] hover:text-[var(--text-secondary)]"}`,children:[e.jsx(M,{size:14}),r("workers.fleet")]}),e.jsxs("button",{type:"button",onClick:()=>c("setup_guide"),className:`flex shrink-0 whitespace-nowrap items-center gap-2 px-4 py-2.5 text-xs transition-colors ${s==="setup_guide"?"border-b-2 border-[var(--accent)] text-[var(--text-primary)]":"text-[var(--text-muted)] hover:text-[var(--text-secondary)]"}`,children:[e.jsx(oe,{size:14}),r("workers.setup_guide")]})]}),s==="fleet"&&e.jsx(ee,{value:l,onChange:t,options:k})]}),s==="fleet"?h?e.jsx(re,{cards:6}):!b||b.length===0?e.jsx(te,{icon:M,title:r("workers.no_workers_found"),description:r(l!=="all"?"workers.try_changing_status_filter":"workers.no_workers_registered"),action:e.jsx("button",{type:"button",onClick:()=>c("setup_guide"),className:"rounded-[4px] bg-[var(--accent)] px-5 py-2 text-[11px] font-bold text-black",children:r("workers.view_setup_guide")})}):e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:(b??[]).map(a=>e.jsx(ne,{worker:a,onClick:()=>d(`/workers/${a.id}`)},a.id))}):e.jsx(Y,{}),e.jsx(le,{isOpen:v,onClose:()=>{p(!1),m(a=>a+1)},onRegistered:()=>{m(a=>a+1)}})]})}export{we as default};
6
+ */const oe=B("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]),ne=G.memo(function({worker:r,onClick:l}){const{t}=C();return e.jsxs("div",{onClick:l,className:`rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-4 font-mono lowercase transition-colors ${l?"cursor-pointer hover:border-[var(--accent)]/40 hover:bg-[var(--bg-input)]":""}`,children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsxs("h3",{className:"truncate text-sm text-[var(--text-primary)]",children:[e.jsx("span",{style:{color:W[r.status],fontSize:"0.6rem"},children:"●"})," ",r.name]}),e.jsx("span",{className:"text-xs",style:{color:W[r.status]},children:r.status})]}),e.jsxs("div",{className:"mb-3 text-xs text-[var(--text-muted)]",children:[r.host,r.os?`:${r.os}`:""]}),e.jsxs("div",{className:"mb-3 flex flex-col gap-2",children:[e.jsx(_,{label:t("workers.cpu"),value:r.cpuUsage,variant:"inline"}),e.jsx(_,{label:t("workers.mem"),value:r.memoryUsage,variant:"inline"}),e.jsx(_,{label:t("workers.disk"),value:r.diskUsage,variant:"inline"})]}),e.jsx("div",{className:"flex items-center justify-between text-xs",children:e.jsx("span",{className:"text-[var(--text-secondary)]",children:t("workers.tasks_slots",{active:String(r.activeSlots),max:String(r.maxSlots)})})}),r.capabilities.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:r.capabilities.map(s=>e.jsx("span",{className:"rounded-[4px] border border-[var(--border)] px-1.5 py-0.5 text-[11px] text-[var(--text-muted)]",children:s},s))})]})});function le({isOpen:d,onClose:r,onRegistered:l}){const{t}=C(),[s,c]=o.useState(1),[v,p]=o.useState(!1),[i,m]=o.useState(""),[u,g]=o.useState(null),[b,h]=o.useState(""),[k,a]=o.useState(""),[j,y]=o.useState(!1),[A,w]=o.useState(!1),[F,T]=o.useState(""),[I,$]=o.useState(""),x=o.useRef(null),O={1:t("workers.reg_step_generate_token"),2:t("workers.reg_step_install_worker"),3:t("workers.reg_step_waiting_activation"),4:t("workers.reg_step_activated")};o.useEffect(()=>(d&&(c(1),m(""),g(null),h(""),a(""),y(!1),w(!1),T(""),$(""),p(!1)),()=>{x.current&&clearInterval(x.current)}),[d]);const E=async()=>{const n=b.trim();if(!n){a(t("admin.pat_label_required"));return}a(""),p(!0);try{const f=await S.post("admin/worker-tokens",{json:{label:n}}).json();m(f.token),g(f.tokenId),c(2)}catch{}finally{p(!1)}},P=typeof window<"u"?window.location.origin:"https://overlord.example.com",L=i?`overlord setup worker --token ${i} --server ${P}`:"",R=()=>{navigator.clipboard.writeText(i),y(!0),setTimeout(()=>y(!1),2e3)},D=()=>{navigator.clipboard.writeText(L),w(!0),setTimeout(()=>w(!1),2e3)},q=o.useCallback(()=>{u&&(c(3),x.current=setInterval(async()=>{try{const n=await S.get(`admin/worker-tokens/${u}/status`).json();n.used&&n.workerName&&(T(n.workerName),$(n.workerId??""),c(4),x.current&&clearInterval(x.current),l==null||l())}catch{}},3e3))},[u,l]);return o.useEffect(()=>()=>{x.current&&clearInterval(x.current)},[]),d?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center font-mono lowercase",children:[e.jsx("div",{className:"absolute inset-0 bg-[var(--bg-primary)]/60 backdrop-blur-sm",onClick:r}),e.jsxs("div",{className:"relative z-10 w-full max-w-[1080px] rounded-[4px] border border-[var(--border)] bg-[var(--bg-card)] p-8",children:[e.jsx("button",{type:"button",onClick:r,className:"absolute right-4 top-4 text-[var(--text-muted)] hover:text-[var(--text-primary)]",children:e.jsx(U,{className:"h-4 w-4"})}),e.jsx("h2",{className:"text-lg font-bold text-[var(--accent)]",children:t("workers.reg_title")}),e.jsx("p",{className:"mt-1 text-xs text-[var(--text-muted)]",children:t("workers.reg_subtitle")}),e.jsx("div",{className:"mt-6 flex items-center justify-center gap-2",children:[1,2,3,4].map((n,f)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:`rounded-[4px] px-3 py-1.5 text-[11px] font-bold ${n===s?"bg-[var(--accent)] text-black":n<s?"bg-[var(--accent)]/20 text-[var(--accent)]":"border border-[var(--border)] bg-[var(--bg-primary)] text-[var(--text-muted)]"}`,children:[n,". ",O[n]]}),f<3&&e.jsx("span",{className:"text-xs text-[var(--text-muted)]",children:"→"})]},n))}),e.jsxs("div",{className:"mt-6 grid grid-cols-1 gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:`rounded-[4px] border p-4 ${s===1?"border-[var(--accent)] bg-[var(--bg-primary)]":"border-[var(--border)] bg-[var(--bg-primary)]"}`,children:[e.jsxs("p",{className:"text-[13px] font-bold text-[var(--accent)]",children:["> ",t("workers.reg_step_generate_token")]}),s===1&&!i?e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:t("workers.reg_click_to_generate")}),k&&e.jsx("p",{className:"text-[11px] text-red-400",children:k}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-[11px] text-[var(--text-muted)]",children:t("admin.label")}),e.jsx("input",{type:"text",placeholder:t("admin.pat_label_placeholder"),value:b,onChange:n=>h(n.target.value),onKeyDown:n=>{n.key==="Enter"&&E()},className:"w-full rounded-[4px] border border-[var(--border)] bg-[var(--bg-input)] px-3 py-1.5 text-[11px] text-[var(--text-primary)] placeholder:text-[var(--text-muted)] focus:border-[var(--accent)] focus:outline-none"})]}),e.jsx("button",{type:"button",onClick:E,disabled:v,className:"rounded-[4px] bg-[var(--accent)] px-4 py-1.5 text-xs font-bold text-black disabled:opacity-50",children:t(v?"admin.generating":"workers.reg_step_generate_token")})]}):i?e.jsxs("div",{className:"mt-3 space-y-3",children:[e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:t("workers.reg_token_generated")}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-[11px] text-[var(--text-muted)]",children:"Token"}),e.jsxs("div",{className:"relative rounded-[4px] border border-[var(--border)] bg-[var(--bg-primary)] px-3 py-2 pr-16",children:[e.jsx("code",{className:"block break-all text-[11px] text-[var(--text-primary)]",children:i}),e.jsx("button",{type:"button",onClick:R,className:"absolute right-2 top-1.5 text-[11px] text-[var(--text-muted)] hover:text-[var(--text-primary)]",children:j?e.jsx("span",{className:"text-[var(--accent)]",children:t("common.copied")}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(z,{className:"h-3 w-3"})," ",t("common.copy")]})})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-[11px] text-[var(--text-muted)]",children:t("admin.setup_command")}),e.jsxs("div",{className:"relative rounded-[4px] border border-[var(--border)] bg-[var(--bg-primary)] px-3 py-2 pr-16",children:[e.jsxs("code",{className:"block break-all text-[11px] text-[var(--accent)]",children:["$ ",L]}),e.jsx("button",{type:"button",onClick:D,className:"absolute right-2 top-1.5 text-[11px] text-[var(--text-muted)] hover:text-[var(--text-primary)]",children:A?e.jsx("span",{className:"text-[var(--accent)]",children:t("common.copied")}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(z,{className:"h-3 w-3"})," ",t("common.copy")]})})]})]}),e.jsx("div",{className:"rounded-[4px] border border-yellow-500/30 bg-yellow-500/10 px-3 py-2 text-[11px] text-yellow-400",children:t("admin.token_shown_once")})]}):e.jsx("p",{className:"mt-2 text-[11px] text-[var(--text-muted)]",children:t("workers.reg_completed")})]}),e.jsxs("div",{className:`rounded-[4px] border p-4 ${s===2?"border-[var(--accent)] bg-[var(--bg-primary)]":"border-[var(--border)] bg-[var(--bg-primary)]"}`,children:[e.jsxs("p",{className:"text-[13px] font-bold text-[var(--text-primary)]",children:["> ",t("workers.reg_step_install_worker")]}),e.jsx("p",{className:"mt-2 text-[11px] text-[var(--text-muted)]",children:t("workers.reg_running_installation")}),s>=2&&e.jsxs("div",{className:"mt-3 space-y-1 rounded-[4px] border border-[var(--border)] bg-[var(--bg-primary)] p-3",children:[e.jsx("p",{className:"text-[11px] text-[var(--text-primary)]",children:"$ overlord setup worker"}),e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:"server url: https://..."}),e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:"worker token: ovw_..."}),e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:"worker name: my-worker"}),e.jsx("p",{className:"text-[11px] text-[var(--accent)]",children:"config written. starting worker..."}),s===2&&e.jsx("p",{className:"text-[11px] text-[var(--accent)] animate-pulse",children:"&block;"})]}),s===2&&e.jsx("button",{type:"button",onClick:q,className:"mt-3 rounded-[4px] bg-[var(--accent)] px-4 py-1.5 text-xs font-bold text-black",children:t("workers.reg_installed_wait")})]}),e.jsxs("div",{className:`rounded-[4px] border p-4 ${s===3?"border-amber-500 bg-[var(--bg-primary)]":"border-[var(--border)] bg-[var(--bg-primary)]"}`,children:[e.jsxs("p",{className:"text-[13px] font-bold text-[var(--text-primary)]",children:["> ",t("workers.reg_step_waiting_activation")]}),s>=3?e.jsx("div",{className:"mt-3 flex flex-col items-center justify-center gap-3 py-6",children:s===3?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full border-2 border-amber-500",children:e.jsx(Z,{className:"h-5 w-5 animate-spin text-amber-500"})}),e.jsx("p",{className:"text-[11px] text-[var(--text-muted)]",children:t("workers.reg_listening_for_worker")})]}):e.jsx("p",{className:"text-[11px] text-[var(--accent)]",children:t("workers.reg_worker_connected")})}):e.jsx("p",{className:"mt-2 text-[11px] text-[var(--text-muted)]",children:t("workers.reg_waiting_for_worker")})]}),e.jsxs("div",{className:`rounded-[4px] border p-4 ${s===4?"border-[var(--accent)] bg-[var(--bg-primary)]":"border-[var(--border)] bg-[var(--bg-primary)]"}`,children:[e.jsxs("p",{className:"text-[13px] font-bold text-[var(--text-primary)]",children:["> ",t("workers.reg_step_activated")]}),s===4?e.jsxs("div",{className:"mt-3 flex flex-col items-center justify-center gap-3 py-6",children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-[var(--accent)]/20",children:e.jsx(K,{className:"h-6 w-6 text-[var(--accent)]"})}),e.jsx("p",{className:"text-xs font-bold text-[var(--accent)]",children:t("workers.reg_worker_activated",{name:F})}),I&&e.jsxs("p",{className:"text-[11px] text-[var(--text-muted)]",children:["worker_id: ",I]})]}):e.jsx("p",{className:"mt-2 text-[11px] text-[var(--text-muted)]",children:t("workers.reg_worker_registered")})]})]}),s===4&&e.jsx("div",{className:"mt-6 flex justify-end",children:e.jsx("button",{type:"button",onClick:r,className:"rounded-[4px] bg-[var(--accent)] px-5 py-2 text-xs font-bold text-black",children:t("workers.reg_done")})})]})]}):null}function we(){const d=H(),{t:r}=C(),[l,t]=o.useState("all"),[s,c]=o.useState("fleet"),[v,p]=o.useState(!1),[i,m]=o.useState(0),u=V(a=>{var j;return(j=a.user)==null?void 0:j.role}),g=X(a=>a.workerSeq),{data:b,loading:h}=se(()=>{const a={};return l!=="all"&&(a.status=l),S.get("web/workers",{searchParams:a}).json()},[l,i,g]),k=o.useMemo(()=>[{value:"all",label:r("workers.all_statuses")},{value:N.ONLINE,label:r("workers.online")},{value:N.OFFLINE,label:r("workers.offline")},{value:N.DRAINING,label:r("workers.draining")}],[r]);return J(o.useMemo(()=>u===Q.ADMIN?e.jsxs("button",{type:"button",onClick:()=>p(!0),className:"flex items-center gap-1.5 rounded-[4px] bg-[var(--accent)] px-3 py-1.5 text-xs text-black hover:opacity-90 transition-opacity",children:[e.jsx(ae,{size:14}),r("workers.register_worker")]}):null,[u,r])),e.jsxs("div",{className:"mx-auto max-w-6xl px-4 md:px-6 py-8 font-mono lowercase",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between border-b border-[var(--border)]",children:[e.jsxs("div",{className:"flex overflow-x-auto no-scrollbar",children:[e.jsxs("button",{type:"button",onClick:()=>{c("fleet"),m(a=>a+1)},className:`flex shrink-0 whitespace-nowrap items-center gap-2 px-4 py-2.5 text-xs transition-colors ${s==="fleet"?"border-b-2 border-[var(--accent)] text-[var(--text-primary)]":"text-[var(--text-muted)] hover:text-[var(--text-secondary)]"}`,children:[e.jsx(M,{size:14}),r("workers.fleet")]}),e.jsxs("button",{type:"button",onClick:()=>c("setup_guide"),className:`flex shrink-0 whitespace-nowrap items-center gap-2 px-4 py-2.5 text-xs transition-colors ${s==="setup_guide"?"border-b-2 border-[var(--accent)] text-[var(--text-primary)]":"text-[var(--text-muted)] hover:text-[var(--text-secondary)]"}`,children:[e.jsx(oe,{size:14}),r("workers.setup_guide")]})]}),s==="fleet"&&e.jsx(ee,{value:l,onChange:t,options:k})]}),s==="fleet"?h?e.jsx(re,{cards:6}):!b||b.length===0?e.jsx(te,{icon:M,title:r("workers.no_workers_found"),description:r(l!=="all"?"workers.try_changing_status_filter":"workers.no_workers_registered"),action:e.jsx("button",{type:"button",onClick:()=>c("setup_guide"),className:"rounded-[4px] bg-[var(--accent)] px-5 py-2 text-[11px] font-bold text-black",children:r("workers.view_setup_guide")})}):e.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:(b??[]).map(a=>e.jsx(ne,{worker:a,onClick:()=>d(`/workers/${a.id}`)},a.id))}):e.jsx(Y,{}),e.jsx(le,{isOpen:v,onClose:()=>{p(!1),m(a=>a+1)},onRegistered:()=>{m(a=>a+1)}})]})}export{we as default};