@lovelybunch/api 1.0.75-alpha.8 → 1.0.75

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 (188) hide show
  1. package/dist/lib/jobs/job-runner.js +10 -2
  2. package/dist/lib/jobs/job-scheduler.js +21 -0
  3. package/dist/lib/mail/mail-runner.d.ts +51 -0
  4. package/dist/lib/mail/mail-runner.js +342 -0
  5. package/dist/lib/slack/slack-service.d.ts +2 -0
  6. package/dist/lib/slack/slack-service.js +3 -0
  7. package/dist/lib/storage/file-storage.d.ts +16 -16
  8. package/dist/lib/storage/file-storage.js +59 -64
  9. package/dist/lib/terminal/terminal-manager.d.ts +3 -5
  10. package/dist/lib/terminal/terminal-manager.js +10 -61
  11. package/dist/routes/api/v1/ai/route.js +361 -20
  12. package/dist/routes/api/v1/chats/[id]/index.js +2 -1
  13. package/dist/routes/api/v1/chats/[id]/route.d.ts +7 -0
  14. package/dist/routes/api/v1/chats/[id]/route.js +30 -1
  15. package/dist/routes/api/v1/context/index.js +0 -2
  16. package/dist/routes/api/v1/git/index.js +23 -0
  17. package/dist/routes/api/v1/knowledge/[filename]/index.d.ts +1 -0
  18. package/dist/routes/api/v1/knowledge/[filename]/index.js +1 -0
  19. package/dist/routes/api/v1/knowledge/[filename]/route.d.ts +3 -0
  20. package/dist/routes/api/v1/knowledge/[filename]/route.js +254 -0
  21. package/dist/routes/api/v1/knowledge/index.d.ts +1 -0
  22. package/dist/routes/api/v1/knowledge/index.js +1 -0
  23. package/dist/routes/api/v1/knowledge/route.d.ts +3 -0
  24. package/dist/routes/api/v1/knowledge/route.js +176 -0
  25. package/dist/routes/api/v1/mail/index.d.ts +3 -0
  26. package/dist/routes/api/v1/mail/index.js +23 -0
  27. package/dist/routes/api/v1/mail/route.d.ts +294 -0
  28. package/dist/routes/api/v1/mail/route.js +344 -0
  29. package/dist/routes/api/v1/mcp/index.js +109 -34
  30. package/dist/routes/api/v1/slack/index.d.ts +3 -0
  31. package/dist/routes/api/v1/slack/index.js +15 -0
  32. package/dist/routes/api/v1/slack/route.d.ts +124 -0
  33. package/dist/routes/api/v1/slack/route.js +192 -0
  34. package/dist/routes/api/v1/tasks/[id]/route.d.ts +117 -0
  35. package/dist/routes/api/v1/tasks/[id]/route.js +166 -0
  36. package/dist/routes/api/v1/tasks/index.d.ts +3 -0
  37. package/dist/routes/api/v1/tasks/index.js +10 -0
  38. package/dist/routes/api/v1/tasks/route.d.ts +96 -0
  39. package/dist/routes/api/v1/tasks/route.js +136 -0
  40. package/dist/routes/api/v1/terminal/[proposalId]/create/route.js +2 -2
  41. package/dist/routes/api/v1/terminal/[taskId]/create/index.d.ts +3 -0
  42. package/dist/routes/api/v1/terminal/[taskId]/create/index.js +5 -0
  43. package/dist/routes/api/v1/terminal/[taskId]/create/route.d.ts +10 -0
  44. package/dist/routes/api/v1/terminal/[taskId]/create/route.js +27 -0
  45. package/dist/routes/api/v1/terminal/[taskId]/destroy/index.d.ts +3 -0
  46. package/dist/routes/api/v1/terminal/[taskId]/destroy/index.js +5 -0
  47. package/dist/routes/api/v1/terminal/[taskId]/destroy/route.d.ts +10 -0
  48. package/dist/routes/api/v1/terminal/[taskId]/destroy/route.js +21 -0
  49. package/dist/routes/api/v1/terminal/[taskId]/resize/index.d.ts +3 -0
  50. package/dist/routes/api/v1/terminal/[taskId]/resize/index.js +5 -0
  51. package/dist/routes/api/v1/terminal/[taskId]/resize/route.d.ts +10 -0
  52. package/dist/routes/api/v1/terminal/[taskId]/resize/route.js +21 -0
  53. package/dist/routes/api/v1/terminal/sessions/route.js +4 -4
  54. package/dist/server-with-static.js +14 -8
  55. package/dist/server.js +14 -8
  56. package/package.json +4 -4
  57. package/static/assets/{ActivityPage-DSSML9J-.js → ActivityPage-k4I7Q53O.js} +1 -1
  58. package/static/assets/ApiKeysSettingsPage-B1YvVdmg.js +2 -0
  59. package/static/assets/{ArchitectureEditPage-CIjqkpMz.js → ArchitectureEditPage-CpowsIx2.js} +1 -1
  60. package/static/assets/{ArchitecturePage-Db__w054.js → ArchitecturePage-DYxC_aMR.js} +1 -1
  61. package/static/assets/{AuthSettingsPage-Bpooi8Z0.js → AuthSettingsPage-DtSo78Y_.js} +2 -2
  62. package/static/assets/{CallbackPage-BGLKeyjv.js → CallbackPage-bROCGapx.js} +1 -1
  63. package/static/assets/CodePage-CPCj64rX.js +2 -0
  64. package/static/assets/{CollapsibleSection-B6RO5o5R.js → CollapsibleSection-M5cXbl92.js} +1 -1
  65. package/static/assets/DashboardPage-B9BZZfw6.js +51 -0
  66. package/static/assets/{GitPage-DxjLaRWe.js → GitPage-BiDtdSK1.js} +2 -2
  67. package/static/assets/GitSettingsPage-THm6wDjs.js +6 -0
  68. package/static/assets/IdentityPage-BC16skg6.js +6 -0
  69. package/static/assets/{ImplementationStepsEditor-DWjDyZzP.js → ImplementationStepsEditor-HliLQav5.js} +2 -2
  70. package/static/assets/IntegrationsSettingsPage-CC_VKIQa.js +1 -0
  71. package/static/assets/JobDetailPage-z1QQYvmU.js +1 -0
  72. package/static/assets/KnowledgeDetailPage-DzHXBS7Q.js +1 -0
  73. package/static/assets/KnowledgeEditPage-BwGnUH_m.js +1 -0
  74. package/static/assets/KnowledgePage-CGIVMS02.js +3 -0
  75. package/static/assets/{LoginPage-DptfKsWo.js → LoginPage-VQ3lcfLV.js} +1 -1
  76. package/static/assets/MailInboxPage-DiZKqwdU.js +1 -0
  77. package/static/assets/MailProcessingModal-DIeSQBoR.js +6 -0
  78. package/static/assets/MailReadPage-C8AACmZQ.js +1 -0
  79. package/static/assets/MailSentPage-C_5yFly_.js +1 -0
  80. package/static/assets/McpSettingsPage-i9YHcu1s.js +1 -0
  81. package/static/assets/NewKnowledgePage-BnVY7WUD.js +9 -0
  82. package/static/assets/{NewSkillPage-Cwy2MSr9.js → NewSkillPage-DwniHD6D.js} +1 -1
  83. package/static/assets/NewTaskPage-F5UX2WMc.js +90 -0
  84. package/static/assets/NotFoundPage-BbSZX_4L.js +6 -0
  85. package/static/assets/NotificationsSettingsPage-C8kjcift.js +1 -0
  86. package/static/assets/ProjectEditPage-DUUlIEqI.js +11 -0
  87. package/static/assets/{ProjectPage-DgUr4bVU.js → ProjectPage-Unz9PQpA.js} +1 -1
  88. package/static/assets/PromptsSettingsPage-DVpIuRKI.js +1 -0
  89. package/static/assets/ResourceDetailPage-DqHZ2KYD.js +1 -0
  90. package/static/assets/ResourcesPage-BP5tuAi-.js +41 -0
  91. package/static/assets/RoleEditPage-BgKu8S0-.js +13 -0
  92. package/static/assets/{RolePage-Sc-GFiL2.js → RolePage-Fed52Ov5.js} +1 -1
  93. package/static/assets/{RulesSettingsPage-DdMCzh9j.js → RulesSettingsPage-BQ2O0u66.js} +2 -2
  94. package/static/assets/SchedulePage-jkxjuzBx.js +4 -0
  95. package/static/assets/SkillDetailPage-k3Q2-NFd.js +1 -0
  96. package/static/assets/{SkillEditPage-BDd2CtAS.js → SkillEditPage-urF4snjo.js} +1 -1
  97. package/static/assets/SkillsPage-DlWDhEjR.js +8 -0
  98. package/static/assets/{SkillsSettingsPage-1N0JQOYc.js → SkillsSettingsPage-BViFgckG.js} +1 -1
  99. package/static/assets/SourceInput-CAFKTHw-.js +1 -0
  100. package/static/assets/{TagInput-D_SdcypZ.js → TagInput-C6lI-ePr.js} +1 -1
  101. package/static/assets/TaskDetailPage-DpbRHnW_.js +16 -0
  102. package/static/assets/TaskEditPage-DssRbW0h.js +1 -0
  103. package/static/assets/TasksPage-CD_eo0Bj.js +17 -0
  104. package/static/assets/TerminalPage-BG_wlccr.js +1 -0
  105. package/static/assets/TerminalSessionPage-CsK-LznK.js +8 -0
  106. package/static/assets/UserPreferencesPage-CWUq3efu.js +1 -0
  107. package/static/assets/UserSettingsPage-CduI_MGS.js +1 -0
  108. package/static/assets/UtilitiesPage-BAxokhLh.js +1 -0
  109. package/static/assets/{alert-BD5jo3SI.js → alert-BXsc6_qu.js} +1 -1
  110. package/static/assets/{arrow-down-BxcoVp6S.js → arrow-down-DmW_3gE8.js} +1 -1
  111. package/static/assets/{arrow-left-CdM_IPng.js → arrow-left-1S-835kP.js} +1 -1
  112. package/static/assets/{arrow-up-BOJ6ob9X.js → arrow-up-BYism_o1.js} +1 -1
  113. package/static/assets/arrow-up-down-Dw3J0a4i.js +6 -0
  114. package/static/assets/{badge-DEiQk9C9.js → badge-BUEY53dV.js} +1 -1
  115. package/static/assets/{browser-modal-Dp1eMxt6.js → browser-modal-DCNdI4NT.js} +2 -2
  116. package/static/assets/{card-BCFxXzRk.js → card-BcPlIAH5.js} +1 -1
  117. package/static/assets/{chevron-left-C25izNzZ.js → chevron-left-FMmNe7yP.js} +1 -1
  118. package/static/assets/{plus-iamYJu5V.js → chevron-up-CqM3won3.js} +2 -2
  119. package/static/assets/{chevrons-up-DqbWMOjv.js → chevrons-up-DTvCkIHc.js} +1 -1
  120. package/static/assets/{circle-alert-CMRMPnbY.js → circle-alert-dseM-Ib7.js} +1 -1
  121. package/static/assets/{circle-check-big-NI18oHuP.js → circle-check-big-jKg34xC-.js} +1 -1
  122. package/static/assets/{circle-check-D5wZZPvj.js → circle-check-eyo6pBP1.js} +1 -1
  123. package/static/assets/{circle-play-BhVU869u.js → circle-play-BrY_lNiH.js} +1 -1
  124. package/static/assets/{circle-x-BXDB-G_q.js → circle-x-uqmzEce1.js} +1 -1
  125. package/static/assets/{clipboard-DC2xmNVx.js → clipboard-tzPFoieb.js} +1 -1
  126. package/static/assets/{clock-CeCp7Pz1.js → clock-Bjc06QBM.js} +1 -1
  127. package/static/assets/code-DrYqPukx.js +6 -0
  128. package/static/assets/{download-ZF_XbTIA.js → download-Bg__QCLT.js} +1 -1
  129. package/static/assets/{external-link-CYBz87-P.js → external-link-CNDy2UUo.js} +1 -1
  130. package/static/assets/{eye-BT8MAvKY.js → eye-DLFBnC8t.js} +1 -1
  131. package/static/assets/{folder-git-2-BE9AIPnj.js → folder-git-2-DUqd0WRi.js} +1 -1
  132. package/static/assets/index-CHdBxVyk.css +2 -0
  133. package/static/assets/index-DFcWlnzl.js +487 -0
  134. package/static/assets/{info-DunFSp-x.js → info-D6jxZC5X.js} +1 -1
  135. package/static/assets/kiro-CX1mOsRO.js +17 -0
  136. package/static/assets/{label-vYhfrPMD.js → label-DBuh-ke5.js} +1 -1
  137. package/static/assets/{markdown-editor-BzZ8tCto.js → markdown-editor-B4YNQFT2.js} +1 -1
  138. package/static/assets/message-square-B5RWz_ff.js +6 -0
  139. package/static/assets/paperclip-4A_3MaPx.js +6 -0
  140. package/static/assets/{pause-BHonpdnw.js → pause-BzhKXHtR.js} +1 -1
  141. package/static/assets/{play-CCo7tau2.js → play-CHIf-Rcz.js} +1 -1
  142. package/static/assets/{radio-group-Db-pBuyW.js → radio-group-C1ct-VsJ.js} +1 -1
  143. package/static/assets/{refresh-cw-Bg7vQzOw.js → refresh-cw-B3OwrDUf.js} +1 -1
  144. package/static/assets/{search-CH2zaibZ.js → search-Cq1ksEdp.js} +1 -1
  145. package/static/assets/select-44mcS2_G.js +1 -0
  146. package/static/assets/{status-utils-BDOyevaX.js → status-utils-CDkPeVfP.js} +1 -1
  147. package/static/assets/{switch-CH-VOgPo.js → switch-CIwjYvCt.js} +1 -1
  148. package/static/assets/{tabs-XeRAjZYR.js → tabs-DTV6Su-h.js} +1 -1
  149. package/static/assets/{tag-CRP5nL5-.js → tag-p6yeowCW.js} +1 -1
  150. package/static/assets/{terminal-preview-DMJMuORo.js → terminal-preview-DN38x9Jm.js} +1 -1
  151. package/static/assets/use-terminal-BXJqOeJe.js +1 -0
  152. package/static/assets/video-BH5ChaoS.js +36 -0
  153. package/static/index.html +2 -2
  154. package/static/assets/ApiKeysSettingsPage-Chw9PNL5.js +0 -2
  155. package/static/assets/CodePage-CrokcH-S.js +0 -2
  156. package/static/assets/DashboardPage-BaSQQ8Nv.js +0 -41
  157. package/static/assets/GitSettingsPage-tKBXYAFm.js +0 -6
  158. package/static/assets/IdentityPage-D2yBjeYn.js +0 -11
  159. package/static/assets/IntegrationsSettingsPage-Bx8-0Ig4.js +0 -1
  160. package/static/assets/JobDetailPage-BQmTHled.js +0 -1
  161. package/static/assets/KnowledgeDetailPage-QMU2bC3L.js +0 -1
  162. package/static/assets/KnowledgeEditPage-DbMJVcLc.js +0 -1
  163. package/static/assets/KnowledgePage-aU1GxZSZ.js +0 -8
  164. package/static/assets/McpSettingsPage-C3WxFwRB.js +0 -1
  165. package/static/assets/NewKnowledgePage-Cbiswrw_.js +0 -9
  166. package/static/assets/NewProposalPage-B_sDMBTK.js +0 -90
  167. package/static/assets/ProjectEditPage-BznWiBBc.js +0 -11
  168. package/static/assets/PromptsSettingsPage-CY0-870a.js +0 -1
  169. package/static/assets/ProposalDetailPage-K4iMXHEg.js +0 -1
  170. package/static/assets/ProposalEditPage-jZOtCMqP.js +0 -1
  171. package/static/assets/ProposalsPage-C7n4-G05.js +0 -17
  172. package/static/assets/ResourcesPage-vB5-XkUv.js +0 -71
  173. package/static/assets/RoleEditPage-Cu7ZB3yj.js +0 -13
  174. package/static/assets/SchedulePage-Bkkf2wA0.js +0 -4
  175. package/static/assets/SkillDetailPage-5sDxf3Of.js +0 -1
  176. package/static/assets/SkillsPage-D2G7EfK8.js +0 -8
  177. package/static/assets/SourceInput-DlC0zwva.js +0 -1
  178. package/static/assets/TerminalPage--KZ7azvP.js +0 -1
  179. package/static/assets/TerminalSessionPage-ClvxK9ia.js +0 -13
  180. package/static/assets/UserPreferencesPage-CheOH7jZ.js +0 -1
  181. package/static/assets/UserSettingsPage-C8STDvfQ.js +0 -1
  182. package/static/assets/UtilitiesPage-9rTxR2md.js +0 -1
  183. package/static/assets/calendar-Cx5r9R7A.js +0 -6
  184. package/static/assets/droid-DqWsM2dp.js +0 -17
  185. package/static/assets/index-DVTgTsDa.css +0 -2
  186. package/static/assets/index-hqVgTgRB.js +0 -462
  187. package/static/assets/use-terminal-DuGZuvd2.js +0 -1
  188. package/static/assets/zap-BlzMp7dY.js +0 -6
