@copilotkit/react-ui 1.51.5-next.0 → 1.51.5-next.2

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 (339) hide show
  1. package/.attw.json +3 -0
  2. package/CHANGELOG.md +17 -0
  3. package/dist/index.cjs +2737 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.css +258 -70
  6. package/dist/index.css.map +1 -1
  7. package/dist/index.d.cts +781 -0
  8. package/dist/index.d.cts.map +1 -0
  9. package/dist/index.d.mts +781 -0
  10. package/dist/index.d.mts.map +1 -0
  11. package/dist/index.mjs +2685 -81
  12. package/dist/index.mjs.map +1 -1
  13. package/dist/index.umd.js +2750 -25
  14. package/dist/index.umd.js.map +1 -1
  15. package/package.json +19 -18
  16. package/src/components/chat/Popup.tsx +1 -1
  17. package/src/components/chat/Sidebar.tsx +1 -1
  18. package/tsdown.config.ts +58 -0
  19. package/vitest.config.mjs +11 -0
  20. package/dist/chunk-2QEDCM6H.mjs +0 -150
  21. package/dist/chunk-2QEDCM6H.mjs.map +0 -1
  22. package/dist/chunk-6SMTHXVA.mjs +0 -28
  23. package/dist/chunk-6SMTHXVA.mjs.map +0 -1
  24. package/dist/chunk-6TLDRWAD.mjs +0 -95
  25. package/dist/chunk-6TLDRWAD.mjs.map +0 -1
  26. package/dist/chunk-72FQQMQ2.mjs +0 -25
  27. package/dist/chunk-72FQQMQ2.mjs.map +0 -1
  28. package/dist/chunk-AOUHT4JR.mjs +0 -34
  29. package/dist/chunk-AOUHT4JR.mjs.map +0 -1
  30. package/dist/chunk-BNJX66OH.mjs +0 -118
  31. package/dist/chunk-BNJX66OH.mjs.map +0 -1
  32. package/dist/chunk-C27LZFA5.mjs +0 -97
  33. package/dist/chunk-C27LZFA5.mjs.map +0 -1
  34. package/dist/chunk-C7WM7GM3.mjs +0 -235
  35. package/dist/chunk-C7WM7GM3.mjs.map +0 -1
  36. package/dist/chunk-CNIC5HO5.mjs +0 -36
  37. package/dist/chunk-CNIC5HO5.mjs.map +0 -1
  38. package/dist/chunk-CQCXH5LY.mjs +0 -143
  39. package/dist/chunk-CQCXH5LY.mjs.map +0 -1
  40. package/dist/chunk-DM2V5WTG.mjs +0 -34
  41. package/dist/chunk-DM2V5WTG.mjs.map +0 -1
  42. package/dist/chunk-DSHTRV2R.mjs +0 -140
  43. package/dist/chunk-DSHTRV2R.mjs.map +0 -1
  44. package/dist/chunk-EACIYBQH.mjs +0 -32
  45. package/dist/chunk-EACIYBQH.mjs.map +0 -1
  46. package/dist/chunk-EFZPSZWO.mjs +0 -1
  47. package/dist/chunk-EFZPSZWO.mjs.map +0 -1
  48. package/dist/chunk-GBAPANZE.mjs +0 -323
  49. package/dist/chunk-GBAPANZE.mjs.map +0 -1
  50. package/dist/chunk-GFE5ZSPV.mjs +0 -112
  51. package/dist/chunk-GFE5ZSPV.mjs.map +0 -1
  52. package/dist/chunk-HHLX4MQN.mjs +0 -31
  53. package/dist/chunk-HHLX4MQN.mjs.map +0 -1
  54. package/dist/chunk-ICA2EXIX.mjs +0 -187
  55. package/dist/chunk-ICA2EXIX.mjs.map +0 -1
  56. package/dist/chunk-IU3WTXLQ.mjs +0 -1
  57. package/dist/chunk-IU3WTXLQ.mjs.map +0 -1
  58. package/dist/chunk-IWOCQACI.mjs +0 -73
  59. package/dist/chunk-IWOCQACI.mjs.map +0 -1
  60. package/dist/chunk-JGMFJZMG.mjs +0 -11
  61. package/dist/chunk-JGMFJZMG.mjs.map +0 -1
  62. package/dist/chunk-JYHRHKV5.mjs +0 -90
  63. package/dist/chunk-JYHRHKV5.mjs.map +0 -1
  64. package/dist/chunk-KXE2JCUH.mjs +0 -1
  65. package/dist/chunk-KXE2JCUH.mjs.map +0 -1
  66. package/dist/chunk-LIXN3OVQ.mjs +0 -405
  67. package/dist/chunk-LIXN3OVQ.mjs.map +0 -1
  68. package/dist/chunk-MC6PY7XH.mjs +0 -456
  69. package/dist/chunk-MC6PY7XH.mjs.map +0 -1
  70. package/dist/chunk-MMVDU6DF.mjs +0 -1
  71. package/dist/chunk-MMVDU6DF.mjs.map +0 -1
  72. package/dist/chunk-MRXNTQOX.mjs +0 -59
  73. package/dist/chunk-MRXNTQOX.mjs.map +0 -1
  74. package/dist/chunk-OQWEOBRX.mjs +0 -120
  75. package/dist/chunk-OQWEOBRX.mjs.map +0 -1
  76. package/dist/chunk-P34CL4LC.mjs +0 -82
  77. package/dist/chunk-P34CL4LC.mjs.map +0 -1
  78. package/dist/chunk-PF3QBO7V.mjs +0 -133
  79. package/dist/chunk-PF3QBO7V.mjs.map +0 -1
  80. package/dist/chunk-PLHTVHUW.mjs +0 -82
  81. package/dist/chunk-PLHTVHUW.mjs.map +0 -1
  82. package/dist/chunk-PP2A5RP6.mjs +0 -21
  83. package/dist/chunk-PP2A5RP6.mjs.map +0 -1
  84. package/dist/chunk-Q64GLWPQ.mjs +0 -30
  85. package/dist/chunk-Q64GLWPQ.mjs.map +0 -1
  86. package/dist/chunk-SC6JRFAJ.mjs +0 -1
  87. package/dist/chunk-SC6JRFAJ.mjs.map +0 -1
  88. package/dist/chunk-T26KLXLH.mjs +0 -1
  89. package/dist/chunk-T26KLXLH.mjs.map +0 -1
  90. package/dist/chunk-T4NNQG6T.mjs +0 -231
  91. package/dist/chunk-T4NNQG6T.mjs.map +0 -1
  92. package/dist/chunk-TGM5PKBF.mjs +0 -44
  93. package/dist/chunk-TGM5PKBF.mjs.map +0 -1
  94. package/dist/chunk-V7W6IM2V.mjs +0 -1
  95. package/dist/chunk-V7W6IM2V.mjs.map +0 -1
  96. package/dist/chunk-WB3YULQ4.mjs +0 -1
  97. package/dist/chunk-WB3YULQ4.mjs.map +0 -1
  98. package/dist/chunk-Y4FKRAKJ.mjs +0 -12
  99. package/dist/chunk-Y4FKRAKJ.mjs.map +0 -1
  100. package/dist/chunk-YDJ4YUUF.mjs +0 -141
  101. package/dist/chunk-YDJ4YUUF.mjs.map +0 -1
  102. package/dist/components/chat/Button.d.ts +0 -9
  103. package/dist/components/chat/Button.js +0 -73
  104. package/dist/components/chat/Button.js.map +0 -1
  105. package/dist/components/chat/Button.mjs +0 -10
  106. package/dist/components/chat/Button.mjs.map +0 -1
  107. package/dist/components/chat/Chat.d.ts +0 -204
  108. package/dist/components/chat/Chat.js +0 -2428
  109. package/dist/components/chat/Chat.js.map +0 -1
  110. package/dist/components/chat/Chat.mjs +0 -29
  111. package/dist/components/chat/Chat.mjs.map +0 -1
  112. package/dist/components/chat/ChatContext.d.ts +0 -145
  113. package/dist/components/chat/ChatContext.js +0 -383
  114. package/dist/components/chat/ChatContext.js.map +0 -1
  115. package/dist/components/chat/ChatContext.mjs +0 -13
  116. package/dist/components/chat/ChatContext.mjs.map +0 -1
  117. package/dist/components/chat/CodeBlock.d.ts +0 -14
  118. package/dist/components/chat/CodeBlock.js +0 -524
  119. package/dist/components/chat/CodeBlock.js.map +0 -1
  120. package/dist/components/chat/CodeBlock.mjs +0 -14
  121. package/dist/components/chat/CodeBlock.mjs.map +0 -1
  122. package/dist/components/chat/Header.d.ts +0 -9
  123. package/dist/components/chat/Header.js +0 -642
  124. package/dist/components/chat/Header.js.map +0 -1
  125. package/dist/components/chat/Header.mjs +0 -17
  126. package/dist/components/chat/Header.mjs.map +0 -1
  127. package/dist/components/chat/Icons.d.ts +0 -20
  128. package/dist/components/chat/Icons.js +0 -362
  129. package/dist/components/chat/Icons.js.map +0 -1
  130. package/dist/components/chat/Icons.mjs +0 -38
  131. package/dist/components/chat/Icons.mjs.map +0 -1
  132. package/dist/components/chat/ImageUploadQueue.d.ts +0 -13
  133. package/dist/components/chat/ImageUploadQueue.js +0 -106
  134. package/dist/components/chat/ImageUploadQueue.js.map +0 -1
  135. package/dist/components/chat/ImageUploadQueue.mjs +0 -8
  136. package/dist/components/chat/ImageUploadQueue.mjs.map +0 -1
  137. package/dist/components/chat/Input.d.ts +0 -9
  138. package/dist/components/chat/Input.js +0 -424
  139. package/dist/components/chat/Input.js.map +0 -1
  140. package/dist/components/chat/Input.mjs +0 -14
  141. package/dist/components/chat/Input.mjs.map +0 -1
  142. package/dist/components/chat/Markdown.d.ts +0 -10
  143. package/dist/components/chat/Markdown.js +0 -678
  144. package/dist/components/chat/Markdown.js.map +0 -1
  145. package/dist/components/chat/Markdown.mjs +0 -11
  146. package/dist/components/chat/Markdown.mjs.map +0 -1
  147. package/dist/components/chat/Messages.d.ts +0 -13
  148. package/dist/components/chat/Messages.js +0 -1242
  149. package/dist/components/chat/Messages.js.map +0 -1
  150. package/dist/components/chat/Messages.mjs +0 -20
  151. package/dist/components/chat/Messages.mjs.map +0 -1
  152. package/dist/components/chat/Modal.d.ts +0 -51
  153. package/dist/components/chat/Modal.js +0 -3294
  154. package/dist/components/chat/Modal.js.map +0 -1
  155. package/dist/components/chat/Modal.mjs +0 -38
  156. package/dist/components/chat/Modal.mjs.map +0 -1
  157. package/dist/components/chat/Popup.d.ts +0 -13
  158. package/dist/components/chat/Popup.js +0 -3305
  159. package/dist/components/chat/Popup.js.map +0 -1
  160. package/dist/components/chat/Popup.mjs +0 -39
  161. package/dist/components/chat/Popup.mjs.map +0 -1
  162. package/dist/components/chat/PoweredByTag.d.ts +0 -7
  163. package/dist/components/chat/PoweredByTag.js +0 -63
  164. package/dist/components/chat/PoweredByTag.js.map +0 -1
  165. package/dist/components/chat/PoweredByTag.mjs +0 -9
  166. package/dist/components/chat/PoweredByTag.mjs.map +0 -1
  167. package/dist/components/chat/Sidebar.d.ts +0 -13
  168. package/dist/components/chat/Sidebar.js +0 -3314
  169. package/dist/components/chat/Sidebar.js.map +0 -1
  170. package/dist/components/chat/Sidebar.mjs +0 -39
  171. package/dist/components/chat/Sidebar.mjs.map +0 -1
  172. package/dist/components/chat/Suggestion.d.ts +0 -12
  173. package/dist/components/chat/Suggestion.js +0 -68
  174. package/dist/components/chat/Suggestion.js.map +0 -1
  175. package/dist/components/chat/Suggestion.mjs +0 -9
  176. package/dist/components/chat/Suggestion.mjs.map +0 -1
  177. package/dist/components/chat/Suggestions.d.ts +0 -9
  178. package/dist/components/chat/Suggestions.js +0 -93
  179. package/dist/components/chat/Suggestions.js.map +0 -1
  180. package/dist/components/chat/Suggestions.mjs +0 -10
  181. package/dist/components/chat/Suggestions.mjs.map +0 -1
  182. package/dist/components/chat/Textarea.d.ts +0 -15
  183. package/dist/components/chat/Textarea.js +0 -87
  184. package/dist/components/chat/Textarea.js.map +0 -1
  185. package/dist/components/chat/Textarea.mjs +0 -8
  186. package/dist/components/chat/Textarea.mjs.map +0 -1
  187. package/dist/components/chat/Window.d.ts +0 -9
  188. package/dist/components/chat/Window.js +0 -166
  189. package/dist/components/chat/Window.js.map +0 -1
  190. package/dist/components/chat/Window.mjs +0 -10
  191. package/dist/components/chat/Window.mjs.map +0 -1
  192. package/dist/components/chat/index.d.ts +0 -18
  193. package/dist/components/chat/index.js +0 -3341
  194. package/dist/components/chat/index.js.map +0 -1
  195. package/dist/components/chat/index.mjs +0 -69
  196. package/dist/components/chat/index.mjs.map +0 -1
  197. package/dist/components/chat/messages/AssistantMessage.d.ts +0 -9
  198. package/dist/components/chat/messages/AssistantMessage.js +0 -807
  199. package/dist/components/chat/messages/AssistantMessage.js.map +0 -1
  200. package/dist/components/chat/messages/AssistantMessage.mjs +0 -13
  201. package/dist/components/chat/messages/AssistantMessage.mjs.map +0 -1
  202. package/dist/components/chat/messages/ErrorMessage.d.ts +0 -9
  203. package/dist/components/chat/messages/ErrorMessage.js +0 -756
  204. package/dist/components/chat/messages/ErrorMessage.js.map +0 -1
  205. package/dist/components/chat/messages/ErrorMessage.mjs +0 -72
  206. package/dist/components/chat/messages/ErrorMessage.mjs.map +0 -1
  207. package/dist/components/chat/messages/ImageRenderer.d.ts +0 -12
  208. package/dist/components/chat/messages/ImageRenderer.js +0 -68
  209. package/dist/components/chat/messages/ImageRenderer.js.map +0 -1
  210. package/dist/components/chat/messages/ImageRenderer.mjs +0 -8
  211. package/dist/components/chat/messages/ImageRenderer.mjs.map +0 -1
  212. package/dist/components/chat/messages/LegacyRenderMessage.d.ts +0 -28
  213. package/dist/components/chat/messages/LegacyRenderMessage.js +0 -1067
  214. package/dist/components/chat/messages/LegacyRenderMessage.js.map +0 -1
  215. package/dist/components/chat/messages/LegacyRenderMessage.mjs +0 -17
  216. package/dist/components/chat/messages/LegacyRenderMessage.mjs.map +0 -1
  217. package/dist/components/chat/messages/RenderMessage.d.ts +0 -9
  218. package/dist/components/chat/messages/RenderMessage.js +0 -942
  219. package/dist/components/chat/messages/RenderMessage.js.map +0 -1
  220. package/dist/components/chat/messages/RenderMessage.mjs +0 -16
  221. package/dist/components/chat/messages/RenderMessage.mjs.map +0 -1
  222. package/dist/components/chat/messages/UserMessage.d.ts +0 -9
  223. package/dist/components/chat/messages/UserMessage.js +0 -58
  224. package/dist/components/chat/messages/UserMessage.js.map +0 -1
  225. package/dist/components/chat/messages/UserMessage.mjs +0 -8
  226. package/dist/components/chat/messages/UserMessage.mjs.map +0 -1
  227. package/dist/components/chat/props.d.ts +0 -298
  228. package/dist/components/chat/props.js +0 -19
  229. package/dist/components/chat/props.js.map +0 -1
  230. package/dist/components/chat/props.mjs +0 -2
  231. package/dist/components/chat/props.mjs.map +0 -1
  232. package/dist/components/dev-console/console.d.ts +0 -11
  233. package/dist/components/dev-console/console.js +0 -595
  234. package/dist/components/dev-console/console.js.map +0 -1
  235. package/dist/components/dev-console/console.mjs +0 -17
  236. package/dist/components/dev-console/console.mjs.map +0 -1
  237. package/dist/components/dev-console/icons.d.ts +0 -9
  238. package/dist/components/dev-console/icons.js +0 -140
  239. package/dist/components/dev-console/icons.js.map +0 -1
  240. package/dist/components/dev-console/icons.mjs +0 -16
  241. package/dist/components/dev-console/icons.mjs.map +0 -1
  242. package/dist/components/dev-console/index.d.ts +0 -3
  243. package/dist/components/dev-console/index.js +0 -595
  244. package/dist/components/dev-console/index.js.map +0 -1
  245. package/dist/components/dev-console/index.mjs +0 -18
  246. package/dist/components/dev-console/index.mjs.map +0 -1
  247. package/dist/components/dev-console/types.d.ts +0 -9
  248. package/dist/components/dev-console/types.js +0 -19
  249. package/dist/components/dev-console/types.js.map +0 -1
  250. package/dist/components/dev-console/types.mjs +0 -1
  251. package/dist/components/dev-console/types.mjs.map +0 -1
  252. package/dist/components/dev-console/utils.d.ts +0 -10
  253. package/dist/components/dev-console/utils.js +0 -183
  254. package/dist/components/dev-console/utils.js.map +0 -1
  255. package/dist/components/dev-console/utils.mjs +0 -16
  256. package/dist/components/dev-console/utils.mjs.map +0 -1
  257. package/dist/components/help-modal/icons.d.ts +0 -9
  258. package/dist/components/help-modal/icons.js +0 -116
  259. package/dist/components/help-modal/icons.js.map +0 -1
  260. package/dist/components/help-modal/icons.mjs +0 -12
  261. package/dist/components/help-modal/icons.mjs.map +0 -1
  262. package/dist/components/help-modal/index.d.ts +0 -2
  263. package/dist/components/help-modal/index.js +0 -144
  264. package/dist/components/help-modal/index.js.map +0 -1
  265. package/dist/components/help-modal/index.mjs +0 -10
  266. package/dist/components/help-modal/index.mjs.map +0 -1
  267. package/dist/components/help-modal/modal.d.ts +0 -5
  268. package/dist/components/help-modal/modal.js +0 -142
  269. package/dist/components/help-modal/modal.js.map +0 -1
  270. package/dist/components/help-modal/modal.mjs +0 -9
  271. package/dist/components/help-modal/modal.mjs.map +0 -1
  272. package/dist/components/index.d.ts +0 -19
  273. package/dist/components/index.js +0 -3345
  274. package/dist/components/index.js.map +0 -1
  275. package/dist/components/index.mjs +0 -76
  276. package/dist/components/index.mjs.map +0 -1
  277. package/dist/context/index.d.ts +0 -2
  278. package/dist/context/index.js +0 -19
  279. package/dist/context/index.js.map +0 -1
  280. package/dist/context/index.mjs +0 -2
  281. package/dist/context/index.mjs.map +0 -1
  282. package/dist/hooks/index.d.ts +0 -2
  283. package/dist/hooks/index.js +0 -36
  284. package/dist/hooks/index.js.map +0 -1
  285. package/dist/hooks/index.mjs +0 -9
  286. package/dist/hooks/index.mjs.map +0 -1
  287. package/dist/hooks/use-copilot-chat-suggestions.d.ts +0 -66
  288. package/dist/hooks/use-copilot-chat-suggestions.js +0 -34
  289. package/dist/hooks/use-copilot-chat-suggestions.js.map +0 -1
  290. package/dist/hooks/use-copilot-chat-suggestions.mjs +0 -8
  291. package/dist/hooks/use-copilot-chat-suggestions.mjs.map +0 -1
  292. package/dist/hooks/use-copy-to-clipboard.d.ts +0 -9
  293. package/dist/hooks/use-copy-to-clipboard.js +0 -62
  294. package/dist/hooks/use-copy-to-clipboard.js.map +0 -1
  295. package/dist/hooks/use-copy-to-clipboard.mjs +0 -8
  296. package/dist/hooks/use-copy-to-clipboard.mjs.map +0 -1
  297. package/dist/hooks/use-dark-mode.d.ts +0 -3
  298. package/dist/hooks/use-dark-mode.js +0 -35
  299. package/dist/hooks/use-dark-mode.js.map +0 -1
  300. package/dist/hooks/use-dark-mode.mjs +0 -8
  301. package/dist/hooks/use-dark-mode.mjs.map +0 -1
  302. package/dist/hooks/use-push-to-talk.d.ts +0 -19
  303. package/dist/hooks/use-push-to-talk.js +0 -202
  304. package/dist/hooks/use-push-to-talk.js.map +0 -1
  305. package/dist/hooks/use-push-to-talk.mjs +0 -12
  306. package/dist/hooks/use-push-to-talk.mjs.map +0 -1
  307. package/dist/index.d.ts +0 -21
  308. package/dist/index.js +0 -3354
  309. package/dist/index.js.map +0 -1
  310. package/dist/lib/utils.d.ts +0 -4
  311. package/dist/lib/utils.js +0 -76
  312. package/dist/lib/utils.js.map +0 -1
  313. package/dist/lib/utils.mjs +0 -34
  314. package/dist/lib/utils.mjs.map +0 -1
  315. package/dist/types/css.d.ts +0 -22
  316. package/dist/types/css.js +0 -19
  317. package/dist/types/css.js.map +0 -1
  318. package/dist/types/css.mjs +0 -1
  319. package/dist/types/css.mjs.map +0 -1
  320. package/dist/types/index.d.ts +0 -3
  321. package/dist/types/index.js +0 -19
  322. package/dist/types/index.js.map +0 -1
  323. package/dist/types/index.mjs +0 -2
  324. package/dist/types/index.mjs.map +0 -1
  325. package/dist/types/suggestions.d.ts +0 -9
  326. package/dist/types/suggestions.js +0 -19
  327. package/dist/types/suggestions.js.map +0 -1
  328. package/dist/types/suggestions.mjs +0 -1
  329. package/dist/types/suggestions.mjs.map +0 -1
  330. package/dist/v2/index.css +0 -4
  331. package/dist/v2/index.css.map +0 -1
  332. package/dist/v2/index.d.ts +0 -2
  333. package/dist/v2/index.js +0 -2
  334. package/dist/v2/index.js.map +0 -1
  335. package/dist/v2/index.mjs +0 -2
  336. package/dist/v2/index.mjs.map +0 -1
  337. package/jest.config.js +0 -5
  338. package/rollup.config.mjs +0 -64
  339. package/tsup.config.ts +0 -15
