@copilotkit/react-ui 1.51.3-next.4 → 1.51.3-next.6

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 (65) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/{chunk-PKSW6ZMQ.mjs → chunk-7OURDQZJ.mjs} +2 -2
  3. package/dist/{chunk-HKZL4P3F.mjs → chunk-BVKKSSB2.mjs} +4 -4
  4. package/dist/{chunk-4S4ZEKE6.mjs → chunk-DI7DDMRS.mjs} +2 -2
  5. package/dist/{chunk-UH5GQ7QF.mjs → chunk-HIW7RXCD.mjs} +2 -2
  6. package/dist/{chunk-SLM2AOHF.mjs → chunk-IHFR6PYG.mjs} +2 -2
  7. package/dist/{chunk-XOBQLKUU.mjs → chunk-JZ3RFQQ6.mjs} +13 -3
  8. package/dist/chunk-JZ3RFQQ6.mjs.map +1 -0
  9. package/dist/{chunk-XEZ5ODJS.mjs → chunk-NCIAFFQ2.mjs} +2 -2
  10. package/dist/{chunk-YQOESY4Y.mjs → chunk-NSJWSIPR.mjs} +4 -4
  11. package/dist/{chunk-O4PPO3K3.mjs → chunk-VVCCMYGT.mjs} +2 -2
  12. package/dist/components/chat/Chat.js +67 -57
  13. package/dist/components/chat/Chat.js.map +1 -1
  14. package/dist/components/chat/Chat.mjs +6 -6
  15. package/dist/components/chat/Markdown.d.ts +2 -4
  16. package/dist/components/chat/Markdown.js +12 -2
  17. package/dist/components/chat/Markdown.js.map +1 -1
  18. package/dist/components/chat/Markdown.mjs +1 -1
  19. package/dist/components/chat/Messages.js +27 -17
  20. package/dist/components/chat/Messages.js.map +1 -1
  21. package/dist/components/chat/Messages.mjs +5 -5
  22. package/dist/components/chat/Modal.js +74 -64
  23. package/dist/components/chat/Modal.js.map +1 -1
  24. package/dist/components/chat/Modal.mjs +7 -7
  25. package/dist/components/chat/Popup.js +74 -64
  26. package/dist/components/chat/Popup.js.map +1 -1
  27. package/dist/components/chat/Popup.mjs +8 -8
  28. package/dist/components/chat/Sidebar.js +76 -66
  29. package/dist/components/chat/Sidebar.js.map +1 -1
  30. package/dist/components/chat/Sidebar.mjs +8 -8
  31. package/dist/components/chat/index.d.ts +1 -1
  32. package/dist/components/chat/index.js +76 -66
  33. package/dist/components/chat/index.js.map +1 -1
  34. package/dist/components/chat/index.mjs +9 -9
  35. package/dist/components/chat/messages/AssistantMessage.js +14 -4
  36. package/dist/components/chat/messages/AssistantMessage.js.map +1 -1
  37. package/dist/components/chat/messages/AssistantMessage.mjs +2 -2
  38. package/dist/components/chat/messages/ErrorMessage.js +14 -4
  39. package/dist/components/chat/messages/ErrorMessage.js.map +1 -1
  40. package/dist/components/chat/messages/ErrorMessage.mjs +1 -1
  41. package/dist/components/chat/messages/LegacyRenderMessage.js +16 -6
  42. package/dist/components/chat/messages/LegacyRenderMessage.js.map +1 -1
  43. package/dist/components/chat/messages/LegacyRenderMessage.mjs +4 -4
  44. package/dist/components/chat/messages/RenderMessage.js +16 -6
  45. package/dist/components/chat/messages/RenderMessage.js.map +1 -1
  46. package/dist/components/chat/messages/RenderMessage.mjs +3 -3
  47. package/dist/components/index.d.ts +1 -1
  48. package/dist/components/index.js +76 -66
  49. package/dist/components/index.js.map +1 -1
  50. package/dist/components/index.mjs +9 -9
  51. package/dist/index.d.ts +1 -1
  52. package/dist/index.js +76 -66
  53. package/dist/index.js.map +1 -1
  54. package/dist/index.mjs +9 -9
  55. package/package.json +8 -5
  56. package/src/components/chat/Markdown.tsx +17 -8
  57. package/dist/chunk-XOBQLKUU.mjs.map +0 -1
  58. /package/dist/{chunk-PKSW6ZMQ.mjs.map → chunk-7OURDQZJ.mjs.map} +0 -0
  59. /package/dist/{chunk-HKZL4P3F.mjs.map → chunk-BVKKSSB2.mjs.map} +0 -0
  60. /package/dist/{chunk-4S4ZEKE6.mjs.map → chunk-DI7DDMRS.mjs.map} +0 -0
  61. /package/dist/{chunk-UH5GQ7QF.mjs.map → chunk-HIW7RXCD.mjs.map} +0 -0
  62. /package/dist/{chunk-SLM2AOHF.mjs.map → chunk-IHFR6PYG.mjs.map} +0 -0
  63. /package/dist/{chunk-XEZ5ODJS.mjs.map → chunk-NCIAFFQ2.mjs.map} +0 -0
  64. /package/dist/{chunk-YQOESY4Y.mjs.map → chunk-NSJWSIPR.mjs.map} +0 -0
  65. /package/dist/{chunk-O4PPO3K3.mjs.map → chunk-VVCCMYGT.mjs.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CopilotModal
3
- } from "../../chunk-HKZL4P3F.mjs";
3
+ } from "../../chunk-BVKKSSB2.mjs";
4
4
  import "../../chunk-C3GSYRC3.mjs";
