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