@ulpi/cli 0.1.10 → 0.1.12

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 (199) hide show
  1. package/dist/{chunk-F32YQRFR.js → chunk-3YFN5ZOR.js} +1 -1
  2. package/dist/{ci-QBXWR3GW.js → ci-EXYAXQVI.js} +1 -1
  3. package/dist/{doctor-SRJIZM2T.js → doctor-2EHFGL6W.js} +1 -1
  4. package/dist/{history-UGYO7Z3U.js → history-MXKIYCX4.js} +1 -1
  5. package/dist/index.js +8 -8
  6. package/dist/portal/apps/portal/.next/BUILD_ID +1 -1
  7. package/dist/portal/apps/portal/.next/app-build-manifest.json +107 -107
  8. package/dist/portal/apps/portal/.next/app-path-routes-manifest.json +18 -18
  9. package/dist/portal/apps/portal/.next/build-manifest.json +2 -2
  10. package/dist/portal/apps/portal/.next/prerender-manifest.json +109 -109
  11. package/dist/portal/apps/portal/.next/server/app/(dashboard)/billing/page_client-reference-manifest.js +1 -1
  12. package/dist/portal/apps/portal/.next/server/app/(dashboard)/codemap/page_client-reference-manifest.js +1 -1
  13. package/dist/portal/apps/portal/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  14. package/dist/portal/apps/portal/.next/server/app/(dashboard)/history/[sha]/transcript/page_client-reference-manifest.js +1 -1
  15. package/dist/portal/apps/portal/.next/server/app/(dashboard)/history/page.js +1 -1
  16. package/dist/portal/apps/portal/.next/server/app/(dashboard)/history/page_client-reference-manifest.js +1 -1
  17. package/dist/portal/apps/portal/.next/server/app/(dashboard)/jobs/[id]/page_client-reference-manifest.js +1 -1
  18. package/dist/portal/apps/portal/.next/server/app/(dashboard)/jobs/page_client-reference-manifest.js +1 -1
  19. package/dist/portal/apps/portal/.next/server/app/(dashboard)/loop/page.js +1 -1
  20. package/dist/portal/apps/portal/.next/server/app/(dashboard)/loop/page_client-reference-manifest.js +1 -1
  21. package/dist/portal/apps/portal/.next/server/app/(dashboard)/mcps/[name]/page_client-reference-manifest.js +1 -1
  22. package/dist/portal/apps/portal/.next/server/app/(dashboard)/mcps/catalog/page_client-reference-manifest.js +1 -1
  23. package/dist/portal/apps/portal/.next/server/app/(dashboard)/mcps/page_client-reference-manifest.js +1 -1
  24. package/dist/portal/apps/portal/.next/server/app/(dashboard)/mcps/secrets/page_client-reference-manifest.js +1 -1
  25. package/dist/portal/apps/portal/.next/server/app/(dashboard)/mcps/submissions/page_client-reference-manifest.js +1 -1
  26. package/dist/portal/apps/portal/.next/server/app/(dashboard)/mcps/usage/page_client-reference-manifest.js +1 -1
  27. package/dist/portal/apps/portal/.next/server/app/(dashboard)/memory/page_client-reference-manifest.js +1 -1
  28. package/dist/portal/apps/portal/.next/server/app/(dashboard)/memory/settings/page_client-reference-manifest.js +1 -1
  29. package/dist/portal/apps/portal/.next/server/app/(dashboard)/memory/timeline/page_client-reference-manifest.js +1 -1
  30. package/dist/portal/apps/portal/.next/server/app/(dashboard)/notifications/page_client-reference-manifest.js +1 -1
  31. package/dist/portal/apps/portal/.next/server/app/(dashboard)/parallel/page.js +1 -1
  32. package/dist/portal/apps/portal/.next/server/app/(dashboard)/parallel/page_client-reference-manifest.js +1 -1
  33. package/dist/portal/apps/portal/.next/server/app/(dashboard)/prd/page_client-reference-manifest.js +1 -1
  34. package/dist/portal/apps/portal/.next/server/app/(dashboard)/repos/[id]/guards/page_client-reference-manifest.js +1 -1
  35. package/dist/portal/apps/portal/.next/server/app/(dashboard)/repos/[id]/page_client-reference-manifest.js +1 -1
  36. package/dist/portal/apps/portal/.next/server/app/(dashboard)/repos/page_client-reference-manifest.js +1 -1
  37. package/dist/portal/apps/portal/.next/server/app/(dashboard)/review/config/page_client-reference-manifest.js +1 -1
  38. package/dist/portal/apps/portal/.next/server/app/(dashboard)/review/page_client-reference-manifest.js +1 -1
  39. package/dist/portal/apps/portal/.next/server/app/(dashboard)/review/plan/page_client-reference-manifest.js +1 -1
  40. package/dist/portal/apps/portal/.next/server/app/(dashboard)/review/queue/page_client-reference-manifest.js +1 -1
  41. package/dist/portal/apps/portal/.next/server/app/(dashboard)/rules/[id]/page_client-reference-manifest.js +1 -1
  42. package/dist/portal/apps/portal/.next/server/app/(dashboard)/rules/new/page_client-reference-manifest.js +1 -1
  43. package/dist/portal/apps/portal/.next/server/app/(dashboard)/rules/page_client-reference-manifest.js +1 -1
  44. package/dist/portal/apps/portal/.next/server/app/(dashboard)/rules/pipelines/page_client-reference-manifest.js +1 -1
  45. package/dist/portal/apps/portal/.next/server/app/(dashboard)/sessions/[sessionId]/page_client-reference-manifest.js +1 -1
  46. package/dist/portal/apps/portal/.next/server/app/(dashboard)/sessions/page.js +1 -1
  47. package/dist/portal/apps/portal/.next/server/app/(dashboard)/sessions/page_client-reference-manifest.js +1 -1
  48. package/dist/portal/apps/portal/.next/server/app/(dashboard)/settings/github/page_client-reference-manifest.js +1 -1
  49. package/dist/portal/apps/portal/.next/server/app/(dashboard)/settings/installations/page_client-reference-manifest.js +1 -1
  50. package/dist/portal/apps/portal/.next/server/app/(dashboard)/settings/keys/page_client-reference-manifest.js +1 -1
  51. package/dist/portal/apps/portal/.next/server/app/(dashboard)/settings/members/page_client-reference-manifest.js +1 -1
  52. package/dist/portal/apps/portal/.next/server/app/(dashboard)/settings/orgs/new/page_client-reference-manifest.js +1 -1
  53. package/dist/portal/apps/portal/.next/server/app/(dashboard)/settings/page_client-reference-manifest.js +1 -1
  54. package/dist/portal/apps/portal/.next/server/app/(dashboard)/skills/page_client-reference-manifest.js +1 -1
  55. package/dist/portal/apps/portal/.next/server/app/(dashboard)/sprints/[batchId]/page_client-reference-manifest.js +1 -1
  56. package/dist/portal/apps/portal/.next/server/app/(dashboard)/sprints/page_client-reference-manifest.js +1 -1
  57. package/dist/portal/apps/portal/.next/server/app/(dashboard)/templates/page_client-reference-manifest.js +1 -1
  58. package/dist/portal/apps/portal/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  59. package/dist/portal/apps/portal/.next/server/app/_not-found.html +1 -1
  60. package/dist/portal/apps/portal/.next/server/app/_not-found.rsc +1 -1
  61. package/dist/portal/apps/portal/.next/server/app/auth/callback/page_client-reference-manifest.js +1 -1
  62. package/dist/portal/apps/portal/.next/server/app/auth/callback.html +1 -1
  63. package/dist/portal/apps/portal/.next/server/app/auth/callback.rsc +1 -1
  64. package/dist/portal/apps/portal/.next/server/app/billing.html +1 -1
  65. package/dist/portal/apps/portal/.next/server/app/billing.rsc +3 -3
  66. package/dist/portal/apps/portal/.next/server/app/codemap.html +1 -1
  67. package/dist/portal/apps/portal/.next/server/app/codemap.rsc +3 -3
  68. package/dist/portal/apps/portal/.next/server/app/dashboard.html +1 -1
  69. package/dist/portal/apps/portal/.next/server/app/dashboard.rsc +3 -3
  70. package/dist/portal/apps/portal/.next/server/app/history.html +1 -1
  71. package/dist/portal/apps/portal/.next/server/app/history.rsc +3 -3
  72. package/dist/portal/apps/portal/.next/server/app/jobs.html +1 -1
  73. package/dist/portal/apps/portal/.next/server/app/jobs.rsc +3 -3
  74. package/dist/portal/apps/portal/.next/server/app/loop.html +1 -1
  75. package/dist/portal/apps/portal/.next/server/app/loop.rsc +3 -3
  76. package/dist/portal/apps/portal/.next/server/app/mcps/catalog.html +1 -1
  77. package/dist/portal/apps/portal/.next/server/app/mcps/catalog.rsc +3 -3
  78. package/dist/portal/apps/portal/.next/server/app/mcps/secrets.html +1 -1
  79. package/dist/portal/apps/portal/.next/server/app/mcps/secrets.rsc +3 -3
  80. package/dist/portal/apps/portal/.next/server/app/mcps/submissions.html +1 -1
  81. package/dist/portal/apps/portal/.next/server/app/mcps/submissions.rsc +3 -3
  82. package/dist/portal/apps/portal/.next/server/app/mcps/usage.html +1 -1
  83. package/dist/portal/apps/portal/.next/server/app/mcps/usage.rsc +3 -3
  84. package/dist/portal/apps/portal/.next/server/app/mcps.html +1 -1
  85. package/dist/portal/apps/portal/.next/server/app/mcps.rsc +3 -3
  86. package/dist/portal/apps/portal/.next/server/app/memory/settings.html +1 -1
  87. package/dist/portal/apps/portal/.next/server/app/memory/settings.rsc +3 -3
  88. package/dist/portal/apps/portal/.next/server/app/memory/timeline.html +1 -1
  89. package/dist/portal/apps/portal/.next/server/app/memory/timeline.rsc +3 -3
  90. package/dist/portal/apps/portal/.next/server/app/memory.html +1 -1
  91. package/dist/portal/apps/portal/.next/server/app/memory.rsc +3 -3
  92. package/dist/portal/apps/portal/.next/server/app/notifications.html +1 -1
  93. package/dist/portal/apps/portal/.next/server/app/notifications.rsc +3 -3
  94. package/dist/portal/apps/portal/.next/server/app/parallel.html +1 -1
  95. package/dist/portal/apps/portal/.next/server/app/parallel.rsc +3 -3
  96. package/dist/portal/apps/portal/.next/server/app/prd.html +1 -1
  97. package/dist/portal/apps/portal/.next/server/app/prd.rsc +3 -3
  98. package/dist/portal/apps/portal/.next/server/app/repos.html +1 -1
  99. package/dist/portal/apps/portal/.next/server/app/repos.rsc +3 -3
  100. package/dist/portal/apps/portal/.next/server/app/review/config.html +1 -1
  101. package/dist/portal/apps/portal/.next/server/app/review/config.rsc +3 -3
  102. package/dist/portal/apps/portal/.next/server/app/review/plan.html +1 -1
  103. package/dist/portal/apps/portal/.next/server/app/review/plan.rsc +3 -3
  104. package/dist/portal/apps/portal/.next/server/app/review/queue.html +1 -1
  105. package/dist/portal/apps/portal/.next/server/app/review/queue.rsc +3 -3
  106. package/dist/portal/apps/portal/.next/server/app/review.html +1 -1
  107. package/dist/portal/apps/portal/.next/server/app/review.meta +2 -0
  108. package/dist/portal/apps/portal/.next/server/app/review.rsc +2 -2
  109. package/dist/portal/apps/portal/.next/server/app/rules/new.html +1 -1
  110. package/dist/portal/apps/portal/.next/server/app/rules/new.rsc +3 -3
  111. package/dist/portal/apps/portal/.next/server/app/rules/pipelines.html +1 -1
  112. package/dist/portal/apps/portal/.next/server/app/rules/pipelines.rsc +3 -3
  113. package/dist/portal/apps/portal/.next/server/app/rules.html +1 -1
  114. package/dist/portal/apps/portal/.next/server/app/rules.rsc +3 -3
  115. package/dist/portal/apps/portal/.next/server/app/sessions.html +1 -1
  116. package/dist/portal/apps/portal/.next/server/app/sessions.rsc +3 -3
  117. package/dist/portal/apps/portal/.next/server/app/settings/github.html +1 -1
  118. package/dist/portal/apps/portal/.next/server/app/settings/github.rsc +3 -3
  119. package/dist/portal/apps/portal/.next/server/app/settings/installations.html +1 -1
  120. package/dist/portal/apps/portal/.next/server/app/settings/installations.rsc +2 -2
  121. package/dist/portal/apps/portal/.next/server/app/settings/keys.html +1 -1
  122. package/dist/portal/apps/portal/.next/server/app/settings/keys.rsc +3 -3
  123. package/dist/portal/apps/portal/.next/server/app/settings/members.html +1 -1
  124. package/dist/portal/apps/portal/.next/server/app/settings/members.rsc +3 -3
  125. package/dist/portal/apps/portal/.next/server/app/settings/orgs/new.html +1 -1
  126. package/dist/portal/apps/portal/.next/server/app/settings/orgs/new.rsc +3 -3
  127. package/dist/portal/apps/portal/.next/server/app/settings.html +1 -1
  128. package/dist/portal/apps/portal/.next/server/app/settings.rsc +3 -3
  129. package/dist/portal/apps/portal/.next/server/app/skills.html +1 -1
  130. package/dist/portal/apps/portal/.next/server/app/skills.rsc +3 -3
  131. package/dist/portal/apps/portal/.next/server/app/sprints.html +1 -1
  132. package/dist/portal/apps/portal/.next/server/app/sprints.rsc +3 -3
  133. package/dist/portal/apps/portal/.next/server/app/templates.html +1 -1
  134. package/dist/portal/apps/portal/.next/server/app/templates.rsc +3 -3
  135. package/dist/portal/apps/portal/.next/server/app-paths-manifest.json +18 -18
  136. package/dist/portal/apps/portal/.next/server/chunks/1522.js +1 -1
  137. package/dist/portal/apps/portal/.next/server/next-font-manifest.js +1 -1
  138. package/dist/portal/apps/portal/.next/server/next-font-manifest.json +1 -1
  139. package/dist/portal/apps/portal/.next/server/pages/404.html +1 -1
  140. package/dist/portal/apps/portal/.next/server/pages/500.html +1 -1
  141. package/dist/portal/apps/portal/.next/server/pages-manifest.json +1 -1
  142. package/dist/portal/apps/portal/.next/static/chunks/380-71bdca6a9260da3e.js +1 -0
  143. package/dist/portal/apps/portal/.next/static/chunks/7525-85f4ca4276511230.js +1 -0
  144. package/dist/portal/apps/portal/.next/static/chunks/7889-a8be276e20a74863.js +1 -0
  145. package/dist/portal/apps/portal/.next/static/chunks/8744-29d969a2ddf40afe.js +1 -0
  146. package/dist/portal/apps/portal/.next/static/chunks/{8934-bb365eb647fb2d5a.js → 8934-9fbad2b348b6ada1.js} +1 -1
  147. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/codemap/page-e85b24075b2ae8e9.js +1 -0
  148. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/dashboard/page-701be25e4930fcb6.js +1 -0
  149. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/history/{page-264989cf873cd3de.js → page-0275ca43fdd64bf2.js} +1 -1
  150. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/layout-4232b69653c5fbbf.js +1 -0
  151. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/loop/page-c3f658ffb8d7397b.js +1 -0
  152. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/mcps/[name]/page-f5283ca4a2a1141b.js +1 -0
  153. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/mcps/catalog/page-9b228ecfe1982eba.js +1 -0
  154. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/mcps/page-d8028301dcd11348.js +1 -0
  155. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/memory/page-34fe9bf93ef853d0.js +1 -0
  156. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/memory/settings/page-5c9c471c9425d814.js +1 -0
  157. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/memory/timeline/page-590f707b60b9ba47.js +1 -0
  158. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/notifications/page-46a9b033af7430e6.js +1 -0
  159. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/parallel/{page-85690140ff82dd58.js → page-49a26690ced20482.js} +1 -1
  160. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/repos/page-155cd1007250e5da.js +1 -0
  161. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/review/config/page-5ffb558d24a57b2c.js +1 -0
  162. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/review/queue/page-9fe0df848d23c383.js +1 -0
  163. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/rules/page-e17685f3220da942.js +1 -0
  164. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/rules/pipelines/page-589f30a41f066568.js +1 -0
  165. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/sessions/page-4ff5d7490cc0d260.js +1 -0
  166. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/settings/page-045a30e0bd843279.js +1 -0
  167. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/skills/page-2bd816bd8e62dc04.js +1 -0
  168. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/templates/page-28a51e2788c5798d.js +1 -0
  169. package/dist/portal/package.json +1 -1
  170. package/dist/{start-DWZHVBUO.js → start-6SLTMLI4.js} +1 -1
  171. package/dist/{update-IBPDEBEK.js → update-563P3ZIS.js} +1 -1
  172. package/dist/{version-checker-XKFQNN3I.js → version-checker-JHHM4OTR.js} +1 -1
  173. package/package.json +6 -6
  174. package/dist/portal/apps/portal/.next/static/chunks/380-52bab5fc966d7cf9.js +0 -1
  175. package/dist/portal/apps/portal/.next/static/chunks/7525-d6350803a451284c.js +0 -1
  176. package/dist/portal/apps/portal/.next/static/chunks/7889-a3331988a8344d05.js +0 -1
  177. package/dist/portal/apps/portal/.next/static/chunks/8744-d545a53c9709467b.js +0 -1
  178. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/codemap/page-bf1ece66c1b05822.js +0 -1
  179. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/dashboard/page-936391d6b330f0cc.js +0 -1
  180. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/layout-05fc9732a636a609.js +0 -1
  181. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/loop/page-faeaacd95742c754.js +0 -1
  182. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/mcps/[name]/page-f24841b78e8c05c0.js +0 -1
  183. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/mcps/catalog/page-2ff0e6b6a5d76dac.js +0 -1
  184. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/mcps/page-2476b9c29c44c372.js +0 -1
  185. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/memory/page-79f977cd348c57ae.js +0 -1
  186. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/memory/settings/page-a3be96ef297c8e33.js +0 -1
  187. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/memory/timeline/page-30db4506366d09f4.js +0 -1
  188. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/notifications/page-df5f393a51d8e17b.js +0 -1
  189. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/repos/page-a0bcc68a119f63e1.js +0 -1
  190. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/review/config/page-770321f5a71a29a3.js +0 -1
  191. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/review/queue/page-33687733a5398264.js +0 -1
  192. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/rules/page-ac19551ab9f2128d.js +0 -1
  193. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/rules/pipelines/page-96ecfcce3a60ebb2.js +0 -1
  194. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/sessions/page-6b199747e9f587de.js +0 -1
  195. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/settings/page-ec4076cedf8df275.js +0 -1
  196. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/skills/page-81f63d5d894b0b03.js +0 -1
  197. package/dist/portal/apps/portal/.next/static/chunks/app/(dashboard)/templates/page-263e03b6690d36f5.js +0 -1
  198. /package/dist/portal/apps/portal/.next/static/{02AzZdYDA5HVAwITp37Ql → p-7mo3JdIgTzhlpqhShmK}/_buildManifest.js +0 -0
  199. /package/dist/portal/apps/portal/.next/static/{02AzZdYDA5HVAwITp37Ql → p-7mo3JdIgTzhlpqhShmK}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1600],{573:(e,t,l)=>{Promise.resolve().then(l.bind(l,4196))},4196:(e,t,l)=>{"use strict";l.r(t),l.d(t,{default:()=>A});var r=l(8111),a=l(5271),s=l(4736),n=l(3951),i=l(4632),o=l(3025),d=l(3446);let c={taskSource:"prd",prdFileName:"",prdContent:"",agentName:"claude",model:"",sandbox:"",agent:"",trackerName:"json",trackerConfig:{},trackerFileName:"",trackerFileContent:"",sourceBranch:"",maxWorkers:3,maxIterations:10,aiConflictResolution:!0,verificationAgentName:"",verificationAgent:""},u=new Set(["idle","stopped","error","completed","failed","cancelled"]);var x=l(5079),m=l(3310);function p(e){let{checked:t,onChange:l}=e;return(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":t,onClick:()=>l(!t),className:"relative inline-flex h-5 w-9 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors ".concat(t?"bg-primary-500":"bg-surface-700"),children:(0,r.jsx)("span",{className:"pointer-events-none inline-block h-4 w-4 rounded-full bg-white shadow-sm transition-transform ".concat(t?"translate-x-4":"translate-x-0")})})}function h(e){let{onStart:t,initialPrdFilename:l,initialAgent:s,initialModel:n}=e,i=(0,d.yC)(),[o,u]=(0,a.useState)(()=>({...c,...s?{agentName:s}:{},...n?{model:n}:{}})),[h,g]=(0,a.useState)(null),[f,b]=(0,a.useState)([]),[j,v]=(0,a.useState)(""),k=(0,a.useRef)(null),y=(0,a.useRef)(null),N=(0,a.useRef)(!1),{getForAgent:w,getFlagForAgent:C}=function(){let e=(0,d.yC)(),[t,l]=(0,a.useState)(new Map),[r,s]=(0,a.useState)(!0),n=(0,a.useCallback)(async()=>{try{var t;let r=await e.get("/api/agents/specializations?includeEmpty=true"),a=new Map;for(let e of null!=(t=r.agents)?t:[])a.set(e.agentName,e);l(a)}catch(e){}finally{s(!1)}},[e]);(0,a.useEffect)(()=>{n()},[n]);let i=(0,a.useCallback)(e=>{var l,r;return null!=(r=null==(l=t.get(e))?void 0:l.specializations)?r:[]},[t]),o=(0,a.useCallback)(e=>{var l;return null==(l=t.get(e))?void 0:l.flag},[t]);return{specs:t,loading:r,refresh:n,getForAgent:i,getFlagForAgent:o}}(),S=x.x.find(e=>e.value===o.trackerName),A="json"===o.trackerName||"markdown"===o.trackerName;(0,a.useEffect)(()=>{(async()=>{try{var e,t;let l=await i.get("/api/loop/branches");b(null!=(e=l.branches)?e:[]),v(null!=(t=l.current)?t:"")}catch(e){}})()},[i]),(0,a.useEffect)(()=>{l&&!N.current&&(N.current=!0,(async()=>{try{let e=await i.get("/api/prd/load?filename=".concat(encodeURIComponent(l)));e.markdown&&u(t=>({...t,taskSource:"prd",prdFileName:l,prdContent:e.markdown}))}catch(e){}})())},[i,l]);let M=(e,t)=>{u(l=>({...l,[e]:t})),g(null)},L=e=>t=>{var l;let r=null==(l=t.target.files)?void 0:l[0];if(!r)return;let a=new FileReader;a.onload=()=>{let t=a.result;"prd"===e?u(e=>({...e,prdFileName:r.name,prdContent:t})):u(e=>({...e,trackerFileName:r.name,trackerFileContent:t})),g(null)},a.readAsText(r)},F=()=>{if("prd"===o.taskSource&&!o.prdContent)return!1;if("tracker"===o.taskSource){if(A&&!o.trackerFileContent)return!1;if(!S)return!0;for(let t of S.fields){var e;if(t.required&&!(null==(e=o.trackerConfig[t.key])?void 0:e.trim()))return!1}}return!(o.maxWorkers<1)};return(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"mb-4 text-base font-semibold text-white",children:"New Parallel Run"}),(0,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsx)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:"Task Source"}),(0,r.jsx)("div",{className:"flex gap-1 rounded-lg border border-white/[0.08] bg-surface-800 p-1",children:[{value:"prd",label:"PRD File"},{value:"tracker",label:"Task Tracker"}].map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>M("taskSource",e.value),className:"flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors ".concat(o.taskSource===e.value?"bg-primary-500 text-white":"text-gray-400 hover:text-gray-300"),children:e.label},e.value))})]}),"prd"===o.taskSource&&(0,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsxs)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:["PRD File ",(0,r.jsx)("span",{className:"ml-0.5 text-red-400",children:"*"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{var e;return null==(e=k.current)?void 0:e.click()},className:"inline-flex items-center gap-2 rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-gray-300 transition-colors hover:bg-surface-700 hover:text-white",children:[(0,r.jsx)("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z"})}),"Browse"]}),o.prdFileName&&(0,r.jsx)("span",{className:"truncate text-sm text-gray-400",children:o.prdFileName}),(0,r.jsx)("input",{ref:k,type:"file",accept:".md,.txt,.markdown",onChange:L("prd"),className:"hidden"})]}),(0,r.jsx)("p",{className:"mt-1 text-[11px] text-gray-600",children:"Markdown file with structured tasks. Tasks will be analyzed for dependencies and grouped for parallel execution."})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-4 ".concat("tracker"===o.taskSource?"sm:grid-cols-4":"sm:grid-cols-3"),children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:"Agent"}),(0,r.jsx)("select",{value:o.agentName,onChange:e=>{let t=e.target.value;u(e=>({...e,agentName:t,model:(0,m.fZ)(t),agent:""})),g(null)},className:"w-full rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-white focus:border-primary-500/50 focus:outline-none",children:m.jw.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:"Model"}),(()=>{let e=(0,m.F_)(o.agentName);return(0,r.jsx)("select",{value:o.model,onChange:e=>M("model",e.target.value),disabled:0===e.length,className:"w-full rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-white focus:border-primary-500/50 focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed",children:0===e.length?(0,r.jsx)("option",{value:"",children:"(default)"}):e.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))})})()]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:"Sandbox"}),(0,r.jsxs)("select",{value:o.sandbox,onChange:e=>M("sandbox",e.target.value),className:"w-full rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-white focus:border-primary-500/50 focus:outline-none",children:[(0,r.jsx)("option",{value:"",children:"Default"}),(0,r.jsx)("option",{value:"workspace-write",children:"Workspace Write"}),(0,r.jsx)("option",{value:"danger-full-access",children:"Full Access"}),(0,r.jsx)("option",{value:"read-only",children:"Read Only"})]}),(0,r.jsx)("p",{className:"mt-1 text-[11px] text-gray-600",children:"Full Access enables network"})]}),"tracker"===o.taskSource&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:"Task Tracker"}),(0,r.jsx)("select",{value:o.trackerName,onChange:e=>{var t;return t=e.target.value,void(u(e=>({...e,trackerName:t,trackerConfig:{},trackerFileName:"",trackerFileContent:""})),g(null))},className:"w-full rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-white focus:border-primary-500/50 focus:outline-none",children:x.x.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))})]})]}),(()=>{let e=w(o.agentName),t=C(o.agentName),l=o.verificationAgentName||o.agentName,a=w(l),s=C(l);return(0,r.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-4 sm:grid-cols-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:"Agent Specialization"}),e.length>0?(0,r.jsxs)("select",{value:o.agent,onChange:e=>M("agent",e.target.value),className:"w-full rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-white focus:border-primary-500/50 focus:outline-none",children:[(0,r.jsx)("option",{value:"",children:"None (default)"}),e.map(e=>(0,r.jsxs)("option",{value:e.name,children:[e.name,e.description?" — ".concat(e.description.slice(0,60)):""]},e.name))]}):(0,r.jsx)("select",{disabled:!0,className:"w-full rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-gray-500 focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed",children:(0,r.jsx)("option",{children:"No specializations available"})}),t&&(0,r.jsxs)("p",{className:"mt-1 text-[11px] text-gray-600",children:["Uses ",t," flag"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:"Verification Agent"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)("select",{value:o.verificationAgentName,onChange:e=>{M("verificationAgentName",e.target.value),M("verificationAgent","")},className:"w-1/2 rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-white focus:border-primary-500/50 focus:outline-none",children:[(0,r.jsx)("option",{value:"",children:"Same as main"}),m.jw.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))]}),a.length>0?(0,r.jsxs)("select",{value:o.verificationAgent,onChange:e=>M("verificationAgent",e.target.value),className:"w-1/2 rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-white focus:border-primary-500/50 focus:outline-none",children:[(0,r.jsx)("option",{value:"",children:"None (default)"}),a.map(e=>(0,r.jsx)("option",{value:e.name,children:e.name},e.name))]}):(0,r.jsx)("select",{disabled:!0,className:"w-1/2 rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-gray-500 focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed",children:(0,r.jsx)("option",{children:"No specializations"})})]}),(0,r.jsxs)("p",{className:"mt-1 text-[11px] text-gray-600",children:["Runs validation after all workers merge",s?" (".concat(s,")"):""]})]})]})})(),"tracker"===o.taskSource&&(0,r.jsxs)("div",{className:"mt-4 space-y-3",children:[A&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:["Task File ",(0,r.jsx)("span",{className:"ml-0.5 text-red-400",children:"*"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{var e;return null==(e=y.current)?void 0:e.click()},className:"inline-flex items-center gap-2 rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-gray-300 transition-colors hover:bg-surface-700 hover:text-white",children:[(0,r.jsx)("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z"})}),"Browse"]}),o.trackerFileName&&(0,r.jsx)("span",{className:"truncate text-sm text-gray-400",children:o.trackerFileName}),(0,r.jsx)("input",{ref:y,type:"file",accept:"json"===o.trackerName?".json":".md,.txt,.markdown",onChange:L("tracker"),className:"hidden"})]})]}),!A&&S&&S.fields.length>0&&(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:S.fields.map(e=>{var t;return(0,r.jsxs)("div",{children:[(0,r.jsxs)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:[e.label,e.required&&(0,r.jsx)("span",{className:"ml-0.5 text-red-400",children:"*"})]}),(0,r.jsx)("input",{type:e.secret?"password":"text",value:null!=(t=o.trackerConfig[e.key])?t:"",onChange:t=>{var l,r;return l=e.key,r=t.target.value,void(u(e=>({...e,trackerConfig:{...e.trackerConfig,[l]:r}})),g(null))},placeholder:e.placeholder,className:"w-full rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-white placeholder:text-gray-600 focus:border-primary-500/50 focus:outline-none"})]},e.key)})})]}),(0,r.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:"Source Branch"}),(0,r.jsxs)("select",{value:o.sourceBranch,onChange:e=>M("sourceBranch",e.target.value),className:"w-full rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-white focus:border-primary-500/50 focus:outline-none",children:[(0,r.jsxs)("option",{value:"",children:["Current (",j||"...",")"]}),f.map(e=>(0,r.jsx)("option",{value:e,children:e},e))]})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:["Max Workers ",(0,r.jsx)("span",{className:"ml-0.5 text-red-400",children:"*"})]}),(0,r.jsx)("input",{type:"number",min:"1",value:o.maxWorkers,onChange:e=>M("maxWorkers",Math.max(1,parseInt(e.target.value)||1)),className:"w-full rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-white placeholder:text-gray-600 focus:border-primary-500/50 focus:outline-none"}),(0,r.jsx)("p",{className:"mt-1 text-[11px] text-gray-600",children:"Concurrent workers"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:"Max Iterations"}),(0,r.jsx)("input",{type:"number",min:"1",max:"50",value:o.maxIterations,onChange:e=>M("maxIterations",Math.max(1,Math.min(50,parseInt(e.target.value)||10))),className:"w-full rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-white placeholder:text-gray-600 focus:border-primary-500/50 focus:outline-none"}),(0,r.jsx)("p",{className:"mt-1 text-[11px] text-gray-600",children:"Per worker limit"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:"AI Conflict Resolution"}),(0,r.jsxs)("div",{className:"flex h-[38px] items-center",children:[(0,r.jsx)(p,{checked:o.aiConflictResolution,onChange:e=>M("aiConflictResolution",e)}),(0,r.jsx)("span",{className:"ml-2 text-xs text-gray-500",children:o.aiConflictResolution?"Enabled":"Disabled"})]})]})]}),(0,r.jsx)("div",{className:"mt-4 rounded-lg border border-white/[0.04] bg-surface-800/30 px-3 py-2",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("svg",{className:"h-3.5 w-3.5 shrink-0 text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z"})}),(0,r.jsx)("span",{className:"text-[11px] text-gray-500",children:"Auto-commit is always enabled for parallel runs (required for worktree merge)."})]})}),h&&(0,r.jsx)("p",{className:"mt-3 text-xs text-red-400",children:h}),(0,r.jsx)("div",{className:"mt-5",children:(0,r.jsxs)("button",{onClick:()=>{if(!F()){if("prd"!==o.taskSource||o.prdContent)if("tracker"===o.taskSource&&A&&!o.trackerFileContent)g("Select a task file");else if(o.maxWorkers<1)g("Max workers must be at least 1");else{let e=null==S?void 0:S.fields.filter(e=>{var t;return e.required&&!(null==(t=o.trackerConfig[e.key])?void 0:t.trim())}).map(e=>e.label);g("Required fields: ".concat(null==e?void 0:e.join(", ")))}else g("Select a PRD file");return}t(o)},disabled:!F(),className:"inline-flex items-center gap-2 rounded-lg bg-primary-500 px-4 py-2 text-xs font-semibold text-white transition-colors hover:bg-primary-600 disabled:cursor-not-allowed disabled:opacity-50",children:[(0,r.jsx)("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5.25 5.653c0-.856.917-1.398 1.667-.986l11.54 6.347a1.125 1.125 0 0 1 0 1.972l-11.54 6.347a1.125 1.125 0 0 1-1.667-.986V5.653Z"})}),"Start Parallel Run"]})})]})}var g=l(5605),f=l(8322);function b(e){let{jobs:t,selectedId:l,onSelect:a,onNewRun:s}=e,n=function(e){let t=new Set(["running","queued"]);return[...e].sort((e,l)=>{let r=+!t.has(e.status),a=+!t.has(l.status);return r!==a?r-a:new Date(l.createdAt).getTime()-new Date(e.createdAt).getTime()})}(t);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-3 shrink-0 border-b border-white/[0.04]",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h2",{className:"text-sm font-semibold text-white",children:"Parallel Jobs"}),t.length>0&&(0,r.jsx)("span",{className:"inline-flex items-center justify-center rounded-full bg-surface-800 px-1.5 py-0.5 text-[10px] font-medium text-gray-400",children:t.length})]}),(0,r.jsxs)("button",{type:"button",onClick:s,className:"inline-flex items-center gap-1.5 rounded-lg bg-primary-500 px-3 py-1.5 text-[11px] font-semibold text-white transition-colors hover:bg-primary-600",children:[(0,r.jsx)("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})}),"New Run"]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===n.length?(0,r.jsx)("div",{className:"p-4",children:(0,r.jsx)(i.p,{title:"No parallel jobs",description:"Start a new parallel run to create a job.",icon:(0,r.jsx)("svg",{className:"h-8 w-8 text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7.5 21 3 16.5m0 0L7.5 12M3 16.5h13.5m0-13.5L21 7.5m0 0L16.5 12M21 7.5H7.5"})})})}):n.map(e=>{let t=l===e.id,s=e.parallel;return(0,r.jsxs)("button",{type:"button",onClick:()=>a(e.id),className:"w-full px-3 py-2.5 text-left transition-colors border-b border-white/[0.02] ".concat(t?"bg-primary-500/10 border-l-2 border-l-primary-500":"hover:bg-white/[0.03]"),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(g.W,{status:e.status,size:"sm"}),(0,r.jsx)(f.L,{name:e.agentName})]}),(0,r.jsxs)("div",{className:"mt-1.5 flex items-center gap-2",children:[(0,r.jsx)("span",{className:"font-mono text-[11px] text-gray-500 truncate",children:e.sourceBranch}),s&&(0,r.jsxs)("span",{className:"text-[11px] text-gray-500 shrink-0",children:["G",s.completedGroups,"/",s.totalGroups," \xb7 ",s.mergedCount,"/",e.taskCount," merged"]}),!s&&e.taskCount>0&&(0,r.jsxs)("span",{className:"text-[11px] text-gray-500 shrink-0",children:[e.taskCount," task",1!==e.taskCount?"s":""]})]}),(0,r.jsx)("div",{className:"mt-1 text-[10px] text-gray-600",children:function(e){let t=Date.now()-new Date(e).getTime();return t<6e4?"just now":t<36e5?"".concat(Math.floor(t/6e4),"m ago"):t<864e5?"".concat(Math.floor(t/36e5),"h ago"):"".concat(Math.floor(t/864e5),"d ago")}(e.createdAt)})]},e.id)})})]})}var j=l(6142),v=l(5323);function k(e){var t,l;let{worker:a}=e,s={pending:"border-white/[0.04] bg-surface-800/50",running:"border-blue-500/20 bg-blue-950/30",completed:"border-emerald-500/20 bg-emerald-950/30",failed:"border-red-500/20 bg-red-950/30"},n=null!=(t=({pending:{dot:"bg-gray-400",label:"Pending"},running:{dot:"bg-blue-400",label:"Running",animate:!0},completed:{dot:"bg-emerald-400",label:"Completed"},failed:{dot:"bg-red-400",label:"Failed"}})[a.status])?t:{dot:"bg-gray-400",label:a.status},i=null!=(l=s[a.status])?l:s.pending,o=a.elapsedMs>0?(0,j.a)(a.elapsedMs):"",d=o?"".concat(n.label," \xb7 ").concat(o):n.label,c=a.error?a.error.length>60?a.error.slice(0,57)+"...":a.error:null;return(0,r.jsxs)("div",{className:"rounded-lg border ".concat(i," p-3 transition-colors duration-300"),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("span",{className:"text-[11px] font-medium text-gray-400",children:["Worker ",a.id]}),a.commitCount>0&&(0,r.jsxs)("span",{className:"ml-auto text-[10px] text-gray-600",children:[a.commitCount," commit",1!==a.commitCount?"s":""]})]}),(0,r.jsx)("p",{className:"mt-1 truncate text-xs text-gray-300",children:a.taskTitle||a.taskId}),(0,r.jsxs)("div",{className:"mt-1.5 flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full ".concat(n.dot," ").concat(n.animate?"animate-pulse":"")}),(0,r.jsx)("span",{className:"text-[11px] text-gray-500",children:d})]}),(0,r.jsx)("p",{className:"mt-1 truncate font-mono text-[10px] text-gray-600",children:a.branchName}),"failed"===a.status&&c&&(0,r.jsx)("p",{className:"mt-1.5 truncate text-[11px] text-red-400",title:a.error,children:c})]})}function y(e){var t;let{status:l,dag:s}=e,[i,o]=(0,a.useState)(new Set);if(!l)return(0,r.jsx)(n.G,{rows:2});let{totalGroups:d,currentGroupIndex:c,workers:u,allWorkers:x}=l,m=Array.from({length:d},(e,t)=>({index:t,status:t<c?"completed":t===c?"active":"pending"})),p=(null!=(t=null!=x?x:u)?t:[]).filter(e=>{let t=parseInt(e.id.split("-")[0],10);return!isNaN(t)&&t===c});return(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)("div",{className:"mb-3 flex items-center gap-4 text-xs text-gray-400",children:[(0,r.jsxs)("span",{children:[l.totalTasksCompleted,"/",l.totalTasks," tasks completed"]}),(0,r.jsxs)("span",{children:["Merge queue: ","number"==typeof l.mergeQueue?l.mergeQueue:0]}),l.elapsedMs>0&&(0,r.jsx)("span",{className:"font-mono text-gray-600",children:(0,j.a)(l.elapsedMs)})]}),m.map((e,t)=>{let l="active"===e.status,a="completed"===e.status,n="pending"===e.status,d=i.has(e.index)||l,c=l?"border-blue-500/30":a?"border-emerald-500/20":"border-white/[0.04]",u=l?"bg-blue-500/[0.06]":a?"bg-emerald-500/[0.04]":"bg-surface-800/30";return(0,r.jsxs)("div",{children:[t>0&&(0,r.jsx)("div",{className:"flex justify-center py-1",children:(0,r.jsx)("svg",{className:"h-4 w-4 text-gray-700",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 13.5 12 21m0 0-7.5-7.5M12 21V3"})})}),(0,r.jsxs)("div",{className:"rounded-lg border ".concat(c," overflow-hidden"),children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{var t;return!l&&(t=e.index,void o(e=>{let l=new Set(e);return l.has(t)?l.delete(t):l.add(t),l}))},className:"flex w-full items-center gap-3 px-4 py-2.5 text-left ".concat(u," ").concat(l?"":"cursor-pointer hover:bg-white/[0.02]"),children:[a&&(0,r.jsx)("svg",{className:"h-4 w-4 shrink-0 text-emerald-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m4.5 12.75 6 6 9-13.5"})}),l&&(0,r.jsx)("span",{className:"h-2 w-2 shrink-0 animate-pulse rounded-full bg-blue-400"}),n&&(0,r.jsx)("span",{className:"h-2 w-2 shrink-0 rounded-full bg-gray-600"}),(0,r.jsxs)("span",{className:"text-xs font-semibold ".concat(l?"text-blue-400":a?"text-emerald-400":"text-gray-500"),children:["Group ",e.index+1,(0,r.jsx)("span",{className:"ml-1.5 font-normal text-[10px] opacity-60",children:0===e.index?"Independent":"Depends on previous"})]}),(0,r.jsx)("span",{className:"text-[11px] ".concat(l?"text-blue-400/70":a?"text-emerald-400/60":"text-gray-600"),children:l?"Running":a?"Completed":(()=>{var t,l,r;let a=null==s||null==(r=s.groups)||null==(l=r[e.index])||null==(t=l.tasks)?void 0:t.length;return a?"Pending \xb7 ".concat(a," tasks"):"Pending"})()}),!l&&(0,r.jsx)("svg",{className:"ml-auto h-3.5 w-3.5 text-gray-600 transition-transform ".concat(d?"rotate-180":""),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m19.5 8.25-7.5 7.5-7.5-7.5"})})]}),d&&l&&p.length>0&&(0,r.jsx)("div",{className:"border-t border-white/[0.04] p-3",children:(0,r.jsx)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3",children:p.map(e=>(0,r.jsx)(k,{worker:e},e.taskId))})}),d&&a&&(()=>{let t,l=(t=e.index,(null!=x?x:[]).filter(e=>{let l=parseInt(e.id.split("-")[0],10);return!isNaN(l)&&l===t}));return l.length>0?(0,r.jsx)("div",{className:"border-t border-white/[0.04] p-3",children:(0,r.jsx)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3",children:l.map(e=>(0,r.jsx)(k,{worker:e},e.taskId))})}):(0,r.jsx)("div",{className:"border-t border-white/[0.04] px-4 py-2",children:(0,r.jsx)("p",{className:"text-[11px] text-gray-500",children:"All tasks in this group completed successfully."})})})(),n&&d&&(()=>{var t,l;let a=null==s||null==(t=s.groups)?void 0:t[e.index],n=null!=(l=null==a?void 0:a.tasks)?l:[];return(0,r.jsxs)("div",{className:"border-t border-white/[0.04] px-4 py-3",children:[(0,r.jsx)("p",{className:"mb-2 text-[11px] text-gray-600",children:"Waiting for previous groups to complete."}),n.length>0&&(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:n.map(e=>(0,r.jsx)("span",{className:"inline-flex items-center rounded-full border border-white/[0.08] bg-surface-800 px-2 py-0.5 text-[10px] font-medium text-gray-500",title:e.id,children:e.title||e.id},e.id))})]})})()]})]},e.index)}),d>0&&(()=>{let e=(null!=x?x:[]).find(e=>"VALIDATION"===e.taskId),t=(null==e?void 0:e.status)==="running",a=(null==e?void 0:e.status)==="completed",s=(null==e?void 0:e.status)==="failed",n=c>=d&&!a&&!s&&"completed"!==l.status&&"failed"!==l.status,i=a?"border-emerald-500/20":t||n?"border-purple-500/30":s?"border-red-500/20":"border-white/[0.04]",o=a?"bg-emerald-500/[0.04]":t||n?"bg-purple-500/[0.06]":s?"bg-red-500/[0.04]":"bg-surface-800/30",u=a?"Completed":s?"Failed":t||n?"Running":"Pending",m=a?"text-emerald-400":s?"text-red-400":t||n?"text-purple-400":"text-gray-500";return(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"flex justify-center py-1",children:(0,r.jsx)("svg",{className:"h-4 w-4 text-gray-700",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 13.5 12 21m0 0-7.5-7.5M12 21V3"})})}),(0,r.jsx)("div",{className:"rounded-lg border ".concat(i," overflow-hidden"),children:(0,r.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2.5 ".concat(o),children:[a&&(0,r.jsx)("svg",{className:"h-4 w-4 shrink-0 text-emerald-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m4.5 12.75 6 6 9-13.5"})}),s&&(0,r.jsx)("svg",{className:"h-4 w-4 shrink-0 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18 18 6M6 6l12 12"})}),(t||n)&&(0,r.jsx)("span",{className:"h-2 w-2 shrink-0 animate-pulse rounded-full bg-purple-400"}),!a&&!s&&!t&&!n&&(0,r.jsx)("span",{className:"h-2 w-2 shrink-0 rounded-full bg-gray-600"}),(0,r.jsxs)("span",{className:"text-xs font-semibold ".concat(m),children:["Validation",(0,r.jsx)("span",{className:"ml-1.5 font-normal text-[10px] opacity-60",children:"Verifies all tasks against PRD"})]}),(0,r.jsx)("span",{className:"text-[11px] ".concat(m," opacity-70"),children:u}),(null==e?void 0:e.elapsedMs)!=null&&e.elapsedMs>0&&(0,r.jsx)("span",{className:"ml-auto text-[10px] font-mono text-gray-600",children:(0,j.a)(e.elapsedMs)})]})})]})})(),0===d&&(0,r.jsx)("div",{className:"rounded-lg border border-white/[0.04] bg-surface-800/30 px-4 py-8 text-center text-sm text-gray-500",children:"No pipeline groups available."})]})}function N(e){let{node:t,x:l,y:a}=e;return(0,r.jsxs)("div",{className:"pointer-events-none absolute z-50 max-w-xs rounded-lg border border-white/10 bg-surface-900 px-3 py-2 shadow-xl",style:{left:l,top:a-8,transform:"translate(-50%, -100%)"},children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-white",children:t.id}),(0,r.jsx)("div",{className:"mt-0.5 text-[11px] text-gray-400 line-clamp-2",children:t.title}),t.dependencies.length>0&&(0,r.jsxs)("div",{className:"mt-1 text-[10px] text-gray-500",children:["Depends on: ",t.dependencies.join(", ")]}),t.dependents.length>0&&(0,r.jsxs)("div",{className:"mt-0.5 text-[10px] text-gray-500",children:["Blocks: ",t.dependents.join(", ")]})]})}function w(e){var t,l,s;let{dag:o,loading:d,status:c}=e,u=(0,a.useRef)(null),[x,m]=(0,a.useState)(null),[p,h]=(0,a.useState)({x:0,y:0}),g=(0,a.useMemo)(()=>{let e=new Map;if(null==c?void 0:c.allWorkers)for(let t of c.allWorkers)e.set(t.taskId,t.status);return e},[c]),f=(0,a.useMemo)(()=>o?function(e,t){var l,r,a,s;let n=null!=(l=e.nodes)?l:{},i=(null!=(r=e.groups)?r:[]).map(e=>{var t;let l=e.tasks?e.tasks:(null!=(t=e.taskIds)?t:[]).map(e=>{var t,l;return{id:e,title:null!=(l=null==(t=n[e])?void 0:t.title)?l:e}});return{depth:e.depth,tasks:l}}),o=[],d=[],c=1;for(let e of i)e.tasks.length>c&&(c=e.tasks.length);let u=200*c+(c-1)*24;for(let e=0;e<i.length;e++){let l=i[e],r=l.tasks,d=40+(u-(200*r.length+(r.length-1)*24))/2,c=72+120*e;for(let e=0;e<r.length;e++){let i=r[e],u=n[i.id],x=d+224*e;o.push({id:i.id,title:(null==u?void 0:u.title)||i.title||i.id,depth:l.depth,x,y:c,cx:x+100,cy:c+26,dependencies:null!=(a=null==u?void 0:u.dependencies)?a:[],dependents:null!=(s=null==u?void 0:u.dependents)?s:[],status:t.get(i.id)})}}let x=new Map(o.map(e=>[e.id,e]));for(let e of o)for(let t of e.dependencies)x.has(t)&&d.push({from:t,to:e.id});let m=o.filter(e=>0===e.dependents.length).map(e=>e.id);if(i.length>0&&m.length>0){let e=72+120*i.length,l=40+(u-200)/2;for(let r of(o.push({id:"VALIDATION",title:"Post-Parallel Validation",depth:i.length,x:l,y:e,cx:l+100,cy:e+26,dependencies:m,dependents:[],status:t.get("VALIDATION")}),x.set("VALIDATION",o[o.length-1]),m))d.push({from:r,to:"VALIDATION"})}let p=o.length>0?Math.max(...o.map(e=>e.y)):48;return{nodes:o,edges:d,width:80+u,height:p+52+48}}(o,g):null,[o,g]);if(d)return(0,r.jsx)(n.G,{rows:2});if(!o)return(0,r.jsx)(i.p,{title:"No DAG analysis",description:"Start a parallel job to see the dependency graph.",icon:(0,r.jsx)("svg",{className:"h-8 w-8 text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7.5 21 3 16.5m0 0L7.5 12M3 16.5h13.5m0-13.5L21 7.5m0 0L16.5 12M21 7.5H7.5"})})});if(!f||0===f.nodes.length)return(0,r.jsx)(i.p,{title:"Empty graph",description:"No tasks found in the DAG.",icon:(0,r.jsx)("svg",{className:"h-8 w-8 text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7.5 21 3 16.5m0 0L7.5 12M3 16.5h13.5m0-13.5L21 7.5m0 0L16.5 12M21 7.5H7.5"})})});let b=x?f.nodes.find(e=>e.id===x):null,j=new Set,v=new Set;if(x){v.add(x);let e=f.nodes.find(e=>e.id===x);if(e){for(let t of e.dependencies)v.add(t),j.add("".concat(t,"->").concat(x));for(let t of e.dependents)v.add(t),j.add("".concat(x,"->").concat(t))}}let k=null!=(t=o.groups)?t:[],y=[...k.map((e,t)=>({label:"G".concat(t+1),depth:e.depth,y:72+120*t})),...k.length>0?[{label:"V",depth:k.length,y:72+120*k.length}]:[]],w=f.edges.length>0;return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex flex-wrap gap-4 text-xs text-gray-400",children:[(0,r.jsxs)("span",{children:["Groups: ",(0,r.jsx)("span",{className:"font-semibold text-white",children:k.length})]}),(0,r.jsxs)("span",{children:["Tasks: ",(0,r.jsx)("span",{className:"font-semibold text-white",children:(null!=(l=o.order)?l:[]).length})]}),(0,r.jsxs)("span",{children:["Max Parallelism: ",(0,r.jsx)("span",{className:"font-semibold text-white",children:null!=(s=o.maxParallelism)?s:0})]}),!w&&f.nodes.length>0&&(0,r.jsx)("span",{className:"text-yellow-500/80",children:"(Dependency arrows require API rebuild)"})]}),(0,r.jsxs)("div",{ref:u,className:"relative overflow-x-auto overflow-y-auto rounded-lg border border-white/[0.06] bg-[#0d0d14]",children:[(0,r.jsxs)("svg",{width:f.width,height:f.height,className:"block",children:[(0,r.jsxs)("defs",{children:[(0,r.jsx)("marker",{id:"arrow",markerWidth:"10",markerHeight:"7",refX:"9",refY:"3.5",orient:"auto",children:(0,r.jsx)("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#a78bfa",fillOpacity:"0.7"})}),(0,r.jsx)("marker",{id:"arrow-dim",markerWidth:"10",markerHeight:"7",refX:"9",refY:"3.5",orient:"auto",children:(0,r.jsx)("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#6b7280",fillOpacity:"0.3"})}),(0,r.jsx)("marker",{id:"arrow-hl",markerWidth:"10",markerHeight:"7",refX:"9",refY:"3.5",orient:"auto",children:(0,r.jsx)("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#c4b5fd"})})]}),y.map((e,t)=>(0,r.jsx)("text",{x:14,y:e.y+26+4,fill:"V"===e.label?"#a78bfa":"#9ca3af",fontSize:11,fontWeight:600,children:e.label},"glabel-".concat(t))),y.map((e,t)=>t>0?(0,r.jsx)("line",{x1:0,y1:e.y-34,x2:f.width,y2:e.y-34,stroke:"#ffffff",strokeOpacity:.06,strokeWidth:1,strokeDasharray:"6 4"},"sep-".concat(t)):null),f.edges.map(e=>{let t=f.nodes.find(t=>t.id===e.from),l=f.nodes.find(t=>t.id===e.to);if(!t||!l)return null;let a=t.cx,s=t.y+52,n=l.cx,i=l.y,o="".concat(e.from,"->").concat(e.to),d=j.has(o),c=x&&!d;return(0,r.jsx)("path",{d:function(e,t,l,r){let a=(t+r)/2;return"M ".concat(e," ").concat(t," C ").concat(e," ").concat(a,", ").concat(l," ").concat(a,", ").concat(l," ").concat(r)}(a,s,n,i),fill:"none",stroke:d?"#c4b5fd":c?"#374151":"#a78bfa",strokeOpacity:d?1:c?.3:.6,strokeWidth:d?2.5:1.5,markerEnd:d?"url(#arrow-hl)":c?"url(#arrow-dim)":"url(#arrow)",style:{transition:"stroke 0.15s, stroke-opacity 0.15s, stroke-width 0.15s"}},o)}),f.nodes.map(e=>{let t=function(e){switch(e){case"completed":return{bg:"#065f46",border:"#10b981",idFill:"#6ee7b7",titleFill:"#a7f3d0",dotFill:"#34d399"};case"failed":return{bg:"#7f1d1d",border:"#ef4444",idFill:"#fca5a5",titleFill:"#fecaca",dotFill:"#f87171"};case"running":return{bg:"#1e3a5f",border:"#3b82f6",idFill:"#93c5fd",titleFill:"#bfdbfe",dotFill:"#60a5fa"};default:return{bg:"#1e1e2e",border:"#4b5563",idFill:"#d1d5db",titleFill:"#9ca3af",dotFill:"#6b7280"}}}(e.status),l=x===e.id,a=!x||v.has(e.id),s=x&&!a;return(0,r.jsxs)("g",{style:{transition:"opacity 0.15s"},opacity:s?.2:1,onMouseEnter:()=>{m(e.id),h({x:e.cx,y:e.y})},onMouseLeave:()=>m(null),className:"cursor-pointer",children:[(0,r.jsx)("rect",{x:e.x,y:e.y,width:200,height:52,rx:10,ry:10,fill:t.bg,fillOpacity:.6,stroke:a&&x?"#ffffff":t.border,strokeOpacity:l?1:a&&x?.8:.4,strokeWidth:l?2.5:a&&x?2:1}),(0,r.jsx)("circle",{cx:e.x+14,cy:e.cy,r:4,fill:t.dotFill,children:"running"===e.status&&(0,r.jsx)("animate",{attributeName:"opacity",values:"1;0.3;1",dur:"1.5s",repeatCount:"indefinite"})}),(0,r.jsx)("text",{x:e.x+26,y:e.y+20,fill:t.idFill,fontSize:11,fontWeight:700,fontFamily:"ui-monospace, monospace",children:e.id}),(0,r.jsx)("text",{x:e.x+26,y:e.y+36,fill:t.titleFill,fillOpacity:.7,fontSize:10,children:e.title.length>22?e.title.slice(0,22)+"…":e.title}),e.dependencies.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("rect",{x:e.x+200-26,y:e.y+4,width:22,height:15,rx:7,fill:"#7c3aed",fillOpacity:.3}),(0,r.jsx)("text",{x:e.x+200-15,y:e.y+14,textAnchor:"middle",fill:"#c4b5fd",fontSize:9,fontWeight:700,children:e.dependencies.length})]})]},e.id)})]}),b&&(0,r.jsx)(N,{node:b,x:p.x,y:p.y})]}),o.warnings.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"mb-2 text-xs font-semibold text-yellow-400",children:"Warnings"}),(0,r.jsx)("div",{className:"space-y-1.5",children:o.warnings.map((e,t)=>(0,r.jsx)("div",{className:"rounded-lg border border-yellow-500/20 bg-yellow-500/[0.06] px-3 py-2 text-xs text-yellow-400",children:e},t))})]}),o.cyclicTaskIds.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"mb-2 text-xs font-semibold text-red-400",children:"Cyclic Tasks"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:o.cyclicTaskIds.map(e=>(0,r.jsx)("span",{className:"inline-flex items-center rounded-full border border-red-500/20 bg-red-500/[0.06] px-2.5 py-0.5 text-[11px] font-medium text-red-400",children:e},e))}),(0,r.jsx)("p",{className:"mt-1.5 text-[11px] text-gray-600",children:"These tasks have circular dependencies and could not be scheduled optimally."})]})]})}function C(e){let{label:t,value:l,mono:a}=e;return(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-[11px] font-medium text-gray-500 w-20 shrink-0",children:t}),(0,r.jsx)("span",{className:"text-xs text-gray-300 ".concat(a?"font-mono":""),children:l})]})}function S(e){let{job:t,status:l,dag:s,dagLoading:n,actionRunning:i,onStop:o,onDelete:d}=e,[c,u]=(0,a.useState)("pipeline"),x="running"===t.status||"queued"===t.status,m="";if(t.startedAt&&t.completedAt){let e=new Date(t.completedAt).getTime()-new Date(t.startedAt).getTime();m=(0,j.a)(e)}else if(t.startedAt){let e=Date.now()-new Date(t.startedAt).getTime();m=(0,j.a)(e)}let p=t.parallel;return(0,r.jsxs)("div",{className:"flex flex-col h-full overflow-hidden",children:[(0,r.jsxs)("div",{className:"shrink-0 pb-4 border-b border-white/[0.04]",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,r.jsx)(g.W,{status:t.status}),(0,r.jsx)(f.L,{name:t.agentName}),(0,r.jsx)("span",{className:"font-mono text-xs text-gray-500",children:t.sourceBranch}),m&&(0,r.jsx)("span",{className:"font-mono text-xs text-gray-600",children:m})]}),(0,r.jsxs)("div",{className:"mt-3 space-y-1",children:[(0,r.jsx)(C,{label:"Job ID",value:t.id,mono:!0}),(0,r.jsx)(C,{label:"Created",value:new Date(t.createdAt).toLocaleString()}),t.startedAt&&(0,r.jsx)(C,{label:"Started",value:new Date(t.startedAt).toLocaleString()}),t.completedAt&&(0,r.jsx)(C,{label:"Completed",value:new Date(t.completedAt).toLocaleString()}),p&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(C,{label:"Workers",value:"".concat(p.workerCount," / ").concat(p.maxWorkers," max")}),(0,r.jsx)(C,{label:"Groups",value:"".concat(p.completedGroups,"/").concat(p.totalGroups," completed")}),(0,r.jsx)(C,{label:"Merged",value:"".concat(p.mergedCount,"/").concat(t.taskCount," tasks")})]}),!p&&t.taskCount>0&&(0,r.jsx)(C,{label:"Tasks",value:"".concat(t.taskCount)}),(0,r.jsx)(C,{label:"Mode",value:"Parallel"})]}),t.error&&(0,r.jsx)("div",{className:"mt-3 rounded-lg border border-red-500/20 bg-red-500/[0.06] px-3 py-2 text-xs text-red-400",children:t.error}),(0,r.jsxs)("div",{className:"mt-3 flex items-center gap-2",children:[x&&(0,r.jsx)("button",{onClick:()=>o(t.id),disabled:"stop"===i,className:"rounded-lg border border-yellow-500/20 bg-yellow-500/[0.06] px-3 py-1.5 text-[11px] font-medium text-yellow-400 transition-colors hover:bg-yellow-500/10 disabled:cursor-not-allowed disabled:opacity-50",children:"stop"===i?"Stopping...":"Stop All"}),(0,r.jsx)("button",{onClick:()=>d(t.id),className:"rounded-lg border border-red-500/20 bg-red-500/[0.06] px-3 py-1.5 text-[11px] font-medium text-red-400 transition-colors hover:bg-red-500/10",children:"Delete"})]})]}),(0,r.jsx)("div",{className:"shrink-0 py-3",children:(0,r.jsx)("div",{className:"flex gap-1 rounded-lg border border-white/[0.08] bg-surface-800 p-1",children:["pipeline","events","dag"].map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>u(e),className:"flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors ".concat(c===e?"bg-primary-500 text-white":"text-gray-400 hover:text-gray-300"),children:"dag"===e?"DAG":e.charAt(0).toUpperCase()+e.slice(1)},e))})}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 overflow-auto",children:["pipeline"===c&&(0,r.jsx)(y,{status:l,dag:s}),"events"===c&&(0,r.jsx)(v.p,{jobId:t.id,agentName:t.agentName}),"dag"===c&&(0,r.jsx)(w,{dag:s,loading:n,status:l})]})]})}function A(){return(0,r.jsx)(o.s,{featureName:"Parallel Execution",children:(0,r.jsx)(M,{})})}function M(){var e,t,l,o,c;let x=(0,s.useRouter)(),m=(0,s.useSearchParams)(),p=null!=(e=null==m?void 0:m.get("job"))?e:null,g=null!=(t=null==m?void 0:m.get("prd"))?t:null,f=null!=(l=null==m?void 0:m.get("agent"))?l:null,j=null!=(o=null==m?void 0:m.get("model"))?o:null,[v,k]=(0,a.useState)(p?"job":g?"new-run":null),{jobs:y,refresh:N,deleteJob:w,stopJob:C}=function(){let e=(0,d.yC)(),[t,l]=(0,a.useState)([]),r=(0,a.useCallback)(async()=>{try{var t;let r=null!=(t=(await e.get("/api/jobs")).jobs)?t:[];l(r.filter(e=>"parallel"===e.mode))}catch(e){}},[e]);(0,a.useEffect)(()=>{r()},[r]);let s=t.some(e=>"running"===e.status||"queued"===e.status);(0,a.useEffect)(()=>{if(!s)return;let e=setInterval(()=>void r(),5e3);return()=>clearInterval(e)},[s,r]);let n=(0,a.useCallback)(async t=>{await e.delete("/api/jobs/".concat(t)),r()},[e,r]),i=(0,a.useCallback)(async t=>{await e.post("/api/jobs/".concat(t,"/cancel")),r()},[e,r]);return{jobs:t,refresh:r,deleteJob:n,stopJob:i}}(),A=y.find(e=>"running"===e.status||"queued"===e.status),M=null!=(c=null!=p?p:null==A?void 0:A.id)?c:null,L=null!=v?v:M?"job":null,{status:F,loading:I,refresh:W}=function(e){let t=(0,d.yC)(),[l,r]=(0,a.useState)(null),[s,n]=(0,a.useState)(!0),i=(0,a.useRef)(new Map),o=(0,a.useCallback)(async()=>{if(!e){r(null),n(!1),i.current.clear();return}try{var l,a;let s=await t.get("/api/parallel/status?jobId=".concat(encodeURIComponent(e))),n=null!=(l=s.workers)?l:[],o=null!=(a=s.allWorkers)?a:[],d=Array.isArray(s.mergeQueue)?s.mergeQueue.length:"number"==typeof s.mergeQueue?s.mergeQueue:0;for(let e of o)i.current.set(e.taskId,e);for(let e of n)i.current.set(e.taskId,e);r({...s,workers:n,allWorkers:Array.from(i.current.values()),mergeQueue:d})}catch(e){r(null)}finally{n(!1)}},[t,e]);(0,a.useEffect)(()=>{o()},[o]);let c=null!=l&&!u.has(l.status);return(0,a.useEffect)(()=>{if(!c)return;let e=setInterval(()=>void o(),3e3);return()=>clearInterval(e)},[c,o]),{status:l,loading:s,refresh:o}}("job"===L?M:null),{dag:R,loading:D}=function(e){let t=(0,d.yC)(),[l,r]=(0,a.useState)(null),[s,n]=(0,a.useState)(!1),i=(0,a.useRef)(null);return(0,a.useEffect)(()=>{e&&i.current!==e&&(i.current=e,n(!0),(async()=>{try{let l=await t.get("/api/parallel/dag?jobId=".concat(encodeURIComponent(e)));r(l)}catch(e){r(null)}finally{n(!1)}})())},[t,e]),{dag:l,loading:s}}("job"===L?M:null),{start:T,stop:B,actionRunning:P,actionMessage:E}=function(e,t){let l=(0,d.yC)(),[r,s]=(0,a.useState)(null),[n,i]=(0,a.useState)(null),o=(0,a.useRef)(null);return(0,a.useEffect)(()=>{if(n)return o.current&&clearTimeout(o.current),o.current=setTimeout(()=>i(null),5e3),()=>{o.current&&clearTimeout(o.current)}},[n]),{start:(0,a.useCallback)(async r=>{s("start"),i(null);try{var a;let s={agentName:r.agentName,mode:"parallel",maxWorkers:r.maxWorkers,maxIterations:r.maxIterations,aiConflictResolution:r.aiConflictResolution,autoCommit:!0},n={};if(r.model&&(n.model=r.model),r.sandbox&&(n.sandbox=r.sandbox),r.agent&&(n.agent=r.agent),Object.keys(n).length>0&&(s.agentConfig=n),r.verificationAgentName){s.verificationAgentName=r.verificationAgentName;let e={};r.verificationAgent&&(e.agent=r.verificationAgent),Object.keys(e).length>0&&(s.verificationAgentConfig=e)}if("prd"===r.taskSource&&r.prdContent)s.prdContent=r.prdContent;else if(s.trackerName=r.trackerName,r.trackerFileContent)s.trackerFileContent=r.trackerFileContent,s.trackerFileName=r.trackerFileName;else{let e=Object.entries(r.trackerConfig).filter(e=>{let[,t]=e;return""!==t.trim()});e.length>0&&(s.trackerConfig=Object.fromEntries(e))}r.sourceBranch&&(s.sourceBranch=r.sourceBranch);let o=await l.post("/api/parallel/start",s);return i(null!=(a=o.message)?a:"Parallel run started."),e(),t(),{jobId:o.jobId}}catch(e){return i(e instanceof Error?e.message:"Failed to start parallel run."),{}}finally{s(null)}},[l,e,t]),stop:(0,a.useCallback)(async r=>{s("stop"),i(null);try{var a;let s=await l.post("/api/parallel/stop",{jobId:r});i(null!=(a=s.message)?a:"Parallel run stopped."),e(),t()}catch(e){i(e instanceof Error?e.message:"Failed to stop parallel run.")}finally{s(null)}},[l,e,t]),actionRunning:r,actionMessage:n}}(W,N),O=M?y.find(e=>e.id===M):null,G=(0,a.useCallback)(e=>{var t;let l=new URLSearchParams(null!=(t=null==m?void 0:m.toString())?t:"");e?l.set("job",e):l.delete("job");let r=l.toString();x.replace("/parallel".concat(r?"?".concat(r):""),{scroll:!1})},[x,m]);(0,a.useEffect)(()=>{p&&k("job")},[p]);let V=(0,a.useCallback)(()=>{k("new-run"),G(null)},[G]),z=(0,a.useCallback)(e=>{k("job"),G(e)},[G]),H=(0,a.useCallback)(async e=>{let t=await T(e);t.jobId?(k("job"),G(t.jobId)):k(null),N()},[T,N,G]),q=(0,a.useCallback)(async e=>{try{await w(e),M===e&&(k(null),G(null))}catch(e){}},[w,M,G]),_=(0,a.useCallback)(async e=>{try{await B(e)}catch(e){}},[B]);return I?(0,r.jsxs)("div",{className:"flex flex-col h-[calc(100vh-32px)]",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-xl font-semibold text-white",children:"Parallel Execution"}),(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-400",children:"Execute tasks in parallel across multiple workers with DAG-based dependency ordering."})]}),(0,r.jsx)("div",{className:"mt-4",children:(0,r.jsx)(n.G,{rows:1})})]}):(0,r.jsxs)("div",{className:"flex flex-col h-[calc(100vh-32px)]",children:[(0,r.jsxs)("div",{className:"shrink-0",children:[(0,r.jsx)("h1",{className:"text-xl font-semibold text-white",children:"Parallel Execution"}),(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-400",children:"Execute tasks in parallel across multiple workers with DAG-based dependency ordering."})]}),E&&(0,r.jsx)("div",{className:"mt-3 shrink-0 rounded-lg border border-blue-500/20 bg-blue-500/[0.06] px-3 py-2 text-xs text-blue-400",children:E}),(0,r.jsxs)("div",{className:"flex gap-4 flex-1 min-h-0 mt-4",children:[(0,r.jsx)("div",{className:"w-80 min-w-[280px] max-w-[360px] shrink-0 flex flex-col rounded-xl border border-white/[0.06] bg-surface-900 overflow-hidden",children:(0,r.jsx)(b,{jobs:y,selectedId:"job"===L?M:null,onSelect:z,onNewRun:V})}),(0,r.jsx)("div",{className:"flex-1 min-w-0 rounded-xl border border-white/[0.06] bg-surface-900 p-5 overflow-hidden flex flex-col",children:"new-run"===L?(0,r.jsx)(h,{onStart:e=>void H(e),initialPrdFilename:null!=g?g:void 0,initialAgent:null!=f?f:void 0,initialModel:null!=j?j:void 0}):O?(0,r.jsx)(S,{job:O,status:F,dag:R,dagLoading:D,actionRunning:P,onStop:e=>void _(e),onDelete:e=>void q(e)}):(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center flex-1",children:[(0,r.jsx)(i.p,{title:y.length>0?"Select a job":"No parallel jobs yet",description:y.length>0?"Choose a job from the list or start a new parallel run.":"Click 'New Run' to start your first parallel execution.",icon:(0,r.jsx)("svg",{className:"h-10 w-10 text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7.5 21 3 16.5m0 0L7.5 12M3 16.5h13.5m0-13.5L21 7.5m0 0L16.5 12M21 7.5H7.5"})})}),0===y.length&&(0,r.jsxs)("button",{type:"button",onClick:V,className:"mt-4 inline-flex items-center gap-2 rounded-lg bg-primary-500 px-4 py-2 text-xs font-semibold text-white transition-colors hover:bg-primary-600",children:[(0,r.jsx)("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})}),"New Parallel Run"]})]})})]})]})}}},e=>{e.O(0,[7889,814,9743,7358],()=>e(e.s=573)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1600],{573:(e,t,l)=>{Promise.resolve().then(l.bind(l,4196))},4196:(e,t,l)=>{"use strict";l.r(t),l.d(t,{default:()=>A});var r=l(8111),a=l(5271),s=l(4736),n=l(3951),i=l(4632),o=l(3025),d=l(3446);let c={taskSource:"prd",prdFileName:"",prdContent:"",agentName:"claude",model:"",sandbox:"",agent:"",trackerName:"json",trackerConfig:{},trackerFileName:"",trackerFileContent:"",sourceBranch:"",maxWorkers:3,maxIterations:10,aiConflictResolution:!0,verificationAgentName:"",verificationAgent:""},u=new Set(["idle","stopped","error","completed","failed","cancelled"]);var x=l(5079),m=l(3310);function p(e){let{checked:t,onChange:l}=e;return(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":t,onClick:()=>l(!t),className:"relative inline-flex h-5 w-9 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors ".concat(t?"bg-primary-500":"bg-surface-700"),children:(0,r.jsx)("span",{className:"pointer-events-none inline-block h-4 w-4 rounded-full bg-white shadow-sm transition-transform ".concat(t?"translate-x-4":"translate-x-0")})})}function h(e){let{onStart:t,initialPrdFilename:l,initialAgent:s,initialModel:n}=e,i=(0,d.yC)(),[o,u]=(0,a.useState)(()=>({...c,...s?{agentName:s}:{},...n?{model:n}:{}})),[h,g]=(0,a.useState)(null),[f,b]=(0,a.useState)([]),[j,v]=(0,a.useState)(""),k=(0,a.useRef)(null),y=(0,a.useRef)(null),N=(0,a.useRef)(!1),{getForAgent:w,getFlagForAgent:C}=function(){let e=(0,d.yC)(),[t,l]=(0,a.useState)(new Map),[r,s]=(0,a.useState)(!0),n=(0,a.useCallback)(async()=>{try{var t;let r=await e.get("/api/agents/specializations?includeEmpty=true"),a=new Map;for(let e of null!=(t=r.agents)?t:[])a.set(e.agentName,e);l(a)}catch(e){}finally{s(!1)}},[e]);(0,a.useEffect)(()=>{n()},[n]);let i=(0,a.useCallback)(e=>{var l,r;return null!=(r=null==(l=t.get(e))?void 0:l.specializations)?r:[]},[t]),o=(0,a.useCallback)(e=>{var l;return null==(l=t.get(e))?void 0:l.flag},[t]);return{specs:t,loading:r,refresh:n,getForAgent:i,getFlagForAgent:o}}(),S=x.x.find(e=>e.value===o.trackerName),A="json"===o.trackerName||"markdown"===o.trackerName;(0,a.useEffect)(()=>{(async()=>{try{var e,t;let l=await i.get("/api/loop/branches");b(null!=(e=l.branches)?e:[]),v(null!=(t=l.current)?t:"")}catch(e){}})()},[i]),(0,a.useEffect)(()=>{l&&!N.current&&(N.current=!0,(async()=>{try{let e=await i.get("/api/prd/load?filename=".concat(encodeURIComponent(l)));e.markdown&&u(t=>({...t,taskSource:"prd",prdFileName:l,prdContent:e.markdown}))}catch(e){}})())},[i,l]);let M=(e,t)=>{u(l=>({...l,[e]:t})),g(null)},L=e=>t=>{var l;let r=null==(l=t.target.files)?void 0:l[0];if(!r)return;let a=new FileReader;a.onload=()=>{let t=a.result;"prd"===e?u(e=>({...e,prdFileName:r.name,prdContent:t})):u(e=>({...e,trackerFileName:r.name,trackerFileContent:t})),g(null)},a.readAsText(r)},F=()=>{if("prd"===o.taskSource&&!o.prdContent)return!1;if("tracker"===o.taskSource){if(A&&!o.trackerFileContent)return!1;if(!S)return!0;for(let t of S.fields){var e;if(t.required&&!(null==(e=o.trackerConfig[t.key])?void 0:e.trim()))return!1}}return!(o.maxWorkers<1)};return(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"mb-4 text-base font-semibold text-white",children:"New Parallel Run"}),(0,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsx)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:"Task Source"}),(0,r.jsx)("div",{className:"flex gap-1 rounded-lg border border-white/[0.08] bg-surface-800 p-1",children:[{value:"prd",label:"PRD File"},{value:"tracker",label:"Task Tracker"}].map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>M("taskSource",e.value),className:"flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors ".concat(o.taskSource===e.value?"bg-primary-500 text-white":"text-gray-400 hover:text-gray-300"),children:e.label},e.value))})]}),"prd"===o.taskSource&&(0,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsxs)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:["PRD File ",(0,r.jsx)("span",{className:"ml-0.5 text-red-400",children:"*"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{var e;return null==(e=k.current)?void 0:e.click()},className:"inline-flex items-center gap-2 rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-gray-300 transition-colors hover:bg-surface-700 hover:text-white",children:[(0,r.jsx)("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z"})}),"Browse"]}),o.prdFileName&&(0,r.jsx)("span",{className:"truncate text-sm text-gray-400",children:o.prdFileName}),(0,r.jsx)("input",{ref:k,type:"file",accept:".md,.txt,.markdown",onChange:L("prd"),className:"hidden"})]}),(0,r.jsx)("p",{className:"mt-1 text-[11px] text-gray-600",children:"Markdown file with structured tasks. Tasks will be analyzed for dependencies and grouped for parallel execution."})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-4 ".concat("tracker"===o.taskSource?"sm:grid-cols-4":"sm:grid-cols-3"),children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:"Agent"}),(0,r.jsx)("select",{value:o.agentName,onChange:e=>{let t=e.target.value;u(e=>({...e,agentName:t,model:(0,m.fZ)(t),agent:""})),g(null)},className:"w-full rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-white focus:border-primary-500/50 focus:outline-none",children:m.jw.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:"Model"}),(()=>{let e=(0,m.F_)(o.agentName);return(0,r.jsx)("select",{value:o.model,onChange:e=>M("model",e.target.value),disabled:0===e.length,className:"w-full rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-white focus:border-primary-500/50 focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed",children:0===e.length?(0,r.jsx)("option",{value:"",children:"(default)"}):e.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))})})()]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:"Sandbox"}),(0,r.jsxs)("select",{value:o.sandbox,onChange:e=>M("sandbox",e.target.value),className:"w-full rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-white focus:border-primary-500/50 focus:outline-none",children:[(0,r.jsx)("option",{value:"",children:"Default"}),(0,r.jsx)("option",{value:"workspace-write",children:"Workspace Write"}),(0,r.jsx)("option",{value:"danger-full-access",children:"Full Access"}),(0,r.jsx)("option",{value:"read-only",children:"Read Only"})]}),(0,r.jsx)("p",{className:"mt-1 text-[11px] text-gray-600",children:"Full Access enables network"})]}),"tracker"===o.taskSource&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:"Task Tracker"}),(0,r.jsx)("select",{value:o.trackerName,onChange:e=>{var t;return t=e.target.value,void(u(e=>({...e,trackerName:t,trackerConfig:{},trackerFileName:"",trackerFileContent:""})),g(null))},className:"w-full rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-white focus:border-primary-500/50 focus:outline-none",children:x.x.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))})]})]}),(()=>{let e=w(o.agentName),t=C(o.agentName),l=o.verificationAgentName||o.agentName,a=w(l),s=C(l);return(0,r.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-4 sm:grid-cols-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:"Agent Specialization"}),e.length>0?(0,r.jsxs)("select",{value:o.agent,onChange:e=>M("agent",e.target.value),className:"w-full rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-white focus:border-primary-500/50 focus:outline-none",children:[(0,r.jsx)("option",{value:"",children:"None (default)"}),e.map(e=>(0,r.jsxs)("option",{value:e.name,children:[e.name,e.description?" — ".concat(e.description.slice(0,60)):""]},e.name))]}):(0,r.jsx)("select",{disabled:!0,className:"w-full rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-gray-500 focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed",children:(0,r.jsx)("option",{children:"No specializations available"})}),t&&(0,r.jsxs)("p",{className:"mt-1 text-[11px] text-gray-600",children:["Uses ",t," flag"]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:"Verification Agent"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)("select",{value:o.verificationAgentName,onChange:e=>{M("verificationAgentName",e.target.value),M("verificationAgent","")},className:"w-1/2 rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-white focus:border-primary-500/50 focus:outline-none",children:[(0,r.jsx)("option",{value:"",children:"Same as main"}),m.jw.map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))]}),a.length>0?(0,r.jsxs)("select",{value:o.verificationAgent,onChange:e=>M("verificationAgent",e.target.value),className:"w-1/2 rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-white focus:border-primary-500/50 focus:outline-none",children:[(0,r.jsx)("option",{value:"",children:"None (default)"}),a.map(e=>(0,r.jsx)("option",{value:e.name,children:e.name},e.name))]}):(0,r.jsx)("select",{disabled:!0,className:"w-1/2 rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-gray-500 focus:outline-none disabled:opacity-50 disabled:cursor-not-allowed",children:(0,r.jsx)("option",{children:"No specializations"})})]}),(0,r.jsxs)("p",{className:"mt-1 text-[11px] text-gray-600",children:["Runs validation after all workers merge",s?" (".concat(s,")"):""]})]})]})})(),"tracker"===o.taskSource&&(0,r.jsxs)("div",{className:"mt-4 space-y-3",children:[A&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:["Task File ",(0,r.jsx)("span",{className:"ml-0.5 text-red-400",children:"*"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{var e;return null==(e=y.current)?void 0:e.click()},className:"inline-flex items-center gap-2 rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-gray-300 transition-colors hover:bg-surface-700 hover:text-white",children:[(0,r.jsx)("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z"})}),"Browse"]}),o.trackerFileName&&(0,r.jsx)("span",{className:"truncate text-sm text-gray-400",children:o.trackerFileName}),(0,r.jsx)("input",{ref:y,type:"file",accept:"json"===o.trackerName?".json":".md,.txt,.markdown",onChange:L("tracker"),className:"hidden"})]})]}),!A&&S&&S.fields.length>0&&(0,r.jsx)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:S.fields.map(e=>{var t;return(0,r.jsxs)("div",{children:[(0,r.jsxs)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:[e.label,e.required&&(0,r.jsx)("span",{className:"ml-0.5 text-red-400",children:"*"})]}),(0,r.jsx)("input",{type:e.secret?"password":"text",value:null!=(t=o.trackerConfig[e.key])?t:"",onChange:t=>{var l,r;return l=e.key,r=t.target.value,void(u(e=>({...e,trackerConfig:{...e.trackerConfig,[l]:r}})),g(null))},placeholder:e.placeholder,className:"w-full rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-white placeholder:text-gray-600 focus:border-primary-500/50 focus:outline-none"})]},e.key)})})]}),(0,r.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:"Source Branch"}),(0,r.jsxs)("select",{value:o.sourceBranch,onChange:e=>M("sourceBranch",e.target.value),className:"w-full rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-white focus:border-primary-500/50 focus:outline-none",children:[(0,r.jsxs)("option",{value:"",children:["Current (",j||"...",")"]}),f.map(e=>(0,r.jsx)("option",{value:e,children:e},e))]})]}),(0,r.jsxs)("div",{children:[(0,r.jsxs)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:["Max Workers ",(0,r.jsx)("span",{className:"ml-0.5 text-red-400",children:"*"})]}),(0,r.jsx)("input",{type:"number",min:"1",value:o.maxWorkers,onChange:e=>M("maxWorkers",Math.max(1,parseInt(e.target.value)||1)),className:"w-full rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-white placeholder:text-gray-600 focus:border-primary-500/50 focus:outline-none"}),(0,r.jsx)("p",{className:"mt-1 text-[11px] text-gray-600",children:"Concurrent workers"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:"Max Iterations"}),(0,r.jsx)("input",{type:"number",min:"1",max:"50",value:o.maxIterations,onChange:e=>M("maxIterations",Math.max(1,Math.min(50,parseInt(e.target.value)||10))),className:"w-full rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-white placeholder:text-gray-600 focus:border-primary-500/50 focus:outline-none"}),(0,r.jsx)("p",{className:"mt-1 text-[11px] text-gray-600",children:"Per worker limit"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:"AI Conflict Resolution"}),(0,r.jsxs)("div",{className:"flex h-[38px] items-center",children:[(0,r.jsx)(p,{checked:o.aiConflictResolution,onChange:e=>M("aiConflictResolution",e)}),(0,r.jsx)("span",{className:"ml-2 text-xs text-gray-500",children:o.aiConflictResolution?"Enabled":"Disabled"})]})]})]}),(0,r.jsx)("div",{className:"mt-4 rounded-lg border border-white/[0.04] bg-surface-800/30 px-3 py-2",children:(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("svg",{className:"h-3.5 w-3.5 shrink-0 text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z"})}),(0,r.jsx)("span",{className:"text-[11px] text-gray-500",children:"Auto-commit is always enabled for parallel runs (required for worktree merge)."})]})}),h&&(0,r.jsx)("p",{className:"mt-3 text-xs text-red-400",children:h}),(0,r.jsx)("div",{className:"mt-5",children:(0,r.jsxs)("button",{onClick:()=>{if(!F()){if("prd"!==o.taskSource||o.prdContent)if("tracker"===o.taskSource&&A&&!o.trackerFileContent)g("Select a task file");else if(o.maxWorkers<1)g("Max workers must be at least 1");else{let e=null==S?void 0:S.fields.filter(e=>{var t;return e.required&&!(null==(t=o.trackerConfig[e.key])?void 0:t.trim())}).map(e=>e.label);g("Required fields: ".concat(null==e?void 0:e.join(", ")))}else g("Select a PRD file");return}t(o)},disabled:!F(),className:"inline-flex items-center gap-2 rounded-lg bg-primary-500 px-4 py-2 text-xs font-semibold text-white transition-colors hover:bg-primary-600 disabled:cursor-not-allowed disabled:opacity-50",children:[(0,r.jsx)("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5.25 5.653c0-.856.917-1.398 1.667-.986l11.54 6.347a1.125 1.125 0 0 1 0 1.972l-11.54 6.347a1.125 1.125 0 0 1-1.667-.986V5.653Z"})}),"Start Parallel Run"]})})]})}var g=l(5605),f=l(8322);function b(e){let{jobs:t,selectedId:l,onSelect:a,onNewRun:s}=e,n=function(e){let t=new Set(["running","queued"]);return[...e].sort((e,l)=>{let r=+!t.has(e.status),a=+!t.has(l.status);return r!==a?r-a:new Date(l.createdAt).getTime()-new Date(e.createdAt).getTime()})}(t);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-3 shrink-0 border-b border-white/[0.04]",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h2",{className:"text-sm font-semibold text-white",children:"Parallel Jobs"}),t.length>0&&(0,r.jsx)("span",{className:"inline-flex items-center justify-center rounded-full bg-surface-800 px-1.5 py-0.5 text-[10px] font-medium text-gray-400",children:t.length})]}),(0,r.jsxs)("button",{type:"button",onClick:s,className:"inline-flex items-center gap-1.5 rounded-lg bg-primary-500 px-3 py-1.5 text-[11px] font-semibold text-white transition-colors hover:bg-primary-600",children:[(0,r.jsx)("svg",{className:"h-3 w-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})}),"New Run"]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-y-auto",children:0===n.length?(0,r.jsx)("div",{className:"p-4",children:(0,r.jsx)(i.p,{title:"No parallel jobs",description:"Start a new parallel run to create a job.",icon:(0,r.jsx)("svg",{className:"h-8 w-8 text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7.5 21 3 16.5m0 0L7.5 12M3 16.5h13.5m0-13.5L21 7.5m0 0L16.5 12M21 7.5H7.5"})})})}):n.map(e=>{let t=l===e.id,s=e.parallel;return(0,r.jsxs)("button",{type:"button",onClick:()=>a(e.id),className:"w-full px-3 py-2.5 text-left transition-colors border-b border-white/[0.02] ".concat(t?"bg-primary-500/10 border-l-2 border-l-primary-500":"hover:bg-white/[0.03]"),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(g.W,{status:e.status,size:"sm"}),(0,r.jsx)(f.L,{name:e.agentName})]}),(0,r.jsxs)("div",{className:"mt-1.5 flex items-center gap-2",children:[(0,r.jsx)("span",{className:"font-mono text-[11px] text-gray-500 truncate",children:e.sourceBranch}),s&&(0,r.jsxs)("span",{className:"text-[11px] text-gray-500 shrink-0",children:["G",s.completedGroups,"/",s.totalGroups," \xb7 ",s.mergedCount,"/",e.taskCount," merged"]}),!s&&e.taskCount>0&&(0,r.jsxs)("span",{className:"text-[11px] text-gray-500 shrink-0",children:[e.taskCount," task",1!==e.taskCount?"s":""]})]}),(0,r.jsx)("div",{className:"mt-1 text-[10px] text-gray-600",children:function(e){let t=Date.now()-new Date(e).getTime();return t<6e4?"just now":t<36e5?"".concat(Math.floor(t/6e4),"m ago"):t<864e5?"".concat(Math.floor(t/36e5),"h ago"):"".concat(Math.floor(t/864e5),"d ago")}(e.createdAt)})]},e.id)})})]})}var j=l(6142),v=l(5323);function k(e){var t,l;let{worker:a}=e,s={pending:"border-white/[0.04] bg-surface-800/50",running:"border-blue-500/20 bg-blue-950/30",completed:"border-emerald-500/20 bg-emerald-950/30",failed:"border-red-500/20 bg-red-950/30"},n=null!=(t=({pending:{dot:"bg-gray-400",label:"Pending"},running:{dot:"bg-blue-400",label:"Running",animate:!0},completed:{dot:"bg-emerald-400",label:"Completed"},failed:{dot:"bg-red-400",label:"Failed"}})[a.status])?t:{dot:"bg-gray-400",label:a.status},i=null!=(l=s[a.status])?l:s.pending,o=a.elapsedMs>0?(0,j.a)(a.elapsedMs):"",d=o?"".concat(n.label," \xb7 ").concat(o):n.label,c=a.error?a.error.length>60?a.error.slice(0,57)+"...":a.error:null;return(0,r.jsxs)("div",{className:"rounded-lg border ".concat(i," p-3 transition-colors duration-300"),children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsxs)("span",{className:"text-[11px] font-medium text-gray-400",children:["Worker ",a.id]}),a.commitCount>0&&(0,r.jsxs)("span",{className:"ml-auto text-[10px] text-gray-600",children:[a.commitCount," commit",1!==a.commitCount?"s":""]})]}),(0,r.jsx)("p",{className:"mt-1 truncate text-xs text-gray-300",children:a.taskTitle||a.taskId}),(0,r.jsxs)("div",{className:"mt-1.5 flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full ".concat(n.dot," ").concat(n.animate?"animate-pulse":"")}),(0,r.jsx)("span",{className:"text-[11px] text-gray-500",children:d})]}),(0,r.jsx)("p",{className:"mt-1 truncate font-mono text-[10px] text-gray-600",children:a.branchName}),"failed"===a.status&&c&&(0,r.jsx)("p",{className:"mt-1.5 truncate text-[11px] text-red-400",title:a.error,children:c})]})}function y(e){var t;let{status:l,dag:s}=e,[i,o]=(0,a.useState)(new Set);if(!l)return(0,r.jsx)(n.G,{rows:2});let{totalGroups:d,currentGroupIndex:c,workers:u,allWorkers:x}=l,m=Array.from({length:d},(e,t)=>({index:t,status:t<c?"completed":t===c?"active":"pending"})),p=(null!=(t=null!=x?x:u)?t:[]).filter(e=>{let t=parseInt(e.id.split("-")[0],10);return!isNaN(t)&&t===c});return(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsxs)("div",{className:"mb-3 flex items-center gap-4 text-xs text-gray-400",children:[(0,r.jsxs)("span",{children:[l.totalTasksCompleted,"/",l.totalTasks," tasks completed"]}),(0,r.jsxs)("span",{children:["Merge queue: ","number"==typeof l.mergeQueue?l.mergeQueue:0]}),l.elapsedMs>0&&(0,r.jsx)("span",{className:"font-mono text-gray-600",children:(0,j.a)(l.elapsedMs)})]}),m.map((e,t)=>{let l="active"===e.status,a="completed"===e.status,n="pending"===e.status,d=i.has(e.index)||l,c=l?"border-blue-500/30":a?"border-emerald-500/20":"border-white/[0.04]",u=l?"bg-blue-500/[0.06]":a?"bg-emerald-500/[0.04]":"bg-surface-800/30";return(0,r.jsxs)("div",{children:[t>0&&(0,r.jsx)("div",{className:"flex justify-center py-1",children:(0,r.jsx)("svg",{className:"h-4 w-4 text-gray-700",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 13.5 12 21m0 0-7.5-7.5M12 21V3"})})}),(0,r.jsxs)("div",{className:"rounded-lg border ".concat(c," overflow-hidden"),children:[(0,r.jsxs)("button",{type:"button",onClick:()=>{var t;return!l&&(t=e.index,void o(e=>{let l=new Set(e);return l.has(t)?l.delete(t):l.add(t),l}))},className:"flex w-full items-center gap-3 px-4 py-2.5 text-left ".concat(u," ").concat(l?"":"cursor-pointer hover:bg-white/[0.02]"),children:[a&&(0,r.jsx)("svg",{className:"h-4 w-4 shrink-0 text-emerald-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m4.5 12.75 6 6 9-13.5"})}),l&&(0,r.jsx)("span",{className:"h-2 w-2 shrink-0 animate-pulse rounded-full bg-blue-400"}),n&&(0,r.jsx)("span",{className:"h-2 w-2 shrink-0 rounded-full bg-gray-600"}),(0,r.jsxs)("span",{className:"text-xs font-semibold ".concat(l?"text-blue-400":a?"text-emerald-400":"text-gray-500"),children:["Group ",e.index+1,(0,r.jsx)("span",{className:"ml-1.5 font-normal text-[10px] opacity-60",children:0===e.index?"Independent":"Depends on previous"})]}),(0,r.jsx)("span",{className:"text-[11px] ".concat(l?"text-blue-400/70":a?"text-emerald-400/60":"text-gray-600"),children:l?"Running":a?"Completed":(()=>{var t,l,r;let a=null==s||null==(r=s.groups)||null==(l=r[e.index])||null==(t=l.tasks)?void 0:t.length;return a?"Pending \xb7 ".concat(a," tasks"):"Pending"})()}),!l&&(0,r.jsx)("svg",{className:"ml-auto h-3.5 w-3.5 text-gray-600 transition-transform ".concat(d?"rotate-180":""),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m19.5 8.25-7.5 7.5-7.5-7.5"})})]}),d&&l&&p.length>0&&(0,r.jsx)("div",{className:"border-t border-white/[0.04] p-3",children:(0,r.jsx)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3",children:p.map(e=>(0,r.jsx)(k,{worker:e},e.taskId))})}),d&&a&&(()=>{let t,l=(t=e.index,(null!=x?x:[]).filter(e=>{let l=parseInt(e.id.split("-")[0],10);return!isNaN(l)&&l===t}));return l.length>0?(0,r.jsx)("div",{className:"border-t border-white/[0.04] p-3",children:(0,r.jsx)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3",children:l.map(e=>(0,r.jsx)(k,{worker:e},e.taskId))})}):(0,r.jsx)("div",{className:"border-t border-white/[0.04] px-4 py-2",children:(0,r.jsx)("p",{className:"text-[11px] text-gray-500",children:"All tasks in this group completed successfully."})})})(),n&&d&&(()=>{var t,l;let a=null==s||null==(t=s.groups)?void 0:t[e.index],n=null!=(l=null==a?void 0:a.tasks)?l:[];return(0,r.jsxs)("div",{className:"border-t border-white/[0.04] px-4 py-3",children:[(0,r.jsx)("p",{className:"mb-2 text-[11px] text-gray-600",children:"Waiting for previous groups to complete."}),n.length>0&&(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:n.map(e=>(0,r.jsx)("span",{className:"inline-flex items-center rounded-full border border-white/[0.08] bg-surface-800 px-2 py-0.5 text-[10px] font-medium text-gray-500",title:e.id,children:e.title||e.id},e.id))})]})})()]})]},e.index)}),d>0&&(()=>{let e=(null!=x?x:[]).find(e=>"VALIDATION"===e.taskId),t=(null==e?void 0:e.status)==="running",a=(null==e?void 0:e.status)==="completed",s=(null==e?void 0:e.status)==="failed",n=c>=d&&!a&&!s&&"completed"!==l.status&&"failed"!==l.status,i=a?"border-emerald-500/20":t||n?"border-purple-500/30":s?"border-red-500/20":"border-white/[0.04]",o=a?"bg-emerald-500/[0.04]":t||n?"bg-purple-500/[0.06]":s?"bg-red-500/[0.04]":"bg-surface-800/30",u=a?"Completed":s?"Failed":t||n?"Running":"Pending",m=a?"text-emerald-400":s?"text-red-400":t||n?"text-purple-400":"text-gray-500";return(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"flex justify-center py-1",children:(0,r.jsx)("svg",{className:"h-4 w-4 text-gray-700",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 13.5 12 21m0 0-7.5-7.5M12 21V3"})})}),(0,r.jsx)("div",{className:"rounded-lg border ".concat(i," overflow-hidden"),children:(0,r.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2.5 ".concat(o),children:[a&&(0,r.jsx)("svg",{className:"h-4 w-4 shrink-0 text-emerald-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m4.5 12.75 6 6 9-13.5"})}),s&&(0,r.jsx)("svg",{className:"h-4 w-4 shrink-0 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18 18 6M6 6l12 12"})}),(t||n)&&(0,r.jsx)("span",{className:"h-2 w-2 shrink-0 animate-pulse rounded-full bg-purple-400"}),!a&&!s&&!t&&!n&&(0,r.jsx)("span",{className:"h-2 w-2 shrink-0 rounded-full bg-gray-600"}),(0,r.jsxs)("span",{className:"text-xs font-semibold ".concat(m),children:["Validation",(0,r.jsx)("span",{className:"ml-1.5 font-normal text-[10px] opacity-60",children:"Verifies all tasks against PRD"})]}),(0,r.jsx)("span",{className:"text-[11px] ".concat(m," opacity-70"),children:u}),(null==e?void 0:e.elapsedMs)!=null&&e.elapsedMs>0&&(0,r.jsx)("span",{className:"ml-auto text-[10px] font-mono text-gray-600",children:(0,j.a)(e.elapsedMs)})]})})]})})(),0===d&&(0,r.jsx)("div",{className:"rounded-lg border border-white/[0.04] bg-surface-800/30 px-4 py-8 text-center text-sm text-gray-500",children:"No pipeline groups available."})]})}function N(e){let{node:t,x:l,y:a}=e;return(0,r.jsxs)("div",{className:"pointer-events-none absolute z-50 max-w-xs rounded-lg border border-white/10 bg-surface-900 px-3 py-2 shadow-xl",style:{left:l,top:a-8,transform:"translate(-50%, -100%)"},children:[(0,r.jsx)("div",{className:"text-xs font-semibold text-white",children:t.id}),(0,r.jsx)("div",{className:"mt-0.5 text-[11px] text-gray-400 line-clamp-2",children:t.title}),t.dependencies.length>0&&(0,r.jsxs)("div",{className:"mt-1 text-[10px] text-gray-500",children:["Depends on: ",t.dependencies.join(", ")]}),t.dependents.length>0&&(0,r.jsxs)("div",{className:"mt-0.5 text-[10px] text-gray-500",children:["Blocks: ",t.dependents.join(", ")]})]})}function w(e){var t,l,s;let{dag:o,loading:d,status:c}=e,u=(0,a.useRef)(null),[x,m]=(0,a.useState)(null),[p,h]=(0,a.useState)({x:0,y:0}),g=(0,a.useMemo)(()=>{let e=new Map;if(null==c?void 0:c.allWorkers)for(let t of c.allWorkers)e.set(t.taskId,t.status);return e},[c]),f=(0,a.useMemo)(()=>o?function(e,t){var l,r,a,s;let n=null!=(l=e.nodes)?l:{},i=(null!=(r=e.groups)?r:[]).map(e=>{var t;let l=e.tasks?e.tasks:(null!=(t=e.taskIds)?t:[]).map(e=>{var t,l;return{id:e,title:null!=(l=null==(t=n[e])?void 0:t.title)?l:e}});return{depth:e.depth,tasks:l}}),o=[],d=[],c=1;for(let e of i)e.tasks.length>c&&(c=e.tasks.length);let u=200*c+(c-1)*24;for(let e=0;e<i.length;e++){let l=i[e],r=l.tasks,d=40+(u-(200*r.length+(r.length-1)*24))/2,c=72+120*e;for(let e=0;e<r.length;e++){let i=r[e],u=n[i.id],x=d+224*e;o.push({id:i.id,title:(null==u?void 0:u.title)||i.title||i.id,depth:l.depth,x,y:c,cx:x+100,cy:c+26,dependencies:null!=(a=null==u?void 0:u.dependencies)?a:[],dependents:null!=(s=null==u?void 0:u.dependents)?s:[],status:t.get(i.id)})}}let x=new Map(o.map(e=>[e.id,e]));for(let e of o)for(let t of e.dependencies)x.has(t)&&d.push({from:t,to:e.id});let m=o.filter(e=>0===e.dependents.length).map(e=>e.id);if(i.length>0&&m.length>0){let e=72+120*i.length,l=40+(u-200)/2;for(let r of(o.push({id:"VALIDATION",title:"Post-Parallel Validation",depth:i.length,x:l,y:e,cx:l+100,cy:e+26,dependencies:m,dependents:[],status:t.get("VALIDATION")}),x.set("VALIDATION",o[o.length-1]),m))d.push({from:r,to:"VALIDATION"})}let p=o.length>0?Math.max(...o.map(e=>e.y)):48;return{nodes:o,edges:d,width:80+u,height:p+52+48}}(o,g):null,[o,g]);if(d)return(0,r.jsx)(n.G,{rows:2});if(!o)return(0,r.jsx)(i.p,{title:"No DAG analysis",description:"Start a parallel job to see the dependency graph.",icon:(0,r.jsx)("svg",{className:"h-8 w-8 text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7.5 21 3 16.5m0 0L7.5 12M3 16.5h13.5m0-13.5L21 7.5m0 0L16.5 12M21 7.5H7.5"})})});if(!f||0===f.nodes.length)return(0,r.jsx)(i.p,{title:"Empty graph",description:"No tasks found in the DAG.",icon:(0,r.jsx)("svg",{className:"h-8 w-8 text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7.5 21 3 16.5m0 0L7.5 12M3 16.5h13.5m0-13.5L21 7.5m0 0L16.5 12M21 7.5H7.5"})})});let b=x?f.nodes.find(e=>e.id===x):null,j=new Set,v=new Set;if(x){v.add(x);let e=f.nodes.find(e=>e.id===x);if(e){for(let t of e.dependencies)v.add(t),j.add("".concat(t,"->").concat(x));for(let t of e.dependents)v.add(t),j.add("".concat(x,"->").concat(t))}}let k=null!=(t=o.groups)?t:[],y=[...k.map((e,t)=>({label:"G".concat(t+1),depth:e.depth,y:72+120*t})),...k.length>0?[{label:"V",depth:k.length,y:72+120*k.length}]:[]],w=f.edges.length>0;return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"flex flex-wrap gap-4 text-xs text-gray-400",children:[(0,r.jsxs)("span",{children:["Groups: ",(0,r.jsx)("span",{className:"font-semibold text-white",children:k.length})]}),(0,r.jsxs)("span",{children:["Tasks: ",(0,r.jsx)("span",{className:"font-semibold text-white",children:(null!=(l=o.order)?l:[]).length})]}),(0,r.jsxs)("span",{children:["Max Parallelism: ",(0,r.jsx)("span",{className:"font-semibold text-white",children:null!=(s=o.maxParallelism)?s:0})]}),!w&&f.nodes.length>0&&(0,r.jsx)("span",{className:"text-yellow-500/80",children:"(Dependency arrows require API rebuild)"})]}),(0,r.jsxs)("div",{ref:u,className:"relative overflow-x-auto overflow-y-auto rounded-lg border border-white/[0.06] bg-[#0d0d14]",children:[(0,r.jsxs)("svg",{width:f.width,height:f.height,className:"block",children:[(0,r.jsxs)("defs",{children:[(0,r.jsx)("marker",{id:"arrow",markerWidth:"10",markerHeight:"7",refX:"9",refY:"3.5",orient:"auto",children:(0,r.jsx)("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#a78bfa",fillOpacity:"0.7"})}),(0,r.jsx)("marker",{id:"arrow-dim",markerWidth:"10",markerHeight:"7",refX:"9",refY:"3.5",orient:"auto",children:(0,r.jsx)("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#6b7280",fillOpacity:"0.3"})}),(0,r.jsx)("marker",{id:"arrow-hl",markerWidth:"10",markerHeight:"7",refX:"9",refY:"3.5",orient:"auto",children:(0,r.jsx)("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#c4b5fd"})})]}),y.map((e,t)=>(0,r.jsx)("text",{x:14,y:e.y+26+4,fill:"V"===e.label?"#a78bfa":"#9ca3af",fontSize:11,fontWeight:600,children:e.label},"glabel-".concat(t))),y.map((e,t)=>t>0?(0,r.jsx)("line",{x1:0,y1:e.y-34,x2:f.width,y2:e.y-34,stroke:"#ffffff",strokeOpacity:.06,strokeWidth:1,strokeDasharray:"6 4"},"sep-".concat(t)):null),f.edges.map(e=>{let t=f.nodes.find(t=>t.id===e.from),l=f.nodes.find(t=>t.id===e.to);if(!t||!l)return null;let a=t.cx,s=t.y+52,n=l.cx,i=l.y,o="".concat(e.from,"->").concat(e.to),d=j.has(o),c=x&&!d;return(0,r.jsx)("path",{d:function(e,t,l,r){let a=(t+r)/2;return"M ".concat(e," ").concat(t," C ").concat(e," ").concat(a,", ").concat(l," ").concat(a,", ").concat(l," ").concat(r)}(a,s,n,i),fill:"none",stroke:d?"#c4b5fd":c?"#374151":"#a78bfa",strokeOpacity:d?1:c?.3:.6,strokeWidth:d?2.5:1.5,markerEnd:d?"url(#arrow-hl)":c?"url(#arrow-dim)":"url(#arrow)",style:{transition:"stroke 0.15s, stroke-opacity 0.15s, stroke-width 0.15s"}},o)}),f.nodes.map(e=>{let t=function(e){switch(e){case"completed":return{bg:"#065f46",border:"#10b981",idFill:"#6ee7b7",titleFill:"#a7f3d0",dotFill:"#34d399"};case"failed":return{bg:"#7f1d1d",border:"#ef4444",idFill:"#fca5a5",titleFill:"#fecaca",dotFill:"#f87171"};case"running":return{bg:"#1e3a5f",border:"#3b82f6",idFill:"#93c5fd",titleFill:"#bfdbfe",dotFill:"#60a5fa"};default:return{bg:"#1e1e2e",border:"#4b5563",idFill:"#d1d5db",titleFill:"#9ca3af",dotFill:"#6b7280"}}}(e.status),l=x===e.id,a=!x||v.has(e.id),s=x&&!a;return(0,r.jsxs)("g",{style:{transition:"opacity 0.15s"},opacity:s?.2:1,onMouseEnter:()=>{m(e.id),h({x:e.cx,y:e.y})},onMouseLeave:()=>m(null),className:"cursor-pointer",children:[(0,r.jsx)("rect",{x:e.x,y:e.y,width:200,height:52,rx:10,ry:10,fill:t.bg,fillOpacity:.6,stroke:a&&x?"#ffffff":t.border,strokeOpacity:l?1:a&&x?.8:.4,strokeWidth:l?2.5:a&&x?2:1}),(0,r.jsx)("circle",{cx:e.x+14,cy:e.cy,r:4,fill:t.dotFill,children:"running"===e.status&&(0,r.jsx)("animate",{attributeName:"opacity",values:"1;0.3;1",dur:"1.5s",repeatCount:"indefinite"})}),(0,r.jsx)("text",{x:e.x+26,y:e.y+20,fill:t.idFill,fontSize:11,fontWeight:700,fontFamily:"ui-monospace, monospace",children:e.id}),(0,r.jsx)("text",{x:e.x+26,y:e.y+36,fill:t.titleFill,fillOpacity:.7,fontSize:10,children:e.title.length>22?e.title.slice(0,22)+"…":e.title}),e.dependencies.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("rect",{x:e.x+200-26,y:e.y+4,width:22,height:15,rx:7,fill:"#7c3aed",fillOpacity:.3}),(0,r.jsx)("text",{x:e.x+200-15,y:e.y+14,textAnchor:"middle",fill:"#c4b5fd",fontSize:9,fontWeight:700,children:e.dependencies.length})]})]},e.id)})]}),b&&(0,r.jsx)(N,{node:b,x:p.x,y:p.y})]}),o.warnings.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"mb-2 text-xs font-semibold text-yellow-400",children:"Warnings"}),(0,r.jsx)("div",{className:"space-y-1.5",children:o.warnings.map((e,t)=>(0,r.jsx)("div",{className:"rounded-lg border border-yellow-500/20 bg-yellow-500/[0.06] px-3 py-2 text-xs text-yellow-400",children:e},t))})]}),o.cyclicTaskIds.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"mb-2 text-xs font-semibold text-red-400",children:"Cyclic Tasks"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:o.cyclicTaskIds.map(e=>(0,r.jsx)("span",{className:"inline-flex items-center rounded-full border border-red-500/20 bg-red-500/[0.06] px-2.5 py-0.5 text-[11px] font-medium text-red-400",children:e},e))}),(0,r.jsx)("p",{className:"mt-1.5 text-[11px] text-gray-600",children:"These tasks have circular dependencies and could not be scheduled optimally."})]})]})}function C(e){let{label:t,value:l,mono:a}=e;return(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-[11px] font-medium text-gray-500 w-20 shrink-0",children:t}),(0,r.jsx)("span",{className:"text-xs text-gray-300 ".concat(a?"font-mono":""),children:l})]})}function S(e){let{job:t,status:l,dag:s,dagLoading:n,actionRunning:i,onStop:o,onDelete:d}=e,[c,u]=(0,a.useState)("pipeline"),x="running"===t.status||"queued"===t.status,m="";if(t.startedAt&&t.completedAt){let e=new Date(t.completedAt).getTime()-new Date(t.startedAt).getTime();m=(0,j.a)(e)}else if(t.startedAt){let e=Date.now()-new Date(t.startedAt).getTime();m=(0,j.a)(e)}let p=t.parallel;return(0,r.jsxs)("div",{className:"flex flex-col h-full overflow-hidden",children:[(0,r.jsxs)("div",{className:"shrink-0 pb-4 border-b border-white/[0.04]",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,r.jsx)(g.W,{status:t.status}),(0,r.jsx)(f.L,{name:t.agentName}),(0,r.jsx)("span",{className:"font-mono text-xs text-gray-500",children:t.sourceBranch}),m&&(0,r.jsx)("span",{className:"font-mono text-xs text-gray-600",children:m})]}),(0,r.jsxs)("div",{className:"mt-3 space-y-1",children:[(0,r.jsx)(C,{label:"Job ID",value:t.id,mono:!0}),(0,r.jsx)(C,{label:"Created",value:new Date(t.createdAt).toLocaleString()}),t.startedAt&&(0,r.jsx)(C,{label:"Started",value:new Date(t.startedAt).toLocaleString()}),t.completedAt&&(0,r.jsx)(C,{label:"Completed",value:new Date(t.completedAt).toLocaleString()}),p&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(C,{label:"Workers",value:"".concat(p.workerCount," / ").concat(p.maxWorkers," max")}),(0,r.jsx)(C,{label:"Groups",value:"".concat(p.completedGroups,"/").concat(p.totalGroups," completed")}),(0,r.jsx)(C,{label:"Merged",value:"".concat(p.mergedCount,"/").concat(t.taskCount," tasks")})]}),!p&&t.taskCount>0&&(0,r.jsx)(C,{label:"Tasks",value:"".concat(t.taskCount)}),(0,r.jsx)(C,{label:"Mode",value:"Parallel"})]}),t.error&&(0,r.jsx)("div",{className:"mt-3 rounded-lg border border-red-500/20 bg-red-500/[0.06] px-3 py-2 text-xs text-red-400",children:t.error}),(0,r.jsxs)("div",{className:"mt-3 flex items-center gap-2",children:[x&&(0,r.jsx)("button",{onClick:()=>o(t.id),disabled:"stop"===i,className:"rounded-lg border border-yellow-500/20 bg-yellow-500/[0.06] px-3 py-1.5 text-[11px] font-medium text-yellow-400 transition-colors hover:bg-yellow-500/10 disabled:cursor-not-allowed disabled:opacity-50",children:"stop"===i?"Stopping...":"Stop All"}),(0,r.jsx)("button",{onClick:()=>d(t.id),className:"rounded-lg border border-red-500/20 bg-red-500/[0.06] px-3 py-1.5 text-[11px] font-medium text-red-400 transition-colors hover:bg-red-500/10",children:"Delete"})]})]}),(0,r.jsx)("div",{className:"shrink-0 py-3",children:(0,r.jsx)("div",{className:"flex gap-1 rounded-lg border border-white/[0.08] bg-surface-800 p-1",children:["pipeline","events","dag"].map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>u(e),className:"flex-1 rounded-md px-3 py-1.5 text-xs font-medium transition-colors ".concat(c===e?"bg-primary-500 text-white":"text-gray-400 hover:text-gray-300"),children:"dag"===e?"DAG":e.charAt(0).toUpperCase()+e.slice(1)},e))})}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 overflow-auto",children:["pipeline"===c&&(0,r.jsx)(y,{status:l,dag:s}),"events"===c&&(0,r.jsx)(v.p,{jobId:t.id,agentName:t.agentName}),"dag"===c&&(0,r.jsx)(w,{dag:s,loading:n,status:l})]})]})}function A(){return(0,r.jsx)(o.s,{featureName:"Parallel Execution",children:(0,r.jsx)(a.Suspense,{fallback:(0,r.jsx)("div",{}),children:(0,r.jsx)(M,{})})})}function M(){var e,t,l,o,c;let x=(0,s.useRouter)(),m=(0,s.useSearchParams)(),p=null!=(e=null==m?void 0:m.get("job"))?e:null,g=null!=(t=null==m?void 0:m.get("prd"))?t:null,f=null!=(l=null==m?void 0:m.get("agent"))?l:null,j=null!=(o=null==m?void 0:m.get("model"))?o:null,[v,k]=(0,a.useState)(p?"job":g?"new-run":null),{jobs:y,refresh:N,deleteJob:w,stopJob:C}=function(){let e=(0,d.yC)(),[t,l]=(0,a.useState)([]),r=(0,a.useCallback)(async()=>{try{var t;let r=null!=(t=(await e.get("/api/jobs")).jobs)?t:[];l(r.filter(e=>"parallel"===e.mode))}catch(e){}},[e]);(0,a.useEffect)(()=>{r()},[r]);let s=t.some(e=>"running"===e.status||"queued"===e.status);(0,a.useEffect)(()=>{if(!s)return;let e=setInterval(()=>void r(),5e3);return()=>clearInterval(e)},[s,r]);let n=(0,a.useCallback)(async t=>{await e.delete("/api/jobs/".concat(t)),r()},[e,r]),i=(0,a.useCallback)(async t=>{await e.post("/api/jobs/".concat(t,"/cancel")),r()},[e,r]);return{jobs:t,refresh:r,deleteJob:n,stopJob:i}}(),A=y.find(e=>"running"===e.status||"queued"===e.status),M=null!=(c=null!=p?p:null==A?void 0:A.id)?c:null,L=null!=v?v:M?"job":null,{status:F,loading:I,refresh:W}=function(e){let t=(0,d.yC)(),[l,r]=(0,a.useState)(null),[s,n]=(0,a.useState)(!0),i=(0,a.useRef)(new Map),o=(0,a.useCallback)(async()=>{if(!e){r(null),n(!1),i.current.clear();return}try{var l,a;let s=await t.get("/api/parallel/status?jobId=".concat(encodeURIComponent(e))),n=null!=(l=s.workers)?l:[],o=null!=(a=s.allWorkers)?a:[],d=Array.isArray(s.mergeQueue)?s.mergeQueue.length:"number"==typeof s.mergeQueue?s.mergeQueue:0;for(let e of o)i.current.set(e.taskId,e);for(let e of n)i.current.set(e.taskId,e);r({...s,workers:n,allWorkers:Array.from(i.current.values()),mergeQueue:d})}catch(e){r(null)}finally{n(!1)}},[t,e]);(0,a.useEffect)(()=>{o()},[o]);let c=null!=l&&!u.has(l.status);return(0,a.useEffect)(()=>{if(!c)return;let e=setInterval(()=>void o(),3e3);return()=>clearInterval(e)},[c,o]),{status:l,loading:s,refresh:o}}("job"===L?M:null),{dag:R,loading:D}=function(e){let t=(0,d.yC)(),[l,r]=(0,a.useState)(null),[s,n]=(0,a.useState)(!1),i=(0,a.useRef)(null);return(0,a.useEffect)(()=>{e&&i.current!==e&&(i.current=e,n(!0),(async()=>{try{let l=await t.get("/api/parallel/dag?jobId=".concat(encodeURIComponent(e)));r(l)}catch(e){r(null)}finally{n(!1)}})())},[t,e]),{dag:l,loading:s}}("job"===L?M:null),{start:T,stop:B,actionRunning:P,actionMessage:E}=function(e,t){let l=(0,d.yC)(),[r,s]=(0,a.useState)(null),[n,i]=(0,a.useState)(null),o=(0,a.useRef)(null);return(0,a.useEffect)(()=>{if(n)return o.current&&clearTimeout(o.current),o.current=setTimeout(()=>i(null),5e3),()=>{o.current&&clearTimeout(o.current)}},[n]),{start:(0,a.useCallback)(async r=>{s("start"),i(null);try{var a;let s={agentName:r.agentName,mode:"parallel",maxWorkers:r.maxWorkers,maxIterations:r.maxIterations,aiConflictResolution:r.aiConflictResolution,autoCommit:!0},n={};if(r.model&&(n.model=r.model),r.sandbox&&(n.sandbox=r.sandbox),r.agent&&(n.agent=r.agent),Object.keys(n).length>0&&(s.agentConfig=n),r.verificationAgentName){s.verificationAgentName=r.verificationAgentName;let e={};r.verificationAgent&&(e.agent=r.verificationAgent),Object.keys(e).length>0&&(s.verificationAgentConfig=e)}if("prd"===r.taskSource&&r.prdContent)s.prdContent=r.prdContent;else if(s.trackerName=r.trackerName,r.trackerFileContent)s.trackerFileContent=r.trackerFileContent,s.trackerFileName=r.trackerFileName;else{let e=Object.entries(r.trackerConfig).filter(e=>{let[,t]=e;return""!==t.trim()});e.length>0&&(s.trackerConfig=Object.fromEntries(e))}r.sourceBranch&&(s.sourceBranch=r.sourceBranch);let o=await l.post("/api/parallel/start",s);return i(null!=(a=o.message)?a:"Parallel run started."),e(),t(),{jobId:o.jobId}}catch(e){return i(e instanceof Error?e.message:"Failed to start parallel run."),{}}finally{s(null)}},[l,e,t]),stop:(0,a.useCallback)(async r=>{s("stop"),i(null);try{var a;let s=await l.post("/api/parallel/stop",{jobId:r});i(null!=(a=s.message)?a:"Parallel run stopped."),e(),t()}catch(e){i(e instanceof Error?e.message:"Failed to stop parallel run.")}finally{s(null)}},[l,e,t]),actionRunning:r,actionMessage:n}}(W,N),O=M?y.find(e=>e.id===M):null,G=(0,a.useCallback)(e=>{var t;let l=new URLSearchParams(null!=(t=null==m?void 0:m.toString())?t:"");e?l.set("job",e):l.delete("job");let r=l.toString();x.replace("/parallel".concat(r?"?".concat(r):""),{scroll:!1})},[x,m]);(0,a.useEffect)(()=>{p&&k("job")},[p]);let V=(0,a.useCallback)(()=>{k("new-run"),G(null)},[G]),z=(0,a.useCallback)(e=>{k("job"),G(e)},[G]),H=(0,a.useCallback)(async e=>{let t=await T(e);t.jobId?(k("job"),G(t.jobId)):k(null),N()},[T,N,G]),q=(0,a.useCallback)(async e=>{try{await w(e),M===e&&(k(null),G(null))}catch(e){}},[w,M,G]),_=(0,a.useCallback)(async e=>{try{await B(e)}catch(e){}},[B]);return I?(0,r.jsxs)("div",{className:"flex flex-col h-[calc(100vh-32px)]",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-xl font-semibold text-white",children:"Parallel Execution"}),(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-400",children:"Execute tasks in parallel across multiple workers with DAG-based dependency ordering."})]}),(0,r.jsx)("div",{className:"mt-4",children:(0,r.jsx)(n.G,{rows:1})})]}):(0,r.jsxs)("div",{className:"flex flex-col h-[calc(100vh-32px)]",children:[(0,r.jsxs)("div",{className:"shrink-0",children:[(0,r.jsx)("h1",{className:"text-xl font-semibold text-white",children:"Parallel Execution"}),(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-400",children:"Execute tasks in parallel across multiple workers with DAG-based dependency ordering."})]}),E&&(0,r.jsx)("div",{className:"mt-3 shrink-0 rounded-lg border border-blue-500/20 bg-blue-500/[0.06] px-3 py-2 text-xs text-blue-400",children:E}),(0,r.jsxs)("div",{className:"flex gap-4 flex-1 min-h-0 mt-4",children:[(0,r.jsx)("div",{className:"w-80 min-w-[280px] max-w-[360px] shrink-0 flex flex-col rounded-xl border border-white/[0.06] bg-surface-900 overflow-hidden",children:(0,r.jsx)(b,{jobs:y,selectedId:"job"===L?M:null,onSelect:z,onNewRun:V})}),(0,r.jsx)("div",{className:"flex-1 min-w-0 rounded-xl border border-white/[0.06] bg-surface-900 p-5 overflow-hidden flex flex-col",children:"new-run"===L?(0,r.jsx)(h,{onStart:e=>void H(e),initialPrdFilename:null!=g?g:void 0,initialAgent:null!=f?f:void 0,initialModel:null!=j?j:void 0}):O?(0,r.jsx)(S,{job:O,status:F,dag:R,dagLoading:D,actionRunning:P,onStop:e=>void _(e),onDelete:e=>void q(e)}):(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center flex-1",children:[(0,r.jsx)(i.p,{title:y.length>0?"Select a job":"No parallel jobs yet",description:y.length>0?"Choose a job from the list or start a new parallel run.":"Click 'New Run' to start your first parallel execution.",icon:(0,r.jsx)("svg",{className:"h-10 w-10 text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7.5 21 3 16.5m0 0L7.5 12M3 16.5h13.5m0-13.5L21 7.5m0 0L16.5 12M21 7.5H7.5"})})}),0===y.length&&(0,r.jsxs)("button",{type:"button",onClick:V,className:"mt-4 inline-flex items-center gap-2 rounded-lg bg-primary-500 px-4 py-2 text-xs font-semibold text-white transition-colors hover:bg-primary-600",children:[(0,r.jsx)("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})}),"New Parallel Run"]})]})})]})]})}}},e=>{e.O(0,[7889,814,9743,7358],()=>e(e.s=573)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6816],{422:(e,t,s)=>{"use strict";function r(){{let e=window.location.hostname;return"localhost"===e||"127.0.0.1"===e}}function a(){return r(),"http://localhost:9800"}s.d(t,{J:()=>r,h:()=>a})},704:(e,t,s)=>{"use strict";s.d(t,{$:()=>n,Dy:()=>l,Ji:()=>i});var r=s(5271),a=s(3446);function n(){let e=(0,a.yC)(),[t,s]=(0,r.useState)(null),[n,i]=(0,r.useState)(!0),[l,o]=(0,r.useState)(null),c=(0,r.useRef)(null),d=(0,r.useCallback)(async()=>{o(null);try{let t=await e.get("/api/codemap/status");return s(t),t}catch(e){return o(e instanceof Error?e.message:"Failed to fetch codemap status"),null}finally{i(!1)}},[e]);return(0,r.useEffect)(()=>{let e=!1;async function t(){var s;if(e)return;let r=await d();e||(c.current=setTimeout(()=>void t(),null!=(s=null==r?void 0:r.pollIntervalMs)?s:15e3))}return i(!0),t(),()=>{e=!0,c.current&&clearTimeout(c.current)}},[d]),{status:t,loading:n,error:l,refresh:d}}function i(){let e=(0,a.yC)(),[t,s]=(0,r.useState)([]),[n,i]=(0,r.useState)(!1),[l,o]=(0,r.useState)(null);return{results:t,searching:n,search:(0,r.useCallback)(async(t,r)=>{i(!0),o(null);try{var a,n,l;let i=await e.post("/api/codemap/search",{query:t,...r});return s(null!=(a=i.results)?a:[]),o(null!=(n=i.durationMs)?n:null),null!=(l=i.results)?l:[]}catch(e){return s([]),o(null),[]}finally{i(!1)}},[e]),durationMs:l}}function l(){let e=(0,a.yC)(),t=(0,r.useCallback)(async()=>e.get("/api/codemap/config"),[e]);return{getConfig:t,updateConfig:(0,r.useCallback)(async t=>e.put("/api/codemap/config",t),[e]),triggerAction:(0,r.useCallback)(async t=>e.post("/api/codemap/action",{action:t}),[e])}}},1208:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>w});var r=s(8111),a=s(5271),n=s(3446),i=s(8934),l=s(2928),o=s(704),c=s(8984),d=s(3951),u=s(4632),x=s(6028),m=s(5935),h=s.n(m);function p(e){let{repo:t,onDelete:s,onSetDefault:n}=e,[i,l]=(0,a.useState)(!1);return(0,r.jsx)("div",{className:"group rounded-xl border border-white/[0.06] bg-surface-900 p-4 transition-colors hover:border-white/[0.1]",children:(0,r.jsxs)("div",{className:"flex items-start gap-4",children:[(0,r.jsx)("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-surface-800",children:(0,r.jsx)("svg",{className:"h-5 w-5 text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 12.75V12A2.25 2.25 0 0 1 4.5 9.75h15A2.25 2.25 0 0 1 21.75 12v.75m-8.69-6.44-2.12-2.12a1.5 1.5 0 0 0-1.061-.44H4.5A2.25 2.25 0 0 0 2.25 6v12a2.25 2.25 0 0 0 2.25 2.25h15A2.25 2.25 0 0 0 21.75 18V9a2.25 2.25 0 0 0-2.25-2.25h-5.379a1.5 1.5 0 0 1-1.06-.44Z"})})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h3",{className:"text-sm font-semibold text-white",children:t.name}),t.isDefault&&(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full bg-primary-500/15 px-2 py-0.5 text-[11px] font-medium text-primary-400",children:[(0,r.jsx)("svg",{className:"h-3 w-3",fill:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.006 5.404.434c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.434 2.082-5.005Z"})}),"Default"]})]}),(0,r.jsx)("p",{className:"mt-0.5 truncate font-mono text-xs text-gray-500",children:t.path})]}),(0,r.jsxs)("div",{className:"flex shrink-0 items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100",children:[!t.isDefault&&(0,r.jsx)("button",{onClick:()=>n(t.id),className:"rounded-lg p-1.5 text-gray-500 transition-colors hover:bg-white/[0.06] hover:text-primary-400",title:"Set as default",children:(0,r.jsx)("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11.48 3.499a.562.562 0 0 1 1.04 0l2.125 5.111a.563.563 0 0 0 .475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 0 0-.182.557l1.285 5.385a.562.562 0 0 1-.84.61l-4.725-2.885a.562.562 0 0 0-.586 0L6.982 20.54a.562.562 0 0 1-.84-.61l1.285-5.386a.562.562 0 0 0-.182-.557l-4.204-3.602a.562.562 0 0 1 .321-.988l5.518-.442a.563.563 0 0 0 .475-.345L11.48 3.5Z"})})}),(0,r.jsx)("button",{onClick:()=>{i?(s(t.id),l(!1)):(l(!0),setTimeout(()=>l(!1),3e3))},className:"rounded-lg p-1.5 transition-colors ".concat(i?"bg-red-500/10 text-red-400":"text-gray-500 hover:bg-white/[0.06] hover:text-red-400"),title:i?"Click again to confirm":"Remove repo",children:(0,r.jsx)("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0"})})})]})]})})}function f(e){let{onAdd:t,onClose:s}=e,[n,i]=(0,a.useState)(""),[l,o]=(0,a.useState)(""),[c,d]=(0,a.useState)(!1),[u,x]=(0,a.useState)(null);async function m(){if(n.trim()&&l.trim()){d(!0),x(null);try{await t({name:n.trim(),path:l.trim()}),s()}catch(e){x(e instanceof Error?e.message:"Failed to register repo")}finally{d(!1)}}}return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:"Repo Name"}),(0,r.jsx)("input",{type:"text",value:n,onChange:e=>i(e.target.value),placeholder:"My Repo",className:"w-full rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-white placeholder-gray-600 outline-none focus:border-primary-500/50"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"mb-1.5 block text-xs font-medium text-gray-400",children:"Path"}),(0,r.jsx)("input",{type:"text",value:l,onChange:e=>o(e.target.value),placeholder:"/path/to/repo",className:"w-full rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 font-mono text-sm text-white placeholder-gray-600 outline-none focus:border-primary-500/50"})]}),u&&(0,r.jsx)("div",{className:"rounded-lg border border-red-500/20 bg-red-500/[0.06] px-3 py-2 text-xs text-red-400",children:u}),(0,r.jsxs)("div",{className:"flex items-center gap-3 pt-2",children:[(0,r.jsx)("button",{onClick:()=>void m(),disabled:c||!n.trim()||!l.trim(),className:"rounded-lg bg-primary-500 px-4 py-2 text-sm font-semibold text-white transition-colors hover:bg-primary-600 disabled:cursor-not-allowed disabled:opacity-50",children:c?"Adding...":"Add Repo"}),(0,r.jsx)("button",{onClick:s,className:"rounded-lg px-4 py-2 text-sm font-medium text-gray-400 transition-colors hover:text-gray-200",children:"Cancel"})]})]})}function g(){let{repos:e,loading:t,error:s,registerRepo:i,deleteRepo:l,setDefault:o}=function(){let e=(0,n.yC)(),[t,s]=(0,a.useState)([]),[r,i]=(0,a.useState)(!0),[l,o]=(0,a.useState)(null),c=(0,a.useCallback)(async()=>{i(!0),o(null);try{var t;let r=await e.get("/api/repos");s(null!=(t=r.repos)?t:[])}catch(e){o(e instanceof Error?e.message:"Failed to fetch repos")}finally{i(!1)}},[e]);(0,a.useEffect)(()=>{c()},[c]);let d=(0,a.useCallback)(async t=>{await e.post("/api/repos",t),await c()},[e,c]),u=(0,a.useCallback)(async t=>{await e.delete("/api/repos/".concat(t)),await c()},[e,c]),x=(0,a.useCallback)(async t=>{await e.post("/api/repos/default",{id:t}),await c()},[e,c]);return{repos:t,loading:r,error:l,refresh:c,registerRepo:d,deleteRepo:u,setDefault:x}}(),[c,m]=(0,a.useState)(!1);return t?(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)("h1",{className:"text-xl font-semibold text-white",children:"Repos"}),(0,r.jsx)(d.G,{rows:3})]}):s?(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)("h1",{className:"text-xl font-semibold text-white",children:"Repos"}),(0,r.jsx)("div",{className:"rounded-xl border border-red-500/20 bg-red-500/[0.06] p-4",children:(0,r.jsxs)("p",{className:"text-sm text-red-400",children:["Failed to load repos: ",s]})})]}):(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-xl font-semibold text-white",children:"Repos"}),(0,r.jsxs)("p",{className:"mt-1 text-sm text-gray-400",children:[e.length," registered repo",1!==e.length?"s":""]})]}),(0,r.jsxs)("button",{onClick:()=>m(!0),className:"inline-flex items-center gap-2 rounded-lg bg-primary-500 px-4 py-2 text-sm font-semibold text-white transition-colors hover:bg-primary-600",children:[(0,r.jsx)("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})}),"Add Repo"]})]}),0===e.length?(0,r.jsx)(u.p,{title:"No repos registered",description:"Register a repo directory to manage its rules, sessions, and history.",action:{label:"Add Repo",onClick:()=>m(!0)}}):(0,r.jsx)("div",{className:"space-y-2",children:e.map(e=>(0,r.jsx)(p,{repo:e,onDelete:e=>void l(e),onSetDefault:e=>void o(e)},e.id))}),e.length>0&&(0,r.jsx)(y,{}),(0,r.jsxs)("div",{className:"rounded-xl border border-white/[0.06] bg-surface-900 p-4",children:[(0,r.jsx)("h3",{className:"mb-3 text-sm font-semibold text-white",children:"CLI Reference"}),(0,r.jsxs)("div",{className:"space-y-1.5 font-mono text-xs text-gray-500",children:[(0,r.jsxs)("p",{children:[(0,r.jsx)("code",{className:"rounded bg-surface-800 px-1.5 py-0.5 text-gray-400",children:"ulpi repos list"}),(0,r.jsx)("span",{className:"ml-2 font-sans text-gray-600",children:"-- List all registered repos"})]}),(0,r.jsxs)("p",{children:[(0,r.jsx)("code",{className:"rounded bg-surface-800 px-1.5 py-0.5 text-gray-400",children:"ulpi repos add /path"}),(0,r.jsx)("span",{className:"ml-2 font-sans text-gray-600",children:"-- Register a repo"})]}),(0,r.jsxs)("p",{children:[(0,r.jsx)("code",{className:"rounded bg-surface-800 px-1.5 py-0.5 text-gray-400",children:"ulpi init"}),(0,r.jsx)("span",{className:"ml-2 font-sans text-gray-600",children:"-- Detect stack and install hooks"})]})]})]}),(0,r.jsx)(x.a,{open:c,onClose:()=>m(!1),title:"Add Repo",description:"Register a local repo directory to manage with ULPI.",children:(0,r.jsx)(f,{onAdd:i,onClose:()=>m(!1)})})]})}function y(){var e,t;let s=(0,n.yC)(),{status:i}=(0,o.$)(),{status:l}=(0,c.XB)(),[d,u]=(0,a.useState)(null),[x,m]=(0,a.useState)(null),h=[{name:"CodeMap",initialized:null!=(e=null==i?void 0:i.initialized)&&e,initFn:()=>s.post("/api/codemap/action",{action:"init"})},{name:"Memory",initialized:null!=(t=null==l?void 0:l.initialized)&&t,initFn:()=>s.post("/api/memory/action",{action:"init"})},{name:"History",initialized:!0,initFn:()=>s.post("/api/history/init")}];return(0,r.jsxs)("div",{className:"rounded-xl border border-white/[0.06] bg-surface-900 p-4",children:[(0,r.jsx)("h3",{className:"mb-3 text-sm font-semibold text-white",children:"Subsystem Status"}),x&&(0,r.jsx)("div",{className:"mb-3 rounded-lg border border-blue-500/20 bg-blue-500/[0.06] px-3 py-2 text-xs text-blue-400",children:x}),(0,r.jsx)("div",{className:"space-y-2",children:h.map(e=>(0,r.jsxs)("div",{className:"flex items-center justify-between rounded-lg border border-white/[0.04] bg-surface-800/50 px-3 py-2.5",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,r.jsx)("span",{className:"h-2 w-2 rounded-full ".concat(e.initialized?"bg-emerald-400":"bg-gray-500")}),(0,r.jsx)("span",{className:"text-sm text-gray-300",children:e.name})]}),e.initialized?(0,r.jsx)("span",{className:"text-[11px] font-medium text-emerald-400",children:"Ready"}):(0,r.jsxs)("button",{onClick:()=>{u(e.name),m(null),e.initFn().then(()=>{m("".concat(e.name," initialized.")),u(null)}).catch(t=>{m(t instanceof Error?t.message:"".concat(e.name," init failed")),u(null)})},disabled:null!==d,className:"inline-flex items-center gap-1.5 rounded-lg bg-primary-500 px-3 py-1.5 text-[11px] font-semibold text-white transition-colors hover:bg-primary-600 disabled:cursor-not-allowed disabled:opacity-50",children:[d===e.name&&(0,r.jsx)("span",{className:"h-3 w-3 animate-spin rounded-full border-2 border-white border-t-transparent"}),"Initialize"]})]},e.name))})]})}function b(e){let{repo:t}=e;return(0,r.jsxs)(h(),{href:"/repos/".concat(t.id),className:"group flex items-center justify-between rounded-xl border border-white/[0.06] bg-surface-900 p-4 transition-colors hover:bg-surface-850",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,r.jsx)("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-surface-800",children:(0,r.jsx)("svg",{className:"h-4 w-4 text-gray-500",viewBox:"0 0 24 24",fill:"currentColor",children:(0,r.jsx)("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12Z"})})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-gray-200 truncate group-hover:text-white transition-colors",children:t.full_name}),(0,r.jsxs)("div",{className:"mt-0.5 flex items-center gap-2",children:[(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs ".concat(t.active?"text-emerald-400":"text-gray-500"),children:[(0,r.jsx)("span",{className:"h-1.5 w-1.5 rounded-full ".concat(t.active?"bg-emerald-400":"bg-gray-600")}),t.active?"Active":"Inactive"]}),t.config.auto_review&&(0,r.jsx)("span",{className:"rounded-full bg-surface-800 px-1.5 py-0.5 text-[10px] text-gray-500",children:"Review"}),t.config.auto_run_on_pr&&(0,r.jsx)("span",{className:"rounded-full bg-surface-800 px-1.5 py-0.5 text-[10px] text-gray-500",children:"Auto-run"})]})]})]}),(0,r.jsx)("svg",{className:"h-4 w-4 shrink-0 text-gray-700 transition-colors group-hover:text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m8.25 4.5 7.5 7.5-7.5 7.5"})})]})}function j(e){let{repo:t,installationId:s,orgId:n,onActivated:i}=e,[o,c]=(0,a.useState)(!1);async function d(){c(!0);try{await l.uE.connectRepo(n,{github_installation_id:s,github_repo_id:t.github_repo_id,full_name:t.full_name}),i()}catch(e){c(!1)}}return(0,r.jsxs)("div",{className:"flex items-center justify-between py-3 border-b border-white/[0.04] last:border-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,r.jsx)("svg",{className:"h-4 w-4 shrink-0 text-gray-600",viewBox:"0 0 24 24",fill:"currentColor",children:(0,r.jsx)("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12Z"})}),(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("p",{className:"text-sm text-gray-200 truncate",children:t.full_name}),(0,r.jsxs)("div",{className:"flex items-center gap-2 mt-0.5",children:[t.private&&(0,r.jsx)("span",{className:"text-[10px] text-gray-600",children:"Private"}),t.language&&(0,r.jsx)("span",{className:"text-[10px] text-gray-600",children:t.language})]})]})]}),t.activated?(0,r.jsx)("span",{className:"text-xs text-emerald-400",children:"Connected"}):(0,r.jsx)("button",{onClick:()=>void d(),disabled:o,className:"rounded-lg bg-primary-500 px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-primary-600 disabled:opacity-50",children:o?"Connecting...":"Connect"})]})}function v(e){let{orgId:t,installations:s,onDone:n}=e,[i,o]=(0,a.useState)(s[0]),[c,d]=(0,a.useState)([]),[u,x]=(0,a.useState)(!1),[m,h]=(0,a.useState)(null),p=(0,a.useCallback)(async()=>{if(i){x(!0),h(null);try{let e=await l.uE.listAvailableRepos(t,i.github_installation_id);d(e.repos)}catch(e){h("Failed to load repositories from GitHub.")}finally{x(!1)}}},[t,i]);return(0,a.useEffect)(()=>{p()},[p]),(0,r.jsxs)("div",{className:"rounded-xl border border-white/[0.06] bg-surface-900 p-5",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-white",children:"Select Repositories"}),(0,r.jsx)("p",{className:"text-xs text-gray-500 mt-0.5",children:"Choose repositories to connect from your GitHub installation."})]}),(0,r.jsx)("button",{onClick:n,className:"text-xs text-gray-500 hover:text-gray-300 transition-colors",children:"Done"})]}),s.length>1&&(0,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsx)("label",{className:"text-xs text-gray-500 mb-1.5 block",children:"Installation"}),(0,r.jsx)("select",{value:i.id,onChange:e=>{let t=s.find(t=>t.id===e.target.value);t&&o(t)},className:"w-full rounded-lg border border-white/[0.08] bg-surface-800 px-3 py-2 text-sm text-gray-200",children:s.map(e=>(0,r.jsxs)("option",{value:e.id,children:[e.github_account_login," (",e.github_account_type,")"]},e.id))})]}),u?(0,r.jsx)("div",{className:"space-y-3 py-4",children:Array.from({length:4}).map((e,t)=>(0,r.jsx)("div",{className:"h-10 animate-pulse rounded bg-surface-800"},t))}):m?(0,r.jsxs)("div",{className:"py-8 text-center",children:[(0,r.jsx)("p",{className:"text-sm text-red-400",children:m}),(0,r.jsx)("button",{onClick:()=>void p(),className:"mt-2 text-xs text-primary-400 hover:text-primary-300",children:"Try again"})]}):0===c.length?(0,r.jsxs)("div",{className:"py-8 text-center",children:[(0,r.jsx)("p",{className:"text-sm text-gray-400",children:"No repositories found."}),(0,r.jsx)("p",{className:"text-xs text-gray-600 mt-1",children:"Adjust the repository access in your GitHub App settings."})]}):(0,r.jsx)("div",{children:c.map(e=>(0,r.jsx)(j,{repo:e,installationId:i.github_installation_id,orgId:t,onActivated:()=>{d(t=>t.map(t=>t.github_repo_id===e.github_repo_id?{...t,activated:!0}:t))}},e.github_repo_id))})]})}function N(){let{org:e}=(0,i.As)(),[t,s]=(0,a.useState)([]),[n,o]=(0,a.useState)([]),[c,d]=(0,a.useState)(!0),[u,x]=(0,a.useState)(!1),m=(0,a.useCallback)(async()=>{if(e)try{let[t,r]=await Promise.all([l.uE.listRepos(e.id),l.uE.listInstallations(e.id)]);s(t),o(r)}catch(e){}finally{d(!1)}},[e]);async function h(){if(e)if(n.length>0)x(!0);else try{let{url:t}=await l.uE.getInstallUrl(e.id);window.location.href=t}catch(e){}}return(0,a.useEffect)(()=>{m()},[m]),(0,r.jsxs)("div",{className:"space-y-6 animate-in",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-xl font-semibold text-white",children:"Repositories"}),(0,r.jsx)("p",{className:"mt-0.5 text-sm text-gray-500",children:"Manage your connected GitHub repositories."})]}),(0,r.jsxs)("button",{onClick:()=>void h(),className:"inline-flex items-center gap-2 rounded-lg bg-primary-500 px-3.5 py-2 text-sm font-medium text-white transition-colors hover:bg-primary-600",children:[(0,r.jsx)("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})}),"Connect"]})]}),u&&e&&n.length>0&&(0,r.jsx)(v,{orgId:e.id,installations:n,onDone:function(){x(!1),m()}}),c?(0,r.jsx)("div",{className:"space-y-2",children:Array.from({length:3}).map((e,t)=>(0,r.jsx)("div",{className:"h-[68px] animate-pulse rounded-xl border border-white/[0.04] bg-surface-900"},t))}):0!==t.length||u?t.length>0?(0,r.jsx)("div",{className:"space-y-2",children:t.map(e=>(0,r.jsx)(b,{repo:e},e.id))}):null:(0,r.jsxs)("div",{className:"rounded-xl border border-dashed border-white/[0.08] bg-surface-900/50 py-16 text-center",children:[(0,r.jsx)("svg",{className:"mx-auto h-10 w-10 text-gray-700",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M20.25 6.375c0 2.278-3.694 4.125-8.25 4.125S3.75 8.653 3.75 6.375m16.5 0c0-2.278-3.694-4.125-8.25-4.125S3.75 4.097 3.75 6.375m16.5 0v11.25c0 2.278-3.694 4.125-8.25 4.125s-8.25-1.847-8.25-4.125V6.375"})}),(0,r.jsx)("h3",{className:"mt-3 text-sm font-medium text-gray-300",children:"No repositories connected"}),(0,r.jsx)("p",{className:"mt-1.5 text-xs text-gray-500 max-w-xs mx-auto",children:n.length>0?"Click Connect to choose repositories from your GitHub installation.":"Install the ULPI GitHub App first, then connect repositories."}),(0,r.jsx)("div",{className:"mt-5",children:(0,r.jsx)("button",{onClick:()=>void h(),className:"inline-flex items-center gap-2 rounded-lg bg-primary-500 px-3.5 py-2 text-sm font-medium text-white transition-colors hover:bg-primary-600",children:n.length>0?"Connect Repository":"Install GitHub App"})})]})]})}function w(){return"cloud"===(0,n.Xk)()?(0,r.jsx)(N,{}):(0,r.jsx)(g,{})}},3446:(e,t,s)=>{"use strict";s.d(t,{Kv:()=>c,HI:()=>x,Xk:()=>d,yC:()=>u});var r=s(8111),a=s(5271),n=s(422),i=s(7811);class l{async request(e,t){let s="".concat(this.baseUrl).concat(e);if(this.repo){let e=s.includes("?")?"&":"?";s="".concat(s).concat(e,"repo=").concat(encodeURIComponent(this.repo))}let r=i.env.NEXT_PUBLIC_ULPI_API_SECRET,a=await fetch(s,{...t,headers:{"Content-Type":"application/json",...r?{"X-Ulpi-Secret":r}:{},...null==t?void 0:t.headers}});if(!a.ok)throw Error((await a.json().catch(()=>({error:a.statusText}))).error||"API error: ".concat(a.status));return a.json()}async get(e){return this.request(e)}async post(e,t){return this.request(e,{method:"POST",body:t?JSON.stringify(t):void 0})}async put(e,t){return this.request(e,{method:"PUT",body:t?JSON.stringify(t):void 0})}async delete(e){return this.request(e,{method:"DELETE"})}constructor(){this.repo=null,this.baseUrl=(0,n.h)()}}let o=(0,a.createContext)({mode:"cloud",localClient:null});function c(e){let{children:t}=e,s=(0,a.useMemo)(()=>{let e=(0,n.J)()?"local":"cloud";return{mode:e,localClient:"local"===e?new l:null}},[]);return(0,r.jsx)(o,{value:s,children:t})}function d(){return(0,a.useContext)(o).mode}function u(){let{localClient:e}=(0,a.useContext)(o);if(!e)throw Error("LocalApiClient not available in cloud mode");return e}function x(){return(0,a.useContext)(o)}},3951:(e,t,s)=>{"use strict";s.d(t,{G:()=>a});var r=s(8111);function a(e){let{rows:t=3,variant:s="skeleton",className:a=""}=e;return"spinner"===s?(0,r.jsx)("div",{className:"flex items-center justify-center py-16 ".concat(a),children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,r.jsx)("div",{className:"h-7 w-7 animate-spin rounded-full border-2 border-primary-500 border-t-transparent"}),(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"Loading..."})]})}):(0,r.jsx)("div",{className:"space-y-3 ".concat(a),children:Array.from({length:t}).map((e,t)=>(0,r.jsx)("div",{className:"animate-pulse rounded-xl border border-white/[0.04] bg-surface-800/50 p-4",children:(0,r.jsxs)("div",{className:"flex items-center gap-4",children:[(0,r.jsx)("div",{className:"h-8 w-8 rounded-lg bg-white/[0.06]"}),(0,r.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,r.jsx)("div",{className:"h-3.5 w-1/3 rounded bg-white/[0.06]"}),(0,r.jsx)("div",{className:"h-3 w-2/3 rounded bg-white/[0.04]"})]}),(0,r.jsx)("div",{className:"h-5 w-16 rounded-full bg-white/[0.04]"})]})},t))})}},4632:(e,t,s)=>{"use strict";s.d(t,{p:()=>n});var r=s(8111);function a(){return(0,r.jsx)("svg",{className:"h-10 w-10 text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M20.25 7.5l-.625 10.632a2.25 2.25 0 0 1-2.247 2.118H6.622a2.25 2.25 0 0 1-2.247-2.118L3.75 7.5m6 4.125 2.25 2.25m0 0 2.25 2.25M12 13.875l2.25-2.25M12 13.875l-2.25 2.25M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125Z"})})}function n(e){let{icon:t,title:s,description:n,action:i,className:l=""}=e;return(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center rounded-2xl border border-dashed border-white/[0.06] bg-surface-800/30 px-6 py-16 text-center ".concat(l),children:[(0,r.jsx)("div",{className:"mb-4",children:null!=t?t:(0,r.jsx)(a,{})}),(0,r.jsx)("h3",{className:"text-sm font-medium text-gray-300",children:s}),n&&(0,r.jsx)("p",{className:"mt-1.5 max-w-sm text-xs text-gray-500",children:n}),i&&(0,r.jsx)("button",{onClick:i.onClick,className:"mt-5 rounded-lg bg-primary-500 px-4 py-2 text-xs font-semibold text-white transition-colors hover:bg-primary-600",children:i.label})]})}},6028:(e,t,s)=>{"use strict";s.d(t,{a:()=>n});var r=s(8111),a=s(5271);function n(e){let{open:t,onClose:s,title:n,description:i,children:l,maxWidth:o="max-w-lg"}=e,c=(0,a.useRef)(null),d=(0,a.useCallback)(e=>{"Escape"===e.key&&s()},[s]);return((0,a.useEffect)(()=>{if(t)return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[t,d]),(0,a.useEffect)(()=>(t?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[t]),t)?(0,r.jsxs)("div",{className:"fixed inset-0 z-50 flex items-center justify-center px-4",children:[(0,r.jsx)("div",{ref:c,className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:s}),(0,r.jsxs)("div",{className:"relative z-10 w-full ".concat(o," animate-in rounded-2xl border border-white/[0.08] bg-surface-900 shadow-2xl"),children:[(0,r.jsxs)("div",{className:"flex items-start justify-between border-b border-white/[0.06] px-6 py-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"text-base font-semibold text-white",children:n}),i&&(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-400",children:i})]}),(0,r.jsx)("button",{onClick:s,className:"ml-4 rounded-lg p-1.5 text-gray-500 transition-colors hover:bg-white/[0.06] hover:text-gray-300",children:(0,r.jsx)("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18 18 6M6 6l12 12"})})})]}),(0,r.jsx)("div",{className:"px-6 py-4",children:l})]})]}):null}},6199:(e,t,s)=>{Promise.resolve().then(s.bind(s,1208))},8984:(e,t,s)=>{"use strict";s.d(t,{XB:()=>n,nu:()=>i,wC:()=>l});var r=s(5271),a=s(3446);function n(){let e=(0,a.yC)(),[t,s]=(0,r.useState)(null),[n,i]=(0,r.useState)(!0),[l,o]=(0,r.useState)(null),c=(0,r.useRef)(null),d=(0,r.useCallback)(async()=>{o(null);try{let t=await e.get("/api/memory/status");return s(t),t}catch(e){return o(e instanceof Error?e.message:"Failed to fetch memory status"),null}finally{i(!1)}},[e]);(0,r.useEffect)(()=>{let e=!1;async function t(){var s;if(e)return;let r=await d();e||(c.current=setTimeout(()=>void t(),null!=(s=null==r?void 0:r.pollIntervalMs)?s:3e4))}return i(!0),t(),()=>{e=!0,c.current&&clearTimeout(c.current)}},[d]);let u=(0,r.useCallback)(async t=>{await e.put("/api/memory/config",{enabled:t}),await d()},[e,d]);return{status:t,loading:n,error:l,refresh:d,toggleEnabled:u}}function i(){let e=(0,a.yC)(),[t,s]=(0,r.useState)([]),[n,i]=(0,r.useState)(!1);return{results:t,searching:n,search:(0,r.useCallback)(async t=>{i(!0);try{var r;let a=(null!=(r=(await e.post("/api/memory/search",{query:t})).results)?r:[]).map(e=>e.entry);return s(a),a}catch(e){return s([]),[]}finally{i(!1)}},[e])}}function l(){let e=(0,a.yC)(),t=(0,r.useCallback)(async(t,s)=>e.post("/api/memory/remember",{summary:t,type:null!=s?s:"CONTEXT"}),[e]),s=(0,r.useCallback)(async t=>e.get("/api/memory/timeline".concat(t?"?limit=".concat(t):"")),[e]);return{remember:t,getTimeline:s,forget:(0,r.useCallback)(async t=>e.post("/api/memory/entries/".concat(t,"/forget")),[e]),runAction:(0,r.useCallback)(async t=>e.post("/api/memory/action",{action:t}),[e])}}}},e=>{e.O(0,[5935,8934,814,9743,7358],()=>e(e.s=6199)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5602],{422:(e,t,r)=>{"use strict";function s(){{let e=window.location.hostname;return"localhost"===e||"127.0.0.1"===e}}function n(){return s(),"http://localhost:9800"}r.d(t,{J:()=>s,h:()=>n})},3446:(e,t,r)=>{"use strict";r.d(t,{Kv:()=>c,HI:()=>h,Xk:()=>d,yC:()=>u});var s=r(8111),n=r(5271),i=r(422),a=r(7811);class l{async request(e,t){let r="".concat(this.baseUrl).concat(e);if(this.repo){let e=r.includes("?")?"&":"?";r="".concat(r).concat(e,"repo=").concat(encodeURIComponent(this.repo))}let s=a.env.NEXT_PUBLIC_ULPI_API_SECRET,n=await fetch(r,{...t,headers:{"Content-Type":"application/json",...s?{"X-Ulpi-Secret":s}:{},...null==t?void 0:t.headers}});if(!n.ok)throw Error((await n.json().catch(()=>({error:n.statusText}))).error||"API error: ".concat(n.status));return n.json()}async get(e){return this.request(e)}async post(e,t){return this.request(e,{method:"POST",body:t?JSON.stringify(t):void 0})}async put(e,t){return this.request(e,{method:"PUT",body:t?JSON.stringify(t):void 0})}async delete(e){return this.request(e,{method:"DELETE"})}constructor(){this.repo=null,this.baseUrl=(0,i.h)()}}let o=(0,n.createContext)({mode:"cloud",localClient:null});function c(e){let{children:t}=e,r=(0,n.useMemo)(()=>{let e=(0,i.J)()?"local":"cloud";return{mode:e,localClient:"local"===e?new l:null}},[]);return(0,s.jsx)(o,{value:r,children:t})}function d(){return(0,n.useContext)(o).mode}function u(){let{localClient:e}=(0,n.useContext)(o);if(!e)throw Error("LocalApiClient not available in cloud mode");return e}function h(){return(0,n.useContext)(o)}},3951:(e,t,r)=>{"use strict";r.d(t,{G:()=>n});var s=r(8111);function n(e){let{rows:t=3,variant:r="skeleton",className:n=""}=e;return"spinner"===r?(0,s.jsx)("div",{className:"flex items-center justify-center py-16 ".concat(n),children:(0,s.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,s.jsx)("div",{className:"h-7 w-7 animate-spin rounded-full border-2 border-primary-500 border-t-transparent"}),(0,s.jsx)("p",{className:"text-xs text-gray-500",children:"Loading..."})]})}):(0,s.jsx)("div",{className:"space-y-3 ".concat(n),children:Array.from({length:t}).map((e,t)=>(0,s.jsx)("div",{className:"animate-pulse rounded-xl border border-white/[0.04] bg-surface-800/50 p-4",children:(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)("div",{className:"h-8 w-8 rounded-lg bg-white/[0.06]"}),(0,s.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,s.jsx)("div",{className:"h-3.5 w-1/3 rounded bg-white/[0.06]"}),(0,s.jsx)("div",{className:"h-3 w-2/3 rounded bg-white/[0.04]"})]}),(0,s.jsx)("div",{className:"h-5 w-16 rounded-full bg-white/[0.04]"})]})},t))})}},5708:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>c});var s=r(8111),n=r(5271),i=r(3446),a=r(3951);function l(e){let{checked:t,onChange:r}=e;return(0,s.jsx)("button",{type:"button",role:"switch","aria-checked":t,onClick:()=>r(!t),className:"relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out ".concat(t?"bg-primary-500":"bg-surface-700"),children:(0,s.jsx)("span",{className:"pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow transform transition duration-200 ease-in-out ".concat(t?"translate-x-5":"translate-x-0")})})}function o(e){let{label:t,description:r,children:n}=e;return(0,s.jsxs)("div",{className:"flex items-center justify-between rounded-xl border border-white/[0.06] bg-surface-900 p-4",children:[(0,s.jsxs)("div",{className:"pr-4",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-white",children:t}),(0,s.jsx)("p",{className:"mt-0.5 text-xs text-gray-500",children:r})]}),(0,s.jsx)("div",{className:"shrink-0",children:n})]})}function c(){let e=(0,i.yC)(),[t,r]=(0,n.useState)(null),[c,d]=(0,n.useState)(!0),[u,h]=(0,n.useState)(!1),[x,p]=(0,n.useState)(!1),[m,v]=(0,n.useState)(null);async function f(){if(t){h(!0),v(null);try{await e.put("/api/review/config",t),p(!0),setTimeout(()=>p(!1),2e3)}catch(e){v(e instanceof Error?e.message:"Failed to save config")}finally{h(!1)}}}return((0,n.useEffect)(()=>{e.get("/api/review/config").then(r).catch(()=>{r({enabled:!0,plan_review:!0,code_review:!0,auto_open_browser:!0,require_server:!1})}).finally(()=>d(!1))},[e]),c)?(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsx)("h1",{className:"text-xl font-semibold text-white",children:"Review Settings"}),(0,s.jsx)(a.G,{rows:4})]}):(0,s.jsxs)("div",{className:"space-y-6 max-w-3xl",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("h1",{className:"text-xl font-semibold text-white flex items-center gap-2",children:[(0,s.jsxs)("svg",{className:"h-5 w-5 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:[(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.325.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 0 1 1.37.49l1.296 2.247a1.125 1.125 0 0 1-.26 1.431l-1.003.827c-.293.241-.438.613-.43.992a7.723 7.723 0 0 1 0 .255c-.008.378.137.75.43.991l1.004.827c.424.35.534.955.26 1.43l-1.298 2.247a1.125 1.125 0 0 1-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.47 6.47 0 0 1-.22.128c-.331.183-.581.495-.644.869l-.213 1.281c-.09.543-.56.94-1.11.94h-2.594c-.55 0-1.019-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 0 1-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 0 1-1.369-.49l-1.297-2.247a1.125 1.125 0 0 1 .26-1.431l1.004-.827c.292-.24.437-.613.43-.991a6.932 6.932 0 0 1 0-.255c.007-.38-.138-.751-.43-.992l-1.004-.827a1.125 1.125 0 0 1-.26-1.43l1.297-2.247a1.125 1.125 0 0 1 1.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.086.22-.128.332-.183.582-.495.644-.869l.214-1.28Z"}),(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"})]}),"Review Settings"]}),(0,s.jsx)("p",{className:"mt-1 text-sm text-gray-400",children:"Configure plan and code review behavior"})]}),(0,s.jsxs)("button",{onClick:()=>void f(),disabled:u||!t,className:"flex items-center gap-2 rounded-lg bg-primary-500 px-4 py-2 text-sm font-semibold text-white transition-colors hover:bg-primary-600 disabled:opacity-50",children:[(0,s.jsx)("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17.593 3.322c1.1.128 1.907 1.077 1.907 2.185V21L12 17.25 4.5 21V5.507c0-1.108.806-2.057 1.907-2.185a48.507 48.507 0 0 1 11.186 0Z"})}),x?"Saved!":u?"Saving...":"Save"]})]}),m&&(0,s.jsx)("div",{className:"rounded-xl border border-red-500/20 bg-red-500/[0.06] px-4 py-3 text-sm text-red-400",children:m}),t&&(0,s.jsx)("div",{className:"space-y-3",children:[{key:"enabled",label:"Review Enabled",description:"Enable review interception for plan and code changes"},{key:"plan_review",label:"Plan Review",description:"Review plans when ExitPlanMode is triggered"},{key:"code_review",label:"Code Review",description:"Review code diffs before git commits"},{key:"auto_open_browser",label:"Auto-open Browser",description:"Automatically open the review UI in your browser"},{key:"require_server",label:"Require Server",description:"Require a running ULPI server before starting review (fail-closed mode)"}].map(e=>{let{key:n,label:i,description:a}=e;return(0,s.jsx)(o,{label:i,description:a,children:(0,s.jsx)(l,{checked:!!t[n],onChange:()=>{t&&r({...t,[n]:!t[n]})}})},n)})})]})}},6967:(e,t,r)=>{Promise.resolve().then(r.bind(r,5708))}},e=>{e.O(0,[814,9743,7358],()=>e(e.s=6967)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8459],{422:(e,t,r)=>{"use strict";function s(){{let e=window.location.hostname;return"localhost"===e||"127.0.0.1"===e}}function a(){return s(),"http://localhost:9800"}r.d(t,{J:()=>s,h:()=>a})},3446:(e,t,r)=>{"use strict";r.d(t,{Kv:()=>c,HI:()=>x,Xk:()=>o,yC:()=>u});var s=r(8111),a=r(5271),n=r(422),l=r(7811);class d{async request(e,t){let r="".concat(this.baseUrl).concat(e);if(this.repo){let e=r.includes("?")?"&":"?";r="".concat(r).concat(e,"repo=").concat(encodeURIComponent(this.repo))}let s=l.env.NEXT_PUBLIC_ULPI_API_SECRET,a=await fetch(r,{...t,headers:{"Content-Type":"application/json",...s?{"X-Ulpi-Secret":s}:{},...null==t?void 0:t.headers}});if(!a.ok)throw Error((await a.json().catch(()=>({error:a.statusText}))).error||"API error: ".concat(a.status));return a.json()}async get(e){return this.request(e)}async post(e,t){return this.request(e,{method:"POST",body:t?JSON.stringify(t):void 0})}async put(e,t){return this.request(e,{method:"PUT",body:t?JSON.stringify(t):void 0})}async delete(e){return this.request(e,{method:"DELETE"})}constructor(){this.repo=null,this.baseUrl=(0,n.h)()}}let i=(0,a.createContext)({mode:"cloud",localClient:null});function c(e){let{children:t}=e,r=(0,a.useMemo)(()=>{let e=(0,n.J)()?"local":"cloud";return{mode:e,localClient:"local"===e?new d:null}},[]);return(0,s.jsx)(i,{value:r,children:t})}function o(){return(0,a.useContext)(i).mode}function u(){let{localClient:e}=(0,a.useContext)(i);if(!e)throw Error("LocalApiClient not available in cloud mode");return e}function x(){return(0,a.useContext)(i)}},3604:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>p});var s=r(8111),a=r(5271),n=r(4736),l=r(3446),d=r(422),i=r(5605),c=r(3951),o=r(4632),u=r(7811);function x(e){return"session"===e.kind?e.data.registeredAt:new Date(e.data.updatedAt).getTime()}function m(e){let{type:t}=e;return"plan"===t?(0,s.jsx)("span",{className:"rounded-full bg-primary-500/10 px-2 py-0.5 text-[10px] font-medium text-primary-400",children:"Plan"}):(0,s.jsx)("span",{className:"rounded-full bg-emerald-500/10 px-2 py-0.5 text-[10px] font-medium text-emerald-400",children:"Code"})}function p(){let e=(0,n.useRouter)(),t=(0,l.yC)(),[r,p]=(0,a.useState)([]),[h,g]=(0,a.useState)([]),[b,f]=(0,a.useState)(!0),[v,y]=(0,a.useState)(null),[j,w]=(0,a.useState)("all"),[,N]=(0,a.useState)(0);(0,a.useEffect)(()=>{let e=setInterval(()=>N(e=>e+1),3e4);return()=>clearInterval(e)},[]);let C=(0,a.useCallback)(async()=>{try{let[e,r]=await Promise.all([t.get("/api/review/hub/sessions").then(e=>Array.isArray(e)?e:[]).catch(()=>[]),t.get("/api/review/plans").then(e=>Array.isArray(e)?e:[]).catch(()=>[])]);p(e),g(r),y(null)}catch(e){y(e instanceof Error?e.message:"Failed to load review data")}finally{f(!1)}},[t]);(0,a.useEffect)(()=>{C()},[C]);let k=(0,a.useRef)(null);(0,a.useEffect)(()=>{let e=null;return!function t(){try{let r=(0,d.h)(),s=u.env.NEXT_PUBLIC_ULPI_API_SECRET,a=s?"".concat(r,"/api/review/hub/events?secret=").concat(encodeURIComponent(s)):"".concat(r,"/api/review/hub/events");k.current=new EventSource(a);let n=()=>void C();k.current.addEventListener("session-added",n),k.current.addEventListener("session-decided",n),k.current.addEventListener("session-updated",n),k.current.onerror=()=>{var r;null==(r=k.current)||r.close(),k.current=null,e=setTimeout(t,3e3)}}catch(e){}}(),()=>{var t;null==(t=k.current)||t.close(),k.current=null,e&&clearTimeout(e)}},[C]);let P=[...r.map(e=>({kind:"session",data:e})),...h.map(e=>({kind:"plan",data:e}))].sort((e,t)=>x(t)-x(e)),E=P.filter(e=>(function(e,t){switch(t){case"all":return!0;case"pending":if("session"===e.kind)return"pending"===e.data.status||"active"===e.data.status;return"pending"===e.data.status;case"code":return"session"===e.kind&&"code"===e.data.type;case"decided":if("session"===e.kind)return"decided"===e.data.status;return"approved"===e.data.status||"denied"===e.data.status}})(e,j)),S=r.filter(e=>"pending"===e.status||"active"===e.status).length,_=h.length,L=r.filter(e=>"decided"===e.status).length;return b?(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsx)("h1",{className:"text-xl font-semibold text-white",children:"Review Queue"}),(0,s.jsx)(c.G,{rows:4})]}):(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"text-xl font-semibold text-white",children:"Review Queue"}),(0,s.jsx)("p",{className:"mt-1 text-sm text-gray-400",children:"Pending reviews and recent decisions"})]}),v&&(0,s.jsx)("div",{className:"rounded-xl border border-red-500/20 bg-red-500/[0.06] px-4 py-3 text-sm text-red-400",children:v}),(0,s.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,s.jsxs)("div",{className:"rounded-xl border border-white/[0.06] bg-surface-900 p-3 text-center",children:[(0,s.jsx)("p",{className:"text-lg font-semibold text-white",children:S}),(0,s.jsx)("p",{className:"text-[10px] text-gray-500",children:"Pending"})]}),(0,s.jsxs)("div",{className:"rounded-xl border border-white/[0.06] bg-surface-900 p-3 text-center",children:[(0,s.jsx)("p",{className:"text-lg font-semibold text-white",children:_}),(0,s.jsx)("p",{className:"text-[10px] text-gray-500",children:"Plans"})]}),(0,s.jsxs)("div",{className:"rounded-xl border border-white/[0.06] bg-surface-900 p-3 text-center",children:[(0,s.jsx)("p",{className:"text-lg font-semibold text-white",children:L}),(0,s.jsx)("p",{className:"text-[10px] text-gray-500",children:"Decided"})]})]}),(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5",children:[["all","All"],["pending","Pending"],["code","Code"],["decided","Decided"]].map(e=>{let[t,r]=e;return(0,s.jsx)("button",{onClick:()=>w(t),className:"rounded-full px-3 py-1 text-xs font-medium transition-colors ".concat(j===t?"bg-primary-500/15 text-primary-400":"bg-surface-800 text-gray-500 hover:text-gray-300"),children:r},t)})}),(0,s.jsx)("div",{className:"rounded-xl border border-white/[0.06] bg-surface-900 overflow-hidden",children:0===E.length?(0,s.jsx)(o.p,{title:0===P.length?"No reviews yet":"No entries match this filter",description:0===P.length?"Reviews will appear here when ULPI intercepts a plan exit or git commit.":"Try changing the filter to see more results."}):(0,s.jsx)("div",{className:"divide-y divide-white/[0.04]",children:E.map(t=>{let r="session"===t.kind?"session-".concat(t.data.id):"plan-".concat(t.data.slug),a="session"===t.kind?t.data.title||"Untitled review":t.data.title,n=x(t);return(0,s.jsxs)("button",{onClick:()=>(function(t){if("session"===t.kind){let r=t.data;e.push("/review/plan?session=".concat(encodeURIComponent(r.id)))}else e.push("/review/plan?slug=".concat(encodeURIComponent(t.data.slug)))})(t),className:"flex w-full items-start gap-3 px-4 py-3 text-left transition-colors hover:bg-white/[0.02]",children:[(0,s.jsx)("div",{className:"flex flex-col items-start gap-1.5 pt-0.5",children:"session"===t.kind?(0,s.jsx)(m,{type:t.data.type}):(0,s.jsx)(m,{type:"plan"})}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"truncate text-sm font-medium text-gray-200",children:a}),(0,s.jsxs)("div",{className:"mt-1 flex items-center gap-2",children:[(t.kind,(0,s.jsx)(i.W,{status:t.data.status,size:"sm"})),"session"===t.kind&&t.data.decision&&(0,s.jsx)(i.W,{status:"allow"===t.data.decision.behavior?"approved":"rejected",size:"sm"}),"session"===t.kind&&t.data.projectSlug&&(0,s.jsx)("span",{className:"truncate max-w-[120px] rounded bg-surface-800 px-1.5 py-0.5 font-mono text-[10px] text-gray-500",children:t.data.projectSlug}),"plan"===t.kind&&t.data.versionCount>1&&(0,s.jsxs)("span",{className:"text-[10px] text-gray-600",children:["v",t.data.versionCount]})]})]}),(0,s.jsxs)("div",{className:"shrink-0 text-right",children:[(0,s.jsx)("p",{className:"text-[10px] text-gray-600",children:new Date(n).toLocaleDateString(void 0,{month:"short",day:"numeric"})}),(0,s.jsx)("p",{className:"text-[10px] text-gray-600",children:function(e){let t=Math.floor((Date.now()-e)/1e3);if(t<60)return"just now";let r=Math.floor(t/60);if(r<60)return"".concat(r,"m ago");let s=Math.floor(r/60);if(s<24)return"".concat(s,"h ago");let a=Math.floor(s/24);return"".concat(a,"d ago")}(n)})]})]},r)})})})]})}},3951:(e,t,r)=>{"use strict";r.d(t,{G:()=>a});var s=r(8111);function a(e){let{rows:t=3,variant:r="skeleton",className:a=""}=e;return"spinner"===r?(0,s.jsx)("div",{className:"flex items-center justify-center py-16 ".concat(a),children:(0,s.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,s.jsx)("div",{className:"h-7 w-7 animate-spin rounded-full border-2 border-primary-500 border-t-transparent"}),(0,s.jsx)("p",{className:"text-xs text-gray-500",children:"Loading..."})]})}):(0,s.jsx)("div",{className:"space-y-3 ".concat(a),children:Array.from({length:t}).map((e,t)=>(0,s.jsx)("div",{className:"animate-pulse rounded-xl border border-white/[0.04] bg-surface-800/50 p-4",children:(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)("div",{className:"h-8 w-8 rounded-lg bg-white/[0.06]"}),(0,s.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,s.jsx)("div",{className:"h-3.5 w-1/3 rounded bg-white/[0.06]"}),(0,s.jsx)("div",{className:"h-3 w-2/3 rounded bg-white/[0.04]"})]}),(0,s.jsx)("div",{className:"h-5 w-16 rounded-full bg-white/[0.04]"})]})},t))})}},4632:(e,t,r)=>{"use strict";r.d(t,{p:()=>n});var s=r(8111);function a(){return(0,s.jsx)("svg",{className:"h-10 w-10 text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M20.25 7.5l-.625 10.632a2.25 2.25 0 0 1-2.247 2.118H6.622a2.25 2.25 0 0 1-2.247-2.118L3.75 7.5m6 4.125 2.25 2.25m0 0 2.25 2.25M12 13.875l2.25-2.25M12 13.875l-2.25 2.25M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125Z"})})}function n(e){let{icon:t,title:r,description:n,action:l,className:d=""}=e;return(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center rounded-2xl border border-dashed border-white/[0.06] bg-surface-800/30 px-6 py-16 text-center ".concat(d),children:[(0,s.jsx)("div",{className:"mb-4",children:null!=t?t:(0,s.jsx)(a,{})}),(0,s.jsx)("h3",{className:"text-sm font-medium text-gray-300",children:r}),n&&(0,s.jsx)("p",{className:"mt-1.5 max-w-sm text-xs text-gray-500",children:n}),l&&(0,s.jsx)("button",{onClick:l.onClick,className:"mt-5 rounded-lg bg-primary-500 px-4 py-2 text-xs font-semibold text-white transition-colors hover:bg-primary-600",children:l.label})]})}},4736:(e,t,r)=>{"use strict";var s=r(1504);r.o(s,"useParams")&&r.d(t,{useParams:function(){return s.useParams}}),r.o(s,"usePathname")&&r.d(t,{usePathname:function(){return s.usePathname}}),r.o(s,"useRouter")&&r.d(t,{useRouter:function(){return s.useRouter}}),r.o(s,"useSearchParams")&&r.d(t,{useSearchParams:function(){return s.useSearchParams}})},5605:(e,t,r)=>{"use strict";r.d(t,{W:()=>l});var s=r(8111);let a={pending:"bg-yellow-500/10 text-yellow-400 border-yellow-500/20",queued:"bg-yellow-500/10 text-yellow-400 border-yellow-500/20",active:"bg-blue-500/10 text-blue-400 border-blue-500/20",running:"bg-blue-500/10 text-blue-400 border-blue-500/20",in_progress:"bg-blue-500/10 text-blue-400 border-blue-500/20",completed:"bg-emerald-500/10 text-emerald-400 border-emerald-500/20",success:"bg-emerald-500/10 text-emerald-400 border-emerald-500/20",approved:"bg-emerald-500/10 text-emerald-400 border-emerald-500/20",error:"bg-red-500/10 text-red-400 border-red-500/20",failed:"bg-red-500/10 text-red-400 border-red-500/20",rejected:"bg-red-500/10 text-red-400 border-red-500/20",cancelled:"bg-gray-500/10 text-gray-400 border-gray-500/20",idle:"bg-gray-500/10 text-gray-400 border-gray-500/20"},n={pending:"bg-yellow-400",queued:"bg-yellow-400",active:"bg-blue-400",running:"bg-blue-400",in_progress:"bg-blue-400",completed:"bg-emerald-400",success:"bg-emerald-400",approved:"bg-emerald-400",error:"bg-red-400",failed:"bg-red-400",rejected:"bg-red-400",cancelled:"bg-gray-400",idle:"bg-gray-400"};function l(e){var t,r;let{status:l,label:d,showDot:i=!0,size:c="sm",className:o=""}=e,u=l.toLowerCase().replace(/\s+/g,"_"),x=null!=(t=a[u])?t:"bg-gray-500/10 text-gray-400 border-gray-500/20",m=null!=(r=n[u])?r:"bg-gray-400",p=null!=d?d:l.charAt(0).toUpperCase()+l.slice(1).replace(/_/g," ");return(0,s.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-full border font-medium ".concat(x," ").concat("sm"===c?"px-2 py-0.5 text-[11px]":"px-2.5 py-1 text-xs"," ").concat(o),children:[i&&(0,s.jsx)("span",{className:"h-1.5 w-1.5 rounded-full ".concat(m)}),p]})}},6614:(e,t,r)=>{Promise.resolve().then(r.bind(r,3604))}},e=>{e.O(0,[814,9743,7358],()=>e(e.s=6614)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9558],{422:(e,t,s)=>{"use strict";function r(){{let e=window.location.hostname;return"localhost"===e||"127.0.0.1"===e}}function a(){return r(),"http://localhost:9800"}s.d(t,{J:()=>r,h:()=>a})},2757:(e,t,s)=>{Promise.resolve().then(s.bind(s,7970))},3025:(e,t,s)=>{"use strict";s.d(t,{s:()=>n});var r=s(8111),a=s(3446);function n(e){let{children:t,featureName:s="This feature"}=e;return"cloud"===(0,a.Xk)()?(0,r.jsx)("div",{className:"space-y-6",children:(0,r.jsxs)("div",{className:"rounded-xl border border-white/[0.06] bg-surface-900 p-8 text-center",children:[(0,r.jsx)("svg",{className:"mx-auto h-10 w-10 text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 17.25v1.007a3 3 0 0 1-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0 1 15 18.257V17.25m6-12V15a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 15V5.25m18 0A2.25 2.25 0 0 0 18.75 3H5.25A2.25 2.25 0 0 0 3 5.25m18 0V12a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 12V5.25"})}),(0,r.jsxs)("p",{className:"mt-3 text-sm text-gray-400",children:[s," is available in local mode."]}),(0,r.jsx)("p",{className:"mt-1 text-xs text-gray-600",children:"Connect to a local ULPI API server to use this feature."})]})}):(0,r.jsx)(r.Fragment,{children:t})}},3446:(e,t,s)=>{"use strict";s.d(t,{Kv:()=>c,HI:()=>u,Xk:()=>d,yC:()=>x});var r=s(8111),a=s(5271),n=s(422),l=s(7811);class i{async request(e,t){let s="".concat(this.baseUrl).concat(e);if(this.repo){let e=s.includes("?")?"&":"?";s="".concat(s).concat(e,"repo=").concat(encodeURIComponent(this.repo))}let r=l.env.NEXT_PUBLIC_ULPI_API_SECRET,a=await fetch(s,{...t,headers:{"Content-Type":"application/json",...r?{"X-Ulpi-Secret":r}:{},...null==t?void 0:t.headers}});if(!a.ok)throw Error((await a.json().catch(()=>({error:a.statusText}))).error||"API error: ".concat(a.status));return a.json()}async get(e){return this.request(e)}async post(e,t){return this.request(e,{method:"POST",body:t?JSON.stringify(t):void 0})}async put(e,t){return this.request(e,{method:"PUT",body:t?JSON.stringify(t):void 0})}async delete(e){return this.request(e,{method:"DELETE"})}constructor(){this.repo=null,this.baseUrl=(0,n.h)()}}let o=(0,a.createContext)({mode:"cloud",localClient:null});function c(e){let{children:t}=e,s=(0,a.useMemo)(()=>{let e=(0,n.J)()?"local":"cloud";return{mode:e,localClient:"local"===e?new i:null}},[]);return(0,r.jsx)(o,{value:s,children:t})}function d(){return(0,a.useContext)(o).mode}function x(){let{localClient:e}=(0,a.useContext)(o);if(!e)throw Error("LocalApiClient not available in cloud mode");return e}function u(){return(0,a.useContext)(o)}},3951:(e,t,s)=>{"use strict";s.d(t,{G:()=>a});var r=s(8111);function a(e){let{rows:t=3,variant:s="skeleton",className:a=""}=e;return"spinner"===s?(0,r.jsx)("div",{className:"flex items-center justify-center py-16 ".concat(a),children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,r.jsx)("div",{className:"h-7 w-7 animate-spin rounded-full border-2 border-primary-500 border-t-transparent"}),(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"Loading..."})]})}):(0,r.jsx)("div",{className:"space-y-3 ".concat(a),children:Array.from({length:t}).map((e,t)=>(0,r.jsx)("div",{className:"animate-pulse rounded-xl border border-white/[0.04] bg-surface-800/50 p-4",children:(0,r.jsxs)("div",{className:"flex items-center gap-4",children:[(0,r.jsx)("div",{className:"h-8 w-8 rounded-lg bg-white/[0.06]"}),(0,r.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,r.jsx)("div",{className:"h-3.5 w-1/3 rounded bg-white/[0.06]"}),(0,r.jsx)("div",{className:"h-3 w-2/3 rounded bg-white/[0.04]"})]}),(0,r.jsx)("div",{className:"h-5 w-16 rounded-full bg-white/[0.04]"})]})},t))})}},4632:(e,t,s)=>{"use strict";s.d(t,{p:()=>n});var r=s(8111);function a(){return(0,r.jsx)("svg",{className:"h-10 w-10 text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M20.25 7.5l-.625 10.632a2.25 2.25 0 0 1-2.247 2.118H6.622a2.25 2.25 0 0 1-2.247-2.118L3.75 7.5m6 4.125 2.25 2.25m0 0 2.25 2.25M12 13.875l2.25-2.25M12 13.875l-2.25 2.25M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125Z"})})}function n(e){let{icon:t,title:s,description:n,action:l,className:i=""}=e;return(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center rounded-2xl border border-dashed border-white/[0.06] bg-surface-800/30 px-6 py-16 text-center ".concat(i),children:[(0,r.jsx)("div",{className:"mb-4",children:null!=t?t:(0,r.jsx)(a,{})}),(0,r.jsx)("h3",{className:"text-sm font-medium text-gray-300",children:s}),n&&(0,r.jsx)("p",{className:"mt-1.5 max-w-sm text-xs text-gray-500",children:n}),l&&(0,r.jsx)("button",{onClick:l.onClick,className:"mt-5 rounded-lg bg-primary-500 px-4 py-2 text-xs font-semibold text-white transition-colors hover:bg-primary-600",children:l.label})]})}},4638:(e,t,s)=>{"use strict";s.d(t,{f:()=>n});var r=s(5271),a=s(3446);function n(){let e=(0,a.yC)(),[t,s]=(0,r.useState)({rules:[],loading:!0,error:null}),n=(0,r.useCallback)(async()=>{s(e=>({...e,loading:!0,error:null}));try{let t=await e.get("/api/rules"),r=Array.isArray(t)?t:[];s({rules:r,loading:!1,error:null})}catch(e){s(t=>({...t,loading:!1,error:e instanceof Error?e.message:"Failed to fetch rules"}))}},[e]);(0,r.useEffect)(()=>{n()},[n]);let l=(0,r.useCallback)(async t=>{await e.post("/api/rules",t),await n()},[e,n]),i=(0,r.useCallback)(async(t,s)=>{await e.put("/api/rules/".concat(t),s),await n()},[e,n]),o=(0,r.useCallback)(async t=>{await e.delete("/api/rules/".concat(t)),await n()},[e,n]),c=(0,r.useCallback)(async t=>{await e.post("/api/rules/".concat(t,"/toggle")),await n()},[e,n]);return{...t,fetchRules:n,createRule:l,updateRule:i,deleteRule:o,toggleRule:c}}},7970:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>f});var r=s(8111),a=s(5271),n=s(5935),l=s.n(n),i=s(4638);let o={precondition:"bg-blue-500/10 text-blue-400 border-blue-500/20",postcondition:"bg-amber-500/10 text-amber-400 border-amber-500/20",permission:"bg-violet-500/10 text-violet-400 border-violet-500/20",pipeline:"bg-cyan-500/10 text-cyan-400 border-cyan-500/20"};function c(e){var t;let{type:s}=e,a=null!=(t=o[s])?t:"bg-gray-500/10 text-gray-400 border-gray-500/20";return(0,r.jsx)("span",{className:"inline-flex items-center rounded-full border px-2 py-0.5 text-[11px] font-medium ".concat(a),children:s.charAt(0).toUpperCase()+s.slice(1)})}function d(e){var t;let{decision:s}=e,a=null!=(t=({allow:"bg-emerald-500/10 text-emerald-400 border-emerald-500/20",deny:"bg-red-500/10 text-red-400 border-red-500/20",ask_user:"bg-amber-500/10 text-amber-400 border-amber-500/20"})[s])?t:"bg-gray-500/10 text-gray-400 border-gray-500/20",n="ask_user"===s?"Ask User":s.charAt(0).toUpperCase()+s.slice(1);return(0,r.jsx)("span",{className:"inline-flex items-center rounded-full border px-2 py-0.5 text-[11px] font-medium ".concat(a),children:n})}function x(e){let{checked:t,onChange:s}=e;return(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":t,onClick:e=>{e.preventDefault(),e.stopPropagation(),s()},className:"relative inline-flex h-5 w-9 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors ".concat(t?"bg-primary-500":"bg-surface-700"),children:(0,r.jsx)("span",{className:"pointer-events-none inline-block h-4 w-4 rounded-full bg-white shadow-sm transition-transform ".concat(t?"translate-x-4":"translate-x-0")})})}function u(e){var t;let{rule:s,onToggle:n,onDelete:i}=e,[o,u]=(0,a.useState)(!1);return(0,r.jsx)("div",{className:"group rounded-xl border border-white/[0.06] bg-surface-900 p-4 transition-colors hover:border-white/[0.1]",children:(0,r.jsxs)("div",{className:"flex items-start gap-4",children:[(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[(0,r.jsx)(l(),{href:"/rules/".concat(s.id),className:"text-sm font-semibold text-white hover:text-primary-400 transition-colors",children:s.id}),(0,r.jsx)(c,{type:(t=s.section).endsWith("s")?t.slice(0,-1):t}),s.locked&&(0,r.jsx)("svg",{className:"h-3.5 w-3.5 text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M16.5 10.5V6.75a4.5 4.5 0 1 0-9 0v3.75m-.75 11.25h10.5a2.25 2.25 0 0 0 2.25-2.25v-6.75a2.25 2.25 0 0 0-2.25-2.25H6.75a2.25 2.25 0 0 0-2.25 2.25v6.75a2.25 2.25 0 0 0 2.25 2.25Z"})})]}),(0,r.jsxs)("div",{className:"space-y-1 text-xs text-gray-500",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"text-gray-600",children:"Trigger:"}),(0,r.jsx)("span",{className:"rounded-md bg-surface-800 px-1.5 py-0.5 text-[10px] font-medium text-gray-400",children:s.trigger})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"text-gray-600",children:"Matcher:"}),(0,r.jsx)("span",{className:"font-mono text-gray-400",children:s.matcher})]}),s.file_pattern&&(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"text-gray-600",children:"File:"}),(0,r.jsx)("span",{className:"font-mono text-gray-400",children:s.file_pattern})]}),s.command_pattern&&(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"text-gray-600",children:"Command:"}),(0,r.jsx)("span",{className:"font-mono text-gray-400",children:s.command_pattern})]})]}),(0,r.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:["permissions"===s.section&&s.decision&&(0,r.jsx)(d,{decision:s.decision}),"preconditions"===s.section&&s.requires_read&&(0,r.jsx)("span",{className:"inline-flex items-center rounded-full border border-blue-500/20 bg-blue-500/10 px-2 py-0.5 text-[11px] font-medium text-blue-400",children:"Requires Read"}),"postconditions"===s.section&&s.run&&(0,r.jsxs)("span",{className:"font-mono text-xs text-gray-400",children:["$ ",s.run]}),"pipelines"===s.section&&s.steps&&(0,r.jsxs)("span",{className:"text-xs text-gray-500",children:[s.steps.length," step",1!==s.steps.length?"s":""]}),s.message&&(0,r.jsx)("p",{className:"w-full text-xs text-gray-500 line-clamp-1",children:s.message})]})]}),(0,r.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,r.jsx)(x,{checked:s.enabled,onChange:()=>n(s.id)}),(0,r.jsx)(l(),{href:"/rules/".concat(s.id),className:"rounded-lg p-1.5 text-gray-500 transition-colors hover:bg-white/[0.06] hover:text-gray-300",title:"Edit rule",children:(0,r.jsx)("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125"})})}),i&&(0,r.jsx)("button",{onClick:e=>{e.preventDefault(),o?(i(s.id),u(!1)):(u(!0),setTimeout(()=>u(!1),3e3))},className:"rounded-lg p-1.5 transition-colors ".concat(o?"bg-red-500/10 text-red-400":"text-gray-500 hover:bg-white/[0.06] hover:text-red-400"),title:o?"Click again to confirm":"Delete rule",children:(0,r.jsx)("svg",{className:"h-3.5 w-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0"})})})]})]})})}var m=s(3951),h=s(4632),p=s(3025);let g=[{key:"all",label:"All"},{key:"preconditions",label:"Preconditions"},{key:"permissions",label:"Permissions"},{key:"postconditions",label:"Postconditions"},{key:"pipelines",label:"Pipelines"}];function f(){return(0,r.jsx)(p.s,{featureName:"Rules management",children:(0,r.jsx)(b,{})})}function b(){let{rules:e,loading:t,error:s,toggleRule:n,deleteRule:o}=(0,i.f)(),[c,d]=(0,a.useState)("all"),[x,p]=(0,a.useState)(""),f=(0,a.useMemo)(()=>{let t=e;if("all"!==c&&(t=t.filter(e=>e.section===c)),x.trim()){let e=x.toLowerCase();t=t.filter(t=>t.id.toLowerCase().includes(e)||t.matcher.toLowerCase().includes(e)||t.message&&"string"==typeof t.message&&t.message.toLowerCase().includes(e))}return t},[e,c,x]),b=(0,a.useMemo)(()=>{let t={all:e.length};for(let r of e){var s;t[r.section]=(null!=(s=t[r.section])?s:0)+1}return t},[e]);return t?(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)("div",{className:"flex items-center justify-between",children:(0,r.jsx)("h1",{className:"text-xl font-semibold text-white",children:"Rules"})}),(0,r.jsx)(m.G,{rows:5})]}):s?(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)("h1",{className:"text-xl font-semibold text-white",children:"Rules"}),(0,r.jsx)("div",{className:"rounded-xl border border-red-500/20 bg-red-500/[0.06] p-4",children:(0,r.jsxs)("p",{className:"text-sm text-red-400",children:["Failed to load rules: ",s]})})]}):(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-xl font-semibold text-white",children:"Rules"}),(0,r.jsxs)("p",{className:"mt-1 text-sm text-gray-400",children:[e.length," rule",1!==e.length?"s":""," configured"]})]}),(0,r.jsxs)(l(),{href:"/rules/new",className:"inline-flex items-center gap-2 rounded-lg bg-primary-500 px-4 py-2 text-sm font-semibold text-white transition-colors hover:bg-primary-600",children:[(0,r.jsx)("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})}),"New Rule"]})]}),(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("svg",{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z"})}),(0,r.jsx)("input",{type:"text",value:x,onChange:e=>p(e.target.value),placeholder:"Search rules by name or matcher...",className:"w-full rounded-lg border border-white/[0.08] bg-surface-800/50 py-2 pl-9 pr-3 text-sm text-white placeholder-gray-600 outline-none transition-colors focus:border-primary-500/50"})]}),(0,r.jsx)("div",{className:"flex gap-1 rounded-lg bg-surface-800/50 p-1",children:g.map(e=>{var t;return(0,r.jsxs)("button",{onClick:()=>d(e.key),className:"rounded-md px-3 py-1.5 text-xs font-medium transition-colors ".concat(c===e.key?"bg-primary-500/15 text-primary-400":"text-gray-500 hover:text-gray-300"),children:[e.label,(null!=(t=b[e.key])?t:0)>0&&(0,r.jsx)("span",{className:"ml-1.5 text-gray-600",children:b[e.key]})]},e.key)})})]}),0===f.length?(0,r.jsx)(h.p,{title:x?"No rules match your search":"No rules configured",description:x?"Try a different search term.":"Create your first rule or run setup to generate rules automatically.",action:x?void 0:{label:"New Rule",onClick:()=>window.location.assign("/rules/new")}}):(0,r.jsx)("div",{className:"space-y-2",children:f.map(e=>(0,r.jsx)(u,{rule:e,onToggle:()=>void n(e.id),onDelete:e=>void o(e)},e.id))})]})}}},e=>{e.O(0,[5935,814,9743,7358],()=>e(e.s=2757)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6630],{422:(e,s,t)=>{"use strict";function r(){{let e=window.location.hostname;return"localhost"===e||"127.0.0.1"===e}}function n(){return r(),"http://localhost:9800"}t.d(s,{J:()=>r,h:()=>n})},3025:(e,s,t)=>{"use strict";t.d(s,{s:()=>a});var r=t(8111),n=t(3446);function a(e){let{children:s,featureName:t="This feature"}=e;return"cloud"===(0,n.Xk)()?(0,r.jsx)("div",{className:"space-y-6",children:(0,r.jsxs)("div",{className:"rounded-xl border border-white/[0.06] bg-surface-900 p-8 text-center",children:[(0,r.jsx)("svg",{className:"mx-auto h-10 w-10 text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 17.25v1.007a3 3 0 0 1-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0 1 15 18.257V17.25m6-12V15a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 15V5.25m18 0A2.25 2.25 0 0 0 18.75 3H5.25A2.25 2.25 0 0 0 3 5.25m18 0V12a2.25 2.25 0 0 1-2.25 2.25H5.25A2.25 2.25 0 0 1 3 12V5.25"})}),(0,r.jsxs)("p",{className:"mt-3 text-sm text-gray-400",children:[t," is available in local mode."]}),(0,r.jsx)("p",{className:"mt-1 text-xs text-gray-600",children:"Connect to a local ULPI API server to use this feature."})]})}):(0,r.jsx)(r.Fragment,{children:s})}},3446:(e,s,t)=>{"use strict";t.d(s,{Kv:()=>o,HI:()=>u,Xk:()=>d,yC:()=>x});var r=t(8111),n=t(5271),a=t(422),l=t(7811);class i{async request(e,s){let t="".concat(this.baseUrl).concat(e);if(this.repo){let e=t.includes("?")?"&":"?";t="".concat(t).concat(e,"repo=").concat(encodeURIComponent(this.repo))}let r=l.env.NEXT_PUBLIC_ULPI_API_SECRET,n=await fetch(t,{...s,headers:{"Content-Type":"application/json",...r?{"X-Ulpi-Secret":r}:{},...null==s?void 0:s.headers}});if(!n.ok)throw Error((await n.json().catch(()=>({error:n.statusText}))).error||"API error: ".concat(n.status));return n.json()}async get(e){return this.request(e)}async post(e,s){return this.request(e,{method:"POST",body:s?JSON.stringify(s):void 0})}async put(e,s){return this.request(e,{method:"PUT",body:s?JSON.stringify(s):void 0})}async delete(e){return this.request(e,{method:"DELETE"})}constructor(){this.repo=null,this.baseUrl=(0,a.h)()}}let c=(0,n.createContext)({mode:"cloud",localClient:null});function o(e){let{children:s}=e,t=(0,n.useMemo)(()=>{let e=(0,a.J)()?"local":"cloud";return{mode:e,localClient:"local"===e?new i:null}},[]);return(0,r.jsx)(c,{value:t,children:s})}function d(){return(0,n.useContext)(c).mode}function x(){let{localClient:e}=(0,n.useContext)(c);if(!e)throw Error("LocalApiClient not available in cloud mode");return e}function u(){return(0,n.useContext)(c)}},3747:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>h});var r=t(8111),n=t(5271),a=t(5935),l=t.n(a),i=t(4638),c=t(3951),o=t(4632),d=t(3025);function x(e){let{steps:s}=e;return(0,r.jsx)("div",{className:"flex flex-wrap items-center gap-1.5",children:s.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsxs)("div",{className:"rounded-lg border border-white/[0.06] bg-surface-800 px-2.5 py-1.5",children:[(0,r.jsx)("p",{className:"text-xs font-medium text-gray-300",children:e.name}),(0,r.jsx)("p",{className:"mt-0.5 font-mono text-[10px] text-gray-500",children:e.run})]}),t<s.length-1&&(0,r.jsx)("svg",{className:"h-3.5 w-3.5 shrink-0 text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.5 4.5 21 12m0 0-7.5 7.5M21 12H3"})})]},t))})}function u(e){let{checked:s,onChange:t}=e;return(0,r.jsx)("button",{type:"button",role:"switch","aria-checked":s,onClick:t,className:"relative inline-flex h-5 w-9 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors ".concat(s?"bg-primary-500":"bg-surface-700"),children:(0,r.jsx)("span",{className:"pointer-events-none inline-block h-4 w-4 rounded-full bg-white shadow-sm transition-transform ".concat(s?"translate-x-4":"translate-x-0")})})}function h(){return(0,r.jsx)(d.s,{featureName:"Pipelines",children:(0,r.jsx)(m,{})})}function m(){let{rules:e,loading:s,error:t,toggleRule:a}=(0,i.f)(),d=(0,n.useMemo)(()=>e.filter(e=>"pipelines"===e.section),[e]);return s?(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)("h1",{className:"text-xl font-semibold text-white",children:"Pipelines"}),(0,r.jsx)(c.G,{rows:3})]}):t?(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)("h1",{className:"text-xl font-semibold text-white",children:"Pipelines"}),(0,r.jsx)("div",{className:"rounded-xl border border-red-500/20 bg-red-500/[0.06] p-4",children:(0,r.jsxs)("p",{className:"text-sm text-red-400",children:["Failed to load rules: ",t]})})]}):(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-xl font-semibold text-white",children:"Pipelines"}),(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-400",children:"Pipeline rules run multi-step workflows on tool actions"})]}),(0,r.jsxs)(l(),{href:"/rules/new",className:"inline-flex items-center gap-2 rounded-lg bg-primary-500 px-4 py-2 text-sm font-semibold text-white transition-colors hover:bg-primary-600",children:[(0,r.jsx)("svg",{className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"})}),"New Pipeline"]})]}),0===d.length?(0,r.jsx)(o.p,{title:"No pipelines configured",description:"Pipelines run a sequence of steps when a tool action matches. Create one from the Rule Builder.",action:{label:"Create Pipeline",onClick:()=>window.location.assign("/rules/new")}}):(0,r.jsx)("div",{className:"space-y-3",children:d.map(e=>{let s=Array.isArray(e.steps)?e.steps:[],t="string"==typeof e.on_failure?e.on_failure:"block";return(0,r.jsx)("div",{className:"rounded-xl border border-white/[0.06] bg-surface-900 p-4",children:(0,r.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"mb-2 flex items-center gap-2",children:[(0,r.jsx)(l(),{href:"/rules/".concat(e.id),className:"text-sm font-semibold text-white hover:text-primary-400 transition-colors",children:e.id}),(0,r.jsx)("span",{className:"inline-flex items-center rounded-full border border-cyan-500/20 bg-cyan-500/10 px-2 py-0.5 text-[11px] font-medium text-cyan-400",children:"Pipeline"}),!e.enabled&&(0,r.jsx)("span",{className:"text-[11px] text-gray-600",children:"Disabled"})]}),(0,r.jsxs)("div",{className:"mb-3 flex items-center gap-3 text-xs text-gray-500",children:[(0,r.jsxs)("span",{children:["Trigger: ",(0,r.jsx)("span",{className:"text-gray-400",children:e.trigger})]}),(0,r.jsxs)("span",{children:["Matcher: ",(0,r.jsx)("span",{className:"font-mono text-gray-400",children:e.matcher})]}),(0,r.jsxs)("span",{children:["On failure: ",(0,r.jsx)("span",{className:"text-gray-400",children:t})]})]}),s.length>0&&(0,r.jsx)(x,{steps:s})]}),(0,r.jsx)(u,{checked:e.enabled,onChange:()=>void a(e.id)})]})},e.id)})})]})}},3951:(e,s,t)=>{"use strict";t.d(s,{G:()=>n});var r=t(8111);function n(e){let{rows:s=3,variant:t="skeleton",className:n=""}=e;return"spinner"===t?(0,r.jsx)("div",{className:"flex items-center justify-center py-16 ".concat(n),children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,r.jsx)("div",{className:"h-7 w-7 animate-spin rounded-full border-2 border-primary-500 border-t-transparent"}),(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"Loading..."})]})}):(0,r.jsx)("div",{className:"space-y-3 ".concat(n),children:Array.from({length:s}).map((e,s)=>(0,r.jsx)("div",{className:"animate-pulse rounded-xl border border-white/[0.04] bg-surface-800/50 p-4",children:(0,r.jsxs)("div",{className:"flex items-center gap-4",children:[(0,r.jsx)("div",{className:"h-8 w-8 rounded-lg bg-white/[0.06]"}),(0,r.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,r.jsx)("div",{className:"h-3.5 w-1/3 rounded bg-white/[0.06]"}),(0,r.jsx)("div",{className:"h-3 w-2/3 rounded bg-white/[0.04]"})]}),(0,r.jsx)("div",{className:"h-5 w-16 rounded-full bg-white/[0.04]"})]})},s))})}},4632:(e,s,t)=>{"use strict";t.d(s,{p:()=>a});var r=t(8111);function n(){return(0,r.jsx)("svg",{className:"h-10 w-10 text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M20.25 7.5l-.625 10.632a2.25 2.25 0 0 1-2.247 2.118H6.622a2.25 2.25 0 0 1-2.247-2.118L3.75 7.5m6 4.125 2.25 2.25m0 0 2.25 2.25M12 13.875l2.25-2.25M12 13.875l-2.25 2.25M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125Z"})})}function a(e){let{icon:s,title:t,description:a,action:l,className:i=""}=e;return(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center rounded-2xl border border-dashed border-white/[0.06] bg-surface-800/30 px-6 py-16 text-center ".concat(i),children:[(0,r.jsx)("div",{className:"mb-4",children:null!=s?s:(0,r.jsx)(n,{})}),(0,r.jsx)("h3",{className:"text-sm font-medium text-gray-300",children:t}),a&&(0,r.jsx)("p",{className:"mt-1.5 max-w-sm text-xs text-gray-500",children:a}),l&&(0,r.jsx)("button",{onClick:l.onClick,className:"mt-5 rounded-lg bg-primary-500 px-4 py-2 text-xs font-semibold text-white transition-colors hover:bg-primary-600",children:l.label})]})}},4638:(e,s,t)=>{"use strict";t.d(s,{f:()=>a});var r=t(5271),n=t(3446);function a(){let e=(0,n.yC)(),[s,t]=(0,r.useState)({rules:[],loading:!0,error:null}),a=(0,r.useCallback)(async()=>{t(e=>({...e,loading:!0,error:null}));try{let s=await e.get("/api/rules"),r=Array.isArray(s)?s:[];t({rules:r,loading:!1,error:null})}catch(e){t(s=>({...s,loading:!1,error:e instanceof Error?e.message:"Failed to fetch rules"}))}},[e]);(0,r.useEffect)(()=>{a()},[a]);let l=(0,r.useCallback)(async s=>{await e.post("/api/rules",s),await a()},[e,a]),i=(0,r.useCallback)(async(s,t)=>{await e.put("/api/rules/".concat(s),t),await a()},[e,a]),c=(0,r.useCallback)(async s=>{await e.delete("/api/rules/".concat(s)),await a()},[e,a]),o=(0,r.useCallback)(async s=>{await e.post("/api/rules/".concat(s,"/toggle")),await a()},[e,a]);return{...s,fetchRules:a,createRule:l,updateRule:i,deleteRule:c,toggleRule:o}}},7299:(e,s,t)=>{Promise.resolve().then(t.bind(t,3747))}},e=>{e.O(0,[5935,814,9743,7358],()=>e(e.s=7299)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6274],{422:(e,t,s)=>{"use strict";function r(){{let e=window.location.hostname;return"localhost"===e||"127.0.0.1"===e}}function a(){return r(),"http://localhost:9800"}s.d(t,{J:()=>r,h:()=>a})},759:(e,t,s)=>{Promise.resolve().then(s.bind(s,9947))},3446:(e,t,s)=>{"use strict";s.d(t,{Kv:()=>o,HI:()=>u,Xk:()=>d,yC:()=>x});var r=s(8111),a=s(5271),l=s(422),n=s(7811);class i{async request(e,t){let s="".concat(this.baseUrl).concat(e);if(this.repo){let e=s.includes("?")?"&":"?";s="".concat(s).concat(e,"repo=").concat(encodeURIComponent(this.repo))}let r=n.env.NEXT_PUBLIC_ULPI_API_SECRET,a=await fetch(s,{...t,headers:{"Content-Type":"application/json",...r?{"X-Ulpi-Secret":r}:{},...null==t?void 0:t.headers}});if(!a.ok)throw Error((await a.json().catch(()=>({error:a.statusText}))).error||"API error: ".concat(a.status));return a.json()}async get(e){return this.request(e)}async post(e,t){return this.request(e,{method:"POST",body:t?JSON.stringify(t):void 0})}async put(e,t){return this.request(e,{method:"PUT",body:t?JSON.stringify(t):void 0})}async delete(e){return this.request(e,{method:"DELETE"})}constructor(){this.repo=null,this.baseUrl=(0,l.h)()}}let c=(0,a.createContext)({mode:"cloud",localClient:null});function o(e){let{children:t}=e,s=(0,a.useMemo)(()=>{let e=(0,l.J)()?"local":"cloud";return{mode:e,localClient:"local"===e?new i:null}},[]);return(0,r.jsx)(c,{value:s,children:t})}function d(){return(0,a.useContext)(c).mode}function x(){let{localClient:e}=(0,a.useContext)(c);if(!e)throw Error("LocalApiClient not available in cloud mode");return e}function u(){return(0,a.useContext)(c)}},3951:(e,t,s)=>{"use strict";s.d(t,{G:()=>a});var r=s(8111);function a(e){let{rows:t=3,variant:s="skeleton",className:a=""}=e;return"spinner"===s?(0,r.jsx)("div",{className:"flex items-center justify-center py-16 ".concat(a),children:(0,r.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,r.jsx)("div",{className:"h-7 w-7 animate-spin rounded-full border-2 border-primary-500 border-t-transparent"}),(0,r.jsx)("p",{className:"text-xs text-gray-500",children:"Loading..."})]})}):(0,r.jsx)("div",{className:"space-y-3 ".concat(a),children:Array.from({length:t}).map((e,t)=>(0,r.jsx)("div",{className:"animate-pulse rounded-xl border border-white/[0.04] bg-surface-800/50 p-4",children:(0,r.jsxs)("div",{className:"flex items-center gap-4",children:[(0,r.jsx)("div",{className:"h-8 w-8 rounded-lg bg-white/[0.06]"}),(0,r.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,r.jsx)("div",{className:"h-3.5 w-1/3 rounded bg-white/[0.06]"}),(0,r.jsx)("div",{className:"h-3 w-2/3 rounded bg-white/[0.04]"})]}),(0,r.jsx)("div",{className:"h-5 w-16 rounded-full bg-white/[0.04]"})]})},t))})}},4632:(e,t,s)=>{"use strict";s.d(t,{p:()=>l});var r=s(8111);function a(){return(0,r.jsx)("svg",{className:"h-10 w-10 text-gray-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M20.25 7.5l-.625 10.632a2.25 2.25 0 0 1-2.247 2.118H6.622a2.25 2.25 0 0 1-2.247-2.118L3.75 7.5m6 4.125 2.25 2.25m0 0 2.25 2.25M12 13.875l2.25-2.25M12 13.875l-2.25 2.25M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125Z"})})}function l(e){let{icon:t,title:s,description:l,action:n,className:i=""}=e;return(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center rounded-2xl border border-dashed border-white/[0.06] bg-surface-800/30 px-6 py-16 text-center ".concat(i),children:[(0,r.jsx)("div",{className:"mb-4",children:null!=t?t:(0,r.jsx)(a,{})}),(0,r.jsx)("h3",{className:"text-sm font-medium text-gray-300",children:s}),l&&(0,r.jsx)("p",{className:"mt-1.5 max-w-sm text-xs text-gray-500",children:l}),n&&(0,r.jsx)("button",{onClick:n.onClick,className:"mt-5 rounded-lg bg-primary-500 px-4 py-2 text-xs font-semibold text-white transition-colors hover:bg-primary-600",children:n.label})]})}},4736:(e,t,s)=>{"use strict";var r=s(1504);s.o(r,"useParams")&&s.d(t,{useParams:function(){return r.useParams}}),s.o(r,"usePathname")&&s.d(t,{usePathname:function(){return r.usePathname}}),s.o(r,"useRouter")&&s.d(t,{useRouter:function(){return r.useRouter}}),s.o(r,"useSearchParams")&&s.d(t,{useSearchParams:function(){return r.useSearchParams}})},5605:(e,t,s)=>{"use strict";s.d(t,{W:()=>n});var r=s(8111);let a={pending:"bg-yellow-500/10 text-yellow-400 border-yellow-500/20",queued:"bg-yellow-500/10 text-yellow-400 border-yellow-500/20",active:"bg-blue-500/10 text-blue-400 border-blue-500/20",running:"bg-blue-500/10 text-blue-400 border-blue-500/20",in_progress:"bg-blue-500/10 text-blue-400 border-blue-500/20",completed:"bg-emerald-500/10 text-emerald-400 border-emerald-500/20",success:"bg-emerald-500/10 text-emerald-400 border-emerald-500/20",approved:"bg-emerald-500/10 text-emerald-400 border-emerald-500/20",error:"bg-red-500/10 text-red-400 border-red-500/20",failed:"bg-red-500/10 text-red-400 border-red-500/20",rejected:"bg-red-500/10 text-red-400 border-red-500/20",cancelled:"bg-gray-500/10 text-gray-400 border-gray-500/20",idle:"bg-gray-500/10 text-gray-400 border-gray-500/20"},l={pending:"bg-yellow-400",queued:"bg-yellow-400",active:"bg-blue-400",running:"bg-blue-400",in_progress:"bg-blue-400",completed:"bg-emerald-400",success:"bg-emerald-400",approved:"bg-emerald-400",error:"bg-red-400",failed:"bg-red-400",rejected:"bg-red-400",cancelled:"bg-gray-400",idle:"bg-gray-400"};function n(e){var t,s;let{status:n,label:i,showDot:c=!0,size:o="sm",className:d=""}=e,x=n.toLowerCase().replace(/\s+/g,"_"),u=null!=(t=a[x])?t:"bg-gray-500/10 text-gray-400 border-gray-500/20",m=null!=(s=l[x])?s:"bg-gray-400",h=null!=i?i:n.charAt(0).toUpperCase()+n.slice(1).replace(/_/g," ");return(0,r.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-full border font-medium ".concat(u," ").concat("sm"===o?"px-2 py-0.5 text-[11px]":"px-2.5 py-1 text-xs"," ").concat(d),children:[c&&(0,r.jsx)("span",{className:"h-1.5 w-1.5 rounded-full ".concat(m)}),h]})}},9947:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>_});var r=s(8111),a=s(5271),l=s(4736),n=s(422),i=s(8934),c=s(2928),o=s(3446),d=s(3951),x=s(4632),u=s(5605);function m(e){let t=Date.now()-new Date(e).getTime();return t<6e4?"just now":t<36e5?"".concat(Math.floor(t/6e4),"m ago"):t<864e5?"".concat(Math.floor(t/36e5),"h ago"):"".concat(Math.floor(t/864e5),"d ago")}function h(e){return new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function p(e,t){let s=new Date(e).getTime(),r=(t?new Date(t).getTime():Date.now())-s;if(r<0)return"0s";if(r<6e4)return"".concat(Math.round(r/1e3),"s");if(r<36e5){let e=Math.floor(r/6e4),t=Math.round(r%6e4/1e3);return"".concat(e,"m ").concat(t,"s")}let a=Math.floor(r/36e5),l=Math.floor(r%36e5/6e4);return"".concat(a,"h ").concat(l,"m")}function g(e){if(!e)return"Unknown";let t=e.replace(/\/$/,"").split("/");return t[t.length-1]||e}let f={PreToolUse:"bg-blue-400",PostToolUse:"bg-emerald-400",PermissionRequest:"bg-amber-400",Notification:"bg-violet-400",Stop:"bg-orange-400",SessionStart:"bg-cyan-400",SessionEnd:"bg-gray-400"},b={PreToolUse:"bg-blue-500/15 text-blue-400 border-blue-500/30",PostToolUse:"bg-emerald-500/15 text-emerald-400 border-emerald-500/30",PermissionRequest:"bg-amber-500/15 text-amber-400 border-amber-500/30",Notification:"bg-violet-500/15 text-violet-400 border-violet-500/30",Stop:"bg-orange-500/15 text-orange-400 border-orange-500/30",SessionStart:"bg-cyan-500/15 text-cyan-400 border-cyan-500/30",SessionEnd:"bg-gray-500/15 text-gray-400 border-gray-500/30"};function j(e){let{session:t,selected:s,onSelect:a}=e,l=t.filesRead>0||t.filesWritten>0||t.commandsRun>0||t.rulesEnforced>0;return(0,r.jsxs)("button",{onClick:a,className:"w-full text-left rounded-lg px-3 py-3 transition-colors ".concat(s?"bg-primary-500/10 border border-primary-500/30":"border border-transparent hover:bg-white/[0.03]"),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.jsx)("span",{className:"h-2 w-2 shrink-0 rounded-full ".concat(l?"bg-emerald-400":"bg-gray-600")}),(0,r.jsx)("span",{className:"font-mono text-xs text-primary-400 truncate",children:t.sessionName||t.sessionId.slice(0,12)})]}),(0,r.jsx)("span",{className:"text-[10px] text-gray-600 shrink-0",children:m(t.startedAt)})]}),(0,r.jsx)("p",{className:"mt-1 text-xs text-gray-400 truncate pl-4",children:g(t.projectDir)}),(0,r.jsxs)("div",{className:"mt-1.5 flex items-center gap-3 text-[10px] text-gray-600 pl-4",children:[(0,r.jsxs)("span",{children:[t.filesRead,"r"]}),(0,r.jsxs)("span",{children:[t.filesWritten,"w"]}),(0,r.jsxs)("span",{children:[t.commandsRun,"c"]}),t.rulesEnforced>0&&(0,r.jsxs)("span",{className:"text-amber-400/70",children:[t.rulesEnforced," rules"]}),t.actionsBlocked>0&&(0,r.jsxs)("span",{className:"text-red-400/70",children:[t.actionsBlocked," blocked"]})]})]})}function v(e){let{label:t,active:s}=e;return(0,r.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-medium ".concat(s?"bg-emerald-500/10 text-emerald-400":"bg-surface-800 text-gray-600"),children:[s?"+":"-"," ",t]})}function y(e){var t;let{sessionId:s}=e,[l,n]=(0,a.useState)(null),{session:i,loading:c,error:m,refresh:j}=function(e){let t=(0,o.yC)(),[s,r]=(0,a.useState)(null),[l,n]=(0,a.useState)(!0),[i,c]=(0,a.useState)(null),d=(0,a.useRef)(!1),x=(0,a.useRef)(e);x.current!==e&&(x.current=e,d.current=!1);let u=(0,a.useCallback)(async()=>{if(!e){r(null),n(!1);return}d.current||n(!0),c(null);try{let s=await t.get("/api/session?session=".concat(encodeURIComponent(e)));r(s)}catch(e){c(e instanceof Error?e.message:"Failed to load session"),r(null)}finally{d.current=!0,n(!1)}},[t,e]);return(0,a.useEffect)(()=>{u()},[u]),{session:s,loading:l,error:i,refresh:u}}(s),{events:y,loading:N,error:w,refresh:k}=function(e){let t=(0,o.yC)(),[s,r]=(0,a.useState)([]),[l,n]=(0,a.useState)(!0),[i,c]=(0,a.useState)(null),d=(0,a.useRef)(!1),x=(0,a.useRef)(e);x.current!==e&&(x.current=e,d.current=!1);let u=(0,a.useCallback)(async()=>{if(!e){r([]),n(!1);return}d.current||n(!0),c(null);try{let s=await t.get("/api/events?session=".concat(encodeURIComponent(e)));r(Array.isArray(s)?s:[])}catch(e){c(e instanceof Error?e.message:"Failed to load events"),r([])}finally{d.current=!0,n(!1)}},[t,e]);return(0,a.useEffect)(()=>{u()},[u]),{events:s,loading:l,error:i,refresh:u}}(s);(0,a.useEffect)(()=>{if(!i||"ended"===i.phase)return;let e=setInterval(()=>{j(),k()},3e3);return()=>clearInterval(e)},[i,j,k]),(0,a.useEffect)(()=>{n(null)},[s]);let C=(0,a.useMemo)(()=>{let e=y;return"read"===l?e=y.filter(e=>"Read"===e.toolName||"file_read"===e.event):"written"===l?e=y.filter(e=>"Write"===e.toolName||"Edit"===e.toolName||"file_written"===e.event):"cmds"===l?e=y.filter(e=>"Bash"===e.toolName||e.command):"rules"===l?e=y.filter(e=>e.ruleName):"blocked"===l&&(e=y.filter(e=>e.event.includes("block")||e.event.includes("deny"))),[...e].sort((e,t)=>new Date(e.ts).getTime()-new Date(t.ts).getTime())},[y,l]);return c?(0,r.jsx)(d.G,{rows:4}):m?(0,r.jsxs)("div",{className:"rounded-xl border border-red-500/20 bg-red-500/5 p-5",children:[(0,r.jsx)("h2",{className:"text-base font-semibold text-red-400",children:"Failed to load session"}),(0,r.jsx)("p",{className:"mt-1 text-sm text-red-400/70",children:m})]}):i?(0,r.jsxs)("div",{className:"flex flex-col h-full min-h-0",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between shrink-0",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"text-base font-semibold text-white",children:i.sessionName||"Session Detail"}),(0,r.jsx)("p",{className:"font-mono text-[10px] text-gray-600",children:i.sessionId})]}),(0,r.jsx)(u.W,{status:null!=(t=i.phase)?t:"active"})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs mt-4 shrink-0",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-gray-600",children:"Project "}),(0,r.jsx)("span",{className:"text-gray-300",children:g(i.projectDir)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-gray-600",children:"Started "}),(0,r.jsx)("span",{className:"text-gray-300",children:h(i.startedAt)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-gray-600",children:"Duration "}),(0,r.jsx)("span",{className:"text-gray-300",children:p(i.startedAt)})]}),i.branch&&(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-gray-600",children:"Branch "}),(0,r.jsx)("span",{className:"text-gray-300 font-mono",children:i.branch})]})]}),(0,r.jsx)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-5 mt-4 shrink-0",children:[{key:"read",label:"Files Read",value:i.filesRead.length,activeColor:"text-primary-400",icon:(0,r.jsx)("svg",{className:"h-[18px] w-[18px]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z"})})},{key:"written",label:"Files Written",value:i.filesWritten.length,activeColor:"text-primary-400",icon:(0,r.jsx)("svg",{className:"h-[18px] w-[18px]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10"})})},{key:"cmds",label:"Commands",value:i.commandsRun.length,activeColor:"text-primary-400",icon:(0,r.jsx)("svg",{className:"h-[18px] w-[18px]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6.75 7.5l3 2.25-3 2.25m4.5 0h3m-9 8.25h13.5A2.25 2.25 0 0 0 21 18V6a2.25 2.25 0 0 0-2.25-2.25H5.25A2.25 2.25 0 0 0 3 6v12a2.25 2.25 0 0 0 2.25 2.25Z"})})},{key:"rules",label:"Rules Enforced",value:i.rulesEnforced,activeColor:"text-primary-400",icon:(0,r.jsx)("svg",{className:"h-[18px] w-[18px]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75 11.25 15 15 9.75m-3-7.036A11.959 11.959 0 0 1 3.598 6 11.99 11.99 0 0 0 3 9.749c0 5.592 3.824 10.29 9 11.623 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.571-.598-3.751h-.152c-3.196 0-6.1-1.248-8.25-3.285Z"})})},{key:"blocked",label:"Blocked",value:i.actionsBlocked,activeColor:"text-primary-400",icon:(0,r.jsx)("svg",{className:"h-[18px] w-[18px]",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M18.364 18.364A9 9 0 0 0 5.636 5.636m12.728 12.728A9 9 0 0 1 5.636 5.636m12.728 12.728L5.636 5.636"})})}].map(e=>{let t=l===e.key;return(0,r.jsxs)("button",{onClick:()=>n(t?null:e.key),className:"flex items-center gap-3 rounded-lg border p-3 text-left transition-all ".concat(t?"border-primary-500/40 bg-primary-500/[0.07] ring-1 ring-primary-500/30":"border-white/[0.06] bg-surface-800/50 hover:bg-surface-800/80"),children:[(0,r.jsx)("div",{className:"shrink-0 ".concat(t?e.activeColor:"text-primary-400/50"),children:e.icon}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("p",{className:"text-lg font-semibold text-white",children:e.value}),(0,r.jsx)("p",{className:"text-[10px] text-gray-500",children:e.label})]})]},e.key)})}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-1.5 mt-4 shrink-0",children:[(0,r.jsx)(v,{label:"Tests",active:i.testsRun}),(0,r.jsx)(v,{label:"Lint",active:i.lintRun}),(0,r.jsx)(v,{label:"Build",active:i.buildRun}),(0,r.jsx)(v,{label:"Fmt",active:i.formatterRun}),(0,r.jsx)(v,{label:"Branch",active:i.branchCreated}),(0,r.jsx)(v,{label:"Plan",active:i.planApproved})]}),(0,r.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col mt-4",children:[(0,r.jsxs)("div",{className:"mb-2 flex items-center justify-between shrink-0",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h3",{className:"text-xs font-semibold text-white",children:"Events"}),l&&(0,r.jsxs)("button",{onClick:()=>n(null),className:"inline-flex items-center gap-1 rounded-full bg-primary-500/15 px-2 py-0.5 text-[10px] font-medium text-primary-400 hover:bg-primary-500/25 transition-colors",children:[l,(0,r.jsx)("svg",{className:"h-2.5 w-2.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18 18 6M6 6l12 12"})})]})]}),(0,r.jsx)("span",{className:"text-[10px] text-gray-600",children:l?"".concat(C.length," / ").concat(y.length):y.length||""})]}),N?(0,r.jsx)(d.G,{rows:3}):w?(0,r.jsx)("div",{className:"rounded-lg border border-red-500/20 bg-red-500/5 p-3",children:(0,r.jsx)("p",{className:"text-xs text-red-400",children:w})}):0===C.length?(0,r.jsx)("p",{className:"py-6 text-center text-xs text-gray-600",children:l?"No ".concat(l," events"):"No events recorded"}):(0,r.jsxs)("div",{className:"relative flex-1 min-h-0 overflow-y-auto",children:[(0,r.jsx)("div",{className:"absolute left-[7px] top-2 bottom-2 w-px bg-white/[0.06]"}),(0,r.jsx)("div",{className:"space-y-1",children:C.map((e,t)=>{var s,a,l;let n=null!=(s=e.hookEvent)?s:"",i=null!=(a=f[n])?a:"bg-gray-500",c=null!=(l=b[n])?l:"bg-gray-500/15 text-gray-400 border-gray-500/30",o=function(e){let t=[];if(e.message&&t.push(e.message),e.toolName&&t.push("tool: ".concat(e.toolName)),e.filePath){var s;let r=null!=(s=e.filePath.split("/").pop())?s:e.filePath;t.push(r)}if(e.command){let s=e.command.length>60?e.command.slice(0,57)+"...":e.command;t.push(s)}return e.ruleName&&t.push("rule: ".concat(e.ruleName)),t.join(" | ")}(e);return(0,r.jsxs)("div",{className:"relative flex items-start gap-2",children:[(0,r.jsx)("div",{className:"relative z-10 mt-2 shrink-0",children:(0,r.jsx)("div",{className:"h-[7px] w-[7px] rounded-full ".concat(i," ring-2 ring-surface-900"),style:{marginLeft:"1px"}})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0 rounded-md border border-white/[0.03] bg-surface-800/20 px-2 py-1.5 hover:bg-surface-800/40 transition-colors",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[n&&(0,r.jsx)("span",{className:"inline-flex items-center rounded px-1 py-px text-[9px] font-medium border shrink-0 ".concat(c),children:n}),(0,r.jsx)("span",{className:"text-[10px] text-gray-500 truncate",children:e.event.replace(/_/g," ")})]}),(0,r.jsx)("span",{className:"text-[9px] text-gray-700 shrink-0",children:new Date(e.ts).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"})})]}),o&&(0,r.jsx)("p",{className:"mt-0.5 text-[10px] text-gray-600 font-mono truncate",children:o})]})]},"".concat(e.ts,"-").concat(e.event,"-").concat(t))})})]})]})]}):(0,r.jsx)(x.p,{title:"Session not found",description:'No session found with ID "'.concat(s,'".')})}function N(){var e;let t=(0,l.useRouter)(),s=(0,l.useSearchParams)(),n=null!=(e=null==s?void 0:s.get("id"))?e:null,{sessions:i,loading:c,error:x}=function(){let e=(0,o.yC)(),[t,s]=(0,a.useState)([]),[r,l]=(0,a.useState)(!0),[n,i]=(0,a.useState)(null),c=(0,a.useRef)(!1),d=(0,a.useCallback)(async()=>{c.current||l(!0),i(null);try{let t=await e.get("/api/sessions");s(Array.isArray(t)?t:[])}catch(e){i(e instanceof Error?e.message:"Failed to fetch sessions")}finally{c.current=!0,l(!1)}},[e]);return(0,a.useEffect)(()=>{d()},[d]),{sessions:t,loading:r,error:n,refresh:d}}(),u=(0,a.useCallback)(e=>{t.push("/sessions?id=".concat(encodeURIComponent(e)),{scroll:!1})},[t]);return(0,r.jsxs)("div",{className:"flex flex-col h-[calc(100vh-32px)]",children:[(0,r.jsxs)("div",{className:"shrink-0",children:[(0,r.jsx)("h1",{className:"text-xl font-semibold text-white",children:"Sessions"}),(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-400",children:"Session history and event timeline."})]}),(0,r.jsxs)("div",{className:"flex gap-4 flex-1 min-h-0 mt-4",children:[(0,r.jsx)("div",{className:"w-1/3 min-w-[280px] max-w-[400px] shrink-0 overflow-y-auto rounded-xl border border-white/[0.06] bg-surface-900 p-2",children:c?(0,r.jsx)(d.G,{rows:6}):x?(0,r.jsx)("div",{className:"p-3",children:(0,r.jsx)("p",{className:"text-xs text-red-400",children:x})}):0===i.length?(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"No sessions found"}),(0,r.jsx)("p",{className:"mt-1 text-xs text-gray-600",children:"Start a Claude Code session with ULPI hooks."})]}):(0,r.jsx)("div",{className:"space-y-0.5",children:i.map(e=>(0,r.jsx)(j,{session:e,selected:e.sessionId===n,onSelect:()=>u(e.sessionId)},e.sessionId))})}),(0,r.jsx)("div",{className:"flex-1 min-w-0 rounded-xl border border-white/[0.06] bg-surface-900 p-5 overflow-hidden flex flex-col",children:n?(0,r.jsx)(y,{sessionId:n}):(0,r.jsxs)("div",{className:"flex h-full flex-col items-center justify-center text-center",children:[(0,r.jsx)("svg",{className:"h-10 w-10 text-gray-700",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25H12"})}),(0,r.jsx)("p",{className:"mt-3 text-sm text-gray-500",children:"Select a session"}),(0,r.jsx)("p",{className:"mt-1 text-xs text-gray-600",children:"Click a session on the left to view its details and events."})]})})]})]})}let w={active:"bg-emerald-500/10 text-emerald-400 border-emerald-500/20",idle:"bg-yellow-500/10 text-yellow-400 border-yellow-500/20",ended:"bg-gray-500/10 text-gray-400 border-gray-500/20"};function k(e){var t;let{status:s}=e;return(0,r.jsxs)("span",{className:"inline-flex items-center rounded-md border px-2 py-0.5 text-[11px] font-medium ".concat(null!=(t=w[s])?t:w.ended),children:["active"===s&&(0,r.jsx)("span",{className:"mr-1.5 h-1.5 w-1.5 rounded-full bg-emerald-400 animate-pulse"}),s]})}let C=[{label:"All",value:""},{label:"Active",value:"active"},{label:"Idle",value:"idle"},{label:"Ended",value:"ended"}];function S(){var e,t;let s=(0,l.useRouter)(),n=(0,l.useSearchParams)(),o=null!=(e=null==n?void 0:n.get("id"))?e:null,{org:u}=(0,i.As)(),[g,f]=(0,a.useState)([]),[b,j]=(0,a.useState)(!0),[v,y]=(0,a.useState)(""),[N,w]=(0,a.useState)(null),[S,_]=(0,a.useState)(!1),L=(0,a.useCallback)(async()=>{if(u){j(!0);try{let e=await c.uE.listSessions(u.id,{status:v||void 0});f(e.sessions)}catch(e){}finally{j(!1)}}},[u,v]);(0,a.useEffect)(()=>{L()},[L]),(0,a.useEffect)(()=>{if(!g.some(e=>"active"===e.status))return;let e=setInterval(()=>void L(),5e3);return()=>clearInterval(e)},[g,L]),(0,a.useEffect)(()=>{if(!u||!o)return void w(null);_(!0),c.uE.getSession(u.id,o).then(e=>w(e)).catch(()=>w(null)).finally(()=>_(!1))},[u,o]);let E=(0,a.useCallback)(e=>{s.push("/sessions?id=".concat(encodeURIComponent(e)),{scroll:!1})},[s]);return(0,r.jsxs)("div",{className:"flex flex-col h-[calc(100vh-32px)]",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between shrink-0",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-xl font-semibold text-white",children:"Sessions"}),(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-400",children:"Live and recent worker sessions."})]}),(0,r.jsx)("div",{className:"inline-flex rounded-lg bg-surface-900 p-1",children:C.map(e=>(0,r.jsx)("button",{onClick:()=>y(e.value),className:"rounded-md px-3 py-1.5 text-xs font-medium transition-colors ".concat(v===e.value?"bg-surface-750 text-white":"text-gray-400 hover:text-gray-300"),children:e.label},e.value))})]}),(0,r.jsxs)("div",{className:"flex gap-4 flex-1 min-h-0 mt-4",children:[(0,r.jsx)("div",{className:"w-1/3 min-w-[280px] max-w-[400px] shrink-0 overflow-y-auto rounded-xl border border-white/[0.06] bg-surface-900 p-2",children:b?(0,r.jsx)(d.G,{rows:6}):0===g.length?(0,r.jsx)("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"No sessions found"})}):(0,r.jsx)("div",{className:"space-y-0.5",children:g.map(e=>(0,r.jsxs)("button",{onClick:()=>E(e.id),className:"w-full text-left rounded-lg px-3 py-3 transition-colors ".concat(e.id===o?"bg-primary-500/10 border border-primary-500/30":"border border-transparent hover:bg-white/[0.03]"),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.jsx)("span",{className:"font-mono text-xs text-primary-400 truncate",children:e.id.slice(0,12)}),(0,r.jsx)(k,{status:e.status})]}),(0,r.jsx)("span",{className:"text-[10px] text-gray-600 shrink-0",children:m(e.last_activity_at)})]}),e.repo_full_name&&(0,r.jsx)("p",{className:"mt-1 text-xs text-gray-400 truncate pl-0",children:e.repo_full_name}),e.current_task&&(0,r.jsx)("p",{className:"mt-0.5 text-[10px] text-gray-600 truncate",children:e.current_task})]},e.id))})}),(0,r.jsx)("div",{className:"flex-1 min-w-0 overflow-y-auto rounded-xl border border-white/[0.06] bg-surface-900 p-5",children:o?S?(0,r.jsx)(d.G,{rows:4}):N?(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsx)("div",{className:"flex items-start justify-between",children:(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("h2",{className:"text-base font-semibold text-white",children:"Session"}),(0,r.jsx)(k,{status:N.status})]}),N.repo_full_name&&(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-400",children:N.repo_full_name})]})}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-x-6 gap-y-2 text-xs sm:grid-cols-3",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-gray-600",children:"Agent "}),(0,r.jsx)("span",{className:"text-gray-300",children:null!=(t=N.agent_type)?t:"claude"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-gray-600",children:"Duration "}),(0,r.jsx)("span",{className:"text-gray-300",children:p(N.started_at,N.ended_at)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-gray-600",children:"Files "}),(0,r.jsx)("span",{className:"text-gray-300",children:N.files_changed})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-gray-600",children:"Started "}),(0,r.jsx)("span",{className:"text-gray-300",children:h(N.started_at)})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-gray-600",children:"Last Activity "}),(0,r.jsx)("span",{className:"text-gray-300",children:h(N.last_activity_at)})]})]}),N.current_task&&(0,r.jsxs)("div",{className:"rounded-lg border border-white/[0.06] bg-surface-950/50 px-3 py-2",children:[(0,r.jsx)("span",{className:"text-[9px] font-medium uppercase tracking-widest text-gray-600",children:"Current Task"}),(0,r.jsx)("p",{className:"mt-1 text-xs text-gray-300",children:N.current_task})]}),N.output_tail&&(0,r.jsxs)("div",{className:"rounded-lg border border-white/[0.06] bg-surface-950 overflow-hidden",children:[(0,r.jsx)("div",{className:"border-b border-white/[0.06] px-3 py-1.5",children:(0,r.jsx)("span",{className:"text-[10px] font-medium text-gray-500",children:"Output"})}),(0,r.jsx)("div",{className:"px-3 py-2 max-h-64 overflow-y-auto",children:(0,r.jsx)("pre",{className:"whitespace-pre-wrap break-all text-[10px] font-mono text-gray-500",children:N.output_tail})})]})]}):(0,r.jsx)(x.p,{title:"Session not found",description:"Could not load session details."}):(0,r.jsxs)("div",{className:"flex h-full flex-col items-center justify-center text-center",children:[(0,r.jsx)("svg",{className:"h-10 w-10 text-gray-700",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25H12"})}),(0,r.jsx)("p",{className:"mt-3 text-sm text-gray-500",children:"Select a session"})]})})]})]})}function _(){let e=(0,n.J)();return(0,r.jsx)(a.Suspense,{fallback:(0,r.jsx)("div",{}),children:e?(0,r.jsx)(N,{}):(0,r.jsx)(S,{})})}}},e=>{e.O(0,[8934,814,9743,7358],()=>e(e.s=759)),_N_E=e.O()}]);