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