@copilotkit/react-ui 0.15.0-alpha.0 → 0.15.0-alpha.2
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.
- package/.turbo/turbo-build.log +196 -209
- package/CHANGELOG.md +27 -1
- package/dist/chunk-3M4HWSE7.mjs +61 -0
- package/dist/chunk-3M4HWSE7.mjs.map +1 -0
- package/dist/chunk-47SYBLI2.mjs +110 -0
- package/dist/chunk-47SYBLI2.mjs.map +1 -0
- package/dist/chunk-5O2MCJZ2.mjs +21 -0
- package/dist/chunk-5O2MCJZ2.mjs.map +1 -0
- package/dist/chunk-7YXG7D47.mjs +191 -0
- package/dist/chunk-7YXG7D47.mjs.map +1 -0
- package/dist/chunk-CKJXXQ2W.mjs +26 -0
- package/dist/chunk-CKJXXQ2W.mjs.map +1 -0
- package/dist/{chunk-6LAZQHEB.mjs → chunk-DPRH4HX3.mjs} +18 -43
- package/dist/chunk-DPRH4HX3.mjs.map +1 -0
- package/dist/chunk-GWGHQNRI.mjs +54 -0
- package/dist/chunk-GWGHQNRI.mjs.map +1 -0
- package/dist/chunk-JD7BAH7U.mjs +3 -0
- package/dist/chunk-KBGIPFXA.mjs +14 -0
- package/dist/chunk-KBGIPFXA.mjs.map +1 -0
- package/dist/chunk-NNVWLSYK.mjs +72 -0
- package/dist/chunk-NNVWLSYK.mjs.map +1 -0
- package/dist/chunk-NYLOXKYT.mjs +51 -0
- package/dist/chunk-NYLOXKYT.mjs.map +1 -0
- package/dist/chunk-OF66AL5Z.mjs +56 -0
- package/dist/chunk-OF66AL5Z.mjs.map +1 -0
- package/dist/chunk-P4GBO6MW.mjs +3 -0
- package/dist/chunk-UWPFPWAW.mjs +14 -0
- package/dist/chunk-UWPFPWAW.mjs.map +1 -0
- package/dist/chunk-WB3YULQ4.mjs +3 -0
- package/dist/chunk-WM6BS77F.mjs +53 -0
- package/dist/chunk-WM6BS77F.mjs.map +1 -0
- package/dist/chunk-Z34F3WLK.mjs +14 -0
- package/dist/chunk-Z34F3WLK.mjs.map +1 -0
- package/dist/components/chat/Button.d.ts +6 -0
- package/dist/components/chat/Button.js +38 -0
- package/dist/components/chat/Button.js.map +1 -0
- package/dist/components/chat/Button.mjs +6 -0
- package/dist/components/chat/Chat.d.ts +96 -0
- package/dist/components/chat/Chat.js +800 -0
- package/dist/components/chat/Chat.js.map +1 -0
- package/dist/components/chat/Chat.mjs +16 -0
- package/dist/components/chat/ChatContext.d.ts +105 -0
- package/dist/components/chat/ChatContext.js +220 -0
- package/dist/components/chat/ChatContext.js.map +1 -0
- package/dist/components/chat/ChatContext.mjs +5 -0
- package/dist/components/chat/CodeBlock.js +221 -0
- package/dist/components/chat/CodeBlock.js.map +1 -0
- package/dist/components/chat/CodeBlock.mjs +6 -0
- package/dist/components/chat/Header.d.ts +6 -0
- package/dist/components/chat/Header.js +31 -0
- package/dist/components/chat/Header.js.map +1 -0
- package/dist/components/chat/Header.mjs +6 -0
- package/dist/components/chat/Icons.d.ts +15 -0
- package/dist/components/chat/Icons.js +233 -0
- package/dist/components/chat/Icons.js.map +1 -0
- package/dist/components/chat/Icons.mjs +4 -0
- package/dist/components/chat/Input.d.ts +6 -0
- package/dist/components/chat/Input.js +111 -0
- package/dist/components/chat/Input.js.map +1 -0
- package/dist/components/chat/Input.mjs +7 -0
- package/dist/components/chat/Markdown.d.ts +6 -0
- package/dist/components/chat/Markdown.js +269 -0
- package/dist/components/chat/Markdown.js.map +1 -0
- package/dist/components/chat/Markdown.mjs +7 -0
- package/dist/components/chat/Messages.d.ts +6 -0
- package/dist/components/chat/Messages.js +331 -0
- package/dist/components/chat/Messages.js.map +1 -0
- package/dist/components/chat/Messages.mjs +9 -0
- package/dist/components/chat/Popup.d.ts +10 -0
- package/dist/components/chat/Popup.js +806 -0
- package/dist/components/chat/Popup.js.map +1 -0
- package/dist/components/chat/Popup.mjs +17 -0
- package/dist/components/chat/Response.d.ts +6 -0
- package/dist/components/chat/Response.js +31 -0
- package/dist/components/chat/Response.js.map +1 -0
- package/dist/components/chat/Response.mjs +6 -0
- package/dist/components/chat/Sidebar.d.ts +13 -0
- package/dist/components/chat/Sidebar.js +817 -0
- package/dist/components/chat/Sidebar.js.map +1 -0
- package/dist/components/chat/Sidebar.mjs +17 -0
- package/dist/components/chat/Textarea.d.ts +13 -0
- package/dist/components/chat/Textarea.js +55 -0
- package/dist/components/chat/Textarea.js.map +1 -0
- package/dist/components/chat/Textarea.mjs +4 -0
- package/dist/components/chat/Window.d.ts +6 -0
- package/dist/components/chat/Window.js +116 -0
- package/dist/components/chat/Window.js.map +1 -0
- package/dist/components/chat/Window.mjs +4 -0
- package/dist/components/chat/index.d.ts +8 -0
- package/dist/components/chat/index.js +824 -0
- package/dist/components/chat/index.js.map +1 -0
- package/dist/components/chat/index.mjs +20 -0
- package/dist/components/chat/props.d.ts +33 -0
- package/dist/components/chat/props.js +4 -0
- package/dist/components/chat/props.mjs +3 -0
- package/dist/components/index.d.ts +6 -7
- package/dist/components/index.js +824 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.mjs +17 -22
- package/dist/context/index.js +4 -0
- package/dist/hooks/index.js +4 -0
- package/dist/hooks/use-copy-to-clipboard.js +47 -0
- package/dist/hooks/use-copy-to-clipboard.js.map +1 -0
- package/dist/index.css +565 -917
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +6 -7
- package/dist/index.js +824 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +18 -23
- package/dist/lib/utils.js +64 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/utils.mjs +38 -2
- package/dist/lib/utils.mjs.map +1 -1
- package/dist/lib/utils.test.js +10 -0
- package/dist/lib/utils.test.js.map +1 -0
- package/dist/types/index.js +4 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/types.d.ts +1 -1
- package/dist/types/types.js +4 -0
- package/dist/types/types.js.map +1 -0
- package/package.json +8 -7
- package/src/components/chat/Button.tsx +23 -0
- package/src/components/chat/Chat.tsx +186 -0
- package/src/components/chat/ChatContext.tsx +176 -0
- package/src/components/{chat-components/ui/codeblock.tsx → chat/CodeBlock.tsx} +21 -33
- package/src/components/chat/Header.tsx +15 -0
- package/src/components/chat/Icons.tsx +179 -0
- package/src/components/chat/Input.tsx +51 -0
- package/src/components/chat/Markdown.tsx +68 -0
- package/src/components/chat/Messages.tsx +113 -0
- package/src/components/chat/Popup.tsx +9 -0
- package/src/components/chat/Response.tsx +12 -0
- package/src/components/chat/Sidebar.tsx +28 -0
- package/src/components/chat/Textarea.tsx +61 -0
- package/src/components/chat/Window.tsx +141 -0
- package/src/components/chat/index.tsx +3 -0
- package/src/components/chat/props.ts +36 -0
- package/src/components/index.ts +1 -7
- package/src/css/animations.css +35 -0
- package/src/css/button.css +54 -0
- package/src/css/colors.css +61 -0
- package/src/css/header.css +43 -0
- package/src/css/input.css +79 -0
- package/src/css/markdown.css +123 -0
- package/src/css/messages.css +57 -0
- package/src/css/popup.css +22 -0
- package/src/css/response.css +29 -0
- package/src/css/sidebar.css +34 -0
- package/src/css/window.css +58 -0
- package/src/styles.css +12 -0
- package/src/types/types.ts +1 -1
- package/tsup.config.ts +1 -2
- package/dist/chunk-2KAF7NKC.mjs +0 -484
- package/dist/chunk-2KAF7NKC.mjs.map +0 -1
- package/dist/chunk-5KEDV5VC.mjs +0 -27
- package/dist/chunk-5KEDV5VC.mjs.map +0 -1
- package/dist/chunk-6LAZQHEB.mjs.map +0 -1
- package/dist/chunk-CF3BK4OX.mjs +0 -53
- package/dist/chunk-CF3BK4OX.mjs.map +0 -1
- package/dist/chunk-CNQX2VY3.mjs +0 -66
- package/dist/chunk-CNQX2VY3.mjs.map +0 -1
- package/dist/chunk-GCOPYGHH.mjs +0 -27
- package/dist/chunk-GCOPYGHH.mjs.map +0 -1
- package/dist/chunk-IJLMKBSZ.mjs +0 -25
- package/dist/chunk-IJLMKBSZ.mjs.map +0 -1
- package/dist/chunk-INCNMGJ7.mjs +0 -72
- package/dist/chunk-INCNMGJ7.mjs.map +0 -1
- package/dist/chunk-M3CZWJI3.mjs +0 -44
- package/dist/chunk-M3CZWJI3.mjs.map +0 -1
- package/dist/chunk-MC6KTH4X.mjs +0 -12
- package/dist/chunk-MC6KTH4X.mjs.map +0 -1
- package/dist/chunk-NMT7XT2R.mjs +0 -39
- package/dist/chunk-NMT7XT2R.mjs.map +0 -1
- package/dist/chunk-OHWEJUCS.mjs +0 -18
- package/dist/chunk-OHWEJUCS.mjs.map +0 -1
- package/dist/chunk-OOBQC5H6.mjs +0 -34
- package/dist/chunk-OOBQC5H6.mjs.map +0 -1
- package/dist/chunk-Q6YO7LDK.mjs +0 -40
- package/dist/chunk-Q6YO7LDK.mjs.map +0 -1
- package/dist/chunk-RPTRCFSO.mjs +0 -42
- package/dist/chunk-RPTRCFSO.mjs.map +0 -1
- package/dist/chunk-SEH5PQVW.mjs +0 -52
- package/dist/chunk-SEH5PQVW.mjs.map +0 -1
- package/dist/chunk-SHOTWRKC.mjs +0 -18
- package/dist/chunk-SHOTWRKC.mjs.map +0 -1
- package/dist/chunk-SRBUGQTM.mjs +0 -109
- package/dist/chunk-SRBUGQTM.mjs.map +0 -1
- package/dist/chunk-TEYIQHMK.mjs +0 -12
- package/dist/chunk-TEYIQHMK.mjs.map +0 -1
- package/dist/chunk-U6NJWGTV.mjs +0 -3
- package/dist/chunk-VGX2W5ZB.mjs +0 -28
- package/dist/chunk-VGX2W5ZB.mjs.map +0 -1
- package/dist/chunk-WLTEQ2FW.mjs +0 -80
- package/dist/chunk-WLTEQ2FW.mjs.map +0 -1
- package/dist/chunk-ZYC5YVDO.mjs +0 -21
- package/dist/chunk-ZYC5YVDO.mjs.map +0 -1
- package/dist/components/chat-components/chat-list.d.ts +0 -8
- package/dist/components/chat-components/chat-list.mjs +0 -13
- package/dist/components/chat-components/chat-message-actions.d.ts +0 -8
- package/dist/components/chat-components/chat-message-actions.mjs +0 -8
- package/dist/components/chat-components/chat-message.d.ts +0 -8
- package/dist/components/chat-components/chat-message.mjs +0 -11
- package/dist/components/chat-components/chat-panel.d.ts +0 -8
- package/dist/components/chat-components/chat-panel.mjs +0 -10
- package/dist/components/chat-components/chat-scroll-anchor.d.ts +0 -6
- package/dist/components/chat-components/chat-scroll-anchor.mjs +0 -5
- package/dist/components/chat-components/clear-history.d.ts +0 -9
- package/dist/components/chat-components/clear-history.mjs +0 -56
- package/dist/components/chat-components/clear-history.mjs.map +0 -1
- package/dist/components/chat-components/copilot-chat.d.ts +0 -12
- package/dist/components/chat-components/copilot-chat.mjs +0 -22
- package/dist/components/chat-components/default-empty-screen.d.ts +0 -8
- package/dist/components/chat-components/default-empty-screen.mjs +0 -8
- package/dist/components/chat-components/external-link.d.ts +0 -6
- package/dist/components/chat-components/external-link.mjs +0 -4
- package/dist/components/chat-components/markdown.d.ts +0 -6
- package/dist/components/chat-components/markdown.mjs +0 -4
- package/dist/components/chat-components/prompt-form.d.ts +0 -9
- package/dist/components/chat-components/prompt-form.mjs +0 -9
- package/dist/components/chat-components/theme-toggle.d.ts +0 -3
- package/dist/components/chat-components/theme-toggle.mjs +0 -32
- package/dist/components/chat-components/theme-toggle.mjs.map +0 -1
- package/dist/components/chat-components/toaster.d.ts +0 -1
- package/dist/components/chat-components/toaster.mjs +0 -4
- package/dist/components/chat-components/toaster.mjs.map +0 -1
- package/dist/components/chat-components/ui/alert-dialog.d.ts +0 -20
- package/dist/components/chat-components/ui/alert-dialog.mjs +0 -6
- package/dist/components/chat-components/ui/badge.d.ts +0 -12
- package/dist/components/chat-components/ui/badge.mjs +0 -29
- package/dist/components/chat-components/ui/badge.mjs.map +0 -1
- package/dist/components/chat-components/ui/button.d.ts +0 -14
- package/dist/components/chat-components/ui/button.mjs +0 -5
- package/dist/components/chat-components/ui/codeblock.mjs +0 -8
- package/dist/components/chat-components/ui/dialog.d.ts +0 -18
- package/dist/components/chat-components/ui/dialog.mjs +0 -94
- package/dist/components/chat-components/ui/dialog.mjs.map +0 -1
- package/dist/components/chat-components/ui/dropdown-menu.d.ts +0 -24
- package/dist/components/chat-components/ui/dropdown-menu.mjs +0 -87
- package/dist/components/chat-components/ui/dropdown-menu.mjs.map +0 -1
- package/dist/components/chat-components/ui/icons.d.ts +0 -33
- package/dist/components/chat-components/ui/icons.mjs +0 -5
- package/dist/components/chat-components/ui/input.d.ts +0 -7
- package/dist/components/chat-components/ui/input.mjs +0 -26
- package/dist/components/chat-components/ui/input.mjs.map +0 -1
- package/dist/components/chat-components/ui/label.d.ts +0 -8
- package/dist/components/chat-components/ui/label.mjs +0 -19
- package/dist/components/chat-components/ui/label.mjs.map +0 -1
- package/dist/components/chat-components/ui/select.d.ts +0 -13
- package/dist/components/chat-components/ui/select.mjs +0 -101
- package/dist/components/chat-components/ui/select.mjs.map +0 -1
- package/dist/components/chat-components/ui/separator.d.ts +0 -6
- package/dist/components/chat-components/ui/separator.mjs +0 -5
- package/dist/components/chat-components/ui/sheet.d.ts +0 -19
- package/dist/components/chat-components/ui/sheet.mjs +0 -93
- package/dist/components/chat-components/ui/sheet.mjs.map +0 -1
- package/dist/components/chat-components/ui/switch.d.ts +0 -6
- package/dist/components/chat-components/ui/switch.mjs +0 -33
- package/dist/components/chat-components/ui/switch.mjs.map +0 -1
- package/dist/components/chat-components/ui/textarea.d.ts +0 -7
- package/dist/components/chat-components/ui/textarea.mjs +0 -25
- package/dist/components/chat-components/ui/textarea.mjs.map +0 -1
- package/dist/components/chat-components/ui/tooltip.d.ts +0 -9
- package/dist/components/chat-components/ui/tooltip.mjs +0 -5
- package/dist/components/sidebar/copilot-sidebar-ui-provider.d.ts +0 -9
- package/dist/components/sidebar/copilot-sidebar-ui-provider.mjs +0 -25
- package/dist/components/sidebar/copilot-sidebar.d.ts +0 -7
- package/dist/components/sidebar/copilot-sidebar.mjs +0 -23
- package/dist/components/sidebar/sidebar-context.d.ts +0 -9
- package/dist/components/sidebar/sidebar-context.mjs +0 -4
- package/dist/hooks/use-at-bottom.d.ts +0 -3
- package/dist/hooks/use-at-bottom.mjs +0 -4
- package/dist/hooks/use-enter-submit.d.ts +0 -8
- package/dist/hooks/use-enter-submit.mjs +0 -4
- package/src/components/chat-components/chat-list.tsx +0 -28
- package/src/components/chat-components/chat-message-actions.tsx +0 -36
- package/src/components/chat-components/chat-message.tsx +0 -70
- package/src/components/chat-components/chat-panel.tsx +0 -64
- package/src/components/chat-components/chat-scroll-anchor.tsx +0 -29
- package/src/components/chat-components/clear-history.tsx +0 -72
- package/src/components/chat-components/copilot-chat.tsx +0 -57
- package/src/components/chat-components/default-empty-screen.tsx +0 -57
- package/src/components/chat-components/external-link.tsx +0 -17
- package/src/components/chat-components/markdown.tsx +0 -8
- package/src/components/chat-components/prompt-form.tsx +0 -85
- package/src/components/chat-components/theme-toggle.tsx +0 -31
- package/src/components/chat-components/toaster.tsx +0 -3
- package/src/components/chat-components/ui/alert-dialog.tsx +0 -126
- package/src/components/chat-components/ui/badge.tsx +0 -33
- package/src/components/chat-components/ui/button.tsx +0 -49
- package/src/components/chat-components/ui/dialog.tsx +0 -106
- package/src/components/chat-components/ui/dropdown-menu.tsx +0 -117
- package/src/components/chat-components/ui/icons.tsx +0 -484
- package/src/components/chat-components/ui/input.tsx +0 -24
- package/src/components/chat-components/ui/label.tsx +0 -21
- package/src/components/chat-components/ui/select.tsx +0 -119
- package/src/components/chat-components/ui/separator.tsx +0 -26
- package/src/components/chat-components/ui/sheet.tsx +0 -106
- package/src/components/chat-components/ui/switch.tsx +0 -29
- package/src/components/chat-components/ui/textarea.tsx +0 -23
- package/src/components/chat-components/ui/tooltip.tsx +0 -30
- package/src/components/sidebar/copilot-sidebar-ui-provider.tsx +0 -77
- package/src/components/sidebar/copilot-sidebar.tsx +0 -39
- package/src/components/sidebar/sidebar-context.tsx +0 -11
- package/src/hooks/use-at-bottom.tsx +0 -20
- package/src/hooks/use-enter-submit.tsx +0 -17
- /package/dist/{chunk-U6NJWGTV.mjs.map → chunk-JD7BAH7U.mjs.map} +0 -0
- /package/dist/{components/chat-components/chat-list.mjs.map → chunk-P4GBO6MW.mjs.map} +0 -0
- /package/dist/{components/chat-components/chat-message-actions.mjs.map → chunk-WB3YULQ4.mjs.map} +0 -0
- /package/dist/components/{chat-components/chat-message.mjs.map → chat/Button.mjs.map} +0 -0
- /package/dist/components/{chat-components/chat-panel.mjs.map → chat/Chat.mjs.map} +0 -0
- /package/dist/components/{chat-components/chat-scroll-anchor.mjs.map → chat/ChatContext.mjs.map} +0 -0
- /package/dist/components/{chat-components/ui/codeblock.d.ts → chat/CodeBlock.d.ts} +0 -0
- /package/dist/components/{chat-components/copilot-chat.mjs.map → chat/CodeBlock.mjs.map} +0 -0
- /package/dist/components/{chat-components/default-empty-screen.mjs.map → chat/Header.mjs.map} +0 -0
- /package/dist/components/{chat-components/external-link.mjs.map → chat/Icons.mjs.map} +0 -0
- /package/dist/components/{chat-components/markdown.mjs.map → chat/Input.mjs.map} +0 -0
- /package/dist/components/{chat-components/prompt-form.mjs.map → chat/Markdown.mjs.map} +0 -0
- /package/dist/components/{chat-components/ui/alert-dialog.mjs.map → chat/Messages.mjs.map} +0 -0
- /package/dist/components/{chat-components/ui/button.mjs.map → chat/Popup.mjs.map} +0 -0
- /package/dist/components/{chat-components/ui/codeblock.mjs.map → chat/Response.mjs.map} +0 -0
- /package/dist/components/{chat-components/ui/icons.mjs.map → chat/Sidebar.mjs.map} +0 -0
- /package/dist/components/{chat-components/ui/separator.mjs.map → chat/Textarea.mjs.map} +0 -0
- /package/dist/components/{chat-components/ui/tooltip.mjs.map → chat/Window.mjs.map} +0 -0
- /package/dist/components/{sidebar/copilot-sidebar-ui-provider.mjs.map → chat/index.mjs.map} +0 -0
- /package/dist/components/{sidebar/copilot-sidebar.mjs.map → chat/props.js.map} +0 -0
- /package/dist/components/{sidebar/sidebar-context.mjs.map → chat/props.mjs.map} +0 -0
- /package/dist/{hooks/use-at-bottom.mjs.map → context/index.js.map} +0 -0
- /package/dist/hooks/{use-enter-submit.mjs.map → index.js.map} +0 -0
|
@@ -0,0 +1,806 @@
|
|
|
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
|
+
|
|
38
|
+
var __defProp = Object.defineProperty;
|
|
39
|
+
var __defProps = Object.defineProperties;
|
|
40
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
41
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
42
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
43
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
44
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
45
|
+
var __spreadValues = (a, b) => {
|
|
46
|
+
for (var prop in b || (b = {}))
|
|
47
|
+
if (__hasOwnProp.call(b, prop))
|
|
48
|
+
__defNormalProp(a, prop, b[prop]);
|
|
49
|
+
if (__getOwnPropSymbols)
|
|
50
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
51
|
+
if (__propIsEnum.call(b, prop))
|
|
52
|
+
__defNormalProp(a, prop, b[prop]);
|
|
53
|
+
}
|
|
54
|
+
return a;
|
|
55
|
+
};
|
|
56
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
57
|
+
var __objRest = (source, exclude) => {
|
|
58
|
+
var target = {};
|
|
59
|
+
for (var prop in source)
|
|
60
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
61
|
+
target[prop] = source[prop];
|
|
62
|
+
if (source != null && __getOwnPropSymbols)
|
|
63
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
64
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
65
|
+
target[prop] = source[prop];
|
|
66
|
+
}
|
|
67
|
+
return target;
|
|
68
|
+
};
|
|
69
|
+
var __async = (__this, __arguments, generator) => {
|
|
70
|
+
return new Promise((resolve, reject) => {
|
|
71
|
+
var fulfilled = (value) => {
|
|
72
|
+
try {
|
|
73
|
+
step(generator.next(value));
|
|
74
|
+
} catch (e) {
|
|
75
|
+
reject(e);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
var rejected = (value) => {
|
|
79
|
+
try {
|
|
80
|
+
step(generator.throw(value));
|
|
81
|
+
} catch (e) {
|
|
82
|
+
reject(e);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
86
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
var OpenIcon = /* @__PURE__ */ jsxRuntime.jsx(
|
|
90
|
+
"svg",
|
|
91
|
+
{
|
|
92
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
93
|
+
viewBox: "0 0 24 24",
|
|
94
|
+
fill: "currentColor",
|
|
95
|
+
width: "24",
|
|
96
|
+
height: "24",
|
|
97
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("g", { transform: "translate(24, 0) scale(-1, 1)", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
98
|
+
"path",
|
|
99
|
+
{
|
|
100
|
+
fillRule: "evenodd",
|
|
101
|
+
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",
|
|
102
|
+
clipRule: "evenodd"
|
|
103
|
+
}
|
|
104
|
+
) })
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
var CloseIcon = /* @__PURE__ */ jsxRuntime.jsx(
|
|
108
|
+
"svg",
|
|
109
|
+
{
|
|
110
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
111
|
+
fill: "none",
|
|
112
|
+
viewBox: "0 0 24 24",
|
|
113
|
+
strokeWidth: "1.5",
|
|
114
|
+
stroke: "currentColor",
|
|
115
|
+
width: "24",
|
|
116
|
+
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" })
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
var HeaderCloseIcon = /* @__PURE__ */ jsxRuntime.jsx(
|
|
121
|
+
"svg",
|
|
122
|
+
{
|
|
123
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
124
|
+
fill: "none",
|
|
125
|
+
viewBox: "0 0 24 24",
|
|
126
|
+
strokeWidth: "1.5",
|
|
127
|
+
stroke: "currentColor",
|
|
128
|
+
width: "24",
|
|
129
|
+
height: "24",
|
|
130
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
var SendIcon = /* @__PURE__ */ jsxRuntime.jsx(
|
|
134
|
+
"svg",
|
|
135
|
+
{
|
|
136
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
137
|
+
fill: "none",
|
|
138
|
+
viewBox: "0 0 24 24",
|
|
139
|
+
strokeWidth: 1.5,
|
|
140
|
+
stroke: "currentColor",
|
|
141
|
+
width: "24",
|
|
142
|
+
height: "24",
|
|
143
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
144
|
+
"path",
|
|
145
|
+
{
|
|
146
|
+
strokeLinecap: "round",
|
|
147
|
+
strokeLinejoin: "round",
|
|
148
|
+
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"
|
|
149
|
+
}
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
var SpinnerIcon = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
154
|
+
"svg",
|
|
155
|
+
{
|
|
156
|
+
style: {
|
|
157
|
+
animation: "copilotKitSpinAnimation 1s linear infinite",
|
|
158
|
+
color: "rgb(107 114 128)"
|
|
159
|
+
},
|
|
160
|
+
width: "24",
|
|
161
|
+
height: "24",
|
|
162
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
163
|
+
fill: "none",
|
|
164
|
+
viewBox: "0 0 24 24",
|
|
165
|
+
children: [
|
|
166
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
167
|
+
"circle",
|
|
168
|
+
{
|
|
169
|
+
style: { opacity: 0.25 },
|
|
170
|
+
cx: "12",
|
|
171
|
+
cy: "12",
|
|
172
|
+
r: "10",
|
|
173
|
+
stroke: "currentColor",
|
|
174
|
+
strokeWidth: "4"
|
|
175
|
+
}
|
|
176
|
+
),
|
|
177
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
178
|
+
"path",
|
|
179
|
+
{
|
|
180
|
+
style: { opacity: 0.75 },
|
|
181
|
+
fill: "currentColor",
|
|
182
|
+
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"
|
|
183
|
+
}
|
|
184
|
+
)
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
var ActivityIcon = /* @__PURE__ */ jsxRuntime.jsxs(
|
|
189
|
+
"svg",
|
|
190
|
+
{
|
|
191
|
+
style: {
|
|
192
|
+
display: "inline-block",
|
|
193
|
+
marginLeft: "0.25rem",
|
|
194
|
+
marginRight: "0.25rem"
|
|
195
|
+
},
|
|
196
|
+
height: "24",
|
|
197
|
+
width: "24",
|
|
198
|
+
viewBox: "0 0 27 27",
|
|
199
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
200
|
+
fill: "currentColor",
|
|
201
|
+
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" })
|
|
205
|
+
]
|
|
206
|
+
}
|
|
207
|
+
);
|
|
208
|
+
function CheckIcon(_a) {
|
|
209
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
210
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
211
|
+
"svg",
|
|
212
|
+
__spreadProps(__spreadValues({
|
|
213
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
214
|
+
viewBox: "0 0 256 256",
|
|
215
|
+
fill: "currentColor",
|
|
216
|
+
style: { height: "1rem", width: "1rem" },
|
|
217
|
+
className
|
|
218
|
+
}, 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" })
|
|
220
|
+
})
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
function DownloadIcon(_a) {
|
|
224
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
225
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
226
|
+
"svg",
|
|
227
|
+
__spreadProps(__spreadValues({
|
|
228
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
229
|
+
viewBox: "0 0 256 256",
|
|
230
|
+
fill: "currentColor",
|
|
231
|
+
style: { height: "1rem", width: "1rem" },
|
|
232
|
+
className
|
|
233
|
+
}, 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" })
|
|
235
|
+
})
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
function CopyIcon(_a) {
|
|
239
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
240
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
241
|
+
"svg",
|
|
242
|
+
__spreadProps(__spreadValues({
|
|
243
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
244
|
+
viewBox: "0 0 256 256",
|
|
245
|
+
fill: "currentColor",
|
|
246
|
+
style: { height: "1rem", width: "1rem" },
|
|
247
|
+
className
|
|
248
|
+
}, 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" })
|
|
250
|
+
})
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
var StopIcon = /* @__PURE__ */ jsxRuntime.jsx(
|
|
254
|
+
"svg",
|
|
255
|
+
{
|
|
256
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
257
|
+
viewBox: "0 0 256 256",
|
|
258
|
+
fill: "currentColor",
|
|
259
|
+
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" })
|
|
261
|
+
}
|
|
262
|
+
);
|
|
263
|
+
var RegenerateIcon = /* @__PURE__ */ jsxRuntime.jsx(
|
|
264
|
+
"svg",
|
|
265
|
+
{
|
|
266
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
267
|
+
viewBox: "0 0 256 256",
|
|
268
|
+
fill: "currentColor",
|
|
269
|
+
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" })
|
|
271
|
+
}
|
|
272
|
+
);
|
|
273
|
+
var ChatContext = React__namespace.default.createContext(void 0);
|
|
274
|
+
function useChatContext() {
|
|
275
|
+
const context = React__namespace.default.useContext(ChatContext);
|
|
276
|
+
if (context === void 0) {
|
|
277
|
+
throw new Error(
|
|
278
|
+
"Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?"
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
return context;
|
|
282
|
+
}
|
|
283
|
+
var ChatContextProvider = ({
|
|
284
|
+
// temperature,
|
|
285
|
+
// instructions,
|
|
286
|
+
// maxFeedback,
|
|
287
|
+
labels,
|
|
288
|
+
icons,
|
|
289
|
+
children
|
|
290
|
+
}) => {
|
|
291
|
+
const context = React.useMemo(
|
|
292
|
+
() => ({
|
|
293
|
+
labels: __spreadValues(__spreadValues({}, {
|
|
294
|
+
initial: "",
|
|
295
|
+
title: "CopilotKit",
|
|
296
|
+
placeholder: "Type a message...",
|
|
297
|
+
thinking: "Thinking...",
|
|
298
|
+
done: "\u2705 Done",
|
|
299
|
+
error: "\u274C An error occurred. Please try again.",
|
|
300
|
+
stopGenerating: "Stop generating",
|
|
301
|
+
regenerateResponse: "Regenerate response"
|
|
302
|
+
}), labels),
|
|
303
|
+
icons: __spreadProps(__spreadValues({}, {
|
|
304
|
+
openIcon: OpenIcon,
|
|
305
|
+
closeIcon: CloseIcon,
|
|
306
|
+
headerCloseIcon: HeaderCloseIcon,
|
|
307
|
+
sendIcon: SendIcon,
|
|
308
|
+
activityIcon: ActivityIcon,
|
|
309
|
+
spinnerIcon: SpinnerIcon,
|
|
310
|
+
stopIcon: StopIcon,
|
|
311
|
+
regenerateIcon: RegenerateIcon
|
|
312
|
+
}), {
|
|
313
|
+
icons
|
|
314
|
+
})
|
|
315
|
+
}),
|
|
316
|
+
[labels, icons]
|
|
317
|
+
);
|
|
318
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ChatContext.Provider, { value: context, children });
|
|
319
|
+
};
|
|
320
|
+
var Window = ({
|
|
321
|
+
open,
|
|
322
|
+
setOpen,
|
|
323
|
+
children,
|
|
324
|
+
clickOutsideToClose,
|
|
325
|
+
hotkey,
|
|
326
|
+
hitEscapeToClose
|
|
327
|
+
}) => {
|
|
328
|
+
const windowRef = React__namespace.default.useRef(null);
|
|
329
|
+
const handleClickOutside = React.useCallback(
|
|
330
|
+
(event) => {
|
|
331
|
+
var _a;
|
|
332
|
+
if (!clickOutsideToClose) {
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
const parentElement = (_a = windowRef.current) == null ? void 0 : _a.parentElement;
|
|
336
|
+
if (open && parentElement && !parentElement.contains(event.target)) {
|
|
337
|
+
setOpen(false);
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
[clickOutsideToClose, open, setOpen]
|
|
341
|
+
);
|
|
342
|
+
const handleKeyDown = React.useCallback(
|
|
343
|
+
(event) => {
|
|
344
|
+
var _a;
|
|
345
|
+
const target = event.target;
|
|
346
|
+
const isInput = target.tagName === "INPUT" || target.tagName === "SELECT" || target.tagName === "TEXTAREA" || target.isContentEditable;
|
|
347
|
+
const isDescendantOfWrapper = (_a = windowRef.current) == null ? void 0 : _a.contains(target);
|
|
348
|
+
if (open && event.key === "Escape" && (!isInput || isDescendantOfWrapper) && hitEscapeToClose) {
|
|
349
|
+
setOpen(false);
|
|
350
|
+
} else if (event.key === hotkey && (isMacOS() && event.metaKey || !isMacOS() && event.ctrlKey) && (!isInput || isDescendantOfWrapper)) {
|
|
351
|
+
setOpen(!open);
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
[hitEscapeToClose, hotkey, open, setOpen]
|
|
355
|
+
);
|
|
356
|
+
const adjustForMobile = React.useCallback(() => {
|
|
357
|
+
const copilotKitWindow = windowRef.current;
|
|
358
|
+
const vv = window.visualViewport;
|
|
359
|
+
if (!copilotKitWindow || !vv) {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
if (window.innerWidth < 640 && open) {
|
|
363
|
+
copilotKitWindow.style.height = `${vv.height}px`;
|
|
364
|
+
copilotKitWindow.style.left = `${vv.offsetLeft}px`;
|
|
365
|
+
copilotKitWindow.style.top = `${vv.offsetTop}px`;
|
|
366
|
+
document.body.style.position = "fixed";
|
|
367
|
+
document.body.style.width = "100%";
|
|
368
|
+
document.body.style.height = `${window.innerHeight}px`;
|
|
369
|
+
document.body.style.overflow = "hidden";
|
|
370
|
+
document.body.style.touchAction = "none";
|
|
371
|
+
document.body.addEventListener("touchmove", preventScroll, {
|
|
372
|
+
passive: false
|
|
373
|
+
});
|
|
374
|
+
} else {
|
|
375
|
+
copilotKitWindow.style.height = "";
|
|
376
|
+
copilotKitWindow.style.left = "";
|
|
377
|
+
copilotKitWindow.style.top = "";
|
|
378
|
+
document.body.style.position = "";
|
|
379
|
+
document.body.style.height = "";
|
|
380
|
+
document.body.style.width = "";
|
|
381
|
+
document.body.style.overflow = "";
|
|
382
|
+
document.body.style.top = "";
|
|
383
|
+
document.body.style.touchAction = "";
|
|
384
|
+
document.body.removeEventListener("touchmove", preventScroll);
|
|
385
|
+
}
|
|
386
|
+
}, [open]);
|
|
387
|
+
React.useEffect(() => {
|
|
388
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
389
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
390
|
+
if (window.visualViewport) {
|
|
391
|
+
window.visualViewport.addEventListener("resize", adjustForMobile);
|
|
392
|
+
adjustForMobile();
|
|
393
|
+
}
|
|
394
|
+
return () => {
|
|
395
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
396
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
397
|
+
if (window.visualViewport) {
|
|
398
|
+
window.visualViewport.removeEventListener("resize", adjustForMobile);
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
}, [adjustForMobile, handleClickOutside, handleKeyDown]);
|
|
402
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `copilotKitWindow${open ? " open" : ""}`, ref: windowRef, children });
|
|
403
|
+
};
|
|
404
|
+
var preventScroll = (event) => {
|
|
405
|
+
let targetElement = event.target;
|
|
406
|
+
const hasParentWithClass = (element, className) => {
|
|
407
|
+
while (element && element !== document.body) {
|
|
408
|
+
if (element.classList.contains(className)) {
|
|
409
|
+
return true;
|
|
410
|
+
}
|
|
411
|
+
element = element.parentElement;
|
|
412
|
+
}
|
|
413
|
+
return false;
|
|
414
|
+
};
|
|
415
|
+
if (!hasParentWithClass(targetElement, "copilotKitMessages")) {
|
|
416
|
+
event.preventDefault();
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
function isMacOS() {
|
|
420
|
+
return /Mac|iMac|Macintosh/i.test(navigator.userAgent);
|
|
421
|
+
}
|
|
422
|
+
var Button = ({ open, setOpen }) => {
|
|
423
|
+
const context = useChatContext();
|
|
424
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { onClick: () => setOpen(!open), children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
425
|
+
"button",
|
|
426
|
+
{
|
|
427
|
+
className: `copilotKitButton ${open ? "open" : ""}`,
|
|
428
|
+
"aria-label": open ? "Close Chat" : "Open Chat",
|
|
429
|
+
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 })
|
|
432
|
+
]
|
|
433
|
+
}
|
|
434
|
+
) });
|
|
435
|
+
};
|
|
436
|
+
var Header = ({ setOpen }) => {
|
|
437
|
+
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 })
|
|
441
|
+
] });
|
|
442
|
+
};
|
|
443
|
+
function useCopyToClipboard({ timeout = 2e3 }) {
|
|
444
|
+
const [isCopied, setIsCopied] = React__namespace.useState(false);
|
|
445
|
+
const copyToClipboard = (value) => {
|
|
446
|
+
var _a;
|
|
447
|
+
if (typeof window === "undefined" || !((_a = navigator.clipboard) == null ? void 0 : _a.writeText)) {
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
if (!value) {
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
navigator.clipboard.writeText(value).then(() => {
|
|
454
|
+
setIsCopied(true);
|
|
455
|
+
setTimeout(() => {
|
|
456
|
+
setIsCopied(false);
|
|
457
|
+
}, timeout);
|
|
458
|
+
});
|
|
459
|
+
};
|
|
460
|
+
return { isCopied, copyToClipboard };
|
|
461
|
+
}
|
|
462
|
+
var programmingLanguages = {
|
|
463
|
+
javascript: ".js",
|
|
464
|
+
python: ".py",
|
|
465
|
+
java: ".java",
|
|
466
|
+
c: ".c",
|
|
467
|
+
cpp: ".cpp",
|
|
468
|
+
"c++": ".cpp",
|
|
469
|
+
"c#": ".cs",
|
|
470
|
+
ruby: ".rb",
|
|
471
|
+
php: ".php",
|
|
472
|
+
swift: ".swift",
|
|
473
|
+
"objective-c": ".m",
|
|
474
|
+
kotlin: ".kt",
|
|
475
|
+
typescript: ".ts",
|
|
476
|
+
go: ".go",
|
|
477
|
+
perl: ".pl",
|
|
478
|
+
rust: ".rs",
|
|
479
|
+
scala: ".scala",
|
|
480
|
+
haskell: ".hs",
|
|
481
|
+
lua: ".lua",
|
|
482
|
+
shell: ".sh",
|
|
483
|
+
sql: ".sql",
|
|
484
|
+
html: ".html",
|
|
485
|
+
css: ".css"
|
|
486
|
+
// add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component
|
|
487
|
+
};
|
|
488
|
+
var generateRandomString = (length, lowercase = false) => {
|
|
489
|
+
const chars = "ABCDEFGHJKLMNPQRSTUVWXY3456789";
|
|
490
|
+
let result = "";
|
|
491
|
+
for (let i = 0; i < length; i++) {
|
|
492
|
+
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
493
|
+
}
|
|
494
|
+
return lowercase ? result.toLowerCase() : result;
|
|
495
|
+
};
|
|
496
|
+
var CodeBlock = React.memo(({ language, value }) => {
|
|
497
|
+
const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2e3 });
|
|
498
|
+
const downloadAsFile = () => {
|
|
499
|
+
if (typeof window === "undefined") {
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
502
|
+
const fileExtension = programmingLanguages[language] || ".file";
|
|
503
|
+
const suggestedFileName = `file-${generateRandomString(3, true)}${fileExtension}`;
|
|
504
|
+
const fileName = window.prompt("Enter file name", suggestedFileName);
|
|
505
|
+
if (!fileName) {
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
const blob = new Blob([value], { type: "text/plain" });
|
|
509
|
+
const url = URL.createObjectURL(blob);
|
|
510
|
+
const link = document.createElement("a");
|
|
511
|
+
link.download = fileName;
|
|
512
|
+
link.href = url;
|
|
513
|
+
link.style.display = "none";
|
|
514
|
+
document.body.appendChild(link);
|
|
515
|
+
link.click();
|
|
516
|
+
document.body.removeChild(link);
|
|
517
|
+
URL.revokeObjectURL(url);
|
|
518
|
+
};
|
|
519
|
+
const onCopy = () => {
|
|
520
|
+
if (isCopied)
|
|
521
|
+
return;
|
|
522
|
+
copyToClipboard(value);
|
|
523
|
+
};
|
|
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" })
|
|
531
|
+
] }),
|
|
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" })
|
|
535
|
+
] })
|
|
536
|
+
] })
|
|
537
|
+
] }),
|
|
538
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
539
|
+
reactSyntaxHighlighter.Prism,
|
|
540
|
+
{
|
|
541
|
+
language,
|
|
542
|
+
style: prism.vscDarkPlus,
|
|
543
|
+
PreTag: "div",
|
|
544
|
+
customStyle: {
|
|
545
|
+
margin: 0,
|
|
546
|
+
borderBottomLeftRadius: "0.375rem",
|
|
547
|
+
borderBottomRightRadius: "0.375rem"
|
|
548
|
+
},
|
|
549
|
+
children: value
|
|
550
|
+
}
|
|
551
|
+
)
|
|
552
|
+
] });
|
|
553
|
+
});
|
|
554
|
+
CodeBlock.displayName = "CodeBlock";
|
|
555
|
+
var MemoizedReactMarkdown = React.memo(
|
|
556
|
+
ReactMarkdown__default.default,
|
|
557
|
+
(prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.className === nextProps.className
|
|
558
|
+
);
|
|
559
|
+
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 }) });
|
|
561
|
+
};
|
|
562
|
+
var components = {
|
|
563
|
+
p({ children }) {
|
|
564
|
+
return /* @__PURE__ */ jsxRuntime.jsx("p", { children });
|
|
565
|
+
},
|
|
566
|
+
code(_a) {
|
|
567
|
+
var _b = _a, { children, className, inline } = _b, props = __objRest(_b, ["children", "className", "inline"]);
|
|
568
|
+
if (children.length) {
|
|
569
|
+
if (children[0] == "\u258D") {
|
|
570
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
571
|
+
"span",
|
|
572
|
+
{
|
|
573
|
+
style: {
|
|
574
|
+
animation: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",
|
|
575
|
+
marginTop: "0.25rem"
|
|
576
|
+
},
|
|
577
|
+
children: "\u258D"
|
|
578
|
+
}
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
children[0] = children[0].replace("`\u258D`", "\u258D");
|
|
582
|
+
}
|
|
583
|
+
const match = /language-(\w+)/.exec(className || "");
|
|
584
|
+
if (inline) {
|
|
585
|
+
return /* @__PURE__ */ jsxRuntime.jsx("code", __spreadProps(__spreadValues({ className }, props), { children }));
|
|
586
|
+
}
|
|
587
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
588
|
+
CodeBlock,
|
|
589
|
+
__spreadValues({
|
|
590
|
+
language: match && match[1] || "",
|
|
591
|
+
value: String(children).replace(/\n$/, "")
|
|
592
|
+
}, props),
|
|
593
|
+
Math.random()
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
};
|
|
597
|
+
var Messages = ({ messages, inProgress }) => {
|
|
598
|
+
const context = useChatContext();
|
|
599
|
+
const initialMessages = React.useMemo(
|
|
600
|
+
() => makeInitialMessages(context.labels.initial),
|
|
601
|
+
[context.labels.initial]
|
|
602
|
+
);
|
|
603
|
+
messages = [...initialMessages, ...messages];
|
|
604
|
+
const messagesEndRef = React__namespace.default.useRef(null);
|
|
605
|
+
const scrollToBottom = () => {
|
|
606
|
+
if (messagesEndRef.current) {
|
|
607
|
+
messagesEndRef.current.scrollIntoView({
|
|
608
|
+
behavior: "auto"
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
};
|
|
612
|
+
React.useEffect(() => {
|
|
613
|
+
scrollToBottom();
|
|
614
|
+
}, [messages]);
|
|
615
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "copilotKitMessages", children: [
|
|
616
|
+
messages.map((message, index) => {
|
|
617
|
+
const isCurrentMessage = index === messages.length - 1;
|
|
618
|
+
if (message.role === "user") {
|
|
619
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "copilotKitMessage copilotKitUserMessage", children: message.content }, index);
|
|
620
|
+
} else if (message.role == "assistant") {
|
|
621
|
+
if (isCurrentMessage && inProgress && !message.content) {
|
|
622
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: context.icons.spinnerIcon }, index);
|
|
623
|
+
} 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);
|
|
625
|
+
} else {
|
|
626
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: /* @__PURE__ */ jsxRuntime.jsx(Markdown, { content: message.content }) }, index);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
}),
|
|
630
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: messagesEndRef })
|
|
631
|
+
] });
|
|
632
|
+
};
|
|
633
|
+
function makeInitialMessages(initial) {
|
|
634
|
+
let initialArray = [];
|
|
635
|
+
if (initial) {
|
|
636
|
+
if (Array.isArray(initial)) {
|
|
637
|
+
initialArray.push(...initial);
|
|
638
|
+
} else {
|
|
639
|
+
initialArray.push(initial);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
return initialArray.map((message) => ({
|
|
643
|
+
id: nanoid.nanoid(),
|
|
644
|
+
role: "assistant",
|
|
645
|
+
content: message
|
|
646
|
+
}));
|
|
647
|
+
}
|
|
648
|
+
var AutoResizingTextarea = React.forwardRef(
|
|
649
|
+
({ 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(() => {
|
|
654
|
+
const calculateMaxHeight = () => {
|
|
655
|
+
const textarea = internalTextareaRef.current;
|
|
656
|
+
if (textarea) {
|
|
657
|
+
textarea.style.height = "auto";
|
|
658
|
+
const singleRowHeight = textarea.scrollHeight;
|
|
659
|
+
setMaxHeight(singleRowHeight * maxRows);
|
|
660
|
+
if (autoFocus) {
|
|
661
|
+
textarea.focus();
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
};
|
|
665
|
+
calculateMaxHeight();
|
|
666
|
+
}, [maxRows]);
|
|
667
|
+
React.useEffect(() => {
|
|
668
|
+
const textarea = internalTextareaRef.current;
|
|
669
|
+
if (textarea) {
|
|
670
|
+
textarea.style.height = "auto";
|
|
671
|
+
textarea.style.height = `${Math.min(textarea.scrollHeight, maxHeight)}px`;
|
|
672
|
+
}
|
|
673
|
+
}, [value, maxHeight]);
|
|
674
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
675
|
+
"textarea",
|
|
676
|
+
{
|
|
677
|
+
ref: internalTextareaRef,
|
|
678
|
+
value,
|
|
679
|
+
onChange,
|
|
680
|
+
onKeyDown,
|
|
681
|
+
placeholder,
|
|
682
|
+
style: {
|
|
683
|
+
overflow: "hidden",
|
|
684
|
+
resize: "none",
|
|
685
|
+
maxHeight: `${maxHeight}px`
|
|
686
|
+
},
|
|
687
|
+
rows: 1
|
|
688
|
+
}
|
|
689
|
+
);
|
|
690
|
+
}
|
|
691
|
+
);
|
|
692
|
+
var Textarea_default = AutoResizingTextarea;
|
|
693
|
+
var Input = ({ inProgress, onSend, children }) => {
|
|
694
|
+
const context = useChatContext();
|
|
695
|
+
const textareaRef = React.useRef(null);
|
|
696
|
+
const handleDivClick = (event) => {
|
|
697
|
+
var _a;
|
|
698
|
+
if (event.target !== event.currentTarget)
|
|
699
|
+
return;
|
|
700
|
+
(_a = textareaRef.current) == null ? void 0 : _a.focus();
|
|
701
|
+
};
|
|
702
|
+
const [text, setText] = React.useState("");
|
|
703
|
+
const send = () => {
|
|
704
|
+
var _a;
|
|
705
|
+
if (inProgress)
|
|
706
|
+
return;
|
|
707
|
+
onSend(text);
|
|
708
|
+
setText("");
|
|
709
|
+
(_a = textareaRef.current) == null ? void 0 : _a.focus();
|
|
710
|
+
};
|
|
711
|
+
const icon = inProgress ? context.icons.activityIcon : context.icons.sendIcon;
|
|
712
|
+
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(
|
|
717
|
+
Textarea_default,
|
|
718
|
+
{
|
|
719
|
+
ref: textareaRef,
|
|
720
|
+
placeholder: context.labels.placeholder,
|
|
721
|
+
autoFocus: true,
|
|
722
|
+
maxRows: 5,
|
|
723
|
+
value: text,
|
|
724
|
+
onChange: (event) => setText(event.target.value),
|
|
725
|
+
onKeyDown: (event) => {
|
|
726
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
727
|
+
event.preventDefault();
|
|
728
|
+
send();
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
)
|
|
733
|
+
] });
|
|
734
|
+
};
|
|
735
|
+
var ResponseButton = ({ onClick, inProgress }) => {
|
|
736
|
+
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 }),
|
|
739
|
+
inProgress ? context.labels.stopGenerating : context.labels.regenerateResponse
|
|
740
|
+
] });
|
|
741
|
+
};
|
|
742
|
+
var CopilotChat = ({
|
|
743
|
+
instructions,
|
|
744
|
+
defaultOpen = false,
|
|
745
|
+
clickOutsideToClose = true,
|
|
746
|
+
hitEscapeToClose = true,
|
|
747
|
+
onSetOpen,
|
|
748
|
+
hotkey = "e",
|
|
749
|
+
icons,
|
|
750
|
+
labels,
|
|
751
|
+
makeSystemMessage,
|
|
752
|
+
showResponseButton = true,
|
|
753
|
+
Window: Window2 = Window,
|
|
754
|
+
Button: Button2 = Button,
|
|
755
|
+
Header: Header2 = Header,
|
|
756
|
+
Messages: Messages2 = Messages,
|
|
757
|
+
Input: Input2 = Input,
|
|
758
|
+
ResponseButton: ResponseButton2 = ResponseButton,
|
|
759
|
+
className
|
|
760
|
+
}) => {
|
|
761
|
+
const { visibleMessages, append, reload, stop, isLoading, input, setInput } = reactCore.useCopilotChat({
|
|
762
|
+
id: nanoid.nanoid(),
|
|
763
|
+
makeSystemMessage,
|
|
764
|
+
additionalInstructions: instructions
|
|
765
|
+
});
|
|
766
|
+
const [openState, setOpenState] = React__namespace.default.useState(defaultOpen);
|
|
767
|
+
const setOpen = (open) => {
|
|
768
|
+
onSetOpen == null ? void 0 : onSetOpen(open);
|
|
769
|
+
setOpenState(open);
|
|
770
|
+
};
|
|
771
|
+
const sendMessage = (message) => __async(void 0, null, function* () {
|
|
772
|
+
append({
|
|
773
|
+
id: nanoid.nanoid(),
|
|
774
|
+
content: message,
|
|
775
|
+
role: "user"
|
|
776
|
+
});
|
|
777
|
+
});
|
|
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(
|
|
781
|
+
Window2,
|
|
782
|
+
{
|
|
783
|
+
open: openState,
|
|
784
|
+
setOpen,
|
|
785
|
+
clickOutsideToClose,
|
|
786
|
+
hotkey,
|
|
787
|
+
hitEscapeToClose,
|
|
788
|
+
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 }) })
|
|
792
|
+
]
|
|
793
|
+
}
|
|
794
|
+
)
|
|
795
|
+
] }) });
|
|
796
|
+
};
|
|
797
|
+
var CopilotPopup = (props) => {
|
|
798
|
+
props = __spreadProps(__spreadValues({}, props), {
|
|
799
|
+
className: props.className ? props.className + " copilotKitPopup" : "copilotKitPopup"
|
|
800
|
+
});
|
|
801
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CopilotChat, __spreadValues({}, props));
|
|
802
|
+
};
|
|
803
|
+
|
|
804
|
+
exports.CopilotPopup = CopilotPopup;
|
|
805
|
+
//# sourceMappingURL=out.js.map
|
|
806
|
+
//# sourceMappingURL=Popup.js.map
|