@copilotkit/react-ui 0.15.0-alpha.8 → 0.15.0

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 (147) hide show
  1. package/.turbo/turbo-build.log +187 -207
  2. package/CHANGELOG.md +46 -0
  3. package/dist/chunk-3M4HWSE7.mjs +13 -7
  4. package/dist/chunk-3M4HWSE7.mjs.map +1 -1
  5. package/dist/chunk-47SYBLI2.mjs +5 -5
  6. package/dist/chunk-47SYBLI2.mjs.map +1 -1
  7. package/dist/chunk-5O2MCJZ2.mjs +8 -4
  8. package/dist/chunk-5O2MCJZ2.mjs.map +1 -1
  9. package/dist/chunk-7NSRDJ5C.mjs +0 -2
  10. package/dist/chunk-7NSRDJ5C.mjs.map +1 -1
  11. package/dist/chunk-7YXG7D47.mjs +20 -4
  12. package/dist/chunk-7YXG7D47.mjs.map +1 -1
  13. package/dist/chunk-CKJXXQ2W.mjs +13 -6
  14. package/dist/chunk-CKJXXQ2W.mjs.map +1 -1
  15. package/dist/chunk-DPRH4HX3.mjs +20 -10
  16. package/dist/chunk-DPRH4HX3.mjs.map +1 -1
  17. package/dist/chunk-GWGHQNRI.mjs +17 -9
  18. package/dist/chunk-GWGHQNRI.mjs.map +1 -1
  19. package/dist/chunk-H4VKQGVU.mjs +0 -2
  20. package/dist/chunk-H4VKQGVU.mjs.map +1 -1
  21. package/dist/chunk-IU3WTXLQ.mjs +0 -2
  22. package/dist/chunk-IU3WTXLQ.mjs.map +1 -1
  23. package/dist/chunk-JD7BAH7U.mjs +0 -2
  24. package/dist/chunk-JD7BAH7U.mjs.map +1 -1
  25. package/dist/chunk-KBGIPFXA.mjs +12 -5
  26. package/dist/chunk-KBGIPFXA.mjs.map +1 -1
  27. package/dist/chunk-MRXNTQOX.mjs +6 -2
  28. package/dist/chunk-MRXNTQOX.mjs.map +1 -1
  29. package/dist/chunk-NNVWLSYK.mjs +32 -14
  30. package/dist/chunk-NNVWLSYK.mjs.map +1 -1
  31. package/dist/chunk-NYLOXKYT.mjs +12 -6
  32. package/dist/chunk-NYLOXKYT.mjs.map +1 -1
  33. package/dist/chunk-OF66AL5Z.mjs +22 -6
  34. package/dist/chunk-OF66AL5Z.mjs.map +1 -1
  35. package/dist/chunk-P4GBO6MW.mjs +0 -2
  36. package/dist/chunk-P4GBO6MW.mjs.map +1 -1
  37. package/dist/chunk-POVINPXX.mjs +4 -4
  38. package/dist/chunk-POVINPXX.mjs.map +1 -1
  39. package/dist/chunk-UWPFPWAW.mjs +8 -4
  40. package/dist/chunk-UWPFPWAW.mjs.map +1 -1
  41. package/dist/chunk-WB3YULQ4.mjs +0 -2
  42. package/dist/chunk-WB3YULQ4.mjs.map +1 -1
  43. package/dist/chunk-WM6BS77F.mjs +5 -5
  44. package/dist/chunk-WM6BS77F.mjs.map +1 -1
  45. package/dist/chunk-Z34F3WLK.mjs +8 -4
  46. package/dist/chunk-Z34F3WLK.mjs.map +1 -1
  47. package/dist/components/chat/Button.js +48 -15
  48. package/dist/components/chat/Button.js.map +1 -1
  49. package/dist/components/chat/Button.mjs +9 -5
  50. package/dist/components/chat/Button.mjs.map +1 -1
  51. package/dist/components/chat/Chat.js +204 -138
  52. package/dist/components/chat/Chat.js.map +1 -1
  53. package/dist/components/chat/Chat.mjs +19 -15
  54. package/dist/components/chat/Chat.mjs.map +1 -1
  55. package/dist/components/chat/ChatContext.js +71 -37
  56. package/dist/components/chat/ChatContext.js.map +1 -1
  57. package/dist/components/chat/ChatContext.mjs +12 -4
  58. package/dist/components/chat/ChatContext.mjs.map +1 -1
  59. package/dist/components/chat/CodeBlock.js +75 -53
  60. package/dist/components/chat/CodeBlock.js.map +1 -1
  61. package/dist/components/chat/CodeBlock.mjs +14 -5
  62. package/dist/components/chat/CodeBlock.mjs.map +1 -1
  63. package/dist/components/chat/Header.js +48 -15
  64. package/dist/components/chat/Header.js.map +1 -1
  65. package/dist/components/chat/Header.mjs +9 -5
  66. package/dist/components/chat/Header.mjs.map +1 -1
  67. package/dist/components/chat/Icons.js +73 -42
  68. package/dist/components/chat/Icons.js.map +1 -1
  69. package/dist/components/chat/Icons.mjs +27 -3
  70. package/dist/components/chat/Icons.mjs.map +1 -1
  71. package/dist/components/chat/Input.js +64 -26
  72. package/dist/components/chat/Input.js.map +1 -1
  73. package/dist/components/chat/Input.mjs +10 -6
  74. package/dist/components/chat/Input.mjs.map +1 -1
  75. package/dist/components/chat/Markdown.js +86 -66
  76. package/dist/components/chat/Markdown.js.map +1 -1
  77. package/dist/components/chat/Markdown.mjs +10 -6
  78. package/dist/components/chat/Markdown.mjs.map +1 -1
  79. package/dist/components/chat/Messages.js +113 -79
  80. package/dist/components/chat/Messages.js.map +1 -1
  81. package/dist/components/chat/Messages.mjs +12 -8
  82. package/dist/components/chat/Messages.mjs.map +1 -1
  83. package/dist/components/chat/Popup.js +210 -139
  84. package/dist/components/chat/Popup.js.map +1 -1
  85. package/dist/components/chat/Popup.mjs +20 -16
  86. package/dist/components/chat/Popup.mjs.map +1 -1
  87. package/dist/components/chat/Response.js +47 -14
  88. package/dist/components/chat/Response.js.map +1 -1
  89. package/dist/components/chat/Response.mjs +9 -5
  90. package/dist/components/chat/Response.mjs.map +1 -1
  91. package/dist/components/chat/Sidebar.js +213 -141
  92. package/dist/components/chat/Sidebar.js.map +1 -1
  93. package/dist/components/chat/Sidebar.mjs +20 -16
  94. package/dist/components/chat/Sidebar.mjs.map +1 -1
  95. package/dist/components/chat/Textarea.js +32 -14
  96. package/dist/components/chat/Textarea.js.map +1 -1
  97. package/dist/components/chat/Textarea.mjs +7 -3
  98. package/dist/components/chat/Textarea.mjs.map +1 -1
  99. package/dist/components/chat/Window.js +45 -17
  100. package/dist/components/chat/Window.js.map +1 -1
  101. package/dist/components/chat/Window.mjs +7 -3
  102. package/dist/components/chat/Window.mjs.map +1 -1
  103. package/dist/components/chat/index.js +219 -143
  104. package/dist/components/chat/index.js.map +1 -1
  105. package/dist/components/chat/index.mjs +26 -19
  106. package/dist/components/chat/index.mjs.map +1 -1
  107. package/dist/components/chat/props.js +17 -2
  108. package/dist/components/chat/props.js.map +1 -1
  109. package/dist/components/chat/props.mjs +1 -2
  110. package/dist/components/chat/props.mjs.map +1 -1
  111. package/dist/components/index.js +219 -143
  112. package/dist/components/index.js.map +1 -1
  113. package/dist/components/index.mjs +27 -20
  114. package/dist/components/index.mjs.map +1 -1
  115. package/dist/context/index.js +17 -2
  116. package/dist/context/index.js.map +1 -1
  117. package/dist/context/index.mjs +1 -2
  118. package/dist/context/index.mjs.map +1 -1
  119. package/dist/hooks/index.js +17 -2
  120. package/dist/hooks/index.js.map +1 -1
  121. package/dist/hooks/index.mjs +1 -2
  122. package/dist/hooks/index.mjs.map +1 -1
  123. package/dist/hooks/use-copy-to-clipboard.js +40 -26
  124. package/dist/hooks/use-copy-to-clipboard.js.map +1 -1
  125. package/dist/hooks/use-copy-to-clipboard.mjs +8 -3
  126. package/dist/hooks/use-copy-to-clipboard.mjs.map +1 -1
  127. package/dist/index.js +219 -143
  128. package/dist/index.js.map +1 -1
  129. package/dist/index.mjs +30 -23
  130. package/dist/index.mjs.map +1 -1
  131. package/dist/lib/utils.js +40 -14
  132. package/dist/lib/utils.js.map +1 -1
  133. package/dist/lib/utils.mjs +13 -7
  134. package/dist/lib/utils.mjs.map +1 -1
  135. package/dist/lib/utils.test.js +1 -2
  136. package/dist/lib/utils.test.js.map +1 -1
  137. package/dist/lib/utils.test.mjs +0 -1
  138. package/dist/lib/utils.test.mjs.map +1 -1
  139. package/dist/types/index.js +17 -2
  140. package/dist/types/index.js.map +1 -1
  141. package/dist/types/index.mjs +1 -2
  142. package/dist/types/index.mjs.map +1 -1
  143. package/dist/types/types.js +17 -2
  144. package/dist/types/types.js.map +1 -1
  145. package/dist/types/types.mjs +0 -2
  146. package/dist/types/types.mjs.map +1 -1
  147. package/package.json +8 -8
