@jiggai/kitchen 0.3.9 → 0.3.11

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 (200) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +2 -2
  3. package/.next/prerender-manifest.json +3 -3
  4. package/.next/server/app/_global-error.html +2 -2
  5. package/.next/server/app/_global-error.rsc +1 -1
  6. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  7. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  8. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  11. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  12. package/.next/server/app/_not-found.html +1 -1
  13. package/.next/server/app/_not-found.rsc +3 -3
  14. package/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
  15. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  16. package/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
  17. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  18. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  19. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  20. package/.next/server/app/agents/[agentId]/page_client-reference-manifest.js +1 -1
  21. package/.next/server/app/api/goals/[id]/promote/route.js.nft.json +1 -1
  22. package/.next/server/app/api/goals/[id]/route.js.nft.json +1 -1
  23. package/.next/server/app/api/goals/route.js.nft.json +1 -1
  24. package/.next/server/app/api/recipes/[id]/route.js.nft.json +1 -1
  25. package/.next/server/app/api/recipes/clone/route.js.nft.json +1 -1
  26. package/.next/server/app/api/recipes/custom-team/route.js.nft.json +1 -1
  27. package/.next/server/app/api/recipes/delete/route.js.nft.json +1 -1
  28. package/.next/server/app/api/recipes/team-agents/route.js.nft.json +1 -1
  29. package/.next/server/app/api/scaffold/route.js.nft.json +1 -1
  30. package/.next/server/app/api/teams/[teamId]/tickets/assign/route.js.nft.json +1 -1
  31. package/.next/server/app/api/teams/[teamId]/tickets/comment/route.js.nft.json +1 -1
  32. package/.next/server/app/api/teams/[teamId]/tickets/delete/route.js.nft.json +1 -1
  33. package/.next/server/app/api/teams/[teamId]/tickets/move/route.js.nft.json +1 -1
  34. package/.next/server/app/api/teams/[teamId]/tickets/move-to-goals/route.js.nft.json +1 -1
  35. package/.next/server/app/api/teams/orchestrator/route.js.nft.json +1 -1
  36. package/.next/server/app/api/teams/remove-team/route.js.nft.json +1 -1
  37. package/.next/server/app/api/tickets/assign/route.js.nft.json +1 -1
  38. package/.next/server/app/api/tickets/assignees/route.js.nft.json +1 -1
  39. package/.next/server/app/api/tickets/move/route.js.nft.json +1 -1
  40. package/.next/server/app/channels/page_client-reference-manifest.js +1 -1
  41. package/.next/server/app/channels.html +2 -2
  42. package/.next/server/app/channels.rsc +4 -4
  43. package/.next/server/app/channels.segments/_full.segment.rsc +4 -4
  44. package/.next/server/app/channels.segments/_head.segment.rsc +1 -1
  45. package/.next/server/app/channels.segments/_index.segment.rsc +3 -3
  46. package/.next/server/app/channels.segments/_tree.segment.rsc +2 -2
  47. package/.next/server/app/channels.segments/channels/__PAGE__.segment.rsc +2 -2
  48. package/.next/server/app/channels.segments/channels.segment.rsc +1 -1
  49. package/.next/server/app/cron-jobs/page_client-reference-manifest.js +1 -1
  50. package/.next/server/app/goals/[id]/page_client-reference-manifest.js +1 -1
  51. package/.next/server/app/goals/new/page_client-reference-manifest.js +1 -1
  52. package/.next/server/app/goals/new.html +2 -2
  53. package/.next/server/app/goals/new.rsc +4 -4
  54. package/.next/server/app/goals/new.segments/_full.segment.rsc +4 -4
  55. package/.next/server/app/goals/new.segments/_head.segment.rsc +1 -1
  56. package/.next/server/app/goals/new.segments/_index.segment.rsc +3 -3
  57. package/.next/server/app/goals/new.segments/_tree.segment.rsc +2 -2
  58. package/.next/server/app/goals/new.segments/goals/new/__PAGE__.segment.rsc +2 -2
  59. package/.next/server/app/goals/new.segments/goals/new.segment.rsc +1 -1
  60. package/.next/server/app/goals/new.segments/goals.segment.rsc +1 -1
  61. package/.next/server/app/goals/page_client-reference-manifest.js +1 -1
  62. package/.next/server/app/goals.html +1 -1
  63. package/.next/server/app/goals.rsc +4 -4
  64. package/.next/server/app/goals.segments/_full.segment.rsc +4 -4
  65. package/.next/server/app/goals.segments/_head.segment.rsc +1 -1
  66. package/.next/server/app/goals.segments/_index.segment.rsc +3 -3
  67. package/.next/server/app/goals.segments/_tree.segment.rsc +2 -2
  68. package/.next/server/app/goals.segments/goals/__PAGE__.segment.rsc +2 -2
  69. package/.next/server/app/goals.segments/goals.segment.rsc +1 -1
  70. package/.next/server/app/page.js +2 -2
  71. package/.next/server/app/page.js.nft.json +1 -1
  72. package/.next/server/app/page_client-reference-manifest.js +1 -1
  73. package/.next/server/app/recipes/[id]/page.js +3 -3
  74. package/.next/server/app/recipes/[id]/page.js.nft.json +1 -1
  75. package/.next/server/app/recipes/[id]/page_client-reference-manifest.js +1 -1
  76. package/.next/server/app/recipes/page.js +2 -2
  77. package/.next/server/app/recipes/page.js.nft.json +1 -1
  78. package/.next/server/app/recipes/page_client-reference-manifest.js +1 -1
  79. package/.next/server/app/runs/page.js +3 -3
  80. package/.next/server/app/runs/page.js.nft.json +1 -1
  81. package/.next/server/app/runs/page_client-reference-manifest.js +1 -1
  82. package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  83. package/.next/server/app/settings.html +1 -1
  84. package/.next/server/app/settings.rsc +4 -4
  85. package/.next/server/app/settings.segments/_full.segment.rsc +4 -4
  86. package/.next/server/app/settings.segments/_head.segment.rsc +1 -1
  87. package/.next/server/app/settings.segments/_index.segment.rsc +3 -3
  88. package/.next/server/app/settings.segments/_tree.segment.rsc +2 -2
  89. package/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +2 -2
  90. package/.next/server/app/settings.segments/settings.segment.rsc +1 -1
  91. package/.next/server/app/teams/[teamId]/page.js +3 -3
  92. package/.next/server/app/teams/[teamId]/page.js.nft.json +1 -1
  93. package/.next/server/app/teams/[teamId]/page_client-reference-manifest.js +1 -1
  94. package/.next/server/app/teams/[teamId]/runs/[workflowId]/[runId]/page.js +2 -2
  95. package/.next/server/app/teams/[teamId]/runs/[workflowId]/[runId]/page.js.nft.json +1 -1
  96. package/.next/server/app/teams/[teamId]/runs/[workflowId]/[runId]/page_client-reference-manifest.js +1 -1
  97. package/.next/server/app/teams/[teamId]/runs/page_client-reference-manifest.js +1 -1
  98. package/.next/server/app/teams/[teamId]/tickets/[ticket]/page.js.nft.json +1 -1
  99. package/.next/server/app/teams/[teamId]/tickets/[ticket]/page_client-reference-manifest.js +1 -1
  100. package/.next/server/app/teams/[teamId]/tickets/page.js.nft.json +1 -1
  101. package/.next/server/app/teams/[teamId]/tickets/page_client-reference-manifest.js +1 -1
  102. package/.next/server/app/teams/[teamId]/workflows/[workflowId]/page.js +3 -3
  103. package/.next/server/app/teams/[teamId]/workflows/[workflowId]/page.js.nft.json +1 -1
  104. package/.next/server/app/teams/[teamId]/workflows/[workflowId]/page_client-reference-manifest.js +1 -1
  105. package/.next/server/app/teams/[teamId]/workflows/page.js +3 -3
  106. package/.next/server/app/teams/[teamId]/workflows/page.js.nft.json +1 -1
  107. package/.next/server/app/teams/[teamId]/workflows/page_client-reference-manifest.js +1 -1
  108. package/.next/server/app/tickets/[ticket]/page.js.nft.json +1 -1
  109. package/.next/server/app/tickets/[ticket]/page_client-reference-manifest.js +1 -1
  110. package/.next/server/app/tickets/page.js.nft.json +1 -1
  111. package/.next/server/app/tickets/page_client-reference-manifest.js +1 -1
  112. package/.next/server/chunks/[root-of-the-server]__ff69832c._.js.map +1 -1
  113. package/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_1fe98a49.js +1 -1
  114. package/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_1fe98a49.js.map +1 -1
  115. package/.next/server/chunks/ssr/[root-of-the-server]__24c20736._.js +3 -0
  116. package/.next/server/chunks/ssr/[root-of-the-server]__24c20736._.js.map +1 -0
  117. package/.next/server/chunks/ssr/[root-of-the-server]__30619465._.js +3 -0
  118. package/.next/server/chunks/ssr/[root-of-the-server]__30619465._.js.map +1 -0
  119. package/.next/server/chunks/ssr/[root-of-the-server]__471bc2e7._.js +1 -1
  120. package/.next/server/chunks/ssr/[root-of-the-server]__471bc2e7._.js.map +1 -1
  121. package/.next/server/chunks/ssr/[root-of-the-server]__49281b4c._.js +1 -1
  122. package/.next/server/chunks/ssr/[root-of-the-server]__49281b4c._.js.map +1 -1
  123. package/.next/server/chunks/ssr/[root-of-the-server]__4981f370._.js +3 -0
  124. package/.next/server/chunks/ssr/[root-of-the-server]__4981f370._.js.map +1 -0
  125. package/.next/server/chunks/ssr/[root-of-the-server]__4c66998a._.js +3 -0
  126. package/.next/server/chunks/ssr/[root-of-the-server]__4c66998a._.js.map +1 -0
  127. package/.next/server/chunks/ssr/[root-of-the-server]__7fcc6175._.js +3 -0
  128. package/.next/server/chunks/ssr/[root-of-the-server]__7fcc6175._.js.map +1 -0
  129. package/.next/server/chunks/ssr/[root-of-the-server]__8e001110._.js +3 -0
  130. package/.next/server/chunks/ssr/[root-of-the-server]__8e001110._.js.map +1 -0
  131. package/.next/server/chunks/ssr/[root-of-the-server]__9a7d79aa._.js +1 -1
  132. package/.next/server/chunks/ssr/[root-of-the-server]__9a7d79aa._.js.map +1 -1
  133. package/.next/server/chunks/ssr/[root-of-the-server]__ad4e8478._.js +3 -0
  134. package/.next/server/chunks/ssr/[root-of-the-server]__ad4e8478._.js.map +1 -0
  135. package/.next/server/chunks/ssr/[root-of-the-server]__bd20cf10._.js +3 -0
  136. package/.next/server/chunks/ssr/[root-of-the-server]__bd20cf10._.js.map +1 -0
  137. package/.next/server/chunks/ssr/[root-of-the-server]__cefae8c8._.js +3 -0
  138. package/.next/server/chunks/ssr/[root-of-the-server]__cefae8c8._.js.map +1 -0
  139. package/.next/server/chunks/ssr/{node_modules_next_10fb6ad9._.js → _7f9e89d2._.js} +2 -2
  140. package/.next/server/chunks/ssr/_7f9e89d2._.js.map +1 -0
  141. package/.next/server/chunks/ssr/b1a17_app_teams_[teamId]_workflows_[workflowId]_workflows-editor-client_tsx_5e714aa2._.js +1 -1
  142. package/.next/server/chunks/ssr/b1a17_app_teams_[teamId]_workflows_[workflowId]_workflows-editor-client_tsx_5e714aa2._.js.map +1 -1
  143. package/.next/server/chunks/ssr/src_59477309._.js +1 -1
  144. package/.next/server/chunks/ssr/src_59477309._.js.map +1 -1
  145. package/.next/server/chunks/ssr/src_app_teams_[teamId]_team-editor_index_tsx_e68e9cbc._.js +1 -1
  146. package/.next/server/chunks/ssr/src_app_teams_[teamId]_team-editor_index_tsx_e68e9cbc._.js.map +1 -1
  147. package/.next/server/chunks/ssr/src_app_teams_[teamId]_workflows_workflows-client_tsx_12742cc9._.js +3 -0
  148. package/.next/server/chunks/ssr/src_app_teams_[teamId]_workflows_workflows-client_tsx_12742cc9._.js.map +1 -0
  149. package/.next/server/chunks/ssr/src_lib_errors_ts_f440efeb._.js +3 -0
  150. package/.next/server/chunks/ssr/src_lib_errors_ts_f440efeb._.js.map +1 -0
  151. package/.next/server/pages/404.html +1 -1
  152. package/.next/server/pages/500.html +2 -2
  153. package/.next/server/server-reference-manifest.js +1 -1
  154. package/.next/server/server-reference-manifest.json +1 -1
  155. package/.next/static/chunks/3e0d3a43014c0ad2.css +3 -0
  156. package/.next/static/chunks/43d0024279c6160e.js +1 -0
  157. package/.next/static/chunks/4f5e02a609758a0b.js +1 -0
  158. package/.next/static/chunks/5e3b1d0f61a651bf.js +1 -0
  159. package/.next/static/chunks/5f77499ca309ab9d.js +10 -0
  160. package/.next/static/chunks/be12a66bd736fad8.js +1 -0
  161. package/.next/static/chunks/{b28737d6a10af30d.js → ecdc9465f0e4d954.js} +1 -1
  162. package/README.md +6 -5
  163. package/openclaw.plugin.json +1 -1
  164. package/package.json +1 -1
  165. package/public/images/clawkitchen/home.png +0 -0
  166. package/public/images/clawkitchen/recipes.png +0 -0
  167. package/public/images/clawkitchen/runs.png +0 -0
  168. package/public/images/clawkitchen/team.png +0 -0
  169. package/public/images/clawkitchen/tickets.png +0 -0
  170. package/public/images/clawkitchen/workflows.png +0 -0
  171. package/.next/server/chunks/ssr/[root-of-the-server]__1d65fddf._.js +0 -3
  172. package/.next/server/chunks/ssr/[root-of-the-server]__1d65fddf._.js.map +0 -1
  173. package/.next/server/chunks/ssr/[root-of-the-server]__450d6006._.js +0 -3
  174. package/.next/server/chunks/ssr/[root-of-the-server]__450d6006._.js.map +0 -1
  175. package/.next/server/chunks/ssr/[root-of-the-server]__76f9757d._.js +0 -3
  176. package/.next/server/chunks/ssr/[root-of-the-server]__76f9757d._.js.map +0 -1
  177. package/.next/server/chunks/ssr/[root-of-the-server]__9ffebe91._.js +0 -3
  178. package/.next/server/chunks/ssr/[root-of-the-server]__9ffebe91._.js.map +0 -1
  179. package/.next/server/chunks/ssr/[root-of-the-server]__a26db919._.js +0 -3
  180. package/.next/server/chunks/ssr/[root-of-the-server]__a26db919._.js.map +0 -1
  181. package/.next/server/chunks/ssr/[root-of-the-server]__afaa71fe._.js +0 -3
  182. package/.next/server/chunks/ssr/[root-of-the-server]__afaa71fe._.js.map +0 -1
  183. package/.next/server/chunks/ssr/[root-of-the-server]__b577b475._.js +0 -3
  184. package/.next/server/chunks/ssr/[root-of-the-server]__b577b475._.js.map +0 -1
  185. package/.next/server/chunks/ssr/[root-of-the-server]__e94ab521._.js +0 -3
  186. package/.next/server/chunks/ssr/[root-of-the-server]__e94ab521._.js.map +0 -1
  187. package/.next/server/chunks/ssr/[root-of-the-server]__fb6781d4._.js +0 -3
  188. package/.next/server/chunks/ssr/[root-of-the-server]__fb6781d4._.js.map +0 -1
  189. package/.next/server/chunks/ssr/node_modules_next_10fb6ad9._.js.map +0 -1
  190. package/.next/server/chunks/ssr/src_e54f24fb._.js +0 -3
  191. package/.next/server/chunks/ssr/src_e54f24fb._.js.map +0 -1
  192. package/.next/static/chunks/42b3230688d0834c.js +0 -1
  193. package/.next/static/chunks/635adeaf329f2446.js +0 -1
  194. package/.next/static/chunks/6427cd3eaffdd572.js +0 -10
  195. package/.next/static/chunks/be874907adf946fd.js +0 -1
  196. package/.next/static/chunks/cfe32a0bce2eab2b.css +0 -3
  197. package/.next/static/chunks/e397a21bf5f13650.js +0 -1
  198. /package/.next/static/{AKnetF2w3rOYqZBVpzsLP → pW5SAQ1dzPcsq_66yy5po}/_buildManifest.js +0 -0
  199. /package/.next/static/{AKnetF2w3rOYqZBVpzsLP → pW5SAQ1dzPcsq_66yy5po}/_clientMiddlewareManifest.json +0 -0
  200. /package/.next/static/{AKnetF2w3rOYqZBVpzsLP → pW5SAQ1dzPcsq_66yy5po}/_ssgManifest.js +0 -0
