@lovelybunch/api 1.0.76-alpha.9 → 1.0.77-alpha.0

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 (173) hide show
  1. package/dist/lib/git.d.ts +3 -0
  2. package/dist/lib/git.js +35 -0
  3. package/dist/lib/terminal/terminal-manager.js +2 -1
  4. package/dist/routes/api/v1/ai/route.js +214 -152
  5. package/dist/routes/api/v1/config/route.js +13 -9
  6. package/dist/routes/api/v1/context/agents/route.d.ts +3 -0
  7. package/dist/routes/api/v1/context/agents/route.js +159 -0
  8. package/dist/routes/api/v1/context/index.js +6 -4
  9. package/dist/routes/api/v1/context/memory/route.d.ts +3 -0
  10. package/dist/routes/api/v1/context/memory/route.js +163 -0
  11. package/dist/routes/api/v1/context/team/route.d.ts +3 -0
  12. package/dist/routes/api/v1/context/team/route.js +159 -0
  13. package/dist/routes/api/v1/events/status/route.d.ts +1 -1
  14. package/dist/routes/api/v1/git/index.js +27 -1
  15. package/dist/routes/api/v1/jobs/[id]/route.d.ts +26 -32
  16. package/dist/routes/api/v1/jobs/[id]/route.js +3 -3
  17. package/dist/routes/api/v1/jobs/[id]/run/route.d.ts +2 -2
  18. package/dist/routes/api/v1/jobs/[id]/runs/[runId]/route.d.ts +2 -2
  19. package/dist/routes/api/v1/jobs/route.d.ts +33 -33
  20. package/dist/routes/api/v1/jobs/route.js +17 -2
  21. package/dist/routes/api/v1/jobs/status/route.d.ts +1 -1
  22. package/dist/routes/api/v1/mail/route.d.ts +3 -3
  23. package/dist/routes/api/v1/mcp/index.js +194 -21
  24. package/dist/routes/api/v1/resources/generate/route.js +10 -3
  25. package/dist/routes/api/v1/slack/route.d.ts +6 -6
  26. package/dist/routes/api/v1/tasks/[id]/route.d.ts +4 -4
  27. package/dist/routes/api/v1/tasks/[id]/steps/[stepId]/route.d.ts +2 -2
  28. package/dist/routes/api/v1/tasks/route.d.ts +1 -1
  29. package/dist/server-with-static.js +23 -17
  30. package/dist/server.js +1 -0
  31. package/package.json +24 -23
  32. package/static/assets/ActivityPage-rASRHKYj.js +1 -0
  33. package/static/assets/AgentsContextEditPage-CMWD-7mS.js +9 -0
  34. package/static/assets/AgentsContextPage-VfMmxxr6.js +1 -0
  35. package/static/assets/{ApiKeysSettingsPage-CjrCuHHE.js → ApiKeysSettingsPage-DxtuyXwn.js} +2 -2
  36. package/static/assets/{AuthSettingsPage-elJX4TCV.js → AuthSettingsPage-CWTpS6BA.js} +2 -2
  37. package/static/assets/{CallbackPage-CUuZYgBL.js → CallbackPage-CjlTVuif.js} +1 -1
  38. package/static/assets/CodePage-DwjtGxQi.js +2 -0
  39. package/static/assets/{CollapsibleSection-DfTxWX0X.js → CollapsibleSection-LrQJlSxD.js} +1 -1
  40. package/static/assets/{DashboardPage-CmS8UPSm.js → DashboardPage-DnyFyDO0.js} +9 -19
  41. package/static/assets/{GitPage-DSfn76oO.js → GitPage-o37iQMYQ.js} +3 -3
  42. package/static/assets/{GitSettingsPage-Bu8h7hcr.js → GitSettingsPage-O0fe5kxm.js} +2 -2
  43. package/static/assets/{IdentityPage-NFKq2FHi.js → IdentityPage-KWjruliO.js} +2 -2
  44. package/static/assets/{ImplementationStepsEditor-Cn-MshnR.js → ImplementationStepsEditor-h_Mxu1tF.js} +2 -2
  45. package/static/assets/IntegrationsSettingsPage-DeFQd6af.js +1 -0
  46. package/static/assets/JobDetailPage-HOLpF7Sx.js +1 -0
  47. package/static/assets/KnowledgeDetailPage-C5egPQ54.js +1 -0
  48. package/static/assets/KnowledgeEditPage-DrdvEGuR.js +1 -0
  49. package/static/assets/{KnowledgePage-C3zoPEcH.js → KnowledgePage-CK5rtZcv.js} +2 -2
  50. package/static/assets/{LoginPage-BYNLGEnz.js → LoginPage-DajEouCN.js} +1 -1
  51. package/static/assets/MailInboxPage-CewILL7o.js +1 -0
  52. package/static/assets/MailProcessingModal-B1ZLXyYl.js +1 -0
  53. package/static/assets/MailReadPage--LnQ743i.js +1 -0
  54. package/static/assets/MailSentPage-BqO4iBq6.js +1 -0
  55. package/static/assets/{McpSettingsPage-CfhBioEH.js → McpSettingsPage-BZ6GJOtk.js} +1 -1
  56. package/static/assets/MemoryEditPage-BLfdKEDu.js +13 -0
  57. package/static/assets/MemoryPage-BV0RlvUS.js +1 -0
  58. package/static/assets/{NewKnowledgePage-BUwh_DFd.js → NewKnowledgePage-SrBhXpH6.js} +1 -1
  59. package/static/assets/{NewSkillPage-B2rztwzD.js → NewSkillPage-vt-0rIkv.js} +1 -1
  60. package/static/assets/{NewTaskPage-Cvw20nug.js → NewTaskPage-CBUpwIFP.js} +2 -2
  61. package/static/assets/{NotFoundPage-CXvLVHsT.js → NotFoundPage-CWF5qOC0.js} +1 -1
  62. package/static/assets/{NotificationsSettingsPage-Df_GZ7_p.js → NotificationsSettingsPage-3ZvMrqiq.js} +1 -1
  63. package/static/assets/{PromptsSettingsPage-QTxJgO5-.js → PromptsSettingsPage-pHKoiUPI.js} +1 -1
  64. package/static/assets/{ResourceDetailPage-C9RHHVKu.js → ResourceDetailPage-CE4iDbv7.js} +1 -1
  65. package/static/assets/ResourcesPage-4_5NA4RF.js +41 -0
  66. package/static/assets/{RoleEditPage-N2-v2MXN.js → RoleEditPage-4sSELIRX.js} +1 -1
  67. package/static/assets/{RolePage-Da0kZMUH.js → RolePage-Ds17xn4X.js} +1 -1
  68. package/static/assets/{RulesSettingsPage-CSd5iz22.js → RulesSettingsPage-DnyGaden.js} +1 -1
  69. package/static/assets/RunDetailPage-D2ajvKfh.js +1 -0
  70. package/static/assets/SchedulePage-oEGct1B1.js +4 -0
  71. package/static/assets/{SkillDetailPage-QjqBAuFU.js → SkillDetailPage-mSypV_JK.js} +1 -1
  72. package/static/assets/{SkillEditPage-BB0x4VVH.js → SkillEditPage-DeI8uu3S.js} +1 -1
  73. package/static/assets/{SkillsPage-BMDNxMmZ.js → SkillsPage-Bb_dEdun.js} +2 -2
  74. package/static/assets/{SkillsSettingsPage-DcdeOlAl.js → SkillsSettingsPage-CMWf2O9y.js} +1 -1
  75. package/static/assets/SourceInput-CtyUOXOG.js +1 -0
  76. package/static/assets/{TagInput-bxFcAknC.js → TagInput-C0NyMxlY.js} +1 -1
  77. package/static/assets/{TaskDetailPage-CAmREdfh.js → TaskDetailPage-6DDI0juh.js} +1 -1
  78. package/static/assets/{TaskEditPage-BDgZtG36.js → TaskEditPage-Btc1NXtR.js} +1 -1
  79. package/static/assets/{TasksPage-BQ6eLw0T.js → TasksPage-C9TYvqRz.js} +3 -3
  80. package/static/assets/TeamEditPage-CLvNy6Ss.js +9 -0
  81. package/static/assets/TeamPage-DSWax4fa.js +1 -0
  82. package/static/assets/{TerminalPage-BhWGRGf1.js → TerminalPage-DNDHEYJZ.js} +1 -1
  83. package/static/assets/{TerminalSessionPage-Bu-WiE0d.js → TerminalSessionPage-nNCw_oDE.js} +2 -2
  84. package/static/assets/{UserPreferencesPage-B_Tu1a8h.js → UserPreferencesPage-jc1SA79x.js} +1 -1
  85. package/static/assets/UserSettingsPage-pr6n15Pz.js +1 -0
  86. package/static/assets/UtilitiesPage-CjLb989o.js +1 -0
  87. package/static/assets/{alert-C42EBWiI.js → alert-BtkLXQ3p.js} +1 -1
  88. package/static/assets/{arrow-down-CuFFg288.js → arrow-down-DnNLmXEs.js} +1 -1
  89. package/static/assets/{arrow-left-C8VbyW3d.js → arrow-left-B9NBHEkS.js} +1 -1
  90. package/static/assets/{arrow-up-down-GN3qK2mU.js → arrow-up-down-DIuMvAne.js} +1 -1
  91. package/static/assets/{arrow-up-vC1c-5gW.js → arrow-up-eMUJY7J9.js} +1 -1
  92. package/static/assets/{badge-CKwUSKzT.js → badge-BbfU_aPt.js} +1 -1
  93. package/static/assets/{browser-modal-C9VBJ_El.js → browser-modal-J9l3o5os.js} +2 -2
  94. package/static/assets/{card-DRBgMGuU.js → card-CL5bB4cs.js} +1 -1
  95. package/static/assets/{chevron-left-2sP4ienq.js → chevron-left-B-7K6MNx.js} +1 -1
  96. package/static/assets/{chevron-up-DJfyvHso.js → chevron-up-BwTmMEW2.js} +1 -1
  97. package/static/assets/{chevrons-up-DfFpzHXf.js → chevrons-up-jI6nxhrz.js} +1 -1
  98. package/static/assets/{circle-alert-DP4rtmEK.js → circle-alert-vJFSz39V.js} +1 -1
  99. package/static/assets/{circle-check-Cnp-EoKX.js → circle-check-D2LVHMl-.js} +1 -1
  100. package/static/assets/{circle-check-big-3mrGMFVn.js → circle-check-big-BwQ_q1N7.js} +1 -1
  101. package/static/assets/{circle-play-7F5AVehH.js → circle-play-CLKDBkrK.js} +1 -1
  102. package/static/assets/{circle-x-DxbiyJ6w.js → circle-x-CuUVLiI-.js} +1 -1
  103. package/static/assets/{clipboard-CQNR4_yT.js → clipboard-BHOFelnW.js} +1 -1
  104. package/static/assets/{clock-DGw3R_UL.js → clock-D-X3KCw6.js} +1 -1
  105. package/static/assets/{code-DSNMK8tD.js → code-DqYaanki.js} +1 -1
  106. package/static/assets/{download-BWL6PFiw.js → download-DeEju9jg.js} +1 -1
  107. package/static/assets/{external-link-BqUE-DMN.js → external-link-CrRz0sU-.js} +1 -1
  108. package/static/assets/{eye-BD57N1qQ.js → eye-Cx9ZGkg5.js} +1 -1
  109. package/static/assets/{folder-git-2-CW5Zi8Bm.js → folder-git-2-Cizv1NA6.js} +1 -1
  110. package/static/assets/globe-lpD9Jv31.js +6 -0
  111. package/static/assets/{index-BWktaW8U.js → index-BCYTbJRb.js} +1 -1
  112. package/static/assets/{index-BArpuuuE.js → index-BL-5Bhtg.js} +1 -1
  113. package/static/assets/{index-EpelXypg.js → index-BPdWQ0rI.js} +1 -1
  114. package/static/assets/{index-CheR43vH.js → index-BVrOTqTm.js} +1 -1
  115. package/static/assets/{index-uxv5vQZF.js → index-BknCCMZK.js} +1 -1
  116. package/static/assets/{index-CVVL2h9f.js → index-BvZJRqTz.js} +1 -1
  117. package/static/assets/index-ByTA2ZiD.js +497 -0
  118. package/static/assets/{index-CMt1ExW-.js → index-CMaK0hpv.js} +1 -1
  119. package/static/assets/{index-CMQcknsg.js → index-CkT4WgqR.js} +1 -1
  120. package/static/assets/{index-Bedu89qc.js → index-CuLP7P_G.js} +1 -1
  121. package/static/assets/{index-B9OOTqx4.js → index-D12O6wM3.js} +1 -1
  122. package/static/assets/{index-stPObw-o.js → index-DIt703WU.js} +1 -1
  123. package/static/assets/{index-CXWGFCS-.js → index-DK1gGyTZ.js} +1 -1
  124. package/static/assets/index-DVMcu9sQ.css +1 -0
  125. package/static/assets/{index-BG5vEV31.js → index-Dc9Njo8L.js} +1 -1
  126. package/static/assets/{index-B0fLM-4F.js → index-DgAcL75U.js} +1 -1
  127. package/static/assets/{index-BmTTXfmk.js → index-Djzp98Vj.js} +1 -1
  128. package/static/assets/{index-DO47L-WG.js → index-Dnj5cWsp.js} +1 -1
  129. package/static/assets/{index-X4fPPLHI.js → index-Hy3cH93B.js} +1 -1
  130. package/static/assets/{index-D4awulBm.js → index-ihWq-CVE.js} +1 -1
  131. package/static/assets/{info-DMJxIp7i.js → info-DxhTCbw1.js} +1 -1
  132. package/static/assets/{label-DxDedS8x.js → label-Dp0-28_O.js} +1 -1
  133. package/static/assets/{markdown-editor-DJ2CscSp.js → markdown-editor-DUmrf1eN.js} +3 -3
  134. package/static/assets/{message-square-DF58cqKJ.js → message-square-BPOApeM3.js} +1 -1
  135. package/static/assets/{paperclip-CHyfSVll.js → paperclip-Bfjc1WLZ.js} +1 -1
  136. package/static/assets/{pause-B-ouFhaQ.js → pause-Bfz-QQZp.js} +1 -1
  137. package/static/assets/{pipeline-builders-Bkf0wt_O.js → pipeline-builders-DrEjlsbH.js} +1 -1
  138. package/static/assets/{play-B0y1weCV.js → play-fOwEoIcu.js} +1 -1
  139. package/static/assets/{radio-group-DFNQiPDU.js → radio-group-B8RB7N01.js} +1 -1
  140. package/static/assets/{refresh-cw-5y5jTc6x.js → refresh-cw-Cj_5MZiJ.js} +1 -1
  141. package/static/assets/{search-B5deRThk.js → search-BgbqRUnf.js} +1 -1
  142. package/static/assets/{select-BzOa_wZx.js → select-CfwLZl55.js} +1 -1
  143. package/static/assets/server-u9FLHclt.js +6 -0
  144. package/static/assets/{switch-Bf2z8aaj.js → switch-CX_Inx_p.js} +1 -1
  145. package/static/assets/{tabs-DkdBSep3.js → tabs-Bj0YyeRI.js} +1 -1
  146. package/static/assets/{tag-gRsTk0jY.js → tag-rYG4CdRx.js} +1 -1
  147. package/static/assets/terminal-preview-BNm5-Umi.js +1 -0
  148. package/static/assets/triangle-alert-C0ovMJwZ.js +6 -0
  149. package/static/assets/{use-terminal-D6Qe1nwM.js → use-terminal-D1UnvAVs.js} +1 -1
  150. package/static/assets/{video-DXo9sCfT.js → video-CuyRES-H.js} +1 -1
  151. package/static/index.html +2 -2
  152. package/static/assets/ActivityPage-BaSoKgwZ.js +0 -1
  153. package/static/assets/ArchitectureEditPage-MYU7btLs.js +0 -21
  154. package/static/assets/ArchitecturePage-CGqWy8b1.js +0 -1
  155. package/static/assets/CodePage-C_bzfOnI.js +0 -2
  156. package/static/assets/IntegrationsSettingsPage-Cw6ItrNf.js +0 -1
  157. package/static/assets/JobDetailPage-DLSD4HiU.js +0 -1
  158. package/static/assets/KnowledgeDetailPage-DY8PpD9X.js +0 -1
  159. package/static/assets/KnowledgeEditPage-B28N-7vM.js +0 -1
  160. package/static/assets/MailInboxPage-DDYg0W70.js +0 -1
  161. package/static/assets/MailProcessingModal-CXIrtSz0.js +0 -6
  162. package/static/assets/MailReadPage-CVz6oD-y.js +0 -1
  163. package/static/assets/MailSentPage-ClaVWZCR.js +0 -1
  164. package/static/assets/ProjectEditPage-DKf6ZoiG.js +0 -11
  165. package/static/assets/ProjectPage-CHhx9s1k.js +0 -1
  166. package/static/assets/ResourcesPage-BI8tfYZ2.js +0 -41
  167. package/static/assets/SchedulePage-CS8g2Db-.js +0 -4
  168. package/static/assets/SourceInput-rc4KSqcv.js +0 -1
  169. package/static/assets/UserSettingsPage-BnEGtrGo.js +0 -1
  170. package/static/assets/UtilitiesPage-k7ABCAig.js +0 -1
  171. package/static/assets/index-Cht-fo9a.css +0 -1
  172. package/static/assets/index-DB2Tq9wz.js +0 -487
  173. package/static/assets/terminal-preview-BfrUN2ok.js +0 -1
