upfynai-code 3.0.4 → 3.2.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 (258) hide show
  1. package/README.md +69 -92
  2. package/bin/cli.js +191 -0
  3. package/dist/client/assets/AppContent-M14Au3SB.js +542 -0
  4. package/{client/dist/assets/BrowserPanel-0TLEl-IC.js → dist/client/assets/BrowserPanel-TFKm2NDJ.js} +2 -2
  5. package/dist/client/assets/DashboardPanel-C88HjsCh.js +1 -0
  6. package/dist/client/assets/FileTree-DvO1xnDE.js +1 -0
  7. package/{client/dist/assets/GitPanel-C_xFM-N2.js → dist/client/assets/GitPanel-D-slVlyy.js} +2 -2
  8. package/dist/client/assets/LoginModal-Chi4SYcr.js +21 -0
  9. package/{client/dist/assets/MarkdownPreview-CESjI261.js → dist/client/assets/MarkdownPreview-CuIix2u9.js} +1 -1
  10. package/dist/client/assets/MermaidBlock-Dq9uFv82.js +2 -0
  11. package/dist/client/assets/Onboarding-QYXx24dX.js +1 -0
  12. package/{client/dist/assets/PreviewPanel-CqCa92Tf.js → dist/client/assets/PreviewPanel-Dd8q-jo0.js} +1 -1
  13. package/dist/client/assets/SetupForm-CrspaUva.js +1 -0
  14. package/dist/client/assets/WorkflowsPanel-DIlYAdhB.js +1 -0
  15. package/dist/client/assets/index-CnNNzw9A.css +1 -0
  16. package/{client/dist/assets/index-HaY-3pK1.js → dist/client/assets/index-rUkK9FDP.js} +26 -26
  17. package/{client/dist/assets/vendor-codemirror-D2ALgpaX.js → dist/client/assets/vendor-codemirror-jc6nyJQg.js} +1 -1
  18. package/{client/dist/assets/vendor-diff-DNQpbhrT.js → dist/client/assets/vendor-diff-THJmAcEI.js} +1 -1
  19. package/{client/dist/assets/vendor-icons-GyYE35HP.js → dist/client/assets/vendor-icons-CfjIpdrD.js} +145 -155
  20. package/{client/dist/assets/vendor-markdown-CimbIo6Y.js → dist/client/assets/vendor-markdown-Cdm6NEGf.js} +1 -1
  21. package/dist/client/assets/vendor-mermaid-DTPaBx-U.js +2559 -0
  22. package/{client/dist/assets/vendor-react-96lCPsRK.js → dist/client/assets/vendor-react-wFkb6mSf.js} +1 -1
  23. package/{client/dist/assets/vendor-syntax-LS_Nt30I.js → dist/client/assets/vendor-syntax-C_UZR7tc.js} +1 -1
  24. package/dist/client/favicon.png +0 -0
  25. package/dist/client/icons/icon-128x128.png +0 -0
  26. package/dist/client/icons/icon-144x144.png +0 -0
  27. package/dist/client/icons/icon-152x152.png +0 -0
  28. package/dist/client/icons/icon-192x192.png +0 -0
  29. package/dist/client/icons/icon-384x384.png +0 -0
  30. package/dist/client/icons/icon-512x512.png +0 -0
  31. package/dist/client/icons/icon-72x72.png +0 -0
  32. package/dist/client/icons/icon-96x96.png +0 -0
  33. package/{client/dist → dist/client}/index.html +37 -36
  34. package/dist/client/logo-128.png +0 -0
  35. package/dist/client/logo-256.png +0 -0
  36. package/dist/client/logo-32.png +0 -0
  37. package/dist/client/logo-512.png +0 -0
  38. package/dist/client/logo-64.png +0 -0
  39. package/dist/client/logo.png +0 -0
  40. package/{client/dist → dist/client}/manifest.json +12 -12
  41. package/{client/dist → dist/client}/mcp-docs.html +1 -1
  42. package/{client/dist → dist/client}/sw.js +2 -2
  43. package/package.json +56 -105
  44. package/scripts/postinstall.js +9 -0
  45. package/scripts/prepublish.js +77 -0
  46. package/src/animation.js +228 -0
  47. package/src/auth.js +142 -0
  48. package/src/config.js +40 -0
  49. package/src/connect.js +416 -0
  50. package/src/launch.js +81 -0
  51. package/src/mcp.js +57 -0
  52. package/src/permissions.js +140 -0
  53. package/src/persistent-shell.js +261 -0
  54. package/src/server.js +54 -0
  55. package/client/dist/assets/AppContent-CwrTP6TW.js +0 -545
  56. package/client/dist/assets/CanvasFullScreen-D1GWQsGL.js +0 -1
  57. package/client/dist/assets/CanvasWorkspace-D7ORj358.js +0 -163
  58. package/client/dist/assets/DashboardPanel-BV7ybUDe.js +0 -1
  59. package/client/dist/assets/FileTree-5qfhBqdE.js +0 -1
  60. package/client/dist/assets/LoginModal-CImJHRjX.js +0 -13
  61. package/client/dist/assets/MermaidBlock-BFM21cwe.js +0 -2
  62. package/client/dist/assets/Onboarding-B3cteLu2.js +0 -1
  63. package/client/dist/assets/SetupForm-P6dsYgHO.js +0 -1
  64. package/client/dist/assets/WorkflowsPanel-CBoN80kc.js +0 -1
  65. package/client/dist/assets/index-46kkVu2i.css +0 -1
  66. package/client/dist/assets/pdf-CE_K4jFx.js +0 -12
  67. package/client/dist/assets/vendor-canvas-BZV40eAE.css +0 -1
  68. package/client/dist/assets/vendor-canvas-DvHJ_Pn2.js +0 -49
  69. package/client/dist/assets/vendor-mermaid-DucWyDEe.js +0 -2556
  70. package/client/dist/favicon.png +0 -0
  71. package/client/dist/icons/icon-128x128.png +0 -0
  72. package/client/dist/icons/icon-144x144.png +0 -0
  73. package/client/dist/icons/icon-152x152.png +0 -0
  74. package/client/dist/icons/icon-192x192.png +0 -0
  75. package/client/dist/icons/icon-384x384.png +0 -0
  76. package/client/dist/icons/icon-512x512.png +0 -0
  77. package/client/dist/icons/icon-72x72.png +0 -0
  78. package/client/dist/icons/icon-96x96.png +0 -0
  79. package/client/dist/logo-128.png +0 -0
  80. package/client/dist/logo-256.png +0 -0
  81. package/client/dist/logo-32.png +0 -0
  82. package/client/dist/logo-512.png +0 -0
  83. package/client/dist/logo-64.png +0 -0
  84. package/commands/upfynai-connect.md +0 -59
  85. package/commands/upfynai-disconnect.md +0 -31
  86. package/commands/upfynai-doctor.md +0 -99
  87. package/commands/upfynai-export.md +0 -49
  88. package/commands/upfynai-local.md +0 -82
  89. package/commands/upfynai-status.md +0 -75
  90. package/commands/upfynai-stop.md +0 -49
  91. package/commands/upfynai-uninstall.md +0 -58
  92. package/commands/upfynai.md +0 -69
  93. package/scripts/build-client.js +0 -17
  94. package/scripts/fix-node-pty.js +0 -67
  95. package/scripts/install-commands.js +0 -78
  96. package/server/agent-loop.js +0 -242
  97. package/server/auto-compact.js +0 -99
  98. package/server/browser.js +0 -131
  99. package/server/claude-sdk.js +0 -797
  100. package/server/cli-ui.js +0 -798
  101. package/server/cli.js +0 -751
  102. package/server/constants/config.js +0 -31
  103. package/server/cursor-cli.js +0 -270
  104. package/server/database/auth.db +0 -0
  105. package/server/database/db.js +0 -1547
  106. package/server/database/init.sql +0 -70
  107. package/server/index.js +0 -3813
  108. package/server/load-env.js +0 -26
  109. package/server/mcp-server.js +0 -621
  110. package/server/middleware/auth.js +0 -184
  111. package/server/middleware/relayHelpers.js +0 -44
  112. package/server/middleware/sandboxRouter.js +0 -174
  113. package/server/openai-codex.js +0 -403
  114. package/server/openrouter.js +0 -137
  115. package/server/projects.js +0 -1807
  116. package/server/provider-factory.js +0 -174
  117. package/server/relay-client.js +0 -390
  118. package/server/routes/agent.js +0 -1234
  119. package/server/routes/auth.js +0 -559
  120. package/server/routes/browser.js +0 -419
  121. package/server/routes/canvas.js +0 -53
  122. package/server/routes/cli-auth.js +0 -263
  123. package/server/routes/codex.js +0 -396
  124. package/server/routes/commands.js +0 -707
  125. package/server/routes/composio.js +0 -176
  126. package/server/routes/cursor.js +0 -770
  127. package/server/routes/dashboard.js +0 -295
  128. package/server/routes/git.js +0 -1208
  129. package/server/routes/keys.js +0 -34
  130. package/server/routes/mcp-utils.js +0 -48
  131. package/server/routes/mcp.js +0 -661
  132. package/server/routes/payments.js +0 -227
  133. package/server/routes/projects.js +0 -754
  134. package/server/routes/sessions.js +0 -146
  135. package/server/routes/settings.js +0 -261
  136. package/server/routes/taskmaster.js +0 -1928
  137. package/server/routes/user.js +0 -106
  138. package/server/routes/vapi-chat.js +0 -624
  139. package/server/routes/voice.js +0 -235
  140. package/server/routes/webhooks.js +0 -166
  141. package/server/routes/workflows.js +0 -312
  142. package/server/sandbox.js +0 -120
  143. package/server/services/browser-ai.js +0 -154
  144. package/server/services/composio.js +0 -204
  145. package/server/services/sessionRegistry.js +0 -139
  146. package/server/services/whisperService.js +0 -84
  147. package/server/services/workflowScheduler.js +0 -211
  148. package/server/tests/relay-flow.test.js +0 -570
  149. package/server/tests/sessions.test.js +0 -259
  150. package/server/utils/commandParser.js +0 -303
  151. package/server/utils/email.js +0 -66
  152. package/server/utils/gitConfig.js +0 -24
  153. package/server/utils/mcp-detector.js +0 -198
  154. package/server/utils/taskmaster-websocket.js +0 -129
  155. package/shared/integrationCatalog.d.ts +0 -12
  156. package/shared/integrationCatalog.js +0 -172
  157. package/shared/modelConstants.js +0 -96
  158. /package/{shared → dist}/agents/claude.js +0 -0
  159. /package/{shared → dist}/agents/codex.js +0 -0
  160. /package/{shared → dist}/agents/cursor.js +0 -0
  161. /package/{shared → dist}/agents/detect.js +0 -0
  162. /package/{shared → dist}/agents/exec.js +0 -0
  163. /package/{shared → dist}/agents/files.js +0 -0
  164. /package/{shared → dist}/agents/git.js +0 -0
  165. /package/{shared → dist}/agents/gitagent.js +0 -0
  166. /package/{shared → dist}/agents/index.js +0 -0
  167. /package/{shared → dist}/agents/shell.js +0 -0
  168. /package/{shared → dist}/agents/utils.js +0 -0
  169. /package/{client/dist → dist/client}/api-docs.html +0 -0
  170. /package/{client/dist → dist/client}/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  171. /package/{client/dist → dist/client}/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  172. /package/{client/dist → dist/client}/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  173. /package/{client/dist → dist/client}/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  174. /package/{client/dist → dist/client}/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  175. /package/{client/dist → dist/client}/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  176. /package/{client/dist → dist/client}/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  177. /package/{client/dist → dist/client}/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  178. /package/{client/dist → dist/client}/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  179. /package/{client/dist → dist/client}/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  180. /package/{client/dist → dist/client}/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  181. /package/{client/dist → dist/client}/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  182. /package/{client/dist → dist/client}/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  183. /package/{client/dist → dist/client}/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  184. /package/{client/dist → dist/client}/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  185. /package/{client/dist → dist/client}/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  186. /package/{client/dist → dist/client}/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  187. /package/{client/dist → dist/client}/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  188. /package/{client/dist → dist/client}/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  189. /package/{client/dist → dist/client}/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  190. /package/{client/dist → dist/client}/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  191. /package/{client/dist → dist/client}/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  192. /package/{client/dist → dist/client}/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  193. /package/{client/dist → dist/client}/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  194. /package/{client/dist → dist/client}/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  195. /package/{client/dist → dist/client}/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  196. /package/{client/dist → dist/client}/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  197. /package/{client/dist → dist/client}/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  198. /package/{client/dist → dist/client}/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  199. /package/{client/dist → dist/client}/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  200. /package/{client/dist → dist/client}/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  201. /package/{client/dist → dist/client}/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  202. /package/{client/dist → dist/client}/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  203. /package/{client/dist → dist/client}/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  204. /package/{client/dist → dist/client}/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  205. /package/{client/dist → dist/client}/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  206. /package/{client/dist → dist/client}/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  207. /package/{client/dist → dist/client}/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  208. /package/{client/dist → dist/client}/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  209. /package/{client/dist → dist/client}/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  210. /package/{client/dist → dist/client}/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  211. /package/{client/dist → dist/client}/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  212. /package/{client/dist → dist/client}/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  213. /package/{client/dist → dist/client}/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  214. /package/{client/dist → dist/client}/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  215. /package/{client/dist → dist/client}/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  216. /package/{client/dist → dist/client}/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  217. /package/{client/dist → dist/client}/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  218. /package/{client/dist → dist/client}/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  219. /package/{client/dist → dist/client}/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  220. /package/{client/dist → dist/client}/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  221. /package/{client/dist → dist/client}/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  222. /package/{client/dist → dist/client}/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  223. /package/{client/dist → dist/client}/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  224. /package/{client/dist → dist/client}/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  225. /package/{client/dist → dist/client}/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  226. /package/{client/dist → dist/client}/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  227. /package/{client/dist → dist/client}/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  228. /package/{client/dist → dist/client}/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  229. /package/{client/dist → dist/client}/assets/vendor-i18n-DCFGyhQR.js +0 -0
  230. /package/{client/dist → dist/client}/assets/vendor-xterm-CZq1hqo1.js +0 -0
  231. /package/{client/dist → dist/client}/assets/vendor-xterm-qxJ8_QYu.css +0 -0
  232. /package/{client/dist → dist/client}/clear-cache.html +0 -0
  233. /package/{client/dist → dist/client}/convert-icons.md +0 -0
  234. /package/{client/dist → dist/client}/favicon.svg +0 -0
  235. /package/{client/dist → dist/client}/generate-icons.js +0 -0
  236. /package/{client/dist → dist/client}/icons/claude-ai-icon.svg +0 -0
  237. /package/{client/dist → dist/client}/icons/codex-white.svg +0 -0
  238. /package/{client/dist → dist/client}/icons/codex.svg +0 -0
  239. /package/{client/dist → dist/client}/icons/cursor-white.svg +0 -0
  240. /package/{client/dist → dist/client}/icons/cursor.svg +0 -0
  241. /package/{client/dist → dist/client}/icons/icon-128x128.svg +0 -0
  242. /package/{client/dist → dist/client}/icons/icon-144x144.svg +0 -0
  243. /package/{client/dist → dist/client}/icons/icon-152x152.svg +0 -0
  244. /package/{client/dist → dist/client}/icons/icon-192x192.svg +0 -0
  245. /package/{client/dist → dist/client}/icons/icon-384x384.svg +0 -0
  246. /package/{client/dist → dist/client}/icons/icon-512x512.svg +0 -0
  247. /package/{client/dist → dist/client}/icons/icon-72x72.svg +0 -0
  248. /package/{client/dist → dist/client}/icons/icon-96x96.svg +0 -0
  249. /package/{client/dist → dist/client}/icons/icon-template.svg +0 -0
  250. /package/{client/dist → dist/client}/logo.svg +0 -0
  251. /package/{client/dist → dist/client}/offline.html +0 -0
  252. /package/{client/dist → dist/client}/screenshots/cli-selection.png +0 -0
  253. /package/{client/dist → dist/client}/screenshots/desktop-main.png +0 -0
  254. /package/{client/dist → dist/client}/screenshots/mobile-chat.png +0 -0
  255. /package/{client/dist → dist/client}/screenshots/tools-modal.png +0 -0
  256. /package/{shared → dist}/gitagent/index.js +0 -0
  257. /package/{shared → dist}/gitagent/parser.js +0 -0
  258. /package/{shared → dist}/gitagent/prompt-builder.js +0 -0
@@ -0,0 +1,542 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MermaidBlock-Dq9uFv82.js","assets/vendor-syntax-C_UZR7tc.js","assets/vendor-react-wFkb6mSf.js","assets/vendor-markdown-Cdm6NEGf.js","assets/vendor-diff-THJmAcEI.js","assets/MarkdownPreview-CuIix2u9.js","assets/FileTree-DvO1xnDE.js","assets/index-rUkK9FDP.js","assets/vendor-icons-CfjIpdrD.js","assets/vendor-i18n-DCFGyhQR.js","assets/index-CnNNzw9A.css","assets/LoginModal-Chi4SYcr.js","assets/vendor-xterm-CZq1hqo1.js","assets/vendor-xterm-qxJ8_QYu.css","assets/vendor-codemirror-jc6nyJQg.js","assets/GitPanel-D-slVlyy.js","assets/WorkflowsPanel-DIlYAdhB.js","assets/DashboardPanel-C88HjsCh.js","assets/PreviewPanel-Dd8q-jo0.js","assets/BrowserPanel-TFKm2NDJ.js"])))=>i.map(i=>d[i]);
2
+ import{r as l,j as e,R as lt,f as Er,g as eo,u as vi,h as ki}from"./vendor-react-wFkb6mSf.js";import{I as rr,u as hr,a as Ue,b as Fr,c as Te,d as zr,l as Ra,e as fa,f as fr,g as wi,h as to}from"./index-rUkK9FDP.js";import{S as Lt,b as Ut,c as Oa,R as is,P as st,d as ji,e as Mr,X as He,F as ns,f as vs,g as Rr,h as Dr,i as wt,j as jt,k as Ni,l as Pt,m as er,n as mr,o as Ba,p as Lr,q as sr,W as ba,G as br,K as ya,L as Tr,r as va,E as ar,s as ro,T as $t,t as bt,u as Pr,v as Wa,w as Ci,x as Si,y as ka,z as Or,A as $r,Z as tr,B as wa,D as so,M as Ei,H as Ti,J as ao,N as Xs,O as Zs,Q as ea,U as Ua,V as Ai,Y as Ii,_ as ja,$ as ks,a0 as no,a1 as os,a2 as ft,a3 as ur,a as Mi,a4 as ls,a5 as Di,a6 as oo,a7 as Na,a8 as io,a9 as ta,aa as lo,ab as Li,ac as Pi,ad as $i,ae as _i,af as Ca,ag as co,ah as Fi,ai as uo,aj as mo,ak as zi,al as Ri,am as Oi,an as Bi,ao as Wi,ap as Ui,aq as Hi,ar as Gi,as as Vi}from"./vendor-icons-CfjIpdrD.js";import{C as qi,a as Ki,b as Ji,u as Be,L as Yi,S as po}from"./LoginModal-Chi4SYcr.js";import{h as xo,p as go,b as Nt}from"./vendor-syntax-C_UZR7tc.js";import{a as Qi,b as Xi,c as Zi,M as el}from"./vendor-markdown-Cdm6NEGf.js";import{F as ho,E as Wt,S as tl,V as Sa,c as pr,a as rl,f as sl,u as al,b as nl,T as Ha,l as ol,h as Ga,s as il,d as ll,e as cl,g as dl,i as _s,j as ul,R as fo,o as bo,k as ml,m as yo,n as pl,p as xl,q as gl,r as hl,t as fl,v as bl}from"./vendor-codemirror-jc6nyJQg.js";const Va=t=>typeof window>"u"?!1:window.innerWidth<t,qa=()=>{if(typeof window>"u")return!1;const t=window.navigator;return window.matchMedia("(display-mode: standalone)").matches||!!t.standalone||document.referrer.includes("android-app://")};function Ea(t={}){const{mobileBreakpoint:r=768,trackMobile:s=!0,trackPWA:a=!0}=t,[n,o]=l.useState(()=>s?Va(r):!1),[i,c]=l.useState(()=>a?qa():!1);return l.useEffect(()=>{if(!s||typeof window>"u")return;const d=()=>{o(Va(r))};return d(),window.addEventListener("resize",d),()=>{window.removeEventListener("resize",d)}},[r,s]),l.useEffect(()=>{if(!a||typeof window>"u")return;const d=window.matchMedia("(display-mode: standalone)"),u=()=>{c(qa())};return u(),typeof d.addEventListener=="function"?(d.addEventListener("change",u),()=>{d.removeEventListener("change",u)}):(d.addListener(u),()=>{d.removeListener(u)})},[a]),{isMobile:n,isPWA:i}}const Ka="3.1.0",Ja="upfyn-version-dismissed",yl=(t,r)=>{const s=t.split(".").map(Number),a=r.split(".").map(Number);for(let n=0;n<Math.max(s.length,a.length);n++){const o=s[n]||0,i=a[n]||0;if(o!==i)return o-i}return 0},vo=(t,r)=>{const[s,a]=l.useState(!1),[n,o]=l.useState(null),[i,c]=l.useState(null);l.useEffect(()=>{if(rr)return;const u=async()=>{try{const h=await fetch("https://registry.npmjs.org/upfynai-code/latest");if(!h.ok)return;const p=await h.json();if(p.version){const g=p.version;if(o(g),localStorage.getItem(Ja)===g){a(!1);return}a(yl(g,Ka)>0),c({title:`v${g}`,body:"",htmlUrl:"https://www.npmjs.com/package/upfynai-code",publishedAt:null})}}catch{}};u();const m=setInterval(u,1800*1e3);return()=>clearInterval(m)},[t,r]);const d=l.useCallback(()=>{n&&localStorage.setItem(Ja,n),a(!1)},[n]);return{updateAvailable:s,latestVersion:n,currentVersion:Ka,releaseInfo:i,dismissUpdate:d}},Yt={autoExpandTools:!1,showRawParameters:!1,showThinking:!0,autoScrollToBottom:!0,sendByCtrlEnter:!1,sidebarVisible:!0},cs=Object.keys(Yt),vl=new Set(cs),Fs="ui-preferences:sync",ds=(t,r)=>{if(typeof t=="boolean")return t;if(typeof t=="string"){if(t==="true")return!0;if(t==="false")return!1}return r},kl=(t,r)=>{try{const s=localStorage.getItem(t);if(s===null)return r;const a=JSON.parse(s);return ds(a,r)}catch{return r}},wl=t=>{if(typeof window>"u")return Yt;try{const r=localStorage.getItem(t);if(r){const s=JSON.parse(r);if(s&&typeof s=="object"&&!Array.isArray(s)){const a=s;return cs.reduce((n,o)=>(n[o]=ds(a[o],Yt[o]),n),{...Yt})}}}catch{}return cs.reduce((r,s)=>(r[s]=kl(s,Yt[s]),r),{...Yt})};function jl(t,r){switch(r.type){case"set":{const{key:s,value:a}=r;if(!vl.has(s))return t;const n=ds(a,t[s]);return t[s]===n?t:{...t,[s]:n}}case"set_many":{const s=r.value||{};let a=!1;const n={...t};for(const o of cs){if(!(o in s))continue;const i=s[o],c=ds(i,t[o]);n[o]!==c&&(n[o]=c,a=!0)}return a?n:t}case"reset":return{...Yt,...r.value||{}};default:return t}}function Ta(t="uiPreferences"){const r=l.useRef(`ui-preferences-${Math.random().toString(36).slice(2)}`),[s,a]=l.useReducer(jl,t,wl);return l.useEffect(()=>{typeof window>"u"||(localStorage.setItem(t,JSON.stringify(s)),window.dispatchEvent(new CustomEvent(Fs,{detail:{storageKey:t,sourceId:r.current,value:s}})))},[s,t]),l.useEffect(()=>{if(typeof window>"u")return;const c=m=>{!m||typeof m!="object"||Array.isArray(m)||a({type:"set_many",value:m})},d=m=>{if(!(m.key!==t||m.newValue===null))try{const h=JSON.parse(m.newValue);c(h)}catch{}},u=m=>{const p=m.detail;!p||p.storageKey!==t||p.sourceId===r.current||c(p.value)};return window.addEventListener("storage",d),window.addEventListener(Fs,u),()=>{window.removeEventListener("storage",d),window.removeEventListener(Fs,u)}},[t]),{preferences:s,setPreference:(c,d)=>{a({type:"set",key:c,value:d})},setPreferences:c=>{a({type:"set_many",value:c})},resetPreferences:c=>{a({type:"reset",value:c})},dispatch:a}}const Nl=()=>{try{const t=localStorage.getItem("claude-settings");return t&&JSON.parse(t).projectSortOrder==="date"?"date":"name"}catch{return"name"}},Cl=()=>{try{const t=localStorage.getItem("starredProjects");return t?new Set(JSON.parse(t)):new Set}catch{return new Set}},Sl=t=>{try{localStorage.setItem("starredProjects",JSON.stringify([...t]))}catch{}},us=t=>t.__provider==="cursor"?new Date(t.createdAt||0):t.__provider==="codex"?new Date(t.createdAt||t.lastActivity||0):new Date(t.lastActivity||0),El=(t,r)=>t.__provider==="cursor"?t.name||r("projects.untitledSession"):t.__provider==="codex"?t.summary||t.name||r("projects.codexSession"):t.summary||r("projects.newSession"),Tl=t=>t.__provider==="cursor"?String(t.createdAt||""):t.__provider==="codex"?String(t.createdAt||t.lastActivity||""):String(t.lastActivity||""),Al=(t,r,s)=>{const a=us(t),n=Math.floor((r.getTime()-a.getTime())/(1e3*60));return{isCursorSession:t.__provider==="cursor",isCodexSession:t.__provider==="codex",isActive:n<10,sessionName:El(t,s),sessionTime:Tl(t),messageCount:Number(t.messageCount||0)}},ko=(t,r)=>{const s=[...t.sessions||[],...r[t.name]||[]].map(o=>({...o,__provider:"claude"})),a=(t.cursorSessions||[]).map(o=>({...o,__provider:"cursor"})),n=(t.codexSessions||[]).map(o=>({...o,__provider:"codex"}));return[...s,...a,...n].sort((o,i)=>us(i).getTime()-us(o).getTime())},Ya=(t,r)=>{const s=ko(t,r);return s.length===0?new Date(0):s.reduce((a,n)=>{const o=us(n);return o>a?o:a},new Date(0))},Il=(t,r,s,a)=>{const n=[...t];return n.sort((o,i)=>{const c=s.has(o.name),d=s.has(i.name);return c&&!d?-1:!c&&d?1:r==="date"?Ya(i,a).getTime()-Ya(o,a).getTime():(o.displayName||o.name).localeCompare(i.displayName||i.name)}),n},Ml=(t,r)=>{const s=r.trim().toLowerCase();return s?t.filter(a=>{const n=(a.displayName||a.name).toLowerCase(),o=a.name.toLowerCase();return n.includes(s)||o.includes(s)}):t},Dl=(t,r)=>{var n;const s=!!((n=t.taskmaster)!=null&&n.hasTaskmaster),a=!!(r!=null&&r.hasMCPServer&&(r!=null&&r.isConfigured));return s&&a?"fully-configured":s?"taskmaster-only":a?"mcp-only":"not-configured"},Ll=t=>{const r=typeof t.fullPath=="string"&&t.fullPath.length>0?t.fullPath:typeof t.path=="string"?t.path:"";return{name:t.name,displayName:typeof t.displayName=="string"&&t.displayName.trim().length>0?t.displayName:t.name,fullPath:r,path:typeof t.path=="string"&&t.path.length>0?t.path:r}};function Pl({projects:t,selectedProject:r,selectedSession:s,isLoading:a,isMobile:n,t:o,onRefresh:i,onProjectSelect:c,onSessionSelect:d,onSessionDelete:u,onProjectDelete:m,setCurrentProject:h,setSidebarVisible:p,sidebarVisible:g}){const{addToast:f}=hr(),[x,y]=l.useState(new Set),[N,j]=l.useState(null),[v,k]=l.useState(!1),[A,P]=l.useState(""),[S,b]=l.useState({}),[C,E]=l.useState({}),[B,T]=l.useState(new Set),[W,H]=l.useState(new Date),[_,M]=l.useState("name"),[z,K]=l.useState(!1),[te,q]=l.useState({}),[ie,$]=l.useState(null),[X,re]=l.useState(""),[Y,U]=l.useState(""),[O,F]=l.useState(new Set),[V,R]=l.useState(null),[Z,G]=l.useState(null),[w,I]=l.useState(!1),[J,se]=l.useState(()=>Cl()),ce=!n&&!g;l.useEffect(()=>{const ae=setInterval(()=>{H(new Date)},6e4);return()=>clearInterval(ae)},[]),l.useEffect(()=>{E({}),T(new Set),q({})},[t]),l.useEffect(()=>{r&&y(ae=>{if(ae.has(r.name))return ae;const ye=new Set(ae);return ye.add(r.name),ye})},[s,r]),l.useEffect(()=>{if(t.length>0&&!a){const ae=new Set;t.forEach(ye=>{ye.sessions&&ye.sessions.length>=0&&ae.add(ye.name)}),T(ae)}},[t,a]),l.useEffect(()=>{const ae=()=>{M(Nl())};ae();const ye=Ee=>{Ee.key==="claude-settings"&&ae()};window.addEventListener("storage",ye);const $e=setInterval(()=>{document.hasFocus()&&ae()},1e3);return()=>{window.removeEventListener("storage",ye),clearInterval($e)}},[]);const Ce=l.useCallback(ae=>ye=>{const $e=ye.target;$e.closest(".overflow-y-auto")||$e.closest("[data-scroll-container]")||(ye.preventDefault(),ye.stopPropagation(),ae())},[]),fe=l.useCallback(ae=>{y(ye=>{const $e=new Set;return ye.has(ae)||$e.add(ae),$e})},[]),_e=l.useCallback((ae,ye)=>{d({...ae,__projectName:ye})},[d]),we=l.useCallback(ae=>{se(ye=>{const $e=new Set(ye);return $e.has(ae)?$e.delete(ae):$e.add(ae),Sl($e),$e})},[]),Ae=l.useCallback(ae=>J.has(ae),[J]),Re=l.useCallback(ae=>ko(ae,C),[C]),Ie=l.useMemo(()=>t.map(ae=>{const ye=te[ae.name];return ye===void 0?ae:{...ae,sessionMeta:{...ae.sessionMeta,hasMore:ye}}}),[te,t]),L=l.useMemo(()=>Il(Ie,_,J,C),[C,_,Ie,J]),ee=l.useMemo(()=>Ml(L,Y),[Y,L]),ge=l.useCallback(ae=>{j(ae.name),P(ae.displayName)},[]),be=l.useCallback(()=>{j(null),P("")},[]),Pe=l.useCallback(async ae=>{try{(await Ue.renameProject(ae,A)).ok?window.refreshProjects?await window.refreshProjects():window.location.reload():console.error("Failed to rename project")}catch(ye){console.error("Error renaming project:",ye)}finally{j(null),P("")}},[A]),Fe=l.useCallback((ae,ye,$e,Ee="claude")=>{G({projectName:ae,sessionId:ye,sessionTitle:$e,provider:Ee})},[]),ze=l.useCallback(async()=>{if(!Z)return;const{projectName:ae,sessionId:ye,provider:$e}=Z;G(null),u==null||u(ye);try{const Ee=$e==="codex"?await Ue.deleteCodexSession(ye):await Ue.deleteSession(ae,ye);Ee.ok||console.error("[Sidebar] Failed to delete session:",Ee.status)}catch(Ee){console.error("[Sidebar] Error deleting session:",Ee)}},[u,Z,o]),Ve=l.useCallback(ae=>{R({project:ae,sessionCount:Re(ae).length})},[Re]),ne=l.useCallback(async()=>{if(!V)return;const{project:ae,sessionCount:ye}=V,$e=ye===0;R(null),F(Ee=>new Set([...Ee,ae.name]));try{const Ee=await Ue.deleteProject(ae.name,!$e);if(Ee.ok)m==null||m(ae.name);else{const Ye=await Ee.json();f(Ye.error||o("messages.deleteProjectFailed"),"error")}}catch(Ee){console.error("Error deleting project:",Ee),f(o("messages.deleteProjectError"),"error")}finally{F(Ee=>{const Ye=new Set(Ee);return Ye.delete(ae.name),Ye})}},[V,m,o]),he=l.useCallback(async ae=>{var Ee,Ye,it;const ye=te[ae.name];if(!(!(ye!==void 0?ye:((Ee=ae.sessionMeta)==null?void 0:Ee.hasMore)===!0)||S[ae.name])){b(dt=>({...dt,[ae.name]:!0}));try{const dt=(((Ye=ae.sessions)==null?void 0:Ye.length)||0)+(((it=C[ae.name])==null?void 0:it.length)||0),It=await Ue.sessions(ae.name,5,dt);if(!It.ok)return;const Mt=await It.json();E(Ct=>({...Ct,[ae.name]:[...Ct[ae.name]||[],...Mt.sessions||[]]})),Mt.hasMore===!1&&q(Ct=>({...Ct,[ae.name]:!1}))}catch(dt){console.error("Error loading more sessions:",dt)}finally{b(dt=>({...dt,[ae.name]:!1}))}}},[C,S,te]),Ne=l.useCallback(ae=>{c(ae),h(ae)},[c,h]),Me=l.useCallback(async()=>{K(!0);try{await i()}finally{K(!1)}},[i]),Le=l.useCallback(async(ae,ye,$e)=>{$(null),re("")},[]),Oe=l.useCallback(()=>{p(!1)},[p]),Je=l.useCallback(()=>{p(!0)},[p]);return{isSidebarCollapsed:ce,expandedProjects:x,editingProject:N,showNewProject:v,editingName:A,loadingSessions:S,additionalSessions:C,initialSessionsLoaded:B,currentTime:W,projectSortOrder:_,isRefreshing:z,editingSession:ie,editingSessionName:X,searchFilter:Y,deletingProjects:O,deleteConfirmation:V,sessionDeleteConfirmation:Z,showVersionModal:w,starredProjects:J,filteredProjects:ee,handleTouchClick:Ce,toggleProject:fe,handleSessionClick:_e,toggleStarProject:we,isProjectStarred:Ae,getProjectSessions:Re,startEditing:ge,cancelEditing:be,saveProjectName:Pe,showDeleteSessionConfirmation:Fe,confirmDeleteSession:ze,requestProjectDelete:Ve,confirmDeleteProject:ne,loadMoreSessions:he,handleProjectSelect:Ne,refreshProjects:Me,updateSessionSummary:Le,collapseSidebar:Oe,expandSidebar:Je,setShowNewProject:k,setEditingName:P,setEditingSession:$,setEditingSessionName:re,setSearchFilter:U,setDeleteConfirmation:R,setSessionDeleteConfirmation:G,setShowVersionModal:I}}function $l({onExpand:t,onShowSettings:r,updateAvailable:s,onShowVersionModal:a,t:n}){return e.jsxs("div",{className:"h-full flex flex-col items-center py-3 gap-1 bg-background/80 backdrop-blur-sm w-12",children:[e.jsx("button",{onClick:t,className:"w-8 h-8 rounded-lg flex items-center justify-center hover:bg-accent/80 transition-colors group","aria-label":n("common:versionUpdate.ariaLabels.showSidebar"),title:n("common:versionUpdate.ariaLabels.showSidebar"),children:e.jsx("img",{src:"/app/logo.png",alt:"",className:"w-6 h-6 rounded"})}),e.jsx("div",{className:"nav-divider w-6 my-1"}),e.jsx("button",{onClick:r,className:"w-8 h-8 rounded-lg flex items-center justify-center hover:bg-accent/80 transition-colors group","aria-label":n("actions.settings"),title:n("actions.settings"),children:e.jsx(Lt,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})}),s&&e.jsxs("button",{onClick:a,className:"relative w-8 h-8 rounded-lg flex items-center justify-center hover:bg-accent/80 transition-colors","aria-label":n("common:versionUpdate.ariaLabels.updateAvailable"),title:n("common:versionUpdate.ariaLabels.updateAvailable"),children:[e.jsx(Ut,{className:"w-4 h-4 text-blue-500"}),e.jsx("span",{className:"absolute top-1.5 right-1.5 w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"})]})]})}function wo(t){var r,s,a="";if(typeof t=="string"||typeof t=="number")a+=t;else if(typeof t=="object")if(Array.isArray(t)){var n=t.length;for(r=0;r<n;r++)t[r]&&(s=wo(t[r]))&&(a&&(a+=" "),a+=s)}else for(s in t)t[s]&&(a&&(a+=" "),a+=s);return a}function jo(){for(var t,r,s=0,a="",n=arguments.length;s<n;s++)(t=arguments[s])&&(r=wo(t))&&(a&&(a+=" "),a+=r);return a}const _l=(t,r)=>{const s=new Array(t.length+r.length);for(let a=0;a<t.length;a++)s[a]=t[a];for(let a=0;a<r.length;a++)s[t.length+a]=r[a];return s},Fl=(t,r)=>({classGroupId:t,validator:r}),No=(t=new Map,r=null,s)=>({nextPart:t,validators:r,classGroupId:s}),ms="-",Qa=[],zl="arbitrary..",Rl=t=>{const r=Bl(t),{conflictingClassGroups:s,conflictingClassGroupModifiers:a}=t;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return Ol(i);const c=i.split(ms),d=c[0]===""&&c.length>1?1:0;return Co(c,d,r)},getConflictingClassGroupIds:(i,c)=>{if(c){const d=a[i],u=s[i];return d?u?_l(u,d):d:u||Qa}return s[i]||Qa}}},Co=(t,r,s)=>{if(t.length-r===0)return s.classGroupId;const n=t[r],o=s.nextPart.get(n);if(o){const u=Co(t,r+1,o);if(u)return u}const i=s.validators;if(i===null)return;const c=r===0?t.join(ms):t.slice(r).join(ms),d=i.length;for(let u=0;u<d;u++){const m=i[u];if(m.validator(c))return m.classGroupId}},Ol=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const r=t.slice(1,-1),s=r.indexOf(":"),a=r.slice(0,s);return a?zl+a:void 0})(),Bl=t=>{const{theme:r,classGroups:s}=t;return Wl(s,r)},Wl=(t,r)=>{const s=No();for(const a in t){const n=t[a];Aa(n,s,a,r)}return s},Aa=(t,r,s,a)=>{const n=t.length;for(let o=0;o<n;o++){const i=t[o];Ul(i,r,s,a)}},Ul=(t,r,s,a)=>{if(typeof t=="string"){Hl(t,r,s);return}if(typeof t=="function"){Gl(t,r,s,a);return}Vl(t,r,s,a)},Hl=(t,r,s)=>{const a=t===""?r:So(r,t);a.classGroupId=s},Gl=(t,r,s,a)=>{if(ql(t)){Aa(t(a),r,s,a);return}r.validators===null&&(r.validators=[]),r.validators.push(Fl(s,t))},Vl=(t,r,s,a)=>{const n=Object.entries(t),o=n.length;for(let i=0;i<o;i++){const[c,d]=n[i];Aa(d,So(r,c),s,a)}},So=(t,r)=>{let s=t;const a=r.split(ms),n=a.length;for(let o=0;o<n;o++){const i=a[o];let c=s.nextPart.get(i);c||(c=No(),s.nextPart.set(i,c)),s=c}return s},ql=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,Kl=t=>{if(t<1)return{get:()=>{},set:()=>{}};let r=0,s=Object.create(null),a=Object.create(null);const n=(o,i)=>{s[o]=i,r++,r>t&&(r=0,a=s,s=Object.create(null))};return{get(o){let i=s[o];if(i!==void 0)return i;if((i=a[o])!==void 0)return n(o,i),i},set(o,i){o in s?s[o]=i:n(o,i)}}},ra="!",Xa=":",Jl=[],Za=(t,r,s,a,n)=>({modifiers:t,hasImportantModifier:r,baseClassName:s,maybePostfixModifierPosition:a,isExternal:n}),Yl=t=>{const{prefix:r,experimentalParseClassName:s}=t;let a=n=>{const o=[];let i=0,c=0,d=0,u;const m=n.length;for(let x=0;x<m;x++){const y=n[x];if(i===0&&c===0){if(y===Xa){o.push(n.slice(d,x)),d=x+1;continue}if(y==="/"){u=x;continue}}y==="["?i++:y==="]"?i--:y==="("?c++:y===")"&&c--}const h=o.length===0?n:n.slice(d);let p=h,g=!1;h.endsWith(ra)?(p=h.slice(0,-1),g=!0):h.startsWith(ra)&&(p=h.slice(1),g=!0);const f=u&&u>d?u-d:void 0;return Za(o,g,p,f)};if(r){const n=r+Xa,o=a;a=i=>i.startsWith(n)?o(i.slice(n.length)):Za(Jl,!1,i,void 0,!0)}if(s){const n=a;a=o=>s({className:o,parseClassName:n})}return a},Ql=t=>{const r=new Map;return t.orderSensitiveModifiers.forEach((s,a)=>{r.set(s,1e6+a)}),s=>{const a=[];let n=[];for(let o=0;o<s.length;o++){const i=s[o],c=i[0]==="[",d=r.has(i);c||d?(n.length>0&&(n.sort(),a.push(...n),n=[]),a.push(i)):n.push(i)}return n.length>0&&(n.sort(),a.push(...n)),a}},Xl=t=>({cache:Kl(t.cacheSize),parseClassName:Yl(t),sortModifiers:Ql(t),...Rl(t)}),Zl=/\s+/,ec=(t,r)=>{const{parseClassName:s,getClassGroupId:a,getConflictingClassGroupIds:n,sortModifiers:o}=r,i=[],c=t.trim().split(Zl);let d="";for(let u=c.length-1;u>=0;u-=1){const m=c[u],{isExternal:h,modifiers:p,hasImportantModifier:g,baseClassName:f,maybePostfixModifierPosition:x}=s(m);if(h){d=m+(d.length>0?" "+d:d);continue}let y=!!x,N=a(y?f.substring(0,x):f);if(!N){if(!y){d=m+(d.length>0?" "+d:d);continue}if(N=a(f),!N){d=m+(d.length>0?" "+d:d);continue}y=!1}const j=p.length===0?"":p.length===1?p[0]:o(p).join(":"),v=g?j+ra:j,k=v+N;if(i.indexOf(k)>-1)continue;i.push(k);const A=n(N,y);for(let P=0;P<A.length;++P){const S=A[P];i.push(v+S)}d=m+(d.length>0?" "+d:d)}return d},tc=(...t)=>{let r=0,s,a,n="";for(;r<t.length;)(s=t[r++])&&(a=Eo(s))&&(n&&(n+=" "),n+=a);return n},Eo=t=>{if(typeof t=="string")return t;let r,s="";for(let a=0;a<t.length;a++)t[a]&&(r=Eo(t[a]))&&(s&&(s+=" "),s+=r);return s},rc=(t,...r)=>{let s,a,n,o;const i=d=>{const u=r.reduce((m,h)=>h(m),t());return s=Xl(u),a=s.cache.get,n=s.cache.set,o=c,c(d)},c=d=>{const u=a(d);if(u)return u;const m=ec(d,s);return n(d,m),m};return o=i,(...d)=>o(tc(...d))},sc=[],tt=t=>{const r=s=>s[t]||sc;return r.isThemeGetter=!0,r},To=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Ao=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ac=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,nc=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,oc=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,ic=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,lc=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,cc=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Rt=t=>ac.test(t),De=t=>!!t&&!Number.isNaN(Number(t)),Ot=t=>!!t&&Number.isInteger(Number(t)),zs=t=>t.endsWith("%")&&De(t.slice(0,-1)),Dt=t=>nc.test(t),Io=()=>!0,dc=t=>oc.test(t)&&!ic.test(t),Ia=()=>!1,uc=t=>lc.test(t),mc=t=>cc.test(t),pc=t=>!me(t)&&!pe(t),xc=t=>Ht(t,Lo,Ia),me=t=>To.test(t),Jt=t=>Ht(t,Po,dc),en=t=>Ht(t,wc,De),gc=t=>Ht(t,_o,Io),hc=t=>Ht(t,$o,Ia),tn=t=>Ht(t,Mo,Ia),fc=t=>Ht(t,Do,mc),Yr=t=>Ht(t,Fo,uc),pe=t=>Ao.test(t),jr=t=>nr(t,Po),bc=t=>nr(t,$o),rn=t=>nr(t,Mo),yc=t=>nr(t,Lo),vc=t=>nr(t,Do),Qr=t=>nr(t,Fo,!0),kc=t=>nr(t,_o,!0),Ht=(t,r,s)=>{const a=To.exec(t);return a?a[1]?r(a[1]):s(a[2]):!1},nr=(t,r,s=!1)=>{const a=Ao.exec(t);return a?a[1]?r(a[1]):s:!1},Mo=t=>t==="position"||t==="percentage",Do=t=>t==="image"||t==="url",Lo=t=>t==="length"||t==="size"||t==="bg-size",Po=t=>t==="length",wc=t=>t==="number",$o=t=>t==="family-name",_o=t=>t==="number"||t==="weight",Fo=t=>t==="shadow",jc=()=>{const t=tt("color"),r=tt("font"),s=tt("text"),a=tt("font-weight"),n=tt("tracking"),o=tt("leading"),i=tt("breakpoint"),c=tt("container"),d=tt("spacing"),u=tt("radius"),m=tt("shadow"),h=tt("inset-shadow"),p=tt("text-shadow"),g=tt("drop-shadow"),f=tt("blur"),x=tt("perspective"),y=tt("aspect"),N=tt("ease"),j=tt("animate"),v=()=>["auto","avoid","all","avoid-page","page","left","right","column"],k=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],A=()=>[...k(),pe,me],P=()=>["auto","hidden","clip","visible","scroll"],S=()=>["auto","contain","none"],b=()=>[pe,me,d],C=()=>[Rt,"full","auto",...b()],E=()=>[Ot,"none","subgrid",pe,me],B=()=>["auto",{span:["full",Ot,pe,me]},Ot,pe,me],T=()=>[Ot,"auto",pe,me],W=()=>["auto","min","max","fr",pe,me],H=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],_=()=>["start","end","center","stretch","center-safe","end-safe"],M=()=>["auto",...b()],z=()=>[Rt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...b()],K=()=>[Rt,"screen","full","dvw","lvw","svw","min","max","fit",...b()],te=()=>[Rt,"screen","full","lh","dvh","lvh","svh","min","max","fit",...b()],q=()=>[t,pe,me],ie=()=>[...k(),rn,tn,{position:[pe,me]}],$=()=>["no-repeat",{repeat:["","x","y","space","round"]}],X=()=>["auto","cover","contain",yc,xc,{size:[pe,me]}],re=()=>[zs,jr,Jt],Y=()=>["","none","full",u,pe,me],U=()=>["",De,jr,Jt],O=()=>["solid","dashed","dotted","double"],F=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],V=()=>[De,zs,rn,tn],R=()=>["","none",f,pe,me],Z=()=>["none",De,pe,me],G=()=>["none",De,pe,me],w=()=>[De,pe,me],I=()=>[Rt,"full",...b()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Dt],breakpoint:[Dt],color:[Io],container:[Dt],"drop-shadow":[Dt],ease:["in","out","in-out"],font:[pc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Dt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Dt],shadow:[Dt],spacing:["px",De],text:[Dt],"text-shadow":[Dt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Rt,me,pe,y]}],container:["container"],columns:[{columns:[De,me,pe,c]}],"break-after":[{"break-after":v()}],"break-before":[{"break-before":v()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:A()}],overflow:[{overflow:P()}],"overflow-x":[{"overflow-x":P()}],"overflow-y":[{"overflow-y":P()}],overscroll:[{overscroll:S()}],"overscroll-x":[{"overscroll-x":S()}],"overscroll-y":[{"overscroll-y":S()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:C()}],"inset-x":[{"inset-x":C()}],"inset-y":[{"inset-y":C()}],start:[{"inset-s":C(),start:C()}],end:[{"inset-e":C(),end:C()}],"inset-bs":[{"inset-bs":C()}],"inset-be":[{"inset-be":C()}],top:[{top:C()}],right:[{right:C()}],bottom:[{bottom:C()}],left:[{left:C()}],visibility:["visible","invisible","collapse"],z:[{z:[Ot,"auto",pe,me]}],basis:[{basis:[Rt,"full","auto",c,...b()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[De,Rt,"auto","initial","none",me]}],grow:[{grow:["",De,pe,me]}],shrink:[{shrink:["",De,pe,me]}],order:[{order:[Ot,"first","last","none",pe,me]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:B()}],"col-start":[{"col-start":T()}],"col-end":[{"col-end":T()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:B()}],"row-start":[{"row-start":T()}],"row-end":[{"row-end":T()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":W()}],"auto-rows":[{"auto-rows":W()}],gap:[{gap:b()}],"gap-x":[{"gap-x":b()}],"gap-y":[{"gap-y":b()}],"justify-content":[{justify:[...H(),"normal"]}],"justify-items":[{"justify-items":[..._(),"normal"]}],"justify-self":[{"justify-self":["auto",..._()]}],"align-content":[{content:["normal",...H()]}],"align-items":[{items:[..._(),{baseline:["","last"]}]}],"align-self":[{self:["auto",..._(),{baseline:["","last"]}]}],"place-content":[{"place-content":H()}],"place-items":[{"place-items":[..._(),"baseline"]}],"place-self":[{"place-self":["auto",..._()]}],p:[{p:b()}],px:[{px:b()}],py:[{py:b()}],ps:[{ps:b()}],pe:[{pe:b()}],pbs:[{pbs:b()}],pbe:[{pbe:b()}],pt:[{pt:b()}],pr:[{pr:b()}],pb:[{pb:b()}],pl:[{pl:b()}],m:[{m:M()}],mx:[{mx:M()}],my:[{my:M()}],ms:[{ms:M()}],me:[{me:M()}],mbs:[{mbs:M()}],mbe:[{mbe:M()}],mt:[{mt:M()}],mr:[{mr:M()}],mb:[{mb:M()}],ml:[{ml:M()}],"space-x":[{"space-x":b()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":b()}],"space-y-reverse":["space-y-reverse"],size:[{size:z()}],"inline-size":[{inline:["auto",...K()]}],"min-inline-size":[{"min-inline":["auto",...K()]}],"max-inline-size":[{"max-inline":["none",...K()]}],"block-size":[{block:["auto",...te()]}],"min-block-size":[{"min-block":["auto",...te()]}],"max-block-size":[{"max-block":["none",...te()]}],w:[{w:[c,"screen",...z()]}],"min-w":[{"min-w":[c,"screen","none",...z()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[i]},...z()]}],h:[{h:["screen","lh",...z()]}],"min-h":[{"min-h":["screen","lh","none",...z()]}],"max-h":[{"max-h":["screen","lh",...z()]}],"font-size":[{text:["base",s,jr,Jt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,kc,gc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",zs,me]}],"font-family":[{font:[bc,hc,r]}],"font-features":[{"font-features":[me]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[n,pe,me]}],"line-clamp":[{"line-clamp":[De,"none",pe,en]}],leading:[{leading:[o,...b()]}],"list-image":[{"list-image":["none",pe,me]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",pe,me]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:q()}],"text-color":[{text:q()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...O(),"wavy"]}],"text-decoration-thickness":[{decoration:[De,"from-font","auto",pe,Jt]}],"text-decoration-color":[{decoration:q()}],"underline-offset":[{"underline-offset":[De,"auto",pe,me]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:b()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",pe,me]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",pe,me]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:ie()}],"bg-repeat":[{bg:$()}],"bg-size":[{bg:X()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ot,pe,me],radial:["",pe,me],conic:[Ot,pe,me]},vc,fc]}],"bg-color":[{bg:q()}],"gradient-from-pos":[{from:re()}],"gradient-via-pos":[{via:re()}],"gradient-to-pos":[{to:re()}],"gradient-from":[{from:q()}],"gradient-via":[{via:q()}],"gradient-to":[{to:q()}],rounded:[{rounded:Y()}],"rounded-s":[{"rounded-s":Y()}],"rounded-e":[{"rounded-e":Y()}],"rounded-t":[{"rounded-t":Y()}],"rounded-r":[{"rounded-r":Y()}],"rounded-b":[{"rounded-b":Y()}],"rounded-l":[{"rounded-l":Y()}],"rounded-ss":[{"rounded-ss":Y()}],"rounded-se":[{"rounded-se":Y()}],"rounded-ee":[{"rounded-ee":Y()}],"rounded-es":[{"rounded-es":Y()}],"rounded-tl":[{"rounded-tl":Y()}],"rounded-tr":[{"rounded-tr":Y()}],"rounded-br":[{"rounded-br":Y()}],"rounded-bl":[{"rounded-bl":Y()}],"border-w":[{border:U()}],"border-w-x":[{"border-x":U()}],"border-w-y":[{"border-y":U()}],"border-w-s":[{"border-s":U()}],"border-w-e":[{"border-e":U()}],"border-w-bs":[{"border-bs":U()}],"border-w-be":[{"border-be":U()}],"border-w-t":[{"border-t":U()}],"border-w-r":[{"border-r":U()}],"border-w-b":[{"border-b":U()}],"border-w-l":[{"border-l":U()}],"divide-x":[{"divide-x":U()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":U()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...O(),"hidden","none"]}],"divide-style":[{divide:[...O(),"hidden","none"]}],"border-color":[{border:q()}],"border-color-x":[{"border-x":q()}],"border-color-y":[{"border-y":q()}],"border-color-s":[{"border-s":q()}],"border-color-e":[{"border-e":q()}],"border-color-bs":[{"border-bs":q()}],"border-color-be":[{"border-be":q()}],"border-color-t":[{"border-t":q()}],"border-color-r":[{"border-r":q()}],"border-color-b":[{"border-b":q()}],"border-color-l":[{"border-l":q()}],"divide-color":[{divide:q()}],"outline-style":[{outline:[...O(),"none","hidden"]}],"outline-offset":[{"outline-offset":[De,pe,me]}],"outline-w":[{outline:["",De,jr,Jt]}],"outline-color":[{outline:q()}],shadow:[{shadow:["","none",m,Qr,Yr]}],"shadow-color":[{shadow:q()}],"inset-shadow":[{"inset-shadow":["none",h,Qr,Yr]}],"inset-shadow-color":[{"inset-shadow":q()}],"ring-w":[{ring:U()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:q()}],"ring-offset-w":[{"ring-offset":[De,Jt]}],"ring-offset-color":[{"ring-offset":q()}],"inset-ring-w":[{"inset-ring":U()}],"inset-ring-color":[{"inset-ring":q()}],"text-shadow":[{"text-shadow":["none",p,Qr,Yr]}],"text-shadow-color":[{"text-shadow":q()}],opacity:[{opacity:[De,pe,me]}],"mix-blend":[{"mix-blend":[...F(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":F()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[De]}],"mask-image-linear-from-pos":[{"mask-linear-from":V()}],"mask-image-linear-to-pos":[{"mask-linear-to":V()}],"mask-image-linear-from-color":[{"mask-linear-from":q()}],"mask-image-linear-to-color":[{"mask-linear-to":q()}],"mask-image-t-from-pos":[{"mask-t-from":V()}],"mask-image-t-to-pos":[{"mask-t-to":V()}],"mask-image-t-from-color":[{"mask-t-from":q()}],"mask-image-t-to-color":[{"mask-t-to":q()}],"mask-image-r-from-pos":[{"mask-r-from":V()}],"mask-image-r-to-pos":[{"mask-r-to":V()}],"mask-image-r-from-color":[{"mask-r-from":q()}],"mask-image-r-to-color":[{"mask-r-to":q()}],"mask-image-b-from-pos":[{"mask-b-from":V()}],"mask-image-b-to-pos":[{"mask-b-to":V()}],"mask-image-b-from-color":[{"mask-b-from":q()}],"mask-image-b-to-color":[{"mask-b-to":q()}],"mask-image-l-from-pos":[{"mask-l-from":V()}],"mask-image-l-to-pos":[{"mask-l-to":V()}],"mask-image-l-from-color":[{"mask-l-from":q()}],"mask-image-l-to-color":[{"mask-l-to":q()}],"mask-image-x-from-pos":[{"mask-x-from":V()}],"mask-image-x-to-pos":[{"mask-x-to":V()}],"mask-image-x-from-color":[{"mask-x-from":q()}],"mask-image-x-to-color":[{"mask-x-to":q()}],"mask-image-y-from-pos":[{"mask-y-from":V()}],"mask-image-y-to-pos":[{"mask-y-to":V()}],"mask-image-y-from-color":[{"mask-y-from":q()}],"mask-image-y-to-color":[{"mask-y-to":q()}],"mask-image-radial":[{"mask-radial":[pe,me]}],"mask-image-radial-from-pos":[{"mask-radial-from":V()}],"mask-image-radial-to-pos":[{"mask-radial-to":V()}],"mask-image-radial-from-color":[{"mask-radial-from":q()}],"mask-image-radial-to-color":[{"mask-radial-to":q()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":k()}],"mask-image-conic-pos":[{"mask-conic":[De]}],"mask-image-conic-from-pos":[{"mask-conic-from":V()}],"mask-image-conic-to-pos":[{"mask-conic-to":V()}],"mask-image-conic-from-color":[{"mask-conic-from":q()}],"mask-image-conic-to-color":[{"mask-conic-to":q()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ie()}],"mask-repeat":[{mask:$()}],"mask-size":[{mask:X()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",pe,me]}],filter:[{filter:["","none",pe,me]}],blur:[{blur:R()}],brightness:[{brightness:[De,pe,me]}],contrast:[{contrast:[De,pe,me]}],"drop-shadow":[{"drop-shadow":["","none",g,Qr,Yr]}],"drop-shadow-color":[{"drop-shadow":q()}],grayscale:[{grayscale:["",De,pe,me]}],"hue-rotate":[{"hue-rotate":[De,pe,me]}],invert:[{invert:["",De,pe,me]}],saturate:[{saturate:[De,pe,me]}],sepia:[{sepia:["",De,pe,me]}],"backdrop-filter":[{"backdrop-filter":["","none",pe,me]}],"backdrop-blur":[{"backdrop-blur":R()}],"backdrop-brightness":[{"backdrop-brightness":[De,pe,me]}],"backdrop-contrast":[{"backdrop-contrast":[De,pe,me]}],"backdrop-grayscale":[{"backdrop-grayscale":["",De,pe,me]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[De,pe,me]}],"backdrop-invert":[{"backdrop-invert":["",De,pe,me]}],"backdrop-opacity":[{"backdrop-opacity":[De,pe,me]}],"backdrop-saturate":[{"backdrop-saturate":[De,pe,me]}],"backdrop-sepia":[{"backdrop-sepia":["",De,pe,me]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":b()}],"border-spacing-x":[{"border-spacing-x":b()}],"border-spacing-y":[{"border-spacing-y":b()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",pe,me]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[De,"initial",pe,me]}],ease:[{ease:["linear","initial",N,pe,me]}],delay:[{delay:[De,pe,me]}],animate:[{animate:["none",j,pe,me]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[x,pe,me]}],"perspective-origin":[{"perspective-origin":A()}],rotate:[{rotate:Z()}],"rotate-x":[{"rotate-x":Z()}],"rotate-y":[{"rotate-y":Z()}],"rotate-z":[{"rotate-z":Z()}],scale:[{scale:G()}],"scale-x":[{"scale-x":G()}],"scale-y":[{"scale-y":G()}],"scale-z":[{"scale-z":G()}],"scale-3d":["scale-3d"],skew:[{skew:w()}],"skew-x":[{"skew-x":w()}],"skew-y":[{"skew-y":w()}],transform:[{transform:[pe,me,"","none","gpu","cpu"]}],"transform-origin":[{origin:A()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:I()}],"translate-x":[{"translate-x":I()}],"translate-y":[{"translate-y":I()}],"translate-z":[{"translate-z":I()}],"translate-none":["translate-none"],accent:[{accent:q()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:q()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",pe,me]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":b()}],"scroll-mx":[{"scroll-mx":b()}],"scroll-my":[{"scroll-my":b()}],"scroll-ms":[{"scroll-ms":b()}],"scroll-me":[{"scroll-me":b()}],"scroll-mbs":[{"scroll-mbs":b()}],"scroll-mbe":[{"scroll-mbe":b()}],"scroll-mt":[{"scroll-mt":b()}],"scroll-mr":[{"scroll-mr":b()}],"scroll-mb":[{"scroll-mb":b()}],"scroll-ml":[{"scroll-ml":b()}],"scroll-p":[{"scroll-p":b()}],"scroll-px":[{"scroll-px":b()}],"scroll-py":[{"scroll-py":b()}],"scroll-ps":[{"scroll-ps":b()}],"scroll-pe":[{"scroll-pe":b()}],"scroll-pbs":[{"scroll-pbs":b()}],"scroll-pbe":[{"scroll-pbe":b()}],"scroll-pt":[{"scroll-pt":b()}],"scroll-pr":[{"scroll-pr":b()}],"scroll-pb":[{"scroll-pb":b()}],"scroll-pl":[{"scroll-pl":b()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",pe,me]}],fill:[{fill:["none",...q()]}],"stroke-w":[{stroke:[De,jr,Jt,en]}],stroke:[{stroke:["none",...q()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},Nc=rc(jc);function ke(...t){return Nc(jo(t))}function Cc(t){if(!t||typeof t!="string")return null;try{return JSON.parse(t)}catch{return null}}const zo=l.forwardRef(({className:t,children:r,...s},a)=>e.jsx("div",{className:ke(t,"relative overflow-hidden"),...s,children:e.jsx("div",{ref:a,className:"h-full w-full rounded-[inherit] overflow-auto",style:{WebkitOverflowScrolling:"touch",touchAction:"pan-y"},children:r})}));zo.displayName="ScrollArea";function Sc({updateAvailable:t,releaseInfo:r,latestVersion:s,onShowVersionModal:a,onShowSettings:n,t:o}){return e.jsxs("div",{className:"flex-shrink-0",style:{paddingBottom:"env(safe-area-inset-bottom, 0)"},children:[t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"nav-divider"}),e.jsx("div",{className:"hidden md:block px-2 py-1.5",children:e.jsxs("button",{className:"w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-left hover:bg-blue-50/80 dark:hover:bg-blue-900/15 transition-colors group",onClick:a,children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(Oa,{className:"w-4 h-4 text-blue-500 dark:text-blue-400"}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"text-sm font-medium text-blue-600 dark:text-blue-300 truncate block",children:(r==null?void 0:r.title)||`v${s}`}),e.jsx("span",{className:"text-[10px] text-blue-500/70 dark:text-blue-400/60",children:o("version.updateAvailable")})]})]})}),e.jsx("div",{className:"md:hidden px-3 py-2",children:e.jsxs("button",{className:"w-full h-11 bg-blue-50/80 dark:bg-blue-900/15 border border-blue-200/60 dark:border-blue-700/40 rounded-xl flex items-center gap-3 px-3.5 active:scale-[0.98] transition-all",onClick:a,children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx(Oa,{className:"w-4.5 h-4.5 text-blue-500 dark:text-blue-400"}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse"})]}),e.jsxs("div",{className:"min-w-0 flex-1 text-left",children:[e.jsx("span",{className:"text-sm font-medium text-blue-600 dark:text-blue-300 truncate block",children:(r==null?void 0:r.title)||`v${s}`}),e.jsx("span",{className:"text-xs text-blue-500/70 dark:text-blue-400/60",children:o("version.updateAvailable")})]})]})})]}),e.jsx("div",{className:"nav-divider"}),e.jsx("div",{className:"hidden md:block px-2 py-1.5",children:e.jsxs("button",{className:"w-full flex items-center gap-2 px-2.5 py-1.5 rounded-lg text-muted-foreground hover:text-foreground hover:bg-accent/60 transition-colors",onClick:n,children:[e.jsx(Lt,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"text-sm",children:o("actions.settings")})]})}),e.jsx("div",{className:"md:hidden p-3 pb-20",children:e.jsxs("button",{className:"w-full h-12 bg-muted/40 hover:bg-muted/60 rounded-xl flex items-center gap-3.5 px-4 active:scale-[0.98] transition-all",onClick:n,children:[e.jsx("div",{className:"w-8 h-8 rounded-xl bg-background/80 flex items-center justify-center",children:e.jsx(Lt,{className:"w-4.5 h-4.5 text-muted-foreground"})}),e.jsx("span",{className:"text-base font-medium text-foreground",children:o("actions.settings")})]})})]})}const sn=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,an=jo,Ro=(t,r)=>s=>{var a;if((r==null?void 0:r.variants)==null)return an(t,s==null?void 0:s.class,s==null?void 0:s.className);const{variants:n,defaultVariants:o}=r,i=Object.keys(n).map(u=>{const m=s==null?void 0:s[u],h=o==null?void 0:o[u];if(m===null)return null;const p=sn(m)||sn(h);return n[u][p]}),c=s&&Object.entries(s).reduce((u,m)=>{let[h,p]=m;return p===void 0||(u[h]=p),u},{}),d=r==null||(a=r.compoundVariants)===null||a===void 0?void 0:a.reduce((u,m)=>{let{class:h,className:p,...g}=m;return Object.entries(g).every(f=>{let[x,y]=f;return Array.isArray(y)?y.includes({...o,...c}[x]):{...o,...c}[x]===y})?[...u,h,p]:u},[]);return an(t,i,d,s==null?void 0:s.class,s==null?void 0:s.className)},Ec=Ro("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),xe=l.forwardRef(({className:t,variant:r,size:s,...a},n)=>e.jsx("button",{className:ke(Ec({variant:r,size:s,className:t})),ref:n,...a}));xe.displayName="Button";const Ze=l.forwardRef(({className:t,type:r,...s},a)=>e.jsx("input",{type:r,className:ke("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",t),ref:a,...s}));Ze.displayName="Input";function Tc({isPWA:t,isMobile:r,isLoading:s,projectsCount:a,searchFilter:n,onSearchFilterChange:o,onClearSearchFilter:i,onRefresh:c,isRefreshing:d,onCreateProject:u,onCollapseSidebar:m,t:h}){const p=()=>e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx("img",{src:"/app/logo.png",alt:"",className:"w-7 h-7 rounded-lg flex-shrink-0"}),e.jsx("h1",{className:"text-sm font-semibold text-foreground tracking-tight truncate",children:h("app.title")})]});return e.jsxs("div",{className:"flex-shrink-0",children:[e.jsxs("div",{className:"hidden md:block px-3 pt-3 pb-2",style:{},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[rr?e.jsx("a",{href:"https://code.upfyn.com",className:"flex items-center gap-2.5 min-w-0 hover:opacity-80 transition-opacity",title:h("tooltips.viewEnvironments"),children:e.jsx(p,{})}):e.jsx(p,{}),e.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[e.jsx(xe,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground hover:bg-accent/80 rounded-lg",onClick:c,disabled:d,title:h("tooltips.refresh"),children:e.jsx(is,{className:`w-3.5 h-3.5 ${d?"animate-spin":""}`})}),e.jsx(xe,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground hover:bg-accent/80 rounded-lg",onClick:u,title:h("tooltips.createProject"),children:e.jsx(st,{className:"w-3.5 h-3.5"})}),e.jsx(xe,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground hover:bg-accent/80 rounded-lg",onClick:m,title:h("tooltips.hideSidebar"),children:e.jsx(ji,{className:"w-3.5 h-3.5"})})]})]}),a>0&&!s&&e.jsxs("div",{className:"relative mt-2.5",children:[e.jsx(Mr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground/50 pointer-events-none"}),e.jsx(Ze,{type:"text",placeholder:h("projects.searchPlaceholder"),value:n,onChange:g=>o(g.target.value),className:"nav-search-input pl-9 pr-8 h-9 text-sm rounded-xl border-0 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0 transition-all duration-200"}),n&&e.jsx("button",{onClick:i,className:"absolute right-2.5 top-1/2 -translate-y-1/2 p-0.5 hover:bg-accent rounded-md",children:e.jsx(He,{className:"w-3 h-3 text-muted-foreground"})})]})]}),e.jsx("div",{className:"hidden md:block nav-divider"}),e.jsxs("div",{className:"md:hidden p-3 pb-2",style:t&&r?{paddingTop:"16px"}:{},children:[e.jsxs("div",{className:"flex items-center justify-between",children:[rr?e.jsx("a",{href:"https://code.upfyn.com",className:"flex items-center gap-2.5 active:opacity-70 transition-opacity min-w-0",title:h("tooltips.viewEnvironments"),children:e.jsx(p,{})}):e.jsx(p,{}),e.jsxs("div",{className:"flex gap-1.5 flex-shrink-0",children:[e.jsx("button",{className:"w-8 h-8 rounded-lg bg-muted/50 flex items-center justify-center active:scale-95 transition-all",onClick:c,disabled:d,children:e.jsx(is,{className:`w-4 h-4 text-muted-foreground ${d?"animate-spin":""}`})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-primary/90 text-primary-foreground flex items-center justify-center active:scale-95 transition-all",onClick:u,children:e.jsx(ns,{className:"w-4 h-4"})})]})]}),a>0&&!s&&e.jsxs("div",{className:"relative mt-2.5",children:[e.jsx(Mr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground/50 pointer-events-none"}),e.jsx(Ze,{type:"text",placeholder:h("projects.searchPlaceholder"),value:n,onChange:g=>o(g.target.value),className:"nav-search-input pl-10 pr-9 h-10 text-sm rounded-xl border-0 placeholder:text-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0 transition-all duration-200"}),n&&e.jsx("button",{onClick:i,className:"absolute right-2.5 top-1/2 -translate-y-1/2 p-1 hover:bg-accent rounded-md",children:e.jsx(He,{className:"w-3.5 h-3.5 text-muted-foreground"})})]})]}),e.jsx("div",{className:"md:hidden nav-divider"})]})}const Ac=({status:t="not-configured",size:r="sm",className:s="",showLabel:a=!1})=>{const o=(()=>{switch(t){case"fully-configured":return{icon:Rr,color:"text-green-500 dark:text-green-400",bgColor:"bg-green-50 dark:bg-green-950",label:"TaskMaster Ready",title:"TaskMaster fully configured with MCP server"};case"taskmaster-only":return{icon:Lt,color:"text-blue-500 dark:text-blue-400",bgColor:"bg-blue-50 dark:bg-blue-950",label:"TaskMaster Init",title:"TaskMaster initialized, MCP server needs setup"};case"mcp-only":return{icon:vs,color:"text-amber-500 dark:text-amber-400",bgColor:"bg-amber-50 dark:bg-amber-950",label:"MCP Ready",title:"MCP server configured, TaskMaster needs initialization"};case"not-configured":case"error":default:return{icon:He,color:"text-gray-400 dark:text-gray-500",bgColor:"bg-gray-50 dark:bg-gray-900",label:"No TaskMaster",title:"TaskMaster not configured"}}})(),i=o.icon,c={xs:"w-3 h-3",sm:"w-4 h-4",md:"w-5 h-5",lg:"w-6 h-6"},d={xs:"p-0.5",sm:"p-1",md:"p-1.5",lg:"p-2"};return a?e.jsxs("div",{className:ke("inline-flex items-center gap-1.5 text-xs rounded-md px-2 py-1 transition-colors",o.bgColor,o.color,s),title:o.title,children:[e.jsx(i,{className:c[r]}),e.jsx("span",{className:"font-medium",children:o.label})]}):e.jsx("div",{className:ke("inline-flex items-center justify-center rounded-full transition-colors",o.bgColor,d[r],s),title:o.title,children:e.jsx(i,{className:ke(c[r],o.color)})})},Ic=Ro("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function kt({className:t,variant:r,...s}){return e.jsx("div",{className:ke(Ic({variant:r}),t),...s})}const nn=(t,r,s)=>{const a=new Date(t),n=r;if(isNaN(a.getTime()))return s?s("status.unknown"):"Unknown";const o=n.getTime()-a.getTime(),i=Math.floor(o/1e3),c=Math.floor(o/(1e3*60)),d=Math.floor(o/(1e3*60*60)),u=Math.floor(o/(1e3*60*60*24));return i<60?s?s("time.justNow"):"Just now":c===1?s?s("time.oneMinuteAgo"):"1 min ago":c<60?s?s("time.minutesAgo",{count:c}):`${c} mins ago`:d===1?s?s("time.oneHourAgo"):"1 hour ago":d<24?s?s("time.hoursAgo",{count:d}):`${d} hours ago`:u===1?s?s("time.oneDayAgo"):"1 day ago":u<7?s?s("time.daysAgo",{count:u}):`${u} days ago`:a.toLocaleDateString()};function vt({provider:t="claude",className:r="w-5 h-5"}){return t==="cursor"?e.jsx(qi,{className:r}):t==="codex"?e.jsx(Ki,{className:r}):e.jsx(Ji,{className:r})}function Mc({project:t,session:r,selectedSession:s,currentTime:a,editingSession:n,editingSessionName:o,onEditingSessionNameChange:i,onStartEditingSession:c,onCancelEditingSession:d,onSaveEditingSession:u,onProjectSelect:m,onSessionSelect:h,onDeleteSession:p,touchHandlerFactory:g,t:f}){const x=Al(r,a,f),y=(s==null?void 0:s.id)===r.id,N=()=>{m(t),h(r,t.name)},j=()=>{u(t.name,r.id,o)},v=()=>{p(t.name,r.id,x.sessionName,r.__provider)};return e.jsxs("div",{className:"group relative",children:[x.isActive&&e.jsx("div",{className:"absolute left-0 top-1/2 transform -translate-y-1/2 -translate-x-1",children:e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"})}),e.jsx("div",{className:"md:hidden",children:e.jsx("div",{className:ke("p-2 mx-3 my-0.5 rounded-md bg-card border active:scale-[0.98] transition-all duration-150 relative",y?"bg-primary/5 border-primary/20":"",!y&&x.isActive?"border-green-500/30 bg-green-50/5 dark:bg-green-900/5":"border-border/30"),onClick:N,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:ke("w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0",y?"bg-primary/10":"bg-muted/50"),children:e.jsx(vt,{provider:r.__provider,className:"w-3 h-3"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-medium truncate text-foreground",children:x.sessionName}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(Dr,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:nn(x.sessionTime,a,f)}),x.messageCount>0&&e.jsx(kt,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto",children:x.messageCount}),e.jsx("span",{className:"ml-1 opacity-70",children:e.jsx(vt,{provider:r.__provider,className:"w-3 h-3"})})]})]}),!x.isCursorSession&&e.jsx("button",{className:"w-5 h-5 rounded-md bg-red-50 dark:bg-red-900/20 flex items-center justify-center active:scale-95 transition-transform opacity-70 ml-1",onClick:k=>{k.stopPropagation(),v()},children:e.jsx(wt,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})})]})})}),e.jsxs("div",{className:"hidden md:block",children:[e.jsx(xe,{variant:"ghost",className:ke("w-full justify-start px-2 py-2.5 h-auto min-h-[48px] font-normal text-left hover:bg-accent/50 transition-colors duration-200",y&&"bg-accent text-accent-foreground"),onClick:()=>h(r,t.name),children:e.jsxs("div",{className:"flex items-start gap-2 min-w-0 w-full pr-14",children:[e.jsx(vt,{provider:r.__provider,className:"w-3 h-3 mt-1 flex-shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-medium truncate text-foreground leading-5",children:x.sessionName}),e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[e.jsx(Dr,{className:"w-2.5 h-2.5 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:nn(x.sessionTime,a,f)}),x.messageCount>0&&e.jsx(kt,{variant:"secondary",className:"text-xs px-1 py-0 ml-auto group-hover:opacity-0 transition-opacity",children:x.messageCount}),e.jsx("span",{className:"ml-1 opacity-70 group-hover:opacity-0 transition-opacity",children:e.jsx(vt,{provider:r.__provider,className:"w-3 h-3"})})]})]})]})}),!x.isCursorSession&&e.jsx("div",{className:"absolute right-2 top-1/2 transform -translate-y-1/2 flex items-center gap-1.5 opacity-0 group-hover:opacity-100 transition-all duration-200 bg-accent/80 backdrop-blur-sm rounded-md px-1 py-0.5",children:n===r.id&&!x.isCodexSession?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:o,onChange:k=>i(k.target.value),onKeyDown:k=>{k.stopPropagation(),k.key==="Enter"?j():k.key==="Escape"&&d()},onClick:k=>k.stopPropagation(),className:"w-32 px-2 py-1 text-xs border border-border rounded bg-background focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0}),e.jsx("button",{className:"w-6 h-6 bg-green-50 hover:bg-green-100 dark:bg-green-900/20 dark:hover:bg-green-900/40 rounded flex items-center justify-center",onClick:k=>{k.stopPropagation(),j()},title:f("tooltips.save"),children:e.jsx(jt,{className:"w-3 h-3 text-green-600 dark:text-green-400"})}),e.jsx("button",{className:"w-6 h-6 bg-gray-50 hover:bg-gray-100 dark:bg-gray-900/20 dark:hover:bg-gray-900/40 rounded flex items-center justify-center",onClick:k=>{k.stopPropagation(),d()},title:f("tooltips.cancel"),children:e.jsx(He,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})})]}):e.jsxs(e.Fragment,{children:[!x.isCodexSession&&e.jsx("button",{className:"w-7 h-7 bg-gray-50 hover:bg-gray-100 dark:bg-gray-800 dark:hover:bg-gray-700 rounded flex items-center justify-center",onClick:k=>{k.stopPropagation(),c(r.id,r.summary||f("projects.newSession"))},title:f("tooltips.editSessionName"),children:e.jsx(Ni,{className:"w-3 h-3 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{className:"w-7 h-7 bg-red-50 hover:bg-red-100 dark:bg-red-900/20 dark:hover:bg-red-900/40 rounded flex items-center justify-center",onClick:k=>{k.stopPropagation(),v()},title:f("tooltips.deleteSession"),children:e.jsx(wt,{className:"w-3 h-3 text-red-600 dark:text-red-400"})})]})})]})]})}function Dc(){return e.jsx(e.Fragment,{children:Array.from({length:3}).map((t,r)=>e.jsx("div",{className:"p-2 rounded-md",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"w-3 h-3 bg-muted rounded-full animate-pulse mt-0.5"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("div",{className:"h-3 bg-muted rounded animate-pulse",style:{width:`${60+r*15}%`}}),e.jsx("div",{className:"h-2 bg-muted rounded animate-pulse w-1/2"})]})]})},r))})}function Lc({project:t,isExpanded:r,sessions:s,selectedSession:a,initialSessionsLoaded:n,isLoadingSessions:o,currentTime:i,editingSession:c,editingSessionName:d,onEditingSessionNameChange:u,onStartEditingSession:m,onCancelEditingSession:h,onSaveEditingSession:p,onProjectSelect:g,onSessionSelect:f,onDeleteSession:x,onLoadMoreSessions:y,onNewSession:N,touchHandlerFactory:j,t:v}){var P;if(!r)return null;const k=s.length>0,A=((P=t.sessionMeta)==null?void 0:P.hasMore)===!0;return e.jsxs("div",{className:"ml-3 space-y-1 border-l border-border pl-3",children:[n?!k&&!o?e.jsx("div",{className:"py-2 px-3 text-left",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:v("sessions.noSessions")})}):s.map(S=>e.jsx(Mc,{project:t,session:S,selectedSession:a,currentTime:i,editingSession:c,editingSessionName:d,onEditingSessionNameChange:u,onStartEditingSession:m,onCancelEditingSession:h,onSaveEditingSession:p,onProjectSelect:g,onSessionSelect:f,onDeleteSession:x,touchHandlerFactory:j,t:v},S.id)):e.jsx(Dc,{}),k&&A&&e.jsx(xe,{variant:"ghost",size:"sm",className:"w-full justify-center gap-2 mt-2 text-muted-foreground",onClick:()=>y(t),disabled:o,children:o?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-3 h-3 animate-spin rounded-full border border-muted-foreground border-t-transparent"}),v("sessions.loading")]}):e.jsxs(e.Fragment,{children:[e.jsx(Pt,{className:"w-3 h-3"}),v("sessions.showMore")]})}),e.jsx("div",{className:"md:hidden px-3 pb-2",children:e.jsxs("button",{className:"w-full h-8 bg-primary hover:bg-primary/90 text-primary-foreground rounded-md flex items-center justify-center gap-2 font-medium text-xs active:scale-[0.98] transition-all duration-150",onClick:()=>{g(t),N(t)},children:[e.jsx(st,{className:"w-3 h-3"}),v("sessions.newSession")]})}),e.jsxs(xe,{variant:"default",size:"sm",className:"hidden md:flex w-full justify-start gap-2 mt-1 h-8 text-xs font-medium bg-primary hover:bg-primary/90 text-primary-foreground transition-colors",onClick:()=>N(t),children:[e.jsx(st,{className:"w-3 h-3"}),v("sessions.newSession")]})]})}const Pc=(t,r)=>{const s=t.length;return r&&s>=5?`${s}+`:`${s}`};function $c({project:t,selectedProject:r,selectedSession:s,isExpanded:a,isDeleting:n,isStarred:o,editingProject:i,editingName:c,sessions:d,initialSessionsLoaded:u,isLoadingSessions:m,currentTime:h,editingSession:p,editingSessionName:g,tasksEnabled:f,mcpServerStatus:x,onEditingNameChange:y,onToggleProject:N,onProjectSelect:j,onToggleStarProject:v,onStartEditingProject:k,onCancelEditingProject:A,onSaveProjectName:P,onDeleteProject:S,onSessionSelect:b,onDeleteSession:C,onLoadMoreSessions:E,onNewSession:B,onEditingSessionNameChange:T,onStartEditingSession:W,onCancelEditingSession:H,onSaveEditingSession:_,onOpenProjectSettings:M,touchHandlerFactory:z,t:K}){var V;const te=(r==null?void 0:r.name)===t.name,q=i===t.name,ie=((V=t.sessionMeta)==null?void 0:V.hasMore)===!0,$=Pc(d,ie),X=`${$} session${d.length===1?"":"s"}`,re=Dl(t,x),Y=()=>N(t.name),U=()=>v(t.name),O=()=>{P(t.name)},F=()=>{(r==null?void 0:r.name)!==t.name&&j(t),Y()};return e.jsxs("div",{className:ke("md:space-y-1",n&&"opacity-50 pointer-events-none"),children:[e.jsxs("div",{className:"group md:group",children:[e.jsx("div",{className:"md:hidden",children:e.jsx("div",{className:ke("p-3 mx-3 my-1 rounded-lg bg-card border border-border/50 active:scale-[0.98] transition-all duration-150",te&&"bg-primary/5 border-primary/20",o&&!te&&"bg-yellow-50/50 dark:bg-yellow-900/5 border-yellow-200/30 dark:border-yellow-800/30"),onClick:Y,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:ke("w-8 h-8 rounded-lg flex items-center justify-center transition-colors",a?"bg-primary/10":"bg-muted"),children:a?e.jsx(er,{className:"w-4 h-4 text-primary"}):e.jsx(mr,{className:"w-4 h-4 text-muted-foreground"})}),e.jsx("div",{className:"min-w-0 flex-1",children:q?e.jsx("input",{type:"text",value:c,onChange:R=>y(R.target.value),className:"w-full px-3 py-2 text-sm border-2 border-primary/40 focus:border-primary rounded-lg bg-background text-foreground shadow-sm focus:shadow-md transition-all duration-200 focus:outline-none",placeholder:K("projects.projectNamePlaceholder"),autoFocus:!0,autoComplete:"off",onClick:R=>R.stopPropagation(),onKeyDown:R=>{R.key==="Enter"&&O(),R.key==="Escape"&&A()},style:{fontSize:"16px",WebkitAppearance:"none",borderRadius:"8px"}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between min-w-0 flex-1",children:[e.jsx("h3",{className:"text-sm font-medium text-foreground truncate",children:t.displayName}),f&&e.jsx(Ac,{status:re,size:"xs",className:"hidden md:inline-flex flex-shrink-0 ml-2"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:X})]})})]}),e.jsx("div",{className:"flex items-center gap-1",children:q?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"w-8 h-8 rounded-lg bg-green-500 dark:bg-green-600 flex items-center justify-center active:scale-90 transition-all duration-150 shadow-sm active:shadow-none",onClick:R=>{R.stopPropagation(),O()},children:e.jsx(jt,{className:"w-4 h-4 text-white"})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-gray-500 dark:bg-gray-600 flex items-center justify-center active:scale-90 transition-all duration-150 shadow-sm active:shadow-none",onClick:R=>{R.stopPropagation(),A()},children:e.jsx(He,{className:"w-4 h-4 text-white"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:ke("w-8 h-8 rounded-lg flex items-center justify-center active:scale-90 transition-all duration-150 border",o?"bg-yellow-500/10 dark:bg-yellow-900/30 border-yellow-200 dark:border-yellow-800":"bg-gray-500/10 dark:bg-gray-900/30 border-gray-200 dark:border-gray-800"),onClick:R=>{R.stopPropagation(),U()},title:K(o?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:e.jsx(Ba,{className:ke("w-4 h-4 transition-colors",o?"text-yellow-600 dark:text-yellow-400 fill-current":"text-gray-600 dark:text-gray-400")})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-gray-500/10 dark:bg-gray-900/30 flex items-center justify-center active:scale-90 border border-gray-200 dark:border-gray-800",onClick:R=>{R.stopPropagation(),M(t)},title:K("tooltips.projectSettings",{defaultValue:"Project settings"}),children:e.jsx(Lt,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-red-500/10 dark:bg-red-900/30 flex items-center justify-center active:scale-90 border border-red-200 dark:border-red-800",onClick:R=>{R.stopPropagation(),S(t)},children:e.jsx(wt,{className:"w-4 h-4 text-red-600 dark:text-red-400"})}),e.jsx("button",{className:"w-8 h-8 rounded-lg bg-primary/10 dark:bg-primary/20 flex items-center justify-center active:scale-90 border border-primary/20 dark:border-primary/30",onClick:R=>{R.stopPropagation(),k(t)},children:e.jsx(Lr,{className:"w-4 h-4 text-primary"})}),e.jsx("div",{className:"w-6 h-6 rounded-md bg-muted/30 flex items-center justify-center",children:a?e.jsx(Pt,{className:"w-3 h-3 text-muted-foreground"}):e.jsx(sr,{className:"w-3 h-3 text-muted-foreground"})})]})})]})})}),e.jsxs(xe,{variant:"ghost",className:ke("hidden md:flex w-full justify-between p-2 h-auto font-normal hover:bg-accent/50",te&&"bg-accent text-accent-foreground",o&&!te&&"bg-yellow-50/50 dark:bg-yellow-900/10 hover:bg-yellow-100/50 dark:hover:bg-yellow-900/20"),onClick:F,children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[a?e.jsx(er,{className:"w-4 h-4 text-primary flex-shrink-0"}):e.jsx(mr,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),e.jsx("div",{className:"min-w-0 flex-1 text-left",children:q?e.jsxs("div",{className:"space-y-1",children:[e.jsx("input",{type:"text",value:c,onChange:R=>y(R.target.value),className:"w-full px-2 py-1 text-sm border border-border rounded bg-background text-foreground focus:ring-2 focus:ring-primary/20",placeholder:K("projects.projectNamePlaceholder"),autoFocus:!0,onKeyDown:R=>{R.key==="Enter"&&O(),R.key==="Escape"&&A()}}),e.jsx("div",{className:"text-xs text-muted-foreground truncate",title:t.fullPath,children:t.fullPath})]}):e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold truncate text-foreground",title:t.displayName,children:t.displayName}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[$,t.fullPath!==t.displayName&&e.jsxs("span",{className:"ml-1 opacity-60",title:t.fullPath,children:[" - ",t.fullPath.length>25?`...${t.fullPath.slice(-22)}`:t.fullPath]})]})]})})]}),e.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:q?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-6 h-6 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-900/20 flex items-center justify-center rounded cursor-pointer transition-colors",onClick:R=>{R.stopPropagation(),O()},children:e.jsx(jt,{className:"w-3 h-3"})}),e.jsx("div",{className:"w-6 h-6 text-gray-500 hover:text-gray-700 hover:bg-gray-50 dark:hover:bg-gray-800 flex items-center justify-center rounded cursor-pointer transition-colors",onClick:R=>{R.stopPropagation(),A()},children:e.jsx(He,{className:"w-3 h-3"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:ke("w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 flex items-center justify-center rounded cursor-pointer touch:opacity-100",o?"hover:bg-yellow-50 dark:hover:bg-yellow-900/20 opacity-100":"hover:bg-accent"),onClick:R=>{R.stopPropagation(),U()},title:K(o?"tooltips.removeFromFavorites":"tooltips.addToFavorites"),children:e.jsx(Ba,{className:ke("w-3 h-3 transition-colors",o?"text-yellow-600 dark:text-yellow-400 fill-current":"text-muted-foreground")})}),e.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-accent flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:R=>{R.stopPropagation(),M(t)},title:K("tooltips.projectSettings",{defaultValue:"Project settings"}),children:e.jsx(Lt,{className:"w-3 h-3"})}),e.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-accent flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:R=>{R.stopPropagation(),k(t)},title:K("tooltips.renameProject"),children:e.jsx(Lr,{className:"w-3 h-3"})}),e.jsx("div",{className:"w-6 h-6 opacity-0 group-hover:opacity-100 transition-all duration-200 hover:bg-red-50 dark:hover:bg-red-900/20 flex items-center justify-center rounded cursor-pointer touch:opacity-100",onClick:R=>{R.stopPropagation(),S(t)},title:K("tooltips.deleteProject"),children:e.jsx(wt,{className:"w-3 h-3 text-red-600 dark:text-red-400"})}),a?e.jsx(Pt,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"}):e.jsx(sr,{className:"w-4 h-4 text-muted-foreground group-hover:text-foreground transition-colors"})]})})]})]}),e.jsx(Lc,{project:t,isExpanded:a,sessions:d,selectedSession:s,initialSessionsLoaded:u,isLoadingSessions:m,currentTime:h,editingSession:p,editingSessionName:g,onEditingSessionNameChange:T,onStartEditingSession:W,onCancelEditingSession:H,onSaveEditingSession:_,onProjectSelect:j,onSessionSelect:b,onDeleteSession:C,onLoadMoreSessions:E,onNewSession:B,touchHandlerFactory:z,t:K})]})}function _c({isLoading:t,loadingProgress:r,projectsCount:s,filteredProjectsCount:a,t:n}){const{isRelayConnected:o}=Fr();return t?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx("div",{className:"w-6 h-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:n("projects.loadingProjects")}),r&&r.total>0?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"w-full bg-muted rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:"bg-primary h-full transition-all duration-300 ease-out",style:{width:`${r.current/r.total*100}%`}})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[r.current,"/",r.total," ",n("projects.projects")]}),r.currentProject&&e.jsx("p",{className:"text-xs text-muted-foreground/70 truncate max-w-[200px] mx-auto",title:r.currentProject,children:r.currentProject.split("-").slice(-2).join("/")})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:n("projects.fetchingProjects")})]}):s===0?o?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx(mr,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:n("projects.noProjects")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("projects.runClaudeCli")})]}):e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx(ba,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:"No machine connected"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect your machine to see projects"})]}):a===0?e.jsxs("div",{className:"text-center py-12 md:py-8 px-4",children:[e.jsx("div",{className:"w-12 h-12 bg-muted rounded-lg flex items-center justify-center mx-auto mb-4 md:mb-3",children:e.jsx(Mr,{className:"w-6 h-6 text-muted-foreground"})}),e.jsx("h3",{className:"text-base font-medium text-foreground mb-2 md:mb-1",children:n("projects.noMatchingProjects")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("projects.tryDifferentSearch")})]}):null}function Fc({projects:t,filteredProjects:r,selectedProject:s,selectedSession:a,isLoading:n,loadingProgress:o,expandedProjects:i,editingProject:c,editingName:d,loadingSessions:u,initialSessionsLoaded:m,currentTime:h,editingSession:p,editingSessionName:g,deletingProjects:f,tasksEnabled:x,mcpServerStatus:y,getProjectSessions:N,isProjectStarred:j,onEditingNameChange:v,onToggleProject:k,onProjectSelect:A,onToggleStarProject:P,onStartEditingProject:S,onCancelEditingProject:b,onSaveProjectName:C,onDeleteProject:E,onSessionSelect:B,onDeleteSession:T,onLoadMoreSessions:W,onNewSession:H,onEditingSessionNameChange:_,onStartEditingSession:M,onCancelEditingSession:z,onSaveEditingSession:K,onOpenProjectSettings:te,touchHandlerFactory:q,t:ie}){const $=e.jsx(_c,{isLoading:n,loadingProgress:o,projectsCount:t.length,filteredProjectsCount:r.length,t:ie}),X=!n&&t.length>0&&r.length>0;return e.jsx("div",{className:"md:space-y-1 pb-safe-area-inset-bottom",children:X?r.map(re=>e.jsx($c,{project:re,selectedProject:s,selectedSession:a,isExpanded:i.has(re.name),isDeleting:f.has(re.name),isStarred:j(re.name),editingProject:c,editingName:d,sessions:N(re),initialSessionsLoaded:m.has(re.name),isLoadingSessions:!!u[re.name],currentTime:h,editingSession:p,editingSessionName:g,tasksEnabled:x,mcpServerStatus:y,onEditingNameChange:v,onToggleProject:k,onProjectSelect:A,onToggleStarProject:P,onStartEditingProject:S,onCancelEditingProject:b,onSaveProjectName:C,onDeleteProject:E,onSessionSelect:B,onDeleteSession:T,onLoadMoreSessions:W,onNewSession:H,onEditingSessionNameChange:_,onStartEditingSession:M,onCancelEditingSession:z,onSaveEditingSession:K,onOpenProjectSettings:te,touchHandlerFactory:q,t:ie},re.name)):$})}function zc({isPWA:t,isMobile:r,isLoading:s,projects:a,searchFilter:n,onSearchFilterChange:o,onClearSearchFilter:i,onRefresh:c,isRefreshing:d,onCreateProject:u,onCollapseSidebar:m,updateAvailable:h,releaseInfo:p,latestVersion:g,onShowVersionModal:f,onShowSettings:x,projectListProps:y,t:N}){return e.jsxs("div",{className:"h-full flex flex-col bg-background/80 backdrop-blur-sm md:select-none md:w-72",style:{},children:[e.jsx(Tc,{isPWA:t,isMobile:r,isLoading:s,projectsCount:a.length,searchFilter:n,onSearchFilterChange:o,onClearSearchFilter:i,onRefresh:c,isRefreshing:d,onCreateProject:u,onCollapseSidebar:m,t:N}),e.jsx(zo,{className:"flex-1 px-1.5 py-1.5 md:py-2 overflow-y-auto overscroll-contain",children:e.jsx(Fc,{...y})}),e.jsx(Sc,{updateAvailable:h,releaseInfo:p,latestVersion:g,onShowVersionModal:f,onShowSettings:x,t:N})]})}const Rc=({onClose:t,onProjectCreated:r})=>{var Ie;const{t:s}=Be(),[a,n]=l.useState(1),[o,i]=l.useState("existing"),[c,d]=l.useState(""),[u,m]=l.useState(""),[h,p]=l.useState(""),[g,f]=l.useState("stored"),[x,y]=l.useState(""),[N,j]=l.useState(!1),[v,k]=l.useState(null),[A,P]=l.useState([]),[S,b]=l.useState(!1),[C,E]=l.useState([]),[B,T]=l.useState(!1),[W,H]=l.useState(!1),[_,M]=l.useState("~"),[z,K]=l.useState([]),[te,q]=l.useState(!1),[ie,$]=l.useState(!1),[X,re]=l.useState(!1),[Y,U]=l.useState(""),[O,F]=l.useState(!1),[V,R]=l.useState(""),[Z,G]=l.useState([]);l.useEffect(()=>{a===2&&o==="new"&&u&&w()},[a,o,u]),l.useEffect(()=>{c.length>2?I(c):(E([]),T(!1))},[c]);const w=async()=>{try{b(!0);const ge=((await(await Ue.get("/settings/credentials?type=github_token")).json()).credentials||[]).filter(be=>be.is_active);P(ge),ge.length>0&&!h&&p(ge[0].id.toString())}catch(L){console.error("Error loading GitHub tokens:",L)}finally{b(!1)}},I=async L=>{try{const ee=L.lastIndexOf("/"),ge=ee>0?L.substring(0,ee):"~",Pe=await(await Ue.browseFilesystem(ge)).json();if(Pe.suggestions){const Fe=Pe.suggestions.filter(ze=>ze.path.toLowerCase().startsWith(L.toLowerCase())&&ze.path.toLowerCase()!==L.toLowerCase());E(Fe.slice(0,5)),T(Fe.length>0)}}catch(ee){console.error("Error loading path suggestions:",ee)}},J=()=>{if(k(null),a===1){if(!o){k(s("projectWizard.errors.selectType"));return}n(2)}else if(a===2){if(!c.trim()){k(s("projectWizard.errors.providePath"));return}n(3)}},se=()=>{k(null),n(a-1)},ce=async()=>{j(!0),k(null),R("");try{if(o==="new"&&u){const be=new URLSearchParams({path:c.trim(),githubUrl:u.trim()});g==="stored"&&h?be.append("githubTokenId",h):g==="new"&&x&&be.append("newGithubToken",x.trim());const Pe=`/api/projects/clone-progress?${be}`;await new Promise((Fe,ze)=>{const Ve=new EventSource(Pe);Ve.onmessage=ne=>{try{const he=JSON.parse(ne.data);he.type==="progress"?R(he.message):he.type==="complete"?(Ve.close(),r&&r(he.project),t(),Fe()):he.type==="error"&&(Ve.close(),ze(new Error(he.message)))}catch(he){console.error("Error parsing SSE event:",he)}},Ve.onerror=()=>{Ve.close(),ze(new Error("Connection lost during clone"))}});return}const L={workspaceType:o,path:c.trim()},ee=await Ue.createWorkspace(L),ge=await ee.json();if(!ee.ok)throw new Error(ge.details||ge.error||s("projectWizard.errors.failedToCreate"));r&&r(ge.project),t()}catch(L){console.error("Error creating workspace:",L),k(L.message||s("projectWizard.errors.failedToCreate"))}finally{j(!1)}},Ce=L=>{d(L.path),T(!1)},fe=async()=>{H(!0),await _e("~")},_e=async L=>{try{q(!0);const ge=await(await Ue.browseFilesystem(L)).json();M(ge.path||L),K(ge.suggestions||[]),ge.drives&&Array.isArray(ge.drives)&&G(ge.drives)}catch(ee){console.error("Error loading folders:",ee)}finally{q(!1)}},we=(L,ee=!1)=>{d(L),H(!1),ee&&n(3)},Ae=async L=>{await _e(L)},Re=async()=>{if(Y.trim()){F(!0),k(null);try{const L=_.includes("\\")?"\\":"/",ee=`${_}${L}${Y.trim()}`,ge=await Ue.createFolder(ee),be=await ge.json();if(!ge.ok)throw new Error(be.error||s("projectWizard.errors.failedToCreateFolder","Failed to create folder"));U(""),re(!1),await _e(be.path||ee)}catch(L){console.error("Error creating folder:",L),k(L.message||s("projectWizard.errors.failedToCreateFolder","Failed to create folder"))}finally{F(!1)}}};return e.jsxs("div",{className:"fixed top-0 left-0 right-0 bottom-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[60] p-0 sm:p-4",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-none sm:rounded-lg shadow-xl w-full h-full sm:h-auto sm:max-w-2xl border-0 sm:border border-gray-200 dark:border-gray-700 overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(ns,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:s("projectWizard.title")})]}),e.jsx("button",{onClick:t,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",disabled:N,children:e.jsx(He,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"px-6 pt-4 pb-2",children:e.jsx("div",{className:"flex items-center justify-between",children:[1,2,3].map(L=>e.jsxs(lt.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center font-medium text-sm ${L<a?"bg-green-500 text-white":L===a?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-500"}`,children:L<a?e.jsx(jt,{className:"w-4 h-4"}):L}),e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 hidden sm:inline",children:s(L===1?"projectWizard.steps.type":L===2?"projectWizard.steps.configure":"projectWizard.steps.confirm")})]}),L<3&&e.jsx("div",{className:`flex-1 h-1 mx-2 rounded ${L<a?"bg-green-500":"bg-gray-200 dark:bg-gray-700"}`})]},L))})}),e.jsxs("div",{className:"p-6 space-y-6 min-h-[300px]",children:[v&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 flex items-start gap-3",children:[e.jsx(vs,{className:"w-5 h-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5"}),e.jsx("div",{className:"flex-1",children:e.jsx("p",{className:"text-sm text-red-800 dark:text-red-200",children:v})})]}),a===1&&e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:s("projectWizard.step1.question")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx("button",{onClick:()=>i("existing"),className:`p-4 border-2 rounded-lg text-left transition-all ${o==="existing"?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-green-100 dark:bg-green-900/50 rounded-lg flex items-center justify-center flex-shrink-0",children:e.jsx(ns,{className:"w-5 h-5 text-green-600 dark:text-green-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:s("projectWizard.step1.existing.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("projectWizard.step1.existing.description")})]})]})}),e.jsx("button",{onClick:()=>i("new"),className:`p-4 border-2 rounded-lg text-left transition-all ${o==="new"?"border-blue-500 bg-blue-50 dark:bg-blue-900/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center flex-shrink-0",children:e.jsx(br,{className:"w-5 h-5 text-purple-600 dark:text-purple-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h5",{className:"font-semibold text-gray-900 dark:text-white mb-1",children:s("projectWizard.step1.new.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("projectWizard.step1.new.description")})]})]})})]})]})}),a===2&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s(o==="existing"?"projectWizard.step2.existingPath":"projectWizard.step2.newPath")}),e.jsxs("div",{className:"relative flex gap-2",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(Ze,{type:"text",value:c,onChange:L=>d(L.target.value),placeholder:o==="existing"?"/path/to/existing/workspace":"/path/to/new/workspace",className:"w-full"}),B&&C.length>0&&e.jsx("div",{className:"absolute z-10 w-full mt-1 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg max-h-60 overflow-y-auto",children:C.map((L,ee)=>e.jsxs("button",{onClick:()=>Ce(L),className:"w-full px-4 py-2 text-left hover:bg-gray-100 dark:hover:bg-gray-700 text-sm",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:L.name}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:L.path})]},ee))})]}),e.jsx(xe,{type:"button",variant:"outline",onClick:fe,className:"px-3",title:"Browse folders",children:e.jsx(er,{className:"w-4 h-4"})})]}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s(o==="existing"?"projectWizard.step2.existingHelp":"projectWizard.step2.newHelp")})]}),o==="new"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.githubUrl")}),e.jsx(Ze,{type:"text",value:u,onChange:L=>m(L.target.value),placeholder:"https://github.com/username/repository",className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s("projectWizard.step2.githubHelp")})]}),u&&!u.startsWith("git@")&&!u.startsWith("ssh://")&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx(ya,{className:"w-5 h-5 text-gray-600 dark:text-gray-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h5",{className:"font-medium text-gray-900 dark:text-white mb-1",children:s("projectWizard.step2.githubAuth")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("projectWizard.step2.githubAuthHelp")})]})]}),S?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[e.jsx(Tr,{className:"w-4 h-4 animate-spin"}),s("projectWizard.step2.loadingTokens")]}):A.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2 mb-4",children:[e.jsx("button",{onClick:()=>f("stored"),className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${g==="stored"?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:s("projectWizard.step2.storedToken")}),e.jsx("button",{onClick:()=>f("new"),className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${g==="new"?"bg-blue-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:s("projectWizard.step2.newToken")}),e.jsx("button",{onClick:()=>{f("none"),p(""),y("")},className:`px-3 py-2 text-sm font-medium rounded-lg transition-colors ${g==="none"?"bg-green-500 text-white":"bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"}`,children:s("projectWizard.step2.nonePublic")})]}),g==="stored"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.selectToken")}),e.jsxs("select",{value:h,onChange:L=>p(L.target.value),className:"w-full px-3 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg text-sm",children:[e.jsx("option",{value:"",children:s("projectWizard.step2.selectTokenPlaceholder")}),A.map(L=>e.jsx("option",{value:L.id,children:L.credential_name},L.id))]})]}):g==="new"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.newToken")}),e.jsx(Ze,{type:"password",value:x,onChange:L=>y(L.target.value),placeholder:"ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s("projectWizard.step2.tokenHelp")})]}):null]}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-3 border border-blue-200 dark:border-blue-800",children:e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:s("projectWizard.step2.publicRepoInfo")})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:s("projectWizard.step2.optionalTokenPublic")}),e.jsx(Ze,{type:"password",value:x,onChange:L=>y(L.target.value),placeholder:s("projectWizard.step2.tokenPublicPlaceholder"),className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:s("projectWizard.step2.noTokensHelp")})]})]})]})]})]}),a===3&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-900 dark:text-white mb-3",children:s("projectWizard.step3.reviewConfig")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.workspaceType")}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:s(o==="existing"?"projectWizard.step3.existingWorkspace":"projectWizard.step3.newWorkspace")})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.path")}),e.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-white break-all",children:c})]}),o==="new"&&u&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.cloneFrom")}),e.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-white break-all",children:u})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:s("projectWizard.step3.authentication")}),e.jsx("span",{className:"text-xs text-gray-900 dark:text-white",children:g==="stored"&&h?`${s("projectWizard.step3.usingStoredToken")} ${((Ie=A.find(L=>L.id.toString()===h))==null?void 0:Ie.credential_name)||"Unknown"}`:g==="new"&&x?s("projectWizard.step3.usingProvidedToken"):u.startsWith("git@")||u.startsWith("ssh://")?s("projectWizard.step3.sshKey","SSH Key"):s("projectWizard.step3.noAuthentication")})]})]})]})]}),e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-4 border border-blue-200 dark:border-blue-800",children:N&&V?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-blue-800 dark:text-blue-200",children:s("projectWizard.step3.cloningRepository","Cloning repository...")}),e.jsx("code",{className:"block text-xs font-mono text-blue-700 dark:text-blue-300 whitespace-pre-wrap break-all",children:V})]}):e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200",children:s(o==="existing"?"projectWizard.step3.existingInfo":u?"projectWizard.step3.newWithClone":"projectWizard.step3.newEmpty")})})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-6 border-t border-gray-200 dark:border-gray-700",children:[e.jsx(xe,{variant:"outline",onClick:a===1?t:se,disabled:N,children:a===1?s("projectWizard.buttons.cancel"):e.jsxs(e.Fragment,{children:[e.jsx(va,{className:"w-4 h-4 mr-1"}),s("projectWizard.buttons.back")]})}),e.jsx(xe,{onClick:a===3?ce:J,disabled:N||a===1&&!o,children:N?e.jsxs(e.Fragment,{children:[e.jsx(Tr,{className:"w-4 h-4 mr-2 animate-spin"}),u?s("projectWizard.buttons.cloning","Cloning..."):s("projectWizard.buttons.creating")]}):a===3?e.jsxs(e.Fragment,{children:[e.jsx(jt,{className:"w-4 h-4 mr-1"}),s("projectWizard.buttons.createProject")]}):e.jsxs(e.Fragment,{children:[s("projectWizard.buttons.next"),e.jsx(sr,{className:"w-4 h-4 ml-1"})]})})]})]}),W&&e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-[70] p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-2xl max-h-[80vh] border border-gray-200 dark:border-gray-700 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(er,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Select Folder"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>$(!ie),className:`p-2 rounded-md transition-colors ${ie?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,title:ie?"Hide hidden folders":"Show hidden folders",children:ie?e.jsx(ar,{className:"w-5 h-5"}):e.jsx(ro,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>re(!X),className:`p-2 rounded-md transition-colors ${X?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,title:"Create new folder",children:e.jsx(st,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>H(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:e.jsx(He,{className:"w-5 h-5"})})]})]}),X&&e.jsx("div",{className:"px-4 py-3 border-b border-gray-200 dark:border-gray-700 bg-blue-50 dark:bg-blue-900/20",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ze,{type:"text",value:Y,onChange:L=>U(L.target.value),placeholder:"New folder name",className:"flex-1",onKeyDown:L=>{L.key==="Enter"&&Re(),L.key==="Escape"&&(re(!1),U(""))},autoFocus:!0}),e.jsx(xe,{size:"sm",onClick:Re,disabled:!Y.trim()||O,children:O?e.jsx(Tr,{className:"w-4 h-4 animate-spin"}):"Create"}),e.jsx(xe,{size:"sm",variant:"ghost",onClick:()=>{re(!1),U("")},children:"Cancel"})]})}),Z.length>0&&e.jsx("div",{className:"px-4 py-2 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/30",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 mr-1",children:"Drives:"}),Z.map(L=>{const ee=typeof L=="string"?L:L.name||L.path,ge=typeof L=="string"?`${L}\\`:L.path||`${L.name}\\`;return e.jsx("button",{onClick:()=>Ae(ge),className:`px-3 py-1.5 text-sm font-mono font-medium rounded-md border transition-colors ${_.startsWith(ee)?"bg-blue-100 dark:bg-blue-900/50 border-blue-300 dark:border-blue-700 text-blue-700 dark:text-blue-300":"bg-white dark:bg-gray-800 border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,children:ee},ee)})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:te?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(Tr,{className:"w-6 h-6 animate-spin text-gray-400"})}):e.jsxs("div",{className:"space-y-1",children:[_!=="~"&&_!=="/"&&!/^[A-Za-z]:\\?$/.test(_)&&e.jsxs("button",{onClick:()=>{const L=Math.max(_.lastIndexOf("/"),_.lastIndexOf("\\"));let ee;L<=0?ee="/":L===2&&/^[A-Za-z]:/.test(_)?ee=_.substring(0,3):ee=_.substring(0,L),Ae(ee)},className:"w-full px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg flex items-center gap-3",children:[e.jsx(er,{className:"w-5 h-5 text-gray-400"}),e.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:".."})]}),z.length===0?e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:"No subfolders found"}):z.filter(L=>ie||!L.name.startsWith(".")).sort((L,ee)=>L.name.toLowerCase().localeCompare(ee.name.toLowerCase())).map((L,ee)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>Ae(L.path),className:"flex-1 px-4 py-3 text-left hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg flex items-center gap-3",children:[e.jsx(ns,{className:"w-5 h-5 text-blue-500"}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:L.name})]}),e.jsx(xe,{variant:"ghost",size:"sm",onClick:()=>we(L.path,o==="existing"),className:"text-xs px-3",children:"Select"})]},ee))]})}),e.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"px-4 py-3 bg-gray-50 dark:bg-gray-900/50 flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Path:"}),e.jsx("code",{className:"text-sm font-mono text-gray-900 dark:text-white flex-1 truncate",children:_})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 p-4",children:[e.jsx(xe,{variant:"outline",onClick:()=>{H(!1),re(!1),U("")},children:"Cancel"}),e.jsx(xe,{variant:"outline",onClick:()=>we(_,o==="existing"),children:"Use this folder"})]})]})]})})]})};function Oc({isOpen:t,onConfirm:r,onCancel:s,title:a,message:n,detail:o,variant:i="danger",confirmLabel:c="Confirm",cancelLabel:d="Cancel"}){const u=l.useRef(null);l.useEffect(()=>{var p;t&&((p=u.current)==null||p.focus())},[t]);const m=l.useCallback(p=>{p.key==="Escape"&&s()},[s]);if(!t)return null;const h=i==="danger";return Er.createPortal(e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",onKeyDown:m,children:e.jsxs("div",{className:"bg-card border border-border/40 rounded-2xl shadow-2xl max-w-md w-full overflow-hidden",children:[e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:`w-11 h-11 rounded-xl flex items-center justify-center flex-shrink-0 ${h?"bg-red-500/10":"bg-amber-500/10"}`,children:h?e.jsx($t,{className:"w-5 h-5 text-red-500"}):e.jsx(bt,{className:"w-5 h-5 text-amber-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground mb-1.5",children:a}),e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:n}),o&&e.jsx("p",{className:"text-[10px] text-muted-foreground/60 mt-2 leading-relaxed",children:o})]})]})}),e.jsxs("div",{className:"flex gap-2 px-5 py-4 border-t border-border/20",children:[e.jsx("button",{ref:u,onClick:s,className:"flex-1 px-4 py-2.5 text-xs font-medium text-muted-foreground bg-muted/30 hover:bg-muted/50 rounded-xl transition-colors",children:d}),e.jsx("button",{onClick:r,className:`flex-1 px-4 py-2.5 text-xs font-medium rounded-xl transition-opacity ${h?"bg-red-600 hover:bg-red-700 text-white":"bg-foreground hover:opacity-90 text-background"}`,children:c})]})]})}),document.body)}function Ma(){const[t,r]=l.useState(null),s=l.useCallback(i=>new Promise(c=>{r({...i,resolve:c})}),[]),a=l.useCallback(()=>{t==null||t.resolve(!0),r(null)},[t]),n=l.useCallback(()=>{t==null||t.resolve(!1),r(null)},[t]),o=t?{isOpen:!0,onConfirm:a,onCancel:n,title:t.title,message:t.message,detail:t.detail,variant:t.variant,confirmLabel:t.confirmLabel,cancelLabel:t.cancelLabel}:{isOpen:!1,onConfirm:()=>{},onCancel:()=>{},title:"",message:""};return{confirm:s,dialogProps:o,ConfirmDialog:Oc}}const Bc="3.1.0";function Wc(){const{t}=Be("settings"),{confirm:r,dialogProps:s,ConfirmDialog:a}=Ma(),[n,o]=l.useState([]),[i,c]=l.useState([]),[d,u]=l.useState(!0),[m,h]=l.useState(!1),[p,g]=l.useState(!1),[f,x]=l.useState(""),[y,N]=l.useState(""),[j,v]=l.useState(""),[k,A]=l.useState(""),[P,S]=l.useState({}),[b,C]=l.useState(null),[E,B]=l.useState(null),{updateAvailable:T,latestVersion:W,releaseInfo:H}=vo("AnitChaudhry","UpfynAI-Code");l.useEffect(()=>{_()},[]);const _=async()=>{try{u(!0);const re=await(await Te("/api/settings/api-keys")).json();o(re.apiKeys||[]);const U=await(await Te("/api/settings/credentials?type=github_token")).json();c(U.credentials||[])}catch(X){console.error("Error fetching settings:",X)}finally{u(!1)}},M=async()=>{if(f.trim())try{const re=await(await Te("/api/settings/api-keys",{method:"POST",body:JSON.stringify({keyName:f})})).json();re.success&&(B(re.apiKey),x(""),h(!1),_())}catch(X){console.error("Error creating API key:",X)}},z=async X=>{if(await r({title:t("apiKeys.deleteTitle","Delete API Key"),message:t("apiKeys.confirmDelete"),confirmLabel:t("apiKeys.deleteButton","Delete"),cancelLabel:t("common:cancel","Cancel")}))try{await Te(`/api/settings/api-keys/${X}`,{method:"DELETE"}),_()}catch(Y){console.error("Error deleting API key:",Y)}},K=async(X,re)=>{try{await Te(`/api/settings/api-keys/${X}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!re})}),_()}catch(Y){console.error("Error toggling API key:",Y)}},te=async()=>{if(!(!y.trim()||!j.trim()))try{(await(await Te("/api/settings/credentials",{method:"POST",body:JSON.stringify({credentialName:y,credentialType:"github_token",credentialValue:j,description:k})})).json()).success&&(N(""),v(""),A(""),g(!1),_())}catch(X){console.error("Error creating GitHub credential:",X)}},q=async X=>{if(await r({title:t("apiKeys.github.deleteTitle","Delete GitHub Credential"),message:t("apiKeys.github.confirmDelete"),confirmLabel:t("apiKeys.deleteButton","Delete"),cancelLabel:t("common:cancel","Cancel")}))try{await Te(`/api/settings/credentials/${X}`,{method:"DELETE"}),_()}catch(Y){console.error("Error deleting GitHub credential:",Y)}},ie=async(X,re)=>{try{await Te(`/api/settings/credentials/${X}/toggle`,{method:"PATCH",body:JSON.stringify({isActive:!re})}),_()}catch(Y){console.error("Error toggling GitHub credential:",Y)}},$=(X,re)=>{navigator.clipboard.writeText(X),C(re),setTimeout(()=>C(null),2e3)};return d?e.jsx("div",{className:"text-muted-foreground",children:t("apiKeys.loading")}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-8",children:[E&&e.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/20 rounded-lg",children:[e.jsx("h4",{className:"font-semibold text-yellow-500 mb-2",children:t("apiKeys.newKey.alertTitle")}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:t("apiKeys.newKey.alertMessage")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 px-3 py-2 bg-background/50 rounded font-mono text-sm break-all",children:E.apiKey}),e.jsx(xe,{size:"sm",variant:"outline",onClick:()=>$(E.apiKey,"new"),children:b==="new"?e.jsx(jt,{className:"h-4 w-4"}):e.jsx(Pr,{className:"h-4 w-4"})})]}),e.jsx(xe,{size:"sm",variant:"ghost",className:"mt-3",onClick:()=>B(null),children:t("apiKeys.newKey.iveSavedIt")})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ya,{className:"h-5 w-5"}),e.jsx("h3",{className:"text-lg font-semibold",children:t("apiKeys.title")})]}),e.jsxs(xe,{size:"sm",onClick:()=>h(!m),children:[e.jsx(st,{className:"h-4 w-4 mr-1"}),t("apiKeys.newButton")]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:t("apiKeys.description")}),e.jsxs("a",{href:"/api-docs.html",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline inline-flex items-center gap-1",children:[t("apiKeys.apiDocsLink"),e.jsx(Wa,{className:"h-3 w-3"})]})]}),m&&e.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card",children:[e.jsx(Ze,{placeholder:t("apiKeys.form.placeholder"),value:f,onChange:X=>x(X.target.value),className:"mb-2"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(xe,{onClick:M,children:t("apiKeys.form.createButton")}),e.jsx(xe,{variant:"outline",onClick:()=>h(!1),children:t("apiKeys.form.cancelButton")})]})]}),e.jsx("div",{className:"space-y-2",children:n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:t("apiKeys.empty")}):n.map(X=>e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium",children:X.key_name}),e.jsx("code",{className:"text-xs text-muted-foreground",children:X.api_key}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[t("apiKeys.list.created")," ",new Date(X.created_at).toLocaleDateString(),X.last_used&&` • ${t("apiKeys.list.lastUsed")} ${new Date(X.last_used).toLocaleDateString()}`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{size:"sm",variant:X.is_active?"outline":"secondary",onClick:()=>K(X.id,X.is_active),children:X.is_active?t("apiKeys.status.active"):t("apiKeys.status.inactive")}),e.jsx(xe,{size:"sm",variant:"ghost",onClick:()=>z(X.id),children:e.jsx(wt,{className:"h-4 w-4"})})]})]},X.id))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ci,{className:"h-5 w-5"}),e.jsx("h3",{className:"text-lg font-semibold",children:t("apiKeys.github.title")})]}),e.jsxs(xe,{size:"sm",onClick:()=>g(!p),children:[e.jsx(st,{className:"h-4 w-4 mr-1"}),t("apiKeys.github.addButton")]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:t("apiKeys.github.descriptionAlt")}),p&&e.jsxs("div",{className:"mb-4 p-4 border rounded-lg bg-card space-y-3",children:[e.jsx(Ze,{placeholder:t("apiKeys.github.form.namePlaceholder"),value:y,onChange:X=>N(X.target.value)}),e.jsxs("div",{className:"relative",children:[e.jsx(Ze,{type:P.new?"text":"password",placeholder:t("apiKeys.github.form.tokenPlaceholder"),value:j,onChange:X=>v(X.target.value),className:"pr-10"}),e.jsx("button",{type:"button",onClick:()=>S({...P,new:!P.new}),className:"absolute right-3 top-2.5 text-muted-foreground hover:text-foreground",children:P.new?e.jsx(ro,{className:"h-4 w-4"}):e.jsx(ar,{className:"h-4 w-4"})})]}),e.jsx(Ze,{placeholder:t("apiKeys.github.form.descriptionPlaceholder"),value:k,onChange:X=>A(X.target.value)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(xe,{onClick:te,children:t("apiKeys.github.form.addButton")}),e.jsx(xe,{variant:"outline",onClick:()=>{g(!1),N(""),v(""),A("")},children:t("apiKeys.github.form.cancelButton")})]}),e.jsx("a",{href:"https://github.com/settings/tokens",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary hover:underline block",children:t("apiKeys.github.form.howToCreate")})]}),e.jsx("div",{className:"space-y-2",children:i.length===0?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:t("apiKeys.github.empty")}):i.map(X=>e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium",children:X.credential_name}),X.description&&e.jsx("div",{className:"text-xs text-muted-foreground",children:X.description}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:[t("apiKeys.github.added")," ",new Date(X.created_at).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{size:"sm",variant:X.is_active?"outline":"secondary",onClick:()=>ie(X.id,X.is_active),children:X.is_active?t("apiKeys.status.active"):t("apiKeys.status.inactive")}),e.jsx(xe,{size:"sm",variant:"ghost",onClick:()=>q(X.id),children:e.jsx(wt,{className:"h-4 w-4"})})]})]},X.id))})]}),e.jsx("div",{className:"pt-6 border-t border-border/50",children:e.jsxs("div",{className:"flex items-center justify-between text-xs italic text-muted-foreground/60",children:[e.jsxs("a",{href:(H==null?void 0:H.htmlUrl)||"https://github.com/AnitChaudhry/UpfynAI-Code/releases",target:"_blank",rel:"noopener noreferrer",className:"hover:text-muted-foreground transition-colors",children:["v",Bc]}),T&&W&&e.jsxs("a",{href:(H==null?void 0:H.htmlUrl)||"https://github.com/AnitChaudhry/UpfynAI-Code/releases",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 px-2 py-0.5 bg-green-500/10 text-green-600 dark:text-green-400 rounded-full hover:bg-green-500/20 transition-colors not-italic font-medium",children:[e.jsx("span",{className:"text-[10px]",children:t("apiKeys.version.updateAvailable",{version:W})}),e.jsx(Wa,{className:"h-2.5 w-2.5"})]})]})})]}),e.jsx(a,{...s})]})}function Uc(){const{t}=Be("settings"),[r,s]=l.useState(""),[a,n]=l.useState(""),[o,i]=l.useState(!1),[c,d]=l.useState(!1),[u,m]=l.useState(null);l.useEffect(()=>{h()},[]);const h=async()=>{try{i(!0);const g=await Te("/api/user/git-config");if(g.ok){const f=await g.json();s(f.gitName||""),n(f.gitEmail||"")}}catch(g){console.error("Error loading git config:",g)}finally{i(!1)}},p=async()=>{try{d(!0);const g=await Te("/api/user/git-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({gitName:r,gitEmail:a})});if(g.ok)m("success"),setTimeout(()=>m(null),3e3);else{const f=await g.json();m("error"),console.error("Failed to save git config:",f.error)}}catch(g){console.error("Error saving git config:",g),m("error")}finally{d(!1)}};return e.jsx("div",{className:"space-y-8",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(br,{className:"h-5 w-5"}),e.jsx("h3",{className:"text-lg font-semibold",children:t("git.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:t("git.description")}),e.jsxs("div",{className:"p-4 border rounded-lg bg-card space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-git-name",className:"block text-sm font-medium text-foreground mb-2",children:t("git.name.label")}),e.jsx(Ze,{id:"settings-git-name",type:"text",value:r,onChange:g=>s(g.target.value),placeholder:"John Doe",disabled:o,className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("git.name.help")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-git-email",className:"block text-sm font-medium text-foreground mb-2",children:t("git.email.label")}),e.jsx(Ze,{id:"settings-git-email",type:"email",value:a,onChange:g=>n(g.target.value),placeholder:"john@example.com",disabled:o,className:"w-full"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("git.email.help")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{onClick:p,disabled:c||!r||!a,children:t(c?"git.actions.saving":"git.actions.save")}),u==="success"&&e.jsxs("div",{className:"text-sm text-green-600 dark:text-green-400 flex items-center gap-2",children:[e.jsx(jt,{className:"w-4 h-4"}),t("git.status.success")]})]})]})]})})}function Hc(){const{t}=Be("settings"),{tasksEnabled:r,setTasksEnabled:s,isTaskMasterInstalled:a,isCheckingInstallation:n}=zr();return e.jsx("div",{className:"space-y-8",children:n?e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin w-5 h-5 border-2 border-blue-600 border-t-transparent rounded-full"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:t("tasks.checking")})]})}):e.jsxs(e.Fragment,{children:[!a&&e.jsx("div",{className:"bg-orange-50 dark:bg-orange-950/50 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-orange-100 dark:bg-orange-900 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"w-4 h-4 text-orange-600 dark:text-orange-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100 mb-2",children:t("tasks.notInstalled.title")}),e.jsxs("div",{className:"text-sm text-orange-800 dark:text-orange-200 space-y-3",children:[e.jsx("p",{children:t("tasks.notInstalled.description")}),e.jsx("div",{className:"bg-orange-100 dark:bg-orange-900/50 rounded-lg p-3 font-mono text-sm",children:e.jsx("code",{children:t("tasks.notInstalled.installCommand")})}),e.jsx("div",{children:e.jsxs("a",{href:"https://github.com/eyaltoledano/claude-task-master",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-medium text-sm",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z",clipRule:"evenodd"})}),t("tasks.notInstalled.viewOnGitHub"),e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-medium",children:t("tasks.notInstalled.afterInstallation")}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-xs",children:[e.jsx("li",{children:t("tasks.notInstalled.steps.restart")}),e.jsx("li",{children:t("tasks.notInstalled.steps.autoAvailable")}),e.jsx("li",{children:t("tasks.notInstalled.steps.initCommand")})]})]})]})]})]})}),a&&e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:t("tasks.settings.enableLabel")}),e.jsx("div",{className:"text-sm text-muted-foreground mt-1",children:t("tasks.settings.enableDescription")})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:r,onChange:o=>s(o.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"})]})]})})})]})})}const Gc={claude:{name:"Claude",color:"blue"},cursor:{name:"Cursor",color:"purple"},codex:{name:"Codex",color:"gray"}},Vc={blue:{border:"border-l-blue-500 md:border-l-blue-500",borderBottom:"border-b-blue-500",bg:"bg-blue-50 dark:bg-blue-900/20",dot:"bg-blue-500"},purple:{border:"border-l-purple-500 md:border-l-purple-500",borderBottom:"border-b-purple-500",bg:"bg-purple-50 dark:bg-purple-900/20",dot:"bg-purple-500"},gray:{border:"border-l-gray-700 dark:border-l-gray-300",borderBottom:"border-b-gray-700 dark:border-b-gray-300",bg:"bg-gray-100 dark:bg-gray-800/50",dot:"bg-gray-700 dark:bg-gray-300"}};function dr({agentId:t,authStatus:r,isSelected:s,onClick:a,isMobile:n=!1}){const{t:o}=Be("settings"),i=Gc[t],c=Vc[i.color];return n?e.jsx("button",{onClick:a,className:`flex-1 text-center py-3 px-2 border-b-2 transition-colors ${s?`${c.borderBottom} ${c.bg}`:"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx(vt,{provider:t,className:"w-5 h-5"}),e.jsx("span",{className:"text-xs font-medium text-foreground",children:i.name}),(r==null?void 0:r.authenticated)&&e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c.dot}`})]})}):e.jsxs("button",{onClick:a,className:`w-full text-left p-3 border-l-4 transition-colors ${s?`${c.border} ${c.bg}`:"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(vt,{provider:t,className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:i.name})]}),e.jsx("div",{className:"text-xs text-muted-foreground pl-6",children:r!=null&&r.loading?e.jsx("span",{className:"text-gray-400",children:o("agents.authStatus.checking")}):r!=null&&r.authenticated?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c.dot}`}),e.jsx("span",{className:"truncate max-w-[120px]",title:r.email,children:r.email||o("agents.authStatus.connected")})]}):e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-gray-400"}),e.jsx("span",{children:o("agents.authStatus.notConnected")})]})})]})}const qc={claude:{name:"Claude",description:"Anthropic Claude AI assistant",bgClass:"bg-blue-50 dark:bg-blue-900/20",borderClass:"border-blue-200 dark:border-blue-800",textClass:"text-blue-900 dark:text-blue-100",subtextClass:"text-blue-700 dark:text-blue-300",buttonClass:"bg-blue-600 hover:bg-blue-700"},cursor:{name:"Cursor",description:"Cursor AI-powered code editor",bgClass:"bg-purple-50 dark:bg-purple-900/20",borderClass:"border-purple-200 dark:border-purple-800",textClass:"text-purple-900 dark:text-purple-100",subtextClass:"text-purple-700 dark:text-purple-300",buttonClass:"bg-purple-600 hover:bg-purple-700"},codex:{name:"Codex",description:"OpenAI Codex AI assistant",bgClass:"bg-gray-100 dark:bg-gray-800/50",borderClass:"border-gray-300 dark:border-gray-600",textClass:"text-gray-900 dark:text-gray-100",subtextClass:"text-gray-700 dark:text-gray-300",buttonClass:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600"}};function Kc({agent:t,authStatus:r,onLogin:s}){const{t:a}=Be("settings"),n=qc[t];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx(vt,{provider:t,className:"w-6 h-6"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium text-foreground",children:n.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a(`agents.account.${t}.description`)})]})]}),e.jsx("div",{className:`${n.bgClass} border ${n.borderClass} rounded-lg p-4`,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:`font-medium ${n.textClass}`,children:a("agents.connectionStatus")}),e.jsx("div",{className:`text-sm ${n.subtextClass}`,children:r!=null&&r.loading?a("agents.authStatus.checkingAuth"):r!=null&&r.authenticated?a("agents.authStatus.loggedInAs",{email:r.email||a("agents.authStatus.authenticatedUser")}):a("agents.authStatus.notConnected")})]}),e.jsx("div",{children:r!=null&&r.loading?e.jsx(kt,{variant:"secondary",className:"bg-gray-100 dark:bg-gray-800",children:a("agents.authStatus.checking")}):r!=null&&r.authenticated?e.jsx(kt,{variant:"success",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300",children:a("agents.authStatus.connected")}):e.jsx(kt,{variant:"secondary",className:"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-300",children:a("agents.authStatus.disconnected")})})]}),e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:`font-medium ${n.textClass}`,children:r!=null&&r.authenticated?a("agents.login.reAuthenticate"):a("agents.login.title")}),e.jsx("div",{className:`text-sm ${n.subtextClass}`,children:r!=null&&r.authenticated?a("agents.login.reAuthDescription"):a("agents.login.description",{agent:n.name})})]}),e.jsxs(xe,{onClick:s,className:`${n.buttonClass} text-white`,size:"sm",children:[e.jsx(Si,{className:"w-4 h-4 mr-2"}),r!=null&&r.authenticated?a("agents.login.reLoginButton"):a("agents.login.button")]})]})}),(r==null?void 0:r.error)&&e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-4",children:e.jsx("div",{className:"text-sm text-red-600 dark:text-red-400",children:a("agents.error",{error:r.error})})})]})})]})}const Jc=["Bash(git log:*)","Bash(git diff:*)","Bash(git status:*)","Write","Read","Edit","Glob","Grep","MultiEdit","Task","TodoWrite","TodoRead","WebFetch","WebSearch"],Yc=["Shell(ls)","Shell(mkdir)","Shell(cd)","Shell(cat)","Shell(echo)","Shell(git status)","Shell(git diff)","Shell(git log)","Shell(npm install)","Shell(npm run)","Shell(python)","Shell(node)"];function Qc({skipPermissions:t,setSkipPermissions:r,allowedTools:s,setAllowedTools:a,disallowedTools:n,setDisallowedTools:o,newAllowedTool:i,setNewAllowedTool:c,newDisallowedTool:d,setNewDisallowedTool:u}){const{t:m}=Be("settings"),h=x=>{x&&!s.includes(x)&&(a([...s,x]),c(""))},p=x=>{a(s.filter(y=>y!==x))},g=x=>{x&&!n.includes(x)&&(o([...n,x]),u(""))},f=x=>{o(n.filter(y=>y!==x))};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($t,{className:"w-5 h-5 text-orange-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.title")})]}),e.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("label",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:x=>r(x.target.checked),className:"w-4 h-4 text-blue-600 bg-gray-100 dark:bg-gray-700 border-gray-300 dark:border-gray-600 rounded focus:ring-blue-500 focus:ring-2"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:m("permissions.skipPermissions.label")}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:m("permissions.skipPermissions.claudeDescription")})]})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ka,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.allowedTools.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("permissions.allowedTools.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ze,{value:i,onChange:x=>c(x.target.value),placeholder:m("permissions.allowedTools.placeholder"),onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),h(i))},className:"flex-1 h-10"}),e.jsxs(xe,{onClick:()=>h(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(st,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:m("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:m("permissions.allowedTools.quickAdd")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Jc.map(x=>e.jsx(xe,{variant:"outline",size:"sm",onClick:()=>h(x),disabled:s.includes(x),className:"text-xs h-8",children:x},x))})]}),e.jsxs("div",{className:"space-y-2",children:[s.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:x}),e.jsx(xe,{variant:"ghost",size:"sm",onClick:()=>p(x),className:"text-green-600 hover:text-green-700",children:e.jsx(He,{className:"w-4 h-4"})})]},x)),s.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:m("permissions.allowedTools.empty")})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($t,{className:"w-5 h-5 text-red-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.blockedTools.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("permissions.blockedTools.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ze,{value:d,onChange:x=>u(x.target.value),placeholder:m("permissions.blockedTools.placeholder"),onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),g(d))},className:"flex-1 h-10"}),e.jsxs(xe,{onClick:()=>g(d),disabled:!d,size:"sm",className:"h-10 px-4",children:[e.jsx(st,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:m("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[n.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:x}),e.jsx(xe,{variant:"ghost",size:"sm",onClick:()=>f(x),className:"text-red-600 hover:text-red-700",children:e.jsx(He,{className:"w-4 h-4"})})]},x)),n.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:m("permissions.blockedTools.empty")})]})]}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-blue-900 dark:text-blue-100 mb-2",children:m("permissions.toolExamples.title")}),e.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-1",children:[e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git log:*)"'})," ",m("permissions.toolExamples.bashGitLog")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(git diff:*)"'})," ",m("permissions.toolExamples.bashGitDiff")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Write"'})," ",m("permissions.toolExamples.write")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:'"Bash(rm:*)"'})," ",m("permissions.toolExamples.bashRm")]})]})]})]})}function Xc({skipPermissions:t,setSkipPermissions:r,allowedCommands:s,setAllowedCommands:a,disallowedCommands:n,setDisallowedCommands:o,newAllowedCommand:i,setNewAllowedCommand:c,newDisallowedCommand:d,setNewDisallowedCommand:u}){const{t:m}=Be("settings"),h=x=>{x&&!s.includes(x)&&(a([...s,x]),c(""))},p=x=>{a(s.filter(y=>y!==x))},g=x=>{x&&!n.includes(x)&&(o([...n,x]),u(""))},f=x=>{o(n.filter(y=>y!==x))};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($t,{className:"w-5 h-5 text-orange-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.title")})]}),e.jsx("div",{className:"bg-orange-50 dark:bg-orange-900/20 border border-orange-200 dark:border-orange-800 rounded-lg p-4",children:e.jsxs("label",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:x=>r(x.target.checked),className:"w-4 h-4 text-purple-600 bg-gray-100 dark:bg-gray-700 border-gray-300 dark:border-gray-600 rounded focus:ring-purple-500 focus:ring-2"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-orange-900 dark:text-orange-100",children:m("permissions.skipPermissions.label")}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:m("permissions.skipPermissions.cursorDescription")})]})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ka,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.allowedCommands.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("permissions.allowedCommands.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ze,{value:i,onChange:x=>c(x.target.value),placeholder:m("permissions.allowedCommands.placeholder"),onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),h(i))},className:"flex-1 h-10"}),e.jsxs(xe,{onClick:()=>h(i),disabled:!i,size:"sm",className:"h-10 px-4",children:[e.jsx(st,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:m("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:m("permissions.allowedCommands.quickAdd")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Yc.map(x=>e.jsx(xe,{variant:"outline",size:"sm",onClick:()=>h(x),disabled:s.includes(x),className:"text-xs h-8",children:x},x))})]}),e.jsxs("div",{className:"space-y-2",children:[s.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-green-800 dark:text-green-200",children:x}),e.jsx(xe,{variant:"ghost",size:"sm",onClick:()=>p(x),className:"text-green-600 hover:text-green-700",children:e.jsx(He,{className:"w-4 h-4"})})]},x)),s.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:m("permissions.allowedCommands.empty")})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx($t,{className:"w-5 h-5 text-red-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:m("permissions.blockedCommands.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:m("permissions.blockedCommands.description")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx(Ze,{value:d,onChange:x=>u(x.target.value),placeholder:m("permissions.blockedCommands.placeholder"),onKeyPress:x=>{x.key==="Enter"&&(x.preventDefault(),g(d))},className:"flex-1 h-10"}),e.jsxs(xe,{onClick:()=>g(d),disabled:!d,size:"sm",className:"h-10 px-4",children:[e.jsx(st,{className:"w-4 h-4 mr-2 sm:mr-0"}),e.jsx("span",{className:"sm:hidden",children:m("permissions.actions.add")})]})]}),e.jsxs("div",{className:"space-y-2",children:[n.map(x=>e.jsxs("div",{className:"flex items-center justify-between bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:[e.jsx("span",{className:"font-mono text-sm text-red-800 dark:text-red-200",children:x}),e.jsx(xe,{variant:"ghost",size:"sm",onClick:()=>f(x),className:"text-red-600 hover:text-red-700",children:e.jsx(He,{className:"w-4 h-4"})})]},x)),n.length===0&&e.jsx("div",{className:"text-center py-6 text-gray-500 dark:text-gray-400",children:m("permissions.blockedCommands.empty")})]})]}),e.jsxs("div",{className:"bg-purple-50 dark:bg-purple-900/20 border border-purple-200 dark:border-purple-800 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-purple-900 dark:text-purple-100 mb-2",children:m("permissions.shellExamples.title")}),e.jsxs("ul",{className:"text-sm text-purple-800 dark:text-purple-200 space-y-1",children:[e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(ls)"'})," ",m("permissions.shellExamples.ls")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(git status)"'})," ",m("permissions.shellExamples.gitStatus")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(npm install)"'})," ",m("permissions.shellExamples.npmInstall")]}),e.jsxs("li",{children:[e.jsx("code",{className:"bg-purple-100 dark:bg-purple-800 px-1 rounded",children:'"Shell(rm -rf)"'})," ",m("permissions.shellExamples.rmRf")]})]})]})]})}function Zc({permissionMode:t,setPermissionMode:r}){const{t:s}=Be("settings");return e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ka,{className:"w-5 h-5 text-green-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:s("permissions.codex.permissionMode")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("permissions.codex.description")}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="default"?"bg-gray-100 dark:bg-gray-800 border-gray-400 dark:border-gray-500":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>r("default"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="default",onChange:()=>r("default"),className:"mt-1 w-4 h-4 text-green-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:s("permissions.codex.modes.default.title")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:s("permissions.codex.modes.default.description")})]})]})}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="acceptEdits"?"bg-green-50 dark:bg-green-900/20 border-green-400 dark:border-green-600":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>r("acceptEdits"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="acceptEdits",onChange:()=>r("acceptEdits"),className:"mt-1 w-4 h-4 text-green-600"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-green-900 dark:text-green-100",children:s("permissions.codex.modes.acceptEdits.title")}),e.jsx("div",{className:"text-sm text-green-700 dark:text-green-300",children:s("permissions.codex.modes.acceptEdits.description")})]})]})}),e.jsx("div",{className:`border rounded-lg p-4 cursor-pointer transition-all ${t==="bypassPermissions"?"bg-orange-50 dark:bg-orange-900/20 border-orange-400 dark:border-orange-600":"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}`,onClick:()=>r("bypassPermissions"),children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"codexPermissionMode",checked:t==="bypassPermissions",onChange:()=>r("bypassPermissions"),className:"mt-1 w-4 h-4 text-orange-600"}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-medium text-orange-900 dark:text-orange-100 flex items-center gap-2",children:[s("permissions.codex.modes.bypassPermissions.title"),e.jsx($t,{className:"w-4 h-4"})]}),e.jsx("div",{className:"text-sm text-orange-700 dark:text-orange-300",children:s("permissions.codex.modes.bypassPermissions.description")})]})]})}),e.jsxs("details",{className:"text-sm",children:[e.jsx("summary",{className:"cursor-pointer text-muted-foreground hover:text-foreground",children:s("permissions.codex.technicalDetails")}),e.jsxs("div",{className:"mt-2 p-3 bg-gray-50 dark:bg-gray-900/50 rounded-lg text-xs text-muted-foreground space-y-2",children:[e.jsxs("p",{children:[e.jsxs("strong",{children:[s("permissions.codex.modes.default.title"),":"]})," ",s("permissions.codex.technicalInfo.default")]}),e.jsxs("p",{children:[e.jsxs("strong",{children:[s("permissions.codex.modes.acceptEdits.title"),":"]})," ",s("permissions.codex.technicalInfo.acceptEdits")]}),e.jsxs("p",{children:[e.jsxs("strong",{children:[s("permissions.codex.modes.bypassPermissions.title"),":"]})," ",s("permissions.codex.technicalInfo.bypassPermissions")]}),e.jsx("p",{className:"text-xs opacity-75",children:s("permissions.codex.technicalInfo.overrideNote")})]})]})]})})}function Rs({agent:t,...r}){return t==="claude"?e.jsx(Qc,{...r}):t==="cursor"?e.jsx(Xc,{...r}):t==="codex"?e.jsx(Zc,{...r}):null}const ed=t=>{switch(t){case"stdio":return e.jsx(bt,{className:"w-4 h-4"});case"sse":return e.jsx(tr,{className:"w-4 h-4"});case"http":return e.jsx($r,{className:"w-4 h-4"});default:return e.jsx(Or,{className:"w-4 h-4"})}};function td({servers:t,onAdd:r,onEdit:s,onDelete:a,onTest:n,onDiscoverTools:o,testResults:i,serverTools:c,toolsLoading:d}){const{t:u}=Be("settings");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Or,{className:"w-5 h-5 text-purple-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:u("mcpServers.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:u("mcpServers.description.claude")}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(xe,{onClick:r,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(st,{className:"w-4 h-4 mr-2"}),u("mcpServers.addButton")]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(m=>{var h,p,g,f;return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[ed(m.type),e.jsx("span",{className:"font-medium text-foreground",children:m.name}),e.jsx(kt,{variant:"outline",className:"text-xs",children:m.type}),e.jsx(kt,{variant:"outline",className:"text-xs",children:m.scope==="local"?u("mcpServers.scope.local"):m.scope==="user"?u("mcpServers.scope.user"):m.scope})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[m.type==="stdio"&&((h=m.config)==null?void 0:h.command)&&e.jsxs("div",{children:[u("mcpServers.config.command"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:m.config.command})]}),(m.type==="sse"||m.type==="http")&&((p=m.config)==null?void 0:p.url)&&e.jsxs("div",{children:[u("mcpServers.config.url"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:m.config.url})]}),((g=m.config)==null?void 0:g.args)&&m.config.args.length>0&&e.jsxs("div",{children:[u("mcpServers.config.args"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:m.config.args.join(" ")})]})]}),(i==null?void 0:i[m.id])&&e.jsx("div",{className:`mt-2 p-2 rounded text-xs ${i[m.id].success?"bg-green-50 dark:bg-green-900/20 text-green-800 dark:text-green-200":"bg-red-50 dark:bg-red-900/20 text-red-800 dark:text-red-200"}`,children:e.jsx("div",{className:"font-medium",children:i[m.id].message})}),(c==null?void 0:c[m.id])&&((f=c[m.id].tools)==null?void 0:f.length)>0&&e.jsxs("div",{className:"mt-2 p-2 rounded text-xs bg-blue-50 dark:bg-blue-900/20 text-blue-800 dark:text-blue-200",children:[e.jsxs("div",{className:"font-medium",children:[u("mcpServers.tools.title")," ",u("mcpServers.tools.count",{count:c[m.id].tools.length})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[c[m.id].tools.slice(0,5).map((x,y)=>e.jsx("code",{className:"bg-blue-100 dark:bg-blue-800 px-1 rounded",children:x.name},y)),c[m.id].tools.length>5&&e.jsx("span",{className:"text-xs opacity-75",children:u("mcpServers.tools.more",{count:c[m.id].tools.length-5})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(xe,{onClick:()=>s(m),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:u("mcpServers.actions.edit"),children:e.jsx(Lr,{className:"w-4 h-4"})}),e.jsx(xe,{onClick:()=>a(m.id,m.scope),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:u("mcpServers.actions.delete"),children:e.jsx(wt,{className:"w-4 h-4"})})]})]})},m.id)}),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:u("mcpServers.empty")})]})]})}function rd({servers:t,onAdd:r,onEdit:s,onDelete:a}){const{t:n}=Be("settings");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Or,{className:"w-5 h-5 text-purple-500"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:n("mcpServers.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("mcpServers.description.cursor")}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(xe,{onClick:r,className:"bg-purple-600 hover:bg-purple-700 text-white",size:"sm",children:[e.jsx(st,{className:"w-4 h-4 mr-2"}),n("mcpServers.addButton")]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(o=>{var i;return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(bt,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:o.name}),e.jsx(kt,{variant:"outline",className:"text-xs",children:"stdio"})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:((i=o.config)==null?void 0:i.command)&&e.jsxs("div",{children:[n("mcpServers.config.command"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:o.config.command})]})})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(xe,{onClick:()=>s(o),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:n("mcpServers.actions.edit"),children:e.jsx(Lr,{className:"w-4 h-4"})}),e.jsx(xe,{onClick:()=>a(o.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:n("mcpServers.actions.delete"),children:e.jsx(wt,{className:"w-4 h-4"})})]})]})},o.name||o.id)}),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:n("mcpServers.empty")})]})]})}function sd({servers:t,onAdd:r,onEdit:s,onDelete:a}){const{t:n}=Be("settings");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Or,{className:"w-5 h-5 text-gray-700 dark:text-gray-300"}),e.jsx("h3",{className:"text-lg font-medium text-foreground",children:n("mcpServers.title")})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n("mcpServers.description.codex")}),e.jsx("div",{className:"flex justify-between items-center",children:e.jsxs(xe,{onClick:r,className:"bg-gray-800 hover:bg-gray-900 dark:bg-gray-700 dark:hover:bg-gray-600 text-white",size:"sm",children:[e.jsx(st,{className:"w-4 h-4 mr-2"}),n("mcpServers.addButton")]})}),e.jsxs("div",{className:"space-y-2",children:[t.map(o=>{var i,c,d;return e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(bt,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium text-foreground",children:o.name}),e.jsx(kt,{variant:"outline",className:"text-xs",children:"stdio"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[((i=o.config)==null?void 0:i.command)&&e.jsxs("div",{children:[n("mcpServers.config.command"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:o.config.command})]}),((c=o.config)==null?void 0:c.args)&&o.config.args.length>0&&e.jsxs("div",{children:[n("mcpServers.config.args"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:o.config.args.join(" ")})]}),((d=o.config)==null?void 0:d.env)&&Object.keys(o.config.env).length>0&&e.jsxs("div",{children:[n("mcpServers.config.environment"),": ",e.jsx("code",{className:"bg-gray-100 dark:bg-gray-800 px-1 rounded text-xs",children:Object.entries(o.config.env).map(([u,m])=>`${u}=${m}`).join(", ")})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(xe,{onClick:()=>s(o),variant:"ghost",size:"sm",className:"text-gray-600 hover:text-gray-700",title:n("mcpServers.actions.edit"),children:e.jsx(Lr,{className:"w-4 h-4"})}),e.jsx(xe,{onClick:()=>a(o.name),variant:"ghost",size:"sm",className:"text-red-600 hover:text-red-700",title:n("mcpServers.actions.delete"),children:e.jsx(wt,{className:"w-4 h-4"})})]})]})},o.name)}),t.length===0&&e.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:n("mcpServers.empty")})]}),e.jsxs("div",{className:"bg-gray-100 dark:bg-gray-800/50 border border-gray-300 dark:border-gray-600 rounded-lg p-4",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-gray-100 mb-2",children:n("mcpServers.help.title")}),e.jsx("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:n("mcpServers.help.description")})]})]})}function Os({agent:t,...r}){return t==="claude"?e.jsx(td,{...r}):t==="cursor"?e.jsx(rd,{...r}):t==="codex"?e.jsx(sd,{...r}):null}const ad=[{name:"filesystem",description:"Read/write local files and directories",category:"Files & Code",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-filesystem","/path"]}},{name:"github",description:"GitHub repos, issues, and PRs",category:"Data & APIs",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-github"]}},{name:"postgres",description:"Query PostgreSQL databases",category:"Data & APIs",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-postgres"]}},{name:"brave-search",description:"Web search via Brave Search API",category:"AI & Search",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-brave-search"]}},{name:"memory",description:"Persistent memory store for AI agents",category:"AI & Search",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-memory"]}},{name:"puppeteer",description:"Browser automation and scraping",category:"DevOps",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-puppeteer"]}},{name:"sqlite",description:"Query SQLite databases",category:"Data & APIs",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-sqlite"]}},{name:"fetch",description:"HTTP fetch and web content retrieval",category:"Data & APIs",installConfig:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-fetch"]}}],nd={"Files & Code":"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300","Data & APIs":"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300","AI & Search":"bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300",DevOps:"bg-orange-100 dark:bg-orange-900/30 text-orange-700 dark:text-orange-300"};function od(){const[t,r]=l.useState([]),[s,a]=l.useState(!0),[n,o]=l.useState(null),[i,c]=l.useState(""),d=l.useCallback(async()=>{a(!0);try{const g=await(await Te("/api/mcp/config/read")).json();g.success&&g.servers&&r(g.servers)}catch{}a(!1)},[]);l.useEffect(()=>{d();const p=window.location.origin;c(`${p}/mcp`)},[d]);const u=async p=>{o(p.name);try{(await Te("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:p.name,config:{command:p.installConfig.command,args:p.installConfig.args}})})).ok&&await d()}catch{}o(null)},m=p=>t.some(g=>g.name===p),h=p=>{navigator.clipboard.writeText(p)};return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2"})}),e.jsx("h3",{className:"text-base sm:text-lg font-semibold text-foreground",children:"Installed Servers"}),e.jsx("button",{onClick:()=>void d(),className:"ml-auto text-sm text-muted-foreground hover:text-foreground transition-colors",title:"Refresh",children:e.jsx("svg",{className:`w-4 h-4 ${s?"animate-spin":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})]}),s?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-6",children:[e.jsxs("svg",{className:"w-4 h-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Loading servers..."]}):t.length===0?e.jsx("div",{className:"text-sm text-muted-foreground bg-muted/30 rounded-lg px-4 py-4 border border-border/30",children:"No MCP servers installed. Browse the directory below to get started."}):e.jsx("div",{className:"grid gap-2",children:t.map(p=>{var g,f;return e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 bg-card border border-border/50 rounded-lg",children:[e.jsx("svg",{className:"w-4 h-4 text-primary flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:p.name}),p.type==="stdio"&&((g=p.config)==null?void 0:g.command)&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:[p.config.command," ",p.config.args?p.config.args.join(" "):""]}),(p.type==="http"||p.type==="sse")&&((f=p.config)==null?void 0:f.url)&&e.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:p.config.url})]}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${p.type==="stdio"?"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300":p.type==="sse"?"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-300":"bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300"}`,children:p.type}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${p.scope==="user"?"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400":"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300"}`,children:p.scope})]},p.id)})})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("svg",{className:"w-5 h-5 text-amber-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),e.jsx("h3",{className:"text-base sm:text-lg font-semibold text-foreground",children:"Server Directory"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Popular MCP servers"})]}),e.jsx("div",{className:"grid gap-2",children:ad.map(p=>{const g=m(p.name);return e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 bg-muted/20 border border-border/30 rounded-lg",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:p.name}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${nd[p.category]||"bg-gray-100 text-gray-600"}`,children:p.category})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:p.description})]}),g?e.jsxs("span",{className:"text-xs text-green-600 dark:text-green-400 font-medium flex items-center gap-1 flex-shrink-0",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),"Installed"]}):e.jsx("button",{onClick:()=>void u(p),disabled:n===p.name,className:"text-xs px-3 py-1.5 rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 font-medium transition-colors flex-shrink-0 min-h-[36px]",children:n===p.name?"Installing...":"Install"})]},p.name)})})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("svg",{className:"w-5 h-5 text-blue-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})}),e.jsx("h3",{className:"text-base sm:text-lg font-semibold text-foreground",children:"Your Upfyn MCP Server"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"Connect external AI clients (Claude Desktop, Cursor, etc.) to your Upfyn instance using MCP."}),e.jsxs("div",{className:"bg-muted/30 border border-border/30 rounded-lg p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"MCP Endpoint"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("code",{className:"flex-1 text-sm bg-card border border-border rounded px-3 py-1.5 font-mono text-foreground truncate",children:i}),e.jsx("button",{onClick:()=>h(i),className:"px-2.5 py-1.5 rounded-md border border-border hover:bg-accent text-muted-foreground hover:text-foreground transition-colors min-w-[44px] min-h-[44px] flex items-center justify-center",title:"Copy",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Claude Desktop Config"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("code",{className:"flex-1 text-xs bg-card border border-border rounded px-3 py-1.5 font-mono text-foreground overflow-x-auto",children:`{ "mcpServers": { "upfyn": { "url": "${i}" } } }`}),e.jsx("button",{onClick:()=>h(`{ "mcpServers": { "upfyn": { "url": "${i}" } } }`),className:"px-2.5 py-1.5 rounded-md border border-border hover:bg-accent text-muted-foreground hover:text-foreground transition-colors flex-shrink-0 min-w-[44px] min-h-[44px] flex items-center justify-center",title:"Copy config",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]})]})]})]})}function id(){const{isRelayConnected:t,relayCwd:r,relayMachine:s,relayPlatform:a,relayAgents:n,sandboxActive:o,isDisconnecting:i,disconnect:c}=Fr(),[d,u]=l.useState(null),[m,h]=l.useState(!0),[p,g]=l.useState(null),[f,x]=l.useState(!1),[y,N]=l.useState(!1),[j,v]=l.useState(!1),k=l.useCallback(async()=>{try{const C=await Te("/api/auth/connect-token");if(C.ok){const E=await C.json();u(E.token||null)}}catch{}h(!1)},[]);l.useEffect(()=>{k()},[k]);const A=l.useCallback((C,E)=>{navigator.clipboard.writeText(C),g(E),setTimeout(()=>g(null),2e3)},[]),P=l.useCallback(async()=>{x(!0);try{const C=await Te("/api/auth/regenerate-token",{method:"POST"});if(C.ok){const E=await C.json();u(E.token||null)}}catch{}x(!1)},[]),S=l.useCallback(async()=>{await c()&&N(!1)},[c]),b=d?`uc connect --key ${d}`:"uc connect";return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:`rounded-lg border p-4 ${t?"bg-green-500/5 border-green-500/20":"bg-amber-500/5 border-amber-500/20"}`,children:e.jsxs("div",{className:"flex items-center gap-3",children:[t?e.jsx(wa,{className:"w-5 h-5 text-green-500 flex-shrink-0"}):e.jsx(ba,{className:"w-5 h-5 text-amber-400 flex-shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-foreground",children:t?"Machine Connected":"Machine Not Connected"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:t?"Your local machine is connected and ready to execute commands.":"Connect your machine to enable chat, terminal, files, and git."})]}),t&&(y?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-amber-400",children:"Disconnect?"}),e.jsx("button",{onClick:S,disabled:i,className:"text-xs px-3 py-1 rounded bg-red-500/20 text-red-400 hover:bg-red-500/30 border border-red-500/30 transition-colors disabled:opacity-40",children:i?"...":"Yes"}),e.jsx("button",{onClick:()=>N(!1),className:"text-xs px-3 py-1 rounded bg-muted text-muted-foreground hover:bg-muted/80 transition-colors",children:"No"})]}):e.jsx("button",{onClick:()=>N(!0),className:"p-2 rounded hover:bg-red-500/10 text-muted-foreground hover:text-red-400 transition-colors",title:"Disconnect machine",children:e.jsx(so,{className:"w-4 h-4"})}))]})}),t&&e.jsxs("div",{className:"rounded-lg border border-border bg-muted/30 p-4 space-y-3",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Machine Info"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 text-sm",children:[s&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Ei,{className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:s})]}),a&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(bt,{className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsx("span",{children:a})]}),r&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground sm:col-span-2",children:[e.jsx(Ti,{className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsx("span",{className:"truncate font-mono text-xs",children:r})]})]}),n&&e.jsx("div",{className:"pt-2 border-t border-border",children:e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Agents: ",Object.entries(n).filter(([,C])=>C.installed).map(([,C])=>C.label).join(", ")||"None detected"]})}),o&&e.jsx("div",{className:"text-xs px-2 py-1 rounded bg-emerald-500/20 text-emerald-400 border border-emerald-500/30 w-fit",children:"Sandbox Active"})]}),e.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Relay Token"}),e.jsxs("button",{onClick:P,disabled:f,className:"text-xs text-muted-foreground hover:text-foreground flex items-center gap-1 transition-colors disabled:opacity-40",children:[e.jsx(is,{className:`w-3 h-3 ${f?"animate-spin":""}`}),"Regenerate"]})]}),m?e.jsx("div",{className:"h-10 bg-muted/50 rounded animate-pulse"}):d?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 text-xs font-mono bg-background/50 border border-border rounded-md px-3 py-2 truncate select-all",children:d}),e.jsx("button",{onClick:()=>A(d,"token"),className:"flex-shrink-0 p-2 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground",title:"Copy token",children:p==="token"?e.jsx(jt,{className:"w-4 h-4 text-green-400"}):e.jsx(Pr,{className:"w-4 h-4"})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Unable to load token."})]}),!t&&d&&e.jsxs("div",{className:"rounded-lg border border-border p-4 space-y-3",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground",children:"Quick Connect"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Run this command on your local machine:"}),e.jsxs("div",{className:"flex items-center gap-2 bg-background/50 border border-border rounded-md px-3 py-2",children:[e.jsx("code",{className:"flex-1 text-xs font-mono truncate select-all",children:b}),e.jsx("button",{onClick:()=>A(b,"command"),className:"flex-shrink-0 p-1.5 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground",title:"Copy command",children:p==="command"?e.jsx(jt,{className:"w-3.5 h-3.5 text-green-400"}):e.jsx(Pr,{className:"w-3.5 h-3.5"})})]})]}),!t&&e.jsxs("div",{className:"rounded-lg border border-border",children:[e.jsxs("button",{onClick:()=>v(!j),className:"w-full flex items-center justify-between p-4 text-sm font-medium text-foreground hover:bg-muted/30 transition-colors",children:[e.jsx("span",{children:"First-time setup instructions"}),e.jsx("span",{className:`text-muted-foreground transition-transform ${j?"rotate-180":""}`,children:"▾"})]}),j&&e.jsxs("div",{className:"px-4 pb-4 space-y-3 border-t border-border pt-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Bs,{number:1,text:"Install the CLI globally:"}),e.jsx(Ws,{text:"npm install -g upfynai-code",onCopy:A,copied:p,label:"step1"}),e.jsx(Bs,{number:2,text:"Login to your account:"}),e.jsx(Ws,{text:"uc login",onCopy:A,copied:p,label:"step2"}),e.jsx(Bs,{number:3,text:"Connect your machine:"}),e.jsx(Ws,{text:b,onCopy:A,copied:p,label:"step3"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Once connected, all workspace features (chat, terminal, files, git) will become active."})]})]})]})}function Bs({number:t,text:r}){return e.jsxs("p",{className:"text-xs text-muted-foreground",children:[e.jsx("span",{className:"inline-flex items-center justify-center w-4 h-4 rounded-full bg-muted text-[10px] font-medium mr-1.5",children:t}),r]})}function Ws({text:t,onCopy:r,copied:s,label:a}){return e.jsxs("div",{className:"flex items-center gap-2 bg-background/50 rounded-md border border-border px-3 py-2",children:[e.jsx("code",{className:"text-xs text-foreground flex-1 font-mono",children:t}),e.jsx("button",{onClick:()=>r(t,a),className:"flex-shrink-0 p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground",children:s===a?e.jsx(jt,{className:"w-3 h-3 text-green-400"}):e.jsx(Pr,{className:"w-3 h-3"})})]})}function Oo({compact:t=!1}){const{i18n:r,t:s}=Be("settings"),a=n=>{const o=n.target.value;r.changeLanguage(o)};return t?e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(ao,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),s("account.language")]}),e.jsx("select",{value:r.language,onChange:a,className:"w-[100px] text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 focus:outline-none focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400",children:Ra.map(n=>e.jsx("option",{value:n.value,children:n.nativeName},n.value))})]}):e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-100 mb-1",children:s("account.languageLabel")}),e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:s("account.languageDescription")})]}),e.jsx("select",{value:r.language,onChange:a,className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-36",children:Ra.map(n=>e.jsx("option",{value:n.value,children:n.nativeName},n.value))})]})})}function ld(){const[t,r]=l.useState([]),[s,a]=l.useState(!0),[n,o]=l.useState(null),[i,c]=l.useState(!1),d=async()=>{try{const f=await Te("/api/sessions");if(f.ok){const x=await f.json();r(x.sessions||[])}}catch{}a(!1)};l.useEffect(()=>{d();const f=setInterval(d,1e4);return()=>clearInterval(f)},[]);const u=async(f,x)=>{o(f);try{await Te(`/api/sessions/${f}/abort`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:x})}),await d()}catch{}o(null)},m=async()=>{c(!0);try{await Te("/api/sessions/abort-all",{method:"POST"}),await d()}catch{}c(!1)},h=f=>{if(!f)return"";const x=Date.now()-new Date(f).getTime(),y=Math.floor(x/1e3);if(y<60)return`${y}s`;const N=Math.floor(y/60);return N<60?`${N}m`:`${Math.floor(N/60)}h ${N%60}m`},p=f=>({claude:"Claude",cursor:"Cursor",codex:"Codex"})[f]||f,g=f=>({claude:"text-orange-500",cursor:"text-blue-500",codex:"text-green-500"})[f]||"text-gray-500";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[e.jsx(Xs,{className:"w-5 h-5"})," Active Sessions"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:d,className:"text-sm text-muted-foreground hover:text-foreground flex items-center gap-1",children:[e.jsx(is,{className:"w-3.5 h-3.5"})," Refresh"]}),t.length>0&&e.jsxs("button",{onClick:m,disabled:i,className:"text-sm text-red-500 hover:text-red-400 flex items-center gap-1 disabled:opacity-50",children:[e.jsx(Ua,{className:"w-3.5 h-3.5"})," ",i?"Aborting...":"Abort All"]})]})]}),s?e.jsx("div",{className:"text-center text-muted-foreground text-sm py-8",children:"Loading sessions..."}):t.length===0?e.jsxs("div",{className:"bg-muted/30 border border-border rounded-lg p-8 text-center",children:[e.jsx(Xs,{className:"w-8 h-8 mx-auto mb-2 text-muted-foreground/50"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"No active sessions"}),e.jsx("p",{className:"text-muted-foreground/60 text-xs mt-1",children:"Sessions appear here when you run Claude, Cursor, or Codex commands"})]}):e.jsx("div",{className:"border border-border rounded-lg overflow-hidden divide-y divide-border",children:t.map(f=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 hover:bg-muted/30 transition-colors",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-mono text-foreground truncate",children:f.sessionId}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:`text-xs font-medium ${g(f.provider)}`,children:p(f.provider)}),e.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium ${f.status==="active"?"bg-green-500/10 text-green-500 dark:text-green-400":"bg-gray-500/10 text-gray-500"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${f.status==="active"?"bg-green-500":"bg-gray-400"}`}),f.status]}),f.startedAt&&e.jsx("span",{className:"text-xs text-muted-foreground",children:h(f.startedAt)})]})]}),e.jsx("button",{onClick:()=>u(f.sessionId,f.provider),disabled:n===f.sessionId,className:"p-1.5 rounded hover:bg-red-500/10 text-red-500 hover:text-red-400 transition-colors disabled:opacity-50",title:"Abort session",children:e.jsx(Ua,{className:"w-4 h-4"})})]},f.sessionId))})]})}function cd({isOpen:t,onClose:r,projects:s=[],initialTab:a="agents"}){var Vr,qr,Kr,et;const{isDarkMode:n,toggleDarkMode:o}=fa(),{t:i}=Be("settings"),{addToast:c}=hr(),{confirm:d,dialogProps:u,ConfirmDialog:m}=Ma(),[h,p]=l.useState([]),[g,f]=l.useState([]),[x,y]=l.useState(""),[N,j]=l.useState(""),[v,k]=l.useState(!1),[A,P]=l.useState(!1),[S,b]=l.useState(null),[C,E]=l.useState("name"),[B,T]=l.useState([]),[W,H]=l.useState(!1),[_,M]=l.useState(null),[z,K]=l.useState({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),[te,q]=l.useState(!1),[ie,$]=l.useState({}),[X,re]=l.useState({}),[Y,U]=l.useState({}),[O,F]=l.useState(a),[V,R]=l.useState(""),[Z,G]=l.useState("claude"),[w,I]=l.useState("account"),[J,se]=l.useState(()=>localStorage.getItem("codeEditorTheme")||"dark"),[ce,Ce]=l.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[fe,_e]=l.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[we,Ae]=l.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[Re,Ie]=l.useState(()=>localStorage.getItem("codeEditorFontSize")||"14"),[L,ee]=l.useState([]),[ge,be]=l.useState([]),[Pe,Fe]=l.useState(!1),[ze,Ve]=l.useState(""),[ne,he]=l.useState(""),[Ne,Me]=l.useState([]),[Le,Oe]=l.useState([]),[Je,ae]=l.useState("default"),[ye,$e]=l.useState(!1),[Ee,Ye]=l.useState({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),[it,dt]=l.useState(null),[It,Mt]=l.useState(!1),[Ct,Ft]=l.useState(!1),[ht,Vt]=l.useState(""),[de,ue]=l.useState(null),[le,je]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),[We,Qe]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),[Xe,ut]=l.useState({authenticated:!1,email:null,loading:!0,error:null}),Br=async()=>{try{const D=await Te("/api/cursor/mcp");if(D.ok){const Q=await D.json();Me(Q.servers||[])}else console.error("Failed to fetch Cursor MCP servers")}catch(D){console.error("Error fetching Cursor MCP servers:",D)}},yt=async()=>{try{const D=await Te("/api/codex/mcp/config/read");if(D.ok){const oe=await D.json();if(oe.success&&oe.servers){Oe(oe.servers);return}}const Q=await Te("/api/codex/mcp/cli/list");if(Q.ok){const oe=await Q.json();if(oe.success&&oe.servers){const ve=oe.servers.map(qe=>({id:qe.name,name:qe.name,type:qe.type||"stdio",scope:"user",config:{command:qe.command||"",args:qe.args||[],env:qe.env||{}}}));Oe(ve)}}}catch(D){console.error("Error fetching Codex MCP servers:",D)}},pt=async()=>{try{const D=await Te("/api/mcp/config/read");if(D.ok){const ve=await D.json();if(ve.success&&ve.servers){T(ve.servers);return}}const Q=await Te("/api/mcp/cli/list");if(Q.ok){const ve=await Q.json();if(ve.success&&ve.servers){const qe=ve.servers.map(nt=>({id:nt.name,name:nt.name,type:nt.type,scope:"user",config:{command:nt.command||"",args:nt.args||[],env:nt.env||{},url:nt.url||"",headers:nt.headers||{},timeout:3e4},created:new Date().toISOString(),updated:new Date().toISOString()}));T(qe);return}}const oe=await Te("/api/mcp/servers?scope=user");if(oe.ok){const ve=await oe.json();T(ve.servers||[])}else console.error("Failed to fetch MCP servers")}catch(D){console.error("Error fetching MCP servers:",D)}},at=async D=>{var Q,oe,ve,qe,nt;try{_&&await rt(_.id,"user");const cr=await Te("/api/mcp/cli/add",{method:"POST",body:JSON.stringify({name:D.name,type:D.type,scope:D.scope,projectPath:D.projectPath,command:(Q=D.config)==null?void 0:Q.command,args:((oe=D.config)==null?void 0:oe.args)||[],url:(ve=D.config)==null?void 0:ve.url,headers:((qe=D.config)==null?void 0:qe.headers)||{},env:((nt=D.config)==null?void 0:nt.env)||{}})});if(cr.ok){const Jr=await cr.json();if(Jr.success)return await pt(),!0;throw new Error(Jr.error||"Failed to save server via Claude CLI")}else{const Jr=await cr.json();throw new Error(Jr.error||"Failed to save server")}}catch(cr){throw console.error("Error saving MCP server:",cr),cr}},rt=async(D,Q="user")=>{try{const oe=await Te(`/api/mcp/cli/remove/${D}?scope=${Q}`,{method:"DELETE"});if(oe.ok){const ve=await oe.json();if(ve.success)return await pt(),!0;throw new Error(ve.error||"Failed to delete server via Claude CLI")}else{const ve=await oe.json();throw new Error(ve.error||"Failed to delete server")}}catch(oe){throw console.error("Error deleting MCP server:",oe),oe}},zt=async(D,Q="user")=>{try{const oe=await Te(`/api/mcp/servers/${D}/test?scope=${Q}`,{method:"POST"});if(oe.ok)return(await oe.json()).testResult;{const ve=await oe.json();throw new Error(ve.error||"Failed to test server")}}catch(oe){throw console.error("Error testing MCP server:",oe),oe}},vr=async(D,Q="user")=>{try{const oe=await Te(`/api/mcp/servers/${D}/tools?scope=${Q}`,{method:"POST"});if(oe.ok)return(await oe.json()).toolsResult;{const ve=await oe.json();throw new Error(ve.error||"Failed to discover tools")}}catch(oe){throw console.error("Error discovering MCP tools:",oe),oe}},Ns=async D=>{var Q,oe,ve;try{it&&await kr(it.id);const qe=await Te("/api/codex/mcp/cli/add",{method:"POST",body:JSON.stringify({name:D.name,command:(Q=D.config)==null?void 0:Q.command,args:((oe=D.config)==null?void 0:oe.args)||[],env:((ve=D.config)==null?void 0:ve.env)||{}})});if(qe.ok){const nt=await qe.json();if(nt.success)return await yt(),!0;throw new Error(nt.error||"Failed to save Codex MCP server")}else{const nt=await qe.json();throw new Error(nt.error||"Failed to save server")}}catch(qe){throw console.error("Error saving Codex MCP server:",qe),qe}},kr=async D=>{try{const Q=await Te(`/api/codex/mcp/cli/remove/${D}`,{method:"DELETE"});if(Q.ok){const oe=await Q.json();if(oe.success)return await yt(),!0;throw new Error(oe.error||"Failed to delete Codex MCP server")}else{const oe=await Q.json();throw new Error(oe.error||"Failed to delete server")}}catch(Q){throw console.error("Error deleting Codex MCP server:",Q),Q}},ir=()=>{Ye({name:"",type:"stdio",config:{command:"",args:[],env:{}}}),dt(null),$e(!1)},Wr=(D=null)=>{var Q,oe,ve;D?(dt(D),Ye({name:D.name,type:D.type||"stdio",config:{command:((Q=D.config)==null?void 0:Q.command)||"",args:((oe=D.config)==null?void 0:oe.args)||[],env:((ve=D.config)==null?void 0:ve.env)||{}}})):ir(),$e(!0)},Cs=async D=>{D.preventDefault(),Mt(!0);try{it&&await kr(it.name),await Ns(Ee),ir(),b("success")}catch(Q){c(`Error: ${Q.message}`,"error"),b("error")}finally{Mt(!1)}},Ss=async D=>{if(await d({title:i("mcp.deleteTitle","Delete MCP Server"),message:i("mcp.confirmDelete","Are you sure you want to delete this MCP server?"),confirmLabel:i("mcp.deleteButton","Delete"),cancelLabel:i("common:cancel","Cancel")}))try{await kr(D),b("success")}catch(oe){c(`Error: ${oe.message}`,"error"),b("error")}};l.useEffect(()=>{t&&(Es(),Ur(),Hr(),Gr(),F(a))},[t,a]),l.useEffect(()=>{localStorage.setItem("codeEditorTheme",J),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[J]),l.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",ce.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[ce]),l.useEffect(()=>{localStorage.setItem("codeEditorShowMinimap",fe.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[fe]),l.useEffect(()=>{localStorage.setItem("codeEditorLineNumbers",we.toString()),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[we]),l.useEffect(()=>{localStorage.setItem("codeEditorFontSize",Re),window.dispatchEvent(new Event("codeEditorSettingsChanged"))},[Re]);const Es=async()=>{try{const D=localStorage.getItem("claude-settings");if(D){const ve=JSON.parse(D);p(ve.allowedTools||[]),f(ve.disallowedTools||[]),k(ve.skipPermissions||!1),E(ve.projectSortOrder||"name")}else p([]),f([]),k(!1),E("name");const Q=localStorage.getItem("cursor-tools-settings");if(Q){const ve=JSON.parse(Q);ee(ve.allowedCommands||[]),be(ve.disallowedCommands||[]),Fe(ve.skipPermissions||!1)}else ee([]),be([]),Fe(!1);const oe=localStorage.getItem("codex-settings");if(oe){const ve=JSON.parse(oe);ae(ve.permissionMode||"default")}else ae("default");await pt(),await Br(),await yt()}catch(D){console.error("Error loading tool settings:",D),p([]),f([]),k(!1),E("name")}},Ur=async()=>{try{const D=await Te("/api/cli/claude/status");if(D.ok){const Q=await D.json();je({authenticated:Q.authenticated,email:Q.email,loading:!1,error:Q.error||null})}else je({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(D){console.error("Error checking Claude auth status:",D),je({authenticated:!1,email:null,loading:!1,error:D.message})}},Hr=async()=>{try{const D=await Te("/api/cli/cursor/status");if(D.ok){const Q=await D.json();Qe({authenticated:Q.authenticated,email:Q.email,loading:!1,error:Q.error||null})}else Qe({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(D){console.error("Error checking Cursor auth status:",D),Qe({authenticated:!1,email:null,loading:!1,error:D.message})}},Gr=async()=>{try{const D=await Te("/api/cli/codex/status");if(D.ok){const Q=await D.json();ut({authenticated:Q.authenticated,email:Q.email,loading:!1,error:Q.error||null})}else ut({authenticated:!1,email:null,loading:!1,error:"Failed to check authentication status"})}catch(D){console.error("Error checking Codex auth status:",D),ut({authenticated:!1,email:null,loading:!1,error:D.message})}},Ts=()=>{Vt("claude"),ue((s==null?void 0:s[0])||{name:"default",fullPath:process.cwd()}),Ft(!0)},As=()=>{Vt("cursor"),ue((s==null?void 0:s[0])||{name:"default",fullPath:process.cwd()}),Ft(!0)},Is=()=>{Vt("codex"),ue((s==null?void 0:s[0])||{name:"default",fullPath:process.cwd()}),Ft(!0)},lr=D=>{D===0&&(b("success"),ht==="claude"?Ur():ht==="cursor"?Hr():ht==="codex"&&Gr())},Ms=()=>{P(!0),b(null);try{const D={allowedTools:h,disallowedTools:g,skipPermissions:v,projectSortOrder:C,lastUpdated:new Date().toISOString()},Q={allowedCommands:L,disallowedCommands:ge,skipPermissions:Pe,lastUpdated:new Date().toISOString()},oe={permissionMode:Je,lastUpdated:new Date().toISOString()};localStorage.setItem("claude-settings",JSON.stringify(D)),localStorage.setItem("cursor-tools-settings",JSON.stringify(Q)),localStorage.setItem("codex-settings",JSON.stringify(oe)),b("success"),setTimeout(()=>{r()},1e3)}catch(D){console.error("Error saving tool settings:",D),b("error")}finally{P(!1)}},qt=()=>{K({name:"",type:"stdio",scope:"user",projectPath:"",config:{command:"",args:[],env:{},url:"",headers:{},timeout:3e4},jsonInput:"",importMode:"form"}),M(null),H(!1),R("")},wr=(D=null)=>{D?(M(D),K({name:D.name,type:D.type,scope:D.scope,projectPath:D.projectPath||"",config:{...D.config},raw:D.raw,importMode:"form",jsonInput:""})):qt(),H(!0)},Ds=async D=>{D.preventDefault(),q(!0);try{if(z.importMode==="json"){const Q=await Te("/api/mcp/cli/add-json",{method:"POST",body:JSON.stringify({name:z.name,jsonConfig:z.jsonInput,scope:z.scope,projectPath:z.projectPath})});if(Q.ok){const oe=await Q.json();if(oe.success)await pt(),qt(),b("success");else throw new Error(oe.error||"Failed to add server via JSON")}else{const oe=await Q.json();throw new Error(oe.error||"Failed to add server")}}else await at(z),qt(),b("success")}catch(Q){c(`Error: ${Q.message}`,"error"),b("error")}finally{q(!1)}},Ls=async(D,Q)=>{if(await d({title:i("mcp.deleteTitle","Delete MCP Server"),message:i("mcp.confirmDelete","Are you sure you want to delete this MCP server?"),confirmLabel:i("mcp.deleteButton","Delete"),cancelLabel:i("common:cancel","Cancel")}))try{await rt(D,Q),b("success")}catch(ve){c(`Error: ${ve.message}`,"error"),b("error")}},Ps=async(D,Q)=>{try{$({...ie,[D]:{loading:!0}});const oe=await zt(D,Q);$({...ie,[D]:oe})}catch(oe){$({...ie,[D]:{success:!1,message:oe.message,details:[]}})}},$s=async(D,Q)=>{try{U({...Y,[D]:!0});const oe=await vr(D,Q);re({...X,[D]:oe})}catch{re({...X,[D]:{success:!1,tools:[],resources:[],prompts:[]}})}finally{U({...Y,[D]:!1})}},Kt=(D,Q)=>{K(oe=>({...oe,config:{...oe.config,[D]:Q}}))};return t?e.jsxs("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[9999] md:p-4 bg-background/95",children:[e.jsxs("div",{className:"bg-background border border-border md:rounded-lg shadow-xl w-full md:max-w-4xl h-full md:h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-border flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Lt,{className:"w-5 h-5 md:w-6 md:h-6 text-blue-600"}),e.jsx("h2",{className:"text-lg md:text-xl font-semibold text-foreground",children:i("title")})]}),e.jsx(xe,{variant:"ghost",size:"sm",onClick:r,className:"text-muted-foreground hover:text-foreground touch-manipulation",children:e.jsx(He,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsx("div",{className:"border-b border-border",children:e.jsxs("div",{className:"flex overflow-x-auto scrollbar-none px-4 md:px-6",children:[e.jsx("button",{onClick:()=>F("agents"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${O==="agents"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("mainTabs.agents")}),!rr&&e.jsxs("button",{onClick:()=>F("connection"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${O==="connection"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(wa,{className:"w-4 h-4 inline mr-2"}),"Connection"]}),e.jsx("button",{onClick:()=>F("appearance"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${O==="appearance"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("mainTabs.appearance")}),e.jsxs("button",{onClick:()=>F("git"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${O==="git"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(br,{className:"w-4 h-4 inline mr-2"}),i("mainTabs.git")]}),e.jsxs("button",{onClick:()=>F("api"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${O==="api"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(ya,{className:"w-4 h-4 inline mr-2"}),i("mainTabs.apiTokens")]}),e.jsx("button",{onClick:()=>F("tasks"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${O==="tasks"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("mainTabs.tasks")}),e.jsxs("button",{onClick:()=>F("mcp"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${O==="mcp"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Or,{className:"w-4 h-4 inline mr-2"}),"MCP Hub"]}),e.jsxs("button",{onClick:()=>F("sessions"),className:`px-3 py-3 text-sm font-medium border-b-2 transition-colors whitespace-nowrap flex-shrink-0 ${O==="sessions"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Xs,{className:"w-4 h-4 inline mr-2"}),"Sessions"]})]})}),e.jsxs("div",{className:"p-4 md:p-6 space-y-6 md:space-y-8 pb-safe-area-inset-bottom",children:[O==="appearance"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:O==="appearance"&&e.jsxs("div",{className:"space-y-6 md:space-y-8",children:[e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.darkMode.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.darkMode.description")})]}),e.jsxs("button",{onClick:o,className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":n,"aria-label":"Toggle dark mode",children:[e.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),e.jsx("span",{className:`${n?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:n?e.jsx(Zs,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx(ea,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})})}),e.jsx("div",{className:"space-y-4",children:e.jsx(Oo,{})}),e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.projectSorting.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.projectSorting.description")})]}),e.jsxs("select",{value:C,onChange:D=>E(D.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-32",children:[e.jsx("option",{value:"name",children:i("appearanceSettings.projectSorting.alphabetical")}),e.jsx("option",{value:"date",children:i("appearanceSettings.projectSorting.recentActivity")})]})]})})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:i("appearanceSettings.codeEditor.title")}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.theme.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.theme.description")})]}),e.jsxs("button",{onClick:()=>se(J==="dark"?"light":"dark"),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":J==="dark","aria-label":"Toggle editor theme",children:[e.jsx("span",{className:"sr-only",children:"Toggle editor theme"}),e.jsx("span",{className:`${J==="dark"?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:J==="dark"?e.jsx(Zs,{className:"w-3.5 h-3.5 text-gray-700"}):e.jsx(ea,{className:"w-3.5 h-3.5 text-yellow-500"})})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.wordWrap.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.wordWrap.description")})]}),e.jsxs("button",{onClick:()=>Ce(!ce),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":ce,"aria-label":"Toggle word wrap",children:[e.jsx("span",{className:"sr-only",children:"Toggle word wrap"}),e.jsx("span",{className:`${ce?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.showMinimap.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.showMinimap.description")})]}),e.jsxs("button",{onClick:()=>_e(!fe),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":fe,"aria-label":"Toggle minimap",children:[e.jsx("span",{className:"sr-only",children:"Toggle minimap"}),e.jsx("span",{className:`${fe?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.lineNumbers.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.lineNumbers.description")})]}),e.jsxs("button",{onClick:()=>Ae(!we),className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":we,"aria-label":"Toggle line numbers",children:[e.jsx("span",{className:"sr-only",children:"Toggle line numbers"}),e.jsx("span",{className:`${we?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200`})]})]})}),e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-foreground",children:i("appearanceSettings.codeEditor.fontSize.label")}),e.jsx("div",{className:"text-sm text-muted-foreground",children:i("appearanceSettings.codeEditor.fontSize.description")})]}),e.jsxs("select",{value:Re,onChange:D=>Ie(D.target.value),className:"text-sm bg-gray-50 dark:bg-gray-800 border border-gray-300 dark:border-gray-600 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 p-2 w-24",children:[e.jsx("option",{value:"10",children:"10px"}),e.jsx("option",{value:"11",children:"11px"}),e.jsx("option",{value:"12",children:"12px"}),e.jsx("option",{value:"13",children:"13px"}),e.jsx("option",{value:"14",children:"14px"}),e.jsx("option",{value:"15",children:"15px"}),e.jsx("option",{value:"16",children:"16px"}),e.jsx("option",{value:"18",children:"18px"}),e.jsx("option",{value:"20",children:"20px"})]})]})})]})]})}),O==="connection"&&!rr&&e.jsx(id,{}),O==="git"&&e.jsx(Uc,{}),O==="agents"&&e.jsxs("div",{className:"flex flex-col md:flex-row h-full min-h-[400px] md:min-h-[500px]",children:[e.jsx("div",{className:"md:hidden border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsxs("div",{className:"flex",children:[e.jsx(dr,{agentId:"claude",authStatus:le,isSelected:Z==="claude",onClick:()=>G("claude"),isMobile:!0}),e.jsx(dr,{agentId:"cursor",authStatus:We,isSelected:Z==="cursor",onClick:()=>G("cursor"),isMobile:!0}),e.jsx(dr,{agentId:"codex",authStatus:Xe,isSelected:Z==="codex",onClick:()=>G("codex"),isMobile:!0})]})}),e.jsx("div",{className:"hidden md:block w-48 border-r border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsxs("div",{className:"p-2",children:[e.jsx(dr,{agentId:"claude",authStatus:le,isSelected:Z==="claude",onClick:()=>G("claude")}),e.jsx(dr,{agentId:"cursor",authStatus:We,isSelected:Z==="cursor",onClick:()=>G("cursor")}),e.jsx(dr,{agentId:"codex",authStatus:Xe,isSelected:Z==="codex",onClick:()=>G("codex")})]})}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:e.jsxs("div",{className:"flex px-2 md:px-4 overflow-x-auto",children:[e.jsx("button",{onClick:()=>I("account"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${w==="account"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("tabs.account")}),e.jsx("button",{onClick:()=>I("permissions"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${w==="permissions"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("tabs.permissions")}),e.jsx("button",{onClick:()=>I("mcp"),className:`px-3 md:px-4 py-2 md:py-3 text-xs md:text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${w==="mcp"?"border-blue-600 text-blue-600 dark:text-blue-400":"border-transparent text-muted-foreground hover:text-foreground"}`,children:i("tabs.mcpServers")})]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-3 md:p-4",children:[w==="account"&&e.jsx(Kc,{agent:Z,authStatus:Z==="claude"?le:Z==="cursor"?We:Xe,onLogin:Z==="claude"?Ts:Z==="cursor"?As:Is}),w==="permissions"&&Z==="claude"&&e.jsx(Rs,{agent:"claude",skipPermissions:v,setSkipPermissions:k,allowedTools:h,setAllowedTools:p,disallowedTools:g,setDisallowedTools:f,newAllowedTool:x,setNewAllowedTool:y,newDisallowedTool:N,setNewDisallowedTool:j}),w==="permissions"&&Z==="cursor"&&e.jsx(Rs,{agent:"cursor",skipPermissions:Pe,setSkipPermissions:Fe,allowedCommands:L,setAllowedCommands:ee,disallowedCommands:ge,setDisallowedCommands:be,newAllowedCommand:ze,setNewAllowedCommand:Ve,newDisallowedCommand:ne,setNewDisallowedCommand:he}),w==="permissions"&&Z==="codex"&&e.jsx(Rs,{agent:"codex",permissionMode:Je,setPermissionMode:ae}),w==="mcp"&&Z==="claude"&&e.jsx(Os,{agent:"claude",servers:B,onAdd:()=>wr(),onEdit:D=>wr(D),onDelete:(D,Q)=>Ls(D,Q),onTest:(D,Q)=>Ps(D,Q),onDiscoverTools:(D,Q)=>$s(D,Q),testResults:ie,serverTools:X,toolsLoading:Y}),w==="mcp"&&Z==="cursor"&&e.jsx(Os,{agent:"cursor",servers:Ne,onAdd:()=>{},onEdit:D=>{},onDelete:D=>{}}),w==="mcp"&&Z==="codex"&&e.jsx(Os,{agent:"codex",servers:Le,onAdd:()=>Wr(),onEdit:D=>Wr(D),onDelete:D=>Ss(D)})]})]})]}),W&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:e.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[e.jsx("h3",{className:"text-lg font-medium text-foreground",children:i(_?"mcpForm.title.edit":"mcpForm.title.add")}),e.jsx(xe,{variant:"ghost",size:"sm",onClick:qt,children:e.jsx(He,{className:"w-4 h-4"})})]}),e.jsxs("form",{onSubmit:Ds,className:"p-4 space-y-4",children:[!_&&e.jsxs("div",{className:"flex gap-2 mb-4",children:[e.jsx("button",{type:"button",onClick:()=>K(D=>({...D,importMode:"form"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${z.importMode==="form"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:i("mcpForm.importMode.form")}),e.jsx("button",{type:"button",onClick:()=>K(D=>({...D,importMode:"json"})),className:`px-4 py-2 rounded-lg font-medium transition-colors ${z.importMode==="json"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:i("mcpForm.importMode.json")})]}),z.importMode==="form"&&_&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-3",children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.scope.label")}),e.jsxs("div",{className:"flex items-center gap-2",children:[z.scope==="user"?e.jsx($r,{className:"w-4 h-4"}):e.jsx(er,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm",children:z.scope==="user"?i("mcpForm.scope.userGlobal"):i("mcpForm.scope.projectLocal")}),z.scope==="local"&&z.projectPath&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",z.projectPath]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:i("mcpForm.scope.cannotChange")})]}),z.importMode==="form"&&!_&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.scope.label")," *"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>K(D=>({...D,scope:"user",projectPath:""})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${z.scope==="user"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx($r,{className:"w-4 h-4"}),e.jsx("span",{children:i("mcpForm.scope.userGlobal")})]})}),e.jsx("button",{type:"button",onClick:()=>K(D=>({...D,scope:"local"})),className:`flex-1 px-4 py-2 rounded-lg font-medium transition-colors ${z.scope==="local"?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700"}`,children:e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx(er,{className:"w-4 h-4"}),e.jsx("span",{children:i("mcpForm.scope.projectLocal")})]})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:z.scope==="user"?i("mcpForm.scope.userDescription"):i("mcpForm.scope.projectDescription")})]}),z.scope==="local"&&!_&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.selectProject")," *"]}),e.jsxs("select",{value:z.projectPath,onChange:D=>K(Q=>({...Q,projectPath:D.target.value})),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",required:z.scope==="local",children:[e.jsxs("option",{value:"",children:[i("mcpForm.fields.selectProject"),"..."]}),s.map(D=>e.jsx("option",{value:D.path||D.fullPath,children:D.displayName||D.name},D.name))]}),z.projectPath&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:i("mcpForm.projectPath",{path:z.projectPath})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:z.importMode==="json"?"md:col-span-2":"",children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.serverName")," *"]}),e.jsx(Ze,{value:z.name,onChange:D=>{K(Q=>({...Q,name:D.target.value}))},placeholder:i("mcpForm.placeholders.serverName"),required:!0})]}),z.importMode==="form"&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.transportType")," *"]}),e.jsxs("select",{value:z.type,onChange:D=>{K(Q=>({...Q,type:D.target.value}))},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",children:[e.jsx("option",{value:"stdio",children:"stdio"}),e.jsx("option",{value:"sse",children:"SSE"}),e.jsx("option",{value:"http",children:"HTTP"})]})]})]}),_&&z.raw&&z.importMode==="form"&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-900/50 border border-gray-200 dark:border-gray-700 rounded-lg p-4",children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:i("mcpForm.configDetails",{configFile:_.scope==="global"?"~/.claude.json":"project config"})}),e.jsx("pre",{className:"text-xs bg-gray-100 dark:bg-gray-800 p-3 rounded overflow-x-auto",children:JSON.stringify(z.raw,null,2)})]}),z.importMode==="json"&&e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.jsonConfig")," *"]}),e.jsx("textarea",{value:z.jsonInput,onChange:D=>{K(Q=>({...Q,jsonInput:D.target.value}));try{if(D.target.value.trim()){const Q=JSON.parse(D.target.value);Q.type?Q.type==="stdio"&&!Q.command?R(i("mcpForm.validation.stdioRequiresCommand")):(Q.type==="http"||Q.type==="sse")&&!Q.url?R(i("mcpForm.validation.httpRequiresUrl",{type:Q.type})):R(""):R(i("mcpForm.validation.missingType"))}}catch{D.target.value.trim()?R(i("mcpForm.validation.invalidJson")):R("")}},className:`w-full px-3 py-2 border ${V?"border-red-500":"border-gray-300 dark:border-gray-600"} bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500 font-mono text-sm`,rows:"8",placeholder:`{
3
+ "type": "stdio",
4
+ "command": "/path/to/server",
5
+ "args": ["--api-key", "abc123"],
6
+ "env": {
7
+ "CACHE_DIR": "/tmp"
8
+ }
9
+ }`,required:!0}),V&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:V}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[i("mcpForm.validation.jsonHelp"),e.jsx("br",{}),"• stdio: ",'{"type":"stdio","command":"npx","args":["@upstash/context7-mcp"]}',e.jsx("br",{}),"• http/sse: ",'{"type":"http","url":"https://api.example.com/mcp"}']})]})}),z.importMode==="form"&&z.type==="stdio"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.command")," *"]}),e.jsx(Ze,{value:z.config.command,onChange:D=>Kt("command",D.target.value),placeholder:"/path/to/mcp-server",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.arguments")}),e.jsx("textarea",{value:Array.isArray(z.config.args)?z.config.args.join(`
10
+ `):"",onChange:D=>Kt("args",D.target.value.split(`
11
+ `).filter(Q=>Q.trim())),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",rows:"3",placeholder:`--api-key
12
+ abc123`})]})]}),z.importMode==="form"&&(z.type==="sse"||z.type==="http")&&e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.url")," *"]}),e.jsx(Ze,{value:z.config.url,onChange:D=>Kt("url",D.target.value),placeholder:"https://api.example.com/mcp",type:"url",required:!0})]}),z.importMode==="form"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.envVars")}),e.jsx("textarea",{value:Object.entries(z.config.env||{}).map(([D,Q])=>`${D}=${Q}`).join(`
13
+ `),onChange:D=>{const Q={};D.target.value.split(`
14
+ `).forEach(oe=>{const[ve,...qe]=oe.split("=");ve&&ve.trim()&&(Q[ve.trim()]=qe.join("=").trim())}),Kt("env",Q)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",rows:"3",placeholder:`API_KEY=your-key
15
+ DEBUG=true`})]}),z.importMode==="form"&&(z.type==="sse"||z.type==="http")&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.headers")}),e.jsx("textarea",{value:Object.entries(z.config.headers||{}).map(([D,Q])=>`${D}=${Q}`).join(`
16
+ `),onChange:D=>{const Q={};D.target.value.split(`
17
+ `).forEach(oe=>{const[ve,...qe]=oe.split("=");ve&&ve.trim()&&(Q[ve.trim()]=qe.join("=").trim())}),Kt("headers",Q)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 rounded-lg focus:ring-blue-500 focus:border-blue-500",rows:"3",placeholder:`Authorization=Bearer token
18
+ X-API-Key=your-key`})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(xe,{type:"button",variant:"outline",onClick:qt,children:i("mcpForm.actions.cancel")}),e.jsx(xe,{type:"submit",disabled:te,className:"bg-purple-600 hover:bg-purple-700 disabled:opacity-50",children:i(te?"mcpForm.actions.saving":_?"mcpForm.actions.updateServer":"mcpForm.actions.addServer")})]})]})]})}),ye&&e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[110] p-4",children:e.jsxs("div",{className:"bg-background border border-border rounded-lg w-full max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[e.jsx("h3",{className:"text-lg font-medium text-foreground",children:i(it?"mcpForm.title.edit":"mcpForm.title.add")}),e.jsx(xe,{variant:"ghost",size:"sm",onClick:ir,children:e.jsx(He,{className:"w-4 h-4"})})]}),e.jsxs("form",{onSubmit:Cs,className:"p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.serverName")," *"]}),e.jsx(Ze,{value:Ee.name,onChange:D=>Ye(Q=>({...Q,name:D.target.value})),placeholder:i("mcpForm.placeholders.serverName"),required:!0})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-foreground mb-2",children:[i("mcpForm.fields.command")," *"]}),e.jsx(Ze,{value:((Vr=Ee.config)==null?void 0:Vr.command)||"",onChange:D=>Ye(Q=>({...Q,config:{...Q.config,command:D.target.value}})),placeholder:"npx @my-org/mcp-server",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.arguments")}),e.jsx("textarea",{value:(((qr=Ee.config)==null?void 0:qr.args)||[]).join(`
19
+ `),onChange:D=>Ye(Q=>({...Q,config:{...Q.config,args:D.target.value.split(`
20
+ `).filter(oe=>oe.trim())}})),placeholder:`--port
21
+ 3000`,rows:3,className:"w-full px-3 py-2 text-sm bg-background border border-input rounded-md focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-foreground mb-2",children:i("mcpForm.fields.envVars")}),e.jsx("textarea",{value:Object.entries(((Kr=Ee.config)==null?void 0:Kr.env)||{}).map(([D,Q])=>`${D}=${Q}`).join(`
22
+ `),onChange:D=>{const Q={};D.target.value.split(`
23
+ `).forEach(oe=>{const[ve,...qe]=oe.split("=");ve&&qe.length>0&&(Q[ve.trim()]=qe.join("=").trim())}),Ye(oe=>({...oe,config:{...oe.config,env:Q}}))},placeholder:`API_KEY=xxx
24
+ DEBUG=true`,rows:3,className:"w-full px-3 py-2 text-sm bg-background border border-input rounded-md focus:outline-none focus:ring-2 focus:ring-ring"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t border-border",children:[e.jsx(xe,{type:"button",variant:"outline",onClick:ir,children:i("mcpForm.actions.cancel")}),e.jsx(xe,{type:"submit",disabled:It||!Ee.name||!((et=Ee.config)!=null&&et.command),className:"bg-green-600 hover:bg-green-700 text-white",children:i(It?"mcpForm.actions.saving":it?"mcpForm.actions.updateServer":"mcpForm.actions.addServer")})]})]})]})}),O==="tasks"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:e.jsx(Hc,{})}),O==="api"&&e.jsx("div",{className:"space-y-6 md:space-y-8",children:e.jsx(Wc,{})}),O==="mcp"&&e.jsx(od,{}),O==="sessions"&&e.jsx(ld,{})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between p-4 md:p-6 border-t border-border flex-shrink-0 gap-3 pb-safe-area-inset-bottom",children:[e.jsxs("div",{className:"flex items-center justify-center sm:justify-start gap-2 order-2 sm:order-1",children:[S==="success"&&e.jsxs("div",{className:"text-green-600 dark:text-green-400 text-sm flex items-center gap-1",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),i("saveStatus.success")]}),S==="error"&&e.jsxs("div",{className:"text-red-600 dark:text-red-400 text-sm flex items-center gap-1",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",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 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})}),i("saveStatus.error")]})]}),e.jsxs("div",{className:"flex items-center gap-3 order-1 sm:order-2",children:[e.jsx(xe,{variant:"outline",onClick:r,disabled:A,className:"flex-1 sm:flex-none h-10 touch-manipulation",children:i("footerActions.cancel")}),e.jsx(xe,{onClick:Ms,disabled:A,className:"flex-1 sm:flex-none h-10 bg-blue-600 hover:bg-blue-700 disabled:opacity-50 touch-manipulation",children:A?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 animate-spin rounded-full border-2 border-white border-t-transparent"}),i("saveStatus.saving")]}):i("footerActions.save")})]})]})]}),e.jsx(Yi,{isOpen:Ct,onClose:()=>Ft(!1),provider:ht,project:de,onComplete:lr,isAuthenticated:ht==="claude"?le.authenticated:ht==="cursor"?We.authenticated:ht==="codex"?Xe.authenticated:!1},ht),e.jsx(m,{...u})]}):null}function dd({isOpen:t,onClose:r,releaseInfo:s,currentVersion:a,latestVersion:n}){const{t:o}=Be("common"),[i,c]=l.useState(!1),[d,u]=l.useState(""),[m,h]=l.useState(""),[p,g]=l.useState(!1),[f,x]=l.useState(!1),y=l.useCallback(async()=>{c(!0),u(`Starting update...
25
+ `),h(""),g(!1);try{const j=await Te("/api/system/update",{method:"POST"}),v=await j.json();j.ok?(u(k=>k+(v.output||"")+`
26
+ `),u(k=>k+`
27
+ Update completed successfully!
28
+ `),u(k=>k+`Restart the server to apply changes.
29
+ `),g(!0)):(h(v.error||"Update failed"),u(k=>k+`
30
+ Update failed: `+(v.error||"Unknown error")+`
31
+ `))}catch{h("Network error — could not reach the server."),u(j=>j+`
32
+ Update failed: Network error
33
+ `)}finally{c(!1)}},[]),N=l.useCallback(()=>{navigator.clipboard.writeText("npm install -g upfynai-code@latest"),x(!0),setTimeout(()=>x(!1),2e3)},[]);return t?e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("button",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:r,"aria-label":o("versionUpdate.ariaLabels.closeModal")}),e.jsxs("div",{className:"relative bg-card border border-border/40 rounded-2xl shadow-2xl w-full max-w-lg mx-4 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-primary/10 rounded-xl flex items-center justify-center",children:e.jsx("svg",{className:"w-5 h-5 text-primary",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M9 19l3 3m0 0l3-3m-3 3V10"})})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground",children:o("versionUpdate.title")}),e.jsx("p",{className:"text-xs text-muted-foreground/50",children:(s==null?void 0:s.title)||o("versionUpdate.newVersionReady")})]})]}),e.jsx("button",{onClick:r,className:"p-2 text-muted-foreground/40 hover:text-foreground hover:bg-muted/30 rounded-lg transition-colors",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center p-3 bg-muted/20 rounded-xl",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:o("versionUpdate.currentVersion")}),e.jsx("span",{className:"text-xs text-foreground font-mono",children:a})]}),e.jsxs("div",{className:"flex justify-between items-center p-3 bg-primary/5 rounded-xl border border-primary/15",children:[e.jsx("span",{className:"text-xs font-medium text-primary",children:o("versionUpdate.latestVersion")}),e.jsx("span",{className:"text-xs text-primary font-mono font-semibold",children:n})]})]}),(s==null?void 0:s.body)&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:o("versionUpdate.whatsNew")}),(s==null?void 0:s.htmlUrl)&&e.jsxs("a",{href:s.htmlUrl,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] text-primary hover:underline flex items-center gap-1",children:[o("versionUpdate.viewFullRelease"),e.jsx("svg",{className:"w-2.5 h-2.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})]}),e.jsx("div",{className:"bg-muted/20 rounded-xl p-3 max-h-48 overflow-y-auto",children:e.jsx("div",{className:"text-xs text-muted-foreground whitespace-pre-wrap leading-relaxed",children:ud(s.body)})})]}),d&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:o("versionUpdate.updateProgress")}),e.jsx("div",{className:"bg-background rounded-xl p-3 border border-border/30 max-h-40 overflow-y-auto",children:e.jsx("pre",{className:"text-[10px] text-green-400 font-mono whitespace-pre-wrap",children:d})}),m&&e.jsx("div",{className:"px-3 py-2 text-xs text-red-400 bg-red-500/[0.03] border border-red-500/15 rounded-xl",children:m})]}),!i&&!d&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-foreground",children:o("versionUpdate.manualUpgrade")}),e.jsxs("div",{className:"flex items-center justify-between bg-background rounded-xl p-3 border border-border/30 cursor-pointer hover:border-border/50 transition-colors group",onClick:N,children:[e.jsx("code",{className:"text-xs text-foreground font-mono",children:"npm install -g upfynai-code@latest"}),e.jsx("span",{className:"text-[10px] text-muted-foreground/40 group-hover:text-primary transition-colors",children:f?"Copied!":"Click to copy"})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground/40 leading-relaxed",children:o("versionUpdate.manualUpgradeHint")})]})]}),e.jsxs("div",{className:"flex gap-2 px-5 py-4 border-t border-border/20",children:[e.jsx("button",{onClick:r,className:"flex-1 px-4 py-2.5 text-xs font-medium text-muted-foreground bg-muted/30 hover:bg-muted/50 rounded-xl transition-colors",children:o(p?"versionUpdate.buttons.close":"versionUpdate.buttons.later")}),!d&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:N,className:"flex-1 px-4 py-2.5 text-xs font-medium text-muted-foreground bg-muted/30 hover:bg-muted/50 rounded-xl transition-colors",children:f?"Copied!":o("versionUpdate.buttons.copyCommand")}),e.jsx("button",{onClick:y,disabled:i,className:"flex-1 px-4 py-2.5 text-xs font-medium text-background bg-foreground hover:opacity-90 disabled:opacity-40 rounded-xl transition-opacity flex items-center justify-center gap-2",children:i?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-3.5 h-3.5 border-2 border-background/30 border-t-background rounded-full animate-spin"}),o("versionUpdate.buttons.updating")]}):o("versionUpdate.buttons.updateNow")})]})]})]})]}):null}const ud=t=>t?t.replace(/\b[0-9a-f]{40}\b/gi,"").replace(/(?:^|\s|-)([0-9a-f]{7,10})\b/gi,"").replace(/\*\*Full Changelog\*\*:.*$/gim,"").replace(/https?:\/\/github\.com\/[^\/]+\/[^\/]+\/compare\/[^\s)]+/gi,"").replace(/\n\s*\n\s*\n/g,`
34
+
35
+ `).trim():"",md=cd;function pd(t){return e.jsx(md,{...t})}function xd({projects:t,showSettings:r,settingsInitialTab:s,onCloseSettings:a,showNewProject:n,onCloseNewProject:o,onProjectCreated:i,deleteConfirmation:c,onCancelDeleteProject:d,onConfirmDeleteProject:u,sessionDeleteConfirmation:m,onCancelDeleteSession:h,onConfirmDeleteSession:p,showVersionModal:g,onCloseVersionModal:f,releaseInfo:x,currentVersion:y,latestVersion:N,t:j}){const v=l.useMemo(()=>t.map(Ll),[t]);return e.jsxs(e.Fragment,{children:[n&&Er.createPortal(e.jsx(Rc,{onClose:o,onProjectCreated:i}),document.body),r&&Er.createPortal(e.jsx(pd,{isOpen:r,onClose:a,projects:v,initialTab:s}),document.body),c&&Er.createPortal(e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-card border border-border rounded-xl shadow-2xl max-w-md w-full overflow-hidden",children:[e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center flex-shrink-0",children:e.jsx($t,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:j("deleteConfirmation.deleteProject")}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[j("deleteConfirmation.confirmDelete")," ",e.jsx("span",{className:"font-medium text-foreground",children:c.project.displayName||c.project.name}),"?"]}),c.sessionCount>0&&e.jsxs("div",{className:"mt-3 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg",children:[e.jsx("p",{className:"text-sm text-red-700 dark:text-red-300 font-medium",children:j("deleteConfirmation.sessionCount",{count:c.sessionCount})}),e.jsx("p",{className:"text-xs text-red-600 dark:text-red-400 mt-1",children:j("deleteConfirmation.allConversationsDeleted")})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:j("deleteConfirmation.cannotUndo")})]})]})}),e.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[e.jsx(xe,{variant:"outline",className:"flex-1",onClick:d,children:j("actions.cancel")}),e.jsxs(xe,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:u,children:[e.jsx(wt,{className:"w-4 h-4 mr-2"}),j("actions.delete")]})]})]})}),document.body),m&&Er.createPortal(e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-card border border-border rounded-xl shadow-2xl max-w-md w-full overflow-hidden",children:[e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center flex-shrink-0",children:e.jsx($t,{className:"w-6 h-6 text-red-600 dark:text-red-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:j("deleteConfirmation.deleteSession")}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-1",children:[j("deleteConfirmation.confirmDelete")," ",e.jsx("span",{className:"font-medium text-foreground",children:m.sessionTitle||j("sessions.unnamed")}),"?"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-3",children:j("deleteConfirmation.cannotUndo")})]})]})}),e.jsxs("div",{className:"flex gap-3 p-4 bg-muted/30 border-t border-border",children:[e.jsx(xe,{variant:"outline",className:"flex-1",onClick:h,children:j("actions.cancel")}),e.jsxs(xe,{variant:"destructive",className:"flex-1 bg-red-600 hover:bg-red-700 text-white",onClick:p,children:[e.jsx(wt,{className:"w-4 h-4 mr-2"}),j("actions.delete")]})]})]})}),document.body),e.jsx(dd,{isOpen:g,onClose:f,releaseInfo:x,currentVersion:y,latestVersion:N})]})}function gd({project:t,isOpen:r,onClose:s}){var j;const{t:a}=Be("sidebar"),[n,o]=l.useState(null),[i,c]=l.useState(null),[d,u]=l.useState(!1),[m,h]=l.useState(null),[p,g]=l.useState([]),[f,x]=l.useState(!1),y=l.useCallback(async()=>{u(!0),h(null);try{const k=await(await Te(`/api/projects/${encodeURIComponent(t.name)}/claude-md`)).json();o(k.content),c(k.path||null),k.error&&h(k.error)}catch{h("Failed to fetch CLAUDE.md")}finally{u(!1)}},[t.name]),N=l.useCallback(async()=>{x(!0);try{const v=t.fullPath||t.path||"",A=await(await Te(`/api/mcp/config/read?projectPath=${encodeURIComponent(v)}`)).json();A.success&&A.servers?g(A.servers.filter(P=>P.scope==="project"||P.scope==="local")):g([])}catch{g([])}finally{x(!1)}},[t.fullPath,t.path]);return l.useEffect(()=>{r&&(y(),N())},[r,y,N]),l.useEffect(()=>{if(!r)return;const v=k=>{k.key==="Escape"&&s()};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[r,s]),r?e.jsxs("div",{className:"fixed inset-0 z-50 flex",children:[e.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm",onClick:s}),e.jsxs("div",{className:"relative ml-auto w-full sm:max-w-md bg-card border-l border-border shadow-2xl flex flex-col h-full animate-in slide-in-from-right duration-200",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-muted/30",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground truncate",children:t.displayName}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",title:t.fullPath,children:t.fullPath})]}),e.jsx("button",{onClick:s,className:"ml-3 w-10 h-10 sm:w-7 sm:h-7 rounded-md hover:bg-accent flex items-center justify-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-4 space-y-5 pb-[max(1rem,env(safe-area-inset-bottom))]",children:[e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:a("projectSettings.quickInfo",{defaultValue:"Quick Info"})}),e.jsxs("div",{className:"space-y-1.5 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx("svg",{className:"w-3.5 h-3.5 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"})}),e.jsx("span",{className:"truncate",children:t.fullPath})]}),((j=t.taskmaster)==null?void 0:j.hasTaskmaster)&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx("svg",{className:"w-3.5 h-3.5 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})}),e.jsxs("span",{children:["TaskMaster: ",e.jsx("span",{className:"text-green-600 dark:text-green-400",children:"Active"})]})]})]})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:"CLAUDE.md"}),d?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-3",children:[e.jsxs("svg",{className:"w-4 h-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Loading..."]}):m?e.jsx("div",{className:"text-sm text-amber-600 dark:text-amber-400 bg-amber-50 dark:bg-amber-900/20 rounded-lg px-3 py-2",children:m}):n?e.jsxs("div",{className:"bg-muted/50 rounded-lg border border-border/50 overflow-hidden",children:[e.jsx("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/50 bg-muted/30",children:e.jsx("span",{className:"text-xs text-muted-foreground font-mono truncate",children:i})}),e.jsx("pre",{className:"px-3 py-2 text-xs text-foreground overflow-x-auto max-h-[300px] overflow-y-auto whitespace-pre-wrap font-mono leading-relaxed",children:n})]}):e.jsx("div",{className:"text-sm text-muted-foreground bg-muted/30 rounded-lg px-3 py-3 border border-border/30",children:a("projectSettings.noClaudeMd",{defaultValue:"No CLAUDE.md found in this project."})})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:a("projectSettings.mcpServers",{defaultValue:"Project MCP Servers"})}),f?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-3",children:[e.jsxs("svg",{className:"w-4 h-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Loading..."]}):p.length>0?e.jsx("div",{className:"space-y-2",children:p.map(v=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-muted/30 rounded-lg border border-border/30",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-primary flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2"})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("span",{className:"text-sm font-medium text-foreground",children:v.name})}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${v.type==="stdio"?"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300":"bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300"}`,children:v.type})]},v.id))}):e.jsx("div",{className:"text-sm text-muted-foreground bg-muted/30 rounded-lg px-3 py-3 border border-border/30",children:a("projectSettings.noMcpServers",{defaultValue:"No project-scoped MCP servers configured."})})]})]})]})]}):null}function on({projects:t,selectedProject:r,selectedSession:s,onProjectSelect:a,onSessionSelect:n,onNewSession:o,onSessionDelete:i,onProjectDelete:c,isLoading:d,loadingProgress:u,onRefresh:m,onShowSettings:h,showSettings:p,settingsInitialTab:g,onCloseSettings:f,isMobile:x}){const{t:y}=Be(["sidebar","common"]),{isPWA:N}=Ea({trackMobile:!1}),{updateAvailable:j,latestVersion:v,currentVersion:k,releaseInfo:A,dismissUpdate:P}=vo("AnitChaudhry","UpfynAI-Code"),{preferences:S,setPreference:b}=Ta(),{sidebarVisible:C}=S,{setCurrentProject:E,mcpServerStatus:B}=fr(),{tasksEnabled:T}=zr(),[W,H]=l.useState(null),_=l.useCallback(Ee=>H(Ee),[]),M=l.useCallback(()=>H(null),[]),{isSidebarCollapsed:z,expandedProjects:K,editingProject:te,showNewProject:q,editingName:ie,loadingSessions:$,initialSessionsLoaded:X,currentTime:re,isRefreshing:Y,editingSession:U,editingSessionName:O,searchFilter:F,deletingProjects:V,deleteConfirmation:R,sessionDeleteConfirmation:Z,showVersionModal:G,filteredProjects:w,handleTouchClick:I,toggleProject:J,handleSessionClick:se,toggleStarProject:ce,isProjectStarred:Ce,getProjectSessions:fe,startEditing:_e,cancelEditing:we,saveProjectName:Ae,showDeleteSessionConfirmation:Re,confirmDeleteSession:Ie,requestProjectDelete:L,confirmDeleteProject:ee,loadMoreSessions:ge,handleProjectSelect:be,refreshProjects:Pe,updateSessionSummary:Fe,collapseSidebar:ze,expandSidebar:Ve,setShowNewProject:ne,setEditingName:he,setEditingSession:Ne,setEditingSessionName:Me,setSearchFilter:Le,setDeleteConfirmation:Oe,setSessionDeleteConfirmation:Je,setShowVersionModal:ae}=Pl({projects:t,selectedProject:r,selectedSession:s,isLoading:d,isMobile:x,t:y,onRefresh:m,onProjectSelect:a,onSessionSelect:n,onSessionDelete:i,onProjectDelete:c,setCurrentProject:E,setSidebarVisible:Ee=>b("sidebarVisible",Ee),sidebarVisible:C});l.useEffect(()=>{typeof document>"u"||(document.documentElement.classList.toggle("pwa-mode",N),document.body.classList.toggle("pwa-mode",N))},[N]);const ye=()=>{if(window.refreshProjects){window.refreshProjects();return}window.location.reload()},$e={projects:t,filteredProjects:w,selectedProject:r,selectedSession:s,isLoading:d,loadingProgress:u,expandedProjects:K,editingProject:te,editingName:ie,loadingSessions:$,initialSessionsLoaded:X,currentTime:re,editingSession:U,editingSessionName:O,deletingProjects:V,tasksEnabled:T,mcpServerStatus:B,getProjectSessions:fe,isProjectStarred:Ce,onEditingNameChange:he,onToggleProject:J,onProjectSelect:be,onToggleStarProject:ce,onStartEditingProject:_e,onCancelEditingProject:we,onSaveProjectName:Ee=>{Ae(Ee)},onDeleteProject:L,onSessionSelect:se,onDeleteSession:Re,onLoadMoreSessions:Ee=>{ge(Ee)},onNewSession:o,onEditingSessionNameChange:Me,onStartEditingSession:(Ee,Ye)=>{Ne(Ee),Me(Ye)},onCancelEditingSession:()=>{Ne(null),Me("")},onSaveEditingSession:(Ee,Ye,it)=>{Fe(Ee,Ye,it)},onOpenProjectSettings:_,touchHandlerFactory:I,t:y};return e.jsxs(e.Fragment,{children:[W&&e.jsx(gd,{project:W,isOpen:!0,onClose:M}),e.jsx(xd,{projects:t,showSettings:p,settingsInitialTab:g,onCloseSettings:f,showNewProject:q,onCloseNewProject:()=>ne(!1),onProjectCreated:ye,deleteConfirmation:R,onCancelDeleteProject:()=>Oe(null),onConfirmDeleteProject:ee,sessionDeleteConfirmation:Z,onCancelDeleteSession:()=>Je(null),onConfirmDeleteSession:Ie,showVersionModal:G,onCloseVersionModal:()=>{ae(!1),P()},releaseInfo:A,currentVersion:k,latestVersion:v,t:y}),z?e.jsx($l,{onExpand:Ve,onShowSettings:h,updateAvailable:j,onShowVersionModal:()=>ae(!0),t:y}):e.jsx(e.Fragment,{children:e.jsx(zc,{isPWA:N,isMobile:x,isLoading:d,projects:t,searchFilter:F,onSearchFilterChange:Le,onClearSearchFilter:()=>Le(""),onRefresh:()=>{Pe()},isRefreshing:Y,onCreateProject:()=>ne(!0),onCollapseSidebar:ze,updateAvailable:j,releaseInfo:A,latestVersion:v,onShowVersionModal:()=>ae(!0),onShowSettings:h,projectListProps:$e,t:y})})]})}function hd(){const{isDarkMode:t,toggleDarkMode:r}=fa();return e.jsxs("button",{onClick:r,className:"relative inline-flex h-8 w-14 items-center rounded-full bg-gray-200 dark:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-900",role:"switch","aria-checked":t,"aria-label":"Toggle dark mode",children:[e.jsx("span",{className:"sr-only",children:"Toggle dark mode"}),e.jsx("span",{className:`${t?"translate-x-7":"translate-x-1"} inline-block h-6 w-6 transform rounded-full bg-white shadow-lg transition-transform duration-200 flex items-center justify-center`,children:t?e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-700",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"})}):e.jsx("svg",{className:"w-3.5 h-3.5 text-yellow-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"})})})]})}const fd=()=>{const{t}=Be("settings"),[r,s]=l.useState(!1),[a,n]=l.useState(()=>localStorage.getItem("whisperMode")||"default"),{isDarkMode:o}=fa(),{isMobile:i}=Ea({trackPWA:!1}),{preferences:c,setPreference:d}=Ta(),{autoExpandTools:u,showRawParameters:m,showThinking:h,autoScrollToBottom:p,sendByCtrlEnter:g}=c,[f,x]=l.useState(()=>{const M=localStorage.getItem("quickSettingsHandlePosition");if(M)try{return JSON.parse(M).y??50}catch{return localStorage.removeItem("quickSettingsHandlePosition"),50}return 50}),[y,N]=l.useState(!1),[j,v]=l.useState(0),[k,A]=l.useState(0),[P,S]=l.useState(!1),b=l.useRef(null),C=l.useRef({min:10,max:90}),E=5;l.useEffect(()=>{localStorage.setItem("quickSettingsHandlePosition",JSON.stringify({y:f}))},[f]);const B=l.useCallback(()=>i?{bottom:`${window.innerHeight*f/100}px`}:{top:`${f}%`,transform:"translateY(-50%)"},[f,i]),T=l.useCallback(M=>{M.stopPropagation();const z=M.type.includes("touch")?M.touches[0].clientY:M.clientY;v(z),A(f),S(!1),N(!1)},[f]),W=l.useCallback(M=>{if(j===0)return;const z=M.type.includes("touch")?M.touches[0].clientY:M.clientY,K=Math.abs(z-j);if(!y&&K>E&&(N(!0),S(!0),document.body.style.cursor="grabbing",document.body.style.userSelect="none",M.type.includes("touch")&&(document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%")),!y)return;M.type.includes("touch")&&M.preventDefault();const te=z-j;let q;i?q=-(te/window.innerHeight)*100:q=te/window.innerHeight*100;let ie=k+q;ie=Math.max(C.current.min,Math.min(C.current.max,ie)),x(ie)},[y,j,k,i,E]),H=l.useCallback(()=>{N(!1),v(0),document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]);l.useEffect(()=>()=>{document.body.style.cursor="",document.body.style.userSelect="",document.body.style.overflow="",document.body.style.position="",document.body.style.width=""},[]),l.useEffect(()=>{if(j!==0){const M=q=>W(q),z=()=>H(),K=q=>W(q),te=()=>H();return document.addEventListener("mousemove",M),document.addEventListener("mouseup",z),document.addEventListener("touchmove",K,{passive:!1}),document.addEventListener("touchend",te),()=>{document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",z),document.removeEventListener("touchmove",K),document.removeEventListener("touchend",te)}}},[j,W,H]);const _=M=>{if(P){M.preventDefault(),S(!1);return}s(z=>!z)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{ref:b,onClick:_,onMouseDown:M=>{T(M)},onTouchStart:M=>{T(M)},className:`fixed ${r?"right-64":"right-0"} z-50 ${y?"":"transition-all duration-150 ease-out"} bg-white dark:bg-gray-800 border ${y?"border-blue-500 dark:border-blue-400":"border-gray-200 dark:border-gray-700"} rounded-l-md p-2 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors shadow-lg ${y?"cursor-grabbing":"cursor-pointer"} touch-none`,style:{...B(),touchAction:"none",WebkitTouchCallout:"none",WebkitUserSelect:"none"},"aria-label":t(y?"quickSettings.dragHandle.dragging":r?"quickSettings.dragHandle.closePanel":"quickSettings.dragHandle.openPanel"),title:t(y?"quickSettings.dragHandle.draggingStatus":"quickSettings.dragHandle.toggleAndMove"),children:y?e.jsx(Ai,{className:"h-5 w-5 text-blue-500 dark:text-blue-400"}):r?e.jsx(sr,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}):e.jsx(va,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"})}),e.jsx("div",{className:`fixed top-0 right-0 h-full w-64 bg-background border-l border-border shadow-xl transform transition-transform duration-150 ease-out z-40 ${r?"translate-x-0":"translate-x-full"} ${i?"h-screen":""}`,children:e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:e.jsxs("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(Ii,{className:"h-5 w-5 text-gray-600 dark:text-gray-400"}),t("quickSettings.title")]})}),e.jsxs("div",{className:`flex-1 overflow-y-auto overflow-x-hidden p-4 space-y-6 bg-background ${i?"pb-mobile-nav":""}`,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:t("quickSettings.sections.appearance")}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[o?e.jsx(Zs,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}):e.jsx(ea,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.darkMode")]}),e.jsx(hd,{})]}),e.jsx("div",{children:e.jsx(Oo,{compact:!0})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:t("quickSettings.sections.toolDisplay")}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(ja,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.autoExpandTools")]}),e.jsx("input",{type:"checkbox",checked:u,onChange:M=>d("autoExpandTools",M.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(ar,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.showRawParameters")]}),e.jsx("input",{type:"checkbox",checked:m,onChange:M=>d("showRawParameters",M.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(ks,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.showThinking")]}),e.jsx("input",{type:"checkbox",checked:h,onChange:M=>d("showThinking",M.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:t("quickSettings.sections.viewOptions")}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(no,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.autoScrollToBottom")]}),e.jsx("input",{type:"checkbox",checked:p,onChange:M=>d("autoScrollToBottom",M.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:t("quickSettings.sections.inputSettings")}),e.jsxs("label",{className:"flex items-center justify-between p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm text-gray-900 dark:text-white",children:[e.jsx(ao,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.sendByCtrlEnter")]}),e.jsx("input",{type:"checkbox",checked:g,onChange:M=>d("sendByCtrlEnter",M.target.checked),className:"h-4 w-4 rounded border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 focus:ring-2 dark:focus:ring-blue-400 bg-gray-100 dark:bg-gray-800 checked:bg-blue-600 dark:checked:bg-blue-600"})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 ml-3",children:t("quickSettings.sendByCtrlEnterDescription")})]}),e.jsxs("div",{className:"space-y-2",style:{display:"none"},children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 mb-2",children:t("quickSettings.sections.whisperDictation")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsx("input",{type:"radio",name:"whisperMode",value:"default",checked:a==="default",onChange:()=>{n("default"),localStorage.setItem("whisperMode","default"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 dark:focus:ring-blue-400 dark:bg-gray-800 dark:checked:bg-blue-600"}),e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[e.jsx(os,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.whisper.modes.default")]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:t("quickSettings.whisper.modes.defaultDescription")})]})]}),e.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsx("input",{type:"radio",name:"whisperMode",value:"prompt",checked:a==="prompt",onChange:()=>{n("prompt"),localStorage.setItem("whisperMode","prompt"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 dark:focus:ring-blue-400 dark:bg-gray-800 dark:checked:bg-blue-600"}),e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[e.jsx(Ut,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.whisper.modes.prompt")]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:t("quickSettings.whisper.modes.promptDescription")})]})]}),e.jsxs("label",{className:"flex items-start p-3 rounded-lg bg-gray-50 dark:bg-gray-800 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer transition-colors border border-transparent hover:border-gray-300 dark:hover:border-gray-600",children:[e.jsx("input",{type:"radio",name:"whisperMode",value:"vibe",checked:a==="vibe"||a==="instructions"||a==="architect",onChange:()=>{n("vibe"),localStorage.setItem("whisperMode","vibe"),window.dispatchEvent(new Event("whisperModeChanged"))},className:"mt-0.5 h-4 w-4 border-gray-300 dark:border-gray-600 text-blue-600 dark:text-blue-500 focus:ring-blue-500 dark:focus:ring-blue-400 dark:bg-gray-800 dark:checked:bg-blue-600"}),e.jsxs("div",{className:"ml-3 flex-1",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-white",children:[e.jsx(ft,{className:"h-4 w-4 text-gray-600 dark:text-gray-400"}),t("quickSettings.whisper.modes.vibe")]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:t("quickSettings.whisper.modes.vibeDescription")})]})]})]})]})]})]})}),r&&e.jsx("div",{className:"fixed inset-0 bg-background/80 backdrop-blur-sm z-30 transition-opacity duration-150 ease-out",onClick:_})]})};function Tt(t){return t&&t.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&")}function bd(t){if(!t||typeof t!="string")return t;try{return t.replace(/```\s*([^\n\r]+?)\s*```/g,"`$1`")}catch{return t}}function Xr(t){if(!t||typeof t!="string")return t;const r=[],s="__MATH_BLOCK_",a="__";let n=t.replace(/\$\$([\s\S]*?)\$\$|\$([^\$\n]+?)\$/g,o=>{const i=r.length;return r.push(o),`${s}${i}${a}`});return n=n.replace(/\\n/g,`
36
+ `).replace(/\\t/g," ").replace(/\\r/g,"\r"),n=n.replace(new RegExp(`${s}(\\d+)${a}`,"g"),(o,i)=>r[parseInt(i,10)]),n}function Bo(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function sa(t){try{return typeof t!="string"?t:t.replace(/Claude AI usage limit reached\|(\d{10,13})/g,(r,s)=>{let a=parseInt(s,10);if(!Number.isFinite(a))return r;a<1e12&&(a*=1e3);const n=new Date(a),o=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}).format(n),i=-n.getTimezoneOffset(),c=i>=0?"+":"-",d=Math.abs(i),u=Math.floor(d/60),m=d%60,h=`GMT${c}${u}${m?":"+String(m).padStart(2,"0"):""}`,f=((Intl.DateTimeFormat().resolvedOptions().timeZone||"").split("/").pop()||"").replace(/_/g," ").toLowerCase().replace(/\b\w/g,j=>j.toUpperCase()),x=f?`${h} (${f})`:h,y=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],N=`${n.getDate()} ${y[n.getMonth()]} ${n.getFullYear()}`;return`Claude usage limit reached. Your limit will reset at **${o} ${x}** - ${N}`})}catch{return t}}const Wo=l.createContext(null),yd=Wo.Provider;function vd(){return l.useContext(Wo)}const kd=l.lazy(()=>Nt(()=>import("./MermaidBlock-Dq9uFv82.js"),__vite__mapDeps([0,1,2,3])));function wd(t){return`<!DOCTYPE html>
37
+ <html><head>
38
+ <meta charset="utf-8" />
39
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
40
+ <script src="https://cdn.jsdelivr.net/npm/react@18/umd/react.production.min.js"><\/script>
41
+ <script src="https://cdn.jsdelivr.net/npm/react-dom@18/umd/react-dom.production.min.js"><\/script>
42
+ <script src="https://cdn.jsdelivr.net/npm/@babel/standalone@7/babel.min.js"><\/script>
43
+ <script src="https://cdn.jsdelivr.net/npm/recharts@2/umd/Recharts.min.js"><\/script>
44
+ <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2/dist/tailwind.min.css" rel="stylesheet" />
45
+ <style>body{margin:0;padding:16px;font-family:system-ui,sans-serif;background:#fff;color:#111}
46
+ #root{min-height:100vh}</style>
47
+ </head><body><div id="root"></div>
48
+ <script type="text/babel">
49
+ const { useState, useEffect, useRef, useMemo, useCallback, Fragment } = React;
50
+ ${t}
51
+
52
+ // Try to find and render the default export or last component
53
+ const _components = [];
54
+ ${t.replace(/(?:export\s+default\s+)?(?:function|const)\s+([A-Z]\w*)/g,(r,s)=>`_components.push(typeof ${s} !== 'undefined' ? ${s} : null);`)}
55
+ const _App = _components.filter(Boolean).pop();
56
+ if (_App) {
57
+ ReactDOM.createRoot(document.getElementById('root')).render(React.createElement(_App));
58
+ } else {
59
+ document.getElementById('root').innerHTML = '<p style="color:#666">No component found to render</p>';
60
+ }
61
+ <\/script></body></html>`}const jd=new Set(["html","jsx","tsx","react"]);function Nd(t,r){return!!(jd.has(t)||t==="text"&&r.trim().startsWith("<!DOCTYPE")||r.trim().startsWith("<html"))}function ln(t,r){return t==="jsx"||t==="tsx"||t==="react"?wd(r):r.trim().toLowerCase().startsWith("<!doctype")||r.trim().toLowerCase().startsWith("<html")?r:`<!DOCTYPE html><html><head>
62
+ <meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />
63
+ <style>body{margin:0;padding:16px;font-family:system-ui,sans-serif}</style>
64
+ </head><body>${r}</body></html>`}const Cd=({node:t,inline:r,className:s,children:a,...n})=>{const{t:o}=Be("chat"),[i,c]=l.useState(!1),[d,u]=l.useState("code"),m=vd(),h=Array.isArray(a)?a.join(""):String(a??""),p=/[\r\n]/.test(h);if(r||t&&t.type==="inlineCode"||!p)return e.jsx("code",{className:`font-mono text-[0.9em] px-1.5 py-0.5 rounded-md bg-gray-100 text-gray-900 border border-gray-200 dark:bg-gray-800/60 dark:text-gray-100 dark:border-gray-700 whitespace-pre-wrap break-words ${s||""}`,...n,children:a});const x=/language-(\w+)/.exec(s||""),y=x?x[1]:"text",N=Nd(y,h);if(y==="mermaid")return e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"my-2 p-4 rounded-lg bg-slate-900/50 border border-slate-700 text-sm text-slate-500",children:"Loading diagram..."}),children:e.jsx(kd,{code:h})});const j=h,v=()=>{const A=()=>{c(!0),setTimeout(()=>c(!1),1500)};try{if(navigator&&navigator.clipboard&&navigator.clipboard.writeText)navigator.clipboard.writeText(j).then(A).catch(()=>{const P=document.createElement("textarea");P.value=j,P.style.position="fixed",P.style.opacity="0",document.body.appendChild(P),P.select();try{document.execCommand("copy")}catch{}document.body.removeChild(P),A()});else{const P=document.createElement("textarea");P.value=j,P.style.position="fixed",P.style.opacity="0",document.body.appendChild(P),P.select();try{document.execCommand("copy")}catch{}document.body.removeChild(P),A()}}catch{}},k=()=>{m&&m({id:`html-preview-${Date.now()}`,type:"html",title:y==="html"?"HTML Preview":"React Preview",data:{html:ln(y,h)}})};return e.jsxs("div",{className:"relative group my-2",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800 rounded-t-lg border-b border-gray-700/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[y&&y!=="text"&&e.jsx("span",{className:"text-xs text-gray-400 font-medium uppercase",children:y}),N&&e.jsxs("div",{className:"flex items-center rounded-md bg-gray-700/50 p-0.5",children:[e.jsx("button",{type:"button",onClick:()=>u("code"),className:`text-[10px] px-2 py-0.5 rounded transition-colors ${d==="code"?"bg-gray-600 text-white":"text-gray-400 hover:text-gray-200"}`,children:"Code"}),e.jsx("button",{type:"button",onClick:()=>u("preview"),className:`text-[10px] px-2 py-0.5 rounded transition-colors ${d==="preview"?"bg-blue-600 text-white":"text-gray-400 hover:text-gray-200"}`,children:"Preview"})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[N&&m&&e.jsx("button",{type:"button",onClick:k,className:"opacity-0 group-hover:opacity-100 transition-opacity text-xs px-1.5 py-0.5 rounded-md bg-gray-700/80 hover:bg-gray-700 text-gray-300 border border-gray-600",title:"Open in side panel",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})}),e.jsx("button",{type:"button",onClick:v,className:"opacity-0 group-hover:opacity-100 focus:opacity-100 active:opacity-100 transition-opacity text-xs px-2 py-0.5 rounded-md bg-gray-700/80 hover:bg-gray-700 text-white border border-gray-600",title:o(i?"codeBlock.copied":"codeBlock.copyCode"),"aria-label":o(i?"codeBlock.copied":"codeBlock.copyCode"),children:i?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),o("codeBlock.copied")]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),o("codeBlock.copy")]})})]})]}),d==="code"&&e.jsx(xo,{language:y,style:go,customStyle:{margin:0,borderRadius:"0 0 0.5rem 0.5rem",fontSize:"0.875rem",padding:"1rem"},codeTagProps:{style:{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'}},children:h}),d==="preview"&&N&&e.jsx("div",{className:"bg-white rounded-b-lg overflow-hidden border border-gray-700 border-t-0",children:e.jsx("iframe",{srcDoc:ln(y,h),sandbox:"allow-scripts allow-same-origin",className:"w-full border-0",style:{minHeight:"200px",height:"400px"},title:"Code preview"})})]})},Sd={code:Cd,blockquote:({children:t})=>e.jsx("blockquote",{className:"border-l-4 border-gray-300 dark:border-gray-600 pl-4 italic text-gray-600 dark:text-gray-400 my-2",children:t}),a:({href:t,children:r})=>e.jsx("a",{href:t,className:"text-blue-600 dark:text-blue-400 hover:underline",target:"_blank",rel:"noopener noreferrer",children:r}),p:({children:t})=>e.jsx("div",{className:"mb-2 last:mb-0",children:t}),table:({children:t})=>e.jsx("div",{className:"overflow-x-auto my-2",children:e.jsx("table",{className:"min-w-full border-collapse border border-gray-200 dark:border-gray-700",children:t})}),thead:({children:t})=>e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-800",children:t}),th:({children:t})=>e.jsx("th",{className:"px-3 py-2 text-left text-sm font-semibold border border-gray-200 dark:border-gray-700",children:t}),td:({children:t})=>e.jsx("td",{className:"px-3 py-2 align-top text-sm border border-gray-200 dark:border-gray-700",children:t})};function Qt({children:t,className:r}){const s=bd(String(t??"")),a=l.useMemo(()=>[Qi,Xi],[]),n=l.useMemo(()=>[Zi],[]);return e.jsx("div",{className:r,children:e.jsx(el,{remarkPlugins:a,rehypePlugins:n,components:Sd,children:s})})}const Uo="claude-settings",ot={setItem:(t,r)=>{try{if(t.startsWith("chat_messages_")&&typeof r=="string")try{const s=JSON.parse(r);if(Array.isArray(s)&&s.length>50){const a=s.slice(-50);r=JSON.stringify(a)}}catch(s){console.warn("Could not parse chat messages for truncation:",s)}localStorage.setItem(t,r)}catch(s){if((s==null?void 0:s.name)==="QuotaExceededError"){console.warn("localStorage quota exceeded, clearing old data");const a=Object.keys(localStorage),n=a.filter(i=>i.startsWith("chat_messages_")).sort();n.length>3&&n.slice(0,n.length-3).forEach(i=>{localStorage.removeItem(i)}),a.filter(i=>i.startsWith("draft_input_")).forEach(i=>{localStorage.removeItem(i)});try{localStorage.setItem(t,r)}catch(i){if(console.error("Failed to save to localStorage even after cleanup:",i),t.startsWith("chat_messages_")&&typeof r=="string")try{const c=JSON.parse(r);if(Array.isArray(c)&&c.length>10){const d=c.slice(-10);localStorage.setItem(t,JSON.stringify(d))}}catch(c){console.error("Final save attempt failed:",c)}}}else console.error("localStorage error:",s)}},getItem:t=>{try{return localStorage.getItem(t)}catch(r){return console.error("localStorage getItem error:",r),null}},removeItem:t=>{try{localStorage.removeItem(t)}catch(r){console.error("localStorage removeItem error:",r)}}};function Da(){const t=ot.getItem(Uo);if(!t)return{allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"};try{const r=JSON.parse(t);return{...r,allowedTools:Array.isArray(r.allowedTools)?r.allowedTools:[],disallowedTools:Array.isArray(r.disallowedTools)?r.disallowedTools:[],skipPermissions:!!r.skipPermissions,projectSortOrder:r.projectSortOrder||"name"}}catch{return{allowedTools:[],disallowedTools:[],skipPermissions:!1,projectSortOrder:"name"}}}function aa(t,r){if(!t)return null;if(t!=="Bash")return t;const s=Cc(r),a=typeof(s==null?void 0:s.command)=="string"?s.command.trim():"";if(!a)return t;const n=a.split(/\s+/);return n.length===0?t:n[0]==="git"&&n[1]?`Bash(${n[0]} ${n[1]}:*)`:`Bash(${n[0]}:*)`}function cn(t){if(t==null)return"";if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}}function Ed(t,r){var i;if(r!=="claude"||!((i=t==null?void 0:t.toolResult)!=null&&i.isError))return null;const s=t==null?void 0:t.toolName,a=aa(s,t.toolInput);if(!a)return null;const o=Da().allowedTools.includes(a);return{toolName:s||"UnknownTool",entry:a,isAllowed:o}}function Td(t){if(!t)return{success:!1};const r=Da(),s=r.allowedTools.includes(t),a=s?r.allowedTools:[...r.allowedTools,t],n=r.disallowedTools.filter(i=>i!==t),o={...r,allowedTools:a,disallowedTools:n,lastUpdated:new Date().toISOString()};return ot.setItem(Uo,JSON.stringify(o)),{success:!0,alreadyAllowed:s,updatedSettings:o}}const dn={Bash:{input:{type:"one-line",icon:"terminal",getValue:t=>t.command,getSecondary:t=>t.description,action:"copy",style:"terminal",wrapText:!0,colorScheme:{primary:"text-green-400 font-mono",secondary:"text-gray-400",background:"",border:"border-green-500 dark:border-green-400",icon:"text-green-500 dark:text-green-400"}},result:{hideOnSuccess:!0,type:"special"}},Read:{input:{type:"one-line",label:"Read",getValue:t=>t.file_path||"",action:"open-file",colorScheme:{primary:"text-gray-700 dark:text-gray-300",background:"",border:"border-gray-300 dark:border-gray-600",icon:"text-gray-500 dark:text-gray-400"}},result:{hidden:!0}},Edit:{input:{type:"collapsible",title:t=>{var s;return`${((s=t.file_path)==null?void 0:s.split("/").pop())||t.file_path||"file"}`},defaultOpen:!1,contentType:"diff",actionButton:"none",getContentProps:t=>({oldContent:t.old_string,newContent:t.new_string,filePath:t.file_path,badge:"Edit",badgeColor:"gray"})},result:{hideOnSuccess:!0}},Write:{input:{type:"collapsible",title:t=>{var s;return`${((s=t.file_path)==null?void 0:s.split("/").pop())||t.file_path||"file"}`},defaultOpen:!1,contentType:"diff",actionButton:"none",getContentProps:t=>({oldContent:"",newContent:t.content,filePath:t.file_path,badge:"New",badgeColor:"green"})},result:{hideOnSuccess:!0}},ApplyPatch:{input:{type:"collapsible",title:t=>{var s;return`${((s=t.file_path)==null?void 0:s.split("/").pop())||t.file_path||"file"}`},defaultOpen:!1,contentType:"diff",actionButton:"none",getContentProps:t=>({oldContent:t.old_string,newContent:t.new_string,filePath:t.file_path,badge:"Patch",badgeColor:"gray"})},result:{hideOnSuccess:!0}},Grep:{input:{type:"one-line",label:"Grep",getValue:t=>t.pattern,getSecondary:t=>t.path?`in ${t.path}`:void 0,action:"jump-to-results",colorScheme:{primary:"text-gray-700 dark:text-gray-300",secondary:"text-gray-500 dark:text-gray-400",background:"",border:"border-gray-400 dark:border-gray-500",icon:"text-gray-500 dark:text-gray-400"}},result:{type:"collapsible",defaultOpen:!1,title:t=>{var a;const r=t.toolUseResult||{},s=r.numFiles||((a=r.filenames)==null?void 0:a.length)||0;return`Found ${s} ${s===1?"file":"files"}`},contentType:"file-list",getContentProps:t=>({files:(t.toolUseResult||{}).filenames||[]})}},Glob:{input:{type:"one-line",label:"Glob",getValue:t=>t.pattern,getSecondary:t=>t.path?`in ${t.path}`:void 0,action:"jump-to-results",colorScheme:{primary:"text-gray-700 dark:text-gray-300",secondary:"text-gray-500 dark:text-gray-400",background:"",border:"border-gray-400 dark:border-gray-500",icon:"text-gray-500 dark:text-gray-400"}},result:{type:"collapsible",defaultOpen:!1,title:t=>{var a;const r=t.toolUseResult||{},s=r.numFiles||((a=r.filenames)==null?void 0:a.length)||0;return`Found ${s} ${s===1?"file":"files"}`},contentType:"file-list",getContentProps:t=>({files:(t.toolUseResult||{}).filenames||[]})}},TodoWrite:{input:{type:"collapsible",title:"Updating todo list",defaultOpen:!1,contentType:"todo-list",getContentProps:t=>({todos:t.todos})},result:{type:"collapsible",contentType:"success-message",getMessage:()=>"Todo list updated"}},TodoRead:{input:{type:"one-line",label:"TodoRead",getValue:()=>"reading list",action:"none",colorScheme:{primary:"text-gray-500 dark:text-gray-400",border:"border-violet-400 dark:border-violet-500"}},result:{type:"collapsible",contentType:"todo-list",getContentProps:t=>{try{const r=String(t.content||"");let s=null;return r.startsWith("[")&&(s=JSON.parse(r)),{todos:s,isResult:!0}}catch{return{todos:[],isResult:!0}}}}},TaskCreate:{input:{type:"one-line",label:"Task",getValue:t=>t.subject||"Creating task",getSecondary:t=>t.status||void 0,action:"none",colorScheme:{primary:"text-gray-700 dark:text-gray-300",border:"border-violet-400 dark:border-violet-500",icon:"text-violet-500 dark:text-violet-400"}},result:{hideOnSuccess:!0}},TaskUpdate:{input:{type:"one-line",label:"Task",getValue:t=>{const r=[];return t.taskId&&r.push(`#${t.taskId}`),t.status&&r.push(t.status),t.subject&&r.push(`"${t.subject}"`),r.join(" → ")||"updating"},action:"none",colorScheme:{primary:"text-gray-700 dark:text-gray-300",border:"border-violet-400 dark:border-violet-500",icon:"text-violet-500 dark:text-violet-400"}},result:{hideOnSuccess:!0}},TaskList:{input:{type:"one-line",label:"Tasks",getValue:()=>"listing tasks",action:"none",colorScheme:{primary:"text-gray-500 dark:text-gray-400",border:"border-violet-400 dark:border-violet-500",icon:"text-violet-500 dark:text-violet-400"}},result:{type:"collapsible",defaultOpen:!0,title:"Task list",contentType:"task",getContentProps:t=>({content:String((t==null?void 0:t.content)||"")})}},TaskGet:{input:{type:"one-line",label:"Task",getValue:t=>t.taskId?`#${t.taskId}`:"fetching",action:"none",colorScheme:{primary:"text-gray-700 dark:text-gray-300",border:"border-violet-400 dark:border-violet-500",icon:"text-violet-500 dark:text-violet-400"}},result:{type:"collapsible",defaultOpen:!0,title:"Task details",contentType:"task",getContentProps:t=>({content:String((t==null?void 0:t.content)||"")})}},Task:{input:{type:"collapsible",title:t=>{const r=t.subagent_type||"Agent",s=t.description||"Running task";return`Subagent / ${r}: ${s}`},defaultOpen:!1,contentType:"markdown",getContentProps:t=>{if(t.prompt&&!t.model&&!t.resume)return{content:t.prompt||""};const s=[];return t.model&&s.push(`**Model:** ${t.model}`),t.prompt&&s.push(`**Prompt:**
65
+ ${t.prompt}`),t.resume&&s.push(`**Resuming from:** ${t.resume}`),{content:s.join(`
66
+
67
+ `)}},colorScheme:{border:"border-purple-500 dark:border-purple-400",icon:"text-purple-500 dark:text-purple-400"}},result:{type:"collapsible",title:"Subagent result",defaultOpen:!1,contentType:"markdown",getContentProps:t=>{if(t&&t.content){let r=t.content;if(typeof r=="string")try{const s=JSON.parse(r);Array.isArray(s)&&(r=s)}catch{return{content:r}}return Array.isArray(r)?{content:r.filter(a=>a.type==="text").map(a=>a.text).join(`
68
+
69
+ `)||"No response text"}:{content:String(r)}}return{content:String(t||"No response")}}}},AskUserQuestion:{input:{type:"collapsible",title:t=>{var a,n;const r=((a=t.questions)==null?void 0:a.length)||0,s=t.answers&&Object.keys(t.answers).length>0;if(r===1){const o=((n=t.questions[0])==null?void 0:n.header)||"Question";return s?`${o} — answered`:o}return s?`${r} questions — answered`:`${r} questions`},defaultOpen:!0,contentType:"question-answer",getContentProps:t=>({questions:t.questions||[],answers:t.answers||{}})},result:{hideOnSuccess:!0}},exit_plan_mode:{input:{type:"collapsible",title:"Implementation plan",defaultOpen:!0,contentType:"markdown",getContentProps:t=>{var r;return{content:((r=t.plan)==null?void 0:r.replace(/\\n/g,`
70
+ `))||t.plan}}},result:{type:"collapsible",contentType:"markdown",getContentProps:t=>{var r;try{let s=t.content;return typeof s=="string"&&(s=JSON.parse(s)),{content:((r=s.plan)==null?void 0:r.replace(/\\n/g,`
71
+ `))||s.plan}}catch{return{content:""}}}}},ExitPlanMode:{input:{type:"collapsible",title:"Implementation plan",defaultOpen:!0,contentType:"markdown",getContentProps:t=>{var r;return{content:((r=t.plan)==null?void 0:r.replace(/\\n/g,`
72
+ `))||t.plan}}},result:{type:"collapsible",contentType:"markdown",getContentProps:t=>{var r;try{let s=t.content;return typeof s=="string"&&(s=JSON.parse(s)),{content:((r=s.plan)==null?void 0:r.replace(/\\n/g,`
73
+ `))||s.plan}}catch{return{content:""}}}}},Default:{input:{type:"collapsible",title:"Parameters",defaultOpen:!1,contentType:"text",getContentProps:t=>({content:typeof t=="string"?t:JSON.stringify(t,null,2),format:"code"})},result:{type:"collapsible",contentType:"text",getContentProps:t=>({content:String((t==null?void 0:t.content)||""),format:"plain"})}}};function Ho(t){return dn[t]||dn.Default}function Ad(t,r){const s=Ho(t);return s.result?!!(s.result.hidden||s.result.hideOnSuccess&&r&&!r.isError):!1}const Go=({title:t,toolName:r,open:s=!1,action:a,onTitleClick:n,children:o,className:i=""})=>e.jsxs("details",{className:`relative group/details ${i}`,open:s,children:[e.jsxs("summary",{className:"flex items-center gap-1.5 text-xs cursor-pointer py-0.5 select-none group-open/details:sticky group-open/details:top-0 group-open/details:z-10 group-open/details:bg-background group-open/details:-mx-1 group-open/details:px-1",children:[e.jsx("svg",{className:"w-3 h-3 text-gray-400 dark:text-gray-500 transition-transform duration-150 group-open/details:rotate-90 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),r&&e.jsx("span",{className:"font-medium text-gray-500 dark:text-gray-400 flex-shrink-0",children:r}),r&&e.jsx("span",{className:"text-gray-300 dark:text-gray-600 text-[10px] flex-shrink-0",children:"/"}),n?e.jsx("button",{onClick:c=>{c.preventDefault(),c.stopPropagation(),n()},className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-mono hover:underline truncate flex-1 text-left transition-colors",children:t}):e.jsx("span",{className:"text-gray-600 dark:text-gray-400 truncate flex-1",children:t}),a&&e.jsx("span",{className:"flex-shrink-0 ml-1",children:a})]}),e.jsx("div",{className:"mt-1.5 pl-[18px]",children:o})]}),Id=l.lazy(()=>Nt(()=>import("./vendor-diff-THJmAcEI.js"),__vite__mapDeps([4,2]))),Md={variables:{dark:{diffViewerBackground:"#0f172a",diffViewerColor:"#e2e8f0",addedBackground:"#064e3b20",addedColor:"#6ee7b7",removedBackground:"#7f1d1d20",removedColor:"#fca5a5",wordAddedBackground:"#065f4630",wordRemovedBackground:"#991b1b30",addedGutterBackground:"#064e3b30",removedGutterBackground:"#7f1d1d30",gutterBackground:"#0f172a",gutterBackgroundDark:"#0f172a",highlightBackground:"#1e293b",highlightGutterBackground:"#1e293b",codeFoldGutterBackground:"#1e293b",codeFoldBackground:"#1e293b",emptyLineBackground:"#0f172a",gutterColor:"#475569",addedGutterColor:"#6ee7b7",removedGutterColor:"#fca5a5",codeFoldContentColor:"#94a3b8",diffViewerTitleBackground:"#1e293b",diffViewerTitleColor:"#e2e8f0",diffViewerTitleBorderColor:"#334155"}},line:{padding:"2px 8px",fontSize:"12px",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace"},gutter:{padding:"2px 8px",fontSize:"11px",minWidth:"36px"},contentText:{fontSize:"12px",lineHeight:"20px"}},Dd=({oldContent:t,newContent:r,filePath:s,createDiff:a,onFileClick:n,badge:o="Diff",badgeColor:i="gray"})=>{const[c,d]=l.useState(!1),[u,m]=l.useState(!1),h=i==="green"?"bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400":"bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400",p=l.useMemo(()=>{const f=a(t,r),x=f.filter(N=>N.type==="added").length,y=f.filter(N=>N.type==="removed").length;return{added:x,removed:y}},[a,t,r]),g=()=>{navigator.clipboard.writeText(r).then(()=>{m(!0),setTimeout(()=>m(!1),1500)}).catch(()=>{})};return e.jsxs("div",{className:"border border-gray-200/60 dark:border-gray-700/50 rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5 bg-gray-50/80 dark:bg-gray-800/40 border-b border-gray-200/60 dark:border-gray-700/50",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[n?e.jsx("button",{onClick:n,className:"text-[11px] font-mono text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 truncate cursor-pointer transition-colors",children:s}):e.jsx("span",{className:"text-[11px] font-mono text-gray-600 dark:text-gray-400 truncate",children:s}),e.jsx("span",{className:`text-[10px] font-medium px-1.5 py-px rounded ${h} flex-shrink-0`,children:o}),p.added>0&&e.jsxs("span",{className:"text-[10px] text-green-600 dark:text-green-400 font-mono flex-shrink-0",children:["+",p.added]}),p.removed>0&&e.jsxs("span",{className:"text-[10px] text-red-600 dark:text-red-400 font-mono flex-shrink-0",children:["-",p.removed]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0 ml-2",children:[e.jsx("button",{onClick:()=>d(!c),className:"text-[10px] px-1.5 py-0.5 rounded border border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",title:c?"Unified view":"Split view",children:c?"Unified":"Split"}),e.jsx("button",{onClick:g,className:"text-[10px] px-1.5 py-0.5 rounded border border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",title:"Copy new content",children:u?"Copied":"Copy"})]})]}),e.jsx("div",{className:"max-h-[500px] overflow-auto",children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"p-4 text-xs text-gray-500 dark:text-gray-400",children:"Loading diff viewer..."}),children:e.jsx(Id,{oldValue:t,newValue:r,splitView:c,useDarkTheme:!0,styles:Md,hideLineNumbers:!1,showDiffOnly:!0,extraLinesSurroundingDiff:3})})})]})},Ld=t=>{if(typeof document>"u"||!document.body)return!1;const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.opacity="0",r.style.left="-9999px",document.body.appendChild(r),r.select(),r.setSelectionRange(0,t.length);let s=!1;try{s=document.execCommand("copy")}catch{s=!1}finally{document.body.removeChild(r)}return s},Pd=async t=>{var r;if(typeof navigator<"u"&&typeof window<"u"&&window.isSecureContext&&((r=navigator.clipboard)!=null&&r.writeText))try{return await navigator.clipboard.writeText(t),!0}catch{}return Ld(t)},$d=({toolName:t,icon:r,label:s,value:a,secondary:n,action:o="none",onAction:i,style:c,wrapText:d=!1,colorScheme:u={primary:"text-gray-700 dark:text-gray-300",secondary:"text-gray-500 dark:text-gray-400",background:"",border:"border-gray-300 dark:border-gray-600",icon:"text-gray-500 dark:text-gray-400"},resultId:m,toolResult:h,toolId:p})=>{const[g,f]=l.useState(!1),x=c==="terminal",y=async()=>{if(o==="copy"&&a){if(!await Pd(a))return;f(!0),setTimeout(()=>f(!1),2e3)}else i&&i()},N=()=>e.jsx("button",{onClick:y,className:"opacity-0 group-hover:opacity-100 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 transition-all ml-1 flex-shrink-0",title:"Copy to clipboard","aria-label":"Copy to clipboard",children:g?e.jsx("svg",{className:"w-3 h-3 text-green-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})});if(x)return e.jsxs("div",{className:"group my-1",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("div",{className:"flex items-center gap-1.5 flex-shrink-0 pt-0.5",children:e.jsx("svg",{className:"w-3 h-3 text-green-500 dark:text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),e.jsxs("div",{className:"flex-1 min-w-0 flex items-start gap-2",children:[e.jsx("div",{className:"bg-gray-900 dark:bg-black rounded px-2.5 py-1 flex-1 min-w-0",children:e.jsxs("code",{className:`text-xs text-green-400 font-mono ${d?"whitespace-pre-wrap break-all":"block truncate"}`,children:[e.jsx("span",{className:"text-green-600 dark:text-green-500 select-none",children:"$ "}),a]})}),o==="copy"&&N()]})]}),n&&e.jsx("div",{className:"ml-7 mt-1",children:e.jsx("span",{className:"text-[11px] text-gray-400 dark:text-gray-500 italic",children:n})})]});if(o==="open-file"){const j=a.split("/").pop()||a;return e.jsxs("div",{className:`group flex items-center gap-1.5 border-l-2 ${u.border} pl-3 py-0.5 my-0.5`,children:[e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0",children:s||t}),e.jsx("span",{className:"text-gray-300 dark:text-gray-600 text-[10px]",children:"/"}),e.jsx("button",{onClick:y,className:"text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-mono hover:underline transition-colors truncate",title:a,children:j})]})}return o==="jump-to-results"?e.jsxs("div",{className:`group flex items-center gap-1.5 border-l-2 ${u.border} pl-3 py-0.5 my-0.5`,children:[e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0",children:s||t}),e.jsx("span",{className:"text-gray-300 dark:text-gray-600 text-[10px]",children:"/"}),e.jsx("span",{className:`text-xs font-mono truncate flex-1 min-w-0 ${u.primary}`,children:a}),n&&e.jsx("span",{className:"text-[11px] text-gray-400 dark:text-gray-500 italic flex-shrink-0",children:n}),h&&e.jsx("a",{href:`#tool-result-${p}`,className:"flex-shrink-0 text-[11px] text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 transition-colors flex items-center gap-0.5",children:e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})})]}):e.jsxs("div",{className:`group flex items-center gap-1.5 ${u.background||""} border-l-2 ${u.border} pl-3 py-0.5 my-0.5`,children:[r&&r!=="terminal"&&e.jsx("span",{className:`${u.icon} flex-shrink-0 text-xs`,children:r}),!r&&(s||t)&&e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 flex-shrink-0",children:s||t}),(r||s||t)&&e.jsx("span",{className:"text-gray-300 dark:text-gray-600 text-[10px]",children:"/"}),e.jsx("span",{className:`text-xs font-mono ${d?"whitespace-pre-wrap break-all":"truncate"} flex-1 min-w-0 ${u.primary}`,children:a}),n&&e.jsx("span",{className:`text-[11px] ${u.secondary} italic flex-shrink-0`,children:n}),o==="copy"&&N()]})},un={edit:"border-l-amber-500 dark:border-l-amber-400",search:"border-l-gray-400 dark:border-l-gray-500",bash:"border-l-green-500 dark:border-l-green-400",todo:"border-l-violet-500 dark:border-l-violet-400",task:"border-l-violet-500 dark:border-l-violet-400",agent:"border-l-purple-500 dark:border-l-purple-400",plan:"border-l-indigo-500 dark:border-l-indigo-400",question:"border-l-blue-500 dark:border-l-blue-400",default:"border-l-gray-300 dark:border-l-gray-600"},_d=({toolName:t,title:r,defaultOpen:s=!1,action:a,onTitleClick:n,children:o,showRawParameters:i=!1,rawContent:c,className:d="",toolCategory:u})=>{const m=un[u||"default"]||un.default;return e.jsx("div",{className:`border-l-2 ${m} pl-3 py-0.5 my-1 ${d}`,children:e.jsxs(Go,{title:r,toolName:t,open:s,action:a,onTitleClick:n,children:[o,i&&c&&e.jsxs("details",{className:"relative mt-2 group/raw",children:[e.jsxs("summary",{className:"flex items-center gap-1.5 text-[11px] text-gray-400 dark:text-gray-500 cursor-pointer hover:text-gray-600 dark:hover:text-gray-300 py-0.5",children:[e.jsx("svg",{className:"w-2.5 h-2.5 transition-transform duration-150 group-open/raw:rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),"raw params"]}),e.jsx("pre",{className:"mt-1 text-[11px] bg-gray-50 dark:bg-gray-900/50 border border-gray-200/40 dark:border-gray-700/40 p-2 rounded whitespace-pre-wrap break-words overflow-hidden text-gray-600 dark:text-gray-400 font-mono",children:c})]})]})})},Zr=(t,r)=>{var a;const s=typeof r=="string"?(()=>{try{return JSON.parse(r)}catch{return{}}})():r||{};switch(t){case"Read":case"Write":case"Edit":case"ApplyPatch":return((a=s.file_path)==null?void 0:a.split("/").pop())||s.file_path||"";case"Grep":case"Glob":return s.pattern||"";case"Bash":const n=s.command||"";return n.length>40?`${n.slice(0,40)}...`:n;case"Task":return s.description||s.subagent_type||"";case"WebFetch":case"WebSearch":return s.url||s.query||"";default:return""}},Fd=({toolInput:t,toolResult:r,subagentState:s})=>{const a=typeof t=="string"?(()=>{try{return JSON.parse(t)}catch{return{}}})():t||{},n=(a==null?void 0:a.subagent_type)||"Agent",o=(a==null?void 0:a.description)||"Running task",i=(a==null?void 0:a.prompt)||"",{childTools:c,currentToolIndex:d,isComplete:u}=s,m=d>=0?c[d]:null,h=`Subagent / ${n}: ${o}`;return e.jsx("div",{className:"border-l-2 border-l-purple-500 dark:border-l-purple-400 pl-3 py-0.5 my-1",children:e.jsxs(Go,{title:h,toolName:"Task",open:!1,children:[i&&e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400 mb-2 whitespace-pre-wrap break-words line-clamp-4",children:i}),m&&!u&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400 mt-1",children:[e.jsx("span",{className:"animate-pulse w-1.5 h-1.5 rounded-full bg-purple-500 dark:bg-purple-400 flex-shrink-0"}),e.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:"Currently:"}),e.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:m.toolName}),Zr(m.toolName,m.toolInput)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"/"}),e.jsx("span",{className:"font-mono truncate text-gray-500 dark:text-gray-400",children:Zr(m.toolName,m.toolInput)})]})]}),u&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400 mt-1",children:[e.jsx("svg",{className:"w-3 h-3 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsxs("span",{children:["Completed (",c.length," ",c.length===1?"tool":"tools",")"]})]}),c.length>0&&e.jsxs("details",{className:"mt-2 group/history",children:[e.jsxs("summary",{className:"cursor-pointer text-[11px] text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 flex items-center gap-1",children:[e.jsx("svg",{className:"w-2.5 h-2.5 transition-transform duration-150 group-open/history:rotate-90 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),e.jsxs("span",{children:["View tool history (",c.length,")"]})]}),e.jsx("div",{className:"mt-1 pl-3 border-l border-gray-200 dark:border-gray-700 space-y-0.5",children:c.map((p,g)=>{var f;return e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400",children:[e.jsxs("span",{className:"text-gray-400 dark:text-gray-500 w-4 text-right flex-shrink-0",children:[g+1,"."]}),e.jsx("span",{className:"font-medium",children:p.toolName}),Zr(p.toolName,p.toolInput)&&e.jsx("span",{className:"font-mono truncate text-gray-400 dark:text-gray-500",children:Zr(p.toolName,p.toolInput)}),((f=p.toolResult)==null?void 0:f.isError)&&e.jsx("span",{className:"text-red-500 flex-shrink-0",children:"(error)"})]},p.toolId)})})]}),u&&r&&e.jsx("div",{className:"mt-2 text-xs text-gray-600 dark:text-gray-400",children:(()=>{let p=r.content;if(typeof p=="string")try{const g=JSON.parse(p);if(Array.isArray(g)){const f=g.filter(x=>x.type==="text"&&x.text).map(x=>x.text);f.length>0&&(p=f.join(`
74
+ `))}}catch{}else if(Array.isArray(p)){const g=p.filter(f=>f.type==="text"&&f.text).map(f=>f.text);g.length>0&&(p=g.join(`
75
+ `))}return typeof p=="string"?e.jsx("div",{className:"whitespace-pre-wrap break-words line-clamp-6",children:p}):p?e.jsx("pre",{className:"whitespace-pre-wrap break-words line-clamp-6 font-mono text-[11px]",children:JSON.stringify(p,null,2)}):null})()})]})})},zd=({content:t,className:r="mt-1 prose prose-sm max-w-none dark:prose-invert"})=>e.jsx(Qt,{className:r,children:t}),Rd=({files:t,onFileClick:r,title:s})=>e.jsxs("div",{children:[s&&e.jsx("div",{className:"text-[11px] text-gray-500 dark:text-gray-400 mb-1",children:s}),e.jsx("div",{className:"flex flex-wrap gap-x-1 gap-y-0.5 max-h-48 overflow-y-auto",children:t.map((a,n)=>{const o=typeof a=="string"?a:a.path,i=o.split("/").pop()||o,c=typeof a=="string"?()=>r==null?void 0:r(a):a.onClick;return e.jsxs("span",{className:"inline-flex items-center",children:[e.jsx("button",{onClick:c,className:"text-[11px] font-mono text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:underline transition-colors",title:o,children:i}),n<t.length-1&&e.jsx("span",{className:"text-gray-300 dark:text-gray-600 text-[10px] ml-1",children:","})]},n)})})]}),Od=({todos:t,isResult:r=!1})=>{if(!t||!Array.isArray(t))return null;const s=o=>{switch(o){case"completed":return e.jsx(Mi,{className:"w-3.5 h-3.5 text-green-500 dark:text-green-400"});case"in_progress":return e.jsx(Dr,{className:"w-3.5 h-3.5 text-blue-500 dark:text-blue-400"});case"pending":default:return e.jsx(ur,{className:"w-3.5 h-3.5 text-gray-400 dark:text-gray-500"})}},a=o=>{switch(o){case"completed":return"bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-200 border-green-200 dark:border-green-800";case"in_progress":return"bg-blue-100 dark:bg-blue-900/30 text-blue-800 dark:text-blue-200 border-blue-200 dark:border-blue-800";case"pending":default:return"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700"}},n=o=>{switch(o){case"high":return"bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-300 border-red-200 dark:border-red-800";case"medium":return"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-300 border-yellow-200 dark:border-yellow-800";case"low":default:return"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700"}};return e.jsxs("div",{className:"space-y-1.5",children:[r&&e.jsxs("div",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-1.5",children:["Todo List (",t.length," ",t.length===1?"item":"items",")"]}),t.map((o,i)=>e.jsxs("div",{className:"flex items-start gap-2 p-2 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded transition-colors",children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:s(o.status)}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-0.5",children:[e.jsx("p",{className:`text-xs font-medium ${o.status==="completed"?"line-through text-gray-500 dark:text-gray-400":"text-gray-900 dark:text-gray-100"}`,children:o.content}),e.jsxs("div",{className:"flex gap-1 flex-shrink-0",children:[e.jsx(kt,{variant:"outline",className:`text-[10px] px-1.5 py-px ${n(o.priority)}`,children:o.priority}),e.jsx(kt,{variant:"outline",className:`text-[10px] px-1.5 py-px ${a(o.status)}`,children:o.status.replace("_"," ")})]})]})})]},o.id||`todo-${i}`))]})},Bd=({todos:t,isResult:r=!1})=>e.jsx(Od,{todos:t,isResult:r});function Wd(t){const r=[],s=t.split(`
76
+ `);for(const a of s){const n=a.match(/#(\d+)\.?\s*(?:\[(\w+)\]\s*)?(.+?)(?:\s*\((?:owner:\s*\w+)?\))?$/);if(n){const[,o,i,c]=n,d=a.match(/blockedBy:\s*\[([^\]]*)\]/);r.push({id:o,subject:c.trim(),status:i||"pending",blockedBy:d?d[1].split(",").map(u=>u.trim()).filter(Boolean):void 0})}}return r}const mn={completed:{icon:e.jsx("svg",{className:"w-3.5 h-3.5 text-green-500 dark:text-green-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),textClass:"line-through text-gray-400 dark:text-gray-500",badgeClass:"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300 border-green-200 dark:border-green-800"},in_progress:{icon:e.jsx("svg",{className:"w-3.5 h-3.5 text-blue-500 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),textClass:"text-gray-900 dark:text-gray-100",badgeClass:"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 border-blue-200 dark:border-blue-800"},pending:{icon:e.jsx("svg",{className:"w-3.5 h-3.5 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("circle",{cx:"12",cy:"12",r:"9",strokeWidth:2})}),textClass:"text-gray-700 dark:text-gray-300",badgeClass:"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 border-gray-200 dark:border-gray-700"}},Ud=({content:t})=>{const r=Wd(t);if(r.length===0)return e.jsx("pre",{className:"text-[11px] font-mono text-gray-600 dark:text-gray-400 whitespace-pre-wrap",children:t});const s=r.filter(n=>n.status==="completed").length,a=r.length;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsxs("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:[s,"/",a," completed"]}),e.jsx("div",{className:"flex-1 h-1 bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-green-500 dark:bg-green-400 rounded-full transition-all",style:{width:`${a>0?s/a*100:0}%`}})})]}),e.jsx("div",{className:"space-y-px",children:r.map(n=>{const o=mn[n.status]||mn.pending;return e.jsxs("div",{className:"flex items-center gap-1.5 py-0.5 group",children:[e.jsx("span",{className:"flex-shrink-0",children:o.icon}),e.jsxs("span",{className:"text-[11px] font-mono text-gray-400 dark:text-gray-500 flex-shrink-0",children:["#",n.id]}),e.jsx("span",{className:`text-xs truncate flex-1 ${o.textClass}`,children:n.subject}),e.jsx("span",{className:`text-[10px] px-1 py-px rounded border flex-shrink-0 ${o.badgeClass}`,children:n.status.replace("_"," ")})]},n.id)})})]})},Hd=({content:t,format:r="plain",className:s=""})=>{if(r==="json"){let a=t;try{const n=JSON.parse(t);a=JSON.stringify(n,null,2)}catch{}return e.jsx("pre",{className:`mt-1 text-xs bg-gray-900 dark:bg-gray-950 text-gray-100 p-2.5 rounded overflow-x-auto font-mono ${s}`,children:a})}return r==="code"?e.jsx("pre",{className:`mt-1 text-xs bg-gray-50 dark:bg-gray-800/50 border border-gray-200/50 dark:border-gray-700/50 p-2 rounded whitespace-pre-wrap break-words overflow-hidden text-gray-700 dark:text-gray-300 font-mono ${s}`,children:t}):e.jsx("div",{className:`mt-1 text-sm text-gray-700 dark:text-gray-300 whitespace-pre-wrap ${s}`,children:t})},Gd=({questions:t,answers:r,className:s=""})=>{const[a,n]=l.useState(null);if(!t||t.length===0)return null;const o=Object.keys(r||{}).length>0,i=t.length;return e.jsxs("div",{className:`space-y-2 ${s}`,children:[t.map((c,d)=>{const u=r==null?void 0:r[c.question],m=u?u.split(", "):[],h=!u,p=a===d;return e.jsxs("div",{className:"rounded-lg border border-gray-150 dark:border-gray-700/50 bg-gray-50/50 dark:bg-gray-800/30 overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>n(p?null:d),className:"w-full text-left px-3 py-2 flex items-start gap-2.5 hover:bg-gray-50 dark:hover:bg-gray-800/50 transition-colors",children:[e.jsx("div",{className:`mt-0.5 flex-shrink-0 w-4 h-4 rounded-full flex items-center justify-center ${m.length>0?"bg-blue-100 dark:bg-blue-900/40":"bg-gray-100 dark:bg-gray-800"}`,children:m.length>0?e.jsx("svg",{className:"w-2.5 h-2.5 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-gray-300 dark:bg-gray-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[c.header&&e.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[9px] font-semibold uppercase tracking-wider bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 border border-blue-100/80 dark:border-blue-800/40",children:c.header}),i>1&&e.jsxs("span",{className:"text-[10px] tabular-nums text-gray-400 dark:text-gray-500",children:[d+1,"/",i]})]}),e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400 mt-0.5 leading-snug",children:c.question}),!p&&m.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-1.5",children:m.map(g=>{const f=!c.options.some(x=>x.label===g);return e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] px-1.5 py-0.5 rounded-md bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 font-medium",children:[g,f&&e.jsx("span",{className:"text-[9px] text-blue-400 dark:text-blue-500 font-normal",children:"(custom)"})]},g)})}),!p&&h&&o&&e.jsx("span",{className:"inline-block mt-1 text-[10px] text-gray-400 dark:text-gray-500 italic",children:"Skipped"})]}),e.jsx("svg",{className:`w-3.5 h-3.5 mt-0.5 text-gray-400 dark:text-gray-500 flex-shrink-0 transition-transform duration-200 ${p?"rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),p&&e.jsx("div",{className:"px-3 pb-2.5 pt-0.5 border-t border-gray-100 dark:border-gray-700/40",children:e.jsxs("div",{className:"space-y-1 ml-6.5",children:[c.options.map(g=>{const f=m.includes(g.label);return e.jsxs("div",{className:`flex items-start gap-2 px-2.5 py-1.5 rounded-lg text-[12px] ${f?"bg-blue-50/80 dark:bg-blue-900/20 border border-blue-200/60 dark:border-blue-800/40":"text-gray-400 dark:text-gray-500"}`,children:[e.jsx("div",{className:`mt-0.5 flex-shrink-0 w-3.5 h-3.5 ${c.multiSelect?"rounded-[3px]":"rounded-full"} border-[1.5px] flex items-center justify-center ${f?"border-blue-500 dark:border-blue-400 bg-blue-500 dark:bg-blue-500":"border-gray-300 dark:border-gray-600"}`,children:f&&e.jsx("svg",{className:"w-2 h-2 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:f?"text-gray-900 dark:text-gray-100 font-medium":"",children:g.label}),g.description&&e.jsx("span",{className:`block text-[11px] mt-0.5 ${f?"text-blue-600/70 dark:text-blue-300/70":"text-gray-400 dark:text-gray-600"}`,children:g.description})]})]},g.label)}),m.filter(g=>!c.options.some(f=>f.label===g)).map(g=>e.jsxs("div",{className:"flex items-start gap-2 px-2.5 py-1.5 rounded-lg text-[12px] bg-blue-50/80 dark:bg-blue-900/20 border border-blue-200/60 dark:border-blue-800/40",children:[e.jsx("div",{className:`mt-0.5 flex-shrink-0 w-3.5 h-3.5 ${c.multiSelect?"rounded-[3px]":"rounded-full"} border-[1.5px] border-blue-500 dark:border-blue-400 bg-blue-500 dark:bg-blue-500 flex items-center justify-center`,children:e.jsx("svg",{className:"w-2 h-2 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-gray-900 dark:text-gray-100 font-medium",children:g}),e.jsx("span",{className:"text-[10px] text-blue-500 dark:text-blue-400 ml-1",children:"(custom)"})]})]},g)),h&&o&&e.jsx("div",{className:"text-[11px] text-gray-400 dark:text-gray-500 italic px-2.5 py-1",children:"No answer provided"})]})})]},d)}),!o&&i===1&&e.jsx("div",{className:"text-[11px] text-gray-400 dark:text-gray-500 italic",children:"Skipped"})]})},Vd=({request:t,onDecision:r})=>{const s=t.input,a=(s==null?void 0:s.questions)||[],[n,o]=l.useState(0),[i,c]=l.useState(()=>new Map),[d,u]=l.useState(()=>new Map),[m,h]=l.useState(()=>new Map),[p,g]=l.useState(!1),f=l.useRef(null),x=l.useRef(null);l.useEffect(()=>{requestAnimationFrame(()=>g(!0))},[]),l.useEffect(()=>{var M;m.get(n)||(M=f.current)==null||M.focus()},[n,m]),l.useEffect(()=>{var M;m.get(n)&&((M=x.current)==null||M.focus())},[m,n]);const y=l.useCallback((M,z,K)=>{c(te=>{const q=new Map(te),ie=new Set(q.get(M)||[]);return K?ie.has(z)?ie.delete(z):ie.add(z):(ie.clear(),ie.add(z),h($=>{const X=new Map($);return X.set(M,!1),X})),q.set(M,ie),q})},[]),N=l.useCallback((M,z)=>{h(K=>{const te=new Map(K),q=te.get(M)||!1;return te.set(M,!q),!z&&!q&&c(ie=>{const $=new Map(ie);return $.set(M,new Set),$}),te})},[]),j=l.useCallback((M,z)=>{u(K=>{const te=new Map(K);return te.set(M,z),te})},[]),v=l.useCallback(()=>{const M={};return a.forEach((z,K)=>{const te=Array.from(i.get(K)||[]),q=m.get(K)||!1,ie=(d.get(K)||"").trim();q&&ie&&te.push(ie),te.length>0&&(M[z.question]=te.join(", "))}),M},[a,i,m,d]),k=l.useCallback(()=>{r(t.requestId,{allow:!0,updatedInput:{...s,answers:v()}})},[r,t.requestId,s,v]),A=l.useCallback(()=>{r(t.requestId,{allow:!0,updatedInput:{...s,answers:{}}})},[r,t.requestId,s]),P=l.useCallback(M=>{if(M.target instanceof HTMLInputElement)return;const z=a[n];if(!z)return;const K=z.multiSelect||!1,te=z.options.length,q=parseInt(M.key);if(!isNaN(q)&&q>=1&&q<=te){M.preventDefault(),y(n,z.options[q-1].label,K);return}if(M.key==="0"){M.preventDefault(),N(n,K);return}if(M.key==="Enter"){M.preventDefault(),n===a.length-1?k():o($=>$+1);return}if(M.key==="Escape"){M.preventDefault(),A();return}},[n,a,y,N,k,A]);if(a.length===0)return null;const S=a.length,b=S===1,C=a[n],E=C.multiSelect||!1,B=i.get(n)||new Set,T=m.get(n)||!1,W=n===S-1,H=n===0,_=B.size>0||T&&(d.get(n)||"").trim().length>0;return e.jsx("div",{ref:f,tabIndex:-1,onKeyDown:P,className:`w-full outline-none transition-all duration-500 ease-out ${p?"opacity-100 translate-y-0":"opacity-0 translate-y-3"}`,children:e.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-gray-200/80 dark:border-gray-700/50 bg-white dark:bg-gray-800/90 shadow-lg dark:shadow-2xl",children:[e.jsx("div",{className:"absolute top-0 left-0 right-0 h-[2px] bg-gradient-to-r from-blue-500 via-cyan-400 to-teal-400"}),e.jsxs("div",{className:"px-4 pt-3.5 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-1.5",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx("div",{className:"w-6 h-6 rounded-lg bg-gradient-to-br from-blue-500/10 to-cyan-500/10 dark:from-blue-400/15 dark:to-cyan-400/15 flex items-center justify-center",children:e.jsx("svg",{className:"w-3.5 h-3.5 text-blue-600 dark:text-blue-400",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.75,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827m0 3h.01"})})}),e.jsx("div",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-cyan-400 dark:bg-cyan-500 animate-pulse"})]}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("span",{className:"text-[10px] font-medium tracking-wide uppercase text-gray-400 dark:text-gray-500",children:"Claude needs your input"}),C.header&&e.jsx("span",{className:"inline-flex items-center px-1.5 py-px rounded text-[9px] font-semibold uppercase tracking-wider bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 border border-blue-100 dark:border-blue-800/50",children:C.header})]}),!b&&e.jsxs("span",{className:"text-[10px] tabular-nums text-gray-400 dark:text-gray-500 flex-shrink-0",children:[n+1,"/",S]})]}),!b&&e.jsx("div",{className:"flex items-center gap-1 mb-2",children:a.map((M,z)=>e.jsx("button",{type:"button",onClick:()=>o(z),className:`h-[3px] rounded-full transition-all duration-300 ${z===n?"w-5 bg-blue-500 dark:bg-blue-400":z<n?"w-2.5 bg-blue-300 dark:bg-blue-600":"w-2.5 bg-gray-200 dark:bg-gray-700"}`},z))}),e.jsx("p",{className:"text-[14px] leading-snug font-medium text-gray-900 dark:text-gray-100",children:C.question}),E&&e.jsx("span",{className:"text-[10px] text-gray-400 dark:text-gray-500",children:"Select all that apply"})]}),e.jsx("div",{className:"px-4 pb-2 max-h-48 overflow-y-auto scrollbar-thin",role:E?"group":"radiogroup","aria-label":C.question,children:e.jsxs("div",{className:"space-y-1",children:[C.options.map((M,z)=>{const K=B.has(M.label);return e.jsxs("button",{type:"button",onClick:()=>y(n,M.label,E),className:`group w-full text-left flex items-center gap-2.5 px-3 py-2 rounded-lg border transition-all duration-150 ${K?"border-blue-300 dark:border-blue-600 bg-blue-50/80 dark:bg-blue-900/25 ring-1 ring-blue-200/50 dark:ring-blue-700/30":"border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 hover:bg-gray-50/60 dark:hover:bg-gray-750/50"}`,children:[e.jsx("kbd",{className:`flex-shrink-0 w-5 h-5 rounded text-[10px] font-mono flex items-center justify-center transition-all duration-150 ${K?"bg-blue-500 dark:bg-blue-500 text-white font-semibold":"bg-gray-100 dark:bg-gray-800 text-gray-400 dark:text-gray-500 border border-gray-200 dark:border-gray-700 group-hover:border-gray-300 dark:group-hover:border-gray-600"}`,children:z+1}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:`text-[13px] leading-tight transition-colors duration-150 ${K?"text-gray-900 dark:text-gray-100 font-medium":"text-gray-700 dark:text-gray-300"}`,children:M.label}),M.description&&e.jsx("div",{className:`text-[11px] leading-snug transition-colors duration-150 ${K?"text-blue-600/70 dark:text-blue-300/70":"text-gray-400 dark:text-gray-500"}`,children:M.description})]}),K&&e.jsx("svg",{className:"w-4 h-4 text-blue-500 dark:text-blue-400 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})]},M.label)}),e.jsxs("button",{type:"button",onClick:()=>N(n,E),className:`group w-full text-left flex items-center gap-2.5 px-3 py-2 rounded-lg border transition-all duration-150 ${T?"border-blue-300 dark:border-blue-600 bg-blue-50/80 dark:bg-blue-900/25 ring-1 ring-blue-200/50 dark:ring-blue-700/30":"border-dashed border-gray-200 dark:border-gray-700/60 hover:border-gray-300 dark:hover:border-gray-600 hover:bg-gray-50/60 dark:hover:bg-gray-750/50"}`,children:[e.jsx("kbd",{className:`flex-shrink-0 w-5 h-5 rounded text-[10px] font-mono flex items-center justify-center transition-all duration-150 ${T?"bg-blue-500 dark:bg-blue-500 text-white font-semibold":"bg-gray-100 dark:bg-gray-800 text-gray-400 dark:text-gray-500 border border-gray-200 dark:border-gray-700 group-hover:border-gray-300 dark:group-hover:border-gray-600"}`,children:"0"}),e.jsx("span",{className:`text-[13px] leading-tight transition-colors ${T?"text-gray-900 dark:text-gray-100 font-medium":"text-gray-500 dark:text-gray-400"}`,children:"Other..."}),T&&e.jsx("svg",{className:"w-4 h-4 text-blue-500 dark:text-blue-400 flex-shrink-0 ml-auto",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4.5 12.75l6 6 9-13.5"})})]}),T&&e.jsx("div",{className:"pl-[30px] pr-0.5",children:e.jsxs("div",{className:"relative",children:[e.jsx("input",{ref:x,type:"text",value:d.get(n)||"",onChange:M=>j(n,M.target.value),onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),W?k():o(z=>z+1)),M.stopPropagation()},placeholder:"Type your answer...",className:"w-full text-[13px] rounded-lg border-0 bg-gray-50 dark:bg-gray-900/60 text-gray-900 dark:text-gray-100 px-3 py-1.5 outline-none ring-1 ring-gray-200 dark:ring-gray-700 focus:ring-2 focus:ring-blue-400 dark:focus:ring-blue-500 placeholder:text-gray-400 dark:placeholder:text-gray-600 transition-shadow duration-200"}),e.jsx("kbd",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-[9px] font-mono text-gray-300 dark:text-gray-600 bg-gray-100 dark:bg-gray-800 px-1 py-0.5 rounded border border-gray-200 dark:border-gray-700",children:"Enter"})]})})]})}),e.jsxs("div",{className:"px-4 py-2 border-t border-gray-100 dark:border-gray-700/50 bg-gray-50/50 dark:bg-gray-800/50 flex items-center justify-between gap-2",children:[e.jsxs("button",{type:"button",onClick:A,className:"text-[11px] text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 transition-colors",children:[b?"Skip":"Skip all",e.jsx("span",{className:"ml-1 text-[9px] text-gray-300 dark:text-gray-600",children:"Esc"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[!b&&!H&&e.jsxs("button",{type:"button",onClick:()=>o(M=>M-1),className:"inline-flex items-center gap-0.5 text-[11px] font-medium px-2.5 py-1.5 rounded-lg text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700/60 transition-all duration-150",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 19l-7-7 7-7"})}),"Back"]}),W?e.jsxs("button",{type:"button",onClick:k,disabled:!_&&!Object.keys(v()).length,className:"inline-flex items-center gap-1 text-[11px] font-semibold px-3.5 py-1.5 rounded-lg bg-gradient-to-r from-blue-600 to-blue-500 dark:from-blue-500 dark:to-blue-600 text-white shadow-sm hover:shadow-md disabled:opacity-30 disabled:cursor-not-allowed disabled:shadow-none transition-all duration-200",children:["Submit",e.jsx("span",{className:"text-[9px] opacity-70 font-mono ml-0.5",children:"Enter"})]}):e.jsxs("button",{type:"button",onClick:()=>o(M=>M+1),className:"inline-flex items-center gap-1 text-[11px] font-semibold px-3.5 py-1.5 rounded-lg bg-gradient-to-r from-blue-600 to-blue-500 dark:from-blue-500 dark:to-blue-600 text-white shadow-sm hover:shadow-md transition-all duration-200",children:["Next",e.jsx("span",{className:"text-[9px] opacity-70 font-mono ml-0.5",children:"Enter"})]})]})]})]})})};function Us(t,r,s,a,n){const o=`${t}-${r||Date.now()}`;if(t==="Edit"||t==="Write"||t==="ApplyPatch"){const i=typeof s=="string"?(()=>{try{return JSON.parse(s)}catch{return s}})():s,c=(i==null?void 0:i.file_path)||"file",d=c.split("/").pop()||c;return{id:`diff-${o}`,type:"diff",title:d,data:{filePath:c,oldContent:(i==null?void 0:i.old_string)||"",newContent:t==="Write"?(i==null?void 0:i.content)||"":(i==null?void 0:i.new_string)||"",badge:t==="Write"?"New":t==="ApplyPatch"?"Patch":"Edit"}}}if(t==="Bash"&&a&&!a.isError){const i=typeof s=="string"?(()=>{try{return JSON.parse(s)}catch{return s}})():s;return{id:`terminal-${o}`,type:"terminal",title:((i==null?void 0:i.command)||"terminal").substring(0,40),data:{command:(i==null?void 0:i.command)||"",output:String((a==null?void 0:a.content)||"")}}}if((t==="Grep"||t==="Glob")&&a){const i=typeof s=="string"?(()=>{try{return JSON.parse(s)}catch{return s}})():s,c=typeof a=="string"?(()=>{try{return JSON.parse(a)}catch{return a}})():a,u=((c==null?void 0:c.toolUseResult)||{}).filenames||[];return{id:`search-${o}`,type:"search",title:`${t}: ${(i==null?void 0:i.pattern)||"search"}`,data:{pattern:(i==null?void 0:i.pattern)||"",files:u}}}if(t==="Read"&&a&&!a.isError){const i=typeof s=="string"?(()=>{try{return JSON.parse(s)}catch{return s}})():s,c=(i==null?void 0:i.file_path)||"file",d=c.split("/").pop()||c;return{id:`code-${o}`,type:"code",title:d,data:{filePath:c,content:String((a==null?void 0:a.content)||"")}}}return null}function qd(t){return["Edit","Write","ApplyPatch"].includes(t)?"edit":["Grep","Glob"].includes(t)?"search":t==="Bash"?"bash":["TodoWrite","TodoRead"].includes(t)?"todo":["TaskCreate","TaskUpdate","TaskList","TaskGet"].includes(t)?"task":t==="Task"?"agent":t==="exit_plan_mode"||t==="ExitPlanMode"?"plan":t==="AskUserQuestion"?"question":"default"}const na=l.memo(({toolName:t,toolInput:r,toolResult:s,toolId:a,mode:n,onFileOpen:o,createDiff:i,selectedProject:c,autoExpandTools:d=!1,showRawParameters:u=!1,rawToolInput:m,isSubagentContainer:h,subagentState:p,onArtifactOpen:g})=>{var v,k,A,P,S;if(h&&p)return n==="result"?null:e.jsx(Fd,{toolInput:r,toolResult:s,subagentState:p});const f=Ho(t),x=n==="input"?f.input:f.result,y=l.useMemo(()=>{try{const b=n==="input"?r:s;return typeof b=="string"?JSON.parse(b):b}catch{return n==="input"?r:s}},[n,r,s]),N=l.useCallback(()=>{var b;if((x==null?void 0:x.action)==="open-file"&&o){const C=((b=x.getValue)==null?void 0:b.call(x,y))||"";o(C)}},[x,y,o]),j=l.useCallback(()=>{if(!g)return;const b=Us(t,a,r,s);b&&g(b)},[g,t,a,r,s,n]);if(!x)return null;if(x.type==="one-line"){const b=((v=x.getValue)==null?void 0:v.call(x,y))||"",C=(k=x.getSecondary)==null?void 0:k.call(x,y),E=g&&Us(t,a,r,s)!==null;return e.jsxs("div",{className:"group/oneline relative",children:[e.jsx($d,{toolName:t,toolResult:s,toolId:a,icon:x.icon,label:x.label,value:b,secondary:C,action:x.action,onAction:N,style:x.style,wrapText:x.wrapText,colorScheme:x.colorScheme,resultId:n==="input"?`tool-result-${a}`:void 0}),E&&e.jsx("button",{onClick:j,className:"absolute top-0.5 right-0 opacity-0 group-hover/oneline:opacity-100 transition-opacity text-[10px] px-1 py-0.5 rounded border border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 bg-white dark:bg-gray-900 z-10",title:"Open in side panel",children:e.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})})]})}if(x.type==="collapsible"){const b=typeof x.title=="function"?x.title(y):x.title||"Details",C=x.defaultOpen!==void 0?x.defaultOpen:d,E=((A=x.getContentProps)==null?void 0:A.call(x,y,{selectedProject:c,createDiff:i,onFileOpen:o}))||{};let B=null;switch(x.contentType){case"diff":i&&(B=e.jsx(Dd,{...E,createDiff:i,onFileClick:()=>o==null?void 0:o(E.filePath)}));break;case"markdown":B=e.jsx(zd,{content:E.content||""});break;case"file-list":B=e.jsx(Rd,{files:E.files||[],onFileClick:o,title:E.title});break;case"todo-list":((P=E.todos)==null?void 0:P.length)>0&&(B=e.jsx(Bd,{todos:E.todos,isResult:E.isResult}));break;case"task":B=e.jsx(Ud,{content:E.content||""});break;case"question-answer":B=e.jsx(Gd,{questions:E.questions||[],answers:E.answers||{}});break;case"text":B=e.jsx(Hd,{content:E.content||"",format:E.format||"plain"});break;case"success-message":{const _=((S=x.getMessage)==null?void 0:S.call(x,y))||"Success";B=e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),_]});break}}const T=(t==="Edit"||t==="Write"||t==="ApplyPatch")&&E.filePath&&o?()=>o(E.filePath,{old_string:E.oldContent,new_string:E.newContent}):void 0,H=g&&Us(t,a,r,s)!==null?e.jsx("button",{onClick:_=>{_.preventDefault(),_.stopPropagation(),j()},className:"opacity-0 group-hover/details:opacity-100 transition-opacity text-[10px] px-1.5 py-0.5 rounded border border-gray-300 dark:border-gray-600 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700",title:"Open in side panel",children:e.jsx("svg",{className:"w-3 h-3 inline-block",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})}):void 0;return e.jsx(_d,{toolName:t,toolId:a,title:b,defaultOpen:C,action:H,onTitleClick:T,showRawParameters:n==="input"&&u,rawContent:m,toolCategory:qd(t),children:B})}return null});na.displayName="ToolRenderer";const Kd=l.memo(({message:t,index:r,prevMessage:s,createDiff:a,onFileOpen:n,onShowSettings:o,onGrantToolPermission:i,autoExpandTools:c,showRawParameters:d,showThinking:u,selectedProject:m,provider:h,onArtifactOpen:p})=>{const{t:g}=Be("chat"),f=s&&s.type===t.type&&(s.type==="assistant"||s.type==="user"||s.type==="tool"||s.type==="error"),x=lt.useRef(null),[y,N]=lt.useState(!1),j=Ed(t,h),[v,k]=lt.useState("idle");lt.useEffect(()=>{k("idle")},[j==null?void 0:j.entry,t.toolId]),lt.useEffect(()=>{const S=x.current;if(!c||!S||!t.isToolUse)return;const b=new IntersectionObserver(C=>{C.forEach(E=>{E.isIntersecting&&!y&&(N(!0),S.querySelectorAll("details").forEach(T=>{T.open=!0}))})},{threshold:.1});return b.observe(S),()=>{b.unobserve(S)}},[c,y,t.isToolUse]);const A=l.useMemo(()=>new Date(t.timestamp).toLocaleTimeString(),[t.timestamp]);return t.isThinking&&!u?null:e.jsx(yd,{value:p||null,children:e.jsx("div",{ref:x,className:`chat-message ${t.type} ${f?"grouped":""} ${t.type==="user"?"flex justify-end px-3 sm:px-0":"px-3 sm:px-0"}`,children:t.type==="user"?e.jsxs("div",{className:"flex items-end space-x-0 sm:space-x-3 w-full sm:w-auto sm:max-w-[85%] md:max-w-md lg:max-w-lg xl:max-w-xl",children:[e.jsxs("div",{className:"bg-blue-600 text-white rounded-2xl rounded-br-md px-3 sm:px-4 py-2 shadow-sm flex-1 sm:flex-initial",children:[e.jsx("div",{className:"text-sm whitespace-pre-wrap break-words",children:t.content}),t.images&&t.images.length>0&&e.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:t.images.map((S,b)=>e.jsx("img",{src:S.data,alt:S.name,className:"rounded-lg max-w-full h-auto cursor-pointer hover:opacity-90 transition-opacity",onClick:()=>window.open(S.data,"_blank")},S.name||b))}),e.jsx("div",{className:"text-xs text-blue-100 mt-1 text-right",children:A})]}),!f&&e.jsx("div",{className:"hidden sm:flex w-8 h-8 bg-blue-600 rounded-full items-center justify-center text-white text-sm flex-shrink-0",children:"U"})]}):t.isTaskNotification?e.jsx("div",{className:"w-full",children:e.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[e.jsx("span",{className:`inline-block w-1.5 h-1.5 rounded-full flex-shrink-0 ${t.taskStatus==="completed"?"bg-green-400 dark:bg-green-500":"bg-amber-400 dark:bg-amber-500"}`}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:t.content})]})}):e.jsxs("div",{className:"w-full",children:[!f&&e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[t.type==="error"?e.jsx("div",{className:"w-8 h-8 bg-red-600 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0",children:"!"}):t.type==="tool"?e.jsx("div",{className:"w-8 h-8 bg-gray-600 dark:bg-gray-700 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0",children:"🔧"}):e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0 p-1",children:e.jsx(vt,{provider:h,className:"w-full h-full"})}),e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:t.type==="error"?g("messageTypes.error"):t.type==="tool"?g("messageTypes.tool"):g(h==="cursor"?"messageTypes.cursor":h==="codex"?"messageTypes.codex":"messageTypes.claude")})]}),e.jsxs("div",{className:"w-full",children:[t.isToolUse?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-col",children:e.jsx("div",{className:"flex flex-col",children:e.jsx(Qt,{className:"prose prose-sm max-w-none dark:prose-invert",children:String(t.displayText||"")})})}),t.toolInput&&e.jsx(na,{toolName:t.toolName||"UnknownTool",toolInput:t.toolInput,toolResult:t.toolResult,toolId:t.toolId,mode:"input",onFileOpen:n,createDiff:a,selectedProject:m,autoExpandTools:c,showRawParameters:d,rawToolInput:typeof t.toolInput=="string"?t.toolInput:void 0,isSubagentContainer:t.isSubagentContainer,subagentState:t.subagentState,onArtifactOpen:p}),t.toolResult&&!Ad(t.toolName||"UnknownTool",t.toolResult)&&(t.toolResult.isError?e.jsxs("div",{id:`tool-result-${t.toolId}`,className:"relative mt-2 p-3 rounded border scroll-mt-4 bg-red-50/50 dark:bg-red-950/10 border-red-200/60 dark:border-red-800/40",children:[e.jsxs("div",{className:"relative flex items-center gap-1.5 mb-2",children:[e.jsx("svg",{className:"w-4 h-4 text-red-500 dark:text-red-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),e.jsx("span",{className:"text-xs font-medium text-red-700 dark:text-red-300",children:g("messageTypes.error")})]}),e.jsxs("div",{className:"relative text-sm text-red-900 dark:text-red-100",children:[e.jsx(Qt,{className:"prose prose-sm max-w-none prose-red dark:prose-invert",children:String(t.toolResult.content||"")}),j&&e.jsxs("div",{className:"mt-4 border-t border-red-200/60 dark:border-red-800/60 pt-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{if(!i)return;const S=i(j);S!=null&&S.success?k("granted"):k("error")},disabled:j.isAllowed||v==="granted",className:`inline-flex items-center gap-2 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${j.isAllowed||v==="granted"?"bg-green-100 dark:bg-green-900/30 border-green-300/70 dark:border-green-800/60 text-green-800 dark:text-green-200 cursor-default":"bg-white/80 dark:bg-gray-900/40 border-red-300/70 dark:border-red-800/60 text-red-700 dark:text-red-200 hover:bg-white dark:hover:bg-gray-900/70"}`,children:j.isAllowed||v==="granted"?g("permissions.added"):g("permissions.grant",{tool:j.toolName})}),o&&e.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),o()},className:"text-xs text-red-700 dark:text-red-200 underline hover:text-red-800 dark:hover:text-red-100",children:g("permissions.openSettings")})]}),e.jsx("div",{className:"mt-2 text-xs text-red-700/90 dark:text-red-200/80",children:g("permissions.addTo",{entry:j.entry})}),v==="error"&&e.jsx("div",{className:"mt-2 text-xs text-red-700 dark:text-red-200",children:g("permissions.error")}),(j.isAllowed||v==="granted")&&e.jsx("div",{className:"mt-2 text-xs text-green-700 dark:text-green-200",children:g("permissions.retry")})]})]})]}):e.jsx("div",{id:`tool-result-${t.toolId}`,className:"scroll-mt-4",children:e.jsx(na,{toolName:t.toolName||"UnknownTool",toolInput:t.toolInput,toolResult:t.toolResult,toolId:t.toolId,mode:"result",onFileOpen:n,createDiff:a,selectedProject:m,autoExpandTools:c,onArtifactOpen:p})}))]}):t.isInteractivePrompt?e.jsx("div",{className:"bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-amber-500 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("svg",{className:"w-5 h-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold text-amber-900 dark:text-amber-100 text-base mb-3",children:g("interactive.title")}),(()=>{const S=(t.content||"").split(`
77
+ `).filter(E=>E.trim()),b=S.find(E=>E.includes("?"))||S[0]||"",C=[];return S.forEach(E=>{const B=E.match(/[❯\s]*(\d+)\.\s+(.+)/);if(B){const T=E.includes("❯");C.push({number:B[1],text:B[2].trim(),isSelected:T})}}),e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-amber-800 dark:text-amber-200 mb-4",children:b}),e.jsx("div",{className:"space-y-2 mb-4",children:C.map(E=>e.jsx("button",{className:`w-full text-left px-4 py-3 rounded-lg border-2 transition-all ${E.isSelected?"bg-amber-600 dark:bg-amber-700 text-white border-amber-600 dark:border-amber-700 shadow-md":"bg-white dark:bg-gray-800 text-amber-900 dark:text-amber-100 border-amber-300 dark:border-amber-700"} cursor-not-allowed opacity-75`,disabled:!0,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center text-sm font-bold ${E.isSelected?"bg-white/20":"bg-amber-100 dark:bg-amber-800/50"}`,children:E.number}),e.jsx("span",{className:"text-sm sm:text-base font-medium flex-1",children:E.text}),E.isSelected&&e.jsx("span",{className:"text-lg",children:"❯"})]})},E.number))}),e.jsxs("div",{className:"bg-amber-100 dark:bg-amber-800/30 rounded-lg p-3",children:[e.jsx("p",{className:"text-amber-900 dark:text-amber-100 text-sm font-medium mb-1",children:g("interactive.waiting")}),e.jsx("p",{className:"text-amber-800 dark:text-amber-200 text-xs",children:g("interactive.instruction")})]})]})})()]})]})}):t.isThinking?e.jsx("div",{className:"text-sm",children:e.jsxs("details",{className:"group rounded-lg border border-purple-500/20 dark:border-purple-400/15 bg-purple-50/30 dark:bg-purple-950/10 overflow-hidden",children:[e.jsxs("summary",{className:"cursor-pointer px-3 py-2 flex items-center gap-2.5 hover:bg-purple-50/50 dark:hover:bg-purple-950/20 transition-colors select-none",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-purple-500 dark:text-purple-400 transition-transform group-open:rotate-90 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),e.jsx("svg",{className:"w-4 h-4 text-purple-500 dark:text-purple-400 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})}),e.jsx("span",{className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:"Thinking"})]}),e.jsx("div",{className:"px-3 pb-3 pt-1 border-t border-purple-500/10 dark:border-purple-400/10",children:e.jsx("div",{className:"pl-3 border-l-2 border-purple-400/30 dark:border-purple-500/20 text-gray-600 dark:text-gray-400 text-sm",children:e.jsx(Qt,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:t.content})})})]})}):e.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:[u&&t.reasoning&&e.jsxs("details",{className:"mb-3 group/reasoning rounded-lg border border-purple-500/20 dark:border-purple-400/15 bg-purple-50/30 dark:bg-purple-950/10 overflow-hidden",children:[e.jsxs("summary",{className:"cursor-pointer px-3 py-2 flex items-center gap-2.5 hover:bg-purple-50/50 dark:hover:bg-purple-950/20 transition-colors select-none",children:[e.jsx("svg",{className:"w-3.5 h-3.5 text-purple-500 dark:text-purple-400 transition-transform group-open/reasoning:rotate-90 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})}),e.jsx("svg",{className:"w-4 h-4 text-purple-500 dark:text-purple-400 flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})}),e.jsx("span",{className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:"Extended thinking"})]}),e.jsx("div",{className:"px-3 pb-3 pt-1 border-t border-purple-500/10 dark:border-purple-400/10",children:e.jsx("div",{className:"pl-3 border-l-2 border-purple-400/30 dark:border-purple-500/20 text-gray-600 dark:text-gray-400 text-sm",children:e.jsx(Qt,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:t.reasoning})})})]}),(()=>{const S=sa(String(t.content||"")),b=S.trim();if((b.startsWith("{")||b.startsWith("["))&&(b.endsWith("}")||b.endsWith("]")))try{const C=JSON.parse(b),E=JSON.stringify(C,null,2);return e.jsxs("div",{className:"my-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})}),e.jsx("span",{className:"font-medium",children:g("json.response")})]}),e.jsx("div",{className:"bg-gray-800 dark:bg-gray-900 border border-gray-600/30 dark:border-gray-700 rounded-lg overflow-hidden",children:e.jsx("pre",{className:"p-4 overflow-x-auto",children:e.jsx("code",{className:"text-gray-100 dark:text-gray-200 text-sm font-mono block whitespace-pre",children:E})})})]})}catch{}return t.type==="assistant"?e.jsx(Qt,{className:"prose prose-sm max-w-none dark:prose-invert prose-gray",children:S}):e.jsx("div",{className:"whitespace-pre-wrap",children:S})})()]}),!f&&e.jsx("div",{className:"text-[11px] text-gray-400 dark:text-gray-500 mt-1",children:A})]})]})})})}),Vo=({task:t,onClose:r,onEdit:s,onStatusChange:a,onTaskClick:n,isOpen:o=!0,className:i=""})=>{var B;const{addToast:c}=hr(),[d,u]=l.useState(!1),[m,h]=l.useState(t||{}),[p,g]=l.useState(!1),[f,x]=l.useState(!1),[y,N]=l.useState(!1),{currentProject:j,refreshTasks:v}=fr();if(!o||!t)return null;const k=async()=>{if(j){g(!0);try{const T={};if(m.title!==t.title&&(T.title=m.title),m.description!==t.description&&(T.description=m.description),m.details!==t.details&&(T.details=m.details),Object.keys(T).length>0){const W=await Ue.taskmaster.updateTask(j.name,t.id,T);if(W.ok)v==null||v(),s==null||s(m),u(!1);else{const H=await W.json();console.error("Failed to update task:",H),c(`Failed to update task: ${H.message}`,"error")}}else u(!1)}catch(T){console.error("Error updating task:",T),c("Error updating task. Please try again.","error")}finally{g(!1)}}},A=()=>{navigator.clipboard.writeText(t.id.toString())},P=T=>{switch(T){case"done":return{icon:Rr,color:"text-green-600 dark:text-green-400",bg:"bg-green-50 dark:bg-green-950"};case"in-progress":return{icon:Dr,color:"text-blue-600 dark:text-blue-400",bg:"bg-blue-50 dark:bg-blue-950"};case"review":return{icon:vs,color:"text-amber-600 dark:text-amber-400",bg:"bg-amber-50 dark:bg-amber-950"};case"deferred":return{icon:io,color:"text-gray-500 dark:text-gray-400",bg:"bg-gray-50 dark:bg-gray-800"};case"cancelled":return{icon:He,color:"text-red-600 dark:text-red-400",bg:"bg-red-50 dark:bg-red-950"};default:return{icon:ur,color:"text-slate-500 dark:text-slate-400",bg:"bg-slate-50 dark:bg-slate-800"}}},S=P(t.status),b=S.icon,C=T=>{switch(T){case"high":return"text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-950";case"medium":return"text-yellow-600 dark:text-yellow-400 bg-yellow-50 dark:bg-yellow-950";case"low":return"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-950";default:return"text-gray-600 dark:text-gray-400 bg-gray-50 dark:bg-gray-800"}},E=[{value:"pending",label:"Pending"},{value:"in-progress",label:"In Progress"},{value:"review",label:"Review"},{value:"done",label:"Done"},{value:"deferred",label:"Deferred"},{value:"cancelled",label:"Cancelled"}];return e.jsx("div",{className:"modal-backdrop fixed inset-0 flex items-center justify-center z-[100] md:p-4 bg-black/50",children:e.jsxs("div",{className:ke("bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 md:rounded-lg shadow-xl","w-full md:max-w-4xl h-full md:h-[90vh] flex flex-col",i),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx(b,{className:ke("w-6 h-6",S.color)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("button",{onClick:A,className:"flex items-center gap-1 px-2 py-1 text-xs bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-300 rounded hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors",title:"Click to copy task ID",children:[e.jsxs("span",{children:["Task ",t.id]}),e.jsx(Pr,{className:"w-3 h-3"})]}),t.parentId&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Subtask of Task ",t.parentId]})]}),d?e.jsx("input",{type:"text",value:m.title||"",onChange:T=>h({...m,title:T.target.value}),className:"w-full text-lg font-semibold bg-transparent border-b-2 border-blue-500 focus:outline-none text-gray-900 dark:text-white",placeholder:"Task title"}):e.jsx("h1",{className:"text-lg md:text-xl font-semibold text-gray-900 dark:text-white line-clamp-2",children:t.title})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[d?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:k,disabled:p,className:"p-2 text-green-600 hover:text-green-700 hover:bg-green-50 dark:hover:bg-green-950 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:p?"Saving...":"Save changes",children:e.jsx(ls,{className:ke("w-5 h-5",p&&"animate-spin")})}),e.jsx("button",{onClick:()=>{u(!1),h(t)},disabled:p,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"Cancel editing",children:e.jsx(He,{className:"w-5 h-5"})})]}):e.jsx("button",{onClick:()=>u(!0),className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition-colors",title:"Edit task",children:e.jsx(Di,{className:"w-5 h-5"})}),e.jsx("button",{onClick:r,className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition-colors",title:"Close",children:e.jsx(He,{className:"w-5 h-5"})})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 md:p-6 space-y-6 min-h-0",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Status"}),e.jsx("div",{className:ke("w-full px-3 py-2 rounded-md border border-gray-300 dark:border-gray-600",S.bg,S.color),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{className:"w-4 h-4"}),e.jsx("span",{className:"font-medium capitalize",children:((B=E.find(T=>T.value===t.status))==null?void 0:B.label)||t.status})]})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Priority"}),e.jsxs("div",{className:ke("px-3 py-2 rounded-md text-sm font-medium capitalize",C(t.priority)),children:[e.jsx(oo,{className:"w-4 h-4 inline mr-2"}),t.priority||"Not set"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Dependencies"}),t.dependencies&&t.dependencies.length>0?e.jsx("div",{className:"flex flex-wrap gap-1",children:t.dependencies.map(T=>e.jsxs("button",{onClick:()=>n&&n({id:T}),className:"px-2 py-1 bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300 rounded text-sm hover:bg-blue-200 dark:hover:bg-blue-800 transition-colors cursor-pointer disabled:cursor-default disabled:opacity-50",disabled:!n,title:n?`Click to view Task ${T}`:`Task ${T}`,children:[e.jsx(Na,{className:"w-3 h-3 inline mr-1"}),T]},T))}):e.jsx("span",{className:"text-gray-500 dark:text-gray-400 text-sm",children:"No dependencies"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Description"}),d?e.jsx("textarea",{value:m.description||"",onChange:T=>h({...m,description:T.target.value}),rows:3,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-800 text-gray-900 dark:text-white",placeholder:"Task description"}):e.jsx("p",{className:"text-gray-700 dark:text-gray-300 whitespace-pre-wrap",children:t.description||"No description provided"})]}),t.details&&e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg",children:[e.jsxs("button",{onClick:()=>x(!f),className:"w-full flex items-center justify-between p-4 text-left hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Implementation Details"}),f?e.jsx(Pt,{className:"w-4 h-4 text-gray-500"}):e.jsx(sr,{className:"w-4 h-4 text-gray-500"})]}),f&&e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 p-4",children:d?e.jsx("textarea",{value:m.details||"",onChange:T=>h({...m,details:T.target.value}),rows:4,className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-800 text-gray-900 dark:text-white",placeholder:"Implementation details"}):e.jsx("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-md p-4",children:e.jsx("p",{className:"text-gray-700 dark:text-gray-300 whitespace-pre-wrap",children:t.details})})})]}),t.testStrategy&&e.jsxs("div",{className:"border border-gray-200 dark:border-gray-700 rounded-lg",children:[e.jsxs("button",{onClick:()=>N(!y),className:"w-full flex items-center justify-between p-4 text-left hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Test Strategy"}),y?e.jsx(Pt,{className:"w-4 h-4 text-gray-500"}):e.jsx(sr,{className:"w-4 h-4 text-gray-500"})]}),y&&e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 p-4",children:e.jsx("div",{className:"bg-blue-50 dark:bg-blue-950 rounded-md p-4",children:e.jsx("p",{className:"text-gray-700 dark:text-gray-300 whitespace-pre-wrap",children:t.testStrategy})})})]}),t.subtasks&&t.subtasks.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:["Subtasks (",t.subtasks.length,")"]}),e.jsx("div",{className:"space-y-2",children:t.subtasks.map(T=>{const W=P(T.status),H=W.icon;return e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-gray-50 dark:bg-gray-800 rounded-md",children:[e.jsx(H,{className:ke("w-4 h-4",W.color)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white truncate",children:T.title}),T.description&&e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 truncate",children:T.description})]}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:T.id})]},T.id)})})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 md:p-6 border-t border-gray-200 dark:border-gray-700 flex-shrink-0",children:[e.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Task ID: ",t.id]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("button",{onClick:r,className:"px-4 py-2 text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-md transition-colors",children:"Close"})})]})]})})},pn=({onShowAllTasks:t,onStartTask:r,className:s=""})=>{const{nextTask:a,tasks:n,currentProject:o,isLoadingTasks:i,projectTaskMaster:c,refreshTasks:d,refreshProjects:u}=fr(),{addToast:m}=hr(),[h,p]=l.useState(!1),[g,f]=l.useState(!1),[x,y]=l.useState(!1),[N,j]=l.useState(!1),[v,k]=l.useState(!1),[A,P]=l.useState(!1),[S,b]=l.useState(!1),C=async()=>{if(o){b(!0);try{const W=await Ue.taskmaster.init(o.name);if(W.ok)await u(),f(!1);else{const H=await W.json();console.error("Failed to initialize TaskMaster:",H),m(`Failed to initialize TaskMaster: ${H.message}`,"error")}}catch(W){console.error("Error initializing TaskMaster:",W),m("Error initializing TaskMaster. Please try again.","error")}finally{b(!1)}}},E=()=>{y(!0),f(!1)},B=()=>{j(!0),f(!1)};if(!o||i)return null;let T;if((!n||n.length===0)&&!(c!=null&&c.hasTaskmaster))T=e.jsxs("div",{className:ke("bg-blue-50 dark:bg-blue-950 border border-blue-200 dark:border-blue-800 rounded-lg p-3 mb-4",s),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ta,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"TaskMaster AI is not configured"}),e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400 mt-0.5"})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("button",{onClick:C,disabled:S,className:"text-xs px-2 py-1 bg-blue-600 hover:bg-blue-700 text-white rounded transition-colors flex items-center gap-1 disabled:opacity-50",children:[e.jsx(tr,{className:"w-3 h-3"}),S?"Initializing...":"Initialize TaskMaster AI"]}),e.jsx("button",{onClick:()=>f(!g),className:"text-xs px-1.5 py-1 bg-slate-100 dark:bg-slate-800 hover:bg-slate-200 dark:hover:bg-slate-700 text-slate-600 dark:text-slate-400 rounded transition-colors",title:"More options",children:g?e.jsx(lo,{className:"w-3 h-3"}):e.jsx(Pt,{className:"w-3 h-3"})})]})]}),g&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-blue-200 dark:border-blue-800",children:[!(c!=null&&c.hasTaskmaster)&&e.jsxs("div",{className:"mb-3 p-3 bg-blue-50 dark:bg-blue-900/50 rounded-lg",children:[e.jsx("h4",{className:"text-sm font-medium text-blue-900 dark:text-blue-100 mb-2",children:"🎯 What is TaskMaster?"}),e.jsxs("div",{className:"text-xs text-blue-800 dark:text-blue-200 space-y-1",children:[e.jsxs("p",{children:["• ",e.jsx("strong",{children:"AI-Powered Task Management:"})," Break complex projects into manageable subtasks"]}),e.jsxs("p",{children:["• ",e.jsx("strong",{children:"PRD Templates:"})," Generate tasks from Product Requirements Documents"]}),e.jsxs("p",{children:["• ",e.jsx("strong",{children:"Dependency Tracking:"})," Understand task relationships and execution order"]}),e.jsxs("p",{children:["• ",e.jsx("strong",{children:"Progress Visualization:"})," Kanban boards and detailed task analytics"]}),e.jsxs("p",{children:["• ",e.jsx("strong",{children:"CLI Integration:"})," Use taskmaster commands for advanced workflows"]})]})]}),e.jsx("div",{className:"flex flex-col gap-2",children:c!=null&&c.hasTaskmaster?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-2 p-2 bg-green-50 dark:bg-green-900/30 rounded text-xs text-green-800 dark:text-green-200",children:[e.jsx("strong",{children:"Add more tasks:"})," Create additional tasks manually or generate them from a PRD template"]}),e.jsxs("button",{className:"text-xs px-3 py-2 bg-green-100 dark:bg-green-900 hover:bg-green-200 dark:hover:bg-green-800 text-green-800 dark:text-green-200 rounded transition-colors text-left flex items-center gap-2 disabled:opacity-50",onClick:E,disabled:S,children:[e.jsx(st,{className:"w-3 h-3"}),"Create a new task manually"]}),e.jsxs("button",{className:"text-xs px-3 py-2 bg-purple-100 dark:bg-purple-900 hover:bg-purple-200 dark:hover:bg-purple-800 text-purple-800 dark:text-purple-200 rounded transition-colors text-left flex items-center gap-2 disabled:opacity-50",onClick:B,disabled:S,children:[e.jsx(ft,{className:"w-3 h-3"}),S?"Parsing...":"Generate tasks from PRD template"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"text-xs px-3 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded transition-colors text-left flex items-center gap-2 disabled:opacity-50",onClick:C,disabled:S,children:[e.jsx(tr,{className:"w-3 h-3"}),S?"Initializing...":"Initialize TaskMaster (Auto)"]}),e.jsxs("button",{className:"text-xs px-3 py-2 bg-slate-100 dark:bg-slate-800 hover:bg-slate-200 dark:hover:bg-slate-700 text-slate-800 dark:text-slate-200 rounded transition-colors text-left flex items-center gap-2",onClick:()=>k(!0),children:[e.jsx(bt,{className:"w-3 h-3"}),"Initialize via Terminal (Advanced)"]})]})})]})]});else if(a)T=e.jsx("div",{className:ke("bg-slate-50 dark:bg-slate-900/30 border border-slate-200 dark:border-slate-700 rounded-lg p-3 mb-4",s),children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"w-5 h-5 bg-blue-100 dark:bg-blue-900/50 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsx(Li,{className:"w-3 h-3 text-blue-600 dark:text-blue-400"})}),e.jsxs("span",{className:"text-xs text-slate-600 dark:text-slate-400 font-medium",children:["Task ",a.id]}),a.priority==="high"&&e.jsx("div",{className:"w-4 h-4 rounded bg-red-100 dark:bg-red-900/50 flex items-center justify-center",title:"High Priority",children:e.jsx(tr,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})}),a.priority==="medium"&&e.jsx("div",{className:"w-4 h-4 rounded bg-amber-100 dark:bg-amber-900/50 flex items-center justify-center",title:"Medium Priority",children:e.jsx(oo,{className:"w-2.5 h-2.5 text-amber-600 dark:text-amber-400"})}),a.priority==="low"&&e.jsx("div",{className:"w-4 h-4 rounded bg-gray-100 dark:bg-gray-800 flex items-center justify-center",title:"Low Priority",children:e.jsx(ur,{className:"w-2.5 h-2.5 text-gray-400 dark:text-gray-500"})})]}),e.jsx("p",{className:"text-sm font-medium text-slate-900 dark:text-slate-100 line-clamp-1",children:a.title})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsxs("button",{onClick:()=>r==null?void 0:r(),className:"text-xs px-3 py-1.5 bg-blue-600 hover:bg-blue-700 text-white rounded-md font-medium transition-colors shadow-sm flex items-center gap-1",children:[e.jsx(Pi,{className:"w-3 h-3"}),"Start Task"]}),e.jsx("button",{onClick:()=>P(!0),className:"text-xs px-2 py-1.5 border border-slate-300 dark:border-slate-600 hover:bg-slate-100 dark:hover:bg-slate-800 text-slate-600 dark:text-slate-300 rounded-md transition-colors flex items-center gap-1",title:"View task details",children:e.jsx(ar,{className:"w-3 h-3"})}),t&&e.jsx("button",{onClick:t,className:"text-xs px-2 py-1.5 border border-slate-300 dark:border-slate-600 hover:bg-slate-100 dark:hover:bg-slate-800 text-slate-600 dark:text-slate-300 rounded-md transition-colors flex items-center gap-1",title:"View all tasks",children:e.jsx(ta,{className:"w-3 h-3"})})]})]})});else if(n&&n.length>0){const W=n.filter(_=>_.status==="done").length,H=n.length;T=e.jsx("div",{className:ke("bg-purple-50 dark:bg-purple-950 border border-purple-200 dark:border-purple-800 rounded-lg p-3 mb-4",s),children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rr,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"}),e.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:W===H?"All done! 🎉":"No pending tasks"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-gray-600 dark:text-gray-400",children:[W,"/",H]}),e.jsx("button",{onClick:t,className:"text-xs px-2 py-1 bg-purple-600 hover:bg-purple-700 text-white rounded transition-colors",children:"Review"})]})]})})}else T=null;return e.jsxs(e.Fragment,{children:[T,x&&e.jsx(Jd,{currentProject:o,onClose:()=>y(!1),onTaskCreated:()=>{d(),y(!1)}}),N&&e.jsx(Yd,{currentProject:o,onClose:()=>j(!1),onTemplateApplied:()=>{d(),j(!1)}}),v&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 w-full max-w-4xl h-[600px] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(bt,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"TaskMaster Setup"}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Interactive CLI for ",o==null?void 0:o.displayName]})]})]}),e.jsx("button",{onClick:()=>k(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800",children:e.jsx(He,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"flex-1 p-4",children:e.jsx("div",{className:"h-full bg-black rounded-lg overflow-hidden",children:e.jsx(po,{selectedProject:o,selectedSession:null,isActive:!0,initialCommand:"npx task-master init",isPlainShell:!0})})}),e.jsx("div",{className:"p-4 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:"TaskMaster initialization will start automatically"}),e.jsx("button",{onClick:()=>k(!1),className:"px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Close"})]})})]})}),A&&a&&e.jsx(Vo,{task:a,isOpen:A,onClose:()=>P(!1),onStatusChange:()=>d==null?void 0:d(),onTaskClick:null})]})},Jd=({currentProject:t,onClose:r,onTaskCreated:s})=>{const[a,n]=l.useState({title:"",description:"",priority:"medium",useAI:!1,prompt:""}),[o,i]=l.useState(!1),c=async d=>{if(d.preventDefault(),!!t){i(!0);try{const u=a.useAI?{prompt:a.prompt,priority:a.priority}:{title:a.title,description:a.description,priority:a.priority},m=await Ue.taskmaster.addTask(t.name,u);if(m.ok)s();else{const h=await m.json();console.error("Failed to create task:",h),addToast(`Failed to create task: ${h.message}`,"error")}}catch(u){console.error("Error creating task:",u),addToast("Error creating task. Please try again.","error")}finally{i(!1)}}};return e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 w-full max-w-md",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Create New Task"}),e.jsx("button",{onClick:r,className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded",children:e.jsx(He,{className:"w-4 h-4"})})]}),e.jsxs("form",{onSubmit:c,className:"space-y-4",children:[e.jsx("div",{children:e.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:[e.jsx("input",{type:"checkbox",checked:a.useAI,onChange:d=>n(u=>({...u,useAI:d.target.checked}))}),"Use AI to generate task details"]})}),a.useAI?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Task Description (AI will generate details)"}),e.jsx("textarea",{value:a.prompt,onChange:d=>n(u=>({...u,prompt:d.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",rows:"3",placeholder:"Describe what you want to accomplish...",required:!0})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Task Title"}),e.jsx("input",{type:"text",value:a.title,onChange:d=>n(u=>({...u,title:d.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",placeholder:"Enter task title...",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Description"}),e.jsx("textarea",{value:a.description,onChange:d=>n(u=>({...u,description:d.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",rows:"3",placeholder:"Describe the task...",required:!0})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Priority"}),e.jsxs("select",{value:a.priority,onChange:d=>n(u=>({...u,priority:d.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",children:[e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"high",children:"High"})]})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx("button",{type:"button",onClick:r,className:"flex-1 px-4 py-2 border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300",disabled:o,children:"Cancel"}),e.jsx("button",{type:"submit",className:"flex-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded disabled:opacity-50",disabled:o||a.useAI&&!a.prompt.trim()||!a.useAI&&(!a.title.trim()||!a.description.trim()),children:o?"Creating...":"Create Task"})]})]})]})})},Yd=({currentProject:t,onClose:r,onTemplateApplied:s})=>{const[a,n]=l.useState([]),[o,i]=l.useState(null),[c,d]=l.useState({}),[u,m]=l.useState("prd.txt"),[h,p]=l.useState(!0),[g,f]=l.useState(!1),[x,y]=l.useState("select");useEffect(()=>{(async()=>{try{const k=await Ue.taskmaster.getTemplates();if(k.ok){const A=await k.json();n(A.templates)}}catch(k){console.error("Error loading templates:",k)}finally{p(!1)}})()},[]);const N=v=>{i(v);const k=v.content.match(/\[([^\]]+)\]/g)||[],A=[...new Set(k.map(S=>S.slice(1,-1)))],P={};A.forEach(S=>{P[S]=""}),d(P),y("customize")},j=async()=>{if(!(!o||!t)){f(!0);try{const v=await Ue.taskmaster.applyTemplate(t.name,{templateId:o.id,fileName:u,customizations:c});if(!v.ok){const A=await v.json();throw new Error(A.message||"Failed to apply template")}const k=await Ue.taskmaster.parsePRD(t.name,{fileName:u,numTasks:10});if(!k.ok){const A=await k.json();throw new Error(A.message||"Failed to generate tasks")}y("generate"),setTimeout(()=>{s()},2e3)}catch(v){console.error("Error applying template:",v),addToast(`Error: ${v.message}`,"error"),f(!1)}}};return h?e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 w-full max-w-md",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"}),e.jsx("span",{className:"text-gray-900 dark:text-white",children:"Loading templates..."})]})})}):e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-6 w-full max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:x==="select"?"Select PRD Template":x==="customize"?"Customize Template":"Generating Tasks"}),e.jsx("button",{onClick:r,className:"p-1 hover:bg-gray-200 dark:hover:bg-gray-700 rounded",children:e.jsx(He,{className:"w-4 h-4"})})]}),x==="select"&&e.jsx("div",{className:"space-y-3",children:a.map(v=>e.jsx("div",{className:"p-4 border border-gray-200 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 cursor-pointer transition-colors",onClick:()=>N(v),children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white",children:v.name}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:v.description}),e.jsx("span",{className:"inline-block text-xs bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200 px-2 py-1 rounded mt-2",children:v.category})]}),e.jsx(Na,{className:"w-4 h-4 text-gray-400 mt-1"})]})},v.id))}),x==="customize"&&o&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"File Name"}),e.jsx("input",{type:"text",value:u,onChange:v=>m(v.target.value),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",placeholder:"prd.txt"})]}),Object.keys(c).length>0&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"Customize Template"}),e.jsx("div",{className:"space-y-3",children:Object.entries(c).map(([v,k])=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-gray-600 dark:text-gray-400 mb-1",children:v.replace(/([A-Z])/g," $1").replace(/^./,A=>A.toUpperCase())}),e.jsx("input",{type:"text",value:k,onChange:A=>d(P=>({...P,[v]:A.target.value})),className:"w-full p-2 border border-gray-300 dark:border-gray-600 rounded text-sm focus:ring-2 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:text-white",placeholder:`Enter ${v.toLowerCase()}`})]},v))})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx("button",{onClick:()=>y("select"),className:"flex-1 px-4 py-2 border border-gray-300 dark:border-gray-600 rounded hover:bg-gray-50 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300",children:"Back"}),e.jsx("button",{onClick:j,className:"flex-1 px-4 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded disabled:opacity-50",disabled:g,children:g?"Applying...":"Apply & Generate Tasks"})]})]}),x==="generate"&&e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 bg-green-100 dark:bg-green-900 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(Rr,{className:"w-8 h-8 text-green-600 dark:text-green-400"})}),e.jsx("h4",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"Template Applied Successfully!"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Your PRD has been created and tasks are being generated..."})]})]})})},La={OPTIONS:[{value:"sonnet",label:"Sonnet"},{value:"opus",label:"Opus"},{value:"haiku",label:"Haiku"},{value:"opusplan",label:"Opus Plan"},{value:"sonnet[1m]",label:"Sonnet [1M]"}],DEFAULT:"sonnet"},Pa={OPTIONS:[{value:"gpt-5.2-high",label:"GPT-5.2 High"},{value:"gemini-3-pro",label:"Gemini 3 Pro"},{value:"opus-4.5-thinking",label:"Claude 4.5 Opus (Thinking)"},{value:"gpt-5.2",label:"GPT-5.2"},{value:"gpt-5.1",label:"GPT-5.1"},{value:"gpt-5.1-high",label:"GPT-5.1 High"},{value:"composer-1",label:"Composer 1"},{value:"auto",label:"Auto"},{value:"sonnet-4.5",label:"Claude 4.5 Sonnet"},{value:"sonnet-4.5-thinking",label:"Claude 4.5 Sonnet (Thinking)"},{value:"opus-4.5",label:"Claude 4.5 Opus"},{value:"gpt-5.1-codex",label:"GPT-5.1 Codex"},{value:"gpt-5.1-codex-high",label:"GPT-5.1 Codex High"},{value:"gpt-5.1-codex-max",label:"GPT-5.1 Codex Max"},{value:"gpt-5.1-codex-max-high",label:"GPT-5.1 Codex Max High"},{value:"opus-4.1",label:"Claude 4.1 Opus"},{value:"grok",label:"Grok"}],DEFAULT:"gpt-5"},$a={OPTIONS:[{value:"gpt-5.3-codex",label:"GPT-5.3 Codex"},{value:"gpt-5.2-codex",label:"GPT-5.2 Codex"},{value:"gpt-5.2",label:"GPT-5.2"},{value:"gpt-5.1-codex-max",label:"GPT-5.1 Codex Max"},{value:"o3",label:"O3"},{value:"o4-mini",label:"O4-mini"}],DEFAULT:"gpt-5.2"},Qd=[{id:"claude",name:"Claude Code",infoKey:"providerSelection.providerInfo.anthropic",accent:"border-primary",ring:"ring-primary/15",check:"bg-primary text-primary-foreground"},{id:"cursor",name:"Cursor",infoKey:"providerSelection.providerInfo.cursorEditor",accent:"border-violet-500 dark:border-violet-400",ring:"ring-violet-500/15",check:"bg-violet-500 text-white"},{id:"codex",name:"Codex",infoKey:"providerSelection.providerInfo.openai",accent:"border-emerald-600 dark:border-emerald-400",ring:"ring-emerald-600/15",check:"bg-emerald-600 dark:bg-emerald-500 text-white"}];function Xd(t){return t==="claude"?La:t==="codex"?$a:Pa}function Zd(t,r,s,a){return t==="claude"?r:t==="codex"?a:s}function eu({selectedSession:t,currentSessionId:r,provider:s,setProvider:a,textareaRef:n,claudeModel:o,setClaudeModel:i,cursorModel:c,setCursorModel:d,codexModel:u,setCodexModel:m,tasksEnabled:h,isTaskMasterInstalled:p,onShowAllTasks:g,setInput:f}){const{t:x}=Be("chat"),y=x("tasks.nextTaskPrompt",{defaultValue:"Start the next task"}),N=A=>{a(A),localStorage.setItem("selected-provider",A),setTimeout(()=>{var P;return(P=n.current)==null?void 0:P.focus()},100)},j=A=>{s==="claude"?(i(A),localStorage.setItem("claude-model",A)):s==="codex"?(m(A),localStorage.setItem("codex-model",A)):(d(A),localStorage.setItem("cursor-model",A))},v=Xd(s),k=Zd(s,o,c,u);return!t&&!r?e.jsx("div",{className:"flex items-center justify-center h-full px-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h2",{className:"text-lg sm:text-xl font-semibold text-foreground tracking-tight",children:x("providerSelection.title")}),e.jsx("p",{className:"text-[13px] text-muted-foreground mt-1",children:x("providerSelection.description")})]}),e.jsx("div",{className:"grid grid-cols-3 gap-2 sm:gap-2.5 mb-6",children:Qd.map(A=>{const P=s===A.id;return e.jsxs("button",{onClick:()=>N(A.id),className:`
78
+ relative flex flex-col items-center gap-2.5 pt-5 pb-4 px-2
79
+ rounded-xl border-[1.5px] transition-all duration-150
80
+ active:scale-[0.97]
81
+ ${P?`${A.accent} ${A.ring} ring-2 bg-card shadow-sm`:"border-border bg-card/60 hover:bg-card hover:border-border/80"}
82
+ `,children:[e.jsx(vt,{provider:A.id,className:`w-9 h-9 transition-transform duration-150 ${P?"scale-110":""}`}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[13px] font-semibold text-foreground leading-none",children:A.name}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1 leading-tight",children:x(A.infoKey)})]}),P&&e.jsx("div",{className:`absolute -top-1 -right-1 w-[18px] h-[18px] rounded-full ${A.check} flex items-center justify-center shadow-sm`,children:e.jsx(jt,{className:"w-2.5 h-2.5",strokeWidth:3})})]},A.id)})}),e.jsxs("div",{className:`transition-all duration-200 ${s?"opacity-100 translate-y-0":"opacity-0 translate-y-1 pointer-events-none"}`,children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-5",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:x("providerSelection.selectModel")}),e.jsxs("div",{className:"relative",children:[e.jsx("select",{value:k,onChange:A=>j(A.target.value),tabIndex:-1,className:"appearance-none pl-3 pr-7 py-1.5 text-sm font-medium bg-muted/50 border border-border/60 rounded-lg text-foreground cursor-pointer hover:bg-muted transition-colors focus:outline-none focus:ring-2 focus:ring-primary/20",children:v.OPTIONS.map(({value:A,label:P})=>e.jsx("option",{value:A,children:P},A))}),e.jsx(Pt,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground pointer-events-none"})]})]}),e.jsx("p",{className:"text-center text-sm text-muted-foreground/70",children:s==="claude"?x("providerSelection.readyPrompt.claude",{model:o}):s==="cursor"?x("providerSelection.readyPrompt.cursor",{model:c}):s==="codex"?x("providerSelection.readyPrompt.codex",{model:u}):x("providerSelection.readyPrompt.default")})]}),s&&h&&p&&e.jsx("div",{className:"mt-5",children:e.jsx(pn,{onStartTask:()=>f(y),onShowAllTasks:g})})]})}):t?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center px-6 max-w-md",children:[e.jsx("p",{className:"text-lg font-semibold text-foreground mb-1.5",children:x("session.continue.title")}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:x("session.continue.description")}),h&&p&&e.jsx("div",{className:"mt-5",children:e.jsx(pn,{onStartTask:()=>f(y),onShowAllTasks:g})})]})}):null}function tu({selectedProvider:t}){return e.jsx("div",{className:"chat-message assistant",children:e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"flex items-center space-x-3 mb-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-white text-sm flex-shrink-0 p-1 bg-transparent",children:e.jsx(vt,{provider:t,className:"w-full h-full"})}),e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:t==="cursor"?"Cursor":t==="codex"?"Codex":"Claude"})]}),e.jsx("div",{className:"w-full pl-3 sm:pl-0",children:e.jsxs("div",{className:"inline-flex items-center gap-2.5 px-3 py-2 rounded-lg border border-purple-500/20 dark:border-purple-400/15 bg-purple-50/30 dark:bg-purple-950/10",children:[e.jsx("svg",{className:"w-4 h-4 text-purple-500 dark:text-purple-400 animate-pulse flex-shrink-0",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})}),e.jsx("span",{className:"text-xs font-medium text-purple-700 dark:text-purple-300",children:"Thinking"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-purple-500 dark:bg-purple-400 animate-bounce",style:{animationDelay:"0ms"}}),e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-purple-500 dark:bg-purple-400 animate-bounce",style:{animationDelay:"150ms"}}),e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-purple-500 dark:bg-purple-400 animate-bounce",style:{animationDelay:"300ms"}})]})]})})]})})}const ru=t=>{if(typeof t!="string"&&typeof t!="number")return null;const r=String(t).trim();return r.length>0?r:null},su=t=>{const r=[t.id,t.messageId,t.toolId,t.toolCallId,t.blobId,t.rowid,t.sequence];for(const o of r){const i=ru(o);if(i)return`message-${t.type}-${i}`}const s=new Date(t.timestamp).getTime();if(!Number.isFinite(s))return null;const a=typeof t.content=="string"?t.content.slice(0,48):"",n=typeof t.toolName=="string"?t.toolName:"";return`message-${t.type}-${s}-${n}-${a}`};function au({scrollContainerRef:t,onWheel:r,onTouchMove:s,isLoadingSessionMessages:a,chatMessages:n,selectedSession:o,currentSessionId:i,provider:c,setProvider:d,textareaRef:u,claudeModel:m,setClaudeModel:h,cursorModel:p,setCursorModel:g,codexModel:f,setCodexModel:x,tasksEnabled:y,isTaskMasterInstalled:N,onShowAllTasks:j,setInput:v,isLoadingMoreMessages:k,hasMoreMessages:A,totalMessages:P,sessionMessagesCount:S,visibleMessageCount:b,visibleMessages:C,loadEarlierMessages:E,loadAllMessages:B,allMessagesLoaded:T,isLoadingAllMessages:W,loadAllJustFinished:H,showLoadAllOverlay:_,createDiff:M,onFileOpen:z,onShowSettings:K,onGrantToolPermission:te,autoExpandTools:q,showRawParameters:ie,showThinking:$,selectedProject:X,isLoading:re,onArtifactOpen:Y}){const{t:U}=Be("chat"),O=l.useRef(new WeakMap),F=l.useRef(new Set),V=l.useRef(0),R=l.useCallback(Z=>{const G=O.current.get(Z);if(G)return G;const w=su(Z);let I=w;if(!I||F.current.has(I))do V.current+=1,I=w?`${w}-${V.current}`:`message-generated-${V.current}`;while(F.current.has(I));return F.current.add(I),O.current.set(Z,I),I},[]);return e.jsxs("div",{ref:t,onWheel:r,onTouchMove:s,className:"flex-1 overflow-y-auto overflow-x-hidden px-0 py-3 sm:p-4 pb-24 space-y-3 sm:space-y-4 relative",children:[a&&n.length===0?e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400 mt-8",children:e.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),e.jsx("p",{children:U("session.loading.sessionMessages")})]})}):n.length===0?e.jsx(eu,{selectedSession:o,currentSessionId:i,provider:c,setProvider:d,textareaRef:u,claudeModel:m,setClaudeModel:h,cursorModel:p,setCursorModel:g,codexModel:f,setCodexModel:x,tasksEnabled:y,isTaskMasterInstalled:N,onShowAllTasks:j,setInput:v}):e.jsxs(e.Fragment,{children:[k&&!W&&!T&&e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400 py-3",children:e.jsxs("div",{className:"flex items-center justify-center space-x-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-gray-400"}),e.jsx("p",{className:"text-sm",children:U("session.loading.olderMessages")})]})}),A&&!k&&!T&&e.jsx("div",{className:"text-center text-gray-500 dark:text-gray-400 text-sm py-2 border-b border-gray-200 dark:border-gray-700",children:P>0&&e.jsxs("span",{children:[U("session.messages.showingOf",{shown:S,total:P})," ",e.jsx("span",{className:"text-xs",children:U("session.messages.scrollToLoad")})]})}),(_||W||H)&&e.jsx("div",{className:"sticky top-2 z-20 flex justify-center pointer-events-none",children:H?e.jsxs("div",{className:"px-4 py-1.5 text-xs font-medium text-white bg-green-600 dark:bg-green-500 rounded-full shadow-lg flex items-center space-x-2",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M5 13l4 4L19 7"})}),e.jsx("span",{children:U("session.messages.allLoaded")})]}):e.jsxs("button",{className:"pointer-events-auto px-4 py-1.5 text-xs font-medium text-white bg-blue-600 hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600 rounded-full shadow-lg transition-all duration-200 hover:scale-105 disabled:opacity-75 disabled:cursor-wait flex items-center space-x-2",onClick:B,disabled:W,children:[W&&e.jsx("div",{className:"animate-spin rounded-full h-3 w-3 border-2 border-white/30 border-t-white"}),e.jsx("span",{children:W?U("session.messages.loadingAll"):e.jsxs(e.Fragment,{children:[U("session.messages.loadAll")," ",P>0&&`(${P})`]})})]})}),T&&e.jsx("div",{className:"text-center text-amber-600 dark:text-amber-400 text-xs py-1.5 bg-amber-50 dark:bg-amber-900/20 border-b border-amber-200 dark:border-amber-800",children:U("session.messages.perfWarning")}),!A&&n.length>b&&e.jsxs("div",{className:"text-center text-gray-500 dark:text-gray-400 text-sm py-2 border-b border-gray-200 dark:border-gray-700",children:[U("session.messages.showingLast",{count:b,total:n.length})," |",e.jsx("button",{className:"ml-1 text-blue-600 hover:text-blue-700 underline",onClick:E,children:U("session.messages.loadEarlier")})," | ",e.jsx("button",{className:"text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 underline",onClick:B,children:U("session.messages.loadAll")})]}),C.map((Z,G)=>{const w=G>0?C[G-1]:null;return e.jsx(Kd,{message:Z,index:G,prevMessage:w,createDiff:M,onFileOpen:z,onShowSettings:K,onGrantToolPermission:te,autoExpandTools:q,showRawParameters:ie,showThinking:$,selectedProject:X,provider:c,onArtifactOpen:Y},R(Z))})]}),re&&e.jsx(tu,{selectedProvider:c})]})}const nu=({commands:t=[],selectedIndex:r=-1,onSelect:s,onClose:a,position:n={top:0,left:0},isOpen:o=!1,frequentCommands:i=[]})=>{const c=l.useRef(null),d=l.useRef(null),m=(()=>{const v=window.innerWidth<640,k=window.innerHeight;return v?{position:"fixed",bottom:`${n.bottom||90}px`,left:"16px",right:"16px",width:"auto",maxWidth:"calc(100vw - 32px)",maxHeight:"min(50vh, 300px)"}:{position:"fixed",top:`${Math.max(16,Math.min(n.top,k-316))}px`,left:`${n.left}px`,width:"min(400px, calc(100vw - 32px))",maxWidth:"calc(100vw - 32px)",maxHeight:"300px"}})();if(l.useEffect(()=>{const v=k=>{c.current&&!c.current.contains(k.target)&&o&&a()};if(o)return document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[o,a]),l.useEffect(()=>{if(d.current&&c.current){const v=c.current.getBoundingClientRect(),k=d.current.getBoundingClientRect();k.bottom>v.bottom?d.current.scrollIntoView({block:"nearest",behavior:"smooth"}):k.top<v.top&&d.current.scrollIntoView({block:"nearest",behavior:"smooth"})}},[r]),!o)return null;if(t.length===0)return e.jsx("div",{ref:c,className:"command-menu command-menu-empty",style:{...m,maxHeight:"300px",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",zIndex:1e3,padding:"20px",opacity:1,transform:"translateY(0)",transition:"opacity 150ms ease-in-out, transform 150ms ease-in-out",textAlign:"center"},children:"No commands available"});const h=i.length>0,p=v=>`${v.name}::${v.namespace||v.type||"other"}::${v.path||""}`,g=new Set(i.map(p)),f=t.reduce((v,k)=>{if(h&&g.has(p(k)))return v;const A=k.namespace||k.type||"other";return v[A]||(v[A]=[]),v[A].push(k),v},{});h&&(f.frequent=i);for(const v of Object.keys(f))v!=="builtin"&&v!=="project"&&v!=="frequent"&&(f.project=[...f.project||[],...f[v]],delete f[v]);const y=(h?["frequent","builtin","project"]:["builtin","project"]).filter(v=>f[v]),N={frequent:"⭐ Frequently Used",builtin:"Upfynai",project:"Project"},j=new Map;return t.forEach((v,k)=>{const A=p(v);j.has(A)||j.set(A,k)}),e.jsxs("div",{ref:c,role:"listbox","aria-label":"Available commands",className:"command-menu",style:{...m,maxHeight:"300px",overflowY:"auto",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",zIndex:1e3,padding:"8px",opacity:o?1:0,transform:o?"translateY(0)":"translateY(-10px)",transition:"opacity 150ms ease-in-out, transform 150ms ease-in-out"},children:[y.map(v=>e.jsxs("div",{className:"command-group",children:[y.length>1&&e.jsx("div",{style:{fontSize:"11px",fontWeight:600,textTransform:"uppercase",color:"#6b7280",padding:"8px 12px 4px",letterSpacing:"0.05em"},children:N[v]||v}),f[v].map(k=>{const A=p(k),P=j.get(A)??-1,S=P===r;return e.jsxs("div",{ref:S?d:null,role:"option","aria-selected":S,className:"command-item",onMouseEnter:()=>{s&&P>=0&&s(k,P,!0)},onClick:()=>{s&&s(k,P,!1)},style:{display:"flex",alignItems:"flex-start",padding:"10px 12px",borderRadius:"6px",cursor:"pointer",backgroundColor:S?"#eff6ff":"transparent",transition:"background-color 100ms ease-in-out",marginBottom:"2px"},onMouseDown:b=>b.preventDefault(),children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:k.description?"4px":0},children:[e.jsxs("span",{style:{fontSize:"16px",flexShrink:0},children:[v==="builtin"&&"⚡",v==="project"&&"📁",v==="frequent"&&"⭐"]}),e.jsx("span",{style:{fontWeight:600,fontSize:"14px",color:"#111827",fontFamily:"monospace"},children:k.name}),e.jsx("span",{className:"command-metadata-badge",style:{fontSize:"10px",padding:"2px 6px",borderRadius:"4px",backgroundColor:v==="builtin"?"#dbeafe":"#f3f4f6",color:v==="builtin"?"#2563eb":"#6b7280",fontWeight:500},children:v==="builtin"?"Upfynai":"Project"})]}),k.description&&e.jsx("div",{style:{fontSize:"13px",color:"#6b7280",marginLeft:"24px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:k.description})]}),S&&e.jsx("span",{style:{marginLeft:"8px",color:"#3b82f6",fontSize:"12px",fontWeight:600},children:"↵"})]},`${v}-${k.name}-${k.path||""}`)})]},v)),e.jsx("style",{children:`
83
+ .command-menu {
84
+ background-color: white;
85
+ border: 1px solid #e5e7eb;
86
+ }
87
+ .command-menu-empty {
88
+ color: #6b7280;
89
+ }
90
+
91
+ @media (prefers-color-scheme: dark) {
92
+ .command-menu {
93
+ background-color: #1f2937 !important;
94
+ border: 1px solid #374151 !important;
95
+ }
96
+ .command-menu-empty {
97
+ color: #9ca3af !important;
98
+ }
99
+ .command-item[aria-selected="true"] {
100
+ background-color: #1e40af !important;
101
+ }
102
+ .command-item span:not(.command-metadata-badge) {
103
+ color: #f3f4f6 !important;
104
+ }
105
+ .command-metadata-badge {
106
+ background-color: #374151 !important;
107
+ color: #d1d5db !important;
108
+ }
109
+ .command-item div {
110
+ color: #d1d5db !important;
111
+ }
112
+ .command-group > div:first-child {
113
+ color: #9ca3af !important;
114
+ }
115
+ }
116
+ `})]})};function ou({status:t,onAbort:r,isLoading:s,provider:a="claude"}){const[n,o]=l.useState(0),[i,c]=l.useState(0),[d,u]=l.useState(0);if(l.useEffect(()=>{if(!s){o(0),u(0);return}const N=Date.now(),j=30+Math.random()*20,v=setInterval(()=>{const k=Math.floor((Date.now()-N)/1e3);o(k),u(Math.floor(k*j))},1e3);return()=>clearInterval(v)},[s]),l.useEffect(()=>{if(!s)return;const N=setInterval(()=>{c(j=>(j+1)%4)},500);return()=>clearInterval(N)},[s]),!s)return null;const m=["Thinking","Processing","Analyzing","Working","Computing","Reasoning"],h=Math.floor(n/3)%m.length,p=(t==null?void 0:t.text)||m[h],g=(t==null?void 0:t.tokens)||d,f=(t==null?void 0:t.can_interrupt)!==!1,y=["✻","✹","✸","✶"][i];return e.jsx("div",{className:"w-full mb-3 sm:mb-6 animate-in slide-in-from-bottom duration-300",children:e.jsxs("div",{className:"flex items-center justify-between max-w-4xl mx-auto bg-gray-800 dark:bg-gray-900 text-white rounded-lg shadow-lg px-2.5 py-2 sm:px-4 sm:py-3 border border-gray-700 dark:border-gray-800",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3",children:[e.jsx("span",{className:ke("text-base sm:text-xl transition-all duration-500 flex-shrink-0",i%2===0?"text-blue-400 scale-110":"text-blue-300"),children:y}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsxs("span",{className:"font-medium text-xs sm:text-sm truncate",children:[p,"..."]}),e.jsxs("span",{className:"text-gray-400 text-xs sm:text-sm flex-shrink-0",children:["(",n,"s)"]}),g>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-500 hidden sm:inline",children:"·"}),e.jsxs("span",{className:"text-gray-300 text-xs sm:text-sm hidden sm:inline flex-shrink-0",children:["⚒ ",g.toLocaleString()]})]}),e.jsx("span",{className:"text-gray-500 hidden sm:inline",children:"·"}),e.jsx("span",{className:"text-gray-400 text-xs sm:text-sm hidden sm:inline",children:"esc to stop"})]})})]})}),f&&r&&e.jsxs("button",{onClick:r,className:"ml-2 sm:ml-3 text-xs bg-red-600 hover:bg-red-700 active:bg-red-800 text-white px-2 py-1 sm:px-3 sm:py-1.5 rounded-md transition-colors flex items-center gap-1 sm:gap-1.5 flex-shrink-0 font-medium",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),e.jsx("span",{className:"hidden sm:inline",children:"Stop"})]})]})})}async function iu(t,r){const s=new FormData,a=`recording_${Date.now()}.webm`,n=new File([t],a,{type:t.type});s.append("audio",n);const o=window.localStorage.getItem("whisperMode")||"default";s.append("mode",o);try{const i=await Ue.transcribe(s);if(!i.ok){const d=await i.json().catch(()=>({}));throw new Error(d.error||`Transcription error: ${i.status} ${i.statusText}`)}return(await i.json()).text||""}catch(i){throw i.name==="TypeError"&&i.message.includes("fetch")?new Error("Cannot connect to server. Please ensure the backend is running."):i}}function lu({onTranscript:t,className:r=""}){const[s,a]=l.useState("idle"),[n,o]=l.useState(null),[i,c]=l.useState(!0),d=l.useRef(null),u=l.useRef(null),m=l.useRef([]),h=l.useRef(0);l.useEffect(()=>{(()=>{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia){c(!1),o("Microphone not supported. Please use HTTPS or a modern browser.");return}if(location.protocol!=="https:"&&location.hostname!=="localhost"){c(!1),o("Microphone requires HTTPS. Please use a secure connection.");return}c(!0),o(null)})()},[]);const p=async()=>{try{if(console.log("Starting recording..."),o(null),m.current=[],!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)throw new Error("Microphone access not available. Please use HTTPS or a supported browser.");const v=await navigator.mediaDevices.getUserMedia({audio:!0});u.current=v;const k=MediaRecorder.isTypeSupported("audio/webm")?"audio/webm":"audio/mp4",A=new MediaRecorder(v,{mimeType:k});d.current=A,A.ondataavailable=P=>{P.data.size>0&&m.current.push(P.data)},A.onstop=async()=>{console.log("Recording stopped, creating blob...");const P=new Blob(m.current,{type:k});u.current&&(u.current.getTracks().forEach(E=>E.stop()),u.current=null),a("transcribing");const S=window.localStorage.getItem("whisperMode")||"default",b=S==="prompt"||S==="vibe"||S==="instructions"||S==="architect";let C;b&&(C=setTimeout(()=>{a("processing")},2e3));try{const E=await iu(P);E&&t&&t(E)}catch(E){console.error("Transcription error:",E),o(E.message)}finally{C&&clearTimeout(C),a("idle")}},A.start(),a("recording"),console.log("Recording started successfully")}catch(v){console.error("Failed to start recording:",v);let k="Microphone access failed";v.name==="NotAllowedError"?k="Microphone access denied. Please allow microphone permissions.":v.name==="NotFoundError"?k="No microphone found. Please check your audio devices.":v.name==="NotSupportedError"?k="Microphone not supported by this browser.":v.name==="NotReadableError"?k="Microphone is being used by another application.":v.message.includes("HTTPS")&&(k=v.message),o(k),a("idle")}},g=()=>{console.log("Stopping recording..."),d.current&&d.current.state==="recording"?d.current.stop():(console.log("Recorder not in recording state, forcing cleanup"),u.current&&(u.current.getTracks().forEach(v=>v.stop()),u.current=null),a("idle"))},f=v=>{if(v&&(v.preventDefault(),v.stopPropagation()),!i)return;const k=Date.now();if(k-h.current<300){console.log("Ignoring rapid tap");return}h.current=k,console.log("Button clicked, current state:",s),s==="idle"?p():s==="recording"&&g()};l.useEffect(()=>()=>{u.current&&u.current.getTracks().forEach(v=>v.stop())},[]);const x=()=>{if(!i)return{icon:e.jsx(os,{className:"w-5 h-5"}),className:"bg-gray-400 cursor-not-allowed",disabled:!0};switch(s){case"recording":return{icon:e.jsx(os,{className:"w-5 h-5 text-white"}),className:"bg-red-500 hover:bg-red-600 animate-pulse",disabled:!1};case"transcribing":return{icon:e.jsx(Tr,{className:"w-5 h-5 animate-spin"}),className:"bg-blue-500 hover:bg-blue-600",disabled:!0};case"processing":return{icon:e.jsx(ks,{className:"w-5 h-5 animate-pulse"}),className:"bg-purple-500 hover:bg-purple-600",disabled:!0};default:return{icon:e.jsx(os,{className:"w-5 h-5"}),className:"bg-gray-700 hover:bg-gray-600",disabled:!1}}},{icon:y,className:N,disabled:j}=x();return e.jsxs("div",{className:"relative",children:[e.jsx("button",{type:"button",style:{backgroundColor:s==="recording"?"#ef4444":s==="transcribing"?"#3b82f6":s==="processing"?"#a855f7":"#374151"},className:`
117
+ flex items-center justify-center
118
+ w-9 h-9 rounded-full
119
+ text-white transition-all duration-200
120
+ focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500
121
+ dark:ring-offset-gray-800
122
+ touch-action-manipulation
123
+ ${j?"cursor-not-allowed opacity-75":"cursor-pointer"}
124
+ ${s==="recording"?"animate-pulse":""}
125
+ hover:opacity-90
126
+ ${r}
127
+ `,onClick:f,disabled:j,children:y}),n&&e.jsx("div",{className:`absolute bottom-full mb-2 right-0\r
128
+ bg-destructive/90 text-destructive-foreground text-[11px] px-2.5 py-1.5 rounded-lg whitespace-nowrap z-50\r
129
+ animate-fade-in shadow-lg max-w-[220px] text-center`,style:{whiteSpace:"normal"},children:n}),s==="recording"&&e.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-red-500 animate-ping pointer-events-none"}),s==="processing"&&e.jsx("div",{className:"absolute -inset-1 rounded-full border-2 border-purple-500 animate-ping pointer-events-none"})]})}const cu=({file:t,onRemove:r,uploadProgress:s,error:a})=>{const[n,o]=l.useState(void 0);return l.useEffect(()=>{const i=URL.createObjectURL(t);return o(i),()=>URL.revokeObjectURL(i)},[t]),e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:n,alt:t.name,className:"w-20 h-20 object-cover rounded"}),s!==void 0&&s<100&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsxs("div",{className:"text-white text-xs",children:[s,"%"]})}),a&&e.jsx("div",{className:"absolute inset-0 bg-red-500/50 flex items-center justify-center",children:e.jsx("svg",{className:"w-6 h-6 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),e.jsx("button",{type:"button",onClick:r,className:"absolute -top-2 -right-2 bg-red-500 text-white rounded-full p-1 opacity-100 sm:opacity-0 sm:group-hover:opacity-100 focus:opacity-100 transition-opacity","aria-label":"Remove image",children:e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})},qo={};function du(t,r){qo[t]=r}function uu(t){return qo[t]||null}du("AskUserQuestion",Vd);function mu({pendingPermissionRequests:t,handlePermissionDecision:r,handleGrantToolPermission:s}){return t.length?e.jsx("div",{className:"mb-3 space-y-2",children:t.map(a=>{const n=uu(a.toolName);if(n)return e.jsx(n,{request:a,onDecision:r},a.requestId);const o=cn(a.input),i=aa(a.toolName,o),c=Da(),d=i?c.allowedTools.includes(i):!1,u=d?"Allow (saved)":"Allow & remember",m=i?t.filter(h=>aa(h.toolName,cn(h.input))===i).map(h=>h.requestId):[a.requestId];return e.jsxs("div",{className:"rounded-lg border border-amber-200 dark:border-amber-800 bg-amber-50 dark:bg-amber-900/20 p-3 shadow-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-semibold text-amber-900 dark:text-amber-100",children:"Permission required"}),e.jsxs("div",{className:"text-xs text-amber-800 dark:text-amber-200",children:["Tool: ",e.jsx("span",{className:"font-mono",children:a.toolName})]})]}),i&&e.jsxs("div",{className:"text-xs text-amber-700 dark:text-amber-300",children:["Allow rule: ",e.jsx("span",{className:"font-mono",children:i})]})]}),o&&e.jsxs("details",{className:"mt-2",children:[e.jsx("summary",{className:"cursor-pointer text-xs text-amber-800 dark:text-amber-200 hover:text-amber-900 dark:hover:text-amber-100",children:"View tool input"}),e.jsx("pre",{className:"mt-2 max-h-40 overflow-auto rounded-md bg-white/80 dark:bg-gray-900/60 border border-amber-200/60 dark:border-amber-800/60 p-2 text-xs text-amber-900 dark:text-amber-100 whitespace-pre-wrap",children:o})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>r(a.requestId,{allow:!0}),className:"inline-flex items-center gap-2 rounded-md bg-amber-600 text-white text-xs font-medium px-3 py-1.5 hover:bg-amber-700 transition-colors",children:"Allow once"}),e.jsx("button",{type:"button",onClick:()=>{i&&!d&&s({entry:i,toolName:a.toolName}),r(m,{allow:!0,rememberEntry:i})},className:`inline-flex items-center gap-2 rounded-md text-xs font-medium px-3 py-1.5 border transition-colors ${i?"border-amber-300 text-amber-800 hover:bg-amber-100 dark:border-amber-700 dark:text-amber-100 dark:hover:bg-amber-900/30":"border-gray-300 text-gray-400 cursor-not-allowed"}`,disabled:!i,children:u}),e.jsx("button",{type:"button",onClick:()=>r(a.requestId,{allow:!1,message:"User denied tool use"}),className:"inline-flex items-center gap-2 rounded-md text-xs font-medium px-3 py-1.5 border border-red-300 text-red-700 hover:bg-red-50 dark:border-red-800 dark:text-red-200 dark:hover:bg-red-900/30 transition-colors",children:"Deny"})]})]},a.requestId)})}):null}const Ko=[{id:"none",name:"Standard",description:"Regular Claude response",icon:null,prefix:"",color:"text-gray-600"},{id:"think",name:"Think",description:"Basic extended thinking",icon:ks,prefix:"think",color:"text-blue-600"},{id:"think-hard",name:"Think Hard",description:"More thorough evaluation",icon:tr,prefix:"think hard",color:"text-purple-600"},{id:"think-harder",name:"Think Harder",description:"Deep analysis with alternatives",icon:Ut,prefix:"think harder",color:"text-indigo-600"},{id:"ultrathink",name:"Ultrathink",description:"Maximum thinking budget",icon:$i,prefix:"ultrathink",color:"text-red-600"}];function pu({selectedMode:t,onModeChange:r,onClose:s,className:a=""}){const{t:n}=Be("chat"),o={"think-hard":"thinkHard","think-harder":"thinkHarder"},i=Ko.map(p=>{const g=o[p.id]||p.id;return{...p,name:n(`thinkingMode.modes.${g}.name`),description:n(`thinkingMode.modes.${g}.description`),prefix:n(`thinkingMode.modes.${g}.prefix`)}}),[c,d]=l.useState(!1),u=l.useRef(null);l.useEffect(()=>{const p=g=>{u.current&&!u.current.contains(g.target)&&(d(!1),s&&s())};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[s]);const m=i.find(p=>p.id===t)||i[0],h=m.icon||ks;return e.jsxs("div",{className:`relative ${a}`,ref:u,children:[e.jsx("button",{type:"button",onClick:()=>d(!c),className:`w-10 h-10 sm:w-10 sm:h-10 rounded-full flex items-center justify-center transition-all duration-200 ${t==="none"?"bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600":"bg-blue-100 hover:bg-blue-200 dark:bg-blue-900 dark:hover:bg-blue-800"}`,title:n("thinkingMode.buttonTitle",{mode:m.name}),children:e.jsx(h,{className:`w-5 h-5 ${m.color}`})}),c&&e.jsxs("div",{className:"absolute bottom-full right-0 mb-2 w-64 bg-white dark:bg-gray-800 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 overflow-hidden",children:[e.jsxs("div",{className:"p-3 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:n("thinkingMode.selector.title")}),e.jsx("button",{onClick:()=>{d(!1),s&&s()},className:"p-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded",children:e.jsx(He,{className:"w-4 h-4 text-gray-500"})})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:n("thinkingMode.selector.description")})]}),e.jsx("div",{className:"py-1",children:i.map(p=>{const g=p.icon,f=p.id===t;return e.jsx("button",{onClick:()=>{r(p.id),d(!1),s&&s()},className:`w-full px-4 py-3 text-left hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors ${f?"bg-gray-50 dark:bg-gray-700":""}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:`mt-0.5 ${p.icon?p.color:"text-gray-400"}`,children:g?e.jsx(g,{className:"w-5 h-5"}):e.jsx("div",{className:"w-5 h-5"})}),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 text-sm ${f?"text-gray-900 dark:text-white":"text-gray-700 dark:text-gray-300"}`,children:p.name}),f&&e.jsx("span",{className:"text-xs bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300 px-2 py-0.5 rounded",children:n("thinkingMode.selector.active")})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:p.description}),p.prefix&&e.jsx("code",{className:"text-xs bg-gray-100 dark:bg-gray-700 px-1.5 py-0.5 rounded mt-1 inline-block",children:p.prefix})]})]})},p.id)})}),e.jsx("div",{className:"p-3 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",children:e.jsxs("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:[e.jsx("strong",{children:"Tip:"})," ",n("thinkingMode.selector.tip")]})})]})]})}function xu({used:t,total:r}){if(t==null||r==null||r<=0)return null;const s=Math.min(100,t/r*100),a=10,n=2*Math.PI*a,o=n-s/100*n,i=()=>s<50?"#3b82f6":s<75?"#f59e0b":"#ef4444";return e.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400",children:[e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",className:"transform -rotate-90",children:[e.jsx("circle",{cx:"12",cy:"12",r:a,fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-gray-300 dark:text-gray-600"}),e.jsx("circle",{cx:"12",cy:"12",r:a,fill:"none",stroke:i(),strokeWidth:"2",strokeDasharray:n,strokeDashoffset:o,strokeLinecap:"round"})]}),e.jsxs("span",{title:`${t.toLocaleString()} / ${r.toLocaleString()} tokens`,children:[s.toFixed(1),"%"]})]})}function gu({permissionMode:t,onModeSwitch:r,provider:s,thinkingMode:a,setThinkingMode:n,aiMode:o,setAiMode:i,tokenBudget:c,currentModel:d,onModelChange:u,modelOptions:m,slashCommandsCount:h,onToggleCommandMenu:p,hasInput:g,onClearInput:f,isUserScrolledUp:x,hasMessages:y,onScrollToBottom:N}){var S;const{t:j}=Be("chat"),[v,k]=l.useState(!1),A=l.useRef(null);l.useEffect(()=>{if(!v)return;const b=C=>{A.current&&!A.current.contains(C.target)&&k(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[v]);const P=((S=m.find(b=>b.value===d))==null?void 0:S.label)||d;return e.jsxs("div",{className:"flex items-center justify-center gap-2 sm:gap-3 flex-wrap",children:[e.jsx("button",{type:"button",onClick:r,className:`px-2.5 py-1 sm:px-3 sm:py-1.5 rounded-lg text-sm font-medium border transition-all duration-200 ${t==="default"?"bg-muted/50 text-muted-foreground border-border/60 hover:bg-muted":t==="acceptEdits"?"bg-green-50 dark:bg-green-900/15 text-green-700 dark:text-green-300 border-green-300/60 dark:border-green-600/40 hover:bg-green-100 dark:hover:bg-green-900/25":t==="bypassPermissions"?"bg-orange-50 dark:bg-orange-900/15 text-orange-700 dark:text-orange-300 border-orange-300/60 dark:border-orange-600/40 hover:bg-orange-100 dark:hover:bg-orange-900/25":"bg-primary/5 text-primary border-primary/20 hover:bg-primary/10"}`,title:j("input.clickToChangeMode"),children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:`w-1.5 h-1.5 rounded-full ${t==="default"?"bg-muted-foreground":t==="acceptEdits"?"bg-green-500":t==="bypassPermissions"?"bg-orange-500":"bg-primary"}`}),e.jsxs("span",{children:[t==="default"&&j("codex.modes.default"),t==="acceptEdits"&&j("codex.modes.acceptEdits"),t==="bypassPermissions"&&j("codex.modes.bypassPermissions"),t==="plan"&&j("codex.modes.plan")]})]})}),s==="claude"&&e.jsx("div",{className:"flex items-center rounded-lg border border-border/60 overflow-hidden",children:["plan","code","analyse"].map(b=>{const C=o===b,E={plan:"Plan",code:"Code",analyse:"Analyse"},B={plan:C?"bg-blue-500/15 text-blue-400 border-blue-500/30":"",code:C?"bg-emerald-500/15 text-emerald-400 border-emerald-500/30":"",analyse:C?"bg-purple-500/15 text-purple-400 border-purple-500/30":""};return e.jsx("button",{type:"button",onClick:()=>i(b),className:`px-2 py-1 sm:px-2.5 sm:py-1.5 text-xs sm:text-sm font-medium transition-all duration-200 ${C?B[b]:"text-muted-foreground hover:text-foreground hover:bg-muted/50"}`,title:`${E[b]} mode`,children:E[b]},b)})}),s==="claude"&&e.jsx(pu,{selectedMode:a,onModeChange:n,onClose:()=>{},className:""}),e.jsxs("div",{className:"relative",ref:A,children:[e.jsx("button",{type:"button",onClick:()=>k(b=>!b),className:"px-2.5 py-1 sm:px-3 sm:py-1.5 rounded-lg text-sm font-medium border transition-all duration-200 bg-muted/50 text-muted-foreground border-border/60 hover:bg-muted hover:text-foreground",title:j("input.selectModel",{defaultValue:"Select model"}),children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})}),e.jsx("span",{children:P}),e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})}),v&&e.jsx("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 bg-card border border-border/60 rounded-xl shadow-lg min-w-[160px] max-h-[240px] overflow-y-auto z-50",children:m.map(b=>e.jsx("button",{type:"button",onClick:()=>{u(b.value),k(!1)},className:`w-full text-left px-3 py-2 text-sm transition-colors first:rounded-t-xl last:rounded-b-xl ${b.value===d?"bg-primary/10 text-primary font-medium":"text-foreground hover:bg-accent/50"}`,children:b.label},b.value))})]}),e.jsx(xu,{used:(c==null?void 0:c.used)||0,total:(c==null?void 0:c.total)||parseInt(void 0)||16e4}),e.jsxs("button",{type:"button",onClick:p,className:"relative w-8 h-8 sm:w-8 sm:h-8 text-muted-foreground hover:text-foreground rounded-lg flex items-center justify-center transition-colors hover:bg-accent/60",title:j("input.showAllCommands"),children:[e.jsx("svg",{className:"w-4 h-4 sm:w-5 sm:h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),h>0&&e.jsx("span",{className:"absolute -top-1 -right-1 bg-primary text-primary-foreground text-[10px] font-bold rounded-full w-4 h-4 sm:w-5 sm:h-5 flex items-center justify-center",children:h})]}),g&&e.jsx("button",{type:"button",onClick:f,className:"w-8 h-8 sm:w-8 sm:h-8 bg-card hover:bg-accent/60 border border-border/50 rounded-lg flex items-center justify-center transition-all duration-200 group shadow-sm",title:j("input.clearInput",{defaultValue:"Clear input"}),children:e.jsx("svg",{className:"w-3.5 h-3.5 sm:w-4 sm:h-4 text-muted-foreground group-hover:text-foreground transition-colors",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),x&&y&&e.jsx("button",{onClick:N,className:"w-8 h-8 sm:w-8 sm:h-8 bg-primary hover:bg-primary/90 text-primary-foreground rounded-lg shadow-sm flex items-center justify-center transition-all duration-200 hover:scale-105",title:j("input.scrollToBottom",{defaultValue:"Scroll to bottom"}),children:e.jsx("svg",{className:"w-3.5 h-3.5 sm:w-4 sm:h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 14l-7 7m0 0l-7-7m7 7V3"})})})]})}const xn="upfynai-voice-output-enabled",gn="upfynai-voice-id",hu=2e3;function Jo(){const[t,r]=l.useState(!1),[s,a]=l.useState(()=>localStorage.getItem(xn)==="true"),[n,o]=l.useState(()=>localStorage.getItem(gn)||"en-US-AriaNeural"),i=l.useRef(null),c=l.useRef(null),d=l.useCallback(async p=>{if(!(!s||!p)&&!(p.length>hu))try{r(!0);const g=await Te("/api/voice/tts",{method:"POST",body:JSON.stringify({text:p,voice:n})});if(!g.ok)throw new Error("TTS failed");const f=await g.blob(),x=URL.createObjectURL(f);i.current&&(i.current.pause(),i.current=null),c.current&&URL.revokeObjectURL(c.current),c.current=x;const y=new Audio(x);i.current=y,y.onended=()=>{r(!1),URL.revokeObjectURL(x),c.current=null,i.current=null},y.onerror=()=>{r(!1),URL.revokeObjectURL(x),c.current=null,i.current=null},await y.play()}catch{r(!1)}},[s,n]),u=l.useCallback(()=>{i.current&&(i.current.pause(),i.current=null),c.current&&(URL.revokeObjectURL(c.current),c.current=null),r(!1)},[]),m=l.useCallback(()=>{const p=!s;a(p),localStorage.setItem(xn,String(p)),p||u()},[s,u]),h=l.useCallback(p=>{o(p),localStorage.setItem(gn,p)},[]);return{speak:d,stop:u,isPlaying:t,voiceEnabled:s,toggleVoice:m,selectedVoice:n,changeVoice:h}}function fu({pendingPermissionRequests:t,handlePermissionDecision:r,handleGrantToolPermission:s,claudeStatus:a,isLoading:n,onAbortSession:o,provider:i,permissionMode:c,onModeSwitch:d,thinkingMode:u,setThinkingMode:m,aiMode:h,setAiMode:p,tokenBudget:g,currentModel:f,onModelChange:x,modelOptions:y,slashCommandsCount:N,onToggleCommandMenu:j,hasInput:v,onClearInput:k,isUserScrolledUp:A,hasMessages:P,onScrollToBottom:S,onSubmit:b,isDragActive:C,attachedImages:E,onRemoveImage:B,uploadingImages:T,imageErrors:W,showFileDropdown:H,filteredFiles:_,selectedFileIndex:M,onSelectFile:z,filteredCommands:K,selectedCommandIndex:te,onCommandSelect:q,onCloseCommandMenu:ie,isCommandMenuOpen:$,frequentCommands:X,getRootProps:re,getInputProps:Y,openImagePicker:U,inputHighlightRef:O,renderInputWithMentions:F,textareaRef:V,input:R,onInputChange:Z,onTextareaClick:G,onTextareaKeyDown:w,onTextareaPaste:I,onTextareaScrollSync:J,onTextareaInput:se,onInputFocusChange:ce,isInputFocused:Ce,placeholder:fe,isTextareaExpanded:_e,sendByCtrlEnter:we,onTranscript:Ae}){var Ve;const{t:Re}=Be("chat"),{voiceEnabled:Ie,toggleVoice:L,isPlaying:ee}=Jo(),ge=nu,be=(Ve=V.current)==null?void 0:Ve.getBoundingClientRect(),Pe={top:be?Math.max(16,be.top-316):0,left:be?be.left:16,bottom:be?window.innerHeight-be.top+8:90},Fe=t.some(ne=>ne.toolName==="AskUserQuestion"),ze=Ce?"max-sm:fixed max-sm:bottom-0 max-sm:left-0 max-sm:right-0 max-sm:z-50 max-sm:bg-background max-sm:shadow-[0_-4px_20px_rgba(0,0,0,0.12)] max-sm:border-t max-sm:border-border/30 max-sm:rounded-b-none":"";return e.jsxs("div",{className:`sticky bottom-0 z-30 bg-background p-2 sm:p-3 flex-shrink-0 pb-2 ${ze}`,children:[!Fe&&e.jsx("div",{className:"flex-1",children:e.jsx(ou,{status:a,isLoading:n,onAbort:o,provider:i})}),e.jsxs("div",{className:"max-w-4xl mx-auto mb-3",children:[e.jsx(mu,{pendingPermissionRequests:t,handlePermissionDecision:r,handleGrantToolPermission:s}),!Fe&&e.jsx(gu,{permissionMode:c,onModeSwitch:d,provider:i,thinkingMode:u,setThinkingMode:m,aiMode:h,setAiMode:p,tokenBudget:g,currentModel:f,onModelChange:x,modelOptions:y,slashCommandsCount:N,onToggleCommandMenu:j,hasInput:v,onClearInput:k,isUserScrolledUp:A,hasMessages:P,onScrollToBottom:S})]}),!Fe&&e.jsxs("form",{onSubmit:b,className:"relative max-w-4xl mx-auto",children:[C&&e.jsx("div",{className:"absolute inset-0 bg-primary/15 border-2 border-dashed border-primary/50 rounded-2xl flex items-center justify-center z-50",children:e.jsxs("div",{className:"bg-card rounded-xl p-4 shadow-lg border border-border/30",children:[e.jsx("svg",{className:"w-8 h-8 text-primary mx-auto mb-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"})}),e.jsx("p",{className:"text-sm font-medium",children:"Drop images here"})]})}),E.length>0&&e.jsx("div",{className:"mb-2 p-2 bg-muted/40 rounded-xl",children:e.jsx("div",{className:"flex flex-wrap gap-2",children:E.map((ne,he)=>e.jsx(cu,{file:ne,onRemove:()=>B(he),uploadProgress:T.get(ne.name),error:W.get(ne.name)},he))})}),H&&_.length>0&&e.jsx("div",{className:"absolute bottom-full left-0 right-0 mb-2 bg-card/95 backdrop-blur-md border border-border/50 rounded-xl shadow-lg max-h-48 overflow-y-auto z-50",children:_.map((ne,he)=>e.jsxs("div",{className:`px-4 py-3 cursor-pointer border-b border-border/30 last:border-b-0 touch-manipulation ${he===M?"bg-primary/8 text-primary":"hover:bg-accent/50 text-foreground"}`,onMouseDown:Ne=>{Ne.preventDefault(),Ne.stopPropagation()},onClick:Ne=>{Ne.preventDefault(),Ne.stopPropagation(),z(ne)},children:[e.jsx("div",{className:"font-medium text-sm",children:ne.name}),e.jsx("div",{className:"text-xs text-muted-foreground font-mono",children:ne.path})]},ne.path))}),e.jsx(ge,{commands:K,selectedIndex:te,onSelect:q,onClose:ie,position:Pe,isOpen:$,frequentCommands:X}),e.jsxs("div",{...re(),className:`relative bg-card/80 backdrop-blur-sm rounded-2xl shadow-sm border border-border/40 focus-within:shadow-md focus-within:border-primary/25 focus-within:ring-1 focus-within:ring-primary/10 transition-all duration-200 overflow-hidden ${_e?"chat-input-expanded":""}`,children:[e.jsx("input",{...Y()}),e.jsx("div",{ref:O,"aria-hidden":"true",className:"absolute inset-0 pointer-events-none overflow-hidden rounded-2xl",children:e.jsx("div",{className:"chat-input-placeholder block w-full pl-12 pr-20 sm:pr-40 py-1.5 sm:py-4 text-transparent text-base leading-6 whitespace-pre-wrap break-words",children:F(R)})}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("textarea",{ref:V,value:R,onChange:Z,onClick:G,onKeyDown:w,onPaste:I,onScroll:ne=>J(ne.target),onFocus:()=>ce==null?void 0:ce(!0),onBlur:()=>ce==null?void 0:ce(!1),onInput:se,placeholder:fe,disabled:n,className:"chat-input-placeholder block w-full pl-12 pr-20 sm:pr-40 py-1.5 sm:py-4 bg-transparent rounded-2xl focus:outline-none text-foreground placeholder-muted-foreground/50 disabled:opacity-50 resize-none min-h-[50px] sm:min-h-[80px] max-h-[40vh] sm:max-h-[300px] overflow-y-auto text-base leading-6 transition-all duration-200",style:{height:"50px"}}),e.jsx("button",{type:"button",onClick:U,className:"absolute left-1.5 top-1/2 transform -translate-y-1/2 w-9 h-9 flex items-center justify-center hover:bg-accent/60 rounded-xl transition-colors",title:Re("input.attachImages"),children:e.jsx("svg",{className:"w-5 h-5 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),e.jsxs("div",{className:"absolute right-[88px] sm:right-[88px] top-1/2 transform -translate-y-1/2 flex items-center gap-0.5",children:[e.jsx(lu,{onTranscript:Ae}),e.jsx("button",{type:"button",onClick:L,className:`w-9 h-9 flex items-center justify-center rounded-lg transition-colors ${Ie?"text-primary hover:bg-primary/10":"text-muted-foreground/40 hover:text-muted-foreground hover:bg-accent/50"} ${ee?"animate-pulse":""}`,title:Ie?"Disable voice output":"Enable voice output",children:Ie?e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15.536 8.464a5 5 0 010 7.072M18.364 5.636a9 9 0 010 12.728M11 5L6 9H2v6h4l5 4V5z"})}):e.jsxs("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:2,children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707A1 1 0 0112 5v14a1 1 0 01-1.707.707L5.586 15z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2"})]})})]}),e.jsx("button",{type:"submit",disabled:!R.trim()||n,onMouseDown:ne=>{ne.preventDefault(),b(ne)},onTouchStart:ne=>{ne.preventDefault(),b(ne)},className:"absolute right-2 top-1/2 transform -translate-y-1/2 w-10 h-10 sm:w-11 sm:h-11 bg-primary hover:bg-primary/90 disabled:bg-muted disabled:text-muted-foreground disabled:cursor-not-allowed rounded-xl flex items-center justify-center transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-primary/30 focus:ring-offset-1 focus:ring-offset-background",children:e.jsx("svg",{className:"w-4 h-4 sm:w-[18px] sm:h-[18px] text-primary-foreground transform rotate-90",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})}),e.jsx("div",{className:`absolute bottom-1 left-12 right-14 sm:right-40 text-xs text-muted-foreground/50 pointer-events-none hidden sm:block transition-opacity duration-200 ${R.trim()?"opacity-0":"opacity-100"}`,children:Re(we?"input.hintText.ctrlEnter":"input.hintText.enter")})]})]})]})]})}function bu({selectedSession:t}){const[r,s]=l.useState("default"),[a,n]=l.useState([]),[o,i]=l.useState(()=>localStorage.getItem("selected-provider")||"claude"),[c,d]=l.useState(()=>localStorage.getItem("cursor-model")||Pa.DEFAULT),[u,m]=l.useState(()=>localStorage.getItem("claude-model")||La.DEFAULT),[h,p]=l.useState(()=>localStorage.getItem("codex-model")||$a.DEFAULT),g=l.useRef(o);l.useEffect(()=>{if(!(t!=null&&t.id))return;const x=localStorage.getItem(`permissionMode-${t.id}`);s(x||"default")},[t==null?void 0:t.id]),l.useEffect(()=>{!(t!=null&&t.__provider)||t.__provider===o||(i(t.__provider),localStorage.setItem("selected-provider",t.__provider))},[o,t]),l.useEffect(()=>{g.current!==o&&(n([]),g.current=o)},[o]),l.useEffect(()=>{n(x=>x.filter(y=>!y.sessionId||y.sessionId===(t==null?void 0:t.id)))},[t==null?void 0:t.id]),l.useEffect(()=>{o==="cursor"&&Te("/api/cursor/config").then(x=>x.json()).then(x=>{var N,j;if(!x.success||!((j=(N=x.config)==null?void 0:N.model)!=null&&j.modelId))return;const y=x.config.model.modelId;localStorage.getItem("cursor-model")||d(y)}).catch(x=>{console.error("Error loading Cursor config:",x)})},[o]);const f=l.useCallback(()=>{const x=o==="codex"?["default","acceptEdits","bypassPermissions"]:["default","acceptEdits","bypassPermissions","plan"],N=(x.indexOf(r)+1)%x.length,j=x[N];s(j),t!=null&&t.id&&localStorage.setItem(`permissionMode-${t.id}`,j)},[r,o,t==null?void 0:t.id]);return{provider:o,setProvider:i,cursorModel:c,setCursorModel:d,claudeModel:u,setClaudeModel:m,codexModel:h,setCodexModel:p,permissionMode:r,setPermissionMode:s,pendingPermissionRequests:a,setPendingPermissionRequests:n,cyclePermissionMode:f}}const yu=t=>Array.isArray(t)?t:[],Ir=t=>{if(!t)return!0;const r=t.trim();return r.startsWith("<command-name>")||r.startsWith("<command-message>")||r.startsWith("<command-args>")||r.startsWith("<local-command-stdout>")||r.startsWith("<system-reminder>")||r.startsWith("<INSTRUCTIONS>")||r.startsWith("<instructions>")||r.startsWith("Caveat:")||r.startsWith("This session is being continued from a previous")||r.startsWith("[Request interrupted")||/^#\s+AGENTS\.md instructions for/i.test(r)||r.startsWith("# AGENTS.md")||r.includes("## Skills")&&r.includes("### Available skills")||r.includes("### How to use skills")&&r.includes("Trigger rules:")||r.startsWith("A skill is a set of local instructions")||/^<system[_-]?prompt>/i.test(r)||r.startsWith("## System Information")&&r.includes("Operating System:")},ps=t=>{if(t==null||t==="")return"";if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return String(t)}},Hs=(t,r)=>r&&(r.startsWith("/")?r:`${t}/${r}`),vu=(t,r)=>{const s=t.split(`
130
+ `),a=r.split(`
131
+ `),n=Array.from({length:s.length+1},()=>new Array(a.length+1).fill(0));for(let d=s.length-1;d>=0;d-=1)for(let u=a.length-1;u>=0;u-=1)s[d]===a[u]?n[d][u]=n[d+1][u+1]+1:n[d][u]=Math.max(n[d+1][u],n[d][u+1]);const o=[];let i=0,c=0;for(;i<s.length&&c<a.length;){const d=s[i],u=a[c];if(d===u){i+=1,c+=1;continue}if(n[i+1][c]>=n[i][c+1]){o.push({type:"removed",content:d,lineNum:i+1}),i+=1;continue}o.push({type:"added",content:u,lineNum:c+1}),c+=1}for(;i<s.length;)o.push({type:"removed",content:s[i],lineNum:i+1}),i+=1;for(;c<a.length;)o.push({type:"added",content:a[c],lineNum:c+1}),c+=1;return o},ku=()=>{const t=new Map;return(r,s)=>{const a=JSON.stringify([r,s]),n=t.get(a);if(n)return n;const o=vu(r,s);if(t.set(a,o),t.size>100){const i=t.keys().next().value;i&&t.delete(i)}return o}},wu=(t,r)=>{var n,o;const s=[],a={};for(let i=0;i<t.length;i+=1){const c=t[i],d=c.content;let u="",m="assistant",h=null;try{if(d!=null&&d.role&&(d!=null&&d.content)){if(d.role==="system")continue;if(d.role==="tool"){const p=yu(d.content);for(const g of p){if((g==null?void 0:g.type)!=="tool-result")continue;const f=g.toolName==="ApplyPatch"?"Edit":g.toolName||"Unknown Tool",x=g.toolCallId||d.id,y=g.result||"";x&&a[x]?a[x].toolResult={content:y,isError:!1}:s.push({type:"assistant",content:"",timestamp:new Date(Date.now()+i*1e3),blobId:c.id,sequence:c.sequence,rowid:c.rowid,isToolUse:!0,toolName:f,toolId:x,toolInput:ps(null),toolResult:{content:y,isError:!1}})}continue}if(m=d.role==="user"?"user":"assistant",Array.isArray(d.content)){const p=[];for(const g of d.content){if((g==null?void 0:g.type)==="text"&&(g!=null&&g.text)){p.push(Tt(g.text));continue}if((g==null?void 0:g.type)==="reasoning"&&(g!=null&&g.text)){h=Tt(g.text);continue}if((g==null?void 0:g.type)==="tool-call"||(g==null?void 0:g.type)==="tool_use"){(p.length>0||h)&&(s.push({type:m,content:p.join(`
132
+ `),reasoning:h??void 0,timestamp:new Date(Date.now()+i*1e3),blobId:c.id,sequence:c.sequence,rowid:c.rowid}),p.length=0,h=null);const f=g.toolName||g.name||"Unknown Tool",x=f==="ApplyPatch"?"Edit":f,y=g.toolCallId||g.id||`tool_${i}`;let N=g.args||g.input;if(x==="Edit"&&g.args)if(g.args.patch){const v=String(g.args.patch).split(`
133
+ `),k=[],A=[];let P=!1;v.forEach(S=>{if(S.startsWith("@@")){P=!0;return}P&&(S.startsWith("-")?k.push(S.slice(1)):S.startsWith("+")?A.push(S.slice(1)):S.startsWith(" ")&&(k.push(S.slice(1)),A.push(S.slice(1))))}),N={file_path:Hs(r,g.args.file_path),old_string:k.join(`
134
+ `)||g.args.patch,new_string:A.join(`
135
+ `)||g.args.patch}}else N=g.args;else if(x==="Read"&&g.args){const v=g.args.path||g.args.file_path;N={file_path:Hs(r,v)}}else if(x==="Write"&&g.args){const v=g.args.path||g.args.file_path;N={file_path:Hs(r,v),content:g.args.contents||g.args.content}}const j={type:"assistant",content:"",timestamp:new Date(Date.now()+i*1e3),blobId:c.id,sequence:c.sequence,rowid:c.rowid,isToolUse:!0,toolName:x,toolId:y,toolInput:ps(N),toolResult:null};s.push(j),a[y]=j;continue}typeof g=="string"&&p.push(g)}p.length>0?(u=p.join(`
136
+ `),h&&!u&&(s.push({type:m,content:"",reasoning:h,timestamp:new Date(Date.now()+i*1e3),blobId:c.id,sequence:c.sequence,rowid:c.rowid}),u="")):u=""}else typeof d.content=="string"&&(u=d.content)}else if((n=d==null?void 0:d.message)!=null&&n.role&&((o=d==null?void 0:d.message)!=null&&o.content)){if(d.message.role==="system")continue;m=d.message.role==="user"?"user":"assistant",Array.isArray(d.message.content)?u=d.message.content.map(p=>typeof p=="string"?p:(p==null?void 0:p.text)||"").filter(Boolean).join(`
137
+ `):typeof d.message.content=="string"&&(u=d.message.content)}}catch(p){console.log("Error parsing blob content:",p)}if(u&&u.trim()&&!Ir(u)){const p={type:m,content:u,timestamp:new Date(Date.now()+i*1e3),blobId:c.id,sequence:c.sequence,rowid:c.rowid};h&&(p.reasoning=h),s.push(p)}}return s.sort((i,c)=>i.sequence!==void 0&&c.sequence!==void 0?Number(i.sequence)-Number(c.sequence):i.rowid!==void 0&&c.rowid!==void 0?Number(i.rowid)-Number(c.rowid):new Date(i.timestamp).getTime()-new Date(c.timestamp).getTime()),s},ju=t=>{const r=[],s=new Map;return t.forEach(a=>{var n,o;((n=a.message)==null?void 0:n.role)==="user"&&Array.isArray((o=a.message)==null?void 0:o.content)&&a.message.content.forEach(i=>{i.type==="tool_result"&&s.set(i.tool_use_id,{content:i.content,isError:!!i.is_error,timestamp:new Date(a.timestamp||Date.now()),toolUseResult:a.toolUseResult||null,subagentTools:a.subagentTools})})}),t.forEach(a=>{var n,o,i,c,d,u,m;if(((n=a.message)==null?void 0:n.role)==="user"&&((o=a.message)!=null&&o.content)){let h="";if(Array.isArray(a.message.content)){const g=[];a.message.content.forEach(f=>{f.type==="text"&&g.push(Tt(f.text))}),h=g.join(`
138
+ `)}else typeof a.message.content=="string"?h=Tt(a.message.content):h=Tt(String(a.message.content));if(!(!h||Ir(h))){const f=/<task-notification>\s*<task-id>[^<]*<\/task-id>\s*<output-file>[^<]*<\/output-file>\s*<status>([^<]*)<\/status>\s*<summary>([^<]*)<\/summary>\s*<\/task-notification>/g.exec(h);if(f){const x=((i=f[1])==null?void 0:i.trim())||"completed",y=((c=f[2])==null?void 0:c.trim())||"Background task finished";r.push({type:"assistant",content:y,timestamp:a.timestamp||new Date().toISOString(),isTaskNotification:!0,taskStatus:x})}else r.push({type:"user",content:Xr(h),timestamp:a.timestamp||new Date().toISOString()})}return}if(a.type==="thinking"&&((d=a.message)!=null&&d.content)){r.push({type:"assistant",content:Xr(a.message.content),timestamp:a.timestamp||new Date().toISOString(),isThinking:!0});return}if(a.type==="tool_use"&&a.toolName){r.push({type:"assistant",content:"",timestamp:a.timestamp||new Date().toISOString(),isToolUse:!0,toolName:a.toolName,toolInput:ps(a.toolInput),toolCallId:a.toolCallId});return}if(a.type==="tool_result"){for(let h=r.length-1;h>=0;h-=1){const p=r[h];if(!(!p.isToolUse||p.toolResult)&&(!a.toolCallId||p.toolCallId===a.toolCallId)){p.toolResult={content:a.output||"",isError:!1};break}}return}if(((u=a.message)==null?void 0:u.role)==="assistant"&&((m=a.message)!=null&&m.content)){if(Array.isArray(a.message.content)){a.message.content.forEach(h=>{if(h.type==="text"){let p=h.text;if(typeof p=="string"){if(Ir(p))return;p=Xr(p)}r.push({type:"assistant",content:p,timestamp:a.timestamp||new Date().toISOString()});return}if(h.type==="tool_use"){const p=s.get(h.id),g=h.name==="Task",f=[];if(g&&(p!=null&&p.subagentTools)&&Array.isArray(p.subagentTools))for(const x of p.subagentTools)f.push({toolId:x.toolId,toolName:x.toolName,toolInput:x.toolInput,toolResult:x.toolResult||null,timestamp:new Date(x.timestamp||Date.now())});r.push({type:"assistant",content:"",timestamp:a.timestamp||new Date().toISOString(),isToolUse:!0,toolName:h.name,toolInput:ps(h.input),toolId:h.id,toolResult:p?{content:typeof p.content=="string"?p.content:JSON.stringify(p.content),isError:p.isError,toolUseResult:p.toolUseResult}:null,toolError:(p==null?void 0:p.isError)||!1,toolResultTimestamp:(p==null?void 0:p.timestamp)||new Date,isSubagentContainer:g,subagentState:g?{childTools:f,currentToolIndex:f.length>0?f.length-1:-1,isComplete:!!p}:void 0})}});return}typeof a.message.content=="string"&&!Ir(a.message.content)&&r.push({type:"assistant",content:Xr(a.message.content),timestamp:a.timestamp||new Date().toISOString()})}}),r},Nu=20,es=100;function Cu({selectedProject:t,selectedSession:r,ws:s,sendMessage:a,autoScrollToBottom:n,externalMessageUpdate:o,processingSessions:i,resetStreamingState:c,pendingViewSessionRef:d}){const[u,m]=l.useState(()=>{if(typeof window<"u"&&t){const ne=ot.getItem(`chat_messages_${t.name}`);if(ne)try{return JSON.parse(ne)}catch{return console.error("Failed to parse saved chat messages, resetting"),ot.removeItem(`chat_messages_${t.name}`),[]}return[]}return[]}),[h,p]=l.useState(!1),[g,f]=l.useState((r==null?void 0:r.id)||null),[x,y]=l.useState([]),[N,j]=l.useState(!1),[v,k]=l.useState(!1),[A,P]=l.useState(!1),[S,b]=l.useState(0),[C,E]=l.useState(!1),[B,T]=l.useState(!1),[W,H]=l.useState(!1),[_,M]=l.useState(null),[z,K]=l.useState(es),[te,q]=l.useState(null),[ie,$]=l.useState(!1),[X,re]=l.useState(!1),[Y,U]=l.useState(!1),[O,F]=l.useState(!1),V=l.useRef(null),R=l.useRef(!1),Z=l.useRef(!1),G=l.useRef(!1),w=l.useRef(!1),I=l.useRef(null),J=l.useRef(!0),se=l.useRef(0),ce=l.useRef({height:0,top:0}),Ce=l.useRef(null),fe=l.useRef(null),_e=l.useMemo(()=>ku(),[]),we=l.useCallback(async(ne,he,Ne=!1,Me="claude")=>{var Oe;if(!ne||!he)return[];const Le=!Ne;Le?j(!0):k(!0);try{const Je=Ne?se.current:0,ae=await Ue.sessionMessages(ne,he,Nu,Je,Me);if(!ae.ok)throw new Error("Failed to load session messages");const ye=await ae.json();if(Le&&ye.tokenUsage&&M(ye.tokenUsage),ye.hasMore!==void 0){const Ee=((Oe=ye.messages)==null?void 0:Oe.length)||0;return P(!!ye.hasMore),b(Number(ye.total||0)),se.current=Je+Ee,ye.messages||[]}const $e=ye.messages||[];return P(!1),b($e.length),se.current=$e.length,$e}catch(Je){return console.error("Error loading session messages:",Je),[]}finally{Le?j(!1):k(!1)}},[]),Ae=l.useCallback(async(ne,he)=>{var Ne;if(!ne||!he)return[];j(!0);try{const Me=`/api/cursor/sessions/${encodeURIComponent(he)}?projectPath=${encodeURIComponent(ne)}`,Le=await Te(Me);if(!Le.ok)return[];const Oe=await Le.json(),Je=((Ne=Oe==null?void 0:Oe.session)==null?void 0:Ne.messages)||[];return wu(Je,ne)}catch(Me){return console.error("Error loading Cursor session messages:",Me),[]}finally{j(!1)}},[]),Re=l.useMemo(()=>ju(x),[x]),Ie=l.useCallback(()=>{const ne=V.current;ne&&(ne.scrollTop=ne.scrollHeight)},[]),L=l.useCallback(()=>{Ie(),ie&&(K(es),$(!1),G.current=!1)},[ie,Ie]),ee=l.useCallback(()=>{const ne=V.current;if(!ne)return!1;const{scrollTop:he,scrollHeight:Ne,clientHeight:Me}=ne;return Ne-he-Me<50},[]),ge=l.useCallback(async ne=>{if(!ne||Z.current||v||G.current||!A||!r||!t)return!1;const he=r.__provider||"claude";if(he==="cursor")return!1;Z.current=!0;const Ne=ne.scrollHeight,Me=ne.scrollTop;try{const Le=await we(t.name,r.id,!0,he);return Le.length===0?!1:(I.current={height:Ne,top:Me},y(Oe=>[...Le,...Oe]),K(Oe=>Oe+Le.length),!0)}finally{Z.current=!1}},[A,v,we,t,r]),be=l.useCallback(async()=>{const ne=V.current;if(!ne)return;const he=ee();if(H(!he),!G.current){if(!(ne.scrollTop<100)){w.current=!1;return}if(w.current){ne.scrollTop>20&&(w.current=!1);return}await ge(ne)&&(w.current=!0)}},[ee,ge]);l.useLayoutEffect(()=>{if(!I.current||!V.current)return;const{height:ne,top:he}=I.current,Ne=V.current,Le=Ne.scrollHeight-ne;Ne.scrollTop=he+Math.max(Le,0),I.current=null},[u.length]),l.useEffect(()=>{J.current=!0,w.current=!1,I.current=null,K(es),H(!1)},[t==null?void 0:t.name,r==null?void 0:r.id]),l.useEffect(()=>{if(!(!J.current||!V.current||N)){if(u.length===0){J.current=!1;return}J.current=!1,setTimeout(()=>{Ie()},200)}},[u.length,N,Ie]),l.useEffect(()=>{(async()=>{if(r&&t){const he=localStorage.getItem("selected-provider")||"claude";if(R.current=!0,g!==null&&g!==r.id?(C||(c(),d.current=null,m([]),y([]),q(null),T(!1)),se.current=0,P(!1),b(0),K(es),$(!1),G.current=!1,re(!1),U(!1),F(!1),fe.current&&clearTimeout(fe.current),Ce.current&&clearTimeout(Ce.current),M(null),p(!1),s&&a({type:"check-session-status",sessionId:r.id,provider:he})):g===null&&(se.current=0,P(!1),b(0),s&&a({type:"check-session-status",sessionId:r.id,provider:he})),he==="cursor")if(f(r.id),sessionStorage.setItem("cursorSessionId",r.id),C)E(!1);else{const Me=t.fullPath||t.path||"",Le=await Ae(Me,r.id);y([]),m(Le)}else if(f(r.id),C)E(!1);else{const Me=await we(t.name,r.id,!1,r.__provider||"claude");y(Me)}}else C||(c(),d.current=null,m([]),y([]),q(null),T(!1),p(!1)),f(null),sessionStorage.removeItem("cursorSessionId"),se.current=0,P(!1),b(0),M(null);setTimeout(()=>{R.current=!1},250)})()},[C,Ae,we,d,c,t,r,a,s]),l.useEffect(()=>{if(!o||!r||!t)return;(async()=>{try{if((localStorage.getItem("selected-provider")||"claude")==="cursor"){const Le=t.fullPath||t.path||"",Oe=await Ae(Le,r.id);y([]),m(Oe);return}const Ne=await we(t.name,r.id,!1,r.__provider||"claude");y(Ne),!!n&&ee()&&setTimeout(()=>Ie(),200)}catch(he){console.error("Error reloading messages from external update:",he)}})()},[n,o,ee,Ae,we,Ie,t,r]),l.useEffect(()=>{r!=null&&r.id&&(d.current=null)},[d,r==null?void 0:r.id]),l.useEffect(()=>{x.length>0&&m(Re)},[Re,x.length]),l.useEffect(()=>{t&&u.length>0&&ot.setItem(`chat_messages_${t.name}`,JSON.stringify(u))},[u,t]),l.useEffect(()=>{if(!t||!(r!=null&&r.id)||r.id.startsWith("new-session-")){M(null);return}if((r.__provider||"claude")!=="claude")return;(async()=>{try{const Ne=`/api/projects/${t.name}/sessions/${r.id}/token-usage`,Me=await Te(Ne);if(Me.ok){const Le=await Me.json();M(Le)}else M(null)}catch(Ne){console.error("Failed to fetch initial token usage:",Ne)}})()},[t,r==null?void 0:r.id,r==null?void 0:r.__provider]);const Pe=l.useMemo(()=>u.length<=z?u:u.slice(-z),[u,z]);l.useEffect(()=>{if(!n&&V.current){const ne=V.current;ce.current={height:ne.scrollHeight,top:ne.scrollTop}}}),l.useEffect(()=>{if(!V.current||u.length===0||Z.current||v||I.current)return;if(n){W||setTimeout(()=>Ie(),50);return}const ne=V.current,he=ce.current.height,Ne=ce.current.top,Le=ne.scrollHeight-he;Le>0&&Ne>0&&(ne.scrollTop=Ne+Le)},[n,u.length,v,W,Ie]),l.useEffect(()=>{const ne=V.current;if(ne)return ne.addEventListener("scroll",be),()=>ne.removeEventListener("scroll",be)},[be]),l.useEffect(()=>{const ne=(r==null?void 0:r.id)||g;if(!ne||!i)return;i.has(ne)&&!h&&(p(!0),T(!0))},[g,h,i,r==null?void 0:r.id]);const Fe=l.useRef(!1);l.useEffect(()=>{const ne=Fe.current;return Fe.current=v,ne&&!v&&A&&(fe.current&&clearTimeout(fe.current),F(!0),fe.current=setTimeout(()=>{F(!1)},2e3)),!A&&!v&&(fe.current&&clearTimeout(fe.current),F(!1)),()=>{fe.current&&clearTimeout(fe.current)}},[v,A]);const ze=l.useCallback(async()=>{if(!r||!t||X)return;const ne=r.__provider||"claude";if(ne==="cursor"){K(1/0),$(!0),G.current=!0,U(!0),Ce.current&&clearTimeout(Ce.current),Ce.current=setTimeout(()=>{U(!1),F(!1)},1e3);return}const he=r.id;G.current=!0,Z.current=!0,re(!0),F(!0);const Ne=V.current,Me=Ne?Ne.scrollHeight:0,Le=Ne?Ne.scrollTop:0;try{const Oe=await Ue.sessionMessages(t.name,he,null,0,ne);if(g!==he)return;if(Oe.ok){const Je=await Oe.json(),ae=Je.messages||Je;Ne&&(I.current={height:Me,top:Le}),y(Array.isArray(ae)?ae:[]),P(!1),b(Array.isArray(ae)?ae.length:0),se.current=Array.isArray(ae)?ae.length:0,K(1/0),$(!0),U(!0),Ce.current&&clearTimeout(Ce.current),Ce.current=setTimeout(()=>{U(!1),F(!1)},1e3)}else G.current=!1,F(!1)}catch(Oe){console.error("Error loading all messages:",Oe),G.current=!1,F(!1)}finally{Z.current=!1,re(!1)}},[r,t,X,g]),Ve=l.useCallback(()=>{K(ne=>ne+100)},[]);return{chatMessages:u,setChatMessages:m,isLoading:h,setIsLoading:p,currentSessionId:g,setCurrentSessionId:f,sessionMessages:x,setSessionMessages:y,isLoadingSessionMessages:N,isLoadingMoreMessages:v,hasMoreMessages:A,totalMessages:S,isSystemSessionChange:C,setIsSystemSessionChange:E,canAbortSession:B,setCanAbortSession:T,isUserScrolledUp:W,setIsUserScrolledUp:H,tokenBudget:_,setTokenBudget:M,visibleMessageCount:z,visibleMessages:Pe,loadEarlierMessages:Ve,loadAllMessages:ze,allMessagesLoaded:ie,isLoadingAllMessages:X,loadAllJustFinished:Y,showLoadAllOverlay:O,claudeStatus:te,setClaudeStatus:q,createDiff:_e,scrollContainerRef:V,scrollToBottom:Ie,scrollToBottomAndReset:L,isNearBottom:ee,handleScroll:be,loadSessionMessages:we,loadCursorSessionMessages:Ae}}const ts=(t,r,s=!1)=>{r&&t(a=>{const n=[...a],o=n.length-1,i=n[o];if(i&&i.type==="assistant"&&!i.isToolUse&&i.isStreaming){const c=s?i.content?`${i.content}
139
+ ${r}`:r:`${i.content||""}${r}`;n[o]={...i,content:c}}else n.push({type:"assistant",content:r,timestamp:new Date,isStreaming:!0});return n})},Su=t=>{t(r=>{const s=[...r],a=s.length-1,n=s[a];return n&&n.type==="assistant"&&n.isStreaming&&(s[a]={...n,isStreaming:!1}),s})};function Eu({latestMessage:t,provider:r,selectedProject:s,selectedSession:a,currentSessionId:n,setCurrentSessionId:o,setChatMessages:i,setIsLoading:c,setCanAbortSession:d,setClaudeStatus:u,setTokenBudget:m,setIsSystemSessionChange:h,setPendingPermissionRequests:p,pendingViewSessionRef:g,streamBufferRef:f,streamTimerRef:x,onSessionInactive:y,onSessionProcessing:N,onSessionNotProcessing:j,onReplaceTemporarySession:v,onNavigateToSession:k,onResponseComplete:A}){const P=l.useRef(null);l.useEffect(()=>{var re,Y,U,O,F,V,R,Z,G;if(!t||P.current===t)return;P.current=t;const S=((re=t.data)==null?void 0:re.message)||t.data,b=S&&typeof S=="object"?S:null,C=t.data&&typeof t.data=="object"?t.data:null,B=["projects_updated","taskmaster-project-updated","session-created"].includes(String(t.type)),T=new Set(["claude-complete","codex-complete","cursor-result","session-aborted","claude-error","cursor-error","codex-error"]),W=t.type==="claude-response"&&b&&b.type==="system"&&b.subtype==="init",H=t.type==="cursor-system"&&C&&C.type==="system"&&C.subtype==="init",_=W?b==null?void 0:b.session_id:H?C==null?void 0:C.session_id:null,M=(a==null?void 0:a.id)||n||((Y=g.current)==null?void 0:Y.sessionId)||null,z=_&&(!M||_===M),K=B||!!z,te=!t.sessionId&&g.current&&!g.current.sessionId&&(t.type==="claude-error"||t.type==="cursor-error"||t.type==="codex-error"),q=w=>{w&&(y==null||y(w),j==null||j(w))},ie=(...w)=>Array.from(new Set(w.filter(I=>typeof I=="string"&&I.length>0))),$=()=>{c(!1),d(!1),u(null)},X=(...w)=>{ie(...w).forEach(J=>{y==null||y(J),j==null||j(J)})};if(!K){if(!M&&(t.sessionId&&T.has(String(t.type))&&q(t.sessionId),!te)||!t.sessionId&&!te)return;if(t.sessionId!==M){t.sessionId&&T.has(String(t.type))&&q(t.sessionId);return}}switch(t.type){case"session-created":t.sessionId&&!n&&(sessionStorage.setItem("pendingSessionId",t.sessionId),g.current&&!g.current.sessionId&&(g.current.sessionId=t.sessionId),h(!0),v==null||v(t.sessionId),p(w=>w.map(I=>I.sessionId?I:{...I,sessionId:t.sessionId})));break;case"relay-session-id":{const w=t.cliSessionId;w&&(o(w),sessionStorage.setItem("pendingSessionId",w));break}case"session-busy":case"session-lock-denied":{$();const w=t.error||"Session is busy. Wait for the current request to finish.";i(I=>[...I,{type:"system",content:w,timestamp:new Date().toISOString()}]);break}case"token-budget":t.data&&m(t.data);break;case"claude-response":{if(S&&typeof S=="object"&&S.type){if(S.type==="content_block_delta"&&((U=S.delta)!=null&&U.text)){const w=Tt(S.delta.text);f.current+=w,x.current||(x.current=window.setTimeout(()=>{const I=f.current;f.current="",x.current=null,ts(i,I,!1)},100));return}if(S.type==="content_block_stop"){x.current&&(clearTimeout(x.current),x.current=null);const w=f.current;f.current="",ts(i,w,!1),Su(i);return}}if((b==null?void 0:b.type)==="system"&&b.subtype==="init"&&b.session_id&&n&&b.session_id!==n&&z){h(!0),k==null||k(b.session_id);return}if((b==null?void 0:b.type)==="system"&&b.subtype==="init"&&b.session_id&&!n&&z){h(!0),k==null||k(b.session_id);return}if((b==null?void 0:b.type)==="system"&&b.subtype==="init"&&b.session_id&&n&&b.session_id===n&&z)return;if(b&&Array.isArray(b.content)){const w=C==null?void 0:C.parentToolUseId;b.content.forEach(I=>{var J;if(I.type==="tool_use"){const se=I.input?JSON.stringify(I.input,null,2):"";if(w){i(Ce=>Ce.map(fe=>{var _e;if(fe.toolId===w&&fe.isSubagentContainer){const we={toolId:I.id,toolName:I.name,toolInput:I.input,toolResult:null,timestamp:new Date},Ae=((_e=fe.subagentState)==null?void 0:_e.childTools)||[];return{...fe,subagentState:{childTools:[...Ae,we],currentToolIndex:Ae.length,isComplete:!1}}}return fe}));return}const ce=I.name==="Task";i(Ce=>[...Ce,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:I.name,toolInput:se,toolId:I.id,toolResult:null,isSubagentContainer:ce,subagentState:ce?{childTools:[],currentToolIndex:-1,isComplete:!1}:void 0}]);return}if(I.type==="text"&&((J=I.text)!=null&&J.trim())){let se=Tt(I.text);se=sa(se),i(ce=>[...ce,{type:"assistant",content:se,timestamp:new Date}])}})}else if(b&&typeof b.content=="string"&&b.content.trim()){let w=Tt(b.content);w=sa(w),i(I=>[...I,{type:"assistant",content:w,timestamp:new Date}])}if((b==null?void 0:b.role)==="user"&&Array.isArray(b.content)){const w=C==null?void 0:C.parentToolUseId;b.content.forEach(I=>{I.type==="tool_result"&&i(J=>J.map(se=>{if(w&&se.toolId===w&&se.isSubagentContainer)return{...se,subagentState:{...se.subagentState,childTools:se.subagentState.childTools.map(ce=>ce.toolId===I.tool_use_id?{...ce,toolResult:{content:I.content,isError:I.is_error,timestamp:new Date}}:ce)}};if(se.isToolUse&&se.toolId===I.tool_use_id){const ce={...se,toolResult:{content:I.content,isError:I.is_error,timestamp:new Date}};return se.isSubagentContainer&&se.subagentState&&(ce.subagentState={...se.subagentState,isComplete:!0}),ce}return se}))})}break}case"claude-output":{const w=String(t.data||"");w.trim()&&(f.current+=f.current?`
140
+ ${w}`:w,x.current||(x.current=window.setTimeout(()=>{const I=f.current;f.current="",x.current=null,ts(i,I,!0)},100)));break}case"claude-interactive-prompt":{const w=typeof t.data=="string"?t.data:JSON.stringify(t.data??"",null,2);i(I=>[...I,{type:"assistant",content:w,timestamp:new Date,isInteractivePrompt:!0}])}break;case"claude-permission-request":if(r!=="claude"||!t.requestId)break;{const w=t.requestId;p(I=>I.some(J=>J.requestId===w)?I:[...I,{requestId:w,toolName:t.toolName||"UnknownTool",input:t.input,context:t.context,sessionId:t.sessionId||null,receivedAt:new Date}])}c(!0),d(!0),u({text:"Waiting for permission",tokens:0,can_interrupt:!0});break;case"claude-permission-cancelled":if(!t.requestId)break;p(w=>w.filter(I=>I.requestId!==t.requestId));break;case"claude-error":i(w=>[...w,{type:"error",content:`Error: ${t.error}`,timestamp:new Date}]);break;case"cursor-system":try{const w=t.data;if(w&&w.type==="system"&&w.subtype==="init"&&w.session_id){if(!z)return;if(n&&w.session_id!==n){h(!0),k==null||k(w.session_id);return}if(!n){h(!0),k==null||k(w.session_id);return}}}catch{}break;case"cursor-user":break;case"cursor-tool-use":i(w=>[...w,{type:"assistant",content:`Using tool: ${t.tool} ${t.input?`with ${t.input}`:""}`,timestamp:new Date,isToolUse:!0,toolName:t.tool,toolInput:t.input}]);break;case"cursor-error":i(w=>[...w,{type:"error",content:`Cursor error: ${t.error||"Unknown error"}`,timestamp:new Date}]);break;case"cursor-result":{const w=t.sessionId||n,I=sessionStorage.getItem("pendingSessionId");$(),X(w,n,a==null?void 0:a.id,I);try{const J=t.data||{},se=typeof J.result=="string"?J.result:"";x.current&&(clearTimeout(x.current),x.current=null);const ce=f.current;f.current="",i(Ce=>{const fe=[...Ce],_e=fe.length-1,we=fe[_e];if(we&&we.type==="assistant"&&!we.isToolUse&&we.isStreaming){const Ae=se&&se.trim()?se:`${we.content||""}${ce||""}`;fe[_e]={...we,content:Ae,isStreaming:!1}}else se&&se.trim()&&fe.push({type:J.is_error?"error":"assistant",content:se,timestamp:new Date,isStreaming:!1});return fe})}catch{}w&&!n&&w===I&&(o(w),sessionStorage.removeItem("pendingSessionId"),window.refreshProjects&&setTimeout(()=>{var J;return(J=window.refreshProjects)==null?void 0:J.call(window)},500));break}case"cursor-output":try{const I=String(t.data??"").replace(/\x1b\[[0-9;?]*[A-Za-z]/g,"").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"").trim();I&&(f.current+=f.current?`
141
+ ${I}`:I,x.current||(x.current=window.setTimeout(()=>{const J=f.current;f.current="",x.current=null,ts(i,J,!0)},100)))}catch{}break;case"claude-complete":{const w=sessionStorage.getItem("pendingSessionId"),I=t.sessionId||n||w;$(),X(I,n,a==null?void 0:a.id,w),w&&!n&&t.exitCode===0&&(o(w),sessionStorage.removeItem("pendingSessionId")),s&&t.exitCode===0&&ot.removeItem(`chat_messages_${s.name}`),p([]),A&&i(J=>{for(let se=J.length-1;se>=0;se--)if(J[se].type==="assistant"&&J[se].content&&!J[se].isToolUse){A(J[se].content||"");break}return J});break}case"codex-response":{const w=t.data;if(!w)break;if(w.type==="item")switch(w.itemType){case"agent_message":if((F=(O=w.message)==null?void 0:O.content)!=null&&F.trim()){const I=Tt(w.message.content);Ir(I)||i(J=>[...J,{type:"assistant",content:I,timestamp:new Date}])}break;case"reasoning":if((R=(V=w.message)==null?void 0:V.content)!=null&&R.trim()){const I=Tt(w.message.content);i(J=>[...J,{type:"assistant",content:I,timestamp:new Date,isThinking:!0}])}break;case"command_execution":w.command&&i(I=>[...I,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"Bash",toolInput:w.command,toolResult:w.output||null,exitCode:w.exitCode}]);break;case"file_change":if(((Z=w.changes)==null?void 0:Z.length)>0){const I=w.changes.map(J=>`${J.kind}: ${J.path}`).join(`
142
+ `);i(J=>[...J,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:"FileChanges",toolInput:I,toolResult:{content:`Status: ${w.status}`,isError:!1}}])}break;case"mcp_tool_call":i(I=>{var J;return[...I,{type:"assistant",content:"",timestamp:new Date,isToolUse:!0,toolName:`${w.server}:${w.tool}`,toolInput:JSON.stringify(w.arguments,null,2),toolResult:w.result?JSON.stringify(w.result,null,2):((J=w.error)==null?void 0:J.message)||null}]});break;case"error":(G=w.message)!=null&&G.content&&i(I=>[...I,{type:"error",content:w.message.content,timestamp:new Date}]);break}w.type==="turn_complete"&&($(),X(t.sessionId,n,a==null?void 0:a.id)),w.type==="turn_failed"&&($(),X(t.sessionId,n,a==null?void 0:a.id),i(I=>{var J;return[...I,{type:"error",content:((J=w.error)==null?void 0:J.message)||"Turn failed",timestamp:new Date}]}));break}case"codex-complete":{const w=sessionStorage.getItem("pendingSessionId"),I=t.actualSessionId||w,J=t.sessionId||n||w;$(),X(J,I,n,a==null?void 0:a.id,w),w&&!n&&(o(I),h(!0),I&&(k==null||k(I)),sessionStorage.removeItem("pendingSessionId")),s&&ot.removeItem(`chat_messages_${s.name}`);break}case"codex-error":c(!1),d(!1),i(w=>[...w,{type:"error",content:t.error||"An error occurred with Codex",timestamp:new Date}]);break;case"session-aborted":{const w=typeof window<"u"?sessionStorage.getItem("pendingSessionId"):null,I=t.sessionId||n;t.success!==!1?($(),X(I,n,a==null?void 0:a.id,w),w&&(!I||w===I)&&sessionStorage.removeItem("pendingSessionId"),p([]),i(se=>[...se,{type:"assistant",content:"Session interrupted by user.",timestamp:new Date}])):i(se=>[...se,{type:"error",content:"Stop request failed. The session is still running.",timestamp:new Date}]);break}case"session-status":{const w=t.sessionId;(w===n||a&&w===a.id)&&t.isProcessing&&(c(!0),d(!0),N==null||N(w));break}case"claude-status":{const w=t.data;if(!w)break;const I={text:"Working...",tokens:0,can_interrupt:!0};w.message?I.text=w.message:w.status?I.text=w.status:typeof w=="string"&&(I.text=w),w.tokens?I.tokens=w.tokens:w.token_count&&(I.tokens=w.token_count),w.can_interrupt!==void 0&&(I.can_interrupt=w.can_interrupt),u(I),c(!0),d(I.can_interrupt);break}case"shell-exec-output":{c(!1),d(!1),u(null);const w=t.output||"(no output)",I=t.exitCode,se=t.status==="error"||I&&I!==0;i(ce=>[...ce,{type:se?"error":"assistant",content:"```\n"+w+"\n```"+(I?`
143
+
144
+ Exit code: ${I}`:""),timestamp:new Date}]);break}}},[t,r,s,a,n,o,i,c,d,u,m,h,p,y,N,j,v,k])}var Gs={exports:{}},Vs,hn;function Tu(){if(hn)return Vs;hn=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Vs=t,Vs}var qs,fn;function Au(){if(fn)return qs;fn=1;var t=Tu();function r(){}function s(){}return s.resetWarningCache=r,qs=function(){function a(i,c,d,u,m,h){if(h!==t){var p=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw p.name="Invariant Violation",p}}a.isRequired=a;function n(){return a}var o={array:a,bigint:a,bool:a,func:a,number:a,object:a,string:a,symbol:a,any:a,arrayOf:n,element:a,elementType:a,instanceOf:n,node:a,objectOf:n,oneOf:n,oneOfType:n,shape:n,exact:n,checkPropTypes:s,resetWarningCache:r};return o.PropTypes=o,o},qs}var bn;function Iu(){return bn||(bn=1,Gs.exports=Au()()),Gs.exports}var Mu=Iu();const Ge=eo(Mu);function or(t,r,s,a){function n(o){return o instanceof s?o:new s(function(i){i(o)})}return new(s||(s=Promise))(function(o,i){function c(m){try{u(a.next(m))}catch(h){i(h)}}function d(m){try{u(a.throw(m))}catch(h){i(h)}}function u(m){m.done?o(m.value):n(m.value).then(c,d)}u((a=a.apply(t,r||[])).next())})}const Du=new Map([["1km","application/vnd.1000minds.decision-model+xml"],["3dml","text/vnd.in3d.3dml"],["3ds","image/x-3ds"],["3g2","video/3gpp2"],["3gp","video/3gp"],["3gpp","video/3gpp"],["3mf","model/3mf"],["7z","application/x-7z-compressed"],["7zip","application/x-7z-compressed"],["123","application/vnd.lotus-1-2-3"],["aab","application/x-authorware-bin"],["aac","audio/x-acc"],["aam","application/x-authorware-map"],["aas","application/x-authorware-seg"],["abw","application/x-abiword"],["ac","application/vnd.nokia.n-gage.ac+xml"],["ac3","audio/ac3"],["acc","application/vnd.americandynamics.acc"],["ace","application/x-ace-compressed"],["acu","application/vnd.acucobol"],["acutc","application/vnd.acucorp"],["adp","audio/adpcm"],["aep","application/vnd.audiograph"],["afm","application/x-font-type1"],["afp","application/vnd.ibm.modcap"],["ahead","application/vnd.ahead.space"],["ai","application/pdf"],["aif","audio/x-aiff"],["aifc","audio/x-aiff"],["aiff","audio/x-aiff"],["air","application/vnd.adobe.air-application-installer-package+zip"],["ait","application/vnd.dvb.ait"],["ami","application/vnd.amiga.ami"],["amr","audio/amr"],["apk","application/vnd.android.package-archive"],["apng","image/apng"],["appcache","text/cache-manifest"],["application","application/x-ms-application"],["apr","application/vnd.lotus-approach"],["arc","application/x-freearc"],["arj","application/x-arj"],["asc","application/pgp-signature"],["asf","video/x-ms-asf"],["asm","text/x-asm"],["aso","application/vnd.accpac.simply.aso"],["asx","video/x-ms-asf"],["atc","application/vnd.acucorp"],["atom","application/atom+xml"],["atomcat","application/atomcat+xml"],["atomdeleted","application/atomdeleted+xml"],["atomsvc","application/atomsvc+xml"],["atx","application/vnd.antix.game-component"],["au","audio/x-au"],["avi","video/x-msvideo"],["avif","image/avif"],["aw","application/applixware"],["azf","application/vnd.airzip.filesecure.azf"],["azs","application/vnd.airzip.filesecure.azs"],["azv","image/vnd.airzip.accelerator.azv"],["azw","application/vnd.amazon.ebook"],["b16","image/vnd.pco.b16"],["bat","application/x-msdownload"],["bcpio","application/x-bcpio"],["bdf","application/x-font-bdf"],["bdm","application/vnd.syncml.dm+wbxml"],["bdoc","application/x-bdoc"],["bed","application/vnd.realvnc.bed"],["bh2","application/vnd.fujitsu.oasysprs"],["bin","application/octet-stream"],["blb","application/x-blorb"],["blorb","application/x-blorb"],["bmi","application/vnd.bmi"],["bmml","application/vnd.balsamiq.bmml+xml"],["bmp","image/bmp"],["book","application/vnd.framemaker"],["box","application/vnd.previewsystems.box"],["boz","application/x-bzip2"],["bpk","application/octet-stream"],["bpmn","application/octet-stream"],["bsp","model/vnd.valve.source.compiled-map"],["btif","image/prs.btif"],["buffer","application/octet-stream"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["c","text/x-c"],["c4d","application/vnd.clonk.c4group"],["c4f","application/vnd.clonk.c4group"],["c4g","application/vnd.clonk.c4group"],["c4p","application/vnd.clonk.c4group"],["c4u","application/vnd.clonk.c4group"],["c11amc","application/vnd.cluetrust.cartomobile-config"],["c11amz","application/vnd.cluetrust.cartomobile-config-pkg"],["cab","application/vnd.ms-cab-compressed"],["caf","audio/x-caf"],["cap","application/vnd.tcpdump.pcap"],["car","application/vnd.curl.car"],["cat","application/vnd.ms-pki.seccat"],["cb7","application/x-cbr"],["cba","application/x-cbr"],["cbr","application/x-cbr"],["cbt","application/x-cbr"],["cbz","application/x-cbr"],["cc","text/x-c"],["cco","application/x-cocoa"],["cct","application/x-director"],["ccxml","application/ccxml+xml"],["cdbcmsg","application/vnd.contact.cmsg"],["cda","application/x-cdf"],["cdf","application/x-netcdf"],["cdfx","application/cdfx+xml"],["cdkey","application/vnd.mediastation.cdkey"],["cdmia","application/cdmi-capability"],["cdmic","application/cdmi-container"],["cdmid","application/cdmi-domain"],["cdmio","application/cdmi-object"],["cdmiq","application/cdmi-queue"],["cdr","application/cdr"],["cdx","chemical/x-cdx"],["cdxml","application/vnd.chemdraw+xml"],["cdy","application/vnd.cinderella"],["cer","application/pkix-cert"],["cfs","application/x-cfs-compressed"],["cgm","image/cgm"],["chat","application/x-chat"],["chm","application/vnd.ms-htmlhelp"],["chrt","application/vnd.kde.kchart"],["cif","chemical/x-cif"],["cii","application/vnd.anser-web-certificate-issue-initiation"],["cil","application/vnd.ms-artgalry"],["cjs","application/node"],["cla","application/vnd.claymore"],["class","application/octet-stream"],["clkk","application/vnd.crick.clicker.keyboard"],["clkp","application/vnd.crick.clicker.palette"],["clkt","application/vnd.crick.clicker.template"],["clkw","application/vnd.crick.clicker.wordbank"],["clkx","application/vnd.crick.clicker"],["clp","application/x-msclip"],["cmc","application/vnd.cosmocaller"],["cmdf","chemical/x-cmdf"],["cml","chemical/x-cml"],["cmp","application/vnd.yellowriver-custom-menu"],["cmx","image/x-cmx"],["cod","application/vnd.rim.cod"],["coffee","text/coffeescript"],["com","application/x-msdownload"],["conf","text/plain"],["cpio","application/x-cpio"],["cpp","text/x-c"],["cpt","application/mac-compactpro"],["crd","application/x-mscardfile"],["crl","application/pkix-crl"],["crt","application/x-x509-ca-cert"],["crx","application/x-chrome-extension"],["cryptonote","application/vnd.rig.cryptonote"],["csh","application/x-csh"],["csl","application/vnd.citationstyles.style+xml"],["csml","chemical/x-csml"],["csp","application/vnd.commonspace"],["csr","application/octet-stream"],["css","text/css"],["cst","application/x-director"],["csv","text/csv"],["cu","application/cu-seeme"],["curl","text/vnd.curl"],["cww","application/prs.cww"],["cxt","application/x-director"],["cxx","text/x-c"],["dae","model/vnd.collada+xml"],["daf","application/vnd.mobius.daf"],["dart","application/vnd.dart"],["dataless","application/vnd.fdsn.seed"],["davmount","application/davmount+xml"],["dbf","application/vnd.dbf"],["dbk","application/docbook+xml"],["dcr","application/x-director"],["dcurl","text/vnd.curl.dcurl"],["dd2","application/vnd.oma.dd2+xml"],["ddd","application/vnd.fujixerox.ddd"],["ddf","application/vnd.syncml.dmddf+xml"],["dds","image/vnd.ms-dds"],["deb","application/x-debian-package"],["def","text/plain"],["deploy","application/octet-stream"],["der","application/x-x509-ca-cert"],["dfac","application/vnd.dreamfactory"],["dgc","application/x-dgc-compressed"],["dic","text/x-c"],["dir","application/x-director"],["dis","application/vnd.mobius.dis"],["disposition-notification","message/disposition-notification"],["dist","application/octet-stream"],["distz","application/octet-stream"],["djv","image/vnd.djvu"],["djvu","image/vnd.djvu"],["dll","application/octet-stream"],["dmg","application/x-apple-diskimage"],["dmn","application/octet-stream"],["dmp","application/vnd.tcpdump.pcap"],["dms","application/octet-stream"],["dna","application/vnd.dna"],["doc","application/msword"],["docm","application/vnd.ms-word.template.macroEnabled.12"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["dot","application/msword"],["dotm","application/vnd.ms-word.template.macroEnabled.12"],["dotx","application/vnd.openxmlformats-officedocument.wordprocessingml.template"],["dp","application/vnd.osgi.dp"],["dpg","application/vnd.dpgraph"],["dra","audio/vnd.dra"],["drle","image/dicom-rle"],["dsc","text/prs.lines.tag"],["dssc","application/dssc+der"],["dtb","application/x-dtbook+xml"],["dtd","application/xml-dtd"],["dts","audio/vnd.dts"],["dtshd","audio/vnd.dts.hd"],["dump","application/octet-stream"],["dvb","video/vnd.dvb.file"],["dvi","application/x-dvi"],["dwd","application/atsc-dwd+xml"],["dwf","model/vnd.dwf"],["dwg","image/vnd.dwg"],["dxf","image/vnd.dxf"],["dxp","application/vnd.spotfire.dxp"],["dxr","application/x-director"],["ear","application/java-archive"],["ecelp4800","audio/vnd.nuera.ecelp4800"],["ecelp7470","audio/vnd.nuera.ecelp7470"],["ecelp9600","audio/vnd.nuera.ecelp9600"],["ecma","application/ecmascript"],["edm","application/vnd.novadigm.edm"],["edx","application/vnd.novadigm.edx"],["efif","application/vnd.picsel"],["ei6","application/vnd.pg.osasli"],["elc","application/octet-stream"],["emf","image/emf"],["eml","message/rfc822"],["emma","application/emma+xml"],["emotionml","application/emotionml+xml"],["emz","application/x-msmetafile"],["eol","audio/vnd.digital-winds"],["eot","application/vnd.ms-fontobject"],["eps","application/postscript"],["epub","application/epub+zip"],["es","application/ecmascript"],["es3","application/vnd.eszigno3+xml"],["esa","application/vnd.osgi.subsystem"],["esf","application/vnd.epson.esf"],["et3","application/vnd.eszigno3+xml"],["etx","text/x-setext"],["eva","application/x-eva"],["evy","application/x-envoy"],["exe","application/octet-stream"],["exi","application/exi"],["exp","application/express"],["exr","image/aces"],["ext","application/vnd.novadigm.ext"],["ez","application/andrew-inset"],["ez2","application/vnd.ezpix-album"],["ez3","application/vnd.ezpix-package"],["f","text/x-fortran"],["f4v","video/mp4"],["f77","text/x-fortran"],["f90","text/x-fortran"],["fbs","image/vnd.fastbidsheet"],["fcdt","application/vnd.adobe.formscentral.fcdt"],["fcs","application/vnd.isac.fcs"],["fdf","application/vnd.fdf"],["fdt","application/fdt+xml"],["fe_launch","application/vnd.denovo.fcselayout-link"],["fg5","application/vnd.fujitsu.oasysgp"],["fgd","application/x-director"],["fh","image/x-freehand"],["fh4","image/x-freehand"],["fh5","image/x-freehand"],["fh7","image/x-freehand"],["fhc","image/x-freehand"],["fig","application/x-xfig"],["fits","image/fits"],["flac","audio/x-flac"],["fli","video/x-fli"],["flo","application/vnd.micrografx.flo"],["flv","video/x-flv"],["flw","application/vnd.kde.kivio"],["flx","text/vnd.fmi.flexstor"],["fly","text/vnd.fly"],["fm","application/vnd.framemaker"],["fnc","application/vnd.frogans.fnc"],["fo","application/vnd.software602.filler.form+xml"],["for","text/x-fortran"],["fpx","image/vnd.fpx"],["frame","application/vnd.framemaker"],["fsc","application/vnd.fsc.weblaunch"],["fst","image/vnd.fst"],["ftc","application/vnd.fluxtime.clip"],["fti","application/vnd.anser-web-funds-transfer-initiation"],["fvt","video/vnd.fvt"],["fxp","application/vnd.adobe.fxp"],["fxpl","application/vnd.adobe.fxp"],["fzs","application/vnd.fuzzysheet"],["g2w","application/vnd.geoplan"],["g3","image/g3fax"],["g3w","application/vnd.geospace"],["gac","application/vnd.groove-account"],["gam","application/x-tads"],["gbr","application/rpki-ghostbusters"],["gca","application/x-gca-compressed"],["gdl","model/vnd.gdl"],["gdoc","application/vnd.google-apps.document"],["geo","application/vnd.dynageo"],["geojson","application/geo+json"],["gex","application/vnd.geometry-explorer"],["ggb","application/vnd.geogebra.file"],["ggt","application/vnd.geogebra.tool"],["ghf","application/vnd.groove-help"],["gif","image/gif"],["gim","application/vnd.groove-identity-message"],["glb","model/gltf-binary"],["gltf","model/gltf+json"],["gml","application/gml+xml"],["gmx","application/vnd.gmx"],["gnumeric","application/x-gnumeric"],["gpg","application/gpg-keys"],["gph","application/vnd.flographit"],["gpx","application/gpx+xml"],["gqf","application/vnd.grafeq"],["gqs","application/vnd.grafeq"],["gram","application/srgs"],["gramps","application/x-gramps-xml"],["gre","application/vnd.geometry-explorer"],["grv","application/vnd.groove-injector"],["grxml","application/srgs+xml"],["gsf","application/x-font-ghostscript"],["gsheet","application/vnd.google-apps.spreadsheet"],["gslides","application/vnd.google-apps.presentation"],["gtar","application/x-gtar"],["gtm","application/vnd.groove-tool-message"],["gtw","model/vnd.gtw"],["gv","text/vnd.graphviz"],["gxf","application/gxf"],["gxt","application/vnd.geonext"],["gz","application/gzip"],["gzip","application/gzip"],["h","text/x-c"],["h261","video/h261"],["h263","video/h263"],["h264","video/h264"],["hal","application/vnd.hal+xml"],["hbci","application/vnd.hbci"],["hbs","text/x-handlebars-template"],["hdd","application/x-virtualbox-hdd"],["hdf","application/x-hdf"],["heic","image/heic"],["heics","image/heic-sequence"],["heif","image/heif"],["heifs","image/heif-sequence"],["hej2","image/hej2k"],["held","application/atsc-held+xml"],["hh","text/x-c"],["hjson","application/hjson"],["hlp","application/winhlp"],["hpgl","application/vnd.hp-hpgl"],["hpid","application/vnd.hp-hpid"],["hps","application/vnd.hp-hps"],["hqx","application/mac-binhex40"],["hsj2","image/hsj2"],["htc","text/x-component"],["htke","application/vnd.kenameaapp"],["htm","text/html"],["html","text/html"],["hvd","application/vnd.yamaha.hv-dic"],["hvp","application/vnd.yamaha.hv-voice"],["hvs","application/vnd.yamaha.hv-script"],["i2g","application/vnd.intergeo"],["icc","application/vnd.iccprofile"],["ice","x-conference/x-cooltalk"],["icm","application/vnd.iccprofile"],["ico","image/x-icon"],["ics","text/calendar"],["ief","image/ief"],["ifb","text/calendar"],["ifm","application/vnd.shana.informed.formdata"],["iges","model/iges"],["igl","application/vnd.igloader"],["igm","application/vnd.insors.igm"],["igs","model/iges"],["igx","application/vnd.micrografx.igx"],["iif","application/vnd.shana.informed.interchange"],["img","application/octet-stream"],["imp","application/vnd.accpac.simply.imp"],["ims","application/vnd.ms-ims"],["in","text/plain"],["ini","text/plain"],["ink","application/inkml+xml"],["inkml","application/inkml+xml"],["install","application/x-install-instructions"],["iota","application/vnd.astraea-software.iota"],["ipfix","application/ipfix"],["ipk","application/vnd.shana.informed.package"],["irm","application/vnd.ibm.rights-management"],["irp","application/vnd.irepository.package+xml"],["iso","application/x-iso9660-image"],["itp","application/vnd.shana.informed.formtemplate"],["its","application/its+xml"],["ivp","application/vnd.immervision-ivp"],["ivu","application/vnd.immervision-ivu"],["jad","text/vnd.sun.j2me.app-descriptor"],["jade","text/jade"],["jam","application/vnd.jam"],["jar","application/java-archive"],["jardiff","application/x-java-archive-diff"],["java","text/x-java-source"],["jhc","image/jphc"],["jisp","application/vnd.jisp"],["jls","image/jls"],["jlt","application/vnd.hp-jlyt"],["jng","image/x-jng"],["jnlp","application/x-java-jnlp-file"],["joda","application/vnd.joost.joda-archive"],["jp2","image/jp2"],["jpe","image/jpeg"],["jpeg","image/jpeg"],["jpf","image/jpx"],["jpg","image/jpeg"],["jpg2","image/jp2"],["jpgm","video/jpm"],["jpgv","video/jpeg"],["jph","image/jph"],["jpm","video/jpm"],["jpx","image/jpx"],["js","application/javascript"],["json","application/json"],["json5","application/json5"],["jsonld","application/ld+json"],["jsonl","application/jsonl"],["jsonml","application/jsonml+json"],["jsx","text/jsx"],["jxr","image/jxr"],["jxra","image/jxra"],["jxrs","image/jxrs"],["jxs","image/jxs"],["jxsc","image/jxsc"],["jxsi","image/jxsi"],["jxss","image/jxss"],["kar","audio/midi"],["karbon","application/vnd.kde.karbon"],["kdb","application/octet-stream"],["kdbx","application/x-keepass2"],["key","application/x-iwork-keynote-sffkey"],["kfo","application/vnd.kde.kformula"],["kia","application/vnd.kidspiration"],["kml","application/vnd.google-earth.kml+xml"],["kmz","application/vnd.google-earth.kmz"],["kne","application/vnd.kinar"],["knp","application/vnd.kinar"],["kon","application/vnd.kde.kontour"],["kpr","application/vnd.kde.kpresenter"],["kpt","application/vnd.kde.kpresenter"],["kpxx","application/vnd.ds-keypoint"],["ksp","application/vnd.kde.kspread"],["ktr","application/vnd.kahootz"],["ktx","image/ktx"],["ktx2","image/ktx2"],["ktz","application/vnd.kahootz"],["kwd","application/vnd.kde.kword"],["kwt","application/vnd.kde.kword"],["lasxml","application/vnd.las.las+xml"],["latex","application/x-latex"],["lbd","application/vnd.llamagraphics.life-balance.desktop"],["lbe","application/vnd.llamagraphics.life-balance.exchange+xml"],["les","application/vnd.hhe.lesson-player"],["less","text/less"],["lgr","application/lgr+xml"],["lha","application/octet-stream"],["link66","application/vnd.route66.link66+xml"],["list","text/plain"],["list3820","application/vnd.ibm.modcap"],["listafp","application/vnd.ibm.modcap"],["litcoffee","text/coffeescript"],["lnk","application/x-ms-shortcut"],["log","text/plain"],["lostxml","application/lost+xml"],["lrf","application/octet-stream"],["lrm","application/vnd.ms-lrm"],["ltf","application/vnd.frogans.ltf"],["lua","text/x-lua"],["luac","application/x-lua-bytecode"],["lvp","audio/vnd.lucent.voice"],["lwp","application/vnd.lotus-wordpro"],["lzh","application/octet-stream"],["m1v","video/mpeg"],["m2a","audio/mpeg"],["m2v","video/mpeg"],["m3a","audio/mpeg"],["m3u","text/plain"],["m3u8","application/vnd.apple.mpegurl"],["m4a","audio/x-m4a"],["m4p","application/mp4"],["m4s","video/iso.segment"],["m4u","application/vnd.mpegurl"],["m4v","video/x-m4v"],["m13","application/x-msmediaview"],["m14","application/x-msmediaview"],["m21","application/mp21"],["ma","application/mathematica"],["mads","application/mads+xml"],["maei","application/mmt-aei+xml"],["mag","application/vnd.ecowin.chart"],["maker","application/vnd.framemaker"],["man","text/troff"],["manifest","text/cache-manifest"],["map","application/json"],["mar","application/octet-stream"],["markdown","text/markdown"],["mathml","application/mathml+xml"],["mb","application/mathematica"],["mbk","application/vnd.mobius.mbk"],["mbox","application/mbox"],["mc1","application/vnd.medcalcdata"],["mcd","application/vnd.mcd"],["mcurl","text/vnd.curl.mcurl"],["md","text/markdown"],["mdb","application/x-msaccess"],["mdi","image/vnd.ms-modi"],["mdx","text/mdx"],["me","text/troff"],["mesh","model/mesh"],["meta4","application/metalink4+xml"],["metalink","application/metalink+xml"],["mets","application/mets+xml"],["mfm","application/vnd.mfmp"],["mft","application/rpki-manifest"],["mgp","application/vnd.osgeo.mapguide.package"],["mgz","application/vnd.proteus.magazine"],["mid","audio/midi"],["midi","audio/midi"],["mie","application/x-mie"],["mif","application/vnd.mif"],["mime","message/rfc822"],["mj2","video/mj2"],["mjp2","video/mj2"],["mjs","application/javascript"],["mk3d","video/x-matroska"],["mka","audio/x-matroska"],["mkd","text/x-markdown"],["mks","video/x-matroska"],["mkv","video/x-matroska"],["mlp","application/vnd.dolby.mlp"],["mmd","application/vnd.chipnuts.karaoke-mmd"],["mmf","application/vnd.smaf"],["mml","text/mathml"],["mmr","image/vnd.fujixerox.edmics-mmr"],["mng","video/x-mng"],["mny","application/x-msmoney"],["mobi","application/x-mobipocket-ebook"],["mods","application/mods+xml"],["mov","video/quicktime"],["movie","video/x-sgi-movie"],["mp2","audio/mpeg"],["mp2a","audio/mpeg"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mp4a","audio/mp4"],["mp4s","application/mp4"],["mp4v","video/mp4"],["mp21","application/mp21"],["mpc","application/vnd.mophun.certificate"],["mpd","application/dash+xml"],["mpe","video/mpeg"],["mpeg","video/mpeg"],["mpg","video/mpeg"],["mpg4","video/mp4"],["mpga","audio/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["mpm","application/vnd.blueice.multipass"],["mpn","application/vnd.mophun.application"],["mpp","application/vnd.ms-project"],["mpt","application/vnd.ms-project"],["mpy","application/vnd.ibm.minipay"],["mqy","application/vnd.mobius.mqy"],["mrc","application/marc"],["mrcx","application/marcxml+xml"],["ms","text/troff"],["mscml","application/mediaservercontrol+xml"],["mseed","application/vnd.fdsn.mseed"],["mseq","application/vnd.mseq"],["msf","application/vnd.epson.msf"],["msg","application/vnd.ms-outlook"],["msh","model/mesh"],["msi","application/x-msdownload"],["msl","application/vnd.mobius.msl"],["msm","application/octet-stream"],["msp","application/octet-stream"],["msty","application/vnd.muvee.style"],["mtl","model/mtl"],["mts","model/vnd.mts"],["mus","application/vnd.musician"],["musd","application/mmt-usd+xml"],["musicxml","application/vnd.recordare.musicxml+xml"],["mvb","application/x-msmediaview"],["mvt","application/vnd.mapbox-vector-tile"],["mwf","application/vnd.mfer"],["mxf","application/mxf"],["mxl","application/vnd.recordare.musicxml"],["mxmf","audio/mobile-xmf"],["mxml","application/xv+xml"],["mxs","application/vnd.triscape.mxs"],["mxu","video/vnd.mpegurl"],["n-gage","application/vnd.nokia.n-gage.symbian.install"],["n3","text/n3"],["nb","application/mathematica"],["nbp","application/vnd.wolfram.player"],["nc","application/x-netcdf"],["ncx","application/x-dtbncx+xml"],["nfo","text/x-nfo"],["ngdat","application/vnd.nokia.n-gage.data"],["nitf","application/vnd.nitf"],["nlu","application/vnd.neurolanguage.nlu"],["nml","application/vnd.enliven"],["nnd","application/vnd.noblenet-directory"],["nns","application/vnd.noblenet-sealer"],["nnw","application/vnd.noblenet-web"],["npx","image/vnd.net-fpx"],["nq","application/n-quads"],["nsc","application/x-conference"],["nsf","application/vnd.lotus-notes"],["nt","application/n-triples"],["ntf","application/vnd.nitf"],["numbers","application/x-iwork-numbers-sffnumbers"],["nzb","application/x-nzb"],["oa2","application/vnd.fujitsu.oasys2"],["oa3","application/vnd.fujitsu.oasys3"],["oas","application/vnd.fujitsu.oasys"],["obd","application/x-msbinder"],["obgx","application/vnd.openblox.game+xml"],["obj","model/obj"],["oda","application/oda"],["odb","application/vnd.oasis.opendocument.database"],["odc","application/vnd.oasis.opendocument.chart"],["odf","application/vnd.oasis.opendocument.formula"],["odft","application/vnd.oasis.opendocument.formula-template"],["odg","application/vnd.oasis.opendocument.graphics"],["odi","application/vnd.oasis.opendocument.image"],["odm","application/vnd.oasis.opendocument.text-master"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogex","model/vnd.opengex"],["ogg","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["omdoc","application/omdoc+xml"],["onepkg","application/onenote"],["onetmp","application/onenote"],["onetoc","application/onenote"],["onetoc2","application/onenote"],["opf","application/oebps-package+xml"],["opml","text/x-opml"],["oprc","application/vnd.palm"],["opus","audio/ogg"],["org","text/x-org"],["osf","application/vnd.yamaha.openscoreformat"],["osfpvg","application/vnd.yamaha.openscoreformat.osfpvg+xml"],["osm","application/vnd.openstreetmap.data+xml"],["otc","application/vnd.oasis.opendocument.chart-template"],["otf","font/otf"],["otg","application/vnd.oasis.opendocument.graphics-template"],["oth","application/vnd.oasis.opendocument.text-web"],["oti","application/vnd.oasis.opendocument.image-template"],["otp","application/vnd.oasis.opendocument.presentation-template"],["ots","application/vnd.oasis.opendocument.spreadsheet-template"],["ott","application/vnd.oasis.opendocument.text-template"],["ova","application/x-virtualbox-ova"],["ovf","application/x-virtualbox-ovf"],["owl","application/rdf+xml"],["oxps","application/oxps"],["oxt","application/vnd.openofficeorg.extension"],["p","text/x-pascal"],["p7a","application/x-pkcs7-signature"],["p7b","application/x-pkcs7-certificates"],["p7c","application/pkcs7-mime"],["p7m","application/pkcs7-mime"],["p7r","application/x-pkcs7-certreqresp"],["p7s","application/pkcs7-signature"],["p8","application/pkcs8"],["p10","application/x-pkcs10"],["p12","application/x-pkcs12"],["pac","application/x-ns-proxy-autoconfig"],["pages","application/x-iwork-pages-sffpages"],["pas","text/x-pascal"],["paw","application/vnd.pawaafile"],["pbd","application/vnd.powerbuilder6"],["pbm","image/x-portable-bitmap"],["pcap","application/vnd.tcpdump.pcap"],["pcf","application/x-font-pcf"],["pcl","application/vnd.hp-pcl"],["pclxl","application/vnd.hp-pclxl"],["pct","image/x-pict"],["pcurl","application/vnd.curl.pcurl"],["pcx","image/x-pcx"],["pdb","application/x-pilot"],["pde","text/x-processing"],["pdf","application/pdf"],["pem","application/x-x509-user-cert"],["pfa","application/x-font-type1"],["pfb","application/x-font-type1"],["pfm","application/x-font-type1"],["pfr","application/font-tdpfr"],["pfx","application/x-pkcs12"],["pgm","image/x-portable-graymap"],["pgn","application/x-chess-pgn"],["pgp","application/pgp"],["php","application/x-httpd-php"],["php3","application/x-httpd-php"],["php4","application/x-httpd-php"],["phps","application/x-httpd-php-source"],["phtml","application/x-httpd-php"],["pic","image/x-pict"],["pkg","application/octet-stream"],["pki","application/pkixcmp"],["pkipath","application/pkix-pkipath"],["pkpass","application/vnd.apple.pkpass"],["pl","application/x-perl"],["plb","application/vnd.3gpp.pic-bw-large"],["plc","application/vnd.mobius.plc"],["plf","application/vnd.pocketlearn"],["pls","application/pls+xml"],["pm","application/x-perl"],["pml","application/vnd.ctc-posml"],["png","image/png"],["pnm","image/x-portable-anymap"],["portpkg","application/vnd.macports.portpkg"],["pot","application/vnd.ms-powerpoint"],["potm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["potx","application/vnd.openxmlformats-officedocument.presentationml.template"],["ppa","application/vnd.ms-powerpoint"],["ppam","application/vnd.ms-powerpoint.addin.macroEnabled.12"],["ppd","application/vnd.cups-ppd"],["ppm","image/x-portable-pixmap"],["pps","application/vnd.ms-powerpoint"],["ppsm","application/vnd.ms-powerpoint.slideshow.macroEnabled.12"],["ppsx","application/vnd.openxmlformats-officedocument.presentationml.slideshow"],["ppt","application/powerpoint"],["pptm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["pqa","application/vnd.palm"],["prc","application/x-pilot"],["pre","application/vnd.lotus-freelance"],["prf","application/pics-rules"],["provx","application/provenance+xml"],["ps","application/postscript"],["psb","application/vnd.3gpp.pic-bw-small"],["psd","application/x-photoshop"],["psf","application/x-font-linux-psf"],["pskcxml","application/pskc+xml"],["pti","image/prs.pti"],["ptid","application/vnd.pvi.ptid1"],["pub","application/x-mspublisher"],["pvb","application/vnd.3gpp.pic-bw-var"],["pwn","application/vnd.3m.post-it-notes"],["pya","audio/vnd.ms-playready.media.pya"],["pyv","video/vnd.ms-playready.media.pyv"],["qam","application/vnd.epson.quickanime"],["qbo","application/vnd.intu.qbo"],["qfx","application/vnd.intu.qfx"],["qps","application/vnd.publishare-delta-tree"],["qt","video/quicktime"],["qwd","application/vnd.quark.quarkxpress"],["qwt","application/vnd.quark.quarkxpress"],["qxb","application/vnd.quark.quarkxpress"],["qxd","application/vnd.quark.quarkxpress"],["qxl","application/vnd.quark.quarkxpress"],["qxt","application/vnd.quark.quarkxpress"],["ra","audio/x-realaudio"],["ram","audio/x-pn-realaudio"],["raml","application/raml+yaml"],["rapd","application/route-apd+xml"],["rar","application/x-rar"],["ras","image/x-cmu-raster"],["rcprofile","application/vnd.ipunplugged.rcprofile"],["rdf","application/rdf+xml"],["rdz","application/vnd.data-vision.rdz"],["relo","application/p2p-overlay+xml"],["rep","application/vnd.businessobjects"],["res","application/x-dtbresource+xml"],["rgb","image/x-rgb"],["rif","application/reginfo+xml"],["rip","audio/vnd.rip"],["ris","application/x-research-info-systems"],["rl","application/resource-lists+xml"],["rlc","image/vnd.fujixerox.edmics-rlc"],["rld","application/resource-lists-diff+xml"],["rm","audio/x-pn-realaudio"],["rmi","audio/midi"],["rmp","audio/x-pn-realaudio-plugin"],["rms","application/vnd.jcp.javame.midlet-rms"],["rmvb","application/vnd.rn-realmedia-vbr"],["rnc","application/relax-ng-compact-syntax"],["rng","application/xml"],["roa","application/rpki-roa"],["roff","text/troff"],["rp9","application/vnd.cloanto.rp9"],["rpm","audio/x-pn-realaudio-plugin"],["rpss","application/vnd.nokia.radio-presets"],["rpst","application/vnd.nokia.radio-preset"],["rq","application/sparql-query"],["rs","application/rls-services+xml"],["rsa","application/x-pkcs7"],["rsat","application/atsc-rsat+xml"],["rsd","application/rsd+xml"],["rsheet","application/urc-ressheet+xml"],["rss","application/rss+xml"],["rtf","text/rtf"],["rtx","text/richtext"],["run","application/x-makeself"],["rusd","application/route-usd+xml"],["rv","video/vnd.rn-realvideo"],["s","text/x-asm"],["s3m","audio/s3m"],["saf","application/vnd.yamaha.smaf-audio"],["sass","text/x-sass"],["sbml","application/sbml+xml"],["sc","application/vnd.ibm.secure-container"],["scd","application/x-msschedule"],["scm","application/vnd.lotus-screencam"],["scq","application/scvp-cv-request"],["scs","application/scvp-cv-response"],["scss","text/x-scss"],["scurl","text/vnd.curl.scurl"],["sda","application/vnd.stardivision.draw"],["sdc","application/vnd.stardivision.calc"],["sdd","application/vnd.stardivision.impress"],["sdkd","application/vnd.solent.sdkm+xml"],["sdkm","application/vnd.solent.sdkm+xml"],["sdp","application/sdp"],["sdw","application/vnd.stardivision.writer"],["sea","application/octet-stream"],["see","application/vnd.seemail"],["seed","application/vnd.fdsn.seed"],["sema","application/vnd.sema"],["semd","application/vnd.semd"],["semf","application/vnd.semf"],["senmlx","application/senml+xml"],["sensmlx","application/sensml+xml"],["ser","application/java-serialized-object"],["setpay","application/set-payment-initiation"],["setreg","application/set-registration-initiation"],["sfd-hdstx","application/vnd.hydrostatix.sof-data"],["sfs","application/vnd.spotfire.sfs"],["sfv","text/x-sfv"],["sgi","image/sgi"],["sgl","application/vnd.stardivision.writer-global"],["sgm","text/sgml"],["sgml","text/sgml"],["sh","application/x-sh"],["shar","application/x-shar"],["shex","text/shex"],["shf","application/shf+xml"],["shtml","text/html"],["sid","image/x-mrsid-image"],["sieve","application/sieve"],["sig","application/pgp-signature"],["sil","audio/silk"],["silo","model/mesh"],["sis","application/vnd.symbian.install"],["sisx","application/vnd.symbian.install"],["sit","application/x-stuffit"],["sitx","application/x-stuffitx"],["siv","application/sieve"],["skd","application/vnd.koan"],["skm","application/vnd.koan"],["skp","application/vnd.koan"],["skt","application/vnd.koan"],["sldm","application/vnd.ms-powerpoint.slide.macroenabled.12"],["sldx","application/vnd.openxmlformats-officedocument.presentationml.slide"],["slim","text/slim"],["slm","text/slim"],["sls","application/route-s-tsid+xml"],["slt","application/vnd.epson.salt"],["sm","application/vnd.stepmania.stepchart"],["smf","application/vnd.stardivision.math"],["smi","application/smil"],["smil","application/smil"],["smv","video/x-smv"],["smzip","application/vnd.stepmania.package"],["snd","audio/basic"],["snf","application/x-font-snf"],["so","application/octet-stream"],["spc","application/x-pkcs7-certificates"],["spdx","text/spdx"],["spf","application/vnd.yamaha.smaf-phrase"],["spl","application/x-futuresplash"],["spot","text/vnd.in3d.spot"],["spp","application/scvp-vp-response"],["spq","application/scvp-vp-request"],["spx","audio/ogg"],["sql","application/x-sql"],["src","application/x-wais-source"],["srt","application/x-subrip"],["sru","application/sru+xml"],["srx","application/sparql-results+xml"],["ssdl","application/ssdl+xml"],["sse","application/vnd.kodak-descriptor"],["ssf","application/vnd.epson.ssf"],["ssml","application/ssml+xml"],["sst","application/octet-stream"],["st","application/vnd.sailingtracker.track"],["stc","application/vnd.sun.xml.calc.template"],["std","application/vnd.sun.xml.draw.template"],["stf","application/vnd.wt.stf"],["sti","application/vnd.sun.xml.impress.template"],["stk","application/hyperstudio"],["stl","model/stl"],["stpx","model/step+xml"],["stpxz","model/step-xml+zip"],["stpz","model/step+zip"],["str","application/vnd.pg.format"],["stw","application/vnd.sun.xml.writer.template"],["styl","text/stylus"],["stylus","text/stylus"],["sub","text/vnd.dvb.subtitle"],["sus","application/vnd.sus-calendar"],["susp","application/vnd.sus-calendar"],["sv4cpio","application/x-sv4cpio"],["sv4crc","application/x-sv4crc"],["svc","application/vnd.dvb.service"],["svd","application/vnd.svd"],["svg","image/svg+xml"],["svgz","image/svg+xml"],["swa","application/x-director"],["swf","application/x-shockwave-flash"],["swi","application/vnd.aristanetworks.swi"],["swidtag","application/swid+xml"],["sxc","application/vnd.sun.xml.calc"],["sxd","application/vnd.sun.xml.draw"],["sxg","application/vnd.sun.xml.writer.global"],["sxi","application/vnd.sun.xml.impress"],["sxm","application/vnd.sun.xml.math"],["sxw","application/vnd.sun.xml.writer"],["t","text/troff"],["t3","application/x-t3vm-image"],["t38","image/t38"],["taglet","application/vnd.mynfc"],["tao","application/vnd.tao.intent-module-archive"],["tap","image/vnd.tencent.tap"],["tar","application/x-tar"],["tcap","application/vnd.3gpp2.tcap"],["tcl","application/x-tcl"],["td","application/urc-targetdesc+xml"],["teacher","application/vnd.smart.teacher"],["tei","application/tei+xml"],["teicorpus","application/tei+xml"],["tex","application/x-tex"],["texi","application/x-texinfo"],["texinfo","application/x-texinfo"],["text","text/plain"],["tfi","application/thraud+xml"],["tfm","application/x-tex-tfm"],["tfx","image/tiff-fx"],["tga","image/x-tga"],["tgz","application/x-tar"],["thmx","application/vnd.ms-officetheme"],["tif","image/tiff"],["tiff","image/tiff"],["tk","application/x-tcl"],["tmo","application/vnd.tmobile-livetv"],["toml","application/toml"],["torrent","application/x-bittorrent"],["tpl","application/vnd.groove-tool-template"],["tpt","application/vnd.trid.tpt"],["tr","text/troff"],["tra","application/vnd.trueapp"],["trig","application/trig"],["trm","application/x-msterminal"],["ts","video/mp2t"],["tsd","application/timestamped-data"],["tsv","text/tab-separated-values"],["ttc","font/collection"],["ttf","font/ttf"],["ttl","text/turtle"],["ttml","application/ttml+xml"],["twd","application/vnd.simtech-mindmapper"],["twds","application/vnd.simtech-mindmapper"],["txd","application/vnd.genomatix.tuxedo"],["txf","application/vnd.mobius.txf"],["txt","text/plain"],["u8dsn","message/global-delivery-status"],["u8hdr","message/global-headers"],["u8mdn","message/global-disposition-notification"],["u8msg","message/global"],["u32","application/x-authorware-bin"],["ubj","application/ubjson"],["udeb","application/x-debian-package"],["ufd","application/vnd.ufdl"],["ufdl","application/vnd.ufdl"],["ulx","application/x-glulx"],["umj","application/vnd.umajin"],["unityweb","application/vnd.unity"],["uoml","application/vnd.uoml+xml"],["uri","text/uri-list"],["uris","text/uri-list"],["urls","text/uri-list"],["usdz","model/vnd.usdz+zip"],["ustar","application/x-ustar"],["utz","application/vnd.uiq.theme"],["uu","text/x-uuencode"],["uva","audio/vnd.dece.audio"],["uvd","application/vnd.dece.data"],["uvf","application/vnd.dece.data"],["uvg","image/vnd.dece.graphic"],["uvh","video/vnd.dece.hd"],["uvi","image/vnd.dece.graphic"],["uvm","video/vnd.dece.mobile"],["uvp","video/vnd.dece.pd"],["uvs","video/vnd.dece.sd"],["uvt","application/vnd.dece.ttml+xml"],["uvu","video/vnd.uvvu.mp4"],["uvv","video/vnd.dece.video"],["uvva","audio/vnd.dece.audio"],["uvvd","application/vnd.dece.data"],["uvvf","application/vnd.dece.data"],["uvvg","image/vnd.dece.graphic"],["uvvh","video/vnd.dece.hd"],["uvvi","image/vnd.dece.graphic"],["uvvm","video/vnd.dece.mobile"],["uvvp","video/vnd.dece.pd"],["uvvs","video/vnd.dece.sd"],["uvvt","application/vnd.dece.ttml+xml"],["uvvu","video/vnd.uvvu.mp4"],["uvvv","video/vnd.dece.video"],["uvvx","application/vnd.dece.unspecified"],["uvvz","application/vnd.dece.zip"],["uvx","application/vnd.dece.unspecified"],["uvz","application/vnd.dece.zip"],["vbox","application/x-virtualbox-vbox"],["vbox-extpack","application/x-virtualbox-vbox-extpack"],["vcard","text/vcard"],["vcd","application/x-cdlink"],["vcf","text/x-vcard"],["vcg","application/vnd.groove-vcard"],["vcs","text/x-vcalendar"],["vcx","application/vnd.vcx"],["vdi","application/x-virtualbox-vdi"],["vds","model/vnd.sap.vds"],["vhd","application/x-virtualbox-vhd"],["vis","application/vnd.visionary"],["viv","video/vnd.vivo"],["vlc","application/videolan"],["vmdk","application/x-virtualbox-vmdk"],["vob","video/x-ms-vob"],["vor","application/vnd.stardivision.writer"],["vox","application/x-authorware-bin"],["vrml","model/vrml"],["vsd","application/vnd.visio"],["vsf","application/vnd.vsf"],["vss","application/vnd.visio"],["vst","application/vnd.visio"],["vsw","application/vnd.visio"],["vtf","image/vnd.valve.source.texture"],["vtt","text/vtt"],["vtu","model/vnd.vtu"],["vxml","application/voicexml+xml"],["w3d","application/x-director"],["wad","application/x-doom"],["wadl","application/vnd.sun.wadl+xml"],["war","application/java-archive"],["wasm","application/wasm"],["wav","audio/x-wav"],["wax","audio/x-ms-wax"],["wbmp","image/vnd.wap.wbmp"],["wbs","application/vnd.criticaltools.wbs+xml"],["wbxml","application/wbxml"],["wcm","application/vnd.ms-works"],["wdb","application/vnd.ms-works"],["wdp","image/vnd.ms-photo"],["weba","audio/webm"],["webapp","application/x-web-app-manifest+json"],["webm","video/webm"],["webmanifest","application/manifest+json"],["webp","image/webp"],["wg","application/vnd.pmi.widget"],["wgt","application/widget"],["wks","application/vnd.ms-works"],["wm","video/x-ms-wm"],["wma","audio/x-ms-wma"],["wmd","application/x-ms-wmd"],["wmf","image/wmf"],["wml","text/vnd.wap.wml"],["wmlc","application/wmlc"],["wmls","text/vnd.wap.wmlscript"],["wmlsc","application/vnd.wap.wmlscriptc"],["wmv","video/x-ms-wmv"],["wmx","video/x-ms-wmx"],["wmz","application/x-msmetafile"],["woff","font/woff"],["woff2","font/woff2"],["word","application/msword"],["wpd","application/vnd.wordperfect"],["wpl","application/vnd.ms-wpl"],["wps","application/vnd.ms-works"],["wqd","application/vnd.wqd"],["wri","application/x-mswrite"],["wrl","model/vrml"],["wsc","message/vnd.wfa.wsc"],["wsdl","application/wsdl+xml"],["wspolicy","application/wspolicy+xml"],["wtb","application/vnd.webturbo"],["wvx","video/x-ms-wvx"],["x3d","model/x3d+xml"],["x3db","model/x3d+fastinfoset"],["x3dbz","model/x3d+binary"],["x3dv","model/x3d-vrml"],["x3dvz","model/x3d+vrml"],["x3dz","model/x3d+xml"],["x32","application/x-authorware-bin"],["x_b","model/vnd.parasolid.transmit.binary"],["x_t","model/vnd.parasolid.transmit.text"],["xaml","application/xaml+xml"],["xap","application/x-silverlight-app"],["xar","application/vnd.xara"],["xav","application/xcap-att+xml"],["xbap","application/x-ms-xbap"],["xbd","application/vnd.fujixerox.docuworks.binder"],["xbm","image/x-xbitmap"],["xca","application/xcap-caps+xml"],["xcs","application/calendar+xml"],["xdf","application/xcap-diff+xml"],["xdm","application/vnd.syncml.dm+xml"],["xdp","application/vnd.adobe.xdp+xml"],["xdssc","application/dssc+xml"],["xdw","application/vnd.fujixerox.docuworks"],["xel","application/xcap-el+xml"],["xenc","application/xenc+xml"],["xer","application/patch-ops-error+xml"],["xfdf","application/vnd.adobe.xfdf"],["xfdl","application/vnd.xfdl"],["xht","application/xhtml+xml"],["xhtml","application/xhtml+xml"],["xhvml","application/xv+xml"],["xif","image/vnd.xiff"],["xl","application/excel"],["xla","application/vnd.ms-excel"],["xlam","application/vnd.ms-excel.addin.macroEnabled.12"],["xlc","application/vnd.ms-excel"],["xlf","application/xliff+xml"],["xlm","application/vnd.ms-excel"],["xls","application/vnd.ms-excel"],["xlsb","application/vnd.ms-excel.sheet.binary.macroEnabled.12"],["xlsm","application/vnd.ms-excel.sheet.macroEnabled.12"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xlt","application/vnd.ms-excel"],["xltm","application/vnd.ms-excel.template.macroEnabled.12"],["xltx","application/vnd.openxmlformats-officedocument.spreadsheetml.template"],["xlw","application/vnd.ms-excel"],["xm","audio/xm"],["xml","application/xml"],["xns","application/xcap-ns+xml"],["xo","application/vnd.olpc-sugar"],["xop","application/xop+xml"],["xpi","application/x-xpinstall"],["xpl","application/xproc+xml"],["xpm","image/x-xpixmap"],["xpr","application/vnd.is-xpr"],["xps","application/vnd.ms-xpsdocument"],["xpw","application/vnd.intercon.formnet"],["xpx","application/vnd.intercon.formnet"],["xsd","application/xml"],["xsl","application/xml"],["xslt","application/xslt+xml"],["xsm","application/vnd.syncml+xml"],["xspf","application/xspf+xml"],["xul","application/vnd.mozilla.xul+xml"],["xvm","application/xv+xml"],["xvml","application/xv+xml"],["xwd","image/x-xwindowdump"],["xyz","chemical/x-xyz"],["xz","application/x-xz"],["yaml","text/yaml"],["yang","application/yang"],["yin","application/yin+xml"],["yml","text/yaml"],["ymp","text/x-suse-ymp"],["z","application/x-compress"],["z1","application/x-zmachine"],["z2","application/x-zmachine"],["z3","application/x-zmachine"],["z4","application/x-zmachine"],["z5","application/x-zmachine"],["z6","application/x-zmachine"],["z7","application/x-zmachine"],["z8","application/x-zmachine"],["zaz","application/vnd.zzazz.deck+xml"],["zip","application/zip"],["zir","application/vnd.zul"],["zirz","application/vnd.zul"],["zmm","application/vnd.handheld-entertainment+xml"],["zsh","text/x-scriptzsh"]]);function xr(t,r,s){const a=Lu(t),{webkitRelativePath:n}=t,o=typeof r=="string"?r:typeof n=="string"&&n.length>0?n:`./${t.name}`;return typeof a.path!="string"&&yn(a,"path",o),yn(a,"relativePath",o),a}function Lu(t){const{name:r}=t;if(r&&r.lastIndexOf(".")!==-1&&!t.type){const a=r.split(".").pop().toLowerCase(),n=Du.get(a);n&&Object.defineProperty(t,"type",{value:n,writable:!1,configurable:!1,enumerable:!0})}return t}function yn(t,r,s){Object.defineProperty(t,r,{value:s,writable:!1,configurable:!1,enumerable:!0})}const Pu=[".DS_Store","Thumbs.db"];function $u(t){return or(this,void 0,void 0,function*(){return xs(t)&&_u(t.dataTransfer)?Ou(t.dataTransfer,t.type):Fu(t)?zu(t):Array.isArray(t)&&t.every(r=>"getFile"in r&&typeof r.getFile=="function")?Ru(t):[]})}function _u(t){return xs(t)}function Fu(t){return xs(t)&&xs(t.target)}function xs(t){return typeof t=="object"&&t!==null}function zu(t){return oa(t.target.files).map(r=>xr(r))}function Ru(t){return or(this,void 0,void 0,function*(){return(yield Promise.all(t.map(s=>s.getFile()))).map(s=>xr(s))})}function Ou(t,r){return or(this,void 0,void 0,function*(){if(t.items){const s=oa(t.items).filter(n=>n.kind==="file");if(r!=="drop")return s;const a=yield Promise.all(s.map(Bu));return vn(Yo(a))}return vn(oa(t.files).map(s=>xr(s)))})}function vn(t){return t.filter(r=>Pu.indexOf(r.name)===-1)}function oa(t){if(t===null)return[];const r=[];for(let s=0;s<t.length;s++){const a=t[s];r.push(a)}return r}function Bu(t){if(typeof t.webkitGetAsEntry!="function")return kn(t);const r=t.webkitGetAsEntry();return r&&r.isDirectory?Qo(r):kn(t,r)}function Yo(t){return t.reduce((r,s)=>[...r,...Array.isArray(s)?Yo(s):[s]],[])}function kn(t,r){return or(this,void 0,void 0,function*(){var s;if(globalThis.isSecureContext&&typeof t.getAsFileSystemHandle=="function"){const o=yield t.getAsFileSystemHandle();if(o===null)throw new Error(`${t} is not a File`);if(o!==void 0){const i=yield o.getFile();return i.handle=o,xr(i)}}const a=t.getAsFile();if(!a)throw new Error(`${t} is not a File`);return xr(a,(s=r==null?void 0:r.fullPath)!==null&&s!==void 0?s:void 0)})}function Wu(t){return or(this,void 0,void 0,function*(){return t.isDirectory?Qo(t):Uu(t)})}function Qo(t){const r=t.createReader();return new Promise((s,a)=>{const n=[];function o(){r.readEntries(i=>or(this,void 0,void 0,function*(){if(i.length){const c=Promise.all(i.map(Wu));n.push(c),o()}else try{const c=yield Promise.all(n);s(c)}catch(c){a(c)}}),i=>{a(i)})}o()})}function Uu(t){return or(this,void 0,void 0,function*(){return new Promise((r,s)=>{t.file(a=>{const n=xr(a,t.fullPath);r(n)},a=>{s(a)})})})}var rs={},wn;function Hu(){return wn||(wn=1,rs.__esModule=!0,rs.default=function(t,r){if(t&&r){var s=Array.isArray(r)?r:r.split(",");if(s.length===0)return!0;var a=t.name||"",n=(t.type||"").toLowerCase(),o=n.replace(/\/.*$/,"");return s.some(function(i){var c=i.trim().toLowerCase();return c.charAt(0)==="."?a.toLowerCase().endsWith(c):c.endsWith("/*")?o===c.replace(/\/.*$/,""):n===c})}return!0}),rs}var Gu=Hu();const Ks=eo(Gu);function jn(t){return Ku(t)||qu(t)||Zo(t)||Vu()}function Vu(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
145
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function qu(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Ku(t){if(Array.isArray(t))return ia(t)}function Nn(t,r){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),s.push.apply(s,a)}return s}function Cn(t){for(var r=1;r<arguments.length;r++){var s=arguments[r]!=null?arguments[r]:{};r%2?Nn(Object(s),!0).forEach(function(a){Xo(t,a,s[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):Nn(Object(s)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(s,a))})}return t}function Xo(t,r,s){return r in t?Object.defineProperty(t,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[r]=s,t}function _r(t,r){return Qu(t)||Yu(t,r)||Zo(t,r)||Ju()}function Ju(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
146
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Zo(t,r){if(t){if(typeof t=="string")return ia(t,r);var s=Object.prototype.toString.call(t).slice(8,-1);if(s==="Object"&&t.constructor&&(s=t.constructor.name),s==="Map"||s==="Set")return Array.from(t);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return ia(t,r)}}function ia(t,r){(r==null||r>t.length)&&(r=t.length);for(var s=0,a=new Array(r);s<r;s++)a[s]=t[s];return a}function Yu(t,r){var s=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(s!=null){var a=[],n=!0,o=!1,i,c;try{for(s=s.call(t);!(n=(i=s.next()).done)&&(a.push(i.value),!(r&&a.length===r));n=!0);}catch(d){o=!0,c=d}finally{try{!n&&s.return!=null&&s.return()}finally{if(o)throw c}}return a}}function Qu(t){if(Array.isArray(t))return t}var Xu=typeof Ks=="function"?Ks:Ks.default,Zu="file-invalid-type",em="file-too-large",tm="file-too-small",rm="too-many-files",sm=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",s=r.split(","),a=s.length>1?"one of ".concat(s.join(", ")):s[0];return{code:Zu,message:"File type must be ".concat(a)}},Sn=function(r){return{code:em,message:"File is larger than ".concat(r," ").concat(r===1?"byte":"bytes")}},En=function(r){return{code:tm,message:"File is smaller than ".concat(r," ").concat(r===1?"byte":"bytes")}},am={code:rm,message:"Too many files"};function nm(t){return t.type===""&&typeof t.getAsFile=="function"}function ei(t,r){var s=t.type==="application/x-moz-file"||Xu(t,r)||nm(t);return[s,s?null:sm(r)]}function ti(t,r,s){if(Xt(t.size))if(Xt(r)&&Xt(s)){if(t.size>s)return[!1,Sn(s)];if(t.size<r)return[!1,En(r)]}else{if(Xt(r)&&t.size<r)return[!1,En(r)];if(Xt(s)&&t.size>s)return[!1,Sn(s)]}return[!0,null]}function Xt(t){return t!=null}function om(t){var r=t.files,s=t.accept,a=t.minSize,n=t.maxSize,o=t.multiple,i=t.maxFiles,c=t.validator;return!o&&r.length>1||o&&i>=1&&r.length>i?!1:r.every(function(d){var u=ei(d,s),m=_r(u,1),h=m[0],p=ti(d,a,n),g=_r(p,1),f=g[0],x=c?c(d):null;return h&&f&&!x})}function gs(t){return typeof t.isPropagationStopped=="function"?t.isPropagationStopped():typeof t.cancelBubble<"u"?t.cancelBubble:!1}function Nr(t){return t.dataTransfer?Array.prototype.some.call(t.dataTransfer.types,function(r){return r==="Files"||r==="application/x-moz-file"}):!!t.target&&!!t.target.files}function Tn(t){t.preventDefault()}function im(t){return t.indexOf("MSIE")!==-1||t.indexOf("Trident/")!==-1}function lm(t){return t.indexOf("Edge/")!==-1}function cm(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return im(t)||lm(t)}function St(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];return function(a){for(var n=arguments.length,o=new Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return r.some(function(c){return!gs(a)&&c&&c.apply(void 0,[a].concat(o)),gs(a)})}}function dm(){return"showOpenFilePicker"in window}function um(t){if(Xt(t)){var r=Object.entries(t).filter(function(s){var a=_r(s,2),n=a[0],o=a[1],i=!0;return ri(n)||(console.warn('Skipped "'.concat(n,'" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types.')),i=!1),(!Array.isArray(o)||!o.every(si))&&(console.warn('Skipped "'.concat(n,'" because an invalid file extension was provided.')),i=!1),i}).reduce(function(s,a){var n=_r(a,2),o=n[0],i=n[1];return Cn(Cn({},s),{},Xo({},o,i))},{});return[{description:"Files",accept:r}]}return t}function mm(t){if(Xt(t))return Object.entries(t).reduce(function(r,s){var a=_r(s,2),n=a[0],o=a[1];return[].concat(jn(r),[n],jn(o))},[]).filter(function(r){return ri(r)||si(r)}).join(",")}function pm(t){return t instanceof DOMException&&(t.name==="AbortError"||t.code===t.ABORT_ERR)}function xm(t){return t instanceof DOMException&&(t.name==="SecurityError"||t.code===t.SECURITY_ERR)}function ri(t){return t==="audio/*"||t==="video/*"||t==="image/*"||t==="text/*"||t==="application/*"||/\w+\/[-+.\w]+/g.test(t)}function si(t){return/^.*\.[\w]+$/.test(t)}var gm=["children"],hm=["open"],fm=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],bm=["refKey","onChange","onClick"];function An(t){return km(t)||vm(t)||ai(t)||ym()}function ym(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
147
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function vm(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function km(t){if(Array.isArray(t))return la(t)}function Js(t,r){return Nm(t)||jm(t,r)||ai(t,r)||wm()}function wm(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
148
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ai(t,r){if(t){if(typeof t=="string")return la(t,r);var s=Object.prototype.toString.call(t).slice(8,-1);if(s==="Object"&&t.constructor&&(s=t.constructor.name),s==="Map"||s==="Set")return Array.from(t);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return la(t,r)}}function la(t,r){(r==null||r>t.length)&&(r=t.length);for(var s=0,a=new Array(r);s<r;s++)a[s]=t[s];return a}function jm(t,r){var s=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(s!=null){var a=[],n=!0,o=!1,i,c;try{for(s=s.call(t);!(n=(i=s.next()).done)&&(a.push(i.value),!(r&&a.length===r));n=!0);}catch(d){o=!0,c=d}finally{try{!n&&s.return!=null&&s.return()}finally{if(o)throw c}}return a}}function Nm(t){if(Array.isArray(t))return t}function In(t,r){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);r&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),s.push.apply(s,a)}return s}function Ke(t){for(var r=1;r<arguments.length;r++){var s=arguments[r]!=null?arguments[r]:{};r%2?In(Object(s),!0).forEach(function(a){ca(t,a,s[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):In(Object(s)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(s,a))})}return t}function ca(t,r,s){return r in t?Object.defineProperty(t,r,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[r]=s,t}function hs(t,r){if(t==null)return{};var s=Cm(t,r),a,n;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(n=0;n<o.length;n++)a=o[n],!(r.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(s[a]=t[a])}return s}function Cm(t,r){if(t==null)return{};var s={},a=Object.keys(t),n,o;for(o=0;o<a.length;o++)n=a[o],!(r.indexOf(n)>=0)&&(s[n]=t[n]);return s}var _a=l.forwardRef(function(t,r){var s=t.children,a=hs(t,gm),n=oi(a),o=n.open,i=hs(n,hm);return l.useImperativeHandle(r,function(){return{open:o}},[o]),lt.createElement(l.Fragment,null,s(Ke(Ke({},i),{},{open:o})))});_a.displayName="Dropzone";var ni={disabled:!1,getFilesFromEvent:$u,maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!1,autoFocus:!1};_a.defaultProps=ni;_a.propTypes={children:Ge.func,accept:Ge.objectOf(Ge.arrayOf(Ge.string)),multiple:Ge.bool,preventDropOnDocument:Ge.bool,noClick:Ge.bool,noKeyboard:Ge.bool,noDrag:Ge.bool,noDragEventsBubbling:Ge.bool,minSize:Ge.number,maxSize:Ge.number,maxFiles:Ge.number,disabled:Ge.bool,getFilesFromEvent:Ge.func,onFileDialogCancel:Ge.func,onFileDialogOpen:Ge.func,useFsAccessApi:Ge.bool,autoFocus:Ge.bool,onDragEnter:Ge.func,onDragLeave:Ge.func,onDragOver:Ge.func,onDrop:Ge.func,onDropAccepted:Ge.func,onDropRejected:Ge.func,onError:Ge.func,validator:Ge.func};var da={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,isDragGlobal:!1,acceptedFiles:[],fileRejections:[]};function oi(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=Ke(Ke({},ni),t),s=r.accept,a=r.disabled,n=r.getFilesFromEvent,o=r.maxSize,i=r.minSize,c=r.multiple,d=r.maxFiles,u=r.onDragEnter,m=r.onDragLeave,h=r.onDragOver,p=r.onDrop,g=r.onDropAccepted,f=r.onDropRejected,x=r.onFileDialogCancel,y=r.onFileDialogOpen,N=r.useFsAccessApi,j=r.autoFocus,v=r.preventDropOnDocument,k=r.noClick,A=r.noKeyboard,P=r.noDrag,S=r.noDragEventsBubbling,b=r.onError,C=r.validator,E=l.useMemo(function(){return mm(s)},[s]),B=l.useMemo(function(){return um(s)},[s]),T=l.useMemo(function(){return typeof y=="function"?y:Mn},[y]),W=l.useMemo(function(){return typeof x=="function"?x:Mn},[x]),H=l.useRef(null),_=l.useRef(null),M=l.useReducer(Sm,da),z=Js(M,2),K=z[0],te=z[1],q=K.isFocused,ie=K.isFileDialogActive,$=l.useRef(typeof window<"u"&&window.isSecureContext&&N&&dm()),X=function(){!$.current&&ie&&setTimeout(function(){if(_.current){var ee=_.current.files;ee.length||(te({type:"closeDialog"}),W())}},300)};l.useEffect(function(){return window.addEventListener("focus",X,!1),function(){window.removeEventListener("focus",X,!1)}},[_,ie,W,$]);var re=l.useRef([]),Y=l.useRef([]),U=function(ee){H.current&&H.current.contains(ee.target)||(ee.preventDefault(),re.current=[])};l.useEffect(function(){return v&&(document.addEventListener("dragover",Tn,!1),document.addEventListener("drop",U,!1)),function(){v&&(document.removeEventListener("dragover",Tn),document.removeEventListener("drop",U))}},[H,v]),l.useEffect(function(){var L=function(Fe){Y.current=[].concat(An(Y.current),[Fe.target]),Nr(Fe)&&te({isDragGlobal:!0,type:"setDragGlobal"})},ee=function(Fe){Y.current=Y.current.filter(function(ze){return ze!==Fe.target&&ze!==null}),!(Y.current.length>0)&&te({isDragGlobal:!1,type:"setDragGlobal"})},ge=function(){Y.current=[],te({isDragGlobal:!1,type:"setDragGlobal"})},be=function(){Y.current=[],te({isDragGlobal:!1,type:"setDragGlobal"})};return document.addEventListener("dragenter",L,!1),document.addEventListener("dragleave",ee,!1),document.addEventListener("dragend",ge,!1),document.addEventListener("drop",be,!1),function(){document.removeEventListener("dragenter",L),document.removeEventListener("dragleave",ee),document.removeEventListener("dragend",ge),document.removeEventListener("drop",be)}},[H]),l.useEffect(function(){return!a&&j&&H.current&&H.current.focus(),function(){}},[H,j,a]);var O=l.useCallback(function(L){b?b(L):console.error(L)},[b]),F=l.useCallback(function(L){L.preventDefault(),L.persist(),we(L),re.current=[].concat(An(re.current),[L.target]),Nr(L)&&Promise.resolve(n(L)).then(function(ee){if(!(gs(L)&&!S)){var ge=ee.length,be=ge>0&&om({files:ee,accept:E,minSize:i,maxSize:o,multiple:c,maxFiles:d,validator:C}),Pe=ge>0&&!be;te({isDragAccept:be,isDragReject:Pe,isDragActive:!0,type:"setDraggedFiles"}),u&&u(L)}}).catch(function(ee){return O(ee)})},[n,u,O,S,E,i,o,c,d,C]),V=l.useCallback(function(L){L.preventDefault(),L.persist(),we(L);var ee=Nr(L);if(ee&&L.dataTransfer)try{L.dataTransfer.dropEffect="copy"}catch{}return ee&&h&&h(L),!1},[h,S]),R=l.useCallback(function(L){L.preventDefault(),L.persist(),we(L);var ee=re.current.filter(function(be){return H.current&&H.current.contains(be)}),ge=ee.indexOf(L.target);ge!==-1&&ee.splice(ge,1),re.current=ee,!(ee.length>0)&&(te({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),Nr(L)&&m&&m(L))},[H,m,S]),Z=l.useCallback(function(L,ee){var ge=[],be=[];L.forEach(function(Pe){var Fe=ei(Pe,E),ze=Js(Fe,2),Ve=ze[0],ne=ze[1],he=ti(Pe,i,o),Ne=Js(he,2),Me=Ne[0],Le=Ne[1],Oe=C?C(Pe):null;if(Ve&&Me&&!Oe)ge.push(Pe);else{var Je=[ne,Le];Oe&&(Je=Je.concat(Oe)),be.push({file:Pe,errors:Je.filter(function(ae){return ae})})}}),(!c&&ge.length>1||c&&d>=1&&ge.length>d)&&(ge.forEach(function(Pe){be.push({file:Pe,errors:[am]})}),ge.splice(0)),te({acceptedFiles:ge,fileRejections:be,isDragReject:be.length>0,type:"setFiles"}),p&&p(ge,be,ee),be.length>0&&f&&f(be,ee),ge.length>0&&g&&g(ge,ee)},[te,c,E,i,o,d,p,g,f,C]),G=l.useCallback(function(L){L.preventDefault(),L.persist(),we(L),re.current=[],Nr(L)&&Promise.resolve(n(L)).then(function(ee){gs(L)&&!S||Z(ee,L)}).catch(function(ee){return O(ee)}),te({type:"reset"})},[n,Z,O,S]),w=l.useCallback(function(){if($.current){te({type:"openDialog"}),T();var L={multiple:c,types:B};window.showOpenFilePicker(L).then(function(ee){return n(ee)}).then(function(ee){Z(ee,null),te({type:"closeDialog"})}).catch(function(ee){pm(ee)?(W(ee),te({type:"closeDialog"})):xm(ee)?($.current=!1,_.current?(_.current.value=null,_.current.click()):O(new Error("Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided."))):O(ee)});return}_.current&&(te({type:"openDialog"}),T(),_.current.value=null,_.current.click())},[te,T,W,N,Z,O,B,c]),I=l.useCallback(function(L){!H.current||!H.current.isEqualNode(L.target)||(L.key===" "||L.key==="Enter"||L.keyCode===32||L.keyCode===13)&&(L.preventDefault(),w())},[H,w]),J=l.useCallback(function(){te({type:"focus"})},[]),se=l.useCallback(function(){te({type:"blur"})},[]),ce=l.useCallback(function(){k||(cm()?setTimeout(w,0):w())},[k,w]),Ce=function(ee){return a?null:ee},fe=function(ee){return A?null:Ce(ee)},_e=function(ee){return P?null:Ce(ee)},we=function(ee){S&&ee.stopPropagation()},Ae=l.useMemo(function(){return function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ee=L.refKey,ge=ee===void 0?"ref":ee,be=L.role,Pe=L.onKeyDown,Fe=L.onFocus,ze=L.onBlur,Ve=L.onClick,ne=L.onDragEnter,he=L.onDragOver,Ne=L.onDragLeave,Me=L.onDrop,Le=hs(L,fm);return Ke(Ke(ca({onKeyDown:fe(St(Pe,I)),onFocus:fe(St(Fe,J)),onBlur:fe(St(ze,se)),onClick:Ce(St(Ve,ce)),onDragEnter:_e(St(ne,F)),onDragOver:_e(St(he,V)),onDragLeave:_e(St(Ne,R)),onDrop:_e(St(Me,G)),role:typeof be=="string"&&be!==""?be:"presentation"},ge,H),!a&&!A?{tabIndex:0}:{}),Le)}},[H,I,J,se,ce,F,V,R,G,A,P,a]),Re=l.useCallback(function(L){L.stopPropagation()},[]),Ie=l.useMemo(function(){return function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},ee=L.refKey,ge=ee===void 0?"ref":ee,be=L.onChange,Pe=L.onClick,Fe=hs(L,bm),ze=ca({accept:E,multiple:c,type:"file",style:{border:0,clip:"rect(0, 0, 0, 0)",clipPath:"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap"},onChange:Ce(St(be,G)),onClick:Ce(St(Pe,Re)),tabIndex:-1},ge,_);return Ke(Ke({},ze),Fe)}},[_,s,c,G,a]);return Ke(Ke({},K),{},{isFocused:q&&!a,getRootProps:Ae,getInputProps:Ie,rootRef:H,inputRef:_,open:Ce(w)})}function Sm(t,r){switch(r.type){case"focus":return Ke(Ke({},t),{},{isFocused:!0});case"blur":return Ke(Ke({},t),{},{isFocused:!1});case"openDialog":return Ke(Ke({},da),{},{isFileDialogActive:!0});case"closeDialog":return Ke(Ke({},t),{},{isFileDialogActive:!1});case"setDraggedFiles":return Ke(Ke({},t),{},{isDragActive:r.isDragActive,isDragAccept:r.isDragAccept,isDragReject:r.isDragReject});case"setFiles":return Ke(Ke({},t),{},{acceptedFiles:r.acceptedFiles,fileRejections:r.fileRejections,isDragReject:r.isDragReject});case"setDragGlobal":return Ke(Ke({},t),{},{isDragGlobal:r.isDragGlobal});case"reset":return Ke({},da);default:return t}}function Mn(){}const ii=(t,r="")=>{let s=[];return t.forEach(a=>{const n=r?`${r}/${a.name}`:a.name;if(a.type==="directory"&&a.children){s=s.concat(ii(a.children,n));return}a.type==="file"&&s.push({name:a.name,path:n,relativePath:a.path})}),s};function Em({selectedProject:t,input:r,setInput:s,textareaRef:a}){const[n,o]=l.useState([]),[i,c]=l.useState([]),[d,u]=l.useState([]),[m,h]=l.useState(!1),[p,g]=l.useState(-1),[f,x]=l.useState(0),[y,N]=l.useState(-1);l.useEffect(()=>{const C=new AbortController;return(async()=>{const B=t==null?void 0:t.name;if(o([]),u([]),!!B)try{const T=await Ue.getFiles(B,{signal:C.signal});if(!T.ok)return;const W=await T.json();o(ii(W))}catch(T){if((T==null?void 0:T.name)==="AbortError")return;console.error("Error fetching files:",T)}})(),()=>{C.abort()}},[t==null?void 0:t.name]),l.useEffect(()=>{const C=r.slice(0,f),E=C.lastIndexOf("@");if(E===-1){h(!1),N(-1);return}const B=C.slice(E+1);if(B.includes(" ")){h(!1),N(-1);return}N(E),h(!0),g(-1);const T=n.filter(W=>W.name.toLowerCase().includes(B.toLowerCase())||W.path.toLowerCase().includes(B.toLowerCase())).slice(0,10);u(T)},[r,f,n]);const j=l.useMemo(()=>!r||i.length===0?[]:i.filter(C=>r.includes(C)),[i,r]),v=l.useMemo(()=>j.length===0?[]:Array.from(new Set(j)).sort((E,B)=>B.length-E.length),[j]),k=l.useMemo(()=>{if(v.length===0)return null;const C=v.map(Bo).join("|");return new RegExp(`(${C})`,"g")},[v]),A=l.useMemo(()=>new Set(v),[v]),P=l.useCallback(C=>C?k?C.split(k).map((B,T)=>A.has(B)?e.jsx("span",{className:"bg-blue-200/70 -ml-0.5 dark:bg-blue-300/40 px-0.5 rounded-md box-decoration-clone text-transparent",children:B},`mention-${T}`):e.jsx("span",{children:B},`text-${T}`)):C:"",[k,A]),S=l.useCallback(C=>{const E=r.slice(0,y),B=r.slice(y),T=B.indexOf(" "),W=T!==-1?B.slice(T):"",H=`${E}${C.path} ${W}`,_=E.length+C.path.length+1;a.current&&!a.current.matches(":focus")&&a.current.focus(),s(H),x(_),c(M=>M.includes(C.path)?M:[...M,C.path]),h(!1),N(-1),a.current&&requestAnimationFrame(()=>{a.current&&(a.current.setSelectionRange(_,_),a.current.matches(":focus")||a.current.focus())})},[r,y,a,s]),b=l.useCallback(C=>!m||d.length===0?!1:C.key==="ArrowDown"?(C.preventDefault(),g(E=>E<d.length-1?E+1:0),!0):C.key==="ArrowUp"?(C.preventDefault(),g(E=>E>0?E-1:d.length-1),!0):C.key==="Tab"||C.key==="Enter"?(C.preventDefault(),p>=0?S(d[p]):d.length>0&&S(d[0]),!0):C.key==="Escape"?(C.preventDefault(),h(!1),!0):!1,[m,d,p,S]);return{showFileDropdown:m,filteredFiles:d,selectedFileIndex:p,renderInputWithMentions:P,selectFile:S,setCursorPosition:x,handleFileMentionsKeyDown:b}}function _t(t){return Array.isArray?Array.isArray(t):di(t)==="[object Array]"}function Tm(t){if(typeof t=="string")return t;let r=t+"";return r=="0"&&1/t==-1/0?"-0":r}function Am(t){return t==null?"":Tm(t)}function At(t){return typeof t=="string"}function li(t){return typeof t=="number"}function Im(t){return t===!0||t===!1||Mm(t)&&di(t)=="[object Boolean]"}function ci(t){return typeof t=="object"}function Mm(t){return ci(t)&&t!==null}function gt(t){return t!=null}function Ys(t){return!t.trim().length}function di(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const Dm="Incorrect 'index' type",Lm=t=>`Invalid value for key ${t}`,Pm=t=>`Pattern length exceeds max of ${t}.`,$m=t=>`Missing ${t} property in key`,_m=t=>`Property 'weight' in key '${t}' must be a positive integer`,Dn=Object.prototype.hasOwnProperty;class Fm{constructor(r){this._keys=[],this._keyMap={};let s=0;r.forEach(a=>{let n=ui(a);this._keys.push(n),this._keyMap[n.id]=n,s+=n.weight}),this._keys.forEach(a=>{a.weight/=s})}get(r){return this._keyMap[r]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function ui(t){let r=null,s=null,a=null,n=1,o=null;if(At(t)||_t(t))a=t,r=Ln(t),s=ua(t);else{if(!Dn.call(t,"name"))throw new Error($m("name"));const i=t.name;if(a=i,Dn.call(t,"weight")&&(n=t.weight,n<=0))throw new Error(_m(i));r=Ln(i),s=ua(i),o=t.getFn}return{path:r,id:s,weight:n,src:a,getFn:o}}function Ln(t){return _t(t)?t:t.split(".")}function ua(t){return _t(t)?t.join("."):t}function zm(t,r){let s=[],a=!1;const n=(o,i,c)=>{if(gt(o))if(!i[c])s.push(o);else{let d=i[c];const u=o[d];if(!gt(u))return;if(c===i.length-1&&(At(u)||li(u)||Im(u)))s.push(Am(u));else if(_t(u)){a=!0;for(let m=0,h=u.length;m<h;m+=1)n(u[m],i,c+1)}else i.length&&n(u,i,c+1)}};return n(t,At(r)?r.split("."):r,0),a?s:s[0]}const Rm={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Om={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(t,r)=>t.score===r.score?t.idx<r.idx?-1:1:t.score<r.score?-1:1},Bm={location:0,threshold:.6,distance:100},Wm={useExtendedSearch:!1,getFn:zm,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var Se={...Om,...Rm,...Bm,...Wm};const Um=/[^ ]+/g;function Hm(t=1,r=3){const s=new Map,a=Math.pow(10,r);return{get(n){const o=n.match(Um).length;if(s.has(o))return s.get(o);const i=1/Math.pow(o,.5*t),c=parseFloat(Math.round(i*a)/a);return s.set(o,c),c},clear(){s.clear()}}}class Fa{constructor({getFn:r=Se.getFn,fieldNormWeight:s=Se.fieldNormWeight}={}){this.norm=Hm(s,3),this.getFn=r,this.isCreated=!1,this.setIndexRecords()}setSources(r=[]){this.docs=r}setIndexRecords(r=[]){this.records=r}setKeys(r=[]){this.keys=r,this._keysMap={},r.forEach((s,a)=>{this._keysMap[s.id]=a})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,At(this.docs[0])?this.docs.forEach((r,s)=>{this._addString(r,s)}):this.docs.forEach((r,s)=>{this._addObject(r,s)}),this.norm.clear())}add(r){const s=this.size();At(r)?this._addString(r,s):this._addObject(r,s)}removeAt(r){this.records.splice(r,1);for(let s=r,a=this.size();s<a;s+=1)this.records[s].i-=1}getValueForItemAtKeyId(r,s){return r[this._keysMap[s]]}size(){return this.records.length}_addString(r,s){if(!gt(r)||Ys(r))return;let a={v:r,i:s,n:this.norm.get(r)};this.records.push(a)}_addObject(r,s){let a={i:s,$:{}};this.keys.forEach((n,o)=>{let i=n.getFn?n.getFn(r):this.getFn(r,n.path);if(gt(i)){if(_t(i)){let c=[];const d=[{nestedArrIndex:-1,value:i}];for(;d.length;){const{nestedArrIndex:u,value:m}=d.pop();if(gt(m))if(At(m)&&!Ys(m)){let h={v:m,i:u,n:this.norm.get(m)};c.push(h)}else _t(m)&&m.forEach((h,p)=>{d.push({nestedArrIndex:p,value:h})})}a.$[o]=c}else if(At(i)&&!Ys(i)){let c={v:i,n:this.norm.get(i)};a.$[o]=c}}}),this.records.push(a)}toJSON(){return{keys:this.keys,records:this.records}}}function mi(t,r,{getFn:s=Se.getFn,fieldNormWeight:a=Se.fieldNormWeight}={}){const n=new Fa({getFn:s,fieldNormWeight:a});return n.setKeys(t.map(ui)),n.setSources(r),n.create(),n}function Gm(t,{getFn:r=Se.getFn,fieldNormWeight:s=Se.fieldNormWeight}={}){const{keys:a,records:n}=t,o=new Fa({getFn:r,fieldNormWeight:s});return o.setKeys(a),o.setIndexRecords(n),o}function ss(t,{errors:r=0,currentLocation:s=0,expectedLocation:a=0,distance:n=Se.distance,ignoreLocation:o=Se.ignoreLocation}={}){const i=r/t.length;if(o)return i;const c=Math.abs(a-s);return n?i+c/n:c?1:i}function Vm(t=[],r=Se.minMatchCharLength){let s=[],a=-1,n=-1,o=0;for(let i=t.length;o<i;o+=1){let c=t[o];c&&a===-1?a=o:!c&&a!==-1&&(n=o-1,n-a+1>=r&&s.push([a,n]),a=-1)}return t[o-1]&&o-a>=r&&s.push([a,o-1]),s}const Zt=32;function qm(t,r,s,{location:a=Se.location,distance:n=Se.distance,threshold:o=Se.threshold,findAllMatches:i=Se.findAllMatches,minMatchCharLength:c=Se.minMatchCharLength,includeMatches:d=Se.includeMatches,ignoreLocation:u=Se.ignoreLocation}={}){if(r.length>Zt)throw new Error(Pm(Zt));const m=r.length,h=t.length,p=Math.max(0,Math.min(a,h));let g=o,f=p;const x=c>1||d,y=x?Array(h):[];let N;for(;(N=t.indexOf(r,f))>-1;){let S=ss(r,{currentLocation:N,expectedLocation:p,distance:n,ignoreLocation:u});if(g=Math.min(S,g),f=N+m,x){let b=0;for(;b<m;)y[N+b]=1,b+=1}}f=-1;let j=[],v=1,k=m+h;const A=1<<m-1;for(let S=0;S<m;S+=1){let b=0,C=k;for(;b<C;)ss(r,{errors:S,currentLocation:p+C,expectedLocation:p,distance:n,ignoreLocation:u})<=g?b=C:k=C,C=Math.floor((k-b)/2+b);k=C;let E=Math.max(1,p-C+1),B=i?h:Math.min(p+C,h)+m,T=Array(B+2);T[B+1]=(1<<S)-1;for(let H=B;H>=E;H-=1){let _=H-1,M=s[t.charAt(_)];if(x&&(y[_]=+!!M),T[H]=(T[H+1]<<1|1)&M,S&&(T[H]|=(j[H+1]|j[H])<<1|1|j[H+1]),T[H]&A&&(v=ss(r,{errors:S,currentLocation:_,expectedLocation:p,distance:n,ignoreLocation:u}),v<=g)){if(g=v,f=_,f<=p)break;E=Math.max(1,2*p-f)}}if(ss(r,{errors:S+1,currentLocation:p,expectedLocation:p,distance:n,ignoreLocation:u})>g)break;j=T}const P={isMatch:f>=0,score:Math.max(.001,v)};if(x){const S=Vm(y,c);S.length?d&&(P.indices=S):P.isMatch=!1}return P}function Km(t){let r={};for(let s=0,a=t.length;s<a;s+=1){const n=t.charAt(s);r[n]=(r[n]||0)|1<<a-s-1}return r}const fs=String.prototype.normalize?(t=>t.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"")):(t=>t);class pi{constructor(r,{location:s=Se.location,threshold:a=Se.threshold,distance:n=Se.distance,includeMatches:o=Se.includeMatches,findAllMatches:i=Se.findAllMatches,minMatchCharLength:c=Se.minMatchCharLength,isCaseSensitive:d=Se.isCaseSensitive,ignoreDiacritics:u=Se.ignoreDiacritics,ignoreLocation:m=Se.ignoreLocation}={}){if(this.options={location:s,threshold:a,distance:n,includeMatches:o,findAllMatches:i,minMatchCharLength:c,isCaseSensitive:d,ignoreDiacritics:u,ignoreLocation:m},r=d?r:r.toLowerCase(),r=u?fs(r):r,this.pattern=r,this.chunks=[],!this.pattern.length)return;const h=(g,f)=>{this.chunks.push({pattern:g,alphabet:Km(g),startIndex:f})},p=this.pattern.length;if(p>Zt){let g=0;const f=p%Zt,x=p-f;for(;g<x;)h(this.pattern.substr(g,Zt),g),g+=Zt;if(f){const y=p-Zt;h(this.pattern.substr(y),y)}}else h(this.pattern,0)}searchIn(r){const{isCaseSensitive:s,ignoreDiacritics:a,includeMatches:n}=this.options;if(r=s?r:r.toLowerCase(),r=a?fs(r):r,this.pattern===r){let x={isMatch:!0,score:0};return n&&(x.indices=[[0,r.length-1]]),x}const{location:o,distance:i,threshold:c,findAllMatches:d,minMatchCharLength:u,ignoreLocation:m}=this.options;let h=[],p=0,g=!1;this.chunks.forEach(({pattern:x,alphabet:y,startIndex:N})=>{const{isMatch:j,score:v,indices:k}=qm(r,x,y,{location:o+N,distance:i,threshold:c,findAllMatches:d,minMatchCharLength:u,includeMatches:n,ignoreLocation:m});j&&(g=!0),p+=v,j&&k&&(h=[...h,...k])});let f={isMatch:g,score:g?p/this.chunks.length:1};return g&&n&&(f.indices=h),f}}class Gt{constructor(r){this.pattern=r}static isMultiMatch(r){return Pn(r,this.multiRegex)}static isSingleMatch(r){return Pn(r,this.singleRegex)}search(){}}function Pn(t,r){const s=t.match(r);return s?s[1]:null}class Jm extends Gt{constructor(r){super(r)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(r){const s=r===this.pattern;return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Ym extends Gt{constructor(r){super(r)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(r){const a=r.indexOf(this.pattern)===-1;return{isMatch:a,score:a?0:1,indices:[0,r.length-1]}}}class Qm extends Gt{constructor(r){super(r)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(r){const s=r.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Xm extends Gt{constructor(r){super(r)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(r){const s=!r.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,r.length-1]}}}class Zm extends Gt{constructor(r){super(r)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(r){const s=r.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[r.length-this.pattern.length,r.length-1]}}}class ep extends Gt{constructor(r){super(r)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(r){const s=!r.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,r.length-1]}}}class xi extends Gt{constructor(r,{location:s=Se.location,threshold:a=Se.threshold,distance:n=Se.distance,includeMatches:o=Se.includeMatches,findAllMatches:i=Se.findAllMatches,minMatchCharLength:c=Se.minMatchCharLength,isCaseSensitive:d=Se.isCaseSensitive,ignoreDiacritics:u=Se.ignoreDiacritics,ignoreLocation:m=Se.ignoreLocation}={}){super(r),this._bitapSearch=new pi(r,{location:s,threshold:a,distance:n,includeMatches:o,findAllMatches:i,minMatchCharLength:c,isCaseSensitive:d,ignoreDiacritics:u,ignoreLocation:m})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(r){return this._bitapSearch.searchIn(r)}}class gi extends Gt{constructor(r){super(r)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(r){let s=0,a;const n=[],o=this.pattern.length;for(;(a=r.indexOf(this.pattern,s))>-1;)s=a+o,n.push([a,s-1]);const i=!!n.length;return{isMatch:i,score:i?0:1,indices:n}}}const ma=[Jm,gi,Qm,Xm,ep,Zm,Ym,xi],$n=ma.length,tp=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,rp="|";function sp(t,r={}){return t.split(rp).map(s=>{let a=s.trim().split(tp).filter(o=>o&&!!o.trim()),n=[];for(let o=0,i=a.length;o<i;o+=1){const c=a[o];let d=!1,u=-1;for(;!d&&++u<$n;){const m=ma[u];let h=m.isMultiMatch(c);h&&(n.push(new m(h,r)),d=!0)}if(!d)for(u=-1;++u<$n;){const m=ma[u];let h=m.isSingleMatch(c);if(h){n.push(new m(h,r));break}}}return n})}const ap=new Set([xi.type,gi.type]);class np{constructor(r,{isCaseSensitive:s=Se.isCaseSensitive,ignoreDiacritics:a=Se.ignoreDiacritics,includeMatches:n=Se.includeMatches,minMatchCharLength:o=Se.minMatchCharLength,ignoreLocation:i=Se.ignoreLocation,findAllMatches:c=Se.findAllMatches,location:d=Se.location,threshold:u=Se.threshold,distance:m=Se.distance}={}){this.query=null,this.options={isCaseSensitive:s,ignoreDiacritics:a,includeMatches:n,minMatchCharLength:o,findAllMatches:c,ignoreLocation:i,location:d,threshold:u,distance:m},r=s?r:r.toLowerCase(),r=a?fs(r):r,this.pattern=r,this.query=sp(this.pattern,this.options)}static condition(r,s){return s.useExtendedSearch}searchIn(r){const s=this.query;if(!s)return{isMatch:!1,score:1};const{includeMatches:a,isCaseSensitive:n,ignoreDiacritics:o}=this.options;r=n?r:r.toLowerCase(),r=o?fs(r):r;let i=0,c=[],d=0;for(let u=0,m=s.length;u<m;u+=1){const h=s[u];c.length=0,i=0;for(let p=0,g=h.length;p<g;p+=1){const f=h[p],{isMatch:x,indices:y,score:N}=f.search(r);if(x){if(i+=1,d+=N,a){const j=f.constructor.type;ap.has(j)?c=[...c,...y]:c.push(y)}}else{d=0,i=0,c.length=0;break}}if(i){let p={isMatch:!0,score:d/i};return a&&(p.indices=c),p}}return{isMatch:!1,score:1}}}const pa=[];function op(...t){pa.push(...t)}function xa(t,r){for(let s=0,a=pa.length;s<a;s+=1){let n=pa[s];if(n.condition(t,r))return new n(t,r)}return new pi(t,r)}const bs={AND:"$and",OR:"$or"},ga={PATH:"$path",PATTERN:"$val"},ha=t=>!!(t[bs.AND]||t[bs.OR]),ip=t=>!!t[ga.PATH],lp=t=>!_t(t)&&ci(t)&&!ha(t),_n=t=>({[bs.AND]:Object.keys(t).map(r=>({[r]:t[r]}))});function hi(t,r,{auto:s=!0}={}){const a=n=>{let o=Object.keys(n);const i=ip(n);if(!i&&o.length>1&&!ha(n))return a(_n(n));if(lp(n)){const d=i?n[ga.PATH]:o[0],u=i?n[ga.PATTERN]:n[d];if(!At(u))throw new Error(Lm(d));const m={keyId:ua(d),pattern:u};return s&&(m.searcher=xa(u,r)),m}let c={children:[],operator:o[0]};return o.forEach(d=>{const u=n[d];_t(u)&&u.forEach(m=>{c.children.push(a(m))})}),c};return ha(t)||(t=_n(t)),a(t)}function cp(t,{ignoreFieldNorm:r=Se.ignoreFieldNorm}){t.forEach(s=>{let a=1;s.matches.forEach(({key:n,norm:o,score:i})=>{const c=n?n.weight:null;a*=Math.pow(i===0&&c?Number.EPSILON:i,(c||1)*(r?1:o))}),s.score=a})}function dp(t,r){const s=t.matches;r.matches=[],gt(s)&&s.forEach(a=>{if(!gt(a.indices)||!a.indices.length)return;const{indices:n,value:o}=a;let i={indices:n,value:o};a.key&&(i.key=a.key.src),a.idx>-1&&(i.refIndex=a.idx),r.matches.push(i)})}function up(t,r){r.score=t.score}function mp(t,r,{includeMatches:s=Se.includeMatches,includeScore:a=Se.includeScore}={}){const n=[];return s&&n.push(dp),a&&n.push(up),t.map(o=>{const{idx:i}=o,c={item:r[i],refIndex:i};return n.length&&n.forEach(d=>{d(o,c)}),c})}class yr{constructor(r,s={},a){this.options={...Se,...s},this.options.useExtendedSearch,this._keyStore=new Fm(this.options.keys),this.setCollection(r,a)}setCollection(r,s){if(this._docs=r,s&&!(s instanceof Fa))throw new Error(Dm);this._myIndex=s||mi(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(r){gt(r)&&(this._docs.push(r),this._myIndex.add(r))}remove(r=()=>!1){const s=[];for(let a=0,n=this._docs.length;a<n;a+=1){const o=this._docs[a];r(o,a)&&(this.removeAt(a),a-=1,n-=1,s.push(o))}return s}removeAt(r){this._docs.splice(r,1),this._myIndex.removeAt(r)}getIndex(){return this._myIndex}search(r,{limit:s=-1}={}){const{includeMatches:a,includeScore:n,shouldSort:o,sortFn:i,ignoreFieldNorm:c}=this.options;let d=At(r)?At(this._docs[0])?this._searchStringList(r):this._searchObjectList(r):this._searchLogical(r);return cp(d,{ignoreFieldNorm:c}),o&&d.sort(i),li(s)&&s>-1&&(d=d.slice(0,s)),mp(d,this._docs,{includeMatches:a,includeScore:n})}_searchStringList(r){const s=xa(r,this.options),{records:a}=this._myIndex,n=[];return a.forEach(({v:o,i,n:c})=>{if(!gt(o))return;const{isMatch:d,score:u,indices:m}=s.searchIn(o);d&&n.push({item:o,idx:i,matches:[{score:u,value:o,norm:c,indices:m}]})}),n}_searchLogical(r){const s=hi(r,this.options),a=(c,d,u)=>{if(!c.children){const{keyId:h,searcher:p}=c,g=this._findMatches({key:this._keyStore.get(h),value:this._myIndex.getValueForItemAtKeyId(d,h),searcher:p});return g&&g.length?[{idx:u,item:d,matches:g}]:[]}const m=[];for(let h=0,p=c.children.length;h<p;h+=1){const g=c.children[h],f=a(g,d,u);if(f.length)m.push(...f);else if(c.operator===bs.AND)return[]}return m},n=this._myIndex.records,o={},i=[];return n.forEach(({$:c,i:d})=>{if(gt(c)){let u=a(s,c,d);u.length&&(o[d]||(o[d]={idx:d,item:c,matches:[]},i.push(o[d])),u.forEach(({matches:m})=>{o[d].matches.push(...m)}))}}),i}_searchObjectList(r){const s=xa(r,this.options),{keys:a,records:n}=this._myIndex,o=[];return n.forEach(({$:i,i:c})=>{if(!gt(i))return;let d=[];a.forEach((u,m)=>{d.push(...this._findMatches({key:u,value:i[m],searcher:s}))}),d.length&&o.push({idx:c,item:i,matches:d})}),o}_findMatches({key:r,value:s,searcher:a}){if(!gt(s))return[];let n=[];if(_t(s))s.forEach(({v:o,i,n:c})=>{if(!gt(o))return;const{isMatch:d,score:u,indices:m}=a.searchIn(o);d&&n.push({score:u,key:r,value:o,idx:i,norm:c,indices:m})});else{const{v:o,n:i}=s,{isMatch:c,score:d,indices:u}=a.searchIn(o);c&&n.push({score:d,key:r,value:o,norm:i,indices:u})}return n}}yr.version="7.1.0";yr.createIndex=mi;yr.parseIndex=Gm;yr.config=Se;yr.parseQuery=hi;op(np);const pp=150,fi=t=>`command_history_${t}`,Qs=t=>{const r=ot.getItem(fi(t));if(!r)return{};try{return JSON.parse(r)}catch(s){return console.error("Error parsing command history:",s),{}}},xp=(t,r)=>{ot.setItem(fi(t),JSON.stringify(r))},Fn=t=>!!t&&typeof t.then=="function";function gp({selectedProject:t,input:r,setInput:s,textareaRef:a,onExecuteCommand:n}){const[o,i]=l.useState([]),[c,d]=l.useState([]),[u,m]=l.useState(!1),[h,p]=l.useState(""),[g,f]=l.useState(-1),[x,y]=l.useState(-1),N=l.useRef(null),j=l.useCallback(()=>{N.current!==null&&(window.clearTimeout(N.current),N.current=null)},[]),v=l.useCallback(()=>{m(!1),y(-1),p(""),f(-1),j()},[j]);l.useEffect(()=>{(async()=>{if(!t){i([]),d([]);return}try{const W=await Te("/api/commands/list",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectPath:t.fullPath||t.path})});if(!W.ok)throw new Error("Failed to fetch commands");const H=await W.json(),_=[...(H.builtIn||[]).map(K=>({...K,type:"built-in"})),...(H.custom||[]).map(K=>({...K,type:"custom"}))],M=Qs(t.name),z=[..._].sort((K,te)=>{const q=M[K.name]||0;return(M[te.name]||0)-q});i(z)}catch(W){console.error("Error fetching slash commands:",W),i([])}})()},[t]),l.useEffect(()=>{u||f(-1)},[u]);const k=l.useMemo(()=>o.length?new yr(o,{keys:[{name:"name",weight:2},{name:"description",weight:1}],threshold:.4,includeScore:!0,minMatchCharLength:1}):null,[o]);l.useEffect(()=>{if(!h){d(o);return}if(!k){d([]);return}const T=k.search(h);d(T.map(W=>W.item))},[h,o,k]);const A=l.useMemo(()=>{if(!t||o.length===0)return[];const T=Qs(t.name);return o.map(W=>({...W,usageCount:T[W.name]||0})).filter(W=>W.usageCount>0).sort((W,H)=>H.usageCount-W.usageCount).slice(0,5)},[t,o]),P=l.useCallback(T=>{if(!t)return;const W=Qs(t.name);W[T.name]=(W[T.name]||0)+1,xp(t.name,W)},[t]),S=l.useCallback(T=>{const W=r.slice(0,x),H=r.slice(x),_=H.indexOf(" "),M=_!==-1?H.slice(_):"",z=`${W}${T.name} ${M}`;s(z),v();const K=n(T);Fn(K)&&K.catch(()=>{})},[r,x,s,v,n]),b=l.useCallback((T,W,H)=>{if(!T||!t)return;if(H){f(W);return}P(T);const _=n(T);Fn(_)?(_.then(()=>{v()}),_.catch(()=>{})):v()},[t,P,n,v]),C=l.useCallback(()=>{var W;const T=!u;m(T),p(""),f(-1),T&&d(o),(W=a.current)==null||W.focus()},[u,o,a]),E=l.useCallback((T,W)=>{if(!T.trim()){v();return}const H=T.slice(0,W);if((H.match(/```/g)||[]).length%2===1){v();return}const z=/(^|\s)\/(\S*)$/,K=H.match(z);if(!K){v();return}const te=(K.index||0)+K[1].length,q=K[2];y(te),m(!0),f(-1),j(),N.current=window.setTimeout(()=>{p(q)},pp)},[v,j]),B=l.useCallback(T=>u?c.length?T.key==="ArrowDown"?(T.preventDefault(),f(W=>W<c.length-1?W+1:0),!0):T.key==="ArrowUp"?(T.preventDefault(),f(W=>W>0?W-1:c.length-1),!0):T.key==="Tab"||T.key==="Enter"?(T.preventDefault(),g>=0?S(c[g]):c.length>0&&S(c[0]),!0):T.key==="Escape"?(T.preventDefault(),v(),!0):!1:T.key==="Escape"?(T.preventDefault(),v(),!0):!1:!1,[u,c,v,S,g]);return l.useEffect(()=>()=>{j()},[j]),{slashCommands:o,slashCommandsCount:o.length,filteredCommands:c,frequentCommands:A,commandQuery:h,showCommandMenu:u,selectedCommandIndex:g,resetCommandMenuState:v,handleCommandSelect:b,handleToggleCommandMenu:C,handleCommandInputChange:E,handleCommandMenuKeyDown:B}}const hp=()=>({preventDefault:()=>{}}),fp=t=>!!(t&&t.startsWith("new-session-"));function bp({selectedProject:t,selectedSession:r,currentSessionId:s,provider:a,permissionMode:n,cyclePermissionMode:o,cursorModel:i,claudeModel:c,codexModel:d,isLoading:u,canAbortSession:m,tokenBudget:h,sendMessage:p,sendByCtrlEnter:g,onSessionActive:f,onInputFocusChange:x,onFileOpen:y,onShowSettings:N,pendingViewSessionRef:j,scrollToBottom:v,setChatMessages:k,setSessionMessages:A,setIsLoading:P,setCanAbortSession:S,setClaudeStatus:b,setIsUserScrolledUp:C,setPendingPermissionRequests:E}){const[B,T]=l.useState(()=>typeof window<"u"&&t&&ot.getItem(`draft_input_${t.name}`)||""),[W,H]=l.useState([]),[_,M]=l.useState(new Map),[z,K]=l.useState(new Map),[te,q]=l.useState(!1),[ie,$]=l.useState("none"),[X,re]=l.useState("code"),{confirm:Y,dialogProps:U,ConfirmDialog:O}=Ma(),F=l.useRef(null),V=l.useRef(null),R=l.useRef(null),Z=l.useRef(B),G=l.useCallback(de=>{const{action:ue,data:le}=de;switch(ue){case"clear":k([]),A==null||A([]);break;case"help":k(je=>[...je,{type:"assistant",content:le.content,timestamp:Date.now()}]);break;case"model":k(je=>[...je,{type:"assistant",content:`**Current Model**: ${le.current.model}
149
+
150
+ **Available Models**:
151
+
152
+ Claude: ${le.available.claude.join(", ")}
153
+
154
+ Cursor: ${le.available.cursor.join(", ")}`,timestamp:Date.now()}]);break;case"cost":{const je=`**Token Usage**: ${le.tokenUsage.used.toLocaleString()} / ${le.tokenUsage.total.toLocaleString()} (${le.tokenUsage.percentage}%)
155
+
156
+ **Estimated Cost**:
157
+ - Input: $${le.cost.input}
158
+ - Output: $${le.cost.output}
159
+ - **Total**: $${le.cost.total}
160
+
161
+ **Model**: ${le.model}`;k(We=>[...We,{type:"assistant",content:je,timestamp:Date.now()}]);break}case"status":{const je=`**System Status**
162
+
163
+ - Version: ${le.version}
164
+ - Uptime: ${le.uptime}
165
+ - Model: ${le.model}
166
+ - Provider: ${le.provider}
167
+ - Node.js: ${le.nodeVersion}
168
+ - Platform: ${le.platform}`;k(We=>[...We,{type:"assistant",content:je,timestamp:Date.now()}]);break}case"memory":le.error?k(je=>[...je,{type:"assistant",content:`⚠️ ${le.message}`,timestamp:Date.now()}]):(k(je=>[...je,{type:"assistant",content:`📝 ${le.message}
169
+
170
+ Path: \`${le.path}\``,timestamp:Date.now()}]),le.exists&&y&&y(le.path));break;case"config":N==null||N();break;case"rewind":le.error?k(je=>[...je,{type:"assistant",content:`⚠️ ${le.message}`,timestamp:Date.now()}]):(k(je=>je.slice(0,-le.steps*2)),k(je=>[...je,{type:"assistant",content:`⏪ ${le.message}`,timestamp:Date.now()}]));break}},[y,N,k,A]),w=l.useCallback(async de=>{const{content:ue,hasBashCommands:le}=de;if(le&&!await Y({title:"Execute Bash Commands",message:"This command contains bash commands that will be executed. Do you want to proceed?",variant:"warning",confirmLabel:"Execute",cancelLabel:"Cancel"})){k(Qe=>[...Qe,{type:"assistant",content:"❌ Command execution cancelled",timestamp:Date.now()}]);return}const je=ue||"";T(je),Z.current=je,setTimeout(()=>{R.current&&R.current(hp())},0)},[Y,k]),I=l.useCallback(async de=>{if(!(!de||!t))try{const ue=B.match(new RegExp(`${Bo(de.name)}\\s*(.*)`)),le=ue&&ue[1]?ue[1].trim().split(/\s+/):[],je={projectPath:t.fullPath||t.path,projectName:t.name,sessionId:s,provider:a,model:a==="cursor"?i:a==="codex"?d:c,tokenUsage:h},We=await Te("/api/commands/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandName:de.name,commandPath:de.path,args:le,context:je})});if(!We.ok){let Xe=`Failed to execute command (${We.status})`;try{const ut=await We.json();Xe=(ut==null?void 0:ut.message)||(ut==null?void 0:ut.error)||Xe}catch{}throw new Error(Xe)}const Qe=await We.json();Qe.type==="builtin"?(G(Qe),T(""),Z.current=""):Qe.type==="custom"&&await w(Qe)}catch(ue){const le=ue instanceof Error?ue.message:"Unknown error";k(je=>[...je,{type:"assistant",content:`Error executing command: ${le}`,timestamp:Date.now()}])}},[c,d,s,i,G,w,B,a,t,k,h]),{slashCommandsCount:J,filteredCommands:se,frequentCommands:ce,commandQuery:Ce,showCommandMenu:fe,selectedCommandIndex:_e,resetCommandMenuState:we,handleCommandSelect:Ae,handleToggleCommandMenu:Re,handleCommandInputChange:Ie,handleCommandMenuKeyDown:L}=gp({selectedProject:t,input:B,setInput:T,textareaRef:F,onExecuteCommand:I}),{showFileDropdown:ee,filteredFiles:ge,selectedFileIndex:be,renderInputWithMentions:Pe,selectFile:Fe,setCursorPosition:ze,handleFileMentionsKeyDown:Ve}=Em({selectedProject:t,input:B,setInput:T,textareaRef:F}),ne=l.useCallback(de=>{!V.current||!de||(V.current.scrollTop=de.scrollTop,V.current.scrollLeft=de.scrollLeft)},[]),he=l.useCallback(de=>{const ue=de.filter(le=>{try{if(!le||typeof le!="object"||!le.type||!le.type.startsWith("image/"))return!1;if(!le.size||le.size>5242880){const je=le.name||"Unknown file";return K(We=>{const Qe=new Map(We);return Qe.set(je,"File too large (max 5MB)"),Qe}),!1}return!0}catch{return!1}});ue.length>0&&H(le=>[...le,...ue].slice(0,5))},[]),Ne=l.useCallback(de=>{const ue=Array.from(de.clipboardData.items);if(ue.forEach(le=>{if(!le.type.startsWith("image/"))return;const je=le.getAsFile();je&&he([je])}),ue.length===0&&de.clipboardData.files.length>0){const je=Array.from(de.clipboardData.files).filter(We=>We.type.startsWith("image/"));je.length>0&&he(je)}},[he]),{getRootProps:Me,getInputProps:Le,isDragActive:Oe,open:Je}=oi({accept:{"image/*":[".png",".jpg",".jpeg",".gif",".webp",".svg"]},maxSize:5*1024*1024,maxFiles:5,onDrop:he,noClick:!0,noKeyboard:!0}),ae=l.useCallback(async de=>{de.preventDefault();const ue=Z.current;if(!ue.trim()||u||!t)return;if(ue.trimStart().startsWith("!")){const at=ue.trimStart().slice(1).trim();if(!at)return;const rt=t.fullPath||t.path||"";k(zt=>[...zt,{type:"user",content:ue,timestamp:new Date}]),P(!0),p({type:"shell-exec",command:at,cwd:rt}),T(""),Z.current="",we(),H([]),q(!1),F.current&&(F.current.style.height="auto"),ot.removeItem(`draft_input_${t.name}`);return}let le=ue;const je=Ko.find(at=>at.id===ie);je&&je.prefix&&(le=`${je.prefix}: ${ue}`);let We=[];if(W.length>0){const at=new FormData;W.forEach(rt=>{at.append("images",rt)});try{const rt=await Te(`/api/projects/${t.name}/upload-images`,{method:"POST",headers:{},body:at});if(!rt.ok)throw new Error("Failed to upload images");We=(await rt.json()).images}catch(rt){const zt=rt instanceof Error?rt.message:"Unknown error";k(vr=>[...vr,{type:"error",content:`Failed to upload images: ${zt}`,timestamp:new Date}]);return}}const Qe={type:"user",content:ue,images:We,timestamp:new Date};k(at=>[...at,Qe]),P(!0),S(!0),b({text:"Processing",tokens:0,can_interrupt:!0}),C(!1),setTimeout(()=>v(),100);const Xe=s||(r==null?void 0:r.id)||sessionStorage.getItem("cursorSessionId"),ut=Xe||`new-session-${Date.now()}`;!Xe&&!(r!=null&&r.id)&&(typeof window<"u"&&sessionStorage.removeItem("pendingSessionId"),j.current={sessionId:null,startedAt:Date.now()}),f==null||f(ut);const yt=(()=>{try{const at=a==="cursor"?"cursor-tools-settings":a==="codex"?"codex-settings":"claude-settings",rt=ot.getItem(at);if(rt)return JSON.parse(rt)}catch{}return{allowedTools:[],disallowedTools:[],skipPermissions:!1}})(),pt=t.fullPath||t.path||"";p(a==="cursor"?{type:"cursor-command",command:le,sessionId:Xe,options:{cwd:pt,projectPath:pt,sessionId:Xe,resume:!!Xe,model:i,skipPermissions:(yt==null?void 0:yt.skipPermissions)||!1,toolsSettings:yt}}:a==="codex"?{type:"codex-command",command:le,sessionId:Xe,options:{cwd:pt,projectPath:pt,sessionId:Xe,resume:!!Xe,model:d,permissionMode:n==="plan"?"default":n}}:{type:"claude-command",command:le,options:{projectPath:pt,cwd:pt,sessionId:Xe,resume:!!Xe,toolsSettings:yt,permissionMode:n,model:c,images:We,aiMode:X}}),T(""),Z.current="",we(),H([]),M(new Map),K(new Map),q(!1),$("none"),F.current&&(F.current.style.height="auto"),ot.removeItem(`draft_input_${t.name}`)},[W,c,d,s,i,u,f,j,n,a,we,v,t,r==null?void 0:r.id,p,S,k,b,P,C,ie,X]);l.useEffect(()=>{R.current=ae},[ae]),l.useEffect(()=>{Z.current=B},[B]),l.useEffect(()=>{if(!t)return;const de=ot.getItem(`draft_input_${t.name}`)||"";T(ue=>{const le=ue===de?ue:de;return Z.current=le,le})},[t==null?void 0:t.name]),l.useEffect(()=>{t&&(B!==""?ot.setItem(`draft_input_${t.name}`,B):ot.removeItem(`draft_input_${t.name}`))},[B,t]),l.useEffect(()=>{if(!F.current)return;F.current.style.height="auto",F.current.style.height=`${F.current.scrollHeight}px`;const de=parseInt(window.getComputedStyle(F.current).lineHeight),ue=F.current.scrollHeight>de*2;q(ue)},[B]),l.useEffect(()=>{!F.current||B.trim()||(F.current.style.height="auto",q(!1))},[B]);const ye=l.useCallback(de=>{const ue=de.target.value,le=de.target.selectionStart;if(T(ue),Z.current=ue,ze(le),!ue.trim()){de.target.style.height="auto",q(!1),we();return}Ie(ue,le)},[Ie,we,ze]),$e=l.useCallback(de=>{if(!L(de)&&!Ve(de)){if(de.key==="Tab"&&!ee&&!fe){de.preventDefault(),o();return}if(de.key==="Enter"){if(de.nativeEvent.isComposing)return;((de.ctrlKey||de.metaKey)&&!de.shiftKey||!de.shiftKey&&!de.ctrlKey&&!de.metaKey&&!g)&&(de.preventDefault(),ae(de))}}},[o,L,Ve,ae,g,fe,ee]),Ee=l.useCallback(de=>{ze(de.currentTarget.selectionStart)},[ze]),Ye=l.useCallback(de=>{const ue=de.currentTarget;ue.style.height="auto",ue.style.height=`${ue.scrollHeight}px`,ze(ue.selectionStart),ne(ue);const le=parseInt(window.getComputedStyle(ue).lineHeight);q(ue.scrollHeight>le*2)},[ze,ne]),it=l.useCallback(()=>{T(""),Z.current="",we(),F.current&&(F.current.style.height="auto",F.current.focus()),q(!1)},[we]),dt=l.useCallback(()=>{var We;if(!m)return;const de=typeof window<"u"?sessionStorage.getItem("pendingSessionId"):null,ue=typeof window<"u"?sessionStorage.getItem("cursorSessionId"):null,je=[s,((We=j.current)==null?void 0:We.sessionId)||null,de,a==="cursor"?ue:null,(r==null?void 0:r.id)||null].find(Qe=>!!Qe&&!fp(Qe))||null;je&&p({type:"abort-session",sessionId:je,provider:a})},[m,s,j,a,r==null?void 0:r.id,p]),It=l.useCallback(de=>{de.trim()&&T(ue=>{const le=ue.trim()?`${ue} ${de}`:de;return Z.current=le,setTimeout(()=>{if(!F.current)return;F.current.style.height="auto",F.current.style.height=`${F.current.scrollHeight}px`;const je=parseInt(window.getComputedStyle(F.current).lineHeight);q(F.current.scrollHeight>je*2)},0),le})},[]),Mt=l.useCallback(de=>!de||a!=="claude"?{success:!1}:Td(de.entry),[a]),Ct=l.useCallback((de,ue)=>{const je=(Array.isArray(de)?de:[de]).filter(Boolean);je.length!==0&&(je.forEach(We=>{p({type:"claude-permission-response",requestId:We,allow:!!(ue!=null&&ue.allow),updatedInput:ue==null?void 0:ue.updatedInput,message:ue==null?void 0:ue.message,rememberEntry:ue==null?void 0:ue.rememberEntry})}),E(We=>{const Qe=We.filter(Xe=>!je.includes(Xe.requestId));return Qe.length===0&&b(null),Qe}))},[p,b,E]),[Ft,ht]=l.useState(!1),Vt=l.useCallback(de=>{ht(de),x==null||x(de)},[x]);return{input:B,setInput:T,textareaRef:F,inputHighlightRef:V,isTextareaExpanded:te,thinkingMode:ie,setThinkingMode:$,aiMode:X,setAiMode:re,slashCommandsCount:J,filteredCommands:se,frequentCommands:ce,commandQuery:Ce,showCommandMenu:fe,selectedCommandIndex:_e,resetCommandMenuState:we,handleCommandSelect:Ae,handleToggleCommandMenu:Re,showFileDropdown:ee,filteredFiles:ge,selectedFileIndex:be,renderInputWithMentions:Pe,selectFile:Fe,attachedImages:W,setAttachedImages:H,uploadingImages:_,imageErrors:z,getRootProps:Me,getInputProps:Le,isDragActive:Oe,openImagePicker:Je,handleSubmit:ae,handleInputChange:ye,handleKeyDown:$e,handlePaste:Ne,handleTextareaClick:Ee,handleTextareaInput:Ye,syncInputOverlayScroll:ne,handleClearInput:it,handleAbortSession:dt,handleTranscript:It,handlePermissionDecision:Ct,handleGrantToolPermission:Mt,handleInputFocusChange:Vt,isInputFocused:Ft,commandConfirmDialogProps:U,CommandConfirmDialog:O}}const yp=[{pattern:/\b(?:open|show|go to|switch to|navigate to)\s+(?:the\s+)?(?:chat|conversation)\b/i,tab:"chat"},{pattern:/\b(?:open|show|go to|switch to|navigate to)\s+(?:the\s+)?(?:terminal|shell|console|command line)\b/i,tab:"shell"},{pattern:/\b(?:open|show|go to|switch to|navigate to)\s+(?:the\s+)?(?:files?|file\s*(?:tree|explorer|browser|manager))\b/i,tab:"files"},{pattern:/\b(?:open|show|go to|switch to|navigate to)\s+(?:the\s+)?(?:git|version control|source control)\b/i,tab:"git"},{pattern:/\b(?:open|show|go to|switch to|navigate to)\s+(?:the\s+)?(?:workflows?|automations?|cron)\b/i,tab:"workflows"},{pattern:/\b(?:open|show|go to|switch to|navigate to)\s+(?:the\s+)?(?:tasks?|task\s*master)\b/i,tab:"tasks"}],vp=[{pattern:/\b(?:run|execute)\s+git\s+status\b/i,action:"git-status"},{pattern:/\b(?:run|execute)\s+git\s+(.+)/i,action:"git-command",extractArgs:t=>t[1]},{pattern:/\b(?:create|start|new)\s+(?:a\s+)?(?:new\s+)?session\b/i,action:"new-session"},{pattern:/\b(?:clear|reset)\s+(?:the\s+)?(?:chat|conversation)\b/i,action:"clear-chat"},{pattern:/\bscroll\s+(?:to\s+)?(?:the\s+)?(?:bottom|down)\b/i,action:"scroll-bottom"},{pattern:/\b(?:stop|cancel|abort)\s+(?:the\s+)?(?:session|response|generation)\b/i,action:"abort"}];function zn(t){const r=t.trim();if(!r)return null;for(const{pattern:s,tab:a}of yp)if(s.test(r))return{type:"navigate",tab:a};for(const{pattern:s,action:a,extractArgs:n}of vp){const o=r.match(s);if(o)return{type:"action",action:a,args:n?n(o):void 0}}return null}function kp({setActiveTab:t,onChatInput:r,onAbortSession:s,onScrollToBottom:a}){return{routeTranscript:l.useCallback(o=>{const i=zn(o);if(!i){r(o);return}if(i.type==="navigate"){t(i.tab);return}if(i.type==="action")switch(i.action){case"abort":s==null||s();return;case"scroll-bottom":a==null||a();return;case"new-session":t("chat");return;case"git-status":case"git-command":t("git");return;case"clear-chat":t("chat");return;default:r(o)}},[t,r,s,a]),parseIntent:zn}}function wp({selectedProject:t,selectedSession:r,ws:s,sendMessage:a,latestMessage:n,onFileOpen:o,onInputFocusChange:i,onSessionActive:c,onSessionInactive:d,onSessionProcessing:u,onSessionNotProcessing:m,processingSessions:h,onReplaceTemporarySession:p,onNavigateToSession:g,onShowSettings:f,autoExpandTools:x,showRawParameters:y,showThinking:N,autoScrollToBottom:j,sendByCtrlEnter:v,externalMessageUpdate:k,onShowAllTasks:A,setActiveTab:P,onArtifactOpen:S}){const{tasksEnabled:b,isTaskMasterInstalled:C}=zr(),{t:E}=Be("chat"),{speak:B}=Jo(),T=l.useRef(""),W=l.useRef(null),H=l.useRef(null),_=l.useCallback(()=>{W.current&&(clearTimeout(W.current),W.current=null),T.current=""},[]),{provider:M,setProvider:z,cursorModel:K,setCursorModel:te,claudeModel:q,setClaudeModel:ie,codexModel:$,setCodexModel:X,permissionMode:re,pendingPermissionRequests:Y,setPendingPermissionRequests:U,cyclePermissionMode:O}=bu({selectedSession:r}),{chatMessages:F,setChatMessages:V,isLoading:R,setIsLoading:Z,currentSessionId:G,setCurrentSessionId:w,sessionMessages:I,setSessionMessages:J,isLoadingSessionMessages:se,isLoadingMoreMessages:ce,hasMoreMessages:Ce,totalMessages:fe,setIsSystemSessionChange:_e,canAbortSession:we,setCanAbortSession:Ae,isUserScrolledUp:Re,setIsUserScrolledUp:Ie,tokenBudget:L,setTokenBudget:ee,visibleMessageCount:ge,visibleMessages:be,loadEarlierMessages:Pe,loadAllMessages:Fe,allMessagesLoaded:ze,isLoadingAllMessages:Ve,loadAllJustFinished:ne,showLoadAllOverlay:he,claudeStatus:Ne,setClaudeStatus:Me,createDiff:Le,scrollContainerRef:Oe,scrollToBottom:Je,scrollToBottomAndReset:ae,handleScroll:ye}=Cu({selectedProject:t,selectedSession:r,ws:s,sendMessage:a,autoScrollToBottom:j,externalMessageUpdate:k,processingSessions:h,resetStreamingState:_,pendingViewSessionRef:H}),{input:$e,setInput:Ee,textareaRef:Ye,inputHighlightRef:it,isTextareaExpanded:dt,thinkingMode:It,setThinkingMode:Mt,aiMode:Ct,setAiMode:Ft,slashCommandsCount:ht,filteredCommands:Vt,frequentCommands:de,commandQuery:ue,showCommandMenu:le,selectedCommandIndex:je,resetCommandMenuState:We,handleCommandSelect:Qe,handleToggleCommandMenu:Xe,showFileDropdown:ut,filteredFiles:Br,selectedFileIndex:yt,renderInputWithMentions:pt,selectFile:at,attachedImages:rt,setAttachedImages:zt,uploadingImages:vr,imageErrors:Ns,getRootProps:kr,getInputProps:ir,isDragActive:Wr,openImagePicker:Cs,handleSubmit:Ss,handleInputChange:Es,handleKeyDown:Ur,handlePaste:Hr,handleTextareaClick:Gr,handleTextareaInput:Ts,syncInputOverlayScroll:As,handleClearInput:Is,handleAbortSession:lr,handleTranscript:Ms,handlePermissionDecision:qt,handleGrantToolPermission:wr,handleInputFocusChange:Ds,isInputFocused:Ls,commandConfirmDialogProps:Ps,CommandConfirmDialog:$s}=bp({selectedProject:t,selectedSession:r,currentSessionId:G,provider:M,permissionMode:re,cyclePermissionMode:O,cursorModel:K,claudeModel:q,codexModel:$,isLoading:R,canAbortSession:we,tokenBudget:L,sendMessage:a,sendByCtrlEnter:v,onSessionActive:c,onInputFocusChange:i,onFileOpen:o,onShowSettings:f,pendingViewSessionRef:H,scrollToBottom:Je,setChatMessages:V,setSessionMessages:J,setIsLoading:Z,setCanAbortSession:Ae,setClaudeStatus:Me,setIsUserScrolledUp:Ie,setPendingPermissionRequests:U});Eu({latestMessage:n,provider:M,selectedProject:t,selectedSession:r,currentSessionId:G,setCurrentSessionId:w,setChatMessages:V,setIsLoading:Z,setCanAbortSession:Ae,setClaudeStatus:Me,setTokenBudget:ee,setIsSystemSessionChange:_e,setPendingPermissionRequests:U,pendingViewSessionRef:H,streamBufferRef:T,streamTimerRef:W,onSessionInactive:d,onSessionProcessing:u,onSessionNotProcessing:m,onReplaceTemporarySession:p,onNavigateToSession:g,onResponseComplete:B});const Kt=l.useMemo(()=>M==="claude"?La.OPTIONS:M==="codex"?$a.OPTIONS:Pa.OPTIONS,[M]),Vr=M==="claude"?q:M==="codex"?$:K,qr=l.useCallback(et=>{M==="claude"?(ie(et),localStorage.setItem("claude-model",et)):M==="codex"?(X(et),localStorage.setItem("codex-model",et)):(te(et),localStorage.setItem("cursor-model",et))},[M,ie,X,te]),{routeTranscript:Kr}=kp({setActiveTab:P||(()=>{}),onChatInput:Ms,onAbortSession:lr,onScrollToBottom:ae});if(l.useEffect(()=>{if(!R||!we)return;const et=D=>{D.key!=="Escape"||D.repeat||D.defaultPrevented||(D.preventDefault(),lr())};return document.addEventListener("keydown",et,{capture:!0}),()=>{document.removeEventListener("keydown",et,{capture:!0})}},[we,lr,R]),l.useEffect(()=>{const et=(r==null?void 0:r.id)||G;et&&R&&u&&u(et)},[G,R,u,r==null?void 0:r.id]),l.useEffect(()=>()=>{_()},[_]),!t){const et=E(M==="cursor"?"messageTypes.cursor":M==="codex"?"messageTypes.codex":"messageTypes.claude");return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("div",{className:"text-center text-muted-foreground",children:e.jsx("p",{className:"text-sm",children:E("projectSelection.startChatWithProvider",{provider:et,defaultValue:"Select a project to start chatting with {{provider}}"})})})})}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx(au,{scrollContainerRef:Oe,onWheel:ye,onTouchMove:ye,isLoadingSessionMessages:se,chatMessages:F,selectedSession:r,currentSessionId:G,provider:M,setProvider:et=>z(et),textareaRef:Ye,claudeModel:q,setClaudeModel:ie,cursorModel:K,setCursorModel:te,codexModel:$,setCodexModel:X,tasksEnabled:b,isTaskMasterInstalled:C,onShowAllTasks:A,setInput:Ee,isLoadingMoreMessages:ce,hasMoreMessages:Ce,totalMessages:fe,sessionMessagesCount:I.length,visibleMessageCount:ge,visibleMessages:be,loadEarlierMessages:Pe,loadAllMessages:Fe,allMessagesLoaded:ze,isLoadingAllMessages:Ve,loadAllJustFinished:ne,showLoadAllOverlay:he,createDiff:Le,onFileOpen:o,onShowSettings:f,onGrantToolPermission:wr,autoExpandTools:x,showRawParameters:y,showThinking:N,selectedProject:t,isLoading:R,onArtifactOpen:S}),e.jsx(fu,{pendingPermissionRequests:Y,handlePermissionDecision:qt,handleGrantToolPermission:wr,claudeStatus:Ne,isLoading:R,onAbortSession:lr,provider:M,permissionMode:re,onModeSwitch:O,thinkingMode:It,setThinkingMode:Mt,aiMode:Ct,setAiMode:Ft,tokenBudget:L,currentModel:Vr,onModelChange:qr,modelOptions:Kt,slashCommandsCount:ht,onToggleCommandMenu:Xe,hasInput:!!$e.trim(),onClearInput:Is,isUserScrolledUp:Re,hasMessages:F.length>0,onScrollToBottom:ae,onSubmit:Ss,isDragActive:Wr,attachedImages:rt,onRemoveImage:et=>zt(D=>D.filter((Q,oe)=>oe!==et)),uploadingImages:vr,imageErrors:Ns,showFileDropdown:ut,filteredFiles:Br,selectedFileIndex:yt,onSelectFile:at,filteredCommands:Vt,selectedCommandIndex:je,onCommandSelect:Qe,onCloseCommandMenu:We,isCommandMenuOpen:le,frequentCommands:ue?[]:de,getRootProps:kr,getInputProps:ir,openImagePicker:Cs,inputHighlightRef:it,renderInputWithMentions:pt,textareaRef:Ye,input:$e,onInputChange:Es,onTextareaClick:Gr,onTextareaKeyDown:Ur,onTextareaPaste:Hr,onTextareaScrollSync:As,onTextareaInput:Ts,onInputFocusChange:Ds,isInputFocused:Ls,placeholder:E("input.placeholder",{provider:E(M==="cursor"?"messageTypes.cursor":M==="codex"?"messageTypes.codex":"messageTypes.claude")}),isTextareaExpanded:dt,sendByCtrlEnter:v,onTranscript:Kr})]}),e.jsx(fd,{}),e.jsx($s,{...Ps})]})}const jp=lt.memo(wp);class Cr extends lt.Component{constructor(r){super(r),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(r){return{hasError:!0}}componentDidCatch(r,s){this.setState({error:r,errorInfo:s})}render(){return this.state.hasError?e.jsx("div",{className:"flex flex-col items-center justify-center p-8 text-center",children:e.jsxs("div",{className:"bg-destructive/5 border border-destructive/20 rounded-xl p-6 max-w-lg",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-destructive/10 flex items-center justify-center flex-shrink-0",children:e.jsx("svg",{className:"h-4.5 w-4.5 text-destructive",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"})})}),e.jsxs("div",{className:"text-left",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Something went wrong"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"This section encountered an error"})]})]}),this.props.showDetails&&this.state.error&&e.jsxs("details",{className:"mt-3 text-left",children:[e.jsx("summary",{className:"cursor-pointer text-xs font-mono text-muted-foreground hover:text-foreground transition-colors",children:"Error Details"}),e.jsxs("pre",{className:"mt-2 text-xs bg-muted/50 text-muted-foreground p-3 rounded-lg overflow-auto max-h-40 border border-border/50",children:[this.state.error.toString(),this.state.errorInfo&&this.state.errorInfo.componentStack]})]}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx("button",{onClick:()=>{this.setState({hasError:!1,error:null,errorInfo:null}),this.props.onRetry&&this.props.onRetry()},className:"bg-primary text-primary-foreground px-4 py-2 rounded-lg text-sm font-medium hover:bg-primary/90 transition-colors focus:outline-none focus:ring-2 focus:ring-primary/50",children:"Try Again"}),e.jsx("button",{onClick:()=>window.location.reload(),className:"bg-muted text-muted-foreground px-4 py-2 rounded-lg text-sm font-medium hover:bg-muted/80 hover:text-foreground transition-colors",children:"Reload Page"})]})]})}):this.props.children}}function Np(t){const r=l.useRef(!1),s=l.useCallback(o=>{o&&(o.preventDefault(),o.stopPropagation()),t()},[t]),a=l.useCallback(o=>{r.current=!0,s(o),window.setTimeout(()=>{r.current=!1},350)},[s]);return{handleMobileMenuClick:l.useCallback(o=>{if(r.current){o.preventDefault(),o.stopPropagation();return}s(o)},[s]),handleMobileMenuTouchEnd:a}}function bi({onMenuClick:t,compact:r=!1}){const{handleMobileMenuClick:s,handleMobileMenuTouchEnd:a}=Np(t),n=r?"p-1.5 text-muted-foreground hover:text-foreground rounded-lg hover:bg-accent/60 pwa-menu-button":"p-1.5 text-muted-foreground hover:text-foreground rounded-lg hover:bg-accent/60 touch-manipulation active:scale-95 pwa-menu-button flex-shrink-0";return e.jsx("button",{onClick:s,onTouchEnd:a,className:n,"aria-label":"Open menu",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})})}const Et=({children:t,content:r,position:s="top",className:a="",delay:n=500})=>{const[o,i]=l.useState(!1),[c,d]=l.useState(null),u=()=>{const g=setTimeout(()=>{i(!0)},n);d(g)},m=()=>{c&&(clearTimeout(c),d(null)),i(!1)},h=()=>{switch(s){case"top":return"bottom-full left-1/2 transform -translate-x-1/2 mb-2";case"bottom":return"top-full left-1/2 transform -translate-x-1/2 mt-2";case"left":return"right-full top-1/2 transform -translate-y-1/2 mr-2";case"right":return"left-full top-1/2 transform -translate-y-1/2 ml-2";default:return"bottom-full left-1/2 transform -translate-x-1/2 mb-2"}},p=()=>{switch(s){case"top":return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100";case"bottom":return"bottom-full left-1/2 transform -translate-x-1/2 border-b-gray-900 dark:border-b-gray-100";case"left":return"left-full top-1/2 transform -translate-y-1/2 border-l-gray-900 dark:border-l-gray-100";case"right":return"right-full top-1/2 transform -translate-y-1/2 border-r-gray-900 dark:border-r-gray-100";default:return"top-full left-1/2 transform -translate-x-1/2 border-t-gray-900 dark:border-t-gray-100"}};return r?e.jsxs("div",{className:"relative inline-block",onMouseEnter:u,onMouseLeave:m,children:[t,o&&e.jsxs("div",{className:ke("absolute z-50 px-2 py-1 text-xs font-medium text-white bg-gray-900 dark:bg-gray-100 dark:text-gray-900 rounded shadow-lg whitespace-nowrap pointer-events-none","animate-in fade-in-0 zoom-in-95 duration-200",h(),a),children:[r,e.jsx("div",{className:ke("absolute w-0 h-0 border-4 border-transparent",p())})]})]}):t},Rn=[{id:"dashboard",labelKey:"Dashboard",icon:_i},{id:"chat",labelKey:"tabs.chat",icon:Ca},{id:"shell",labelKey:"tabs.shell",icon:bt},{id:"files",labelKey:"tabs.files",icon:mr},{id:"git",labelKey:"tabs.git",icon:br},{id:"workflows",labelKey:"Workflows",icon:tr},{id:"browser",labelKey:"Browser",icon:$r}],Cp={id:"tasks",labelKey:"tabs.tasks",icon:co};function Sp({activeTab:t,setActiveTab:r,shouldShowTasksTab:s}){const{t:a}=Be(),n=new Set(["workflows","browser"]),o=wi?Rn.filter(c=>!n.has(c.id)):Rn,i=s?[...o,Cp]:o;return e.jsx("div",{className:"inline-flex items-center bg-muted/60 rounded-lg p-[3px] gap-[2px]",children:i.map(c=>{const d=c.icon,u=c.id===t;return e.jsx(Et,{content:a(c.labelKey),position:"bottom",children:e.jsxs("button",{"data-tour":c.id,onClick:()=>r(c.id),className:`relative flex items-center gap-1.5 px-2.5 py-[5px] text-sm font-medium rounded-md transition-all duration-150 ${u?"bg-background text-foreground shadow-sm ring-1 ring-border/50":"text-muted-foreground hover:text-foreground hover:bg-muted/40"}`,children:[e.jsx(d,{className:"w-3.5 h-3.5",strokeWidth:u?2.2:1.8}),e.jsx("span",{className:"hidden lg:inline",children:a(c.labelKey)})]})},c.id)})})}function Ep(t,r,s){return t==="files"?s("mainContent.projectFiles"):t==="git"?s("tabs.git"):t==="tasks"&&r?"TaskMaster":"Project"}function Tp(t){return t.__provider==="cursor"?t.name||"Untitled Session":t.summary||"New Session"}function Ap({activeTab:t,selectedProject:r,selectedSession:s,shouldShowTasksTab:a}){const{t:n}=Be(),o=t==="chat"&&!!s,i=t==="chat"&&!s;return e.jsxs("div",{className:"min-w-0 flex items-center gap-2 flex-1 overflow-x-auto scrollbar-hide",children:[o&&e.jsx("div",{className:"w-5 h-5 flex-shrink-0 flex items-center justify-center",children:e.jsx(vt,{provider:s==null?void 0:s.__provider,className:"w-4 h-4"})}),e.jsx("div",{className:"min-w-0 flex-1",children:t==="chat"&&s?e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground whitespace-nowrap overflow-x-auto scrollbar-hide leading-tight",children:Tp(s)}),e.jsx("div",{className:"text-[11px] text-muted-foreground truncate leading-tight",children:r.displayName})]}):i?e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-base font-semibold text-foreground leading-tight",children:n("mainContent.newSession")}),e.jsx("div",{className:"text-xs text-muted-foreground truncate leading-tight",children:r.displayName})]}):e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-sm font-semibold text-foreground leading-tight",children:Ep(t,a,n)}),e.jsx("div",{className:"text-[11px] text-muted-foreground truncate leading-tight",children:r.displayName})]})})]})}function Ip({activeTab:t,setActiveTab:r,selectedProject:s,selectedSession:a,shouldShowTasksTab:n,isMobile:o,onMenuClick:i}){return e.jsx("div",{className:"bg-background border-b border-border/60 px-3 py-1.5 sm:px-4 sm:py-2 pwa-header-safe flex-shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[o&&e.jsx(bi,{onMenuClick:i}),e.jsx(Ap,{activeTab:t,selectedProject:s,selectedSession:a,shouldShowTasksTab:n})]}),e.jsx("div",{className:"flex-shrink-0 hidden sm:block",children:e.jsx(Sp,{activeTab:t,setActiveTab:r,shouldShowTasksTab:n})})]})})}function On({mode:t,isMobile:r,onMenuClick:s}){const{t:a}=Be(),n=t==="loading";return e.jsxs("div",{className:"h-full flex flex-col",children:[r&&e.jsx("div",{className:"bg-background/80 backdrop-blur-sm border-b border-border/50 p-2 sm:p-3 pwa-header-safe flex-shrink-0",children:e.jsx(bi,{onMenuClick:s,compact:!0})}),n?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx("div",{className:"w-10 h-10 mx-auto mb-4",children:e.jsx("div",{className:"w-full h-full rounded-full border-[3px] border-muted border-t-primary",style:{animation:"spin 1s linear infinite",WebkitAnimation:"spin 1s linear infinite",MozAnimation:"spin 1s linear infinite"}})}),e.jsx("h2",{className:"text-lg font-semibold text-foreground mb-1",children:a("mainContent.loading")}),e.jsx("p",{className:"text-sm",children:a("mainContent.settingUpWorkspace")})]})}):e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center max-w-md mx-auto px-6",children:[e.jsx("div",{className:"w-14 h-14 mx-auto mb-5 bg-muted/50 rounded-2xl flex items-center justify-center",children:e.jsx(mr,{className:"w-7 h-7 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2 text-foreground",children:a("mainContent.chooseProject")}),e.jsx("p",{className:"text-sm text-muted-foreground mb-5 leading-relaxed",children:a("mainContent.selectProjectDescription")}),e.jsx("div",{className:"bg-primary/5 rounded-xl p-3.5 border border-primary/10",children:e.jsxs("p",{className:"text-sm text-primary",children:[e.jsxs("strong",{children:[a("mainContent.tip"),":"]})," ",a(r?"mainContent.createProjectMobile":"mainContent.createProjectDesktop")]})})]})})]})}var Mp=function(t,r){var s={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&r.indexOf(a)<0&&(s[a]=t[a]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,a=Object.getOwnPropertySymbols(t);n<a.length;n++)r.indexOf(a[n])<0&&Object.prototype.propertyIsEnumerable.call(t,a[n])&&(s[a[n]]=t[a[n]]);return s};const ct=ho.define({combine:t=>{const r=[];for(let s of t){if(!s)continue;const{create:a,gutters:n}=s,o=Mp(s,["create","gutters"]);r.push(Object.assign(Object.assign({},o),{enabled:!0,gutters:n?n.filter(i=>Object.keys(i).length>0):void 0}))}return rl(r,{enabled:r.length>0,displayText:"characters",eventHandlers:{},showOverlay:"always",gutters:[]})}}),xt={PixelMultiplier:2,SizeRatio:4,MaxWidth:120},Dp=Wt.theme({".cm-minimap-overlay-container":{position:"absolute",top:0,height:"100%",width:"100%","&.cm-minimap-overlay-mouse-over":{opacity:0,transition:"visibility 0s linear 300ms, opacity 300ms"},"&.cm-minimap-overlay-mouse-over:hover":{opacity:1,transition:"visibility 0s linear 0ms, opacity 300ms"},"&.cm-minimap-overlay-off":{display:"none"},"& .cm-minimap-overlay":{background:"rgb(121, 121, 121)",opacity:"0.2",position:"absolute",right:0,top:0,width:"100%",transition:"top 0s ease-in 0ms","&:hover":{opacity:"0.3"}},"&.cm-minimap-overlay-active":{opacity:1,visibility:"visible",transition:"visibility 0s linear 0ms, opacity 300ms","& .cm-minimap-overlay":{opacity:"0.4"}}}}),Bt=xt.PixelMultiplier*xt.SizeRatio,Lp=Sa.fromClass(class{constructor(t){this.view=t,this._isDragging=!1,t.state.facet(ct).enabled&&this.create(t)}create(t){this.container=pr("div",{class:"cm-minimap-overlay-container"}),this.dom=pr("div",{class:"cm-minimap-overlay"}),this.container.appendChild(this.dom),this.container.addEventListener("mousedown",this.onMouseDown.bind(this)),window.addEventListener("mouseup",this.onMouseUp.bind(this)),window.addEventListener("mousemove",this.onMouseMove.bind(this));const r=t.dom.querySelector(".cm-minimap-inner");r&&r.appendChild(this.container),this.computeShowOverlay(),this.computeHeight(),this.computeTop()}remove(){this.container&&(this.container.removeEventListener("mousedown",this.onMouseDown),window.removeEventListener("mouseup",this.onMouseUp),window.removeEventListener("mousemove",this.onMouseMove),this.container.remove())}update(t){const r=t.startState.facet(ct).enabled,s=t.state.facet(ct).enabled;if(r&&!s){this.remove();return}!r&&s&&this.create(t.view),s&&(this.computeShowOverlay(),t.geometryChanged&&(this.computeHeight(),this.computeTop()))}computeHeight(){if(!this.dom)return;const t=this.view.dom.clientHeight/Bt;this.dom.style.height=t+"px"}computeTop(){if(!this._isDragging&&this.dom){const{clientHeight:t,scrollHeight:r,scrollTop:s}=this.view.scrollDOM,a=r-t,n=s/Bt,o=t/Bt,i=t-o;let c=s/a;isNaN(c)&&(c=0);const d=i*c,u=Math.min(d,n);this.dom.style.top=u+"px"}}computeShowOverlay(){if(!this.container)return;const{showOverlay:t}=this.view.state.facet(ct);t==="mouse-over"?this.container.classList.add("cm-minimap-overlay-mouse-over"):this.container.classList.remove("cm-minimap-overlay-mouse-over");const{clientHeight:r,scrollHeight:s}=this.view.scrollDOM;r===s?this.container.classList.add("cm-minimap-overlay-off"):this.container.classList.remove("cm-minimap-overlay-off")}onMouseDown(t){if(!this.container||t.button===2)return;const{clientY:r,target:s}=t;if(s===this.dom){this._dragStartY=t.clientY,this._isDragging=!0,this.container.classList.add("cm-minimap-overlay-active");return}const{clientHeight:a,scrollHeight:n,scrollTop:o}=this.view.scrollDOM,i=s.getBoundingClientRect().top,c=(r-i)*Bt,d=o/(n-a),m=(a*Bt-a)*d,h=Math.max(0,o-m);this.view.scrollDOM.scrollTop=h+c-a/2}onMouseUp(t){this._isDragging&&this.container&&(this._dragStartY=void 0,this._isDragging=!1,this.container.classList.remove("cm-minimap-overlay-active"))}onMouseMove(t){if(!this._isDragging||!this.dom)return;if(t.preventDefault(),t.stopPropagation(),!this._dragStartY){this._dragStartY=t.clientY;return}const r=t.clientY-this._dragStartY,s=r<0,a=r>0;this._dragStartY=t.clientY;const n=this.dom.getBoundingClientRect().height,o=this.dom.getBoundingClientRect().y,i=o+n,c=parseFloat(this.dom.style.top),d=this.view.scrollDOM.scrollTop,u=this.view.scrollDOM.clientHeight,m=this.view.scrollDOM.scrollHeight,h=d===0,p=Math.round(d)>=Math.round(m-u);if(h&&s||h&&t.clientY<o||p&&a||p&&t.clientY>i)return;const g=this.view.scrollDOM.scrollHeight,f=this.view.scrollDOM.clientHeight,x=(g-f)/Bt,y=f-f/Bt,N=c+r,j=N/y,v=(g-f)*j,k=N*Bt;this.view.scrollDOM.scrollTop=Math.max(v,k);const A=Math.min(Math.max(0,N),Math.min(y,x));this.dom.style.top=A+"px"}destroy(){this.remove()}},{eventHandlers:{scroll(){requestAnimationFrame(()=>this.computeTop())}}}),Pp=[Dp,Lp];class za{constructor(r){this.map=new Map,this.view=r}get(r){return this.map.get(r)}set(r,s){this.map.set(r,s)}}function Bn(t){var r;if(!t.facet(ct).enabled)return[];const s=[],a=t.doc.iterLines(),n=nl(t).iter();let o=0;for(a.next();!a.done;){const i=a.value;let c=o,d=c+i.length;for(;n.value&&n.to<c;)n.next();const{from:u,to:m}=n,h=c>=u&&c<m,p=d>u&&d<=m;if(h){let g=(r=s.pop())!==null&&r!==void 0?r:[],f=g.pop();f&&f.folded&&(f.to=m),f&&g.push(f),(!f||!f.folded)&&g.push({from:u,to:m,folded:!0}),p||g.push({from:m,to:d,folded:!1}),s.push(g)}else p?s.push([{from:c,to:u,folded:!1},{from:u,to:m,folded:!0}]):s.push([{from:c,to:d,folded:!1}]);o=d+1,a.next()}return s}const gr=tl.define({create:t=>Bn(t),update:(t,r)=>ws([r])||r.docChanged?Bn(r.state):t});function ws(t){return t.find(r=>r.effects.find(s=>s.is(sl)||s.is(al)))}class $p extends za{constructor(r){super(r),this.count=void 0}shouldUpdate(r){if(!r.state.facet(ct).enabled)return!1;if(r.docChanged)return!0;for(const s of r.transactions)for(const a of s.effects)if(a.is(il))return!0;return!!(ws(r.transactions)||this.count===void 0)}update(r){if(!this.shouldUpdate(r))return;this.map.clear();const s=r.state.field(gr);this.count=ll(r.state),cl(r.state,(a,n,o)=>{const i=this.findLine(n,s),c=this.findLine(o,s);let d=a.severity;for(let u=i;u<=c;u++){const m=this.get(u);m&&(d=[d,m].sort(this.sort.bind(this)).slice(0,1)[0]),this.set(u,d)}})}drawLine(r,s){const{context:a,lineHeight:n,offsetX:o,offsetY:i}=r,c=this.get(s);c&&(a.globalAlpha=.65,a.beginPath(),a.rect(o,i,a.canvas.width-o,n),a.fillStyle=this.color(c),a.fill())}findLine(r,s){return s.findIndex(n=>{const o=n.slice(0,1)[0],i=n.slice(-1)[0];return!o||!i?!1:o.from<=r&&r<=i.to})+1}color(r){return r==="error"?"#d11":r==="warning"?"orange":"#999"}sort(r,s){return this.score(s)-this.score(r)}score(r){switch(r){case"error":return 3;case"warning":return 2;default:return 1}}}function _p(t){return new $p(t)}class Fp extends za{constructor(r){super(r),this.getDrawInfo(),this._themeClasses=r.dom.classList.value}shouldUpdate(r){return r.state.facet(ct).enabled?!!(r.docChanged||r.selectionSet||this._themeClasses!==this.view.dom.classList.value||ws(r.transactions)):!1}update(r){if(!this.shouldUpdate(r))return;this.map.clear(),this._themeClasses!==this.view.dom.classList.value&&(this._drawInfo=void 0,this._themeClasses=this.view.dom.classList.value);const{ranges:s}=r.state.selection;let a=0;for(const[n,o]of r.state.field(gr).entries()){const i=[];let c=0;for(const u of o){do{if(a>=s.length||u.to<s[a].from)continue;if(s[a].from===s[a].to){a++;continue}const m=s[a],h={from:c+Math.max(u.from,m.from)-u.from,to:c+Math.min(u.to,m.to)-u.from,extends:m.to>u.to},p=i.slice(-1)[0];if(p&&p.to===h.from){let{to:g}=h;u.folded&&h.extends?g=h.from+1:u.folded&&!h.extends&&(g=p.to),i[i.length-1]=Object.assign(Object.assign({},p),{to:g,extends:h.extends})}else u.folded||i.push(h);if(h.extends)break;a++}while(a<s.length&&u.to>=s[a].from);c+=u.folded?1:u.to-u.from}if(i.length===0)continue;const d=n+1;this.map.set(d,i)}}drawLine(r,s){let{context:a,lineHeight:n,charWidth:o,offsetX:i,offsetY:c}=r;const d=this.get(s);if(d)for(const u of d){const m=i+u.from*o,h=(u.to-u.from)*o,p=a.canvas.width-m;u.extends&&(a.globalAlpha=.65,a.beginPath(),a.rect(m,c,p,n),a.fillStyle=this.getDrawInfo().backgroundColor,a.fill()),a.globalAlpha=1,a.beginPath(),a.rect(m,c,h,n),a.fillStyle=this.getDrawInfo().backgroundColor,a.fill()}}getDrawInfo(){if(this._drawInfo)return this._drawInfo;const r=document.createElement("span");r.setAttribute("class","cm-selectionBackground"),this.view.dom.appendChild(r);const a={backgroundColor:window.getComputedStyle(r).backgroundColor};return this._drawInfo=a,this.view.dom.removeChild(r),a}}function zp(t){return new Fp(t)}class Rp extends za{constructor(r){super(r),this._fontInfoMap=new Map,this._themeClasses=new Set(r.dom.classList.values()),r.state.facet(ct).enabled&&this.updateImpl(r.state)}shouldUpdate(r){return!!(r.docChanged||r.state.facet(ct)!==r.startState.facet(ct)||this.themeChanged()||ws(r.transactions))}update(r){this.shouldUpdate(r)&&(this._highlightingCallbackId&&(typeof window.requestIdleCallback<"u"?cancelIdleCallback(this._highlightingCallbackId):clearTimeout(this._highlightingCallbackId)),this.updateImpl(r.state,r.changes))}updateImpl(r,s){var a;this.map.clear(),this._displayText=r.facet(ct).displayText,this.themeChanged()&&this._fontInfoMap.clear();let n;if(this._previousTree&&s){const h=Ha.addTree(this._previousTree),p=[];s.iterChangedRanges((g,f,x,y)=>p.push({fromA:g,toA:f,fromB:x,toB:y})),n=Ha.applyChanges(h,p)}const o=r.doc.toString(),i=(a=r.facet(ol))===null||a===void 0?void 0:a.parser,c=i?i.parse(o,n):void 0;this._previousTree=c;const d={style:h=>dl(r,h)};let u=[];if(c){const h=r.doc.lineAt(this.view.viewport.from).number,p=r.doc.lineAt(this.view.viewport.to).number,g=p-h,f=h/(r.doc.lines-g),{SizeRatio:x,PixelMultiplier:y}=xt,N=g*x*y,j=f*N,v=Math.max(1,Math.floor(h-j)),k=Math.min(p+Math.floor(N-j),r.doc.lines);Ga(c,d,(A,P,S)=>{u.push({from:A,to:P,tags:S})},r.doc.line(v).from,r.doc.line(k).to)}this.updateMapImpl(r,u),u=[];const m=()=>{c&&(Ga(c,d,(h,p,g)=>{u.push({from:h,to:p,tags:g})}),this.updateMapImpl(r,u),this._highlightingCallbackId=void 0)};this._highlightingCallbackId=typeof window.requestIdleCallback<"u"?requestIdleCallback(m):setTimeout(m)}updateMapImpl(r,s){this.map.clear();const a=r.doc.toString(),n=s.values();let o=n.next();for(const[i,c]of r.field(gr).entries()){const d=[];for(const m of c){if(m.from===m.to)continue;if(m.folded){d.push({text:"…",tags:""});continue}let h=m.from;for(;!o.done&&o.value.from<m.to;){const{from:p,to:g,tags:f}=o.value;if(g<h){o=n.next();continue}p>h&&d.push({text:a.slice(h,p),tags:""});const x=Math.max(p,m.from),y=Math.min(g,m.to);if(d.push({text:a.slice(x,y),tags:f}),h=y,g>y)break;o=n.next()}h!==m.to&&d.push({text:a.slice(h,m.to),tags:""})}const u=i+1;this.map.set(u,d)}}measure(r){const{color:s,font:a,lineHeight:n}=this.getFontInfo("");return r.textBaseline="ideographic",r.fillStyle=s,r.font=a,{charWidth:r.measureText("_").width,lineHeight:n}}beforeDraw(){this._fontInfoMap.clear()}drawLine(r,s){const a=this.get(s);if(!a)return;let{context:n,charWidth:o,lineHeight:i,offsetX:c,offsetY:d}=r,u;n.textBaseline="ideographic";for(const m of a){const h=this.getFontInfo(m.tags);switch((!u||u.color!==h.color)&&(n.fillStyle=h.color),(!u||u.font!==h.font)&&(n.font=h.font),u=h,i=Math.max(i,h.lineHeight),this._displayText){case"characters":{n.fillText(m.text,c,d+i),c+=m.text.length*o;break}case"blocks":{const p=/\S+/g;let g;for(;(g=p.exec(m.text))!==null;){const f=c+g.index*o;let x=(p.lastIndex-g.index)*o;if(f>n.canvas.width)break;f+x>n.canvas.width&&(x=n.canvas.width-f);const y=2/xt.SizeRatio,N=i-y;n.fillStyle=h.color,n.globalAlpha=.65,n.beginPath(),n.rect(f,d,x,N),n.fill()}c+=m.text.length*o;break}}}}getFontInfo(r){const s=this._fontInfoMap.get(r);if(s)return s;const a=pr("span",{class:r}),n=pr("div",{class:"cm-line",style:"display: none"},a);this.view.contentDOM.appendChild(n);const o=window.getComputedStyle(a),i=parseFloat(o.lineHeight)/xt.SizeRatio,c={color:o.color,font:`${o.fontStyle} ${o.fontWeight} ${i}px ${o.fontFamily}`,lineHeight:i};return this._fontInfoMap.set(r,c),this.view.contentDOM.removeChild(n),c}themeChanged(){const r=this._themeClasses,s=new Set(this.view.dom.classList.values());if(this._themeClasses=s,!r||(r.delete("cm-focused"),s.delete("cm-focused"),r.size!==s.size))return!0;let a=!0;return r.forEach(n=>{s.has(n)||(a=!1)}),!a}}function Op(t){return new Rp(t)}const yi=4;function Bp(t,r,s){const a=t[s];a&&(r.context.fillStyle=a,r.context.globalAlpha=1,r.context.beginPath(),r.context.rect(r.offsetX,r.offsetY,yi,r.lineHeight),r.context.fill())}const Wp=Wt.theme({"&":{height:"100%",overflowY:"auto"},"& .cm-minimap-gutter":{borderRight:0,flexShrink:0,left:"unset",position:"sticky",right:0,top:0},"& .cm-minimap-inner":{height:"100%",position:"absolute",right:0,top:0,overflowY:"hidden","& canvas":{display:"block"}},"& .cm-minimap-box-shadow":{boxShadow:"12px 0px 20px 5px #6c6c6c"}}),Wn=6,Up=Sa.fromClass(class{constructor(t){this.view=t,this.text=Op(t),this.selection=zp(t),this.diagnostic=_p(t),t.state.facet(Ar)&&this.create(t)}create(t){const r=t.state.facet(Ar);if(!r)throw Error("Expected nonnull");this.inner=pr("div",{class:"cm-minimap-inner"}),this.canvas=pr("canvas"),this.dom=r.create(t).dom,this.dom.classList.add("cm-gutters"),this.dom.classList.add("cm-minimap-gutter"),this.inner.appendChild(this.canvas),this.dom.appendChild(this.inner),this.view.scrollDOM.insertBefore(this.dom,this.view.contentDOM.nextSibling);for(const s in this.view.state.facet(ct).eventHandlers){const a=this.view.state.facet(ct).eventHandlers[s];a&&this.dom.addEventListener(s,n=>a(n,this.view))}}remove(){this.dom&&this.dom.remove()}update(t){const r=t.startState.facet(Ar),s=t.state.facet(Ar);if(r&&!s){this.remove();return}!r&&s&&this.create(t.view),s&&(this.text.update(t),this.selection.update(t),this.diagnostic.update(t),this.render())}getWidth(){const t=this.view.dom.clientWidth;if(t<=xt.MaxWidth*Wn){const r=t/(xt.MaxWidth*Wn);return xt.MaxWidth*r}return xt.MaxWidth}render(){if(!this.dom||!this.canvas||!this.inner)return;this.text.beforeDraw(),this.updateBoxShadow(),this.dom.style.width=this.getWidth()+"px",this.canvas.style.maxWidth=this.getWidth()+"px",this.canvas.width=this.getWidth()*xt.PixelMultiplier;const t=this.view.dom.getBoundingClientRect().height;this.inner.style.minHeight=t+"px",this.canvas.height=t*xt.PixelMultiplier,this.canvas.style.height=t+"px";const r=this.canvas.getContext("2d");if(!r)return;r.clearRect(0,0,this.canvas.width,this.canvas.height);const{charWidth:s,lineHeight:a}=this.text.measure(r);let{startIndex:n,endIndex:o,offsetY:i}=this.canvasStartAndEndIndex(r,a);const c=this.view.state.facet(ct).gutters;for(let d=n;d<o;d++){const u=this.view.state.field(gr);if(d>=u.length)break;const m={offsetX:0,offsetY:i,context:r,lineHeight:a,charWidth:s};if(c.length){m.offsetX+=2;for(let h of c)Bp(h,m,d+1),m.offsetX+=yi;m.offsetX+=2}this.text.drawLine(m,d+1),this.selection.drawLine(m,d+1),this.diagnostic.drawLine(m,d+1),i+=a}r.restore()}canvasStartAndEndIndex(t,r){let{top:s,bottom:a}=this.view.documentPadding;s/=xt.SizeRatio,a/=xt.SizeRatio;const n=t.canvas.height,{clientHeight:o,scrollHeight:i,scrollTop:c}=this.view.scrollDOM;let d=c/(i-o);isNaN(d)&&(d=0);const u=this.view.state.field(gr).length,m=s+a+u*r,h=Math.max(0,d*(m-n)),p=Math.max(0,s-h),g=Math.round(Math.max(0,h-s)/r),f=Math.round((n-p)/r);return{startIndex:g,endIndex:g+f,offsetY:p}}updateBoxShadow(){if(!this.canvas)return;const{clientWidth:t,scrollWidth:r,scrollLeft:s}=this.view.scrollDOM;t+s<r?this.canvas.classList.add("cm-minimap-box-shadow"):this.canvas.classList.remove("cm-minimap-box-shadow")}destroy(){this.remove()}},{eventHandlers:{scroll(){requestAnimationFrame(()=>this.render())}},provide:t=>Wt.scrollMargins.of(r=>{var s;const a=(s=r.plugin(t))===null||s===void 0?void 0:s.getWidth();return a?{right:a}:null})}),Ar=ho.define({combine:t=>{var r;return(r=t.find(s=>s!==null))!==null&&r!==void 0?r:null},enables:t=>[[ct.compute([t],r=>r.facet(t)),Wp,gr,Up,Pp]]}),Hp=l.lazy(()=>Nt(()=>import("./MarkdownPreview-CuIix2u9.js"),__vite__mapDeps([5,2,3,1]))),Un=bl.define({token(t){return t.match(/^#.*/)?"comment":t.sol()&&t.match(/^[A-Za-z_][A-Za-z0-9_.]*(?==)/)?"variableName.definition":t.match(/^=/)?"operator":t.match(/^"(?:[^"\\]|\\.)*"?/)||t.match(/^'(?:[^'\\]|\\.)*'?/)?"string":t.match(/^\$\{[^}]*\}?/)||t.match(/^\$[A-Za-z_][A-Za-z0-9_]*/)?"variableName.special":t.match(/^\d+/)?"number":(t.next(),null)}});function Gp({file:t,onClose:r,projectPath:s,isSidebar:a=!1,isExpanded:n=!1,onToggleExpand:o=null,onPopOut:i=null}){const{t:c}=Be("codeEditor"),{addToast:d}=hr(),[u,m]=l.useState(""),[h,p]=l.useState(!0),[g,f]=l.useState(!1),[x,y]=l.useState(!1),[N,j]=l.useState(()=>{const O=localStorage.getItem("codeEditorTheme");return O?O==="dark":!0}),[v,k]=l.useState(!1),[A,P]=l.useState(!!t.diffInfo),[S,b]=l.useState(()=>localStorage.getItem("codeEditorWordWrap")==="true"),[C,E]=l.useState(()=>localStorage.getItem("codeEditorShowMinimap")!=="false"),[B,T]=l.useState(()=>localStorage.getItem("codeEditorLineNumbers")!=="false"),[W,H]=l.useState(()=>localStorage.getItem("codeEditorFontSize")||"12"),[_,M]=l.useState(!1),z=l.useRef(null),K=l.useMemo(()=>{var F;const O=(F=t.name.split(".").pop())==null?void 0:F.toLowerCase();return O==="md"||O==="markdown"},[t.name]),te=l.useMemo(()=>{if(!t.diffInfo||!A||!C)return[];const O={};return[Ar.compute(["doc"],F=>{const V=_s(F),R=(V==null?void 0:V.chunks)||[];return Object.keys(O).forEach(Z=>delete O[Z]),R.forEach(Z=>{const G=F.doc.lineAt(Z.fromB).number,w=F.doc.lineAt(Math.min(Z.toB,F.doc.length)).number;for(let I=G;I<=w;I++)O[I]=N?"rgba(34, 197, 94, 0.8)":"rgba(34, 197, 94, 1)"}),{create:()=>({dom:document.createElement("div")}),displayText:"blocks",showOverlay:"always",gutters:[O]}})]},[t.diffInfo,A,C,N]),q=l.useMemo(()=>!t.diffInfo||!A?[]:[Sa.fromClass(class{constructor(O){setTimeout(()=>{const F=_s(O.state),V=(F==null?void 0:F.chunks)||[];if(V.length>0){const R=V[0];O.dispatch({effects:Wt.scrollIntoView(R.fromB,{y:"center"})})}},100)}update(){}destroy(){}})],[t.diffInfo,A]),ie=!!(t.diffInfo||a&&i||a&&o),$=l.useMemo(()=>{if(!ie)return[];const O=F=>{const V=document.createElement("div");V.className="cm-editor-toolbar-panel";let R=0;const Z=()=>{const G=t.diffInfo&&A,w=G?_s(F.state):null,I=(w==null?void 0:w.chunks)||[],J=I.length;let se='<div style="display: flex; align-items: center; justify-content: space-between; width: 100%;">';if(se+='<div style="display: flex; align-items: center; gap: 8px;">',G&&(se+=`
171
+ <span style="font-weight: 500;">${J>0?`${R+1}/${J}`:"0"} ${c("toolbar.changes")}</span>
172
+ <button class="cm-diff-nav-btn cm-diff-nav-prev" title="${c("toolbar.previousChange")}" ${J===0?"disabled":""}>
173
+ <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
174
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 15l7-7 7 7" />
175
+ </svg>
176
+ </button>
177
+ <button class="cm-diff-nav-btn cm-diff-nav-next" title="${c("toolbar.nextChange")}" ${J===0?"disabled":""}>
178
+ <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
179
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
180
+ </svg>
181
+ </button>
182
+ `),se+="</div>",se+='<div style="display: flex; align-items: center; gap: 4px;">',t.diffInfo&&(se+=`
183
+ <button class="cm-toolbar-btn cm-toggle-diff-btn" title="${c(A?"toolbar.hideDiff":"toolbar.showDiff")}">
184
+ <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
185
+ ${A?'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21" />':'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" /><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />'}
186
+ </svg>
187
+ </button>
188
+ `),a&&i&&(se+=`
189
+ <button class="cm-toolbar-btn cm-popout-btn" title="Open in modal">
190
+ <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
191
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6M15 3h6v6M10 14L21 3" />
192
+ </svg>
193
+ </button>
194
+ `),a&&o&&(se+=`
195
+ <button class="cm-toolbar-btn cm-expand-btn" title="${c(n?"toolbar.collapse":"toolbar.expand")}">
196
+ <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
197
+ ${n?'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25" />':'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4" />'}
198
+ </svg>
199
+ </button>
200
+ `),se+="</div>",se+="</div>",V.innerHTML=se,G){const ce=V.querySelector(".cm-diff-nav-prev"),Ce=V.querySelector(".cm-diff-nav-next");ce==null||ce.addEventListener("click",()=>{if(I.length===0)return;R=R>0?R-1:I.length-1;const fe=I[R];fe&&F.dispatch({effects:Wt.scrollIntoView(fe.fromB,{y:"center"})}),Z()}),Ce==null||Ce.addEventListener("click",()=>{if(I.length===0)return;R=R<I.length-1?R+1:0;const fe=I[R];fe&&F.dispatch({effects:Wt.scrollIntoView(fe.fromB,{y:"center"})}),Z()})}if(t.diffInfo){const ce=V.querySelector(".cm-toggle-diff-btn");ce==null||ce.addEventListener("click",()=>{P(!A)})}if(a&&i){const ce=V.querySelector(".cm-popout-btn");ce==null||ce.addEventListener("click",()=>{i()})}if(a&&o){const ce=V.querySelector(".cm-expand-btn");ce==null||ce.addEventListener("click",()=>{o()})}};return Z(),{top:!0,dom:V,update:Z}};return[ul.of(O)]},[t.diffInfo,A,a,n,o,i]),X=O=>{var R;const F=O.toLowerCase();if(F===".env"||F.startsWith(".env."))return[Un];const V=(R=O.split(".").pop())==null?void 0:R.toLowerCase();switch(V){case"js":case"jsx":case"ts":case"tsx":return[fl({jsx:!0,typescript:V.includes("ts")})];case"py":return[hl()];case"html":case"htm":return[gl()];case"css":case"scss":case"less":return[xl()];case"json":return[pl()];case"md":case"markdown":return[yo()];case"env":return[Un];default:return[]}};l.useEffect(()=>{(async()=>{try{if(p(!0),t.diffInfo&&t.diffInfo.new_string!==void 0&&t.diffInfo.old_string!==void 0){m(t.diffInfo.new_string),p(!1);return}const F=await Ue.readFile(t.projectName,t.path);if(!F.ok)throw new Error(`Failed to load file: ${F.status} ${F.statusText}`);const V=await F.json();m(V.content)}catch(F){console.error("Error loading file:",F),m(`// Error loading file: ${F.message}
201
+ // File: ${t.name}
202
+ // Path: ${t.path}`)}finally{p(!1)}})()},[t,s]);const re=async()=>{f(!0);try{console.log("Saving file:",{projectName:t.projectName,path:t.path,contentLength:u==null?void 0:u.length});const O=await Ue.saveFile(t.projectName,t.path,u);if(console.log("Save response:",{status:O.status,ok:O.ok,contentType:O.headers.get("content-type")}),!O.ok){const V=O.headers.get("content-type");if(V&&V.includes("application/json")){const R=await O.json();throw new Error(R.error||`Save failed: ${O.status}`)}else{const R=await O.text();throw console.error("Non-JSON error response:",R),new Error(`Save failed: ${O.status} ${O.statusText}`)}}const F=await O.json();console.log("Save successful:",F),k(!0),setTimeout(()=>k(!1),2e3)}catch(O){console.error("Error saving file:",O),d(`Error saving file: ${O.message}`,"error")}finally{f(!1)}},Y=()=>{const O=new Blob([u],{type:"text/plain"}),F=URL.createObjectURL(O),V=document.createElement("a");V.href=F,V.download=t.name,document.body.appendChild(V),V.click(),document.body.removeChild(V),URL.revokeObjectURL(F)},U=()=>{y(!x)};return l.useEffect(()=>{localStorage.setItem("codeEditorTheme",N?"dark":"light")},[N]),l.useEffect(()=>{localStorage.setItem("codeEditorWordWrap",S.toString())},[S]),l.useEffect(()=>{const O=()=>{const F=localStorage.getItem("codeEditorTheme");F&&j(F==="dark");const V=localStorage.getItem("codeEditorWordWrap");V!==null&&b(V==="true");const R=localStorage.getItem("codeEditorShowMinimap");R!==null&&E(R!=="false");const Z=localStorage.getItem("codeEditorLineNumbers");Z!==null&&T(Z!=="false");const G=localStorage.getItem("codeEditorFontSize");G&&H(G)};return window.addEventListener("storage",O),window.addEventListener("codeEditorSettingsChanged",O),()=>{window.removeEventListener("storage",O),window.removeEventListener("codeEditorSettingsChanged",O)}},[]),l.useEffect(()=>{const O=F=>{(F.ctrlKey||F.metaKey)&&(F.key==="s"?(F.preventDefault(),re()):F.key==="Escape"&&(F.preventDefault(),r()))};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[u]),h?e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
203
+ .code-editor-loading {
204
+ background-color: ${N?"#111827":"#ffffff"} !important;
205
+ }
206
+ .code-editor-loading:hover {
207
+ background-color: ${N?"#111827":"#ffffff"} !important;
208
+ }
209
+ `}),a?e.jsx("div",{className:"w-full h-full flex items-center justify-center bg-background",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"}),e.jsx("span",{className:"text-gray-900 dark:text-white",children:c("loading",{fileName:t.name})})]})}):e.jsx("div",{className:"fixed inset-0 z-[9999] md:bg-black/50 md:flex md:items-center md:justify-center",children:e.jsx("div",{className:"code-editor-loading w-full h-full md:rounded-lg md:w-auto md:h-auto p-8 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"}),e.jsx("span",{className:"text-gray-900 dark:text-white",children:c("loading",{fileName:t.name})})]})})})]}):e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
210
+ /* Light background for full line changes */
211
+ .cm-deletedChunk {
212
+ background-color: ${N?"rgba(239, 68, 68, 0.15)":"rgba(255, 235, 235, 1)"} !important;
213
+ border-left: 3px solid ${N?"rgba(239, 68, 68, 0.6)":"rgb(239, 68, 68)"} !important;
214
+ padding-left: 4px !important;
215
+ }
216
+
217
+ .cm-insertedChunk {
218
+ background-color: ${N?"rgba(34, 197, 94, 0.15)":"rgba(230, 255, 237, 1)"} !important;
219
+ border-left: 3px solid ${N?"rgba(34, 197, 94, 0.6)":"rgb(34, 197, 94)"} !important;
220
+ padding-left: 4px !important;
221
+ }
222
+
223
+ /* Override linear-gradient underline and use solid darker background for partial changes */
224
+ .cm-editor.cm-merge-b .cm-changedText {
225
+ background: ${N?"rgba(34, 197, 94, 0.4)":"rgba(34, 197, 94, 0.3)"} !important;
226
+ padding-top: 2px !important;
227
+ padding-bottom: 2px !important;
228
+ margin-top: -2px !important;
229
+ margin-bottom: -2px !important;
230
+ }
231
+
232
+ .cm-editor .cm-deletedChunk .cm-changedText {
233
+ background: ${N?"rgba(239, 68, 68, 0.4)":"rgba(239, 68, 68, 0.3)"} !important;
234
+ padding-top: 2px !important;
235
+ padding-bottom: 2px !important;
236
+ margin-top: -2px !important;
237
+ margin-bottom: -2px !important;
238
+ }
239
+
240
+ /* Minimap gutter styling */
241
+ .cm-gutter.cm-gutter-minimap {
242
+ background-color: ${N?"#1e1e1e":"#f5f5f5"};
243
+ }
244
+
245
+ /* Editor toolbar panel styling */
246
+ .cm-editor-toolbar-panel {
247
+ padding: 4px 10px;
248
+ background-color: ${N?"#1f2937":"#ffffff"};
249
+ border-bottom: 1px solid ${N?"#374151":"#e5e7eb"};
250
+ color: ${N?"#d1d5db":"#374151"};
251
+ font-size: 12px;
252
+ }
253
+
254
+ .cm-diff-nav-btn,
255
+ .cm-toolbar-btn {
256
+ padding: 3px;
257
+ background: transparent;
258
+ border: none;
259
+ cursor: pointer;
260
+ border-radius: 4px;
261
+ display: inline-flex;
262
+ align-items: center;
263
+ justify-content: center;
264
+ color: inherit;
265
+ transition: background-color 0.2s;
266
+ }
267
+
268
+ .cm-diff-nav-btn:hover,
269
+ .cm-toolbar-btn:hover {
270
+ background-color: ${N?"#374151":"#f3f4f6"};
271
+ }
272
+
273
+ .cm-diff-nav-btn:disabled {
274
+ opacity: 0.5;
275
+ cursor: not-allowed;
276
+ }
277
+ `}),e.jsx("div",{className:a?"w-full h-full flex flex-col":`fixed inset-0 z-[9999] md:bg-black/50 md:flex md:items-center md:justify-center md:p-4 ${x?"md:p-0":""}`,children:e.jsxs("div",{className:a?"bg-background flex flex-col w-full h-full":`bg-background shadow-2xl flex flex-col ${"w-full h-full md:rounded-lg md:shadow-2xl"+(x?" md:w-full md:h-full md:rounded-none":" md:w-full md:max-w-6xl md:h-[80vh] md:max-h-[80vh]")}`,children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border flex-shrink-0 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:t.name}),t.diffInfo&&e.jsx("span",{className:"text-[10px] bg-blue-100 dark:bg-blue-900 text-blue-600 dark:text-blue-300 px-1.5 py-0.5 rounded whitespace-nowrap",children:c("header.showingChanges")})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:t.path})]})}),e.jsxs("div",{className:"flex items-center gap-0.5 md:gap-1 flex-shrink-0",children:[K&&e.jsx("button",{onClick:()=>M(!_),className:`p-1.5 rounded-md min-w-[36px] min-h-[36px] md:min-w-0 md:min-h-0 flex items-center justify-center transition-colors ${_?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900/30":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-800"}`,title:c(_?"actions.editMarkdown":"actions.previewMarkdown"),children:_?e.jsx(Fi,{className:"w-4 h-4"}):e.jsx(ar,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>{var O;return(O=window.openSettings)==null?void 0:O.call(window,"appearance")},className:"p-1.5 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[36px] min-h-[36px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:c("toolbar.settings"),children:e.jsx(Lt,{className:"w-4 h-4"})}),e.jsx("button",{onClick:Y,className:"p-1.5 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[36px] min-h-[36px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:c("actions.download"),children:e.jsx(uo,{className:"w-4 h-4"})}),e.jsx("button",{onClick:re,disabled:g,className:`p-1.5 rounded-md disabled:opacity-50 flex items-center justify-center transition-colors min-w-[36px] min-h-[36px] md:min-w-0 md:min-h-0 ${v?"text-green-600 dark:text-green-400 bg-green-50 dark:bg-green-900/30":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-800"}`,title:c(v?"actions.saved":g?"actions.saving":"actions.save"),children:v?e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):e.jsx(ls,{className:"w-4 h-4"})}),!a&&e.jsx("button",{onClick:U,className:"hidden md:flex p-1.5 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 items-center justify-center",title:c(x?"actions.exitFullscreen":"actions.fullscreen"),children:x?e.jsx(mo,{className:"w-4 h-4"}):e.jsx(ja,{className:"w-4 h-4"})}),e.jsx("button",{onClick:r,className:"p-1.5 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[36px] min-h-[36px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:c("actions.close"),children:e.jsx(He,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:_&&K?e.jsx("div",{className:"h-full overflow-y-auto bg-white dark:bg-gray-900",children:e.jsx("div",{className:"max-w-4xl mx-auto px-8 py-6 prose prose-sm dark:prose-invert prose-headings:font-semibold prose-a:text-blue-600 dark:prose-a:text-blue-400 prose-code:text-sm prose-pre:bg-gray-900 prose-img:rounded-lg max-w-none",children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"text-muted-foreground text-sm p-4",children:"Loading preview..."}),children:e.jsx(Hp,{content:u})})})}):e.jsx(fo,{ref:z,value:u,onChange:m,extensions:[...X(t.name),...$,...t.diffInfo&&A&&t.diffInfo.old_string!==void 0?[ml({original:t.diffInfo.old_string,mergeControls:!1,highlightChanges:!0,syntaxHighlightDeletions:!1,gutter:!0}),...te,...q]:[],...S?[Wt.lineWrapping]:[]],theme:N?bo:void 0,height:"100%",style:{fontSize:`${W}px`,height:"100%"},basicSetup:{lineNumbers:B,foldGutter:!0,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!0,highlightSelectionMatches:!0,searchKeymap:!0}})}),e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-t border-border bg-muted flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-600 dark:text-gray-400",children:[e.jsxs("span",{children:[c("footer.lines")," ",u.split(`
278
+ `).length]}),e.jsxs("span",{children:[c("footer.characters")," ",u.length]})]}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:c("footer.shortcuts")})]})]})})]})}const Hn=Gp;function Vp({editingFile:t,isMobile:r,editorExpanded:s,editorWidth:a,resizeHandleRef:n,onResizeStart:o,onCloseEditor:i,onToggleEditorExpand:c,projectPath:d,fillSpace:u}){const[m,h]=l.useState(!1);if(!t)return null;if(r||m)return e.jsx(Hn,{file:t,onClose:()=>{h(!1),i()},projectPath:d,isSidebar:!1});const p=s||u;return e.jsxs(e.Fragment,{children:[!s&&e.jsx("div",{ref:n,onMouseDown:o,className:"flex-shrink-0 w-1 bg-gray-200 dark:bg-gray-700 hover:bg-blue-500 dark:hover:bg-blue-600 cursor-col-resize transition-colors relative group",title:"Drag to resize",children:e.jsx("div",{className:"absolute inset-y-0 left-1/2 -translate-x-1/2 w-1 bg-blue-500 dark:bg-blue-600 opacity-0 group-hover:opacity-100 transition-opacity"})}),e.jsx("div",{className:`flex-shrink-0 border-l border-gray-200 dark:border-gray-700 h-full overflow-hidden ${p?"flex-1":""}`,style:p?void 0:{width:`${a}px`},children:e.jsx(Hn,{file:t,onClose:i,projectPath:d,isSidebar:!0,isExpanded:s,onToggleExpand:c,onPopOut:()=>h(!0)})})]})}const qp=l.lazy(()=>Nt(()=>import("./vendor-diff-THJmAcEI.js"),__vite__mapDeps([4,2]))),Kp={variables:{dark:{diffViewerBackground:"#0f172a",diffViewerColor:"#e2e8f0",addedBackground:"#064e3b20",addedColor:"#6ee7b7",removedBackground:"#7f1d1d20",removedColor:"#fca5a5",wordAddedBackground:"#065f4630",wordRemovedBackground:"#991b1b30",addedGutterBackground:"#064e3b30",removedGutterBackground:"#7f1d1d30",gutterBackground:"#0f172a",gutterBackgroundDark:"#0f172a",highlightBackground:"#1e293b",highlightGutterBackground:"#1e293b",codeFoldGutterBackground:"#1e293b",codeFoldBackground:"#1e293b",emptyLineBackground:"#0f172a",gutterColor:"#475569",addedGutterColor:"#6ee7b7",removedGutterColor:"#fca5a5",codeFoldContentColor:"#94a3b8",diffViewerTitleBackground:"#1e293b",diffViewerTitleColor:"#e2e8f0",diffViewerTitleBorderColor:"#334155"}},line:{padding:"2px 8px",fontSize:"12px",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace"},gutter:{padding:"2px 8px",fontSize:"11px",minWidth:"36px"},contentText:{fontSize:"12px",lineHeight:"20px"}};function Jp(t){var a;const r=((a=t.split(".").pop())==null?void 0:a.toLowerCase())||"";return{ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",kt:"kotlin",swift:"swift",c:"c",cpp:"cpp",h:"c",hpp:"cpp",cs:"csharp",php:"php",html:"html",css:"css",scss:"scss",less:"less",json:"json",yaml:"yaml",yml:"yaml",toml:"toml",xml:"xml",sql:"sql",sh:"bash",bash:"bash",zsh:"bash",md:"markdown",mdx:"markdown",graphql:"graphql",dockerfile:"docker",tf:"hcl",lua:"lua",r:"r",vue:"html",svelte:"html"}[r]||"text"}function Yp({data:t}){const[r,s]=lt.useState(!1),a=t.language||Jp(t.filePath||""),n=t.content||"",o=()=>{navigator.clipboard.writeText(n).then(()=>{s(!0),setTimeout(()=>s(!1),1500)}).catch(()=>{})};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800/60 border-b border-gray-700/50",children:[e.jsx("span",{className:"text-xs text-gray-400 font-mono truncate",children:t.filePath||"code"}),e.jsx("button",{onClick:o,className:"text-[10px] px-2 py-0.5 rounded border border-gray-600 text-gray-400 hover:text-gray-200 hover:bg-gray-700 transition-colors",children:r?"Copied":"Copy"})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsx(xo,{language:a,style:go,customStyle:{margin:0,borderRadius:0,fontSize:"0.8125rem",padding:"1rem",minHeight:"100%"},showLineNumbers:!0,lineNumberStyle:{minWidth:"2.5em",paddingRight:"1em",color:"#475569"},children:n})})]})}function Qp({data:t}){const[r,s]=lt.useState(!1);return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800/60 border-b border-gray-700/50",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-xs text-gray-400 font-mono truncate",children:t.filePath||"diff"}),e.jsx("span",{className:`text-[10px] font-medium px-1.5 py-px rounded flex-shrink-0 ${t.badge==="New"?"bg-green-900/30 text-green-400":"bg-gray-800 text-gray-400"}`,children:t.badge||"Diff"})]}),e.jsx("button",{onClick:()=>s(!r),className:"text-[10px] px-2 py-0.5 rounded border border-gray-600 text-gray-400 hover:text-gray-200 hover:bg-gray-700 transition-colors",children:r?"Unified":"Split"})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"p-4 text-xs text-gray-500",children:"Loading diff viewer..."}),children:e.jsx(qp,{oldValue:t.oldContent||"",newValue:t.newContent||"",splitView:r,useDarkTheme:!0,styles:Kp,hideLineNumbers:!1,showDiffOnly:!0,extraLinesSurroundingDiff:3})})})]})}function Xp({data:t}){const[r,s]=lt.useState(!1),a=t.output||"",n=()=>{navigator.clipboard.writeText(a).then(()=>{s(!0),setTimeout(()=>s(!1),1500)}).catch(()=>{})};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800/60 border-b border-gray-700/50",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-xs text-green-400 font-mono",children:"$"}),e.jsx("span",{className:"text-xs text-gray-300 font-mono truncate",children:t.command||"terminal"})]}),e.jsx("button",{onClick:n,className:"text-[10px] px-2 py-0.5 rounded border border-gray-600 text-gray-400 hover:text-gray-200 hover:bg-gray-700 transition-colors",children:r?"Copied":"Copy"})]}),e.jsx("div",{className:"flex-1 overflow-auto bg-gray-950 p-3",children:e.jsx("pre",{className:"text-xs text-gray-300 font-mono whitespace-pre-wrap break-words",children:a})})]})}function Zp({data:t,onFileOpen:r}){const s=t.files||[],a=t.pattern||"";return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800/60 border-b border-gray-700/50",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-xs text-gray-400",children:"Search:"}),e.jsx("span",{className:"text-xs text-gray-300 font-mono truncate",children:a})]}),e.jsxs("span",{className:"text-[10px] text-gray-500 flex-shrink-0",children:[s.length," files"]})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:s.length===0?e.jsx("div",{className:"p-4 text-xs text-gray-500 text-center",children:"No files found"}):e.jsx("div",{className:"divide-y divide-gray-800/50",children:s.map((n,o)=>e.jsx("button",{onClick:()=>r==null?void 0:r(n),className:"w-full text-left px-3 py-1.5 text-xs font-mono text-blue-400 hover:text-blue-300 hover:bg-gray-800/50 transition-colors truncate",children:n},o))})})]})}function ex({data:t}){const r=t.html||"";return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800/60 border-b border-gray-700/50",children:e.jsx("span",{className:"text-xs text-gray-400",children:"Preview"})}),e.jsx("div",{className:"flex-1 overflow-hidden bg-white",children:e.jsx("iframe",{srcDoc:r,sandbox:"allow-scripts",className:"w-full h-full border-0",title:"HTML Preview"})})]})}function tx({data:t}){const r=t.content||"";return e.jsx("div",{className:"h-full flex flex-col overflow-auto p-4",children:e.jsx(Qt,{className:"prose prose-sm max-w-none dark:prose-invert text-sm text-gray-300",children:r})})}function rx({artifact:t,onFileOpen:r}){switch(t.type){case"code":return e.jsx(Yp,{data:t.data});case"diff":return e.jsx(Qp,{data:t.data});case"terminal":return e.jsx(Xp,{data:t.data});case"search":return e.jsx(Zp,{data:t.data,onFileOpen:r});case"html":return e.jsx(ex,{data:t.data});case"markdown":return e.jsx(tx,{data:t.data});default:return e.jsx("div",{className:"p-4 text-xs text-gray-500",children:"Unknown artifact type"})}}const Gn={code:"📄",diff:"±",terminal:"$",search:"🔍",html:"🌐",markdown:"📝"};function Vn({artifacts:t,recentArtifacts:r,activeArtifactId:s,panelWidth:a,panelExpanded:n,resizeHandleRef:o,onResizeStart:i,onSetActive:c,onClose:d,onReopenArtifact:u,onClearHistory:m,onCloseAll:h,onToggleExpand:p,onFileOpen:g}){const[f,x]=lt.useState(!1);if(t.length===0&&r.length===0)return null;const y=t.find(N=>N.id===s)||t[0];return e.jsxs(e.Fragment,{children:[!n&&e.jsx("div",{ref:o,onMouseDown:i,className:"flex-shrink-0 w-1 bg-gray-200 dark:bg-gray-700 hover:bg-blue-500 dark:hover:bg-blue-600 cursor-col-resize transition-colors relative group",title:"Drag to resize",children:e.jsx("div",{className:"absolute inset-y-0 left-1/2 -translate-x-1/2 w-1 bg-blue-500 dark:bg-blue-600 opacity-0 group-hover:opacity-100 transition-opacity"})}),e.jsxs("div",{className:`flex-shrink-0 border-l border-gray-200 dark:border-gray-700 h-full overflow-hidden flex flex-col bg-gray-900 ${n?"flex-1":""}`,style:n?void 0:{width:`${a}px`},children:[e.jsxs("div",{className:"flex items-center bg-gray-800/80 border-b border-gray-700/50 min-h-[36px]",children:[e.jsx("div",{className:"flex-1 flex items-center overflow-x-auto scrollbar-none",children:t.map(N=>e.jsxs("button",{onClick:()=>c(N.id),className:`group/tab flex items-center gap-1.5 px-3 py-2 sm:py-1.5 text-xs border-r border-gray-700/30 whitespace-nowrap transition-colors ${N.id===(y==null?void 0:y.id)?"bg-gray-900 text-gray-200":"text-gray-500 hover:text-gray-300 hover:bg-gray-800/50"}`,children:[e.jsx("span",{className:"text-[10px] opacity-60",children:Gn[N.type]||"•"}),e.jsx("span",{className:"max-w-[120px] truncate",children:N.title}),e.jsx("button",{onClick:j=>{j.stopPropagation(),d(N.id)},className:"ml-1 opacity-0 group-hover/tab:opacity-100 text-gray-500 hover:text-gray-300 transition-opacity","aria-label":"Close tab",children:"×"})]},N.id))}),e.jsxs("div",{className:"flex items-center gap-0.5 px-1.5 flex-shrink-0",children:[r.length>0&&e.jsx("button",{onClick:()=>x(!f),className:`p-1 transition-colors min-w-[36px] min-h-[36px] flex items-center justify-center ${f?"text-gray-200":"text-gray-500 hover:text-gray-300"}`,title:`Recent (${r.length})`,children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsx("button",{onClick:p,className:"p-1 text-gray-500 hover:text-gray-300 transition-colors min-w-[36px] min-h-[36px] flex items-center justify-center",title:n?"Restore size":"Expand",children:n?e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25"})}):e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}),e.jsx("button",{onClick:h,className:"p-1 text-gray-500 hover:text-gray-300 transition-colors min-w-[36px] min-h-[36px] flex items-center justify-center",title:"Close all",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:y?e.jsx(rx,{artifact:y,onFileOpen:g}):t.length===0&&r.length>0?e.jsx("div",{className:"flex items-center justify-center h-full text-xs text-gray-500",children:"No open artifacts. Check recent history below."}):null}),f&&r.length>0&&e.jsxs("div",{className:"border-t border-gray-700/50 max-h-[200px] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-gray-800/60 sticky top-0",children:[e.jsxs("span",{className:"text-[10px] font-medium text-gray-400 uppercase tracking-wider",children:["Recent (",r.length,")"]}),e.jsx("button",{onClick:m,className:"text-[10px] text-gray-500 hover:text-gray-300 transition-colors",children:"Clear"})]}),e.jsx("div",{className:"divide-y divide-gray-800/30",children:r.map(N=>e.jsxs("button",{onClick:()=>u(N.id),className:"w-full text-left px-3 py-2.5 sm:py-1.5 text-xs hover:bg-gray-800/50 transition-colors flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] opacity-60 flex-shrink-0",children:Gn[N.type]||"•"}),e.jsx("span",{className:"text-gray-400 truncate",children:N.title}),e.jsx("span",{className:"ml-auto text-[10px] text-gray-600 flex-shrink-0",children:N.type})]},N.id))})]})]})]})}const qn=({task:t,onClick:r,showParent:s=!1,className:a=""})=>{const o=(c=>{switch(c){case"done":return{icon:Rr,bgColor:"bg-green-50 dark:bg-green-950",borderColor:"border-green-200 dark:border-green-800",iconColor:"text-green-600 dark:text-green-400",textColor:"text-green-900 dark:text-green-100",statusText:"Done"};case"in-progress":return{icon:Dr,bgColor:"bg-blue-50 dark:bg-blue-950",borderColor:"border-blue-200 dark:border-blue-800",iconColor:"text-blue-600 dark:text-blue-400",textColor:"text-blue-900 dark:text-blue-100",statusText:"In Progress"};case"review":return{icon:vs,bgColor:"bg-amber-50 dark:bg-amber-950",borderColor:"border-amber-200 dark:border-amber-800",iconColor:"text-amber-600 dark:text-amber-400",textColor:"text-amber-900 dark:text-amber-100",statusText:"Review"};case"deferred":return{icon:io,bgColor:"bg-gray-50 dark:bg-gray-800",borderColor:"border-gray-200 dark:border-gray-700",iconColor:"text-gray-500 dark:text-gray-400",textColor:"text-gray-700 dark:text-gray-300",statusText:"Deferred"};case"cancelled":return{icon:He,bgColor:"bg-red-50 dark:bg-red-950",borderColor:"border-red-200 dark:border-red-800",iconColor:"text-red-600 dark:text-red-400",textColor:"text-red-900 dark:text-red-100",statusText:"Cancelled"};case"pending":default:return{icon:ur,bgColor:"bg-slate-50 dark:bg-slate-800",borderColor:"border-slate-200 dark:border-slate-700",iconColor:"text-slate-500 dark:text-slate-400",textColor:"text-slate-900 dark:text-slate-100",statusText:"Pending"}}})(t.status);o.icon;const i=c=>{switch(c){case"high":return e.jsx(Et,{content:"High Priority",children:e.jsx("div",{className:"w-4 h-4 bg-red-100 dark:bg-red-900/30 rounded flex items-center justify-center",children:e.jsx(lo,{className:"w-2.5 h-2.5 text-red-600 dark:text-red-400"})})});case"medium":return e.jsx(Et,{content:"Medium Priority",children:e.jsx("div",{className:"w-4 h-4 bg-amber-100 dark:bg-amber-900/30 rounded flex items-center justify-center",children:e.jsx(zi,{className:"w-2.5 h-2.5 text-amber-600 dark:text-amber-400"})})});case"low":return e.jsx(Et,{content:"Low Priority",children:e.jsx("div",{className:"w-4 h-4 bg-blue-100 dark:bg-blue-900/30 rounded flex items-center justify-center",children:e.jsx(ur,{className:"w-1.5 h-1.5 text-blue-600 dark:text-blue-400 fill-current"})})});default:return e.jsx(Et,{content:"No Priority Set",children:e.jsx("div",{className:"w-4 h-4 bg-gray-100 dark:bg-gray-800 rounded flex items-center justify-center",children:e.jsx(ur,{className:"w-1.5 h-1.5 text-gray-400 dark:text-gray-500"})})})}};return e.jsxs("div",{className:ke("bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700","hover:shadow-md hover:border-blue-300 dark:hover:border-blue-600 transition-all duration-200 cursor-pointer","p-3 space-y-3",r&&"hover:-translate-y-0.5",a),onClick:r,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2 mb-1",children:e.jsx(Et,{content:`Task ID: ${t.id}`,children:e.jsx("span",{className:"text-xs font-mono text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-gray-700 px-2 py-0.5 rounded",children:t.id})})}),e.jsx("h3",{className:"font-medium text-sm text-gray-900 dark:text-white line-clamp-2 leading-tight",children:t.title}),s&&t.parentId&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400 font-medium",children:["Task ",t.parentId]})]}),e.jsx("div",{className:"flex-shrink-0",children:i(t.priority)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center",children:t.dependencies&&Array.isArray(t.dependencies)&&t.dependencies.length>0&&e.jsx(Et,{content:`Depends on: ${t.dependencies.map(c=>`Task ${c}`).join(", ")}`,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400",children:[e.jsx(Na,{className:"w-3 h-3"}),e.jsxs("span",{children:["Depends on: ",t.dependencies.join(", ")]})]})})}),e.jsx(Et,{content:`Status: ${o.statusText}`,children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:ke("w-2 h-2 rounded-full",o.iconColor.replace("text-","bg-"))}),e.jsx("span",{className:ke("text-xs font-medium",o.textColor),children:o.statusText})]})})]}),t.subtasks&&t.subtasks.length>0&&e.jsx("div",{className:"ml-3",children:e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Progress:"}),e.jsx(Et,{content:`${t.subtasks.filter(c=>c.status==="done").length} of ${t.subtasks.length} subtasks completed`,children:e.jsx("div",{className:"flex-1 bg-gray-200 dark:bg-gray-700 rounded-full h-1.5",children:e.jsx("div",{className:ke("h-full rounded-full transition-all duration-300",t.status==="done"?"bg-green-500":"bg-blue-500"),style:{width:`${Math.round(t.subtasks.filter(c=>c.status==="done").length/t.subtasks.length*100)}%`}})})}),e.jsx(Et,{content:`${t.subtasks.filter(c=>c.status==="done").length} completed, ${t.subtasks.filter(c=>c.status==="pending").length} pending, ${t.subtasks.filter(c=>c.status==="in-progress").length} in progress`,children:e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[t.subtasks.filter(c=>c.status==="done").length,"/",t.subtasks.length]})})]})})]})},sx=({currentProject:t,onClose:r,onTaskCreated:s})=>e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-md border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(Ut,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Create AI-Generated Task"})]}),e.jsx("button",{onClick:r,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:e.jsx(He,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-4 border border-blue-200 dark:border-blue-800",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(Ut,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"💡 Pro Tip: Ask Your AI Assistant Directly!"}),e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200 mb-3",children:"You can simply ask your AI assistant in the chat to create tasks for you. The AI assistant will automatically generate detailed tasks with research-backed insights."}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded border border-blue-200 dark:border-blue-700 p-3 mb-3",children:[e.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"Example:"}),e.jsx("p",{className:"text-sm text-gray-900 dark:text-white font-mono",children:'"Please add a new task to implement user profile image uploads using Cloudinary, research the best approach."'})]}),e.jsxs("p",{className:"text-xs text-blue-700 dark:text-blue-300",children:[e.jsx("strong",{children:"This runs:"})," ",e.jsx("code",{className:"bg-blue-100 dark:bg-blue-900/50 px-1 rounded text-xs",children:'task-master add-task --prompt="Implement user profile image uploads using Cloudinary" --research'})]})]})]})}),e.jsxs("div",{className:"text-center pt-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:"For more examples and advanced usage patterns:"}),e.jsx("a",{href:"https://github.com/eyaltoledano/claude-task-master/blob/main/docs/examples.md",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-sm text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline font-medium",children:"View TaskMaster Documentation →"})]}),e.jsx("div",{className:"pt-4",children:e.jsx("button",{onClick:r,className:"w-full px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Got it, I'll ask my AI assistant directly"})})]})]})}),ax=({tasks:t=[],onTaskClick:r,className:s="",showParentTasks:a=!1,defaultView:n="kanban",currentProject:o,onTaskCreated:i,onShowPRDEditor:c,existingPRDs:d=[],onRefreshPRDs:u})=>{var R,Z;const[m,h]=l.useState(""),[p,g]=l.useState("all"),[f,x]=l.useState("all"),[y,N]=l.useState("id"),[j,v]=l.useState("asc"),[k,A]=l.useState(n),[P,S]=l.useState(!1),[b,C]=l.useState(!1),[E,B]=l.useState(!1),[T,W]=l.useState(!1),[H,_]=l.useState(!1),[M,z]=l.useState(!1),{projectTaskMaster:K,refreshProjects:te,refreshTasks:q,setCurrentProject:ie}=fr(),{t:$}=Be("tasks");l.useEffect(()=>{const G=w=>{M&&!w.target.closest(".relative")&&z(!1)};return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[M]);const X=l.useMemo(()=>{const G=new Set(t.map(w=>w.status).filter(Boolean));return Array.from(G).sort()},[t]),re=l.useMemo(()=>{const G=new Set(t.map(w=>w.priority).filter(Boolean));return Array.from(G).sort()},[t]),Y=l.useMemo(()=>{let G=t.filter(w=>{var Ce;const I=m.toLowerCase(),J=!m||w.title.toLowerCase().includes(I)||((Ce=w.description)==null?void 0:Ce.toLowerCase().includes(I))||w.id.toString().includes(I),se=p==="all"||w.status===p,ce=f==="all"||w.priority===f;return J&&se&&ce});return G.sort((w,I)=>{let J,se;switch(y){case"title":J=w.title.toLowerCase(),se=I.title.toLowerCase();break;case"status":const ce={pending:1,"in-progress":2,done:3,blocked:4,deferred:5,cancelled:6};J=ce[w.status]||99,se=ce[I.status]||99;break;case"priority":const Ce={high:3,medium:2,low:1};J=Ce[w.priority]||0,se=Ce[I.priority]||0;break;case"updated":J=new Date(w.updatedAt||w.createdAt||0),se=new Date(I.updatedAt||I.createdAt||0);break;case"id":default:const fe=Ae=>Ae.toString().split(".").map(Ie=>parseInt(Ie,10)),_e=fe(w.id),we=fe(I.id);for(let Ae=0;Ae<Math.max(_e.length,we.length);Ae++){const Re=_e[Ae]||0,Ie=we[Ae]||0;if(Re!==Ie){J=Re,se=Ie;break}}break}return y==="updated"?j==="asc"?J-se:se-J:typeof J=="string"?j==="asc"?J.localeCompare(se):se.localeCompare(J):j==="asc"?J-se:se-J}),G},[t,m,p,f,y,j]),U=l.useMemo(()=>{const G=[{id:"pending",title:$("kanban.pending"),status:"pending",color:"bg-slate-50 dark:bg-slate-900/50 border-slate-200 dark:border-slate-700",headerColor:"bg-slate-100 dark:bg-slate-800 text-slate-800 dark:text-slate-200"},{id:"in-progress",title:$("kanban.inProgress"),status:"in-progress",color:"bg-blue-50 dark:bg-blue-900/50 border-blue-200 dark:border-blue-700",headerColor:"bg-blue-100 dark:bg-blue-800 text-blue-800 dark:text-blue-200"},{id:"done",title:$("kanban.done"),status:"done",color:"bg-emerald-50 dark:bg-emerald-900/50 border-emerald-200 dark:border-emerald-700",headerColor:"bg-emerald-100 dark:bg-emerald-800 text-emerald-800 dark:text-emerald-200"},{id:"blocked",title:$("kanban.blocked"),status:"blocked",color:"bg-red-50 dark:bg-red-900/50 border-red-200 dark:border-red-700",headerColor:"bg-red-100 dark:bg-red-800 text-red-800 dark:text-red-200"},{id:"deferred",title:$("kanban.deferred"),status:"deferred",color:"bg-amber-50 dark:bg-amber-900/50 border-amber-200 dark:border-amber-700",headerColor:"bg-amber-100 dark:bg-amber-800 text-amber-800 dark:text-amber-200"},{id:"cancelled",title:$("kanban.cancelled"),status:"cancelled",color:"bg-gray-50 dark:bg-gray-900/50 border-gray-200 dark:border-gray-700",headerColor:"bg-gray-100 dark:bg-gray-800 text-gray-800 dark:text-gray-200"}],w=["pending","in-progress","done"];return G.filter(J=>{const se=Y.some(Ce=>Ce.status===J.status),ce=w.includes(J.status);return se||ce}).map(J=>({...J,tasks:Y.filter(se=>se.status===J.status)}))},[Y,$]),O=G=>{y===G?v(j==="asc"?"desc":"asc"):(N(G),v("asc"))},F=()=>{h(""),g("all"),x("all")},V=G=>y!==G?e.jsx(Ui,{className:"w-4 h-4"}):j==="asc"?e.jsx(Hi,{className:"w-4 h-4"}):e.jsx(no,{className:"w-4 h-4"});if(t.length===0){const G=(o==null?void 0:o.taskMasterConfigured)||((R=o==null?void 0:o.taskmaster)==null?void 0:R.hasTaskmaster)||(K==null?void 0:K.hasTaskmaster);return e.jsxs("div",{className:ke("text-center py-12",s),children:[G?e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs("div",{className:"bg-gradient-to-r from-blue-50 to-indigo-50 dark:from-blue-950/50 dark:to-indigo-950/50 rounded-xl border border-blue-200 dark:border-blue-800 p-6 mb-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"w-10 h-10 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(ft,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:$("gettingStarted.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:$("gettingStarted.subtitle")})]})]}),e.jsxs("div",{className:"space-y-4 text-left",children:[e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"flex gap-3 p-3 bg-white dark:bg-gray-800/50 rounded-lg border border-blue-100 dark:border-blue-800/50",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 bg-blue-600 text-white text-xs font-semibold rounded-full flex items-center justify-center",children:"1"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-1",children:$("gettingStarted.steps.createPRD.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-2",children:$("gettingStarted.steps.createPRD.description")}),e.jsxs("button",{onClick:()=>{c==null||c()},className:"inline-flex items-center gap-1 text-xs bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 px-2 py-1 rounded hover:bg-purple-200 dark:hover:bg-purple-900/50 transition-colors",children:[e.jsx(ft,{className:"w-3 h-3"}),$("gettingStarted.steps.createPRD.addButton")]}),d.length>0&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mb-2",children:$("gettingStarted.steps.createPRD.existingPRDs")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.map(w=>e.jsxs("button",{onClick:async()=>{try{const I=await Ue.get(`/taskmaster/prd/${encodeURIComponent(o.name)}/${encodeURIComponent(w.name)}`);if(I.ok){const J=await I.json();c==null||c({name:w.name,content:J.content,isExisting:!0})}else console.error("Failed to load PRD:",I.statusText)}catch(I){console.error("Error loading PRD:",I)}},className:"inline-flex items-center gap-1 text-xs bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 px-2 py-1 rounded hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors",children:[e.jsx(ft,{className:"w-3 h-3"}),w.name]},w.name))})]})]})]}),e.jsxs("div",{className:"flex gap-3 p-3 bg-white dark:bg-gray-800/50 rounded-lg border border-blue-100 dark:border-blue-800/50",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 bg-blue-600 text-white text-xs font-semibold rounded-full flex items-center justify-center",children:"2"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-1",children:$("gettingStarted.steps.generateTasks.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:$("gettingStarted.steps.generateTasks.description")})]})]}),e.jsxs("div",{className:"flex gap-3 p-3 bg-white dark:bg-gray-800/50 rounded-lg border border-blue-100 dark:border-blue-800/50",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 bg-blue-600 text-white text-xs font-semibold rounded-full flex items-center justify-center",children:"3"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-1",children:$("gettingStarted.steps.analyzeTasks.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:$("gettingStarted.steps.analyzeTasks.description")})]})]}),e.jsxs("div",{className:"flex gap-3 p-3 bg-white dark:bg-gray-800/50 rounded-lg border border-blue-100 dark:border-blue-800/50",children:[e.jsx("div",{className:"flex-shrink-0 w-6 h-6 bg-blue-600 text-white text-xs font-semibold rounded-full flex items-center justify-center",children:"4"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-1",children:$("gettingStarted.steps.startBuilding.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:$("gettingStarted.steps.startBuilding.description")})]})]})]}),e.jsx("div",{className:"flex gap-3 pt-4 border-t border-blue-200 dark:border-blue-700",children:e.jsxs("button",{onClick:w=>{w.preventDefault(),w.stopPropagation(),c==null||c()},className:"flex items-center gap-2 px-4 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg font-medium transition-colors cursor-pointer",style:{zIndex:10},children:[e.jsx(ft,{className:"w-4 h-4"}),$("buttons.addPRD")]})})]})]}),e.jsx("div",{className:"text-center",children:e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400 mb-2",children:$("gettingStarted.tip")})})]}):e.jsxs("div",{className:"max-w-md mx-auto",children:[e.jsx("div",{className:"text-blue-600 dark:text-blue-400 mb-4",children:e.jsx(Lt,{className:"w-12 h-12 mx-auto mb-4"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white mb-2",children:$("notConfigured.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:$("notConfigured.description")}),e.jsxs("div",{className:"mb-6 p-4 bg-blue-50 dark:bg-blue-950 rounded-lg text-left",children:[e.jsx("h4",{className:"text-sm font-medium text-blue-900 dark:text-blue-100 mb-3",children:$("notConfigured.whatIsTitle")}),e.jsxs("div",{className:"text-xs text-blue-800 dark:text-blue-200 space-y-1",children:[e.jsxs("p",{children:["• ",$("notConfigured.features.aiPowered")]}),e.jsxs("p",{children:["• ",$("notConfigured.features.prdTemplates")]}),e.jsxs("p",{children:["• ",$("notConfigured.features.dependencyTracking")]}),e.jsxs("p",{children:["• ",$("notConfigured.features.progressVisualization")]}),e.jsxs("p",{children:["• ",$("notConfigured.features.cliIntegration")]})]})]}),e.jsxs("button",{onClick:()=>{_(!1),B(!0)},className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg font-medium transition-colors flex items-center gap-2 mx-auto",children:[e.jsx(bt,{className:"w-4 h-4"}),$("notConfigured.initializeButton")]})]}),E&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center p-4 pt-16 bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 w-full max-w-4xl h-[600px] flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(bt,{className:"w-4 h-4 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:$("setupModal.title")}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:$("setupModal.subtitle",{projectName:o==null?void 0:o.displayName})})]})]}),e.jsx("button",{onClick:()=>{B(!1),setTimeout(()=>{te(),o&&ie(o)},1e3)},className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800",children:e.jsx(st,{className:"w-5 h-5 rotate-45"})})]}),e.jsx("div",{className:"flex-1 p-4",children:e.jsx("div",{className:"h-full bg-black rounded-lg overflow-hidden",onClick:w=>{const I=w.currentTarget.querySelector(".xterm-screen");I&&I.focus()},children:e.jsx(po,{selectedProject:o,selectedSession:null,isActive:!0,initialCommand:"npx task-master init",isPlainShell:!0,onProcessComplete:w=>{_(!0),w===0&&setTimeout(()=>{te(),o&&ie(o)},1e3)}})})}),e.jsx("div",{className:"p-4 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:H?e.jsxs("span",{className:"flex items-center gap-2 text-green-600 dark:text-green-400",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),$("setupModal.completed")]}):$("setupModal.willStart")}),e.jsx("button",{onClick:()=>{B(!1),_(!1),setTimeout(()=>{te(),o&&ie(o)},1e3)},className:ke("px-4 py-2 text-sm font-medium rounded-md transition-colors",H?"bg-green-600 hover:bg-green-700 text-white":"text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-600"),children:$(H?"setupModal.closeContinueButton":"setupModal.closeButton")})]})})]})})]})}return e.jsxs("div",{className:ke("space-y-4",s),children:[e.jsxs("div",{className:"flex flex-col lg:flex-row gap-3 lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(Mr,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),e.jsx("input",{type:"text",placeholder:$("search.placeholder"),value:m,onChange:G=>h(G.target.value),className:"pl-10 pr-4 py-2 w-full border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"flex bg-gray-100 dark:bg-gray-800 rounded-lg p-1",children:[e.jsx("button",{onClick:()=>A("kanban"),className:ke("p-2 rounded-md transition-colors",k==="kanban"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),title:$("views.kanban"),children:e.jsx(Ri,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>A("list"),className:ke("p-2 rounded-md transition-colors",k==="list"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),title:$("views.list"),children:e.jsx(ta,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>A("grid"),className:ke("p-2 rounded-md transition-colors",k==="grid"?"bg-white dark:bg-gray-700 text-gray-900 dark:text-white shadow-sm":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),title:$("views.grid"),children:e.jsx(Oi,{className:"w-4 h-4"})})]}),e.jsxs("button",{onClick:()=>S(!P),className:ke("flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors",P?"bg-blue-50 dark:bg-blue-900 border-blue-200 dark:border-blue-700 text-blue-700 dark:text-blue-300":"bg-white dark:bg-gray-800 border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700"),children:[e.jsx(Bi,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:$("filters.button")}),e.jsx(Pt,{className:ke("w-4 h-4 transition-transform",P&&"rotate-180")})]}),o&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>W(!0),className:"p-2 text-gray-600 dark:text-gray-400 hover:text-blue-600 dark:hover:text-blue-400 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors border border-gray-300 dark:border-gray-600",title:$("buttons.help"),children:e.jsx(Wi,{className:"w-4 h-4"})}),e.jsx("div",{className:"relative",children:d.length>0?e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>z(!M),className:"flex items-center gap-2 px-3 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg transition-colors font-medium",title:$("buttons.prdsAvailable",{count:d.length}),children:[e.jsx(ft,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:$("buttons.prds")}),e.jsx("span",{className:"px-1.5 py-0.5 text-xs bg-purple-500 rounded-full min-w-[1.25rem] text-center",children:d.length}),e.jsx(Pt,{className:ke("w-3 h-3 transition-transform hidden sm:block",M&&"rotate-180")})]}),M&&e.jsx("div",{className:"absolute right-0 top-full mt-2 w-56 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-xl z-30",children:e.jsxs("div",{className:"p-2",children:[e.jsxs("button",{onClick:()=>{c==null||c(),z(!1)},className:"w-full text-left px-3 py-2 text-sm font-medium text-purple-700 dark:text-purple-300 hover:bg-purple-50 dark:hover:bg-purple-900/30 rounded flex items-center gap-2",children:[e.jsx(st,{className:"w-4 h-4"}),$("buttons.createNewPRD")]}),e.jsx("div",{className:"border-t border-gray-200 dark:border-gray-700 my-1"}),e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 px-3 py-1 font-medium",children:$("gettingStarted.steps.createPRD.existingPRDs")}),d.map(G=>e.jsxs("button",{onClick:async()=>{try{const w=await Ue.get(`/taskmaster/prd/${encodeURIComponent(o.name)}/${encodeURIComponent(G.name)}`);if(w.ok){const I=await w.json();c==null||c({name:G.name,content:I.content,isExisting:!0}),z(!1)}}catch(w){console.error("Error loading PRD:",w)}},className:"w-full text-left px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded flex items-center gap-2",title:$("prd.modified",{date:new Date(G.modified).toLocaleDateString()}),children:[e.jsx(ft,{className:"w-4 h-4"}),e.jsx("span",{className:"truncate",children:G.name})]},G.name))]})})]}):e.jsxs("button",{onClick:()=>{c==null||c()},className:"flex items-center gap-2 px-3 py-2 bg-purple-600 hover:bg-purple-700 text-white rounded-lg transition-colors font-medium",title:$("buttons.addPRD"),children:[e.jsx(ft,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:$("buttons.addPRD")})]})}),((o==null?void 0:o.taskMasterConfigured)||((Z=o==null?void 0:o.taskmaster)==null?void 0:Z.hasTaskmaster)||(K==null?void 0:K.hasTaskmaster)||t.length>0)&&e.jsxs("button",{onClick:()=>C(!0),className:"flex items-center gap-2 px-3 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors font-medium",title:$("buttons.addTask"),children:[e.jsx(st,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:$("buttons.addTask")})]})]})]})]}),P&&e.jsxs("div",{className:"bg-gray-50 dark:bg-gray-800 rounded-lg p-4 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:$("filters.status")}),e.jsxs("select",{value:p,onChange:G=>g(G.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"all",children:$("filters.allStatuses")}),X.map(G=>e.jsx("option",{value:G,children:$(`statuses.${G}`,G.charAt(0).toUpperCase()+G.slice(1).replace("-"," "))},G))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:$("filters.priority")}),e.jsxs("select",{value:f,onChange:G=>x(G.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"all",children:$("filters.allPriorities")}),re.map(G=>e.jsx("option",{value:G,children:$(`priorities.${G}`,G.charAt(0).toUpperCase()+G.slice(1))},G))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:$("filters.sortBy")}),e.jsxs("select",{value:`${y}-${j}`,onChange:G=>{const[w,I]=G.target.value.split("-");N(w),v(I)},className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500",children:[e.jsx("option",{value:"id-asc",children:$("sort.idAsc")}),e.jsx("option",{value:"id-desc",children:$("sort.idDesc")}),e.jsx("option",{value:"title-asc",children:$("sort.titleAsc")}),e.jsx("option",{value:"title-desc",children:$("sort.titleDesc")}),e.jsx("option",{value:"status-asc",children:$("sort.statusAsc")}),e.jsx("option",{value:"status-desc",children:$("sort.statusDesc")}),e.jsx("option",{value:"priority-asc",children:$("sort.priorityAsc")}),e.jsx("option",{value:"priority-desc",children:$("sort.priorityDesc")})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:$("filters.showing",{filtered:Y.length,total:t.length})}),e.jsx("button",{onClick:F,className:"text-sm text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 font-medium",children:$("filters.clearFilters")})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("button",{onClick:()=>O("id"),className:ke("flex items-center gap-1 px-3 py-1.5 rounded-md text-sm transition-colors",y==="id"?"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700"),children:[$("sort.id")," ",V("id")]}),e.jsxs("button",{onClick:()=>O("status"),className:ke("flex items-center gap-1 px-3 py-1.5 rounded-md text-sm transition-colors",y==="status"?"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700"),children:[$("sort.status")," ",V("status")]}),e.jsxs("button",{onClick:()=>O("priority"),className:ke("flex items-center gap-1 px-3 py-1.5 rounded-md text-sm transition-colors",y==="priority"?"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700"),children:[$("sort.priority")," ",V("priority")]})]}),Y.length===0?e.jsx("div",{className:"text-center py-12",children:e.jsxs("div",{className:"text-gray-500 dark:text-gray-400",children:[e.jsx(Mr,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:$("noMatchingTasks.title")}),e.jsx("p",{className:"text-sm",children:$("noMatchingTasks.description")})]})}):k==="kanban"?e.jsx("div",{className:ke("grid gap-6",U.length===1&&"grid-cols-1 max-w-md mx-auto",U.length===2&&"grid-cols-1 md:grid-cols-2",U.length===3&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-3",U.length===4&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-4",U.length===5&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5",U.length>=6&&"grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6"),children:U.map(G=>e.jsxs("div",{className:ke("rounded-xl border shadow-sm transition-shadow hover:shadow-md",G.color),children:[e.jsx("div",{className:ke("px-4 py-3 rounded-t-xl border-b",G.headerColor),children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"font-semibold text-sm",children:G.title}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"text-xs font-medium px-2 py-1 bg-white/60 dark:bg-black/20 rounded-full",children:G.tasks.length})})]})}),e.jsx("div",{className:"p-3 space-y-3 min-h-[200px] max-h-[calc(100vh-300px)] overflow-y-auto",children:G.tasks.length===0?e.jsxs("div",{className:"text-center py-8 text-gray-400 dark:text-gray-500",children:[e.jsx("div",{className:"w-8 h-8 mx-auto mb-2 rounded-full bg-gray-200 dark:bg-gray-700 flex items-center justify-center",children:e.jsx("div",{className:"w-3 h-3 rounded-full bg-gray-300 dark:bg-gray-600"})}),e.jsx("div",{className:"text-xs font-medium text-gray-500 dark:text-gray-400",children:$("kanban.noTasksYet")}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500 mt-1",children:G.status==="pending"?$("kanban.tasksWillAppear"):G.status==="in-progress"?$("kanban.moveTasksHere"):G.status==="done"?$("kanban.completedTasksHere"):$("kanban.statusTasksHere")})]}):G.tasks.map(w=>e.jsx("div",{className:"transform transition-transform hover:scale-[1.02]",children:e.jsx(qn,{task:w,onClick:()=>r==null?void 0:r(w),showParent:a,className:"w-full shadow-sm hover:shadow-md transition-shadow cursor-pointer"})},w.id))})]},G.id))}):e.jsx("div",{className:ke("gap-4",k==="grid"?"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3":"space-y-4"),children:Y.map(G=>e.jsx(qn,{task:G,onClick:()=>r==null?void 0:r(G),showParent:a,className:k==="grid"?"h-full":""},G.id))}),b&&e.jsx(sx,{currentProject:o,onClose:()=>C(!1),onTaskCreated:()=>{C(!1),i&&i()}}),T&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-lg shadow-xl border border-gray-200 dark:border-gray-700 w-full max-w-4xl max-h-[90vh] overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-blue-100 dark:bg-blue-900/50 rounded-lg flex items-center justify-center",children:e.jsx(ft,{className:"w-5 h-5 text-blue-600 dark:text-blue-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:$("helpGuide.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:$("helpGuide.subtitle")})]})]}),e.jsx("button",{onClick:()=>W(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors",children:e.jsx(He,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-120px)]",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-4 p-4 bg-gradient-to-r from-blue-50 to-indigo-50 dark:from-blue-950/50 dark:to-indigo-950/50 rounded-lg border border-blue-200 dark:border-blue-800",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-blue-600 text-white text-sm font-semibold rounded-full flex items-center justify-center",children:"1"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-2",children:$("gettingStarted.steps.createPRD.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:$("gettingStarted.steps.createPRD.description")}),e.jsxs("button",{onClick:()=>{c==null||c(),W(!1)},className:"inline-flex items-center gap-2 text-sm bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 px-3 py-1.5 rounded-lg hover:bg-purple-200 dark:hover:bg-purple-900/50 transition-colors",children:[e.jsx(ft,{className:"w-4 h-4"}),$("buttons.addPRD")]})]})]}),e.jsxs("div",{className:"flex gap-4 p-4 bg-gradient-to-r from-green-50 to-emerald-50 dark:from-green-950/50 dark:to-emerald-950/50 rounded-lg border border-green-200 dark:border-green-800",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-green-600 text-white text-sm font-semibold rounded-full flex items-center justify-center",children:"2"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-2",children:$("gettingStarted.steps.generateTasks.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:$("gettingStarted.steps.generateTasks.description")}),e.jsx("div",{className:"bg-white dark:bg-gray-800/50 rounded border border-green-200 dark:border-green-700/50 p-3 mb-2",children:e.jsx("p",{className:"text-xs text-gray-900 dark:text-white font-mono whitespace-pre-wrap",children:$("helpGuide.examples.parsePRD")})})]})]}),e.jsxs("div",{className:"flex gap-4 p-4 bg-gradient-to-r from-amber-50 to-orange-50 dark:from-amber-950/50 dark:to-orange-950/50 rounded-lg border border-amber-200 dark:border-amber-800",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-amber-600 text-white text-sm font-semibold rounded-full flex items-center justify-center",children:"3"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-2",children:$("gettingStarted.steps.analyzeTasks.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:$("gettingStarted.steps.analyzeTasks.description")}),e.jsx("div",{className:"bg-white dark:bg-gray-800/50 rounded border border-amber-200 dark:border-amber-700/50 p-3 mb-2",children:e.jsx("p",{className:"text-xs text-gray-900 dark:text-white font-mono whitespace-pre-wrap",children:$("helpGuide.examples.expandTask")})})]})]}),e.jsxs("div",{className:"flex gap-4 p-4 bg-gradient-to-r from-purple-50 to-pink-50 dark:from-purple-950/50 dark:to-pink-950/50 rounded-lg border border-purple-200 dark:border-purple-800",children:[e.jsx("div",{className:"flex-shrink-0 w-8 h-8 bg-purple-600 text-white text-sm font-semibold rounded-full flex items-center justify-center",children:"4"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-2",children:$("gettingStarted.steps.startBuilding.title")}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:$("gettingStarted.steps.startBuilding.description")}),e.jsx("div",{className:"bg-white dark:bg-gray-800/50 rounded border border-purple-200 dark:border-purple-700/50 p-3 mb-3",children:e.jsx("p",{className:"text-xs text-gray-900 dark:text-white font-mono whitespace-pre-wrap",children:$("helpGuide.examples.addTask")})}),e.jsx("a",{href:"https://github.com/eyaltoledano/claude-task-master/blob/main/docs/examples.md",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",children:$("helpGuide.moreExamples")})]})]}),e.jsxs("div",{className:"mt-6 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsx("h4",{className:"font-medium text-gray-900 dark:text-white mb-3",children:$("helpGuide.proTips.title")}),e.jsxs("ul",{className:"space-y-2 text-sm text-gray-600 dark:text-gray-400",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 bg-blue-500 rounded-full mt-2 flex-shrink-0"}),$("helpGuide.proTips.search")]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 bg-green-500 rounded-full mt-2 flex-shrink-0"}),$("helpGuide.proTips.views")]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 bg-purple-500 rounded-full mt-2 flex-shrink-0"}),$("helpGuide.proTips.filters")]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 bg-orange-500 rounded-full mt-2 flex-shrink-0"}),$("helpGuide.proTips.details")]})]})]}),e.jsxs("div",{className:"mt-6 p-4 bg-blue-50 dark:bg-blue-950/50 rounded-lg border border-blue-200 dark:border-blue-800",children:[e.jsx("h4",{className:"font-medium text-blue-900 dark:text-blue-100 mb-3",children:$("helpGuide.learnMore.title")}),e.jsx("p",{className:"text-sm text-blue-800 dark:text-blue-200 mb-3",children:$("helpGuide.learnMore.description")}),e.jsxs("a",{href:"https://github.com/eyaltoledano/claude-task-master",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm bg-blue-600 hover:bg-blue-700 text-white px-3 py-2 rounded-lg font-medium transition-colors",children:[e.jsx("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z",clipRule:"evenodd"})}),$("helpGuide.learnMore.githubButton"),e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})]})]})})]})})]})},nx=({file:t,onClose:r,projectPath:s,project:a,initialContent:n="",isNewFile:o=!1,onSave:i})=>{const{addToast:c}=hr(),[d,u]=l.useState(n),[m,h]=l.useState(!o),[p,g]=l.useState(!1),[f,x]=l.useState(!1),[y,N]=l.useState(!0),[j,v]=l.useState(!1),[k,A]=l.useState(!1),[P,S]=l.useState(!0),[b,C]=l.useState(""),[E,B]=l.useState(!1),[T,W]=l.useState(!1),[H,_]=l.useState([]),M=l.useRef(null),z=`# Product Requirements Document - Example Project
279
+
280
+ ## 1. Overview
281
+ **Product Name:** AI-Powered Task Manager
282
+ **Version:** 1.0
283
+ **Date:** 2024-12-27
284
+ **Author:** Development Team
285
+
286
+ This document outlines the requirements for building an AI-powered task management application that integrates with development workflows and provides intelligent task breakdown and prioritization.
287
+
288
+ ## 2. Objectives
289
+ - Create an intuitive task management system that works seamlessly with developer tools
290
+ - Provide AI-powered task generation from high-level requirements
291
+ - Enable real-time collaboration and progress tracking
292
+ - Integrate with popular development environments (VS Code, Cursor, etc.)
293
+
294
+ ### Success Metrics
295
+ - User adoption rate > 80% within development teams
296
+ - Task completion rate improvement of 25%
297
+ - Time-to-delivery reduction of 15%
298
+
299
+ ## 3. User Stories
300
+
301
+ ### Core Functionality
302
+ - As a project manager, I want to create PRDs that automatically generate detailed tasks so I can save time on project planning
303
+ - As a developer, I want to see my next task clearly highlighted so I can maintain focus
304
+ - As a team lead, I want to track progress across multiple projects so I can provide accurate status updates
305
+ - As a developer, I want tasks to be broken down into implementable subtasks so I can work more efficiently
306
+
307
+ ### AI Integration
308
+ - As a user, I want to describe a feature in natural language and get detailed implementation tasks so I can start working immediately
309
+ - As a project manager, I want the AI to analyze task complexity and suggest appropriate time estimates
310
+ - As a developer, I want intelligent task prioritization based on dependencies and deadlines
311
+
312
+ ### Collaboration
313
+ - As a team member, I want to see real-time updates when tasks are completed so I can coordinate my work
314
+ - As a stakeholder, I want to view project progress through intuitive dashboards
315
+ - As a developer, I want to add implementation notes to tasks for future reference
316
+
317
+ ## 4. Functional Requirements
318
+
319
+ ### Task Management
320
+ - Create, edit, and delete tasks with rich metadata (priority, status, dependencies, estimates)
321
+ - Hierarchical task structure with subtasks and sub-subtasks
322
+ - Real-time status updates and progress tracking
323
+ - Dependency management with circular dependency detection
324
+ - Bulk operations (move, update status, assign)
325
+
326
+ ### AI Features
327
+ - Natural language PRD parsing to generate structured tasks
328
+ - Intelligent task breakdown with complexity analysis
329
+ - Automated subtask generation with implementation details
330
+ - Smart dependency suggestion
331
+ - Progress prediction based on historical data
332
+
333
+ ### Integration Features
334
+ - VS Code/Cursor extension for in-editor task management
335
+ - Git integration for linking commits to tasks
336
+ - API for third-party tool integration
337
+ - Webhook support for external notifications
338
+ - CLI tool for command-line task management
339
+
340
+ ### User Interface
341
+ - Responsive web application (desktop and mobile)
342
+ - Multiple view modes (Kanban, list, calendar)
343
+ - Dark/light theme support
344
+ - Drag-and-drop task organization
345
+ - Advanced filtering and search capabilities
346
+ - Keyboard shortcuts for power users
347
+
348
+ ## 5. Technical Requirements
349
+
350
+ ### Frontend
351
+ - React.js with TypeScript for type safety
352
+ - Modern UI framework (Tailwind CSS)
353
+ - State management (Context API or Redux)
354
+ - Real-time updates via WebSockets
355
+ - Progressive Web App (PWA) support
356
+ - Accessibility compliance (WCAG 2.1 AA)
357
+
358
+ ### Backend
359
+ - Node.js with Express.js framework
360
+ - RESTful API design with OpenAPI documentation
361
+ - Real-time communication via Socket.io
362
+ - Background job processing
363
+ - Rate limiting and security middleware
364
+
365
+ ### AI Integration
366
+ - Integration with multiple AI providers (OpenAI, Anthropic, etc.)
367
+ - Fallback model support
368
+ - Context-aware prompt engineering
369
+ - Token usage optimization
370
+ - Model response caching
371
+
372
+ ### Database
373
+ - Primary: PostgreSQL for relational data
374
+ - Cache: Redis for session management and real-time features
375
+ - Full-text search capabilities
376
+ - Database migrations and seeding
377
+ - Backup and recovery procedures
378
+
379
+ ### Infrastructure
380
+ - Docker containerization
381
+ - Cloud deployment (AWS/GCP/Azure)
382
+ - Auto-scaling capabilities
383
+ - Monitoring and logging (structured logging)
384
+ - CI/CD pipeline with automated testing
385
+
386
+ ## 6. Non-Functional Requirements
387
+
388
+ ### Performance
389
+ - Page load time < 2 seconds
390
+ - API response time < 500ms for 95% of requests
391
+ - Support for 1000+ concurrent users
392
+ - Efficient handling of large task lists (10,000+ tasks)
393
+
394
+ ### Security
395
+ - JWT-based authentication with refresh tokens
396
+ - Role-based access control (RBAC)
397
+ - Data encryption at rest and in transit
398
+ - Regular security audits and penetration testing
399
+ - GDPR and privacy compliance
400
+
401
+ ### Reliability
402
+ - 99.9% uptime SLA
403
+ - Graceful error handling and recovery
404
+ - Data backup every 6 hours with point-in-time recovery
405
+ - Disaster recovery plan with RTO < 4 hours
406
+
407
+ ### Scalability
408
+ - Horizontal scaling for both frontend and backend
409
+ - Database read replicas for query optimization
410
+ - CDN for static asset delivery
411
+ - Microservices architecture for future expansion
412
+
413
+ ## 7. User Experience Design
414
+
415
+ ### Information Architecture
416
+ - Intuitive navigation with breadcrumbs
417
+ - Context-aware menus and actions
418
+ - Progressive disclosure of complex features
419
+ - Consistent design patterns throughout
420
+
421
+ ### Interaction Design
422
+ - Smooth animations and transitions
423
+ - Immediate feedback for user actions
424
+ - Undo/redo functionality for critical operations
425
+ - Smart defaults and auto-save features
426
+
427
+ ### Visual Design
428
+ - Modern, clean interface with plenty of whitespace
429
+ - Consistent color scheme and typography
430
+ - Clear visual hierarchy with proper contrast ratios
431
+ - Iconography that supports comprehension
432
+
433
+ ## 8. Integration Requirements
434
+
435
+ ### Development Tools
436
+ - VS Code extension with task panel and quick actions
437
+ - Cursor IDE integration with AI task suggestions
438
+ - Terminal CLI for command-line workflow
439
+ - Browser extension for web-based tools
440
+
441
+ ### Third-Party Services
442
+ - GitHub/GitLab integration for issue sync
443
+ - Slack/Discord notifications
444
+ - Calendar integration (Google Calendar, Outlook)
445
+ - Time tracking tools (Toggl, Harvest)
446
+
447
+ ### APIs and Webhooks
448
+ - RESTful API with comprehensive documentation
449
+ - GraphQL endpoint for complex queries
450
+ - Webhook system for external integrations
451
+ - SDK development for major programming languages
452
+
453
+ ## 9. Implementation Phases
454
+
455
+ ### Phase 1: Core MVP (8-10 weeks)
456
+ - Basic task management (CRUD operations)
457
+ - Simple AI task generation
458
+ - Web interface with essential features
459
+ - User authentication and basic permissions
460
+
461
+ ### Phase 2: Enhanced Features (6-8 weeks)
462
+ - Advanced AI features (complexity analysis, subtask generation)
463
+ - Real-time collaboration
464
+ - Mobile-responsive design
465
+ - Integration with one development tool (VS Code)
466
+
467
+ ### Phase 3: Enterprise Features (4-6 weeks)
468
+ - Advanced user management and permissions
469
+ - API and webhook system
470
+ - Performance optimization
471
+ - Comprehensive testing and security audit
472
+
473
+ ### Phase 4: Ecosystem Expansion (4-6 weeks)
474
+ - Additional tool integrations
475
+ - Mobile app development
476
+ - Advanced analytics and reporting
477
+ - Third-party marketplace preparation
478
+
479
+ ## 10. Risk Assessment
480
+
481
+ ### Technical Risks
482
+ - AI model reliability and cost management
483
+ - Real-time synchronization complexity
484
+ - Database performance with large datasets
485
+ - Integration complexity with multiple tools
486
+
487
+ ### Business Risks
488
+ - User adoption in competitive market
489
+ - AI provider dependency
490
+ - Data privacy and security concerns
491
+ - Feature scope creep and timeline delays
492
+
493
+ ### Mitigation Strategies
494
+ - Implement robust error handling and fallback systems
495
+ - Develop comprehensive testing strategy
496
+ - Create detailed documentation and user guides
497
+ - Establish clear project scope and change management process
498
+
499
+ ## 11. Success Criteria
500
+
501
+ ### Development Milestones
502
+ - Alpha version with core features completed
503
+ - Beta version with selected user group feedback
504
+ - Production-ready version with full feature set
505
+ - Post-launch iterations based on user feedback
506
+
507
+ ### Business Metrics
508
+ - User engagement and retention rates
509
+ - Task completion and productivity metrics
510
+ - Customer satisfaction scores (NPS > 50)
511
+ - Revenue targets and subscription growth
512
+
513
+ ## 12. Appendices
514
+
515
+ ### Glossary
516
+ - **PRD**: Product Requirements Document
517
+ - **AI**: Artificial Intelligence
518
+ - **CRUD**: Create, Read, Update, Delete
519
+ - **API**: Application Programming Interface
520
+ - **CI/CD**: Continuous Integration/Continuous Deployment
521
+
522
+ ### References
523
+ - Industry best practices for task management
524
+ - AI integration patterns and examples
525
+ - Security and compliance requirements
526
+ - Performance benchmarking data
527
+
528
+ ---
529
+
530
+ **Document Control:**
531
+ - Version: 1.0
532
+ - Last Updated: December 27, 2024
533
+ - Next Review: January 15, 2025
534
+ - Approved By: Product Owner, Technical Lead`;l.useEffect(()=>{(async()=>{if(t!=null&&t.name)C(t.name.replace(/\.(txt|md)$/,""));else if(o){const U=new Date().toISOString().split("T")[0];C(`prd-${U}`)}if(o){u(z),h(!1);return}if(t.content){u(t.content),h(!1);return}try{h(!0);const Y=await Ue.readFile(t.projectName,t.path);if(!Y.ok)throw new Error(`Failed to load file: ${Y.status} ${Y.statusText}`);const U=await Y.json();u(U.content||z)}catch(Y){console.error("Error loading PRD file:",Y),u(`# Error Loading PRD
535
+
536
+ Error: ${Y.message}
537
+
538
+ File: ${(t==null?void 0:t.name)||"New PRD"}
539
+ Path: ${(t==null?void 0:t.path)||"Not saved yet"}
540
+
541
+ ${z}`)}finally{h(!1)}})()},[t,s,o]),l.useEffect(()=>{(async()=>{if(!(a!=null&&a.name)){console.log("No project name available:",a);return}try{console.log("Fetching PRDs for project:",a.name);const Y=await Ue.get(`/taskmaster/prd/${encodeURIComponent(a.name)}`);if(Y.ok){const U=await Y.json();console.log("Fetched existing PRDs:",U.prds),_(U.prds||[])}else console.log("Failed to fetch PRDs:",Y.status,Y.statusText)}catch(Y){console.error("Error fetching existing PRDs:",Y)}})()},[a==null?void 0:a.name]);const K=async()=>{if(!d.trim()){c("Please add content before saving.","warning");return}if(!b.trim()){c("Please provide a filename for the PRD.","warning");return}const re=b.endsWith(".txt")||b.endsWith(".md")?b:`${b}.txt`,Y=H.find(U=>U.name===re);if(console.log("Save check:",{fullFileName:re,existingPRDs:H,existingFile:Y,isExisting:t==null?void 0:t.isExisting,fileObject:t,shouldShowModal:Y&&!(t!=null&&t.isExisting)}),Y&&!(t!=null&&t.isExisting)){console.log("Showing overwrite confirmation modal"),W(!0);return}await te()},te=async()=>{g(!0);try{const re=b.endsWith(".txt")||b.endsWith(".md")?b:`${b}.txt`,Y=await Te(`/api/taskmaster/prd/${encodeURIComponent(a==null?void 0:a.name)}`,{method:"POST",body:JSON.stringify({fileName:re,content:d})});if(!Y.ok){const O=await Y.json();throw new Error(O.message||`Save failed: ${Y.status}`)}v(!0),setTimeout(()=>v(!1),2e3);const U=await Ue.get(`/taskmaster/prd/${encodeURIComponent(a.name)}`);if(U.ok){const O=await U.json();_(O.prds||[])}i&&await i()}catch(re){console.error("Error saving PRD:",re),c(`Error saving PRD: ${re.message}`,"error")}finally{g(!1)}},q=()=>{const re=new Blob([d],{type:"text/markdown"}),Y=URL.createObjectURL(re),U=document.createElement("a");U.href=Y;const O=b?`${b}.txt`:"prd.txt";U.download=O,document.body.appendChild(U),U.click(),document.body.removeChild(U),URL.revokeObjectURL(Y)},ie=async()=>{if(!d.trim()){c("Please add content to the PRD before generating tasks.","warning");return}B(!0)},$=()=>{x(!f)};l.useEffect(()=>{const re=Y=>{(Y.ctrlKey||Y.metaKey)&&(Y.key==="s"?(Y.preventDefault(),K()):Y.key==="Escape"&&(Y.preventDefault(),r()))};return document.addEventListener("keydown",re),()=>document.removeEventListener("keydown",re)},[d]);const X=re=>re.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*)\*/gim,"<em>$1</em>").replace(/^\- (.*$)/gim,"<li>$1</li>").replace(/(<li>.*<\/li>)/gims,"<ul>$1</ul>").replace(/\n\n/gim,"</p><p>").replace(/^(?!<[h|u|l])(.*$)/gim,"<p>$1</p>").replace(/<\/ul>\s*<ul>/gim,"");return m?e.jsx("div",{className:"fixed inset-0 z-[200] md:bg-black/50 md:flex md:items-center md:justify-center",children:e.jsx("div",{className:"w-full h-full md:rounded-lg md:w-auto md:h-auto p-8 flex items-center justify-center bg-white dark:bg-gray-900",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"}),e.jsx("span",{className:"text-gray-900 dark:text-white",children:"Loading PRD..."})]})})}):e.jsxs("div",{className:`fixed inset-0 z-[200] md:bg-black/50 md:flex md:items-center md:justify-center md:p-4 ${f?"md:p-0":""}`,children:[e.jsxs("div",{className:ke("bg-white dark:bg-gray-900 shadow-2xl flex flex-col","w-full h-full md:rounded-lg md:shadow-2xl",f?"md:w-full md:h-full md:rounded-none":"md:w-full md:max-w-6xl md:h-[85vh] md:max-h-[85vh]"),children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700 flex-shrink-0 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:"w-8 h-8 bg-purple-600 rounded flex items-center justify-center flex-shrink-0",children:e.jsx(ft,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1 min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center min-w-0 flex-1 bg-gray-50 dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-md px-3 py-2 focus-within:ring-2 focus-within:ring-purple-500 focus-within:border-purple-500 dark:focus-within:ring-purple-400 dark:focus-within:border-purple-400",children:[e.jsx("input",{type:"text",value:b,onChange:re=>{const Y=re.target.value.replace(/[<>:"/\\|?*]/g,"");C(Y)},className:"font-medium text-gray-900 dark:text-white bg-transparent border-none outline-none min-w-0 flex-1 text-base sm:text-sm placeholder-gray-400 dark:placeholder-gray-500",placeholder:"Enter PRD filename",maxLength:100}),e.jsx("span",{className:"text-sm sm:text-xs text-gray-500 dark:text-gray-400 whitespace-nowrap ml-1",children:".txt"})]}),e.jsx("button",{onClick:()=>{var re;return(re=document.querySelector('input[placeholder="Enter PRD filename"]'))==null?void 0:re.focus()},className:"p-1 text-gray-400 hover:text-purple-600 dark:hover:text-purple-400 transition-colors",title:"Click to edit filename",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"})})})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("span",{className:"text-xs bg-purple-100 dark:bg-purple-900 text-purple-600 dark:text-purple-300 px-2 py-1 rounded whitespace-nowrap",children:"📋 PRD"}),o&&e.jsx("span",{className:"text-xs bg-green-100 dark:bg-green-900 text-green-600 dark:text-green-300 px-2 py-1 rounded whitespace-nowrap",children:"✨ New"})]})]}),e.jsx("p",{className:"text-xs sm:text-sm text-gray-500 dark:text-gray-400 truncate mt-1",children:"Product Requirements Document"})]})]}),e.jsxs("div",{className:"flex items-center gap-1 md:gap-2 flex-shrink-0",children:[e.jsx("button",{onClick:()=>A(!k),className:ke("p-2 md:p-2 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800","min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",k?"text-purple-600 dark:text-purple-400 bg-purple-50 dark:bg-purple-900":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"),title:k?"Switch to edit mode":"Preview markdown",children:e.jsx(ar,{className:"w-5 h-5 md:w-4 md:h-4"})}),e.jsx("button",{onClick:()=>S(!P),className:ke("p-2 md:p-2 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800","min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",P?"text-blue-600 dark:text-blue-400 bg-blue-50 dark:bg-blue-900":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"),title:P?"Disable word wrap":"Enable word wrap",children:e.jsx("span",{className:"text-sm md:text-xs font-mono font-bold",children:"↵"})}),e.jsx("button",{onClick:()=>N(!y),className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:"Toggle theme",children:e.jsx("span",{className:"text-lg md:text-base",children:y?"☀️":"🌙"})}),e.jsx("button",{onClick:q,className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:"Download PRD",children:e.jsx(uo,{className:"w-5 h-5 md:w-4 md:h-4"})}),e.jsxs("button",{onClick:ie,disabled:!d.trim(),className:ke("px-3 py-2 rounded-md disabled:opacity-50 flex items-center gap-2 transition-colors text-sm font-medium","bg-purple-600 hover:bg-purple-700 text-white","min-h-[44px] md:min-h-0"),title:"Generate tasks from PRD content",children:[e.jsx(Ut,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden md:inline",children:"Generate Tasks"})]}),e.jsx("button",{onClick:K,disabled:p,className:ke("px-3 py-2 text-white rounded-md disabled:opacity-50 flex items-center gap-2 transition-colors","min-h-[44px] md:min-h-0",j?"bg-green-600 hover:bg-green-700":"bg-purple-600 hover:bg-purple-700"),children:j?e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-5 h-5 md:w-4 md:h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsx("span",{className:"hidden sm:inline",children:"Saved!"})]}):e.jsxs(e.Fragment,{children:[e.jsx(ls,{className:"w-5 h-5 md:w-4 md:h-4"}),e.jsx("span",{className:"hidden sm:inline",children:p?"Saving...":"Save PRD"})]})}),e.jsx("button",{onClick:$,className:"hidden md:flex p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 items-center justify-center",title:f?"Exit fullscreen":"Fullscreen",children:f?e.jsx(mo,{className:"w-4 h-4"}):e.jsx(ja,{className:"w-4 h-4"})}),e.jsx("button",{onClick:r,className:"p-2 md:p-2 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 min-w-[44px] min-h-[44px] md:min-w-0 md:min-h-0 flex items-center justify-center",title:"Close",children:e.jsx(He,{className:"w-6 h-6 md:w-4 md:h-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:k?e.jsx("div",{className:"h-full overflow-y-auto p-6 prose prose-gray dark:prose-invert max-w-none",children:e.jsx("div",{className:"markdown-preview",dangerouslySetInnerHTML:{__html:X(d)}})}):e.jsx(fo,{ref:M,value:d,onChange:u,extensions:[yo(),...P?[Wt.lineWrapping]:[]],theme:y?bo:void 0,height:"100%",style:{fontSize:"14px",height:"100%"},basicSetup:{lineNumbers:!0,foldGutter:!0,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!0,highlightSelectionMatches:!0,searchKeymap:!0}})}),e.jsxs("div",{className:"flex items-center justify-between p-3 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-600 dark:text-gray-400",children:[e.jsxs("span",{children:["Lines: ",d.split(`
542
+ `).length]}),e.jsxs("span",{children:["Characters: ",d.length]}),e.jsxs("span",{children:["Words: ",d.split(/\s+/).filter(re=>re.length>0).length]}),e.jsx("span",{children:"Format: Markdown"})]}),e.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Press Ctrl+S to save • Esc to close"})]})]}),E&&e.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-xl w-full max-w-md border border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center",children:e.jsx(Ut,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Generate Tasks from PRD"})]}),e.jsx("button",{onClick:()=>B(!1),className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-md hover:bg-gray-100 dark:hover:bg-gray-700",children:e.jsx(He,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsx("div",{className:"bg-purple-50 dark:bg-purple-900/20 rounded-lg p-4 border border-purple-200 dark:border-purple-800",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-purple-100 dark:bg-purple-900/50 rounded-lg flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx(Ut,{className:"w-4 h-4 text-purple-600 dark:text-purple-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold text-purple-900 dark:text-purple-100 mb-2",children:"💡 Pro Tip: Ask Your AI Assistant Directly!"}),e.jsx("p",{className:"text-sm text-purple-800 dark:text-purple-200 mb-3",children:"You can simply ask your AI assistant in the chat to parse your PRD and generate tasks. The AI assistant will automatically save your PRD and create detailed tasks with implementation details."}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded border border-purple-200 dark:border-purple-700 p-3 mb-3",children:[e.jsx("p",{className:"text-xs font-medium text-gray-600 dark:text-gray-400 mb-1",children:"💬 Example:"}),e.jsxs("p",{className:"text-xs text-gray-900 dark:text-white font-mono",children:[`"I've just initialized a new project with Claude Task Master. I have a PRD at .taskmaster/docs/`,b.endsWith(".txt")||b.endsWith(".md")?b:`${b}.txt`,'. Can you help me parse it and set up the initial tasks?"']})]}),e.jsxs("p",{className:"text-xs text-purple-700 dark:text-purple-300",children:[e.jsx("strong",{children:"This will:"})," Save your PRD, analyze its content, and generate structured tasks with subtasks, dependencies, and implementation details."]})]})]})}),e.jsxs("div",{className:"text-center pt-4 border-t border-gray-200 dark:border-gray-700",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-3",children:"For more examples and advanced usage patterns:"}),e.jsx("a",{href:"https://github.com/eyaltoledano/claude-task-master/blob/main/docs/examples.md",target:"_blank",rel:"noopener noreferrer",className:"inline-block text-sm text-purple-600 dark:text-purple-400 hover:text-purple-700 dark:hover:text-purple-300 underline font-medium",children:"View TaskMaster Documentation →"})]}),e.jsx("div",{className:"pt-4",children:e.jsx("button",{onClick:()=>B(!1),className:"w-full px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Got it, I'll ask my AI assistant directly"})})]})]})}),T&&e.jsxs("div",{className:"fixed inset-0 z-[300] flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50",onClick:()=>W(!1)}),e.jsx("div",{className:"relative bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-md w-full border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"flex items-center mb-4",children:[e.jsx("div",{className:"p-2 rounded-full mr-3 bg-yellow-100 dark:bg-yellow-900",children:e.jsx($t,{className:"w-5 h-5 text-yellow-600 dark:text-yellow-400"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"File Already Exists"})]}),e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-6",children:['A PRD file named "',b.endsWith(".txt")||b.endsWith(".md")?b:`${b}.txt`,'" already exists. Do you want to overwrite it with the current content?']}),e.jsxs("div",{className:"flex justify-end space-x-3",children:[e.jsx("button",{onClick:()=>W(!1),className:"px-4 py-2 text-sm text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-md hover:bg-gray-50 dark:hover:bg-gray-600 transition-colors",children:"Cancel"}),e.jsxs("button",{onClick:async()=>{W(!1),await te()},className:"px-4 py-2 text-sm text-white bg-yellow-600 hover:bg-yellow-700 rounded-md flex items-center space-x-2 transition-colors",children:[e.jsx(ls,{className:"w-4 h-4"}),e.jsx("span",{children:"Overwrite"})]})]})]})})]})]})},ox=ax,ix=Vo,lx=nx,cx="PRD saved successfully!";function dx(t){return t.prdFiles||t.prds||[]}function ux({isVisible:t}){const{tasks:r=[],currentProject:s,refreshTasks:a}=fr(),[n,o]=l.useState(null),[i,c]=l.useState(!1),[d,u]=l.useState(!1),[m,h]=l.useState(null),[p,g]=l.useState([]),[f,x]=l.useState(null),y=l.useRef(null),N=l.useCallback(E=>{y.current&&clearTimeout(y.current),x(E),y.current=setTimeout(()=>{x(null),y.current=null},3e3)},[]),j=l.useCallback(async()=>{if(!(s!=null&&s.name)){g([]);return}try{const E=await Ue.get(`/taskmaster/prd/${encodeURIComponent(s.name)}`);if(!E.ok){g([]);return}const B=await E.json();g(dx(B))}catch(E){console.error("Failed to load existing PRDs:",E),g([])}},[s==null?void 0:s.name]),v=l.useCallback(async(E=!1)=>{await j(),E&&N(cx)},[j,N]);l.useEffect(()=>{j()},[j]),l.useEffect(()=>()=>{y.current&&clearTimeout(y.current)},[]);const k=l.useCallback(E=>{if(!(!E||typeof E!="object"||!("id"in E))){if(!("title"in E)||!E.title){const B=r.find(T=>String(T.id)===String(E.id));B&&(o(B),c(!0));return}o(E),c(!0)}},[r]),A=l.useCallback(()=>{c(!1),o(null)},[]),P=l.useCallback((E,B)=>{console.log("Update task status:",E,B),a==null||a()},[a]),S=l.useCallback((E=null)=>{h(E),u(!0)},[]),b=l.useCallback(()=>{u(!1),h(null)},[]),C=l.useCallback(async()=>{b(),await v(!0),a==null||a()},[b,v,a]);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`h-full ${t?"block":"hidden"}`,children:e.jsx("div",{className:"h-full flex flex-col overflow-hidden",children:e.jsx(ox,{tasks:r,onTaskClick:k,showParentTasks:!0,className:"flex-1 overflow-y-auto p-4",currentProject:s,onTaskCreated:a||void 0,onShowPRDEditor:S,existingPRDs:p,onRefreshPRDs:(E=!1)=>{v(E)}})})}),i&&n&&e.jsx(ix,{task:n,isOpen:i,onClose:A,onStatusChange:P,onTaskClick:k}),d&&e.jsx(lx,{project:s,projectPath:(s==null?void 0:s.fullPath)||(s==null?void 0:s.path),onClose:b,isNewFile:!(m!=null&&m.isExisting),file:{name:(m==null?void 0:m.name)||"prd.txt",content:(m==null?void 0:m.content)||""},onSave:C}),f&&e.jsx("div",{className:"fixed bottom-4 right-4 z-50 animate-in slide-in-from-bottom-2 duration-300",children:e.jsxs("div",{className:"bg-green-600 text-white px-4 py-3 rounded-lg shadow-lg flex items-center gap-3",children:[e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),e.jsx("span",{className:"font-medium",children:f})]})})]})}function mx(){const{isRelayConnected:t,isChecking:r,sandboxActive:s,isDisconnecting:a,disconnect:n,relayCwd:o,relayMachine:i}=Fr(),[c,d]=l.useState(!1),u=l.useCallback(async()=>{await n()&&d(!1)},[n]);return rr||r?null:t?e.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5 bg-green-500/5 border-b border-green-500/15 text-sm",children:[e.jsx(wa,{className:"w-3.5 h-3.5 text-green-500 flex-shrink-0"}),e.jsx("span",{className:"text-green-400 text-xs font-medium",children:"Connected"}),i&&e.jsx("span",{className:"text-[10px] text-muted-foreground truncate max-w-[150px]",children:i}),o&&e.jsx("span",{className:"text-[10px] text-muted-foreground truncate max-w-[200px] hidden sm:inline",children:o.split(/[\\/]/).slice(-2).join("/")}),s&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-500/20 text-emerald-400 border border-emerald-500/30",children:"Isolated"}),e.jsx("div",{className:"ml-auto flex items-center gap-1",children:c?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] text-amber-400",children:"Disconnect?"}),e.jsx("button",{onClick:u,disabled:a,className:"text-[10px] px-2 py-0.5 rounded bg-red-500/20 text-red-400 hover:bg-red-500/30 border border-red-500/30 transition-colors disabled:opacity-40",children:a?"Disconnecting...":"Yes"}),e.jsx("button",{onClick:()=>d(!1),className:"text-[10px] px-2 py-0.5 rounded bg-muted text-muted-foreground hover:bg-muted/80 transition-colors",children:"No"})]}):e.jsx("button",{onClick:()=>d(!0),className:"p-1 rounded hover:bg-red-500/10 text-muted-foreground hover:text-red-400 transition-colors",title:"Disconnect relay",children:e.jsx(so,{className:"w-3.5 h-3.5"})})})]}):e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-amber-500/20 bg-amber-500/5",children:[e.jsx(ba,{className:"w-3.5 h-3.5 text-amber-400 flex-shrink-0"}),e.jsx("span",{className:"text-xs text-amber-300",children:"Machine not connected"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"—"}),e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["Go to ",e.jsx("span",{className:"text-foreground font-medium",children:"Settings > Connection"})," to connect"]})]})}function px(){const{connectionState:t,reconnectAttempts:r}=to();return t==="connected"||t==="disconnected"?null:e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-amber-500/10 border-b border-amber-500/20 text-amber-400 text-xs animate-in fade-in duration-300",children:[e.jsx("div",{className:"w-2 h-2 bg-amber-400 rounded-full animate-pulse shrink-0"}),e.jsx("span",{children:t==="connecting"?"Connecting...":e.jsxs(e.Fragment,{children:["Reconnecting to server",r>1&&e.jsxs("span",{className:"text-amber-400/60 ml-1",children:["(attempt ",r,")"]}),e.jsx("span",{className:"ml-1.5",children:"— your session is preserved"})]})})]})}function as({children:t,fallback:r,bypass:s}){const{isRelayConnected:a}=Fr();return s||rr||a?e.jsx(e.Fragment,{children:t}):e.jsxs("div",{className:"relative h-full w-full",children:[e.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-background/60 backdrop-blur-sm",children:r||e.jsxs("div",{className:"text-center space-y-2 px-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Machine not connected"}),e.jsx("p",{className:"text-xs text-muted-foreground/70",children:"Go to Settings > Connection to connect your machine"})]})}),e.jsx("div",{className:"h-full w-full opacity-30 pointer-events-none select-none","aria-hidden":!0,children:t})]})}function js({icon:t,label:r}){return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 text-muted-foreground",role:"status","aria-label":`${r} loading`,children:[e.jsx(t,{className:"w-10 h-10 opacity-40"}),e.jsxs("p",{className:"text-sm font-medium",children:[r," requires a connected machine"]}),e.jsx("p",{className:"text-xs opacity-60",children:"Connect your machine to get started"})]})}function xx(){return e.jsx(js,{icon:Ca,label:"Chat"})}function Kn(){return e.jsx(js,{icon:bt,label:"Shell"})}function Jn(){return e.jsx(js,{icon:Gi,label:"Files"})}function Yn(){return e.jsx(js,{icon:br,label:"Git"})}function gx({selectedProject:t,isMobile:r,initialWidth:s=600}){const[a,n]=l.useState(null),[o,i]=l.useState(s),[c,d]=l.useState(!1),[u,m]=l.useState(!1),h=l.useRef(null),[p,g]=l.useState(280),[f,x]=l.useState(!1),y=l.useRef(null),N=l.useCallback((P,S=null)=>{const C=P.replace(/\\/g,"/").split("/").pop()||P;n({name:C,path:P,projectName:t==null?void 0:t.name,diffInfo:S})},[t==null?void 0:t.name]),j=l.useCallback(()=>{n(null),d(!1)},[]),v=l.useCallback(()=>{d(P=>!P)},[]),k=l.useCallback(P=>{r||(x(!0),P.preventDefault())},[r]);l.useEffect(()=>{const P=b=>{var H;if(!f)return;const C=(H=y.current)==null?void 0:H.parentElement;if(!C)return;const E=C.getBoundingClientRect(),B=b.clientX-E.left,T=180,W=Math.min(500,E.width*.5);B>=T&&B<=W&&g(B)},S=()=>{x(!1)};return f&&(document.addEventListener("mousemove",P),document.addEventListener("mouseup",S),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",P),document.removeEventListener("mouseup",S),f&&(document.body.style.cursor="",document.body.style.userSelect="")}},[f]);const A=l.useCallback(P=>{r||(m(!0),P.preventDefault())},[r]);return l.useEffect(()=>{const P=b=>{var H;if(!u)return;const C=(H=h.current)==null?void 0:H.parentElement;if(!C)return;const E=C.getBoundingClientRect(),B=E.right-b.clientX,T=300,W=E.width*.8;B>=T&&B<=W&&i(B)},S=()=>{m(!1)};return u&&(document.addEventListener("mousemove",P),document.addEventListener("mouseup",S),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",P),document.removeEventListener("mouseup",S),document.body.style.cursor="",document.body.style.userSelect=""}},[u]),{editingFile:a,editorWidth:o,editorExpanded:c,resizeHandleRef:h,handleFileOpen:N,handleCloseEditor:j,handleToggleEditorExpand:v,handleResizeStart:A,fileTreeWidth:p,fileTreeResizeRef:y,handleFileTreeResizeStart:k}}function hx({isMobile:t,initialWidth:r=520}){const[s,a]=l.useState([]),[n,o]=l.useState([]),[i,c]=l.useState(null),[d,u]=l.useState(r),[m,h]=l.useState(!1),[p,g]=l.useState(!1),f=l.useRef(null),x=s.length>0||n.length>0,y=l.useCallback(S=>{a(b=>b.find(E=>E.id===S.id)?b.map(E=>E.id===S.id?S:E):[...b,S]),c(S.id)},[]),N=l.useCallback(S=>{a(b=>{const C=b.find(E=>E.id===S);return C&&o(E=>{const B=E.filter(T=>T.id!==S);return[C,...B].slice(0,20)}),b.filter(E=>E.id!==S)}),c(b=>{if(b!==S)return b;const C=s.filter(E=>E.id!==S);return C.length>0?C[C.length-1].id:null})},[s]),j=l.useCallback(S=>{const b=n.find(C=>C.id===S);b&&(o(C=>C.filter(E=>E.id!==S)),a(C=>[...C,b]),c(b.id))},[n]),v=l.useCallback(()=>{o([])},[]),k=l.useCallback(()=>{a(S=>(S.length>0&&o(b=>{const C=new Set(b.map(B=>B.id));return[...S.filter(B=>!C.has(B.id)),...b].slice(0,20)}),[])),c(null),h(!1)},[]),A=l.useCallback(()=>{h(S=>!S)},[]),P=l.useCallback(S=>{t||(g(!0),S.preventDefault())},[t]);return l.useEffect(()=>{const S=C=>{var _;if(!p)return;const E=(_=f.current)==null?void 0:_.parentElement;if(!E)return;const B=E.getBoundingClientRect(),T=B.right-C.clientX,W=320,H=B.width*.75;T>=W&&T<=H&&u(T)},b=()=>{g(!1)};return p&&(document.addEventListener("mousemove",S),document.addEventListener("mouseup",b),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",S),document.removeEventListener("mouseup",b),p&&(document.body.style.cursor="",document.body.style.userSelect="")}},[p]),{artifacts:s,recentArtifacts:n,activeArtifactId:i,setActiveArtifactId:c,panelWidth:d,panelExpanded:m,isOpen:x,resizeHandleRef:f,openArtifact:y,closeArtifact:N,reopenArtifact:j,clearHistory:v,closeAll:k,toggleExpand:A,handleResizeStart:P}}const fx=l.lazy(()=>Nt(()=>import("./FileTree-DvO1xnDE.js"),__vite__mapDeps([6,2,7,1,3,8,9,10,11,12,13,14]))),bx=l.lazy(()=>Nt(()=>import("./LoginModal-Chi4SYcr.js").then(t=>t.c),__vite__mapDeps([11,2,7,1,3,8,9,10,12,13]))),yx=l.lazy(()=>Nt(()=>import("./GitPanel-D-slVlyy.js"),__vite__mapDeps([15,2,7,1,3,8,9,10,11,12,13,14]))),vx=l.lazy(()=>Nt(()=>import("./WorkflowsPanel-DIlYAdhB.js"),__vite__mapDeps([16,2,7,1,3,8,9,10]))),kx=l.lazy(()=>Nt(()=>import("./DashboardPanel-C88HjsCh.js"),__vite__mapDeps([17,2,7,1,3,8,9,10,11,12,13,14]))),wx=l.lazy(()=>Nt(()=>import("./PreviewPanel-Dd8q-jo0.js"),__vite__mapDeps([18,2]))),jx=l.lazy(()=>Nt(()=>import("./BrowserPanel-TFKm2NDJ.js"),__vite__mapDeps([19,2,7,1,3,8,9,10])));function Nx({selectedProject:t,selectedSession:r,activeTab:s,setActiveTab:a,ws:n,sendMessage:o,latestMessage:i,isMobile:c,onMenuClick:d,isLoading:u,onInputFocusChange:m,onSessionActive:h,onSessionInactive:p,onSessionProcessing:g,onSessionNotProcessing:f,processingSessions:x,onReplaceTemporarySession:y,onNavigateToSession:N,onShowSettings:j,externalMessageUpdate:v}){var Ae,Re;const{preferences:k}=Ta(),{autoExpandTools:A,showRawParameters:P,showThinking:S,autoScrollToBottom:b,sendByCtrlEnter:C}=k,{currentProject:E,setCurrentProject:B}=fr(),{tasksEnabled:T,isTaskMasterInstalled:W}=zr(),H=T!==!1,{editingFile:_,editorWidth:M,editorExpanded:z,resizeHandleRef:K,handleFileOpen:te,handleCloseEditor:q,handleToggleEditorExpand:ie,handleResizeStart:$,fileTreeWidth:X,fileTreeResizeRef:re,handleFileTreeResizeStart:Y}=gx({selectedProject:t,isMobile:c}),{artifacts:U,recentArtifacts:O,activeArtifactId:F,setActiveArtifactId:V,panelWidth:R,panelExpanded:Z,isOpen:G,resizeHandleRef:w,openArtifact:I,closeArtifact:J,reopenArtifact:se,clearHistory:ce,closeAll:Ce,toggleExpand:fe,handleResizeStart:_e}=hx({isMobile:c}),we=lt.useCallback(Ie=>{I(Ie)},[I]);return l.useEffect(()=>{t&&t!==E&&(B==null||B(t))},[t,E,B]),l.useEffect(()=>{!H&&s==="tasks"&&a("chat")},[H,s,a]),u?e.jsx(On,{mode:"loading",isMobile:c,onMenuClick:d}):t?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx(Ip,{activeTab:s,setActiveTab:a,selectedProject:t,selectedSession:r,shouldShowTasksTab:H,isMobile:c,onMenuClick:d}),e.jsx(px,{}),e.jsx(mx,{}),e.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[e.jsxs("div",{className:`flex flex-col min-h-0 overflow-hidden ${z?"hidden":""} ${s==="files"&&_?"flex-shrink-0":"flex-1"}`,style:s==="files"&&_?{width:`${X}px`}:void 0,children:[s==="dashboard"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading dashboard..."}),children:e.jsx(kx,{selectedProject:t})})}),e.jsx("div",{className:`h-full ${s==="chat"?"block":"hidden"}`,children:e.jsx(as,{fallback:e.jsx(xx,{}),children:e.jsx(Cr,{showDetails:!0,children:e.jsx(jp,{selectedProject:t,selectedSession:r,ws:n,sendMessage:o,latestMessage:i,onFileOpen:te,onInputFocusChange:m,onSessionActive:h,onSessionInactive:p,onSessionProcessing:g,onSessionNotProcessing:f,processingSessions:x,onReplaceTemporarySession:y,onNavigateToSession:N,onShowSettings:j,autoExpandTools:A,showRawParameters:P,showThinking:S,autoScrollToBottom:b,sendByCtrlEnter:C,externalMessageUpdate:v,onShowAllTasks:T?()=>a("tasks"):null,setActiveTab:a,onArtifactOpen:we})})})}),e.jsx("div",{className:`h-full overflow-hidden ${s==="files"?"block":"hidden"}`,children:e.jsx(as,{fallback:e.jsx(Jn,{}),children:e.jsx(l.Suspense,{fallback:e.jsx(Jn,{}),children:e.jsx(fx,{selectedProject:t,onFileOpen:te,activeFilePath:(_==null?void 0:_.path)||null})})})}),e.jsx("div",{className:`h-full w-full overflow-hidden ${s==="shell"?"block":"hidden"}`,children:e.jsx(as,{fallback:e.jsx(Kn,{}),children:e.jsx(Cr,{children:e.jsx(l.Suspense,{fallback:e.jsx(Kn,{}),children:e.jsx(bx,{project:t,session:r,showHeader:!1,multiTab:!0})})})})}),e.jsx("div",{className:`h-full overflow-hidden ${s==="git"?"block":"hidden"}`,children:e.jsx(as,{fallback:e.jsx(Yn,{}),children:e.jsx(Cr,{children:e.jsx(l.Suspense,{fallback:e.jsx(Yn,{}),children:e.jsx(yx,{selectedProject:t,isMobile:c,onFileOpen:te})})})})}),s==="workflows"&&!IS_LOCAL&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(Cr,{children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading workflows..."}),children:e.jsx(vx,{selectedProject:t})})})}),H&&e.jsx(ux,{isVisible:s==="tasks"}),s==="preview"&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading preview..."}),children:e.jsx(wx,{initialHtml:(Re=(Ae=U.find(Ie=>Ie.type==="html"))==null?void 0:Ae.data)==null?void 0:Re.html})})}),s==="browser"&&!IS_LOCAL&&e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx(Cr,{children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading browser..."}),children:e.jsx(jx,{selectedProject:t})})})})]}),s==="files"&&_&&!z&&e.jsx("div",{ref:re,onMouseDown:Y,className:"w-1 flex-shrink-0 cursor-col-resize hover:bg-primary/30 active:bg-primary/50 transition-colors relative group",children:e.jsx("div",{className:"absolute inset-y-0 -left-1 -right-1"})}),e.jsx(Vp,{editingFile:_,isMobile:c,editorExpanded:z,editorWidth:M,resizeHandleRef:K,onResizeStart:$,onCloseEditor:q,onToggleEditorExpand:ie,projectPath:t.path,fillSpace:s==="files"}),G&&!_&&(c?e.jsx("div",{className:"fixed inset-0 z-40 bg-gray-900 flex flex-col",children:e.jsx(Vn,{artifacts:U,recentArtifacts:O,activeArtifactId:F,panelWidth:R,panelExpanded:Z,resizeHandleRef:w,onResizeStart:_e,onSetActive:V,onClose:J,onReopenArtifact:se,onClearHistory:ce,onCloseAll:Ce,onToggleExpand:fe,onFileOpen:te})}):e.jsx(Vn,{artifacts:U,recentArtifacts:O,activeArtifactId:F,panelWidth:R,panelExpanded:Z,resizeHandleRef:w,onResizeStart:_e,onSetActive:V,onClose:J,onReopenArtifact:se,onClearHistory:ce,onCloseAll:Ce,onToggleExpand:fe,onPinToCanvas:handlePinToCanvas,onFileOpen:te}))]})]}):e.jsx(On,{mode:"empty",isMobile:c,onMenuClick:d})}const Cx=lt.memo(Nx);function Sx({activeTab:t,setActiveTab:r,isInputFocused:s}){const{tasksEnabled:a,isTaskMasterInstalled:n}=zr(),i=[{id:"dashboard",icon:Vi,label:"Home"},{id:"chat",icon:Ca,label:"Chat"},{id:"shell",icon:bt,label:"Shell"},{id:"files",icon:mr,label:"Files"},{id:"preview",icon:ar,label:"Preview"},{id:"git",icon:br,label:"Git"},{id:"workflows",icon:tr,label:"Auto"},{id:"browser",icon:$r,label:"Browser"},...!!(a&&n)?[{id:"tasks",icon:co,label:"Tasks"}]:[]];return e.jsx("div",{className:`fixed bottom-0 left-0 right-0 z-50 px-2 pb-[max(6px,env(safe-area-inset-bottom))] transform transition-transform duration-300 ease-in-out ${s?"translate-y-full":"translate-y-0"}`,children:e.jsx("div",{className:"nav-glass mobile-nav-float rounded-2xl border border-border/30",children:e.jsx("div",{className:"flex items-center justify-around px-0.5 py-1 gap-0 overflow-x-auto scrollbar-hide",children:i.map(c=>{const d=c.icon,u=t===c.id;return e.jsxs("button",{onClick:()=>r(c.id),onTouchStart:m=>{m.preventDefault(),r(c.id)},className:`flex flex-col items-center justify-center gap-0.5 px-1.5 py-1.5 rounded-xl flex-shrink-0 min-w-[42px] relative touch-manipulation transition-all duration-200 active:scale-95 ${u?"text-primary":"text-muted-foreground hover:text-foreground"}`,"aria-label":c.label,"aria-current":u?"page":void 0,children:[u&&e.jsx("div",{className:"absolute inset-0 bg-primary/8 dark:bg-primary/12 rounded-xl"}),e.jsx(d,{className:`relative z-10 transition-all duration-200 ${u?"w-[18px] h-[18px]":"w-4 h-4"}`,strokeWidth:u?2.4:1.8}),e.jsx("span",{className:`relative z-10 text-[9px] leading-tight font-medium truncate w-full text-center transition-all duration-200 ${u?"opacity-100":"opacity-60"}`,children:c.label})]},c.id)})})})})}const Qn="upfyn-tour-complete",Sr=[{target:"chat",title:"Chat",description:"Talk to AI agents — Claude, Cursor, or Codex. Stream responses, run tools, and see every action live."},{target:"files",title:"Files",description:"Browse your project tree, open files in the built-in editor, and make quick edits."},{target:"shell",title:"Shell",description:"A full terminal — run commands, install packages, or manage processes. Supports multiple tabs."},{target:"git",title:"Git",description:"Stage, commit, push, and view diffs — all from the browser. No terminal needed."}];function Ex(){const[t,r]=l.useState(!1),[s,a]=l.useState(0),[n,o]=l.useState(null);l.useEffect(()=>{if(localStorage.getItem(Qn))return;const x=setTimeout(()=>r(!0),800);return()=>clearTimeout(x)},[]);const i=l.useCallback(()=>{if(!t)return;const x=document.querySelector(`[data-tour="${Sr[s].target}"]`);o(x?x.getBoundingClientRect():null)},[t,s]);l.useEffect(()=>(i(),window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)),[i]);const c=l.useCallback(()=>{r(!1),localStorage.setItem(Qn,"1")},[]),d=l.useCallback(()=>{s<Sr.length-1?a(s+1):c()},[s,c]),u=l.useCallback(()=>{s>0&&a(s-1)},[s]);if(l.useEffect(()=>{if(!t)return;const x=y=>{y.key==="Escape"?c():y.key==="ArrowRight"||y.key==="Enter"?d():y.key==="ArrowLeft"&&u()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[t,d,u,c]),!t||!n)return null;const m=6,h={top:n.top-m,left:n.left-m,width:n.width+m*2,height:n.height+m*2},p=h.top+h.height+12,g=Math.max(12,Math.min(h.left+h.width/2-160,window.innerWidth-332)),f=Sr[s];return e.jsxs("div",{className:"fixed inset-0 z-[9999]",role:"dialog","aria-label":"Feature tour",children:[e.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:c}),e.jsx("div",{className:"absolute rounded-lg ring-2 ring-primary/60 bg-transparent pointer-events-none",style:{...h,boxShadow:"0 0 0 9999px rgba(0,0,0,0.5)"}}),e.jsxs("div",{className:"absolute w-[320px] bg-card border border-border/60 rounded-xl shadow-2xl overflow-hidden",style:{top:p,left:g},children:[e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-sm font-bold text-foreground",children:f.title}),e.jsx("button",{onClick:c,className:"p-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors","aria-label":"Skip tour",children:e.jsx(He,{className:"w-4 h-4"})})]}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:f.description})]}),e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-t border-border/40 bg-muted/20",children:[e.jsxs("span",{className:"text-xs text-muted-foreground/60",children:[s+1," / ",Sr.length]}),e.jsxs("div",{className:"flex items-center gap-2",children:[s>0&&e.jsxs("button",{onClick:u,className:"flex items-center gap-1 px-3 py-1.5 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors rounded-lg",children:[e.jsx(va,{className:"w-3.5 h-3.5"}),"Back"]}),e.jsx("button",{onClick:d,className:"flex items-center gap-1 px-4 py-1.5 text-xs font-medium bg-primary text-primary-foreground rounded-lg hover:opacity-90 transition-opacity",children:s<Sr.length-1?e.jsxs(e.Fragment,{children:["Next",e.jsx(sr,{className:"w-3.5 h-3.5"})]}):"Done"})]})]})]})]})}function Tx(){const[t,r]=l.useState(new Set),[s,a]=l.useState(new Set),n=l.useCallback(u=>{u&&r(m=>new Set([...m,u]))},[]),o=l.useCallback(u=>{u&&r(m=>{const h=new Set(m);return h.delete(u),h})},[]),i=l.useCallback(u=>{u&&a(m=>new Set([...m,u]))},[]),c=l.useCallback(u=>{u&&a(m=>{const h=new Set(m);return h.delete(u),h})},[]),d=l.useCallback(u=>{u&&r(m=>{const h=new Set;for(const p of m)p.startsWith("new-session-")||h.add(p);return h.add(u),h})},[]);return{activeSessions:t,processingSessions:s,markSessionAsActive:n,markSessionAsInactive:o,markSessionAsProcessing:i,markSessionAsNotProcessing:c,replaceTemporarySession:d}}const mt=t=>JSON.stringify(t??null),Xn=(t,r,s)=>t.length!==r.length?!0:r.some((a,n)=>{const o=t[n];return!o||a.name!==o.name||a.displayName!==o.displayName||a.fullPath!==o.fullPath||mt(a.sessionMeta)!==mt(o.sessionMeta)||mt(a.sessions)!==mt(o.sessions)?!0:mt(a.cursorSessions)!==mt(o.cursorSessions)||mt(a.codexSessions)!==mt(o.codexSessions)}),ys=t=>[...t.sessions??[],...t.codexSessions??[],...t.cursorSessions??[]],Ax=(t,r,s,a)=>{if(!s||!a)return!0;const n=t.find(d=>d.name===s.name),o=r.find(d=>d.name===s.name);if(!n||!o)return!1;const i=ys(n).find(d=>d.id===a.id),c=ys(o).find(d=>d.id===a.id);return!i||!c?!1:i.id===c.id&&i.title===c.title&&i.created_at===c.created_at&&i.updated_at===c.updated_at};function Ix({sessionId:t,navigate:r,latestMessage:s,isMobile:a,activeSessions:n}){const[o,i]=l.useState([]),[c,d]=l.useState(null),[u,m]=l.useState(null),[h,p]=l.useState("chat"),[g,f]=l.useState(!1),[x,y]=l.useState(!0),[N,j]=l.useState(null),[v,k]=l.useState(!1),[A,P]=l.useState(!1),[S,b]=l.useState("agents"),[C,E]=l.useState(0),{relayCwd:B,isRelayConnected:T}=Fr(),W=l.useRef(null),H=l.useRef(new Set),_=l.useRef(null),M=l.useCallback(async()=>{try{y(!0);const U=await Ue.projects();if(!U.ok)return;const O=await U.json();if(!Array.isArray(O))return;i(F=>F.length===0||Xn(F,O,!0)?O:F)}catch(U){console.error("Error fetching projects:",U)}finally{y(!1)}},[]),z=l.useCallback((U="tools")=>{b(U),P(!0)},[]);l.useEffect(()=>{M()},[M]);const K=l.useRef(0);l.useEffect(()=>{if(x||o.length>0||!T||!B){K.current=0;return}if(K.current>=3)return;const U=setTimeout(()=>{K.current++,M()},1500);return()=>clearTimeout(U)},[x,o.length,T,B,M]),l.useEffect(()=>{if(!(x||c||t||o.length===0)){if(T&&B){const U=R=>R.replace(/\\/g,"/").replace(/\/+$/,"").toLowerCase(),O=U(B),F=O.split("/").pop()||"",V=o.find(R=>U(R.fullPath||"")===O||U(R.name||"")===F);if(V){d(V);return}}o.length===1&&d(o[0])}},[x,o,c,t,T,B]),l.useEffect(()=>{if(!_.current||o.length===0)return;const U=_.current,O=Z=>Z.replace(/\\/g,"/").replace(/\/+$/,"").toLowerCase(),F=O(U),V=F.split("/").pop()||"",R=o.find(Z=>O(Z.fullPath||"")===F||O(Z.name||"")===V);R&&(_.current=null,d(R),m(null),p("chat"),r("/"))},[o,r]),l.useEffect(()=>{if(!s)return;if((s.type==="relay-init"||s.type==="relay-status")&&s.cwd&&s.connected!==!1){_.current=s.cwd,M();return}if(s.type==="shell-project-selected"&&s.projectPath){_.current=s.projectPath,M();return}if(s.type==="loading_progress"){W.current&&(clearTimeout(W.current),W.current=null),j(s),s.phase==="complete"&&(W.current=setTimeout(()=>{j(null),W.current=null},500));return}if(s.type!=="projects_updated")return;const U=s;if(U.changedFile&&u&&c){const G=U.changedFile.replace(/\\/g,"/").split("/");G.length>=2&&G[G.length-1].replace(".jsonl","")===u.id&&(n.has(u.id)||E(se=>se+1))}const O=u&&n.has(u.id)||n.size>0&&Array.from(n).some(Z=>Z.startsWith("new-session-")),F=U.projects;if(!Array.isArray(F)||O&&!Ax(o,F,c,u)||(i(F),!c))return;const V=F.find(Z=>Z.name===c.name);if(!V||(mt(V)!==mt(c)&&d(V),!u))return;ys(V).find(Z=>Z.id===u.id)||m(null)},[s,c,u,n,o]),l.useEffect(()=>()=>{W.current&&(clearTimeout(W.current),W.current=null)},[]),l.useEffect(()=>{var O,F,V;if(!t||o.length===0)return;const U=!u||u.id!==t;for(const R of o){const Z=(O=R.sessions)==null?void 0:O.find(I=>I.id===t);if(Z){const I=(c==null?void 0:c.name)!==R.name,J=(u==null?void 0:u.id)!==t||u.__provider!=="claude";I&&d(R),J&&m({...Z,__provider:"claude"}),U&&p("chat");return}const G=(F=R.cursorSessions)==null?void 0:F.find(I=>I.id===t);if(G){const I=(c==null?void 0:c.name)!==R.name,J=(u==null?void 0:u.id)!==t||u.__provider!=="cursor";I&&d(R),J&&m({...G,__provider:"cursor"}),U&&p("chat");return}const w=(V=R.codexSessions)==null?void 0:V.find(I=>I.id===t);if(w){const I=(c==null?void 0:c.name)!==R.name,J=(u==null?void 0:u.id)!==t||u.__provider!=="codex";I&&d(R),J&&m({...w,__provider:"codex"}),U&&p("chat");return}}},[t,o,c==null?void 0:c.name,u==null?void 0:u.id,u==null?void 0:u.__provider]);const te=l.useCallback(U=>{d(U),m(null),r("/"),a&&f(!1)},[a,r]),q=l.useCallback(U=>{if(m(U),h!=="git"&&h!=="preview"&&p("chat"),(localStorage.getItem("selected-provider")||"claude")==="cursor"&&sessionStorage.setItem("cursorSessionId",U.id),a){const F=U.__projectName,V=c==null?void 0:c.name;F!==V&&f(!1)}r(`/session/${U.id}`)},[h,a,r,c==null?void 0:c.name]),ie=l.useCallback(U=>{d(U),m(null),p("chat"),r("/"),a&&f(!1)},[a,r]),$=l.useCallback(U=>{H.current.add(U),setTimeout(()=>H.current.delete(U),3e4),(u==null?void 0:u.id)===U&&(m(null),r("/")),i(O=>O.map(F=>{var V,R;return{...F,sessions:((V=F.sessions)==null?void 0:V.filter(Z=>Z.id!==U))??[],sessionMeta:{...F.sessionMeta,total:Math.max(0,(((R=F.sessionMeta)==null?void 0:R.total)??0)-1)}}}))},[r,u==null?void 0:u.id]),X=l.useCallback(async()=>{try{const U=await Ue.projects();if(!U.ok)return;let O=await U.json();if(!Array.isArray(O)||(H.current.size>0&&(O=O.map(R=>{var Z;return{...R,sessions:((Z=R.sessions)==null?void 0:Z.filter(G=>!H.current.has(G.id)))??[]}})),i(R=>Xn(R,O,!0)?O:R),!c))return;const F=O.find(R=>R.name===c.name);if(!F||(mt(F)!==mt(c)&&d(F),!u))return;const V=ys(F).find(R=>R.id===u.id);if(V){const R=V.__provider||!u.__provider?V:{...V,__provider:u.__provider};mt(R)!==mt(u)&&m(R)}}catch(U){console.error("Error refreshing sidebar:",U)}},[c,u]),re=l.useCallback(U=>{(c==null?void 0:c.name)===U&&(d(null),m(null),r("/")),i(O=>O.filter(F=>F.name!==U))},[r,c==null?void 0:c.name]),Y=l.useMemo(()=>({projects:o,selectedProject:c,selectedSession:u,onProjectSelect:te,onSessionSelect:q,onNewSession:ie,onSessionDelete:$,onProjectDelete:re,isLoading:x,loadingProgress:N,onRefresh:X,onShowSettings:()=>P(!0),showSettings:A,settingsInitialTab:S,onCloseSettings:()=>P(!1),isMobile:a}),[ie,re,te,$,q,X,x,a,N,o,S,c,u,A]);return{projects:o,selectedProject:c,selectedSession:u,activeTab:h,sidebarOpen:g,isLoadingProjects:x,loadingProgress:N,isInputFocused:v,showSettings:A,settingsInitialTab:S,externalMessageUpdate:C,setActiveTab:p,setSidebarOpen:f,setIsInputFocused:k,setShowSettings:P,openSettings:z,fetchProjects:M,sidebarSharedProps:Y,handleProjectSelect:te,handleSessionSelect:q,handleNewSession:ie,handleSessionDelete:$,handleProjectDelete:re,handleSidebarRefresh:X}}const Zn="upfyn-pwa-install-dismissed",Mx=10080*60*1e3;function Dx(){const[t,r]=l.useState(null),[s,a]=l.useState(!1),[n,o]=l.useState(()=>{const u=localStorage.getItem(Zn);if(!u)return!1;const m=parseInt(u,10);return Date.now()-m<Mx});l.useEffect(()=>{if(window.matchMedia("(display-mode: standalone)").matches||navigator.standalone===!0){a(!0);return}const m=p=>{p.preventDefault(),r(p)};window.addEventListener("beforeinstallprompt",m);const h=()=>a(!0);return window.addEventListener("appinstalled",h),()=>{window.removeEventListener("beforeinstallprompt",m),window.removeEventListener("appinstalled",h)}},[]);const i=l.useCallback(async()=>{if(!t)return;await t.prompt();const{outcome:u}=await t.userChoice;u==="accepted"&&a(!0),r(null)},[t]),c=l.useCallback(()=>{localStorage.setItem(Zn,String(Date.now())),o(!0)},[]);return{canPrompt:!!t&&!s&&!n,isInstalled:s,promptInstall:i,dismiss:c}}function Lx(){const t=vi(),{sessionId:r}=ki(),{t:s}=Be("common"),{isMobile:a}=Ea({trackPWA:!1}),{ws:n,sendMessage:o,latestMessage:i}=to(),{canPrompt:c,promptInstall:d,dismiss:u}=Dx(),{activeSessions:m,processingSessions:h,markSessionAsActive:p,markSessionAsInactive:g,markSessionAsProcessing:f,markSessionAsNotProcessing:x,replaceTemporarySession:y}=Tx(),{selectedProject:N,selectedSession:j,activeTab:v,sidebarOpen:k,isLoadingProjects:A,isInputFocused:P,externalMessageUpdate:S,setActiveTab:b,setSidebarOpen:C,setIsInputFocused:E,setShowSettings:B,openSettings:T,fetchProjects:W,sidebarSharedProps:H}=Ix({sessionId:r,navigate:t,latestMessage:i,isMobile:a,activeSessions:m});return l.useEffect(()=>(window.refreshProjects=W,()=>{window.refreshProjects===W&&delete window.refreshProjects}),[W]),l.useEffect(()=>(window.openSettings=T,()=>{window.openSettings===T&&delete window.openSettings}),[T]),e.jsxs("div",{className:"fixed inset-0 flex bg-background",children:[a?e.jsxs("div",{className:`fixed inset-0 z-50 flex transition-all duration-150 ease-out ${k?"opacity-100 visible":"opacity-0 invisible"}`,children:[e.jsx("button",{className:"fixed inset-0 bg-background/60 backdrop-blur-sm transition-opacity duration-150 ease-out",onClick:_=>{_.stopPropagation(),C(!1)},onTouchStart:_=>{_.preventDefault(),_.stopPropagation(),C(!1)},"aria-label":s("versionUpdate.ariaLabels.closeSidebar")}),e.jsx("div",{className:`relative w-[85vw] max-w-sm sm:w-80 h-full bg-card border-r border-border/40 transform transition-transform duration-150 ease-out ${k?"translate-x-0":"-translate-x-full"}`,onClick:_=>_.stopPropagation(),onTouchStart:_=>_.stopPropagation(),children:e.jsx(on,{...H})})]}):e.jsx("div",{className:"h-full flex-shrink-0 border-r border-border/50",children:e.jsx(on,{...H})}),e.jsxs("div",{className:`flex-1 flex flex-col min-w-0 ${a?"pb-mobile-nav":""}`,children:[a&&c&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-primary/10 border-b border-primary/20 flex-shrink-0",children:[e.jsx("span",{className:"text-xs text-foreground flex-1",children:"Install Upfyn for a better experience"}),e.jsx("button",{onClick:d,className:"text-xs px-3 py-1 rounded-md bg-primary text-primary-foreground font-medium hover:bg-primary/90 transition-colors",children:"Install"}),e.jsx("button",{onClick:u,className:"p-1 text-muted-foreground hover:text-foreground transition-colors","aria-label":"Dismiss",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx(Cx,{selectedProject:N,selectedSession:j,activeTab:v,setActiveTab:b,ws:n,sendMessage:o,latestMessage:i,isMobile:a,onMenuClick:()=>C(!0),isLoading:A,onInputFocusChange:E,onSessionActive:p,onSessionInactive:g,onSessionProcessing:f,onSessionNotProcessing:x,processingSessions:h,onReplaceTemporarySession:y,onNavigateToSession:_=>t(`/session/${_}`),onShowSettings:()=>B(!0),externalMessageUpdate:S})]}),a&&e.jsx(Sx,{activeTab:v,setActiveTab:b,isInputFocused:P}),!a&&e.jsx(Ex,{})]})}const Bx=Object.freeze(Object.defineProperty({__proto__:null,default:Lx},Symbol.toStringTag,{value:"Module"}));export{Bx as A,xe as B,Ze as I,lu as M,zo as S,Ea as a,ke as c,Dx as u};