@copilotkit/react-ui 1.3.2 → 1.3.3

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 (84) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/{chunk-PGJGIYRW.mjs → chunk-3YESXHJH.mjs} +3 -3
  3. package/dist/{chunk-I454U2HM.mjs → chunk-BTOVRBBW.mjs} +52 -25
  4. package/dist/chunk-BTOVRBBW.mjs.map +1 -0
  5. package/dist/chunk-GDNJRSD4.mjs +126 -0
  6. package/dist/chunk-GDNJRSD4.mjs.map +1 -0
  7. package/dist/{chunk-N6GQ4WV4.mjs → chunk-GHMYWL42.mjs} +2 -2
  8. package/dist/{chunk-N6GQ4WV4.mjs.map → chunk-GHMYWL42.mjs.map} +1 -1
  9. package/dist/chunk-GOTHQ665.mjs +19 -0
  10. package/dist/chunk-GOTHQ665.mjs.map +1 -0
  11. package/dist/chunk-MA5B5ELM.mjs +26 -0
  12. package/dist/chunk-MA5B5ELM.mjs.map +1 -0
  13. package/dist/chunk-U42OB2S3.mjs +61 -0
  14. package/dist/chunk-U42OB2S3.mjs.map +1 -0
  15. package/dist/{chunk-KJQVEUVB.mjs → chunk-UUHCZZZV.mjs} +2 -2
  16. package/dist/chunk-UUHCZZZV.mjs.map +1 -0
  17. package/dist/chunk-YH2STM73.mjs +76 -0
  18. package/dist/chunk-YH2STM73.mjs.map +1 -0
  19. package/dist/components/chat/Chat.d.ts +18 -2
  20. package/dist/components/chat/Chat.js +664 -556
  21. package/dist/components/chat/Chat.js.map +1 -1
  22. package/dist/components/chat/Chat.mjs +6 -2
  23. package/dist/components/chat/Messages.d.ts +1 -1
  24. package/dist/components/chat/Messages.js +61 -662
  25. package/dist/components/chat/Messages.js.map +1 -1
  26. package/dist/components/chat/Messages.mjs +1 -4
  27. package/dist/components/chat/Modal.js +669 -561
  28. package/dist/components/chat/Modal.js.map +1 -1
  29. package/dist/components/chat/Modal.mjs +7 -3
  30. package/dist/components/chat/Popup.js +669 -561
  31. package/dist/components/chat/Popup.js.map +1 -1
  32. package/dist/components/chat/Popup.mjs +8 -4
  33. package/dist/components/chat/Sidebar.js +669 -561
  34. package/dist/components/chat/Sidebar.js.map +1 -1
  35. package/dist/components/chat/Sidebar.mjs +8 -4
  36. package/dist/components/chat/index.d.ts +1 -1
  37. package/dist/components/chat/index.js +669 -561
  38. package/dist/components/chat/index.js.map +1 -1
  39. package/dist/components/chat/index.mjs +9 -5
  40. package/dist/components/chat/messages/RenderActionExecutionMessage.d.ts +7 -0
  41. package/dist/components/chat/messages/RenderActionExecutionMessage.js +122 -0
  42. package/dist/components/chat/messages/RenderActionExecutionMessage.js.map +1 -0
  43. package/dist/components/chat/messages/RenderActionExecutionMessage.mjs +10 -0
  44. package/dist/components/chat/messages/RenderActionExecutionMessage.mjs.map +1 -0
  45. package/dist/components/chat/messages/RenderAgentStateMessage.d.ts +7 -0
  46. package/dist/components/chat/messages/RenderAgentStateMessage.js +107 -0
  47. package/dist/components/chat/messages/RenderAgentStateMessage.js.map +1 -0
  48. package/dist/components/chat/messages/RenderAgentStateMessage.mjs +10 -0
  49. package/dist/components/chat/messages/RenderAgentStateMessage.mjs.map +1 -0
  50. package/dist/components/chat/messages/RenderResultMessage.d.ts +7 -0
  51. package/dist/components/chat/messages/RenderResultMessage.js +65 -0
  52. package/dist/components/chat/messages/RenderResultMessage.js.map +1 -0
  53. package/dist/components/chat/messages/RenderResultMessage.mjs +10 -0
  54. package/dist/components/chat/messages/RenderResultMessage.mjs.map +1 -0
  55. package/dist/components/chat/messages/RenderTextMessage.d.ts +7 -0
  56. package/dist/components/chat/messages/RenderTextMessage.js +614 -0
  57. package/dist/components/chat/messages/RenderTextMessage.js.map +1 -0
  58. package/dist/components/chat/messages/RenderTextMessage.mjs +13 -0
  59. package/dist/components/chat/messages/RenderTextMessage.mjs.map +1 -0
  60. package/dist/components/chat/props.d.ts +12 -1
  61. package/dist/components/chat/props.js.map +1 -1
  62. package/dist/components/index.d.ts +1 -1
  63. package/dist/components/index.js +669 -561
  64. package/dist/components/index.js.map +1 -1
  65. package/dist/components/index.mjs +9 -5
  66. package/dist/index.d.ts +1 -1
  67. package/dist/index.js +677 -569
  68. package/dist/index.js.map +1 -1
  69. package/dist/index.mjs +9 -5
  70. package/package.json +7 -7
  71. package/src/components/chat/Chat.tsx +39 -4
  72. package/src/components/chat/Messages.tsx +45 -175
  73. package/src/components/chat/Popup.tsx +2 -2
  74. package/src/components/chat/Sidebar.tsx +2 -2
  75. package/src/components/chat/messages/RenderActionExecutionMessage.tsx +90 -0
  76. package/src/components/chat/messages/RenderAgentStateMessage.tsx +81 -0
  77. package/src/components/chat/messages/RenderResultMessage.tsx +15 -0
  78. package/src/components/chat/messages/RenderTextMessage.tsx +28 -0
  79. package/src/components/chat/props.ts +12 -0
  80. package/dist/chunk-4K36ATCD.mjs +0 -184
  81. package/dist/chunk-4K36ATCD.mjs.map +0 -1
  82. package/dist/chunk-I454U2HM.mjs.map +0 -1
  83. package/dist/chunk-KJQVEUVB.mjs.map +0 -1
  84. /package/dist/{chunk-PGJGIYRW.mjs.map → chunk-3YESXHJH.mjs.map} +0 -0