@@ -0,0 +1,6 @@
1
+ import{c as a}from"./index-DFcWlnzl.js";/**
2
+ * @license lucide-react v0.542.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const e=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],o=a("message-square",e);export{o as M};
@@ -0,0 +1,6 @@
1
+ import{c}from"./index-DFcWlnzl.js";/**
2
+ * @license lucide-react v0.542.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const a=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],o=c("paperclip",a);export{o as P};
@@ -1,4 +1,4 @@
1
- import{c as e}from"./index-hqVgTgRB.js";/**
1
+ import{c as e}from"./index-DFcWlnzl.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as a}from"./index-hqVgTgRB.js";/**
1
+ import{c as a}from"./index-DFcWlnzl.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{r as n,b9 as E,at as K,an as T,j as a,ao as N,ba as U,ar as x,as as g,bb as V,aq as w,bc as z,aw as H,av as $,e as I,bd as W}from"./index-hqVgTgRB.js";var C="Radio",[X,_]=N(C),[Y,J]=X(C),j=n.forwardRef((r,t)=>{const{__scopeRadio:e,name:d,checked:o=!1,required:s,disabled:i,value:p="on",onCheck:f,form:R,...v}=r,[l,m]=n.useState(null),c=g(t,y=>m(y)),u=n.useRef(!1),b=l?R||!!l.closest("form"):!0;return a.jsxs(Y,{scope:e,checked:o,disabled:i,children:[a.jsx(x.button,{type:"button",role:"radio","aria-checked":o,"data-state":S(o),"data-disabled":i?"":void 0,disabled:i,value:p,...v,ref:c,onClick:w(r.onClick,y=>{o||f?.(),b&&(u.current=y.isPropagationStopped(),u.current||y.stopPropagation())})}),b&&a.jsx(P,{control:l,bubbles:!u.current,name:d,value:p,checked:o,required:s,disabled:i,form:R,style:{transform:"translateX(-100%)"}})]})});j.displayName=C;var k="RadioIndicator",G=n.forwardRef((r,t)=>{const{__scopeRadio:e,forceMount:d,...o}=r,s=J(k,e);return a.jsx(z,{present:d||s.checked,children:a.jsx(x.span,{"data-state":S(s.checked),"data-disabled":s.disabled?"":void 0,...o,ref:t})})});G.displayName=k;var Q="RadioBubbleInput",P=n.forwardRef(({__scopeRadio:r,control:t,checked:e,bubbles:d=!0,...o},s)=>{const i=n.useRef(null),p=g(i,s),f=H(e),R=$(t);return n.useEffect(()=>{const v=i.current;if(!v)return;const l=window.HTMLInputElement.prototype,c=Object.getOwnPropertyDescriptor(l,"checked").set;if(f!==e&&c){const u=new Event("click",{bubbles:d});c.call(v,e),v.dispatchEvent(u)}},[f,e,d]),a.jsx(x.input,{type:"radio","aria-hidden":!0,defaultChecked:e,...o,tabIndex:-1,ref:p,style:{...o.style,...R,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});P.displayName=Q;function S(r){return r?"checked":"unchecked"}var Z=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],h="RadioGroup",[ee,de]=N(h,[E,_]),A=E(),D=_(),[oe,re]=ee(h),M=n.forwardRef((r,t)=>{const{__scopeRadioGroup:e,name:d,defaultValue:o,value:s,required:i=!1,disabled:p=!1,orientation:f,dir:R,loop:v=!0,onValueChange:l,...m}=r,c=A(e),u=K(R),[b,y]=T({prop:s,defaultProp:o??null,onChange:l,caller:h});return a.jsx(oe,{scope:e,name:d,required:i,disabled:p,value:b,onValueChange:y,children:a.jsx(U,{asChild:!0,...c,orientation:f,dir:u,loop:v,children:a.jsx(x.div,{role:"radiogroup","aria-required":i,"aria-orientation":f,"data-disabled":p?"":void 0,dir:u,...m,ref:t})})})});M.displayName=h;var O="RadioGroupItem",q=n.forwardRef((r,t)=>{const{__scopeRadioGroup:e,disabled:d,...o}=r,s=re(O,e),i=s.disabled||d,p=A(e),f=D(e),R=n.useRef(null),v=g(t,R),l=s.value===o.value,m=n.useRef(!1);return n.useEffect(()=>{const c=b=>{Z.includes(b.key)&&(m.current=!0)},u=()=>m.current=!1;return document.addEventListener("keydown",c),document.addEventListener("keyup",u),()=>{document.removeEventListener("keydown",c),document.removeEventListener("keyup",u)}},[]),a.jsx(V,{asChild:!0,...p,focusable:!i,active:l,children:a.jsx(j,{disabled:i,required:s.required,checked:l,...f,...o,name:s.name,ref:v,onCheck:()=>s.onValueChange(o.value),onKeyDown:w(c=>{c.key==="Enter"&&c.preventDefault()}),onFocus:w(o.onFocus,()=>{m.current&&R.current?.click()})})})});q.displayName=O;var ae="RadioGroupIndicator",F=n.forwardRef((r,t)=>{const{__scopeRadioGroup:e,...d}=r,o=D(e);return a.jsx(G,{...o,...d,ref:t})});F.displayName=ae;var L=M,B=q,te=F;const se=n.forwardRef(({className:r,...t},e)=>a.jsx(L,{className:I("grid gap-2",r),...t,ref:e}));se.displayName=L.displayName;const ne=n.forwardRef(({className:r,...t},e)=>a.jsx(B,{ref:e,className:I("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",r),...t,children:a.jsx(te,{className:"flex items-center justify-center",children:a.jsx(W,{className:"h-2.5 w-2.5 fill-current text-current"})})}));ne.displayName=B.displayName;export{se as R,ne as a};
1
+ import{r as n,bk as E,am as K,ag as T,j as a,ah as N,bl as U,ak as h,al as w,bm as V,aj as g,bn as z,ap as H,ao as $,e as k,bo as W}from"./index-DFcWlnzl.js";var C="Radio",[X,I]=N(C),[Y,J]=X(C),j=n.forwardRef((r,t)=>{const{__scopeRadio:e,name:d,checked:o=!1,required:s,disabled:i,value:p="on",onCheck:f,form:R,...v}=r,[l,m]=n.useState(null),c=w(t,y=>m(y)),u=n.useRef(!1),b=l?R||!!l.closest("form"):!0;return a.jsxs(Y,{scope:e,checked:o,disabled:i,children:[a.jsx(h.button,{type:"button",role:"radio","aria-checked":o,"data-state":S(o),"data-disabled":i?"":void 0,disabled:i,value:p,...v,ref:c,onClick:g(r.onClick,y=>{o||f?.(),b&&(u.current=y.isPropagationStopped(),u.current||y.stopPropagation())})}),b&&a.jsx(P,{control:l,bubbles:!u.current,name:d,value:p,checked:o,required:s,disabled:i,form:R,style:{transform:"translateX(-100%)"}})]})});j.displayName=C;var _="RadioIndicator",G=n.forwardRef((r,t)=>{const{__scopeRadio:e,forceMount:d,...o}=r,s=J(_,e);return a.jsx(z,{present:d||s.checked,children:a.jsx(h.span,{"data-state":S(s.checked),"data-disabled":s.disabled?"":void 0,...o,ref:t})})});G.displayName=_;var Q="RadioBubbleInput",P=n.forwardRef(({__scopeRadio:r,control:t,checked:e,bubbles:d=!0,...o},s)=>{const i=n.useRef(null),p=w(i,s),f=H(e),R=$(t);return n.useEffect(()=>{const v=i.current;if(!v)return;const l=window.HTMLInputElement.prototype,c=Object.getOwnPropertyDescriptor(l,"checked").set;if(f!==e&&c){const u=new Event("click",{bubbles:d});c.call(v,e),v.dispatchEvent(u)}},[f,e,d]),a.jsx(h.input,{type:"radio","aria-hidden":!0,defaultChecked:e,...o,tabIndex:-1,ref:p,style:{...o.style,...R,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});P.displayName=Q;function S(r){return r?"checked":"unchecked"}var Z=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],x="RadioGroup",[ee,de]=N(x,[E,I]),A=E(),D=I(),[oe,re]=ee(x),M=n.forwardRef((r,t)=>{const{__scopeRadioGroup:e,name:d,defaultValue:o,value:s,required:i=!1,disabled:p=!1,orientation:f,dir:R,loop:v=!0,onValueChange:l,...m}=r,c=A(e),u=K(R),[b,y]=T({prop:s,defaultProp:o??null,onChange:l,caller:x});return a.jsx(oe,{scope:e,name:d,required:i,disabled:p,value:b,onValueChange:y,children:a.jsx(U,{asChild:!0,...c,orientation:f,dir:u,loop:v,children:a.jsx(h.div,{role:"radiogroup","aria-required":i,"aria-orientation":f,"data-disabled":p?"":void 0,dir:u,...m,ref:t})})})});M.displayName=x;var O="RadioGroupItem",F=n.forwardRef((r,t)=>{const{__scopeRadioGroup:e,disabled:d,...o}=r,s=re(O,e),i=s.disabled||d,p=A(e),f=D(e),R=n.useRef(null),v=w(t,R),l=s.value===o.value,m=n.useRef(!1);return n.useEffect(()=>{const c=b=>{Z.includes(b.key)&&(m.current=!0)},u=()=>m.current=!1;return document.addEventListener("keydown",c),document.addEventListener("keyup",u),()=>{document.removeEventListener("keydown",c),document.removeEventListener("keyup",u)}},[]),a.jsx(V,{asChild:!0,...p,focusable:!i,active:l,children:a.jsx(j,{disabled:i,required:s.required,checked:l,...f,...o,name:s.name,ref:v,onCheck:()=>s.onValueChange(o.value),onKeyDown:g(c=>{c.key==="Enter"&&c.preventDefault()}),onFocus:g(o.onFocus,()=>{m.current&&R.current?.click()})})})});F.displayName=O;var ae="RadioGroupIndicator",L=n.forwardRef((r,t)=>{const{__scopeRadioGroup:e,...d}=r,o=D(e);return a.jsx(G,{...o,...d,ref:t})});L.displayName=ae;var q=M,B=F,te=L;const se=n.forwardRef(({className:r,...t},e)=>a.jsx(q,{className:k("grid gap-2",r),...t,ref:e}));se.displayName=q.displayName;const ne=n.forwardRef(({className:r,...t},e)=>a.jsx(B,{ref:e,className:k("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",r),...t,children:a.jsx(te,{className:"flex items-center justify-center",children:a.jsx(W,{className:"h-2.5 w-2.5 fill-current text-current"})})}));ne.displayName=B.displayName;export{se as R,ne as a};
@@ -1,4 +1,4 @@
1
- import{c as e}from"./index-hqVgTgRB.js";/**
1
+ import{c as e}from"./index-DFcWlnzl.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c}from"./index-hqVgTgRB.js";/**
1
+ import{c}from"./index-DFcWlnzl.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -0,0 +1 @@
1
+ import{r as t,b3 as Pe,am as ft,ag as Te,j as r,b4 as mt,ah as ht,b5 as be,ai as gt,al as L,b6 as z,ak as j,ap as vt,b7 as xt,b8 as St,aj as N,b9 as wt,ba as Re,bb as yt,bc as Ct,bd as bt,be as It,bf as Tt,bg as Nt,bh as Pt,bi as Rt,an as Ne,bj as Et,e as G,n as Ee,ae as _t}from"./index-DFcWlnzl.js";import{C as jt}from"./chevron-up-CqM3won3.js";var Mt=[" ","Enter","ArrowUp","ArrowDown"],At=[" ","Enter"],Q="Select",[ie,de,Ot]=gt(Q),[oe,mo]=ht(Q,[Ot,Pe]),ue=Pe(),[Dt,Y]=oe(Q),[Lt,kt]=oe(Q),_e=o=>{const{__scopeSelect:n,children:e,open:l,defaultOpen:a,onOpenChange:u,value:s,defaultValue:c,onValueChange:i,dir:f,name:v,autoComplete:w,disabled:P,required:I,form:C}=o,d=ue(n),[h,x]=t.useState(null),[m,g]=t.useState(null),[F,M]=t.useState(!1),ne=ft(f),[R,O]=Te({prop:l,defaultProp:a??!1,onChange:u,caller:Q}),[W,X]=Te({prop:s,defaultProp:c,onChange:i,caller:Q}),k=t.useRef(null),B=h?C||!!h.closest("form"):!0,[K,V]=t.useState(new Set),H=Array.from(K).map(E=>E.props.value).join(";");return r.jsx(mt,{...d,children:r.jsxs(Dt,{required:I,scope:n,trigger:h,onTriggerChange:x,valueNode:m,onValueNodeChange:g,valueNodeHasChildren:F,onValueNodeHasChildrenChange:M,contentId:be(),value:W,onValueChange:X,open:R,onOpenChange:O,dir:ne,triggerPointerDownPosRef:k,disabled:P,children:[r.jsx(ie.Provider,{scope:n,children:r.jsx(Lt,{scope:o.__scopeSelect,onNativeOptionAdd:t.useCallback(E=>{V(D=>new Set(D).add(E))},[]),onNativeOptionRemove:t.useCallback(E=>{V(D=>{const U=new Set(D);return U.delete(E),U})},[]),children:e})}),B?r.jsxs(et,{"aria-hidden":!0,required:I,tabIndex:-1,name:v,autoComplete:w,value:W,onChange:E=>X(E.target.value),disabled:P,form:C,children:[W===void 0?r.jsx("option",{value:""}):null,Array.from(K)]},H):null]})})};_e.displayName=Q;var je="SelectTrigger",Me=t.forwardRef((o,n)=>{const{__scopeSelect:e,disabled:l=!1,...a}=o,u=ue(e),s=Y(je,e),c=s.disabled||l,i=L(n,s.onTriggerChange),f=de(e),v=t.useRef("touch"),[w,P,I]=ot(d=>{const h=f().filter(g=>!g.disabled),x=h.find(g=>g.value===s.value),m=nt(h,d,x);m!==void 0&&s.onValueChange(m.value)}),C=d=>{c||(s.onOpenChange(!0),I()),d&&(s.triggerPointerDownPosRef.current={x:Math.round(d.pageX),y:Math.round(d.pageY)})};return r.jsx(St,{asChild:!0,...u,children:r.jsx(j.button,{type:"button",role:"combobox","aria-controls":s.contentId,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":"none",dir:s.dir,"data-state":s.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":tt(s.value)?"":void 0,...a,ref:i,onClick:N(a.onClick,d=>{d.currentTarget.focus(),v.current!=="mouse"&&C(d)}),onPointerDown:N(a.onPointerDown,d=>{v.current=d.pointerType;const h=d.target;h.hasPointerCapture(d.pointerId)&&h.releasePointerCapture(d.pointerId),d.button===0&&d.ctrlKey===!1&&d.pointerType==="mouse"&&(C(d),d.preventDefault())}),onKeyDown:N(a.onKeyDown,d=>{const h=w.current!=="";!(d.ctrlKey||d.altKey||d.metaKey)&&d.key.length===1&&P(d.key),!(h&&d.key===" ")&&Mt.includes(d.key)&&(C(),d.preventDefault())})})})});Me.displayName=je;var Ae="SelectValue",Oe=t.forwardRef((o,n)=>{const{__scopeSelect:e,className:l,style:a,children:u,placeholder:s="",...c}=o,i=Y(Ae,e),{onValueNodeHasChildrenChange:f}=i,v=u!==void 0,w=L(n,i.onValueNodeChange);return z(()=>{f(v)},[f,v]),r.jsx(j.span,{...c,ref:w,style:{pointerEvents:"none"},children:tt(i.value)?r.jsx(r.Fragment,{children:s}):u})});Oe.displayName=Ae;var Bt="SelectIcon",De=t.forwardRef((o,n)=>{const{__scopeSelect:e,children:l,...a}=o;return r.jsx(j.span,{"aria-hidden":!0,...a,ref:n,children:l||"▼"})});De.displayName=Bt;var Vt="SelectPortal",Le=o=>r.jsx(wt,{asChild:!0,...o});Le.displayName=Vt;var ee="SelectContent",ke=t.forwardRef((o,n)=>{const e=Y(ee,o.__scopeSelect),[l,a]=t.useState();if(z(()=>{a(new DocumentFragment)},[]),!e.open){const u=l;return u?Re.createPortal(r.jsx(Be,{scope:o.__scopeSelect,children:r.jsx(ie.Slot,{scope:o.__scopeSelect,children:r.jsx("div",{children:o.children})})}),u):null}return r.jsx(Ve,{...o,ref:n})});ke.displayName=ee;var A=10,[Be,q]=oe(ee),Ht="SelectContentImpl",Ut=Tt("SelectContent.RemoveScroll"),Ve=t.forwardRef((o,n)=>{const{__scopeSelect:e,position:l="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:u,onPointerDownOutside:s,side:c,sideOffset:i,align:f,alignOffset:v,arrowPadding:w,collisionBoundary:P,collisionPadding:I,sticky:C,hideWhenDetached:d,avoidCollisions:h,...x}=o,m=Y(ee,e),[g,F]=t.useState(null),[M,ne]=t.useState(null),R=L(n,p=>F(p)),[O,W]=t.useState(null),[X,k]=t.useState(null),B=de(e),[K,V]=t.useState(!1),H=t.useRef(!1);t.useEffect(()=>{if(g)return Ct(g)},[g]),bt();const E=t.useCallback(p=>{const[b,..._]=B().map(T=>T.ref.current),[S]=_.slice(-1),y=document.activeElement;for(const T of p)if(T===y||(T?.scrollIntoView({block:"nearest"}),T===b&&M&&(M.scrollTop=0),T===S&&M&&(M.scrollTop=M.scrollHeight),T?.focus(),document.activeElement!==y))return},[B,M]),D=t.useCallback(()=>E([O,g]),[E,O,g]);t.useEffect(()=>{K&&D()},[K,D]);const{onOpenChange:U,triggerPointerDownPosRef:$}=m;t.useEffect(()=>{if(g){let p={x:0,y:0};const b=S=>{p={x:Math.abs(Math.round(S.pageX)-($.current?.x??0)),y:Math.abs(Math.round(S.pageY)-($.current?.y??0))}},_=S=>{p.x<=10&&p.y<=10?S.preventDefault():g.contains(S.target)||U(!1),document.removeEventListener("pointermove",b),$.current=null};return $.current!==null&&(document.addEventListener("pointermove",b),document.addEventListener("pointerup",_,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",b),document.removeEventListener("pointerup",_,{capture:!0})}}},[g,U,$]),t.useEffect(()=>{const p=()=>U(!1);return window.addEventListener("blur",p),window.addEventListener("resize",p),()=>{window.removeEventListener("blur",p),window.removeEventListener("resize",p)}},[U]);const[pe,ae]=ot(p=>{const b=B().filter(y=>!y.disabled),_=b.find(y=>y.ref.current===document.activeElement),S=nt(b,p,_);S&&setTimeout(()=>S.ref.current.focus())}),fe=t.useCallback((p,b,_)=>{const S=!H.current&&!_;(m.value!==void 0&&m.value===b||S)&&(W(p),S&&(H.current=!0))},[m.value]),me=t.useCallback(()=>g?.focus(),[g]),te=t.useCallback((p,b,_)=>{const S=!H.current&&!_;(m.value!==void 0&&m.value===b||S)&&k(p)},[m.value]),le=l==="popper"?xe:He,re=le===xe?{side:c,sideOffset:i,align:f,alignOffset:v,arrowPadding:w,collisionBoundary:P,collisionPadding:I,sticky:C,hideWhenDetached:d,avoidCollisions:h}:{};return r.jsx(Be,{scope:e,content:g,viewport:M,onViewportChange:ne,itemRefCallback:fe,selectedItem:O,onItemLeave:me,itemTextRefCallback:te,focusSelectedItem:D,selectedItemText:X,position:l,isPositioned:K,searchRef:pe,children:r.jsx(It,{as:Ut,allowPinchZoom:!0,children:r.jsx(Nt,{asChild:!0,trapped:m.open,onMountAutoFocus:p=>{p.preventDefault()},onUnmountAutoFocus:N(a,p=>{m.trigger?.focus({preventScroll:!0}),p.preventDefault()}),children:r.jsx(Pt,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:u,onPointerDownOutside:s,onFocusOutside:p=>p.preventDefault(),onDismiss:()=>m.onOpenChange(!1),children:r.jsx(le,{role:"listbox",id:m.contentId,"data-state":m.open?"open":"closed",dir:m.dir,onContextMenu:p=>p.preventDefault(),...x,...re,onPlaced:()=>V(!0),ref:R,style:{display:"flex",flexDirection:"column",outline:"none",...x.style},onKeyDown:N(x.onKeyDown,p=>{const b=p.ctrlKey||p.altKey||p.metaKey;if(p.key==="Tab"&&p.preventDefault(),!b&&p.key.length===1&&ae(p.key),["ArrowUp","ArrowDown","Home","End"].includes(p.key)){let S=B().filter(y=>!y.disabled).map(y=>y.ref.current);if(["ArrowUp","End"].includes(p.key)&&(S=S.slice().reverse()),["ArrowUp","ArrowDown"].includes(p.key)){const y=p.target,T=S.indexOf(y);S=S.slice(T+1)}setTimeout(()=>E(S)),p.preventDefault()}})})})})})})});Ve.displayName=Ht;var Ft="SelectItemAlignedPosition",He=t.forwardRef((o,n)=>{const{__scopeSelect:e,onPlaced:l,...a}=o,u=Y(ee,e),s=q(ee,e),[c,i]=t.useState(null),[f,v]=t.useState(null),w=L(n,R=>v(R)),P=de(e),I=t.useRef(!1),C=t.useRef(!0),{viewport:d,selectedItem:h,selectedItemText:x,focusSelectedItem:m}=s,g=t.useCallback(()=>{if(u.trigger&&u.valueNode&&c&&f&&d&&h&&x){const R=u.trigger.getBoundingClientRect(),O=f.getBoundingClientRect(),W=u.valueNode.getBoundingClientRect(),X=x.getBoundingClientRect();if(u.dir!=="rtl"){const y=X.left-O.left,T=W.left-y,Z=R.left-T,J=R.width+Z,he=Math.max(J,O.width),ge=window.innerWidth-A,ve=Ne(T,[A,Math.max(A,ge-he)]);c.style.minWidth=J+"px",c.style.left=ve+"px"}else{const y=O.right-X.right,T=window.innerWidth-W.right-y,Z=window.innerWidth-R.right-T,J=R.width+Z,he=Math.max(J,O.width),ge=window.innerWidth-A,ve=Ne(T,[A,Math.max(A,ge-he)]);c.style.minWidth=J+"px",c.style.right=ve+"px"}const k=P(),B=window.innerHeight-A*2,K=d.scrollHeight,V=window.getComputedStyle(f),H=parseInt(V.borderTopWidth,10),E=parseInt(V.paddingTop,10),D=parseInt(V.borderBottomWidth,10),U=parseInt(V.paddingBottom,10),$=H+E+K+U+D,pe=Math.min(h.offsetHeight*5,$),ae=window.getComputedStyle(d),fe=parseInt(ae.paddingTop,10),me=parseInt(ae.paddingBottom,10),te=R.top+R.height/2-A,le=B-te,re=h.offsetHeight/2,p=h.offsetTop+re,b=H+E+p,_=$-b;if(b<=te){const y=k.length>0&&h===k[k.length-1].ref.current;c.style.bottom="0px";const T=f.clientHeight-d.offsetTop-d.offsetHeight,Z=Math.max(le,re+(y?me:0)+T+D),J=b+Z;c.style.height=J+"px"}else{const y=k.length>0&&h===k[0].ref.current;c.style.top="0px";const Z=Math.max(te,H+d.offsetTop+(y?fe:0)+re)+_;c.style.height=Z+"px",d.scrollTop=b-te+d.offsetTop}c.style.margin=`${A}px 0`,c.style.minHeight=pe+"px",c.style.maxHeight=B+"px",l?.(),requestAnimationFrame(()=>I.current=!0)}},[P,u.trigger,u.valueNode,c,f,d,h,x,u.dir,l]);z(()=>g(),[g]);const[F,M]=t.useState();z(()=>{f&&M(window.getComputedStyle(f).zIndex)},[f]);const ne=t.useCallback(R=>{R&&C.current===!0&&(g(),m?.(),C.current=!1)},[g,m]);return r.jsx(Kt,{scope:e,contentWrapper:c,shouldExpandOnScrollRef:I,onScrollButtonChange:ne,children:r.jsx("div",{ref:i,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:F},children:r.jsx(j.div,{...a,ref:w,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});He.displayName=Ft;var Wt="SelectPopperPosition",xe=t.forwardRef((o,n)=>{const{__scopeSelect:e,align:l="start",collisionPadding:a=A,...u}=o,s=ue(e);return r.jsx(Rt,{...s,...u,ref:n,align:l,collisionPadding:a,style:{boxSizing:"border-box",...u.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});xe.displayName=Wt;var[Kt,Ie]=oe(ee,{}),Se="SelectViewport",Ue=t.forwardRef((o,n)=>{const{__scopeSelect:e,nonce:l,...a}=o,u=q(Se,e),s=Ie(Se,e),c=L(n,u.onViewportChange),i=t.useRef(0);return r.jsxs(r.Fragment,{children:[r.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:l}),r.jsx(ie.Slot,{scope:e,children:r.jsx(j.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:N(a.onScroll,f=>{const v=f.currentTarget,{contentWrapper:w,shouldExpandOnScrollRef:P}=s;if(P?.current&&w){const I=Math.abs(i.current-v.scrollTop);if(I>0){const C=window.innerHeight-A*2,d=parseFloat(w.style.minHeight),h=parseFloat(w.style.height),x=Math.max(d,h);if(x<C){const m=x+I,g=Math.min(C,m),F=m-g;w.style.height=g+"px",w.style.bottom==="0px"&&(v.scrollTop=F>0?F:0,w.style.justifyContent="flex-end")}}}i.current=v.scrollTop})})})]})});Ue.displayName=Se;var Fe="SelectGroup",[$t,zt]=oe(Fe),Gt=t.forwardRef((o,n)=>{const{__scopeSelect:e,...l}=o,a=be();return r.jsx($t,{scope:e,id:a,children:r.jsx(j.div,{role:"group","aria-labelledby":a,...l,ref:n})})});Gt.displayName=Fe;var We="SelectLabel",Ke=t.forwardRef((o,n)=>{const{__scopeSelect:e,...l}=o,a=zt(We,e);return r.jsx(j.div,{id:a.id,...l,ref:n})});Ke.displayName=We;var ce="SelectItem",[Yt,$e]=oe(ce),ze=t.forwardRef((o,n)=>{const{__scopeSelect:e,value:l,disabled:a=!1,textValue:u,...s}=o,c=Y(ce,e),i=q(ce,e),f=c.value===l,[v,w]=t.useState(u??""),[P,I]=t.useState(!1),C=L(n,m=>i.itemRefCallback?.(m,l,a)),d=be(),h=t.useRef("touch"),x=()=>{a||(c.onValueChange(l),c.onOpenChange(!1))};if(l==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return r.jsx(Yt,{scope:e,value:l,disabled:a,textId:d,isSelected:f,onItemTextChange:t.useCallback(m=>{w(g=>g||(m?.textContent??"").trim())},[]),children:r.jsx(ie.ItemSlot,{scope:e,value:l,disabled:a,textValue:v,children:r.jsx(j.div,{role:"option","aria-labelledby":d,"data-highlighted":P?"":void 0,"aria-selected":f&&P,"data-state":f?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...s,ref:C,onFocus:N(s.onFocus,()=>I(!0)),onBlur:N(s.onBlur,()=>I(!1)),onClick:N(s.onClick,()=>{h.current!=="mouse"&&x()}),onPointerUp:N(s.onPointerUp,()=>{h.current==="mouse"&&x()}),onPointerDown:N(s.onPointerDown,m=>{h.current=m.pointerType}),onPointerMove:N(s.onPointerMove,m=>{h.current=m.pointerType,a?i.onItemLeave?.():h.current==="mouse"&&m.currentTarget.focus({preventScroll:!0})}),onPointerLeave:N(s.onPointerLeave,m=>{m.currentTarget===document.activeElement&&i.onItemLeave?.()}),onKeyDown:N(s.onKeyDown,m=>{i.searchRef?.current!==""&&m.key===" "||(At.includes(m.key)&&x(),m.key===" "&&m.preventDefault())})})})})});ze.displayName=ce;var se="SelectItemText",Ge=t.forwardRef((o,n)=>{const{__scopeSelect:e,className:l,style:a,...u}=o,s=Y(se,e),c=q(se,e),i=$e(se,e),f=kt(se,e),[v,w]=t.useState(null),P=L(n,x=>w(x),i.onItemTextChange,x=>c.itemTextRefCallback?.(x,i.value,i.disabled)),I=v?.textContent,C=t.useMemo(()=>r.jsx("option",{value:i.value,disabled:i.disabled,children:I},i.value),[i.disabled,i.value,I]),{onNativeOptionAdd:d,onNativeOptionRemove:h}=f;return z(()=>(d(C),()=>h(C)),[d,h,C]),r.jsxs(r.Fragment,{children:[r.jsx(j.span,{id:i.textId,...u,ref:P}),i.isSelected&&s.valueNode&&!s.valueNodeHasChildren?Re.createPortal(u.children,s.valueNode):null]})});Ge.displayName=se;var Ye="SelectItemIndicator",qe=t.forwardRef((o,n)=>{const{__scopeSelect:e,...l}=o;return $e(Ye,e).isSelected?r.jsx(j.span,{"aria-hidden":!0,...l,ref:n}):null});qe.displayName=Ye;var we="SelectScrollUpButton",Xe=t.forwardRef((o,n)=>{const e=q(we,o.__scopeSelect),l=Ie(we,o.__scopeSelect),[a,u]=t.useState(!1),s=L(n,l.onScrollButtonChange);return z(()=>{if(e.viewport&&e.isPositioned){let c=function(){const f=i.scrollTop>0;u(f)};const i=e.viewport;return c(),i.addEventListener("scroll",c),()=>i.removeEventListener("scroll",c)}},[e.viewport,e.isPositioned]),a?r.jsx(Je,{...o,ref:s,onAutoScroll:()=>{const{viewport:c,selectedItem:i}=e;c&&i&&(c.scrollTop=c.scrollTop-i.offsetHeight)}}):null});Xe.displayName=we;var ye="SelectScrollDownButton",Ze=t.forwardRef((o,n)=>{const e=q(ye,o.__scopeSelect),l=Ie(ye,o.__scopeSelect),[a,u]=t.useState(!1),s=L(n,l.onScrollButtonChange);return z(()=>{if(e.viewport&&e.isPositioned){let c=function(){const f=i.scrollHeight-i.clientHeight,v=Math.ceil(i.scrollTop)<f;u(v)};const i=e.viewport;return c(),i.addEventListener("scroll",c),()=>i.removeEventListener("scroll",c)}},[e.viewport,e.isPositioned]),a?r.jsx(Je,{...o,ref:s,onAutoScroll:()=>{const{viewport:c,selectedItem:i}=e;c&&i&&(c.scrollTop=c.scrollTop+i.offsetHeight)}}):null});Ze.displayName=ye;var Je=t.forwardRef((o,n)=>{const{__scopeSelect:e,onAutoScroll:l,...a}=o,u=q("SelectScrollButton",e),s=t.useRef(null),c=de(e),i=t.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return t.useEffect(()=>()=>i(),[i]),z(()=>{c().find(v=>v.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[c]),r.jsx(j.div,{"aria-hidden":!0,...a,ref:n,style:{flexShrink:0,...a.style},onPointerDown:N(a.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(l,50))}),onPointerMove:N(a.onPointerMove,()=>{u.onItemLeave?.(),s.current===null&&(s.current=window.setInterval(l,50))}),onPointerLeave:N(a.onPointerLeave,()=>{i()})})}),qt="SelectSeparator",Qe=t.forwardRef((o,n)=>{const{__scopeSelect:e,...l}=o;return r.jsx(j.div,{"aria-hidden":!0,...l,ref:n})});Qe.displayName=qt;var Ce="SelectArrow",Xt=t.forwardRef((o,n)=>{const{__scopeSelect:e,...l}=o,a=ue(e),u=Y(Ce,e),s=q(Ce,e);return u.open&&s.position==="popper"?r.jsx(Et,{...a,...l,ref:n}):null});Xt.displayName=Ce;var Zt="SelectBubbleInput",et=t.forwardRef(({__scopeSelect:o,value:n,...e},l)=>{const a=t.useRef(null),u=L(l,a),s=vt(n);return t.useEffect(()=>{const c=a.current;if(!c)return;const i=window.HTMLSelectElement.prototype,v=Object.getOwnPropertyDescriptor(i,"value").set;if(s!==n&&v){const w=new Event("change",{bubbles:!0});v.call(c,n),c.dispatchEvent(w)}},[s,n]),r.jsx(j.select,{...e,style:{...xt,...e.style},ref:u,defaultValue:n})});et.displayName=Zt;function tt(o){return o===""||o===void 0}function ot(o){const n=yt(o),e=t.useRef(""),l=t.useRef(0),a=t.useCallback(s=>{const c=e.current+s;n(c),(function i(f){e.current=f,window.clearTimeout(l.current),f!==""&&(l.current=window.setTimeout(()=>i(""),1e3))})(c)},[n]),u=t.useCallback(()=>{e.current="",window.clearTimeout(l.current)},[]);return t.useEffect(()=>()=>window.clearTimeout(l.current),[]),[e,a,u]}function nt(o,n,e){const a=n.length>1&&Array.from(n).every(f=>f===n[0])?n[0]:n,u=e?o.indexOf(e):-1;let s=Jt(o,Math.max(u,0));a.length===1&&(s=s.filter(f=>f!==e));const i=s.find(f=>f.textValue.toLowerCase().startsWith(a.toLowerCase()));return i!==e?i:void 0}function Jt(o,n){return o.map((e,l)=>o[(n+l)%o.length])}var Qt=_e,rt=Me,eo=Oe,to=De,oo=Le,st=ke,no=Ue,at=Ke,lt=ze,ro=Ge,so=qe,ct=Xe,it=Ze,dt=Qe;const ho=Qt,go=eo,ao=t.forwardRef(({className:o,children:n,...e},l)=>r.jsxs(rt,{ref:l,className:G("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",o),...e,children:[n,r.jsx(to,{asChild:!0,children:r.jsx(Ee,{className:"h-4 w-4 opacity-50"})})]}));ao.displayName=rt.displayName;const ut=t.forwardRef(({className:o,...n},e)=>r.jsx(ct,{ref:e,className:G("flex cursor-default items-center justify-center py-1",o),...n,children:r.jsx(jt,{className:"h-4 w-4"})}));ut.displayName=ct.displayName;const pt=t.forwardRef(({className:o,...n},e)=>r.jsx(it,{ref:e,className:G("flex cursor-default items-center justify-center py-1",o),...n,children:r.jsx(Ee,{className:"h-4 w-4"})}));pt.displayName=it.displayName;const lo=t.forwardRef(({className:o,children:n,position:e="popper",...l},a)=>r.jsx(oo,{children:r.jsxs(st,{ref:a,className:G("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",o),position:e,...l,children:[r.jsx(ut,{}),r.jsx(no,{className:G("p-1",e==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:n}),r.jsx(pt,{})]})}));lo.displayName=st.displayName;const co=t.forwardRef(({className:o,...n},e)=>r.jsx(at,{ref:e,className:G("px-2 py-1.5 text-sm font-semibold",o),...n}));co.displayName=at.displayName;const io=t.forwardRef(({className:o,children:n,...e},l)=>r.jsxs(lt,{ref:l,className:G("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",o),...e,children:[r.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:r.jsx(so,{children:r.jsx(_t,{className:"h-4 w-4"})})}),r.jsx(ro,{children:n})]}));io.displayName=lt.displayName;const uo=t.forwardRef(({className:o,...n},e)=>r.jsx(dt,{ref:e,className:G("-mx-1 my-1 h-px bg-muted",o),...n}));uo.displayName=dt.displayName;export{ho as S,ao as a,go as b,lo as c,io as d};
@@ -1 +1 @@
1
- const c=["draft","backlog","ready","queued","active","blocked","review","done","canceled","duplicate"],t=["draft","backlog","ready","queued","active","blocked","review"];function d(e){return{draft:"Draft",backlog:"Backlog",ready:"Ready",queued:"Queued",active:"Active",blocked:"Blocked",review:"Review",done:"Done",canceled:"Canceled",duplicate:"Duplicate"}[e]??e}function r(e){switch(e){case"ready":case"done":return"default";case"review":case"active":case"queued":return"secondary";case"canceled":case"blocked":case"duplicate":return"destructive";default:return"outline"}}export{t as A,c as C,d as a,r as g};
1
+ const c=["draft","backlog","ready","queued","active","blocked","review","done","canceled","duplicate"],t=["draft","backlog","ready","queued","active","blocked","review"];function d(e){return{draft:"Draft",backlog:"Backlog",ready:"Ready",queued:"Queued",active:"Active",blocked:"Blocked",review:"Review",done:"Done",canceled:"Canceled",duplicate:"Duplicate"}[e]??e}function r(e){switch(e){case"ready":case"done":return"default";case"review":case"active":case"queued":return"secondary";case"canceled":case"blocked":case"duplicate":return"destructive";default:return"outline"}}export{t as A,c as T,d as a,r as g};
@@ -1 +1 @@
1
- import{r as c,j as e,e as i}from"./index-hqVgTgRB.js";const d=c.forwardRef(({className:s,onCheckedChange:r,onChange:t,...o},n)=>{const l=a=>{t?.(a),r?.(a.target.checked)};return e.jsxs("label",{className:i("relative inline-flex cursor-pointer",s),children:[e.jsx("input",{type:"checkbox",className:"sr-only peer",onChange:l,ref:n,...o}),e.jsx("div",{className:"block bg-gray-300 w-9 h-5 rounded-full transition-colors duration-200 ease-in-out peer-checked:bg-blue-600"}),e.jsx("div",{className:"absolute left-0 top-0 bg-white w-4 h-4 rounded-full mt-0.5 ml-0.5 transition-transform duration-200 ease-in-out transform peer-checked:translate-x-4 shadow"})]})});d.displayName="Switch";export{d as S};
1
+ import{r as c,j as e,e as i}from"./index-DFcWlnzl.js";const d=c.forwardRef(({className:s,onCheckedChange:r,onChange:t,...o},n)=>{const l=a=>{t?.(a),r?.(a.target.checked)};return e.jsxs("label",{className:i("relative inline-flex cursor-pointer",s),children:[e.jsx("input",{type:"checkbox",className:"sr-only peer",onChange:l,ref:n,...o}),e.jsx("div",{className:"block bg-gray-300 w-9 h-5 rounded-full transition-colors duration-200 ease-in-out peer-checked:bg-blue-600"}),e.jsx("div",{className:"absolute left-0 top-0 bg-white w-4 h-4 rounded-full mt-0.5 ml-0.5 transition-transform duration-200 ease-in-out transform peer-checked:translate-x-4 shadow"})]})});d.displayName="Switch";export{d as S};
@@ -1 +1 @@
1
- import{r as l,at as F,an as $,j as c,ao as D,b8 as V,ar as g,b9 as y,ba as k,bb as G,aq as m,bc as L,e as T}from"./index-hqVgTgRB.js";var p="Tabs",[K,Q]=D(p,[y]),h=y(),[q,x]=K(p),N=l.forwardRef((e,a)=>{const{__scopeTabs:t,value:o,onValueChange:r,defaultValue:d,orientation:n="horizontal",dir:u,activationMode:f="automatic",...v}=e,i=F(u),[s,b]=$({prop:o,onChange:r,defaultProp:d??"",caller:p});return c.jsx(q,{scope:t,baseId:V(),value:s,onValueChange:b,orientation:n,dir:i,activationMode:f,children:c.jsx(g.div,{dir:i,"data-orientation":n,...v,ref:a})})});N.displayName=p;var C="TabsList",I=l.forwardRef((e,a)=>{const{__scopeTabs:t,loop:o=!0,...r}=e,d=x(C,t),n=h(t);return c.jsx(k,{asChild:!0,...n,orientation:d.orientation,dir:d.dir,loop:o,children:c.jsx(g.div,{role:"tablist","aria-orientation":d.orientation,...r,ref:a})})});I.displayName=C;var R="TabsTrigger",j=l.forwardRef((e,a)=>{const{__scopeTabs:t,value:o,disabled:r=!1,...d}=e,n=x(R,t),u=h(t),f=A(n.baseId,o),v=E(n.baseId,o),i=o===n.value;return c.jsx(G,{asChild:!0,...u,focusable:!r,active:i,children:c.jsx(g.button,{type:"button",role:"tab","aria-selected":i,"aria-controls":v,"data-state":i?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:f,...d,ref:a,onMouseDown:m(e.onMouseDown,s=>{!r&&s.button===0&&s.ctrlKey===!1?n.onValueChange(o):s.preventDefault()}),onKeyDown:m(e.onKeyDown,s=>{[" ","Enter"].includes(s.key)&&n.onValueChange(o)}),onFocus:m(e.onFocus,()=>{const s=n.activationMode!=="manual";!i&&!r&&s&&n.onValueChange(o)})})})});j.displayName=R;var w="TabsContent",_=l.forwardRef((e,a)=>{const{__scopeTabs:t,value:o,forceMount:r,children:d,...n}=e,u=x(w,t),f=A(u.baseId,o),v=E(u.baseId,o),i=o===u.value,s=l.useRef(i);return l.useEffect(()=>{const b=requestAnimationFrame(()=>s.current=!1);return()=>cancelAnimationFrame(b)},[]),c.jsx(L,{present:r||i,children:({present:b})=>c.jsx(g.div,{"data-state":i?"active":"inactive","data-orientation":u.orientation,role:"tabpanel","aria-labelledby":f,hidden:!b,id:v,tabIndex:0,...n,ref:a,style:{...e.style,animationDuration:s.current?"0s":void 0},children:b&&d})})});_.displayName=w;function A(e,a){return`${e}-trigger-${a}`}function E(e,a){return`${e}-content-${a}`}var B=N,S=I,M=j,P=_;const U=B,z=l.forwardRef(({className:e,...a},t)=>c.jsx(S,{ref:t,className:T("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...a}));z.displayName=S.displayName;const H=l.forwardRef(({className:e,...a},t)=>c.jsx(M,{ref:t,className:T("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",e),...a}));H.displayName=M.displayName;const O=l.forwardRef(({className:e,...a},t)=>c.jsx(P,{ref:t,className:T("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...a}));O.displayName=P.displayName;export{U as T,z as a,H as b,O as c};
1
+ import{r as l,am as F,ag as k,j as c,ah as $,b5 as D,ak as g,bk as y,bl as V,bm as G,aj as p,bn as L,e as T}from"./index-DFcWlnzl.js";var m="Tabs",[K,Q]=$(m,[y]),h=y(),[B,x]=K(m),N=l.forwardRef((e,a)=>{const{__scopeTabs:t,value:o,onValueChange:r,defaultValue:d,orientation:n="horizontal",dir:u,activationMode:f="automatic",...v}=e,i=F(u),[s,b]=k({prop:o,onChange:r,defaultProp:d??"",caller:m});return c.jsx(B,{scope:t,baseId:D(),value:s,onValueChange:b,orientation:n,dir:i,activationMode:f,children:c.jsx(g.div,{dir:i,"data-orientation":n,...v,ref:a})})});N.displayName=m;var C="TabsList",j=l.forwardRef((e,a)=>{const{__scopeTabs:t,loop:o=!0,...r}=e,d=x(C,t),n=h(t);return c.jsx(V,{asChild:!0,...n,orientation:d.orientation,dir:d.dir,loop:o,children:c.jsx(g.div,{role:"tablist","aria-orientation":d.orientation,...r,ref:a})})});j.displayName=C;var I="TabsTrigger",R=l.forwardRef((e,a)=>{const{__scopeTabs:t,value:o,disabled:r=!1,...d}=e,n=x(I,t),u=h(t),f=A(n.baseId,o),v=E(n.baseId,o),i=o===n.value;return c.jsx(G,{asChild:!0,...u,focusable:!r,active:i,children:c.jsx(g.button,{type:"button",role:"tab","aria-selected":i,"aria-controls":v,"data-state":i?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:f,...d,ref:a,onMouseDown:p(e.onMouseDown,s=>{!r&&s.button===0&&s.ctrlKey===!1?n.onValueChange(o):s.preventDefault()}),onKeyDown:p(e.onKeyDown,s=>{[" ","Enter"].includes(s.key)&&n.onValueChange(o)}),onFocus:p(e.onFocus,()=>{const s=n.activationMode!=="manual";!i&&!r&&s&&n.onValueChange(o)})})})});R.displayName=I;var w="TabsContent",_=l.forwardRef((e,a)=>{const{__scopeTabs:t,value:o,forceMount:r,children:d,...n}=e,u=x(w,t),f=A(u.baseId,o),v=E(u.baseId,o),i=o===u.value,s=l.useRef(i);return l.useEffect(()=>{const b=requestAnimationFrame(()=>s.current=!1);return()=>cancelAnimationFrame(b)},[]),c.jsx(L,{present:r||i,children:({present:b})=>c.jsx(g.div,{"data-state":i?"active":"inactive","data-orientation":u.orientation,role:"tabpanel","aria-labelledby":f,hidden:!b,id:v,tabIndex:0,...n,ref:a,style:{...e.style,animationDuration:s.current?"0s":void 0},children:b&&d})})});_.displayName=w;function A(e,a){return`${e}-trigger-${a}`}function E(e,a){return`${e}-content-${a}`}var q=N,S=j,M=R,P=_;const U=q,z=l.forwardRef(({className:e,...a},t)=>c.jsx(S,{ref:t,className:T("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...a}));z.displayName=S.displayName;const H=l.forwardRef(({className:e,...a},t)=>c.jsx(M,{ref:t,className:T("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",e),...a}));H.displayName=M.displayName;const O=l.forwardRef(({className:e,...a},t)=>c.jsx(P,{ref:t,className:T("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...a}));O.displayName=P.displayName;export{U as T,z as a,H as b,O as c};
@@ -1,4 +1,4 @@
1
- import{c}from"./index-hqVgTgRB.js";/**
1
+ import{c}from"./index-DFcWlnzl.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{r as t,af as j,j as u}from"./index-hqVgTgRB.js";import{x as k,a as B}from"./xterm-DTxiCjtJ.js";function A({sessionId:l,className:p,heightPx:d=160,maxScrollback:m=200}){const h=t.useRef(null),v=t.useRef(null),w=t.useRef(null),y=t.useRef(null),[x,R]=t.useState(!0),o=t.useRef([]),i=t.useRef(null);return t.useEffect(()=>{const a=h.current;if(!a||!l)return;const e=new k.Terminal({disableStdin:!0,cursorBlink:!1,convertEol:!0,scrollback:Math.max(50,Math.min(m,1e3)),fontSize:12,fontFamily:"'IBM Plex Mono', 'Source Code Pro', 'Fira Code', ui-monospace, Menlo, Monaco, monospace",lineHeight:1.25,letterSpacing:.3,theme:{background:"#1a1b26",foreground:"#c0caf5",cursor:"#c0caf5",selectionBackground:"#33467c",black:"#15161e",red:"#f7768e",green:"#9ece6a",yellow:"#e0af68",blue:"#7aa2f7",magenta:"#bb9af7",cyan:"#7dcfff",white:"#a9b1d6",brightBlack:"#414868",brightRed:"#f7768e",brightGreen:"#9ece6a",brightYellow:"#e0af68",brightBlue:"#7aa2f7",brightMagenta:"#bb9af7",brightCyan:"#7dcfff",brightWhite:"#c0caf5"}}),f=new B.FitAddon;e.loadAddon(f),e.open(a),a.style.height=`${d}px`,v.current=e,w.current=f;const s=()=>{try{const n=a.getBoundingClientRect();n.width>8&&n.height>8&&e.element&&f.fit()}catch{}},S=setTimeout(()=>s(),100),g=new ResizeObserver(()=>s());g.observe(a);const b=()=>{document.visibilityState==="visible"&&setTimeout(s,50)};document.addEventListener("visibilitychange",b);const c=new WebSocket(`${j}/ws/terminal-preview/${l}`);y.current=c,c.onopen=()=>R(!1);const E=()=>{i.current=null;const n=o.current;if(n.length){o.current=[];try{e.write(n.join(""))}catch{}}},F=()=>{i.current===null&&(i.current=requestAnimationFrame(E))};return c.onmessage=n=>{let r;try{r=JSON.parse(n.data)}catch{return}if(r?.type==="snapshot"){if(e.reset(),o.current=[],r.data)try{e.write(r.data)}catch{}s()}else r?.type==="data"&&r.data&&(o.current.push(String(r.data)),F())},c.onclose=()=>{},c.onerror=()=>{},()=>{clearTimeout(S),g.disconnect(),document.removeEventListener("visibilitychange",b);try{c.close()}catch{}i.current!==null&&cancelAnimationFrame(i.current),i.current=null,o.current=[],e.dispose()}},[l,d,m]),u.jsxs("div",{className:`relative w-full ${p||""}`.trim(),children:[x&&u.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-50/60 z-10",children:u.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading preview…"})}),u.jsx("div",{ref:h,className:"border border-muted rounded overflow-hidden"})]})}export{A as T};
1
+ import{r as t,a8 as j,j as u}from"./index-DFcWlnzl.js";import{x as k,a as B}from"./xterm-DTxiCjtJ.js";function A({sessionId:l,className:p,heightPx:d=160,maxScrollback:m=200}){const h=t.useRef(null),v=t.useRef(null),w=t.useRef(null),y=t.useRef(null),[x,R]=t.useState(!0),o=t.useRef([]),i=t.useRef(null);return t.useEffect(()=>{const a=h.current;if(!a||!l)return;const e=new k.Terminal({disableStdin:!0,cursorBlink:!1,convertEol:!0,scrollback:Math.max(50,Math.min(m,1e3)),fontSize:12,fontFamily:"'IBM Plex Mono', 'Source Code Pro', 'Fira Code', ui-monospace, Menlo, Monaco, monospace",lineHeight:1.25,letterSpacing:.3,theme:{background:"#1a1b26",foreground:"#c0caf5",cursor:"#c0caf5",selectionBackground:"#33467c",black:"#15161e",red:"#f7768e",green:"#9ece6a",yellow:"#e0af68",blue:"#7aa2f7",magenta:"#bb9af7",cyan:"#7dcfff",white:"#a9b1d6",brightBlack:"#414868",brightRed:"#f7768e",brightGreen:"#9ece6a",brightYellow:"#e0af68",brightBlue:"#7aa2f7",brightMagenta:"#bb9af7",brightCyan:"#7dcfff",brightWhite:"#c0caf5"}}),f=new B.FitAddon;e.loadAddon(f),e.open(a),a.style.height=`${d}px`,v.current=e,w.current=f;const s=()=>{try{const n=a.getBoundingClientRect();n.width>8&&n.height>8&&e.element&&f.fit()}catch{}},S=setTimeout(()=>s(),100),g=new ResizeObserver(()=>s());g.observe(a);const b=()=>{document.visibilityState==="visible"&&setTimeout(s,50)};document.addEventListener("visibilitychange",b);const c=new WebSocket(`${j}/ws/terminal-preview/${l}`);y.current=c,c.onopen=()=>R(!1);const E=()=>{i.current=null;const n=o.current;if(n.length){o.current=[];try{e.write(n.join(""))}catch{}}},F=()=>{i.current===null&&(i.current=requestAnimationFrame(E))};return c.onmessage=n=>{let r;try{r=JSON.parse(n.data)}catch{return}if(r?.type==="snapshot"){if(e.reset(),o.current=[],r.data)try{e.write(r.data)}catch{}s()}else r?.type==="data"&&r.data&&(o.current.push(String(r.data)),F())},c.onclose=()=>{},c.onerror=()=>{},()=>{clearTimeout(S),g.disconnect(),document.removeEventListener("visibilitychange",b);try{c.close()}catch{}i.current!==null&&cancelAnimationFrame(i.current),i.current=null,o.current=[],e.dispose()}},[l,d,m]),u.jsxs("div",{className:`relative w-full ${p||""}`.trim(),children:[x&&u.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-gray-50/60 z-10",children:u.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading preview…"})}),u.jsx("div",{ref:h,className:"border border-muted rounded overflow-hidden"})]})}export{A as T};
@@ -0,0 +1 @@
1
+ import{r as i,ad as v,A as f}from"./index-DFcWlnzl.js";function j(){const[y,p]=i.useState([]),[m,c]=i.useState(!1),[d,o]=i.useState(null),{refresh:w}=v(),S=i.useCallback(async(s,n)=>{try{c(!0),o(null);const e=await fetch(`${f}/api/v1/terminal/${s}/create`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({startupCommand:n})});if(!e.ok){const t=await e.json();throw new Error(t.error||"Failed to create terminal session")}const r=await e.json();return await w(),r.sessionId}catch(e){const r=e instanceof Error?e.message:"Unknown error";return o(r),null}finally{c(!1)}},[w]),g=i.useCallback(async s=>{try{c(!0),o(null);let n;if(s.startsWith("session-")){const r=s.split("-");n=`${r[0]}-${r[1]}`}else{const r=s.split("-");n=`${r[0]}-${r[1]}`}const e=await fetch(`${f}/api/v1/terminal/${n}/destroy`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:s})});if(!e.ok){const r=await e.json();throw new Error(r.error||"Failed to destroy terminal session")}return p(r=>r.filter(t=>t.id!==s)),await w(),!0}catch(n){const e=n instanceof Error?n.message:"Unknown error";return o(e),!1}finally{c(!1)}},[w]),$=i.useCallback(async(s,n,e)=>{try{o(null);let r;if(s.startsWith("session-")){const a=s.split("-");r=`${a[0]}-${a[1]}`}else{const a=s.split("-");r=`${a[0]}-${a[1]}`}const t=await fetch(`${f}/api/v1/terminal/${r}/resize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:s,cols:n,rows:e})});if(!t.ok){const a=await t.json();throw new Error(a.error||"Failed to resize terminal session")}return!0}catch(r){const t=r instanceof Error?r.message:"Unknown error";return o(t),!1}},[]),k=i.useCallback(async(s,n,e)=>{try{c(!0),o(null);const r=new URLSearchParams;s&&r.set("taskId",s),n&&(r.set("withPreview","true"),e&&Number.isFinite(e)&&r.set("lines",String(e)));const t=`${f}/api/v1/terminal/sessions${r.toString()?`?${r.toString()}`:""}`,a=await fetch(t);if(!a.ok){const l=await a.json();throw new Error(l.error||"Failed to fetch terminal sessions")}const u=await a.json();p(u.sessions)}catch(r){const t=r instanceof Error?r.message:"Unknown error";o(t)}finally{c(!1)}},[]),E=i.useCallback(async(s,n=8)=>{try{o(null);const e=new URLSearchParams;e.set("sessionId",s),e.set("withPreview","true"),e.set("lines",String(n)),e.set("colorize","true");const r=`${f}/api/v1/terminal/sessions?${e.toString()}`,t=await fetch(r);if(!t.ok){const l=await t.json().catch(()=>({}));throw new Error(l.error||"Failed to fetch preview")}const a=await t.json(),u=Array.isArray(a?.sessions)&&a.sessions[0]?.preview?a.sessions[0].preview:[];return p(l=>l.map(h=>h.id===s?{...h,preview:u}:h)),u}catch(e){const r=e instanceof Error?e.message:"Unknown error";return o(r),[]}},[]);return{sessions:y,loading:m,error:d,createSession:S,destroySession:g,resizeSession:$,refreshSessions:k,fetchPreview:E}}export{j as u};
@@ -0,0 +1,36 @@
1
+ import{c as e}from"./index-DFcWlnzl.js";/**
2
+ * @license lucide-react v0.542.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const a=[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]],h=e("file-code",a);/**
7
+ * @license lucide-react v0.542.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const c=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],k=e("hard-drive",c);/**
12
+ * @license lucide-react v0.542.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const t=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],s=e("image",t);/**
17
+ * @license lucide-react v0.542.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const y=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],x=e("link-2",y);/**
22
+ * @license lucide-react v0.542.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const o=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],r=e("maximize-2",o);/**
27
+ * @license lucide-react v0.542.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const i=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],m=e("music",i);/**
32
+ * @license lucide-react v0.542.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */const n=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],l=e("video",n);export{h as F,k as H,s as I,x as L,m as M,l as V,r as a};
package/static/index.html CHANGED
@@ -8,8 +8,8 @@
8
8
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
9
9
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap" rel="stylesheet">
10
10
  <title>Coconut - Agentic Development Environment</title>
