@copilotkit/react-ui 0.10.0-alpha.4 → 0.10.0-alpha.5

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 (89) hide show
  1. package/.turbo/turbo-build.log +180 -88
  2. package/CHANGELOG.md +11 -0
  3. package/dist/components/chat-components/chat-list.js +470 -0
  4. package/dist/components/chat-components/chat-list.js.map +1 -0
  5. package/dist/components/chat-components/chat-message-actions.js +188 -0
  6. package/dist/components/chat-components/chat-message-actions.js.map +1 -0
  7. package/dist/components/chat-components/chat-message.js +431 -0
  8. package/dist/components/chat-components/chat-message.js.map +1 -0
  9. package/dist/components/chat-components/chat-panel.js +330 -0
  10. package/dist/components/chat-components/chat-panel.js.map +1 -0
  11. package/dist/components/chat-components/chat-scroll-anchor.js +65 -0
  12. package/dist/components/chat-components/chat-scroll-anchor.js.map +1 -0
  13. package/dist/components/chat-components/clear-history.js +323 -0
  14. package/dist/components/chat-components/clear-history.js.map +1 -0
  15. package/dist/components/chat-components/copilot-chat.js +876 -0
  16. package/dist/components/chat-components/copilot-chat.js.map +1 -0
  17. package/dist/components/chat-components/default-empty-screen.js +211 -0
  18. package/dist/components/chat-components/default-empty-screen.js.map +1 -0
  19. package/dist/components/chat-components/external-link.js +35 -0
  20. package/dist/components/chat-components/external-link.js.map +1 -0
  21. package/dist/components/chat-components/markdown.js +14 -0
  22. package/dist/components/chat-components/markdown.js.map +1 -0
  23. package/dist/components/chat-components/prompt-form.js +245 -0
  24. package/dist/components/chat-components/prompt-form.js.map +1 -0
  25. package/dist/components/chat-components/theme-toggle.js +158 -0
  26. package/dist/components/chat-components/theme-toggle.js.map +1 -0
  27. package/dist/components/chat-components/toaster.js +12 -0
  28. package/dist/components/chat-components/toaster.js.map +1 -0
  29. package/dist/components/chat-components/ui/alert-dialog.js +229 -0
  30. package/dist/components/chat-components/ui/alert-dialog.js.map +1 -0
  31. package/dist/components/chat-components/ui/badge.js +70 -0
  32. package/dist/components/chat-components/ui/badge.js.map +1 -0
  33. package/dist/components/chat-components/ui/button.js +105 -0
  34. package/dist/components/chat-components/ui/button.js.map +1 -0
  35. package/dist/components/chat-components/ui/codeblock.js +299 -0
  36. package/dist/components/chat-components/ui/codeblock.js.map +1 -0
  37. package/dist/components/chat-components/ui/dialog.js +198 -0
  38. package/dist/components/chat-components/ui/dialog.js.map +1 -0
  39. package/dist/components/chat-components/ui/dropdown-menu.js +153 -0
  40. package/dist/components/chat-components/ui/dropdown-menu.js.map +1 -0
  41. package/dist/components/chat-components/ui/icons.js +567 -0
  42. package/dist/components/chat-components/ui/icons.js.map +1 -0
  43. package/dist/components/chat-components/ui/input.js +80 -0
  44. package/dist/components/chat-components/ui/input.js.map +1 -0
  45. package/dist/components/chat-components/ui/label.js +80 -0
  46. package/dist/components/chat-components/ui/label.js.map +1 -0
  47. package/dist/components/chat-components/ui/select.js +196 -0
  48. package/dist/components/chat-components/ui/select.js.map +1 -0
  49. package/dist/components/chat-components/ui/separator.js +84 -0
  50. package/dist/components/chat-components/ui/separator.js.map +1 -0
  51. package/dist/components/chat-components/ui/sheet.js +189 -0
  52. package/dist/components/chat-components/ui/sheet.js.map +1 -0
  53. package/dist/components/chat-components/ui/switch.js +88 -0
  54. package/dist/components/chat-components/ui/switch.js.map +1 -0
  55. package/dist/components/chat-components/ui/textarea.js +79 -0
  56. package/dist/components/chat-components/ui/textarea.js.map +1 -0
  57. package/dist/components/chat-components/ui/tooltip.js +86 -0
  58. package/dist/components/chat-components/ui/tooltip.js.map +1 -0
  59. package/dist/components/index.js +989 -0
  60. package/dist/components/index.js.map +1 -0
  61. package/dist/components/sidebar/copilot-sidebar-ui-provider.js +984 -0
  62. package/dist/components/sidebar/copilot-sidebar-ui-provider.js.map +1 -0
  63. package/dist/components/sidebar/copilot-sidebar.js +916 -0
  64. package/dist/components/sidebar/copilot-sidebar.js.map +1 -0
  65. package/dist/components/sidebar/sidebar-context.js +14 -0
  66. package/dist/components/sidebar/sidebar-context.js.map +1 -0
  67. package/dist/context/index.js +4 -0
  68. package/dist/context/index.js.map +1 -0
  69. package/dist/hooks/index.js +4 -0
  70. package/dist/hooks/index.js.map +1 -0
  71. package/dist/hooks/use-at-bottom.js +44 -0
  72. package/dist/hooks/use-at-bottom.js.map +1 -0
  73. package/dist/hooks/use-copy-to-clipboard.js +49 -0
  74. package/dist/hooks/use-copy-to-clipboard.js.map +1 -0
  75. package/dist/hooks/use-enter-submit.js +20 -0
  76. package/dist/hooks/use-enter-submit.js.map +1 -0
  77. package/dist/index.js +989 -0
  78. package/dist/index.js.map +1 -0
  79. package/dist/index.mjs +1 -1
  80. package/dist/lib/utils.js +64 -0
  81. package/dist/lib/utils.js.map +1 -0
  82. package/dist/lib/utils.test.js +10 -0
  83. package/dist/lib/utils.test.js.map +1 -0
  84. package/dist/types/index.js +4 -0
  85. package/dist/types/index.js.map +1 -0
  86. package/dist/types/types.js +4 -0
  87. package/dist/types/types.js.map +1 -0
  88. package/package.json +4 -4
  89. package/tsup.config.ts +1 -1