5
5
  import "../../chunk-GDSZGYCE.mjs";
6
6
  import "../../chunk-V7W6IM2V.mjs";
@@ -11,20 +11,20 @@ import "../../chunk-KXE2JCUH.mjs";
11
11
  import "../../chunk-NRA3CFEE.mjs";
12
12
  import "../../chunk-BH6PCAAL.mjs";
13
13
  import "../../chunk-UFN2VWSR.mjs";
14
- import "../../chunk-YQOESY4Y.mjs";
14
+ import "../../chunk-NSJWSIPR.mjs";
15
15
  import "../../chunk-VHKHX7GV.mjs";
16
16
  import "../../chunk-6TWQUA2Q.mjs";
17
17
  import "../../chunk-PLHTVHUW.mjs";
18
18
  import "../../chunk-3W6J75HS.mjs";
19
19
  import "../../chunk-ELGRNEAO.mjs";
20
20
  import "../../chunk-QIOJXTIQ.mjs";
21
- import "../../chunk-UH5GQ7QF.mjs";
22
- import "../../chunk-PKSW6ZMQ.mjs";
23
- import "../../chunk-XEZ5ODJS.mjs";
24
- import "../../chunk-SLM2AOHF.mjs";
21
+ import "../../chunk-HIW7RXCD.mjs";
22
+ import "../../chunk-7OURDQZJ.mjs";
23
+ import "../../chunk-NCIAFFQ2.mjs";
24
+ import "../../chunk-IHFR6PYG.mjs";
25
25
  import "../../chunk-DBKRAOH7.mjs";
26
26
  import "../../chunk-RYUCX3ZK.mjs";
27
- import "../../chunk-XOBQLKUU.mjs";
27
+ import "../../chunk-JZ3RFQQ6.mjs";
28
28
  import "../../chunk-IK2BPURM.mjs";
29
29
  import "../../chunk-IEMQ2SQW.mjs";
30
30
  import "../../chunk-XWG3L6QC.mjs";
