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

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