@@ -1,51 +1,41 @@
1
- import{c as y,u as Re,a as Le,r as l,j as e,D as De,b as _e,d as te,e as f,f as ae,g as ne,S as re,B as d,C as le,I as B,h as G,i as qe,G as Ie,F as Pe,k as ue,Z as ze,l as We,m as Fe,T as ce,n as Ve,o as Be,L as N,P as Ee,M as $e,K as A,p as g,A as Ke}from"./index-DB2Tq9wz.js";import{C as x,a as u,b as R,c as L,d as ie}from"./card-DRBgMGuU.js";import{B as Ge}from"./badge-CKwUSKzT.js";import{g as He}from"./status-utils-PwF3DXLL.js";import{L as Oe}from"./label-DxDedS8x.js";import{S as oe,a as de,b as me,c as he,d as E}from"./select-BzOa_wZx.js";import{u as Ye}from"./use-terminal-D6Qe1nwM.js";import{T as Qe}from"./terminal-preview-BfrUN2ok.js";import{C as Ue}from"./circle-check-Cnp-EoKX.js";import{C as Ze}from"./chevron-left-2sP4ienq.js";import{S as Je}from"./search-B5deRThk.js";import{C as Xe}from"./code-DSNMK8tD.js";import{F as es}from"./folder-git-2-CW5Zi8Bm.js";import{E as ss}from"./external-link-BqUE-DMN.js";import{P as ts}from"./play-B0y1weCV.js";import{C as as}from"./clock-DGw3R_UL.js";import{C as ns}from"./circle-check-big-3mrGMFVn.js";import"./index-Bedu89qc.js";import"./chevron-up-DJfyvHso.js";import"./xterm-DTxiCjtJ.js";/**
1
+ import{c as b,u as Re,a as Le,r as l,j as e,D as De,b as Ie,d as te,e as f,f as ae,g as ne,S as re,B as d,C as le,I as B,h as G,i as Pe,G as _e,F as qe,k as ue,Z as We,l as ze,m as Fe,T as ce,n as Ve,o as Be,L as v,P as Ee,M as Ke,K as A,p as g,q as $e,A as Ge}from"./index-ByTA2ZiD.js";import{C as h,a as u,b as R,c as L,d as ie}from"./card-CL5bB4cs.js";import{B as He}from"./badge-BbfU_aPt.js";import{g as Oe}from"./status-utils-PwF3DXLL.js";import{L as Ye}from"./label-Dp0-28_O.js";import{S as oe,a as de,b as me,c as xe,d as E}from"./select-CfwLZl55.js";import{u as Qe}from"./use-terminal-D1UnvAVs.js";import{T as Ue}from"./terminal-preview-BNm5-Umi.js";import{C as Ze}from"./circle-check-D2LVHMl-.js";import{C as Je}from"./chevron-left-B-7K6MNx.js";import{S as Xe}from"./search-BgbqRUnf.js";import{G as es}from"./globe-lpD9Jv31.js";import{C as ss}from"./code-DqYaanki.js";import{F as ts}from"./folder-git-2-Cizv1NA6.js";import{E as as}from"./external-link-CrRz0sU-.js";import{P as ns}from"./play-fOwEoIcu.js";import{C as rs}from"./clock-D-X3KCw6.js";import{C as ls}from"./circle-check-big-BwQ_q1N7.js";import"./index-CuLP7P_G.js";import"./chevron-up-BwTmMEW2.js";import"./xterm-DTxiCjtJ.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const rs=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],ls=y("brain",rs);/**
6
+ */const cs=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],is=b("chart-line",cs);/**
7
7
  * @license lucide-react v0.542.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const cs=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],is=y("chart-line",cs);/**
11
+ */const os=[["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"}]],ds=b("database",os);/**
12
12
  * @license lucide-react v0.542.0 - ISC
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const os=[["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"}]],ds=y("database",os);/**
16
+ */const ms=[["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"}]],xs=b("file-chart-column-increasing",ms);/**
17
17
  * @license lucide-react v0.542.0 - ISC
18
18
  *
19
19
  * This source code is licensed under the ISC license.
20
20
  * See the LICENSE file in the root directory of this source tree.
21
- */const ms=[["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"}]],hs=y("file-chart-column-increasing",ms);/**
21
+ */const hs=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]],W=b("file-plus-2",hs);/**
22
22
  * @license lucide-react v0.542.0 - ISC
23
23
  *
24
24
  * This source code is licensed under the ISC license.
25
25
  * See the LICENSE file in the root directory of this source tree.
26
- */const xs=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]],z=y("file-plus-2",xs);/**
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
27
  * @license lucide-react v0.542.0 - ISC
28
28
  *
29
29
  * This source code is licensed under the ISC license.
30
30
  * See the LICENSE file in the root directory of this source tree.
31
- */const us=[["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"}]],ps=y("globe",us);/**
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
32
  * @license lucide-react v0.542.0 - ISC
33
33
  *
34
34
  * This source code is licensed under the ISC license.
35
35
  * See the LICENSE file in the root directory of this source tree.
36
- */const fs=[["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"}]],js=y("palette",fs);/**
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
37
  * @license lucide-react v0.542.0 - ISC
38
38
  *
39
39
  * This source code is licensed under the ISC license.
40
40
  * See the LICENSE file in the root directory of this source tree.
41
- */const gs=[["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"}]],ys=y("rocket",gs);/**
42
- * @license lucide-react v0.542.0 - ISC
43
- *
44
- * This source code is licensed under the ISC license.
45
- * See the LICENSE file in the root directory of this source tree.
46
- */const vs=[["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"}]],Ns=y("test-tube",vs);/**
47
- * @license lucide-react v0.542.0 - ISC
48
- *
49
- * This source code is licensed under the ISC license.
50
- * See the LICENSE file in the root directory of this source tree.
51
- */const bs=[["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"}]],ws=y("wand-sparkles",bs),ks={Rocket:ys,FolderGit2:es,FileBarChart:hs,FilePlus2:z,Calendar:Fe,Sparkles:G,Settings:We,Zap:ze,Code:Xe,Bot:ue,FileText:Pe,GitBranch:Ie,ChartLine:is,Shield:qe,Database:ds,TestTube:Ns,Palette:js,Globe:ps},Cs={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"}},xe={setup:"Setup",analysis:"Analysis",automation:"Automation",coding:"Coding"};function $(i){return ks[i]||G}function K(i){return Cs[i||"blue"]}function Ss(i,b){let m=i.replace(/\{\{#if (\w+)\}\}(.*?)\{\{\/if\}\}/g,(S,j,M)=>b[j]?.trim()?M.replace(/\{\{(\w+)\}\}/g,(w,t)=>b[t]||""):"");return m=m.replace(/\{\{(\w+)\}\}/g,(S,j)=>b[j]||""),m}function Ms({open:i,onOpenChange:b,workflows:m}){const S=Re(),{loading:j,createSession:M,destroySession:D}=Ye(),{toast:w}=Le(),[t,n]=l.useState(null),[h,v]=l.useState(0),[o,_]=l.useState(""),[r,k]=l.useState("all"),[p,T]=l.useState({}),[H,O]=l.useState(!1),[q,Y]=l.useState(null),[pe,Q]=l.useState(null),[W,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=o===""||s.title.toLowerCase().includes(o.toLowerCase())||s.description.toLowerCase().includes(o.toLowerCase()),c=r==="all"||s.category===r;return a&&c}),[m,o,r]),Z=l.useMemo(()=>o||r!=="all"?[]:m.filter(s=>s.featured),[m,o,r]),J=l.useMemo(()=>o||r!=="all"?C:C.filter(s=>!s.featured),[C,o,r]),X=s=>{n(s),v(0);const a={};s.params?.forEach(c=>{c.defaultValue&&(a[c.id]=c.defaultValue)}),T(a)},je=()=>{h>0?v(h-1):(n(null),T({}))},ge=()=>{t&&h<t.steps.length-1&&v(h+1)},I=()=>{n(null),v(0),_(""),k("all"),T({}),Y(null),Q(null),b(!1)},P=(s,a)=>{T(c=>({...c,[s]:a}))},F=l.useMemo(()=>t?.params?t.params.filter(s=>s.required).every(s=>p[s.id]?.trim()):!0,[t,p]),V=l.useMemo(()=>t?.command?Ss(t.command,p):"",[t,p]),ye=async()=>{if(!V)return;const s=`wizard-${Date.now()}`;O(!0);try{const a=await M(s,V);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=$(s.icon),c=K(s.color);return e.jsx(x,{className:f("cursor-pointer transition-all duration-200 hover:scale-[1.02]",c.bg,c.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",c.icon)})}),e.jsx("h3",{className:"text-sm font-semibold line-clamp-2",children:s.title})]})},s.id)},Ne=s=>{const a=$(s.icon),c=K(s.color);return e.jsx(x,{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",c.bg),children:e.jsx(a,{className:f("h-5 w-5",c.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(Je,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(B,{placeholder:"Search workflows...",value:o,onChange:s=>_(s.target.value),className:"pl-9"})]}),e.jsxs(oe,{value:r,onValueChange:k,children:[e.jsx(de,{children:e.jsx(me,{placeholder:"All categories"})}),e.jsxs(he,{children:[e.jsx(E,{value:"all",children:"All categories"}),U.map(s=>e.jsx(E,{value:s,children:xe[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:xe[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||o||r!=="all")&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-muted-foreground mb-3",children:o||r!=="all"?`Results (${C.length})`:"All Workflows"}),e.jsx("div",{className:"space-y-2",children:C.length>0?(o||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(x,{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(x,{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(x,{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(Oe,{htmlFor:s.id,children:[s.label,s.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),s.type==="text"&&e.jsx(B,{id:s.id,placeholder:s.placeholder,value:p[s.id]||"",onChange:a=>P(s.id,a.target.value)}),s.type==="textarea"&&e.jsx(Be,{id:s.id,placeholder:s.placeholder,value:p[s.id]||"",onChange:a=>P(s.id,a.target.value),rows:4}),s.type==="number"&&e.jsx(B,{id:s.id,type:"number",placeholder:s.placeholder,value:p[s.id]||"",onChange:a=>P(s.id,a.target.value)}),s.type==="select"&&s.options&&e.jsxs(oe,{value:p[s.id]||"",onValueChange:a=>P(s.id,a),children:[e.jsx(de,{children:e.jsx(me,{placeholder:s.placeholder||"Select..."})}),e.jsx(he,{children:s.options.map(a=>e.jsx(E,{value:a.value,children:a.label},a.value))})]})]},s.id))}):null,Ce=()=>t?.command?q?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(ce,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("h4",{className:"text-sm font-semibold",children:"Terminal Output"})]}),e.jsx(Qe,{sessionId:q,heightPx:220,maxScrollback:500})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(d,{onClick:()=>{I(),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()=>{q&&await D(q),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(x,{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(x,{children:e.jsxs(u,{className:"p-4",children:[e.jsxs("button",{type:"button",onClick:()=>fe(!W),className:"flex items-center justify-between w-full text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("h4",{className:"text-sm font-semibold",children:"Command"})]}),e.jsx(Ve,{className:f("h-4 w-4 text-muted-foreground transition-transform",W&&"rotate-180")})]}),W&&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:V})})]})})]}):null,Se=()=>{if(!t)return null;const s=t.steps[h],a=s.type||"info",c=h===t.steps.length-1,Me=$(t.icon),ee=K(t.color),Te=()=>{switch(a){case"params":return ke();case"confirm":return Ce();case"info":default:return we(s)}},Ae=c&&!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 ",h+1," of ",t.steps.length]})]})]}),e.jsx("div",{className:"flex items-center space-x-2 pt-2",children:t.steps.map((Ls,se)=>e.jsx("div",{className:f("h-1.5 flex-1 rounded-full transition-colors",se<=h?"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(x,{className:"bg-primary/5 border-primary/20",children:e.jsxs(u,{className:"p-4 flex items-center space-x-3",children:[e.jsx(Ue,{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:I,children:"Cancel"}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(d,{variant:"outline",onClick:je,children:[e.jsx(Ze,{className:"mr-2 h-4 w-4"}),h===0?"Back to Workflows":"Previous"]}),a!=="confirm"&&(c?e.jsx(d,{onClick:I,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(De,{open:i,onOpenChange:b,children:e.jsx(_e,{className:"max-w-4xl max-h-[90vh]",children:t?Se():be()})})}const Ts=[{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/registry/blueprints/coconut-vite-starter-1.0.1.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"}]}],As={workflows:Ts},Rs=As.workflows;function Js(){const[i,b]=l.useState({total:0,inReview:0,approved:0}),[m,S]=l.useState([]),[j,M]=l.useState(!0),[D,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="/tasks/new"),(n.metaKey||n.ctrlKey)&&n.key==="u"&&(n.preventDefault(),window.location.href="/knowledge"),(n.metaKey||n.ctrlKey)&&n.key==="e"&&(n.preventDefault(),window.location.href="/agents")};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[]),l.useEffect(()=>{(async()=>{try{const h=await(await fetch(`${Ke}/api/v1/tasks`)).json();if(h.success&&h.data){const v=h.data,o={total:v.length,inReview:v.filter(r=>r.status==="review").length,approved:v.filter(r=>r.status==="ready"||r.status==="done").length},_=v.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);b(o),S(_)}}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 and take quick actions"})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(N,{to:"/tasks",children:e.jsxs(x,{className:"hover:bg-accent hover:border-accent-foreground/20 transition-colors cursor-pointer",children:[e.jsxs(R,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(L,{className:"text-sm font-medium",children:"All Tasks"}),e.jsx(z,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(u,{children:[e.jsx("div",{className:"text-2xl font-bold",children:j?"...":i.total}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i.total===0?"No tasks yet":`${i.total} task${i.total!==1?"s":""}`})]})]})}),e.jsx(N,{to:"/tasks?status=review",children:e.jsxs(x,{className:"hover:bg-accent hover:border-accent-foreground/20 transition-colors cursor-pointer",children:[e.jsxs(R,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(L,{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?"...":i.inReview}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Awaiting approval"})]})]})}),e.jsx(N,{to:"/tasks?status=ready",children:e.jsxs(x,{className:"hover:bg-accent hover:border-accent-foreground/20 transition-colors cursor-pointer",children:[e.jsxs(R,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(L,{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?"...":i.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(x,{children:[e.jsxs(R,{children:[e.jsx(L,{children:"Recent Tasks"}),e.jsx(ie,{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(N,{to:`/tasks/${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(Ge,{variant:He(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(N,{to:"/tasks",children:"View All Tasks"})})})]}):e.jsxs("div",{className:"text-center py-6",children:[e.jsx(z,{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(N,{to:"/tasks/new",children:[e.jsx(Ee,{className:"mr-2 h-4 w-4"}),"New Task"]})})]})})]}),e.jsxs(x,{className:"flex flex-col",children:[e.jsxs(R,{children:[e.jsx(L,{children:"Quick Actions"}),e.jsx(ie,{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($e,{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(ws,{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(N,{to:"/tasks/new",children:[e.jsxs("span",{className:"flex items-center",children:[e.jsx(z,{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(N,{to:"/knowledge",children:[e.jsxs("span",{className:"flex items-center",children:[e.jsx(ls,{className:"mr-2 h-4 w-4"}),"View Knowledge"]}),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(N,{to:"/agents",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(Ms,{open:D,onOpenChange:w,workflows:Rs})]})}export{Js as default};
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:ts,FileBarChart:xs,FilePlus2:W,Calendar:Fe,Sparkles:G,Settings:ze,Zap:We,Code:ss,Bot:ue,FileText:qe,GitBranch:_e,ChartLine:is,Shield:Pe,Database:ds,TestTube:ys,Palette:ps,Globe:es},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(i){return bs[i]||G}function $(i){return ws[i||"blue"]}function ks(i,N){let m=i.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:i,onOpenChange:N,workflows:m}){const S=Re(),{loading:j,createSession:M,destroySession:D}=Qe(),{toast:w}=Le(),[t,n]=l.useState(null),[x,y]=l.useState(0),[o,I]=l.useState(""),[r,k]=l.useState("all"),[p,T]=l.useState({}),[H,O]=l.useState(!1),[P,Y]=l.useState(null),[pe,Q]=l.useState(null),[z,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=o===""||s.title.toLowerCase().includes(o.toLowerCase())||s.description.toLowerCase().includes(o.toLowerCase()),c=r==="all"||s.category===r;return a&&c}),[m,o,r]),Z=l.useMemo(()=>o||r!=="all"?[]:m.filter(s=>s.featured),[m,o,r]),J=l.useMemo(()=>o||r!=="all"?C:C.filter(s=>!s.featured),[C,o,r]),X=s=>{n(s),y(0);const a={};s.params?.forEach(c=>{c.defaultValue&&(a[c.id]=c.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),I(""),k("all"),T({}),Y(null),Q(null),N(!1)},q=(s,a)=>{T(c=>({...c,[s]:a}))},F=l.useMemo(()=>t?.params?t.params.filter(s=>s.required).every(s=>p[s.id]?.trim()):!0,[t,p]),V=l.useMemo(()=>t?.command?ks(t.command,p):"",[t,p]),ye=async()=>{if(!V)return;const s=`wizard-${Date.now()}`;O(!0);try{const a=await M(s,V);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),c=$(s.color);return e.jsx(h,{className:f("cursor-pointer transition-all duration-200 hover:scale-[1.02]",c.bg,c.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",c.icon)})}),e.jsx("h3",{className:"text-sm font-semibold line-clamp-2",children:s.title})]})},s.id)},Ne=s=>{const a=K(s.icon),c=$(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",c.bg),children:e.jsx(a,{className:f("h-5 w-5",c.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(Xe,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(B,{placeholder:"Search workflows...",value:o,onChange:s=>I(s.target.value),className:"pl-9"})]}),e.jsxs(oe,{value:r,onValueChange:k,children:[e.jsx(de,{children:e.jsx(me,{placeholder:"All categories"})}),e.jsxs(xe,{children:[e.jsx(E,{value:"all",children:"All categories"}),U.map(s=>e.jsx(E,{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||o||r!=="all")&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-muted-foreground mb-3",children:o||r!=="all"?`Results (${C.length})`:"All Workflows"}),e.jsx("div",{className:"space-y-2",children:C.length>0?(o||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(Ye,{htmlFor:s.id,children:[s.label,s.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),s.type==="text"&&e.jsx(B,{id:s.id,placeholder:s.placeholder,value:p[s.id]||"",onChange:a=>q(s.id,a.target.value)}),s.type==="textarea"&&e.jsx(Be,{id:s.id,placeholder:s.placeholder,value:p[s.id]||"",onChange:a=>q(s.id,a.target.value),rows:4}),s.type==="number"&&e.jsx(B,{id:s.id,type:"number",placeholder:s.placeholder,value:p[s.id]||"",onChange:a=>q(s.id,a.target.value)}),s.type==="select"&&s.options&&e.jsxs(oe,{value:p[s.id]||"",onValueChange:a=>q(s.id,a),children:[e.jsx(de,{children:e.jsx(me,{placeholder:s.placeholder||"Select..."})}),e.jsx(xe,{children:s.options.map(a=>e.jsx(E,{value:a.value,children:a.label},a.value))})]})]},s.id))}):null,Ce=()=>t?.command?P?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(ce,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("h4",{className:"text-sm font-semibold",children:"Terminal Output"})]}),e.jsx(Ue,{sessionId:P,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(as,{className:"h-4 w-4 mr-2"}),"Open in Terminal"]}),e.jsx(d,{onClick:async()=>{P&&await D(P),_()},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(ns,{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(!z),className:"flex items-center justify-between w-full text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("h4",{className:"text-sm font-semibold",children:"Command"})]}),e.jsx(Ve,{className:f("h-4 w-4 text-muted-foreground transition-transform",z&&"rotate-180")})]}),z&&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:V})})]})})]}):null,Se=()=>{if(!t)return null;const s=t.steps[x],a=s.type||"info",c=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=c&&!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(Ze,{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(Je,{className:"mr-2 h-4 w-4"}),x===0?"Back to Workflows":"Previous"]}),a!=="confirm"&&(c?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(De,{open:i,onOpenChange:N,children:e.jsx(Ie,{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/registry/blueprints/coconut-vite-starter-1.0.1.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 Zs(){const[i,N]=l.useState({total:0,inReview:0,approved:0}),[m,S]=l.useState([]),[j,M]=l.useState(!0),[D,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="/tasks/new"),(n.metaKey||n.ctrlKey)&&n.key==="u"&&(n.preventDefault(),window.location.href="/knowledge"),(n.metaKey||n.ctrlKey)&&n.key==="e"&&(n.preventDefault(),window.location.href="/agents")};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[]),l.useEffect(()=>{(async()=>{try{const x=await(await fetch(`${Ge}/api/v1/tasks`)).json();if(x.success&&x.data){const y=x.data,o={total:y.length,inReview:y.filter(r=>r.status==="review").length,approved:y.filter(r=>r.status==="ready"||r.status==="done").length},I=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(o),S(I)}}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 agent tasks and take quick actions"})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(v,{to:"/tasks",children:e.jsxs(h,{className:"hover:bg-accent hover:border-accent-foreground/20 transition-colors cursor-pointer",children:[e.jsxs(R,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(L,{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?"...":i.total}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i.total===0?"No tasks yet":`${i.total} task${i.total!==1?"s":""}`})]})]})}),e.jsx(v,{to:"/tasks?status=review",children:e.jsxs(h,{className:"hover:bg-accent hover:border-accent-foreground/20 transition-colors cursor-pointer",children:[e.jsxs(R,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(L,{className:"text-sm font-medium",children:"In Review"}),e.jsx(rs,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(u,{children:[e.jsx("div",{className:"text-2xl font-bold",children:j?"...":i.inReview}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Awaiting approval"})]})]})}),e.jsx(v,{to:"/tasks?status=ready",children:e.jsxs(h,{className:"hover:bg-accent hover:border-accent-foreground/20 transition-colors cursor-pointer",children:[e.jsxs(R,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(L,{className:"text-sm font-medium",children:"Ready / Done"}),e.jsx(ls,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(u,{children:[e.jsx("div",{className:"text-2xl font-bold",children:j?"...":i.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(R,{children:[e.jsx(L,{children:"Recent Tasks"}),e.jsx(ie,{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:`/tasks/${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(He,{variant:Oe(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:"/tasks",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:"/tasks/new",children:[e.jsx(Ee,{className:"mr-2 h-4 w-4"}),"New Task"]})})]})})]}),e.jsxs(h,{className:"flex flex-col",children:[e.jsxs(R,{children:[e.jsx(L,{children:"Quick Actions"}),e.jsx(ie,{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(Ke,{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:"/tasks/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:"/knowledge",children:[e.jsxs("span",{className:"flex items-center",children:[e.jsx($e,{className:"mr-2 h-4 w-4"}),"View Knowledge"]}),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:"/agents",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:D,onOpenChange:w,workflows:Ts})]})}export{Zs as default};
@@ -1,9 +1,9 @@
1
- import{c as le,A as l,bF as ws,r as n,a as vs,ac as ys,j as e,L as ee,l as $e,B as o,G as D,aa as Ns,X as Cs,I as k,n as Me,E as Be,D as se,b as te,d as ae,f as re,g as ne,bx as ks,W as Oe}from"./index-DB2Tq9wz.js";import{C as ie}from"./card-DRBgMGuU.js";import{L as Re}from"./label-DxDedS8x.js";import{T as Ss,a as Ps,b as Ge,c as We}from"./tabs-DkdBSep3.js";import{C as Ts}from"./circle-check-Cnp-EoKX.js";import{C as As}from"./circle-x-DxbiyJ6w.js";import{A as Ds}from"./arrow-down-CuFFg288.js";import{A as Es}from"./arrow-up-vC1c-5gW.js";import{R as ze}from"./refresh-cw-5y5jTc6x.js";import{C as ce}from"./circle-alert-DP4rtmEK.js";import{C as Ue}from"./chevron-up-DJfyvHso.js";import{F as oe}from"./folder-git-2-CW5Zi8Bm.js";/**
1
+ import{c as le,A as l,bH as ws,r as n,a as vs,ac as ys,j as e,L as ee,l as Fe,B as o,G as D,aa as Ns,X as Cs,I as k,n as Me,H as Be,D as se,b as te,d as ae,f as re,g as ne,bE as ks,Y as Oe}from"./index-ByTA2ZiD.js";import{C as ie}from"./card-CL5bB4cs.js";import{L as Re}from"./label-Dp0-28_O.js";import{T as Ss,a as Ps,b as Ge,c as We}from"./tabs-Bj0YyeRI.js";import{C as Ts}from"./circle-check-D2LVHMl-.js";import{C as As}from"./circle-x-CuUVLiI-.js";import{A as Ds}from"./arrow-down-DnNLmXEs.js";import{A as Es}from"./arrow-up-eMUJY7J9.js";import{R as ze}from"./refresh-cw-Cj_5MZiJ.js";import{C as ce}from"./circle-alert-vJFSz39V.js";import{C as Ue}from"./chevron-up-BwTmMEW2.js";import{F as oe}from"./folder-git-2-Cizv1NA6.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const Fs=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],$s=le("git-commit-horizontal",Fs);/**
6
+ */const $s=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],Fs=le("git-commit-horizontal",$s);/**
7
7
  * @license lucide-react v0.542.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
@@ -13,4 +13,4 @@ import{c as le,A as l,bF as ws,r as n,a as vs,ac as ys,j as e,L as ee,l as $e,B
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const Bs=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]],Le=le("git-pull-request",Bs);let S;async function Os(){if(S!==void 0)return S;try{const m=await fetch(`${l}/api/v1/config`);if(!m.ok)return S=null,null;const r=(await m.json())?.data||{},f=r?.coconut?.id||r?.cloud?.coconutId||r?.cloud?.coconut_id;return S=typeof f=="string"&&f.trim()?f.trim():null,S}catch(m){return console.error("[github-token] Failed to load Coconut ID",m),S=null,null}}async function Rs(m){const x=await fetch(`${ws}/api/v1/git/token`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({coconutId:m})});if(!x.ok){let P="Failed to request GitHub token from control plane";if(x.status===401||x.status===403)throw new Error("Please sign in to app.coconut.dev and then retry the action.");try{const y=await x.json();P=y?.error?.message||y?.message||P}catch{}throw new Error(P)}const r=await x.json(),f=r?.token||r?.data?.token,b=r?.expiresAt||r?.data?.expiresAt;if(!f||!b)throw new Error("Control plane response missing token or expiresAt");return{token:f,expiresAt:b}}async function Gs(m,x){const r=await fetch(`${l}/api/v1/git/providers/github/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:m,expiresAt:x})}),f=await r.json().catch(()=>({}));if(!r.ok||!f?.success){const b=f?.error?.message||"Failed to store GitHub token on Coconut";throw new Error(b)}}async function Ws(){const m=await Os();if(!m)throw new Error("Coconut ID not configured. Reconnect via Settings → Git.");const{token:x,expiresAt:r}=await Rs(m);return await Gs(x,r),{tokenFetched:!0,message:r}}function Qs(){const[m,x]=n.useState(!0),[r,f]=n.useState(null),[b,P]=n.useState([]),[y,_e]=n.useState([]),[E,de]=n.useState(""),[g,F]=n.useState(""),[me,Je]=n.useState("main"),[ue,c]=n.useState(null),{toast:i}=vs(),{refresh:J}=ys(),[he,xe]=n.useState(!1),[$,M]=n.useState(!1),[T,ge]=n.useState(null),[A,fe]=n.useState(null),[He,pe]=n.useState(null),[be,je]=n.useState(null),[we,ve]=n.useState(null),[qe,ye]=n.useState(null),[B,Ve]=n.useState("merge"),[H,Ke]=n.useState("merge"),[Xe,Ye]=n.useState("../worktrees"),[O,Qe]=n.useState("github"),[h,Ne]=n.useState(null),[Ze,w]=n.useState(!1),[es,R]=n.useState(!1),[G,q]=n.useState(""),[W,V]=n.useState(""),[Ce,ke]=n.useState(!1),[v,K]=n.useState(""),[z,U]=n.useState(!1),[p,N]=n.useState(new Set),[I,ss]=n.useState(!1),[L,ts]=n.useState(!1),[as,_]=n.useState(!1),[C,X]=n.useState(null),[Y,Se]=n.useState(null),Pe=n.useCallback(async()=>{if(O!=="github"||h?.provider!=="github")return!0;if(h?.authenticated&&h?.expiresAt){const t=new Date(h.expiresAt).getTime(),a=Date.now(),d=300*1e3;if(t>a+d)return!0}const s=i({title:"Fetching GitHub token",description:"Contacting control plane…"});try{const{message:t}=await Ws();return i({title:"GitHub token ready",description:t?`Valid until ${new Date(t).toLocaleString()}`:"Token fetched successfully."}),Ne(a=>({...a,authenticated:!0,error:void 0,expiresAt:t??a?.expiresAt,provider:"github"})),!0}catch(t){const a=t?.message?`${t.message} Visit Settings → Git to reconnect.`:"Visit Settings → Git to connect GitHub.";return i({title:"GitHub token unavailable",description:a,variant:"destructive"}),c(t?.message||"GitHub authorization required. Visit Settings → Git to reconnect."),!1}finally{s?.dismiss?.()}},[O,h?.provider,h?.authenticated,h?.expiresAt,i]),u=async()=>{x(!0),c(null);try{const[s,t,a,d,Z]=await Promise.all([fetch(`${l}/api/v1/git/status`).then(j=>j.json()),fetch(`${l}/api/v1/git/branches`).then(j=>j.json()),fetch(`${l}/api/v1/git/worktrees`).then(j=>j.json()),fetch(`${l}/api/v1/git/settings`).then(j=>j.json()).catch(()=>null),fetch(`${l}/api/v1/git/auth-status`).then(j=>j.json()).catch(()=>null)]);s.success&&f(s.data),t.success&&P(t.data),a.success&&_e(a.data),d&&d.success&&d.data?.defaultWorktreePath&&(Ye(d.data.defaultWorktreePath),d.data.authMode&&Qe(d.data.authMode)),Z&&Z.success&&Ne(Z.data)}catch(s){c(s.message),i({title:"Failed to refresh",description:s.message,variant:"destructive"})}finally{x(!1)}};n.useEffect(()=>{u()},[]);const Te=n.useMemo(()=>{const s=r?.branch?.toLowerCase();return s==="main"||s==="master"},[r?.branch]),Q=n.useMemo(()=>{const s=!!v.trim(),t=p.size>0;return s&&t},[v,p]),rs=s=>s==="??"||s.includes("U")?"U":s.includes("R")?"R":s.includes("C")?"C":s.includes("D")?"D":s.includes("A")?"A":s.includes("M")?"M":s||"?",ns=(s,t)=>{N(a=>{const d=new Set(a);return t?d.add(s):d.delete(s),d})},is=()=>{r?.changes&&N(new Set(r.changes.map(s=>s.path)))},cs=()=>{N(new Set)},os=()=>{r?.changes&&(r.changes.every(t=>p.has(t.path))?cs():is())},ls=n.useMemo(()=>!r?.changes||r.changes.length===0?!1:r.changes.every(s=>p.has(s.path)),[r?.changes,p]),ds=s=>{X(s),_(!0)},ms=async()=>{if(C){Se(C),c(null);try{const s=await fetch(`${l}/api/v1/git/discard`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:C})}).then(t=>t.json());if(!s.success)throw new Error(s.error?.message||"Failed to discard file");N(t=>{const a=new Set(t);return a.delete(C),a}),i({title:"File discarded",description:C}),_(!1),X(null),await u(),await J()}catch(s){c(s.message),i({title:"Discard failed",description:s.message,variant:"destructive"})}finally{Se(null)}}},us=async()=>{if(E.trim()){xe(!0),c(null);try{const s=await fetch(`${l}/api/v1/git/worktrees`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:E,from:"main"})}).then(t=>t.json());if(!s.success)throw new Error(s.error?.message||"Failed to create worktree");de(""),await u(),i({title:"Worktree created",description:s.data?.added?.branch})}catch(s){c(s.message),i({title:"Create failed",description:s.message,variant:"destructive"})}xe(!1)}},Ae=async s=>{if(c(null),!(O==="github"&&h?.provider==="github"&&!await Pe())){try{ge(s||"");const t=s?`/api/v1/git/worktrees/${encodeURIComponent(s)}/push`:"/api/v1/git/push",a=await fetch(`${l}${t}`,{method:"POST"}).then(d=>d.json());if(!a.success)throw new Error(a.error?.message||"Push failed");i({title:"Pushed",description:s?`Worktree ${s}`:"Current branch"}),await u()}catch(t){const a=t.message||"",d=a.includes("Authentication")||a.includes("could not read Username")||a.includes("could not read Password")||a.includes("terminal prompts disabled");c(a),i({title:"Push failed",description:a,variant:"destructive"}),d&&w(!0)}ge(null)}},De=async s=>{if(c(null),!(O==="github"&&h?.provider==="github"&&!await Pe())){try{fe(s||"");const t=s?`/api/v1/git/worktrees/${encodeURIComponent(s)}/pull`:"/api/v1/git/pull",a=await fetch(`${l}${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({strategy:H})}).then(d=>d.json());if(!a.success)throw new Error(a.error?.message||"Pull failed");await u(),i({title:"Pulled",description:`${s?`Worktree ${s}`:"Current branch"} (${H})`})}catch(t){const a=t.message||"",d=a.includes("Authentication")||a.includes("could not read Username")||a.includes("could not read Password")||a.includes("terminal prompts disabled");c(a),i({title:"Pull failed",description:a,variant:"destructive"}),d&&w(!0)}fe(null)}},hs=async s=>{if(confirm(`Remove worktree ${s}?`)){c(null);try{pe(s);const t=await fetch(`${l}/api/v1/git/worktrees/${encodeURIComponent(s)}`,{method:"DELETE"}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Failed to remove worktree");await u(),i({title:"Worktree removed",description:s})}catch(t){c(t.message),i({title:"Remove failed",description:t.message,variant:"destructive"})}pe(t=>t===s?null:t)}},xs=async()=>{if(!G||!W){i({title:"Error",description:"Username and password are required",variant:"destructive"});return}ke(!0);try{const t=await(await fetch(`${l}/api/v1/git/credentials`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:G,password:W})})).json();if(!t.success)throw new Error(t.error?.message||"Failed to save credentials");i({title:"Success",description:"Credentials saved successfully"}),w(!1),q(""),V(""),await u()}catch(s){i({title:"Error",description:s?.message||"Failed to save credentials",variant:"destructive"})}finally{ke(!1)}},gs=async()=>{if(g.trim()){M(!0),c(null);try{const s=await fetch(`${l}/api/v1/git/branches`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:g,from:me})}).then(t=>t.json());if(!s.success)throw new Error(s.error?.message||"Failed to create branch");F(""),await u(),i({title:"Branch created",description:g})}catch(s){c(s.message),i({title:"Create failed",description:s.message,variant:"destructive"})}M(!1)}},fs=async s=>{je(s),c(null);try{const t=await fetch(`${l}/api/v1/git/branches/${encodeURIComponent(s)}/switch`,{method:"POST"}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Failed to switch branch");await u(),i({title:"Switched branch",description:s})}catch(t){c(t.message),i({title:"Switch failed",description:t.message,variant:"destructive"})}je(null)},ps=async s=>{if(confirm(`Delete branch ${s}?`)){ye(s),c(null);try{const t=await fetch(`${l}/api/v1/git/branches/${encodeURIComponent(s)}`,{method:"DELETE"}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Failed to delete branch");await u(),i({title:"Branch deleted",description:s})}catch(t){c(t.message),i({title:"Delete failed",description:t.message,variant:"destructive"})}ye(null)}},bs=async s=>{ve(s),c(null);try{const t=await fetch(`${l}/api/v1/git/branches/${encodeURIComponent(s)}/merge`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({strategy:B})}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Failed to merge branch");await u(),i({title:"Branch merged",description:`${s} (${B})`})}catch(t){c(t.message),i({title:"Merge failed",description:t.message,variant:"destructive"})}ve(null)},Ee=async()=>{if(Q){if(Te){R(!0);return}U(!0),c(null);try{const s=Array.from(p),t=await fetch(`${l}/api/v1/git/commits`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:v,files:s.length>0?s:void 0})}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Commit failed");K(""),N(new Set),await u(),await J(),i({title:"Committed",description:v})}catch(s){c(s.message),i({title:"Commit failed",description:s.message,variant:"destructive"})}U(!1)}},js=async()=>{R(!1),U(!0),c(null);try{const s=Array.from(p),t=await fetch(`${l}/api/v1/git/commits`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:v,files:s.length>0?s:void 0})}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Commit failed");K(""),N(new Set),await u(),await J(),i({title:"Committed",description:v})}catch(s){c(s.message),i({title:"Commit failed",description:s.message,variant:"destructive"})}U(!1)},Fe=async()=>{if(g.trim()){R(!1),M(!0),c(null);try{const s=await fetch(`${l}/api/v1/git/branches`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:g,from:r?.branch})}).then(a=>a.json());if(!s.success)throw new Error(s.error?.message||"Failed to create branch");const t=await fetch(`${l}/api/v1/git/branches/${encodeURIComponent(g)}/switch`,{method:"POST"}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Failed to switch branch");F(""),await u(),i({title:"Branch created & switched",description:g})}catch(s){c(s.message),i({title:"Failed",description:s.message,variant:"destructive"})}M(!1)}};return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Source Control"}),h&&e.jsx(ee,{to:"/settings/git",className:"flex items-center gap-1.5 text-xs rounded-full px-2.5 py-1 border hover:bg-muted transition-colors",title:h.authenticated?"Authenticated with remote":"Authentication required - click to configure",children:h.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(Ts,{className:"h-3 w-3 text-green-600"}),e.jsx("span",{className:"text-muted-foreground",children:"Connected"})]}):e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-3 w-3 text-red-600"}),e.jsx("span",{className:"text-muted-foreground",children:"Not authenticated"}),e.jsx($e,{className:"h-3 w-3 text-muted-foreground ml-0.5"})]})})]}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs("select",{className:"text-sm border rounded-md px-3 py-2 bg-background h-9",value:H,onChange:s=>Ke(s.target.value),title:"Pull strategy",children:[e.jsx("option",{value:"merge",children:"Merge"}),e.jsx("option",{value:"rebase",children:"Rebase"}),e.jsx("option",{value:"ff-only",children:"FF only"})]}),e.jsxs(o,{variant:"outline",onClick:()=>De(),size:"sm",disabled:A==="",children:[e.jsx(Ds,{className:"h-4 w-4 mr-2"+(A===""?" animate-spin":"")}),A===""?"Pulling…":"Pull"]}),e.jsxs(o,{onClick:()=>Ae(),size:"sm",disabled:T==="",children:[e.jsx(Es,{className:"h-4 w-4 mr-2"+(T===""?" animate-spin":"")}),T===""?"Pushing…":"Push"]})]})]}),ue&&e.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-600 dark:border-red-900 dark:bg-red-950",children:ue}),e.jsxs(ie,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h3",{className:"font-semibold",children:"Repository Status"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(o,{variant:"outline",size:"sm","aria-label":"Refresh status",onClick:u,disabled:m,children:[e.jsx(ze,{className:"h-4 w-4"+(m?" animate-spin":"")}),"Refresh"]})})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Overview of your current branch, sync status with the remote, and uncommitted changes."}),m?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ze,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):r?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Branch:"}),e.jsx("span",{className:"font-mono font-semibold",children:r.branch}),Te&&e.jsxs("span",{className:"flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-amber-500/10 text-amber-600",children:[e.jsx(ce,{className:"h-3 w-3"}),"Default branch"]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-blue-600",children:"↓"}),e.jsxs("span",{className:"text-muted-foreground",children:[r.behind," behind"]})]}),e.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 rounded"+(r.ahead>0?" bg-amber-500/10":""),children:[e.jsx("span",{className:"text-green-600",children:"↑"}),e.jsxs("span",{className:r.ahead>0?"text-amber-700 dark:text-amber-300 font-medium":"text-muted-foreground",children:[r.ahead," ",r.ahead>0?"unpushed":"ahead"]})]})]})]}),r.changes.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx(o,{variant:"default",size:"sm",onClick:os,className:"h-7 text-xs",children:ls?"Deselect All":"Select All"}),e.jsxs("div",{className:"text-sm font-medium text-muted-foreground",children:["Uncommitted Changes (",r.changes.length,")"]})]}),e.jsx("div",{className:"rounded-lg border bg-muted/30 p-3 max-h-48 overflow-auto",children:e.jsx("ul",{className:"text-sm font-mono space-y-1",children:r.changes.map((s,t)=>e.jsxs("li",{className:"flex gap-2 items-center justify-between rounded px-2 py-1 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex gap-2 items-center flex-1 min-w-0",children:[e.jsx(Ns,{checked:p.has(s.path),onCheckedChange:a=>ns(s.path,a===!0)}),e.jsx("span",{className:"inline-flex items-center justify-center w-6 h-5 rounded bg-background text-xs font-semibold",children:rs(s.status)}),e.jsx("span",{className:"text-muted-foreground truncate",children:s.path})]}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>ds(s.path),className:"h-6 w-6 p-0 text-muted-foreground hover:text-destructive flex-shrink-0",title:"Discard changes",children:e.jsx(Cs,{className:"h-3.5 w-3.5 opacity-50"})})]},t))})})]}),e.jsxs("div",{className:"pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:"Commit Changes"}),p.size>0&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:[p.size," of ",r.changes.length," file",r.changes.length!==1?"s":""," selected"]})]}),(r.changes?.length??0)>0?e.jsxs(e.Fragment,{children:[p.size===0&&e.jsx("div",{className:"mb-3 text-xs text-amber-600 bg-amber-50 dark:bg-amber-950/20 border border-amber-200 dark:border-amber-900 rounded-lg p-2",children:"Select files above to commit specific changes"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{placeholder:"Describe your changes...",value:v,onChange:s=>K(s.target.value),className:"flex-1 bg-background border-2 border-primary focus-visible:border-primary",onKeyDown:s=>{s.key==="Enter"&&Q&&!z&&Ee()}}),e.jsxs(o,{onClick:Ee,disabled:!Q||z,children:[e.jsx($s,{className:"h-4 w-4 mr-2"}),z?"Committing…":"Commit"]})]})]}):e.jsx("div",{className:"text-center py-6 text-sm text-muted-foreground bg-muted/30 rounded-lg",children:"No uncommitted changes. Make some changes to your files to commit them."})]})]}):e.jsx("div",{className:"text-sm text-muted-foreground",children:"No status available"})]}),e.jsxs(ie,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h3",{className:"font-semibold",children:"Branches"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",b.length,")"]})]}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>ss(!I),"aria-label":I?"Collapse branches":"Expand branches",children:I?e.jsx(Ue,{className:"h-4 w-4"}):e.jsx(Me,{className:"h-4 w-4"})})]}),I&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-muted-foreground my-4",children:"Branches let you work on different features or fixes in isolation. Create a branch from any existing branch, switch between them, and merge them back when ready."}),e.jsxs("div",{className:"flex gap-2 mb-4 p-3 rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex-1 flex gap-2",children:[e.jsxs("div",{className:"flex flex-col gap-1 flex-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"From branch"}),e.jsx("select",{className:"text-sm border rounded-md px-3 py-2 bg-background",value:me,onChange:s=>Je(s.target.value),title:"Base branch for new branch",children:b.map(s=>e.jsx("option",{value:s.name,children:s.name},s.name))})]}),e.jsxs("div",{className:"flex flex-col gap-1 flex-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"New branch name"}),e.jsx(k,{placeholder:"feature/my-feature",value:g,onChange:s=>F(s.target.value),className:"bg-background border-2 border-primary focus-visible:border-primary"})]})]}),e.jsx("div",{className:"flex items-end",children:e.jsxs(o,{onClick:gs,disabled:$||!g.trim(),children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),$?"Creating…":"Create Branch"]})})]}),b.length===0?e.jsx("div",{className:"text-center py-8 text-sm text-muted-foreground",children:"No branches found. Create your first branch above."}):e.jsx("div",{className:"space-y-2",children:b.map(s=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-card p-3 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[s.current?e.jsx("div",{className:"h-2.5 w-2.5 rounded-full bg-green-600 animate-pulse",title:"Current branch"}):e.jsx("div",{className:"h-2.5 w-2.5 rounded-full border-2 border-muted-foreground"}),e.jsx("div",{className:"font-mono text-sm font-medium",children:s.name}),s.current&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-green-600/10 text-green-600 font-medium",children:"ACTIVE"})]}),e.jsx("div",{className:"flex gap-1.5",children:!s.current&&e.jsxs(e.Fragment,{children:[e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>fs(s.name),disabled:be===s.name,title:"Switch to this branch",children:[e.jsx(D,{className:"h-3.5 w-3.5 mr-1.5"}),be===s.name?"Switching…":"Switch"]}),e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>bs(s.name),disabled:we===s.name,title:`Merge ${s.name} into ${r?.branch||"current branch"} (${B})`,children:[e.jsx(Ie,{className:"h-3.5 w-3.5 mr-1.5"}),we===s.name?"Merging…":"Merge"]}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>ps(s.name),disabled:qe===s.name,className:"text-destructive hover:text-destructive",title:"Delete this branch",children:e.jsx(Be,{className:"h-3.5 w-3.5"})})]})})]},s.name))}),e.jsx("div",{className:"mt-4 pt-3 border-t flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(Ie,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Merge strategy:"}),e.jsxs("select",{className:"text-xs border rounded px-2 py-1 bg-background font-medium",value:B,onChange:s=>Ve(s.target.value),children:[e.jsx("option",{value:"merge",children:"Merge commit"}),e.jsx("option",{value:"squash",children:"Squash & merge"}),e.jsx("option",{value:"rebase",children:"Rebase & merge"})]})]})})]})]}),e.jsxs(ie,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h3",{className:"font-semibold",children:"Worktrees"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",y.length,")"]})]}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>ts(!L),"aria-label":L?"Collapse worktrees":"Expand worktrees",children:L?e.jsx(Ue,{className:"h-4 w-4"}):e.jsx(Me,{className:"h-4 w-4"})})]}),L&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mt-4",children:"Worktrees allow you to have multiple branches checked out simultaneously in different directories. Perfect for working on multiple features at once or testing changes without switching branches."}),e.jsxs("div",{className:"flex gap-2 mb-3 p-3 rounded-lg bg-muted/30",children:[e.jsx(k,{placeholder:"feature/worktree-name",value:E,onChange:s=>de(s.target.value),className:"flex-1 bg-background border-2 border-primary focus-visible:border-primary"}),e.jsxs(o,{onClick:us,disabled:he||!E.trim(),children:[e.jsx(oe,{className:"h-4 w-4 mr-2"}),he?"Creating…":"Create Worktree"]})]}),e.jsxs("p",{className:"mb-4 text-xs text-muted-foreground bg-muted/30 rounded-lg p-2",children:["💡 Worktrees are created in ",e.jsx("code",{className:"font-mono font-semibold",children:Xe})," relative to your project root.",e.jsx(ee,{to:"/settings/git",className:"underline underline-offset-2 ml-1 font-medium",children:"Configure location"})]}),y.length===0?e.jsx("div",{className:"text-center py-8 text-sm text-muted-foreground",children:"No worktrees yet. Create one to work on multiple branches simultaneously."}):e.jsx("div",{className:"space-y-2 mb-4",children:y.map(s=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3 bg-card hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(oe,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-sm font-medium",children:s.name}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["→ ",s.branch]})]}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:s.path})]})]}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>De(s.name),disabled:A===s.name,title:"Pull latest changes",children:[e.jsx(Le,{className:"h-3.5 w-3.5 mr-1.5"}),A===s.name?"Pulling…":"Pull"]}),e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>Ae(s.name),disabled:T===s.name,title:"Push changes",children:[e.jsx(Le,{className:"h-3.5 w-3.5 mr-1.5"}),T===s.name?"Pushing…":"Push"]}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>hs(s.name),disabled:He===s.name,className:"text-destructive hover:text-destructive",title:"Remove worktree",children:e.jsx(Be,{className:"h-3.5 w-3.5"})})]})]},s.name))})]})]}),e.jsx(se,{open:Ze,onOpenChange:w,children:e.jsxs(te,{className:"max-w-2xl",children:[e.jsxs(ae,{children:[e.jsx(re,{children:"Authentication Required"}),e.jsx(ne,{children:"Configure git credentials to push or pull from the remote repository."})]}),e.jsxs(Ss,{defaultValue:h?.remote?.startsWith("https://")?"credentials":"instructions",className:"w-full",children:[e.jsxs(Ps,{className:"grid w-full grid-cols-2",children:[e.jsxs(Ge,{value:"credentials",disabled:!h?.remote?.startsWith("https://"),children:[e.jsx(ks,{className:"h-4 w-4 mr-2"}),"Enter Credentials"]}),e.jsxs(Ge,{value:"instructions",children:[e.jsx($e,{className:"h-4 w-4 mr-2"}),"Setup Instructions"]})]}),e.jsxs(We,{value:"credentials",className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{htmlFor:"auth-username",children:"Username"}),e.jsx(k,{id:"auth-username",placeholder:"your-username",value:G,onChange:s=>q(s.target.value),autoComplete:"username",className:"bg-muted border-2 border-muted-foreground/30 focus-visible:border-primary"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{htmlFor:"auth-password",children:"Password / Personal Access Token"}),e.jsx(k,{id:"auth-password",type:"password",placeholder:"ghp_xxxxxxxxxxxx or your password",value:W,onChange:s=>V(s.target.value),autoComplete:"current-password",className:"bg-muted border-2 border-muted-foreground/30 focus-visible:border-primary"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"We recommend using a Personal Access Token instead of your password."})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(o,{variant:"outline",className:"flex-1",onClick:()=>{w(!1),q(""),V("")},children:"Cancel"}),e.jsx(o,{className:"flex-1",onClick:xs,disabled:Ce||!G||!W,children:Ce?"Saving...":"Save & Test"})]})]}),e.jsxs(We,{value:"instructions",className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure one of the following authentication methods:"}),e.jsxs("div",{className:"space-y-2 text-xs",children:[e.jsxs("div",{className:"rounded bg-muted p-3",children:[e.jsx("div",{className:"font-semibold mb-1",children:"SSH Keys (Recommended)"}),e.jsx("code",{className:"text-[11px] block bg-background rounded px-2 py-1",children:'ssh-keygen -t ed25519 -C "your_email@example.com"'}),e.jsx("p",{className:"mt-1 text-muted-foreground",children:"Then add ~/.ssh/id_ed25519.pub to your GitHub/GitLab account"})]}),e.jsxs("div",{className:"rounded bg-muted p-3",children:[e.jsx("div",{className:"font-semibold mb-1",children:"Git Credential Manager"}),e.jsx("code",{className:"text-[11px] block bg-background rounded px-2 py-1",children:"brew install git-credential-manager"})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(o,{variant:"outline",onClick:()=>w(!1),className:"flex-1",children:"Close"}),e.jsx(o,{asChild:!0,className:"flex-1",children:e.jsx(ee,{to:"/settings/git",onClick:()=>w(!1),children:"Open Settings"})})]})]})]})]})}),e.jsx(se,{open:as,onOpenChange:_,children:e.jsxs(te,{className:"max-w-md",children:[e.jsxs(ae,{children:[e.jsxs(re,{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-5 w-5 text-destructive"}),"Discard Changes?"]}),e.jsxs(ne,{children:["Are you sure you want to discard changes to ",e.jsx("code",{className:"font-mono text-sm bg-muted px-1 py-0.5 rounded",children:C}),"? This action cannot be undone."]})]}),e.jsxs(Oe,{children:[e.jsx(o,{variant:"outline",onClick:()=>{_(!1),X(null)},disabled:Y!==null,children:"Cancel"}),e.jsx(o,{variant:"destructive",onClick:ms,disabled:Y!==null,children:Y?"Discarding...":"Discard"})]})]})}),e.jsx(se,{open:es,onOpenChange:R,children:e.jsxs(te,{className:"max-w-lg",children:[e.jsxs(ae,{children:[e.jsxs(re,{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-5 w-5 text-amber-600"}),"Create a Branch First?"]}),e.jsxs(ne,{children:["You're about to commit directly to ",r?.branch,". It's best practice to create a feature branch first."]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"rounded-lg border border-blue-200 bg-blue-50 dark:border-blue-900 dark:bg-blue-950 p-4",children:[e.jsx("h4",{className:"text-sm font-semibold mb-2 text-blue-900 dark:text-blue-100",children:"Why create a branch?"}),e.jsxs("ul",{className:"text-sm text-blue-700 dark:text-blue-200 space-y-1 list-disc list-inside",children:[e.jsxs("li",{children:["Keeps ",r?.branch," stable and deployable"]}),e.jsx("li",{children:"Makes it easier to review and test changes"}),e.jsx("li",{children:"Allows working on multiple features simultaneously"}),e.jsx("li",{children:"Simplifies collaboration with your team"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"New branch name"}),e.jsx(k,{placeholder:"feature/my-awesome-feature",value:g,onChange:s=>F(s.target.value),onKeyDown:s=>{s.key==="Enter"&&g.trim()&&Fe()},className:"bg-muted border-2 border-muted-foreground/30 focus-visible:border-primary"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["This will create a new branch from ",r?.branch," and switch to it"]})]})]}),e.jsxs(Oe,{className:"flex-col sm:flex-row gap-2",children:[e.jsxs(o,{variant:"outline",onClick:js,disabled:z,className:"sm:flex-1",children:["Commit to ",r?.branch," Anyway"]}),e.jsxs(o,{onClick:Fe,disabled:!g.trim()||$,className:"sm:flex-1",children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),$?"Creating...":"Create Branch & Switch"]})]})]})})]})}export{Qs as default};
16
+ */const Bs=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]],Le=le("git-pull-request",Bs);let S;async function Os(){if(S!==void 0)return S;try{const m=await fetch(`${l}/api/v1/config`);if(!m.ok)return S=null,null;const r=(await m.json())?.data||{},f=r?.coconut?.id||r?.cloud?.coconutId||r?.cloud?.coconut_id;return S=typeof f=="string"&&f.trim()?f.trim():null,S}catch(m){return console.error("[github-token] Failed to load Coconut ID",m),S=null,null}}async function Rs(m){const x=await fetch(`${ws}/api/v1/git/token`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({coconutId:m})});if(!x.ok){let P="Failed to request GitHub token from control plane";if(x.status===401||x.status===403)throw new Error("Please sign in to app.coconut.dev and then retry the action.");try{const y=await x.json();P=y?.error?.message||y?.message||P}catch{}throw new Error(P)}const r=await x.json(),f=r?.token||r?.data?.token,b=r?.expiresAt||r?.data?.expiresAt;if(!f||!b)throw new Error("Control plane response missing token or expiresAt");return{token:f,expiresAt:b}}async function Gs(m,x){const r=await fetch(`${l}/api/v1/git/providers/github/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:m,expiresAt:x})}),f=await r.json().catch(()=>({}));if(!r.ok||!f?.success){const b=f?.error?.message||"Failed to store GitHub token on Coconut";throw new Error(b)}}async function Ws(){const m=await Os();if(!m)throw new Error("Coconut ID not configured. Reconnect via Settings → Git.");const{token:x,expiresAt:r}=await Rs(m);return await Gs(x,r),{tokenFetched:!0,message:r}}function Qs(){const[m,x]=n.useState(!0),[r,f]=n.useState(null),[b,P]=n.useState([]),[y,_e]=n.useState([]),[E,de]=n.useState(""),[g,$]=n.useState(""),[me,He]=n.useState("main"),[ue,c]=n.useState(null),{toast:i}=vs(),{refresh:H}=ys(),[he,xe]=n.useState(!1),[F,M]=n.useState(!1),[T,ge]=n.useState(null),[A,fe]=n.useState(null),[Je,pe]=n.useState(null),[be,je]=n.useState(null),[we,ve]=n.useState(null),[qe,ye]=n.useState(null),[B,Ve]=n.useState("merge"),[J,Ke]=n.useState("merge"),[Xe,Ye]=n.useState("../worktrees"),[O,Qe]=n.useState("github"),[h,Ne]=n.useState(null),[Ze,w]=n.useState(!1),[es,R]=n.useState(!1),[G,q]=n.useState(""),[W,V]=n.useState(""),[Ce,ke]=n.useState(!1),[v,K]=n.useState(""),[z,U]=n.useState(!1),[p,N]=n.useState(new Set),[I,ss]=n.useState(!1),[L,ts]=n.useState(!1),[as,_]=n.useState(!1),[C,X]=n.useState(null),[Y,Se]=n.useState(null),Pe=n.useCallback(async()=>{if(O!=="github"||h?.provider!=="github")return!0;if(h?.authenticated&&h?.expiresAt){const t=new Date(h.expiresAt).getTime(),a=Date.now(),d=300*1e3;if(t>a+d)return!0}const s=i({title:"Fetching GitHub token",description:"Contacting control plane…"});try{const{message:t}=await Ws();return i({title:"GitHub token ready",description:t?`Valid until ${new Date(t).toLocaleString()}`:"Token fetched successfully."}),Ne(a=>({...a,authenticated:!0,error:void 0,expiresAt:t??a?.expiresAt,provider:"github"})),!0}catch(t){const a=t?.message?`${t.message} Visit Settings → Git to reconnect.`:"Visit Settings → Git to connect GitHub.";return i({title:"GitHub token unavailable",description:a,variant:"destructive"}),c(t?.message||"GitHub authorization required. Visit Settings → Git to reconnect."),!1}finally{s?.dismiss?.()}},[O,h?.provider,h?.authenticated,h?.expiresAt,i]),u=async()=>{x(!0),c(null);try{const[s,t,a,d,Z]=await Promise.all([fetch(`${l}/api/v1/git/status`).then(j=>j.json()),fetch(`${l}/api/v1/git/branches`).then(j=>j.json()),fetch(`${l}/api/v1/git/worktrees`).then(j=>j.json()),fetch(`${l}/api/v1/git/settings`).then(j=>j.json()).catch(()=>null),fetch(`${l}/api/v1/git/auth-status`).then(j=>j.json()).catch(()=>null)]);s.success&&f(s.data),t.success&&P(t.data),a.success&&_e(a.data),d&&d.success&&d.data?.defaultWorktreePath&&(Ye(d.data.defaultWorktreePath),d.data.authMode&&Qe(d.data.authMode)),Z&&Z.success&&Ne(Z.data)}catch(s){c(s.message),i({title:"Failed to refresh",description:s.message,variant:"destructive"})}finally{x(!1)}};n.useEffect(()=>{u()},[]);const Te=n.useMemo(()=>{const s=r?.branch?.toLowerCase();return s==="main"||s==="master"},[r?.branch]),Q=n.useMemo(()=>{const s=!!v.trim(),t=p.size>0;return s&&t},[v,p]),rs=s=>s==="??"||s.includes("U")?"U":s.includes("R")?"R":s.includes("C")?"C":s.includes("D")?"D":s.includes("A")?"A":s.includes("M")?"M":s||"?",ns=(s,t)=>{N(a=>{const d=new Set(a);return t?d.add(s):d.delete(s),d})},is=()=>{r?.changes&&N(new Set(r.changes.map(s=>s.path)))},cs=()=>{N(new Set)},os=()=>{r?.changes&&(r.changes.every(t=>p.has(t.path))?cs():is())},ls=n.useMemo(()=>!r?.changes||r.changes.length===0?!1:r.changes.every(s=>p.has(s.path)),[r?.changes,p]),ds=s=>{X(s),_(!0)},ms=async()=>{if(C){Se(C),c(null);try{const s=await fetch(`${l}/api/v1/git/discard`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:C})}).then(t=>t.json());if(!s.success)throw new Error(s.error?.message||"Failed to discard file");N(t=>{const a=new Set(t);return a.delete(C),a}),i({title:"File discarded",description:C}),_(!1),X(null),await u(),await H()}catch(s){c(s.message),i({title:"Discard failed",description:s.message,variant:"destructive"})}finally{Se(null)}}},us=async()=>{if(E.trim()){xe(!0),c(null);try{const s=await fetch(`${l}/api/v1/git/worktrees`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:E,from:"main"})}).then(t=>t.json());if(!s.success)throw new Error(s.error?.message||"Failed to create worktree");de(""),await u(),i({title:"Worktree created",description:s.data?.added?.branch})}catch(s){c(s.message),i({title:"Create failed",description:s.message,variant:"destructive"})}xe(!1)}},Ae=async s=>{if(c(null),!(O==="github"&&h?.provider==="github"&&!await Pe())){try{ge(s||"");const t=s?`/api/v1/git/worktrees/${encodeURIComponent(s)}/push`:"/api/v1/git/push",a=await fetch(`${l}${t}`,{method:"POST"}).then(d=>d.json());if(!a.success)throw new Error(a.error?.message||"Push failed");i({title:"Pushed",description:s?`Worktree ${s}`:"Current branch"}),await u()}catch(t){const a=t.message||"",d=a.includes("Authentication")||a.includes("could not read Username")||a.includes("could not read Password")||a.includes("terminal prompts disabled");c(a),i({title:"Push failed",description:a,variant:"destructive"}),d&&w(!0)}ge(null)}},De=async s=>{if(c(null),!(O==="github"&&h?.provider==="github"&&!await Pe())){try{fe(s||"");const t=s?`/api/v1/git/worktrees/${encodeURIComponent(s)}/pull`:"/api/v1/git/pull",a=await fetch(`${l}${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({strategy:J})}).then(d=>d.json());if(!a.success)throw new Error(a.error?.message||"Pull failed");await u(),i({title:"Pulled",description:`${s?`Worktree ${s}`:"Current branch"} (${J})`})}catch(t){const a=t.message||"",d=a.includes("Authentication")||a.includes("could not read Username")||a.includes("could not read Password")||a.includes("terminal prompts disabled");c(a),i({title:"Pull failed",description:a,variant:"destructive"}),d&&w(!0)}fe(null)}},hs=async s=>{if(confirm(`Remove worktree ${s}?`)){c(null);try{pe(s);const t=await fetch(`${l}/api/v1/git/worktrees/${encodeURIComponent(s)}`,{method:"DELETE"}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Failed to remove worktree");await u(),i({title:"Worktree removed",description:s})}catch(t){c(t.message),i({title:"Remove failed",description:t.message,variant:"destructive"})}pe(t=>t===s?null:t)}},xs=async()=>{if(!G||!W){i({title:"Error",description:"Username and password are required",variant:"destructive"});return}ke(!0);try{const t=await(await fetch(`${l}/api/v1/git/credentials`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:G,password:W})})).json();if(!t.success)throw new Error(t.error?.message||"Failed to save credentials");i({title:"Success",description:"Credentials saved successfully"}),w(!1),q(""),V(""),await u()}catch(s){i({title:"Error",description:s?.message||"Failed to save credentials",variant:"destructive"})}finally{ke(!1)}},gs=async()=>{if(g.trim()){M(!0),c(null);try{const s=await fetch(`${l}/api/v1/git/branches`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:g,from:me})}).then(t=>t.json());if(!s.success)throw new Error(s.error?.message||"Failed to create branch");$(""),await u(),i({title:"Branch created",description:g})}catch(s){c(s.message),i({title:"Create failed",description:s.message,variant:"destructive"})}M(!1)}},fs=async s=>{je(s),c(null);try{const t=await fetch(`${l}/api/v1/git/branches/${encodeURIComponent(s)}/switch`,{method:"POST"}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Failed to switch branch");await u(),i({title:"Switched branch",description:s})}catch(t){c(t.message),i({title:"Switch failed",description:t.message,variant:"destructive"})}je(null)},ps=async s=>{if(confirm(`Delete branch ${s}?`)){ye(s),c(null);try{const t=await fetch(`${l}/api/v1/git/branches/${encodeURIComponent(s)}`,{method:"DELETE"}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Failed to delete branch");await u(),i({title:"Branch deleted",description:s})}catch(t){c(t.message),i({title:"Delete failed",description:t.message,variant:"destructive"})}ye(null)}},bs=async s=>{ve(s),c(null);try{const t=await fetch(`${l}/api/v1/git/branches/${encodeURIComponent(s)}/merge`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({strategy:B})}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Failed to merge branch");await u(),i({title:"Branch merged",description:`${s} (${B})`})}catch(t){c(t.message),i({title:"Merge failed",description:t.message,variant:"destructive"})}ve(null)},Ee=async()=>{if(Q){if(Te){R(!0);return}U(!0),c(null);try{const s=Array.from(p),t=await fetch(`${l}/api/v1/git/commits`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:v,files:s.length>0?s:void 0})}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Commit failed");K(""),N(new Set),await u(),await H(),i({title:"Committed",description:v})}catch(s){c(s.message),i({title:"Commit failed",description:s.message,variant:"destructive"})}U(!1)}},js=async()=>{R(!1),U(!0),c(null);try{const s=Array.from(p),t=await fetch(`${l}/api/v1/git/commits`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:v,files:s.length>0?s:void 0})}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Commit failed");K(""),N(new Set),await u(),await H(),i({title:"Committed",description:v})}catch(s){c(s.message),i({title:"Commit failed",description:s.message,variant:"destructive"})}U(!1)},$e=async()=>{if(g.trim()){R(!1),M(!0),c(null);try{const s=await fetch(`${l}/api/v1/git/branches`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:g,from:r?.branch})}).then(a=>a.json());if(!s.success)throw new Error(s.error?.message||"Failed to create branch");const t=await fetch(`${l}/api/v1/git/branches/${encodeURIComponent(g)}/switch`,{method:"POST"}).then(a=>a.json());if(!t.success)throw new Error(t.error?.message||"Failed to switch branch");$(""),await u(),i({title:"Branch created & switched",description:g})}catch(s){c(s.message),i({title:"Failed",description:s.message,variant:"destructive"})}M(!1)}};return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Source Control"}),h&&e.jsx(ee,{to:"/settings/git",className:"flex items-center gap-1.5 text-xs rounded-full px-2.5 py-1 border hover:bg-muted transition-colors",title:h.authenticated?"Authenticated with remote":"Authentication required - click to configure",children:h.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(Ts,{className:"h-3 w-3 text-green-600"}),e.jsx("span",{className:"text-muted-foreground",children:"Connected"})]}):e.jsxs(e.Fragment,{children:[e.jsx(As,{className:"h-3 w-3 text-red-600"}),e.jsx("span",{className:"text-muted-foreground",children:"Not authenticated"}),e.jsx(Fe,{className:"h-3 w-3 text-muted-foreground ml-0.5"})]})})]}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs("select",{className:"text-sm border rounded-md px-3 py-2 bg-background h-9",value:J,onChange:s=>Ke(s.target.value),title:"Pull strategy",children:[e.jsx("option",{value:"merge",children:"Merge"}),e.jsx("option",{value:"rebase",children:"Rebase"}),e.jsx("option",{value:"ff-only",children:"FF only"})]}),e.jsxs(o,{variant:"outline",onClick:()=>De(),size:"sm",disabled:A==="",children:[e.jsx(Ds,{className:"h-4 w-4 mr-2"+(A===""?" animate-spin":"")}),A===""?"Pulling…":"Pull"]}),e.jsxs(o,{onClick:()=>Ae(),size:"sm",disabled:T==="",children:[e.jsx(Es,{className:"h-4 w-4 mr-2"+(T===""?" animate-spin":"")}),T===""?"Pushing…":"Push"]})]})]}),ue&&e.jsx("div",{className:"rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-600 dark:border-red-900 dark:bg-red-950",children:ue}),e.jsxs(ie,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h3",{className:"font-semibold",children:"Repository Status"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(o,{variant:"outline",size:"sm","aria-label":"Refresh status",onClick:u,disabled:m,children:[e.jsx(ze,{className:"h-4 w-4"+(m?" animate-spin":"")}),"Refresh"]})})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Overview of your current branch, sync status with the remote, and uncommitted changes."}),m?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ze,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):r?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Branch:"}),e.jsx("span",{className:"font-mono font-semibold",children:r.branch}),Te&&e.jsxs("span",{className:"flex items-center gap-1 text-xs px-2 py-1 rounded-full bg-amber-500/10 text-amber-600",children:[e.jsx(ce,{className:"h-3 w-3"}),"Default branch"]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-blue-600",children:"↓"}),e.jsxs("span",{className:"text-muted-foreground",children:[r.behind," behind"]})]}),e.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 rounded"+(r.ahead>0?" bg-amber-500/10":""),children:[e.jsx("span",{className:"text-green-600",children:"↑"}),e.jsxs("span",{className:r.ahead>0?"text-amber-700 dark:text-amber-300 font-medium":"text-muted-foreground",children:[r.ahead," ",r.ahead>0?"unpushed":"ahead"]})]})]})]}),r.changes.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx(o,{variant:"default",size:"sm",onClick:os,className:"h-7 text-xs",children:ls?"Deselect All":"Select All"}),e.jsxs("div",{className:"text-sm font-medium text-muted-foreground",children:["Uncommitted Changes (",r.changes.length,")"]})]}),e.jsx("div",{className:"rounded-lg border bg-muted/30 p-3 max-h-48 overflow-auto",children:e.jsx("ul",{className:"text-sm font-mono space-y-1",children:r.changes.map((s,t)=>e.jsxs("li",{className:"flex gap-2 items-center justify-between rounded px-2 py-1 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex gap-2 items-center flex-1 min-w-0",children:[e.jsx(Ns,{checked:p.has(s.path),onCheckedChange:a=>ns(s.path,a===!0)}),e.jsx("span",{className:"inline-flex items-center justify-center w-6 h-5 rounded bg-background text-xs font-semibold",children:rs(s.status)}),e.jsx("span",{className:"text-muted-foreground truncate",children:s.path})]}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>ds(s.path),className:"h-6 w-6 p-0 text-muted-foreground hover:text-destructive flex-shrink-0",title:"Discard changes",children:e.jsx(Cs,{className:"h-3.5 w-3.5 opacity-50"})})]},t))})})]}),e.jsxs("div",{className:"pt-4 border-t",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:"Commit Changes"}),p.size>0&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:[p.size," of ",r.changes.length," file",r.changes.length!==1?"s":""," selected"]})]}),(r.changes?.length??0)>0?e.jsxs(e.Fragment,{children:[p.size===0&&e.jsx("div",{className:"mb-3 text-xs text-amber-600 bg-amber-50 dark:bg-amber-950/20 border border-amber-200 dark:border-amber-900 rounded-lg p-2",children:"Select files above to commit specific changes"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(k,{placeholder:"Describe your changes...",value:v,onChange:s=>K(s.target.value),className:"flex-1 bg-background border-2 border-primary focus-visible:border-primary",onKeyDown:s=>{s.key==="Enter"&&Q&&!z&&Ee()}}),e.jsxs(o,{onClick:Ee,disabled:!Q||z,children:[e.jsx(Fs,{className:"h-4 w-4 mr-2"}),z?"Committing…":"Commit"]})]})]}):e.jsx("div",{className:"text-center py-6 text-sm text-muted-foreground bg-muted/30 rounded-lg",children:"No uncommitted changes. Make some changes to your files to commit them."})]})]}):e.jsx("div",{className:"text-sm text-muted-foreground",children:"No status available"})]}),e.jsxs(ie,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h3",{className:"font-semibold",children:"Branches"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",b.length,")"]})]}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>ss(!I),"aria-label":I?"Collapse branches":"Expand branches",children:I?e.jsx(Ue,{className:"h-4 w-4"}):e.jsx(Me,{className:"h-4 w-4"})})]}),I&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-muted-foreground my-4",children:"Branches let you work on different features or fixes in isolation. Create a branch from any existing branch, switch between them, and merge them back when ready."}),e.jsxs("div",{className:"flex gap-2 mb-4 p-3 rounded-lg bg-muted/30",children:[e.jsxs("div",{className:"flex-1 flex gap-2",children:[e.jsxs("div",{className:"flex flex-col gap-1 flex-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"From branch"}),e.jsx("select",{className:"text-sm border rounded-md px-3 py-2 bg-background",value:me,onChange:s=>He(s.target.value),title:"Base branch for new branch",children:b.map(s=>e.jsx("option",{value:s.name,children:s.name},s.name))})]}),e.jsxs("div",{className:"flex flex-col gap-1 flex-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"New branch name"}),e.jsx(k,{placeholder:"feature/my-feature",value:g,onChange:s=>$(s.target.value),className:"bg-background border-2 border-primary focus-visible:border-primary"})]})]}),e.jsx("div",{className:"flex items-end",children:e.jsxs(o,{onClick:gs,disabled:F||!g.trim(),children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),F?"Creating…":"Create Branch"]})})]}),b.length===0?e.jsx("div",{className:"text-center py-8 text-sm text-muted-foreground",children:"No branches found. Create your first branch above."}):e.jsx("div",{className:"space-y-2",children:b.map(s=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border bg-card p-3 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[s.current?e.jsx("div",{className:"h-2.5 w-2.5 rounded-full bg-green-600 animate-pulse",title:"Current branch"}):e.jsx("div",{className:"h-2.5 w-2.5 rounded-full border-2 border-muted-foreground"}),e.jsx("div",{className:"font-mono text-sm font-medium",children:s.name}),s.current&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-green-600/10 text-green-600 font-medium",children:"ACTIVE"})]}),e.jsx("div",{className:"flex gap-1.5",children:!s.current&&e.jsxs(e.Fragment,{children:[e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>fs(s.name),disabled:be===s.name,title:"Switch to this branch",children:[e.jsx(D,{className:"h-3.5 w-3.5 mr-1.5"}),be===s.name?"Switching…":"Switch"]}),e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>bs(s.name),disabled:we===s.name,title:`Merge ${s.name} into ${r?.branch||"current branch"} (${B})`,children:[e.jsx(Ie,{className:"h-3.5 w-3.5 mr-1.5"}),we===s.name?"Merging…":"Merge"]}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>ps(s.name),disabled:qe===s.name,className:"text-destructive hover:text-destructive",title:"Delete this branch",children:e.jsx(Be,{className:"h-3.5 w-3.5"})})]})})]},s.name))}),e.jsx("div",{className:"mt-4 pt-3 border-t flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(Ie,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Merge strategy:"}),e.jsxs("select",{className:"text-xs border rounded px-2 py-1 bg-background font-medium",value:B,onChange:s=>Ve(s.target.value),children:[e.jsx("option",{value:"merge",children:"Merge commit"}),e.jsx("option",{value:"squash",children:"Squash & merge"}),e.jsx("option",{value:"rebase",children:"Rebase & merge"})]})]})})]})]}),e.jsxs(ie,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h3",{className:"font-semibold",children:"Worktrees"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",y.length,")"]})]}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>ts(!L),"aria-label":L?"Collapse worktrees":"Expand worktrees",children:L?e.jsx(Ue,{className:"h-4 w-4"}):e.jsx(Me,{className:"h-4 w-4"})})]}),L&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mt-4",children:"Worktrees allow you to have multiple branches checked out simultaneously in different directories. Perfect for working on multiple features at once or testing changes without switching branches."}),e.jsxs("div",{className:"flex gap-2 mb-3 p-3 rounded-lg bg-muted/30",children:[e.jsx(k,{placeholder:"feature/worktree-name",value:E,onChange:s=>de(s.target.value),className:"flex-1 bg-background border-2 border-primary focus-visible:border-primary"}),e.jsxs(o,{onClick:us,disabled:he||!E.trim(),children:[e.jsx(oe,{className:"h-4 w-4 mr-2"}),he?"Creating…":"Create Worktree"]})]}),e.jsxs("p",{className:"mb-4 text-xs text-muted-foreground bg-muted/30 rounded-lg p-2",children:["💡 Worktrees are created in ",e.jsx("code",{className:"font-mono font-semibold",children:Xe})," relative to your project root.",e.jsx(ee,{to:"/settings/git",className:"underline underline-offset-2 ml-1 font-medium",children:"Configure location"})]}),y.length===0?e.jsx("div",{className:"text-center py-8 text-sm text-muted-foreground",children:"No worktrees yet. Create one to work on multiple branches simultaneously."}):e.jsx("div",{className:"space-y-2 mb-4",children:y.map(s=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3 bg-card hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(oe,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-sm font-medium",children:s.name}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["→ ",s.branch]})]}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:s.path})]})]}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>De(s.name),disabled:A===s.name,title:"Pull latest changes",children:[e.jsx(Le,{className:"h-3.5 w-3.5 mr-1.5"}),A===s.name?"Pulling…":"Pull"]}),e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>Ae(s.name),disabled:T===s.name,title:"Push changes",children:[e.jsx(Le,{className:"h-3.5 w-3.5 mr-1.5"}),T===s.name?"Pushing…":"Push"]}),e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>hs(s.name),disabled:Je===s.name,className:"text-destructive hover:text-destructive",title:"Remove worktree",children:e.jsx(Be,{className:"h-3.5 w-3.5"})})]})]},s.name))})]})]}),e.jsx(se,{open:Ze,onOpenChange:w,children:e.jsxs(te,{className:"max-w-2xl",children:[e.jsxs(ae,{children:[e.jsx(re,{children:"Authentication Required"}),e.jsx(ne,{children:"Configure git credentials to push or pull from the remote repository."})]}),e.jsxs(Ss,{defaultValue:h?.remote?.startsWith("https://")?"credentials":"instructions",className:"w-full",children:[e.jsxs(Ps,{className:"grid w-full grid-cols-2",children:[e.jsxs(Ge,{value:"credentials",disabled:!h?.remote?.startsWith("https://"),children:[e.jsx(ks,{className:"h-4 w-4 mr-2"}),"Enter Credentials"]}),e.jsxs(Ge,{value:"instructions",children:[e.jsx(Fe,{className:"h-4 w-4 mr-2"}),"Setup Instructions"]})]}),e.jsxs(We,{value:"credentials",className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{htmlFor:"auth-username",children:"Username"}),e.jsx(k,{id:"auth-username",placeholder:"your-username",value:G,onChange:s=>q(s.target.value),autoComplete:"username",className:"bg-muted border-2 border-muted-foreground/30 focus-visible:border-primary"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(Re,{htmlFor:"auth-password",children:"Password / Personal Access Token"}),e.jsx(k,{id:"auth-password",type:"password",placeholder:"ghp_xxxxxxxxxxxx or your password",value:W,onChange:s=>V(s.target.value),autoComplete:"current-password",className:"bg-muted border-2 border-muted-foreground/30 focus-visible:border-primary"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"We recommend using a Personal Access Token instead of your password."})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(o,{variant:"outline",className:"flex-1",onClick:()=>{w(!1),q(""),V("")},children:"Cancel"}),e.jsx(o,{className:"flex-1",onClick:xs,disabled:Ce||!G||!W,children:Ce?"Saving...":"Save & Test"})]})]}),e.jsxs(We,{value:"instructions",className:"space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure one of the following authentication methods:"}),e.jsxs("div",{className:"space-y-2 text-xs",children:[e.jsxs("div",{className:"rounded bg-muted p-3",children:[e.jsx("div",{className:"font-semibold mb-1",children:"SSH Keys (Recommended)"}),e.jsx("code",{className:"text-[11px] block bg-background rounded px-2 py-1",children:'ssh-keygen -t ed25519 -C "your_email@example.com"'}),e.jsx("p",{className:"mt-1 text-muted-foreground",children:"Then add ~/.ssh/id_ed25519.pub to your GitHub/GitLab account"})]}),e.jsxs("div",{className:"rounded bg-muted p-3",children:[e.jsx("div",{className:"font-semibold mb-1",children:"Git Credential Manager"}),e.jsx("code",{className:"text-[11px] block bg-background rounded px-2 py-1",children:"brew install git-credential-manager"})]})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(o,{variant:"outline",onClick:()=>w(!1),className:"flex-1",children:"Close"}),e.jsx(o,{asChild:!0,className:"flex-1",children:e.jsx(ee,{to:"/settings/git",onClick:()=>w(!1),children:"Open Settings"})})]})]})]})]})}),e.jsx(se,{open:as,onOpenChange:_,children:e.jsxs(te,{className:"max-w-md",children:[e.jsxs(ae,{children:[e.jsxs(re,{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-5 w-5 text-destructive"}),"Discard Changes?"]}),e.jsxs(ne,{children:["Are you sure you want to discard changes to ",e.jsx("code",{className:"font-mono text-sm bg-muted px-1 py-0.5 rounded",children:C}),"? This action cannot be undone."]})]}),e.jsxs(Oe,{children:[e.jsx(o,{variant:"outline",onClick:()=>{_(!1),X(null)},disabled:Y!==null,children:"Cancel"}),e.jsx(o,{variant:"destructive",onClick:ms,disabled:Y!==null,children:Y?"Discarding...":"Discard"})]})]})}),e.jsx(se,{open:es,onOpenChange:R,children:e.jsxs(te,{className:"max-w-lg",children:[e.jsxs(ae,{children:[e.jsxs(re,{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-5 w-5 text-amber-600"}),"Create a Branch First?"]}),e.jsxs(ne,{children:["You're about to commit directly to ",r?.branch,". It's best practice to create a feature branch first."]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"rounded-lg border border-blue-200 bg-blue-50 dark:border-blue-900 dark:bg-blue-950 p-4",children:[e.jsx("h4",{className:"text-sm font-semibold mb-2 text-blue-900 dark:text-blue-100",children:"Why create a branch?"}),e.jsxs("ul",{className:"text-sm text-blue-700 dark:text-blue-200 space-y-1 list-disc list-inside",children:[e.jsxs("li",{children:["Keeps ",r?.branch," stable and deployable"]}),e.jsx("li",{children:"Makes it easier to review and test changes"}),e.jsx("li",{children:"Allows working on multiple features simultaneously"}),e.jsx("li",{children:"Simplifies collaboration with your team"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"New branch name"}),e.jsx(k,{placeholder:"feature/my-awesome-feature",value:g,onChange:s=>$(s.target.value),onKeyDown:s=>{s.key==="Enter"&&g.trim()&&$e()},className:"bg-muted border-2 border-muted-foreground/30 focus-visible:border-primary"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["This will create a new branch from ",r?.branch," and switch to it"]})]})]}),e.jsxs(Oe,{className:"flex-col sm:flex-row gap-2",children:[e.jsxs(o,{variant:"outline",onClick:js,disabled:z,className:"sm:flex-1",children:["Commit to ",r?.branch," Anyway"]}),e.jsxs(o,{onClick:$e,disabled:!g.trim()||F,className:"sm:flex-1",children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),F?"Creating...":"Create Branch & Switch"]})]})]})})]})}export{Qs as default};
@@ -1,6 +1,6 @@
1
- import{c as Te,r,a as He,A as u,j as e,bv as he,B as o,E as Fe,t as De,bx as ze,I as U,D as W,b as B,d as q,f as J,g as K,W as Y}from"./index-DB2Tq9wz.js";import{C as xe,b as pe,c as ge,d as fe,a as be}from"./card-DRBgMGuU.js";import{L as f}from"./label-DxDedS8x.js";import{R as Me,a as je}from"./radio-group-DFNQiPDU.js";import{R as A}from"./refresh-cw-5y5jTc6x.js";import{E as ve}from"./external-link-BqUE-DMN.js";import{C as Oe}from"./circle-check-Cnp-EoKX.js";import{C as Ie}from"./circle-x-DxbiyJ6w.js";/**
1
+ import{c as He,r,a as Te,A as u,j as e,bx as he,B as o,H as Fe,v as De,bE as ze,I as U,D as W,b as B,d as q,f as J,g as K,Y}from"./index-ByTA2ZiD.js";import{C as xe,b as pe,c as ge,d as fe,a as be}from"./card-CL5bB4cs.js";import{L as f}from"./label-Dp0-28_O.js";import{R as Me,a as je}from"./radio-group-B8RB7N01.js";import{R as A}from"./refresh-cw-Cj_5MZiJ.js";import{E as ve}from"./external-link-CrRz0sU-.js";import{C as Oe}from"./circle-check-D2LVHMl-.js";import{C as Ie}from"./circle-x-CuUVLiI-.js";/**
2
2
  * @license lucide-react v0.542.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
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=Te("github",_e),V="../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,T]=r.useState("github"),[Z,Q]=r.useState(!0),[H,ee]=r.useState(!1),[a,te]=r.useState(null),[w,se]=r.useState(!1),[x,ye]=r.useState(null),[Ne,N]=r.useState(!1),[k,F]=r.useState(""),[C,D]=r.useState(""),[re,ae]=r.useState(!1),[p,S]=r.useState(!1),[ie,oe]=r.useState(!1),[ke,R]=r.useState(!1),[E,G]=r.useState(""),[ne,ce]=r.useState(!1),[z,le]=r.useState(!1),[Ce,P]=r.useState(!1),m=r.useRef(null),{toast:i}=He(),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),T(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(!k||!C){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:k,password:C})})).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&&!H&&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),T(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 tasks 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=>T(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:V}),"."]}),_&&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(V),children:["Use ",V]}),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:H,onClick:M,children:"Reload"}),e.jsx(o,{type:"button",disabled:!ue,onClick:Ae,children:H?"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:k,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:C,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(Y,{children:[e.jsx(o,{variant:"outline",onClick:()=>{N(!1),F(""),D("")},children:"Cancel"}),e.jsx(o,{onClick:Le,disabled:re||!k||!C||!a?.remote,children:re?"Saving...":"Save Credentials"})]})]})}),e.jsx(W,{open:Ce,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(Y,{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:ke,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(Y,{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};
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),V="../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),[k,F]=r.useState(""),[C,D]=r.useState(""),[re,ae]=r.useState(!1),[p,S]=r.useState(!1),[ie,oe]=r.useState(!1),[ke,R]=r.useState(!1),[E,G]=r.useState(""),[ne,ce]=r.useState(!1),[z,le]=r.useState(!1),[Ce,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(!k||!C){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:k,password:C})})).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 tasks 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:V}),"."]}),_&&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(V),children:["Use ",V]}),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:k,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:C,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(Y,{children:[e.jsx(o,{variant:"outline",onClick:()=>{N(!1),F(""),D("")},children:"Cancel"}),e.jsx(o,{onClick:Le,disabled:re||!k||!C||!a?.remote,children:re?"Saving...":"Save Credentials"})]})]})}),e.jsx(W,{open:Ce,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(Y,{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:ke,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(Y,{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};