@@ -1,44 +1,12 @@
1
- 'use strict';
2
-
3
- var React = require('react');
4
- var jsxRuntime = require('react/jsx-runtime');
5
- var reactCore = require('@copilotkit/react-core');
6
- var nanoid = require('nanoid');
7
- var ReactMarkdown = require('react-markdown');
8
- var reactSyntaxHighlighter = require('react-syntax-highlighter');
9
- var prism = require('react-syntax-highlighter/dist/esm/styles/prism');
10
- var remarkGfm = require('remark-gfm');
11
- var remarkMath = require('remark-math');
12
-
13
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
14
-
15
- function _interopNamespace(e) {
16
- if (e && e.__esModule) return e;
17
- var n = Object.create(null);
18
- if (e) {
19
- Object.keys(e).forEach(function (k) {
20
- if (k !== 'default') {
21
- var d = Object.getOwnPropertyDescriptor(e, k);
22
- Object.defineProperty(n, k, d.get ? d : {
23
- enumerable: true,
24
- get: function () { return e[k]; }
25
- });
26
- }
27
- });
28
- }
29
- n.default = e;
30
- return Object.freeze(n);
31
- }
32
-
33
- var React__namespace = /*#__PURE__*/_interopNamespace(React);
34
- var ReactMarkdown__default = /*#__PURE__*/_interopDefault(ReactMarkdown);
35
- var remarkGfm__default = /*#__PURE__*/_interopDefault(remarkGfm);
36
- var remarkMath__default = /*#__PURE__*/_interopDefault(remarkMath);
37
-
1
+ "use strict";
2
+ var __create = Object.create;
38
3
  var __defProp = Object.defineProperty;
39
4
  var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
40
6
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
41
8
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
42
10
  var __hasOwnProp = Object.prototype.hasOwnProperty;
43
11
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
44
12
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -66,6 +34,27 @@ var __objRest = (source, exclude) => {
66
34
  }
67
35
  return target;
