@sapienx/agentos 0.3.11 → 0.3.14

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 (201) hide show
  1. package/README.md +12 -2
  2. package/bin/agentos.js +777 -10
  3. package/bundle/.next/BUILD_ID +1 -1
  4. package/bundle/.next/app-path-routes-manifest.json +10 -8
  5. package/bundle/.next/build-manifest.json +3 -3
  6. package/bundle/.next/prerender-manifest.json +3 -3
  7. package/bundle/.next/react-loadable-manifest.json +3 -3
  8. package/bundle/.next/required-server-files.json +16 -0
  9. package/bundle/.next/routes-manifest.json +14 -0
  10. package/bundle/.next/server/app/_global-error/page.js +3 -3
  11. package/bundle/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  12. package/bundle/.next/server/app/_global-error.html +1 -1
  13. package/bundle/.next/server/app/_global-error.rsc +1 -1
  14. package/bundle/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  15. package/bundle/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  16. package/bundle/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  17. package/bundle/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  18. package/bundle/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  19. package/bundle/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  20. package/bundle/.next/server/app/_not-found/page.js +2 -2
  21. package/bundle/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  22. package/bundle/.next/server/app/_not-found.html +1 -1
  23. package/bundle/.next/server/app/_not-found.rsc +3 -3
  24. package/bundle/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
  25. package/bundle/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  26. package/bundle/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  27. package/bundle/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  28. package/bundle/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  29. package/bundle/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  30. package/bundle/.next/server/app/api/agents/[agentId]/chat/route.js +8 -1
  31. package/bundle/.next/server/app/api/agents/[agentId]/chat/route.js.nft.json +1 -1
  32. package/bundle/.next/server/app/api/agents/route.js +1 -1
  33. package/bundle/.next/server/app/api/agents/route.js.nft.json +1 -1
  34. package/bundle/.next/server/app/api/diagnostics/route.js +1 -1
  35. package/bundle/.next/server/app/api/diagnostics/route.js.nft.json +1 -1
  36. package/bundle/.next/server/app/api/files/reveal/route.js +1 -1
  37. package/bundle/.next/server/app/api/gateway/control/route.js +1 -1
  38. package/bundle/.next/server/app/api/gateway/control/route.js.nft.json +1 -1
  39. package/bundle/.next/server/app/api/mission/route.js +1 -1
  40. package/bundle/.next/server/app/api/mission/route.js.nft.json +1 -1
  41. package/bundle/.next/server/app/api/models/catalog/route.js +1 -0
  42. package/bundle/.next/server/app/api/models/catalog/route.js.nft.json +1 -0
  43. package/bundle/.next/server/app/api/models/catalog/route_client-reference-manifest.js +1 -0
  44. package/bundle/.next/server/app/api/models/providers/route.js +2 -2
  45. package/bundle/.next/server/app/api/models/providers/route.js.nft.json +1 -1
  46. package/bundle/.next/server/app/api/onboarding/models/route.js +7 -7
  47. package/bundle/.next/server/app/api/onboarding/models/route.js.nft.json +1 -1
  48. package/bundle/.next/server/app/api/onboarding/route.js +8 -8
  49. package/bundle/.next/server/app/api/onboarding/route.js.nft.json +1 -1
  50. package/bundle/.next/server/app/api/openclaw/capabilities/route.js +3 -3
  51. package/bundle/.next/server/app/api/planner/[planId]/deploy/route.js +2 -2
  52. package/bundle/.next/server/app/api/planner/[planId]/deploy/route.js.nft.json +1 -1
  53. package/bundle/.next/server/app/api/planner/[planId]/document-rewrite/route.js +1 -1
  54. package/bundle/.next/server/app/api/planner/[planId]/document-rewrite/route.js.nft.json +1 -1
  55. package/bundle/.next/server/app/api/planner/[planId]/route.js +1 -1
  56. package/bundle/.next/server/app/api/planner/[planId]/route.js.nft.json +1 -1
  57. package/bundle/.next/server/app/api/planner/[planId]/simulate/route.js +1 -1
  58. package/bundle/.next/server/app/api/planner/[planId]/simulate/route.js.nft.json +1 -1
  59. package/bundle/.next/server/app/api/planner/[planId]/turn/route.js +1 -1
  60. package/bundle/.next/server/app/api/planner/[planId]/turn/route.js.nft.json +1 -1
  61. package/bundle/.next/server/app/api/planner/route.js +1 -1
  62. package/bundle/.next/server/app/api/planner/route.js.nft.json +1 -1
  63. package/bundle/.next/server/app/api/reset/route.js +3 -3
  64. package/bundle/.next/server/app/api/reset/route.js.nft.json +1 -1
  65. package/bundle/.next/server/app/api/runtimes/[runtimeId]/route.js +1 -1
  66. package/bundle/.next/server/app/api/runtimes/[runtimeId]/route.js.nft.json +1 -1
  67. package/bundle/.next/server/app/api/settings/gateway/route.js +1 -1
  68. package/bundle/.next/server/app/api/settings/gateway/route.js.nft.json +1 -1
  69. package/bundle/.next/server/app/api/settings/workspace-root/route.js +1 -1
  70. package/bundle/.next/server/app/api/settings/workspace-root/route.js.nft.json +1 -1
  71. package/bundle/.next/server/app/api/snapshot/route.js +1 -1
  72. package/bundle/.next/server/app/api/snapshot/route.js.nft.json +1 -1
  73. package/bundle/.next/server/app/api/stream/route.js +2 -2
  74. package/bundle/.next/server/app/api/stream/route.js.nft.json +1 -1
  75. package/bundle/.next/server/app/api/system/open-terminal/route.js +1 -1
  76. package/bundle/.next/server/app/api/tasks/[taskId]/abort/route.js +1 -1
  77. package/bundle/.next/server/app/api/tasks/[taskId]/abort/route.js.nft.json +1 -1
  78. package/bundle/.next/server/app/api/tasks/[taskId]/stream/route.js +2 -2
  79. package/bundle/.next/server/app/api/tasks/[taskId]/stream/route.js.nft.json +1 -1
  80. package/bundle/.next/server/app/api/update/route.js +4 -4
  81. package/bundle/.next/server/app/api/update/route.js.nft.json +1 -1
  82. package/bundle/.next/server/app/api/workspaces/[workspaceId]/channels/discovered-groups/route.js +1 -1
  83. package/bundle/.next/server/app/api/workspaces/[workspaceId]/channels/discovered-groups/route.js.nft.json +1 -1
  84. package/bundle/.next/server/app/api/workspaces/[workspaceId]/channels/route.js +1 -1
  85. package/bundle/.next/server/app/api/workspaces/[workspaceId]/channels/route.js.nft.json +1 -1
  86. package/bundle/.next/server/app/api/workspaces/[workspaceId]/edit-draft/route.js +1 -1
  87. package/bundle/.next/server/app/api/workspaces/[workspaceId]/edit-draft/route.js.nft.json +1 -1
  88. package/bundle/.next/server/app/api/workspaces/[workspaceId]/surfaces/discovery/route.js +1 -0
  89. package/bundle/.next/server/app/api/workspaces/[workspaceId]/surfaces/discovery/route.js.nft.json +1 -0
  90. package/bundle/.next/server/app/api/workspaces/[workspaceId]/surfaces/discovery/route_client-reference-manifest.js +1 -0
  91. package/bundle/.next/server/app/api/workspaces/route.js +2 -2
  92. package/bundle/.next/server/app/api/workspaces/route.js.nft.json +1 -1
  93. package/bundle/.next/server/app/page.js +44 -41
  94. package/bundle/.next/server/app/page.js.nft.json +1 -1
  95. package/bundle/.next/server/app/page_client-reference-manifest.js +1 -1
  96. package/bundle/.next/server/app-paths-manifest.json +10 -8
  97. package/bundle/.next/server/chunks/199.js +412 -0
  98. package/bundle/.next/server/chunks/639.js +98 -0
  99. package/bundle/.next/server/chunks/661.js +1 -1
  100. package/bundle/.next/server/functions-config-manifest.json +3 -1
  101. package/bundle/.next/server/middleware-build-manifest.js +1 -1
  102. package/bundle/.next/server/middleware-react-loadable-manifest.js +1 -1
  103. package/bundle/.next/server/pages/404.html +1 -1
  104. package/bundle/.next/server/pages/500.html +1 -1
  105. package/bundle/.next/server/server-reference-manifest.json +1 -1
  106. package/bundle/.next/static/3RfU29upg-cPxACyzCFUb/_buildManifest.js +1 -0
  107. package/bundle/.next/static/chunks/{1364.5bd755c8584fcbc8.js → 2999.fef298fbe30cd4bd.js} +1 -1
  108. package/bundle/.next/static/chunks/5261.29ae1e1fe185a617.js +1 -0
  109. package/bundle/.next/static/chunks/7963-6bd42810c5733ae8.js +15 -0
  110. package/bundle/.next/static/chunks/app/_global-error/page-cde9c645dcfceb9f.js +1 -0
  111. package/bundle/.next/static/chunks/app/_not-found/page-cde9c645dcfceb9f.js +1 -0
  112. package/bundle/.next/static/chunks/app/api/agents/[agentId]/chat/route-cde9c645dcfceb9f.js +1 -0
  113. package/bundle/.next/static/chunks/app/api/agents/route-cde9c645dcfceb9f.js +1 -0
  114. package/bundle/.next/static/chunks/app/api/diagnostics/route-cde9c645dcfceb9f.js +1 -0
  115. package/bundle/.next/static/chunks/app/api/files/reveal/route-cde9c645dcfceb9f.js +1 -0
  116. package/bundle/.next/static/chunks/app/api/gateway/control/route-cde9c645dcfceb9f.js +1 -0
  117. package/bundle/.next/static/chunks/app/api/mission/route-cde9c645dcfceb9f.js +1 -0
  118. package/bundle/.next/static/chunks/app/api/models/catalog/route-cde9c645dcfceb9f.js +1 -0
  119. package/bundle/.next/static/chunks/app/api/models/providers/route-cde9c645dcfceb9f.js +1 -0
  120. package/bundle/.next/static/chunks/app/api/onboarding/models/route-cde9c645dcfceb9f.js +1 -0
  121. package/bundle/.next/static/chunks/app/api/onboarding/route-cde9c645dcfceb9f.js +1 -0
  122. package/bundle/.next/static/chunks/app/api/openclaw/capabilities/route-cde9c645dcfceb9f.js +1 -0
  123. package/bundle/.next/static/chunks/app/api/planner/[planId]/deploy/route-cde9c645dcfceb9f.js +1 -0
  124. package/bundle/.next/static/chunks/app/api/planner/[planId]/document-rewrite/route-cde9c645dcfceb9f.js +1 -0
  125. package/bundle/.next/static/chunks/app/api/planner/[planId]/route-cde9c645dcfceb9f.js +1 -0
  126. package/bundle/.next/static/chunks/app/api/planner/[planId]/simulate/route-cde9c645dcfceb9f.js +1 -0
  127. package/bundle/.next/static/chunks/app/api/planner/[planId]/turn/route-cde9c645dcfceb9f.js +1 -0
  128. package/bundle/.next/static/chunks/app/api/planner/route-cde9c645dcfceb9f.js +1 -0
  129. package/bundle/.next/static/chunks/app/api/reset/route-cde9c645dcfceb9f.js +1 -0
  130. package/bundle/.next/static/chunks/app/api/runtimes/[runtimeId]/route-cde9c645dcfceb9f.js +1 -0
  131. package/bundle/.next/static/chunks/app/api/settings/gateway/route-cde9c645dcfceb9f.js +1 -0
  132. package/bundle/.next/static/chunks/app/api/settings/workspace-root/route-cde9c645dcfceb9f.js +1 -0
  133. package/bundle/.next/static/chunks/app/api/snapshot/route-cde9c645dcfceb9f.js +1 -0
  134. package/bundle/.next/static/chunks/app/api/stream/route-cde9c645dcfceb9f.js +1 -0
  135. package/bundle/.next/static/chunks/app/api/system/open-terminal/route-cde9c645dcfceb9f.js +1 -0
  136. package/bundle/.next/static/chunks/app/api/tasks/[taskId]/abort/route-cde9c645dcfceb9f.js +1 -0
  137. package/bundle/.next/static/chunks/app/api/tasks/[taskId]/stream/route-cde9c645dcfceb9f.js +1 -0
  138. package/bundle/.next/static/chunks/app/api/update/route-cde9c645dcfceb9f.js +1 -0
  139. package/bundle/.next/static/chunks/app/api/workspaces/[workspaceId]/channels/discovered-groups/route-cde9c645dcfceb9f.js +1 -0
  140. package/bundle/.next/static/chunks/app/api/workspaces/[workspaceId]/channels/route-cde9c645dcfceb9f.js +1 -0
  141. package/bundle/.next/static/chunks/app/api/workspaces/[workspaceId]/edit-draft/route-cde9c645dcfceb9f.js +1 -0
  142. package/bundle/.next/static/chunks/app/api/workspaces/[workspaceId]/surfaces/discovery/route-cde9c645dcfceb9f.js +1 -0
  143. package/bundle/.next/static/chunks/app/api/workspaces/route-cde9c645dcfceb9f.js +1 -0
  144. package/bundle/.next/static/chunks/app/not-found-cde9c645dcfceb9f.js +1 -0
  145. package/bundle/.next/static/chunks/app/page-29f20effd872e616.js +179 -0
  146. package/bundle/.next/static/chunks/next/dist/client/components/builtin/app-error-cde9c645dcfceb9f.js +1 -0
  147. package/bundle/.next/static/chunks/next/dist/client/components/builtin/forbidden-cde9c645dcfceb9f.js +1 -0
  148. package/bundle/.next/static/chunks/next/dist/client/components/builtin/unauthorized-cde9c645dcfceb9f.js +1 -0
  149. package/bundle/.next/static/chunks/{webpack-4fdc6767ef8ff7b1.js → webpack-e0accbaa78fb0b56.js} +1 -1
  150. package/bundle/.next/static/css/9f1b31fd4086df59.css +3 -0
  151. package/bundle/package.json +1 -1
  152. package/bundle/public/readme/banner.jpeg +0 -0
  153. package/bundle/public/readme/mission-control-hero.svg +2 -2
  154. package/bundle/public/site.webmanifest +1 -1
  155. package/bundle/scripts/openclaw-mission-dispatch-runner.mjs +180 -9
  156. package/bundle/server.js +1 -1
  157. package/package.json +2 -2
  158. package/bundle/.next/server/chunks/212.js +0 -98
  159. package/bundle/.next/server/chunks/49.js +0 -420
  160. package/bundle/.next/static/PMHP584Iqd3KMZJH68hEV/_buildManifest.js +0 -1
  161. package/bundle/.next/static/chunks/1506.ec91294c1cbc454f.js +0 -1
  162. package/bundle/.next/static/chunks/5954-fd2a9c905dcede3c.js +0 -15
  163. package/bundle/.next/static/chunks/app/_global-error/page-1a770949224cd2a0.js +0 -1
  164. package/bundle/.next/static/chunks/app/_not-found/page-1a770949224cd2a0.js +0 -1
  165. package/bundle/.next/static/chunks/app/api/agents/[agentId]/chat/route-1a770949224cd2a0.js +0 -1
  166. package/bundle/.next/static/chunks/app/api/agents/route-1a770949224cd2a0.js +0 -1
  167. package/bundle/.next/static/chunks/app/api/diagnostics/route-1a770949224cd2a0.js +0 -1
  168. package/bundle/.next/static/chunks/app/api/files/reveal/route-1a770949224cd2a0.js +0 -1
  169. package/bundle/.next/static/chunks/app/api/gateway/control/route-1a770949224cd2a0.js +0 -1
  170. package/bundle/.next/static/chunks/app/api/mission/route-1a770949224cd2a0.js +0 -1
  171. package/bundle/.next/static/chunks/app/api/models/providers/route-1a770949224cd2a0.js +0 -1
  172. package/bundle/.next/static/chunks/app/api/onboarding/models/route-1a770949224cd2a0.js +0 -1
  173. package/bundle/.next/static/chunks/app/api/onboarding/route-1a770949224cd2a0.js +0 -1
  174. package/bundle/.next/static/chunks/app/api/openclaw/capabilities/route-1a770949224cd2a0.js +0 -1
  175. package/bundle/.next/static/chunks/app/api/planner/[planId]/deploy/route-1a770949224cd2a0.js +0 -1
  176. package/bundle/.next/static/chunks/app/api/planner/[planId]/document-rewrite/route-1a770949224cd2a0.js +0 -1
  177. package/bundle/.next/static/chunks/app/api/planner/[planId]/route-1a770949224cd2a0.js +0 -1
  178. package/bundle/.next/static/chunks/app/api/planner/[planId]/simulate/route-1a770949224cd2a0.js +0 -1
  179. package/bundle/.next/static/chunks/app/api/planner/[planId]/turn/route-1a770949224cd2a0.js +0 -1
  180. package/bundle/.next/static/chunks/app/api/planner/route-1a770949224cd2a0.js +0 -1
  181. package/bundle/.next/static/chunks/app/api/reset/route-1a770949224cd2a0.js +0 -1
  182. package/bundle/.next/static/chunks/app/api/runtimes/[runtimeId]/route-1a770949224cd2a0.js +0 -1
  183. package/bundle/.next/static/chunks/app/api/settings/gateway/route-1a770949224cd2a0.js +0 -1
  184. package/bundle/.next/static/chunks/app/api/settings/workspace-root/route-1a770949224cd2a0.js +0 -1
  185. package/bundle/.next/static/chunks/app/api/snapshot/route-1a770949224cd2a0.js +0 -1
  186. package/bundle/.next/static/chunks/app/api/stream/route-1a770949224cd2a0.js +0 -1
  187. package/bundle/.next/static/chunks/app/api/system/open-terminal/route-1a770949224cd2a0.js +0 -1
  188. package/bundle/.next/static/chunks/app/api/tasks/[taskId]/abort/route-1a770949224cd2a0.js +0 -1
  189. package/bundle/.next/static/chunks/app/api/tasks/[taskId]/stream/route-1a770949224cd2a0.js +0 -1
  190. package/bundle/.next/static/chunks/app/api/update/route-1a770949224cd2a0.js +0 -1
  191. package/bundle/.next/static/chunks/app/api/workspaces/[workspaceId]/channels/discovered-groups/route-1a770949224cd2a0.js +0 -1
  192. package/bundle/.next/static/chunks/app/api/workspaces/[workspaceId]/channels/route-1a770949224cd2a0.js +0 -1
  193. package/bundle/.next/static/chunks/app/api/workspaces/[workspaceId]/edit-draft/route-1a770949224cd2a0.js +0 -1
  194. package/bundle/.next/static/chunks/app/api/workspaces/route-1a770949224cd2a0.js +0 -1
  195. package/bundle/.next/static/chunks/app/not-found-1a770949224cd2a0.js +0 -1
  196. package/bundle/.next/static/chunks/app/page-e7ca3c6ffb09198b.js +0 -176
  197. package/bundle/.next/static/chunks/next/dist/client/components/builtin/app-error-1a770949224cd2a0.js +0 -1
  198. package/bundle/.next/static/chunks/next/dist/client/components/builtin/forbidden-1a770949224cd2a0.js +0 -1
  199. package/bundle/.next/static/chunks/next/dist/client/components/builtin/unauthorized-1a770949224cd2a0.js +0 -1
  200. package/bundle/.next/static/css/e20ab76ee4e77d93.css +0 -3
  201. /package/bundle/.next/static/{PMHP584Iqd3KMZJH68hEV → 3RfU29upg-cPxACyzCFUb}/_ssgManifest.js +0 -0
@@ -1,176 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8974],{243:(e,t,a)=>{"use strict";a.d(t,{Toaster:()=>s.l$,o:()=>s.oR});var s=a(8583)},473:(e,t,a)=>{"use strict";a.d(t,{Bc:()=>l,ZI:()=>c,k$:()=>d,m_:()=>o});var s=a(6366),r=a(430),n=a(971),i=a(3351);let l=n.Kq,o=n.bL,d=n.l9,c=r.forwardRef(({className:e,sideOffset:t=6,children:a,...r},l)=>(0,s.jsx)(n.ZL,{children:(0,s.jsx)(n.UC,{ref:l,sideOffset:t,className:(0,i.cn)("relative z-[9999] overflow-hidden rounded-[18px] border border-cyan-300/10 bg-slate-950/45 px-4 py-3 text-xs text-slate-100 shadow-[0_18px_50px_rgba(0,0,0,0.24)] backdrop-blur-xl",e),...r,children:(0,s.jsx)("div",{className:"relative z-10",children:a})})}));c.displayName=n.UC.displayName},474:(e,t,a)=>{"use strict";a.d(t,{m:()=>i});var s=a(6366),r=a(6658),n=a(3351);function i({tone:e,pulse:t=!1,className:a}){return(0,s.jsxs)("span",{className:(0,n.cn)("relative inline-flex h-2.5 w-2.5 items-center justify-center",a),children:[t?(0,s.jsx)(r.P.span,{className:(0,n.cn)("absolute inset-0 rounded-full",e),animate:{opacity:[.4,0],scale:[1,2.2]},transition:{duration:1.8,repeat:1/0,ease:"easeOut"}}):null,(0,s.jsx)("span",{className:(0,n.cn)("relative inline-flex h-2.5 w-2.5 rounded-full",e)})]})}},2711:(e,t,a)=>{"use strict";a.d(t,{$7:()=>h,$m:()=>g,CK:()=>d,FO:()=>i,JZ:()=>o,Uu:()=>p,_y:()=>l,fw:()=>r,hv:()=>n,iD:()=>m,m_:()=>u,sY:()=>c});var s=a(3962);function r(e,t=Date.now()){return null==e||Number.isNaN(e)?"No activity":`${(0,s.k)(e,t,{addSuffix:!0})}`}function n(e){if(!e)return Date.now();let t=Date.parse(e);return Number.isNaN(t)?Date.now():t}function i(e){return e?e>=1e3?`${Math.round(e/1e3)}k`:String(e):"n/a"}function l(e){return"number"!=typeof e?"0":e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(e)}function o(e){return e.split("/").at(1)||e}function d(e){return e.name?.trim()||e.identityName?.trim()||"OpenClaw"}function c(e){switch(e){case"running":return"text-cyan-300";case"completed":return"text-emerald-300";case"cancelled":return"text-rose-300";case"stalled":case"queued":return"text-amber-200";default:return"text-slate-400"}}function p(e){switch(e){case"running":return"default";case"completed":return"success";case"cancelled":return"danger";case"stalled":return"warning";default:return"muted"}}function m(e){switch(e){case"healthy":return"text-emerald-300";case"degraded":return"text-amber-200";default:return"text-rose-200"}}function u(e,t=8){return e?e.length<=t?e:e.slice(0,t):"n/a"}function h(e){return e.replace(/^\/Users\/[^/]+/,"~")}let x=[/^Task output routing:/i,/^Agent operating policy:/i];function g(e,t=64){if(!e)return"";let a=function(e){let t=e.replace(/\r\n/g,"\n").trim();if(!t)return"";let a=[];for(let e of t.split("\n")){let t=e.trim();if(x.some(e=>e.test(t)))break;a.push(e)}return a.join(" ").replace(/\s+/g," ").trim()}(e);return a?a.length<=t?a:`${a.slice(0,Math.max(t-1,1)).trimEnd()}…`:""}},2842:(e,t,a)=>{"use strict";a.d(t,{$x:()=>o,A_:()=>i,Bw:()=>g,Cf:()=>c,DS:()=>d,UJ:()=>h,_P:()=>m,bQ:()=>x,bt:()=>n,g0:()=>p,sH:()=>l,zR:()=>u});let s={worker:{label:"Worker",description:"Delivers code, docs, research, review, or analysis without mutating the system.",defaultName:"Worker",defaultEmoji:"\uD83D\uDEE0️",defaultTheme:"slate",badgeVariant:"default"},setup:{label:"Setup / Operator",description:"Prepares the environment, installs dependencies, and unblocks other agents.",defaultName:"Setup Operator",defaultEmoji:"\uD83E\uDDF0",defaultTheme:"amber",badgeVariant:"warning"},browser:{label:"Browser",description:"Captures browser evidence, screenshots, and user-path validation inside the workspace.",defaultName:"Browser Agent",defaultEmoji:"\uD83C\uDF10",defaultTheme:"blue",badgeVariant:"success"},monitoring:{label:"Monitoring",description:"Periodically checks workspace health, drift, and blockers, then leaves triage handoffs.",defaultName:"Monitoring Agent",defaultEmoji:"\uD83D\uDEF0️",defaultTheme:"teal",badgeVariant:"warning"},custom:{label:"Custom",description:"Starts from a safe default policy but leaves room for manual overrides.",defaultName:"Custom Agent",defaultEmoji:"\uD83E\uDDE9",defaultTheme:"violet",badgeVariant:"muted"}},r={worker:{missingToolBehavior:"fallback",installScope:"none",fileAccess:"workspace-only",networkAccess:"enabled"},setup:{missingToolBehavior:"allow-install",installScope:"workspace",fileAccess:"workspace-only",networkAccess:"enabled"},browser:{missingToolBehavior:"ask-setup",installScope:"none",fileAccess:"workspace-only",networkAccess:"enabled"},monitoring:{missingToolBehavior:"fallback",installScope:"none",fileAccess:"workspace-only",networkAccess:"enabled"},custom:{missingToolBehavior:"fallback",installScope:"none",fileAccess:"workspace-only",networkAccess:"enabled"}},n=Object.entries(s).map(([e,t])=>({value:e,label:t.label,description:t.description})),i=[{value:"fallback",label:"Fallback",description:"Produce the nearest viable output format instead of failing the task."},{value:"ask-setup",label:"Ask for setup",description:"Stop before environment changes and report the missing capability clearly."},{value:"route-setup",label:"Route to setup agent",description:"Leave an explicit setup handoff instead of attempting installs directly."},{value:"allow-install",label:"Allow install",description:"Install missing tooling when policy allows it and the task truly depends on it."}],l=[{value:"none",label:"None",description:"Do not install workspace or system dependencies."},{value:"workspace",label:"Workspace only",description:"Only install dependencies inside the project or workspace environment."},{value:"system",label:"System",description:"Permit system-wide installs when they are necessary and intentional."}],o=[{value:"workspace-only",label:"Workspace only",description:"Keep file work grounded inside the attached workspace."},{value:"extended",label:"Extended",description:"Allow broader file access when the task explicitly needs it."}],d=[{value:"restricted",label:"Off",description:"Avoid network access unless the task explicitly depends on it."},{value:"enabled",label:"On",description:"Use network access when the task needs external information or downloads."}];function c(e){return s[e]}function p(e="worker",t){return{...r[e],...t??{},preset:e}}function m(e){return s[e].label}function u(e){return i.find(t=>t.value===e)?.label??e}function h(e){return l.find(t=>t.value===e)?.label??e}function x(e){return o.find(t=>t.value===e)?.label??e}function g(e){return d.find(t=>t.value===e)?.label??e}},3031:(e,t,a)=>{"use strict";a.d(t,{MissionControlShell:()=>rV});var s=a(6366),r=a(576),n=a(5411),i=a(2071),l=a(1113),o=a(2452),d=a(3899),c=a(9261),p=a(4837),m=a(9758),u=a(9613),h=a(2060),x=a(6658),g=a(430),b=a(7227),f=a(5054),w=a(7794),y=a(6247),v=a(656),j=a(2625),k=a(6761),N=a(7932),C=a(5880),S=a(3351);let A=(0,C.F)("inline-flex items-center justify-center whitespace-nowrap rounded-2xl text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-cyan-400 text-slate-950 shadow-lg shadow-cyan-400/20 hover:bg-cyan-300",secondary:"border border-white/10 bg-white/5 text-slate-100 hover:bg-white/10 hover:text-white",ghost:"text-slate-200 hover:bg-white/[0.08] hover:text-white",destructive:"bg-rose-500 text-white shadow-lg shadow-rose-500/20 hover:bg-rose-400"},size:{default:"h-11 px-4 py-2",sm:"h-9 rounded-xl px-3",lg:"h-12 rounded-2xl px-5",icon:"h-11 w-11"}},defaultVariants:{variant:"default",size:"default"}}),I=g.forwardRef(({className:e,variant:t,size:a,asChild:r=!1,...n},i)=>{let l=r?N.DX:"button";return(0,s.jsx)(l,{className:(0,S.cn)(A({variant:t,size:a,className:e})),ref:i,...n})});I.displayName="Button";let T=g.forwardRef(({className:e,type:t,...a},r)=>(0,s.jsx)("input",{type:t,className:(0,S.cn)("flex h-11 w-full rounded-2xl border border-white/10 bg-white/5 px-4 py-2 text-sm text-white placeholder:text-slate-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-cyan-400/60 disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...a}));T.displayName="Input";var M=a(6563);let O=M.bL,R=g.forwardRef(({className:e,...t},a)=>(0,s.jsx)(M.B8,{ref:a,className:(0,S.cn)("inline-flex h-11 items-center rounded-2xl border border-white/10 bg-white/5 p-1 text-slate-400",e),...t}));R.displayName=M.B8.displayName;let $=g.forwardRef(({className:e,...t},a)=>(0,s.jsx)(M.l9,{ref:a,className:(0,S.cn)("inline-flex items-center justify-center whitespace-nowrap rounded-xl px-3 py-2 text-sm transition-all data-[state=active]:bg-white/10 data-[state=active]:text-white",e),...t}));$.displayName=M.l9.displayName;let E=g.forwardRef(({className:e,...t},a)=>(0,s.jsx)(M.UC,{ref:a,className:(0,S.cn)("mt-4 outline-none focus-visible:ring-0",e),...t}));E.displayName=M.UC.displayName;let D=[{id:"openai-codex",label:"ChatGPT",shortLabel:"ChatGPT",description:"Connect your ChatGPT account and pull in Codex-ready models.",category:"primary",connectKind:"oauth",accent:"from-[#d8f5eb] via-[#ebfbf5] to-white",helperText:"Account-based login with the OpenClaw provider flow."},{id:"openrouter",label:"OpenRouter",shortLabel:"OpenRouter",description:"Add an API key, discover the full catalog, and curate the models you want.",category:"primary",connectKind:"apiKey",accent:"from-[#fff2d7] via-[#fff7ea] to-white",helperText:"Best for broad model access and curated remote routes.",searchPlaceholder:"Search OpenRouter models"},{id:"ollama",label:"Ollama Local",shortLabel:"Ollama",description:"Discover models already available on this machine and add them instantly.",category:"primary",connectKind:"local",accent:"from-[#deefff] via-[#f2f8ff] to-white",helperText:"Local-first discovery with helpful pull commands when empty."},{id:"anthropic",label:"Anthropic",shortLabel:"Anthropic",description:"Paste an API key and add Claude models through the same flow.",category:"other",connectKind:"apiKey",accent:"from-[#efe9ff] via-[#f7f3ff] to-white",helperText:"Simple API key connection."},{id:"openai",label:"OpenAI API",shortLabel:"OpenAI",description:"Connect a standard OpenAI API key for direct GPT model access.",category:"other",connectKind:"apiKey",accent:"from-[#e8f8e8] via-[#f4fbf4] to-white",helperText:"Use this for API-key-based OpenAI routing."},{id:"gemini",label:"Gemini",shortLabel:"Gemini",description:"Add a Gemini API key, discover Google models, and pick the routes you want.",category:"other",connectKind:"apiKey",accent:"from-[#e6f7ff] via-[#f4fbff] to-white",helperText:"Simple API key connection.",searchPlaceholder:"Search Gemini models"},{id:"deepseek",label:"DeepSeek",shortLabel:"DeepSeek",description:"Add a DeepSeek API key, discover the catalog, and add the models you need.",category:"other",connectKind:"apiKey",accent:"from-[#e7eeff] via-[#f4f7ff] to-white",helperText:"Simple API key connection.",searchPlaceholder:"Search DeepSeek models"},{id:"mistral",label:"Mistral",shortLabel:"Mistral",description:"Add a Mistral API key, discover Mistral and Codestral models, and curate your routes.",category:"other",connectKind:"apiKey",accent:"from-[#f2e8ff] via-[#fbf7ff] to-white",helperText:"Simple API key connection.",searchPlaceholder:"Search Mistral models"},{id:"xai",label:"xAI",shortLabel:"xAI",description:"Use an xAI API key to bring Grok models into AgentOS.",category:"other",connectKind:"apiKey",accent:"from-[#ffe6ea] via-[#fff3f5] to-white",helperText:"Simple API key connection."}];function _(e){let t=D.find(t=>t.id===e);if(!t)throw Error(`Unknown model provider: ${e}`);return t}function P(e){return"string"==typeof e&&D.some(t=>t.id===e)}function L(e){if(P(e))return e;if(e&&"object"==typeof e&&"id"in e){let t=e.id;if(P(t))return t}return null}function U(e,t){let a=t.trim().toLowerCase();return a?e.filter(e=>`${e.name} ${e.id} ${e.tags.join(" ")}`.toLowerCase().includes(a)):e}function F({provider:e,models:t,selectedModelIds:a,search:r,onSearchChange:n,onToggleModel:i,onAddSelected:l,isAdding:o}){let d=t.filter(e=>e.recommended),c=a.filter(e=>!t.find(t=>t.id===e)?.alreadyAdded).length,p="openrouter"===e,m=_(e).searchPlaceholder,u=t.length>8||!!m,h=U(d,r),x=U(t,r);return(0,s.jsxs)("div",{className:"rounded-[18px] border border-white/10 bg-[linear-gradient(180deg,rgba(10,15,26,0.94),rgba(7,11,20,0.96))] p-3",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-display text-[0.84rem] text-white",children:"Select models to add"}),(0,s.jsxs)("p",{className:"mt-1 text-[10px] leading-[0.98rem] text-slate-400",children:["Found ",t.length," model",1===t.length?"":"s"," for this provider."]})]}),(0,s.jsxs)(k.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:[t.filter(e=>e.alreadyAdded).length," already added"]})]}),u?(0,s.jsxs)("div",{className:"relative mt-3",children:[(0,s.jsx)(y.A,{className:"pointer-events-none absolute left-3 top-1/2 h-3 w-3 -translate-y-1/2 text-slate-500"}),(0,s.jsx)(T,{value:r,onChange:e=>n(e.target.value),placeholder:m??"Search models",className:"h-8 pl-8 text-[11px]"})]}):null,p?(0,s.jsxs)(O,{defaultValue:"recommended",className:"mt-3",children:[(0,s.jsxs)(R,{className:"h-8 rounded-[16px] p-0.5",children:[(0,s.jsx)($,{value:"recommended",className:"rounded-[13px] px-2 py-1 text-[10px]",children:"Recommended"}),(0,s.jsx)($,{value:"all",className:"rounded-[13px] px-2 py-1 text-[10px]",children:"All models"})]}),(0,s.jsx)(E,{value:"recommended",children:(0,s.jsx)(z,{models:h,selectedModelIds:a,onToggleModel:i,emptyMessage:"No recommended matches. Switch to All models to browse the full catalog."})}),(0,s.jsx)(E,{value:"all",children:(0,s.jsx)(z,{models:x,selectedModelIds:a,onToggleModel:i,emptyMessage:"No models matched this search."})})]}):(0,s.jsx)("div",{className:"mt-3",children:(0,s.jsx)(z,{models:x,selectedModelIds:a,onToggleModel:i,emptyMessage:"No models matched this search."})}),(0,s.jsxs)("div",{className:"mt-3 flex items-center justify-between gap-2 border-t border-white/10 pt-3",children:[(0,s.jsx)("p",{className:"text-[9px] leading-4 text-slate-400",children:c>0?`${c} model${1===c?"":"s"} selected`:"Choose at least one model to add"}),(0,s.jsx)(I,{type:"button",onClick:l,disabled:0===c||o,className:"h-7 rounded-full px-2.5 text-[10px]",children:o?"Adding...":"Add selected models"})]})]})}function z({models:e,selectedModelIds:t,onToggleModel:a,emptyMessage:r}){return 0===e.length?(0,s.jsx)("div",{className:"rounded-[16px] border border-dashed border-white/10 bg-white/[0.03] px-3 py-5 text-center text-[11px] text-slate-400",children:r}):(0,s.jsx)("div",{className:"max-h-[min(28vh,220px)] space-y-1 overflow-y-auto pr-1",children:e.map(e=>{let r=t.includes(e.id);return(0,s.jsxs)("button",{type:"button",disabled:e.alreadyAdded,onClick:()=>a(e.id),className:(0,S.cn)("flex w-full items-start justify-between gap-2 rounded-[14px] border px-2.5 py-2 text-left transition-all",e.alreadyAdded?"cursor-not-allowed border-white/8 bg-white/[0.02] opacity-70":r?"border-cyan-300/35 bg-cyan-300/[0.08]":"border-white/8 bg-white/[0.03] hover:border-white/16 hover:bg-white/[0.05]"),children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-start gap-2",children:[(0,s.jsx)("div",{className:(0,S.cn)("mt-0.5 flex h-[16px] w-[16px] shrink-0 items-center justify-center rounded-md border",e.alreadyAdded?"border-white/10 bg-white/[0.03] text-slate-500":r?"border-cyan-300/50 bg-cyan-300/15 text-cyan-100":"border-white/12 bg-white/[0.03] text-transparent"),children:e.alreadyAdded?(0,s.jsx)(v.A,{className:"h-2 w-2"}):(0,s.jsx)(j.A,{className:"h-2 w-2"})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"truncate text-[11px] font-medium text-white",children:e.name}),(0,s.jsx)("p",{className:"mt-0.5 truncate text-[9px] uppercase tracking-[0.16em] text-slate-500",children:e.id}),(0,s.jsxs)("div",{className:"mt-1 flex flex-wrap gap-1.5 text-[9px] text-slate-400",children:[(0,s.jsx)("span",{children:e.input}),e.contextWindow?(0,s.jsxs)("span",{children:[Intl.NumberFormat().format(e.contextWindow)," ctx"]}):null,e.isFree?(0,s.jsx)("span",{children:"free"}):null]})]})]}),(0,s.jsx)("div",{className:"shrink-0",children:e.alreadyAdded?(0,s.jsx)(k.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Already added"}):e.recommended?(0,s.jsx)(k.E,{variant:"default",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Recommended"}):e.local?(0,s.jsx)(k.E,{variant:"success",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Local"}):(0,s.jsx)(k.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:"Remote"})})]},e.id)})})}D.filter(e=>"primary"===e.category),D.filter(e=>"other"===e.category);var W=a(25),B=a(6732);let q={"openai-codex":{kind:"image",src:"/assets/provider-logos/openai.svg"},openai:{kind:"image",src:"/assets/provider-logos/openai.svg"},anthropic:{kind:"simple",icon:K("siAnthropic","Anthropic")},gemini:{kind:"simple",icon:K("siGooglegemini","Gemini")},deepseek:{kind:"image",src:"/assets/provider-logos/deepseek.svg"},mistral:{kind:"simple",icon:K("siMistralai","Mistral")},openrouter:{kind:"simple",icon:K("siOpenrouter","OpenRouter")},ollama:{kind:"simple",icon:K("siOllama","Ollama")},xai:{kind:"image",src:"/assets/provider-logos/xai.svg"}};function K(e,t){let a=B[e];return a||{title:t,hex:"ffffff",path:"M0 0h24v24H0z"}}function G({provider:e,className:t}){let a=q[e.trim().toLowerCase()];return a?(0,s.jsx)("div",{className:(0,S.cn)("flex shrink-0 items-center justify-center overflow-hidden rounded-[16px] border border-black/5 bg-white/95 text-slate-900 shadow-[0_1px_1px_rgba(0,0,0,0.04)]",t),"aria-hidden":"true",children:"image"===a.kind?(0,s.jsx)(W.default,{src:a.src,alt:"",width:18,height:18,className:"h-[72%] w-[72%] select-none object-contain",unoptimized:!0}):(0,s.jsx)("svg",{viewBox:"0 0 24 24",className:"h-[72%] w-[72%] select-none",fill:`#${a.icon.hex}`,children:(0,s.jsx)("path",{d:a.icon.path})})}):null}function V({descriptor:e,active:t,compact:a=!1,connected:r=!1,detail:n,onClick:i}){return(0,s.jsxs)("button",{type:"button",onClick:i,className:(0,S.cn)("group w-full rounded-[20px] border text-left transition-all",a?"p-2.5":"p-3.5",t?a?"border-cyan-300/40 bg-[linear-gradient(180deg,rgba(23,32,52,0.98),rgba(11,18,31,0.98))] shadow-[0_12px_26px_rgba(10,16,28,0.22)]":"border-cyan-300/40 bg-[linear-gradient(180deg,rgba(23,32,52,0.98),rgba(11,18,31,0.98))] shadow-[0_16px_36px_rgba(10,16,28,0.26)]":"border-white/10 bg-[linear-gradient(180deg,rgba(15,23,42,0.92),rgba(10,15,28,0.92))] hover:border-white/18 hover:bg-[linear-gradient(180deg,rgba(20,29,49,0.96),rgba(12,18,31,0.96))]"),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2.5",children:[(0,s.jsx)(G,{className:(0,S.cn)(a?"h-7 w-7":"h-9 w-9",t?"ring-1 ring-cyan-300/20":""),provider:e.id}),(0,s.jsx)(k.E,{variant:r?"success":t?"default":"muted",className:(0,S.cn)("tracking-[0.12em]",a?"px-1.5 py-0.5 text-[9px]":"px-2 py-0.5 text-[10px]"),children:r?"Connected":t?"Selected":"Provider"})]}),(0,s.jsxs)("div",{className:a?"mt-2":"mt-3.5",children:[(0,s.jsx)("p",{className:(0,S.cn)("font-display text-white",a?"text-[0.82rem]":"text-[0.94rem]"),children:e.label}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1 text-slate-300",a?"text-[9px] leading-[0.95rem]":"text-[11px] leading-5"),children:e.description}),(0,s.jsx)("p",{className:(0,S.cn)("mt-2.5 uppercase tracking-[0.18em] text-slate-500",a?"text-[8px]":"text-[9px]"),children:n||e.helperText})]})]})}var J=a(1288),H=a(5433);let Y=J.bL,Q=J.l9,Z=J.ZL;J.bm;let X=g.forwardRef(({className:e,...t},a)=>(0,s.jsx)(J.hJ,{ref:a,className:(0,S.cn)("fixed inset-0 z-50 bg-slate-950/75 backdrop-blur-md",e),...t}));X.displayName=J.hJ.displayName;let ee=g.forwardRef(({className:e,children:t,...a},r)=>(0,s.jsxs)(Z,{children:[(0,s.jsx)(X,{}),(0,s.jsxs)(J.UC,{ref:r,className:(0,S.cn)("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 rounded-[28px] border border-white/10 bg-slate-950/90 p-6 shadow-panel backdrop-blur-xl duration-200",e),...a,children:[t,(0,s.jsxs)(J.bm,{className:"absolute right-4 top-4 rounded-full p-2 text-slate-400 transition-colors hover:bg-white/5 hover:text-white",children:[(0,s.jsx)(H.A,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]})]}));ee.displayName=J.UC.displayName;let et=({className:e,...t})=>(0,s.jsx)("div",{className:(0,S.cn)("flex flex-col space-y-2 text-left",e),...t}),ea=({className:e,...t})=>(0,s.jsx)("div",{className:(0,S.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t}),es=g.forwardRef(({className:e,...t},a)=>(0,s.jsx)(J.hE,{ref:a,className:(0,S.cn)("font-display text-xl text-white",e),...t}));es.displayName=J.hE.displayName;let er=g.forwardRef(({className:e,...t},a)=>(0,s.jsx)(J.VY,{ref:a,className:(0,S.cn)("text-sm text-slate-400",e),...t}));async function en(e){let t=await fetch("/api/models/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await t.json().catch(()=>null);if(!t.ok||!a)throw Error(a?.error||a?.message||"Model provider request failed.");if(!a.ok&&a.message)throw Error(a.message);return a}er.displayName=J.VY.displayName;let ei=Object.fromEntries(D.map(e=>{var t;return[e.id,{id:t=e.id,descriptor:_(t),getConnectionStatus:()=>en({action:"status",provider:t}),connect:e=>en({action:"connect",provider:t,apiKey:e?.apiKey?.trim()?e.apiKey.trim():void 0,endpoint:e?.endpoint?.trim()?e.endpoint.trim():void 0}),discoverModels:()=>en({action:"discover",provider:t}),addModels:e=>en({action:"add-models",provider:t,modelIds:e})}]}));var el=a(243);let eo=()=>({flowState:"idle",connection:null,statusMessage:null,errorMessage:null,emptyState:null,manualCommand:null,docsUrl:null,models:[],selectedModelIds:[],apiKey:"",search:"",loaded:!1});function ed({open:e,onOpenChange:t,snapshot:a,initialProvider:r=null,onSnapshotChange:l}){var o,d;let c,p,m,u,h=L(r),[x,y]=(0,g.useState)(h),[v,j]=(0,g.useState)({}),[N,C]=(0,g.useState)(!1),A=(0,g.useEffectEvent)(e=>{$(e)});(0,g.useEffect)(()=>{if(e){if(h)return void A(h);y(e=>P(e)?e:null)}},[e,h]);let M=P(x)?x:null,O=M&&v[M]||eo(),R=M?_(M):null;async function $(e){if(y(e),"ollama"!==e){(v[e]||eo()).loaded||await E(e);return}await z(e,!0)}async function E(e){let t=ei[e];K(e,{flowState:"idle",errorMessage:null});try{let a=await t.getConnectionStatus();G(e,a,a.emptyState?"discovery-empty":"idle")}catch(t){K(e,{flowState:"auth-error",errorMessage:t instanceof Error?t.message:"Provider status could not be loaded.",loaded:!0})}}async function U(e){let t=ei[e],a=v[e]||eo();K(e,{flowState:"connecting",errorMessage:null,statusMessage:"openai-codex"===e?"Opening the ChatGPT connection flow...":`Connecting ${_(e).shortLabel}...`});try{let s=await t.connect({apiKey:a.apiKey});G(e,s,"openai-codex"===e?"connecting":s.models.length?"discovery-success":"idle"),s.snapshot&&l(s.snapshot),"openai-codex"!==e&&"ollama"!==e&&await z(e)}catch(t){K(e,{flowState:"auth-error",errorMessage:t instanceof Error?t.message:"Provider connection failed."})}}async function z(e,t=!1){let a=ei[e],s=v[e]||eo();if(t||"discovery-loading"!==s.flowState){K(e,{flowState:"discovery-loading",errorMessage:null,statusMessage:"ollama"===e?"Checking the local Ollama runtime...":"Discovering available models..."});try{let t=await a.discoverModels();G(e,t,t.models.length>0?"discovery-success":t.emptyState?"discovery-empty":"idle"),t.snapshot&&l(t.snapshot)}catch(t){K(e,{flowState:"auth-error",errorMessage:t instanceof Error?t.message:"Model discovery failed."})}}}async function W(e){let t=ei[e],a=v[e]||eo(),s=a.selectedModelIds.filter(e=>!a.models.find(t=>t.id===e)?.alreadyAdded);if(0!==s.length){K(e,{flowState:"connecting",errorMessage:null,statusMessage:"Adding selected models..."});try{let a=await t.addModels(s);G(e,a,"add-success",{selectedModelIds:[]}),a.snapshot&&l(a.snapshot),el.o.success("Models added.",{description:a.message})}catch(t){K(e,{flowState:"add-error",errorMessage:t instanceof Error?t.message:"Models could not be added."})}}}async function B(e){try{C(!0);let t=await fetch("/api/system/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:e})}),a=await t.json().catch(()=>null);if(!t.ok)throw Error(a?.error||"Terminal could not be opened.");el.o.success("Terminal opened.",{description:"Finish the provider login there, then return here to discover models."})}catch(e){el.o.error("Unable to open Terminal.",{description:e instanceof Error?e.message:"Unknown terminal error."})}finally{C(!1)}}async function q(e){try{await navigator.clipboard.writeText(e),el.o.success("Copied.",{description:"Command copied to your clipboard."})}catch{el.o.error("Copy failed.",{description:"Clipboard access is not available."})}}function K(e,t){j(a=>({...a,[e]:{...a[e]||eo(),...t}}))}function G(e,t,a,s){K(e,{flowState:a,connection:t.connection,statusMessage:t.message,errorMessage:null,emptyState:t.emptyState??null,manualCommand:t.manualCommand??null,docsUrl:t.docsUrl??null,models:t.models,loaded:!0,...s})}return(0,s.jsx)(Y,{open:e,onOpenChange:t,children:(0,s.jsxs)(ee,{className:"flex h-[80dvh] max-h-[80dvh] w-[calc(100vw-16px)] max-w-[760px] flex-col gap-0 overflow-hidden p-0 sm:h-[min(80dvh,700px)] sm:max-h-[min(80dvh,700px)] sm:w-[min(760px,calc(100vw-40px))]",children:[(0,s.jsxs)(et,{className:"shrink-0 border-b border-white/10 bg-[linear-gradient(180deg,rgba(12,18,31,0.96),rgba(9,13,24,0.98))] px-4 py-3.5 pr-10",children:[(0,s.jsx)(es,{className:"text-[1.05rem]",children:"Add Models"}),(0,s.jsx)(er,{className:"max-w-[500px] text-[11px] leading-[1rem] text-slate-400",children:"Connect a provider, discover available models, and add them in seconds."})]}),(0,s.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:(0,s.jsxs)("div",{className:"space-y-4 px-3 py-3 sm:px-4 sm:py-4",children:[(0,s.jsxs)("div",{className:"rounded-[22px] border border-white/10 bg-[linear-gradient(180deg,rgba(13,20,34,0.94),rgba(9,13,24,0.96))] p-3",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-display text-[0.84rem] text-white",children:"All providers"}),(0,s.jsx)("p",{className:"mt-1 text-[9px] leading-[0.95rem] text-slate-400",children:"Scroll right to browse the full provider catalog."})]}),(0,s.jsxs)(k.E,{variant:"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:[D.length," total"]})]}),(0,s.jsxs)("div",{className:"relative mt-2.5",children:[(0,s.jsx)("div",{className:"pointer-events-none absolute inset-y-0 left-0 z-10 w-6 bg-gradient-to-r from-[rgba(13,20,34,0.96)] to-transparent"}),(0,s.jsx)("div",{className:"pointer-events-none absolute inset-y-0 right-0 z-10 w-6 bg-gradient-to-l from-[rgba(13,20,34,0.96)] to-transparent"}),(0,s.jsx)("div",{className:"-mx-1 overflow-x-auto overscroll-x-contain pb-1",children:(0,s.jsx)("div",{className:"flex min-w-max gap-2.5 px-1",children:D.map(e=>(0,s.jsx)("div",{className:"w-[236px] shrink-0 snap-start sm:w-[244px]",children:(0,s.jsx)(V,{descriptor:e,active:M===e.id,compact:!0,connected:ep(a,v,e.id).connected,detail:ep(a,v,e.id).detail,onClick:()=>{$(e.id)}})},e.id))})}),(0,s.jsx)("div",{className:"pointer-events-none absolute bottom-1.5 right-3 z-10 rounded-full border border-white/10 bg-slate-950/70 px-2 py-0.5 text-[8px] uppercase tracking-[0.14em] text-slate-400",children:"Scroll ->"})]})]}),(0,s.jsx)("div",{className:"rounded-[22px] border border-white/10 bg-[linear-gradient(180deg,rgba(11,18,32,0.96),rgba(6,10,18,0.98))] p-3",children:M&&R?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-display text-[0.88rem] text-white",children:R.label}),(0,s.jsx)("p",{className:"mt-1 max-w-[520px] text-[10px] leading-[0.98rem] text-slate-400",children:"oauth"===R.connectKind?"Use your account login, then discover the models that are ready to add.":"local"===R.connectKind?"Check the local runtime first, then add the models already available on this machine.":"Connect the provider, review the discovered catalog, and add only the models you want."})]}),(0,s.jsx)(k.E,{variant:O.connection?.connected?"success":"muted",className:"px-1.5 py-0.5 text-[9px] tracking-[0.12em]",children:O.connection?.connected?"Connected":"Not connected"})]}),(0,s.jsx)("div",{className:"mt-3 flex flex-wrap gap-1",children:(o=M,d=O,c="ollama"===o?!!(d.connection?.connected||d.emptyState):!!(d.connection?.connected||d.manualCommand),p=d.models.length>0||!!d.emptyState,m=d.selectedModelIds.length>0,u="add-success"===d.flowState,[{label:"Choose provider",status:"done"},{label:"ollama"===o?"Local check":"Connect",status:"connecting"!==d.flowState||c?c?"done":"pending":"active"},{label:"Discover",status:"discovery-loading"===d.flowState?"active":p?"done":"pending"},{label:"Select",status:u?"done":m?"active":"pending"},{label:"Add",status:u?"done":"add-error"===d.flowState?"active":"pending"}]).map(e=>(0,s.jsxs)("div",{className:(0,S.cn)("inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-[9px] uppercase tracking-[0.14em]","done"===e.status?"border-emerald-300/20 bg-emerald-300/10 text-emerald-100":"active"===e.status?"border-cyan-300/20 bg-cyan-300/10 text-cyan-100":"border-white/10 bg-white/[0.03] text-slate-500"),children:[(0,s.jsx)("span",{className:(0,S.cn)("h-1.5 w-1.5 rounded-full","done"===e.status?"bg-emerald-300":"active"===e.status?"bg-cyan-300":"bg-slate-600")}),e.label]},e.label))}),O.statusMessage?(0,s.jsx)("div",{className:"mt-3 rounded-[16px] border border-white/10 bg-white/[0.04] px-3 py-2",children:(0,s.jsx)("p",{className:"text-[11px] text-slate-200",children:O.statusMessage})}):null,O.errorMessage?(0,s.jsx)("div",{className:"mt-3 rounded-[16px] border border-rose-400/20 bg-rose-400/[0.08] px-3 py-2 text-[11px] text-rose-100",children:O.errorMessage}):null,"openai-codex"===M?(0,s.jsxs)("div",{className:"mt-4 rounded-[20px] border border-white/10 bg-white/[0.03] p-3",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-display text-[0.88rem] text-white",children:"Connect your ChatGPT account"}),(0,s.jsx)("p",{className:"mt-1 max-w-[500px] text-[10px] leading-[0.98rem] text-slate-400",children:"This uses OpenClaw's account-based login flow. No API key is required."})]}),(0,s.jsx)(I,{type:"button",className:"h-8 rounded-full px-3 text-[10px]",disabled:"connecting"===O.flowState&&!O.manualCommand,onClick:()=>{U(M)},children:"connecting"!==O.flowState||O.manualCommand?"Connect ChatGPT":(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Connecting..."]})})]}),O.manualCommand?(0,s.jsxs)("div",{className:"mt-3 rounded-[16px] border border-cyan-300/15 bg-cyan-300/[0.07] p-3",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-[11px] font-medium text-cyan-50",children:"Finish sign-in in Terminal"}),(0,s.jsx)("p",{className:"mt-1 max-w-[480px] text-[10px] leading-[0.98rem] text-cyan-100/80",children:"Open Terminal, complete the provider login, then return here and check discovery."})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,s.jsx)(I,{type:"button",variant:"secondary",size:"sm",className:"h-7 rounded-full px-2.5 text-[10px]",disabled:N,onClick:()=>{B(O.manualCommand||"")},children:N?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.A,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Opening..."]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(b.A,{className:"mr-1.5 h-3 w-3"}),"Open Terminal"]})}),(0,s.jsxs)(I,{type:"button",variant:"ghost",size:"sm",className:"h-7 rounded-full px-2.5 text-[10px]",onClick:()=>{q(O.manualCommand||"")},children:[(0,s.jsx)(f.A,{className:"mr-1.5 h-3 w-3"}),"Copy command"]}),(0,s.jsxs)(I,{type:"button",variant:"ghost",size:"sm",className:"h-7 rounded-full px-2.5 text-[10px]",onClick:()=>{z(M)},children:[(0,s.jsx)(n.A,{className:"mr-1.5 h-3 w-3"}),"I've connected it"]})]})]}),(0,s.jsx)("div",{className:"mt-2.5 overflow-x-auto rounded-[14px] border border-white/10 bg-slate-950/60 px-3 py-2",children:(0,s.jsx)("code",{className:"text-[10px] text-slate-200",children:O.manualCommand})})]}):null]}):null,"apiKey"===R.connectKind?(0,s.jsx)("div",{className:"mt-4 rounded-[20px] border border-white/10 bg-white/[0.03] p-3",children:(0,s.jsxs)("div",{className:"flex flex-wrap items-end gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("label",{className:"block text-[9px] uppercase tracking-[0.16em] text-slate-500",children:"API key"}),(0,s.jsx)(T,{type:"password",value:O.apiKey,onChange:e=>K(M,{apiKey:e.target.value}),placeholder:"openrouter"===M?"sk-or-v1-...":"Paste API key",className:"mt-1.5 h-8 text-[11px]"})]}),(0,s.jsx)(I,{type:"button",className:"h-8 rounded-full px-3 text-[10px]",disabled:"connecting"===O.flowState||!O.apiKey.trim(),onClick:()=>{U(M)},children:"connecting"===O.flowState?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Connecting..."]}):`Connect ${R.shortLabel}`})]})}):null,"oauth"!==R.connectKind?(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[(0,s.jsx)(I,{type:"button",variant:"secondary",size:"sm",className:"h-8 rounded-full px-3 text-[10px]",disabled:"discovery-loading"===O.flowState,onClick:()=>{z(M)},children:"discovery-loading"===O.flowState?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.A,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Discovering..."]}):"Discover models"}),(0,s.jsx)(I,{type:"button",variant:"ghost",size:"sm",className:"h-8 rounded-full px-3 text-[10px]",onClick:()=>{E(M)},children:"Refresh status"})]}):null,O.emptyState?(0,s.jsx)(ec,{emptyState:O.emptyState,onCopyCommand:e=>{q(e)}}):null,O.models.length>0?(0,s.jsx)("div",{className:"mt-5",children:(0,s.jsx)(F,{provider:M,models:O.models,selectedModelIds:O.selectedModelIds,search:O.search,onSearchChange:e=>K(M,{search:e}),onToggleModel:e=>{K(M,{selectedModelIds:O.selectedModelIds.includes(e)?O.selectedModelIds.filter(t=>t!==e):[...O.selectedModelIds,e]})},onAddSelected:()=>{W(M)},isAdding:"connecting"===O.flowState&&"Adding selected models..."===O.statusMessage})}):null,"add-success"===O.flowState?(0,s.jsxs)("div",{className:"mt-3 flex items-center gap-2.5 rounded-[16px] border border-emerald-300/20 bg-emerald-300/[0.08] px-3 py-2",children:[(0,s.jsx)(w.A,{className:"h-3.5 w-3.5 text-emerald-200"}),(0,s.jsx)("p",{className:"text-[11px] text-emerald-50",children:O.statusMessage||"Models were added successfully."})]}):null,O.docsUrl?(0,s.jsx)("a",{href:O.docsUrl,target:"_blank",rel:"noreferrer",className:"mt-3 inline-flex text-[10px] text-slate-300 underline underline-offset-4",children:"OpenClaw model docs"}):null]}):(0,s.jsx)("div",{className:"flex min-h-[180px] items-center justify-center rounded-[20px] border border-dashed border-white/10 bg-white/[0.02] px-4 py-6 text-center",children:(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-display text-[0.88rem] text-white",children:"Choose a provider to begin"}),(0,s.jsx)("p",{className:"mt-1.5 max-w-[360px] text-[11px] leading-[0.98rem] text-slate-400",children:"Start with ChatGPT, OpenRouter, Gemini, DeepSeek, Mistral, or Ollama Local. The flow will guide you through connect, discovery, selection, and add."})]})})})]})})]})})}function ec({emptyState:e,onCopyCommand:t}){return(0,s.jsxs)("div",{className:"mt-3 rounded-[20px] border border-white/10 bg-white/[0.03] p-3",children:[(0,s.jsx)("p",{className:"font-display text-[0.88rem] text-white",children:e.title}),(0,s.jsx)("p",{className:"mt-1 max-w-[520px] text-[11px] leading-[0.98rem] text-slate-400",children:e.description}),e.commands?.length?(0,s.jsx)("div",{className:"mt-3 space-y-1.5",children:e.commands.map(e=>(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-[14px] border border-white/10 bg-slate-950/60 px-3 py-2",children:[(0,s.jsx)("code",{className:"text-[10px] text-slate-200",children:e}),(0,s.jsxs)(I,{type:"button",size:"sm",variant:"ghost",className:"h-7 rounded-full px-2.5 text-[10px]",onClick:()=>t(e),children:[(0,s.jsx)(f.A,{className:"mr-1.5 h-3 w-3"}),"Copy"]})]},e))}):null]})}function ep(e,t,a){let s=t[a]?.connection;if(s)return s;let r=e.diagnostics.modelReadiness.authProviders.find(e=>e.provider===a),n=e.models.filter(e=>e.id.startsWith(`${a}/`)).length;return"ollama"===a?{provider:a,connected:n>0,canConnect:!0,needsTerminal:!1,detail:n>0?`${n} model${1===n?"":"s"} already visible in AgentOS.`:"Detect local models from this machine."}:{provider:a,connected:!!(r?.connected||n>0),canConnect:!0,needsTerminal:"openai-codex"===a,detail:r?.detail||_(a).helperText}}var em=a(8583),eu=a(3875);function eh({title:e,selectedValues:t,selectedTone:a,selectedEmptyLabel:r,lockedValues:n=[],observedValues:i=[],inputRef:l,inputValue:o,onInputValueChange:d,onRemove:c,onAddCustom:p,onPick:m,suggestions:u,emptySuggestionLabel:h,loading:x,catalogError:g,helperLabel:b,highlight:f,customActionLabel:w}){let y="cyan"===a?{border:"border-cyan-300/20",chip:"border-cyan-300/15 bg-cyan-400/10 text-cyan-50",chipHover:"hover:border-cyan-200/30 hover:bg-cyan-400/15"}:{border:"border-amber-300/20",chip:"border-amber-300/15 bg-amber-400/10 text-amber-50",chipHover:"hover:border-amber-200/30 hover:bg-amber-400/15"},j=n.length>0;return(0,s.jsxs)("div",{className:(0,S.cn)("rounded-[18px] border bg-[linear-gradient(180deg,rgba(11,18,32,0.86),rgba(8,13,24,0.82))] p-3.5",y.border,f&&"shadow-[0_0_0_1px_rgba(34,211,238,0.08)]"),children:[(0,s.jsxs)("div",{className:"mb-3 flex items-center justify-between gap-2",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.22em] text-slate-500",children:e}),(0,s.jsx)(k.E,{variant:"muted",children:"Declared"})]}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5",children:t.length>0?t.map(e=>(0,s.jsxs)("button",{type:"button",className:(0,S.cn)("inline-flex max-w-full items-center gap-1.5 rounded-full border px-2.5 py-1 text-[11px] transition-colors",y.chip,y.chipHover),onClick:()=>{n.includes(e)||c(e)},title:n.includes(e)?`Locked by policy: ${e}`:`Remove ${e}`,children:[(0,s.jsx)("span",{className:"max-w-full truncate",children:e}),n.includes(e)?(0,s.jsx)(v.A,{className:"h-3 w-3 text-white/70"}):(0,s.jsx)("span",{className:"text-white/70",children:"\xd7"})]},e)):(0,s.jsx)(k.E,{variant:"muted",children:r})}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,s.jsx)(T,{ref:l,value:o,onChange:e=>d(e.target.value),onKeyDown:e=>(function(e,t,a,s,r){if("Enter"!==e.key)return;e.preventDefault();let n=s[0];n?r(n.value):t.trim()&&a()})(e,o,p,u,m),placeholder:"Skills"===e?"Search OpenClaw or workspace skills":"Search built-in tools or plugin tools",className:"h-8 flex-1 rounded-xl border-white/10 bg-white/5 px-3 text-[12px]"}),(0,s.jsxs)(I,{type:"button",variant:"secondary",size:"sm",onClick:p,disabled:!o.trim(),className:"h-8 rounded-xl px-3 text-[11px]",children:[(0,s.jsx)(eu.A,{className:"mr-1 h-3.5 w-3.5"}),w]})]}),(0,s.jsx)("div",{className:"max-h-[280px] space-y-1.5 overflow-y-auto pr-1",children:(0,s.jsx)(ex,{kind:"Skills"===e?"skill":"tool",options:u,onPick:m,emptyLabel:h})}),j?(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Policy locked"}),(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:n.map(e=>(0,s.jsxs)(k.E,{variant:"success",children:[(0,s.jsx)(v.A,{className:"mr-1 h-3 w-3"}),e]},e))})]}):null,i.length>0?(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Observed"}),(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:i.slice(0,10).map(e=>(0,s.jsx)(k.E,{variant:"muted",children:e},e))})]}):null,(0,s.jsx)("p",{className:"text-[11px] leading-5 text-slate-500",children:b}),g?(0,s.jsx)("p",{className:"text-[11px] leading-5 text-slate-500",children:g}):null,x&&0===u.length?(0,s.jsx)("p",{className:"text-[11px] leading-5 text-slate-500",children:"Loading OpenClaw catalog..."}):null]})]})}function ex({kind:e,options:t,onPick:a,emptyLabel:r}){return 0===t.length?(0,s.jsx)("p",{className:"text-[11px] leading-5 text-slate-500",children:r}):(0,s.jsx)("div",{className:"space-y-1.5",children:t.map(t=>{var r;return(0,s.jsxs)("button",{type:"button",className:(0,S.cn)("group flex w-full items-start justify-between gap-3 rounded-xl border border-white/[0.08] bg-white/[0.03] px-3 py-1.5 text-left transition-colors hover:border-cyan-300/20 hover:bg-cyan-400/[0.05]","tool"===e&&"hover:border-amber-300/20 hover:bg-amber-400/[0.05]"),onClick:()=>a(t.value),title:t.description,children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("p",{className:"truncate text-[12px] leading-4 text-white",children:t.label}),"group"===t.category?(0,s.jsx)(k.E,{variant:"muted",children:"group"}):null]}),(0,s.jsx)("p",{className:"line-clamp-2 text-[11px] leading-4 text-slate-400",children:t.description})]}),(0,s.jsx)(k.E,{variant:"skill"===(r=t).kind?"workspace"===r.category?"success":"custom"===r.category?"muted":"default":"plugin"===r.category?"warning":"group"===r.category||"custom"===r.category?"muted":"default",children:t.sourceLabel})]},t.value)})})}var eg=a(2842),eb=a(2711);function ef(e,t){let a=new Map;for(let r of e){var s;let e=r.value.trim();if(!e)continue;let n=a.get(e);if(!n){a.set(e,{...r,value:e,label:r.label||e,description:r.description||"",sourceLabel:r.sourceLabel||"OpenClaw",sourceRank:r.sourceRank??99,kind:r.kind||t,category:r.category});continue}n.description=n.description||r.description,s=n.sourceLabel,n.sourceLabel=ey([s,r.sourceLabel].filter(e=>!!e)).join(" \xb7 "),n.sourceRank=Math.min(n.sourceRank,r.sourceRank??n.sourceRank),n.category=n.category??r.category}return Array.from(a.values()).sort((e,t)=>{let a=e.sourceRank-t.sourceRank;if(0!==a)return a;let s=e.label.localeCompare(t.label);return 0!==s?s:e.value.localeCompare(t.value)})}function ew(e,t,a,s=8){let r=t.trim().toLowerCase(),n=new Set(ey(a));return e.filter(e=>!n.has(e.value)).filter(e=>!r||5>ej(e,r)).sort((e,t)=>{let a=ej(e,r),s=ej(t,r);if(a!==s)return a-s;let n=e.sourceRank-t.sourceRank;return 0!==n?n:e.label.localeCompare(t.label)}).slice(0,s)}function ey(e){let t=new Set,a=[];for(let s of e){if("string"!=typeof s)continue;let e=s.trim();!e||t.has(e)||(t.add(e),a.push(e))}return a}function ev(e,t){return e.length===t.length&&e.every((e,a)=>e===t[a])}function ej(e,t){if(!t)return 0;let a=[e.value.toLowerCase(),e.label.toLowerCase(),e.description.toLowerCase(),e.sourceLabel.toLowerCase()];return a.some(e=>e===t)?0:a.some(e=>e.startsWith(t))?1:a.some(e=>e.includes(t))?2:5}let ek=[{name:"exec",description:"Run shell commands and manage background processes.",source:"OpenClaw built-in",category:"builtin"},{name:"process",description:"Run shell commands and manage background processes.",source:"OpenClaw built-in",category:"builtin"},{name:"bash",description:"Run shell commands and manage background processes.",source:"OpenClaw built-in",category:"builtin"},{name:"code_execution",description:"Run sandboxed remote Python analysis.",source:"OpenClaw built-in",category:"builtin"},{name:"browser",description:"Control a Chromium browser (navigate, click, screenshot).",source:"OpenClaw built-in",category:"builtin"},{name:"web_search",description:"Search the web and fetch search results.",source:"OpenClaw built-in",category:"builtin"},{name:"x_search",description:"Search X posts.",source:"OpenClaw built-in",category:"builtin"},{name:"web_fetch",description:"Fetch page content.",source:"OpenClaw built-in",category:"builtin"},{name:"read",description:"Read files in the workspace.",source:"OpenClaw built-in",category:"builtin"},{name:"write",description:"Write files in the workspace.",source:"OpenClaw built-in",category:"builtin"},{name:"edit",description:"Edit files in the workspace.",source:"OpenClaw built-in",category:"builtin"},{name:"apply_patch",description:"Apply structured multi-hunk patches.",source:"OpenClaw built-in",category:"builtin"},{name:"message",description:"Send messages across channels.",source:"OpenClaw built-in",category:"builtin"},{name:"canvas",description:"Drive node canvas workflows.",source:"OpenClaw built-in",category:"builtin"},{name:"nodes",description:"Discover and target paired devices.",source:"OpenClaw built-in",category:"builtin"},{name:"cron",description:"Manage scheduled jobs.",source:"OpenClaw built-in",category:"builtin"},{name:"gateway",description:"Inspect and restart gateway services.",source:"OpenClaw built-in",category:"builtin"},{name:"image",description:"Analyze images.",source:"OpenClaw built-in",category:"builtin"},{name:"image_generate",description:"Generate or edit images.",source:"OpenClaw built-in",category:"builtin"},{name:"sessions_list",description:"Session management and sub-agent discovery.",source:"OpenClaw built-in",category:"builtin"},{name:"sessions_history",description:"Session management and sub-agent discovery.",source:"OpenClaw built-in",category:"builtin"},{name:"sessions_send",description:"Session management and sub-agent discovery.",source:"OpenClaw built-in",category:"builtin"},{name:"sessions_spawn",description:"Session management and sub-agent discovery.",source:"OpenClaw built-in",category:"builtin"},{name:"sessions_yield",description:"Session management and sub-agent discovery.",source:"OpenClaw built-in",category:"builtin"},{name:"subagents",description:"Session management and sub-agent discovery.",source:"OpenClaw built-in",category:"builtin"},{name:"session_status",description:"Session management and sub-agent discovery.",source:"OpenClaw built-in",category:"builtin"},{name:"agents_list",description:"Session management and sub-agent discovery.",source:"OpenClaw built-in",category:"builtin"}],eN=[{name:"group:runtime",description:"exec, bash, process, code_execution",source:"OpenClaw docs",category:"group"},{name:"group:fs",description:"read, write, edit, apply_patch",source:"OpenClaw docs",category:"group"},{name:"group:sessions",description:"sessions_list, sessions_history, sessions_send, sessions_spawn, sessions_yield, subagents, session_status",source:"OpenClaw docs",category:"group"},{name:"group:memory",description:"memory_search, memory_get",source:"OpenClaw docs",category:"group"},{name:"group:web",description:"web_search, x_search, web_fetch",source:"OpenClaw docs",category:"group"},{name:"group:ui",description:"browser, canvas",source:"OpenClaw docs",category:"group"},{name:"group:automation",description:"cron, gateway",source:"OpenClaw docs",category:"group"},{name:"group:messaging",description:"message",source:"OpenClaw docs",category:"group"},{name:"group:nodes",description:"nodes",source:"OpenClaw docs",category:"group"},{name:"group:openclaw",description:"All built-in OpenClaw tools (excludes plugin tools).",source:"OpenClaw docs",category:"group"}];function eC({open:e,agentId:t,initialFocus:a="skills",snapshot:r,onOpenChange:n,onSnapshotChange:l,onRefresh:o}){let d=t?r.agents.find(e=>e.id===t)??null:null,c=r.workspaces.find(e=>e.id===d?.workspaceId),[p,m]=(0,g.useState)(null),[u,h]=(0,g.useState)(null),[x,b]=(0,g.useState)(!1),[f,w]=(0,g.useState)(!1),[y,v]=(0,g.useState)(null),[j,N]=(0,g.useState)(""),[C,S]=(0,g.useState)(""),[A,T]=(0,g.useState)([]),[M,O]=(0,g.useState)([]),R=(0,g.useRef)(null),$=(0,g.useRef)(null),E=(0,g.useRef)(r),D="tools"===a?"tools":"skills",_="skills"===D,P="tools"===D,L=ey(d?.skills??[]),U=ey((d?.tools??[]).filter(e=>"fs.workspaceOnly"!==e)),F=d?.tools.includes("fs.workspaceOnly")?["fs.workspaceOnly"]:[],z=ey(d?.observedTools??[]),W=ey(c?.bootstrap.localSkillIds??[]),B=(0,g.useMemo)(()=>[...ek,...eN],[]);(0,g.useEffect)(()=>{E.current=r},[r]),(0,g.useEffect)(()=>{if(!e||!t)return;let a=E.current.agents.find(e=>e.id===t)??null;if(!a)return;let s=ey(a.skills??[]),r=ey((a.tools??[]).filter(e=>"fs.workspaceOnly"!==e));T(s),O(r),N(""),S(""),v(null)},[t,e]),(0,g.useEffect)(()=>{if(!e)return;let t=new AbortController;return b(!0),fetch("/api/openclaw/capabilities",{signal:t.signal}).then(async e=>{let t=await e.json();if(!e.ok)throw Error(t.error||"Unable to load OpenClaw capability catalog.");m(t),h(null)}).catch(e=>{t.signal.aborted||(m(null),h(e instanceof Error?e.message:"Unable to load OpenClaw capability catalog."))}).finally(()=>{t.signal.aborted||b(!1)}),()=>t.abort()},[e]);let q=(0,g.useMemo)(()=>ef([...(p?.skills??[]).map(e=>{var t;return{value:e.name,label:e.name,description:e.description,sourceLabel:"openclaw-bundled"===(t=e.source)?"OpenClaw bundled":"workspace"===t?"Workspace":t,sourceRank:+("openclaw-bundled"!==e.source),kind:"skill"}}),...W.map(e=>({value:e,label:e,description:"Workspace-local SKILL.md scaffold.",sourceLabel:"Workspace",sourceRank:0,kind:"skill",category:"workspace"})),...A.filter(e=>!(p?.skills??[]).some(t=>t.name===e)).map(e=>({value:e,label:e,description:"Already configured on this agent.",sourceLabel:"Current agent",sourceRank:2,kind:"skill",category:"custom"}))],"skill"),[p?.skills,A,W]),K=(0,g.useMemo)(()=>ef([...B.map(e=>({value:e.name,label:e.name,description:e.description,sourceLabel:"builtin"===e.category?"OpenClaw built-in":"group"===e.category?"OpenClaw docs":e.source,sourceRank:"builtin"===e.category?0:"plugin"===e.category?1:2,kind:"tool",category:e.category})),...M.filter(e=>"fs.workspaceOnly"!==e&&!(p?.tools??[]).some(t=>t.name===e)).map(e=>({value:e,label:e,description:"Already configured on this agent.",sourceLabel:"Current agent",sourceRank:3,kind:"tool",category:"custom"})),...z.filter(e=>"fs.workspaceOnly"!==e&&!(p?.tools??[]).some(t=>t.name===e)&&!U.includes(e)).map(e=>({value:e,label:e,description:"Recovered from runtime transcripts.",sourceLabel:"Observed",sourceRank:4,kind:"tool",category:"custom"}))],"tool"),[p?.tools,U,M,B,z]),G=(0,g.useMemo)(()=>ew(q,j,A),[A,j,q]),V=(0,g.useMemo)(()=>ew(K,C,M),[M,C,K]);if((0,g.useEffect)(()=>{if(e){if("skills"===a)return void R.current?.focus();$.current?.focus()}},[a,e]),!d)return null;let J=_?ey(A):L,H=P?ey(M):U,Q=!ev(J,L)||!ev(H,U),Z="h-5 border-white/[0.08] px-2 py-0 text-[10px] font-normal tracking-[0.06em] normal-case",X=async()=>{if(ev(J,L)&&ev(H,U))return void n(!1);w(!0),v(null);try{let e={id:d.id};_?e.skills=J:e.tools=H;let t=await fetch("/api/agents",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await t.json();if(!t.ok)throw Error(a.error||"Unable to update agent capabilities.");l?.(e=>(function(e,t,a,s){let r=ey(a),n=ey(s),i=e.agents.map(e=>e.id===t?{...e,skills:r,tools:n}:e),l=i.find(e=>e.id===t);if(!l)return e;let o=e.workspaces.map(e=>{if(e.id!==l.workspaceId)return e;let t=i.filter(t=>t.workspaceId===e.id);return{...e,capabilities:{...e.capabilities,skills:ey(t.flatMap(e=>e.skills)),tools:ey(t.flatMap(e=>e.tools)),workspaceOnlyAgentCount:t.filter(e=>e.tools.includes("fs.workspaceOnly")).length}}});return{...e,agents:i,workspaces:o}})(e,d.id,J,H)),em.oR.success("Agent capabilities updated."),n(!1);let s=o?.();s&&s.catch(()=>void 0)}catch(t){let e=t instanceof Error?t.message:"Unable to update agent capabilities.";v(e),em.oR.error(e)}finally{w(!1)}};return(0,s.jsx)(Y,{open:e,onOpenChange:n,children:(0,s.jsx)(ee,{className:"w-[min(680px,calc(100vw-1.5rem))] max-h-[calc(100dvh-1.5rem)] overflow-hidden rounded-[24px] border-white/10 bg-[linear-gradient(180deg,rgba(7,10,18,0.98),rgba(4,7,14,0.98))] p-0",children:(0,s.jsxs)("div",{className:"flex max-h-[calc(100dvh-1.5rem)] min-h-0 flex-col",children:[(0,s.jsxs)(et,{className:"border-b border-white/[0.08] px-4 py-3",children:[(0,s.jsx)(es,{className:"text-[0.95rem]",children:`Edit ${_?"skills":"tools"} \xb7 ${(0,eb.CK)(d)}`}),(0,s.jsx)(er,{className:"text-[12px] leading-5 text-slate-400",children:_?"Select from OpenClaw and workspace skills or add a custom value.":"Select from built-in tools, plugin tools, or add a custom value."}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-1.5 pt-1",children:[(0,s.jsx)(k.E,{variant:"muted",className:Z,children:(0,eg._P)(d.policy.preset)}),d.identity.source?(0,s.jsx)(k.E,{variant:"muted",className:Z,children:d.identity.source}):null,(0,s.jsx)(k.E,{variant:"muted",className:Z,children:d.id})]})]}),(0,s.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[(0,s.jsx)("div",{className:"px-4 py-4",children:(0,s.jsx)(eh,{title:_?"Skills":"Tools",selectedValues:_?A:M,selectedTone:_?"cyan":"amber",selectedEmptyLabel:_?"No explicit skills":"No explicit tools configured",lockedValues:P?F:[],observedValues:P?z:[],inputRef:_?R:$,inputValue:_?j:C,onInputValueChange:_?N:S,onRemove:e=>{_?T(t=>t.filter(t=>t!==e)):O(t=>t.filter(t=>t!==e))},onAddCustom:()=>{let e=ey((_?j:C).split(/[\n,]/g).map(e=>e.trim()).filter(e=>!!e));e.length>0&&(_?(T(t=>ey([...t,...e])),N("")):(O(t=>ey([...t,...e])),S("")))},onPick:e=>{_?(T(t=>ey([...t,e])),N("")):(O(t=>ey([...t,e])),S(""))},suggestions:_?G:V,emptySuggestionLabel:x&&(_?G.length:V.length)===0?_?"Loading OpenClaw skill catalog...":"Loading OpenClaw tool catalog...":_?"No matching skills found.":"No matching tools found.",loading:x,catalogError:u,helperLabel:_?"Workspace skills and OpenClaw skills are shown first.":"Built-ins, plugins, and groups are shown first. Observed tools are read-only.",highlight:!0,customActionLabel:_?"Add custom skill":"Add custom tool"})}),y?(0,s.jsx)("div",{className:"border-t border-white/[0.08] px-4 py-3",children:(0,s.jsx)("p",{className:"text-[12px] leading-5 text-rose-300",children:y})}):null]}),(0,s.jsxs)(ea,{className:"border-t border-white/[0.08] px-4 py-2 sm:flex-row",children:[(0,s.jsx)(I,{type:"button",variant:"secondary",onClick:()=>n(!1),disabled:f,className:"h-8 rounded-full px-2.5 text-[10px]",children:"Cancel"}),(0,s.jsxs)(I,{type:"button",onClick:()=>{X()},disabled:f||!Q,className:"h-8 rounded-full px-2.5 text-[10px]",children:[f?(0,s.jsx)(i.A,{className:"mr-1 h-3.5 w-3.5 animate-spin"}):null,"Save changes"]})]})]})})})}var eS=a(1880),eA=a(4816),eI=a(5027),eT=a(7618),eM=a(7882),eO=a(8755);let eR=(0,C.F)("text-xs font-medium uppercase tracking-[0.18em] text-slate-400"),e$=g.forwardRef(({className:e,...t},a)=>(0,s.jsx)(eO.b,{ref:a,className:(0,S.cn)(eR(),e),...t}));function eE(e){return Array.from(new Set(e.map(e=>e.trim()).filter(Boolean).filter(Boolean)))}function eD(e,t){return e.channelRegistry.channels.filter(e=>e.workspaces.some(e=>e.workspaceId===t)).sort((e,t)=>e.type!==t.type?e.type.localeCompare(t.type):e.name.localeCompare(t.name))}function e_(e,t){return{...e,channelRegistry:t}}async function eP(e){let t=eE(e.currentChannelIds),a=eE(e.nextChannelIds),s=a.filter(e=>!t.includes(e)),r=t.filter(e=>!a.includes(e));for(let t of s){let a=await fetch(`/api/workspaces/${encodeURIComponent(e.workspaceId)}/channels`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"bind-agent",channelId:t,agentId:e.agentId,workspacePath:e.workspacePath})}),s=await a.json();if(!a.ok||s.error)throw Error(s.error||"OpenClaw could not bind the channel.");s.registry&&e.onRegistryChange&&e.onRegistryChange(e=>e_(e,s.registry))}for(let t of r){let a=await fetch(`/api/workspaces/${encodeURIComponent(e.workspaceId)}/channels`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"unbind-agent",channelId:t,agentId:e.agentId})}),s=await a.json();if(!a.ok||s.error)throw Error(s.error||"OpenClaw could not unbind the channel.");s.registry&&e.onRegistryChange&&e.onRegistryChange(e=>e_(e,s.registry))}}function eL({snapshot:e,workspaceId:t,channelIds:a,agentId:r,isSaving:n,onChange:l}){let o=eD(e,t),d=new Set(a);return 0===o.length?(0,s.jsx)("div",{className:"rounded-[20px] border border-white/10 bg-white/[0.03] p-4",children:(0,s.jsx)("div",{className:"flex items-start justify-between gap-3",children:(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium text-white",children:"Channel participation"}),(0,s.jsx)("p",{className:"mt-1 text-xs leading-5 text-slate-400",children:"Add Telegram channels from the workspace screen first. Primary agents speak publicly; selected agents assist internally."})]})})}):(0,s.jsxs)("div",{className:"rounded-[20px] border border-white/10 bg-white/[0.03] p-4",children:[(0,s.jsx)("div",{className:"flex items-start justify-between gap-3",children:(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium text-white",children:"Channel participation"}),(0,s.jsx)("p",{className:"mt-1 text-xs leading-5 text-slate-400",children:"Primary agents speak on Telegram. Selected channels let this agent assist the primary internally."})]})}),n?(0,s.jsxs)("div",{className:"mt-3 inline-flex items-center gap-2 rounded-full border border-cyan-300/20 bg-cyan-400/[0.08] px-3 py-1.5 text-[11px] text-cyan-50",children:[(0,s.jsx)(i.A,{className:"h-3.5 w-3.5 animate-spin"}),(0,s.jsx)("span",{children:"Applying channel changes..."})]}):null,(0,s.jsx)("div",{className:"mt-3 space-y-2",children:o.map(i=>{var o;let c=d.has(i.id),p=!!(r&&i.primaryAgentId===r),m=(o=i.primaryAgentId)?(0,eb.CK)(e.agents.find(e=>e.id===o)??{name:o}):null,u=i.workspaces.find(e=>e.workspaceId===t)??null,h=u?.agentIds.length??0;return(0,s.jsxs)("div",{className:(0,S.cn)("flex items-center justify-between gap-3 rounded-2xl border px-3 py-2.5",c?"border-cyan-300/40 bg-cyan-400/[0.08]":"border-white/8 bg-white/[0.02]"),children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("p",{className:"truncate text-sm font-medium text-white",children:i.name}),(0,s.jsx)(k.E,{variant:"muted",className:"h-5 rounded-full px-2 text-[10px]",children:i.type}),p?(0,s.jsx)(k.E,{className:"h-5 rounded-full px-2 text-[10px]",children:"Primary voice"}):c?(0,s.jsx)(k.E,{className:"h-5 rounded-full px-2 text-[10px]",children:"Assistant"}):null,h>1?(0,s.jsx)(k.E,{variant:"muted",className:"h-5 rounded-full px-2 text-[10px]",children:"Team"}):null]}),(0,s.jsxs)("p",{className:"mt-1 truncate text-[11px] text-slate-400",children:[i.id,m?` \xb7 primary ${m}`:""]})]}),(0,s.jsx)(I,{type:"button",variant:c?"secondary":"default",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",disabled:!!n||c&&p,onClick:()=>l(d.has(i.id)?a.filter(e=>e!==i.id):[...a,i.id]),children:c?p?"Primary":"Remove":"Assist"})]},i.id)})})]})}e$.displayName=eO.b.displayName;let eU=[{value:"15m",label:"15 min"},{value:"30m",label:"30 min"},{value:"60m",label:"1 hour"},{value:"240m",label:"4 hours"}];function eF(e){return"monitoring"===e?{enabled:!0,every:"30m"}:{enabled:!1,every:"30m"}}function ez(e,t){let a=eF(e),s="string"==typeof t?.every&&t.every.trim()&&"disabled"!==t.every?t.every.trim():a.every;return"boolean"==typeof t?.enabled?{enabled:t.enabled,every:s}:t?.every==="disabled"?{enabled:!1,every:s}:a}function eW(e,t,a){let s=eF(t);return e.enabled!==s.enabled||e.every!==s.every?e:eF(a)}function eB({snapshot:e,defaultWorkspaceId:t,onRefresh:a,onSnapshotChange:r,onAgentCreated:n,trigger:i}){var l,o;let d,c,[p,m]=(0,g.useState)(!1),[u,h]=(0,g.useState)(!1),[x,b]=(0,g.useState)("basics"),[f,w]=(0,g.useState)(!1),[y,v]=(0,g.useState)(!1),[j,k]=(0,g.useState)(()=>eJ(t??e.workspaces[0]?.id??"")),N=e.workspaces.find(e=>e.id===j.workspaceId)??e.workspaces[0]??null,C=(l=N?.slug,o=j.name||(0,eg.Cf)(j.policy.preset).defaultName,d=eH(l??""),c=eH(o)||"agent",d?`${d}-${c}`:c),A=eH(j.id),M=A.length>0?e.agents.find(e=>e.id===A)??null:null,D=M?e.workspaces.find(e=>e.id===M.workspaceId)?.name??M.workspacePath:null,_=!!(A&&j.workspaceId)&&!f&&null===M;(0,g.useEffect)(()=>{m(!0)},[]),(0,g.useEffect)(()=>{u||(k(eJ(t??e.workspaces[0]?.id??"")),b("basics"),v(!1))},[u,t,e.workspaces]),(0,g.useEffect)(()=>{u&&!y&&C&&k(e=>e.id===C?e:{...e,id:C})},[u,y,C]);let P=async()=>{if(!A||M)return;w(!0);let e=!1,t=null;try{let a=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...j,id:A})}),s=await a.json();if(!a.ok||s.error||!s.agentId)throw Error(s.error||"OpenClaw could not create the agent.");N&&await eP({workspaceId:j.workspaceId,workspacePath:N.path,agentId:s.agentId,currentChannelIds:[],nextChannelIds:j.channelIds,onRegistryChange:r}),t=s.agentId,h(!1),e=!0}catch(e){el.o.error("Agent creation failed.",{description:e instanceof Error?e.message:"Unknown agent error."})}finally{w(!1)}e&&t&&(a().catch(()=>{}),el.o.success("Agent created in OpenClaw.",{description:t}),n?.(t))};return p?(0,s.jsxs)(Y,{open:u,onOpenChange:h,children:[(0,s.jsx)(Q,{asChild:!0,children:i}),(0,s.jsxs)(ee,{className:"max-h-[90vh] overflow-y-auto sm:max-w-3xl",children:[(0,s.jsxs)(et,{children:[(0,s.jsx)(es,{children:"Create a new OpenClaw agent"}),(0,s.jsx)(er,{children:"This creates a real isolated agent bound to an existing workspace with a preset policy."})]}),(0,s.jsxs)(O,{value:x,onValueChange:e=>b(e),children:[(0,s.jsxs)(R,{className:"h-10 rounded-[18px] p-0.5",children:[(0,s.jsx)($,{value:"basics",className:"h-9 rounded-[15px] px-3 text-[12px]",children:"Basics"}),(0,s.jsx)($,{value:"advanced",className:"h-9 rounded-[15px] px-3 text-[12px]",children:"Advanced"})]}),(0,s.jsxs)(E,{value:"basics",className:"space-y-4",children:[(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("p",{className:"text-[11px] uppercase tracking-[0.18em] text-slate-400",children:"Agent preset"}),(0,s.jsx)("div",{className:"grid gap-3 sm:grid-cols-2",children:eg.bt.map(e=>(0,s.jsx)(eK,{label:e.label,description:e.description,active:j.policy.preset===e.value,badgeVariant:(0,eg.Cf)(e.value).badgeVariant,onClick:()=>k(t=>{var a,s;let r,n,i;return a=t,s=e.value,r=(0,eg.Cf)(a.policy.preset),n=(0,eg.Cf)(s),i=(0,eg.g0)(s),{...a,name:a.name&&a.name!==r.defaultName?a.name:n.defaultName,emoji:a.emoji&&a.emoji!==r.defaultEmoji?a.emoji:n.defaultEmoji,theme:a.theme&&a.theme!==r.defaultTheme?a.theme:n.defaultTheme,policy:i,heartbeat:eW(a.heartbeat,a.policy.preset,s)}})},e.value))})]}),(0,s.jsx)(eG,{policy:j.policy,heartbeat:j.heartbeat}),(0,s.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,s.jsxs)(eq,{label:"Agent id",htmlFor:"create-agent-id",children:[(0,s.jsx)(T,{id:"create-agent-id",value:j.id,onChange:e=>{let t=e.target.value,a=eH(t);v(!!a&&a!==C),k(e=>({...e,id:t}))},placeholder:C||"workspace-agent"}),(0,s.jsx)("p",{className:(0,S.cn)("text-[12px]",M?"text-rose-300":"text-slate-500"),children:M?`ID "${A}" is already used by ${(0,eb.CK)(M)} in ${D}.`:A&&A!==j.id.trim()?`Saved as ${A}. Suggested workspace-scoped id: ${C}.`:`Workspace-scoped id: ${C}.`})]}),(0,s.jsx)(eq,{label:"Display name",htmlFor:"create-agent-name",children:(0,s.jsx)(T,{id:"create-agent-name",value:j.name,onChange:e=>k(t=>({...t,name:e.target.value})),placeholder:(0,eg.Cf)(j.policy.preset).defaultName})})]}),(0,s.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,s.jsx)(eq,{label:"Workspace",htmlFor:"create-agent-workspace",children:(0,s.jsx)("select",{id:"create-agent-workspace",value:j.workspaceId,onChange:e=>k(t=>({...t,workspaceId:e.target.value,channelIds:[]})),className:"flex h-11 w-full rounded-2xl border border-white/10 bg-white/5 px-4 py-2 text-sm text-white outline-none",children:e.workspaces.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name},e.id))})}),(0,s.jsx)(eq,{label:"Model",htmlFor:"create-agent-model",children:(0,s.jsxs)("select",{id:"create-agent-model",value:j.modelId,onChange:e=>k(t=>({...t,modelId:e.target.value})),className:"flex h-11 w-full rounded-2xl border border-white/10 bg-white/5 px-4 py-2 text-sm text-white outline-none",children:[(0,s.jsx)("option",{value:"",children:"Use OpenClaw default"}),e.models.map(e=>(0,s.jsx)("option",{value:e.id,children:e.id},e.id))]})})]}),(0,s.jsx)("div",{className:"rounded-[18px] border border-white/10 bg-white/[0.03] p-4 text-sm leading-6 text-slate-400",children:"Routing, identity customisation, and policy overrides live in Advanced."})]}),(0,s.jsxs)(E,{value:"advanced",className:"space-y-4",children:[(0,s.jsx)(eL,{snapshot:e,workspaceId:j.workspaceId,channelIds:j.channelIds,isSaving:f,onChange:e=>k(t=>({...t,channelIds:e}))}),(0,s.jsxs)("div",{className:"rounded-[20px] border border-white/10 bg-white/[0.03] p-4",children:[(0,s.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,s.jsx)(eq,{label:"Emoji",htmlFor:"create-agent-emoji",children:(0,s.jsx)(T,{id:"create-agent-emoji",value:j.emoji,onChange:e=>k(t=>({...t,emoji:e.target.value})),placeholder:(0,eg.Cf)(j.policy.preset).defaultEmoji})}),(0,s.jsx)(eq,{label:"Theme",htmlFor:"create-agent-theme",children:(0,s.jsx)(T,{id:"create-agent-theme",value:j.theme,onChange:e=>k(t=>({...t,theme:e.target.value})),placeholder:(0,eg.Cf)(j.policy.preset).defaultTheme})})]}),(0,s.jsx)("div",{className:"mt-4",children:(0,s.jsx)(eq,{label:"Avatar URL",htmlFor:"create-agent-avatar",children:(0,s.jsx)(T,{id:"create-agent-avatar",value:j.avatar,onChange:e=>k(t=>({...t,avatar:e.target.value})),placeholder:"https://example.com/avatar.png"})})})]}),(0,s.jsxs)("div",{className:"rounded-[20px] border border-white/10 bg-white/[0.03] p-4",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium text-white",children:"Heartbeat"}),(0,s.jsx)("p",{className:"mt-1 text-xs leading-5 text-slate-400",children:"Use this only for periodic watch or triage agents. Leave it off for normal task execution."})]}),(0,s.jsx)(I,{type:"button",variant:j.heartbeat.enabled?"default":"secondary",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",onClick:()=>k(e=>({...e,heartbeat:e.heartbeat.enabled?{...e.heartbeat,enabled:!1}:{...e.heartbeat,enabled:!0,every:e.heartbeat.every||eF(e.policy.preset).every}})),children:j.heartbeat.enabled?"On":"Off"})]}),j.heartbeat.enabled?(0,s.jsx)("div",{className:"mt-3",children:(0,s.jsx)(eq,{label:"Interval",htmlFor:"create-agent-heartbeat-every",children:(0,s.jsx)("select",{id:"create-agent-heartbeat-every",value:j.heartbeat.every,onChange:e=>k(t=>({...t,heartbeat:{...t.heartbeat,every:e.target.value}})),className:"flex h-11 w-full rounded-2xl border border-white/10 bg-white/5 px-4 py-2 text-sm text-white outline-none",children:eU.map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))})})}):null]}),(0,s.jsxs)("div",{className:"rounded-[20px] border border-white/10 bg-white/[0.03] p-4",children:[(0,s.jsx)("div",{className:"flex items-start justify-between gap-3",children:(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium text-white",children:"Agent policy"}),(0,s.jsx)("p",{className:"mt-1 text-xs leading-5 text-slate-400",children:"Tune fallback, install scope, file access, and network posture."})]})}),(0,s.jsxs)("div",{className:"mt-4 grid gap-4 sm:grid-cols-2",children:[(0,s.jsx)(eV,{label:"Missing tool behavior",htmlFor:"create-agent-missing-tools",value:j.policy.missingToolBehavior,options:eg.A_,onChange:e=>k(t=>({...t,policy:{...t.policy,missingToolBehavior:e}}))}),(0,s.jsx)(eV,{label:"Install scope",htmlFor:"create-agent-install-scope",value:j.policy.installScope,options:eg.sH,onChange:e=>k(t=>({...t,policy:{...t.policy,installScope:e}}))}),(0,s.jsx)(eV,{label:"File access",htmlFor:"create-agent-file-access",value:j.policy.fileAccess,options:eg.$x,onChange:e=>k(t=>({...t,policy:{...t.policy,fileAccess:e}}))}),(0,s.jsx)(eV,{label:"Network access",htmlFor:"create-agent-network-access",value:j.policy.networkAccess,options:eg.DS,onChange:e=>k(t=>({...t,policy:{...t.policy,networkAccess:e}}))})]})]})]})]}),(0,s.jsxs)(ea,{children:[(0,s.jsx)(I,{variant:"secondary",onClick:()=>h(!1),children:"Cancel"}),(0,s.jsx)(I,{onClick:P,disabled:!_,children:f?"Creating...":"Create agent"})]})]})]}):(0,s.jsx)(s.Fragment,{children:i})}function eq({label:e,htmlFor:t,children:a}){return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(e$,{htmlFor:t,className:"text-[11px] uppercase tracking-[0.18em] text-slate-400",children:e}),a]})}function eK({label:e,description:t,active:a,badgeVariant:r,onClick:n}){return(0,s.jsx)("button",{type:"button",onClick:n,className:(0,S.cn)("rounded-[20px] border p-3 text-left transition-colors",a?"border-cyan-300/30 bg-cyan-400/10":"border-white/10 bg-white/[0.03]"),children:(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-white",children:e}),(0,s.jsx)("p",{className:"text-[11px] leading-4 text-slate-400",children:t})]}),(0,s.jsx)(k.E,{variant:r,children:a?"selected":"preset"})]})})}function eG({policy:e,heartbeat:t}){let a=(0,eg.Cf)(e.preset);return(0,s.jsxs)("div",{className:"rounded-[20px] border border-white/10 bg-slate-950/50 p-3.5",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium text-white",children:a.label}),(0,s.jsx)("p",{className:"mt-1 text-xs leading-5 text-slate-400",children:a.description})]}),(0,s.jsx)(k.E,{variant:a.badgeVariant,children:a.label})]}),(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2",children:[(0,s.jsx)(k.E,{variant:"muted",children:(0,eg.zR)(e.missingToolBehavior)}),(0,s.jsx)(k.E,{variant:"muted",children:(0,eg.UJ)(e.installScope)}),(0,s.jsx)(k.E,{variant:"muted",children:(0,eg.bQ)(e.fileAccess)}),(0,s.jsxs)(k.E,{variant:"muted",children:["Network ",(0,eg.Bw)(e.networkAccess)]}),(0,s.jsxs)(k.E,{variant:t.enabled?"success":"muted",children:["Heartbeat ",t.enabled?t.every:"off"]})]})]})}function eV({label:e,htmlFor:t,value:a,options:r,onChange:n}){return(0,s.jsx)(eq,{label:e,htmlFor:t,children:(0,s.jsx)("select",{id:t,value:a,onChange:e=>n(e.target.value),className:"flex h-11 w-full rounded-2xl border border-white/10 bg-white/5 px-4 py-2 text-sm text-white outline-none",children:r.map(e=>(0,s.jsxs)("option",{value:e.value,children:[e.label," - ",e.description]},e.value))})})}function eJ(e,t={}){let a=(0,eg.g0)(t.policy?.preset??"worker",t.policy),s=(0,eg.Cf)(a.preset),r=ez(a.preset,t.heartbeat);return{id:t.id??"",workspaceId:e,modelId:t.modelId??"",name:t.name??s.defaultName,emoji:t.emoji??s.defaultEmoji,theme:t.theme??s.defaultTheme,avatar:t.avatar??"",policy:a,heartbeat:r,channelIds:Array.from(new Set((t.channelIds??[]).filter(e=>"string"==typeof e&&!!e.trim())))}}function eH(e){return e.toLowerCase().normalize("NFKD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}let eY=g.forwardRef(({className:e,...t},a)=>(0,s.jsx)("textarea",{className:(0,S.cn)("flex min-h-[96px] w-full rounded-2xl border border-white/10 bg-white/5 px-4 py-3 text-sm text-white placeholder:text-slate-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-cyan-400/60 disabled:cursor-not-allowed disabled:opacity-50",e),ref:a,...t}));eY.displayName="Textarea";let eQ="mission-control-recent-prompts";function eZ({snapshot:e,activeWorkspaceId:t,selectedNodeId:a,composeIntent:r,isComposerActive:n,onTargetAgentChange:l,onTargetAgentSelect:o,onComposerActiveChange:d,onRefresh:c,onOpenWorkspaceCreate:p,onOpenWorkspaceChannels:m,onMissionDispatchStart:u,onMissionDispatchFailure:h,onMissionResponse:b}){let f,w,[y,v]=(0,g.useState)(""),[j,k]=(0,g.useState)(""),[N,C]=(0,g.useState)("medium"),[A,T]=(0,g.useState)(!1),[M,O]=(0,g.useState)(!1),[R,$]=(0,g.useState)(!1),[E,D]=(0,g.useState)(!1),[_,P]=(0,g.useState)(!1),[L,U]=(0,g.useState)(!1),[F,z]=(0,g.useState)(null),W=(0,g.useRef)(null),B=(0,g.useRef)(null),q=(0,g.useRef)(null),K=(0,g.useRef)(null),G=(0,g.useRef)(!1),V=(0,g.useRef)(null),J=e.workspaces.find(e=>e.id===t)??e.workspaces[0],Y=e.agents.filter(e=>!J||e.workspaceId===J.id),Q=Y.find(e=>e.id===j)??Y[0]??null,Z=Q?(0,eb.CK)(Q):null,X=Q?.id??null,ee=Y.map(e=>({label:(0,eb.CK)(e),value:e.id})),et=e3(J?.id??t??null,X),ea=!!(y.trim()&&X&&!A),es=Z?`Compose for ${Z}...`:"Compose a mission...",er=((f=[]).push({id:"workspace-create",label:"Create workspace",action:"open-workspace-create"}),w=new Set,f.filter(e=>{let t=`${e.action||"mission"}:${e.mission?.trim().toLowerCase()||e.label.toLowerCase()}`;return!w.has(t)&&(w.add(t),!0)}).slice(0,3)),en=er.length>0,ei=E&&!_&&!n&&!R&&!A&&0===y.trim().length&&null===F;(0,g.useEffect)(()=>{let s=`${t??"all"}:${a??"none"}:${Y.map(e=>e.id).join(",")}`,r=function(e,t,a){let s=e.agents.find(e=>e.id===a);if(s)return s.id;let r=e.tasks.find(e=>e.id===a);if(r?.primaryAgentId)return r.primaryAgentId;let n=e.runtimes.find(e=>e.id===a);if(n?.agentId)return n.agentId;let i=e.agents.filter(e=>t?e.workspaceId===t:e.isDefault);return i.find(e=>e.isDefault)?.id||i[0]?.id||e.agents[0]?.id}(e,t,a),n=q.current;if(n&&Y.some(e=>e.id===n)){j!==n&&k(n),q.current=null;return}B.current!==s&&(B.current=s,r&&Y.some(e=>e.id===r))?k(r):Y.some(e=>e.id===j)||k(r&&Y.some(e=>e.id===r)?r:Y[0]?.id??"")},[e,t,a,j,Y]),(0,g.useEffect)(()=>{let e=globalThis.matchMedia("(min-width: 1024px)"),t=()=>{D(e.matches),e.matches||P(!1)};return t(),e.addEventListener("change",t),()=>{e.removeEventListener("change",t)}},[]),(0,g.useEffect)(()=>{U(!0)},[]),(0,g.useEffect)(()=>{var e;(e=W.current)&&(e.style.height="0px",e.style.height=`${Math.min(e.scrollHeight,150)}px`)},[y]),(0,g.useEffect)(()=>{if(!et||void 0===globalThis.localStorage)return;if(V.current===et){V.current=null;return}let e=function(e){try{var t;let a=globalThis.localStorage.getItem(e);if(!a)return null;let s=JSON.parse(a);if("string"!=typeof s.mission)return null;return{mission:s.mission,thinking:(t=s.thinking,"off"===t||"minimal"===t||"low"===t||"medium"===t||"high"===t)?s.thinking:"medium"}}catch{return null}}(et);G.current=!0,v(e?.mission??""),C(e?.thinking??"medium"),z(null)},[et]),(0,g.useEffect)(()=>{if(et&&void 0!==globalThis.localStorage){if(G.current){G.current=!1;return}!function(e,t){try{if(!t.mission.trim()&&"medium"===t.thinking)return void globalThis.localStorage.removeItem(e);globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}(et,{mission:y,thinking:N})}},[et,y,N]),(0,g.useEffect)(()=>{l?.(X??null)},[X,l]),(0,g.useEffect)(()=>{if(!r||K.current===r.id)return;K.current=r.id;let e=r.mission.trim();if(!e)return;let a=e3(J?.id??t??null,r.agentId??X);a&&(V.current=a);let s=0===y.trim().length||y.trim()===e;z({id:r.id,mission:e,sourceKind:r.sourceKind??"copy",sourceLabel:r.sourceLabel??"selected runtime"}),s&&v(e),r.agentId&&k(r.agentId),requestAnimationFrame(()=>{W.current?.focus(),s&&W.current?.setSelectionRange(e.length,e.length)})},[r,y,t,X,J?.id]);let eo=async e=>{T(!0);let a=e.agentId||X,s=Date.now(),r=globalThis.crypto?.randomUUID?.()||`dispatch:${s}`,n=new AbortController;a&&u({requestId:r,mission:e.mission.trim(),agentId:a,workspaceId:J?.id??t??null,submittedAt:s,abortController:n});try{let i=e.mission.trim(),l=await fetch("/api/mission",{method:"POST",headers:{"Content-Type":"application/json"},signal:n.signal,body:JSON.stringify(e)}),o=await l.json();if(!l.ok||o.error)throw Error(o.error||"OpenClaw rejected the mission.");b(o,{requestId:r}),v(""),z(null),$(!1),G.current=!0,et&&void 0!==globalThis.localStorage&&globalThis.localStorage.removeItem(et),a&&function(e){let t=[e,...(function(){try{let e=globalThis.localStorage.getItem(eQ);if(!e)return[];let t=JSON.parse(e);if(!Array.isArray(t))return[];return t.filter(e=>"object"==typeof e&&null!==e&&"string"==typeof e.id&&"string"==typeof e.mission&&"string"==typeof e.agentId&&"string"==typeof e.agentName&&"number"==typeof e.submittedAt).slice(0,6)}catch{return[]}})().filter(t=>t.mission.trim()!==e.mission.trim()||t.agentId!==e.agentId||t.workspaceId!==e.workspaceId)].slice(0,6);try{globalThis.localStorage.setItem(eQ,JSON.stringify(t))}catch{}}({id:globalThis.crypto?.randomUUID?.()||`${s}`,mission:i,agentId:a,agentName:Z??"Agent",workspaceId:J?.id??t,workspaceName:J?.name??null,submittedAt:s});let d="string"==typeof o.meta?.outputDirRelative?`${o.status} via ${o.agentId} \xb7 ${o.meta.outputDirRelative}`:`${o.status} via ${o.agentId}`;"stalled"===o.status?el.o.error("Mission could not start.",{description:o.summary||d}):el.o.success("Mission queued in OpenClaw.",{description:d}),c().catch(()=>null)}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)return;h(r,e instanceof Error?e.message:"Unknown mission error."),el.o.error("Mission dispatch failed.",{description:e instanceof Error?e.message:"Unknown mission error."})}finally{T(!1)}},ed=(e,t={})=>{t.thinking&&C(t.thinking),v(a=>{var s,r;let n,i;return"replace"===t.mode?e:(s=a,r=e,n=s.trim(),i=r.trim(),n?i?`${n}
2
-
3
- ${i}`:n:i)}),requestAnimationFrame(()=>{W.current?.focus();let e=W.current?.value??"";W.current?.setSelectionRange(e.length,e.length)})};return(0,s.jsx)("div",{className:(0,S.cn)("mx-auto w-full transition-[width] duration-300",ei&&"lg:w-[360px]"),onMouseEnter:()=>{E&&P(!0)},onMouseLeave:()=>{E&&P(!1)},children:(0,s.jsx)(eM.N,{initial:!1,mode:"wait",children:ei?(0,s.jsx)(x.P.button,{type:"button",initial:{opacity:0,y:8,scale:.98},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:8,scale:.98},onFocus:()=>P(!0),onClick:()=>{P(!0),requestAnimationFrame(()=>{W.current?.focus()})},className:"w-full overflow-hidden rounded-full border border-white/[0.08] bg-[linear-gradient(180deg,rgba(10,16,26,0.96),rgba(6,10,18,0.94))] p-2 text-left shadow-[0_24px_72px_rgba(0,0,0,0.22)] isolate",children:(0,s.jsxs)("div",{className:"flex items-center gap-2 rounded-full border border-white/[0.07] bg-[linear-gradient(180deg,rgba(20,28,43,0.9),rgba(11,17,28,0.88))] px-3 py-2 shadow-[inset_0_1px_0_rgba(255,255,255,0.04)]",children:[(0,s.jsx)("span",{className:"inline-flex h-7 items-center rounded-full border border-white/[0.08] bg-white/[0.04] px-2.5 text-[11px] text-slate-300",children:Z||"No agent"}),(0,s.jsx)("p",{className:"min-w-0 flex-1 truncate text-[13px] text-[#f6eee5]/58",children:es}),(0,s.jsxs)("span",{className:"inline-flex h-8 items-center rounded-full bg-white px-3 text-[12px] font-medium text-slate-950",children:[(0,s.jsx)(eS.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Create task"]})]})},"collapsed"):(0,s.jsxs)(x.P.div,{initial:{opacity:0,y:8,scale:.985},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:8,scale:.985},className:"overflow-hidden rounded-[26px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(10,16,26,0.96),rgba(6,10,18,0.94))] p-2.5 shadow-[0_24px_72px_rgba(0,0,0,0.26)] isolate",children:[(0,s.jsx)(eM.N,{initial:!1,children:F?(0,s.jsxs)(x.P.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},className:"mb-2 flex flex-wrap items-center gap-2 px-1 text-[12px] text-slate-400",children:[(0,s.jsxs)("span",{className:"truncate",children:["From ",F.sourceLabel]}),(0,s.jsx)("button",{type:"button",className:"text-slate-200 transition-colors hover:text-white",onClick:()=>ed(F.mission,{mode:"replace"}),children:"Replace"}),(0,s.jsx)("button",{type:"button",className:"text-slate-200 transition-colors hover:text-white",onClick:()=>ed(F.mission),children:"Append"}),(0,s.jsx)("button",{type:"button",className:"inline-flex h-6 w-6 items-center justify-center rounded-full text-slate-400 transition-colors hover:bg-white/[0.06] hover:text-white",onClick:()=>z(null),"aria-label":"Dismiss runtime suggestion",children:(0,s.jsx)(H.A,{className:"h-3.5 w-3.5"})})]}):null}),(0,s.jsxs)("div",{className:(0,S.cn)("rounded-[22px] border border-white/[0.07] bg-[linear-gradient(180deg,rgba(20,28,43,0.92),rgba(10,16,26,0.9))] shadow-[inset_0_1px_0_rgba(255,255,255,0.04)] transition-all duration-200",n&&"border-white/[0.14] bg-[linear-gradient(180deg,rgba(24,34,50,0.94),rgba(12,18,30,0.92))] shadow-[inset_0_1px_0_rgba(255,255,255,0.06)]"),onFocusCapture:()=>d?.(!0),onBlurCapture:e=>{let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||d?.(!1)},children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-2.5 pb-1 pt-2.5",children:[Q?(0,s.jsx)(eX,{value:j,options:ee,onChange:e=>{k(e),o?.(e)}}):(0,s.jsx)(e5,{children:"No agent"}),(0,s.jsxs)("div",{className:"ml-auto flex items-center gap-1",children:[(0,s.jsx)(e1,{label:"Refresh mission control",onClick:async()=>{O(!0),await c(),O(!1)},children:M?(0,s.jsx)(i.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(eA.A,{className:"h-3.5 w-3.5"})}),(0,s.jsx)(e1,{label:"Create workspace",onClick:p,children:(0,s.jsx)(eI.A,{className:"h-3.5 w-3.5"})}),(0,s.jsx)(e1,{label:"Composer settings",onClick:()=>$(e=>!e),active:R||"medium"!==N,children:(0,s.jsxs)("span",{className:"relative inline-flex",children:[(0,s.jsx)(eT.A,{className:"h-3.5 w-3.5"}),"medium"!==N?(0,s.jsx)("span",{className:"absolute -right-1 -top-1 h-1.5 w-1.5 rounded-full bg-white/80"}):null]})})]})]}),(0,s.jsx)("div",{className:"px-2.5 pt-0.5",children:(0,s.jsx)(eY,{ref:W,value:y,onChange:e=>v(e.target.value),onKeyDown:async e=>{(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&(e.preventDefault(),ea&&X&&await eo({mission:y,agentId:X,workspaceId:t??void 0,thinking:N}))},placeholder:es,className:"min-h-[50px] max-h-[150px] resize-none overflow-y-auto border-0 bg-transparent px-0 py-0.5 text-[15px] leading-[1.6] text-white placeholder:text-[#f6eee5]/60 shadow-none focus-visible:ring-0 focus-visible:ring-offset-0"})}),(0,s.jsxs)("div",{className:"flex items-end justify-between gap-2.5 px-2.5 pb-2.5 pt-1.5",children:[(0,s.jsx)(eM.N,{initial:!1,children:en?(0,s.jsxs)(x.P.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:4},className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[er.map(e=>(0,s.jsx)(e2,{label:e.label,onClick:()=>{"open-workspace-create"===e.action?p():e.mission&&ed(e.mission,{thinking:e.thinking})}},e.id)),J?(0,s.jsx)(eB,{snapshot:e,defaultWorkspaceId:J.id,onRefresh:c,onAgentCreated:e=>{q.current=e,k(e)},trigger:(0,s.jsx)("button",{type:"button",className:"inline-flex h-8 items-center rounded-full border border-white/[0.08] bg-white/[0.04] px-3 text-[12px] text-slate-300 transition-all hover:bg-white/[0.08] hover:text-white",children:"+ Create Agent"})}):null,L&&J?(0,s.jsx)("button",{type:"button",onClick:m,className:"inline-flex h-8 items-center rounded-full border border-cyan-300/18 bg-cyan-400/[0.1] px-3 text-[12px] text-cyan-50 transition-all hover:border-cyan-300/28 hover:bg-cyan-400/[0.14] hover:text-white",children:"Add Channel"}):null]}):(0,s.jsx)("div",{})}),(0,s.jsxs)(I,{className:"h-9 rounded-full bg-white px-3.5 text-slate-950 shadow-none hover:bg-white/92",disabled:!ea,onClick:async()=>{X&&await eo({mission:y,agentId:X,workspaceId:t??void 0,thinking:N})},children:[A?(0,s.jsx)(i.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(eS.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Create task"]})]})]}),(0,s.jsx)(eM.N,{initial:!1,children:R?(0,s.jsx)(x.P.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},exit:{opacity:0,y:-6},className:"mt-2 flex justify-end",children:(0,s.jsxs)("div",{className:"w-full max-w-[232px] rounded-[20px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(14,20,31,0.96),rgba(10,15,24,0.94))] p-3 shadow-[0_16px_32px_rgba(0,0,0,0.22)]",children:[(0,s.jsx)("p",{className:"text-[11px] text-slate-300",children:"Thinking"}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)(e0,{ariaLabel:"Select thinking level",value:N,options:[{label:"off",value:"off"},{label:"minimal",value:"minimal"},{label:"low",value:"low"},{label:"medium",value:"medium"},{label:"high",value:"high"}],onChange:e=>C(e)})}),(0,s.jsx)("button",{type:"button",className:"mt-3 text-[12px] text-slate-400 transition-colors hover:text-white",onClick:()=>{v(""),C("medium"),z(null),G.current=!0,et&&void 0!==globalThis.localStorage&&globalThis.localStorage.removeItem(et)},children:"Clear draft"})]})}):null})]},"expanded")})})}function eX({value:e,options:t,onChange:a}){let r=t.find(t=>t.value===e)??t[0],n=t.length>1;return(0,s.jsxs)("div",{className:"relative inline-flex items-center rounded-full border border-white/[0.08] bg-white/[0.04] text-slate-100",children:[n?(0,s.jsx)("select",{"aria-label":"Select mission agent",value:r?.value??"",onChange:e=>a(e.target.value),className:"h-8 appearance-none bg-transparent pl-3 pr-8 text-[12px] outline-none",children:t.map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))}):(0,s.jsx)("span",{className:"px-3 text-[12px]",children:r?.label||"No agent"}),n?(0,s.jsx)(u.A,{className:"pointer-events-none absolute right-3 h-3.5 w-3.5 text-slate-400"}):null]})}function e0({ariaLabel:e,value:t,options:a,onChange:r}){let n=a.find(e=>e.value===t)??a[0];return(0,s.jsxs)("div",{className:"relative inline-flex w-full items-center rounded-full border border-white/[0.08] bg-white/[0.04] text-slate-100",children:[(0,s.jsx)("select",{"aria-label":e,value:n?.value??"",onChange:e=>r(e.target.value),className:"h-9 w-full appearance-none bg-transparent pl-3 pr-9 text-[12px] outline-none",children:a.map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))}),(0,s.jsx)(u.A,{className:"pointer-events-none absolute right-3 h-3.5 w-3.5 text-slate-400"})]})}function e1({label:e,active:t=!1,onClick:a,children:r}){return(0,s.jsx)("button",{type:"button","aria-label":e,title:e,onClick:a,className:(0,S.cn)("inline-flex h-8 w-8 items-center justify-center rounded-full border border-transparent text-slate-400 transition-all hover:border-white/[0.08] hover:bg-white/[0.06] hover:text-white",t&&"border-white/[0.08] bg-white/[0.06] text-white"),children:r})}function e2({label:e,onClick:t}){return(0,s.jsx)("button",{type:"button",onClick:t,className:"inline-flex h-8 items-center rounded-full border border-white/[0.08] bg-white/[0.04] px-3 text-[12px] text-slate-300 transition-all hover:bg-white/[0.08] hover:text-white",children:e})}function e5({children:e}){return(0,s.jsx)("div",{className:"inline-flex h-8 items-center rounded-full border border-white/[0.08] bg-white/[0.04] px-3 text-[12px] text-slate-300",children:e})}function e3(e,t){return e||t?`mission-control-composer-draft:${e??"global"}:${t??"unassigned"}`:null}var e4=a(9568),e8=a(2385),e6=a(6161),e9=a(910),e7=a(6765),te=a(159),tt=a(9582);let ta="mission-control-action";function ts(e){return`mission-control-agent-chat:v1:${e}`}function tr(e,t){try{globalThis.localStorage?.setItem(ts(e),JSON.stringify(t.slice(-60)))}catch{}}function tn(e){return/^\s+$/.test(e)?14:/[.!?]$/.test(e)?140:/[,:;]$/.test(e)?80:Math.min(80,26+4*e.length)}function ti({surfaceTheme:e}){return(0,s.jsx)("span",{className:"inline-flex items-center gap-[3px] align-middle",children:[0,1,2].map(t=>(0,s.jsx)(x.P.span,{animate:{opacity:[.35,1,.35],y:[0,-1,0]},transition:{duration:1.1,repeat:1/0,delay:.14*t,ease:"easeInOut"},className:(0,S.cn)("h-1.5 w-1.5 rounded-full","light"===e?"bg-[#8f7263]":"bg-cyan-300")},t))})}function tl({agent:e,snapshot:t,surfaceTheme:a,onRefresh:r,onSnapshotChange:n}){let[l,o]=(0,g.useState)(""),[d,c]=(0,g.useState)(!1),[p,m]=(0,g.useState)(!1),[u,h]=(0,g.useState)([]),[b,f]=(0,g.useState)(null),[w,y]=(0,g.useState)(""),v=(0,g.useRef)(null),j=(0,g.useRef)(null),k=(0,g.useRef)(null),N=(0,eb.CK)(e),C=(0,g.useMemo)(()=>(function(e,t){let a=e.agents.filter(e=>e.workspaceId===t.workspaceId).sort((e,a)=>e.id===t.id&&a.id!==t.id?-1:a.id===t.id&&e.id!==t.id?1:e.isDefault!==a.isDefault?e.isDefault?-1:1:(0,eb.CK)(e).localeCompare((0,eb.CK)(a)));if(0===a.length)return null;let s=["Workspace team roster:","Use this roster, not `agents_list`, when the operator asks who else is in the workspace. That tool may be restricted to your own scope.","If prior chat messages in this drawer claimed you were the only agent, ignore that older claim if it conflicts with this roster."];for(let e of a){let a=[e.id===t.id?"you":null,e.isDefault?"primary":null,(0,eg._P)(e.policy.preset)].filter(Boolean);s.push(`- ${(0,eb.CK)(e)} (\`${e.id}\`) \xb7 ${a.join(" \xb7 ")}.`)}return s.join("\n")})(t,e),[t,e]),A=()=>{null!==k.current&&(globalThis.clearTimeout(k.current),k.current=null)};(0,g.useEffect)(()=>(A(),h(function(e){try{let t=globalThis.localStorage?.getItem(ts(e));if(!t)return[];let a=JSON.parse(t);if(!Array.isArray(a))return[];return a.filter(e=>"object"==typeof e&&null!==e&&("user"===e.role||"assistant"===e.role||"system"===e.role)&&"string"==typeof e.id&&"string"==typeof e.text&&"number"==typeof e.createdAt).slice(-60)}catch{return[]}}(e.id)),o(""),c(!1),m(!1),f(null),y(""),requestAnimationFrame(()=>j.current?.focus()),()=>A()),[e.id]),(0,g.useEffect)(()=>{v.current&&(v.current.scrollTop=v.current.scrollHeight)},[u.length,e.id,p,w,b]);let T=u.some(e=>"user"===e.role&&"sending"===e.status),M=p||T,O=!!l.trim()&&!d&&!b&&!T,R=(0,g.useMemo)(()=>u.length>0?u:[{id:"system:empty",role:"system",text:"Start a direct chat with this agent. Messages stay in this drawer and are stored locally in your browser.",createdAt:Date.now()}],[u]),$=async()=>{var t;let a,s,i,p,x=l.trim();if(!x||d||b||T)return;c(!0),m(!0);let g=Date.now(),w={id:globalThis.crypto?.randomUUID?.()||`user:${g}`,role:"user",text:x,createdAt:g,status:"sending"},v=[...u,w].slice(-60);h(v),tr(e.id,v),o("");let S={message:(t={agentName:N,agentDir:e.agentDir,workspacePath:e.workspacePath,workspaceTeamPrompt:C},a=v.filter(e=>"user"===e.role||"assistant"===e.role).slice(-8).map(e=>`${"user"===e.role?"Operator":"Agent"}: ${e.text.trim()}`).join("\n"),s=x.trim(),i=["You are chatting directly with the operator inside Mission Control. Reply conversationally, be concise, and ask a clarifying question when needed. Do not create tasks or mention task cards."],t.agentDir&&i.push(`Your agent-specific identity file is ${t.agentDir}/IDENTITY.md. If the operator renames you or asks about your identity file, use that path.`),t.workspacePath&&(i.push(`Do not treat ${t.workspacePath}/IDENTITY.md as your personal identity file unless the operator explicitly asks for a workspace-wide identity change.`),i.push(`Do not update ${t.workspacePath}/MEMORY.md for a self-rename unless the operator explicitly asks to store that as workspace memory.`)),i.push(`Mission Control applies self-renames through a structured action, not by having you edit files yourself. If the operator asks to rename you or set your display name, reply normally and append exactly one action block on its own line using this format: <${ta}>{"type":"rename_agent","name":"New Name"}</${ta}>.`),i.push("Only emit that action block for an actual rename request. Do not emit it for questions about your current name, hypothetical questions about rename mechanics, or identity discussions that do not request a change."),t.agentDir&&i.push(`If the operator asks which path would be updated, explain that Mission Control applies the rename centrally and then syncs ${t.agentDir}/IDENTITY.md.`),t.workspaceTeamPrompt&&i.push(t.workspaceTeamPrompt),i.push(`Your current display name in Mission Control is ${t.agentName}.`),p=`${i.join("\n")}
4
- `,a?`${p}
5
- Conversation so far:
6
- ${a}
7
-
8
- Operator: ${s}`:`${p}
9
- Operator: ${s}`),rawMessage:x,thinking:"low"};try{let t=await fetch(`/api/agents/${encodeURIComponent(e.id)}/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(S)}),a=await t.json();if(!t.ok||a.error)throw Error(a.error||"OpenClaw rejected the message.");let s={id:globalThis.crypto?.randomUUID?.()||`assistant:${Date.now()}`,role:"assistant",text:a.payloads.map(e=>e.text?.trim()).filter(Boolean).join("\n\n")||a.summary||"No response text was returned.",createdAt:Date.now(),status:"sent",runId:a.runId},i=v.map(e=>e.id===w.id?{...e,status:"sent"}:e).concat(s).slice(-60),l=function(e){let t=e?.missionControlAction;if(!t||"object"!=typeof t||"rename_agent"!==t.type||!0!==t.applied||"string"!=typeof t.name)return null;let a=t.name.trim();return a.length>0?a:null}(a.meta);l&&n&&n(t=>{var a,s,r;return a=t,s=e.id,r=l,{...a,agents:a.agents.map(e=>e.id===s?{...e,name:r,identityName:r}:e),tasks:a.tasks.map(e=>e.primaryAgentId===s?{...e,primaryAgentName:r}:e)}}),h(i),tr(e.id,i),c(!1),m(!1),((e,t)=>{A();let a=t.trim().match(/\S+|\s+/g)??[];if(0===a.length){f(null),y("");return}let s=a[0];if(!s){f(null),y("");return}let r=1;f(e),y(s);let n=()=>{if(r>=a.length){k.current=globalThis.setTimeout(()=>{f(null),y(""),k.current=null},220);return}let e=r+1;y(a.slice(0,e).join(""));let t=tn(a[r]??"");r=e,k.current=globalThis.setTimeout(n,t)};k.current=globalThis.setTimeout(n,tn(s))})(s.id,s.text),r?.().catch(()=>null)}catch(s){let t=s instanceof Error?s.message:"Unknown send error.";el.o.error("Chat message failed.",{description:t});let a=v.map(e=>e.id===w.id?{...e,status:"error"}:e).slice(-60);h(a),tr(e.id,a),m(!1)}finally{c(!1),requestAnimationFrame(()=>j.current?.focus())}};return(0,s.jsxs)("div",{className:(0,S.cn)("flex h-full min-h-0 flex-col overflow-hidden","light"===a?"text-[#4a382c]":"text-slate-200"),children:[(0,s.jsxs)("div",{ref:v,className:(0,S.cn)("mission-scroll min-h-0 flex-1 overflow-y-auto overscroll-contain pr-1","light"===a?"text-[#4a382c]":"text-slate-200"),children:[(0,s.jsx)("div",{className:"space-y-2.5",children:R.map(e=>{let t="user"===e.role,r="system"===e.role,n="assistant"===e.role&&e.id===b;return(0,s.jsx)("div",{className:(0,S.cn)("flex",t?"justify-end":"justify-start"),children:(0,s.jsxs)("div",{className:(0,S.cn)("min-w-0 max-w-[92%] rounded-[18px] border px-3 py-2 text-[13px] leading-5 shadow-[0_14px_34px_rgba(0,0,0,0.14)]",r?"light"===a?"border-[#e3d4c8] bg-[#fffaf6] text-[#6c5647]":"border-white/[0.08] bg-white/[0.03] text-slate-400":t?"light"===a?"border-[#e3d4c8] bg-[#fff3f6] text-[#4a382c]":"border-white/[0.08] bg-[linear-gradient(180deg,rgba(255,255,255,0.07),rgba(255,255,255,0.03))] text-slate-100":"light"===a?"border-[#e3d4c8] bg-[#fffaf6] text-[#4a382c]":"border-cyan-300/12 bg-[linear-gradient(180deg,rgba(34,211,238,0.10),rgba(59,130,246,0.06))] text-slate-100"),children:[(0,s.jsx)("p",{className:"whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:"assistant"===e.role&&e.id===b?w:e.text}),n?(0,s.jsx)(x.P.span,{"aria-hidden":"true",animate:{opacity:[.2,1,.2]},transition:{duration:.9,repeat:1/0,ease:"easeInOut"},className:"ml-0.5 inline-block h-[1em] w-[1px] translate-y-[2px] bg-current"}):null,"sending"===e.status?(0,s.jsx)("p",{className:(0,S.cn)("mt-1.5 text-[10px] uppercase tracking-[0.18em]","light"===a?"text-[#8b7262]":"text-slate-500"),children:"Sending…"}):"error"===e.status?(0,s.jsx)("p",{className:"mt-1.5 text-[10px] uppercase tracking-[0.18em] text-rose-300",children:"Failed to send"}):null]})},e.id)})}),(0,s.jsx)(eM.N,{initial:!1,children:M?(0,s.jsx)(x.P.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:4},className:"mt-2 flex justify-start",children:(0,s.jsxs)("div",{className:(0,S.cn)("inline-flex items-center gap-2 rounded-[18px] border px-3 py-2 text-[12px] leading-5 shadow-[0_14px_34px_rgba(0,0,0,0.14)]","light"===a?"border-[#e3d4c8] bg-[#fffaf6] text-[#4a382c]":"border-cyan-300/12 bg-[linear-gradient(180deg,rgba(34,211,238,0.10),rgba(59,130,246,0.06))] text-slate-100"),children:[(0,s.jsx)("span",{className:"font-medium",children:N}),(0,s.jsx)("span",{className:(0,S.cn)("text-[10px] uppercase tracking-[0.18em]","light"===a?"text-[#8b7262]":"text-slate-400"),children:"typing"}),(0,s.jsx)(ti,{surfaceTheme:a})]})}):null})]}),(0,s.jsxs)("div",{className:(0,S.cn)("mt-2 shrink-0 rounded-[18px] border p-3","light"===a?"border-[#e3d4c8] bg-[#fffaf6]":"border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.86),rgba(8,13,24,0.82))]"),onPointerDown:e=>{let t=e.target;!t||t.closest("textarea")||t.closest("button")||j.current?.focus()},children:[(0,s.jsx)(eY,{ref:j,value:l,onChange:e=>o(e.target.value),onKeyDown:async e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),await $())},placeholder:`Message to ${N}...`,className:(0,S.cn)("min-h-[60px] cursor-text resize-none border-0 bg-transparent px-3.5 py-2.5 text-[13px] leading-[1.5] shadow-none focus-visible:ring-0 focus-visible:ring-offset-0","light"===a?"text-[#3f2f24] placeholder:text-[#8f7664]":"text-white placeholder:text-slate-500")}),(0,s.jsx)("div",{className:"mt-1.5 flex items-center justify-end gap-1.5",children:(0,s.jsxs)(I,{disabled:!O,className:(0,S.cn)("h-8 rounded-full px-3 shadow-none","light"===a?"bg-[#4a382c] text-[#fffaf6] hover:bg-[#3f2f24]":"bg-white text-slate-950 hover:bg-white/92"),onClick:$,children:[d?(0,s.jsx)(i.A,{className:"mr-[5px] h-[13px] w-[13px] animate-spin"}):(0,s.jsx)(eS.A,{className:"mr-[5px] h-[13px] w-[13px]"}),"Send"]})})]})]})}var to=a(8790),td=a(473);function tc({label:e,side:t,surfaceTheme:a,panelCollapsed:r,children:n}){return(0,s.jsx)(td.Bc,{delayDuration:120,children:(0,s.jsxs)(td.m_,{children:[(0,s.jsx)(td.k$,{asChild:!0,children:n}),(0,s.jsx)(td.ZI,{side:t,align:"center",sideOffset:10,className:(0,S.cn)("rounded-[10px] px-2.5 py-1.5 text-[10px] font-medium leading-none tracking-[0.12em] whitespace-nowrap shadow-[0_16px_40px_rgba(0,0,0,0.32)]","light"===a?r?"border border-slate-200/80 bg-white/96 text-slate-900 shadow-[0_16px_40px_rgba(15,23,42,0.18)]":"border border-white/10 bg-slate-950/94 text-white shadow-[0_16px_40px_rgba(0,0,0,0.36)]":"border border-white/10 bg-slate-950/92 text-slate-100"),children:e})]})})}function tp({className:e,...t}){return(0,s.jsx)(k.E,{...t,className:(0,S.cn)("!h-4 !px-1.5 !py-0 !text-[8px] !leading-none !tracking-[0.1em] !whitespace-nowrap",e)})}function tm(e){return(0,s.jsx)(tu,{...e},e.selectedNodeId??"overview")}function tu({snapshot:e,surfaceTheme:t,selectedNodeId:a,agentDetailFocus:r,lastMission:n,onRefresh:i,onSnapshotChange:l,onConfigureAgentCapabilities:o,onAbortTask:d,collapsed:c,onToggleCollapsed:p,activeTab:m,onActiveTabChange:u}){let h=(0,eb.hv)(e.generatedAt),f=e.workspaces.find(e=>e.id===a),w=e.agents.find(e=>e.id===a),y=e.tasks.find(e=>e.id===a),v=e.runtimes.find(e=>e.id===a),j=e.models.find(e=>e.id===a),k=!!y?.metadata.optimistic,N=f||w||y||v||j||null,C=v?.id??null,A=y?.id??null,[I,T]=(0,g.useState)(null),[M,O]=(0,g.useState)(null),[R,$]=(0,g.useState)(null),[E,D]=(0,g.useState)(null),_=(0,g.useMemo)(()=>{var e;let t;return k&&y?{task:e=y,runs:[],outputs:[],liveFeed:Array.isArray(t=e.metadata.optimisticEvents)?t.filter(tj).sort((e,t)=>Date.parse(e.timestamp)-Date.parse(t.timestamp)):[],createdFiles:[],warnings:"stalled"===e.status||tk(e)?[e.subtitle]:[],integrity:tv(e)}:null},[k,y]),P=I&&I.runtimeId===C?I:null,L=M?.runtimeId===C?M.message:null,U=R&&R.task.id===A?R:null,F=E?.taskId===A?E.message:null,z=_??U,W=!!A&&!k&&!z&&!F,B=!!C&&!P&&!L,q=!!w,K=!!(v||y),G=!!(v||y),V=("chat"!==m||q)&&("output"!==m||K)&&("files"!==m||G)?m:"overview",J="chat"===V&&!!w,H=y?"Feed":"Output",Y=f?.name||(w?(0,eb.CK)(w):null)||(y?(0,eb.$m)(y.title||y.mission||"Task",48)||"Task":null)||(v?(0,eb.$m)(v.title||"Run",48)||"Run":null)||j?.name||"Gateway overview",Q=f?"workspace":w?"agent":y?"task":v?"run":j?"model":"selection",Z=(0,g.useMemo)(()=>[{id:"overview",label:"Overview",icon:e4.A,enabled:!0},{id:"chat",label:"Chat",icon:e8.A,enabled:q},{id:"output",label:H,icon:b.A,enabled:K},{id:"files",label:"Files",icon:e6.A,enabled:G},{id:"raw",label:"Raw",icon:e9.A,enabled:!0}],[H,q,G,K]);return(0,g.useEffect)(()=>{if(!C)return;let e=new AbortController;return fetch(`/api/runtimes/${encodeURIComponent(C)}`,{signal:e.signal}).then(async e=>{let t=await e.json();if(!e.ok)throw Error(t.error||"Unable to load runtime output.");T(t),O(null)}).catch(t=>{e.signal.aborted||(T(null),O({runtimeId:C,message:t instanceof Error?t.message:"Unable to load runtime output."}))}),()=>e.abort()},[C]),(0,g.useEffect)(()=>{if(!A||k)return;let e=new EventSource(`/api/tasks/${encodeURIComponent(A)}/stream`),t=e=>{try{let t=JSON.parse(e.data);if("task"!==t.type)return;$(t.detail),D(null)}catch(e){D({taskId:A,message:e instanceof Error?e.message:"Unable to parse task feed."})}},a=e=>{try{let t=JSON.parse(e.data);"error"===t.type&&D({taskId:A,message:t.error})}catch{D({taskId:A,message:"Unable to load task detail."})}};return e.addEventListener("task",t),e.addEventListener("task-error",a),e.onerror=()=>{D(e=>e?.taskId===A?e:{taskId:A,message:"Task feed disconnected. Reconnecting…"})},()=>{e.removeEventListener("task",t),e.removeEventListener("task-error",a),e.close()}},[A,k]),(0,s.jsxs)("div",{className:"panel-surface panel-glow flex h-full flex-row-reverse overflow-hidden rounded-none border border-r-0 border-white/[0.08] bg-[#04070e]/88 shadow-[0_28px_90px_rgba(0,0,0,0.42)] backdrop-blur-2xl",children:[(0,s.jsxs)("div",{className:(0,S.cn)("flex h-full shrink-0 flex-col items-center bg-[linear-gradient(180deg,rgba(7,10,18,0.98),rgba(3,6,12,0.98))] px-1.5 py-2",c?"w-full":"w-[60px] border-l border-white/[0.08]"),children:[(0,s.jsx)(tc,{label:"Inspector",side:"left",surfaceTheme:t,panelCollapsed:c,children:(0,s.jsx)("button",{type:"button","aria-label":c?"Expand inspector":"Collapse inspector",onClick:p,className:"flex h-9 w-9 items-center justify-center rounded-[8px] border border-cyan-300/18 bg-cyan-400/[0.1] shadow-[0_8px_18px_rgba(34,211,238,0.14)] transition-all hover:border-cyan-200/24 hover:bg-cyan-400/[0.14]",children:(0,s.jsx)(b.A,{className:"h-3.5 w-3.5 text-cyan-200"})})}),(0,s.jsx)("div",{className:"mt-3.5 flex flex-1 flex-col items-center gap-1",children:Z.map(e=>(0,s.jsx)(tI,{icon:e.icon,label:e.label,active:V===e.id,surfaceTheme:t,panelCollapsed:c,tooltipSide:"left",disabled:!e.enabled,onClick:()=>{e.enabled&&(u(e.id),c&&p())}},e.id))}),(0,s.jsxs)("div",{className:"mt-1.5 flex flex-col items-center gap-0.5",children:[(0,s.jsx)(tp,{variant:"muted",className:"h-4 min-w-[28px] rounded-full px-1 py-0 text-[8px] leading-none tracking-[0.12em]",children:N?"live":"idle"}),c?(0,s.jsx)("p",{className:"max-w-[44px] truncate text-center text-[8px] uppercase tracking-[0.14em] text-slate-500",children:Q}):null]})]}),c?null:(0,s.jsx)("div",{className:"min-w-0 flex-1 bg-[linear-gradient(180deg,rgba(6,10,18,0.96),rgba(3,6,14,0.98))]",children:(0,s.jsxs)("div",{className:(0,S.cn)("mission-scroll flex h-full min-h-0 flex-col overscroll-contain",J?"overflow-hidden":"overflow-y-auto"),children:[(0,s.jsxs)("div",{className:"shrink-0 border-b border-white/[0.08] px-3 pb-2 pt-3",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"text-[9px] font-medium uppercase tracking-[0.24em] text-slate-500",children:"Inspector"}),(0,s.jsxs)("div",{className:"mt-1 flex min-w-0 items-center gap-1.5",children:[(0,s.jsx)("h2",{className:"min-w-0 truncate font-display text-[1.02rem] leading-5 text-white",children:Y}),(0,s.jsx)(tp,{variant:"muted",className:"shrink-0 h-4 px-1.5 py-0 text-[8px] leading-none tracking-[0.1em]",children:Q})]}),(0,s.jsx)("p",{className:"mt-1 truncate text-[11px] leading-4 text-slate-400",children:y?`${y.runtimeCount} runs \xb7 ${y.liveRunCount} live \xb7 ${(0,eb.fw)(y.updatedAt,h)}`:v?`Run ${(0,eb.m_)(v.runId||v.id,10)} \xb7 ${v.status} \xb7 ${(0,eb.fw)(v.updatedAt,h)}`:w?`${w.activeRuntimeIds.length} active runs`:f?`${f.agentIds.length} agents attached`:j?`${j.provider} model`:"Live gateway context"})]}),(0,s.jsx)("div",{className:"hidden h-8 w-8 shrink-0 items-center justify-center rounded-none border border-white/10 bg-white/[0.04] text-cyan-200 sm:flex",children:(0,s.jsx)(b.A,{className:"h-3.5 w-3.5"})})]}),(0,s.jsx)("div",{className:"mt-2 flex flex-nowrap gap-1 overflow-x-auto pb-0.5",children:Z.filter(e=>e.enabled).map(e=>(0,s.jsx)(tT,{label:e.label,active:V===e.id,onClick:()=>u(e.id)},e.id))})]}),(0,s.jsx)("div",{className:(0,S.cn)("flex-1 p-3",J&&"min-h-0 overflow-hidden"),children:(0,s.jsx)(eM.N,{mode:"wait",children:(0,s.jsxs)(x.P.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},className:(0,S.cn)("space-y-3.5",J&&"flex h-full min-h-0 flex-col space-y-0"),children:["overview"===V?(0,s.jsxs)(s.Fragment,{children:[f?(0,s.jsx)(tx,{snapshot:e,workspaceId:f.id}):null,w?(0,s.jsx)(tg,{snapshot:e,agentId:w.id,focusSection:r,onConfigureAgentCapabilities:o}):null,y?(0,s.jsx)(tb,{snapshot:e,task:y,taskId:y.id,taskDetail:z,taskDetailLoading:W,taskDetailError:F,onAbortTask:d}):null,v?(0,s.jsx)(tN,{snapshot:e,runtimeId:v.id,runtimeOutput:P,runtimeOutputLoading:B,runtimeOutputError:L}):null,j?(0,s.jsx)(tA,{snapshot:e,modelId:j.id}):null,N?null:(0,s.jsx)(th,{snapshot:e,lastMission:n})]}):null,J&&w?(0,s.jsx)(tl,{agent:w,snapshot:e,surfaceTheme:t,onRefresh:i,onSnapshotChange:l}):null,"output"===V&&y?(0,s.jsx)(tw,{task:y,taskDetail:z,taskDetailLoading:W,taskDetailError:F}):null,"output"===V&&v?(0,s.jsx)(tS,{runtime:v,runtimeOutput:P,runtimeOutputLoading:B,runtimeOutputError:L}):null,"files"===V&&y?(0,s.jsx)(ty,{snapshot:e,task:y,taskDetail:z}):null,"files"===V&&v?(0,s.jsx)(tC,{runtime:v,runtimeOutput:P}):null,"raw"===V?(0,s.jsx)("pre",{className:"overflow-x-auto rounded-[18px] border border-white/[0.08] bg-slate-950/[0.72] p-3 text-[11px] leading-5 text-slate-300",children:JSON.stringify(y&&z?z:v&&P?{runtime:v,output:P}:N||e,null,2)}):null]},`${a||"overview"}:${V}`)})}),J?null:(0,s.jsx)("div",{className:"shrink-0 border-t border-white/[0.08] p-3",children:(0,s.jsx)("div",{className:"rounded-[22px] border border-cyan-300/10 bg-[linear-gradient(180deg,rgba(7,22,31,0.95),rgba(5,13,22,0.95))] p-3.5 shadow-[0_16px_40px_rgba(0,0,0,0.22)]",children:(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"flex h-11 w-11 items-center justify-center rounded-full border border-cyan-300/15 bg-cyan-400/[0.12] text-cyan-200",children:(0,s.jsx)(e7.A,{className:"h-4 w-4"})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"truncate font-display text-[15px] text-white",children:y?`${y.runtimeCount} runs`:v?`Run ${(0,eb.m_)(v.runId||v.id,10)}`:w?`${w.activeRuntimeIds.length} active runs`:f?`${f.agentIds.length} agents`:j?j.provider:"Gateway overview"}),(0,s.jsxs)("p",{className:"mt-1 text-[12px] text-slate-400",children:[Q," \xb7"," ",y?`${z?.liveFeed.length??0} live feed events`:v?`${P?.items.length??0} transcript entries`:w?`${w.activeRuntimeIds.length} tracked runs`:f?`${f.agentIds.length} attached`:`${e.presence.length} live beacons`]})]})]})})})]})})]})}function th({snapshot:e,lastMission:t}){let a=(0,eb.hv)(e.generatedAt),r=e.diagnostics.runtime.stateWritable&&e.diagnostics.runtime.sessionStoreWritable?"passed"===e.diagnostics.runtime.smokeTest.status?"verified":"pending smoke test":"attention";return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(tM,{icon:e7.A,title:"Gateway health",value:e.diagnostics.health,children:[(0,s.jsx)("p",{children:e.diagnostics.gatewayUrl}),(0,s.jsx)("p",{children:e.diagnostics.dashboardUrl})]}),(0,s.jsxs)(tM,{icon:e6.A,title:"Runtime preflight",value:r,children:[(0,s.jsx)("p",{className:"font-mono text-xs text-slate-400",children:e.diagnostics.runtime.stateRoot}),(0,s.jsx)("p",{children:e.diagnostics.runtime.sessionStores.length>0?`${e.diagnostics.runtime.sessionStores.filter(e=>e.writable).length}/${e.diagnostics.runtime.sessionStores.length} session stores writable`:"No agent session stores have been probed yet."}),e.diagnostics.runtime.smokeTest.checkedAt?(0,s.jsxs)("p",{children:["Smoke test ",e.diagnostics.runtime.smokeTest.status," \xb7"," ",e.diagnostics.runtime.smokeTest.agentId||"unknown agent"," \xb7"," ",(0,eb.fw)(Date.parse(e.diagnostics.runtime.smokeTest.checkedAt),a)]}):(0,s.jsx)("p",{children:"No runtime smoke test has been recorded yet."}),e.diagnostics.runtime.issues[0]?(0,s.jsx)("div",{className:"rounded-[14px] border border-amber-400/15 bg-amber-400/8 px-3 py-2 text-[13px] text-amber-50",children:e.diagnostics.runtime.issues[0]}):null]}),(0,s.jsxs)(tM,{icon:b.A,title:"Presence beacons",value:String(e.presence.length),children:[0===e.presence.length?(0,s.jsx)("p",{children:"No live presence payloads."}):null,e.presence.map(e=>(0,s.jsxs)("div",{className:"rounded-[14px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.86),rgba(8,13,24,0.82))] px-3 py-2",children:[(0,s.jsx)("div",{className:"text-[13px] text-white",children:e.host}),(0,s.jsxs)("div",{className:"mt-1 text-xs text-slate-400",children:[e.ip," \xb7 ",e.platform," \xb7 ",e.version]})]},e.ts))]}),t?(0,s.jsxs)(tM,{icon:te.A,title:"Last mission",value:t.status,children:[(0,s.jsx)("p",{className:"text-sm text-white",children:t.summary}),(0,s.jsx)("p",{className:"font-mono text-xs text-slate-500",children:t.runId?`Run ${t.runId}`:`Dispatch ${t.dispatchId??"pending"}`}),"string"==typeof t.meta?.outputDirRelative?(0,s.jsx)("p",{className:"font-mono text-xs text-slate-400",children:t.meta.outputDirRelative}):null,t.payloads[0]?.text?(0,s.jsx)("div",{className:"rounded-[14px] border border-cyan-400/15 bg-cyan-400/8 px-3 py-2 text-[13px] text-cyan-50",children:t.payloads[0].text}):null]}):null]})}function tx({snapshot:e,workspaceId:t}){let a=(0,eb.hv)(e.generatedAt),r=e.workspaces.find(e=>e.id===t),n=e.agents.filter(e=>e.workspaceId===t),i=r?r.modelIds.map(t=>e.models.find(e=>e.id===t)?.name||t):[],l=e.runtimes.filter(e=>e.workspaceId===t||r?.activeRuntimeIds.includes(e.id)).sort((e,t)=>(t.updatedAt??0)-(e.updatedAt??0));if(!r)return null;let o=l.filter(e=>"running"===e.status||"queued"===e.status||"idle"===e.status),d=l[0]??null,c=tP(l.flatMap(t_)).slice(0,8),p=r.bootstrap.coreFiles.every(e=>e.present)&&r.bootstrap.projectShell.every(e=>e.present)?"ready":r.bootstrap.coreFiles.some(e=>e.present)||r.bootstrap.projectShell.some(e=>e.present)?"partial":"thin",m=Array.from(new Set(n.flatMap(e=>e.observedTools??[]))),u=0===n.length?"no agents":r.capabilities.workspaceOnlyAgentCount===n.length?"workspace-only":0===r.capabilities.workspaceOnlyAgentCount?"open":"mixed";return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(tM,{icon:e6.A,title:"Overview",value:r.health,children:[(0,s.jsx)("p",{className:"font-mono text-xs text-slate-400",children:(0,eb.$7)(r.path)}),(0,s.jsx)(tR,{items:[{label:"Agents",value:String(n.length)},{label:"Models",value:String(r.modelIds.length)},{label:"Runs",value:String(l.length)},{label:"Sessions",value:String(r.totalSessions)}]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Models"}),(0,s.jsx)(tE,{emptyLabel:"No models attached",items:i,emptyVariant:"muted",itemVariant:"muted"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Team"}),(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:n.map(e=>(0,s.jsx)(tp,{variant:e.isDefault?"default":"muted",children:(0,eb.CK)(e)},e.id))})]})]}),(0,s.jsxs)(tM,{icon:te.A,title:"Bootstrap",value:p,children:[(0,s.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,s.jsx)(tp,{variant:r.bootstrap.template?"default":"muted",children:r.bootstrap.template||"template unknown"}),(0,s.jsx)(tp,{variant:r.bootstrap.sourceMode?"muted":"warning",children:r.bootstrap.sourceMode||"source unknown"}),r.bootstrap.agentTemplate?(0,s.jsx)(tp,{variant:"muted",children:r.bootstrap.agentTemplate}):null]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Core files"}),(0,s.jsx)(t$,{items:r.bootstrap.coreFiles,missingVariant:"warning"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Optional scaffold"}),(0,s.jsx)(t$,{items:[...r.bootstrap.optionalFiles,...r.bootstrap.folders]})]}),r.bootstrap.contextFiles?.length?(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Context docs"}),(0,s.jsx)(t$,{items:r.bootstrap.contextFiles})]}):null,(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Project shell"}),(0,s.jsx)(t$,{items:r.bootstrap.projectShell})]})]}),(0,s.jsxs)(tM,{icon:te.A,title:"Capabilities",value:u,children:[(0,s.jsxs)("p",{children:[r.capabilities.workspaceOnlyAgentCount,"/",n.length," agents are configured with"," ",(0,s.jsx)("span",{className:"font-mono text-xs text-slate-300",children:"fs.workspaceOnly"}),"."]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Skills"}),(0,s.jsx)(tE,{emptyLabel:"No explicit skills",items:r.capabilities.skills,emptyVariant:"muted",itemVariant:"muted"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Local workspace skills"}),(0,s.jsx)(tE,{emptyLabel:"No local SKILL.md scaffolds",items:r.bootstrap.localSkillIds,emptyVariant:"muted",itemVariant:"success"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Declared tools"}),(0,s.jsx)(tE,{emptyLabel:"No explicit tools configured",items:r.capabilities.tools,emptyVariant:"muted",itemVariant:"warning"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Observed tools"}),(0,s.jsx)(tE,{emptyLabel:"No runtime tool calls recovered yet",items:m,emptyVariant:"muted",itemVariant:"default"})]})]}),(0,s.jsxs)(tM,{icon:b.A,title:"Activity",value:`${o.length} live`,children:[(0,s.jsxs)("p",{children:[l.length," tracked runs across ",r.totalSessions," recorded sessions."]}),(0,s.jsx)("p",{children:d?`Latest update ${(0,eb.fw)(d.updatedAt,a)}`:"No runtime activity has been recorded yet."}),l.length>0?(0,s.jsx)("div",{className:"space-y-2 pt-1",children:l.slice(0,3).map(e=>(0,s.jsxs)("div",{className:"flex items-center justify-between rounded-[14px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.86),rgba(8,13,24,0.82))] px-3 py-2",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"truncate text-[13px] text-white",children:e.title}),(0,s.jsxs)("p",{className:"truncate text-[10px] uppercase tracking-[0.18em] text-slate-500",children:[e.subtitle," \xb7 ",(0,eb.m_)(e.runId||e.id,10)]})]}),(0,s.jsx)(tp,{variant:(0,eb.Uu)(e.status),children:e.status})]},e.id))}):null,(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Agent posture"}),(0,s.jsx)("div",{className:"space-y-2",children:n.map(e=>(0,s.jsxs)("div",{className:"flex items-center justify-between rounded-[14px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.86),rgba(8,13,24,0.82))] px-3 py-2",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"truncate text-[13px] text-white",children:(0,eb.CK)(e)}),(0,s.jsx)("p",{className:"truncate text-[10px] uppercase tracking-[0.18em] text-slate-500",children:e.currentAction})]}),(0,s.jsx)(tp,{variant:"engaged"===e.status?"default":"offline"===e.status?"danger":"muted",children:e.status})]},e.id))})]})]}),(0,s.jsx)(tM,{icon:e9.A,title:"Created files",value:String(c.length),children:(0,s.jsx)(tO,{files:c,emptyLabel:"No file artifacts have been detected in recent workspace runs."})})]})}function tg({snapshot:e,agentId:t,focusSection:a,onConfigureAgentCapabilities:r}){let n=(0,eb.hv)(e.generatedAt),i=e.agents.find(e=>e.id===t),l=e.workspaces.find(e=>e.id===i?.workspaceId),o=e.models.find(e=>e.id===i?.modelId),d=(0,g.useRef)(null),c=(0,g.useRef)(null),p=(0,g.useRef)(null),m=i?.observedTools??[],u=i?.skills??[],h=(i?.tools??[]).filter(e=>"fs.workspaceOnly"!==e),f=i?.tools.includes("fs.workspaceOnly")?["fs.workspaceOnly"]:[],w=i?(0,eg.Cf)(i.policy.preset):null,y=i?[{label:"Preset",value:(0,eg._P)(i.policy.preset)},{label:"Missing tools",value:(0,eg.zR)(i.policy.missingToolBehavior)},{label:"Install scope",value:(0,eg.UJ)(i.policy.installScope)},{label:"File access",value:(0,eg.bQ)(i.policy.fileAccess)},{label:"Network",value:(0,eg.Bw)(i.policy.networkAccess)}]:[],j=e.runtimes.filter(e=>i?.activeRuntimeIds.includes(e.id)).sort((e,t)=>(t.updatedAt??0)-(e.updatedAt??0)),[k,N]=(0,g.useState)(null),C=tP(j.flatMap(t_)).slice(0,8);return((0,g.useEffect)(()=>{if(!a)return;let e="skills"===a?d.current:"tools"===a?c.current:p.current;e?.scrollIntoView({behavior:"smooth",block:"start"})},[a]),i)?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(tM,{icon:te.A,title:"Agent identity",value:i.id,children:[(0,s.jsx)("p",{children:(0,eb.CK)(i)}),(0,s.jsx)("p",{children:i.identity.emoji?`${i.identity.emoji} \xb7 ${i.identity.theme??"theme unset"}`:"No identity emoji"}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2",children:[i.isDefault?(0,s.jsx)(tp,{variant:"default",children:"default agent"}):null,(0,s.jsx)(tp,{variant:(0,eg.Cf)(i.policy.preset).badgeVariant,children:(0,eg._P)(i.policy.preset)}),i.identity.source?(0,s.jsx)(tp,{variant:"muted",children:i.identity.source}):null]})]}),(0,s.jsxs)(tM,{icon:e6.A,title:"Workspace",value:l?.name||"n/a",children:[(0,s.jsx)("p",{className:"font-mono text-xs text-slate-400",children:(0,eb.$7)(i.workspacePath)}),(0,s.jsxs)("p",{children:[i.sessionCount," recorded sessions"]})]}),(0,s.jsxs)(tM,{icon:te.A,title:"Model assignment",value:o?.name||i.modelId,children:[(0,s.jsx)("p",{children:o?`${o.provider} \xb7 ${(0,eb.FO)(o.contextWindow)} ctx`:"Model metadata unavailable"}),(0,s.jsx)("p",{children:o?.available===!1?"Currently unavailable":o?.local?"Local model route":"Remote model route"})]}),(0,s.jsx)(tM,{icon:te.A,title:"Agent summary",value:(0,eg._P)(i.policy.preset),actions:(0,s.jsxs)(I,{type:"button",variant:"secondary",size:"sm",onClick:()=>{r?.(i.id,"tools"===a?"tools":"skills")},className:"h-7 rounded-full px-2.5 text-[11px]",children:[(0,s.jsx)(tt.A,{className:"mr-1 h-3 w-3"}),"Edit"]}),children:(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"w-full",children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Purpose"}),(0,s.jsx)("div",{className:"w-full rounded-[14px] border border-white/[0.08] bg-white/[0.03] px-3 py-2.5",children:(0,s.jsx)("p",{className:"text-[13px] leading-5 text-slate-200",children:i.profile.purpose||"No explicit purpose was found in the workspace bootstrap files."})})]}),(0,s.jsxs)("div",{ref:d,className:(0,S.cn)("scroll-mt-4 rounded-[14px] border border-white/[0.08] bg-white/[0.03] px-3 py-2.5 transition-all","skills"===a&&"border-cyan-300/25 bg-cyan-400/[0.05] shadow-[0_0_0_1px_rgba(34,211,238,0.08)]"),children:[(0,s.jsxs)("div",{className:"mb-2 flex items-center justify-between gap-2",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Skills"}),(0,s.jsxs)(tp,{variant:"muted",children:[u.length," configured"]})]}),(0,s.jsx)(tE,{emptyLabel:"No explicit skills",items:u,emptyVariant:"muted",itemVariant:"muted"})]}),(0,s.jsxs)("div",{ref:c,className:(0,S.cn)("scroll-mt-4 rounded-[14px] border border-white/[0.08] bg-white/[0.03] px-3 py-2.5 transition-all","tools"===a&&"border-cyan-300/25 bg-cyan-400/[0.05] shadow-[0_0_0_1px_rgba(34,211,238,0.08)]"),children:[(0,s.jsxs)("div",{className:"mb-2 flex items-center justify-between gap-2",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Tools"}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[f.length>0?(0,s.jsxs)(tp,{variant:"success",children:[(0,s.jsx)(v.A,{className:"mr-1 h-3 w-3"}),"policy locked"]}):null,(0,s.jsxs)(tp,{variant:"muted",children:[h.length," configured"]})]})]}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)(tE,{emptyLabel:"No explicit tools configured",items:h,emptyVariant:"muted",itemVariant:"warning"}),f.length>0?(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Policy locked"}),(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:f.map(e=>(0,s.jsxs)(tp,{variant:"success",children:[(0,s.jsx)(v.A,{className:"mr-1 h-3 w-3"}),e]},e))}),(0,s.jsx)("p",{className:"mt-1 text-[11px] leading-5 text-slate-500",children:"This capability is derived from the agent policy and cannot be removed here."})]}):null,m.length>0?(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Observed"}),(0,s.jsx)(tE,{emptyLabel:"No runtime tool calls recovered yet",items:m,emptyVariant:"muted",itemVariant:"default"})]}):null]})]}),(0,s.jsxs)("div",{className:"rounded-[14px] border border-white/[0.08] bg-white/[0.03] px-3 py-3",children:[(0,s.jsx)("p",{className:"text-[12px] leading-5 text-slate-400",children:w?.description??"No policy description available."}),(0,s.jsxs)("div",{className:"mt-3 grid gap-1.5 text-[13px] text-slate-300",children:[y.map(e=>(0,s.jsxs)("p",{children:[e.label,": ",(0,s.jsx)("span",{className:"text-white",children:e.value})]},e.label)),i.profile.outputPreference?(0,s.jsxs)("p",{children:["Output preference: ",(0,s.jsx)("span",{className:"text-white",children:i.profile.outputPreference})]}):null]})]})]})}),(0,s.jsxs)(tM,{icon:e7.A,title:"Runtime posture",value:i.status,children:[(0,s.jsx)("p",{children:i.currentAction}),(0,s.jsxs)("p",{children:["Last active ",(0,eb.fw)(i.lastActiveAt,n)]}),(0,s.jsx)("p",{children:i.heartbeat.enabled?`Heartbeat ${i.heartbeat.every}`:"Heartbeat disabled"}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,s.jsx)(tp,{variant:i.heartbeat.enabled?"success":"muted",children:i.heartbeat.enabled?"heartbeat on":"heartbeat off"}),"number"==typeof i.heartbeat.everyMs?(0,s.jsxs)(tp,{variant:"muted",children:[Math.round(i.heartbeat.everyMs/1e3),"s interval"]}):null]})]}),(0,s.jsx)("div",{ref:p,className:"scroll-mt-4",children:(0,s.jsxs)(tM,{icon:b.A,title:"Activity history",value:String(j.length),className:(0,S.cn)("sessions"===a&&"border-cyan-300/25 bg-[linear-gradient(180deg,rgba(12,25,37,0.92),rgba(8,13,24,0.88))] shadow-[0_0_0_1px_rgba(34,211,238,0.08)]"),children:[(0,s.jsxs)("p",{children:[i.sessionCount," recorded sessions overall."]}),(0,s.jsx)("p",{children:j.length>0?`${j.length} history item${1===j.length?"":"s"} recovered from the latest agent activity.`:"No linked runtime records were recovered for this agent in the current snapshot."}),i.sessionCount>j.length?(0,s.jsxs)("p",{className:"text-[12px] text-slate-500",children:[i.sessionCount-j.length," session",i.sessionCount-j.length==1?"":"s"," do not have recovered runtime data yet."]}):null,j.length>0?(0,s.jsx)("div",{className:"space-y-2.5 pt-1",children:j.map(e=>{var t,a;let r=k===e.id,i=function(e){switch(e){case"session":return"Direct chat";case"turn":return"Conversation";case"cron":return"Scheduled";default:return"Unknown source"}}(e.source),l=function(e){if(e.taskId)return"Task";switch(e.source){case"session":return"Chat";case"turn":return"Run";case"cron":return"Scheduled";default:return"Activity"}}(e),o=e.sessionId?`session ${(0,eb.m_)(e.sessionId,10)}`:e.runId?`run ${(0,eb.m_)(e.runId,10)}`:"session n/a",d="number"!=typeof(t=e.tokenUsage?.total)||Number.isNaN(t)?"0 Tokens":t>=1e3?`${Math.round(t/1e3)}K Tokens`:`${t} Tokens`,c="number"!=typeof(a=e.updatedAt)||Number.isNaN(a)?"No time":new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(a));return(0,s.jsxs)("div",{className:(0,S.cn)("overflow-hidden rounded-[14px] border bg-[linear-gradient(180deg,rgba(11,18,32,0.86),rgba(8,13,24,0.82))] transition-all",r?"border-cyan-300/22 shadow-[0_0_0_1px_rgba(34,211,238,0.08)]":"border-white/[0.08]"),children:[(0,s.jsxs)("button",{type:"button","aria-expanded":r,className:"nodrag nopan flex w-full flex-col gap-2 px-3 py-2.5 text-left transition-colors hover:bg-white/[0.03]",onClick:()=>{N(t=>t===e.id?null:e.id)},onPointerDown:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,s.jsx)(tp,{variant:(0,eb.Uu)(e.status),children:e.status}),(0,s.jsx)(tp,{variant:e.tokenUsage?.total?"default":"muted",children:d})]}),(0,s.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,s.jsx)("p",{className:"line-clamp-2 text-[13px] leading-5 text-white",children:e.title}),(0,s.jsx)("p",{className:"line-clamp-2 text-[12px] leading-5 text-slate-300",children:e.subtitle})]}),(0,s.jsxs)("div",{className:"flex items-end justify-between gap-3",children:[(0,s.jsx)("div",{className:"min-w-0",children:(0,s.jsxs)("p",{className:"truncate text-[9px] uppercase tracking-[0.18em] text-slate-500",children:[l," \xb7 ",o]})}),(0,s.jsx)("p",{className:"shrink-0 text-right text-[9px] uppercase tracking-[0.18em] text-slate-500",children:c})]})]}),(0,s.jsx)(eM.N,{initial:!1,children:r?(0,s.jsx)(x.P.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.18},className:"overflow-hidden border-t border-white/[0.08]",children:(0,s.jsxs)("div",{className:"space-y-3 px-3 py-3",children:[(0,s.jsx)(tR,{items:[{label:"Source",value:i},{label:"Status",value:e.status},{label:"Updated",value:(0,eb.fw)(e.updatedAt,n)},{label:"Key",value:(0,eb.m_)(e.key,12)}]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[e.sessionId?(0,s.jsxs)(tp,{variant:"muted",children:["session ",(0,eb.m_)(e.sessionId,12)]}):null,e.runId?(0,s.jsxs)(tp,{variant:"muted",children:["run ",(0,eb.m_)(e.runId,12)]}):null,e.taskId?(0,s.jsxs)(tp,{variant:"muted",children:["task ",(0,eb.m_)(e.taskId,12)]}):null,e.modelId?(0,s.jsxs)(tp,{variant:"muted",children:["model ",(0,eb.m_)(e.modelId,12)]}):null]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Preview"}),(0,s.jsx)("div",{className:"rounded-[12px] border border-white/[0.08] bg-white/[0.03] px-3 py-2",children:(0,s.jsx)("p",{className:"text-[12px] leading-5 text-slate-200",children:e.subtitle})})]}),e.toolNames?.length?(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Tools"}),(0,s.jsx)(tE,{emptyLabel:"No tool names recorded",items:e.toolNames,emptyVariant:"muted",itemVariant:"warning"})]}):null]})}):null})]},e.id)})}):null]})}),(0,s.jsx)(tM,{icon:e9.A,title:"Created files",value:String(C.length),children:(0,s.jsx)(tO,{files:C,emptyLabel:"No file artifacts have been detected for this agent yet."})}),(0,s.jsxs)(tM,{icon:te.A,title:"Capabilities",value:`${i.skills.length} skills`,children:[(0,s.jsx)(tE,{emptyLabel:"No explicit skills",items:i.skills,emptyVariant:"muted",itemVariant:"muted"}),(0,s.jsxs)("div",{className:"pt-1",children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Declared tools"}),(0,s.jsx)(tE,{emptyLabel:"No explicit tools configured",items:i.tools,emptyVariant:"muted",itemVariant:"warning"})]}),(0,s.jsxs)("div",{className:"pt-1",children:[(0,s.jsx)("p",{className:"mb-2 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Observed tools"}),(0,s.jsx)(tE,{emptyLabel:"No runtime tool calls recovered yet",items:m,emptyVariant:"muted",itemVariant:"default"})]})]})]}):null}function tb({snapshot:e,task:t,taskId:a,taskDetail:r,taskDetailLoading:n,taskDetailError:i,onAbortTask:l}){let d=e.tasks.find(e=>e.id===a)??t,c=tk(d),p=!!l&&function(e){if(tk(e))return!1;let t=e.status;return"running"===t||"queued"===t}(d),m=e.workspaces.find(e=>e.id===t?.workspaceId),u=e.agents.find(e=>e.id===t?.primaryAgentId),h=r?.runs??e.runtimes.filter(e=>t?.runtimeIds.includes(e.id)).sort((e,t)=>(t.updatedAt??0)-(e.updatedAt??0)),x=r?.createdFiles??tP(h.flatMap(e=>t_(e))),g=r?.warnings??[];if(!t)return null;let f=r?.integrity??tv(t);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(tM,{icon:e6.A,title:"Mission",value:c?"aborted":d.status,children:[(0,s.jsx)("p",{className:"line-clamp-1 text-sm text-white",children:(0,eb.$m)(d.mission||d.title,80)||d.title}),(0,s.jsx)("p",{className:"line-clamp-1 text-[12.5px] leading-5 text-slate-400",children:(0,eb.$m)(d.subtitle,110)||d.subtitle}),(0,s.jsx)(tR,{items:[{label:"Runs",value:String(d.runtimeCount)},{label:"Feed",value:String(d.updateCount)},{label:"Files",value:String(d.artifactCount)},{label:"Live",value:String(d.liveRunCount)}]}),l&&(p||c)?(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:(0,s.jsxs)(I,{type:"button",variant:c?"secondary":"destructive",size:"sm",disabled:!p,className:"gap-2",onClick:()=>{p&&l(d)},children:[(0,s.jsx)(o.A,{className:"h-3.5 w-3.5"}),c?"Aborted":"Abort task"]})}):null,(0,s.jsxs)("div",{className:"flex flex-wrap gap-2",children:[m?(0,s.jsx)(tp,{variant:"muted",children:m.name}):null,u?(0,s.jsx)(tp,{variant:"default",children:(0,eb.CK)(u)}):null,d.dispatchId?(0,s.jsxs)(tp,{variant:"muted",children:["dispatch ",(0,eb.m_)(d.dispatchId,8)]}):null,c?(0,s.jsx)(tp,{variant:"danger",children:"aborted"}):null]}),n&&!r?(0,s.jsx)("p",{children:"Connecting live task feed…"}):null,i?(0,s.jsx)("p",{className:"rounded-[12px] border border-amber-400/20 bg-amber-400/10 px-3 py-2 text-[12px] leading-5 text-amber-100",children:i}):null]}),(0,s.jsx)(tf,{task:d,integrity:f}),(0,s.jsxs)(tM,{icon:b.A,title:"Runs",value:String(h.length),children:[0===h.length?(0,s.jsx)("p",{children:"No OpenClaw runs have been grouped into this task yet."}):null,(0,s.jsx)("div",{className:"space-y-2",children:h.map(e=>(0,s.jsxs)("div",{className:"flex items-center justify-between rounded-[14px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.86),rgba(8,13,24,0.82))] px-3 py-2",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"truncate text-[13px] text-white",children:e.title}),(0,s.jsx)("p",{className:"truncate text-[10px] uppercase tracking-[0.18em] text-slate-500",children:e.subtitle})]}),(0,s.jsx)(tp,{variant:(0,eb.Uu)(e.status),children:e.status})]},e.id))})]}),(0,s.jsx)(tM,{icon:e9.A,title:"Artifacts",value:String(x.length),children:(0,s.jsx)(tO,{files:x,emptyLabel:"This task has not produced a detectable file artifact yet."})}),g.length>0?(0,s.jsx)(tM,{icon:e7.A,title:"Warnings",value:String(g.length),children:(0,s.jsx)(tD,{items:g,emptyLabel:"No warnings detected."})}):null]})}function tf({task:e,integrity:t}){let a=tk(e),r=t.issues.find(e=>"partial-final-response"===e.id),n=a?"This task was aborted by an operator. Captured evidence may be incomplete.":"verified"===t.status?"Mission Control found a matching transcript and the captured result looks internally consistent.":t.sessionMismatch?"The linked transcript belongs to a different mission or stale session, so this completion cannot be trusted yet.":t.issues.some(e=>"empty-output-dir"===e.id)?"The task is marked completed, but the expected deliverables are missing from the output folder.":"error"===t.status?"The captured evidence does not line up with the requested mission.":"Mission Control recovered partial evidence, but this result still needs operator review.";return(0,s.jsxs)(tM,{icon:e7.A,title:"Result integrity",value:a?"aborted":"stalled"===e.status?"stalled":t.status,children:[(0,s.jsx)("p",{children:n}),(0,s.jsx)(tR,{items:[{label:"Output files",value:String(t.outputFileCount)},{label:"Transcript turns",value:String(t.transcriptTurnCount)},{label:"Matched turns",value:String(t.matchingTranscriptTurnCount)},{label:"Tools",value:String(t.toolNames.length)},{label:"Emails",value:String(t.emails.length)}]}),t.outputDir||t.outputDirRelative?(0,s.jsxs)("div",{className:"rounded-[14px] border border-white/[0.08] bg-white/[0.03] px-3 py-2.5",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-slate-500",children:"Output folder"}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)(to.G,{text:t.outputDirRelative||t.outputDir||"Output folder",className:"text-[12.5px] leading-5 text-slate-100",filePath:t.outputDir,displayPath:t.outputDirRelative||t.outputDir})}),(0,s.jsx)("p",{className:"mt-2 text-[11px] text-slate-400",children:t.outputDirExists?`${t.outputFileCount} file${1===t.outputFileCount?"":"s"} detected in the folder.`:"The output folder is not currently accessible."})]}):null,(0,s.jsxs)("div",{className:"rounded-[14px] border border-white/[0.08] bg-white/[0.03] px-3 py-2.5",children:[(0,s.jsxs)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-slate-500",children:["Final response ","none"!==t.finalResponseSource?`(${t.finalResponseSource})`:""]}),r?(0,s.jsx)("p",{className:"mt-2 rounded-[12px] border border-amber-400/20 bg-amber-400/10 px-3 py-2 text-[12px] leading-5 text-amber-100",children:r.detail}):null,(0,s.jsx)("div",{className:"mt-2",children:t.finalResponseText?(0,s.jsx)(to.G,{text:t.finalResponseText,className:"text-[12.5px] leading-5 text-slate-100"}):(0,s.jsx)("p",{className:"text-[12.5px] leading-5 text-slate-400",children:"No final response was captured."})})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-slate-500",children:"Recovered tools"}),t.toolNames.length>0?(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:t.toolNames.map(e=>(0,s.jsx)(tp,{variant:"muted",children:e},e))}):(0,s.jsx)("p",{children:"No tool calls were recovered from a matching transcript turn."})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-slate-500",children:"Detected emails"}),t.emails.length>0?(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:t.emails.map(e=>(0,s.jsx)(tp,{variant:"muted",children:e},e))}):(0,s.jsx)("p",{children:"No email addresses were detected in the captured result."})]}),t.dispatchSessionId?(0,s.jsxs)("p",{className:"font-mono text-xs text-slate-400",children:["session ",(0,eb.m_)(t.dispatchSessionId,12),t.sessionMismatch?" \xb7 mismatch detected":""]}):null,t.issues.length>0?(0,s.jsxs)("div",{className:"rounded-[14px] border border-amber-400/16 bg-amber-400/[0.06] px-3 py-2.5",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-amber-100/80",children:"Review issues"}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)(tD,{items:t.issues.map(e=>`${e.title}: ${e.detail}`),emptyLabel:"No integrity issues detected."})})]}):null]})}function tw({task:e,taskDetail:t,taskDetailLoading:a,taskDetailError:r}){if(a&&!t)return(0,s.jsx)(tM,{icon:b.A,title:"Live feed",value:"connecting",children:(0,s.jsx)("p",{children:"Connecting to the task feed…"})});if(r&&!t)return(0,s.jsx)(tM,{icon:b.A,title:"Live feed",value:"error",children:(0,s.jsx)("p",{children:r})});let n=t?.liveFeed??[],i=t?.integrity??tv(e);return(0,s.jsxs)(tM,{icon:b.A,title:"Live feed",value:String(n.length),children:[r?(0,s.jsx)("p",{className:"rounded-[12px] border border-amber-400/20 bg-amber-400/10 px-3 py-2 text-[12px] leading-5 text-amber-100",children:r}):null,i.issues.length>0?(0,s.jsx)("p",{className:"rounded-[12px] border border-amber-400/20 bg-amber-400/10 px-3 py-2 text-[12px] leading-5 text-amber-100",children:i.issues[0]?.detail}):null,0===n.length?(0,s.jsx)("p",{children:"No streamed task events have arrived yet."}):null,(0,s.jsx)("div",{className:"space-y-2",children:n.map(e=>(0,s.jsxs)("div",{className:"rounded-[14px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.86),rgba(8,13,24,0.82))] px-3 py-2.5",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,s.jsx)(tp,{variant:function(e,t){if(t)return"danger";switch(e){case"assistant":return"default";case"tool":case"warning":return"warning";case"artifact":return"success";default:return"muted"}}(e.kind,e.isError),children:e.kind}),(0,s.jsx)("p",{className:"truncate text-[12px] text-white",children:e.title})]}),(0,s.jsx)("span",{className:"text-[10px] uppercase tracking-[0.18em] text-slate-500",children:(0,eb.fw)(new Date(e.timestamp).getTime())})]}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)(to.G,{text:e.detail,className:"text-[12.5px] leading-5 text-slate-100",url:e.url,filePath:e.filePath,displayPath:e.displayPath})})]},e.id))})]})}function ty({snapshot:e,task:t,taskDetail:a}){let r=a?.runs??e.runtimes.filter(e=>t.runtimeIds.includes(e.id)).sort((e,t)=>(t.updatedAt??0)-(e.updatedAt??0)),n=a?.createdFiles??tP(r.flatMap(e=>t_(e))),i=a?.integrity??tv(t);return(0,s.jsxs)(tM,{icon:e9.A,title:"Files",value:String(n.length),children:[(0,s.jsxs)("p",{children:[r.length," run",1===r.length?"":"s"," contributed to this task."]}),i.outputDir||i.outputDirRelative?(0,s.jsxs)("div",{className:"rounded-[14px] border border-white/[0.08] bg-white/[0.03] px-3 py-2.5",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-slate-500",children:"Output folder"}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)(to.G,{text:i.outputDirRelative||i.outputDir||"Output folder",className:"text-[12.5px] leading-5 text-slate-100",filePath:i.outputDir,displayPath:i.outputDirRelative||i.outputDir})}),(0,s.jsx)("p",{className:"mt-2 text-[11px] text-slate-400",children:i.outputDirExists?`${i.outputFileCount} file${1===i.outputFileCount?"":"s"} detected in the folder.`:"The output folder is not currently accessible."})]}):null,(0,s.jsx)(tO,{files:n,emptyLabel:"This task has not produced a detectable file artifact yet."})]})}function tv(e){let t=tk(e)?[{id:"task-cancelled",severity:"warning",title:"Task was cancelled by the operator",detail:"The mission dispatch was stopped before completion, so the captured evidence is intentionally incomplete."}]:"stalled"===e.status?[{id:"stalled-dispatch",severity:"warning",title:"Dispatch stalled before evidence was captured",detail:e.subtitle}]:e.metadata.optimistic?[{id:"pending-evidence",severity:"warning",title:"Waiting for runtime evidence",detail:"Mission Control will attach transcript, tool, and file evidence after the first runtime is observed."}]:[];return{status:t.some(e=>"error"===e.severity)?"error":t.length>0?"warning":"verified",outputDir:"string"==typeof e.metadata.outputDir&&e.metadata.outputDir.trim().length>0?e.metadata.outputDir:null,outputDirRelative:"string"==typeof e.metadata.outputDirRelative&&e.metadata.outputDirRelative.trim().length>0?e.metadata.outputDirRelative:null,outputDirExists:!1,outputFileCount:0,transcriptTurnCount:0,matchingTranscriptTurnCount:0,finalResponseText:null,finalResponseSource:"none",dispatchSessionId:null,sessionMismatch:!1,toolNames:[],emails:[],issues:t}}function tj(e){return"object"==typeof e&&null!==e&&"string"==typeof e.id&&"string"==typeof e.kind&&"string"==typeof e.timestamp&&"string"==typeof e.title&&"string"==typeof e.detail}function tk(e){let t="string"==typeof e.metadata.dispatchStatus?e.metadata.dispatchStatus:null,a=e.status;return"cancelled"===t||"aborted"===t||"cancelled"===a||"aborted"===a}function tN({snapshot:e,runtimeId:t,runtimeOutput:a,runtimeOutputLoading:r,runtimeOutputError:n}){let i,l=(0,eb.hv)(e.generatedAt),o=e.runtimes.find(e=>e.id===t),d=tP(a?.createdFiles??(o?t_(o):[])),c=a?.warnings??(o&&Array.isArray(i=o.metadata.warnings)?i.filter(e=>"string"==typeof e&&e.trim().length>0):[]),p=a?.warningSummary??c[0]??null;return o?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(tM,{icon:b.A,title:"Runtime key",value:o.status,children:[(0,s.jsx)("p",{className:"font-mono text-xs text-slate-400",children:o.key}),(0,s.jsxs)("p",{children:["Session ",(0,eb.m_)(o.sessionId,12)]}),o.taskId?(0,s.jsxs)("p",{children:["Task ",(0,eb.m_)(o.taskId,12)]}):null,o.runId?(0,s.jsxs)("p",{children:["Run ",(0,eb.m_)(o.runId,12)]}):null]}),(0,s.jsxs)(tM,{icon:e7.A,title:"Activity",value:(0,eb.fw)(o.updatedAt,l),children:[(0,s.jsx)("p",{children:o.subtitle}),(0,s.jsxs)("p",{children:[(0,eb._y)(o.tokenUsage?.total)," tokens"]})]}),(0,s.jsxs)(tM,{icon:te.A,title:"Latest output",value:a?.stopReason||(r?"loading":"no transcript"),children:[r?(0,s.jsx)("p",{children:"Loading transcript output…"}):null,n?(0,s.jsx)("p",{children:n}):null,r||n?null:(0,s.jsx)(to.G,{text:a?.finalText||a?.errorMessage||"No assistant output has been recorded for this runtime yet.",className:"text-[13px] leading-5 text-slate-100"}),p?(0,s.jsxs)("p",{className:"mt-3 rounded-[12px] border border-amber-400/20 bg-amber-400/10 px-3 py-2 text-[12px] leading-5 text-amber-100",children:["Fallback used: ",p]}):null,a?.finalTimestamp?(0,s.jsxs)("p",{className:"text-[11px] uppercase tracking-[0.18em] text-slate-500",children:["Updated ",(0,eb.fw)(new Date(a.finalTimestamp).getTime())]}):null]}),(0,s.jsx)(tM,{icon:e9.A,title:"Created files",value:String(d.length),children:(0,s.jsx)(tO,{files:d,emptyLabel:"This runtime has not produced a detectable file artifact."})})]}):null}function tC({runtime:e,runtimeOutput:t}){let a=tP(t?.createdFiles??t_(e));return(0,s.jsxs)(tM,{icon:e9.A,title:"Files",value:String(a.length),children:[(0,s.jsx)("p",{children:e.title}),(0,s.jsx)(tO,{files:a,emptyLabel:"This runtime has not produced a detectable file artifact."})]})}function tS({runtime:e,runtimeOutput:t,runtimeOutputLoading:a,runtimeOutputError:r}){return a?(0,s.jsx)(tM,{icon:b.A,title:"Runtime output",value:"loading",children:(0,s.jsxs)("p",{children:["Loading transcript output for ",e.title,"…"]})}):r?(0,s.jsx)(tM,{icon:b.A,title:"Runtime output",value:"error",children:(0,s.jsx)("p",{children:r})}):t?(0,s.jsxs)("div",{className:"space-y-3.5",children:[t.warningSummary?(0,s.jsx)(tM,{icon:e7.A,title:"Warnings",value:String(t.warnings.length),children:(0,s.jsx)("p",{children:t.warningSummary})}):null,(0,s.jsx)(tM,{icon:e9.A,title:"Created files",value:String(t.createdFiles.length),children:(0,s.jsx)(tO,{files:t.createdFiles,emptyLabel:"This runtime transcript does not include a successful file creation."})}),(0,s.jsxs)(tM,{icon:b.A,title:"Final response",value:"stalled"===e.status||"cancelled"===e.status?e.status:t.stopReason||t.status,children:["stalled"===e.status||"cancelled"===e.status?(0,s.jsx)("p",{className:"mb-2 rounded-[12px] border border-amber-400/20 bg-amber-400/10 px-3 py-2 text-[12px] leading-5 text-amber-100",children:"This runtime did not complete cleanly. The text below is the last captured assistant output, not a verified completion."}):null,t.errorMessage?(0,s.jsx)("p",{className:"mb-2 rounded-[12px] border border-rose-400/20 bg-rose-400/10 px-3 py-2 text-[12px] leading-5 text-rose-100",children:t.errorMessage}):null,(0,s.jsx)(to.G,{text:t.finalText||t.errorMessage||"No assistant output has been recorded for this runtime yet.",className:"text-[13px] leading-5 text-slate-100"}),t.finalTimestamp?(0,s.jsx)("p",{className:"text-[11px] uppercase tracking-[0.18em] text-slate-500",children:new Date(t.finalTimestamp).toLocaleString()}):null]}),(0,s.jsxs)(tM,{icon:e7.A,title:"Transcript trail",value:String(t.items.length),children:[0===t.items.length?(0,s.jsx)("p",{children:"No transcript entries were found."}):null,(0,s.jsx)("div",{className:"space-y-2",children:t.items.map(e=>(0,s.jsxs)("div",{className:"rounded-[14px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.86),rgba(8,13,24,0.82))] px-3 py-2.5",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(tp,{variant:"assistant"===e.role?e.isError?"danger":"default":"toolResult"===e.role?"warning":"muted",children:e.role}),e.toolName?(0,s.jsx)(tp,{variant:"muted",children:e.toolName}):null]}),(0,s.jsx)("span",{className:"text-[10px] uppercase tracking-[0.18em] text-slate-500",children:(0,eb.fw)(new Date(e.timestamp).getTime())})]}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)(to.G,{text:e.text,className:"text-[12.5px] leading-5 text-slate-100"})})]},e.id))})]})]}):(0,s.jsx)(tM,{icon:b.A,title:"Runtime output",value:"missing",children:(0,s.jsx)("p",{children:"No transcript data is available for this runtime."})})}function tA({snapshot:e,modelId:t}){let a=e.models.find(e=>e.id===t);return a?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(tM,{icon:te.A,title:"Model routing",value:a.provider,children:[(0,s.jsx)("p",{children:a.name}),(0,s.jsx)("p",{children:a.local?"Local model":"Remote model"})]}),(0,s.jsxs)(tM,{icon:e7.A,title:"Capacity",value:`${(0,eb.FO)(a.contextWindow)} ctx`,children:[(0,s.jsx)("p",{children:a.input}),(0,s.jsx)("p",{children:!1===a.available?"Unavailable":"Available"}),(0,s.jsxs)("p",{children:[a.usageCount," attached agents"]})]})]}):null}function tI({icon:e,label:t,active:a,surfaceTheme:r,panelCollapsed:n,tooltipSide:i,disabled:l=!1,onClick:o}){return(0,s.jsx)(tc,{label:t,side:i,surfaceTheme:r,panelCollapsed:n,children:(0,s.jsx)("button",{type:"button","aria-label":t,"aria-disabled":l,tabIndex:l?-1:0,onClick:o,className:(0,S.cn)("inline-flex h-8 w-8 items-center justify-center rounded-[8px] border transition-all",l?"border-white/5 bg-white/[0.02] text-slate-600":a?"border-cyan-300/18 bg-cyan-400 text-slate-950 shadow-[0_10px_22px_rgba(96,165,250,0.28)]":"border-white/10 bg-white/[0.03] text-slate-400 hover:border-white/15 hover:bg-white/[0.08] hover:text-white"),children:(0,s.jsx)(e,{className:"h-3 w-3"})})})}function tT({label:e,active:t,onClick:a}){return(0,s.jsx)("button",{type:"button",onClick:a,className:(0,S.cn)("inline-flex items-center rounded-full border px-2.5 py-1.5 text-[10px] uppercase tracking-[0.14em] whitespace-nowrap transition-all",t?"border-cyan-300/20 bg-cyan-400 text-slate-950 shadow-[0_10px_24px_rgba(96,165,250,0.28)]":"border-white/[0.08] bg-white/[0.03] text-slate-300 hover:bg-white/[0.07] hover:text-white"),children:e})}function tM({icon:e,title:t,value:a,actions:r,children:n,className:i}){return(0,s.jsxs)("section",{className:(0,S.cn)("rounded-[18px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(12,19,34,0.86),rgba(8,13,24,0.82))] p-3 transition-all",i),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.24em] text-slate-500",children:t}),(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,s.jsx)("p",{className:"min-w-0 font-display text-[1rem] text-white",children:a}),r?(0,s.jsx)("div",{className:"shrink-0",children:r}):null]})]}),(0,s.jsx)("div",{className:"rounded-[14px] border border-white/[0.08] bg-white/5 p-2 text-slate-300",children:(0,s.jsx)(e,{className:"h-3.5 w-3.5"})})]}),(0,s.jsx)("div",{className:"mt-3 space-y-1.5 text-[12.5px] leading-5 text-slate-300",children:n})]})}function tO({files:e,emptyLabel:t}){return 0===e.length?(0,s.jsx)("p",{className:"text-[12px] text-slate-400",children:t}):(0,s.jsx)("div",{className:"space-y-2",children:e.map(e=>(0,s.jsx)("button",{type:"button",onClick:()=>void tL(e.path),className:"w-full rounded-[14px] border border-cyan-300/12 bg-[linear-gradient(180deg,rgba(11,18,32,0.86),rgba(8,13,24,0.82))] px-3 py-2 text-left transition-all hover:border-cyan-300/28 hover:bg-cyan-400/[0.08]",children:(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"truncate font-mono text-[12px] text-cyan-100",children:e.displayPath}),(0,s.jsx)("p",{className:"truncate text-[11px] text-slate-400",children:(0,eb.$7)(e.path)})]}),(0,s.jsx)(tp,{variant:"muted",children:"reveal"})]})},e.path))})}function tR({items:e}){return(0,s.jsx)("div",{className:"grid grid-cols-2 gap-2",children:e.map(e=>(0,s.jsxs)("div",{className:"rounded-[14px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.86),rgba(8,13,24,0.82))] px-3 py-2",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-slate-500",children:e.label}),(0,s.jsx)("p",{className:"mt-1 text-[13px] text-white",children:e.value})]},e.label))})}function t$({items:e,missingVariant:t="muted"}){return(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:e.map(e=>(0,s.jsx)(tp,{variant:e.present?"success":t,children:e.label},e.id))})}function tE({items:e,emptyLabel:t,itemVariant:a,emptyVariant:r}){return 0===e.length?(0,s.jsx)(tp,{variant:r,children:t}):(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:e.map(e=>(0,s.jsx)(tp,{variant:a,children:e},e))})}function tD({items:e,emptyLabel:t}){return 0===e.length?(0,s.jsx)("p",{className:"text-[12px] text-slate-400",children:t}):(0,s.jsx)("div",{className:"space-y-2",children:e.map(e=>(0,s.jsx)("div",{className:"rounded-[14px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.86),rgba(8,13,24,0.82))] px-3 py-2",children:(0,s.jsx)("p",{className:"text-[12px] leading-5 text-slate-200",children:e})},e))})}function t_(e){let t=e.metadata.createdFiles;return Array.isArray(t)?t.flatMap(e=>{if(!e||"object"!=typeof e)return[];let t="path"in e&&"string"==typeof e.path?e.path:null,a="displayPath"in e&&"string"==typeof e.displayPath?e.displayPath:t;return t&&a?[{path:t,displayPath:a}]:[]}):[]}function tP(e){let t=new Set,a=[];for(let s of e)!s.path||t.has(s.path)||(t.add(s.path),a.push(s));return a}async function tL(e){try{let t=await fetch("/api/files/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})}),a=await t.json();if(!t.ok)throw Error(a.error||"Unable to reveal file.");em.oR.success("Revealed file.",{description:(0,eb.$7)(e)})}catch(e){em.oR.error("Could not reveal file.",{description:e instanceof Error?e.message:"Unknown file reveal error."})}}var tU=a(2662),tF=a(4927);function tz(e){var t;return e.diagnostics.installed&&e.diagnostics.rpcOk&&(t=e).diagnostics.runtime.stateWritable&&t.diagnostics.runtime.sessionStoreWritable}function tW(e){return tz(e)&&e.diagnostics.modelReadiness.ready&&"passed"===e.diagnostics.runtime.smokeTest.status}function tB({snapshot:e,surfaceTheme:t,stage:a,systemActionLabel:r,systemActionDescription:n,systemPhase:l,modelPhase:o,systemRun:d,modelRun:c,selectedModelId:p,discoveredModels:m,onSelectedModelIdChange:u,onRunSystemSetup:h,onRunModelAutoSetup:g,onRunModelDiscover:b,onRunModelRefresh:f,onRunModelSetDefault:w,onOpenAddModels:y,onContinueToModels:v,onBackToSystem:k,onDismiss:N,canDismiss:C}){var A,T,M,O,R,$,E,D,_,P,L,U,F,z,W,B,q,K,G;let V,J,H,Y,Q,Z,X=tz(e),ee=tW(e),et=(A=a,T=X,M=ee,[{id:"system",order:1,label:"System setup",description:"CLI, gateway, RPC, runtime state",state:tJ(T,"system"===A&&!T)},{id:"models",order:2,label:"Model setup",description:"Default model, auth",state:tJ(M,"models"===A&&!M)}]),ea=(O=e,R=l,V=O.diagnostics.rpcOk&&!O.diagnostics.loaded,J=O.diagnostics.installed||"installing-gateway"===R||"starting-gateway"===R||"verifying"===R||"ready"===R,H=O.diagnostics.loaded||V||"starting-gateway"===R||"verifying"===R||"ready"===R,Y=O.diagnostics.rpcOk||"ready"===R,Q=O.diagnostics.runtime.stateWritable&&O.diagnostics.runtime.sessionStoreWritable||"ready"===R,Z=Y&&Q,[{id:"cli",label:"OpenClaw CLI",description:O.diagnostics.installed?`Installed${O.diagnostics.version?` \xb7 v${O.diagnostics.version}`:""}`:"Install the OpenClaw CLI.",state:tJ(J,!J&&("detecting"===R||"installing-cli"===R))},{id:"gateway",label:"Gateway service",description:O.diagnostics.loaded?"Gateway is already registered.":V?"Gateway is running directly.":"Register the gateway service once.",state:tJ(H,!H&&("installing-gateway"===R||J&&"detecting"===R))},{id:"runtime",label:"Runtime ready",description:Z?"RPC and state are ready.":Y?"RPC is online; verify state access.":H?"Gateway is up; verify RPC.":"Start the gateway and verify RPC.",state:tJ(Z,!Z&&("starting-gateway"===R||"verifying"===R||H&&"detecting"===R))}]),es=e.models.filter(e=>!1!==e.available&&!e.missing),er=m.filter(e=>!es.some(t=>t.id===e.modelId)),en=tV(p,es),ei="system"===a?d:c,el=ei.statusMessage||ei.resultMessage||($=a,E=n,D=en,"system"===$?E:D?`Selected model: ${D}.`:"Choose or connect a usable model route."),eo="system"===a?(_=l,tz(P=e)?"ready":P.diagnostics.rpcOk?"verifying access":P.diagnostics.loaded&&!P.diagnostics.rpcOk?"verifying"===_?"connecting":"starting gateway":_?_.replace("-"," "):"waiting"):(L=o,tW(U=e)?"ready":U.diagnostics.modelReadiness.ready&&"passed"!==U.diagnostics.runtime.smokeTest.status?"smoke test":L?L.replace("-"," "):"waiting"),ed="idle"!==ei.runState||!!ei.manualCommand||ei.log.trim().length>0||"models"===a&&m.length>0,ec=(F=ei.runState,z=a,W=ee,"running"===F?"Running":W?"Ready":"success"===F?"models"===z?"Updated":"Step complete":"error"===F?"Needs attention":"system"===z?"Step 1":"Step 2"),ep="system"===(B={stage:a,systemReady:X,modelReady:ee,systemActionLabel:r,selectedModelId:p,availableModelIds:es.map(e=>e.id)}).stage?B.systemReady&&B.modelReady?{kind:"dismiss",label:"Enter Mission Control"}:B.systemReady?{kind:"continue",label:"Continue to model setup"}:{kind:"system",label:B.systemActionLabel}:B.modelReady?{kind:"dismiss",label:"Enter Mission Control"}:B.selectedModelId&&B.availableModelIds.includes(B.selectedModelId)||B.selectedModelId?{kind:"set-default",label:"Use selected model"}:{kind:"auto",label:"Auto configure models"};return(0,s.jsx)(x.P.div,{initial:{opacity:0,backdropFilter:"blur(0px)"},animate:{opacity:1,backdropFilter:"blur(12px)"},exit:{opacity:0,backdropFilter:"blur(0px)"},className:(0,S.cn)("absolute inset-0 z-[80] pointer-events-auto flex items-center justify-center overflow-y-auto px-3 py-4 sm:px-4 sm:py-6","light"===t?"bg-[radial-gradient(circle_at_top,rgba(255,255,255,0.94),rgba(247,239,232,0.88)_46%,rgba(242,230,220,0.92))]":"bg-[radial-gradient(circle_at_top,rgba(17,24,39,0.9),rgba(3,7,18,0.92)_48%,rgba(2,6,23,0.96))]"),children:(0,s.jsxs)(x.P.div,{initial:{opacity:0,y:18,scale:.985},animate:{opacity:1,y:0,scale:1},className:(0,S.cn)("my-auto flex w-full max-w-[420px] flex-col overflow-hidden rounded-[16px] border shadow-[0_18px_46px_rgba(0,0,0,0.18)] backdrop-blur-2xl max-h-[min(80vh,560px)]","light"===t?"border-[#dccabd]/90 bg-[rgba(255,250,246,0.92)] text-[#47362b] shadow-[0_18px_50px_rgba(161,125,101,0.15)]":"border-white/10 bg-[rgba(6,10,18,0.84)] text-slate-100"),children:[(0,s.jsxs)("div",{className:"overflow-y-auto px-2.5 py-2.5 sm:px-3 sm:py-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsxs)("span",{className:(0,S.cn)("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[8px] uppercase tracking-[0.18em]","light"===t?"border-[#d8c0b0] bg-[#f3e7dc] text-[#8d725f]":"border-white/10 bg-white/[0.06] text-slate-300"),children:[(0,s.jsx)(eI.A,{className:"h-2 w-2"}),"Welcome"]}),(0,s.jsx)("span",{className:(0,S.cn)("rounded-full border px-1.5 py-0.5 text-[8px] uppercase tracking-[0.16em]",(q=ei.runState,K=ee,G=t,"error"===q?"light"===G?"border-rose-300 bg-rose-50 text-rose-700":"border-rose-300/25 bg-rose-300/10 text-rose-200":"success"===q||K?"light"===G?"border-emerald-300 bg-emerald-50 text-emerald-700":"border-emerald-300/25 bg-emerald-300/10 text-emerald-200":"running"===q?"light"===G?"border-[#d8c0b0] bg-white/80 text-[#8d725f]":"border-white/10 bg-white/[0.04] text-slate-300":"light"===G?"border-[#d8c0b0] bg-white/80 text-[#8d725f]":"border-white/10 bg-white/[0.04] text-slate-400")),children:ec})]}),(0,s.jsxs)("div",{className:"mt-3",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[7px] uppercase tracking-[0.18em]","light"===t?"text-[#977b69]":"text-slate-500"),children:"OpenClaw Mission Control"}),(0,s.jsx)("h1",{className:(0,S.cn)("mt-1 font-display text-[1.12rem] leading-[1.25rem]","light"===t?"text-[#33251c]":"text-white"),children:"Bring your local OpenClaw online."}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1.5 text-[11px] leading-[1.05rem]","light"===t?"text-[#705b4d]":"text-slate-300"),children:"Set up the system, then pick a default model."})]}),(0,s.jsx)("div",{className:"mt-3 grid gap-1.5 sm:grid-cols-2",children:et.map(e=>(0,s.jsx)("div",{className:(0,S.cn)("rounded-[14px] border px-2.5 py-2",tZ(e.state,t)),children:(0,s.jsxs)("div",{className:"flex items-center justify-between gap-1.5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:(0,S.cn)("inline-flex h-5 w-5 items-center justify-center rounded-full border text-[9px] font-medium",tX(e.state,t)),children:"complete"===e.state?(0,s.jsx)(j.A,{className:"h-2.5 w-2.5"}):e.order}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[11px]","light"===t?"text-[#3e2f24]":"text-white"),children:e.label}),(0,s.jsx)("p",{className:(0,S.cn)("mt-0.5 text-[8px] leading-[0.85rem]","light"===t?"text-[#8f7664]":"text-slate-500"),children:e.description})]})]}),(0,s.jsx)("span",{className:(0,S.cn)("rounded-full px-1.5 py-0.5 text-[6px] uppercase tracking-[0.14em]",t0(e.state,t)),children:"complete"===e.state?"Ready":"current"===e.state?"Active":"Pending"})]})},e.id))}),"system"===a?(0,s.jsx)(tq,{steps:ea,surfaceTheme:t,statusCopy:el,showDetails:ed,phaseLabel:eo,run:ei}):(0,s.jsx)(tK,{snapshot:e,surfaceTheme:t,statusCopy:el,showDetails:ed,phaseLabel:eo,run:ei,selectedModelId:p,availableModels:es.map(e=>({id:e.id,name:e.name,provider:e.provider})),discoveredModels:er,onSelectedModelIdChange:u,onRunModelDiscover:b,onRunModelRefresh:f,onRunModelSetDefault:w,onOpenAddModels:y})]}),(0,s.jsxs)("div",{className:(0,S.cn)("mt-auto flex flex-wrap items-center justify-between gap-1.5 border-t px-2.5 py-2 sm:px-3","light"===t?"border-[#ebddd2]":"border-white/8"),children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:["models"===a?(0,s.jsxs)(I,{type:"button",variant:"ghost",size:"sm",onClick:k,disabled:"running"===ei.runState,className:tY(t),children:[(0,s.jsx)(tU.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Back"]}):null,C?(0,s.jsx)("button",{type:"button",onClick:N,className:(0,S.cn)("text-[9px] uppercase tracking-[0.16em] transition-colors","light"===t?"text-[#8f7664] hover:text-[#6f5949]":"text-slate-500 hover:text-slate-300"),children:"Open demo surface"}):null]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:["models"!==a||ee?null:(0,s.jsx)(I,{type:"button",variant:"secondary",size:"sm",onClick:g,disabled:"running"===c.runState,className:tH(t),children:"running"===c.runState?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Working..."]}):"Auto configure"}),(0,s.jsx)(I,{type:"button",onClick:()=>{"system"===a?X&&ee?N():X?v():h():ee?N():"set-default"===ep.kind?w():g()},disabled:"running"===ei.runState,className:(0,S.cn)("h-8 min-w-[156px] rounded-full px-3 text-[11px]","light"===t?"bg-[#c8946f] text-white shadow-[0_14px_34px_rgba(200,148,111,0.24)] hover:bg-[#b88461]":"bg-white text-slate-950 hover:bg-white/92"),children:"running"===ei.runState?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.A,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Working..."]}):(0,s.jsxs)(s.Fragment,{children:[ep.label,(0,s.jsx)(tF.A,{className:"ml-1.5 h-3 w-3"})]})})]})]})]})})}function tq({steps:e,surfaceTheme:t,statusCopy:a,showDetails:r,phaseLabel:n,run:i}){let[l,o]=(0,g.useState)(!1);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"mt-3",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[7px] uppercase tracking-[0.18em]","light"===t?"text-[#977b69]":"text-slate-500"),children:"Step 1"}),(0,s.jsx)("h2",{className:(0,S.cn)("mt-1 text-[13px] font-medium","light"===t?"text-[#33251c]":"text-white"),children:"System setup"}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1 text-[10px] leading-[0.95rem]","light"===t?"text-[#705b4d]":"text-slate-400"),children:"Install the CLI, start the gateway, and verify RPC."})]}),(0,s.jsx)("div",{className:"mt-2.5 space-y-1.5",children:e.map((e,a)=>(0,s.jsxs)("div",{className:(0,S.cn)("flex items-center gap-1.5 rounded-[12px] border px-2 py-1.5",tZ(e.state,t)),children:[(0,s.jsx)("span",{className:(0,S.cn)("mt-0.5 inline-flex h-5 w-5 items-center justify-center rounded-full border text-[9px] font-medium",tX(e.state,t)),children:"complete"===e.state?(0,s.jsx)(j.A,{className:"h-2.5 w-2.5"}):a+1}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-1.5",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[11px]","light"===t?"text-[#3e2f24]":"text-white"),children:e.label}),(0,s.jsx)("span",{className:(0,S.cn)("rounded-full px-1.5 py-0.5 text-[6px] uppercase tracking-[0.14em]",t0(e.state,t)),children:"complete"===e.state?"Ready":"current"===e.state?"Active":"Pending"})]}),(0,s.jsx)("p",{className:(0,S.cn)("mt-0.5 text-[8px] leading-[0.82rem]","light"===t?"text-[#8f7664]":"text-slate-500"),children:e.description})]})]},e.id))}),(0,s.jsx)(tG,{surfaceTheme:t,statusCopy:a,showDetails:r,phaseLabel:n,detailsOpen:l,onDetailsOpenChange:o,run:i})]})}function tK({snapshot:e,surfaceTheme:t,statusCopy:a,showDetails:r,phaseLabel:i,run:l,selectedModelId:o,availableModels:d,discoveredModels:c,onSelectedModelIdChange:p,onRunModelDiscover:m,onRunModelRefresh:u,onRunModelSetDefault:h,onOpenAddModels:x}){let b=e.diagnostics.modelReadiness,[f,w]=(0,g.useState)(()=>c.length>0),y=b.authProviders.filter(e=>e.connected),v=tV(o,d),j=b.resolvedDefaultModel||b.defaultModel||"Not set",k=o?`Selected: ${v??j}`:`Default: ${j}`,N=`${k} \xb7 ${b.availableModelCount}/${b.totalModelCount} routes \xb7 ${y.length} connected`,C=b.issues.length>0||y.length>0||c.length>0;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"mt-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[7px] uppercase tracking-[0.18em]","light"===t?"text-[#977b69]":"text-slate-500"),children:"Step 2"}),(0,s.jsx)("h2",{className:(0,S.cn)("mt-1 text-[13px] font-medium","light"===t?"text-[#33251c]":"text-white"),children:"Model setup"})]}),(0,s.jsxs)(I,{type:"button",variant:"secondary",size:"sm",onClick:u,disabled:"running"===l.runState,className:tH(t),children:[(0,s.jsx)(n.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Refresh"]})]}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1 text-[10px] leading-[0.95rem]","light"===t?"text-[#705b4d]":"text-slate-400"),children:"Pick the default model."})]}),(0,s.jsxs)("div",{className:(0,S.cn)("mt-2.5 rounded-[12px] border px-2.5 py-2.5","light"===t?"border-[#e5d5c9] bg-[#fffaf6]":"border-white/8 bg-[rgba(255,255,255,0.02)]"),children:[(0,s.jsxs)("label",{className:"block",children:[(0,s.jsx)("span",{className:(0,S.cn)("text-[7px] uppercase tracking-[0.16em]","light"===t?"text-[#977b69]":"text-slate-500"),children:"Default model"}),(0,s.jsxs)("select",{value:o,onChange:e=>p(e.target.value),className:(0,S.cn)("mt-1.5 h-9 w-full rounded-[12px] border px-2.5 text-[11px] outline-none","light"===t?"border-[#dccabd] bg-white text-[#33251c]":"border-white/10 bg-white/[0.04] text-slate-100"),children:[(0,s.jsx)("option",{value:"",children:"Auto choose"}),d.map(e=>(0,s.jsxs)("option",{value:e.id,children:[e.name," \xb7 ",e.provider]},e.id))]})]}),(0,s.jsxs)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[(0,s.jsxs)(I,{type:"button",variant:"secondary",size:"sm",onClick:x,className:tH(t),children:[(0,s.jsx)(eu.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Add models"]}),(0,s.jsx)(I,{type:"button",variant:"secondary",size:"sm",onClick:()=>{w(!0),m()},disabled:"running"===l.runState,className:tH(t),children:c.length>0?"Scan again":"Discover models"}),C?(0,s.jsx)(I,{type:"button",variant:"ghost",size:"sm",onClick:()=>w(e=>!e),"aria-expanded":f,className:tY(t),children:f?"Hide details":"Show details"}):null]}),(0,s.jsx)("p",{className:(0,S.cn)("mt-2 text-[9px] leading-[0.95rem]","light"===t?"text-[#705b4d]":"text-slate-500"),children:N}),f?(0,s.jsxs)("div",{className:"mt-2.5 space-y-2",children:[b.issues.length>0?(0,s.jsx)("div",{className:"space-y-1",children:b.issues.map(e=>(0,s.jsx)("p",{className:(0,S.cn)("rounded-[10px] border px-2 py-1.5 text-[9px] leading-[0.85rem]","light"===t?"border-amber-200 bg-amber-50 text-amber-800":"border-amber-300/20 bg-amber-300/10 text-amber-100"),children:e},e))}):null,y.length>0?(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5",children:y.map(e=>(0,s.jsxs)("span",{className:(0,S.cn)("rounded-full border px-2 py-0.5 text-[9px]","light"===t?"border-emerald-200 bg-emerald-50 text-emerald-700":"border-emerald-300/20 bg-emerald-300/10 text-emerald-200"),children:[tQ(e.provider),e.detail?` \xb7 ${e.detail}`:""]},e.provider))}):null,c.length>0?(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[7px] uppercase tracking-[0.16em]","light"===t?"text-[#977b69]":"text-slate-500"),children:"Routes"}),(0,s.jsx)("div",{className:"space-y-1.5",children:c.slice(0,3).map(e=>(0,s.jsxs)("div",{className:(0,S.cn)("flex items-center justify-between gap-2 rounded-[12px] border px-2 py-1.5","light"===t?"border-[#eadcd0] bg-[#fff7f2]":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:(0,S.cn)("truncate text-[10px]","light"===t?"text-[#3e2f24]":"text-white"),children:e.name}),(0,s.jsxs)("p",{className:(0,S.cn)("mt-0.5 text-[8px] leading-[0.85rem]","light"===t?"text-[#8f7664]":"text-slate-500"),children:[tQ(e.provider),e.isFree?" \xb7 free":"",e.supportsTools?" \xb7 tools":""]})]}),(0,s.jsx)(I,{type:"button",variant:"secondary",size:"sm",onClick:()=>h(e.modelId),disabled:"running"===l.runState,className:tH(t),children:"Use"})]},e.modelId))}),(0,s.jsx)("p",{className:(0,S.cn)("text-[9px] leading-[0.95rem]","light"===t?"text-[#705b4d]":"text-slate-500"),children:"Configured routes only. Missing credentials will hand you off to OpenClaw."})]}):null]}):null]}),(0,s.jsx)(tG,{surfaceTheme:t,statusCopy:a,showDetails:r,phaseLabel:i,detailsOpen:f,onDetailsOpenChange:w,run:l})]})}function tG({surfaceTheme:e,statusCopy:t,showDetails:a,phaseLabel:r,detailsOpen:n,onDetailsOpenChange:l,run:o}){let[d,c]=(0,g.useState)(!1),p=!!o.manualCommand?.trim().startsWith("openclaw "),m=async()=>{if(o.manualCommand)try{await navigator.clipboard.writeText(o.manualCommand),el.o.success("Command copied.",{description:"Open Terminal and paste it."})}catch(e){el.o.error("Could not copy command.",{description:e instanceof Error?e.message:"Clipboard access is unavailable."})}},u=async()=>{if(o.manualCommand&&p){c(!0);try{let e=await fetch("/api/system/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({command:o.manualCommand})}),t=await e.json().catch(()=>null);if(!e.ok||t?.error)throw Error(t?.error||"Unable to open Terminal.");el.o.success("Terminal opened.",{description:"Finish auth there, then refresh."})}catch(e){el.o.error("Could not open Terminal.",{description:e instanceof Error?e.message:"Open Terminal manually and run the command."})}finally{c(!1)}}};return(0,s.jsxs)("div",{className:(0,S.cn)("mt-2.5 rounded-[12px] border","light"===e?"border-[#e5d5c9] bg-[#fffaf6]":"border-white/8 bg-[rgba(255,255,255,0.02)]"),children:[(0,s.jsxs)("div",{className:"px-2.5 py-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[7px] uppercase tracking-[0.16em]","light"===e?"text-[#977b69]":"text-slate-500"),children:"Status"}),a?(0,s.jsx)("button",{type:"button",onClick:()=>l(!n),className:(0,S.cn)("text-[8px] uppercase tracking-[0.16em] transition-colors","light"===e?"text-[#8f7664] hover:text-[#6f5949]":"text-slate-500 hover:text-slate-300"),children:n?"Hide details":"Show details"}):null]}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1 text-[11px] leading-[1rem]","light"===e?"text-[#5f4b3e]":"text-slate-300"),children:t})]}),a&&n?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:(0,S.cn)("flex items-center justify-between border-y px-2.5 py-1.5","light"===e?"border-[#ebddd2]":"border-white/8"),children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[8px] uppercase tracking-[0.16em]","light"===e?"text-[#977b69]":"text-slate-500"),children:"Log"}),(0,s.jsx)("span",{className:"light"===e?"text-[10px] text-[#8c7362]":"text-[10px] text-slate-400",children:r})]}),(0,s.jsx)("pre",{className:(0,S.cn)("max-h-[120px] min-h-[68px] overflow-auto whitespace-pre-wrap break-words px-2.5 py-2 font-mono text-[8px] leading-[0.82rem]","light"===e?"text-[#4f3d31]":"text-slate-200"),children:o.log||"No output yet.\n\nStart the step to stream logs."}),o.manualCommand?(0,s.jsxs)("div",{className:(0,S.cn)("border-t px-2.5 py-2","light"===e?"border-[#ebddd2]":"border-white/8"),children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[8px] uppercase tracking-[0.16em]","light"===e?"text-[#977b69]":"text-slate-500"),children:p?"Terminal":"Manual"}),p?(0,s.jsx)("p",{className:(0,S.cn)("mt-1 text-[9px] leading-[0.95rem]","light"===e?"text-[#705b4d]":"text-slate-400"),children:"Open Terminal and run this command."}):null,(0,s.jsx)("p",{className:(0,S.cn)("mt-1 break-all font-mono text-[9px] leading-[0.92rem]","light"===e?"text-[#4f3d31]":"text-slate-200"),children:o.manualCommand}),(0,s.jsxs)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[(0,s.jsxs)(I,{type:"button",variant:"secondary",size:"sm",onClick:m,className:tH(e),children:[(0,s.jsx)(f.A,{className:"mr-1.5 h-3 w-3"}),"Copy command"]}),p?(0,s.jsx)(I,{type:"button",variant:"secondary",size:"sm",onClick:u,disabled:d,className:tH(e),children:d?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.A,{className:"mr-1.5 h-3 w-3 animate-spin"}),"Opening..."]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(b.A,{className:"mr-1.5 h-3 w-3"}),"Open Terminal"]})}):null]}),o.docsUrl?(0,s.jsxs)("a",{href:o.docsUrl,target:"_blank",rel:"noreferrer",className:(0,S.cn)("mt-2 inline-flex items-center gap-1 text-[9px] underline underline-offset-4","light"===e?"text-[#7f6554]":"text-slate-300"),children:["Setup docs",(0,s.jsx)(tF.A,{className:"h-2.5 w-2.5"})]}):null]}):null]}):null]})}function tV(e,t){if(!e.trim())return null;let a=t.find(t=>t.id===e);return a?.name||(0,eb.JZ)(e)}function tJ(e,t){return e?"complete":t?"current":"pending"}function tH(e){return"light"===e?"border-[#b89374] bg-[#ecd4c1] text-[#4a3426] shadow-[inset_0_1px_0_rgba(255,255,255,0.55)] hover:bg-[#e4c6af] hover:text-[#38261b]":"border-white/10 bg-white/[0.05] text-slate-200 hover:bg-white/[0.1]"}function tY(e){return"light"===e?"border border-[#d7bca7] bg-[#f8ede4] text-[#5a4131] hover:bg-[#eedbcc] hover:text-[#3f2d21]":"text-slate-500 hover:bg-white/[0.08] hover:text-slate-200"}function tQ(e){let t=e.trim().toLowerCase();return"openrouter"===t?"OpenRouter":"openai-codex"===t?"OpenAI Codex":"openai"===t?"OpenAI":"anthropic"===t?"Anthropic":"ollama"===t?"Ollama":"xai"===t?"xAI":"gemini"===t?"Gemini":"deepseek"===t?"DeepSeek":"mistral"===t?"Mistral":e.split("-").map(e=>e?e[0].toUpperCase()+e.slice(1):e).join(" ")}function tZ(e,t){return"complete"===e?"light"===t?"border-emerald-200 bg-emerald-50/60":"border-emerald-400/20 bg-emerald-400/8":"current"===e?"light"===t?"border-[#d9c2b3] bg-white/70":"border-white/12 bg-white/[0.05]":"light"===t?"border-[#eadcd0] bg-[#fffaf6]/80":"border-white/6 bg-white/[0.02]"}function tX(e,t){return"complete"===e?"light"===t?"border-emerald-300 bg-emerald-100 text-emerald-700":"border-emerald-300/25 bg-emerald-300/10 text-emerald-200":"current"===e?"light"===t?"border-[#d5b9a5] bg-[#f5ebe3] text-[#8b6d5a]":"border-white/12 bg-white/[0.06] text-white":"light"===t?"border-[#e1ccc0] bg-white text-[#9a7f6c]":"border-white/8 bg-white/[0.03] text-slate-400"}function t0(e,t){return"complete"===e?"light"===t?"bg-emerald-100 text-emerald-700":"bg-emerald-300/10 text-emerald-200":"current"===e?"light"===t?"bg-[#efe1d4] text-[#876c5a]":"bg-white/[0.06] text-slate-300":"light"===t?"bg-[#f6ece4] text-[#a08471]":"bg-white/[0.04] text-slate-500"}var t1=a(2820),t2=a(7262),t5=a(5084);function t3({open:e,target:t,surfaceTheme:a,previewState:r,preview:n,previewError:l,runState:d,statusMessage:c,resultMessage:p,backgroundLogPath:m,log:u,confirmText:h,onConfirmTextChange:x,onRefreshPreview:g,onExecute:b,onOpenChange:f}){let w="full-uninstall"===t?"FULL UNINSTALL":"RESET MISSION CONTROL",y="running"===d,v="success"===d||"error"===d,j=null!==t&&"ready"===r&&!y&&!v&&h.trim()===w,k="full-uninstall"===t?"Full Uninstall":"Reset Mission Control",N="light"===a?"border-rose-400/80 bg-rose-600 text-white hover:bg-rose-700":"border-rose-400/35 bg-rose-500/90 text-white hover:bg-rose-500";return(0,s.jsx)(Y,{open:e,onOpenChange:e=>{(e||!y)&&f(e)},children:(0,s.jsxs)(ee,{className:(0,S.cn)("max-h-[88vh] w-[min(92vw,56rem)] max-w-[92vw] min-w-0 overflow-x-hidden overflow-y-auto sm:max-w-3xl","light"===a?"border-[#dcc8bb] bg-[rgba(252,247,241,0.98)] text-[#402f24]":"border-white/12 bg-[rgba(7,12,22,0.96)] text-slate-100"),children:[(0,s.jsxs)(et,{children:[(0,s.jsxs)(es,{className:(0,S.cn)("flex items-center gap-2","light"===a?"text-[#3f2f24]":"text-white"),children:["full-uninstall"===t?(0,s.jsx)(t1.A,{className:"h-4 w-4"}):(0,s.jsx)(t2.A,{className:"h-4 w-4"}),k]}),(0,s.jsx)(er,{className:"light"===a?"text-[#7e6555]":"text-slate-400",children:"full-uninstall"===t?"Remove Mission Control state, OpenClaw service and local state, then attempt to remove detected OpenClaw and AgentOS packages.":"Remove Mission Control-managed workspaces, attached agents, planner state, and browser state."})]}),"loading"===r?(0,s.jsxs)("div",{className:(0,S.cn)("flex items-center gap-2 rounded-[16px] border px-4 py-4 text-sm","light"===a?"border-[#e6d6ca] bg-white":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsx)(i.A,{className:"h-4 w-4 animate-spin"}),"Loading the reset preview..."]}):null,"error"===r?(0,s.jsxs)("div",{className:(0,S.cn)("rounded-[16px] border px-4 py-4","light"===a?"border-rose-200 bg-rose-50 text-rose-900":"border-rose-400/25 bg-rose-500/10 text-rose-100"),children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:"Preview could not be prepared."}),(0,s.jsx)("p",{className:"mt-1 text-sm",children:l||"Unknown reset preview error."})]}):null,n?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"grid gap-3 md:grid-cols-4",children:[(0,s.jsx)(t4,{label:"Delete folders",value:String(n.summary.deleteFolderCount),surfaceTheme:a}),(0,s.jsx)(t4,{label:"Keep folders",value:String(n.summary.metadataOnlyCount),surfaceTheme:a}),(0,s.jsx)(t4,{label:"Agents",value:String(n.summary.agentCount),surfaceTheme:a}),(0,s.jsx)(t4,{label:"Live agents",value:String(n.summary.liveAgentCount),surfaceTheme:a,danger:n.summary.liveAgentCount>0})]}),n.warnings.length>0?(0,s.jsx)("div",{className:(0,S.cn)("mt-3 rounded-[16px] border px-4 py-4","light"===a?"border-amber-300/90 bg-amber-50 text-amber-950":"border-amber-300/25 bg-amber-300/10 text-amber-50"),children:(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)(o.A,{className:"mt-0.5 h-4 w-4 shrink-0"}),(0,s.jsx)("div",{className:"space-y-1 text-sm",children:n.warnings.map(e=>(0,s.jsx)("p",{children:e},e))})]})}):null,(0,s.jsxs)("div",{className:(0,S.cn)("mt-3 rounded-[16px] border px-4 py-4","light"===a?"border-[#e6d6ca] bg-white":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:(0,S.cn)("text-xs uppercase tracking-[0.18em]","light"===a?"text-[#9a7f6c]":"text-slate-500"),children:"Workspace impact"}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1 text-sm","light"===a?"text-[#6d5647]":"text-slate-400"),children:"`Delete folder` removes the workspace directory. `Keep folder` only removes OpenClaw and Mission Control integration from that location."})]}),(0,s.jsx)(I,{type:"button",size:"sm",variant:"secondary",onClick:g,className:"light"===a?"border-[#dcc6b6] bg-white text-[#5d4739] hover:bg-[#f7eee7] hover:text-[#5d4739]":void 0,children:"Refresh preview"})]}),(0,s.jsx)("div",{className:"mt-3 space-y-2",children:n.workspaces.map(e=>(0,s.jsxs)("div",{className:(0,S.cn)("rounded-[14px] border px-3 py-3","light"===a?"border-[#ece0d6] bg-[#fffaf6]":"border-white/8 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:(0,S.cn)("text-sm font-medium","light"===a?"text-[#3f2f24]":"text-white"),children:e.name}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1 break-all font-mono text-[11px]","light"===a?"text-[#7e6555]":"text-slate-400"),children:e.path})]}),(0,s.jsx)("span",{className:(0,S.cn)("rounded-full border px-2 py-0.5 text-[10px] uppercase tracking-[0.16em]","delete-folder"===e.action?"light"===a?"border-rose-300 bg-rose-50 text-rose-700":"border-rose-400/25 bg-rose-500/10 text-rose-200":"light"===a?"border-amber-300 bg-amber-50 text-amber-700":"border-amber-300/25 bg-amber-300/10 text-amber-200"),children:"delete-folder"===e.action?"Delete folder":"Keep folder"})]}),(0,s.jsxs)("p",{className:(0,S.cn)("mt-2 text-xs","light"===a?"text-[#6d5647]":"text-slate-400"),children:[e.agentCount," agents, ",e.runtimeCount," tracked runs, ",e.liveAgentCount," live agents."]}),(0,s.jsx)("div",{className:"mt-2 space-y-1",children:e.reasons.map(e=>(0,s.jsx)("p",{className:(0,S.cn)("text-xs","light"===a?"text-[#7e6555]":"text-slate-500"),children:e},e))})]},e.workspaceId))})]}),(0,s.jsxs)("div",{className:"mt-3 grid gap-3 md:grid-cols-2",children:[(0,s.jsx)(t8,{title:"Mission Control state",items:n.missionControlPaths,surfaceTheme:a}),(0,s.jsx)(t8,{title:"Browser state",items:n.browserStorageKeys,surfaceTheme:a})]}),"full-uninstall"===t?(0,s.jsxs)("div",{className:"mt-3 grid gap-3 md:grid-cols-2",children:[(0,s.jsx)(t8,{title:"OpenClaw state",items:n.openClawPaths,surfaceTheme:a}),(0,s.jsxs)("div",{className:(0,S.cn)("rounded-[16px] border px-4 py-4","light"===a?"border-[#e6d6ca] bg-white":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsx)("p",{className:(0,S.cn)("text-xs uppercase tracking-[0.18em]","light"===a?"text-[#9a7f6c]":"text-slate-500"),children:"Package cleanup"}),(0,s.jsx)("div",{className:"mt-3 space-y-2",children:n.packageActions.map(e=>(0,s.jsxs)("div",{className:(0,S.cn)("min-w-0 overflow-hidden rounded-[14px] border px-3 py-3","light"===a?"border-[#ece0d6] bg-[#fffaf6]":"border-white/8 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,s.jsx)("p",{className:(0,S.cn)("min-w-0 break-all text-sm font-medium","light"===a?"text-[#3f2f24]":"text-white"),children:e.packageName}),(0,s.jsx)("span",{className:(0,S.cn)("shrink-0 rounded-full border px-2 py-0.5 text-[10px] uppercase tracking-[0.16em]",e.detected?"light"===a?"border-rose-300 bg-rose-50 text-rose-700":"border-rose-400/25 bg-rose-500/10 text-rose-200":"light"===a?"border-[#dcc6b6] bg-[#f4e8dd] text-[#876c5a]":"border-white/10 bg-white/[0.05] text-slate-300"),children:e.detected?"Scheduled":"Manual"})]}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1 break-words text-xs","light"===a?"text-[#6d5647]":"text-slate-400"),children:e.reason||"No extra detail."}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1 whitespace-pre-wrap break-all font-mono text-[11px]","light"===a?"text-[#7e6555]":"text-slate-500"),children:e.command||"Automatic package removal is not available."})]},e.packageName))})]})]}):null,(0,s.jsxs)("div",{className:(0,S.cn)("mt-3 rounded-[16px] border px-4 py-4","light"===a?"border-rose-200 bg-rose-50/70 text-rose-950":"border-rose-400/25 bg-rose-500/10 text-rose-50"),children:[(0,s.jsxs)(e$,{htmlFor:"reset-confirm",className:"text-sm font-medium text-inherit",children:["Type ",w," to continue"]}),(0,s.jsx)(T,{id:"reset-confirm",value:h,onChange:e=>x(e.target.value),placeholder:w,disabled:y,className:(0,S.cn)("mt-2 h-10","light"===a?"border-rose-200 bg-white text-rose-950 placeholder:text-rose-300":"border-rose-300/20 bg-slate-950/50 text-rose-50 placeholder:text-rose-200/35")})]})]}):null,"idle"!==d||p||u?(0,s.jsxs)("div",{className:(0,S.cn)("min-w-0 overflow-hidden rounded-[16px] border px-4 py-4","error"===d?"light"===a?"border-rose-200 bg-rose-50 text-rose-950":"border-rose-400/25 bg-rose-500/10 text-rose-50":"success"===d?"light"===a?"border-emerald-200 bg-emerald-50 text-emerald-950":"border-emerald-400/25 bg-emerald-500/10 text-emerald-50":"light"===a?"border-[#e6d6ca] bg-white text-[#3f2f24]":"border-white/10 bg-white/[0.03] text-slate-100"),children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:c||p||"Reset status"}),p?(0,s.jsx)("p",{className:"mt-1 text-sm",children:p}):null,m?(0,s.jsxs)("p",{className:"mt-2 break-all font-mono text-[11px]",children:["Background cleanup log: ",m]}):null,(0,s.jsx)("pre",{className:(0,S.cn)("mt-3 max-h-56 w-full max-w-full overflow-x-hidden overflow-y-auto whitespace-pre-wrap break-words rounded-[14px] border px-3 py-3 text-[11px] leading-relaxed","light"===a?"border-[#e6d6ca] bg-[#fffaf6] text-[#5f4a3d]":"border-white/10 bg-slate-950/45 text-slate-300"),children:u||"Waiting for command output..."})]}):null,(0,s.jsxs)(ea,{children:[(0,s.jsx)(I,{type:"button",variant:v?"default":"secondary",onClick:()=>f(!1),disabled:y,className:v&&"light"===a?"bg-[#5c4437] text-white hover:bg-[#4d382d]":v?"bg-cyan-400 text-slate-950 hover:bg-cyan-300":void 0,children:v?"Done":"Close"}),v?null:(0,s.jsx)(I,{type:"button",onClick:b,disabled:!j,className:N,children:y?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Running..."]}):(0,s.jsxs)(s.Fragment,{children:["full-uninstall"===t?(0,s.jsx)(t1.A,{className:"mr-1.5 h-3.5 w-3.5"}):(0,s.jsx)(t5.A,{className:"mr-1.5 h-3.5 w-3.5"}),k]})})]})]})})}function t4({label:e,value:t,surfaceTheme:a,danger:r=!1}){return(0,s.jsxs)("div",{className:(0,S.cn)("rounded-[16px] border px-4 py-3",r?"light"===a?"border-rose-200 bg-rose-50":"border-rose-400/20 bg-rose-500/10":"light"===a?"border-[#e6d6ca] bg-white":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[11px] uppercase tracking-[0.16em]","light"===a?"text-[#9a7f6c]":"text-slate-500"),children:e}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1 font-display text-lg","light"===a?"text-[#3f2f24]":"text-white"),children:t})]})}function t8({title:e,items:t,surfaceTheme:a}){return(0,s.jsxs)("div",{className:(0,S.cn)("rounded-[16px] border px-4 py-4","light"===a?"border-[#e6d6ca] bg-white":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsx)("p",{className:(0,S.cn)("text-xs uppercase tracking-[0.18em]","light"===a?"text-[#9a7f6c]":"text-slate-500"),children:e}),(0,s.jsx)("div",{className:"mt-3 space-y-2",children:t.map(e=>(0,s.jsx)("p",{className:(0,S.cn)("break-all rounded-[12px] border px-3 py-2 font-mono text-[11px]","light"===a?"border-[#ece0d6] bg-[#fffaf6] text-[#6d5647]":"border-white/8 bg-white/[0.03] text-slate-400"),children:e},e))})]})}var t6=a(7101),t9=a(3633),t7=a(3324),ae=a(736),at=a(8482),aa=a(8072),as=a(474);function ar({snapshot:e,surfaceTheme:t,activeWorkspaceId:a,requestedAgentAction:r,connectionState:l,collapsed:d,modelManager:c,onToggleCollapsed:p,onSelectWorkspace:m,onRefresh:h,onRunModelRefresh:x,onRunModelDiscover:b,onRunModelSetDefault:f,onConnectModelProvider:w,onOpenModelSetup:y,onOpenAddModels:v,onEditWorkspace:j,onSnapshotChange:N}){var C;let[A,M]=(0,g.useState)(!1),O=(0,eb.iD)(e.diagnostics.health),R="healthy"===e.diagnostics.health?"bg-emerald-300":"degraded"===e.diagnostics.health?"bg-amber-200":"bg-rose-300",$=e.diagnostics.gatewayUrl.replace(/^wss?:\/\//,"").replace(/\/$/,""),[E,D]=(0,g.useState)(!1),[_,P]=(0,g.useState)(!1),[L,U]=(0,g.useState)(!1),[F,z]=(0,g.useState)(!1),[B,q]=(0,g.useState)(!1),[K,G]=(0,g.useState)(!1),[V,J]=(0,g.useState)(!1),[H,Q]=(0,g.useState)(null),[Z,X]=(0,g.useState)([]),[en,ei]=(0,g.useState)(null),[eo,ed]=(0,g.useState)(""),[ec,ep]=(0,g.useState)(null),[em,eu]=(0,g.useState)(""),[eh,ex]=(0,g.useState)("workspaces"),[ef,ew]=(0,g.useState)(""),ey=(0,g.useRef)(null),ev=(0,g.useMemo)(()=>e.agents.filter(e=>!a||e.workspaceId===a).sort((e,t)=>e.workspaceId!==t.workspaceId?e.workspaceId.localeCompare(t.workspaceId):(0,eb.CK)(e).localeCompare((0,eb.CK)(t))),[e.agents,a]),ej=e.workspaces.find(e=>e.id===a)??e.workspaces[0]??null,ek=(0,g.useMemo)(()=>e.models.filter(e=>!1!==e.available&&!e.missing),[e.models]),eN=(0,g.useMemo)(()=>c.discoveredModels.filter(t=>!e.models.some(e=>e.id===t.modelId)),[c.discoveredModels,e.models]),eC=ef&&(ek.some(e=>e.id===ef)||eN.some(e=>e.modelId===ef))?ef:(C=e).diagnostics.modelReadiness.resolvedDefaultModel||C.diagnostics.modelReadiness.defaultModel||C.models.find(e=>!1!==e.available&&!e.missing)?.id||"",eS=!!H&&(_||"monitoring"===H.policy.preset),eA=()=>{A&&M(!1),d&&p()},eI=[{id:"overview",label:"Overview",icon:t6.A},{id:"workspaces",label:"Workspaces",icon:t9.A,badge:String(e.workspaces.length)},{id:"agents",label:"Agents",icon:t7.A,badge:String(ev.length)},{id:"models",label:"Models",icon:te.A,badge:String(e.models.length)}],eT=(0,g.useMemo)(()=>en?e.agents.filter(e=>e.workspaceId===en.id):[],[en,e.agents]),eM=(0,g.useMemo)(()=>eT.filter(e=>"engaged"===e.status||"monitoring"===e.status||"ready"===e.status),[eT]),eO=(0,g.useMemo)(()=>en?e.runtimes.filter(e=>e.workspaceId===en.id):[],[en,e.runtimes]),eR=(0,g.useMemo)(()=>ec?e.runtimes.filter(e=>e.agentId===ec.id):[],[ec,e.runtimes]),e$=ec?e.workspaces.find(e=>e.id===ec.workspaceId)??null:null,eE=!!ec&&("engaged"===ec.status||"monitoring"===ec.status||"ready"===ec.status),e_=(0,g.useCallback)(e=>{ep(e),eu(""),G(!0)},[]),eq=e=>{D(e),e||(Q(null),X([]),P(!1))},eK=(0,g.useCallback)(t=>{var a,s;let r=(a=t.workspaceId,s=t.id,eD(e,a).filter(e=>e.primaryAgentId===s||e.workspaces.some(e=>e.workspaceId===a&&(e.agentIds.includes(s)||e.groupAssignments.some(e=>!1!==e.enabled&&e.agentId===s)))).map(e=>e.id));Q({...function(e,t={}){let a=(0,eg.g0)(t.policy?.preset??"worker",t.policy),s=(0,eg.Cf)(a.preset),r=ez(a.preset,t.heartbeat);return{id:t.id??"",workspaceId:e,modelId:t.modelId??"",name:t.name??s.defaultName,emoji:t.emoji??s.defaultEmoji,theme:t.theme??s.defaultTheme,avatar:t.avatar??"",policy:a,heartbeat:r,channelIds:Array.from(new Set((t.channelIds??[]).filter(e=>"string"==typeof e&&!!e.trim())))}}(t.workspaceId,{id:t.id,modelId:"unassigned"===t.modelId?"":t.modelId,name:(0,eb.CK)(t),emoji:t.identity.emoji??"",theme:t.identity.theme??"",avatar:t.identity.avatar??"",policy:t.policy,heartbeat:ez(t.policy.preset,{enabled:t.heartbeat.enabled,every:t.heartbeat.every??void 0}),channelIds:r})}),X(r),P(!1),D(!0)},[e]);(0,g.useEffect)(()=>{if(!r||ey.current===r.requestId)return;let t=e.agents.find(e=>e.id===r.agentId);if(t){if(ey.current=r.requestId,"edit"===r.kind)return void eK(t);e_(t)}},[r,e.agents,e_,eK]);let eG=async()=>{if(!H)return;let t=e.workspaces.find(e=>e.id===H.workspaceId)??null;U(!0);let a=!1;try{let e=await fetch("/api/agents",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(H)}),s=await e.json();if(!e.ok||s.error)throw Error(s.error||"OpenClaw could not update the agent.");t&&await eP({workspaceId:H.workspaceId,workspacePath:t.path,agentId:H.id,currentChannelIds:Z,nextChannelIds:H.channelIds,onRegistryChange:N}),eq(!1),a=!0}catch(e){el.o.error("Agent update failed.",{description:e instanceof Error?e.message:"Unknown agent error."})}finally{U(!1)}a&&(h().catch(()=>{}),el.o.success("Agent updated in OpenClaw.",{description:H.id}))},eV=async()=>{if(!en)return;q(!0);let e=!1,t=en.path;try{let s=await fetch("/api/workspaces",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceId:en.id})}),r=await s.json();if(!s.ok||r.error)throw Error(r.error||"OpenClaw could not delete the workspace.");z(!1),ei(null),ed(""),m(a===en.id?null:a),t=r.workspacePath||en.path,e=!0}catch(e){el.o.error("Workspace deletion failed.",{description:e instanceof Error?e.message:"Unknown workspace error."})}finally{q(!1)}e&&(h().catch(()=>{}),el.o.success("Workspace deleted from OpenClaw.",{description:t}))},eJ=async()=>{if(!ec)return;J(!0);let e=!1,t=ec.id;try{let a=await fetch("/api/agents",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentId:ec.id})}),s=await a.json();if(!a.ok||s.error)throw Error(s.error||"OpenClaw could not delete the agent.");H?.id===ec.id&&eq(!1),G(!1),ep(null),eu(""),t=s.agentId||ec.id,e=!0}catch(e){el.o.error("Agent deletion failed.",{description:e instanceof Error?e.message:"Unknown agent error."})}finally{J(!1)}e&&(h().catch(()=>{}),el.o.success("Agent deleted from OpenClaw.",{description:t}))};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"relative flex h-full items-start overflow-visible",children:[(0,s.jsxs)("div",{className:(0,S.cn)("panel-surface panel-glow mission-ease-smooth relative flex h-full shrink-0 self-stretch flex-col items-center overflow-hidden px-1.5 py-2 transition-[max-height] duration-500",d?"w-full":"w-[60px] border-r border-white/[0.08]",A?"max-h-[164px]":"max-h-full"),children:[(0,s.jsx)(tc,{label:"Mission Control",side:"right",surfaceTheme:t,panelCollapsed:d,children:(0,s.jsx)("button",{type:"button","aria-label":d?"Open mission control":"Collapse mission control",onClick:()=>{d?eA():p()},className:"flex h-9 w-9 shrink-0 aspect-square items-center justify-center overflow-hidden rounded-[8px] border border-cyan-300/20 bg-cyan-400/[0.12] shadow-[0_10px_24px_rgba(34,211,238,0.18)]",children:(0,s.jsx)(W.default,{src:"/assets/logo.webp",alt:"",width:32,height:32,"aria-hidden":"true",className:"pointer-events-none h-full w-full select-none object-cover",priority:!0})})}),(0,s.jsx)("div",{className:(0,S.cn)("mission-ease-smooth mt-3.5 flex w-full flex-1 flex-col items-center gap-1 overflow-hidden transition-[max-height,opacity,transform] duration-500",A?"max-h-0 -translate-y-3 opacity-0 pointer-events-none":"max-h-[420px] translate-y-0 opacity-100"),children:eI.map(e=>(0,s.jsx)(an,{icon:e.icon,label:e.label,active:eh===e.id,surfaceTheme:t,panelCollapsed:d,tooltipSide:"right",onClick:()=>{(ex(e.id),d)?eA():eh===e.id&&p()}},e.id))}),(0,s.jsxs)("div",{className:"mt-auto flex w-full flex-col items-center gap-1 pb-1",children:[(0,s.jsxs)("div",{className:"flex flex-col items-center gap-1",children:[(0,s.jsx)(as.m,{tone:R,pulse:"healthy"===e.diagnostics.health}),d?(0,s.jsx)("p",{className:"text-[8px] uppercase tracking-[0.16em] text-slate-500",children:e.mode}):null]}),(0,s.jsx)(tc,{label:A?"Expand rail":"Collapse rail",side:"right",surfaceTheme:t,panelCollapsed:d,children:(0,s.jsx)("button",{type:"button","aria-label":A?"Expand rail":"Collapse rail",onClick:()=>{d||p(),M(e=>!e)},className:"inline-flex h-8 w-8 items-center justify-center rounded-[8px] border border-white/10 bg-white/[0.04] text-slate-300 transition-all hover:border-cyan-300/18 hover:bg-white/[0.08] hover:text-white",children:A?(0,s.jsx)(u.A,{className:"h-3.5 w-3.5"}):(0,s.jsx)(ae.A,{className:"h-3.5 w-3.5"})})})]})]}),(0,s.jsx)("div",{className:(0,S.cn)("panel-surface panel-glow mission-ease-smooth h-full min-w-0 flex-1 overflow-hidden rounded-none border border-white/[0.08] bg-[#04070e]/88 shadow-[0_28px_90px_rgba(0,0,0,0.42)] backdrop-blur-2xl transition-[opacity,transform] duration-500",d?"-translate-x-4 opacity-0 pointer-events-none":"translate-x-0 opacity-100",!d&&"border-l-0"),children:(0,s.jsxs)("div",{className:"mission-scroll flex h-full min-h-0 flex-col overflow-y-auto overscroll-contain",children:[(0,s.jsxs)("div",{className:"shrink-0 px-4 pb-3 pt-4",children:[(0,s.jsxs)("div",{className:"flex w-full items-baseline justify-center gap-2 whitespace-nowrap text-center",children:[(0,s.jsx)("span",{className:"font-display text-[14px] font-semibold tracking-[0.18em] text-slate-100",children:"AgentOS"}),(0,s.jsx)("span",{className:"text-[11px] font-medium text-slate-600",children:"|"}),(0,s.jsx)("span",{className:"font-display text-[10px] font-normal tracking-[0.18em] text-slate-500",children:"Mission Control"})]}),(0,s.jsx)("div",{className:"mt-3 h-px w-full bg-white/[0.08]"}),(0,s.jsxs)("div",{className:"mt-3 rounded-[18px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(13,20,34,0.98),rgba(6,10,18,0.96))] p-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(as.m,{tone:R,pulse:"healthy"===e.diagnostics.health}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[12px] font-medium capitalize",O),children:e.diagnostics.health}),(0,s.jsxs)("p",{className:"truncate text-[9px] uppercase tracking-[0.18em] text-slate-500",children:["live"===l?"online":l,(0,s.jsx)("span",{className:"mx-2 text-slate-600",children:"\xb7"}),$]})]})]}),e.diagnostics.issues.length>0?(0,s.jsx)("div",{className:"mt-2.5 rounded-[14px] border border-amber-400/15 bg-amber-400/[0.08] px-2.5 py-1.5 text-[11px] text-amber-100",children:e.diagnostics.issues[0]}):null,"offline"===e.diagnostics.health?(0,s.jsx)("div",{className:"mt-2.5",children:(0,s.jsxs)(I,{type:"button",variant:"secondary",size:"sm",onClick:y,className:"h-8 w-full justify-center rounded-none border-amber-300/20 bg-amber-300/10 px-3 text-[10px] text-amber-50 transition-all duration-200 hover:-translate-y-0.5 hover:border-amber-300/30 hover:bg-amber-300/16 hover:text-amber-50",children:[(0,s.jsx)(at.A,{className:"mr-1.5 h-3 w-3"}),"Open setup"]})}):null]}),(0,s.jsx)("div",{className:"mt-3 flex flex-wrap gap-1.5",children:eI.map(e=>(0,s.jsx)(ai,{label:e.label,badge:e.badge,active:eh===e.id,onClick:()=>ex(e.id)},e.id))})]}),(0,s.jsxs)("div",{className:"flex-1 space-y-6 p-4",children:["overview"===eh?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(al,{eyebrow:"Overview",title:"System summary",detail:"Current health, active focus, and runtime inventory."}),(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,s.jsx)(ao,{label:"Workspaces",value:String(e.workspaces.length)}),(0,s.jsx)(ao,{label:"Agents",value:String(e.agents.length)}),(0,s.jsx)(ao,{label:"Models",value:String(e.models.length)}),(0,s.jsx)(ao,{label:"Runs",value:String(e.runtimes.length)})]}),ej?(0,s.jsxs)("div",{className:"rounded-[22px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.9),rgba(6,10,18,0.88))] p-4",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"truncate font-display text-[15px] text-white",children:ej.name}),(0,s.jsx)("p",{className:"mt-1 truncate text-[10px] uppercase tracking-[0.22em] text-slate-500",children:ej.slug})]}),(0,s.jsx)(k.E,{variant:"muted",children:ej.health})]}),(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2 text-[10px] uppercase tracking-[0.16em] text-slate-400",children:[(0,s.jsxs)("span",{children:[ej.agentIds.length," agents"]}),(0,s.jsxs)("span",{children:[ej.modelIds.length," models"]}),(0,s.jsxs)("span",{children:[ej.activeRuntimeIds.length," runs"]})]}),(0,s.jsx)("p",{className:"mt-3 text-[12px] text-slate-400",children:function(e){let t=(0,eb.$7)(e),a=t.split("/").filter(Boolean).filter(e=>{var t;return t=e,!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t)});if(a.length<=3)return t;let s="~"===a[0]?"~/":"/";return`${s}…/${a.slice(-2).join("/")}`}(ej.path)})]}):null]}):null,"workspaces"===eh?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(al,{eyebrow:"Home",title:"Workspaces",detail:"Select, rename, or remove real OpenClaw workspaces.",action:(0,s.jsx)(I,{variant:"ghost",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",onClick:()=>m(null),children:"All"})}),(0,s.jsx)("div",{className:"space-y-3",children:e.workspaces.map(e=>{let t=e.id===a;return(0,s.jsxs)("div",{className:(0,S.cn)("rounded-[20px] border p-3.5 transition-all",t?"border-cyan-300/[0.35] bg-cyan-400/[0.08] shadow-[0_14px_40px_rgba(34,211,238,0.12)]":"border-white/[0.08] bg-white/[0.03] hover:bg-white/[0.05]"),children:[(0,s.jsx)("button",{type:"button",onClick:()=>m(t?null:e.id),className:"w-full text-left",children:(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"truncate font-display text-[15px] text-white",children:e.name}),(0,s.jsx)("p",{className:"mt-1 truncate text-[10px] uppercase tracking-[0.22em] text-slate-500",children:e.slug})]}),(0,s.jsx)(k.E,{variant:t?"default":"muted",children:e.health})]})}),(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2 text-[10px] uppercase tracking-[0.16em] text-slate-400",children:[(0,s.jsxs)("span",{children:[e.agentIds.length," agents"]}),(0,s.jsxs)("span",{children:[e.modelIds.length," models"]}),(0,s.jsxs)("span",{children:[e.activeRuntimeIds.length," runs"]})]}),(0,s.jsxs)("div",{className:"mt-3 flex items-center gap-2",children:[(0,s.jsx)(I,{variant:"secondary",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",onClick:()=>j(e.id),children:"Edit"}),(0,s.jsx)(I,{variant:"ghost",size:"sm",className:"h-8 rounded-full px-3 text-[11px] text-rose-200 hover:bg-rose-400/10 hover:text-rose-100",onClick:()=>{ei(e),ed(""),z(!0)},children:"Delete"})]})]},e.id)})})]}):null,"agents"===eh?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(al,{eyebrow:"Apps",title:"Agents",detail:"Create and tune live isolated OpenClaw operators.",action:(0,s.jsx)(eB,{snapshot:e,defaultWorkspaceId:a??e.workspaces[0]?.id??null,onRefresh:h,onSnapshotChange:N,trigger:(0,s.jsx)(I,{variant:"secondary",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",disabled:0===e.workspaces.length,children:"Add"})})}),(0,s.jsxs)("div",{className:"space-y-3",children:[0===ev.length?(0,s.jsx)("div",{className:"rounded-[18px] border border-white/[0.08] bg-white/[0.03] px-3.5 py-3 text-[12px] text-slate-400",children:"No agents are attached to this workspace yet."}):null,ev.map(t=>{let r=(0,eb.CK)(t);return(0,s.jsxs)("div",{className:"rounded-[18px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.9),rgba(8,13,24,0.84))] p-3.5",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("p",{className:"truncate text-[13px] font-medium text-white",children:[t.identity.emoji?`${t.identity.emoji} `:"",r]}),(0,s.jsx)("p",{className:"mt-1 truncate text-[10px] uppercase tracking-[0.22em] text-slate-500",children:t.id}),(0,s.jsxs)("div",{className:"mt-2 flex flex-wrap gap-2",children:[(0,s.jsx)(k.E,{variant:(0,eg.Cf)(t.policy.preset).badgeVariant,children:(0,eg._P)(t.policy.preset)}),(0,s.jsx)(k.E,{variant:"engaged"===t.status?"default":"muted",children:t.status})]})]}),(0,s.jsx)(ax,{agentName:r,onEdit:()=>eK(t),onDelete:()=>e_(t)})]}),(0,s.jsx)("div",{className:"mt-3 flex items-center gap-2",children:(0,s.jsx)("div",{className:"min-w-0 flex-1 rounded-full border border-white/[0.08] bg-white/[0.03] px-3 py-2 text-[10px] uppercase tracking-[0.16em] text-slate-400",children:(0,s.jsx)("span",{className:"truncate",children:"unassigned"===t.modelId?"default model":(0,eb.JZ)(t.modelId)})})}),a?null:(0,s.jsx)("p",{className:"mt-2 truncate text-[10px] uppercase tracking-[0.18em] text-slate-500",children:e.workspaces.find(e=>e.id===t.workspaceId)?.name||"Workspace"})]},t.id)})]})]}):null,"models"===eh?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(al,{eyebrow:"Models",title:"Models & providers",detail:"Connect providers, choose a default route, and manage live model readiness."}),(0,s.jsxs)("div",{className:"rounded-[20px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.9),rgba(8,13,24,0.84))] p-4",children:[(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Default"}),(0,s.jsx)("p",{className:"font-display text-[15px] text-white",children:e.diagnostics.modelReadiness.resolvedDefaultModel||e.diagnostics.modelReadiness.defaultModel||"Not set"}),(0,s.jsx)("p",{className:"text-[12px] leading-5 text-slate-400",children:"Connect providers, choose a default route, and keep live model readiness visible."})]}),(0,s.jsxs)("div",{className:"mt-4 grid gap-3 border-t border-white/[0.06] pt-4 sm:grid-cols-2",children:[(0,s.jsxs)("div",{className:"rounded-[16px] border border-white/[0.06] bg-white/[0.03] px-3 py-2.5",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-slate-500",children:"Providers"}),(0,s.jsxs)("p",{className:"mt-1.5 text-[13px] leading-5 text-white",children:[e.diagnostics.modelReadiness.authProviders.filter(e=>e.connected).length," ","connected"]})]}),(0,s.jsxs)("div",{className:"rounded-[16px] border border-white/[0.06] bg-white/[0.03] px-3 py-2.5",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-slate-500",children:"Routes"}),(0,s.jsxs)("p",{className:"mt-1.5 text-[13px] leading-5 text-white",children:[e.diagnostics.modelReadiness.availableModelCount,"/",e.diagnostics.modelReadiness.totalModelCount," available"]})]})]}),c.systemReady?null:(0,s.jsxs)("div",{className:"mt-4 rounded-[16px] border border-amber-400/15 bg-amber-400/[0.08] px-3 py-2.5",children:[(0,s.jsx)("p",{className:"text-[13px] font-medium text-amber-50",children:"Finish system setup first"}),(0,s.jsx)("p",{className:"mt-1.5 text-[12px] leading-5 text-amber-100/80",children:"Provider auth and model verification need a live OpenClaw gateway and writable runtime state."}),(0,s.jsx)("div",{className:"mt-3",children:(0,s.jsx)(I,{variant:"secondary",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",onClick:y,children:"Open setup"})})]}),(0,s.jsxs)("label",{className:"mt-4 block space-y-1 border-t border-white/[0.06] pt-4",children:[(0,s.jsx)("span",{className:"text-[10px] uppercase tracking-[0.18em] text-slate-500",children:"Default model"}),(0,s.jsxs)("select",{value:eC,onChange:e=>ew(e.target.value),className:"h-10 w-full rounded-[14px] border border-white/[0.08] bg-white/[0.04] px-3 text-[12px] text-slate-100 outline-none",children:[(0,s.jsx)("option",{value:"",children:"Auto choose"}),ek.map(e=>(0,s.jsxs)("option",{value:e.id,children:[e.name," \xb7 ",e.provider]},e.id))]})]}),(0,s.jsxs)("div",{className:"mt-4 grid gap-2",children:[(0,s.jsx)(I,{variant:"secondary",size:"sm",className:"h-8 w-full justify-center rounded-full px-3 text-[11px]",disabled:!c.systemReady||"running"===c.runState,onClick:()=>f(eC||void 0),children:"running"===c.runState?"Working...":"Use selected model"}),(0,s.jsx)(I,{variant:"ghost",size:"sm",className:"h-8 w-full justify-center rounded-full px-3 text-[11px]",disabled:!c.systemReady||"running"===c.runState,onClick:b,children:"Discover routes"})]})]}),(0,s.jsxs)("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[(0,s.jsx)(I,{variant:"secondary",size:"sm",className:"h-8 w-full justify-center rounded-full px-3 text-[11px]",onClick:v,children:"Add models"}),(0,s.jsxs)(I,{variant:"ghost",size:"sm",className:"h-8 w-full justify-center rounded-full px-3 text-[11px]",disabled:"running"===c.runState,onClick:x,children:["running"===c.runState?(0,s.jsx)(i.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(n.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Refresh"]})]}),(0,s.jsx)("div",{className:"space-y-3",children:e.diagnostics.modelReadiness.authProviders.map(e=>(0,s.jsx)(ad,{provider:e,disabled:!c.systemReady||"running"===c.runState,onConnect:()=>w(e.provider)},e.provider))}),eN.length>0?(0,s.jsxs)("div",{className:"rounded-[20px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.9),rgba(8,13,24,0.84))] p-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-display text-[15px] text-white",children:"Discovered routes"}),(0,s.jsx)("p",{className:"mt-1 text-[12px] leading-5 text-slate-400",children:"Newly detected remote routes that are not configured in the current model deck yet."})]}),(0,s.jsx)(k.E,{variant:"muted",children:eN.length})]}),(0,s.jsx)("div",{className:"mt-3 space-y-2",children:eN.slice(0,6).map(e=>(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-[14px] border border-white/[0.08] bg-white/[0.03] px-3 py-2.5",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"truncate text-[13px] font-medium text-white",children:e.name}),(0,s.jsxs)("p",{className:"mt-1 text-[10px] uppercase tracking-[0.18em] text-slate-500",children:[ac(e.provider),e.isFree?" \xb7 free":"",e.supportsTools?" \xb7 tools":""]})]}),(0,s.jsx)(I,{variant:"secondary",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",disabled:!c.systemReady||"running"===c.runState,onClick:()=>f(e.modelId),children:"Use"})]},e.modelId))})]}):null,(0,s.jsx)("div",{className:"space-y-3",children:e.models.slice(0,8).map(e=>(0,s.jsxs)("div",{className:"rounded-[18px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.9),rgba(8,13,24,0.84))] px-3.5 py-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"truncate text-[13px] font-medium text-white",children:(0,eb.JZ)(e.id)}),(0,s.jsx)("p",{className:"mt-1 text-[10px] uppercase tracking-[0.22em] text-slate-500",children:e.provider})]}),(0,s.jsx)(k.E,{variant:e.local?"success":e.missing?"danger":"muted",children:e.local?"local":e.missing?"missing":"remote"})]}),(0,s.jsxs)("div",{className:"mt-3 flex items-center justify-between text-[11px] text-slate-400",children:[(0,s.jsxs)("span",{children:[(0,eb.FO)(e.contextWindow)," ctx"]}),(0,s.jsxs)("span",{children:[e.usageCount," agents"]})]})]},e.id))})]}):null]}),(0,s.jsx)("div",{className:"shrink-0 border-t border-white/[0.08] p-4",children:(0,s.jsx)("div",{className:"rounded-[22px] border border-cyan-300/10 bg-[linear-gradient(180deg,rgba(7,22,31,0.95),rgba(5,13,22,0.95))] p-4 shadow-[0_16px_40px_rgba(0,0,0,0.22)]",children:(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"flex h-11 w-11 items-center justify-center rounded-full border border-cyan-300/15 bg-cyan-400/[0.12] text-cyan-200",children:(0,s.jsx)(at.A,{className:"h-4 w-4"})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"truncate font-display text-[15px] text-white",children:ej?.name||"No active workspace"}),(0,s.jsx)("p",{className:"mt-1 text-[12px] text-slate-400",children:ej?`${ej.agentIds.length} agents \xb7 ${ej.activeRuntimeIds.length} runs`:`${e.agents.length} agents \xb7 ${e.runtimes.length} runs`})]})]})})})]})})]}),(0,s.jsx)(Y,{open:F,onOpenChange:z,children:(0,s.jsxs)(ee,{children:[(0,s.jsxs)(et,{children:[(0,s.jsx)(es,{children:"Delete OpenClaw workspace"}),(0,s.jsx)(er,{children:"This permanently removes the workspace directory and all OpenClaw agents bound to it."})]}),en?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)("div",{className:"rounded-[20px] border border-rose-400/20 bg-rose-500/[0.08] px-4 py-3.5",children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("div",{className:"mt-0.5 rounded-full border border-rose-300/20 bg-rose-400/10 p-2 text-rose-200",children:(0,s.jsx)(o.A,{className:"h-4 w-4"})}),(0,s.jsxs)("div",{className:"space-y-1.5 text-sm text-rose-50",children:[(0,s.jsx)("p",{className:"font-medium",children:"This action cannot be undone."}),(0,s.jsx)("p",{className:"text-rose-100/80",children:"OpenClaw will remove the workspace folder from disk and prune the attached agents/state."})]})]})}),(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-3",children:[(0,s.jsx)(ab,{label:"Agents",value:String(eT.length)}),(0,s.jsx)(ab,{label:"Runs",value:String(eO.length)}),(0,s.jsx)(ab,{label:"Live agents",value:String(eM.length),danger:eM.length>0})]}),(0,s.jsxs)("div",{className:"rounded-[18px] border border-white/10 bg-white/[0.03] px-3.5 py-3",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.2em] text-slate-500",children:"Workspace path"}),(0,s.jsx)("p",{className:"mt-1.5 break-all font-mono text-xs text-slate-300",children:en.path})]}),eM.length>0||eO.length>0?(0,s.jsx)("div",{className:"rounded-[18px] border border-amber-400/15 bg-amber-400/[0.08] px-3.5 py-3 text-sm text-amber-100",children:eM.length>0?`${eM.length} active or recently engaged agents are still attached to this workspace.`:`${eO.length} runtime records are still associated with this workspace.`}):null,(0,s.jsx)(ap,{label:`Type ${en.slug} to confirm`,htmlFor:"delete-workspace-confirm",children:(0,s.jsx)(T,{id:"delete-workspace-confirm",value:eo,onChange:e=>ed(e.target.value),placeholder:en.slug})})]}):null,(0,s.jsxs)(ea,{children:[(0,s.jsx)(I,{variant:"secondary",onClick:()=>{z(!1),ei(null),ed("")},children:"Cancel"}),(0,s.jsx)(I,{variant:"destructive",onClick:eV,disabled:B||!en||eo.trim()!==en.slug,children:B?"Deleting…":"Delete workspace"})]})]})}),(0,s.jsx)(Y,{open:K,onOpenChange:G,children:(0,s.jsxs)(ee,{children:[(0,s.jsxs)(et,{children:[(0,s.jsx)(es,{children:"Delete OpenClaw agent"}),(0,s.jsx)(er,{children:"This removes the selected agent from OpenClaw and detaches its workspace binding."})]}),ec?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)("div",{className:"rounded-[20px] border border-rose-400/20 bg-rose-500/[0.08] px-4 py-3.5",children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("div",{className:"mt-0.5 rounded-full border border-rose-300/20 bg-rose-400/10 p-2 text-rose-200",children:(0,s.jsx)(o.A,{className:"h-4 w-4"})}),(0,s.jsxs)("div",{className:"space-y-1.5 text-sm text-rose-50",children:[(0,s.jsx)("p",{className:"font-medium",children:"This action cannot be undone."}),(0,s.jsx)("p",{className:"text-rose-100/80",children:"OpenClaw will delete this agent, remove its config entry, remove its manifest record, and clean up agent-specific policy/state files. Shared workspace docs and files will remain."})]})]})}),(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-3",children:[(0,s.jsx)(ab,{label:"Status",value:ec.status,danger:eE}),(0,s.jsx)(ab,{label:"Runs",value:String(eR.length)}),(0,s.jsx)(ab,{label:"Workspace",value:e$?.name??"Unknown"})]}),(0,s.jsxs)("div",{className:"rounded-[18px] border border-white/10 bg-white/[0.03] px-3.5 py-3",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.2em] text-slate-500",children:"Agent id"}),(0,s.jsx)("p",{className:"mt-1.5 break-all font-mono text-xs text-slate-300",children:ec.id})]}),eE||eR.length>0?(0,s.jsx)("div",{className:"rounded-[18px] border border-amber-400/15 bg-amber-400/[0.08] px-3.5 py-3 text-sm text-amber-100",children:eE?"This agent is still active or recently engaged. Delete it only if you want to stop using it entirely.":`${eR.length} runtime records are still associated with this agent.`}):null,(0,s.jsx)(ap,{label:`Type ${ec.id} to confirm`,htmlFor:"delete-agent-confirm",children:(0,s.jsx)(T,{id:"delete-agent-confirm",value:em,onChange:e=>eu(e.target.value),placeholder:ec.id})})]}):null,(0,s.jsxs)(ea,{children:[(0,s.jsx)(I,{variant:"secondary",onClick:()=>{G(!1),ep(null),eu("")},children:"Cancel"}),(0,s.jsx)(I,{variant:"destructive",onClick:eJ,disabled:V||!ec||em.trim()!==ec.id,children:V?"Deleting…":"Delete agent"})]})]})}),(0,s.jsx)(Y,{open:E,onOpenChange:eq,children:(0,s.jsxs)(ee,{className:"max-h-[90vh] overflow-y-auto sm:max-w-3xl",children:[(0,s.jsxs)(et,{children:[(0,s.jsx)(es,{children:"Edit OpenClaw agent"}),(0,s.jsx)(er,{children:"Update the selected agent identity, preset, and operating policy."})]}),H?(0,s.jsxs)("div",{className:"space-y-5",children:[(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("p",{className:"text-[11px] uppercase tracking-[0.18em] text-slate-400",children:"Agent preset"}),(0,s.jsx)("div",{className:"grid gap-3 sm:grid-cols-2",children:eg.bt.map(e=>(0,s.jsx)(am,{label:e.label,description:e.description,active:H.policy.preset===e.value,badgeVariant:(0,eg.Cf)(e.value).badgeVariant,onClick:()=>Q(t=>{var a,s;let r,n,i;return t?(a=t,s=e.value,r=(0,eg.Cf)(a.policy.preset),n=(0,eg.Cf)(s),i=(0,eg.g0)(s),{...a,name:a.name&&a.name!==r.defaultName?a.name:n.defaultName,emoji:a.emoji&&a.emoji!==r.defaultEmoji?a.emoji:n.defaultEmoji,theme:a.theme&&a.theme!==r.defaultTheme?a.theme:n.defaultTheme,policy:i,heartbeat:eW(a.heartbeat,a.policy.preset,s)}):t})},e.value))})]}),(0,s.jsx)(au,{policy:H.policy}),(0,s.jsx)(ap,{label:"Agent id",htmlFor:"edit-agent-id",children:(0,s.jsx)(T,{id:"edit-agent-id",value:H.id,disabled:!0})}),(0,s.jsx)(ap,{label:"Display name",htmlFor:"edit-agent-name",children:(0,s.jsx)(T,{id:"edit-agent-name",value:H.name,onChange:e=>Q(t=>t?{...t,name:e.target.value}:t),placeholder:(0,eg.Cf)(H.policy.preset).defaultName})}),(0,s.jsx)(ap,{label:"Workspace",htmlFor:"edit-agent-workspace",children:(0,s.jsx)(T,{id:"edit-agent-workspace",value:e.workspaces.find(e=>e.id===H.workspaceId)?.name||H.workspaceId,disabled:!0})}),(0,s.jsx)(ap,{label:"Model",htmlFor:"edit-agent-model",children:(0,s.jsxs)("select",{id:"edit-agent-model",value:H.modelId,onChange:e=>Q(t=>t?{...t,modelId:e.target.value}:t),className:"flex h-11 w-full rounded-2xl border border-white/10 bg-white/5 px-4 py-2 text-sm text-white outline-none",children:[(0,s.jsx)("option",{value:"",children:"Use OpenClaw default"}),e.models.map(e=>(0,s.jsx)("option",{value:e.id,children:e.id},e.id))]})}),(0,s.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,s.jsx)(ap,{label:"Emoji",htmlFor:"edit-agent-emoji",children:(0,s.jsx)(T,{id:"edit-agent-emoji",value:H.emoji,onChange:e=>Q(t=>t?{...t,emoji:e.target.value}:t),placeholder:(0,eg.Cf)(H.policy.preset).defaultEmoji})}),(0,s.jsx)(ap,{label:"Theme",htmlFor:"edit-agent-theme",children:(0,s.jsx)(T,{id:"edit-agent-theme",value:H.theme,onChange:e=>Q(t=>t?{...t,theme:e.target.value}:t),placeholder:(0,eg.Cf)(H.policy.preset).defaultTheme})})]}),(0,s.jsx)(ap,{label:"Avatar URL",htmlFor:"edit-agent-avatar",children:(0,s.jsx)(T,{id:"edit-agent-avatar",value:H.avatar,onChange:e=>Q(t=>t?{...t,avatar:e.target.value}:t),placeholder:"https://example.com/avatar.png"})}),(0,s.jsx)(eL,{snapshot:e,workspaceId:H.workspaceId,channelIds:H.channelIds,agentId:H.id,isSaving:L,onChange:e=>Q(t=>t?{...t,channelIds:e}:t)}),(0,s.jsxs)("div",{className:"rounded-[20px] border border-white/10 bg-white/[0.03] p-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium text-white",children:"Advanced policy"}),(0,s.jsx)("p",{className:"mt-1 text-xs leading-5 text-slate-400",children:"Override how this agent handles missing tools, installs, file scope, and network usage."})]}),(0,s.jsx)(I,{type:"button",variant:"secondary",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",onClick:()=>P(e=>!e),children:_?"Hide":"Show"})]}),eS?(0,s.jsxs)("div",{className:"mt-4 rounded-[18px] border border-white/10 bg-slate-950/40 p-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium text-white",children:"Heartbeat"}),(0,s.jsx)("p",{className:"mt-1 text-xs leading-5 text-slate-400",children:"Use this only for periodic watch or triage agents. Leave it off for normal task execution."})]}),(0,s.jsx)(I,{type:"button",variant:H.heartbeat.enabled?"default":"secondary",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",onClick:()=>Q(e=>e?{...e,heartbeat:e.heartbeat.enabled?{...e.heartbeat,enabled:!1}:{...e.heartbeat,enabled:!0,every:e.heartbeat.every||eF(e.policy.preset).every}}:e),children:H.heartbeat.enabled?"On":"Off"})]}),H.heartbeat.enabled?(0,s.jsx)("div",{className:"mt-3",children:(0,s.jsx)(ap,{label:"Interval",htmlFor:"edit-agent-heartbeat-every",children:(0,s.jsx)("select",{id:"edit-agent-heartbeat-every",value:H.heartbeat.every,onChange:e=>Q(t=>t?{...t,heartbeat:{...t.heartbeat,every:e.target.value}}:t),className:"flex h-11 w-full rounded-2xl border border-white/10 bg-white/5 px-4 py-2 text-sm text-white outline-none",children:eU.map(e=>(0,s.jsx)("option",{value:e.value,children:e.label},e.value))})})}):null]}):null,_?(0,s.jsxs)("div",{className:"mt-4 grid gap-4 sm:grid-cols-2",children:[(0,s.jsx)(ah,{label:"Missing tool behavior",htmlFor:"edit-agent-missing-tools",value:H.policy.missingToolBehavior,options:eg.A_,onChange:e=>Q(t=>t?{...t,policy:{...t.policy,missingToolBehavior:e}}:t)}),(0,s.jsx)(ah,{label:"Install scope",htmlFor:"edit-agent-install-scope",value:H.policy.installScope,options:eg.sH,onChange:e=>Q(t=>t?{...t,policy:{...t.policy,installScope:e}}:t)}),(0,s.jsx)(ah,{label:"File access",htmlFor:"edit-agent-file-access",value:H.policy.fileAccess,options:eg.$x,onChange:e=>Q(t=>t?{...t,policy:{...t.policy,fileAccess:e}}:t)}),(0,s.jsx)(ah,{label:"Network access",htmlFor:"edit-agent-network-access",value:H.policy.networkAccess,options:eg.DS,onChange:e=>Q(t=>t?{...t,policy:{...t.policy,networkAccess:e}}:t)})]}):null]})]}):null,(0,s.jsxs)(ea,{children:[(0,s.jsx)(I,{variant:"secondary",onClick:()=>eq(!1),children:"Cancel"}),(0,s.jsx)(I,{onClick:eG,disabled:L||!H,children:L?"Saving…":"Save changes"})]})]})})]})}function an({icon:e,label:t,active:a,surfaceTheme:r,panelCollapsed:n,tooltipSide:i,onClick:l}){return(0,s.jsx)(tc,{label:t,side:i,surfaceTheme:r,panelCollapsed:n,children:(0,s.jsx)("button",{type:"button",onClick:l,"aria-label":t,className:(0,S.cn)("inline-flex h-8 w-8 items-center justify-center rounded-[8px] border transition-all",a?"border-cyan-300/20 bg-cyan-400 text-slate-950 shadow-[0_12px_28px_rgba(96,165,250,0.35)]":"border-white/10 bg-white/[0.03] text-slate-400 hover:border-white/15 hover:bg-white/[0.08] hover:text-white"),children:(0,s.jsx)(e,{className:"h-3.5 w-3.5"})})})}function ai({label:e,badge:t,active:a,onClick:r}){return(0,s.jsxs)("button",{type:"button",onClick:r,className:(0,S.cn)("inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1.5 text-[10px] uppercase tracking-[0.16em] transition-all",a?"border-cyan-300/20 bg-cyan-400 text-slate-950 shadow-[0_10px_24px_rgba(96,165,250,0.28)]":"border-white/[0.08] bg-white/[0.03] text-slate-300 hover:bg-white/[0.07] hover:text-white"),children:[(0,s.jsx)("span",{children:e}),t?(0,s.jsx)("span",{className:(0,S.cn)("rounded-full px-1.5 py-0.5 text-[9px] tracking-normal",a?"bg-slate-950/14 text-slate-950":"bg-white/[0.08] text-slate-400"),children:t}):null]})}function al({eyebrow:e,title:t,detail:a,action:r}){return(0,s.jsxs)("div",{className:"flex items-end justify-between gap-4",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.22em] text-slate-500",children:e}),(0,s.jsx)("h2",{className:"mt-1.5 font-display text-[1.02rem] text-white",children:t}),(0,s.jsx)("p",{className:"mt-1.5 text-[12px] leading-5 text-slate-400",children:a})]}),r?(0,s.jsx)("div",{className:"shrink-0",children:r}):null]})}function ao({label:e,value:t}){return(0,s.jsxs)("div",{className:"rounded-[18px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.88),rgba(7,12,22,0.82))] px-3.5 py-3",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.2em] text-slate-500",children:e}),(0,s.jsx)("p",{className:"mt-1.5 font-display text-[1.2rem] text-white",children:t})]})}function ad({provider:e,disabled:t,onConnect:a}){let r,n="openai-codex"===e.provider?"Connect ChatGPT":"openrouter"===e.provider?"Add API key":"Connect";return(0,s.jsxs)("div",{className:"rounded-[20px] border border-white/[0.08] bg-[linear-gradient(180deg,rgba(11,18,32,0.9),rgba(8,13,24,0.84))] p-4",children:[(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)(G,{className:"h-8 w-8",provider:e.provider}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("p",{className:"truncate font-display text-[15px] text-white",children:ac(e.provider)}),(0,s.jsx)(k.E,{variant:e.connected?"success":e.canLogin?"warning":"muted",children:e.connected?"connected":e.canLogin?"needs auth":"local"})]}),(0,s.jsx)("p",{className:"mt-1 text-[12px] leading-5 text-slate-400",children:e.detail||("openai-codex"===(r=e.provider.trim().toLowerCase())?"Use the OpenClaw OpenAI Codex route. If your ChatGPT plan includes Codex access, connect that account here.":"openrouter"===r?"Paste an API key to unlock OpenRouter-hosted routes.":"gemini"===r?"Paste a Gemini API key to unlock Gemini-hosted routes.":"deepseek"===r?"Paste a DeepSeek API key to unlock DeepSeek-hosted routes.":"mistral"===r?"Paste a Mistral API key to unlock Mistral and Codestral routes.":"xai"===r?"Paste an xAI API key to unlock Grok routes.":"ollama"===r?"Local model provider. Pull models locally to make new routes available.":"Connect this provider to make its remote routes available inside AgentOS.")})]})]}),(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.canLogin?(0,s.jsx)(I,{variant:e.connected?"ghost":"secondary",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",disabled:t,onClick:a,children:n}):null,"openai-codex"===e.provider?(0,s.jsx)(k.E,{variant:"muted",children:"ChatGPT/Codex route"}):null]})]})}function ac(e){let t=e.trim().toLowerCase();return"openrouter"===t?"OpenRouter":"openai-codex"===t?"OpenAI Codex":"openai"===t?"OpenAI":"anthropic"===t?"Anthropic":"ollama"===t?"Ollama":"xai"===t?"xAI":"gemini"===t?"Gemini":"deepseek"===t?"DeepSeek":"mistral"===t?"Mistral":e.split("-").map(e=>e?e[0].toUpperCase()+e.slice(1):e).join(" ")}function ap({label:e,htmlFor:t,children:a}){return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(e$,{htmlFor:t,className:"text-[11px] uppercase tracking-[0.18em] text-slate-400",children:e}),a]})}function am({label:e,description:t,active:a,badgeVariant:r,onClick:n}){return(0,s.jsx)("button",{type:"button",onClick:n,className:(0,S.cn)("rounded-[20px] border p-4 text-left transition-colors",a?"border-cyan-300/30 bg-cyan-400/10":"border-white/10 bg-white/[0.03]"),children:(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-white",children:e}),(0,s.jsx)("p",{className:"text-xs leading-5 text-slate-400",children:t})]}),(0,s.jsx)(k.E,{variant:r,children:a?"selected":"preset"})]})})}function au({policy:e}){let t=(0,eg.Cf)(e.preset);return(0,s.jsxs)("div",{className:"rounded-[20px] border border-white/10 bg-slate-950/50 p-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium text-white",children:t.label}),(0,s.jsx)("p",{className:"mt-1 text-xs leading-5 text-slate-400",children:t.description})]}),(0,s.jsx)(k.E,{variant:t.badgeVariant,children:t.label})]}),(0,s.jsxs)("div",{className:"mt-4 flex flex-wrap gap-2",children:[(0,s.jsx)(k.E,{variant:"muted",children:(0,eg.zR)(e.missingToolBehavior)}),(0,s.jsx)(k.E,{variant:"muted",children:(0,eg.UJ)(e.installScope)}),(0,s.jsx)(k.E,{variant:"muted",children:(0,eg.bQ)(e.fileAccess)}),(0,s.jsxs)(k.E,{variant:"muted",children:["Network ",(0,eg.Bw)(e.networkAccess)]})]})]})}function ah({label:e,htmlFor:t,value:a,options:r,onChange:n}){return(0,s.jsx)(ap,{label:e,htmlFor:t,children:(0,s.jsx)("select",{id:t,value:a,onChange:e=>n(e.target.value),className:"flex h-11 w-full rounded-2xl border border-white/10 bg-white/5 px-4 py-2 text-sm text-white outline-none",children:r.map(e=>(0,s.jsxs)("option",{value:e.value,children:[e.label," - ",e.description]},e.value))})})}function ax({agentName:e,onEdit:t,onDelete:a}){let[r,n]=(0,g.useState)(!1),i=(0,g.useRef)(null);return(0,g.useEffect)(()=>{if(!r)return;let e=e=>{i.current?.contains(e.target)||n(!1)};return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e)},[r]),(0,s.jsxs)("div",{className:"relative",ref:i,children:[(0,s.jsx)("button",{type:"button","aria-label":`${e} actions`,onClick:()=>n(e=>!e),className:"inline-flex rounded-full border border-white/[0.08] bg-white/[0.05] p-1.5 text-slate-300 transition-colors hover:bg-white/[0.1] hover:text-white",children:(0,s.jsx)(aa.A,{className:"h-3.5 w-3.5"})}),r?(0,s.jsxs)("div",{className:"absolute right-0 top-[calc(100%+8px)] z-30 min-w-[136px] rounded-[14px] border border-white/[0.1] bg-slate-950/96 p-1.5 shadow-[0_20px_44px_rgba(0,0,0,0.42)] backdrop-blur-xl",children:[(0,s.jsx)(ag,{label:"Edit",onClick:()=>{n(!1),t()}}),(0,s.jsx)(ag,{label:"Delete",danger:!0,onClick:()=>{n(!1),a()}})]}):null]})}function ag({label:e,onClick:t,danger:a=!1}){return(0,s.jsx)("button",{type:"button",className:(0,S.cn)("flex w-full items-center rounded-[10px] px-2.5 py-2 text-left text-[11px] transition-colors",a?"text-rose-200 hover:bg-rose-400/10 hover:text-rose-100":"text-slate-200 hover:bg-white/[0.06] hover:text-white"),onClick:t,children:(0,s.jsx)("span",{children:e})})}function ab({label:e,value:t,danger:a=!1}){return(0,s.jsxs)("div",{className:(0,S.cn)("rounded-[18px] border px-3.5 py-3",a?"border-amber-300/20 bg-amber-400/[0.08]":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.2em] text-slate-500",children:e}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1.5 font-display text-lg",a?"text-amber-100":"text-white"),children:t})]})}function af({snapshot:e,workspaceId:t,open:a,onOpenChange:r,onRefresh:n,onSnapshotChange:l}){let d=(0,g.useMemo)(()=>e.workspaces.find(e=>e.id===t)??null,[e.workspaces,t]),c=d?.id??null,p=(0,g.useMemo)(()=>e.agents.filter(e=>e.workspaceId===d?.id),[e.agents,d?.id]),m=(0,g.useMemo)(()=>d?eD(e,d.id):[],[e,d]),h=(0,g.useCallback)((t,a="Unset")=>t?(0,eb.CK)(e.agents.find(e=>e.id===t)??{name:t}):a,[e.agents]),x=(0,g.useMemo)(()=>{let t=new Map;for(let a of e.channelAccounts)"telegram"===a.type&&t.set(a.id,a);for(let a of e.channelRegistry.channels){if("telegram"!==a.type)continue;let e=t.get(a.id);t.set(a.id,{id:a.id,type:"telegram",name:a.name,enabled:e?.enabled??!0})}return Array.from(t.values()).sort((e,t)=>e.name.localeCompare(t.name))},[e.channelAccounts,e.channelRegistry.channels]),[b,f]=(0,g.useState)(!1),[w,y]=(0,g.useState)(null),[v,j]=(0,g.useState)("existing"),[N,C]=(0,g.useState)({accountId:null,kind:"idle",message:null}),[S,A]=(0,g.useState)(null),[M,D]=(0,g.useState)(""),[_,P]=(0,g.useState)(""),[L,U]=(0,g.useState)(""),[F,z]=(0,g.useState)(""),[W,B]=(0,g.useState)([]),[q,K]=(0,g.useState)(!1),[G,V]=(0,g.useState)(null),[J,Q]=(0,g.useState)([]),[Z,X]=(0,g.useState)(null),[en,ei]=(0,g.useState)("");(0,g.useEffect)(()=>{if(!a){P(""),U(""),z(""),j("existing"),f(!1),y(null),C({accountId:null,kind:"idle",message:null}),A(null),D(""),B([]),K(!1),V(null),Q([]),X(null),ei("");return}j(x.length>0?"existing":"new"),P(""),U("")},[a,x.length]),(0,g.useEffect)(()=>{a&&!F&&z(p[0]?.id||"")},[a,F,p]),(0,g.useEffect)(()=>{if(!a||!c)return;let e=!1;return(async()=>{K(!0),V(null);try{let t=await fetch(`/api/workspaces/${encodeURIComponent(c)}/channels/discovered-groups`,{method:"GET"}),a=await t.json();if(!t.ok||a.error)throw Error(a.error||"Telegram groups could not be loaded.");e||B(Array.isArray(a.groups)?a.groups:[])}catch(t){e||V(t instanceof Error?t.message:"Telegram groups could not be loaded.")}finally{e||K(!1)}})(),()=>{e=!0}},[a,c]);let eo=async e=>{if(!d)throw Error("Workspace was not found.");let t=await fetch(`/api/workspaces/${encodeURIComponent(d.id)}/channels`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await t.json();if(!t.ok||a.error)throw Error(a.error||"OpenClaw could not update this channel right now.");return a},ed=async e=>{if(!d)throw Error("Workspace was not found.");let t=await fetch(`/api/workspaces/${encodeURIComponent(d.id)}/channels`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),a=await t.json();if(!t.ok||a.error)throw Error(a.error||"OpenClaw could not update this channel right now.");return a},ec=async e=>{if(!d)throw Error("Workspace was not found.");let t=await fetch(`/api/workspaces/${encodeURIComponent(d.id)}/channels`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({channelId:e})}),a=await t.json();if(!t.ok||a.error)throw Error(a.error||"OpenClaw could not update this channel right now.");return a},ep=async e=>{if(!d)throw Error("Workspace was not found.");let t=await fetch(`/api/workspaces/${encodeURIComponent(d.id)}/channels`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({channelId:e,scope:"global"})}),a=await t.json();if(!t.ok||a.error)throw Error(a.error||"OpenClaw could not update this channel right now.");return a},em=()=>{A(null),D("")},eh=e=>{f(!0),y(e)},ex=()=>{f(!1),y(null)},eg=async(e,t)=>{if(!d)return;eh(`Adding ${t} to this workspace...`),C({accountId:e,kind:"loading",message:null});let a=!1;try{let s=await eo({channelId:e,type:"telegram",name:t,primaryAgentId:F||null,agentId:F||void 0});s.registry&&l&&l(e=>e_(e,s.registry)),C({accountId:e,kind:"success",message:"Added to workspace."}),a=!0}catch(a){let t=a instanceof Error?a.message:"Unknown channel error.";C({accountId:e,kind:"error",message:t}),el.o.error("Channel add failed.",{description:t})}finally{ex()}a&&(el.o.success("Telegram channel added to workspace."),n().catch(()=>{}))},ef=async()=>{if(!d)return;if(!_.trim()||!L.trim())return void el.o.error("Channel name and bot token are required.");eh("Creating Telegram channel...");let e=!1;try{let t=await eo({type:"telegram",name:_.trim(),token:L.trim(),primaryAgentId:F||null,agentId:F||void 0});P(""),U(""),t.registry&&l&&l(e=>{var a,s;let r,n=e_(e,t.registry);return t.account&&(a=n,s=t.account,r=a.channelAccounts.filter(e=>e.id!==s.id),n={...a,channelAccounts:[...r,s]}),n}),e=!0}catch(e){el.o.error("Channel creation failed.",{description:e instanceof Error?e.message:"Unknown channel error."})}finally{ex()}e&&(el.o.success("Telegram channel created."),n().catch(()=>{}))},ew=async(e,t)=>{if(!d||!t)return;eh("Updating primary agent...");let a=!1;try{let s=m.find(t=>t.id===e),r=s?.workspaces.find(e=>e.workspaceId===d.id)??null;if(s&&r&&!r.agentIds.includes(t)){let a=await ed({action:"bind-agent",channelId:e,agentId:t,workspacePath:d.path});a.registry&&l&&l(e=>e_(e,a.registry))}let n=await ed({action:"primary",channelId:e,primaryAgentId:t});n.registry&&l&&l(e=>e_(e,n.registry)),a=!0}catch(e){el.o.error("Primary update failed.",{description:e instanceof Error?e.message:"Unknown channel error."})}finally{ex()}a&&(el.o.success("Primary agent updated."),n().catch(()=>{}))},ey=async e=>{if(!d)return;eh("Removing channel from workspace...");let t=!1;try{let a=await ec(e);a.registry&&l&&l(e=>e_(e,a.registry)),t=!0}catch(e){el.o.error("Channel removal failed.",{description:e instanceof Error?e.message:"Unknown channel error."})}finally{ex()}t&&(el.o.success("Channel removed from workspace."),n().catch(()=>{}))},ev=async(e,t)=>{if(!d||!t)return;eh("Adding delegate agent...");let a=!1;try{let s=await ed({action:"bind-agent",channelId:e,agentId:t,workspacePath:d.path});s.registry&&l&&l(e=>e_(e,s.registry)),X(null),ei(""),a=!0}catch(e){el.o.error("Delegate update failed.",{description:e instanceof Error?e.message:"Unknown channel error."})}finally{ex()}a&&(el.o.success("Delegate agent added."),n().catch(()=>{}))},ej=async(e,t)=>{if(!d)return;eh("Removing delegate agent...");let a=!1;try{let s=await ed({action:"unbind-agent",channelId:e,agentId:t});s.registry&&l&&l(e=>e_(e,s.registry)),a=!0}catch(e){el.o.error("Delegate update failed.",{description:e instanceof Error?e.message:"Unknown channel error."})}finally{ex()}a&&(el.o.success("Delegate agent removed."),n().catch(()=>{}))},ek=async()=>{if(d){K(!0),V(null);try{let e=await fetch(`/api/workspaces/${encodeURIComponent(d.id)}/channels/discovered-groups`,{method:"GET"}),t=await e.json();if(!e.ok||t.error)throw Error(t.error||"Telegram groups could not be loaded.");B(Array.isArray(t.groups)?t.groups:[])}catch(t){let e=t instanceof Error?t.message:"Telegram groups could not be loaded.";V(e),el.o.error("Telegram groups could not be refreshed.",{description:e})}finally{K(!1)}}},eN=async(e,t,a,s)=>{eh(s?`Allowing ${a.title??a.chatId}...`:`Removing ${a.title??a.chatId}...`);let r=!1;try{let n=t.filter(e=>!1!==e.enabled&&e.chatId!==a.chatId).map(e=>({chatId:e.chatId,agentId:e.agentId??null,title:e.title??null,enabled:!0}));s&&n.push({chatId:a.chatId,agentId:null,title:a.title??null,enabled:!0});let i=await ed({action:"groups",channelId:e,groupAssignments:n});i.registry&&l&&l(e=>e_(e,i.registry)),r=!0}catch(e){el.o.error("Allowed groups update failed.",{description:e instanceof Error?e.message:"Unknown channel error."})}finally{ex()}r&&(el.o.success(s?"Group added to allowlist.":"Group removed from allowlist."),n().catch(()=>{}))},eC=async(e,t,a,s)=>{eh(`Updating ${a.title??a.chatId} owner...`);let r=!1;try{let n=t.filter(e=>!1!==e.enabled).map(e=>e.chatId===a.chatId?{chatId:e.chatId,agentId:s||null,title:a.title??e.title??null,enabled:!0}:{chatId:e.chatId,agentId:e.agentId??null,title:e.title??null,enabled:!0}),i=await ed({action:"groups",channelId:e,groupAssignments:n});i.registry&&l&&l(e=>e_(e,i.registry)),r=!0}catch(e){el.o.error("Group owner update failed.",{description:e instanceof Error?e.message:"Unknown channel error."})}finally{ex()}r&&(el.o.success("Group owner updated."),n().catch(()=>{}))},eS=(0,g.useMemo)(()=>{if(!S)return null;let t=e.channelRegistry.channels.find(e=>e.id===S.id)??null,a=t?.workspaces??[],s=a.map(t=>{let a=e.workspaces.find(e=>e.id===t.workspaceId)??null,s=av(t.agentIds.map(e=>h(e,e))),r=av(t.groupAssignments.filter(e=>!1!==e.enabled&&e.agentId).map(e=>h(e.agentId,e.agentId??"")));return{workspaceId:t.workspaceId,workspaceName:a?.name??t.workspaceId,agentNames:av([...s,...r]),groupRouteCount:t.groupAssignments.filter(e=>!1!==e.enabled).length}}).sort((e,t)=>e.workspaceName.localeCompare(t.workspaceName)),r=av([...a.flatMap(e=>e.agentIds),...a.flatMap(e=>e.groupAssignments.filter(e=>!1!==e.enabled&&e.agentId).map(e=>e.agentId)),t?.primaryAgentId??""]),n=av(r.map(e=>h(e,e))),i=t?.primaryAgentId?h(t.primaryAgentId,t.primaryAgentId):null;return{channel:t,workspaceBindings:a,affectedWorkspaceDetails:s,affectedAgentNames:n,primaryAgentName:i}},[S,h,e]),eA=null!==S&&aj(M)===aj(S.name),eI=async()=>{if(!S||!eA)return;eh(`Deleting ${S.name} everywhere...`);let e=!1;try{let t=await ep(S.id);em(),t.registry&&l&&l(e=>{var a,s;let r=e_(e,t.registry);return a=r,s=S.id,r={...a,channelAccounts:a.channelAccounts.filter(e=>e.id!==s)}}),e=!0}catch(e){el.o.error("Channel deletion failed.",{description:e instanceof Error?e.message:"Unknown channel error."})}finally{ex()}e&&(el.o.success("Channel deleted everywhere."),n().catch(()=>{}))},eT=new Set(m.map(e=>e.id));return(0,s.jsxs)(Y,{open:a,onOpenChange:r,children:[(0,s.jsxs)(ee,{className:"max-h-[90vh] overflow-y-auto sm:max-w-3xl",children:[(0,s.jsxs)(et,{children:[(0,s.jsx)(es,{children:"Workspace Channels"}),(0,s.jsx)(er,{children:"Manage Telegram accounts for this workspace. Disconnect only detaches here; Delete removes the account everywhere."})]}),b&&w?(0,s.jsx)("div",{className:"rounded-2xl border border-cyan-300/20 bg-cyan-400/[0.08] px-3 py-2",children:(0,s.jsxs)("div",{className:"flex items-center gap-2 text-[11px] text-cyan-50",children:[(0,s.jsx)(i.A,{className:"h-3.5 w-3.5 animate-spin"}),(0,s.jsx)("span",{children:w})]})}):null,(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("section",{className:"rounded-[20px] border border-white/10 bg-white/[0.03] p-3 sm:p-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-white",children:"Workspace channels"}),(0,s.jsx)("p",{className:"mt-1 text-xs leading-5 text-slate-400",children:"Primary agent, bound agents, and disconnect live here."})]}),(0,s.jsx)(k.E,{variant:"muted",className:"h-6 rounded-full px-2 text-[10px]",children:m.length})]}),(0,s.jsx)("div",{className:"mt-3",children:m.length>0?(0,s.jsx)("div",{className:"space-y-2",children:m.map(t=>{let a=t.workspaces.find(e=>e.workspaceId===d?.id)??null,r=J.includes(t.id),n=t.primaryAgentId??"",i=h(n,"Unset"),l=n?e.agents.find(e=>e.id===n)??null:null,o=l?e.workspaces.find(e=>e.id===l.workspaceId)??null:null,c=l?[...p,...p.some(e=>e.id===l.id)?[]:[l]]:p,m=a?.agentIds.length??0,x=(a?.agentIds??[]).filter(e=>e!==n).map(t=>e.agents.find(e=>e.id===t)??null).filter(e=>!!e),g=p.filter(e=>e.id!==n&&!x.some(t=>t.id===e.id)),f=(a?.groupAssignments??[]).filter(e=>!1!==e.enabled),w=function(e,t){let a=new Map;for(let t of e)a.set(t.chatId,t);for(let e of t)a.set(e.chatId,{chatId:e.chatId,title:e.title??a.get(e.chatId)?.title??null,lastSeen:a.get(e.chatId)?.lastSeen??null});return Array.from(a.values()).sort((e,t)=>{let a=e.title??e.chatId,s=t.title??t.chatId;return a.localeCompare(s)})}(W,f);return(0,s.jsxs)("div",{className:"rounded-2xl border border-white/8 bg-white/[0.02] px-3 py-2.5",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("p",{className:"truncate text-sm font-medium text-white",children:t.name}),(0,s.jsx)(k.E,{variant:"muted",className:"h-5 rounded-full px-2 text-[10px]",children:t.type}),(0,s.jsx)(k.E,{className:"h-5 rounded-full px-2 text-[10px]",children:n?"Global primary":"Primary unset"})]}),(0,s.jsxs)("p",{className:"truncate text-[11px] text-slate-400",children:[t.id," \xb7 primary ",i," \xb7 ",m," bound"]})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:justify-end",children:[(0,s.jsxs)(I,{type:"button",variant:"ghost",size:"sm",className:"h-8 rounded-full px-2.5 text-[11px]",disabled:b,onClick:()=>Q(e=>e.includes(t.id)?e.filter(e=>e!==t.id):[...e,t.id]),children:[(0,s.jsx)(u.A,{className:`mr-1 h-3.5 w-3.5 transition-transform ${r?"-rotate-90":"rotate-0"}`}),r?"Show groups":"Hide groups"]}),(0,s.jsxs)("select",{id:`workspace-channel-primary-${t.id}`,value:n,onChange:e=>void ew(t.id,e.target.value),className:"flex h-8 min-w-[170px] rounded-full border border-white/10 bg-white/5 px-3 text-[11px] text-white outline-none",disabled:b,children:[(0,s.jsx)("option",{value:"",children:"Select primary"}),c.map(e=>(0,s.jsx)("option",{value:e.id,children:e.id===l?.id&&e.workspaceId!==d?.id?`${(0,eb.CK)(e)} (${o?.name??"other workspace"})`:(0,eb.CK)(e)},e.id))]}),(0,s.jsx)(I,{type:"button",variant:"secondary",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",disabled:b,onClick:()=>ey(t.id),children:"Disconnect"})]})]}),r?null:(0,s.jsxs)("div",{className:"mt-3 border-t border-white/6 pt-3",children:[(0,s.jsxs)("div",{className:"mb-3 rounded-2xl border border-white/8 bg-white/[0.02] px-3 py-2.5",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("p",{className:"text-[11px] font-medium text-white",children:"Delegate agents"}),(0,s.jsx)(k.E,{variant:"muted",className:"h-5 rounded-full px-2 text-[10px]",children:x.length})]}),(0,s.jsxs)(I,{type:"button",variant:"ghost",size:"sm",className:"h-7 rounded-full px-2.5 text-[11px]",disabled:b||0===g.length,onClick:()=>{X(e=>e===t.id?null:t.id),ei(g[0]?.id??"")},children:[(0,s.jsx)(eu.A,{className:"mr-1 h-3.5 w-3.5"}),"Add delegate"]})]}),(0,s.jsx)("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:x.length>0?x.map(e=>(0,s.jsxs)("div",{className:"inline-flex items-center gap-1.5 rounded-full border border-white/10 bg-white/5 px-2.5 py-1 text-[11px] text-white",children:[(0,s.jsx)("span",{className:"truncate",children:(0,eb.CK)(e)}),(0,s.jsx)("button",{type:"button",className:"rounded-full p-0.5 text-slate-400 transition-colors hover:text-white",disabled:b,onClick:()=>void ej(t.id,e.id),children:(0,s.jsx)(H.A,{className:"h-3 w-3"})})]},`${t.id}-${e.id}`)):(0,s.jsx)("p",{className:"text-[11px] text-slate-400",children:"No delegates yet."})}),Z===t.id?(0,s.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[(0,s.jsx)("select",{value:en,onChange:e=>ei(e.target.value),className:"flex h-8 min-w-[170px] rounded-full border border-white/10 bg-white/5 px-3 text-[11px] text-white outline-none",disabled:b,children:g.map(e=>(0,s.jsx)("option",{value:e.id,children:(0,eb.CK)(e)},e.id))}),(0,s.jsx)(I,{type:"button",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",disabled:b||!en,onClick:()=>void ev(t.id,en),children:"Add"}),(0,s.jsx)(I,{type:"button",variant:"secondary",size:"sm",className:"h-8 rounded-full px-3 text-[11px]",disabled:b,onClick:()=>{X(null),ei("")},children:"Cancel"})]}):null]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-[11px] font-medium text-white",children:"Allowed groups"}),(0,s.jsx)("p",{className:"mt-1 text-[11px] text-slate-400",children:"Recent Telegram groups are detected from logs. Unassigned groups fall back to the channel primary."})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)(k.E,{variant:"muted",className:"h-5 rounded-full px-2 text-[10px]",children:[f.length," selected"]}),(0,s.jsx)(I,{type:"button",variant:"ghost",size:"sm",className:"h-7 rounded-full px-2.5 text-[11px]",disabled:b||q,onClick:()=>void ek(),children:q?"Refreshing...":"Refresh"})]})]}),G?(0,s.jsx)("p",{className:"mt-2 text-[11px] text-rose-300",children:G}):null,w.length>0?(0,s.jsx)("div",{className:"mt-3 space-y-2",children:w.map(e=>{var a;let r,n=f.find(t=>t.chatId===e.chatId)??null,i=!!n;return(0,s.jsx)("div",{className:"rounded-2xl border border-white/8 bg-white/[0.02] px-3 py-2.5",children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("input",{type:"checkbox",className:"mt-0.5 h-4 w-4 rounded border-white/15 bg-white/5 accent-cyan-300",checked:i,disabled:b,onChange:a=>void eN(t.id,f,e,a.target.checked)}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,s.jsxs)("div",{className:"min-w-0 flex items-center gap-2",children:[(0,s.jsx)("p",{className:"truncate text-sm font-medium text-white",children:e.title??`Group ${e.chatId}`}),W.some(t=>t.chatId===e.chatId)?null:(0,s.jsx)(k.E,{variant:"muted",className:"h-5 rounded-full px-2 text-[10px]",children:"Saved"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-[11px] text-slate-400",children:"Owner"}),(0,s.jsxs)("select",{value:n?.agentId??"",disabled:b||!i,onChange:a=>void eC(t.id,f,e,a.target.value),className:"flex h-8 min-w-[150px] shrink-0 rounded-full border border-white/10 bg-white/5 px-3 text-[11px] text-white outline-none disabled:cursor-not-allowed disabled:opacity-50",children:[(0,s.jsx)("option",{value:"",children:"Use primary agent"}),p.map(e=>(0,s.jsx)("option",{value:e.id,children:(0,eb.CK)(e)},e.id))]})]})]}),(0,s.jsxs)("p",{className:"mt-1 truncate text-[11px] text-slate-400",children:[e.chatId,e.lastSeen?` \xb7 seen ${Number.isNaN(r=Date.parse(a=e.lastSeen))?a:new Date(r).toISOString().replace("T"," ").slice(0,16)}`:""]})]})]})},`${t.id}-${e.chatId}`)})}):(0,s.jsx)("div",{className:"mt-3 rounded-2xl border border-dashed border-white/10 bg-white/[0.02] px-3 py-3 text-[11px] text-slate-400",children:"No Telegram groups found yet. Send one message in the target group, then refresh here."})]})]},t.id)})}):(0,s.jsx)("div",{className:"rounded-2xl border border-dashed border-white/10 bg-white/[0.02] px-4 py-4 text-sm text-slate-400",children:"No channels have been added to this workspace yet."})})]}),(0,s.jsxs)("section",{className:"rounded-[20px] border border-white/10 bg-white/[0.03] p-3 sm:p-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-white",children:"Add Telegram"}),(0,s.jsx)("p",{className:"mt-1 text-xs leading-5 text-slate-400",children:"Reuse a stored bot or create a new one for this workspace."})]}),(0,s.jsxs)(k.E,{variant:"muted",className:"h-6 rounded-full px-2 text-[10px]",children:[x.length," saved"]})]}),(0,s.jsxs)(O,{className:"mt-3",value:v,onValueChange:e=>j(e),children:[(0,s.jsxs)(R,{className:"h-10",children:[(0,s.jsx)($,{className:"h-8 rounded-xl px-3 text-[12px]",value:"existing",children:"Existing"}),(0,s.jsx)($,{className:"h-8 rounded-xl px-3 text-[12px]",value:"new",children:"New"})]}),(0,s.jsx)(E,{className:"mt-3",value:"existing",children:x.length>0?(0,s.jsx)("div",{className:"space-y-2",children:x.map(e=>{let t=eT.has(e.id);return(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-2xl border border-white/8 bg-white/[0.02] px-3 py-2.5",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("p",{className:"truncate text-sm font-medium text-white",children:e.name}),(0,s.jsx)(k.E,{variant:"muted",className:"h-5 rounded-full px-2 text-[10px]",children:"telegram"}),t?(0,s.jsx)(k.E,{className:"h-5 rounded-full px-2 text-[10px]",children:"In workspace"}):null]}),(0,s.jsx)("p",{className:"mt-1 truncate text-[11px] text-slate-400",children:e.id}),N.accountId===e.id&&"idle"!==N.kind?(0,s.jsx)("p",{className:"error"===N.kind?"mt-1 text-[11px] text-rose-300":"success"===N.kind?"mt-1 text-[11px] text-emerald-300":"mt-1 text-[11px] text-slate-400",children:"loading"===N.kind?"Adding...":N.message}):null]}),(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[(0,s.jsx)(I,{type:"button",variant:t?"secondary":"default",size:"sm",className:"h-8 rounded-full px-2.5 text-[11px] whitespace-nowrap",disabled:b||t,onClick:()=>eg(e.id,e.name),children:N.accountId===e.id&&"loading"===N.kind?"Adding...":t?"Added":"Add"}),(0,s.jsx)(I,{type:"button",variant:"destructive",size:"sm",className:"h-8 rounded-full px-2.5 text-[11px] whitespace-nowrap",disabled:b,onClick:()=>{A(e),D("")},children:"Delete"})]})]},e.id)})}):(0,s.jsxs)("div",{className:"rounded-2xl border border-dashed border-white/10 bg-white/[0.02] px-4 py-4 text-sm text-slate-400",children:["No stored Telegram accounts yet. Switch to ",(0,s.jsx)("span",{className:"text-white",children:"New"})," to add one."]})}),(0,s.jsxs)(E,{className:"mt-3",value:"new",children:[(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,s.jsx)(aw,{label:"Channel name",htmlFor:"workspace-channel-name",children:(0,s.jsx)(T,{id:"workspace-channel-name",value:_,onChange:e=>P(e.target.value),placeholder:"Support bot"})}),(0,s.jsx)(aw,{label:"Bot token",htmlFor:"workspace-channel-token",children:(0,s.jsx)(T,{id:"workspace-channel-token",value:L,onChange:e=>U(e.target.value),placeholder:"123456:ABC..."})})]}),(0,s.jsxs)("div",{className:"mt-3 grid gap-3 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-end",children:[(0,s.jsx)(aw,{label:"Primary agent",htmlFor:"workspace-channel-primary",children:(0,s.jsxs)("select",{id:"workspace-channel-primary",value:F,onChange:e=>z(e.target.value),className:"flex h-11 w-full rounded-2xl border border-white/10 bg-white/5 px-4 py-2 text-sm text-white outline-none",children:[(0,s.jsx)("option",{value:"",children:"Select agent"}),p.map(e=>(0,s.jsx)("option",{value:e.id,children:(0,eb.CK)(e)},e.id))]})}),(0,s.jsx)(I,{type:"button",className:"h-11 rounded-full px-4",disabled:b||!_.trim()||!L.trim()||!F,onClick:ef,children:b?"Creating...":"Create"})]})]})]})]})]}),(0,s.jsx)(ea,{children:(0,s.jsx)(I,{variant:"secondary",onClick:()=>r(!1),children:"Close"})})]}),(0,s.jsx)(Y,{open:!!S,onOpenChange:e=>!e&&em(),children:(0,s.jsxs)(ee,{className:"sm:max-w-2xl",children:[(0,s.jsxs)(et,{children:[(0,s.jsx)(es,{children:"Delete Telegram account"}),(0,s.jsx)(er,{children:"This permanently removes the account from every workspace and deletes the OpenClaw channel account."})]}),b&&w?(0,s.jsx)("div",{className:"rounded-2xl border border-cyan-300/20 bg-cyan-400/[0.08] px-3 py-2",children:(0,s.jsxs)("div",{className:"flex items-center gap-2 text-[11px] text-cyan-50",children:[(0,s.jsx)(i.A,{className:"h-3.5 w-3.5 animate-spin"}),(0,s.jsx)("span",{children:w})]})}):null,eS?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsx)("div",{className:"rounded-[20px] border border-rose-500/25 bg-rose-500/[0.08] p-4",children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)(o.A,{className:"mt-0.5 h-4 w-4 shrink-0 text-rose-200"}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("p",{className:"text-sm font-medium text-rose-50",children:["Deleting ",S?.name," will remove access from every place it is used."]}),(0,s.jsx)("p",{className:"mt-1 text-xs leading-5 text-rose-100/80",children:eS.workspaceBindings.length>0?`It is currently connected to ${eS.workspaceBindings.length} workspace${1===eS.workspaceBindings.length?"":"s"} and ${eS.affectedAgentNames.length} agent${1===eS.affectedAgentNames.length?"":"s"}.`:"It is not connected to any workspace yet, so this will only remove the stored account."})]})]})}),(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-3",children:[(0,s.jsx)(ay,{label:"Workspace links",value:String(eS.workspaceBindings.length)}),(0,s.jsx)(ay,{label:"Affected agents",value:String(eS.affectedAgentNames.length)}),(0,s.jsx)(ay,{label:"Primary",value:eS.primaryAgentName??"Unset"})]}),eS.affectedWorkspaceDetails.length>0?(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("p",{className:"text-[11px] uppercase tracking-[0.18em] text-slate-400",children:"Affected workspaces"}),(0,s.jsx)("div",{className:"space-y-2",children:eS.affectedWorkspaceDetails.map(e=>(0,s.jsx)("div",{className:"rounded-2xl border border-white/8 bg-white/[0.03] px-3 py-2.5",children:(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"truncate text-sm font-medium text-white",children:e.workspaceName}),(0,s.jsx)("p",{className:"mt-1 text-[11px] text-slate-400",children:e.agentNames.length>0?e.agentNames.join(", "):"No direct agent bindings"})]}),(0,s.jsxs)(k.E,{variant:"muted",className:"h-5 rounded-full px-2 text-[10px]",children:[e.groupRouteCount," group routes"]})]})},e.workspaceId))})]}):null,(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(aw,{label:`Type ${S?.name??""} to confirm`,htmlFor:"delete-channel-confirm",children:(0,s.jsx)(T,{id:"delete-channel-confirm",value:M,onChange:e=>D(e.target.value),placeholder:S?.name??""})}),(0,s.jsx)("p",{className:"text-[11px] text-slate-400",children:"This action is permanent. The account, workspace bindings, and agent references will be removed."})]})]}):null,(0,s.jsxs)(ea,{children:[(0,s.jsx)(I,{variant:"secondary",onClick:em,children:"Cancel"}),(0,s.jsx)(I,{variant:"destructive",disabled:!eA||b,onClick:()=>void eI(),children:b?"Deleting...":"Delete everywhere"})]})]})})]})}function aw({label:e,htmlFor:t,children:a}){return(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(e$,{htmlFor:t,className:"text-[10px] uppercase tracking-[0.16em] text-slate-400",children:e}),a]})}function ay({label:e,value:t}){return(0,s.jsxs)("div",{className:"rounded-2xl border border-white/8 bg-white/[0.02] px-3 py-2.5",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.18em] text-slate-400",children:e}),(0,s.jsx)("p",{className:"mt-1 truncate text-sm font-medium text-white",children:t})]})}function av(e){return Array.from(new Set(e.filter(Boolean)))}function aj(e){return e.trim().toLowerCase()}var ak=a(93);function aN({progress:e,className:t}){return(0,s.jsxs)("div",{className:(0,S.cn)("rounded-[18px] border border-white/10 bg-slate-950/50 p-4",t),children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"max-w-2xl",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.22em] text-slate-500",children:e.title}),(0,s.jsx)("p",{className:"mt-2 text-sm text-slate-200",children:e.description})]}),(0,s.jsxs)("div",{className:"shrink-0 text-right",children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Progress"}),(0,s.jsxs)("p",{className:"mt-1 text-lg font-semibold text-white",children:[e.percent,"%"]})]})]}),(0,s.jsx)("div",{className:"mt-4 h-2 overflow-hidden rounded-full bg-white/8",children:(0,s.jsx)("div",{className:"h-full rounded-full bg-cyan-300/85 transition-[width] duration-500 ease-out",style:{width:`${e.percent}%`}})}),(0,s.jsx)("div",{className:"mt-4 space-y-2.5",children:e.steps.map((e,t)=>{let a="done"===e.status?"border-emerald-400/20 bg-emerald-400/10":"active"===e.status?"border-cyan-400/25 bg-cyan-400/10":"error"===e.status?"border-amber-400/25 bg-amber-400/10":"border-white/10 bg-white/[0.03]",r="done"===e.status?"border-emerald-300/30 bg-emerald-300/15 text-emerald-100":"active"===e.status?"border-cyan-300/30 bg-cyan-300/15 text-cyan-100":"error"===e.status?"border-amber-300/30 bg-amber-300/15 text-amber-100":"border-white/10 bg-slate-950/65 text-slate-400",n="done"===e.status?"bg-emerald-300/85":"active"===e.status?"bg-cyan-300/85":"error"===e.status?"bg-amber-300/85":"bg-transparent";return(0,s.jsx)("div",{className:(0,S.cn)("rounded-[14px] border px-3 py-2.5 transition-colors",a),children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("span",{className:(0,S.cn)("mt-0.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full border text-[10px] font-medium",r),children:"done"===e.status?(0,s.jsx)(j.A,{className:"h-3.5 w-3.5"}):"active"===e.status?(0,s.jsx)(i.A,{className:"h-3.5 w-3.5 animate-spin"}):"error"===e.status?(0,s.jsx)(o.A,{className:"h-3.5 w-3.5"}):t+1}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[(0,s.jsx)("p",{className:"text-sm text-white",children:e.label}),(0,s.jsxs)("span",{className:"text-xs tabular-nums text-slate-400",children:[e.percent,"%"]})]}),(0,s.jsx)("p",{className:"mt-0.5 text-xs leading-5 text-slate-400",children:e.detail||e.description}),(0,s.jsx)("div",{className:"mt-2 h-1.5 overflow-hidden rounded-full bg-white/8",children:(0,s.jsx)("div",{className:(0,S.cn)("h-full rounded-full transition-[width] duration-500 ease-out",n),style:{width:`${e.percent}%`}})}),e.activities.length>0?(0,s.jsx)("div",{className:"mt-2.5 space-y-1.5",children:e.activities.map(e=>(0,s.jsxs)("div",{className:"flex items-start gap-2 text-[11px] leading-5 text-slate-300",children:[(0,s.jsx)("span",{className:(0,S.cn)("mt-[7px] h-1.5 w-1.5 shrink-0 rounded-full","done"===e.status&&"bg-emerald-300","active"===e.status&&"bg-cyan-300","error"===e.status&&"bg-amber-300","pending"===e.status&&"bg-slate-500")}),(0,s.jsx)("span",{className:"min-w-0",children:e.message})]},e.id))}):null]})]})},e.id)})})]})}var aC=a(6595);let aS=["AGENTS.md","SOUL.md","IDENTITY.md","TOOLS.md","HEARTBEAT.md"],aA={software:"Software project",frontend:"Frontend app",backend:"Backend/API",research:"Research",content:"Content/Growth"},aI=["Use repository-local scripts or documented commands for repeatable workflows.","Update this file when the project exposes a cleaner build, test, or release path."];function aT(e){let t=[{id:"agents",label:"AGENTS.md",relativePath:"AGENTS.md",kind:"file",headings:["Workspace","Team","Customize","Safety defaults","Daily memory","Output"]},{id:"soul",label:"SOUL.md",relativePath:"SOUL.md",kind:"file",headings:["My Purpose","How I Operate","My Quirks","Active Focus"]},{id:"identity",label:"IDENTITY.md",relativePath:"IDENTITY.md",kind:"file",headings:["Role"]},{id:"tools",label:"TOOLS.md",relativePath:"TOOLS.md",kind:"file",headings:["Examples","Notes"]},{id:"heartbeat",label:"HEARTBEAT.md",relativePath:"HEARTBEAT.md",kind:"file",headings:[]},{id:"memory-md",label:"MEMORY.md",relativePath:"MEMORY.md",kind:"file",headings:["Current brief","Stable facts"]},{id:"memory-blueprint",label:"memory/blueprint.md",relativePath:"memory/blueprint.md",kind:"file",headings:["Outcome","Constraints","Unknowns"]},{id:"memory-decisions",label:"memory/decisions.md",relativePath:"memory/decisions.md",kind:"file",headings:["Template"]},{id:"docs-brief",label:"docs/brief.md",relativePath:"docs/brief.md",kind:"file",headings:["Objective","Success signals","Open questions"]},{id:"docs-architecture",label:"docs/architecture.md",relativePath:"docs/architecture.md",kind:"file",headings:["Current shape","Dependencies","Risks"]},{id:"deliverables-readme",label:"deliverables/README.md",relativePath:"deliverables/README.md",kind:"file",headings:["Deliverables"]}];return"frontend"===e&&t.push({id:"docs-ux-notes",label:"docs/ux-notes.md",relativePath:"docs/ux-notes.md",kind:"file",headings:["UX Notes"]}),"backend"===e&&t.push({id:"docs-service-map",label:"docs/service-map.md",relativePath:"docs/service-map.md",kind:"file",headings:["Service Map"]}),"research"===e&&t.push({id:"docs-research-plan",label:"docs/research-plan.md",relativePath:"docs/research-plan.md",kind:"file",headings:["Research Plan"]}),"content"===e&&t.push({id:"docs-content-brief",label:"docs/content-brief.md",relativePath:"docs/content-brief.md",kind:"file",headings:["Content Brief"]}),t}function aM(e,t){let a=new Map(aT(e??null).map(e=>[e.relativePath,e])),s=e=>e.map(e=>a.get(e)).filter(Boolean),r=[{id:"core",title:"Core bootstrap",description:"Required for every workspace and shared by all agents.",enabled:!0,resources:s(aS)},{id:"memory",title:"Memory",description:"Durable notes and decisions that survive across sessions.",enabled:t.generateMemory,resources:t.generateMemory?s(["MEMORY.md","memory/blueprint.md","memory/decisions.md"]):[]},{id:"starter",title:"Starter docs",description:"Planning, architecture, and handoff docs used for the first pass.",enabled:t.generateStarterDocs,resources:t.generateStarterDocs?s(["docs/brief.md","docs/architecture.md","deliverables/README.md",..."frontend"===e?["docs/ux-notes.md"]:"backend"===e?["docs/service-map.md"]:"research"===e?["docs/research-plan.md"]:"content"===e?["docs/content-brief.md"]:[]]):[]}];return{template:e??null,rules:t,sections:r,resources:r.flatMap(e=>e.resources)}}function aO(e){let t=aE(e.template,e.rules),a=new Map(a$(e.docOverrides).map(e=>[e.path,e.content]));return t.map(t=>{let s=t.render(e),r=a.has(t.path);return{path:t.path,title:t.title,description:t.description,category:t.category,baseContent:s,content:r?a.get(t.path)??"":s,overridden:r}})}function aR(e){let t=aO(e).map(e=>({...e,generated:!0})),a=new Set(t.map(e=>e.path));return[...t,...a$(e.docOverrides).filter(e=>!a.has(e.path)).map(e=>{var t;return{path:e.path,title:e.path,description:"Existing workspace file.",category:(t=e.path).startsWith("memory/")?"memory":t.startsWith("docs/")?"docs":t.startsWith("deliverables/")?"deliverables":"core",baseContent:e.content,content:e.content,overridden:!1,generated:!1}})]}function a$(e){let t=new Map;for(let a of e??[]){let e=a.path.trim();e&&t.set(e,a.content)}return Array.from(t.entries()).map(([e,t])=>({path:e,content:t}))}function aE(e,t){let a=[{path:"AGENTS.md",title:"AGENTS.md",description:"Shared operating instructions for all agents.",category:"core",render:aD},{path:"SOUL.md",title:"SOUL.md",description:"Purpose, operating style, and active focus.",category:"core",render:({template:e,brief:t,contextSources:a})=>{var s,r,n;return s=e,r=t,n=a,`# SOUL
10
-
11
- ## My Purpose
12
- Help this ${aA[s].toLowerCase()} workspace turn intent into real outcomes with pragmatic execution, verification, and durable memory.
13
-
14
- ## How I Operate
15
- - Start from the current workspace reality before proposing large moves.
16
- - Prefer concrete action, visible artifacts, and clear handoffs.
17
- - Keep docs, memory, and deliverables aligned with the actual state of the work.
18
-
19
- ## My Quirks
20
- - Pragmatic
21
- - Direct
22
- - Product-aware
23
- - Quality-minded
24
-
25
- ${r?`## Active Focus
26
- ${r}
27
- `:""}${aP(n)}`}},{path:"IDENTITY.md",title:"IDENTITY.md",description:"Workspace identity and vibe.",category:"core",render:({template:e})=>{var t;return t=e,`# IDENTITY
28
-
29
- ## Role
30
- This workspace hosts a ${aA[t].toLowerCase()} team coordinated through OpenClaw.
31
-
32
- **Vibe:** pragmatic, concise, quality-minded, workspace-grounded
33
- `}},{path:"TOOLS.md",title:"TOOLS.md",description:"Repository commands and workflow notes.",category:"core",render:({template:e,toolExamples:t})=>{var a,s;return a=e,s=t??aI,`# TOOLS
34
-
35
- Repository commands and workflow notes for this ${aA[a].toLowerCase()} workspace.
36
-
37
- ## Examples
38
- ${s.map(e=>`- ${e}`).join("\n")}
39
-
40
- ## Notes
41
- - Replace these examples with sharper project-specific commands when the repo exposes them.
42
- - Prefer repeatable commands that other agents can run without interpretation drift.
43
- `}},{path:"HEARTBEAT.md",title:"HEARTBEAT.md",description:"Refresh ritual and coherence checks.",category:"core",render:({template:e})=>{var t;return t=e,`# HEARTBEAT
44
-
45
- - Start each substantial task by refreshing the brief, docs, and current files.
46
- - Keep the ${aA[t].toLowerCase()} workspace coherent across code, docs, and memory.
47
- - Prefer explicit handoffs between implementation, review, testing, and knowledge capture.
48
- `}}];return t.generateMemory&&a.push({path:"MEMORY.md",title:"MEMORY.md",description:"Durable project memory.",category:"memory",render:({name:e,template:t,brief:a,contextSources:s})=>{var r,n,i,l;return r=e,n=t,i=a,l=s,`# ${r} Memory
49
-
50
- Durable project facts for this ${aA[n].toLowerCase()} workspace.
51
-
52
- ## Current brief
53
- ${i||"No brief captured yet. Fill this in as soon as the project goal is clarified."}
54
-
55
- ## Stable facts
56
- - Add durable architecture, product, or workflow facts here.
57
- - Move longer notes into memory/*.md when they outgrow this file.
58
-
59
- ${aP(l)}`}},{path:"memory/blueprint.md",title:"memory/blueprint.md",description:"Project blueprint and current outcome.",category:"memory",render:({name:e,template:t,brief:a})=>{var s,r,n;return s=e,r=t,n=a,`# ${s} Blueprint
60
-
61
- ## Workspace type
62
- ${aA[r]}
63
-
64
- ## Outcome
65
- ${n||"Define the target outcome, user impact, and quality bar for this workspace."}
66
-
67
- ## Constraints
68
- - Add technical, product, legal, or operational constraints here.
69
-
70
- ## Unknowns
71
- - Capture unresolved questions that block confident execution.
72
- `}},{path:"memory/decisions.md",title:"memory/decisions.md",description:"Decision log.",category:"memory",render:()=>`# Decisions
73
-
74
- Use this file for durable decisions that should survive across sessions.
75
-
76
- ## Template
77
- - Date:
78
- - Decision:
79
- - Context:
80
- - Consequence:
81
- `}),t.generateStarterDocs&&a.push({path:"docs/brief.md",title:"docs/brief.md",description:"Objective, source mode, and success signals.",category:"docs",render:({name:e,template:t,brief:a,sourceMode:s,contextSources:r})=>{var n,i,l,o,d;return n=e,i=t,l=a,o=s,d=r,`# ${n} Brief
82
-
83
- ## Template
84
- ${aA[i]}
85
-
86
- ## Source mode
87
- ${o}
88
-
89
- ## Objective
90
- ${l||"Clarify the main goal, target user, and success definition for this workspace."}
91
-
92
- ## Success signals
93
- - Define what success looks like in observable terms.
94
-
95
- ## Open questions
96
- - List the unknowns worth resolving first.
97
-
98
- ${aP(d)}`}},{path:"docs/architecture.md",title:"docs/architecture.md",description:"Current system shape and dependencies.",category:"docs",render:({template:e,contextSources:t})=>{var a,s;return a=e,s=t,`# Architecture
99
-
100
- ## Current shape
101
- - Describe the main components, systems, or content lanes in this ${aA[a].toLowerCase()} workspace.
102
-
103
- ## Dependencies
104
- - List critical external services, repos, data sources, or channels.
105
-
106
- ## Risks
107
- - Capture structural, operational, or delivery risks here.
108
-
109
- ${aP(s)}`}},{path:"deliverables/README.md",title:"deliverables/README.md",description:"Guidance for handoff artifacts.",category:"deliverables",render:()=>`# Deliverables
110
-
111
- Use this folder for substantial output artifacts that should be easy to hand off or review.
112
-
113
- - Create one subfolder per task or run, for example \`deliverables/2026-03-07-15-30-00-launch-brief/\`.
114
- - Put drafts, reports, docs, and publishable assets for that task inside its run folder.
115
- - Keep filenames descriptive and tied to the task or audience.
116
- `}),"frontend"===e&&a.push({path:"docs/ux-notes.md",title:"docs/ux-notes.md",description:"Interaction patterns and UI risks.",category:"docs",render:()=>a_("ux")}),"backend"===e&&a.push({path:"docs/service-map.md",title:"docs/service-map.md",description:"Service, queue, and dependency map.",category:"docs",render:()=>a_("backend")}),"research"===e&&a.push({path:"docs/research-plan.md",title:"docs/research-plan.md",description:"Question framing and evidence plan.",category:"docs",render:()=>a_("research")}),"content"===e&&a.push({path:"docs/content-brief.md",title:"docs/content-brief.md",description:"Audience, channel, and campaign brief.",category:"docs",render:()=>a_("content")}),a}function aD({name:e,brief:t,template:a,sourceMode:s,rules:r,agents:n=[]}){let i=n.map(e=>`- ${e.role}: ${e.name}${e.skillId?` \xb7 skill ${e.skillId}`:""}${e.policy?` \xb7 ${(0,eg._P)(e.policy.preset)}`:""}`);return`# ${e}
117
-
118
- Shared project context for all agents working in this workspace.
119
-
120
- ## Workspace
121
- - Template: ${aA[a]}
122
- - Source mode: ${s}
123
- - Workspace-only access: ${r.workspaceOnly?"enabled":"disabled"}
124
-
125
- ## Team
126
- ${i.length>0?i.join("\n"):"- No agents configured yet."}
127
-
128
- ## Customize
129
- ${t||"Clarify the project goal, definition of done, constraints, and success signals before large changes."}
130
-
131
- ## Safety defaults
132
- - Stay inside the attached workspace unless the task explicitly requires another location.
133
- - Prefer direct, reviewable changes over speculative rewrites.
134
- - Preserve user work and avoid destructive actions without clear approval.
135
- - Update durable docs when stable architecture, workflow, or product decisions change.
136
- - Worker and browser agents should not install tooling unless their explicit policy allows it.
137
- - Route environment preparation to setup-oriented agents when the work depends on new tooling.
138
-
139
- ## Daily memory
140
- - Capture durable facts in MEMORY.md and memory/*.md.
141
- - Record stable decisions in memory/decisions.md.
142
- - Keep temporary chatter and scratch notes in memory/.
143
-
144
- ## Output
145
- - Be concise in chat and write longer output to files when the artifact matters.
146
- - Put task-specific deliverables, drafts, reports, and docs inside per-run folders under deliverables/.
147
- - Avoid writing final artifacts to the workspace root unless explicitly requested.
148
- `}function a_(e){return"ux"===e?`# UX Notes
149
-
150
- - Track interaction patterns, responsive edge cases, and visual risk areas here.
151
- `:"backend"===e?`# Service Map
152
-
153
- - Document services, jobs, queues, external dependencies, and critical flows here.
154
- `:"research"===e?`# Research Plan
155
-
156
- - State the question, method, evidence sources, and expected output before large investigation work.
157
- `:`# Content Brief
158
-
159
- - Capture audience, channel, tone, CTA, and distribution assumptions for this content workspace.
160
- `}function aP(e){let t=(e??[]).filter(e=>"error"!==e.status&&e.summary.trim().length>0).slice(0,4);if(0===t.length)return"";let a=t.filter(e=>(e.confidence??100)>=80),s=t.filter(e=>(e.confidence??100)<80),r=e=>{let t="website"===e.kind?"Website":"repo"===e.kind?"Repo":"folder"===e.kind?"Folder":"Prompt",a="number"==typeof e.confidence?` (${e.confidence}%)`:"";return`- ${t}: ${e.label}${a} - ${e.summary}`},n=[];return a.length>0&&n.push(`## Evidence
161
- ${a.map(r).join("\n")}`),s.length>0&&n.push(`## Assumptions
162
- ${s.map(r).join("\n")}`),n.length>0?`
163
- ${n.join("\n\n")}
164
- `:""}let aL=[{value:"empty",label:"Empty workspace",description:"Create a fresh project folder and scaffold the shared OpenClaw context."},{value:"clone",label:"Clone repo",description:"Clone a repository first, then layer workspace docs, memory, and agents on top."},{value:"existing",label:"Use existing folder",description:"Attach OpenClaw to a folder that already exists and preserve any current files."}],aU=[{value:"software",label:"Software project",description:"Balanced software delivery setup for product and engineering work."},{value:"frontend",label:"Frontend app",description:"UI-focused team with browser coverage and product-facing documentation."},{value:"backend",label:"Backend/API",description:"Service and API template with strong testing and delivery defaults."},{value:"research",label:"Research",description:"Exploration-first workspace for investigation, synthesis, and durable notes."},{value:"content",label:"Content/Growth",description:"Campaign and content setup for strategy, writing, review, and analytics."}],aF=[{value:"balanced",label:"Balanced",description:"General-purpose default for daily execution, review, and coordination."},{value:"fast",label:"Fast",description:"Favor speed and iteration for high-throughput tasking and first passes."},{value:"quality",label:"Quality",description:"Favor deeper reasoning and more careful outputs for critical work."}],az={workspaceOnly:!0,generateStarterDocs:!0,generateMemory:!0,kickoffMission:!0},aW={software:[{id:"builder",role:"Builder",name:"Builder",emoji:"\uD83D\uDEE0️",theme:"amber",skillId:"project-builder",isPrimary:!0,description:"Implements requested changes and drives delivery forward."},{id:"reviewer",role:"Reviewer",name:"Reviewer",emoji:"\uD83D\uDD0D",theme:"rose",skillId:"project-reviewer",description:"Reviews work for correctness, regressions, and product risk."},{id:"tester",role:"Tester",name:"Tester",emoji:"\uD83E\uDDEA",theme:"emerald",skillId:"project-tester",description:"Validates behavior, tests, and environment assumptions."},{id:"learner",role:"Learner",name:"Learner",emoji:"\uD83E\uDDE0",theme:"cyan",skillId:"project-learner",description:"Consolidates durable project knowledge and memory."}],frontend:[{id:"builder",role:"Builder",name:"Builder",emoji:"\uD83D\uDEE0️",theme:"amber",skillId:"project-builder",isPrimary:!0,description:"Implements UI and frontend product work."},{id:"reviewer",role:"Reviewer",name:"Reviewer",emoji:"\uD83D\uDD0D",theme:"rose",skillId:"project-reviewer",description:"Reviews interaction, correctness, and regression risk."},{id:"tester",role:"Tester",name:"Tester",emoji:"\uD83E\uDDEA",theme:"emerald",skillId:"project-tester",description:"Checks behavior, responsive states, and verification gaps."},{id:"learner",role:"Learner",name:"Learner",emoji:"\uD83E\uDDE0",theme:"cyan",skillId:"project-learner",description:"Maintains stable product and implementation knowledge."},{id:"browser",role:"Browser Agent",name:"Browser Agent",emoji:"\uD83C\uDF10",theme:"blue",skillId:"project-browser",description:"Exercises browser flows, captures UI evidence, and validates user paths."}],backend:[{id:"builder",role:"Builder",name:"Builder",emoji:"\uD83D\uDEE0️",theme:"amber",skillId:"project-builder",isPrimary:!0,description:"Implements service, API, and infrastructure changes."},{id:"reviewer",role:"Reviewer",name:"Reviewer",emoji:"\uD83D\uDD0D",theme:"rose",skillId:"project-reviewer",description:"Catches correctness, data handling, and operational risks."},{id:"tester",role:"Tester",name:"Tester",emoji:"\uD83E\uDDEA",theme:"emerald",skillId:"project-tester",description:"Validates APIs, background jobs, migrations, and failure paths."},{id:"learner",role:"Learner",name:"Learner",emoji:"\uD83E\uDDE0",theme:"cyan",skillId:"project-learner",description:"Maintains architecture notes and durable operational memory."}],research:[{id:"researcher",role:"Research Lead",name:"Research Lead",emoji:"\uD83D\uDD2C",theme:"violet",skillId:"project-researcher",isPrimary:!0,description:"Runs investigations, frames questions, and synthesizes findings."},{id:"reviewer",role:"Reviewer",name:"Reviewer",emoji:"\uD83D\uDD0D",theme:"rose",skillId:"project-reviewer",description:"Pressure-tests claims, assumptions, and interpretation quality."},{id:"learner",role:"Archivist",name:"Archivist",emoji:"\uD83E\uDDE0",theme:"cyan",skillId:"project-learner",description:"Distills durable research notes, memory, and takeaways."}],content:[{id:"strategist",role:"Strategist",name:"Strategist",emoji:"\uD83D\uDCE3",theme:"orange",skillId:"project-strategist",isPrimary:!0,description:"Frames audience, goals, positioning, and campaign direction."},{id:"writer",role:"Writer",name:"Writer",emoji:"✍️",theme:"sky",skillId:"project-writer",description:"Drafts content, messaging, and campaign assets."},{id:"reviewer",role:"Reviewer",name:"Reviewer",emoji:"\uD83D\uDD0D",theme:"rose",skillId:"project-reviewer",description:"Edits for clarity, quality, and consistency."},{id:"analyst",role:"Analyst",name:"Analyst",emoji:"\uD83D\uDCC8",theme:"emerald",skillId:"project-analyst",description:"Tracks results, experiments, and performance insights."}]};function aB(e,t,a){let s=function(e){let t=e?.trim();if(!t)return"";let a=(!/\s/.test(t)&&t.includes(".")?t.split(".")[0]:t).replace(/[^A-Za-z0-9\u00C0-\u024F]+/g," ").trim();return a?a.split(/\s+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" "):""}(e);if(!s)return a;let r=t.trim();return r?`${s} ${r}`:s}function aq(e){if("raw"===e)return"workspace";let[t]=e.split(".");return t}function aK({open:e,surfaceTheme:t,plan:a,focus:r,busy:n=!1,onClose:l,onSave:o}){var d;let[c,p]=(0,g.useState)(()=>"raw"===r?"raw":"fields"),[m,u]=(0,g.useState)(()=>{var e;return a?{companyName:(e=a).company.name,companyMission:e.company.mission,companyTargetCustomer:e.company.targetCustomer,companyConstraints:aV(e.company.constraints),companySuccessSignals:aV(e.company.successSignals),productOffer:e.product.offer,productRevenueModel:e.product.revenueModel,productScopeV1:aV(e.product.scopeV1),productNonGoals:aV(e.product.nonGoals),productLaunchPriority:aV(e.product.launchPriority),workspaceName:e.workspace.name,workspaceDirectory:e.workspace.directory??"",workspaceSourceMode:e.workspace.sourceMode,workspaceRepoUrl:e.workspace.repoUrl??"",workspaceExistingPath:e.workspace.existingPath??"",workspaceTemplate:e.workspace.template,workspaceModelProfile:e.workspace.modelProfile,workspaceModelId:e.workspace.modelId??"",workspaceStackDecisions:aV(e.workspace.stackDecisions),workspaceDocs:aV(e.workspace.docs),workspaceRuleGenerateStarterDocs:e.workspace.rules.generateStarterDocs,workspaceRuleGenerateMemory:e.workspace.rules.generateMemory,workspaceRuleKickoffMission:e.workspace.rules.kickoffMission,intakeReviewRequested:e.intake.reviewRequested,intakeAutopilot:e.autopilot,teamAllowEphemeralSubagents:e.team.allowEphemeralSubagents,teamMaxParallelRuns:String(e.team.maxParallelRuns),teamEscalationRules:aV(e.team.escalationRules),deployBlockers:aV(e.deploy.blockers),deployWarnings:aV(e.deploy.warnings),deployFirstMissions:aV(e.deploy.firstMissions)}:null}),[h,x]=(0,g.useState)(()=>a?JSON.stringify(a,null,2):""),[b,f]=(0,g.useState)(null),w=(0,g.useRef)({}),y=(0,g.useRef)({}),v="light"===t,j=r&&"raw"!==r?aq(r):null,k=r&&"raw"!==r&&(d=r).includes(".")?d:null;(0,g.useEffect)(()=>{if(!e||!a||!r||"raw"===r||"fields"!==c)return;let t=aq(r),s=k?y.current[k]??w.current[t]:w.current[t];s&&globalThis.requestAnimationFrame(()=>{s.scrollIntoView({behavior:"smooth",block:k?"center":"start"}),k&&s===y.current[k]&&"function"==typeof s.focus&&s.focus({preventScroll:!0})})},[r,k,e,a,c]);let N=!!(a&&m);if(!e||!a||!m)return null;let C=(e,t)=>{u(a=>a?{...a,[e]:t}:a)},A=e=>t=>{y.current[e]=t},M=async()=>{var e,t,s,r;let n,i,d,c,p,u,h,x,g=(e=a,t=m,n=structuredClone(e),i=e.company.name.trim(),d=e.workspace.name.trim(),c=t.companyName.trim(),p=t.workspaceName.trim(),u=c!==i,h=p!==d,n.company.name=c,n.company.mission=t.companyMission.trim(),n.company.targetCustomer=t.companyTargetCustomer.trim(),n.company.constraints=aJ(t.companyConstraints),n.company.successSignals=aJ(t.companySuccessSignals),n.product.offer=t.productOffer.trim(),n.product.revenueModel=t.productRevenueModel.trim(),n.product.scopeV1=aJ(t.productScopeV1),n.product.nonGoals=aJ(t.productNonGoals),n.product.launchPriority=aJ(t.productLaunchPriority),n.workspace.name=p,n.workspace.directory=aH(t.workspaceDirectory),n.workspace.sourceMode=t.workspaceSourceMode,n.workspace.repoUrl=aH(t.workspaceRepoUrl),n.workspace.existingPath=aH(t.workspaceExistingPath),n.workspace.template=t.workspaceTemplate,n.workspace.modelProfile=t.workspaceModelProfile,n.workspace.modelId=aH(t.workspaceModelId),n.workspace.stackDecisions=aJ(t.workspaceStackDecisions),n.workspace.docs=aJ(t.workspaceDocs),n.workspace.rules={...n.workspace.rules,workspaceOnly:!0,generateStarterDocs:t.workspaceRuleGenerateStarterDocs,generateMemory:t.workspaceRuleGenerateMemory,kickoffMission:t.workspaceRuleKickoffMission},h&&!u?n.company.name=p:u&&!h&&(n.workspace.name=c),n.team.allowEphemeralSubagents=t.teamAllowEphemeralSubagents,n.team.maxParallelRuns=Number.isFinite(Number(t.teamMaxParallelRuns))?Math.max(1,Number(t.teamMaxParallelRuns)):n.team.maxParallelRuns,n.team.escalationRules=aJ(t.teamEscalationRules),n.intake.reviewRequested=t.intakeReviewRequested,n.autopilot=t.intakeAutopilot,n.deploy.blockers=aJ(t.deployBlockers),n.deploy.warnings=aJ(t.deployWarnings),n.deploy.firstMissions=aJ(t.deployFirstMissions),n),b=(s=a,r=g,x=[],(aG(s.company,r.company)&&x.push("company"),aG(s.product,r.product)&&x.push("product"),aG(s.workspace,r.workspace)&&x.push("workspace"),aG(s.team,r.team)&&x.push("team"),aG({reviewRequested:s.intake.reviewRequested,autopilot:s.autopilot},{reviewRequested:r.intake.reviewRequested,autopilot:r.autopilot})&&x.push("intake"),aG(s.deploy,r.deploy)&&x.push("deploy"),0===x.length)?"Manual blueprint edit applied.":`Manual blueprint edit applied to ${x.join(", ")}.`);await o(g,b)&&l()},D=async()=>{try{let e=JSON.parse(h);await o(e,"Manual raw blueprint edit applied.")&&l()}catch(e){f(e instanceof Error?e.message:"Raw JSON could not be parsed.")}};return(0,s.jsxs)("div",{className:"absolute inset-0 z-30",children:[(0,s.jsx)("button",{type:"button","aria-label":"Close blueprint editor",onClick:l,className:(0,S.cn)("absolute inset-0 h-full w-full cursor-default",v?"bg-[rgba(17,14,10,0.26)]":"bg-[rgba(2,6,13,0.56)]")}),(0,s.jsxs)("div",{className:(0,S.cn)("absolute inset-y-0 right-0 flex h-full w-full flex-col border-l shadow-[0_34px_120px_rgba(0,0,0,0.35)] lg:max-w-[760px]",v?"border-[#e6ded4] bg-[linear-gradient(180deg,rgba(255,253,249,0.98),rgba(247,241,233,0.98))] text-[#151311]":"border-white/10 bg-[linear-gradient(180deg,rgba(5,9,18,0.98),rgba(3,7,15,0.98))] text-white"),onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:(0,S.cn)("flex items-start justify-between gap-4 border-b px-4 py-4 md:px-5",v?"border-[#e7dfd4]":"border-white/10"),children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[11px] uppercase tracking-[0.18em]",v?"text-[#9a9085]":"text-slate-500"),children:"Blueprint editor"}),(0,s.jsx)("h2",{className:(0,S.cn)("mt-1 text-[18px] font-semibold tracking-[-0.03em]",v?"text-[#171410]":"text-white"),children:"Edit any detail, then keep chatting with Architect"}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1 text-[13px] leading-6",v?"text-[#6f675e]":"text-slate-300"),children:"Structured fields cover the common edits. Raw JSON lets you change anything else in the same plan."})]}),(0,s.jsx)("button",{type:"button",onClick:l,className:(0,S.cn)("inline-flex size-9 shrink-0 items-center justify-center rounded-full border transition-colors",v?"border-[#e3dbd0] bg-white text-[#5d564d] hover:bg-[#f5efe6]":"border-white/10 bg-white/[0.05] text-slate-300 hover:bg-white/[0.08]"),children:(0,s.jsx)(H.A,{className:"h-4 w-4"})})]}),(0,s.jsxs)("div",{className:(0,S.cn)("flex items-center gap-2 border-b px-4 py-3 md:px-5",v?"border-[#e7dfd4]":"border-white/10"),children:[(0,s.jsx)(aY,{surfaceTheme:t,label:`Stage \xb7 ${a.stage}`}),(0,s.jsx)(aY,{surfaceTheme:t,label:`Status \xb7 ${a.status}`}),(0,s.jsx)(aY,{surfaceTheme:t,label:`Readiness \xb7 ${a.readinessScore}%`})]}),(0,s.jsxs)(O,{value:c,onValueChange:e=>p(e),className:"flex min-h-0 flex-1 flex-col px-4 py-4 md:px-5",children:[(0,s.jsxs)(R,{className:(0,S.cn)("w-fit",v?"bg-[#f2ece4] text-[#645b52]":"bg-white/5"),children:[(0,s.jsx)($,{value:"fields",children:"Fields"}),(0,s.jsx)($,{value:"raw",children:"Raw JSON"})]}),(0,s.jsx)(E,{value:"fields",className:"min-h-0 flex-1",children:(0,s.jsx)(aC.F,{className:"h-full pr-1",children:(0,s.jsxs)("div",{className:"space-y-4 pb-4",children:[(0,s.jsxs)("div",{className:"grid gap-4 xl:grid-cols-2",children:[(0,s.jsxs)(aQ,{surfaceTheme:t,sectionId:"company",highlighted:"company"===j,title:"Company",description:"Mission and audience details.",register:e=>{w.current.company=e},children:[(0,s.jsx)(aZ,{label:"Name",children:(0,s.jsx)(T,{ref:A("company.name"),value:m.companyName,onChange:e=>C("companyName",e.target.value)})}),(0,s.jsx)(aZ,{label:"Mission",children:(0,s.jsx)(eY,{ref:A("company.mission"),value:m.companyMission,onChange:e=>C("companyMission",e.target.value),className:"min-h-[96px]"})}),(0,s.jsx)(aZ,{label:"Target customer",children:(0,s.jsx)(T,{ref:A("company.targetCustomer"),value:m.companyTargetCustomer,onChange:e=>C("companyTargetCustomer",e.target.value)})}),(0,s.jsx)(aZ,{label:"Constraints",children:(0,s.jsx)(eY,{ref:A("company.constraints"),value:m.companyConstraints,onChange:e=>C("companyConstraints",e.target.value),placeholder:"One constraint per line",className:"min-h-[84px]"})}),(0,s.jsx)(aZ,{label:"Success signals",children:(0,s.jsx)(eY,{ref:A("company.successSignals"),value:m.companySuccessSignals,onChange:e=>C("companySuccessSignals",e.target.value),placeholder:"One signal per line",className:"min-h-[84px]"})})]}),(0,s.jsxs)(aQ,{surfaceTheme:t,sectionId:"product",highlighted:"product"===j,title:"Product",description:"Offer and V1 shape.",register:e=>{w.current.product=e},children:[(0,s.jsx)(aZ,{label:"Offer",children:(0,s.jsx)(eY,{ref:A("product.offer"),value:m.productOffer,onChange:e=>C("productOffer",e.target.value),className:"min-h-[96px]"})}),(0,s.jsx)(aZ,{label:"Revenue model",children:(0,s.jsx)(T,{ref:A("product.revenueModel"),value:m.productRevenueModel,onChange:e=>C("productRevenueModel",e.target.value)})}),(0,s.jsx)(aZ,{label:"Scope V1",children:(0,s.jsx)(eY,{ref:A("product.scopeV1"),value:m.productScopeV1,onChange:e=>C("productScopeV1",e.target.value),placeholder:"One item per line",className:"min-h-[84px]"})}),(0,s.jsx)(aZ,{label:"Non-goals",children:(0,s.jsx)(eY,{ref:A("product.nonGoals"),value:m.productNonGoals,onChange:e=>C("productNonGoals",e.target.value),placeholder:"One item per line",className:"min-h-[84px]"})}),(0,s.jsx)(aZ,{label:"Launch priority",children:(0,s.jsx)(eY,{ref:A("product.launchPriority"),value:m.productLaunchPriority,onChange:e=>C("productLaunchPriority",e.target.value),placeholder:"One item per line",className:"min-h-[84px]"})})]})]}),(0,s.jsxs)(aQ,{surfaceTheme:t,sectionId:"workspace",highlighted:"workspace"===j,title:"Workspace",description:"Provisioning path and bootstrap rules.",register:e=>{w.current.workspace=e},children:[(0,s.jsxs)("div",{className:"grid gap-4 xl:grid-cols-2",children:[(0,s.jsx)(aZ,{label:"Workspace name",children:(0,s.jsx)(T,{ref:A("workspace.name"),value:m.workspaceName,onChange:e=>C("workspaceName",e.target.value)})}),(0,s.jsx)(aZ,{label:"Workspace directory",children:(0,s.jsx)(T,{ref:A("workspace.directory"),value:m.workspaceDirectory,onChange:e=>C("workspaceDirectory",e.target.value)})}),(0,s.jsx)(aZ,{label:"Repository URL",children:(0,s.jsx)(T,{ref:A("workspace.repoUrl"),value:m.workspaceRepoUrl,onChange:e=>C("workspaceRepoUrl",e.target.value)})}),(0,s.jsx)(aZ,{label:"Existing folder path",children:(0,s.jsx)(T,{ref:A("workspace.existingPath"),value:m.workspaceExistingPath,onChange:e=>C("workspaceExistingPath",e.target.value)})}),(0,s.jsx)(aZ,{label:"Model id",children:(0,s.jsx)(T,{ref:A("workspace.modelId"),value:m.workspaceModelId,onChange:e=>C("workspaceModelId",e.target.value)})})]}),(0,s.jsx)(aX,{surfaceTheme:t,label:"Source mode",value:m.workspaceSourceMode,options:aL,onChange:e=>C("workspaceSourceMode",e),fieldRef:A("workspace.sourceMode"),highlighted:"workspace.sourceMode"===k}),(0,s.jsx)(aX,{surfaceTheme:t,label:"Template",value:m.workspaceTemplate,options:aU,onChange:e=>C("workspaceTemplate",e),fieldRef:A("workspace.template"),highlighted:"workspace.template"===k}),(0,s.jsx)(aX,{surfaceTheme:t,label:"Model profile",value:m.workspaceModelProfile,options:aF,onChange:e=>C("workspaceModelProfile",e),fieldRef:A("workspace.modelProfile"),highlighted:"workspace.modelProfile"===k}),(0,s.jsxs)("div",{className:"grid gap-4 xl:grid-cols-2",children:[(0,s.jsx)(aZ,{label:"Stack decisions",children:(0,s.jsx)(eY,{ref:A("workspace.stackDecisions"),value:m.workspaceStackDecisions,onChange:e=>C("workspaceStackDecisions",e.target.value),placeholder:"One item per line",className:"min-h-[84px]"})}),(0,s.jsx)(aZ,{label:"Docs",children:(0,s.jsx)(eY,{ref:A("workspace.docs"),value:m.workspaceDocs,onChange:e=>C("workspaceDocs",e.target.value),placeholder:"One item per line",className:"min-h-[84px]"})})]}),(0,s.jsx)(a0,{surfaceTheme:t,label:"Starter docs",description:"Generate the first brief, architecture, and deliverables scaffold.",checked:m.workspaceRuleGenerateStarterDocs,onToggle:()=>C("workspaceRuleGenerateStarterDocs",!m.workspaceRuleGenerateStarterDocs),fieldRef:A("workspace.ruleGenerateStarterDocs"),highlighted:"workspace.ruleGenerateStarterDocs"===k}),(0,s.jsx)(a0,{surfaceTheme:t,label:"Memory",description:"Generate the persistent memory files for blueprint decisions.",checked:m.workspaceRuleGenerateMemory,onToggle:()=>C("workspaceRuleGenerateMemory",!m.workspaceRuleGenerateMemory),fieldRef:A("workspace.ruleGenerateMemory"),highlighted:"workspace.ruleGenerateMemory"===k}),(0,s.jsx)(a0,{surfaceTheme:t,label:"Kickoff mission",description:"Run the first mission immediately after bootstrap.",checked:m.workspaceRuleKickoffMission,onToggle:()=>C("workspaceRuleKickoffMission",!m.workspaceRuleKickoffMission),fieldRef:A("workspace.ruleKickoffMission"),highlighted:"workspace.ruleKickoffMission"===k})]}),(0,s.jsxs)("div",{className:"grid gap-4 xl:grid-cols-2",children:[(0,s.jsxs)(aQ,{surfaceTheme:t,sectionId:"team",highlighted:"team"===j,title:"Team",description:"Planner behavior and coordination rules.",register:e=>{w.current.team=e},children:[(0,s.jsx)(a0,{surfaceTheme:t,label:"Allow ephemeral subagents",description:"Let the planner spin up temporary helpers when useful.",checked:m.teamAllowEphemeralSubagents,onToggle:()=>C("teamAllowEphemeralSubagents",!m.teamAllowEphemeralSubagents),fieldRef:A("team.allowEphemeralSubagents"),highlighted:"team.allowEphemeralSubagents"===k}),(0,s.jsx)(a0,{surfaceTheme:t,label:"Autopilot",description:"Let the planner take a stronger lead when the shape is clear.",checked:m.intakeAutopilot,onToggle:()=>C("intakeAutopilot",!m.intakeAutopilot),fieldRef:A("team.autopilot"),highlighted:"team.autopilot"===k}),(0,s.jsx)(a0,{surfaceTheme:t,label:"Review requested",description:"Keep the planner in a review-heavy shaping mode.",checked:m.intakeReviewRequested,onToggle:()=>C("intakeReviewRequested",!m.intakeReviewRequested),fieldRef:A("team.reviewRequested"),highlighted:"team.reviewRequested"===k}),(0,s.jsx)(aZ,{label:"Max parallel runs",children:(0,s.jsx)(T,{ref:A("team.maxParallelRuns"),type:"number",min:1,value:m.teamMaxParallelRuns,onChange:e=>C("teamMaxParallelRuns",e.target.value)})}),(0,s.jsx)(aZ,{label:"Escalation rules",children:(0,s.jsx)(eY,{ref:A("team.escalationRules"),value:m.teamEscalationRules,onChange:e=>C("teamEscalationRules",e.target.value),placeholder:"One rule per line",className:"min-h-[84px]"})})]}),(0,s.jsxs)(aQ,{surfaceTheme:t,sectionId:"deploy",highlighted:"deploy"===j,title:"Deploy",description:"Review blockers, warnings, and first missions.",register:e=>{w.current.deploy=e},children:[(0,s.jsx)(aZ,{label:"Blockers",children:(0,s.jsx)(eY,{ref:A("deploy.blockers"),value:m.deployBlockers,onChange:e=>C("deployBlockers",e.target.value),placeholder:"One blocker per line",className:"min-h-[84px]"})}),(0,s.jsx)(aZ,{label:"Warnings",children:(0,s.jsx)(eY,{ref:A("deploy.warnings"),value:m.deployWarnings,onChange:e=>C("deployWarnings",e.target.value),placeholder:"One warning per line",className:"min-h-[84px]"})}),(0,s.jsx)(aZ,{label:"First missions",children:(0,s.jsx)(eY,{ref:A("deploy.firstMissions"),value:m.deployFirstMissions,onChange:e=>C("deployFirstMissions",e.target.value),placeholder:"One mission per line",className:"min-h-[84px]"})})]}),(0,s.jsxs)(aQ,{surfaceTheme:t,title:"Note",description:"What happens on save?",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[13px] leading-6",v?"text-[#6f675e]":"text-slate-300"),children:"Derived plan fields like readiness score, stage, and recommended missions are recalculated after you save."}),(0,s.jsx)("p",{className:(0,S.cn)("mt-3 text-[13px] leading-6",v?"text-[#6f675e]":"text-slate-300"),children:"If you want to edit something that is not shown here, switch to Raw JSON and change the exact nested field."})]})]})]})})}),(0,s.jsx)(E,{value:"raw",className:"min-h-0 flex-1",children:(0,s.jsxs)("div",{className:"flex h-full min-h-0 flex-col gap-3",children:[(0,s.jsx)("div",{className:(0,S.cn)("rounded-[18px] border px-4 py-3",v?"border-[#e5ddd2] bg-white":"border-white/10 bg-white/[0.04]"),children:(0,s.jsx)("p",{className:(0,S.cn)("text-[13px] leading-6",v?"text-[#6f675e]":"text-slate-300"),children:"This view edits the full blueprint JSON. It is the fastest way to change nested fields, agents, workflows, and any other detail."})}),(0,s.jsx)(eY,{value:h,onChange:e=>{x(e.target.value),f(null)},className:(0,S.cn)("min-h-0 flex-1 font-mono text-[12px] leading-5",v?"border-[#dcd4c9] bg-white text-[#1a1714]":"border-white/10 bg-[#03060d] text-slate-100")}),b?(0,s.jsx)("p",{className:"rounded-xl border border-rose-300/30 bg-rose-500/10 px-3 py-2 text-[13px] leading-5 text-rose-200",children:b}):null,(0,s.jsx)("p",{className:(0,S.cn)("text-[12px] leading-5",v?"text-[#7b7268]":"text-slate-400"),children:"Current draft JSON snapshot loaded on open. Changes are saved through the same planner draft path as the structured editor."})]})})]}),(0,s.jsxs)("div",{className:(0,S.cn)("flex items-center justify-between gap-3 border-t px-4 py-4 md:px-5",v?"border-[#e7dfd4]":"border-white/10"),children:[(0,s.jsx)(I,{type:"button",variant:"secondary",onClick:l,className:v?"rounded-full border-[#ddd6cb] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:"Cancel"}),(0,s.jsxs)(I,{type:"button",onClick:"raw"===c?D:M,disabled:!N||n,className:v?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",children:[n?(0,s.jsx)(i.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,s.jsx)(tt.A,{className:"mr-2 h-4 w-4"}),"Apply changes"]})]})]})]})}function aG(e,t){return JSON.stringify(e)!==JSON.stringify(t)}function aV(e){return e.join("\n")}function aJ(e){return e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean)}function aH(e){let t=e.trim();return t.length>0?t:void 0}function aY({surfaceTheme:e,label:t}){return(0,s.jsx)("span",{className:(0,S.cn)("inline-flex items-center rounded-full border px-2.5 py-1 text-[10px] uppercase tracking-[0.16em]","light"===e?"border-[#e4ddd3] bg-[#f7f2eb] text-[#746b61]":"border-white/10 bg-white/[0.05] text-slate-300"),children:t})}function aQ({surfaceTheme:e,sectionId:t,highlighted:a=!1,title:r,description:n,register:i,children:l}){let o="light"===e;return(0,s.jsxs)("section",{ref:i,"data-blueprint-section":t,className:(0,S.cn)("rounded-[22px] border p-4 transition-all duration-300",o?"border-[#e5ddd2] bg-white":"border-white/10 bg-white/[0.04]",a&&(o?"ring-2 ring-[#d8b184]/70 shadow-[0_0_0_1px_rgba(216,177,132,0.18),0_18px_36px_rgba(102,78,47,0.16)]":"ring-2 ring-cyan-300/45 shadow-[0_0_0_1px_rgba(103,232,249,0.14),0_18px_36px_rgba(6,182,212,0.16)]")),children:[(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[11px] uppercase tracking-[0.18em]",o?"text-[#a0978b]":"text-slate-500"),children:r}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1 text-[13px] leading-6",o?"text-[#6f675e]":"text-slate-300"),children:n})]}),(0,s.jsx)("div",{className:"space-y-4",children:l})]})}function aZ({label:e,children:t}){return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(e$,{children:e}),t]})}function aX({surfaceTheme:e,label:t,value:a,options:r,onChange:n,fieldRef:i,highlighted:l=!1}){let o="light"===e;return(0,s.jsxs)("div",{ref:i,tabIndex:-1,className:(0,S.cn)("space-y-2 rounded-[18px] border p-3 transition-all",o?"border-[#e8e0d6] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]",l&&(o?"ring-2 ring-[#d8b184]/60 shadow-[0_0_0_1px_rgba(216,177,132,0.12)]":"ring-2 ring-cyan-300/30 shadow-[0_0_0_1px_rgba(103,232,249,0.12)]")),children:[(0,s.jsx)(e$,{children:t}),(0,s.jsx)("div",{className:"grid gap-2 md:grid-cols-2",children:r.map(e=>{let t=e.value===a;return(0,s.jsx)("button",{type:"button",onClick:()=>n(e.value),className:(0,S.cn)("rounded-[16px] border px-3 py-3 text-left transition-colors",t?o?"border-[#161514] bg-[#161514] text-white":"border-cyan-300 bg-cyan-300/15 text-cyan-50":o?"border-[#e7dfd4] bg-[#faf6f1] text-[#171410] hover:border-[#d6cab9] hover:bg-[#f6efe6]":"border-white/10 bg-white/[0.03] text-slate-100 hover:border-white/15 hover:bg-white/[0.05]"),children:(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-[13px] font-medium",children:e.label}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1 text-[12px] leading-5",t?"opacity-80":o?"text-[#70685e]":"text-slate-400"),children:e.description})]}),t?(0,s.jsx)(j.A,{className:"mt-0.5 h-4 w-4 shrink-0"}):null]})},e.value)})})]})}function a0({surfaceTheme:e,label:t,description:a,checked:r,onToggle:n,fieldRef:i,highlighted:l=!1}){let o="light"===e;return(0,s.jsx)("button",{type:"button",onClick:n,ref:i,className:(0,S.cn)("w-full rounded-[16px] border px-3 py-3 text-left transition-colors",r?o?"border-[#1f1b17] bg-[#1f1b17] text-white":"border-cyan-300 bg-cyan-300/15 text-cyan-50":o?"border-[#e7dfd4] bg-[#faf6f1] text-[#171410] hover:border-[#d6cab9] hover:bg-[#f6efe6]":"border-white/10 bg-white/[0.03] text-slate-100 hover:border-white/15 hover:bg-white/[0.05]",l&&(o?"ring-2 ring-[#d8b184]/60 shadow-[0_0_0_1px_rgba(216,177,132,0.12)]":"ring-2 ring-cyan-300/30 shadow-[0_0_0_1px_rgba(103,232,249,0.12)]")),children:(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-[13px] font-medium",children:t}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1 text-[12px] leading-5",r?"opacity-80":o?"text-[#70685e]":"text-slate-400"),children:a})]}),(0,s.jsx)("span",{className:(0,S.cn)("mt-0.5 inline-flex size-5 shrink-0 items-center justify-center rounded-full border",r?o?"border-white/25 bg-white text-[#171410]":"border-white/20 bg-white text-slate-950":o?"border-[#cfc6ba] bg-transparent text-transparent":"border-white/15 bg-transparent text-transparent"),children:(0,s.jsx)(j.A,{className:"h-3 w-3"})})]})})}function a1({open:e,surfaceTheme:t,plan:a,path:r,busy:n=!1,rewriteBusy:l=!1,onClose:o,onSave:d,onRewriteWithArchitect:c}){let p="light"===t,m=(0,g.useMemo)(()=>e&&a?aR({name:a.workspace.name||"Workspace",brief:a.company.mission||a.product.offer||void 0,template:a.workspace.template,sourceMode:a.workspace.sourceMode,rules:a.workspace.rules,agents:a.team.persistentAgents.filter(e=>e.enabled),docOverrides:a.workspace.docOverrides,toolExamples:[],contextSources:a.intake.sources}).find(e=>e.path===r)??null:null,[e,r,a]),[u,h]=(0,g.useState)(()=>m?.content??""),[x,b]=(0,g.useState)(""),[f,w]=(0,g.useState)(null),y=n||l||!!f;if((0,g.useEffect)(()=>{if(!f)return;if(f.revealedCharCount>=f.changedToCharCount){let e=globalThis.setTimeout(()=>{h(f.nextContent),w(null)},120);return()=>{globalThis.clearTimeout(e)}}let e=globalThis.setTimeout(()=>{w(e=>e?{...e,revealedCharCount:Math.min(e.revealedCharCount+1,e.changedToCharCount)}:e)},Math.max(12,Math.min(24,Math.round(1800/Math.max(f.changedToCharCount,1)))));return()=>{globalThis.clearTimeout(e)}},[f]),!e||!a||!m)return null;let v=async()=>{let e=await c({path:m.path,currentContent:u,instruction:x.trim()||void 0});if(!e)return;let t=function(e,t){if(e===t)return null;let a=e.split(/\r?\n/),s=t.split(/\r?\n/),r=0;for(;r<a.length&&r<s.length&&a[r]===s[r];)r+=1;let n=0;for(;n<a.length-r&&n<s.length-r&&a[a.length-1-n]===s[s.length-1-n];)n+=1;let i=s.slice(0,r),l=a.slice(r,a.length-n),o=s.slice(r,s.length-n),d=s.slice(s.length-n),c=o.join("\n"),p=Array.from(c).length;return{prefixLines:i,changedFromLines:l,changedToLines:o,suffixLines:d,changedToText:c,changedToCharCount:p,revealedCharCount:0,nextContent:t}}(u,e);if(!t){h(e),b("");return}w(t),b("")},j=async()=>{let e=structuredClone(a),t=a$([...e.workspace.docOverrides.filter(e=>e.path!==m.path),...u===m.baseContent?[]:[{path:m.path,content:u}]]);e.workspace.docOverrides=t;let s=u===m.baseContent?m.generated?`Reset ${m.path} to the generated default scaffold.`:`Kept ${m.path} at the loaded workspace content.`:m.generated?`Updated ${m.path} scaffold content.`:`Updated ${m.path} existing file content.`;await d(e,s)&&o()};return(0,s.jsxs)("div",{className:"absolute inset-0 z-30",children:[(0,s.jsx)("button",{type:"button","aria-label":"Close document editor",onClick:o,className:(0,S.cn)("absolute inset-0 h-full w-full cursor-default",p?"bg-[rgba(17,14,10,0.26)]":"bg-[rgba(2,6,13,0.56)]")}),(0,s.jsxs)("div",{className:(0,S.cn)("absolute inset-y-0 right-0 flex h-full w-full flex-col border-l shadow-[0_34px_120px_rgba(0,0,0,0.35)] lg:max-w-[860px]",p?"border-[#e6ded4] bg-[linear-gradient(180deg,rgba(255,253,249,0.98),rgba(247,241,233,0.98))] text-[#151311]":"border-white/10 bg-[linear-gradient(180deg,rgba(5,9,18,0.98),rgba(3,7,15,0.98))] text-white"),onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:(0,S.cn)("flex items-center justify-between gap-4 border-b px-4 py-3 md:px-5",p?"border-[#e7dfd4]":"border-white/10"),children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[11px] uppercase tracking-[0.18em]",p?"text-[#9a9085]":"text-slate-500"),children:"Document editor"}),(0,s.jsx)("span",{className:(0,S.cn)("text-[11px] uppercase tracking-[0.18em]",p?"text-[#c2b6a5]":"text-slate-600"),children:"/"}),(0,s.jsx)("p",{className:(0,S.cn)("truncate font-mono text-[12px]",p?"text-[#4a433b]":"text-slate-300"),children:m.path}),(0,s.jsx)("span",{className:(0,S.cn)("inline-flex shrink-0 items-center rounded-full border px-2 py-0.5 text-[10px] uppercase tracking-[0.16em]",m.generated?m.overridden?p?"border-emerald-200 bg-emerald-50 text-emerald-900":"border-emerald-300/30 bg-emerald-300/12 text-emerald-100":p?"border-[#e0d7cc] bg-white text-[#7a7168]":"border-white/10 bg-white/[0.05] text-slate-400":p?"border-cyan-200 bg-cyan-50 text-cyan-900":"border-cyan-300/25 bg-cyan-300/12 text-cyan-100"),children:m.generated?m.overridden?"Customized":"Generated":"Existing"})]}),(0,s.jsx)("button",{type:"button",onClick:o,className:(0,S.cn)("inline-flex size-9 shrink-0 items-center justify-center rounded-full border transition-colors",p?"border-[#e3dbd0] bg-white text-[#5d564d] hover:bg-[#f5efe6]":"border-white/10 bg-white/[0.05] text-slate-300 hover:bg-white/[0.08]"),children:(0,s.jsx)(H.A,{className:"h-4 w-4"})})]}),(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-3 px-4 py-3 md:px-5",children:[(0,s.jsx)(aC.F,{className:"min-h-0 flex-1",children:f?(0,s.jsx)(a2,{surfaceTheme:t,animation:f}):(0,s.jsx)(eY,{value:u,onChange:e=>h(e.target.value),className:(0,S.cn)("min-h-[60vh] font-mono text-[12px] leading-5",p?"border-[#dcd4c9] bg-white text-[#1a1714]":"border-white/10 bg-[#03060d] text-slate-100"),disabled:y})}),(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3 border-t pt-2",style:{borderColor:p?"#e7dfd4":"rgba(255,255,255,0.1)"},children:[(0,s.jsx)(I,{type:"button",variant:"secondary",onClick:()=>{h(m.baseContent)},disabled:y,className:p?"rounded-full border-[#ddd6cb] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:m.generated?"Reset to default":"Reset to loaded content"}),(0,s.jsxs)(I,{type:"button",onClick:j,disabled:y,className:p?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",children:[n?(0,s.jsx)(i.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,s.jsx)(tt.A,{className:"mr-2 h-4 w-4"}),"Apply changes"]})]}),(0,s.jsx)("div",{className:(0,S.cn)("rounded-[18px] border px-4 py-3",p?"border-[#e5ded3] bg-white":"border-white/10 bg-white/[0.04]"),children:(0,s.jsxs)("div",{className:"grid gap-3 md:grid-cols-[minmax(0,1fr),auto] md:items-end",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("label",{htmlFor:"architect-rewrite-prompt",className:(0,S.cn)("text-[11px] uppercase tracking-[0.18em]",p?"text-[#8b8278]":"text-slate-400"),children:"Architect instructions"}),(0,s.jsx)(eY,{id:"architect-rewrite-prompt",value:x,onChange:e=>b(e.target.value),placeholder:"Tell Architect what to rewrite in this document.",className:(0,S.cn)("mt-2 min-h-[88px] font-sans text-[13px] leading-6",p?"border-[#dcd4c9] bg-white text-[#1a1714]":"border-white/10 bg-[#03060d] text-slate-100"),disabled:y}),(0,s.jsx)("p",{className:(0,S.cn)("mt-2 text-[12px] leading-5",p?"text-[#7b7268]":"text-slate-400"),children:"Leave it blank for a general pass. Architect will rewrite only the changed block and keep the rest intact."})]}),(0,s.jsxs)(I,{type:"button",variant:"secondary",onClick:v,disabled:y,className:p?"rounded-full border-[#d8d0c4] bg-[#f8f3eb] text-[#3f3831] hover:bg-[#f1ebe4]":"rounded-full border-cyan-300/20 bg-cyan-300/10 text-cyan-100 hover:bg-cyan-300/16",children:[l?(0,s.jsx)(i.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,s.jsx)(eI.A,{className:"mr-2 h-4 w-4"}),"Rewrite with Architect"]})]})})]})]})]})}function a2({surfaceTheme:e,animation:t}){var a,r;let n="light"===e,i=(0,S.cn)("whitespace-pre-wrap break-words rounded-lg border px-3 py-2",n?"border-[#e4ddd2] bg-white text-[#1a1714]":"border-white/10 bg-[#040810] text-slate-100"),l=(a=t.changedToText,(r=t.revealedCharCount)<=0?"":Array.from(a).slice(0,r).join(""));return(0,s.jsxs)("div",{className:(0,S.cn)("rounded-[18px] border px-4 py-3",n?"border-[#e5ded3] bg-white":"border-white/10 bg-white/[0.04]"),children:[(0,s.jsxs)("div",{className:(0,S.cn)("flex items-center justify-between gap-2 whitespace-nowrap text-[9px] uppercase tracking-[0.18em] leading-none",n?"text-[#8b8278]":"text-slate-400"),children:[(0,s.jsx)("span",{className:"min-w-0 truncate",children:"Rewriting"}),(0,s.jsxs)("span",{className:(0,S.cn)("shrink-0 rounded-full border px-2 py-0.5",n?"border-[#dfd7cc] bg-[#faf6f1] text-[#6e6458]":"border-white/10 bg-white/[0.04] text-slate-300"),children:[t.revealedCharCount,"/",t.changedToCharCount||1]})]}),(0,s.jsxs)("div",{className:"mt-2 space-y-2 font-mono text-[12px] leading-5",children:[t.prefixLines.length?(0,s.jsx)("div",{className:(0,S.cn)("space-y-1.5",n?"text-[#27231e]":"text-slate-100"),children:t.prefixLines.map((e,t)=>(0,s.jsx)("div",{className:"whitespace-pre-wrap break-words",children:e||"\xa0"},`prefix-${t}`))}):null,(0,s.jsx)("div",{className:(0,S.cn)("rounded-2xl border px-3 py-2.5",n?"border-[#d8cdbc] bg-[#f9f5ef]":"border-cyan-300/20 bg-cyan-300/6"),children:(0,s.jsxs)("div",{className:"grid gap-2 md:grid-cols-2",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:(0,S.cn)("mb-1 text-[9px] uppercase tracking-[0.18em]",n?"text-[#968a7c]":"text-slate-400"),children:"Old"}),(0,s.jsx)("div",{className:i,children:t.changedFromLines.length?t.changedFromLines.map((e,t)=>(0,s.jsx)("div",{className:"whitespace-pre-wrap break-words opacity-55 line-through",children:e||"\xa0"},`before-${t}`)):(0,s.jsx)("div",{className:"opacity-45",children:"[empty]"})})]}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:(0,S.cn)("mb-1 text-[9px] uppercase tracking-[0.18em]",n?"text-[#968a7c]":"text-slate-400"),children:"New"}),(0,s.jsx)("div",{className:(0,S.cn)(i,"min-h-[96px]"),children:t.changedToCharCount>0?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"whitespace-pre-wrap break-words",children:l}),t.revealedCharCount<t.changedToCharCount?(0,s.jsx)(x.P.span,{"aria-hidden":"true",className:(0,S.cn)("ml-0.5 inline-block align-[-0.15em] text-[1.1em] leading-none",n?"text-[#161514]":"text-cyan-100"),animate:{opacity:[0,1,0]},transition:{duration:.8,repeat:1/0,ease:"easeInOut"},children:"|"}):null]}):(0,s.jsx)("span",{className:(0,S.cn)("opacity-45",n?"text-[#7d7266]":"text-slate-400"),children:"[removed]"})})]})]})}),t.suffixLines.length?(0,s.jsx)("div",{className:(0,S.cn)("space-y-1.5",n?"text-[#27231e]":"text-slate-100"),children:t.suffixLines.map((e,t)=>(0,s.jsx)("div",{className:"whitespace-pre-wrap break-words",children:e||"\xa0"},`suffix-${t}`))}):null]})]})}var a5=a(3479),a3=a(4779),a4=a(9350),a8=a(5800),a6=a(6968),a9=a(9266),a7=a(7876),se=a(9469),st=a(3960),sa=a(1333),ss=a(7828),sr=a(421);let sn=[{id:"company",label:"Company",icon:ss.A},{id:"product",label:"Product",icon:sr.A},{id:"workspace",label:"Workspace",icon:st.A},{id:"team",label:"Team",icon:t7.A},{id:"operations",label:"Operations",icon:at.A},{id:"deploy",label:"Deploy",icon:a3.A}],si=[{id:"intake",label:"Intake",section:"company"},{id:"context-harvest",label:"Context",section:"workspace"},{id:"team-synthesis",label:"Team",section:"team"},{id:"pressure-test",label:"Review",section:"operations"},{id:"decision-lock",label:"Lock",section:"deploy"},{id:"ready",label:"Ready",section:"deploy"},{id:"deploying",label:"Deploying",section:"deploy"},{id:"deployed",label:"Live",section:"deploy"}];function sl(e){return si.find(t=>t.id===e)?.section??"company"}function so(e){return si.find(t=>t.id===e)?.label??"Draft"}function sd(e,t){switch(t){case"company":{let t=[e.company.name,e.company.mission,e.company.targetCustomer].filter(e=>!e.trim()).length;return 0===t?{label:"Ready to review",variant:"success"}:{label:`${t} core field${1===t?"":"s"} missing`,variant:"warning"}}case"product":{let t=[+!e.product.offer.trim(),e.product.scopeV1.length>0?0:1,e.product.launchPriority.length>0?0:1].reduce((e,t)=>e+t,0);return 0===t?{label:"Scope is defined",variant:"success"}:{label:`${t} product decision${1===t?"":"s"} pending`,variant:"warning"}}case"workspace":{let t=+!e.workspace.name.trim();return"clone"!==e.workspace.sourceMode||e.workspace.repoUrl?.trim()||(t+=1),"existing"!==e.workspace.sourceMode||e.workspace.existingPath?.trim()||(t+=1),0===t?{label:"Provisioning path set",variant:"success"}:{label:`${t} workspace input${1===t?"":"s"} missing`,variant:"warning"}}case"team":{let t=e.team.persistentAgents.filter(e=>e.enabled).length,a=e.team.persistentAgents.some(e=>e.enabled&&e.isPrimary);if(0===t)return{label:"Add at least one agent",variant:"danger"};if(!a)return{label:"Primary agent missing",variant:"warning"};return{label:`${t} active agent${1===t?"":"s"}`,variant:"success"}}case"operations":{let t=e.operations.workflows.filter(e=>e.enabled).length,a=e.operations.automations.filter(e=>e.enabled).length;if(0===t&&0===a)return{label:"No runtime loops yet",variant:"warning"};return{label:`${t} workflows, ${a} automations`,variant:"success"}}default:if(!e.intake.reviewRequested&&"deploying"!==e.status&&"deployed"!==e.status)return{label:"Review not opened yet",variant:"muted"};if(e.deploy.blockers.length>0)return{label:`${e.deploy.blockers.length} blocker${1===e.deploy.blockers.length?"":"s"}`,variant:"danger"};if(e.deploy.warnings.length>0)return{label:`${e.deploy.warnings.length} warning${1===e.deploy.warnings.length?"":"s"}`,variant:"warning"};return{label:"Ready to deploy",variant:"success"}}}function sc(e,t){switch(t){case"company":return e.company.name?`${e.company.name}${e.company.mission?` \xb7 ${e.company.mission}`:""}`:"Mission and audience are still being shaped.";case"product":return e.product.offer||"Offer and V1 scope are still being drafted.";case"workspace":return`${sp(e.workspace.template)} \xb7 ${sp(e.workspace.sourceMode)}`;case"team":return`${e.team.persistentAgents.filter(e=>e.enabled).length} agents drafted`;case"operations":return`${e.operations.workflows.filter(e=>e.enabled).length} workflows \xb7 ${e.operations.automations.filter(e=>e.enabled).length} automations`;default:return e.intake.reviewRequested?"Deploy review is open.":"Review not started."}}function sp(e){return e.split(/[-_]/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}let sm=Object.fromEntries(aU.map(e=>[e.value,e.label])),su={prompt:{label:"Prompt",icon:eI.A},website:{label:"Website",icon:a6.A},repo:{label:"Repo",icon:a8.A},folder:{label:"Folder",icon:a9.A}};function sh({surfaceTheme:e,plan:t,variant:a="panel",summaryText:r,className:n,onOpenBlueprintEditor:i,onOpenDocumentEditor:l}){var o;let d,c="light"===e,p=(0,g.useMemo)(()=>aM(t.workspace.template,t.workspace.rules),[t.workspace.rules,t.workspace.template]),m=(0,g.useMemo)(()=>new Set(a$(t.workspace.docOverrides).map(e=>e.path)),[t.workspace.docOverrides]),u=t.company.name||t.workspace.name||"Workspace",h=t.company.mission||t.product.offer||"Mission still being shaped.",x=t.company.targetCustomer||"Audience still being confirmed.",b=sp(t.workspace.sourceMode),f=sm[t.workspace.template],w=sp(t.company.type),y=so(t.stage),v="blocked"===t.status?"Blocked":"ready"===t.status?"Ready":"deployed"===t.status?"Live":"deploying"===t.status?"Deploying":"Draft",j=r?.trim()||t.architectSummary,k=t.intake.sources.find(e=>"ready"===e.status)??t.intake.sources[0]??null,N=t.intake.inferences.slice(0,4),C=p.resources.length,A=((d=(o=u).trim().split(/\s+/).filter(Boolean)).length>1?`${d[0][0]??""}${d[1][0]??""}`:o.slice(0,2)).toUpperCase(),T=k?su[k.kind].icon:"clone"===t.workspace.sourceMode?a8.A:"existing"===t.workspace.sourceMode?a9.A:eI.A,M=k?k.label:b,O=k?`${su[k.kind].label} \xb7 ${sC(k.status)}`:b,R=function(e){switch(e){case"blocked":return"danger";case"ready":case"deployed":return"success";case"review":return"warning";default:return"muted"}}(t.status),$="panel"===a,[E,D]=(0,g.useState)(0),_=$?3:5,P=$?["Collecting context from the prompt and sources…","Shaping the draft with the first signal set…","Writing the scaffold files now…","Draft ready."]:["Collecting context from the prompt and sources…","Pulling evidence from the website and files…","Extracting structured facts…","Grouping the file scaffold…","Checking remaining decisions…","Draft ready."],L=P[Math.min(E,P.length-1)]??P[0],U=E>=1,F=E>=1,z=E>=2,W=E>=($?3:5),B=!$&&E>=3,q=!$&&E>=4,K=!$&&E>=5,G=$?p.sections.filter(e=>e.enabled):p.sections,V=G.reduce((e,t)=>e+t.resources.length,0),J=$?V:C;return((0,g.useEffect)(()=>{let e="function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,t=globalThis.setTimeout(()=>{D(e?_:0)},0);if(e)return()=>{globalThis.clearTimeout(t)};let a=$?[200,1400,3200]:[200,1400,2600,4300,6200],s=($?[1,2,3]:[1,2,3,4,5]).map((e,t)=>globalThis.setTimeout(()=>D(e),a[t]??a[a.length-1]??0));return()=>{globalThis.clearTimeout(t),s.forEach(e=>globalThis.clearTimeout(e))}},[$,_]),$)?(0,s.jsxs)("div",{className:(0,S.cn)("workspace-architect-card-enter relative overflow-hidden rounded-[28px] border p-4 md:p-5",c?"border-[#e5ddd2] bg-white shadow-[0_16px_42px_rgba(56,47,38,0.06)]":"border-white/10 bg-[rgba(6,10,18,0.96)] shadow-[0_16px_42px_rgba(0,0,0,0.2)]",n),children:[(0,s.jsx)("div",{className:(0,S.cn)("pointer-events-none absolute inset-0",c?"bg-[radial-gradient(circle_at_top_right,rgba(216,177,132,0.14),transparent_36%),radial-gradient(circle_at_bottom_left,rgba(94,193,255,0.06),transparent_42%)]":"bg-[radial-gradient(circle_at_top_right,rgba(103,232,249,0.12),transparent_34%),radial-gradient(circle_at_bottom_left,rgba(59,130,246,0.12),transparent_42%)]")}),(0,s.jsxs)("div",{className:"relative space-y-4",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-start gap-3",children:[(0,s.jsx)("div",{className:(0,S.cn)("inline-flex size-11 shrink-0 items-center justify-center rounded-2xl border text-[12px] font-semibold tracking-[0.12em]",c?"border-[#e4ddd2] bg-[#fcfaf7] text-[#4f4942]":"border-white/10 bg-white/[0.05] text-slate-100"),children:A}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[10px] uppercase tracking-[0.24em]",c?"text-[#8d8174]":"text-slate-500"),children:"Architect"}),(0,s.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[(0,s.jsx)(sg,{surfaceTheme:e,text:u,className:(0,S.cn)("text-[18px] font-semibold tracking-[-0.04em]",c?"text-[#171410]":"text-white"),startDelayMs:0,wordDelayMs:95},`hero-title:${$?"panel":"message"}:${u}`),(0,s.jsx)(sk,{surfaceTheme:e,tone:R,label:v})]}),(0,s.jsx)(sg,{surfaceTheme:e,text:U?j:L,className:(0,S.cn)("workspace-architect-card-enter mt-1 line-clamp-2 text-[12px] leading-5",c?"text-[#6f685f]":"text-slate-300",!U&&"italic"),startDelayMs:80,wordDelayMs:115},`hero-status:${$?"panel":"message"}:${U?j:L}`)]})]}),(0,s.jsxs)("div",{className:"shrink-0 text-right",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[10px] uppercase tracking-[0.2em]",c?"text-[#918577]":"text-slate-500"),children:"Readiness"}),(0,s.jsxs)("p",{className:(0,S.cn)("mt-1 text-[24px] font-semibold tracking-[-0.05em]",c?"text-[#181612]":"text-white"),children:[t.readinessScore,"%"]}),i?(0,s.jsxs)(I,{type:"button",variant:"secondary",size:"sm",onClick:()=>i("workspace.name"),className:c?"mt-2 rounded-full border-[#ddd6cb] bg-[#f7f2eb] px-3 text-[#403934] hover:bg-[#f1ebe3]":"mt-2 rounded-full border-white/10 bg-white/[0.04] px-3 text-slate-200 hover:bg-white/[0.08]",children:[(0,s.jsx)(tt.A,{className:"mr-2 h-3.5 w-3.5"}),"Edit"]}):null]})]}),F?(0,s.jsxs)("div",{className:"workspace-architect-card-enter grid gap-2.5 sm:grid-cols-3",style:sS(90),children:[(0,s.jsx)(sx,{surfaceTheme:e,label:"Mission",value:h,icon:eI.A,revealDelayMs:120}),(0,s.jsx)(sx,{surfaceTheme:e,label:"Audience",value:x,icon:se.A,revealDelayMs:220}),(0,s.jsx)(sx,{surfaceTheme:e,label:"Source",value:M,detail:O,icon:T,revealDelayMs:320})]}):null,z?(0,s.jsxs)("div",{className:"workspace-architect-card-enter flex flex-wrap gap-1.5",style:sS(170),children:[(0,s.jsx)(sb,{surfaceTheme:e,label:"Mission",value:sj(h,48),icon:eI.A,revealDelayMs:0}),(0,s.jsx)(sb,{surfaceTheme:e,label:"Source",value:sj(M,34),icon:T,revealDelayMs:110}),(0,s.jsx)(sb,{surfaceTheme:e,label:"Template",value:f,icon:st.A,revealDelayMs:220}),(0,s.jsx)(sb,{surfaceTheme:e,label:"Files",value:String(C),icon:a5.A,revealDelayMs:330})]}):null,W?(0,s.jsxs)("div",{className:"space-y-2.5",children:[(0,s.jsx)("div",{className:"flex items-center justify-between gap-2",children:(0,s.jsx)(sf,{surfaceTheme:e,title:"Files",subtitle:`${G.length} groups in the canonical scaffold.`})}),(0,s.jsx)("div",{className:"space-y-2",children:G.map((t,a)=>(0,s.jsxs)("div",{className:(0,S.cn)("workspace-architect-card-enter rounded-[18px] border px-3 py-3",c?"border-[#e4ddd3] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]"),style:sS(72*a),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(sg,{surfaceTheme:e,text:t.title,className:(0,S.cn)("text-[13px] font-semibold",c?"text-[#171410]":"text-white"),startDelayMs:120*a,wordDelayMs:70},`files-section-title:${t.id}:${a}:${t.title}`),(0,s.jsx)(sk,{surfaceTheme:e,tone:t.enabled?"success":"muted",label:t.enabled?"Included":"Skipped"})]}),$?null:(0,s.jsx)("p",{className:(0,S.cn)("mt-1 text-[11px] leading-5",c?"text-[#7a7168]":"text-slate-400"),children:t.description})]}),(0,s.jsxs)("span",{className:(0,S.cn)("text-[11px] uppercase tracking-[0.16em]",c?"text-[#95897c]":"text-slate-500"),children:[t.resources.length," file",1===t.resources.length?"":"s"]})]}),t.resources.length>0?(0,s.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:t.resources.map((r,n)=>(0,s.jsx)(sv,{surfaceTheme:e,label:r.label,tone:m.has(r.relativePath)?"success":"core"===t.id?"default":"accent",animated:!0,delayMs:(6*a+n)*88,interactive:!!l,onClick:l?()=>l(r.relativePath):void 0},r.relativePath))}):(0,s.jsx)("p",{className:(0,S.cn)("mt-2 text-[11px] leading-5",c?"text-[#7a7168]":"text-slate-400"),children:"Disabled by the current workspace rules."})]},t.id))})]}):null]})]}):(0,s.jsxs)("div",{className:(0,S.cn)("workspace-architect-card-enter relative overflow-hidden border",$?"rounded-[28px] p-4 md:p-5":"rounded-[26px] p-3.5 md:p-4",c?"border-[#e5ddd2] bg-white shadow-[0_22px_60px_rgba(56,47,38,0.07)]":"border-white/10 bg-[rgba(6,10,18,0.96)] shadow-[0_22px_60px_rgba(0,0,0,0.22)]",n),children:[(0,s.jsx)("div",{className:(0,S.cn)("pointer-events-none absolute inset-0",c?"bg-[radial-gradient(circle_at_top_right,rgba(216,177,132,0.16),transparent_36%),radial-gradient(circle_at_bottom_left,rgba(94,193,255,0.08),transparent_42%)]":"bg-[radial-gradient(circle_at_top_right,rgba(103,232,249,0.18),transparent_34%),radial-gradient(circle_at_bottom_left,rgba(59,130,246,0.16),transparent_42%)]")}),(0,s.jsxs)("div",{className:"relative space-y-4",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-start gap-3",children:[(0,s.jsx)("div",{className:(0,S.cn)("inline-flex size-12 shrink-0 items-center justify-center rounded-2xl border text-[12px] font-semibold tracking-[0.12em]",c?"border-[#e4ddd2] bg-[#fcfaf7] text-[#4f4942]":"border-white/10 bg-white/[0.05] text-slate-100"),children:A}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[10px] uppercase tracking-[0.24em]",c?"text-[#8d8174]":"text-slate-500"),children:"Architect"}),(0,s.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[20px] font-semibold tracking-[-0.04em]",c?"text-[#171410]":"text-white"),children:u}),(0,s.jsx)(sk,{surfaceTheme:e,tone:R,label:v})]}),(0,s.jsx)(sg,{surfaceTheme:e,text:U?j:L,className:(0,S.cn)("workspace-architect-card-enter mt-1 line-clamp-3 text-[13px] leading-6",c?"text-[#6f685f]":"text-slate-300",!U&&"italic"),startDelayMs:80,wordDelayMs:120},`hero-status:${$?"panel":"message"}:${U?j:L}`)]})]}),(0,s.jsxs)("div",{className:"shrink-0 text-right",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[10px] uppercase tracking-[0.2em]",c?"text-[#918577]":"text-slate-500"),children:"Readiness"}),(0,s.jsxs)("p",{className:(0,S.cn)("mt-1 text-[28px] font-semibold tracking-[-0.05em]",c?"text-[#181612]":"text-white"),children:[t.readinessScore,"%"]}),$&&i?(0,s.jsxs)(I,{type:"button",variant:"secondary",size:"sm",onClick:()=>i("workspace.name"),className:c?"mt-2 rounded-full border-[#ddd6cb] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"mt-2 rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:[(0,s.jsx)(tt.A,{className:"mr-2 h-3.5 w-3.5"}),"Edit details"]}):null]})]}),F?(0,s.jsxs)("div",{className:"workspace-architect-card-enter grid gap-2.5 sm:grid-cols-3",style:sS(90),children:[(0,s.jsx)(sx,{surfaceTheme:e,label:"Mission",value:h,icon:eI.A,revealDelayMs:120}),(0,s.jsx)(sx,{surfaceTheme:e,label:"Audience",value:x,icon:se.A,revealDelayMs:220}),(0,s.jsx)(sx,{surfaceTheme:e,label:"Source",value:M,detail:O,icon:T,revealDelayMs:320})]}):null,z?(0,s.jsx)("div",{className:"workspace-architect-card-enter flex flex-wrap gap-1.5",style:sS(170),children:$?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(sb,{surfaceTheme:e,label:"Template",value:f,icon:st.A,revealDelayMs:0}),(0,s.jsx)(sb,{surfaceTheme:e,label:"Stage",value:y,icon:sa.A,revealDelayMs:110}),(0,s.jsx)(sb,{surfaceTheme:e,label:"Files",value:String(J),icon:a5.A,revealDelayMs:220})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(sb,{surfaceTheme:e,label:"Template",value:f,icon:st.A,revealDelayMs:0}),(0,s.jsx)(sb,{surfaceTheme:e,label:"Company",value:w,icon:ss.A,revealDelayMs:110}),(0,s.jsx)(sb,{surfaceTheme:e,label:"Stage",value:y,icon:sa.A,revealDelayMs:220}),(0,s.jsx)(sb,{surfaceTheme:e,label:"Sources",value:String(t.intake.sources.length),icon:a6.A,revealDelayMs:330}),(0,s.jsx)(sb,{surfaceTheme:e,label:"Files",value:String(C),icon:a5.A,revealDelayMs:440})]})}):null,B?(0,s.jsxs)("section",{className:"space-y-3",children:[(0,s.jsx)(sf,{surfaceTheme:e,title:"Evidence",subtitle:"What the architect pulled from the prompt, website, repo, or existing folder.",revealDelayMs:0}),t.intake.sources.length>0?(0,s.jsx)("div",{className:"grid gap-2 md:grid-cols-2",children:t.intake.sources.map((t,a)=>(0,s.jsx)(sw,{surfaceTheme:e,source:t,delayMs:120*a},t.id))}):(0,s.jsx)(sN,{surfaceTheme:e,title:"No sources yet",description:"Add a website, repo, folder, or short brief and the architect will start grounding the draft."})]}):null,q?(0,s.jsxs)("section",{className:"space-y-3",children:[(0,s.jsx)(sf,{surfaceTheme:e,title:"Inferred facts",subtitle:"Structured fields the architect is using to shape the workspace.",revealDelayMs:0}),N.length>0?(0,s.jsx)("div",{className:"grid gap-2 md:grid-cols-2",children:N.map((t,a)=>(0,s.jsx)(sy,{surfaceTheme:e,inference:t,delayMs:120*a},t.id))}):(0,s.jsx)(sN,{surfaceTheme:e,title:"No inferences yet",description:"Architect will populate structured facts once it has enough source signal."})]}):null,W?(0,s.jsxs)("section",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,s.jsx)(sf,{surfaceTheme:e,title:"Files to create",subtitle:$?"Canonical scaffold derived from the current workspace rules.":"The same file set the workspace will scaffold on the next pass.",revealDelayMs:0}),(0,s.jsx)(sk,{surfaceTheme:e,tone:"muted",label:`${J} file${1===J?"":"s"}`})]}),(0,s.jsx)("div",{className:"space-y-2.5",children:G.map((t,a)=>(0,s.jsxs)("div",{className:(0,S.cn)("workspace-architect-card-enter rounded-[18px] border px-3 py-3",c?"border-[#e4ddd3] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]"),style:sS(72*a),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsx)("div",{className:"min-w-0",children:(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[13px] font-semibold",c?"text-[#171410]":"text-white"),children:t.title}),(0,s.jsx)(sk,{surfaceTheme:e,tone:t.enabled?"success":"muted",label:t.enabled?"Included":"Skipped"})]})}),(0,s.jsxs)("span",{className:(0,S.cn)("text-[11px] uppercase tracking-[0.16em]",c?"text-[#95897c]":"text-slate-500"),children:[t.resources.length," file",1===t.resources.length?"":"s"]})]}),t.resources.length>0?(0,s.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:t.resources.map((r,n)=>(0,s.jsx)(sv,{surfaceTheme:e,label:r.label,tone:m.has(r.relativePath)?"success":"core"===t.id?"default":"accent",animated:!0,delayMs:(6*a+n)*52,interactive:!!l,onClick:l?()=>l(r.relativePath):void 0},r.relativePath))}):(0,s.jsx)("p",{className:(0,S.cn)("mt-2 text-[11px] leading-5",c?"text-[#7a7168]":"text-slate-400"),children:"Disabled by the current workspace rules."})]},t.id))})]}):null,K&&t.intake.confirmations.length>0?(0,s.jsxs)("section",{className:"space-y-3",children:[(0,s.jsx)(sf,{surfaceTheme:e,title:"Open decisions",subtitle:"These are the remaining items the architect still wants to confirm."}),(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5",children:t.intake.confirmations.map((e,t)=>(0,s.jsxs)("span",{className:(0,S.cn)("workspace-architect-chip-enter inline-flex items-center rounded-full border px-2.5 py-1 text-[10px] leading-4",c?"border-[#ddd6cb] bg-white text-[#6a6157]":"border-white/10 bg-white/[0.05] text-slate-300"),style:sS(48*t),children:[(0,s.jsx)(sa.A,{className:"mr-1 h-3 w-3 shrink-0"}),(0,s.jsx)("span",{className:"max-w-[28rem] truncate",children:e})]},`decision:${t}:${e}`))})]}):null]})]})}function sx({surfaceTheme:e,label:t,value:a,detail:r,icon:n,revealDelayMs:i=0}){let l="light"===e;return(0,s.jsx)("div",{className:(0,S.cn)("rounded-[18px] border px-3 py-3",l?"border-[#e4ddd3] bg-white":"border-white/10 bg-white/[0.03]"),children:(0,s.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,s.jsx)("span",{className:(0,S.cn)("inline-flex size-8 shrink-0 items-center justify-center rounded-full border",l?"border-[#e4ddd2] bg-[#faf6f1] text-[#5f5952]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,s.jsx)(n,{className:"h-3.5 w-3.5"})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)(sg,{surfaceTheme:e,text:t,className:(0,S.cn)("text-[10px] uppercase tracking-[0.18em]",l?"text-[#8f8274]":"text-slate-500"),startDelayMs:i,wordDelayMs:55},`detail-label:${t}:${i}`),(0,s.jsx)(sg,{surfaceTheme:e,text:a,className:(0,S.cn)("mt-1 text-[13px] font-medium leading-5",l?"text-[#171410]":"text-white"),startDelayMs:i+80,wordDelayMs:110},`detail-value:${t}:${i}`),r?(0,s.jsx)(sg,{surfaceTheme:e,text:r,className:(0,S.cn)("mt-1 text-[11px] leading-5",l?"text-[#7a7168]":"text-slate-400"),startDelayMs:i+200,wordDelayMs:95},`detail-extra:${t}:${i}`):null]})]})})}function sg({surfaceTheme:e,text:t,className:a,startDelayMs:r=0,wordDelayMs:n=110}){let i=(0,g.useMemo)(()=>t.trim().split(/\s+/).filter(Boolean),[t]),[l,o]=(0,g.useState)(0);return(0,g.useEffect)(()=>{let e="function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;if(0===i.length)return;let t=e?[globalThis.setTimeout(()=>{o(i.length)},0)]:i.map((e,t)=>globalThis.setTimeout(()=>{o(t+1)},r+t*n));return()=>{t.forEach(e=>globalThis.clearTimeout(e))}},[r,n,i]),(0,s.jsxs)("p",{className:a,children:[i.slice(0,l).map((e,t)=>(0,s.jsxs)("span",{children:[t>0?" ":"",e]},`${t}:${e}`)),l<i.length?(0,s.jsx)("span",{"aria-hidden":"true",className:(0,S.cn)("ml-0.5 inline-block animate-pulse","light"===e?"text-[#6f685f]":"text-slate-300"),children:"▍"}):null]})}function sb({surfaceTheme:e,label:t,value:a,icon:r,revealDelayMs:n=0}){let i="light"===e;return(0,s.jsxs)("div",{className:(0,S.cn)("inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-[11px]",i?"border-[#e4ddd2] bg-white text-[#5f5851]":"border-white/10 bg-white/[0.04] text-slate-300"),children:[(0,s.jsx)(r,{className:"h-3.5 w-3.5 shrink-0"}),(0,s.jsx)(sg,{surfaceTheme:e,text:t,className:"uppercase tracking-[0.16em]",startDelayMs:n,wordDelayMs:55},`stat-label:${t}:${n}`),(0,s.jsx)(sg,{surfaceTheme:e,text:a,className:"font-medium normal-case tracking-normal",startDelayMs:n+80,wordDelayMs:80},`stat-value:${t}:${n}`)]})}function sf({surfaceTheme:e,title:t,subtitle:a,revealDelayMs:r=0}){let n="light"===e;return(0,s.jsxs)("div",{children:[(0,s.jsx)(sg,{surfaceTheme:e,text:t,className:(0,S.cn)("text-[11px] uppercase tracking-[0.18em]",n?"text-[#8f8274]":"text-slate-500"),startDelayMs:r,wordDelayMs:60},`heading-title:${t}:${r}`),(0,s.jsx)(sg,{surfaceTheme:e,text:a,className:(0,S.cn)("mt-1 text-[12px] leading-5",n?"text-[#70665c]":"text-slate-400"),startDelayMs:r+100,wordDelayMs:90},`heading-subtitle:${t}:${r}`)]})}function sw({surfaceTheme:e,source:t,delayMs:a=0}){var r;let n="light"===e,i=su[t.kind].icon;return(0,s.jsx)("div",{className:(0,S.cn)("workspace-architect-chip-enter rounded-[18px] border px-3 py-3",n?"border-[#e4ddd3] bg-white":"border-white/10 bg-white/[0.03]"),style:sS(a),children:(0,s.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,s.jsx)("span",{className:(0,S.cn)("inline-flex size-8 shrink-0 items-center justify-center rounded-full border",n?"border-[#e4ddd2] bg-[#faf6f1] text-[#5f5952]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,s.jsx)(i,{className:"h-3.5 w-3.5"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)(sg,{surfaceTheme:e,text:t.label,className:(0,S.cn)("text-[12px] font-semibold",n?"text-[#171410]":"text-white"),startDelayMs:a,wordDelayMs:70},`source-label:${t.id}:${a}`),(0,s.jsx)(sg,{surfaceTheme:e,text:t.summary,className:(0,S.cn)("mt-1 text-[11px] leading-5",n?"text-[#7a7168]":"text-slate-400"),startDelayMs:a+90,wordDelayMs:95},`source-summary:${t.id}:${a}`)]}),(0,s.jsxs)("div",{className:"flex shrink-0 flex-col items-end gap-1",children:[(0,s.jsx)(sk,{surfaceTheme:e,tone:"ready"===t.status?"success":"danger",label:sC(t.status)}),"number"==typeof t.confidence?(0,s.jsx)("span",{className:(0,S.cn)("text-[10px] uppercase tracking-[0.16em]",n?"text-[#8f8274]":"text-slate-500"),children:(r=t.confidence,`${Math.round(100*r)}%`)}):null]})]}),t.details.length>0?(0,s.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:t.details.slice(0,2).map((e,a)=>(0,s.jsx)("span",{className:(0,S.cn)("inline-flex items-center rounded-full border px-2 py-0.5 text-[10px] leading-4",n?"border-[#e4ddd2] bg-[#faf6f1] text-[#6d645b]":"border-white/10 bg-white/[0.04] text-slate-300"),children:e},`source-detail:${t.id}:${a}:${e}`))}):null]})]})})}function sy({surfaceTheme:e,inference:t,delayMs:a}){let r="light"===e;return(0,s.jsxs)("div",{className:(0,S.cn)("workspace-architect-chip-enter rounded-[18px] border px-3 py-3",r?"border-[#e4ddd3] bg-white":"border-white/10 bg-white/[0.03]"),style:sS(a),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)(sg,{surfaceTheme:e,text:sp(t.section),className:(0,S.cn)("text-[10px] uppercase tracking-[0.18em]",r?"text-[#8f8274]":"text-slate-500"),startDelayMs:a,wordDelayMs:55},`inference-section:${t.id}:${a}`),(0,s.jsx)(sg,{surfaceTheme:e,text:t.label,className:(0,S.cn)("mt-1 text-[12px] font-semibold leading-5",r?"text-[#171410]":"text-white"),startDelayMs:a+80,wordDelayMs:75},`inference-label:${t.id}:${a}`)]}),(0,s.jsx)(sk,{surfaceTheme:e,tone:function(e){switch(e){case"confirmed":return"success";case"needs-confirmation":return"warning";default:return"muted"}}(t.status),label:"confirmed"===t.status?"Confirmed":"needs-confirmation"===t.status?"Needs check":"Inferred"})]}),(0,s.jsx)(sg,{surfaceTheme:e,text:t.value,className:(0,S.cn)("mt-2 text-[13px] leading-6",r?"text-[#5f564e]":"text-slate-300"),startDelayMs:a+120,wordDelayMs:100},`inference-value:${t.id}:${a}`),(0,s.jsx)(sg,{surfaceTheme:e,text:t.rationale,className:(0,S.cn)("mt-2 text-[11px] leading-5",r?"text-[#7a7168]":"text-slate-400"),startDelayMs:a+250,wordDelayMs:90},`inference-rationale:${t.id}:${a}`),t.sourceLabels.length>0?(0,s.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:t.sourceLabels.slice(0,3).map((e,a)=>(0,s.jsx)("span",{className:(0,S.cn)("inline-flex items-center rounded-full border px-2 py-0.5 text-[10px] leading-4",r?"border-[#e4ddd2] bg-[#faf6f1] text-[#6d645b]":"border-white/10 bg-white/[0.04] text-slate-300"),children:e},`inference-source:${t.id}:${a}:${e}`))}):null]})}function sv({surfaceTheme:e,label:t,tone:a="default",animated:r=!1,delayMs:n=0,interactive:i=!1,onClick:l}){let o="light"===e,d=(0,S.cn)("inline-flex items-center rounded-full border px-2.5 py-1 font-mono text-[10px] leading-4 transition-colors",r&&"workspace-architect-chip-enter","accent"===a?o?"border-[#d8b184] bg-[#f8efe3] text-[#7c5a34]":"border-cyan-300/30 bg-cyan-300/10 text-cyan-100":"success"===a?o?"border-emerald-300 bg-emerald-50 text-emerald-900":"border-emerald-300/30 bg-emerald-300/12 text-emerald-100":"muted"===a?o?"border-[#e4ddd3] bg-[#faf6f1] text-[#6d645b]":"border-white/10 bg-white/[0.04] text-slate-400":o?"border-[#e4ddd3] bg-white text-[#6d645b]":"border-white/10 bg-white/[0.05] text-slate-300",i?"success"===a?o?"cursor-pointer hover:border-emerald-400 hover:bg-emerald-100":"cursor-pointer hover:border-emerald-300/45 hover:bg-emerald-300/16":o?"cursor-pointer hover:border-[#d8c8ba] hover:bg-[#f6efe6]":"cursor-pointer hover:border-white/15 hover:bg-white/[0.08]":""),c=i?tt.A:j.A;return i?(0,s.jsxs)("button",{type:"button",onClick:l,"aria-label":`Edit ${t}`,className:d,style:sS(n),children:[(0,s.jsx)(c,{className:"mr-1 h-3 w-3"}),t]}):(0,s.jsxs)("span",{className:d,style:sS(n),children:[(0,s.jsx)(c,{className:"mr-1 h-3 w-3"}),t]})}function sj(e,t){let a=e.trim();return a.length<=t?a:`${a.slice(0,Math.max(0,t-1)).trimEnd()}…`}function sk({surfaceTheme:e,tone:t,label:a}){return(0,s.jsx)("span",{className:(0,S.cn)("inline-flex items-center rounded-full border px-2.5 py-1 text-[10px] uppercase tracking-[0.16em]","muted"===t&&("light"===e?"border-[#e4ddd3] bg-[#f7f2eb] text-[#746b61]":"border-white/10 bg-white/[0.05] text-slate-300"),"success"===t&&"border-emerald-200 bg-emerald-50 text-emerald-700","warning"===t&&"border-amber-200 bg-amber-50 text-amber-700","danger"===t&&"border-rose-200 bg-rose-50 text-rose-700"),children:a})}function sN({surfaceTheme:e,title:t,description:a}){let r="light"===e;return(0,s.jsxs)("div",{className:(0,S.cn)("rounded-[18px] border border-dashed px-3 py-3",r?"border-[#ddd5ca] bg-white/80":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsx)(sg,{surfaceTheme:e,text:t,className:(0,S.cn)("text-[12px] font-medium",r?"text-[#171410]":"text-white"),startDelayMs:0,wordDelayMs:65},`empty-title:${t}`),(0,s.jsx)(sg,{surfaceTheme:e,text:a,className:(0,S.cn)("mt-1 text-[12px] leading-5",r?"text-[#70665c]":"text-slate-400"),startDelayMs:90,wordDelayMs:90},`empty-description:${t}`)]})}function sC(e){return"ready"===e?"Ready":"Needs check"}function sS(e){return{animationDelay:`${e}ms`}}let sA=Object.fromEntries(aU.map(e=>[e.value,e.label]));function sI({className:e,surfaceTheme:t,workspaceMode:a="create",mode:r,snapshot:n,basicQuickSetup:i,plan:l,resolvedName:o,resolvedTemplate:d,sourceAnalysis:c,workspacePath:p,notice:m,basicRules:u,basicPreset:h,onOpenBlueprintEditor:x,onOpenDocumentEditor:b,onBasicPresetChange:f,onBasicRuleToggle:w,progress:y}){let v="light"===t,j=(0,g.useRef)({}),k=(0,g.useRef)(null),[N,C]=(0,g.useState)(null),A=(e="workspace.name")=>{x?.(e)},T=(0,g.useMemo)(()=>(function({mode:e,plan:t,notice:a,progress:s,resolvedName:r,resolvedTemplate:n,basicRules:i,basicPreset:l,sourceAnalysis:o,workspacePath:d}){return{mode:e,noticeSignature:a?`${a.tone}:${a.title}:${a.description}`:"",progressSignature:s?JSON.stringify(s):"",basic:{architectSignature:t?[t.architectSummary,t.company.name,t.company.mission,t.company.targetCustomer,t.workspace.template,JSON.stringify(t.workspace.rules),t.intake.sources.map(e=>`${e.kind}:${e.status}:${e.label}:${Math.round((e.confidence??0)*100)}`).join("|"),t.intake.inferences.map(e=>`${e.section}:${e.status}:${e.label}:${e.value}`).join("|"),t.intake.confirmations.join("|")].join(":"):"",summarySignature:[r,n,o.kind,o.label,o.hint,o.repoUrl??"",o.existingPath??"",o.websiteUrl??"",d].join(":"),defaultsSignature:`${l}:${i.generateStarterDocs}:${i.generateMemory}:${i.kickoffMission}`},advanced:{stage:t?.stage??null,readinessSignature:t?`${t.readinessScore}:${t.architectSummary}`:"",deploySignature:t?`${t.intake.reviewRequested}:${t.deploy.blockers.join("|")}:${t.deploy.warnings.join("|")}`:"",sectionSignatures:Object.fromEntries(sn.map(e=>[e.id,t?`${sd(t,e.id).label}:${sd(t,e.id).variant}:${sc(t,e.id)}`:""]))}}})({mode:r,plan:l,notice:m,progress:y,resolvedName:o,resolvedTemplate:d,basicRules:u,basicPreset:h,sourceAnalysis:c,workspacePath:p}),[h,u,r,m,l,y,o,d,c,p]),M=(0,g.useMemo)(()=>l?aR({name:l.workspace.name||"Workspace",brief:l.company.mission||l.product.offer||void 0,template:l.workspace.template,sourceMode:l.workspace.sourceMode,rules:l.workspace.rules,agents:l.team.persistentAgents.filter(e=>e.enabled),docOverrides:l.workspace.docOverrides,toolExamples:[],contextSources:l.intake.sources}):[],[l]),O=(0,g.useMemo)(()=>new Map(M.map(e=>[e.path,e])),[M]),R=(0,g.useMemo)(()=>aM(l?.workspace.template??d,l?.workspace.rules??u),[u,l?.workspace.rules,l?.workspace.template,d]);return(0,g.useEffect)(()=>{let e=k.current;if(k.current=T,!e)return;let t=function(e,t){if(e.mode!==t.mode)return"basic"===t.mode?t.basic.architectSignature?"architect-readout":"summary":t.advanced.stage?`section-${sl(t.advanced.stage)}`:"readiness";if(e.noticeSignature!==t.noticeSignature&&t.noticeSignature)return"notice";if(e.progressSignature!==t.progressSignature&&t.progressSignature)return"progress";if("basic"===t.mode)return e.basic.architectSignature!==t.basic.architectSignature&&t.basic.architectSignature?"architect-readout":e.basic.summarySignature!==t.basic.summarySignature?"summary":e.basic.defaultsSignature!==t.basic.defaultsSignature?"defaults":null;if(e.advanced.deploySignature!==t.advanced.deploySignature&&t.advanced.deploySignature)return"deploy-review";if(e.advanced.stage!==t.advanced.stage&&t.advanced.stage)return`section-${sl(t.advanced.stage)}`;if(e.advanced.readinessSignature!==t.advanced.readinessSignature&&t.advanced.readinessSignature)return"readiness";for(let a of sn)if(e.advanced.sectionSignatures[a.id]!==t.advanced.sectionSignatures[a.id])return`section-${a.id}`;return null}(e,T);t&&C(t)},[T]),(0,g.useEffect)(()=>{if(!N)return;let e=j.current[N];e&&globalThis.requestAnimationFrame(()=>{e.scrollIntoView({behavior:"smooth",block:"center"})});let t=globalThis.setTimeout(()=>{C(e=>e===N?null:e)},2200);return()=>{globalThis.clearTimeout(t)}},[N]),(0,s.jsx)("aside",{className:(0,S.cn)("min-h-0 border-t lg:border-l lg:border-t-0",v?"border-[#ebe5dd] bg-[#f7f2eb]":"border-white/10 bg-[rgba(5,9,18,0.92)]",e),children:(0,s.jsx)(aC.F,{className:"h-full",children:(0,s.jsxs)("div",{className:"space-y-4 p-4 md:p-5",children:[(0,s.jsx)(sM,{surfaceTheme:t,title:"basic"===r?"Workspace draft":"Workspace blueprint",subtitle:"basic"===r?"Live draft view. The fast path stays available while Architect fills in the details.":"Structured blueprint synced with the conversation.",action:l&&x?(0,s.jsxs)(I,{type:"button",variant:"secondary",size:"sm",onClick:()=>A("workspace.name"),className:v?"rounded-full border-[#ddd6cb] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:[(0,s.jsx)(tt.A,{className:"mr-2 h-3.5 w-3.5"}),"Edit details"]}):null}),"create"===a?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(sT,{sectionKey:"setup-speed",activeSection:N,surfaceTheme:t,register:e=>{j.current["setup-speed"]=e},children:(0,s.jsx)(sD,{surfaceTheme:t,mode:r,preset:h,onPresetChange:f,onOpenBlueprintEditor:A})}),i?(0,s.jsx)("div",{className:"space-y-3",children:i}):null]}):null,m?(0,s.jsx)(sT,{sectionKey:"notice",activeSection:N,surfaceTheme:t,register:e=>{j.current.notice=e},children:(0,s.jsxs)("div",{className:(0,S.cn)("rounded-[18px] border px-4 py-3","warning"===m.tone?v?"border-amber-200 bg-amber-50 text-amber-900":"border-amber-400/25 bg-amber-400/10 text-amber-100":v?"border-[#e3ddd4] bg-white text-[#3f3933]":"border-white/10 bg-white/[0.04] text-slate-200"),children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[11px] uppercase tracking-[0.18em]",v?"text-[#9c9389]":"text-slate-500"),children:m.title}),(0,s.jsx)("p",{className:"mt-1 text-[13px] leading-6",children:m.description})]})}):null,y?(0,s.jsx)(sT,{sectionKey:"progress",activeSection:N,surfaceTheme:t,register:e=>{j.current.progress=e},children:(0,s.jsx)(aN,{progress:y,className:(0,S.cn)(v?"border-[#e5ded3] bg-white text-slate-900 [&_p]:text-inherit":"border-white/10 bg-slate-950/50")})}):null,"basic"===r?(0,s.jsxs)("div",{className:"space-y-3",children:[l?(0,s.jsx)(sT,{sectionKey:"architect-readout",activeSection:N,surfaceTheme:t,register:e=>{j.current["architect-readout"]=e},children:(0,s.jsx)(sh,{surfaceTheme:t,plan:l,variant:"panel",onOpenBlueprintEditor:A,onOpenDocumentEditor:b},l.updatedAt)}):null,(0,s.jsx)(sT,{sectionKey:"summary",activeSection:N,surfaceTheme:t,register:e=>{j.current.summary=e},children:(0,s.jsx)(sO,{surfaceTheme:t,resolvedName:o,resolvedTemplate:d,sourceAnalysis:c,workspacePath:p,workspaceRoot:n.diagnostics.workspaceRoot,summaryLabel:l?"Architect refreshed the draft.":"Resolved from quick setup.",onOpenBlueprintEditor:A})}),(0,s.jsx)(sT,{sectionKey:"defaults",activeSection:N,surfaceTheme:t,register:e=>{j.current.defaults=e},children:(0,s.jsxs)("div",{className:(0,S.cn)("rounded-[22px] border p-4",v?"border-[#e5ddd2] bg-white":"border-white/10 bg-white/[0.04]"),children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[11px] uppercase tracking-[0.18em]",v?"text-[#a0978b]":"text-slate-500"),children:"Fast-path defaults"}),(0,s.jsx)(sE,{surfaceTheme:t,plan:l,template:d,rules:u,preset:h,onRuleToggle:w,onOpenBlueprintEditor:A,onOpenDocumentEditor:b})]})})]}):l?(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)(sT,{sectionKey:"readiness",activeSection:N,surfaceTheme:t,register:e=>{j.current.readiness=e},children:(0,s.jsx)("button",{type:"button",onClick:()=>A("deploy.blockers"),className:(0,S.cn)("w-full rounded-[22px] border p-4 text-left transition-colors",v?"border-[#e5ddd2] bg-white hover:border-[#d9ccbf] hover:bg-[#fdfbf7]":"border-white/10 bg-white/[0.04] hover:border-white/15 hover:bg-white/[0.06]"),children:(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[11px] uppercase tracking-[0.18em]",v?"text-[#a0978b]":"text-slate-500"),children:"Readiness"}),(0,s.jsxs)("p",{className:(0,S.cn)("mt-1 text-[28px] font-semibold tracking-[-0.03em]",v?"text-[#181612]":"text-white"),children:[l.readinessScore,"%"]}),(0,s.jsx)("p",{className:(0,S.cn)("text-[13px] leading-6",v?"text-[#6e665d]":"text-slate-300"),children:l.architectSummary})]}),(0,s.jsx)("span",{className:(0,S.cn)("inline-flex size-10 items-center justify-center rounded-full border",v?"border-[#e5ddd2] bg-[#f5f0e8] text-[#6a635b]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,s.jsx)(t7.A,{className:"h-4 w-4"})})]})})}),sn.map(e=>{let a=sd(l,e.id),r=e.icon,n=`section-${e.id}`;return(0,s.jsx)(sT,{sectionKey:n,activeSection:N,surfaceTheme:t,register:e=>{j.current[n]=e},children:(0,s.jsx)("button",{type:"button",onClick:()=>A("company"===e.id?"company.mission":"product"===e.id?"product.offer":"workspace"===e.id?"workspace.name":"team"===e.id?"team.maxParallelRuns":"deploy.blockers"),className:(0,S.cn)("w-full rounded-[22px] border p-4 text-left transition-colors",v?"border-[#e5ddd2] bg-white hover:border-[#d9ccbf] hover:bg-[#fdfbf7]":"border-white/10 bg-white/[0.04] hover:border-white/15 hover:bg-white/[0.06]"),children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("span",{className:(0,S.cn)("inline-flex size-9 shrink-0 items-center justify-center rounded-full border",v?"border-[#e7e0d6] bg-[#faf6f1] text-[#5e5750]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,s.jsx)(r,{className:"h-4 w-4"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[14px] font-semibold",v?"text-[#171410]":"text-white"),children:e.label}),(0,s.jsx)(s$,{surfaceTheme:t,tone:a.variant,label:a.label})]}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1 text-[13px] leading-6",v?"text-[#70685f]":"text-slate-300"),children:sc(l,e.id)})]})]})})},e.id)}),(0,s.jsx)(sT,{sectionKey:"documents",activeSection:N,surfaceTheme:t,register:e=>{j.current.documents=e},children:(0,s.jsxs)("div",{className:(0,S.cn)("rounded-[22px] border p-4",v?"border-[#e5ddd2] bg-white":"border-white/10 bg-white/[0.04]"),children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(a5.A,{className:(0,S.cn)("h-4 w-4",v?"text-[#5f5952]":"text-slate-300")}),(0,s.jsx)("p",{className:(0,S.cn)("text-[14px] font-semibold",v?"text-[#171410]":"text-white"),children:"Documents"})]}),(0,s.jsx)("div",{className:"mt-3 space-y-3",children:R.sections.map(e=>{let a=e.resources.map(e=>O.get(e.relativePath)).filter(e=>!!e);return(0,s.jsxs)("div",{className:(0,S.cn)("rounded-[18px] border px-3 py-3",v?"border-[#e8e0d6] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[12px] font-semibold",v?"text-[#171410]":"text-white"),children:e.title}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1 text-[11px] leading-5",v?"text-[#7a7168]":"text-slate-400"),children:e.description})]}),(0,s.jsx)(s$,{surfaceTheme:t,tone:e.enabled?"success":"muted",label:e.enabled?"Included":"Skipped"})]}),a.length>0?(0,s.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:a.map(e=>(0,s.jsx)(sP,{surfaceTheme:t,label:e.path,tone:e.generated?e.overridden?"success":"default":"accent",interactive:!!b,onClick:b?()=>b(e.path):void 0},e.path))}):(0,s.jsx)("p",{className:(0,S.cn)("mt-2 text-[11px] leading-5",v?"text-[#7a7168]":"text-slate-400"),children:"Disabled by the current workspace rules."})]},e.id)})}),b?(0,s.jsx)("p",{className:(0,S.cn)("mt-2 text-[11px] leading-5",v?"text-[#7a7168]":"text-slate-400"),children:"edit"===a?"These are the current workspace files grouped by the canonical context manifest.":"These are the scaffold documents that will be written for this workspace."}):null]})}),(0,s.jsx)(sT,{sectionKey:"deploy-review",activeSection:N,surfaceTheme:t,register:e=>{j.current["deploy-review"]=e},children:(0,s.jsxs)("button",{type:"button",onClick:()=>A("deploy.blockers"),className:(0,S.cn)("w-full rounded-[22px] border p-4 text-left transition-colors",v?"border-[#e5ddd2] bg-white hover:border-[#d9ccbf] hover:bg-[#fdfbf7]":"border-white/10 bg-white/[0.04] hover:border-white/15 hover:bg-white/[0.06]"),children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(a3.A,{className:(0,S.cn)("h-4 w-4",v?"text-[#5f5952]":"text-slate-300")}),(0,s.jsx)("p",{className:(0,S.cn)("text-[14px] font-semibold",v?"text-[#171410]":"text-white"),children:"Deploy review"})]}),l.deploy.blockers.length>0?(0,s.jsx)(sL,{surfaceTheme:t,title:"Blockers",tone:"danger",items:l.deploy.blockers}):null,l.deploy.warnings.length>0?(0,s.jsx)(sL,{surfaceTheme:t,title:"Warnings",tone:"warning",items:l.deploy.warnings}):null,0===l.deploy.blockers.length&&0===l.deploy.warnings.length?(0,s.jsx)("p",{className:(0,S.cn)("mt-3 text-[13px] leading-6",v?"text-[#70685f]":"text-slate-300"),children:"Architect has not surfaced blockers or warnings yet. Request review when the blueprint feels directionally right."}):null]})})]}):(0,s.jsxs)("div",{className:(0,S.cn)("rounded-[22px] border border-dashed p-5",v?"border-[#ddd5ca] bg-white/80":"border-white/10 bg-white/[0.04]"),children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[14px] font-medium",v?"text-[#211d19]":"text-white"),children:"Architect is preparing the blueprint."}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1 text-[13px] leading-6",v?"text-[#776f65]":"text-slate-300"),children:"Once the first plan is ready, this pane will start reflecting the structured workspace draft."})]})]})})})}function sT({sectionKey:e,activeSection:t,surfaceTheme:a,register:r,children:n}){return(0,s.jsx)("div",{ref:r,className:(0,S.cn)("scroll-mt-6 rounded-[26px] transition-all duration-500",t===e&&("light"===a?"ring-2 ring-[#d8b184]/70 shadow-[0_0_0_1px_rgba(216,177,132,0.18),0_18px_36px_rgba(102,78,47,0.16)]":"ring-2 ring-cyan-300/45 shadow-[0_0_0_1px_rgba(103,232,249,0.14),0_18px_36px_rgba(6,182,212,0.16)]")),children:n})}function sM({surfaceTheme:e,title:t,subtitle:a,action:r}){let n="light"===e;return(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[11px] uppercase tracking-[0.18em]",n?"text-[#8b7262]":"text-slate-500"),children:t}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1 text-[13px] leading-6",n?"text-[#705b4d]":"text-slate-300"),children:a})]}),r?(0,s.jsx)("div",{className:"shrink-0",children:r}):null]})}function sO({surfaceTheme:e,resolvedName:t,resolvedTemplate:a,sourceAnalysis:r,workspacePath:n,workspaceRoot:i,summaryLabel:l,onOpenBlueprintEditor:o}){let d="light"===e;return(0,s.jsx)("div",{className:(0,S.cn)("rounded-[22px] border p-4",d?"border-[#e5ddd2] bg-white":"border-white/10 bg-white/[0.04]"),children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("span",{className:(0,S.cn)("inline-flex size-9 shrink-0 items-center justify-center rounded-full border",d?"border-[#e7e0d6] bg-[#faf6f1] text-[#5e5750]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,s.jsx)(eI.A,{className:"h-4 w-4"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[11px] uppercase tracking-[0.18em]",d?"text-[#a0978b]":"text-slate-500"),children:"Fast-path snapshot"}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1 text-[12px] leading-5",d?"text-[#776f65]":"text-slate-400"),children:l}),(0,s.jsxs)("div",{className:"mt-4 space-y-2",children:[(0,s.jsx)(sR,{surfaceTheme:e,label:"Name",value:t,icon:eI.A,onClick:()=>o?.("workspace.name")}),(0,s.jsx)(sR,{surfaceTheme:e,label:"Template",value:sA[a],icon:a4.A,onClick:()=>o?.("workspace.template")}),(0,s.jsx)(sR,{surfaceTheme:e,label:"Source",value:r.label,icon:"clone"===r.kind?a8.A:"website"===r.kind?a6.A:a9.A,onClick:()=>o?.("workspace.sourceMode")}),(0,s.jsx)(sR,{surfaceTheme:e,label:"Path",value:n,icon:a9.A,mono:!0,title:`Root: ${i}`,onClick:()=>o?.("workspace.directory")})]})]})]})})}function sR({surfaceTheme:e,label:t,value:a,icon:r,detail:n,mono:i=!1,title:l,onClick:o}){let d="light"===e,c=!!o;return(0,s.jsx)("button",{type:"button",onClick:o,className:(0,S.cn)("w-full rounded-[14px] border px-3 py-2.5 text-left transition-colors",d?"border-[#e8e0d6] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]",c&&(d?"cursor-pointer hover:border-[#d9b78b] hover:bg-[#f7efe3] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#d9b78b]/60":"cursor-pointer hover:border-cyan-300/30 hover:bg-white/[0.06] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-cyan-300/30")),title:l,children:(0,s.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,s.jsx)("span",{className:(0,S.cn)("inline-flex size-6 shrink-0 items-center justify-center rounded-full border",d?"border-[#e0d7cc] bg-white text-[#615a52]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,s.jsx)(r,{className:"h-3 w-3"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[10px] uppercase tracking-[0.16em]",d?"text-[#8d8276]":"text-slate-500"),children:t}),(0,s.jsx)("p",{className:(0,S.cn)("truncate text-[12px] font-medium leading-4",d?"text-[#171410]":"text-white",i&&"font-mono text-[12px]"),title:a,children:a})]}),c?(0,s.jsx)(tt.A,{className:(0,S.cn)("h-3.5 w-3.5 shrink-0",d?"text-[#8f8377]":"text-slate-400")}):null,n?(0,s.jsx)("span",{className:(0,S.cn)("shrink-0 text-[10px] leading-4",d?"text-[#776f65]":"text-slate-400"),children:n}):null]})})}function s$({surfaceTheme:e,tone:t,label:a}){return(0,s.jsx)("span",{className:(0,S.cn)("inline-flex items-center rounded-full border px-2.5 py-1 text-[10px] uppercase tracking-[0.16em]","muted"===t&&("light"===e?"border-[#e4ddd3] bg-[#f7f2eb] text-[#746b61]":"border-white/10 bg-white/[0.05] text-slate-300"),"success"===t&&"border-emerald-200 bg-emerald-50 text-emerald-700","warning"===t&&"border-amber-200 bg-amber-50 text-amber-700","danger"===t&&"border-rose-200 bg-rose-50 text-rose-700"),children:a})}function sE({surfaceTheme:e,plan:t,template:a,rules:r,preset:n,onRuleToggle:i,onOpenBlueprintEditor:l,onOpenDocumentEditor:o}){var d,c;let p,m,u,h,x,b="light"===e,f=aM(a,r),w=(d=a,c=r,p=aT(d),m=new Set(aS),u=p.filter(e=>m.has(e.relativePath)).map(e=>e.label),h=p.filter(e=>e.relativePath.startsWith("docs/")||e.relativePath.startsWith("deliverables/")).map(e=>e.label),x=p.filter(e=>"MEMORY.md"===e.relativePath||e.relativePath.startsWith("memory/")).map(e=>e.label),[{id:"core",title:"Core agent files",description:"Identity and operating rules.",checked:!0,locked:!0,files:u,rule:void 0},{id:"docs",title:"Starter docs",description:"Brief, architecture, handoff.",checked:c.generateStarterDocs,locked:!1,files:h,rule:"generateStarterDocs"},{id:"memory",title:"Memory files",description:"Durable decisions and context.",checked:c.generateMemory,locked:!1,files:x,rule:"generateMemory"},{id:"kickoff",title:"Kickoff mission",description:"Starts the first mission.",checked:c.kickoffMission,locked:!1,files:[],rule:"kickoffMission"}]),y=(0,g.useMemo)(()=>new Set(a$(t?.workspace.docOverrides).map(e=>e.path)),[t?.workspace.docOverrides]),v=!!t;return(0,s.jsxs)("div",{className:"mt-3 space-y-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:["custom"===n?(0,s.jsx)(s$,{surfaceTheme:e,tone:"muted",label:"Custom mix"}):(0,s.jsx)("span",{}),l?(0,s.jsxs)(I,{type:"button",variant:"secondary",size:"sm",onClick:()=>l("workspace.ruleGenerateStarterDocs"),className:b?"rounded-full border-[#ddd6cb] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:[(0,s.jsx)(tt.A,{className:"mr-2 h-3.5 w-3.5"}),"Edit section"]}):null]}),(0,s.jsx)("div",{className:"space-y-2",children:w.map(t=>(0,s.jsx)("button",{type:"button",onClick:t.rule?()=>i(t.rule):void 0,disabled:!t.rule,className:(0,S.cn)("w-full rounded-[18px] border px-3 py-3 text-left transition-colors",b?"border-[#e8e0d6] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]",t.rule?b?"hover:border-[#d8c9ba] hover:bg-[#f6efe6]":"hover:border-white/15 hover:bg-white/[0.05]":"cursor-default"),children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("span",{className:(0,S.cn)("mt-0.5 inline-flex size-5 shrink-0 items-center justify-center rounded-md border",t.checked?b?"border-[#1f1b17] bg-[#1f1b17] text-white":"border-cyan-300 bg-cyan-300 text-slate-950":b?"border-[#d9d0c6] bg-white text-transparent":"border-white/15 bg-transparent text-transparent"),children:(0,s.jsx)(j.A,{className:"h-3 w-3"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[13px] font-medium",b?"text-[#171410]":"text-white"),children:t.title}),t.locked?(0,s.jsxs)("span",{className:(0,S.cn)("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[10px] uppercase tracking-[0.16em]",b?"border-[#e0d7cc] bg-white text-[#7a7168]":"border-white/10 bg-white/[0.05] text-slate-400"),children:[(0,s.jsx)(a7.A,{className:"h-3 w-3"}),"Required"]}):null]}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1 text-[12px] leading-5",b?"text-[#776f65]":"text-slate-400"),children:t.description}),t.files.length>0?(0,s.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:t.files.map(t=>(0,s.jsx)(sP,{surfaceTheme:e,label:t},t))}):null]})]})},t.id))}),(0,s.jsxs)("div",{className:(0,S.cn)("rounded-[18px] border px-3 py-3",b?"border-[#e8e0d6] bg-[#faf6f1]":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(a5.A,{className:(0,S.cn)("h-4 w-4",b?"text-[#5f5952]":"text-slate-300")}),(0,s.jsx)("p",{className:(0,S.cn)("text-[12px] uppercase tracking-[0.16em]",b?"text-[#8d8276]":"text-slate-500"),children:"Canonical manifest"})]}),(0,s.jsx)("div",{className:"mt-3 space-y-3",children:f.sections.map(t=>(0,s.jsxs)("div",{className:(0,S.cn)("rounded-[16px] border px-3 py-3",b?"border-[#e2d9cc] bg-white":"border-white/10 bg-white/[0.02]"),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[12px] font-semibold",b?"text-[#171410]":"text-white"),children:t.title}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1 text-[11px] leading-5",b?"text-[#7b7269]":"text-slate-400"),children:t.description})]}),(0,s.jsx)(s$,{surfaceTheme:e,tone:t.enabled?"success":"muted",label:t.enabled?"Included":"Skipped"})]}),t.resources.length>0?(0,s.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:t.resources.map(t=>(0,s.jsx)(sP,{surfaceTheme:e,label:t.label,tone:y.has(t.relativePath)?"success":"default",interactive:!!(v&&o),onClick:v&&o?()=>o(t.relativePath):void 0},t.relativePath))}):(0,s.jsx)("p",{className:(0,S.cn)("mt-2 text-[11px] leading-5",b?"text-[#7a7168]":"text-slate-400"),children:"Disabled by the current workspace rules."})]},t.id))}),r.kickoffMission?(0,s.jsx)(sP,{surfaceTheme:e,label:"Kickoff mission",tone:"accent"}):null,v&&o?(0,s.jsx)("p",{className:(0,S.cn)("mt-2 text-[11px] leading-5",b?"text-[#7a7168]":"text-slate-400"),children:"Click a file chip to edit its scaffold or override."}):null]}),(0,s.jsxs)("p",{className:(0,S.cn)("text-[13px] leading-6",b?"text-[#70685f]":"text-slate-300"),children:["fastest"===n?"Core files only.":"custom"===n?"Only the extras you kept.":"Starter docs, memory, kickoff."," Switch to Advanced later if you need more control."]})]})}function sD({surfaceTheme:e,mode:t,preset:a,onPresetChange:r,onOpenBlueprintEditor:n}){let i="light"===e;return(0,s.jsxs)("div",{className:(0,S.cn)("rounded-xl border p-3",i?"border-[#e5ddd2] bg-white":"border-white/10 bg-white/[0.04]"),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[10px] uppercase tracking-[0.18em]",i?"text-[#a0978b]":"text-slate-500"),children:"Setup speed"}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1 text-[11px] leading-5",i?"text-[#70685f]":"text-slate-300"),children:"basic"===t?"Choose how much scaffold the fast path should write.":"These presets also update the bootstrap rules."})]}),(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:["custom"===a?(0,s.jsx)(s$,{surfaceTheme:e,tone:"muted",label:"Custom"}):null,n?(0,s.jsxs)(I,{type:"button",variant:"secondary",size:"sm",onClick:()=>n("workspace.ruleGenerateStarterDocs"),className:i?"rounded-full border-[#ddd6cb] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:[(0,s.jsx)(tt.A,{className:"mr-2 h-3.5 w-3.5"}),"Edit"]}):null]})]}),(0,s.jsxs)("div",{className:"mt-3 space-y-2",children:[(0,s.jsx)(s_,{surfaceTheme:e,active:"standard"===a,title:"Standard",description:"Docs, memory, kickoff",onClick:()=>r("standard")}),(0,s.jsx)(s_,{surfaceTheme:e,active:"fastest"===a,title:"Fastest setup",description:"Core files only",onClick:()=>r("fastest")})]})]})}function s_({surfaceTheme:e,active:t,title:a,description:r,onClick:n}){let i="light"===e;return(0,s.jsx)("button",{type:"button",onClick:n,className:(0,S.cn)("w-full rounded-[14px] border px-3 py-2 text-left transition-colors",t?i?"border-[#1f1b17] bg-[#1f1b17] text-white":"border-cyan-300 bg-cyan-300/15 text-cyan-50":i?"border-[#e8e0d6] bg-[#faf6f1] text-[#171410] hover:border-[#d8c9ba] hover:bg-[#f6efe6]":"border-white/10 bg-white/[0.03] text-white hover:border-white/15 hover:bg-white/[0.05]"),children:(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,s.jsx)(a4.A,{className:"h-3.5 w-3.5 shrink-0"}),(0,s.jsx)("p",{className:"truncate text-[12px] font-medium",children:a})]}),(0,s.jsx)("p",{className:(0,S.cn)("truncate text-right text-[11px] leading-4",t?"opacity-80":i?"text-[#776f65]":"text-slate-400"),children:r})]})})}function sP({surfaceTheme:e,label:t,tone:a="default",interactive:r=!1,onClick:n}){let i=(0,S.cn)("inline-flex items-center rounded-full border px-2.5 py-1 font-mono text-[10px] transition-colors","accent"===a?"light"===e?"border-[#d8b184] bg-[#f8efe3] text-[#7c5a34]":"border-cyan-300/30 bg-cyan-300/10 text-cyan-100":"success"===a?"light"===e?"border-emerald-300 bg-emerald-50 text-emerald-900":"border-emerald-300/30 bg-emerald-300/12 text-emerald-100":"light"===e?"border-[#e4ddd3] bg-white text-[#6c645b]":"border-white/10 bg-white/[0.05] text-slate-300",r?"success"===a?"light"===e?"cursor-pointer hover:border-emerald-400 hover:bg-emerald-100":"cursor-pointer hover:border-emerald-300/45 hover:bg-emerald-300/16":"light"===e?"cursor-pointer hover:border-[#d8c8ba] hover:bg-[#f6efe6]":"cursor-pointer hover:border-white/15 hover:bg-white/[0.08]":"");return r?(0,s.jsxs)("button",{type:"button",onClick:n,"aria-label":`Edit ${t}`,className:i,children:[(0,s.jsx)(tt.A,{className:"mr-1 h-3 w-3"}),t]}):(0,s.jsxs)("span",{className:i,children:[(0,s.jsx)(j.A,{className:"mr-1 h-3 w-3"}),t]})}function sL({surfaceTheme:e,title:t,tone:a,items:r}){let n="light"===e;return(0,s.jsxs)("div",{className:(0,S.cn)("mt-3 rounded-[18px] border px-4 py-3","danger"===a?n?"border-rose-200 bg-rose-50":"border-rose-400/25 bg-rose-400/10":n?"border-amber-200 bg-amber-50":"border-amber-400/25 bg-amber-400/10"),children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[11px] uppercase tracking-[0.18em]",n?"text-[#9f958a]":"text-slate-500"),children:t}),(0,s.jsx)("div",{className:"mt-2 space-y-2",children:r.map(e=>(0,s.jsxs)("div",{className:(0,S.cn)("flex items-start gap-2 text-[13px] leading-6",n?"text-[#403934]":"text-slate-200"),children:[(0,s.jsx)(o.A,{className:"mt-1 h-3.5 w-3.5 shrink-0"}),(0,s.jsx)("span",{children:e})]},e))})]})}function sU({surfaceTheme:e,mode:t,onModeChange:a,onNewDraft:r,badges:n,title:i="Create workspace",showModeToggle:l=!0,showNewDraft:o=!0}){let d="light"===e;return(0,s.jsx)("div",{className:(0,S.cn)("relative z-[1] border-b px-4 py-2 md:px-5",d?"border-[#e7e1d8] bg-[linear-gradient(180deg,rgba(255,255,255,0.96),rgba(248,244,237,0.94))]":"border-white/10 bg-[linear-gradient(180deg,rgba(10,16,29,0.96),rgba(6,11,21,0.94))]"),children:(0,s.jsxs)("div",{className:"flex flex-col gap-2 md:flex-nowrap md:flex-row md:items-center md:justify-between md:gap-3",children:[(0,s.jsx)("div",{className:"min-w-0",children:(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-2.5",children:[(0,s.jsx)("span",{className:(0,S.cn)("inline-flex size-8 shrink-0 items-center justify-center rounded-full border shadow-[0_8px_20px_rgba(56,47,38,0.08)]",d?"border-[#e3ddd4] bg-white text-[#4c4640]":"border-white/10 bg-white/[0.05] text-slate-200 shadow-[0_16px_36px_rgba(0,0,0,0.28)]"),children:(0,s.jsx)(t7.A,{className:"h-3.5 w-3.5"})}),(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[10px] uppercase tracking-[0.22em]",d?"text-[#7f6554]":"text-slate-500"),children:"Architect"}),(0,s.jsx)("span",{className:(0,S.cn)("text-[10px] uppercase tracking-[0.18em]",d?"text-[#a59a8e]":"text-slate-600"),children:"/"}),(0,s.jsx)("h2",{className:(0,S.cn)("truncate text-[16px] font-semibold tracking-[-0.02em]",d?"text-[#2d2118]":"text-white"),children:i})]})]})}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 md:flex-nowrap md:justify-end",children:[n.length>0?(0,s.jsx)("div",{className:"flex flex-wrap items-center gap-1.5 md:flex-nowrap",children:n.map(e=>(0,s.jsx)("span",{className:(0,S.cn)("inline-flex items-center rounded-full border px-2.5 py-0.5 text-[9px] font-medium uppercase tracking-[0.16em]","success"===e.tone&&"border-emerald-200 bg-emerald-50 text-emerald-700","warning"===e.tone&&"border-amber-200 bg-amber-50 text-amber-700","danger"===e.tone&&"border-rose-200 bg-rose-50 text-rose-700",(!e.tone||"muted"===e.tone)&&(d?"border-[#e4ddd3] bg-white text-[#5f5348]":"border-white/10 bg-white/[0.05] text-slate-300")),children:e.label},e.id))}):null,l?(0,s.jsxs)("div",{className:(0,S.cn)("inline-flex rounded-full border p-0.5",d?"border-[#e4ddd3] bg-[#f4efe7]":"border-white/10 bg-white/[0.04]"),children:[(0,s.jsx)(sF,{surfaceTheme:e,active:"basic"===t,label:"Basic",onClick:()=>a("basic")}),(0,s.jsx)(sF,{surfaceTheme:e,active:"advanced"===t,label:"Advanced",onClick:()=>a("advanced")})]}):null,o&&r?(0,s.jsxs)("button",{type:"button",onClick:r,className:(0,S.cn)("inline-flex h-8 items-center gap-2 rounded-full border px-2.5 text-[11px] transition-colors",d?"border-[#dfd8ce] bg-white text-[#38322d] hover:bg-[#f5f1ea]":"border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]"),children:[(0,s.jsx)(eu.A,{className:"h-3.5 w-3.5"}),"New draft"]}):null]})]})})}function sF({surfaceTheme:e,active:t,label:a,onClick:r}){let n="light"===e;return(0,s.jsx)("button",{type:"button",onClick:r,className:(0,S.cn)("inline-flex min-w-[78px] items-center justify-center rounded-full px-2.5 py-1 text-[11px] transition-colors",t?n?"bg-white text-[#151310] shadow-sm":"bg-[#0f1726] text-white shadow-[0_8px_18px_rgba(0,0,0,0.28)]":n?"text-[#6d584a] hover:text-[#2d2824]":"text-slate-400 hover:text-slate-100"),children:a})}var sz=a(3942);function sW({surfaceTheme:e,value:t,placeholder:a,onChange:r,onSubmit:n,disabled:l=!1,isBusy:o=!1,helperText:d,toolbar:c,className:p}){let m=(0,g.useRef)(null),u=!!t.trim()&&!l;(0,g.useEffect)(()=>{let e=m.current;e&&(e.style.height="0px",e.style.height=`${Math.min(e.scrollHeight,200)}px`)},[t]);let h=async e=>{e.preventDefault(),u&&await n()},x=async e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),u&&await n())},b="light"===e;return(0,s.jsxs)("form",{onSubmit:h,className:(0,S.cn)("rounded-[20px] border p-2.5 transition-all duration-200 focus-within:shadow-[0_0_0_1px_rgba(0,0,0,0.02)]",b?"border-[#ddd6cb] bg-white shadow-[0_18px_56px_rgba(56,47,38,0.08)] focus-within:border-[#cfc6ba]":"border-white/10 bg-[rgba(7,12,22,0.92)] shadow-[0_18px_56px_rgba(0,0,0,0.34)] focus-within:border-cyan-300/30",p),children:[(0,s.jsx)("textarea",{ref:m,value:t,onChange:e=>r(e.target.value),onKeyDown:x,placeholder:a,className:(0,S.cn)("min-h-[44px] max-h-[200px] w-full resize-none overflow-y-auto border-0 bg-transparent px-1.5 py-1.5 text-[15px] leading-6 outline-none",b?"text-[#191714] placeholder:text-[#9b948c]":"text-slate-100 placeholder:text-slate-500")}),(0,s.jsxs)("div",{className:"mt-2 flex flex-wrap items-center justify-between gap-2",children:[(0,s.jsxs)("div",{className:"flex min-h-8 items-center gap-2",children:[c,d?(0,s.jsx)("p",{className:(0,S.cn)("text-[11px]",b?"text-[#8b837a]":"text-slate-400"),children:d}):null]}),(0,s.jsx)("button",{type:"submit",disabled:!u,className:(0,S.cn)("inline-flex size-8 items-center justify-center rounded-full transition-colors disabled:cursor-not-allowed",b?"bg-[#161514] text-white hover:bg-[#26231f] disabled:bg-[#d5cec5] disabled:text-[#8d857c]":"bg-cyan-300 text-slate-950 hover:bg-cyan-200 disabled:bg-white/[0.08] disabled:text-slate-500"),children:o?(0,s.jsx)(i.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(sz.A,{className:"h-3.5 w-3.5"})})]})]})}function sB({surfaceTheme:e,messages:t,architectMessageId:a=null,architectPlan:r=null,isTyping:n=!1,typingLabel:i="Typing…",emptyState:l,auxiliary:o,className:d}){let c=(0,g.useRef)(null),p=(0,g.useRef)(null);return(0,g.useEffect)(()=>{c.current?.scrollIntoView({block:"end"})},[a,r?.updatedAt,n,t.length]),(0,g.useEffect)(()=>{let e=p.current;if(!e||"u"<typeof ResizeObserver)return;let t=0,a=new ResizeObserver(()=>{globalThis.cancelAnimationFrame(t),t=globalThis.requestAnimationFrame(()=>{c.current?.scrollIntoView({block:"end"})})});return a.observe(e),()=>{a.disconnect(),globalThis.cancelAnimationFrame(t)}},[]),(0,s.jsx)(aC.F,{className:(0,S.cn)("h-full",d),children:(0,s.jsxs)("div",{ref:p,className:"mx-auto flex min-h-full w-full max-w-3xl flex-col gap-4 px-2 py-4 md:gap-5 md:px-4",children:[l,o,t.map(t=>(0,s.jsx)(sq,{message:t,surfaceTheme:e,architectMessageId:a,architectPlan:r},t.id)),n?(0,s.jsx)(sK,{surfaceTheme:e,label:i}):null,(0,s.jsx)("div",{ref:c,className:"h-6 w-full shrink-0"})]})})}function sq({message:e,surfaceTheme:t,architectMessageId:a,architectPlan:r}){let n="light"===t;if("assistant"===e.role&&r&&e.id===a)return(0,s.jsx)("div",{className:"mx-auto w-full max-w-3xl",children:(0,s.jsx)(sh,{surfaceTheme:t,plan:r,variant:"message",summaryText:e.text},`${e.id}:${r.updatedAt}`)});if("system"===e.role)return(0,s.jsxs)("div",{className:(0,S.cn)("mx-auto w-full max-w-2xl rounded-2xl border px-4 py-3 text-[13px] leading-6",n?"border-[#e3ddd4] bg-[#f5f0e8] text-[#5b544d]":"border-white/10 bg-white/[0.05] text-slate-300"),children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[11px] uppercase tracking-[0.18em]",n?"text-[#8b8074]":"text-slate-500"),children:e.author||"Workspace Wizard"}),(0,s.jsx)("p",{className:"mt-1",children:e.text})]});let i="user"===e.role,l="pending"===e.status;return(0,s.jsxs)("div",{className:(0,S.cn)("flex w-full items-start gap-2.5",i?"justify-end":"justify-start"),children:[i?null:(0,s.jsx)("div",{className:(0,S.cn)("mt-0.5 inline-flex size-8 shrink-0 items-center justify-center rounded-full border",n?"border-[#e6dfd4] bg-white text-[#5f5a53]":"border-white/10 bg-white/[0.05] text-slate-300"),children:"Architect"===e.author?(0,s.jsx)(t7.A,{className:"h-3.5 w-3.5"}):(0,s.jsx)(eI.A,{className:"h-3.5 w-3.5"})}),(0,s.jsxs)("div",{className:(0,S.cn)("max-w-[min(100%,680px)]",i?n?"rounded-2xl border border-[#ddd6cb] bg-[#1a1715] px-3 py-2 text-white":"rounded-2xl border border-cyan-200/40 bg-cyan-300 px-3 py-2 text-slate-950":"space-y-1 px-0 py-0",l&&"opacity-75"),children:[!i&&e.author?(0,s.jsx)("p",{className:(0,S.cn)("text-[10px] uppercase tracking-[0.2em]",n?"text-[#8f857a]":"text-slate-500"),children:e.author}):null,(0,s.jsx)("p",{className:(0,S.cn)("whitespace-pre-wrap text-[14px] leading-7",i&&"leading-6"),children:e.text})]})]})}function sK({surfaceTheme:e,label:t}){let a="light"===e;return(0,s.jsxs)("div",{className:"flex w-full items-start gap-2.5",children:[(0,s.jsx)("div",{className:(0,S.cn)("mt-0.5 inline-flex size-8 shrink-0 items-center justify-center rounded-full border",a?"border-[#e6dfd4] bg-white text-[#5f5a53]":"border-white/10 bg-white/[0.05] text-slate-300"),children:(0,s.jsx)(t7.A,{className:"h-3.5 w-3.5"})}),(0,s.jsxs)("div",{className:"max-w-[min(100%,680px)]",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[10px] uppercase tracking-[0.2em]",a?"text-[#8f857a]":"text-slate-500"),children:"Architect"}),(0,s.jsxs)("div",{className:"mt-1 flex items-center gap-2.5",children:[(0,s.jsxs)("div",{className:(0,S.cn)("inline-flex items-center gap-1.5 rounded-full border px-3 py-1.5",a?"border-[#e6dfd5] bg-white text-[#5a534c]":"border-white/10 bg-white/[0.05] text-slate-300"),children:[(0,s.jsx)("span",{className:(0,S.cn)("inline-flex size-1.5 animate-pulse rounded-full",a?"bg-[#5a534c]":"bg-slate-300")}),(0,s.jsx)("span",{className:(0,S.cn)("inline-flex size-1.5 animate-pulse rounded-full [animation-delay:120ms]",a?"bg-[#5a534c]":"bg-slate-300")}),(0,s.jsx)("span",{className:(0,S.cn)("inline-flex size-1.5 animate-pulse rounded-full [animation-delay:240ms]",a?"bg-[#5a534c]":"bg-slate-300")})]}),(0,s.jsx)("p",{className:(0,S.cn)("text-[12px] leading-5",a?"text-[#6f685f]":"text-slate-400"),children:t})]})]})]})}async function sG(e,t){if(!e.body)throw Error("The server did not return a readable stream.");let a=e.body.getReader(),s=new TextDecoder,r="";for(;;){let{value:e,done:n}=await a.read();if(n)break;let i=(r+=s.decode(e,{stream:!0})).indexOf("\n");for(;i>=0;){let e=r.slice(0,i).trim();r=r.slice(i+1),e&&await t(JSON.parse(e)),i=r.indexOf("\n")}}let n=r.trim();n&&await t(JSON.parse(n))}let sV={founder:"Founder",product:"Product Lead",architect:"System Architect",ops:"Operations",growth:"Growth",reviewer:"Reviewer"},sJ={small:{label:"Small",agentCount:1,workflowCount:1,automationCount:0,externalChannelCount:0,confirmationLimit:1,suggestedReplyLimit:2},medium:{label:"Medium",agentCount:3,workflowCount:3,automationCount:1,externalChannelCount:0,confirmationLimit:2,suggestedReplyLimit:3},large:{label:"Large",agentCount:5,workflowCount:4,automationCount:2,externalChannelCount:1,confirmationLimit:3,suggestedReplyLimit:4}};function sH(e){return sJ[e]??sJ.medium}let sY={internal:{label:"Internal",requiresCredentials:!1,credentials:[]},slack:{label:"Slack",requiresCredentials:!0,credentials:[{key:"botToken",label:"Bot token",placeholder:"xoxb-...",secret:!0}]},telegram:{label:"Telegram",requiresCredentials:!0,credentials:[{key:"token",label:"Bot token",placeholder:"123456:ABC...",secret:!0}]},discord:{label:"Discord",requiresCredentials:!0,credentials:[{key:"token",label:"Bot token",placeholder:"Discord bot token",secret:!0}]},googlechat:{label:"Google Chat",requiresCredentials:!0,credentials:[{key:"webhookUrl",label:"Webhook URL",placeholder:"https://chat.googleapis.com/...",secret:!0}]}};function sQ(){return globalThis.crypto?.randomUUID?.()??`plan-${Date.now()}`}function sZ(e,t,a){return{id:sQ(),role:e,author:t,text:a,createdAt:new Date().toISOString()}}function sX(e){return{id:e.id?.trim()||sQ(),kind:e.kind,label:e.label.trim(),summary:e.summary.trim(),details:rc(e.details),status:e.status??"ready",createdAt:e.createdAt??new Date().toISOString(),confidence:"number"==typeof e.confidence?Math.max(0,Math.min(100,Math.round(e.confidence))):void 0,url:rd(e.url),error:rd(e.error)}}function s0(e){return{id:e.id?.trim()||sQ(),section:e.section,label:e.label.trim(),value:e.value.trim(),confidence:Math.max(0,Math.min(100,Math.round(e.confidence??72))),status:e.status??"inferred",rationale:ro(e.rationale??""),sourceLabels:rc(e.sourceLabels)}}function s1(e){let t=ru(e?.id||e?.name||"operator")||"operator",a=e?.role?.trim()||"Operator",s=e?.name?.trim()||rh(t);return{id:t,role:a,name:s,purpose:e?.purpose?.trim()||`${s} owns ${a.toLowerCase()} execution and handoffs.`,enabled:e?.enabled!==!1,isPrimary:!!e?.isPrimary,emoji:e?.emoji?.trim(),theme:e?.theme?.trim(),skillId:e?.skillId?.trim(),modelId:e?.modelId?.trim(),policy:e?.policy??(0,eg.g0)("worker"),heartbeat:e?.heartbeat??{enabled:!1},responsibilities:rc(e?.responsibilities),outputs:rc(e?.outputs),channelIds:rc(e?.channelIds)}}function s2(e){return{id:ru(e?.id||e?.name||`workflow-${Date.now()}`)||`workflow-${Date.now()}`,name:e?.name?.trim()||"New workflow",goal:e?.goal?.trim()||"",trigger:e?.trigger??"manual",ownerAgentId:e?.ownerAgentId?.trim(),collaboratorAgentIds:rc(e?.collaboratorAgentIds),successDefinition:e?.successDefinition?.trim()||"",outputs:rc(e?.outputs),channelIds:rc(e?.channelIds),enabled:e?.enabled!==!1}}function s5(e="internal",t){let a=sY[e];return{id:ru(t?.id||t?.name||`${e}-${Date.now()}`)||`${e}-${Date.now()}`,type:e,name:t?.name?.trim()||a.label,purpose:t?.purpose?.trim()||"",target:t?.target?.trim(),enabled:t?.enabled!==!1,announce:!!t?.announce,requiresCredentials:a.requiresCredentials,accountId:t?.accountId?.trim(),primaryAgentId:t?.primaryAgentId?.trim()??null,allowedChatIds:rc(t?.allowedChatIds),groupAssignments:Array.isArray(t?.groupAssignments)?t.groupAssignments.map(e=>({chatId:"string"==typeof e.chatId?e.chatId.trim():"",agentId:"string"==typeof e.agentId?e.agentId.trim():null,title:"string"==typeof e.title?e.title.trim():null,enabled:!1!==e.enabled})).filter(e=>!!e.chatId):[],credentials:t?.credentials?.map(e=>({...e,value:e.value??""}))??a.credentials.map(e=>({...e,value:""}))}}function s3(e){return{id:ru(e?.id||e?.name||`automation-${Date.now()}`)||`automation-${Date.now()}`,name:e?.name?.trim()||"New automation",description:e?.description?.trim()||"",enabled:e?.enabled!==!1,scheduleKind:e?.scheduleKind??"every",scheduleValue:e?.scheduleValue?.trim()||"24h",agentId:e?.agentId?.trim(),mission:e?.mission?.trim()||"",thinking:e?.thinking??"medium",announce:!!e?.announce,channelId:e?.channelId?.trim()}}function s4(e,t){return(function(e,t,a){let s=aW[e];if("solo"===t){let e=s.find(e=>e.isPrimary)??s[0];return[{...e,name:aB(a,e.role,"Builder"===e.role?"Default Agent":e.name),policy:(0,eg.g0)("browser"===e.id?"browser":"worker"),enabled:!0}]}return s.map(e=>({id:e.id,role:e.role,name:e.isPrimary?aB(a,e.role,e.name):e.name,emoji:e.emoji,theme:e.theme,skillId:e.skillId,modelId:e.modelId,isPrimary:!!e.isPrimary,policy:(0,eg.g0)("browser"===e.id?"browser":"worker"),enabled:!0}))})(e,"core",t).map(t=>{var a,s,r,n,i,l,o;return s1({id:t.id,role:t.role,name:t.name,purpose:(a=t.id,s=t.role,r=e,/review/i.test(a)||/review/i.test(s)?`Pressure-test ${r} work for correctness, regression risk, and missing validation.`:/test/i.test(a)||/test/i.test(s)?`Validate behavior, environment assumptions, and release confidence for this ${r} workspace.`:/learn/i.test(a)||/learn/i.test(s)?"Keep the workspace memory, conventions, and durable decisions coherent over time.":/browser/i.test(a)||/browser/i.test(s)?"Exercise real UI flows and collect evidence for browser-facing work.":`Own hands-on delivery and keep the ${r} workspace moving.`),enabled:t.enabled,isPrimary:t.isPrimary,emoji:t.emoji,theme:t.theme,skillId:t.skillId,modelId:t.modelId,policy:t.policy??(0,eg.g0)("worker"),heartbeat:t.heartbeat??{enabled:!1},responsibilities:(n=t.id,i=e,/review/i.test(n)?["Review active work","Call out regressions","Protect launch quality"]:/test/i.test(n)?["Run verification loops","Capture evidence","Surface failing assumptions"]:/learn/i.test(n)?["Update durable memory","Track decisions","Reduce restart friction"]:/browser/i.test(n)?["Exercise flows","Capture screenshots","Validate responsive states"]:"content"===i?["Drive content production","Coordinate handoffs","Prepare launch artifacts"]:["Implement the next increment","Coordinate specialists","Keep execution momentum"]),outputs:(l=t.id,o=e,/review/i.test(l)?["review notes","risk checklist"]:/test/i.test(l)?["verification report","repro steps"]:/learn/i.test(l)?["memory updates","decision log entries"]:/browser/i.test(l)?["screenshots","browser validation notes"]:"research"===o?["research summary","evidence log"]:["implementation artifacts","handoff summary"])})})}function s8(e,t){let a=t.find(e=>e.enabled&&e.isPrimary)?.id,s=ri(t,"review"),r=ri(t,"test"),n=ri(t,"learn"),i=ri(t,"browser");if("research"===e)return[s2({id:"research-loop",name:"Research loop",goal:"Turn the main question into evidence-backed findings and explicit unknowns.",trigger:"manual",ownerAgentId:a,collaboratorAgentIds:[n,s].filter(Boolean),successDefinition:"Question, evidence, synthesis, and next-step recommendations are documented.",outputs:["docs/research-plan.md","deliverables/<run>/research-summary.md"]}),s2({id:"finding-review",name:"Finding review",goal:"Pressure-test claims before publishing or acting on them.",trigger:"manual",ownerAgentId:s??a,collaboratorAgentIds:[a].filter(Boolean),successDefinition:"Assumptions, risks, and evidence gaps are explicit.",outputs:["deliverables/<run>/review-notes.md"]})];if("content"===e)return[s2({id:"strategy",name:"Strategy and briefing",goal:"Clarify audience, offer, channels, and campaign bets before production.",trigger:"manual",ownerAgentId:a,collaboratorAgentIds:[s,n].filter(Boolean),successDefinition:"The team agrees on brief, priorities, and success signals.",outputs:["docs/content-brief.md","deliverables/<run>/campaign-brief.md"]}),s2({id:"production",name:"Production and QA",goal:"Create assets, review them, and prepare a launch package.",trigger:"manual",ownerAgentId:a,collaboratorAgentIds:[s].filter(Boolean),successDefinition:"Assets are approved and delivery-ready.",outputs:["deliverables/<run>/drafts/","deliverables/<run>/launch-package.md"]}),s2({id:"performance-loop",name:"Performance loop",goal:"Review outcomes, learn from results, and feed the next iteration.",trigger:"cron",ownerAgentId:n??s??a,collaboratorAgentIds:[a].filter(Boolean),successDefinition:"Measured results and next changes are documented.",outputs:["deliverables/<run>/performance-review.md"]})];let l=i&&"frontend"===e?i:a;return[s2({id:"scope-v1",name:"V1 shaping",goal:"Turn the product goal into a constrained first delivery batch.",trigger:"manual",ownerAgentId:a,collaboratorAgentIds:[n,s].filter(Boolean),successDefinition:"Scope, non-goals, and critical path are documented.",outputs:["docs/brief.md","memory/blueprint.md"]}),s2({id:"delivery",name:"Delivery loop",goal:"Implement, validate, and hand off the next meaningful increment.",trigger:"manual",ownerAgentId:l,collaboratorAgentIds:[r,s].filter(Boolean),successDefinition:"A tested increment ships with review notes and clear handoff.",outputs:["deliverables/<run>/release-notes.md","deliverables/<run>/verification.md"]}),s2({id:"launch-readiness",name:"Launch readiness",goal:"Check blockers, rollback posture, and communication before launch.",trigger:"launch",ownerAgentId:s??a,collaboratorAgentIds:[r,n].filter(Boolean),successDefinition:"Launch risks, open blockers, and go/no-go signal are explicit.",outputs:["deliverables/<run>/launch-checklist.md"]})]}function s6(){return[s5("internal",{id:"internal-ops",name:"Internal ops",purpose:"Default internal coordination surface for planner outputs and deploy notes.",announce:!1})]}function s9(e){var t,a,s,r,n,i,l,o,d,c,p,m,u,h,x,g,b,f,w,y,v,j,k,N,C,S,A,I;let T,M,O,R,$,E,D,_,P,L,U,F,z,W,B,q,K,G,V,J,H=rm(e),Y=H.intake.sources.some(e=>"workspace-edit-source"===e.id);if(H.runtime=(t=H.id,a=H.runtime,B=a?.architectSessionId?.trim()||`planner-${t}-architect`,q=Object.fromEntries(Object.entries(a?.advisorAgentIds??{}).filter(([,e])=>"string"==typeof e&&e.trim())),K=Object.fromEntries(Object.entries(sV).map(([e])=>[e,a?.advisorSessionIds?.[e]?.trim()||`planner-${t}-${e}`])),{mode:a?.mode==="fallback"?"fallback":"agent",status:a?.status==="error"?"error":a?.status==="ready"?"ready":"pending",workspaceId:rd(a?.workspaceId),workspacePath:rd(a?.workspacePath),architectAgentId:rd(a?.architectAgentId),architectSessionId:B,advisorAgentIds:q,advisorSessionIds:K,lastArchitectRunId:rd(a?.lastArchitectRunId),lastAdvisorRunIds:rc(a?.lastAdvisorRunIds),lastError:rd(a?.lastError)}),H.intake=(s={...H.intake,started:!!H.intake?.started||H.conversation.some(e=>"user"===e.role)},{started:!!s?.started,initialPrompt:ro(s?.initialPrompt??""),latestPrompt:ro(s?.latestPrompt??""),sources:(s?.sources??[]).map(e=>sX(e)),confirmations:rc(s?.confirmations).map(e=>e.trim()).filter(Boolean).slice(0,3),mode:s?.mode==="advanced"?"advanced":"guided",size:s?.size==="small"||s?.size==="large"?s.size:"medium",reviewRequested:!!s?.reviewRequested,turnCount:Math.max(0,Math.floor(s?.turnCount??0)),inferences:(s?.inferences??[]).map(e=>s0(e)),suggestedReplies:rc(s?.suggestedReplies).slice(0,4)}),H.company.name=ro(H.company.name),H.company.mission=ro(H.company.mission),H.company.targetCustomer=ro(H.company.targetCustomer),H.company.constraints=rc(H.company.constraints),H.company.successSignals=rc(H.company.successSignals),H.product.offer=ro(H.product.offer),H.product.scopeV1=rc(H.product.scopeV1),H.product.nonGoals=rc(H.product.nonGoals),H.product.revenueModel=ro(H.product.revenueModel),H.product.launchPriority=rc(H.product.launchPriority),H.workspace.name=ro(H.workspace.name),H.workspace.directory=rd(H.workspace.directory),H.workspace.repoUrl=rd(H.workspace.repoUrl),H.workspace.existingPath=rd(H.workspace.existingPath),H.workspace.stackDecisions=rc(H.workspace.stackDecisions),H.workspace.docs=rp(rc(H.workspace.docs).concat((i=H.workspace.template,aE(i,H.workspace.rules).map(e=>e.path)))),H.workspace.docOverrides=a$(H.workspace.docOverrides),H.team.persistentAgents=H.team.persistentAgents.map(e=>s1({...e,id:e.id,role:e.role,name:e.name,purpose:e.purpose,enabled:e.enabled,isPrimary:e.isPrimary,emoji:e.emoji,theme:e.theme,skillId:e.skillId,modelId:e.modelId,policy:e.policy,heartbeat:e.heartbeat,responsibilities:e.responsibilities,outputs:e.outputs})).filter((e,t,a)=>a.findIndex(t=>t.id===e.id)===t),Y){if(!H.team.persistentAgents.some(e=>e.enabled&&e.isPrimary)){let e=H.team.persistentAgents.find(e=>e.enabled);e&&(e.isPrimary=!0)}}else{let e,t;if(0===H.team.persistentAgents.length&&(H.team.persistentAgents=s4(H.workspace.template,H.workspace.name)),!H.team.persistentAgents.some(e=>e.enabled&&e.isPrimary)){let e=H.team.persistentAgents.find(e=>e.enabled);e&&(e.isPrimary=!0)}let a=H.team.persistentAgents.find(e=>e.enabled&&e.isPrimary);a&&H.workspace.name&&(l=a.name,o=a.role,e=l.trim().toLowerCase(),t=o.trim().toLowerCase(),!e||"default agent"===e||e===t||"primary agent"===e||"workspace agent"===e)&&(a.name=aB(H.workspace.name,a.role,a.name))}H.operations.channels=H.operations.channels.map(e=>s5(e.type,e)).filter((e,t,a)=>a.findIndex(t=>t.id===e.id)===t),Y||0!==H.operations.channels.length||(H.operations.channels=s6()),H.operations.workflows=H.operations.workflows.map(e=>s2(e)).filter((e,t,a)=>a.findIndex(t=>t.id===e.id)===t),Y||0!==H.operations.workflows.length||(H.operations.workflows=s8(H.workspace.template,H.team.persistentAgents)),H.operations.automations=H.operations.automations.map(e=>s3(e)).filter((e,t,a)=>a.findIndex(t=>t.id===e.id)===t),Y||(V=sH((G=rm(H)).intake.size),G.team.persistentAgents=function(e,t,a){var s;let r,n;if(a<=0)return[];return rl((n=(s=[...t,...s4(e),...(r=s1({id:"ops-lead",role:"Operations Lead",name:"Operations Lead",purpose:"Own automations, reporting cadence, and cross-agent handoffs for the workspace.",responsibilities:["Maintain the operating cadence","Wire recurring automations","Keep handoffs durable"],outputs:["ops brief","automation notes"]}),"research"===e?[s1({id:"analyst",role:"Analyst",name:"Analyst",purpose:"Turn gathered evidence into patterns, themes, and decision-ready summaries.",responsibilities:["Cluster findings","Spot repeated signals","Prepare concise summaries"],outputs:["insight summary","theme map"]}),r]:[r])]).find(e=>e.isPrimary)??s[0])?[n,...s.filter(e=>e.id!==n.id)]:s).slice(0,a).map((e,t)=>s1({...e,enabled:!0,isPrimary:e.isPrimary||0===t}))}(G.workspace.template,G.team.persistentAgents,V.agentCount),G.operations.channels=function(e,t,a){let s=t.find(e=>"internal"===e.type)??s6()[0],r=[...t.filter(e=>"internal"!==e.type),...("content"===e?["telegram","discord","slack"]:["slack","discord","telegram"]).map(t=>s5(t,{id:`${t}-ops`,purpose:"content"===e?"Optional distribution or community surface for a larger operating setup.":"Optional external operating surface for a larger workspace.",enabled:!1,announce:!0}))].filter((e,t,a)=>a.findIndex(t=>t.type===e.type)===t);return[s5("internal",{...s,enabled:!0}),...r.slice(0,a)]}(G.workspace.template,G.operations.channels,V.externalChannelCount),G.operations.workflows=function(e,t,a,s){let r,n,i,l;return s<=0?[]:rl([...t,...s8(e,a),...(r=a.find(e=>e.enabled&&e.isPrimary)?.id,n=ri(a,"review"),i=ri(a,"learn"),l=ri(a,"ops"),[s2({id:"context-sync",name:"research"===e?"Evidence sync":"Context sync",goal:"Pull new context from linked sources and keep the blueprint aligned with reality.",trigger:"manual",ownerAgentId:i??r,collaboratorAgentIds:[r,n].filter(Boolean),successDefinition:"New context is reflected in durable docs, scope, and decision notes.",outputs:["memory/blueprint.md","deliverables/<run>/context-sync.md"]}),s2({id:"ops-rhythm",name:"Operating rhythm",goal:"Review handoffs, automations, and next-step ownership on a repeatable cadence.",trigger:"cron",ownerAgentId:l??n??i??r,collaboratorAgentIds:[r].filter(Boolean),successDefinition:"The workspace has a fresh operator brief and an explicit next batch of work.",outputs:["deliverables/<run>/ops-rhythm.md"]})])]).slice(0,s).map(e=>{var t,s;let r,n,i,l,o;return t=e,r=new Set((s=a).filter(e=>e.enabled).map(e=>e.id)),n=s.find(e=>e.enabled&&e.isPrimary)?.id,i=ri(s,"review"),l=ri(s,"learn"),o=t.ownerAgentId&&r.has(t.ownerAgentId)?t.ownerAgentId:i??l??n,s2({...t,ownerAgentId:o,collaboratorAgentIds:t.collaboratorAgentIds.filter(e=>r.has(e)&&e!==o),enabled:!0})})}(G.workspace.template,G.operations.workflows,G.team.persistentAgents,V.workflowCount),G.operations.automations=function(e,t,a,s,r){let n,i,l;return r<=0?[]:rl([...t,...(n=ri(a,"review")??a.find(e=>e.enabled)?.id,i=ri(a,"learn")??n,[s3({id:"daily-triage",name:"Daily triage",description:"Review drift, blockers, and next handoffs every day.",scheduleKind:"every",scheduleValue:"24h",agentId:n,mission:"content"===e?"Review active campaigns, blockers, and next content handoffs. Leave a concise operator brief.":"Inspect the workspace, surface blockers, and leave a concise next-step handoff for the team.",thinking:"medium",channelId:l=s[0]?.id}),s3({id:"weekly-review",name:"Weekly review",description:"Capture progress, decisions, and next bets once per week.",scheduleKind:"every",scheduleValue:"168h",agentId:i,mission:"research"===e?"Summarize evidence gathered this week, open questions, and the next investigation batch.":"Summarize progress, major decisions, and the next delivery batch for this workspace.",thinking:"high",channelId:l})].filter(e=>e.agentId))]).slice(0,r).map(e=>{var t,r,n;let i,l,o,d,c;return t=e,r=a,n=s,i=new Set(r.filter(e=>e.enabled).map(e=>e.id)),l=new Set(n.map(e=>e.id)),o=r.find(e=>e.enabled&&e.isPrimary)?.id,d=ri(r,"review"),c=ri(r,"learn"),s3({...t,agentId:t.agentId&&i.has(t.agentId)?t.agentId:d??c??o,channelId:t.channelId&&l.has(t.channelId)?t.channelId:n[0]?.id,enabled:!0})})}(G.workspace.template,G.operations.automations,G.team.persistentAgents,G.operations.channels,V.automationCount),H=G),H.operations.hooks=H.operations.hooks.map(e=>({id:ru(e?.id||e?.name||`hook-${Date.now()}`)||`hook-${Date.now()}`,name:e?.name?.trim()||"New hook",source:e?.source?.trim()||"",enabled:e?.enabled!==!1,notes:e?.notes?.trim()||""})).filter((e,t,a)=>a.findIndex(t=>t.id===e.id)===t),H.operations.sandbox=(r=H.operations.sandbox,{workspaceOnly:r?.workspaceOnly??!0,mode:r?.mode??"default",notes:rc(r?.notes)}),Y||(H.deploy.firstMissions=(J=(n=H).team.persistentAgents.find(e=>e.enabled&&e.isPrimary),rp([J?"Inspect the new workspace, refine docs to match the blueprint, and break the first delivery batch into concrete tasks.":"",n.team.persistentAgents.find(e=>/review/i.test(e.role)&&e.enabled)?"Review the blueprint against the created workspace, call out execution risks, and leave a launch-readiness checklist.":"",n.team.persistentAgents.find(e=>/learn/i.test(e.role)&&e.enabled)?"Capture durable facts, decisions, and conventions in memory files so the team can continue without drift.":""].filter(Boolean))));let Q=rr(H.company.name),Z=rr(H.workspace.name);if((!H.company.name||Q)&&H.workspace.name&&!Z&&(H.company.name=H.workspace.name),(!H.workspace.name||Z)&&H.company.name&&!Q&&(H.workspace.name=H.company.name),!H.intake.started)return H.deploy.blockers=[],H.deploy.warnings=[],H.intake.confirmations=[],H.intake.inferences=[],H.intake.suggestedReplies=[],H.readinessScore=0,H.architectSummary="Start with one prompt. Paste the project goal, website URL, repo, or existing folder and the architect will draft the workspace for you.",H.stage="intake",H.status="draft",H.updatedAt=new Date().toISOString(),H;let X=function(e){let t=[],a=sH(e.intake.size);for(let a of e.intake.sources.filter(e=>"error"===e.status))t.push("tr"===re(e)?`${a.label} kaynağını inceleyemedim. Bu kaynak \xf6nemliyse şirket bağlamını manuel olarak doğrula.`:`I could not inspect ${a.label}. Confirm the company context manually if this source matters.`);return rp(t).slice(0,a.confirmationLimit)}(H),ee=function(e){let t=[];for(let a of(e.company.name||t.push("Company or workspace name is missing."),e.company.mission||t.push("Mission is missing."),e.company.targetCustomer||t.push("Target customer is missing."),e.workspace.name||t.push("Workspace name is missing."),"clone"!==e.workspace.sourceMode||e.workspace.repoUrl||t.push("Clone mode needs a repository URL."),"existing"!==e.workspace.sourceMode||e.workspace.existingPath||t.push("Existing-folder mode needs a folder path."),e.team.persistentAgents.some(e=>e.enabled)||t.push("At least one persistent agent must be enabled."),e.team.persistentAgents.some(e=>e.enabled&&e.isPrimary)||t.push("One enabled agent must be marked as primary."),e.operations.workflows.some(e=>e.enabled)||t.push("At least one enabled workflow is required."),e.operations.workflows.filter(e=>e.enabled)))a.name&&a.goal&&a.successDefinition||t.push(`Workflow "${a.name||a.id}" is incomplete.`),a.ownerAgentId&&!e.team.persistentAgents.some(e=>e.id===a.ownerAgentId&&e.enabled)&&t.push(`Workflow "${a.name}" points to a missing or disabled owner agent.`);for(let a of e.operations.automations.filter(e=>e.enabled))a.mission&&a.scheduleValue||t.push(`Automation "${a.name}" is incomplete.`),a.agentId&&!e.team.persistentAgents.some(e=>e.id===a.agentId&&e.enabled)&&t.push(`Automation "${a.name}" points to a missing or disabled agent.`);for(let a of e.operations.channels.filter(e=>e.enabled&&e.requiresCredentials))a.credentials.filter(e=>!e.value.trim()).length>0&&t.push(`Channel "${a.name}" is missing required credentials.`);return rp(t)}(H),et=(T=[],M=sH((d=H).intake.size),0===d.product.nonGoals.length&&T.push("No non-goals are defined for V1."),0===d.product.launchPriority.length&&T.push("Launch priorities are not ordered yet."),0===d.company.successSignals.length&&T.push("Success signals are still empty."),0===d.workspace.stackDecisions.length&&"content"!==d.workspace.template&&T.push("Critical stack decisions are not captured yet."),M.automationCount>0&&!d.operations.automations.some(e=>e.enabled)&&T.push("No automation loops are enabled."),M.externalChannelCount>0&&!d.operations.channels.some(e=>"internal"!==e.type)&&T.push("Only internal channels are configured."),M.agentCount>=3&&d.team.maxParallelRuns<2&&T.push("Parallel run limit is conservative for a multi-agent workspace."),rp(T)),ea=(c=H).intake.reviewRequested||"deploying"===c.status||"deployed"===c.status;return H.intake.confirmations=X,H.intake.inferences=(O=[],R=(p=H).intake.sources.filter(e=>"ready"===e.status).map(e=>e.label),$=p.intake.confirmations.join(" ").toLowerCase(),p.company.name&&O.push(s0({section:"company",label:"Company",value:p.company.name,confidence:ra(p,"company-name"),status:rs($,"company"),rationale:R.length>0?"Derived from linked context and the current brief.":"Derived from the current brief.",sourceLabels:R})),p.company.mission&&O.push(s0({section:"company",label:"Mission",value:p.company.mission,confidence:ra(p,"mission"),status:rs($,"outcome"),rationale:"Architect condensed the first business outcome from the request.",sourceLabels:R})),p.company.targetCustomer&&O.push(s0({section:"company",label:"First audience",value:p.company.targetCustomer,confidence:ra(p,"target-customer"),status:rs($,"audience"),rationale:"This is the current best guess for the first user or buyer segment.",sourceLabels:R})),O.push(s0({section:"workspace",label:"Workspace type",value:rh(p.workspace.template),confidence:ra(p,"template"),status:"inferred",rationale:"Template is inferred from the requested operating model and linked context.",sourceLabels:R})),O.push(s0({section:"workspace",label:"Starting point",value:"clone"===p.workspace.sourceMode?p.workspace.repoUrl||"Clone an existing repository":"existing"===p.workspace.sourceMode?p.workspace.existingPath||"Attach an existing folder":"Start from scratch",confidence:ra(p,"source-mode"),status:rs($,"start"),rationale:"This is how the workspace will be materialized when you deploy.",sourceLabels:R})),p.product.offer&&O.push(s0({section:"product",label:"Offer",value:p.product.offer,confidence:ra(p,"offer"),status:"inferred",rationale:"Architect turned the brief into a concrete operator-facing offer.",sourceLabels:R})),(E=p.operations.channels.filter(e=>e.enabled&&"internal"!==e.type)).length>0&&O.push(s0({section:"operations",label:"External channels",value:E.map(e=>e.name).join(", "),confidence:ra(p,"channels"),status:"inferred",rationale:"The request implies these operating channels should exist after deploy.",sourceLabels:R})),(D=p.team.persistentAgents.find(e=>e.enabled&&e.isPrimary))&&O.push(s0({section:"team",label:"Primary operator",value:`${D.name} (${D.role})`,confidence:ra(p,"team"),status:"inferred",rationale:"Architect drafted a primary agent to own the first delivery loop.",sourceLabels:R})),(_=p.operations.workflows.find(e=>e.enabled))&&O.push(s0({section:"operations",label:"First workflow",value:_.name,confidence:ra(p,"workflow"),status:"inferred",rationale:"This is the first operational loop the company would run after deploy.",sourceLabels:R})),O.slice(0,8)),H.intake.suggestedReplies=(m=H,u=X,P=re(m),L=[],U=sH(m.intake.size),F=function(e){let t=e.intake.sources.filter(e=>"ready"===e.status).flatMap(e=>[e.label,e.summary,...e.details]).join(" ").toLowerCase();if(!t)return;let a=/\bweb3|onchain|crypto|blockchain|token\b/.test(t),s=/\bstartup|startups|founder|founders|business(?:es)?\b/.test(t),r=/\bcommunity|communities|member|members|holder|holders|nft|dao|governance\b/.test(t),n=/\bdeveloper|developers|builder|builders|engineer|engineers\b/.test(t),i=/\boperator|operators|moderator|moderators|admin|admins|ops\b/.test(t);return s&&r?a?"Web3 startups and token-led communities":"startups and their communities":s?a?"Web3 startups and founders":"startups and founders":r?a?"DAO, NFT, and Web3 communities":"community leads and members":n&&i?"developers and internal operators":n?"developers and technical teams":i?"internal operators and moderators":void 0}(m),z=s7(m),m.company.targetCustomer||(F&&L.push("tr"===P?`İlk hedef kitle ${rn(F)} gibi g\xf6r\xfcn\xfcyor.`:`The first audience looks like ${rn(F)}.`),"content"===m.workspace.template?(L.push("tr"===P?"İlk kullanıcılar topluluk y\xf6neticileri ve moderat\xf6rler.":"The first users are community managers and moderators."),L.push("tr"===P?"İlk kullanıcılar daha hızlı moderasyon ve onboarding isteyen Telegram \xfcyeleri.":"The first users are Telegram members who need faster moderation and onboarding.")):L.push("tr"===P?"İlk kullanıcılar bu iş akışını her g\xfcn y\xfcr\xfcten operat\xf6rler.":"The first users are the operators running this workflow every day.")),m.company.mission||L.push("tr"===P?"İlk hedef, hacmi en y\xfcksek manuel iş akışını otomatikleştirmek.":"The first outcome is automating the highest-volume manual workflow."),!m.product.scopeV1.length&&m.company.mission&&m.company.targetCustomer&&L.push("tr"===P?"V1, genişlemeden \xf6nce en dar ama faydalı d\xf6ng\xfcy\xfc u\xe7tan uca \xe7\xf6zmeli.":"V1 should handle the narrowest useful loop end to end before we expand."),m.workspace.repoUrl||m.workspace.existingPath||rt(m.intake.latestPrompt||m.intake.initialPrompt)||(L.push("tr"===P?"Şimdilik varsayılan bir başlangı\xe7la ilerleyelim; kaynak t\xfcr\xfcn\xfc daha sonra istediğin gibi revize edebiliriz.":"We can proceed with a default starting point and revise the source later if you want."),L.push("tr"===P?"Eğer bir repo ya da mevcut klas\xf6r istiyorsan sonraki mesajda sadece onu s\xf6ylemen yeterli.":"If you want a repo or existing folder, just say so in the next edit.")),0===m.company.successSignals.length&&m.intake.turnCount>=2&&L.push("tr"===P?"Başarı; daha az manuel iş, daha hızlı yanıt s\xfcreleri ve daha net bir operasyon ritmi demek.":"Success means less manual work, faster response times, and a clearer operating cadence."),0!==u.length||z||(L.push("tr"===P?"İstersen bu taslağı şimdi daha keskin hale getirebiliriz.":"If you want, we can tighten this draft right now."),L.push("tr"===P?"Gelişmiş edit\xf6r\xfc a\xe7.":"Open the advanced editor.")),rp(L).slice(0,U.suggestedReplyLimit)),H.deploy.blockers=ea?ee:[],H.deploy.warnings=ea?et:[],H.readinessScore=(h=H,x=ee,g=et,b=ea,W=14,h.company.name&&(W+=10),h.company.mission&&(W+=15),h.company.targetCustomer&&(W+=15),h.product.offer&&(W+=10),h.product.scopeV1.length>0&&(W+=10),h.workspace.name&&(W+=10),h.intake.sources.length>0&&(W+=6),h.team.persistentAgents.some(e=>e.enabled&&e.isPrimary)&&(W+=10),h.operations.workflows.some(e=>e.enabled)&&(W+=10),h.operations.automations.some(e=>e.enabled)&&(W+=5),b?(W-=12*x.length,W-=3*g.length):W-=4*Math.max(0,h.intake.confirmations.length-1),Math.max(0,Math.min(100,W))),H.architectSummary=function(e,t,a,s){let r=re(e),n=s7(e),i=e.intake.sources.find(e=>"website"===e.kind&&"ready"===e.status&&"number"==typeof e.confidence&&e.confidence<80&&!!e.label),l=e.team.persistentAgents.filter(e=>e.enabled).length,o=e.operations.workflows.filter(e=>e.enabled).length,d=e.operations.automations.filter(e=>e.enabled).length,c=e.intake.confirmations.length;if(!e.intake.started)return"tr"===r?"Tek mesajla başla.":"Start with one prompt.";if(!s&&n){let t=e.company.mission||e.product.offer||e.company.name||e.workspace.name,a="clone"===e.workspace.sourceMode?"tr"===r?"klon repo":"a cloned repo":"existing"===e.workspace.sourceMode?"tr"===r?"mevcut klas\xf6r":"an existing folder":"tr"===r?"sıfırdan":"scratch",s=!i||e.company.name||e.workspace.name?"":"tr"===r?`Site adı i\xe7in ${i.label} varsayımını kullandım.`:`I used ${i.label} as the site name.`;return"tr"===r?[s,t?`İlk taslak ${t} etrafında hazır.`:`İlk taslak ${a} başlangıcıyla hazır.`].filter(Boolean).join(" "):[s,t?`First pass ready around ${t}.`:`First pass ready from ${a}.`].filter(Boolean).join(" ")}return s?"tr"===r?[e.company.mission?`Odak: ${e.company.mission}.`:"Misyon kısa bir c\xfcmle istiyor.",e.company.targetCustomer?`Kitle: ${e.company.targetCustomer}.`:"Kitle a\xe7ık.",`${l} agent, ${o} g\xf6rev, ${d} automation.`,c>0?`${c} revizyon kaldı.`:t.length>0?`${t.length} blocker kaldı.`:a.length>0?`${a.length} warning var.`:"Deploy'a hazır."].join(" "):[e.company.mission?`Focus: ${e.company.mission}.`:"Mission still needs a short sentence.",e.company.targetCustomer?`Audience: ${e.company.targetCustomer}.`:"Audience open.",`${l} agents, ${o} workflows, ${d} automations.`,c>0?`${c} revision${1===c?"":"s"} left.`:t.length>0?`${t.length} blocker${1===t.length?"":"s"} remain.`:a.length>0?`${a.length} warning${1===a.length?"":"s"} remain.`:"Ready to deploy."].join(" "):"tr"===r?[e.company.mission?`Odak: ${e.company.mission}.`:e.company.name||e.workspace.name?`İlk \xe7ıktı: ${e.company.name||e.workspace.name}.`:"İlk \xe7ıktı netleşiyor.",e.company.targetCustomer?`Kitle: ${e.company.targetCustomer}.`:"Kitle a\xe7ık.",e.intake.sources.length>0?`${e.intake.sources.length} kaynak topladım.`:"URL, repo ya da kısa brief yeterli.",`${l} agent, ${o} g\xf6rev, ${d} automation.`,c>0?`${c} revizyon kaldı.`:"Revizyona hazır."].join(" "):[e.company.mission?`Focus: ${e.company.mission}.`:`First outcome: ${e.company.name||e.workspace.name||"this workspace"}.`,e.company.targetCustomer?`Audience: ${e.company.targetCustomer}.`:"Audience open.",e.intake.sources.length>0?`I have ${e.intake.sources.length} source${1===e.intake.sources.length?"":"s"}.`:"Add a URL, repo, or short brief.",`${l} agents, ${o} workflows, ${d} automations.`,c>0?`${c} revision${1===c?"":"s"} left.`:"Ready to revise."].join(" ")}(H,ee,et,ea),H.stage=(f=H,w=ee,y=et,v=X,j=ea,f.intake.started?!j&&s7(f)?f.intake.sources.length>0?"context-harvest":"intake":"deploying"===f.status?"deploying":"deployed"===f.status?"deployed":(k=f).company.mission||k.product.offer||k.workspace.name||k.intake.sources.length>0?((N=f).company.name||N.workspace.name)&&N.company.mission&&N.team.persistentAgents.some(e=>e.enabled)&&N.operations.workflows.some(e=>e.enabled)?j?w.length>0?"pressure-test":y.length>0||f.readinessScore<90?"decision-lock":"ready":v.length>0?"team-synthesis":"decision-lock":"team-synthesis":f.intake.turnCount>1?"context-harvest":"intake":"intake"),H.status=(C=H,S=ee,A=X,I=ea,C.intake.started?"deploying"===C.status||"deployed"===C.status?C.status:I?"blocked"===C.status&&S.length>0||S.length>0?"blocked":C.readinessScore>=90?"ready":"review":s7(C)||A.length>0?"draft":"review":"draft"),H.updatedAt=new Date().toISOString(),H}function s7(e){return e.intake.turnCount<=1&&!e.intake.reviewRequested}function re(e,t){for(let s of[t,...e.conversation.slice().reverse().filter(e=>"user"===e.role).map(e=>e.text),e.intake.latestPrompt,e.intake.initialPrompt]){var a;let e=!function(e){let t=e?.trim();if(!t)return!1;if(/[çğıöşüÇĞİÖŞÜ]/.test(t))return!0;let a=t.toLowerCase().match(/\b(ve|bir|bu|şu|için|ile|olarak|olan|mı|mi|mu|mü|ne|nasıl|hangi|neden|hedef|ilk|müşteri|kullanıcı|oluştur|gerekli|alanları|yardımcı)\b/g);return!!(a&&a.length>=2)}(a=s)?!function(e){let t=e?.trim();if(!t||/[çğıöşüÇĞİÖŞÜ]/.test(t))return!1;let a=t.toLowerCase().match(/\b(let'?s|the|and|for|with|from|this|that|what|how|why|when|where|who|should|could|would|need|want|start|build|create|launch|project|workspace|customer|user|team|goal|mission|review|deploy|product|website|repo|folder)\b/g);return!!(a&&a.length>=2)}(a)?null:"en":"tr";if(e)return e}return"en"}function rt(e){return/\b(from scratch|greenfield|empty workspace|clone|repo|existing folder|existing workspace|s[ıi]f[ıi]rdan|mevcut klas[oö]r|mevcut repo|bo[sş])\b/i.test(e)}function ra(e,t){let a=`${e.intake.initialPrompt} ${e.intake.latestPrompt}`.toLowerCase(),s=e.intake.sources.filter(e=>"ready"===e.status),r=66;return s.length>0&&(r+=8),e.intake.turnCount>1&&(r+=6),("template"===t&&/\b(telegram|discord|community|topluluk|grup|content|marketing|research|frontend|backend)\b/.test(a)||"source-mode"===t&&rt(a)||"channels"===t&&/\b(slack|telegram|discord|google chat)\b/.test(a))&&(r+=10),"company-name"===t&&s.some(e=>"website"===e.kind)&&(r+=6),"target-customer"!==t||e.company.targetCustomer||(r-=18),("workflow"===t||"team"===t)&&(r-=4),Math.max(52,Math.min(96,r))}function rs(e,t){return e.includes(t)?"needs-confirmation":"inferred"}function rr(e){let t=e.toLowerCase();return/\b(yapal[ıi]m|ekleyelim|başlatal[ıi]m|kural[ıi]m|olsun|diyelim|verelim|koyal[ıi]m|kurmak|kurulum|oluşturmak|oluşturma|başlatmak|başlama|yapmak|yapma|istiyorum|istiyoruz|istemek|want|build|create|make|start|launch|setup|set up)\b/.test(t)}function rn(e){return e?e.charAt(0).toLowerCase()+e.slice(1):e}function ri(e,t){return e.find(e=>RegExp(t,"i").test(`${e.id} ${e.role} ${e.name}`))?.id}function rl(e){return e.filter((e,t,a)=>a.findIndex(t=>t.id===e.id)===t)}function ro(e){return e.trim()}function rd(e){return e?.trim()||void 0}function rc(e){return rp((e??[]).flatMap(e=>e.split(/\r?\n|,/g).map(e=>e.trim()).filter(Boolean)).map(e=>e.trim()).filter(Boolean))}function rp(e){return Array.from(new Set(e.filter(Boolean)))}function rm(e){return structuredClone(e)}function ru(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function rh(e){return e.split(/[-_]/g).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1)).join(" ")}function rx(e){let t="clone"===e.sourceMode?{label:"Cloning repository",description:"The repository is being cloned before workspace files are added."}:"existing"===e.sourceMode?{label:"Attaching existing folder",description:"Mission Control is validating the existing directory and preparing it for bootstrap."}:{label:"Preparing workspace folder",description:"A fresh workspace directory is being created inside the configured workspace root."};return{title:"Provisioning workspace",description:"Mission Control is creating the workspace and reporting each real bootstrap step as it finishes.",steps:[{id:"validate",label:"Checking input and target path",description:"Workspace input, agent ids, and the destination directory are being validated."},{id:"source",label:t.label,description:t.description},{id:"scaffold",label:"Scaffolding workspace files",description:"Core docs, local state, starter memory, and shared workspace metadata are being written."},{id:"agents",label:1===e.agentCount?"Creating the first agent":"Creating workspace agents",description:1===e.agentCount?"The primary agent is being provisioned and linked to the workspace.":"Each enabled agent is being provisioned and linked to the workspace."},{id:"kickoff",label:e.kickoffMission?"Running kickoff mission":"Finalizing workspace",description:e.kickoffMission?"The primary agent is inspecting the new workspace and refining the initial setup.":"Workspace bootstrap is wrapping up without a kickoff mission."}]}}function rg(e){return{title:e.title,description:e.description,percent:0,steps:e.steps.map(e=>({...e,status:"pending",percent:0,activities:[]}))}}let rb=new Set(["a","an","and","autonomous","automate","automated","automation","build","create","for","from","in","launch","new","of","on","project","run","runs","set","setup","start","that","the","to","up","workspace","adı","agent","ajan","asistan","benim","bide","bir","birde","de","diye","ekleyelim","gibi","i\xe7in","olarak","olsun","proje","şahsi","verelim","yeni"]);function rf(){return{name:"",goal:"",source:""}}function rw(e){let t=e.trim();if(!t)return{kind:"empty",createSourceMode:"empty",label:"Fresh workspace",hint:"Mission Control will scaffold a new project folder."};if(rk(t))return{kind:"existing",createSourceMode:"existing",label:"Existing folder",hint:t,existingPath:t};if(rN(t))return{kind:"clone",createSourceMode:"clone",label:"Clone repository",hint:t,repoUrl:t};let a=rC(t);return a?rS(a)?{kind:"clone",createSourceMode:"clone",label:"Clone repository",hint:a,repoUrl:a}:{kind:"website",createSourceMode:"empty",label:"Fresh workspace + website",hint:a,websiteUrl:a}:{kind:"context",createSourceMode:"empty",label:"Fresh workspace + context",hint:"The pasted source will be attached to the brief.",contextText:t}}function ry(e){let t=e.toLowerCase();return/\b(telegram|discord|community|channel automation|campaign|content|marketing|growth|seo|newsletter)\b/.test(t)?"content":/\b(frontend|ui|website|landing page|design system|dashboard)\b/.test(t)?"frontend":/\b(backend|api|service|microservice|worker|cron|queue|sdk)\b/.test(t)?"backend":/\b(research|investigation|analysis|benchmark|thesis)\b/.test(t)?"research":"software"}function rv(e){return e.name.trim()||function(e,t){let a=function(e){let t=e.trim();if(!t)return;if(rN(t))return rA(t.split(":").at(-1)??"");let a=rC(t);return a?rS(a)?rA(new URL(a).pathname):function(e){try{let[t]=new URL(e).hostname.replace(/^www\./,"").split(".");if(!t)return;return t.split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}catch{return}}(a):rk(t)?rA(t):void 0}(e);if(a)return a;let s=function(e){let t=e.match(/["“]([^"”]+)["”]/)?.[1]?.trim();if(t)return t;for(let t of[/\b(?:adı|ismi|name)\s*(?:olarak|:|=)?\s*([\p{L}\p{N}][\p{L}\p{N}._-]{1,40}(?:\s+[\p{L}\p{N}][\p{L}\p{N}._-]{1,40}){0,2})(?=\s+(?:olsun|olacak|diyelim|verelim|koyalım|olarak|için)\b|[.!?,]|$)/iu,/\b([\p{L}\p{N}][\p{L}\p{N}._-]{1,40}(?:\s+[\p{L}\p{N}][\p{L}\p{N}._-]{1,40}){0,2})\s+diye\b/iu]){let a=(e.match(t)?.[1]??"").replace(/\b(yeni|bir|workspace|project|proje|ekleyelim|kuralım|başlatalım|oluşturalım)\b/giu," ").replace(/\b(diye|olarak|benim|bide|bir de)\b.*$/iu,"").replace(/\s+/g," ").trim();if(a)return a}}(t);if(s)return s;let r=t.toLowerCase().replace(/[^a-z0-9\s-]+/g," ").split(/\s+/).map(e=>e.trim()).filter(e=>e&&!rb.has(e)).slice(0,4);return 0===r.length?"":r.map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}(e.source,e.goal)||"New Workspace"}function rj(e){let t=e.workspace.repoUrl?.trim()||e.workspace.existingPath?.trim()||e.intake.sources.find(e=>"website"===e.kind)?.url||e.intake.sources.find(e=>"prompt"===e.kind)?.summary||"";return{name:e.workspace.name||"",goal:e.company.mission||e.product.offer||e.intake.latestPrompt||"",source:t}}function rk(e){return e.startsWith("/")||e.startsWith("./")||e.startsWith("../")}function rN(e){return/^git@[^:]+:[^/].+/.test(e)}function rC(e){if(e.includes("@"))return null;let t=e.replace(/[),.;!?]+$/g,""),a=/^https?:\/\//i.test(t)?t:`https://${t}`;try{let e=new URL(a);return e.hostname.includes(".")?e.toString():null}catch{return null}}function rS(e){try{let t=new URL(e),a=t.hostname.toLowerCase(),s=t.pathname.toLowerCase();return"github.com"===a||"gitlab.com"===a||"bitbucket.org"===a||s.endsWith(".git")}catch{return!1}}function rA(e){let t=e.replace(/\\/g,"/").replace(/\/+$/g,"").split("/").filter(Boolean).at(-1)?.replace(/\.git$/i,"");if(t)return t.split(/[-_]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}let rI="workspace-wizard-basic-source",rT="Imported quick setup assumptions:";function rM(e="standard"){return{...az,workspaceOnly:!0,generateStarterDocs:"fastest"!==e,generateMemory:"fastest"!==e,kickoffMission:"fastest"!==e}}function rO(e){return{...rM(),...e,workspaceOnly:!0}}function rR(e,t,a){let s=structuredClone(e),r=rw(t.source),n=rv(t),i=t.goal.trim();return s.intake.mode=s.intake.mode||"guided",s.intake.started=!!(i||t.source.trim()),i&&(s.intake.initialPrompt||(s.intake.initialPrompt=i),s.intake.latestPrompt=i,s.company.mission=i,s.product.offer.trim()||(s.product.offer=i)),s.workspace.name=n,s.workspace.sourceMode=r.createSourceMode,s.workspace.repoUrl=r.repoUrl,s.workspace.existingPath=r.existingPath,s.workspace.template=ry(`${i}
165
- ${t.source}`),s.workspace.modelProfile=s.workspace.modelProfile||"balanced",s.workspace.rules=rO(a??s.workspace.rules),s.intake.sources=s.intake.sources.filter(e=>e.id!==rI),"empty"!==r.kind&&s.intake.sources.unshift(sX({id:rI,kind:"clone"===r.kind?"repo":"existing"===r.kind?"folder":"website"===r.kind?"website":"prompt",label:r.label,summary:r.hint,details:[r.hint],url:r.repoUrl??r.websiteUrl})),s9(s)}function r$(e){return rO(e.workspace.rules)}let rE="mission-control-workspace-plan-id";function rD({open:e,onOpenChange:t,initialMode:a="basic",workspaceEditId:r=null,surfaceTheme:n,snapshot:l,onRefresh:o,onWorkspaceCreated:d,onWorkspaceUpdated:c}){let p=!!r,m=function({open:e,initialMode:t,workspaceEditId:a,onRefresh:s,onWorkspaceCreated:r,onWorkspaceUpdated:n}){let[i,l]=(0,g.useState)(t),[o,d]=(0,g.useState)(null),[c,p]=(0,g.useState)(null),[m,u]=(0,g.useState)(!1),[h,x]=(0,g.useState)(rf),[b,f]=(0,g.useState)(()=>rM("fastest")),[w,y]=(0,g.useState)(null),[v,j]=(0,g.useState)(!1),[k,N]=(0,g.useState)(!1),[C,S]=(0,g.useState)(!1),[A,I]=(0,g.useState)(!1),[T,M]=(0,g.useState)(!1),[O,R]=(0,g.useState)(!1),[$,E]=(0,g.useState)(!1),[D,_]=(0,g.useState)(!1),[,P]=(0,g.useState)(null),[L,U]=(0,g.useState)(null),[F,z]=(0,g.useState)(null),[W,B]=(0,g.useState)(0),[q,K]=(0,g.useState)(null),G=(0,g.useRef)(null),V=(0,g.useRef)(null),J=(0,g.useRef)(null),H=(0,g.useMemo)(()=>a?`${rE}:${a}`:rE,[a]),Y=(0,g.useMemo)(()=>rw(h.source),[h.source]),Q=(0,g.useMemo)(()=>{let e;return(e=rO(b)).generateStarterDocs||e.generateMemory||e.kickoffMission?e.generateStarterDocs&&e.generateMemory&&e.kickoffMission?"standard":"custom":"fastest"},[b]),Z=(0,g.useMemo)(()=>(function({initialTurn:e,step:t,active:a}){return a?e?t>=2?{title:"Still working",description:"The first turn is the slowest. The planner is usually inspecting links, extracting intent, and narrowing the plan."}:t>=1?{title:"Collecting context",description:"The architect is reading the prompt, extracting intent, and drafting the next clarifying question."}:{title:"Starting planner",description:"The architect is opening the planning session and preparing the first intent pass."}:t>=2?{title:"Still working",description:"The architect is waiting on the planner runtime. This can happen when linked context or advisor runs take longer."}:t>=1?{title:"Updating draft",description:"Refreshing context, specialist notes, and the current workspace plan."}:{title:"Architect thinking",description:"Applying your latest direction to the workspace draft."}:null})({initialTurn:!o?.intake.started,step:k?W:0,active:k||$||D}),[D,$,k,o?.intake.started,W]),X=(0,g.useCallback)(e=>(V.current=e,d(e),u(!!e),e)?(p(e.id),x(rj(e)),f(r$(e)),globalThis.localStorage?.setItem(H,e.id),e):(p(null),null),[H]);(0,g.useEffect)(()=>{if(!k)return void B(0);B(0);let e=globalThis.setTimeout(()=>B(1),1800),t=globalThis.setTimeout(()=>B(2),6200);return()=>{globalThis.clearTimeout(e),globalThis.clearTimeout(t)}},[k]);let ee=(0,g.useCallback)(e=>{if(!o)return null;let t=s9(e(structuredClone(o)));return X(t),t},[X,o]),et=(0,g.useCallback)(()=>globalThis.localStorage?.getItem(H)??null,[H]),ea=(0,g.useCallback)(()=>{globalThis.localStorage?.removeItem(H),u(!1)},[H]),es=(0,g.useCallback)(async({resumeStored:e})=>{if(a){let t=e?globalThis.localStorage?.getItem(H):null;if(t){let e=await fetch(`/api/planner/${t}`,{cache:"no-store"});if(e.ok)return(await e.json()).plan}let s=await fetch(`/api/workspaces/${a}/edit-draft`,{method:"POST"}),r=await s.json();if(!s.ok||!r.plan)throw Error(r.error||"Unable to create workspace edit draft.");return r.seed&&(J.current=r.seed,P(r.seed)),r.plan}let t=e?globalThis.localStorage?.getItem(H):null;if(t){let e=await fetch(`/api/planner/${t}`,{cache:"no-store"});if(e.ok)return(await e.json()).plan}let s=await fetch("/api/planner",{method:"POST"}),r=await s.json();if(!s.ok||!r.plan)throw Error(r.error||"Unable to create planner workspace.");return r.plan},[H,a]),er=(0,g.useCallback)(async({resumeStored:e,draftOverride:t})=>{if(o)return o;if(G.current)return G.current;let a=(async()=>{j(!0);try{let a=await es({resumeStored:e}),s=t??h,r=s.goal.trim()||s.source.trim()||s.name.trim()?rR(a,s,b):a;return X(r)}catch(e){return el.o.error("Workspace architect could not start.",{description:e instanceof Error?e.message:"Unknown planner error."}),null}finally{j(!1),G.current=null}})();return G.current=a,a},[h,b,X,o,es]),en=(0,g.useCallback)(async()=>{if(y(null),U(null),z(null),N(!1),S(!1),I(!1),M(!1),R(!1),E(!1),K(null),G.current=null,a){ea(),d(null),V.current=null,p(null),await er({resumeStored:!1,draftOverride:void 0})&&l("advanced");return}if("basic"===i){ea(),d(null),V.current=null,p(null),x(rf()),f(rM("fastest"));return}ea(),d(null),V.current=null,p(null);let e=rf();x(e),f(rM("fastest")),await er({resumeStored:!1,draftOverride:e})&&l("advanced")},[ea,er,i,a]),ei=(0,g.useCallback)(()=>{ea(),y(null)},[ea]),eo=(0,g.useCallback)(async e=>{let t=e??V.current;if(!t||!c)return!1;S(!0);try{let e=await fetch(`/api/planner/${c}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({plan:t})}),a=await e.json();if(!e.ok||!a.plan)throw Error(a.error||"Unable to save planner workspace.");return X(a.plan),el.o.success("Planner draft saved."),!0}catch(e){return el.o.error("Planner draft could not be saved.",{description:e instanceof Error?e.message:"Unknown planner save error."}),!1}finally{S(!1)}},[X,c]),ed=(0,g.useCallback)(async e=>{let t=e??V.current;if(!t||!c)return!1;I(!0);try{let e=await fetch(`/api/planner/${c}/simulate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plan:t})}),a=await e.json();if(!e.ok||!a.plan)throw Error(a.error||"Unable to simulate planner team.");return X(a.plan),el.o.success("Planner team simulated."),!0}catch(e){return el.o.error("Planner simulation failed.",{description:e instanceof Error?e.message:"Unknown planner simulation error."}),!1}finally{I(!1)}},[X,c]),ec=(0,g.useCallback)(()=>{ee(e=>(e.intake.mode="advanced",e.intake.reviewRequested=!0,e.advisorNotes=[],e.conversation.push(sZ("assistant","Workspace Architect","Deploy review is open now. I am surfacing the real blockers and warnings that matter before launch.")),e))},[ee]),ep=(0,g.useCallback)(async()=>{if(a)return null;let e=await er({resumeStored:!1,draftOverride:h})??V.current;if(!e)return null;let t=rR(e,h,b);X(t),R(!0),z(rg(rx({sourceMode:t.workspace.sourceMode,agentCount:1,kickoffMission:t.workspace.rules.kickoffMission??!0})));try{var n;let e=await fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...{name:t.workspace.name,brief:[(n=t).company.mission.trim()||n.product.offer.trim(),n.company.name.trim()?`Company: ${n.company.name.trim()}`:null,n.company.targetCustomer.trim()?`Audience: ${n.company.targetCustomer.trim()}`:null,n.product.offer.trim()?`Offer: ${n.product.offer.trim()}`:null,n.company.successSignals.length>0?`Success signals: ${n.company.successSignals.join(", ")}`:null,n.product.scopeV1.length>0?`Scope: ${n.product.scopeV1.join(", ")}`:null,...n.intake.sources.flatMap(e=>{if(e.id!==rI&&"website"!==e.kind)return[];if("repo"===e.kind&&e.url)return[`Bootstrap source: clone ${e.url}`];if("folder"===e.kind)return[`Bootstrap source: existing folder ${e.summary}`];if("website"===e.kind&&e.url){let t="number"==typeof e.confidence?` (${e.confidence}%)`:"";return[`Reference website${t}: ${e.url} - ${e.summary}`]}return"prompt"===e.kind?[`Additional context: ${e.summary}`]:[]})].filter(e=>!!e?.trim()).join("\n"),directory:t.workspace.directory,modelId:t.workspace.modelId,sourceMode:t.workspace.sourceMode,repoUrl:t.workspace.repoUrl,existingPath:t.workspace.existingPath,template:t.workspace.template,teamPreset:"solo",modelProfile:t.workspace.modelProfile||"balanced",docOverrides:t.workspace.docOverrides,rules:rO(t.workspace.rules),contextSources:t.intake.sources},stream:!0})});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||"OpenClaw could not create the workspace.")}let a=null,i=null;if(await sG(e,async e=>{"progress"===e.type?z(e.progress):(e.progress&&z(e.progress),e.ok?a=e.result:i=e.error)}),i||!a)throw Error(i||"OpenClaw could not create the workspace.");let l=a;return ea(),await s(),r(l.workspaceId),el.o.success("Workspace created.",{description:`${l.agentIds.length} agent${1===l.agentIds.length?"":"s"} created at ${l.workspacePath}`}),l.kickoffError&&el.o.message("Workspace created, but kickoff needs attention.",{description:l.kickoffError}),l}catch(e){return el.o.error("Workspace creation failed.",{description:e instanceof Error?e.message:"Unknown workspace error."}),null}finally{R(!1)}},[h,b,ea,X,er,s,r,a]),em=(0,g.useCallback)(async()=>{let e=V.current,t=J.current;if(!e||!a)return null;_(!0);try{let r=await fetch("/api/workspaces",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceId:a,name:e.workspace.name,directory:e.workspace.directory,plan:e,baseline:t})}),i=await r.json();if(!r.ok||i.error)throw Error(i.error||"OpenClaw could not update the workspace.");return ea(),await s(),n?.(i.workspaceId??a),el.o.success("Workspace updated.",{description:i.workspacePath||e.workspace.directory||e.workspace.name}),i}catch(e){return el.o.error("Workspace update failed.",{description:e instanceof Error?e.message:"Unknown workspace error."}),null}finally{_(!1)}},[ea,s,n,a]),eu=(0,g.useCallback)(async()=>{var e;let t=V.current;if(!t||!c)return null;M(!0),U(rg({title:"Deploying workspace",description:"The planner is turning the blueprint into a live workspace and streaming each deploy stage.",steps:[{id:"plan",label:"Locking deploy plan",description:"Deploy blockers are being checked and the planner state is being locked for launch."},...rx({sourceMode:(e={sourceMode:t.workspace.sourceMode??"empty",agentCount:t.team.persistentAgents.filter(e=>e.enabled).length,kickoffMission:t.workspace.rules.kickoffMission??!0,hasChannels:!!t.operations.channels.some(e=>e.enabled&&"internal"!==e.type),hasAutomations:!!t.operations.automations.some(e=>e.enabled),hasPlannerKickoffs:!!t.deploy.firstMissions.some(e=>e.trim().length>0)}).sourceMode,agentCount:e.agentCount,kickoffMission:e.kickoffMission}).steps,{id:"blueprint",label:"Writing planner files",description:"Planner blueprint, company notes, and workflow docs are being written into the workspace."},{id:"channels",label:e.hasChannels?"Provisioning channels":"Checking channels",description:e.hasChannels?"Enabled external channels are being provisioned and connected.":"No external channels are enabled, so this stage will pass quickly."},{id:"automations",label:e.hasAutomations?"Provisioning automations":"Checking automation loops",description:e.hasAutomations?"Enabled recurring loops are being attached to their target agents.":"No recurring automations are enabled, so this stage is mostly validation."},{id:"planner-kickoff",label:e.hasPlannerKickoffs?"Running planner kickoff missions":"Finalizing deploy",description:e.hasPlannerKickoffs?"The first missions are being dispatched so the new workspace starts with clear momentum.":"The workspace is being finalized and the deploy request is wrapping up."}]}));try{let e=await fetch(`/api/planner/${c}/deploy`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plan:t,stream:!0})});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||"Unable to deploy planner workspace.")}let a=null,n=null;if(await sG(e,async e=>{"progress"===e.type?U(e.progress):(e.progress&&U(e.progress),e.ok?a=e.result:n=e.error)}),n||!a)throw Error(n||"Unable to deploy planner workspace.");let i=a;return X(i.plan),ea(),await s(),r(i.workspaceId),el.o.success("Workspace deployed.",{description:i.workspacePath}),i}catch(e){return el.o.error("Planner deploy failed.",{description:e instanceof Error?e.message:"Unknown deploy error."}),null}finally{M(!1)}},[ea,X,s,r,c]),eh=(0,g.useCallback)(async e=>{if(!e.trim())return!1;N(!0),K(e.trim());try{let a="advanced"===t&&!o&&!h.goal.trim()&&!h.source.trim()&&!h.name.trim(),s=await er({resumeStored:a,draftOverride:h})??o;if(!s)return!1;let r=await fetch(`/api/planner/${s.id}/turn`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:e,plan:s})}),n=await r.json();if(!r.ok||!n.plan)throw Error(n.error||"Unable to process planner turn.");return X(n.plan),y(null),!0}catch(e){return el.o.error("Planner turn failed.",{description:e instanceof Error?e.message:"Unknown planner turn error."}),!1}finally{K(null),N(!1)}},[h,X,er,t,o]),ex=(0,g.useCallback)(async({path:e,currentContent:t,instruction:a})=>{if(!o||!c)return null;let s=e.trim();if(!s)return null;E(!0);try{let e=await fetch(`/api/planner/${c}/document-rewrite`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plan:o,path:s,currentContent:t,instruction:a?.trim()||"Rewrite this document to improve clarity, usefulness, and consistency with the workspace context."})}),r=await e.json();if(!e.ok||!r.plan)throw Error(r.error||"Unable to rewrite the document.");X(r.plan),y(null);let n=aO({name:r.plan.workspace.name||"Workspace",brief:r.plan.company.mission||r.plan.product.offer||void 0,template:r.plan.workspace.template,sourceMode:r.plan.workspace.sourceMode,rules:r.plan.workspace.rules,agents:r.plan.team.persistentAgents.filter(e=>e.enabled),docOverrides:r.plan.workspace.docOverrides,toolExamples:[],contextSources:r.plan.intake.sources}).find(e=>e.path===s);return el.o.success(`Architect rewrote ${s}.`,{description:r.reply||"The document override has been updated."}),n?.content??null}catch(e){return el.o.error("Document rewrite failed.",{description:e instanceof Error?e.message:"Unknown document rewrite error."}),null}finally{E(!1)}},[X,o,c]),eg=(0,g.useCallback)(async()=>{let e=et();if(!e)return u(!1),!1;j(!0);try{let t=await fetch(`/api/planner/${e}`,{cache:"no-store"}),s=await t.json();if(!t.ok||!s.plan)throw Error(s.error||"Unable to load the stored planner draft.");return X(s.plan),l("advanced"),y({tone:"muted",title:a?"Resumed workspace edit":"Resumed previous draft",description:a?"Architect restored your earlier edit session so you can keep shaping the same workspace.":"Architect restored your earlier blueprint so you can keep shaping the same workspace."}),!0}catch(e){return el.o.error("Stored draft could not be resumed.",{description:e instanceof Error?e.message:"Unknown planner error."}),!1}finally{j(!1),G.current=null}},[X,et,a]),eb=(0,g.useCallback)(async e=>{if(e!==i){if(a){if("basic"===e)return;l("advanced");return}if("advanced"===e){let e=await er({resumeStored:!1,draftOverride:h});if(!e)return;let t=rR(e,h,b),a=!t.intake.started&&t.conversation.filter(e=>"system"!==e.role).length<=1?function(e,t){let a=structuredClone(e),s=t.goal.trim(),r=t.source.trim();if(a.conversation=a.conversation.filter(e=>!("system"===e.role&&"Workspace Wizard"===e.author&&e.text.startsWith(rT))),!s&&!r)return s9(a);let n=[s?`goal: ${s}`:null,r?`source: ${r}`:null,`fast-path name: ${rv(t)}`].filter(Boolean);return a.conversation.push(sZ("system","Workspace Wizard",`${rT} ${n.join(" \xb7 ")}`)),s9(a)}(t,h):t;X(a),y(a.intake.started||h.goal.trim()||h.source.trim()?{tone:"muted",title:"Same draft, deeper controls",description:"Architect will keep extending the exact same conversation and blueprint as you move into Advanced."}:null),l("advanced");return}if(o)x(rj(o)),f(r$(o)),y(o&&(o.team.persistentAgents.filter(e=>e.enabled).length>1||o.operations.workflows.some(e=>e.enabled)||o.operations.automations.some(e=>e.enabled)||o.operations.channels.some(e=>e.enabled&&"internal"!==e.type)||o.operations.hooks.some(e=>e.enabled))?{tone:"warning",title:"Advanced details preserved",description:"Basic mode will keep showing the fast path, but the richer blueprint remains in memory if you switch back."}:null);else y(null);l("basic")}},[h,b,X,er,i,o,a]),ef=(0,g.useCallback)(e=>{x(t=>{let a={...t,goal:e};return"basic"===i&&d(e=>{let t=e?rR(e,a,b):e;return V.current=t,t}),a})},[b,i]),ew=(0,g.useCallback)(e=>{x(t=>{let a={...t,source:e};return"basic"===i&&d(e=>{let t=e?rR(e,a,b):e;return V.current=t,t}),a})},[b,i]),ey=(0,g.useCallback)(e=>{x(t=>{let a={...t,name:e};return"basic"===i&&d(e=>{let t=e?rR(e,a,b):e;return V.current=t,t}),a})},[b,i]),ev=(0,g.useCallback)(e=>{let t=rM(e);f(t),d(e=>{let a=e?rR(e,h,t):e;return V.current=a,a})},[h]),ej=(0,g.useCallback)(e=>{f(t=>{let a={...t,[e]:!t[e],workspaceOnly:!0};return d(e=>{let t=e?rR(e,h,a):e;return V.current=t,t}),a})},[h]);return(0,g.useEffect)(()=>{if(!e){l(t),d(null),V.current=null,p(null),u(!1),x(rf()),f(rM("fastest")),y(null),z(null),U(null),E(!1),_(!1),K(null),P(null),J.current=null,G.current=null;return}let s=et();if(l(a?"advanced":t),u(!a&&!!s),x(rf()),f(rM("fastest")),y(null),z(null),U(null),E(!1),_(!1),K(null),P(null),J.current=null,G.current=null,!a&&"advanced"!==t){d(null),V.current=null,p(null);return}if(a||"advanced"===t){let e=(async()=>{j(!0);try{let e=await es({resumeStored:!a}),t=X(e);return!a&&s&&t&&y({tone:"muted",title:"Resumed previous draft",description:"Architect restored the last saved blueprint. Start a new draft if you want a clean slate."}),t}catch(e){return el.o.error("Workspace architect could not start.",{description:e instanceof Error?e.message:"Unknown planner error."}),null}finally{j(!1),G.current=null}})();G.current=e}else d(null),V.current=null,p(null)},[X,et,t,e,es,a]),{mode:i,plan:o,planId:c,hasStoredDraft:m,notice:w,sourceAnalysis:Y,basicDraft:h,basicRules:b,basicPreset:Q,isPlanLoading:v,isSending:k,isSaving:C,isSimulating:A,isDeploying:T,isCreating:O,isApplyingWorkspaceChanges:D,isDocumentRewriting:$,createProgress:F,deployProgress:L,architectBusyStatus:Z,pendingUserMessage:q,setBasicGoal:ef,setBasicSource:ew,setBasicName:ey,setBasicPreset:ev,toggleBasicRule:ej,setNotice:y,updatePlan:ee,switchMode:eb,startFreshDraft:en,discardStoredDraft:ei,resumeStoredDraft:eg,savePlan:eo,simulatePlan:ed,requestReview:ec,createWorkspace:ep,deployPlan:eu,applyWorkspaceChanges:em,submitArchitectTurn:eh,rewriteDocumentWithArchitect:ex}}({open:e,initialMode:a,workspaceEditId:r,onRefresh:o,onWorkspaceCreated:d,onWorkspaceUpdated:c}),[u,h]=(0,g.useState)(""),[x,b]=(0,g.useState)(!1),[f,w]=(0,g.useState)(!1),[y,v]=(0,g.useState)(!1),[j,k]=(0,g.useState)("workspace.name"),[N,C]=(0,g.useState)("AGENTS.md"),S="light"===n,A=p?l.workspaces.find(e=>e.id===r)??null:null,T=e=>{e||(h(""),b(!1),w(!1),v(!1),k("workspace.name"),C("AGENTS.md")),t(e)},M=p?m.plan?.workspace.name??A?.name??rv(m.basicDraft):rv(m.basicDraft),O=p?m.plan?.workspace.template??A?.bootstrap.template??ry(`${m.basicDraft.goal}
166
- ${m.basicDraft.source}`):ry(`${m.basicDraft.goal}
167
- ${m.basicDraft.source}`),R=p?m.plan?.workspace.directory??A?.path??l.diagnostics.workspaceRoot:function(e,t,a=rw(t.source)){if("existing"===a.kind&&a.existingPath)return a.existingPath;let s=rv(t).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return`${(0,eb.$7)(e)}/${s||"workspace"}`}(l.diagnostics.workspaceRoot,m.basicDraft,m.sourceAnalysis),$=(0,g.useMemo)(()=>{var e,t;let a;return e=m.mode,t=m.plan,a=[{id:"surface",label:p?"Editing workspace":"basic"===e?"Architect-assisted fast path":"Architect co-design",tone:"muted"}],t&&("basic"===e?t.intake.confirmations.length>0?a.push({id:"confirmations",label:`${t.intake.confirmations.length} decision${1===t.intake.confirmations.length?"":"s"} needed`,tone:t.intake.confirmations.length>1?"warning":"muted"}):t.intake.started&&a.push({id:"draft",label:"Draft synced live",tone:"muted"}):(t.intake.confirmations.length>0&&a.push({id:"confirmations",label:`${t.intake.confirmations.length} decision${1===t.intake.confirmations.length?"":"s"} needed`,tone:t.intake.confirmations.length>1?"warning":"muted"}),a.push({id:"stage",label:`Stage \xb7 ${so(t.stage)}`,tone:"muted"}),a.push({id:"readiness",label:`${t.readinessScore}% drafted`,tone:t.readinessScore>=85?"success":t.readinessScore>=45?"warning":"muted"}),a.push({id:"status",label:`Status \xb7 ${t.status}`,tone:"blocked"===t.status?"danger":"ready"===t.status||"deployed"===t.status?"success":"review"===t.status?"warning":"muted"}))),a},[p,m.mode,m.plan]),E=(0,g.useMemo)(()=>{var e,t;let a;return e=m.plan,t=m.pendingUserMessage,a=e?.conversation.map(e=>({id:e.id,role:e.role,author:"assistant"===e.role?"Architect":"system"===e.role?"Workspace Wizard":e.author,text:e.text}))??[],t?.trim()&&a.push({id:"pending-user-message",role:"user",text:t.trim(),status:"pending"}),a},[m.pendingUserMessage,m.plan]),D=(0,g.useMemo)(()=>{for(let e=E.length-1;e>=0;e-=1){let t=E[e];if("assistant"===t.role&&"Architect"===t.author)return t.id}return null},[E]),_=m.isCreating?m.createProgress:m.isDeploying?m.deployProgress:null,P=m.isSending||m.isPlanLoading||m.isDeploying||m.isCreating||m.isDocumentRewriting||m.isApplyingWorkspaceChanges,L="basic"===m.mode&&m.hasStoredDraft&&!m.plan&&!m.isPlanLoading,U=p?!!(m.plan||u.trim()):!!(m.plan?.intake.started||m.basicDraft.goal.trim()||u.trim()),F=!!(m.plan?.intake.started||m.basicDraft.name.trim()||m.basicDraft.goal.trim()||m.basicDraft.source.trim()||u.trim()),z=p||"basic"!==m.mode?null:(0,s.jsx)(rU,{surfaceTheme:n,name:m.basicDraft.name,source:m.basicDraft.source,onNameChange:m.setBasicName,onSourceChange:m.setBasicSource}),W=async e=>{let t=(e??u).trim();if(!t)return!1;let a=void 0===e;a&&h("");let s=await m.submitArchitectTurn(t);return!s&&a&&h(u),s},B=async()=>{if(p){if(!(!u.trim()||await W()))return;await m.applyWorkspaceChanges()&&T(!1);return}(!u.trim()||await W())&&await m.createWorkspace()&&T(!1)},q=async()=>{p||await m.deployPlan()&&T(!1)},K=async(e,t)=>{let a=t.trim()?{...e,conversation:[...e.conversation,sZ("system","Workspace Wizard",t)]}:e;return m.savePlan(a)},G=async(e,t)=>{let a=t.trim()?{...e,conversation:[...e.conversation,sZ("system","Workspace Wizard",t)]}:e;return m.savePlan(a)},V=(e="workspace.name")=>{k(e),b(!1),w(!0),v(!1)},J=e=>{C(e),b(!1),w(!1),v(!0)};return(0,s.jsx)(Y,{open:e,onOpenChange:T,children:(0,s.jsxs)(ee,{className:S?"h-[92vh] max-w-[min(1380px,96vw)] gap-0 overflow-hidden border-[#e7dfd4] bg-[#fcfaf6] p-0 text-[#161411] shadow-[0_40px_140px_rgba(16,12,8,0.45)]":"h-[92vh] max-w-[min(1380px,96vw)] gap-0 overflow-hidden border-white/10 bg-[rgba(4,8,15,0.96)] p-0 text-white shadow-[0_40px_140px_rgba(0,0,0,0.58)]",children:[(0,s.jsx)(es,{className:"sr-only",children:p?"Edit workspace":"Create workspace"}),(0,s.jsx)(er,{className:"sr-only",children:p?"Edit the existing workspace blueprint, documents, and agents using Architect.":"Create a workspace in Basic or Advanced mode using the Architect wizard."}),(0,s.jsxs)("div",{className:"relative flex h-full min-h-0 flex-col overflow-hidden",children:[(0,s.jsx)("div",{className:S?"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_top,rgba(255,255,255,0.86),transparent_34%),linear-gradient(180deg,rgba(248,244,237,0.92),rgba(252,250,246,0.86)_24%,rgba(244,238,230,0.82)_100%)]":"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_top,rgba(59,130,246,0.14),transparent_28%),radial-gradient(circle_at_80%_18%,rgba(56,189,248,0.12),transparent_24%),linear-gradient(180deg,rgba(9,15,27,0.98),rgba(4,8,15,0.96)_28%,rgba(2,6,13,0.98)_100%)]"}),(0,s.jsx)(sU,{surfaceTheme:n,mode:m.mode,onModeChange:e=>{m.switchMode(e)},onNewDraft:p?void 0:()=>{h(""),b(!1),w(!1),v(!1),m.startFreshDraft()},title:p?"Edit workspace":"Create workspace",showModeToggle:!p,showNewDraft:!p,badges:$}),(0,s.jsxs)("div",{className:"relative z-[1] grid min-h-0 flex-1 lg:grid-cols-[minmax(0,1fr),390px] xl:grid-cols-[minmax(0,1fr),420px]",children:[(0,s.jsxs)("div",{className:S?"flex min-h-0 flex-col bg-[linear-gradient(180deg,rgba(252,250,246,0.7),rgba(247,242,235,0.92))]":"flex min-h-0 flex-col bg-[linear-gradient(180deg,rgba(8,13,24,0.2),rgba(6,10,18,0.42))]",children:[(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[m.architectBusyStatus?(0,s.jsx)("div",{className:S?"border-b border-[#ece5db] px-4 py-2.5 md:px-5":"border-b border-white/10 px-4 py-2.5 md:px-5",children:(0,s.jsxs)("div",{className:S?"rounded-2xl border border-[#e6dfd5] bg-white px-3 py-2":"rounded-2xl border border-white/10 bg-white/[0.04] px-3 py-2",children:[(0,s.jsx)("p",{className:S?"text-[10px] uppercase tracking-[0.2em] text-[#8b7262]":"text-[10px] uppercase tracking-[0.2em] text-slate-500",children:m.architectBusyStatus.title}),(0,s.jsx)("p",{className:S?"mt-1 text-[12px] leading-5 text-[#6d665e]":"mt-1 text-[12px] leading-5 text-slate-300",children:m.architectBusyStatus.description})]})}):null,(0,s.jsx)("div",{className:"min-h-0 flex-1",children:(0,s.jsx)(sB,{surfaceTheme:n,messages:E,architectMessageId:D,architectPlan:m.plan,isTyping:m.isSending,typingLabel:"Architect is shaping the next pass...",emptyState:m.isPlanLoading&&0===E.length?(0,s.jsx)(rL,{surfaceTheme:n}):0===E.length&&"basic"===m.mode?(0,s.jsx)(r_,{surfaceTheme:n}):0===E.length?(0,s.jsx)(rP,{surfaceTheme:n}):null,auxiliary:(0,s.jsxs)(s.Fragment,{children:[L?(0,s.jsx)(rF,{surfaceTheme:n,isBusy:P,onResume:()=>{m.resumeStoredDraft()},onStartFresh:m.discardStoredDraft}):null,_?(0,s.jsx)("div",{className:"mx-auto w-full max-w-3xl",children:(0,s.jsx)(aN,{progress:_,className:S?"border-[#e6dfd5] bg-white":"border-white/10 bg-slate-950/50"})}):null]})})})]}),(0,s.jsx)("div",{className:S?"border-t border-[#ece5db] bg-[linear-gradient(180deg,rgba(252,250,246,0.7),rgba(247,242,235,0.92))] px-4 py-4 md:px-5":"border-t border-white/10 bg-[linear-gradient(180deg,rgba(5,9,18,0.68),rgba(4,8,15,0.94))] px-4 py-4 md:px-5",children:(0,s.jsx)("div",{className:"mx-auto w-full max-w-3xl",children:(0,s.jsx)(sW,{surfaceTheme:n,value:u,onChange:h,onSubmit:async()=>{await W()},placeholder:p?"Tell Architect what to change in this workspace...":"basic"===m.mode?"Describe what this workspace should do...":"Refine the blueprint with Architect...",disabled:P,isBusy:m.isSending,helperText:p?"Architect updates the existing workspace draft as you chat.":"basic"===m.mode?"Architect keeps the fast-path draft synced as you chat.":"Architect updates the shared blueprint on every turn.",toolbar:p?(0,s.jsx)("span",{className:S?"inline-flex items-center rounded-full border border-[#e3ddd4] bg-[#f6f1ea] px-3 py-1 text-[11px] uppercase tracking-[0.16em] text-[#6c645b]":"inline-flex items-center rounded-full border border-white/10 bg-white/[0.05] px-3 py-1 text-[11px] uppercase tracking-[0.16em] text-slate-300",children:"Editing draft"}):"basic"!==m.mode||m.plan?m.plan?(0,s.jsxs)("span",{className:S?"inline-flex items-center rounded-full border border-[#e3ddd4] bg-[#f6f1ea] px-3 py-1 text-[11px] uppercase tracking-[0.16em] text-[#6c645b]":"inline-flex items-center rounded-full border border-white/10 bg-white/[0.05] px-3 py-1 text-[11px] uppercase tracking-[0.16em] text-slate-300",children:["Stage \xb7 ",so(m.plan.stage)]}):null:(0,s.jsx)("span",{className:S?"inline-flex items-center rounded-full border border-[#e3ddd4] bg-[#f6f1ea] px-3 py-1 text-[11px] uppercase tracking-[0.16em] text-[#6c645b]":"inline-flex items-center rounded-full border border-white/10 bg-white/[0.05] px-3 py-1 text-[11px] uppercase tracking-[0.16em] text-slate-300",children:"Live draft"})})})})]}),(0,s.jsx)(sI,{className:"hidden lg:block",surfaceTheme:n,workspaceMode:p?"edit":"create",mode:m.mode,snapshot:l,basicQuickSetup:z,plan:m.plan,resolvedName:M,resolvedTemplate:O,sourceAnalysis:m.sourceAnalysis,workspacePath:R,notice:m.notice,basicRules:m.basicRules,basicPreset:m.basicPreset,onOpenBlueprintEditor:V,onOpenDocumentEditor:J,onBasicPresetChange:m.setBasicPreset,onBasicRuleToggle:m.toggleBasicRule,progress:p?null:"basic"===m.mode?m.createProgress:m.isDeploying?m.deployProgress:null})]}),x?(0,s.jsxs)("div",{className:S?"absolute inset-0 z-20 flex flex-col bg-[rgba(22,18,14,0.18)] backdrop-blur-sm lg:hidden":"absolute inset-0 z-20 flex flex-col bg-[rgba(2,6,13,0.56)] backdrop-blur-sm lg:hidden",children:[(0,s.jsxs)("div",{className:S?"flex items-center justify-between border-b border-[#e7dfd4] bg-[#fcfaf6] px-4 py-3":"flex items-center justify-between border-b border-white/10 bg-[rgba(4,8,15,0.96)] px-4 py-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:S?"text-[11px] uppercase tracking-[0.18em] text-[#9f958a]":"text-[11px] uppercase tracking-[0.18em] text-slate-500",children:"basic"===m.mode?"Workspace draft":"Workspace blueprint"}),(0,s.jsx)("p",{className:S?"text-[13px] text-[#6f675e]":"text-[13px] text-slate-300",children:"Review the structured side of the same wizard."})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[m.plan?(0,s.jsx)(I,{type:"button",variant:"secondary",size:"sm",onClick:()=>V(),className:S?"rounded-full border-[#ddd6cb] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",children:"Edit details"}):null,(0,s.jsx)("button",{type:"button",onClick:()=>b(!1),className:S?"inline-flex size-9 items-center justify-center rounded-full border border-[#e4ddd3] bg-white text-[#4f4943] transition-colors hover:bg-[#f4efe7]":"inline-flex size-9 items-center justify-center rounded-full border border-white/10 bg-white/[0.05] text-slate-200 transition-colors hover:bg-white/[0.08]",children:(0,s.jsx)(H.A,{className:"h-4 w-4"})})]})]}),(0,s.jsx)(sI,{className:"min-h-0 flex-1 border-t-0 lg:hidden",surfaceTheme:n,workspaceMode:p?"edit":"create",mode:m.mode,snapshot:l,basicQuickSetup:z,plan:m.plan,resolvedName:M,resolvedTemplate:O,sourceAnalysis:m.sourceAnalysis,workspacePath:R,notice:m.notice,basicRules:m.basicRules,basicPreset:m.basicPreset,onOpenBlueprintEditor:V,onOpenDocumentEditor:J,onBasicPresetChange:m.setBasicPreset,onBasicRuleToggle:m.toggleBasicRule,progress:p?null:"basic"===m.mode?m.createProgress:m.isDeploying?m.deployProgress:null})]}):null,f&&m.plan?(0,s.jsx)(aK,{open:f,surfaceTheme:n,plan:m.plan,busy:m.isSaving,focus:j,onClose:()=>w(!1),onSave:K},`${m.plan.id}:${j}`):null,y&&m.plan?(0,s.jsx)(a1,{open:y,surfaceTheme:n,plan:m.plan,path:N,busy:m.isSaving,rewriteBusy:m.isDocumentRewriting,onClose:()=>v(!1),onSave:G,onRewriteWithArchitect:m.rewriteDocumentWithArchitect},`${m.plan.id}:${N}`):null,(0,s.jsx)("div",{className:S?"relative z-[1] border-t border-[#e7dfd4] bg-white/90 px-4 py-3 backdrop-blur-sm md:px-5":"relative z-[1] border-t border-white/10 bg-[rgba(4,8,15,0.88)] px-4 py-3 backdrop-blur-sm md:px-5",children:(0,s.jsxs)("div",{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[(0,s.jsx)("p",{className:S?"text-[13px] text-[#776f65]":"text-[13px] text-slate-300",children:"basic"===m.mode?"Chat stays fast. Open the blueprint for details.":"Chat and blueprint stay synced as you refine the plan."}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsxs)(I,{variant:"secondary",size:"sm",className:S?"rounded-full border-[#dfd8ce] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3] lg:hidden":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08] lg:hidden",onClick:()=>b(!0),children:[(0,s.jsx)(ak.A,{className:"mr-2 h-4 w-4"}),"View blueprint"]}),p?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(I,{variant:"secondary",size:"sm",className:S?"rounded-full border-[#dfd8ce] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",onClick:()=>void m.savePlan(),disabled:!m.plan||m.isSaving||m.isPlanLoading,children:[m.isSaving?(0,s.jsx)(i.A,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save draft"]}),(0,s.jsxs)(I,{size:"sm",className:S?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",onClick:()=>void B(),disabled:!U||m.isPlanLoading||m.isSending||m.isSaving||m.isApplyingWorkspaceChanges,children:[m.isApplyingWorkspaceChanges?(0,s.jsx)(i.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,s.jsx)(eI.A,{className:"mr-2 h-4 w-4"}),"Apply changes"]})]}):"basic"===m.mode?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(I,{variant:"secondary",size:"sm",className:S?"rounded-full border-[#dfd8ce] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",onClick:()=>{m.switchMode("advanced")},disabled:m.isCreating||m.isSending||m.isPlanLoading,children:"Advanced details"}),(0,s.jsxs)(I,{size:"sm",className:S?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",onClick:()=>void B(),disabled:m.isCreating||m.isSending||m.isPlanLoading||!F,children:[m.isCreating?(0,s.jsx)(i.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,s.jsx)(eI.A,{className:"mr-2 h-4 w-4"}),"Create workspace"]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(I,{variant:"secondary",size:"sm",className:S?"rounded-full border-[#dfd8ce] bg-[#f7f2eb] text-[#403934] hover:bg-[#f1ebe3]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",onClick:()=>void m.savePlan(),disabled:!m.plan||m.isSaving||m.isPlanLoading,children:[m.isSaving?(0,s.jsx)(i.A,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Save draft"]}),m.plan?.intake.reviewRequested?(0,s.jsxs)(I,{size:"sm",className:S?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",onClick:()=>void q(),disabled:!m.plan||m.plan.deploy.blockers.length>0||m.isDeploying||m.isPlanLoading,children:[m.isDeploying?(0,s.jsx)(i.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,s.jsx)(t7.A,{className:"mr-2 h-4 w-4"}),"Deploy workspace"]}):(0,s.jsx)(I,{size:"sm",className:S?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",onClick:()=>m.requestReview(),disabled:!m.plan||m.isSending||m.isDeploying,children:"Review blueprint"})]})]})]})})]})]})})}function r_({surfaceTheme:e}){let t="light"===e;return(0,s.jsxs)("div",{className:"mx-auto mt-4 flex w-full max-w-2xl flex-col gap-3 px-4 md:mt-12 md:px-6",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[10px] uppercase tracking-[0.22em]",t?"text-[#8b7262]":"text-slate-500"),children:"Fast path"}),(0,s.jsx)("p",{className:t?"text-[24px] font-semibold tracking-[-0.03em] text-[#181612]":"text-[24px] font-semibold tracking-[-0.03em] text-white",children:"Start with one prompt."}),(0,s.jsx)("p",{className:t?"text-[15px] leading-7 text-[#7f756b]":"text-[15px] leading-7 text-slate-400",children:"Tell Architect what this workspace should do. It will reflect the intent back and ask the next critical question."})]})}function rP({surfaceTheme:e}){let t="light"===e;return(0,s.jsxs)("div",{className:"mx-auto mt-4 flex w-full max-w-2xl flex-col gap-3 px-4 md:mt-12 md:px-6",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[10px] uppercase tracking-[0.22em]",t?"text-[#8b7262]":"text-slate-500"),children:"Blueprint mode"}),(0,s.jsx)("p",{className:t?"text-[24px] font-semibold tracking-[-0.03em] text-[#181612]":"text-[24px] font-semibold tracking-[-0.03em] text-white",children:"Shape the workspace with Architect."}),(0,s.jsx)("p",{className:t?"text-[15px] leading-7 text-[#7f756b]":"text-[15px] leading-7 text-slate-400",children:"Describe the operating model, and the structured draft updates as you chat."})]})}function rL({surfaceTheme:e}){return(0,s.jsxs)("div",{className:"light"===e?"mx-auto mt-10 flex w-full max-w-2xl items-center gap-3 rounded-2xl border border-[#e6dfd5] bg-white px-4 py-3 text-[13px] text-[#6d665e]":"mx-auto mt-10 flex w-full max-w-2xl items-center gap-3 rounded-2xl border border-white/10 bg-white/[0.04] px-4 py-3 text-[13px] text-slate-300",children:[(0,s.jsx)(i.A,{className:"h-4 w-4 animate-spin"}),"Architect is opening the planning session and extracting intent from the latest brief."]})}function rU({surfaceTheme:e,name:t,source:a,onNameChange:r,onSourceChange:n}){let i="light"===e;return(0,s.jsx)("div",{className:i?"mx-auto w-full max-w-3xl rounded-2xl border border-[#e4ddd3] bg-white p-3.5 shadow-[0_18px_56px_rgba(56,47,38,0.06)]":"mx-auto w-full max-w-3xl rounded-2xl border border-white/10 bg-white/[0.04] p-3.5 shadow-[0_18px_56px_rgba(0,0,0,0.24)]",children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("span",{className:i?"inline-flex size-8 shrink-0 items-center justify-center rounded-full border border-[#e4ddd3] bg-[#faf6f1] text-[#5e5750]":"inline-flex size-8 shrink-0 items-center justify-center rounded-full border border-white/10 bg-white/[0.05] text-slate-300",children:(0,s.jsx)(eI.A,{className:"h-3.5 w-3.5"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:i?"text-[10px] uppercase tracking-[0.2em] text-[#8b7262]":"text-[10px] uppercase tracking-[0.2em] text-slate-500",children:"Quick details"}),(0,s.jsx)("p",{className:i?"mt-1 text-[12px] leading-5 text-[#70685f]":"mt-1 text-[12px] leading-5 text-slate-300",children:"Optional name and source live here. Architect can still infer both from the prompt."}),(0,s.jsxs)("div",{className:"mt-3 grid gap-2.5 md:grid-cols-2",children:[(0,s.jsx)(rz,{surfaceTheme:e,label:"Workspace name",children:(0,s.jsx)(T,{value:t,onChange:e=>r(e.target.value),placeholder:"Optional. Architect can infer it.",className:i?"border-[#e4ddd3] bg-[#fcfaf6] text-[#1c1916] placeholder:text-[#9b948c] focus-visible:ring-[#b8ada1]":"border-white/10 bg-[rgba(4,8,15,0.64)] text-slate-100 placeholder:text-slate-500 focus-visible:ring-cyan-300/60"})}),(0,s.jsx)(rz,{surfaceTheme:e,label:"Source",children:(0,s.jsx)(T,{value:a,onChange:e=>n(e.target.value),placeholder:"Repo URL, website URL, or existing folder path",className:i?"border-[#e4ddd3] bg-[#fcfaf6] text-[#1c1916] placeholder:text-[#9b948c] focus-visible:ring-[#b8ada1]":"border-white/10 bg-[rgba(4,8,15,0.64)] text-slate-100 placeholder:text-slate-500 focus-visible:ring-cyan-300/60"})})]})]})]})})}function rF({surfaceTheme:e,isBusy:t,onResume:a,onStartFresh:r}){let n="light"===e;return(0,s.jsx)("div",{className:n?"mx-auto w-full max-w-3xl rounded-[22px] border border-[#e4ddd3] bg-[#fffaf3] px-4 py-4 shadow-[0_18px_48px_rgba(56,47,38,0.05)]":"mx-auto w-full max-w-3xl rounded-[22px] border border-white/10 bg-white/[0.05] px-4 py-4",children:(0,s.jsxs)("div",{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:n?"text-[11px] uppercase tracking-[0.18em] text-[#8b7262]":"text-[11px] uppercase tracking-[0.18em] text-slate-500",children:"Previous draft found"}),(0,s.jsx)("p",{className:n?"mt-1 text-[14px] leading-6 text-[#30261d]":"mt-1 text-[14px] leading-6 text-white",children:"Architect still has an earlier workspace blueprint. Resume it or start fresh before creating a new one."})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(I,{variant:"secondary",size:"sm",className:n?"rounded-full border-[#dfd8ce] bg-white text-[#403934] hover:bg-[#f7f2eb]":"rounded-full border-white/10 bg-white/[0.04] text-slate-200 hover:bg-white/[0.08]",onClick:r,disabled:t,children:"Start fresh"}),(0,s.jsx)(I,{size:"sm",className:n?"rounded-full bg-[#161514] text-white hover:bg-[#26231f]":"rounded-full bg-cyan-300 text-slate-950 hover:bg-cyan-200",onClick:a,disabled:t,children:"Resume blueprint"})]})]})})}function rz({surfaceTheme:e,label:t,children:a}){return(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)("p",{className:"light"===e?"text-[11px] uppercase tracking-[0.16em] text-[#8d8276]":"text-[11px] uppercase tracking-[0.16em] text-slate-500",children:t}),a]})}let rW=(0,a(6611).default)(()=>Promise.all([a.e(5751),a.e(9708),a.e(1364),a.e(1506)]).then(a.bind(a,1506)).then(e=>e.MissionCanvas),{loadableGenerated:{webpack:()=>[1506]},ssr:!1,loading:()=>(0,s.jsx)("div",{className:"h-full w-full"})}),rB="mission-control-surface-theme",rq="mission-control-hidden-runtime-ids",rK="mission-control-hidden-task-keys",rG="mission-control-locked-task-keys";function rV({initialSnapshot:e}){var t,a,d,c,p,m,u;let{snapshot:h,connectionState:x,refresh:b,refreshSnapshot:f,setSnapshot:w}=function(e){let[t,a]=(0,g.useState)(e),[s,r]=(0,g.useState)("connecting");(0,g.useEffect)(()=>{let e=new EventSource("/api/stream");return e.addEventListener("snapshot",e=>{let t=JSON.parse(e.data);(0,g.startTransition)(()=>{a(t),r("live")})}),e.addEventListener("error",()=>{r("retrying")}),e.addEventListener("ready",()=>{r("live")}),e.onerror=()=>{r("retrying")},()=>{e.close()}},[]);let n=async()=>{let e=await fetch("/api/snapshot",{cache:"no-store"}),t=await e.json();return(0,g.startTransition)(()=>{a(t),r("live")}),t};return{snapshot:t,connectionState:s,refresh:async()=>{await n()},refreshSnapshot:n,setSnapshot:a}}(e),[y,v]=(0,g.useState)(e.workspaces[0]?.id??null),[j,k]=(0,g.useState)(e.workspaces[0]?.id??null),[N,C]=(0,g.useState)(null),[A,T]=(0,g.useState)(null),[M,O]=(0,g.useState)(null),[R,$]=(0,g.useState)(!1),[E,D]=(0,g.useState)(0),[_,P]=(0,g.useState)("overview"),[U,F]=(0,g.useState)(null),[z,W]=(0,g.useState)(null),[B,q]=(0,g.useState)([]),[K,G]=(0,g.useState)(null),[V,J]=(0,g.useState)([]),[H,Q]=(0,g.useState)([]),[Z,X]=(0,g.useState)([]),[en,ei]=(0,g.useState)(null),[eo,ec]=(0,g.useState)(null),[ep,em]=(0,g.useState)(null),[eu,eh]=(0,g.useState)("idle"),[ex,eg]=(0,g.useState)(null),ef=(0,g.useRef)(new Map),[ew,ey]=(0,g.useState)(!1),[ev,ej]=(0,g.useState)(!1),[ek,eN]=(0,g.useState)(!1),[eS,eA]=(0,g.useState)(!1),[eI,eT]=(0,g.useState)(null),[eM,eO]=(0,g.useState)("idle"),[eR,e$]=(0,g.useState)(null),[eE,eD]=(0,g.useState)(null),[e_,eP]=(0,g.useState)("idle"),[eL,eU]=(0,g.useState)(null),[eF,ez]=(0,g.useState)(null),[eW,eB]=(0,g.useState)(null),[eq,eK]=(0,g.useState)(""),[eG,eV]=(0,g.useState)(""),[eJ,eH]=(0,g.useState)(()=>r2(e)),[eY,eQ]=(0,g.useState)(()=>r5(e)),[eX,e0]=(0,g.useState)(!1),[e1,e2]=(0,g.useState)(!1),[e5,e3]=(0,g.useState)(!1),[e4,e8]=(0,g.useState)("idle"),[e6,e9]=(0,g.useState)(null),[e7,te]=(0,g.useState)(null),[tt,ta]=(0,g.useState)(""),[ts,tr]=(0,g.useState)("idle"),[tn,ti]=(0,g.useState)(null),[tl,to]=(0,g.useState)(null),[td,tc]=(0,g.useState)(null),[tp,tu]=(0,g.useState)(""),[th,tx]=(0,g.useState)(null),[tg,tb]=(0,g.useState)(null),[tf,tw]=(0,g.useState)("system"),[ty,tv]=(0,g.useState)(""),[tj,tk]=(0,g.useState)([]),[tN,tC]=(0,g.useState)("idle"),[tS,tA]=(0,g.useState)(null),[tI,tT]=(0,g.useState)(null),[tM,tO]=(0,g.useState)(null),[tR,t$]=(0,g.useState)(""),[tE,tD]=(0,g.useState)(null),[t_,tP]=(0,g.useState)(null),[tL,tU]=(0,g.useState)(!1),[tF,tq]=(0,g.useState)(!1),[tK,tG]=(0,g.useState)(!1),[tV,tJ]=(0,g.useState)(()=>tW(e)),[tH,tY]=(0,g.useState)(null),[tQ,tZ]=(0,g.useState)(null),[tX,t0]=(0,g.useState)("dark"),[t1,t2]=(0,g.useState)(!1),[t5,t4]=(0,g.useState)("basic"),[t8,t6]=(0,g.useState)(null),[t9,t7]=(0,g.useState)(!1),[ae,at]=(0,g.useState)(!1),[aa,as]=(0,g.useState)(null),[an,ai]=(0,g.useState)(null),al=(0,g.useMemo)(()=>(function(e,t){if(0===t.length)return e;let a=t.filter(t=>!t.dispatchId||!e.tasks.some(e=>e.dispatchId===t.dispatchId)).map(e=>e.task);return 0===a.length?e:{...e,tasks:[...a,...e.tasks]}})(h,B),[h,B]),ao=(0,g.useMemo)(()=>Array.isArray(V)?V:[],[V]),ad=(0,g.useMemo)(()=>Array.isArray(H)?H:[],[H]),ac=(0,g.useMemo)(()=>Array.isArray(Z)?Z:[],[Z]),ap=(0,g.useCallback)((e,t="overview",a=null)=>{k(e),P(t),C(a)},[]),am=(0,g.useRef)(null),au=(0,g.useRef)(!1),ah=(0,g.useRef)(!1),ax=(0,g.useRef)(null),ag=h.runtimes.filter(e=>{var t;return("running"===e.status||"queued"===e.status)&&("string"!=typeof(t=e).metadata.kind||"direct"!==t.metadata.kind)}).length,ab=tz(h),aw=tW(h),ay=[h.diagnostics.updatePackageManager,h.diagnostics.updateInstallKind].filter(Boolean).join(" \xb7 "),av="running"===e4,aj="success"===e4||"error"===e4,ak="running"===(t=e4)?"Updating OpenClaw":"success"===t?"Update complete":"error"===t?"Update failed":"Update OpenClaw",aN="running"===(a=e4)?"OpenClaw is being updated now. Local gateway activity may pause briefly while the CLI is replaced.":"success"===a?"The CLI update finished. Review the result below, then close this panel when you are done.":"error"===a?"The update did not complete cleanly. Review the result and captured output before trying again.":"This runs openclaw update against the installed CLI and may briefly interrupt local gateway activity.",aC=(d=h).diagnostics.installed?tz(d)?{label:"Enter Mission Control",description:"OpenClaw is online and runtime state is writable."}:d.diagnostics.rpcOk?{label:"Repair runtime access",description:"OpenClaw is online, but write access still needs verification."}:d.diagnostics.loaded?(!d.diagnostics.rpcOk,{label:"Start OpenClaw",description:"Start the local gateway and wait for RPC."}):{label:"Prepare local gateway",description:"Register and start the local gateway."}:{label:"Install OpenClaw",description:"Download the CLI and get Mission Control ready."},aS=ag>0||B.length>0,aA=!tL&&!aw&&!aS&&(!tV||"offline"===h.diagnostics.health),aI=al.tasks.filter(e=>!y||e.workspaceId===y).filter(e=>rX(e,ao,ad,ac)).length,aT=(0,g.useCallback)(e=>{let t=al.tasks.filter(t=>t.workspaceId===e).filter(e=>!ac.includes(e.key));if(0===t.length)return;let a=t.every(e=>rX(e,ao,ad,ac)),s=new Set(t.map(e=>e.key)),r=new Set(t.flatMap(e=>e.runtimeIds));if(a){Q(e=>e.filter(e=>!s.has(e))),J(e=>e.filter(e=>!r.has(e)));return}Q(e=>Array.from(new Set([...e,...s]))),J(e=>Array.from(new Set([...e,...r])))},[al.tasks,ao,ad,ac]),aM=(0,g.useCallback)(e=>{let t=al.agents.find(t=>t.id===e);t&&(T(t=>t===e?null:e),v(t.workspaceId),ap(e))},[ap,al.agents]),aO=(0,g.useCallback)((e,t)=>{let a=al.agents.find(t=>t.id===e);a&&(T(a.id),v(a.workspaceId),ej(!0),ap(a.id,"overview",t))},[ap,al.agents]),aR=(0,g.useCallback)((e,t)=>{let a=al.agents.find(t=>t.id===e);a&&(T(a.id),v(a.workspaceId),ap(a.id),ec({requestId:`capabilities:${e}:${t}:${Date.now()}`,agentId:e,focus:t}))},[ap,al.agents]),a$=(0,g.useCallback)(e=>{e||ec(null)},[]),aE=(0,g.useCallback)(e=>{if(!A)return;let t=al.agents.find(t=>t.id===e);t&&(A!==e||y!==t.workspaceId||j!==e)&&(T(e),v(t.workspaceId),ap(e))},[y,A,ap,j,al.agents]),aD=(0,g.useCallback)(()=>{au.current=!0},[]),a_=(0,g.useCallback)(e=>{if(e){ah.current=!1,$(!0);return}if(au.current){ah.current=!0;return}ah.current=!1,$(!1)},[]),aP=(0,g.useCallback)(()=>{T(null),ap(y??al.workspaces[0]?.id??null)},[y,ap,al.workspaces]);(0,g.useEffect)(()=>{let e=()=>{!au.current||(au.current=!1,ah.current&&(ah.current=!1,$(!1),D(e=>e+1)))};return window.addEventListener("pointerup",e),window.addEventListener("pointercancel",e),()=>{window.removeEventListener("pointerup",e),window.removeEventListener("pointercancel",e)}},[]);let aL=(0,g.useCallback)((e="basic")=>{t6(null),t4(e),t2(!0)},[]),aU=(0,g.useCallback)(e=>{t6(e),t4("advanced"),t2(!0)},[]),aF=(0,g.useCallback)(e=>{t2(e),e||(t6(null),t4("basic"))},[]),az=(0,g.useCallback)(()=>{t7(!0)},[]);(0,g.useEffect)(()=>{if(y){if(h.workspaces.some(e=>e.id===y)){an===y&&ai(null);return}an!==y&&v(h.workspaces[0]?.id??null)}},[h.workspaces,y,an]),(0,g.useEffect)(()=>{if(j){if(al.workspaces.some(e=>e.id===j)||al.agents.some(e=>e.id===j)||al.tasks.some(e=>e.id===j)||al.runtimes.some(e=>e.id===j)||al.models.some(e=>e.id===j)){an===j&&ai(null);return}an!==j&&ap(y||al.workspaces[0]?.id||null)}},[al,j,y,an,ap]),(0,g.useEffect)(()=>{let e=al.tasks.find(e=>e.id===j),t=e&&rX(e,ao,ad,ac);if(j){if(A&&!R){j!==A&&e?.primaryAgentId!==A&&ap(A);return}(ao.includes(j)||t)&&ap(y||al.workspaces[0]?.id||null)}},[j,A,R,ao,ad,ac,y,al.workspaces,al.tasks,ap]),(0,g.useEffect)(()=>{!A||al.agents.some(e=>e.id===A)||T(null)},[A,al.agents]),(0,g.useEffect)(()=>{let e=globalThis.localStorage?.getItem(rB),t=globalThis.localStorage?.getItem(rq),a=globalThis.localStorage?.getItem(rK),s=globalThis.localStorage?.getItem(rG);if(("dark"===e||"light"===e)&&t0(e),t)try{let e=JSON.parse(t);Array.isArray(e)&&J(e.filter(e=>"string"==typeof e))}catch{}if(a)try{let e=JSON.parse(a);Array.isArray(e)&&Q(e.filter(e=>"string"==typeof e))}catch{}if(s)try{let e=JSON.parse(s);Array.isArray(e)&&X(e.filter(e=>"string"==typeof e))}catch{}},[]),(0,g.useEffect)(()=>{globalThis.localStorage?.setItem(rB,tX)},[tX]),(0,g.useEffect)(()=>{globalThis.localStorage?.setItem(rq,JSON.stringify(V))},[V]),(0,g.useEffect)(()=>{globalThis.localStorage?.setItem(rK,JSON.stringify(H))},[H]),(0,g.useEffect)(()=>{globalThis.localStorage?.setItem(rG,JSON.stringify(Z))},[Z]),(0,g.useEffect)(()=>{if(!z)return;let e=h.tasks.find(e=>e.dispatchId===z);e&&(ap(e.id,"overview"),ej(!0),W(null))},[z,h.tasks,ap]),(0,g.useEffect)(()=>{q(e=>e.filter(e=>{let t="string"==typeof e.task.metadata.dispatchSubmittedAt?Date.parse(e.task.metadata.dispatchSubmittedAt):e.task.updatedAt??NaN,a=!Number.isNaN(t)&&Date.now()-t>18e5;if(!e.dispatchId)return!a;let s=h.tasks.find(t=>t.dispatchId===e.dispatchId);return s?"running"===s.status||"queued"===s.status:!a}))},[h.tasks]),(0,g.useEffect)(()=>{ek||eX||e1||(eH(r2(h)),eQ(r5(h)))},[h,ek,eX,e1]),(0,g.useEffect)(()=>{aw&&tU(!1)},[aw]),(0,g.useEffect)(()=>{aw&&tJ(!0)},[aw]),(0,g.useEffect)(()=>{tv(e=>{let t=h.models.filter(e=>!1!==e.available&&!e.missing).map(e=>e.id),a=h.diagnostics.modelReadiness.recommendedModelId;return e&&t.includes(e)?e:a&&t.includes(a)?a:t[0]||""})},[h.models,h.diagnostics.modelReadiness.recommendedModelId]),(0,g.useEffect)(()=>{ab?tw("models"):tw("system")},[ab]),(0,g.useEffect)(()=>{(ax.current&&(globalThis.clearTimeout(ax.current),ax.current=null),aw)?"idle"!==ts||"idle"!==tN?(tr("success"),ti("ready"),to(null),tc("OpenClaw and a usable default model are ready. Entering Mission Control..."),tC("success"),tA("ready"),tT(null),tO("A usable default model is ready."),tw("models"),tG(!0),ax.current=globalThis.setTimeout(()=>{tG(!1)},1100)):tG(!1):tG(!1)},[aw,ts,tN]),(0,g.useEffect)(()=>()=>{ax.current&&globalThis.clearTimeout(ax.current)},[]);let aW=()=>{"running"!==e4&&(e8("idle"),e9(null),te(null),ta(""))},aB=e=>{ta(t=>{let a=`${t}${e}`;return a.length>4e4?a.slice(a.length-4e4):a})},aq=e=>{tu(t=>{let a=`${t}${e}`;return a.length>4e4?a.slice(a.length-4e4):a})},aK=e=>{t$(t=>{let a=`${t}${e}`;return a.length>4e4?a.slice(a.length-4e4):a})},aG=e=>{eK(t=>{let a=`${t}${e}`;return a.length>4e4?a.slice(a.length-4e4):a})},aV=(0,g.useCallback)(async()=>{if(!ep||"running"===eu)return;let e="string"==typeof ep.metadata.optimisticRequestId?ep.metadata.optimisticRequestId:null,t=e?B.find(t=>t.requestId===e):B.find(e=>e.task.id===ep.id),a="string"==typeof ep.dispatchId?ep.dispatchId:t?.dispatchId??null;if(e&&!a){ef.current.get(e)?.abort(),ef.current.delete(e),q(t=>t.map(t=>t.requestId===e?{...t,task:rZ(t.task,{status:"cancelled",subtitle:"Mission submission cancelled before dispatch.",bootstrapStage:"cancelled",feedEvent:{id:`${t.task.id}:cancelled:${Date.now()}`,kind:"warning",timestamp:new Date().toISOString(),title:"Dispatch cancelled",detail:"Mission submission cancelled before dispatch.",isError:!1}})}:t)),el.o.success("Mission submission cancelled.",{description:ep.title}),em(null),eh("idle"),eg(null);return}eh("running"),eg(null);try{let e=await fetch(`/api/tasks/${encodeURIComponent(ep.id)}/abort`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:"Aborted from Mission Control.",dispatchId:a})}),t=await e.json().catch(()=>null);if(!e.ok)throw Error(t?.error||t?.message||t?.summary||"Unable to abort task.");el.o.success("Task abort requested.",{description:ep.title}),em(null),eh("idle"),await b()}catch(t){let e=t instanceof Error?t.message:"Unknown abort error.";eh("error"),eg(e),el.o.error("Task abort failed.",{description:e})}},[B,b,ep,eu]),aJ=e=>{e&&tk(e)};(0,g.useEffect)(()=>{if(!ek)return;let e=e=>{am.current?.contains(e.target)||eN(!1)},t=e=>{"Escape"===e.key&&eN(!1)};return window.addEventListener("pointerdown",e),window.addEventListener("keydown",t),()=>{window.removeEventListener("pointerdown",e),window.removeEventListener("keydown",t)}},[ek]);let aH=async()=>{e3(!0),e8("running"),e9("Starting OpenClaw update..."),te(null),ta("");try{let e=await fetch("/api/update",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirmed:!0})});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||"OpenClaw update request failed.")}if(!e.body)throw Error("OpenClaw update did not return a readable stream.");let t=e.body.getReader(),a=new TextDecoder,s="",r=!1;for(;;){let{value:e,done:n}=await t.read();if(n)break;let i=(s+=a.decode(e,{stream:!0})).indexOf("\n");for(;i>=0;){let e=s.slice(0,i).trim();if(s=s.slice(i+1),e){let t=JSON.parse(e);"status"===t.type?(e9(t.message),aB(`
168
- > ${t.message}
169
- `)):"log"===t.type?aB(t.text):(r=!0,e9(null),te(t.message),e8(t.ok?"success":"error"),t.snapshot&&w(t.snapshot),t.ok?el.o.success("OpenClaw updated.",{description:t.message}):el.o.error("OpenClaw update failed.",{description:t.message}))}i=s.indexOf("\n")}}let n=s.trim();if(n){let e=JSON.parse(n);"done"===e.type&&(r=!0,e9(null),te(e.message),e8(e.ok?"success":"error"),e.snapshot&&w(e.snapshot))}if(!r)throw Error("OpenClaw update stream ended unexpectedly.")}catch(e){e8("error"),e9(null),te(e instanceof Error?e.message:"OpenClaw update failed."),el.o.error("OpenClaw update failed.",{description:e instanceof Error?e.message:"Unknown update error."})}},aY=async()=>{tU(!1),tw("system"),tr("running"),ti("detecting"),to("Checking local OpenClaw status..."),tc(null),tx(null),tb(null),tu("");try{let e=await fetch("/api/onboarding",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({intent:"auto"})});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||"OpenClaw onboarding request failed.")}if(!e.body)throw Error("OpenClaw onboarding did not return a readable stream.");let t=e.body.getReader(),a=new TextDecoder,s="",r=!1;for(;;){let{value:e,done:n}=await t.read();if(n)break;let i=(s+=a.decode(e,{stream:!0})).indexOf("\n");for(;i>=0;){let e=s.slice(0,i).trim();if(s=s.slice(i+1),e){let t=JSON.parse(e);"status"===t.type?(ti(t.phase),to(t.message),aq(`
170
- > ${t.message}
171
- `)):"log"===t.type?aq(t.text):(r=!0,ti(t.phase),to(null),tc(t.message),tx(t.manualCommand??null),tb(t.docsUrl??null),tr(t.ok?"success":"error"),t.snapshot&&w(t.snapshot),t.ok?el.o.success("System setup ready.",{description:t.message}):el.o.error("OpenClaw onboarding failed.",{description:t.message}))}i=s.indexOf("\n")}}let n=s.trim();if(n){let e=JSON.parse(n);"done"===e.type&&(r=!0,ti(e.phase),to(null),tc(e.message),tx(e.manualCommand??null),tb(e.docsUrl??null),tr(e.ok?"success":"error"),e.snapshot&&w(e.snapshot))}if(!r)throw Error("OpenClaw onboarding stream ended unexpectedly.")}catch(e){tr("error"),to(null),tc(e instanceof Error?e.message:"OpenClaw onboarding failed."),el.o.error("OpenClaw onboarding failed.",{description:e instanceof Error?e.message:"Unknown onboarding error."})}},aQ=async e=>{var t,a;let s="discover"===(t=e.intent)?{statusMessage:"Scanning models...",successTitle:"Models discovered.",errorTitle:"Model discovery failed."}:"login-provider"===t?{statusMessage:"Checking auth...",successTitle:"Provider connected.",errorTitle:"Provider auth needs attention."}:"refresh"===t?{statusMessage:"Refreshing...",successTitle:"Model setup refreshed.",errorTitle:"Model refresh failed."}:{statusMessage:"Checking models...",successTitle:"Model setup ready.",errorTitle:"Model setup failed."};tU(!1),tw("models"),tC("running"),tA("refresh"===(a=e.intent)?"refreshing":"discover"===a?"discovering":"detecting"),tT(s.statusMessage),tO(null),tD(null),tP(null),t$("");try{let t=await fetch("/api/onboarding/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error||"Model onboarding request failed.")}if(!t.body)throw Error("Model onboarding did not return a readable stream.");let a=t.body.getReader(),r=new TextDecoder,n="",i=!1;for(;;){let{value:e,done:t}=await a.read();if(t)break;let l=(n+=r.decode(e,{stream:!0})).indexOf("\n");for(;l>=0;){let e=n.slice(0,l).trim();if(n=n.slice(l+1),e){let t=JSON.parse(e);"status"===t.type?(tA(t.phase),tT(t.message),aK(`
172
- > ${t.message}
173
- `)):"log"===t.type?aK(t.text):(i=!0,tA(t.phase),tT(null),tO(t.message),tD(t.manualCommand??null),tP(t.docsUrl??null),tC(t.ok?"success":"error"),aJ(t.discoveredModels),t.snapshot&&w(t.snapshot),t.ok?el.o.success(s.successTitle,{description:t.message}):"authenticating"===t.phase&&t.manualCommand?el.o.message("Continue in terminal.",{description:t.message}):el.o.error(s.errorTitle,{description:t.message}))}l=n.indexOf("\n")}}let l=n.trim();if(l){let e=JSON.parse(l);"done"===e.type&&(i=!0,tA(e.phase),tT(null),tO(e.message),tD(e.manualCommand??null),tP(e.docsUrl??null),tC(e.ok?"success":"error"),aJ(e.discoveredModels),e.snapshot&&w(e.snapshot))}if(!i)throw Error("Model onboarding stream ended unexpectedly.")}catch(e){tC("error"),tT(null),tO(e instanceof Error?e.message:"Model onboarding failed."),el.o.error(s.errorTitle,{description:e instanceof Error?e.message:"Unknown model onboarding error."})}},aZ=async()=>{await aQ({intent:"auto",modelId:ty||void 0})},aX=async()=>{await aQ({intent:"refresh"})},a0=async()=>{await aQ({intent:"discover"})},a1=async e=>{await aQ({intent:"login-provider",provider:e})},a2=async e=>{let t=e||ty;t?await aQ({intent:"set-default",modelId:t}):await aZ()},a5=(e=ab?"models":"system")=>{eN(!1),tw(e),tU(!1),tG(!1),tq(!0)},a3=async e=>{tY(e);try{let t=await fetch("/api/gateway/control",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e})}),a=await t.json();if(!t.ok||a.error||!a.snapshot)throw Error(a.error||"Gateway control request failed.");w(a.snapshot),el.o.success("Gateway updated.",{description:a.message||"Gateway state changed."})}catch(e){el.o.error("Gateway action failed.",{description:e instanceof Error?e.message:"Unknown gateway control error."})}finally{tY(null)}},a4=e=>{as(L(e)),at(!0)},a8=async()=>{eA(!0);try{let e=await f(),t=Date.now(),a=e.diagnostics.updateInfo?.trim();if(tZ(t),!e.diagnostics.installed)return void el.o.message("OpenClaw is unavailable.",{description:e.diagnostics.issues[0]||"Mission Control is running in fallback mode."});if(e.diagnostics.updateAvailable)return void el.o.message("Update available.",{description:a||`v${e.diagnostics.latestVersion} is available. Current version: v${e.diagnostics.version||"unknown"}.`});if(e.diagnostics.latestVersion&&!e.diagnostics.version)return void el.o.message("Update status refreshed.",{description:a||`Latest available version: v${e.diagnostics.latestVersion}.`});if(e.diagnostics.updateError)return void el.o.error("Update check could not reach the registry.",{description:a||e.diagnostics.updateError});el.o.success("OpenClaw is up to date.",{description:a||`Current version: v${e.diagnostics.version||"unknown"}. No newer release was reported.`})}catch(e){el.o.error("Update check failed.",{description:e instanceof Error?e.message:"Unable to refresh OpenClaw status."})}finally{eA(!1)}},a6=async e=>{e0(!0);try{let t=await fetch("/api/settings/gateway",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({gatewayUrl:e})});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error||"Gateway settings could not be updated.")}let a=await t.json();w(a.snapshot),eH(r2(a.snapshot)),el.o.success("Gateway updated.",{description:e?.trim()?`Mission Control now targets ${a.snapshot.diagnostics.configuredGatewayUrl||a.snapshot.diagnostics.gatewayUrl}.`:"Mission Control reverted to the local default gateway."})}catch(e){el.o.error("Gateway update failed.",{description:e instanceof Error?e.message:"Unable to update the OpenClaw gateway."})}finally{e0(!1)}},a9=async e=>{e2(!0);try{let t=await fetch("/api/settings/workspace-root",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceRoot:e})});if(!t.ok){let e=await t.json().catch(()=>null);throw Error(e?.error||"Workspace root could not be updated.")}let a=await t.json();w(a.snapshot),eQ(r5(a.snapshot)),el.o.success("Workspace root updated.",{description:e?.trim()?`New workspaces will default to ${(0,eb.$7)(a.snapshot.diagnostics.workspaceRoot)}. Existing workspaces stay where they are.`:"Mission Control reverted to the default workspace root. Existing workspaces were not moved."})}catch(e){el.o.error("Workspace root update failed.",{description:e instanceof Error?e.message:"Unable to update the default workspace root."})}finally{e2(!1)}},a7=()=>{if(void 0===globalThis.localStorage)return;let e=["mission-control-composer-draft:"];for(let e of["mission-control-surface-theme","mission-control-workspace-plan-id","mission-control-recent-prompts"])globalThis.localStorage.removeItem(e);for(let t=globalThis.localStorage.length-1;t>=0;t-=1){let a=globalThis.localStorage.key(t);a&&e.some(e=>a.startsWith(e))&&globalThis.localStorage.removeItem(a)}},se=()=>{eO("idle"),e$(null),eD(null),eP("idle"),eU(null),ez(null),eB(null),eK(""),eV("")},st=async e=>{eO("loading"),e$(null),eD(null);try{let t=await fetch("/api/reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({intent:"preview",target:e})}),a=await t.json().catch(()=>null);if(!t.ok||!a?.preview)throw Error(a?.error||"Reset preview could not be loaded.");e$(a.preview),eO("ready")}catch(e){eO("error"),eD(e instanceof Error?e.message:"Reset preview failed.")}},sa=async e=>{eN(!1),eT(e),se(),await st(e)},ss=async()=>{if(eI){eP("running"),eU("full-uninstall"===eI?"Starting full uninstall...":"Starting Mission Control reset..."),ez(null),eB(null),eK("");try{let e=await fetch("/api/reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({intent:"execute",target:eI,confirmed:!0})});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error||"Reset request failed.")}if(!e.body)throw Error("Reset request did not return a readable stream.");let t=e.body.getReader(),a=new TextDecoder,s="",r=!1;for(;;){let{value:e,done:n}=await t.read();if(n)break;let i=(s+=a.decode(e,{stream:!0})).indexOf("\n");for(;i>=0;){let e=s.slice(0,i).trim();if(s=s.slice(i+1),e){let t=JSON.parse(e);"status"===t.type?(eU(t.message),aG(`
174
- > ${t.message}
175
- `)):"log"===t.type?aG(`${t.text}
176
- `):(r=!0,eU(null),ez(t.message),eB(t.backgroundLogPath??null),eP(t.ok?"success":"error"),t.snapshot&&w(t.snapshot),t.ok?(a7(),el.o.success("full-uninstall"===eI?"Full uninstall started.":"Mission Control reset completed.",{description:t.message})):el.o.error("full-uninstall"===eI?"Full uninstall failed.":"Mission Control reset failed.",{description:t.message}))}i=s.indexOf("\n")}}let n=s.trim();if(n){let e=JSON.parse(n);"done"===e.type&&(r=!0,eU(null),ez(e.message),eB(e.backgroundLogPath??null),eP(e.ok?"success":"error"),e.snapshot&&w(e.snapshot),e.ok&&a7())}if(!r)throw Error("Reset stream ended unexpectedly.")}catch(e){eP("error"),eU(null),ez(e instanceof Error?e.message:"Reset failed."),el.o.error("full-uninstall"===eI?"Full uninstall failed.":"Mission Control reset failed.",{description:e instanceof Error?e.message:"Unknown reset error."})}}};return(0,s.jsxs)("div",{className:(0,S.cn)("mission-shell relative min-h-screen overflow-hidden","light"===tX&&"mission-shell--light"),children:[(0,s.jsxs)("div",{className:"mission-canvas-backdrop absolute inset-0 z-0",children:[(0,s.jsx)("div",{"aria-hidden":"true",className:"mission-canvas-pattern absolute inset-0 z-0"}),(0,s.jsx)("div",{className:"absolute inset-0 z-10",children:(0,s.jsx)(rW,{snapshot:al,activeWorkspaceId:y,selectedNodeId:j,focusedAgentId:A,composerTargetAgentId:M,isComposerActive:R,composerViewportResetNonce:E,recentDispatchId:z,hiddenRuntimeIds:V,hiddenTaskKeys:H,lockedTaskKeys:Z,onToggleWorkspaceTaskCards:aT,className:"rounded-none",onEditAgent:e=>{ap(e),ei({requestId:`edit:${e}:${Date.now()}`,kind:"edit",agentId:e})},onDeleteAgent:e=>{ap(e),ei({requestId:`delete:${e}:${Date.now()}`,kind:"delete",agentId:e})},onFocusAgent:aM,onConfigureAgentCapabilities:aR,onInspectAgentDetail:aO,onMessageAgent:e=>{let t=al.agents.find(t=>t.id===e);t&&(ei(null),T(null),v(t.workspaceId),ap(e,"chat"),ej(!0))},onReplyTask:e=>{let t=rY(e);G({id:`reply:${e.id}:${Date.now()}`,mission:t,agentId:e.primaryAgentId,sourceKind:"reply",sourceLabel:e.title.trim()||e.subtitle.trim()||e.id})},onCopyTaskPrompt:async e=>{let t=rY(e);G({id:`copy:${e.id}:${Date.now()}`,mission:t,agentId:e.primaryAgentId,sourceKind:"copy",sourceLabel:e.title.trim()||e.subtitle.trim()||e.id});try{await navigator.clipboard.writeText(t),el.o.success("Prompt copied to clipboard.",{description:"The mission input was also populated."})}catch{el.o.message("Prompt moved into mission input.",{description:"Clipboard access was not available."})}},onHideTask:e=>{ac.includes(e.key)||(Q(t=>t.includes(e.key)?t:[...t,e.key]),J(t=>{let a=new Set(t);return e.runtimeIds.forEach(e=>a.add(e)),Array.from(a)}))},onToggleTaskLock:e=>{X(t=>{let a=Array.isArray(t)?t:[];return a.includes(e.key)?a.filter(t=>t!==e.key):[...a,e.key]})},onAbortTask:e=>{rQ(e)&&(em(e),eh("idle"),eg(null))},onInspectTask:(e,t)=>{ap(e.id,t),ej(!0)},onSelectNode:e=>{ap(e)},onCanvasNodePointerDownCapture:aD})})]}),(0,s.jsx)("div",{className:(0,S.cn)("pointer-events-none absolute top-0 z-40 hidden lg:block",ew?"lg:left-[384px]":"lg:left-[84px]",ev?"lg:right-[426px]":"lg:right-[84px]"),children:(0,s.jsx)(rH,{snapshot:h,surfaceTheme:tX,settingsRef:am,isSettingsOpen:ek,gatewayDraft:eJ,workspaceRootDraft:eY,isSavingGateway:eX,isSavingWorkspaceRoot:e1,isCheckingForUpdates:eS,selectedModelId:ty,modelOnboardingRunState:tN,gatewayControlAction:tH,lastCheckedAt:tQ,onToggleTheme:()=>t0(e=>"light"===e?"dark":"light"),onToggleSettings:()=>eN(e=>!e),onGatewayDraftChange:eH,onWorkspaceRootDraftChange:eQ,onSelectedModelIdChange:tv,onSaveGatewaySettings:a6,onSaveWorkspaceRootSettings:a9,onCheckForUpdates:a8,onControlGateway:a3,onOpenSetupWizard:a5,onRunModelRefresh:aX,onRunModelSetDefault:a2,onOpenAddModels:a4,onOpenUpdateDialog:()=>{aW(),e3(!0)},onOpenResetDialog:e=>{sa(e)}})}),(0,s.jsxs)("div",{className:"relative z-20 min-h-screen pointer-events-none lg:h-screen",children:[(0,s.jsx)("div",{className:"pointer-events-none absolute left-1/2 top-4 z-30 -translate-x-1/2 lg:hidden",children:(0,s.jsx)(rJ,{surfaceTheme:tX})}),(0,s.jsx)("div",{className:"pointer-events-none absolute left-[84px] top-6 z-10 hidden lg:block",children:(0,s.jsx)(rJ,{surfaceTheme:tX})}),(0,s.jsx)("div",{className:(0,S.cn)("pointer-events-auto absolute left-0 top-0 z-30 h-[100dvh] overflow-visible mission-ease-smooth transition-[width] duration-500",ew?"w-[calc(100vw-96px)] max-w-[280px] lg:w-[360px] lg:max-w-none":"w-[60px]"),children:(0,s.jsx)(ar,{snapshot:al,surfaceTheme:tX,activeWorkspaceId:y,requestedAgentAction:en,connectionState:x,collapsed:!ew,modelManager:{runState:tN,statusMessage:tI,resultMessage:tM,log:tR,manualCommand:tE,docsUrl:t_,discoveredModels:tj,systemReady:ab},onToggleCollapsed:()=>ey(e=>!e),onSelectWorkspace:e=>{T(null),v(e),ap(e)},onRefresh:b,onRunModelRefresh:aX,onRunModelDiscover:a0,onRunModelSetDefault:a2,onConnectModelProvider:a1,onOpenModelSetup:()=>a5(ab?"models":"system"),onOpenAddModels:a4,onEditWorkspace:aU,onSnapshotChange:w})}),(0,s.jsx)("div",{className:(0,S.cn)("pointer-events-auto absolute right-0 top-0 z-30 h-[100dvh] overflow-visible mission-ease-smooth transition-[width] duration-500",ev?"w-[calc(100vw-112px)] max-w-[300px] lg:w-[394px] lg:max-w-none":"w-[60px]"),children:(0,s.jsx)(tm,{snapshot:al,surfaceTheme:tX,selectedNodeId:j,agentDetailFocus:N,lastMission:U,onRefresh:b,onSnapshotChange:w,onConfigureAgentCapabilities:aR,collapsed:!ev,onToggleCollapsed:()=>ej(e=>!e),activeTab:_,onActiveTabChange:P,onAbortTask:e=>{rQ(e)&&(em(e),eh("idle"),eg(null))}})}),(0,s.jsx)(eC,{open:!!eo,agentId:eo?.agentId??null,initialFocus:eo?.focus??"skills",snapshot:al,onOpenChange:a$,onSnapshotChange:e=>w(e),onRefresh:b}),(0,s.jsxs)("div",{className:"pointer-events-auto absolute bottom-[calc(env(safe-area-inset-bottom)+12px)] left-4 right-4 z-40 lg:bottom-6 lg:left-1/2 lg:right-auto lg:w-[min(800px,calc(100vw-320px))] lg:-translate-x-1/2",children:[(0,s.jsxs)("div",{className:"mx-auto mb-1 flex w-fit flex-col items-start gap-1",children:[aI>0?(0,s.jsxs)("div",{className:"inline-flex items-center gap-1.5 rounded-full border border-white/[0.08] bg-[linear-gradient(180deg,rgba(10,16,26,0.96),rgba(6,10,18,0.94))] px-3 py-1 text-[8px] text-slate-200 shadow-[0_10px_24px_rgba(0,0,0,0.14)]",children:[(0,s.jsx)(r.A,{className:"h-3 w-3 text-slate-400"}),(0,s.jsxs)("span",{className:"leading-3 text-slate-300",children:[aI," hidden"]})]}):null,A?(0,s.jsxs)("button",{type:"button",onClick:aP,className:"inline-flex items-center gap-1.5 rounded-full border border-cyan-300/18 bg-[linear-gradient(180deg,rgba(16,25,38,0.98),rgba(8,12,20,0.96))] px-3 py-1 text-[8px] text-cyan-100 shadow-[0_10px_24px_rgba(0,0,0,0.14)] transition-colors hover:border-cyan-200/30 hover:bg-[linear-gradient(180deg,rgba(20,33,49,0.98),rgba(10,15,25,0.96))]","aria-label":"Reset focus and show the full workspace",title:"Reset Focus",children:[(0,s.jsx)(n.A,{className:"h-3 w-3 text-cyan-300"}),(0,s.jsx)("span",{className:"leading-3 text-cyan-50",children:"Reset Focus"})]}):null]}),(0,s.jsx)(eZ,{snapshot:al,activeWorkspaceId:y,selectedNodeId:j,composeIntent:K,isComposerActive:R,onTargetAgentChange:O,onTargetAgentSelect:aE,onComposerActiveChange:a_,onRefresh:b,onOpenWorkspaceCreate:()=>{aL("basic")},onOpenWorkspaceChannels:az,onMissionDispatchStart:e=>{var t,a;let s,r,n;ef.current.set(e.requestId,e.abortController);let i=(t=e,a=h,s=new Date(t.submittedAt).toISOString(),r=a.agents.find(e=>e.id===t.agentId),n={id:`optimistic:${t.requestId}:submitted`,kind:"user",timestamp:s,title:"Mission submitted",detail:r1(t.mission,220),agentId:t.agentId},{requestId:t.requestId,dispatchId:null,task:{id:`optimistic-task:${t.requestId}`,key:`optimistic:${t.requestId}`,title:r1(t.mission,86),mission:t.mission,subtitle:"Sending mission to AgentOS. Waiting for a dispatch id.",status:"queued",updatedAt:t.submittedAt,ageMs:0,workspaceId:t.workspaceId??void 0,primaryAgentId:t.agentId,primaryAgentName:(0,eb.CK)(r??{name:"OpenClaw"}),runtimeIds:[],agentIds:[t.agentId],sessionIds:[],runIds:[],runtimeCount:0,updateCount:0,liveRunCount:0,artifactCount:0,warningCount:0,metadata:{optimistic:!0,optimisticRequestId:t.requestId,bootstrapStage:"submitting",dispatchSubmittedAt:s,optimisticEvents:[n]}}});q(t=>[i,...t.filter(t=>t.requestId!==e.requestId)]),e.workspaceId&&v(e.workspaceId),ap(i.task.id),ej(!0)},onMissionDispatchFailure:(e,t)=>{ef.current.delete(e),q(a=>a.map(a=>a.requestId===e?{...a,task:rZ(a.task,{status:"stalled",subtitle:t,bootstrapStage:"stalled",feedEvent:{id:`${a.task.id}:failed:${Date.now()}`,kind:"warning",timestamp:new Date().toISOString(),title:"Dispatch failed",detail:t,isError:!0}})}:a))},onMissionResponse:(e,t)=>{ef.current.delete(t.requestId),F(e),q(a=>a.map(a=>a.requestId===t.requestId?{...a,dispatchId:e.dispatchId??a.dispatchId,task:rZ(a.task,{dispatchId:e.dispatchId,status:"stalled"===e.status?"stalled":"cancelled"===e.status?"cancelled":"queued",subtitle:e.summary,bootstrapStage:"stalled"===e.status?"stalled":"cancelled"===e.status?"cancelled":"accepted",feedEvent:{id:`${a.task.id}:response:${Date.now()}`,kind:"stalled"===e.status||"cancelled"===e.status?"warning":"status",timestamp:new Date().toISOString(),title:"stalled"===e.status?"Dispatch blocked":"cancelled"===e.status?"Dispatch cancelled":"Mission accepted",detail:e.summary||"Mission accepted and queued for OpenClaw execution.",isError:"stalled"===e.status||"cancelled"===e.status}})}:a)),e.dispatchId&&W(e.dispatchId)}})]}),(0,s.jsx)(af,{snapshot:al,workspaceId:y??al.workspaces[0]?.id??null,open:t9,onOpenChange:t7,onRefresh:b,onSnapshotChange:w}),aA||tK||tF?(0,s.jsx)(tB,{snapshot:h,surfaceTheme:tX,stage:tf,systemActionLabel:aC.label,systemActionDescription:aC.description,systemPhase:tn,modelPhase:tS,systemRun:{runState:ts,statusMessage:tl,resultMessage:td,log:tp,manualCommand:th,docsUrl:tg},modelRun:{runState:tN,statusMessage:tI,resultMessage:tM,log:tR,manualCommand:tE,docsUrl:t_},selectedModelId:ty,discoveredModels:tj,onSelectedModelIdChange:tv,onRunSystemSetup:aY,onRunModelAutoSetup:aZ,onRunModelDiscover:a0,onRunModelRefresh:aX,onRunModelSetDefault:a2,onOpenAddModels:a4,onContinueToModels:()=>tw("models"),onBackToSystem:()=>tw("system"),onDismiss:()=>{tq(!1),tG(!1),aw||tU(!0)},canDismiss:!tK&&"running"!==ts&&"running"!==tN}):null,(0,s.jsx)(rD,{open:t1,onOpenChange:aF,initialMode:t5,workspaceEditId:t8,surfaceTheme:tX,snapshot:h,onRefresh:b,onWorkspaceCreated:e=>{ai(e),v(e),ap(e)},onWorkspaceUpdated:e=>{ai(e),v(e),ap(e)}},t8?`workspace-edit:${t8}`:"workspace-create"),(0,s.jsx)(ed,{open:ae,onOpenChange:at,snapshot:h,initialProvider:aa,onSnapshotChange:w}),(0,s.jsx)(t3,{open:null!==eI,target:eI,surfaceTheme:tX,previewState:eM,preview:eR,previewError:eE,runState:e_,statusMessage:eL,resultMessage:eF,backgroundLogPath:eW,log:eq,confirmText:eG,onConfirmTextChange:eV,onRefreshPreview:()=>{eI&&st(eI)},onExecute:()=>{ss()},onOpenChange:e=>{e||"running"!==e_&&(eT(null),se())}}),(0,s.jsx)(Y,{open:null!==ep,onOpenChange:e=>{"running"!==eu&&(e||(em(null),eh("idle"),eg(null)))},children:(0,s.jsxs)(ee,{className:(0,S.cn)("max-w-[480px] gap-5 p-5 sm:p-6","light"===tX?"border-[#d7c5b7] bg-[rgba(252,247,241,0.98)] text-[#4a382c] shadow-[0_30px_80px_rgba(161,125,101,0.2)]":"border-white/10 bg-slate-950/94 text-slate-100"),children:[(0,s.jsxs)(et,{children:[(0,s.jsx)(es,{className:"light"===tX?"text-[#3f2f24]":"text-white",children:"Abort task?"}),(0,s.jsx)(er,{className:"light"===tX?"text-[#7e6555]":"text-slate-400",children:"This stops the current OpenClaw dispatch for the selected task. It does not delete captured evidence or files."})]}),ep?(0,s.jsxs)("div",{className:(0,S.cn)("rounded-[20px] border px-4 py-4","light"===tX?"border-[#e3d4c8] bg-[#fffaf6] text-[#4f3d31]":"border-rose-400/20 bg-rose-400/10 text-rose-50"),children:[(0,s.jsx)("p",{className:"text-[10px] uppercase tracking-[0.24em] text-slate-500",children:"Selected task"}),(0,s.jsx)("p",{className:"mt-2 font-display text-[1.02rem] leading-6 text-inherit",children:ep.title}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1 text-sm leading-6","light"===tX?"text-[#8b7262]":"text-rose-100/80"),children:ep.subtitle}),ex?(0,s.jsx)("p",{className:"mt-3 rounded-[16px] border border-rose-400/20 bg-rose-400/10 px-3 py-2 text-sm text-rose-50",children:ex}):null]}):null,(0,s.jsxs)(ea,{children:[(0,s.jsx)(I,{type:"button",variant:"secondary",disabled:"running"===eu,className:"light"===tX?"border-[#d9c9bc] bg-[#f5ebe3] text-[#6c5647] hover:bg-[#eddccf]":"",onClick:()=>{"running"!==eu&&(em(null),eh("idle"),eg(null))},children:"Cancel"}),(0,s.jsx)(I,{type:"button",variant:"destructive",disabled:!ep||"running"===eu,onClick:()=>{aV()},children:"running"===eu?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.A,{className:"mr-2 h-4 w-4 animate-spin"}),"Aborting..."]}):"Abort task"})]})]})}),(0,s.jsxs)("div",{className:(0,S.cn)("pointer-events-auto absolute bottom-3 right-[74px] z-30 text-[11px] tracking-[0.04em] lg:bottom-4",ev?"lg:right-[426px]":"lg:right-[86px]","light"===tX?"text-[#8f7664]":"text-slate-500"),children:["Built on"," ",(0,s.jsx)("a",{href:"https://openclaw.ai/",target:"_blank",rel:"noreferrer",className:(0,S.cn)("transition-colors","light"===tX?"text-[#6f5a4b] hover:text-[#4f3d31]":"text-slate-300 hover:text-slate-100"),children:"OpenClaw"})," ","by"," ",(0,s.jsx)("a",{href:"https://sapienx.app/",target:"_blank",rel:"noreferrer",className:(0,S.cn)("transition-colors","light"===tX?"text-[#6f5a4b] hover:text-[#4f3d31]":"text-slate-300 hover:text-slate-100"),children:"SapienX"})]}),(0,s.jsx)(Y,{open:e5,onOpenChange:e=>{"running"!==e4&&(e3(e),e||aW())},children:(0,s.jsxs)(ee,{className:(0,S.cn)("max-w-[468px] gap-5 p-5 sm:p-6","light"===tX?"border-[#d7c5b7] bg-[rgba(252,247,241,0.98)] text-[#4a382c] shadow-[0_30px_80px_rgba(161,125,101,0.2)]":"border-white/10 bg-slate-950/94 text-slate-100"),children:[(0,s.jsxs)(et,{children:[(0,s.jsx)(es,{className:"light"===tX?"text-[#3f2f24]":"text-white",children:ak}),(0,s.jsx)(er,{className:"light"===tX?"text-[#7e6555]":"text-slate-400",children:aN})]}),aj?(0,s.jsxs)("div",{className:(0,S.cn)("space-y-4","light"===tX?"text-[#4f3d31]":"text-slate-200"),children:[(0,s.jsxs)("div",{className:(0,S.cn)("rounded-[24px] border px-4 py-5",(c=e4,p=tX,"success"===c?"light"===p?"border-emerald-300 bg-emerald-50/80 text-emerald-950":"border-emerald-300/25 bg-emerald-300/10 text-emerald-50":"light"===p?"border-rose-300 bg-rose-50/90 text-rose-950":"border-rose-300/25 bg-rose-300/10 text-rose-50")),children:[(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("div",{className:(0,S.cn)("flex h-11 w-11 shrink-0 items-center justify-center rounded-2xl border",(m=e4,u=tX,"success"===m?"light"===u?"border-emerald-300 bg-white/80 text-emerald-700":"border-emerald-300/25 bg-emerald-300/10 text-emerald-200":"light"===u?"border-rose-300 bg-white/80 text-rose-700":"border-rose-300/25 bg-rose-300/10 text-rose-200")),children:"success"===e4?(0,s.jsx)(l.A,{className:"h-5 w-5"}):(0,s.jsx)(o.A,{className:"h-5 w-5"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"font-display text-[1.05rem] leading-6",children:"success"===e4?"OpenClaw is up to date":"Update needs attention"}),(0,s.jsx)("p",{className:"mt-1 text-sm leading-6",children:e7||("success"===e4?"The update finished successfully.":"The update did not finish cleanly.")})]})]}),(0,s.jsxs)("div",{className:"mt-4 grid gap-3 sm:grid-cols-2",children:[(0,s.jsxs)("div",{className:(0,S.cn)("rounded-[18px] border px-3 py-3","light"===tX?"border-white/70 bg-white/70":"border-white/10 bg-slate-950/30"),children:[(0,s.jsx)("p",{className:"light"===tX?"text-[10px] uppercase tracking-[0.22em] text-[#8d725f]":"text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Installed version"}),(0,s.jsxs)("p",{className:"mt-2 font-display text-lg text-inherit",children:["v",h.diagnostics.version||h.diagnostics.latestVersion||"unknown"]})]}),(0,s.jsxs)("div",{className:(0,S.cn)("rounded-[18px] border px-3 py-3","light"===tX?"border-white/70 bg-white/70":"border-white/10 bg-slate-950/30"),children:[(0,s.jsx)("p",{className:"light"===tX?"text-[10px] uppercase tracking-[0.22em] text-[#8d725f]":"text-[10px] uppercase tracking-[0.22em] text-slate-500",children:"Install mode"}),(0,s.jsx)("p",{className:"mt-2 text-sm font-medium text-inherit",children:ay||"unknown"})]})]})]}),(0,s.jsxs)("div",{className:(0,S.cn)("rounded-[20px] border","light"===tX?"border-[#e3d4c8] bg-[#fffaf6]":"border-white/8 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:(0,S.cn)("flex items-center justify-between border-b px-4 py-3","light"===tX?"border-[#eadccf]":"border-white/8"),children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[10px] uppercase tracking-[0.24em]","light"===tX?"text-[#9a7f6c]":"text-slate-500"),children:"Update log"}),(0,s.jsx)("span",{className:"light"===tX?"text-xs text-[#8b7262]":"text-xs text-slate-400",children:"success"===e4?"Completed":"Failed"})]}),(0,s.jsx)("pre",{className:(0,S.cn)("max-h-[180px] overflow-auto whitespace-pre-wrap break-words px-4 py-3 font-mono text-[11px] leading-5","light"===tX?"text-[#4f3d31]":"text-slate-200"),children:tt||"No command output was captured."})]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:(0,S.cn)("grid gap-3 sm:grid-cols-2","light"===tX?"text-[#4f3d31]":"text-slate-200"),children:[(0,s.jsxs)("div",{className:(0,S.cn)("rounded-[20px] border px-4 py-4","light"===tX?"border-[#e3d4c8] bg-[#fffaf6]":"border-white/8 bg-white/[0.03]"),children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[10px] uppercase tracking-[0.24em]","light"===tX?"text-[#9a7f6c]":"text-slate-500"),children:"Version target"}),(0,s.jsxs)("p",{className:"mt-2 font-display text-[1.1rem] leading-6 text-inherit",children:["v",h.diagnostics.latestVersion||h.diagnostics.version||"unknown"]}),(0,s.jsxs)("p",{className:"light"===tX?"mt-1 text-xs text-[#8b7262]":"mt-1 text-xs text-slate-400",children:["Current: v",h.diagnostics.version||"unknown"]})]}),(0,s.jsxs)("div",{className:(0,S.cn)("rounded-[20px] border px-4 py-4","light"===tX?"border-[#e3d4c8] bg-[#fffaf6]":"border-white/8 bg-white/[0.03]"),children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[10px] uppercase tracking-[0.24em]","light"===tX?"text-[#9a7f6c]":"text-slate-500"),children:"Install mode"}),(0,s.jsx)("p",{className:"mt-2 text-sm font-medium leading-6 text-inherit",children:ay||"unknown"}),(0,s.jsx)("p",{className:"light"===tX?"mt-1 text-xs text-[#8b7262]":"mt-1 text-xs text-slate-400",children:(0,eb.$7)(h.diagnostics.updateRoot||"")||"Install root unavailable"})]})]}),(0,s.jsx)("div",{className:(0,S.cn)("rounded-[20px] border px-4 py-3 text-sm",ag>0?"light"===tX?"border-rose-300/80 bg-rose-50 text-rose-800":"border-rose-300/25 bg-rose-300/10 text-rose-100":"light"===tX?"border-[#e3d4c8] bg-[#fffaf6] text-[#745e4f]":"border-white/8 bg-white/[0.03] text-slate-300"),children:ag>0?`${ag} running or queued runtime${1===ag?"":"s"} may be interrupted during the update.`:"No running runtimes are currently tracked, so the update risk is lower."}),av?(0,s.jsxs)("div",{className:(0,S.cn)("rounded-[20px] border","light"===tX?"border-[#e3d4c8] bg-[#fffaf6]":"border-white/8 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:(0,S.cn)("flex items-center gap-3 border-b px-4 py-3","light"===tX?"border-[#eadccf]":"border-white/8"),children:[(0,s.jsx)("div",{className:(0,S.cn)("flex h-9 w-9 items-center justify-center rounded-2xl border","light"===tX?"border-[#dcc6b6] bg-[#f4e8dd] text-[#7b6453]":"border-white/10 bg-white/[0.05] text-slate-200"),children:(0,s.jsx)(i.A,{className:"h-4 w-4 animate-spin"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"light"===tX?"text-sm font-medium text-[#4a382c]":"text-sm font-medium text-white",children:"Update in progress"}),(0,s.jsx)("p",{className:"light"===tX?"text-xs text-[#8b7262]":"text-xs text-slate-400",children:e6||"Streaming OpenClaw output..."})]})]}),(0,s.jsx)("pre",{className:(0,S.cn)("max-h-[180px] min-h-[120px] overflow-auto whitespace-pre-wrap break-words px-4 py-3 font-mono text-[11px] leading-5","light"===tX?"text-[#4f3d31]":"text-slate-200"),children:tt||"Waiting for command output..."})]}):null]}),(0,s.jsxs)(ea,{children:[(0,s.jsx)(I,{type:"button",variant:"secondary",onClick:()=>{e3(!1),aW()},disabled:av,className:"light"===tX?"border-[#d9c9bc] bg-[#f5ebe3] text-[#6c5647] hover:bg-[#eddccf]":"",children:aj?"Done":"Cancel"}),aj?null:(0,s.jsx)(I,{type:"button",onClick:aH,disabled:av,className:(0,S.cn)(h.diagnostics.updateAvailable?"bg-amber-400 text-slate-950 shadow-lg shadow-amber-400/20 hover:bg-amber-300":"","light"!==tX||h.diagnostics.updateAvailable?"":"bg-[#c8946f] text-white shadow-[0_12px_28px_rgba(200,148,111,0.24)] hover:bg-[#b88461]"),children:av?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.A,{className:"mr-2 h-4 w-4 animate-spin"}),"Updating..."]}):"Update now"})]})]})})]})]})}function rJ({surfaceTheme:e}){return(0,s.jsxs)("div",{className:(0,S.cn)("flex h-11 items-center gap-3 rounded-full border px-4 shadow-[0_18px_50px_rgba(0,0,0,0.24)] backdrop-blur-xl","light"===e?"border-[#d9c9bc]/90 bg-[#f8f5f0]/86 shadow-[0_18px_42px_rgba(161,125,101,0.14)]":"border-cyan-300/10 bg-slate-950/45"),children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:(0,S.cn)("inline-flex h-7 w-7 items-center justify-center overflow-hidden rounded-[8px] border","light"===e?"border-[#d1bcad] bg-[#f5ece4]":"border-white/[0.08] bg-white/[0.03]"),children:(0,s.jsx)("video",{"aria-hidden":"true",autoPlay:!0,loop:!0,muted:!0,playsInline:!0,preload:"auto",className:"h-full w-full scale-[1.15] object-cover",children:(0,s.jsx)("source",{src:"/assets/logo.webm",type:"video/webm"})})}),(0,s.jsx)("p",{className:(0,S.cn)("text-[10px] tracking-[0.18em]","light"===e?"text-[#8a7261]":"text-slate-500"),children:"AgentOS"})]}),(0,s.jsx)("span",{"aria-hidden":"true",className:(0,S.cn)("h-4 w-px","light"===e?"bg-[#cdb7a8]/80":"bg-white/[0.08]")}),(0,s.jsx)("h2",{className:(0,S.cn)("font-display text-[0.88rem]","light"===e?"text-[#816958]/80":"text-slate-400/75"),children:"Mission Control"})]})}function rH({snapshot:e,surfaceTheme:t,settingsRef:a,isSettingsOpen:r,gatewayDraft:l,workspaceRootDraft:b,isSavingGateway:f,isSavingWorkspaceRoot:w,isCheckingForUpdates:y,selectedModelId:v,modelOnboardingRunState:j,gatewayControlAction:k,lastCheckedAt:N,onToggleTheme:C,onToggleSettings:A,onGatewayDraftChange:M,onWorkspaceRootDraftChange:O,onSelectedModelIdChange:R,onSaveGatewaySettings:$,onSaveWorkspaceRootSettings:E,onCheckForUpdates:D,onControlGateway:_,onOpenSetupWizard:P,onRunModelRefresh:L,onRunModelSetDefault:U,onOpenAddModels:F,onOpenUpdateDialog:z,onOpenResetDialog:W}){var B,q,K;let G=e.diagnostics.health,V=tW(e),J=null!==k,H="running"===j,Y="offline"===G,Q=function(e){switch(e){case"healthy":return"Online";case"degraded":return"Degraded";default:return"Offline"}}(G),Z=r3(t,"secondary"),X=r3(t,"primary"),ee=r3(t,"warning"),et=r3(t,"warningSolid"),ea=(B=t,(0,S.cn)("inline-flex h-8 w-8 items-center justify-center rounded-full border transition-[background-color,border-color,color,transform] duration-150 active:scale-[0.96]","light"===B?"border-[#d0bcae] bg-[#efe5dc] text-[#7f6554] shadow-[inset_0_1px_0_rgba(255,255,255,0.55)] hover:bg-[#e7d9ce] hover:border-[#c8b09f] hover:text-[#5f4a3d] active:bg-[#ddcdbf]":"border-white/12 bg-white/[0.08] text-slate-200 hover:bg-white/[0.12] hover:border-white/16 hover:text-slate-100 active:bg-white/[0.16]")),es=(q=t,(0,S.cn)("relative inline-flex h-7 w-14 items-center rounded-full border transition-[background-color,border-color,transform] duration-150 active:scale-[0.98]","light"===q?"border-[#d0bcae] bg-[#eaded3] shadow-[inset_0_1px_0_rgba(255,255,255,0.55)] hover:bg-[#e3d5c8] hover:border-[#c8b09f] active:bg-[#d9c8ba]":"border-white/12 bg-white/[0.08] hover:bg-white/[0.12] hover:border-white/16 active:bg-white/[0.16]")),er=(K=t,(0,S.cn)("absolute left-1 inline-flex h-5 w-5 items-center justify-center rounded-full shadow-[0_4px_12px_rgba(0,0,0,0.18)] transition-[transform,background-color,color] duration-150","light"===K?"translate-x-7 bg-[#c8946f] text-white":"translate-x-0 bg-cyan-300 text-slate-950")),[en,ei]=(0,g.useState)(!1),el=(0,g.useRef)(null);(0,g.useEffect)(()=>{if(!en)return;let e=e=>{let t=e.target;el.current?.contains(t)||ei(!1)};return window.addEventListener("pointerdown",e),()=>window.removeEventListener("pointerdown",e)},[en]);let eo=e.diagnostics.rpcOk?"Online":e.diagnostics.loaded?"Service only":"Offline";return(0,s.jsx)("div",{className:"flex w-full items-center px-0 pt-6",children:(0,s.jsxs)("div",{ref:a,className:"pointer-events-auto relative ml-auto",children:[(0,s.jsxs)("div",{className:(0,S.cn)("flex h-11 items-center gap-3 rounded-full border px-4 shadow-[0_18px_50px_rgba(0,0,0,0.24)] backdrop-blur-xl","light"===t?"border-[#d9c9bc]/90 bg-[#f8f5f0]/86 shadow-[0_18px_42px_rgba(161,125,101,0.14)]":"border-cyan-300/10 bg-slate-950/45"),children:[(0,s.jsxs)("div",{className:"flex items-baseline gap-[3px]",children:[(0,s.jsx)("span",{className:(0,S.cn)("text-[10px] uppercase tracking-[0.3em]","light"===t?"text-[#8a7261]":"text-slate-500"),children:"OPENCLAW"}),(0,s.jsxs)("span",{className:(0,S.cn)("font-mono text-[8px] tracking-[0.04em]","light"===t?"text-[#6f5a4b]/85":"text-slate-300/80"),children:["v",e.diagnostics.version||"unknown"]})]}),Y?(0,s.jsxs)(x.P.button,{type:"button",onClick:()=>P("system"),title:"System is offline. Open the setup wizard.","aria-label":"System is offline. Open the setup wizard.",whileHover:{scale:1.03,y:-1},whileTap:{scale:.98},transition:{type:"spring",stiffness:420,damping:28},className:(0,S.cn)("group relative inline-flex cursor-pointer select-none items-center gap-2 overflow-hidden rounded-full border px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.22em] transition-[background-color,border-color,color,box-shadow,transform] duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-cyan-300/40 focus-visible:ring-offset-2 focus-visible:ring-offset-transparent",r8(G,t),"light"===t?"shadow-[0_10px_24px_rgba(244,63,94,0.12)] hover:border-rose-300 hover:bg-rose-100 hover:text-rose-800":"shadow-[0_10px_24px_rgba(244,63,94,0.18)] hover:border-rose-300/40 hover:bg-rose-300/15 hover:text-rose-100"),children:[(0,s.jsx)(x.P.span,{"aria-hidden":"true",className:(0,S.cn)("pointer-events-none absolute inset-0 rounded-full","light"===t?"bg-[radial-gradient(circle_at_top,rgba(244,63,94,0.18),rgba(244,63,94,0))]":"bg-[radial-gradient(circle_at_top,rgba(251,113,133,0.18),rgba(251,113,133,0))]"),animate:{opacity:[.35,.65,.35],scale:[.98,1.02,.98]},transition:{duration:2.8,repeat:1/0,ease:"easeInOut"}}),(0,s.jsx)("span",{"aria-hidden":"true",className:(0,S.cn)("relative z-10 h-2 w-2 rounded-full shadow-[0_0_12px_currentColor]",r6(G))}),(0,s.jsxs)("span",{className:"relative z-10 inline-flex items-center gap-1.5",children:[(0,s.jsx)("span",{children:Q}),(0,s.jsx)("span",{className:(0,S.cn)("rounded-full border px-1.5 py-0.5 text-[7px] uppercase tracking-[0.18em]","light"===t?"border-rose-300/40 bg-rose-100/70 text-rose-800":"border-rose-300/25 bg-rose-300/10 text-rose-100/90"),children:"Setup"}),(0,s.jsx)(d.A,{className:"h-3 w-3 opacity-80 transition-transform duration-200 group-hover:-translate-y-0.5 group-hover:translate-x-0.5"})]})]}):(0,s.jsxs)("span",{className:(0,S.cn)("inline-flex items-center gap-2 rounded-full border px-2.5 py-1 text-[10px] font-medium uppercase tracking-[0.22em]",r8(G,t)),children:[(0,s.jsx)("span",{"aria-hidden":"true",className:(0,S.cn)("h-2 w-2 rounded-full shadow-[0_0_12px_currentColor]",r6(G))}),Q]}),(0,s.jsx)("button",{type:"button",role:"switch","aria-label":"light"===t?"Switch to dark theme":"Switch to light theme","aria-checked":"light"===t,onClick:C,className:es,children:(0,s.jsx)("span",{className:er,children:"light"===t?(0,s.jsx)(c.A,{className:"h-3 w-3"}):(0,s.jsx)(p.A,{className:"h-3 w-3"})})}),(0,s.jsx)("button",{type:"button","aria-label":"Open settings","aria-expanded":r,"aria-haspopup":"menu",onClick:A,className:ea,children:(0,s.jsx)(m.A,{className:"h-3.5 w-3.5"})})]}),r?(0,s.jsxs)("div",{role:"menu","aria-label":"OpenClaw settings",className:(0,S.cn)("absolute right-0 top-[calc(100%+12px)] z-[70] max-h-[min(82vh,calc(100svh-96px))] w-[300px] overflow-y-auto overscroll-contain rounded-[20px] border p-3 shadow-[0_22px_64px_rgba(0,0,0,0.24)] backdrop-blur-2xl","light"===t?"border-[#dbc9bc]/90 bg-[rgba(252,247,241,0.95)] text-[#4a382c] shadow-[0_24px_60px_rgba(161,125,101,0.18)]":"border-cyan-300/12 bg-[rgba(10,16,28,0.9)] text-slate-100"),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[8px] uppercase tracking-[0.24em]","light"===t?"text-[#9a7f6c]":"text-slate-500"),children:"Settings"}),(0,s.jsx)("h3",{className:(0,S.cn)("mt-0.5 font-display text-[14px]","light"===t?"text-[#3f2f24]":"text-white"),children:"OpenClaw surface"})]}),(0,s.jsx)("span",{className:(0,S.cn)("rounded-full border px-1.5 py-0.5 text-[8px] uppercase tracking-[0.18em]","light"===t?"border-[#d6c0b0] bg-[#f3e7dc] text-[#8a7261]":"border-white/10 bg-white/[0.06] text-slate-400"),children:e.mode})]}),e.diagnostics.updateAvailable&&e.diagnostics.latestVersion?(0,s.jsxs)("div",{className:(0,S.cn)("mt-2.5 rounded-[18px] border px-3 py-3","light"===t?"border-amber-300/90 bg-[linear-gradient(135deg,rgba(255,247,237,0.98),rgba(252,231,214,0.94))] shadow-[0_16px_36px_rgba(194,120,55,0.16)]":"border-amber-300/30 bg-[linear-gradient(135deg,rgba(71,35,8,0.62),rgba(33,20,8,0.82))] shadow-[0_18px_42px_rgba(245,158,11,0.14)]"),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2.5",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[8px] uppercase tracking-[0.18em]","light"===t?"text-amber-800/70":"text-amber-200/80"),children:"Update available"}),(0,s.jsxs)("div",{className:"mt-1.5 flex items-baseline gap-1.5",children:[(0,s.jsxs)("p",{className:(0,S.cn)("font-display text-[0.98rem]","light"===t?"text-amber-950":"text-amber-50"),children:["v",e.diagnostics.latestVersion]}),(0,s.jsxs)("p",{className:(0,S.cn)("text-[9px]","light"===t?"text-amber-900/70":"text-amber-100/70"),children:["from v",e.diagnostics.version||"unknown"]})]})]}),(0,s.jsx)(d.A,{className:(0,S.cn)("mt-0.5 h-4 w-4","light"===t?"text-amber-700":"text-amber-300")})]}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1.5 text-[10px] leading-[1.05rem]","light"===t?"text-amber-950/80":"text-amber-50/85"),children:"A newer OpenClaw release was detected. You can update directly from Mission Control."}),(0,s.jsx)("button",{type:"button",onClick:z,className:(0,S.cn)("mt-2.5 inline-flex items-center justify-center py-1",et),children:"Update now"})]}):null,(0,s.jsxs)("div",{className:(0,S.cn)("mt-2.5 rounded-[16px] border px-2.5 py-2","light"===t?"border-[#e6d7cb] bg-[#fffaf6]":"border-white/8 bg-white/[0.03]"),children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[8px] uppercase tracking-[0.18em]","light"===t?"text-[#9a7f6c]":"text-slate-500"),children:"OpenClaw version"}),(0,s.jsxs)("div",{className:"mt-1.5 flex items-center justify-between gap-2",children:[(0,s.jsx)("p",{className:(0,S.cn)("font-display text-[0.88rem]","light"===t?"text-[#3f2f24]":"text-white"),children:e.diagnostics.version||"Unavailable"}),e.diagnostics.updateChannel?(0,s.jsx)("span",{className:(0,S.cn)("rounded-full border px-1.5 py-0.5 text-[8px] uppercase tracking-[0.18em]","light"===t?"border-[#dcc6b6] bg-[#f4e8dd] text-[#876c5a]":"border-cyan-400/14 bg-cyan-400/8 text-cyan-100"),children:e.diagnostics.updateChannel}):null]}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1.5 text-[10px] leading-[1.05rem]","light"===t?"text-[#816958]":"text-slate-400"),children:e.diagnostics.updateInfo?.trim()||"No additional update message was returned in the latest OpenClaw status snapshot."}),(0,s.jsxs)("div",{className:"mt-3",children:[(0,s.jsx)(I,{type:"button",size:"sm",variant:"secondary",onClick:()=>{D()},disabled:y,className:(0,S.cn)("w-full disabled:cursor-wait",e.diagnostics.updateAvailable?ee:Z),children:y?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Checking..."]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.A,{className:"mr-1.5 h-3.5 w-3.5"}),"Check for updates"]})}),N?(0,s.jsxs)("p",{className:(0,S.cn)("mt-2 text-center text-[9px]","light"===t?"text-[#8f7664]":"text-slate-500"),children:["Last checked at"," ",new Date(N).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]}):null]})]}),(0,s.jsxs)("div",{className:(0,S.cn)("mt-2 rounded-[16px] border px-2.5 py-2.5","light"===t?"border-[#e6d7cb] bg-[#fffaf6]":"border-white/8 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[8px] uppercase tracking-[0.18em]","light"===t?"text-[#9a7f6c]":"text-slate-500"),children:"Setup center"}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1 text-[10px] leading-[1.05rem]","light"===t?"text-[#816958]":"text-slate-400"),children:"Reopen the wizard or manage the gateway endpoint."})]}),(0,s.jsx)("span",{className:(0,S.cn)("rounded-full border px-1.5 py-0.5 text-[8px] uppercase tracking-[0.18em]",V?"light"===t?"border-emerald-300 bg-emerald-50 text-emerald-700":"border-emerald-300/25 bg-emerald-300/10 text-emerald-200":"light"===t?"border-amber-300 bg-amber-50 text-amber-700":"border-amber-300/25 bg-amber-300/10 text-amber-200"),children:V?"Ready":"Needs attention"})]}),(0,s.jsxs)("div",{className:"mt-3 flex items-center gap-2",children:[(0,s.jsx)(I,{type:"button",size:"sm",variant:"secondary",onClick:()=>P(e.diagnostics.rpcOk?"models":"system"),className:Z,children:"Open wizard"}),(0,s.jsx)(I,{type:"button",size:"sm",variant:"secondary",disabled:H,onClick:()=>{L()},className:Z,children:"Refresh setup"})]}),(0,s.jsxs)("div",{className:(0,S.cn)("mt-2 rounded-[14px] border px-2.5 py-2.5","light"===t?"border-[#eadcd0] bg-white":"border-white/10 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[11px]","light"===t?"text-[#9a7f6c]":"text-slate-400"),children:"Model setup"}),(0,s.jsxs)("p",{className:(0,S.cn)("mt-0.5 text-[10px] leading-[1.05rem]","light"===t?"text-[#816958]":"text-slate-500"),children:["Default model: ",e.diagnostics.modelReadiness.resolvedDefaultModel||e.diagnostics.modelReadiness.defaultModel||"Not set"]})]}),(0,s.jsxs)("span",{className:(0,S.cn)("rounded-full border px-1.5 py-0.5 text-[8px] uppercase tracking-[0.18em]",e.diagnostics.modelReadiness.ready?"light"===t?"border-emerald-300 bg-emerald-50 text-emerald-700":"border-emerald-300/25 bg-emerald-300/10 text-emerald-200":"light"===t?"border-amber-300 bg-amber-50 text-amber-700":"border-amber-300/25 bg-amber-300/10 text-amber-200"),children:[e.diagnostics.modelReadiness.availableModelCount,"/",e.diagnostics.modelReadiness.totalModelCount]})]}),(0,s.jsxs)("select",{value:v,onChange:e=>R(e.target.value),disabled:H,className:(0,S.cn)("mt-2.5 h-9 w-full rounded-[14px] border px-2.5 text-[11px]","light"===t?"border-[#d9c9bc] bg-[#fffdfb] text-[#4f3d31]":"border-white/10 bg-white/[0.04] text-slate-100"),children:[(0,s.jsx)("option",{value:"",children:"Auto choose"}),e.models.filter(e=>!1!==e.available&&!e.missing).map(e=>(0,s.jsxs)("option",{value:e.id,children:[e.name," \xb7 ",e.provider]},e.id))]}),(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,s.jsx)(I,{type:"button",size:"sm",variant:"secondary",disabled:H,onClick:()=>{U()},className:Z,children:H?"Working...":"Use selected"}),(0,s.jsx)(I,{type:"button",size:"sm",variant:"secondary",disabled:H,onClick:()=>{F()},className:Z,children:"Add models"})]})]})]}),(0,s.jsxs)("div",{className:(0,S.cn)("mt-2 rounded-[16px] border px-2.5 py-2.5","light"===t?"border-[#e6d7cb] bg-[#fffaf6]":"border-white/8 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsx)("div",{children:(0,s.jsx)(e$,{htmlFor:"workspace-root",className:(0,S.cn)("text-[11px]","light"===t?"text-[#9a7f6c]":"text-slate-500"),children:"Workspace root"})}),(0,s.jsx)("span",{className:(0,S.cn)("rounded-full border px-1.5 py-0.5 text-[8px] uppercase tracking-[0.18em]","light"===t?"border-[#dcc6b6] bg-[#f4e8dd] text-[#876c5a]":"border-white/10 bg-white/[0.05] text-slate-300"),children:"New only"})]}),(0,s.jsx)(T,{id:"workspace-root",value:b,onChange:e=>O(e.target.value),placeholder:"~/Documents/Shared/projects",disabled:w,style:"light"===t?{colorScheme:"light"}:void 0,className:(0,S.cn)("mt-2.5 h-9 rounded-[14px] px-2.5 text-[11px]","light"===t?"border-[#d9c9bc] bg-[#fffdfb] text-[#4f3d31] caret-[#7c5a46] placeholder:text-[#b29b8b] shadow-[inset_0_0_0_1000px_#fffdfb] [-webkit-text-fill-color:#4f3d31] focus-visible:ring-[#c8946f]/45":"border-white/10 bg-white/[0.04] text-slate-100 placeholder:text-slate-500")}),(0,s.jsxs)("div",{className:"mt-2.5 flex items-center gap-2",children:[(0,s.jsx)(I,{type:"button",size:"sm",variant:"secondary",disabled:w,onClick:()=>{E(null)},className:Z,children:"Reset"}),(0,s.jsx)(I,{type:"button",size:"sm",disabled:w,onClick:()=>{E(b)},className:X,children:w?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Saving..."]}):"Save"})]})]}),(0,s.jsxs)("div",{className:(0,S.cn)("mt-2 rounded-[16px] border px-2.5 py-2.5","light"===t?"border-[#e6d7cb] bg-[#fffaf6]":"border-white/8 bg-white/[0.03]"),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[11px] uppercase tracking-[0.18em]","light"===t?"text-[#9a7f6c]":"text-slate-400"),children:"Gateway"}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:(0,S.cn)("rounded-full border px-1.5 py-0.5 text-[8px] uppercase tracking-[0.18em]","light"===t?"border-[#dcc6b6] bg-[#f4e8dd] text-[#876c5a]":"border-white/10 bg-white/[0.05] text-slate-300"),children:e.diagnostics.bindMode||"default"}),(0,s.jsxs)("div",{className:"relative",ref:el,children:[(0,s.jsxs)(I,{type:"button",size:"sm",variant:"secondary",disabled:J,onClick:()=>{ei(e=>!e)},className:(0,S.cn)("inline-flex h-7 items-center gap-1 rounded-full border px-2.5 text-[8px] uppercase tracking-[0.18em] transition-[background-color,border-color,color,transform] duration-150 active:scale-[0.96]",e.diagnostics.rpcOk?"light"===t?"border-emerald-300 bg-emerald-50 text-emerald-700 hover:bg-emerald-100 hover:border-emerald-300 hover:text-emerald-700":"border-emerald-300/25 bg-emerald-300/10 text-emerald-200 hover:bg-emerald-300/16 hover:border-emerald-300/35":e.diagnostics.loaded?"light"===t?"border-amber-300 bg-amber-50 text-amber-700 hover:bg-amber-100 hover:border-amber-300 hover:text-amber-800":"border-amber-300/25 bg-amber-300/10 text-amber-200 hover:bg-amber-300/16 hover:border-amber-300/35":"light"===t?"border-rose-300 bg-rose-50 text-rose-700 hover:bg-rose-100 hover:border-rose-300 hover:text-rose-700":"border-rose-300/25 bg-rose-300/10 text-rose-200 hover:bg-rose-300/16 hover:border-rose-300/35"),"aria-haspopup":"menu","aria-expanded":en,"aria-label":`Gateway service status: ${eo}. Open actions menu.`,title:"Gateway actions",children:[(0,s.jsx)("span",{children:eo}),(0,s.jsx)(u.A,{className:"h-3 w-3 opacity-80"})]}),en?(0,s.jsxs)("div",{className:(0,S.cn)("absolute right-0 top-[calc(100%+8px)] z-30 min-w-[152px] rounded-[14px] border p-1.5 shadow-[0_20px_44px_rgba(0,0,0,0.42)] backdrop-blur-xl","light"===t?"border-[#d9c9bc] bg-[#fdfaf7]/98":"border-white/[0.1] bg-slate-950/96"),children:[(0,s.jsx)(r4,{icon:d.A,label:"start"===k?"Starting...":"Start",disabled:J||e.diagnostics.rpcOk,onClick:()=>{ei(!1),_("start")},surfaceTheme:t}),(0,s.jsx)(r4,{icon:n.A,label:"restart"===k?"Restarting...":"Restart",disabled:J||!e.diagnostics.loaded,onClick:()=>{ei(!1),_("restart")},surfaceTheme:t}),(0,s.jsx)(r4,{icon:h.A,label:"stop"===k?"Stopping...":"Stop",disabled:J||!e.diagnostics.loaded,onClick:()=>{ei(!1),_("stop")},surfaceTheme:t})]}):null]})]})]}),(0,s.jsxs)("div",{className:"mt-2 grid gap-2",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)(e$,{htmlFor:"gateway-url",className:"sr-only",children:"Gateway endpoint"}),(0,s.jsx)(T,{id:"gateway-url",value:l,onChange:e=>M(e.target.value),placeholder:"ws://127.0.0.1:18789",disabled:f,style:"light"===t?{colorScheme:"light"}:void 0,className:(0,S.cn)("h-8 min-w-0 rounded-[12px] px-2.5 font-mono text-[12px]","light"===t?"border-[#d9c9bc] bg-[#fffdfb] text-[#4f3d31] caret-[#7c5a46] placeholder:text-[#b29b8b] shadow-[inset_0_0_0_1000px_#fffdfb] [-webkit-text-fill-color:#4f3d31] focus-visible:ring-[#c8946f]/45":"border-white/10 bg-white/[0.04] text-slate-100 placeholder:text-slate-500")})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(I,{type:"button",size:"sm",variant:"secondary",disabled:f,onClick:()=>{$(null)},className:Z,children:"Local"}),(0,s.jsx)(I,{type:"button",size:"sm",disabled:f,onClick:()=>{$(l)},className:X,children:f?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.A,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}),"Saving..."]}):"Save"})]})]})]}),(0,s.jsxs)("div",{className:(0,S.cn)("mt-2 rounded-[16px] border px-2.5 py-2.5","light"===t?"border-rose-200 bg-[linear-gradient(135deg,rgba(255,245,245,0.96),rgba(255,236,236,0.92))]":"border-rose-400/18 bg-[linear-gradient(135deg,rgba(62,16,24,0.46),rgba(24,10,15,0.82))]"),children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:(0,S.cn)("text-[8px] uppercase tracking-[0.18em]","light"===t?"text-rose-700/80":"text-rose-200/75"),children:"Danger zone"}),(0,s.jsx)("p",{className:(0,S.cn)("mt-1 text-[10px] leading-[1.05rem]","light"===t?"text-rose-900/80":"text-rose-100/80"),children:"Review exactly which workspaces, agents, integration files, and packages would be removed before taking irreversible actions."})]}),(0,s.jsx)(o.A,{className:(0,S.cn)("mt-0.5 h-4 w-4","light"===t?"text-rose-700":"text-rose-200")})]}),(0,s.jsxs)("div",{className:"mt-3 grid gap-2",children:[(0,s.jsx)(I,{type:"button",size:"sm",variant:"secondary",onClick:()=>W("mission-control"),className:(0,S.cn)("justify-start","light"===t?"border-rose-200 bg-white text-rose-900 hover:bg-rose-50 hover:text-rose-900":"border-rose-400/20 bg-white/[0.04] text-rose-100 hover:bg-rose-500/10"),children:"Reset Mission Control"}),(0,s.jsx)(I,{type:"button",size:"sm",variant:"secondary",onClick:()=>W("full-uninstall"),className:(0,S.cn)("justify-start","light"===t?"border-rose-300 bg-rose-600 text-white hover:bg-rose-700":"border-rose-400/24 bg-rose-500/90 text-white hover:bg-rose-500"),children:"Full Uninstall"})]})]})]}):null]})})}function rY(e){return e.mission?.trim()?e.mission.trim():e.title.trim()?e.title.trim():e.subtitle.trim()||"Continue this task."}function rQ(e){let t,a;if(t="string"==typeof e.metadata.dispatchStatus?e.metadata.dispatchStatus:null,a=e.status,"cancelled"===t||"aborted"===t||"cancelled"===a||"aborted"===a)return!1;let s=e.status;return"running"===s||"queued"===s}function rZ(e,t){let a,s=(Array.isArray(a=e.metadata.optimisticEvents)?a.filter(r0):[]).concat(t.feedEvent);return{...e,dispatchId:t.dispatchId??e.dispatchId,status:t.status,subtitle:t.subtitle,updatedAt:Date.now(),liveRunCount:+("stalled"!==t.status&&"cancelled"!==t.status),warningCount:"stalled"===t.status||"cancelled"===t.status?1:e.warningCount,metadata:{...e.metadata,bootstrapStage:t.bootstrapStage,optimisticEvents:function(e){let t=new Map;for(let a of e)t.set(a.id,a);return[...t.values()].sort((e,t)=>Date.parse(e.timestamp)-Date.parse(t.timestamp))}(s)}}}function rX(e,t,a,s){let r=Array.isArray(t)?t:[],n=Array.isArray(a)?a:[];return!(Array.isArray(s)?s:[]).includes(e.key)&&(!!n.includes(e.key)||0!==e.runtimeIds.length&&e.runtimeIds.every(e=>r.includes(e)))}function r0(e){return"object"==typeof e&&null!==e&&"string"==typeof e.id&&"string"==typeof e.kind&&"string"==typeof e.timestamp&&"string"==typeof e.title&&"string"==typeof e.detail}function r1(e,t){let a=e.replace(/\s+/g," ").trim();return a.length<=t?a:`${a.slice(0,Math.max(t-1,1)).trimEnd()}…`}function r2(e){return(e.diagnostics.configuredGatewayUrl||e.diagnostics.gatewayUrl).replace(/\/$/,"")}function r5(e){return(0,eb.$7)(e.diagnostics.configuredWorkspaceRoot||e.diagnostics.workspaceRoot)}function r3(e,t){let a="h-8 rounded-[12px] border px-2.5 text-[9px] uppercase tracking-[0.18em] transition-[background-color,border-color,color,box-shadow,transform] duration-150 active:scale-[0.985]";return"primary"===t?(0,S.cn)(a,"light"===e?"border-[#c8946f] bg-[#c8946f] text-white shadow-[0_12px_28px_rgba(200,148,111,0.24)] hover:bg-[#b88461] hover:border-[#b88461] hover:text-white active:bg-[#a97553] active:border-[#a97553]":"border-cyan-300/30 bg-cyan-300 text-slate-950 shadow-[0_12px_28px_rgba(34,211,238,0.2)] hover:bg-cyan-200 hover:border-cyan-200 hover:text-slate-950 active:bg-cyan-100 active:border-cyan-100"):"warning"===t?(0,S.cn)(a,"light"===e?"border-amber-400/90 bg-amber-100 text-amber-900 shadow-[inset_0_1px_0_rgba(255,255,255,0.55)] hover:bg-amber-200 hover:border-amber-400 hover:text-amber-900 active:bg-amber-300":"border-amber-300/35 bg-amber-300/16 text-amber-100 shadow-[inset_0_1px_0_rgba(255,255,255,0.05)] hover:bg-amber-300/24 hover:border-amber-300/45 hover:text-amber-50 active:bg-amber-300/30"):"warningSolid"===t?(0,S.cn)(a,"light"===e?"border-amber-900 bg-amber-900 text-amber-50 shadow-[0_12px_28px_rgba(146,64,14,0.18)] hover:bg-amber-800 hover:border-amber-800 hover:text-amber-50 active:bg-amber-700 active:border-amber-700":"border-amber-300 bg-amber-300 text-slate-950 shadow-[0_12px_28px_rgba(245,158,11,0.18)] hover:bg-amber-200 hover:border-amber-200 hover:text-slate-950 active:bg-amber-100 active:border-amber-100"):(0,S.cn)(a,"light"===e?"border-[#d3bba9] bg-[#f1e3d7] text-[#6f5949] shadow-[inset_0_1px_0_rgba(255,255,255,0.55)] hover:bg-[#ead8ca] hover:border-[#caa98f] hover:text-[#5f4a3d] active:bg-[#dfc9b7] active:border-[#bf9c82]":"border-white/12 bg-white/[0.05] text-slate-200 shadow-[inset_0_1px_0_rgba(255,255,255,0.04)] hover:bg-white/[0.1] hover:border-white/16 hover:text-slate-100 active:bg-white/[0.14] active:border-white/20")}function r4({icon:e,label:t,disabled:a=!1,onClick:r,surfaceTheme:n}){return(0,s.jsxs)("button",{type:"button",disabled:a,className:(0,S.cn)("flex w-full items-center gap-2 rounded-[10px] px-2.5 py-2 text-left text-[11px] transition-colors",a?"light"===n?"cursor-not-allowed text-[#8f7866]/60":"cursor-not-allowed text-slate-400/60":"light"===n?"text-[#4f3d31] hover:bg-[#efe5dc] hover:text-[#34261d]":"text-slate-200 hover:bg-white/[0.06] hover:text-white"),onClick:r,children:[(0,s.jsx)(e,{className:"h-3.5 w-3.5 shrink-0"}),(0,s.jsx)("span",{children:t})]})}function r8(e,t){switch(e){case"healthy":return"light"===t?"border-emerald-300/80 bg-emerald-50 text-emerald-700":"border-emerald-400/25 bg-emerald-400/10 text-emerald-200";case"degraded":return"light"===t?"border-amber-300/90 bg-amber-50 text-amber-700":"border-amber-300/25 bg-amber-300/10 text-amber-200";default:return"light"===t?"border-rose-300/80 bg-rose-50 text-rose-700":"border-rose-300/25 bg-rose-300/10 text-rose-200"}}function r6(e){switch(e){case"healthy":return"bg-emerald-400";case"degraded":return"bg-amber-300";default:return"bg-rose-300"}}},3351:(e,t,a)=>{"use strict";a.d(t,{cn:()=>n});var s=a(5286),r=a(493);function n(...e){return(0,r.QP)((0,s.$)(e))}},6595:(e,t,a)=>{"use strict";a.d(t,{F:()=>l});var s=a(6366),r=a(430),n=a(6337),i=a(3351);let l=r.forwardRef(({className:e,children:t,...a},r)=>(0,s.jsxs)(n.bL,{ref:r,className:(0,i.cn)("relative overflow-hidden",e),...a,children:[(0,s.jsx)(n.LM,{className:"mission-scroll h-full w-full rounded-[inherit] [&>div]:!block [&>div]:!w-full [&>div]:!min-w-0",children:t}),(0,s.jsx)(o,{}),(0,s.jsx)(n.OK,{})]}));l.displayName=n.bL.displayName;let o=r.forwardRef(({className:e,orientation:t="vertical",...a},r)=>(0,s.jsx)(n.VM,{ref:r,orientation:t,className:(0,i.cn)("flex touch-none select-none transition-colors","vertical"===t&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===t&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...a,children:(0,s.jsx)(n.lr,{className:"relative flex-1 rounded-full bg-white/[0.12]"})}));o.displayName=n.VM.displayName},6761:(e,t,a)=>{"use strict";a.d(t,{E:()=>l});var s=a(6366);a(430);var r=a(5880),n=a(3351);let i=(0,r.F)("inline-flex items-center rounded-full border px-2.5 py-0.5 text-[11px] font-medium tracking-[0.14em] uppercase transition-colors",{variants:{variant:{default:"border-cyan-400/30 bg-cyan-400/10 text-cyan-200",muted:"border-white/10 bg-white/5 text-slate-300",success:"border-emerald-400/25 bg-emerald-400/10 text-emerald-200",warning:"border-amber-400/25 bg-amber-400/10 text-amber-100",danger:"border-rose-400/30 bg-rose-400/10 text-rose-100"}},defaultVariants:{variant:"default"}});function l({className:e,variant:t,...a}){return(0,s.jsx)("div",{className:(0,n.cn)(i({variant:t}),e),...a})}},7442:(e,t,a)=>{Promise.resolve().then(a.bind(a,3031))},8790:(e,t,a)=>{"use strict";a.d(t,{G:()=>u});var s=a(6366),r=a(8359),n=a(3688),i=a(8583),l=a(2711),o=a(3351);let d=/https?:\/\/[^\s<>"'`)\]]+/g,c=/\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/gi,p=/(?:^|[\s(])((?:\.{1,2}\/)?(?:deliverables|memory|docs|app|components|lib|public|scripts|packages|hooks|output)\/[^\s`),;]+)/g,m=/`((?:\/|\.{1,2}\/|deliverables\/|memory\/|docs\/|app\/|components\/|lib\/|public\/|scripts\/|packages\/|hooks\/|output\/)[^`\n]+)`/g;function u({text:e,className:t,url:a,filePath:i,displayPath:x,compact:g=!1}){let b=function(e,t){let a=new Set;for(let s of(t&&a.add(t),e.matchAll(d)))s[0]&&a.add(s[0]);return[...a]}(e,a),f=function(e){let t=new Set;for(let a of e.matchAll(c))a[0]&&t.add(a[0]);return[...t]}(e),w=function(e,t,a){let s=new Map;for(let r of(t&&s.set(t,{path:t,label:a||t}),e.matchAll(m))){let e=r[1]?.trim();!e||s.has(e)||s.set(e,{path:e,label:e})}for(let t of e.matchAll(p)){let e=t[1]?.trim();!e||s.has(e)||s.set(e,{path:e,label:e})}return[...s.values()]}(e,i,x);return(0,s.jsxs)("div",{className:(0,o.cn)("space-y-2",g&&"space-y-1.5"),children:[(0,s.jsx)("p",{className:(0,o.cn)("whitespace-pre-wrap break-words",t),children:function(e){let t=Array.from(e.matchAll(d));if(0===t.length)return e;let a=[],r=0;for(let[n]of t){let t=e.indexOf(n,r);t>r&&a.push(e.slice(r,t)),a.push((0,s.jsx)("a",{href:n,target:"_blank",rel:"noreferrer",className:"nodrag nopan text-cyan-100 underline decoration-cyan-200/45 underline-offset-2 transition-colors hover:text-cyan-50 hover:decoration-cyan-100",onClick:e=>e.stopPropagation(),children:n},`${n}:${t}`)),r=t+n.length}return r<e.length&&a.push(e.slice(r)),a}(e)}),b.length>0||f.length>0||w.length>0?(0,s.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[b.map(e=>(0,s.jsxs)("a",{href:e,target:"_blank",rel:"noreferrer",className:(0,o.cn)("nodrag nopan inline-flex max-w-full items-center gap-1 rounded-full border border-cyan-300/16 bg-cyan-400/[0.08] px-2 py-1 text-[10px] text-cyan-100 transition-colors hover:border-cyan-200/30 hover:bg-cyan-400/[0.14]",g&&"px-1.5 py-[3px] text-[9px]"),onClick:e=>e.stopPropagation(),children:[(0,s.jsx)(r.A,{className:(0,o.cn)("h-3 w-3 shrink-0",g&&"h-2.5 w-2.5")}),(0,s.jsx)("span",{className:"truncate",children:function(e){try{let t=new URL(e);return`${t.hostname}${"/"===t.pathname?"":t.pathname}`}catch{return e}}(e)})]},e)),f.map(e=>(0,s.jsxs)("a",{href:`mailto:${e}`,className:(0,o.cn)("nodrag nopan inline-flex max-w-full items-center gap-1 rounded-full border border-sky-300/16 bg-sky-400/[0.08] px-2 py-1 text-[10px] text-sky-50 transition-colors hover:border-sky-200/30 hover:bg-sky-400/[0.14]",g&&"px-1.5 py-[3px] text-[9px]"),onClick:e=>e.stopPropagation(),children:[(0,s.jsx)(r.A,{className:(0,o.cn)("h-3 w-3 shrink-0",g&&"h-2.5 w-2.5")}),(0,s.jsx)("span",{className:"truncate",children:e})]},e)),w.map(e=>(0,s.jsxs)("button",{type:"button",className:(0,o.cn)("nodrag nopan inline-flex max-w-full items-center gap-1 rounded-full border border-emerald-300/16 bg-emerald-400/[0.08] px-2 py-1 text-[10px] text-emerald-50 transition-colors hover:border-emerald-200/30 hover:bg-emerald-400/[0.14]",g&&"px-1.5 py-[3px] text-[9px]"),onClick:t=>{t.stopPropagation(),h(e.path)},children:[(0,s.jsx)(n.A,{className:(0,o.cn)("h-3 w-3 shrink-0",g&&"h-2.5 w-2.5")}),(0,s.jsx)("span",{className:"truncate",children:(0,l.$7)(e.label)})]},`${e.path}:${e.label}`))]}):null]})}async function h(e){try{let t=await fetch("/api/files/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e})}),a=await t.json();if(!t.ok)throw Error(a.error||"Unable to reveal file.");i.oR.success("Revealed file.",{description:(0,l.$7)(e)})}catch(e){i.oR.error("Could not reveal file.",{description:e instanceof Error?e.message:"Unknown file reveal error."})}}}},e=>{e.O(0,[2505,8583,5954,8807,4424,7358],()=>e(e.s=7442)),_N_E=e.O()}]);