@copilotkit/react-ui 0.0.0-0.0.0-max-changeset-10101010101010-20260109191632

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 (395) hide show
  1. package/CHANGELOG.md +17415 -0
  2. package/LICENSE +21 -0
  3. package/README.md +141 -0
  4. package/dist/chunk-3W6J75HS.mjs +126 -0
  5. package/dist/chunk-3W6J75HS.mjs.map +1 -0
  6. package/dist/chunk-54JAUBUJ.mjs +26 -0
  7. package/dist/chunk-54JAUBUJ.mjs.map +1 -0
  8. package/dist/chunk-7OURDQZJ.mjs +133 -0
  9. package/dist/chunk-7OURDQZJ.mjs.map +1 -0
  10. package/dist/chunk-7PR2KJDO.mjs +222 -0
  11. package/dist/chunk-7PR2KJDO.mjs.map +1 -0
  12. package/dist/chunk-BH6PCAAL.mjs +81 -0
  13. package/dist/chunk-BH6PCAAL.mjs.map +1 -0
  14. package/dist/chunk-C3GSYRC3.mjs +118 -0
  15. package/dist/chunk-C3GSYRC3.mjs.map +1 -0
  16. package/dist/chunk-DBKRAOH7.mjs +34 -0
  17. package/dist/chunk-DBKRAOH7.mjs.map +1 -0
  18. package/dist/chunk-EFZPSZWO.mjs +1 -0
  19. package/dist/chunk-EFZPSZWO.mjs.map +1 -0
  20. package/dist/chunk-ELGRNEAO.mjs +32 -0
  21. package/dist/chunk-ELGRNEAO.mjs.map +1 -0
  22. package/dist/chunk-ELUJRANC.mjs +21 -0
  23. package/dist/chunk-ELUJRANC.mjs.map +1 -0
  24. package/dist/chunk-FFJHOZX6.mjs +202 -0
  25. package/dist/chunk-FFJHOZX6.mjs.map +1 -0
  26. package/dist/chunk-GDSZGYCE.mjs +32 -0
  27. package/dist/chunk-GDSZGYCE.mjs.map +1 -0
  28. package/dist/chunk-HIW7RXCD.mjs +184 -0
  29. package/dist/chunk-HIW7RXCD.mjs.map +1 -0
  30. package/dist/chunk-IEMQ2SQW.mjs +93 -0
  31. package/dist/chunk-IEMQ2SQW.mjs.map +1 -0
  32. package/dist/chunk-IHFR6PYG.mjs +116 -0
  33. package/dist/chunk-IHFR6PYG.mjs.map +1 -0
  34. package/dist/chunk-IK2BPURM.mjs +400 -0
  35. package/dist/chunk-IK2BPURM.mjs.map +1 -0
  36. package/dist/chunk-IU3WTXLQ.mjs +1 -0
  37. package/dist/chunk-IU3WTXLQ.mjs.map +1 -0
  38. package/dist/chunk-JGMFJZMG.mjs +11 -0
  39. package/dist/chunk-JGMFJZMG.mjs.map +1 -0
  40. package/dist/chunk-JY2CSDKN.mjs +135 -0
  41. package/dist/chunk-JY2CSDKN.mjs.map +1 -0
  42. package/dist/chunk-JZ3RFQQ6.mjs +128 -0
  43. package/dist/chunk-JZ3RFQQ6.mjs.map +1 -0
  44. package/dist/chunk-KXE2JCUH.mjs +1 -0
  45. package/dist/chunk-KXE2JCUH.mjs.map +1 -0
  46. package/dist/chunk-LQEFRHRT.mjs +30 -0
  47. package/dist/chunk-LQEFRHRT.mjs.map +1 -0
  48. package/dist/chunk-MMVDU6DF.mjs +1 -0
  49. package/dist/chunk-MMVDU6DF.mjs.map +1 -0
  50. package/dist/chunk-MRXNTQOX.mjs +59 -0
  51. package/dist/chunk-MRXNTQOX.mjs.map +1 -0
  52. package/dist/chunk-NCIAFFQ2.mjs +82 -0
  53. package/dist/chunk-NCIAFFQ2.mjs.map +1 -0
  54. package/dist/chunk-NGJ32FAP.mjs +30 -0
  55. package/dist/chunk-NGJ32FAP.mjs.map +1 -0
  56. package/dist/chunk-NRA3CFEE.mjs +97 -0
  57. package/dist/chunk-NRA3CFEE.mjs.map +1 -0
  58. package/dist/chunk-O72ZB5V3.mjs +140 -0
  59. package/dist/chunk-O72ZB5V3.mjs.map +1 -0
  60. package/dist/chunk-PLHTVHUW.mjs +82 -0
  61. package/dist/chunk-PLHTVHUW.mjs.map +1 -0
  62. package/dist/chunk-Q5V6S67N.mjs +103 -0
  63. package/dist/chunk-Q5V6S67N.mjs.map +1 -0
  64. package/dist/chunk-QB3GUN2N.mjs +31 -0
  65. package/dist/chunk-QB3GUN2N.mjs.map +1 -0
  66. package/dist/chunk-QIOJXTIQ.mjs +64 -0
  67. package/dist/chunk-QIOJXTIQ.mjs.map +1 -0
  68. package/dist/chunk-QPQRLXN3.mjs +435 -0
  69. package/dist/chunk-QPQRLXN3.mjs.map +1 -0
  70. package/dist/chunk-RYUCX3ZK.mjs +32 -0
  71. package/dist/chunk-RYUCX3ZK.mjs.map +1 -0
  72. package/dist/chunk-SC6JRFAJ.mjs +1 -0
  73. package/dist/chunk-SC6JRFAJ.mjs.map +1 -0
  74. package/dist/chunk-T26KLXLH.mjs +1 -0
  75. package/dist/chunk-T26KLXLH.mjs.map +1 -0
  76. package/dist/chunk-UFN2VWSR.mjs +25 -0
  77. package/dist/chunk-UFN2VWSR.mjs.map +1 -0
  78. package/dist/chunk-V7W6IM2V.mjs +1 -0
  79. package/dist/chunk-V7W6IM2V.mjs.map +1 -0
  80. package/dist/chunk-WB3YULQ4.mjs +1 -0
  81. package/dist/chunk-WB3YULQ4.mjs.map +1 -0
  82. package/dist/chunk-XWG3L6QC.mjs +258 -0
  83. package/dist/chunk-XWG3L6QC.mjs.map +1 -0
  84. package/dist/chunk-Y4FKRAKJ.mjs +12 -0
  85. package/dist/chunk-Y4FKRAKJ.mjs.map +1 -0
  86. package/dist/components/chat/Button.d.ts +9 -0
  87. package/dist/components/chat/Button.js +71 -0
  88. package/dist/components/chat/Button.js.map +1 -0
  89. package/dist/components/chat/Button.mjs +10 -0
  90. package/dist/components/chat/Button.mjs.map +1 -0
  91. package/dist/components/chat/Chat.d.ts +204 -0
  92. package/dist/components/chat/Chat.js +2270 -0
  93. package/dist/components/chat/Chat.js.map +1 -0
  94. package/dist/components/chat/Chat.mjs +29 -0
  95. package/dist/components/chat/Chat.mjs.map +1 -0
  96. package/dist/components/chat/ChatContext.d.ts +145 -0
  97. package/dist/components/chat/ChatContext.js +329 -0
  98. package/dist/components/chat/ChatContext.js.map +1 -0
  99. package/dist/components/chat/ChatContext.mjs +13 -0
  100. package/dist/components/chat/ChatContext.mjs.map +1 -0
  101. package/dist/components/chat/CodeBlock.d.ts +14 -0
  102. package/dist/components/chat/CodeBlock.js +510 -0
  103. package/dist/components/chat/CodeBlock.js.map +1 -0
  104. package/dist/components/chat/CodeBlock.mjs +14 -0
  105. package/dist/components/chat/CodeBlock.mjs.map +1 -0
  106. package/dist/components/chat/Header.d.ts +9 -0
  107. package/dist/components/chat/Header.js +582 -0
  108. package/dist/components/chat/Header.js.map +1 -0
  109. package/dist/components/chat/Header.mjs +17 -0
  110. package/dist/components/chat/Header.mjs.map +1 -0
  111. package/dist/components/chat/Icons.d.ts +20 -0
  112. package/dist/components/chat/Icons.js +297 -0
  113. package/dist/components/chat/Icons.js.map +1 -0
  114. package/dist/components/chat/Icons.mjs +38 -0
  115. package/dist/components/chat/Icons.mjs.map +1 -0
  116. package/dist/components/chat/ImageUploadQueue.d.ts +13 -0
  117. package/dist/components/chat/ImageUploadQueue.js +106 -0
  118. package/dist/components/chat/ImageUploadQueue.js.map +1 -0
  119. package/dist/components/chat/ImageUploadQueue.mjs +8 -0
  120. package/dist/components/chat/ImageUploadQueue.mjs.map +1 -0
  121. package/dist/components/chat/Input.d.ts +9 -0
  122. package/dist/components/chat/Input.js +396 -0
  123. package/dist/components/chat/Input.js.map +1 -0
  124. package/dist/components/chat/Input.mjs +14 -0
  125. package/dist/components/chat/Input.mjs.map +1 -0
  126. package/dist/components/chat/Markdown.d.ts +10 -0
  127. package/dist/components/chat/Markdown.js +652 -0
  128. package/dist/components/chat/Markdown.js.map +1 -0
  129. package/dist/components/chat/Markdown.mjs +11 -0
  130. package/dist/components/chat/Markdown.mjs.map +1 -0
  131. package/dist/components/chat/Messages.d.ts +13 -0
  132. package/dist/components/chat/Messages.js +1195 -0
  133. package/dist/components/chat/Messages.js.map +1 -0
  134. package/dist/components/chat/Messages.mjs +20 -0
  135. package/dist/components/chat/Messages.mjs.map +1 -0
  136. package/dist/components/chat/Modal.d.ts +51 -0
  137. package/dist/components/chat/Modal.js +3075 -0
  138. package/dist/components/chat/Modal.js.map +1 -0
  139. package/dist/components/chat/Modal.mjs +38 -0
  140. package/dist/components/chat/Modal.mjs.map +1 -0
  141. package/dist/components/chat/Popup.d.ts +13 -0
  142. package/dist/components/chat/Popup.js +3086 -0
  143. package/dist/components/chat/Popup.js.map +1 -0
  144. package/dist/components/chat/Popup.mjs +39 -0
  145. package/dist/components/chat/Popup.mjs.map +1 -0
  146. package/dist/components/chat/PoweredByTag.d.ts +7 -0
  147. package/dist/components/chat/PoweredByTag.js +61 -0
  148. package/dist/components/chat/PoweredByTag.js.map +1 -0
  149. package/dist/components/chat/PoweredByTag.mjs +9 -0
  150. package/dist/components/chat/PoweredByTag.mjs.map +1 -0
  151. package/dist/components/chat/Sidebar.d.ts +13 -0
  152. package/dist/components/chat/Sidebar.js +3095 -0
  153. package/dist/components/chat/Sidebar.js.map +1 -0
  154. package/dist/components/chat/Sidebar.mjs +39 -0
  155. package/dist/components/chat/Sidebar.mjs.map +1 -0
  156. package/dist/components/chat/Suggestion.d.ts +12 -0
  157. package/dist/components/chat/Suggestion.js +56 -0
  158. package/dist/components/chat/Suggestion.js.map +1 -0
  159. package/dist/components/chat/Suggestion.mjs +9 -0
  160. package/dist/components/chat/Suggestion.mjs.map +1 -0
  161. package/dist/components/chat/Suggestions.d.ts +9 -0
  162. package/dist/components/chat/Suggestions.js +81 -0
  163. package/dist/components/chat/Suggestions.js.map +1 -0
  164. package/dist/components/chat/Suggestions.mjs +10 -0
  165. package/dist/components/chat/Suggestions.mjs.map +1 -0
  166. package/dist/components/chat/Textarea.d.ts +15 -0
  167. package/dist/components/chat/Textarea.js +84 -0
  168. package/dist/components/chat/Textarea.js.map +1 -0
  169. package/dist/components/chat/Textarea.mjs +8 -0
  170. package/dist/components/chat/Textarea.mjs.map +1 -0
  171. package/dist/components/chat/Window.d.ts +9 -0
  172. package/dist/components/chat/Window.js +164 -0
  173. package/dist/components/chat/Window.js.map +1 -0
  174. package/dist/components/chat/Window.mjs +10 -0
  175. package/dist/components/chat/Window.mjs.map +1 -0
  176. package/dist/components/chat/index.d.ts +18 -0
  177. package/dist/components/chat/index.js +3122 -0
  178. package/dist/components/chat/index.js.map +1 -0
  179. package/dist/components/chat/index.mjs +69 -0
  180. package/dist/components/chat/index.mjs.map +1 -0
  181. package/dist/components/chat/messages/AssistantMessage.d.ts +9 -0
  182. package/dist/components/chat/messages/AssistantMessage.js +775 -0
  183. package/dist/components/chat/messages/AssistantMessage.js.map +1 -0
  184. package/dist/components/chat/messages/AssistantMessage.mjs +13 -0
  185. package/dist/components/chat/messages/AssistantMessage.mjs.map +1 -0
  186. package/dist/components/chat/messages/ErrorMessage.d.ts +9 -0
  187. package/dist/components/chat/messages/ErrorMessage.js +722 -0
  188. package/dist/components/chat/messages/ErrorMessage.js.map +1 -0
  189. package/dist/components/chat/messages/ErrorMessage.mjs +66 -0
  190. package/dist/components/chat/messages/ErrorMessage.mjs.map +1 -0
  191. package/dist/components/chat/messages/ImageRenderer.d.ts +12 -0
  192. package/dist/components/chat/messages/ImageRenderer.js +58 -0
  193. package/dist/components/chat/messages/ImageRenderer.js.map +1 -0
  194. package/dist/components/chat/messages/ImageRenderer.mjs +8 -0
  195. package/dist/components/chat/messages/ImageRenderer.mjs.map +1 -0
  196. package/dist/components/chat/messages/LegacyRenderMessage.d.ts +28 -0
  197. package/dist/components/chat/messages/LegacyRenderMessage.js +1023 -0
  198. package/dist/components/chat/messages/LegacyRenderMessage.js.map +1 -0
  199. package/dist/components/chat/messages/LegacyRenderMessage.mjs +17 -0
  200. package/dist/components/chat/messages/LegacyRenderMessage.mjs.map +1 -0
  201. package/dist/components/chat/messages/RenderMessage.d.ts +9 -0
  202. package/dist/components/chat/messages/RenderMessage.js +898 -0
  203. package/dist/components/chat/messages/RenderMessage.js.map +1 -0
  204. package/dist/components/chat/messages/RenderMessage.mjs +16 -0
  205. package/dist/components/chat/messages/RenderMessage.mjs.map +1 -0
  206. package/dist/components/chat/messages/UserMessage.d.ts +9 -0
  207. package/dist/components/chat/messages/UserMessage.js +56 -0
  208. package/dist/components/chat/messages/UserMessage.js.map +1 -0
  209. package/dist/components/chat/messages/UserMessage.mjs +8 -0
  210. package/dist/components/chat/messages/UserMessage.mjs.map +1 -0
  211. package/dist/components/chat/props.d.ts +298 -0
  212. package/dist/components/chat/props.js +19 -0
  213. package/dist/components/chat/props.js.map +1 -0
  214. package/dist/components/chat/props.mjs +2 -0
  215. package/dist/components/chat/props.mjs.map +1 -0
  216. package/dist/components/dev-console/console.d.ts +11 -0
  217. package/dist/components/dev-console/console.js +537 -0
  218. package/dist/components/dev-console/console.js.map +1 -0
  219. package/dist/components/dev-console/console.mjs +17 -0
  220. package/dist/components/dev-console/console.mjs.map +1 -0
  221. package/dist/components/dev-console/icons.d.ts +9 -0
  222. package/dist/components/dev-console/icons.js +131 -0
  223. package/dist/components/dev-console/icons.js.map +1 -0
  224. package/dist/components/dev-console/icons.mjs +16 -0
  225. package/dist/components/dev-console/icons.mjs.map +1 -0
  226. package/dist/components/dev-console/index.d.ts +3 -0
  227. package/dist/components/dev-console/index.js +537 -0
  228. package/dist/components/dev-console/index.js.map +1 -0
  229. package/dist/components/dev-console/index.mjs +18 -0
  230. package/dist/components/dev-console/index.mjs.map +1 -0
  231. package/dist/components/dev-console/types.d.ts +9 -0
  232. package/dist/components/dev-console/types.js +19 -0
  233. package/dist/components/dev-console/types.js.map +1 -0
  234. package/dist/components/dev-console/types.mjs +1 -0
  235. package/dist/components/dev-console/types.mjs.map +1 -0
  236. package/dist/components/dev-console/utils.d.ts +10 -0
  237. package/dist/components/dev-console/utils.js +177 -0
  238. package/dist/components/dev-console/utils.js.map +1 -0
  239. package/dist/components/dev-console/utils.mjs +16 -0
  240. package/dist/components/dev-console/utils.mjs.map +1 -0
  241. package/dist/components/help-modal/icons.d.ts +9 -0
  242. package/dist/components/help-modal/icons.js +107 -0
  243. package/dist/components/help-modal/icons.js.map +1 -0
  244. package/dist/components/help-modal/icons.mjs +12 -0
  245. package/dist/components/help-modal/icons.mjs.map +1 -0
  246. package/dist/components/help-modal/index.d.ts +2 -0
  247. package/dist/components/help-modal/index.js +137 -0
  248. package/dist/components/help-modal/index.js.map +1 -0
  249. package/dist/components/help-modal/index.mjs +10 -0
  250. package/dist/components/help-modal/index.mjs.map +1 -0
  251. package/dist/components/help-modal/modal.d.ts +5 -0
  252. package/dist/components/help-modal/modal.js +135 -0
  253. package/dist/components/help-modal/modal.js.map +1 -0
  254. package/dist/components/help-modal/modal.mjs +9 -0
  255. package/dist/components/help-modal/modal.mjs.map +1 -0
  256. package/dist/components/index.d.ts +19 -0
  257. package/dist/components/index.js +3126 -0
  258. package/dist/components/index.js.map +1 -0
  259. package/dist/components/index.mjs +76 -0
  260. package/dist/components/index.mjs.map +1 -0
  261. package/dist/context/index.d.ts +2 -0
  262. package/dist/context/index.js +19 -0
  263. package/dist/context/index.js.map +1 -0
  264. package/dist/context/index.mjs +2 -0
  265. package/dist/context/index.mjs.map +1 -0
  266. package/dist/hooks/index.d.ts +2 -0
  267. package/dist/hooks/index.js +36 -0
  268. package/dist/hooks/index.js.map +1 -0
  269. package/dist/hooks/index.mjs +9 -0
  270. package/dist/hooks/index.mjs.map +1 -0
  271. package/dist/hooks/use-copilot-chat-suggestions.d.ts +66 -0
  272. package/dist/hooks/use-copilot-chat-suggestions.js +34 -0
  273. package/dist/hooks/use-copilot-chat-suggestions.js.map +1 -0
  274. package/dist/hooks/use-copilot-chat-suggestions.mjs +8 -0
  275. package/dist/hooks/use-copilot-chat-suggestions.mjs.map +1 -0
  276. package/dist/hooks/use-copy-to-clipboard.d.ts +9 -0
  277. package/dist/hooks/use-copy-to-clipboard.js +60 -0
  278. package/dist/hooks/use-copy-to-clipboard.js.map +1 -0
  279. package/dist/hooks/use-copy-to-clipboard.mjs +8 -0
  280. package/dist/hooks/use-copy-to-clipboard.mjs.map +1 -0
  281. package/dist/hooks/use-dark-mode.d.ts +3 -0
  282. package/dist/hooks/use-dark-mode.js +35 -0
  283. package/dist/hooks/use-dark-mode.js.map +1 -0
  284. package/dist/hooks/use-dark-mode.mjs +8 -0
  285. package/dist/hooks/use-dark-mode.mjs.map +1 -0
  286. package/dist/hooks/use-push-to-talk.d.ts +19 -0
  287. package/dist/hooks/use-push-to-talk.js +195 -0
  288. package/dist/hooks/use-push-to-talk.js.map +1 -0
  289. package/dist/hooks/use-push-to-talk.mjs +12 -0
  290. package/dist/hooks/use-push-to-talk.mjs.map +1 -0
  291. package/dist/index.css +1258 -0
  292. package/dist/index.css.map +1 -0
  293. package/dist/index.d.ts +21 -0
  294. package/dist/index.js +3135 -0
  295. package/dist/index.js.map +1 -0
  296. package/dist/index.mjs +84 -0
  297. package/dist/index.mjs.map +1 -0
  298. package/dist/lib/utils.d.ts +4 -0
  299. package/dist/lib/utils.js +76 -0
  300. package/dist/lib/utils.js.map +1 -0
  301. package/dist/lib/utils.mjs +34 -0
  302. package/dist/lib/utils.mjs.map +1 -0
  303. package/dist/types/css.d.ts +22 -0
  304. package/dist/types/css.js +19 -0
  305. package/dist/types/css.js.map +1 -0
  306. package/dist/types/css.mjs +1 -0
  307. package/dist/types/css.mjs.map +1 -0
  308. package/dist/types/index.d.ts +3 -0
  309. package/dist/types/index.js +19 -0
  310. package/dist/types/index.js.map +1 -0
  311. package/dist/types/index.mjs +2 -0
  312. package/dist/types/index.mjs.map +1 -0
  313. package/dist/types/suggestions.d.ts +9 -0
  314. package/dist/types/suggestions.js +19 -0
  315. package/dist/types/suggestions.js.map +1 -0
  316. package/dist/types/suggestions.mjs +1 -0
  317. package/dist/types/suggestions.mjs.map +1 -0
  318. package/dist/v2/index.css +4 -0
  319. package/dist/v2/index.css.map +1 -0
  320. package/dist/v2/index.d.ts +2 -0
  321. package/dist/v2/index.js +2 -0
  322. package/dist/v2/index.js.map +1 -0
  323. package/dist/v2/index.mjs +2 -0
  324. package/dist/v2/index.mjs.map +1 -0
  325. package/jest.config.js +5 -0
  326. package/package.json +83 -0
  327. package/postcss.config.js +60 -0
  328. package/src/components/chat/Button.tsx +18 -0
  329. package/src/components/chat/Chat.tsx +795 -0
  330. package/src/components/chat/ChatContext.tsx +248 -0
  331. package/src/components/chat/CodeBlock.tsx +418 -0
  332. package/src/components/chat/Header.tsx +24 -0
  333. package/src/components/chat/Icons.tsx +237 -0
  334. package/src/components/chat/ImageUploadQueue.tsx +77 -0
  335. package/src/components/chat/Input.tsx +156 -0
  336. package/src/components/chat/Markdown.tsx +144 -0
  337. package/src/components/chat/Messages.tsx +206 -0
  338. package/src/components/chat/Modal.tsx +220 -0
  339. package/src/components/chat/Popup.tsx +77 -0
  340. package/src/components/chat/PoweredByTag.tsx +42 -0
  341. package/src/components/chat/Sidebar.tsx +96 -0
  342. package/src/components/chat/Suggestion.tsx +29 -0
  343. package/src/components/chat/Suggestions.tsx +23 -0
  344. package/src/components/chat/Textarea.tsx +77 -0
  345. package/src/components/chat/Window.tsx +152 -0
  346. package/src/components/chat/index.tsx +11 -0
  347. package/src/components/chat/messages/AssistantMessage.tsx +118 -0
  348. package/src/components/chat/messages/ErrorMessage.tsx +59 -0
  349. package/src/components/chat/messages/ImageRenderer.tsx +37 -0
  350. package/src/components/chat/messages/LegacyRenderMessage.tsx +150 -0
  351. package/src/components/chat/messages/RenderMessage.tsx +61 -0
  352. package/src/components/chat/messages/UserMessage.tsx +46 -0
  353. package/src/components/chat/props.ts +353 -0
  354. package/src/components/dev-console/console.tsx +242 -0
  355. package/src/components/dev-console/icons.tsx +99 -0
  356. package/src/components/dev-console/index.tsx +2 -0
  357. package/src/components/dev-console/types.ts +7 -0
  358. package/src/components/dev-console/utils.ts +142 -0
  359. package/src/components/help-modal/icons.tsx +68 -0
  360. package/src/components/help-modal/index.tsx +1 -0
  361. package/src/components/help-modal/modal.tsx +101 -0
  362. package/src/components/index.ts +2 -0
  363. package/src/context/index.ts +1 -0
  364. package/src/css/animations.css +35 -0
  365. package/src/css/button.css +67 -0
  366. package/src/css/colors.css +78 -0
  367. package/src/css/console.css +166 -0
  368. package/src/css/crew.css +277 -0
  369. package/src/css/header.css +65 -0
  370. package/src/css/input.css +152 -0
  371. package/src/css/markdown.css +150 -0
  372. package/src/css/messages.css +244 -0
  373. package/src/css/panel.css +39 -0
  374. package/src/css/popup.css +22 -0
  375. package/src/css/sidebar.css +34 -0
  376. package/src/css/suggestions.css +43 -0
  377. package/src/css/window.css +60 -0
  378. package/src/hooks/index.ts +1 -0
  379. package/src/hooks/use-copilot-chat-suggestions.tsx +71 -0
  380. package/src/hooks/use-copy-to-clipboard.tsx +29 -0
  381. package/src/hooks/use-dark-mode.ts +10 -0
  382. package/src/hooks/use-push-to-talk.tsx +167 -0
  383. package/src/index.tsx +7 -0
  384. package/src/lib/utils.test.ts +7 -0
  385. package/src/lib/utils.ts +27 -0
  386. package/src/styles.css +14 -0
  387. package/src/types/css.ts +21 -0
  388. package/src/types/index.ts +2 -0
  389. package/src/types/suggestions.ts +7 -0
  390. package/src/v2/index.ts +1 -0
  391. package/src/v2/styles.css +1 -0
  392. package/tailwind.config.js +7 -0
  393. package/tsconfig.json +12 -0
  394. package/tsup.config.ts +11 -0
  395. package/typedoc.json +4 -0
