@copilotkit/react-ui 0.22.0-multi-release-alpha.0 → 0.22.0-multi-feature-usecopilotreadable.4

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 (45) hide show
  1. package/.turbo/turbo-build.log +89 -93
  2. package/CHANGELOG.md +52 -4
  3. package/dist/components/chat/Button.mjs +6 -30
  4. package/dist/components/chat/Button.mjs.map +1 -1
  5. package/dist/components/chat/Chat.mjs +16 -1198
  6. package/dist/components/chat/Chat.mjs.map +1 -1
  7. package/dist/components/chat/ChatContext.mjs +7 -217
  8. package/dist/components/chat/ChatContext.mjs.map +1 -1
  9. package/dist/components/chat/CodeBlock.mjs +8 -483
  10. package/dist/components/chat/CodeBlock.mjs.map +1 -1
  11. package/dist/components/chat/Header.mjs +6 -23
  12. package/dist/components/chat/Header.mjs.map +1 -1
  13. package/dist/components/chat/Icons.mjs +14 -218
  14. package/dist/components/chat/Icons.mjs.map +1 -1
  15. package/dist/components/chat/Input.mjs +7 -116
  16. package/dist/components/chat/Input.mjs.map +1 -1
  17. package/dist/components/chat/Markdown.mjs +7 -547
  18. package/dist/components/chat/Markdown.mjs.map +1 -1
  19. package/dist/components/chat/Messages.mjs +9 -678
  20. package/dist/components/chat/Messages.mjs.map +1 -1
  21. package/dist/components/chat/Popup.mjs +17 -1207
  22. package/dist/components/chat/Popup.mjs.map +1 -1
  23. package/dist/components/chat/Response.mjs +6 -23
  24. package/dist/components/chat/Response.mjs.map +1 -1
  25. package/dist/components/chat/Sidebar.mjs +17 -1218
  26. package/dist/components/chat/Sidebar.mjs.map +1 -1
  27. package/dist/components/chat/Textarea.mjs +4 -48
  28. package/dist/components/chat/Textarea.mjs.map +1 -1
  29. package/dist/components/chat/Window.mjs +4 -105
  30. package/dist/components/chat/Window.mjs.map +1 -1
  31. package/dist/components/chat/index.mjs +24 -1225
  32. package/dist/components/chat/index.mjs.map +1 -1
  33. package/dist/components/chat/props.mjs +1 -0
  34. package/dist/components/index.mjs +25 -1225
  35. package/dist/components/index.mjs.map +1 -1
  36. package/dist/context/index.mjs +1 -0
  37. package/dist/hooks/index.mjs +1 -0
  38. package/dist/hooks/use-copy-to-clipboard.mjs +4 -21
  39. package/dist/hooks/use-copy-to-clipboard.mjs.map +1 -1
  40. package/dist/index.mjs +28 -1225
  41. package/dist/index.mjs.map +1 -1
  42. package/dist/lib/utils.mjs +3 -20
  43. package/dist/lib/utils.mjs.map +1 -1
  44. package/dist/types/index.mjs +1 -0
  45. package/package.json +6 -6