11
- <script type="module" crossorigin src="/assets/index-hqVgTgRB.js"></script>
12
- <link rel="stylesheet" crossorigin href="/assets/index-DVTgTsDa.css">
11
+ <script type="module" crossorigin src="/assets/index-DFcWlnzl.js"></script>
12
+ <link rel="stylesheet" crossorigin href="/assets/index-CHdBxVyk.css">
13
13
  </head>
14
14
  <body class="font-inter">
15
15
  <div id="root"></div>
@@ -1,2 +0,0 @@
1
- import{E as J,r as t,b5 as y,j as e,B as a,b6 as R,V as X,D as j,b as g,d as v,f,g as A,I as F,a5 as N,am as Y,J as i}from"./index-hqVgTgRB.js";import{C as V,b as W,c as G,d as Q,a as Z}from"./card-BCFxXzRk.js";import{L as w}from"./label-vYhfrPMD.js";import{B as _}from"./badge-DEiQk9C9.js";import{A as I,a as C}from"./alert-BD5jo3SI.js";import{I as L}from"./info-DunFSp-x.js";import{P as ee}from"./plus-iamYJu5V.js";import{C as se}from"./circle-alert-CMRMPnbY.js";function de(){const{authEnabled:n}=J(),[P,k]=t.useState([]),[b,K]=t.useState(!0),[O,l]=t.useState(!1),[M,d]=t.useState(!1),[x,D]=t.useState(""),[h,E]=t.useState("never"),[c,S]=t.useState(null),[m,o]=t.useState(null);t.useEffect(()=>{p()},[]);const p=async()=>{K(!0);try{const s=await y("/api/v1/api-keys");s.success&&k(s.data?.apiKeys||[])}catch(s){console.error("Failed to load API keys:",s),k([])}finally{K(!1)}},U=async()=>{if(!x.trim()){i({title:"Error",description:"Please provide a name for the API key",variant:"destructive"});return}try{const s={name:x,scopes:["*"]};h!=="never"&&(s.expiresIn=h);const r=await y("/api/v1/api-keys",{method:"POST",body:JSON.stringify(s)});r.success&&(S(r.data),l(!1),d(!0),D(""),E("never"),await p(),i({title:"API Key Created",description:"Make sure to copy your API key now. You won't be able to see it again!"}))}catch(s){console.error("Failed to create API key:",s),i({title:"Error",description:"Failed to create API key",variant:"destructive"})}},B=async s=>{try{(await y(`/api/v1/api-keys/${s}`,{method:"DELETE"})).success&&(await p(),o(null),i({title:"API Key Deleted",description:"The API key has been permanently deleted"}))}catch(r){console.error("Failed to delete API key:",r),i({title:"Error",description:"Failed to delete API key",variant:"destructive"})}},H=async s=>{try{await navigator.clipboard.writeText(s),i({title:"Copied",description:"API key copied to clipboard"})}catch{i({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},u=s=>new Date(s).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),$=s=>s?new Date(s)<new Date:!1,q=typeof window<"u"?window.location.origin:"http://localhost:3000",z=c?`curl -H "X-API-Key: ${c.key}" \\
2
- + ${q}/api/v1/proposals`:"",T=n?null:e.jsxs(I,{children:[e.jsx(L,{className:"h-4 w-4"}),e.jsxs(C,{children:["Authentication is currently disabled. API keys will only be required once you enable authentication in the ",e.jsx("a",{href:"/settings/authentication",className:"underline",children:"Authentication settings"}),"."]})]});return!n&&b?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"API Keys"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage API keys for programmatic access"})]}),T]}):b?e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"API Keys"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"API Keys"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage API keys for programmatic access to your Coconut instance"})]}),T,n&&e.jsxs(I,{children:[e.jsx(L,{className:"h-4 w-4"}),e.jsxs(C,{children:["API keys provide programmatic access to your Coconut instance. Use them in CI/CD pipelines or automation scripts by including the key in the ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:"X-API-Key"})," header."]})]}),e.jsxs(V,{children:[e.jsx(W,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(G,{children:"Active API Keys"}),e.jsx(Q,{children:"API keys you've created for programmatic access"})]}),e.jsxs(a,{onClick:()=>l(!0),disabled:!n,children:[e.jsx(ee,{className:"mr-2 h-4 w-4"}),"Create API Key"]})]})}),e.jsx(Z,{children:P.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(R,{className:"h-12 w-12 mx-auto mb-4 opacity-20"}),e.jsx("p",{children:"No API keys yet"}),e.jsx("p",{className:"text-sm",children:"Create an API key to get started with programmatic access"})]}):e.jsx("div",{className:"space-y-4",children:P.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("p",{className:"font-medium",children:s.name}),$(s.expiresAt)&&e.jsx(_,{variant:"destructive",children:"Expired"})]}),e.jsx("p",{className:"text-sm text-muted-foreground font-mono",children:s.keyPreview}),e.jsxs("div",{className:"flex items-center gap-4 mt-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Created: ",u(s.createdAt)]}),s.expiresAt&&e.jsxs("span",{children:["Expires: ",u(s.expiresAt)]}),s.lastUsedAt&&e.jsxs("span",{children:["Last used: ",u(s.lastUsedAt)]})]})]}),e.jsx(a,{variant:"ghost",size:"icon",onClick:()=>o(s.id),children:e.jsx(X,{className:"h-4 w-4 text-destructive"})})]},s.id))})})]}),e.jsx(j,{open:O,onOpenChange:l,children:e.jsxs(g,{children:[e.jsxs(v,{children:[e.jsx(f,{children:"Create API Key"}),e.jsx(A,{children:"Create a new API key for programmatic access. The key will only be shown once."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"keyName",children:"Name"}),e.jsx(F,{id:"keyName",placeholder:"CI/CD Pipeline",value:x,onChange:s=>D(s.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"A descriptive name to identify this API key"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"keyExpiry",children:"Expiration"}),e.jsxs("select",{id:"keyExpiry",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:h,onChange:s=>E(s.target.value),children:[e.jsx("option",{value:"never",children:"Never"}),e.jsx("option",{value:"30d",children:"30 days"}),e.jsx("option",{value:"90d",children:"90 days"}),e.jsx("option",{value:"1y",children:"1 year"})]})]})]}),e.jsxs(N,{children:[e.jsx(a,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(a,{onClick:U,disabled:!n,children:"Create API Key"})]})]})}),e.jsx(j,{open:M,onOpenChange:d,children:e.jsxs(g,{className:"sm:max-w-[600px]",children:[e.jsxs(v,{children:[e.jsx(f,{children:"API Key Created"}),e.jsx(A,{children:"Make sure to copy your API key now. You won't be able to see it again!"})]}),e.jsxs(I,{variant:"destructive",className:"my-4",children:[e.jsx(se,{className:"h-4 w-4"}),e.jsx(C,{children:"This is the only time you will see this key. Store it securely."})]}),c&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{children:"API Key"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(F,{readOnly:!0,value:c.key,className:"font-mono text-sm"}),e.jsx(a,{variant:"outline",size:"icon",onClick:()=>H(c.key),children:e.jsx(Y,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("p",{className:"mb-2",children:"Usage example:"}),e.jsx("pre",{className:"bg-muted p-3 rounded-md whitespace-pre-wrap break-words",children:e.jsx("code",{className:"font-mono text-xs",children:z})})]})]}),e.jsx(N,{children:e.jsx(a,{onClick:()=>{d(!1),S(null)},children:"I've Saved My Key"})})]})}),e.jsx(j,{open:!!m,onOpenChange:s=>!s&&o(null),children:e.jsxs(g,{children:[e.jsxs(v,{children:[e.jsx(f,{children:"Delete API Key"}),e.jsx(A,{children:"Are you sure you want to delete this API key? This action cannot be undone and any scripts using this key will stop working."})]}),e.jsxs(N,{children:[e.jsx(a,{variant:"outline",onClick:()=>o(null),children:"Cancel"}),e.jsx(a,{variant:"destructive",onClick:()=>m&&B(m),children:"Delete API Key"})]})]})})]})}export{de as default};
@@ -1,2 +0,0 @@
1
- import{u as ce,a as de,r as i,j as e,B as l,q as oe,T as me,O as xe,v as M,X as he,F as ue,Q as fe,D as pe,b as je,d as ge,f as ve,h as Ne,i as ye,k as we,l as Se,m as C,p as Ce,a9 as B,aa as R,ab as O,ac as H,ad as L,ai as G,ah as be,w as ke,A as I}from"./index-hqVgTgRB.js";import{C as g,b as Ae,a as _,c as De}from"./card-BCFxXzRk.js";import{B as U}from"./badge-DEiQk9C9.js";import{u as Me}from"./use-terminal-DuGZuvd2.js";import{T as Ie}from"./terminal-preview-DMJMuORo.js";import{b as Te,d as $e,c as Ee,a as Pe}from"./droid-DqWsM2dp.js";import{R as ze}from"./refresh-cw-Bg7vQzOw.js";import{C as Fe,a as Be}from"./chevrons-up-DqbWMOjv.js";import{P as Re}from"./play-CCo7tau2.js";import"./xterm-DTxiCjtJ.js";const Oe=c=>c?Array.isArray(c)?c.filter(x=>typeof x=="string").map(x=>x.trim()).filter(Boolean):typeof c=="string"?c.split(",").map(x=>x.trim()).filter(Boolean):[]:[];function Je(){const c=ce(),{sessions:x,loading:b,error:T,refreshSessions:w,createSession:V,destroySession:q}=Me(),{toast:v}=de(),[$,W]=i.useState([]),[Q,X]=i.useState(!0),[p,k]=i.useState(()=>({})),[A,N]=i.useState(!1),[j,J]=i.useState("claude"),[E,K]=i.useState(""),[D,P]=i.useState(!1),[h,Y]=i.useState([]),[f,y]=i.useState([]),[Z,ee]=i.useState({}),[u,se]=i.useState([]),[o,S]=i.useState([]),te=s=>{const t=Date.now(),a=new Date(s).getTime(),n=Math.max(0,Math.floor((t-a)/1e3));if(n<60)return`${n}s ago`;const d=Math.floor(n/60);if(d<60)return`${d}m ago`;const r=Math.floor(d/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`};i.useEffect(()=>{(async()=>{try{const t=await fetch(`${I}/api/v1/proposals`);if(t.ok){const a=await t.json(),n=a.data||a;W(Array.isArray(n)?n:[])}}catch(t){console.error("Error loading proposals:",t)}finally{X(!1)}})()},[]),i.useEffect(()=>{w()},[w]),i.useEffect(()=>{if(!A)return;(async()=>{try{const t=await fetch(`${I}/api/v1/mcp`);if(t.ok){const a=await t.json();a?.success&&Array.isArray(a.servers)&&(Y(a.servers),y(n=>n.filter(d=>a.servers.includes(d))),a.mcpServers&&typeof a.mcpServers=="object"&&ee(a.mcpServers))}}catch(t){console.error("Failed to load MCP servers",t)}try{const t=await fetch(`${I}/api/v1/skills`);if(t.ok){const a=await t.json(),d=(Array.isArray(a?.documents)?a.documents:[]).map(r=>({id:r.id,name:r?.metadata?.name||r.id,mcpServers:Oe(r?.metadata?.metadata?.mcpServers)}));se(d),S(r=>r.filter(F=>d.some(re=>re.id===F)))}}catch(t){console.error("Failed to load skills",t)}})()},[A]),i.useEffect(()=>{o.length!==0&&y(s=>{const t=new Set(s),a=h.length>0?new Set(h):void 0;return o.forEach(n=>{const d=u.find(r=>r.id===n);d&&d.mcpServers.forEach(r=>{(!a||a.has(r))&&t.add(r)})}),Array.from(t)})},[o,u,h]);const m=i.useMemo(()=>x.filter(s=>s.proposalId?.startsWith("cp-")||s.proposalId?.startsWith("ag-")).sort((s,t)=>new Date(t.lastActivity).getTime()-new Date(s.lastActivity).getTime()),[x]);i.useEffect(()=>{k(s=>{const t={...s};return m.forEach(a=>{a.id in t||(t[a.id]=!0)}),t})},[m]);const z=i.useMemo(()=>$.filter(s=>s.status==="draft"||s.status==="ready").sort((s,t)=>new Date(t.metadata.createdAt).getTime()-new Date(s.metadata.createdAt).getTime()).slice(0,3),[$]),ae=()=>{const s=m.every(a=>p[a.id]),t={};m.forEach(a=>{t[a.id]=!s}),k(t)},ie=m.length>0&&m.every(s=>p[s.id]),ne=async s=>{await q(s)?(v({title:"Session closed",description:s}),setTimeout(()=>w(),100)):v({title:"Failed to close session",description:s,variant:"destructive"})},le=async()=>{P(!0);try{const s=`cp-${Date.now()}`,t={proposalId:s,contextType:"change-proposal",cliAgent:j,mcpServersMap:Z,selectedMcpServers:f,skills:u,selectedSkillIds:o,automationEnabled:!1,customInstruction:E.trim(),includeDefaultInstructions:!1};let a="";j==="claude"?a=Te(t):j==="gemini"?a=$e(t):j==="codex"?a=Ee(t):j==="droid"&&(a=Pe(t)),await V(s,!1,a)?(v({title:"Coding session started",description:`Session ${s} created`}),N(!1),c(`/terminal/${s}`)):v({title:"Failed to start session",description:"Could not create terminal session",variant:"destructive"})}catch(s){console.error("Error starting coding session:",s),v({title:"Error",description:"Failed to start coding session",variant:"destructive"})}finally{P(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Code"}),e.jsx("p",{className:"text-muted-foreground hidden sm:block",children:"Terminal sessions and coding agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(l,{variant:"outline",size:"sm",onClick:()=>w(),disabled:b,children:[e.jsx(ze,{className:`h-4 w-4 sm:mr-2 ${b?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]}),m.length>0&&e.jsx(l,{variant:"outline",size:"sm",onClick:ae,children:ie?e.jsxs(e.Fragment,{children:[e.jsx(Fe,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Hide All"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Be,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Show All"})]})}),e.jsxs(l,{size:"sm",onClick:()=>N(!0),children:[e.jsx(Re,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Interactive Session"})]})]})]}),T&&e.jsx("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsx("div",{className:"text-red-600",children:T})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sessions"}),b?e.jsx("div",{className:"space-y-2",children:[...Array(2)].map((s,t)=>e.jsx(g,{className:"p-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-4 w-4 rounded bg-muted animate-pulse"}),e.jsxs("div",{children:[e.jsx("div",{className:"h-4 w-40 bg-muted rounded animate-pulse mb-2"}),e.jsx("div",{className:"h-3 w-24 bg-muted rounded animate-pulse"})]})]}),e.jsx("div",{className:"h-6 w-20 bg-muted rounded animate-pulse"})]})},t))}):m.length===0?e.jsx(g,{className:"p-8",children:e.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-3",children:[e.jsx(oe,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No active sessions"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Get started by launching an"," ",e.jsx("button",{onClick:()=>N(!0),className:"text-primary hover:underline font-medium",children:"Interactive Session"})," ","or working on a"," ",e.jsx("button",{onClick:()=>c("/proposals"),className:"text-primary hover:underline font-medium",children:"Change Proposal"})]})]})]})}):e.jsx("div",{className:"space-y-2",children:m.slice(0,10).map(s=>e.jsxs(g,{className:"p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(me,{className:"h-4 w-4 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-sm",children:s.proposalId}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Session ",s.id.split("-").slice(-1)[0].substring(0,8)," • Last activity ",te(s.lastActivity)]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("div",{className:`flex items-center gap-1 ${s.connected?"text-green-600":"text-gray-400"}`,title:s.connected?"Connected":"Disconnected",children:e.jsx("div",{className:`w-2 h-2 rounded-full ${s.connected?"bg-green-500":"bg-gray-400"}`})}),e.jsx(l,{size:"sm",variant:"outline",onClick:()=>{k(t=>({...t,[s.id]:!t[s.id]}))},"aria-label":p[s.id]?"Hide preview":"Show preview",title:p[s.id]?"Hide preview":"Show preview",children:p[s.id]?e.jsx(xe,{className:"h-4 w-4"}):e.jsx(M,{className:"h-4 w-4"})}),e.jsx(l,{size:"sm",variant:"outline",onClick:()=>c(`/terminal/${s.proposalId}`),children:"Open"}),e.jsx(l,{size:"icon",variant:"destructive",onClick:()=>ne(s.id),title:"Close session","aria-label":"Close session",children:e.jsx(he,{className:"h-4 w-4"})})]})]}),p[s.id]&&e.jsx("div",{className:"mt-2 w-full p-2 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>c(`/terminal/${s.proposalId}`),title:"Click to open full terminal session",children:e.jsx(Ie,{sessionId:s.id,heightPx:160,maxScrollback:200})})]},s.id))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"New Tasks"}),Q?e.jsx("div",{className:"space-y-3",children:[...Array(3)].map((s,t)=>e.jsx(g,{children:e.jsx(Ae,{className:"py-3",children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-4 bg-muted rounded w-2/3 animate-pulse"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/3 animate-pulse"})]}),e.jsx("div",{className:"h-5 bg-muted rounded w-16 animate-pulse"})]})})},t))}):z.length===0?e.jsx(g,{children:e.jsx(_,{className:"flex items-center justify-center py-6",children:e.jsx("div",{className:"text-center text-sm text-gray-500",children:"No draft or approved proposals found"})})}):e.jsx("div",{className:"space-y-2",children:z.map(s=>e.jsx(g,{className:"hover:shadow-md transition-all cursor-pointer hover:border-primary/50",onClick:()=>c(`/terminal/${s.id}`),children:e.jsx(_,{className:"py-4",children:e.jsx("div",{className:"flex justify-between items-start gap-4",children:e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(De,{className:"text-base leading-tight",children:s.title||s.intent}),e.jsxs("div",{className:"flex gap-1 ml-3 flex-shrink-0",children:[s.priority&&e.jsx(U,{variant:s.priority==="high"||s.priority==="critical"?"destructive":s.priority==="medium"?"secondary":"outline",className:"text-xs",children:s.priority}),e.jsx(U,{variant:"default",className:"text-xs",children:s.status})]})]}),s.content&&e.jsxs("div",{className:"text-sm text-muted-foreground leading-relaxed",children:[s.content.split(`
2
- `).slice(0,2).join(" ").substring(0,150),s.content.length>150?"...":""]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"text-xs text-muted-foreground",children:[s.id," • by ",s.author.name," • ",new Date(s.metadata.createdAt).toLocaleDateString()]}),e.jsxs("div",{className:"flex gap-2",onClick:t=>t.stopPropagation(),children:[e.jsxs(l,{variant:"ghost",size:"sm",onClick:()=>c(`/proposals/${s.id}`),className:"h-7 px-2 text-xs",children:[e.jsx(ue,{className:"h-3 w-3 mr-1"})," View"]}),e.jsxs(l,{variant:"ghost",size:"sm",onClick:()=>c(`/proposals/${s.id}/edit`),className:"h-7 px-2 text-xs",children:[e.jsx(fe,{className:"h-3 w-3 mr-1"})," Edit"]})]})]})]})})})},s.id))})]}),e.jsx(pe,{open:A,onOpenChange:N,children:e.jsxs(je,{className:"max-w-lg",children:[e.jsxs(ge,{children:[e.jsx(ve,{children:"Start Coding Agent"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Start an interactive coding session"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Coding Agent"}),e.jsxs(Ne,{value:j,onValueChange:s=>J(s),children:[e.jsx(ye,{className:"w-full",children:e.jsx(we,{placeholder:"Select coding agent"})}),e.jsxs(Se,{children:[e.jsx(C,{value:"claude",children:"Claude Code"}),e.jsx(C,{value:"gemini",children:"Google Gemini"}),e.jsx(C,{value:"codex",children:"OpenAI Codex"}),e.jsx(C,{value:"droid",children:"Factory Droid"})]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(Ce,{className:"h-4 w-4"}),"Skills"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[o.length," of ",u.length," selected"]})]}),e.jsxs(B,{children:[e.jsx(R,{asChild:!0,children:e.jsxs(l,{variant:"outline",className:"w-full justify-between",children:[o.length===0?"Select skills...":o.length===u.length?"All skills selected":`${o.length} skill${o.length!==1?"s":""} selected`,e.jsx(M,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(O,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsxs(H,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Available Skills"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(l,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),S(u.map(t=>t.id))},children:"All"}),e.jsx(l,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),S([])},children:"None"})]})]}),e.jsx(L,{}),u.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-gray-500",children:"No skills found"}):u.map(s=>e.jsx(G,{checked:o.includes(s.id),onCheckedChange:t=>{S(a=>t?a.includes(s.id)?a:[...a,s.id]:a.filter(n=>n!==s.id))},children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:s.name}),s.mcpServers.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["MCP servers: ",s.mcpServers.join(", ")]}),s.mcpServers.length===0&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Inherits available MCP servers"})]})},s.id))]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(be,{className:"h-4 w-4"}),"MCP Servers"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[f.length," of ",h.length," selected"]})]}),e.jsxs(B,{children:[e.jsx(R,{asChild:!0,children:e.jsxs(l,{variant:"outline",className:"w-full justify-between",children:[f.length===0?"Select MCP servers...":f.length===h.length?"All servers selected":`${f.length} server${f.length!==1?"s":""} selected`,e.jsx(M,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(O,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsxs(H,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Available Servers"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(l,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),y(h)},children:"All"}),e.jsx(l,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),y([])},children:"None"})]})]}),e.jsx(L,{}),h.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-gray-500",children:"No MCP servers found"}):h.map(s=>e.jsx(G,{checked:f.includes(s),onCheckedChange:t=>{y(a=>t?a.includes(s)?a:[...a,s]:a.filter(n=>n!==s))},children:s},s))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Additional Instructions (optional)"}),e.jsx(ke,{value:E,onChange:s=>K(s.target.value),placeholder:"Add any custom instructions for the coding agent...",rows:4,className:"resize-none"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(l,{variant:"outline",onClick:()=>N(!1),disabled:D,children:"Cancel"}),e.jsx(l,{onClick:le,disabled:D,children:D?"Starting...":"Start Session"})]})]})]})})]})}export{Je as default};
@@ -1,41 +0,0 @@
1
- import{c as b,u as Pe,a as Re,r as l,j as e,D as Le,b as De,d as te,e as f,f as ae,g as ne,S as re,B as d,C as le,I as E,h as oe,i as ce,k as ie,l as de,m as V,n as G,o as Ie,G as _e,F as ze,p as ue,q as We,s as qe,t as W,T as me,v as Fe,w as Be,L as v,M as Ee,K as A,x as g,y as Ve,A as Ke}from"./index-hqVgTgRB.js";import{C as h,a as u,b as P,c as R,d as xe}from"./card-BCFxXzRk.js";import{B as $e}from"./badge-DEiQk9C9.js";import{g as Ge}from"./status-utils-BDOyevaX.js";import{L as He}from"./label-vYhfrPMD.js";import{u as Oe}from"./use-terminal-DuGZuvd2.js";import{T as Ye}from"./terminal-preview-DMJMuORo.js";import{C as Qe}from"./circle-check-D5wZZPvj.js";import{C as Ue}from"./chevron-left-C25izNzZ.js";import{S as Ze}from"./search-CH2zaibZ.js";import{Z as Je}from"./zap-BlzMp7dY.js";import{C as Xe}from"./calendar-Cx5r9R7A.js";import{F as es}from"./folder-git-2-BE9AIPnj.js";import{E as ss}from"./external-link-CYBz87-P.js";import{P as ts}from"./play-CCo7tau2.js";import{C as as}from"./clock-CeCp7Pz1.js";import{C as ns}from"./circle-check-big-NI18oHuP.js";import{P as rs}from"./plus-iamYJu5V.js";import"./xterm-DTxiCjtJ.js";/**
2
- * @license lucide-react v0.542.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const ls=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],os=b("chart-line",ls);/**
7
- * @license lucide-react v0.542.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const cs=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],is=b("database",cs);/**
12
- * @license lucide-react v0.542.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const ds=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 18v-2",key:"qcmpov"}],["path",{d:"M12 18v-4",key:"q1q25u"}],["path",{d:"M16 18v-6",key:"15y0np"}]],ms=b("file-chart-column-increasing",ds);/**
17
- * @license lucide-react v0.542.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const xs=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],hs=b("globe",xs);/**
22
- * @license lucide-react v0.542.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const us=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],ps=b("palette",us);/**
27
- * @license lucide-react v0.542.0 - ISC
28
- *
29
- * This source code is licensed under the ISC license.
30
- * See the LICENSE file in the root directory of this source tree.
31
- */const fs=[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]],js=b("rocket",fs);/**
32
- * @license lucide-react v0.542.0 - ISC
33
- *
34
- * This source code is licensed under the ISC license.
35
- * See the LICENSE file in the root directory of this source tree.
36
- */const gs=[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]],ys=b("test-tube",gs);/**
37
- * @license lucide-react v0.542.0 - ISC
38
- *
39
- * This source code is licensed under the ISC license.
40
- * See the LICENSE file in the root directory of this source tree.
41
- */const vs=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],Ns=b("wand-sparkles",vs),bs={Rocket:js,FolderGit2:es,FileBarChart:ms,FilePlus2:W,Calendar:Xe,Sparkles:G,Settings:qe,Zap:Je,Code:We,Bot:ue,FileText:ze,GitBranch:_e,ChartLine:os,Shield:Ie,Database:is,TestTube:ys,Palette:ps,Globe:hs},ws={blue:{bg:"bg-gradient-to-br from-blue-500/30 to-blue-600/15",icon:"text-blue-400",border:"border-blue-500/40 hover:border-blue-500/60"},purple:{bg:"bg-gradient-to-br from-purple-500/30 to-purple-600/15",icon:"text-purple-400",border:"border-purple-500/40 hover:border-purple-500/60"},green:{bg:"bg-gradient-to-br from-emerald-500/30 to-emerald-600/15",icon:"text-emerald-400",border:"border-emerald-500/40 hover:border-emerald-500/60"},orange:{bg:"bg-gradient-to-br from-orange-500/30 to-orange-600/15",icon:"text-orange-400",border:"border-orange-500/40 hover:border-orange-500/60"},pink:{bg:"bg-gradient-to-br from-pink-500/30 to-pink-600/15",icon:"text-pink-400",border:"border-pink-500/40 hover:border-pink-500/60"}},he={setup:"Setup",analysis:"Analysis",automation:"Automation",coding:"Coding"};function K(c){return bs[c]||G}function $(c){return ws[c||"blue"]}function ks(c,N){let m=c.replace(/\{\{#if (\w+)\}\}(.*?)\{\{\/if\}\}/g,(S,j,M)=>N[j]?.trim()?M.replace(/\{\{(\w+)\}\}/g,(w,t)=>N[t]||""):"");return m=m.replace(/\{\{(\w+)\}\}/g,(S,j)=>N[j]||""),m}function Cs({open:c,onOpenChange:N,workflows:m}){const S=Pe(),{loading:j,createSession:M,destroySession:L}=Oe(),{toast:w}=Re(),[t,n]=l.useState(null),[x,y]=l.useState(0),[i,D]=l.useState(""),[r,k]=l.useState("all"),[p,T]=l.useState({}),[H,O]=l.useState(!1),[I,Y]=l.useState(null),[pe,Q]=l.useState(null),[q,fe]=l.useState(!1),U=l.useMemo(()=>{const s=new Set(m.map(a=>a.category));return Array.from(s)},[m]),C=l.useMemo(()=>m.filter(s=>{const a=i===""||s.title.toLowerCase().includes(i.toLowerCase())||s.description.toLowerCase().includes(i.toLowerCase()),o=r==="all"||s.category===r;return a&&o}),[m,i,r]),Z=l.useMemo(()=>i||r!=="all"?[]:m.filter(s=>s.featured),[m,i,r]),J=l.useMemo(()=>i||r!=="all"?C:C.filter(s=>!s.featured),[C,i,r]),X=s=>{n(s),y(0);const a={};s.params?.forEach(o=>{o.defaultValue&&(a[o.id]=o.defaultValue)}),T(a)},je=()=>{x>0?y(x-1):(n(null),T({}))},ge=()=>{t&&x<t.steps.length-1&&y(x+1)},_=()=>{n(null),y(0),D(""),k("all"),T({}),Y(null),Q(null),N(!1)},z=(s,a)=>{T(o=>({...o,[s]:a}))},F=l.useMemo(()=>t?.params?t.params.filter(s=>s.required).every(s=>p[s.id]?.trim()):!0,[t,p]),B=l.useMemo(()=>t?.command?ks(t.command,p):"",[t,p]),ye=async()=>{if(!B)return;const s=`wizard-${Date.now()}`;O(!0);try{const a=await M(s,!1,B);a?(w({title:"Session started",description:s}),Y(a),Q(s)):w({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{O(!1)}},ve=s=>{const a=K(s.icon),o=$(s.color);return e.jsx(h,{className:f("cursor-pointer transition-all duration-200 hover:scale-[1.02]",o.bg,o.border),onClick:()=>X(s),children:e.jsxs(u,{className:"p-4 flex flex-col items-center text-center h-full",children:[e.jsx("div",{className:f("w-12 h-12 rounded-xl flex items-center justify-center mb-3","bg-background/50 backdrop-blur-sm"),children:e.jsx(a,{className:f("h-6 w-6",o.icon)})}),e.jsx("h3",{className:"text-sm font-semibold line-clamp-2",children:s.title})]})},s.id)},Ne=s=>{const a=K(s.icon),o=$(s.color);return e.jsx(h,{className:"cursor-pointer hover:bg-accent hover:border-accent-foreground/20 transition-colors",onClick:()=>X(s),children:e.jsx(u,{className:"p-4",children:e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("div",{className:f("flex-shrink-0 w-10 h-10 rounded-lg flex items-center justify-center",o.bg),children:e.jsx(a,{className:f("h-5 w-5",o.icon)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-sm font-semibold truncate",children:s.title}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.description})]}),e.jsx(le,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"})]})})},s.id)},be=()=>e.jsxs("div",{className:"flex h-[600px]",children:[e.jsxs("div",{className:"w-56 border-r pr-4 flex flex-col space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(Ze,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(E,{placeholder:"Search workflows...",value:i,onChange:s=>D(s.target.value),className:"pl-9"})]}),e.jsxs(oe,{value:r,onValueChange:k,children:[e.jsx(ce,{children:e.jsx(ie,{placeholder:"All categories"})}),e.jsxs(de,{children:[e.jsx(V,{value:"all",children:"All categories"}),U.map(s=>e.jsx(V,{value:s,children:he[s]||s},s))]})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground mb-2 px-1",children:"Categories"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("button",{onClick:()=>k("all"),className:f("w-full text-left px-3 py-2 text-sm rounded-md transition-colors",r==="all"?"bg-accent text-accent-foreground":"hover:bg-accent/50"),children:"All Workflows"}),U.map(s=>e.jsx("button",{onClick:()=>k(s),className:f("w-full text-left px-3 py-2 text-sm rounded-md transition-colors",r===s?"bg-accent text-accent-foreground":"hover:bg-accent/50"),children:he[s]||s},s))]})]})]}),e.jsxs("div",{className:"flex-1 pl-4",children:[e.jsxs(te,{className:"mb-4",children:[e.jsx(ae,{className:"text-2xl",children:"Getting Started"}),e.jsx(ne,{children:"Choose a workflow to get started with Coconut. We'll guide you through each step."})]}),e.jsx(re,{className:"h-[500px] pr-4",children:e.jsxs("div",{className:"space-y-6",children:[Z.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-semibold text-muted-foreground mb-3 flex items-center",children:[e.jsx(G,{className:"h-4 w-4 mr-2"}),"Featured"]}),e.jsx("div",{className:"grid grid-cols-3 gap-3 p-1",children:Z.map(ve)})]}),(J.length>0||i||r!=="all")&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-muted-foreground mb-3",children:i||r!=="all"?`Results (${C.length})`:"All Workflows"}),e.jsx("div",{className:"space-y-2",children:C.length>0?(i||r!=="all"?C:J).map(Ne):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:e.jsx("p",{children:"No workflows found matching your search."})})})]})]})})]})]}),we=s=>e.jsx("div",{className:"space-y-4",children:s.content&&e.jsxs("div",{className:"space-y-4",children:[s.content.text&&e.jsx(h,{children:e.jsx(u,{className:"p-4",children:e.jsx("p",{className:"text-sm leading-relaxed",children:s.content.text})})}),s.content.image&&e.jsx(h,{children:e.jsx(u,{className:"p-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("img",{src:s.content.image.src,alt:s.content.image.alt,className:"w-full rounded-md border"}),s.content.image.caption&&e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:s.content.image.caption})]})})}),s.content.video&&e.jsx(h,{children:e.jsx(u,{className:"p-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"relative rounded-md overflow-hidden border bg-muted",children:e.jsx("video",{src:s.content.video.src,poster:s.content.video.poster,controls:!0,className:"w-full",children:"Your browser does not support the video tag."})}),s.content.video.caption&&e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:s.content.video.caption})]})})})]})}),ke=()=>t?.params?e.jsx("div",{className:"space-y-4",children:t.params.map(s=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs(He,{htmlFor:s.id,children:[s.label,s.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),s.type==="text"&&e.jsx(E,{id:s.id,placeholder:s.placeholder,value:p[s.id]||"",onChange:a=>z(s.id,a.target.value)}),s.type==="textarea"&&e.jsx(Be,{id:s.id,placeholder:s.placeholder,value:p[s.id]||"",onChange:a=>z(s.id,a.target.value),rows:4}),s.type==="number"&&e.jsx(E,{id:s.id,type:"number",placeholder:s.placeholder,value:p[s.id]||"",onChange:a=>z(s.id,a.target.value)}),s.type==="select"&&s.options&&e.jsxs(oe,{value:p[s.id]||"",onValueChange:a=>z(s.id,a),children:[e.jsx(ce,{children:e.jsx(ie,{placeholder:s.placeholder||"Select..."})}),e.jsx(de,{children:s.options.map(a=>e.jsx(V,{value:a.value,children:a.label},a.value))})]})]},s.id))}):null,Ce=()=>t?.command?I?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(me,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("h4",{className:"text-sm font-semibold",children:"Terminal Output"})]}),e.jsx(Ye,{sessionId:I,heightPx:220,maxScrollback:500})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(d,{onClick:()=>{_(),S(`/terminal/${pe}`)},variant:"secondary",className:"flex-1",children:[e.jsx(ss,{className:"h-4 w-4 mr-2"}),"Open in Terminal"]}),e.jsx(d,{onClick:async()=>{I&&await L(I),_()},className:"flex-1 bg-green-600 hover:bg-green-700",children:"Done"})]})]}):e.jsxs("div",{className:"space-y-6",children:[t.params&&t.params.length>0&&e.jsx(h,{children:e.jsxs(u,{className:"p-4",children:[e.jsx("h4",{className:"text-sm font-semibold mb-3",children:"Configuration"}),e.jsx("div",{className:"space-y-2",children:t.params.map(s=>e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:[s.label,":"]}),e.jsx("span",{className:"font-medium truncate ml-2 max-w-[200px]",children:p[s.id]||e.jsx("span",{className:"text-muted-foreground italic",children:"Not set"})})]},s.id))})]})}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs(d,{onClick:ye,disabled:j||H||!F,className:"flex-1",children:[e.jsx(ts,{className:"h-4 w-4 mr-2"}),H?"Starting...":"Run"]})}),!F&&e.jsx("p",{className:"text-sm text-destructive text-center",children:"Please fill in all required fields before running."}),e.jsx(h,{children:e.jsxs(u,{className:"p-4",children:[e.jsxs("button",{type:"button",onClick:()=>fe(!q),className:"flex items-center justify-between w-full text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(me,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("h4",{className:"text-sm font-semibold",children:"Command"})]}),e.jsx(Fe,{className:f("h-4 w-4 text-muted-foreground transition-transform",q&&"rotate-180")})]}),q&&e.jsx("div",{className:"bg-muted rounded-md p-3 overflow-x-auto mt-3",children:e.jsx("code",{className:"text-xs font-mono whitespace-pre-wrap break-all",children:B})})]})})]}):null,Se=()=>{if(!t)return null;const s=t.steps[x],a=s.type||"info",o=x===t.steps.length-1,Me=K(t.icon),ee=$(t.color),Te=()=>{switch(a){case"params":return ke();case"confirm":return Ce();case"info":default:return we(s)}},Ae=o&&!t.command&&a==="info";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(te,{children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.jsx("div",{className:f("flex-shrink-0 w-10 h-10 rounded-lg flex items-center justify-center",ee.bg),children:e.jsx(Me,{className:f("h-5 w-5",ee.icon)})}),e.jsxs("div",{className:"flex-1",children:[e.jsx(ae,{className:"text-xl",children:t.title}),e.jsxs(ne,{children:["Step ",x+1," of ",t.steps.length]})]})]}),e.jsx("div",{className:"flex items-center space-x-2 pt-2",children:t.steps.map((As,se)=>e.jsx("div",{className:f("h-1.5 flex-1 rounded-full transition-colors",se<=x?"bg-primary":"bg-muted")},se))})]}),e.jsx(re,{className:"h-[450px] pr-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-2",children:s.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s.description})]}),Te(),Ae&&e.jsx(h,{className:"bg-primary/5 border-primary/20",children:e.jsxs(u,{className:"p-4 flex items-center space-x-3",children:[e.jsx(Qe,{className:"h-5 w-5 text-primary flex-shrink-0"}),e.jsx("p",{className:"text-sm font-medium",children:`You've completed this workflow! Click "Finish" to close this wizard.`})]})})]})}),e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsx(d,{variant:"ghost",onClick:_,children:"Cancel"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(d,{variant:"outline",onClick:je,children:[e.jsx(Ue,{className:"mr-2 h-4 w-4"}),x===0?"Back to Workflows":"Previous"]}),a!=="confirm"&&(o?e.jsx(d,{onClick:_,children:"Finish"}):e.jsxs(d,{onClick:ge,disabled:a==="params"&&!F,children:["Next",e.jsx(le,{className:"ml-2 h-4 w-4"})]}))]})]})]})};return e.jsx(Le,{open:c,onOpenChange:N,children:e.jsx(De,{className:"max-w-4xl max-h-[90vh]",children:t?Se():be()})})}const Ss=[{id:"new-project",title:"Start Building a New Website",description:"Scaffold a ready-to-go Vite + React + TypeScript project with Tailwind CSS",icon:"Rocket",category:"setup",featured:!0,color:"blue",command:"npx -y http://registry.coconut.dev/utils/coconut-vite-starter-1.0.0.tgz",steps:[{type:"info",title:"Start Building a New Website",description:"Get up and running with a modern web stack in seconds",content:{text:"This wizard scaffolds a ready-to-go Vite + React + TypeScript project with Tailwind CSS and React Router. Perfect for quick experiments, agent-driven prototypes, or Coconut sandboxes. You'll have a fully configured development environment with hot reloading, routing, and styling out of the box."}},{type:"confirm",title:"Create Your Project",description:"Run the scaffolding command to set up your new website"}]},{id:"company-sentiment-analysis",title:"Daily Company Sentiment Analysis",description:"Monitor a company's online presence with automated daily sentiment analysis",icon:"ChartLine",category:"automation",featured:!0,color:"orange",command:'npx -y http://registry.coconut.dev/utils/coconut-research-sentiment-analysis-1.0.2.tgz --company "{{company}}" --url "{{url}}"{{#if socialPlatforms}} --social-platforms "{{socialPlatforms}}"{{/if}}{{#if keywords}} --keywords "{{keywords}}"{{/if}}',params:[{id:"company",label:"Company Name",type:"text",placeholder:"e.g., Acme Corp",required:!0},{id:"url",label:"Company Website URL",type:"text",placeholder:"e.g., https://acme.com",required:!0},{id:"socialPlatforms",label:"Social Platforms (optional)",type:"text",placeholder:"e.g., twitter,linkedin,reddit",required:!1},{id:"keywords",label:"Keywords to Track (optional)",type:"text",placeholder:"e.g., product launch,customer feedback",required:!1}],steps:[{type:"info",title:"Daily Company Sentiment Analysis",description:"Learn how automated sentiment monitoring works",content:{text:"This wizard creates a scheduled job that monitors a company's online presence daily (Monday–Friday). It uses web scraping to gather sentiment data and generates comprehensive reports including overall sentiment score, key themes, notable mentions, and trend analysis over time."}},{type:"params",title:"Configure Analysis",description:"Enter the company details and optional filters"},{type:"confirm",title:"Review and Create Job",description:"Confirm your settings and create the sentiment analysis job"}]}],Ms={workflows:Ss},Ts=Ms.workflows;function Qs(){const[c,N]=l.useState({total:0,inReview:0,approved:0}),[m,S]=l.useState([]),[j,M]=l.useState(!0),[L,w]=l.useState(!1);return l.useEffect(()=>{const t=n=>{(n.metaKey||n.ctrlKey)&&n.key==="k"&&(n.preventDefault(),w(!0)),(n.metaKey||n.ctrlKey)&&n.key==="i"&&(n.preventDefault(),window.location.href="/proposals/new"),(n.metaKey||n.ctrlKey)&&n.key==="u"&&(n.preventDefault(),window.location.href="/context/knowledge"),(n.metaKey||n.ctrlKey)&&n.key==="e"&&(n.preventDefault(),window.location.href="/code")};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[]),l.useEffect(()=>{(async()=>{try{const x=await(await fetch(`${Ke}/api/v1/proposals`)).json();if(x.success&&x.data){const y=x.data,i={total:y.length,inReview:y.filter(r=>r.status==="review").length,approved:y.filter(r=>r.status==="ready"||r.status==="done").length},D=y.sort((r,k)=>{const p=new Date(r.metadata?.updatedAt||r.metadata?.createdAt||0);return new Date(k.metadata?.updatedAt||k.metadata?.createdAt||0).getTime()-p.getTime()}).slice(0,5);N(i),S(D)}}catch(n){console.error("Failed to fetch task stats:",n)}finally{M(!1)}})()},[]),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Home"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage change tasks, brainstorm, and take quick actions."})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(v,{to:"/proposals",children:e.jsxs(h,{className:"hover:bg-accent hover:border-accent-foreground/20 transition-colors cursor-pointer",children:[e.jsxs(P,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(R,{className:"text-sm font-medium",children:"All Tasks"}),e.jsx(W,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(u,{children:[e.jsx("div",{className:"text-2xl font-bold",children:j?"...":c.total}),e.jsx("p",{className:"text-xs text-muted-foreground",children:c.total===0?"No tasks yet":`${c.total} task${c.total!==1?"s":""}`})]})]})}),e.jsx(v,{to:"/proposals?status=review",children:e.jsxs(h,{className:"hover:bg-accent hover:border-accent-foreground/20 transition-colors cursor-pointer",children:[e.jsxs(P,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(R,{className:"text-sm font-medium",children:"In Review"}),e.jsx(as,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(u,{children:[e.jsx("div",{className:"text-2xl font-bold",children:j?"...":c.inReview}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Awaiting approval"})]})]})}),e.jsx(v,{to:"/proposals?status=ready",children:e.jsxs(h,{className:"hover:bg-accent hover:border-accent-foreground/20 transition-colors cursor-pointer",children:[e.jsxs(P,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(R,{className:"text-sm font-medium",children:"Ready / Done"}),e.jsx(ns,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(u,{children:[e.jsx("div",{className:"text-2xl font-bold",children:j?"...":c.approved}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Ready to implement"})]})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(h,{children:[e.jsxs(P,{children:[e.jsx(R,{children:"Recent Tasks"}),e.jsx(xe,{children:"Recently created or updated tasks"})]}),e.jsx(u,{children:j?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(t=>e.jsxs("div",{className:"animate-pulse",children:[e.jsx("div",{className:"h-4 bg-muted rounded w-3/4"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2 mt-2"})]},t))}):m.length>0?e.jsxs("div",{className:"space-y-4 overflow-hidden",children:[m.map(t=>e.jsx(v,{to:`/proposals/${t.id}`,className:"block",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-3 p-3 rounded-lg border hover:bg-accent hover:border-accent-foreground/20 transition-colors cursor-pointer",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx($e,{variant:Ge(t.status),children:t.status})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"text-sm font-medium line-clamp-2 sm:truncate",children:t.title||t.intent}),e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[t.author.name," • ",new Date(t.metadata?.updatedAt||t.metadata?.createdAt||"").toLocaleDateString()]})]})]})},t.id)),e.jsx("div",{className:"pt-2",children:e.jsx(d,{variant:"outline",size:"sm",asChild:!0,className:"w-full",children:e.jsx(v,{to:"/proposals",children:"View All Tasks"})})})]}):e.jsxs("div",{className:"text-center py-6",children:[e.jsx(W,{className:"mx-auto h-12 w-12 text-muted-foreground/50"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No tasks yet"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Create your first task to get started."}),e.jsx(d,{asChild:!0,className:"mt-4",children:e.jsxs(v,{to:"/proposals/new",children:[e.jsx(rs,{className:"mr-2 h-4 w-4"}),"New Task"]})})]})})]}),e.jsxs(h,{className:"flex flex-col",children:[e.jsxs(P,{children:[e.jsx(R,{children:"Quick Actions"}),e.jsx(xe,{children:"Common tasks and operations"})]}),e.jsx(u,{className:"flex flex-col flex-1",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs(d,{variant:"default",className:"w-full justify-between",onClick:()=>window.dispatchEvent(new CustomEvent("open-assistant-expanded")),children:[e.jsxs("span",{className:"flex items-center",children:[e.jsx(Ee,{className:"mr-2 h-4 w-4"}),"Chat with Assistant"]}),e.jsxs(A,{children:[e.jsx(g,{children:"⌘"}),e.jsx(g,{children:"L"})]})]}),e.jsxs(d,{variant:"outline",className:"w-full justify-between",onClick:()=>w(!0),children:[e.jsxs("span",{className:"flex items-center",children:[e.jsx(Ns,{className:"mr-2 h-4 w-4"}),"Launch Wizard"]}),e.jsxs(A,{children:[e.jsx(g,{children:"⌘"}),e.jsx(g,{children:"K"})]})]}),e.jsx(d,{asChild:!0,variant:"outline",className:"w-full justify-between",children:e.jsxs(v,{to:"/proposals/new",children:[e.jsxs("span",{className:"flex items-center",children:[e.jsx(W,{className:"mr-2 h-4 w-4"}),"Create a Task"]}),e.jsxs(A,{children:[e.jsx(g,{children:"⌘"}),e.jsx(g,{children:"I"})]})]})}),e.jsx(d,{asChild:!0,variant:"outline",className:"w-full justify-between",children:e.jsxs(v,{to:"/context/knowledge",children:[e.jsxs("span",{className:"flex items-center",children:[e.jsx(Ve,{className:"mr-2 h-4 w-4"}),"View the Knowledge Base"]}),e.jsxs(A,{children:[e.jsx(g,{children:"⌘"}),e.jsx(g,{children:"U"})]})]})}),e.jsx(d,{asChild:!0,variant:"outline",className:"w-full justify-between",children:e.jsxs(v,{to:"/code",children:[e.jsxs("span",{className:"flex items-center",children:[e.jsx(ue,{className:"mr-2 h-4 w-4"}),"Start an Agent"]}),e.jsxs(A,{children:[e.jsx(g,{children:"⌘"}),e.jsx(g,{children:"E"})]})]})})]})})]})]}),e.jsx(Cs,{open:L,onOpenChange:w,workflows:Ts})]})}export{Qs as default};
@@ -1,6 +0,0 @@
1
- import{c as He,r,a as Te,A as u,j as e,a6 as he,B as o,V as Fe,H as De,b6 as ze,I as U,D as W,b as B,d as q,f as J,g as K,a5 as V}from"./index-hqVgTgRB.js";import{C as xe,b as pe,c as ge,d as fe,a as be}from"./card-BCFxXzRk.js";import{L as f}from"./label-vYhfrPMD.js";import{R as Me,a as je}from"./radio-group-Db-pBuyW.js";import{R as A}from"./refresh-cw-Bg7vQzOw.js";import{E as ve}from"./external-link-CYBz87-P.js";import{C as Oe}from"./circle-check-D5wZZPvj.js";import{C as Ie}from"./circle-x-BXDB-G_q.js";/**
2
- * @license lucide-react v0.542.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const _e=[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]],we=He("github",_e),Y="../worktrees",y="../worktrees",b="coconut/github-auth-state";function $e(h){const j=h.trim();return j?/^([A-Za-z]:\\|\\\\|\/|~)/.test(j):!1}function Ze(){const[h,j]=r.useState(null),[X,v]=r.useState(y),[c,H]=r.useState("github"),[Z,Q]=r.useState(!0),[T,ee]=r.useState(!1),[a,te]=r.useState(null),[w,se]=r.useState(!1),[x,ye]=r.useState(null),[Ne,N]=r.useState(!1),[C,F]=r.useState(""),[k,D]=r.useState(""),[re,ae]=r.useState(!1),[p,S]=r.useState(!1),[ie,oe]=r.useState(!1),[Ce,R]=r.useState(!1),[E,G]=r.useState(""),[ne,ce]=r.useState(!1),[z,le]=r.useState(!1),[ke,P]=r.useState(!1),m=r.useRef(null),{toast:i}=Te(),M=r.useCallback(async()=>{Q(!0);try{const s=await(await fetch(`${u}/api/v1/git/settings`)).json();if(s.success){const n=s.data||{},d={defaultWorktreePath:n.defaultWorktreePath||y,authMode:n.authMode||"github"};j(d),v(d.defaultWorktreePath),H(d.authMode)}else throw new Error(s.error?.message||"Failed to load settings")}catch(t){console.error("Failed to load git settings",t),i({title:"Error",description:"Failed to load git settings",variant:"destructive"})}finally{Q(!1)}},[i]),l=r.useCallback(async()=>{se(!0);try{const[t,s]=await Promise.all([fetch(`${u}/api/v1/git/auth-status`).then(n=>n.json()),fetch(`${u}/api/v1/git/credential-config`).then(n=>n.json())]);if(t.success)te(t.data);else throw new Error(t.error?.message||"Failed to check auth status");s.success&&ye(s.data)}catch(t){console.error("Failed to check git auth status",t),te({authenticated:!1,error:"Failed to check status"})}finally{se(!1)}},[i]),O=c==="github",Se=O&&a?.provider==="github",L=!!(O&&a?.authenticated&&a?.provider==="github"),I=!!(O&&a?.provider==="github"&&!a?.authenticated),de=r.useMemo(()=>{if(!a?.expiresAt)return null;const t=new Date(a.expiresAt);return Number.isNaN(t.getTime())?null:t.toLocaleString()},[a?.expiresAt]);r.useEffect(()=>{if(typeof window>"u")return;const t=s=>{s.origin===window.location.origin&&s.data?.type==="github-auth"&&(m.current&&!m.current.closed&&m.current.close(),m.current=null,localStorage.removeItem(b),S(!1),s.data?.success?(i({title:"GitHub connected",description:"GitHub authorization completed successfully."}),l()):i({title:"GitHub authorization failed",description:s.data?.message||"Authorization was cancelled or failed.",variant:"destructive"}))};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[l,i]),r.useEffect(()=>{if(typeof window>"u"||!p)return;const t=window.setInterval(()=>{m.current&&m.current.closed&&(window.clearInterval(t),m.current=null,S(!1),localStorage.removeItem(b))},500);return()=>window.clearInterval(t)},[p]);const Re=r.useCallback(async()=>{if(!p&&!(typeof window>"u")){S(!0);try{const t=`${window.location.origin}/auth/github/callback`,s=await fetch(`${u}/api/v1/git/providers/github/authorize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callbackUrl:t})}),n=await s.json();if(!s.ok||!n.success)throw new Error(n?.error?.message||"Failed to start GitHub authorization");const d=n?.data?.authorizeUrl,me=n?.data?.state;if(!d||!me)throw new Error("Invalid response from authorization endpoint");localStorage.removeItem(b),localStorage.setItem(b,me);const $=window.open(d,"github-authorization","width=600,height=700");if(!$)throw localStorage.removeItem(b),new Error("Popup blocked. Please allow popups and try again.");m.current=$,$.focus()}catch(t){S(!1),localStorage.removeItem(b),i({title:"GitHub authorization failed",description:t?.message||"Unable to open GitHub authorization flow.",variant:"destructive"})}}},[p,i]),Ee=r.useCallback(async()=>{oe(!0);try{const t=await fetch(`${u}/api/v1/git/providers/github/token`,{method:"DELETE"}),s=await t.json();if(!t.ok||!s.success)throw new Error(s?.error?.message||"Failed to disconnect GitHub");i({title:"GitHub disconnected",description:"Stored GitHub credentials were removed."}),await l()}catch(t){i({title:"Failed to disconnect GitHub",description:t?.message||"Please try again.",variant:"destructive"})}finally{oe(!1)}},[l,i]);r.useEffect(()=>{M(),l()},[M,l]);const Ge=async()=>{if(!E.trim()){i({title:"Error",description:"Remote URL is required",variant:"destructive"});return}ce(!0);try{const s=await(await fetch(`${u}/api/v1/git/remote`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({remoteUrl:E.trim()})})).json();if(!s.success)throw new Error(s.error?.message||"Failed to set remote URL");i({title:"Success",description:"Remote URL set successfully"}),R(!1),G(""),await l()}catch(t){console.error("Failed to set remote URL",t),i({title:"Error",description:t?.message||"Failed to set remote URL",variant:"destructive"})}finally{ce(!1)}},Pe=async()=>{le(!0);try{const s=await(await fetch(`${u}/api/v1/git/remote`,{method:"DELETE"})).json();if(!s.success)throw new Error(s.error?.message||"Failed to delete remote");i({title:"Success",description:"Remote URL removed"}),await l()}catch(t){console.error("Failed to delete remote",t),i({title:"Error",description:t?.message||"Failed to delete remote",variant:"destructive"})}finally{le(!1)}},Le=async()=>{if(!C||!k){i({title:"Error",description:"Username and password are required",variant:"destructive"});return}if(!a?.remote){i({title:"Error",description:"Set a remote URL first before saving credentials",variant:"destructive"});return}ae(!0);try{const s=await(await fetch(`${u}/api/v1/git/credentials`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:C,password:k})})).json();if(!s.success)throw new Error(s.error?.message||"Failed to save credentials");i({title:"Success",description:"Credentials saved successfully"}),N(!1),F(""),D(""),await l()}catch(t){console.error("Failed to save credentials",t),i({title:"Error",description:t?.message||"Failed to save credentials",variant:"destructive"})}finally{ae(!1)}},g=X.trim(),_=r.useMemo(()=>g?$e(g)?"Path must be relative to the project root":null:"Path is required",[g]),Ue=r.useMemo(()=>h?g!==h.defaultWorktreePath||(h.authMode||"github")!==c:!1,[h,g,c]),ue=!Z&&!T&&Ue&&!_,Ae=async()=>{if(ue){ee(!0);try{const s=await(await fetch(`${u}/api/v1/git/settings`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultWorktreePath:g,authMode:c})})).json();if(!s.success)throw new Error(s.error?.message||"Failed to update settings");const n=s.data||{},d={defaultWorktreePath:n.defaultWorktreePath||y,authMode:n.authMode||"github"};j(d),v(d.defaultWorktreePath),H(d.authMode),i({title:"Updated",description:"Git settings saved"})}catch(t){console.error("Failed to update git settings",t),i({title:"Error",description:t?.message||"Failed to update git settings",variant:"destructive"})}finally{ee(!1)}}};return Z&&!h?e.jsx("div",{children:"Loading..."}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"Git Settings"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Control how Coconut creates worktrees for change proposals and manual Git operations."})]}),e.jsx(he,{}),e.jsxs(xe,{children:[e.jsxs(pe,{children:[e.jsx(ge,{children:"Remote Authentication"}),e.jsx(fe,{children:"Configure authentication for remote git operations."})]}),e.jsxs(be,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{className:"text-sm font-medium",children:"Remote URL"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"The git remote URL for your repository (origin)."}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded border bg-muted/30 px-3 py-2",children:[w&&!a?e.jsxs("span",{className:"text-sm text-muted-foreground italic flex items-center gap-2",children:[e.jsx(A,{className:"h-3.5 w-3.5 animate-spin"}),"Loading..."]}):a?.remote?e.jsxs("a",{href:a.remote.replace(/\.git$/,"").replace(/^git@([^:]+):/,"https://$1/"),target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline truncate inline-flex items-center gap-1.5",children:[a.remote,e.jsx(ve,{className:"h-3.5 w-3.5 shrink-0"})]}):e.jsx("span",{className:"text-sm text-muted-foreground italic",children:"Not configured"}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[a?.remote&&e.jsx(o,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>P(!0),disabled:z,title:"Remove remote",children:e.jsx(Fe,{className:"h-4 w-4"})}),e.jsx(o,{variant:"outline",size:"sm",onClick:()=>{G(a?.remote||""),R(!0)},children:a?.remote?"Edit":"Set Remote"})]})]})]}),e.jsx(he,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{className:"text-sm font-medium",children:"Authentication Mode"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose how Coconut authenticates with your remote repository when pushing or pulling."}),e.jsxs(Me,{value:c,onValueChange:t=>H(t||"github"),className:"grid gap-2 md:grid-cols-2",children:[e.jsx("label",{htmlFor:"mode-github",className:`cursor-pointer rounded-md border p-3 transition-colors ${c==="github"?"border-primary ring-1 ring-primary/40 bg-primary/5":"border-border bg-background hover:border-primary/60"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(je,{value:"github",id:"mode-github",className:"mt-1 h-5 w-5 shrink-0 border-[1.5px]"}),e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsx("span",{className:"text-sm font-medium",children:"GitHub"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Use the Coconut control plane to fetch short-lived GitHub tokens automatically."})]})]})}),e.jsx("label",{htmlFor:"mode-local",className:`cursor-pointer rounded-md border p-3 transition-colors ${c==="local"?"border-primary ring-1 ring-primary/40 bg-primary/5":"border-border bg-background hover:border-primary/60"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(je,{value:"local",id:"mode-local",className:"mt-1 h-5 w-5 shrink-0 border-[1.5px]"}),e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsx("span",{className:"text-sm font-medium",children:"Local configuration"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Manage credentials yourself using SSH keys, stored PATs, or OS credential helpers on this Coconut."})]})]})})]})]}),c==="github"&&!a&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-4 text-sm text-muted-foreground",children:[e.jsx(A,{className:"h-4 w-4 animate-spin"}),"Loading authentication status..."]}),c==="github"&&a&&!a.remote&&e.jsxs("div",{className:"rounded border border-amber-200 bg-amber-50 p-3 text-sm text-amber-700 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-200",children:[e.jsx("span",{className:"font-medium",children:"Remote URL required:"})," Set a remote URL above to enable GitHub authentication."]}),c==="github"&&a?.remote&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-3 rounded border p-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[w?e.jsx(A,{className:"h-5 w-5 mt-1 animate-spin text-muted-foreground"}):a?.authenticated?e.jsx(Oe,{className:"h-5 w-5 mt-1 text-green-600"}):e.jsx(Ie,{className:"h-5 w-5 mt-1 text-red-600"}),e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsx("div",{className:"font-medium",children:w?"Checking...":L?"Connected to GitHub":I?"GitHub authorization required":a?.authenticated?"Authenticated":"Not authenticated"}),Se&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(we,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:L?"GitHub App credentials active":"Authorize with GitHub to continue"})]}),L&&de&&e.jsxs("span",{className:"rounded bg-muted px-2 py-0.5 text-[11px] text-muted-foreground",children:["Expires ",de]})]}),a?.error&&e.jsx("div",{className:"text-xs text-red-600",children:a.error})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:[e.jsxs(o,{variant:"outline",size:"sm",onClick:l,disabled:w,children:[e.jsx(A,{className:"h-4 w-4 mr-2"+(w?" animate-spin":"")}),"Check Status"]}),L?e.jsx(o,{variant:"ghost",size:"sm",onClick:Ee,disabled:ie,children:ie?"Disconnecting…":"Disconnect GitHub"}):e.jsxs(o,{size:"sm",onClick:Re,disabled:p,children:[p?e.jsx(De,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(we,{className:"h-4 w-4 mr-2"}),p?"Authorizing…":I?"Reconnect GitHub":"Connect GitHub"]})]}),e.jsx("div",{className:"text-right",children:e.jsxs("a",{href:"https://app.coconut.dev/git",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-primary hover:underline",children:["Manage Github authentication",e.jsx(ve,{className:"h-3 w-3"})]})})]}),I&&e.jsx("div",{className:"rounded border border-amber-200 bg-amber-50 p-3 text-xs text-amber-700 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-200",children:"GitHub authorization has expired. Click “Reconnect GitHub” to refresh access."}),x&&(x.helper||x.origin)&&e.jsxs("div",{className:"rounded border bg-muted/50 p-3",children:[e.jsx("div",{className:"text-xs font-medium mb-1",children:"Current Configuration"}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[x.helper&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"font-mono",children:"credential.helper:"}),e.jsx("span",{className:"font-mono text-foreground",children:x.helper})]}),x.origin&&e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"font-mono",children:"Configured in:"}),e.jsx("span",{className:"font-mono text-foreground",children:x.origin})]})]})]})]}),c==="local"&&e.jsxs("div",{className:"rounded bg-muted p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm font-medium",children:"Setup Git Credentials"}),e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>N(!0),children:[e.jsx(ze,{className:"h-4 w-4 mr-2"}),"Enter Credentials"]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-2",children:[e.jsx("p",{children:"Configure credentials directly on this Coconut. Coconut will use your existing SSH keys or credential helpers without contacting the control plane."}),e.jsxs("div",{className:"space-y-2 ml-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold",children:"Option 1: SSH Keys (Recommended)"}),e.jsxs("code",{className:"text-[11px] block mt-1 bg-background rounded px-2 py-1",children:['ssh-keygen -t ed25519 -C "your_email@example.com"',e.jsx("br",{}),"# Add ~/.ssh/id_ed25519.pub to your Git provider account"]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold",children:"Option 2: Git Credential Manager"}),e.jsxs("code",{className:"text-[11px] block mt-1 bg-background rounded px-2 py-1",children:["# macOS (already configured with osxkeychain)",e.jsx("br",{}),"git credential-osxkeychain",e.jsx("br",{}),e.jsx("br",{}),"# Or install Git Credential Manager",e.jsx("br",{}),"brew install git-credential-manager"]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold",children:"Option 3: Personal Access Token"}),e.jsxs("code",{className:"text-[11px] block mt-1 bg-background rounded px-2 py-1",children:["# Store credentials after first push/pull",e.jsx("br",{}),"git config credential.helper store"]})]})]}),e.jsx("p",{className:"mt-3",children:'After configuring, click "Check Status" to verify authentication.'})]})]})]})]}),e.jsxs(xe,{children:[e.jsxs(pe,{children:[e.jsx(ge,{children:"Worktree Location"}),e.jsx(fe,{children:"Choose where new worktrees should be created relative to your project root."})]}),e.jsxs(be,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"default-worktree-path",children:"Default worktree path"}),e.jsx(U,{id:"default-worktree-path",value:X,onChange:t=>v(t.target.value),placeholder:"../worktrees",spellCheck:!1}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Paths are resolved from your project root. We recommend keeping worktrees outside the repository, for example ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-[11px] font-mono",children:Y}),"."]}),_&&e.jsx("p",{className:"text-xs text-red-600",children:_})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(o,{type:"button",variant:"outline",size:"sm",onClick:()=>v(Y),children:["Use ",Y]}),e.jsxs(o,{type:"button",variant:"ghost",size:"sm",onClick:()=>v(y),children:["Reset to ",y]})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(o,{type:"button",variant:"outline",disabled:T,onClick:M,children:"Reload"}),e.jsx(o,{type:"button",disabled:!ue,onClick:Ae,children:T?"Saving...":"Save changes"})]}),e.jsx(W,{open:Ne,onOpenChange:N,children:e.jsxs(B,{children:[e.jsxs(q,{children:[e.jsx(J,{children:"Enter Git Credentials"}),e.jsx(K,{children:"Enter your username and personal access token for HTTPS authentication. Your credentials will be securely stored using your system's credential manager."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[!a?.remote&&e.jsx("div",{className:"rounded border border-amber-200 bg-amber-50 p-3 text-xs text-amber-700 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-200",children:"No remote URL configured. Set a remote URL first before entering credentials."}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"git-username",children:"Username"}),e.jsx(U,{id:"git-username",placeholder:"your-username",value:C,onChange:t=>F(t.target.value),autoComplete:"username"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"git-password",children:"Password / Personal Access Token"}),e.jsx(U,{id:"git-password",type:"password",placeholder:"ghp_xxxxxxxxxxxx or your password",value:k,onChange:t=>D(t.target.value),autoComplete:"current-password"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["We recommend using a Personal Access Token instead of your password.",e.jsx("br",{}),"GitHub: Settings → Developer settings → Personal access tokens",e.jsx("br",{}),"GitLab: Preferences → Access Tokens"]})]})]}),e.jsxs(V,{children:[e.jsx(o,{variant:"outline",onClick:()=>{N(!1),F(""),D("")},children:"Cancel"}),e.jsx(o,{onClick:Le,disabled:re||!C||!k||!a?.remote,children:re?"Saving...":"Save Credentials"})]})]})}),e.jsx(W,{open:ke,onOpenChange:P,children:e.jsxs(B,{children:[e.jsxs(q,{children:[e.jsx(J,{children:"Remove Remote?"}),e.jsx(K,{children:"This will remove the origin remote from your local git configuration. The remote repository itself won't be affected."})]}),e.jsxs(V,{children:[e.jsx(o,{variant:"outline",onClick:()=>P(!1),children:"Cancel"}),e.jsx(o,{variant:"destructive",onClick:async()=>{P(!1),await Pe()},disabled:z,children:z?"Removing...":"Remove Remote"})]})]})}),e.jsx(W,{open:Ce,onOpenChange:R,children:e.jsxs(B,{children:[e.jsxs(q,{children:[e.jsx(J,{children:a?.remote?"Edit Remote URL":"Set Remote URL"}),e.jsx(K,{children:"Configure the git remote URL for your repository. This is the origin remote used for push and pull operations."})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"remote-url",children:"Remote URL"}),e.jsx(U,{id:"remote-url",placeholder:"https://github.com/username/repo.git",value:E,onChange:t=>G(t.target.value),autoComplete:"off"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enter your repository URL (HTTPS or SSH format)."})]})}),e.jsxs(V,{children:[e.jsx(o,{variant:"outline",onClick:()=>{R(!1),G("")},children:"Cancel"}),e.jsx(o,{onClick:Ge,disabled:ne||!E.trim(),children:ne?"Saving...":"Save"})]})]})})]})}export{Ze as default};
@@ -1,11 +0,0 @@
1
- import{c as oe,a as ve,r as u,j as e,H as se,B as x,a7 as fe,a3 as Ne,b4 as Te,o as Ce,I as c,w as O,ag as ae,a6 as ne,V as be,h as Se,i as we,k as Ae,l as ke,m as Ie,A as ie}from"./index-hqVgTgRB.js";import{C as y,b as g,c as j,d as v,a as f,e as Oe}from"./card-BCFxXzRk.js";import{L as o}from"./label-vYhfrPMD.js";import{B as re}from"./badge-DEiQk9C9.js";import{A as Fe,a as Pe}from"./alert-BD5jo3SI.js";import{T as Ee,a as Me,b,c as S}from"./tabs-XeRAjZYR.js";import{Z as Le}from"./zap-BlzMp7dY.js";import{E as De}from"./eye-BT8MAvKY.js";import{P as E}from"./plus-iamYJu5V.js";import{C as _e,a as Ue}from"./clipboard-DC2xmNVx.js";/**
2
- * @license lucide-react v0.542.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const Re=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],Je=oe("mail",Re);/**
7
- * @license lucide-react v0.542.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const $e=[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]],qe=oe("refresh-ccw",$e),Be=["a2a_v0.2","a2a_v0.1","jsonrpc2","jsonrpc","openrpc","rest"],Ke=["GET","POST","PUT","PATCH","DELETE"],He=()=>({id:"",skill:"",description:"",endpoint:"",method:"POST",enabled:!0,inputMimeType:"application/json",outputMimeType:"application/json",inputSchema:"",outputSchema:""}),w={id:"",name:"",description:"",version:"1.0.0",url:"",documentation:"",protocols:["a2a_v0.2"],authentication:{scheme:"api_key",in:"header",name:"X-API-Key",example:"",description:""},capabilities:[],supportedInputTypes:["application/json"],supportedOutputTypes:["application/json"],security:{transport:"https",encryption:"TLS 1.3",notes:""},contact:{name:"",email:""},lastUpdated:void 0},N=a=>({...a,protocols:[...a.protocols],authentication:{...a.authentication},capabilities:a.capabilities.map(n=>({...n})),supportedInputTypes:[...a.supportedInputTypes],supportedOutputTypes:[...a.supportedOutputTypes],security:{...a.security},contact:{...a.contact}}),F=()=>N(w);function Ve(a){if(!a)return F();const n=Array.isArray(a.protocols)?a.protocols.filter(r=>typeof r=="string"):[],d=Array.isArray(a.supportedContentTypes?.input)?a.supportedContentTypes.input.filter(r=>typeof r=="string"):[],A=Array.isArray(a.supportedContentTypes?.output)?a.supportedContentTypes.output.filter(r=>typeof r=="string"):[],T=Array.isArray(a.capabilities)?a.capabilities.map(r=>({id:typeof r.id=="string"?r.id:"",skill:typeof r.skill=="string"?r.skill:"",description:typeof r.description=="string"?r.description:"",endpoint:typeof r.endpoint=="string"?r.endpoint:"",method:typeof r.method=="string"?r.method:"POST",enabled:r?.enabled!==!1,inputMimeType:typeof r.input?.mimeType=="string"?r.input.mimeType:"application/json",outputMimeType:typeof r.output?.mimeType=="string"?r.output.mimeType:"application/json",inputSchema:r.input?.schema?JSON.stringify(r.input.schema,null,2):"",outputSchema:r.output?.schema?JSON.stringify(r.output.schema,null,2):""})):[],M={scheme:typeof a.authentication?.scheme=="string"?a.authentication.scheme:"api_key",in:typeof a.authentication?.in=="string"?a.authentication.in:"header",name:typeof a.authentication?.name=="string"?a.authentication.name:"X-API-Key",example:typeof a.authentication?.example=="string"?a.authentication.example:"",description:typeof a.authentication?.description=="string"?a.authentication.description:""};return{id:typeof a.id=="string"?a.id:"",name:typeof a.name=="string"?a.name:"",description:typeof a.description=="string"?a.description:"",version:typeof a.version=="string"?a.version:"1.0.0",url:typeof a.url=="string"?a.url:"",documentation:typeof a.documentation=="string"?a.documentation:"",protocols:n.length>0?n:w.protocols,authentication:M,capabilities:T,supportedInputTypes:d.length>0?d:w.supportedInputTypes,supportedOutputTypes:A.length>0?A:w.supportedOutputTypes,security:{transport:typeof a.security?.transport=="string"?a.security.transport:w.security.transport,encryption:typeof a.security?.encryption=="string"?a.security.encryption:w.security.encryption,notes:typeof a.security?.notes=="string"?a.security.notes:""},contact:{name:typeof a.contact?.name=="string"?a.contact.name:"",email:typeof a.contact?.email=="string"?a.contact.email:""},lastUpdated:typeof a.lastUpdated=="string"?a.lastUpdated:void 0}}function at(){const{toast:a}=ve(),[n,d]=u.useState(()=>F()),[A,T]=u.useState(()=>F()),[M,r]=u.useState(!0),[L,B]=u.useState(!1),[K,k]=u.useState(null),[H,D]=u.useState(""),[V,_]=u.useState(""),[X,U]=u.useState(""),[P,R]=u.useState(void 0),[le,z]=u.useState(!1),ce=u.useMemo(()=>{const t=new Set([...Be,...n.protocols]);return Array.from(t).sort()},[n.protocols]);u.useEffect(()=>{let t=!0;return(async()=>{r(!0),k(null);try{const s=await fetch(`${ie}/api/v1/identity/agent-card`);if(!s.ok)throw new Error(`Failed to load agent card (${s.status})`);const l=await s.json();if(l.success&&l.data){const p=Ve(l.data.card||void 0);if(p.id||(p.id="urn:agent:coconut"),p.url||(p.url=`${window.location.origin}/api/v1`),p.lastUpdated=l.data.updatedAt??p.lastUpdated,t){const m=N(p);d(m),T(N(m)),R(l.data.updatedAt??m.lastUpdated)}}else{if(l.error)throw new Error(l.error);if(t){const p=F();d(p),T(N(p))}}}catch(s){if(console.error("Failed to fetch agent card",s),t){k(s instanceof Error?s.message:"Failed to load agent identity");const l=F();d(l),T(N(l))}}finally{t&&r(!1)}})(),()=>{t=!1}},[]);const de=(t,i)=>{d(s=>{const l=i?[...new Set([...s.protocols,t])]:s.protocols.filter(p=>p!==t);return{...s,protocols:l}})},Y=()=>{const t=H.trim();t&&(d(i=>({...i,protocols:[...new Set([...i.protocols,t])]})),D(""))},Z=()=>{const t=V.trim();t&&(d(i=>({...i,supportedInputTypes:[...new Set([...i.supportedInputTypes,t])]})),_(""))},G=()=>{const t=X.trim();t&&(d(i=>({...i,supportedOutputTypes:[...new Set([...i.supportedOutputTypes,t])]})),U(""))},pe=t=>{d(i=>({...i,supportedInputTypes:i.supportedInputTypes.filter(s=>s!==t)}))},ue=t=>{d(i=>({...i,supportedOutputTypes:i.supportedOutputTypes.filter(s=>s!==t)}))},C=(t,i)=>{d(s=>({...s,[t]:i}))},I=(t,i)=>{d(s=>({...s,authentication:{...s.authentication,[t]:i}}))},J=(t,i)=>{d(s=>({...s,security:{...s.security,[t]:i}}))},Q=(t,i)=>{d(s=>({...s,contact:{...s.contact,[t]:i}}))},he=()=>{d(t=>({...t,capabilities:[...t.capabilities,He()]}))},h=(t,i)=>{d(s=>{const l=[...s.capabilities];return l[t]={...l[t],...i},{...s,capabilities:l}})},me=t=>{d(i=>({...i,capabilities:i.capabilities.filter((s,l)=>l!==t)}))},$=()=>{const t=[["id","Agent ID"],["name","Name"],["description","Description"],["version","Version"],["url","Service URL"]];for(const[s,l]of t){const p=n[s];if(typeof p!="string"||!p.trim())throw new Error(`${l} is required`)}const i=n.capabilities.map((s,l)=>({cap:s,index:l})).filter(({cap:s})=>s.enabled&&s.id.trim()&&s.endpoint.trim()).map(({cap:s,index:l})=>{const p=s.id.trim()||`Capability ${l+1}`,m={id:s.id.trim(),skill:s.skill.trim(),description:s.description.trim(),endpoint:s.endpoint.trim(),method:s.method||"POST"},ee=(q,je)=>{if(!(!q||!q.trim()))try{return JSON.parse(q)}catch(te){throw new Error(`${p} ${je} schema must be valid JSON. ${te?.message??te}`)}};return(s.inputMimeType?.trim()||s.inputSchema?.trim())&&(m.input={mimeType:s.inputMimeType?.trim()||"application/json",schema:ee(s.inputSchema,"input")}),(s.outputMimeType?.trim()||s.outputSchema?.trim())&&(m.output={mimeType:s.outputMimeType?.trim()||"application/json",schema:ee(s.outputSchema,"output")}),m});return{id:n.id.trim(),name:n.name.trim(),description:n.description.trim(),version:n.version.trim(),url:n.url.trim(),documentation:n.documentation.trim()||void 0,protocols:n.protocols,authentication:{scheme:n.authentication.scheme.trim()||"api_key",in:n.authentication.in.trim()||"header",name:n.authentication.name.trim()||"X-API-Key",example:n.authentication.example.trim()||void 0,description:n.authentication.description.trim()||void 0},capabilities:i,supportedContentTypes:{input:n.supportedInputTypes,output:n.supportedOutputTypes},security:{transport:n.security.transport.trim()||"https",encryption:n.security.encryption.trim()||"TLS 1.3",notes:n.security.notes.trim()||void 0},contact:{name:n.contact.name.trim()||void 0,email:n.contact.email.trim()||void 0},lastUpdated:new Date().toISOString()}},xe=async()=>{B(!0),k(null);try{const t=$(),i=await fetch(`${ie}/api/v1/identity/agent-card`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({card:t})}),s=await i.json();if(!i.ok||!s?.success)throw new Error(s?.error||"Failed to save agent card");a({title:"Agent card saved",description:"The identity card has been updated successfully."});const l=s?.data?.updatedAt??new Date().toISOString();d(p=>{const m={...p,lastUpdated:l};return T(N(m)),m}),R(l)}catch(t){console.error("Failed to save agent card",t),k(t instanceof Error?t.message:"Failed to save agent card"),a({title:"Save failed",description:t instanceof Error?t.message:"Failed to save agent card, see console for details.",variant:"destructive"})}finally{B(!1)}},ye=()=>{d(N(A)),k(null),D(""),_(""),U(""),R(A.lastUpdated??P)},ge=async()=>{try{const t=JSON.stringify($(),null,2);await navigator.clipboard.writeText(t),z(!0),setTimeout(()=>z(!1),1500),a({title:"Copied!",description:"Agent card JSON copied to clipboard."})}catch(t){console.error("Failed to copy agent card preview:",t),a({title:"Copy failed",description:"Unable to copy agent card JSON to clipboard.",variant:"destructive"})}},W=u.useMemo(()=>{if(!P)return null;try{return new Date(P).toLocaleString()}catch{return null}},[P]);return M?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(se,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Loading identity card..."})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col justify-between gap-4 md:flex-row md:items-end",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Agent Identity"}),e.jsxs("p",{className:"text-muted-foreground",children:["Manage the"," ",e.jsx("a",{href:"/.well-known/agent-card.json",target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-4 hover:text-primary",children:"/.well-known/agent-card.json"})," ","descriptor for A2A discovery."]}),W&&e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["Last updated ",W]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(x,{variant:"outline",onClick:ye,disabled:L,children:[e.jsx(qe,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Reset"})]}),e.jsx(x,{onClick:xe,disabled:L,children:L?e.jsxs(e.Fragment,{children:[e.jsx(se,{className:"h-4 w-4 animate-spin sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Saving..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Save Changes"})]})})]})]}),K&&e.jsxs(Fe,{variant:"destructive",children:[e.jsx("div",{className:"font-semibold",children:"Something went wrong"}),e.jsx(Pe,{children:K})]}),e.jsxs(Ee,{defaultValue:"overview",className:"space-y-6",children:[e.jsxs(Me,{className:"grid w-full grid-cols-6 h-auto p-1",children:[e.jsxs(b,{value:"overview",className:"gap-2",children:[e.jsx(Ne,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Identity"})]}),e.jsxs(b,{value:"protocols",className:"gap-2",children:[e.jsx(Te,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Protocols"})]}),e.jsxs(b,{value:"auth",className:"gap-2",children:[e.jsx(Ce,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Security"})]}),e.jsxs(b,{value:"capabilities",className:"gap-2",children:[e.jsx(Le,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Capabilities"})]}),e.jsxs(b,{value:"contact",className:"gap-2",children:[e.jsx(Je,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contact"})]}),e.jsxs(b,{value:"preview",className:"gap-2",children:[e.jsx(De,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Preview"})]})]}),e.jsx(S,{value:"overview",children:e.jsxs(y,{children:[e.jsxs(g,{children:[e.jsx(j,{children:"Identity Overview"}),e.jsx(v,{children:"Define core attributes used for discovery."})]}),e.jsxs(f,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-id",children:"Agent Identifier"}),e.jsx(c,{id:"agent-id",value:n.id,placeholder:"urn:agent:coconut-dev",onChange:t=>C("id",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-name",children:"Name"}),e.jsx(c,{id:"agent-name",value:n.name,placeholder:"Coconut Development Agent",onChange:t=>C("name",t.target.value)})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-version",children:"Version"}),e.jsx(c,{id:"agent-version",value:n.version,placeholder:"1.0.0",onChange:t=>C("version",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-url",children:"Primary Endpoint"}),e.jsx(c,{id:"agent-url",value:n.url,placeholder:"https://coconut.dev/api/v1",onChange:t=>C("url",t.target.value)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-description",children:"Description"}),e.jsx(O,{id:"agent-description",value:n.description,placeholder:"Agent responsible for managing proposals, plans, and operations...",onChange:t=>C("description",t.target.value),rows:4})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-docs",children:"Documentation URL"}),e.jsx(c,{id:"agent-docs",value:n.documentation,placeholder:"https://docs.coconut.dev/a2a",onChange:t=>C("documentation",t.target.value)})]})]})]})}),e.jsx(S,{value:"protocols",children:e.jsxs(y,{children:[e.jsxs(g,{children:[e.jsx(j,{children:"Protocols & Content Types"}),e.jsx(v,{children:"Select supported discovery protocols and payload formats."})]}),e.jsxs(f,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Protocols"}),e.jsx("div",{className:"grid gap-2 md:grid-cols-3",children:ce.map(t=>e.jsxs("label",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/20 px-3 py-2",children:[e.jsx(ae,{checked:n.protocols.includes(t),onCheckedChange:i=>de(t,!!i)}),e.jsx("span",{className:"text-sm font-medium",children:t})]},t))}),e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row",children:[e.jsx(c,{value:H,placeholder:"Add custom protocol (press Add)",onChange:t=>D(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),Y())}}),e.jsxs(x,{type:"button",variant:"outline",onClick:Y,children:[e.jsx(E,{className:"mr-2 h-4 w-4"}),"Add"]})]})]}),e.jsx(ne,{}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Supported Input Types"}),e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row",children:[e.jsx(c,{value:V,placeholder:"application/json",onChange:t=>_(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),Z())}}),e.jsxs(x,{type:"button",variant:"outline",onClick:Z,children:[e.jsx(E,{className:"mr-2 h-4 w-4"}),"Add"]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:n.supportedInputTypes.map(t=>e.jsxs(re,{variant:"secondary",className:"flex items-center gap-1",children:[t,e.jsx("button",{type:"button",onClick:()=>pe(t),className:"ml-1 rounded-full border border-transparent bg-transparent text-muted-foreground transition hover:text-foreground",children:"×"})]},t))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Supported Output Types"}),e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row",children:[e.jsx(c,{value:X,placeholder:"application/json",onChange:t=>U(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),G())}}),e.jsxs(x,{type:"button",variant:"outline",onClick:G,children:[e.jsx(E,{className:"mr-2 h-4 w-4"}),"Add"]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:n.supportedOutputTypes.map(t=>e.jsxs(re,{variant:"secondary",className:"flex items-center gap-1",children:[t,e.jsx("button",{type:"button",onClick:()=>ue(t),className:"ml-1 rounded-full border border-transparent bg-transparent text-muted-foreground transition hover:text-foreground",children:"×"})]},t))})]})]})]})]})}),e.jsx(S,{value:"auth",children:e.jsxs(y,{children:[e.jsxs(g,{children:[e.jsx(j,{children:"Authentication & Security"}),e.jsx(v,{children:"Document how peer agents should authenticate and connect."})]}),e.jsxs(f,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"auth-scheme",children:"Authentication Scheme"}),e.jsx(c,{id:"auth-scheme",value:n.authentication.scheme,placeholder:"api_key",onChange:t=>I("scheme",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"auth-in",children:"Credential Location"}),e.jsx(c,{id:"auth-in",value:n.authentication.in,placeholder:"header",onChange:t=>I("in",t.target.value)})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"auth-name",children:"Header or Field Name"}),e.jsx(c,{id:"auth-name",value:n.authentication.name,placeholder:"X-API-Key",onChange:t=>I("name",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"auth-example",children:"Example Secret"}),e.jsx(c,{id:"auth-example",value:n.authentication.example,placeholder:"nut_***************",onChange:t=>I("example",t.target.value)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"auth-description",children:"Authentication Notes"}),e.jsx(O,{id:"auth-description",value:n.authentication.description,placeholder:"Provide API key via X-API-Key header to authenticate requests between agents.",onChange:t=>I("description",t.target.value),rows:3})]}),e.jsx(ne,{}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"security-transport",children:"Transport"}),e.jsx(c,{id:"security-transport",value:n.security.transport,placeholder:"https",onChange:t=>J("transport",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"security-encryption",children:"Encryption"}),e.jsx(c,{id:"security-encryption",value:n.security.encryption,placeholder:"TLS 1.3",onChange:t=>J("encryption",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"security-notes",children:"Security Notes"}),e.jsx(c,{id:"security-notes",value:n.security.notes,placeholder:"Requests must be encrypted over TLS.",onChange:t=>J("notes",t.target.value)})]})]})]})]})}),e.jsx(S,{value:"capabilities",children:e.jsxs(y,{children:[e.jsxs(g,{children:[e.jsx(j,{children:"Capabilities"}),e.jsx(v,{children:"Describe the skills other agents can invoke."})]}),e.jsxs(f,{className:"space-y-4",children:[n.capabilities.length===0&&e.jsx("div",{className:"rounded-lg border border-dashed border-border bg-muted/40 p-6 text-center text-sm text-muted-foreground",children:"No capabilities defined yet. Add one to expose functionality for peer agents."}),n.capabilities.map((t,i)=>e.jsxs(y,{className:"border border-border/60",children:[e.jsxs(g,{className:"flex flex-col gap-2 space-y-0 md:flex-row md:items-center",children:[e.jsxs("div",{className:"flex flex-1 flex-col",children:[e.jsxs(j,{className:"text-lg font-semibold",children:["Capability #",i+1]}),e.jsx(v,{children:"Toggle availability and describe request contracts."})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(ae,{checked:t.enabled,onCheckedChange:s=>h(i,{enabled:!!s})}),"Expose capability"]}),e.jsxs(x,{size:"icon",variant:"ghost",onClick:()=>me(i),title:"Remove capability",children:[e.jsx(be,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Remove capability"})]})]})]}),e.jsxs(f,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Capability ID"}),e.jsx(c,{value:t.id,placeholder:"create-proposal",onChange:s=>h(i,{id:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Skill"}),e.jsx(c,{value:t.skill,placeholder:"proposal_management.create",onChange:s=>h(i,{skill:s.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Description"}),e.jsx(O,{value:t.description,placeholder:"Creates a new task containing intent, plan, and artifacts.",rows:3,onChange:s=>h(i,{description:s.target.value})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Endpoint"}),e.jsx(c,{value:t.endpoint,placeholder:"https://coconut.dev/api/v1/proposals",onChange:s=>h(i,{endpoint:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"HTTP Method"}),e.jsxs(Se,{value:t.method,onValueChange:s=>h(i,{method:s}),children:[e.jsx(we,{children:e.jsx(Ae,{placeholder:"Select method"})}),e.jsx(ke,{children:Ke.map(s=>e.jsx(Ie,{value:s,children:s},s))})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Input MIME Type"}),e.jsx(c,{value:t.inputMimeType??"",placeholder:"application/json",onChange:s=>h(i,{inputMimeType:s.target.value})}),e.jsx(o,{children:"Input Schema (JSON)"}),e.jsx(O,{value:t.inputSchema??"",placeholder:'{ "type": "object", "properties": { "title": { "type": "string" } } }',rows:5,onChange:s=>h(i,{inputSchema:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Output MIME Type"}),e.jsx(c,{value:t.outputMimeType??"",placeholder:"application/json",onChange:s=>h(i,{outputMimeType:s.target.value})}),e.jsx(o,{children:"Output Schema (JSON)"}),e.jsx(O,{value:t.outputSchema??"",placeholder:'{ "type": "object", "properties": { "status": { "type": "string" } } }',rows:5,onChange:s=>h(i,{outputSchema:s.target.value})})]})]})]})]},`${t.id||"capability"}-${i}`))]}),e.jsx(Oe,{children:e.jsxs(x,{type:"button",variant:"outline",onClick:he,children:[e.jsx(E,{className:"mr-2 h-4 w-4"}),"Add Capability"]})})]})}),e.jsx(S,{value:"contact",children:e.jsxs(y,{children:[e.jsxs(g,{children:[e.jsx(j,{children:"Contact"}),e.jsx(v,{children:"Provide a human escalation path for peer agents."})]}),e.jsxs(f,{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"contact-name",children:"Contact Name"}),e.jsx(c,{id:"contact-name",value:n.contact.name,placeholder:"Coconut DevOps Team",onChange:t=>Q("name",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"contact-email",children:"Contact Email"}),e.jsx(c,{id:"contact-email",value:n.contact.email,placeholder:"support@coconut.dev",onChange:t=>Q("email",t.target.value)})]})]})]})}),e.jsx(S,{value:"preview",children:e.jsxs(y,{children:[e.jsx(g,{children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(j,{children:"Preview"}),e.jsx(v,{children:"Review the JSON payload served at /.well-known/agent-card.json."})]}),e.jsx(x,{variant:"outline",size:"sm",onClick:ge,children:le?e.jsxs(e.Fragment,{children:[e.jsx(_e,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copied"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ue,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copy"})]})})]})}),e.jsx(f,{children:e.jsx("pre",{className:"max-h-96 overflow-auto rounded-md bg-muted p-4 text-sm",children:JSON.stringify((()=>{try{return $()}catch{return{id:n.id,name:n.name,description:n.description,version:n.version,url:n.url,protocols:n.protocols}}})(),null,2)})})]})})]})]})}export{at as default};