chorus-codes 0.8.1 → 0.8.3

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 (102) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +2 -2
  3. package/.next/prerender-manifest.json +3 -3
  4. package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  5. package/.next/server/app/_global-error.html +1 -1
  6. package/.next/server/app/_global-error.rsc +1 -1
  7. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  8. package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  12. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  13. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  14. package/.next/server/app/_not-found.html +1 -1
  15. package/.next/server/app/_not-found.rsc +1 -1
  16. package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  17. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  18. package/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  19. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  20. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  21. package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  22. package/.next/server/app/api/daemon/[...path]/route.js +1 -1
  23. package/.next/server/app/connect/page_client-reference-manifest.js +1 -1
  24. package/.next/server/app/demo/[scenario]/page_client-reference-manifest.js +1 -1
  25. package/.next/server/app/new/page.js +1 -1
  26. package/.next/server/app/new/page_client-reference-manifest.js +1 -1
  27. package/.next/server/app/new.html +1 -1
  28. package/.next/server/app/new.rsc +2 -2
  29. package/.next/server/app/new.segments/_full.segment.rsc +2 -2
  30. package/.next/server/app/new.segments/_head.segment.rsc +1 -1
  31. package/.next/server/app/new.segments/_index.segment.rsc +1 -1
  32. package/.next/server/app/new.segments/_tree.segment.rsc +1 -1
  33. package/.next/server/app/new.segments/new/__PAGE__.segment.rsc +2 -2
  34. package/.next/server/app/new.segments/new.segment.rsc +1 -1
  35. package/.next/server/app/onboarding/page_client-reference-manifest.js +1 -1
  36. package/.next/server/app/onboarding.html +1 -1
  37. package/.next/server/app/onboarding.rsc +2 -2
  38. package/.next/server/app/onboarding.segments/_full.segment.rsc +2 -2
  39. package/.next/server/app/onboarding.segments/_head.segment.rsc +1 -1
  40. package/.next/server/app/onboarding.segments/_index.segment.rsc +1 -1
  41. package/.next/server/app/onboarding.segments/_tree.segment.rsc +1 -1
  42. package/.next/server/app/onboarding.segments/onboarding/__PAGE__.segment.rsc +2 -2
  43. package/.next/server/app/onboarding.segments/onboarding.segment.rsc +1 -1
  44. package/.next/server/app/page_client-reference-manifest.js +1 -1
  45. package/.next/server/app/personas/page_client-reference-manifest.js +1 -1
  46. package/.next/server/app/personas.html +1 -1
  47. package/.next/server/app/personas.rsc +2 -2
  48. package/.next/server/app/personas.segments/_full.segment.rsc +2 -2
  49. package/.next/server/app/personas.segments/_head.segment.rsc +1 -1
  50. package/.next/server/app/personas.segments/_index.segment.rsc +1 -1
  51. package/.next/server/app/personas.segments/_tree.segment.rsc +1 -1
  52. package/.next/server/app/personas.segments/personas/__PAGE__.segment.rsc +2 -2
  53. package/.next/server/app/personas.segments/personas.segment.rsc +1 -1
  54. package/.next/server/app/runs/[runId]/page_client-reference-manifest.js +1 -1
  55. package/.next/server/app/runs/page_client-reference-manifest.js +1 -1
  56. package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  57. package/.next/server/app/settings/permissions/page.js +1 -1
  58. package/.next/server/app/settings/permissions/page_client-reference-manifest.js +1 -1
  59. package/.next/server/app/settings.html +1 -1
  60. package/.next/server/app/settings.rsc +2 -2
  61. package/.next/server/app/settings.segments/_full.segment.rsc +2 -2
  62. package/.next/server/app/settings.segments/_head.segment.rsc +1 -1
  63. package/.next/server/app/settings.segments/_index.segment.rsc +1 -1
  64. package/.next/server/app/settings.segments/_tree.segment.rsc +1 -1
  65. package/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +2 -2
  66. package/.next/server/app/settings.segments/settings.segment.rsc +1 -1
  67. package/.next/server/app/templates/page.js +1 -1
  68. package/.next/server/app/templates/page_client-reference-manifest.js +1 -1
  69. package/.next/server/app/templates.html +1 -1
  70. package/.next/server/app/templates.rsc +2 -2
  71. package/.next/server/app/templates.segments/_full.segment.rsc +2 -2
  72. package/.next/server/app/templates.segments/_head.segment.rsc +1 -1
  73. package/.next/server/app/templates.segments/_index.segment.rsc +1 -1
  74. package/.next/server/app/templates.segments/_tree.segment.rsc +1 -1
  75. package/.next/server/app/templates.segments/templates/__PAGE__.segment.rsc +2 -2
  76. package/.next/server/app/templates.segments/templates.segment.rsc +1 -1
  77. package/.next/server/chunks/681.js +1 -1
  78. package/.next/server/chunks/946.js +1 -1
  79. package/.next/server/middleware-build-manifest.js +1 -1
  80. package/.next/server/pages/404.html +1 -1
  81. package/.next/server/pages/500.html +1 -1
  82. package/.next/server/server-reference-manifest.json +1 -1
  83. package/.next/static/chunks/641-8ba70af28d6509c0.js +1 -0
  84. package/.next/static/chunks/app/new/{page-e84d8e7864dd8059.js → page-2211cfc5ff439235.js} +1 -1
  85. package/.next/static/chunks/app/templates/{page-9d588b21525591e0.js → page-e6ce9f999d32c417.js} +1 -1
  86. package/.next/trace +20 -20
  87. package/.next/trace-build +1 -1
  88. package/dist/daemon/index.js +37 -9
  89. package/dist/daemon/index.js.map +1 -1
  90. package/dist/daemon/routes/chats.js +8 -0
  91. package/dist/daemon/routes/chats.js.map +1 -1
  92. package/dist/daemon/template-adapter.js +203 -0
  93. package/dist/daemon/template-adapter.js.map +1 -0
  94. package/dist/lib/db/connection.js +8 -0
  95. package/dist/lib/db/connection.js.map +1 -1
  96. package/dist/lib/db/schema.sql +6 -0
  97. package/dist/lib/db/templates.js +19 -4
  98. package/dist/lib/db/templates.js.map +1 -1
  99. package/package.json +1 -1
  100. package/.next/static/chunks/641-9a68e56c49410f66.js +0 -1
  101. /package/.next/static/{bbzOQo_mKxMPrYmXUbnSg → yHKRgofXZrcF6ayBirqri}/_buildManifest.js +0 -0
  102. /package/.next/static/{bbzOQo_mKxMPrYmXUbnSg → yHKRgofXZrcF6ayBirqri}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- <!DOCTYPE html><html id="__next_error__"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-87142ab87b87c8fb.js"/><script src="/_next/static/chunks/ed64ccb0-b7d2b5246d18ca7e.js" async=""></script><script src="/_next/static/chunks/128-a5d059bf5b2e5090.js" async=""></script><script src="/_next/static/chunks/main-app-e9f7985e32dc8a63.js" async=""></script><meta name="next-size-adjust" content=""/><title>500: This page couldn’t load</title><style>:root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }</style><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;display:flex;align-items:center;justify-content:center"><div style="margin-top:-32px;max-width:325px;padding:32px 28px;text-align:left"><svg width="32" height="32" viewBox="-0.2 -1.5 32 32" fill="none" style="margin-bottom:24px"><path d="M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z" fill="var(--next-error-title)"></path></svg><h1 style="font-size:24px;font-weight:500;letter-spacing:-0.02em;line-height:32px;margin:0 0 12px 0;color:var(--next-error-title)">This page couldn’t load</h1><p style="font-size:14px;font-weight:400;line-height:21px;margin:0 0 20px 0;color:var(--next-error-message)">A server error occurred. Reload to try again.</p><form style="margin:0"><button type="submit" style="display:inline-flex;align-items:center;justify-content:center;height:32px;padding:0 12px;font-size:14px;font-weight:500;line-height:20px;border-radius:6px;cursor:pointer;color:var(--next-error-btn-text);background:var(--next-error-btn-bg);border:var(--next-error-btn-border)">Reload</button></form></div></div><!--$--><!--/$--><script src="/_next/static/chunks/webpack-87142ab87b87c8fb.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[5484,[],\"\"]\n3:I[5482,[],\"\"]\n4:I[5017,[],\"OutletBoundary\"]\n5:\"$Sreact.suspense\"\n8:I[5017,[],\"ViewportBoundary\"]\na:I[5017,[],\"MetadataBoundary\"]\nc:I[3720,[],\"default\",1]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"c\":[\"\",\"_global-error\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"_global-error\",{\"children\":[\"__PAGE__\",{}]}]}],[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[\"$\",\"html\",null,{\"id\":\"__next_error__\",\"children\":[[\"$\",\"head\",null,{\"children\":[[\"$\",\"title\",null,{\"children\":\"500: This page couldn’t load\"}],[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\":root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }\"}}]]}],[\"$\",\"body\",null,{\"children\":[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"display\":\"flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"style\":{\"marginTop\":\"-32px\",\"maxWidth\":\"325px\",\"padding\":\"32px 28px\",\"textAlign\":\"left\"},\"children\":[[\"$\",\"svg\",null,{\"width\":\"32\",\"height\":\"32\",\"viewBox\":\"-0.2 -1.5 32 32\",\"fill\":\"none\",\"style\":{\"marginBottom\":\"24px\"},\"children\":[\"$\",\"path\",null,{\"d\":\"M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z\",\"fill\":\"var(--next-error-title)\"}]}],[\"$\",\"h1\",null,{\"style\":{\"fontSize\":\"24px\",\"fontWeight\":500,\"letterSpacing\":\"-0.02em\",\"lineHeight\":\"32px\",\"margin\":\"0 0 12px 0\",\"color\":\"var(--next-error-title)\"},\"children\":\"This page couldn’t load\"}],[\"$\",\"p\",null,{\"style\":{\"fontSize\":\"14px\",\"fontWeight\":400,\"lineHeight\":\"21px\",\"margin\":\"0 0 20px 0\",\"color\":\"var(--next-error-message)\"},\"children\":\"A server error occurred. Reload to try again.\"}],[\"$\",\"form\",null,{\"style\":{\"margin\":0},\"children\":[\"$\",\"button\",null,{\"type\":\"submit\",\"style\":{\"display\":\"inline-flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\",\"height\":\"32px\",\"padding\":\"0 12px\",\"fontSize\":\"14px\",\"fontWeight\":500,\"lineHeight\":\"20px\",\"borderRadius\":\"6px\",\"cursor\":\"pointer\",\"color\":\"var(--next-error-btn-text)\",\"background\":\"var(--next-error-btn-bg)\",\"border\":\"var(--next-error-btn-border)\"},\"children\":\"Reload\"}]}]]}]}]}]]}],null,[\"$\",\"$L4\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@6\"}]}]]}],{},null,false,null]},null,false,\"$@7\"]},null,false,\"$@7\"],[\"$\",\"$1\",\"h\",{\"children\":[null,[\"$\",\"$L8\",null,{\"children\":\"$L9\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$La\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.Metadata\",\"children\":\"$Lb\"}]}]}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$c\",[]],\"S\":true,\"h\":null,\"s\":\"$undefined\",\"l\":\"$undefined\",\"p\":\"$undefined\",\"d\":\"$undefined\",\"b\":\"bbzOQo_mKxMPrYmXUbnSg\"}\n"])</script><script>self.__next_f.push([1,"d:[]\n7:\"$Wd\"\n"])</script><script>self.__next_f.push([1,"9:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])</script><script>self.__next_f.push([1,"6:null\nb:[]\n"])</script></body></html>
1
+ <!DOCTYPE html><html id="__next_error__"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/webpack-87142ab87b87c8fb.js"/><script src="/_next/static/chunks/ed64ccb0-b7d2b5246d18ca7e.js" async=""></script><script src="/_next/static/chunks/128-a5d059bf5b2e5090.js" async=""></script><script src="/_next/static/chunks/main-app-e9f7985e32dc8a63.js" async=""></script><meta name="next-size-adjust" content=""/><title>500: This page couldn’t load</title><style>:root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }</style><script src="/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;display:flex;align-items:center;justify-content:center"><div style="margin-top:-32px;max-width:325px;padding:32px 28px;text-align:left"><svg width="32" height="32" viewBox="-0.2 -1.5 32 32" fill="none" style="margin-bottom:24px"><path d="M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z" fill="var(--next-error-title)"></path></svg><h1 style="font-size:24px;font-weight:500;letter-spacing:-0.02em;line-height:32px;margin:0 0 12px 0;color:var(--next-error-title)">This page couldn’t load</h1><p style="font-size:14px;font-weight:400;line-height:21px;margin:0 0 20px 0;color:var(--next-error-message)">A server error occurred. Reload to try again.</p><form style="margin:0"><button type="submit" style="display:inline-flex;align-items:center;justify-content:center;height:32px;padding:0 12px;font-size:14px;font-weight:500;line-height:20px;border-radius:6px;cursor:pointer;color:var(--next-error-btn-text);background:var(--next-error-btn-bg);border:var(--next-error-btn-border)">Reload</button></form></div></div><!--$--><!--/$--><script src="/_next/static/chunks/webpack-87142ab87b87c8fb.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[5484,[],\"\"]\n3:I[5482,[],\"\"]\n4:I[5017,[],\"OutletBoundary\"]\n5:\"$Sreact.suspense\"\n8:I[5017,[],\"ViewportBoundary\"]\na:I[5017,[],\"MetadataBoundary\"]\nc:I[3720,[],\"default\",1]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"c\":[\"\",\"_global-error\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"_global-error\",{\"children\":[\"__PAGE__\",{}]}]}],[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[\"$\",\"html\",null,{\"id\":\"__next_error__\",\"children\":[[\"$\",\"head\",null,{\"children\":[[\"$\",\"title\",null,{\"children\":\"500: This page couldn’t load\"}],[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\":root {--next-error-bg: #fff;--next-error-text: #171717;--next-error-title: #171717;--next-error-message: #171717;--next-error-digest: #666666;--next-error-btn-text: #fff;--next-error-btn-bg: #171717;--next-error-btn-border: none;--next-error-btn-secondary-text: #171717;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);}@media (prefers-color-scheme: dark) {:root {--next-error-bg: #0a0a0a;--next-error-text: #ededed;--next-error-title: #ededed;--next-error-message: #ededed;--next-error-digest: #a0a0a0;--next-error-btn-text: #0a0a0a;--next-error-btn-bg: #ededed;--next-error-btn-border: none;--next-error-btn-secondary-text: #ededed;--next-error-btn-secondary-bg: transparent;--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);}}body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }\"}}]]}],[\"$\",\"body\",null,{\"children\":[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"display\":\"flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"style\":{\"marginTop\":\"-32px\",\"maxWidth\":\"325px\",\"padding\":\"32px 28px\",\"textAlign\":\"left\"},\"children\":[[\"$\",\"svg\",null,{\"width\":\"32\",\"height\":\"32\",\"viewBox\":\"-0.2 -1.5 32 32\",\"fill\":\"none\",\"style\":{\"marginBottom\":\"24px\"},\"children\":[\"$\",\"path\",null,{\"d\":\"M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z\",\"fill\":\"var(--next-error-title)\"}]}],[\"$\",\"h1\",null,{\"style\":{\"fontSize\":\"24px\",\"fontWeight\":500,\"letterSpacing\":\"-0.02em\",\"lineHeight\":\"32px\",\"margin\":\"0 0 12px 0\",\"color\":\"var(--next-error-title)\"},\"children\":\"This page couldn’t load\"}],[\"$\",\"p\",null,{\"style\":{\"fontSize\":\"14px\",\"fontWeight\":400,\"lineHeight\":\"21px\",\"margin\":\"0 0 20px 0\",\"color\":\"var(--next-error-message)\"},\"children\":\"A server error occurred. Reload to try again.\"}],[\"$\",\"form\",null,{\"style\":{\"margin\":0},\"children\":[\"$\",\"button\",null,{\"type\":\"submit\",\"style\":{\"display\":\"inline-flex\",\"alignItems\":\"center\",\"justifyContent\":\"center\",\"height\":\"32px\",\"padding\":\"0 12px\",\"fontSize\":\"14px\",\"fontWeight\":500,\"lineHeight\":\"20px\",\"borderRadius\":\"6px\",\"cursor\":\"pointer\",\"color\":\"var(--next-error-btn-text)\",\"background\":\"var(--next-error-btn-bg)\",\"border\":\"var(--next-error-btn-border)\"},\"children\":\"Reload\"}]}]]}]}]}]]}],null,[\"$\",\"$L4\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@6\"}]}]]}],{},null,false,null]},null,false,\"$@7\"]},null,false,\"$@7\"],[\"$\",\"$1\",\"h\",{\"children\":[null,[\"$\",\"$L8\",null,{\"children\":\"$L9\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$La\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.Metadata\",\"children\":\"$Lb\"}]}]}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$c\",[]],\"S\":true,\"h\":null,\"s\":\"$undefined\",\"l\":\"$undefined\",\"p\":\"$undefined\",\"d\":\"$undefined\",\"b\":\"yHKRgofXZrcF6ayBirqri\"}\n"])</script><script>self.__next_f.push([1,"d:[]\n7:\"$Wd\"\n"])</script><script>self.__next_f.push([1,"9:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])</script><script>self.__next_f.push([1,"6:null\nb:[]\n"])</script></body></html>
@@ -1 +1 @@
1
- {"node":{},"edge":{},"encryptionKey":"MP0lwzfdNILe0fOrPiLkaEB/UYt4ktGTGehEIK1+cuE="}
1
+ {"node":{},"edge":{},"encryptionKey":"lCyd9pFRIwXJ+1WvT3V2GPzSUQROzh30CQd9s6gJ3XM="}
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[641],{1993:(e,t,n)=>{n.d(t,{K7:()=>c,UT:()=>i,dW:()=>a,qI:()=>s});var r=n(4411);function o(e){return{id:e.id,label:e.label,one_liner:e.one_liner,system_prompt:e.system_prompt,recommended_lineage:e.recommended_lineage,builtin:!!e.builtin,forked_from:e.forked_from??null,created_at:e.created_at,updated_at:e.updated_at}}async function i(){return(await (0,r.T)("/personas")).items.map(o)}async function a(e){return o(await (0,r.T)(`/personas/${encodeURIComponent(e)}`))}async function s(e){return o(await (0,r.T)("/personas",{method:"POST",body:JSON.stringify(e)}))}async function c(e){await (0,r.T)(`/personas/${encodeURIComponent(e)}`,{method:"DELETE"})}},4284:(e,t,n)=>{n.d(t,{U:()=>o});var r=n(9442);function o({className:e}){return(0,r.jsxs)("svg",{viewBox:"0 0 32 32","aria-hidden":"true",className:e,fill:"currentColor",children:[(0,r.jsx)("circle",{cx:"11",cy:"20",r:"3.2",fillOpacity:"0.55"}),(0,r.jsx)("circle",{cx:"21",cy:"20",r:"3.2",fillOpacity:"0.55"}),(0,r.jsx)("circle",{cx:"16",cy:"11",r:"3.2"})]})}},4411:(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{$:()=>DaemonError,T:()=>fetchFromDaemon});var process=__webpack_require__(9298);let CLIENT_BASE="/api/daemon",API_PREFIX="/api/v1",cachedServerBase=null;function readDaemonJsonSync(){try{let dynRequire="function"==typeof globalThis.require?globalThis.require:eval("require");if(!dynRequire)return null;let fs=dynRequire("node:fs"),path=dynRequire("node:path"),os=dynRequire("node:os"),target=path.join(os.homedir(),".chorus","daemon.json"),raw=fs.readFileSync(target,"utf-8"),parsed=JSON.parse(raw);if(1!==parsed.schemaVersion||"number"!=typeof parsed.daemonPort)return null;return{daemonPort:parsed.daemonPort}}catch{return null}}async function getServerBase(){if(cachedServerBase)return cachedServerBase;let e=readDaemonJsonSync();return cachedServerBase=e?`http://127.0.0.1:${e.daemonPort}`:process.env.CHORUS_DAEMON_URL?process.env.CHORUS_DAEMON_URL:"http://127.0.0.1:7707"}async function getBaseUrl(){return new URL(CLIENT_BASE,window.location.origin).toString()}class DaemonError extends Error{constructor(e,t,n,r){super(n),this.code=e,this.statusCode=t,this.details=r,this.name="DaemonError"}}async function fetchFromDaemon(e,t={}){let n=await getBaseUrl(),r=e.startsWith("/")?e:`/${e}`,o=r===API_PREFIX||r.startsWith(`${API_PREFIX}/`)?r:`${API_PREFIX}${r}`,i=`${n.replace(/\/$/,"")}${o}`;try{let e=await fetch(i,{...t,headers:{"Content-Type":"application/json",...t.headers}}),n=await e.json().catch(()=>({ok:!1,error:{code:"parse_error",message:"Failed to parse response"}})),r=n;if(!r.ok){let t=n;if("string"==typeof t.error&&"string"==typeof t.message)throw new DaemonError(t.error,e.status,t.message);throw new DaemonError(r.error?.code||"unknown",e.status,r.error?.message||`Daemon returned ${e.status}`,r.error?.details)}return r.data}catch(e){if(e instanceof DaemonError)throw e;if(e instanceof TypeError&&e.message.includes("fetch"))throw cachedServerBase=null,new DaemonError("connection_failed",0,"Failed to connect to Chorus daemon. Is it running?");throw new DaemonError("unknown",0,e instanceof Error?e.message:"Unknown error")}}},6185:(e,t,n)=>{n.d(t,{$v:()=>r.$,jb:()=>T.jb,RL:()=>a,K7:()=>v.K7,I7:()=>y,dW:()=>v.dW,Ih:()=>i,UT:()=>v.UT,eG:()=>m,qI:()=>v.qI,AI:()=>h,Xx:()=>g.Xx,WH:()=>g.WH});var r=n(4411);function o(e){let t;if(e.attached_files)try{let n=JSON.parse(e.attached_files);Array.isArray(n)&&(t=n)}catch{}return{id:e.id,slug:e.slug??void 0,work:e.work,templateId:e.template_id,status:e.status,currentPhaseIdx:e.current_phase_idx??0,yolo:!!e.yolo,attachedFiles:t,repoPath:e.repo_path??void 0,prUrl:e.pr_url??void 0,shipError:e.ship_error??void 0,artifact:e.artifact??void 0,verdict:e.verdict??void 0,createdAt:e.created_at,updatedAt:e.updated_at,finishedAt:e.finished_at??void 0}}async function i(e){let t=new URLSearchParams;e?.limit&&t.append("limit",e.limit.toString()),e?.offset&&t.append("offset",e.offset.toString()),e?.status&&t.append("status",e.status);let n=t.toString();return(await (0,r.T)(`/chats${n?`?${n}`:""}`)).items.map(o)}async function a(e){return o(await (0,r.T)("/chats",{method:"POST",body:JSON.stringify(e)}))}var s=n(599);let c=new Set(["anthropic","openai","google","opencode","moonshot","any","xai"]),d={anthropic:"claude",openai:"codex",google:"gemini",opencode:"opencode",moonshot:"kimi",any:"claude",xai:"opencode"};function u(e){return e?d[e]??"claude":"claude"}function l(e,t){if(e.category)return e.category;let n=t.toLowerCase();return n.includes("bug")||n.includes("debug")||n.includes("diagnose")?"debug":n.includes("plan")||n.includes("architect")?"plan":n.includes("decide")||n.includes("decision")?"decide":"review"}function f(e){let t=e.kind??"review";return{id:e.id??"phase",name:e.title??e.name??e.id??"Phase",description:e.description??"",kind:t,gate:"auto",doer:{lineage:u(e.doer?.lineage),models:e.doer?.models??[],...e.doer?.persona?{persona:e.doer.persona}:{}},reviewer:{require:e.reviewer?.require??1,crossLineage:e.reviewer?.crossLineage??!0,candidates:(e.reviewer?.candidates??[]).map(e=>u(e.lineage)).filter(e=>c.has(Object.keys(d).find(t=>d[t]===e)??"")),candidatesWithModels:(e.reviewer?.candidates??[]).map(e=>({lineage:u(e.lineage),models:e.models??[],...e.persona?{persona:e.persona}:{}}))},inputs:{include:e.inputs?.include??[],exclude:e.inputs?.exclude??[]},iterate:{max:e.iterate?.maxRounds??2,onMax:"ask-user"},blindSpots:[],execution:"parallel",builtin:!0,..."review_only"===t?{artifact:{label:e.artifact?.label??"Artifact to review",hint:e.artifact?.hint??"Paste a unified diff, a markdown draft, code, or any text blob.",maxBytes:e.artifact?.maxBytes??1048576}}:{}}}function p(e){let t={};try{t=s.Ay.parse(e.yaml)??{}}catch{}let n="majority";"number"==typeof t.agreementThreshold?n=t.agreementThreshold>=.99?"unanimous":t.agreementThreshold>=.5?"majority":"any":"string"==typeof t.agreementThreshold&&(n=t.agreementThreshold);let r=(t.phases??[]).map(f);return{id:e.id,name:t.name??e.id,description:t.description??"",category:l(t,e.id),phases:r,agreementThreshold:n,onThresholdMet:"auto-finalize"===t.onThresholdMet?"auto-finalize":"ask-user",maxRounds:t.maxRounds??3,driver:"external",driverHandoff:!1,verificationGate:"auto",costCapUsd:0,yoloDefault:t.yoloDefault??!1,estimatedBaselineTokens:t.estimatedBaselineTokens,onError:"ask-user",notify:"dashboard-only",yaml:e.yaml,authorHandle:t.author??"chorus",forks:0,popularity:0,source:e.source,isComplete:"number"==typeof e.is_complete?0!==e.is_complete:!1!==e.is_complete}}async function m(){return(await (0,r.T)("/templates")).items.map(p)}async function h(e){return p(await (0,r.T)("/templates",{method:"POST",body:JSON.stringify(e)}))}async function y(e){await (0,r.T)(`/templates/${encodeURIComponent(e)}`,{method:"DELETE"})}var g=n(6441),T=n(8141),v=n(1993);n(7847)},6441:(e,t,n)=>{n.d(t,{A1:()=>f,Ci:()=>p,Df:()=>a,Dl:()=>l,Ep:()=>s,WH:()=>h,WK:()=>m,Xx:()=>c,fk:()=>o,iW:()=>i,nr:()=>u,oD:()=>d});var r=n(4411);async function o(){return(await (0,r.T)("/onboard/detect-clis")).items}async function i(e,t){return(0,r.T)("/onboard/validate-cli-path",{method:"POST",body:JSON.stringify({id:e,path:t})})}async function a(e,t){return(0,r.T)("/onboard/save-cli-path",{method:"POST",body:JSON.stringify({id:e,path:t})})}async function s(e){return(0,r.T)("/settings/permissions",{method:"PUT",body:JSON.stringify(e)})}async function c(e){return(0,r.T)("/settings",{method:"PUT",body:JSON.stringify(e)})}async function d(){return(0,r.T)("/settings/transport")}async function u(e){return(0,r.T)("/settings/transport",{method:"PUT",body:JSON.stringify(e)})}async function l(){return(0,r.T)("/settings/billing")}async function f(e){return(0,r.T)("/settings/billing",{method:"PUT",body:JSON.stringify(e)})}async function p(){return(0,r.T)("/settings/telemetry")}async function m(e){return(0,r.T)("/settings/telemetry",{method:"PUT",body:JSON.stringify({enabled:e})})}async function h(e,t){return(0,r.T)(`/secrets/${e}`,{method:"PUT",body:JSON.stringify(t)})}},7362:(e,t,n)=>{n.d(t,{cn:()=>i});var r=n(142),o=n(9317);function i(...e){return(0,o.QP)((0,r.$)(e))}},7847:(e,t,n)=>{n.d(t,{createVoice:()=>s,listVoices:()=>i,updateVoice:()=>a});var r=n(4411);function o(e){if(!e)return"";let t=[];return e.lineage&&t.push(`lineage=${encodeURIComponent(e.lineage)}`),e.source&&t.push(`source=${encodeURIComponent(e.source)}`),e.provider&&t.push(`provider=${encodeURIComponent(e.provider)}`),void 0!==e.enabled&&t.push(`enabled=${e.enabled?"true":"false"}`),0===t.length?"":`?${t.join("&")}`}async function i(e){return(await (0,r.T)(`/voices${o(e)}`)).items}async function a(e,t){return(0,r.T)(`/voices/${encodeURIComponent(e)}`,{method:"PUT",body:JSON.stringify(t)})}async function s(e){return(0,r.T)("/voices",{method:"POST",body:JSON.stringify(e)})}},8141:(e,t,n)=>{n.d(t,{Ay:()=>i,jb:()=>o});var r=n(4411);async function o(e){return(0,r.T)(`/orchestrators/${e}/connect`,{method:"POST"})}async function i(){return(0,r.T)("/orchestrators/opencode/models")}}}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[359],{63:(e,t,r)=>{"use strict";r.d(t,{Zp:()=>n});var s=r(9442);r(6074);var a=r(7362);function n({className:e,...t}){return(0,s.jsx)("div",{"data-slot":"card",className:(0,a.cn)("flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm",e),...t})}},862:(e,t,r)=>{"use strict";function s(e){return!!e&&e.phases[0]?.kind==="review_only"}r.d(t,{$:()=>s})},2471:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(3884).A)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]])},2919:(e,t,r)=>{Promise.resolve().then(r.bind(r,6141))},3734:(e,t,r)=>{"use strict";r.d(t,{JR:()=>c,QJ:()=>n,VW:()=>o,YM:()=>m,m_:()=>i,r2:()=>x,u5:()=>l,x0:()=>u,ze:()=>s});let s={anthropic:"Claude",openai:"Codex",google:"Gemini",opencode:"OpenCode",moonshot:"Kimi"},a={anthropic:"bg-violet-400",openai:"bg-orange-400",google:"bg-blue-400",opencode:"bg-emerald-400",moonshot:"bg-pink-400"};function n(e){return e?s[e]??e:""}function o(e){return e?a[e]??"bg-muted":"bg-muted"}let i={claude:"Claude",codex:"Codex",gemini:"Gemini",opencode:"OpenCode",kimi:"Kimi",openrouter:"OpenRouter"},d={claude:"bg-violet-400",codex:"bg-orange-400",gemini:"bg-blue-400",opencode:"bg-emerald-400",kimi:"bg-pink-400",openrouter:"bg-cyan-400"};function l(e){return e?i[e]??e:""}function c(e){return e?d[e]??"bg-muted":"bg-muted"}let u={claude:"claude-opus-4-7",codex:"gpt-5.5",gemini:"gemini-3.1-pro-preview",opencode:"kimi-k2.6",kimi:"kimi-k2.6",openrouter:""};function m(e){if(e)return u[e]}let x={claude:{dot:"bg-violet-400",ring:"ring-violet-400/40",gradient:"bg-gradient-to-b from-violet-500/15 to-card"},codex:{dot:"bg-orange-400",ring:"ring-orange-400/40",gradient:"bg-gradient-to-b from-orange-500/15 to-card"},gemini:{dot:"bg-blue-400",ring:"ring-blue-400/40",gradient:"bg-gradient-to-b from-blue-500/15 to-card"},opencode:{dot:"bg-emerald-400",ring:"ring-emerald-400/40",gradient:"bg-gradient-to-b from-emerald-500/15 to-card"},kimi:{dot:"bg-pink-400",ring:"ring-pink-400/40",gradient:"bg-gradient-to-b from-pink-500/15 to-card"},openrouter:{dot:"bg-cyan-400",ring:"ring-cyan-400/40",gradient:"bg-gradient-to-b from-cyan-500/15 to-card"}}},4372:(e,t,r)=>{"use strict";r.d(t,{G:()=>o});var s=r(9442),a=r(821),n=r(8344);function o({children:e}){return(0,s.jsxs)("div",{className:"flex h-screen w-screen overflow-hidden bg-background text-foreground",children:[(0,s.jsx)(a.AppSidebar,{}),(0,s.jsxs)("div",{className:"flex flex-1 flex-col overflow-hidden",children:[(0,s.jsx)(n.MobileTopBar,{}),(0,s.jsx)("main",{className:"flex-1 overflow-y-auto",children:e})]})]})}},5702:(e,t,r)=>{"use strict";r.d(t,{E:()=>d});var s=r(9442);r(6074);var a=r(9056),n=r(8113),o=r(7362);let i=(0,a.F)("inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3",{variants:{variant:{default:"bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90",outline:"border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",ghost:"[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",link:"text-primary underline-offset-4 [a&]:hover:underline"}},defaultVariants:{variant:"default"}});function d({className:e,variant:t="default",asChild:r=!1,...a}){let l=r?n.bL:"span";return(0,s.jsx)(l,{"data-slot":"badge","data-variant":t,className:(0,o.cn)(i({variant:t}),e),...a})}},6141:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>N});var s=r(9442),a=r(8821),n=r(2471),o=r(5902),i=r(6074),d=r(4372),l=r(6457),c=r(5702),u=r(6185),m=r(6441),x=r(862);function p({icon:e,label:t,value:r,wide:a,children:n}){let[o,d]=(0,i.useState)(!1);return(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>d(e=>!e),className:"flex items-center gap-2 rounded-md border border-border bg-card px-3 py-1.5 text-sm transition hover:border-muted-foreground/40",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:e}),(0,s.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:t}),(0,s.jsx)("span",{className:"font-medium",children:r})]}),o&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"fixed inset-0 z-10",onClick:()=>d(!1)}),(0,s.jsx)("div",{className:`absolute left-0 top-full z-20 mt-1 rounded-md border border-border bg-popover p-1.5 shadow-xl ${a?"w-80":"w-56"}`,onClick:()=>d(!1),children:n})]})]})}var g=r(6289);let h=(0,r(3884).A)("dollar-sign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);var f=r(63),b=r(3734);function v({template:e,prompt:t,setPrompt:r,reviewOnly:a,artifactSpec:n,billingMode:o,costEstimate:i,overCap:d,isPending:l,onStart:c}){return(0,s.jsxs)(s.Fragment,{children:[a&&n&&(0,s.jsxs)("div",{className:"mb-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[(0,s.jsx)("span",{className:"font-medium text-foreground",children:n.label}),(0,s.jsx)("span",{className:"text-muted-foreground/60",children:"\xb7"}),(0,s.jsxs)("span",{children:["cap ",(n.maxBytes/1024).toLocaleString()," KB"]})]}),(0,s.jsxs)(f.Zp,{className:"overflow-hidden p-0 mb-4",children:[(0,s.jsx)("textarea",{value:t,onChange:e=>r(e.target.value),placeholder:a&&n?n.hint:"Describe what you want chorus to weigh in on. Paste code, errors, design docs — anything the reviewers should see.",className:`block w-full resize-none border-0 bg-transparent px-5 py-4 text-sm text-foreground placeholder:text-muted-foreground/70 focus:outline-none ${a?"font-mono text-[12px] leading-relaxed":""}`,rows:a?16:10,spellCheck:!a}),(0,s.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border bg-card/40 px-5 py-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsx)(j,{template:e,reviewOnly:a}),(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3 sm:justify-end",children:[(0,s.jsx)(y,{billingMode:o,costEstimate:i,overCap:d,template:e}),(0,s.jsxs)("button",{type:"button",onClick:c,disabled:!t||d||l,className:`inline-flex shrink-0 items-center gap-2 whitespace-nowrap rounded-md px-4 py-2 text-sm font-medium transition ${!t||d||l?"cursor-not-allowed bg-muted text-muted-foreground":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:[l?"Starting...":a?"Send for review":"Start the run",(0,s.jsx)(g.A,{className:"h-4 w-4"})]})]})]})]})]})}function j({template:e,reviewOnly:t}){return(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[!t&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:`h-1.5 w-1.5 rounded-full ${(0,b.JR)(e.phases[0]?.doer.lineage)}`}),"Doer: ",e.phases[0]?.doer.lineage]}),(0,s.jsx)("span",{className:"text-muted-foreground/50",children:"\xb7"})]}),(0,s.jsx)(w,{template:e}),e.phases.length>1&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-muted-foreground/50",children:"\xb7"}),(0,s.jsxs)("span",{className:"font-mono text-[10px]",children:[e.phases.length," phases"]})]})]})}function w({template:e}){let t=e.phases[0]?.reviewer.candidatesWithModels??[],r=new Map;for(let e of t)r.set(e.lineage,(r.get(e.lineage)??0)+1);return(0,s.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"text-muted-foreground/80",children:"Reviewers:"}),t.map((e,t)=>{let a=(r.get(e.lineage)??0)>1,n=e.models?.[0]?.split("/").pop()??e.models?.[0],o=a&&n?`${e.lineage} \xb7 ${n}`:e.lineage;return(0,s.jsxs)("span",{className:"flex items-center gap-1",title:e.models?.[0]?`${e.lineage} \xb7 ${e.models[0]}`:e.lineage,children:[(0,s.jsx)("span",{className:`h-1.5 w-1.5 rounded-full ${(0,b.JR)(e.lineage)}`}),o]},`${e.lineage}-${e.models?.[0]??"default"}-${t}`)}),e.phases[0]?.reviewer.crossLineage&&(0,s.jsx)(c.E,{variant:"outline",className:"ml-1 border-border font-mono text-[9px] uppercase",title:"Reviewer must be a different lineage than the doer",children:"cross-lineage"})]})}function y({billingMode:e,costEstimate:t,overCap:r,template:a}){return"subscription"===e?(0,s.jsxs)("div",{className:"flex items-center gap-1.5 font-mono text-[10px] text-muted-foreground",title:`~${t.inputTokens.toLocaleString()} input tokens \xd7 ${t.reviewerCount} reviewers — counts against your CLI subscription quota, not billed per call`,children:["Subscription quota \xb7 ~",t.inputTokens.toLocaleString()," tok"]}):(0,s.jsxs)("div",{className:`flex items-center gap-1.5 font-mono text-[10px] ${r?"text-rose-300":"text-muted-foreground"}`,title:`~${t.inputTokens.toLocaleString()} input tokens \xd7 ${t.reviewerCount} reviewers; up to ${t.maxRounds} round${t.maxRounds>1?"s":""} on disagreement`,children:[(0,s.jsx)(h,{className:"h-3 w-3"}),t.maxRounds>1?`~$${t.usd.toFixed(3)} – $${t.usdRangeMax.toFixed(3)} est`:`~$${t.usd.toFixed(3)} est`,a.costCapUsd>0&&(0,s.jsxs)("span",{className:"text-muted-foreground/60",children:["/ cap $",a.costCapUsd.toFixed(2)]})]})}function N(){return(0,s.jsx)(i.Suspense,{fallback:(0,s.jsx)(d.G,{children:(0,s.jsx)("div",{className:"p-8 text-sm text-muted-foreground",children:"Loading…"})}),children:(0,s.jsx)(k,{})})}function k(){let e=(0,o.useSearchParams)(),t=(0,o.useRouter)(),[r,g]=(0,i.useTransition)(),[h,f]=(0,i.useState)([]),[b,j]=(0,i.useState)(null),[w,y]=(0,i.useState)(null);(0,i.useEffect)(()=>{(0,u.eG)().then(f).catch(e=>j(e instanceof u.$v?e.message:"Failed to load templates"))},[]);let[N,k]=(0,i.useState)("api");(0,i.useEffect)(()=>{(0,m.Dl)().then(e=>k(e.mode)).catch(()=>{})},[]);let $=e.get("template")??h[0]?.id??"",[C,S]=(0,i.useState)(""),R=[],M=h.find(e=>e.id===$)??h[0],E=(0,i.useMemo)(()=>(function(e){let{template:t,prompt:r,attachments:s}=e,a=t?.phases?.[0]?.reviewer?.candidates?.length??3,n=Math.max(1,t?.maxRounds??1),o=Math.ceil(r.length/4)+1500*s.length+(t?.estimatedBaselineTokens??800),i=(3e-6*o+.018000000000000002)*a;return{usd:i,usdRangeMax:i*n,inputTokens:o,reviewerCount:a,maxRounds:n}})({template:M,prompt:C,attachments:R}),[C,R,M]),F=!!("subscription"!==N&&M?.costCapUsd&&M.costCapUsd>0&&E.usdRangeMax>M.costCapUsd),[P,L]=(0,i.useState)(!1),[A,T]=(0,i.useState)(""),O=(0,x.$)(M),G=O?M?.phases?.[0]?.artifact:void 0;async function z(){if(M&&C){if(O&&G){let e=new TextEncoder().encode(C).length;if(e>G.maxBytes)return void y(`Artifact is ${e.toLocaleString()} bytes; this template caps at ${G.maxBytes.toLocaleString()}. Trim it down.`)}y(null),g(async()=>{try{let e=A.trim(),r=await (0,u.RL)({work:O?function(e){let t="Review the supplied artifact independently.";if(!e)return t;for(let t of e.split("\n")){let e=t.trim();if(0===e.length||e.startsWith("```")||e.startsWith("~~~"))continue;if(e.length<=80)return e;let r=e.slice(0,80),s=r.lastIndexOf(" ");return(s>40?r.slice(0,s):r)+"…"}return t}(C):C,templateId:M.id,files:R.length>0?R.map(e=>e.name):void 0,...O?{artifact:C}:{},...!O&&e.length>0?{repoPath:e}:{},yolo:P});t.push(`/runs/${r.slug||r.id}`)}catch(e){y(e instanceof u.$v?e.message:"Failed to create chat")}})}}return b?(0,s.jsx)(d.G,{children:(0,s.jsx)("div",{className:"mx-auto w-full max-w-6xl px-4 py-6 sm:px-6 sm:py-8 md:px-8 md:py-10",children:(0,s.jsxs)("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4",children:[(0,s.jsx)("p",{className:"text-sm text-destructive",children:"Error loading templates"}),(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:b})]})})}):M?(0,s.jsx)(d.G,{children:(0,s.jsxs)("div",{className:"mx-auto w-full max-w-6xl px-4 py-6 sm:px-6 sm:py-8 md:px-8 md:py-10",children:[(0,s.jsx)(l.z,{eyebrow:"New chat",title:O?"Paste an artifact. Get reviews.":"Paste a task. Pick a template.",subtitle:O?"Chorus skips the doer and runs your text past three reviewers. Single pass — revise yourself and resubmit for another round.":"Chorus runs it past your reviewers and reports consensus."}),w&&(0,s.jsx)("div",{className:"mb-4 rounded-lg border border-destructive/50 bg-destructive/10 p-4",children:(0,s.jsx)("p",{className:"text-sm text-destructive",children:w})}),(0,s.jsx)("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:(0,s.jsx)(p,{icon:(0,s.jsx)(a.A,{className:"h-3.5 w-3.5"}),label:"Template",value:M?.name||"Select a template",wide:!0,children:(0,s.jsx)("ul",{className:"space-y-1",children:h.map(r=>(0,s.jsx)("li",{children:(0,s.jsxs)("button",{type:"button",onClick:()=>{let s=new URLSearchParams(e);s.set("template",r.id),t.push(`/new?${s.toString()}`)},className:`block w-full rounded-md p-2 text-left transition ${r.id===$?"bg-accent":"hover:bg-accent/50"}`,children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm font-medium",children:r.name}),(0,x.$)(r)&&(0,s.jsx)(c.E,{variant:"outline",className:"border-blue-500/30 bg-blue-500/10 font-mono text-[9px] uppercase text-blue-300",children:"review only"})]}),(0,s.jsx)("div",{className:"text-xs text-muted-foreground line-clamp-1",children:r.description})]})},r.id))})})}),(0,s.jsx)(v,{template:M,prompt:C,setPrompt:S,reviewOnly:O,artifactSpec:G,billingMode:N,costEstimate:E,overCap:F,isPending:r,onStart:z}),F&&(0,s.jsxs)("div",{className:"mb-4 flex items-start gap-2 rounded-md border border-rose-500/30 bg-rose-500/5 px-3 py-2 text-[11px] text-rose-200",children:[(0,s.jsx)(n.A,{className:"mt-0.5 h-3 w-3 shrink-0 text-rose-400"}),(0,s.jsxs)("span",{children:["Estimated cost"," ",(0,s.jsxs)("span",{className:"font-mono",children:["$",E.usd.toFixed(3)]})," ","exceeds template cap"," ",(0,s.jsxs)("span",{className:"font-mono",children:["$",M.costCapUsd.toFixed(2)]}),". Trim attachments, shorten the prompt, or raise the cap in template settings."]})]}),(0,s.jsxs)("div",{className:`mb-4 rounded-lg border border-dashed border-border bg-card/30 p-4 ${O?"opacity-50":""}`,children:[(0,s.jsxs)("div",{className:"mb-2 flex items-center gap-2",children:[(0,s.jsxs)("span",{className:"text-sm font-medium text-foreground",children:["Target repo"," ",(0,s.jsx)("span",{className:"text-muted-foreground",children:"(optional)"})]}),(0,s.jsx)(c.E,{variant:"outline",className:"border-emerald-500/30 bg-emerald-500/10 font-mono text-[10px] uppercase text-emerald-300",children:"opens PR"})]}),(0,s.jsx)("input",{type:"text",value:O?"":A,onChange:e=>T(e.target.value),disabled:O,placeholder:"/absolute/path/to/repo",className:"w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-xs text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-primary disabled:cursor-not-allowed disabled:opacity-60",spellCheck:!1}),(0,s.jsx)("p",{className:"mt-2 text-[11px] text-muted-foreground",children:O?"Review-only templates have no doer and no Ship phase, so there's nothing to commit. Pick a template with a doer (e.g. Tri-Review) to open a PR.":(0,s.jsxs)(s.Fragment,{children:["When set: doer makes real edits in this repo. After reviewers agree, chorus opens a PR via"," ",(0,s.jsx)("code",{className:"rounded bg-muted px-1",children:"gh pr create"})," (no auto-merge — you review + click Merge in GitHub). Leave blank to skip the Ship phase."]})})]}),(0,s.jsxs)("button",{type:"button",onClick:()=>L(e=>!e),className:`mb-4 flex w-full items-start justify-between gap-3 rounded-lg border px-4 py-3 text-left transition ${P?"border-rose-500/40 bg-rose-500/5":"border-dashed border-border bg-card/30 hover:border-foreground/30"}`,children:[(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("span",{className:`mt-0.5 grid h-7 w-7 place-items-center rounded-md text-sm ${P?"bg-rose-500/20 text-rose-300":"bg-card text-muted-foreground"}`,children:"\uD83D\uDE80"}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-foreground",children:"Yolo mode"}),(0,s.jsx)(c.E,{variant:"outline",className:"border-rose-500/30 bg-rose-500/10 font-mono text-[10px] uppercase text-rose-300",children:"unsafe"})]}),(0,s.jsx)("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:P?"Reviewer gates auto-approve. Permission prompts auto-allow. The driver merges without asking. Cost cap still enforced.":"Skip every ask-user gate for this single run. Useful for trusted templates or trivial fixes."})]})]}),(0,s.jsx)("span",{className:`flex h-5 w-9 shrink-0 items-center rounded-full border p-0.5 transition ${P?"border-rose-500/40 bg-rose-500/20":"border-border bg-card"}`,children:(0,s.jsx)("span",{className:`h-3.5 w-3.5 rounded-full transition-transform ${P?"translate-x-4 bg-rose-400":"bg-muted-foreground/50"}`})})]})]})}):(0,s.jsx)(d.G,{children:(0,s.jsx)("div",{className:"mx-auto w-full max-w-6xl px-4 py-12 text-sm text-muted-foreground sm:px-6 md:px-8",children:"Loading templates…"})})}},6289:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(3884).A)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]])},6457:(e,t,r)=>{"use strict";r.d(t,{z:()=>a});var s=r(9442);function a({eyebrow:e,title:t,subtitle:r,action:n}){return(0,s.jsxs)("header",{className:"mb-6 flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-xs uppercase tracking-wider text-muted-foreground",children:e}),(0,s.jsx)("h1",{className:"mt-1 text-2xl font-semibold tracking-tight",children:t}),r&&(0,s.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-muted-foreground",children:r})]}),n&&(0,s.jsx)("div",{className:"shrink-0 self-start sm:self-auto",children:n})]})}},9056:(e,t,r)=>{"use strict";r.d(t,{F:()=>o});var s=r(142);let a=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,n=s.$,o=(e,t)=>r=>{var s;if((null==t?void 0:t.variants)==null)return n(e,null==r?void 0:r.class,null==r?void 0:r.className);let{variants:o,defaultVariants:i}=t,d=Object.keys(o).map(e=>{let t=null==r?void 0:r[e],s=null==i?void 0:i[e];if(null===t)return null;let n=a(t)||a(s);return o[e][n]}),l=r&&Object.entries(r).reduce((e,t)=>{let[r,s]=t;return void 0===s||(e[r]=s),e},{});return n(e,d,null==t||null==(s=t.compoundVariants)?void 0:s.reduce((e,t)=>{let{class:r,className:s,...a}=t;return Object.entries(a).every(e=>{let[t,r]=e;return Array.isArray(r)?r.includes({...i,...l}[t]):({...i,...l})[t]===r})?[...e,r,s]:e},[]),null==r?void 0:r.class,null==r?void 0:r.className)}}},e=>{e.O(0,[116,720,641,344,506,128,358],()=>e(e.s=2919)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[359],{63:(e,t,r)=>{"use strict";r.d(t,{Zp:()=>n});var s=r(9442);r(6074);var a=r(7362);function n({className:e,...t}){return(0,s.jsx)("div",{"data-slot":"card",className:(0,a.cn)("flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm",e),...t})}},862:(e,t,r)=>{"use strict";function s(e){return!!e&&e.phases[0]?.kind==="review_only"}r.d(t,{$:()=>s})},2471:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(3884).A)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]])},2919:(e,t,r)=>{Promise.resolve().then(r.bind(r,6141))},3734:(e,t,r)=>{"use strict";r.d(t,{JR:()=>c,QJ:()=>n,VW:()=>o,YM:()=>m,m_:()=>i,r2:()=>x,u5:()=>l,x0:()=>u,ze:()=>s});let s={anthropic:"Claude",openai:"Codex",google:"Gemini",opencode:"OpenCode",moonshot:"Kimi"},a={anthropic:"bg-violet-400",openai:"bg-orange-400",google:"bg-blue-400",opencode:"bg-emerald-400",moonshot:"bg-pink-400"};function n(e){return e?s[e]??e:""}function o(e){return e?a[e]??"bg-muted":"bg-muted"}let i={claude:"Claude",codex:"Codex",gemini:"Gemini",opencode:"OpenCode",kimi:"Kimi",openrouter:"OpenRouter"},d={claude:"bg-violet-400",codex:"bg-orange-400",gemini:"bg-blue-400",opencode:"bg-emerald-400",kimi:"bg-pink-400",openrouter:"bg-cyan-400"};function l(e){return e?i[e]??e:""}function c(e){return e?d[e]??"bg-muted":"bg-muted"}let u={claude:"claude-opus-4-7",codex:"gpt-5.5",gemini:"gemini-3.1-pro-preview",opencode:"kimi-k2.6",kimi:"kimi-k2.6",openrouter:""};function m(e){if(e)return u[e]}let x={claude:{dot:"bg-violet-400",ring:"ring-violet-400/40",gradient:"bg-gradient-to-b from-violet-500/15 to-card"},codex:{dot:"bg-orange-400",ring:"ring-orange-400/40",gradient:"bg-gradient-to-b from-orange-500/15 to-card"},gemini:{dot:"bg-blue-400",ring:"ring-blue-400/40",gradient:"bg-gradient-to-b from-blue-500/15 to-card"},opencode:{dot:"bg-emerald-400",ring:"ring-emerald-400/40",gradient:"bg-gradient-to-b from-emerald-500/15 to-card"},kimi:{dot:"bg-pink-400",ring:"ring-pink-400/40",gradient:"bg-gradient-to-b from-pink-500/15 to-card"},openrouter:{dot:"bg-cyan-400",ring:"ring-cyan-400/40",gradient:"bg-gradient-to-b from-cyan-500/15 to-card"}}},4372:(e,t,r)=>{"use strict";r.d(t,{G:()=>o});var s=r(9442),a=r(821),n=r(8344);function o({children:e}){return(0,s.jsxs)("div",{className:"flex h-screen w-screen overflow-hidden bg-background text-foreground",children:[(0,s.jsx)(a.AppSidebar,{}),(0,s.jsxs)("div",{className:"flex flex-1 flex-col overflow-hidden",children:[(0,s.jsx)(n.MobileTopBar,{}),(0,s.jsx)("main",{className:"flex-1 overflow-y-auto",children:e})]})]})}},5702:(e,t,r)=>{"use strict";r.d(t,{E:()=>d});var s=r(9442);r(6074);var a=r(9056),n=r(8113),o=r(7362);let i=(0,a.F)("inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3",{variants:{variant:{default:"bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90",outline:"border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",ghost:"[a&]:hover:bg-accent [a&]:hover:text-accent-foreground",link:"text-primary underline-offset-4 [a&]:hover:underline"}},defaultVariants:{variant:"default"}});function d({className:e,variant:t="default",asChild:r=!1,...a}){let l=r?n.bL:"span";return(0,s.jsx)(l,{"data-slot":"badge","data-variant":t,className:(0,o.cn)(i({variant:t}),e),...a})}},6141:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>N});var s=r(9442),a=r(8821),n=r(2471),o=r(5902),i=r(6074),d=r(4372),l=r(6457),c=r(5702),u=r(6185),m=r(6441),x=r(862);function p({icon:e,label:t,value:r,wide:a,children:n}){let[o,d]=(0,i.useState)(!1);return(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>d(e=>!e),className:"flex items-center gap-2 rounded-md border border-border bg-card px-3 py-1.5 text-sm transition hover:border-muted-foreground/40",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:e}),(0,s.jsx)("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:t}),(0,s.jsx)("span",{className:"font-medium",children:r})]}),o&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"fixed inset-0 z-10",onClick:()=>d(!1)}),(0,s.jsx)("div",{className:`absolute left-0 top-full z-20 mt-1 rounded-md border border-border bg-popover p-1.5 shadow-xl ${a?"w-80":"w-56"}`,onClick:()=>d(!1),children:n})]})]})}var g=r(6289);let h=(0,r(3884).A)("dollar-sign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]);var f=r(63),b=r(3734);function v({template:e,prompt:t,setPrompt:r,reviewOnly:a,artifactSpec:n,billingMode:o,costEstimate:i,overCap:d,isPending:l,onStart:c}){return(0,s.jsxs)(s.Fragment,{children:[a&&n&&(0,s.jsxs)("div",{className:"mb-2 flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[(0,s.jsx)("span",{className:"font-medium text-foreground",children:n.label}),(0,s.jsx)("span",{className:"text-muted-foreground/60",children:"\xb7"}),(0,s.jsxs)("span",{children:["cap ",(n.maxBytes/1024).toLocaleString()," KB"]})]}),(0,s.jsxs)(f.Zp,{className:"overflow-hidden p-0 mb-4",children:[(0,s.jsx)("textarea",{value:t,onChange:e=>r(e.target.value),placeholder:a&&n?n.hint:"Describe what you want chorus to weigh in on. Paste code, errors, design docs — anything the reviewers should see.",className:`block w-full resize-none border-0 bg-transparent px-5 py-4 text-sm text-foreground placeholder:text-muted-foreground/70 focus:outline-none ${a?"font-mono text-[12px] leading-relaxed":""}`,rows:a?16:10,spellCheck:!a}),(0,s.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border bg-card/40 px-5 py-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsx)(j,{template:e,reviewOnly:a}),(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3 sm:justify-end",children:[(0,s.jsx)(y,{billingMode:o,costEstimate:i,overCap:d,template:e}),(0,s.jsxs)("button",{type:"button",onClick:c,disabled:!t||d||l,className:`inline-flex shrink-0 items-center gap-2 whitespace-nowrap rounded-md px-4 py-2 text-sm font-medium transition ${!t||d||l?"cursor-not-allowed bg-muted text-muted-foreground":"bg-primary text-primary-foreground hover:bg-primary/90"}`,children:[l?"Starting...":a?"Send for review":"Start the run",(0,s.jsx)(g.A,{className:"h-4 w-4"})]})]})]})]})]})}function j({template:e,reviewOnly:t}){return(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[!t&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:`h-1.5 w-1.5 rounded-full ${(0,b.JR)(e.phases[0]?.doer.lineage)}`}),"Doer: ",e.phases[0]?.doer.lineage]}),(0,s.jsx)("span",{className:"text-muted-foreground/50",children:"\xb7"})]}),(0,s.jsx)(w,{template:e}),e.phases.length>1&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-muted-foreground/50",children:"\xb7"}),(0,s.jsxs)("span",{className:"font-mono text-[10px]",children:[e.phases.length," phases"]})]})]})}function w({template:e}){let t=e.phases[0]?.reviewer.candidatesWithModels??[],r=new Map;for(let e of t)r.set(e.lineage,(r.get(e.lineage)??0)+1);return(0,s.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"text-muted-foreground/80",children:"Reviewers:"}),t.map((e,t)=>{let a=(r.get(e.lineage)??0)>1,n=e.models?.[0]?.split("/").pop()??e.models?.[0],o=a&&n?`${e.lineage} \xb7 ${n}`:e.lineage;return(0,s.jsxs)("span",{className:"flex items-center gap-1",title:e.models?.[0]?`${e.lineage} \xb7 ${e.models[0]}`:e.lineage,children:[(0,s.jsx)("span",{className:`h-1.5 w-1.5 rounded-full ${(0,b.JR)(e.lineage)}`}),o]},`${e.lineage}-${e.models?.[0]??"default"}-${t}`)}),e.phases[0]?.reviewer.crossLineage&&(0,s.jsx)(c.E,{variant:"outline",className:"ml-1 border-border font-mono text-[9px] uppercase",title:"Reviewer must be a different lineage than the doer",children:"cross-lineage"})]})}function y({billingMode:e,costEstimate:t,overCap:r,template:a}){return"subscription"===e?(0,s.jsxs)("div",{className:"flex items-center gap-1.5 font-mono text-[10px] text-muted-foreground",title:`~${t.inputTokens.toLocaleString()} input tokens \xd7 ${t.reviewerCount} reviewers — counts against your CLI subscription quota, not billed per call`,children:["Subscription quota \xb7 ~",t.inputTokens.toLocaleString()," tok"]}):(0,s.jsxs)("div",{className:`flex items-center gap-1.5 font-mono text-[10px] ${r?"text-rose-300":"text-muted-foreground"}`,title:`~${t.inputTokens.toLocaleString()} input tokens \xd7 ${t.reviewerCount} reviewers; up to ${t.maxRounds} round${t.maxRounds>1?"s":""} on disagreement`,children:[(0,s.jsx)(h,{className:"h-3 w-3"}),t.maxRounds>1?`~$${t.usd.toFixed(3)} – $${t.usdRangeMax.toFixed(3)} est`:`~$${t.usd.toFixed(3)} est`,a.costCapUsd>0&&(0,s.jsxs)("span",{className:"text-muted-foreground/60",children:["/ cap $",a.costCapUsd.toFixed(2)]})]})}function N(){return(0,s.jsx)(i.Suspense,{fallback:(0,s.jsx)(d.G,{children:(0,s.jsx)("div",{className:"p-8 text-sm text-muted-foreground",children:"Loading…"})}),children:(0,s.jsx)(k,{})})}function k(){let e=(0,o.useSearchParams)(),t=(0,o.useRouter)(),[r,g]=(0,i.useTransition)(),[h,f]=(0,i.useState)([]),[b,j]=(0,i.useState)(null),[w,y]=(0,i.useState)(null);(0,i.useEffect)(()=>{(0,u.eG)().then(f).catch(e=>j(e instanceof u.$v?e.message:"Failed to load templates"))},[]);let[N,k]=(0,i.useState)("api");(0,i.useEffect)(()=>{(0,m.Dl)().then(e=>k(e.mode)).catch(()=>{})},[]);let $=e.get("template")??h[0]?.id??"",[C,S]=(0,i.useState)(""),R=[],M=h.find(e=>e.id===$)??h[0],E=(0,i.useMemo)(()=>(function(e){let{template:t,prompt:r,attachments:s}=e,a=t?.phases?.[0]?.reviewer?.candidates?.length??3,n=Math.max(1,t?.maxRounds??1),o=Math.ceil(r.length/4)+1500*s.length+(t?.estimatedBaselineTokens??800),i=(3e-6*o+.018000000000000002)*a;return{usd:i,usdRangeMax:i*n,inputTokens:o,reviewerCount:a,maxRounds:n}})({template:M,prompt:C,attachments:R}),[C,R,M]),F=!!("subscription"!==N&&M?.costCapUsd&&M.costCapUsd>0&&E.usdRangeMax>M.costCapUsd),[L,P]=(0,i.useState)(!1),[A,T]=(0,i.useState)(""),O=(0,x.$)(M),G=O?M?.phases?.[0]?.artifact:void 0;async function z(){if(M&&C){if(O&&G){let e=new TextEncoder().encode(C).length;if(e>G.maxBytes)return void y(`Artifact is ${e.toLocaleString()} bytes; this template caps at ${G.maxBytes.toLocaleString()}. Trim it down.`)}y(null),g(async()=>{try{let e=A.trim(),r=await (0,u.RL)({work:O?function(e){let t="Review the supplied artifact independently.";if(!e)return t;for(let t of e.split("\n")){let e=t.trim();if(0===e.length||e.startsWith("```")||e.startsWith("~~~"))continue;if(e.length<=80)return e;let r=e.slice(0,80),s=r.lastIndexOf(" ");return(s>40?r.slice(0,s):r)+"…"}return t}(C):C,templateId:M.id,files:R.length>0?R.map(e=>e.name):void 0,...O?{artifact:C}:{},...!O&&e.length>0?{repoPath:e}:{},yolo:L});t.push(`/runs/${r.slug||r.id}`)}catch(e){y(e instanceof u.$v?e.message:"Failed to create chat")}})}}return b?(0,s.jsx)(d.G,{children:(0,s.jsx)("div",{className:"mx-auto w-full max-w-6xl px-4 py-6 sm:px-6 sm:py-8 md:px-8 md:py-10",children:(0,s.jsxs)("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4",children:[(0,s.jsx)("p",{className:"text-sm text-destructive",children:"Error loading templates"}),(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:b})]})})}):M?(0,s.jsx)(d.G,{children:(0,s.jsxs)("div",{className:"mx-auto w-full max-w-6xl px-4 py-6 sm:px-6 sm:py-8 md:px-8 md:py-10",children:[(0,s.jsx)(l.z,{eyebrow:"New chat",title:O?"Paste an artifact. Get reviews.":"Paste a task. Pick a template.",subtitle:O?"Chorus skips the doer and runs your text past three reviewers. Single pass — revise yourself and resubmit for another round.":"Chorus runs it past your reviewers and reports consensus."}),w&&(0,s.jsx)("div",{className:"mb-4 rounded-lg border border-destructive/50 bg-destructive/10 p-4",children:(0,s.jsx)("p",{className:"text-sm text-destructive",children:w})}),(0,s.jsx)("div",{className:"mb-4 flex flex-wrap items-center gap-2",children:(0,s.jsx)(p,{icon:(0,s.jsx)(a.A,{className:"h-3.5 w-3.5"}),label:"Template",value:M?.name||"Select a template",wide:!0,children:(0,s.jsx)("ul",{className:"space-y-1",children:h.map(r=>{let a=!1===r.isComplete;return(0,s.jsx)("li",{children:(0,s.jsxs)("button",{type:"button",disabled:a,onClick:()=>{if(a)return;let s=new URLSearchParams(e);s.set("template",r.id),t.push(`/new?${s.toString()}`)},className:`block w-full rounded-md p-2 text-left transition ${a?"cursor-not-allowed opacity-50":r.id===$?"bg-accent":"hover:bg-accent/50"}`,children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm font-medium",children:r.name}),(0,x.$)(r)&&(0,s.jsx)(c.E,{variant:"outline",className:"border-blue-500/30 bg-blue-500/10 font-mono text-[9px] uppercase text-blue-300",children:"review only"}),a&&(0,s.jsx)(c.E,{variant:"outline",className:"border-amber-500/40 bg-amber-500/10 font-mono text-[9px] uppercase text-amber-300",children:"needs setup"})]}),(0,s.jsx)("div",{className:"text-xs text-muted-foreground line-clamp-1",children:a?"Edit this template's YAML to fill in models for your fleet.":r.description})]})},r.id)})})})}),(0,s.jsx)(v,{template:M,prompt:C,setPrompt:S,reviewOnly:O,artifactSpec:G,billingMode:N,costEstimate:E,overCap:F,isPending:r,onStart:z}),F&&(0,s.jsxs)("div",{className:"mb-4 flex items-start gap-2 rounded-md border border-rose-500/30 bg-rose-500/5 px-3 py-2 text-[11px] text-rose-200",children:[(0,s.jsx)(n.A,{className:"mt-0.5 h-3 w-3 shrink-0 text-rose-400"}),(0,s.jsxs)("span",{children:["Estimated cost"," ",(0,s.jsxs)("span",{className:"font-mono",children:["$",E.usd.toFixed(3)]})," ","exceeds template cap"," ",(0,s.jsxs)("span",{className:"font-mono",children:["$",M.costCapUsd.toFixed(2)]}),". Trim attachments, shorten the prompt, or raise the cap in template settings."]})]}),(0,s.jsxs)("div",{className:`mb-4 rounded-lg border border-dashed border-border bg-card/30 p-4 ${O?"opacity-50":""}`,children:[(0,s.jsxs)("div",{className:"mb-2 flex items-center gap-2",children:[(0,s.jsxs)("span",{className:"text-sm font-medium text-foreground",children:["Target repo"," ",(0,s.jsx)("span",{className:"text-muted-foreground",children:"(optional)"})]}),(0,s.jsx)(c.E,{variant:"outline",className:"border-emerald-500/30 bg-emerald-500/10 font-mono text-[10px] uppercase text-emerald-300",children:"opens PR"})]}),(0,s.jsx)("input",{type:"text",value:O?"":A,onChange:e=>T(e.target.value),disabled:O,placeholder:"/absolute/path/to/repo",className:"w-full rounded-md border border-border bg-background px-3 py-2 font-mono text-xs text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:ring-1 focus:ring-primary disabled:cursor-not-allowed disabled:opacity-60",spellCheck:!1}),(0,s.jsx)("p",{className:"mt-2 text-[11px] text-muted-foreground",children:O?"Review-only templates have no doer and no Ship phase, so there's nothing to commit. Pick a template with a doer (e.g. Tri-Review) to open a PR.":(0,s.jsxs)(s.Fragment,{children:["When set: doer makes real edits in this repo. After reviewers agree, chorus opens a PR via"," ",(0,s.jsx)("code",{className:"rounded bg-muted px-1",children:"gh pr create"})," (no auto-merge — you review + click Merge in GitHub). Leave blank to skip the Ship phase."]})})]}),(0,s.jsxs)("button",{type:"button",onClick:()=>P(e=>!e),className:`mb-4 flex w-full items-start justify-between gap-3 rounded-lg border px-4 py-3 text-left transition ${L?"border-rose-500/40 bg-rose-500/5":"border-dashed border-border bg-card/30 hover:border-foreground/30"}`,children:[(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)("span",{className:`mt-0.5 grid h-7 w-7 place-items-center rounded-md text-sm ${L?"bg-rose-500/20 text-rose-300":"bg-card text-muted-foreground"}`,children:"\uD83D\uDE80"}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-foreground",children:"Yolo mode"}),(0,s.jsx)(c.E,{variant:"outline",className:"border-rose-500/30 bg-rose-500/10 font-mono text-[10px] uppercase text-rose-300",children:"unsafe"})]}),(0,s.jsx)("p",{className:"mt-0.5 text-[11px] text-muted-foreground",children:L?"Reviewer gates auto-approve. Permission prompts auto-allow. The driver merges without asking. Cost cap still enforced.":"Skip every ask-user gate for this single run. Useful for trusted templates or trivial fixes."})]})]}),(0,s.jsx)("span",{className:`flex h-5 w-9 shrink-0 items-center rounded-full border p-0.5 transition ${L?"border-rose-500/40 bg-rose-500/20":"border-border bg-card"}`,children:(0,s.jsx)("span",{className:`h-3.5 w-3.5 rounded-full transition-transform ${L?"translate-x-4 bg-rose-400":"bg-muted-foreground/50"}`})})]})]})}):(0,s.jsx)(d.G,{children:(0,s.jsx)("div",{className:"mx-auto w-full max-w-6xl px-4 py-12 text-sm text-muted-foreground sm:px-6 md:px-8",children:"Loading templates…"})})}},6289:(e,t,r)=>{"use strict";r.d(t,{A:()=>s});let s=(0,r(3884).A)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]])},6457:(e,t,r)=>{"use strict";r.d(t,{z:()=>a});var s=r(9442);function a({eyebrow:e,title:t,subtitle:r,action:n}){return(0,s.jsxs)("header",{className:"mb-6 flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-xs uppercase tracking-wider text-muted-foreground",children:e}),(0,s.jsx)("h1",{className:"mt-1 text-2xl font-semibold tracking-tight",children:t}),r&&(0,s.jsx)("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-muted-foreground",children:r})]}),n&&(0,s.jsx)("div",{className:"shrink-0 self-start sm:self-auto",children:n})]})}},9056:(e,t,r)=>{"use strict";r.d(t,{F:()=>o});var s=r(142);let a=e=>"boolean"==typeof e?`${e}`:0===e?"0":e,n=s.$,o=(e,t)=>r=>{var s;if((null==t?void 0:t.variants)==null)return n(e,null==r?void 0:r.class,null==r?void 0:r.className);let{variants:o,defaultVariants:i}=t,d=Object.keys(o).map(e=>{let t=null==r?void 0:r[e],s=null==i?void 0:i[e];if(null===t)return null;let n=a(t)||a(s);return o[e][n]}),l=r&&Object.entries(r).reduce((e,t)=>{let[r,s]=t;return void 0===s||(e[r]=s),e},{});return n(e,d,null==t||null==(s=t.compoundVariants)?void 0:s.reduce((e,t)=>{let{class:r,className:s,...a}=t;return Object.entries(a).every(e=>{let[t,r]=e;return Array.isArray(r)?r.includes({...i,...l}[t]):({...i,...l})[t]===r})?[...e,r,s]:e},[]),null==r?void 0:r.class,null==r?void 0:r.className)}}},e=>{e.O(0,[116,720,641,344,506,128,358],()=>e(e.s=2919)),_N_E=e.O()}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[814],{4538:(e,r,t)=>{"use strict";t.r(r),t.d(r,{default:()=>e5});var s=t(9442),a=t(6074),n=t(4052),o=t(3149),i=t(8420),d=t(4372),l=t(63),c=t(5702),u=t(6457),m=t(8191),x=t(9315),p=t(2865),h=t(6891),f=t(6458),g=t(4030),b=t(2956),v=t(1853),j=t(6185),y=t(599),w=t(2794);let N=w.ai().int().min(3e4).max(36e5).optional(),k=w.k5(["anthropic","openai","google","opencode","moonshot","openrouter","any"]),A=w.k5(["anthropic","openai","google","opencode","moonshot","openrouter"]),C=w.Ik({require:w.ai().int().min(0).default(1),crossLineage:w.zM().default(!0),candidates:w.YO(w.Ik({lineage:A,models:w.YO(w.Yj()).optional(),persona:w.Yj().optional()}))}),M=w.Ik({include:w.YO(w.Yj()).default([]),exclude:w.YO(w.Yj()).default([])}).default({include:[],exclude:[]}),S=w.Ik({maxRounds:w.ai().int().min(1).default(2),onDisagreement:w.k5(["continue","escalate","accept-doer"]).default("continue"),shareSessionAcrossRounds:w.zM().default(!0),shareSessionAcrossPhases:w.zM().default(!1)}).default({maxRounds:2,onDisagreement:"continue",shareSessionAcrossRounds:!0,shareSessionAcrossPhases:!1}),Y=w.Ik({id:w.Yj().min(1),kind:w.k5(["plan","spec","tests","implement","review","verify","divergence"]),title:w.Yj().min(1),description:w.Yj().optional(),doer:w.Ik({lineage:k,models:w.YO(w.Yj()).optional(),persona:w.Yj().optional()}),reviewer:C.optional(),inputs:M,iterate:S,timeoutMs:N}),D=w.Ik({id:w.Yj().min(1),kind:w.eu("review_only"),title:w.Yj().min(1),description:w.Yj().optional(),reviewer:C,artifact:w.Ik({label:w.Yj().min(1).default("Artifact to review"),hint:w.Yj().default("Paste a unified diff, a markdown draft, code, or any text blob."),maxBytes:w.ai().int().min(1).default(1048576)}).default({label:"Artifact to review",hint:"Paste a unified diff, a markdown draft, code, or any text blob.",maxBytes:1048576}),inputs:M,timeoutMs:N}),R=w.gM("kind",[Y.extend({kind:w.eu("plan")}),Y.extend({kind:w.eu("spec")}),Y.extend({kind:w.eu("tests")}),Y.extend({kind:w.eu("implement")}),Y.extend({kind:w.eu("review")}),Y.extend({kind:w.eu("verify")}),Y.extend({kind:w.eu("divergence")}),D]),L=w.Ik({id:w.Yj().min(1),name:w.Yj().min(1),description:w.Yj().min(1),author:w.Yj().default("chorus"),agreementThreshold:w.ai().min(0).max(1).default(.66),onThresholdMet:w.k5(["merge","ask","review"]).default("ask"),maxRounds:w.ai().int().min(1).default(3),yoloDefault:w.zM().default(!1),estimatedBaselineTokens:w.ai().int().min(0).optional(),phases:w.YO(R).min(1).refine(e=>{let r=e.filter(e=>"review_only"===e.kind).length;return 0===r||1===r&&1===e.length},{message:"review_only phases cannot be mixed with other phase kinds and only one is allowed (hybrid templates are out of scope)"}).refine(e=>{let r=e.map(e=>e.id);return new Set(r).size===r.length},{message:"phase ids must be unique"}),ship:w.Ik({enabled:w.zM().default(!1),baseBranch:w.Yj().optional(),branchPattern:w.Yj().default("chorus/{chatId}"),titleTemplate:w.Yj().default("chorus: {template} via #{chatId}")}).optional(),fallback:w.Ik({doer:w.YO(w.Ik({lineage:k,models:w.YO(w.Yj()).min(1),persona:w.Yj().optional()})).optional(),reviewer:w.YO(w.Ik({lineage:A,models:w.YO(w.Yj()).min(1),persona:w.Yj().optional()})).optional()}).optional()}),P=Object.freeze({valid:!0,issues:[]});var T=t(7362),$=t(8979),_=t(8821),q=t(4608),E=t(7978);let I={claude:"anthropic",codex:"openai",gemini:"google",opencode:"opencode",kimi:"moonshot",openrouter:"openrouter"},F={anthropic:"claude",openai:"codex",google:"gemini",opencode:"opencode",moonshot:"kimi",xai:"opencode"},O={claude:"claude-opus-4-7",codex:"gpt-5.5",gemini:"gemini-3.1-pro-preview",opencode:"kimi-k2.6",kimi:"kimi-k2.6",openrouter:""},z={id:"",name:"",description:"",author:"you",category:"review",phases:[{id:"review",name:"Review",description:"Three independent critiques.",kind:"review",gate:"ask-user",doer:{lineage:"claude",models:["claude-opus-4-7"]},reviewer:{require:3,crossLineage:!0,candidates:["codex","gemini","opencode"]},inputs:{include:[],exclude:[]},iterate:{max:3,onMax:"ask-user"},blindSpots:[],execution:"parallel",builtin:!1}],threshold:"unanimous",onThresholdMet:"ask-user",maxRounds:3,yoloDefault:!1,fallbackDoer:[],fallbackReviewer:[]},B=[{id:"review",label:"Review"},{id:"plan",label:"Plan"},{id:"debug",label:"Debug"},{id:"decide",label:"Decide"}],U=[{id:"unanimous",label:"Unanimous",hint:"All lineages must agree. Strictest — best for high-stakes reviews."},{id:"majority",label:"Majority",hint:"≥ ⅔ of lineages agree. Good default for code review."},{id:"any",label:"Any",hint:"≥1 lineage agrees. Useful for brainstorming where divergence is fine."}],V=[{id:"auto-finalize",label:"Auto-finalize"},{id:"ask-user",label:"Ask me"}],G=[{id:1,label:"Basics",icon:$.A},{id:2,label:"Phases",icon:_.A},{id:3,label:"Fallback",icon:q.A},{id:4,label:"Policy",icon:E.A}],W=["claude","codex","gemini","opencode","kimi","openrouter"];function K(e){return e.trim().toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-")||"untitled"}function H(e){var r;return y.Ay.stringify({id:(r=e).id||K(r.name),name:r.name||"Untitled template",description:r.description||"Describe what this template is for.",author:r.author||"chorus",agreementThreshold:void 0!==r.customThreshold?r.customThreshold:function(e){switch(e){case"unanimous":return 1;case"majority":return .66;case"any":return .34}}(r.threshold),onThresholdMet:r.onThresholdMetRaw??("auto-finalize"===r.onThresholdMet?"merge":"ask"),maxRounds:r.maxRounds,yoloDefault:r.yoloDefault,phases:r.phases.map(e=>{let r="review_only"===e.kind,t=e.reviewer.candidates.length>0?{require:e.reviewer.require,crossLineage:e.reviewer.crossLineage,candidates:e.reviewer.candidates.flatMap(r=>{let t=(e.reviewer.candidateModels?.[r]??[]).map(e=>e.trim()).filter(e=>e.length>0),s=e.reviewer.candidatePersonas?.[r],a=I[r]??"anthropic";if(0===t.length){let e=O[r]??"claude-opus-4-7",t=s?.[""];return[{lineage:a,models:[e],...t?{persona:t}:{}}]}return t.map(e=>{let r=s?.[e];return{lineage:a,models:[e],...r?{persona:r}:{}}})})}:void 0;return r?{id:e.id,kind:e.kind,title:e.name,description:e.description,reviewer:t,inputs:{include:e.inputs.include,exclude:e.inputs.exclude},artifact:{label:e.artifact?.label??"Artifact to review",hint:e.artifact?.hint??"Paste a unified diff, a markdown draft, code, or any text blob.",maxBytes:e.artifact?.maxBytes??1048576}}:{id:e.id,kind:e.kind,title:e.name,description:e.description,doer:{lineage:I[e.doer.lineage]??"anthropic",models:e.doer.models.length>0?e.doer.models:[O[e.doer.lineage]??"claude-opus-4-7"],...e.doer.persona?{persona:e.doer.persona}:{}},reviewer:t,inputs:{include:e.inputs.include,exclude:e.inputs.exclude},iterate:{maxRounds:e.iterate.max,onDisagreement:"loopback"===e.iterate.onMax?"continue":"fail"===e.iterate.onMax?"accept-doer":"escalate",shareSessionAcrossRounds:!0,shareSessionAcrossPhases:!1}}}),...r.fallbackDoer.length>0||r.fallbackReviewer.length>0?{fallback:{...r.fallbackDoer.length>0?{doer:r.fallbackDoer.map(e=>({lineage:I[e.lineage]??"anthropic",models:[e.model],...e.persona?{persona:e.persona}:{}}))}:{},...r.fallbackReviewer.length>0?{reviewer:r.fallbackReviewer.map(e=>({lineage:I[e.lineage]??"anthropic",models:[e.model],...e.persona?{persona:e.persona}:{}}))}:{}}}:{}},{lineWidth:0})}var Z=t(6758),J=t(5483),Q=t(7847),X=t(1993),ee=t(52),er=t(2116),et=t(9410),es=t(9208),ea=t(7618),en=t(4579),eo=t(9812),ei=t(3734);let ed={review:ee.A,review_only:ee.A,plan:er.A,spec:p.A,tests:et.A,implement:es.A,verify:ea.A,pr:en.A,divergence:q.A,recon:eo.A},el=[{id:"plan",label:"Plan"},{id:"spec",label:"Spec / API"},{id:"tests",label:"Tests"},{id:"implement",label:"Implement"},{id:"verify",label:"Verify"},{id:"pr",label:"Open PR"},{id:"review",label:"Review"},{id:"review_only",label:"Review only (artifact)"},{id:"divergence",label:"Divergence"},{id:"recon",label:"Recon"}],ec=["claude","codex","gemini","opencode","kimi","openrouter"].map(e=>({id:e,label:ei.m_[e],dot:ei.r2[e].dot})),eu=ei.x0,em={anthropic:"claude",openai:"codex",google:"gemini",opencode:"opencode",moonshot:"kimi",xai:"opencode"};function ex(){let[e,r]=(0,a.useState)({byLineage:{},connectedLineages:new Set,loaded:!1});return(0,a.useEffect)(()=>{(0,Q.listVoices)({enabled:!0}).then(e=>{let t={},s=new Set;for(let r of e){if("openrouter"===r.provider){s.add("openrouter"),(t.openrouter??=[]).push(r.id);continue}let e=em[r.lineage];e&&(s.add(e),(t[e]??=[]).push(r.model_id)),r.provider.startsWith("opencode")&&"opencode"!==e&&(s.add("opencode"),(t.opencode??=[]).push(r.model_id))}for(let e of Object.keys(t))t[e]=Array.from(new Set(t[e]));r({byLineage:t,connectedLineages:s,loaded:!0})}).catch(()=>r({byLineage:{},connectedLineages:new Set,loaded:!0}))},[]),e}var ep=t(1304),eh=t(2379),ef=t(5445),eg=t(9707),eb=t(2471);function ev({children:e,onClick:r,disabled:t,title:a,className:n}){return(0,s.jsx)("button",{type:"button",disabled:t,onClick:e=>{e.stopPropagation(),r()},title:a,className:(0,T.cn)("grid h-6 w-6 place-items-center rounded text-muted-foreground transition hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-30",n),children:e})}function ej({label:e,children:r}){return(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"mb-1.5 block text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:e}),r]})}function ey({on:e,tone:r,onClick:t,children:a}){return(0,s.jsx)("button",{type:"button",onClick:t,className:(0,T.cn)("rounded-md border px-2 py-0.5 font-mono text-[10px] uppercase tracking-wider transition",{emerald:e?"border-emerald-500/40 bg-emerald-500/15 text-emerald-200":"border-border bg-card/40 text-muted-foreground hover:border-emerald-500/30",rose:e?"border-rose-500/40 bg-rose-500/15 text-rose-200":"border-border bg-card/40 text-muted-foreground hover:border-rose-500/30"}[r]),children:a})}function ew({value:e,personas:r,onChange:t,inline:a,ariaLabel:n}){let o="__none__",i=r.some(r=>r.id===e);return(0,s.jsxs)("select",{value:e??o,onChange:e=>{let r=e.target.value;t(r===o?void 0:r)},className:(0,T.cn)("h-7 rounded-md border border-border bg-background px-2 text-[11px] focus:border-primary/60 focus:outline-none",a?"w-32 shrink-0":"w-full"),"aria-label":n??"Persona",children:[(0,s.jsx)("option",{value:o,children:"(no persona)"}),r.map(e=>(0,s.jsx)("option",{value:e.id,children:e.label},e.id)),e&&!i&&(0,s.jsxs)("option",{value:e,children:[e," (missing)"]})]})}function eN({lineage:e,value:r,options:t,onChange:n,defaultModel:o}){let i="__custom__",d=!r||t.includes(r),[l,c]=(0,a.useState)(!1);if(l)return(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)("input",{type:"text",value:r,onChange:e=>n(e.target.value),placeholder:o?`default: ${o}`:`${e} model id`,className:"h-7 flex-1 rounded-md border border-border bg-background px-2 font-mono text-[11px] text-foreground placeholder:text-muted-foreground/50 focus:border-primary/60 focus:outline-none",autoFocus:!0}),(0,s.jsx)("button",{type:"button",onClick:()=>c(!1),className:"h-7 rounded-md border border-border bg-card/40 px-2 text-[10px] text-muted-foreground hover:text-foreground",children:"done"})]});if(0===t.length)return(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("input",{type:"text",value:r,onChange:e=>n(e.target.value),placeholder:o?`default: ${o}`:`${e} model id`,className:"h-7 w-full rounded-md border border-border bg-background px-2 font-mono text-[11px] text-foreground placeholder:text-muted-foreground/50 focus:border-primary/60 focus:outline-none"}),(0,s.jsxs)("p",{className:"text-[10px] text-amber-400/80",children:["No ",e," voices enabled. Configure in Connect to populate this dropdown."]})]});let u=d?t:[r,...t];return(0,s.jsxs)("select",{value:r,onChange:e=>{e.target.value===i?c(!0):n(e.target.value)},className:"h-7 w-full rounded-md border border-border bg-background px-2 font-mono text-[11px] text-foreground focus:border-primary/60 focus:outline-none",children:[!r&&(0,s.jsx)("option",{value:"",children:o?`default: ${o}`:"— pick a model —"}),u.map(e=>(0,s.jsxs)("option",{value:e,children:[e,t.includes(e)||r!==e?"":" (not enabled)"]},e)),(0,s.jsx)("option",{value:i,children:"+ custom (type a model id)…"})]})}function ek(e){let r=[];for(let t of e.candidates){let s=e.candidateModels?.[t],a=e.candidatePersonas?.[t];if(s&&0!==s.length)for(let e of s)r.push({lineage:t,model:e,...a?.[e]?{persona:a[e]}:{}});else r.push({lineage:t,model:"",...a?.[""]?{persona:a[""]}:{}})}return r}function eA({phase:e,connectedVoices:r,personas:t,onUpdate:a}){let n=ek(e.reviewer),o=ec.filter(e=>0===r.connectedLineages.size||r.connectedLineages.has(e.id));function i(r){a({reviewer:function(e,r){let t=[],s={},a={};for(let r of e)t.includes(r.lineage)||t.push(r.lineage),r.model&&(s[r.lineage]??=[]).push(r.model),r.persona&&((a[r.lineage]??={})[r.model]=r.persona);return{...r,candidates:t,candidateModels:s,...Object.keys(a).length>0?{candidatePersonas:a}:{candidatePersonas:void 0}}}(r,e.reviewer)})}function d(e,t){let s=n.map((r,s)=>s===e?{...r,...t}:r);if(t.lineage&&t.lineage!==n[e].lineage){let a=r.byLineage[t.lineage]??[];s[e].model=a[0]??eu[t.lineage]??""}i(s)}return(0,s.jsxs)("div",{className:"space-y-1.5",children:[0===n.length&&(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"No reviewers yet. Click + add reviewer below."}),n.map((e,a)=>{let l=ec.find(r=>r.id===e.lineage);return(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsxs)("select",{value:e.lineage,onChange:e=>d(a,{lineage:e.target.value}),className:"h-7 w-32 shrink-0 rounded-md border border-border bg-background px-2 text-[11px] focus:border-primary/60 focus:outline-none","aria-label":"Reviewer lineage",children:[o.map(e=>(0,s.jsx)("option",{value:e.id,children:e.label},e.id)),!o.find(r=>r.id===e.lineage)&&(0,s.jsxs)("option",{value:e.lineage,children:[l?.label??e.lineage," (not connected)"]})]}),(0,s.jsx)("div",{className:"flex-1",children:(0,s.jsx)(eN,{lineage:e.lineage,value:e.model,options:r.byLineage[e.lineage]??[],defaultModel:eu[e.lineage],onChange:e=>d(a,{model:e})})}),(0,s.jsx)(ew,{value:e.persona,personas:t,onChange:e=>d(a,{persona:e}),inline:!0,ariaLabel:"Reviewer persona"}),(0,s.jsx)("button",{type:"button",onClick:()=>{i(n.filter((e,r)=>r!==a))},"aria-label":"Remove reviewer",className:"grid h-7 w-7 shrink-0 place-items-center rounded-md border border-border bg-card/40 text-muted-foreground hover:border-destructive/40 hover:text-destructive",children:(0,s.jsx)(h.A,{className:"h-3 w-3"})})]},a)}),(0,s.jsxs)("button",{type:"button",onClick:function(){let e=o[0]?.id??"claude",t=r.byLineage[e]??[],s=new Set(n.filter(r=>r.lineage===e).map(e=>e.model)),a=t.find(e=>!s.has(e))??eu[e]??"";i([...n,{lineage:e,model:a}])},className:"flex w-full items-center justify-center gap-1.5 rounded-md border border-dashed border-border bg-card/30 px-3 py-2 text-[11px] font-medium text-muted-foreground transition hover:border-primary/40 hover:bg-card/50 hover:text-foreground",children:[(0,s.jsx)(x.A,{className:"h-3 w-3"}),"Add another reviewer"]})]})}function eC({phase:e,onUpdate:r,connectedVoices:t,personas:a}){return(0,s.jsxs)(ej,{label:"Doer \xb7 the agent that writes this phase's output",children:[(0,s.jsx)("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-5",children:ec.filter(e=>0===t.connectedLineages.size||t.connectedLineages.has(e.id)).map(a=>(0,s.jsxs)("button",{type:"button",onClick:()=>{let e=(t.byLineage[a.id]??[])[0]??eu[a.id];r({doer:{lineage:a.id,models:e?[e]:[]}})},className:(0,T.cn)("flex items-center gap-1.5 rounded-md border px-2 py-1.5 text-left transition",e.doer.lineage===a.id?"border-primary/40 bg-primary/10":"border-border bg-card/40 hover:border-foreground/30"),children:[(0,s.jsx)("span",{className:(0,T.cn)("h-1.5 w-1.5 rounded-full",a.dot)}),(0,s.jsx)("span",{className:"text-xs",children:a.label}),e.doer.lineage===a.id&&(0,s.jsx)(eg.A,{className:"ml-auto h-3 w-3 text-primary"})]},a.id))}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)(eN,{lineage:e.doer.lineage,value:e.doer.models[0]??"",options:t.byLineage[e.doer.lineage]??[],defaultModel:eu[e.doer.lineage],onChange:t=>r({doer:{...e.doer,models:t?[t]:[]}})})}),(0,s.jsxs)("div",{className:"mt-2",children:[(0,s.jsx)("label",{className:"mb-1 block text-[10px] text-muted-foreground",children:"Persona (optional \xb7 prepends a worldview to the doer's prompt)"}),(0,s.jsx)(ew,{value:e.doer.persona,personas:a,onChange:t=>r({doer:t?{...e.doer,persona:t}:(()=>{let{persona:r,...t}=e.doer;return t})()}),ariaLabel:"Doer persona"})]})]})}function eM({phase:e,onUpdate:r}){let t={label:e.artifact?.label??"Artifact to review",hint:e.artifact?.hint??"Paste a unified diff, a markdown draft, code, or any text blob.",maxBytes:e.artifact?.maxBytes??1048576};return(0,s.jsx)(ej,{label:"Artifact \xb7 what the user pastes when starting a chat",children:(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"Label"}),(0,s.jsx)("input",{type:"text",value:t.label,onChange:e=>r({artifact:{...t,label:e.target.value}}),placeholder:"Artifact to review",className:"mt-1 h-7 w-full rounded-md border border-border bg-background px-2.5 text-[11px] placeholder:text-muted-foreground/60 focus:border-primary/60 focus:outline-none"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"Placeholder hint"}),(0,s.jsx)("textarea",{value:e.artifact?.hint??"",onChange:e=>r({artifact:{...t,hint:e.target.value}}),placeholder:"Paste a unified diff, a markdown draft, code, or any text blob.",rows:2,className:"mt-1 w-full resize-none rounded-md border border-border bg-background px-2.5 py-1.5 text-[11px] placeholder:text-muted-foreground/60 focus:border-primary/60 focus:outline-none"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"Max bytes (server-side cap)"}),(0,s.jsx)("input",{type:"number",min:1024,step:1024,value:t.maxBytes,onChange:e=>r({artifact:{...t,maxBytes:Math.max(1024,parseInt(e.target.value,10)||1048576)}}),className:"mt-1 h-7 w-full rounded-md border border-border bg-background px-2.5 font-mono text-[11px] focus:border-primary/60 focus:outline-none"}),(0,s.jsx)("p",{className:"mt-1 text-[10px] text-muted-foreground/80",children:"1 MiB = 1048576. Default if unset."})]})]})})}function eS({phase:e,onUpdate:r,connectedVoices:t,personas:a}){return(0,s.jsx)(ej,{label:"Reviewers \xb7 who gates this phase",children:(0,s.jsx)(eA,{phase:e,connectedVoices:t,personas:a,onUpdate:r})})}function eY({phase:e,onUpdate:r}){return(0,s.jsx)(ej,{label:"Approvals",children:(0,s.jsxs)("div",{className:"flex items-center gap-4 flex-wrap",children:[(0,s.jsxs)("label",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:["Require:",(0,s.jsx)("input",{type:"number",min:0,max:Math.max(1,ek(e.reviewer).length),value:e.reviewer.require,onChange:t=>r({reviewer:{...e.reviewer,require:Math.max(0,parseInt(t.target.value,10)||0)}}),className:"h-6 w-12 rounded border border-border bg-background px-1.5 text-center font-mono text-[11px]"}),"approval",1===e.reviewer.require?"":"s"]}),"review_only"!==e.kind&&(0,s.jsxs)("label",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[(0,s.jsx)("input",{type:"checkbox",checked:e.reviewer.crossLineage,onChange:t=>r({reviewer:{...e.reviewer,crossLineage:t.target.checked}}),className:"accent-primary"}),"Cross-lineage required"]})]})})}function eD({phase:e,onUpdate:r}){return(0,s.jsx)(ej,{label:"Reviewer execution \xb7 how multiple reviewers interact",children:(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>r({execution:"parallel"}),className:(0,T.cn)("rounded-md border px-3 py-2.5 text-left transition","parallel"===e.execution?"border-emerald-500/40 bg-emerald-500/5":"border-border bg-card/40 hover:border-foreground/30"),children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-xs font-medium",children:["Parallel independent",(0,s.jsx)("span",{className:"font-mono text-[9px] uppercase text-emerald-300/80",children:"fast"})]}),(0,s.jsx)("p",{className:"mt-0.5 text-[10px] leading-snug text-muted-foreground",children:"All reviewers see the same pack, work in isolation, vote. Catches single-reviewer mistakes via consensus. Risk: shared blind spots pass anyway."})]}),(0,s.jsxs)("button",{type:"button",onClick:()=>r({execution:"sequential"}),className:(0,T.cn)("rounded-md border px-3 py-2.5 text-left transition","sequential"===e.execution?"border-amber-500/40 bg-amber-500/5":"border-border bg-card/40 hover:border-foreground/30"),children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-xs font-medium",children:["Sequential hostile",(0,s.jsx)("span",{className:"font-mono text-[9px] uppercase text-amber-300/80",children:"thorough"})]}),(0,s.jsx)("p",{className:"mt-0.5 text-[10px] leading-snug text-muted-foreground",children:"Reviewers run in order. Each receives the already-hardened output and hunts what the prior reviewer missed. Slower; only works if the first reviewer's solution is sound."})]})]})})}function eR({phase:e,onUpdate:r,priorPhases:t}){return(0,s.jsxs)(ej,{label:"Inputs \xb7 which prior phases this doer can read",children:[(0,s.jsx)("div",{className:"space-y-1.5",children:t.map(t=>{let a=e.inputs.include.includes(t),n=e.inputs.exclude.includes(t),o=n?"exclude":a?"include":"none";return(0,s.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border bg-card/30 px-2.5 py-1.5",children:[(0,s.jsx)("code",{className:"font-mono text-[11px] text-foreground",children:t}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)(ey,{on:"include"===o,tone:"emerald",onClick:()=>r({inputs:{include:a?e.inputs.include.filter(e=>e!==t):[...e.inputs.include,t],exclude:e.inputs.exclude.filter(e=>e!==t)}}),children:"include"}),(0,s.jsx)(ey,{on:"exclude"===o,tone:"rose",onClick:()=>r({inputs:{include:e.inputs.include.filter(e=>e!==t),exclude:n?e.inputs.exclude.filter(e=>e!==t):[...e.inputs.exclude,t]}}),children:"exclude (blind)"})]})]},t)})}),(0,s.jsxs)("p",{className:"mt-2 flex items-start gap-1.5 text-[10px] text-muted-foreground",children:[(0,s.jsx)(eb.A,{className:"mt-0.5 h-2.5 w-2.5 shrink-0 text-muted-foreground/60"}),(0,s.jsxs)("span",{children:[(0,s.jsx)("span",{className:"font-mono text-rose-300",children:"exclude"}),"prevents this doer from seeing that phase's output. Used for info asymmetry — e.g. the implementer shouldn't see the tests."]})]})]})}function eL({phase:e,onUpdate:r,priorPhases:t}){return(0,s.jsx)(ej,{label:"Iterate \xb7 what happens when reviewer rejects",children:(0,s.jsxs)("div",{className:"grid grid-cols-3 gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"Max revise"}),(0,s.jsx)("input",{type:"number",min:1,max:10,value:e.iterate.max,onChange:t=>r({iterate:{...e.iterate,max:Math.max(1,parseInt(t.target.value,10)||1)}}),className:"mt-1 h-7 w-full rounded-md border border-border bg-background px-2 font-mono text-[11px]"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"On max"}),(0,s.jsxs)("select",{value:e.iterate.onMax,onChange:t=>r({iterate:{...e.iterate,onMax:t.target.value}}),className:"mt-1 h-7 w-full rounded-md border border-border bg-background px-1.5 text-[11px]",children:[(0,s.jsx)("option",{value:"ask-user",children:"ask me"}),(0,s.jsx)("option",{value:"loopback",children:"loop back"}),(0,s.jsx)("option",{value:"fail",children:"fail"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"Loop back to"}),(0,s.jsxs)("select",{disabled:"loopback"!==e.iterate.onMax,value:e.iterate.loopbackTo??"",onChange:t=>r({iterate:{...e.iterate,loopbackTo:t.target.value||void 0}}),className:"mt-1 h-7 w-full rounded-md border border-border bg-background px-1.5 text-[11px] disabled:opacity-40",children:[(0,s.jsx)("option",{value:"",children:"—"}),t.map(e=>(0,s.jsx)("option",{value:e,children:e},e))]})]})]})})}function eP({phase:e,onUpdate:r}){return(0,s.jsx)(ej,{label:"Gate \xb7 what happens when this phase finishes",children:(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>r({gate:"auto"}),className:(0,T.cn)("rounded-md border px-2.5 py-1.5 text-left transition","auto"===e.gate?"border-emerald-500/40 bg-emerald-500/10":"border-border bg-card/40 hover:border-foreground/30"),children:[(0,s.jsx)("div",{className:"text-xs font-medium",children:"Auto-proceed"}),(0,s.jsx)("div",{className:"text-[10px] text-muted-foreground",children:"Continue to next phase without asking."})]}),(0,s.jsxs)("button",{type:"button",onClick:()=>r({gate:"ask-user"}),className:(0,T.cn)("rounded-md border px-2.5 py-1.5 text-left transition","ask-user"===e.gate?"border-amber-500/40 bg-amber-500/10":"border-border bg-card/40 hover:border-foreground/30"),children:[(0,s.jsx)("div",{className:"text-xs font-medium",children:"Checkpoint (ask me)"}),(0,s.jsx)("div",{className:"text-[10px] text-muted-foreground",children:"Stop here, surface verdict, wait for click."})]})]})})}function eT({phase:e,index:r,total:t,allPhaseIds:n,connectedVoices:o,personas:d,onUpdate:l,onMoveUp:c,onMoveDown:u,onDelete:m}){let[x,p]=(0,a.useState)(0===r),h=ed[e.kind],f=n.slice(0,r);return(0,s.jsxs)("div",{className:"rounded-lg border border-border bg-card/40",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>p(e=>!e),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left",children:[(0,s.jsx)("span",{className:"font-mono text-[10px] text-muted-foreground/60",children:String(r+1).padStart(2,"0")}),(0,s.jsx)("span",{className:"grid h-7 w-7 shrink-0 place-items-center rounded-md bg-primary/15 text-primary",children:(0,s.jsx)(h,{className:"h-3.5 w-3.5"})}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-foreground truncate",children:e.name||"Untitled phase"}),(0,s.jsx)("span",{className:"font-mono text-[10px] uppercase text-muted-foreground/70",children:e.kind})]}),(0,s.jsx)(e$,{phase:e})]}),(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5",children:[(0,s.jsx)(ev,{disabled:0===r,onClick:c,title:"Move up",children:(0,s.jsx)(ep.A,{className:"h-3 w-3"})}),(0,s.jsx)(ev,{disabled:r===t-1,onClick:u,title:"Move down",children:(0,s.jsx)(eh.A,{className:"h-3 w-3"})}),(0,s.jsx)(ev,{onClick:m,title:"Delete phase",className:"hover:text-rose-400",children:(0,s.jsx)(i.A,{className:"h-3 w-3"})}),(0,s.jsx)("span",{className:"ml-1 text-muted-foreground/60",children:x?(0,s.jsx)(ef.A,{className:"h-3.5 w-3.5"}):(0,s.jsx)(J.A,{className:"h-3.5 w-3.5"})})]})]}),x&&(0,s.jsxs)("div",{className:"space-y-4 border-t border-border bg-background/40 px-3 py-3",children:[(0,s.jsxs)("div",{className:"grid grid-cols-[1fr_140px] gap-2",children:[(0,s.jsx)(ej,{label:"Name",children:(0,s.jsx)("input",{type:"text",value:e.name,onChange:e=>l({name:e.target.value}),className:"h-8 w-full rounded-md border border-border bg-background px-2.5 text-xs text-foreground focus:border-primary/60 focus:outline-none"})}),(0,s.jsx)(ej,{label:"Kind",children:(0,s.jsx)("select",{value:e.kind,onChange:e=>l({kind:e.target.value}),className:"h-8 w-full rounded-md border border-border bg-background px-2 text-xs text-foreground focus:border-primary/60 focus:outline-none",children:el.map(e=>(0,s.jsx)("option",{value:e.id,children:e.label},e.id))})})]}),(0,s.jsx)(ej,{label:"Description",children:(0,s.jsx)("input",{type:"text",value:e.description,onChange:e=>l({description:e.target.value}),placeholder:"What this phase produces and why it exists.",className:"h-8 w-full rounded-md border border-border bg-background px-2.5 text-xs text-foreground placeholder:text-muted-foreground/60 focus:border-primary/60 focus:outline-none"})}),"review_only"!==e.kind&&(0,s.jsx)(eC,{phase:e,onUpdate:l,connectedVoices:o,personas:d}),"review_only"===e.kind&&(0,s.jsx)(eM,{phase:e,onUpdate:l}),(0,s.jsx)(eS,{phase:e,onUpdate:l,connectedVoices:o,personas:d}),(0,s.jsx)(eY,{phase:e,onUpdate:l}),(0,s.jsx)(eD,{phase:e,onUpdate:l}),f.length>0&&(0,s.jsx)(eR,{phase:e,onUpdate:l,priorPhases:f}),"review_only"!==e.kind&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eL,{phase:e,onUpdate:l,priorPhases:f}),(0,s.jsx)(eP,{phase:e,onUpdate:l})]})]})]})}function e$({phase:e}){return(0,s.jsxs)("div",{className:"mt-0.5 flex flex-wrap items-center gap-1.5 text-[10px] text-muted-foreground",children:["review_only"!==e.kind&&(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{className:(0,T.cn)("h-1.5 w-1.5 rounded-full",ec.find(r=>r.id===e.doer.lineage)?.dot)}),"doer: ",e.doer.lineage]}),e.reviewer.candidates.length>0&&(0,s.jsxs)(s.Fragment,{children:["review_only"!==e.kind&&(0,s.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,s.jsxs)("span",{className:"flex items-center gap-1",children:["reviewers:",e.reviewer.candidates.map(e=>(0,s.jsx)("span",{className:(0,T.cn)("h-1.5 w-1.5 rounded-full",ec.find(r=>r.id===e)?.dot),title:e},e))]})]}),e.reviewer.crossLineage&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,s.jsx)("span",{className:"text-amber-300/90 font-mono text-[9px] uppercase",children:"cross-lineage"})]}),(0,s.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,s.jsx)("span",{className:(0,T.cn)("font-mono text-[9px] uppercase","sequential"===e.execution?"text-amber-300/90":"text-emerald-300/80"),title:"sequential"===e.execution?"Sequential hostile — reviewers chain":"Parallel independent — reviewers vote",children:"sequential"===e.execution?"sequential":"parallel"}),e.inputs.exclude.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,s.jsxs)("span",{className:"text-rose-300/90 font-mono text-[9px]",children:["blind-to: ",e.inputs.exclude.join(",")]})]})]})}function e_({phases:e,onChange:r}){let t=ex(),{personas:n}=function(){let[e,r]=(0,a.useState)({personas:[],loaded:!1});return(0,a.useEffect)(()=>{(0,X.UT)().then(e=>r({personas:e,loaded:!0})).catch(()=>r({personas:[],loaded:!0}))},[]),e}();function o(t,s){let a=t+s;if(a<0||a>=e.length)return;let n=[...e];[n[t],n[a]]=[n[a],n[t]],r(n)}let i=e.map(e=>e.id);return(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,s.jsxs)("span",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:["Phases (",e.length,")"]}),(0,s.jsx)("span",{className:"text-[11px] text-muted-foreground/70",children:"Each phase has a doer + reviewer. Adversarial by default."})]}),(0,s.jsx)("div",{className:"space-y-2",children:e.map((a,d)=>(0,s.jsx)(eT,{phase:a,index:d,total:e.length,allPhaseIds:i,connectedVoices:t,personas:n,onUpdate:t=>{r(e.map((e,r)=>r===d?{...e,...t}:e))},onMoveUp:()=>o(d,-1),onMoveDown:()=>o(d,1),onDelete:()=>{r(e.filter((e,r)=>r!==d))}},a.id))}),(0,s.jsxs)("button",{type:"button",onClick:function(){var t;r([...e,(t=e.length,{id:`phase-${t+1}`,name:`Phase ${t+1}`,description:"",kind:"review",gate:"auto",doer:{lineage:"claude",models:["claude-opus-4-7"]},reviewer:{require:1,crossLineage:!0,candidates:["codex"]},inputs:{include:[],exclude:[]},iterate:{max:3,onMax:"ask-user"},blindSpots:[],execution:"sequential",builtin:!1})])},className:"mt-3 flex w-full items-center justify-center gap-1.5 rounded-md border border-dashed border-border bg-card/30 px-3 py-2.5 text-xs font-medium text-muted-foreground transition hover:border-primary/40 hover:bg-card/50 hover:text-foreground",children:[(0,s.jsx)(x.A,{className:"h-3.5 w-3.5"}),"Add phase"]})]})}function eq({active:e,onClick:r,disabled:t,children:a}){return(0,s.jsxs)("button",{type:"button",onClick:r,disabled:t,className:(0,T.cn)("relative flex items-center gap-1.5 rounded-t-md px-3 py-2.5 text-sm font-medium transition-colors",t?"cursor-not-allowed text-muted-foreground/50":e?"text-foreground":"text-muted-foreground hover:text-foreground"),children:[a,e&&!t&&(0,s.jsx)("span",{className:"absolute inset-x-0 -bottom-px h-0.5 bg-primary"})]})}function eE({label:e,htmlFor:r,hint:t,children:a}){return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("label",{htmlFor:r,className:"block text-[13px] font-medium text-foreground",children:e}),a,t&&(0,s.jsx)("p",{className:"text-[11px] leading-snug text-muted-foreground/80",children:t})]})}function eI({active:e,onClick:r,children:t}){return(0,s.jsx)("button",{type:"button",onClick:r,className:(0,T.cn)("h-8 rounded-md border px-3 text-xs font-medium transition",e?"border-primary/60 bg-primary/15 text-primary":"border-border bg-card text-muted-foreground hover:border-muted-foreground/30 hover:bg-accent/40 hover:text-foreground"),children:t})}function eF({form:e,setField:r,showErrors:t}){let a=t&&0===e.name.trim().length,n=t&&0===e.description.trim().length;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(eE,{label:"Name *",htmlFor:"tpl-name",children:[(0,s.jsx)("input",{id:"tpl-name",value:e.name,onChange:e=>r("name",e.target.value),placeholder:"security-audit","aria-invalid":a,className:(0,T.cn)("h-10 w-full rounded-md border bg-background px-3 text-sm placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2",a?"border-destructive/60 focus:border-destructive focus:ring-destructive/30":"border-border focus:border-primary/60 focus:ring-primary/20")}),a&&(0,s.jsx)("p",{className:"text-[11px] text-destructive",children:"Name is required."})]}),(0,s.jsxs)(eE,{label:"Description *",htmlFor:"tpl-desc",hint:"One sentence on when someone should reach for this template.",children:[(0,s.jsx)("textarea",{id:"tpl-desc",value:e.description,onChange:e=>r("description",e.target.value),placeholder:"Independent security audit from 3 model families…",rows:2,"aria-invalid":n,className:(0,T.cn)("w-full resize-none rounded-md border bg-background px-3 py-2 text-sm leading-relaxed placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2",n?"border-destructive/60 focus:border-destructive focus:ring-destructive/30":"border-border focus:border-primary/60 focus:ring-primary/20")}),n&&(0,s.jsx)("p",{className:"text-[11px] text-destructive",children:"Description is required."})]}),(0,s.jsx)(eE,{label:"Category",children:(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:B.map(t=>(0,s.jsx)(eI,{active:t.id===e.category,onClick:()=>r("category",t.id),children:t.label},t.id))})})]})}function eO({form:e,setField:r}){let t=ex();return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"rounded-md border border-border bg-card/40 px-3 py-2 text-[11px] leading-relaxed text-muted-foreground",children:[(0,s.jsxs)("div",{className:"mb-1 flex items-center gap-1.5 text-foreground",children:[(0,s.jsx)(q.A,{className:"h-3 w-3"}),(0,s.jsx)("span",{className:"text-[12px] font-medium",children:"Template-level fallback chains"})]}),"Tried in order whenever a slot exhausts its own per-slot model chain. Cross-lineage swap supported — a codex slot can fall through to a claude or kimi entry. Strict",(0,s.jsx)("span",{className:"font-mono",children:" (lineage, model)"})," dedup keeps diversity: a fallback whose model already runs as another reviewer in this phase is skipped, so you never review the same code twice with the same voice. Order matters — list your most-preferred fallback first."]}),(0,s.jsx)(ez,{title:"Doer fallback",hint:"Engaged when the doer's primary + per-slot models all fail.",rows:e.fallbackDoer,onChange:e=>r("fallbackDoer",e),connectedVoices:t}),(0,s.jsx)(ez,{title:"Reviewer fallback",hint:"Engaged when any reviewer's primary + per-slot models all fail.",rows:e.fallbackReviewer,onChange:e=>r("fallbackReviewer",e),connectedVoices:t})]})}function ez({title:e,hint:r,rows:t,onChange:a,connectedVoices:n}){let o=(e,r)=>{a(t.map((t,s)=>s===e?{...t,...r}:t))};return(0,s.jsxs)("div",{className:"rounded-lg border border-border bg-card/40 p-4",children:[(0,s.jsxs)("div",{className:"mb-1 flex items-center justify-between",children:[(0,s.jsx)("h4",{className:"text-[13px] font-semibold tracking-tight",children:e}),(0,s.jsxs)("button",{type:"button",onClick:()=>{let e=W.find(e=>(n.byLineage[e]??[]).length>0)??"claude",r=n.byLineage[e]?.[0]??"";a([...t,{lineage:e,model:r}])},className:"inline-flex h-7 items-center gap-1 rounded-md border border-border bg-card px-2.5 text-[11px] font-medium text-muted-foreground transition hover:border-primary/40 hover:text-primary",children:[(0,s.jsx)(x.A,{className:"h-3 w-3"}),"Add fallback"]})]}),(0,s.jsx)("p",{className:"mb-3 text-[11px] leading-snug text-muted-foreground/80",children:r}),0===t.length?(0,s.jsx)("p",{className:"rounded-md border border-dashed border-border/60 bg-background/30 px-3 py-4 text-center text-[11px] text-muted-foreground",children:"None set — slot will fail its phase if the per-slot chain exhausts."}):(0,s.jsx)("ul",{className:"space-y-2",children:t.map((e,r)=>{let i=n.byLineage[e.lineage]??[],d=0===e.model.length||i.includes(e.model);return(0,s.jsxs)("li",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-border bg-card font-mono text-[10px] text-muted-foreground",children:r+1}),(0,s.jsx)("select",{value:e.lineage,onChange:e=>{var s;let a,i;return s=e.target.value,a=n.byLineage[s]??[],i=t[r].model,void o(r,{lineage:s,model:a.includes(i)?i:a[0]??""})},className:"h-8 rounded-md border border-border bg-background px-2 text-xs text-foreground focus:border-primary/60 focus:outline-none focus:ring-1 focus:ring-primary/20",children:W.map(e=>(0,s.jsx)("option",{value:e,children:e},e))}),(0,s.jsxs)("select",{value:e.model,onChange:e=>o(r,{model:e.target.value}),className:"h-8 flex-1 rounded-md border border-border bg-background px-2 font-mono text-[11px] text-foreground focus:border-primary/60 focus:outline-none focus:ring-1 focus:ring-primary/20",children:[0===i.length&&(0,s.jsx)("option",{value:"",disabled:!0,children:n.loaded?`No ${e.lineage} models enabled — open Connect → ${e.lineage}`:"loading…"}),i.map(e=>(0,s.jsx)("option",{value:e,children:e},e)),!d&&e.model.length>0&&(0,s.jsxs)("option",{value:e.model,children:[e.model," (stored)"]})]}),(0,s.jsx)("button",{type:"button",onClick:()=>{a(t.filter((e,t)=>t!==r))},"aria-label":`Remove fallback ${r+1}`,className:"grid h-7 w-7 place-items-center rounded-md border border-border bg-card text-muted-foreground transition hover:border-destructive/40 hover:text-destructive",children:(0,s.jsx)(h.A,{className:"h-3 w-3"})})]},r)})})]})}function eB({form:e,setField:r}){return(0,s.jsxs)("div",{className:"rounded-lg border border-border bg-card/40 p-4",children:[(0,s.jsx)("h3",{className:"mb-3 text-[13px] font-semibold tracking-tight",children:"Across all phases"}),(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsx)("div",{className:"mb-1.5 text-[11px] font-medium text-muted-foreground",children:"Agreement threshold (per review-style phase)"}),(0,s.jsx)("div",{className:"grid grid-cols-3 gap-2",children:U.map(t=>(0,s.jsx)("button",{type:"button",onClick:()=>r("threshold",t.id),className:(0,T.cn)("rounded-md border px-3 py-2 text-left transition",e.threshold===t.id?"border-primary/60 bg-primary/10 ring-1 ring-primary/40":"border-border bg-card hover:border-muted-foreground/30 hover:bg-accent/40"),children:(0,s.jsx)("div",{className:"text-xs font-medium",children:t.label})},t.id))}),(0,s.jsx)("p",{className:"mt-1.5 text-[11px] leading-snug text-muted-foreground/80",children:U.find(r=>r.id===e.threshold)?.hint})]}),(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsx)("div",{className:"mb-1.5 text-[11px] font-medium text-muted-foreground",children:"When threshold is met"}),(0,s.jsx)("div",{className:"grid grid-cols-2 gap-2",children:V.map(t=>(0,s.jsx)("button",{type:"button",onClick:()=>r("onThresholdMet",t.id),className:(0,T.cn)("rounded-md border px-3 py-2 text-left transition",e.onThresholdMet===t.id?"border-primary/60 bg-primary/10 ring-1 ring-primary/40":"border-border bg-card hover:border-muted-foreground/30 hover:bg-accent/40"),children:(0,s.jsx)("div",{className:"text-xs font-medium",children:t.label})},t.id))})]}),(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsxs)("div",{className:"mb-1.5 flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Max revise rounds (per phase)"}),(0,s.jsx)("span",{className:"font-mono text-xs text-foreground",children:e.maxRounds})]}),(0,s.jsx)("input",{type:"range",min:1,max:5,step:1,value:e.maxRounds,onChange:e=>r("maxRounds",parseInt(e.target.value,10)),className:"h-1 w-full cursor-pointer appearance-none rounded-full bg-muted accent-primary"})]}),(0,s.jsxs)("button",{type:"button",onClick:()=>r("yoloDefault",!e.yoloDefault),className:(0,T.cn)("flex w-full items-center justify-between rounded-md border px-3 py-2 text-left transition",e.yoloDefault?"border-rose-500/40 bg-rose-500/5":"border-border bg-card hover:border-foreground/30"),children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-xs font-medium text-foreground",children:"\uD83D\uDE80 Yolo by default"}),(0,s.jsx)("div",{className:"text-[10px] text-muted-foreground",children:"Auto-approve every gate. Only flip on for trusted templates or trivial fixes. Cost cap still enforced."})]}),(0,s.jsx)("span",{className:(0,T.cn)("flex h-5 w-9 shrink-0 items-center rounded-full border p-0.5 transition",e.yoloDefault?"border-rose-500/40 bg-rose-500/20":"border-border bg-card"),children:(0,s.jsx)("span",{className:(0,T.cn)("h-3.5 w-3.5 rounded-full transition-transform",e.yoloDefault?"translate-x-4 bg-rose-400":"bg-muted-foreground/50")})})]})]})}function eU(e,r){let t=[];if(1===e)r.name&&0!==r.name.trim().length?r.name.length>80&&t.push("Name is too long (max 80 chars)."):t.push("Name is required."),r.description&&0!==r.description.trim().length||t.push("Description is required — one line on when to use this template.");else if(2===e)for(let e of(0===r.phases.length&&t.push("At least one phase is required."),r.phases))e.id&&0!==e.id.trim().length||t.push(`Phase "${e.name||"(unnamed)"}" needs an id.`),"review_only"===e.kind||e.doer.lineage&&0!==e.doer.models.length||t.push(`Phase "${e.name||e.id}" needs a doer lineage + model.`),0===e.reviewer.candidates.length&&t.push(`Phase "${e.name||e.id}" needs at least one reviewer.`);return t}function eV({form:e,setField:r}){let[t,n]=(0,a.useState)(1),[o,i]=(0,a.useState)(!1),d=eU(t,e),l=0===d.length;return(0,s.jsxs)("div",{className:"flex h-full flex-col px-6 py-6",children:[(0,s.jsx)(eG,{currentStep:t,onJump:r=>{if(r<=t){i(!1),n(r);return}for(let s=t;s<r;s++)if(eU(s,e).length>0)return void i(!0);i(!1),n(r)},form:e}),(0,s.jsxs)("div",{className:"mt-6 flex-1 space-y-6",children:[1===t&&(0,s.jsx)(eF,{form:e,setField:r,showErrors:o}),2===t&&(0,s.jsx)(eW,{form:e,setField:r,showErrors:o}),3===t&&(0,s.jsx)(eO,{form:e,setField:r}),4===t&&(0,s.jsx)(eB,{form:e,setField:r})]}),o&&d.length>0&&(0,s.jsxs)("div",{className:"mt-6 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:[(0,s.jsx)("div",{className:"mb-1 font-medium",children:"Resolve these to continue:"}),(0,s.jsx)("ul",{className:"space-y-0.5 pl-4",children:d.map(e=>(0,s.jsx)("li",{className:"list-disc",children:e},e))})]}),(0,s.jsxs)("div",{className:"mt-6 flex items-center justify-between border-t border-border pt-4",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>{i(!1),t>1&&n(t-1)},disabled:1===t,className:"inline-flex h-9 items-center gap-1.5 rounded-md border border-border bg-card px-3 text-sm font-medium text-muted-foreground transition hover:border-muted-foreground/30 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40",children:[(0,s.jsx)(Z.A,{className:"h-3.5 w-3.5"}),"Back"]}),(0,s.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:["Step ",t," of 4 \xb7 ",G[t-1].label]}),t<4?(0,s.jsxs)("button",{type:"button",onClick:()=>{l?(i(!1),t<4&&n(t+1)):i(!0)},className:(0,T.cn)("inline-flex h-9 items-center gap-1.5 rounded-md px-3 text-sm font-medium shadow-sm transition",l?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-muted text-muted-foreground/60"),children:["Next",(0,s.jsx)(J.A,{className:"h-3.5 w-3.5"})]}):(0,s.jsxs)("span",{className:"text-[11px] text-emerald-300",children:[(0,s.jsx)(b.A,{className:"mr-1 inline-block h-3 w-3"}),"Save in the footer below"]})]})]})}function eG({currentStep:e,onJump:r,form:t}){return(0,s.jsx)("div",{className:"flex items-stretch gap-2",children:G.map(a=>{let n=a.icon,o=a.id===e,i=0===eU(a.id,t).length,d=a.id<e;return(0,s.jsxs)("button",{type:"button",onClick:()=>r(a.id),className:(0,T.cn)("flex flex-1 items-center gap-2 rounded-md border px-3 py-2 text-left transition",o?"border-primary/60 bg-primary/10":d&&!i?"border-destructive/40 bg-destructive/5":"border-border bg-card hover:border-muted-foreground/30"),children:[(0,s.jsx)("span",{className:(0,T.cn)("flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-[10px] font-mono",o?"bg-primary text-primary-foreground":d&&i?"bg-emerald-500/20 text-emerald-300":d&&!i?"bg-destructive/20 text-destructive":"bg-muted text-muted-foreground"),children:d&&i?"✓":a.id}),(0,s.jsx)(n,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,s.jsx)("span",{className:"hidden text-xs font-medium sm:inline",children:a.label})]},a.id)})})}function eW({form:e,setField:r,showErrors:t}){let a=eU(2,e);return(0,s.jsxs)(s.Fragment,{children:[t&&a.length>0&&(0,s.jsx)("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:a[0]}),(0,s.jsx)(e_,{phases:e.phases,onChange:e=>r("phases",e)})]})}function eK(e){return Array.isArray(e)?e.flatMap(e=>{let r=F[e.lineage??""]??"claude",t=(e.models??[]).filter(e=>"string"==typeof e&&e.trim().length>0);return 0===t.length?[]:t.map(t=>({lineage:r,model:t,...e.persona?{persona:e.persona}:{}}))}):[]}let eH=["plan","spec","tests","implement","review","verify","divergence","review_only"];function eZ(e,r){let t,s,a,n,o=[];try{t=y.Ay.parse(e)??{}}catch{return{form:{...z,id:r},formLossy:!0,lossyReasons:["YAML failed to parse — only YAML mode is available."]}}t.ship?.enabled&&o.push("Template has `ship.enabled: true` — form mode can't edit ship config.");let i=[];for(let e of t.phases??[]){let{phase:r,reasons:t}=function(e){let r=[];void 0!==e.timeoutMs&&r.push(`Phase ${e.id??"?"} has \`timeoutMs\` — not exposed in form mode.`);let t="review_only"===e.kind,s=t?"claude":F[e.doer?.lineage??""]??"claude",a={},n={},o=new Set,i=[],d=[];for(let r of e.reviewer?.candidates??[]){let e=F[r.lineage??""];if(!e)continue;o.has(e)||(o.add(e),i.push(e));let t=(r.models??[]).map(e=>(e??"").trim()).filter(e=>e.length>0),s=r.persona&&r.persona.trim().length>0?r.persona:void 0,l=r=>{if(!s)return;let t=n[e]??={},a=t[r];void 0!==a&&a!==s&&d.push(`${e}/${r||"(no model)"}: "${a}" vs "${s}"`),t[r]=s};if(0===t.length)l("");else for(let r of t)(a[e]??=[]).push(r),l(r)}d.length>0&&r.push(`Phase ${e.id??"?"} has overlapping reviewer candidates with conflicting personas (${d.join("; ")}) — form mode would silently last-write-wins; edit in YAML to disambiguate.`);let l=eH.includes(e.kind)?e.kind:"review";return e.kind&&!eH.includes(e.kind)&&r.push(`Phase ${e.id??"?"} has unknown kind \`${e.kind}\` — form mode would coerce it to \`review\`.`),{phase:{id:e.id??"phase",name:e.title??e.name??e.id??"Phase",description:e.description??"",kind:l,gate:"auto",doer:{lineage:s,models:e.doer?.models&&e.doer.models.length>0?e.doer.models:[O[s]??"claude-opus-4-7"],...e.doer?.persona&&e.doer.persona.trim().length>0?{persona:e.doer.persona.trim()}:{}},reviewer:{require:e.reviewer?.require??1,crossLineage:e.reviewer?.crossLineage??!0,candidates:i,candidateModels:a,...Object.keys(n).length>0?{candidatePersonas:n}:{}},inputs:{include:e.inputs?.include??[],exclude:e.inputs?.exclude??[]},iterate:{max:e.iterate?.maxRounds??2,onMax:(e.iterate?.onDisagreement??"continue")==="continue"?"loopback":e.iterate?.onDisagreement==="accept-doer"?"fail":"ask-user"},blindSpots:[],execution:"parallel",builtin:!1,...t&&e.artifact?{artifact:{label:e.artifact.label??"Artifact to review",hint:e.artifact.hint??"Paste a unified diff, a markdown draft, code, or any text blob.",maxBytes:e.artifact.maxBytes??1048576}}:t?{artifact:{label:"Artifact to review",hint:"Paste a unified diff, a markdown draft, code, or any text blob.",maxBytes:1048576}}:{}},reasons:r}}(e);i.push(r),o.push(...t)}if("number"==typeof t.agreementThreshold){var d;s=(d=t.agreementThreshold)>=.99?"unanimous":d>=.5?"majority":"any",new Set([1,.66,.34]).has(t.agreementThreshold)||(a=t.agreementThreshold,o.push(`Custom \`agreementThreshold: ${t.agreementThreshold}\` — form mode only offers 1.0 / 0.66 / 0.34 presets.`))}else s=t.agreementThreshold??"majority";let l="review"===t.onThresholdMet?"review":void 0;return"review"===l&&o.push("`onThresholdMet: review` — form mode only offers auto-finalize / ask-user."),{form:{id:t.id??r,name:t.name??"",description:t.description??"",author:t.author??"chorus",category:(n=(t.id??r).toLowerCase()).includes("bug")||n.includes("debug")||n.includes("diagnose")?"debug":n.includes("plan")||n.includes("architect")?"plan":n.includes("decide")||n.includes("decision")?"decide":"review",phases:i.length>0?i:z.phases,threshold:s,...void 0!==a?{customThreshold:a}:{},onThresholdMet:"merge"===t.onThresholdMet?"auto-finalize":"ask-user",...l?{onThresholdMetRaw:l}:{},maxRounds:t.maxRounds??3,yoloDefault:t.yoloDefault??!1,fallbackDoer:eK(t.fallback?.doer),fallbackReviewer:eK(t.fallback?.reviewer)},formLossy:o.length>0,lossyReasons:o}}function eJ({yaml:e,filename:r,issues:t,onChange:a}){return(0,s.jsxs)("div",{className:"flex h-full min-h-[400px] flex-col",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between border-b border-border bg-card/40 px-6 py-2.5",children:[(0,s.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:r}),(0,s.jsx)(eQ,{issues:t})]}),(0,s.jsx)("textarea",{value:e,onChange:e=>a(e.target.value),spellCheck:!1,className:"flex-1 resize-none border-0 bg-background px-6 py-4 font-mono text-[12px] leading-relaxed text-foreground focus:outline-none"}),t.length>0&&(0,s.jsx)("ul",{className:"border-t border-border bg-destructive/5 px-6 py-2.5 text-[11px] text-destructive",children:t.map((e,r)=>(0,s.jsxs)("li",{className:"flex items-start gap-1.5 leading-snug",children:[(0,s.jsx)(g.A,{className:"mt-[1px] h-3 w-3 shrink-0"}),(0,s.jsxs)("span",{children:[(0,s.jsx)("span",{className:"font-mono",children:e.path}),"number"==typeof e.line&&` (line ${e.line})`,": ",e.message]})]},r))})]})}function eQ({issues:e}){return 0===e.length?(0,s.jsxs)("span",{className:"flex items-center gap-1 rounded-md bg-emerald-500/10 px-1.5 py-0.5 text-[10px] font-medium text-emerald-400",children:[(0,s.jsx)(b.A,{className:"h-3 w-3"}),"Valid"]}):(0,s.jsxs)("span",{className:"flex items-center gap-1 rounded-md bg-destructive/10 px-1.5 py-0.5 text-[10px] font-medium text-destructive",children:[(0,s.jsx)(g.A,{className:"h-3 w-3"}),e.length," ",1===e.length?"issue":"issues"]})}function eX({editing:e,trigger:r,onSaved:t}){var i;let[d,l]=(0,a.useState)(!1),c=!!e,u=(0,a.useMemo)(()=>{if(!e)return{form:z,yaml:H(z),lossy:!1,reasons:[]};let r=eZ(e.yaml,e.id);return{form:r.form,yaml:e.yaml,lossy:r.formLossy,reasons:r.lossyReasons}},[e?.id,e?.yaml]),[m,w]=(0,a.useState)(u.form),[N,k]=(0,a.useState)(u.yaml),[A,C]=(0,a.useState)(!1),[M,S]=(0,a.useState)(!1),[Y,D]=(0,a.useState)(u.lossy?"yaml":"form"),[R,$]=(0,a.useState)(!1),[_,q]=(0,a.useState)(null),[E,I]=(0,a.useState)([]);(0,a.useEffect)(()=>{w(u.form),k(u.yaml),C(!1),S(!1),D(u.lossy?"yaml":"form"),q(null),I([])},[u]);let F=(0,a.useRef)(u);(0,a.useEffect)(()=>{F.current=u});let O=(i={yamlDirty:A,tab:Y,formDirty:M,yamlText:N,formYaml:H(m),initialYaml:u.yaml}).yamlDirty||"yaml"===i.tab?i.yamlText:i.formDirty?i.formYaml:i.initialYaml,B=(0,a.useMemo)(()=>(function(e){let r;if(0===e.trim().length)return{valid:!1,issues:[{path:"<yaml>",message:"Template YAML is empty."}]};try{r=y.Ay.parse(e)}catch(t){let e=t instanceof Error?t.message:String(t),r=t.linePos?.[0];return{valid:!1,issues:[{path:"<yaml>",message:e,...r?{line:r.line,col:r.col}:{}}]}}if(null==r)return{valid:!1,issues:[{path:"<yaml>",message:"Template YAML parsed to null — at minimum it must define id, name, and phases."}]};let t=L.safeParse(r);return t.success?P:{valid:!1,issues:t.error.issues.map(e=>({path:e.path.length>0?e.path.join("."):"<root>",message:e.message}))}})(O),[O]);function U(e){if("form"===e&&A){let e=eZ(N,m.id);if(e.formLossy)return;w(e.form),C(!1),S(!0)}D(e)}function V(){let e=F.current;w(e.form),k(e.yaml),C(!1),S(!1),D(e.lossy?"yaml":"form"),$(!1),q(null),I([])}function G(e){l(e),e||setTimeout(V,200)}async function W(){if(!B.valid||R)return;let r=c?e.id:m.id||K(m.name)||"untitled";$(!0),q(null),I([]);try{let e=await (0,j.AI)({id:r,yaml:O});t?.(e.id),G(!1)}catch(e){e instanceof j.$v?(q(e.message),I(e.details?.issues??[])):q(e instanceof Error?e.message:"Save failed (unknown error)")}finally{$(!1)}}let Z=B.valid&&!R,J=r??(0,s.jsxs)("button",{type:"button","aria-label":c?"Edit template":"New template",className:"inline-flex shrink-0 items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground shadow-sm transition hover:bg-primary/90",children:[c?(0,s.jsx)(n.A,{className:"h-4 w-4"}):(0,s.jsx)(x.A,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"hidden sm:inline",children:c?"Edit":"New template"})]});return(0,s.jsxs)(v.lG,{open:d,onOpenChange:G,children:[(0,s.jsx)(v.zM,{asChild:!0,children:J}),(0,s.jsxs)(v.Cf,{showCloseButton:!1,className:"flex max-h-[85vh] w-[min(96vw,720px)] flex-col gap-0 overflow-hidden border-border bg-card p-0 shadow-2xl sm:max-w-none",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 border-b border-border px-6 py-4",children:[(0,s.jsx)("div",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-md bg-primary/15 text-primary ring-1 ring-primary/20",children:(0,s.jsx)(p.A,{className:"h-4 w-4"})}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)(v.L3,{className:"text-[15px] font-semibold leading-tight tracking-tight",children:c?`Edit template — ${e.name}`:"New template"}),(0,s.jsx)(v.rr,{className:"mt-0.5 text-xs text-muted-foreground",children:c?"Edit the YAML directly or use the form. Validation runs live.":"A reusable review workflow. Edit visually below or paste raw YAML."})]}),(0,s.jsx)("button",{type:"button",onClick:()=>G(!1),className:"grid h-7 w-7 place-items-center rounded-md text-muted-foreground transition hover:bg-accent hover:text-foreground","aria-label":"Close",children:(0,s.jsx)(h.A,{className:"h-4 w-4"})})]}),(0,s.jsx)("div",{className:"border-b border-border bg-card/40 px-6",children:(0,s.jsxs)("div",{className:"-mb-px flex items-center gap-1",children:[(0,s.jsxs)(eq,{active:"form"===Y,onClick:()=>!u.lossy&&U("form"),disabled:u.lossy,children:[(0,s.jsx)(f.A,{className:"h-3.5 w-3.5"}),"Form",u.lossy&&(0,s.jsx)("span",{className:"ml-1 rounded bg-muted px-1 text-[9px] font-medium text-muted-foreground",children:"YAML only"})]}),(0,s.jsxs)(eq,{active:"yaml"===Y,onClick:()=>U("yaml"),children:[(0,s.jsx)(p.A,{className:"h-3.5 w-3.5"}),"YAML",!B.valid&&"form"===Y&&(0,s.jsx)("span",{className:"ml-1 h-1.5 w-1.5 rounded-full bg-destructive"})]})]})}),(0,s.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[u.lossy&&"yaml"===Y&&(0,s.jsx)("div",{className:"border-b border-amber-500/30 bg-amber-500/5 px-6 py-2.5 text-[11px] text-amber-200",children:(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)(g.A,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("div",{className:"font-medium",children:"Form editing disabled for this template"}),(0,s.jsx)("ul",{className:"mt-1 space-y-0.5 leading-snug",children:u.reasons.map((e,r)=>(0,s.jsxs)("li",{children:["\xb7 ",e]},r))})]})]})}),"form"===Y?(0,s.jsx)(eV,{form:m,setField:function(e,r){let t={...m,[e]:r};w(t),S(!0),A||k(H(t))}}):(0,s.jsx)(eJ,{yaml:N,filename:`${m.id||K(m.name)||"untitled"}.yaml`,issues:B.issues,onChange:e=>{k(e),C(!0)}})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-2 border-t border-border bg-card/40 px-6 py-3",children:[_&&(0,s.jsx)("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:(0,s.jsxs)("div",{className:"flex items-start gap-1.5",children:[(0,s.jsx)(g.A,{className:"mt-0.5 h-3 w-3 shrink-0"}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("div",{className:"font-medium",children:"Save failed"}),(0,s.jsx)("div",{className:"mt-0.5 leading-snug",children:_}),E.length>0&&(0,s.jsx)("ul",{className:"mt-1 space-y-0.5",children:E.slice(0,5).map((e,r)=>(0,s.jsxs)("li",{children:[(0,s.jsx)("span",{className:"font-mono",children:e.path}),":"," ",e.message]},r))})]})]})}),(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsx)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:B.valid?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(b.A,{className:"h-3 w-3 text-emerald-400"}),(0,s.jsx)("span",{children:"Ready to save"})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(g.A,{className:"h-3 w-3 text-destructive/80"}),(0,s.jsxs)("span",{children:[B.issues.length," ",1===B.issues.length?"issue":"issues"," to resolve"]})]})}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("button",{type:"button",onClick:()=>G(!1),className:"h-9 rounded-md border border-border bg-card px-4 text-sm font-medium text-muted-foreground transition hover:border-muted-foreground/30 hover:text-foreground",children:"Cancel"}),(0,s.jsxs)("button",{type:"button",disabled:!Z,onClick:W,className:(0,T.cn)("inline-flex h-9 items-center gap-1.5 rounded-md px-4 text-sm font-medium shadow-sm transition",Z?"bg-primary text-primary-foreground hover:bg-primary/90":"cursor-not-allowed bg-muted text-muted-foreground/60 shadow-none"),children:[R&&(0,s.jsx)(o.A,{className:"h-3.5 w-3.5 animate-spin"}),R?"Saving…":c?"Save changes":"Save template"]})]})]})]})]})]})}let e0=Object.fromEntries(Object.entries(ei.r2).map(([e,r])=>[e,r.dot])),e1=[{id:"all",label:"All"},{id:"review",label:"Review"},{id:"plan",label:"Plan"},{id:"debug",label:"Debug"},{id:"decide",label:"Decide"}];function e5(){let[e,r]=(0,a.useState)([]),[t,x]=(0,a.useState)(null),[p,h]=(0,a.useState)("all"),[f,g]=(0,a.useState)(""),[b,v]=(0,a.useState)(null),[y,w]=(0,a.useState)(null),[N,k]=(0,a.useState)(null),A=(0,a.useCallback)(async e=>{try{let t=await (0,j.eG)();r(t),e&&t.find(r=>r.id===e)?g(e):t.length>0&&!f&&g(t[0].id)}catch(e){x(e instanceof j.$v?e.message:"Failed to load templates")}},[f]);async function C(e){if(!y&&"builtin"!==e.source){if(b!==e.id){v(e.id),k(null),setTimeout(()=>{v(r=>r===e.id?null:r)},8e3);return}w(e.id),k(null);try{await (0,j.I7)(e.id),v(null),f===e.id&&g(""),await A()}catch(e){k(e instanceof j.$v||e instanceof Error?e.message:"Delete failed (unknown error)"),v(null)}finally{w(null)}}}(0,a.useEffect)(()=>{A()},[]);let M="all"===p?e:e.filter(e=>e.category===p),S=e.find(e=>e.id===f)??e[0]??null;return t?(0,s.jsx)(d.G,{children:(0,s.jsx)("div",{className:"mx-auto w-full max-w-6xl px-4 py-6 sm:px-6 sm:py-8 md:px-8 md:py-10",children:(0,s.jsxs)("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4",children:[(0,s.jsx)("p",{className:"text-sm text-destructive",children:"Error loading templates"}),(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:t})]})})}):(0,s.jsx)(d.G,{children:(0,s.jsxs)("div",{className:"mx-auto w-full max-w-6xl px-4 py-6 sm:px-6 sm:py-8 md:px-8 md:py-10",children:[(0,s.jsx)(u.z,{eyebrow:"Templates",title:"Reusable review workflows",subtitle:"Each template defines the driver, reviewers, prompts, and quorum rule for a kind of task. Fork, edit, share.",action:(0,s.jsx)(eX,{onSaved:e=>A(e)})}),N&&(0,s.jsx)("div",{className:"mb-4 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:N}),(0,s.jsx)("div",{className:"mb-4 flex items-center gap-1 border-b border-border",children:e1.map(e=>(0,s.jsxs)("button",{type:"button",onClick:()=>h(e.id),className:`relative px-3 py-2 text-sm transition ${e.id===p?"text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[e.label,e.id===p&&(0,s.jsx)("span",{className:"absolute inset-x-3 bottom-0 h-0.5 bg-primary"})]},e.id))}),(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-[1fr_1fr]",children:[(0,s.jsx)("div",{className:"flex min-w-0 flex-col gap-2",children:M.map(e=>(0,s.jsxs)("div",{role:"button",tabIndex:0,onClick:()=>g(e.id),onKeyDown:r=>{("Enter"===r.key||" "===r.key)&&(r.preventDefault(),g(e.id))},className:`group relative cursor-pointer rounded-xl text-left transition focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60 ${e.id===f?"ring-2 ring-primary/60 ring-offset-2 ring-offset-background":""}`,children:[(0,s.jsxs)(l.Zp,{className:"bg-card p-4 transition group-hover:border-muted-foreground/30",children:[(0,s.jsx)("div",{className:"flex items-start justify-between gap-3",children:(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm font-semibold",children:e.name}),(0,s.jsx)(c.E,{variant:"outline",className:"border-border text-[10px] capitalize",children:e.category})]}),(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground line-clamp-2",children:e.description})]})}),e.phases[0]?.reviewer?.candidates.length?(0,s.jsxs)("div",{className:"mt-3 flex items-center gap-2 text-[11px] text-muted-foreground",children:[e.phases[0]?.kind!=="review_only"&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-amber-400"}),"doer"]}),(0,s.jsx)("span",{className:"text-muted-foreground/40",children:"→"})]}),(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[e.phases[0]?.reviewer?.candidates.map(e=>(0,s.jsx)("span",{className:`h-1.5 w-1.5 rounded-full ${e0[e]}`,title:e},e)),(0,s.jsxs)("span",{children:[e.phases[0]?.reviewer?.candidates.length," ",e.phases[0]?.reviewer?.candidates.length===1?"reviewer":"reviewers"]})]}),e.phases.length>1&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,s.jsxs)("span",{className:"font-mono text-[10px]",children:[e.phases.length," phases"]})]})]}):null]}),(0,s.jsxs)("div",{className:`absolute bottom-3 right-3 flex items-center gap-1.5 transition ${e.id===f?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,onClick:r=>{r.stopPropagation(),g(e.id)},onKeyDown:e=>e.stopPropagation(),children:[(0,s.jsx)(eX,{editing:e,onSaved:e=>A(e),trigger:(0,s.jsx)("button",{type:"button","aria-label":`Edit ${e.name}`,className:"grid h-7 w-7 place-items-center rounded-md border border-border bg-card text-muted-foreground transition hover:border-muted-foreground/40 hover:bg-accent/60 hover:text-foreground",children:(0,s.jsx)(n.A,{className:"h-3.5 w-3.5"})})}),"builtin"!==e.source&&(0,s.jsx)("button",{type:"button","aria-label":b===e.id?`Confirm delete ${e.name}`:`Delete ${e.name}`,title:b===e.id?"Click again to confirm":"Delete",disabled:y===e.id,onClick:()=>C(e),className:`grid h-7 w-7 place-items-center rounded-md border transition disabled:cursor-not-allowed disabled:opacity-50 ${b===e.id?"border-destructive bg-destructive/15 text-destructive":"border-border bg-card text-muted-foreground hover:border-destructive/50 hover:text-destructive"}`,children:y===e.id?(0,s.jsx)(o.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(i.A,{className:"h-3.5 w-3.5"})})]})]},e.id))}),S?(0,s.jsx)("div",{className:"lg:sticky lg:top-6 lg:max-h-[calc(100vh-10rem)] lg:h-[calc(100vh-10rem)]",children:(0,s.jsx)(m.N,{filename:`${S.id}.yaml`,charCount:S.yaml.length,maxHeightClassName:"h-full",footer:(0,s.jsxs)("span",{children:["by ",S.authorHandle]}),children:S.yaml})}):(0,s.jsx)(l.Zp,{className:"bg-card p-4 text-center text-muted-foreground",children:(0,s.jsx)("p",{children:"Select a template to view details"})})]})]})})}},9936:(e,r,t)=>{Promise.resolve().then(t.bind(t,4538))}},e=>{e.O(0,[116,720,15,641,344,744,506,128,358],()=>e(e.s=9936)),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[814],{4538:(e,r,t)=>{"use strict";t.r(r),t.d(r,{default:()=>e5});var s=t(9442),a=t(6074),n=t(4052),o=t(3149),i=t(8420),d=t(4372),l=t(63),c=t(5702),u=t(6457),m=t(8191),x=t(9315),p=t(2865),h=t(6891),f=t(6458),g=t(4030),b=t(2956),v=t(1853),j=t(6185),y=t(599),w=t(2794);let N=w.ai().int().min(3e4).max(36e5).optional(),k=w.k5(["anthropic","openai","google","opencode","moonshot","openrouter","any"]),C=w.k5(["anthropic","openai","google","opencode","moonshot","openrouter"]),A=w.Ik({require:w.ai().int().min(0).default(1),crossLineage:w.zM().default(!0),candidates:w.YO(w.Ik({lineage:C,models:w.YO(w.Yj()).optional(),persona:w.Yj().optional()}))}),M=w.Ik({include:w.YO(w.Yj()).default([]),exclude:w.YO(w.Yj()).default([])}).default({include:[],exclude:[]}),S=w.Ik({maxRounds:w.ai().int().min(1).default(2),onDisagreement:w.k5(["continue","escalate","accept-doer"]).default("continue"),shareSessionAcrossRounds:w.zM().default(!0),shareSessionAcrossPhases:w.zM().default(!1)}).default({maxRounds:2,onDisagreement:"continue",shareSessionAcrossRounds:!0,shareSessionAcrossPhases:!1}),Y=w.Ik({id:w.Yj().min(1),kind:w.k5(["plan","spec","tests","implement","review","verify","divergence"]),title:w.Yj().min(1),description:w.Yj().optional(),doer:w.Ik({lineage:k,models:w.YO(w.Yj()).optional(),persona:w.Yj().optional()}),reviewer:A.optional(),inputs:M,iterate:S,timeoutMs:N}),L=w.Ik({id:w.Yj().min(1),kind:w.eu("review_only"),title:w.Yj().min(1),description:w.Yj().optional(),reviewer:A,artifact:w.Ik({label:w.Yj().min(1).default("Artifact to review"),hint:w.Yj().default("Paste a unified diff, a markdown draft, code, or any text blob."),maxBytes:w.ai().int().min(1).default(1048576)}).default({label:"Artifact to review",hint:"Paste a unified diff, a markdown draft, code, or any text blob.",maxBytes:1048576}),inputs:M,timeoutMs:N}),D=w.gM("kind",[Y.extend({kind:w.eu("plan")}),Y.extend({kind:w.eu("spec")}),Y.extend({kind:w.eu("tests")}),Y.extend({kind:w.eu("implement")}),Y.extend({kind:w.eu("review")}),Y.extend({kind:w.eu("verify")}),Y.extend({kind:w.eu("divergence")}),L]),R=w.Ik({id:w.Yj().min(1),name:w.Yj().min(1),description:w.Yj().min(1),author:w.Yj().default("chorus"),agreementThreshold:w.ai().min(0).max(1).default(.66),onThresholdMet:w.k5(["merge","ask","review"]).default("ask"),maxRounds:w.ai().int().min(1).default(3),yoloDefault:w.zM().default(!1),estimatedBaselineTokens:w.ai().int().min(0).optional(),phases:w.YO(D).min(1).refine(e=>{let r=e.filter(e=>"review_only"===e.kind).length;return 0===r||1===r&&1===e.length},{message:"review_only phases cannot be mixed with other phase kinds and only one is allowed (hybrid templates are out of scope)"}).refine(e=>{let r=e.map(e=>e.id);return new Set(r).size===r.length},{message:"phase ids must be unique"}),ship:w.Ik({enabled:w.zM().default(!1),baseBranch:w.Yj().optional(),branchPattern:w.Yj().default("chorus/{chatId}"),titleTemplate:w.Yj().default("chorus: {template} via #{chatId}")}).optional(),fallback:w.Ik({doer:w.YO(w.Ik({lineage:k,models:w.YO(w.Yj()).min(1),persona:w.Yj().optional()})).optional(),reviewer:w.YO(w.Ik({lineage:C,models:w.YO(w.Yj()).min(1),persona:w.Yj().optional()})).optional()}).optional()}),P=Object.freeze({valid:!0,issues:[]});var T=t(7362),$=t(8979),_=t(8821),E=t(4608),q=t(7978);let I={claude:"anthropic",codex:"openai",gemini:"google",opencode:"opencode",kimi:"moonshot",openrouter:"openrouter"},F={anthropic:"claude",openai:"codex",google:"gemini",opencode:"opencode",moonshot:"kimi",xai:"opencode"},O={claude:"claude-opus-4-7",codex:"gpt-5.5",gemini:"gemini-3.1-pro-preview",opencode:"kimi-k2.6",kimi:"kimi-k2.6",openrouter:""},z={id:"",name:"",description:"",author:"you",category:"review",phases:[{id:"review",name:"Review",description:"Three independent critiques.",kind:"review",gate:"ask-user",doer:{lineage:"claude",models:["claude-opus-4-7"]},reviewer:{require:3,crossLineage:!0,candidates:["codex","gemini","opencode"]},inputs:{include:[],exclude:[]},iterate:{max:3,onMax:"ask-user"},blindSpots:[],execution:"parallel",builtin:!1}],threshold:"unanimous",onThresholdMet:"ask-user",maxRounds:3,yoloDefault:!1,fallbackDoer:[],fallbackReviewer:[]},B=[{id:"review",label:"Review"},{id:"plan",label:"Plan"},{id:"debug",label:"Debug"},{id:"decide",label:"Decide"}],U=[{id:"unanimous",label:"Unanimous",hint:"All lineages must agree. Strictest — best for high-stakes reviews."},{id:"majority",label:"Majority",hint:"≥ ⅔ of lineages agree. Good default for code review."},{id:"any",label:"Any",hint:"≥1 lineage agrees. Useful for brainstorming where divergence is fine."}],V=[{id:"auto-finalize",label:"Auto-finalize"},{id:"ask-user",label:"Ask me"}],G=[{id:1,label:"Basics",icon:$.A},{id:2,label:"Phases",icon:_.A},{id:3,label:"Fallback",icon:E.A},{id:4,label:"Policy",icon:q.A}],W=["claude","codex","gemini","opencode","kimi","openrouter"];function K(e){return e.trim().toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-")||"untitled"}function H(e){var r;return y.Ay.stringify({id:(r=e).id||K(r.name),name:r.name||"Untitled template",description:r.description||"Describe what this template is for.",author:r.author||"chorus",agreementThreshold:void 0!==r.customThreshold?r.customThreshold:function(e){switch(e){case"unanimous":return 1;case"majority":return .66;case"any":return .34}}(r.threshold),onThresholdMet:r.onThresholdMetRaw??("auto-finalize"===r.onThresholdMet?"merge":"ask"),maxRounds:r.maxRounds,yoloDefault:r.yoloDefault,phases:r.phases.map(e=>{let r="review_only"===e.kind,t=e.reviewer.candidates.length>0?{require:e.reviewer.require,crossLineage:e.reviewer.crossLineage,candidates:e.reviewer.candidates.flatMap(r=>{let t=(e.reviewer.candidateModels?.[r]??[]).map(e=>e.trim()).filter(e=>e.length>0),s=e.reviewer.candidatePersonas?.[r],a=I[r]??"anthropic";if(0===t.length){let e=O[r]??"claude-opus-4-7",t=s?.[""];return[{lineage:a,models:[e],...t?{persona:t}:{}}]}return t.map(e=>{let r=s?.[e];return{lineage:a,models:[e],...r?{persona:r}:{}}})})}:void 0;return r?{id:e.id,kind:e.kind,title:e.name,description:e.description,reviewer:t,inputs:{include:e.inputs.include,exclude:e.inputs.exclude},artifact:{label:e.artifact?.label??"Artifact to review",hint:e.artifact?.hint??"Paste a unified diff, a markdown draft, code, or any text blob.",maxBytes:e.artifact?.maxBytes??1048576}}:{id:e.id,kind:e.kind,title:e.name,description:e.description,doer:{lineage:I[e.doer.lineage]??"anthropic",models:e.doer.models.length>0?e.doer.models:[O[e.doer.lineage]??"claude-opus-4-7"],...e.doer.persona?{persona:e.doer.persona}:{}},reviewer:t,inputs:{include:e.inputs.include,exclude:e.inputs.exclude},iterate:{maxRounds:e.iterate.max,onDisagreement:"loopback"===e.iterate.onMax?"continue":"fail"===e.iterate.onMax?"accept-doer":"escalate",shareSessionAcrossRounds:!0,shareSessionAcrossPhases:!1}}}),...r.fallbackDoer.length>0||r.fallbackReviewer.length>0?{fallback:{...r.fallbackDoer.length>0?{doer:r.fallbackDoer.map(e=>({lineage:I[e.lineage]??"anthropic",models:[e.model],...e.persona?{persona:e.persona}:{}}))}:{},...r.fallbackReviewer.length>0?{reviewer:r.fallbackReviewer.map(e=>({lineage:I[e.lineage]??"anthropic",models:[e.model],...e.persona?{persona:e.persona}:{}}))}:{}}}:{}},{lineWidth:0})}var Z=t(6758),J=t(5483),Q=t(7847),X=t(1993),ee=t(52),er=t(2116),et=t(9410),es=t(9208),ea=t(7618),en=t(4579),eo=t(9812),ei=t(3734);let ed={review:ee.A,review_only:ee.A,plan:er.A,spec:p.A,tests:et.A,implement:es.A,verify:ea.A,pr:en.A,divergence:E.A,recon:eo.A},el=[{id:"plan",label:"Plan"},{id:"spec",label:"Spec / API"},{id:"tests",label:"Tests"},{id:"implement",label:"Implement"},{id:"verify",label:"Verify"},{id:"pr",label:"Open PR"},{id:"review",label:"Review"},{id:"review_only",label:"Review only (artifact)"},{id:"divergence",label:"Divergence"},{id:"recon",label:"Recon"}],ec=["claude","codex","gemini","opencode","kimi","openrouter"].map(e=>({id:e,label:ei.m_[e],dot:ei.r2[e].dot})),eu=ei.x0,em={anthropic:"claude",openai:"codex",google:"gemini",opencode:"opencode",moonshot:"kimi",xai:"opencode"};function ex(){let[e,r]=(0,a.useState)({byLineage:{},connectedLineages:new Set,loaded:!1});return(0,a.useEffect)(()=>{(0,Q.listVoices)({enabled:!0}).then(e=>{let t={},s=new Set;for(let r of e){if("openrouter"===r.provider){s.add("openrouter"),(t.openrouter??=[]).push(r.id);continue}let e=em[r.lineage];e&&(s.add(e),(t[e]??=[]).push(r.model_id)),r.provider.startsWith("opencode")&&"opencode"!==e&&(s.add("opencode"),(t.opencode??=[]).push(r.model_id))}for(let e of Object.keys(t))t[e]=Array.from(new Set(t[e]));r({byLineage:t,connectedLineages:s,loaded:!0})}).catch(()=>r({byLineage:{},connectedLineages:new Set,loaded:!0}))},[]),e}var ep=t(1304),eh=t(2379),ef=t(5445),eg=t(9707),eb=t(2471);function ev({children:e,onClick:r,disabled:t,title:a,className:n}){return(0,s.jsx)("button",{type:"button",disabled:t,onClick:e=>{e.stopPropagation(),r()},title:a,className:(0,T.cn)("grid h-6 w-6 place-items-center rounded text-muted-foreground transition hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-30",n),children:e})}function ej({label:e,children:r}){return(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"mb-1.5 block text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:e}),r]})}function ey({on:e,tone:r,onClick:t,children:a}){return(0,s.jsx)("button",{type:"button",onClick:t,className:(0,T.cn)("rounded-md border px-2 py-0.5 font-mono text-[10px] uppercase tracking-wider transition",{emerald:e?"border-emerald-500/40 bg-emerald-500/15 text-emerald-200":"border-border bg-card/40 text-muted-foreground hover:border-emerald-500/30",rose:e?"border-rose-500/40 bg-rose-500/15 text-rose-200":"border-border bg-card/40 text-muted-foreground hover:border-rose-500/30"}[r]),children:a})}function ew({value:e,personas:r,onChange:t,inline:a,ariaLabel:n}){let o="__none__",i=r.some(r=>r.id===e);return(0,s.jsxs)("select",{value:e??o,onChange:e=>{let r=e.target.value;t(r===o?void 0:r)},className:(0,T.cn)("h-7 rounded-md border border-border bg-background px-2 text-[11px] focus:border-primary/60 focus:outline-none",a?"w-32 shrink-0":"w-full"),"aria-label":n??"Persona",children:[(0,s.jsx)("option",{value:o,children:"(no persona)"}),r.map(e=>(0,s.jsx)("option",{value:e.id,children:e.label},e.id)),e&&!i&&(0,s.jsxs)("option",{value:e,children:[e," (missing)"]})]})}function eN({lineage:e,value:r,options:t,onChange:n,defaultModel:o}){let i="__custom__",d=!r||t.includes(r),[l,c]=(0,a.useState)(!1);if(l)return(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)("input",{type:"text",value:r,onChange:e=>n(e.target.value),placeholder:o?`default: ${o}`:`${e} model id`,className:"h-7 flex-1 rounded-md border border-border bg-background px-2 font-mono text-[11px] text-foreground placeholder:text-muted-foreground/50 focus:border-primary/60 focus:outline-none",autoFocus:!0}),(0,s.jsx)("button",{type:"button",onClick:()=>c(!1),className:"h-7 rounded-md border border-border bg-card/40 px-2 text-[10px] text-muted-foreground hover:text-foreground",children:"done"})]});if(0===t.length)return(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("input",{type:"text",value:r,onChange:e=>n(e.target.value),placeholder:o?`default: ${o}`:`${e} model id`,className:"h-7 w-full rounded-md border border-border bg-background px-2 font-mono text-[11px] text-foreground placeholder:text-muted-foreground/50 focus:border-primary/60 focus:outline-none"}),(0,s.jsxs)("p",{className:"text-[10px] text-amber-400/80",children:["No ",e," voices enabled. Configure in Connect to populate this dropdown."]})]});let u=d?t:[r,...t];return(0,s.jsxs)("select",{value:r,onChange:e=>{e.target.value===i?c(!0):n(e.target.value)},className:"h-7 w-full rounded-md border border-border bg-background px-2 font-mono text-[11px] text-foreground focus:border-primary/60 focus:outline-none",children:[!r&&(0,s.jsx)("option",{value:"",children:o?`default: ${o}`:"— pick a model —"}),u.map(e=>(0,s.jsxs)("option",{value:e,children:[e,t.includes(e)||r!==e?"":" (not enabled)"]},e)),(0,s.jsx)("option",{value:i,children:"+ custom (type a model id)…"})]})}function ek(e){let r=[];for(let t of e.candidates){let s=e.candidateModels?.[t],a=e.candidatePersonas?.[t];if(s&&0!==s.length)for(let e of s)r.push({lineage:t,model:e,...a?.[e]?{persona:a[e]}:{}});else r.push({lineage:t,model:"",...a?.[""]?{persona:a[""]}:{}})}return r}function eC({phase:e,connectedVoices:r,personas:t,onUpdate:a}){let n=ek(e.reviewer),o=ec.filter(e=>0===r.connectedLineages.size||r.connectedLineages.has(e.id));function i(r){a({reviewer:function(e,r){let t=[],s={},a={};for(let r of e)t.includes(r.lineage)||t.push(r.lineage),r.model&&(s[r.lineage]??=[]).push(r.model),r.persona&&((a[r.lineage]??={})[r.model]=r.persona);return{...r,candidates:t,candidateModels:s,...Object.keys(a).length>0?{candidatePersonas:a}:{candidatePersonas:void 0}}}(r,e.reviewer)})}function d(e,t){let s=n.map((r,s)=>s===e?{...r,...t}:r);if(t.lineage&&t.lineage!==n[e].lineage){let a=r.byLineage[t.lineage]??[];s[e].model=a[0]??eu[t.lineage]??""}i(s)}return(0,s.jsxs)("div",{className:"space-y-1.5",children:[0===n.length&&(0,s.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"No reviewers yet. Click + add reviewer below."}),n.map((e,a)=>{let l=ec.find(r=>r.id===e.lineage);return(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsxs)("select",{value:e.lineage,onChange:e=>d(a,{lineage:e.target.value}),className:"h-7 w-32 shrink-0 rounded-md border border-border bg-background px-2 text-[11px] focus:border-primary/60 focus:outline-none","aria-label":"Reviewer lineage",children:[o.map(e=>(0,s.jsx)("option",{value:e.id,children:e.label},e.id)),!o.find(r=>r.id===e.lineage)&&(0,s.jsxs)("option",{value:e.lineage,children:[l?.label??e.lineage," (not connected)"]})]}),(0,s.jsx)("div",{className:"flex-1",children:(0,s.jsx)(eN,{lineage:e.lineage,value:e.model,options:r.byLineage[e.lineage]??[],defaultModel:eu[e.lineage],onChange:e=>d(a,{model:e})})}),(0,s.jsx)(ew,{value:e.persona,personas:t,onChange:e=>d(a,{persona:e}),inline:!0,ariaLabel:"Reviewer persona"}),(0,s.jsx)("button",{type:"button",onClick:()=>{i(n.filter((e,r)=>r!==a))},"aria-label":"Remove reviewer",className:"grid h-7 w-7 shrink-0 place-items-center rounded-md border border-border bg-card/40 text-muted-foreground hover:border-destructive/40 hover:text-destructive",children:(0,s.jsx)(h.A,{className:"h-3 w-3"})})]},a)}),(0,s.jsxs)("button",{type:"button",onClick:function(){let e=o[0]?.id??"claude",t=r.byLineage[e]??[],s=new Set(n.filter(r=>r.lineage===e).map(e=>e.model)),a=t.find(e=>!s.has(e))??eu[e]??"";i([...n,{lineage:e,model:a}])},className:"flex w-full items-center justify-center gap-1.5 rounded-md border border-dashed border-border bg-card/30 px-3 py-2 text-[11px] font-medium text-muted-foreground transition hover:border-primary/40 hover:bg-card/50 hover:text-foreground",children:[(0,s.jsx)(x.A,{className:"h-3 w-3"}),"Add another reviewer"]})]})}function eA({phase:e,onUpdate:r,connectedVoices:t,personas:a}){return(0,s.jsxs)(ej,{label:"Doer \xb7 the agent that writes this phase's output",children:[(0,s.jsx)("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-5",children:ec.filter(e=>0===t.connectedLineages.size||t.connectedLineages.has(e.id)).map(a=>(0,s.jsxs)("button",{type:"button",onClick:()=>{let e=(t.byLineage[a.id]??[])[0]??eu[a.id];r({doer:{lineage:a.id,models:e?[e]:[]}})},className:(0,T.cn)("flex items-center gap-1.5 rounded-md border px-2 py-1.5 text-left transition",e.doer.lineage===a.id?"border-primary/40 bg-primary/10":"border-border bg-card/40 hover:border-foreground/30"),children:[(0,s.jsx)("span",{className:(0,T.cn)("h-1.5 w-1.5 rounded-full",a.dot)}),(0,s.jsx)("span",{className:"text-xs",children:a.label}),e.doer.lineage===a.id&&(0,s.jsx)(eg.A,{className:"ml-auto h-3 w-3 text-primary"})]},a.id))}),(0,s.jsx)("div",{className:"mt-2",children:(0,s.jsx)(eN,{lineage:e.doer.lineage,value:e.doer.models[0]??"",options:t.byLineage[e.doer.lineage]??[],defaultModel:eu[e.doer.lineage],onChange:t=>r({doer:{...e.doer,models:t?[t]:[]}})})}),(0,s.jsxs)("div",{className:"mt-2",children:[(0,s.jsx)("label",{className:"mb-1 block text-[10px] text-muted-foreground",children:"Persona (optional \xb7 prepends a worldview to the doer's prompt)"}),(0,s.jsx)(ew,{value:e.doer.persona,personas:a,onChange:t=>r({doer:t?{...e.doer,persona:t}:(()=>{let{persona:r,...t}=e.doer;return t})()}),ariaLabel:"Doer persona"})]})]})}function eM({phase:e,onUpdate:r}){let t={label:e.artifact?.label??"Artifact to review",hint:e.artifact?.hint??"Paste a unified diff, a markdown draft, code, or any text blob.",maxBytes:e.artifact?.maxBytes??1048576};return(0,s.jsx)(ej,{label:"Artifact \xb7 what the user pastes when starting a chat",children:(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"Label"}),(0,s.jsx)("input",{type:"text",value:t.label,onChange:e=>r({artifact:{...t,label:e.target.value}}),placeholder:"Artifact to review",className:"mt-1 h-7 w-full rounded-md border border-border bg-background px-2.5 text-[11px] placeholder:text-muted-foreground/60 focus:border-primary/60 focus:outline-none"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"Placeholder hint"}),(0,s.jsx)("textarea",{value:e.artifact?.hint??"",onChange:e=>r({artifact:{...t,hint:e.target.value}}),placeholder:"Paste a unified diff, a markdown draft, code, or any text blob.",rows:2,className:"mt-1 w-full resize-none rounded-md border border-border bg-background px-2.5 py-1.5 text-[11px] placeholder:text-muted-foreground/60 focus:border-primary/60 focus:outline-none"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"Max bytes (server-side cap)"}),(0,s.jsx)("input",{type:"number",min:1024,step:1024,value:t.maxBytes,onChange:e=>r({artifact:{...t,maxBytes:Math.max(1024,parseInt(e.target.value,10)||1048576)}}),className:"mt-1 h-7 w-full rounded-md border border-border bg-background px-2.5 font-mono text-[11px] focus:border-primary/60 focus:outline-none"}),(0,s.jsx)("p",{className:"mt-1 text-[10px] text-muted-foreground/80",children:"1 MiB = 1048576. Default if unset."})]})]})})}function eS({phase:e,onUpdate:r,connectedVoices:t,personas:a}){return(0,s.jsx)(ej,{label:"Reviewers \xb7 who gates this phase",children:(0,s.jsx)(eC,{phase:e,connectedVoices:t,personas:a,onUpdate:r})})}function eY({phase:e,onUpdate:r}){return(0,s.jsx)(ej,{label:"Approvals",children:(0,s.jsxs)("div",{className:"flex items-center gap-4 flex-wrap",children:[(0,s.jsxs)("label",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:["Require:",(0,s.jsx)("input",{type:"number",min:0,max:Math.max(1,ek(e.reviewer).length),value:e.reviewer.require,onChange:t=>r({reviewer:{...e.reviewer,require:Math.max(0,parseInt(t.target.value,10)||0)}}),className:"h-6 w-12 rounded border border-border bg-background px-1.5 text-center font-mono text-[11px]"}),"approval",1===e.reviewer.require?"":"s"]}),"review_only"!==e.kind&&(0,s.jsxs)("label",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[(0,s.jsx)("input",{type:"checkbox",checked:e.reviewer.crossLineage,onChange:t=>r({reviewer:{...e.reviewer,crossLineage:t.target.checked}}),className:"accent-primary"}),"Cross-lineage required"]})]})})}function eL({phase:e,onUpdate:r}){return(0,s.jsx)(ej,{label:"Reviewer execution \xb7 how multiple reviewers interact",children:(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>r({execution:"parallel"}),className:(0,T.cn)("rounded-md border px-3 py-2.5 text-left transition","parallel"===e.execution?"border-emerald-500/40 bg-emerald-500/5":"border-border bg-card/40 hover:border-foreground/30"),children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-xs font-medium",children:["Parallel independent",(0,s.jsx)("span",{className:"font-mono text-[9px] uppercase text-emerald-300/80",children:"fast"})]}),(0,s.jsx)("p",{className:"mt-0.5 text-[10px] leading-snug text-muted-foreground",children:"All reviewers see the same pack, work in isolation, vote. Catches single-reviewer mistakes via consensus. Risk: shared blind spots pass anyway."})]}),(0,s.jsxs)("button",{type:"button",onClick:()=>r({execution:"sequential"}),className:(0,T.cn)("rounded-md border px-3 py-2.5 text-left transition","sequential"===e.execution?"border-amber-500/40 bg-amber-500/5":"border-border bg-card/40 hover:border-foreground/30"),children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-xs font-medium",children:["Sequential hostile",(0,s.jsx)("span",{className:"font-mono text-[9px] uppercase text-amber-300/80",children:"thorough"})]}),(0,s.jsx)("p",{className:"mt-0.5 text-[10px] leading-snug text-muted-foreground",children:"Reviewers run in order. Each receives the already-hardened output and hunts what the prior reviewer missed. Slower; only works if the first reviewer's solution is sound."})]})]})})}function eD({phase:e,onUpdate:r,priorPhases:t}){return(0,s.jsxs)(ej,{label:"Inputs \xb7 which prior phases this doer can read",children:[(0,s.jsx)("div",{className:"space-y-1.5",children:t.map(t=>{let a=e.inputs.include.includes(t),n=e.inputs.exclude.includes(t),o=n?"exclude":a?"include":"none";return(0,s.jsxs)("div",{className:"flex items-center justify-between rounded-md border border-border bg-card/30 px-2.5 py-1.5",children:[(0,s.jsx)("code",{className:"font-mono text-[11px] text-foreground",children:t}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)(ey,{on:"include"===o,tone:"emerald",onClick:()=>r({inputs:{include:a?e.inputs.include.filter(e=>e!==t):[...e.inputs.include,t],exclude:e.inputs.exclude.filter(e=>e!==t)}}),children:"include"}),(0,s.jsx)(ey,{on:"exclude"===o,tone:"rose",onClick:()=>r({inputs:{include:e.inputs.include.filter(e=>e!==t),exclude:n?e.inputs.exclude.filter(e=>e!==t):[...e.inputs.exclude,t]}}),children:"exclude (blind)"})]})]},t)})}),(0,s.jsxs)("p",{className:"mt-2 flex items-start gap-1.5 text-[10px] text-muted-foreground",children:[(0,s.jsx)(eb.A,{className:"mt-0.5 h-2.5 w-2.5 shrink-0 text-muted-foreground/60"}),(0,s.jsxs)("span",{children:[(0,s.jsx)("span",{className:"font-mono text-rose-300",children:"exclude"}),"prevents this doer from seeing that phase's output. Used for info asymmetry — e.g. the implementer shouldn't see the tests."]})]})]})}function eR({phase:e,onUpdate:r,priorPhases:t}){return(0,s.jsx)(ej,{label:"Iterate \xb7 what happens when reviewer rejects",children:(0,s.jsxs)("div",{className:"grid grid-cols-3 gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"Max revise"}),(0,s.jsx)("input",{type:"number",min:1,max:10,value:e.iterate.max,onChange:t=>r({iterate:{...e.iterate,max:Math.max(1,parseInt(t.target.value,10)||1)}}),className:"mt-1 h-7 w-full rounded-md border border-border bg-background px-2 font-mono text-[11px]"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"On max"}),(0,s.jsxs)("select",{value:e.iterate.onMax,onChange:t=>r({iterate:{...e.iterate,onMax:t.target.value}}),className:"mt-1 h-7 w-full rounded-md border border-border bg-background px-1.5 text-[11px]",children:[(0,s.jsx)("option",{value:"ask-user",children:"ask me"}),(0,s.jsx)("option",{value:"loopback",children:"loop back"}),(0,s.jsx)("option",{value:"fail",children:"fail"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-[10px] text-muted-foreground",children:"Loop back to"}),(0,s.jsxs)("select",{disabled:"loopback"!==e.iterate.onMax,value:e.iterate.loopbackTo??"",onChange:t=>r({iterate:{...e.iterate,loopbackTo:t.target.value||void 0}}),className:"mt-1 h-7 w-full rounded-md border border-border bg-background px-1.5 text-[11px] disabled:opacity-40",children:[(0,s.jsx)("option",{value:"",children:"—"}),t.map(e=>(0,s.jsx)("option",{value:e,children:e},e))]})]})]})})}function eP({phase:e,onUpdate:r}){return(0,s.jsx)(ej,{label:"Gate \xb7 what happens when this phase finishes",children:(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>r({gate:"auto"}),className:(0,T.cn)("rounded-md border px-2.5 py-1.5 text-left transition","auto"===e.gate?"border-emerald-500/40 bg-emerald-500/10":"border-border bg-card/40 hover:border-foreground/30"),children:[(0,s.jsx)("div",{className:"text-xs font-medium",children:"Auto-proceed"}),(0,s.jsx)("div",{className:"text-[10px] text-muted-foreground",children:"Continue to next phase without asking."})]}),(0,s.jsxs)("button",{type:"button",onClick:()=>r({gate:"ask-user"}),className:(0,T.cn)("rounded-md border px-2.5 py-1.5 text-left transition","ask-user"===e.gate?"border-amber-500/40 bg-amber-500/10":"border-border bg-card/40 hover:border-foreground/30"),children:[(0,s.jsx)("div",{className:"text-xs font-medium",children:"Checkpoint (ask me)"}),(0,s.jsx)("div",{className:"text-[10px] text-muted-foreground",children:"Stop here, surface verdict, wait for click."})]})]})})}function eT({phase:e,index:r,total:t,allPhaseIds:n,connectedVoices:o,personas:d,onUpdate:l,onMoveUp:c,onMoveDown:u,onDelete:m}){let[x,p]=(0,a.useState)(0===r),h=ed[e.kind],f=n.slice(0,r);return(0,s.jsxs)("div",{className:"rounded-lg border border-border bg-card/40",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>p(e=>!e),className:"flex w-full items-center gap-3 px-3 py-2.5 text-left",children:[(0,s.jsx)("span",{className:"font-mono text-[10px] text-muted-foreground/60",children:String(r+1).padStart(2,"0")}),(0,s.jsx)("span",{className:"grid h-7 w-7 shrink-0 place-items-center rounded-md bg-primary/15 text-primary",children:(0,s.jsx)(h,{className:"h-3.5 w-3.5"})}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-foreground truncate",children:e.name||"Untitled phase"}),(0,s.jsx)("span",{className:"font-mono text-[10px] uppercase text-muted-foreground/70",children:e.kind})]}),(0,s.jsx)(e$,{phase:e})]}),(0,s.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5",children:[(0,s.jsx)(ev,{disabled:0===r,onClick:c,title:"Move up",children:(0,s.jsx)(ep.A,{className:"h-3 w-3"})}),(0,s.jsx)(ev,{disabled:r===t-1,onClick:u,title:"Move down",children:(0,s.jsx)(eh.A,{className:"h-3 w-3"})}),(0,s.jsx)(ev,{onClick:m,title:"Delete phase",className:"hover:text-rose-400",children:(0,s.jsx)(i.A,{className:"h-3 w-3"})}),(0,s.jsx)("span",{className:"ml-1 text-muted-foreground/60",children:x?(0,s.jsx)(ef.A,{className:"h-3.5 w-3.5"}):(0,s.jsx)(J.A,{className:"h-3.5 w-3.5"})})]})]}),x&&(0,s.jsxs)("div",{className:"space-y-4 border-t border-border bg-background/40 px-3 py-3",children:[(0,s.jsxs)("div",{className:"grid grid-cols-[1fr_140px] gap-2",children:[(0,s.jsx)(ej,{label:"Name",children:(0,s.jsx)("input",{type:"text",value:e.name,onChange:e=>l({name:e.target.value}),className:"h-8 w-full rounded-md border border-border bg-background px-2.5 text-xs text-foreground focus:border-primary/60 focus:outline-none"})}),(0,s.jsx)(ej,{label:"Kind",children:(0,s.jsx)("select",{value:e.kind,onChange:e=>l({kind:e.target.value}),className:"h-8 w-full rounded-md border border-border bg-background px-2 text-xs text-foreground focus:border-primary/60 focus:outline-none",children:el.map(e=>(0,s.jsx)("option",{value:e.id,children:e.label},e.id))})})]}),(0,s.jsx)(ej,{label:"Description",children:(0,s.jsx)("input",{type:"text",value:e.description,onChange:e=>l({description:e.target.value}),placeholder:"What this phase produces and why it exists.",className:"h-8 w-full rounded-md border border-border bg-background px-2.5 text-xs text-foreground placeholder:text-muted-foreground/60 focus:border-primary/60 focus:outline-none"})}),"review_only"!==e.kind&&(0,s.jsx)(eA,{phase:e,onUpdate:l,connectedVoices:o,personas:d}),"review_only"===e.kind&&(0,s.jsx)(eM,{phase:e,onUpdate:l}),(0,s.jsx)(eS,{phase:e,onUpdate:l,connectedVoices:o,personas:d}),(0,s.jsx)(eY,{phase:e,onUpdate:l}),(0,s.jsx)(eL,{phase:e,onUpdate:l}),f.length>0&&(0,s.jsx)(eD,{phase:e,onUpdate:l,priorPhases:f}),"review_only"!==e.kind&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eR,{phase:e,onUpdate:l,priorPhases:f}),(0,s.jsx)(eP,{phase:e,onUpdate:l})]})]})]})}function e$({phase:e}){return(0,s.jsxs)("div",{className:"mt-0.5 flex flex-wrap items-center gap-1.5 text-[10px] text-muted-foreground",children:["review_only"!==e.kind&&(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{className:(0,T.cn)("h-1.5 w-1.5 rounded-full",ec.find(r=>r.id===e.doer.lineage)?.dot)}),"doer: ",e.doer.lineage]}),e.reviewer.candidates.length>0&&(0,s.jsxs)(s.Fragment,{children:["review_only"!==e.kind&&(0,s.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,s.jsxs)("span",{className:"flex items-center gap-1",children:["reviewers:",e.reviewer.candidates.map(e=>(0,s.jsx)("span",{className:(0,T.cn)("h-1.5 w-1.5 rounded-full",ec.find(r=>r.id===e)?.dot),title:e},e))]})]}),e.reviewer.crossLineage&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,s.jsx)("span",{className:"text-amber-300/90 font-mono text-[9px] uppercase",children:"cross-lineage"})]}),(0,s.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,s.jsx)("span",{className:(0,T.cn)("font-mono text-[9px] uppercase","sequential"===e.execution?"text-amber-300/90":"text-emerald-300/80"),title:"sequential"===e.execution?"Sequential hostile — reviewers chain":"Parallel independent — reviewers vote",children:"sequential"===e.execution?"sequential":"parallel"}),e.inputs.exclude.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,s.jsxs)("span",{className:"text-rose-300/90 font-mono text-[9px]",children:["blind-to: ",e.inputs.exclude.join(",")]})]})]})}function e_({phases:e,onChange:r}){let t=ex(),{personas:n}=function(){let[e,r]=(0,a.useState)({personas:[],loaded:!1});return(0,a.useEffect)(()=>{(0,X.UT)().then(e=>r({personas:e,loaded:!0})).catch(()=>r({personas:[],loaded:!0}))},[]),e}();function o(t,s){let a=t+s;if(a<0||a>=e.length)return;let n=[...e];[n[t],n[a]]=[n[a],n[t]],r(n)}let i=e.map(e=>e.id);return(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,s.jsxs)("span",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:["Phases (",e.length,")"]}),(0,s.jsx)("span",{className:"text-[11px] text-muted-foreground/70",children:"Each phase has a doer + reviewer. Adversarial by default."})]}),(0,s.jsx)("div",{className:"space-y-2",children:e.map((a,d)=>(0,s.jsx)(eT,{phase:a,index:d,total:e.length,allPhaseIds:i,connectedVoices:t,personas:n,onUpdate:t=>{r(e.map((e,r)=>r===d?{...e,...t}:e))},onMoveUp:()=>o(d,-1),onMoveDown:()=>o(d,1),onDelete:()=>{r(e.filter((e,r)=>r!==d))}},a.id))}),(0,s.jsxs)("button",{type:"button",onClick:function(){var t;r([...e,(t=e.length,{id:`phase-${t+1}`,name:`Phase ${t+1}`,description:"",kind:"review",gate:"auto",doer:{lineage:"claude",models:["claude-opus-4-7"]},reviewer:{require:1,crossLineage:!0,candidates:["codex"]},inputs:{include:[],exclude:[]},iterate:{max:3,onMax:"ask-user"},blindSpots:[],execution:"sequential",builtin:!1})])},className:"mt-3 flex w-full items-center justify-center gap-1.5 rounded-md border border-dashed border-border bg-card/30 px-3 py-2.5 text-xs font-medium text-muted-foreground transition hover:border-primary/40 hover:bg-card/50 hover:text-foreground",children:[(0,s.jsx)(x.A,{className:"h-3.5 w-3.5"}),"Add phase"]})]})}function eE({active:e,onClick:r,disabled:t,children:a}){return(0,s.jsxs)("button",{type:"button",onClick:r,disabled:t,className:(0,T.cn)("relative flex items-center gap-1.5 rounded-t-md px-3 py-2.5 text-sm font-medium transition-colors",t?"cursor-not-allowed text-muted-foreground/50":e?"text-foreground":"text-muted-foreground hover:text-foreground"),children:[a,e&&!t&&(0,s.jsx)("span",{className:"absolute inset-x-0 -bottom-px h-0.5 bg-primary"})]})}function eq({label:e,htmlFor:r,hint:t,children:a}){return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("label",{htmlFor:r,className:"block text-[13px] font-medium text-foreground",children:e}),a,t&&(0,s.jsx)("p",{className:"text-[11px] leading-snug text-muted-foreground/80",children:t})]})}function eI({active:e,onClick:r,children:t}){return(0,s.jsx)("button",{type:"button",onClick:r,className:(0,T.cn)("h-8 rounded-md border px-3 text-xs font-medium transition",e?"border-primary/60 bg-primary/15 text-primary":"border-border bg-card text-muted-foreground hover:border-muted-foreground/30 hover:bg-accent/40 hover:text-foreground"),children:t})}function eF({form:e,setField:r,showErrors:t}){let a=t&&0===e.name.trim().length,n=t&&0===e.description.trim().length;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(eq,{label:"Name *",htmlFor:"tpl-name",children:[(0,s.jsx)("input",{id:"tpl-name",value:e.name,onChange:e=>r("name",e.target.value),placeholder:"security-audit","aria-invalid":a,className:(0,T.cn)("h-10 w-full rounded-md border bg-background px-3 text-sm placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2",a?"border-destructive/60 focus:border-destructive focus:ring-destructive/30":"border-border focus:border-primary/60 focus:ring-primary/20")}),a&&(0,s.jsx)("p",{className:"text-[11px] text-destructive",children:"Name is required."})]}),(0,s.jsxs)(eq,{label:"Description *",htmlFor:"tpl-desc",hint:"One sentence on when someone should reach for this template.",children:[(0,s.jsx)("textarea",{id:"tpl-desc",value:e.description,onChange:e=>r("description",e.target.value),placeholder:"Independent security audit from 3 model families…",rows:2,"aria-invalid":n,className:(0,T.cn)("w-full resize-none rounded-md border bg-background px-3 py-2 text-sm leading-relaxed placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2",n?"border-destructive/60 focus:border-destructive focus:ring-destructive/30":"border-border focus:border-primary/60 focus:ring-primary/20")}),n&&(0,s.jsx)("p",{className:"text-[11px] text-destructive",children:"Description is required."})]}),(0,s.jsx)(eq,{label:"Category",children:(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:B.map(t=>(0,s.jsx)(eI,{active:t.id===e.category,onClick:()=>r("category",t.id),children:t.label},t.id))})})]})}function eO({form:e,setField:r}){let t=ex();return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"rounded-md border border-border bg-card/40 px-3 py-2 text-[11px] leading-relaxed text-muted-foreground",children:[(0,s.jsxs)("div",{className:"mb-1 flex items-center gap-1.5 text-foreground",children:[(0,s.jsx)(E.A,{className:"h-3 w-3"}),(0,s.jsx)("span",{className:"text-[12px] font-medium",children:"Template-level fallback chains"})]}),"Tried in order whenever a slot exhausts its own per-slot model chain. Cross-lineage swap supported — a codex slot can fall through to a claude or kimi entry. Strict",(0,s.jsx)("span",{className:"font-mono",children:" (lineage, model)"})," dedup keeps diversity: a fallback whose model already runs as another reviewer in this phase is skipped, so you never review the same code twice with the same voice. Order matters — list your most-preferred fallback first."]}),(0,s.jsx)(ez,{title:"Doer fallback",hint:"Engaged when the doer's primary + per-slot models all fail.",rows:e.fallbackDoer,onChange:e=>r("fallbackDoer",e),connectedVoices:t}),(0,s.jsx)(ez,{title:"Reviewer fallback",hint:"Engaged when any reviewer's primary + per-slot models all fail.",rows:e.fallbackReviewer,onChange:e=>r("fallbackReviewer",e),connectedVoices:t})]})}function ez({title:e,hint:r,rows:t,onChange:a,connectedVoices:n}){let o=(e,r)=>{a(t.map((t,s)=>s===e?{...t,...r}:t))};return(0,s.jsxs)("div",{className:"rounded-lg border border-border bg-card/40 p-4",children:[(0,s.jsxs)("div",{className:"mb-1 flex items-center justify-between",children:[(0,s.jsx)("h4",{className:"text-[13px] font-semibold tracking-tight",children:e}),(0,s.jsxs)("button",{type:"button",onClick:()=>{let e=W.find(e=>(n.byLineage[e]??[]).length>0)??"claude",r=n.byLineage[e]?.[0]??"";a([...t,{lineage:e,model:r}])},className:"inline-flex h-7 items-center gap-1 rounded-md border border-border bg-card px-2.5 text-[11px] font-medium text-muted-foreground transition hover:border-primary/40 hover:text-primary",children:[(0,s.jsx)(x.A,{className:"h-3 w-3"}),"Add fallback"]})]}),(0,s.jsx)("p",{className:"mb-3 text-[11px] leading-snug text-muted-foreground/80",children:r}),0===t.length?(0,s.jsx)("p",{className:"rounded-md border border-dashed border-border/60 bg-background/30 px-3 py-4 text-center text-[11px] text-muted-foreground",children:"None set — slot will fail its phase if the per-slot chain exhausts."}):(0,s.jsx)("ul",{className:"space-y-2",children:t.map((e,r)=>{let i=n.byLineage[e.lineage]??[],d=0===e.model.length||i.includes(e.model);return(0,s.jsxs)("li",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-border bg-card font-mono text-[10px] text-muted-foreground",children:r+1}),(0,s.jsx)("select",{value:e.lineage,onChange:e=>{var s;let a,i;return s=e.target.value,a=n.byLineage[s]??[],i=t[r].model,void o(r,{lineage:s,model:a.includes(i)?i:a[0]??""})},className:"h-8 rounded-md border border-border bg-background px-2 text-xs text-foreground focus:border-primary/60 focus:outline-none focus:ring-1 focus:ring-primary/20",children:W.map(e=>(0,s.jsx)("option",{value:e,children:e},e))}),(0,s.jsxs)("select",{value:e.model,onChange:e=>o(r,{model:e.target.value}),className:"h-8 flex-1 rounded-md border border-border bg-background px-2 font-mono text-[11px] text-foreground focus:border-primary/60 focus:outline-none focus:ring-1 focus:ring-primary/20",children:[0===i.length&&(0,s.jsx)("option",{value:"",disabled:!0,children:n.loaded?`No ${e.lineage} models enabled — open Connect → ${e.lineage}`:"loading…"}),i.map(e=>(0,s.jsx)("option",{value:e,children:e},e)),!d&&e.model.length>0&&(0,s.jsxs)("option",{value:e.model,children:[e.model," (stored)"]})]}),(0,s.jsx)("button",{type:"button",onClick:()=>{a(t.filter((e,t)=>t!==r))},"aria-label":`Remove fallback ${r+1}`,className:"grid h-7 w-7 place-items-center rounded-md border border-border bg-card text-muted-foreground transition hover:border-destructive/40 hover:text-destructive",children:(0,s.jsx)(h.A,{className:"h-3 w-3"})})]},r)})})]})}function eB({form:e,setField:r}){return(0,s.jsxs)("div",{className:"rounded-lg border border-border bg-card/40 p-4",children:[(0,s.jsx)("h3",{className:"mb-3 text-[13px] font-semibold tracking-tight",children:"Across all phases"}),(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsx)("div",{className:"mb-1.5 text-[11px] font-medium text-muted-foreground",children:"Agreement threshold (per review-style phase)"}),(0,s.jsx)("div",{className:"grid grid-cols-3 gap-2",children:U.map(t=>(0,s.jsx)("button",{type:"button",onClick:()=>r("threshold",t.id),className:(0,T.cn)("rounded-md border px-3 py-2 text-left transition",e.threshold===t.id?"border-primary/60 bg-primary/10 ring-1 ring-primary/40":"border-border bg-card hover:border-muted-foreground/30 hover:bg-accent/40"),children:(0,s.jsx)("div",{className:"text-xs font-medium",children:t.label})},t.id))}),(0,s.jsx)("p",{className:"mt-1.5 text-[11px] leading-snug text-muted-foreground/80",children:U.find(r=>r.id===e.threshold)?.hint})]}),(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsx)("div",{className:"mb-1.5 text-[11px] font-medium text-muted-foreground",children:"When threshold is met"}),(0,s.jsx)("div",{className:"grid grid-cols-2 gap-2",children:V.map(t=>(0,s.jsx)("button",{type:"button",onClick:()=>r("onThresholdMet",t.id),className:(0,T.cn)("rounded-md border px-3 py-2 text-left transition",e.onThresholdMet===t.id?"border-primary/60 bg-primary/10 ring-1 ring-primary/40":"border-border bg-card hover:border-muted-foreground/30 hover:bg-accent/40"),children:(0,s.jsx)("div",{className:"text-xs font-medium",children:t.label})},t.id))})]}),(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsxs)("div",{className:"mb-1.5 flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Max revise rounds (per phase)"}),(0,s.jsx)("span",{className:"font-mono text-xs text-foreground",children:e.maxRounds})]}),(0,s.jsx)("input",{type:"range",min:1,max:5,step:1,value:e.maxRounds,onChange:e=>r("maxRounds",parseInt(e.target.value,10)),className:"h-1 w-full cursor-pointer appearance-none rounded-full bg-muted accent-primary"})]}),(0,s.jsxs)("button",{type:"button",onClick:()=>r("yoloDefault",!e.yoloDefault),className:(0,T.cn)("flex w-full items-center justify-between rounded-md border px-3 py-2 text-left transition",e.yoloDefault?"border-rose-500/40 bg-rose-500/5":"border-border bg-card hover:border-foreground/30"),children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"text-xs font-medium text-foreground",children:"\uD83D\uDE80 Yolo by default"}),(0,s.jsx)("div",{className:"text-[10px] text-muted-foreground",children:"Auto-approve every gate. Only flip on for trusted templates or trivial fixes. Cost cap still enforced."})]}),(0,s.jsx)("span",{className:(0,T.cn)("flex h-5 w-9 shrink-0 items-center rounded-full border p-0.5 transition",e.yoloDefault?"border-rose-500/40 bg-rose-500/20":"border-border bg-card"),children:(0,s.jsx)("span",{className:(0,T.cn)("h-3.5 w-3.5 rounded-full transition-transform",e.yoloDefault?"translate-x-4 bg-rose-400":"bg-muted-foreground/50")})})]})]})}function eU(e,r){let t=[];if(1===e)r.name&&0!==r.name.trim().length?r.name.length>80&&t.push("Name is too long (max 80 chars)."):t.push("Name is required."),r.description&&0!==r.description.trim().length||t.push("Description is required — one line on when to use this template.");else if(2===e)for(let e of(0===r.phases.length&&t.push("At least one phase is required."),r.phases))e.id&&0!==e.id.trim().length||t.push(`Phase "${e.name||"(unnamed)"}" needs an id.`),"review_only"===e.kind||e.doer.lineage&&0!==e.doer.models.length||t.push(`Phase "${e.name||e.id}" needs a doer lineage + model.`),0===e.reviewer.candidates.length&&t.push(`Phase "${e.name||e.id}" needs at least one reviewer.`);return t}function eV({form:e,setField:r}){let[t,n]=(0,a.useState)(1),[o,i]=(0,a.useState)(!1),d=eU(t,e),l=0===d.length;return(0,s.jsxs)("div",{className:"flex h-full flex-col px-6 py-6",children:[(0,s.jsx)(eG,{currentStep:t,onJump:r=>{if(r<=t){i(!1),n(r);return}for(let s=t;s<r;s++)if(eU(s,e).length>0)return void i(!0);i(!1),n(r)},form:e}),(0,s.jsxs)("div",{className:"mt-6 flex-1 space-y-6",children:[1===t&&(0,s.jsx)(eF,{form:e,setField:r,showErrors:o}),2===t&&(0,s.jsx)(eW,{form:e,setField:r,showErrors:o}),3===t&&(0,s.jsx)(eO,{form:e,setField:r}),4===t&&(0,s.jsx)(eB,{form:e,setField:r})]}),o&&d.length>0&&(0,s.jsxs)("div",{className:"mt-6 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:[(0,s.jsx)("div",{className:"mb-1 font-medium",children:"Resolve these to continue:"}),(0,s.jsx)("ul",{className:"space-y-0.5 pl-4",children:d.map(e=>(0,s.jsx)("li",{className:"list-disc",children:e},e))})]}),(0,s.jsxs)("div",{className:"mt-6 flex items-center justify-between border-t border-border pt-4",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>{i(!1),t>1&&n(t-1)},disabled:1===t,className:"inline-flex h-9 items-center gap-1.5 rounded-md border border-border bg-card px-3 text-sm font-medium text-muted-foreground transition hover:border-muted-foreground/30 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40",children:[(0,s.jsx)(Z.A,{className:"h-3.5 w-3.5"}),"Back"]}),(0,s.jsxs)("span",{className:"text-[11px] text-muted-foreground",children:["Step ",t," of 4 \xb7 ",G[t-1].label]}),t<4?(0,s.jsxs)("button",{type:"button",onClick:()=>{l?(i(!1),t<4&&n(t+1)):i(!0)},className:(0,T.cn)("inline-flex h-9 items-center gap-1.5 rounded-md px-3 text-sm font-medium shadow-sm transition",l?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-muted text-muted-foreground/60"),children:["Next",(0,s.jsx)(J.A,{className:"h-3.5 w-3.5"})]}):(0,s.jsxs)("span",{className:"text-[11px] text-emerald-300",children:[(0,s.jsx)(b.A,{className:"mr-1 inline-block h-3 w-3"}),"Save in the footer below"]})]})]})}function eG({currentStep:e,onJump:r,form:t}){return(0,s.jsx)("div",{className:"flex items-stretch gap-2",children:G.map(a=>{let n=a.icon,o=a.id===e,i=0===eU(a.id,t).length,d=a.id<e;return(0,s.jsxs)("button",{type:"button",onClick:()=>r(a.id),className:(0,T.cn)("flex flex-1 items-center gap-2 rounded-md border px-3 py-2 text-left transition",o?"border-primary/60 bg-primary/10":d&&!i?"border-destructive/40 bg-destructive/5":"border-border bg-card hover:border-muted-foreground/30"),children:[(0,s.jsx)("span",{className:(0,T.cn)("flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-[10px] font-mono",o?"bg-primary text-primary-foreground":d&&i?"bg-emerald-500/20 text-emerald-300":d&&!i?"bg-destructive/20 text-destructive":"bg-muted text-muted-foreground"),children:d&&i?"✓":a.id}),(0,s.jsx)(n,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,s.jsx)("span",{className:"hidden text-xs font-medium sm:inline",children:a.label})]},a.id)})})}function eW({form:e,setField:r,showErrors:t}){let a=eU(2,e);return(0,s.jsxs)(s.Fragment,{children:[t&&a.length>0&&(0,s.jsx)("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:a[0]}),(0,s.jsx)(e_,{phases:e.phases,onChange:e=>r("phases",e)})]})}function eK(e){return Array.isArray(e)?e.flatMap(e=>{let r=F[e.lineage??""]??"claude",t=(e.models??[]).filter(e=>"string"==typeof e&&e.trim().length>0);return 0===t.length?[]:t.map(t=>({lineage:r,model:t,...e.persona?{persona:e.persona}:{}}))}):[]}let eH=["plan","spec","tests","implement","review","verify","divergence","review_only"];function eZ(e,r){let t,s,a,n,o=[];try{t=y.Ay.parse(e)??{}}catch{return{form:{...z,id:r},formLossy:!0,lossyReasons:["YAML failed to parse — only YAML mode is available."]}}t.ship?.enabled&&o.push("Template has `ship.enabled: true` — form mode can't edit ship config.");let i=[];for(let e of t.phases??[]){let{phase:r,reasons:t}=function(e){let r=[];void 0!==e.timeoutMs&&r.push(`Phase ${e.id??"?"} has \`timeoutMs\` — not exposed in form mode.`);let t="review_only"===e.kind,s=t?"claude":F[e.doer?.lineage??""]??"claude",a={},n={},o=new Set,i=[],d=[];for(let r of e.reviewer?.candidates??[]){let e=F[r.lineage??""];if(!e)continue;o.has(e)||(o.add(e),i.push(e));let t=(r.models??[]).map(e=>(e??"").trim()).filter(e=>e.length>0),s=r.persona&&r.persona.trim().length>0?r.persona:void 0,l=r=>{if(!s)return;let t=n[e]??={},a=t[r];void 0!==a&&a!==s&&d.push(`${e}/${r||"(no model)"}: "${a}" vs "${s}"`),t[r]=s};if(0===t.length)l("");else for(let r of t)(a[e]??=[]).push(r),l(r)}d.length>0&&r.push(`Phase ${e.id??"?"} has overlapping reviewer candidates with conflicting personas (${d.join("; ")}) — form mode would silently last-write-wins; edit in YAML to disambiguate.`);let l=eH.includes(e.kind)?e.kind:"review";return e.kind&&!eH.includes(e.kind)&&r.push(`Phase ${e.id??"?"} has unknown kind \`${e.kind}\` — form mode would coerce it to \`review\`.`),{phase:{id:e.id??"phase",name:e.title??e.name??e.id??"Phase",description:e.description??"",kind:l,gate:"auto",doer:{lineage:s,models:e.doer?.models&&e.doer.models.length>0?e.doer.models:[O[s]??"claude-opus-4-7"],...e.doer?.persona&&e.doer.persona.trim().length>0?{persona:e.doer.persona.trim()}:{}},reviewer:{require:e.reviewer?.require??1,crossLineage:e.reviewer?.crossLineage??!0,candidates:i,candidateModels:a,...Object.keys(n).length>0?{candidatePersonas:n}:{}},inputs:{include:e.inputs?.include??[],exclude:e.inputs?.exclude??[]},iterate:{max:e.iterate?.maxRounds??2,onMax:(e.iterate?.onDisagreement??"continue")==="continue"?"loopback":e.iterate?.onDisagreement==="accept-doer"?"fail":"ask-user"},blindSpots:[],execution:"parallel",builtin:!1,...t&&e.artifact?{artifact:{label:e.artifact.label??"Artifact to review",hint:e.artifact.hint??"Paste a unified diff, a markdown draft, code, or any text blob.",maxBytes:e.artifact.maxBytes??1048576}}:t?{artifact:{label:"Artifact to review",hint:"Paste a unified diff, a markdown draft, code, or any text blob.",maxBytes:1048576}}:{}},reasons:r}}(e);i.push(r),o.push(...t)}if("number"==typeof t.agreementThreshold){var d;s=(d=t.agreementThreshold)>=.99?"unanimous":d>=.5?"majority":"any",new Set([1,.66,.34]).has(t.agreementThreshold)||(a=t.agreementThreshold,o.push(`Custom \`agreementThreshold: ${t.agreementThreshold}\` — form mode only offers 1.0 / 0.66 / 0.34 presets.`))}else s=t.agreementThreshold??"majority";let l="review"===t.onThresholdMet?"review":void 0;return"review"===l&&o.push("`onThresholdMet: review` — form mode only offers auto-finalize / ask-user."),{form:{id:t.id??r,name:t.name??"",description:t.description??"",author:t.author??"chorus",category:(n=(t.id??r).toLowerCase()).includes("bug")||n.includes("debug")||n.includes("diagnose")?"debug":n.includes("plan")||n.includes("architect")?"plan":n.includes("decide")||n.includes("decision")?"decide":"review",phases:i.length>0?i:z.phases,threshold:s,...void 0!==a?{customThreshold:a}:{},onThresholdMet:"merge"===t.onThresholdMet?"auto-finalize":"ask-user",...l?{onThresholdMetRaw:l}:{},maxRounds:t.maxRounds??3,yoloDefault:t.yoloDefault??!1,fallbackDoer:eK(t.fallback?.doer),fallbackReviewer:eK(t.fallback?.reviewer)},formLossy:o.length>0,lossyReasons:o}}function eJ({yaml:e,filename:r,issues:t,onChange:a}){return(0,s.jsxs)("div",{className:"flex h-full min-h-[400px] flex-col",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between border-b border-border bg-card/40 px-6 py-2.5",children:[(0,s.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:r}),(0,s.jsx)(eQ,{issues:t})]}),(0,s.jsx)("textarea",{value:e,onChange:e=>a(e.target.value),spellCheck:!1,className:"flex-1 resize-none border-0 bg-background px-6 py-4 font-mono text-[12px] leading-relaxed text-foreground focus:outline-none"}),t.length>0&&(0,s.jsx)("ul",{className:"border-t border-border bg-destructive/5 px-6 py-2.5 text-[11px] text-destructive",children:t.map((e,r)=>(0,s.jsxs)("li",{className:"flex items-start gap-1.5 leading-snug",children:[(0,s.jsx)(g.A,{className:"mt-[1px] h-3 w-3 shrink-0"}),(0,s.jsxs)("span",{children:[(0,s.jsx)("span",{className:"font-mono",children:e.path}),"number"==typeof e.line&&` (line ${e.line})`,": ",e.message]})]},r))})]})}function eQ({issues:e}){return 0===e.length?(0,s.jsxs)("span",{className:"flex items-center gap-1 rounded-md bg-emerald-500/10 px-1.5 py-0.5 text-[10px] font-medium text-emerald-400",children:[(0,s.jsx)(b.A,{className:"h-3 w-3"}),"Valid"]}):(0,s.jsxs)("span",{className:"flex items-center gap-1 rounded-md bg-destructive/10 px-1.5 py-0.5 text-[10px] font-medium text-destructive",children:[(0,s.jsx)(g.A,{className:"h-3 w-3"}),e.length," ",1===e.length?"issue":"issues"]})}function eX({editing:e,trigger:r,onSaved:t}){var i;let[d,l]=(0,a.useState)(!1),c=!!e,u=(0,a.useMemo)(()=>{if(!e)return{form:z,yaml:H(z),lossy:!1,reasons:[]};let r=eZ(e.yaml,e.id);return{form:r.form,yaml:e.yaml,lossy:r.formLossy,reasons:r.lossyReasons}},[e?.id,e?.yaml]),[m,w]=(0,a.useState)(u.form),[N,k]=(0,a.useState)(u.yaml),[C,A]=(0,a.useState)(!1),[M,S]=(0,a.useState)(!1),[Y,L]=(0,a.useState)(u.lossy?"yaml":"form"),[D,$]=(0,a.useState)(!1),[_,E]=(0,a.useState)(null),[q,I]=(0,a.useState)([]);(0,a.useEffect)(()=>{w(u.form),k(u.yaml),A(!1),S(!1),L(u.lossy?"yaml":"form"),E(null),I([])},[u]);let F=(0,a.useRef)(u);(0,a.useEffect)(()=>{F.current=u});let O=(i={yamlDirty:C,tab:Y,formDirty:M,yamlText:N,formYaml:H(m),initialYaml:u.yaml}).yamlDirty||"yaml"===i.tab?i.yamlText:i.formDirty?i.formYaml:i.initialYaml,B=(0,a.useMemo)(()=>(function(e){let r;if(0===e.trim().length)return{valid:!1,issues:[{path:"<yaml>",message:"Template YAML is empty."}]};try{r=y.Ay.parse(e)}catch(t){let e=t instanceof Error?t.message:String(t),r=t.linePos?.[0];return{valid:!1,issues:[{path:"<yaml>",message:e,...r?{line:r.line,col:r.col}:{}}]}}if(null==r)return{valid:!1,issues:[{path:"<yaml>",message:"Template YAML parsed to null — at minimum it must define id, name, and phases."}]};let t=R.safeParse(r);return t.success?P:{valid:!1,issues:t.error.issues.map(e=>({path:e.path.length>0?e.path.join("."):"<root>",message:e.message}))}})(O),[O]);function U(e){if("form"===e&&C){let e=eZ(N,m.id);if(e.formLossy)return;w(e.form),A(!1),S(!0)}L(e)}function V(){let e=F.current;w(e.form),k(e.yaml),A(!1),S(!1),L(e.lossy?"yaml":"form"),$(!1),E(null),I([])}function G(e){l(e),e||setTimeout(V,200)}async function W(){if(!B.valid||D)return;let r=c?e.id:m.id||K(m.name)||"untitled";$(!0),E(null),I([]);try{let e=await (0,j.AI)({id:r,yaml:O});t?.(e.id),G(!1)}catch(e){e instanceof j.$v?(E(e.message),I(e.details?.issues??[])):E(e instanceof Error?e.message:"Save failed (unknown error)")}finally{$(!1)}}let Z=B.valid&&!D,J=r??(0,s.jsxs)("button",{type:"button","aria-label":c?"Edit template":"New template",className:"inline-flex shrink-0 items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground shadow-sm transition hover:bg-primary/90",children:[c?(0,s.jsx)(n.A,{className:"h-4 w-4"}):(0,s.jsx)(x.A,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"hidden sm:inline",children:c?"Edit":"New template"})]});return(0,s.jsxs)(v.lG,{open:d,onOpenChange:G,children:[(0,s.jsx)(v.zM,{asChild:!0,children:J}),(0,s.jsxs)(v.Cf,{showCloseButton:!1,className:"flex max-h-[85vh] w-[min(96vw,720px)] flex-col gap-0 overflow-hidden border-border bg-card p-0 shadow-2xl sm:max-w-none",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 border-b border-border px-6 py-4",children:[(0,s.jsx)("div",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-md bg-primary/15 text-primary ring-1 ring-primary/20",children:(0,s.jsx)(p.A,{className:"h-4 w-4"})}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)(v.L3,{className:"text-[15px] font-semibold leading-tight tracking-tight",children:c?`Edit template — ${e.name}`:"New template"}),(0,s.jsx)(v.rr,{className:"mt-0.5 text-xs text-muted-foreground",children:c?"Edit the YAML directly or use the form. Validation runs live.":"A reusable review workflow. Edit visually below or paste raw YAML."})]}),(0,s.jsx)("button",{type:"button",onClick:()=>G(!1),className:"grid h-7 w-7 place-items-center rounded-md text-muted-foreground transition hover:bg-accent hover:text-foreground","aria-label":"Close",children:(0,s.jsx)(h.A,{className:"h-4 w-4"})})]}),(0,s.jsx)("div",{className:"border-b border-border bg-card/40 px-6",children:(0,s.jsxs)("div",{className:"-mb-px flex items-center gap-1",children:[(0,s.jsxs)(eE,{active:"form"===Y,onClick:()=>!u.lossy&&U("form"),disabled:u.lossy,children:[(0,s.jsx)(f.A,{className:"h-3.5 w-3.5"}),"Form",u.lossy&&(0,s.jsx)("span",{className:"ml-1 rounded bg-muted px-1 text-[9px] font-medium text-muted-foreground",children:"YAML only"})]}),(0,s.jsxs)(eE,{active:"yaml"===Y,onClick:()=>U("yaml"),children:[(0,s.jsx)(p.A,{className:"h-3.5 w-3.5"}),"YAML",!B.valid&&"form"===Y&&(0,s.jsx)("span",{className:"ml-1 h-1.5 w-1.5 rounded-full bg-destructive"})]})]})}),(0,s.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[u.lossy&&"yaml"===Y&&(0,s.jsx)("div",{className:"border-b border-amber-500/30 bg-amber-500/5 px-6 py-2.5 text-[11px] text-amber-200",children:(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)(g.A,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("div",{className:"font-medium",children:"Form editing disabled for this template"}),(0,s.jsx)("ul",{className:"mt-1 space-y-0.5 leading-snug",children:u.reasons.map((e,r)=>(0,s.jsxs)("li",{children:["\xb7 ",e]},r))})]})]})}),"form"===Y?(0,s.jsx)(eV,{form:m,setField:function(e,r){let t={...m,[e]:r};w(t),S(!0),C||k(H(t))}}):(0,s.jsx)(eJ,{yaml:N,filename:`${m.id||K(m.name)||"untitled"}.yaml`,issues:B.issues,onChange:e=>{k(e),A(!0)}})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-2 border-t border-border bg-card/40 px-6 py-3",children:[_&&(0,s.jsx)("div",{className:"rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[11px] text-destructive",children:(0,s.jsxs)("div",{className:"flex items-start gap-1.5",children:[(0,s.jsx)(g.A,{className:"mt-0.5 h-3 w-3 shrink-0"}),(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("div",{className:"font-medium",children:"Save failed"}),(0,s.jsx)("div",{className:"mt-0.5 leading-snug",children:_}),q.length>0&&(0,s.jsx)("ul",{className:"mt-1 space-y-0.5",children:q.slice(0,5).map((e,r)=>(0,s.jsxs)("li",{children:[(0,s.jsx)("span",{className:"font-mono",children:e.path}),":"," ",e.message]},r))})]})]})}),(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsx)("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:B.valid?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(b.A,{className:"h-3 w-3 text-emerald-400"}),(0,s.jsx)("span",{children:"Ready to save"})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(g.A,{className:"h-3 w-3 text-destructive/80"}),(0,s.jsxs)("span",{children:[B.issues.length," ",1===B.issues.length?"issue":"issues"," to resolve"]})]})}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("button",{type:"button",onClick:()=>G(!1),className:"h-9 rounded-md border border-border bg-card px-4 text-sm font-medium text-muted-foreground transition hover:border-muted-foreground/30 hover:text-foreground",children:"Cancel"}),(0,s.jsxs)("button",{type:"button",disabled:!Z,onClick:W,className:(0,T.cn)("inline-flex h-9 items-center gap-1.5 rounded-md px-4 text-sm font-medium shadow-sm transition",Z?"bg-primary text-primary-foreground hover:bg-primary/90":"cursor-not-allowed bg-muted text-muted-foreground/60 shadow-none"),children:[D&&(0,s.jsx)(o.A,{className:"h-3.5 w-3.5 animate-spin"}),D?"Saving…":c?"Save changes":"Save template"]})]})]})]})]})]})}let e0=Object.fromEntries(Object.entries(ei.r2).map(([e,r])=>[e,r.dot])),e1=[{id:"all",label:"All"},{id:"review",label:"Review"},{id:"plan",label:"Plan"},{id:"debug",label:"Debug"},{id:"decide",label:"Decide"}];function e5(){let[e,r]=(0,a.useState)([]),[t,x]=(0,a.useState)(null),[p,h]=(0,a.useState)("all"),[f,g]=(0,a.useState)(""),[b,v]=(0,a.useState)(null),[y,w]=(0,a.useState)(null),[N,k]=(0,a.useState)(null),C=(0,a.useCallback)(async e=>{try{let t=await (0,j.eG)();r(t),e&&t.find(r=>r.id===e)?g(e):t.length>0&&!f&&g(t[0].id)}catch(e){x(e instanceof j.$v?e.message:"Failed to load templates")}},[f]);async function A(e){if(!y&&"builtin"!==e.source){if(b!==e.id){v(e.id),k(null),setTimeout(()=>{v(r=>r===e.id?null:r)},8e3);return}w(e.id),k(null);try{await (0,j.I7)(e.id),v(null),f===e.id&&g(""),await C()}catch(e){k(e instanceof j.$v||e instanceof Error?e.message:"Delete failed (unknown error)"),v(null)}finally{w(null)}}}(0,a.useEffect)(()=>{C()},[]);let M="all"===p?e:e.filter(e=>e.category===p),S=e.find(e=>e.id===f)??e[0]??null;return t?(0,s.jsx)(d.G,{children:(0,s.jsx)("div",{className:"mx-auto w-full max-w-6xl px-4 py-6 sm:px-6 sm:py-8 md:px-8 md:py-10",children:(0,s.jsxs)("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 p-4",children:[(0,s.jsx)("p",{className:"text-sm text-destructive",children:"Error loading templates"}),(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:t})]})})}):(0,s.jsx)(d.G,{children:(0,s.jsxs)("div",{className:"mx-auto w-full max-w-6xl px-4 py-6 sm:px-6 sm:py-8 md:px-8 md:py-10",children:[(0,s.jsx)(u.z,{eyebrow:"Templates",title:"Reusable review workflows",subtitle:"Each template defines the driver, reviewers, prompts, and quorum rule for a kind of task. Fork, edit, share.",action:(0,s.jsx)(eX,{onSaved:e=>C(e)})}),N&&(0,s.jsx)("div",{className:"mb-4 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:N}),(0,s.jsx)("div",{className:"mb-4 flex items-center gap-1 border-b border-border",children:e1.map(e=>(0,s.jsxs)("button",{type:"button",onClick:()=>h(e.id),className:`relative px-3 py-2 text-sm transition ${e.id===p?"text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[e.label,e.id===p&&(0,s.jsx)("span",{className:"absolute inset-x-3 bottom-0 h-0.5 bg-primary"})]},e.id))}),(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-[1fr_1fr]",children:[(0,s.jsx)("div",{className:"flex min-w-0 flex-col gap-2",children:M.map(e=>(0,s.jsxs)("div",{role:"button",tabIndex:0,onClick:()=>g(e.id),onKeyDown:r=>{("Enter"===r.key||" "===r.key)&&(r.preventDefault(),g(e.id))},className:`group relative cursor-pointer rounded-xl text-left transition focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60 ${e.id===f?"ring-2 ring-primary/60 ring-offset-2 ring-offset-background":""}`,children:[(0,s.jsxs)(l.Zp,{className:"bg-card p-4 transition group-hover:border-muted-foreground/30",children:[(0,s.jsx)("div",{className:"flex items-start justify-between gap-3",children:(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm font-semibold",children:e.name}),(0,s.jsx)(c.E,{variant:"outline",className:"border-border text-[10px] capitalize",children:e.category}),!1===e.isComplete&&(0,s.jsx)(c.E,{variant:"outline",className:"border-amber-500/40 bg-amber-500/10 font-mono text-[9px] uppercase text-amber-300",children:"needs setup"})]}),(0,s.jsx)("p",{className:"mt-1 text-xs text-muted-foreground line-clamp-2",children:!1===e.isComplete?"Some slots couldn't be filled from your installed CLIs. Edit the YAML to pick models for each slot.":e.description})]})}),e.phases[0]?.reviewer?.candidates.length?(0,s.jsxs)("div",{className:"mt-3 flex items-center gap-2 text-[11px] text-muted-foreground",children:[e.phases[0]?.kind!=="review_only"&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-amber-400"}),"doer"]}),(0,s.jsx)("span",{className:"text-muted-foreground/40",children:"→"})]}),(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[e.phases[0]?.reviewer?.candidates.map(e=>(0,s.jsx)("span",{className:`h-1.5 w-1.5 rounded-full ${e0[e]}`,title:e},e)),(0,s.jsxs)("span",{children:[e.phases[0]?.reviewer?.candidates.length," ",e.phases[0]?.reviewer?.candidates.length===1?"reviewer":"reviewers"]})]}),e.phases.length>1&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-muted-foreground/40",children:"\xb7"}),(0,s.jsxs)("span",{className:"font-mono text-[10px]",children:[e.phases.length," phases"]})]})]}):null]}),(0,s.jsxs)("div",{className:`absolute bottom-3 right-3 flex items-center gap-1.5 transition ${e.id===f?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"}`,onClick:r=>{r.stopPropagation(),g(e.id)},onKeyDown:e=>e.stopPropagation(),children:[(0,s.jsx)(eX,{editing:e,onSaved:e=>C(e),trigger:(0,s.jsx)("button",{type:"button","aria-label":`Edit ${e.name}`,className:"grid h-7 w-7 place-items-center rounded-md border border-border bg-card text-muted-foreground transition hover:border-muted-foreground/40 hover:bg-accent/60 hover:text-foreground",children:(0,s.jsx)(n.A,{className:"h-3.5 w-3.5"})})}),"builtin"!==e.source&&(0,s.jsx)("button",{type:"button","aria-label":b===e.id?`Confirm delete ${e.name}`:`Delete ${e.name}`,title:b===e.id?"Click again to confirm":"Delete",disabled:y===e.id,onClick:()=>A(e),className:`grid h-7 w-7 place-items-center rounded-md border transition disabled:cursor-not-allowed disabled:opacity-50 ${b===e.id?"border-destructive bg-destructive/15 text-destructive":"border-border bg-card text-muted-foreground hover:border-destructive/50 hover:text-destructive"}`,children:y===e.id?(0,s.jsx)(o.A,{className:"h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(i.A,{className:"h-3.5 w-3.5"})})]})]},e.id))}),S?(0,s.jsx)("div",{className:"lg:sticky lg:top-6 lg:max-h-[calc(100vh-10rem)] lg:h-[calc(100vh-10rem)]",children:(0,s.jsx)(m.N,{filename:`${S.id}.yaml`,charCount:S.yaml.length,maxHeightClassName:"h-full",footer:(0,s.jsxs)("span",{children:["by ",S.authorHandle]}),children:S.yaml})}):(0,s.jsx)(l.Zp,{className:"bg-card p-4 text-center text-muted-foreground",children:(0,s.jsx)("p",{children:"Select a template to view details"})})]})]})})}},9936:(e,r,t)=>{Promise.resolve().then(t.bind(t,4538))}},e=>{e.O(0,[116,720,15,641,344,744,506,128,358],()=>e(e.s=9936)),_N_E=e.O()}]);