@@ -0,0 +1,614 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __objRest = (source, exclude) => {
26
+ var target = {};
27
+ for (var prop in source)
28
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
+ target[prop] = source[prop];
30
+ if (source != null && __getOwnPropSymbols)
31
+ for (var prop of __getOwnPropSymbols(source)) {
32
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
+ target[prop] = source[prop];
34
+ }
35
+ return target;
36
+ };
37
+ var __export = (target, all) => {
38
+ for (var name in all)
39
+ __defProp(target, name, { get: all[name], enumerable: true });
40
+ };
41
+ var __copyProps = (to, from, except, desc) => {
42
+ if (from && typeof from === "object" || typeof from === "function") {
43
+ for (let key of __getOwnPropNames(from))
44
+ if (!__hasOwnProp.call(to, key) && key !== except)
45
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
46
+ }
47
+ return to;
48
+ };
49
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
50
+ // If the importer is in node compatibility mode or this is not an ESM
51
+ // file that has been converted to a CommonJS file using a Babel-
52
+ // compatible transform (i.e. "__esModule" has not been set), then set
53
+ // "default" to the CommonJS "module.exports" for node compatibility.
54
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
55
+ mod
56
+ ));
57
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
58
+
59
+ // src/components/chat/messages/RenderTextMessage.tsx
60
+ var RenderTextMessage_exports = {};
61
+ __export(RenderTextMessage_exports, {
62
+ RenderTextMessage: () => RenderTextMessage
63
+ });
64
+ module.exports = __toCommonJS(RenderTextMessage_exports);
65
+ var import_runtime_client_gql = require("@copilotkit/runtime-client-gql");
66
+
67
+ // src/components/chat/Markdown.tsx
68
+ var import_react2 = require("react");
69
+ var import_react_markdown = __toESM(require("react-markdown"));
70
+
71
+ // src/components/chat/CodeBlock.tsx
72
+ var import_react = require("react");
73
+ var import_react_syntax_highlighter = require("react-syntax-highlighter");
74
+
75
+ // src/hooks/use-copy-to-clipboard.tsx
76
+ var React = __toESM(require("react"));
77
+ function useCopyToClipboard({ timeout = 2e3 }) {
78
+ const [isCopied, setIsCopied] = React.useState(false);
79
+ const copyToClipboard = (value) => {
80
+ var _a;
81
+ if (typeof window === "undefined" || !((_a = navigator.clipboard) == null ? void 0 : _a.writeText)) {
82
+ return;
83
+ }
84
+ if (!value) {
85
+ return;
86
+ }
87
+ navigator.clipboard.writeText(value).then(() => {
88
+ setIsCopied(true);
89
+ setTimeout(() => {
90
+ setIsCopied(false);
91
+ }, timeout);
92
+ });
93
+ };
94
+ return { isCopied, copyToClipboard };
95
+ }
96
+
97
+ // src/components/chat/Icons.tsx
98
+ var import_jsx_runtime = require("react/jsx-runtime");
99
+ function CheckIcon(_a) {
100
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
101
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
102
+ "svg",
103
+ __spreadProps(__spreadValues({
104
+ xmlns: "http://www.w3.org/2000/svg",
105
+ viewBox: "0 0 256 256",
106
+ fill: "currentColor",
107
+ style: { height: "1rem", width: "1rem" },
108
+ className
109
+ }, props), {
110
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m229.66 77.66-128 128a8 8 0 0 1-11.32 0l-56-56a8 8 0 0 1 11.32-11.32L96 188.69 218.34 66.34a8 8 0 0 1 11.32 11.32Z" })
111
+ })
112
+ );
113
+ }
114
+ function DownloadIcon(_a) {
115
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
116
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
117
+ "svg",
118
+ __spreadProps(__spreadValues({
119
+ xmlns: "http://www.w3.org/2000/svg",
120
+ viewBox: "0 0 256 256",
121
+ fill: "currentColor",
122
+ style: { height: "1rem", width: "1rem" },
123
+ className
124
+ }, props), {
125
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M224 152v56a16 16 0 0 1-16 16H48a16 16 0 0 1-16-16v-56a8 8 0 0 1 16 0v56h160v-56a8 8 0 0 1 16 0Zm-101.66 5.66a8 8 0 0 0 11.32 0l40-40a8 8 0 0 0-11.32-11.32L136 132.69V40a8 8 0 0 0-16 0v92.69l-26.34-26.35a8 8 0 0 0-11.32 11.32Z" })
126
+ })
127
+ );
128
+ }
129
+ function CopyIcon(_a) {
130
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
131
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
132
+ "svg",
133
+ __spreadProps(__spreadValues({
134
+ xmlns: "http://www.w3.org/2000/svg",
135
+ viewBox: "0 0 256 256",
136
+ fill: "currentColor",
137
+ style: { height: "1rem", width: "1rem" },
138
+ className
139
+ }, props), {
140
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M216 32H88a8 8 0 0 0-8 8v40H40a8 8 0 0 0-8 8v128a8 8 0 0 0 8 8h128a8 8 0 0 0 8-8v-40h40a8 8 0 0 0 8-8V40a8 8 0 0 0-8-8Zm-56 176H48V96h112Zm48-48h-32V88a8 8 0 0 0-8-8H96V48h112Z" })
141
+ })
142
+ );
143
+ }
144
+
145
+ // src/components/chat/CodeBlock.tsx
146
+ var import_jsx_runtime2 = require("react/jsx-runtime");
147
+ var programmingLanguages = {
148
+ javascript: ".js",
149
+ python: ".py",
150
+ java: ".java",
151
+ c: ".c",
152
+ cpp: ".cpp",
153
+ "c++": ".cpp",
154
+ "c#": ".cs",
155
+ ruby: ".rb",
156
+ php: ".php",
157
+ swift: ".swift",
158
+ "objective-c": ".m",
159
+ kotlin: ".kt",
160
+ typescript: ".ts",
161
+ go: ".go",
162
+ perl: ".pl",
163
+ rust: ".rs",
164
+ scala: ".scala",
165
+ haskell: ".hs",
166
+ lua: ".lua",
167
+ shell: ".sh",
168
+ sql: ".sql",
169
+ html: ".html",
170
+ css: ".css"
171
+ // add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component
172
+ };
173
+ var generateRandomString = (length, lowercase = false) => {
174
+ const chars = "ABCDEFGHJKLMNPQRSTUVWXY3456789";
175
+ let result = "";
176
+ for (let i = 0; i < length; i++) {
177
+ result += chars.charAt(Math.floor(Math.random() * chars.length));
178
+ }
179
+ return lowercase ? result.toLowerCase() : result;
180
+ };
181
+ var CodeBlock = (0, import_react.memo)(({ language, value }) => {
182
+ const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2e3 });
183
+ const downloadAsFile = () => {
184
+ if (typeof window === "undefined") {
185
+ return;
186
+ }
187
+ const fileExtension = programmingLanguages[language] || ".file";
188
+ const suggestedFileName = `file-${generateRandomString(3, true)}${fileExtension}`;
189
+ const fileName = window.prompt("Enter file name", suggestedFileName);
190
+ if (!fileName) {
191
+ return;
192
+ }
193
+ const blob = new Blob([value], { type: "text/plain" });
194
+ const url = URL.createObjectURL(blob);
195
+ const link = document.createElement("a");
196
+ link.download = fileName;
197
+ link.href = url;
198
+ link.style.display = "none";
199
+ document.body.appendChild(link);
200
+ link.click();
201
+ document.body.removeChild(link);
202
+ URL.revokeObjectURL(url);
203
+ };
204
+ const onCopy = () => {
205
+ if (isCopied)
206
+ return;
207
+ copyToClipboard(value);
208
+ };
209
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "copilotKitCodeBlock", children: [
210
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "copilotKitCodeBlockToolbar", children: [
211
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "copilotKitCodeBlockToolbarLanguage", children: language }),
212
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "copilotKitCodeBlockToolbarButtons", children: [
213
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: "copilotKitCodeBlockToolbarButton", onClick: downloadAsFile, children: [
214
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DownloadIcon, {}),
215
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "sr-only", children: "Download" })
216
+ ] }),
217
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: "copilotKitCodeBlockToolbarButton", onClick: onCopy, children: [
218
+ isCopied ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CheckIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CopyIcon, {}),
219
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "sr-only", children: "Copy code" })
220
+ ] })
221
+ ] })
222
+ ] }),
223
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
224
+ import_react_syntax_highlighter.Prism,
225
+ {
226
+ language,
227
+ style: highlightStyle,
228
+ PreTag: "div",
229
+ customStyle: {
230
+ margin: 0,
231
+ borderBottomLeftRadius: "0.375rem",
232
+ borderBottomRightRadius: "0.375rem"
233
+ },
234
+ children: value
235
+ }
236
+ )
237
+ ] });
238
+ });
239
+ CodeBlock.displayName = "CodeBlock";
240
+ var highlightStyle = {
241
+ 'pre[class*="language-"]': {
242
+ color: "#d4d4d4",
243
+ fontSize: "13px",
244
+ textShadow: "none",
245
+ fontFamily: 'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',
246
+ direction: "ltr",
247
+ textAlign: "left",
248
+ whiteSpace: "pre",
249
+ wordSpacing: "normal",
250
+ wordBreak: "normal",
251
+ lineHeight: "1.5",
252
+ MozTabSize: "4",
253
+ OTabSize: "4",
254
+ tabSize: "4",
255
+ WebkitHyphens: "none",
256
+ MozHyphens: "none",
257
+ msHyphens: "none",
258
+ hyphens: "none",
259
+ padding: "1em",
260
+ margin: ".5em 0",
261
+ overflow: "auto",
262
+ background: "#1e1e1e"
263
+ },
264
+ 'code[class*="language-"]': {
265
+ color: "#d4d4d4",
266
+ fontSize: "13px",
267
+ textShadow: "none",
268
+ fontFamily: 'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',
269
+ direction: "ltr",
270
+ textAlign: "left",
271
+ whiteSpace: "pre",
272
+ wordSpacing: "normal",
273
+ wordBreak: "normal",
274
+ lineHeight: "1.5",
275
+ MozTabSize: "4",
276
+ OTabSize: "4",
277
+ tabSize: "4",
278
+ WebkitHyphens: "none",
279
+ MozHyphens: "none",
280
+ msHyphens: "none",
281
+ hyphens: "none"
282
+ },
283
+ 'pre[class*="language-"]::selection': {
284
+ textShadow: "none",
285
+ background: "#264F78"
286
+ },
287
+ 'code[class*="language-"]::selection': {
288
+ textShadow: "none",
289
+ background: "#264F78"
290
+ },
291
+ 'pre[class*="language-"] *::selection': {
292
+ textShadow: "none",
293
+ background: "#264F78"
294
+ },
295
+ 'code[class*="language-"] *::selection': {
296
+ textShadow: "none",
297
+ background: "#264F78"
298
+ },
299
+ ':not(pre) > code[class*="language-"]': {
300
+ padding: ".1em .3em",
301
+ borderRadius: ".3em",
302
+ color: "#db4c69",
303
+ background: "#1e1e1e"
304
+ },
305
+ ".namespace": {
306
+ Opacity: ".7"
307
+ },
308
+ "doctype.doctype-tag": {
309
+ color: "#569CD6"
310
+ },
311
+ "doctype.name": {
312
+ color: "#9cdcfe"
313
+ },
314
+ comment: {
315
+ color: "#6a9955"
316
+ },
317
+ prolog: {
318
+ color: "#6a9955"
319
+ },
320
+ punctuation: {
321
+ color: "#d4d4d4"
322
+ },
323
+ ".language-html .language-css .token.punctuation": {
324
+ color: "#d4d4d4"
325
+ },
326
+ ".language-html .language-javascript .token.punctuation": {
327
+ color: "#d4d4d4"
328
+ },
329
+ property: {
330
+ color: "#9cdcfe"
331
+ },
332
+ tag: {
333
+ color: "#569cd6"
334
+ },
335
+ boolean: {
336
+ color: "#569cd6"
337
+ },
338
+ number: {
339
+ color: "#b5cea8"
340
+ },
341
+ constant: {
342
+ color: "#9cdcfe"
343
+ },
344
+ symbol: {
345
+ color: "#b5cea8"
346
+ },
347
+ inserted: {
348
+ color: "#b5cea8"
349
+ },
350
+ unit: {
351
+ color: "#b5cea8"
352
+ },
353
+ selector: {
354
+ color: "#d7ba7d"
355
+ },
356
+ "attr-name": {
357
+ color: "#9cdcfe"
358
+ },
359
+ string: {
360
+ color: "#ce9178"
361
+ },
362
+ char: {
363
+ color: "#ce9178"
364
+ },
365
+ builtin: {
366
+ color: "#ce9178"
367
+ },
368
+ deleted: {
369
+ color: "#ce9178"
370
+ },
371
+ ".language-css .token.string.url": {
372
+ textDecoration: "underline"
373
+ },
374
+ operator: {
375
+ color: "#d4d4d4"
376
+ },
377
+ entity: {
378
+ color: "#569cd6"
379
+ },
380
+ "operator.arrow": {
381
+ color: "#569CD6"
382
+ },
383
+ atrule: {
384
+ color: "#ce9178"
385
+ },
386
+ "atrule.rule": {
387
+ color: "#c586c0"
388
+ },
389
+ "atrule.url": {
390
+ color: "#9cdcfe"
391
+ },
392
+ "atrule.url.function": {
393
+ color: "#dcdcaa"
394
+ },
395
+ "atrule.url.punctuation": {
396
+ color: "#d4d4d4"
397
+ },
398
+ keyword: {
399
+ color: "#569CD6"
400
+ },
401
+ "keyword.module": {
402
+ color: "#c586c0"
403
+ },
404
+ "keyword.control-flow": {
405
+ color: "#c586c0"
406
+ },
407
+ function: {
408
+ color: "#dcdcaa"
409
+ },
410
+ "function.maybe-class-name": {
411
+ color: "#dcdcaa"
412
+ },
413
+ regex: {
414
+ color: "#d16969"
415
+ },
416
+ important: {
417
+ color: "#569cd6"
418
+ },
419
+ italic: {
420
+ fontStyle: "italic"
421
+ },
422
+ "class-name": {
423
+ color: "#4ec9b0"
424
+ },
425
+ "maybe-class-name": {
426
+ color: "#4ec9b0"
427
+ },
428
+ console: {
429
+ color: "#9cdcfe"
430
+ },
431
+ parameter: {
432
+ color: "#9cdcfe"
433
+ },
434
+ interpolation: {
435
+ color: "#9cdcfe"
436
+ },
437
+ "punctuation.interpolation-punctuation": {
438
+ color: "#569cd6"
439
+ },
440
+ variable: {
441
+ color: "#9cdcfe"
442
+ },
443
+ "imports.maybe-class-name": {
444
+ color: "#9cdcfe"
445
+ },
446
+ "exports.maybe-class-name": {
447
+ color: "#9cdcfe"
448
+ },
449
+ escape: {
450
+ color: "#d7ba7d"
451
+ },
452
+ "tag.punctuation": {
453
+ color: "#808080"
454
+ },
455
+ cdata: {
456
+ color: "#808080"
457
+ },
458
+ "attr-value": {
459
+ color: "#ce9178"
460
+ },
461
+ "attr-value.punctuation": {
462
+ color: "#ce9178"
463
+ },
464
+ "attr-value.punctuation.attr-equals": {
465
+ color: "#d4d4d4"
466
+ },
467
+ namespace: {
468
+ color: "#4ec9b0"
469
+ },
470
+ 'pre[class*="language-javascript"]': {
471
+ color: "#9cdcfe"
472
+ },
473
+ 'code[class*="language-javascript"]': {
474
+ color: "#9cdcfe"
475
+ },
476
+ 'pre[class*="language-jsx"]': {
477
+ color: "#9cdcfe"
478
+ },
479
+ 'code[class*="language-jsx"]': {
480
+ color: "#9cdcfe"
481
+ },
482
+ 'pre[class*="language-typescript"]': {
483
+ color: "#9cdcfe"
484
+ },
485
+ 'code[class*="language-typescript"]': {
486
+ color: "#9cdcfe"
487
+ },
488
+ 'pre[class*="language-tsx"]': {
489
+ color: "#9cdcfe"
490
+ },
491
+ 'code[class*="language-tsx"]': {
492
+ color: "#9cdcfe"
493
+ },
494
+ 'pre[class*="language-css"]': {
495
+ color: "#ce9178"
496
+ },
497
+ 'code[class*="language-css"]': {
498
+ color: "#ce9178"
499
+ },
500
+ 'pre[class*="language-html"]': {
501
+ color: "#d4d4d4"
502
+ },
503
+ 'code[class*="language-html"]': {
504
+ color: "#d4d4d4"
505
+ },
506
+ ".language-regex .token.anchor": {
507
+ color: "#dcdcaa"
508
+ },
509
+ ".language-html .token.punctuation": {
510
+ color: "#808080"
511
+ },
512
+ 'pre[class*="language-"] > code[class*="language-"]': {
513
+ position: "relative",
514
+ zIndex: "1"
515
+ },
516
+ ".line-highlight.line-highlight": {
517
+ background: "#f7ebc6",
518
+ boxShadow: "inset 5px 0 0 #f7d87c",
519
+ zIndex: "0"
520
+ }
521
+ };
522
+
523
+ // src/components/chat/Markdown.tsx
524
+ var import_remark_gfm = __toESM(require("remark-gfm"));
525
+ var import_remark_math = __toESM(require("remark-math"));
526
+ var import_jsx_runtime3 = require("react/jsx-runtime");
527
+ var MemoizedReactMarkdown = (0, import_react2.memo)(
528
+ import_react_markdown.default,
529
+ (prevProps, nextProps) => prevProps.children === nextProps.children && prevProps.className === nextProps.className
530
+ );
531
+ var Markdown = ({ content }) => {
532
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "copilotKitMarkdown", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(MemoizedReactMarkdown, { components, remarkPlugins: [import_remark_gfm.default, import_remark_math.default], children: content }) });
533
+ };
534
+ var components = {
535
+ p({ children }) {
536
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children });
537
+ },
538
+ a(_a) {
539
+ var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
540
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
541
+ "a",
542
+ __spreadProps(__spreadValues({
543
+ style: { color: "blue", textDecoration: "underline" }
544
+ }, props), {
545
+ target: "_blank",
546
+ rel: "noopener noreferrer",
547
+ children
548
+ })
549
+ );
550
+ },
551
+ code(_c) {
552
+ var _d = _c, { children, className, inline } = _d, props = __objRest(_d, ["children", "className", "inline"]);
553
+ if (children.length) {
554
+ if (children[0] == "\u258D") {
555
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
556
+ "span",
557
+ {
558
+ style: {
559
+ animation: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite",
560
+ marginTop: "0.25rem"
561
+ },
562
+ children: "\u258D"
563
+ }
564
+ );
565
+ }
566
+ children[0] = children[0].replace("`\u258D`", "\u258D");
567
+ }
568
+ const match = /language-(\w+)/.exec(className || "");
569
+ if (inline) {
570
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("code", __spreadProps(__spreadValues({ className }, props), { children }));
571
+ }
572
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
573
+ CodeBlock,
574
+ __spreadValues({
575
+ language: match && match[1] || "",
576
+ value: String(children).replace(/\n$/, "")
577
+ }, props),
578
+ Math.random()
579
+ );
580
+ }
581
+ };
582
+
583
+ // src/components/chat/ChatContext.tsx
584
+ var import_react3 = __toESM(require("react"));
585
+ var import_jsx_runtime4 = require("react/jsx-runtime");
586
+ var ChatContext = import_react3.default.createContext(void 0);
587
+ function useChatContext() {
588
+ const context = import_react3.default.useContext(ChatContext);
589
+ if (context === void 0) {
590
+ throw new Error(
591
+ "Context not found. Did you forget to wrap your app in a <ChatContextProvider> component?"
592
+ );
593
+ }
594
+ return context;
595
+ }
596
+
597
+ // src/components/chat/messages/RenderTextMessage.tsx
598
+ var import_jsx_runtime5 = require("react/jsx-runtime");
599
+ function RenderTextMessage(props) {
600
+ const { message, inProgress, index, isCurrentMessage } = props;
601
+ const { icons } = useChatContext();
602
+ if (message instanceof import_runtime_client_gql.TextMessage) {
603
+ if (message.role === "user") {
604
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "copilotKitMessage copilotKitUserMessage", children: message.content }, index);
605
+ } else if (message.role == "assistant") {
606
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: `copilotKitMessage copilotKitAssistantMessage`, children: isCurrentMessage && inProgress && !message.content ? icons.spinnerIcon : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Markdown, { content: message.content }) }, index);
607
+ }
608
+ }
609
+ }
610
+ // Annotate the CommonJS export names for ESM import in node:
611
+ 0 && (module.exports = {
612
+ RenderTextMessage
613
+ });
614
+ //# sourceMappingURL=RenderTextMessage.js.map