@@ -1,2428 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __defProps = Object.defineProperties;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
- var __getOwnPropNames = Object.getOwnPropertyNames;
8
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
- var __getProtoOf = Object.getPrototypeOf;
10
- var __hasOwnProp = Object.prototype.hasOwnProperty;
11
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
- var __spreadValues = (a, b) => {
14
- for (var prop in b || (b = {}))
15
- if (__hasOwnProp.call(b, prop))
16
- __defNormalProp(a, prop, b[prop]);
17
- if (__getOwnPropSymbols)
18
- for (var prop of __getOwnPropSymbols(b)) {
19
- if (__propIsEnum.call(b, prop))
20
- __defNormalProp(a, prop, b[prop]);
21
- }
22
- return a;
23
- };
24
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
- var __objRest = (source, exclude) => {
26
- var target = {};
27
- for (var prop in source)
28
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
- target[prop] = source[prop];
30
- if (source != null && __getOwnPropSymbols)
31
- for (var prop of __getOwnPropSymbols(source)) {
32
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
- target[prop] = source[prop];
34
- }
35
- return target;
36
- };
37
- var __export = (target, all) => {
38
- for (var name in all)
39
- __defProp(target, name, { get: all[name], enumerable: true });
40
- };
41
- var __copyProps = (to, from, except, desc) => {
42
- if (from && typeof from === "object" || typeof from === "function") {
43
- for (let key of __getOwnPropNames(from))
44
- if (!__hasOwnProp.call(to, key) && key !== except)
45
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
46
- }
47
- return to;
48
- };
49
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
50
- // If the importer is in node compatibility mode or this is not an ESM
51
- // file that has been converted to a CommonJS file using a Babel-
52
- // compatible transform (i.e. "__esModule" has not been set), then set
53
- // "default" to the CommonJS "module.exports" for node compatibility.
54
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
55
- mod
56
- ));
57
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
58
- var __async = (__this, __arguments, generator) => {
59
- return new Promise((resolve, reject) => {
60
- var fulfilled = (value) => {
61
- try {
62
- step(generator.next(value));
63
- } catch (e) {
64
- reject(e);
65
- }
66
- };
67
- var rejected = (value) => {
68
- try {
69
- step(generator.throw(value));
70
- } catch (e) {
71
- reject(e);
72
- }
73
- };
74
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
75
- step((generator = generator.apply(__this, __arguments)).next());
76
- });
77
- };
78
-
79
- // src/components/chat/Chat.tsx
80
- var Chat_exports = {};
81
- __export(Chat_exports, {
82
- CopilotChat: () => CopilotChat,
83
- WrappedCopilotChat: () => WrappedCopilotChat
84
- });
85
- module.exports = __toCommonJS(Chat_exports);
86
-
87
- // src/components/chat/ChatContext.tsx
88
- var import_react = __toESM(require("react"));
89
-
90
- // src/components/chat/Icons.tsx
91
- var import_jsx_runtime = require("react/jsx-runtime");
92
- var OpenIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
93
- "svg",
94
- {
95
- xmlns: "http://www.w3.org/2000/svg",
96
- viewBox: "0 0 24 24",
97
- fill: "currentColor",
98
- width: "24",
99
- height: "24",
100
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", { transform: "translate(24, 0) scale(-1, 1)", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
101
- "path",
102
- {
103
- fillRule: "evenodd",
104
- 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",
105
- clipRule: "evenodd"
106
- }
107
- ) })
108
- }
109
- );
110
- var CloseIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
111
- "svg",
112
- {
113
- xmlns: "http://www.w3.org/2000/svg",
114
- fill: "none",
115
- viewBox: "0 0 24 24",
116
- strokeWidth: "1.5",
117
- stroke: "currentColor",
118
- width: "24",
119
- height: "24",
120
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
121
- "path",
122
- {
123
- strokeLinecap: "round",
124
- strokeLinejoin: "round",
125
- d: "M19.5 8.25l-7.5 7.5-7.5-7.5"
126
- }
127
- )
128
- }
129
- );
130
- var HeaderCloseIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
131
- "svg",
132
- {
133
- xmlns: "http://www.w3.org/2000/svg",
134
- fill: "none",
135
- viewBox: "0 0 24 24",
136
- strokeWidth: "1.5",
137
- stroke: "currentColor",
138
- width: "24",
139
- height: "24",
140
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
141
- "path",
142
- {
143
- strokeLinecap: "round",
144
- strokeLinejoin: "round",
145
- d: "M6 18L18 6M6 6l12 12"
146
- }
147
- )
148
- }
149
- );
150
- var SendIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
151
- "svg",
152
- {
153
- xmlns: "http://www.w3.org/2000/svg",
154
- fill: "none",
155
- viewBox: "0 0 24 24",
156
- strokeWidth: "1.5",
157
- stroke: "currentColor",
158
- width: "24",
159
- height: "24",
160
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
161
- "path",
162
- {
163
- strokeLinecap: "round",
164
- strokeLinejoin: "round",
165
- d: "M12 19V5m0 0l-7 7m7-7l7 7"
166
- }
167
- )
168
- }
169
- );
170
- var MicrophoneIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
171
- "svg",
172
- {
173
- xmlns: "http://www.w3.org/2000/svg",
174
- fill: "none",
175
- viewBox: "0 0 24 24",
176
- strokeWidth: "1.5",
177
- stroke: "currentColor",
178
- width: "24",
179
- height: "24",
180
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
181
- "path",
182
- {
183
- strokeLinecap: "round",
184
- strokeLinejoin: "round",
185
- 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"
186
- }
187
- )
188
- }
189
- );
190
- var StopIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
191
- "svg",
192
- {
193
- xmlns: "http://www.w3.org/2000/svg",
194
- fill: "none",
195
- viewBox: "0 0 24 24",
196
- strokeWidth: "1.5",
197
- stroke: "currentColor",
198
- width: "24",
199
- height: "24",
200
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
201
- "path",
202
- {
203
- strokeLinecap: "round",
204
- strokeLinejoin: "round",
205
- 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"
206
- }
207
- )
208
- }
209
- );
210
- var RegenerateIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
211
- "svg",
212
- {
213
- xmlns: "http://www.w3.org/2000/svg",
214
- fill: "none",
215
- viewBox: "0 0 24 24",
216
- strokeWidth: "2",
217
- stroke: "currentColor",
218
- width: "16",
219
- height: "16",
220
- style: { minWidth: "16px", minHeight: "16px" },
221
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
222
- "path",
223
- {
224
- strokeLinecap: "round",
225
- strokeLinejoin: "round",
226
- 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"
227
- }
228
- )
229
- }
230
- );
231
- var CopyIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
232
- "svg",
233
- {
234
- xmlns: "http://www.w3.org/2000/svg",
235
- fill: "none",
236
- viewBox: "0 0 24 24",
237
- strokeWidth: "2",
238
- stroke: "currentColor",
239
- width: "16",
240
- height: "16",
241
- style: { minWidth: "16px", minHeight: "16px" },
242
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
243
- "path",
244
- {
245
- strokeLinecap: "round",
246
- strokeLinejoin: "round",
247
- 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"
248
- }
249
- )
250
- }
251
- );
252
- var SmallSpinnerIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
253
- "span",
254
- {
255
- className: "copilotKitSpinner",
256
- style: { width: "13px", height: "13px" }
257
- }
258
- );
259
- var SpinnerIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
260
- "span",
261
- {
262
- className: "copilotKitSpinner",
263
- style: { width: "24px", height: "24px" }
264
- }
265
- );
266
- var ActivityIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "4px" }, children: [
267
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
268
- "span",
269
- {
270
- className: "copilotKitActivityDot",
271
- style: { animationDelay: "0s" }
272
- }
273
- ),
274
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
275
- "span",
276
- {
277
- className: "copilotKitActivityDot",
278
- style: { animationDelay: "0.2s" }
279
- }
280
- ),
281
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
282
- "span",
283
- {
284
- className: "copilotKitActivityDot",
285
- style: { animationDelay: "0.4s" }
286
- }
287
- )
288
- ] });
289
- var ThumbsUpIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
290
- "svg",
291
- {
292
- xmlns: "http://www.w3.org/2000/svg",
293
- fill: "none",
294
- viewBox: "0 0 24 24",
295
- strokeWidth: "2",
296
- stroke: "currentColor",
297
- width: "16",
298
- height: "16",
299
- style: { minWidth: "16px", minHeight: "16px" },
300
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
301
- "path",
302
- {
303
- strokeLinecap: "round",
304
- strokeLinejoin: "round",
305
- 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"
306
- }
307
- )
308
- }
309
- );
310
- var ThumbsDownIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
311
- "svg",
312
- {
313
- xmlns: "http://www.w3.org/2000/svg",
314
- fill: "none",
315
- viewBox: "0 0 24 24",
316
- strokeWidth: "2",
317
- stroke: "currentColor",
318
- width: "16",
319
- height: "16",
320
- style: { minWidth: "16px", minHeight: "16px" },
321
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
322
- "path",
323
- {
324
- strokeLinecap: "round",
325
- strokeLinejoin: "round",
326
- 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"
327
- }
328
- )
329
- }
330
- );
331
- var DownloadIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
332
- "svg",
333
- {
334
- xmlns: "http://www.w3.org/2000/svg",
335
- fill: "none",
336
- viewBox: "0 0 24 24",
337
- strokeWidth: "2",
338
- stroke: "currentColor",
339
- width: "16",
340
- height: "16",
341
- style: { minWidth: "16px", minHeight: "16px" },
342
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
343
- "path",
344
- {
345
- strokeLinecap: "round",
346
- strokeLinejoin: "round",
347
- 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"
348
- }
349
- )
350
- }
351
- );
352
- var UploadIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
353
- "svg",
354
- {
355
- xmlns: "http://www.w3.org/2000/svg",
356
- fill: "none",
357
- viewBox: "0 0 24 24",
358
- strokeWidth: "1.5",
359
- stroke: "currentColor",
360
- width: "24",
361
- height: "24",
362
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
363
- "path",
364
- {
365
- strokeLinecap: "round",
366
- strokeLinejoin: "round",
367
- d: "M12 4.5v15m7.5-7.5h-15"
368
- }
369
- )
370
- }
371
- );
372
- var CheckIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
373
- "svg",
374
- {
375
- xmlns: "http://www.w3.org/2000/svg",
376
- fill: "none",
377
- viewBox: "0 0 24 24",
378
- strokeWidth: "2",
379
- stroke: "currentColor",
380
- width: "16",
381
- height: "16",
382
- style: { minWidth: "16px", minHeight: "16px" },
383
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
384
- "path",
385
- {
386
- strokeLinecap: "round",
387
- strokeLinejoin: "round",
388
- d: "M4.5 12.75l6 6 9-13.5"
389
- }
390
- )
391
- }
392
- );
393
-
394
- // src/components/chat/ChatContext.tsx
395
- var import_jsx_runtime2 = require("react/jsx-runtime");
396
- var ChatContext = import_react.default.createContext(
397
- void 0
398
- );
399
- function useChatContext() {
400
- const context = import_react.default.useContext(ChatContext);
401
- if (context === void 0) {
402
- throw new Error(
403
- "Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?"
404
- );
405
- }
406
- return context;
407
- }
408
- var ChatContextProvider = ({
409
- // temperature,
410
- // instructions,
411
- // maxFeedback,
412
- labels,
413
- icons,
414
- children,
415
- open,
416
- setOpen
417
- }) => {
418
- const memoizedLabels = (0, import_react.useMemo)(
419
- () => __spreadValues(__spreadValues({}, {
420
- initial: "",
421
- title: "CopilotKit",
422
- placeholder: "Type a message...",
423
- error: "\u274C An error occurred. Please try again.",
424
- stopGenerating: "Stop generating",
425
- regenerateResponse: "Regenerate response",
426
- copyToClipboard: "Copy to clipboard",
427
- thumbsUp: "Thumbs up",
428
- thumbsDown: "Thumbs down",
429
- copied: "Copied!"
430
- }), labels),
431
- [labels]
432
- );
433
- const memoizedIcons = (0, import_react.useMemo)(
434
- () => __spreadValues(__spreadValues({}, {
435
- openIcon: OpenIcon,
436
- closeIcon: CloseIcon,
437
- headerCloseIcon: HeaderCloseIcon,
438
- sendIcon: SendIcon,
439
- activityIcon: ActivityIcon,
440
- spinnerIcon: SpinnerIcon,
441
- stopIcon: StopIcon,
442
- regenerateIcon: RegenerateIcon,
443
- pushToTalkIcon: MicrophoneIcon,
444
- copyIcon: CopyIcon,
445
- thumbsUpIcon: ThumbsUpIcon,
446
- thumbsDownIcon: ThumbsDownIcon,
447
- uploadIcon: UploadIcon
448
- }), icons),
449
- [icons]
450
- );
451
- const context = (0, import_react.useMemo)(
452
- () => ({
453
- labels: memoizedLabels,
454
- icons: memoizedIcons,
455
- open,
456
- setOpen
457
- }),
458
- [memoizedLabels, memoizedIcons, open, setOpen]
459
- );
460
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ChatContext.Provider, { value: context, children });
461
- };
462
-
463
- // src/components/chat/Messages.tsx
464
- var import_react6 = require("react");
465
- var import_react_core = require("@copilotkit/react-core");
466
-
467
- // src/components/chat/messages/UserMessage.tsx
468
- var import_jsx_runtime3 = require("react/jsx-runtime");
469
- var getTextContent = (content) => {
470
- if (typeof content === "undefined") {
471
- return void 0;
472
- }
473
- if (typeof content === "string") {
474
- return content;
475
- }
476
- return content.map((part) => {
477
- if (part.type === "text") {
478
- return part.text;
479
- }
480
- return void 0;
481
- }).filter(
482
- (value) => typeof value === "string" && value.length > 0
483
- ).join(" ").trim() || void 0;
484
- };
485
- var UserMessage = (props) => {
486
- const { message, ImageRenderer: ImageRenderer2 } = props;
487
- const isImageMessage = message && "image" in message && Boolean(message.image);
488
- if (isImageMessage) {
489
- const imageMessage = message;
490
- const content2 = getTextContent(imageMessage == null ? void 0 : imageMessage.content);
491
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "copilotKitMessage copilotKitUserMessage", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ImageRenderer2, { image: imageMessage.image, content: content2 }) });
492
- }
493
- const content = getTextContent(message == null ? void 0 : message.content);
494
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "copilotKitMessage copilotKitUserMessage", children: content });
495
- };
496
-
497
- // src/components/chat/Markdown.tsx
498
- var import_react3 = require("react");
499
- var import_react_markdown = __toESM(require("react-markdown"));
500
-
501
- // src/components/chat/CodeBlock.tsx
502
- var import_react2 = require("react");
503
- var import_react_syntax_highlighter = require("react-syntax-highlighter");
504
-
505
- // src/hooks/use-copy-to-clipboard.tsx
506
- var React2 = __toESM(require("react"));
507
- function useCopyToClipboard({
508
- timeout = 2e3
509
- }) {
510
- const [isCopied, setIsCopied] = React2.useState(false);
511
- const copyToClipboard = (value) => {
512
- var _a;
513
- if (typeof window === "undefined" || !((_a = navigator.clipboard) == null ? void 0 : _a.writeText)) {
514
- return;
515
- }
516
- if (!value) {
517
- return;
518
- }
519
- navigator.clipboard.writeText(value).then(() => {
520
- setIsCopied(true);
521
- setTimeout(() => {
522
- setIsCopied(false);
523
- }, timeout);
524
- });
525
- };
526
- return { isCopied, copyToClipboard };
527
- }
528
-
529
- // src/components/chat/CodeBlock.tsx
530
- var import_jsx_runtime4 = require("react/jsx-runtime");
531
- var programmingLanguages = {
532
- javascript: ".js",
533
- python: ".py",
534
- java: ".java",
535
- c: ".c",
536
- cpp: ".cpp",
537
- "c++": ".cpp",
538
- "c#": ".cs",
539
- ruby: ".rb",
540
- php: ".php",
541
- swift: ".swift",
542
- "objective-c": ".m",
543
- kotlin: ".kt",
544
- typescript: ".ts",
545
- go: ".go",
546
- perl: ".pl",
547
- rust: ".rs",
548
- scala: ".scala",
549
- haskell: ".hs",
550
- lua: ".lua",
551
- shell: ".sh",
552
- sql: ".sql",
553
- html: ".html",
554
- css: ".css"
555
- // add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component
556
- };
557
- var generateRandomString = (length, lowercase = false) => {
558
- const chars = "ABCDEFGHJKLMNPQRSTUVWXY3456789";
559
- let result = "";
560
- for (let i = 0; i < length; i++) {
561
- result += chars.charAt(Math.floor(Math.random() * chars.length));
562
- }
563
- return lowercase ? result.toLowerCase() : result;
564
- };
565
- var CodeBlock = (0, import_react2.memo)(({ language, value }) => {
566
- const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2e3 });
567
- const [SyntaxHighlighter, setSyntaxHighlighter] = (0, import_react2.useState)(() => import_react_syntax_highlighter.Light);
568
- (0, import_react2.useEffect)(() => {
569
- try {
570
- new RegExp("(?<=#)\\w+");
571
- setSyntaxHighlighter(() => import_react_syntax_highlighter.Prism);
572
- } catch (e) {
573
- setSyntaxHighlighter(() => import_react_syntax_highlighter.Light);
574
- }
575
- }, []);
576
- const downloadAsFile = () => {
577
- if (typeof window === "undefined") {
578
- return;
579
- }
580
- const fileExtension = programmingLanguages[language] || ".file";
581
- const suggestedFileName = `file-${generateRandomString(3, true)}${fileExtension}`;
582
- const fileName = window.prompt("Enter file name", suggestedFileName);
583
- if (!fileName) {
584
- return;
585
- }
586
- const blob = new Blob([value], { type: "text/plain" });
587
- const url = URL.createObjectURL(blob);
588
- const link = document.createElement("a");
589
- link.download = fileName;
590
- link.href = url;
591
- link.style.display = "none";
592
- document.body.appendChild(link);
593
- link.click();
594
- document.body.removeChild(link);
595
- URL.revokeObjectURL(url);
596
- };
597
- const onCopy = () => {
598
- if (isCopied)
599
- return;
600
- copyToClipboard(value);
601
- };
602
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "copilotKitCodeBlock", children: [
603
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "copilotKitCodeBlockToolbar", children: [
604
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "copilotKitCodeBlockToolbarLanguage", children: language }),
605
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "copilotKitCodeBlockToolbarButtons", children: [
606
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
607
- "button",
608
- {
609
- className: "copilotKitCodeBlockToolbarButton",
610
- onClick: downloadAsFile,
611
- children: DownloadIcon
612
- }
613
- ),
614
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { className: "copilotKitCodeBlockToolbarButton", onClick: onCopy, children: isCopied ? CheckIcon : CopyIcon })
615
- ] })
616
- ] }),
617
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
618
- SyntaxHighlighter,
619
- {
620
- language,
621
- style: highlightStyle,
622
- PreTag: "div",
623
- customStyle: {
624
- margin: 0,
625
- borderBottomLeftRadius: "0.375rem",
626
- borderBottomRightRadius: "0.375rem"
627
- },
628
- children: value
629
- }
630
- )
631
- ] });
632
- });
633
- CodeBlock.displayName = "CodeBlock";
634
- var highlightStyle = {
635
- 'pre[class*="language-"]': {
636
- color: "#d4d4d4",
637
- fontSize: "13px",
638
- textShadow: "none",
639
- fontFamily: 'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',
640
- direction: "ltr",
641
- textAlign: "left",
642
- whiteSpace: "pre",
643
- wordSpacing: "normal",
644
- wordBreak: "normal",
645
- lineHeight: "1.5",
646
- MozTabSize: "4",
647
- OTabSize: "4",
648
- tabSize: "4",
649
- WebkitHyphens: "none",
650
- MozHyphens: "none",
651
- msHyphens: "none",
652
- hyphens: "none",
653
- padding: "1em",
654
- margin: ".5em 0",
655
- overflow: "auto",
656
- background: "#1e1e1e"
657
- },
658
- 'code[class*="language-"]': {
659
- color: "#d4d4d4",
660
- fontSize: "13px",
661
- textShadow: "none",
662
- fontFamily: 'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',
663
- direction: "ltr",
664
- textAlign: "left",
665
- whiteSpace: "pre",
666
- wordSpacing: "normal",
667
- wordBreak: "normal",
668
- lineHeight: "1.5",
669
- MozTabSize: "4",
670
- OTabSize: "4",
671
- tabSize: "4",
672
- WebkitHyphens: "none",
673
- MozHyphens: "none",
674
- msHyphens: "none",
675
- hyphens: "none"
676
- },
677
- 'pre[class*="language-"]::selection': {
678
- textShadow: "none",
679
- background: "#264F78"
680
- },
681
- 'code[class*="language-"]::selection': {
682
- textShadow: "none",
683
- background: "#264F78"
684
- },
685
- 'pre[class*="language-"] *::selection': {
686
- textShadow: "none",
687
- background: "#264F78"
688
- },
689
- 'code[class*="language-"] *::selection': {
690
- textShadow: "none",
691
- background: "#264F78"
692
- },
693
- ':not(pre) > code[class*="language-"]': {
694
- padding: ".1em .3em",
695
- borderRadius: ".3em",
696
- color: "#db4c69",
697
- background: "#1e1e1e"
698
- },
699
- ".namespace": {
700
- Opacity: ".7"
701
- },
702
- "doctype.doctype-tag": {
703
- color: "#569CD6"
704
- },
705
- "doctype.name": {
706
- color: "#9cdcfe"
707
- },
708
- comment: {
709
- color: "#6a9955"
710
- },
711
- prolog: {
712
- color: "#6a9955"
713
- },
714
- punctuation: {
715
- color: "#d4d4d4"
716
- },
717
- ".language-html .language-css .token.punctuation": {
718
- color: "#d4d4d4"
719
- },
720
- ".language-html .language-javascript .token.punctuation": {
721
- color: "#d4d4d4"
722
- },
723
- property: {
724
- color: "#9cdcfe"
725
- },
726
- tag: {
727
- color: "#569cd6"
728
- },
729
- boolean: {
730
- color: "#569cd6"
731
- },
732
- number: {
733
- color: "#b5cea8"
734
- },
735
- constant: {
736
- color: "#9cdcfe"
737
- },
738
- symbol: {
739
- color: "#b5cea8"
740
- },
741
- inserted: {
742
- color: "#b5cea8"
743
- },
744
- unit: {
745
- color: "#b5cea8"
746
- },
747
- selector: {
748
- color: "#d7ba7d"
749
- },
750
- "attr-name": {
751
- color: "#9cdcfe"
752
- },
753
- string: {
754
- color: "#ce9178"
755
- },
756
- char: {
757
- color: "#ce9178"
758
- },
759
- builtin: {
760
- color: "#ce9178"
761
- },
762
- deleted: {
763
- color: "#ce9178"
764
- },
765
- ".language-css .token.string.url": {
766
- textDecoration: "underline"
767
- },
768
- operator: {
769
- color: "#d4d4d4"
770
- },
771
- entity: {
772
- color: "#569cd6"
773
- },
774
- "operator.arrow": {
775
- color: "#569CD6"
776
- },
777
- atrule: {
778
- color: "#ce9178"
779
- },
780
- "atrule.rule": {
781
- color: "#c586c0"
782
- },
783
- "atrule.url": {
784
- color: "#9cdcfe"
785
- },
786
- "atrule.url.function": {
787
- color: "#dcdcaa"
788
- },
789
- "atrule.url.punctuation": {
790
- color: "#d4d4d4"
791
- },
792
- keyword: {
793
- color: "#569CD6"
794
- },
795
- "keyword.module": {
796
- color: "#c586c0"
797
- },
798
- "keyword.control-flow": {
799
- color: "#c586c0"
800
- },
801
- function: {
802
- color: "#dcdcaa"
803
- },
804
- "function.maybe-class-name": {
805
- color: "#dcdcaa"
806
- },
807
- regex: {
808
- color: "#d16969"
809
- },
810
- important: {
811
- color: "#569cd6"
812
- },
813
- italic: {
814
- fontStyle: "italic"
815
- },
816
- "class-name": {
817
- color: "#4ec9b0"
818
- },
819
- "maybe-class-name": {
820
- color: "#4ec9b0"
821
- },
822
- console: {
823
- color: "#9cdcfe"
824
- },
825
- parameter: {
826
- color: "#9cdcfe"
827
- },
828
- interpolation: {
829
- color: "#9cdcfe"
830
- },
831
- "punctuation.interpolation-punctuation": {
832
- color: "#569cd6"
833
- },
834
- variable: {
835
- color: "#9cdcfe"
836
- },
837
- "imports.maybe-class-name": {
838
- color: "#9cdcfe"
839
- },
840
- "exports.maybe-class-name": {
841
- color: "#9cdcfe"
842
- },
843
- escape: {
844
- color: "#d7ba7d"
845
- },
846
- "tag.punctuation": {
847
- color: "#808080"
848
- },
849
- cdata: {
850
- color: "#808080"
851
- },
852
- "attr-value": {
853
- color: "#ce9178"
854
- },
855
- "attr-value.punctuation": {
856
- color: "#ce9178"
857
- },
858
- "attr-value.punctuation.attr-equals": {
859
- color: "#d4d4d4"
860
- },
861
- namespace: {
862
- color: "#4ec9b0"
863
- },
864
- 'pre[class*="language-javascript"]': {
865
- color: "#9cdcfe"
866
- },
867
- 'code[class*="language-javascript"]': {
868
- color: "#9cdcfe"
869
- },
870
- 'pre[class*="language-jsx"]': {
871
- color: "#9cdcfe"
872
- },
873
- 'code[class*="language-jsx"]': {
874
- color: "#9cdcfe"
875
- },
876
- 'pre[class*="language-typescript"]': {
877
- color: "#9cdcfe"
878
- },
879
- 'code[class*="language-typescript"]': {
880
- color: "#9cdcfe"
881
- },
882
- 'pre[class*="language-tsx"]': {
883
- color: "#9cdcfe"
884
- },
885
- 'code[class*="language-tsx"]': {
886
- color: "#9cdcfe"
887
- },
888
- 'pre[class*="language-css"]': {
889
- color: "#ce9178"
890
- },
891
- 'code[class*="language-css"]': {
892
- color: "#ce9178"
893
- },
894
- 'pre[class*="language-html"]': {
895
- color: "#d4d4d4"
896
- },
897
- 'code[class*="language-html"]': {
898
- color: "#d4d4d4"
899
- },
900
- ".language-regex .token.anchor": {
901
- color: "#dcdcaa"
902
- },
903
- ".language-html .token.punctuation": {
904
- color: "#808080"
905
- },
906
- 'pre[class*="language-"] > code[class*="language-"]': {
907
- position: "relative",
908
- zIndex: "1"
909
- },
910
- ".line-highlight.line-highlight": {
911
- background: "#f7ebc6",
912
- boxShadow: "inset 5px 0 0 #f7d87c",
913
- zIndex: "0"
914
- }
915
- };
916
-
917
- // src/components/chat/Markdown.tsx
918
- var import_remark_gfm = __toESM(require("remark-gfm"));
919
- var import_remark_math = __toESM(require("remark-math"));
920
- var import_rehype_raw = __toESM(require("rehype-raw"));
921
- var import_jsx_runtime5 = require("react/jsx-runtime");
922
- var defaultComponents = {
923
- a(_a) {
924
- var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
925
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
926
- "a",
927
- __spreadProps(__spreadValues({
928
- className: "copilotKitMarkdownElement"
929
- }, props), {
930
- target: "_blank",
931
- rel: "noopener noreferrer",
932
- children
933
- })
934
- );
935
- },
936
- // @ts-expect-error -- inline
937
- code(_c) {
938
- var _d = _c, { children, className, inline } = _d, props = __objRest(_d, ["children", "className", "inline"]);
939
- if (Array.isArray(children) && children.length) {
940
- if (children[0] == "\u258D") {
941
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
942
- "span",
943
- {
944
- style: {
945
- animation: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",
946
- marginTop: "0.25rem"
947
- },
948
- children: "\u258D"
949
- }
950
- );
951
- }
952
- children[0] = (children == null ? void 0 : children[0]).replace("`\u258D`", "\u258D");
953
- }
954
- const match = /language-(\w+)/.exec(className || "");
955
- const hasLanguage = match && match[1];
956
- const content = String(children);
957
- const hasNewlines = content.includes("\n");
958
- const isInline = !hasLanguage && !hasNewlines;
959
- if (isInline) {
960
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
961
- "code",
962
- __spreadProps(__spreadValues({
963
- className: `copilotKitMarkdownElement copilotKitInlineCode ${className || ""}`
964
- }, props), {
965
- children
966
- })
967
- );
968
- }
969
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
970
- CodeBlock,
971
- __spreadValues({
972
- language: match && match[1] || "",
973
- value: String(children).replace(/\n$/, "")
974
- }, props),
975
- Math.random()
976
- );
977
- },
978
- h1: (_e) => {
979
- var _f = _e, { children } = _f, props = __objRest(_f, ["children"]);
980
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h1", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
981
- },
982
- h2: (_g) => {
983
- var _h = _g, { children } = _h, props = __objRest(_h, ["children"]);
984
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h2", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
985
- },
986
- h3: (_i) => {
987
- var _j = _i, { children } = _j, props = __objRest(_j, ["children"]);
988
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h3", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
989
- },
990
- h4: (_k) => {
991
- var _l = _k, { children } = _l, props = __objRest(_l, ["children"]);
992
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h4", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
993
- },
994
- h5: (_m) => {
995
- var _n = _m, { children } = _n, props = __objRest(_n, ["children"]);
996
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h5", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
997
- },
998
- h6: (_o) => {
999
- var _p = _o, { children } = _p, props = __objRest(_p, ["children"]);
1000
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h6", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1001
- },
1002
- p: (_q) => {
1003
- var _r = _q, { children } = _r, props = __objRest(_r, ["children"]);
1004
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1005
- },
1006
- pre: (_s) => {
1007
- var _t = _s, { children } = _t, props = __objRest(_t, ["children"]);
1008
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("pre", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1009
- },
1010
- blockquote: (_u) => {
1011
- var _v = _u, { children } = _v, props = __objRest(_v, ["children"]);
1012
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("blockquote", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1013
- },
1014
- ul: (_w) => {
1015
- var _x = _w, { children } = _x, props = __objRest(_x, ["children"]);
1016
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("ul", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1017
- },
1018
- li: (_y) => {
1019
- var _z = _y, { children } = _z, props = __objRest(_z, ["children"]);
1020
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1021
- }
1022
- };
1023
- var MemoizedReactMarkdown = (0, import_react3.memo)(
1024
- import_react_markdown.default,
1025
- (prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.components === nextProps.components
1026
- );
1027
- var Markdown = ({ content, components }) => {
1028
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "copilotKitMarkdown", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1029
- MemoizedReactMarkdown,
1030
- {
1031
- components: __spreadValues(__spreadValues({}, defaultComponents), components),
1032
- remarkPlugins: [
1033
- import_remark_gfm.default,
1034
- [import_remark_math.default, { singleDollarTextMath: false }]
1035
- ],
1036
- rehypePlugins: [import_rehype_raw.default],
1037
- children: content
1038
- }
1039
- ) });
1040
- };
1041
-
1042
- // src/components/chat/messages/AssistantMessage.tsx
1043
- var import_react4 = require("react");
1044
- var import_jsx_runtime6 = require("react/jsx-runtime");
1045
- var AssistantMessage = (props) => {
1046
- var _a, _b, _c;
1047
- const { icons, labels } = useChatContext();
1048
- const {
1049
- message,
1050
- isLoading,
1051
- onRegenerate,
1052
- onCopy,
1053
- onThumbsUp,
1054
- onThumbsDown,
1055
- isCurrentMessage,
1056
- feedback,
1057
- markdownTagRenderers
1058
- } = props;
1059
- const [copied, setCopied] = (0, import_react4.useState)(false);
1060
- const handleCopy = () => {
1061
- const content2 = (message == null ? void 0 : message.content) || "";
1062
- if (content2 && onCopy) {
1063
- navigator.clipboard.writeText(content2);
1064
- setCopied(true);
1065
- onCopy(content2);
1066
- setTimeout(() => setCopied(false), 2e3);
1067
- } else if (content2) {
1068
- navigator.clipboard.writeText(content2);
1069
- setCopied(true);
1070
- setTimeout(() => setCopied(false), 2e3);
1071
- }
1072
- };
1073
- const handleRegenerate = () => {
1074
- if (onRegenerate)
1075
- onRegenerate();
1076
- };
1077
- const handleThumbsUp = () => {
1078
- if (onThumbsUp && message) {
1079
- onThumbsUp(message);
1080
- }
1081
- };
1082
- const handleThumbsDown = () => {
1083
- if (onThumbsDown && message) {
1084
- onThumbsDown(message);
1085
- }
1086
- };
1087
- const LoadingIcon = () => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: icons.activityIcon });
1088
- const content = (message == null ? void 0 : message.content) || "";
1089
- const subComponent = (_b = (_a = message == null ? void 0 : message.generativeUI) == null ? void 0 : _a.call(message)) != null ? _b : props.subComponent;
1090
- const subComponentPosition = (_c = message == null ? void 0 : message.generativeUIPosition) != null ? _c : "after";
1091
- const renderBefore = subComponent && subComponentPosition === "before";
1092
- const renderAfter = subComponent && subComponentPosition !== "before";
1093
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
1094
- renderBefore ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { marginBottom: "0.5rem" }, children: subComponent }) : null,
1095
- content && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "copilotKitMessage copilotKitAssistantMessage", children: [
1096
- content && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Markdown, { content, components: markdownTagRenderers }),
1097
- content && !isLoading && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1098
- "div",
1099
- {
1100
- className: `copilotKitMessageControls ${isCurrentMessage ? "currentMessage" : ""}`,
1101
- children: [
1102
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1103
- "button",
1104
- {
1105
- className: "copilotKitMessageControlButton",
1106
- onClick: handleRegenerate,
1107
- "aria-label": labels.regenerateResponse,
1108
- title: labels.regenerateResponse,
1109
- children: icons.regenerateIcon
1110
- }
1111
- ),
1112
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1113
- "button",
1114
- {
1115
- className: "copilotKitMessageControlButton",
1116
- onClick: handleCopy,
1117
- "aria-label": labels.copyToClipboard,
1118
- title: labels.copyToClipboard,
1119
- children: copied ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: { fontSize: "10px", fontWeight: "bold" }, children: "\u2713" }) : icons.copyIcon
1120
- }
1121
- ),
1122
- onThumbsUp && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1123
- "button",
1124
- {
1125
- className: `copilotKitMessageControlButton ${feedback === "thumbsUp" ? "active" : ""}`,
1126
- onClick: handleThumbsUp,
1127
- "aria-label": labels.thumbsUp,
1128
- title: labels.thumbsUp,
1129
- children: icons.thumbsUpIcon
1130
- }
1131
- ),
1132
- onThumbsDown && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1133
- "button",
1134
- {
1135
- className: `copilotKitMessageControlButton ${feedback === "thumbsDown" ? "active" : ""}`,
1136
- onClick: handleThumbsDown,
1137
- "aria-label": labels.thumbsDown,
1138
- title: labels.thumbsDown,
1139
- children: icons.thumbsDownIcon
1140
- }
1141
- )
1142
- ]
1143
- }
1144
- )
1145
- ] }),
1146
- renderAfter ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { marginBottom: "0.5rem" }, children: subComponent }) : null,
1147
- isLoading && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(LoadingIcon, {})
1148
- ] });
1149
- };
1150
-
1151
- // src/components/chat/messages/ImageRenderer.tsx
1152
- var import_react5 = require("react");
1153
- var import_jsx_runtime7 = require("react/jsx-runtime");
1154
- var ImageRenderer = ({
1155
- image,
1156
- content,
1157
- className = ""
1158
- }) => {
1159
- const [imageError, setImageError] = (0, import_react5.useState)(false);
1160
- const imageSrc = `data:image/${image.format};base64,${image.bytes}`;
1161
- const altText = content || "User uploaded image";
1162
- const handleImageError = () => {
1163
- setImageError(true);
1164
- };
1165
- if (imageError) {
1166
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1167
- "div",
1168
- {
1169
- className: `copilotKitImageRendering copilotKitImageRenderingError ${className}`,
1170
- children: [
1171
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "copilotKitImageRenderingErrorMessage", children: "Failed to load image" }),
1172
- content && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "copilotKitImageRenderingContent", children: content })
1173
- ]
1174
- }
1175
- );
1176
- }
1177
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: `copilotKitImageRendering ${className}`, children: [
1178
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1179
- "img",
1180
- {
1181
- src: imageSrc,
1182
- alt: altText,
1183
- className: "copilotKitImageRenderingImage",
1184
- onError: handleImageError
1185
- }
1186
- ),
1187
- content && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "copilotKitImageRenderingContent", children: content })
1188
- ] });
1189
- };
1190
-
1191
- // src/components/chat/messages/RenderMessage.tsx
1192
- var import_jsx_runtime8 = require("react/jsx-runtime");
1193
- function RenderMessage(_a) {
1194
- var _b = _a, {
1195
- UserMessage: UserMessage2 = UserMessage,
1196
- AssistantMessage: AssistantMessage2 = AssistantMessage,
1197
- ImageRenderer: ImageRenderer2 = ImageRenderer
1198
- } = _b, props = __objRest(_b, [
1199
- "UserMessage",
1200
- "AssistantMessage",
1201
- "ImageRenderer"
1202
- ]);
1203
- var _a2;
1204
- const {
1205
- message,
1206
- messages,
1207
- inProgress,
1208
- index,
1209
- isCurrentMessage,
1210
- onRegenerate,
1211
- onCopy,
1212
- onThumbsUp,
1213
- onThumbsDown,
1214
- messageFeedback,
1215
- markdownTagRenderers
1216
- } = props;
1217
- switch (message.role) {
1218
- case "user":
1219
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1220
- UserMessage2,
1221
- {
1222
- rawData: message,
1223
- "data-message-role": "user",
1224
- message,
1225
- ImageRenderer: ImageRenderer2
1226
- },
1227
- index
1228
- );
1229
- case "assistant":
1230
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1231
- AssistantMessage2,
1232
- {
1233
- "data-message-role": "assistant",
1234
- subComponent: (_a2 = message.generativeUI) == null ? void 0 : _a2.call(message),
1235
- rawData: message,
1236
- message,
1237
- messages,
1238
- isLoading: inProgress && isCurrentMessage && !message.content,
1239
- isGenerating: inProgress && isCurrentMessage && !!message.content,
1240
- isCurrentMessage,
1241
- onRegenerate: () => onRegenerate == null ? void 0 : onRegenerate(message.id),
1242
- onCopy,
1243
- onThumbsUp,
1244
- onThumbsDown,
1245
- feedback: (messageFeedback == null ? void 0 : messageFeedback[message.id]) || null,
1246
- markdownTagRenderers,
1247
- ImageRenderer: ImageRenderer2
1248
- },
1249
- index
1250
- );
1251
- default:
1252
- return null;
1253
- }
1254
- }
1255
-
1256
- // src/components/chat/messages/LegacyRenderMessage.tsx
1257
- var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
1258
- var import_jsx_runtime9 = require("react/jsx-runtime");
1259
- var LegacyRenderMessage = ({
1260
- message,
1261
- messages,
1262
- inProgress,
1263
- index,
1264
- isCurrentMessage,
1265
- actionResult,
1266
- AssistantMessage: AssistantMessage2,
1267
- UserMessage: UserMessage2,
1268
- ImageRenderer: ImageRenderer2,
1269
- onRegenerate,
1270
- onCopy,
1271
- onThumbsUp,
1272
- onThumbsDown,
1273
- markdownTagRenderers,
1274
- legacyProps
1275
- }) => {
1276
- var _a;
1277
- const {
1278
- RenderTextMessage,
1279
- RenderActionExecutionMessage,
1280
- RenderAgentStateMessage,
1281
- RenderResultMessage,
1282
- RenderImageMessage
1283
- } = legacyProps;
1284
- const deprecatedMessage = (_a = (0, import_runtime_client_gql.aguiToGQL)(message)[0]) != null ? _a : void 0;
1285
- if (deprecatedMessage.isTextMessage() && RenderTextMessage) {
1286
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1287
- RenderTextMessage,
1288
- {
1289
- message,
1290
- messages,
1291
- inProgress,
1292
- index,
1293
- isCurrentMessage,
1294
- AssistantMessage: AssistantMessage2,
1295
- UserMessage: UserMessage2,
1296
- onRegenerate,
1297
- onCopy,
1298
- onThumbsUp,
1299
- onThumbsDown,
1300
- markdownTagRenderers
1301
- }
1302
- );
1303
- }
1304
- if (deprecatedMessage.isActionExecutionMessage() && RenderActionExecutionMessage) {
1305
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1306
- RenderActionExecutionMessage,
1307
- {
1308
- messages,
1309
- message,
1310
- inProgress,
1311
- index,
1312
- isCurrentMessage,
1313
- actionResult,
1314
- AssistantMessage: AssistantMessage2,
1315
- UserMessage: UserMessage2
1316
- }
1317
- );
1318
- }
1319
- if (deprecatedMessage.isAgentStateMessage() && RenderAgentStateMessage) {
1320
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1321
- RenderAgentStateMessage,
1322
- {
1323
- messages,
1324
- message,
1325
- inProgress,
1326
- index,
1327
- isCurrentMessage,
1328
- AssistantMessage: AssistantMessage2,
1329
- UserMessage: UserMessage2
1330
- }
1331
- );
1332
- }
1333
- if (deprecatedMessage.isResultMessage() && RenderResultMessage) {
1334
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1335
- RenderResultMessage,
1336
- {
1337
- messages,
1338
- message,
1339
- inProgress,
1340
- index,
1341
- isCurrentMessage,
1342
- AssistantMessage: AssistantMessage2,
1343
- UserMessage: UserMessage2
1344
- }
1345
- );
1346
- }
1347
- if (deprecatedMessage.isImageMessage() && RenderImageMessage) {
1348
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1349
- RenderImageMessage,
1350
- {
1351
- messages,
1352
- message,
1353
- inProgress,
1354
- index,
1355
- isCurrentMessage,
1356
- AssistantMessage: AssistantMessage2,
1357
- UserMessage: UserMessage2
1358
- }
1359
- );
1360
- }
1361
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1362
- RenderMessage,
1363
- {
1364
- messages,
1365
- message,
1366
- inProgress,
1367
- index,
1368
- isCurrentMessage,
1369
- AssistantMessage: AssistantMessage2,
1370
- UserMessage: UserMessage2,
1371
- ImageRenderer: ImageRenderer2,
1372
- onRegenerate,
1373
- onCopy,
1374
- onThumbsUp,
1375
- onThumbsDown,
1376
- markdownTagRenderers
1377
- }
1378
- );
1379
- };
1380
-
1381
- // src/components/chat/Messages.tsx
1382
- var import_jsx_runtime10 = require("react/jsx-runtime");
1383
- var Messages = ({
1384
- inProgress,
1385
- children,
1386
- RenderMessage: RenderMessage2,
1387
- AssistantMessage: AssistantMessage2,
1388
- UserMessage: UserMessage2,
1389
- ErrorMessage,
1390
- ImageRenderer: ImageRenderer2,
1391
- onRegenerate,
1392
- onCopy,
1393
- onThumbsUp,
1394
- onThumbsDown,
1395
- messageFeedback,
1396
- markdownTagRenderers,
1397
- chatError,
1398
- // Legacy props
1399
- RenderTextMessage,
1400
- RenderActionExecutionMessage,
1401
- RenderAgentStateMessage,
1402
- RenderResultMessage,
1403
- RenderImageMessage
1404
- }) => {
1405
- var _a;
1406
- const { labels, icons } = useChatContext();
1407
- const { messages: visibleMessages, interrupt } = (0, import_react_core.useCopilotChatInternal)();
1408
- const initialMessages = (0, import_react6.useMemo)(
1409
- () => makeInitialMessages(labels.initial),
1410
- [labels.initial]
1411
- );
1412
- const messages = [...initialMessages, ...visibleMessages];
1413
- const { messagesContainerRef, messagesEndRef } = useScrollToBottom(messages);
1414
- const hasLegacyProps = !!(RenderTextMessage || RenderActionExecutionMessage || RenderAgentStateMessage || RenderResultMessage || RenderImageMessage);
1415
- (0, import_react6.useEffect)(() => {
1416
- if (hasLegacyProps) {
1417
- console.warn(
1418
- "[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"
1419
- );
1420
- }
1421
- }, [hasLegacyProps]);
1422
- const legacyProps = (0, import_react6.useMemo)(
1423
- () => ({
1424
- RenderTextMessage,
1425
- RenderActionExecutionMessage,
1426
- RenderAgentStateMessage,
1427
- RenderResultMessage,
1428
- RenderImageMessage
1429
- }),
1430
- [
1431
- RenderTextMessage,
1432
- RenderActionExecutionMessage,
1433
- RenderAgentStateMessage,
1434
- RenderResultMessage,
1435
- RenderImageMessage
1436
- ]
1437
- );
1438
- const MessageRenderer = hasLegacyProps ? (props) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(LegacyRenderMessage, __spreadProps(__spreadValues({}, props), { legacyProps })) : RenderMessage2;
1439
- const LoadingIcon = () => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children: icons.activityIcon });
1440
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "copilotKitMessages", ref: messagesContainerRef, children: [
1441
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "copilotKitMessagesContainer", children: [
1442
- messages.map((message, index) => {
1443
- const isCurrentMessage = index === messages.length - 1;
1444
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1445
- MessageRenderer,
1446
- {
1447
- message,
1448
- messages,
1449
- inProgress,
1450
- index,
1451
- isCurrentMessage,
1452
- AssistantMessage: AssistantMessage2,
1453
- UserMessage: UserMessage2,
1454
- ImageRenderer: ImageRenderer2,
1455
- onRegenerate,
1456
- onCopy,
1457
- onThumbsUp,
1458
- onThumbsDown,
1459
- messageFeedback,
1460
- markdownTagRenderers
1461
- },
1462
- index
1463
- );
1464
- }),
1465
- ((_a = messages[messages.length - 1]) == null ? void 0 : _a.role) === "user" && inProgress && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(LoadingIcon, {}),
1466
- interrupt,
1467
- chatError && ErrorMessage && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ErrorMessage, { error: chatError, isCurrentMessage: true })
1468
- ] }),
1469
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("footer", { className: "copilotKitMessagesFooter", ref: messagesEndRef, children })
1470
- ] });
1471
- };
1472
- function makeInitialMessages(initial) {
1473
- if (!initial)
1474
- return [];
1475
- if (Array.isArray(initial)) {
1476
- return initial.map((message) => {
1477
- return {
1478
- id: message,
1479
- role: "assistant",
1480
- content: message
1481
- };
1482
- });
1483
- }
1484
- return [
1485
- {
1486
- id: initial,
1487
- role: "assistant",
1488
- content: initial
1489
- }
1490
- ];
1491
- }
1492
- function useScrollToBottom(messages) {
1493
- const messagesEndRef = (0, import_react6.useRef)(null);
1494
- const messagesContainerRef = (0, import_react6.useRef)(null);
1495
- const isProgrammaticScrollRef = (0, import_react6.useRef)(false);
1496
- const isUserScrollUpRef = (0, import_react6.useRef)(false);
1497
- const scrollToBottom = () => {
1498
- if (messagesContainerRef.current && messagesEndRef.current) {
1499
- isProgrammaticScrollRef.current = true;
1500
- messagesContainerRef.current.scrollTop = messagesContainerRef.current.scrollHeight;
1501
- }
1502
- };
1503
- const handleScroll = () => {
1504
- if (isProgrammaticScrollRef.current) {
1505
- isProgrammaticScrollRef.current = false;
1506
- return;
1507
- }
1508
- if (messagesContainerRef.current) {
1509
- const { scrollTop, scrollHeight, clientHeight } = messagesContainerRef.current;
1510
- isUserScrollUpRef.current = scrollTop + clientHeight < scrollHeight;
1511
- }
1512
- };
1513
- (0, import_react6.useEffect)(() => {
1514
- const container = messagesContainerRef.current;
1515
- if (container) {
1516
- container.addEventListener("scroll", handleScroll);
1517
- }
1518
- return () => {
1519
- if (container) {
1520
- container.removeEventListener("scroll", handleScroll);
1521
- }
1522
- };
1523
- }, []);
1524
- (0, import_react6.useEffect)(() => {
1525
- const container = messagesContainerRef.current;
1526
- if (!container) {
1527
- return;
1528
- }
1529
- const mutationObserver = new MutationObserver(() => {
1530
- if (!isUserScrollUpRef.current) {
1531
- scrollToBottom();
1532
- }
1533
- });
1534
- mutationObserver.observe(container, {
1535
- childList: true,
1536
- subtree: true,
1537
- characterData: true
1538
- });
1539
- return () => {
1540
- mutationObserver.disconnect();
1541
- };
1542
- }, []);
1543
- (0, import_react6.useEffect)(() => {
1544
- isUserScrollUpRef.current = false;
1545
- scrollToBottom();
1546
- }, [messages.filter((m) => m.role === "user").length]);
1547
- return { messagesEndRef, messagesContainerRef };
1548
- }
1549
-
1550
- // src/components/chat/Input.tsx
1551
- var import_react10 = require("react");
1552
-
1553
- // src/components/chat/Textarea.tsx
1554
- var import_react7 = require("react");
1555
- var import_jsx_runtime11 = require("react/jsx-runtime");
1556
- var AutoResizingTextarea = (0, import_react7.forwardRef)(
1557
- ({
1558
- maxRows = 1,
1559
- placeholder,
1560
- value,
1561
- onChange,
1562
- onKeyDown,
1563
- onCompositionStart,
1564
- onCompositionEnd,
1565
- autoFocus
1566
- }, ref) => {
1567
- const internalTextareaRef = (0, import_react7.useRef)(null);
1568
- const [maxHeight, setMaxHeight] = (0, import_react7.useState)(0);
1569
- (0, import_react7.useImperativeHandle)(
1570
- ref,
1571
- () => internalTextareaRef.current
1572
- );
1573
- (0, import_react7.useEffect)(() => {
1574
- const calculateMaxHeight = () => {
1575
- const textarea = internalTextareaRef.current;
1576
- if (textarea) {
1577
- textarea.style.height = "auto";
1578
- const singleRowHeight = textarea.scrollHeight;
1579
- setMaxHeight(singleRowHeight * maxRows);
1580
- if (autoFocus) {
1581
- textarea.focus();
1582
- }
1583
- }
1584
- };
1585
- calculateMaxHeight();
1586
- }, [maxRows]);
1587
- (0, import_react7.useEffect)(() => {
1588
- const textarea = internalTextareaRef.current;
1589
- if (textarea) {
1590
- textarea.style.height = "auto";
1591
- textarea.style.height = `${Math.min(textarea.scrollHeight, maxHeight)}px`;
1592
- }
1593
- }, [value, maxHeight]);
1594
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1595
- "textarea",
1596
- {
1597
- ref: internalTextareaRef,
1598
- value,
1599
- onChange,
1600
- onKeyDown,
1601
- onCompositionStart,
1602
- onCompositionEnd,
1603
- placeholder,
1604
- style: {
1605
- overflow: "auto",
1606
- resize: "none",
1607
- maxHeight: `${maxHeight}px`
1608
- },
1609
- rows: 1
1610
- }
1611
- );
1612
- }
1613
- );
1614
- var Textarea_default = AutoResizingTextarea;
1615
-
1616
- // src/hooks/use-push-to-talk.tsx
1617
- var import_react_core2 = require("@copilotkit/react-core");
1618
- var import_runtime_client_gql2 = require("@copilotkit/runtime-client-gql");
1619
- var import_react8 = require("react");
1620
- var startRecording = (mediaStreamRef, mediaRecorderRef, audioContextRef, recordedChunks, onStop) => __async(void 0, null, function* () {
1621
- if (!mediaStreamRef.current || !audioContextRef.current) {
1622
- mediaStreamRef.current = yield navigator.mediaDevices.getUserMedia({
1623
- audio: true
1624
- });
1625
- audioContextRef.current = new window.AudioContext();
1626
- yield audioContextRef.current.resume();
1627
- }
1628
- mediaRecorderRef.current = new MediaRecorder(mediaStreamRef.current);
1629
- mediaRecorderRef.current.start(1e3);
1630
- mediaRecorderRef.current.ondataavailable = (event) => {
1631
- recordedChunks.push(event.data);
1632
- };
1633
- mediaRecorderRef.current.onstop = onStop;
1634
- });
1635
- var stopRecording = (mediaRecorderRef) => {
1636
- if (mediaRecorderRef.current && mediaRecorderRef.current.state !== "inactive") {
1637
- mediaRecorderRef.current.stop();
1638
- }
1639
- };
1640
- var transcribeAudio = (recordedChunks, transcribeAudioUrl) => __async(void 0, null, function* () {
1641
- const completeBlob = new Blob(recordedChunks, { type: "audio/mp4" });
1642
- const formData = new FormData();
1643
- formData.append("file", completeBlob, "recording.mp4");
1644
- const response = yield fetch(transcribeAudioUrl, {
1645
- method: "POST",
1646
- body: formData
1647
- });
1648
- if (!response.ok) {
1649
- throw new Error(`Error: ${response.statusText}`);
1650
- }
1651
- const transcription = yield response.json();
1652
- return transcription.text;
1653
- });
1654
- var playAudioResponse = (text, textToSpeechUrl, audioContext) => {
1655
- const encodedText = encodeURIComponent(text);
1656
- const url = `${textToSpeechUrl}?text=${encodedText}`;
1657
- fetch(url).then((response) => response.arrayBuffer()).then((arrayBuffer) => audioContext.decodeAudioData(arrayBuffer)).then((audioBuffer) => {
1658
- const source = audioContext.createBufferSource();
1659
- source.buffer = audioBuffer;
1660
- source.connect(audioContext.destination);
1661
- source.start(0);
1662
- }).catch((error) => {
1663
- console.error("Error with decoding audio data", error);
1664
- });
1665
- };
1666
- var usePushToTalk = ({
1667
- sendFunction,
1668
- inProgress
1669
- }) => {
1670
- const [pushToTalkState, setPushToTalkState] = (0, import_react8.useState)("idle");
1671
- const mediaStreamRef = (0, import_react8.useRef)(null);
1672
- const audioContextRef = (0, import_react8.useRef)(null);
1673
- const mediaRecorderRef = (0, import_react8.useRef)(null);
1674
- const recordedChunks = (0, import_react8.useRef)([]);
1675
- const generalContext = (0, import_react_core2.useCopilotContext)();
1676
- const messagesContext = (0, import_react_core2.useCopilotMessagesContext)();
1677
- const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
1678
- const [startReadingFromMessageId, setStartReadingFromMessageId] = (0, import_react8.useState)(null);
1679
- (0, import_react8.useEffect)(() => {
1680
- if (pushToTalkState === "recording") {
1681
- startRecording(
1682
- mediaStreamRef,
1683
- mediaRecorderRef,
1684
- audioContextRef,
1685
- recordedChunks.current,
1686
- () => {
1687
- setPushToTalkState("transcribing");
1688
- }
1689
- );
1690
- } else {
1691
- stopRecording(mediaRecorderRef);
1692
- if (pushToTalkState === "transcribing") {
1693
- transcribeAudio(
1694
- recordedChunks.current,
1695
- context.copilotApiConfig.transcribeAudioUrl
1696
- ).then((transcription) => __async(void 0, null, function* () {
1697
- recordedChunks.current = [];
1698
- setPushToTalkState("idle");
1699
- const message = yield sendFunction(transcription);
1700
- setStartReadingFromMessageId(message.id);
1701
- }));
1702
- }
1703
- }
1704
- return () => {
1705
- stopRecording(mediaRecorderRef);
1706
- };
1707
- }, [pushToTalkState]);
1708
- (0, import_react8.useEffect)(() => {
1709
- if (inProgress === false && startReadingFromMessageId) {
1710
- const lastMessageIndex = context.messages.findIndex(
1711
- (message) => message.id === startReadingFromMessageId
1712
- );
1713
- const aguiMessages = (0, import_runtime_client_gql2.gqlToAGUI)(context.messages);
1714
- const messagesAfterLast = aguiMessages.slice(lastMessageIndex + 1).filter((message) => message.role === "assistant");
1715
- const text = messagesAfterLast.map((message) => message.content).join("\n");
1716
- playAudioResponse(
1717
- text,
1718
- context.copilotApiConfig.textToSpeechUrl,
1719
- audioContextRef.current
1720
- );
1721
- setStartReadingFromMessageId(null);
1722
- }
1723
- }, [startReadingFromMessageId, inProgress]);
1724
- return { pushToTalkState, setPushToTalkState };
1725
- };
1726
-
1727
- // src/components/chat/Input.tsx
1728
- var import_react_core3 = require("@copilotkit/react-core");
1729
-
1730
- // src/components/chat/PoweredByTag.tsx
1731
- var import_react9 = require("react");
1732
-
1733
- // src/hooks/use-dark-mode.ts
1734
- var useDarkMode = () => {
1735
- if (typeof window === "undefined")
1736
- return false;
1737
- 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;
1738
- };
1739
-
1740
- // src/components/chat/PoweredByTag.tsx
1741
- var import_jsx_runtime12 = require("react/jsx-runtime");
1742
- function PoweredByTag({
1743
- showPoweredBy = true
1744
- }) {
1745
- const [mounted, setMounted] = (0, import_react9.useState)(false);
1746
- const isDark = useDarkMode();
1747
- (0, import_react9.useEffect)(() => {
1748
- setMounted(true);
1749
- }, []);
1750
- if (!showPoweredBy) {
1751
- return null;
1752
- }
1753
- const poweredByStyle = {
1754
- visibility: "visible",
1755
- display: "block",
1756
- position: "static",
1757
- textAlign: "center",
1758
- fontSize: "12px",
1759
- padding: "3px 0",
1760
- color: mounted && isDark ? "rgb(69, 69, 69)" : "rgb(214, 214, 214)"
1761
- };
1762
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "poweredBy", style: poweredByStyle, children: "Powered by CopilotKit" }) });
1763
- }
1764
-
1765
- // src/components/chat/Input.tsx
1766
- var import_jsx_runtime13 = require("react/jsx-runtime");
1767
- var MAX_NEWLINES = 6;
1768
- var Input = ({
1769
- inProgress,
1770
- onSend,
1771
- chatReady = false,
1772
- onStop,
1773
- onUpload,
1774
- hideStopButton = false
1775
- }) => {
1776
- var _a;
1777
- const context = useChatContext();
1778
- const copilotContext = (0, import_react_core3.useCopilotContext)();
1779
- const showPoweredBy = !((_a = copilotContext.copilotApiConfig) == null ? void 0 : _a.publicApiKey);
1780
- const pushToTalkConfigured = copilotContext.copilotApiConfig.textToSpeechUrl !== void 0 && copilotContext.copilotApiConfig.transcribeAudioUrl !== void 0;
1781
- const textareaRef = (0, import_react10.useRef)(null);
1782
- const [isComposing, setIsComposing] = (0, import_react10.useState)(false);
1783
- const handleDivClick = (event) => {
1784
- var _a2;
1785
- const target = event.target;
1786
- if (target.closest("button"))
1787
- return;
1788
- if (target.tagName === "TEXTAREA")
1789
- return;
1790
- (_a2 = textareaRef.current) == null ? void 0 : _a2.focus();
1791
- };
1792
- const [text, setText] = (0, import_react10.useState)("");
1793
- const send = () => {
1794
- var _a2;
1795
- if (inProgress)
1796
- return;
1797
- onSend(text);
1798
- setText("");
1799
- (_a2 = textareaRef.current) == null ? void 0 : _a2.focus();
1800
- };
1801
- const { pushToTalkState, setPushToTalkState } = usePushToTalk({
1802
- sendFunction: onSend,
1803
- inProgress
1804
- });
1805
- const isInProgress = inProgress || pushToTalkState === "transcribing";
1806
- const { buttonIcon, buttonAlt } = (0, import_react10.useMemo)(() => {
1807
- if (!chatReady)
1808
- return { buttonIcon: context.icons.spinnerIcon, buttonAlt: "Loading" };
1809
- return isInProgress && !hideStopButton && chatReady ? { buttonIcon: context.icons.stopIcon, buttonAlt: "Stop" } : { buttonIcon: context.icons.sendIcon, buttonAlt: "Send" };
1810
- }, [
1811
- isInProgress,
1812
- chatReady,
1813
- hideStopButton,
1814
- context.icons.stopIcon,
1815
- context.icons.sendIcon
1816
- ]);
1817
- const showPushToTalk = pushToTalkConfigured && (pushToTalkState === "idle" || pushToTalkState === "recording") && !inProgress;
1818
- const { interrupt } = (0, import_react_core3.useCopilotChatInternal)();
1819
- const canSend = (0, import_react10.useMemo)(() => {
1820
- return !isInProgress && text.trim().length > 0 && pushToTalkState === "idle" && !interrupt;
1821
- }, [interrupt, isInProgress, text, pushToTalkState]);
1822
- const canStop = (0, import_react10.useMemo)(() => {
1823
- return isInProgress && !hideStopButton;
1824
- }, [isInProgress, hideStopButton]);
1825
- const sendDisabled = !canSend && !canStop;
1826
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1827
- "div",
1828
- {
1829
- className: `copilotKitInputContainer ${showPoweredBy ? "poweredByContainer" : ""}`,
1830
- children: [
1831
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "copilotKitInput", onClick: handleDivClick, children: [
1832
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1833
- Textarea_default,
1834
- {
1835
- ref: textareaRef,
1836
- placeholder: context.labels.placeholder,
1837
- autoFocus: false,
1838
- maxRows: MAX_NEWLINES,
1839
- value: text,
1840
- onChange: (event) => setText(event.target.value),
1841
- onCompositionStart: () => setIsComposing(true),
1842
- onCompositionEnd: () => setIsComposing(false),
1843
- onKeyDown: (event) => {
1844
- if (event.key === "Enter" && !event.shiftKey && !isComposing) {
1845
- event.preventDefault();
1846
- if (canSend) {
1847
- send();
1848
- }
1849
- }
1850
- }
1851
- }
1852
- ),
1853
- /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "copilotKitInputControls", children: [
1854
- onUpload && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", { onClick: onUpload, className: "copilotKitInputControlButton", children: context.icons.uploadIcon }),
1855
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { style: { flexGrow: 1 } }),
1856
- showPushToTalk && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1857
- "button",
1858
- {
1859
- onClick: () => setPushToTalkState(
1860
- pushToTalkState === "idle" ? "recording" : "transcribing"
1861
- ),
1862
- className: pushToTalkState === "recording" ? "copilotKitInputControlButton copilotKitPushToTalkRecording" : "copilotKitInputControlButton",
1863
- children: context.icons.pushToTalkIcon
1864
- }
1865
- ),
1866
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1867
- "button",
1868
- {
1869
- disabled: sendDisabled,
1870
- onClick: isInProgress && !hideStopButton ? onStop : send,
1871
- "data-copilotkit-in-progress": inProgress,
1872
- "data-test-id": inProgress ? "copilot-chat-request-in-progress" : "copilot-chat-ready",
1873
- className: "copilotKitInputControlButton",
1874
- "aria-label": buttonAlt,
1875
- children: buttonIcon
1876
- }
1877
- )
1878
- ] })
1879
- ] }),
1880
- /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(PoweredByTag, { showPoweredBy })
1881
- ]
1882
- }
1883
- );
1884
- };
1885
-
1886
- // src/components/chat/Chat.tsx
1887
- var import_react11 = __toESM(require("react"));
1888
- var import_react_core5 = require("@copilotkit/react-core");
1889
- var import_shared = require("@copilotkit/shared");
1890
-
1891
- // src/components/chat/ImageUploadQueue.tsx
1892
- var import_jsx_runtime14 = require("react/jsx-runtime");
1893
- var ImageUploadQueue = ({
1894
- images,
1895
- onRemoveImage,
1896
- className = ""
1897
- }) => {
1898
- if (images.length === 0)
1899
- return null;
1900
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1901
- "div",
1902
- {
1903
- className: `copilotKitImageUploadQueue ${className}`,
1904
- style: {
1905
- display: "flex",
1906
- flexWrap: "wrap",
1907
- gap: "8px",
1908
- margin: "8px",
1909
- padding: "8px"
1910
- },
1911
- children: images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
1912
- "div",
1913
- {
1914
- className: "copilotKitImageUploadQueueItem",
1915
- style: {
1916
- position: "relative",
1917
- display: "inline-block",
1918
- width: "60px",
1919
- height: "60px",
1920
- borderRadius: "4px",
1921
- overflow: "hidden"
1922
- },
1923
- children: [
1924
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1925
- "img",
1926
- {
1927
- src: `data:${image.contentType};base64,${image.bytes}`,
1928
- alt: `Selected image ${index + 1}`,
1929
- style: {
1930
- width: "100%",
1931
- height: "100%",
1932
- objectFit: "cover"
1933
- }
1934
- }
1935
- ),
1936
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1937
- "button",
1938
- {
1939
- onClick: () => onRemoveImage(index),
1940
- className: "copilotKitImageUploadQueueRemoveButton",
1941
- style: {
1942
- position: "absolute",
1943
- top: "2px",
1944
- right: "2px",
1945
- background: "rgba(0,0,0,0.6)",
1946
- color: "white",
1947
- border: "none",
1948
- borderRadius: "50%",
1949
- width: "18px",
1950
- height: "18px",
1951
- display: "flex",
1952
- alignItems: "center",
1953
- justifyContent: "center",
1954
- cursor: "pointer",
1955
- fontSize: "10px",
1956
- padding: 0
1957
- },
1958
- children: "\u2715"
1959
- }
1960
- )
1961
- ]
1962
- },
1963
- index
1964
- ))
1965
- }
1966
- );
1967
- };
1968
-
1969
- // src/components/chat/Suggestion.tsx
1970
- var import_react_core4 = require("@copilotkit/react-core");
1971
- var import_jsx_runtime15 = require("react/jsx-runtime");
1972
- function Suggestion({
1973
- title,
1974
- onClick,
1975
- partial,
1976
- className
1977
- }) {
1978
- const { isLoading } = (0, import_react_core4.useCopilotChatInternal)();
1979
- if (!title)
1980
- return null;
1981
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1982
- "button",
1983
- {
1984
- disabled: partial || isLoading,
1985
- onClick: (e) => {
1986
- e.preventDefault();
1987
- onClick();
1988
- },
1989
- className: `suggestion ${className != null ? className : ""} ${partial ? "loading" : ""}`,
1990
- "data-test-id": "suggestion",
1991
- type: "button",
1992
- children: partial ? SmallSpinnerIcon : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: title })
1993
- }
1994
- );
1995
- }
1996
-
1997
- // src/components/chat/Suggestions.tsx
1998
- var import_jsx_runtime16 = require("react/jsx-runtime");
1999
- function Suggestions({
2000
- suggestions,
2001
- onSuggestionClick,
2002
- isLoading
2003
- }) {
2004
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "suggestions", children: suggestions.map((suggestion, index) => {
2005
- var _a, _b;
2006
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2007
- Suggestion,
2008
- {
2009
- title: suggestion.title,
2010
- message: suggestion.message,
2011
- partial: (_b = (_a = suggestion.isLoading) != null ? _a : suggestion.partial) != null ? _b : isLoading,
2012
- className: suggestion.className,
2013
- onClick: () => onSuggestionClick(suggestion.message)
2014
- },
2015
- index
2016
- );
2017
- }) });
2018
- }
2019
-
2020
- // src/components/chat/Chat.tsx
2021
- var import_jsx_runtime17 = require("react/jsx-runtime");
2022
- function CopilotChat({
2023
- instructions,
2024
- suggestions = "auto",
2025
- onSubmitMessage,
2026
- makeSystemMessage,
2027
- disableSystemMessage,
2028
- onInProgress,
2029
- onStopGeneration,
2030
- onReloadMessages,
2031
- onRegenerate,
2032
- onCopy,
2033
- onThumbsUp,
2034
- onThumbsDown,
2035
- markdownTagRenderers,
2036
- Messages: Messages2 = Messages,
2037
- RenderMessage: RenderMessage2 = RenderMessage,
2038
- RenderSuggestionsList = Suggestions,
2039
- Input: Input2 = Input,
2040
- className,
2041
- icons,
2042
- labels,
2043
- AssistantMessage: AssistantMessage2 = AssistantMessage,
2044
- UserMessage: UserMessage2 = UserMessage,
2045
- ImageRenderer: ImageRenderer2 = ImageRenderer,
2046
- ErrorMessage,
2047
- imageUploadsEnabled,
2048
- inputFileAccept = "image/*",
2049
- hideStopButton,
2050
- observabilityHooks,
2051
- renderError,
2052
- onError,
2053
- // Legacy props - deprecated
2054
- RenderTextMessage,
2055
- RenderActionExecutionMessage,
2056
- RenderAgentStateMessage,
2057
- RenderResultMessage,
2058
- RenderImageMessage
2059
- }) {
2060
- const {
2061
- additionalInstructions,
2062
- setChatInstructions,
2063
- copilotApiConfig,
2064
- setBannerError,
2065
- setInternalErrorHandler,
2066
- removeInternalErrorHandler
2067
- } = (0, import_react_core5.useCopilotContext)();
2068
- const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
2069
- const [selectedImages, setSelectedImages] = (0, import_react11.useState)([]);
2070
- const [chatError, setChatError] = (0, import_react11.useState)(null);
2071
- const [messageFeedback, setMessageFeedback] = (0, import_react11.useState)({});
2072
- const fileInputRef = (0, import_react11.useRef)(null);
2073
- const triggerObservabilityHook = (0, import_react11.useCallback)(
2074
- (hookName, ...args) => {
2075
- if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
2076
- observabilityHooks[hookName](...args);
2077
- }
2078
- if ((observabilityHooks == null ? void 0 : observabilityHooks[hookName]) && !publicApiKey) {
2079
- setBannerError(
2080
- new import_shared.CopilotKitError({
2081
- message: "observabilityHooks requires a publicApiKey to function.",
2082
- code: import_shared.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
2083
- severity: import_shared.Severity.CRITICAL,
2084
- visibility: import_shared.ErrorVisibility.BANNER
2085
- })
2086
- );
2087
- import_shared.styledConsole.publicApiKeyRequired("observabilityHooks");
2088
- }
2089
- },
2090
- [publicApiKey, observabilityHooks, setBannerError]
2091
- );
2092
- const triggerChatError = (0, import_react11.useCallback)(
2093
- (error, operation, originalError) => {
2094
- const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
2095
- setChatError({
2096
- message: errorMessage,
2097
- operation,
2098
- timestamp: Date.now()
2099
- });
2100
- const errorEvent = {
2101
- type: "error",
2102
- timestamp: Date.now(),
2103
- context: {
2104
- source: "ui",
2105
- request: {
2106
- operation,
2107
- url: chatApiEndpoint,
2108
- startTime: Date.now()
2109
- },
2110
- technical: {
2111
- environment: "browser",
2112
- userAgent: typeof navigator !== "undefined" ? navigator.userAgent : void 0,
2113
- stackTrace: originalError instanceof Error ? originalError.stack : void 0
2114
- }
2115
- },
2116
- error
2117
- };
2118
- if (onError) {
2119
- onError(errorEvent);
2120
- }
2121
- if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks.onError)) {
2122
- observabilityHooks.onError(errorEvent);
2123
- }
2124
- if ((observabilityHooks == null ? void 0 : observabilityHooks.onError) && !publicApiKey) {
2125
- setBannerError(
2126
- new import_shared.CopilotKitError({
2127
- message: "observabilityHooks.onError requires a publicApiKey to function.",
2128
- code: import_shared.CopilotKitErrorCode.MISSING_PUBLIC_API_KEY_ERROR,
2129
- severity: import_shared.Severity.CRITICAL,
2130
- visibility: import_shared.ErrorVisibility.BANNER
2131
- })
2132
- );
2133
- import_shared.styledConsole.publicApiKeyRequired("observabilityHooks.onError");
2134
- }
2135
- },
2136
- [publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
2137
- );
2138
- (0, import_react11.useEffect)(() => {
2139
- const id = "chat-component";
2140
- setInternalErrorHandler({
2141
- [id]: (error) => {
2142
- if (!error)
2143
- return;
2144
- triggerChatError(error.error, "sendMessage");
2145
- }
2146
- });
2147
- return () => {
2148
- removeInternalErrorHandler == null ? void 0 : removeInternalErrorHandler(id);
2149
- };
2150
- }, [triggerChatError, setInternalErrorHandler, removeInternalErrorHandler]);
2151
- (0, import_react11.useEffect)(() => {
2152
- if (!imageUploadsEnabled)
2153
- return;
2154
- const handlePaste = (e) => __async(this, null, function* () {
2155
- var _a, _b;
2156
- const target = e.target;
2157
- if (!((_a = target.parentElement) == null ? void 0 : _a.classList.contains("copilotKitInput")))
2158
- return;
2159
- const items = Array.from(((_b = e.clipboardData) == null ? void 0 : _b.items) || []);
2160
- const imageItems = items.filter((item) => item.type.startsWith("image/"));
2161
- if (imageItems.length === 0)
2162
- return;
2163
- e.preventDefault();
2164
- const imagePromises = imageItems.map(
2165
- (item) => {
2166
- const file = item.getAsFile();
2167
- if (!file)
2168
- return Promise.resolve(null);
2169
- return new Promise((resolve, reject) => {
2170
- const reader = new FileReader();
2171
- reader.onload = (e2) => {
2172
- var _a2, _b2;
2173
- const base64String = (_b2 = (_a2 = e2.target) == null ? void 0 : _a2.result) == null ? void 0 : _b2.split(",")[1];
2174
- if (base64String) {
2175
- resolve({
2176
- contentType: file.type,
2177
- bytes: base64String
2178
- });
2179
- } else {
2180
- resolve(null);
2181
- }
2182
- };
2183
- reader.onerror = reject;
2184
- reader.readAsDataURL(file);
2185
- });
2186
- }
2187
- );
2188
- try {
2189
- const loadedImages = (yield Promise.all(imagePromises)).filter(
2190
- (img) => img !== null
2191
- );
2192
- setSelectedImages((prev) => [...prev, ...loadedImages]);
2193
- } catch (error) {
2194
- triggerChatError(error, "processClipboardImages", error);
2195
- console.error("Error processing pasted images:", error);
2196
- }
2197
- });
2198
- document.addEventListener("paste", handlePaste);
2199
- return () => document.removeEventListener("paste", handlePaste);
2200
- }, [imageUploadsEnabled, triggerChatError]);
2201
- (0, import_react11.useEffect)(() => {
2202
- if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
2203
- setChatInstructions(instructions || "");
2204
- return;
2205
- }
2206
- const combinedAdditionalInstructions = [
2207
- instructions,
2208
- "Additionally, follow these instructions:",
2209
- ...additionalInstructions.map((instruction) => `- ${instruction}`)
2210
- ];
2211
- setChatInstructions(combinedAdditionalInstructions.join("\n") || "");
2212
- }, [instructions, additionalInstructions]);
2213
- const {
2214
- messages,
2215
- isLoading,
2216
- sendMessage,
2217
- stopGeneration,
2218
- reloadMessages,
2219
- suggestions: currentSuggestions,
2220
- isLoadingSuggestions,
2221
- agent
2222
- } = (0, import_react_core5.useCopilotChatInternal)({
2223
- suggestions,
2224
- onInProgress,
2225
- onSubmitMessage,
2226
- onStopGeneration,
2227
- onReloadMessages
2228
- });
2229
- const prevIsLoading = (0, import_react11.useRef)(isLoading);
2230
- (0, import_react11.useEffect)(() => {
2231
- if (prevIsLoading.current !== isLoading) {
2232
- if (isLoading) {
2233
- triggerObservabilityHook("onChatStarted");
2234
- } else {
2235
- triggerObservabilityHook("onChatStopped");
2236
- }
2237
- prevIsLoading.current = isLoading;
2238
- }
2239
- }, [isLoading, triggerObservabilityHook]);
2240
- const handleSendMessage = (text) => {
2241
- const images = selectedImages;
2242
- setSelectedImages([]);
2243
- if (fileInputRef.current) {
2244
- fileInputRef.current.value = "";
2245
- }
2246
- triggerObservabilityHook("onMessageSent", text);
2247
- return sendMessage({
2248
- id: (0, import_shared.randomUUID)(),
2249
- content: text,
2250
- role: "user"
2251
- });
2252
- };
2253
- const chatContext = import_react11.default.useContext(ChatContext);
2254
- const isVisible = chatContext ? chatContext.open : true;
2255
- const handleRegenerate = (messageId) => {
2256
- if (onRegenerate) {
2257
- onRegenerate(messageId);
2258
- }
2259
- triggerObservabilityHook("onMessageRegenerated", messageId);
2260
- reloadMessages(messageId);
2261
- };
2262
- const handleCopy = (message) => {
2263
- if (onCopy) {
2264
- onCopy(message);
2265
- }
2266
- triggerObservabilityHook("onMessageCopied", message);
2267
- };
2268
- const handleImageUpload = (event) => __async(this, null, function* () {
2269
- if (!event.target.files || event.target.files.length === 0) {
2270
- return;
2271
- }
2272
- const files = Array.from(event.target.files).filter(
2273
- (file) => file.type.startsWith("image/")
2274
- );
2275
- if (files.length === 0)
2276
- return;
2277
- const fileReadPromises = files.map((file) => {
2278
- return new Promise(
2279
- (resolve, reject) => {
2280
- const reader = new FileReader();
2281
- reader.onload = (e) => {
2282
- var _a, _b;
2283
- const base64String = ((_b = (_a = e.target) == null ? void 0 : _a.result) == null ? void 0 : _b.split(",")[1]) || "";
2284
- if (base64String) {
2285
- resolve({
2286
- contentType: file.type,
2287
- bytes: base64String
2288
- });
2289
- }
2290
- };
2291
- reader.onerror = reject;
2292
- reader.readAsDataURL(file);
2293
- }
2294
- );
2295
- });
2296
- try {
2297
- const loadedImages = yield Promise.all(fileReadPromises);
2298
- setSelectedImages((prev) => [...prev, ...loadedImages]);
2299
- } catch (error) {
2300
- triggerChatError(error, "processUploadedImages", error);
2301
- console.error("Error reading files:", error);
2302
- }
2303
- });
2304
- const removeSelectedImage = (index) => {
2305
- setSelectedImages((prev) => prev.filter((_, i) => i !== index));
2306
- };
2307
- const handleThumbsUp = (message) => {
2308
- if (onThumbsUp) {
2309
- onThumbsUp(message);
2310
- }
2311
- setMessageFeedback((prev) => __spreadProps(__spreadValues({}, prev), {
2312
- [message.id]: "thumbsUp"
2313
- }));
2314
- triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsUp");
2315
- };
2316
- const handleThumbsDown = (message) => {
2317
- if (onThumbsDown) {
2318
- onThumbsDown(message);
2319
- }
2320
- setMessageFeedback((prev) => __spreadProps(__spreadValues({}, prev), {
2321
- [message.id]: "thumbsDown"
2322
- }));
2323
- triggerObservabilityHook("onFeedbackGiven", message.id, "thumbsDown");
2324
- };
2325
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(WrappedCopilotChat, { icons, labels, className, children: [
2326
- chatError && renderError && renderError(__spreadProps(__spreadValues({}, chatError), {
2327
- onDismiss: () => setChatError(null),
2328
- onRetry: () => {
2329
- setChatError(null);
2330
- }
2331
- })),
2332
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2333
- Messages2,
2334
- {
2335
- AssistantMessage: AssistantMessage2,
2336
- UserMessage: UserMessage2,
2337
- RenderMessage: RenderMessage2,
2338
- messages,
2339
- inProgress: isLoading,
2340
- onRegenerate: handleRegenerate,
2341
- onCopy: handleCopy,
2342
- onThumbsUp: handleThumbsUp,
2343
- onThumbsDown: handleThumbsDown,
2344
- messageFeedback,
2345
- markdownTagRenderers,
2346
- ImageRenderer: ImageRenderer2,
2347
- ErrorMessage,
2348
- chatError,
2349
- RenderTextMessage,
2350
- RenderActionExecutionMessage,
2351
- RenderAgentStateMessage,
2352
- RenderResultMessage,
2353
- RenderImageMessage,
2354
- children: currentSuggestions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2355
- RenderSuggestionsList,
2356
- {
2357
- onSuggestionClick: handleSendMessage,
2358
- suggestions: currentSuggestions,
2359
- isLoading: isLoadingSuggestions
2360
- }
2361
- )
2362
- }
2363
- ),
2364
- imageUploadsEnabled && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
2365
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2366
- ImageUploadQueue,
2367
- {
2368
- images: selectedImages,
2369
- onRemoveImage: removeSelectedImage
2370
- }
2371
- ),
2372
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2373
- "input",
2374
- {
2375
- type: "file",
2376
- multiple: true,
2377
- ref: fileInputRef,
2378
- onChange: handleImageUpload,
2379
- accept: inputFileAccept,
2380
- style: { display: "none" }
2381
- }
2382
- )
2383
- ] }),
2384
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2385
- Input2,
2386
- {
2387
- inProgress: isLoading,
2388
- chatReady: Boolean(agent),
2389
- onSend: handleSendMessage,
2390
- isVisible,
2391
- onStop: stopGeneration,
2392
- onUpload: imageUploadsEnabled ? () => {
2393
- var _a;
2394
- return (_a = fileInputRef.current) == null ? void 0 : _a.click();
2395
- } : void 0,
2396
- hideStopButton
2397
- }
2398
- )
2399
- ] });
2400
- }
2401
- function WrappedCopilotChat({
2402
- children,
2403
- icons,
2404
- labels,
2405
- className
2406
- }) {
2407
- const chatContext = import_react11.default.useContext(ChatContext);
2408
- if (!chatContext) {
2409
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2410
- ChatContextProvider,
2411
- {
2412
- icons,
2413
- labels,
2414
- open: true,
2415
- setOpen: () => {
2416
- },
2417
- children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children })
2418
- }
2419
- );
2420
- }
2421
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_jsx_runtime17.Fragment, { children });
2422
- }
2423
- // Annotate the CommonJS export names for ESM import in node:
2424
- 0 && (module.exports = {
2425
- CopilotChat,
2426
- WrappedCopilotChat
2427
- });
2428
- //# sourceMappingURL=Chat.js.map