upfynai-code 3.0.3 → 3.1.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 (243) hide show
  1. package/README.md +66 -91
  2. package/bin/cli.js +191 -0
  3. package/{client/dist → dist/client}/api-docs.html +838 -838
  4. package/{client/dist/assets/AppContent-Bvg0CPCO.js → dist/client/assets/AppContent-BofJquUs.js} +43 -43
  5. package/dist/client/assets/BrowserPanel-CSvD4jOX.js +2 -0
  6. package/dist/client/assets/CanvasFullScreen-onRfarpc.js +1 -0
  7. package/dist/client/assets/CanvasWorkspace-DvGKdL-k.js +259 -0
  8. package/dist/client/assets/DashboardPanel-DqAHbXDO.js +1 -0
  9. package/dist/client/assets/FileTree-BE0h-9M9.js +1 -0
  10. package/{client/dist/assets/GitPanel-RtyZUIWS.js → dist/client/assets/GitPanel-DdeJ0bp5.js} +2 -2
  11. package/{client/dist/assets/LoginModal-BWep8a6g.js → dist/client/assets/LoginModal-BP0pCTrH.js} +3 -3
  12. package/{client/dist/assets/MarkdownPreview-DHmk3qzu.js → dist/client/assets/MarkdownPreview-CESjI261.js} +1 -1
  13. package/dist/client/assets/MermaidBlock-D0rfEhrT.js +2 -0
  14. package/dist/client/assets/Onboarding-B2zQy-_6.js +1 -0
  15. package/dist/client/assets/SetupForm-Be7-WBe-.js +1 -0
  16. package/dist/client/assets/WorkflowsPanel-CusLbVJ6.js +1 -0
  17. package/{client/dist/assets/index-C5ptjuTl.js → dist/client/assets/index-BQy15irW.js} +25 -25
  18. package/dist/client/assets/index-CS0fDqEC.js +1 -0
  19. package/dist/client/assets/index-DYLSCCCp.css +1 -0
  20. package/dist/client/assets/vendor-canvas-QWTduIvM.js +23 -0
  21. package/{client/dist/assets/vendor-codemirror-CbtmxxaB.js → dist/client/assets/vendor-codemirror-D2ALgpaX.js} +1 -1
  22. package/{client/dist/assets/vendor-icons-BaD0x9SL.js → dist/client/assets/vendor-icons-kix3Gb31.js} +178 -138
  23. package/{client/dist/assets/vendor-mermaid-CH7SGc99.js → dist/client/assets/vendor-mermaid-CS3J4_Bz.js} +329 -326
  24. package/{client/dist/assets/vendor-syntax-DuHI9Ok6.js → dist/client/assets/vendor-syntax-LS_Nt30I.js} +1 -1
  25. package/{client/dist → dist/client}/clear-cache.html +85 -85
  26. package/dist/client/favicon.png +0 -0
  27. package/dist/client/favicon.svg +15 -0
  28. package/{client/dist → dist/client}/index.html +17 -17
  29. package/{client/dist → dist/client}/manifest.json +15 -15
  30. package/{client/dist → dist/client}/mcp-docs.html +108 -108
  31. package/{client/dist → dist/client}/offline.html +84 -84
  32. package/{client/dist → dist/client}/sw.js +82 -82
  33. package/package.json +55 -104
  34. package/scripts/postinstall.js +9 -0
  35. package/scripts/prepublish.js +77 -0
  36. package/src/animation.js +228 -0
  37. package/src/auth.js +142 -0
  38. package/src/config.js +40 -0
  39. package/src/connect.js +416 -0
  40. package/src/launch.js +81 -0
  41. package/src/mcp.js +57 -0
  42. package/src/permissions.js +140 -0
  43. package/src/persistent-shell.js +261 -0
  44. package/src/server.js +54 -0
  45. package/client/dist/assets/CanvasFullScreen-BdiJ35aq.js +0 -1
  46. package/client/dist/assets/CanvasWorkspace-Bk9R9_e0.js +0 -163
  47. package/client/dist/assets/DashboardPanel-CblJfTGi.js +0 -1
  48. package/client/dist/assets/FileTree-BDUnBheV.js +0 -1
  49. package/client/dist/assets/MermaidBlock-BuBc_G-F.js +0 -2
  50. package/client/dist/assets/Onboarding-Drnlt75a.js +0 -1
  51. package/client/dist/assets/SetupForm-CtCKitZG.js +0 -1
  52. package/client/dist/assets/WorkflowsPanel-B2mIXDvD.js +0 -1
  53. package/client/dist/assets/index-BFuqS0tY.css +0 -1
  54. package/client/dist/assets/vendor-canvas-D39yWul6.js +0 -49
  55. package/client/dist/favicon.png +0 -0
  56. package/client/dist/favicon.svg +0 -5
  57. package/commands/upfynai-connect.md +0 -59
  58. package/commands/upfynai-disconnect.md +0 -31
  59. package/commands/upfynai-doctor.md +0 -99
  60. package/commands/upfynai-export.md +0 -49
  61. package/commands/upfynai-local.md +0 -82
  62. package/commands/upfynai-status.md +0 -75
  63. package/commands/upfynai-stop.md +0 -49
  64. package/commands/upfynai-uninstall.md +0 -58
  65. package/commands/upfynai.md +0 -69
  66. package/scripts/build-client.js +0 -17
  67. package/scripts/fix-node-pty.js +0 -67
  68. package/scripts/install-commands.js +0 -78
  69. package/server/agent-loop.js +0 -242
  70. package/server/auto-compact.js +0 -99
  71. package/server/claude-sdk.js +0 -797
  72. package/server/cli-ui.js +0 -798
  73. package/server/cli.js +0 -751
  74. package/server/constants/config.js +0 -31
  75. package/server/cursor-cli.js +0 -270
  76. package/server/database/auth.db +0 -0
  77. package/server/database/db.js +0 -1451
  78. package/server/database/init.sql +0 -70
  79. package/server/index.js +0 -3814
  80. package/server/load-env.js +0 -26
  81. package/server/mcp-server.js +0 -621
  82. package/server/middleware/auth.js +0 -181
  83. package/server/middleware/relayHelpers.js +0 -44
  84. package/server/middleware/sandboxRouter.js +0 -174
  85. package/server/openai-codex.js +0 -403
  86. package/server/openrouter.js +0 -137
  87. package/server/projects.js +0 -1807
  88. package/server/provider-factory.js +0 -174
  89. package/server/relay-client.js +0 -390
  90. package/server/routes/agent.js +0 -1234
  91. package/server/routes/auth.js +0 -559
  92. package/server/routes/canvas.js +0 -53
  93. package/server/routes/cli-auth.js +0 -263
  94. package/server/routes/codex.js +0 -396
  95. package/server/routes/commands.js +0 -707
  96. package/server/routes/composio.js +0 -176
  97. package/server/routes/cursor.js +0 -770
  98. package/server/routes/dashboard.js +0 -295
  99. package/server/routes/git.js +0 -1208
  100. package/server/routes/keys.js +0 -34
  101. package/server/routes/mcp-utils.js +0 -48
  102. package/server/routes/mcp.js +0 -661
  103. package/server/routes/payments.js +0 -227
  104. package/server/routes/projects.js +0 -655
  105. package/server/routes/sessions.js +0 -146
  106. package/server/routes/settings.js +0 -261
  107. package/server/routes/taskmaster.js +0 -1928
  108. package/server/routes/user.js +0 -106
  109. package/server/routes/vapi-chat.js +0 -624
  110. package/server/routes/voice.js +0 -235
  111. package/server/routes/webhooks.js +0 -166
  112. package/server/routes/workflows.js +0 -312
  113. package/server/sandbox.js +0 -120
  114. package/server/services/composio.js +0 -204
  115. package/server/services/sessionRegistry.js +0 -139
  116. package/server/services/whisperService.js +0 -84
  117. package/server/services/workflowScheduler.js +0 -211
  118. package/server/tests/relay-flow.test.js +0 -570
  119. package/server/tests/sessions.test.js +0 -259
  120. package/server/utils/commandParser.js +0 -303
  121. package/server/utils/email.js +0 -66
  122. package/server/utils/gitConfig.js +0 -24
  123. package/server/utils/mcp-detector.js +0 -198
  124. package/server/utils/taskmaster-websocket.js +0 -129
  125. package/shared/integrationCatalog.d.ts +0 -12
  126. package/shared/integrationCatalog.js +0 -172
  127. package/shared/modelConstants.js +0 -96
  128. /package/{shared → dist}/agents/claude.js +0 -0
  129. /package/{shared → dist}/agents/codex.js +0 -0
  130. /package/{shared → dist}/agents/cursor.js +0 -0
  131. /package/{shared → dist}/agents/detect.js +0 -0
  132. /package/{shared → dist}/agents/exec.js +0 -0
  133. /package/{shared → dist}/agents/files.js +0 -0
  134. /package/{shared → dist}/agents/git.js +0 -0
  135. /package/{shared → dist}/agents/gitagent.js +0 -0
  136. /package/{shared → dist}/agents/index.js +0 -0
  137. /package/{shared → dist}/agents/shell.js +0 -0
  138. /package/{shared → dist}/agents/utils.js +0 -0
  139. /package/{client/dist → dist/client}/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  140. /package/{client/dist → dist/client}/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  141. /package/{client/dist → dist/client}/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  142. /package/{client/dist → dist/client}/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  143. /package/{client/dist → dist/client}/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  144. /package/{client/dist → dist/client}/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  145. /package/{client/dist → dist/client}/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  146. /package/{client/dist → dist/client}/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  147. /package/{client/dist → dist/client}/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  148. /package/{client/dist → dist/client}/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  149. /package/{client/dist → dist/client}/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  150. /package/{client/dist → dist/client}/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  151. /package/{client/dist → dist/client}/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  152. /package/{client/dist → dist/client}/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  153. /package/{client/dist → dist/client}/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  154. /package/{client/dist → dist/client}/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  155. /package/{client/dist → dist/client}/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  156. /package/{client/dist → dist/client}/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  157. /package/{client/dist → dist/client}/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  158. /package/{client/dist → dist/client}/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  159. /package/{client/dist → dist/client}/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  160. /package/{client/dist → dist/client}/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  161. /package/{client/dist → dist/client}/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  162. /package/{client/dist → dist/client}/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  163. /package/{client/dist → dist/client}/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  164. /package/{client/dist → dist/client}/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  165. /package/{client/dist → dist/client}/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  166. /package/{client/dist → dist/client}/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  167. /package/{client/dist → dist/client}/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  168. /package/{client/dist → dist/client}/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  169. /package/{client/dist → dist/client}/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  170. /package/{client/dist → dist/client}/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  171. /package/{client/dist → dist/client}/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  172. /package/{client/dist → dist/client}/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  173. /package/{client/dist → dist/client}/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  174. /package/{client/dist → dist/client}/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  175. /package/{client/dist → dist/client}/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  176. /package/{client/dist → dist/client}/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  177. /package/{client/dist → dist/client}/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  178. /package/{client/dist → dist/client}/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  179. /package/{client/dist → dist/client}/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  180. /package/{client/dist → dist/client}/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  181. /package/{client/dist → dist/client}/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  182. /package/{client/dist → dist/client}/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  183. /package/{client/dist → dist/client}/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  184. /package/{client/dist → dist/client}/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  185. /package/{client/dist → dist/client}/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  186. /package/{client/dist → dist/client}/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  187. /package/{client/dist → dist/client}/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  188. /package/{client/dist → dist/client}/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  189. /package/{client/dist → dist/client}/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  190. /package/{client/dist → dist/client}/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  191. /package/{client/dist → dist/client}/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  192. /package/{client/dist → dist/client}/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  193. /package/{client/dist → dist/client}/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  194. /package/{client/dist → dist/client}/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  195. /package/{client/dist → dist/client}/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  196. /package/{client/dist → dist/client}/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  197. /package/{client/dist → dist/client}/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  198. /package/{client/dist → dist/client}/assets/PreviewPanel-CqCa92Tf.js +0 -0
  199. /package/{client/dist → dist/client}/assets/pdf-CE_K4jFx.js +0 -0
  200. /package/{client/dist → dist/client}/assets/vendor-canvas-BZV40eAE.css +0 -0
  201. /package/{client/dist → dist/client}/assets/vendor-diff-DNQpbhrT.js +0 -0
  202. /package/{client/dist → dist/client}/assets/vendor-i18n-DCFGyhQR.js +0 -0
  203. /package/{client/dist → dist/client}/assets/vendor-markdown-CimbIo6Y.js +0 -0
  204. /package/{client/dist → dist/client}/assets/vendor-react-96lCPsRK.js +0 -0
  205. /package/{client/dist → dist/client}/assets/vendor-xterm-CZq1hqo1.js +0 -0
  206. /package/{client/dist → dist/client}/assets/vendor-xterm-qxJ8_QYu.css +0 -0
  207. /package/{client/dist → dist/client}/convert-icons.md +0 -0
  208. /package/{client/dist → dist/client}/generate-icons.js +0 -0
  209. /package/{client/dist → dist/client}/icons/claude-ai-icon.svg +0 -0
  210. /package/{client/dist → dist/client}/icons/codex-white.svg +0 -0
  211. /package/{client/dist → dist/client}/icons/codex.svg +0 -0
  212. /package/{client/dist → dist/client}/icons/cursor-white.svg +0 -0
  213. /package/{client/dist → dist/client}/icons/cursor.svg +0 -0
  214. /package/{client/dist → dist/client}/icons/icon-128x128.png +0 -0
  215. /package/{client/dist → dist/client}/icons/icon-128x128.svg +0 -0
  216. /package/{client/dist → dist/client}/icons/icon-144x144.png +0 -0
  217. /package/{client/dist → dist/client}/icons/icon-144x144.svg +0 -0
  218. /package/{client/dist → dist/client}/icons/icon-152x152.png +0 -0
  219. /package/{client/dist → dist/client}/icons/icon-152x152.svg +0 -0
  220. /package/{client/dist → dist/client}/icons/icon-192x192.png +0 -0
  221. /package/{client/dist → dist/client}/icons/icon-192x192.svg +0 -0
  222. /package/{client/dist → dist/client}/icons/icon-384x384.png +0 -0
  223. /package/{client/dist → dist/client}/icons/icon-384x384.svg +0 -0
  224. /package/{client/dist → dist/client}/icons/icon-512x512.png +0 -0
  225. /package/{client/dist → dist/client}/icons/icon-512x512.svg +0 -0
  226. /package/{client/dist → dist/client}/icons/icon-72x72.png +0 -0
  227. /package/{client/dist → dist/client}/icons/icon-72x72.svg +0 -0
  228. /package/{client/dist → dist/client}/icons/icon-96x96.png +0 -0
  229. /package/{client/dist → dist/client}/icons/icon-96x96.svg +0 -0
  230. /package/{client/dist → dist/client}/icons/icon-template.svg +0 -0
  231. /package/{client/dist → dist/client}/logo-128.png +0 -0
  232. /package/{client/dist → dist/client}/logo-256.png +0 -0
  233. /package/{client/dist → dist/client}/logo-32.png +0 -0
  234. /package/{client/dist → dist/client}/logo-512.png +0 -0
  235. /package/{client/dist → dist/client}/logo-64.png +0 -0
  236. /package/{client/dist → dist/client}/logo.svg +0 -0
  237. /package/{client/dist → dist/client}/screenshots/cli-selection.png +0 -0
  238. /package/{client/dist → dist/client}/screenshots/desktop-main.png +0 -0
  239. /package/{client/dist → dist/client}/screenshots/mobile-chat.png +0 -0
  240. /package/{client/dist → dist/client}/screenshots/tools-modal.png +0 -0
  241. /package/{shared → dist}/gitagent/index.js +0 -0
  242. /package/{shared → dist}/gitagent/parser.js +0 -0
  243. /package/{shared → dist}/gitagent/prompt-builder.js +0 -0