@@ -0,0 +1 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,87090,e=>{"use strict";var t=e.i(43476),r=e.i(71645),a=e.i(22016),o=e.i(44355);function s(e){let t=new Set;for(let r of e)t.add(r);return t.size}function n(e,t){return`ck-wf-draft:${e}:${t}`}function i({teamId:e,workflowId:i,draft:l,llmTaskEnabled:d}){let c,x,m,p,u,h,g,v,b,[k,f]=(0,r.useState)("canvas"),[y,w]=(0,r.useState)(!1),[j,N]=(0,r.useState)({kind:"loading"}),[S,C]=(0,r.useState)(""),I=(0,r.useRef)(null),[A,T]=(0,r.useState)(!1),[$,M]=(0,r.useState)(1),L=(0,r.useRef)(null),[O,E]=(0,r.useState)(""),[B,R]=(0,r.useState)(null),[_,z]=(0,r.useState)({kind:"select"}),[U,W]=(0,r.useState)(""),[P,D]=(0,r.useState)([]),[J,F]=(0,r.useState)(""),[q,K]=(0,r.useState)([]),[Z,Y]=(0,r.useState)(""),V=(0,r.useMemo)(()=>/Tool not available:\s*gateway/i.test(String(Z||"")),[Z]),[H,X]=(0,r.useState)([]),[Q,G]=(0,r.useState)(!1),[ee,et]=(0,r.useState)(""),[er,ea]=(0,r.useState)(""),[eo,es]=(0,r.useState)(!1),[en,ei]=(0,r.useState)(""),[el,ed]=(0,r.useState)({}),[ec,ex]=(0,r.useState)(!1),[em,ep]=(0,r.useState)(!1),[eu,eh]=(0,r.useState)(""),[eg,ev]=(0,r.useState)(""),[eb,ek]=(0,r.useState)(""),[ef,ey]=(0,r.useState)("llm"),[ew,ej]=(0,r.useState)(""),[eN,eS]=(0,r.useState)(""),[eC,eI]=(0,r.useState)("");function eA(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function eT(e){if(!eA(e))return null;let t=eA(e.match)?e.match:null;if(!t)return null;let r=String(t.channel??"").trim();if(!r)return null;let a=String(e.agentId??"").trim(),o=String(t.accountId??"").trim(),s=eA(t.peer)?t.peer:null,n=s?String(s.kind??"").trim():"",i=s?String(s.id??"").trim():"",l=i||o;if(!l)return null;let d=a||(o?`${r}:account:${o}`:`${r}:${n}:${i}`),c=[r];return a&&c.push(a),o&&c.push(`account:${o}`),n&&i&&c.push(`${n}:${i}`),{id:d,label:c.join(" · "),channel:r,target:l}}(0,r.useEffect)(()=>{(async()=>{try{if(l){let t=sessionStorage.getItem(n(e,i));if(t)return void N({kind:"ready",jsonText:t});let r=JSON.stringify({schema:"clawkitchen.workflow.v1",id:i,name:"New workflow",timezone:"UTC",nodes:[{id:"start",type:"start",name:"start",x:80,y:80,config:{}},{id:"end",type:"end",name:"end",x:520,y:80,config:{}}],edges:[{id:"e1",from:"start",to:"end"}]},null,2)+"\n";N({kind:"ready",jsonText:r});try{sessionStorage.setItem(n(e,i),r)}catch{}return}let t=await fetch(`/api/teams/workflows?teamId=${encodeURIComponent(e)}&id=${encodeURIComponent(i)}`,{cache:"no-store"}),r=await t.json();if(!t.ok||!r.ok)throw Error(r.error||"Failed to load workflow");N({kind:"ready",jsonText:JSON.stringify(r.workflow,null,2)+"\n"})}catch(e){N({kind:"error",error:e instanceof Error?e.message:String(e)})}})()},[e,i,l]),(0,r.useEffect)(()=>{(async()=>{F("");try{let t=await fetch("/api/agents",{cache:"no-store"}),r=await t.json();if(!t.ok)throw Error(r.error||r.message||"Failed to load agents");let a=(Array.isArray(r.agents)?r.agents:[]).map(e=>({id:String(e.id??"").trim(),identityName:"string"==typeof e.identityName?e.identityName:void 0})).filter(t=>t.id&&t.id.startsWith(`${e}-`));D(a)}catch(e){F(e instanceof Error?e.message:String(e)),D([])}})()},[e]),(0,r.useEffect)(()=>{(async()=>{Y("");try{let e=await fetch("/api/channels/bindings",{cache:"no-store"}),t=await e.json();if(!e.ok||!1===t.ok)throw Error(t.error||"Failed to load bindings");let r=(Array.isArray(t.bindings)?t.bindings:[]).map(eT).filter(Boolean);K(r)}catch(e){Y(e instanceof Error?e.message:String(e)),K([])}})()},[]);let e$=(0,r.useCallback)(async()=>{ei(""),es(!0);try{let e=await fetch("/api/cron/jobs",{cache:"no-store"}),t=await e.json();if(!e.ok||!1===t.ok)throw Error(t.error||"Failed to load cron jobs");let r=Array.isArray(t.jobs)?t.jobs:[],a={};for(let e of r){if(!e||!e.enabled)continue;let t=String(e.agentId??"").trim();if(t){a[t]=!0;continue}if(e.scope&&"agent"===String(e.scope.kind)){let t=String(e.scope.id??"").trim();t&&(a[t]=!0)}}return ed(a),a}catch(e){return ei(e instanceof Error?e.message:String(e)),ed({}),{}}finally{es(!1)}},[]);(0,r.useEffect)(()=>{e$()},[e$]);let eM=(0,r.useMemo)(()=>{if("ready"!==j.kind)return{wf:null,err:""};try{return{wf:JSON.parse(j.jsonText),err:""}}catch(e){return{wf:null,err:e instanceof Error?e.message:String(e)}}},[j]),eL=(0,r.useMemo)(()=>eM.wf?function(e){let t=[],r=[];"clawkitchen.workflow.v1"!==e.schema&&t.push(`schema must be clawkitchen.workflow.v1 (got ${String(e.schema)})`),String(e.id||"").trim()||t.push("id is required"),String(e.name||"").trim()||t.push("name is required");let a=Array.isArray(e.nodes)?e.nodes:[],o=Array.isArray(e.edges)?e.edges:[],n=Array.isArray(e.triggers)?e.triggers:[],i=a.map(e=>String(e?.id??"").trim()).filter(Boolean);i.length!==a.length&&t.push("all nodes must have a non-empty id"),s(i)!==i.length&&t.push("node ids must be unique");let l=o.map(e=>String(e?.id??"").trim()).filter(Boolean);l.length!==o.length&&t.push("all edges must have a non-empty id"),s(l)!==l.length&&t.push("edge ids must be unique");let d=new Set(i);for(let e of o){let r=String(e?.from??"").trim(),a=String(e?.to??"").trim();if(!r||!a){t.push(`edge ${String(e?.id??"(missing id)")} must have from/to`);continue}d.has(r)||t.push(`edge ${String(e.id)} references missing from node: ${r}`),d.has(a)||t.push(`edge ${String(e.id)} references missing to node: ${a}`)}let c=a.filter(e=>"start"===e.type),x=a.filter(e=>"end"===e.type);for(let e of(c.length||r.push("no start node found"),c.length>1&&r.push("multiple start nodes found (MVP supports this, but execution semantics may be ambiguous)"),x.length||r.push("no end node found"),n))if("cron"===e.kind){(String(e.id||"").trim()||t.push("cron trigger missing id"),String(e.expr||"").trim())?5!==String(e.expr||"").trim().split(/\s+/).filter(Boolean).length&&r.push(`cron trigger ${String(e.id)} expr is not 5-field: ${String(e.expr)}`):t.push(`cron trigger ${String(e.id||"(missing id)")} missing expr`);let a=e.tz?String(e.tz).trim():"";a&&"UTC"!==a&&!a.includes("/")&&r.push(`cron trigger ${String(e.id)} tz doesn't look like an IANA timezone: ${String(e.tz)}`)}let m=e.meta&&"object"==typeof e.meta&&!Array.isArray(e.meta)?e.meta:{},p=String(m.approvalTarget??"").trim();for(let e of a){if("human_approval"!==e.type)continue;let t=e.config&&"object"==typeof e.config&&!Array.isArray(e.config)?e.config:{},a=String(t.target??t.chatId??"").trim(),o=String(t.provider??t.channel??"").trim();a||p||r.push(`human_approval node ${String(e.id)} has no target (set node.config.target or workflow.meta.approvalTarget)`),!a||o||String(m.approvalProvider??"").trim()||r.push(`human_approval node ${String(e.id)} has a target but no provider (set node.config.provider or workflow.meta.approvalProvider)`)}return{errors:t,warnings:r}}(eM.wf):{errors:[],warnings:[]},[eM.wf]),eO=(0,r.useMemo)(()=>{let e=eM.wf;if(!e)return{missingAgentOnNodeIds:[],requiredAgentIds:[],agentIdsMissingCron:[],ok:!0};let t=(e.nodes??[]).filter(e=>"start"!==e.type&&"end"!==e.type&&"human_approval"!==e.type),r=t.filter(e=>!String((e.config&&"object"==typeof e.config&&!Array.isArray(e.config)?e.config:{}).agentId??"").trim()).map(e=>e.id),a=Array.from(new Set(t.map(e=>String((e.config&&"object"==typeof e.config&&!Array.isArray(e.config)?e.config:{}).agentId??"").trim()).filter(Boolean))),o=a.filter(e=>!el[e]),s=0===r.length&&0===o.length;return{missingAgentOnNodeIds:r,requiredAgentIds:a,agentIdsMissingCron:o,ok:s}},[eM.wf,el]);function eE(t){let r=JSON.stringify(t,null,2)+"\n";if(N({kind:"ready",jsonText:r}),l)try{sessionStorage.setItem(n(e,i),r)}catch{}}async function eB(){if("ready"===j.kind&&eM.wf&&!eM.err&&!eL.errors.length){w(!0),C("");try{let t=await fetch("/api/teams/workflows",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:e,workflow:eM.wf})}),r=await t.json();if(!t.ok||!r.ok)throw Error(r.error||"Failed to save workflow");try{sessionStorage.removeItem(n(e,i))}catch{}}catch(e){C(e instanceof Error?e.message:String(e))}finally{w(!1)}}}if("loading"===j.kind)return(0,t.jsx)("div",{className:"ck-glass w-full p-6",children:"Loading…"});if("error"===j.kind)return(0,t.jsx)("div",{className:"ck-glass w-full p-6",children:j.error});let eR=!1===d?(0,t.jsxs)("div",{className:"mx-3 mb-3 rounded-[var(--ck-radius-sm)] border border-amber-500/30 bg-amber-500/10 p-3 text-sm",children:[(0,t.jsx)("div",{className:"font-medium text-amber-200",children:"LLM support is not enabled"}),(0,t.jsxs)("div",{className:"mt-1 text-[color:var(--ck-text-secondary)]",children:["Workflow LLM nodes require the optional built-in ",(0,t.jsx)("code",{className:"px-1",children:"llm-task"})," plugin."]}),(0,t.jsxs)("div",{className:"mt-2 text-[color:var(--ck-text-secondary)]",children:["Enable it with: ",(0,t.jsx)("code",{className:"px-1",children:"openclaw plugins enable llm-task"})," then run"," ",(0,t.jsx)("code",{className:"px-1",children:"openclaw gateway restart"}),"."]})]}):null;return(0,t.jsxs)("div",{className:"flex h-full min-h-0 w-full flex-1 flex-col",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 px-3 py-3",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,t.jsx)("a",{href:`/teams/${encodeURIComponent(e)}?tab=workflows`,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10",children:"Back"}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsxs)("div",{className:"truncate text-base font-medium text-[color:var(--ck-text-primary)]",children:[i,".workflow.json"]}),(0,t.jsxs)("div",{className:"mt-0.5 text-sm text-[color:var(--ck-text-tertiary)]",children:["Team: ",e]})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("div",{className:"flex overflow-hidden rounded-[var(--ck-radius-sm)] border border-white/10",children:[(0,t.jsx)("button",{type:"button",onClick:()=>f("canvas"),className:"canvas"===k?"bg-white/10 px-3 py-2 text-xs font-medium text-[color:var(--ck-text-primary)]":"bg-transparent px-3 py-2 text-xs font-medium text-[color:var(--ck-text-secondary)] hover:bg-white/5",children:"Canvas"}),(0,t.jsx)("button",{type:"button",onClick:()=>f("json"),className:"json"===k?"bg-white/10 px-3 py-2 text-xs font-medium text-[color:var(--ck-text-primary)]":"bg-transparent px-3 py-2 text-xs font-medium text-[color:var(--ck-text-secondary)] hover:bg-white/5",children:"JSON"})]}),(0,t.jsx)("input",{ref:I,type:"file",accept:"application/json,.json",className:"hidden",onChange:async t=>{let r=t.target.files?.[0];if(t.target.value="",r){C("");try{let t=await r.text(),a=JSON.parse(t);if(N({kind:"ready",jsonText:JSON.stringify(a,null,2)+"\n"}),l)try{sessionStorage.setItem(n(e,i),JSON.stringify(a,null,2)+"\n")}catch{}}catch(e){C(e instanceof Error?e.message:String(e))}}}}),(0,t.jsx)("button",{type:"button",disabled:y,onClick:()=>I.current?.click(),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)] shadow-[var(--ck-shadow-1)] hover:bg-white/10 disabled:opacity-50",children:"Import"}),(0,t.jsx)("button",{type:"button",disabled:!eM.wf||!!eM.err||eL.errors.length>0,onClick:function(){if(!eM.wf||eM.err||eL.errors.length)return;let e=`${eM.wf.id||i}.workflow.json`,t=new Blob([JSON.stringify(eM.wf,null,2)+"\n"],{type:"application/json"}),r=URL.createObjectURL(t),a=document.createElement("a");a.href=r,a.download=e,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(r)},className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)] shadow-[var(--ck-shadow-1)] hover:bg-white/10 disabled:opacity-50",children:"Export"}),(0,t.jsx)("button",{type:"button",disabled:y||!eM.wf||!!eM.err||eL.errors.length>0,onClick:eB,className:"rounded-[var(--ck-radius-sm)] bg-[var(--ck-accent-red)] px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] disabled:opacity-50",children:y?"Saving…":"Save"})]})]}),eR,eM.err?(0,t.jsxs)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-yellow-400/30 bg-yellow-500/10 p-3 text-sm text-yellow-100",children:["JSON parse error: ",eM.err]}):null,!eM.err&&eL.errors.length?(0,t.jsxs)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-3 text-sm text-red-100",children:[(0,t.jsx)("div",{className:"font-medium",children:"Workflow validation errors"}),(0,t.jsx)("ul",{className:"mt-2 list-disc space-y-1 pl-5",children:eL.errors.map(e=>(0,t.jsx)("li",{children:e},e))})]}):null,eM.err||eL.errors.length||!eL.warnings.length?null:(0,t.jsxs)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-yellow-400/30 bg-yellow-500/10 p-3 text-sm text-yellow-100",children:[(0,t.jsx)("div",{className:"font-medium",children:"Workflow validation warnings"}),(0,t.jsx)("ul",{className:"mt-2 list-disc space-y-1 pl-5",children:eL.warnings.map(e=>(0,t.jsx)("li",{children:e},e))})]}),S?(0,t.jsx)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-3 text-sm text-red-100",children:S}):null,(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 gap-0",children:["json"===k?(0,t.jsx)("textarea",{value:j.jsonText,onChange:t=>{let r=t.target.value;if(N({kind:"ready",jsonText:r}),l)try{sessionStorage.setItem(n(e,i),r)}catch{}},className:"h-full min-h-0 w-full flex-1 resize-none rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3 font-mono text-xs text-[color:var(--ck-text-primary)]"}):(0,t.jsx)("div",{ref:L,className:"relative h-full min-h-0 w-full flex-1 overflow-auto bg-black/20",onWheel:e=>{if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();let t=e.deltaY>0?-1:1;M(e=>Math.max(.5,Math.min(2.5,Math.round((e+.1*t)*10)/10)))},onClick:e=>{if("add-node"!==_.kind)return;let t=eM.wf;if(!t)return;let r=L.current;if(!r)return;let a=e.target;if(a&&a.closest("[data-wf-node='1']"))return;let o=r.getBoundingClientRect(),s=(e.clientX-o.left+r.scrollLeft)/$,n=(e.clientY-o.top+r.scrollTop)/$,i=_.nodeType.replace(/[^a-z0-9_\-]/gi,"_"),l=new Set(t.nodes.map(e=>e.id)),d=1,c=`${i}_${d}`;for(;l.has(c);)d++,c=`${i}_${d}`;let x=Math.max(0,s-90),m=Math.max(0,n-24),p={id:c,type:_.nodeType,name:c,x,y:m,config:{}};eE({...t,nodes:[...t.nodes,p]}),E(c),z({kind:"select"})},children:(0,t.jsxs)("div",{className:"relative",style:{width:2200*$,height:1200*$},children:[(0,t.jsxs)("div",{className:A?"absolute left-3 top-3 z-20 w-[44px] overflow-hidden rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/40 p-2 backdrop-blur":"absolute left-3 top-3 z-20 w-[260px] rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/40 p-2 backdrop-blur",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("div",{className:A?"hidden":"text-[10px] font-medium uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"Tools"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("div",{className:A?"hidden":"flex items-center gap-1",children:[(0,t.jsx)("button",{type:"button",onClick:()=>M(e=>Math.max(.5,Math.round((e-.1)*10)/10)),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[10px] text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:"Zoom out (Ctrl/Cmd+wheel)",children:"-"}),(0,t.jsxs)("div",{className:"min-w-[42px] text-center text-[10px] text-[color:var(--ck-text-tertiary)]",children:[Math.round(100*$),"%"]}),(0,t.jsx)("button",{type:"button",onClick:()=>M(e=>Math.min(2.5,Math.round((e+.1)*10)/10)),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[10px] text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:"Zoom in (Ctrl/Cmd+wheel)",children:"+"})]}),(0,t.jsx)("button",{type:"button",onClick:()=>T(e=>!e),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[10px] text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:A?"Expand":"Collapse",children:A?">":"<"})]})]}),A?(0,t.jsx)("div",{className:"mt-2 flex flex-col items-center gap-2",children:[{key:"select",label:"Select",active:"select"===_.kind,onClick:()=>{z({kind:"select"}),W("")},icon:(0,t.jsx)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M5 4l7 16 2-7 7-2L5 4Z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"})})},{key:"connect",label:"Connect",active:"connect"===_.kind,onClick:()=>{z(e=>"connect"===e.kind?{kind:"select"}:{kind:"connect"}),W("")},icon:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:[(0,t.jsx)("path",{d:"M10 13a5 5 0 0 1 0-7l1.2-1.2a5 5 0 0 1 7 7L17 12",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),(0,t.jsx)("path",{d:"M14 11a5 5 0 0 1 0 7L12.8 19.2a5 5 0 1 1-7-7L7 12",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})},{key:"llm",label:"LLM",active:"add-node"===_.kind&&"llm"===_.nodeType,onClick:()=>{z({kind:"add-node",nodeType:"llm"}),W("")},icon:(0,t.jsx)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M12 2l1.5 6.5L20 10l-6.5 1.5L12 18l-1.5-6.5L4 10l6.5-1.5L12 2Z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"})})},{key:"tool",label:"Tool",active:"add-node"===_.kind&&"tool"===_.nodeType,onClick:()=>{z({kind:"add-node",nodeType:"tool"}),W("")},icon:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:[(0,t.jsx)("path",{d:"M14.5 7.5l2 2-8.5 8.5H6v-2l8.5-8.5Z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M12 6a4 4 0 0 0-5 5l3-3 2 2 3-3A4 4 0 0 0 12 6Z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"})]})},{key:"condition",label:"If",active:"add-node"===_.kind&&"condition"===_.nodeType,onClick:()=>{z({kind:"add-node",nodeType:"condition"}),W("")},icon:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:[(0,t.jsx)("path",{d:"M7 4v7a3 3 0 0 0 3 3h7",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),(0,t.jsx)("path",{d:"M17 10l3 3-3 3",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})]})},{key:"delay",label:"Delay",active:"add-node"===_.kind&&"delay"===_.nodeType,onClick:()=>{z({kind:"add-node",nodeType:"delay"}),W("")},icon:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:[(0,t.jsx)("path",{d:"M12 7v5l3 2",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M21 12a9 9 0 1 1-9-9",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})},{key:"approval",label:"Approval",active:"add-node"===_.kind&&"human_approval"===_.nodeType,onClick:()=>{z({kind:"add-node",nodeType:"human_approval"}),W("")},icon:(0,t.jsx)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M20 6 9 17l-5-5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})})},{key:"end",label:"End",active:"add-node"===_.kind&&"end"===_.nodeType,onClick:()=>{z({kind:"add-node",nodeType:"end"}),W("")},icon:(0,t.jsx)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M7 7h10v10H7V7Z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"})})}].map(e=>(0,t.jsx)("button",{type:"button",onClick:e.onClick,className:e.active?"flex h-8 w-8 items-center justify-center rounded-[var(--ck-radius-sm)] bg-white/10 text-[color:var(--ck-text-primary)]":"flex h-8 w-8 items-center justify-center rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:e.label,"aria-label":e.label,children:e.icon},e.key))}):(0,t.jsxs)("div",{className:"mt-2 grid grid-cols-2 gap-2",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{z({kind:"select"}),W("")},className:"select"===_.kind?"rounded-[var(--ck-radius-sm)] bg-white/10 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]":"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-xs text-[color:var(--ck-text-secondary)] hover:bg-white/10",children:"Select"}),(0,t.jsx)("button",{type:"button",onClick:()=>{z({kind:"connect"}),W("")},className:"connect"===_.kind?"rounded-[var(--ck-radius-sm)] bg-white/10 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]":"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-xs text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:"Click a node, then click another node to create an edge",children:"Connect"}),[{t:"llm",label:"LLM"},{t:"tool",label:"Tool"},{t:"condition",label:"If"},{t:"delay",label:"Delay"},{t:"human_approval",label:"Approve"},{t:"end",label:"End"}].map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>{z({kind:"add-node",nodeType:e.t}),W("")},className:"add-node"===_.kind&&_.nodeType===e.t?"rounded-[var(--ck-radius-sm)] bg-white/10 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]":"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-xs text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:"Select tool, then click on the canvas to place",children:["+ ",e.label]},e.t))]}),!A&&"connect"===_.kind&&U?(0,t.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-secondary)]",children:["Connecting from: ",(0,t.jsx)("span",{className:"font-mono",children:U})]}):null,A||"add-node"!==_.kind?null:(0,t.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-secondary)]",children:["Click on the canvas to place a ",(0,t.jsx)("span",{className:"font-mono",children:_.nodeType})," node."]}),(0,t.jsxs)("div",{className:"mt-3 border-t border-white/10 pt-3",children:[(0,t.jsxs)("div",{className:A?"hidden":"flex items-center justify-between gap-2",children:[(0,t.jsx)("div",{className:"text-[10px] font-medium uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"Agents"}),(0,t.jsx)("div",{className:"text-[10px] text-[color:var(--ck-text-tertiary)]",children:"drag → node"})]}),A?(0,t.jsx)("button",{type:"button",onClick:()=>T(!1),className:"mt-2 flex h-8 w-8 items-center justify-center rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:"Expand to see agents","aria-label":"Expand to see agents",children:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:[(0,t.jsx)("path",{d:"M16 11a4 4 0 1 0-8 0",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),(0,t.jsx)("path",{d:"M4 20a8 8 0 0 1 16 0",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})}):(0,t.jsxs)(t.Fragment,{children:[J?(0,t.jsx)("div",{className:"mt-1 text-[11px] text-red-200",children:J}):null,(0,t.jsx)("div",{className:"mt-2 max-h-[140px] space-y-1 overflow-auto",children:P.length?P.map(r=>(0,t.jsx)("div",{draggable:!0,onDragStart:e=>{e.dataTransfer.setData("text/plain",r.id),e.dataTransfer.effectAllowed="copy"},className:"cursor-grab rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-xs text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:r.id,children:r.identityName?r.identityName:r.id.replace(`${e}-`,"")},r.id)):(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:"No team agents found."})})]})]})]}),(0,t.jsxs)("div",{className:"relative h-[1200px] w-[2200px]",style:{transform:`scale(${$})`,transformOrigin:"0 0"},children:[(0,t.jsx)("svg",{className:"pointer-events-none absolute inset-0 -z-10",width:2200,height:1200,style:{overflow:"visible"},children:(eM.wf?.edges??[]).map(e=>{let r=eM.wf;if(!r)return null;let a=r.nodes.find(t=>t.id===e.from),o=r.nodes.find(t=>t.id===e.to);if(!a||!o)return null;let s=("number"==typeof a.x?a.x:80)+90,n=("number"==typeof a.y?a.y:80)+24,i=("number"==typeof o.x?o.x:80)+90,l=("number"==typeof o.y?o.y:80)+24;return(0,t.jsx)("line",{x1:s,y1:n,x2:i,y2:l,stroke:"rgba(255,255,255,0.35)",strokeWidth:3},e.id)})}),(eM.wf?.nodes??[]).map((r,a)=>{let o="number"==typeof r.x?r.x:80+220*a,s="number"==typeof r.y?r.y:80,n=O===r.id;return(0,t.jsxs)("div",{role:"button",tabIndex:0,"data-wf-node":"1",draggable:"select"===_.kind||"connect"===_.kind,onDragStart:e=>{"select"===_.kind&&e.dataTransfer.setData("text/plain","")},onDragOver:e=>{e.dataTransfer.types.includes("text/plain")&&e.preventDefault()},onDrop:e=>{let t=eM.wf;if(!t)return;e.preventDefault(),e.stopPropagation();let a=String(e.dataTransfer.getData("text/plain")||"").trim();if(!a)return;let o=t.nodes.map(e=>{if(e.id!==r.id)return e;let t=e.config&&"object"==typeof e.config&&!Array.isArray(e.config)?e.config:{};return{...e,config:{...t,agentId:a}}});eE({...t,nodes:o}),E(r.id)},onClick:e=>{e.stopPropagation();let t=eM.wf;if("connect"===_.kind){if(!t)return;if(!U){W(r.id),E(r.id);return}let e=r.id;if(W(""),!U||!e||U===e||(t.edges??[]).some(t=>t.from===U&&t.to===e))return;let a=`e${Date.now()}`;eE({...t,edges:[...t.edges??[],{id:a,from:U,to:e}]}),z({kind:"select"});return}E(r.id)},onPointerDown:e=>{if("add-node"===_.kind||0!==e.button)return;let t=L.current;if(!t)return;let a=t.getBoundingClientRect();E(r.id);try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}e.preventDefault();let n=(e.clientX-a.left+t.scrollLeft)/$,i=(e.clientY-a.top+t.scrollTop)/$;R({nodeId:r.id,dx:n-o,dy:i-s})},onPointerUp:e=>{try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}R(null)},onPointerMove:e=>{if(!B||B.nodeId!==r.id)return;let t=eM.wf;if(!t)return;let a=L.current;if(!a)return;let o=a.getBoundingClientRect(),s=(e.clientX-o.left+a.scrollLeft)/$,n=(e.clientY-o.top+a.scrollTop)/$,i=s-B.dx,l=n-B.dy,d=t.nodes.map(e=>e.id===r.id?{...e,x:i,y:l}:e);N({kind:"ready",jsonText:JSON.stringify({...t,nodes:d},null,2)+"\n"})},className:n?"absolute z-10 cursor-grab rounded-[var(--ck-radius-sm)] border border-white/25 bg-white/10 px-3 py-2 text-xs text-[color:var(--ck-text-primary)] shadow-[var(--ck-shadow-1)]":"absolute z-10 cursor-grab rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-xs text-[color:var(--ck-text-secondary)] hover:bg-white/10",style:{left:o,top:s,width:180},children:[(0,t.jsx)("div",{className:"font-medium text-[color:var(--ck-text-primary)]",children:r.name||r.id}),(0,t.jsx)("div",{className:"mt-0.5 text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:r.type}),(()=>{let a=r.config&&"object"==typeof r.config&&!Array.isArray(r.config)?r.config:null,o=a?String(a.agentId??"").trim():"";if(!o)return null;let s=o.replace(`${e}-`,"");return(0,t.jsxs)("div",{className:"mt-1 text-[10px] text-[color:var(--ck-text-secondary)]",children:["Agent: ",s]})})()]},r.id)}),(()=>{let e=eM.wf;if(!e||!O)return null;let r=e.nodes.find(e=>e.id===O);if(!r)return null;let a="number"==typeof r.x?r.x:80,o="number"==typeof r.y?r.y:80,s=r.config&&"object"==typeof r.config&&!Array.isArray(r.config)?r.config:{},n=String(s.agentId??"").trim();return(0,t.jsxs)("div",{className:"absolute z-10 w-[320px] rounded-[var(--ck-radius-sm)] border border-white/15 bg-black/60 p-3 shadow-[var(--ck-shadow-1)] backdrop-blur",style:{left:a+200,top:o},children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-primary)]",children:r.name||r.id}),(0,t.jsx)("button",{type:"button",onClick:()=>E(""),className:"text-[10px] text-[color:var(--ck-text-tertiary)] hover:text-[color:var(--ck-text-primary)]",children:"Close"})]}),(0,t.jsxs)("div",{className:"mt-2 space-y-2",children:[(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"name"}),(0,t.jsx)("input",{value:String(r.name??""),onChange:t=>{let a=t.target.value;eE({...e,nodes:e.nodes.map(e=>e.id===r.id?{...e,name:a}:e)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/30 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"Optional"})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"type"}),(0,t.jsxs)("select",{value:r.type,onChange:t=>{let a=t.target.value;eE({...e,nodes:e.nodes.map(e=>e.id===r.id?{...e,type:a}:e)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/30 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",children:[(0,t.jsx)("option",{value:"start",children:"start"}),(0,t.jsx)("option",{value:"end",children:"end"}),(0,t.jsx)("option",{value:"llm",children:"llm"}),(0,t.jsx)("option",{value:"tool",children:"tool"}),(0,t.jsx)("option",{value:"condition",children:"condition"}),(0,t.jsx)("option",{value:"delay",children:"delay"}),(0,t.jsx)("option",{value:"human_approval",children:"human_approval"})]})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"agentId"}),(0,t.jsx)("input",{value:n,onChange:t=>{let a=String(t.target.value||"").trim(),o={...s,...a?{agentId:a}:{}};a||delete o.agentId,eE({...e,nodes:e.nodes.map(e=>e.id===r.id?{...e,config:o}:e)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/30 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"(drag an agent onto the node or type)"})]}),"human_approval"===r.type?(0,t.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-2",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"approval config"}),(0,t.jsxs)("div",{className:"mt-2 space-y-2",children:[(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"provider"}),(0,t.jsx)("input",{value:String(s.provider??""),onChange:t=>{let a=String(t.target.value||"").trim(),o={...s,...a?{provider:a}:{}};a||delete o.provider,eE({...e,nodes:e.nodes.map(e=>e.id===r.id?{...e,config:o}:e)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"telegram"})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"target"}),(0,t.jsx)("input",{value:String(s.target??""),onChange:t=>{let a=String(t.target.value||"").trim(),o={...s,...a?{target:a}:{}};a||delete o.target,eE({...e,nodes:e.nodes.map(e=>e.id===r.id?{...e,config:o}:e)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"(e.g. Telegram chat id)"}),(0,t.jsx)("div",{className:"mt-1 text-[10px] text-[color:var(--ck-text-tertiary)]",children:"Overrides workflow-level default when set."})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"messageTemplate (optional)"}),(0,t.jsx)("textarea",{value:String(s.messageTemplate??""),onChange:t=>{let a=String(t.target.value||""),o={...s,...a.trim()?{messageTemplate:a}:{}};a.trim()||delete o.messageTemplate,eE({...e,nodes:e.nodes.map(e=>e.id===r.id?{...e,config:o}:e)})},className:"mt-1 h-[70px] w-full resize-none rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2 font-mono text-[10px] text-[color:var(--ck-text-primary)]",placeholder:"Approval needed for {{workflowName}} (run {{runId}})",spellCheck:!1}),(0,t.jsxs)("div",{className:"mt-1 text-[10px] text-[color:var(--ck-text-tertiary)]",children:["Vars: ","{{workflowName}}",", ","{{workflowId}}",", ","{{runId}}",", ","{{nodeId}}"]})]})]})]}):null,(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"config (json)"}),(0,t.jsx)("textarea",{value:JSON.stringify(s,null,2),onChange:t=>{try{let a=JSON.parse(t.target.value);if(!a||"object"!=typeof a||Array.isArray(a))return;eE({...e,nodes:e.nodes.map(e=>e.id===r.id?{...e,config:a}:e)})}catch{}},className:"mt-1 h-[140px] w-full resize-none rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/30 p-2 font-mono text-[10px] text-[color:var(--ck-text-primary)]",spellCheck:!1}),(0,t.jsx)("div",{className:"mt-1 text-[10px] text-[color:var(--ck-text-tertiary)]",children:"(Edits apply when JSON is valid.)"})]})]})]})})()]})]})}),(0,t.jsx)("div",{className:"w-[380px] shrink-0 overflow-auto p-3 text-sm",children:(0,t.jsx)("div",{className:"space-y-3",children:eM.wf?(x=String((c=eM.wf).timezone??"").trim()||"UTC",m=c.triggers??[],u=String((p=c.meta&&"object"==typeof c.meta&&!Array.isArray(c.meta)?c.meta:{}).approvalBindingId??"").trim(),h=String(p.approvalProvider??"telegram").trim()||"telegram",g=String(p.approvalTarget??"").trim(),v=[{label:"(no preset)",expr:""},{label:"Weekdays 09:00 local",expr:"0 9 * * 1-5"},{label:"Mon/Wed/Fri 09:00 local",expr:"0 9 * * 1,3,5"},{label:"Daily 08:00 local",expr:"0 8 * * *"},{label:"Daily 12:00 local",expr:"0 12 * * *"},{label:"Mon 09:30 local",expr:"30 9 * * 1"}],(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("details",{open:!0,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/15",children:[(0,t.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Workflow"}),(0,t.jsx)("div",{className:"px-3 pb-3",children:(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[11px] font-medium text-[color:var(--ck-text-tertiary)]",children:"Timezone"}),(0,t.jsx)("input",{value:x,onChange:e=>{let t=String(e.target.value||"").trim()||"UTC";eE({...c,timezone:t})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-sm text-[color:var(--ck-text-primary)]",placeholder:"America/New_York"})]})})]}),(0,t.jsxs)("details",{open:!0,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/15",children:[(0,t.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Approval Channel"}),(0,t.jsxs)("div",{className:"px-3 pb-3 space-y-2",children:[(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"binding (recommended)"}),(0,t.jsxs)("select",{value:u,onChange:e=>{let t=String(e.target.value||"").trim(),r=q.find(e=>e.id===t);r?eE({...c,meta:{...p,approvalBindingId:r.id,approvalProvider:r.channel,approvalTarget:r.target},nodes:c.nodes.map(e=>"human_approval"===e.type?{...e,config:{...e.config&&"object"==typeof e.config&&!Array.isArray(e.config)?e.config:{},approvalBindingId:r.id,provider:r.channel,target:r.target}}:e)}):eE({...c,meta:{...p,approvalBindingId:""},nodes:c.nodes.map(e=>"human_approval"===e.type?{...e,config:{...e.config&&"object"==typeof e.config&&!Array.isArray(e.config)?e.config:{},approvalBindingId:""}}:e)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",children:[(0,t.jsx)("option",{value:"",children:"(manual)"}),q.map(e=>(0,t.jsx)("option",{value:e.id,children:e.label},e.id))]}),V?(0,t.jsxs)("div",{className:"mt-1 text-[10px] text-yellow-200",children:["Kitchen looks out of date. Run ",(0,t.jsx)("code",{className:"font-mono",children:"openclaw plugins update"})," then",(0,t.jsx)("code",{className:"ml-1 font-mono",children:"openclaw gateway restart"}),"."]}):null,Z?(0,t.jsxs)("div",{className:"mt-1 text-[10px] text-red-200",children:["Failed to load bindings: ",Z]}):null,(0,t.jsx)("div",{className:"mt-1 text-[10px] text-[color:var(--ck-text-tertiary)]",children:"Uses your existing OpenClaw bindings (recommended). Manual provider/target is an advanced override."})]}),(0,t.jsxs)("details",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/10",children:[(0,t.jsx)("summary",{className:"cursor-pointer list-none px-2 py-1 text-[11px] font-medium text-[color:var(--ck-text-secondary)]",children:"Advanced: manual override"}),(0,t.jsxs)("div",{className:"px-2 pb-2 pt-1 space-y-2",children:[(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"provider"}),(0,t.jsx)("input",{value:h,onChange:e=>{let t=String(e.target.value||"").trim()||"telegram";eE({...c,meta:{...p,approvalBindingId:"",approvalProvider:t},nodes:c.nodes.map(e=>"human_approval"===e.type?{...e,config:{...e.config&&"object"==typeof e.config&&!Array.isArray(e.config)?e.config:{},approvalBindingId:"",provider:t}}:e)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"telegram"})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"target"}),(0,t.jsx)("input",{value:g,onChange:e=>{let t=String(e.target.value||"").trim();eE({...c,meta:{...p,approvalBindingId:"",approvalTarget:t},nodes:c.nodes.map(e=>"human_approval"===e.type?{...e,config:{...e.config&&"object"==typeof e.config&&!Array.isArray(e.config)?e.config:{},approvalBindingId:"",target:t}}:e)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"(e.g. Telegram chat id)"})]})]})]})]})]}),(0,t.jsxs)("details",{open:!0,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/15",children:[(0,t.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Triggers"}),(0,t.jsxs)("div",{className:"px-3 pb-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"triggers"}),(0,t.jsx)("button",{type:"button",onClick:()=>{let e=`t${Date.now()}`;eE({...c,triggers:[...m,{kind:"cron",id:e,name:"New trigger",enabled:!0,expr:"0 9 * * 1-5",tz:x}]})},className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[10px] font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10",children:"+ Add"})]}),(0,t.jsx)("div",{className:"mt-2 space-y-2",children:m.length?m.map((e,r)=>{let a=e.kind,o=String(e.id??""),s=String(e.name??""),n=!!e.enabled,i=String(e.expr??""),l=String(e.tz??x),d=i.trim().split(/\s+/).filter(Boolean),p=!i.trim()||5===d.length;return(0,t.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-primary)]",children:s||o||`trigger-${r+1}`}),(0,t.jsx)("button",{type:"button",onClick:()=>eE({...c,triggers:m.filter((e,t)=>t!==r)}),className:"text-[10px] text-[color:var(--ck-text-tertiary)] hover:text-[color:var(--ck-text-primary)]",children:"Remove"})]}),"cron"===a?null:(0,t.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-secondary)]",children:["Unsupported trigger kind: ",String(a)]}),(0,t.jsxs)("div",{className:"mt-2 grid grid-cols-1 gap-2",children:[(0,t.jsxs)("label",{className:"flex items-center gap-2 text-xs text-[color:var(--ck-text-secondary)]",children:[(0,t.jsx)("input",{type:"checkbox",checked:n,onChange:e=>{let t=e.target.checked;eE({...c,triggers:m.map((e,a)=>a===r&&"cron"===e.kind?{...e,enabled:t}:e)})}}),"Enabled"]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"name"}),(0,t.jsx)("input",{value:s,onChange:e=>{let t=e.target.value;eE({...c,triggers:m.map((e,a)=>a===r&&"cron"===e.kind?{...e,name:t}:e)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"Content cadence"})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"schedule (cron)"}),(0,t.jsx)("input",{value:i,onChange:e=>{let t=e.target.value;eE({...c,triggers:m.map((e,a)=>a===r&&"cron"===e.kind?{...e,expr:t}:e)})},className:p?"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 font-mono text-[11px] text-[color:var(--ck-text-primary)]":"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-red-400/50 bg-black/25 px-2 py-1 font-mono text-[11px] text-[color:var(--ck-text-primary)]",placeholder:"0 9 * * 1,3,5"}),p?null:(0,t.jsxs)("div",{className:"mt-1 text-[10px] text-red-200",children:["Cron should be 5 fields (min hour dom month dow). You entered ",d.length,"."]}),(0,t.jsxs)("div",{className:"mt-1 grid grid-cols-1 gap-1",children:[(0,t.jsx)("select",{value:v.some(e=>e.expr===i)?i:"",onChange:e=>{let t=e.target.value;eE({...c,triggers:m.map((e,a)=>a===r&&"cron"===e.kind?{...e,expr:t}:e)})},className:"w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-[11px] text-[color:var(--ck-text-secondary)]",children:v.map(e=>(0,t.jsx)("option",{value:e.expr,children:e.label},e.label))}),(0,t.jsx)("div",{className:"text-[10px] text-[color:var(--ck-text-tertiary)]",children:"Presets set the cron; edit freely for advanced schedules."})]})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"timezone override"}),(0,t.jsx)("input",{value:l,onChange:e=>{let t=String(e.target.value||"").trim()||x;eE({...c,triggers:m.map((e,a)=>a===r&&"cron"===e.kind?{...e,tz:t}:e)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:x})]})]})]},`${o}-${r}`)}):(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-secondary)]",children:"No triggers yet."})})]})]}),(0,t.jsxs)("details",{open:!0,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/15",children:[(0,t.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Runs"}),(0,t.jsxs)("div",{className:"px-3 pb-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Runs (history)"}),(0,t.jsx)(a.default,{href:`/teams/${encodeURIComponent(e)}/runs`,className:"text-[10px] font-medium text-[color:var(--ck-text-tertiary)] hover:text-[color:var(--ck-text-secondary)] hover:underline",children:"View all →"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("button",{type:"button",disabled:y,onClick:async()=>{let t=String(c.id??"").trim();if(t){et(""),G(!0);try{let r=await fetch("/api/teams/workflow-runs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:e,workflowId:t,mode:"enqueue"})}),a=await r.json();if(!r.ok||!a.ok)throw Error(a.error||"Failed to enqueue run");let o=await fetch(`/api/teams/workflow-runs?teamId=${encodeURIComponent(e)}&workflowId=${encodeURIComponent(t)}`,{cache:"no-store"}),s=await o.json();if(!o.ok||!s.ok)throw Error(s.error||"Failed to refresh runs");let n=(Array.isArray(s.files)?s.files:[]).map(e=>String(e??"").trim()).filter(e=>!!e);X(n)}catch(e){et(e instanceof Error?e.message:String(e))}finally{G(!1)}}},className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[10px] font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:"+ Queue run"}),(0,t.jsx)("button",{type:"button",disabled:y||eo||!eO.ok,onClick:async()=>{let t=String(c.id??"").trim();if(t){if(eO.missingAgentOnNodeIds.length)return void et("All nodes must be assigned to an agent.");if(eO.agentIdsMissingCron.length){ep(!0),eh("");try{let t=await fetch("/api/cron/worker",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:"reconcile",teamId:e})}),r=await t.json();if(!t.ok||!1===r.ok)throw Error(r.error||"Failed to reconcile worker crons");let a=await e$(),o=eO.requiredAgentIds.filter(e=>!a[e]);if(o.length)return void et(`Cron not set up for: ${o.join(", ")}`)}catch(e){et(e instanceof Error?e.message:String(e));return}finally{ep(!1)}}et(""),G(!0);try{let r=await fetch("/api/teams/workflow-runs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:e,workflowId:t,mode:"run_now"})}),a=await r.json();if(!r.ok||!a.ok)throw Error(a.error||"Failed to create run");let o=await fetch(`/api/teams/workflow-runs?teamId=${encodeURIComponent(e)}&workflowId=${encodeURIComponent(t)}`,{cache:"no-store"}),s=await o.json();if(!o.ok||!s.ok)throw Error(s.error||"Failed to refresh runs");let n=(Array.isArray(s.files)?s.files:[]).map(e=>String(e??"").trim()).filter(e=>!!e);X(n)}catch(e){et(e instanceof Error?e.message:String(e))}finally{G(!1)}}},className:"rounded-[var(--ck-radius-sm)] border border-emerald-400/30 bg-emerald-500/10 px-2 py-1 text-[10px] font-medium text-emerald-50 hover:bg-emerald-500/15 disabled:opacity-50",title:"Enqueue a run for the workflow runner (Kitchen does not execute nodes)",children:"+ Run now"}),en?(0,t.jsx)("div",{className:"ml-2 text-[10px] text-amber-100/90",title:en,children:"Cron check unavailable"}):null]})]}),eO.missingAgentOnNodeIds.length?(0,t.jsxs)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-2 text-xs text-red-100",children:["All nodes must be assigned to an agent. Missing agentId on: ",eO.missingAgentOnNodeIds.join(", ")]}):eO.agentIdsMissingCron.length?(0,t.jsxs)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-amber-400/30 bg-amber-500/10 p-2 text-xs text-amber-50",children:[(0,t.jsxs)("div",{children:["Cron not set up for: ",eO.agentIdsMissingCron.join(", ")]}),(0,t.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{eh(""),ex(!0)},className:"rounded-[var(--ck-radius-sm)] border border-amber-300/30 bg-amber-500/10 px-2 py-1 text-[10px] font-medium text-amber-50 hover:bg-amber-500/15",children:"Install worker cron(s)"}),(0,t.jsx)("button",{type:"button",onClick:()=>void e$(),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[10px] font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10",children:"Re-check"})]})]}):null,(0,t.jsx)(o.ConfirmationModal,{open:ec,title:"Install worker cron jobs?",busy:em,error:eu||void 0,confirmLabel:"Install",onClose:()=>{em||ex(!1)},onConfirm:async()=>{ep(!0),eh("");try{let t=await fetch("/api/cron/worker",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:"reconcile",teamId:e})}),r=await t.json();if(!t.ok||!1===r.ok)throw Error(r.error||"Failed to install worker crons");await e$(),ex(!1)}catch(e){eh(e instanceof Error?e.message:String(e))}finally{ep(!1)}},children:(0,t.jsxs)("div",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:["Kitchen will install (or enable) worker cron jobs for the following agents so this workflow can drain:",(0,t.jsx)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2 font-mono text-[11px] text-[color:var(--ck-text-primary)]",children:eO.agentIdsMissingCron.join(", ")}),(0,t.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:["Cron cadence: 1 minute. The worker runs: ",(0,t.jsx)("span",{className:"font-mono",children:"openclaw recipes workflows worker-tick"}),"."]})]})}),ee?(0,t.jsx)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-2 text-xs text-red-100",children:ee}):null,(0,t.jsx)("div",{className:"mt-2 space-y-1",children:Q?(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-secondary)]",children:"Loading runs…"}):H.length?H.slice(0,8).map(r=>{let o=String(c.id??"").trim(),s=String(r).replace(/\.run\.json$/i,""),n=er===s,i=o?`/teams/${encodeURIComponent(e)}/runs/${encodeURIComponent(o)}/${encodeURIComponent(s)}`:"#";return(0,t.jsx)(a.default,{href:i,onClick:()=>ea(s),className:n?"block w-full rounded-[var(--ck-radius-sm)] bg-white/10 px-2 py-1 text-left text-[11px] font-mono text-[color:var(--ck-text-primary)]":"block w-full rounded-[var(--ck-radius-sm)] px-2 py-1 text-left text-[11px] font-mono text-[color:var(--ck-text-secondary)] hover:bg-white/5",title:"Open run detail",children:s},r)}):(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-secondary)]",children:"No runs yet."})}),(0,t.jsxs)("details",{open:!0,className:"mt-3 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/10",children:[(0,t.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Nodes"}),(0,t.jsxs)("div",{className:"px-3 pb-3",children:[(0,t.jsx)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2",children:(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-2",children:[(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"id"}),(0,t.jsx)("input",{value:eg,onChange:e=>ev(e.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"e.g. draft_assets"})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"name (optional)"}),(0,t.jsx)("input",{value:eb,onChange:e=>ek(e.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"Human-friendly label"})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"type"}),(0,t.jsxs)("select",{value:ef,onChange:e=>ey(e.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",children:[(0,t.jsx)("option",{value:"start",children:"start"}),(0,t.jsx)("option",{value:"end",children:"end"}),(0,t.jsx)("option",{value:"llm",children:"llm"}),(0,t.jsx)("option",{value:"tool",children:"tool"}),(0,t.jsx)("option",{value:"condition",children:"condition"}),(0,t.jsx)("option",{value:"delay",children:"delay"}),(0,t.jsx)("option",{value:"human_approval",children:"human_approval"})]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>{let e=String(eg||"").trim().replace(/[^a-z0-9_\-]/gi,"_");if(!e||c.nodes.some(t=>t.id===e))return;let t=c.nodes.reduce((e,t)=>"number"==typeof t.x?Math.max(e,t.x):e,80),r={id:e,type:ef,name:String(eb||"").trim()||e,x:t+220,y:80};eE({...c,nodes:[...c.nodes,r]}),E(e),ev(""),ek("")},className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[11px] font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10",children:"+ Add node"})]})}),(0,t.jsx)("div",{className:"mt-2 space-y-1",children:c.nodes.map(e=>{let r=O===e.id;return(0,t.jsxs)("button",{type:"button",onClick:()=>E(e.id),className:r?"w-full rounded-[var(--ck-radius-sm)] bg-white/10 px-2 py-1 text-left text-[11px] text-[color:var(--ck-text-primary)]":"w-full rounded-[var(--ck-radius-sm)] px-2 py-1 text-left text-[11px] text-[color:var(--ck-text-secondary)] hover:bg-white/5",children:[(0,t.jsx)("span",{className:"font-mono",children:e.id}),(0,t.jsx)("span",{className:"ml-2 text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:e.type})]},e.id)})})]})]}),(0,t.jsxs)("details",{open:!0,className:"mt-3 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/10",children:[(0,t.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Edges"}),(0,t.jsxs)("div",{className:"px-3 pb-3",children:[(0,t.jsx)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2",children:(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-2",children:[(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"from"}),(0,t.jsxs)("select",{value:ew,onChange:e=>ej(e.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",children:[(0,t.jsx)("option",{value:"",children:"(select)"}),c.nodes.map(e=>(0,t.jsx)("option",{value:e.id,children:e.id},e.id))]})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"to"}),(0,t.jsxs)("select",{value:eN,onChange:e=>eS(e.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",children:[(0,t.jsx)("option",{value:"",children:"(select)"}),c.nodes.map(e=>(0,t.jsx)("option",{value:e.id,children:e.id},e.id))]})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"label (optional)"}),(0,t.jsx)("input",{value:eC,onChange:e=>eI(e.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"e.g. approve"})]}),(0,t.jsx)("button",{type:"button",onClick:()=>{let e=String(ew||"").trim(),t=String(eN||"").trim();if(!e||!t||e===t)return;let r={id:`e${Date.now()}`,from:e,to:t,...String(eC||"").trim()?{label:String(eC).trim()}:{}};eE({...c,edges:[...c.edges??[],r]}),eI("")},className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[11px] font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10",children:"+ Add edge"})]})}),(0,t.jsx)("div",{className:"mt-2 space-y-2",children:(c.edges??[]).length?(c.edges??[]).map(e=>(0,t.jsx)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2",children:(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"text-[11px] text-[color:var(--ck-text-secondary)]",children:[(0,t.jsx)("span",{className:"font-mono",children:e.from})," → ",(0,t.jsx)("span",{className:"font-mono",children:e.to}),e.label?(0,t.jsxs)("span",{className:"ml-2 text-[10px] text-[color:var(--ck-text-tertiary)]",children:["(",e.label,")"]}):null]}),(0,t.jsx)("button",{type:"button",onClick:()=>eE({...c,edges:(c.edges??[]).filter(t=>t.id!==e.id)}),className:"text-[10px] text-[color:var(--ck-text-tertiary)] hover:text-[color:var(--ck-text-primary)]",children:"Remove"})]})},e.id)):(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-secondary)]",children:"No edges yet."})})]})]}),(0,t.jsxs)("details",{open:!0,className:"mt-3 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/10",children:[(0,t.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Node inspector"}),(0,t.jsxs)("div",{className:"px-3 pb-3",children:[(0,t.jsx)("div",{className:"flex items-center justify-between gap-2",children:O?(0,t.jsx)("button",{type:"button",onClick:()=>{let e=c.nodes.filter(e=>e.id!==O),t=(c.edges??[]).filter(e=>e.from!==O&&e.to!==O);eE({...c,nodes:e,edges:t}),E("")},className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[10px] font-medium text-red-100 hover:bg-white/10",children:"Delete node"}):null}),O?(b=c.nodes.find(e=>e.id===O))?(0,t.jsxs)("div",{className:"mt-3 space-y-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"id"}),(0,t.jsx)("div",{className:"mt-1 rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",children:b.id})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"name"}),(0,t.jsx)("input",{value:String(b.name??""),onChange:e=>{let t=e.target.value;eE({...c,nodes:c.nodes.map(e=>e.id===b.id?{...e,name:t}:e)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"Optional"})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"type"}),(0,t.jsxs)("select",{value:b.type,onChange:e=>{let t=e.target.value;eE({...c,nodes:c.nodes.map(e=>e.id===b.id?{...e,type:t}:e)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",children:[(0,t.jsx)("option",{value:"start",children:"start"}),(0,t.jsx)("option",{value:"end",children:"end"}),(0,t.jsx)("option",{value:"llm",children:"llm"}),(0,t.jsx)("option",{value:"tool",children:"tool"}),(0,t.jsx)("option",{value:"condition",children:"condition"}),(0,t.jsx)("option",{value:"delay",children:"delay"}),(0,t.jsx)("option",{value:"human_approval",children:"human_approval"})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"x"}),(0,t.jsx)("input",{type:"number",value:"number"==typeof b.x?b.x:0,onChange:e=>{let t=Number(e.target.value);eE({...c,nodes:c.nodes.map(e=>e.id===b.id?{...e,x:t}:e)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]"})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"y"}),(0,t.jsx)("input",{type:"number",value:"number"==typeof b.y?b.y:0,onChange:e=>{let t=Number(e.target.value);eE({...c,nodes:c.nodes.map(e=>e.id===b.id?{...e,y:t}:e)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"config"}),(0,t.jsx)("pre",{className:"mt-1 max-h-[200px] overflow-auto rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2 text-[10px] text-[color:var(--ck-text-secondary)]",children:JSON.stringify(b.config??{},null,2)})]})]}):(0,t.jsx)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"No node selected."}):(0,t.jsx)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"Select a node."})]})]})]})]})]})):null})})]})]})}e.s(["default",()=>i],87090)}]);
@@ -0,0 +1 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,82310,e=>{"use strict";function t(e){return e instanceof Error?e.message:String(e)}e.s(["errorMessage",()=>t])},44355,e=>{"use strict";var t=e.i(43476),r=e.i(74080);function s({open:e,onClose:s,title:a,children:o,error:i,confirmLabel:l,confirmBusyLabel:n,onConfirm:c,confirmDisabled:d,busy:m,confirmButtonClassName:x}){if(!e)return null;let u=m??!1,p=u&&n?n:l,h="confirmation-modal-title";return(0,r.createPortal)((0,t.jsxs)("div",{className:"fixed inset-0 z-[200]",children:[(0,t.jsx)("div",{className:"fixed inset-0 bg-black/60",onClick:s,"aria-hidden":"true"}),(0,t.jsx)("div",{className:"fixed inset-0 overflow-y-auto",role:"dialog","aria-modal":"true","aria-labelledby":h,children:(0,t.jsx)("div",{className:"flex min-h-full items-center justify-center p-4",children:(0,t.jsxs)("div",{className:"w-full max-w-lg rounded-2xl border border-white/10 bg-[color:var(--ck-bg-glass-strong)] p-5 shadow-[var(--ck-shadow-2)]",children:[(0,t.jsx)("h2",{id:h,className:"text-lg font-semibold text-[color:var(--ck-text-primary)]",children:a}),o,i?(0,t.jsx)("div",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-3 text-sm text-red-100",children:i}):null,(0,t.jsxs)("div",{className:"mt-6 flex items-center justify-end gap-2",children:[(0,t.jsx)("button",{type:"button",onClick:s,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10",children:"Cancel"}),(0,t.jsx)("button",{type:"button",disabled:(d??!1)||u,onClick:c,className:x??"rounded-[var(--ck-radius-sm)] bg-[var(--ck-accent-red)] px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] transition-colors hover:bg-[var(--ck-accent-red-hover)] disabled:opacity-50",children:p})]})]})})})]}),document.body)}e.s(["ConfirmationModal",()=>s])},54510,e=>{"use strict";var t=e.i(43476),r=e.i(44355);function s({open:e,onClose:s,title:a,entityLabel:o,bodyText:i,onConfirm:l,busy:n,error:c}){return(0,t.jsx)(r.ConfirmationModal,{open:e,onClose:s,title:a,confirmLabel:"Delete",confirmBusyLabel:"Deleting…",onConfirm:l,busy:n,error:c??void 0,children:(0,t.jsxs)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:[a," ",(0,t.jsx)("code",{className:"font-mono",children:o}),"? ",i]})})}function a(e){return function(r){let a=r[e.entityLabelKey];return(0,t.jsx)(s,{open:r.open,onClose:r.onClose,title:e.title,entityLabel:a,bodyText:e.bodyText,onConfirm:r.onConfirm,busy:r.busy,error:r.error})}}let o=a({title:"Delete agent",bodyText:"This will remove its workspace/state.",entityLabelKey:"agentId"}),i=a({title:"Delete Team",bodyText:"This will remove the team workspace, agents, and stamped cron jobs.",entityLabelKey:"teamId"}),l=a({title:"Delete recipe",bodyText:"This removes the markdown file from your workspace.",entityLabelKey:"recipeId"}),n=a({title:"Delete cron job",bodyText:"This removes it from the Gateway scheduler. You can recreate it later.",entityLabelKey:"jobLabel"});e.s(["DeleteAgentModal",0,o,"DeleteCronJobModal",0,n,"DeleteRecipeModal",0,l,"DeleteTeamModal",0,i],54510)},72532,e=>{"use strict";var t=e.i(43476);function r({title:e,files:r,loading:s,showOptionalFiles:a,onShowOptionalChange:o,selectedFileName:i,onSelectFile:l,renderItemExtra:n}){let c=a?r:r.filter(e=>e.required||!e.missing);return(0,t.jsxs)("div",{className:"ck-glass-strong p-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:e}),(0,t.jsxs)("label",{className:"flex items-center gap-2 text-xs text-[color:var(--ck-text-secondary)]",children:[(0,t.jsx)("input",{type:"checkbox",checked:a,onChange:e=>o(e.target.checked)}),"Show optional"]})]}),(0,t.jsx)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"Default view hides optional missing files to reduce noise."}),(0,t.jsxs)("ul",{className:"mt-3 space-y-1",children:[s?(0,t.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"Loading…"}):null,c.map(e=>{var r;let s;return(0,t.jsx)("li",{children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>l(e.name),className:(r=e.name,s="w-full rounded-[var(--ck-radius-sm)] px-3 py-2 text-left text-sm",i===r?`${s} bg-white/10 text-[color:var(--ck-text-primary)]`:`${s} text-[color:var(--ck-text-secondary)] hover:bg-white/5`),children:[(0,t.jsx)("span",{className:e.required?"text-[color:var(--ck-text-primary)]":"text-[color:var(--ck-text-secondary)]",children:e.name}),(0,t.jsx)("span",{className:"ml-2 text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:e.required?"required":"optional"}),e.missing?(0,t.jsx)("span",{className:"ml-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"missing"}):null]}),n?.(e)]})},e.name)})]})]})}e.s(["FileListWithOptionalToggle",()=>r])},92140,e=>{"use strict";var t=e.i(43476),r=e.i(71645),s=e.i(22016),a=e.i(18566),o=e.i(42771),i=e.i(82310);function l(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function n({teamId:e,llmTaskEnabled:n}){let c=(0,a.useRouter)(),[d,m]=(0,r.useState)([]),[x,u]=(0,r.useState)(!0),[p,h]=(0,r.useState)(!1),[v,f]=(0,r.useState)(""),[b,y]=(0,r.useState)(""),[w,k]=(0,r.useState)({}),[j,g]=(0,r.useState)({}),[N,C]=(0,r.useState)(""),[S,I]=(0,r.useState)(""),[A,R]=(0,r.useState)(null),[$,T]=(0,r.useState)(""),[U,L]=(0,r.useState)(""),[M,D]=(0,r.useState)(!1),E=(0,r.useCallback)(async t=>{let r=!!t?.quiet;f(""),r||u(!0);try{let t=await (0,o.fetchJson)(`/api/teams/workflows?teamId=${encodeURIComponent(e)}`,{cache:"no-store"});if(!t.ok)throw Error("Failed to load workflows");let r=(Array.isArray(t.files)?t.files:[]).map(e=>e.endsWith(".workflow.json")?e.slice(0,-14):null).filter(e=>!!e);m(r.map(e=>({id:e,name:e})))}catch(e){f((0,i.errorMessage)(e))}finally{r||u(!1)}},[e]);async function q(){h(!0);try{await E({quiet:!0})}finally{h(!1)}}async function J(t){if(confirm(`Delete workflow “${t}”? This removes the .workflow.json file from the team workspace.`)){f("");try{let r=await (0,o.fetchJson)(`/api/teams/workflows?teamId=${encodeURIComponent(e)}&id=${encodeURIComponent(t)}`,{method:"DELETE"});if(!r.ok)throw Error(r.error||"Failed to delete workflow");await E({quiet:!0}),b===t&&(y(""),C(""),R(null))}catch(e){f((0,i.errorMessage)(e))}}}async function O(t){g(e=>({...e,[t]:!0})),T("");try{let r=await (0,o.fetchJson)(`/api/teams/workflow-runs?teamId=${encodeURIComponent(e)}&workflowId=${encodeURIComponent(t)}`,{cache:"no-store"});if(!r.ok)throw Error(r.error||"Failed to load runs");let s=Array.isArray(r.runIds)?r.runIds.map(e=>String(e||"").trim()).filter(Boolean):Array.isArray(r.files)?r.files.map(e=>"string"==typeof e&&e.endsWith(".run.json")?e.slice(0,-9):null).filter(e=>!!e):[];k(e=>({...e,[t]:s}))}catch(e){T((0,i.errorMessage)(e)),k(e=>({...e,[t]:[]}))}finally{g(e=>({...e,[t]:!1}))}}async function B(t,r){I(t),C(r),R(null),T(""),L("");try{let s=await (0,o.fetchJson)(`/api/teams/workflow-runs?teamId=${encodeURIComponent(e)}&workflowId=${encodeURIComponent(t)}&runId=${encodeURIComponent(r)}`,{cache:"no-store"});if(!s.ok)throw Error(s.error||"Failed to load run");let a=l(s.run)?s.run:null;if(!a)throw Error("Invalid run format");R({id:String(a.id??r),status:"string"==typeof a.status?a.status:void 0,startedAt:"string"==typeof a.startedAt?a.startedAt:void 0,finishedAt:"string"==typeof a.finishedAt?String(a.finishedAt):void 0,meta:a.meta,memoryUsed:a.memoryUsed,approval:a.approval,raw:a})}catch(e){T((0,i.errorMessage)(e)),R(null)}}async function K(t){if(confirm(`Add workflow from template “${t}”?`)){f("");try{let r=await (0,o.fetchJson)("/api/teams/workflow-templates",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:e,templateId:t})});if(!r.ok)throw Error(r.error||"Failed to apply template");let s=String(r.workflowId??"").trim();if(!s)throw Error("Template applied but workflowId missing");await E({quiet:!0}),c.push(`/teams/${encodeURIComponent(e)}/workflows/${encodeURIComponent(s)}`)}catch(e){f((0,i.errorMessage)(e))}}}(0,r.useEffect)(()=>{E()},[E]);let F=(0,r.useMemo)(()=>{if(!A)return[];let e=A.memoryUsed??(l(A.meta)?A.meta.memoryUsed:void 0);return Array.isArray(e)?e.map(e=>l(e)?e:null).filter(Boolean).map(e=>({ts:String(e.ts??"").trim(),author:String(e.author??"").trim(),type:String(e.type??"").trim(),content:String(e.content??"").trim(),source:e.source})).filter(e=>e.ts&&e.author&&e.type&&e.content):[]},[A]);if(x)return(0,t.jsx)("div",{className:"ck-glass p-4",children:"Loading workflows…"});let P=!1===n?(0,t.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-amber-500/30 bg-amber-500/10 p-4 text-sm",children:[(0,t.jsx)("div",{className:"font-medium text-amber-200",children:"LLM support is not enabled"}),(0,t.jsxs)("div",{className:"mt-1 text-[color:var(--ck-text-secondary)]",children:["Workflow LLM nodes require the optional built-in ",(0,t.jsx)("code",{className:"px-1",children:"llm-task"})," plugin."]}),(0,t.jsxs)("div",{className:"mt-2 text-[color:var(--ck-text-secondary)]",children:["Enable it with: ",(0,t.jsx)("code",{className:"px-1",children:"openclaw plugins enable llm-task"})," then run"," ",(0,t.jsx)("code",{className:"px-1",children:"openclaw gateway restart"}),"."]}),(0,t.jsx)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"If you’re doing a non-interactive install, keep this command in your setup docs as a fallback."})]}):null;return(0,t.jsxs)("div",{className:"ck-glass p-6",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-semibold",children:"Workflows (file-first)"}),(0,t.jsxs)("p",{className:"mt-1 text-sm text-[color:var(--ck-text-secondary)]",children:["Stored in ",(0,t.jsx)("code",{children:"shared-context/workflows/<id>.workflow.json"})," inside the team workspace."]}),P,(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-center justify-start gap-2",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{let t=`new-${Date.now()}`;c.push(`/teams/${encodeURIComponent(e)}/workflows/${encodeURIComponent(t)}?draft=1`)},className:"rounded-[var(--ck-radius-sm)] bg-[var(--ck-accent-red)] px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)]",children:"Add workflow"}),(0,t.jsx)("button",{type:"button",onClick:()=>void K("marketing-cadence-v1"),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10",children:"Add example template"}),(0,t.jsx)("button",{type:"button",onClick:q,disabled:p,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-60",children:p?"Refreshing…":"Refresh"})]})]}),v?(0,t.jsx)("div",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-4 text-sm text-red-100",children:v}):null,0===d.length?(0,t.jsx)("p",{className:"mt-4 text-sm text-[color:var(--ck-text-secondary)]",children:"No workflows yet."}):(0,t.jsx)("ul",{className:"mt-4 divide-y divide-white/10 overflow-hidden rounded-[var(--ck-radius-sm)] border border-white/10",children:d.map(r=>{let a=b===r.id,o=w[r.id]??[],n=!!j[r.id];return(0,t.jsxs)("li",{className:"bg-white/5",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-3",children:[(0,t.jsxs)("button",{type:"button",onClick:async()=>{let e=a?"":r.id;y(e),C(""),R(null),T(""),e&&await O(e)},className:"min-w-0 flex-1 text-left",children:[(0,t.jsx)("div",{className:"truncate text-sm font-medium text-[color:var(--ck-text-primary)]",children:r.name||r.id}),(0,t.jsx)("div",{className:"truncate text-xs text-[color:var(--ck-text-tertiary)]",children:r.id}),(0,t.jsxs)("div",{className:"mt-1 text-[10px] text-[color:var(--ck-text-tertiary)]",children:["Click to ",a?"collapse":"expand"," run details"]})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,t.jsx)(s.default,{href:`/teams/${encodeURIComponent(e)}/workflows/${encodeURIComponent(r.id)}`,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-1.5 text-sm font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10",children:"Edit"}),(0,t.jsx)("button",{type:"button",onClick:()=>void J(r.id),className:"rounded-[var(--ck-radius-sm)] border border-[color:rgba(255,59,48,0.45)] bg-[color:rgba(255,59,48,0.08)] px-3 py-1.5 text-sm font-medium text-[color:var(--ck-accent-red)] transition-colors hover:bg-[color:rgba(255,59,48,0.12)]",children:"Delete"})]})]}),a?(0,t.jsxs)("div",{className:"border-t border-white/10 bg-black/20 px-4 py-3",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Runs"}),(0,t.jsx)("button",{type:"button",disabled:n,onClick:()=>void O(r.id),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[11px] font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-60",children:n?"Loading…":"Refresh runs"})]}),$?(0,t.jsx)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-2 text-xs text-red-100",children:$}):null,(0,t.jsxs)("div",{className:"mt-2 grid grid-cols-1 gap-3 lg:grid-cols-2",children:[(0,t.jsx)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-2",children:o.length?(0,t.jsx)("div",{className:"space-y-1",children:o.slice(0,8).map(e=>{let s=N===e;return(0,t.jsx)("button",{type:"button",onClick:()=>void B(r.id,e),className:s?"w-full rounded-[var(--ck-radius-sm)] bg-white/10 px-2 py-1 text-left text-[11px] text-[color:var(--ck-text-primary)]":"w-full rounded-[var(--ck-radius-sm)] px-2 py-1 text-left text-[11px] text-[color:var(--ck-text-secondary)] hover:bg-white/5",children:(0,t.jsx)("span",{className:"font-mono",children:e})},e)})}):(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:"No runs yet."})}),(0,t.jsx)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:A?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Run detail"}),(0,t.jsxs)("div",{className:"mt-1 text-[11px] text-[color:var(--ck-text-tertiary)]",children:[(0,t.jsx)("span",{className:"font-mono",children:A.id}),A.status?(0,t.jsxs)("span",{children:[" • ",A.status]}):null]})]}),(0,t.jsxs)("div",{className:"border-t border-white/10 pt-3",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Approval"}),(()=>{let r=A.approval;if(!l(r))return(0,t.jsx)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"(No approval info recorded.)"});let s=String(r.state??"").trim(),a="string"==typeof r.requestedAt?r.requestedAt:"",o="string"==typeof r.decidedAt?r.decidedAt:"",n="string"==typeof r.decidedBy?r.decidedBy:"",c="string"==typeof r.note?r.note:"",d=l(r.outbound)?r.outbound:null,m="pending"===s||"waiting_for_approval"===A.status;return(0,t.jsxs)("div",{className:"mt-2 space-y-2",children:[(0,t.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2 text-[11px] text-[color:var(--ck-text-secondary)]",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"font-mono",children:"state"}),": ",(0,t.jsx)("span",{className:"font-mono text-[color:var(--ck-text-primary)]",children:s||"(unknown)"})]}),a?(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"font-mono",children:"requestedAt"}),": ",(0,t.jsx)("span",{className:"font-mono",children:a})]}):null,o?(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"font-mono",children:"decidedAt"}),": ",(0,t.jsx)("span",{className:"font-mono",children:o})]}):null,n?(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"font-mono",children:"decidedBy"}),": ",(0,t.jsx)("span",{className:"font-mono",children:n})]}):null,c?(0,t.jsx)("div",{className:"mt-1 whitespace-pre-wrap text-xs text-[color:var(--ck-text-primary)]",children:c}):null,d?(0,t.jsxs)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/30 p-2 text-[10px]",children:[(0,t.jsx)("div",{className:"text-[color:var(--ck-text-tertiary)]",children:"Outbound"}),(0,t.jsx)("pre",{className:"mt-1 overflow-auto whitespace-pre-wrap",children:JSON.stringify(d,null,2)})]}):null]}),m?(0,t.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-2",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"approval note (optional)"}),(0,t.jsx)("textarea",{value:U,onChange:e=>L(e.target.value),rows:3,className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"e.g. Ship it / please tweak hook"}),(0,t.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:[{action:"approve",label:"Approve"},{action:"request_changes",label:"Request changes"},{action:"cancel",label:"Cancel"}].map(r=>(0,t.jsx)("button",{type:"button",disabled:M,onClick:async()=>{if(S&&N&&confirm(`${r.label} run ${N}?`)){D(!0),T("");try{let t=await fetch("/api/teams/workflow-runs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:e,workflowId:S,runId:N,action:r.action,note:U||void 0,decidedBy:"ClawKitchen UI"})}),s=await t.json();if(!t.ok||!s.ok)throw Error(s.error||"Failed to apply approval action");await B(S,N)}catch(e){T((0,i.errorMessage)(e))}finally{D(!1)}}},className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[11px] font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-60",children:r.label},r.action))})]}):null]})})()]}),(0,t.jsxs)("div",{className:"border-t border-white/10 pt-3",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Memory used in this run"}),F.length?(0,t.jsx)("div",{className:"mt-2 space-y-2",children:F.slice(0,20).map((e,r)=>(0,t.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2",children:[(0,t.jsxs)("div",{className:"text-[10px] text-[color:var(--ck-text-tertiary)]",children:[(0,t.jsx)("span",{className:"font-mono",children:e.ts})," • ",(0,t.jsx)("span",{className:"font-mono",children:e.type})," • ",(0,t.jsx)("span",{className:"font-mono",children:e.author})]}),(0,t.jsx)("div",{className:"mt-1 whitespace-pre-wrap text-xs text-[color:var(--ck-text-primary)]",children:e.content}),void 0!==e.source?(0,t.jsx)("pre",{className:"mt-2 overflow-auto rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/30 p-2 text-[10px] text-[color:var(--ck-text-secondary)]",children:JSON.stringify(e.source,null,2)}):null]},`${e.ts}-${r}`))}):(0,t.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:["(None recorded yet.)",(0,t.jsxs)("div",{className:"mt-1",children:["Next step: have the workflow runner write an explicit ",(0,t.jsx)("span",{className:"font-mono",children:"memoryUsed[]"})," list into the run file."]})]})]})]}):N?(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-secondary)]",children:"Loading run…"}):(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:"Select a run to see details."})})]})]}):null]},r.id)})})]})}e.s(["default",()=>n])}]);
@@ -0,0 +1,10 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,86103,e=>{"use strict";var t=e.i(43476),s=e.i(71645);e.i(22258);var a=e.i(94988),r=e.i(18566),i=e.i(54510),l=e.i(44355);function o({open:e,teamId:s,recipeId:a,onClose:r,onConfirm:i,busy:o}){return(0,t.jsxs)(l.ConfirmationModal,{open:e,onClose:r,title:"Publish changes",confirmLabel:"Publish changes",confirmBusyLabel:"Publishing…",busy:o,onConfirm:i,confirmButtonClassName:"rounded-[var(--ck-radius-sm)] bg-emerald-600 px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] hover:bg-emerald-500 disabled:opacity-50",children:[(0,t.jsxs)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:["This will re-scaffold team ",(0,t.jsx)("code",{className:"font-mono",children:s})," from recipe ",(0,t.jsx)("code",{className:"font-mono",children:a}),"."]}),(0,t.jsxs)("div",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-amber-400/30 bg-amber-500/10 p-3 text-sm text-amber-100",children:[(0,t.jsx)("div",{className:"font-medium",children:"Complete overwrite"}),(0,t.jsxs)("div",{className:"mt-1",children:["All existing team workspace files managed by the recipe will be overwritten (for example: ",(0,t.jsx)("code",{className:"font-mono",children:"AGENTS.md"}),","," ",(0,t.jsx)("code",{className:"font-mono",children:"SOUL.md"}),", role templates, and other scaffolded files). Any manual edits in those files will be lost."]})]})]})}var c=e.i(76972),n=e.i(82310),d=e.i(42771);function m(e,t){try{return JSON.parse(e)}catch{return t}}async function x(e){let[t,s]=await Promise.all([(0,d.fetchJson)("/api/recipes",{cache:"no-store"}),fetch(`/api/teams/meta?teamId=${encodeURIComponent(e)}`,{cache:"no-store"})]);return{recipesData:t,metaRes:s}}async function h(e){let t=await (0,d.fetchAll)([`/api/teams/files?teamId=${encodeURIComponent(e)}`,`/api/cron/jobs?teamId=${encodeURIComponent(e)}`,"/api/agents",`/api/teams/skills?teamId=${encodeURIComponent(e)}`,"/api/skills/available"]),s=await Promise.all(t.map(e=>e.text()));return{responses:t,texts:s}}async function p(e,t){t.setTeamFilesLoading(!0),t.setCronLoading(!0),t.setTeamAgentsLoading(!0),t.setSkillsLoading(!0);try{let{responses:s,texts:a}=await h(e),[r,i,l,o,c]=s,[n,d,x,p,u]=a,v=m(n,{});r.ok&&v.ok&&Array.isArray(v.files)&&t.setTeamFiles(v.files.map(e=>({name:String(e.name??""),missing:!!e.missing,required:!!e.required,rationale:"string"==typeof e.rationale?e.rationale:void 0})));let g=m(d,{});i.ok&&g.ok&&Array.isArray(g.jobs)&&t.setCronJobs(g.jobs);let k=m(x,{});if(l.ok&&Array.isArray(k.agents)){let s=k.agents.filter(t=>String(t.id??"").startsWith(`${e}-`));t.setTeamAgents(s.map(e=>({id:String(e.id??""),identityName:"string"==typeof e.identityName?e.identityName:void 0})))}let f=m(p,{});o.ok&&f.ok&&Array.isArray(f.skills)&&t.setSkillsList(f.skills);let y=m(u,{});if(c.ok&&y.ok&&Array.isArray(y.skills)){let e=y.skills;t.setAvailableSkills(e),t.setSelectedSkill(t=>{let s=String(t??"").trim();return s&&e.includes(s)?s:e[0]??""})}}finally{t.setTeamFilesLoading(!1),t.setCronLoading(!1),t.setTeamAgentsLoading(!1),t.setSkillsLoading(!1)}}async function u(e,t){let s=await x(e);t.setRecipes(s.recipesData.recipes??[]);let a=null;try{let e=await s.metaRes.json(),r=e.meta;s.metaRes.ok&&e.ok&&r?.recipeId?(a={recipeId:String(r.recipeId),recipeName:"string"==typeof r.recipeName?r.recipeName:void 0},t.setTeamMetaRecipeHash("string"==typeof r.recipeHash?r.recipeHash:null)):t.setTeamMetaRecipeHash(null)}catch{t.setTeamMetaRecipeHash(null)}if(a)t.setLockedFromId(a.recipeId),t.setLockedFromName(a.recipeName??null),t.setProvenanceMissing(!1),t.setFromId(a.recipeId);else{t.setLockedFromId(null),t.setLockedFromName(null),t.setProvenanceMissing(!0);let a=s.recipesData.recipes??[],r=a.find(t=>"team"===t.kind&&t.id===e),i=a.find(e=>"team"===e.kind),l=r??i;l&&t.setFromId(l.id)}await p(e,{setTeamFiles:t.setTeamFiles,setCronJobs:t.setCronJobs,setTeamAgents:t.setTeamAgents,setSkillsList:t.setSkillsList,setAvailableSkills:t.setAvailableSkills,setSelectedSkill:t.setSelectedSkill,setTeamFilesLoading:t.setTeamFilesLoading,setCronLoading:t.setCronLoading,setTeamAgentsLoading:t.setTeamAgentsLoading,setSkillsLoading:t.setSkillsLoading})}async function v(e){try{let t=await (0,d.fetchJson)("/api/agents",{cache:"no-store"}),s=(Array.isArray(t.agents)?t.agents:[]).filter(t=>String(t.id??"").startsWith(`${e}-`)).map(e=>({id:String(e.id??""),identityName:"string"==typeof e.identityName?e.identityName:void 0}));return{ok:!0,agents:s}}catch{return{ok:!1,agents:[]}}}async function g(e,t,s){try{await (0,d.fetchJson)("/api/scaffold",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({kind:"team",recipeId:t.trim(),teamId:e,applyConfig:!0,overwrite:!1,allowExisting:!0,cronInstallChoice:"no"})})}catch(e){s((0,n.errorMessage)(e),"error")}}async function k(e,t,s,a){let r=Date.now();for(;Date.now()-r<a;){try{let a=await v(e);if(a.ok){s(a.agents);let e=!!t&&a.agents.some(e=>e.id===t);if(!t||e)return!0}}catch{}await new Promise(e=>setTimeout(e,500))}return!1}async function f(e){let{teamId:t,toId:s,newRole:a,derivedRole:r,newRoleName:i,content:l,setContent:o,setTeamAgents:c,flashMessage:m,ensureCustomRecipeExists:x}=e;try{await x({overwrite:!1})}catch(t){let e=(0,n.errorMessage)(t);if(!/Recipe id already exists:/i.test(e))throw t}let h=await (0,d.fetchJson)("/api/recipes/team-agents",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify("__custom__"===a?{recipeId:s.trim(),op:"add",role:r,name:i}:{recipeId:s.trim(),op:"addLike",baseRole:r,teamId:t,name:i})});if(!h.ok)throw Error("Failed updating agents list");o(String(h.content??l)),await g(t,s,m);let p="string"==typeof h.addedAgentId?h.addedAgentId:"";if(!await k(t,p,c,5e3)&&p){try{fetch("/api/gateway/restart",{method:"POST"})}catch{}await k(t,p,c,1e4)}m(`Updated agents list in ${s}`,"success")}function y(e){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"mt-6 grid grid-cols-1 gap-4 lg:grid-cols-2",children:[(0,t.jsxs)("div",{className:"ck-glass-strong p-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Custom recipe target"}),e.loading?(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:"Loading team…"}):null]}),(0,t.jsx)("label",{className:"mt-3 block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Team id"}),(0,t.jsx)("input",{value:e.toId,onChange:t=>e.setToId(t.target.value),disabled:!e.canEditTargetId,className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)] disabled:opacity-70"}),(0,t.jsx)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:"This is the custom recipe id that will be created when you save."}),(0,t.jsx)("label",{className:"mt-3 block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Team name"}),(0,t.jsx)("input",{value:e.toName,onChange:t=>e.setToName(t.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]"}),(0,t.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2",children:[(0,t.jsx)("button",{type:"button",disabled:e.saving||!e.teamIdValid||!e.targetIdValid||e.targetIsBuiltin,onClick:()=>e.onSaveCustom(!0),className:"rounded-[var(--ck-radius-sm)] bg-[var(--ck-accent-red)] px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] disabled:opacity-50",children:e.saving?"Saving":"Save"}),(0,t.jsx)("button",{type:"button",disabled:e.saving||!e.teamIdValid||!e.targetIdValid||e.targetIsBuiltin||!e.loadedRecipeHash||!e.teamMetaRecipeHash||e.loadedRecipeHash===e.teamMetaRecipeHash,onClick:e.onPublishOpen,className:"rounded-[var(--ck-radius-sm)] bg-emerald-600 px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] disabled:opacity-50",children:e.publishing?"Publishing":"Publish changes"}),(0,t.jsx)("button",{type:"button",disabled:e.saving,onClick:e.onDeleteOpen,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)] disabled:opacity-50",children:"Delete Team"})]})]}),(0,t.jsxs)("div",{className:"ck-glass-strong p-4",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Notes"}),(0,t.jsxs)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Parent recipe (locked)"}),(0,t.jsx)("select",{disabled:!0,className:"mt-2 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)] disabled:opacity-70",value:e.fromId,onChange:t=>e.setFromId(t.target.value),children:e.teamRecipes.map(e=>(0,t.jsxs)("option",{value:e.id,children:[e.id," (",e.source,")"]},`${e.source}:${e.id}`))}),e.lockedFromId&&(0,t.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:[(0,t.jsx)("code",{children:e.lockedFromId}),e.lockedFromName?` (${e.lockedFromName})`:""]}),!e.lockedFromId&&e.provenanceMissing&&(0,t.jsx)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"Provenance not found for this team."})]}),(0,t.jsxs)("ul",{className:"mt-4 list-disc space-y-1 pl-5 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,t.jsx)("li",{children:"Save writes the custom recipe file identified by Team id."}),(0,t.jsx)("li",{children:"Publish changes re-scaffolds this team from your custom recipe."}),(0,t.jsx)("li",{children:"Delete Team runs openclaw recipes remove-team."})]})]})]}),(0,t.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Recipe markdown"}),e.recipeLoadError?(0,t.jsx)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-3 text-sm text-red-100",children:e.recipeLoadError}):null,(0,t.jsx)("textarea",{value:e.content,onChange:t=>{e.setContent(t.target.value),e.setLoadedRecipeHash(null)},className:"mt-2 h-[55vh] w-full resize-none rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-3 font-mono text-xs text-[color:var(--ck-text-primary)]",spellCheck:!1})]})]})}function b(e){let{teamId:s,toId:a,recipeAgents:r,newRole:i,setNewRole:l,customRole:o,setCustomRole:c,newRoleName:n,setNewRoleName:d,derivedRole:m,saving:x,teamAgents:h,teamAgentsLoading:p,onAddAgent:u}=e;return(0,t.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Agents in this team"}),(0,t.jsxs)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:["Add/remove agents by updating the ",(0,t.jsx)("code",{children:"agents:"})," list in your custom team recipe (",(0,t.jsx)("code",{children:a}),")."]}),(0,t.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Role"}),(0,t.jsxs)("select",{value:i,onChange:e=>{let t=e.target.value;if(l(t),"__custom__"===t){c(""),d("");return}c("");let s=r.find(e=>e.role===t);d(s?.name||"")},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]",children:[(0,t.jsx)("option",{value:"",children:"Select…"}),r.map(e=>(0,t.jsx)("option",{value:e.role,children:e.name||e.role},e.role)),(0,t.jsx)("option",{value:"__custom__",children:"Other…"})]}),"__custom__"===i?(0,t.jsx)("input",{value:o,onChange:e=>c(e.target.value),placeholder:"role (e.g. researcher)",className:"mt-2 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]"}):null,(0,t.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:["This writes to the recipe's ",(0,t.jsx)("code",{children:"agents:"})," list."]})]}),(0,t.jsx)("div",{className:"sm:col-span-2",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Name (optional)"}),(0,t.jsx)("input",{value:n,onChange:e=>d(e.target.value),placeholder:"Onchain Researcher",className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]"})]})})]}),(0,t.jsx)("div",{className:"mt-3 flex flex-wrap gap-2",children:(0,t.jsx)("button",{disabled:x||!m,onClick:u,className:"rounded-[var(--ck-radius-sm)] bg-[var(--ck-accent-red)] px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] disabled:opacity-50",children:"Add agent"})}),(0,t.jsxs)("div",{className:"mt-6",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Detected installed team agents (read-only)"}),(0,t.jsxs)("ul",{className:"mt-2 space-y-2",children:[h.length?h.map(e=>(0,t.jsxs)("li",{className:"flex items-center justify-between gap-3",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"truncate text-sm font-medium text-[color:var(--ck-text-primary)]",children:e.identityName||e.id}),(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-secondary)]",children:e.id})]}),(0,t.jsx)("a",{className:"text-sm font-medium text-[var(--ck-accent-red)] hover:text-[color:var(--ck-accent-red-hover)]",href:"/agents/"+encodeURIComponent(e.id)+"?returnTo="+encodeURIComponent("/teams/"+s+"?tab=agents"),children:"Edit"})]},e.id)):null,0===h.length&&!p&&(0,t.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"No team agents detected."}),0===h.length&&p&&(0,t.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"Loading…"})]})]})]})}function j(e){return(0,t.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Skills"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"Skills installed in this team workspace. For agent-specific skills, open the agent from the Agents tab."}),(0,t.jsxs)("div",{className:"mt-4",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Installed"}),(0,t.jsx)("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-sm text-[color:var(--ck-text-secondary)]",children:e.skillsList.length?e.skillsList.map(e=>(0,t.jsx)("li",{children:e},e)):(0,t.jsx)("li",{children:"None installed."})})]}),(0,t.jsxs)("div",{className:"mt-5 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/15 p-3",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Add a skill"}),(0,t.jsxs)("div",{className:"mt-2 flex flex-col gap-2 sm:flex-row sm:items-center",children:[(0,t.jsx)("select",{value:e.selectedSkill,onChange:t=>e.setSelectedSkill(t.target.value),disabled:e.installingSkill||e.skillsLoading||!e.availableSkills.length,className:"w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]",children:e.availableSkills.length?e.availableSkills.map(e=>(0,t.jsx)("option",{value:e,children:e},e)):(0,t.jsx)("option",{value:"",children:"No skills found"})}),(0,t.jsx)("button",{type:"button",disabled:e.installingSkill||e.skillsLoading||!e.selectedSkill,onClick:e.onInstallSkill,className:"rounded-[var(--ck-radius-sm)] bg-[var(--ck-accent-red)] px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] disabled:opacity-50",children:e.installingSkill?"Adding":"Add"})]}),e.teamSkillError&&(0,t.jsx)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-3 text-sm text-red-100",children:e.teamSkillError}),e.teamSkillMsg&&(0,t.jsx)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-emerald-400/30 bg-emerald-500/10 p-3 text-sm text-emerald-100",children:e.teamSkillMsg}),(0,t.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:["Uses openclaw recipes install-skill with team-id ",e.teamId,"."]})]})]})}function N(e){let{cronJobs:s,cronLoading:a,saving:r,onCronAction:i}=e;return(0,t.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Cron jobs (filtered by team name)"}),(0,t.jsxs)("ul",{className:"mt-3 space-y-3",children:[s.length?s.map(e=>{let s=String(e.id??e.jobId??"").trim(),a=s||String(e.name??"job"),l=String(e.name??e.id??e.jobId??"(unnamed)"),o=e.enabled??e.state?.enabled;return(0,t.jsxs)("li",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,t.jsx)("div",{className:"font-medium text-[color:var(--ck-text-primary)]",children:l}),(0,t.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-secondary)]",children:["Enabled: ",String(o??"?")]}),(0,t.jsxs)("div",{className:"mt-2 flex flex-wrap gap-2",children:[(0,t.jsx)("button",{disabled:r||!s,onClick:()=>i(s,l,"run"),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2.5 py-1.5 text-xs font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:"Run"}),(0,t.jsx)("button",{disabled:r||!s,onClick:()=>i(s,l,"enable"),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2.5 py-1.5 text-xs font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:"Enable"}),(0,t.jsx)("button",{disabled:r||!s,onClick:()=>i(s,l,"disable"),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2.5 py-1.5 text-xs font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:"Disable"}),s?null:(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:"(missing id)"})]})]},a)}):null,0===s.length&&a&&(0,t.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"Loading"}),0===s.length&&!a&&(0,t.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"No cron jobs detected for this team."})]})]})}var w=e.i(72532);function S(e){let{teamFiles:s,teamFilesLoading:a,showOptionalFiles:r,setShowOptionalFiles:i,fileName:l,fileContent:o,setFileContent:c,teamFileError:n,saving:d,onLoadTeamFile:m,onSaveTeamFile:x}=e;return(0,t.jsxs)("div",{className:"mt-6 grid grid-cols-1 gap-4 lg:grid-cols-3",children:[(0,t.jsx)(w.FileListWithOptionalToggle,{title:"Team files",files:s,loading:a,showOptionalFiles:r,onShowOptionalChange:i,selectedFileName:l,onSelectFile:m}),(0,t.jsxs)("div",{className:"ck-glass-strong p-4 lg:col-span-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsxs)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:["Edit: ",l]}),(0,t.jsx)("button",{disabled:d,onClick:x,className:"rounded-[var(--ck-radius-sm)] bg-[var(--ck-accent-red)] px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] disabled:opacity-50",children:d?"Saving…":"Save file"})]}),n?(0,t.jsx)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-3 text-sm text-red-100",children:n}):null,(0,t.jsx)("textarea",{value:o,onChange:e=>c(e.target.value),className:"mt-3 h-[55vh] w-full resize-none rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-3 font-mono text-xs text-[color:var(--ck-text-primary)]",spellCheck:!1})]})]})}function I(e){return`${e._file??""}:${e._line??0}`}function C({teamId:e}){let[a,r]=(0,s.useState)(!1),[i,l]=(0,s.useState)(""),[o,c]=(0,s.useState)([]),[d,m]=(0,s.useState)([]),[x,h]=(0,s.useState)([]),[p,u]=(0,s.useState)("learning"),[v,g]=(0,s.useState)(""),[k,f]=(0,s.useState)(""),[y,b]=(0,s.useState)(!1),[j,N]=(0,s.useState)(null);async function w(){r(!0),l("");try{let t=await fetch(`/api/teams/memory?teamId=${encodeURIComponent(e)}`,{cache:"no-store"}),s=await t.json();if(!t.ok||!s.ok)throw Error(s.error||"Failed to load memory");c(Array.isArray(s.files)?s.files:[]),m(Array.isArray(s.pinnedItems)?s.pinnedItems:[]),h(Array.isArray(s.items)?s.items:[])}catch(e){l((0,n.errorMessage)(e)),c([]),m([]),h([])}finally{r(!1)}}(0,s.useEffect)(()=>{w()},[e]);let S=(0,s.useMemo)(()=>[{label:"decision",value:"decision"},{label:"learning",value:"learning"},{label:"bug",value:"bug"},{label:"customer",value:"customer"},{label:"release",value:"release"}],[]),C=(0,s.useMemo)(()=>new Set(d.map(e=>e._key)),[d]);async function A(t){let s=I(t);if(t._file&&t._line){N(s),l("");try{let s={op:"pin",ts:new Date().toISOString(),actor:`${e}-lead`,key:{file:"team.jsonl",line:t._line},item:{ts:t.ts,author:t.author,type:t.type,content:t.content,source:t.source}},a=await fetch(`/api/teams/memory?teamId=${encodeURIComponent(e)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(s)}),r=await a.json();if(!a.ok||!r.ok)throw Error(r.error||"Failed to pin");await w()}catch(e){l((0,n.errorMessage)(e))}finally{N(null)}}}async function T(t){let s=I(t);if(t._file&&t._line){N(s),l("");try{let s={op:"unpin",ts:new Date().toISOString(),actor:`${e}-lead`,key:{file:"team.jsonl",line:t._line}},a=await fetch(`/api/teams/memory?teamId=${encodeURIComponent(e)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(s)}),r=await a.json();if(!a.ok||!r.ok)throw Error(r.error||"Failed to unpin");await w()}catch(e){l((0,n.errorMessage)(e))}finally{N(null)}}}return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"ck-glass p-4",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Team memory (file-first)"}),(0,t.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:["Stored in ",(0,t.jsx)("span",{className:"font-mono",children:"shared-context/memory/*.jsonl"}),". Items must be attributable."]}),(0,t.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-secondary)]",children:["Canonical memory model doc:"," ",(0,t.jsx)("a",{className:"underline decoration-white/20 underline-offset-4 hover:decoration-white/40",href:"https://github.com/JIGGAI/ClawRecipes/blob/main/docs/MEMORY_MODEL.md",target:"_blank",rel:"noreferrer",children:"ClawRecipes/docs/MEMORY_MODEL.md"})]})]}),(0,t.jsx)("button",{type:"button",onClick:w,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10",children:"Refresh"})]}),i?(0,t.jsx)("div",{className:"mt-3 rounded border border-red-400/30 bg-red-500/10 p-2 text-sm text-red-100",children:i}):null,(0,t.jsxs)("div",{className:"mt-3 text-xs text-[color:var(--ck-text-secondary)]",children:["Files: ",o.length?o.join(", "):"(none)"]})]}),(0,t.jsxs)("div",{className:"ck-glass p-4",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Add memory item"}),(0,t.jsxs)("div",{className:"mt-3 grid grid-cols-1 gap-3 md:grid-cols-2",children:[(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"type"}),(0,t.jsx)("select",{value:p,onChange:e=>u(e.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-2 text-sm text-[color:var(--ck-text-primary)]",children:S.map(e=>(0,t.jsx)("option",{value:e.value,children:e.label},e.value))})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"source (ticket/pr/path)"}),(0,t.jsx)("input",{value:k,onChange:e=>f(e.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-2 text-sm text-[color:var(--ck-text-primary)]",placeholder:"e.g. ticket 0088, PR https://..., shared-context/DECISIONS.md"})]}),(0,t.jsxs)("label",{className:"block md:col-span-2",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"content"}),(0,t.jsx)("textarea",{value:v,onChange:e=>g(e.target.value),className:"mt-1 h-[110px] w-full resize-none rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2 text-sm text-[color:var(--ck-text-primary)]",placeholder:"Write a small, specific memory item…"})]}),(0,t.jsx)("div",{className:"md:col-span-2",children:(0,t.jsx)("button",{type:"button",disabled:y||!v.trim(),onClick:async()=>{b(!0),l("");try{let t={op:"append",ts:new Date().toISOString(),author:`${e}-lead`,type:p,content:v.trim(),source:k.trim()?{text:k.trim()}:void 0,file:"team.jsonl"},s=await fetch(`/api/teams/memory?teamId=${encodeURIComponent(e)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)}),a=await s.json();if(!s.ok||!a.ok)throw Error(a.error||"Failed to append memory");g(""),f(""),await w()}catch(e){l((0,n.errorMessage)(e))}finally{b(!1)}},className:"rounded-[var(--ck-radius-sm)] bg-[var(--ck-accent-red)] px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] disabled:opacity-50",children:y?"Saving…":"Append to team.jsonl"})})]})]}),(0,t.jsxs)("div",{className:"ck-glass p-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Pinned memory"}),(0,t.jsxs)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:[d.length," pinned"]})]}),a?(0,t.jsx)("div",{className:"mt-3 text-sm text-[color:var(--ck-text-secondary)]",children:"Loading…"}):null,(0,t.jsx)("div",{className:"mt-3 space-y-3",children:d.length?d.map(e=>(0,t.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-3",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:[(0,t.jsx)("span",{className:"font-mono",children:e.ts}),(0,t.jsx)("span",{className:"mx-2",children:"•"}),(0,t.jsx)("span",{className:"rounded bg-white/5 px-2 py-0.5 font-mono",children:e.type}),(0,t.jsx)("span",{className:"mx-2",children:"•"}),(0,t.jsx)("span",{className:"font-mono",children:e.author}),(0,t.jsx)("span",{className:"mx-2",children:"•"}),(0,t.jsxs)("span",{className:"font-mono",children:["pinned ",e.pinnedAt]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>void T(e),disabled:j===e._key,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-xs font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:j===e._key?"Unpinning…":"Unpin"})]}),(0,t.jsx)("div",{className:"mt-2 whitespace-pre-wrap text-sm text-[color:var(--ck-text-primary)]",children:e.content}),e.source?(0,t.jsx)("pre",{className:"mt-2 overflow-auto rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/30 p-2 text-[10px] text-[color:var(--ck-text-secondary)]",children:JSON.stringify(e.source,null,2)}):null]},e._key)):(0,t.jsx)("div",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"No pinned items yet."})})]}),(0,t.jsxs)("div",{className:"ck-glass p-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Recent memory"}),(0,t.jsxs)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:["Showing ",x.length," (max 200)"]})]}),a?(0,t.jsx)("div",{className:"mt-3 text-sm text-[color:var(--ck-text-secondary)]",children:"Loading…"}):null,(0,t.jsx)("div",{className:"mt-3 space-y-3",children:x.length?x.map(e=>{let s=I(e),a=C.has(s);return(0,t.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-3",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:[(0,t.jsx)("span",{className:"font-mono",children:e.ts}),(0,t.jsx)("span",{className:"mx-2",children:"•"}),(0,t.jsx)("span",{className:"rounded bg-white/5 px-2 py-0.5 font-mono",children:e.type}),(0,t.jsx)("span",{className:"mx-2",children:"•"}),(0,t.jsx)("span",{className:"font-mono",children:e.author})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[e._file?(0,t.jsxs)("span",{className:"text-[10px] text-[color:var(--ck-text-tertiary)] font-mono",children:[e._file,":",e._line]}):null,(0,t.jsx)("button",{type:"button",onClick:()=>void A(e),disabled:a||j===s||!e._file||!e._line,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-xs font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:a?"Pinned":j===s?"Pinning…":"Pin"})]})]}),(0,t.jsx)("div",{className:"mt-2 whitespace-pre-wrap text-sm text-[color:var(--ck-text-primary)]",children:e.content}),e.source?(0,t.jsx)("pre",{className:"mt-2 overflow-auto rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/30 p-2 text-[10px] text-[color:var(--ck-text-secondary)]",children:JSON.stringify(e.source,null,2)}):null]},`${e._file??"?"}:${e._line??0}`)}):(0,t.jsx)("div",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"No memory items yet."})})]})]})}var A=e.i(74080);function T({open:e,onClose:a,teamId:r,onInstalled:i}){let l=(0,s.useMemo)(()=>`${r}-swarm-orchestrator`,[r]),[o,c]=(0,s.useState)(l),[n,m]=(0,s.useState)(""),[x,h]=(0,s.useState)("/home/control/swarm-worktrees"),[p,u]=(0,s.useState)("origin/main"),[v,g]=(0,s.useState)(!0),[k,f]=(0,s.useState)(!0),[y,b]=(0,s.useState)(!1),[j,N]=(0,s.useState)(null),[w,S]=(0,s.useState)(null),I=(0,s.useMemo)(()=>({effectiveAgentId:String(o??"").toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").replace(/--+/g,"-")}),[o]);return e?(0,A.createPortal)((0,t.jsxs)("div",{className:"fixed inset-0 z-[210]",children:[(0,t.jsx)("div",{className:"fixed inset-0 bg-black/60",onClick:()=>{y||a()}}),(0,t.jsx)("div",{className:"fixed inset-0 overflow-y-auto",children:(0,t.jsx)("div",{className:"flex min-h-full items-center justify-center p-4",children:(0,t.jsxs)("div",{className:"w-full max-w-xl rounded-2xl border border-white/10 bg-[color:var(--ck-bg-glass-strong)] p-5 shadow-[var(--ck-shadow-2)]",children:[(0,t.jsx)("div",{className:"text-lg font-semibold text-[color:var(--ck-text-primary)]",children:"Add Orchestrator"}),(0,t.jsxs)("p",{className:"mt-1 text-sm text-[color:var(--ck-text-secondary)]",children:["This will scaffold a new ",(0,t.jsx)("span",{className:"font-mono text-xs",children:"swarm-orchestrator"})," agent workspace for this team and prefill its config."]}),(0,t.jsx)("label",{className:"mt-4 block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Orchestrator agent id"}),(0,t.jsx)("input",{value:o,onChange:e=>c(e.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]"}),(0,t.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:["Default: ",(0,t.jsx)("span",{className:"font-mono",children:l})," (normalized: ",(0,t.jsx)("span",{className:"font-mono",children:I.effectiveAgentId}),")"]}),(0,t.jsx)("label",{className:"mt-4 block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Repo directory (SWARM_REPO_DIR)"}),(0,t.jsx)("input",{value:n,onChange:e=>m(e.target.value),placeholder:"/home/control/clawkitchen",className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]"}),(0,t.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-3 md:grid-cols-2",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Worktree root (SWARM_WORKTREE_ROOT)"}),(0,t.jsx)("input",{value:x,onChange:e=>h(e.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]"}),(0,t.jsx)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:"Recommend a dedicated folder outside the repo."})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Base ref (SWARM_BASE_REF)"}),(0,t.jsx)("input",{value:p,onChange:e=>u(e.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]"})]})]}),(0,t.jsxs)("label",{className:"mt-5 flex items-start gap-2 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,t.jsx)("input",{type:"checkbox",checked:v,onChange:e=>g(e.target.checked),className:"mt-1"}),(0,t.jsxs)("span",{children:["Add this agent to OpenClaw config (recommended).",(0,t.jsx)("br",{}),(0,t.jsxs)("span",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:["This will modify ",(0,t.jsx)("span",{className:"font-mono",children:"~/.openclaw/openclaw.json"})," to add ",(0,t.jsx)("span",{className:"font-mono",children:I.effectiveAgentId}),"."]})]})]}),(0,t.jsxs)("label",{className:"mt-3 flex items-start gap-2 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,t.jsx)("input",{type:"checkbox",checked:k,onChange:e=>f(e.target.checked),className:"mt-1"}),(0,t.jsxs)("span",{children:["Make scripts executable (developer convenience).",(0,t.jsx)("br",{}),(0,t.jsxs)("span",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:["Runs ",(0,t.jsx)("span",{className:"font-mono",children:"chmod +x .clawdbot/*.sh"})," in the orchestrator workspace."]})]})]}),j?(0,t.jsx)("div",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-3 text-sm text-red-100",children:j}):null,w?(0,t.jsxs)("div",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-emerald-400/30 bg-emerald-500/10 p-3 text-sm text-emerald-100",children:["Installed ",(0,t.jsx)("span",{className:"font-mono",children:w.orchestratorAgentId})," → ",(0,t.jsx)("span",{className:"font-mono",children:w.workspace})]}):null,(0,t.jsxs)("div",{className:"mt-6 flex items-center justify-end gap-2",children:[(0,t.jsx)("button",{type:"button",onClick:a,disabled:y,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:"Cancel"}),(0,t.jsx)("button",{type:"button",disabled:y||!I.effectiveAgentId||!n.trim(),onClick:async()=>{b(!0),N(null),S(null);try{let e=await (0,d.fetchJson)("/api/teams/orchestrator/install",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:r,orchestratorAgentId:I.effectiveAgentId,repoDir:n.trim(),worktreeRoot:x.trim(),baseRef:p.trim(),applyConfig:v,makeExecutable:k})});if(!e.ok)throw Error(e.error);S({orchestratorAgentId:e.orchestratorAgentId,workspace:e.workspace}),i()}catch(e){N(e instanceof Error?e.message:String(e))}finally{b(!1)}},className:"rounded-[var(--ck-radius-sm)] bg-[var(--ck-accent-red)] px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] hover:bg-[var(--ck-accent-red-hover)] disabled:opacity-50",children:y?"Installing…":"Install"})]})]})})})]}),document.body):null}function R({teamId:e}){let[a,r]=(0,s.useState)(!0),[i,l]=(0,s.useState)(null),[o,c]=(0,s.useState)(null),[n,m]=(0,s.useState)(!1),x=(0,s.useCallback)(async()=>{r(!0);try{let t=await (0,d.fetchJson)(`/api/teams/orchestrator?teamId=${encodeURIComponent(e)}`,{cache:"no-store"});l(t),c(new Date().toISOString())}catch(e){l({ok:!1,error:e instanceof Error?e.message:String(e)}),c(new Date().toISOString())}finally{r(!1)}},[e]);return((0,s.useEffect)(()=>{x()},[x]),a)?(0,t.jsx)("div",{className:"mt-6 ck-glass-strong p-4",children:"Loading orchestrator state…"}):i?i.ok?i.present?(0,t.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Orchestrator"}),(0,t.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-secondary)]",children:["Agent: ",(0,t.jsx)("span",{className:"font-mono",children:i.agent.id}),i.agent.identityName?` (${i.agent.identityName})`:""]}),(0,t.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-secondary)]",children:["Workspace: ",(0,t.jsx)("span",{className:"font-mono",children:i.agent.workspace})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:o?(0,t.jsxs)("span",{children:["Last updated: ",(0,t.jsx)("span",{className:"font-mono",children:o})]}):null}),(0,t.jsx)("button",{type:"button",onClick:()=>void x(),disabled:a,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)] shadow-[var(--ck-shadow-1)] transition-colors hover:bg-white/10 active:bg-white/15 disabled:opacity-50",children:a?"Refreshing…":"Refresh"})]})]}),(0,t.jsxs)("div",{className:"mt-5 grid grid-cols-1 gap-4 lg:grid-cols-2",children:[(0,t.jsxs)("section",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"tmux sessions"}),i.tmuxSessions.length?(0,t.jsx)("ul",{className:"mt-2 space-y-2",children:i.tmuxSessions.map(e=>(0,t.jsxs)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:[(0,t.jsx)("span",{className:"font-mono",children:e.name}),(0,t.jsxs)("span",{className:"ml-2 text-xs text-[color:var(--ck-text-tertiary)]",children:["attached=",String(e.attached),"number"==typeof e.windows?` windows=${e.windows}`:""]})]},e.name))}):(0,t.jsx)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"No sessions detected (or tmux not running)."})]}),(0,t.jsxs)("section",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"git worktrees"}),i.worktrees.length?(0,t.jsx)("ul",{className:"mt-2 space-y-2",children:i.worktrees.map(e=>(0,t.jsxs)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:[(0,t.jsx)("div",{className:"font-mono text-xs",children:e.path}),(0,t.jsxs)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:[e.branch?e.branch:"(no branch)",e.sha?` @ ${e.sha.slice(0,7)}`:""]})]},e.path))}):(0,t.jsx)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"No worktrees detected."})]})]}),(0,t.jsxs)("section",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Active tasks"}),i.activeTasksSummary?(0,t.jsxs)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,t.jsx)("div",{className:"font-mono text-xs",children:i.activeTasksSummary.path}),(0,t.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:["number"==typeof i.activeTasksSummary.taskCount?`tasks=${i.activeTasksSummary.taskCount}`:"tasks=?",i.activeTasksSummary.rawType?` type=${i.activeTasksSummary.rawType}`:""]})]}):(0,t.jsx)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"No active-tasks.json found."})]}),(0,t.jsxs)("section",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"CLI quick actions"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"The orchestrator is designed to be driven from the CLI (and usually tmux). Common commands:"}),(0,t.jsxs)("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,t.jsxs)("li",{children:[(0,t.jsx)("span",{className:"font-mono text-xs",children:"tmux ls"}),(0,t.jsx)("span",{className:"ml-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"(list sessions)"})]}),(0,t.jsxs)("li",{children:[(0,t.jsx)("span",{className:"font-mono text-xs",children:"tmux attach -t <session>"}),(0,t.jsx)("span",{className:"ml-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"(jump into a running swarm)"})]}),(0,t.jsxs)("li",{children:[(0,t.jsxs)("span",{className:"font-mono text-xs",children:["git -C ",i.agent.workspace," worktree list"]}),(0,t.jsx)("span",{className:"ml-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"(inspect worktrees)"})]})]}),(0,t.jsx)("p",{className:"mt-3 text-xs text-[color:var(--ck-text-tertiary)]",children:"Note: ClawKitchen is read-only here; it surfaces status and pointers, but does not run or attach to tmux."})]}),(0,t.jsxs)("section",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Human approval gate (recommended)"}),(0,t.jsxs)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:["For workflows that publish, deploy, or send outbound messages, keep a ",(0,t.jsx)("strong",{children:"human approval step"}),"."]}),(0,t.jsxs)("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,t.jsx)("li",{children:"Generate a proposed change/post as a draft."}),(0,t.jsx)("li",{children:"Send the draft to a bound messaging channel (e.g. Telegram) for approval."}),(0,t.jsx)("li",{children:"Only execute the final action after explicit approve/deny."})]})]}),(0,t.jsxs)("section",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Where to change settings"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"These are the common knobs for a swarm/orchestrator scaffold (read-only references):"}),(0,t.jsx)("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-sm text-[color:var(--ck-text-secondary)]",children:i.settingsPaths.map(e=>(0,t.jsx)("li",{className:"font-mono text-xs",children:e},e))})]})]}):(0,t.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Orchestrator"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"No swarm/orchestrator detected for this team."})]}),(0,t.jsx)("button",{type:"button",onClick:()=>m(!0),className:"rounded-[var(--ck-radius-sm)] bg-[var(--ck-accent-red)] px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] hover:bg-[var(--ck-accent-red-hover)]",children:"Add Orchestrator"})]}),(0,t.jsxs)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-tertiary)]",children:"Detection"}),(0,t.jsx)("div",{className:"mt-1 font-mono text-xs",children:i.reason||"(no reason provided)"})]}),(0,t.jsxs)("p",{className:"mt-3 text-sm text-[color:var(--ck-text-secondary)]",children:["Default convention is ",(0,t.jsx)("code",{children:"<teamId>-swarm-orchestrator"}),". Once installed, this tab will show: tmux sessions, git worktrees/branches, and active task state."]}),(0,t.jsx)(T,{open:n,onClose:()=>m(!1),teamId:e,onInstalled:()=>{m(!1),x()}})]}):(0,t.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Orchestrator"}),(0,t.jsx)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-3 text-sm text-red-100",children:i.error})]}):(0,t.jsx)("div",{className:"mt-6 ck-glass-strong p-4",children:"No orchestrator state available."})}var O=e.i(92140);let L=[{id:"recipe",label:"Recipe"},{id:"agents",label:"Agents"},{id:"skills",label:"Skills"},{id:"cron",label:"Cron"},{id:"files",label:"Files"},{id:"orchestrator",label:"Orchestrator"}],$=[{id:"memory",label:"Memory"},{id:"workflows",label:"Workflows"}];function M({teamId:e,initialTab:l}){let m=(0,r.useRouter)(),[x,h]=(0,s.useState)([]),[p,v]=(0,s.useState)(""),[g,k]=(0,s.useState)(null),[w,I]=(0,s.useState)(null),[A,T]=(0,s.useState)(!1),[M,_]=(0,s.useState)(e),[F,E]=(0,s.useState)(e),[P,J]=(0,s.useState)(""),[U,D]=(0,s.useState)(null),[H,W]=(0,s.useState)(()=>["recipe","agents","skills","cron","files","memory","orchestrator","workflows"].includes(l)?l:"recipe"),B=(0,s.useMemo)(()=>[...L,...$],[]),[z,V]=(0,s.useState)(!0),[q,G]=(0,s.useState)(!1),[K,Y]=(0,s.useState)(!1),[Q,X]=(0,s.useState)(!1),[Z,ee]=(0,s.useState)(!1),[et,es]=(0,s.useState)(""),ea=(0,c.useToast)(),[er,ei]=(0,s.useState)(!1),[el,eo]=(0,s.useState)(!1),[ec,en]=(0,s.useState)(null);function ed(e,t="info"){let s=String(e??"").trim();s&&ea.push({kind:t,message:s})}let[em,ex]=(0,s.useState)([]),[eh,ep]=(0,s.useState)(!1),[eu,ev]=(0,s.useState)(""),[eg,ek]=(0,s.useState)(!1),[ef,ey]=(0,s.useState)("SOUL.md"),[eb,ej]=(0,s.useState)(""),[eN,ew]=(0,s.useState)([]),[eS,eI]=(0,s.useState)(!1),[eC,eA]=(0,s.useState)([]),[eT,eR]=(0,s.useState)(!1),eO=(0,s.useMemo)(()=>{let e=String(P??"");if(!e.startsWith("---\n"))return[];let t=e.indexOf("\n---\n",4);if(-1===t)return[];let s=e.slice(4,t+1);try{let e=(0,a.parse)(s)??{};return(Array.isArray(e.agents)?e.agents:[]).map(e=>e).map(e=>({role:String(e.role??"").trim(),name:"string"==typeof e.name?e.name:void 0})).filter(e=>!!e.role)}catch{return[]}},[P]),[eL,e$]=(0,s.useState)(""),[eM,e_]=(0,s.useState)(""),[eF,eE]=(0,s.useState)(""),eP=(0,s.useMemo)(()=>("__custom__"===eL?eM:eL).trim()||"",[eL,eM]),[eJ,eU]=(0,s.useState)([]),[eD,eH]=(0,s.useState)([]),[eW,eB]=(0,s.useState)(!1),[ez,eV]=(0,s.useState)(""),[eq,eG]=(0,s.useState)(!1),[eK,eY]=(0,s.useState)(""),[eQ,eX]=(0,s.useState)(""),eZ=(0,s.useMemo)(()=>x.filter(e=>"team"===e.kind),[x]),e0=(0,s.useMemo)(()=>x.find(e=>e.id===M&&"workspace"===e.source)??x.find(e=>e.id===M)??null,[x,M]),e1=!!e.trim(),e2=!!M.trim(),e3=x.some(e=>e.id===M&&"workspace"===e.source),e5=!!(e0?.source==="builtin"&&!e3);async function e4(){let e=M.trim();if(e){ee(!0),es("");try{let t=await (0,d.fetchJson)(`/api/recipes/${encodeURIComponent(e)}`,{cache:"no-store"}),s=t.recipe;J(s.content),D("string"==typeof t.recipeHash?t.recipeHash:null)}catch(e){es((0,n.errorMessage)(e))}finally{ee(!1)}}}async function e6(e){let t=p.trim(),s=String(e.toId??M).trim(),a=String(e.toName??F).trim(),r=!!e.overwrite,i=!!e.scaffold;if(!t)throw Error("Source recipe id is required");if(!s)throw Error("Custom recipe id is required");return await (0,d.fetchJson)("/api/recipes/clone",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({fromId:t,toId:s,toName:a||void 0,overwrite:r,scaffold:i})})}async function e7(e,t){G(!0),ed("");try{let s=await e6({overwrite:e,...t});if(s.scaffold&&!s.scaffold.ok&&ed(`Scaffold failed (recipe was still cloned): ${s.scaffold.error||"Unknown error"}`,"error"),P.trim()&&P.trim()!==s.content.trim()){let e=function(e,t){if(!e.startsWith("---\n"))return e;let s=e.indexOf("\n---\n",4);if(-1===s)return e;let a=e.slice(4,s),r=e.slice(s+5),{next:i,sawTeamBlock:l,patched:o}=function(e,t){let s=[],a=!1,r=!1,i=!1;for(let l of e){if(/^team\s*:\s*$/i.test(l)){a=!0,r=!0,s.push(l);continue}if(a&&/^\S/.test(l)&&(a=!1),a&&/^\s+teamId\s*:/i.test(l)){s.push(` teamId: ${t}`),i=!0;continue}s.push(l)}return{next:s,sawTeamBlock:r,patched:i}}(a.split("\n"),t);if(l&&!o){let e=[];for(let s of i)e.push(s),/^team\s*:\s*$/i.test(s)&&e.push(` teamId: ${t}`);return`---
2
+ ${e.join("\n")}
3
+ ---
4
+ ${r}`}return`---
5
+ ${i.join("\n")}
6
+ ---
7
+ ${r}`}(function(e,t){var s;let a,r;if(!e.startsWith("---\n"))return e;let i=e.indexOf("\n---\n",4);if(-1===i)return e;let l=e.slice(4,i),o=e.slice(i+5),c=(s=l.split("\n"),a=!1,r=s.map(e=>/^id\s*:/i.test(e)?(a=!0,`id: ${t}`):e),a||r.unshift(`id: ${t}`),r);return`---
8
+ ${c.join("\n")}
9
+ ---
10
+ ${o}`}(P,M.trim()),M.trim());await (0,d.fetchJson)(`/api/recipes/${encodeURIComponent(M.trim())}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({content:e})}),J(e)}else J(s.content);try{let e=await (0,d.fetchJson)(`/api/recipes/${encodeURIComponent(M.trim())}`,{cache:"no-store"});"string"==typeof e.recipeHash&&D(e.recipeHash)}catch{D(null)}ed(`Saved team recipe: ${s.filePath}`,"success")}catch(e){ed((0,n.errorMessage)(e),"error")}finally{G(!1)}}async function e8(t){G(!0),ev("");try{let s=await (0,d.fetchJson)(`/api/teams/file?teamId=${encodeURIComponent(e)}&name=${encodeURIComponent(t)}`,{cache:"no-store"});if(!s.ok)throw Error("Failed to load file");ey(t),ej(String(s.content??""))}catch(e){ev((0,n.errorMessage)(e))}finally{G(!1)}}async function e9(){G(!0),ev("");try{if(!(await (0,d.fetchJson)("/api/teams/file",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:e,name:ef,content:eb})})).ok)throw Error("Failed to save file")}catch(e){ev((0,n.errorMessage)(e))}finally{G(!1)}}async function te(){G(!0);try{await f({teamId:e,toId:M,newRole:eL,derivedRole:eP,newRoleName:eF,content:P,setContent:J,setTeamAgents:eA,flashMessage:ed,ensureCustomRecipeExists:e6})}catch(e){ed((0,n.errorMessage)(e),"error")}finally{G(!1)}}async function tt(e,t,s){G(!0);try{await (0,d.fetchJson)("/api/cron/job",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({id:e,action:s})}),ed(`Cron ${s}: ${t}`,"success")}catch(e){ed((0,n.errorMessage)(e),"error")}finally{G(!1)}}async function ts(){eG(!0),eY(""),eX("");try{await (0,d.fetchJson)("/api/teams/skills/install",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:e,skill:ez})}),eY(`Installed skill: ${ez}`);try{let t=await (0,d.fetchJson)(`/api/teams/skills?teamId=${encodeURIComponent(e)}`,{cache:"no-store"});t.ok&&Array.isArray(t.skills)&&eU(t.skills)}catch{}}catch(e){eX((0,n.errorMessage)(e))}finally{eG(!1)}}return(0,s.useEffect)(()=>{_(e),E(e),J(""),D(null),en(null),eo(!1),ei(!1),l&&["recipe","agents","skills","cron","files","memory","orchestrator","workflows"].includes(l)&&W(l)},[e,l]),(0,s.useEffect)(()=>{let t=!1;return V(!0),u(e,{setRecipes:h,setLockedFromId:k,setLockedFromName:I,setProvenanceMissing:T,setFromId:v,setTeamMetaRecipeHash:en,setTeamFiles:ex,setCronJobs:ew,setTeamAgents:eA,setSkillsList:eU,setAvailableSkills:eH,setSelectedSkill:eV,setTeamFilesLoading:ep,setCronLoading:eI,setTeamAgentsLoading:eR,setSkillsLoading:eB}).then(()=>{t||V(!1)}).catch(e=>{ed((0,n.errorMessage)(e),"error"),t||V(!1)}),()=>{t=!0}},[e]),(0,s.useEffect)(()=>{!M.trim()||P.trim()||Z||e4()},[M]),(0,t.jsxs)("div",{className:"ck-glass w-full p-6 sm:p-8",children:[(0,t.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:"Team editor"}),(0,t.jsxs)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:["Bootstrap a ",(0,t.jsx)("strong",{children:"custom team recipe"})," for this installed team, without modifying builtin recipes."]}),(0,t.jsx)("div",{className:"mt-6 flex flex-wrap gap-2",children:B.map(e=>(0,t.jsx)("button",{onClick:()=>W(e.id),className:H===e.id?"rounded-[var(--ck-radius-sm)] bg-[var(--ck-accent-red)] px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)]":"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)] shadow-[var(--ck-shadow-1)] hover:bg-white/10",children:e.label},e.id))}),"recipe"===H&&(0,t.jsx)(y,{loading:z,fromId:p,setFromId:v,toId:M,setToId:_,toName:F,setToName:E,canEditTargetId:!0,teamRecipes:eZ,lockedFromId:g,lockedFromName:w,provenanceMissing:A,saving:q,teamIdValid:e1,targetIdValid:e2,targetIsBuiltin:e5,loadedRecipeHash:U,teamMetaRecipeHash:ec,publishing:K,content:P,setContent:J,setLoadedRecipeHash:D,recipeLoadError:et,onSaveCustom:e7,onPublishOpen:()=>eo(!0),onDeleteOpen:()=>ei(!0)}),"agents"===H&&(0,t.jsx)(b,{teamId:e,toId:M,recipeAgents:eO,newRole:eL,setNewRole:e$,customRole:eM,setCustomRole:e_,newRoleName:eF,setNewRoleName:eE,derivedRole:eP,saving:q,teamAgents:eC,teamAgentsLoading:eT,onAddAgent:te}),"skills"===H&&(0,t.jsx)(j,{teamId:e,skillsList:eJ,availableSkills:eD,skillsLoading:eW,selectedSkill:ez,setSelectedSkill:eV,installingSkill:eq,teamSkillMsg:eK,teamSkillError:eQ,onInstallSkill:ts}),"cron"===H&&(0,t.jsx)(N,{cronJobs:eN,cronLoading:eS,saving:q,onCronAction:tt}),"orchestrator"===H&&(0,t.jsx)(R,{teamId:e}),"memory"===H&&(0,t.jsx)("div",{className:"mt-6",children:(0,t.jsx)(C,{teamId:e})}),"workflows"===H&&(0,t.jsx)("div",{className:"mt-6",children:(0,t.jsx)(O.default,{teamId:e})}),"files"===H&&(0,t.jsx)(S,{teamFiles:em,teamFilesLoading:eh,showOptionalFiles:eg,setShowOptionalFiles:ek,fileName:ef,fileContent:eb,setFileContent:ej,teamFileError:eu,saving:q,onLoadTeamFile:e8,onSaveTeamFile:e9}),(0,t.jsx)(o,{open:el,teamId:e,recipeId:M,busy:K,onClose:()=>eo(!1),onConfirm:async()=>{Y(!0);try{await (0,d.fetchJson)("/api/scaffold",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({kind:"team",recipeId:M.trim(),teamId:e,overwrite:!0,applyConfig:!0})});try{let t=await (0,d.fetchJson)(`/api/teams/meta?teamId=${encodeURIComponent(e)}`,{cache:"no-store"});t.ok&&t.meta&&"string"==typeof t.meta.recipeHash&&en(t.meta.recipeHash)}catch{}eo(!1),ed("Published changes to active team","success")}catch(e){ed((0,n.errorMessage)(e),"error")}finally{Y(!1)}}}),(0,t.jsx)(i.DeleteTeamModal,{open:er,teamId:e,busy:Q,onClose:()=>ei(!1),onConfirm:async()=>{X(!0);try{await (0,d.fetchJson)("/api/teams/remove-team",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:e})}),ed("Deleted team successfully","success"),ei(!1),setTimeout(()=>m.push("/"),250)}catch(e){ed((0,n.errorMessage)(e),"error")}finally{X(!1)}}})]})}e.s(["default",()=>M],86103)}]);
@@ -0,0 +1 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,82310,e=>{"use strict";function t(e){return e instanceof Error?e.message:String(e)}e.s(["errorMessage",()=>t])},36288,e=>{"use strict";var t=e.i(43476),r=e.i(22016),s=e.i(18566),a=e.i(71645),o=e.i(76972),n=e.i(82310),c=e.i(42771);let l=new Set(["lead","dev","qa","tester","agent","system"]);function i({teamId:e,ticket:r,currentOwner:o}){let n=(0,s.useRouter)(),[c,l]=(0,a.useState)([]),[i,d]=(0,a.useState)(o??""),[m,x]=(0,a.useState)(!1),[u,b]=(0,a.useState)(null);(0,a.useEffect)(()=>{let t=!1;return(async()=>{try{let r=e?`/api/teams/${encodeURIComponent(e)}/tickets/assignees`:"/api/tickets/assignees",s=await fetch(r,{cache:"no-store"}),a=await s.json();if(t)return;l(Array.isArray(a.assignees)?a.assignees:[])}catch{if(t)return;l([])}})(),()=>{t=!0}},[]);let h=(0,a.useMemo)(()=>{let e=new Set(c);return o&&e.add(o),Array.from(e).sort()},[c,o]);async function p(){x(!0),b(null);try{let t=e?`/api/teams/${encodeURIComponent(e)}/tickets/assign`:"/api/tickets/assign",s=await fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ticket:r,assignee:i})}),a=await s.json();if(!s.ok)return void b(a.error||"Assign failed");n.refresh()}catch{b("Assign failed")}finally{x(!1)}}return(0,t.jsxs)("div",{className:"ck-glass p-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-tertiary)]",children:"Assignee"}),(0,t.jsxs)("select",{className:"rounded-md border border-white/10 bg-black/20 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]",value:i,onChange:e=>d(e.target.value),children:[(0,t.jsx)("option",{value:"",disabled:!0,children:"Select…"}),h.map(e=>(0,t.jsx)("option",{value:e,children:e},e))]}),(0,t.jsx)("button",{type:"button",onClick:p,disabled:m||!i||i===(o??""),className:"rounded-md bg-emerald-600 px-3 py-2 text-sm font-semibold text-white hover:bg-emerald-500 disabled:cursor-not-allowed disabled:opacity-50",children:m?"Assigning…":"Assign"}),o?(0,t.jsxs)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:["Currently: ",o]}):null]}),u?(0,t.jsx)("div",{className:"mt-2 text-xs text-red-300",children:u}):null]})}function d(e,t){return t||0==e.trim().length}function m(e){let m=(0,s.useRouter)(),x=(0,o.useToast)(),[u,b]=(0,a.useTransition)(),[h,p]=(0,a.useState)(null),[k,v]=(0,a.useState)(null),f=(0,a.useMemo)(()=>(function(e){let t=function(e){let t=/^## Comments\s*$/gim.exec(e);if(!t)return null;let r=t.index+t[0].length,s=e.slice(r).search(/^##\s+/m),a=-1===s?e.length:r+s;return{start:r,end:a}}(e);if(!t)return[];let r=e.slice(t.start,t.end).replace(/^\s+/,"").split("\n"),s=[],a=null,o=/^- \*\*(.+?)\*\*\s+—\s+(.*)$/;for(let e of r){let t=e.replace(/\r$/,""),r=t.match(o);if(r){a&&s.push({...a,body:a.body.trimEnd()});let e=r[1].trim(),t=r[2].trim(),o=t.indexOf(":"),n=(o>=0?t.slice(0,o):t).trim()||"unknown",c=o>=0?t.slice(o+1).trimStart():"",i=function(e){let t=e?.trim()||"unknown",r=t.match(/^(.*?)\s*\((.*?)\)\s*$/);if(r){let e=r[1].trim()||"unknown",s=r[2].trim();return{name:e,role:s&&s.toLowerCase()!=e.toLowerCase()?s:void 0,raw:t}}for(let e of[" — "," - "," | "]){if(!t.includes(e))continue;let[r,s]=t.split(e).map(e=>e.trim()).filter(Boolean);if(!r||!s)break;let a=l.has(r.toLowerCase()),o=l.has(s.toLowerCase());if(a&&!o)return{name:s,role:r,raw:t};return{name:r,role:s,raw:t}}return{name:t,raw:t}}(n);a={timestamp:e,authorName:i.name,authorRole:i.role,authorRaw:i.raw,body:c?c+"\n":""};continue}a&&(a.body+=t.replace(/^\s{0,2}/,"")+"\n")}return a&&s.push({...a,body:a.body.trimEnd()}),s})(e.markdown),[e.markdown]),[g,y]=(0,a.useState)(""),[j,w]=(0,a.useState)("");async function N(){p(null),await (0,c.fetchJson)(`/api/teams/${encodeURIComponent(e.teamId)}/tickets/move-to-goals`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ticket:e.ticketId})})}async function C(){p(null),await (0,c.fetchJson)(`/api/teams/${encodeURIComponent(e.teamId)}/tickets/delete`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ticket:e.ticketId})})}async function S(t){p(null),await (0,c.fetchJson)(`/api/teams/${encodeURIComponent(e.teamId)}/tickets/move`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ticket:e.ticketId,to:t})})}async function T(){p(null);let t=j.trim();if(!t)throw Error("Comment cannot be empty.");await (0,c.fetchJson)(`/api/teams/${encodeURIComponent(e.teamId)}/tickets/comment`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ticket:e.ticketId,author:g.trim()||void 0,comment:t})}),w(""),x.push({kind:"success",message:"Comment added."}),m.refresh()}return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)(r.default,{href:e.backHref??"/tickets",className:"text-sm font-medium hover:underline",children:"← Back"}),(0,t.jsx)("span",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:e.file})]}),h?(0,t.jsx)("div",{className:"ck-glass border border-[color:var(--ck-border-strong)] p-3 text-sm text-[color:var(--ck-text-primary)]",children:h}):null,(0,t.jsxs)("div",{className:"ck-glass p-6",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,t.jsx)("div",{className:"text-sm font-semibold text-[color:var(--ck-text-primary)]",children:"Ticket"}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[(0,t.jsxs)("label",{className:"flex items-center gap-2 text-xs text-[color:var(--ck-text-secondary)]",children:[(0,t.jsx)("span",{children:"Status"}),(0,t.jsxs)("select",{className:"rounded border border-[color:var(--ck-border-subtle)] bg-black/20 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",disabled:u,value:e.stage,onChange:t=>{let r=t.target.value;if(r!==e.stage){if("done"===r&&!window.confirm("Mark this ticket done? This will move the file to work/done and add an audit comment."))return;b(()=>{S(r).then(()=>{x.push({kind:"success",message:`Status updated to ${r}.`}),m.refresh()}).catch(e=>p((0,n.errorMessage)(e)))})}},children:[(0,t.jsx)("option",{value:"backlog",children:"backlog"}),(0,t.jsx)("option",{value:"in-progress",children:"in-progress"}),(0,t.jsx)("option",{value:"testing",children:"testing"}),(0,t.jsx)("option",{value:"done",children:"done"})]})]}),(0,t.jsx)("button",{className:"rounded border border-[color:var(--ck-border-subtle)] px-3 py-1.5 text-xs font-medium text-[color:var(--ck-text-secondary)] hover:border-[color:var(--ck-border-strong)]",onClick:()=>v({kind:"goals"}),disabled:u,children:"Move to Goals"}),(0,t.jsx)("button",{className:"rounded border border-[color:var(--ck-accent-red)] bg-[color:var(--ck-accent-red-soft)] px-3 py-1.5 text-xs font-medium text-[color:var(--ck-accent-red)] hover:bg-[color:var(--ck-accent-red-soft-strong)]",onClick:()=>v({kind:"delete"}),disabled:u,children:"Delete Ticket"})]})]}),void 0!==e.currentOwner?(0,t.jsx)("div",{className:"mt-4",children:(0,t.jsx)(i,{teamId:e.teamId,ticket:e.ticketId,currentOwner:e.currentOwner??null})}):null,(0,t.jsxs)("div",{className:"mt-6 border-t border-[color:var(--ck-border-subtle)] pt-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("div",{className:"text-sm font-semibold text-[color:var(--ck-text-primary)]",children:"Comments"}),(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:f.length})]}),f.length?(0,t.jsx)("div",{className:"mt-3 space-y-3",children:f.map((e,r)=>(0,t.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-[color:var(--ck-border-subtle)] bg-black/10 p-3",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-baseline gap-2",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-primary)]",children:e.authorName}),e.authorRole?(0,t.jsx)("div",{className:"rounded border border-[color:var(--ck-border-subtle)] bg-black/10 px-1.5 py-0.5 text-[10px] font-medium text-[color:var(--ck-text-tertiary)]",children:e.authorRole}):null]}),(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:e.timestamp})]}),(0,t.jsx)("div",{className:"mt-2 whitespace-pre-wrap break-words text-sm leading-6 text-[color:var(--ck-text-secondary)]",children:e.body})]},`${e.timestamp}-${r}`))}):(0,t.jsx)("div",{className:"mt-3 text-sm text-[color:var(--ck-text-secondary)]",children:"No comments yet."}),(0,t.jsxs)("div",{className:"mt-4 border-t border-[color:var(--ck-border-subtle)] pt-4",children:[(0,t.jsx)("div",{className:"text-sm font-semibold text-[color:var(--ck-text-primary)]",children:"Add comment"}),(0,t.jsxs)("div",{className:"mt-3 grid gap-3",children:[(0,t.jsxs)("div",{className:"grid gap-1",children:[(0,t.jsx)("label",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",htmlFor:"ck-comment-author",children:"Author (optional)"}),(0,t.jsx)("input",{id:"ck-comment-author",value:g,onChange:e=>y(e.target.value),placeholder:"unknown",className:"w-full rounded border border-[color:var(--ck-border-subtle)] bg-black/20 px-3 py-2 text-sm text-[color:var(--ck-text-primary)] outline-none focus:border-[color:var(--ck-border-strong)]",disabled:u})]}),(0,t.jsxs)("div",{className:"grid gap-1",children:[(0,t.jsx)("label",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",htmlFor:"ck-comment-body",children:"Comment"}),(0,t.jsx)("textarea",{id:"ck-comment-body",value:j,onChange:e=>w(e.target.value),rows:4,className:"w-full rounded border border-[color:var(--ck-border-subtle)] bg-black/20 px-3 py-2 text-sm text-[color:var(--ck-text-primary)] outline-none focus:border-[color:var(--ck-border-strong)]",disabled:u})]}),(0,t.jsx)("div",{className:"flex items-center justify-end",children:(0,t.jsx)("button",{type:"button","aria-busy":u,className:"rounded-[var(--ck-radius-sm)] bg-[color:var(--ck-accent)] px-3 py-2 text-xs font-semibold text-black transition hover:brightness-110 active:brightness-95 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--ck-border-strong)] focus-visible:ring-offset-2 focus-visible:ring-offset-black/30 disabled:cursor-not-allowed disabled:border disabled:border-[color:var(--ck-border-subtle)] disabled:bg-[color:var(--ck-bg-glass)] disabled:text-[color:var(--ck-text-tertiary)]",onClick:()=>{b(()=>{T().catch(e=>p((0,n.errorMessage)(e)))})},disabled:d(j,u),children:u?"Posting…":"Post comment"})})]})]})]})]}),(0,t.jsx)("div",{className:"ck-glass p-6",children:(0,t.jsx)("pre",{className:"whitespace-pre-wrap break-words text-sm leading-6 text-[color:var(--ck-text-primary)]",children:e.markdown})}),k?(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",children:(0,t.jsxs)("div",{className:"ck-glass w-full max-w-lg rounded-[var(--ck-radius-md)] border border-[color:var(--ck-border-strong)] p-4",children:[(0,t.jsx)("div",{className:"text-sm font-semibold text-[color:var(--ck-text-primary)]",children:"goals"===k.kind?"Move to Goals":"Delete ticket"}),(0,t.jsx)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"goals"===k.kind?(0,t.jsxs)(t.Fragment,{children:["This will move the ticket out of the work lanes into ",(0,t.jsx)("code",{children:"work/goals/"})," so it won’t be picked up by automation."]}):(0,t.jsx)(t.Fragment,{children:"This will permanently remove the ticket markdown file. Assignment stubs (if any) will be archived."})}),(0,t.jsxs)("div",{className:"mt-4 flex items-center justify-end gap-2",children:[(0,t.jsx)("button",{className:"rounded border border-[color:var(--ck-border-subtle)] px-3 py-1.5 text-xs text-[color:var(--ck-text-secondary)]",onClick:()=>v(null),disabled:u,children:"Cancel"}),(0,t.jsx)("button",{className:"delete"===k.kind?"rounded bg-[color:var(--ck-accent-red)] px-3 py-1.5 text-xs font-medium text-white":"rounded bg-[color:var(--ck-accent)] px-3 py-1.5 text-xs font-medium text-black",onClick:()=>{let t=k.kind;v(null),b(()=>{("goals"===t?N():C()).then(()=>{x.push({kind:"success",message:"delete"===t?"Ticket deleted.":"Moved to Goals."}),"delete"===t?m.push(e.backHref??"/tickets"):m.refresh()}).catch(e=>p((0,n.errorMessage)(e)))})},disabled:u,children:"Confirm"})]})]})}):null]})}e.s(["TicketDetailClient",()=>m,"isPostCommentDisabled",()=>d],36288)}]);
@@ -1 +1 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,42771,e=>{"use strict";async function t(e){return Promise.all(e.map(e=>fetch(e,{cache:"no-store"})))}async function r(e,t){let r=await fetch(e,t),o=await r.json();if(!r.ok)throw Error(o.error??"Request failed");return o}async function o(e,t){let r=await fetch(e,t),o=await r.json();return r.ok?{ok:!0,data:o}:{ok:!1,status:r.status,error:o.error??"Request failed"}}e.s(["fetchAll",()=>t,"fetchJson",()=>r,"fetchJsonWithStatus",()=>o])},33525,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"warnOnce",{enumerable:!0,get:function(){return o}});let o=e=>{}},98183,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o={assign:function(){return c},searchParamsToUrlQuery:function(){return a},urlQueryToSearchParams:function(){return l}};for(var n in o)Object.defineProperty(r,n,{enumerable:!0,get:o[n]});function a(e){let t={};for(let[r,o]of e.entries()){let e=t[r];void 0===e?t[r]=o:Array.isArray(e)?e.push(o):t[r]=[e,o]}return t}function s(e){return"string"==typeof e?e:("number"!=typeof e||isNaN(e))&&"boolean"!=typeof e?"":String(e)}function l(e){let t=new URLSearchParams;for(let[r,o]of Object.entries(e))if(Array.isArray(o))for(let e of o)t.append(r,s(e));else t.set(r,s(o));return t}function c(e,...t){for(let r of t){for(let t of r.keys())e.delete(t);for(let[t,o]of r.entries())e.append(t,o)}return e}},95057,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o={formatUrl:function(){return l},formatWithValidation:function(){return i},urlObjectKeys:function(){return c}};for(var n in o)Object.defineProperty(r,n,{enumerable:!0,get:o[n]});let a=e.r(90809)._(e.r(98183)),s=/https?|ftp|gopher|file/;function l(e){let{auth:t,hostname:r}=e,o=e.protocol||"",n=e.pathname||"",l=e.hash||"",c=e.query||"",i=!1;t=t?encodeURIComponent(t).replace(/%3A/i,":")+"@":"",e.host?i=t+e.host:r&&(i=t+(~r.indexOf(":")?`[${r}]`:r),e.port&&(i+=":"+e.port)),c&&"object"==typeof c&&(c=String(a.urlQueryToSearchParams(c)));let u=e.search||c&&`?${c}`||"";return o&&!o.endsWith(":")&&(o+=":"),e.slashes||(!o||s.test(o))&&!1!==i?(i="//"+(i||""),n&&"/"!==n[0]&&(n="/"+n)):i||(i=""),l&&"#"!==l[0]&&(l="#"+l),u&&"?"!==u[0]&&(u="?"+u),n=n.replace(/[?#]/g,encodeURIComponent),u=u.replace("#","%23"),`${o}${i}${n}${u}${l}`}let c=["auth","hash","host","hostname","href","path","pathname","port","protocol","query","search","slashes"];function i(e){return l(e)}},18581,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"useMergedRef",{enumerable:!0,get:function(){return n}});let o=e.r(71645);function n(e,t){let r=(0,o.useRef)(null),n=(0,o.useRef)(null);return(0,o.useCallback)(o=>{if(null===o){let e=r.current;e&&(r.current=null,e());let t=n.current;t&&(n.current=null,t())}else e&&(r.current=a(e,o)),t&&(n.current=a(t,o))},[e,t])}function a(e,t){if("function"!=typeof e)return e.current=t,()=>{e.current=null};{let r=e(t);return"function"==typeof r?r:()=>e(null)}}("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},18967,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o={DecodeError:function(){return v},MiddlewareNotFoundError:function(){return j},MissingStaticPage:function(){return b},NormalizeError:function(){return g},PageNotFoundError:function(){return k},SP:function(){return m},ST:function(){return x},WEB_VITALS:function(){return a},execOnce:function(){return s},getDisplayName:function(){return d},getLocationOrigin:function(){return i},getURL:function(){return u},isAbsoluteUrl:function(){return c},isResSent:function(){return h},loadGetInitialProps:function(){return p},normalizeRepeatedSlashes:function(){return f},stringifyError:function(){return y}};for(var n in o)Object.defineProperty(r,n,{enumerable:!0,get:o[n]});let a=["CLS","FCP","FID","INP","LCP","TTFB"];function s(e){let t,r=!1;return(...o)=>(r||(r=!0,t=e(...o)),t)}let l=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,c=e=>l.test(e);function i(){let{protocol:e,hostname:t,port:r}=window.location;return`${e}//${t}${r?":"+r:""}`}function u(){let{href:e}=window.location,t=i();return e.substring(t.length)}function d(e){return"string"==typeof e?e:e.displayName||e.name||"Unknown"}function h(e){return e.finished||e.headersSent}function f(e){let t=e.split("?");return t[0].replace(/\\/g,"/").replace(/\/\/+/g,"/")+(t[1]?`?${t.slice(1).join("?")}`:"")}async function p(e,t){let r=t.res||t.ctx&&t.ctx.res;if(!e.getInitialProps)return t.ctx&&t.Component?{pageProps:await p(t.Component,t.ctx)}:{};let o=await e.getInitialProps(t);if(r&&h(r))return o;if(!o)throw Object.defineProperty(Error(`"${d(e)}.getInitialProps()" should resolve to an object. But found "${o}" instead.`),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return o}let m="u">typeof performance,x=m&&["mark","measure","getEntriesByName"].every(e=>"function"==typeof performance[e]);class v extends Error{}class g extends Error{}class k extends Error{constructor(e){super(),this.code="ENOENT",this.name="PageNotFoundError",this.message=`Cannot find module for page: ${e}`}}class b extends Error{constructor(e,t){super(),this.message=`Failed to load static file for page: ${e} ${t}`}}class j extends Error{constructor(){super(),this.code="ENOENT",this.message="Cannot find the middleware module"}}function y(e){return JSON.stringify({message:e.message,stack:e.stack})}},73668,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"isLocalURL",{enumerable:!0,get:function(){return a}});let o=e.r(18967),n=e.r(52817);function a(e){if(!(0,o.isAbsoluteUrl)(e))return!0;try{let t=(0,o.getLocationOrigin)(),r=new URL(e,t);return r.origin===t&&(0,n.hasBasePath)(r.pathname)}catch(e){return!1}}},84508,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"errorOnce",{enumerable:!0,get:function(){return o}});let o=e=>{}},22016,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o={default:function(){return v},useLinkStatus:function(){return k}};for(var n in o)Object.defineProperty(r,n,{enumerable:!0,get:o[n]});let a=e.r(90809),s=e.r(43476),l=a._(e.r(71645)),c=e.r(95057),i=e.r(8372),u=e.r(18581),d=e.r(18967),h=e.r(5550);e.r(33525);let f=e.r(91949),p=e.r(73668),m=e.r(9396);function x(e){return"string"==typeof e?e:(0,c.formatUrl)(e)}function v(t){var r;let o,n,a,[c,v]=(0,l.useOptimistic)(f.IDLE_LINK_STATUS),k=(0,l.useRef)(null),{href:b,as:j,children:y,prefetch:w=null,passHref:N,replace:C,shallow:S,scroll:P,onClick:E,onMouseEnter:M,onTouchStart:L,legacyBehavior:R=!1,onNavigate:T,ref:_,unstable_dynamicOnHover:O,...I}=t;o=y,R&&("string"==typeof o||"number"==typeof o)&&(o=(0,s.jsx)("a",{children:o}));let A=l.default.useContext(i.AppRouterContext),W=!1!==w,$=!1!==w?null===(r=w)||"auto"===r?m.FetchStrategy.PPR:m.FetchStrategy.Full:m.FetchStrategy.PPR,{href:B,as:U}=l.default.useMemo(()=>{let e=x(b);return{href:e,as:j?x(j):e}},[b,j]);if(R){if(o?.$$typeof===Symbol.for("react.lazy"))throw Object.defineProperty(Error("`<Link legacyBehavior>` received a direct child that is either a Server Component, or JSX that was loaded with React.lazy(). This is not supported. Either remove legacyBehavior, or make the direct child a Client Component that renders the Link's `<a>` tag."),"__NEXT_ERROR_CODE",{value:"E863",enumerable:!1,configurable:!0});n=l.default.Children.only(o)}let z=R?n&&"object"==typeof n&&n.ref:_,D=l.default.useCallback(e=>(null!==A&&(k.current=(0,f.mountLinkInstance)(e,B,A,$,W,v)),()=>{k.current&&((0,f.unmountLinkForCurrentNavigation)(k.current),k.current=null),(0,f.unmountPrefetchableInstance)(e)}),[W,B,A,$,v]),F={ref:(0,u.useMergedRef)(D,z),onClick(t){R||"function"!=typeof E||E(t),R&&n.props&&"function"==typeof n.props.onClick&&n.props.onClick(t),!A||t.defaultPrevented||function(t,r,o,n,a,s,c){if("u">typeof window){let i,{nodeName:u}=t.currentTarget;if("A"===u.toUpperCase()&&((i=t.currentTarget.getAttribute("target"))&&"_self"!==i||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||t.nativeEvent&&2===t.nativeEvent.which)||t.currentTarget.hasAttribute("download"))return;if(!(0,p.isLocalURL)(r)){a&&(t.preventDefault(),location.replace(r));return}if(t.preventDefault(),c){let e=!1;if(c({preventDefault:()=>{e=!0}}),e)return}let{dispatchNavigateAction:d}=e.r(99781);l.default.startTransition(()=>{d(o||r,a?"replace":"push",s??!0,n.current)})}}(t,B,U,k,C,P,T)},onMouseEnter(e){R||"function"!=typeof M||M(e),R&&n.props&&"function"==typeof n.props.onMouseEnter&&n.props.onMouseEnter(e),A&&W&&(0,f.onNavigationIntent)(e.currentTarget,!0===O)},onTouchStart:function(e){R||"function"!=typeof L||L(e),R&&n.props&&"function"==typeof n.props.onTouchStart&&n.props.onTouchStart(e),A&&W&&(0,f.onNavigationIntent)(e.currentTarget,!0===O)}};return(0,d.isAbsoluteUrl)(U)?F.href=U:R&&!N&&("a"!==n.type||"href"in n.props)||(F.href=(0,h.addBasePath)(U)),a=R?l.default.cloneElement(n,F):(0,s.jsx)("a",{...I,...F,children:o}),(0,s.jsx)(g.Provider,{value:c,children:a})}e.r(84508);let g=(0,l.createContext)(f.IDLE_LINK_STATUS),k=()=>(0,l.useContext)(g);("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},18566,(e,t,r)=>{t.exports=e.r(76562)},76972,e=>{"use strict";var t=e.i(43476),r=e.i(71645);let o=(0,r.createContext)(null);function n({kind:e}){return"success"===e?(0,t.jsx)("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"h-5 w-5 text-emerald-400",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.707a1 1 0 00-1.414-1.414L9 10.172 7.707 8.879a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})}):"error"===e?(0,t.jsx)("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"h-5 w-5 text-red-400",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm-1-5a1 1 0 112 0 1 1 0 01-2 0zm0-8a1 1 0 012 0v6a1 1 0 11-2 0V5z",clipRule:"evenodd"})}):(0,t.jsx)("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"h-5 w-5 text-slate-300",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M18 10A8 8 0 11 2 10a8 8 0 0116 0zM9 9a1 1 0 112 0v5a1 1 0 11-2 0V9zm0-3a1 1 0 112 0 1 1 0 01-2 0z",clipRule:"evenodd"})})}function a({children:e}){let[a,s]=(0,r.useState)([]),l=(0,r.useCallback)(e=>{s(t=>t.filter(t=>t.id!==e))},[]),c=(0,r.useCallback)(e=>{s(t=>t.map(t=>t.id===e?{...t,state:"leave"}:t)),window.setTimeout(()=>l(e),250)},[l]),i=(0,r.useCallback)(e=>{s(t=>t.map(t=>t.id===e?{...t,state:"show"}:t))},[]),u=(0,r.useCallback)(e=>{let t,r=`${Date.now()}-${(t=new Uint8Array(8),crypto.getRandomValues(t),Array.from(t,e=>e.toString(16).padStart(2,"0")).join(""))}`,o={id:r,timeoutMs:5e3,state:"enter",...e};s(e=>[o,...e].slice(0,4)),window.setTimeout(()=>i(r),10);let n=o.timeoutMs;n&&n>0&&window.setTimeout(()=>c(r),n)},[c,i]),d=(0,r.useMemo)(()=>({push:u}),[u]);return(0,t.jsxs)(o.Provider,{value:d,children:[e,(0,t.jsx)("div",{"aria-live":"assertive",className:"pointer-events-none fixed inset-0 z-[100] flex items-end px-4 py-6 sm:p-6",children:(0,t.jsx)("div",{className:"flex w-full flex-col items-start space-y-4",children:a.map(e=>{var r;return(0,t.jsx)("div",{className:"pointer-events-auto w-full max-w-sm overflow-hidden rounded-lg border bg-[color:var(--ck-toast-bg)] shadow-[var(--ck-shadow-2)] transition-all duration-200 ease-out border-[color:var(--ck-toast-border)] "+("enter"===(r=e.state)||"leave"===r?"translate-x-[-16px] opacity-0":"translate-x-0 opacity-100"),children:(0,t.jsx)("div",{className:"p-4",children:(0,t.jsxs)("div",{className:"flex items-start",children:[(0,t.jsx)("div",{className:"shrink-0",children:(0,t.jsx)(n,{kind:e.kind})}),(0,t.jsxs)("div",{className:"ml-3 w-0 flex-1",children:[e.title?(0,t.jsx)("p",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:e.title}):null,(0,t.jsx)("p",{className:"whitespace-pre-wrap text-sm text-[color:var(--ck-text-primary)]",children:e.message})]}),(0,t.jsx)("div",{className:"ml-4 flex shrink-0",children:(0,t.jsxs)("button",{type:"button",onClick:()=>c(e.id),className:"inline-flex rounded-md bg-transparent text-[color:var(--ck-text-tertiary)] hover:text-[color:var(--ck-text-primary)]","aria-label":"Dismiss",title:"Dismiss",children:[(0,t.jsx)("span",{className:"sr-only",children:"Close"}),(0,t.jsx)("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"h-5 w-5",children:(0,t.jsx)("path",{d:"M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 10-1.06-1.06L10 8.94 6.28 5.22z"})})]})})]})})},e.id)})})})]})}function s(){let e=(0,r.useContext)(o);if(!e)throw Error("useToast must be used within ToastProvider");return e}e.s(["ToastProvider",()=>a,"useToast",()=>s])},65046,e=>{"use strict";var t=e.i(71645);let r="ck-selected-team-changed";function o(){try{return(localStorage.getItem("ck-selected-team")||"").trim()}catch{return""}}function n(e){let t=()=>e();return window.addEventListener("storage",t),window.addEventListener(r,t),()=>{window.removeEventListener("storage",t),window.removeEventListener(r,t)}}function a(){return(0,t.useSyncExternalStore)(n,o,()=>"")}function s(){try{window.dispatchEvent(new Event(r))}catch{}}e.s(["dispatchSelectedTeamChanged",()=>s,"useSelectedTeamId",()=>a])},49830,e=>{"use strict";var t=e.i(43476),r=e.i(22016),o=e.i(18566),n=e.i(71645),a=e.i(65046),s=n;class l extends s.default.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("ErrorBoundary caught:",e,t)}render(){return this.state.hasError&&this.state.error?this.props.fallback?this.props.fallback:(0,t.jsxs)("div",{className:"ck-glass mx-auto max-w-2xl p-6 sm:p-8",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold tracking-tight text-[color:var(--ck-text-primary)]",children:"Something went wrong"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"An unexpected error occurred. You can try refreshing the page or go back home."}),(0,t.jsx)("pre",{className:"mt-4 overflow-auto rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-3 font-mono text-xs text-[color:var(--ck-text-secondary)]",children:this.state.error.message}),(0,t.jsxs)("div",{className:"mt-6 flex flex-wrap gap-3",children:[(0,t.jsx)("button",{type:"button",onClick:()=>window.location.reload(),className:"rounded-[var(--ck-radius-sm)] bg-[var(--ck-accent-red)] px-4 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] hover:bg-[var(--ck-accent-red)]/90",children:"Refresh page"}),(0,t.jsx)(r.default,{href:"/",className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-4 py-2 text-sm font-medium text-[color:var(--ck-text-primary)] shadow-[var(--ck-shadow-1)] hover:bg-white/10",children:"Go home"})]})]}):this.props.children}}var c=e.i(42771);function i({className:e,children:r}){return(0,t.jsx)("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:r})}function u({className:e}){return(0,t.jsxs)(i,{className:e,children:[(0,t.jsx)("path",{d:"M12 18a6 6 0 1 0 0-12 6 6 0 0 0 0 12Z",stroke:"currentColor",strokeWidth:"1.8"}),(0,t.jsx)("path",{d:"M12 2v2.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),(0,t.jsx)("path",{d:"M12 19.5V22",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),(0,t.jsx)("path",{d:"M2 12h2.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),(0,t.jsx)("path",{d:"M19.5 12H22",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),(0,t.jsx)("path",{d:"M4.2 4.2 6 6",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),(0,t.jsx)("path",{d:"M18 18l1.8 1.8",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),(0,t.jsx)("path",{d:"M18 6l1.8-1.8",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),(0,t.jsx)("path",{d:"M4.2 19.8 6 18",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"})]})}function d({className:e}){return(0,t.jsx)(i,{className:e,children:(0,t.jsx)("path",{d:"M21 14.2A7.8 7.8 0 0 1 9.8 3a7 7 0 1 0 11.2 11.2Z",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round"})})}let h="ck-theme";function f(){return"light"===window.localStorage.getItem(h)?"light":"dark"}function p(){let[e,r]=(0,n.useState)(f);(0,n.useEffect)(()=>{document.documentElement.dataset.theme=e,window.localStorage.setItem(h,e)},[e]);let o="dark"===e?"Switch to light mode":"Switch to dark mode";return(0,t.jsxs)("button",{type:"button",onClick:function(){r(e=>"dark"===e?"light":"dark")},className:"grid h-9 w-9 place-items-center rounded-full border border-[color:var(--ck-border-subtle)] bg-[color:var(--ck-bg-glass)] text-[color:var(--ck-text-primary)] shadow-[var(--ck-shadow-1)] transition-colors hover:bg-[color:var(--ck-bg-glass-strong)]","aria-label":o,title:o,children:[(0,t.jsx)("span",{className:"sr-only",suppressHydrationWarning:!0,children:o}),"dark"===e?(0,t.jsx)(d,{className:"h-4.5 w-4.5"}):(0,t.jsx)(u,{className:"h-4.5 w-4.5"})]})}var m=e.i(76972);function x({children:e}){return(0,t.jsx)("span",{className:"grid size-7 place-items-center text-[color:var(--ck-text-secondary)]","aria-hidden":!0,children:e})}function v({href:e,label:o,icon:n,active:a,collapsed:s}){return(0,t.jsxs)(r.default,{href:e,title:o,className:(a?"flex items-center rounded-[var(--ck-radius-sm)] bg-white/10 text-sm font-medium text-[color:var(--ck-text-primary)]":"flex items-center rounded-[var(--ck-radius-sm)] text-sm font-medium text-[color:var(--ck-text-secondary)] transition-colors hover:bg-white/5 hover:text-[color:var(--ck-text-primary)]")+(s?" justify-center px-0 py-3":" gap-4 px-4 py-3"),children:[n,s?null:(0,t.jsx)("span",{children:o})]})}function g({children:e}){let s=(0,o.usePathname)()||"/",i=(0,o.useRouter)(),u=(0,n.useMemo)(()=>{let e=s.match(/^\/teams\/([^/]+)(?:\/|$)/);return e?decodeURIComponent(e[1]):null},[s]),d=(0,n.useMemo)(()=>s.startsWith("/teams/"),[s]),[h,f]=(0,n.useState)(()=>{try{return(localStorage.getItem("ck-selected-team")||"").trim()}catch{return""}}),g=(u||h).trim();function k(e){return g&&("/tickets"===e||"/goals"===e||"/cron-jobs"===e||"/runs"===e)?function(e,t){let[r,o]=e.split("?"),n=new URLSearchParams(o??"");return n.set("team",t),`${r}?${n.toString()}`}(e,g):e}function b(e){if(!s.startsWith("/teams/")&&("/tickets"===s||"/goals"===s||"/cron-jobs"===s||"/runs"===s))try{let t=new URL(window.location.href);if(!e){if(!t.searchParams.has("team"))return;t.searchParams.delete("team");let e=t.searchParams.toString();i.replace(t.pathname+(e?`?${e}`:""));return}if((t.searchParams.get("team")??"").trim()===e)return;t.searchParams.set("team",e),i.replace(t.pathname+"?"+t.searchParams.toString())}catch{}}(0,n.useEffect)(()=>{b(g)},[s,g]),(0,n.useEffect)(()=>{try{g?localStorage.setItem("ck-selected-team",g):localStorage.removeItem("ck-selected-team")}catch{}},[g]);let[j,y]=(0,n.useState)(!1);(0,n.useEffect)(()=>{try{let e=localStorage.getItem("ck-leftnav-collapsed");y("1"===e)}catch{}},[]);let[w,N]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{try{let e=await (0,c.fetchJson)("/api/agents",{cache:"no-store"}),t=Array.isArray(e.agents)?e.agents:[],r=new Set;for(let e of t){let t=String(e.workspace??"").split("/").filter(Boolean).find(e=>e.startsWith("workspace-"))??"";if(!t)continue;let o=t.slice(10);o&&"workspace"!==o&&r.add(o)}N(Array.from(r).sort())}catch{N([])}})()},[]);let C=[{href:"/",label:"Agents",icon:(0,t.jsx)(x,{children:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-6 w-6",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,t.jsx)("path",{d:"M3 11l9-8 9 8"}),(0,t.jsx)("path",{d:"M5 10v10h14V10"})]})})},{href:"/recipes",label:"Recipes",icon:(0,t.jsx)(x,{children:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-6 w-6",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,t.jsx)("path",{d:"M6 4h12v16H6z"}),(0,t.jsx)("path",{d:"M9 8h6"}),(0,t.jsx)("path",{d:"M9 12h6"})]})})},{href:k("/tickets"),label:"Tickets",icon:(0,t.jsx)(x,{children:(0,t.jsx)("svg",{viewBox:"0 0 24 24",className:"h-6 w-6",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,t.jsx)("path",{d:"M4 7h16v4a2 2 0 0 1 0 4v4H4v-4a2 2 0 0 0 0-4z"})})})},{href:"/channels",label:"Channels",icon:(0,t.jsx)(x,{children:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-6 w-6",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,t.jsx)("path",{d:"M4 6h16"}),(0,t.jsx)("path",{d:"M4 12h16"}),(0,t.jsx)("path",{d:"M4 18h16"}),(0,t.jsx)("path",{d:"M7 9h0"})]})})},{href:k("/goals"),label:"Goals",icon:(0,t.jsx)(x,{children:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-6 w-6",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,t.jsx)("path",{d:"M12 7v5l3 3"})]})})},{href:k("/cron-jobs"),label:"Cron jobs",icon:(0,t.jsx)(x,{children:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-6 w-6",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,t.jsx)("path",{d:"M12 7v5"})]})})},{href:k("/runs"),label:"Runs",icon:(0,t.jsx)(x,{children:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-6 w-6",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,t.jsx)("path",{d:"M4 19h16"}),(0,t.jsx)("path",{d:"M6 16l4-4 3 3 5-7"}),(0,t.jsx)("circle",{cx:"10",cy:"12",r:"1"}),(0,t.jsx)("circle",{cx:"13",cy:"15",r:"1"}),(0,t.jsx)("circle",{cx:"18",cy:"8",r:"1"})]})})},{href:"/settings",label:"Settings",icon:(0,t.jsx)(x,{children:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-6 w-6",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,t.jsx)("path",{d:"M12 15.5a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Z"}),(0,t.jsx)("path",{d:"M19.4 15a7.9 7.9 0 0 0 .1-1l2-1.5-2-3.5-2.4.5a7.8 7.8 0 0 0-1.7-1L13.5 3h-4L8.6 6.5a7.8 7.8 0 0 0-1.7 1L4.5 7l-2 3.5 2 1.5a7.9 7.9 0 0 0 .1 1l-2 1.5 2 3.5 2.4-.5a7.8 7.8 0 0 0 1.7 1L10.5 21h4l.9-3.5a7.8 7.8 0 0 0 1.7-1l2.4.5 2-3.5-2-1.5Z"})]})})}],S=j?"w-16":"w-72";return(0,t.jsx)(m.ToastProvider,{children:(0,t.jsxs)("div",{className:"flex h-dvh w-dvw overflow-hidden",children:[(0,t.jsxs)("aside",{className:`flex shrink-0 flex-col border-r border-[color:var(--ck-border-subtle)] bg-[color:var(--ck-bg-glass)] backdrop-blur-[var(--ck-glass-blur)] ${S}`,children:[(0,t.jsxs)("div",{className:"flex h-14 items-center justify-between gap-2 border-b border-[color:var(--ck-border-subtle)] px-3",children:[(0,t.jsx)(r.default,{href:"/",className:"text-sm font-semibold tracking-tight",title:"Home",children:j?"CK":"Claw Kitchen"}),(0,t.jsx)("button",{onClick:function(){y(e=>{let t=!e;try{localStorage.setItem("ck-leftnav-collapsed",t?"1":"0")}catch{}return t})},className:"rounded-[var(--ck-radius-sm)] px-2 py-1 text-sm text-[color:var(--ck-text-secondary)] hover:bg-white/5 hover:text-[color:var(--ck-text-primary)]",title:j?"Expand":"Collapse",children:j?"»":"«"})]}),(0,t.jsx)("div",{className:"border-b border-[color:var(--ck-border-subtle)] p-2",children:j?(0,t.jsx)("button",{className:"w-full rounded-[var(--ck-radius-sm)] bg-white/5 px-2 py-2 text-xs font-medium text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:g?`Team: ${g}`:"Select team",onClick:()=>{let e=w[0]||"";if(e){f(e);try{localStorage.setItem("ck-selected-team",e)}catch{}b(e)}},children:"👥"}):(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("div",{className:"px-2 pt-1 text-xs font-semibold uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"Team"}),(0,t.jsxs)("select",{value:g??"",disabled:d,onChange:e=>{let t=(e.target.value||"").trim();f(t);try{t?localStorage.setItem("ck-selected-team",t):localStorage.removeItem("ck-selected-team")}catch{}(0,a.dispatchSelectedTeamChanged)(),b(t)},className:"w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-2 text-sm text-[color:var(--ck-text-primary)]"+(d?" cursor-not-allowed opacity-60":""),children:[(0,t.jsx)("option",{value:"",children:"All teams"}),w.map(e=>(0,t.jsx)("option",{value:e,children:e},e))]}),g?(0,t.jsx)(r.default,{href:`/teams/${encodeURIComponent(g)}`,className:"px-2 pb-1 text-xs font-medium text-[color:var(--ck-text-tertiary)] hover:text-[color:var(--ck-text-secondary)]",children:"Edit team"}):null]})}),(0,t.jsxs)("nav",{className:"min-h-0 flex-1 overflow-auto p-2",children:[(0,t.jsx)("div",{className:"mt-2 px-2 pb-2 pt-2"}),C.map(e=>{let r;return(0,t.jsx)(v,{href:e.href,label:e.label,icon:(0,t.jsx)("span",{"aria-hidden":!0,children:e.icon}),collapsed:j,active:s===(r=e.href.split("?")[0])||s.startsWith(r+"/")},e.href)})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 border-t border-[color:var(--ck-border-subtle)] p-2",children:[(0,t.jsx)("a",{href:"https://github.com/JIGGAI/ClawRecipes/tree/main/docs",target:"_blank",rel:"noreferrer",className:j?"mx-auto rounded-[var(--ck-radius-sm)] px-2 py-2 text-sm text-[color:var(--ck-text-secondary)] hover:bg-white/5 hover:text-[color:var(--ck-text-primary)]":"rounded-[var(--ck-radius-sm)] px-3 py-2 text-sm font-medium text-[color:var(--ck-text-secondary)] hover:bg-white/5 hover:text-[color:var(--ck-text-primary)]",title:"Docs",children:j?"📖":"Docs"}),j?null:(0,t.jsx)(p,{})]})]}),(0,t.jsx)("div",{className:"min-w-0 flex-1",children:(0,t.jsx)("main",{className:"h-full overflow-auto p-4 md:p-6",children:(0,t.jsx)(l,{children:e})})})]})})}e.s(["AppShell",()=>g],49830)}]);
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,42771,e=>{"use strict";async function t(e){return Promise.all(e.map(e=>fetch(e,{cache:"no-store"})))}async function r(e,t){let r=await fetch(e,t),o=await r.json();if(!r.ok)throw Error(o.error??"Request failed");return o}async function o(e,t){let r=await fetch(e,t),o=await r.json();return r.ok?{ok:!0,data:o}:{ok:!1,status:r.status,error:o.error??"Request failed"}}e.s(["fetchAll",()=>t,"fetchJson",()=>r,"fetchJsonWithStatus",()=>o])},33525,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"warnOnce",{enumerable:!0,get:function(){return o}});let o=e=>{}},98183,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o={assign:function(){return c},searchParamsToUrlQuery:function(){return a},urlQueryToSearchParams:function(){return l}};for(var n in o)Object.defineProperty(r,n,{enumerable:!0,get:o[n]});function a(e){let t={};for(let[r,o]of e.entries()){let e=t[r];void 0===e?t[r]=o:Array.isArray(e)?e.push(o):t[r]=[e,o]}return t}function s(e){return"string"==typeof e?e:("number"!=typeof e||isNaN(e))&&"boolean"!=typeof e?"":String(e)}function l(e){let t=new URLSearchParams;for(let[r,o]of Object.entries(e))if(Array.isArray(o))for(let e of o)t.append(r,s(e));else t.set(r,s(o));return t}function c(e,...t){for(let r of t){for(let t of r.keys())e.delete(t);for(let[t,o]of r.entries())e.append(t,o)}return e}},95057,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o={formatUrl:function(){return l},formatWithValidation:function(){return i},urlObjectKeys:function(){return c}};for(var n in o)Object.defineProperty(r,n,{enumerable:!0,get:o[n]});let a=e.r(90809)._(e.r(98183)),s=/https?|ftp|gopher|file/;function l(e){let{auth:t,hostname:r}=e,o=e.protocol||"",n=e.pathname||"",l=e.hash||"",c=e.query||"",i=!1;t=t?encodeURIComponent(t).replace(/%3A/i,":")+"@":"",e.host?i=t+e.host:r&&(i=t+(~r.indexOf(":")?`[${r}]`:r),e.port&&(i+=":"+e.port)),c&&"object"==typeof c&&(c=String(a.urlQueryToSearchParams(c)));let u=e.search||c&&`?${c}`||"";return o&&!o.endsWith(":")&&(o+=":"),e.slashes||(!o||s.test(o))&&!1!==i?(i="//"+(i||""),n&&"/"!==n[0]&&(n="/"+n)):i||(i=""),l&&"#"!==l[0]&&(l="#"+l),u&&"?"!==u[0]&&(u="?"+u),n=n.replace(/[?#]/g,encodeURIComponent),u=u.replace("#","%23"),`${o}${i}${n}${u}${l}`}let c=["auth","hash","host","hostname","href","path","pathname","port","protocol","query","search","slashes"];function i(e){return l(e)}},18581,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"useMergedRef",{enumerable:!0,get:function(){return n}});let o=e.r(71645);function n(e,t){let r=(0,o.useRef)(null),n=(0,o.useRef)(null);return(0,o.useCallback)(o=>{if(null===o){let e=r.current;e&&(r.current=null,e());let t=n.current;t&&(n.current=null,t())}else e&&(r.current=a(e,o)),t&&(n.current=a(t,o))},[e,t])}function a(e,t){if("function"!=typeof e)return e.current=t,()=>{e.current=null};{let r=e(t);return"function"==typeof r?r:()=>e(null)}}("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},18967,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o={DecodeError:function(){return v},MiddlewareNotFoundError:function(){return j},MissingStaticPage:function(){return b},NormalizeError:function(){return g},PageNotFoundError:function(){return k},SP:function(){return m},ST:function(){return x},WEB_VITALS:function(){return a},execOnce:function(){return s},getDisplayName:function(){return d},getLocationOrigin:function(){return i},getURL:function(){return u},isAbsoluteUrl:function(){return c},isResSent:function(){return h},loadGetInitialProps:function(){return p},normalizeRepeatedSlashes:function(){return f},stringifyError:function(){return y}};for(var n in o)Object.defineProperty(r,n,{enumerable:!0,get:o[n]});let a=["CLS","FCP","FID","INP","LCP","TTFB"];function s(e){let t,r=!1;return(...o)=>(r||(r=!0,t=e(...o)),t)}let l=/^[a-zA-Z][a-zA-Z\d+\-.]*?:/,c=e=>l.test(e);function i(){let{protocol:e,hostname:t,port:r}=window.location;return`${e}//${t}${r?":"+r:""}`}function u(){let{href:e}=window.location,t=i();return e.substring(t.length)}function d(e){return"string"==typeof e?e:e.displayName||e.name||"Unknown"}function h(e){return e.finished||e.headersSent}function f(e){let t=e.split("?");return t[0].replace(/\\/g,"/").replace(/\/\/+/g,"/")+(t[1]?`?${t.slice(1).join("?")}`:"")}async function p(e,t){let r=t.res||t.ctx&&t.ctx.res;if(!e.getInitialProps)return t.ctx&&t.Component?{pageProps:await p(t.Component,t.ctx)}:{};let o=await e.getInitialProps(t);if(r&&h(r))return o;if(!o)throw Object.defineProperty(Error(`"${d(e)}.getInitialProps()" should resolve to an object. But found "${o}" instead.`),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return o}let m="u">typeof performance,x=m&&["mark","measure","getEntriesByName"].every(e=>"function"==typeof performance[e]);class v extends Error{}class g extends Error{}class k extends Error{constructor(e){super(),this.code="ENOENT",this.name="PageNotFoundError",this.message=`Cannot find module for page: ${e}`}}class b extends Error{constructor(e,t){super(),this.message=`Failed to load static file for page: ${e} ${t}`}}class j extends Error{constructor(){super(),this.code="ENOENT",this.message="Cannot find the middleware module"}}function y(e){return JSON.stringify({message:e.message,stack:e.stack})}},73668,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"isLocalURL",{enumerable:!0,get:function(){return a}});let o=e.r(18967),n=e.r(52817);function a(e){if(!(0,o.isAbsoluteUrl)(e))return!0;try{let t=(0,o.getLocationOrigin)(),r=new URL(e,t);return r.origin===t&&(0,n.hasBasePath)(r.pathname)}catch(e){return!1}}},84508,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"errorOnce",{enumerable:!0,get:function(){return o}});let o=e=>{}},22016,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o={default:function(){return v},useLinkStatus:function(){return k}};for(var n in o)Object.defineProperty(r,n,{enumerable:!0,get:o[n]});let a=e.r(90809),s=e.r(43476),l=a._(e.r(71645)),c=e.r(95057),i=e.r(8372),u=e.r(18581),d=e.r(18967),h=e.r(5550);e.r(33525);let f=e.r(91949),p=e.r(73668),m=e.r(9396);function x(e){return"string"==typeof e?e:(0,c.formatUrl)(e)}function v(t){var r;let o,n,a,[c,v]=(0,l.useOptimistic)(f.IDLE_LINK_STATUS),k=(0,l.useRef)(null),{href:b,as:j,children:y,prefetch:w=null,passHref:N,replace:C,shallow:S,scroll:E,onClick:P,onMouseEnter:M,onTouchStart:L,legacyBehavior:R=!1,onNavigate:T,ref:_,unstable_dynamicOnHover:O,...I}=t;o=y,R&&("string"==typeof o||"number"==typeof o)&&(o=(0,s.jsx)("a",{children:o}));let A=l.default.useContext(i.AppRouterContext),W=!1!==w,$=!1!==w?null===(r=w)||"auto"===r?m.FetchStrategy.PPR:m.FetchStrategy.Full:m.FetchStrategy.PPR,{href:B,as:U}=l.default.useMemo(()=>{let e=x(b);return{href:e,as:j?x(j):e}},[b,j]);if(R){if(o?.$$typeof===Symbol.for("react.lazy"))throw Object.defineProperty(Error("`<Link legacyBehavior>` received a direct child that is either a Server Component, or JSX that was loaded with React.lazy(). This is not supported. Either remove legacyBehavior, or make the direct child a Client Component that renders the Link's `<a>` tag."),"__NEXT_ERROR_CODE",{value:"E863",enumerable:!1,configurable:!0});n=l.default.Children.only(o)}let z=R?n&&"object"==typeof n&&n.ref:_,D=l.default.useCallback(e=>(null!==A&&(k.current=(0,f.mountLinkInstance)(e,B,A,$,W,v)),()=>{k.current&&((0,f.unmountLinkForCurrentNavigation)(k.current),k.current=null),(0,f.unmountPrefetchableInstance)(e)}),[W,B,A,$,v]),F={ref:(0,u.useMergedRef)(D,z),onClick(t){R||"function"!=typeof P||P(t),R&&n.props&&"function"==typeof n.props.onClick&&n.props.onClick(t),!A||t.defaultPrevented||function(t,r,o,n,a,s,c){if("u">typeof window){let i,{nodeName:u}=t.currentTarget;if("A"===u.toUpperCase()&&((i=t.currentTarget.getAttribute("target"))&&"_self"!==i||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||t.nativeEvent&&2===t.nativeEvent.which)||t.currentTarget.hasAttribute("download"))return;if(!(0,p.isLocalURL)(r)){a&&(t.preventDefault(),location.replace(r));return}if(t.preventDefault(),c){let e=!1;if(c({preventDefault:()=>{e=!0}}),e)return}let{dispatchNavigateAction:d}=e.r(99781);l.default.startTransition(()=>{d(o||r,a?"replace":"push",s??!0,n.current)})}}(t,B,U,k,C,E,T)},onMouseEnter(e){R||"function"!=typeof M||M(e),R&&n.props&&"function"==typeof n.props.onMouseEnter&&n.props.onMouseEnter(e),A&&W&&(0,f.onNavigationIntent)(e.currentTarget,!0===O)},onTouchStart:function(e){R||"function"!=typeof L||L(e),R&&n.props&&"function"==typeof n.props.onTouchStart&&n.props.onTouchStart(e),A&&W&&(0,f.onNavigationIntent)(e.currentTarget,!0===O)}};return(0,d.isAbsoluteUrl)(U)?F.href=U:R&&!N&&("a"!==n.type||"href"in n.props)||(F.href=(0,h.addBasePath)(U)),a=R?l.default.cloneElement(n,F):(0,s.jsx)("a",{...I,...F,children:o}),(0,s.jsx)(g.Provider,{value:c,children:a})}e.r(84508);let g=(0,l.createContext)(f.IDLE_LINK_STATUS),k=()=>(0,l.useContext)(g);("function"==typeof r.default||"object"==typeof r.default&&null!==r.default)&&void 0===r.default.__esModule&&(Object.defineProperty(r.default,"__esModule",{value:!0}),Object.assign(r.default,r),t.exports=r.default)},18566,(e,t,r)=>{t.exports=e.r(76562)},76972,e=>{"use strict";var t=e.i(43476),r=e.i(71645);let o=(0,r.createContext)(null);function n({kind:e}){return"success"===e?(0,t.jsx)("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"h-5 w-5 text-emerald-400",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.707a1 1 0 00-1.414-1.414L9 10.172 7.707 8.879a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})}):"error"===e?(0,t.jsx)("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"h-5 w-5 text-red-400",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm-1-5a1 1 0 112 0 1 1 0 01-2 0zm0-8a1 1 0 012 0v6a1 1 0 11-2 0V5z",clipRule:"evenodd"})}):(0,t.jsx)("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"h-5 w-5 text-slate-300",children:(0,t.jsx)("path",{fillRule:"evenodd",d:"M18 10A8 8 0 11 2 10a8 8 0 0116 0zM9 9a1 1 0 112 0v5a1 1 0 11-2 0V9zm0-3a1 1 0 112 0 1 1 0 01-2 0z",clipRule:"evenodd"})})}function a({children:e}){let[a,s]=(0,r.useState)([]),l=(0,r.useCallback)(e=>{s(t=>t.filter(t=>t.id!==e))},[]),c=(0,r.useCallback)(e=>{s(t=>t.map(t=>t.id===e?{...t,state:"leave"}:t)),window.setTimeout(()=>l(e),250)},[l]),i=(0,r.useCallback)(e=>{s(t=>t.map(t=>t.id===e?{...t,state:"show"}:t))},[]),u=(0,r.useCallback)(e=>{let t,r=`${Date.now()}-${(t=new Uint8Array(8),crypto.getRandomValues(t),Array.from(t,e=>e.toString(16).padStart(2,"0")).join(""))}`,o={id:r,timeoutMs:5e3,state:"enter",...e};s(e=>[o,...e].slice(0,4)),window.setTimeout(()=>i(r),10);let n=o.timeoutMs;n&&n>0&&window.setTimeout(()=>c(r),n)},[c,i]),d=(0,r.useMemo)(()=>({push:u}),[u]);return(0,t.jsxs)(o.Provider,{value:d,children:[e,(0,t.jsx)("div",{"aria-live":"assertive",className:"pointer-events-none fixed inset-0 z-[100] flex items-end px-4 py-6 sm:p-6",children:(0,t.jsx)("div",{className:"flex w-full flex-col items-start space-y-4",children:a.map(e=>{var r;return(0,t.jsx)("div",{className:"pointer-events-auto w-full max-w-sm overflow-hidden rounded-lg border bg-[color:var(--ck-toast-bg)] shadow-[var(--ck-shadow-2)] transition-all duration-200 ease-out border-[color:var(--ck-toast-border)] "+("enter"===(r=e.state)||"leave"===r?"translate-x-[-16px] opacity-0":"translate-x-0 opacity-100"),children:(0,t.jsx)("div",{className:"p-4",children:(0,t.jsxs)("div",{className:"flex items-start",children:[(0,t.jsx)("div",{className:"shrink-0",children:(0,t.jsx)(n,{kind:e.kind})}),(0,t.jsxs)("div",{className:"ml-3 w-0 flex-1",children:[e.title?(0,t.jsx)("p",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:e.title}):null,(0,t.jsx)("p",{className:"whitespace-pre-wrap text-sm text-[color:var(--ck-text-primary)]",children:e.message})]}),(0,t.jsx)("div",{className:"ml-4 flex shrink-0",children:(0,t.jsxs)("button",{type:"button",onClick:()=>c(e.id),className:"inline-flex rounded-md bg-transparent text-[color:var(--ck-text-tertiary)] hover:text-[color:var(--ck-text-primary)]","aria-label":"Dismiss",title:"Dismiss",children:[(0,t.jsx)("span",{className:"sr-only",children:"Close"}),(0,t.jsx)("svg",{viewBox:"0 0 20 20",fill:"currentColor",className:"h-5 w-5",children:(0,t.jsx)("path",{d:"M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 10-1.06-1.06L10 8.94 6.28 5.22z"})})]})})]})})},e.id)})})})]})}function s(){let e=(0,r.useContext)(o);if(!e)throw Error("useToast must be used within ToastProvider");return e}e.s(["ToastProvider",()=>a,"useToast",()=>s])},65046,e=>{"use strict";var t=e.i(71645);let r="ck-selected-team-changed";function o(){try{return(localStorage.getItem("ck-selected-team")||"").trim()}catch{return""}}function n(e){let t=()=>e();return window.addEventListener("storage",t),window.addEventListener(r,t),()=>{window.removeEventListener("storage",t),window.removeEventListener(r,t)}}function a(){return(0,t.useSyncExternalStore)(n,o,()=>"")}function s(){try{window.dispatchEvent(new Event(r))}catch{}}e.s(["dispatchSelectedTeamChanged",()=>s,"useSelectedTeamId",()=>a])},49830,e=>{"use strict";var t=e.i(43476),r=e.i(22016),o=e.i(18566),n=e.i(71645),a=e.i(65046),s=n;class l extends s.default.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error("ErrorBoundary caught:",e,t)}render(){return this.state.hasError&&this.state.error?this.props.fallback?this.props.fallback:(0,t.jsxs)("div",{className:"ck-glass mx-auto max-w-2xl p-6 sm:p-8",children:[(0,t.jsx)("h1",{className:"text-xl font-semibold tracking-tight text-[color:var(--ck-text-primary)]",children:"Something went wrong"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"An unexpected error occurred. You can try refreshing the page or go back home."}),(0,t.jsx)("pre",{className:"mt-4 overflow-auto rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-3 font-mono text-xs text-[color:var(--ck-text-secondary)]",children:this.state.error.message}),(0,t.jsxs)("div",{className:"mt-6 flex flex-wrap gap-3",children:[(0,t.jsx)("button",{type:"button",onClick:()=>window.location.reload(),className:"rounded-[var(--ck-radius-sm)] bg-[var(--ck-accent-red)] px-4 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] hover:bg-[var(--ck-accent-red)]/90",children:"Refresh page"}),(0,t.jsx)(r.default,{href:"/",className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-4 py-2 text-sm font-medium text-[color:var(--ck-text-primary)] shadow-[var(--ck-shadow-1)] hover:bg-white/10",children:"Go home"})]})]}):this.props.children}}var c=e.i(42771);function i({className:e,children:r}){return(0,t.jsx)("svg",{className:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:r})}function u({className:e}){return(0,t.jsxs)(i,{className:e,children:[(0,t.jsx)("path",{d:"M12 18a6 6 0 1 0 0-12 6 6 0 0 0 0 12Z",stroke:"currentColor",strokeWidth:"1.8"}),(0,t.jsx)("path",{d:"M12 2v2.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),(0,t.jsx)("path",{d:"M12 19.5V22",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),(0,t.jsx)("path",{d:"M2 12h2.5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),(0,t.jsx)("path",{d:"M19.5 12H22",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),(0,t.jsx)("path",{d:"M4.2 4.2 6 6",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),(0,t.jsx)("path",{d:"M18 18l1.8 1.8",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),(0,t.jsx)("path",{d:"M18 6l1.8-1.8",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),(0,t.jsx)("path",{d:"M4.2 19.8 6 18",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"})]})}function d({className:e}){return(0,t.jsx)(i,{className:e,children:(0,t.jsx)("path",{d:"M21 14.2A7.8 7.8 0 0 1 9.8 3a7 7 0 1 0 11.2 11.2Z",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round"})})}let h="ck-theme";function f(){return"light"===window.localStorage.getItem(h)?"light":"dark"}function p(){let[e,r]=(0,n.useState)(f);(0,n.useEffect)(()=>{document.documentElement.dataset.theme=e,window.localStorage.setItem(h,e)},[e]);let o="dark"===e?"Switch to light mode":"Switch to dark mode";return(0,t.jsxs)("button",{type:"button",onClick:function(){r(e=>"dark"===e?"light":"dark")},className:"grid h-9 w-9 place-items-center rounded-full border border-[color:var(--ck-border-subtle)] bg-[color:var(--ck-bg-glass)] text-[color:var(--ck-text-primary)] shadow-[var(--ck-shadow-1)] transition-colors hover:bg-[color:var(--ck-bg-glass-strong)]","aria-label":o,title:o,children:[(0,t.jsx)("span",{className:"sr-only",suppressHydrationWarning:!0,children:o}),"dark"===e?(0,t.jsx)(d,{className:"h-4.5 w-4.5"}):(0,t.jsx)(u,{className:"h-4.5 w-4.5"})]})}var m=e.i(76972);function x({children:e}){return(0,t.jsx)("span",{className:"grid size-7 place-items-center text-[color:var(--ck-text-secondary)]","aria-hidden":!0,children:e})}function v({href:e,label:o,icon:n,active:a,collapsed:s}){return(0,t.jsxs)(r.default,{href:e,title:o,className:(a?"flex items-center rounded-[var(--ck-radius-sm)] bg-white/10 text-sm font-medium text-[color:var(--ck-text-primary)]":"flex items-center rounded-[var(--ck-radius-sm)] text-sm font-medium text-[color:var(--ck-text-secondary)] transition-colors hover:bg-white/5 hover:text-[color:var(--ck-text-primary)]")+(s?" justify-center px-0 py-3":" gap-4 px-4 py-3"),children:[n,s?null:(0,t.jsx)("span",{children:o})]})}function g({children:e}){let s=(0,o.usePathname)()||"/",i=(0,o.useRouter)(),u=(0,n.useMemo)(()=>{let e=s.match(/^\/teams\/([^/]+)(?:\/|$)/);return e?decodeURIComponent(e[1]):null},[s]),d=(0,n.useMemo)(()=>s.startsWith("/teams/"),[s]),[h,f]=(0,n.useState)(""),g=(u||h).trim();function k(e){return g&&("/tickets"===e||"/goals"===e||"/cron-jobs"===e||"/runs"===e)?function(e,t){let[r,o]=e.split("?"),n=new URLSearchParams(o??"");return n.set("team",t),`${r}?${n.toString()}`}(e,g):e}function b(e){if(!s.startsWith("/teams/")&&("/tickets"===s||"/goals"===s||"/cron-jobs"===s||"/runs"===s))try{let t=new URL(window.location.href);if(!e){if(!t.searchParams.has("team"))return;t.searchParams.delete("team");let e=t.searchParams.toString();i.replace(t.pathname+(e?`?${e}`:""));return}if((t.searchParams.get("team")??"").trim()===e)return;t.searchParams.set("team",e),i.replace(t.pathname+"?"+t.searchParams.toString())}catch{}}(0,n.useEffect)(()=>{try{f((localStorage.getItem("ck-selected-team")||"").trim())}catch{}},[]),(0,n.useEffect)(()=>{b(g)},[s,g]),(0,n.useEffect)(()=>{try{g?localStorage.setItem("ck-selected-team",g):localStorage.removeItem("ck-selected-team")}catch{}},[g]);let[j,y]=(0,n.useState)(!1);(0,n.useEffect)(()=>{try{let e=localStorage.getItem("ck-leftnav-collapsed");y("1"===e)}catch{}},[]);let[w,N]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{try{let e=await (0,c.fetchJson)("/api/agents",{cache:"no-store"}),t=Array.isArray(e.agents)?e.agents:[],r=new Set;for(let e of t){let t=String(e.workspace??"").split("/").filter(Boolean).find(e=>e.startsWith("workspace-"))??"";if(!t)continue;let o=t.slice(10);o&&"workspace"!==o&&r.add(o)}N(Array.from(r).sort())}catch{N([])}})()},[]);let C=[{href:"/",label:"Agents",icon:(0,t.jsx)(x,{children:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-6 w-6",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,t.jsx)("path",{d:"M3 11l9-8 9 8"}),(0,t.jsx)("path",{d:"M5 10v10h14V10"})]})})},{href:"/recipes",label:"Recipes",icon:(0,t.jsx)(x,{children:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-6 w-6",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,t.jsx)("path",{d:"M6 4h12v16H6z"}),(0,t.jsx)("path",{d:"M9 8h6"}),(0,t.jsx)("path",{d:"M9 12h6"})]})})},{href:k("/tickets"),label:"Tickets",icon:(0,t.jsx)(x,{children:(0,t.jsx)("svg",{viewBox:"0 0 24 24",className:"h-6 w-6",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,t.jsx)("path",{d:"M4 7h16v4a2 2 0 0 1 0 4v4H4v-4a2 2 0 0 0 0-4z"})})})},{href:"/channels",label:"Channels",icon:(0,t.jsx)(x,{children:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-6 w-6",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,t.jsx)("path",{d:"M4 6h16"}),(0,t.jsx)("path",{d:"M4 12h16"}),(0,t.jsx)("path",{d:"M4 18h16"}),(0,t.jsx)("path",{d:"M7 9h0"})]})})},{href:k("/goals"),label:"Goals",icon:(0,t.jsx)(x,{children:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-6 w-6",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,t.jsx)("path",{d:"M12 7v5l3 3"})]})})},{href:k("/cron-jobs"),label:"Cron jobs",icon:(0,t.jsx)(x,{children:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-6 w-6",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,t.jsx)("path",{d:"M12 7v5"})]})})},{href:k("/runs"),label:"Runs",icon:(0,t.jsx)(x,{children:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-6 w-6",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,t.jsx)("path",{d:"M4 19h16"}),(0,t.jsx)("path",{d:"M6 16l4-4 3 3 5-7"}),(0,t.jsx)("circle",{cx:"10",cy:"12",r:"1"}),(0,t.jsx)("circle",{cx:"13",cy:"15",r:"1"}),(0,t.jsx)("circle",{cx:"18",cy:"8",r:"1"})]})})},{href:"/settings",label:"Settings",icon:(0,t.jsx)(x,{children:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-6 w-6",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,t.jsx)("path",{d:"M12 15.5a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Z"}),(0,t.jsx)("path",{d:"M19.4 15a7.9 7.9 0 0 0 .1-1l2-1.5-2-3.5-2.4.5a7.8 7.8 0 0 0-1.7-1L13.5 3h-4L8.6 6.5a7.8 7.8 0 0 0-1.7 1L4.5 7l-2 3.5 2 1.5a7.9 7.9 0 0 0 .1 1l-2 1.5 2 3.5 2.4-.5a7.8 7.8 0 0 0 1.7 1L10.5 21h4l.9-3.5a7.8 7.8 0 0 0 1.7-1l2.4.5 2-3.5-2-1.5Z"})]})})}],S=j?"w-16":"w-72";return(0,t.jsx)(m.ToastProvider,{children:(0,t.jsxs)("div",{className:"flex h-dvh w-dvw overflow-hidden",children:[(0,t.jsxs)("aside",{className:`flex shrink-0 flex-col border-r border-[color:var(--ck-border-subtle)] bg-[color:var(--ck-bg-glass)] backdrop-blur-[var(--ck-glass-blur)] ${S}`,children:[(0,t.jsxs)("div",{className:"flex h-14 items-center justify-between gap-2 border-b border-[color:var(--ck-border-subtle)] px-3",children:[(0,t.jsx)(r.default,{href:"/",className:"text-sm font-semibold tracking-tight",title:"Home",children:j?"CK":"Claw Kitchen"}),(0,t.jsx)("button",{onClick:function(){y(e=>{let t=!e;try{localStorage.setItem("ck-leftnav-collapsed",t?"1":"0")}catch{}return t})},className:"rounded-[var(--ck-radius-sm)] px-2 py-1 text-sm text-[color:var(--ck-text-secondary)] hover:bg-white/5 hover:text-[color:var(--ck-text-primary)]",title:j?"Expand":"Collapse",children:j?"»":"«"})]}),(0,t.jsx)("div",{className:"border-b border-[color:var(--ck-border-subtle)] p-2",children:j?(0,t.jsx)("button",{className:"w-full rounded-[var(--ck-radius-sm)] bg-white/5 px-2 py-2 text-xs font-medium text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:g?`Team: ${g}`:"Select team",onClick:()=>{let e=w[0]||"";if(e){f(e);try{localStorage.setItem("ck-selected-team",e)}catch{}b(e)}},children:"👥"}):(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("div",{className:"px-2 pt-1 text-xs font-semibold uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"Team"}),(0,t.jsxs)("select",{value:g??"",disabled:d,onChange:e=>{let t=(e.target.value||"").trim();f(t);try{t?localStorage.setItem("ck-selected-team",t):localStorage.removeItem("ck-selected-team")}catch{}(0,a.dispatchSelectedTeamChanged)(),b(t)},className:"w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-2 text-sm text-[color:var(--ck-text-primary)]"+(d?" cursor-not-allowed opacity-60":""),children:[(0,t.jsx)("option",{value:"",children:"All teams"}),w.map(e=>(0,t.jsx)("option",{value:e,children:e},e))]}),g?(0,t.jsx)(r.default,{href:`/teams/${encodeURIComponent(g)}`,className:"px-2 pb-1 text-xs font-medium text-[color:var(--ck-text-tertiary)] hover:text-[color:var(--ck-text-secondary)]",children:"Edit team"}):null]})}),(0,t.jsxs)("nav",{className:"min-h-0 flex-1 overflow-auto p-2",children:[(0,t.jsx)("div",{className:"mt-2 px-2 pb-2 pt-2"}),C.map(e=>{let r;return(0,t.jsx)(v,{href:e.href,label:e.label,icon:(0,t.jsx)("span",{"aria-hidden":!0,children:e.icon}),collapsed:j,active:s===(r=e.href.split("?")[0])||s.startsWith(r+"/")},e.href)})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 border-t border-[color:var(--ck-border-subtle)] p-2",children:[(0,t.jsx)("a",{href:"https://github.com/JIGGAI/ClawRecipes/tree/main/docs",target:"_blank",rel:"noreferrer",className:j?"mx-auto rounded-[var(--ck-radius-sm)] px-2 py-2 text-sm text-[color:var(--ck-text-secondary)] hover:bg-white/5 hover:text-[color:var(--ck-text-primary)]":"rounded-[var(--ck-radius-sm)] px-3 py-2 text-sm font-medium text-[color:var(--ck-text-secondary)] hover:bg-white/5 hover:text-[color:var(--ck-text-primary)]",title:"Docs",children:j?"📖":"Docs"}),j?null:(0,t.jsx)(p,{})]})]}),(0,t.jsx)("div",{className:"min-w-0 flex-1",children:(0,t.jsx)("main",{className:"h-full overflow-auto p-4 md:p-6",children:(0,t.jsx)(l,{children:e})})})]})})}e.s(["AppShell",()=>g],49830)}]);