@@ -84,7 +84,7 @@ __export(Popup_exports, {
84
84
  module.exports = __toCommonJS(Popup_exports);
85
85
 
86
86
  // src/components/chat/Modal.tsx
87
- var import_react15 = __toESM(require("react"));
87
+ var import_react16 = __toESM(require("react"));
88
88
 
89
89
  // src/components/chat/ChatContext.tsx
90
90
  var import_react = __toESM(require("react"));
@@ -1025,7 +1025,7 @@ var Header = ({}) => {
1025
1025
  };
1026
1026
 
1027
1027
  // src/components/chat/Messages.tsx
1028
- var import_react9 = require("react");
1028
+ var import_react10 = require("react");
1029
1029
  var import_react_core5 = require("@copilotkit/react-core");
1030
1030
 
1031
1031
  // src/components/chat/messages/UserMessage.tsx
@@ -1057,7 +1057,8 @@ var UserMessage = (props) => {
1057
1057
  };
1058
1058
 
1059
1059
  // src/components/chat/Markdown.tsx
1060
- var import_streamdown = require("streamdown");
1060
+ var import_react7 = require("react");
1061
+ var import_react_markdown = __toESM(require("react-markdown"));
1061
1062
 
1062
1063
  // src/components/chat/CodeBlock.tsx
1063
1064
  var import_react6 = require("react");
@@ -1469,6 +1470,9 @@ var highlightStyle = {
1469
1470
  };
1470
1471
 
1471
1472
  // src/components/chat/Markdown.tsx
1473
+ var import_remark_gfm = __toESM(require("remark-gfm"));
1474
+ var import_remark_math = __toESM(require("remark-math"));
1475
+ var import_rehype_raw = __toESM(require("rehype-raw"));
1472
1476
  var import_jsx_runtime12 = require("react/jsx-runtime");
1473
1477
  var defaultComponents = {
1474
1478
  a(_a) {
@@ -1562,18 +1566,24 @@ var defaultComponents = {
1562
1566
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("li", __spreadProps(__spreadValues({ className: "copilotKitMarkdownElement" }, props), { children }));
1563
1567
  }
1564
1568
  };
1569
+ var MemoizedReactMarkdown = (0, import_react7.memo)(
1570
+ import_react_markdown.default,
1571
+ (prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.components === nextProps.components
1572
+ );
1565
1573
  var Markdown = ({ content, components }) => {
1566
1574
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "copilotKitMarkdown", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1567
- import_streamdown.Streamdown,
1575
+ MemoizedReactMarkdown,
1568
1576
  {
1569
1577
  components: __spreadValues(__spreadValues({}, defaultComponents), components),
1578
+ remarkPlugins: [import_remark_gfm.default, [import_remark_math.default, { singleDollarTextMath: false }]],
1579
+ rehypePlugins: [import_rehype_raw.default],
1570
1580
  children: content
1571
1581
  }
1572
1582
  ) });
1573
1583
  };
1574
1584
 
1575
1585
  // src/components/chat/messages/AssistantMessage.tsx
1576
- var import_react7 = require("react");
1586
+ var import_react8 = require("react");
1577
1587
  var import_jsx_runtime13 = require("react/jsx-runtime");
1578
1588
  var AssistantMessage = (props) => {
1579
1589
  var _a;
@@ -1589,7 +1599,7 @@ var AssistantMessage = (props) => {
1589
1599
  feedback,
1590
1600
  markdownTagRenderers
1591
1601
  } = props;
1592
- const [copied, setCopied] = (0, import_react7.useState)(false);
1602
+ const [copied, setCopied] = (0, import_react8.useState)(false);
1593
1603
  const handleCopy = () => {
1594
1604
  const content2 = (message == null ? void 0 : message.content) || "";
1595
1605
  if (content2 && onCopy) {
@@ -1678,10 +1688,10 @@ var AssistantMessage = (props) => {
1678
1688
  };
1679
1689
 
1680
1690
  // src/components/chat/messages/ImageRenderer.tsx
1681
- var import_react8 = require("react");
1691
+ var import_react9 = require("react");
1682
1692
  var import_jsx_runtime14 = require("react/jsx-runtime");
1683
1693
  var ImageRenderer = ({ image, content, className = "" }) => {
1684
- const [imageError, setImageError] = (0, import_react8.useState)(false);
1694
+ const [imageError, setImageError] = (0, import_react9.useState)(false);
1685
1695
  const imageSrc = `data:image/${image.format};base64,${image.bytes}`;
1686
1696
  const altText = content || "User uploaded image";
1687
1697
  const handleImageError = () => {
@@ -1924,18 +1934,18 @@ var Messages = ({
1924
1934
  var _a;
1925
1935
  const { labels, icons } = useChatContext();
1926
1936
  const { messages: visibleMessages, interrupt } = (0, import_react_core5.useCopilotChatInternal)();
1927
- const initialMessages = (0, import_react9.useMemo)(() => makeInitialMessages(labels.initial), [labels.initial]);
1937
+ const initialMessages = (0, import_react10.useMemo)(() => makeInitialMessages(labels.initial), [labels.initial]);
1928
1938
  const messages = [...initialMessages, ...visibleMessages];
1929
1939
  const { messagesContainerRef, messagesEndRef } = useScrollToBottom(messages);
1930
1940
  const hasLegacyProps = !!(RenderTextMessage || RenderActionExecutionMessage || RenderAgentStateMessage || RenderResultMessage || RenderImageMessage);
1931
- (0, import_react9.useEffect)(() => {
1941
+ (0, import_react10.useEffect)(() => {
1932
1942
  if (hasLegacyProps) {
1933
1943
  console.warn(
1934
1944
  "[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"
1935
1945
  );
1936
1946
  }
1937
1947
  }, [hasLegacyProps]);
1938
- const legacyProps = (0, import_react9.useMemo)(
1948
+ const legacyProps = (0, import_react10.useMemo)(
1939
1949
  () => ({
1940
1950
  RenderTextMessage,
1941
1951
  RenderActionExecutionMessage,
@@ -2006,10 +2016,10 @@ function makeInitialMessages(initial) {
2006
2016
  ];
2007
2017
  }
2008
2018
  function useScrollToBottom(messages) {
2009
- const messagesEndRef = (0, import_react9.useRef)(null);
2010
- const messagesContainerRef = (0, import_react9.useRef)(null);
2011
- const isProgrammaticScrollRef = (0, import_react9.useRef)(false);
2012
- const isUserScrollUpRef = (0, import_react9.useRef)(false);
2019
+ const messagesEndRef = (0, import_react10.useRef)(null);
2020
+ const messagesContainerRef = (0, import_react10.useRef)(null);
2021
+ const isProgrammaticScrollRef = (0, import_react10.useRef)(false);
2022
+ const isUserScrollUpRef = (0, import_react10.useRef)(false);
2013
2023
  const scrollToBottom = () => {
2014
2024
  if (messagesContainerRef.current && messagesEndRef.current) {
2015
2025
  isProgrammaticScrollRef.current = true;
@@ -2026,7 +2036,7 @@ function useScrollToBottom(messages) {
2026
2036
  isUserScrollUpRef.current = scrollTop + clientHeight < scrollHeight;
2027
2037
  }
2028
2038
  };
2029
- (0, import_react9.useEffect)(() => {
2039
+ (0, import_react10.useEffect)(() => {
2030
2040
  const container = messagesContainerRef.current;
2031
2041
  if (container) {
2032
2042
  container.addEventListener("scroll", handleScroll);
@@ -2037,7 +2047,7 @@ function useScrollToBottom(messages) {
2037
2047
  }
2038
2048
  };
2039
2049
  }, []);
2040
- (0, import_react9.useEffect)(() => {
2050
+ (0, import_react10.useEffect)(() => {
2041
2051
  const container = messagesContainerRef.current;
2042
2052
  if (!container) {
2043
2053
  return;
@@ -2056,7 +2066,7 @@ function useScrollToBottom(messages) {
2056
2066
  mutationObserver.disconnect();
2057
2067
  };
2058
2068
  }, []);
2059
- (0, import_react9.useEffect)(() => {
2069
+ (0, import_react10.useEffect)(() => {
2060
2070
  isUserScrollUpRef.current = false;
2061
2071
  scrollToBottom();
2062
2072
  }, [messages.filter((m) => m.role === "user").length]);
@@ -2064,12 +2074,12 @@ function useScrollToBottom(messages) {
2064
2074
  }
2065
2075
 
2066
2076
  // src/components/chat/Input.tsx
2067
- var import_react13 = require("react");
2077
+ var import_react14 = require("react");
2068
2078
 
2069
2079
  // src/components/chat/Textarea.tsx
2070
- var import_react10 = require("react");
2080
+ var import_react11 = require("react");
2071
2081
  var import_jsx_runtime18 = require("react/jsx-runtime");
2072
- var AutoResizingTextarea = (0, import_react10.forwardRef)(
2082
+ var AutoResizingTextarea = (0, import_react11.forwardRef)(
2073
2083
  ({
2074
2084
  maxRows = 1,
2075
2085
  placeholder,
@@ -2080,10 +2090,10 @@ var AutoResizingTextarea = (0, import_react10.forwardRef)(
2080
2090
  onCompositionEnd,
2081
2091
  autoFocus
2082
2092
  }, ref) => {
2083
- const internalTextareaRef = (0, import_react10.useRef)(null);
2084
- const [maxHeight, setMaxHeight] = (0, import_react10.useState)(0);
2085
- (0, import_react10.useImperativeHandle)(ref, () => internalTextareaRef.current);
2086
- (0, import_react10.useEffect)(() => {
2093
+ const internalTextareaRef = (0, import_react11.useRef)(null);
2094
+ const [maxHeight, setMaxHeight] = (0, import_react11.useState)(0);
2095
+ (0, import_react11.useImperativeHandle)(ref, () => internalTextareaRef.current);
2096
+ (0, import_react11.useEffect)(() => {
2087
2097
  const calculateMaxHeight = () => {
2088
2098
  const textarea = internalTextareaRef.current;
2089
2099
  if (textarea) {
@@ -2097,7 +2107,7 @@ var AutoResizingTextarea = (0, import_react10.forwardRef)(
2097
2107
  };
2098
2108
  calculateMaxHeight();
2099
2109
  }, [maxRows]);
2100
- (0, import_react10.useEffect)(() => {
2110
+ (0, import_react11.useEffect)(() => {
2101
2111
  const textarea = internalTextareaRef.current;
2102
2112
  if (textarea) {
2103
2113
  textarea.style.height = "auto";
@@ -2129,7 +2139,7 @@ var Textarea_default = AutoResizingTextarea;
2129
2139
  // src/hooks/use-push-to-talk.tsx
2130
2140
  var import_react_core6 = require("@copilotkit/react-core");
2131
2141
  var import_runtime_client_gql2 = require("@copilotkit/runtime-client-gql");
2132
- var import_react11 = require("react");
2142
+ var import_react12 = require("react");
2133
2143
  var startRecording = (mediaStreamRef, mediaRecorderRef, audioContextRef, recordedChunks, onStop) => __async(void 0, null, function* () {
2134
2144
  if (!mediaStreamRef.current || !audioContextRef.current) {
2135
2145
  mediaStreamRef.current = yield navigator.mediaDevices.getUserMedia({ audio: true });
@@ -2178,16 +2188,16 @@ var usePushToTalk = ({
2178
2188
  sendFunction,
2179
2189
  inProgress
2180
2190
  }) => {
2181
- const [pushToTalkState, setPushToTalkState] = (0, import_react11.useState)("idle");
2182
- const mediaStreamRef = (0, import_react11.useRef)(null);
2183
- const audioContextRef = (0, import_react11.useRef)(null);
2184
- const mediaRecorderRef = (0, import_react11.useRef)(null);
2185
- const recordedChunks = (0, import_react11.useRef)([]);
2191
+ const [pushToTalkState, setPushToTalkState] = (0, import_react12.useState)("idle");
2192
+ const mediaStreamRef = (0, import_react12.useRef)(null);
2193
+ const audioContextRef = (0, import_react12.useRef)(null);
2194
+ const mediaRecorderRef = (0, import_react12.useRef)(null);
2195
+ const recordedChunks = (0, import_react12.useRef)([]);
2186
2196
  const generalContext = (0, import_react_core6.useCopilotContext)();
2187
2197
  const messagesContext = (0, import_react_core6.useCopilotMessagesContext)();
2188
2198
  const context = __spreadValues(__spreadValues({}, generalContext), messagesContext);
2189
- const [startReadingFromMessageId, setStartReadingFromMessageId] = (0, import_react11.useState)(null);
2190
- (0, import_react11.useEffect)(() => {
2199
+ const [startReadingFromMessageId, setStartReadingFromMessageId] = (0, import_react12.useState)(null);
2200
+ (0, import_react12.useEffect)(() => {
2191
2201
  if (pushToTalkState === "recording") {
2192
2202
  startRecording(
2193
2203
  mediaStreamRef,
@@ -2215,7 +2225,7 @@ var usePushToTalk = ({
2215
2225
  stopRecording(mediaRecorderRef);
2216
2226
  };
2217
2227
  }, [pushToTalkState]);
2218
- (0, import_react11.useEffect)(() => {
2228
+ (0, import_react12.useEffect)(() => {
2219
2229
  if (inProgress === false && startReadingFromMessageId) {
2220
2230
  const lastMessageIndex = context.messages.findIndex(
2221
2231
  (message) => message.id === startReadingFromMessageId
@@ -2234,7 +2244,7 @@ var usePushToTalk = ({
2234
2244
  var import_react_core7 = require("@copilotkit/react-core");
2235
2245
 
2236
2246
  // src/components/chat/PoweredByTag.tsx
2237
- var import_react12 = require("react");
2247
+ var import_react13 = require("react");
2238
2248
 
2239
2249
  // src/hooks/use-dark-mode.ts
2240
2250
  var useDarkMode = () => {
@@ -2246,9 +2256,9 @@ var useDarkMode = () => {
2246
2256
  // src/components/chat/PoweredByTag.tsx
2247
2257
  var import_jsx_runtime19 = require("react/jsx-runtime");
2248
2258
  function PoweredByTag({ showPoweredBy = true }) {
2249
- const [mounted, setMounted] = (0, import_react12.useState)(false);
2259
+ const [mounted, setMounted] = (0, import_react13.useState)(false);
2250
2260
  const isDark = useDarkMode();
2251
- (0, import_react12.useEffect)(() => {
2261
+ (0, import_react13.useEffect)(() => {
2252
2262
  setMounted(true);
2253
2263
  }, []);
2254
2264
  if (!showPoweredBy) {
@@ -2282,8 +2292,8 @@ var Input = ({
2282
2292
  const copilotContext = (0, import_react_core7.useCopilotContext)();
2283
2293
  const showPoweredBy = !((_a = copilotContext.copilotApiConfig) == null ? void 0 : _a.publicApiKey);
2284
2294
  const pushToTalkConfigured = copilotContext.copilotApiConfig.textToSpeechUrl !== void 0 && copilotContext.copilotApiConfig.transcribeAudioUrl !== void 0;
2285
- const textareaRef = (0, import_react13.useRef)(null);
2286
- const [isComposing, setIsComposing] = (0, import_react13.useState)(false);
2295
+ const textareaRef = (0, import_react14.useRef)(null);
2296
+ const [isComposing, setIsComposing] = (0, import_react14.useState)(false);
2287
2297
  const handleDivClick = (event) => {
2288
2298
  var _a2;
2289
2299
  const target = event.target;
@@ -2293,7 +2303,7 @@ var Input = ({
2293
2303
  return;
2294
2304
  (_a2 = textareaRef.current) == null ? void 0 : _a2.focus();
2295
2305
  };
2296
- const [text, setText] = (0, import_react13.useState)("");
2306
+ const [text, setText] = (0, import_react14.useState)("");
2297
2307
  const send = () => {
2298
2308
  var _a2;
2299
2309
  if (inProgress)
@@ -2307,17 +2317,17 @@ var Input = ({
2307
2317
  inProgress
2308
2318
  });
2309
2319
  const isInProgress = inProgress || pushToTalkState === "transcribing";
2310
- const { buttonIcon, buttonAlt } = (0, import_react13.useMemo)(() => {
2320
+ const { buttonIcon, buttonAlt } = (0, import_react14.useMemo)(() => {
2311
2321
  if (!chatReady)
2312
2322
  return { buttonIcon: context.icons.spinnerIcon, buttonAlt: "Loading" };
2313
2323
  return isInProgress && !hideStopButton && chatReady ? { buttonIcon: context.icons.stopIcon, buttonAlt: "Stop" } : { buttonIcon: context.icons.sendIcon, buttonAlt: "Send" };
2314
2324
  }, [isInProgress, chatReady, hideStopButton, context.icons.stopIcon, context.icons.sendIcon]);
2315
2325
  const showPushToTalk = pushToTalkConfigured && (pushToTalkState === "idle" || pushToTalkState === "recording") && !inProgress;
2316
2326
  const { interrupt } = (0, import_react_core7.useCopilotChatInternal)();
2317
- const canSend = (0, import_react13.useMemo)(() => {
2327
+ const canSend = (0, import_react14.useMemo)(() => {
2318
2328
  return !isInProgress && text.trim().length > 0 && pushToTalkState === "idle" && !interrupt;
2319
2329
  }, [interrupt, isInProgress, text, pushToTalkState]);
2320
- const canStop = (0, import_react13.useMemo)(() => {
2330
+ const canStop = (0, import_react14.useMemo)(() => {
2321
2331
  return isInProgress && !hideStopButton;
2322
2332
  }, [isInProgress, hideStopButton]);
2323
2333
  const sendDisabled = !canSend && !canStop;
@@ -2374,7 +2384,7 @@ var Input = ({
2374
2384
  };
2375
2385
 
2376
2386
  // src/components/chat/Chat.tsx
2377
- var import_react14 = __toESM(require("react"));
2387
+ var import_react15 = __toESM(require("react"));
2378
2388
  var import_react_core9 = require("@copilotkit/react-core");
2379
2389
  var import_shared3 = require("@copilotkit/shared");
2380
2390
 
@@ -2551,13 +2561,13 @@ function CopilotChat({
2551
2561
  removeInternalErrorHandler
2552
2562
  } = (0, import_react_core9.useCopilotContext)();
2553
2563
  const { publicApiKey, chatApiEndpoint } = copilotApiConfig;
2554
- const [selectedImages, setSelectedImages] = (0, import_react14.useState)([]);
2555
- const [chatError, setChatError] = (0, import_react14.useState)(null);
2556
- const [messageFeedback, setMessageFeedback] = (0, import_react14.useState)(
2564
+ const [selectedImages, setSelectedImages] = (0, import_react15.useState)([]);
2565
+ const [chatError, setChatError] = (0, import_react15.useState)(null);
2566
+ const [messageFeedback, setMessageFeedback] = (0, import_react15.useState)(
2557
2567
  {}
2558
2568
  );
2559
- const fileInputRef = (0, import_react14.useRef)(null);
2560
- const triggerObservabilityHook = (0, import_react14.useCallback)(
2569
+ const fileInputRef = (0, import_react15.useRef)(null);
2570
+ const triggerObservabilityHook = (0, import_react15.useCallback)(
2561
2571
  (hookName, ...args) => {
2562
2572
  if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
2563
2573
  observabilityHooks[hookName](...args);
@@ -2576,7 +2586,7 @@ function CopilotChat({
2576
2586
  },
2577
2587
  [publicApiKey, observabilityHooks, setBannerError]
2578
2588
  );
2579
- const triggerChatError = (0, import_react14.useCallback)(
2589
+ const triggerChatError = (0, import_react15.useCallback)(
2580
2590
  (error, operation, originalError) => {
2581
2591
  const errorMessage = (error == null ? void 0 : error.message) || (error == null ? void 0 : error.toString()) || "An error occurred";
2582
2592
  setChatError({
@@ -2622,7 +2632,7 @@ function CopilotChat({
2622
2632
  },
2623
2633
  [publicApiKey, chatApiEndpoint, observabilityHooks, setBannerError]
2624
2634
  );
2625
- (0, import_react14.useEffect)(() => {
2635
+ (0, import_react15.useEffect)(() => {
2626
2636
  const id = "chat-component";
2627
2637
  setInternalErrorHandler({
2628
2638
  [id]: (error) => {
@@ -2635,7 +2645,7 @@ function CopilotChat({
2635
2645
  removeInternalErrorHandler == null ? void 0 : removeInternalErrorHandler(id);
2636
2646
  };
2637
2647
  }, [triggerChatError, setInternalErrorHandler, removeInternalErrorHandler]);
2638
- (0, import_react14.useEffect)(() => {
2648
+ (0, import_react15.useEffect)(() => {
2639
2649
  if (!imageUploadsEnabled)
2640
2650
  return;
2641
2651
  const handlePaste = (e) => __async(this, null, function* () {
@@ -2681,7 +2691,7 @@ function CopilotChat({
2681
2691
  document.addEventListener("paste", handlePaste);
2682
2692
  return () => document.removeEventListener("paste", handlePaste);
2683
2693
  }, [imageUploadsEnabled, triggerChatError]);
2684
- (0, import_react14.useEffect)(() => {
2694
+ (0, import_react15.useEffect)(() => {
2685
2695
  if (!(additionalInstructions == null ? void 0 : additionalInstructions.length)) {
2686
2696
  setChatInstructions(instructions || "");
2687
2697
  return;
@@ -2709,8 +2719,8 @@ function CopilotChat({
2709
2719
  onStopGeneration,
2710
2720
  onReloadMessages
2711
2721
  });
2712
- const prevIsLoading = (0, import_react14.useRef)(isLoading);
2713
- (0, import_react14.useEffect)(() => {
2722
+ const prevIsLoading = (0, import_react15.useRef)(isLoading);
2723
+ (0, import_react15.useEffect)(() => {
2714
2724
  if (prevIsLoading.current !== isLoading) {
2715
2725
  if (isLoading) {
2716
2726
  triggerObservabilityHook("onChatStarted");
@@ -2733,7 +2743,7 @@ function CopilotChat({
2733
2743
  role: "user"
2734
2744
  });
2735
2745
  };
2736
- const chatContext = import_react14.default.useContext(ChatContext);
2746
+ const chatContext = import_react15.default.useContext(ChatContext);
2737
2747
  const isVisible = chatContext ? chatContext.open : true;
2738
2748
  const handleRegenerate = (messageId) => {
2739
2749
  if (onRegenerate) {
@@ -2877,7 +2887,7 @@ function WrappedCopilotChat({
2877
2887
  labels,
2878
2888
  className
2879
2889
  }) {
2880
- const chatContext = import_react14.default.useContext(ChatContext);
2890
+ const chatContext = import_react15.default.useContext(ChatContext);
2881
2891
  if (!chatContext) {
2882
2892
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(ChatContextProvider, { icons, labels, open: true, setOpen: () => {
2883
2893
  }, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: `copilotKitChat ${className != null ? className : ""}`, children }) });
@@ -2915,7 +2925,7 @@ var CopilotModalInner = (_a) => {
2915
2925
  ]);
2916
2926
  const { copilotApiConfig, setBannerError } = (0, import_react_core10.useCopilotContext)();
2917
2927
  const { publicApiKey } = copilotApiConfig;
2918
- const triggerObservabilityHook = (0, import_react15.useCallback)(
2928
+ const triggerObservabilityHook = (0, import_react16.useCallback)(
2919
2929
  (hookName, ...args) => {
2920
2930
  if (publicApiKey && (observabilityHooks == null ? void 0 : observabilityHooks[hookName])) {
2921
2931
  observabilityHooks[hookName](...args);
@@ -2935,8 +2945,8 @@ var CopilotModalInner = (_a) => {
2935
2945
  [publicApiKey, observabilityHooks, setBannerError]
2936
2946
  );
2937
2947
  const { open } = useChatContext();
2938
- const prevOpen = (0, import_react15.useRef)(open);
2939
- (0, import_react15.useEffect)(() => {
2948
+ const prevOpen = (0, import_react16.useRef)(open);
2949
+ (0, import_react16.useEffect)(() => {
2940
2950
  if (prevOpen.current !== open) {
2941
2951
  onSetOpen == null ? void 0 : onSetOpen(open);
2942
2952
  if (open) {
@@ -2947,8 +2957,8 @@ var CopilotModalInner = (_a) => {
2947
2957
  prevOpen.current = open;
2948
2958
  }
2949
2959
  }, [open, onSetOpen, triggerObservabilityHook]);
2950
- const memoizedHeader = (0, import_react15.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Header2, {}), [Header2]);
2951
- const memoizedChildren = (0, import_react15.useMemo)(() => children, [children]);
2960
+ const memoizedHeader = (0, import_react16.useMemo)(() => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Header2, {}), [Header2]);
2961
+ const memoizedChildren = (0, import_react16.useMemo)(() => children, [children]);
2952
2962
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
2953
2963
  memoizedChildren,
2954
2964
  /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className, children: [
@@ -3028,7 +3038,7 @@ var CopilotModal = (_a) => {
3028
3038
  "children",
3029
3039
  "observabilityHooks"
3030
3040
  ]);
3031
- const [openState, setOpenState] = import_react15.default.useState(defaultOpen);
3041
+ const [openState, setOpenState] = import_react16.default.useState(defaultOpen);
3032
3042
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
3033
3043
  CopilotModalInner,
3034
3044
  __spreadProps(__spreadValues({