sparkecoder 0.1.137 → 0.1.139

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 (121) hide show
  1. package/dist/agent/index.d.ts +1 -1
  2. package/dist/agent/index.js +111 -8
  3. package/dist/agent/index.js.map +1 -1
  4. package/dist/cli.js +112 -9
  5. package/dist/cli.js.map +1 -1
  6. package/dist/{index-BM99kjgq.d.ts → index-BAsQWqZj.d.ts} +7 -0
  7. package/dist/index.d.ts +2 -2
  8. package/dist/index.js +112 -9
  9. package/dist/index.js.map +1 -1
  10. package/dist/server/index.js +112 -9
  11. package/dist/server/index.js.map +1 -1
  12. package/package.json +1 -1
  13. package/web/.next/BUILD_ID +1 -1
  14. package/web/.next/standalone/web/.next/BUILD_ID +1 -1
  15. package/web/.next/standalone/web/.next/build-manifest.json +2 -2
  16. package/web/.next/standalone/web/.next/prerender-manifest.json +3 -3
  17. package/web/.next/standalone/web/.next/server/app/(main)/session/[id]/page_client-reference-manifest.js +1 -1
  18. package/web/.next/standalone/web/.next/server/app/_global-error.html +2 -2
  19. package/web/.next/standalone/web/.next/server/app/_global-error.rsc +1 -1
  20. package/web/.next/standalone/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  21. package/web/.next/standalone/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  22. package/web/.next/standalone/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  23. package/web/.next/standalone/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  24. package/web/.next/standalone/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  25. package/web/.next/standalone/web/.next/server/app/_not-found.html +1 -1
  26. package/web/.next/standalone/web/.next/server/app/_not-found.rsc +1 -1
  27. package/web/.next/standalone/web/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  28. package/web/.next/standalone/web/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  29. package/web/.next/standalone/web/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  30. package/web/.next/standalone/web/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  31. package/web/.next/standalone/web/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  32. package/web/.next/standalone/web/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  33. package/web/.next/standalone/web/.next/server/app/agents.html +1 -1
  34. package/web/.next/standalone/web/.next/server/app/agents.rsc +1 -1
  35. package/web/.next/standalone/web/.next/server/app/agents.segments/!KG1haW4p/agents/__PAGE__.segment.rsc +1 -1
  36. package/web/.next/standalone/web/.next/server/app/agents.segments/!KG1haW4p/agents.segment.rsc +1 -1
  37. package/web/.next/standalone/web/.next/server/app/agents.segments/!KG1haW4p.segment.rsc +1 -1
  38. package/web/.next/standalone/web/.next/server/app/agents.segments/_full.segment.rsc +1 -1
  39. package/web/.next/standalone/web/.next/server/app/agents.segments/_head.segment.rsc +1 -1
  40. package/web/.next/standalone/web/.next/server/app/agents.segments/_index.segment.rsc +1 -1
  41. package/web/.next/standalone/web/.next/server/app/agents.segments/_tree.segment.rsc +1 -1
  42. package/web/.next/standalone/web/.next/server/app/docs/installation.html +2 -2
  43. package/web/.next/standalone/web/.next/server/app/docs/installation.rsc +1 -1
  44. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_full.segment.rsc +1 -1
  45. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_head.segment.rsc +1 -1
  46. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_index.segment.rsc +1 -1
  47. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/_tree.segment.rsc +1 -1
  48. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/docs/installation/__PAGE__.segment.rsc +1 -1
  49. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/docs/installation.segment.rsc +1 -1
  50. package/web/.next/standalone/web/.next/server/app/docs/installation.segments/docs.segment.rsc +1 -1
  51. package/web/.next/standalone/web/.next/server/app/docs/skills.html +2 -2
  52. package/web/.next/standalone/web/.next/server/app/docs/skills.rsc +1 -1
  53. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_full.segment.rsc +1 -1
  54. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_head.segment.rsc +1 -1
  55. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_index.segment.rsc +1 -1
  56. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/_tree.segment.rsc +1 -1
  57. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/docs/skills/__PAGE__.segment.rsc +1 -1
  58. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/docs/skills.segment.rsc +1 -1
  59. package/web/.next/standalone/web/.next/server/app/docs/skills.segments/docs.segment.rsc +1 -1
  60. package/web/.next/standalone/web/.next/server/app/docs/tools.html +2 -2
  61. package/web/.next/standalone/web/.next/server/app/docs/tools.rsc +1 -1
  62. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_full.segment.rsc +1 -1
  63. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_head.segment.rsc +1 -1
  64. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_index.segment.rsc +1 -1
  65. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/_tree.segment.rsc +1 -1
  66. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/docs/tools/__PAGE__.segment.rsc +1 -1
  67. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/docs/tools.segment.rsc +1 -1
  68. package/web/.next/standalone/web/.next/server/app/docs/tools.segments/docs.segment.rsc +1 -1
  69. package/web/.next/standalone/web/.next/server/app/docs.html +2 -2
  70. package/web/.next/standalone/web/.next/server/app/docs.rsc +1 -1
  71. package/web/.next/standalone/web/.next/server/app/docs.segments/_full.segment.rsc +1 -1
  72. package/web/.next/standalone/web/.next/server/app/docs.segments/_head.segment.rsc +1 -1
  73. package/web/.next/standalone/web/.next/server/app/docs.segments/_index.segment.rsc +1 -1
  74. package/web/.next/standalone/web/.next/server/app/docs.segments/_tree.segment.rsc +1 -1
  75. package/web/.next/standalone/web/.next/server/app/docs.segments/docs/__PAGE__.segment.rsc +1 -1
  76. package/web/.next/standalone/web/.next/server/app/docs.segments/docs.segment.rsc +1 -1
  77. package/web/.next/standalone/web/.next/server/app/index.html +1 -1
  78. package/web/.next/standalone/web/.next/server/app/index.rsc +1 -1
  79. package/web/.next/standalone/web/.next/server/app/index.segments/!KG1haW4p/__PAGE__.segment.rsc +1 -1
  80. package/web/.next/standalone/web/.next/server/app/index.segments/!KG1haW4p.segment.rsc +1 -1
  81. package/web/.next/standalone/web/.next/server/app/index.segments/_full.segment.rsc +1 -1
  82. package/web/.next/standalone/web/.next/server/app/index.segments/_head.segment.rsc +1 -1
  83. package/web/.next/standalone/web/.next/server/app/index.segments/_index.segment.rsc +1 -1
  84. package/web/.next/standalone/web/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  85. package/web/.next/standalone/web/.next/server/app/settings.html +1 -1
  86. package/web/.next/standalone/web/.next/server/app/settings.rsc +1 -1
  87. package/web/.next/standalone/web/.next/server/app/settings.segments/!KG1haW4p/settings/__PAGE__.segment.rsc +1 -1
  88. package/web/.next/standalone/web/.next/server/app/settings.segments/!KG1haW4p/settings.segment.rsc +1 -1
  89. package/web/.next/standalone/web/.next/server/app/settings.segments/!KG1haW4p.segment.rsc +1 -1
  90. package/web/.next/standalone/web/.next/server/app/settings.segments/_full.segment.rsc +1 -1
  91. package/web/.next/standalone/web/.next/server/app/settings.segments/_head.segment.rsc +1 -1
  92. package/web/.next/standalone/web/.next/server/app/settings.segments/_index.segment.rsc +1 -1
  93. package/web/.next/standalone/web/.next/server/app/settings.segments/_tree.segment.rsc +1 -1
  94. package/web/.next/standalone/web/.next/server/chunks/[root-of-the-server]__5b38d1a5._.js +1 -1
  95. package/web/.next/standalone/web/.next/server/chunks/[root-of-the-server]__78517719._.js +1 -1
  96. package/web/.next/standalone/web/.next/server/chunks/[root-of-the-server]__9d50fe63._.js +1 -1
  97. package/web/.next/standalone/web/.next/server/chunks/[root-of-the-server]__ce44139a._.js +1 -1
  98. package/web/.next/standalone/web/.next/server/chunks/ssr/[root-of-the-server]__e5911ea8._.js +1 -1
  99. package/web/.next/standalone/web/.next/server/pages/404.html +1 -1
  100. package/web/.next/standalone/web/.next/server/pages/500.html +2 -2
  101. package/web/.next/standalone/web/.next/server/server-reference-manifest.js +1 -1
  102. package/web/.next/standalone/web/.next/server/server-reference-manifest.json +1 -1
  103. package/web/.next/{static/chunks/3f50fe2a802aa800.js → standalone/web/.next/static/chunks/b0cae7e255cae74d.js} +1 -1
  104. package/web/.next/standalone/web/.next/static/{chunks/3f50fe2a802aa800.js → static/chunks/b0cae7e255cae74d.js} +1 -1
  105. package/web/.next/standalone/web/runtime-config.json +5 -5
  106. package/web/.next/standalone/web/src/app/api/config/route.ts +3 -3
  107. package/web/.next/standalone/web/src/app/api/diag/route.ts +5 -2
  108. package/web/.next/standalone/web/src/app/api/health/route.ts +2 -2
  109. package/web/.next/standalone/web/src/app/sfapi/[...path]/route.ts +2 -2
  110. package/web/.next/standalone/web/src/components/chat-interface.tsx +19 -2
  111. package/web/.next/standalone/web/src/lib/local-api.ts +49 -0
  112. package/web/.next/{standalone/web/.next/static/static/chunks/3f50fe2a802aa800.js → static/chunks/b0cae7e255cae74d.js} +1 -1
  113. /package/web/.next/standalone/web/.next/static/{static/wvsSqSLuE0FvQYeAvnmPm → rY6TfiRfMLnxUYYyNit1Q}/_buildManifest.js +0 -0
  114. /package/web/.next/standalone/web/.next/static/{static/wvsSqSLuE0FvQYeAvnmPm → rY6TfiRfMLnxUYYyNit1Q}/_clientMiddlewareManifest.json +0 -0
  115. /package/web/.next/standalone/web/.next/static/{static/wvsSqSLuE0FvQYeAvnmPm → rY6TfiRfMLnxUYYyNit1Q}/_ssgManifest.js +0 -0
  116. /package/web/.next/standalone/web/.next/static/{wvsSqSLuE0FvQYeAvnmPm → static/rY6TfiRfMLnxUYYyNit1Q}/_buildManifest.js +0 -0
  117. /package/web/.next/standalone/web/.next/static/{wvsSqSLuE0FvQYeAvnmPm → static/rY6TfiRfMLnxUYYyNit1Q}/_clientMiddlewareManifest.json +0 -0
  118. /package/web/.next/standalone/web/.next/static/{wvsSqSLuE0FvQYeAvnmPm → static/rY6TfiRfMLnxUYYyNit1Q}/_ssgManifest.js +0 -0
  119. /package/web/.next/static/{wvsSqSLuE0FvQYeAvnmPm → rY6TfiRfMLnxUYYyNit1Q}/_buildManifest.js +0 -0
  120. /package/web/.next/static/{wvsSqSLuE0FvQYeAvnmPm → rY6TfiRfMLnxUYYyNit1Q}/_clientMiddlewareManifest.json +0 -0
  121. /package/web/.next/static/{wvsSqSLuE0FvQYeAvnmPm → rY6TfiRfMLnxUYYyNit1Q}/_ssgManifest.js +0 -0