@@ -1,1201 +1,19 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __objRest = (source, exclude) => {
21
- var target = {};
22
- for (var prop in source)
23
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
- target[prop] = source[prop];
25
- if (source != null && __getOwnPropSymbols)
26
- for (var prop of __getOwnPropSymbols(source)) {
27
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
- target[prop] = source[prop];
29
- }
30
- return target;
31
- };
32
- var __async = (__this, __arguments, generator) => {
33
- return new Promise((resolve, reject) => {
34
- var fulfilled = (value) => {
35
- try {
36
- step(generator.next(value));
37
- } catch (e) {
38
- reject(e);
39
- }
40
- };
41
- var rejected = (value) => {
42
- try {
43
- step(generator.throw(value));
44
- } catch (e) {
45
- reject(e);
46
- }
47
- };
48
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
49
- step((generator = generator.apply(__this, __arguments)).next());
50
- });
51
- };
52
-
53
- // src/components/chat/Chat.tsx
54
- import React7, { useEffect as useEffect5 } from "react";
55
-
56
- // src/components/chat/ChatContext.tsx
57
- import React, { useMemo } from "react";
58
-
59
- // src/components/chat/Icons.tsx
60
- import { jsx, jsxs } from "react/jsx-runtime";
61
- var OpenIcon = /* @__PURE__ */ jsx(
62
- "svg",
63
- {
64
- xmlns: "http://www.w3.org/2000/svg",
65
- viewBox: "0 0 24 24",
66
- fill: "currentColor",
67
- width: "24",
68
- height: "24",
69
- children: /* @__PURE__ */ jsx("g", { transform: "translate(24, 0) scale(-1, 1)", children: /* @__PURE__ */ jsx(
70
- "path",
71
- {
72
- fillRule: "evenodd",
73
- d: "M5.337 21.718a6.707 6.707 0 01-.533-.074.75.75 0 01-.44-1.223 3.73 3.73 0 00.814-1.686c.023-.115-.022-.317-.254-.543C3.274 16.587 2.25 14.41 2.25 12c0-5.03 4.428-9 9.75-9s9.75 3.97 9.75 9c0 5.03-4.428 9-9.75 9-.833 0-1.643-.097-2.417-.279a6.721 6.721 0 01-4.246.997z",
74
- clipRule: "evenodd"
75
- }
76
- ) })
77
- }
78
- );
79
- var CloseIcon = /* @__PURE__ */ jsx(
80
- "svg",
81
- {
82
- xmlns: "http://www.w3.org/2000/svg",
83
- fill: "none",
84
- viewBox: "0 0 24 24",
85
- strokeWidth: "1.5",
86
- stroke: "currentColor",
87
- width: "24",
88
- height: "24",
89
- children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19.5 8.25l-7.5 7.5-7.5-7.5" })
90
- }
91
- );
92
- var HeaderCloseIcon = /* @__PURE__ */ jsx(
93
- "svg",
94
- {
95
- xmlns: "http://www.w3.org/2000/svg",
96
- fill: "none",
97
- viewBox: "0 0 24 24",
98
- strokeWidth: "1.5",
99
- stroke: "currentColor",
100
- width: "24",
101
- height: "24",
102
- children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
103
- }
104
- );
105
- var SendIcon = /* @__PURE__ */ jsx(
106
- "svg",
107
- {
108
- xmlns: "http://www.w3.org/2000/svg",
109
- fill: "none",
110
- viewBox: "0 0 24 24",
111
- strokeWidth: 1.5,
112
- stroke: "currentColor",
113
- width: "24",
114
- height: "24",
115
- children: /* @__PURE__ */ jsx(
116
- "path",
117
- {
118
- strokeLinecap: "round",
119
- strokeLinejoin: "round",
120
- d: "M6 12L3.269 3.126A59.768 59.768 0 0121.485 12 59.77 59.77 0 013.27 20.876L5.999 12zm0 0h7.5"
121
- }
122
- )
123
- }
124
- );
125
- var SpinnerIcon = /* @__PURE__ */ jsxs(
126
- "svg",
127
- {
128
- style: {
129
- animation: "copilotKitSpinAnimation 1s linear infinite",
130
- color: "rgb(107 114 128)"
131
- },
132
- width: "24",
133
- height: "24",
134
- xmlns: "http://www.w3.org/2000/svg",
135
- fill: "none",
136
- viewBox: "0 0 24 24",
137
- children: [
138
- /* @__PURE__ */ jsx(
139
- "circle",
140
- {
141
- style: { opacity: 0.25 },
142
- cx: "12",
143
- cy: "12",
144
- r: "10",
145
- stroke: "currentColor",
146
- strokeWidth: "4"
147
- }
148
- ),
149
- /* @__PURE__ */ jsx(
150
- "path",
151
- {
152
- style: { opacity: 0.75 },
153
- fill: "currentColor",
154
- d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
155
- }
156
- )
157
- ]
158
- }
159
- );
160
- var ActivityIcon = /* @__PURE__ */ jsxs(
161
- "svg",
162
- {
163
- style: {
164
- display: "inline-block",
165
- marginLeft: "0.25rem",
166
- marginRight: "0.25rem"
167
- },
168
- height: "24",
169
- width: "24",
170
- viewBox: "0 0 27 27",
171
- xmlns: "http://www.w3.org/2000/svg",
172
- fill: "currentColor",
173
- children: [
174
- /* @__PURE__ */ jsx("circle", { className: "copilotKitActivityDot1", cx: "4", cy: "12", r: "3" }),
175
- /* @__PURE__ */ jsx("circle", { className: "copilotKitActivityDot1 copilotKitActivityDot2", cx: "12", cy: "12", r: "3" }),
176
- /* @__PURE__ */ jsx("circle", { className: "copilotKitActivityDot1 copilotKitActivityDot3", cx: "20", cy: "12", r: "3" })
177
- ]
178
- }
179
- );
180
- function CheckIcon(_a) {
181
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
182
- return /* @__PURE__ */ jsx(
183
- "svg",
184
- __spreadProps(__spreadValues({
185
- xmlns: "http://www.w3.org/2000/svg",
186
- viewBox: "0 0 256 256",
187
- fill: "currentColor",
188
- style: { height: "1rem", width: "1rem" },
189
- className
190
- }, props), {
191
- children: /* @__PURE__ */ 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" })
192
- })
193
- );
194
- }
195
- function DownloadIcon(_a) {
196
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
197
- return /* @__PURE__ */ jsx(
198
- "svg",
199
- __spreadProps(__spreadValues({
200
- xmlns: "http://www.w3.org/2000/svg",
201
- viewBox: "0 0 256 256",
202
- fill: "currentColor",
203
- style: { height: "1rem", width: "1rem" },
204
- className
205
- }, props), {
206
- children: /* @__PURE__ */ 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" })
207
- })
208
- );
209
- }
210
- function CopyIcon(_a) {
211
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
212
- return /* @__PURE__ */ jsx(
213
- "svg",
214
- __spreadProps(__spreadValues({
215
- xmlns: "http://www.w3.org/2000/svg",
216
- viewBox: "0 0 256 256",
217
- fill: "currentColor",
218
- style: { height: "1rem", width: "1rem" },
219
- className
220
- }, props), {
221
- children: /* @__PURE__ */ 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" })
222
- })
223
- );
224
- }
225
- var StopIcon = /* @__PURE__ */ jsx(
226
- "svg",
227
- {
228
- xmlns: "http://www.w3.org/2000/svg",
229
- viewBox: "0 0 256 256",
230
- fill: "currentColor",
231
- style: { height: "1rem", width: "1rem" },
232
- children: /* @__PURE__ */ 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" })
233
- }
234
- );
235
- var RegenerateIcon = /* @__PURE__ */ jsx(
236
- "svg",
237
- {
238
- xmlns: "http://www.w3.org/2000/svg",
239
- viewBox: "0 0 256 256",
240
- fill: "currentColor",
241
- style: { height: "1rem", width: "1rem" },
242
- children: /* @__PURE__ */ 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" })
243
- }
244
- );
245
-
246
- // src/components/chat/ChatContext.tsx
247
- import { jsx as jsx2 } from "react/jsx-runtime";
248
- var ChatContext = React.createContext(void 0);
249
- function useChatContext() {
250
- const context = React.useContext(ChatContext);
251
- if (context === void 0) {
252
- throw new Error(
253
- "Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?"
254
- );
255
- }
256
- return context;
257
- }
258
- var ChatContextProvider = ({
259
- // temperature,
260
- // instructions,
261
- // maxFeedback,
262
- labels,
263
- icons,
264
- children,
265
- open,
266
- setOpen
267
- }) => {
268
- const context = useMemo(
269
- () => ({
270
- labels: __spreadValues(__spreadValues({}, {
271
- initial: "",
272
- title: "CopilotKit",
273
- placeholder: "Type a message...",
274
- thinking: "Thinking...",
275
- error: "\u274C An error occurred. Please try again.",
276
- stopGenerating: "Stop generating",
277
- regenerateResponse: "Regenerate response"
278
- }), labels),
279
- icons: __spreadProps(__spreadValues({}, {
280
- openIcon: OpenIcon,
281
- closeIcon: CloseIcon,
282
- headerCloseIcon: HeaderCloseIcon,
283
- sendIcon: SendIcon,
284
- activityIcon: ActivityIcon,
285
- spinnerIcon: SpinnerIcon,
286
- stopIcon: StopIcon,
287
- regenerateIcon: RegenerateIcon
288
- }), {
289
- icons
290
- }),
291
- open,
292
- setOpen
293
- }),
294
- [labels, icons, open, setOpen]
295
- );
296
- return /* @__PURE__ */ jsx2(ChatContext.Provider, { value: context, children });
297
- };
298
-
299
- // src/components/chat/Chat.tsx
300
- import { useCopilotChat } from "@copilotkit/react-core";
301
-
302
- // src/components/chat/Window.tsx
303
- import React2, { useCallback, useEffect } from "react";
304
- import { jsx as jsx3 } from "react/jsx-runtime";
305
- var Window = ({
306
- open,
307
- setOpen,
308
- children,
309
- clickOutsideToClose,
310
- shortcut,
311
- hitEscapeToClose
312
- }) => {
313
- const windowRef = React2.useRef(null);
314
- const handleClickOutside = useCallback(
315
- (event) => {
316
- var _a;
317
- if (!clickOutsideToClose) {
318
- return;
319
- }
320
- const parentElement = (_a = windowRef.current) == null ? void 0 : _a.parentElement;
321
- if (open && parentElement && !parentElement.contains(event.target)) {
322
- setOpen(false);
323
- }
324
- },
325
- [clickOutsideToClose, open, setOpen]
326
- );
327
- const handleKeyDown = useCallback(
328
- (event) => {
329
- var _a;
330
- const target = event.target;
331
- const isInput = target.tagName === "INPUT" || target.tagName === "SELECT" || target.tagName === "TEXTAREA" || target.isContentEditable;
332
- const isDescendantOfWrapper = (_a = windowRef.current) == null ? void 0 : _a.contains(target);
333
- if (open && event.key === "Escape" && (!isInput || isDescendantOfWrapper) && hitEscapeToClose) {
334
- setOpen(false);
335
- } else if (event.key === shortcut && (isMacOS() && event.metaKey || !isMacOS() && event.ctrlKey) && (!isInput || isDescendantOfWrapper)) {
336
- setOpen(!open);
337
- }
338
- },
339
- [hitEscapeToClose, shortcut, open, setOpen]
340
- );
341
- const adjustForMobile = useCallback(() => {
342
- const copilotKitWindow = windowRef.current;
343
- const vv = window.visualViewport;
344
- if (!copilotKitWindow || !vv) {
345
- return;
346
- }
347
- if (window.innerWidth < 640 && open) {
348
- copilotKitWindow.style.height = `${vv.height}px`;
349
- copilotKitWindow.style.left = `${vv.offsetLeft}px`;
350
- copilotKitWindow.style.top = `${vv.offsetTop}px`;
351
- document.body.style.position = "fixed";
352
- document.body.style.width = "100%";
353
- document.body.style.height = `${window.innerHeight}px`;
354
- document.body.style.overflow = "hidden";
355
- document.body.style.touchAction = "none";
356
- document.body.addEventListener("touchmove", preventScroll, {
357
- passive: false
358
- });
359
- } else {
360
- copilotKitWindow.style.height = "";
361
- copilotKitWindow.style.left = "";
362
- copilotKitWindow.style.top = "";
363
- document.body.style.position = "";
364
- document.body.style.height = "";
365
- document.body.style.width = "";
366
- document.body.style.overflow = "";
367
- document.body.style.top = "";
368
- document.body.style.touchAction = "";
369
- document.body.removeEventListener("touchmove", preventScroll);
370
- }
371
- }, [open]);
372
- useEffect(() => {
373
- document.addEventListener("mousedown", handleClickOutside);
374
- document.addEventListener("keydown", handleKeyDown);
375
- if (window.visualViewport) {
376
- window.visualViewport.addEventListener("resize", adjustForMobile);
377
- adjustForMobile();
378
- }
379
- return () => {
380
- document.removeEventListener("mousedown", handleClickOutside);
381
- document.removeEventListener("keydown", handleKeyDown);
382
- if (window.visualViewport) {
383
- window.visualViewport.removeEventListener("resize", adjustForMobile);
384
- }
385
- };
386
- }, [adjustForMobile, handleClickOutside, handleKeyDown]);
387
- return /* @__PURE__ */ jsx3("div", { className: `copilotKitWindow${open ? " open" : ""}`, ref: windowRef, children });
388
- };
389
- var preventScroll = (event) => {
390
- let targetElement = event.target;
391
- const hasParentWithClass = (element, className) => {
392
- while (element && element !== document.body) {
393
- if (element.classList.contains(className)) {
394
- return true;
395
- }
396
- element = element.parentElement;
397
- }
398
- return false;
399
- };
400
- if (!hasParentWithClass(targetElement, "copilotKitMessages")) {
401
- event.preventDefault();
402
- }
403
- };
404
- function isMacOS() {
405
- return /Mac|iMac|Macintosh/i.test(navigator.userAgent);
406
- }
407
-
408
- // src/components/chat/Button.tsx
409
- import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
410
- var Button = ({ open, setOpen }) => {
411
- const context = useChatContext();
412
- return /* @__PURE__ */ jsx4("div", { onClick: () => setOpen(!open), children: /* @__PURE__ */ jsxs2(
413
- "button",
414
- {
415
- className: `copilotKitButton ${open ? "open" : ""}`,
416
- "aria-label": open ? "Close Chat" : "Open Chat",
417
- children: [
418
- /* @__PURE__ */ jsx4("div", { className: "copilotKitButtonIcon copilotKitButtonIconOpen", children: context.icons.openIcon }),
419
- /* @__PURE__ */ jsx4("div", { className: "copilotKitButtonIcon copilotKitButtonIconClose", children: context.icons.closeIcon })
420
- ]
421
- }
422
- ) });
423
- };
424
-
425
- // src/components/chat/Header.tsx
426
- import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
427
- var Header = ({ setOpen }) => {
428
- const context = useChatContext();
429
- return /* @__PURE__ */ jsxs3("div", { className: "copilotKitHeader", children: [
430
- /* @__PURE__ */ jsx5("div", { children: context.labels.title }),
431
- /* @__PURE__ */ jsx5("button", { onClick: () => setOpen(false), "aria-label": "Close", children: context.icons.headerCloseIcon })
432
- ] });
433
- };
434
-
435
- // src/components/chat/Messages.tsx
436
- import React4, { useEffect as useEffect2, useMemo as useMemo2 } from "react";
437
- import { nanoid } from "nanoid";
438
- import { decodeResult } from "@copilotkit/shared";
439
-
440
- // src/components/chat/Markdown.tsx
441
- import { memo as memo2 } from "react";
442
- import ReactMarkdown from "react-markdown";
443
-
444
- // src/components/chat/CodeBlock.tsx
445
- import { memo } from "react";
446
- import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
447
-
448
- // src/hooks/use-copy-to-clipboard.tsx
449
- import * as React3 from "react";
450
- function useCopyToClipboard({ timeout = 2e3 }) {
451
- const [isCopied, setIsCopied] = React3.useState(false);
452
- const copyToClipboard = (value) => {
453
- var _a;
454
- if (typeof window === "undefined" || !((_a = navigator.clipboard) == null ? void 0 : _a.writeText)) {
455
- return;
456
- }
457
- if (!value) {
458
- return;
459
- }
460
- navigator.clipboard.writeText(value).then(() => {
461
- setIsCopied(true);
462
- setTimeout(() => {
463
- setIsCopied(false);
464
- }, timeout);
465
- });
466
- };
467
- return { isCopied, copyToClipboard };
468
- }
469
-
470
- // src/components/chat/CodeBlock.tsx
471
- import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
472
- var programmingLanguages = {
473
- javascript: ".js",
474
- python: ".py",
475
- java: ".java",
476
- c: ".c",
477
- cpp: ".cpp",
478
- "c++": ".cpp",
479
- "c#": ".cs",
480
- ruby: ".rb",
481
- php: ".php",
482
- swift: ".swift",
483
- "objective-c": ".m",
484
- kotlin: ".kt",
485
- typescript: ".ts",
486
- go: ".go",
487
- perl: ".pl",
488
- rust: ".rs",
489
- scala: ".scala",
490
- haskell: ".hs",
491
- lua: ".lua",
492
- shell: ".sh",
493
- sql: ".sql",
494
- html: ".html",
495
- css: ".css"
496
- // add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component
497
- };
498
- var generateRandomString = (length, lowercase = false) => {
499
- const chars = "ABCDEFGHJKLMNPQRSTUVWXY3456789";
500
- let result = "";
501
- for (let i = 0; i < length; i++) {
502
- result += chars.charAt(Math.floor(Math.random() * chars.length));
503
- }
504
- return lowercase ? result.toLowerCase() : result;
505
- };
506
- var CodeBlock = memo(({ language, value }) => {
507
- const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2e3 });
508
- const downloadAsFile = () => {
509
- if (typeof window === "undefined") {
510
- return;
511
- }
512
- const fileExtension = programmingLanguages[language] || ".file";
513
- const suggestedFileName = `file-${generateRandomString(3, true)}${fileExtension}`;
514
- const fileName = window.prompt("Enter file name", suggestedFileName);
515
- if (!fileName) {
516
- return;
517
- }
518
- const blob = new Blob([value], { type: "text/plain" });
519
- const url = URL.createObjectURL(blob);
520
- const link = document.createElement("a");
521
- link.download = fileName;
522
- link.href = url;
523
- link.style.display = "none";
524
- document.body.appendChild(link);
525
- link.click();
526
- document.body.removeChild(link);
527
- URL.revokeObjectURL(url);
528
- };
529
- const onCopy = () => {
530
- if (isCopied)
531
- return;
532
- copyToClipboard(value);
533
- };
534
- return /* @__PURE__ */ jsxs4("div", { className: "copilotKitCodeBlock", children: [
535
- /* @__PURE__ */ jsxs4("div", { className: "copilotKitCodeBlockToolbar", children: [
536
- /* @__PURE__ */ jsx6("span", { className: "copilotKitCodeBlockToolbarLanguage", children: language }),
537
- /* @__PURE__ */ jsxs4("div", { className: "copilotKitCodeBlockToolbarButtons", children: [
538
- /* @__PURE__ */ jsxs4("button", { className: "copilotKitCodeBlockToolbarButton", onClick: downloadAsFile, children: [
539
- /* @__PURE__ */ jsx6(DownloadIcon, {}),
540
- /* @__PURE__ */ jsx6("span", { className: "sr-only", children: "Download" })
541
- ] }),
542
- /* @__PURE__ */ jsxs4("button", { className: "copilotKitCodeBlockToolbarButton", onClick: onCopy, children: [
543
- isCopied ? /* @__PURE__ */ jsx6(CheckIcon, {}) : /* @__PURE__ */ jsx6(CopyIcon, {}),
544
- /* @__PURE__ */ jsx6("span", { className: "sr-only", children: "Copy code" })
545
- ] })
546
- ] })
547
- ] }),
548
- /* @__PURE__ */ jsx6(
549
- SyntaxHighlighter,
550
- {
551
- language,
552
- style: highlightStyle,
553
- PreTag: "div",
554
- customStyle: {
555
- margin: 0,
556
- borderBottomLeftRadius: "0.375rem",
557
- borderBottomRightRadius: "0.375rem"
558
- },
559
- children: value
560
- }
561
- )
562
- ] });
563
- });
564
- CodeBlock.displayName = "CodeBlock";
565
- var highlightStyle = {
566
- 'pre[class*="language-"]': {
567
- color: "#d4d4d4",
568
- fontSize: "13px",
569
- textShadow: "none",
570
- fontFamily: 'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',
571
- direction: "ltr",
572
- textAlign: "left",
573
- whiteSpace: "pre",
574
- wordSpacing: "normal",
575
- wordBreak: "normal",
576
- lineHeight: "1.5",
577
- MozTabSize: "4",
578
- OTabSize: "4",
579
- tabSize: "4",
580
- WebkitHyphens: "none",
581
- MozHyphens: "none",
582
- msHyphens: "none",
583
- hyphens: "none",
584
- padding: "1em",
585
- margin: ".5em 0",
586
- overflow: "auto",
587
- background: "#1e1e1e"
588
- },
589
- 'code[class*="language-"]': {
590
- color: "#d4d4d4",
591
- fontSize: "13px",
592
- textShadow: "none",
593
- fontFamily: 'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',
594
- direction: "ltr",
595
- textAlign: "left",
596
- whiteSpace: "pre",
597
- wordSpacing: "normal",
598
- wordBreak: "normal",
599
- lineHeight: "1.5",
600
- MozTabSize: "4",
601
- OTabSize: "4",
602
- tabSize: "4",
603
- WebkitHyphens: "none",
604
- MozHyphens: "none",
605
- msHyphens: "none",
606
- hyphens: "none"
607
- },
608
- 'pre[class*="language-"]::selection': {
609
- textShadow: "none",
610
- background: "#264F78"
611
- },
612
- 'code[class*="language-"]::selection': {
613
- textShadow: "none",
614
- background: "#264F78"
615
- },
616
- 'pre[class*="language-"] *::selection': {
617
- textShadow: "none",
618
- background: "#264F78"
619
- },
620
- 'code[class*="language-"] *::selection': {
621
- textShadow: "none",
622
- background: "#264F78"
623
- },
624
- ':not(pre) > code[class*="language-"]': {
625
- padding: ".1em .3em",
626
- borderRadius: ".3em",
627
- color: "#db4c69",
628
- background: "#1e1e1e"
629
- },
630
- ".namespace": {
631
- Opacity: ".7"
632
- },
633
- "doctype.doctype-tag": {
634
- color: "#569CD6"
635
- },
636
- "doctype.name": {
637
- color: "#9cdcfe"
638
- },
639
- comment: {
640
- color: "#6a9955"
641
- },
642
- prolog: {
643
- color: "#6a9955"
644
- },
645
- punctuation: {
646
- color: "#d4d4d4"
647
- },
648
- ".language-html .language-css .token.punctuation": {
649
- color: "#d4d4d4"
650
- },
651
- ".language-html .language-javascript .token.punctuation": {
652
- color: "#d4d4d4"
653
- },
654
- property: {
655
- color: "#9cdcfe"
656
- },
657
- tag: {
658
- color: "#569cd6"
659
- },
660
- boolean: {
661
- color: "#569cd6"
662
- },
663
- number: {
664
- color: "#b5cea8"
665
- },
666
- constant: {
667
- color: "#9cdcfe"
668
- },
669
- symbol: {
670
- color: "#b5cea8"
671
- },
672
- inserted: {
673
- color: "#b5cea8"
674
- },
675
- unit: {
676
- color: "#b5cea8"
677
- },
678
- selector: {
679
- color: "#d7ba7d"
680
- },
681
- "attr-name": {
682
- color: "#9cdcfe"
683
- },
684
- string: {
685
- color: "#ce9178"
686
- },
687
- char: {
688
- color: "#ce9178"
689
- },
690
- builtin: {
691
- color: "#ce9178"
692
- },
693
- deleted: {
694
- color: "#ce9178"
695
- },
696
- ".language-css .token.string.url": {
697
- textDecoration: "underline"
698
- },
699
- operator: {
700
- color: "#d4d4d4"
701
- },
702
- entity: {
703
- color: "#569cd6"
704
- },
705
- "operator.arrow": {
706
- color: "#569CD6"
707
- },
708
- atrule: {
709
- color: "#ce9178"
710
- },
711
- "atrule.rule": {
712
- color: "#c586c0"
713
- },
714
- "atrule.url": {
715
- color: "#9cdcfe"
716
- },
717
- "atrule.url.function": {
718
- color: "#dcdcaa"
719
- },
720
- "atrule.url.punctuation": {
721
- color: "#d4d4d4"
722
- },
723
- keyword: {
724
- color: "#569CD6"
725
- },
726
- "keyword.module": {
727
- color: "#c586c0"
728
- },
729
- "keyword.control-flow": {
730
- color: "#c586c0"
731
- },
732
- function: {
733
- color: "#dcdcaa"
734
- },
735
- "function.maybe-class-name": {
736
- color: "#dcdcaa"
737
- },
738
- regex: {
739
- color: "#d16969"
740
- },
741
- important: {
742
- color: "#569cd6"
743
- },
744
- italic: {
745
- fontStyle: "italic"
746
- },
747
- "class-name": {
748
- color: "#4ec9b0"
749
- },
750
- "maybe-class-name": {
751
- color: "#4ec9b0"
752
- },
753
- console: {
754
- color: "#9cdcfe"
755
- },
756
- parameter: {
757
- color: "#9cdcfe"
758
- },
759
- interpolation: {
760
- color: "#9cdcfe"
761
- },
762
- "punctuation.interpolation-punctuation": {
763
- color: "#569cd6"
764
- },
765
- variable: {
766
- color: "#9cdcfe"
767
- },
768
- "imports.maybe-class-name": {
769
- color: "#9cdcfe"
770
- },
771
- "exports.maybe-class-name": {
772
- color: "#9cdcfe"
773
- },
774
- escape: {
775
- color: "#d7ba7d"
776
- },
777
- "tag.punctuation": {
778
- color: "#808080"
779
- },
780
- cdata: {
781
- color: "#808080"
782
- },
783
- "attr-value": {
784
- color: "#ce9178"
785
- },
786
- "attr-value.punctuation": {
787
- color: "#ce9178"
788
- },
789
- "attr-value.punctuation.attr-equals": {
790
- color: "#d4d4d4"
791
- },
792
- namespace: {
793
- color: "#4ec9b0"
794
- },
795
- 'pre[class*="language-javascript"]': {
796
- color: "#9cdcfe"
797
- },
798
- 'code[class*="language-javascript"]': {
799
- color: "#9cdcfe"
800
- },
801
- 'pre[class*="language-jsx"]': {
802
- color: "#9cdcfe"
803
- },
804
- 'code[class*="language-jsx"]': {
805
- color: "#9cdcfe"
806
- },
807
- 'pre[class*="language-typescript"]': {
808
- color: "#9cdcfe"
809
- },
810
- 'code[class*="language-typescript"]': {
811
- color: "#9cdcfe"
812
- },
813
- 'pre[class*="language-tsx"]': {
814
- color: "#9cdcfe"
815
- },
816
- 'code[class*="language-tsx"]': {
817
- color: "#9cdcfe"
818
- },
819
- 'pre[class*="language-css"]': {
820
- color: "#ce9178"
821
- },
822
- 'code[class*="language-css"]': {
823
- color: "#ce9178"
824
- },
825
- 'pre[class*="language-html"]': {
826
- color: "#d4d4d4"
827
- },
828
- 'code[class*="language-html"]': {
829
- color: "#d4d4d4"
830
- },
831
- ".language-regex .token.anchor": {
832
- color: "#dcdcaa"
833
- },
834
- ".language-html .token.punctuation": {
835
- color: "#808080"
836
- },
837
- 'pre[class*="language-"] > code[class*="language-"]': {
838
- position: "relative",
839
- zIndex: "1"
840
- },
841
- ".line-highlight.line-highlight": {
842
- background: "#f7ebc6",
843
- boxShadow: "inset 5px 0 0 #f7d87c",
844
- zIndex: "0"
845
- }
846
- };
847
-
848
- // src/components/chat/Markdown.tsx
849
- import remarkGfm from "remark-gfm";
850
- import remarkMath from "remark-math";
851
- import { jsx as jsx7 } from "react/jsx-runtime";
852
- var MemoizedReactMarkdown = memo2(
853
- ReactMarkdown,
854
- (prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.className === nextProps.className
855
- );
856
- var Markdown = ({ content }) => {
857
- return /* @__PURE__ */ jsx7("div", { className: "copilotKitMarkdown", children: /* @__PURE__ */ jsx7(MemoizedReactMarkdown, { components, remarkPlugins: [remarkGfm, remarkMath], children: content }) });
858
- };
859
- var components = {
860
- p({ children }) {
861
- return /* @__PURE__ */ jsx7("p", { children });
862
- },
863
- a(_a) {
864
- var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
865
- return /* @__PURE__ */ jsx7(
866
- "a",
867
- __spreadProps(__spreadValues({
868
- style: { color: "blue", textDecoration: "underline" }
869
- }, props), {
870
- target: "_blank",
871
- rel: "noopener noreferrer",
872
- children
873
- })
874
- );
875
- },
876
- code(_c) {
877
- var _d = _c, { children, className, inline } = _d, props = __objRest(_d, ["children", "className", "inline"]);
878
- if (children.length) {
879
- if (children[0] == "\u258D") {
880
- return /* @__PURE__ */ jsx7(
881
- "span",
882
- {
883
- style: {
884
- animation: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",
885
- marginTop: "0.25rem"
886
- },
887
- children: "\u258D"
888
- }
889
- );
890
- }
891
- children[0] = children[0].replace("`\u258D`", "\u258D");
892
- }
893
- const match = /language-(\w+)/.exec(className || "");
894
- if (inline) {
895
- return /* @__PURE__ */ jsx7("code", __spreadProps(__spreadValues({ className }, props), { children }));
896
- }
897
- return /* @__PURE__ */ jsx7(
898
- CodeBlock,
899
- __spreadValues({
900
- language: match && match[1] || "",
901
- value: String(children).replace(/\n$/, "")
902
- }, props),
903
- Math.random()
904
- );
905
- }
906
- };
907
-
908
- // src/components/chat/Messages.tsx
909
- import { useCopilotContext } from "@copilotkit/react-core";
910
- import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
911
- var Messages = ({ messages, inProgress }) => {
912
- const { chatComponentsCache } = useCopilotContext();
913
- const context = useChatContext();
914
- const initialMessages = useMemo2(
915
- () => makeInitialMessages(context.labels.initial),
916
- [context.labels.initial]
917
- );
918
- messages = [...initialMessages, ...messages];
919
- const functionResults = {};
920
- for (let i = 0; i < messages.length; i++) {
921
- if (messages[i].role === "assistant" && messages[i].function_call) {
922
- const id = messages[i].id;
923
- if (i + 1 < messages.length && messages[i + 1].role === "function") {
924
- functionResults[id] = decodeResult(messages[i + 1].content || "");
925
- }
926
- }
927
- }
928
- const messagesEndRef = React4.useRef(null);
929
- const scrollToBottom = () => {
930
- if (messagesEndRef.current) {
931
- messagesEndRef.current.scrollIntoView({
932
- behavior: "auto"
933
- });
934
- }
935
- };
936
- useEffect2(() => {
937
- scrollToBottom();
938
- }, [messages]);
939
- return /* @__PURE__ */ jsxs5("div", { className: "copilotKitMessages", children: [
940
- messages.map((message, index) => {
941
- var _a, _b, _c;
942
- const isCurrentMessage = index === messages.length - 1;
943
- if (message.role === "user") {
944
- return /* @__PURE__ */ jsx8("div", { className: "copilotKitMessage copilotKitUserMessage", children: message.content }, index);
945
- } else if (message.role == "assistant") {
946
- if (isCurrentMessage && inProgress && !message.content && !message.partialFunctionCall) {
947
- return /* @__PURE__ */ jsx8("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: context.icons.spinnerIcon }, index);
948
- } else if (message.function_call || message.partialFunctionCall) {
949
- const functionCallName = ((_a = message.function_call) == null ? void 0 : _a.name) || ((_b = message.partialFunctionCall) == null ? void 0 : _b.name);
950
- if (chatComponentsCache.current !== null && chatComponentsCache.current[functionCallName]) {
951
- const render = chatComponentsCache.current[functionCallName];
952
- if (typeof render === "string") {
953
- if (isCurrentMessage && inProgress) {
954
- return /* @__PURE__ */ jsxs5("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: [
955
- context.icons.spinnerIcon,
956
- " ",
957
- /* @__PURE__ */ jsx8("span", { className: "inProgressLabel", children: render })
958
- ] }, index);
959
- } else {
960
- return null;
961
- }
962
- } else {
963
- const args = message.function_call ? JSON.parse(message.function_call.arguments || "{}") : (_c = message.partialFunctionCall) == null ? void 0 : _c.arguments;
964
- let status = "inProgress";
965
- if (functionResults[message.id] !== void 0) {
966
- status = "complete";
967
- } else if (message.function_call) {
968
- status = "executing";
969
- }
970
- const toRender = render({
971
- status,
972
- args,
973
- result: functionResults[message.id]
974
- });
975
- if (!toRender && status === "complete") {
976
- return null;
977
- }
978
- if (typeof toRender === "string") {
979
- return /* @__PURE__ */ jsxs5("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: [
980
- isCurrentMessage && inProgress && context.icons.spinnerIcon,
981
- " ",
982
- toRender
983
- ] }, index);
984
- } else {
985
- return /* @__PURE__ */ jsx8("div", { className: "copilotKitCustomAssistantMessage", children: toRender }, index);
986
- }
987
- }
988
- } else if ((!inProgress || !isCurrentMessage) && message.function_call) {
989
- return null;
990
- } else {
991
- return /* @__PURE__ */ jsx8("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: context.icons.spinnerIcon }, index);
992
- }
993
- }
994
- return /* @__PURE__ */ jsx8("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: /* @__PURE__ */ jsx8(Markdown, { content: message.content }) }, index);
995
- }
996
- }),
997
- /* @__PURE__ */ jsx8("div", { ref: messagesEndRef })
998
- ] });
999
- };
1000
- function makeInitialMessages(initial) {
1001
- let initialArray = [];
1002
- if (initial) {
1003
- if (Array.isArray(initial)) {
1004
- initialArray.push(...initial);
1005
- } else {
1006
- initialArray.push(initial);
1007
- }
1008
- }
1009
- return initialArray.map((message) => ({
1010
- id: nanoid(),
1011
- role: "assistant",
1012
- content: message
1013
- }));
1014
- }
1015
-
1016
- // src/components/chat/Input.tsx
1017
- import { useEffect as useEffect4, useRef as useRef2, useState as useState3 } from "react";
1018
-
1019
- // src/components/chat/Textarea.tsx
1020
- import { useState as useState2, useRef, useEffect as useEffect3, forwardRef, useImperativeHandle } from "react";
1021
- import { jsx as jsx9 } from "react/jsx-runtime";
1022
- var AutoResizingTextarea = forwardRef(
1023
- ({ maxRows = 1, placeholder, value, onChange, onKeyDown, autoFocus }, ref) => {
1024
- const internalTextareaRef = useRef(null);
1025
- const [maxHeight, setMaxHeight] = useState2(0);
1026
- useImperativeHandle(ref, () => internalTextareaRef.current);
1027
- useEffect3(() => {
1028
- const calculateMaxHeight = () => {
1029
- const textarea = internalTextareaRef.current;
1030
- if (textarea) {
1031
- textarea.style.height = "auto";
1032
- const singleRowHeight = textarea.scrollHeight;
1033
- setMaxHeight(singleRowHeight * maxRows);
1034
- if (autoFocus) {
1035
- textarea.focus();
1036
- }
1037
- }
1038
- };
1039
- calculateMaxHeight();
1040
- }, [maxRows]);
1041
- useEffect3(() => {
1042
- const textarea = internalTextareaRef.current;
1043
- if (textarea) {
1044
- textarea.style.height = "auto";
1045
- textarea.style.height = `${Math.min(textarea.scrollHeight, maxHeight)}px`;
1046
- }
1047
- }, [value, maxHeight]);
1048
- return /* @__PURE__ */ jsx9(
1049
- "textarea",
1050
- {
1051
- ref: internalTextareaRef,
1052
- value,
1053
- onChange,
1054
- onKeyDown,
1055
- placeholder,
1056
- style: {
1057
- overflow: "hidden",
1058
- resize: "none",
1059
- maxHeight: `${maxHeight}px`
1060
- },
1061
- rows: 1
1062
- }
1063
- );
1064
- }
1065
- );
1066
- var Textarea_default = AutoResizingTextarea;
1067
-
1068
- // src/components/chat/Input.tsx
1069
- import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
1070
- var Input = ({ inProgress, onSend, children, isVisible = false }) => {
1071
- const context = useChatContext();
1072
- const textareaRef = useRef2(null);
1073
- const handleDivClick = (event) => {
1074
- var _a;
1075
- if (event.target !== event.currentTarget)
1076
- return;
1077
- (_a = textareaRef.current) == null ? void 0 : _a.focus();
1078
- };
1079
- const [text, setText] = useState3("");
1080
- const send = () => {
1081
- var _a;
1082
- if (inProgress)
1083
- return;
1084
- onSend(text);
1085
- setText("");
1086
- (_a = textareaRef.current) == null ? void 0 : _a.focus();
1087
- };
1088
- useEffect4(() => {
1089
- var _a;
1090
- if (isVisible) {
1091
- (_a = textareaRef.current) == null ? void 0 : _a.focus();
1092
- }
1093
- }, [isVisible]);
1094
- const icon = inProgress ? context.icons.activityIcon : context.icons.sendIcon;
1095
- const disabled = inProgress || text.length === 0;
1096
- return /* @__PURE__ */ jsxs6("div", { className: "copilotKitInput", onClick: handleDivClick, children: [
1097
- /* @__PURE__ */ jsx10("span", { children }),
1098
- /* @__PURE__ */ jsx10("button", { className: "copilotKitSendButton", disabled, onClick: send, children: icon }),
1099
- /* @__PURE__ */ jsx10(
1100
- Textarea_default,
1101
- {
1102
- ref: textareaRef,
1103
- placeholder: context.labels.placeholder,
1104
- autoFocus: true,
1105
- maxRows: 5,
1106
- value: text,
1107
- onChange: (event) => setText(event.target.value),
1108
- onKeyDown: (event) => {
1109
- if (event.key === "Enter" && !event.shiftKey) {
1110
- event.preventDefault();
1111
- send();
1112
- }
1113
- }
1114
- }
1115
- )
1116
- ] });
1117
- };
1118
-
1119
- // src/components/chat/Chat.tsx
1120
- import { nanoid as nanoid2 } from "nanoid";
1121
-
1122
- // src/components/chat/Response.tsx
1123
- import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
1124
- var ResponseButton = ({ onClick, inProgress }) => {
1125
- const context = useChatContext();
1126
- return /* @__PURE__ */ jsxs7("button", { onClick, className: "copilotKitResponseButton", children: [
1127
- /* @__PURE__ */ jsx11("span", { children: inProgress ? context.icons.stopIcon : context.icons.regenerateIcon }),
1128
- inProgress ? context.labels.stopGenerating : context.labels.regenerateResponse
1129
- ] });
1130
- };
1131
-
1132
- // src/components/chat/Chat.tsx
1133
- import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
1134
- var CopilotChat = ({
1135
- instructions,
1136
- defaultOpen = false,
1137
- clickOutsideToClose = true,
1138
- hitEscapeToClose = true,
1139
- onSetOpen,
1140
- onSubmitMessage,
1141
- shortcut = "/",
1142
- icons,
1143
- labels,
1144
- makeSystemMessage,
1145
- showResponseButton = true,
1146
- onInProgress,
1147
- Window: Window2 = Window,
1148
- Button: Button2 = Button,
1149
- Header: Header2 = Header,
1150
- Messages: Messages2 = Messages,
1151
- Input: Input2 = Input,
1152
- ResponseButton: ResponseButton2 = ResponseButton,
1153
- className,
1154
- children
1155
- }) => {
1156
- const { visibleMessages, append, reload, stop, isLoading, input, setInput } = useCopilotChat({
1157
- id: nanoid2(),
1158
- makeSystemMessage,
1159
- additionalInstructions: instructions
1160
- });
1161
- useEffect5(() => {
1162
- onInProgress == null ? void 0 : onInProgress(isLoading);
1163
- }, [isLoading]);
1164
- const [openState, setOpenState] = React7.useState(defaultOpen);
1165
- const setOpen = (open) => {
1166
- onSetOpen == null ? void 0 : onSetOpen(open);
1167
- setOpenState(open);
1168
- };
1169
- const sendMessage = (message) => __async(void 0, null, function* () {
1170
- onSubmitMessage == null ? void 0 : onSubmitMessage(message);
1171
- append({
1172
- id: nanoid2(),
1173
- content: message,
1174
- role: "user"
1175
- });
1176
- });
1177
- return /* @__PURE__ */ jsxs8(ChatContextProvider, { icons, labels, open: openState, setOpen: setOpenState, children: [
1178
- children,
1179
- /* @__PURE__ */ jsxs8("div", { className, children: [
1180
- /* @__PURE__ */ jsx12(Button2, { open: openState, setOpen }),
1181
- /* @__PURE__ */ jsxs8(
1182
- Window2,
1183
- {
1184
- open: openState,
1185
- setOpen,
1186
- clickOutsideToClose,
1187
- shortcut,
1188
- hitEscapeToClose,
1189
- children: [
1190
- /* @__PURE__ */ jsx12(Header2, { open: openState, setOpen }),
1191
- /* @__PURE__ */ jsx12(Messages2, { messages: visibleMessages, inProgress: isLoading }),
1192
- /* @__PURE__ */ jsx12(Input2, { inProgress: isLoading, onSend: sendMessage, isVisible: openState, children: showResponseButton && visibleMessages.length > 0 && /* @__PURE__ */ jsx12(ResponseButton2, { onClick: isLoading ? stop : reload, inProgress: isLoading }) })
1193
- ]
1194
- }
1195
- )
1196
- ] })
1197
- ] });
1198
- };
1
+ import {
2
+ CopilotChat
3
+ } from "../../chunk-6U3O2JZP.mjs";
4
+ import "../../chunk-73EBDGYK.mjs";
5
+ import "../../chunk-WDHLWSSU.mjs";
6
+ import "../../chunk-YEHO5VMA.mjs";
7
+ import "../../chunk-B7DNOYVQ.mjs";
8
+ import "../../chunk-YTIGBBTC.mjs";
9
+ import "../../chunk-MBYUBR3F.mjs";
10
+ import "../../chunk-7JYUCW7H.mjs";
11
+ import "../../chunk-KE3N45ZY.mjs";
12
+ import "../../chunk-WM6BS77F.mjs";
13
+ import "../../chunk-7LMXXGJT.mjs";
14
+ import "../../chunk-7YXG7D47.mjs";
15
+ import "../../chunk-54JAUBUJ.mjs";
16
+ import "../../chunk-MRXNTQOX.mjs";
1199
17
  export {
1200
18
  CopilotChat
1201
19
  };