68
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);
69
58
  var __async = (__this, __arguments, generator) => {
70
59
  return new Promise((resolve, reject) => {
71
60
  var fulfilled = (value) => {
@@ -86,7 +75,24 @@ var __async = (__this, __arguments, generator) => {
86
75
  step((generator = generator.apply(__this, __arguments)).next());
87
76
  });
88
77
  };
89
- var OpenIcon = /* @__PURE__ */ jsxRuntime.jsx(
78
+
79
+ // src/components/chat/index.tsx
80
+ var chat_exports = {};
81
+ __export(chat_exports, {
82
+ CopilotPopup: () => CopilotPopup,
83
+ CopilotSidebar: () => CopilotSidebar
84
+ });
85
+ module.exports = __toCommonJS(chat_exports);
86
+
87
+ // src/components/chat/Chat.tsx
88
+ var import_react8 = __toESM(require("react"));
89
+
90
+ // src/components/chat/ChatContext.tsx
91
+ var import_react = __toESM(require("react"));
92
+
93
+ // src/components/chat/Icons.tsx
94
+ var import_jsx_runtime = require("react/jsx-runtime");
95
+ var OpenIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
90
96
  "svg",
91
97
  {
92
98
  xmlns: "http://www.w3.org/2000/svg",
@@ -94,7 +100,7 @@ var OpenIcon = /* @__PURE__ */ jsxRuntime.jsx(
94
100
  fill: "currentColor",
95
101
  width: "24",
96
102
  height: "24",
97
- children: /* @__PURE__ */ jsxRuntime.jsx("g", { transform: "translate(24, 0) scale(-1, 1)", children: /* @__PURE__ */ jsxRuntime.jsx(
103
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("g", { transform: "translate(24, 0) scale(-1, 1)", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
98
104
  "path",
99
105
  {
100
106
  fillRule: "evenodd",
@@ -104,7 +110,7 @@ var OpenIcon = /* @__PURE__ */ jsxRuntime.jsx(
104
110
  ) })
105
111
  }
106
112
  );
107
- var CloseIcon = /* @__PURE__ */ jsxRuntime.jsx(
113
+ var CloseIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
108
114
  "svg",
109
115
  {
110
116
  xmlns: "http://www.w3.org/2000/svg",
@@ -114,10 +120,10 @@ var CloseIcon = /* @__PURE__ */ jsxRuntime.jsx(
114
120
  stroke: "currentColor",
115
121
  width: "24",
116
122
  height: "24",
117
- children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19.5 8.25l-7.5 7.5-7.5-7.5" })
123
+ 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" })
118
124
  }
119
125
  );
120
- var HeaderCloseIcon = /* @__PURE__ */ jsxRuntime.jsx(
126
+ var HeaderCloseIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
121
127
  "svg",
122
128
  {
123
129
  xmlns: "http://www.w3.org/2000/svg",
@@ -127,10 +133,10 @@ var HeaderCloseIcon = /* @__PURE__ */ jsxRuntime.jsx(
127
133
  stroke: "currentColor",
128
134
  width: "24",
129
135
  height: "24",
130
- children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
136
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
131
137
  }
132
138
  );
133
- var SendIcon = /* @__PURE__ */ jsxRuntime.jsx(
139
+ var SendIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
134
140
  "svg",
135
141
  {
136
142
  xmlns: "http://www.w3.org/2000/svg",
@@ -140,7 +146,7 @@ var SendIcon = /* @__PURE__ */ jsxRuntime.jsx(
140
146
  stroke: "currentColor",
141
147
  width: "24",
142
148
  height: "24",
143
- children: /* @__PURE__ */ jsxRuntime.jsx(
149
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
144
150
  "path",
145
151
  {
146
152
  strokeLinecap: "round",
@@ -150,7 +156,7 @@ var SendIcon = /* @__PURE__ */ jsxRuntime.jsx(
150
156
  )
151
157
  }
152
158
  );
153
- var SpinnerIcon = /* @__PURE__ */ jsxRuntime.jsxs(
159
+ var SpinnerIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
154
160
  "svg",
155
161
  {
156
162
  style: {
@@ -163,7 +169,7 @@ var SpinnerIcon = /* @__PURE__ */ jsxRuntime.jsxs(
163
169
  fill: "none",
164
170
  viewBox: "0 0 24 24",
165
171
  children: [
166
- /* @__PURE__ */ jsxRuntime.jsx(
172
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
167
173
  "circle",
168
174
  {
169
175
  style: { opacity: 0.25 },
@@ -174,7 +180,7 @@ var SpinnerIcon = /* @__PURE__ */ jsxRuntime.jsxs(
174
180
  strokeWidth: "4"
175
181
  }
176
182
  ),
177
- /* @__PURE__ */ jsxRuntime.jsx(
183
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
178
184
  "path",
179
185
  {
180
186
  style: { opacity: 0.75 },
@@ -185,7 +191,7 @@ var SpinnerIcon = /* @__PURE__ */ jsxRuntime.jsxs(
185
191
  ]
186
192
  }
187
193
  );
188
- var ActivityIcon = /* @__PURE__ */ jsxRuntime.jsxs(
194
+ var ActivityIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
189
195
  "svg",
190
196
  {
191
197
  style: {
@@ -199,15 +205,15 @@ var ActivityIcon = /* @__PURE__ */ jsxRuntime.jsxs(
199
205
  xmlns: "http://www.w3.org/2000/svg",
200
206
  fill: "currentColor",
201
207
  children: [
202
- /* @__PURE__ */ jsxRuntime.jsx("circle", { className: "copilotKitActivityDot1", cx: "4", cy: "12", r: "3" }),
203
- /* @__PURE__ */ jsxRuntime.jsx("circle", { className: "copilotKitActivityDot1 copilotKitActivityDot2", cx: "12", cy: "12", r: "3" }),
204
- /* @__PURE__ */ jsxRuntime.jsx("circle", { className: "copilotKitActivityDot1 copilotKitActivityDot3", cx: "20", cy: "12", r: "3" })
208
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { className: "copilotKitActivityDot1", cx: "4", cy: "12", r: "3" }),
209
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { className: "copilotKitActivityDot1 copilotKitActivityDot2", cx: "12", cy: "12", r: "3" }),
210
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { className: "copilotKitActivityDot1 copilotKitActivityDot3", cx: "20", cy: "12", r: "3" })
205
211
  ]
206
212
  }
207
213
  );
208
214
  function CheckIcon(_a) {
209
215
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
210
- return /* @__PURE__ */ jsxRuntime.jsx(
216
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
211
217
  "svg",
212
218
  __spreadProps(__spreadValues({
213
219
  xmlns: "http://www.w3.org/2000/svg",
@@ -216,13 +222,13 @@ function CheckIcon(_a) {
216
222
  style: { height: "1rem", width: "1rem" },
217
223
  className
218
224
  }, props), {
219
- children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m229.66 77.66-128 128a8 8 0 0 1-11.32 0l-56-56a8 8 0 0 1 11.32-11.32L96 188.69 218.34 66.34a8 8 0 0 1 11.32 11.32Z" })
225
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m229.66 77.66-128 128a8 8 0 0 1-11.32 0l-56-56a8 8 0 0 1 11.32-11.32L96 188.69 218.34 66.34a8 8 0 0 1 11.32 11.32Z" })
220
226
  })
221
227
  );
222
228
  }
223
229
  function DownloadIcon(_a) {
224
230
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
225
- return /* @__PURE__ */ jsxRuntime.jsx(
231
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
226
232
  "svg",
227
233
  __spreadProps(__spreadValues({
228
234
  xmlns: "http://www.w3.org/2000/svg",
@@ -231,13 +237,13 @@ function DownloadIcon(_a) {
231
237
  style: { height: "1rem", width: "1rem" },
232
238
  className
233
239
  }, props), {
234
- children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M224 152v56a16 16 0 0 1-16 16H48a16 16 0 0 1-16-16v-56a8 8 0 0 1 16 0v56h160v-56a8 8 0 0 1 16 0Zm-101.66 5.66a8 8 0 0 0 11.32 0l40-40a8 8 0 0 0-11.32-11.32L136 132.69V40a8 8 0 0 0-16 0v92.69l-26.34-26.35a8 8 0 0 0-11.32 11.32Z" })
240
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M224 152v56a16 16 0 0 1-16 16H48a16 16 0 0 1-16-16v-56a8 8 0 0 1 16 0v56h160v-56a8 8 0 0 1 16 0Zm-101.66 5.66a8 8 0 0 0 11.32 0l40-40a8 8 0 0 0-11.32-11.32L136 132.69V40a8 8 0 0 0-16 0v92.69l-26.34-26.35a8 8 0 0 0-11.32 11.32Z" })
235
241
  })
236
242
  );
237
243
  }
238
244
  function CopyIcon(_a) {
239
245
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
240
- return /* @__PURE__ */ jsxRuntime.jsx(
246
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
241
247
  "svg",
242
248
  __spreadProps(__spreadValues({
243
249
  xmlns: "http://www.w3.org/2000/svg",
@@ -246,33 +252,36 @@ function CopyIcon(_a) {
246
252
  style: { height: "1rem", width: "1rem" },
247
253
  className
248
254
  }, props), {
249
- children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M216 32H88a8 8 0 0 0-8 8v40H40a8 8 0 0 0-8 8v128a8 8 0 0 0 8 8h128a8 8 0 0 0 8-8v-40h40a8 8 0 0 0 8-8V40a8 8 0 0 0-8-8Zm-56 176H48V96h112Zm48-48h-32V88a8 8 0 0 0-8-8H96V48h112Z" })
255
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M216 32H88a8 8 0 0 0-8 8v40H40a8 8 0 0 0-8 8v128a8 8 0 0 0 8 8h128a8 8 0 0 0 8-8v-40h40a8 8 0 0 0 8-8V40a8 8 0 0 0-8-8Zm-56 176H48V96h112Zm48-48h-32V88a8 8 0 0 0-8-8H96V48h112Z" })
250
256
  })
251
257
  );
252
258
  }
253
- var StopIcon = /* @__PURE__ */ jsxRuntime.jsx(
259
+ var StopIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
254
260
  "svg",
255
261
  {
256
262
  xmlns: "http://www.w3.org/2000/svg",
257
263
  viewBox: "0 0 256 256",
258
264
  fill: "currentColor",
259
265
  style: { height: "1rem", width: "1rem" },
260
- children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M128 24a104 104 0 1 0 104 104A104.11 104.11 0 0 0 128 24Zm0 192a88 88 0 1 1 88-88 88.1 88.1 0 0 1-88 88Zm24-120h-48a8 8 0 0 0-8 8v48a8 8 0 0 0 8 8h48a8 8 0 0 0 8-8v-48a8 8 0 0 0-8-8Zm-8 48h-32v-32h32Z" })
266
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M128 24a104 104 0 1 0 104 104A104.11 104.11 0 0 0 128 24Zm0 192a88 88 0 1 1 88-88 88.1 88.1 0 0 1-88 88Zm24-120h-48a8 8 0 0 0-8 8v48a8 8 0 0 0 8 8h48a8 8 0 0 0 8-8v-48a8 8 0 0 0-8-8Zm-8 48h-32v-32h32Z" })
261
267
  }
262
268
  );
263
- var RegenerateIcon = /* @__PURE__ */ jsxRuntime.jsx(
269
+ var RegenerateIcon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
264
270
  "svg",
265
271
  {
266
272
  xmlns: "http://www.w3.org/2000/svg",
267
273
  viewBox: "0 0 256 256",
268
274
  fill: "currentColor",
269
275
  style: { height: "1rem", width: "1rem" },
270
- children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M197.67 186.37a8 8 0 0 1 0 11.29C196.58 198.73 170.82 224 128 224c-37.39 0-64.53-22.4-80-39.85V208a8 8 0 0 1-16 0v-48a8 8 0 0 1 8-8h48a8 8 0 0 1 0 16H55.44C67.76 183.35 93 208 128 208c36 0 58.14-21.46 58.36-21.68a8 8 0 0 1 11.31.05ZM216 40a8 8 0 0 0-8 8v23.85C192.53 54.4 165.39 32 128 32c-42.82 0-68.58 25.27-69.66 26.34a8 8 0 0 0 11.3 11.34C69.86 69.46 92 48 128 48c35 0 60.24 24.65 72.56 40H168a8 8 0 0 0 0 16h48a8 8 0 0 0 8-8V48a8 8 0 0 0-8-8Z" })
276
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M197.67 186.37a8 8 0 0 1 0 11.29C196.58 198.73 170.82 224 128 224c-37.39 0-64.53-22.4-80-39.85V208a8 8 0 0 1-16 0v-48a8 8 0 0 1 8-8h48a8 8 0 0 1 0 16H55.44C67.76 183.35 93 208 128 208c36 0 58.14-21.46 58.36-21.68a8 8 0 0 1 11.31.05ZM216 40a8 8 0 0 0-8 8v23.85C192.53 54.4 165.39 32 128 32c-42.82 0-68.58 25.27-69.66 26.34a8 8 0 0 0 11.3 11.34C69.86 69.46 92 48 128 48c35 0 60.24 24.65 72.56 40H168a8 8 0 0 0 0 16h48a8 8 0 0 0 8-8V48a8 8 0 0 0-8-8Z" })
271
277
  }
272
278
  );
273
- var ChatContext = React__namespace.default.createContext(void 0);
279
+
280
+ // src/components/chat/ChatContext.tsx
281
+ var import_jsx_runtime2 = require("react/jsx-runtime");
282
+ var ChatContext = import_react.default.createContext(void 0);
274
283
  function useChatContext() {
275
- const context = React__namespace.default.useContext(ChatContext);
284
+ const context = import_react.default.useContext(ChatContext);
276
285
  if (context === void 0) {
277
286
  throw new Error(
278
287
  "Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?"
@@ -288,7 +297,7 @@ var ChatContextProvider = ({
288
297
  icons,
289
298
  children
290
299
  }) => {
291
- const context = React.useMemo(
300
+ const context = (0, import_react.useMemo)(
292
301
  () => ({
293
302
  labels: __spreadValues(__spreadValues({}, {
294
303
  initial: "",
@@ -315,8 +324,15 @@ var ChatContextProvider = ({
315
324
  }),
316
325
  [labels, icons]
317
326
  );
318
- return /* @__PURE__ */ jsxRuntime.jsx(ChatContext.Provider, { value: context, children });
327
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ChatContext.Provider, { value: context, children });
319
328
  };
329
+
330
+ // src/components/chat/Chat.tsx
331
+ var import_react_core = require("@copilotkit/react-core");
332
+
333
+ // src/components/chat/Window.tsx
334
+ var import_react2 = __toESM(require("react"));
335
+ var import_jsx_runtime3 = require("react/jsx-runtime");
320
336
  var Window = ({
321
337
  open,
322
338
  setOpen,
@@ -325,8 +341,8 @@ var Window = ({
325
341
  hotkey,
326
342
  hitEscapeToClose
327
343
  }) => {
328
- const windowRef = React__namespace.default.useRef(null);
329
- const handleClickOutside = React.useCallback(
344
+ const windowRef = import_react2.default.useRef(null);
345
+ const handleClickOutside = (0, import_react2.useCallback)(
330
346
  (event) => {
331
347
  var _a;
332
348
  if (!clickOutsideToClose) {
@@ -339,7 +355,7 @@ var Window = ({
339
355
  },
340
356
  [clickOutsideToClose, open, setOpen]
341
357
  );
342
- const handleKeyDown = React.useCallback(
358
+ const handleKeyDown = (0, import_react2.useCallback)(
343
359
  (event) => {
344
360
  var _a;
345
361
  const target = event.target;
@@ -353,7 +369,7 @@ var Window = ({
353
369
  },
354
370
  [hitEscapeToClose, hotkey, open, setOpen]
355
371
  );
356
- const adjustForMobile = React.useCallback(() => {
372
+ const adjustForMobile = (0, import_react2.useCallback)(() => {
357
373
  const copilotKitWindow = windowRef.current;
358
374
  const vv = window.visualViewport;
359
375
  if (!copilotKitWindow || !vv) {
@@ -384,7 +400,7 @@ var Window = ({
384
400
  document.body.removeEventListener("touchmove", preventScroll);
385
401
  }
386
402
  }, [open]);
387
- React.useEffect(() => {
403
+ (0, import_react2.useEffect)(() => {
388
404
  document.addEventListener("mousedown", handleClickOutside);
389
405
  document.addEventListener("keydown", handleKeyDown);
390
406
  if (window.visualViewport) {
@@ -399,7 +415,7 @@ var Window = ({
399
415
  }
400
416
  };
401
417
  }, [adjustForMobile, handleClickOutside, handleKeyDown]);
402
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `copilotKitWindow${open ? " open" : ""}`, ref: windowRef, children });
418
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: `copilotKitWindow${open ? " open" : ""}`, ref: windowRef, children });
403
419
  };
404
420
  var preventScroll = (event) => {
405
421
  let targetElement = event.target;
@@ -419,29 +435,51 @@ var preventScroll = (event) => {
419
435
  function isMacOS() {
420
436
  return /Mac|iMac|Macintosh/i.test(navigator.userAgent);
421
437
  }
438
+
439
+ // src/components/chat/Button.tsx
440
+ var import_jsx_runtime4 = require("react/jsx-runtime");
422
441
  var Button = ({ open, setOpen }) => {
423
442
  const context = useChatContext();
424
- return /* @__PURE__ */ jsxRuntime.jsx("div", { onClick: () => setOpen(!open), children: /* @__PURE__ */ jsxRuntime.jsxs(
443
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { onClick: () => setOpen(!open), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
425
444
  "button",
426
445
  {
427
446
  className: `copilotKitButton ${open ? "open" : ""}`,
428
447
  "aria-label": open ? "Close Chat" : "Open Chat",
429
448
  children: [
430
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "copilotKitButtonIcon copilotKitButtonIconOpen", children: context.icons.openIcon }),
431
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "copilotKitButtonIcon copilotKitButtonIconClose", children: context.icons.closeIcon })
449
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "copilotKitButtonIcon copilotKitButtonIconOpen", children: context.icons.openIcon }),
450
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "copilotKitButtonIcon copilotKitButtonIconClose", children: context.icons.closeIcon })
432
451
  ]
433
452
  }
434
453
  ) });
435
454
  };
455
+
456
+ // src/components/chat/Header.tsx
457
+ var import_jsx_runtime5 = require("react/jsx-runtime");
436
458
  var Header = ({ setOpen }) => {
437
459
  const context = useChatContext();
438
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "copilotKitHeader", children: [
439
- /* @__PURE__ */ jsxRuntime.jsx("div", { children: context.labels.title }),
440
- /* @__PURE__ */ jsxRuntime.jsx("button", { onClick: () => setOpen(false), "aria-label": "Close", children: context.icons.headerCloseIcon })
460
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "copilotKitHeader", children: [
461
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: context.labels.title }),
462
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { onClick: () => setOpen(false), "aria-label": "Close", children: context.icons.headerCloseIcon })
441
463
  ] });
442
464
  };
465
+
466
+ // src/components/chat/Messages.tsx
467
+ var import_react5 = __toESM(require("react"));
468
+ var import_nanoid = require("nanoid");
469
+
470
+ // src/components/chat/Markdown.tsx
471
+ var import_react4 = require("react");
472
+ var import_react_markdown = __toESM(require("react-markdown"));
473
+
474
+ // src/components/chat/CodeBlock.tsx
475
+ var import_react3 = require("react");
476
+ var import_react_syntax_highlighter = require("react-syntax-highlighter");
477
+ var import_prism = require("react-syntax-highlighter/dist/esm/styles/prism");
478
+
479
+ // src/hooks/use-copy-to-clipboard.tsx
480
+ var React3 = __toESM(require("react"));
443
481
  function useCopyToClipboard({ timeout = 2e3 }) {
444
- const [isCopied, setIsCopied] = React__namespace.useState(false);
482
+ const [isCopied, setIsCopied] = React3.useState(false);
445
483
  const copyToClipboard = (value) => {
446
484
  var _a;
447
485
  if (typeof window === "undefined" || !((_a = navigator.clipboard) == null ? void 0 : _a.writeText)) {
@@ -459,6 +497,9 @@ function useCopyToClipboard({ timeout = 2e3 }) {
459
497
  };
460
498
  return { isCopied, copyToClipboard };
461
499
  }
500
+
501
+ // src/components/chat/CodeBlock.tsx
502
+ var import_jsx_runtime6 = require("react/jsx-runtime");
462
503
  var programmingLanguages = {
463
504
  javascript: ".js",
464
505
  python: ".py",
@@ -493,7 +534,7 @@ var generateRandomString = (length, lowercase = false) => {
493
534
  }
494
535
  return lowercase ? result.toLowerCase() : result;
495
536
  };
496
- var CodeBlock = React.memo(({ language, value }) => {
537
+ var CodeBlock = (0, import_react3.memo)(({ language, value }) => {
497
538
  const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2e3 });
498
539
  const downloadAsFile = () => {
499
540
  if (typeof window === "undefined") {
@@ -521,25 +562,25 @@ var CodeBlock = React.memo(({ language, value }) => {
521
562
  return;
522
563
  copyToClipboard(value);
523
564
  };
524
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "copilotKitCodeBlock", children: [
525
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "copilotKitCodeBlockToolbar", children: [
526
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "copilotKitCodeBlockToolbarLanguage", children: language }),
527
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "copilotKitCodeBlockToolbarButtons", children: [
528
- /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "copilotKitCodeBlockToolbarButton", onClick: downloadAsFile, children: [
529
- /* @__PURE__ */ jsxRuntime.jsx(DownloadIcon, {}),
530
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Download" })
565
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "copilotKitCodeBlock", children: [
566
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "copilotKitCodeBlockToolbar", children: [
567
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "copilotKitCodeBlockToolbarLanguage", children: language }),
568
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "copilotKitCodeBlockToolbarButtons", children: [
569
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { className: "copilotKitCodeBlockToolbarButton", onClick: downloadAsFile, children: [
570
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DownloadIcon, {}),
571
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "sr-only", children: "Download" })
531
572
  ] }),
532
- /* @__PURE__ */ jsxRuntime.jsxs("button", { className: "copilotKitCodeBlockToolbarButton", onClick: onCopy, children: [
533
- isCopied ? /* @__PURE__ */ jsxRuntime.jsx(CheckIcon, {}) : /* @__PURE__ */ jsxRuntime.jsx(CopyIcon, {}),
534
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Copy code" })
573
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { className: "copilotKitCodeBlockToolbarButton", onClick: onCopy, children: [
574
+ isCopied ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CheckIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CopyIcon, {}),
575
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "sr-only", children: "Copy code" })
535
576
  ] })
536
577
  ] })
537
578
  ] }),
538
- /* @__PURE__ */ jsxRuntime.jsx(
539
- reactSyntaxHighlighter.Prism,
579
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
580
+ import_react_syntax_highlighter.Prism,
540
581
  {
541
582
  language,
542
- style: prism.vscDarkPlus,
583
+ style: import_prism.vscDarkPlus,
543
584
  PreTag: "div",
544
585
  customStyle: {
545
586
  margin: 0,
@@ -552,22 +593,27 @@ var CodeBlock = React.memo(({ language, value }) => {
552
593
  ] });
553
594
  });
554
595
  CodeBlock.displayName = "CodeBlock";
555
- var MemoizedReactMarkdown = React.memo(
556
- ReactMarkdown__default.default,
596
+
597
+ // src/components/chat/Markdown.tsx
598
+ var import_remark_gfm = __toESM(require("remark-gfm"));
599
+ var import_remark_math = __toESM(require("remark-math"));
600
+ var import_jsx_runtime7 = require("react/jsx-runtime");
601
+ var MemoizedReactMarkdown = (0, import_react4.memo)(
602
+ import_react_markdown.default,
557
603
  (prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.className === nextProps.className
558
604
  );
559
605
  var Markdown = ({ content }) => {
560
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "copilotKitMarkdown", children: /* @__PURE__ */ jsxRuntime.jsx(MemoizedReactMarkdown, { components, remarkPlugins: [remarkGfm__default.default, remarkMath__default.default], children: content }) });
606
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "copilotKitMarkdown", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MemoizedReactMarkdown, { components, remarkPlugins: [import_remark_gfm.default, import_remark_math.default], children: content }) });
561
607
  };
562
608
  var components = {
563
609
  p({ children }) {
564
- return /* @__PURE__ */ jsxRuntime.jsx("p", { children });
610
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { children });
565
611
  },
566
612
  code(_a) {
567
613
  var _b = _a, { children, className, inline } = _b, props = __objRest(_b, ["children", "className", "inline"]);
568
614
  if (children.length) {
569
615
  if (children[0] == "\u258D") {
570
- return /* @__PURE__ */ jsxRuntime.jsx(
616
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
571
617
  "span",
572
618
  {
573
619
  style: {
@@ -582,9 +628,9 @@ var components = {
582
628
  }
583
629
  const match = /language-(\w+)/.exec(className || "");
584
630
  if (inline) {
585
- return /* @__PURE__ */ jsxRuntime.jsx("code", __spreadProps(__spreadValues({ className }, props), { children }));
631
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", __spreadProps(__spreadValues({ className }, props), { children }));
586
632
  }
587
- return /* @__PURE__ */ jsxRuntime.jsx(
633
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
588
634
  CodeBlock,
589
635
  __spreadValues({
590
636
  language: match && match[1] || "",
@@ -594,14 +640,17 @@ var components = {
594
640
  );
595
641
  }
596
642
  };
643
+
644
+ // src/components/chat/Messages.tsx
645
+ var import_jsx_runtime8 = require("react/jsx-runtime");
597
646
  var Messages = ({ messages, inProgress }) => {
598
647
  const context = useChatContext();
599
- const initialMessages = React.useMemo(
648
+ const initialMessages = (0, import_react5.useMemo)(
600
649
  () => makeInitialMessages(context.labels.initial),
601
650
  [context.labels.initial]
602
651
  );
603
652
  messages = [...initialMessages, ...messages];
604
- const messagesEndRef = React__namespace.default.useRef(null);
653
+ const messagesEndRef = import_react5.default.useRef(null);
605
654
  const scrollToBottom = () => {
606
655
  if (messagesEndRef.current) {
607
656
  messagesEndRef.current.scrollIntoView({
@@ -609,25 +658,25 @@ var Messages = ({ messages, inProgress }) => {
609
658
  });
610
659
  }
611
660
  };
612
- React.useEffect(() => {
661
+ (0, import_react5.useEffect)(() => {
613
662
  scrollToBottom();
614
663
  }, [messages]);
615
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "copilotKitMessages", children: [
664
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "copilotKitMessages", children: [
616
665
  messages.map((message, index) => {
617
666
  const isCurrentMessage = index === messages.length - 1;
618
667
  if (message.role === "user") {
619
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "copilotKitMessage copilotKitUserMessage", children: message.content }, index);
668
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "copilotKitMessage copilotKitUserMessage", children: message.content }, index);
620
669
  } else if (message.role == "assistant") {
621
670
  if (isCurrentMessage && inProgress && !message.content) {
622
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: context.icons.spinnerIcon }, index);
671
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: context.icons.spinnerIcon }, index);
623
672
  } else if ((!inProgress || index != messages.length - 1) && !message.content && message.function_call) {
624
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: context.labels.done }, index);
673
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: context.labels.done }, index);
625
674
  } else {
626
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: /* @__PURE__ */ jsxRuntime.jsx(Markdown, { content: message.content }) }, index);
675
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Markdown, { content: message.content }) }, index);
627
676
  }
628
677
  }
629
678
  }),
630
- /* @__PURE__ */ jsxRuntime.jsx("div", { ref: messagesEndRef })
679
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ref: messagesEndRef })
631
680
  ] });
632
681
  };
633
682
  function makeInitialMessages(initial) {
@@ -640,17 +689,24 @@ function makeInitialMessages(initial) {
640
689
  }
641
690
  }
642
691
  return initialArray.map((message) => ({
643
- id: nanoid.nanoid(),
692
+ id: (0, import_nanoid.nanoid)(),
644
693
  role: "assistant",
645
694
  content: message
646
695
  }));
647
696
  }
648
- var AutoResizingTextarea = React.forwardRef(
697
+
698
+ // src/components/chat/Input.tsx
699
+ var import_react7 = require("react");
700
+
701
+ // src/components/chat/Textarea.tsx
702
+ var import_react6 = require("react");
703
+ var import_jsx_runtime9 = require("react/jsx-runtime");
704
+ var AutoResizingTextarea = (0, import_react6.forwardRef)(
649
705
  ({ maxRows = 1, placeholder, value, onChange, onKeyDown, autoFocus }, ref) => {
650
- const internalTextareaRef = React.useRef(null);
651
- const [maxHeight, setMaxHeight] = React.useState(0);
652
- React.useImperativeHandle(ref, () => internalTextareaRef.current);
653
- React.useEffect(() => {
706
+ const internalTextareaRef = (0, import_react6.useRef)(null);
707
+ const [maxHeight, setMaxHeight] = (0, import_react6.useState)(0);
708
+ (0, import_react6.useImperativeHandle)(ref, () => internalTextareaRef.current);
709
+ (0, import_react6.useEffect)(() => {
654
710
  const calculateMaxHeight = () => {
655
711
  const textarea = internalTextareaRef.current;
656
712
  if (textarea) {
@@ -664,14 +720,14 @@ var AutoResizingTextarea = React.forwardRef(
664
720
  };
665
721
  calculateMaxHeight();
666
722
  }, [maxRows]);
667
- React.useEffect(() => {
723
+ (0, import_react6.useEffect)(() => {
668
724
  const textarea = internalTextareaRef.current;
669
725
  if (textarea) {
670
726
  textarea.style.height = "auto";
671
727
  textarea.style.height = `${Math.min(textarea.scrollHeight, maxHeight)}px`;
672
728
  }
673
729
  }, [value, maxHeight]);
674
- return /* @__PURE__ */ jsxRuntime.jsx(
730
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
675
731
  "textarea",
676
732
  {
677
733
  ref: internalTextareaRef,
@@ -690,16 +746,19 @@ var AutoResizingTextarea = React.forwardRef(
690
746
  }
691
747
  );
692
748
  var Textarea_default = AutoResizingTextarea;
749
+
750
+ // src/components/chat/Input.tsx
751
+ var import_jsx_runtime10 = require("react/jsx-runtime");
693
752
  var Input = ({ inProgress, onSend, children }) => {
694
753
  const context = useChatContext();
695
- const textareaRef = React.useRef(null);
754
+ const textareaRef = (0, import_react7.useRef)(null);
696
755
  const handleDivClick = (event) => {
697
756
  var _a;
698
757
  if (event.target !== event.currentTarget)
699
758
  return;
700
759
  (_a = textareaRef.current) == null ? void 0 : _a.focus();
701
760
  };
702
- const [text, setText] = React.useState("");
761
+ const [text, setText] = (0, import_react7.useState)("");
703
762
  const send = () => {
704
763
  var _a;
705
764
  if (inProgress)
@@ -710,10 +769,10 @@ var Input = ({ inProgress, onSend, children }) => {
710
769
  };
711
770
  const icon = inProgress ? context.icons.activityIcon : context.icons.sendIcon;
712
771
  const disabled = inProgress || text.length === 0;
713
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "copilotKitInput", onClick: handleDivClick, children: [
714
- /* @__PURE__ */ jsxRuntime.jsx("span", { children }),
715
- /* @__PURE__ */ jsxRuntime.jsx("button", { className: "copilotKitSendButton", disabled, onClick: send, children: icon }),
716
- /* @__PURE__ */ jsxRuntime.jsx(
772
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "copilotKitInput", onClick: handleDivClick, children: [
773
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children }),
774
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { className: "copilotKitSendButton", disabled, onClick: send, children: icon }),
775
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
717
776
  Textarea_default,
718
777
  {
719
778
  ref: textareaRef,
@@ -732,13 +791,22 @@ var Input = ({ inProgress, onSend, children }) => {
732
791
  )
733
792
  ] });
734
793
  };
794
+
795
+ // src/components/chat/Chat.tsx
796
+ var import_nanoid2 = require("nanoid");
797
+
798
+ // src/components/chat/Response.tsx
799
+ var import_jsx_runtime11 = require("react/jsx-runtime");
735
800
  var ResponseButton = ({ onClick, inProgress }) => {
736
801
  const context = useChatContext();
737
- return /* @__PURE__ */ jsxRuntime.jsxs("button", { onClick, className: "copilotKitResponseButton", children: [
738
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: inProgress ? context.icons.stopIcon : context.icons.regenerateIcon }),
802
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("button", { onClick, className: "copilotKitResponseButton", children: [
803
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { children: inProgress ? context.icons.stopIcon : context.icons.regenerateIcon }),
739
804
  inProgress ? context.labels.stopGenerating : context.labels.regenerateResponse
740
805
  ] });
741
806
  };
807
+
808
+ // src/components/chat/Chat.tsx
809
+ var import_jsx_runtime12 = require("react/jsx-runtime");
742
810
  var CopilotChat = ({
743
811
  instructions,
744
812
  defaultOpen = false,
@@ -758,26 +826,26 @@ var CopilotChat = ({
758
826
  ResponseButton: ResponseButton2 = ResponseButton,
759
827
  className
760
828
  }) => {
761
- const { visibleMessages, append, reload, stop, isLoading, input, setInput } = reactCore.useCopilotChat({
762
- id: nanoid.nanoid(),
829
+ const { visibleMessages, append, reload, stop, isLoading, input, setInput } = (0, import_react_core.useCopilotChat)({
830
+ id: (0, import_nanoid2.nanoid)(),
763
831
  makeSystemMessage,
764
832
  additionalInstructions: instructions
765
833
  });
766
- const [openState, setOpenState] = React__namespace.default.useState(defaultOpen);
834
+ const [openState, setOpenState] = import_react8.default.useState(defaultOpen);
767
835
  const setOpen = (open) => {
768
836
  onSetOpen == null ? void 0 : onSetOpen(open);
769
837
  setOpenState(open);
770
838
  };
771
839
  const sendMessage = (message) => __async(void 0, null, function* () {
772
840
  append({
773
- id: nanoid.nanoid(),
841
+ id: (0, import_nanoid2.nanoid)(),
774
842
  content: message,
775
843
  role: "user"
776
844
  });
777
845
  });
778
- return /* @__PURE__ */ jsxRuntime.jsx(ChatContextProvider, { icons, labels, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className, children: [
779
- /* @__PURE__ */ jsxRuntime.jsx(Button2, { open: openState, setOpen }),
780
- /* @__PURE__ */ jsxRuntime.jsxs(
846
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChatContextProvider, { icons, labels, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className, children: [
847
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button2, { open: openState, setOpen }),
848
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
781
849
  Window2,
782
850
  {
783
851
  open: openState,
@@ -786,25 +854,32 @@ var CopilotChat = ({
786
854
  hotkey,
787
855
  hitEscapeToClose,
788
856
  children: [
789
- /* @__PURE__ */ jsxRuntime.jsx(Header2, { open: openState, setOpen }),
790
- /* @__PURE__ */ jsxRuntime.jsx(Messages2, { messages: visibleMessages, inProgress: isLoading }),
791
- /* @__PURE__ */ jsxRuntime.jsx(Input2, { inProgress: isLoading, onSend: sendMessage, children: showResponseButton && visibleMessages.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(ResponseButton2, { onClick: isLoading ? stop : reload, inProgress: isLoading }) })
857
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Header2, { open: openState, setOpen }),
858
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Messages2, { messages: visibleMessages, inProgress: isLoading }),
859
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Input2, { inProgress: isLoading, onSend: sendMessage, children: showResponseButton && visibleMessages.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ResponseButton2, { onClick: isLoading ? stop : reload, inProgress: isLoading }) })
792
860
  ]
793
861
  }
794
862
  )
795
863
  ] }) });
796
864
  };
865
+
866
+ // src/components/chat/Popup.tsx
867
+ var import_jsx_runtime13 = require("react/jsx-runtime");
797
868
  var CopilotPopup = (props) => {
798
869
  props = __spreadProps(__spreadValues({}, props), {
799
870
  className: props.className ? props.className + " copilotKitPopup" : "copilotKitPopup"
800
871
  });
801
- return /* @__PURE__ */ jsxRuntime.jsx(CopilotChat, __spreadValues({}, props));
872
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(CopilotChat, __spreadValues({}, props));
802
873
  };
874
+
875
+ // src/components/chat/Sidebar.tsx
876
+ var import_react9 = require("react");
877
+ var import_jsx_runtime14 = require("react/jsx-runtime");
803
878
  var CopilotSidebar = (props) => {
804
879
  props = __spreadProps(__spreadValues({}, props), {
805
880
  className: props.className ? props.className + " copilotKitSidebar" : "copilotKitSidebar"
806
881
  });
807
- const [expandedClassName, setExpandedClassName] = React.useState(
882
+ const [expandedClassName, setExpandedClassName] = (0, import_react9.useState)(
808
883
  props.defaultOpen ? "sidebarExpanded" : ""
809
884
  );
810
885
  const onSetOpen = (open) => {
@@ -812,13 +887,14 @@ var CopilotSidebar = (props) => {
812
887
  (_a = props.onSetOpen) == null ? void 0 : _a.call(props, open);
813
888
  setExpandedClassName(open ? "sidebarExpanded" : "");
814
889
  };
815
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `copilotKitSidebarContentWrapper ${expandedClassName}`, children: [
890
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: `copilotKitSidebarContentWrapper ${expandedClassName}`, children: [
816
891
  props.children,
817
- /* @__PURE__ */ jsxRuntime.jsx(CopilotChat, __spreadValues(__spreadValues({}, props), { onSetOpen }))
892
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CopilotChat, __spreadValues(__spreadValues({}, props), { onSetOpen }))
818
893
  ] });
819
894
  };
820
-
821
- exports.CopilotPopup = CopilotPopup;
822
- exports.CopilotSidebar = CopilotSidebar;
823
- //# sourceMappingURL=out.js.map
895
+ // Annotate the CommonJS export names for ESM import in node:
896
+ 0 && (module.exports = {
897
+ CopilotPopup,
898
+ CopilotSidebar
899
+ });
824
900
  //# sourceMappingURL=index.js.map