@@ -1,2 +1,2 @@
1
- <!DOCTYPE html><!--wvsSqSLuE0FvQYeAvnmPm--><html id="__next_error__"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/651e187cc15d66de.js"/><script src="/_next/static/chunks/735a2408c315b2f0.js" async=""></script><script src="/_next/static/chunks/186e0c1b3ff43c9c.js" async=""></script><script src="/_next/static/chunks/a14243261b055626.js" async=""></script><script src="/_next/static/chunks/862ced58ce21a270.js" async=""></script><script src="/_next/static/chunks/turbopack-2c0905c7bbebae3f.js" async=""></script><script src="/_next/static/chunks/9b5512fb633ef95d.js" async=""></script><script src="/_next/static/chunks/0f1cf11540868e42.js" async=""></script><meta name="next-size-adjust" content=""/><title>500: Internal Server Error.</title><link rel="icon" href="/favicon.ico?favicon.e3cbed1b.ico" sizes="256x256" type="image/x-icon"/><script src="/_next/static/chunks/a6dad97d9634a72d.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}
2
- @media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">500</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">Internal Server Error.</h2></div></div></div><!--$--><!--/$--><script src="/_next/static/chunks/651e187cc15d66de.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[488287,[\"/_next/static/chunks/9b5512fb633ef95d.js\",\"/_next/static/chunks/0f1cf11540868e42.js\"],\"default\"]\n3:I[174895,[\"/_next/static/chunks/9b5512fb633ef95d.js\",\"/_next/static/chunks/0f1cf11540868e42.js\"],\"default\"]\n4:I[151858,[\"/_next/static/chunks/9b5512fb633ef95d.js\",\"/_next/static/chunks/0f1cf11540868e42.js\"],\"OutletBoundary\"]\n5:\"$Sreact.suspense\"\n7:I[151858,[\"/_next/static/chunks/9b5512fb633ef95d.js\",\"/_next/static/chunks/0f1cf11540868e42.js\"],\"ViewportBoundary\"]\n9:I[151858,[\"/_next/static/chunks/9b5512fb633ef95d.js\",\"/_next/static/chunks/0f1cf11540868e42.js\"],\"MetadataBoundary\"]\nb:I[552576,[\"/_next/static/chunks/9b5512fb633ef95d.js\",\"/_next/static/chunks/0f1cf11540868e42.js\"],\"default\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"b\":\"wvsSqSLuE0FvQYeAvnmPm\",\"c\":[\"\",\"_global-error\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"__PAGE__\",{}]}],[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[\"$\",\"html\",null,{\"id\":\"__next_error__\",\"children\":[[\"$\",\"head\",null,{\"children\":[\"$\",\"title\",null,{\"children\":\"500: Internal Server Error.\"}]}],[\"$\",\"body\",null,{\"children\":[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"style\":{\"lineHeight\":\"48px\"},\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}\\n@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"paddingRight\":23,\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\"},\"children\":\"500\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"28px\"},\"children\":\"Internal Server Error.\"}]}]]}]}]}]]}],null,[\"$\",\"$L4\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@6\"}]}]]}],{},null,false,false]},null,false,false],[\"$\",\"$1\",\"h\",{\"children\":[null,[\"$\",\"$L7\",null,{\"children\":\"$L8\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$L9\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.Metadata\",\"children\":\"$La\"}]}]}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$b\",\"$undefined\"],\"S\":true}\n"])</script><script>self.__next_f.push([1,"8:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])</script><script>self.__next_f.push([1,"c:I[349310,[\"/_next/static/chunks/9b5512fb633ef95d.js\",\"/_next/static/chunks/0f1cf11540868e42.js\"],\"IconMark\"]\n6:null\na:[[\"$\",\"link\",\"0\",{\"rel\":\"icon\",\"href\":\"/favicon.ico?favicon.e3cbed1b.ico\",\"sizes\":\"256x256\",\"type\":\"image/x-icon\"}],[\"$\",\"$Lc\",\"1\",{}]]\n"])</script></body></html>
1
+ <!DOCTYPE html><!--rY6TfiRfMLnxUYYyNit1Q--><html id="__next_error__"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/651e187cc15d66de.js"/><script src="/_next/static/chunks/735a2408c315b2f0.js" async=""></script><script src="/_next/static/chunks/186e0c1b3ff43c9c.js" async=""></script><script src="/_next/static/chunks/a14243261b055626.js" async=""></script><script src="/_next/static/chunks/862ced58ce21a270.js" async=""></script><script src="/_next/static/chunks/turbopack-2c0905c7bbebae3f.js" async=""></script><script src="/_next/static/chunks/9b5512fb633ef95d.js" async=""></script><script src="/_next/static/chunks/0f1cf11540868e42.js" async=""></script><meta name="next-size-adjust" content=""/><title>500: Internal Server Error.</title><link rel="icon" href="/favicon.ico?favicon.e3cbed1b.ico" sizes="256x256" type="image/x-icon"/><script src="/_next/static/chunks/a6dad97d9634a72d.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}
2
+ @media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">500</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">Internal Server Error.</h2></div></div></div><!--$--><!--/$--><script src="/_next/static/chunks/651e187cc15d66de.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[488287,[\"/_next/static/chunks/9b5512fb633ef95d.js\",\"/_next/static/chunks/0f1cf11540868e42.js\"],\"default\"]\n3:I[174895,[\"/_next/static/chunks/9b5512fb633ef95d.js\",\"/_next/static/chunks/0f1cf11540868e42.js\"],\"default\"]\n4:I[151858,[\"/_next/static/chunks/9b5512fb633ef95d.js\",\"/_next/static/chunks/0f1cf11540868e42.js\"],\"OutletBoundary\"]\n5:\"$Sreact.suspense\"\n7:I[151858,[\"/_next/static/chunks/9b5512fb633ef95d.js\",\"/_next/static/chunks/0f1cf11540868e42.js\"],\"ViewportBoundary\"]\n9:I[151858,[\"/_next/static/chunks/9b5512fb633ef95d.js\",\"/_next/static/chunks/0f1cf11540868e42.js\"],\"MetadataBoundary\"]\nb:I[552576,[\"/_next/static/chunks/9b5512fb633ef95d.js\",\"/_next/static/chunks/0f1cf11540868e42.js\"],\"default\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"b\":\"rY6TfiRfMLnxUYYyNit1Q\",\"c\":[\"\",\"_global-error\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"__PAGE__\",{}]}],[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[\"$\",\"html\",null,{\"id\":\"__next_error__\",\"children\":[[\"$\",\"head\",null,{\"children\":[\"$\",\"title\",null,{\"children\":\"500: Internal Server Error.\"}]}],[\"$\",\"body\",null,{\"children\":[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"style\":{\"lineHeight\":\"48px\"},\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}\\n@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"paddingRight\":23,\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\"},\"children\":\"500\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"28px\"},\"children\":\"Internal Server Error.\"}]}]]}]}]}]]}],null,[\"$\",\"$L4\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@6\"}]}]]}],{},null,false,false]},null,false,false],[\"$\",\"$1\",\"h\",{\"children\":[null,[\"$\",\"$L7\",null,{\"children\":\"$L8\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$L9\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.Metadata\",\"children\":\"$La\"}]}]}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$b\",\"$undefined\"],\"S\":true}\n"])</script><script>self.__next_f.push([1,"8:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])</script><script>self.__next_f.push([1,"c:I[349310,[\"/_next/static/chunks/9b5512fb633ef95d.js\",\"/_next/static/chunks/0f1cf11540868e42.js\"],\"IconMark\"]\n6:null\na:[[\"$\",\"link\",\"0\",{\"rel\":\"icon\",\"href\":\"/favicon.ico?favicon.e3cbed1b.ico\",\"sizes\":\"256x256\",\"type\":\"image/x-icon\"}],[\"$\",\"$Lc\",\"1\",{}]]\n"])</script></body></html>
@@ -1 +1 @@
1
- self.__RSC_SERVER_MANIFEST="{\n \"node\": {},\n \"edge\": {},\n \"encryptionKey\": \"vq7ySJqUf2gM0F5hUBKLiieNHH9RvVDc96El+AuZgbo=\"\n}"
1
+ self.__RSC_SERVER_MANIFEST="{\n \"node\": {},\n \"edge\": {},\n \"encryptionKey\": \"lJrYgD91iH2JxyJvx/uu9Df6XzPSmVUagOcLEqCz5bA=\"\n}"
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "node": {},
3
3
  "edge": {},
4
- "encryptionKey": "vq7ySJqUf2gM0F5hUBKLiieNHH9RvVDc96El+AuZgbo="
4
+ "encryptionKey": "lJrYgD91iH2JxyJvx/uu9Df6XzPSmVUagOcLEqCz5bA="
5
5
  }
@@ -10,4 +10,4 @@ ${ez.updateCommand}`;ti(e),eF(!0)}catch(e){console.error("Failed to start update
10
10
  ${n.trim()}
11
11
  </sparkecoder-user-selected-elements>`;i=`${e}
12
12
 
13
- ${i}`}let a=i,o=r?.map(e=>({type:e.type,data:e.data,mediaType:e.mediaType,filename:e.filename})),l={id:`user-${Date.now()}`,type:"user-message",content:e||(s?"Selected elements attached":""),attachments:o};c(e=>[...e,l]),x(!0),G(!1),eb.current=!0,X(""),J(""),Q(!1),et([]),eh.current="",em.current="",ep.current=[],ex.current=(0,xt.runAgent)(t.id,a||"Please analyze the attached files.",tn,{onStreamId:e=>H(e),attachments:r})},ti=async(e,t)=>{let r=!!(p&&p.trim());if(e.trim()||t&&0!==t.length||r){if(g){let r;return void(r={id:`q-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,text:e,attachments:t,selectedElements:p},w(e=>[...e,r]),d(""),f(null))}d(""),f(null),await ts(e,t,p)}},ta=async e=>{let t=!!e.text?.trim(),r=!!e.files?.length,n=!!(p&&p.trim());if(!t&&!r&&!n)return;let s=[];if(r&&e.files.length>0){for(let t of e.files)if(t.url)try{let e=await fetch(t.url),r=await e.blob(),n=await new Promise(e=>{let t=new FileReader;t.onloadend=()=>e(t.result),t.readAsDataURL(r)}),i=t.mediaType||r.type||"application/octet-stream",a=i.startsWith("image/");s.push({type:a?"image":"file",data:n,mediaType:i,filename:t.filename})}catch(e){console.error("Failed to process attachment:",e)}}ti(e.text||"",s.length>0?s:void 0)},to=async()=>{try{await (0,xt.abortStream)(t.id)}catch(e){console.error("Failed to abort stream:",e)}if(ex.current&&(ex.current(),ex.current=null),em.current.trim()){let e={id:`reasoning-${Date.now()}`,type:"reasoning",content:em.current};c(t=>[...t,e])}if(eh.current.trim()){let e={id:`text-${Date.now()}`,type:"assistant-text",content:eh.current+" [stopped]"};c(t=>[...t,e])}X(""),J(""),Q(!1),et([]),H(null),eh.current="",em.current="",ep.current=[],ev.current=!1,x(!1),G(!1)},tl=(0,b.useRef)(ts);tl.current=ts;let tc=e=>{w(t=>t.map(t=>t.id===e?{...t,text:E}:t)),T(null),P("")},tu=async e=>{let t=y.find(t=>t.id===e);t&&(w(t=>t.filter(t=>t.id!==e)),g?(await to(),setTimeout(()=>{tl.current(t.text,t.attachments,t.selectedElements)},500)):tl.current(t.text,t.attachments,t.selectedElements))},td=async e=>{en(t=>t.filter(t=>t.id!==e.id));try{await (0,xt.approveExecution)(t.id,e.toolCallId)}catch(e){console.error("Failed to approve:",e)}},th=async e=>{en(t=>t.filter(t=>t.id!==e.id));try{await (0,xt.rejectExecution)(t.id,e.toolCallId,"User rejected")}catch(e){console.error("Failed to reject:",e)}},tm=async e=>{en(t=>t.filter(t=>t.id!==e.id));try{await (0,xt.approveExecution)(t.id,e.toolCallId);let r=await (0,xt.updateToolApproval)(t.id,e.toolName,!1,eE);eP(r.config||{})}catch(e){console.error("Failed to approve and disable:",e)}},tp=async(e,r)=>{try{let n=await (0,xt.updateToolApproval)(t.id,e,!r,eE);eP(n.config||{})}catch(e){console.error("Failed to update tool approval:",e)}},tf=e=>({ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",c:"c",cpp:"cpp",h:"c",hpp:"cpp",cs:"csharp",php:"php",swift:"swift",kt:"kotlin",scala:"scala",sh:"bash",bash:"bash",zsh:"bash",fish:"bash",ps1:"powershell",sql:"sql",html:"html",htm:"html",css:"css",scss:"scss",sass:"sass",less:"less",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",md:"markdown",markdown:"markdown",txt:"plaintext",toml:"toml",ini:"ini",cfg:"ini",conf:"ini",dockerfile:"dockerfile",makefile:"makefile"})[e.split(".").pop()?.toLowerCase()||""]||"plaintext";return(0,v.jsxs)("div",{className:(0,k.cn)("flex flex-col h-full bg-background min-w-0 overflow-x-hidden",r&&"embed-mode text-[13px]"),children:[r&&(0,v.jsxs)("div",{className:"border-b border-border/50 px-2 py-1.5 flex items-center justify-between bg-card/50",children:[(0,v.jsx)(S.Button,{size:"icon",variant:"ghost",onClick:o,className:"size-6",children:(0,v.jsx)(xb.PanelLeft,{className:"size-3.5"})}),(0,v.jsx)("span",{className:"text-[11px] text-muted-foreground truncate max-w-[120px] font-medium",children:eN||"Session"}),(0,v.jsx)(S.Button,{size:"icon",variant:"ghost",onClick:()=>eM(!0),className:"size-6",children:(0,v.jsx)(xx.Settings,{className:"size-3.5"})})]}),!r&&(0,v.jsxs)("div",{className:"border-b border-border/50 px-3 sm:px-4 py-2 flex items-center justify-between bg-card/50 backdrop-blur-sm",children:[(0,v.jsxs)("div",{className:"min-w-0 flex items-center gap-2 sm:gap-3",children:[(0,v.jsx)(vr,{}),(0,v.jsx)("div",{className:"flex items-center gap-1.5",children:eC?(0,v.jsxs)("form",{onSubmit:e=>{e.preventDefault(),e9()},className:"flex items-center gap-1",children:[(0,v.jsx)(gC.Input,{ref:eI,value:eN,onChange:e=>eS(e.target.value),onBlur:e9,className:"h-7 text-sm font-semibold w-40 px-2",placeholder:"Session name"}),(0,v.jsx)(S.Button,{type:"submit",size:"icon",variant:"ghost",className:"size-6 text-muted-foreground hover:text-foreground",children:(0,v.jsx)(xg.Check,{className:"size-3.5"})})]}):(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsxs)("button",{onClick:()=>eA(!0),className:"flex items-center gap-1.5 group hover:bg-muted/50 rounded px-1.5 py-0.5 -mx-1.5 transition-colors",children:[(0,v.jsx)("h2",{className:"font-semibold text-foreground truncate max-w-[200px]",children:eN||"Untitled Session"}),(0,v.jsx)(xf.Pencil,{className:"size-3 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity"})]})}),(0,v.jsx)(C.TooltipContent,{children:"Click to rename"})]})})}),t.workingDirectory?(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded-md bg-muted/30 text-xs text-muted-foreground max-w-[200px]",children:[(0,v.jsx)(xv.FolderOpen,{className:"size-3.5 shrink-0"}),(0,v.jsx)("span",{className:"truncate font-mono",children:t.workingDirectory.split("/").pop()||t.workingDirectory})]})}),(0,v.jsx)(C.TooltipContent,{side:"bottom",className:"max-w-md",children:(0,v.jsx)("p",{className:"font-mono text-xs",children:t.workingDirectory})})]})}):null]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[eQ.filter(e=>"browser-recording"===e.category&&e.downloadUrl).map(e=>(0,v.jsx)(yk,{fileName:e.fileName,downloadUrl:e.downloadUrl,sizeBytes:e.sizeBytes,createdAt:e.createdAt},e.id)),W&&(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsxs)(N.Badge,{variant:"outline",className:"gap-1.5 text-xs border-emerald-500/30 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 cursor-help",children:[(0,v.jsx)("span",{className:"size-1.5 rounded-full bg-current animate-pulse"}),"Watching"]})}),(0,v.jsx)(C.TooltipContent,{children:"Watching stream from another client"})]})}),(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsx)(N.Badge,{variant:g?"default":"secondary",className:`cursor-help ${g?"bg-primary/90":""}`,children:g?W?"streaming":"running":t.status})}),(0,v.jsx)(C.TooltipContent,{children:g?W?"Receiving streamed response":"Agent is processing":`Session is ${t.status}`})]})}),(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsx)(S.Button,{size:"icon",variant:"ghost",className:"size-7 hover:bg-accent transition-colors",onClick:()=>eM(!0),children:(0,v.jsx)(xx.Settings,{className:"size-4"})})}),(0,v.jsx)(C.TooltipContent,{children:"Session Settings"})]})}),(0,v.jsxs)(go,{children:[(0,v.jsx)(gl,{asChild:!0,children:(0,v.jsx)(S.Button,{size:"icon",variant:"ghost",className:"size-7 hover:bg-accent transition-colors",children:(0,v.jsx)(xP,{className:"size-4"})})}),(0,v.jsxs)(gc,{align:"end",className:"w-52",children:[(0,v.jsxs)(gu,{onClick:()=>{eY(!1),(0,xt.getBrowserStreamStatus)(t.id).then(e=>{e?.active?(eW(!0),console.log("[browser] Reconnecting PIP — stream active")):console.log("[browser] No active browser stream")})},children:[(0,v.jsx)(gX,{className:"size-4 mr-2"}),"Open Browser PIP"]}),(0,v.jsxs)(gu,{onClick:async()=>{e3(await (0,xt.getBrowserRecordings)(t.id)),e2(!0)},children:[(0,v.jsx)(gZ,{className:"size-4 mr-2"}),"Browser Recordings"]}),(0,v.jsxs)(gu,{onClick:async()=>{e6("copying");try{let e=await vi(t.id);await navigator.clipboard.writeText(e),e6("copied"),console.log(`[debug-dump] copied ${e.length.toLocaleString()} chars to clipboard for session ${t.id}`),setTimeout(()=>e6("idle"),2500)}catch(e){console.error("[debug-dump] failed:",e),e6("error"),setTimeout(()=>e6("idle"),2500)}},children:["copying"===e4?(0,v.jsx)(xh.RefreshCw,{className:"size-4 mr-2 animate-spin"}):"copied"===e4?(0,v.jsx)(xg.Check,{className:"size-4 mr-2 text-green-500"}):"error"===e4?(0,v.jsx)(xm,{className:"size-4 mr-2 text-red-500"}):(0,v.jsx)(xR,{className:"size-4 mr-2"}),"copying"===e4?"Gathering…":"copied"===e4?"Copied to clipboard":"error"===e4?"Failed — see console":"Copy debug JSON"]})]})]})]})]}),(0,v.jsx)(pb.Dialog,{open:eR,onOpenChange:eM,children:(0,v.jsxs)(pb.DialogContent,{className:"sm:max-w-md",children:[(0,v.jsx)(pb.DialogHeader,{children:(0,v.jsxs)(pb.DialogTitle,{className:"flex items-center gap-2",children:[(0,v.jsx)("div",{className:"size-8 rounded-lg bg-muted flex items-center justify-center",children:(0,v.jsx)(xx.Settings,{className:"size-4"})}),"Session Settings"]})}),(0,v.jsxs)("div",{className:"space-y-4 pt-2",children:[(0,v.jsxs)("div",{className:"space-y-2",children:[(0,v.jsx)(xL.Label,{className:"text-sm font-medium",children:"Model"}),(0,v.jsxs)(oh.Select,{value:ej,onValueChange:e8,disabled:g,children:[(0,v.jsx)(oh.SelectTrigger,{className:"w-full",children:(0,v.jsx)(oh.SelectValue,{placeholder:"Select model"})}),(0,v.jsx)(oh.SelectContent,{children:e_?.availableModels.map(e=>(0,v.jsx)(oh.SelectItem,{value:e.id,children:(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsx)("span",{children:e.name}),(0,v.jsx)("span",{className:"text-xs text-muted-foreground",children:e.provider})]})},e.id))})]}),g&&(0,v.jsx)("p",{className:"text-xs text-muted-foreground",children:"Cannot change model while agent is running"})]}),(0,v.jsxs)("div",{className:"space-y-2",children:[(0,v.jsx)(xL.Label,{className:"flex items-center gap-2 text-sm font-medium",children:"Tool Approvals"}),(0,v.jsx)("p",{className:"text-xs text-muted-foreground -mt-0.5",children:"Toggle on to require approval before tool executes"}),(0,v.jsx)("div",{className:"space-y-1 rounded-lg border p-2.5 bg-muted/30",children:e_?.availableTools.map(e=>{var t;let r=(t=e.id,eE.toolApprovals?.[t]!==void 0?eE.toolApprovals[t]:"bash"===t);return(0,v.jsxs)("div",{className:"flex items-center justify-between py-1.5 hover:bg-muted/50 rounded px-2 -mx-1 transition-colors",children:[(0,v.jsxs)("div",{className:"space-y-0",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsx)("span",{className:"text-sm font-medium",children:e.name}),e.dangerous&&(0,v.jsx)("span",{className:"text-[10px] bg-amber-500/20 text-amber-600 dark:text-amber-400 px-1.5 py-0.5 rounded font-medium",children:"risky"})]}),(0,v.jsx)("p",{className:"text-[11px] text-muted-foreground",children:e.description})]}),(0,v.jsx)(xI.Switch,{checked:r,onCheckedChange:()=>tp(e.id,r)})]},e.id)})})]}),(0,v.jsx)("p",{className:"text-xs text-muted-foreground",children:"These settings only apply to this session. Changes take effect for future tool calls."})]})]})}),(0,v.jsx)(pb.Dialog,{open:e1,onOpenChange:e2,children:(0,v.jsxs)(pb.DialogContent,{className:"max-w-2xl w-full p-0 overflow-hidden rounded-xl",children:[(0,v.jsx)(pb.DialogHeader,{className:"px-5 pt-5 pb-3",children:(0,v.jsxs)(pb.DialogTitle,{className:"flex items-center gap-2 text-sm font-medium",children:[(0,v.jsx)("div",{className:"flex items-center justify-center size-6 rounded-lg bg-violet-500/10 dark:bg-violet-400/10",children:(0,v.jsx)(gZ,{className:"size-3.5 text-violet-600 dark:text-violet-400"})}),"Browser Recordings"]})}),(0,v.jsx)("div",{className:"px-5 pb-5 space-y-3",children:0===e5.length?(0,v.jsx)("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No browser recordings for this session"}):e5.map(e=>(0,v.jsxs)("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-muted/30 hover:bg-muted/50 transition-colors",children:[(0,v.jsx)("div",{className:"flex items-center justify-center size-10 rounded-lg bg-violet-500/10 dark:bg-violet-400/10 shrink-0",children:(0,v.jsx)(xC,{className:"size-4 text-violet-600 dark:text-violet-400 ml-0.5"})}),(0,v.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,v.jsx)("p",{className:"text-sm font-medium truncate",children:e.fileName}),(0,v.jsxs)("p",{className:"text-xs text-muted-foreground",children:[e.createdAt&&new Date(e.createdAt).toLocaleString(),null!=e.sizeBytes&&` \xb7 ${e.sizeBytes>1048576?`${(e.sizeBytes/1048576).toFixed(1)} MB`:`${(e.sizeBytes/1024).toFixed(0)} KB`}`]})]}),e.downloadUrl&&(0,v.jsxs)(S.Button,{size:"sm",variant:"outline",className:"shrink-0",onClick:()=>window.open(e.downloadUrl,"_blank"),children:[(0,v.jsx)(xC,{className:"size-3 mr-1"}),"Watch"]})]},e.id))})]})}),!r&&ez?.updateAvailable&&!eB&&(0,v.jsxs)("div",{className:"px-4 py-2 border-b border-amber-500/30 bg-amber-500/10 flex items-center justify-between gap-3",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(xj,{className:"size-4 text-amber-600 dark:text-amber-400 shrink-0"}),(0,v.jsxs)("span",{className:"text-sm text-amber-700 dark:text-amber-300",children:["Update available: ",(0,v.jsxs)("strong",{children:["v",ez.latestVersion]}),(0,v.jsxs)("span",{className:"text-amber-600/70 dark:text-amber-400/70 ml-1",children:["(current: v",ez.currentVersion,")"]})]})]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,v.jsx)(S.Button,{size:"sm",variant:"outline",className:"h-7 text-xs border-amber-500/50 bg-amber-500/20 hover:bg-amber-500/30 text-amber-700 dark:text-amber-300",onClick:e7,disabled:e$,children:e$?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(xh.RefreshCw,{className:"size-3 mr-1.5 animate-spin"}),"Creating..."]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(xj,{className:"size-3 mr-1.5"}),"Update Now"]})}),(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsx)(S.Button,{size:"icon",variant:"ghost",className:"size-6 text-amber-600 dark:text-amber-400 hover:bg-amber-500/20",onClick:()=>{eF(!0),ez?.latestVersion&&localStorage.setItem("sparkecoder-dismissed-version",ez.latestVersion)},children:(0,v.jsx)(xk.X,{className:"size-3.5"})})}),(0,v.jsx)(C.TooltipContent,{children:"Dismiss (won't show again for this version)"})]})})]})]}),!r&&(es&&es.todos&&es.todos.length>0||ea.length>0)&&(0,v.jsx)("div",{className:"px-4 py-2 border-b border-border/50 bg-muted/20",children:(0,v.jsx)(xo,{todosData:es,plans:ea})}),er.length>0&&(0,v.jsx)("div",{className:(0,k.cn)("p-4 border-b border-border space-y-3",r&&"p-2 space-y-2"),children:er.map(e=>{let t=e.input;return(0,v.jsxs)(oG,{approval:{id:e.id,approved:!1},state:"approval-requested",children:[(0,v.jsx)(oq,{children:(0,v.jsxs)("div",{className:"flex items-start gap-3",children:[(0,v.jsx)("div",{className:"size-8 rounded-lg bg-amber-500/20 flex items-center justify-center shrink-0",children:(0,v.jsx)(xm,{className:"size-4 text-amber-500"})}),(0,v.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,v.jsx)("p",{className:"font-medium text-sm",children:"Approval Required"}),(0,v.jsx)("p",{className:"text-sm text-muted-foreground mt-0.5",children:(0,v.jsx)("code",{className:"bg-muted px-1.5 py-0.5 rounded font-mono text-foreground",children:e.toolName})}),(0,v.jsx)("div",{className:"mt-3 rounded-lg border bg-muted/30 overflow-hidden",children:Object.entries(t).map(([e,t])=>(0,v.jsxs)("div",{className:"flex border-b border-border/50 last:border-b-0",children:[(0,v.jsx)("div",{className:"px-3 py-2 bg-muted/50 text-xs font-medium text-muted-foreground w-24 shrink-0",children:e}),(0,v.jsx)("div",{className:"px-3 py-2 text-xs font-mono flex-1 min-w-0 overflow-auto max-h-24",children:"string"==typeof t?(0,v.jsx)("span",{className:"whitespace-pre-wrap break-words",children:t}):(0,v.jsx)("span",{className:"text-muted-foreground",children:JSON.stringify(t)})})]},e))})]})]})}),(0,v.jsxs)(oH,{children:[(0,v.jsx)(oK,{variant:"outline",onClick:()=>th(e),children:"Reject"}),(0,v.jsx)(oK,{variant:"ghost",onClick:()=>tm(e),className:"text-muted-foreground hover:text-foreground",children:"Always Allow"}),(0,v.jsx)(oK,{variant:"default",onClick:()=>td(e),children:"Approve"})]})]},e.id)})}),(0,v.jsxs)(B,{className:(0,k.cn)("flex-1 p-4",r&&"p-2"),children:[(0,v.jsxs)(F,{className:(0,k.cn)("max-w-3xl mx-auto w-full",r&&"max-w-none"),children:[t.config?.task?.enabled&&(s="running"===(n=t.config.task).status,i="completed"===n.status,a="failed"===n.status,(0,v.jsxs)("div",{className:(0,k.cn)("mb-4 rounded-lg border px-3.5 py-2.5 flex items-center gap-2.5 text-sm transition-colors",i&&"border-emerald-500/30 bg-emerald-500/5",a&&"border-red-500/30 bg-red-500/5",s&&"border-blue-500/30 bg-blue-500/5"),children:[(0,v.jsx)(xE.ListChecks,{className:(0,k.cn)("size-4 shrink-0",i&&"text-emerald-500",a&&"text-red-500",s&&"text-blue-500")}),(0,v.jsx)("span",{className:"font-medium truncate",children:t.name||"Task"}),(0,v.jsx)("span",{className:(0,k.cn)("text-xs shrink-0",i&&"text-emerald-600 dark:text-emerald-400",a&&"text-red-600 dark:text-red-400",s&&"text-blue-600 dark:text-blue-400 animate-pulse"),children:s?"Running":i?"Completed":"Failed"}),null!=n.iterations&&(0,v.jsxs)("span",{className:"text-xs text-muted-foreground ml-auto tabular-nums shrink-0",children:[n.iterations," iter."]}),a&&n.error&&(0,v.jsxs)("span",{className:"text-xs text-red-500 truncate ml-1",title:n.error,children:["— ",n.error]})]})),ef&&(0,v.jsx)("div",{className:"flex justify-center py-12",children:(0,v.jsx)(oY,{size:24})}),!ef&&0===l.length&&!K&&(0,v.jsx)($,{icon:(0,v.jsxs)("div",{className:"relative overflow-hidden rounded-2xl size-16 shadow-lg ring-1 ring-white/10",children:[(0,v.jsx)(j.default,{src:"/sparke-coder.png",alt:"SparkECoder",width:64,height:64,className:"absolute inset-0 size-full object-cover",priority:!0}),g&&(0,v.jsx)("video",{src:"/sparkecode.mp4",autoPlay:!0,muted:!0,loop:!0,playsInline:!0,className:"absolute inset-0 size-full object-cover"})]}),title:"Start a conversation",description:"Ask SparkECoder to help you with coding tasks"}),l.filter(e=>{if("tool-call"===e.type&&e.toolCall){if(er.some(t=>t.toolCallId===e.toolCall?.toolCallId))return!1;let t=ee.some(t=>t.toolCallId===e.toolCall?.toolCallId),r=ee.some(t=>t.toolCallId.startsWith(`${e.toolCall?.toolName}_pending_`)&&("streaming"===t.status||"running"===t.status));if(t||r)return!1}return!0}).map(e=>{if("user-message"===e.type){let t,r,n,s=e.content?function(e){let t=e.match(/^\[([A-Z]+)(?:\s+([^\]]*))?\]\s*([\s\S]*)$/);if(!t)return{pill:null,rest:e};let r=t[1];return["WEB","SLACK","SYSTEM","SCHEDULE","WEBHOOK"].includes(r)?{pill:{channel:r,detail:t[2]?.trim()||void 0},rest:t[3]}:{pill:null,rest:e}}(e.content):{pill:null,rest:e.content||""};if(s.pill&&y7.has(s.pill.channel))return(0,v.jsx)(vt,{pill:s.pill,body:s.rest},e.id);let i=!!s.pill&&"WEB"!==s.pill.channel,a=void 0!==e.messageSequence&&el.some(t=>t.messageSequence===e.messageSequence);return(0,v.jsxs)("div",{className:i?"flex flex-col items-end gap-1":void 0,children:[i&&s.pill&&(0,v.jsxs)("div",{className:`inline-flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide px-2 py-0.5 rounded-md border self-end ${y8[s.pill.channel]||"bg-muted text-muted-foreground border-border"}`,children:[(0,v.jsx)("span",{children:s.pill.channel}),s.pill.detail&&(0,v.jsx)("span",{className:"font-normal normal-case opacity-80",children:s.pill.detail})]}),(0,v.jsxs)(aF,{from:"user",children:[(0,v.jsxs)(a$,{children:[e.attachments&&e.attachments.length>0&&(0,v.jsx)("div",{className:"flex flex-wrap gap-2 mb-2",children:e.attachments.map((e,t)=>(0,v.jsx)("div",{className:"relative",children:"image"===e.type?(0,v.jsx)("div",{className:"relative rounded-lg overflow-hidden border border-border/50 max-w-[200px]",children:(0,v.jsx)("img",{src:e.data.startsWith("data:")?e.data:`data:${e.mediaType||"image/png"};base64,${e.data}`,alt:e.filename||"Image attachment",className:"max-w-full h-auto max-h-[150px] object-contain"})}):(0,v.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-muted/50 border border-border/50",children:[(0,v.jsx)(xw,{className:"h-4 w-4 text-muted-foreground"}),(0,v.jsx)("span",{className:"text-sm text-muted-foreground truncate max-w-[150px]",children:e.filename||"File"})]})},t))}),e.content&&(r=(t=s.rest).replace(y6,"").trim(),n=function(e){let t=e.match(/<devtools-context>([\s\S]*?)<\/devtools-context>/);if(!t)return null;let r=t[1],n=r.match(/<page\s+url="([^"]*)"\s+path="([^"]*)"\s+name="([^"]*)"/),s=r.match(/<viewport\s+width="([^"]*)"\s+height="([^"]*)"(?:\s+dpr="([^"]*)")?/);return n?{url:n[1],path:n[2],pageName:n[3],viewportWidth:s?.[1],viewportHeight:s?.[2],dpr:s?.[3]}:null}(t),(0,v.jsxs)(v.Fragment,{children:[!i&&s.pill&&(0,v.jsx)(y9,{...s.pill}),r&&(0,v.jsx)("p",{className:"whitespace-pre-wrap",children:r}),n&&(0,v.jsxs)("div",{className:"flex items-center gap-1.5 mt-1.5 text-[11px] text-muted-foreground/60",children:[(0,v.jsx)(xT,{className:"h-3 w-3"}),(0,v.jsx)("span",{children:n.path}),n.viewportWidth&&n.viewportHeight&&(0,v.jsxs)("span",{className:"text-muted-foreground/40",children:[n.viewportWidth,"x",n.viewportHeight]})]})]}))]}),a&&!g&&(0,v.jsx)(aV,{className:"justify-end mt-1",children:(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsxs)(S.Button,{variant:"ghost",size:"sm",onClick:()=>tr(e.messageSequence,e.content),disabled:eu,className:"h-6 px-2 text-xs text-muted-foreground hover:text-destructive gap-1",children:[(0,v.jsx)(xy,{className:"h-3 w-3"}),"Revert"]})}),(0,v.jsx)(C.TooltipContent,{children:(0,v.jsx)("p",{children:"Revert to before this message (undo all changes after)"})})]})})})]})]},e.id)}if("reasoning"===e.type)return(0,v.jsxs)(mq,{isStreaming:!1,defaultOpen:!1,children:[(0,v.jsx)(mK,{}),(0,v.jsx)(mX,{children:e.content||""})]},e.id);if("assistant-text"===e.type)return(0,v.jsx)(aF,{from:"assistant",children:(0,v.jsxs)("div",{className:"flex gap-3",children:[(0,v.jsx)("div",{className:"relative overflow-hidden rounded-lg size-8 shadow-sm ring-1 ring-white/10 shrink-0",children:(0,v.jsx)(j.default,{src:"/sparke-coder.png",alt:"SparkECoder",width:32,height:32,className:"absolute inset-0 size-full object-cover"})}),(0,v.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,v.jsx)(a$,{children:(0,v.jsx)(aG,{children:e.content||""})}),(0,v.jsx)(aV,{children:(0,v.jsx)(aU,{label:"Copy",onClick:()=>navigator.clipboard.writeText(e.content||""),children:(0,v.jsx)(xd.Copy,{className:"size-3"})})})]})]})},e.id);if("tool-call"===e.type&&e.toolCall){let t=e.toolCall,r=`tool-${t.toolName}`;if("messenger"===t.toolName&&t.input?.action==="post")return(0,v.jsx)(ve,{input:t.input,output:t.output,status:t.status},e.id);if("write_file"===t.toolName)return(0,v.jsx)(xB,{input:t.input,output:t.output,status:t.status,streamingArgsText:t.streamingArgsText,liveContent:t.liveContent,liveOldString:t.liveOldString,liveNewString:t.liveNewString},e.id);if("read_file"===t.toolName)return(0,v.jsx)(xV,{input:t.input,output:t.output,status:t.status},e.id);if("bash"===t.toolName)return(0,v.jsx)(xq,{input:t.input,output:t.output,status:t.status,terminalId:t.terminalId,liveOutput:t.liveOutput},e.id);if("explore_agent"===t.toolName)return(0,v.jsx)(x1,{input:t.input,output:t.output,status:t.status,steps:t.exploreSteps},e.id);if("todo"===t.toolName)return(0,v.jsx)(ye,{input:t.input,output:t.output,status:t.status},e.id);if("load_skill"===t.toolName)return(0,v.jsx)(yn,{input:t.input,output:t.output,status:t.status},e.id);if("linter"===t.toolName)return(0,v.jsx)(yl,{input:t.input,output:t.output,status:t.status},e.id);if("code_graph"===t.toolName)return(0,v.jsx)(yh,{input:t.input,output:t.output,status:t.status},e.id);if("complete_task"===t.toolName||"task_failed"===t.toolName)return(0,v.jsx)(yg,{toolName:t.toolName,input:t.input,output:t.output,status:t.status},e.id);let n="completed"!==t.status;return(0,v.jsxs)(oT,{defaultOpen:n,children:[(0,v.jsx)(oE,{type:r,state:function(e){switch(e){case"pending":case"streaming":default:return"input-streaming";case"running":return"input-available";case"completed":return"output-available";case"rejected":return"output-denied";case"error":return"output-error"}}(t.status),title:t.toolName}),(0,v.jsxs)(oP,{children:[(0,v.jsx)(oR,{input:t.input}),(e=>{let t=e.output,r=e.input;if("bash"===e.toolName)return(0,v.jsx)(xq,{input:e.input,output:e.output,status:e.status,terminalId:e.terminalId,liveOutput:e.liveOutput,className:"mt-2"});if("explore_agent"===e.toolName)return(0,v.jsx)(x1,{input:e.input,output:e.output,status:e.status,steps:e.exploreSteps,className:"mt-2"});if("todo"===e.toolName)return(0,v.jsx)(ye,{input:e.input,output:e.output,status:e.status,className:"mt-2"});if("load_skill"===e.toolName)return(0,v.jsx)(yn,{input:e.input,output:e.output,status:e.status,className:"mt-2"});if("linter"===e.toolName)return(0,v.jsx)(yl,{input:e.input,output:e.output,status:e.status,className:"mt-2"});if("code_graph"===e.toolName)return(0,v.jsx)(yh,{input:e.input,output:e.output,status:e.status,className:"mt-2"});if("write_file"===e.toolName&&r){let e=r.path||"file",n=r.mode||"full",s=e.split("/").pop()||"file",i=tf(e);if("str_replace"===n){let e=r.old_string||"",n=r.new_string||"";return(0,v.jsxs)("div",{className:"mt-2 max-w-full overflow-hidden space-y-2",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,v.jsx)(xp,{className:"size-4 text-muted-foreground"}),(0,v.jsx)("span",{className:"font-medium",children:s}),(0,v.jsx)(N.Badge,{variant:"secondary",className:"text-xs",children:"str_replace"})]}),(0,v.jsxs)("div",{className:"rounded-md border overflow-hidden",children:[(0,v.jsxs)("div",{className:"bg-red-500/10 border-b p-2",children:[(0,v.jsx)("div",{className:"text-xs text-red-500 mb-1",children:"- Remove:"}),(0,v.jsx)("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-words text-red-400",children:e.length>500?e.slice(0,500)+"...":e})]}),(0,v.jsxs)("div",{className:"bg-green-500/10 p-2",children:[(0,v.jsx)("div",{className:"text-xs text-green-500 mb-1",children:"+ Add:"}),(0,v.jsx)("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-words text-green-400",children:n.length>500?n.slice(0,500)+"...":n})]})]}),t&&(0,v.jsxs)("div",{className:`text-xs flex items-center gap-1 ${t.success?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:[(0,v.jsx)("span",{children:t.success?"✓":"✗"}),(0,v.jsx)("span",{children:t.success?`Replaced (${void 0!==t.lineDelta?(t.lineDelta>=0?"+":"")+t.lineDelta+" lines":"done"})`:t.error||"Failed"})]})]})}let a=r.content||"";return(0,v.jsxs)("div",{className:"mt-2 max-w-full overflow-hidden",children:[(0,v.jsxs)(oI,{children:[(0,v.jsxs)(oL,{children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(xp,{className:"size-4 text-muted-foreground shrink-0"}),(0,v.jsx)(oD,{className:"truncate",children:s}),(0,v.jsx)(oz,{className:"truncate text-xs hidden sm:block",children:e})]}),(0,v.jsx)(oO,{children:(0,v.jsx)(oB,{icon:xd.Copy,label:"Copy",onClick:()=>navigator.clipboard.writeText(a)})})]}),a&&(0,v.jsx)(oF,{className:"p-0 max-h-[300px] overflow-auto",children:(0,v.jsx)(o_,{code:a,language:i,showLineNumbers:!0,children:(0,v.jsx)(oN,{className:"sr-only",children:(0,v.jsx)(oS,{children:(0,v.jsx)(oC,{children:s})})})})})]}),t&&(0,v.jsxs)("div",{className:`mt-2 text-xs flex items-center gap-1 ${t.success?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:[(0,v.jsx)("span",{children:t.success?"✓":"✗"}),(0,v.jsx)("span",{children:t.success?`File ${t.action||"written"} successfully`:t.error||"Failed"})]})]})}if("read_file"===e.toolName&&t){let e=r?.path||"file",n=e.split("/").pop()||"file",s=t.imageData,i=t.mediaType;if(s&&i)return(0,v.jsx)("div",{className:"mt-2 max-w-full overflow-hidden",children:(0,v.jsxs)(oI,{children:[(0,v.jsx)(oL,{children:(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(gM,{className:"size-4 text-muted-foreground shrink-0"}),(0,v.jsx)(oD,{className:"truncate",children:n}),(0,v.jsx)(oz,{className:"truncate text-xs hidden sm:block",children:e})]})}),(0,v.jsx)(oF,{className:"p-0 max-h-[400px] overflow-auto",children:(0,v.jsx)("div",{className:"p-3 flex justify-center bg-muted/20",children:(0,v.jsx)("img",{src:`data:${i};base64,${s}`,alt:n,className:"max-w-full max-h-[350px] object-contain rounded"})})})]})});let a=t.content||JSON.stringify(t,null,2),o=tf(e);return(0,v.jsx)("div",{className:"mt-2 max-w-full overflow-hidden",children:(0,v.jsxs)(oI,{children:[(0,v.jsxs)(oL,{children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(xp,{className:"size-4 text-muted-foreground shrink-0"}),(0,v.jsx)(oD,{className:"truncate",children:n}),(0,v.jsx)(oz,{className:"truncate text-xs hidden sm:block",children:e})]}),(0,v.jsx)(oO,{children:(0,v.jsx)(oB,{icon:xd.Copy,label:"Copy",onClick:()=>navigator.clipboard.writeText(a)})})]}),(0,v.jsx)(oF,{className:"p-0 max-h-[300px] overflow-auto",children:(0,v.jsx)(o_,{code:a,language:o,showLineNumbers:!0,children:(0,v.jsx)(oN,{className:"sr-only",children:(0,v.jsx)(oS,{children:(0,v.jsx)(oC,{children:n})})})})})]})})}return t?(0,v.jsx)(oM,{output:(0,v.jsxs)("pre",{className:"text-xs overflow-x-auto max-w-full whitespace-pre-wrap break-words",children:[JSON.stringify(t,null,2).slice(0,500),JSON.stringify(t).length>500?"...":""]}),errorText:"error"===e.status?"Tool execution failed":void 0}):null})(t)]})]},e.id)}return null}),g&&!K&&!Y&&0===ee.length&&(0,v.jsxs)("div",{className:"flex gap-3 items-center",children:[(0,v.jsx)("div",{className:"relative overflow-hidden rounded-lg size-8 shadow-sm ring-1 ring-white/10 shrink-0",children:(0,v.jsx)("video",{src:"/sparkecode.mp4",autoPlay:!0,muted:!0,loop:!0,playsInline:!0,className:"absolute inset-0 size-full object-cover"})}),(0,v.jsx)("span",{className:"text-sm text-muted-foreground",children:"Thinking..."})]}),g&&(Z||Y)&&(0,v.jsxs)(mq,{isStreaming:Z,defaultOpen:!0,children:[(0,v.jsx)(mK,{}),(0,v.jsx)(mX,{children:Y})]}),g&&K&&(0,v.jsx)(aF,{from:"assistant",children:(0,v.jsxs)("div",{className:"flex gap-3",children:[(0,v.jsx)("div",{className:"relative overflow-hidden rounded-lg size-8 shadow-sm ring-1 ring-white/10 shrink-0",children:(0,v.jsx)("video",{src:"/sparkecode.mp4",autoPlay:!0,muted:!0,loop:!0,playsInline:!0,className:"absolute inset-0 size-full object-cover"})}),(0,v.jsx)("div",{className:"flex-1 min-w-0",children:(0,v.jsxs)(a$,{children:[(0,v.jsx)(aG,{children:K}),(0,v.jsx)("span",{className:"inline-block w-2 h-4 bg-primary animate-pulse ml-1"})]})})]})}),g&&ee.map(e=>"write_file"===e.toolName?(0,v.jsx)(xB,{input:e.input,output:e.output,status:e.status,streamingArgsText:e.streamingArgsText,liveContent:e.liveContent,liveOldString:e.liveOldString,liveNewString:e.liveNewString},e.toolCallId):"read_file"===e.toolName?(0,v.jsx)(xV,{input:e.input,output:e.output,status:e.status},e.toolCallId):"bash"===e.toolName?(0,v.jsx)(xq,{input:e.input,output:e.output,status:e.status,terminalId:e.terminalId,liveOutput:e.liveOutput},e.toolCallId):"explore_agent"===e.toolName?(0,v.jsx)(x1,{input:e.input,output:e.output,status:e.status,steps:e.exploreSteps},e.toolCallId):"todo"===e.toolName?(0,v.jsx)(ye,{input:e.input,output:e.output,status:e.status},e.toolCallId):"load_skill"===e.toolName?(0,v.jsx)(yn,{input:e.input,output:e.output,status:e.status},e.toolCallId):"linter"===e.toolName?(0,v.jsx)(yl,{input:e.input,output:e.output,status:e.status},e.toolCallId):"code_graph"===e.toolName?(0,v.jsx)(yh,{input:e.input,output:e.output,status:e.status},e.toolCallId):"complete_task"===e.toolName||"task_failed"===e.toolName?(0,v.jsx)(yg,{toolName:e.toolName,input:e.input,output:e.output,status:e.status},e.toolCallId):(0,v.jsxs)(oT,{defaultOpen:!0,children:[(0,v.jsx)(oE,{type:`tool-${e.toolName}`,state:"streaming"===e.status?"input-streaming":"input-available",title:e.toolName}),(0,v.jsxs)(oP,{children:[(0,v.jsx)(oR,{input:e.input}),(0,v.jsxs)("div",{className:"flex items-center gap-2 p-3 text-muted-foreground",children:[(0,v.jsx)(oY,{size:14}),(0,v.jsx)("span",{className:"text-sm",children:"streaming"===e.status?"Receiving...":"Executing..."})]})]})]},e.toolCallId)),g&&!K&&0===ee.length&&(0,v.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,v.jsx)(oY,{size:16}),(0,v.jsx)("span",{className:"text-sm",children:"Thinking..."})]})]}),(0,v.jsx)(V,{})]}),I&&(0,v.jsxs)("div",{className:"fixed bottom-28 right-4 w-80 max-h-80 overflow-auto border bg-background/95 shadow-lg rounded-md text-xs",children:[(0,v.jsx)("div",{className:"px-3 py-2 border-b font-mono text-muted-foreground",children:"SSE Debug"}),(0,v.jsxs)("div",{className:"px-3 py-2 space-y-1",children:[0===D.length&&0===O.length&&(0,v.jsx)("div",{className:"text-muted-foreground",children:"No events yet"}),D.map((e,t)=>(0,v.jsx)("div",{className:"font-mono",children:e},`evt-${t}`)),O.map((e,t)=>(0,v.jsx)("div",{className:"font-mono text-red-600",children:e},`err-${t}`))]})]}),(0,v.jsx)("div",{className:(0,k.cn)("border-t border-border/50 p-4 pb-6 bg-card/30",r&&"p-2 pb-2"),children:(0,v.jsxs)("div",{className:(0,k.cn)("max-w-3xl mx-auto",r&&"max-w-none"),children:[!r&&!ef&&0===l.length&&!K&&!g&&(0,v.jsx)(g7,{className:"mb-3",children:['Create a hello.txt file with "Hello, World!"',"List files in the current directory","Show the current git status"].map(e=>(0,v.jsx)(xe,{suggestion:e,onClick:e=>{d(e)}},e))}),y.length>0&&(0,v.jsxs)("div",{className:(0,k.cn)("mb-2 rounded-lg border border-border/60 bg-muted/20 overflow-hidden",r&&"mb-1"),children:[(0,v.jsxs)("button",{type:"button",onClick:()=>M(e=>!e),className:(0,k.cn)("w-full flex items-center justify-between px-3 py-1.5 text-xs text-muted-foreground hover:bg-muted/30 transition-colors",r&&"px-2 py-1"),children:[(0,v.jsxs)("div",{className:"flex items-center gap-1.5",children:[R?(0,v.jsx)(xN.ChevronDown,{className:"size-3"}):(0,v.jsx)(xS.default,{className:"size-3"}),(0,v.jsxs)("span",{className:"font-medium",children:[y.length," Queued"]})]}),(0,v.jsx)("span",{className:"text-[10px]",children:"Stop ^C"})]}),R&&(0,v.jsx)("div",{className:"border-t border-border/40 divide-y divide-border/30",children:y.map((e,t)=>(0,v.jsxs)("div",{className:(0,k.cn)("flex items-start gap-2 px-3 py-2 group",r&&"px-2 py-1.5 gap-1.5"),children:[(0,v.jsx)("span",{className:"text-[10px] text-muted-foreground/60 pt-0.5 w-4 shrink-0 text-center",children:t+1}),(0,v.jsxs)("div",{className:"flex-1 min-w-0",children:[_===e.id?(0,v.jsxs)("div",{className:"flex items-center gap-1",children:[(0,v.jsx)("input",{type:"text",value:E,onChange:e=>P(e.target.value),onKeyDown:t=>{"Enter"===t.key&&tc(e.id),"Escape"===t.key&&T(null)},className:(0,k.cn)("flex-1 bg-background border border-border rounded px-2 py-0.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary/30",r&&"text-[11px]"),autoFocus:!0}),(0,v.jsx)("button",{type:"button",onClick:()=>tc(e.id),className:"p-0.5 text-primary hover:text-primary/80",children:(0,v.jsx)(xg.Check,{className:"size-3"})})]}):(0,v.jsx)("p",{className:(0,k.cn)("text-xs text-foreground truncate",r&&"text-[11px]"),children:e.text||"Selected elements attached"}),e.attachments&&e.attachments.length>0&&(0,v.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[e.attachments.length," file",e.attachments.length>1?"s":""]}),e.selectedElements&&(0,v.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"+ selected elements"})]}),(0,v.jsxs)("div",{className:(0,k.cn)("flex items-center gap-0.5 shrink-0 transition-opacity",r?"opacity-100":"opacity-0 group-hover:opacity-100"),children:[(0,v.jsx)("button",{type:"button",onClick:()=>{T(e.id),P(e.text)},className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted/50",title:"Edit",children:(0,v.jsx)(xf.Pencil,{className:"size-3"})}),t>0&&(0,v.jsx)("button",{type:"button",onClick:()=>{var t;return t=e.id,void w(e=>{let r=e.findIndex(e=>e.id===t);if(-1===r)return e;let n=r-1;if(n<0||n>=e.length)return e;let s=[...e];return[s[r],s[n]]=[s[n],s[r]],s})},className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted/50",title:"Move up",children:(0,v.jsx)(xA,{className:"size-3"})}),(0,v.jsx)("button",{type:"button",onClick:()=>tu(e.id),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted/50",title:"Send now",children:(0,v.jsx)(xC,{className:"size-3"})}),(0,v.jsx)("button",{type:"button",onClick:()=>{var t;return t=e.id,void w(e=>e.filter(e=>e.id!==t))},className:"p-1 rounded text-muted-foreground hover:text-destructive hover:bg-muted/50",title:"Remove",children:(0,v.jsx)(x_.Trash2,{className:"size-3"})})]})]},e.id))})]}),(0,v.jsx)(y3,{children:(0,v.jsxs)(gU,{onSubmit:ta,className:"shadow-sm",globalDrop:!0,multiple:!0,children:[(0,v.jsxs)(gG,{children:[p&&(0,v.jsxs)("div",{className:(0,k.cn)("mb-2 flex items-center justify-between rounded-md border border-border/60 bg-muted/40 px-2 py-1 text-xs",r&&"mb-1"),children:[(0,v.jsxs)("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,v.jsx)("span",{className:"size-1.5 rounded-full bg-primary/70"}),(0,v.jsx)("span",{children:"Selected elements attached"})]}),(0,v.jsx)("button",{type:"button",onClick:()=>f(null),className:"rounded-sm p-1 text-muted-foreground hover:text-foreground","aria-label":"Remove selected elements",children:(0,v.jsx)(xk.X,{className:"size-3.5"})})]}),(0,v.jsx)(vn,{})]}),(0,v.jsx)(gW,{children:(0,v.jsxs)("div",{className:"relative w-full",children:[(0,v.jsx)(y4,{sessionId:t.id,value:u+(h?(!u||u.endsWith(" ")||u.endsWith("\n")?"":" ")+h:""),onChange:e=>{h&&m(""),d(e)},placeholder:g?"Type to queue a message...":"Ask SparkECoder... (@ to mention files, / for commands)",disabled:!1,autoFocus:!0,className:(0,k.cn)("min-h-[80px] focus:ring-2 focus:ring-primary/20 transition-all field-sizing-content max-h-48",h&&"caret-red-500",r&&"min-h-[40px] text-sm max-h-24")}),h&&(0,v.jsxs)("div",{className:"absolute bottom-2 right-2 flex items-center gap-1.5 text-xs text-red-500 bg-background/80 backdrop-blur-sm px-2 py-1 rounded-full",children:[(0,v.jsx)("span",{className:"size-2 bg-red-500 rounded-full animate-pulse"}),"Listening..."]})]})}),(0,v.jsxs)(gq,{className:r?"py-1":void 0,children:[!r&&(0,v.jsx)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:(0,v.jsx)("span",{className:"hidden sm:inline",children:"Type @ to mention files, / for commands"})}),(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsx)(yv,{size:"icon",className:"size-9",onTranscriptionChange:e=>{d(t=>{let r=t&&!t.endsWith(" ")&&!t.endsWith("\n");return t+(r?" ":"")+e})},onInterimTranscription:e=>{m(e)},disabled:g}),(0,v.jsx)(vs,{input:u+h,isRunning:g,onStop:to,hasExtraContent:!!(p&&p.trim())})]})]})]})})]})}),(0,v.jsx)(yw,{sessionId:t.id,frame:eG,metadata:eH,active:eU&&!eX,onDismiss:()=>{eY(!0),eW(!1)}})]})}var vo=e.i(482079),vl=e.i(461957);function vc({sessionId:e}){let[t,r]=(0,b.useState)(null),[n,s]=(0,b.useState)(""),[i,a]=(0,b.useState)(!1),o=(0,b.useCallback)(async()=>{let t=await (0,xt.getSession)(e);r(t?.pendingQuestion??null)},[e]);if((0,b.useEffect)(()=>{let e=!1,t=async()=>{e||await o()};t();let r=setInterval(t,3e3);return()=>{e=!0,clearInterval(r)}},[o]),!t)return null;let l=async()=>{if(n.trim()&&!i){a(!0);try{await (0,xt.answerAgentQuestion)(e,t.questionId,n.trim()),s(""),r(null),o()}finally{a(!1)}}};return(0,v.jsx)("div",{className:"border-b border-amber-500/40 bg-amber-500/5 px-4 py-3",children:(0,v.jsxs)("div",{className:"flex items-start gap-3 max-w-3xl mx-auto",children:[(0,v.jsx)(vo.MessageCircleQuestion,{className:"size-5 text-amber-500 shrink-0 mt-0.5"}),(0,v.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,v.jsx)("p",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:t.question}),t.context&&(0,v.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:t.context}),t.choices&&t.choices.length>0&&(0,v.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-2",children:t.choices.map(e=>(0,v.jsx)("button",{type:"button",onClick:()=>s(e),className:"text-xs px-2 py-1 rounded bg-amber-500/10 hover:bg-amber-500/20 text-amber-800 dark:text-amber-200",children:e},e))}),(0,v.jsxs)("div",{className:"flex gap-2 mt-2",children:[(0,v.jsx)("input",{type:"text",value:n,onChange:e=>s(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),l())},placeholder:"Type your answer…",className:"flex-1 px-3 py-1.5 text-sm rounded border border-border bg-background focus:outline-none focus:ring-2 focus:ring-amber-500/40",autoFocus:!0}),(0,v.jsx)(S.Button,{size:"sm",onClick:l,disabled:!n.trim()||i,children:i?(0,v.jsx)(vl.Loader2,{className:"size-3.5 animate-spin"}):"Answer"})]})]})]})})}function vu({params:e}){let{id:t}=(0,b.use)(e),r=(0,w.useRouter)(),[n,s]=(0,b.useState)(null),[i,a]=(0,b.useState)(!0),[o,l]=(0,b.useState)(null);return((0,b.useEffect)(()=>{!async function(){try{let e=await (0,xt.getSession)(t);if(!e)return void l("Session not found");s(e)}catch(e){console.error("Failed to load session:",e),l("Failed to load session")}finally{a(!1)}}()},[t]),i)?(0,v.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,v.jsx)(vl.Loader2,{className:"size-8 animate-spin text-muted-foreground"})}):o||!n?(0,v.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,v.jsxs)("div",{className:"text-center",children:[(0,v.jsx)("p",{className:"text-muted-foreground mb-4",children:o||"Session not found"}),(0,v.jsx)("button",{onClick:()=>r.push("/"),className:"text-primary hover:underline",children:"Go back home"})]})}):(0,v.jsxs)("div",{className:"flex flex-col h-full",children:[(0,v.jsx)(vc,{sessionId:n.id}),(0,v.jsx)("div",{className:"flex-1 min-h-0",children:(0,v.jsx)(va,{session:n})})]})}e.s(["default",()=>vu],330460)}]);
13
+ ${i}`}let a=i,o=r?.map(e=>({type:e.type,data:e.data,mediaType:e.mediaType,filename:e.filename})),l={id:`user-${Date.now()}`,type:"user-message",content:e||(s?"Selected elements attached":""),attachments:o};c(e=>[...e,l]),x(!0),G(!1),eb.current=!0,X(""),J(""),Q(!1),et([]),eh.current="",em.current="",ep.current=[],ex.current=(0,xt.runAgent)(t.id,a||"Please analyze the attached files.",tn,{onStreamId:e=>H(e),attachments:r})},ti=async(e,t)=>{let r=!!(p&&p.trim());if(e.trim()||t&&0!==t.length||r){if(g){let r;return void(r={id:`q-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,text:e,attachments:t,selectedElements:p},w(e=>[...e,r]),d(""),f(null))}d(""),f(null),await ts(e,t,p)}},ta=async e=>{let t=!!e.text?.trim(),r=!!e.files?.length,n=!!(p&&p.trim());if(!t&&!r&&!n)return;let s=[];if(r&&e.files.length>0){for(let t of e.files)if(t.url)try{let e=await fetch(t.url),r=await e.blob(),n=await new Promise(e=>{let t=new FileReader;t.onloadend=()=>e(t.result),t.readAsDataURL(r)}),i=t.mediaType||r.type||"application/octet-stream",a=i.startsWith("image/");s.push({type:a?"image":"file",data:n,mediaType:i,filename:t.filename})}catch(e){console.error("Failed to process attachment:",e)}}ti(e.text||"",s.length>0?s:void 0)},to=async()=>{try{await (0,xt.abortStream)(t.id)}catch(e){console.error("Failed to abort stream:",e)}if(ex.current&&(ex.current(),ex.current=null),em.current.trim()){let e={id:`reasoning-${Date.now()}`,type:"reasoning",content:em.current};c(t=>[...t,e])}if(eh.current.trim()){let e={id:`text-${Date.now()}`,type:"assistant-text",content:eh.current+" [stopped]"};c(t=>[...t,e])}X(""),J(""),Q(!1),et([]),H(null),eh.current="",em.current="",ep.current=[],ev.current=!1,x(!1),G(!1)},tl=(0,b.useRef)(ts);tl.current=ts;let tc=e=>{w(t=>t.map(t=>t.id===e?{...t,text:E}:t)),T(null),P("")},tu=async e=>{let t=y.find(t=>t.id===e);t&&(w(t=>t.filter(t=>t.id!==e)),g?(await to(),setTimeout(()=>{tl.current(t.text,t.attachments,t.selectedElements)},500)):tl.current(t.text,t.attachments,t.selectedElements))},td=async e=>{en(t=>t.filter(t=>t.id!==e.id));try{await (0,xt.approveExecution)(t.id,e.toolCallId)}catch(e){console.error("Failed to approve:",e)}},th=async e=>{en(t=>t.filter(t=>t.id!==e.id));try{await (0,xt.rejectExecution)(t.id,e.toolCallId,"User rejected")}catch(e){console.error("Failed to reject:",e)}},tm=async e=>{en(t=>t.filter(t=>t.id!==e.id));try{await (0,xt.approveExecution)(t.id,e.toolCallId);let r=await (0,xt.updateToolApproval)(t.id,e.toolName,!1,eE);eP(r.config||{})}catch(e){console.error("Failed to approve and disable:",e)}},tp=async(e,r)=>{try{let n=await (0,xt.updateToolApproval)(t.id,e,!r,eE);eP(n.config||{})}catch(e){console.error("Failed to update tool approval:",e)}},tf=e=>({ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",c:"c",cpp:"cpp",h:"c",hpp:"cpp",cs:"csharp",php:"php",swift:"swift",kt:"kotlin",scala:"scala",sh:"bash",bash:"bash",zsh:"bash",fish:"bash",ps1:"powershell",sql:"sql",html:"html",htm:"html",css:"css",scss:"scss",sass:"sass",less:"less",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",md:"markdown",markdown:"markdown",txt:"plaintext",toml:"toml",ini:"ini",cfg:"ini",conf:"ini",dockerfile:"dockerfile",makefile:"makefile"})[e.split(".").pop()?.toLowerCase()||""]||"plaintext";return(0,v.jsxs)("div",{className:(0,k.cn)("flex flex-col h-full bg-background min-w-0 overflow-x-hidden",r&&"embed-mode text-[13px]"),children:[r&&(0,v.jsxs)("div",{className:"border-b border-border/50 px-2 py-1.5 flex items-center justify-between bg-card/50",children:[(0,v.jsx)(S.Button,{size:"icon",variant:"ghost",onClick:o,className:"size-6",children:(0,v.jsx)(xb.PanelLeft,{className:"size-3.5"})}),(0,v.jsx)("span",{className:"text-[11px] text-muted-foreground truncate max-w-[120px] font-medium",children:eN||"Session"}),(0,v.jsx)(S.Button,{size:"icon",variant:"ghost",onClick:()=>eM(!0),className:"size-6",children:(0,v.jsx)(xx.Settings,{className:"size-3.5"})})]}),!r&&(0,v.jsxs)("div",{className:"border-b border-border/50 px-3 sm:px-4 py-2 flex items-center justify-between bg-card/50 backdrop-blur-sm",children:[(0,v.jsxs)("div",{className:"min-w-0 flex items-center gap-2 sm:gap-3",children:[(0,v.jsx)(vr,{}),(0,v.jsx)("div",{className:"flex items-center gap-1.5",children:eC?(0,v.jsxs)("form",{onSubmit:e=>{e.preventDefault(),e9()},className:"flex items-center gap-1",children:[(0,v.jsx)(gC.Input,{ref:eI,value:eN,onChange:e=>eS(e.target.value),onBlur:e9,className:"h-7 text-sm font-semibold w-40 px-2",placeholder:"Session name"}),(0,v.jsx)(S.Button,{type:"submit",size:"icon",variant:"ghost",className:"size-6 text-muted-foreground hover:text-foreground",children:(0,v.jsx)(xg.Check,{className:"size-3.5"})})]}):(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsxs)("button",{onClick:()=>eA(!0),className:"flex items-center gap-1.5 group hover:bg-muted/50 rounded px-1.5 py-0.5 -mx-1.5 transition-colors",children:[(0,v.jsx)("h2",{className:"font-semibold text-foreground truncate max-w-[200px]",children:eN||"Untitled Session"}),(0,v.jsx)(xf.Pencil,{className:"size-3 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity"})]})}),(0,v.jsx)(C.TooltipContent,{children:"Click to rename"})]})})}),t.workingDirectory?(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded-md bg-muted/30 text-xs text-muted-foreground max-w-[200px]",children:[(0,v.jsx)(xv.FolderOpen,{className:"size-3.5 shrink-0"}),(0,v.jsx)("span",{className:"truncate font-mono",children:t.workingDirectory.split("/").pop()||t.workingDirectory})]})}),(0,v.jsx)(C.TooltipContent,{side:"bottom",className:"max-w-md",children:(0,v.jsx)("p",{className:"font-mono text-xs",children:t.workingDirectory})})]})}):null]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[eQ.filter(e=>"browser-recording"===e.category&&e.downloadUrl).map(e=>(0,v.jsx)(yk,{fileName:e.fileName,downloadUrl:e.downloadUrl,sizeBytes:e.sizeBytes,createdAt:e.createdAt},e.id)),W&&(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsxs)(N.Badge,{variant:"outline",className:"gap-1.5 text-xs border-emerald-500/30 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 cursor-help",children:[(0,v.jsx)("span",{className:"size-1.5 rounded-full bg-current animate-pulse"}),"Watching"]})}),(0,v.jsx)(C.TooltipContent,{children:"Watching stream from another client"})]})}),(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsx)(N.Badge,{variant:g?"default":"secondary",className:`cursor-help ${g?"bg-primary/90":""}`,children:g?W?"streaming":"running":t.status})}),(0,v.jsx)(C.TooltipContent,{children:g?W?"Receiving streamed response":"Agent is processing":`Session is ${t.status}`})]})}),(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsx)(S.Button,{size:"icon",variant:"ghost",className:"size-7 hover:bg-accent transition-colors",onClick:()=>eM(!0),children:(0,v.jsx)(xx.Settings,{className:"size-4"})})}),(0,v.jsx)(C.TooltipContent,{children:"Session Settings"})]})}),(0,v.jsxs)(go,{children:[(0,v.jsx)(gl,{asChild:!0,children:(0,v.jsx)(S.Button,{size:"icon",variant:"ghost",className:"size-7 hover:bg-accent transition-colors",children:(0,v.jsx)(xP,{className:"size-4"})})}),(0,v.jsxs)(gc,{align:"end",className:"w-52",children:[(0,v.jsxs)(gu,{onClick:()=>{eY(!1),(0,xt.getBrowserStreamStatus)(t.id).then(e=>{e?.active?(eW(!0),console.log("[browser] Reconnecting PIP — stream active")):console.log("[browser] No active browser stream")})},children:[(0,v.jsx)(gX,{className:"size-4 mr-2"}),"Open Browser PIP"]}),(0,v.jsxs)(gu,{onClick:async()=>{e3(await (0,xt.getBrowserRecordings)(t.id)),e2(!0)},children:[(0,v.jsx)(gZ,{className:"size-4 mr-2"}),"Browser Recordings"]}),(0,v.jsxs)(gu,{onClick:async()=>{e6("copying");try{let e=await vi(t.id);await navigator.clipboard.writeText(e),e6("copied"),console.log(`[debug-dump] copied ${e.length.toLocaleString()} chars to clipboard for session ${t.id}`),setTimeout(()=>e6("idle"),2500)}catch(e){console.error("[debug-dump] failed:",e),e6("error"),setTimeout(()=>e6("idle"),2500)}},children:["copying"===e4?(0,v.jsx)(xh.RefreshCw,{className:"size-4 mr-2 animate-spin"}):"copied"===e4?(0,v.jsx)(xg.Check,{className:"size-4 mr-2 text-green-500"}):"error"===e4?(0,v.jsx)(xm,{className:"size-4 mr-2 text-red-500"}):(0,v.jsx)(xR,{className:"size-4 mr-2"}),"copying"===e4?"Gathering…":"copied"===e4?"Copied to clipboard":"error"===e4?"Failed — see console":"Copy debug JSON"]})]})]})]})]}),(0,v.jsx)(pb.Dialog,{open:eR,onOpenChange:eM,children:(0,v.jsxs)(pb.DialogContent,{className:"sm:max-w-md",children:[(0,v.jsx)(pb.DialogHeader,{children:(0,v.jsxs)(pb.DialogTitle,{className:"flex items-center gap-2",children:[(0,v.jsx)("div",{className:"size-8 rounded-lg bg-muted flex items-center justify-center",children:(0,v.jsx)(xx.Settings,{className:"size-4"})}),"Session Settings"]})}),(0,v.jsxs)("div",{className:"space-y-4 pt-2",children:[(0,v.jsxs)("div",{className:"space-y-2",children:[(0,v.jsx)(xL.Label,{className:"text-sm font-medium",children:"Model"}),(0,v.jsxs)(oh.Select,{value:ej,onValueChange:e8,disabled:g,children:[(0,v.jsx)(oh.SelectTrigger,{className:"w-full",children:(0,v.jsx)(oh.SelectValue,{placeholder:"Select model"})}),(0,v.jsx)(oh.SelectContent,{children:e_?.availableModels.map(e=>(0,v.jsx)(oh.SelectItem,{value:e.id,children:(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsx)("span",{children:e.name}),(0,v.jsx)("span",{className:"text-xs text-muted-foreground",children:e.provider})]})},e.id))})]}),g&&(0,v.jsx)("p",{className:"text-xs text-muted-foreground",children:"Cannot change model while agent is running"})]}),(0,v.jsxs)("div",{className:"space-y-2",children:[(0,v.jsx)(xL.Label,{className:"flex items-center gap-2 text-sm font-medium",children:"Tool Approvals"}),(0,v.jsx)("p",{className:"text-xs text-muted-foreground -mt-0.5",children:"Toggle on to require approval before tool executes"}),(0,v.jsx)("div",{className:"space-y-1 rounded-lg border p-2.5 bg-muted/30",children:e_?.availableTools.map(e=>{var t;let r=(t=e.id,eE.toolApprovals?.[t]!==void 0?eE.toolApprovals[t]:"bash"===t);return(0,v.jsxs)("div",{className:"flex items-center justify-between py-1.5 hover:bg-muted/50 rounded px-2 -mx-1 transition-colors",children:[(0,v.jsxs)("div",{className:"space-y-0",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsx)("span",{className:"text-sm font-medium",children:e.name}),e.dangerous&&(0,v.jsx)("span",{className:"text-[10px] bg-amber-500/20 text-amber-600 dark:text-amber-400 px-1.5 py-0.5 rounded font-medium",children:"risky"})]}),(0,v.jsx)("p",{className:"text-[11px] text-muted-foreground",children:e.description})]}),(0,v.jsx)(xI.Switch,{checked:r,onCheckedChange:()=>tp(e.id,r)})]},e.id)})})]}),(0,v.jsx)("p",{className:"text-xs text-muted-foreground",children:"These settings only apply to this session. Changes take effect for future tool calls."})]})]})}),(0,v.jsx)(pb.Dialog,{open:e1,onOpenChange:e2,children:(0,v.jsxs)(pb.DialogContent,{className:"max-w-2xl w-full p-0 overflow-hidden rounded-xl",children:[(0,v.jsx)(pb.DialogHeader,{className:"px-5 pt-5 pb-3",children:(0,v.jsxs)(pb.DialogTitle,{className:"flex items-center gap-2 text-sm font-medium",children:[(0,v.jsx)("div",{className:"flex items-center justify-center size-6 rounded-lg bg-violet-500/10 dark:bg-violet-400/10",children:(0,v.jsx)(gZ,{className:"size-3.5 text-violet-600 dark:text-violet-400"})}),"Browser Recordings"]})}),(0,v.jsx)("div",{className:"px-5 pb-5 space-y-3",children:0===e5.length?(0,v.jsx)("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No browser recordings for this session"}):e5.map(e=>(0,v.jsxs)("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-muted/30 hover:bg-muted/50 transition-colors",children:[(0,v.jsx)("div",{className:"flex items-center justify-center size-10 rounded-lg bg-violet-500/10 dark:bg-violet-400/10 shrink-0",children:(0,v.jsx)(xC,{className:"size-4 text-violet-600 dark:text-violet-400 ml-0.5"})}),(0,v.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,v.jsx)("p",{className:"text-sm font-medium truncate",children:e.fileName}),(0,v.jsxs)("p",{className:"text-xs text-muted-foreground",children:[e.createdAt&&new Date(e.createdAt).toLocaleString(),null!=e.sizeBytes&&` \xb7 ${e.sizeBytes>1048576?`${(e.sizeBytes/1048576).toFixed(1)} MB`:`${(e.sizeBytes/1024).toFixed(0)} KB`}`]})]}),e.downloadUrl&&(0,v.jsxs)(S.Button,{size:"sm",variant:"outline",className:"shrink-0",onClick:()=>window.open(e.downloadUrl,"_blank"),children:[(0,v.jsx)(xC,{className:"size-3 mr-1"}),"Watch"]})]},e.id))})]})}),!r&&ez?.updateAvailable&&!eB&&(0,v.jsxs)("div",{className:"px-4 py-2 border-b border-amber-500/30 bg-amber-500/10 flex items-center justify-between gap-3",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(xj,{className:"size-4 text-amber-600 dark:text-amber-400 shrink-0"}),(0,v.jsxs)("span",{className:"text-sm text-amber-700 dark:text-amber-300",children:["Update available: ",(0,v.jsxs)("strong",{children:["v",ez.latestVersion]}),(0,v.jsxs)("span",{className:"text-amber-600/70 dark:text-amber-400/70 ml-1",children:["(current: v",ez.currentVersion,")"]})]})]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,v.jsx)(S.Button,{size:"sm",variant:"outline",className:"h-7 text-xs border-amber-500/50 bg-amber-500/20 hover:bg-amber-500/30 text-amber-700 dark:text-amber-300",onClick:e7,disabled:e$,children:e$?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(xh.RefreshCw,{className:"size-3 mr-1.5 animate-spin"}),"Creating..."]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(xj,{className:"size-3 mr-1.5"}),"Update Now"]})}),(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsx)(S.Button,{size:"icon",variant:"ghost",className:"size-6 text-amber-600 dark:text-amber-400 hover:bg-amber-500/20",onClick:()=>{eF(!0),ez?.latestVersion&&localStorage.setItem("sparkecoder-dismissed-version",ez.latestVersion)},children:(0,v.jsx)(xk.X,{className:"size-3.5"})})}),(0,v.jsx)(C.TooltipContent,{children:"Dismiss (won't show again for this version)"})]})})]})]}),!r&&(es&&es.todos&&es.todos.length>0||ea.length>0)&&(0,v.jsx)("div",{className:"px-4 py-2 border-b border-border/50 bg-muted/20",children:(0,v.jsx)(xo,{todosData:es,plans:ea})}),er.length>0&&(0,v.jsx)("div",{className:(0,k.cn)("p-4 border-b border-border space-y-3",r&&"p-2 space-y-2"),children:er.map(e=>{let t=e.input;return(0,v.jsxs)(oG,{approval:{id:e.id,approved:!1},state:"approval-requested",children:[(0,v.jsx)(oq,{children:(0,v.jsxs)("div",{className:"flex items-start gap-3",children:[(0,v.jsx)("div",{className:"size-8 rounded-lg bg-amber-500/20 flex items-center justify-center shrink-0",children:(0,v.jsx)(xm,{className:"size-4 text-amber-500"})}),(0,v.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,v.jsx)("p",{className:"font-medium text-sm",children:"Approval Required"}),(0,v.jsx)("p",{className:"text-sm text-muted-foreground mt-0.5",children:(0,v.jsx)("code",{className:"bg-muted px-1.5 py-0.5 rounded font-mono text-foreground",children:e.toolName})}),(0,v.jsx)("div",{className:"mt-3 rounded-lg border bg-muted/30 overflow-hidden",children:Object.entries(t).map(([e,t])=>(0,v.jsxs)("div",{className:"flex border-b border-border/50 last:border-b-0",children:[(0,v.jsx)("div",{className:"px-3 py-2 bg-muted/50 text-xs font-medium text-muted-foreground w-24 shrink-0",children:e}),(0,v.jsx)("div",{className:"px-3 py-2 text-xs font-mono flex-1 min-w-0 overflow-auto max-h-24",children:"string"==typeof t?(0,v.jsx)("span",{className:"whitespace-pre-wrap break-words",children:t}):(0,v.jsx)("span",{className:"text-muted-foreground",children:JSON.stringify(t)})})]},e))})]})]})}),(0,v.jsxs)(oH,{children:[(0,v.jsx)(oK,{variant:"outline",onClick:()=>th(e),children:"Reject"}),(0,v.jsx)(oK,{variant:"ghost",onClick:()=>tm(e),className:"text-muted-foreground hover:text-foreground",children:"Always Allow"}),(0,v.jsx)(oK,{variant:"default",onClick:()=>td(e),children:"Approve"})]})]},e.id)})}),(0,v.jsxs)(B,{className:(0,k.cn)("flex-1 p-4",r&&"p-2"),children:[(0,v.jsxs)(F,{className:(0,k.cn)("max-w-3xl mx-auto w-full",r&&"max-w-none"),children:[t.config?.task?.enabled&&(s="running"===(n=t.config.task).status,i="completed"===n.status,a="failed"===n.status,(0,v.jsxs)("div",{className:(0,k.cn)("mb-4 rounded-lg border px-3.5 py-2.5 flex items-center gap-2.5 text-sm transition-colors",i&&"border-emerald-500/30 bg-emerald-500/5",a&&"border-red-500/30 bg-red-500/5",s&&"border-blue-500/30 bg-blue-500/5"),children:[(0,v.jsx)(xE.ListChecks,{className:(0,k.cn)("size-4 shrink-0",i&&"text-emerald-500",a&&"text-red-500",s&&"text-blue-500")}),(0,v.jsx)("span",{className:"font-medium truncate",children:t.name||"Task"}),(0,v.jsx)("span",{className:(0,k.cn)("text-xs shrink-0",i&&"text-emerald-600 dark:text-emerald-400",a&&"text-red-600 dark:text-red-400",s&&"text-blue-600 dark:text-blue-400 animate-pulse"),children:s?"Running":i?"Completed":"Failed"}),null!=n.iterations&&(0,v.jsxs)("span",{className:"text-xs text-muted-foreground ml-auto tabular-nums shrink-0",children:[n.iterations," iter."]}),a&&n.error&&(0,v.jsxs)("span",{className:"text-xs text-red-500 truncate ml-1",title:n.error,children:["— ",n.error]})]})),ef&&(0,v.jsx)("div",{className:"flex justify-center py-12",children:(0,v.jsx)(oY,{size:24})}),!ef&&0===l.length&&!K&&(0,v.jsx)($,{icon:(0,v.jsxs)("div",{className:"relative overflow-hidden rounded-2xl size-16 shadow-lg ring-1 ring-white/10",children:[(0,v.jsx)(j.default,{src:"/sparke-coder.png",alt:"SparkECoder",width:64,height:64,className:"absolute inset-0 size-full object-cover",priority:!0}),g&&(0,v.jsx)("video",{src:"/sparkecode.mp4",autoPlay:!0,muted:!0,loop:!0,playsInline:!0,className:"absolute inset-0 size-full object-cover"})]}),title:"Start a conversation",description:"Ask SparkECoder to help you with coding tasks"}),l.filter(e=>{if("tool-call"===e.type&&e.toolCall){if(er.some(t=>t.toolCallId===e.toolCall?.toolCallId))return!1;let t=ee.some(t=>t.toolCallId===e.toolCall?.toolCallId),r=ee.some(t=>t.toolCallId.startsWith(`${e.toolCall?.toolName}_pending_`)&&("streaming"===t.status||"running"===t.status));if(t||r)return!1}return!0}).map(e=>{if("user-message"===e.type){let t,r,n,s=e.content?function(e){let t=e.replace(/^\s+/,"");for(;;){let e=t;if((t=(t=t.replace(/^\[Local device time:[^\]]*\]\s*/,"")).replace(/^\[REPLAY[^\]]*\]\s*/,""))===e)break}let r=t.match(/^\[([A-Z]+)(?:\s+([^\]]*))?\]\s*([\s\S]*)$/);if(!r)return{pill:null,rest:e};let n=r[1];return["WEB","SLACK","SYSTEM","SCHEDULE","WEBHOOK"].includes(n)?{pill:{channel:n,detail:r[2]?.replace(/\s*reply-with=[\s\S]*$/,"").trim()||void 0},rest:r[3]}:{pill:null,rest:e}}(e.content):{pill:null,rest:e.content||""};if(s.pill&&y7.has(s.pill.channel))return(0,v.jsx)(vt,{pill:s.pill,body:s.rest},e.id);let i=!!s.pill&&"WEB"!==s.pill.channel,a=void 0!==e.messageSequence&&el.some(t=>t.messageSequence===e.messageSequence);return(0,v.jsxs)("div",{className:i?"flex flex-col items-end gap-1":void 0,children:[i&&s.pill&&(0,v.jsxs)("div",{className:`inline-flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide px-2 py-0.5 rounded-md border self-end ${y8[s.pill.channel]||"bg-muted text-muted-foreground border-border"}`,children:[(0,v.jsx)("span",{children:s.pill.channel}),s.pill.detail&&(0,v.jsx)("span",{className:"font-normal normal-case opacity-80",children:s.pill.detail})]}),(0,v.jsxs)(aF,{from:"user",children:[(0,v.jsxs)(a$,{children:[e.attachments&&e.attachments.length>0&&(0,v.jsx)("div",{className:"flex flex-wrap gap-2 mb-2",children:e.attachments.map((e,t)=>(0,v.jsx)("div",{className:"relative",children:"image"===e.type?(0,v.jsx)("div",{className:"relative rounded-lg overflow-hidden border border-border/50 max-w-[200px]",children:(0,v.jsx)("img",{src:e.data.startsWith("data:")?e.data:`data:${e.mediaType||"image/png"};base64,${e.data}`,alt:e.filename||"Image attachment",className:"max-w-full h-auto max-h-[150px] object-contain"})}):(0,v.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-muted/50 border border-border/50",children:[(0,v.jsx)(xw,{className:"h-4 w-4 text-muted-foreground"}),(0,v.jsx)("span",{className:"text-sm text-muted-foreground truncate max-w-[150px]",children:e.filename||"File"})]})},t))}),e.content&&(r=(t=s.rest).replace(y6,"").trim(),n=function(e){let t=e.match(/<devtools-context>([\s\S]*?)<\/devtools-context>/);if(!t)return null;let r=t[1],n=r.match(/<page\s+url="([^"]*)"\s+path="([^"]*)"\s+name="([^"]*)"/),s=r.match(/<viewport\s+width="([^"]*)"\s+height="([^"]*)"(?:\s+dpr="([^"]*)")?/);return n?{url:n[1],path:n[2],pageName:n[3],viewportWidth:s?.[1],viewportHeight:s?.[2],dpr:s?.[3]}:null}(t),(0,v.jsxs)(v.Fragment,{children:[!i&&s.pill&&(0,v.jsx)(y9,{...s.pill}),r&&(0,v.jsx)("p",{className:"whitespace-pre-wrap",children:r}),n&&(0,v.jsxs)("div",{className:"flex items-center gap-1.5 mt-1.5 text-[11px] text-muted-foreground/60",children:[(0,v.jsx)(xT,{className:"h-3 w-3"}),(0,v.jsx)("span",{children:n.path}),n.viewportWidth&&n.viewportHeight&&(0,v.jsxs)("span",{className:"text-muted-foreground/40",children:[n.viewportWidth,"x",n.viewportHeight]})]})]}))]}),a&&!g&&(0,v.jsx)(aV,{className:"justify-end mt-1",children:(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsxs)(S.Button,{variant:"ghost",size:"sm",onClick:()=>tr(e.messageSequence,e.content),disabled:eu,className:"h-6 px-2 text-xs text-muted-foreground hover:text-destructive gap-1",children:[(0,v.jsx)(xy,{className:"h-3 w-3"}),"Revert"]})}),(0,v.jsx)(C.TooltipContent,{children:(0,v.jsx)("p",{children:"Revert to before this message (undo all changes after)"})})]})})})]})]},e.id)}if("reasoning"===e.type)return(0,v.jsxs)(mq,{isStreaming:!1,defaultOpen:!1,children:[(0,v.jsx)(mK,{}),(0,v.jsx)(mX,{children:e.content||""})]},e.id);if("assistant-text"===e.type)return(0,v.jsx)(aF,{from:"assistant",children:(0,v.jsxs)("div",{className:"flex gap-3",children:[(0,v.jsx)("div",{className:"relative overflow-hidden rounded-lg size-8 shadow-sm ring-1 ring-white/10 shrink-0",children:(0,v.jsx)(j.default,{src:"/sparke-coder.png",alt:"SparkECoder",width:32,height:32,className:"absolute inset-0 size-full object-cover"})}),(0,v.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,v.jsx)(a$,{children:(0,v.jsx)(aG,{children:e.content||""})}),(0,v.jsx)(aV,{children:(0,v.jsx)(aU,{label:"Copy",onClick:()=>navigator.clipboard.writeText(e.content||""),children:(0,v.jsx)(xd.Copy,{className:"size-3"})})})]})]})},e.id);if("tool-call"===e.type&&e.toolCall){let t=e.toolCall,r=`tool-${t.toolName}`;if("messenger"===t.toolName&&t.input?.action==="post")return(0,v.jsx)(ve,{input:t.input,output:t.output,status:t.status},e.id);if("write_file"===t.toolName)return(0,v.jsx)(xB,{input:t.input,output:t.output,status:t.status,streamingArgsText:t.streamingArgsText,liveContent:t.liveContent,liveOldString:t.liveOldString,liveNewString:t.liveNewString},e.id);if("read_file"===t.toolName)return(0,v.jsx)(xV,{input:t.input,output:t.output,status:t.status},e.id);if("bash"===t.toolName)return(0,v.jsx)(xq,{input:t.input,output:t.output,status:t.status,terminalId:t.terminalId,liveOutput:t.liveOutput},e.id);if("explore_agent"===t.toolName)return(0,v.jsx)(x1,{input:t.input,output:t.output,status:t.status,steps:t.exploreSteps},e.id);if("todo"===t.toolName)return(0,v.jsx)(ye,{input:t.input,output:t.output,status:t.status},e.id);if("load_skill"===t.toolName)return(0,v.jsx)(yn,{input:t.input,output:t.output,status:t.status},e.id);if("linter"===t.toolName)return(0,v.jsx)(yl,{input:t.input,output:t.output,status:t.status},e.id);if("code_graph"===t.toolName)return(0,v.jsx)(yh,{input:t.input,output:t.output,status:t.status},e.id);if("complete_task"===t.toolName||"task_failed"===t.toolName)return(0,v.jsx)(yg,{toolName:t.toolName,input:t.input,output:t.output,status:t.status},e.id);let n="completed"!==t.status;return(0,v.jsxs)(oT,{defaultOpen:n,children:[(0,v.jsx)(oE,{type:r,state:function(e){switch(e){case"pending":case"streaming":default:return"input-streaming";case"running":return"input-available";case"completed":return"output-available";case"rejected":return"output-denied";case"error":return"output-error"}}(t.status),title:t.toolName}),(0,v.jsxs)(oP,{children:[(0,v.jsx)(oR,{input:t.input}),(e=>{let t=e.output,r=e.input;if("bash"===e.toolName)return(0,v.jsx)(xq,{input:e.input,output:e.output,status:e.status,terminalId:e.terminalId,liveOutput:e.liveOutput,className:"mt-2"});if("explore_agent"===e.toolName)return(0,v.jsx)(x1,{input:e.input,output:e.output,status:e.status,steps:e.exploreSteps,className:"mt-2"});if("todo"===e.toolName)return(0,v.jsx)(ye,{input:e.input,output:e.output,status:e.status,className:"mt-2"});if("load_skill"===e.toolName)return(0,v.jsx)(yn,{input:e.input,output:e.output,status:e.status,className:"mt-2"});if("linter"===e.toolName)return(0,v.jsx)(yl,{input:e.input,output:e.output,status:e.status,className:"mt-2"});if("code_graph"===e.toolName)return(0,v.jsx)(yh,{input:e.input,output:e.output,status:e.status,className:"mt-2"});if("write_file"===e.toolName&&r){let e=r.path||"file",n=r.mode||"full",s=e.split("/").pop()||"file",i=tf(e);if("str_replace"===n){let e=r.old_string||"",n=r.new_string||"";return(0,v.jsxs)("div",{className:"mt-2 max-w-full overflow-hidden space-y-2",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,v.jsx)(xp,{className:"size-4 text-muted-foreground"}),(0,v.jsx)("span",{className:"font-medium",children:s}),(0,v.jsx)(N.Badge,{variant:"secondary",className:"text-xs",children:"str_replace"})]}),(0,v.jsxs)("div",{className:"rounded-md border overflow-hidden",children:[(0,v.jsxs)("div",{className:"bg-red-500/10 border-b p-2",children:[(0,v.jsx)("div",{className:"text-xs text-red-500 mb-1",children:"- Remove:"}),(0,v.jsx)("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-words text-red-400",children:e.length>500?e.slice(0,500)+"...":e})]}),(0,v.jsxs)("div",{className:"bg-green-500/10 p-2",children:[(0,v.jsx)("div",{className:"text-xs text-green-500 mb-1",children:"+ Add:"}),(0,v.jsx)("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-words text-green-400",children:n.length>500?n.slice(0,500)+"...":n})]})]}),t&&(0,v.jsxs)("div",{className:`text-xs flex items-center gap-1 ${t.success?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:[(0,v.jsx)("span",{children:t.success?"✓":"✗"}),(0,v.jsx)("span",{children:t.success?`Replaced (${void 0!==t.lineDelta?(t.lineDelta>=0?"+":"")+t.lineDelta+" lines":"done"})`:t.error||"Failed"})]})]})}let a=r.content||"";return(0,v.jsxs)("div",{className:"mt-2 max-w-full overflow-hidden",children:[(0,v.jsxs)(oI,{children:[(0,v.jsxs)(oL,{children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(xp,{className:"size-4 text-muted-foreground shrink-0"}),(0,v.jsx)(oD,{className:"truncate",children:s}),(0,v.jsx)(oz,{className:"truncate text-xs hidden sm:block",children:e})]}),(0,v.jsx)(oO,{children:(0,v.jsx)(oB,{icon:xd.Copy,label:"Copy",onClick:()=>navigator.clipboard.writeText(a)})})]}),a&&(0,v.jsx)(oF,{className:"p-0 max-h-[300px] overflow-auto",children:(0,v.jsx)(o_,{code:a,language:i,showLineNumbers:!0,children:(0,v.jsx)(oN,{className:"sr-only",children:(0,v.jsx)(oS,{children:(0,v.jsx)(oC,{children:s})})})})})]}),t&&(0,v.jsxs)("div",{className:`mt-2 text-xs flex items-center gap-1 ${t.success?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:[(0,v.jsx)("span",{children:t.success?"✓":"✗"}),(0,v.jsx)("span",{children:t.success?`File ${t.action||"written"} successfully`:t.error||"Failed"})]})]})}if("read_file"===e.toolName&&t){let e=r?.path||"file",n=e.split("/").pop()||"file",s=t.imageData,i=t.mediaType;if(s&&i)return(0,v.jsx)("div",{className:"mt-2 max-w-full overflow-hidden",children:(0,v.jsxs)(oI,{children:[(0,v.jsx)(oL,{children:(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(gM,{className:"size-4 text-muted-foreground shrink-0"}),(0,v.jsx)(oD,{className:"truncate",children:n}),(0,v.jsx)(oz,{className:"truncate text-xs hidden sm:block",children:e})]})}),(0,v.jsx)(oF,{className:"p-0 max-h-[400px] overflow-auto",children:(0,v.jsx)("div",{className:"p-3 flex justify-center bg-muted/20",children:(0,v.jsx)("img",{src:`data:${i};base64,${s}`,alt:n,className:"max-w-full max-h-[350px] object-contain rounded"})})})]})});let a=t.content||JSON.stringify(t,null,2),o=tf(e);return(0,v.jsx)("div",{className:"mt-2 max-w-full overflow-hidden",children:(0,v.jsxs)(oI,{children:[(0,v.jsxs)(oL,{children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(xp,{className:"size-4 text-muted-foreground shrink-0"}),(0,v.jsx)(oD,{className:"truncate",children:n}),(0,v.jsx)(oz,{className:"truncate text-xs hidden sm:block",children:e})]}),(0,v.jsx)(oO,{children:(0,v.jsx)(oB,{icon:xd.Copy,label:"Copy",onClick:()=>navigator.clipboard.writeText(a)})})]}),(0,v.jsx)(oF,{className:"p-0 max-h-[300px] overflow-auto",children:(0,v.jsx)(o_,{code:a,language:o,showLineNumbers:!0,children:(0,v.jsx)(oN,{className:"sr-only",children:(0,v.jsx)(oS,{children:(0,v.jsx)(oC,{children:n})})})})})]})})}return t?(0,v.jsx)(oM,{output:(0,v.jsxs)("pre",{className:"text-xs overflow-x-auto max-w-full whitespace-pre-wrap break-words",children:[JSON.stringify(t,null,2).slice(0,500),JSON.stringify(t).length>500?"...":""]}),errorText:"error"===e.status?"Tool execution failed":void 0}):null})(t)]})]},e.id)}return null}),g&&!K&&!Y&&0===ee.length&&(0,v.jsxs)("div",{className:"flex gap-3 items-center",children:[(0,v.jsx)("div",{className:"relative overflow-hidden rounded-lg size-8 shadow-sm ring-1 ring-white/10 shrink-0",children:(0,v.jsx)("video",{src:"/sparkecode.mp4",autoPlay:!0,muted:!0,loop:!0,playsInline:!0,className:"absolute inset-0 size-full object-cover"})}),(0,v.jsx)("span",{className:"text-sm text-muted-foreground",children:"Thinking..."})]}),g&&(Z||Y)&&(0,v.jsxs)(mq,{isStreaming:Z,defaultOpen:!0,children:[(0,v.jsx)(mK,{}),(0,v.jsx)(mX,{children:Y})]}),g&&K&&(0,v.jsx)(aF,{from:"assistant",children:(0,v.jsxs)("div",{className:"flex gap-3",children:[(0,v.jsx)("div",{className:"relative overflow-hidden rounded-lg size-8 shadow-sm ring-1 ring-white/10 shrink-0",children:(0,v.jsx)("video",{src:"/sparkecode.mp4",autoPlay:!0,muted:!0,loop:!0,playsInline:!0,className:"absolute inset-0 size-full object-cover"})}),(0,v.jsx)("div",{className:"flex-1 min-w-0",children:(0,v.jsxs)(a$,{children:[(0,v.jsx)(aG,{children:K}),(0,v.jsx)("span",{className:"inline-block w-2 h-4 bg-primary animate-pulse ml-1"})]})})]})}),g&&ee.map(e=>"write_file"===e.toolName?(0,v.jsx)(xB,{input:e.input,output:e.output,status:e.status,streamingArgsText:e.streamingArgsText,liveContent:e.liveContent,liveOldString:e.liveOldString,liveNewString:e.liveNewString},e.toolCallId):"read_file"===e.toolName?(0,v.jsx)(xV,{input:e.input,output:e.output,status:e.status},e.toolCallId):"bash"===e.toolName?(0,v.jsx)(xq,{input:e.input,output:e.output,status:e.status,terminalId:e.terminalId,liveOutput:e.liveOutput},e.toolCallId):"explore_agent"===e.toolName?(0,v.jsx)(x1,{input:e.input,output:e.output,status:e.status,steps:e.exploreSteps},e.toolCallId):"todo"===e.toolName?(0,v.jsx)(ye,{input:e.input,output:e.output,status:e.status},e.toolCallId):"load_skill"===e.toolName?(0,v.jsx)(yn,{input:e.input,output:e.output,status:e.status},e.toolCallId):"linter"===e.toolName?(0,v.jsx)(yl,{input:e.input,output:e.output,status:e.status},e.toolCallId):"code_graph"===e.toolName?(0,v.jsx)(yh,{input:e.input,output:e.output,status:e.status},e.toolCallId):"complete_task"===e.toolName||"task_failed"===e.toolName?(0,v.jsx)(yg,{toolName:e.toolName,input:e.input,output:e.output,status:e.status},e.toolCallId):(0,v.jsxs)(oT,{defaultOpen:!0,children:[(0,v.jsx)(oE,{type:`tool-${e.toolName}`,state:"streaming"===e.status?"input-streaming":"input-available",title:e.toolName}),(0,v.jsxs)(oP,{children:[(0,v.jsx)(oR,{input:e.input}),(0,v.jsxs)("div",{className:"flex items-center gap-2 p-3 text-muted-foreground",children:[(0,v.jsx)(oY,{size:14}),(0,v.jsx)("span",{className:"text-sm",children:"streaming"===e.status?"Receiving...":"Executing..."})]})]})]},e.toolCallId)),g&&!K&&0===ee.length&&(0,v.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,v.jsx)(oY,{size:16}),(0,v.jsx)("span",{className:"text-sm",children:"Thinking..."})]})]}),(0,v.jsx)(V,{})]}),I&&(0,v.jsxs)("div",{className:"fixed bottom-28 right-4 w-80 max-h-80 overflow-auto border bg-background/95 shadow-lg rounded-md text-xs",children:[(0,v.jsx)("div",{className:"px-3 py-2 border-b font-mono text-muted-foreground",children:"SSE Debug"}),(0,v.jsxs)("div",{className:"px-3 py-2 space-y-1",children:[0===D.length&&0===O.length&&(0,v.jsx)("div",{className:"text-muted-foreground",children:"No events yet"}),D.map((e,t)=>(0,v.jsx)("div",{className:"font-mono",children:e},`evt-${t}`)),O.map((e,t)=>(0,v.jsx)("div",{className:"font-mono text-red-600",children:e},`err-${t}`))]})]}),(0,v.jsx)("div",{className:(0,k.cn)("border-t border-border/50 p-4 pb-6 bg-card/30",r&&"p-2 pb-2"),children:(0,v.jsxs)("div",{className:(0,k.cn)("max-w-3xl mx-auto",r&&"max-w-none"),children:[!r&&!ef&&0===l.length&&!K&&!g&&(0,v.jsx)(g7,{className:"mb-3",children:['Create a hello.txt file with "Hello, World!"',"List files in the current directory","Show the current git status"].map(e=>(0,v.jsx)(xe,{suggestion:e,onClick:e=>{d(e)}},e))}),y.length>0&&(0,v.jsxs)("div",{className:(0,k.cn)("mb-2 rounded-lg border border-border/60 bg-muted/20 overflow-hidden",r&&"mb-1"),children:[(0,v.jsxs)("button",{type:"button",onClick:()=>M(e=>!e),className:(0,k.cn)("w-full flex items-center justify-between px-3 py-1.5 text-xs text-muted-foreground hover:bg-muted/30 transition-colors",r&&"px-2 py-1"),children:[(0,v.jsxs)("div",{className:"flex items-center gap-1.5",children:[R?(0,v.jsx)(xN.ChevronDown,{className:"size-3"}):(0,v.jsx)(xS.default,{className:"size-3"}),(0,v.jsxs)("span",{className:"font-medium",children:[y.length," Queued"]})]}),(0,v.jsx)("span",{className:"text-[10px]",children:"Stop ^C"})]}),R&&(0,v.jsx)("div",{className:"border-t border-border/40 divide-y divide-border/30",children:y.map((e,t)=>(0,v.jsxs)("div",{className:(0,k.cn)("flex items-start gap-2 px-3 py-2 group",r&&"px-2 py-1.5 gap-1.5"),children:[(0,v.jsx)("span",{className:"text-[10px] text-muted-foreground/60 pt-0.5 w-4 shrink-0 text-center",children:t+1}),(0,v.jsxs)("div",{className:"flex-1 min-w-0",children:[_===e.id?(0,v.jsxs)("div",{className:"flex items-center gap-1",children:[(0,v.jsx)("input",{type:"text",value:E,onChange:e=>P(e.target.value),onKeyDown:t=>{"Enter"===t.key&&tc(e.id),"Escape"===t.key&&T(null)},className:(0,k.cn)("flex-1 bg-background border border-border rounded px-2 py-0.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary/30",r&&"text-[11px]"),autoFocus:!0}),(0,v.jsx)("button",{type:"button",onClick:()=>tc(e.id),className:"p-0.5 text-primary hover:text-primary/80",children:(0,v.jsx)(xg.Check,{className:"size-3"})})]}):(0,v.jsx)("p",{className:(0,k.cn)("text-xs text-foreground truncate",r&&"text-[11px]"),children:e.text||"Selected elements attached"}),e.attachments&&e.attachments.length>0&&(0,v.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[e.attachments.length," file",e.attachments.length>1?"s":""]}),e.selectedElements&&(0,v.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"+ selected elements"})]}),(0,v.jsxs)("div",{className:(0,k.cn)("flex items-center gap-0.5 shrink-0 transition-opacity",r?"opacity-100":"opacity-0 group-hover:opacity-100"),children:[(0,v.jsx)("button",{type:"button",onClick:()=>{T(e.id),P(e.text)},className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted/50",title:"Edit",children:(0,v.jsx)(xf.Pencil,{className:"size-3"})}),t>0&&(0,v.jsx)("button",{type:"button",onClick:()=>{var t;return t=e.id,void w(e=>{let r=e.findIndex(e=>e.id===t);if(-1===r)return e;let n=r-1;if(n<0||n>=e.length)return e;let s=[...e];return[s[r],s[n]]=[s[n],s[r]],s})},className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted/50",title:"Move up",children:(0,v.jsx)(xA,{className:"size-3"})}),(0,v.jsx)("button",{type:"button",onClick:()=>tu(e.id),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted/50",title:"Send now",children:(0,v.jsx)(xC,{className:"size-3"})}),(0,v.jsx)("button",{type:"button",onClick:()=>{var t;return t=e.id,void w(e=>e.filter(e=>e.id!==t))},className:"p-1 rounded text-muted-foreground hover:text-destructive hover:bg-muted/50",title:"Remove",children:(0,v.jsx)(x_.Trash2,{className:"size-3"})})]})]},e.id))})]}),(0,v.jsx)(y3,{children:(0,v.jsxs)(gU,{onSubmit:ta,className:"shadow-sm",globalDrop:!0,multiple:!0,children:[(0,v.jsxs)(gG,{children:[p&&(0,v.jsxs)("div",{className:(0,k.cn)("mb-2 flex items-center justify-between rounded-md border border-border/60 bg-muted/40 px-2 py-1 text-xs",r&&"mb-1"),children:[(0,v.jsxs)("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,v.jsx)("span",{className:"size-1.5 rounded-full bg-primary/70"}),(0,v.jsx)("span",{children:"Selected elements attached"})]}),(0,v.jsx)("button",{type:"button",onClick:()=>f(null),className:"rounded-sm p-1 text-muted-foreground hover:text-foreground","aria-label":"Remove selected elements",children:(0,v.jsx)(xk.X,{className:"size-3.5"})})]}),(0,v.jsx)(vn,{})]}),(0,v.jsx)(gW,{children:(0,v.jsxs)("div",{className:"relative w-full",children:[(0,v.jsx)(y4,{sessionId:t.id,value:u+(h?(!u||u.endsWith(" ")||u.endsWith("\n")?"":" ")+h:""),onChange:e=>{h&&m(""),d(e)},placeholder:g?"Type to queue a message...":"Ask SparkECoder... (@ to mention files, / for commands)",disabled:!1,autoFocus:!0,className:(0,k.cn)("min-h-[80px] focus:ring-2 focus:ring-primary/20 transition-all field-sizing-content max-h-48",h&&"caret-red-500",r&&"min-h-[40px] text-sm max-h-24")}),h&&(0,v.jsxs)("div",{className:"absolute bottom-2 right-2 flex items-center gap-1.5 text-xs text-red-500 bg-background/80 backdrop-blur-sm px-2 py-1 rounded-full",children:[(0,v.jsx)("span",{className:"size-2 bg-red-500 rounded-full animate-pulse"}),"Listening..."]})]})}),(0,v.jsxs)(gq,{className:r?"py-1":void 0,children:[!r&&(0,v.jsx)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:(0,v.jsx)("span",{className:"hidden sm:inline",children:"Type @ to mention files, / for commands"})}),(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsx)(yv,{size:"icon",className:"size-9",onTranscriptionChange:e=>{d(t=>{let r=t&&!t.endsWith(" ")&&!t.endsWith("\n");return t+(r?" ":"")+e})},onInterimTranscription:e=>{m(e)},disabled:g}),(0,v.jsx)(vs,{input:u+h,isRunning:g,onStop:to,hasExtraContent:!!(p&&p.trim())})]})]})]})})]})}),(0,v.jsx)(yw,{sessionId:t.id,frame:eG,metadata:eH,active:eU&&!eX,onDismiss:()=>{eY(!0),eW(!1)}})]})}var vo=e.i(482079),vl=e.i(461957);function vc({sessionId:e}){let[t,r]=(0,b.useState)(null),[n,s]=(0,b.useState)(""),[i,a]=(0,b.useState)(!1),o=(0,b.useCallback)(async()=>{let t=await (0,xt.getSession)(e);r(t?.pendingQuestion??null)},[e]);if((0,b.useEffect)(()=>{let e=!1,t=async()=>{e||await o()};t();let r=setInterval(t,3e3);return()=>{e=!0,clearInterval(r)}},[o]),!t)return null;let l=async()=>{if(n.trim()&&!i){a(!0);try{await (0,xt.answerAgentQuestion)(e,t.questionId,n.trim()),s(""),r(null),o()}finally{a(!1)}}};return(0,v.jsx)("div",{className:"border-b border-amber-500/40 bg-amber-500/5 px-4 py-3",children:(0,v.jsxs)("div",{className:"flex items-start gap-3 max-w-3xl mx-auto",children:[(0,v.jsx)(vo.MessageCircleQuestion,{className:"size-5 text-amber-500 shrink-0 mt-0.5"}),(0,v.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,v.jsx)("p",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:t.question}),t.context&&(0,v.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:t.context}),t.choices&&t.choices.length>0&&(0,v.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-2",children:t.choices.map(e=>(0,v.jsx)("button",{type:"button",onClick:()=>s(e),className:"text-xs px-2 py-1 rounded bg-amber-500/10 hover:bg-amber-500/20 text-amber-800 dark:text-amber-200",children:e},e))}),(0,v.jsxs)("div",{className:"flex gap-2 mt-2",children:[(0,v.jsx)("input",{type:"text",value:n,onChange:e=>s(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),l())},placeholder:"Type your answer…",className:"flex-1 px-3 py-1.5 text-sm rounded border border-border bg-background focus:outline-none focus:ring-2 focus:ring-amber-500/40",autoFocus:!0}),(0,v.jsx)(S.Button,{size:"sm",onClick:l,disabled:!n.trim()||i,children:i?(0,v.jsx)(vl.Loader2,{className:"size-3.5 animate-spin"}):"Answer"})]})]})]})})}function vu({params:e}){let{id:t}=(0,b.use)(e),r=(0,w.useRouter)(),[n,s]=(0,b.useState)(null),[i,a]=(0,b.useState)(!0),[o,l]=(0,b.useState)(null);return((0,b.useEffect)(()=>{!async function(){try{let e=await (0,xt.getSession)(t);if(!e)return void l("Session not found");s(e)}catch(e){console.error("Failed to load session:",e),l("Failed to load session")}finally{a(!1)}}()},[t]),i)?(0,v.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,v.jsx)(vl.Loader2,{className:"size-8 animate-spin text-muted-foreground"})}):o||!n?(0,v.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,v.jsxs)("div",{className:"text-center",children:[(0,v.jsx)("p",{className:"text-muted-foreground mb-4",children:o||"Session not found"}),(0,v.jsx)("button",{onClick:()=>r.push("/"),className:"text-primary hover:underline",children:"Go back home"})]})}):(0,v.jsxs)("div",{className:"flex flex-col h-full",children:[(0,v.jsx)(vc,{sessionId:n.id}),(0,v.jsx)("div",{className:"flex-1 min-h-0",children:(0,v.jsx)(va,{session:n})})]})}e.s(["default",()=>vu],330460)}]);
@@ -10,4 +10,4 @@ ${ez.updateCommand}`;ti(e),eF(!0)}catch(e){console.error("Failed to start update
10
10
  ${n.trim()}
11
11
  </sparkecoder-user-selected-elements>`;i=`${e}
12
12
 
13
- ${i}`}let a=i,o=r?.map(e=>({type:e.type,data:e.data,mediaType:e.mediaType,filename:e.filename})),l={id:`user-${Date.now()}`,type:"user-message",content:e||(s?"Selected elements attached":""),attachments:o};c(e=>[...e,l]),x(!0),G(!1),eb.current=!0,X(""),J(""),Q(!1),et([]),eh.current="",em.current="",ep.current=[],ex.current=(0,xt.runAgent)(t.id,a||"Please analyze the attached files.",tn,{onStreamId:e=>H(e),attachments:r})},ti=async(e,t)=>{let r=!!(p&&p.trim());if(e.trim()||t&&0!==t.length||r){if(g){let r;return void(r={id:`q-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,text:e,attachments:t,selectedElements:p},w(e=>[...e,r]),d(""),f(null))}d(""),f(null),await ts(e,t,p)}},ta=async e=>{let t=!!e.text?.trim(),r=!!e.files?.length,n=!!(p&&p.trim());if(!t&&!r&&!n)return;let s=[];if(r&&e.files.length>0){for(let t of e.files)if(t.url)try{let e=await fetch(t.url),r=await e.blob(),n=await new Promise(e=>{let t=new FileReader;t.onloadend=()=>e(t.result),t.readAsDataURL(r)}),i=t.mediaType||r.type||"application/octet-stream",a=i.startsWith("image/");s.push({type:a?"image":"file",data:n,mediaType:i,filename:t.filename})}catch(e){console.error("Failed to process attachment:",e)}}ti(e.text||"",s.length>0?s:void 0)},to=async()=>{try{await (0,xt.abortStream)(t.id)}catch(e){console.error("Failed to abort stream:",e)}if(ex.current&&(ex.current(),ex.current=null),em.current.trim()){let e={id:`reasoning-${Date.now()}`,type:"reasoning",content:em.current};c(t=>[...t,e])}if(eh.current.trim()){let e={id:`text-${Date.now()}`,type:"assistant-text",content:eh.current+" [stopped]"};c(t=>[...t,e])}X(""),J(""),Q(!1),et([]),H(null),eh.current="",em.current="",ep.current=[],ev.current=!1,x(!1),G(!1)},tl=(0,b.useRef)(ts);tl.current=ts;let tc=e=>{w(t=>t.map(t=>t.id===e?{...t,text:E}:t)),T(null),P("")},tu=async e=>{let t=y.find(t=>t.id===e);t&&(w(t=>t.filter(t=>t.id!==e)),g?(await to(),setTimeout(()=>{tl.current(t.text,t.attachments,t.selectedElements)},500)):tl.current(t.text,t.attachments,t.selectedElements))},td=async e=>{en(t=>t.filter(t=>t.id!==e.id));try{await (0,xt.approveExecution)(t.id,e.toolCallId)}catch(e){console.error("Failed to approve:",e)}},th=async e=>{en(t=>t.filter(t=>t.id!==e.id));try{await (0,xt.rejectExecution)(t.id,e.toolCallId,"User rejected")}catch(e){console.error("Failed to reject:",e)}},tm=async e=>{en(t=>t.filter(t=>t.id!==e.id));try{await (0,xt.approveExecution)(t.id,e.toolCallId);let r=await (0,xt.updateToolApproval)(t.id,e.toolName,!1,eE);eP(r.config||{})}catch(e){console.error("Failed to approve and disable:",e)}},tp=async(e,r)=>{try{let n=await (0,xt.updateToolApproval)(t.id,e,!r,eE);eP(n.config||{})}catch(e){console.error("Failed to update tool approval:",e)}},tf=e=>({ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",c:"c",cpp:"cpp",h:"c",hpp:"cpp",cs:"csharp",php:"php",swift:"swift",kt:"kotlin",scala:"scala",sh:"bash",bash:"bash",zsh:"bash",fish:"bash",ps1:"powershell",sql:"sql",html:"html",htm:"html",css:"css",scss:"scss",sass:"sass",less:"less",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",md:"markdown",markdown:"markdown",txt:"plaintext",toml:"toml",ini:"ini",cfg:"ini",conf:"ini",dockerfile:"dockerfile",makefile:"makefile"})[e.split(".").pop()?.toLowerCase()||""]||"plaintext";return(0,v.jsxs)("div",{className:(0,k.cn)("flex flex-col h-full bg-background min-w-0 overflow-x-hidden",r&&"embed-mode text-[13px]"),children:[r&&(0,v.jsxs)("div",{className:"border-b border-border/50 px-2 py-1.5 flex items-center justify-between bg-card/50",children:[(0,v.jsx)(S.Button,{size:"icon",variant:"ghost",onClick:o,className:"size-6",children:(0,v.jsx)(xb.PanelLeft,{className:"size-3.5"})}),(0,v.jsx)("span",{className:"text-[11px] text-muted-foreground truncate max-w-[120px] font-medium",children:eN||"Session"}),(0,v.jsx)(S.Button,{size:"icon",variant:"ghost",onClick:()=>eM(!0),className:"size-6",children:(0,v.jsx)(xx.Settings,{className:"size-3.5"})})]}),!r&&(0,v.jsxs)("div",{className:"border-b border-border/50 px-3 sm:px-4 py-2 flex items-center justify-between bg-card/50 backdrop-blur-sm",children:[(0,v.jsxs)("div",{className:"min-w-0 flex items-center gap-2 sm:gap-3",children:[(0,v.jsx)(vr,{}),(0,v.jsx)("div",{className:"flex items-center gap-1.5",children:eC?(0,v.jsxs)("form",{onSubmit:e=>{e.preventDefault(),e9()},className:"flex items-center gap-1",children:[(0,v.jsx)(gC.Input,{ref:eI,value:eN,onChange:e=>eS(e.target.value),onBlur:e9,className:"h-7 text-sm font-semibold w-40 px-2",placeholder:"Session name"}),(0,v.jsx)(S.Button,{type:"submit",size:"icon",variant:"ghost",className:"size-6 text-muted-foreground hover:text-foreground",children:(0,v.jsx)(xg.Check,{className:"size-3.5"})})]}):(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsxs)("button",{onClick:()=>eA(!0),className:"flex items-center gap-1.5 group hover:bg-muted/50 rounded px-1.5 py-0.5 -mx-1.5 transition-colors",children:[(0,v.jsx)("h2",{className:"font-semibold text-foreground truncate max-w-[200px]",children:eN||"Untitled Session"}),(0,v.jsx)(xf.Pencil,{className:"size-3 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity"})]})}),(0,v.jsx)(C.TooltipContent,{children:"Click to rename"})]})})}),t.workingDirectory?(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded-md bg-muted/30 text-xs text-muted-foreground max-w-[200px]",children:[(0,v.jsx)(xv.FolderOpen,{className:"size-3.5 shrink-0"}),(0,v.jsx)("span",{className:"truncate font-mono",children:t.workingDirectory.split("/").pop()||t.workingDirectory})]})}),(0,v.jsx)(C.TooltipContent,{side:"bottom",className:"max-w-md",children:(0,v.jsx)("p",{className:"font-mono text-xs",children:t.workingDirectory})})]})}):null]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[eQ.filter(e=>"browser-recording"===e.category&&e.downloadUrl).map(e=>(0,v.jsx)(yk,{fileName:e.fileName,downloadUrl:e.downloadUrl,sizeBytes:e.sizeBytes,createdAt:e.createdAt},e.id)),W&&(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsxs)(N.Badge,{variant:"outline",className:"gap-1.5 text-xs border-emerald-500/30 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 cursor-help",children:[(0,v.jsx)("span",{className:"size-1.5 rounded-full bg-current animate-pulse"}),"Watching"]})}),(0,v.jsx)(C.TooltipContent,{children:"Watching stream from another client"})]})}),(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsx)(N.Badge,{variant:g?"default":"secondary",className:`cursor-help ${g?"bg-primary/90":""}`,children:g?W?"streaming":"running":t.status})}),(0,v.jsx)(C.TooltipContent,{children:g?W?"Receiving streamed response":"Agent is processing":`Session is ${t.status}`})]})}),(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsx)(S.Button,{size:"icon",variant:"ghost",className:"size-7 hover:bg-accent transition-colors",onClick:()=>eM(!0),children:(0,v.jsx)(xx.Settings,{className:"size-4"})})}),(0,v.jsx)(C.TooltipContent,{children:"Session Settings"})]})}),(0,v.jsxs)(go,{children:[(0,v.jsx)(gl,{asChild:!0,children:(0,v.jsx)(S.Button,{size:"icon",variant:"ghost",className:"size-7 hover:bg-accent transition-colors",children:(0,v.jsx)(xP,{className:"size-4"})})}),(0,v.jsxs)(gc,{align:"end",className:"w-52",children:[(0,v.jsxs)(gu,{onClick:()=>{eY(!1),(0,xt.getBrowserStreamStatus)(t.id).then(e=>{e?.active?(eW(!0),console.log("[browser] Reconnecting PIP — stream active")):console.log("[browser] No active browser stream")})},children:[(0,v.jsx)(gX,{className:"size-4 mr-2"}),"Open Browser PIP"]}),(0,v.jsxs)(gu,{onClick:async()=>{e3(await (0,xt.getBrowserRecordings)(t.id)),e2(!0)},children:[(0,v.jsx)(gZ,{className:"size-4 mr-2"}),"Browser Recordings"]}),(0,v.jsxs)(gu,{onClick:async()=>{e6("copying");try{let e=await vi(t.id);await navigator.clipboard.writeText(e),e6("copied"),console.log(`[debug-dump] copied ${e.length.toLocaleString()} chars to clipboard for session ${t.id}`),setTimeout(()=>e6("idle"),2500)}catch(e){console.error("[debug-dump] failed:",e),e6("error"),setTimeout(()=>e6("idle"),2500)}},children:["copying"===e4?(0,v.jsx)(xh.RefreshCw,{className:"size-4 mr-2 animate-spin"}):"copied"===e4?(0,v.jsx)(xg.Check,{className:"size-4 mr-2 text-green-500"}):"error"===e4?(0,v.jsx)(xm,{className:"size-4 mr-2 text-red-500"}):(0,v.jsx)(xR,{className:"size-4 mr-2"}),"copying"===e4?"Gathering…":"copied"===e4?"Copied to clipboard":"error"===e4?"Failed — see console":"Copy debug JSON"]})]})]})]})]}),(0,v.jsx)(pb.Dialog,{open:eR,onOpenChange:eM,children:(0,v.jsxs)(pb.DialogContent,{className:"sm:max-w-md",children:[(0,v.jsx)(pb.DialogHeader,{children:(0,v.jsxs)(pb.DialogTitle,{className:"flex items-center gap-2",children:[(0,v.jsx)("div",{className:"size-8 rounded-lg bg-muted flex items-center justify-center",children:(0,v.jsx)(xx.Settings,{className:"size-4"})}),"Session Settings"]})}),(0,v.jsxs)("div",{className:"space-y-4 pt-2",children:[(0,v.jsxs)("div",{className:"space-y-2",children:[(0,v.jsx)(xL.Label,{className:"text-sm font-medium",children:"Model"}),(0,v.jsxs)(oh.Select,{value:ej,onValueChange:e8,disabled:g,children:[(0,v.jsx)(oh.SelectTrigger,{className:"w-full",children:(0,v.jsx)(oh.SelectValue,{placeholder:"Select model"})}),(0,v.jsx)(oh.SelectContent,{children:e_?.availableModels.map(e=>(0,v.jsx)(oh.SelectItem,{value:e.id,children:(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsx)("span",{children:e.name}),(0,v.jsx)("span",{className:"text-xs text-muted-foreground",children:e.provider})]})},e.id))})]}),g&&(0,v.jsx)("p",{className:"text-xs text-muted-foreground",children:"Cannot change model while agent is running"})]}),(0,v.jsxs)("div",{className:"space-y-2",children:[(0,v.jsx)(xL.Label,{className:"flex items-center gap-2 text-sm font-medium",children:"Tool Approvals"}),(0,v.jsx)("p",{className:"text-xs text-muted-foreground -mt-0.5",children:"Toggle on to require approval before tool executes"}),(0,v.jsx)("div",{className:"space-y-1 rounded-lg border p-2.5 bg-muted/30",children:e_?.availableTools.map(e=>{var t;let r=(t=e.id,eE.toolApprovals?.[t]!==void 0?eE.toolApprovals[t]:"bash"===t);return(0,v.jsxs)("div",{className:"flex items-center justify-between py-1.5 hover:bg-muted/50 rounded px-2 -mx-1 transition-colors",children:[(0,v.jsxs)("div",{className:"space-y-0",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsx)("span",{className:"text-sm font-medium",children:e.name}),e.dangerous&&(0,v.jsx)("span",{className:"text-[10px] bg-amber-500/20 text-amber-600 dark:text-amber-400 px-1.5 py-0.5 rounded font-medium",children:"risky"})]}),(0,v.jsx)("p",{className:"text-[11px] text-muted-foreground",children:e.description})]}),(0,v.jsx)(xI.Switch,{checked:r,onCheckedChange:()=>tp(e.id,r)})]},e.id)})})]}),(0,v.jsx)("p",{className:"text-xs text-muted-foreground",children:"These settings only apply to this session. Changes take effect for future tool calls."})]})]})}),(0,v.jsx)(pb.Dialog,{open:e1,onOpenChange:e2,children:(0,v.jsxs)(pb.DialogContent,{className:"max-w-2xl w-full p-0 overflow-hidden rounded-xl",children:[(0,v.jsx)(pb.DialogHeader,{className:"px-5 pt-5 pb-3",children:(0,v.jsxs)(pb.DialogTitle,{className:"flex items-center gap-2 text-sm font-medium",children:[(0,v.jsx)("div",{className:"flex items-center justify-center size-6 rounded-lg bg-violet-500/10 dark:bg-violet-400/10",children:(0,v.jsx)(gZ,{className:"size-3.5 text-violet-600 dark:text-violet-400"})}),"Browser Recordings"]})}),(0,v.jsx)("div",{className:"px-5 pb-5 space-y-3",children:0===e5.length?(0,v.jsx)("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No browser recordings for this session"}):e5.map(e=>(0,v.jsxs)("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-muted/30 hover:bg-muted/50 transition-colors",children:[(0,v.jsx)("div",{className:"flex items-center justify-center size-10 rounded-lg bg-violet-500/10 dark:bg-violet-400/10 shrink-0",children:(0,v.jsx)(xC,{className:"size-4 text-violet-600 dark:text-violet-400 ml-0.5"})}),(0,v.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,v.jsx)("p",{className:"text-sm font-medium truncate",children:e.fileName}),(0,v.jsxs)("p",{className:"text-xs text-muted-foreground",children:[e.createdAt&&new Date(e.createdAt).toLocaleString(),null!=e.sizeBytes&&` \xb7 ${e.sizeBytes>1048576?`${(e.sizeBytes/1048576).toFixed(1)} MB`:`${(e.sizeBytes/1024).toFixed(0)} KB`}`]})]}),e.downloadUrl&&(0,v.jsxs)(S.Button,{size:"sm",variant:"outline",className:"shrink-0",onClick:()=>window.open(e.downloadUrl,"_blank"),children:[(0,v.jsx)(xC,{className:"size-3 mr-1"}),"Watch"]})]},e.id))})]})}),!r&&ez?.updateAvailable&&!eB&&(0,v.jsxs)("div",{className:"px-4 py-2 border-b border-amber-500/30 bg-amber-500/10 flex items-center justify-between gap-3",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(xj,{className:"size-4 text-amber-600 dark:text-amber-400 shrink-0"}),(0,v.jsxs)("span",{className:"text-sm text-amber-700 dark:text-amber-300",children:["Update available: ",(0,v.jsxs)("strong",{children:["v",ez.latestVersion]}),(0,v.jsxs)("span",{className:"text-amber-600/70 dark:text-amber-400/70 ml-1",children:["(current: v",ez.currentVersion,")"]})]})]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,v.jsx)(S.Button,{size:"sm",variant:"outline",className:"h-7 text-xs border-amber-500/50 bg-amber-500/20 hover:bg-amber-500/30 text-amber-700 dark:text-amber-300",onClick:e7,disabled:e$,children:e$?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(xh.RefreshCw,{className:"size-3 mr-1.5 animate-spin"}),"Creating..."]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(xj,{className:"size-3 mr-1.5"}),"Update Now"]})}),(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsx)(S.Button,{size:"icon",variant:"ghost",className:"size-6 text-amber-600 dark:text-amber-400 hover:bg-amber-500/20",onClick:()=>{eF(!0),ez?.latestVersion&&localStorage.setItem("sparkecoder-dismissed-version",ez.latestVersion)},children:(0,v.jsx)(xk.X,{className:"size-3.5"})})}),(0,v.jsx)(C.TooltipContent,{children:"Dismiss (won't show again for this version)"})]})})]})]}),!r&&(es&&es.todos&&es.todos.length>0||ea.length>0)&&(0,v.jsx)("div",{className:"px-4 py-2 border-b border-border/50 bg-muted/20",children:(0,v.jsx)(xo,{todosData:es,plans:ea})}),er.length>0&&(0,v.jsx)("div",{className:(0,k.cn)("p-4 border-b border-border space-y-3",r&&"p-2 space-y-2"),children:er.map(e=>{let t=e.input;return(0,v.jsxs)(oG,{approval:{id:e.id,approved:!1},state:"approval-requested",children:[(0,v.jsx)(oq,{children:(0,v.jsxs)("div",{className:"flex items-start gap-3",children:[(0,v.jsx)("div",{className:"size-8 rounded-lg bg-amber-500/20 flex items-center justify-center shrink-0",children:(0,v.jsx)(xm,{className:"size-4 text-amber-500"})}),(0,v.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,v.jsx)("p",{className:"font-medium text-sm",children:"Approval Required"}),(0,v.jsx)("p",{className:"text-sm text-muted-foreground mt-0.5",children:(0,v.jsx)("code",{className:"bg-muted px-1.5 py-0.5 rounded font-mono text-foreground",children:e.toolName})}),(0,v.jsx)("div",{className:"mt-3 rounded-lg border bg-muted/30 overflow-hidden",children:Object.entries(t).map(([e,t])=>(0,v.jsxs)("div",{className:"flex border-b border-border/50 last:border-b-0",children:[(0,v.jsx)("div",{className:"px-3 py-2 bg-muted/50 text-xs font-medium text-muted-foreground w-24 shrink-0",children:e}),(0,v.jsx)("div",{className:"px-3 py-2 text-xs font-mono flex-1 min-w-0 overflow-auto max-h-24",children:"string"==typeof t?(0,v.jsx)("span",{className:"whitespace-pre-wrap break-words",children:t}):(0,v.jsx)("span",{className:"text-muted-foreground",children:JSON.stringify(t)})})]},e))})]})]})}),(0,v.jsxs)(oH,{children:[(0,v.jsx)(oK,{variant:"outline",onClick:()=>th(e),children:"Reject"}),(0,v.jsx)(oK,{variant:"ghost",onClick:()=>tm(e),className:"text-muted-foreground hover:text-foreground",children:"Always Allow"}),(0,v.jsx)(oK,{variant:"default",onClick:()=>td(e),children:"Approve"})]})]},e.id)})}),(0,v.jsxs)(B,{className:(0,k.cn)("flex-1 p-4",r&&"p-2"),children:[(0,v.jsxs)(F,{className:(0,k.cn)("max-w-3xl mx-auto w-full",r&&"max-w-none"),children:[t.config?.task?.enabled&&(s="running"===(n=t.config.task).status,i="completed"===n.status,a="failed"===n.status,(0,v.jsxs)("div",{className:(0,k.cn)("mb-4 rounded-lg border px-3.5 py-2.5 flex items-center gap-2.5 text-sm transition-colors",i&&"border-emerald-500/30 bg-emerald-500/5",a&&"border-red-500/30 bg-red-500/5",s&&"border-blue-500/30 bg-blue-500/5"),children:[(0,v.jsx)(xE.ListChecks,{className:(0,k.cn)("size-4 shrink-0",i&&"text-emerald-500",a&&"text-red-500",s&&"text-blue-500")}),(0,v.jsx)("span",{className:"font-medium truncate",children:t.name||"Task"}),(0,v.jsx)("span",{className:(0,k.cn)("text-xs shrink-0",i&&"text-emerald-600 dark:text-emerald-400",a&&"text-red-600 dark:text-red-400",s&&"text-blue-600 dark:text-blue-400 animate-pulse"),children:s?"Running":i?"Completed":"Failed"}),null!=n.iterations&&(0,v.jsxs)("span",{className:"text-xs text-muted-foreground ml-auto tabular-nums shrink-0",children:[n.iterations," iter."]}),a&&n.error&&(0,v.jsxs)("span",{className:"text-xs text-red-500 truncate ml-1",title:n.error,children:["— ",n.error]})]})),ef&&(0,v.jsx)("div",{className:"flex justify-center py-12",children:(0,v.jsx)(oY,{size:24})}),!ef&&0===l.length&&!K&&(0,v.jsx)($,{icon:(0,v.jsxs)("div",{className:"relative overflow-hidden rounded-2xl size-16 shadow-lg ring-1 ring-white/10",children:[(0,v.jsx)(j.default,{src:"/sparke-coder.png",alt:"SparkECoder",width:64,height:64,className:"absolute inset-0 size-full object-cover",priority:!0}),g&&(0,v.jsx)("video",{src:"/sparkecode.mp4",autoPlay:!0,muted:!0,loop:!0,playsInline:!0,className:"absolute inset-0 size-full object-cover"})]}),title:"Start a conversation",description:"Ask SparkECoder to help you with coding tasks"}),l.filter(e=>{if("tool-call"===e.type&&e.toolCall){if(er.some(t=>t.toolCallId===e.toolCall?.toolCallId))return!1;let t=ee.some(t=>t.toolCallId===e.toolCall?.toolCallId),r=ee.some(t=>t.toolCallId.startsWith(`${e.toolCall?.toolName}_pending_`)&&("streaming"===t.status||"running"===t.status));if(t||r)return!1}return!0}).map(e=>{if("user-message"===e.type){let t,r,n,s=e.content?function(e){let t=e.match(/^\[([A-Z]+)(?:\s+([^\]]*))?\]\s*([\s\S]*)$/);if(!t)return{pill:null,rest:e};let r=t[1];return["WEB","SLACK","SYSTEM","SCHEDULE","WEBHOOK"].includes(r)?{pill:{channel:r,detail:t[2]?.trim()||void 0},rest:t[3]}:{pill:null,rest:e}}(e.content):{pill:null,rest:e.content||""};if(s.pill&&y7.has(s.pill.channel))return(0,v.jsx)(vt,{pill:s.pill,body:s.rest},e.id);let i=!!s.pill&&"WEB"!==s.pill.channel,a=void 0!==e.messageSequence&&el.some(t=>t.messageSequence===e.messageSequence);return(0,v.jsxs)("div",{className:i?"flex flex-col items-end gap-1":void 0,children:[i&&s.pill&&(0,v.jsxs)("div",{className:`inline-flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide px-2 py-0.5 rounded-md border self-end ${y8[s.pill.channel]||"bg-muted text-muted-foreground border-border"}`,children:[(0,v.jsx)("span",{children:s.pill.channel}),s.pill.detail&&(0,v.jsx)("span",{className:"font-normal normal-case opacity-80",children:s.pill.detail})]}),(0,v.jsxs)(aF,{from:"user",children:[(0,v.jsxs)(a$,{children:[e.attachments&&e.attachments.length>0&&(0,v.jsx)("div",{className:"flex flex-wrap gap-2 mb-2",children:e.attachments.map((e,t)=>(0,v.jsx)("div",{className:"relative",children:"image"===e.type?(0,v.jsx)("div",{className:"relative rounded-lg overflow-hidden border border-border/50 max-w-[200px]",children:(0,v.jsx)("img",{src:e.data.startsWith("data:")?e.data:`data:${e.mediaType||"image/png"};base64,${e.data}`,alt:e.filename||"Image attachment",className:"max-w-full h-auto max-h-[150px] object-contain"})}):(0,v.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-muted/50 border border-border/50",children:[(0,v.jsx)(xw,{className:"h-4 w-4 text-muted-foreground"}),(0,v.jsx)("span",{className:"text-sm text-muted-foreground truncate max-w-[150px]",children:e.filename||"File"})]})},t))}),e.content&&(r=(t=s.rest).replace(y6,"").trim(),n=function(e){let t=e.match(/<devtools-context>([\s\S]*?)<\/devtools-context>/);if(!t)return null;let r=t[1],n=r.match(/<page\s+url="([^"]*)"\s+path="([^"]*)"\s+name="([^"]*)"/),s=r.match(/<viewport\s+width="([^"]*)"\s+height="([^"]*)"(?:\s+dpr="([^"]*)")?/);return n?{url:n[1],path:n[2],pageName:n[3],viewportWidth:s?.[1],viewportHeight:s?.[2],dpr:s?.[3]}:null}(t),(0,v.jsxs)(v.Fragment,{children:[!i&&s.pill&&(0,v.jsx)(y9,{...s.pill}),r&&(0,v.jsx)("p",{className:"whitespace-pre-wrap",children:r}),n&&(0,v.jsxs)("div",{className:"flex items-center gap-1.5 mt-1.5 text-[11px] text-muted-foreground/60",children:[(0,v.jsx)(xT,{className:"h-3 w-3"}),(0,v.jsx)("span",{children:n.path}),n.viewportWidth&&n.viewportHeight&&(0,v.jsxs)("span",{className:"text-muted-foreground/40",children:[n.viewportWidth,"x",n.viewportHeight]})]})]}))]}),a&&!g&&(0,v.jsx)(aV,{className:"justify-end mt-1",children:(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsxs)(S.Button,{variant:"ghost",size:"sm",onClick:()=>tr(e.messageSequence,e.content),disabled:eu,className:"h-6 px-2 text-xs text-muted-foreground hover:text-destructive gap-1",children:[(0,v.jsx)(xy,{className:"h-3 w-3"}),"Revert"]})}),(0,v.jsx)(C.TooltipContent,{children:(0,v.jsx)("p",{children:"Revert to before this message (undo all changes after)"})})]})})})]})]},e.id)}if("reasoning"===e.type)return(0,v.jsxs)(mq,{isStreaming:!1,defaultOpen:!1,children:[(0,v.jsx)(mK,{}),(0,v.jsx)(mX,{children:e.content||""})]},e.id);if("assistant-text"===e.type)return(0,v.jsx)(aF,{from:"assistant",children:(0,v.jsxs)("div",{className:"flex gap-3",children:[(0,v.jsx)("div",{className:"relative overflow-hidden rounded-lg size-8 shadow-sm ring-1 ring-white/10 shrink-0",children:(0,v.jsx)(j.default,{src:"/sparke-coder.png",alt:"SparkECoder",width:32,height:32,className:"absolute inset-0 size-full object-cover"})}),(0,v.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,v.jsx)(a$,{children:(0,v.jsx)(aG,{children:e.content||""})}),(0,v.jsx)(aV,{children:(0,v.jsx)(aU,{label:"Copy",onClick:()=>navigator.clipboard.writeText(e.content||""),children:(0,v.jsx)(xd.Copy,{className:"size-3"})})})]})]})},e.id);if("tool-call"===e.type&&e.toolCall){let t=e.toolCall,r=`tool-${t.toolName}`;if("messenger"===t.toolName&&t.input?.action==="post")return(0,v.jsx)(ve,{input:t.input,output:t.output,status:t.status},e.id);if("write_file"===t.toolName)return(0,v.jsx)(xB,{input:t.input,output:t.output,status:t.status,streamingArgsText:t.streamingArgsText,liveContent:t.liveContent,liveOldString:t.liveOldString,liveNewString:t.liveNewString},e.id);if("read_file"===t.toolName)return(0,v.jsx)(xV,{input:t.input,output:t.output,status:t.status},e.id);if("bash"===t.toolName)return(0,v.jsx)(xq,{input:t.input,output:t.output,status:t.status,terminalId:t.terminalId,liveOutput:t.liveOutput},e.id);if("explore_agent"===t.toolName)return(0,v.jsx)(x1,{input:t.input,output:t.output,status:t.status,steps:t.exploreSteps},e.id);if("todo"===t.toolName)return(0,v.jsx)(ye,{input:t.input,output:t.output,status:t.status},e.id);if("load_skill"===t.toolName)return(0,v.jsx)(yn,{input:t.input,output:t.output,status:t.status},e.id);if("linter"===t.toolName)return(0,v.jsx)(yl,{input:t.input,output:t.output,status:t.status},e.id);if("code_graph"===t.toolName)return(0,v.jsx)(yh,{input:t.input,output:t.output,status:t.status},e.id);if("complete_task"===t.toolName||"task_failed"===t.toolName)return(0,v.jsx)(yg,{toolName:t.toolName,input:t.input,output:t.output,status:t.status},e.id);let n="completed"!==t.status;return(0,v.jsxs)(oT,{defaultOpen:n,children:[(0,v.jsx)(oE,{type:r,state:function(e){switch(e){case"pending":case"streaming":default:return"input-streaming";case"running":return"input-available";case"completed":return"output-available";case"rejected":return"output-denied";case"error":return"output-error"}}(t.status),title:t.toolName}),(0,v.jsxs)(oP,{children:[(0,v.jsx)(oR,{input:t.input}),(e=>{let t=e.output,r=e.input;if("bash"===e.toolName)return(0,v.jsx)(xq,{input:e.input,output:e.output,status:e.status,terminalId:e.terminalId,liveOutput:e.liveOutput,className:"mt-2"});if("explore_agent"===e.toolName)return(0,v.jsx)(x1,{input:e.input,output:e.output,status:e.status,steps:e.exploreSteps,className:"mt-2"});if("todo"===e.toolName)return(0,v.jsx)(ye,{input:e.input,output:e.output,status:e.status,className:"mt-2"});if("load_skill"===e.toolName)return(0,v.jsx)(yn,{input:e.input,output:e.output,status:e.status,className:"mt-2"});if("linter"===e.toolName)return(0,v.jsx)(yl,{input:e.input,output:e.output,status:e.status,className:"mt-2"});if("code_graph"===e.toolName)return(0,v.jsx)(yh,{input:e.input,output:e.output,status:e.status,className:"mt-2"});if("write_file"===e.toolName&&r){let e=r.path||"file",n=r.mode||"full",s=e.split("/").pop()||"file",i=tf(e);if("str_replace"===n){let e=r.old_string||"",n=r.new_string||"";return(0,v.jsxs)("div",{className:"mt-2 max-w-full overflow-hidden space-y-2",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,v.jsx)(xp,{className:"size-4 text-muted-foreground"}),(0,v.jsx)("span",{className:"font-medium",children:s}),(0,v.jsx)(N.Badge,{variant:"secondary",className:"text-xs",children:"str_replace"})]}),(0,v.jsxs)("div",{className:"rounded-md border overflow-hidden",children:[(0,v.jsxs)("div",{className:"bg-red-500/10 border-b p-2",children:[(0,v.jsx)("div",{className:"text-xs text-red-500 mb-1",children:"- Remove:"}),(0,v.jsx)("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-words text-red-400",children:e.length>500?e.slice(0,500)+"...":e})]}),(0,v.jsxs)("div",{className:"bg-green-500/10 p-2",children:[(0,v.jsx)("div",{className:"text-xs text-green-500 mb-1",children:"+ Add:"}),(0,v.jsx)("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-words text-green-400",children:n.length>500?n.slice(0,500)+"...":n})]})]}),t&&(0,v.jsxs)("div",{className:`text-xs flex items-center gap-1 ${t.success?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:[(0,v.jsx)("span",{children:t.success?"✓":"✗"}),(0,v.jsx)("span",{children:t.success?`Replaced (${void 0!==t.lineDelta?(t.lineDelta>=0?"+":"")+t.lineDelta+" lines":"done"})`:t.error||"Failed"})]})]})}let a=r.content||"";return(0,v.jsxs)("div",{className:"mt-2 max-w-full overflow-hidden",children:[(0,v.jsxs)(oI,{children:[(0,v.jsxs)(oL,{children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(xp,{className:"size-4 text-muted-foreground shrink-0"}),(0,v.jsx)(oD,{className:"truncate",children:s}),(0,v.jsx)(oz,{className:"truncate text-xs hidden sm:block",children:e})]}),(0,v.jsx)(oO,{children:(0,v.jsx)(oB,{icon:xd.Copy,label:"Copy",onClick:()=>navigator.clipboard.writeText(a)})})]}),a&&(0,v.jsx)(oF,{className:"p-0 max-h-[300px] overflow-auto",children:(0,v.jsx)(o_,{code:a,language:i,showLineNumbers:!0,children:(0,v.jsx)(oN,{className:"sr-only",children:(0,v.jsx)(oS,{children:(0,v.jsx)(oC,{children:s})})})})})]}),t&&(0,v.jsxs)("div",{className:`mt-2 text-xs flex items-center gap-1 ${t.success?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:[(0,v.jsx)("span",{children:t.success?"✓":"✗"}),(0,v.jsx)("span",{children:t.success?`File ${t.action||"written"} successfully`:t.error||"Failed"})]})]})}if("read_file"===e.toolName&&t){let e=r?.path||"file",n=e.split("/").pop()||"file",s=t.imageData,i=t.mediaType;if(s&&i)return(0,v.jsx)("div",{className:"mt-2 max-w-full overflow-hidden",children:(0,v.jsxs)(oI,{children:[(0,v.jsx)(oL,{children:(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(gM,{className:"size-4 text-muted-foreground shrink-0"}),(0,v.jsx)(oD,{className:"truncate",children:n}),(0,v.jsx)(oz,{className:"truncate text-xs hidden sm:block",children:e})]})}),(0,v.jsx)(oF,{className:"p-0 max-h-[400px] overflow-auto",children:(0,v.jsx)("div",{className:"p-3 flex justify-center bg-muted/20",children:(0,v.jsx)("img",{src:`data:${i};base64,${s}`,alt:n,className:"max-w-full max-h-[350px] object-contain rounded"})})})]})});let a=t.content||JSON.stringify(t,null,2),o=tf(e);return(0,v.jsx)("div",{className:"mt-2 max-w-full overflow-hidden",children:(0,v.jsxs)(oI,{children:[(0,v.jsxs)(oL,{children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(xp,{className:"size-4 text-muted-foreground shrink-0"}),(0,v.jsx)(oD,{className:"truncate",children:n}),(0,v.jsx)(oz,{className:"truncate text-xs hidden sm:block",children:e})]}),(0,v.jsx)(oO,{children:(0,v.jsx)(oB,{icon:xd.Copy,label:"Copy",onClick:()=>navigator.clipboard.writeText(a)})})]}),(0,v.jsx)(oF,{className:"p-0 max-h-[300px] overflow-auto",children:(0,v.jsx)(o_,{code:a,language:o,showLineNumbers:!0,children:(0,v.jsx)(oN,{className:"sr-only",children:(0,v.jsx)(oS,{children:(0,v.jsx)(oC,{children:n})})})})})]})})}return t?(0,v.jsx)(oM,{output:(0,v.jsxs)("pre",{className:"text-xs overflow-x-auto max-w-full whitespace-pre-wrap break-words",children:[JSON.stringify(t,null,2).slice(0,500),JSON.stringify(t).length>500?"...":""]}),errorText:"error"===e.status?"Tool execution failed":void 0}):null})(t)]})]},e.id)}return null}),g&&!K&&!Y&&0===ee.length&&(0,v.jsxs)("div",{className:"flex gap-3 items-center",children:[(0,v.jsx)("div",{className:"relative overflow-hidden rounded-lg size-8 shadow-sm ring-1 ring-white/10 shrink-0",children:(0,v.jsx)("video",{src:"/sparkecode.mp4",autoPlay:!0,muted:!0,loop:!0,playsInline:!0,className:"absolute inset-0 size-full object-cover"})}),(0,v.jsx)("span",{className:"text-sm text-muted-foreground",children:"Thinking..."})]}),g&&(Z||Y)&&(0,v.jsxs)(mq,{isStreaming:Z,defaultOpen:!0,children:[(0,v.jsx)(mK,{}),(0,v.jsx)(mX,{children:Y})]}),g&&K&&(0,v.jsx)(aF,{from:"assistant",children:(0,v.jsxs)("div",{className:"flex gap-3",children:[(0,v.jsx)("div",{className:"relative overflow-hidden rounded-lg size-8 shadow-sm ring-1 ring-white/10 shrink-0",children:(0,v.jsx)("video",{src:"/sparkecode.mp4",autoPlay:!0,muted:!0,loop:!0,playsInline:!0,className:"absolute inset-0 size-full object-cover"})}),(0,v.jsx)("div",{className:"flex-1 min-w-0",children:(0,v.jsxs)(a$,{children:[(0,v.jsx)(aG,{children:K}),(0,v.jsx)("span",{className:"inline-block w-2 h-4 bg-primary animate-pulse ml-1"})]})})]})}),g&&ee.map(e=>"write_file"===e.toolName?(0,v.jsx)(xB,{input:e.input,output:e.output,status:e.status,streamingArgsText:e.streamingArgsText,liveContent:e.liveContent,liveOldString:e.liveOldString,liveNewString:e.liveNewString},e.toolCallId):"read_file"===e.toolName?(0,v.jsx)(xV,{input:e.input,output:e.output,status:e.status},e.toolCallId):"bash"===e.toolName?(0,v.jsx)(xq,{input:e.input,output:e.output,status:e.status,terminalId:e.terminalId,liveOutput:e.liveOutput},e.toolCallId):"explore_agent"===e.toolName?(0,v.jsx)(x1,{input:e.input,output:e.output,status:e.status,steps:e.exploreSteps},e.toolCallId):"todo"===e.toolName?(0,v.jsx)(ye,{input:e.input,output:e.output,status:e.status},e.toolCallId):"load_skill"===e.toolName?(0,v.jsx)(yn,{input:e.input,output:e.output,status:e.status},e.toolCallId):"linter"===e.toolName?(0,v.jsx)(yl,{input:e.input,output:e.output,status:e.status},e.toolCallId):"code_graph"===e.toolName?(0,v.jsx)(yh,{input:e.input,output:e.output,status:e.status},e.toolCallId):"complete_task"===e.toolName||"task_failed"===e.toolName?(0,v.jsx)(yg,{toolName:e.toolName,input:e.input,output:e.output,status:e.status},e.toolCallId):(0,v.jsxs)(oT,{defaultOpen:!0,children:[(0,v.jsx)(oE,{type:`tool-${e.toolName}`,state:"streaming"===e.status?"input-streaming":"input-available",title:e.toolName}),(0,v.jsxs)(oP,{children:[(0,v.jsx)(oR,{input:e.input}),(0,v.jsxs)("div",{className:"flex items-center gap-2 p-3 text-muted-foreground",children:[(0,v.jsx)(oY,{size:14}),(0,v.jsx)("span",{className:"text-sm",children:"streaming"===e.status?"Receiving...":"Executing..."})]})]})]},e.toolCallId)),g&&!K&&0===ee.length&&(0,v.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,v.jsx)(oY,{size:16}),(0,v.jsx)("span",{className:"text-sm",children:"Thinking..."})]})]}),(0,v.jsx)(V,{})]}),I&&(0,v.jsxs)("div",{className:"fixed bottom-28 right-4 w-80 max-h-80 overflow-auto border bg-background/95 shadow-lg rounded-md text-xs",children:[(0,v.jsx)("div",{className:"px-3 py-2 border-b font-mono text-muted-foreground",children:"SSE Debug"}),(0,v.jsxs)("div",{className:"px-3 py-2 space-y-1",children:[0===D.length&&0===O.length&&(0,v.jsx)("div",{className:"text-muted-foreground",children:"No events yet"}),D.map((e,t)=>(0,v.jsx)("div",{className:"font-mono",children:e},`evt-${t}`)),O.map((e,t)=>(0,v.jsx)("div",{className:"font-mono text-red-600",children:e},`err-${t}`))]})]}),(0,v.jsx)("div",{className:(0,k.cn)("border-t border-border/50 p-4 pb-6 bg-card/30",r&&"p-2 pb-2"),children:(0,v.jsxs)("div",{className:(0,k.cn)("max-w-3xl mx-auto",r&&"max-w-none"),children:[!r&&!ef&&0===l.length&&!K&&!g&&(0,v.jsx)(g7,{className:"mb-3",children:['Create a hello.txt file with "Hello, World!"',"List files in the current directory","Show the current git status"].map(e=>(0,v.jsx)(xe,{suggestion:e,onClick:e=>{d(e)}},e))}),y.length>0&&(0,v.jsxs)("div",{className:(0,k.cn)("mb-2 rounded-lg border border-border/60 bg-muted/20 overflow-hidden",r&&"mb-1"),children:[(0,v.jsxs)("button",{type:"button",onClick:()=>M(e=>!e),className:(0,k.cn)("w-full flex items-center justify-between px-3 py-1.5 text-xs text-muted-foreground hover:bg-muted/30 transition-colors",r&&"px-2 py-1"),children:[(0,v.jsxs)("div",{className:"flex items-center gap-1.5",children:[R?(0,v.jsx)(xN.ChevronDown,{className:"size-3"}):(0,v.jsx)(xS.default,{className:"size-3"}),(0,v.jsxs)("span",{className:"font-medium",children:[y.length," Queued"]})]}),(0,v.jsx)("span",{className:"text-[10px]",children:"Stop ^C"})]}),R&&(0,v.jsx)("div",{className:"border-t border-border/40 divide-y divide-border/30",children:y.map((e,t)=>(0,v.jsxs)("div",{className:(0,k.cn)("flex items-start gap-2 px-3 py-2 group",r&&"px-2 py-1.5 gap-1.5"),children:[(0,v.jsx)("span",{className:"text-[10px] text-muted-foreground/60 pt-0.5 w-4 shrink-0 text-center",children:t+1}),(0,v.jsxs)("div",{className:"flex-1 min-w-0",children:[_===e.id?(0,v.jsxs)("div",{className:"flex items-center gap-1",children:[(0,v.jsx)("input",{type:"text",value:E,onChange:e=>P(e.target.value),onKeyDown:t=>{"Enter"===t.key&&tc(e.id),"Escape"===t.key&&T(null)},className:(0,k.cn)("flex-1 bg-background border border-border rounded px-2 py-0.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary/30",r&&"text-[11px]"),autoFocus:!0}),(0,v.jsx)("button",{type:"button",onClick:()=>tc(e.id),className:"p-0.5 text-primary hover:text-primary/80",children:(0,v.jsx)(xg.Check,{className:"size-3"})})]}):(0,v.jsx)("p",{className:(0,k.cn)("text-xs text-foreground truncate",r&&"text-[11px]"),children:e.text||"Selected elements attached"}),e.attachments&&e.attachments.length>0&&(0,v.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[e.attachments.length," file",e.attachments.length>1?"s":""]}),e.selectedElements&&(0,v.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"+ selected elements"})]}),(0,v.jsxs)("div",{className:(0,k.cn)("flex items-center gap-0.5 shrink-0 transition-opacity",r?"opacity-100":"opacity-0 group-hover:opacity-100"),children:[(0,v.jsx)("button",{type:"button",onClick:()=>{T(e.id),P(e.text)},className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted/50",title:"Edit",children:(0,v.jsx)(xf.Pencil,{className:"size-3"})}),t>0&&(0,v.jsx)("button",{type:"button",onClick:()=>{var t;return t=e.id,void w(e=>{let r=e.findIndex(e=>e.id===t);if(-1===r)return e;let n=r-1;if(n<0||n>=e.length)return e;let s=[...e];return[s[r],s[n]]=[s[n],s[r]],s})},className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted/50",title:"Move up",children:(0,v.jsx)(xA,{className:"size-3"})}),(0,v.jsx)("button",{type:"button",onClick:()=>tu(e.id),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted/50",title:"Send now",children:(0,v.jsx)(xC,{className:"size-3"})}),(0,v.jsx)("button",{type:"button",onClick:()=>{var t;return t=e.id,void w(e=>e.filter(e=>e.id!==t))},className:"p-1 rounded text-muted-foreground hover:text-destructive hover:bg-muted/50",title:"Remove",children:(0,v.jsx)(x_.Trash2,{className:"size-3"})})]})]},e.id))})]}),(0,v.jsx)(y3,{children:(0,v.jsxs)(gU,{onSubmit:ta,className:"shadow-sm",globalDrop:!0,multiple:!0,children:[(0,v.jsxs)(gG,{children:[p&&(0,v.jsxs)("div",{className:(0,k.cn)("mb-2 flex items-center justify-between rounded-md border border-border/60 bg-muted/40 px-2 py-1 text-xs",r&&"mb-1"),children:[(0,v.jsxs)("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,v.jsx)("span",{className:"size-1.5 rounded-full bg-primary/70"}),(0,v.jsx)("span",{children:"Selected elements attached"})]}),(0,v.jsx)("button",{type:"button",onClick:()=>f(null),className:"rounded-sm p-1 text-muted-foreground hover:text-foreground","aria-label":"Remove selected elements",children:(0,v.jsx)(xk.X,{className:"size-3.5"})})]}),(0,v.jsx)(vn,{})]}),(0,v.jsx)(gW,{children:(0,v.jsxs)("div",{className:"relative w-full",children:[(0,v.jsx)(y4,{sessionId:t.id,value:u+(h?(!u||u.endsWith(" ")||u.endsWith("\n")?"":" ")+h:""),onChange:e=>{h&&m(""),d(e)},placeholder:g?"Type to queue a message...":"Ask SparkECoder... (@ to mention files, / for commands)",disabled:!1,autoFocus:!0,className:(0,k.cn)("min-h-[80px] focus:ring-2 focus:ring-primary/20 transition-all field-sizing-content max-h-48",h&&"caret-red-500",r&&"min-h-[40px] text-sm max-h-24")}),h&&(0,v.jsxs)("div",{className:"absolute bottom-2 right-2 flex items-center gap-1.5 text-xs text-red-500 bg-background/80 backdrop-blur-sm px-2 py-1 rounded-full",children:[(0,v.jsx)("span",{className:"size-2 bg-red-500 rounded-full animate-pulse"}),"Listening..."]})]})}),(0,v.jsxs)(gq,{className:r?"py-1":void 0,children:[!r&&(0,v.jsx)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:(0,v.jsx)("span",{className:"hidden sm:inline",children:"Type @ to mention files, / for commands"})}),(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsx)(yv,{size:"icon",className:"size-9",onTranscriptionChange:e=>{d(t=>{let r=t&&!t.endsWith(" ")&&!t.endsWith("\n");return t+(r?" ":"")+e})},onInterimTranscription:e=>{m(e)},disabled:g}),(0,v.jsx)(vs,{input:u+h,isRunning:g,onStop:to,hasExtraContent:!!(p&&p.trim())})]})]})]})})]})}),(0,v.jsx)(yw,{sessionId:t.id,frame:eG,metadata:eH,active:eU&&!eX,onDismiss:()=>{eY(!0),eW(!1)}})]})}var vo=e.i(482079),vl=e.i(461957);function vc({sessionId:e}){let[t,r]=(0,b.useState)(null),[n,s]=(0,b.useState)(""),[i,a]=(0,b.useState)(!1),o=(0,b.useCallback)(async()=>{let t=await (0,xt.getSession)(e);r(t?.pendingQuestion??null)},[e]);if((0,b.useEffect)(()=>{let e=!1,t=async()=>{e||await o()};t();let r=setInterval(t,3e3);return()=>{e=!0,clearInterval(r)}},[o]),!t)return null;let l=async()=>{if(n.trim()&&!i){a(!0);try{await (0,xt.answerAgentQuestion)(e,t.questionId,n.trim()),s(""),r(null),o()}finally{a(!1)}}};return(0,v.jsx)("div",{className:"border-b border-amber-500/40 bg-amber-500/5 px-4 py-3",children:(0,v.jsxs)("div",{className:"flex items-start gap-3 max-w-3xl mx-auto",children:[(0,v.jsx)(vo.MessageCircleQuestion,{className:"size-5 text-amber-500 shrink-0 mt-0.5"}),(0,v.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,v.jsx)("p",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:t.question}),t.context&&(0,v.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:t.context}),t.choices&&t.choices.length>0&&(0,v.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-2",children:t.choices.map(e=>(0,v.jsx)("button",{type:"button",onClick:()=>s(e),className:"text-xs px-2 py-1 rounded bg-amber-500/10 hover:bg-amber-500/20 text-amber-800 dark:text-amber-200",children:e},e))}),(0,v.jsxs)("div",{className:"flex gap-2 mt-2",children:[(0,v.jsx)("input",{type:"text",value:n,onChange:e=>s(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),l())},placeholder:"Type your answer…",className:"flex-1 px-3 py-1.5 text-sm rounded border border-border bg-background focus:outline-none focus:ring-2 focus:ring-amber-500/40",autoFocus:!0}),(0,v.jsx)(S.Button,{size:"sm",onClick:l,disabled:!n.trim()||i,children:i?(0,v.jsx)(vl.Loader2,{className:"size-3.5 animate-spin"}):"Answer"})]})]})]})})}function vu({params:e}){let{id:t}=(0,b.use)(e),r=(0,w.useRouter)(),[n,s]=(0,b.useState)(null),[i,a]=(0,b.useState)(!0),[o,l]=(0,b.useState)(null);return((0,b.useEffect)(()=>{!async function(){try{let e=await (0,xt.getSession)(t);if(!e)return void l("Session not found");s(e)}catch(e){console.error("Failed to load session:",e),l("Failed to load session")}finally{a(!1)}}()},[t]),i)?(0,v.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,v.jsx)(vl.Loader2,{className:"size-8 animate-spin text-muted-foreground"})}):o||!n?(0,v.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,v.jsxs)("div",{className:"text-center",children:[(0,v.jsx)("p",{className:"text-muted-foreground mb-4",children:o||"Session not found"}),(0,v.jsx)("button",{onClick:()=>r.push("/"),className:"text-primary hover:underline",children:"Go back home"})]})}):(0,v.jsxs)("div",{className:"flex flex-col h-full",children:[(0,v.jsx)(vc,{sessionId:n.id}),(0,v.jsx)("div",{className:"flex-1 min-h-0",children:(0,v.jsx)(va,{session:n})})]})}e.s(["default",()=>vu],330460)}]);
13
+ ${i}`}let a=i,o=r?.map(e=>({type:e.type,data:e.data,mediaType:e.mediaType,filename:e.filename})),l={id:`user-${Date.now()}`,type:"user-message",content:e||(s?"Selected elements attached":""),attachments:o};c(e=>[...e,l]),x(!0),G(!1),eb.current=!0,X(""),J(""),Q(!1),et([]),eh.current="",em.current="",ep.current=[],ex.current=(0,xt.runAgent)(t.id,a||"Please analyze the attached files.",tn,{onStreamId:e=>H(e),attachments:r})},ti=async(e,t)=>{let r=!!(p&&p.trim());if(e.trim()||t&&0!==t.length||r){if(g){let r;return void(r={id:`q-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,text:e,attachments:t,selectedElements:p},w(e=>[...e,r]),d(""),f(null))}d(""),f(null),await ts(e,t,p)}},ta=async e=>{let t=!!e.text?.trim(),r=!!e.files?.length,n=!!(p&&p.trim());if(!t&&!r&&!n)return;let s=[];if(r&&e.files.length>0){for(let t of e.files)if(t.url)try{let e=await fetch(t.url),r=await e.blob(),n=await new Promise(e=>{let t=new FileReader;t.onloadend=()=>e(t.result),t.readAsDataURL(r)}),i=t.mediaType||r.type||"application/octet-stream",a=i.startsWith("image/");s.push({type:a?"image":"file",data:n,mediaType:i,filename:t.filename})}catch(e){console.error("Failed to process attachment:",e)}}ti(e.text||"",s.length>0?s:void 0)},to=async()=>{try{await (0,xt.abortStream)(t.id)}catch(e){console.error("Failed to abort stream:",e)}if(ex.current&&(ex.current(),ex.current=null),em.current.trim()){let e={id:`reasoning-${Date.now()}`,type:"reasoning",content:em.current};c(t=>[...t,e])}if(eh.current.trim()){let e={id:`text-${Date.now()}`,type:"assistant-text",content:eh.current+" [stopped]"};c(t=>[...t,e])}X(""),J(""),Q(!1),et([]),H(null),eh.current="",em.current="",ep.current=[],ev.current=!1,x(!1),G(!1)},tl=(0,b.useRef)(ts);tl.current=ts;let tc=e=>{w(t=>t.map(t=>t.id===e?{...t,text:E}:t)),T(null),P("")},tu=async e=>{let t=y.find(t=>t.id===e);t&&(w(t=>t.filter(t=>t.id!==e)),g?(await to(),setTimeout(()=>{tl.current(t.text,t.attachments,t.selectedElements)},500)):tl.current(t.text,t.attachments,t.selectedElements))},td=async e=>{en(t=>t.filter(t=>t.id!==e.id));try{await (0,xt.approveExecution)(t.id,e.toolCallId)}catch(e){console.error("Failed to approve:",e)}},th=async e=>{en(t=>t.filter(t=>t.id!==e.id));try{await (0,xt.rejectExecution)(t.id,e.toolCallId,"User rejected")}catch(e){console.error("Failed to reject:",e)}},tm=async e=>{en(t=>t.filter(t=>t.id!==e.id));try{await (0,xt.approveExecution)(t.id,e.toolCallId);let r=await (0,xt.updateToolApproval)(t.id,e.toolName,!1,eE);eP(r.config||{})}catch(e){console.error("Failed to approve and disable:",e)}},tp=async(e,r)=>{try{let n=await (0,xt.updateToolApproval)(t.id,e,!r,eE);eP(n.config||{})}catch(e){console.error("Failed to update tool approval:",e)}},tf=e=>({ts:"typescript",tsx:"tsx",js:"javascript",jsx:"jsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",c:"c",cpp:"cpp",h:"c",hpp:"cpp",cs:"csharp",php:"php",swift:"swift",kt:"kotlin",scala:"scala",sh:"bash",bash:"bash",zsh:"bash",fish:"bash",ps1:"powershell",sql:"sql",html:"html",htm:"html",css:"css",scss:"scss",sass:"sass",less:"less",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",md:"markdown",markdown:"markdown",txt:"plaintext",toml:"toml",ini:"ini",cfg:"ini",conf:"ini",dockerfile:"dockerfile",makefile:"makefile"})[e.split(".").pop()?.toLowerCase()||""]||"plaintext";return(0,v.jsxs)("div",{className:(0,k.cn)("flex flex-col h-full bg-background min-w-0 overflow-x-hidden",r&&"embed-mode text-[13px]"),children:[r&&(0,v.jsxs)("div",{className:"border-b border-border/50 px-2 py-1.5 flex items-center justify-between bg-card/50",children:[(0,v.jsx)(S.Button,{size:"icon",variant:"ghost",onClick:o,className:"size-6",children:(0,v.jsx)(xb.PanelLeft,{className:"size-3.5"})}),(0,v.jsx)("span",{className:"text-[11px] text-muted-foreground truncate max-w-[120px] font-medium",children:eN||"Session"}),(0,v.jsx)(S.Button,{size:"icon",variant:"ghost",onClick:()=>eM(!0),className:"size-6",children:(0,v.jsx)(xx.Settings,{className:"size-3.5"})})]}),!r&&(0,v.jsxs)("div",{className:"border-b border-border/50 px-3 sm:px-4 py-2 flex items-center justify-between bg-card/50 backdrop-blur-sm",children:[(0,v.jsxs)("div",{className:"min-w-0 flex items-center gap-2 sm:gap-3",children:[(0,v.jsx)(vr,{}),(0,v.jsx)("div",{className:"flex items-center gap-1.5",children:eC?(0,v.jsxs)("form",{onSubmit:e=>{e.preventDefault(),e9()},className:"flex items-center gap-1",children:[(0,v.jsx)(gC.Input,{ref:eI,value:eN,onChange:e=>eS(e.target.value),onBlur:e9,className:"h-7 text-sm font-semibold w-40 px-2",placeholder:"Session name"}),(0,v.jsx)(S.Button,{type:"submit",size:"icon",variant:"ghost",className:"size-6 text-muted-foreground hover:text-foreground",children:(0,v.jsx)(xg.Check,{className:"size-3.5"})})]}):(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsxs)("button",{onClick:()=>eA(!0),className:"flex items-center gap-1.5 group hover:bg-muted/50 rounded px-1.5 py-0.5 -mx-1.5 transition-colors",children:[(0,v.jsx)("h2",{className:"font-semibold text-foreground truncate max-w-[200px]",children:eN||"Untitled Session"}),(0,v.jsx)(xf.Pencil,{className:"size-3 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity"})]})}),(0,v.jsx)(C.TooltipContent,{children:"Click to rename"})]})})}),t.workingDirectory?(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 rounded-md bg-muted/30 text-xs text-muted-foreground max-w-[200px]",children:[(0,v.jsx)(xv.FolderOpen,{className:"size-3.5 shrink-0"}),(0,v.jsx)("span",{className:"truncate font-mono",children:t.workingDirectory.split("/").pop()||t.workingDirectory})]})}),(0,v.jsx)(C.TooltipContent,{side:"bottom",className:"max-w-md",children:(0,v.jsx)("p",{className:"font-mono text-xs",children:t.workingDirectory})})]})}):null]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[eQ.filter(e=>"browser-recording"===e.category&&e.downloadUrl).map(e=>(0,v.jsx)(yk,{fileName:e.fileName,downloadUrl:e.downloadUrl,sizeBytes:e.sizeBytes,createdAt:e.createdAt},e.id)),W&&(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsxs)(N.Badge,{variant:"outline",className:"gap-1.5 text-xs border-emerald-500/30 bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 cursor-help",children:[(0,v.jsx)("span",{className:"size-1.5 rounded-full bg-current animate-pulse"}),"Watching"]})}),(0,v.jsx)(C.TooltipContent,{children:"Watching stream from another client"})]})}),(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsx)(N.Badge,{variant:g?"default":"secondary",className:`cursor-help ${g?"bg-primary/90":""}`,children:g?W?"streaming":"running":t.status})}),(0,v.jsx)(C.TooltipContent,{children:g?W?"Receiving streamed response":"Agent is processing":`Session is ${t.status}`})]})}),(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsx)(S.Button,{size:"icon",variant:"ghost",className:"size-7 hover:bg-accent transition-colors",onClick:()=>eM(!0),children:(0,v.jsx)(xx.Settings,{className:"size-4"})})}),(0,v.jsx)(C.TooltipContent,{children:"Session Settings"})]})}),(0,v.jsxs)(go,{children:[(0,v.jsx)(gl,{asChild:!0,children:(0,v.jsx)(S.Button,{size:"icon",variant:"ghost",className:"size-7 hover:bg-accent transition-colors",children:(0,v.jsx)(xP,{className:"size-4"})})}),(0,v.jsxs)(gc,{align:"end",className:"w-52",children:[(0,v.jsxs)(gu,{onClick:()=>{eY(!1),(0,xt.getBrowserStreamStatus)(t.id).then(e=>{e?.active?(eW(!0),console.log("[browser] Reconnecting PIP — stream active")):console.log("[browser] No active browser stream")})},children:[(0,v.jsx)(gX,{className:"size-4 mr-2"}),"Open Browser PIP"]}),(0,v.jsxs)(gu,{onClick:async()=>{e3(await (0,xt.getBrowserRecordings)(t.id)),e2(!0)},children:[(0,v.jsx)(gZ,{className:"size-4 mr-2"}),"Browser Recordings"]}),(0,v.jsxs)(gu,{onClick:async()=>{e6("copying");try{let e=await vi(t.id);await navigator.clipboard.writeText(e),e6("copied"),console.log(`[debug-dump] copied ${e.length.toLocaleString()} chars to clipboard for session ${t.id}`),setTimeout(()=>e6("idle"),2500)}catch(e){console.error("[debug-dump] failed:",e),e6("error"),setTimeout(()=>e6("idle"),2500)}},children:["copying"===e4?(0,v.jsx)(xh.RefreshCw,{className:"size-4 mr-2 animate-spin"}):"copied"===e4?(0,v.jsx)(xg.Check,{className:"size-4 mr-2 text-green-500"}):"error"===e4?(0,v.jsx)(xm,{className:"size-4 mr-2 text-red-500"}):(0,v.jsx)(xR,{className:"size-4 mr-2"}),"copying"===e4?"Gathering…":"copied"===e4?"Copied to clipboard":"error"===e4?"Failed — see console":"Copy debug JSON"]})]})]})]})]}),(0,v.jsx)(pb.Dialog,{open:eR,onOpenChange:eM,children:(0,v.jsxs)(pb.DialogContent,{className:"sm:max-w-md",children:[(0,v.jsx)(pb.DialogHeader,{children:(0,v.jsxs)(pb.DialogTitle,{className:"flex items-center gap-2",children:[(0,v.jsx)("div",{className:"size-8 rounded-lg bg-muted flex items-center justify-center",children:(0,v.jsx)(xx.Settings,{className:"size-4"})}),"Session Settings"]})}),(0,v.jsxs)("div",{className:"space-y-4 pt-2",children:[(0,v.jsxs)("div",{className:"space-y-2",children:[(0,v.jsx)(xL.Label,{className:"text-sm font-medium",children:"Model"}),(0,v.jsxs)(oh.Select,{value:ej,onValueChange:e8,disabled:g,children:[(0,v.jsx)(oh.SelectTrigger,{className:"w-full",children:(0,v.jsx)(oh.SelectValue,{placeholder:"Select model"})}),(0,v.jsx)(oh.SelectContent,{children:e_?.availableModels.map(e=>(0,v.jsx)(oh.SelectItem,{value:e.id,children:(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsx)("span",{children:e.name}),(0,v.jsx)("span",{className:"text-xs text-muted-foreground",children:e.provider})]})},e.id))})]}),g&&(0,v.jsx)("p",{className:"text-xs text-muted-foreground",children:"Cannot change model while agent is running"})]}),(0,v.jsxs)("div",{className:"space-y-2",children:[(0,v.jsx)(xL.Label,{className:"flex items-center gap-2 text-sm font-medium",children:"Tool Approvals"}),(0,v.jsx)("p",{className:"text-xs text-muted-foreground -mt-0.5",children:"Toggle on to require approval before tool executes"}),(0,v.jsx)("div",{className:"space-y-1 rounded-lg border p-2.5 bg-muted/30",children:e_?.availableTools.map(e=>{var t;let r=(t=e.id,eE.toolApprovals?.[t]!==void 0?eE.toolApprovals[t]:"bash"===t);return(0,v.jsxs)("div",{className:"flex items-center justify-between py-1.5 hover:bg-muted/50 rounded px-2 -mx-1 transition-colors",children:[(0,v.jsxs)("div",{className:"space-y-0",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsx)("span",{className:"text-sm font-medium",children:e.name}),e.dangerous&&(0,v.jsx)("span",{className:"text-[10px] bg-amber-500/20 text-amber-600 dark:text-amber-400 px-1.5 py-0.5 rounded font-medium",children:"risky"})]}),(0,v.jsx)("p",{className:"text-[11px] text-muted-foreground",children:e.description})]}),(0,v.jsx)(xI.Switch,{checked:r,onCheckedChange:()=>tp(e.id,r)})]},e.id)})})]}),(0,v.jsx)("p",{className:"text-xs text-muted-foreground",children:"These settings only apply to this session. Changes take effect for future tool calls."})]})]})}),(0,v.jsx)(pb.Dialog,{open:e1,onOpenChange:e2,children:(0,v.jsxs)(pb.DialogContent,{className:"max-w-2xl w-full p-0 overflow-hidden rounded-xl",children:[(0,v.jsx)(pb.DialogHeader,{className:"px-5 pt-5 pb-3",children:(0,v.jsxs)(pb.DialogTitle,{className:"flex items-center gap-2 text-sm font-medium",children:[(0,v.jsx)("div",{className:"flex items-center justify-center size-6 rounded-lg bg-violet-500/10 dark:bg-violet-400/10",children:(0,v.jsx)(gZ,{className:"size-3.5 text-violet-600 dark:text-violet-400"})}),"Browser Recordings"]})}),(0,v.jsx)("div",{className:"px-5 pb-5 space-y-3",children:0===e5.length?(0,v.jsx)("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No browser recordings for this session"}):e5.map(e=>(0,v.jsxs)("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-muted/30 hover:bg-muted/50 transition-colors",children:[(0,v.jsx)("div",{className:"flex items-center justify-center size-10 rounded-lg bg-violet-500/10 dark:bg-violet-400/10 shrink-0",children:(0,v.jsx)(xC,{className:"size-4 text-violet-600 dark:text-violet-400 ml-0.5"})}),(0,v.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,v.jsx)("p",{className:"text-sm font-medium truncate",children:e.fileName}),(0,v.jsxs)("p",{className:"text-xs text-muted-foreground",children:[e.createdAt&&new Date(e.createdAt).toLocaleString(),null!=e.sizeBytes&&` \xb7 ${e.sizeBytes>1048576?`${(e.sizeBytes/1048576).toFixed(1)} MB`:`${(e.sizeBytes/1024).toFixed(0)} KB`}`]})]}),e.downloadUrl&&(0,v.jsxs)(S.Button,{size:"sm",variant:"outline",className:"shrink-0",onClick:()=>window.open(e.downloadUrl,"_blank"),children:[(0,v.jsx)(xC,{className:"size-3 mr-1"}),"Watch"]})]},e.id))})]})}),!r&&ez?.updateAvailable&&!eB&&(0,v.jsxs)("div",{className:"px-4 py-2 border-b border-amber-500/30 bg-amber-500/10 flex items-center justify-between gap-3",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(xj,{className:"size-4 text-amber-600 dark:text-amber-400 shrink-0"}),(0,v.jsxs)("span",{className:"text-sm text-amber-700 dark:text-amber-300",children:["Update available: ",(0,v.jsxs)("strong",{children:["v",ez.latestVersion]}),(0,v.jsxs)("span",{className:"text-amber-600/70 dark:text-amber-400/70 ml-1",children:["(current: v",ez.currentVersion,")"]})]})]}),(0,v.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,v.jsx)(S.Button,{size:"sm",variant:"outline",className:"h-7 text-xs border-amber-500/50 bg-amber-500/20 hover:bg-amber-500/30 text-amber-700 dark:text-amber-300",onClick:e7,disabled:e$,children:e$?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(xh.RefreshCw,{className:"size-3 mr-1.5 animate-spin"}),"Creating..."]}):(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(xj,{className:"size-3 mr-1.5"}),"Update Now"]})}),(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsx)(S.Button,{size:"icon",variant:"ghost",className:"size-6 text-amber-600 dark:text-amber-400 hover:bg-amber-500/20",onClick:()=>{eF(!0),ez?.latestVersion&&localStorage.setItem("sparkecoder-dismissed-version",ez.latestVersion)},children:(0,v.jsx)(xk.X,{className:"size-3.5"})})}),(0,v.jsx)(C.TooltipContent,{children:"Dismiss (won't show again for this version)"})]})})]})]}),!r&&(es&&es.todos&&es.todos.length>0||ea.length>0)&&(0,v.jsx)("div",{className:"px-4 py-2 border-b border-border/50 bg-muted/20",children:(0,v.jsx)(xo,{todosData:es,plans:ea})}),er.length>0&&(0,v.jsx)("div",{className:(0,k.cn)("p-4 border-b border-border space-y-3",r&&"p-2 space-y-2"),children:er.map(e=>{let t=e.input;return(0,v.jsxs)(oG,{approval:{id:e.id,approved:!1},state:"approval-requested",children:[(0,v.jsx)(oq,{children:(0,v.jsxs)("div",{className:"flex items-start gap-3",children:[(0,v.jsx)("div",{className:"size-8 rounded-lg bg-amber-500/20 flex items-center justify-center shrink-0",children:(0,v.jsx)(xm,{className:"size-4 text-amber-500"})}),(0,v.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,v.jsx)("p",{className:"font-medium text-sm",children:"Approval Required"}),(0,v.jsx)("p",{className:"text-sm text-muted-foreground mt-0.5",children:(0,v.jsx)("code",{className:"bg-muted px-1.5 py-0.5 rounded font-mono text-foreground",children:e.toolName})}),(0,v.jsx)("div",{className:"mt-3 rounded-lg border bg-muted/30 overflow-hidden",children:Object.entries(t).map(([e,t])=>(0,v.jsxs)("div",{className:"flex border-b border-border/50 last:border-b-0",children:[(0,v.jsx)("div",{className:"px-3 py-2 bg-muted/50 text-xs font-medium text-muted-foreground w-24 shrink-0",children:e}),(0,v.jsx)("div",{className:"px-3 py-2 text-xs font-mono flex-1 min-w-0 overflow-auto max-h-24",children:"string"==typeof t?(0,v.jsx)("span",{className:"whitespace-pre-wrap break-words",children:t}):(0,v.jsx)("span",{className:"text-muted-foreground",children:JSON.stringify(t)})})]},e))})]})]})}),(0,v.jsxs)(oH,{children:[(0,v.jsx)(oK,{variant:"outline",onClick:()=>th(e),children:"Reject"}),(0,v.jsx)(oK,{variant:"ghost",onClick:()=>tm(e),className:"text-muted-foreground hover:text-foreground",children:"Always Allow"}),(0,v.jsx)(oK,{variant:"default",onClick:()=>td(e),children:"Approve"})]})]},e.id)})}),(0,v.jsxs)(B,{className:(0,k.cn)("flex-1 p-4",r&&"p-2"),children:[(0,v.jsxs)(F,{className:(0,k.cn)("max-w-3xl mx-auto w-full",r&&"max-w-none"),children:[t.config?.task?.enabled&&(s="running"===(n=t.config.task).status,i="completed"===n.status,a="failed"===n.status,(0,v.jsxs)("div",{className:(0,k.cn)("mb-4 rounded-lg border px-3.5 py-2.5 flex items-center gap-2.5 text-sm transition-colors",i&&"border-emerald-500/30 bg-emerald-500/5",a&&"border-red-500/30 bg-red-500/5",s&&"border-blue-500/30 bg-blue-500/5"),children:[(0,v.jsx)(xE.ListChecks,{className:(0,k.cn)("size-4 shrink-0",i&&"text-emerald-500",a&&"text-red-500",s&&"text-blue-500")}),(0,v.jsx)("span",{className:"font-medium truncate",children:t.name||"Task"}),(0,v.jsx)("span",{className:(0,k.cn)("text-xs shrink-0",i&&"text-emerald-600 dark:text-emerald-400",a&&"text-red-600 dark:text-red-400",s&&"text-blue-600 dark:text-blue-400 animate-pulse"),children:s?"Running":i?"Completed":"Failed"}),null!=n.iterations&&(0,v.jsxs)("span",{className:"text-xs text-muted-foreground ml-auto tabular-nums shrink-0",children:[n.iterations," iter."]}),a&&n.error&&(0,v.jsxs)("span",{className:"text-xs text-red-500 truncate ml-1",title:n.error,children:["— ",n.error]})]})),ef&&(0,v.jsx)("div",{className:"flex justify-center py-12",children:(0,v.jsx)(oY,{size:24})}),!ef&&0===l.length&&!K&&(0,v.jsx)($,{icon:(0,v.jsxs)("div",{className:"relative overflow-hidden rounded-2xl size-16 shadow-lg ring-1 ring-white/10",children:[(0,v.jsx)(j.default,{src:"/sparke-coder.png",alt:"SparkECoder",width:64,height:64,className:"absolute inset-0 size-full object-cover",priority:!0}),g&&(0,v.jsx)("video",{src:"/sparkecode.mp4",autoPlay:!0,muted:!0,loop:!0,playsInline:!0,className:"absolute inset-0 size-full object-cover"})]}),title:"Start a conversation",description:"Ask SparkECoder to help you with coding tasks"}),l.filter(e=>{if("tool-call"===e.type&&e.toolCall){if(er.some(t=>t.toolCallId===e.toolCall?.toolCallId))return!1;let t=ee.some(t=>t.toolCallId===e.toolCall?.toolCallId),r=ee.some(t=>t.toolCallId.startsWith(`${e.toolCall?.toolName}_pending_`)&&("streaming"===t.status||"running"===t.status));if(t||r)return!1}return!0}).map(e=>{if("user-message"===e.type){let t,r,n,s=e.content?function(e){let t=e.replace(/^\s+/,"");for(;;){let e=t;if((t=(t=t.replace(/^\[Local device time:[^\]]*\]\s*/,"")).replace(/^\[REPLAY[^\]]*\]\s*/,""))===e)break}let r=t.match(/^\[([A-Z]+)(?:\s+([^\]]*))?\]\s*([\s\S]*)$/);if(!r)return{pill:null,rest:e};let n=r[1];return["WEB","SLACK","SYSTEM","SCHEDULE","WEBHOOK"].includes(n)?{pill:{channel:n,detail:r[2]?.replace(/\s*reply-with=[\s\S]*$/,"").trim()||void 0},rest:r[3]}:{pill:null,rest:e}}(e.content):{pill:null,rest:e.content||""};if(s.pill&&y7.has(s.pill.channel))return(0,v.jsx)(vt,{pill:s.pill,body:s.rest},e.id);let i=!!s.pill&&"WEB"!==s.pill.channel,a=void 0!==e.messageSequence&&el.some(t=>t.messageSequence===e.messageSequence);return(0,v.jsxs)("div",{className:i?"flex flex-col items-end gap-1":void 0,children:[i&&s.pill&&(0,v.jsxs)("div",{className:`inline-flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide px-2 py-0.5 rounded-md border self-end ${y8[s.pill.channel]||"bg-muted text-muted-foreground border-border"}`,children:[(0,v.jsx)("span",{children:s.pill.channel}),s.pill.detail&&(0,v.jsx)("span",{className:"font-normal normal-case opacity-80",children:s.pill.detail})]}),(0,v.jsxs)(aF,{from:"user",children:[(0,v.jsxs)(a$,{children:[e.attachments&&e.attachments.length>0&&(0,v.jsx)("div",{className:"flex flex-wrap gap-2 mb-2",children:e.attachments.map((e,t)=>(0,v.jsx)("div",{className:"relative",children:"image"===e.type?(0,v.jsx)("div",{className:"relative rounded-lg overflow-hidden border border-border/50 max-w-[200px]",children:(0,v.jsx)("img",{src:e.data.startsWith("data:")?e.data:`data:${e.mediaType||"image/png"};base64,${e.data}`,alt:e.filename||"Image attachment",className:"max-w-full h-auto max-h-[150px] object-contain"})}):(0,v.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-muted/50 border border-border/50",children:[(0,v.jsx)(xw,{className:"h-4 w-4 text-muted-foreground"}),(0,v.jsx)("span",{className:"text-sm text-muted-foreground truncate max-w-[150px]",children:e.filename||"File"})]})},t))}),e.content&&(r=(t=s.rest).replace(y6,"").trim(),n=function(e){let t=e.match(/<devtools-context>([\s\S]*?)<\/devtools-context>/);if(!t)return null;let r=t[1],n=r.match(/<page\s+url="([^"]*)"\s+path="([^"]*)"\s+name="([^"]*)"/),s=r.match(/<viewport\s+width="([^"]*)"\s+height="([^"]*)"(?:\s+dpr="([^"]*)")?/);return n?{url:n[1],path:n[2],pageName:n[3],viewportWidth:s?.[1],viewportHeight:s?.[2],dpr:s?.[3]}:null}(t),(0,v.jsxs)(v.Fragment,{children:[!i&&s.pill&&(0,v.jsx)(y9,{...s.pill}),r&&(0,v.jsx)("p",{className:"whitespace-pre-wrap",children:r}),n&&(0,v.jsxs)("div",{className:"flex items-center gap-1.5 mt-1.5 text-[11px] text-muted-foreground/60",children:[(0,v.jsx)(xT,{className:"h-3 w-3"}),(0,v.jsx)("span",{children:n.path}),n.viewportWidth&&n.viewportHeight&&(0,v.jsxs)("span",{className:"text-muted-foreground/40",children:[n.viewportWidth,"x",n.viewportHeight]})]})]}))]}),a&&!g&&(0,v.jsx)(aV,{className:"justify-end mt-1",children:(0,v.jsx)(C.TooltipProvider,{children:(0,v.jsxs)(C.Tooltip,{children:[(0,v.jsx)(C.TooltipTrigger,{asChild:!0,children:(0,v.jsxs)(S.Button,{variant:"ghost",size:"sm",onClick:()=>tr(e.messageSequence,e.content),disabled:eu,className:"h-6 px-2 text-xs text-muted-foreground hover:text-destructive gap-1",children:[(0,v.jsx)(xy,{className:"h-3 w-3"}),"Revert"]})}),(0,v.jsx)(C.TooltipContent,{children:(0,v.jsx)("p",{children:"Revert to before this message (undo all changes after)"})})]})})})]})]},e.id)}if("reasoning"===e.type)return(0,v.jsxs)(mq,{isStreaming:!1,defaultOpen:!1,children:[(0,v.jsx)(mK,{}),(0,v.jsx)(mX,{children:e.content||""})]},e.id);if("assistant-text"===e.type)return(0,v.jsx)(aF,{from:"assistant",children:(0,v.jsxs)("div",{className:"flex gap-3",children:[(0,v.jsx)("div",{className:"relative overflow-hidden rounded-lg size-8 shadow-sm ring-1 ring-white/10 shrink-0",children:(0,v.jsx)(j.default,{src:"/sparke-coder.png",alt:"SparkECoder",width:32,height:32,className:"absolute inset-0 size-full object-cover"})}),(0,v.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,v.jsx)(a$,{children:(0,v.jsx)(aG,{children:e.content||""})}),(0,v.jsx)(aV,{children:(0,v.jsx)(aU,{label:"Copy",onClick:()=>navigator.clipboard.writeText(e.content||""),children:(0,v.jsx)(xd.Copy,{className:"size-3"})})})]})]})},e.id);if("tool-call"===e.type&&e.toolCall){let t=e.toolCall,r=`tool-${t.toolName}`;if("messenger"===t.toolName&&t.input?.action==="post")return(0,v.jsx)(ve,{input:t.input,output:t.output,status:t.status},e.id);if("write_file"===t.toolName)return(0,v.jsx)(xB,{input:t.input,output:t.output,status:t.status,streamingArgsText:t.streamingArgsText,liveContent:t.liveContent,liveOldString:t.liveOldString,liveNewString:t.liveNewString},e.id);if("read_file"===t.toolName)return(0,v.jsx)(xV,{input:t.input,output:t.output,status:t.status},e.id);if("bash"===t.toolName)return(0,v.jsx)(xq,{input:t.input,output:t.output,status:t.status,terminalId:t.terminalId,liveOutput:t.liveOutput},e.id);if("explore_agent"===t.toolName)return(0,v.jsx)(x1,{input:t.input,output:t.output,status:t.status,steps:t.exploreSteps},e.id);if("todo"===t.toolName)return(0,v.jsx)(ye,{input:t.input,output:t.output,status:t.status},e.id);if("load_skill"===t.toolName)return(0,v.jsx)(yn,{input:t.input,output:t.output,status:t.status},e.id);if("linter"===t.toolName)return(0,v.jsx)(yl,{input:t.input,output:t.output,status:t.status},e.id);if("code_graph"===t.toolName)return(0,v.jsx)(yh,{input:t.input,output:t.output,status:t.status},e.id);if("complete_task"===t.toolName||"task_failed"===t.toolName)return(0,v.jsx)(yg,{toolName:t.toolName,input:t.input,output:t.output,status:t.status},e.id);let n="completed"!==t.status;return(0,v.jsxs)(oT,{defaultOpen:n,children:[(0,v.jsx)(oE,{type:r,state:function(e){switch(e){case"pending":case"streaming":default:return"input-streaming";case"running":return"input-available";case"completed":return"output-available";case"rejected":return"output-denied";case"error":return"output-error"}}(t.status),title:t.toolName}),(0,v.jsxs)(oP,{children:[(0,v.jsx)(oR,{input:t.input}),(e=>{let t=e.output,r=e.input;if("bash"===e.toolName)return(0,v.jsx)(xq,{input:e.input,output:e.output,status:e.status,terminalId:e.terminalId,liveOutput:e.liveOutput,className:"mt-2"});if("explore_agent"===e.toolName)return(0,v.jsx)(x1,{input:e.input,output:e.output,status:e.status,steps:e.exploreSteps,className:"mt-2"});if("todo"===e.toolName)return(0,v.jsx)(ye,{input:e.input,output:e.output,status:e.status,className:"mt-2"});if("load_skill"===e.toolName)return(0,v.jsx)(yn,{input:e.input,output:e.output,status:e.status,className:"mt-2"});if("linter"===e.toolName)return(0,v.jsx)(yl,{input:e.input,output:e.output,status:e.status,className:"mt-2"});if("code_graph"===e.toolName)return(0,v.jsx)(yh,{input:e.input,output:e.output,status:e.status,className:"mt-2"});if("write_file"===e.toolName&&r){let e=r.path||"file",n=r.mode||"full",s=e.split("/").pop()||"file",i=tf(e);if("str_replace"===n){let e=r.old_string||"",n=r.new_string||"";return(0,v.jsxs)("div",{className:"mt-2 max-w-full overflow-hidden space-y-2",children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,v.jsx)(xp,{className:"size-4 text-muted-foreground"}),(0,v.jsx)("span",{className:"font-medium",children:s}),(0,v.jsx)(N.Badge,{variant:"secondary",className:"text-xs",children:"str_replace"})]}),(0,v.jsxs)("div",{className:"rounded-md border overflow-hidden",children:[(0,v.jsxs)("div",{className:"bg-red-500/10 border-b p-2",children:[(0,v.jsx)("div",{className:"text-xs text-red-500 mb-1",children:"- Remove:"}),(0,v.jsx)("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-words text-red-400",children:e.length>500?e.slice(0,500)+"...":e})]}),(0,v.jsxs)("div",{className:"bg-green-500/10 p-2",children:[(0,v.jsx)("div",{className:"text-xs text-green-500 mb-1",children:"+ Add:"}),(0,v.jsx)("pre",{className:"text-xs overflow-x-auto whitespace-pre-wrap break-words text-green-400",children:n.length>500?n.slice(0,500)+"...":n})]})]}),t&&(0,v.jsxs)("div",{className:`text-xs flex items-center gap-1 ${t.success?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:[(0,v.jsx)("span",{children:t.success?"✓":"✗"}),(0,v.jsx)("span",{children:t.success?`Replaced (${void 0!==t.lineDelta?(t.lineDelta>=0?"+":"")+t.lineDelta+" lines":"done"})`:t.error||"Failed"})]})]})}let a=r.content||"";return(0,v.jsxs)("div",{className:"mt-2 max-w-full overflow-hidden",children:[(0,v.jsxs)(oI,{children:[(0,v.jsxs)(oL,{children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(xp,{className:"size-4 text-muted-foreground shrink-0"}),(0,v.jsx)(oD,{className:"truncate",children:s}),(0,v.jsx)(oz,{className:"truncate text-xs hidden sm:block",children:e})]}),(0,v.jsx)(oO,{children:(0,v.jsx)(oB,{icon:xd.Copy,label:"Copy",onClick:()=>navigator.clipboard.writeText(a)})})]}),a&&(0,v.jsx)(oF,{className:"p-0 max-h-[300px] overflow-auto",children:(0,v.jsx)(o_,{code:a,language:i,showLineNumbers:!0,children:(0,v.jsx)(oN,{className:"sr-only",children:(0,v.jsx)(oS,{children:(0,v.jsx)(oC,{children:s})})})})})]}),t&&(0,v.jsxs)("div",{className:`mt-2 text-xs flex items-center gap-1 ${t.success?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:[(0,v.jsx)("span",{children:t.success?"✓":"✗"}),(0,v.jsx)("span",{children:t.success?`File ${t.action||"written"} successfully`:t.error||"Failed"})]})]})}if("read_file"===e.toolName&&t){let e=r?.path||"file",n=e.split("/").pop()||"file",s=t.imageData,i=t.mediaType;if(s&&i)return(0,v.jsx)("div",{className:"mt-2 max-w-full overflow-hidden",children:(0,v.jsxs)(oI,{children:[(0,v.jsx)(oL,{children:(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(gM,{className:"size-4 text-muted-foreground shrink-0"}),(0,v.jsx)(oD,{className:"truncate",children:n}),(0,v.jsx)(oz,{className:"truncate text-xs hidden sm:block",children:e})]})}),(0,v.jsx)(oF,{className:"p-0 max-h-[400px] overflow-auto",children:(0,v.jsx)("div",{className:"p-3 flex justify-center bg-muted/20",children:(0,v.jsx)("img",{src:`data:${i};base64,${s}`,alt:n,className:"max-w-full max-h-[350px] object-contain rounded"})})})]})});let a=t.content||JSON.stringify(t,null,2),o=tf(e);return(0,v.jsx)("div",{className:"mt-2 max-w-full overflow-hidden",children:(0,v.jsxs)(oI,{children:[(0,v.jsxs)(oL,{children:[(0,v.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,v.jsx)(xp,{className:"size-4 text-muted-foreground shrink-0"}),(0,v.jsx)(oD,{className:"truncate",children:n}),(0,v.jsx)(oz,{className:"truncate text-xs hidden sm:block",children:e})]}),(0,v.jsx)(oO,{children:(0,v.jsx)(oB,{icon:xd.Copy,label:"Copy",onClick:()=>navigator.clipboard.writeText(a)})})]}),(0,v.jsx)(oF,{className:"p-0 max-h-[300px] overflow-auto",children:(0,v.jsx)(o_,{code:a,language:o,showLineNumbers:!0,children:(0,v.jsx)(oN,{className:"sr-only",children:(0,v.jsx)(oS,{children:(0,v.jsx)(oC,{children:n})})})})})]})})}return t?(0,v.jsx)(oM,{output:(0,v.jsxs)("pre",{className:"text-xs overflow-x-auto max-w-full whitespace-pre-wrap break-words",children:[JSON.stringify(t,null,2).slice(0,500),JSON.stringify(t).length>500?"...":""]}),errorText:"error"===e.status?"Tool execution failed":void 0}):null})(t)]})]},e.id)}return null}),g&&!K&&!Y&&0===ee.length&&(0,v.jsxs)("div",{className:"flex gap-3 items-center",children:[(0,v.jsx)("div",{className:"relative overflow-hidden rounded-lg size-8 shadow-sm ring-1 ring-white/10 shrink-0",children:(0,v.jsx)("video",{src:"/sparkecode.mp4",autoPlay:!0,muted:!0,loop:!0,playsInline:!0,className:"absolute inset-0 size-full object-cover"})}),(0,v.jsx)("span",{className:"text-sm text-muted-foreground",children:"Thinking..."})]}),g&&(Z||Y)&&(0,v.jsxs)(mq,{isStreaming:Z,defaultOpen:!0,children:[(0,v.jsx)(mK,{}),(0,v.jsx)(mX,{children:Y})]}),g&&K&&(0,v.jsx)(aF,{from:"assistant",children:(0,v.jsxs)("div",{className:"flex gap-3",children:[(0,v.jsx)("div",{className:"relative overflow-hidden rounded-lg size-8 shadow-sm ring-1 ring-white/10 shrink-0",children:(0,v.jsx)("video",{src:"/sparkecode.mp4",autoPlay:!0,muted:!0,loop:!0,playsInline:!0,className:"absolute inset-0 size-full object-cover"})}),(0,v.jsx)("div",{className:"flex-1 min-w-0",children:(0,v.jsxs)(a$,{children:[(0,v.jsx)(aG,{children:K}),(0,v.jsx)("span",{className:"inline-block w-2 h-4 bg-primary animate-pulse ml-1"})]})})]})}),g&&ee.map(e=>"write_file"===e.toolName?(0,v.jsx)(xB,{input:e.input,output:e.output,status:e.status,streamingArgsText:e.streamingArgsText,liveContent:e.liveContent,liveOldString:e.liveOldString,liveNewString:e.liveNewString},e.toolCallId):"read_file"===e.toolName?(0,v.jsx)(xV,{input:e.input,output:e.output,status:e.status},e.toolCallId):"bash"===e.toolName?(0,v.jsx)(xq,{input:e.input,output:e.output,status:e.status,terminalId:e.terminalId,liveOutput:e.liveOutput},e.toolCallId):"explore_agent"===e.toolName?(0,v.jsx)(x1,{input:e.input,output:e.output,status:e.status,steps:e.exploreSteps},e.toolCallId):"todo"===e.toolName?(0,v.jsx)(ye,{input:e.input,output:e.output,status:e.status},e.toolCallId):"load_skill"===e.toolName?(0,v.jsx)(yn,{input:e.input,output:e.output,status:e.status},e.toolCallId):"linter"===e.toolName?(0,v.jsx)(yl,{input:e.input,output:e.output,status:e.status},e.toolCallId):"code_graph"===e.toolName?(0,v.jsx)(yh,{input:e.input,output:e.output,status:e.status},e.toolCallId):"complete_task"===e.toolName||"task_failed"===e.toolName?(0,v.jsx)(yg,{toolName:e.toolName,input:e.input,output:e.output,status:e.status},e.toolCallId):(0,v.jsxs)(oT,{defaultOpen:!0,children:[(0,v.jsx)(oE,{type:`tool-${e.toolName}`,state:"streaming"===e.status?"input-streaming":"input-available",title:e.toolName}),(0,v.jsxs)(oP,{children:[(0,v.jsx)(oR,{input:e.input}),(0,v.jsxs)("div",{className:"flex items-center gap-2 p-3 text-muted-foreground",children:[(0,v.jsx)(oY,{size:14}),(0,v.jsx)("span",{className:"text-sm",children:"streaming"===e.status?"Receiving...":"Executing..."})]})]})]},e.toolCallId)),g&&!K&&0===ee.length&&(0,v.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,v.jsx)(oY,{size:16}),(0,v.jsx)("span",{className:"text-sm",children:"Thinking..."})]})]}),(0,v.jsx)(V,{})]}),I&&(0,v.jsxs)("div",{className:"fixed bottom-28 right-4 w-80 max-h-80 overflow-auto border bg-background/95 shadow-lg rounded-md text-xs",children:[(0,v.jsx)("div",{className:"px-3 py-2 border-b font-mono text-muted-foreground",children:"SSE Debug"}),(0,v.jsxs)("div",{className:"px-3 py-2 space-y-1",children:[0===D.length&&0===O.length&&(0,v.jsx)("div",{className:"text-muted-foreground",children:"No events yet"}),D.map((e,t)=>(0,v.jsx)("div",{className:"font-mono",children:e},`evt-${t}`)),O.map((e,t)=>(0,v.jsx)("div",{className:"font-mono text-red-600",children:e},`err-${t}`))]})]}),(0,v.jsx)("div",{className:(0,k.cn)("border-t border-border/50 p-4 pb-6 bg-card/30",r&&"p-2 pb-2"),children:(0,v.jsxs)("div",{className:(0,k.cn)("max-w-3xl mx-auto",r&&"max-w-none"),children:[!r&&!ef&&0===l.length&&!K&&!g&&(0,v.jsx)(g7,{className:"mb-3",children:['Create a hello.txt file with "Hello, World!"',"List files in the current directory","Show the current git status"].map(e=>(0,v.jsx)(xe,{suggestion:e,onClick:e=>{d(e)}},e))}),y.length>0&&(0,v.jsxs)("div",{className:(0,k.cn)("mb-2 rounded-lg border border-border/60 bg-muted/20 overflow-hidden",r&&"mb-1"),children:[(0,v.jsxs)("button",{type:"button",onClick:()=>M(e=>!e),className:(0,k.cn)("w-full flex items-center justify-between px-3 py-1.5 text-xs text-muted-foreground hover:bg-muted/30 transition-colors",r&&"px-2 py-1"),children:[(0,v.jsxs)("div",{className:"flex items-center gap-1.5",children:[R?(0,v.jsx)(xN.ChevronDown,{className:"size-3"}):(0,v.jsx)(xS.default,{className:"size-3"}),(0,v.jsxs)("span",{className:"font-medium",children:[y.length," Queued"]})]}),(0,v.jsx)("span",{className:"text-[10px]",children:"Stop ^C"})]}),R&&(0,v.jsx)("div",{className:"border-t border-border/40 divide-y divide-border/30",children:y.map((e,t)=>(0,v.jsxs)("div",{className:(0,k.cn)("flex items-start gap-2 px-3 py-2 group",r&&"px-2 py-1.5 gap-1.5"),children:[(0,v.jsx)("span",{className:"text-[10px] text-muted-foreground/60 pt-0.5 w-4 shrink-0 text-center",children:t+1}),(0,v.jsxs)("div",{className:"flex-1 min-w-0",children:[_===e.id?(0,v.jsxs)("div",{className:"flex items-center gap-1",children:[(0,v.jsx)("input",{type:"text",value:E,onChange:e=>P(e.target.value),onKeyDown:t=>{"Enter"===t.key&&tc(e.id),"Escape"===t.key&&T(null)},className:(0,k.cn)("flex-1 bg-background border border-border rounded px-2 py-0.5 text-xs focus:outline-none focus:ring-1 focus:ring-primary/30",r&&"text-[11px]"),autoFocus:!0}),(0,v.jsx)("button",{type:"button",onClick:()=>tc(e.id),className:"p-0.5 text-primary hover:text-primary/80",children:(0,v.jsx)(xg.Check,{className:"size-3"})})]}):(0,v.jsx)("p",{className:(0,k.cn)("text-xs text-foreground truncate",r&&"text-[11px]"),children:e.text||"Selected elements attached"}),e.attachments&&e.attachments.length>0&&(0,v.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[e.attachments.length," file",e.attachments.length>1?"s":""]}),e.selectedElements&&(0,v.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"+ selected elements"})]}),(0,v.jsxs)("div",{className:(0,k.cn)("flex items-center gap-0.5 shrink-0 transition-opacity",r?"opacity-100":"opacity-0 group-hover:opacity-100"),children:[(0,v.jsx)("button",{type:"button",onClick:()=>{T(e.id),P(e.text)},className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted/50",title:"Edit",children:(0,v.jsx)(xf.Pencil,{className:"size-3"})}),t>0&&(0,v.jsx)("button",{type:"button",onClick:()=>{var t;return t=e.id,void w(e=>{let r=e.findIndex(e=>e.id===t);if(-1===r)return e;let n=r-1;if(n<0||n>=e.length)return e;let s=[...e];return[s[r],s[n]]=[s[n],s[r]],s})},className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted/50",title:"Move up",children:(0,v.jsx)(xA,{className:"size-3"})}),(0,v.jsx)("button",{type:"button",onClick:()=>tu(e.id),className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted/50",title:"Send now",children:(0,v.jsx)(xC,{className:"size-3"})}),(0,v.jsx)("button",{type:"button",onClick:()=>{var t;return t=e.id,void w(e=>e.filter(e=>e.id!==t))},className:"p-1 rounded text-muted-foreground hover:text-destructive hover:bg-muted/50",title:"Remove",children:(0,v.jsx)(x_.Trash2,{className:"size-3"})})]})]},e.id))})]}),(0,v.jsx)(y3,{children:(0,v.jsxs)(gU,{onSubmit:ta,className:"shadow-sm",globalDrop:!0,multiple:!0,children:[(0,v.jsxs)(gG,{children:[p&&(0,v.jsxs)("div",{className:(0,k.cn)("mb-2 flex items-center justify-between rounded-md border border-border/60 bg-muted/40 px-2 py-1 text-xs",r&&"mb-1"),children:[(0,v.jsxs)("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,v.jsx)("span",{className:"size-1.5 rounded-full bg-primary/70"}),(0,v.jsx)("span",{children:"Selected elements attached"})]}),(0,v.jsx)("button",{type:"button",onClick:()=>f(null),className:"rounded-sm p-1 text-muted-foreground hover:text-foreground","aria-label":"Remove selected elements",children:(0,v.jsx)(xk.X,{className:"size-3.5"})})]}),(0,v.jsx)(vn,{})]}),(0,v.jsx)(gW,{children:(0,v.jsxs)("div",{className:"relative w-full",children:[(0,v.jsx)(y4,{sessionId:t.id,value:u+(h?(!u||u.endsWith(" ")||u.endsWith("\n")?"":" ")+h:""),onChange:e=>{h&&m(""),d(e)},placeholder:g?"Type to queue a message...":"Ask SparkECoder... (@ to mention files, / for commands)",disabled:!1,autoFocus:!0,className:(0,k.cn)("min-h-[80px] focus:ring-2 focus:ring-primary/20 transition-all field-sizing-content max-h-48",h&&"caret-red-500",r&&"min-h-[40px] text-sm max-h-24")}),h&&(0,v.jsxs)("div",{className:"absolute bottom-2 right-2 flex items-center gap-1.5 text-xs text-red-500 bg-background/80 backdrop-blur-sm px-2 py-1 rounded-full",children:[(0,v.jsx)("span",{className:"size-2 bg-red-500 rounded-full animate-pulse"}),"Listening..."]})]})}),(0,v.jsxs)(gq,{className:r?"py-1":void 0,children:[!r&&(0,v.jsx)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:(0,v.jsx)("span",{className:"hidden sm:inline",children:"Type @ to mention files, / for commands"})}),(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsx)(yv,{size:"icon",className:"size-9",onTranscriptionChange:e=>{d(t=>{let r=t&&!t.endsWith(" ")&&!t.endsWith("\n");return t+(r?" ":"")+e})},onInterimTranscription:e=>{m(e)},disabled:g}),(0,v.jsx)(vs,{input:u+h,isRunning:g,onStop:to,hasExtraContent:!!(p&&p.trim())})]})]})]})})]})}),(0,v.jsx)(yw,{sessionId:t.id,frame:eG,metadata:eH,active:eU&&!eX,onDismiss:()=>{eY(!0),eW(!1)}})]})}var vo=e.i(482079),vl=e.i(461957);function vc({sessionId:e}){let[t,r]=(0,b.useState)(null),[n,s]=(0,b.useState)(""),[i,a]=(0,b.useState)(!1),o=(0,b.useCallback)(async()=>{let t=await (0,xt.getSession)(e);r(t?.pendingQuestion??null)},[e]);if((0,b.useEffect)(()=>{let e=!1,t=async()=>{e||await o()};t();let r=setInterval(t,3e3);return()=>{e=!0,clearInterval(r)}},[o]),!t)return null;let l=async()=>{if(n.trim()&&!i){a(!0);try{await (0,xt.answerAgentQuestion)(e,t.questionId,n.trim()),s(""),r(null),o()}finally{a(!1)}}};return(0,v.jsx)("div",{className:"border-b border-amber-500/40 bg-amber-500/5 px-4 py-3",children:(0,v.jsxs)("div",{className:"flex items-start gap-3 max-w-3xl mx-auto",children:[(0,v.jsx)(vo.MessageCircleQuestion,{className:"size-5 text-amber-500 shrink-0 mt-0.5"}),(0,v.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,v.jsx)("p",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:t.question}),t.context&&(0,v.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:t.context}),t.choices&&t.choices.length>0&&(0,v.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-2",children:t.choices.map(e=>(0,v.jsx)("button",{type:"button",onClick:()=>s(e),className:"text-xs px-2 py-1 rounded bg-amber-500/10 hover:bg-amber-500/20 text-amber-800 dark:text-amber-200",children:e},e))}),(0,v.jsxs)("div",{className:"flex gap-2 mt-2",children:[(0,v.jsx)("input",{type:"text",value:n,onChange:e=>s(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),l())},placeholder:"Type your answer…",className:"flex-1 px-3 py-1.5 text-sm rounded border border-border bg-background focus:outline-none focus:ring-2 focus:ring-amber-500/40",autoFocus:!0}),(0,v.jsx)(S.Button,{size:"sm",onClick:l,disabled:!n.trim()||i,children:i?(0,v.jsx)(vl.Loader2,{className:"size-3.5 animate-spin"}):"Answer"})]})]})]})})}function vu({params:e}){let{id:t}=(0,b.use)(e),r=(0,w.useRouter)(),[n,s]=(0,b.useState)(null),[i,a]=(0,b.useState)(!0),[o,l]=(0,b.useState)(null);return((0,b.useEffect)(()=>{!async function(){try{let e=await (0,xt.getSession)(t);if(!e)return void l("Session not found");s(e)}catch(e){console.error("Failed to load session:",e),l("Failed to load session")}finally{a(!1)}}()},[t]),i)?(0,v.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,v.jsx)(vl.Loader2,{className:"size-8 animate-spin text-muted-foreground"})}):o||!n?(0,v.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,v.jsxs)("div",{className:"text-center",children:[(0,v.jsx)("p",{className:"text-muted-foreground mb-4",children:o||"Session not found"}),(0,v.jsx)("button",{onClick:()=>r.push("/"),className:"text-primary hover:underline",children:"Go back home"})]})}):(0,v.jsxs)("div",{className:"flex flex-col h-full",children:[(0,v.jsx)(vc,{sessionId:n.id}),(0,v.jsx)("div",{className:"flex-1 min-h-0",children:(0,v.jsx)(va,{session:n})})]})}e.s(["default",()=>vu],330460)}]);
@@ -1,7 +1,7 @@
1
1
  {
2
- "apiBaseUrl": "http://127.0.0.1:3144",
3
- "localApiBaseUrl": "http://127.0.0.1:3144",
4
- "version": "0.1.136",
5
- "apiPort": 3144,
6
- "writtenAt": "2026-06-12T22:33:50.925Z"
2
+ "apiBaseUrl": "http://127.0.0.1:3199",
3
+ "localApiBaseUrl": "http://127.0.0.1:3199",
4
+ "version": "0.1.138",
5
+ "apiPort": 3199,
6
+ "writtenAt": "2026-06-13T00:32:04.768Z"
7
7
  }
@@ -1,5 +1,5 @@
1
1
  import { NextResponse } from 'next/server';
2
- import { getLocalApiBaseUrl, getRuntimeVersion } from '@/lib/local-api';
2
+ import { resolveLiveLocalApiBaseUrl, getRuntimeVersion } from '@/lib/local-api';
3
3
 
4
4
  /**
5
5
  * Runtime configuration endpoint.
@@ -28,8 +28,8 @@ export const dynamic = 'force-dynamic';
28
28
 
29
29
  export async function GET() {
30
30
  // Server-side must reach the API over loopback, never the public
31
- // (Cloudflare Access-gated) api-<host> URL.
32
- const apiBaseUrl = getLocalApiBaseUrl();
31
+ // (Cloudflare Access-gated) api-<host> URL. Auto-discovers the live port.
32
+ const apiBaseUrl = await resolveLiveLocalApiBaseUrl();
33
33
 
34
34
  try {
35
35
  // Add timeout to prevent hanging if backend is unreachable