@@ -0,0 +1,984 @@
1
+ 'use strict';
2
+
3
+ var React6 = require('react');
4
+ var SeparatorPrimitive = require('@radix-ui/react-separator');
5
+ var clsx = require('clsx');
6
+ var nanoid = require('nanoid');
7
+ var tailwindMerge = require('tailwind-merge');
8
+ var jsxRuntime = require('react/jsx-runtime');
9
+ var remarkGfm = require('remark-gfm');
10
+ var remarkMath = require('remark-math');
11
+ var reactSyntaxHighlighter = require('react-syntax-highlighter');
12
+ var reactSlot = require('@radix-ui/react-slot');
13
+ var classVarianceAuthority = require('class-variance-authority');
14
+ var ReactMarkdown = require('react-markdown');
15
+ var TextareaAutosize = require('react-textarea-autosize');
16
+ var TooltipPrimitive = require('@radix-ui/react-tooltip');
17
+ var reactIntersectionObserver = require('react-intersection-observer');
18
+ var reactCore = require('@copilotkit/react-core');
19
+ var outline = require('@heroicons/react/24/outline');
20
+
21
+ function _interopNamespaceDefault(e) {
22
+ var n = Object.create(null);
23
+ if (e) {
24
+ Object.keys(e).forEach(function (k) {
25
+ if (k !== 'default') {
26
+ var d = Object.getOwnPropertyDescriptor(e, k);
27
+ Object.defineProperty(n, k, d.get ? d : {
28
+ enumerable: true,
29
+ get: function () { return e[k]; }
30
+ });
31
+ }
32
+ });
33
+ }
34
+ n.default = e;
35
+ return Object.freeze(n);
36
+ }
37
+
38
+ var React6__namespace = /*#__PURE__*/_interopNamespaceDefault(React6);
39
+ var SeparatorPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(SeparatorPrimitive);
40
+ var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespaceDefault(TooltipPrimitive);
41
+
42
+ var __defProp = Object.defineProperty;
43
+ var __defProps = Object.defineProperties;
44
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
45
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
46
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
47
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
48
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
49
+ var __spreadValues = (a, b) => {
50
+ for (var prop in b || (b = {}))
51
+ if (__hasOwnProp.call(b, prop))
52
+ __defNormalProp(a, prop, b[prop]);
53
+ if (__getOwnPropSymbols)
54
+ for (var prop of __getOwnPropSymbols(b)) {
55
+ if (__propIsEnum.call(b, prop))
56
+ __defNormalProp(a, prop, b[prop]);
57
+ }
58
+ return a;
59
+ };
60
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
61
+ var __objRest = (source, exclude) => {
62
+ var target = {};
63
+ for (var prop in source)
64
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
65
+ target[prop] = source[prop];
66
+ if (source != null && __getOwnPropSymbols)
67
+ for (var prop of __getOwnPropSymbols(source)) {
68
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
69
+ target[prop] = source[prop];
70
+ }
71
+ return target;
72
+ };
73
+ var __async = (__this, __arguments, generator) => {
74
+ return new Promise((resolve, reject) => {
75
+ var fulfilled = (value) => {
76
+ try {
77
+ step(generator.next(value));
78
+ } catch (e) {
79
+ reject(e);
80
+ }
81
+ };
82
+ var rejected = (value) => {
83
+ try {
84
+ step(generator.throw(value));
85
+ } catch (e) {
86
+ reject(e);
87
+ }
88
+ };
89
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
90
+ step((generator = generator.apply(__this, __arguments)).next());
91
+ });
92
+ };
93
+ function cn(...inputs) {
94
+ return tailwindMerge.twMerge(clsx.clsx(inputs));
95
+ }
96
+ nanoid.customAlphabet(
97
+ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
98
+ 7
99
+ );
100
+ var Separator = React6__namespace.forwardRef(
101
+ (_a, ref) => {
102
+ var _b = _a, { className, orientation = "horizontal", decorative = true } = _b, props = __objRest(_b, ["className", "orientation", "decorative"]);
103
+ return /* @__PURE__ */ jsxRuntime.jsx(SeparatorPrimitive__namespace.Root, __spreadValues({
104
+ ref,
105
+ decorative,
106
+ orientation,
107
+ className: cn(
108
+ "shrink-0 bg-border",
109
+ orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
110
+ className
111
+ )
112
+ }, props));
113
+ }
114
+ );
115
+ Separator.displayName = SeparatorPrimitive__namespace.Root.displayName;
116
+ function useCopyToClipboard({
117
+ timeout = 2e3
118
+ }) {
119
+ const [isCopied, setIsCopied] = React6__namespace.useState(false);
120
+ const copyToClipboard = (value) => {
121
+ var _a;
122
+ if (typeof window === "undefined" || !((_a = navigator.clipboard) == null ? void 0 : _a.writeText)) {
123
+ return;
124
+ }
125
+ if (!value) {
126
+ return;
127
+ }
128
+ navigator.clipboard.writeText(value).then(() => {
129
+ setIsCopied(true);
130
+ setTimeout(() => {
131
+ setIsCopied(false);
132
+ }, timeout);
133
+ });
134
+ };
135
+ return { isCopied, copyToClipboard };
136
+ }
137
+ function IconOpenAI(_a) {
138
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
139
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", __spreadProps(__spreadValues({
140
+ fill: "currentColor",
141
+ viewBox: "0 0 24 24",
142
+ role: "img",
143
+ xmlns: "http://www.w3.org/2000/svg",
144
+ className: cn("h-4 w-4", className)
145
+ }, props), {
146
+ children: [
147
+ /* @__PURE__ */ jsxRuntime.jsx("title", {
148
+ children: "OpenAI icon"
149
+ }),
150
+ /* @__PURE__ */ jsxRuntime.jsx("path", {
151
+ d: "M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"
152
+ })
153
+ ]
154
+ }));
155
+ }
156
+ function IconArrowRight(_a) {
157
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
158
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", __spreadProps(__spreadValues({
159
+ xmlns: "http://www.w3.org/2000/svg",
160
+ viewBox: "0 0 256 256",
161
+ fill: "currentColor",
162
+ className: cn("h-4 w-4", className)
163
+ }, props), {
164
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", {
165
+ d: "m221.66 133.66-72 72a8 8 0 0 1-11.32-11.32L196.69 136H40a8 8 0 0 1 0-16h156.69l-58.35-58.34a8 8 0 0 1 11.32-11.32l72 72a8 8 0 0 1 0 11.32Z"
166
+ })
167
+ }));
168
+ }
169
+ function IconUser(_a) {
170
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
171
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", __spreadProps(__spreadValues({
172
+ xmlns: "http://www.w3.org/2000/svg",
173
+ viewBox: "0 0 256 256",
174
+ fill: "currentColor",
175
+ className: cn("h-4 w-4", className)
176
+ }, props), {
177
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", {
178
+ d: "M230.92 212c-15.23-26.33-38.7-45.21-66.09-54.16a72 72 0 1 0-73.66 0c-27.39 8.94-50.86 27.82-66.09 54.16a8 8 0 1 0 13.85 8c18.84-32.56 52.14-52 89.07-52s70.23 19.44 89.07 52a8 8 0 1 0 13.85-8ZM72 96a56 56 0 1 1 56 56 56.06 56.06 0 0 1-56-56Z"
179
+ })
180
+ }));
181
+ }
182
+ function IconArrowElbow(_a) {
183
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
184
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", __spreadProps(__spreadValues({
185
+ xmlns: "http://www.w3.org/2000/svg",
186
+ viewBox: "0 0 256 256",
187
+ fill: "currentColor",
188
+ className: cn("h-4 w-4", className)
189
+ }, props), {
190
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", {
191
+ d: "M200 32v144a8 8 0 0 1-8 8H67.31l34.35 34.34a8 8 0 0 1-11.32 11.32l-48-48a8 8 0 0 1 0-11.32l48-48a8 8 0 0 1 11.32 11.32L67.31 168H184V32a8 8 0 0 1 16 0Z"
192
+ })
193
+ }));
194
+ }
195
+ function IconRefresh(_a) {
196
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
197
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", __spreadProps(__spreadValues({
198
+ xmlns: "http://www.w3.org/2000/svg",
199
+ viewBox: "0 0 256 256",
200
+ fill: "currentColor",
201
+ className: cn("h-4 w-4", className)
202
+ }, props), {
203
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", {
204
+ 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"
205
+ })
206
+ }));
207
+ }
208
+ function IconStop(_a) {
209
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
210
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", __spreadProps(__spreadValues({
211
+ xmlns: "http://www.w3.org/2000/svg",
212
+ viewBox: "0 0 256 256",
213
+ fill: "currentColor",
214
+ className: cn("h-4 w-4", className)
215
+ }, props), {
216
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", {
217
+ 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"
218
+ })
219
+ }));
220
+ }
221
+ function IconCopy(_a) {
222
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
223
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", __spreadProps(__spreadValues({
224
+ xmlns: "http://www.w3.org/2000/svg",
225
+ viewBox: "0 0 256 256",
226
+ fill: "currentColor",
227
+ className: cn("h-4 w-4", className)
228
+ }, props), {
229
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", {
230
+ 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"
231
+ })
232
+ }));
233
+ }
234
+ function IconCheck(_a) {
235
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
236
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", __spreadProps(__spreadValues({
237
+ xmlns: "http://www.w3.org/2000/svg",
238
+ viewBox: "0 0 256 256",
239
+ fill: "currentColor",
240
+ className: cn("h-4 w-4", className)
241
+ }, props), {
242
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", {
243
+ 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"
244
+ })
245
+ }));
246
+ }
247
+ function IconDownload(_a) {
248
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
249
+ return /* @__PURE__ */ jsxRuntime.jsx("svg", __spreadProps(__spreadValues({
250
+ xmlns: "http://www.w3.org/2000/svg",
251
+ viewBox: "0 0 256 256",
252
+ fill: "currentColor",
253
+ className: cn("h-4 w-4", className)
254
+ }, props), {
255
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", {
256
+ 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"
257
+ })
258
+ }));
259
+ }
260
+ var buttonVariants = classVarianceAuthority.cva(
261
+ "inline-flex items-center justify-center rounded-md text-sm font-medium shadow ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
262
+ {
263
+ variants: {
264
+ variant: {
265
+ default: "bg-primary text-primary-foreground shadow-md hover:bg-primary/90",
266
+ destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
267
+ outline: "border border-input hover:bg-accent hover:text-accent-foreground",
268
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
269
+ ghost: "shadow-none hover:bg-accent hover:text-accent-foreground",
270
+ link: "text-primary underline-offset-4 shadow-none hover:underline"
271
+ },
272
+ size: {
273
+ default: "h-8 px-4 py-2",
274
+ sm: "h-8 rounded-md px-3",
275
+ lg: "h-11 rounded-md px-8",
276
+ icon: "h-8 w-8 p-0"
277
+ }
278
+ },
279
+ defaultVariants: {
280
+ variant: "default",
281
+ size: "default"
282
+ }
283
+ }
284
+ );
285
+ var Button = React6__namespace.forwardRef(
286
+ (_a, ref) => {
287
+ var _b = _a, { className, variant, size, asChild = false } = _b, props = __objRest(_b, ["className", "variant", "size", "asChild"]);
288
+ const Comp = asChild ? reactSlot.Slot : "button";
289
+ return /* @__PURE__ */ jsxRuntime.jsx(Comp, __spreadValues({
290
+ className: cn(buttonVariants({ variant, size, className })),
291
+ ref
292
+ }, props));
293
+ }
294
+ );
295
+ Button.displayName = "Button";
296
+ var programmingLanguages = {
297
+ javascript: ".js",
298
+ python: ".py",
299
+ java: ".java",
300
+ c: ".c",
301
+ cpp: ".cpp",
302
+ "c++": ".cpp",
303
+ "c#": ".cs",
304
+ ruby: ".rb",
305
+ php: ".php",
306
+ swift: ".swift",
307
+ "objective-c": ".m",
308
+ kotlin: ".kt",
309
+ typescript: ".ts",
310
+ go: ".go",
311
+ perl: ".pl",
312
+ rust: ".rs",
313
+ scala: ".scala",
314
+ haskell: ".hs",
315
+ lua: ".lua",
316
+ shell: ".sh",
317
+ sql: ".sql",
318
+ html: ".html",
319
+ css: ".css"
320
+ };
321
+ var generateRandomString = (length, lowercase = false) => {
322
+ const chars = "ABCDEFGHJKLMNPQRSTUVWXY3456789";
323
+ let result = "";
324
+ for (let i = 0; i < length; i++) {
325
+ result += chars.charAt(Math.floor(Math.random() * chars.length));
326
+ }
327
+ return lowercase ? result.toLowerCase() : result;
328
+ };
329
+ var CodeBlock = React6.memo(({ language, value }) => {
330
+ const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2e3 });
331
+ const downloadAsFile = () => {
332
+ if (typeof window === "undefined") {
333
+ return;
334
+ }
335
+ const fileExtension = programmingLanguages[language] || ".file";
336
+ const suggestedFileName = `file-${generateRandomString(
337
+ 3,
338
+ true
339
+ )}${fileExtension}`;
340
+ const fileName = window.prompt("Enter file name", suggestedFileName);
341
+ if (!fileName) {
342
+ return;
343
+ }
344
+ const blob = new Blob([value], { type: "text/plain" });
345
+ const url = URL.createObjectURL(blob);
346
+ const link = document.createElement("a");
347
+ link.download = fileName;
348
+ link.href = url;
349
+ link.style.display = "none";
350
+ document.body.appendChild(link);
351
+ link.click();
352
+ document.body.removeChild(link);
353
+ URL.revokeObjectURL(url);
354
+ };
355
+ const onCopy = () => {
356
+ if (isCopied)
357
+ return;
358
+ copyToClipboard(value);
359
+ };
360
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", {
361
+ className: "codeblock relative w-full bg-zinc-950 font-sans",
362
+ children: [
363
+ /* @__PURE__ */ jsxRuntime.jsxs("div", {
364
+ className: "flex w-full items-center justify-between bg-zinc-800 px-6 py-2 pr-4 text-zinc-100",
365
+ children: [
366
+ /* @__PURE__ */ jsxRuntime.jsx("span", {
367
+ className: "text-xs lowercase",
368
+ children: language
369
+ }),
370
+ /* @__PURE__ */ jsxRuntime.jsxs("div", {
371
+ className: "flex items-center space-x-1",
372
+ children: [
373
+ /* @__PURE__ */ jsxRuntime.jsxs(Button, {
374
+ variant: "ghost",
375
+ className: "hover:bg-zinc-800 focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0",
376
+ onClick: downloadAsFile,
377
+ size: "icon",
378
+ children: [
379
+ /* @__PURE__ */ jsxRuntime.jsx(IconDownload, {}),
380
+ /* @__PURE__ */ jsxRuntime.jsx("span", {
381
+ className: "sr-only",
382
+ children: "Download"
383
+ })
384
+ ]
385
+ }),
386
+ /* @__PURE__ */ jsxRuntime.jsxs(Button, {
387
+ variant: "ghost",
388
+ size: "icon",
389
+ className: "text-xs hover:bg-zinc-800 focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0",
390
+ onClick: onCopy,
391
+ children: [
392
+ isCopied ? /* @__PURE__ */ jsxRuntime.jsx(IconCheck, {}) : /* @__PURE__ */ jsxRuntime.jsx(IconCopy, {}),
393
+ /* @__PURE__ */ jsxRuntime.jsx("span", {
394
+ className: "sr-only",
395
+ children: "Copy code"
396
+ })
397
+ ]
398
+ })
399
+ ]
400
+ })
401
+ ]
402
+ }),
403
+ /* @__PURE__ */ jsxRuntime.jsx(reactSyntaxHighlighter.Prism, {
404
+ language,
405
+ PreTag: "div",
406
+ showLineNumbers: true,
407
+ customStyle: {
408
+ margin: 0,
409
+ width: "100%",
410
+ background: "transparent",
411
+ padding: "1.5rem 1rem"
412
+ },
413
+ codeTagProps: {
414
+ style: {
415
+ fontSize: "0.9rem",
416
+ fontFamily: "var(--font-mono)"
417
+ }
418
+ },
419
+ children: value
420
+ })
421
+ ]
422
+ });
423
+ });
424
+ CodeBlock.displayName = "CodeBlock";
425
+ var MemoizedReactMarkdown = React6.memo(
426
+ ReactMarkdown,
427
+ (prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.className === nextProps.className
428
+ );
429
+ function ChatMessageActions(_a) {
430
+ var _b = _a, {
431
+ message,
432
+ className
433
+ } = _b, props = __objRest(_b, [
434
+ "message",
435
+ "className"
436
+ ]);
437
+ const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2e3 });
438
+ const onCopy = () => {
439
+ if (isCopied)
440
+ return;
441
+ copyToClipboard(message.content);
442
+ };
443
+ return /* @__PURE__ */ jsxRuntime.jsx("div", __spreadProps(__spreadValues({
444
+ className: cn(
445
+ "flex items-center justify-end transition-opacity group-hover:opacity-100 md:absolute md:-right-10 md:-top-2 md:opacity-0",
446
+ className
447
+ )
448
+ }, props), {
449
+ children: /* @__PURE__ */ jsxRuntime.jsxs(Button, {
450
+ variant: "ghost",
451
+ size: "icon",
452
+ onClick: onCopy,
453
+ children: [
454
+ isCopied ? /* @__PURE__ */ jsxRuntime.jsx(IconCheck, {}) : /* @__PURE__ */ jsxRuntime.jsx(IconCopy, {}),
455
+ /* @__PURE__ */ jsxRuntime.jsx("span", {
456
+ className: "sr-only",
457
+ children: "Copy message"
458
+ })
459
+ ]
460
+ })
461
+ }));
462
+ }
463
+ function ChatMessage(_a) {
464
+ var _b = _a, { message } = _b, props = __objRest(_b, ["message"]);
465
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", __spreadProps(__spreadValues({
466
+ className: cn("group relative mb-4 flex items-start")
467
+ }, props), {
468
+ children: [
469
+ /* @__PURE__ */ jsxRuntime.jsx("div", {
470
+ className: cn(
471
+ "flex h-8 w-8 shrink-0 select-none items-center justify-center rounded-md border shadow",
472
+ message.role === "user" ? "bg-background" : "bg-primary text-primary-foreground"
473
+ ),
474
+ children: message.role === "user" ? /* @__PURE__ */ jsxRuntime.jsx(IconUser, {}) : /* @__PURE__ */ jsxRuntime.jsx(IconOpenAI, {})
475
+ }),
476
+ /* @__PURE__ */ jsxRuntime.jsxs("div", {
477
+ className: "ml-4 flex-1 space-y-2 overflow-hidden px-1",
478
+ children: [
479
+ /* @__PURE__ */ jsxRuntime.jsx(MemoizedReactMarkdown, {
480
+ className: "prose break-words dark:prose-invert prose-p:leading-relaxed prose-pre:p-0 text-sm",
481
+ remarkPlugins: [remarkGfm, remarkMath],
482
+ components: {
483
+ p({ children }) {
484
+ return /* @__PURE__ */ jsxRuntime.jsx("p", {
485
+ className: "mb-2 last:mb-0",
486
+ children
487
+ });
488
+ },
489
+ code(_a2) {
490
+ var _b2 = _a2, { children, className, inline } = _b2, props2 = __objRest(_b2, ["children", "className", "inline"]);
491
+ if (children.length) {
492
+ if (children[0] == "\u258D") {
493
+ return /* @__PURE__ */ jsxRuntime.jsx("span", {
494
+ className: "mt-1 animate-pulse cursor-default",
495
+ children: "\u258D"
496
+ });
497
+ }
498
+ children[0] = children[0].replace("`\u258D`", "\u258D");
499
+ }
500
+ const match = /language-(\w+)/.exec(className || "");
501
+ if (inline) {
502
+ return /* @__PURE__ */ jsxRuntime.jsx("code", __spreadProps(__spreadValues({
503
+ className
504
+ }, props2), {
505
+ children
506
+ }));
507
+ }
508
+ return /* @__PURE__ */ jsxRuntime.jsx(CodeBlock, __spreadValues({
509
+ language: match && match[1] || "",
510
+ value: String(children).replace(/\n$/, "")
511
+ }, props2), Math.random());
512
+ }
513
+ },
514
+ children: message.content
515
+ }),
516
+ /* @__PURE__ */ jsxRuntime.jsx(ChatMessageActions, {
517
+ message
518
+ })
519
+ ]
520
+ })
521
+ ]
522
+ }));
523
+ }
524
+ function ChatList({ messages }) {
525
+ const displayedMessages = messages.filter(
526
+ (message) => message.role !== "system"
527
+ );
528
+ if (!displayedMessages.length) {
529
+ return null;
530
+ }
531
+ return /* @__PURE__ */ jsxRuntime.jsx("div", {
532
+ className: "relative mx-auto max-w-2xl px-0",
533
+ children: displayedMessages.map((message, index) => /* @__PURE__ */ jsxRuntime.jsxs("div", {
534
+ children: [
535
+ /* @__PURE__ */ jsxRuntime.jsx(ChatMessage, {
536
+ message
537
+ }),
538
+ index < displayedMessages.length - 1 && /* @__PURE__ */ jsxRuntime.jsx(Separator, {
539
+ className: "my-4 md:my-4"
540
+ })
541
+ ]
542
+ }, index))
543
+ });
544
+ }
545
+ function useEnterSubmit() {
546
+ const formRef = React6.useRef(null);
547
+ const handleKeyDown = (event) => {
548
+ var _a;
549
+ if (event.key === "Enter" && !event.shiftKey && !event.nativeEvent.isComposing) {
550
+ (_a = formRef.current) == null ? void 0 : _a.requestSubmit();
551
+ event.preventDefault();
552
+ }
553
+ };
554
+ return { formRef, onKeyDown: handleKeyDown };
555
+ }
556
+ var TooltipProvider = TooltipPrimitive__namespace.Provider;
557
+ var Tooltip = TooltipPrimitive__namespace.Root;
558
+ var TooltipTrigger = TooltipPrimitive__namespace.Trigger;
559
+ var TooltipContent = React6__namespace.forwardRef((_a, ref) => {
560
+ var _b = _a, { className, sideOffset = 4 } = _b, props = __objRest(_b, ["className", "sideOffset"]);
561
+ return /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Content, __spreadValues({
562
+ ref,
563
+ sideOffset,
564
+ className: cn(
565
+ "z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-xs font-medium text-popover-foreground shadow-md animate-in fade-in-50 data-[side=bottom]:slide-in-from-top-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1",
566
+ className
567
+ )
568
+ }, props));
569
+ });
570
+ TooltipContent.displayName = TooltipPrimitive__namespace.Content.displayName;
571
+ function PromptForm({
572
+ onSubmit,
573
+ input,
574
+ setInput,
575
+ isLoading
576
+ }) {
577
+ const { formRef, onKeyDown } = useEnterSubmit();
578
+ const inputRef = React6__namespace.useRef(null);
579
+ React6__namespace.useEffect(() => {
580
+ if (inputRef.current) {
581
+ inputRef.current.focus();
582
+ }
583
+ }, []);
584
+ return /* @__PURE__ */ jsxRuntime.jsx("form", {
585
+ onSubmit: (e) => __async(this, null, function* () {
586
+ e.preventDefault();
587
+ if (!(input == null ? void 0 : input.trim())) {
588
+ return;
589
+ }
590
+ setInput("");
591
+ yield onSubmit(input);
592
+ }),
593
+ ref: formRef,
594
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", {
595
+ className: "relative flex max-h-60 w-full grow flex-col overflow-hidden bg-background px-8 sm:rounded-md border sm:px-12",
596
+ children: [
597
+ /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, {
598
+ children: [
599
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, {
600
+ asChild: true
601
+ }),
602
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, {
603
+ children: "New Chat"
604
+ })
605
+ ]
606
+ }),
607
+ /* @__PURE__ */ jsxRuntime.jsx(TextareaAutosize, {
608
+ ref: inputRef,
609
+ tabIndex: 0,
610
+ onKeyDown,
611
+ rows: 1,
612
+ value: input,
613
+ onChange: (e) => setInput(e.target.value),
614
+ placeholder: "Send a message.",
615
+ spellCheck: false,
616
+ className: "min-h-[60px] w-full resize-none bg-transparent px-4 py-[1.3rem] focus-within:outline-none sm:text-sm"
617
+ }),
618
+ /* @__PURE__ */ jsxRuntime.jsx("div", {
619
+ className: "absolute right-0 top-4 sm:right-4",
620
+ children: /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, {
621
+ children: [
622
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, {
623
+ asChild: true,
624
+ children: /* @__PURE__ */ jsxRuntime.jsxs(Button, {
625
+ type: "submit",
626
+ size: "icon",
627
+ disabled: isLoading || input === "",
628
+ className: " bg-slate-300",
629
+ children: [
630
+ /* @__PURE__ */ jsxRuntime.jsx(IconArrowElbow, {}),
631
+ /* @__PURE__ */ jsxRuntime.jsx("span", {
632
+ className: "sr-only",
633
+ children: "Send message"
634
+ })
635
+ ]
636
+ })
637
+ }),
638
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, {
639
+ children: "Send message"
640
+ })
641
+ ]
642
+ })
643
+ })
644
+ ]
645
+ })
646
+ });
647
+ }
648
+ function ChatPanel({
649
+ id,
650
+ isLoading,
651
+ stop,
652
+ append,
653
+ reload,
654
+ input,
655
+ setInput,
656
+ messages
657
+ }) {
658
+ return /* @__PURE__ */ jsxRuntime.jsx("div", {
659
+ className: "inset-x-0 bottom-0 bg-gradient-to-b from-muted/10 from-10% to-muted/30 to-50% mt-4 mb-8",
660
+ style: { width: "100%", overflow: "hidden", boxSizing: "border-box" },
661
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", {
662
+ className: "mx-auto sm:max-w-2xl sm:px-4",
663
+ children: [
664
+ /* @__PURE__ */ jsxRuntime.jsx("div", {
665
+ className: "flex h-10 items-center justify-center mb-4",
666
+ children: isLoading ? /* @__PURE__ */ jsxRuntime.jsxs(Button, {
667
+ variant: "outline",
668
+ onClick: () => stop(),
669
+ className: "bg-background",
670
+ children: [
671
+ /* @__PURE__ */ jsxRuntime.jsx(IconStop, {
672
+ className: "mr-2"
673
+ }),
674
+ "Stop generating"
675
+ ]
676
+ }) : (messages == null ? void 0 : messages.length) > 0 && /* @__PURE__ */ jsxRuntime.jsxs(Button, {
677
+ variant: "outline",
678
+ onClick: () => reload(),
679
+ className: "bg-background",
680
+ children: [
681
+ /* @__PURE__ */ jsxRuntime.jsx(IconRefresh, {
682
+ className: "mr-2"
683
+ }),
684
+ "Regenerate response"
685
+ ]
686
+ })
687
+ }),
688
+ /* @__PURE__ */ jsxRuntime.jsx("div", {
689
+ className: "space-y-4 border-2 bg-background px-4 py-2 shadow-lg sm:rounded-xl md:py-4",
690
+ children: /* @__PURE__ */ jsxRuntime.jsx(PromptForm, {
691
+ onSubmit: (value) => __async(this, null, function* () {
692
+ yield append({
693
+ id,
694
+ content: value,
695
+ role: "user"
696
+ });
697
+ }),
698
+ input,
699
+ setInput,
700
+ isLoading
701
+ })
702
+ })
703
+ ]
704
+ })
705
+ });
706
+ }
707
+ function ExternalLink({
708
+ href,
709
+ children
710
+ }) {
711
+ return /* @__PURE__ */ jsxRuntime.jsxs("a", {
712
+ href,
713
+ target: "_blank",
714
+ className: "inline-flex flex-1 justify-center gap-1 leading-4 hover:underline",
715
+ children: [
716
+ /* @__PURE__ */ jsxRuntime.jsx("span", {
717
+ children
718
+ }),
719
+ /* @__PURE__ */ jsxRuntime.jsx("svg", {
720
+ "aria-hidden": "true",
721
+ height: "7",
722
+ viewBox: "0 0 6 6",
723
+ width: "7",
724
+ className: "opacity-70",
725
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", {
726
+ d: "M1.25215 5.54731L0.622742 4.9179L3.78169 1.75597H1.3834L1.38936 0.890915H5.27615V4.78069H4.40513L4.41109 2.38538L1.25215 5.54731Z",
727
+ fill: "currentColor"
728
+ })
729
+ })
730
+ ]
731
+ });
732
+ }
733
+ var exampleMessages = [
734
+ {
735
+ heading: "Explain technical concepts",
736
+ message: `What is a "serverless function"?`
737
+ },
738
+ {
739
+ heading: "Summarize an article",
740
+ message: "Summarize the following article for a 2nd grader: \n"
741
+ },
742
+ {
743
+ heading: "Draft an email",
744
+ message: `Draft an email to my boss about the following:
745
+ `
746
+ }
747
+ ];
748
+ var DefaultEmptyScreen = (props) => {
749
+ return /* @__PURE__ */ jsxRuntime.jsx("div", {
750
+ className: "mx-auto max-w-2xl px-4",
751
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", {
752
+ className: "rounded-lg border bg-background p-8",
753
+ children: [
754
+ /* @__PURE__ */ jsxRuntime.jsx("h1", {
755
+ className: "mb-2 text-lg font-semibold",
756
+ children: "Welcome to CopilotKit! \u{1F44B}"
757
+ }),
758
+ /* @__PURE__ */ jsxRuntime.jsxs("p", {
759
+ className: "mb-2 leading-normal text-muted-foreground",
760
+ children: [
761
+ "This is a Copilot built with",
762
+ " ",
763
+ /* @__PURE__ */ jsxRuntime.jsx(ExternalLink, {
764
+ href: "https://recursively.ai",
765
+ children: "recursively.ai's"
766
+ }),
767
+ " ",
768
+ /* @__PURE__ */ jsxRuntime.jsx(ExternalLink, {
769
+ href: "https://github.com/RecursivelyAI/CopilotKit",
770
+ children: "CopilotKit"
771
+ }),
772
+ " ",
773
+ "."
774
+ ]
775
+ }),
776
+ /* @__PURE__ */ jsxRuntime.jsx("p", {
777
+ className: "leading-normal text-muted-foreground",
778
+ children: "You can start a conversation here or try the following examples:"
779
+ }),
780
+ /* @__PURE__ */ jsxRuntime.jsx("div", {
781
+ className: "mt-4 flex flex-col items-start space-y-2",
782
+ children: exampleMessages.map((message, index) => /* @__PURE__ */ jsxRuntime.jsxs(Button, {
783
+ variant: "link",
784
+ className: "h-auto p-0 text-base",
785
+ onClick: () => props.setInput(message.message),
786
+ children: [
787
+ /* @__PURE__ */ jsxRuntime.jsx(IconArrowRight, {
788
+ className: "mr-2 text-muted-foreground"
789
+ }),
790
+ message.heading
791
+ ]
792
+ }, index))
793
+ })
794
+ ]
795
+ })
796
+ });
797
+ };
798
+ function useAtBottom(offset = 0) {
799
+ const [isAtBottom, setIsAtBottom] = React6__namespace.useState(false);
800
+ React6__namespace.useEffect(() => {
801
+ const handleScroll = () => {
802
+ setIsAtBottom(
803
+ window.innerHeight + window.scrollY >= document.body.offsetHeight - offset
804
+ );
805
+ };
806
+ window.addEventListener("scroll", handleScroll, { passive: true });
807
+ handleScroll();
808
+ return () => {
809
+ window.removeEventListener("scroll", handleScroll);
810
+ };
811
+ }, [offset]);
812
+ return isAtBottom;
813
+ }
814
+ function ChatScrollAnchor({ trackVisibility }) {
815
+ const isAtBottom = useAtBottom();
816
+ const { ref, entry, inView } = reactIntersectionObserver.useInView({
817
+ trackVisibility,
818
+ delay: 100,
819
+ rootMargin: "0px 0px -150px 0px"
820
+ });
821
+ React6__namespace.useEffect(() => {
822
+ if (isAtBottom && trackVisibility && !inView) {
823
+ entry == null ? void 0 : entry.target.scrollIntoView({
824
+ block: "start"
825
+ });
826
+ }
827
+ }, [inView, entry, isAtBottom, trackVisibility]);
828
+ return /* @__PURE__ */ jsxRuntime.jsx("div", {
829
+ ref,
830
+ className: "h-px w-full"
831
+ });
832
+ }
833
+ function CopilotChat({
834
+ id,
835
+ initialMessages,
836
+ makeSystemMessage,
837
+ EmptyScreen = DefaultEmptyScreen
838
+ }) {
839
+ const { visibleMessages, append, reload, stop, isLoading, input, setInput } = reactCore.useCopilotChat({ id, initialMessages, makeSystemMessage });
840
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", {
841
+ className: "w-full h-full flex flex-col overflow-hidden box-border items-start",
842
+ children: [
843
+ /* @__PURE__ */ jsxRuntime.jsx("div", {
844
+ className: "pt-5 px-5 overflow-y-auto overflow-x-hidden w-full flex-grow",
845
+ children: visibleMessages.length ? /* @__PURE__ */ jsxRuntime.jsxs("div", {
846
+ className: "pl-0 pr-6",
847
+ children: [
848
+ /* @__PURE__ */ jsxRuntime.jsx(ChatList, {
849
+ messages: visibleMessages
850
+ }),
851
+ /* @__PURE__ */ jsxRuntime.jsx(ChatScrollAnchor, {
852
+ trackVisibility: isLoading
853
+ })
854
+ ]
855
+ }) : /* @__PURE__ */ jsxRuntime.jsx(EmptyScreen, {
856
+ setInput
857
+ })
858
+ }),
859
+ /* @__PURE__ */ jsxRuntime.jsx("div", {
860
+ className: "flex-shrink-0 w-full",
861
+ children: /* @__PURE__ */ jsxRuntime.jsx(ChatPanel, {
862
+ id,
863
+ isLoading,
864
+ stop,
865
+ append,
866
+ reload,
867
+ messages: visibleMessages,
868
+ input,
869
+ setInput
870
+ })
871
+ })
872
+ ]
873
+ });
874
+ }
875
+ function CopilotSidebar(props) {
876
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", {
877
+ className: "shadow-lg bg-gray-50 flex flex-col border-l-2",
878
+ style: { width: "100%", height: "100%" },
879
+ children: [
880
+ /* @__PURE__ */ jsxRuntime.jsx(TopBar, __spreadValues({}, props)),
881
+ /* @__PURE__ */ jsxRuntime.jsx(CopilotChat, {})
882
+ ]
883
+ });
884
+ }
885
+ function TopBar(props) {
886
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", {
887
+ className: "py-6 flex bg-gray-50 items-center justify-between px-4",
888
+ children: [
889
+ /* @__PURE__ */ jsxRuntime.jsx("h1", {
890
+ className: "text-base font-semibold leading-6 text-gray-900",
891
+ children: "Copilot Chat"
892
+ }),
893
+ /* @__PURE__ */ jsxRuntime.jsx("div", {
894
+ className: "ml-3 flex h-7 items-center",
895
+ children: /* @__PURE__ */ jsxRuntime.jsxs("button", {
896
+ type: "button",
897
+ className: "rounded-md bg-white text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2",
898
+ onClick: () => props.setSidebarOpen(false),
899
+ children: [
900
+ /* @__PURE__ */ jsxRuntime.jsx("span", {
901
+ className: "sr-only",
902
+ children: "Close panel"
903
+ }),
904
+ /* @__PURE__ */ jsxRuntime.jsx(outline.XMarkIcon, {
905
+ className: "h-6 w-6",
906
+ "aria-hidden": "true"
907
+ })
908
+ ]
909
+ })
910
+ })
911
+ ]
912
+ });
913
+ }
914
+ var CopilotSidebarContext = React6.createContext({
915
+ isSidebarOpen: false,
916
+ toggleSidebar: () => {
917
+ }
918
+ });
919
+ function CopilotSidebarUIProvider({
920
+ children
921
+ }) {
922
+ const [sidebarOpen, setSidebarOpen] = React6.useState(true);
923
+ const toggleSidebar = React6.useCallback(() => {
924
+ setSidebarOpen((prev) => !prev);
925
+ }, []);
926
+ return /* @__PURE__ */ jsxRuntime.jsx(CopilotSidebarContext.Provider, {
927
+ value: { isSidebarOpen: sidebarOpen, toggleSidebar },
928
+ children: /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {
929
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", {
930
+ style: {
931
+ height: "100vh",
932
+ width: "100vw",
933
+ position: "relative"
934
+ },
935
+ children: [
936
+ /* @__PURE__ */ jsxRuntime.jsx("div", {
937
+ style: {
938
+ overflowY: "auto",
939
+ overflowX: "hidden",
940
+ height: "100%",
941
+ width: sidebarOpen ? "calc(100% - 450px)" : "100%",
942
+ position: "absolute",
943
+ transition: "width 0.5s ease-in-out"
944
+ },
945
+ children: /* @__PURE__ */ jsxRuntime.jsx("main", {
946
+ children
947
+ })
948
+ }),
949
+ /* @__PURE__ */ jsxRuntime.jsx("div", {
950
+ style: {
951
+ overflowY: "auto",
952
+ height: "100%",
953
+ width: "450px",
954
+ position: "absolute",
955
+ right: sidebarOpen ? "0" : "-450px",
956
+ transition: "right 0.5s ease-in-out"
957
+ },
958
+ children: /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, {
959
+ children: /* @__PURE__ */ jsxRuntime.jsx(CopilotSidebar, {
960
+ setSidebarOpen
961
+ })
962
+ })
963
+ }),
964
+ !sidebarOpen && /* @__PURE__ */ jsxRuntime.jsx("button", {
965
+ onClick: toggleSidebar,
966
+ style: {
967
+ position: "absolute",
968
+ top: "5%",
969
+ right: "20px",
970
+ transform: "translateY(-50%)",
971
+ transition: "opacity 0.5s ease-in-out"
972
+ },
973
+ className: "bg-slate-100 ring-2 ring-slate-600 font-semibold text-black p-2 rounded-lg shadow-lg",
974
+ children: "Open Copilot"
975
+ })
976
+ ]
977
+ })
978
+ })
979
+ });
980
+ }
981
+
982
+ exports.CopilotSidebarUIProvider = CopilotSidebarUIProvider;
983
+ //# sourceMappingURL=out.js.map
984
+ //# sourceMappingURL=copilot-sidebar-ui-provider.js.map