@@ -1 +0,0 @@
1
- import{r as x,j as e,R as Ee}from"./vendor-react-96lCPsRK.js";import{B as V,I as Ie,S as Fe,c as h}from"./AppContent-Bvg0CPCO.js";import{d as Te,b as Le}from"./index-C5ptjuTl.js";import{X as ye,a6 as Me,E as ze,aw as Ae,e as xe,n as me,q as De,m as Re,ax as y,ay as U,$ as I,az as J,aA as Y,aB as ee,S as a,aC as $,aD as F,aE as oe,aF as T,t as j,aG as te,y as w,aH as G,aI as je,aJ as C,aK as S,aL as A,aM as D,aN as E,aO as Be,aP as b,aQ as pe,aR as Oe,aS as ue,aT as R,aU as B,A as ge,aV as Ve,aW as Ue,aX as O,aY as fe,aZ as $e,a_ as Ge,ae as Z}from"./vendor-icons-BaD0x9SL.js";import{u as qe}from"./LoginModal-BWep8a6g.js";import"./vendor-syntax-DuHI9Ok6.js";import"./vendor-markdown-CimbIo6Y.js";import"./vendor-codemirror-CbtmxxaB.js";import"./vendor-i18n-DCFGyhQR.js";import"./vendor-xterm-CZq1hqo1.js";import"./vendor-canvas-D39yWul6.js";import"./vendor-mermaid-CH7SGc99.js";function _e({file:i,onClose:u}){const d=`/api/projects/${i.projectName}/files/content?path=${encodeURIComponent(i.path)}`,[s,p]=x.useState(null),[L,q]=x.useState(null),[N,g]=x.useState(!0);return x.useEffect(()=>{let f;const M=new AbortController;return(async()=>{try{g(!0),q(null),p(null);const m=await Te(d,{signal:M.signal});if(!m.ok)throw new Error(`Request failed with status ${m.status}`);const _=await m.blob();f=URL.createObjectURL(_),p(f)}catch(m){if(m.name==="AbortError")return;console.error("Error loading image:",m),q("Unable to load image")}finally{g(!1)}})(),()=>{M.abort(),f&&URL.revokeObjectURL(f)}},[d]),e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-4xl max-h-[90vh] w-full mx-4 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:i.name}),e.jsx(V,{variant:"ghost",size:"sm",onClick:u,className:"h-8 w-8 p-0",children:e.jsx(ye,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"p-4 flex justify-center items-center bg-gray-50 dark:bg-gray-900 min-h-[400px]",children:[N&&e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400",children:e.jsx("p",{children:"Loading image…"})}),!N&&s&&e.jsx("img",{src:s,alt:i.name,className:"max-w-full max-h-[70vh] object-contain rounded-lg shadow-md"}),!N&&!s&&e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[e.jsx("p",{children:L||"Unable to load image"}),e.jsx("p",{className:"text-sm mt-2 break-all",children:i.path})]})]}),e.jsx("div",{className:"p-4 border-t bg-gray-50 dark:bg-gray-800",children:e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:i.path})})]})})}const He="w-4 h-4 flex-shrink-0",he={js:{icon:R,color:"text-yellow-500"},jsx:{icon:R,color:"text-yellow-500"},mjs:{icon:R,color:"text-yellow-500"},cjs:{icon:R,color:"text-yellow-500"},ts:{icon:B,color:"text-blue-500"},tsx:{icon:B,color:"text-blue-500"},mts:{icon:B,color:"text-blue-500"},py:{icon:Z,color:"text-emerald-500"},pyw:{icon:Z,color:"text-emerald-500"},pyi:{icon:Z,color:"text-emerald-400"},ipynb:{icon:Ge,color:"text-orange-500"},rs:{icon:$,color:"text-orange-600"},toml:{icon:a,color:"text-gray-500"},go:{icon:U,color:"text-cyan-500"},rb:{icon:te,color:"text-red-500"},erb:{icon:te,color:"text-red-400"},php:{icon:$e,color:"text-violet-500"},java:{icon:fe,color:"text-red-600"},jar:{icon:fe,color:"text-red-500"},kt:{icon:U,color:"text-violet-500"},kts:{icon:U,color:"text-violet-400"},c:{icon:O,color:"text-blue-600"},h:{icon:O,color:"text-blue-400"},cpp:{icon:O,color:"text-blue-700"},hpp:{icon:O,color:"text-blue-500"},cc:{icon:O,color:"text-blue-700"},cs:{icon:U,color:"text-purple-600"},swift:{icon:oe,color:"text-orange-500"},lua:{icon:Ue,color:"text-blue-500"},r:{icon:Ve,color:"text-blue-600"},html:{icon:ge,color:"text-orange-600"},htm:{icon:ge,color:"text-orange-600"},css:{icon:F,color:"text-blue-500"},scss:{icon:F,color:"text-pink-500"},sass:{icon:F,color:"text-pink-400"},less:{icon:F,color:"text-indigo-500"},vue:{icon:B,color:"text-emerald-500"},svelte:{icon:B,color:"text-orange-500"},json:{icon:T,color:"text-yellow-600"},jsonc:{icon:T,color:"text-yellow-500"},json5:{icon:T,color:"text-yellow-500"},yaml:{icon:a,color:"text-purple-400"},yml:{icon:a,color:"text-purple-400"},xml:{icon:R,color:"text-orange-500"},csv:{icon:ue,color:"text-green-600"},tsv:{icon:ue,color:"text-green-500"},sql:{icon:Oe,color:"text-blue-500"},graphql:{icon:pe,color:"text-pink-500"},gql:{icon:pe,color:"text-pink-500"},proto:{icon:G,color:"text-green-500"},env:{icon:w,color:"text-yellow-600"},md:{icon:ee,color:"text-blue-500"},mdx:{icon:ee,color:"text-blue-400"},txt:{icon:I,color:"text-gray-500"},doc:{icon:I,color:"text-blue-600"},docx:{icon:I,color:"text-blue-600"},pdf:{icon:Y,color:"text-red-600"},rtf:{icon:I,color:"text-gray-500"},tex:{icon:J,color:"text-teal-600"},rst:{icon:I,color:"text-gray-400"},sh:{icon:j,color:"text-green-500"},bash:{icon:j,color:"text-green-500"},zsh:{icon:j,color:"text-green-400"},fish:{icon:j,color:"text-green-400"},ps1:{icon:j,color:"text-blue-400"},bat:{icon:j,color:"text-gray-500"},cmd:{icon:j,color:"text-gray-500"},png:{icon:b,color:"text-purple-500"},jpg:{icon:b,color:"text-purple-500"},jpeg:{icon:b,color:"text-purple-500"},gif:{icon:b,color:"text-purple-400"},webp:{icon:b,color:"text-purple-400"},ico:{icon:b,color:"text-purple-400"},bmp:{icon:b,color:"text-purple-400"},tiff:{icon:b,color:"text-purple-400"},svg:{icon:Be,color:"text-amber-500"},mp3:{icon:E,color:"text-pink-500"},wav:{icon:E,color:"text-pink-500"},ogg:{icon:E,color:"text-pink-400"},flac:{icon:E,color:"text-pink-400"},aac:{icon:E,color:"text-pink-400"},m4a:{icon:E,color:"text-pink-400"},mp4:{icon:D,color:"text-rose-500"},mov:{icon:D,color:"text-rose-500"},avi:{icon:D,color:"text-rose-500"},webm:{icon:D,color:"text-rose-400"},mkv:{icon:D,color:"text-rose-400"},ttf:{icon:A,color:"text-red-500"},otf:{icon:A,color:"text-red-500"},woff:{icon:A,color:"text-red-400"},woff2:{icon:A,color:"text-red-400"},eot:{icon:A,color:"text-red-400"},zip:{icon:S,color:"text-amber-600"},tar:{icon:S,color:"text-amber-600"},gz:{icon:S,color:"text-amber-600"},bz2:{icon:S,color:"text-amber-600"},rar:{icon:S,color:"text-amber-500"},"7z":{icon:S,color:"text-amber-500"},lock:{icon:y,color:"text-gray-500"},exe:{icon:C,color:"text-gray-500"},bin:{icon:C,color:"text-gray-500"},dll:{icon:C,color:"text-gray-400"},so:{icon:C,color:"text-gray-400"},dylib:{icon:C,color:"text-gray-400"},wasm:{icon:C,color:"text-purple-500"},ini:{icon:a,color:"text-gray-500"},cfg:{icon:a,color:"text-gray-500"},conf:{icon:a,color:"text-gray-500"},log:{icon:J,color:"text-gray-400"},map:{icon:je,color:"text-gray-400"}},be={Dockerfile:{icon:G,color:"text-blue-500"},"docker-compose.yml":{icon:G,color:"text-blue-500"},"docker-compose.yaml":{icon:G,color:"text-blue-500"},".dockerignore":{icon:G,color:"text-gray-500"},".gitignore":{icon:a,color:"text-gray-500"},".gitmodules":{icon:a,color:"text-gray-500"},".gitattributes":{icon:a,color:"text-gray-500"},".editorconfig":{icon:a,color:"text-gray-500"},".prettierrc":{icon:a,color:"text-pink-400"},".prettierignore":{icon:a,color:"text-gray-500"},".eslintrc":{icon:a,color:"text-violet-500"},".eslintrc.js":{icon:a,color:"text-violet-500"},".eslintrc.json":{icon:a,color:"text-violet-500"},".eslintrc.cjs":{icon:a,color:"text-violet-500"},"eslint.config.js":{icon:a,color:"text-violet-500"},"eslint.config.mjs":{icon:a,color:"text-violet-500"},".env":{icon:w,color:"text-yellow-600"},".env.local":{icon:w,color:"text-yellow-600"},".env.development":{icon:w,color:"text-yellow-500"},".env.production":{icon:w,color:"text-yellow-600"},".env.example":{icon:w,color:"text-yellow-400"},"package.json":{icon:T,color:"text-green-500"},"package-lock.json":{icon:y,color:"text-gray-500"},"yarn.lock":{icon:y,color:"text-blue-400"},"pnpm-lock.yaml":{icon:y,color:"text-orange-400"},"bun.lockb":{icon:y,color:"text-gray-400"},"Cargo.toml":{icon:$,color:"text-orange-600"},"Cargo.lock":{icon:y,color:"text-orange-400"},Gemfile:{icon:te,color:"text-red-500"},"Gemfile.lock":{icon:y,color:"text-red-400"},Makefile:{icon:j,color:"text-gray-500"},"CMakeLists.txt":{icon:$,color:"text-blue-500"},"tsconfig.json":{icon:T,color:"text-blue-500"},"jsconfig.json":{icon:T,color:"text-yellow-500"},"vite.config.ts":{icon:oe,color:"text-purple-500"},"vite.config.js":{icon:oe,color:"text-purple-500"},"webpack.config.js":{icon:$,color:"text-blue-500"},"tailwind.config.js":{icon:F,color:"text-cyan-500"},"tailwind.config.ts":{icon:F,color:"text-cyan-500"},"postcss.config.js":{icon:$,color:"text-red-400"},"babel.config.js":{icon:a,color:"text-yellow-500"},".babelrc":{icon:a,color:"text-yellow-500"},"README.md":{icon:ee,color:"text-blue-500"},LICENSE:{icon:Y,color:"text-gray-500"},"LICENSE.md":{icon:Y,color:"text-gray-500"},"CHANGELOG.md":{icon:J,color:"text-blue-400"},"requirements.txt":{icon:I,color:"text-emerald-400"},"go.mod":{icon:U,color:"text-cyan-500"},"go.sum":{icon:y,color:"text-cyan-400"}};function We(i){var d;if(be[i])return be[i];if(i.startsWith(".env"))return{icon:w,color:"text-yellow-600"};const u=(d=i.split(".").pop())==null?void 0:d.toLowerCase();return u&&he[u]?he[u]:{icon:je,color:"text-muted-foreground"}}function no({selectedProject:i,onFileOpen:u,activeFilePath:d=null}){const{t:s}=qe(),[p,L]=x.useState([]),[q,N]=x.useState(!1),[g,f]=x.useState(new Set),[M,W]=x.useState(null),[m,_]=x.useState("detailed"),[v,re]=x.useState(""),[z,ce]=x.useState([]),H=Ee.useRef(null);x.useEffect(()=>{i&&we()},[i]),x.useEffect(()=>{const t=localStorage.getItem("file-tree-view-mode");t&&["simple","detailed","compact"].includes(t)&&_(t)},[]),x.useEffect(()=>{if(!d||p.length===0)return;const t=d.replace(/\\/g,"/"),c=(r,l,n=[])=>{for(const k of r){const ie=(k.path||"").replace(/\\/g,"/");if(k.type==="directory"&&k.children){const Se=[...n,k.path];if(t.startsWith(ie+"/")){const de=c(k.children,l,Se);if(de)return de}}if(k.type!=="directory"&&ie===t)return n}return null},o=c(p,t);o&&o.length>0&&f(r=>{const l=new Set(r);return o.forEach(n=>l.add(n)),l}),requestAnimationFrame(()=>{var r;(r=H.current)==null||r.scrollIntoView({block:"nearest",behavior:"smooth"})})},[d,p]),x.useEffect(()=>{if(!v.trim())ce(p);else{const t=ne(p,v.toLowerCase());ce(t);const c=o=>{o.forEach(r=>{r.type==="directory"&&r.children&&r.children.length>0&&(f(l=>new Set(l.add(r.path))),c(r.children))})};c(t)}},[p,v]);const ne=(t,c)=>t.reduce((o,r)=>{const l=r.name.toLowerCase().includes(c);let n=[];return r.type==="directory"&&r.children&&(n=ne(r.children,c)),(l||n.length>0)&&o.push({...r,children:n}),o},[]),we=async()=>{N(!0);try{const t=await Le.getFiles(i.name);if(!t.ok){const o=await t.text();console.error("❌ File fetch failed:",t.status,o),L([]);return}const c=await t.json();L(c)}catch(t){console.error("❌ Error fetching files:",t),L([])}finally{N(!1)}},Ne=t=>{const c=new Set(g);c.has(t)?c.delete(t):c.add(t),f(c)},P=t=>{_(t),localStorage.setItem("file-tree-view-mode",t)},Q=t=>{if(!t||t===0)return"0 B";const c=1024,o=["B","KB","MB","GB"],r=Math.floor(Math.log(t)/Math.log(c));return parseFloat((t/Math.pow(c,r)).toFixed(1))+" "+o[r]},ve=t=>{if(!t)return"-";const c=new Date,o=new Date(t),r=Math.floor((c-o)/1e3);return r<60?s("fileTree.justNow"):r<3600?s("fileTree.minAgo",{count:Math.floor(r/60)}):r<86400?s("fileTree.hoursAgo",{count:Math.floor(r/3600)}):r<2592e3?s("fileTree.daysAgo",{count:Math.floor(r/86400)}):o.toLocaleDateString()},ke=t=>{var r;const c=(r=t.split(".").pop())==null?void 0:r.toLowerCase();return["png","jpg","jpeg","gif","svg","webp","ico","bmp"].includes(c)},Ce=t=>{const{icon:c,color:o}=We(t);return e.jsx(c,{className:h(He,o)})},X=t=>{t.type==="directory"?Ne(t.path):ke(t.name)?W({name:t.name,path:t.path,projectPath:i.path,projectName:i.name}):u&&u(t.path)},K=t=>{const c=t.type==="directory",o=g.has(t.path);return c?e.jsxs("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[e.jsx(De,{className:h("w-3.5 h-3.5 text-muted-foreground/70 transition-transform duration-150",o&&"rotate-90")}),o?e.jsx(Re,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):e.jsx(me,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"})]}):e.jsx("span",{className:"flex items-center flex-shrink-0 ml-[18px]",children:Ce(t.name)})},se=(t,c=0)=>t.map(o=>{const r=o.type==="directory",l=r&&g.has(o.path),n=!r&&d&&(o.path||"").replace(/\\/g,"/")===d.replace(/\\/g,"/");return e.jsxs("div",{className:"select-none",children:[e.jsxs("div",{ref:n?H:void 0,className:h("group flex items-center gap-1.5 py-[3px] pr-2 cursor-pointer rounded-sm","hover:bg-accent/60 transition-colors duration-100",n&&"bg-primary/10 border-l-2 !border-primary font-medium",!n&&r&&l&&"border-l-2 border-primary/30",!n&&r&&!l&&"border-l-2 border-transparent",!n&&!r&&"border-l-2 border-transparent"),style:{paddingLeft:`${c*16+4}px`},onClick:()=>X(o),children:[K(o),e.jsx("span",{className:h("text-[13px] leading-tight truncate",n?"font-medium text-primary":r?"font-medium text-foreground":"text-foreground/90"),children:o.name})]}),r&&l&&o.children&&o.children.length>0&&e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute top-0 bottom-0 border-l border-border/40",style:{left:`${c*16+14}px`},"aria-hidden":"true"}),se(o.children,c+1)]})]},o.path)}),le=(t,c=0)=>t.map(o=>{const r=o.type==="directory",l=r&&g.has(o.path),n=!r&&d&&(o.path||"").replace(/\\/g,"/")===d.replace(/\\/g,"/");return e.jsxs("div",{className:"select-none",children:[e.jsxs("div",{ref:n?H:void 0,className:h("group grid grid-cols-1 sm:grid-cols-12 gap-0 sm:gap-2 py-[3px] pr-2 hover:bg-accent/60 cursor-pointer items-center rounded-sm transition-colors duration-100",n&&"bg-primary/10 border-l-2 !border-primary font-medium",!n&&r&&l&&"border-l-2 border-primary/30",!n&&r&&!l&&"border-l-2 border-transparent",!n&&!r&&"border-l-2 border-transparent"),style:{paddingLeft:`${c*16+4}px`},onClick:()=>X(o),children:[e.jsxs("div",{className:"sm:col-span-5 flex items-center gap-1.5 min-w-0",children:[K(o),e.jsx("span",{className:h("text-[13px] leading-tight truncate",n?"font-medium text-primary":r?"font-medium text-foreground":"text-foreground/90"),children:o.name}),o.type==="file"&&o.size!=null&&e.jsx("span",{className:"sm:hidden text-[10px] text-muted-foreground/60 ml-auto flex-shrink-0",children:Q(o.size)})]}),e.jsx("div",{className:"hidden sm:block sm:col-span-2 text-sm text-muted-foreground tabular-nums",children:o.type==="file"?Q(o.size):""}),e.jsx("div",{className:"hidden sm:block sm:col-span-3 text-sm text-muted-foreground",children:ve(o.modified)}),e.jsx("div",{className:"hidden sm:block sm:col-span-2 text-sm text-muted-foreground font-mono",children:o.permissionsRwx||""})]}),r&&l&&o.children&&e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute top-0 bottom-0 border-l border-border/40",style:{left:`${c*16+14}px`},"aria-hidden":"true"}),le(o.children,c+1)]})]},o.path)}),ae=(t,c=0)=>t.map(o=>{const r=o.type==="directory",l=r&&g.has(o.path),n=!r&&d&&(o.path||"").replace(/\\/g,"/")===d.replace(/\\/g,"/");return e.jsxs("div",{className:"select-none",children:[e.jsxs("div",{ref:n?H:void 0,className:h("group flex items-center justify-between py-[3px] pr-2 hover:bg-accent/60 cursor-pointer rounded-sm transition-colors duration-100",n&&"bg-primary/10 border-l-2 !border-primary font-medium",!n&&r&&l&&"border-l-2 border-primary/30",!n&&r&&!l&&"border-l-2 border-transparent",!n&&!r&&"border-l-2 border-transparent"),style:{paddingLeft:`${c*16+4}px`},onClick:()=>X(o),children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[K(o),e.jsx("span",{className:h("text-[13px] leading-tight truncate",n?"font-medium text-primary":r?"font-medium text-foreground":"text-foreground/90"),children:o.name})]}),e.jsx("div",{className:"flex items-center gap-3 text-sm text-muted-foreground flex-shrink-0 ml-2",children:o.type==="file"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"tabular-nums",children:Q(o.size)}),e.jsx("span",{className:"font-mono",children:o.permissionsRwx})]})})]}),r&&l&&o.children&&e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute top-0 bottom-0 border-l border-border/40",style:{left:`${c*16+14}px`},"aria-hidden":"true"}),ae(o.children,c+1)]})]},o.path)});return q?e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsx("div",{className:"text-muted-foreground text-sm",children:s("fileTree.loading")})}):e.jsxs("div",{className:"h-full flex flex-col bg-background",children:[e.jsxs("div",{className:"px-3 pt-3 pb-2 border-b border-border space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-foreground",children:s("fileTree.files")}),e.jsxs("div",{className:"flex gap-0.5",children:[e.jsx(V,{variant:m==="simple"?"default":"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>P("simple"),title:s("fileTree.simpleView"),children:e.jsx(Me,{className:"w-3.5 h-3.5"})}),e.jsx(V,{variant:m==="compact"?"default":"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>P("compact"),title:s("fileTree.compactView"),children:e.jsx(ze,{className:"w-3.5 h-3.5"})}),e.jsx(V,{variant:m==="detailed"?"default":"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>P("detailed"),title:s("fileTree.detailedView"),children:e.jsx(Ae,{className:"w-3.5 h-3.5"})})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(xe,{className:"absolute left-2 top-1/2 transform -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground"}),e.jsx(Ie,{type:"text",placeholder:s("fileTree.searchPlaceholder"),value:v,onChange:t=>re(t.target.value),className:"pl-8 pr-8 h-8 text-sm"}),v&&e.jsx(V,{variant:"ghost",size:"sm",className:"absolute right-0.5 top-1/2 transform -translate-y-1/2 h-5 w-5 p-0 hover:bg-accent",onClick:()=>re(""),title:s("fileTree.clearSearch"),children:e.jsx(ye,{className:"w-3 h-3"})})]})]}),m==="detailed"&&z.length>0&&e.jsx("div",{className:"px-3 pt-1.5 pb-1 border-b border-border",children:e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-12 gap-2 px-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70",children:[e.jsx("div",{className:"sm:col-span-5",children:s("fileTree.name")}),e.jsx("div",{className:"hidden sm:block sm:col-span-2",children:s("fileTree.size")}),e.jsx("div",{className:"hidden sm:block sm:col-span-3",children:s("fileTree.modified")}),e.jsx("div",{className:"hidden sm:block sm:col-span-2",children:s("fileTree.permissions")})]})}),e.jsx(Fe,{className:"flex-1 px-2 py-1",children:p.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-3",children:e.jsx(me,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h4",{className:"font-medium text-foreground mb-1",children:s("fileTree.noFilesFound")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("fileTree.checkProjectPath")})]}):z.length===0&&v?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-3",children:e.jsx(xe,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h4",{className:"font-medium text-foreground mb-1",children:s("fileTree.noMatchesFound")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("fileTree.tryDifferentSearch")})]}):e.jsxs("div",{children:[m==="simple"&&se(z),m==="compact"&&ae(z),m==="detailed"&&le(z)]})}),M&&e.jsx(_e,{file:M,onClose:()=>W(null)})]})}export{no as default};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-mermaid-CH7SGc99.js","assets/vendor-canvas-D39yWul6.js","assets/vendor-react-96lCPsRK.js","assets/vendor-canvas-BZV40eAE.css","assets/vendor-syntax-DuHI9Ok6.js","assets/vendor-markdown-CimbIo6Y.js"])))=>i.map(i=>d[i]);
2
- import{b}from"./vendor-syntax-DuHI9Ok6.js";import{r as t,j as e}from"./vendor-react-96lCPsRK.js";import"./vendor-markdown-CimbIo6Y.js";let m=!1;async function h(){const r=await b(()=>import("./vendor-mermaid-CH7SGc99.js").then(s=>s.a7),__vite__mapDeps([0,1,2,3,4,5]));return m||(r.default.initialize({startOnLoad:!1,theme:"dark",themeVariables:{darkMode:!0,background:"#1e293b",primaryColor:"#3b82f6",primaryTextColor:"#e2e8f0",primaryBorderColor:"#475569",lineColor:"#64748b",secondaryColor:"#1e40af",tertiaryColor:"#0f172a",fontFamily:"ui-sans-serif, system-ui, sans-serif",fontSize:"14px"},flowchart:{htmlLabels:!0,curve:"basis"},sequence:{mirrorActors:!1}}),m=!0),r.default}function w({code:r}){const s=t.useRef(null),o=t.useId().replace(/:/g,"-"),[i,n]=t.useState(null),[u,d]=t.useState(null),[f,c]=t.useState(!1);t.useEffect(()=>{let l=!1;return(async()=>{try{const a=await h(),{svg:x}=await a.render(`mermaid${o}`,r.trim());l||(n(x),d(null))}catch(a){l||(d((a==null?void 0:a.message)||"Failed to render diagram"),n(null))}})(),()=>{l=!0}},[r,o]);const p=()=>{navigator.clipboard.writeText(r).then(()=>{c(!0),setTimeout(()=>c(!1),1500)}).catch(()=>{})};return u?e.jsxs("div",{className:"my-2 rounded-lg border border-red-500/30 bg-red-950/20 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("svg",{className:"w-4 h-4 text-red-400",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z",clipRule:"evenodd"})}),e.jsx("span",{className:"text-xs font-medium text-red-400",children:"Mermaid diagram error"})]}),e.jsx("pre",{className:"text-xs text-red-300/70 whitespace-pre-wrap font-mono",children:r})]}):e.jsxs("div",{className:"relative group my-2 rounded-lg border border-slate-700 bg-slate-900/50 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-slate-700/50 bg-slate-800/30",children:[e.jsx("span",{className:"text-xs text-slate-400 font-medium uppercase",children:"mermaid"}),e.jsx("button",{type:"button",onClick:p,className:"opacity-0 group-hover:opacity-100 transition-opacity text-xs px-2 py-0.5 rounded bg-slate-700/80 hover:bg-slate-700 text-slate-300 border border-slate-600",children:f?"Copied":"Copy source"})]}),e.jsx("div",{ref:s,className:"flex items-center justify-center p-4 min-h-[80px] overflow-x-auto [&_svg]:max-w-full",dangerouslySetInnerHTML:i?{__html:i}:void 0,children:!i&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-500",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-blue-500 border-t-transparent rounded-full animate-spin"}),"Rendering diagram..."]})})]})}export{w as default};
@@ -1 +0,0 @@
1
- import{r,j as e}from"./vendor-react-96lCPsRK.js";import{L as X,b as ee,C as te,a as se}from"./LoginModal-BWep8a6g.js";import{I as ae,h as re,d as c}from"./index-C5ptjuTl.js";import{b as ie,t as ne,at as oe,Z as le,G as de,au as ce,av as ue,j as me,r as xe,L as $,a4 as O,q as ge}from"./vendor-icons-BaD0x9SL.js";import"./vendor-xterm-CZq1hqo1.js";import"./vendor-canvas-D39yWul6.js";import"./vendor-mermaid-CH7SGc99.js";import"./vendor-syntax-DuHI9Ok6.js";import"./vendor-markdown-CimbIo6Y.js";import"./vendor-i18n-DCFGyhQR.js";const ke=({onComplete:y})=>{const[a,q]=r.useState(0),[m,N]=r.useState(""),[d,v]=r.useState(""),[o,x]=r.useState(!1),[w,l]=r.useState(""),[G,C]=r.useState(!1),[M,T]=r.useState("right"),[i,g]=r.useState(null),[B]=r.useState({name:"default",fullPath:ae?"/workspace":""}),[k,p]=r.useState({authenticated:!1,email:null,loading:!0,error:null}),[S,b]=r.useState({authenticated:!1,email:null,loading:!0,error:null}),[A,j]=r.useState({authenticated:!1,email:null,loading:!0,error:null}),{user:h}=re(),L=r.useRef(void 0);r.useEffect(()=>{D()},[]);const D=async()=>{try{const t=await c("/api/user/git-config");if(t.ok){const s=await t.json();s.gitName&&N(s.gitName),s.gitEmail&&v(s.gitEmail)}}catch{}};r.useEffect(()=>{const t=L.current;L.current=i,(t===void 0||t!==null&&i===null)&&(F(),E(),I())},[i]);const F=async()=>{try{const t=await c("/api/cli/claude/status");if(t.ok){const s=await t.json();p({authenticated:s.authenticated,email:s.email,loading:!1,error:s.error||null})}else p({authenticated:!1,email:null,loading:!1,error:"Failed to check status"})}catch(t){p({authenticated:!1,email:null,loading:!1,error:t.message})}},E=async()=>{try{const t=await c("/api/cli/cursor/status");if(t.ok){const s=await t.json();b({authenticated:s.authenticated,email:s.email,loading:!1,error:s.error||null})}else b({authenticated:!1,email:null,loading:!1,error:"Failed to check status"})}catch(t){b({authenticated:!1,email:null,loading:!1,error:t.message})}},I=async()=>{try{const t=await c("/api/cli/codex/status");if(t.ok){const s=await t.json();j({authenticated:s.authenticated,email:s.email,loading:!1,error:s.error||null})}else j({authenticated:!1,email:null,loading:!1,error:"Failed to check status"})}catch(t){j({authenticated:!1,email:null,loading:!1,error:t.message})}},U=()=>g("claude"),Y=()=>g("cursor"),_=()=>g("codex"),z=t=>{t===0&&(i==="claude"?F():i==="cursor"?E():i==="codex"&&I())},u=(t,s="right")=>{T(s),C(!0),setTimeout(()=>{q(t),C(!1)},200)},J=async()=>{if(l(""),a===0){u(1,"right");return}if(a===1){if(!m.trim()||!d.trim()){l("Both git name and email are required");return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d)){l("Please enter a valid email address");return}x(!0);try{const s=await c("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:m,gitEmail:d})});if(!s.ok){const n=await s.json();throw new Error(n.error||"Failed to save git configuration")}u(2,"right")}catch(s){l(s.message)}finally{x(!1)}return}u(a+1,"right")},V=()=>{l(""),u(a-1,"left")},W=async()=>{x(!0),l("");try{const t=await c("/api/user/complete-onboarding",{method:"POST"});if(!t.ok){const s=await t.json();throw new Error(s.error||"Failed to complete onboarding")}y&&y()}catch(t){l(t.message)}finally{x(!1)}},f=[{title:"Welcome",required:!1},{title:"Git Identity",required:!0},{title:"Agents",required:!1}],Z=()=>a===0?!0:a===1?m.trim()&&d.trim()&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d):!0,P=[k,S,A].filter(t=>t.authenticated).length,Q=[{icon:ne,title:"AI Agents",desc:"Claude, Cursor & Codex — unified in one interface",gradient:"from-blue-500/10 to-blue-600/5",iconColor:"text-blue-500"},{icon:oe,title:"Canvas",desc:"Visual workspace with code blocks, diagrams & notes",gradient:"from-violet-500/10 to-violet-600/5",iconColor:"text-violet-500"},{icon:le,title:"Relay",desc:"Bridge your local machine to the web UI seamlessly",gradient:"from-amber-500/10 to-amber-600/5",iconColor:"text-amber-500"}],H=[{name:"Claude Code",status:k,onLogin:U,logo:e.jsx(ee,{size:22}),accent:"blue"},{name:"Cursor",status:S,onLogin:Y,logo:e.jsx(te,{size:22}),accent:"violet"},{name:"OpenAI Codex",status:A,onLogin:_,logo:e.jsx(se,{className:"w-5 h-5"}),accent:"neutral"}],K=G?`opacity-0 ${M==="right"?"translate-x-4":"-translate-x-4"}`:"opacity-100 translate-x-0";return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4 sm:p-8",children:e.jsxs("div",{className:"w-full max-w-xl",children:[e.jsxs("div",{className:"mb-10",children:[e.jsx("div",{className:"flex items-center justify-between mb-3 px-1",children:f.map((t,s)=>e.jsxs("button",{onClick:()=>{s<a&&u(s,"left")},disabled:s>a,className:`text-xs font-medium tracking-wide uppercase transition-colors duration-300 ${s===a?"text-foreground":s<a?"text-primary cursor-pointer hover:text-primary/80":"text-muted-foreground/50"}`,children:[t.title,t.required&&s===a&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]},s))}),e.jsx("div",{className:"h-1 bg-muted/60 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary rounded-full transition-all duration-500 ease-out",style:{width:`${a/(f.length-1)*100}%`}})})]}),e.jsxs("div",{className:"bg-card rounded-2xl border border-border/60 shadow-xl shadow-black/[0.04] dark:shadow-black/[0.2] overflow-hidden",children:[e.jsxs("div",{className:`p-8 sm:p-10 transition-all duration-200 ease-out ${K}`,children:[a===0&&e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1 rounded-full bg-primary/10 text-primary text-xs font-medium mb-6",children:[e.jsx(ie,{className:"w-3.5 h-3.5"}),"Quick setup — under a minute"]}),e.jsxs("h1",{className:"text-3xl sm:text-4xl font-bold text-foreground tracking-tight leading-tight",children:["Welcome to Upfyn",h!=null&&h.first_name?e.jsxs("span",{className:"text-primary",children:[", ",h.first_name]}):null]}),e.jsx("p",{className:"text-muted-foreground mt-3 text-base max-w-md mx-auto leading-relaxed",children:"Your visual AI coding interface. Connect your favorite agents, manage projects, and build faster."})]}),e.jsx("div",{className:"grid gap-3",children:Q.map((t,s)=>e.jsxs("div",{className:`group flex items-start gap-4 p-4 rounded-xl bg-gradient-to-r ${t.gradient} border border-border/40 hover:border-border/80 transition-all duration-200`,children:[e.jsx("div",{className:`mt-0.5 p-2 rounded-lg bg-background/80 ${t.iconColor} flex-shrink-0`,children:e.jsx(t.icon,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-foreground text-sm",children:t.title}),e.jsx("p",{className:"text-muted-foreground text-sm mt-0.5",children:t.desc})]})]},s))})]}),a===1&&e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-primary/10 flex items-center justify-center mx-auto mb-5",children:e.jsx(de,{className:"w-7 h-7 text-primary"})}),e.jsx("h2",{className:"text-2xl sm:text-3xl font-bold text-foreground tracking-tight",children:"Git Identity"}),e.jsx("p",{className:"text-muted-foreground mt-2 text-sm max-w-sm mx-auto",children:"Set your name and email for commit attribution"})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"gitName",className:"flex items-center gap-2 text-sm font-medium text-foreground mb-2",children:[e.jsx(ce,{className:"w-3.5 h-3.5 text-muted-foreground"}),"Name"]}),e.jsx("input",{type:"text",id:"gitName",value:m,onChange:t=>N(t.target.value),className:"w-full px-4 py-3 border border-border/60 rounded-xl bg-background text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary/40 transition-all duration-200",placeholder:"John Doe",required:!0,disabled:o})]}),e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"gitEmail",className:"flex items-center gap-2 text-sm font-medium text-foreground mb-2",children:[e.jsx(ue,{className:"w-3.5 h-3.5 text-muted-foreground"}),"Email"]}),e.jsx("input",{type:"email",id:"gitEmail",value:d,onChange:t=>v(t.target.value),className:"w-full px-4 py-3 border border-border/60 rounded-xl bg-background text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary/40 transition-all duration-200",placeholder:"john@example.com",required:!0,disabled:o})]}),e.jsxs("p",{className:"text-xs text-muted-foreground/70 text-center",children:["Applied as ",e.jsx("code",{className:"px-1 py-0.5 rounded bg-muted/60 text-xs",children:"git config --global"})," on your machine"]})]})]}),a===2&&e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h2",{className:"text-2xl sm:text-3xl font-bold text-foreground tracking-tight",children:"Connect Your Agents"}),e.jsxs("p",{className:"text-muted-foreground mt-2 text-sm max-w-sm mx-auto",children:["Optional — login to one or more AI assistants.",P>0&&e.jsxs("span",{className:"text-primary font-medium",children:[" ",P," connected"]})]})]}),e.jsx("div",{className:"space-y-3",children:H.map((t,s)=>{const n=t.status.authenticated,R=t.status.loading;return e.jsxs("div",{className:`group flex items-center justify-between p-4 rounded-xl border transition-all duration-200 ${n?"bg-primary/5 border-primary/20":"bg-card border-border/50 hover:border-border"}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center flex-shrink-0 ${n?"bg-primary/10":"bg-muted/60"}`,children:t.logo}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium text-sm text-foreground flex items-center gap-2",children:[t.name,n&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md bg-green-500/10 text-green-600 dark:text-green-400 text-[10px] font-semibold uppercase tracking-wider",children:[e.jsx(me,{className:"w-3 h-3"}),"Connected"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:R?"Checking...":n?t.status.email||"Ready to use":"Not connected"})]})]}),!n&&!R&&e.jsx("button",{onClick:t.onLogin,className:"px-4 py-2 text-sm font-medium rounded-lg bg-foreground text-background hover:opacity-90 transition-opacity flex-shrink-0",children:"Connect"})]},s)})}),e.jsx("p",{className:"text-xs text-muted-foreground/60 text-center",children:"You can always add or change these in Settings later."})]})]}),w&&e.jsx("div",{className:"mx-8 sm:mx-10 mb-2 p-3 rounded-xl bg-destructive/10 border border-destructive/20",children:e.jsx("p",{className:"text-sm text-destructive",children:w})}),e.jsxs("div",{className:"flex items-center justify-between px-8 sm:px-10 py-5 border-t border-border/40 bg-muted/20",children:[e.jsxs("button",{onClick:V,disabled:a===0||o,className:"flex items-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground disabled:opacity-0 disabled:pointer-events-none transition-all duration-200",children:[e.jsx(xe,{className:"w-4 h-4"}),"Back"]}),a<f.length-1?e.jsx("button",{onClick:J,disabled:!Z()||o,className:"flex items-center gap-2 px-6 py-2.5 bg-primary text-primary-foreground font-medium text-sm rounded-xl hover:opacity-90 disabled:opacity-50 disabled:cursor-not-allowed transition-all duration-200 shadow-sm",children:o?e.jsxs(e.Fragment,{children:[e.jsx($,{className:"w-4 h-4 animate-spin"}),"Saving..."]}):a===0?e.jsxs(e.Fragment,{children:["Get Started",e.jsx(O,{className:"w-4 h-4"})]}):e.jsxs(e.Fragment,{children:["Continue",e.jsx(ge,{className:"w-4 h-4"})]})}):e.jsx("button",{onClick:W,disabled:o,className:"flex items-center gap-2 px-6 py-2.5 bg-primary text-primary-foreground font-medium text-sm rounded-xl hover:opacity-90 disabled:opacity-50 disabled:cursor-not-allowed transition-all duration-200 shadow-sm",children:o?e.jsxs(e.Fragment,{children:[e.jsx($,{className:"w-4 h-4 animate-spin"}),"Finishing..."]}):e.jsxs(e.Fragment,{children:["Start Building",e.jsx(O,{className:"w-4 h-4"})]})})]})]}),e.jsxs("p",{className:"text-center text-xs text-muted-foreground/50 mt-6",children:["Step ",a+1," of ",f.length]})]})}),i&&e.jsx(X,{isOpen:!!i,onClose:()=>g(null),provider:i,project:B,onComplete:z,isOnboarding:!0})]})};export{ke as default};
@@ -1 +0,0 @@
1
- import{r as t,j as e}from"./vendor-react-96lCPsRK.js";import{h as y}from"./index-C5ptjuTl.js";import"./vendor-syntax-DuHI9Ok6.js";import"./vendor-markdown-CimbIo6Y.js";import"./vendor-icons-BaD0x9SL.js";import"./vendor-i18n-DCFGyhQR.js";const q=()=>{const[a,f]=t.useState(""),[d,p]=t.useState(""),[l,x]=t.useState(""),[n,g]=t.useState(""),[u,h]=t.useState(""),[s,i]=t.useState(!1),[c,o]=t.useState(""),{register:j}=y(),N=async r=>{if(r.preventDefault(),o(""),n!==u){o("Passwords do not match");return}if(!a.trim()||a.trim().length<2){o("Name must be at least 2 characters");return}if(!d.trim()||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d)){o("Please enter a valid email address");return}if(n.length<6){o("Password must be at least 6 characters");return}i(!0);const m=a.trim().split(" "),w=m[0]||a.trim(),v=m.slice(1).join(" ")||"",b=await j(w,v,n,d.trim(),l.trim()||null);b.success||o(b.error),i(!1)};return e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsx("div",{className:"w-full max-w-md",children:e.jsxs("div",{className:"bg-card rounded-lg shadow-lg border border-border p-8 space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("img",{src:"/logo.svg",alt:"Upfyn-Code",className:"w-16 h-16",onError:r=>{r.target.style.display="none"}})}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Create Your Account"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"Sign up to start using Upfyn-Code"})]}),e.jsxs("form",{onSubmit:N,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-foreground mb-1",children:"Full Name"}),e.jsx("input",{type:"text",id:"name",value:a,onChange:r=>f(r.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"Your full name",required:!0,disabled:s})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email",className:"block text-sm font-medium text-foreground mb-1",children:"Email"}),e.jsx("input",{type:"email",id:"email",value:d,onChange:r=>p(r.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"you@example.com",required:!0,disabled:s})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"phone",className:"block text-sm font-medium text-foreground mb-1",children:"Mobile Number"}),e.jsx("input",{type:"tel",id:"phone",value:l,onChange:r=>x(r.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"+91 9876543210",disabled:s})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-foreground mb-1",children:"Password"}),e.jsx("input",{type:"password",id:"password",value:n,onChange:r=>g(r.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"At least 6 characters",required:!0,disabled:s})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"confirmPassword",className:"block text-sm font-medium text-foreground mb-1",children:"Confirm Password"}),e.jsx("input",{type:"password",id:"confirmPassword",value:u,onChange:r=>h(r.target.value),className:"w-full px-3 py-2 border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"Confirm your password",required:!0,disabled:s})]}),c&&e.jsx("div",{className:"p-3 bg-red-100 dark:bg-red-900/20 border border-red-300 dark:border-red-800 rounded-md",children:e.jsx("p",{className:"text-sm text-red-700 dark:text-red-400",children:c})}),e.jsx("button",{type:"submit",disabled:s,className:"w-full bg-blue-600 hover:bg-blue-700 disabled:bg-blue-400 text-white font-medium py-2 px-4 rounded-md transition-colors duration-200",children:s?"Creating account...":"Create Account"})]})]})})})};export{q as default};
@@ -1 +0,0 @@
1
- import{r as s,j as e,R as be}from"./vendor-react-96lCPsRK.js";import{d as U,b as $}from"./index-C5ptjuTl.js";import{L as D,b2 as Q,P as J,X as q,f as ne,b as re,b3 as fe,a4 as je,a9 as me,b0 as ue,k as ge,i as oe,g as ee,C as te,h as ae,b4 as V,v as le,j as ie,M as Ne,Z,G as ye,b5 as ve,a1 as we,O as ke,a7 as Ce,l as Se,b6 as Ee,R as Ae,b7 as Ie,b8 as Te,b9 as _e,ba as Le,bb as Re,bc as De,bd as Oe,be as Pe,bf as Ge,$ as Me,w as Ue,aD as $e,bg as We,av as Fe,bh as He}from"./vendor-icons-BaD0x9SL.js";import"./vendor-syntax-DuHI9Ok6.js";import"./vendor-markdown-CimbIo6Y.js";import"./vendor-i18n-DCFGyhQR.js";const Be={"ai-prompt":"bg-blue-500/10 text-blue-400 ring-blue-500/20",webhook:"bg-yellow-500/10 text-yellow-400 ring-yellow-500/20",delay:"bg-purple-500/10 text-purple-400 ring-purple-500/20",condition:"bg-green-500/10 text-green-400 ring-green-500/20",integration:"bg-cyan-500/10 text-cyan-400 ring-cyan-500/20"},Ke=["Send a Slack message when a GitHub issue is created","Email me a daily summary of calendar events","Create a Notion page from each new Trello card","Notify Discord when a payment is received"];function ze({onEdit:o,onCreate:h,refreshKey:b}){const[N,E]=s.useState([]),[A,C]=s.useState(!0),[d,f]=s.useState(null),[m,v]=s.useState(null),[l,j]=s.useState(null),[c,t]=s.useState([]),[u,g]=s.useState(!1),[w,S]=s.useState(!1),[T,R]=s.useState(""),[M,O]=s.useState(!1),[W,I]=s.useState(""),P=s.useCallback(async()=>{try{const a=await U("/api/workflows");if(a.ok){const n=await a.json();E(n.workflows||[])}}catch{}C(!1)},[]);s.useEffect(()=>{P()},[P,b]);const G=async a=>{if(l===a){j(null);return}j(a),g(!0);try{const n=await U(`/api/workflows/${a}/runs`);if(n.ok){const i=await n.json();t(i.runs||[])}}catch{t([])}g(!1)},B=async a=>{try{await U(`/api/workflows/${a}`,{method:"DELETE"}),P()}catch{}},F=async a=>{var n;f(a),v(null);try{const L=await(await U(`/api/workflows/${a}/run`,{method:"POST"})).json();v({id:a,success:L.success,message:L.success?`Completed ${((n=L.results)==null?void 0:n.length)||0} steps`:L.error||"Failed",results:L.results}),P()}catch{v({id:a,success:!1,message:"Network error"})}f(null)},K=async()=>{if(T.trim()){O(!0),I("");try{const a=await U("/api/workflows/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:T.trim()})}),n=await a.json();a.ok&&n.success?(S(!1),R(""),P(),n.workflow&&o(n.workflow)):I(n.error||"Failed to generate workflow")}catch{I("Network error")}O(!1)}};return A?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 gap-3",children:[e.jsx(D,{className:"w-5 h-5 animate-spin text-muted-foreground/50"}),e.jsx("span",{className:"text-xs text-muted-foreground/40",children:"Loading workflows..."})]}):e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-foreground tracking-tight",children:"Workflows"}),e.jsx("p",{className:"text-xs text-muted-foreground/50 mt-0.5",children:"Automate tasks with AI prompts, webhooks, and integrations"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>S(!w),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium rounded-lg transition-all ${w?"bg-primary/10 text-primary":"bg-muted/30 text-muted-foreground hover:text-foreground hover:bg-muted/50"}`,children:[e.jsx(Q,{className:"w-3.5 h-3.5"}),"AI Create"]}),e.jsxs("button",{onClick:h,className:"flex items-center gap-1.5 px-3.5 py-2 text-xs font-medium bg-foreground text-background rounded-lg hover:opacity-90 transition-opacity",children:[e.jsx(J,{className:"w-3.5 h-3.5"}),"New Workflow"]})]})]}),w&&e.jsxs("div",{className:"bg-gradient-to-br from-primary/[0.03] to-transparent border border-primary/15 rounded-2xl p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-primary/10",children:e.jsx(Q,{className:"w-3.5 h-3.5 text-primary"})}),e.jsx("span",{className:"text-xs font-semibold text-foreground",children:"Describe your workflow"})]}),e.jsx("button",{onClick:()=>{S(!1),I("")},className:"p-1 text-muted-foreground/40 hover:text-foreground rounded-lg transition-colors",children:e.jsx(q,{className:"w-3.5 h-3.5"})})]}),e.jsx("textarea",{value:T,onChange:a=>R(a.target.value),placeholder:"Describe what you want to automate in plain English...",rows:3,className:"w-full px-3.5 py-2.5 text-sm bg-background border border-border/40 rounded-xl text-foreground placeholder-muted-foreground/40 focus:outline-none focus:border-primary/40 focus:ring-1 focus:ring-primary/10 resize-none transition-colors",onKeyDown:a=>{a.key==="Enter"&&(a.metaKey||a.ctrlKey)&&!M&&K()}}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Ke.map(a=>e.jsx("button",{onClick:()=>R(a),className:"px-2.5 py-1 text-[10px] text-muted-foreground/50 hover:text-foreground bg-muted/20 hover:bg-muted/40 rounded-full transition-colors",children:a},a))}),W&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs text-red-400 bg-red-500/[0.03] border border-red-500/15 rounded-xl",children:[e.jsx(ne,{className:"w-3.5 h-3.5 flex-shrink-0"}),W]}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{onClick:K,disabled:M||!T.trim(),className:"flex items-center gap-1.5 px-4 py-2 text-xs font-medium bg-foreground text-background rounded-lg hover:opacity-90 transition-opacity disabled:opacity-40",children:M?e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"w-3.5 h-3.5 animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"w-3.5 h-3.5"}),"Generate Workflow"]})})})]}),N.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-muted/30 flex items-center justify-center mb-4",children:e.jsx(re,{className:"w-7 h-7 text-muted-foreground/25"})}),e.jsx("h4",{className:"text-sm font-semibold text-foreground tracking-tight mb-1",children:"No workflows yet"}),e.jsx("p",{className:"text-xs text-muted-foreground/50 max-w-xs leading-relaxed mb-5",children:"Chain AI prompts, webhook calls, conditions, and app integrations into automated pipelines."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>S(!0),className:"flex items-center gap-1.5 px-3.5 py-2 text-xs font-medium bg-primary/10 text-primary rounded-lg hover:bg-primary/15 transition-colors",children:[e.jsx(Q,{className:"w-3.5 h-3.5"}),"Create with AI"]}),e.jsxs("button",{onClick:h,className:"flex items-center gap-1.5 px-4 py-2 text-xs font-medium bg-foreground text-background rounded-lg hover:opacity-90 transition-opacity",children:[e.jsx(J,{className:"w-3.5 h-3.5"}),"Create Manually"]})]})]}):e.jsx("div",{className:"space-y-3",children:N.map((a,n)=>e.jsxs("div",{className:"bg-card/50 border border-border/30 rounded-2xl p-4 hover:border-border/50 transition-all duration-200",style:{animationDelay:`${n*30}ms`},children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h4",{className:"text-sm font-semibold text-foreground tracking-tight",children:a.name}),a.schedule&&a.schedule_enabled?e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-primary/70 bg-primary/5 px-1.5 py-0.5 rounded-full",children:[e.jsx(fe,{className:"w-2.5 h-2.5"}),"Scheduled"]}):null]}),a.description&&e.jsx("p",{className:"text-xs text-muted-foreground/60 mb-3 line-clamp-1",children:a.description}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[a.steps.map((i,L)=>e.jsxs(be.Fragment,{children:[e.jsx("span",{className:`inline-flex items-center gap-1 text-[10px] font-medium px-2 py-0.5 rounded-full ring-1 ${Be[i.type]||"bg-muted text-muted-foreground ring-border/30"}`,children:i.label}),L<a.steps.length-1&&e.jsx(je,{className:"w-3 h-3 text-muted-foreground/20 flex-shrink-0"})]},i.id||L)),a.steps.length===0&&e.jsx("span",{className:"text-[10px] text-muted-foreground/30 italic",children:"No steps configured"})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-2.5 text-[10px] text-muted-foreground/35",children:[e.jsxs("span",{children:[a.steps.length," step",a.steps.length!==1?"s":""]}),a.schedule&&a.schedule_enabled&&e.jsx("span",{className:"font-mono",children:a.schedule}),a.last_run&&e.jsxs("span",{children:["Last run ",new Date(a.last_run).toLocaleDateString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsxs("button",{onClick:()=>F(a.id),disabled:d===a.id||a.steps.length===0,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium bg-green-500/8 text-green-400 hover:bg-green-500/15 rounded-lg transition-colors disabled:opacity-30",title:"Run workflow",children:[d===a.id?e.jsx(D,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(me,{className:"w-3.5 h-3.5"}),"Run"]}),e.jsx("button",{onClick:()=>G(a.id),className:`p-2 rounded-lg transition-colors ${l===a.id?"text-primary bg-primary/5":"text-muted-foreground/40 hover:text-foreground hover:bg-muted/30"}`,title:"Execution history",children:e.jsx(ue,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>o(a),className:"p-2 text-muted-foreground/40 hover:text-foreground hover:bg-muted/30 rounded-lg transition-colors",title:"Edit",children:e.jsx(ge,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>B(a.id),className:"p-2 text-muted-foreground/40 hover:text-red-400 hover:bg-red-500/5 rounded-lg transition-colors",title:"Delete",children:e.jsx(oe,{className:"w-3.5 h-3.5"})})]})]}),(m==null?void 0:m.id)===a.id&&e.jsxs("div",{className:`mt-3 p-3 rounded-xl text-xs ${m.success?"bg-green-500/[0.03] border border-green-500/15":"bg-red-500/[0.03] border border-red-500/15"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[m.success?e.jsx(ee,{className:"w-3.5 h-3.5 text-green-400"}):e.jsx(te,{className:"w-3.5 h-3.5 text-red-400"}),e.jsx("span",{className:`font-medium ${m.success?"text-green-400":"text-red-400"}`,children:m.message})]}),m.results&&e.jsx("div",{className:"space-y-1 mt-2",children:m.results.map((i,L)=>{var H;return e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[i.success?e.jsx(ee,{className:"w-2.5 h-2.5 text-green-400/60"}):e.jsx(te,{className:"w-2.5 h-2.5 text-red-400/60"}),e.jsx("span",{className:"text-muted-foreground",children:i.label}),((H=i.result)==null?void 0:H.status)&&e.jsxs("span",{className:"text-muted-foreground/30",children:["(",i.result.status,")"]}),i.error&&e.jsx("span",{className:"text-red-400/60",children:i.error})]},L)})})]}),l===a.id&&e.jsxs("div",{className:"mt-3 border-t border-border/15 pt-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2.5",children:[e.jsx(ue,{className:"w-3 h-3 text-muted-foreground/50"}),e.jsx("span",{className:"text-[11px] font-semibold text-foreground",children:"Execution History"})]}),u?e.jsxs("div",{className:"flex items-center gap-2 py-3 text-[10px] text-muted-foreground/40",children:[e.jsx(D,{className:"w-3 h-3 animate-spin"}),"Loading..."]}):c.length===0?e.jsx("div",{className:"text-[10px] text-muted-foreground/30 py-3 italic",children:"No runs yet"}):e.jsx("div",{className:"space-y-1.5 max-h-48 overflow-y-auto",children:c.map(i=>e.jsxs("div",{className:"flex items-start gap-2.5 text-[10px] bg-muted/10 rounded-lg p-2.5",children:[e.jsx("div",{className:"shrink-0 mt-0.5",children:i.status==="completed"?e.jsx(ee,{className:"w-3 h-3 text-green-400"}):i.status==="failed"?e.jsx(te,{className:"w-3 h-3 text-red-400"}):i.status==="running"?e.jsx(D,{className:"w-3 h-3 text-yellow-400 animate-spin"}):e.jsx(ae,{className:"w-3 h-3 text-muted-foreground/40"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`font-medium ${i.status==="completed"?"text-green-400":i.status==="failed"?"text-red-400":"text-muted-foreground"}`,children:i.status==="completed"?"Success":i.status==="failed"?"Failed":i.status}),e.jsxs("span",{className:"text-muted-foreground/25",children:[i.steps_completed,"/",i.total_steps," steps"]}),e.jsx("span",{className:"text-muted-foreground/25",children:new Date(i.started_at).toLocaleString()})]}),i.error&&e.jsx("p",{className:"text-red-400/60 mt-0.5 truncate",children:i.error}),i.completed_at&&e.jsxs("span",{className:"text-muted-foreground/20",children:["Duration: ",Math.round((new Date(i.completed_at).getTime()-new Date(i.started_at).getTime())/1e3),"s"]})]})]},i.id))})]})]},a.id))})]})}const de=[{id:"GMAIL",name:"Gmail",icon:"mail",keywords:["gmail","email","send email","inbox","mail"],authConfigId:null,popularActions:[{slug:"GMAIL_SEND_EMAIL",label:"Send Email",params:["to","subject","body"]},{slug:"GMAIL_FETCH_EMAILS",label:"Fetch Emails",params:["query","max_results"]}]},{id:"GOOGLECALENDAR",name:"Google Calendar",icon:"calendar",keywords:["calendar","event","meeting","schedule meeting"],authConfigId:null,popularActions:[{slug:"GOOGLECALENDAR_CREATE_EVENT",label:"Create Event",params:["summary","start_time","end_time"]},{slug:"GOOGLECALENDAR_LIST_EVENTS",label:"List Events",params:["time_min","time_max"]}]},{id:"SLACK",name:"Slack",icon:"hash",keywords:["slack","channel","slack message"],authConfigId:null,popularActions:[{slug:"SLACK_SENDS_A_MESSAGE_TO_A_SLACK_CHANNEL",label:"Send Message",params:["channel","text"]}]},{id:"GITHUB",name:"GitHub",icon:"github",keywords:["github","repository","pull request","issue","commit"],authConfigId:null,popularActions:[{slug:"GITHUB_CREATE_AN_ISSUE",label:"Create Issue",params:["owner","repo","title","body"]},{slug:"GITHUB_CREATE_A_PULL_REQUEST",label:"Create PR",params:["owner","repo","title","head","base"]}]},{id:"NOTION",name:"Notion",icon:"file-text",keywords:["notion","page","note"],authConfigId:null,popularActions:[{slug:"NOTION_CREATE_A_PAGE",label:"Create Page",params:["parent_id","title","content"]}]},{id:"DISCORD",name:"Discord",icon:"message-circle",keywords:["discord"],authConfigId:null,popularActions:[{slug:"DISCORD_SEND_MESSAGE",label:"Send Message",params:["channel_id","content"]}]},{id:"GOOGLEDRIVE",name:"Google Drive",icon:"hard-drive",keywords:["drive","google drive","upload file","file storage"],authConfigId:null,popularActions:[{slug:"GOOGLEDRIVE_UPLOAD_FILE",label:"Upload File",params:["file_name","content"]},{slug:"GOOGLEDRIVE_LIST_FILES",label:"List Files",params:["query"]}]},{id:"TRELLO",name:"Trello",icon:"kanban",keywords:["trello","board","card","kanban"],authConfigId:null,popularActions:[{slug:"TRELLO_CREATE_CARD",label:"Create Card",params:["list_id","name","desc"]}]},{id:"LINEAR",name:"Linear",icon:"bug",keywords:["linear","ticket","linear issue"],authConfigId:null,popularActions:[{slug:"LINEAR_CREATE_ISSUE",label:"Create Issue",params:["team_id","title","description"]},{slug:"LINEAR_LIST_ISSUES",label:"List Issues",params:["team_id","status"]}]},{id:"JIRA",name:"Jira",icon:"bug",keywords:["jira","sprint","jira issue","jira ticket"],authConfigId:null,popularActions:[{slug:"JIRA_CREATE_ISSUE",label:"Create Issue",params:["project_key","summary","description","issue_type"]},{slug:"JIRA_GET_ISSUE",label:"Get Issue",params:["issue_key"]}]},{id:"ASANA",name:"Asana",icon:"list-checks",keywords:["asana","task","asana task","project management"],authConfigId:null,popularActions:[{slug:"ASANA_CREATE_TASK",label:"Create Task",params:["project_id","name","notes"]},{slug:"ASANA_LIST_TASKS",label:"List Tasks",params:["project_id"]}]},{id:"STRIPE",name:"Stripe",icon:"credit-card",keywords:["stripe","payment","invoice","charge","billing"],authConfigId:null,popularActions:[{slug:"STRIPE_CREATE_INVOICE",label:"Create Invoice",params:["customer_id","amount","currency"]},{slug:"STRIPE_LIST_PAYMENTS",label:"List Payments",params:["limit"]}]},{id:"TWILIO",name:"Twilio",icon:"phone",keywords:["twilio","sms","text message","phone"],authConfigId:null,popularActions:[{slug:"TWILIO_SEND_SMS",label:"Send SMS",params:["to","body"]}]},{id:"AIRTABLE",name:"Airtable",icon:"table",keywords:["airtable","spreadsheet","database","airtable record"],authConfigId:null,popularActions:[{slug:"AIRTABLE_CREATE_RECORD",label:"Create Record",params:["base_id","table_name","fields"]},{slug:"AIRTABLE_LIST_RECORDS",label:"List Records",params:["base_id","table_name"]}]}],Y={};for(const o of de)for(const h of o.keywords)Y[h.toLowerCase()]=o.id;const ce={};for(const o of de)ce[o.id]=o;function Je({stepId:o,config:h,onUpdateConfig:b}){const[N,E]=s.useState([]),[A,C]=s.useState(!0),[d,f]=s.useState(!1),[m,v]=s.useState(!1);s.useEffect(()=>{$.composio.catalog().then(t=>t.json()).then(t=>{E(t.catalog||[]),v(t.composioAvailable),C(!1)}).catch(()=>{E(de.map(t=>({...t,connected:!1,connectionId:null}))),C(!1)})},[]);const l=N.find(t=>t.id===h.integrationId),j=l==null?void 0:l.popularActions.find(t=>t.slug===h.toolSlug),c=async t=>{f(!0);try{const g=await(await $.composio.connect(t)).json();if(g.redirectUrl){const w=window.open(g.redirectUrl,"composio_oauth","width=600,height=700,popup=yes"),S=setInterval(async()=>{try{if((await(await $.composio.waitForConnection(g.connectedAccountId)).json()).status==="ACTIVE"){clearInterval(S),w==null||w.close();const O=await(await $.composio.catalog()).json();E(O.catalog||[]),f(!1)}}catch{}},2e3);setTimeout(()=>{clearInterval(S),f(!1)},12e4)}}catch{f(!1)}};return A?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground/50 py-3",children:[e.jsx(D,{className:"w-3 h-3 animate-spin"}),"Loading integrations..."]}):m?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground/60 mb-1 block",children:"Integration"}),e.jsxs("select",{value:h.integrationId||"",onChange:t=>{const u=t.target.value;b("integrationId",u),b("toolSlug",""),b("arguments",{})},className:"w-full px-3 py-2 text-xs bg-background border border-border/40 rounded-lg text-foreground focus:outline-none focus:border-primary/40 transition-colors",children:[e.jsx("option",{value:"",children:"Select an integration..."}),N.map(t=>e.jsxs("option",{value:t.id,children:[t.name," ",t.connected?"(Connected)":""]},t.id))]})]}),l&&!l.connected&&e.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-yellow-500/[0.03] border border-yellow-500/15 rounded-xl",children:[e.jsxs("span",{className:"text-[10px] text-yellow-400 flex-1",children:[l.name," is not connected yet."]}),e.jsxs("button",{onClick:()=>c(l.id),disabled:d,className:"flex items-center gap-1 px-2.5 py-1.5 text-[10px] font-medium bg-foreground text-background rounded-lg hover:opacity-90 disabled:opacity-50 transition-opacity",children:[d?e.jsx(D,{className:"w-3 h-3 animate-spin"}):e.jsx(le,{className:"w-3 h-3"}),"Connect"]})]}),l&&l.connected&&e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-green-400 font-medium",children:[e.jsx(ie,{className:"w-3 h-3"}),"Connected"]}),l&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground/60 mb-1 block",children:"Action"}),e.jsxs("select",{value:h.toolSlug||"",onChange:t=>{b("toolSlug",t.target.value),b("arguments",{})},className:"w-full px-3 py-2 text-xs bg-background border border-border/40 rounded-lg text-foreground focus:outline-none focus:border-primary/40 transition-colors",children:[e.jsx("option",{value:"",children:"Select an action..."}),l.popularActions.map(t=>e.jsx("option",{value:t.slug,children:t.label},t.slug))]})]}),j&&j.params.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground/60 block",children:"Parameters"}),j.params.map(t=>{var u;return e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-muted-foreground/40 mb-0.5 block capitalize",children:t.replace(/_/g," ")}),e.jsx("input",{value:((u=h.arguments)==null?void 0:u[t])||"",onChange:g=>{const w={...h.arguments||{},[t]:g.target.value};b("arguments",w)},placeholder:`{{prev.${t}}} or value`,className:"w-full px-3 py-2 text-xs bg-background border border-border/40 rounded-lg text-foreground placeholder-muted-foreground/25 focus:outline-none focus:border-primary/40 font-mono transition-colors"})]},t)}),e.jsxs("p",{className:"text-[10px] text-muted-foreground/30",children:["Use ","{{prev.field}}"," to reference output from the previous step."]})]})]}):e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground/50 py-3",children:[e.jsx(V,{className:"w-3.5 h-3.5"}),e.jsxs("span",{children:["Composio not configured. Set ",e.jsx("code",{className:"px-1 py-0.5 bg-muted/40 rounded text-[10px] font-mono",children:"COMPOSIO_API_KEY"})," on the server."]})]})}function Ve({keyword:o,integrationId:h,integrationName:b,position:N,onDismiss:E,onAddAction:A}){const[C,d]=s.useState(null),[f,m]=s.useState(!1),v=s.useRef(null),l=ce[h],j=(l==null?void 0:l.popularActions)||[];s.useEffect(()=>{$.composio.catalog().then(t=>t.json()).then(t=>{const u=(t.catalog||[]).find(g=>g.id===h);d((u==null?void 0:u.connected)||!1)}).catch(()=>d(!1))},[h]),s.useEffect(()=>{const t=g=>{v.current&&!v.current.contains(g.target)&&E()},u=g=>{g.key==="Escape"&&E()};return document.addEventListener("mousedown",t),document.addEventListener("keydown",u),()=>{document.removeEventListener("mousedown",t),document.removeEventListener("keydown",u)}},[E]);const c=async()=>{m(!0);try{const u=await(await $.composio.connect(h)).json();if(u.redirectUrl){const g=window.open(u.redirectUrl,"composio_oauth","width=600,height=700,popup=yes"),w=setInterval(async()=>{try{(await(await $.composio.waitForConnection(u.connectedAccountId)).json()).status==="ACTIVE"&&(clearInterval(w),g==null||g.close(),d(!0),m(!1))}catch{}},2e3);setTimeout(()=>{clearInterval(w),m(!1)},12e4)}}catch{m(!1)}};return e.jsxs("div",{ref:v,className:"fixed z-50 bg-card border border-border/40 rounded-2xl shadow-2xl overflow-hidden min-w-[240px] max-w-[300px]",style:{top:N.top,left:Math.min(N.left,window.innerWidth-320)},children:[e.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 bg-muted/20 border-b border-border/20",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-cyan-500/10",children:e.jsx(re,{className:"w-3.5 h-3.5 text-cyan-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs font-semibold text-foreground",children:b}),e.jsxs("div",{className:"text-[10px] text-muted-foreground/40",children:['Detected "',e.jsx("span",{className:"text-primary/60 font-medium",children:o}),'"']})]}),e.jsx("button",{onClick:E,className:"p-1 text-muted-foreground/30 hover:text-foreground rounded-lg transition-colors",children:e.jsx(q,{className:"w-3.5 h-3.5"})})]}),e.jsxs("div",{className:"p-1.5",children:[C===null&&e.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-3 text-xs text-muted-foreground/50",children:[e.jsx(D,{className:"w-3 h-3 animate-spin"}),"Checking connection..."]}),C===!1&&e.jsxs("button",{onClick:c,disabled:f,className:"w-full flex items-center gap-2.5 px-2.5 py-2.5 text-xs text-foreground hover:bg-muted/30 rounded-xl transition-colors",children:[f?e.jsx(D,{className:"w-3.5 h-3.5 animate-spin text-primary"}):e.jsx(le,{className:"w-3.5 h-3.5 text-primary"}),e.jsxs("span",{children:["Connect ",b," to use this"]})]}),C===!0&&j.length>0&&e.jsx("div",{className:"space-y-0.5",children:j.map(t=>e.jsxs("button",{onClick:()=>A(h,t.slug,t.label),className:"w-full flex items-center gap-2.5 px-2.5 py-2 text-xs text-foreground hover:bg-muted/30 rounded-xl transition-colors group",children:[e.jsx(J,{className:"w-3.5 h-3.5 text-cyan-400 group-hover:text-cyan-300"}),e.jsxs("span",{className:"flex-1 text-left",children:["Add: ",t.label]})]},t.slug))})]})]})}function qe(){const[o,h]=s.useState(null),b=s.useRef(null),N=s.useRef(null),E=s.useCallback((d,f,m)=>{b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{if(!d||f===0){h(null);return}const l=d.slice(0,f).toLowerCase().split(/\s+/).filter(Boolean);let j=null;if(l.length>=2){const c=`${l[l.length-2]} ${l[l.length-1]}`;Y[c]&&(j=c)}if(!j&&l.length>=1){const c=l[l.length-1];Y[c]&&(j=c)}if(j&&j!==N.current){const c=Y[j],t=ce[c];if(t){h({keyword:j,integrationId:c,integrationName:t.name,position:m?{top:m.bottom+4,left:m.left}:{top:0,left:0}});return}}h(null)},300)},[]),A=s.useCallback(()=>{o&&(N.current=o.keyword),h(null)},[o]),C=s.useCallback(()=>{N.current=null},[]);return s.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]),{activeMatch:o,detectKeywords:E,dismiss:A,resetDismissed:C}}const se=[{value:"ai-prompt",label:"AI Prompt",desc:"Ask AI to process data",icon:Ne,color:"text-blue-400 bg-blue-500/10",ring:"ring-blue-500/20"},{value:"webhook",label:"Webhook",desc:"Call an HTTP endpoint",icon:Z,color:"text-yellow-400 bg-yellow-500/10",ring:"ring-yellow-500/20"},{value:"delay",label:"Delay",desc:"Wait before continuing",icon:ae,color:"text-purple-400 bg-purple-500/10",ring:"ring-purple-500/20"},{value:"condition",label:"Condition",desc:"Branch on a condition",icon:ye,color:"text-green-400 bg-green-500/10",ring:"ring-green-500/20"},{value:"integration",label:"Integration",desc:"Use a connected app",icon:V,color:"text-cyan-400 bg-cyan-500/10",ring:"ring-cyan-500/20"}];let Ye=0;const xe=()=>`step_${Date.now()}_${++Ye}`,Ze=[{label:"Every minute",cron:"* * * * *"},{label:"Every 5 minutes",cron:"*/5 * * * *"},{label:"Every 15 minutes",cron:"*/15 * * * *"},{label:"Every hour",cron:"0 * * * *"},{label:"Every 6 hours",cron:"0 */6 * * *"},{label:"Daily at midnight",cron:"0 0 * * *"},{label:"Daily at 9 AM",cron:"0 9 * * *"},{label:"Weekly (Monday)",cron:"0 9 * * 1"},{label:"Monthly (1st)",cron:"0 0 1 * *"}];function Xe({workflow:o,onSave:h,onCancel:b}){const[N,E]=s.useState((o==null?void 0:o.name)||""),[A,C]=s.useState((o==null?void 0:o.description)||""),[d,f]=s.useState((o==null?void 0:o.steps)||[]),[m,v]=s.useState((o==null?void 0:o.schedule)||""),[l,j]=s.useState(!!(o!=null&&o.schedule_enabled)),[c,t]=s.useState((o==null?void 0:o.schedule_timezone)||Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"),[u,g]=s.useState([]),[w,S]=s.useState(!1),[T,R]=s.useState(""),[M,O]=s.useState(null),[W,I]=s.useState(!1),P=s.useRef(null),{activeMatch:G,detectKeywords:B,dismiss:F}=qe();s.useEffect(()=>{U("/api/webhooks").then(r=>r.json()).then(r=>{g(r.webhooks||[])}).catch(()=>{})},[]);const K=s.useCallback(r=>{const k=se.find(y=>y.value===r),p={id:xe(),type:r,label:(k==null?void 0:k.label)||r,config:r==="delay"?{seconds:5}:{},order:d.length};f(y=>[...y,p]),O(p.id),I(!1)},[d.length]),a=s.useCallback(r=>{f(k=>k.filter(p=>p.id!==r).map((p,y)=>({...p,order:y}))),M===r&&O(null)},[M]),n=s.useCallback((r,k)=>{f(p=>{const y=p.findIndex(z=>z.id===r);if(y<0)return p;const _=k==="up"?y-1:y+1;if(_<0||_>=p.length)return p;const x=[...p];return[x[y],x[_]]=[x[_],x[y]],x.map((z,he)=>({...z,order:he}))})},[]),i=s.useCallback((r,k,p)=>{f(y=>y.map(_=>_.id===r?{..._,config:{..._.config,[k]:p}}:_))},[]),L=s.useCallback((r,k)=>{f(p=>p.map(y=>y.id===r?{...y,label:k}:y))},[]),H=s.useCallback((r,k,p)=>{const y={id:xe(),type:"integration",label:p,config:{integrationId:r,toolSlug:k,arguments:{}},order:d.length};f(_=>[..._,y]),O(y.id),F()},[d.length,F]),X=s.useCallback(r=>{const k=r.target.value;C(k);const p=r.target.getBoundingClientRect();B(k,r.target.selectionStart||0,p)},[B]),pe=async()=>{if(R(""),!N.trim()){R("Workflow name is required");return}if(d.length===0){R("Add at least one step");return}S(!0);try{const r={name:N,description:A,steps:d,schedule:m||null,schedule_enabled:l,schedule_timezone:c},k=o!=null&&o.id?`/api/workflows/${o.id}`:"/api/workflows",p=o!=null&&o.id?"PUT":"POST",y=await U(k,{method:p,headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!y.ok){const _=await y.json();R(_.error||"Failed to save"),S(!1);return}h()}catch{R("Network error")}S(!1)};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border/20 bg-card/50",children:[e.jsx("button",{onClick:b,className:"p-1.5 text-muted-foreground hover:text-foreground hover:bg-muted/30 rounded-lg transition-colors",children:e.jsx(ve,{className:"w-4 h-4"})}),e.jsx("span",{className:"text-sm font-semibold text-foreground tracking-tight",children:o!=null&&o.id?"Edit Workflow":"New Workflow"}),e.jsx("div",{className:"flex-1"}),e.jsxs("button",{onClick:pe,disabled:w,className:"flex items-center gap-1.5 px-4 py-2 text-xs font-medium bg-foreground text-background rounded-lg hover:opacity-90 transition-opacity disabled:opacity-50",children:[e.jsx(we,{className:"w-3.5 h-3.5"}),w?"Saving...":"Save Workflow"]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-5",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-medium text-muted-foreground/70 mb-1.5 block",children:"Name"}),e.jsx("input",{value:N,onChange:r=>E(r.target.value),placeholder:"My Workflow",className:"w-full px-3.5 py-2.5 text-sm bg-background border border-border/40 rounded-xl text-foreground placeholder-muted-foreground/40 focus:outline-none focus:border-primary/40 focus:ring-1 focus:ring-primary/10 transition-colors"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-medium text-muted-foreground/70 mb-1.5 block",children:"Description"}),e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{ref:P,value:A,onChange:X,placeholder:"Describe what this workflow does... Try typing 'email', 'slack', or 'calendar' to auto-detect integrations",rows:2,className:"w-full px-3.5 py-2.5 text-xs bg-background border border-border/40 rounded-xl text-foreground placeholder-muted-foreground/40 focus:outline-none focus:border-primary/40 focus:ring-1 focus:ring-primary/10 resize-none transition-colors"}),G&&e.jsx(Ve,{keyword:G.keyword,integrationId:G.integrationId,integrationName:G.integrationName,position:G.position,onDismiss:F,onAddAction:H})]})]})]}),e.jsxs("div",{className:"bg-card/50 border border-border/30 rounded-2xl p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-semibold text-foreground flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 rounded-lg bg-purple-500/10",children:e.jsx(ae,{className:"w-3.5 h-3.5 text-purple-400"})}),"Schedule"]}),e.jsx("button",{onClick:()=>j(!l),className:`relative w-9 h-5 rounded-full transition-colors ${l?"bg-primary":"bg-muted/60"}`,children:e.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white shadow-sm transition-transform ${l?"translate-x-[18px]":"translate-x-0.5"}`})})]}),l&&e.jsxs("div",{className:"space-y-3 pt-1",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground/60 mb-1 block",children:"Cron Expression"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{value:m,onChange:r=>v(r.target.value),placeholder:"*/15 * * * *",className:"flex-1 px-3 py-2 text-xs bg-background border border-border/40 rounded-lg text-foreground placeholder-muted-foreground/40 focus:outline-none focus:border-primary/40 font-mono transition-colors"}),e.jsxs("select",{value:m,onChange:r=>v(r.target.value),className:"px-3 py-2 text-xs bg-background border border-border/40 rounded-lg text-foreground focus:outline-none focus:border-primary/40 transition-colors",children:[e.jsx("option",{value:"",children:"Presets..."}),Ze.map(r=>e.jsx("option",{value:r.cron,children:r.label},r.cron))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground/60 mb-1 block",children:"Timezone"}),e.jsx("input",{value:c,onChange:r=>t(r.target.value),placeholder:"UTC",className:"w-48 px-3 py-2 text-xs bg-background border border-border/40 rounded-lg text-foreground placeholder-muted-foreground/40 focus:outline-none focus:border-primary/40 transition-colors"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground/35 leading-relaxed",children:'Runs automatically when the server is online. Missed runs while offline appear as "missed" in execution history.'})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center justify-between mb-3",children:e.jsxs("span",{className:"text-xs font-semibold text-foreground",children:["Steps (",d.length,")"]})}),d.length===0?e.jsx("div",{className:"text-center py-10 border border-dashed border-border/30 rounded-2xl",children:e.jsx("p",{className:"text-xs text-muted-foreground/40",children:"No steps yet. Add your first step below."})}):e.jsx("div",{className:"space-y-2",children:d.map((r,k)=>{const p=se.find(x=>x.value===r.type),y=(p==null?void 0:p.icon)||Z,_=M===r.id;return e.jsxs("div",{className:`border rounded-2xl overflow-hidden transition-colors ${_?"border-border/50 bg-card/50":"border-border/25 bg-card/30"}`,children:[e.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5 cursor-pointer hover:bg-muted/20 transition-colors",onClick:()=>O(_?null:r.id),children:[e.jsx(ke,{className:"w-3 h-3 text-muted-foreground/20 flex-shrink-0"}),e.jsx("span",{className:"text-xs text-muted-foreground/40 w-5 text-center font-mono",children:k+1}),e.jsx("div",{className:`p-1.5 rounded-lg ${(p==null?void 0:p.color)||"bg-muted text-muted-foreground"}`,children:e.jsx(y,{className:"w-3.5 h-3.5"})}),e.jsx("span",{className:"text-xs font-medium text-foreground flex-1 min-w-0 truncate",children:r.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground/35",children:p==null?void 0:p.label}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("button",{onClick:x=>{x.stopPropagation(),n(r.id,"up")},disabled:k===0,className:"p-1 text-muted-foreground/30 hover:text-foreground rounded transition-colors disabled:opacity-20",children:e.jsx(Ce,{className:"w-3 h-3"})}),e.jsx("button",{onClick:x=>{x.stopPropagation(),n(r.id,"down")},disabled:k===d.length-1,className:"p-1 text-muted-foreground/30 hover:text-foreground rounded transition-colors disabled:opacity-20",children:e.jsx(Se,{className:"w-3 h-3"})}),e.jsx("button",{onClick:x=>{x.stopPropagation(),a(r.id)},className:"p-1 text-muted-foreground/30 hover:text-red-400 rounded transition-colors",children:e.jsx(oe,{className:"w-3 h-3"})})]})]}),_&&e.jsxs("div",{className:"px-4 pb-4 pt-2 border-t border-border/15 space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground/60 mb-1 block",children:"Step Label"}),e.jsx("input",{value:r.label,onChange:x=>L(r.id,x.target.value),className:"w-full px-3 py-2 text-xs bg-background border border-border/40 rounded-lg text-foreground focus:outline-none focus:border-primary/40 transition-colors"})]}),r.type==="ai-prompt"&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground/60 mb-1 block",children:"Prompt"}),e.jsx("textarea",{value:r.config.prompt||"",onChange:x=>i(r.id,"prompt",x.target.value),placeholder:"Describe what the AI should do...",rows:3,className:"w-full px-3 py-2 text-xs bg-background border border-border/40 rounded-lg text-foreground placeholder-muted-foreground/40 focus:outline-none focus:border-primary/40 resize-none transition-colors"})]}),r.type==="webhook"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground/60 mb-1 block",children:"Webhook"}),e.jsxs("select",{value:r.config.webhookId||"",onChange:x=>i(r.id,"webhookId",x.target.value),className:"w-full px-3 py-2 text-xs bg-background border border-border/40 rounded-lg text-foreground focus:outline-none focus:border-primary/40 transition-colors",children:[e.jsx("option",{value:"",children:"Select a webhook..."}),u.map(x=>e.jsxs("option",{value:x.id,children:[x.name," (",x.method," ",x.url,")"]},x.id))]}),u.length===0&&e.jsx("p",{className:"text-[10px] text-muted-foreground/35 mt-1",children:"No webhooks created yet. Go to the Webhooks tab first."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground/60 mb-1 block",children:"Payload Template (JSON)"}),e.jsx("textarea",{value:r.config.payloadTemplate||"",onChange:x=>i(r.id,"payloadTemplate",x.target.value),placeholder:'{"key": "value"}',rows:2,className:"w-full px-3 py-2 text-xs bg-background border border-border/40 rounded-lg text-foreground placeholder-muted-foreground/40 focus:outline-none focus:border-primary/40 resize-none font-mono transition-colors"})]})]}),r.type==="delay"&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground/60 mb-1 block",children:"Delay (seconds, max 30)"}),e.jsx("input",{type:"number",min:1,max:30,value:r.config.seconds||5,onChange:x=>i(r.id,"seconds",Math.min(30,Math.max(1,parseInt(x.target.value)||1))),className:"w-24 px-3 py-2 text-xs bg-background border border-border/40 rounded-lg text-foreground focus:outline-none focus:border-primary/40 transition-colors"})]}),r.type==="condition"&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-medium text-muted-foreground/60 mb-1 block",children:"Condition Expression"}),e.jsx("input",{value:r.config.expression||"",onChange:x=>i(r.id,"expression",x.target.value),placeholder:"e.g. response.status === 200",className:"w-full px-3 py-2 text-xs bg-background border border-border/40 rounded-lg text-foreground placeholder-muted-foreground/40 focus:outline-none focus:border-primary/40 font-mono transition-colors"}),e.jsx("p",{className:"text-[10px] text-muted-foreground/30 mt-1",children:"Condition evaluation coming soon"})]}),r.type==="integration"&&e.jsx(Je,{stepId:r.id,config:r.config,onUpdateConfig:(x,z)=>i(r.id,x,z)})]})]},r.id)})}),e.jsx("div",{className:"mt-3",children:W?e.jsxs("div",{className:"border border-border/30 rounded-2xl p-3 bg-card/50",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2.5",children:[e.jsx("span",{className:"text-[11px] font-semibold text-foreground",children:"Add a step"}),e.jsx("button",{onClick:()=>I(!1),className:"p-1 text-muted-foreground/40 hover:text-foreground rounded transition-colors",children:e.jsx(q,{className:"w-3.5 h-3.5"})})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:se.map(r=>{const k=r.icon;return e.jsxs("button",{onClick:()=>K(r.value),className:"flex flex-col items-center gap-2 p-3 rounded-xl border border-border/20 bg-background/50 hover:border-border/50 hover:bg-muted/20 transition-all text-center",children:[e.jsx("div",{className:`p-2 rounded-xl ${r.color}`,children:e.jsx(k,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[11px] font-medium text-foreground block",children:r.label}),e.jsx("span",{className:"text-[9px] text-muted-foreground/40",children:r.desc})]})]},r.value)})})]}):e.jsxs("button",{onClick:()=>I(!0),className:"w-full flex items-center justify-center gap-1.5 py-2.5 text-xs text-muted-foreground/50 hover:text-foreground border border-dashed border-border/30 hover:border-border/50 rounded-2xl transition-colors",children:[e.jsx(J,{className:"w-3.5 h-3.5"}),"Add Step"]})})]}),T&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 text-xs text-red-400 bg-red-500/[0.03] border border-red-500/15 rounded-xl",children:[e.jsx(ne,{className:"w-3.5 h-3.5 flex-shrink-0"}),T]})]})]})}const Qe=["GET","POST","PUT","PATCH","DELETE"],et={GET:"bg-green-500/10 text-green-400",POST:"bg-blue-500/10 text-blue-400",PUT:"bg-yellow-500/10 text-yellow-400",PATCH:"bg-orange-500/10 text-orange-400",DELETE:"bg-red-500/10 text-red-400"};function tt({onWebhooksChange:o}){const[h,b]=s.useState([]),[N,E]=s.useState(!0),[A,C]=s.useState(!1),[d,f]=s.useState(null),[m,v]=s.useState(null),[l,j]=s.useState(null),[c,t]=s.useState(""),[u,g]=s.useState(""),[w,S]=s.useState("POST"),[T,R]=s.useState("{}"),[M,O]=s.useState(""),[W,I]=s.useState(""),P=s.useCallback(async()=>{try{const n=await U("/api/webhooks");if(n.ok){const i=await n.json();b(i.webhooks||[])}}catch{}E(!1)},[]);s.useEffect(()=>{P()},[P]);const G=()=>{t(""),g(""),S("POST"),R("{}"),O(""),I(""),f(null),C(!1)},B=n=>{t(n.name),g(n.url),S(n.method),R(n.headers||"{}"),O(n.description||""),f(n.id),C(!0),I("")},F=async()=>{if(I(""),!c.trim()){I("Name is required");return}if(!u.trim()){I("URL is required");return}try{new URL(u)}catch{I("Invalid URL");return}try{JSON.parse(T)}catch{I("Headers must be valid JSON");return}try{const n={name:c,url:u,method:w,headers:T,description:M},i=d?`/api/webhooks/${d}`:"/api/webhooks",H=await U(i,{method:d?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!H.ok){const X=await H.json();I(X.error||"Failed to save");return}G(),P(),o==null||o()}catch{I("Network error")}},K=async n=>{try{await U(`/api/webhooks/${n}`,{method:"DELETE"}),P(),o==null||o()}catch{}},a=async n=>{v(n),j(null);try{const L=await(await U(`/api/webhooks/${n}/test`,{method:"POST"})).json();j({id:n,result:L.result,success:L.success})}catch{j({id:n,result:{error:"Network error"},success:!1})}v(null)};return N?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 gap-3",children:[e.jsx(D,{className:"w-5 h-5 animate-spin text-muted-foreground/50"}),e.jsx("span",{className:"text-xs text-muted-foreground/40",children:"Loading webhooks..."})]}):e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-foreground tracking-tight",children:"Webhooks"}),e.jsx("p",{className:"text-xs text-muted-foreground/50 mt-0.5",children:"HTTP endpoints that workflows can call during execution"})]}),!A&&e.jsxs("button",{onClick:()=>{G(),C(!0)},className:"flex items-center gap-1.5 px-3.5 py-2 text-xs font-medium bg-foreground text-background rounded-lg hover:opacity-90 transition-opacity",children:[e.jsx(J,{className:"w-3.5 h-3.5"}),"Add Webhook"]})]}),A&&e.jsxs("div",{className:"bg-card/50 border border-border/30 rounded-2xl p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-xs font-semibold text-foreground",children:d?"Edit Webhook":"New Webhook"}),e.jsx("button",{onClick:G,className:"p-1.5 text-muted-foreground/40 hover:text-foreground hover:bg-muted/30 rounded-lg transition-colors",children:e.jsx(q,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-medium text-muted-foreground/70 mb-1.5 block",children:"Name"}),e.jsx("input",{value:c,onChange:n=>t(n.target.value),placeholder:"My Webhook",className:"w-full px-3.5 py-2.5 text-xs bg-background border border-border/40 rounded-xl text-foreground placeholder-muted-foreground/40 focus:outline-none focus:border-primary/40 focus:ring-1 focus:ring-primary/10 transition-colors"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-medium text-muted-foreground/70 mb-1.5 block",children:"Method"}),e.jsx("select",{value:w,onChange:n=>S(n.target.value),className:"w-full px-3.5 py-2.5 text-xs bg-background border border-border/40 rounded-xl text-foreground focus:outline-none focus:border-primary/40 transition-colors",children:Qe.map(n=>e.jsx("option",{value:n,children:n},n))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-medium text-muted-foreground/70 mb-1.5 block",children:"URL"}),e.jsx("input",{value:u,onChange:n=>g(n.target.value),placeholder:"https://example.com/webhook",className:"w-full px-3.5 py-2.5 text-xs bg-background border border-border/40 rounded-xl text-foreground placeholder-muted-foreground/40 focus:outline-none focus:border-primary/40 focus:ring-1 focus:ring-primary/10 transition-colors"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-medium text-muted-foreground/70 mb-1.5 block",children:"Headers (JSON)"}),e.jsx("textarea",{value:T,onChange:n=>R(n.target.value),placeholder:'{"Authorization": "Bearer ..."}',rows:2,className:"w-full px-3.5 py-2.5 text-xs bg-background border border-border/40 rounded-xl text-foreground placeholder-muted-foreground/40 focus:outline-none focus:border-primary/40 font-mono resize-none transition-colors"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-medium text-muted-foreground/70 mb-1.5 block",children:"Description"}),e.jsx("input",{value:M,onChange:n=>O(n.target.value),placeholder:"Optional description...",className:"w-full px-3.5 py-2.5 text-xs bg-background border border-border/40 rounded-xl text-foreground placeholder-muted-foreground/40 focus:outline-none focus:border-primary/40 transition-colors"})]}),W&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 text-xs text-red-400 bg-red-500/[0.03] border border-red-500/15 rounded-xl",children:[e.jsx(ne,{className:"w-3.5 h-3.5 flex-shrink-0"}),W]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[e.jsx("button",{onClick:G,className:"px-3.5 py-2 text-xs text-muted-foreground hover:text-foreground transition-colors rounded-lg",children:"Cancel"}),e.jsxs("button",{onClick:F,className:"flex items-center gap-1.5 px-4 py-2 text-xs font-medium bg-foreground text-background rounded-lg hover:opacity-90 transition-opacity",children:[e.jsx(ie,{className:"w-3.5 h-3.5"}),d?"Update":"Create"]})]})]}),h.length===0&&!A?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-muted/30 flex items-center justify-center mb-4",children:e.jsx(Ee,{className:"w-7 h-7 text-muted-foreground/25"})}),e.jsx("h4",{className:"text-sm font-semibold text-foreground tracking-tight mb-1",children:"No webhooks yet"}),e.jsx("p",{className:"text-xs text-muted-foreground/50 max-w-xs leading-relaxed",children:"Create a webhook endpoint to use in your workflow steps."})]}):e.jsx("div",{className:"space-y-3",children:h.map((n,i)=>e.jsxs("div",{className:"bg-card/50 border border-border/30 rounded-2xl p-4 hover:border-border/50 transition-all duration-200",style:{animationDelay:`${i*30}ms`},children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-sm font-semibold text-foreground tracking-tight",children:n.name}),e.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full font-mono font-medium ${et[n.method]||"bg-muted text-muted-foreground"}`,children:n.method})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground/50 font-mono truncate",children:n.url}),n.description&&e.jsx("p",{className:"text-[11px] text-muted-foreground/40 mt-1",children:n.description}),n.last_triggered&&e.jsxs("p",{className:"text-[10px] text-muted-foreground/30 mt-1.5",children:["Last triggered: ",new Date(n.last_triggered).toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{onClick:()=>a(n.id),disabled:m===n.id,className:"p-2 text-muted-foreground/40 hover:text-green-400 hover:bg-green-500/5 rounded-lg transition-colors disabled:opacity-50",title:"Test webhook",children:m===n.id?e.jsx(D,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(me,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>B(n),className:"p-2 text-muted-foreground/40 hover:text-foreground hover:bg-muted/30 rounded-lg transition-colors",title:"Edit",children:e.jsx(ge,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>K(n.id),className:"p-2 text-muted-foreground/40 hover:text-red-400 hover:bg-red-500/5 rounded-lg transition-colors",title:"Delete",children:e.jsx(oe,{className:"w-3.5 h-3.5"})})]})]}),(l==null?void 0:l.id)===n.id&&e.jsx("div",{className:`mt-3 p-3 rounded-xl text-xs ${l.success?"bg-green-500/[0.03] border border-green-500/15":"bg-red-500/[0.03] border border-red-500/15"}`,children:l.result.error?e.jsx("span",{className:"text-red-400",children:l.result.error}):e.jsxs("div",{children:[e.jsxs("span",{className:l.result.status&&l.result.status<400?"text-green-400 font-medium":"text-red-400 font-medium",children:[l.result.status," ",l.result.statusText]}),l.result.body&&e.jsx("pre",{className:"mt-2 text-[10px] text-muted-foreground/50 font-mono overflow-x-auto max-h-24 overflow-y-auto p-2 bg-background/50 rounded-lg",children:typeof l.result.body=="string"?l.result.body:JSON.stringify(l.result.body,null,2)})]})})]},n.id))})]})}const st={mail:Fe,calendar:We,hash:$e,github:Ue,"file-text":Me,"message-circle":Ge,"hard-drive":Pe,"layout-grid":Oe,zap:Z,bug:De,"list-checks":Re,"credit-card":Le,phone:_e,table:Te,kanban:Ie},rt={GMAIL:{bg:"bg-red-500/8",text:"text-red-400",ring:"ring-red-500/20"},GOOGLECALENDAR:{bg:"bg-blue-500/8",text:"text-blue-400",ring:"ring-blue-500/20"},SLACK:{bg:"bg-purple-500/8",text:"text-purple-400",ring:"ring-purple-500/20"},GITHUB:{bg:"bg-neutral-500/8",text:"text-neutral-300",ring:"ring-neutral-500/20"},NOTION:{bg:"bg-neutral-500/8",text:"text-neutral-300",ring:"ring-neutral-500/20"},DISCORD:{bg:"bg-indigo-500/8",text:"text-indigo-400",ring:"ring-indigo-500/20"},GOOGLEDRIVE:{bg:"bg-yellow-500/8",text:"text-yellow-400",ring:"ring-yellow-500/20"},TRELLO:{bg:"bg-blue-500/8",text:"text-blue-400",ring:"ring-blue-500/20"},LINEAR:{bg:"bg-violet-500/8",text:"text-violet-400",ring:"ring-violet-500/20"},JIRA:{bg:"bg-blue-600/8",text:"text-blue-500",ring:"ring-blue-600/20"},ASANA:{bg:"bg-rose-500/8",text:"text-rose-400",ring:"ring-rose-500/20"},STRIPE:{bg:"bg-violet-500/8",text:"text-violet-400",ring:"ring-violet-500/20"},TWILIO:{bg:"bg-red-500/8",text:"text-red-400",ring:"ring-red-500/20"},AIRTABLE:{bg:"bg-teal-500/8",text:"text-teal-400",ring:"ring-teal-500/20"}},nt={bg:"bg-primary/8",text:"text-primary",ring:"ring-primary/20"};function ot(){const[o,h]=s.useState([]),[b,N]=s.useState(!0),[E,A]=s.useState(!1),[C,d]=s.useState(null),[f,m]=s.useState(null),v=s.useCallback(async()=>{try{const u=await(await $.composio.catalog()).json();h(u.catalog||[]),A(u.composioAvailable)}catch{A(!1)}N(!1)},[]);s.useEffect(()=>{v()},[v]);const l=async t=>{d(t);try{const g=await(await $.composio.connect(t)).json();if(g.redirectUrl){const w=window.open(g.redirectUrl,"composio_oauth","width=600,height=700,popup=yes"),S=setInterval(async()=>{try{(await(await $.composio.waitForConnection(g.connectedAccountId)).json()).status==="ACTIVE"&&(clearInterval(S),w==null||w.close(),d(null),v())}catch{}},2e3);setTimeout(()=>{clearInterval(S),d(null)},12e4)}}catch{d(null)}},j=async t=>{if(t.connectionId){m(t.id);try{await $.composio.disconnect(t.connectionId),await v()}catch{}m(null)}};if(b)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 gap-3",children:[e.jsx(D,{className:"w-5 h-5 animate-spin text-muted-foreground/50"}),e.jsx("span",{className:"text-xs text-muted-foreground/40",children:"Loading integrations..."})]});if(!E)return e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-muted/30 flex items-center justify-center mb-4",children:e.jsx(V,{className:"w-7 h-7 text-muted-foreground/25"})}),e.jsx("h4",{className:"text-sm font-semibold text-foreground tracking-tight mb-1",children:"Composio Not Configured"}),e.jsxs("p",{className:"text-xs text-muted-foreground/50 max-w-xs leading-relaxed",children:["Set ",e.jsx("code",{className:"px-1 py-0.5 bg-muted/40 rounded text-[10px] font-mono",children:"COMPOSIO_API_KEY"})," in your server environment to unlock 850+ app integrations."]})]});const c=o.filter(t=>t.connected).length;return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-foreground tracking-tight",children:"Integrations"}),e.jsxs("p",{className:"text-xs text-muted-foreground/50 mt-0.5",children:[c," of ",o.length," connected"]})]}),e.jsxs("button",{onClick:v,className:"flex items-center gap-1.5 px-2.5 py-1.5 text-xs text-muted-foreground hover:text-foreground bg-muted/30 hover:bg-muted/50 rounded-lg transition-colors",title:"Refresh",children:[e.jsx(Ae,{className:"w-3.5 h-3.5"}),"Refresh"]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:o.map((t,u)=>{const g=rt[t.id]||nt,w=st[t.icon]||V,S=C===t.id,T=f===t.id;return e.jsxs("div",{className:`group relative flex flex-col items-center text-center p-4 rounded-2xl border transition-all duration-200 ${t.connected?"bg-green-500/[0.03] border-green-500/15 hover:border-green-500/30":"bg-card/50 border-border/30 hover:border-border/60 hover:bg-muted/20"}`,style:{animationDelay:`${u*40}ms`},children:[t.connected&&e.jsx("div",{className:"absolute top-2.5 right-2.5",children:e.jsx("div",{className:"w-2 h-2 rounded-full bg-green-400 ring-2 ring-green-400/20"})}),e.jsx("div",{className:`w-12 h-12 rounded-xl ${g.bg} ring-1 ${g.ring} flex items-center justify-center mb-3 transition-transform duration-200 group-hover:scale-105`,children:e.jsx(w,{className:`w-5 h-5 ${g.text}`})}),e.jsx("span",{className:"text-xs font-semibold text-foreground mb-0.5",children:t.name}),e.jsxs("span",{className:"text-[10px] text-muted-foreground/40 mb-3",children:[t.popularActions.length," action",t.popularActions.length!==1?"s":""]}),t.connected?e.jsxs("div",{className:"flex items-center gap-2 w-full",children:[e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-green-400 font-medium flex-1 justify-center",children:[e.jsx(ie,{className:"w-3 h-3"}),"Connected"]}),e.jsx("button",{onClick:()=>j(t),disabled:T,className:"p-1 text-muted-foreground/30 hover:text-red-400 transition-colors opacity-0 group-hover:opacity-100",title:"Disconnect",children:T?e.jsx(D,{className:"w-3 h-3 animate-spin"}):e.jsx(q,{className:"w-3 h-3"})})]}):e.jsxs("button",{onClick:()=>l(t.id),disabled:S,className:"flex items-center justify-center gap-1.5 w-full px-3 py-1.5 text-[11px] font-medium bg-foreground/[0.06] hover:bg-foreground/10 text-foreground rounded-lg transition-colors disabled:opacity-50",children:[S?e.jsx(D,{className:"w-3 h-3 animate-spin"}):e.jsx(le,{className:"w-3 h-3"}),"Connect"]})]},t.id)})})]})}const at=[{id:"workflows",label:"Workflows",icon:Z},{id:"webhooks",label:"Webhooks",icon:He},{id:"integrations",label:"Integrations",icon:V}];function mt({selectedProject:o}){const[h,b]=s.useState("list"),[N,E]=s.useState("workflows"),[A,C]=s.useState(null),[d,f]=s.useState(0),m=s.useCallback(c=>{C(c),b("editor")},[]),v=s.useCallback(()=>{C(null),b("editor")},[]),l=s.useCallback(()=>{b("list"),E("workflows"),C(null),f(c=>c+1)},[]),j=s.useCallback(()=>{b("list"),C(null)},[]);return h==="editor"?e.jsx("div",{className:"h-full",children:e.jsx(Xe,{workflow:A,onSave:l,onCancel:j})}):e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"flex-shrink-0 px-4 pt-4 pb-0",children:e.jsx("div",{className:"flex sm:inline-flex items-center bg-muted/30 rounded-xl p-1 gap-0.5",children:at.map(c=>{const t=c.icon,u=N===c.id;return e.jsxs("button",{onClick:()=>E(c.id),className:`flex items-center gap-1.5 px-3.5 py-2 text-xs font-medium rounded-lg transition-all duration-150 ${u?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(t,{className:"w-3.5 h-3.5"}),c.label]},c.id)})})}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[N==="workflows"&&e.jsx(ze,{onEdit:m,onCreate:v,refreshKey:d}),N==="webhooks"&&e.jsx(tt,{onWebhooksChange:()=>f(c=>c+1)}),N==="integrations"&&e.jsx(ot,{})]})]})}export{mt as default};