@@ -0,0 +1,3126 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __objRest = (source, exclude) => {
26
+ var target = {};
27
+ for (var prop in source)
28
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
+ target[prop] = source[prop];
30
+ if (source != null && __getOwnPropSymbols)
31
+ for (var prop of __getOwnPropSymbols(source)) {
32
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
+ target[prop] = source[prop];
34
+ }
35
+ return target;
36
+ };
37
+ var __export = (target, all) => {
38
+ for (var name in all)
39
+ __defProp(target, name, { get: all[name], enumerable: true });
40
+ };
41
+ var __copyProps = (to, from, except, desc) => {
42
+ if (from && typeof from === "object" || typeof from === "function") {
43
+ for (let key of __getOwnPropNames(from))
44
+ if (!__hasOwnProp.call(to, key) && key !== except)
45
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
46
+ }
47
+ return to;
48
+ };
49
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
50
+ // If the importer is in node compatibility mode or this is not an ESM
51
+ // file that has been converted to a CommonJS file using a Babel-
52
+ // compatible transform (i.e. "__esModule" has not been set), then set
53
+ // "default" to the CommonJS "module.exports" for node compatibility.
54
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
55
+ mod
56
+ ));
57
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
58
+ var __async = (__this, __arguments, generator) => {
59
+ return new Promise((resolve, reject) => {
60
+ var fulfilled = (value) => {
61
+ try {
62
+ step(generator.next(value));
63
+ } catch (e) {
64
+ reject(e);
65
+ }
66
+ };
67
+ var rejected = (value) => {
68
+ try {
69
+ step(generator.throw(value));
70
+ } catch (e) {
71
+ reject(e);
72
+ }
73
+ };
74
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
75
+ step((generator = generator.apply(__this, __arguments)).next());
76
+ });
77
+ };
78
+
79
+ // src/components/index.ts
80
+ var components_exports = {};
81
+ __export(components_exports, {
82
+ AssistantMessage: () => AssistantMessage,
83
+ CopilotChat: () => CopilotChat,
84
+ CopilotDevConsole: () => CopilotDevConsole,
85
+ CopilotPopup: () => CopilotPopup,
86
+ CopilotSidebar: () => CopilotSidebar,
87
+ ImageRenderer: () => ImageRenderer,
88
+ Markdown: () => Markdown,
89
+ RenderSuggestion: () => Suggestion,
90
+ RenderSuggestionsList: () => Suggestions,
91
+ UserMessage: () => UserMessage,
92
+ shouldShowDevConsole: () => import_react_core3.shouldShowDevConsole,
93
+ useChatContext: () => useChatContext
94
+ });
95
+ module.exports = __toCommonJS(components_exports);
96
+
97
+ // src/components/chat/Modal.tsx
98
+ var import_react16 = __toESM(require("react"));
99
+
100
+ // src/components/chat/ChatContext.tsx
101
+ var import_react = __toESM(require("react"));
102
+
103
+ // src/components/chat/Icons.tsx
104
+ var import_jsx_runtime = require("react/jsx-runtime");
105
+ var OpenIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
106
+ "svg",
107
+ {
108
+ xmlns: "http://www.w3.org/2000/svg",
109
+ viewBox: "0 0 24 24",
110
+ fill: "currentColor",
111
+ width: "24",
112
+ height: "24",
113
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", { transform: "translate(24, 0) scale(-1, 1)", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
114
+ "path",
115
+ {
116
+ fillRule: "evenodd",
117
+ d: "M5.337 21.718a6.707 6.707 0 01-.533-.074.75.75 0 01-.44-1.223 3.73 3.73 0 00.814-1.686c.023-.115-.022-.317-.254-.543C3.274 16.587 2.25 14.41 2.25 12c0-5.03 4.428-9 9.75-9s9.75 3.97 9.75 9c0 5.03-4.428 9-9.75 9-.833 0-1.643-.097-2.417-.279a6.721 6.721 0 01-4.246.997z",
118
+ clipRule: "evenodd"
119
+ }
120
+ ) })
121
+ }
122
+ );
123
+ var CloseIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
124
+ "svg",
125
+ {
126
+ xmlns: "http://www.w3.org/2000/svg",
127
+ fill: "none",
128
+ viewBox: "0 0 24 24",
129
+ strokeWidth: "1.5",
130
+ stroke: "currentColor",
131
+ width: "24",
132
+ height: "24",
133
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19.5 8.25l-7.5 7.5-7.5-7.5" })
134
+ }
135
+ );
136
+ var HeaderCloseIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
137
+ "svg",
138
+ {
139
+ xmlns: "http://www.w3.org/2000/svg",
140
+ fill: "none",
141
+ viewBox: "0 0 24 24",
142
+ strokeWidth: "1.5",
143
+ stroke: "currentColor",
144
+ width: "24",
145
+ height: "24",
146
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
147
+ }
148
+ );
149
+ var SendIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
150
+ "svg",
151
+ {
152
+ xmlns: "http://www.w3.org/2000/svg",
153
+ fill: "none",
154
+ viewBox: "0 0 24 24",
155
+ strokeWidth: "1.5",
156
+ stroke: "currentColor",
157
+ width: "24",
158
+ height: "24",
159
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M12 19V5m0 0l-7 7m7-7l7 7" })
160
+ }
161
+ );
162
+ var MicrophoneIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
163
+ "svg",
164
+ {
165
+ xmlns: "http://www.w3.org/2000/svg",
166
+ fill: "none",
167
+ viewBox: "0 0 24 24",
168
+ strokeWidth: "1.5",
169
+ stroke: "currentColor",
170
+ width: "24",
171
+ height: "24",
172
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
173
+ "path",
174
+ {
175
+ strokeLinecap: "round",
176
+ strokeLinejoin: "round",
177
+ d: "M12 18.75a6 6 0 006-6v-1.5m-6 7.5a6 6 0 01-6-6v-1.5m6 7.5v3.75m-3.75 0h7.5M12 15.75a3 3 0 01-3-3V4.5a3 3 0 116 0v8.25a3 3 0 01-3 3z"
178
+ }
179
+ )
180
+ }
181
+ );
182
+ var StopIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
183
+ "svg",
184
+ {
185
+ xmlns: "http://www.w3.org/2000/svg",
186
+ fill: "none",
187
+ viewBox: "0 0 24 24",
188
+ strokeWidth: "1.5",
189
+ stroke: "currentColor",
190
+ width: "24",
191
+ height: "24",
192
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
193
+ "path",
194
+ {
195
+ strokeLinecap: "round",
196
+ strokeLinejoin: "round",
197
+ d: "M5.25 7.5A2.25 2.25 0 017.5 5.25h9a2.25 2.25 0 012.25 2.25v9a2.25 2.25 0 01-2.25 2.25h-9a2.25 2.25 0 01-2.25-2.25v-9z"
198
+ }
199
+ )
200
+ }
201
+ );
202
+ var RegenerateIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
203
+ "svg",
204
+ {
205
+ xmlns: "http://www.w3.org/2000/svg",
206
+ fill: "none",
207
+ viewBox: "0 0 24 24",
208
+ strokeWidth: "2",
209
+ stroke: "currentColor",
210
+ width: "16",
211
+ height: "16",
212
+ style: { minWidth: "16px", minHeight: "16px" },
213
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
214
+ "path",
215
+ {
216
+ strokeLinecap: "round",
217
+ strokeLinejoin: "round",
218
+ d: "M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99"
219
+ }
220
+ )
221
+ }
222
+ );
223
+ var CopyIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
224
+ "svg",
225
+ {
226
+ xmlns: "http://www.w3.org/2000/svg",
227
+ fill: "none",
228
+ viewBox: "0 0 24 24",
229
+ strokeWidth: "2",
230
+ stroke: "currentColor",
231
+ width: "16",
232
+ height: "16",
233
+ style: { minWidth: "16px", minHeight: "16px" },
234
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
235
+ "path",
236
+ {
237
+ strokeLinecap: "round",
238
+ strokeLinejoin: "round",
239
+ d: "M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 01-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 011.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 00-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 01-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 00-3.375-3.375h-1.5a1.125 1.125 0 01-1.125-1.125v-1.5a3.375 3.375 0 00-3.375-3.375H9.75"
240
+ }
241
+ )
242
+ }
243
+ );
244
+ var SmallSpinnerIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "copilotKitSpinner", style: { width: "13px", height: "13px" } });
245
+ var SpinnerIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "copilotKitSpinner", style: { width: "24px", height: "24px" } });
246
+ var ActivityIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "4px" }, children: [
247
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "copilotKitActivityDot", style: { animationDelay: "0s" } }),
248
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "copilotKitActivityDot", style: { animationDelay: "0.2s" } }),
249
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "copilotKitActivityDot", style: { animationDelay: "0.4s" } })
250
+ ] });
251
+ var ThumbsUpIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
252
+ "svg",
253
+ {
254
+ xmlns: "http://www.w3.org/2000/svg",
255
+ fill: "none",
256
+ viewBox: "0 0 24 24",
257
+ strokeWidth: "2",
258
+ stroke: "currentColor",
259
+ width: "16",
260
+ height: "16",
261
+ style: { minWidth: "16px", minHeight: "16px" },
262
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
263
+ "path",
264
+ {
265
+ strokeLinecap: "round",
266
+ strokeLinejoin: "round",
267
+ d: "M6.633 10.5c.806 0 1.533-.446 2.031-1.08a9.041 9.041 0 012.861-2.4c.723-.384 1.35-.956 1.653-1.715a4.498 4.498 0 00.322-1.672V3a.75.75 0 01.75-.75A2.25 2.25 0 0116.5 4.5c0 1.152-.26 2.243-.723 3.218-.266.558.107 1.282.725 1.282h3.126c1.026 0 1.945.694 2.054 1.715.045.422.068.85.068 1.285a11.95 11.95 0 01-2.649 7.521c-.388.482-.987.729-1.605.729H13.48c-.483 0-.964-.078-1.423-.23l-3.114-1.04a4.501 4.501 0 00-1.423-.23H5.904M14.25 9h2.25M5.904 18.75c.083.205.173.405.27.602.197.4-.078.898-.523.898h-.908c-.889 0-1.713-.518-1.972-1.368a12 12 0 01-.521-3.507c0-1.553.295-3.036.831-4.398C3.387 10.203 4.167 9.75 5 9.75h1.053c.472 0 .745.556.5.96a8.958 8.958 0 00-1.302 4.665c0 1.194.232 2.333.654 3.375z"
268
+ }
269
+ )
270
+ }
271
+ );
272
+ var ThumbsDownIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
273
+ "svg",
274
+ {
275
+ xmlns: "http://www.w3.org/2000/svg",
276
+ fill: "none",
277
+ viewBox: "0 0 24 24",
278
+ strokeWidth: "2",
279
+ stroke: "currentColor",
280
+ width: "16",
281
+ height: "16",
282
+ style: { minWidth: "16px", minHeight: "16px" },
283
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
284
+ "path",
285
+ {
286
+ strokeLinecap: "round",
287
+ strokeLinejoin: "round",
288
+ d: "M7.5 15h2.25m8.024-9.75c.011.05.028.1.052.148.591 1.2.924 2.55.924 3.977a8.96 8.96 0 01-.999 4.125m.023-8.25c-.076-.365.183-.75.575-.75h.908c.889 0 1.713.518 1.972 1.368.339 1.11.521 2.287.521 3.507 0 1.553-.295 3.036-.831 4.398C20.613 14.547 19.833 15 19 15h-1.053c-.472 0-.745-.556-.5-.96a8.95 8.95 0 00.303-.54m.023-8.25H16.48a4.5 4.5 0 01-1.423-.23l-3.114-1.04a4.5 4.5 0 00-1.423-.23H6.504c-.618 0-1.217.247-1.605.729A11.95 11.95 0 002.25 12c0 .434.023.863.068 1.285C2.427 14.306 3.346 15 4.372 15h3.126c.618 0 .991.724.725 1.282A7.471 7.471 0 007.5 19.5a2.25 2.25 0 002.25 2.25.75.75 0 00.75-.75v-.633c0-.573.11-1.14.322-1.672.304-.76.93-1.33 1.653-1.715a9.04 9.04 0 002.86-2.4c.498-.634 1.226-1.08 2.032-1.08h.384"
289
+ }
290
+ )
291
+ }
292
+ );
293
+ var DownloadIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
294
+ "svg",
295
+ {
296
+ xmlns: "http://www.w3.org/2000/svg",
297
+ fill: "none",
298
+ viewBox: "0 0 24 24",
299
+ strokeWidth: "2",
300
+ stroke: "currentColor",
301
+ width: "16",
302
+ height: "16",
303
+ style: { minWidth: "16px", minHeight: "16px" },
304
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
305
+ "path",
306
+ {
307
+ strokeLinecap: "round",
308
+ strokeLinejoin: "round",
309
+ d: "M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5M16.5 12L12 16.5m0 0L7.5 12m4.5 4.5V3"
310
+ }
311
+ )
312
+ }
313
+ );
314
+ var UploadIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
315
+ "svg",
316
+ {
317
+ xmlns: "http://www.w3.org/2000/svg",
318
+ fill: "none",
319
+ viewBox: "0 0 24 24",
320
+ strokeWidth: "1.5",
321
+ stroke: "currentColor",
322
+ width: "24",
323
+ height: "24",
324
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M12 4.5v15m7.5-7.5h-15" })
325
+ }
326
+ );
327
+ var CheckIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
328
+ "svg",
329
+ {
330
+ xmlns: "http://www.w3.org/2000/svg",
331
+ fill: "none",
332
+ viewBox: "0 0 24 24",
333
+ strokeWidth: "2",
334
+ stroke: "currentColor",
335
+ width: "16",
336
+ height: "16",
337
+ style: { minWidth: "16px", minHeight: "16px" },
338
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4.5 12.75l6 6 9-13.5" })
339
+ }
340
+ );
341
+
342
+ // src/components/chat/ChatContext.tsx
343
+ var import_jsx_runtime2 = require("react/jsx-runtime");
344
+ var ChatContext = import_react.default.createContext(void 0);
345
+ function useChatContext() {
346
+ const context = import_react.default.useContext(ChatContext);
347
+ if (context === void 0) {
348
+ throw new Error(
349
+ "Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?"
350
+ );
351
+ }
352
+ return context;
353
+ }
354
+ var ChatContextProvider = ({
355
+ // temperature,
356
+ // instructions,
357
+ // maxFeedback,
358
+ labels,
359
+ icons,
360
+ children,
361
+ open,
362
+ setOpen
363
+ }) => {
364
+ const memoizedLabels = (0, import_react.useMemo)(
365
+ () => __spreadValues(__spreadValues({}, {
366
+ initial: "",
367
+ title: "CopilotKit",
368
+ placeholder: "Type a message...",
369
+ error: "\u274C An error occurred. Please try again.",
370
+ stopGenerating: "Stop generating",
371
+ regenerateResponse: "Regenerate response",
372
+ copyToClipboard: "Copy to clipboard",
373
+ thumbsUp: "Thumbs up",
374
+ thumbsDown: "Thumbs down",
375
+ copied: "Copied!"
376
+ }), labels),
377
+ [labels]
378
+ );
379
+ const memoizedIcons = (0, import_react.useMemo)(
380
+ () => __spreadValues(__spreadValues({}, {
381
+ openIcon: OpenIcon,
382
+ closeIcon: CloseIcon,
383
+ headerCloseIcon: HeaderCloseIcon,
384
+ sendIcon: SendIcon,
385
+ activityIcon: ActivityIcon,
386
+ spinnerIcon: SpinnerIcon,
387
+ stopIcon: StopIcon,
388
+ regenerateIcon: RegenerateIcon,
389
+ pushToTalkIcon: MicrophoneIcon,
390
+ copyIcon: CopyIcon,
391
+ thumbsUpIcon: ThumbsUpIcon,
392
+ thumbsDownIcon: ThumbsDownIcon,
393
+ uploadIcon: UploadIcon
394
+ }), icons),
395
+ [icons]
396
+ );
397
+ const context = (0, import_react.useMemo)(
398
+ () => ({
399
+ labels: memoizedLabels,
400
+ icons: memoizedIcons,
401
+ open,
402
+ setOpen
403
+ }),
404
+ [memoizedLabels, memoizedIcons, open, setOpen]
405
+ );
406
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ChatContext.Provider, { value: context, children });
407
+ };
408
+
409
+ // src/components/chat/Window.tsx
410
+ var import_react2 = __toESM(require("react"));
411
+ var import_react_core = require("@copilotkit/react-core");
412
+ var import_shared = require("@copilotkit/shared");
413
+ var import_jsx_runtime3 = require("react/jsx-runtime");
414
+ var Window = ({
415
+ children,
416
+ clickOutsideToClose,
417
+ shortcut,
418
+ hitEscapeToClose
419
+ }) => {
420
+ const windowRef = import_react2.default.useRef(null);
421
+ const context = (0, import_react_core.useCopilotContext)();
422
+ const { open, setOpen } = useChatContext();
423
+ const handleClickOutside = (0, import_react2.useCallback)(
424
+ (event) => {
425
+ var _a;
426
+ if (!clickOutsideToClose) {
427
+ return;
428
+ }
429
+ const parentElement = (_a = windowRef.current) == null ? void 0 : _a.parentElement;
430
+ let className = "";
431
+ if (event.target instanceof HTMLElement) {
432
+ className = event.target.className;
433
+ }
434
+ if (open && parentElement && !parentElement.contains(event.target) && // prevent closing the window when clicking on the debug menu
435
+ !className.includes("copilotKitDebugMenu")) {
436
+ setOpen(false);
437
+ }
438
+ },
439
+ [clickOutsideToClose, open, setOpen]
440
+ );
441
+ const handleKeyDown = (0, import_react2.useCallback)(
442
+ (event) => {
443
+ var _a;
444
+ const target = event.target;
445
+ const isInput = target.tagName === "INPUT" || target.tagName === "SELECT" || target.tagName === "TEXTAREA" || target.isContentEditable;
446
+ const isDescendantOfWrapper = (_a = windowRef.current) == null ? void 0 : _a.contains(target);
447
+ if (open && event.key === "Escape" && (!isInput || isDescendantOfWrapper) && hitEscapeToClose) {
448
+ setOpen(false);
449
+ } else if (event.key === shortcut && ((0, import_shared.isMacOS)() && event.metaKey || !(0, import_shared.isMacOS)() && event.ctrlKey) && (!isInput || isDescendantOfWrapper)) {
450
+ setOpen(!open);
451
+ }
452
+ },
453
+ [hitEscapeToClose, shortcut, open, setOpen]
454
+ );
455
+ const adjustForMobile = (0, import_react2.useCallback)(() => {
456
+ const copilotKitWindow = windowRef.current;
457
+ const vv = window.visualViewport;
458
+ if (!copilotKitWindow || !vv) {
459
+ return;
460
+ }
461
+ if (window.innerWidth < 640 && open) {
462
+ copilotKitWindow.style.height = `${vv.height}px`;
463
+ copilotKitWindow.style.left = `${vv.offsetLeft}px`;
464
+ copilotKitWindow.style.top = `${vv.offsetTop}px`;
465
+ document.body.style.position = "fixed";
466
+ document.body.style.width = "100%";
467
+ document.body.style.height = `${window.innerHeight}px`;
468
+ document.body.style.overflow = "hidden";
469
+ document.body.style.touchAction = "none";
470
+ document.body.addEventListener("touchmove", preventScroll, {
471
+ passive: false
472
+ });
473
+ } else {
474
+ copilotKitWindow.style.height = "";
475
+ copilotKitWindow.style.left = "";
476
+ copilotKitWindow.style.top = "";
477
+ document.body.style.position = "";
478
+ document.body.style.height = "";
479
+ document.body.style.width = "";
480
+ document.body.style.overflow = "";
481
+ document.body.style.top = "";
482
+ document.body.style.touchAction = "";
483
+ document.body.removeEventListener("touchmove", preventScroll);
484
+ }
485
+ }, [open]);
486
+ (0, import_react2.useEffect)(() => {
487
+ document.addEventListener("mousedown", handleClickOutside);
488
+ document.addEventListener("keydown", handleKeyDown);
489
+ if (window.visualViewport) {
490
+ window.visualViewport.addEventListener("resize", adjustForMobile);
491
+ adjustForMobile();
492
+ }
493
+ return () => {
494
+ document.removeEventListener("mousedown", handleClickOutside);
495
+ document.removeEventListener("keydown", handleKeyDown);
496
+ if (window.visualViewport) {
497
+ window.visualViewport.removeEventListener("resize", adjustForMobile);
498
+ }
499
+ };
500
+ }, [adjustForMobile, handleClickOutside, handleKeyDown]);
501
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: `copilotKitWindow ${open ? " open" : ""}`, ref: windowRef, children });
502
+ };
503
+ var preventScroll = (event) => {
504
+ let targetElement = event.target;
505
+ const hasParentWithClass = (element, className) => {
506
+ while (element && element !== document.body) {
507
+ if (element.classList.contains(className)) {
508
+ return true;
509
+ }
510
+ element = element.parentElement;
511
+ }
512
+ return false;
513
+ };
514
+ if (!hasParentWithClass(targetElement, "copilotKitMessages")) {
515
+ event.preventDefault();
516
+ }
517
+ };
518
+
519
+ // src/components/chat/Button.tsx
520
+ var import_jsx_runtime4 = require("react/jsx-runtime");
521
+ var Button = ({}) => {
522
+ const { open, setOpen, icons } = useChatContext();
523
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { onClick: () => setOpen(!open), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
524
+ "button",
525
+ {
526
+ className: `copilotKitButton ${open ? "open" : ""}`,
527
+ "aria-label": open ? "Close Chat" : "Open Chat",
528
+ children: [
529
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "copilotKitButtonIcon copilotKitButtonIconOpen", children: icons.openIcon }),
530
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "copilotKitButtonIcon copilotKitButtonIconClose", children: icons.closeIcon })
531
+ ]
532
+ }
533
+ ) });
534
+ };
535
+
536
+ // src/components/dev-console/utils.ts
537
+ var import_react_core2 = require("@copilotkit/react-core");
538
+ var import_react_core3 = require("@copilotkit/react-core");
539
+ function getPublishedCopilotKitVersion(current, forceCheck = false) {
540
+ return __async(this, null, function* () {
541
+ const LOCAL_STORAGE_KEY = "__copilotkit_version_check__";
542
+ const serializedVersion = localStorage.getItem(LOCAL_STORAGE_KEY);
543
+ if (serializedVersion && !forceCheck) {
544
+ try {
545
+ const parsedVersion = JSON.parse(serializedVersion);
546
+ const oneHour = 60 * 60 * 1e3;
547
+ const now = (/* @__PURE__ */ new Date()).getTime();
548
+ if (parsedVersion.current === current && now - new Date(parsedVersion.lastChecked).getTime() < oneHour) {
549
+ return parsedVersion;
550
+ }
551
+ } catch (error) {
552
+ console.error("Failed to parse CopilotKitVersion from localStorage", error);
553
+ }
554
+ }
555
+ try {
556
+ const response = yield fetch("https://api.cloud.copilotkit.ai/check-for-updates", {
557
+ method: "POST",
558
+ headers: {
559
+ "Content-Type": "application/json"
560
+ },
561
+ body: JSON.stringify({
562
+ packages: [
563
+ {
564
+ packageName: "@copilotkit/shared",
565
+ packageVersion: current
566
+ }
567
+ ]
568
+ })
569
+ });
570
+ const data = yield response.json();
571
+ const version = {
572
+ current,
573
+ lastChecked: (/* @__PURE__ */ new Date()).getTime(),
574
+ latest: data.packages[0].latestVersion,
575
+ severity: data.packages[0].severity,
576
+ advisory: data.packages[0].advisory || null
577
+ };
578
+ localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(version));
579
+ return version;
580
+ } catch (error) {
581
+ console.error("Failed to check for updates", error);
582
+ throw error;
583
+ }
584
+ });
585
+ }
586
+ function logReadables(context) {
587
+ console.log("%cCurrent Readables:", "font-size: 16px; font-weight: bold;");
588
+ const readables = context.getContextString([], import_react_core2.defaultCopilotContextCategories).trim();
589
+ if (readables.length === 0) {
590
+ console.log("No readables found");
591
+ return;
592
+ }
593
+ console.log(readables);
594
+ }
595
+ function logActions(context) {
596
+ console.log("%cCurrent Actions:", "font-size: 16px; font-weight: bold;");
597
+ if (Object.values(context.actions).length === 0) {
598
+ console.log("No actions found");
599
+ return;
600
+ }
601
+ for (const action of Object.values(context.actions)) {
602
+ console.group(action.name);
603
+ console.log("name", action.name);
604
+ console.log("description", action.description);
605
+ console.log("parameters", action.parameters);
606
+ console.groupEnd();
607
+ }
608
+ }
609
+ function logMessages(context) {
610
+ console.log("%cCurrent Messages:", "font-size: 16px; font-weight: bold;");
611
+ if (context.messages.length === 0) {
612
+ console.log("No messages found");
613
+ return;
614
+ }
615
+ const tableData = context.messages.map((message) => {
616
+ if (message.isTextMessage()) {
617
+ return {
618
+ id: message.id,
619
+ type: "TextMessage",
620
+ role: message.role,
621
+ name: void 0,
622
+ scope: void 0,
623
+ content: message.content
624
+ };
625
+ } else if (message.isActionExecutionMessage()) {
626
+ return {
627
+ id: message.id,
628
+ type: "ActionExecutionMessage",
629
+ role: void 0,
630
+ name: message.name,
631
+ scope: message.parentMessageId,
632
+ content: message.arguments
633
+ };
634
+ } else if (message.isResultMessage()) {
635
+ return {
636
+ id: message.id,
637
+ type: "ResultMessage",
638
+ role: void 0,
639
+ name: message.actionName,
640
+ scope: message.actionExecutionId,
641
+ content: message.result
642
+ };
643
+ } else if (message.isAgentStateMessage()) {
644
+ return {
645
+ id: message.id,
646
+ type: `AgentStateMessage (running: ${message.running})`,
647
+ role: message.role,
648
+ name: void 0,
649
+ scope: message.threadId,
650
+ content: message.state
651
+ };
652
+ }
653
+ });
654
+ console.table(tableData);
655
+ }
656
+
657
+ // src/components/dev-console/console.tsx
658
+ var import_react_core4 = require("@copilotkit/react-core");
659
+ var import_react4 = require("react");
660
+
661
+ // src/components/dev-console/icons.tsx
662
+ var import_jsx_runtime5 = require("react/jsx-runtime");
663
+ var ExclamationMarkTriangleIcon = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
664
+ "svg",
665
+ {
666
+ width: "13.3967723px",
667
+ height: "12px",
668
+ viewBox: "0 0 13.3967723 12",
669
+ version: "1.1",
670
+ xmlns: "http://www.w3.org/2000/svg",
671
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("g", { id: "Page-1", stroke: "none", strokeWidth: "1", fill: "none", fillRule: "evenodd", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("g", { id: "exclamation-triangle", fill: "#CD2121", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
672
+ "path",
673
+ {
674
+ d: "M5.39935802,0.75 C5.97670802,-0.25 7.42007802,-0.25 7.99742802,0.75 L13.193588,9.75 C13.770888,10.75 13.049288,12 11.894588,12 L1.50223802,12 C0.34753802,12 -0.37414898,10.75 0.20319802,9.75 L5.39935802,0.75 Z M6.69838802,2.5 C7.11260802,2.5 7.44838802,2.83579 7.44838802,3.25 L7.44838802,6.25 C7.44838802,6.66421 7.11260802,7 6.69838802,7 C6.28417802,7 5.94838802,6.66421 5.94838802,6.25 L5.94838802,3.25 C5.94838802,2.83579 6.28417802,2.5 6.69838802,2.5 Z M6.69838802,10.5 C7.25067802,10.5 7.69838802,10.0523 7.69838802,9.5 C7.69838802,8.9477 7.25067802,8.5 6.69838802,8.5 C6.14610802,8.5 5.69838802,8.9477 5.69838802,9.5 C5.69838802,10.0523 6.14610802,10.5 6.69838802,10.5 Z",
675
+ id: "Shape"
676
+ }
677
+ ) }) })
678
+ }
679
+ );
680
+ var ExclamationMarkIcon = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
681
+ "svg",
682
+ {
683
+ width: "14px",
684
+ height: "14px",
685
+ viewBox: "0 0 14 14",
686
+ version: "1.1",
687
+ xmlns: "http://www.w3.org/2000/svg",
688
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("g", { id: "Page-1", stroke: "none", strokeWidth: "1", fill: "none", fillRule: "evenodd", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("g", { id: "exclamation-circle", fill: "#EC662C", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
689
+ "path",
690
+ {
691
+ d: "M7,14 C10.866,14 14,10.866 14,7 C14,3.13401 10.866,0 7,0 C3.13401,0 0,3.13401 0,7 C0,10.866 3.13401,14 7,14 Z M7,3 C7.41421,3 7.75,3.33579 7.75,3.75 L7.75,6.75 C7.75,7.16421 7.41421,7.5 7,7.5 C6.58579,7.5 6.25,7.16421 6.25,6.75 L6.25,3.75 C6.25,3.33579 6.58579,3 7,3 Z M7,11 C7.55228,11 8,10.5523 8,10 C8,9.4477 7.55228,9 7,9 C6.44772,9 6,9.4477 6,10 C6,10.5523 6.44772,11 7,11 Z",
692
+ id: "Shape"
693
+ }
694
+ ) }) })
695
+ }
696
+ );
697
+ var ChevronDownIcon = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
698
+ "svg",
699
+ {
700
+ width: "7px",
701
+ height: "4px",
702
+ viewBox: "0 0 7 4",
703
+ version: "1.1",
704
+ xmlns: "http://www.w3.org/2000/svg",
705
+ fill: "currentColor",
706
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("g", { id: "Page-1", stroke: "none", strokeWidth: "1", fill: "none", fillRule: "evenodd", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("g", { id: "Group", fill: "currentColor", fillRule: "nonzero", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
707
+ "path",
708
+ {
709
+ d: "M3.71690723,3.90271086 C3.59268176,4.03242971 3.39143629,4.03242971 3.26721082,3.90271086 L0.0853966595,0.57605615 C-0.0314221035,0.444981627 -0.0279751448,0.240725043 0.0931934622,0.114040675 C0.214362069,-0.0126436935 0.409725445,-0.0162475626 0.535093061,0.105888951 L3.49205902,3.19746006 L6.44902499,0.105888951 C6.52834574,0.0168884389 6.64780588,-0.0197473458 6.7605411,0.0103538404 C6.87327633,0.0404550266 6.96130636,0.132492308 6.99009696,0.250359396 C7.01888756,0.368226483 6.98384687,0.493124608 6.89872139,0.57605615 L3.71690723,3.90271086 Z",
710
+ id: "Path"
711
+ }
712
+ ) }) })
713
+ }
714
+ );
715
+ var CheckIcon2 = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
716
+ "svg",
717
+ {
718
+ width: "14px",
719
+ height: "14px",
720
+ viewBox: "0 0 14 14",
721
+ version: "1.1",
722
+ xmlns: "http://www.w3.org/2000/svg",
723
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("g", { id: "Page-1", stroke: "none", strokeWidth: "1", fill: "none", fillRule: "evenodd", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("g", { id: "Group-2", transform: "translate(-118, 0)", fill: "#1BC030", fillRule: "nonzero", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("g", { id: "Group", transform: "translate(118, 0)", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
724
+ "path",
725
+ {
726
+ d: "M0,7 C0,3.13384615 3.13384615,0 7,0 C10.8661538,0 14,3.13384615 14,7 C14,10.8661538 10.8661538,14 7,14 C3.13384615,14 0,10.8661538 0,7 Z M9.59179487,5.69764103 C9.70905818,5.54139023 9.73249341,5.33388318 9.65303227,5.15541491 C9.57357113,4.97694665 9.40367989,4.85551619 9.20909814,4.83811118 C9.01451638,4.82070616 8.82577109,4.91005717 8.71589744,5.07158974 L6.39261538,8.32389744 L5.22666667,7.15794872 C5.01450582,6.96025518 4.68389046,6.9660885 4.47883563,7.17114332 C4.27378081,7.37619815 4.26794748,7.70681351 4.46564103,7.91897436 L6.08102564,9.53435897 C6.19289944,9.64614839 6.3482622,9.70310251 6.50588106,9.69010587 C6.66349993,9.67710922 6.80743532,9.59547613 6.89948718,9.46687179 L9.59179487,5.69764103 L9.59179487,5.69764103 Z",
727
+ id: "Shape"
728
+ }
729
+ ) }) }) })
730
+ }
731
+ );
732
+
733
+ // src/components/dev-console/console.tsx
734
+ var import_react5 = require("@headlessui/react");
735
+ var import_shared2 = require("@copilotkit/shared");
736
+
737
+ // src/components/help-modal/modal.tsx
738
+ var import_react3 = require("react");
739
+
740
+ // src/components/help-modal/icons.tsx
741
+ var import_jsx_runtime6 = require("react/jsx-runtime");
742
+ var CloseIcon2 = () => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
743
+ "svg",
744
+ {
745
+ xmlns: "http://www.w3.org/2000/svg",
746
+ fill: "none",
747
+ viewBox: "0 0 24 24",
748
+ strokeWidth: "1.5",
749
+ stroke: "currentColor",
750
+ width: "20",
751
+ height: "20",
752
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
753
+ }
754
+ );
755
+
756
+ // src/components/help-modal/modal.tsx
757
+ var import_jsx_runtime7 = require("react/jsx-runtime");
758
+ function CopilotKitHelpModal() {
759
+ const [showHelpModal, setShowHelpModal] = (0, import_react3.useState)(false);
760
+ const buttonRef = (0, import_react3.useRef)(null);
761
+ const popoverRef = (0, import_react3.useRef)(null);
762
+ (0, import_react3.useEffect)(() => {
763
+ const handleClickOutside = (event) => {
764
+ if (popoverRef.current && !popoverRef.current.contains(event.target) && buttonRef.current && !buttonRef.current.contains(event.target)) {
765
+ setShowHelpModal(false);
766
+ }
767
+ };
768
+ if (showHelpModal) {
769
+ document.addEventListener("mousedown", handleClickOutside);
770
+ }
771
+ return () => {
772
+ document.removeEventListener("mousedown", handleClickOutside);
773
+ };
774
+ }, [showHelpModal]);
775
+ const HelpButton = () => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
776
+ "button",
777
+ {
778
+ ref: buttonRef,
779
+ onClick: () => setShowHelpModal(!showHelpModal),
780
+ className: "copilotKitDebugMenuTriggerButton relative",
781
+ "aria-label": "Open Help",
782
+ children: "Help"
783
+ }
784
+ );
785
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "relative", children: [
786
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HelpButton, {}),
787
+ showHelpModal && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
788
+ "div",
789
+ {
790
+ ref: popoverRef,
791
+ className: "absolute mt-2 z-50",
792
+ style: {
793
+ top: "100%",
794
+ right: "-120px",
795
+ width: "380px"
796
+ },
797
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "copilotKitHelpModal rounded-lg shadow-xl w-full p-4 flex-col relative", children: [
798
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
799
+ "button",
800
+ {
801
+ className: "copilotKitHelpModalCloseButton absolute text-gray-400 hover:text-gray-600 focus:outline-none",
802
+ style: { top: "10px", right: "10px" },
803
+ onClick: () => setShowHelpModal(false),
804
+ "aria-label": "Close",
805
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CloseIcon2, {})
806
+ }
807
+ ),
808
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "w-full flex mb-6 justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h2", { className: "text-2xl font-bold", children: "Help Options" }) }),
809
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "space-y-4 mb-4", children: [
810
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "copilotKitHelpItemButton", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
811
+ "a",
812
+ {
813
+ href: "https://docs.copilotkit.ai/coagents/troubleshooting/common-issues",
814
+ target: "_blank",
815
+ rel: "noopener noreferrer",
816
+ children: "Visit the Troubleshooting and FAQ section in the docs"
817
+ }
818
+ ) }),
819
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "copilotKitHelpItemButton", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
820
+ "a",
821
+ {
822
+ href: "https://go.copilotkit.ai/dev-console-support-discord",
823
+ target: "_blank",
824
+ rel: "noopener noreferrer",
825
+ children: "Go to Discord Support Channel (Community Support)"
826
+ }
827
+ ) }),
828
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "copilotKitHelpItemButton", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
829
+ "a",
830
+ {
831
+ href: "https://go.copilotkit.ai/dev-console-support-slack",
832
+ target: "_blank",
833
+ rel: "noopener noreferrer",
834
+ children: "Apply for Priority Direct Slack Support"
835
+ }
836
+ ) })
837
+ ] })
838
+ ] })
839
+ }
840
+ )
841
+ ] });
842
+ }
843
+
844
+ // src/components/dev-console/console.tsx
845
+ var import_jsx_runtime8 = require("react/jsx-runtime");
846
+ function CopilotDevConsole() {
847
+ const currentVersion = import_shared2.COPILOTKIT_VERSION;
848
+ const context = (0, import_react_core4.useCopilotContext)();
849
+ const [showDevConsole, setShowDevConsole] = (0, import_react4.useState)(false);
850
+ (0, import_react4.useEffect)(() => {
851
+ setShowDevConsole((0, import_react_core3.shouldShowDevConsole)(context.showDevConsole));
852
+ }, [context.showDevConsole]);
853
+ const dontRunTwiceInDevMode = (0, import_react4.useRef)(false);
854
+ const [versionStatus, setVersionStatus] = (0, import_react4.useState)("unknown");
855
+ const [latestVersion, setLatestVersion] = (0, import_react4.useState)("");
856
+ const consoleRef = (0, import_react4.useRef)(null);
857
+ const [debugButtonMode, setDebugButtonMode] = (0, import_react4.useState)("full");
858
+ const checkForUpdates = (force = false) => {
859
+ setVersionStatus("checking");
860
+ getPublishedCopilotKitVersion(currentVersion, force).then((v) => {
861
+ setLatestVersion(v.latest);
862
+ let versionOk = false;
863
+ if (v.current === v.latest) {
864
+ versionOk = true;
865
+ } else if (/[a-zA-Z]/.test(v.current)) {
866
+ versionOk = true;
867
+ }
868
+ if (versionOk) {
869
+ setVersionStatus("latest");
870
+ } else if (v.severity !== "low") {
871
+ setVersionStatus("outdated");
872
+ } else {
873
+ setVersionStatus("update-available");
874
+ }
875
+ }).catch((e) => {
876
+ console.error(e);
877
+ setVersionStatus("unknown");
878
+ });
879
+ };
880
+ (0, import_react4.useEffect)(() => {
881
+ if (dontRunTwiceInDevMode.current === true) {
882
+ return;
883
+ }
884
+ dontRunTwiceInDevMode.current = true;
885
+ checkForUpdates();
886
+ }, []);
887
+ if (!showDevConsole) {
888
+ return null;
889
+ }
890
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
891
+ "div",
892
+ {
893
+ ref: consoleRef,
894
+ className: "copilotKitDevConsole " + (versionStatus === "update-available" ? "copilotKitDevConsoleUpgrade" : "") + (versionStatus === "outdated" ? "copilotKitDevConsoleWarnOutdated" : ""),
895
+ children: [
896
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
897
+ VersionInfo,
898
+ {
899
+ showDevConsole: context.showDevConsole,
900
+ versionStatus,
901
+ currentVersion,
902
+ latestVersion
903
+ }
904
+ ),
905
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CopilotKitHelpModal, {}),
906
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
907
+ DebugMenuButton,
908
+ {
909
+ setShowDevConsole,
910
+ checkForUpdates,
911
+ mode: debugButtonMode
912
+ }
913
+ )
914
+ ]
915
+ }
916
+ );
917
+ }
918
+ function VersionInfo({
919
+ showDevConsole,
920
+ versionStatus,
921
+ currentVersion,
922
+ latestVersion
923
+ }) {
924
+ const [copyStatus, setCopyStatus] = (0, import_react4.useState)("");
925
+ let versionLabel = "";
926
+ let versionIcon = "";
927
+ let currentVersionLabel = currentVersion;
928
+ if (versionStatus === "latest") {
929
+ versionLabel = "latest";
930
+ versionIcon = CheckIcon2;
931
+ } else if (versionStatus === "checking") {
932
+ versionLabel = "checking";
933
+ versionIcon = SmallSpinnerIcon;
934
+ } else if (versionStatus === "update-available") {
935
+ versionLabel = "update available";
936
+ versionIcon = ExclamationMarkIcon;
937
+ currentVersionLabel = `${currentVersion} \u2192 ${latestVersion}`;
938
+ } else if (versionStatus === "outdated") {
939
+ versionLabel = "outdated";
940
+ versionIcon = ExclamationMarkTriangleIcon;
941
+ currentVersionLabel = `${currentVersion} \u2192 ${latestVersion}`;
942
+ }
943
+ let asideLabel = "";
944
+ if (showDevConsole === true) {
945
+ asideLabel = "(enabled)";
946
+ }
947
+ const installCommand = [
948
+ `npm install`,
949
+ `@copilotkit/react-core@${latestVersion}`,
950
+ `@copilotkit/react-ui@${latestVersion}`,
951
+ `@copilotkit/react-textarea@${latestVersion}`,
952
+ `&& npm install @copilotkit/runtime@${latestVersion}`
953
+ ].join(" ");
954
+ const handleCopyClick = () => {
955
+ navigator.clipboard.writeText(installCommand.trim()).then(() => {
956
+ setCopyStatus("Command copied to clipboard!");
957
+ setTimeout(() => setCopyStatus(""), 1e3);
958
+ });
959
+ };
960
+ if (versionStatus === "update-available" || versionStatus === "outdated") {
961
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "copilotKitVersionInfo", children: [
962
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("p", { children: [
963
+ currentVersionLabel,
964
+ " ",
965
+ versionIcon
966
+ ] }),
967
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { onClick: handleCopyClick, children: copyStatus || installCommand })
968
+ ] });
969
+ }
970
+ return null;
971
+ }
972
+ function DebugMenuButton({
973
+ setShowDevConsole,
974
+ checkForUpdates,
975
+ mode
976
+ }) {
977
+ const context = (0, import_react_core4.useCopilotContext)();
978
+ const messagesContext = (0, import_react_core4.useCopilotMessagesContext)();
979
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx_runtime8.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react5.Menu, { children: [
980
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
981
+ import_react5.MenuButton,
982
+ {
983
+ className: `copilotKitDebugMenuTriggerButton ${mode === "compact" ? "compact" : ""}`,
984
+ children: mode == "compact" ? "Debug" : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
985
+ "Debug ",
986
+ ChevronDownIcon
987
+ ] })
988
+ }
989
+ ),
990
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
991
+ import_react5.MenuItems,
992
+ {
993
+ transition: true,
994
+ anchor: "bottom end",
995
+ className: "copilotKitDebugMenu",
996
+ style: { zIndex: 40 },
997
+ children: [
998
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react5.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => logReadables(context), children: "Log Readables" }) }),
999
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react5.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => logActions(context), children: "Log Actions" }) }),
1000
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react5.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1001
+ "button",
1002
+ {
1003
+ className: "copilotKitDebugMenuItem",
1004
+ onClick: () => logMessages(messagesContext),
1005
+ children: "Log Messages"
1006
+ }
1007
+ ) }),
1008
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react5.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => checkForUpdates(true), children: "Check for Updates" }) }),
1009
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("hr", {}),
1010
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react5.MenuItem, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { className: "copilotKitDebugMenuItem", onClick: () => setShowDevConsole(false), children: "Hide Dev Console" }) })
1011
+ ]
1012
+ }
1013
+ )
1014
+ ] }) });
1015
+ }
1016
+
1017
+ // src/components/chat/Header.tsx
1018
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1019
+ var Header = ({}) => {
1020
+ const { setOpen, icons, labels } = useChatContext();
1021
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "copilotKitHeader", children: [
1022
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { children: labels.title }),
1023
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "copilotKitHeaderControls", children: [
1024
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CopilotDevConsole, {}),
1025
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1026
+ "button",
1027
+ {
1028
+ onClick: () => setOpen(false),
1029
+ "aria-label": "Close",
1030
+ className: "copilotKitHeaderCloseButton",
1031
+ children: icons.headerCloseIcon
1032
+ }
1033
+ )
1034
+ ] })
1035
+ ] });
1036
+ };
1037
+
1038
+ // src/components/chat/Messages.tsx
1039
+ var import_react10 = require("react");
1040
+ var import_react_core5 = require("@copilotkit/react-core");
1041
+
1042
+ // src/components/chat/messages/UserMessage.tsx
1043
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1044
+ var getTextContent = (content) => {
1045
+ if (typeof content === "undefined") {
1046
+ return void 0;
1047
+ }
1048
+ if (typeof content === "string") {
1049
+ return content;
1050
+ }
1051
+ return content.map((part) => {
1052
+ if (part.type === "text") {
1053
+ return part.text;
1054
+ }
1055
+ return void 0;
1056
+ }).filter((value) => typeof value === "string" && value.length > 0).join(" ").trim() || void 0;
1057
+ };
1058
+ var UserMessage = (props) => {
1059
+ const { message, ImageRenderer: ImageRenderer2 } = props;
1060
+ const isImageMessage = message && "image" in message && Boolean(message.image);
1061
+ if (isImageMessage) {
1062
+ const imageMessage = message;
1063
+ const content2 = getTextContent(imageMessage == null ? void 0 : imageMessage.content);
1064
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "copilotKitMessage copilotKitUserMessage", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ImageRenderer2, { image: imageMessage.image, content: content2 }) });
1065
+ }
1066
+ const content = getTextContent(message == null ? void 0 : message.content);
1067
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "copilotKitMessage copilotKitUserMessage", children: content });
1068
+ };
1069
+
1070
+ // src/components/chat/Markdown.tsx
1071
+ var import_react7 = require("react");
1072
+ var import_react_markdown = __toESM(require("react-markdown"));
1073
+
1074
+ // src/components/chat/CodeBlock.tsx
1075
+ var import_react6 = require("react");
1076
+ var import_react_syntax_highlighter = require("react-syntax-highlighter");
1077
+
1078
+ // src/hooks/use-copy-to-clipboard.tsx
1079
+ var React5 = __toESM(require("react"));
1080
+ function useCopyToClipboard({ timeout = 2e3 }) {
1081
+ const [isCopied, setIsCopied] = React5.useState(false);
1082
+ const copyToClipboard = (value) => {
1083
+ var _a;
1084
+ if (typeof window === "undefined" || !((_a = navigator.clipboard) == null ? void 0 : _a.writeText)) {
1085
+ return;
1086
+ }
1087
+ if (!value) {
1088
+ return;
1089
+ }
1090
+ navigator.clipboard.writeText(value).then(() => {
1091
+ setIsCopied(true);
1092
+ setTimeout(() => {
1093
+ setIsCopied(false);
1094
+ }, timeout);
1095
+ });
1096
+ };
1097
+ return { isCopied, copyToClipboard };
1098
+ }
1099
+
1100
+ // src/components/chat/CodeBlock.tsx
1101
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1102
+ var programmingLanguages = {
1103
+ javascript: ".js",
1104
+ python: ".py",
1105
+ java: ".java",
1106
+ c: ".c",
1107
+ cpp: ".cpp",
1108
+ "c++": ".cpp",
1109
+ "c#": ".cs",
1110
+ ruby: ".rb",
1111
+ php: ".php",
1112
+ swift: ".swift",
1113
+ "objective-c": ".m",
1114
+ kotlin: ".kt",
1115
+ typescript: ".ts",
1116
+ go: ".go",
1117
+ perl: ".pl",
1118
+ rust: ".rs",
1119
+ scala: ".scala",
1120
+ haskell: ".hs",
1121
+ lua: ".lua",
1122
+ shell: ".sh",
1123
+ sql: ".sql",
1124
+ html: ".html",
1125
+ css: ".css"
1126
+ // add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component
1127
+ };
1128
+ var generateRandomString = (length, lowercase = false) => {
1129
+ const chars = "ABCDEFGHJKLMNPQRSTUVWXY3456789";
1130
+ let result = "";
1131
+ for (let i = 0; i < length; i++) {
1132
+ result += chars.charAt(Math.floor(Math.random() * chars.length));
1133
+ }
1134
+ return lowercase ? result.toLowerCase() : result;
1135
+ };
1136
+ var CodeBlock = (0, import_react6.memo)(({ language, value }) => {
1137
+ const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2e3 });
1138
+ const [SyntaxHighlighter, setSyntaxHighlighter] = (0, import_react6.useState)(
1139
+ () => import_react_syntax_highlighter.Light
1140
+ );
1141
+ (0, import_react6.useEffect)(() => {
1142
+ try {
1143
+ new RegExp("(?<=#)\\w+");
1144
+ setSyntaxHighlighter(() => import_react_syntax_highlighter.Prism);
1145
+ } catch (e) {
1146
+ setSyntaxHighlighter(() => import_react_syntax_highlighter.Light);
1147
+ }
1148
+ }, []);
1149
+ const downloadAsFile = () => {
1150
+ if (typeof window === "undefined") {
1151
+ return;
1152
+ }
1153
+ const fileExtension = programmingLanguages[language] || ".file";
1154
+ const suggestedFileName = `file-${generateRandomString(3, true)}${fileExtension}`;
1155
+ const fileName = window.prompt("Enter file name", suggestedFileName);
1156
+ if (!fileName) {
1157
+ return;
1158
+ }
1159
+ const blob = new Blob([value], { type: "text/plain" });
1160
+ const url = URL.createObjectURL(blob);
1161
+ const link = document.createElement("a");
1162
+ link.download = fileName;
1163
+ link.href = url;
1164
+ link.style.display = "none";
1165
+ document.body.appendChild(link);
1166
+ link.click();
1167
+ document.body.removeChild(link);
1168
+ URL.revokeObjectURL(url);
1169
+ };
1170
+ const onCopy = () => {
1171
+ if (isCopied)
1172
+ return;
1173
+ copyToClipboard(value);
1174
+ };
1175
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "copilotKitCodeBlock", children: [
1176
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "copilotKitCodeBlockToolbar", children: [
1177
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "copilotKitCodeBlockToolbarLanguage", children: language }),
1178
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "copilotKitCodeBlockToolbarButtons", children: [
1179
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "copilotKitCodeBlockToolbarButton", onClick: downloadAsFile, children: DownloadIcon }),
1180
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", { className: "copilotKitCodeBlockToolbarButton", onClick: onCopy, children: isCopied ? CheckIcon : CopyIcon })
1181
+ ] })
1182
+ ] }),
1183
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1184
+ SyntaxHighlighter,
1185
+ {
1186
+ language,
1187
+ style: highlightStyle,
1188
+ PreTag: "div",
1189
+ customStyle: {
1190
+ margin: 0,
1191
+ borderBottomLeftRadius: "0.375rem",
1192
+ borderBottomRightRadius: "0.375rem"
1193
+ },
1194
+ children: value
1195
+ }
1196
+ )
1197
+ ] });
1198
+ });
1199
+ CodeBlock.displayName = "CodeBlock";
1200
+ var highlightStyle = {
1201
+ 'pre[class*="language-"]': {
1202
+ color: "#d4d4d4",
1203
+ fontSize: "13px",
1204
+ textShadow: "none",
1205
+ fontFamily: 'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',
1206
+ direction: "ltr",
1207
+ textAlign: "left",
1208
+ whiteSpace: "pre",
1209
+ wordSpacing: "normal",
1210
+ wordBreak: "normal",
1211
+ lineHeight: "1.5",
1212
+ MozTabSize: "4",
1213
+ OTabSize: "4",
1214
+ tabSize: "4",
1215
+ WebkitHyphens: "none",
1216
+ MozHyphens: "none",
1217
+ msHyphens: "none",
1218
+ hyphens: "none",
1219
+ padding: "1em",
1220
+ margin: ".5em 0",
1221
+ overflow: "auto",
1222
+ background: "#1e1e1e"
1223
+ },
1224
+ 'code[class*="language-"]': {
1225
+ color: "#d4d4d4",
1226
+ fontSize: "13px",
1227
+ textShadow: "none",
1228
+ fontFamily: 'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',
1229
+ direction: "ltr",
1230
+ textAlign: "left",
1231
+ whiteSpace: "pre",
1232
+ wordSpacing: "normal",
1233
+ wordBreak: "normal",
1234
+ lineHeight: "1.5",
1235
+ MozTabSize: "4",
1236
+ OTabSize: "4",
1237
+ tabSize: "4",
1238
+ WebkitHyphens: "none",
1239
+ MozHyphens: "none",
1240
+ msHyphens: "none",
1241
+ hyphens: "none"
1242
+ },
1243
+ 'pre[class*="language-"]::selection': {
1244
+ textShadow: "none",
1245
+ background: "#264F78"
1246
+ },
1247
+ 'code[class*="language-"]::selection': {
1248
+ textShadow: "none",
1249
+ background: "#264F78"
1250
+ },
1251
+ 'pre[class*="language-"] *::selection': {
1252
+ textShadow: "none",
1253
+ background: "#264F78"
1254
+ },
1255
+ 'code[class*="language-"] *::selection': {
1256
+ textShadow: "none",
1257
+ background: "#264F78"
1258
+ },
1259
+ ':not(pre) > code[class*="language-"]': {
1260
+ padding: ".1em .3em",
1261
+ borderRadius: ".3em",
1262
+ color: "#db4c69",
1263
+ background: "#1e1e1e"
1264
+ },
1265
+ ".namespace": {
1266
+ Opacity: ".7"
1267
+ },
1268
+ "doctype.doctype-tag": {
1269
+ color: "#569CD6"
1270
+ },
1271
+ "doctype.name": {
1272
+ color: "#9cdcfe"
1273
+ },
1274
+ comment: {
1275
+ color: "#6a9955"
1276
+ },
1277
+ prolog: {
1278
+ color: "#6a9955"
1279
+ },
1280
+ punctuation: {
1281
+ color: "#d4d4d4"
1282
+ },
1283
+ ".language-html .language-css .token.punctuation": {
1284
+ color: "#d4d4d4"
1285
+ },
1286
+ ".language-html .language-javascript .token.punctuation": {
1287
+ color: "#d4d4d4"
1288
+ },
1289
+ property: {
1290
+ color: "#9cdcfe"
1291
+ },
1292
+ tag: {
1293
+ color: "#569cd6"
1294
+ },
1295
+ boolean: {
1296
+ color: "#569cd6"
1297
+ },
1298
+ number: {
1299
+ color: "#b5cea8"
1300
+ },
1301
+ constant: {
1302
+ color: "#9cdcfe"
1303
+ },
1304
+ symbol: {
1305
+ color: "#b5cea8"
1306
+ },
1307
+ inserted: {
1308
+ color: "#b5cea8"
1309
+ },
1310
+ unit: {
1311
+ color: "#b5cea8"
1312
+ },
1313
+ selector: {
1314
+ color: "#d7ba7d"
1315
+ },
1316
+ "attr-name": {
1317
+ color: "#9cdcfe"
1318
+ },
1319
+ string: {
1320
+ color: "#ce9178"
1321
+ },
1322
+ char: {
1323
+ color: "#ce9178"
1324
+ },
1325
+ builtin: {
1326
+ color: "#ce9178"
1327
+ },
1328
+ deleted: {
1329
+ color: "#ce9178"
1330
+ },
1331
+ ".language-css .token.string.url": {
1332
+ textDecoration: "underline"
1333
+ },
1334
+ operator: {
1335
+ color: "#d4d4d4"
1336
+ },
1337
+ entity: {
1338
+ color: "#569cd6"
1339
+ },
1340
+ "operator.arrow": {
1341
+ color: "#569CD6"
1342
+ },
1343
+ atrule: {
1344
+ color: "#ce9178"
1345
+ },
1346
+ "atrule.rule": {
1347
+ color: "#c586c0"
1348
+ },
1349
+ "atrule.url": {
1350
+ color: "#9cdcfe"
1351
+ },
1352
+ "atrule.url.function": {
1353
+ color: "#dcdcaa"
1354
+ },
1355
+ "atrule.url.punctuation": {
1356
+ color: "#d4d4d4"
1357
+ },
1358
+ keyword: {
1359
+ color: "#569CD6"
1360
+ },
1361
+ "keyword.module": {
1362
+ color: "#c586c0"
1363
+ },
1364
+ "keyword.control-flow": {
1365
+ color: "#c586c0"
1366
+ },
1367
+ function: {
1368
+ color: "#dcdcaa"
1369
+ },
1370
+ "function.maybe-class-name": {
1371
+ color: "#dcdcaa"
1372
+ },
1373
+ regex: {
1374
+ color: "#d16969"
1375
+ },
1376
+ important: {
1377
+ color: "#569cd6"
1378
+ },
1379
+ italic: {
1380
+ fontStyle: "italic"
1381
+ },
1382
+ "class-name": {
1383
+ color: "#4ec9b0"
1384
+ },
1385
+ "maybe-class-name": {
1386
+ color: "#4ec9b0"
1387
+ },
1388
+ console: {
1389
+ color: "#9cdcfe"
1390
+ },
1391
+ parameter: {
1392
+ color: "#9cdcfe"
1393
+ },
1394
+ interpolation: {
1395
+ color: "#9cdcfe"
1396
+ },
1397
+ "punctuation.interpolation-punctuation": {
1398
+ color: "#569cd6"
1399
+ },
1400
+ variable: {
1401
+ color: "#9cdcfe"
1402
+ },
1403
+ "imports.maybe-class-name": {
1404
+ color: "#9cdcfe"
1405
+ },
1406
+ "exports.maybe-class-name": {
1407
+ color: "#9cdcfe"
1408
+ },
1409
+ escape: {
1410
+ color: "#d7ba7d"
1411
+ },
1412
+ "tag.punctuation": {
1413
+ color: "#808080"
1414
+ },
1415
+ cdata: {
1416
+ color: "#808080"
1417
+ },
1418
+ "attr-value": {
1419
+ color: "#ce9178"
1420
+ },
1421
+ "attr-value.punctuation": {
1422
+ color: "#ce9178"
1423
+ },
1424
+ "attr-value.punctuation.attr-equals": {
1425
+ color: "#d4d4d4"
1426
+ },
1427
+ namespace: {
1428
+ color: "#4ec9b0"
1429
+ },
1430
+ 'pre[class*="language-javascript"]': {
1431
+ color: "#9cdcfe"
1432
+ },
1433
+ 'code[class*="language-javascript"]': {
1434
+ color: "#9cdcfe"
1435
+ },
1436
+ 'pre[class*="language-jsx"]': {
1437
+ color: "#9cdcfe"
1438
+ },
1439
+ 'code[class*="language-jsx"]': {
1440
+ color: "#9cdcfe"
1441
+ },
1442
+ 'pre[class*="language-typescript"]': {
1443
+ color: "#9cdcfe"
1444
+ },
1445
+ 'code[class*="language-typescript"]': {
1446
+ color: "#9cdcfe"
1447
+ },
1448
+ 'pre[class*="language-tsx"]': {
1449
+ color: "#9cdcfe"
1450
+ },
1451
+ 'code[class*="language-tsx"]': {
1452
+ color: "#9cdcfe"
1453
+ },
1454
+ 'pre[class*="language-css"]': {
1455
+ color: "#ce9178"
1456
+ },
1457
+ 'code[class*="language-css"]': {
1458
+ color: "#ce9178"
1459
+ },
1460
+ 'pre[class*="language-html"]': {
1461
+ color: "#d4d4d4"
1462
+ },
1463
+ 'code[class*="language-html"]': {
1464
+ color: "#d4d4d4"
1465
+ },
1466
+ ".language-regex .token.anchor": {
1467
+ color: "#dcdcaa"
1468
+ },
1469
+ ".language-html .token.punctuation": {
1470
+ color: "#808080"
1471
+ },
1472
+ 'pre[class*="language-"] > code[class*="language-"]': {
1473
+ position: "relative",
1474
+ zIndex: "1"
1475
+ },
1476
+ ".line-highlight.line-highlight": {
1477
+ background: "#f7ebc6",
1478
+ boxShadow: "inset 5px 0 0 #f7d87c",
1479
+ zIndex: "0"
1480
+ }
1481
+ };
1482
+
1483
+ // src/components/chat/Markdown.tsx
1484
+ var import_remark_gfm = __toESM(require("remark-gfm"));
1485
+ var import_remark_math = __toESM(require("remark-math"));
1486
+ var import_rehype_raw = __toESM(require("rehype-raw"));
1487
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1488
+ var defaultComponents = {
1489
+ a(_a) {
1490
+ var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
1491
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("a", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { target: "_blank", rel: "noopener noreferrer", children }));
1492
+ },
1493
+ // @ts-expect-error -- inline
1494
+ code(_c) {
1495
+ var _d = _c, { children, className, inline } = _d, props = __objRest(_d, ["children", "className", "inline"]);
1496
+ if (Array.isArray(children) && children.length) {
1497
+ if (children[0] == "\u258D") {
1498
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1499
+ "span",
1500
+ {
1501
+ style: {
1502
+ animation: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",
1503
+ marginTop: "0.25rem"
1504
+ },
1505
+ children: "\u258D"
1506
+ }
1507
+ );
1508
+ }
1509
+ children[0] = (children == null ? void 0 : children[0]).replace("`\u258D`", "\u258D");
1510
+ }
1511
+ const match = /language-(\w+)/.exec(className || "");
1512
+ const hasLanguage = match && match[1];
1513
+ const content = String(children);
1514
+ const hasNewlines = content.includes("\n");
1515
+ const isInline = !hasLanguage && !hasNewlines;
1516
+ if (isInline) {
1517
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1518
+ "code",
1519
+ __spreadProps(__spreadValues({
1520
+ className: `copilotKitMarkdownElement copilotKitInlineCode ${className || ""}`
1521
+ }, props), {
1522
+ children
1523
+ })
1524
+ );
1525
+ }
1526
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1527
+ CodeBlock,
1528
+ __spreadValues({
1529
+ language: match && match[1] || "",
1530
+ value: String(children).replace(/\n$/, "")
1531
+ }, props),
1532
+ Math.random()
1533
+ );
1534
+ },
1535
+ h1: (_e) => {
1536
+ var _f = _e, { children } = _f, props = __objRest(_f, ["children"]);
1537
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h1", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1538
+ },
1539
+ h2: (_g) => {
1540
+ var _h = _g, { children } = _h, props = __objRest(_h, ["children"]);
1541
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h2", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1542
+ },
1543
+ h3: (_i) => {
1544
+ var _j = _i, { children } = _j, props = __objRest(_j, ["children"]);
1545
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h3", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1546
+ },
1547
+ h4: (_k) => {
1548
+ var _l = _k, { children } = _l, props = __objRest(_l, ["children"]);
1549
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h4", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1550
+ },
1551
+ h5: (_m) => {
1552
+ var _n = _m, { children } = _n, props = __objRest(_n, ["children"]);
1553
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h5", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1554
+ },
1555
+ h6: (_o) => {
1556
+ var _p = _o, { children } = _p, props = __objRest(_p, ["children"]);
1557
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h6", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1558
+ },
1559
+ p: (_q) => {
1560
+ var _r = _q, { children } = _r, props = __objRest(_r, ["children"]);
1561
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1562
+ },
1563
+ pre: (_s) => {
1564
+ var _t = _s, { children } = _t, props = __objRest(_t, ["children"]);
1565
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("pre", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1566
+ },
1567
+ blockquote: (_u) => {
1568
+ var _v = _u, { children } = _v, props = __objRest(_v, ["children"]);
1569
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("blockquote", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1570
+ },
1571
+ ul: (_w) => {
1572
+ var _x = _w, { children } = _x, props = __objRest(_x, ["children"]);
1573
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("ul", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1574
+ },
1575
+ li: (_y) => {
1576
+ var _z = _y, { children } = _z, props = __objRest(_z, ["children"]);
1577
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("li", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1578
+ }
1579
+ };
1580
+ var MemoizedReactMarkdown = (0, import_react7.memo)(
1581
+ import_react_markdown.default,
1582
+ (prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.components === nextProps.components
1583
+ );
1584
+ var Markdown = ({ content, components }) => {
1585
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "copilotKitMarkdown", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1586
+ MemoizedReactMarkdown,
1587
+ {
1588
+ components: __spreadValues(__spreadValues({}, defaultComponents), components),
1589
+ remarkPlugins: [import_remark_gfm.default, [import_remark_math.default, { singleDollarTextMath: false }]],
1590
+ rehypePlugins: [import_rehype_raw.default],
1591
+ children: content
1592
+ }
1593
+ ) });
1594
+ };
1595
+
1596
+ // src/components/chat/messages/AssistantMessage.tsx
1597
+ var import_react8 = require("react");
1598
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1599
+ var AssistantMessage = (props) => {
1600
+ var _a;
1601
+ const { icons, labels } = useChatContext();
1602
+ const {
1603
+ message,
1604
+ isLoading,
1605
+ onRegenerate,
1606
+ onCopy,
1607
+ onThumbsUp,
1608
+ onThumbsDown,
1609
+ isCurrentMessage,
1610
+ feedback,
1611
+ markdownTagRenderers
1612
+ } = props;
1613
+ const [copied, setCopied] = (0, import_react8.useState)(false);
1614
+ const handleCopy = () => {
1615
+ const content2 = (message == null ? void 0 : message.content) || "";
1616
+ if (content2 && onCopy) {
1617
+ navigator.clipboard.writeText(content2);
1618
+ setCopied(true);
1619
+ onCopy(content2);
1620
+ setTimeout(() => setCopied(false), 2e3);
1621
+ } else if (content2) {
1622
+ navigator.clipboard.writeText(content2);
1623
+ setCopied(true);
1624
+ setTimeout(() => setCopied(false), 2e3);
1625
+ }
1626
+ };
1627
+ const handleRegenerate = () => {
1628
+ if (onRegenerate)
1629
+ onRegenerate();
1630
+ };
1631
+ const handleThumbsUp = () => {
1632
+ if (onThumbsUp && message) {
1633
+ onThumbsUp(message);
1634
+ }
1635
+ };
1636
+ const handleThumbsDown = () => {
1637
+ if (onThumbsDown && message) {
1638
+ onThumbsDown(message);
1639
+ }
1640
+ };
1641
+ const LoadingIcon = () => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: icons.activityIcon });
1642
+ const content = (message == null ? void 0 : message.content) || "";
1643
+ const subComponent = (_a = message == null ? void 0 : message.generativeUI) == null ? void 0 : _a.call(message);
1644
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
1645
+ content && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "copilotKitMessage copilotKitAssistantMessage", children: [
1646
+ content && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Markdown, { content, components: markdownTagRenderers }),
1647
+ content && !isLoading && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1648
+ "div",
1649
+ {
1650
+ className: `copilotKitMessageControls ${isCurrentMessage ? "currentMessage" : ""}`,
1651
+ children: [
1652
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1653
+ "button",
1654
+ {
1655
+ className: "copilotKitMessageControlButton",
1656
+ onClick: handleRegenerate,
1657
+ "aria-label": labels.regenerateResponse,
1658
+ title: labels.regenerateResponse,
1659
+ children: icons.regenerateIcon
1660
+ }
1661
+ ),
1662
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1663
+ "button",
1664
+ {
1665
+ className: "copilotKitMessageControlButton",
1666
+ onClick: handleCopy,
1667
+ "aria-label": labels.copyToClipboard,
1668
+ title: labels.copyToClipboard,
1669
+ children: copied ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { style: { fontSize: "10px", fontWeight: "bold" }, children: "\u2713" }) : icons.copyIcon
1670
+ }
1671
+ ),
1672
+ onThumbsUp && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1673
+ "button",
1674
+ {
1675
+ className: `copilotKitMessageControlButton ${feedback === "thumbsUp" ? "active" : ""}`,
1676
+ onClick: handleThumbsUp,
1677
+ "aria-label": labels.thumbsUp,
1678
+ title: labels.thumbsUp,
1679
+ children: icons.thumbsUpIcon
1680
+ }
1681
+ ),
1682
+ onThumbsDown && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1683
+ "button",
1684
+ {
1685
+ className: `copilotKitMessageControlButton ${feedback === "thumbsDown" ? "active" : ""}`,
1686
+ onClick: handleThumbsDown,
1687
+ "aria-label": labels.thumbsDown,
1688
+ title: labels.thumbsDown,
1689
+ children: icons.thumbsDownIcon
1690
+ }
1691
+ )
1692
+ ]
1693
+ }
1694
+ )
1695
+ ] }),
1696
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { style: { marginBottom: "0.5rem" }, children: subComponent }),
1697
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LoadingIcon, {})
1698
+ ] });
1699
+ };
1700
+
1701
+ // src/components/chat/messages/ImageRenderer.tsx
1702
+ var import_react9 = require("react");
1703
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1704
+ var ImageRenderer = ({ image, content, className = "" }) => {
1705
+ const [imageError, setImageError] = (0, import_react9.useState)(false);
1706
+ const imageSrc = `data:image/${image.format};base64,${image.bytes}`;
1707
+ const altText = content || "User uploaded image";
1708
+ const handleImageError = () => {
1709
+ setImageError(true);
1710
+ };
1711
+ if (imageError) {
1712
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: `copilotKitImageRendering copilotKitImageRenderingError ${className}`, children: [
1713
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "copilotKitImageRenderingErrorMessage", children: "Failed to load image" }),
1714
+ content && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "copilotKitImageRenderingContent", children: content })
1715
+ ] });
1716
+ }
1717
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: `copilotKitImageRendering ${className}`, children: [
1718
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1719
+ "img",
1720
+ {
1721
+ src: imageSrc,
1722
+ alt: altText,
1723
+ className: "copilotKitImageRenderingImage",
1724
+ onError: handleImageError
1725
+ }
1726
+ ),
1727
+ content && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "copilotKitImageRenderingContent", children: content })
1728
+ ] });
1729
+ };
1730
+
1731
+ // src/components/chat/messages/RenderMessage.tsx
1732
+ var import_jsx_runtime15 = require("react/jsx-runtime");
1733
+ function RenderMessage(_a) {
1734
+ var _b = _a, {
1735
+ UserMessage: UserMessage2 = UserMessage,
1736
+ AssistantMessage: AssistantMessage2 = AssistantMessage,
1737
+ ImageRenderer: ImageRenderer2 = ImageRenderer
1738
+ } = _b, props = __objRest(_b, [
1739
+ "UserMessage",
1740
+ "AssistantMessage",
1741
+ "ImageRenderer"
1742
+ ]);
1743
+ var _a2;
1744
+ const {
1745
+ message,
1746
+ messages,
1747
+ inProgress,
1748
+ index,
1749
+ isCurrentMessage,
1750
+ onRegenerate,
1751
+ onCopy,
1752
+ onThumbsUp,
1753
+ onThumbsDown,
1754
+ messageFeedback,
1755
+ markdownTagRenderers
1756
+ } = props;
1757
+ switch (message.role) {
1758
+ case "user":
1759
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1760
+ UserMessage2,
1761
+ {
1762
+ rawData: message,
1763
+ "data-message-role": "user",
1764
+ message,
1765
+ ImageRenderer: ImageRenderer2
1766
+ },
1767
+ index
1768
+ );
1769
+ case "assistant":
1770
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1771
+ AssistantMessage2,
1772
+ {
1773
+ "data-message-role": "assistant",
1774
+ subComponent: (_a2 = message.generativeUI) == null ? void 0 : _a2.call(message),
1775
+ rawData: message,
1776
+ message,
1777
+ messages,
1778
+ isLoading: inProgress && isCurrentMessage && !message.content,
1779
+ isGenerating: inProgress && isCurrentMessage && !!message.content,
1780
+ isCurrentMessage,
1781
+ onRegenerate: () => onRegenerate == null ? void 0 : onRegenerate(message.id),
1782
+ onCopy,
1783
+ onThumbsUp,
1784
+ onThumbsDown,
1785
+ feedback: (messageFeedback == null ? void 0 : messageFeedback[message.id]) || null,
1786
+ markdownTagRenderers,
1787
+ ImageRenderer: ImageRenderer2
1788
+ },
1789
+ index
1790
+ );
1791
+ default:
1792
+ return null;
1793
+ }
1794
+ }
1795
+
1796
+ // src/components/chat/messages/LegacyRenderMessage.tsx
1797
+ var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
1798
+ var import_jsx_runtime16 = require("react/jsx-runtime");
1799
+ var LegacyRenderMessage = ({
1800
+ message,
1801
+ messages,
1802
+ inProgress,
1803
+ index,
1804
+ isCurrentMessage,
1805
+ actionResult,
1806
+ AssistantMessage: AssistantMessage2,
1807
+ UserMessage: UserMessage2,
1808
+ ImageRenderer: ImageRenderer2,
1809
+ onRegenerate,
1810
+ onCopy,
1811
+ onThumbsUp,
1812
+ onThumbsDown,
1813
+ markdownTagRenderers,
1814
+ legacyProps
1815
+ }) => {
1816
+ var _a;
1817
+ const {
1818
+ RenderTextMessage,
1819
+ RenderActionExecutionMessage,
1820
+ RenderAgentStateMessage,
1821
+ RenderResultMessage,
1822
+ RenderImageMessage
1823
+ } = legacyProps;
1824
+ const deprecatedMessage = (_a = (0, import_runtime_client_gql.aguiToGQL)(message)[0]) != null ? _a : void 0;
1825
+ if (deprecatedMessage.isTextMessage() && RenderTextMessage) {
1826
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1827
+ RenderTextMessage,
1828
+ {
1829
+ message,
1830
+ messages,
1831
+ inProgress,
1832
+ index,
1833
+ isCurrentMessage,
1834
+ AssistantMessage: AssistantMessage2,
1835
+ UserMessage: UserMessage2,
1836
+ onRegenerate,
1837
+ onCopy,
1838
+ onThumbsUp,
1839
+ onThumbsDown,
1840
+ markdownTagRenderers
1841
+ }
1842
+ );
1843
+ }
1844
+ if (deprecatedMessage.isActionExecutionMessage() && RenderActionExecutionMessage) {
1845
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1846
+ RenderActionExecutionMessage,
1847
+ {
1848
+ messages,
1849
+ message,
1850
+ inProgress,
1851
+ index,
1852
+ isCurrentMessage,
1853
+ actionResult,
1854
+ AssistantMessage: AssistantMessage2,
1855
+ UserMessage: UserMessage2
1856
+ }
1857
+ );
1858
+ }
1859
+ if (deprecatedMessage.isAgentStateMessage() && RenderAgentStateMessage) {
1860
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1861
+ RenderAgentStateMessage,
1862
+ {
1863
+ messages,
1864
+ message,
1865
+ inProgress,
1866
+ index,
1867
+ isCurrentMessage,
1868
+ AssistantMessage: AssistantMessage2,
1869
+ UserMessage: UserMessage2
1870
+ }
1871
+ );
1872
+ }
1873
+ if (deprecatedMessage.isResultMessage() && RenderResultMessage) {
1874
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1875
+ RenderResultMessage,
1876
+ {
1877
+ messages,
1878
+ message,
1879
+ inProgress,
1880
+ index,
1881
+ isCurrentMessage,
1882
+ AssistantMessage: AssistantMessage2,
1883
+ UserMessage: UserMessage2
1884
+ }
1885
+ );
1886
+ }
1887
+ if (deprecatedMessage.isImageMessage() && RenderImageMessage) {
1888
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1889
+ RenderImageMessage,
1890
+ {
1891
+ messages,
1892
+ message,
1893
+ inProgress,
1894
+ index,
1895
+ isCurrentMessage,
1896
+ AssistantMessage: AssistantMessage2,
1897
+ UserMessage: UserMessage2
1898
+ }
1899
+ );
1900
+ }
1901
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1902
+ RenderMessage,
1903
+ {
1904
+ messages,
1905
+ message,
1906
+ inProgress,
1907
+ index,
1908
+ isCurrentMessage,
1909
+ AssistantMessage: AssistantMessage2,
1910
+ UserMessage: UserMessage2,
1911
+ ImageRenderer: ImageRenderer2,
1912
+ onRegenerate,
1913
+ onCopy,
1914
+ onThumbsUp,
1915
+ onThumbsDown,
1916
+ markdownTagRenderers
1917
+ }
1918
+ );
1919
+ };
1920
+
1921
+ // src/components/chat/Messages.tsx
1922
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1923
+ var Messages = ({
1924
+ inProgress,
1925
+ children,
1926
+ RenderMessage: RenderMessage2,
1927
+ AssistantMessage: AssistantMessage2,
1928
+ UserMessage: UserMessage2,
1929
+ ErrorMessage,
1930
+ ImageRenderer: ImageRenderer2,
1931
+ onRegenerate,
1932
+ onCopy,
1933
+ onThumbsUp,
1934
+ onThumbsDown,
1935
+ messageFeedback,
1936
+ markdownTagRenderers,
1937
+ chatError,
1938
+ // Legacy props
1939
+ RenderTextMessage,
1940
+ RenderActionExecutionMessage,
1941
+ RenderAgentStateMessage,
1942
+ RenderResultMessage,
1943
+ RenderImageMessage
1944
+ }) => {
1945
+ var _a;
1946
+ const { labels, icons } = useChatContext();
1947
+ const { messages: visibleMessages, interrupt } = (0, import_react_core5.useCopilotChatInternal)();
1948
+ const initialMessages = (0, import_react10.useMemo)(() => makeInitialMessages(labels.initial), [labels.initial]);
1949
+ const messages = [...initialMessages, ...visibleMessages];
1950
+ const { messagesContainerRef, messagesEndRef } = useScrollToBottom(messages);
1951
+ const hasLegacyProps = !!(RenderTextMessage || RenderActionExecutionMessage || RenderAgentStateMessage || RenderResultMessage || RenderImageMessage);
1952
+ (0, import_react10.useEffect)(() => {
1953
+ if (hasLegacyProps) {
1954
+ console.warn(
1955
+ "[CopilotKit] Legacy message render props (RenderTextMessage, RenderActionExecutionMessage, etc.) are deprecated. Please use the unified 'RenderMessage' prop instead. See migration guide: https://docs.copilotkit.ai/migration/render-message"
1956
+ );
1957
+ }
1958
+ }, [hasLegacyProps]);
1959
+ const legacyProps = (0, import_react10.useMemo)(
1960
+ () => ({
1961
+ RenderTextMessage,
1962
+ RenderActionExecutionMessage,
1963
+ RenderAgentStateMessage,
1964
+ RenderResultMessage,
1965
+ RenderImageMessage
1966
+ }),
1967
+ [
1968
+ RenderTextMessage,
1969
+ RenderActionExecutionMessage,
1970
+ RenderAgentStateMessage,
1971
+ RenderResultMessage,
1972
+ RenderImageMessage
1973
+ ]
1974
+ );
1975
+ const MessageRenderer = hasLegacyProps ? (props) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(LegacyRenderMessage, __spreadProps(__spreadValues({}, props), { legacyProps })) : RenderMessage2;
1976
+ const LoadingIcon = () => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { children: icons.activityIcon });
1977
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "copilotKitMessages", ref: messagesContainerRef, children: [
1978
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "copilotKitMessagesContainer", children: [
1979
+ messages.map((message, index) => {
1980
+ const isCurrentMessage = index === messages.length - 1;
1981
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1982
+ MessageRenderer,
1983
+ {
1984
+ message,
1985
+ messages,
1986
+ inProgress,
1987
+ index,
1988
+ isCurrentMessage,
1989
+ AssistantMessage: AssistantMessage2,
1990
+ UserMessage: UserMessage2,
1991
+ ImageRenderer: ImageRenderer2,
1992
+ onRegenerate,
1993
+ onCopy,
1994
+ onThumbsUp,
1995
+ onThumbsDown,
1996
+ messageFeedback,
1997
+ markdownTagRenderers
1998
+ },
1999
+ index
2000
+ );
2001
+ }),
2002
+ ((_a = messages[messages.length - 1]) == null ? void 0 : _a.role) === "user" && inProgress && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(LoadingIcon, {}),
2003
+ interrupt,
2004
+ chatError && ErrorMessage && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ErrorMessage, { error: chatError, isCurrentMessage: true })
2005
+ ] }),
2006
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("footer", { className: "copilotKitMessagesFooter", ref: messagesEndRef, children })
2007
+ ] });
2008
+ };
2009
+ function makeInitialMessages(initial) {
2010
+ if (!initial)
2011
+ return [];
2012
+ if (Array.isArray(initial)) {
2013
+ return initial.map((message) => {
2014
+ return {
2015
+ id: message,
2016
+ role: "assistant",
2017
+ content: message
2018
+ };
2019
+ });
2020
+ }
2021
+ return [
2022
+ {
2023
+ id: initial,
2024
+ role: "assistant",
2025
+ content: initial
2026
+ }
2027
+ ];
2028
+ }
2029
+ function useScrollToBottom(messages) {
2030
+ const messagesEndRef = (0, import_react10.useRef)(null);
2031
+ const messagesContainerRef = (0, import_react10.useRef)(null);
2032
+ const isProgrammaticScrollRef = (0, import_react10.useRef)(false);
2033
+ const isUserScrollUpRef = (0, import_react10.useRef)(false);
2034
+ const scrollToBottom = () => {
2035
+ if (messagesContainerRef.current && messagesEndRef.current) {
2036
+ isProgrammaticScrollRef.current = true;
2037
+ messagesContainerRef.current.scrollTop = messagesContainerRef.current.scrollHeight;
2038
+ }
2039
+ };
2040
+ const handleScroll = () => {
2041
+ if (isProgrammaticScrollRef.current) {
2042
+ isProgrammaticScrollRef.current = false;
2043
+ return;
2044
+ }
2045
+ if (messagesContainerRef.current) {
2046
+ const { scrollTop, scrollHeight, clientHeight } = messagesContainerRef.current;
2047
+ isUserScrollUpRef.current = scrollTop + clientHeight < scrollHeight;
2048
+ }
2049
+ };
2050
+ (0, import_react10.useEffect)(() => {
2051
+ const container = messagesContainerRef.current;
2052
+ if (container) {
2053
+ container.addEventListener("scroll", handleScroll);
2054
+ }
2055
+ return () => {
2056
+ if (container) {
2057
+ container.removeEventListener("scroll", handleScroll);
2058
+ }
2059
+ };
2060
+ }, []);
2061
+ (0, import_react10.useEffect)(() => {
2062
+ const container = messagesContainerRef.current;
2063
+ if (!container) {
2064
+ return;
2065
+ }
2066
+ const mutationObserver = new MutationObserver(() => {
2067
+ if (!isUserScrollUpRef.current) {
2068
+ scrollToBottom();
2069
+ }
2070
+ });
2071
+ mutationObserver.observe(container, {
2072
+ childList: true,
2073
+ subtree: true,
2074
+ characterData: true
2075
+ });
2076
+ return () => {
2077
+ mutationObserver.disconnect();
2078
+ };
2079
+ }, []);
2080
+ (0, import_react10.useEffect)(() => {
2081
+ isUserScrollUpRef.current = false;
2082
+ scrollToBottom();
2083
+ }, [messages.filter((m) => m.role === "user").length]);
2084
+ return { messagesEndRef, messagesContainerRef };
2085
+ }
2086
+
2087
+ // src/components/chat/Input.tsx
2088
+ var import_react14 = require("react");
2089
+
2090
+ // src/components/chat/Textarea.tsx
2091
+ var import_react11 = require("react");
2092
+ var import_jsx_runtime18 = require("react/jsx-runtime");
2093
+ var AutoResizingTextarea = (0, import_react11.forwardRef)(
2094
+ ({
2095
+ maxRows = 1,
2096
+ placeholder,
2097
+ value,
2098
+ onChange,
2099
+ onKeyDown,
2100
+ onCompositionStart,
2101
+ onCompositionEnd,
2102
+ autoFocus
2103
+ }, ref) => {
2104
+ const internalTextareaRef = (0, import_react11.useRef)(null);
2105
+ const [maxHeight, setMaxHeight] = (0, import_react11.useState)(0);
2106
+ (0, import_react11.useImperativeHandle)(ref, () => internalTextareaRef.current);
2107
+ (0, import_react11.useEffect)(() => {
2108
+ const calculateMaxHeight = () => {
2109
+ const textarea = internalTextareaRef.current;
2110
+ if (textarea) {
2111
+ textarea.style.height = "auto";
2112
+ const singleRowHeight = textarea.scrollHeight;
2113
+ setMaxHeight(singleRowHeight * maxRows);
2114
+ if (autoFocus) {
2115
+ textarea.focus();
2116
+ }
2117
+ }
2118
+ };
2119
+ calculateMaxHeight();
2120
+ }, [maxRows]);
2121
+ (0, import_react11.useEffect)(() => {
2122
+ const textarea = internalTextareaRef.current;
2123
+ if (textarea) {
2124
+ textarea.style.height = "auto";
2125
+ textarea.style.height = `${Math.min(textarea.scrollHeight, maxHeight)}px`;
2126
+ }
2127
+ }, [value, maxHeight]);
2128
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2129
+ "textarea",
2130
+ {
2131
+ ref: internalTextareaRef,
2132
+ value,
2133
+ onChange,
2134
+ onKeyDown,
2135
+ onCompositionStart,
2136
+ onCompositionEnd,
2137
+ placeholder,
2138
+ style: {
2139
+ overflow: "auto",
2140
+ resize: "none",
2141
+ maxHeight: `${maxHeight}px`
2142
+ },
2143
+ rows: 1
2144
+ }
2145
+ );
2146
+ }
2147
+ );
2148
+ var Textarea_default = AutoResizingTextarea;
2149
+
2150
+ // src/hooks/use-push-to-talk.tsx
2151
+ var import_react_core6 = require("@copilotkit/react-core");
2152
+ var import_runtime_client_gql2 = require("@copilotkit/runtime-client-gql");
2153
+ var import_react12 = require("react");
2154
+ var startRecording = (mediaStreamRef, mediaRecorderRef, audioContextRef, recordedChunks, onStop) => __async(void 0, null, function* () {
2155
+ if (!mediaStreamRef.current || !audioContextRef.current) {
2156
+ mediaStreamRef.current = yield navigator.mediaDevices.getUserMedia({ audio: true });
2157
+ audioContextRef.current = new window.AudioContext();
2158
+ yield audioContextRef.current.resume();
2159
+ }
2160
+ mediaRecorderRef.current = new MediaRecorder(mediaStreamRef.current);
2161
+ mediaRecorderRef.current.start(1e3);
2162
+ mediaRecorderRef.current.ondataavailable = (event) => {
2163
+ recordedChunks.push(event.data);
2164
+ };
2165
+ mediaRecorderRef.current.onstop = onStop;
2166
+ });
2167
+ var stopRecording = (mediaRecorderRef) => {
2168
+ if (mediaRecorderRef.current && mediaRecorderRef.current.state !== "inactive") {
2169
+ mediaRecorderRef.current.stop();
2170
+ }
2171
+ };
2172
+ var transcribeAudio = (recordedChunks, transcribeAudioUrl) => __async(void 0, null, function* () {
2173
+ const completeBlob = new Blob(recordedChunks, { type: "audio/mp4" });
2174
+ const formData = new FormData();
2175
+ formData.append("file", completeBlob, "recording.mp4");
2176
+ const response = yield fetch(transcribeAudioUrl, {
2177
+ method: "POST",
2178
+ body: formData
2179
+ });
2180
+ if (!response.ok) {
2181
+ throw new Error(`Error: ${response.statusText}`);
2182
+ }
2183
+ const transcription = yield response.json();
2184
+ return transcription.text;
2185
+ });
2186
+ var playAudioResponse = (text, textToSpeechUrl, audioContext) => {
2187
+ const encodedText = encodeURIComponent(text);
2188
+ const url = `${textToSpeechUrl}?text=${encodedText}`;
2189
+ fetch(url).then((response) => response.arrayBuffer()).then((arrayBuffer) => audioContext.decodeAudioData(arrayBuffer)).then((audioBuffer) => {
2190
+ const source = audioContext.createBufferSource();
2191
+ source.buffer = audioBuffer;
2192
+ source.connect(audioContext.destination);
2193
+ source.start(0);
2194
+ }).catch((error) => {
2195
+ console.error("Error with decoding audio data", error);
2196
+ });
2197
+ };
2198
+ var usePushToTalk = ({
2199
+ sendFunction,
2200
+ inProgress
2201
+ }) => {
2202
+ const [pushToTalkState, setPushToTalkState] = (0, import_react12.useState)("idle");
2203
+ const mediaStreamRef = (0, import_react12.useRef)(null);
2204
+ const audioContextRef = (0, import_react12.useRef)(null);
2205
+ const mediaRecorderRef = (0, import_react12.useRef)(null);
2206
+ const recordedChunks = (0, import_react12.useRef)([]);
2207
+ const generalContext = (0, import_react_core6.useCopilotContext)();
2208
+ const messagesContext = (0, import_react_core6.useCopilotMessagesContext)();
2209
+ const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
2210
+ const [startReadingFromMessageId, setStartReadingFromMessageId] = (0, import_react12.useState)(null);
2211
+ (0, import_react12.useEffect)(() => {
2212
+ if (pushToTalkState === "recording") {
2213
+ startRecording(
2214
+ mediaStreamRef,
2215
+ mediaRecorderRef,
2216
+ audioContextRef,
2217
+ recordedChunks.current,
2218
+ () => {
2219
+ setPushToTalkState("transcribing");
2220
+ }
2221
+ );
2222
+ } else {
2223
+ stopRecording(mediaRecorderRef);
2224
+ if (pushToTalkState === "transcribing") {
2225
+ transcribeAudio(recordedChunks.current, context.copilotApiConfig.transcribeAudioUrl).then(
2226
+ (transcription) => __async(void 0, null, function* () {
2227
+ recordedChunks.current = [];
2228
+ setPushToTalkState("idle");
2229
+ const message = yield sendFunction(transcription);
2230
+ setStartReadingFromMessageId(message.id);
2231
+ })
2232
+ );
2233
+ }
2234
+ }
2235
+ return () => {
2236
+ stopRecording(mediaRecorderRef);
2237
+ };
2238
+ }, [pushToTalkState]);
2239
+ (0, import_react12.useEffect)(() => {
2240
+ if (inProgress === false && startReadingFromMessageId) {
2241
+ const lastMessageIndex = context.messages.findIndex(
2242
+ (message) => message.id === startReadingFromMessageId
2243
+ );
2244
+ const aguiMessages = (0, import_runtime_client_gql2.gqlToAGUI)(context.messages);
2245
+ const messagesAfterLast = aguiMessages.slice(lastMessageIndex + 1).filter((message) => message.role === "assistant");
2246
+ const text = messagesAfterLast.map((message) => message.content).join("\n");
2247
+ playAudioResponse(text, context.copilotApiConfig.textToSpeechUrl, audioContextRef.current);
2248
+ setStartReadingFromMessageId(null);
2249
+ }
2250
+ }, [startReadingFromMessageId, inProgress]);
2251
+ return { pushToTalkState, setPushToTalkState };
2252
+ };
2253
+
2254
+ // src/components/chat/Input.tsx
2255
+ var import_react_core7 = require("@copilotkit/react-core");
2256
+
2257
+ // src/components/chat/PoweredByTag.tsx
2258
+ var import_react13 = require("react");
2259
+
2260
+ // src/hooks/use-dark-mode.ts
2261
+ var useDarkMode = () => {
2262
+ if (typeof window === "undefined")
2263
+ return false;
2264
+ return document.documentElement.classList.contains("dark") || document.body.classList.contains("dark") || document.documentElement.getAttribute("data-theme") === "dark" || document.body.getAttribute("data-theme") === "dark" || window.matchMedia("(prefers-color-scheme: dark)").matches;
2265
+ };
2266
+
2267
+ // src/components/chat/PoweredByTag.tsx
2268
+ var import_jsx_runtime19 = require("react/jsx-runtime");
2269
+ function PoweredByTag({ showPoweredBy = true }) {
2270
+ const [mounted, setMounted] = (0, import_react13.useState)(false);
2271
+ const isDark = useDarkMode();
2272
+ (0, import_react13.useEffect)(() => {
2273
+ setMounted(true);
2274
+ }, []);
2275
+ if (!showPoweredBy) {
2276
+ return null;
2277
+ }
2278
+ const poweredByStyle = {
2279
+ visibility: "visible",
2280
+ display: "block",
2281
+ position: "static",
2282
+ textAlign: "center",
2283
+ fontSize: "12px",
2284
+ padding: "3px 0",
2285
+ color: mounted && isDark ? "rgb(69, 69, 69)" : "rgb(214, 214, 214)"
2286
+ };
2287
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "poweredBy", style: poweredByStyle, children: "Powered by CopilotKit" }) });
2288
+ }
2289
+
2290
+ // src/components/chat/Input.tsx
2291
+ var import_jsx_runtime20 = require("react/jsx-runtime");
2292
+ var MAX_NEWLINES = 6;
2293
+ var Input = ({
2294
+ inProgress,
2295
+ onSend,
2296
+ chatReady = false,
2297
+ onStop,
2298
+ onUpload,
2299
+ hideStopButton = false
2300
+ }) => {
2301
+ var _a;
2302
+ const context = useChatContext();
2303
+ const copilotContext = (0, import_react_core7.useCopilotContext)();
2304
+ const showPoweredBy = !((_a = copilotContext.copilotApiConfig) == null ? void 0 : _a.publicApiKey);
2305
+ const pushToTalkConfigured = copilotContext.copilotApiConfig.textToSpeechUrl !== void 0 && copilotContext.copilotApiConfig.transcribeAudioUrl !== void 0;
2306
+ const textareaRef = (0, import_react14.useRef)(null);
2307
+ const [isComposing, setIsComposing] = (0, import_react14.useState)(false);
2308
+ const handleDivClick = (event) => {
2309
+ var _a2;
2310
+ const target = event.target;
2311
+ if (target.closest("button"))
2312
+ return;
2313
+ if (target.tagName === "TEXTAREA")
2314
+ return;
2315
+ (_a2 = textareaRef.current) == null ? void 0 : _a2.focus();
2316
+ };
2317
+ const [text, setText] = (0, import_react14.useState)("");
2318
+ const send = () => {
2319
+ var _a2;
2320
+ if (inProgress)
2321
+ return;
2322
+ onSend(text);
2323
+ setText("");
2324
+ (_a2 = textareaRef.current) == null ? void 0 : _a2.focus();
2325
+ };
2326
+ const { pushToTalkState, setPushToTalkState } = usePushToTalk({
2327
+ sendFunction: onSend,
2328
+ inProgress
2329
+ });
2330
+ const isInProgress = inProgress || pushToTalkState === "transcribing";
2331
+ const { buttonIcon, buttonAlt } = (0, import_react14.useMemo)(() => {
2332
+ if (!chatReady)
2333
+ return { buttonIcon: context.icons.spinnerIcon, buttonAlt: "Loading" };
2334
+ return isInProgress && !hideStopButton && chatReady ? { buttonIcon: context.icons.stopIcon, buttonAlt: "Stop" } : { buttonIcon: context.icons.sendIcon, buttonAlt: "Send" };
2335
+ }, [isInProgress, chatReady, hideStopButton, context.icons.stopIcon, context.icons.sendIcon]);
2336
+ const showPushToTalk = pushToTalkConfigured && (pushToTalkState === "idle" || pushToTalkState === "recording") && !inProgress;
2337
+ const { interrupt } = (0, import_react_core7.useCopilotChatInternal)();
2338
+ const canSend = (0, import_react14.useMemo)(() => {
2339
+ return !isInProgress && text.trim().length > 0 && pushToTalkState === "idle" && !interrupt;
2340
+ }, [interrupt, isInProgress, text, pushToTalkState]);
2341
+ const canStop = (0, import_react14.useMemo)(() => {
2342
+ return isInProgress && !hideStopButton;
2343
+ }, [isInProgress, hideStopButton]);
2344
+ const sendDisabled = !canSend && !canStop;
2345
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: `copilotKitInputContainer ${showPoweredBy ? "poweredByContainer" : ""}`, children: [
2346
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "copilotKitInput", onClick: handleDivClick, children: [
2347
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2348
+ Textarea_default,
2349
+ {
2350
+ ref: textareaRef,
2351
+ placeholder: context.labels.placeholder,
2352
+ autoFocus: false,
2353
+ maxRows: MAX_NEWLINES,
2354
+ value: text,
2355
+ onChange: (event) => setText(event.target.value),
2356
+ onCompositionStart: () => setIsComposing(true),
2357
+ onCompositionEnd: () => setIsComposing(false),
2358
+ onKeyDown: (event) => {
2359
+ if (event.key === "Enter" && !event.shiftKey && !isComposing) {
2360
+ event.preventDefault();
2361
+ if (canSend) {
2362
+ send();
2363
+ }
2364
+ }
2365
+ }
2366
+ }
2367
+ ),
2368
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "copilotKitInputControls", children: [
2369
+ onUpload && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("button", { onClick: onUpload, className: "copilotKitInputControlButton", children: context.icons.uploadIcon }),
2370
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { style: { flexGrow: 1 } }),
2371
+ showPushToTalk && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2372
+ "button",
2373
+ {
2374
+ onClick: () => setPushToTalkState(pushToTalkState === "idle" ? "recording" : "transcribing"),
2375
+ className: pushToTalkState === "recording" ? "copilotKitInputControlButton copilotKitPushToTalkRecording" : "copilotKitInputControlButton",
2376
+ children: context.icons.pushToTalkIcon
2377
+ }
2378
+ ),
2379
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2380
+ "button",
2381
+ {
2382
+ disabled: sendDisabled,
2383
+ onClick: isInProgress && !hideStopButton ? onStop : send,
2384
+ "data-copilotkit-in-progress": inProgress,
2385
+ "data-test-id": inProgress ? "copilot-chat-request-in-progress" : "copilot-chat-ready",
2386
+ className: "copilotKitInputControlButton",
2387
+ "aria-label": buttonAlt,
2388
+ children: buttonIcon
2389
+ }
2390
+ )
2391
+ ] })
2392
+ ] }),
2393
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(PoweredByTag, { showPoweredBy })
2394
+ ] });
2395
+ };
2396
+
2397
+ // src/components/chat/Chat.tsx
2398
+ var import_react15 = __toESM(require("react"));
2399
+ var import_react_core9 = require("@copilotkit/react-core");
2400
+ var import_shared3 = require("@copilotkit/shared");
2401
+
2402
+ // src/components/chat/ImageUploadQueue.tsx
2403
+ var import_jsx_runtime21 = require("react/jsx-runtime");
2404
+ var ImageUploadQueue = ({
2405
+ images,
2406
+ onRemoveImage,
2407
+ className = ""
2408
+ }) => {
2409
+ if (images.length === 0)
2410
+ return null;
2411
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2412
+ "div",
2413
+ {
2414
+ className: `copilotKitImageUploadQueue ${className}`,
2415
+ style: {
2416
+ display: "flex",
2417
+ flexWrap: "wrap",
2418
+ gap: "8px",
2419
+ margin: "8px",
2420
+ padding: "8px"
2421
+ },
2422
+ children: images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
2423
+ "div",
2424
+ {
2425
+ className: "copilotKitImageUploadQueueItem",
2426
+ style: {
2427
+ position: "relative",
2428
+ display: "inline-block",
2429
+ width: "60px",
2430
+ height: "60px",
2431
+ borderRadius: "4px",
2432
+ overflow: "hidden"
2433
+ },
2434
+ children: [
2435
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2436
+ "img",
2437
+ {
2438
+ src: `data:${image.contentType};base64,${image.bytes}`,
2439
+ alt: `Selected image ${index + 1}`,
2440
+ style: {
2441
+ width: "100%",
2442
+ height: "100%",
2443
+ objectFit: "cover"
2444
+ }
2445
+ }
2446
+ ),
2447
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2448
+ "button",
2449
+ {
2450
+ onClick: () => onRemoveImage(index),
2451
+ className: "copilotKitImageUploadQueueRemoveButton",
2452
+ style: {
2453
+ position: "absolute",
2454
+ top: "2px",
2455
+ right: "2px",
2456
+ background: "rgba(0,0,0,0.6)",
2457
+ color: "white",
2458
+ border: "none",
2459
+ borderRadius: "50%",
2460
+ width: "18px",
2461
+ height: "18px",
2462
+ display: "flex",
2463
+ alignItems: "center",
2464
+ justifyContent: "center",
2465
+ cursor: "pointer",
2466
+ fontSize: "10px",
2467
+ padding: 0
2468
+ },
2469
+ children: "\u2715"
2470
+ }
2471
+ )
2472
+ ]
2473
+ },
2474
+ index
2475
+ ))
2476
+ }
2477
+ );
2478
+ };
2479
+
2480
+ // src/components/chat/Suggestion.tsx
2481
+ var import_react_core8 = require("@copilotkit/react-core");
2482
+ var import_jsx_runtime22 = require("react/jsx-runtime");
2483
+ function Suggestion({ title, onClick, partial, className }) {
2484
+ if (!title)
2485
+ return null;
2486
+ const { isLoading } = (0, import_react_core8.useCopilotChatInternal)();
2487
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2488
+ "button",
2489
+ {
2490
+ disabled: partial || isLoading,
2491
+ onClick: (e) => {
2492
+ e.preventDefault();
2493
+ onClick();
2494
+ },
2495
+ className: className || (partial ? "suggestion loading" : "suggestion"),
2496
+ "data-test-id": "suggestion",
2497
+ children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { children: title })
2498
+ }
2499
+ );
2500
+ }
2501
+
2502
+ // src/components/chat/Suggestions.tsx
2503
+ var import_jsx_runtime23 = require("react/jsx-runtime");
2504
+ function Suggestions({
2505
+ suggestions,
2506
+ onSuggestionClick,
2507
+ isLoading
2508
+ }) {
2509
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "suggestions", children: suggestions.map((suggestion, index) => {
2510
+ var _a, _b;
2511
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2512
+ Suggestion,
2513
+ {
2514
+ title: suggestion.title,
2515
+ message: suggestion.message,
2516
+ partial: (_b = (_a = suggestion.isLoading) != null ? _a : suggestion.partial) != null ? _b : isLoading,
2517
+ className: suggestion.className,
2518
+ onClick: () => onSuggestionClick(suggestion.message)
2519
+ },
2520
+ index
2521
+ );
2522
+ }) });
2523
+ }
2524
+
2525
+ // src/components/chat/Chat.tsx
2526
+ var import_jsx_runtime24 = require("react/jsx-runtime");
2527
+ function CopilotChat({
2528
+ instructions,
2529
+ suggestions = "auto",
2530
+ onSubmitMessage,
2531
+ makeSystemMessage,
2532
+ disableSystemMessage,
2533
+ onInProgress,
2534
+ onStopGeneration,
2535
+ onReloadMessages,
2536
+ onRegenerate,
2537
+ onCopy,
2538
+ onThumbsUp,
2539
+ onThumbsDown,
2540
+ markdownTagRenderers,
2541
+ Messages: Messages2 = Messages,
2542
+ RenderMessage: RenderMessage2 = RenderMessage,
2543
+ RenderSuggestionsList = Suggestions,
2544
+ Input: Input2 = Input,
2545
+ className,
2546
+ icons,
2547
+ labels,
2548
+ AssistantMessage: AssistantMessage2 = AssistantMessage,
2549
+ UserMessage: UserMessage2 = UserMessage,
2550
+ ImageRenderer: ImageRenderer2 = ImageRenderer,
2551
+ ErrorMessage,
2552
+ imageUploadsEnabled,
2553
+ inputFileAccept = "image/*",
2554
+ hideStopButton,
2555
+ observabilityHooks,
2556
+ renderError,
2557
+ onError,
2558
+ // Legacy props - deprecated
2559
+ RenderTextMessage,
2560
+ RenderActionExecutionMessage,
2561
+ RenderAgentStateMessage,
2562
+ RenderResultMessage,
2563
+ RenderImageMessage
2564
+ }) {
2565
+ const {
2566
+ additionalInstructions,
2567
+ setChatInstructions,
2568
+ copilotApiConfig,
2569
+ setBannerError,
2570
+ setInternalErrorHandler,
2571
+ removeInternalErrorHandler
2572
+ } = (0, import_react_core9.useCopilotContext)();
2573
+ const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
2574
+ const [selectedImages, setSelectedImages] = (0, import_react15.useState)([]);
2575
+ const [chatError, setChatError] = (0, import_react15.useState)(null);
2576
+ const [messageFeedback, setMessageFeedback] = (0, import_react15.useState)(
2577
+ {}
2578
+ );
2579
+ const fileInputRef = (0, import_react15.useRef)(null);
2580
+ const triggerObservabilityHook = (0, import_react15.useCallback)(
2581
+ (hookName, ...args) => {
2582
+ if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
2583
+ observabilityHooks[hookName](...args);
2584
+ }
2585
+ if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !publicApiKey) {
2586
+ setBannerError(
2587
+ new import_shared3.CopilotKitError({
2588
+ message: "observabilityHooks requires a publicApiKey to function.",
2589
+ code: import_shared3.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
2590
+ severity: import_shared3.Severity.CRITICAL,
2591
+ visibility: import_shared3.ErrorVisibility.BANNER
2592
+ })
2593
+ );
2594
+ import_shared3.styledConsole.publicApiKeyRequired("observabilityHooks");
2595
+ }
2596
+ },
2597
+ [publicApiKey, observabilityHooks, setBannerError]
2598
+ );
2599
+ const triggerChatError = (0, import_react15.useCallback)(
2600
+ (error, operation, originalError) => {
2601
+ const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
2602
+ setChatError({
2603
+ message: errorMessage,
2604
+ operation,
2605
+ timestamp: Date.now()
2606
+ });
2607
+ const errorEvent = {
2608
+ type: "error",
2609
+ timestamp: Date.now(),
2610
+ context: {
2611
+ source: "ui",
2612
+ request: {
2613
+ operation,
2614
+ url: chatApiEndpoint,
2615
+ startTime: Date.now()
2616
+ },
2617
+ technical: {
2618
+ environment: "browser",
2619
+ userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
2620
+ stackTrace: originalError instanceof Error ? originalError.stack : void 0
2621
+ }
2622
+ },
2623
+ error
2624
+ };
2625
+ if (onError) {
2626
+ onError(errorEvent);
2627
+ }
2628
+ if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks.onError)) {
2629
+ observabilityHooks.onError(errorEvent);
2630
+ }
2631
+ if ((observabilityHooks == null ? void 0 : observabilityHooks.onError) && !publicApiKey) {
2632
+ setBannerError(
2633
+ new import_shared3.CopilotKitError({
2634
+ message: "observabilityHooks.onError requires a publicApiKey to function.",
2635
+ code: import_shared3.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
2636
+ severity: import_shared3.Severity.CRITICAL,
2637
+ visibility: import_shared3.ErrorVisibility.BANNER
2638
+ })
2639
+ );
2640
+ import_shared3.styledConsole.publicApiKeyRequired("observabilityHooks.onError");
2641
+ }
2642
+ },
2643
+ [publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
2644
+ );
2645
+ (0, import_react15.useEffect)(() => {
2646
+ const id = "chat-component";
2647
+ setInternalErrorHandler({
2648
+ [id]: (error) => {
2649
+ if (!error)
2650
+ return;
2651
+ triggerChatError(error.error, "sendMessage");
2652
+ }
2653
+ });
2654
+ return () => {
2655
+ removeInternalErrorHandler == null ? void 0 : removeInternalErrorHandler(id);
2656
+ };
2657
+ }, [triggerChatError, setInternalErrorHandler, removeInternalErrorHandler]);
2658
+ (0, import_react15.useEffect)(() => {
2659
+ if (!imageUploadsEnabled)
2660
+ return;
2661
+ const handlePaste = (e) => __async(this, null, function* () {
2662
+ var _a, _b;
2663
+ const target = e.target;
2664
+ if (!((_a = target.parentElement) == null ? void 0 : _a.classList.contains("copilotKitInput")))
2665
+ return;
2666
+ const items = Array.from(((_b = e.clipboardData) == null ? void 0 : _b.items) || []);
2667
+ const imageItems = items.filter((item) => item.type.startsWith("image/"));
2668
+ if (imageItems.length === 0)
2669
+ return;
2670
+ e.preventDefault();
2671
+ const imagePromises = imageItems.map((item) => {
2672
+ const file = item.getAsFile();
2673
+ if (!file)
2674
+ return Promise.resolve(null);
2675
+ return new Promise((resolve, reject) => {
2676
+ const reader = new FileReader();
2677
+ reader.onload = (e2) => {
2678
+ var _a2, _b2;
2679
+ const base64String = (_b2 = (_a2 = e2.target) == null ? void 0 : _a2.result) == null ? void 0 : _b2.split(",")[1];
2680
+ if (base64String) {
2681
+ resolve({
2682
+ contentType: file.type,
2683
+ bytes: base64String
2684
+ });
2685
+ } else {
2686
+ resolve(null);
2687
+ }
2688
+ };
2689
+ reader.onerror = reject;
2690
+ reader.readAsDataURL(file);
2691
+ });
2692
+ });
2693
+ try {
2694
+ const loadedImages = (yield Promise.all(imagePromises)).filter((img) => img !== null);
2695
+ setSelectedImages((prev) => [...prev, ...loadedImages]);
2696
+ } catch (error) {
2697
+ triggerChatError(error, "processClipboardImages", error);
2698
+ console.error("Error processing pasted images:", error);
2699
+ }
2700
+ });
2701
+ document.addEventListener("paste", handlePaste);
2702
+ return () => document.removeEventListener("paste", handlePaste);
2703
+ }, [imageUploadsEnabled, triggerChatError]);
2704
+ (0, import_react15.useEffect)(() => {
2705
+ if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
2706
+ setChatInstructions(instructions || "");
2707
+ return;
2708
+ }
2709
+ const combinedAdditionalInstructions = [
2710
+ instructions,
2711
+ "Additionally, follow these instructions:",
2712
+ ...additionalInstructions.map((instruction) => `- ${instruction}`)
2713
+ ];
2714
+ setChatInstructions(combinedAdditionalInstructions.join("\n") || "");
2715
+ }, [instructions, additionalInstructions]);
2716
+ const {
2717
+ messages,
2718
+ isLoading,
2719
+ sendMessage,
2720
+ stopGeneration,
2721
+ reloadMessages,
2722
+ suggestions: currentSuggestions,
2723
+ isLoadingSuggestions,
2724
+ agent
2725
+ } = (0, import_react_core9.useCopilotChatInternal)({
2726
+ suggestions,
2727
+ onInProgress,
2728
+ onSubmitMessage,
2729
+ onStopGeneration,
2730
+ onReloadMessages
2731
+ });
2732
+ const prevIsLoading = (0, import_react15.useRef)(isLoading);
2733
+ (0, import_react15.useEffect)(() => {
2734
+ if (prevIsLoading.current !== isLoading) {
2735
+ if (isLoading) {
2736
+ triggerObservabilityHook("onChatStarted");
2737
+ } else {
2738
+ triggerObservabilityHook("onChatStopped");
2739
+ }
2740
+ prevIsLoading.current = isLoading;
2741
+ }
2742
+ }, [isLoading, triggerObservabilityHook]);
2743
+ const handleSendMessage = (text) => {
2744
+ const images = selectedImages;
2745
+ setSelectedImages([]);
2746
+ if (fileInputRef.current) {
2747
+ fileInputRef.current.value = "";
2748
+ }
2749
+ triggerObservabilityHook("onMessageSent", text);
2750
+ return sendMessage({
2751
+ id: (0, import_shared3.randomUUID)(),
2752
+ content: text,
2753
+ role: "user"
2754
+ });
2755
+ };
2756
+ const chatContext = import_react15.default.useContext(ChatContext);
2757
+ const isVisible = chatContext ? chatContext.open : true;
2758
+ const handleRegenerate = (messageId) => {
2759
+ if (onRegenerate) {
2760
+ onRegenerate(messageId);
2761
+ }
2762
+ triggerObservabilityHook("onMessageRegenerated", messageId);
2763
+ reloadMessages(messageId);
2764
+ };
2765
+ const handleCopy = (message) => {
2766
+ if (onCopy) {
2767
+ onCopy(message);
2768
+ }
2769
+ triggerObservabilityHook("onMessageCopied", message);
2770
+ };
2771
+ const handleImageUpload = (event) => __async(this, null, function* () {
2772
+ if (!event.target.files || event.target.files.length === 0) {
2773
+ return;
2774
+ }
2775
+ const files = Array.from(event.target.files).filter((file) => file.type.startsWith("image/"));
2776
+ if (files.length === 0)
2777
+ return;
2778
+ const fileReadPromises = files.map((file) => {
2779
+ return new Promise((resolve, reject) => {
2780
+ const reader = new FileReader();
2781
+ reader.onload = (e) => {
2782
+ var _a, _b;
2783
+ const base64String = ((_b = (_a = e.target) == null ? void 0 : _a.result) == null ? void 0 : _b.split(",")[1]) || "";
2784
+ if (base64String) {
2785
+ resolve({
2786
+ contentType: file.type,
2787
+ bytes: base64String
2788
+ });
2789
+ }
2790
+ };
2791
+ reader.onerror = reject;
2792
+ reader.readAsDataURL(file);
2793
+ });
2794
+ });
2795
+ try {
2796
+ const loadedImages = yield Promise.all(fileReadPromises);
2797
+ setSelectedImages((prev) => [...prev, ...loadedImages]);
2798
+ } catch (error) {
2799
+ triggerChatError(error, "processUploadedImages", error);
2800
+ console.error("Error reading files:", error);
2801
+ }
2802
+ });
2803
+ const removeSelectedImage = (index) => {
2804
+ setSelectedImages((prev) => prev.filter((_, i) => i !== index));
2805
+ };
2806
+ const handleThumbsUp = (message) => {
2807
+ if (onThumbsUp) {
2808
+ onThumbsUp(message);
2809
+ }
2810
+ setMessageFeedback((prev) => __spreadProps(__spreadValues({}, prev), {
2811
+ [message.id]: "thumbsUp"
2812
+ }));
2813
+ triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsUp");
2814
+ };
2815
+ const handleThumbsDown = (message) => {
2816
+ if (onThumbsDown) {
2817
+ onThumbsDown(message);
2818
+ }
2819
+ setMessageFeedback((prev) => __spreadProps(__spreadValues({}, prev), {
2820
+ [message.id]: "thumbsDown"
2821
+ }));
2822
+ triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsDown");
2823
+ };
2824
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
2825
+ chatError && renderError && renderError(__spreadProps(__spreadValues({}, chatError), {
2826
+ onDismiss: () => setChatError(null),
2827
+ onRetry: () => {
2828
+ setChatError(null);
2829
+ }
2830
+ })),
2831
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2832
+ Messages2,
2833
+ {
2834
+ AssistantMessage: AssistantMessage2,
2835
+ UserMessage: UserMessage2,
2836
+ RenderMessage: RenderMessage2,
2837
+ messages,
2838
+ inProgress: isLoading,
2839
+ onRegenerate: handleRegenerate,
2840
+ onCopy: handleCopy,
2841
+ onThumbsUp: handleThumbsUp,
2842
+ onThumbsDown: handleThumbsDown,
2843
+ messageFeedback,
2844
+ markdownTagRenderers,
2845
+ ImageRenderer: ImageRenderer2,
2846
+ ErrorMessage,
2847
+ chatError,
2848
+ RenderTextMessage,
2849
+ RenderActionExecutionMessage,
2850
+ RenderAgentStateMessage,
2851
+ RenderResultMessage,
2852
+ RenderImageMessage,
2853
+ children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2854
+ RenderSuggestionsList,
2855
+ {
2856
+ onSuggestionClick: handleSendMessage,
2857
+ suggestions: currentSuggestions,
2858
+ isLoading: isLoadingSuggestions
2859
+ }
2860
+ )
2861
+ }
2862
+ ),
2863
+ imageUploadsEnabled && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
2864
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ImageUploadQueue, { images: selectedImages, onRemoveImage: removeSelectedImage }),
2865
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2866
+ "input",
2867
+ {
2868
+ type: "file",
2869
+ multiple: true,
2870
+ ref: fileInputRef,
2871
+ onChange: handleImageUpload,
2872
+ accept: inputFileAccept,
2873
+ style: { display: "none" }
2874
+ }
2875
+ )
2876
+ ] }),
2877
+ /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2878
+ Input2,
2879
+ {
2880
+ inProgress: isLoading,
2881
+ chatReady: Boolean(agent),
2882
+ onSend: handleSendMessage,
2883
+ isVisible,
2884
+ onStop: stopGeneration,
2885
+ onUpload: imageUploadsEnabled ? () => {
2886
+ var _a;
2887
+ return (_a = fileInputRef.current) == null ? void 0 : _a.click();
2888
+ } : void 0,
2889
+ hideStopButton
2890
+ }
2891
+ )
2892
+ ] });
2893
+ }
2894
+ function WrappedCopilotChat({
2895
+ children,
2896
+ icons,
2897
+ labels,
2898
+ className
2899
+ }) {
2900
+ const chatContext = import_react15.default.useContext(ChatContext);
2901
+ if (!chatContext) {
2902
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
2903
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
2904
+ }
2905
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children });
2906
+ }
2907
+
2908
+ // src/components/chat/Modal.tsx
2909
+ var import_react_core10 = require("@copilotkit/react-core");
2910
+ var import_shared4 = require("@copilotkit/shared");
2911
+ var import_jsx_runtime25 = require("react/jsx-runtime");
2912
+ var CopilotModalInner = (_a) => {
2913
+ var _b = _a, {
2914
+ observabilityHooks,
2915
+ onSetOpen,
2916
+ clickOutsideToClose,
2917
+ hitEscapeToClose,
2918
+ shortcut,
2919
+ className,
2920
+ children,
2921
+ Window: Window2,
2922
+ Button: Button2,
2923
+ Header: Header2
2924
+ } = _b, chatProps = __objRest(_b, [
2925
+ "observabilityHooks",
2926
+ "onSetOpen",
2927
+ "clickOutsideToClose",
2928
+ "hitEscapeToClose",
2929
+ "shortcut",
2930
+ "className",
2931
+ "children",
2932
+ "Window",
2933
+ "Button",
2934
+ "Header"
2935
+ ]);
2936
+ const { copilotApiConfig, setBannerError } = (0, import_react_core10.useCopilotContext)();
2937
+ const { publicApiKey } = copilotApiConfig;
2938
+ const triggerObservabilityHook = (0, import_react16.useCallback)(
2939
+ (hookName, ...args) => {
2940
+ if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
2941
+ observabilityHooks[hookName](...args);
2942
+ }
2943
+ if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !publicApiKey) {
2944
+ setBannerError(
2945
+ new import_shared4.CopilotKitError({
2946
+ message: "observabilityHooks requires a publicApiKey to function.",
2947
+ code: import_shared4.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
2948
+ severity: import_shared4.Severity.CRITICAL,
2949
+ visibility: import_shared4.ErrorVisibility.BANNER
2950
+ })
2951
+ );
2952
+ import_shared4.styledConsole.publicApiKeyRequired("observabilityHooks");
2953
+ }
2954
+ },
2955
+ [publicApiKey, observabilityHooks, setBannerError]
2956
+ );
2957
+ const { open } = useChatContext();
2958
+ const prevOpen = (0, import_react16.useRef)(open);
2959
+ (0, import_react16.useEffect)(() => {
2960
+ if (prevOpen.current !== open) {
2961
+ onSetOpen == null ? void 0 : onSetOpen(open);
2962
+ if (open) {
2963
+ triggerObservabilityHook("onChatExpanded");
2964
+ } else {
2965
+ triggerObservabilityHook("onChatMinimized");
2966
+ }
2967
+ prevOpen.current = open;
2968
+ }
2969
+ }, [open, onSetOpen, triggerObservabilityHook]);
2970
+ const memoizedHeader = (0, import_react16.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Header2, {}), [Header2]);
2971
+ const memoizedChildren = (0, import_react16.useMemo)(() => children, [children]);
2972
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
2973
+ memoizedChildren,
2974
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className, children: [
2975
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Button2, {}),
2976
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
2977
+ Window2,
2978
+ {
2979
+ clickOutsideToClose,
2980
+ shortcut,
2981
+ hitEscapeToClose,
2982
+ children: [
2983
+ memoizedHeader,
2984
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(CopilotChat, __spreadProps(__spreadValues({}, chatProps), { observabilityHooks }))
2985
+ ]
2986
+ }
2987
+ )
2988
+ ] })
2989
+ ] });
2990
+ };
2991
+ var CopilotModal = (_a) => {
2992
+ var _b = _a, {
2993
+ instructions,
2994
+ defaultOpen = false,
2995
+ clickOutsideToClose = true,
2996
+ hitEscapeToClose = true,
2997
+ onSetOpen,
2998
+ onSubmitMessage,
2999
+ onStopGeneration,
3000
+ onReloadMessages,
3001
+ shortcut = "/",
3002
+ icons,
3003
+ labels,
3004
+ makeSystemMessage,
3005
+ onInProgress,
3006
+ Window: Window2 = Window,
3007
+ Button: Button2 = Button,
3008
+ Header: Header2 = Header,
3009
+ Messages: Messages2 = Messages,
3010
+ Input: Input2 = Input,
3011
+ AssistantMessage: AssistantMessage2 = AssistantMessage,
3012
+ UserMessage: UserMessage2 = UserMessage,
3013
+ onThumbsUp,
3014
+ onThumbsDown,
3015
+ onCopy,
3016
+ onRegenerate,
3017
+ markdownTagRenderers,
3018
+ className,
3019
+ children,
3020
+ observabilityHooks
3021
+ } = _b, props = __objRest(_b, [
3022
+ "instructions",
3023
+ "defaultOpen",
3024
+ "clickOutsideToClose",
3025
+ "hitEscapeToClose",
3026
+ "onSetOpen",
3027
+ "onSubmitMessage",
3028
+ "onStopGeneration",
3029
+ "onReloadMessages",
3030
+ "shortcut",
3031
+ "icons",
3032
+ "labels",
3033
+ "makeSystemMessage",
3034
+ "onInProgress",
3035
+ "Window",
3036
+ "Button",
3037
+ "Header",
3038
+ "Messages",
3039
+ "Input",
3040
+ "AssistantMessage",
3041
+ "UserMessage",
3042
+ "onThumbsUp",
3043
+ "onThumbsDown",
3044
+ "onCopy",
3045
+ "onRegenerate",
3046
+ "markdownTagRenderers",
3047
+ "className",
3048
+ "children",
3049
+ "observabilityHooks"
3050
+ ]);
3051
+ const [openState, setOpenState] = import_react16.default.useState(defaultOpen);
3052
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3053
+ CopilotModalInner,
3054
+ __spreadProps(__spreadValues({
3055
+ observabilityHooks,
3056
+ onSetOpen,
3057
+ clickOutsideToClose: clickOutsideToClose != null ? clickOutsideToClose : true,
3058
+ hitEscapeToClose: hitEscapeToClose != null ? hitEscapeToClose : true,
3059
+ shortcut: shortcut != null ? shortcut : "/",
3060
+ className,
3061
+ Window: Window2,
3062
+ Button: Button2,
3063
+ Header: Header2,
3064
+ instructions,
3065
+ onSubmitMessage,
3066
+ onStopGeneration,
3067
+ onReloadMessages,
3068
+ makeSystemMessage,
3069
+ onInProgress,
3070
+ Messages: Messages2,
3071
+ Input: Input2,
3072
+ AssistantMessage: AssistantMessage2,
3073
+ UserMessage: UserMessage2,
3074
+ onThumbsUp,
3075
+ onThumbsDown,
3076
+ onCopy,
3077
+ onRegenerate,
3078
+ markdownTagRenderers
3079
+ }, props), {
3080
+ children
3081
+ })
3082
+ ) });
3083
+ };
3084
+
3085
+ // src/components/chat/Popup.tsx
3086
+ var import_jsx_runtime26 = require("react/jsx-runtime");
3087
+ function CopilotPopup(props) {
3088
+ props = __spreadProps(__spreadValues({}, props), {
3089
+ className: props.className ? props.className + " copilotKitPopup" : "copilotKitPopup"
3090
+ });
3091
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(CopilotModal, __spreadProps(__spreadValues({}, props), { children: props.children }));
3092
+ }
3093
+
3094
+ // src/components/chat/Sidebar.tsx
3095
+ var import_react17 = require("react");
3096
+ var import_jsx_runtime27 = require("react/jsx-runtime");
3097
+ function CopilotSidebar(props) {
3098
+ props = __spreadProps(__spreadValues({}, props), {
3099
+ className: props.className ? props.className + " copilotKitSidebar" : "copilotKitSidebar"
3100
+ });
3101
+ const [expandedClassName, setExpandedClassName] = (0, import_react17.useState)(
3102
+ props.defaultOpen ? "sidebarExpanded" : ""
3103
+ );
3104
+ const onSetOpen = (open) => {
3105
+ var _a;
3106
+ (_a = props.onSetOpen) == null ? void 0 : _a.call(props, open);
3107
+ setExpandedClassName(open ? "sidebarExpanded" : "");
3108
+ };
3109
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: `copilotKitSidebarContentWrapper ${expandedClassName}`, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CopilotModal, __spreadProps(__spreadValues(__spreadValues({}, props), { onSetOpen }), { children: props.children })) });
3110
+ }
3111
+ // Annotate the CommonJS export names for ESM import in node:
3112
+ 0 && (module.exports = {
3113
+ AssistantMessage,
3114
+ CopilotChat,
3115
+ CopilotDevConsole,
3116
+ CopilotPopup,
3117
+ CopilotSidebar,
3118
+ ImageRenderer,
3119
+ Markdown,
3120
+ RenderSuggestion,
3121
+ RenderSuggestionsList,
3122
+ UserMessage,
3123
+ shouldShowDevConsole,
3124
+ useChatContext
3125
+ });
3126
+ //# sourceMappingURL=index.js.map