@uipath/apollo-wind 2.68.0 → 2.70.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/components/custom/chat-first-experience.cjs +3 -3
  2. package/dist/components/custom/chat-first-experience.js +3 -3
  3. package/dist/components/custom/demo-composer.cjs +80 -0
  4. package/dist/components/custom/demo-composer.d.ts +11 -0
  5. package/dist/components/custom/demo-composer.js +46 -0
  6. package/dist/components/custom/panel-flow.cjs +2 -2
  7. package/dist/components/custom/panel-flow.js +2 -2
  8. package/dist/components/ui/chat-composer.cjs +429 -0
  9. package/dist/components/ui/chat-composer.d.ts +157 -0
  10. package/dist/components/ui/chat-composer.js +359 -0
  11. package/dist/components/ui/citation.cjs +188 -0
  12. package/dist/components/ui/citation.d.ts +42 -0
  13. package/dist/components/ui/citation.js +148 -0
  14. package/dist/components/ui/code-block.cjs +375 -0
  15. package/dist/components/ui/code-block.d.ts +38 -0
  16. package/dist/components/ui/code-block.js +307 -0
  17. package/dist/components/ui/dropzone-overlay.cjs +142 -0
  18. package/dist/components/ui/dropzone-overlay.d.ts +27 -0
  19. package/dist/components/ui/dropzone-overlay.js +105 -0
  20. package/dist/components/ui/file-upload.cjs +5 -29
  21. package/dist/components/ui/file-upload.js +2 -26
  22. package/dist/components/ui/file-validation.cjs +91 -0
  23. package/dist/components/ui/file-validation.d.ts +24 -0
  24. package/dist/components/ui/file-validation.js +51 -0
  25. package/dist/components/ui/hover-card.cjs +15 -8
  26. package/dist/components/ui/hover-card.d.ts +4 -1
  27. package/dist/components/ui/hover-card.js +16 -9
  28. package/dist/components/ui/index.cjs +330 -198
  29. package/dist/components/ui/index.d.ts +12 -0
  30. package/dist/components/ui/index.js +12 -0
  31. package/dist/components/ui/input-group.cjs +1 -1
  32. package/dist/components/ui/input-group.d.ts +2 -1
  33. package/dist/components/ui/input-group.js +1 -1
  34. package/dist/components/ui/json-tree-view/JsonTree.cjs +2 -2
  35. package/dist/components/ui/json-tree-view/JsonTree.js +1 -1
  36. package/dist/components/ui/json-tree-view/index.cjs +26 -23
  37. package/dist/components/ui/json-tree-view/index.d.ts +2 -2
  38. package/dist/components/ui/json-tree-view/index.js +2 -2
  39. package/dist/components/ui/live-region.cjs +106 -0
  40. package/dist/components/ui/live-region.d.ts +31 -0
  41. package/dist/components/ui/live-region.js +72 -0
  42. package/dist/components/ui/loading-dots.cjs +95 -0
  43. package/dist/components/ui/loading-dots.d.ts +21 -0
  44. package/dist/components/ui/loading-dots.js +55 -0
  45. package/dist/components/ui/markdown.cjs +428 -0
  46. package/dist/components/ui/markdown.d.ts +55 -0
  47. package/dist/components/ui/markdown.js +378 -0
  48. package/dist/components/ui/message-actions.cjs +302 -0
  49. package/dist/components/ui/message-actions.d.ts +102 -0
  50. package/dist/components/ui/message-actions.js +241 -0
  51. package/dist/components/ui/message.cjs +1 -1
  52. package/dist/components/ui/message.d.ts +2 -0
  53. package/dist/components/ui/message.js +1 -1
  54. package/dist/components/ui/sources.cjs +175 -0
  55. package/dist/components/ui/sources.d.ts +44 -0
  56. package/dist/components/ui/sources.js +132 -0
  57. package/dist/components/ui/thinking-indicator.cjs +146 -0
  58. package/dist/components/ui/thinking-indicator.d.ts +38 -0
  59. package/dist/components/ui/thinking-indicator.js +106 -0
  60. package/dist/components/ui/tool-call.cjs +359 -0
  61. package/dist/components/ui/tool-call.d.ts +75 -0
  62. package/dist/components/ui/tool-call.js +301 -0
  63. package/dist/index.cjs +433 -253
  64. package/dist/index.d.ts +24 -0
  65. package/dist/index.js +13 -1
  66. package/dist/lib/index.cjs +8 -1
  67. package/dist/lib/index.d.ts +1 -0
  68. package/dist/lib/index.js +2 -1
  69. package/dist/lib/url.cjs +54 -0
  70. package/dist/lib/url.d.ts +8 -0
  71. package/dist/lib/url.js +17 -0
  72. package/dist/styles.css +363 -35
  73. package/dist/tailwind.utilities.css +21 -0
  74. package/package.json +7 -1
  75. package/dist/components/custom/chat-composer.cjs +0 -134
  76. package/dist/components/custom/chat-composer.d.ts +0 -14
  77. package/dist/components/custom/chat-composer.js +0 -100
  78. /package/dist/{components/ui/json-tree-view → lib}/clipboard.cjs +0 -0
  79. /package/dist/{components/ui/json-tree-view → lib}/clipboard.d.ts +0 -0
  80. /package/dist/{components/ui/json-tree-view → lib}/clipboard.js +0 -0
@@ -0,0 +1,378 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { createContext, forwardRef, useContext, useId, useMemo } from "react";
3
+ import react_markdown from "react-markdown";
4
+ import rehype_katex from "rehype-katex";
5
+ import remark_gfm from "remark-gfm";
6
+ import remark_math from "remark-math";
7
+ import { CodeBlock, DEFAULT_CODE_BLOCK_STRINGS } from "./code-block.js";
8
+ import { cn } from "../../lib/index.js";
9
+ function hastText(node) {
10
+ if ('text' === node.type) return node.value ?? '';
11
+ return (node.children ?? []).map(hastText).join('');
12
+ }
13
+ function languageOf(node) {
14
+ const className = node.properties?.className;
15
+ const classes = Array.isArray(className) ? className.map(String) : [];
16
+ return classes.find((name)=>name.startsWith('language-'))?.slice('language-'.length);
17
+ }
18
+ const opensInNewTab = (href)=>!!href && !/^(#|mailto:|tel:)/i.test(href);
19
+ const BR_TAG = /^<br\s*\/?>$/i;
20
+ function remarkHtmlBreaks() {
21
+ const visit = (node)=>{
22
+ if (!node.children) return;
23
+ node.children = node.children.map((child)=>'html' === child.type && BR_TAG.test(child.value?.trim() ?? '') ? {
24
+ type: 'break'
25
+ } : child);
26
+ node.children.forEach(visit);
27
+ };
28
+ return (tree)=>visit(tree);
29
+ }
30
+ const CURSOR_CONTAINERS = new Set([
31
+ 'ul',
32
+ 'ol',
33
+ 'li',
34
+ 'blockquote',
35
+ 'table',
36
+ 'thead',
37
+ 'tbody',
38
+ 'tr'
39
+ ]);
40
+ const CURSOR_TEXT_BLOCKS = new Set([
41
+ 'p',
42
+ 'h1',
43
+ 'h2',
44
+ 'h3',
45
+ 'h4',
46
+ 'h5',
47
+ 'h6',
48
+ 'td',
49
+ 'th'
50
+ ]);
51
+ const CURSOR_CLASS = 'ml-0.5 inline-block h-[1.1em] w-[0.45em] translate-y-[0.2em] rounded-[1px] bg-foreground animate-pulse motion-reduce:animate-none';
52
+ function lastContent(node) {
53
+ const children = node.children ?? [];
54
+ for(let i = children.length - 1; i >= 0; i--){
55
+ const child = children[i];
56
+ if ('element' === child.type) return child;
57
+ if ('text' === child.type && child.value?.trim()) return child;
58
+ }
59
+ }
60
+ function findCursorHost(root) {
61
+ let node = root;
62
+ for(;;){
63
+ const last = lastContent(node);
64
+ if (last?.type !== 'element' || !last.tagName) return node;
65
+ if (CURSOR_TEXT_BLOCKS.has(last.tagName)) return last;
66
+ if (!CURSOR_CONTAINERS.has(last.tagName)) return node;
67
+ node = last;
68
+ }
69
+ }
70
+ function rehypeStreamingCursor() {
71
+ return (tree)=>{
72
+ const host = findCursorHost(tree);
73
+ host.children = [
74
+ ...host.children ?? [],
75
+ {
76
+ type: 'element',
77
+ tagName: 'span',
78
+ properties: {
79
+ dataSlot: 'markdown-cursor',
80
+ ariaHidden: 'true',
81
+ className: [
82
+ CURSOR_CLASS
83
+ ]
84
+ },
85
+ children: []
86
+ }
87
+ ];
88
+ };
89
+ }
90
+ function rehypeScopeFootnoteLabel(options) {
91
+ const LABEL = 'footnote-label';
92
+ const scoped = `${options.prefix}${LABEL}`;
93
+ const visit = (node)=>{
94
+ const properties = node.properties;
95
+ if (properties?.id === LABEL) properties.id = scoped;
96
+ if (properties && Array.isArray(properties.ariaDescribedBy)) properties.ariaDescribedBy = properties.ariaDescribedBy.map((ref)=>ref === LABEL ? scoped : ref);
97
+ node.children?.forEach(visit);
98
+ };
99
+ return (tree)=>visit(tree);
100
+ }
101
+ const DEFAULT_MARKDOWN_STRINGS = {
102
+ ...DEFAULT_CODE_BLOCK_STRINGS,
103
+ footnotes: 'Footnotes',
104
+ footnoteBack: 'Back to content',
105
+ taskDone: 'Done',
106
+ taskOpen: 'Not done'
107
+ };
108
+ function isAllowedImageSrc(src, policy) {
109
+ if ('none' === policy) return false;
110
+ if ('all' === policy) return true;
111
+ if ('function' == typeof policy) return policy(src);
112
+ try {
113
+ const base = "u" < typeof window ? 'https://relative.invalid' : window.location.href;
114
+ return new URL(src, base).origin === new URL(base).origin;
115
+ } catch {
116
+ return false;
117
+ }
118
+ }
119
+ const MarkdownContext = /*#__PURE__*/ createContext({
120
+ strings: DEFAULT_MARKDOWN_STRINGS,
121
+ images: 'none',
122
+ codeWrap: false
123
+ });
124
+ const InsideLinkContext = /*#__PURE__*/ createContext(false);
125
+ const LINK_CLASS = 'font-medium text-foreground-link underline underline-offset-2 hover:no-underline';
126
+ function MarkdownLink({ node: _node, className, href, children, ...rest }) {
127
+ return /*#__PURE__*/ jsx("a", {
128
+ href: href,
129
+ className: cn(LINK_CLASS, className),
130
+ ...opensInNewTab(href) ? {
131
+ target: '_blank',
132
+ rel: 'noreferrer'
133
+ } : {},
134
+ ...rest,
135
+ children: /*#__PURE__*/ jsx(InsideLinkContext.Provider, {
136
+ value: true,
137
+ children: children
138
+ })
139
+ });
140
+ }
141
+ function MarkdownImage({ node: _node, className, alt, src, ...rest }) {
142
+ const { images } = useContext(MarkdownContext);
143
+ const insideLink = useContext(InsideLinkContext);
144
+ const source = 'string' == typeof src ? src : '';
145
+ if (source && isAllowedImageSrc(source, images)) return /*#__PURE__*/ jsx("img", {
146
+ alt: alt ?? '',
147
+ src: source,
148
+ loading: "lazy",
149
+ referrerPolicy: "no-referrer",
150
+ className: cn('h-auto max-w-full rounded-md', className),
151
+ ...rest
152
+ });
153
+ const label = alt || source;
154
+ if (insideLink || !source) return /*#__PURE__*/ jsx("span", {
155
+ "data-slot": "markdown-image-text",
156
+ children: label
157
+ });
158
+ return /*#__PURE__*/ jsx("a", {
159
+ "data-slot": "markdown-image-link",
160
+ href: source,
161
+ target: "_blank",
162
+ rel: "noreferrer",
163
+ className: LINK_CLASS,
164
+ children: label
165
+ });
166
+ }
167
+ function MarkdownInput({ node: _node, className, type, checked, ...rest }) {
168
+ const { strings } = useContext(MarkdownContext);
169
+ if ('checkbox' !== type) return /*#__PURE__*/ jsx("input", {
170
+ type: type,
171
+ className: className,
172
+ ...rest
173
+ });
174
+ return /*#__PURE__*/ jsxs(Fragment, {
175
+ children: [
176
+ /*#__PURE__*/ jsx("input", {
177
+ type: "checkbox",
178
+ checked: checked,
179
+ "aria-hidden": "true",
180
+ tabIndex: -1,
181
+ className: cn('mr-2 size-3.5 translate-y-0.5 accent-primary', className),
182
+ ...rest
183
+ }),
184
+ /*#__PURE__*/ jsxs("span", {
185
+ "data-slot": "markdown-task-state",
186
+ className: "sr-only",
187
+ children: [
188
+ checked ? strings.taskDone : strings.taskOpen,
189
+ ' '
190
+ ]
191
+ })
192
+ ]
193
+ });
194
+ }
195
+ function MarkdownPre({ node, children, ...rest }) {
196
+ const { strings, codeWrap, renderCodeActions } = useContext(MarkdownContext);
197
+ const codeNode = node?.children?.find((child)=>'element' === child.type && 'code' === child.tagName);
198
+ if (!codeNode) return /*#__PURE__*/ jsx("pre", {
199
+ ...rest,
200
+ children: children
201
+ });
202
+ const block = {
203
+ code: hastText(codeNode).replace(/\n$/, ''),
204
+ language: languageOf(codeNode)
205
+ };
206
+ return /*#__PURE__*/ jsx(CodeBlock, {
207
+ code: block.code,
208
+ language: block.language,
209
+ wrap: codeWrap,
210
+ actions: renderCodeActions?.(block),
211
+ strings: strings
212
+ });
213
+ }
214
+ const BUILT_IN_COMPONENTS = {
215
+ h1: ({ node: _node, className, ...rest })=>/*#__PURE__*/ jsx("h1", {
216
+ className: cn('text-xl font-semibold tracking-tight', className),
217
+ ...rest
218
+ }),
219
+ h2: ({ node: _node, className, ...rest })=>/*#__PURE__*/ jsx("h2", {
220
+ className: cn('text-lg font-semibold tracking-tight', className),
221
+ ...rest
222
+ }),
223
+ h3: ({ node: _node, className, ...rest })=>/*#__PURE__*/ jsx("h3", {
224
+ className: cn('text-base font-semibold', className),
225
+ ...rest
226
+ }),
227
+ h4: ({ node: _node, className, ...rest })=>/*#__PURE__*/ jsx("h4", {
228
+ className: cn('text-sm font-semibold', className),
229
+ ...rest
230
+ }),
231
+ h5: ({ node: _node, className, ...rest })=>/*#__PURE__*/ jsx("h5", {
232
+ className: cn('text-sm font-semibold', className),
233
+ ...rest
234
+ }),
235
+ h6: ({ node: _node, className, ...rest })=>/*#__PURE__*/ jsx("h6", {
236
+ className: cn('text-sm font-semibold text-muted-foreground', className),
237
+ ...rest
238
+ }),
239
+ p: ({ node: _node, ...rest })=>/*#__PURE__*/ jsx("p", {
240
+ ...rest
241
+ }),
242
+ a: MarkdownLink,
243
+ ul: ({ node: _node, className, ...rest })=>/*#__PURE__*/ jsx("ul", {
244
+ className: cn('flex flex-col gap-1 pl-6', className?.includes('contains-task-list') ? 'list-none pl-1' : 'list-disc', 'marker:text-muted-foreground', className),
245
+ ...rest
246
+ }),
247
+ ol: ({ node: _node, className, ...rest })=>/*#__PURE__*/ jsx("ol", {
248
+ className: cn('flex list-decimal flex-col gap-1 pl-6 marker:text-muted-foreground', className),
249
+ ...rest
250
+ }),
251
+ li: ({ node: _node, className, ...rest })=>/*#__PURE__*/ jsx("li", {
252
+ className: cn('pl-1 [&>ol]:mt-1 [&>p+p]:mt-2 [&>ul]:mt-1 [&>ul.contains-task-list]:pl-6', className),
253
+ ...rest
254
+ }),
255
+ input: MarkdownInput,
256
+ blockquote: ({ node: _node, className, ...rest })=>/*#__PURE__*/ jsx("blockquote", {
257
+ className: cn('flex flex-col gap-2 border-l-2 border-border pl-4 text-muted-foreground', className),
258
+ ...rest
259
+ }),
260
+ hr: ({ node: _node, className, ...rest })=>/*#__PURE__*/ jsx("hr", {
261
+ className: cn('border-border-subtle', className),
262
+ ...rest
263
+ }),
264
+ img: MarkdownImage,
265
+ table: ({ node: _node, className, ...rest })=>/*#__PURE__*/ jsx("div", {
266
+ "data-slot": "markdown-table",
267
+ tabIndex: 0,
268
+ className: "max-w-full overflow-x-auto rounded-lg border border-border-subtle outline-none focus-visible:ring-2 focus-visible:ring-ring",
269
+ children: /*#__PURE__*/ jsx("table", {
270
+ className: cn('w-full border-collapse text-left [&_tr:last-child>td]:border-b-0', className),
271
+ ...rest
272
+ })
273
+ }),
274
+ th: ({ node: _node, className, ...rest })=>/*#__PURE__*/ jsx("th", {
275
+ className: cn('border-b border-border-subtle bg-surface-overlay px-3 py-2 font-semibold', className),
276
+ ...rest
277
+ }),
278
+ td: ({ node: _node, className, ...rest })=>/*#__PURE__*/ jsx("td", {
279
+ className: cn('border-b border-border-subtle px-3 py-2 align-top', className),
280
+ ...rest
281
+ }),
282
+ code: ({ node: _node, className, ...rest })=>/*#__PURE__*/ jsx("code", {
283
+ className: cn('rounded-md bg-surface-overlay px-1.5 py-0.5 font-mono text-[0.875em]', className),
284
+ ...rest
285
+ }),
286
+ pre: MarkdownPre
287
+ };
288
+ const Markdown = /*#__PURE__*/ forwardRef(({ children, components, remarkPlugins, rehypePlugins, streaming = false, images = 'none', codeWrap = false, renderCodeActions, strings, className, ...props }, ref)=>{
289
+ const context = useMemo(()=>({
290
+ strings: {
291
+ ...DEFAULT_MARKDOWN_STRINGS,
292
+ ...strings
293
+ },
294
+ images,
295
+ codeWrap,
296
+ renderCodeActions
297
+ }), [
298
+ strings,
299
+ images,
300
+ codeWrap,
301
+ renderCodeActions
302
+ ]);
303
+ const { footnotes, footnoteBack } = context.strings;
304
+ const footnotePrefix = `markdown${useId().replace(/[^\w-]/g, '')}-`;
305
+ const mergedComponents = useMemo(()=>components ? {
306
+ ...BUILT_IN_COMPONENTS,
307
+ ...components
308
+ } : BUILT_IN_COMPONENTS, [
309
+ components
310
+ ]);
311
+ const mergedRemarkPlugins = useMemo(()=>[
312
+ remark_gfm,
313
+ [
314
+ remark_math,
315
+ {
316
+ singleDollarTextMath: false
317
+ }
318
+ ],
319
+ remarkHtmlBreaks,
320
+ ...remarkPlugins ?? []
321
+ ], [
322
+ remarkPlugins
323
+ ]);
324
+ const mergedRehypePlugins = useMemo(()=>[
325
+ [
326
+ rehypeScopeFootnoteLabel,
327
+ {
328
+ prefix: footnotePrefix
329
+ }
330
+ ],
331
+ [
332
+ rehype_katex,
333
+ {
334
+ output: 'mathml',
335
+ throwOnError: false,
336
+ trust: false,
337
+ strict: 'ignore'
338
+ }
339
+ ],
340
+ ...rehypePlugins ?? [],
341
+ ...streaming ? [
342
+ rehypeStreamingCursor
343
+ ] : []
344
+ ], [
345
+ rehypePlugins,
346
+ streaming,
347
+ footnotePrefix
348
+ ]);
349
+ const remarkRehypeOptions = useMemo(()=>({
350
+ clobberPrefix: footnotePrefix,
351
+ footnoteLabel: footnotes,
352
+ footnoteBackLabel: footnoteBack
353
+ }), [
354
+ footnotePrefix,
355
+ footnotes,
356
+ footnoteBack
357
+ ]);
358
+ return /*#__PURE__*/ jsx("div", {
359
+ ref: ref,
360
+ "data-slot": "markdown",
361
+ "data-streaming": streaming || void 0,
362
+ "aria-busy": streaming || void 0,
363
+ className: cn('flex min-w-0 flex-col gap-3 text-sm leading-relaxed break-words text-foreground [&_math]:text-[1.15em] [&>.katex]:overflow-x-auto [&>.katex]:py-1', className),
364
+ ...props,
365
+ children: /*#__PURE__*/ jsx(MarkdownContext.Provider, {
366
+ value: context,
367
+ children: /*#__PURE__*/ jsx(react_markdown, {
368
+ components: mergedComponents,
369
+ remarkPlugins: mergedRemarkPlugins,
370
+ rehypePlugins: mergedRehypePlugins,
371
+ remarkRehypeOptions: remarkRehypeOptions,
372
+ children: children
373
+ })
374
+ })
375
+ });
376
+ });
377
+ Markdown.displayName = 'Markdown';
378
+ export { DEFAULT_MARKDOWN_STRINGS, Markdown };
@@ -0,0 +1,302 @@
1
+ "use strict";
2
+ "use client";
3
+ var __webpack_require__ = {};
4
+ (()=>{
5
+ __webpack_require__.d = (exports1, definition)=>{
6
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ get: definition[key]
9
+ });
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
14
+ })();
15
+ (()=>{
16
+ __webpack_require__.r = (exports1)=>{
17
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
18
+ value: 'Module'
19
+ });
20
+ Object.defineProperty(exports1, '__esModule', {
21
+ value: true
22
+ });
23
+ };
24
+ })();
25
+ var __webpack_exports__ = {};
26
+ __webpack_require__.r(__webpack_exports__);
27
+ __webpack_require__.d(__webpack_exports__, {
28
+ DEFAULT_MESSAGE_ACTIONS_STRINGS: ()=>DEFAULT_MESSAGE_ACTIONS_STRINGS,
29
+ DEFAULT_MESSAGE_ACTIONS_OVERFLOW_STRINGS: ()=>DEFAULT_MESSAGE_ACTIONS_OVERFLOW_STRINGS,
30
+ DEFAULT_MESSAGE_ACTION_COPY_STRINGS: ()=>DEFAULT_MESSAGE_ACTION_COPY_STRINGS,
31
+ MessageActionFeedback: ()=>MessageActionFeedback,
32
+ MessageActionsOverflow: ()=>MessageActionsOverflow,
33
+ MessageActionCopy: ()=>MessageActionCopy,
34
+ messageActionsVariants: ()=>messageActionsVariants,
35
+ DEFAULT_MESSAGE_ACTION_FEEDBACK_STRINGS: ()=>DEFAULT_MESSAGE_ACTION_FEEDBACK_STRINGS,
36
+ MessageAction: ()=>MessageAction,
37
+ MessageActions: ()=>MessageActions
38
+ });
39
+ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
40
+ const external_class_variance_authority_namespaceObject = require("class-variance-authority");
41
+ const external_lucide_react_namespaceObject = require("lucide-react");
42
+ const external_react_namespaceObject = require("react");
43
+ const index_cjs_namespaceObject = require("../../lib/index.cjs");
44
+ const clipboard_cjs_namespaceObject = require("../../lib/clipboard.cjs");
45
+ const external_button_cjs_namespaceObject = require("./button.cjs");
46
+ const external_dropdown_menu_cjs_namespaceObject = require("./dropdown-menu.cjs");
47
+ const external_toggle_cjs_namespaceObject = require("./toggle.cjs");
48
+ const external_tooltip_cjs_namespaceObject = require("./tooltip.cjs");
49
+ const DEFAULT_MESSAGE_ACTIONS_OVERFLOW_STRINGS = {
50
+ more: 'More actions'
51
+ };
52
+ const DEFAULT_MESSAGE_ACTIONS_STRINGS = {
53
+ ...DEFAULT_MESSAGE_ACTIONS_OVERFLOW_STRINGS,
54
+ label: 'Message actions'
55
+ };
56
+ const messageActionsVariants = (0, external_class_variance_authority_namespaceObject.cva)('flex w-fit max-w-full items-center gap-0.5 px-2', {
57
+ variants: {
58
+ visibility: {
59
+ always: '',
60
+ hover: 'opacity-0 transition-opacity group-hover/message:opacity-100 group-focus-within/message:opacity-100 focus-within:opacity-100 has-[[data-state=open]]:opacity-100 has-[[data-state=delayed-open]]:opacity-100 has-[[data-state=instant-open]]:opacity-100 [@media(hover:none)]:opacity-100'
61
+ }
62
+ },
63
+ defaultVariants: {
64
+ visibility: 'always'
65
+ }
66
+ });
67
+ const MessageActions = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ className, visibility = 'always', actions = [], maxVisible, strings, 'aria-label': ariaLabel, children, ...props }, ref)=>{
68
+ const text = {
69
+ ...DEFAULT_MESSAGE_ACTIONS_STRINGS,
70
+ ...strings
71
+ };
72
+ const limit = void 0 === maxVisible ? actions.length : Math.max(0, maxVisible);
73
+ const visible = actions.slice(0, limit);
74
+ const overflow = actions.slice(limit);
75
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_tooltip_cjs_namespaceObject.TooltipProvider, {
76
+ delayDuration: 300,
77
+ skipDelayDuration: 150,
78
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
79
+ ref: ref,
80
+ role: "group",
81
+ "aria-label": ariaLabel ?? text.label,
82
+ "data-slot": "message-actions",
83
+ "data-visibility": visibility,
84
+ className: (0, index_cjs_namespaceObject.cn)(messageActionsVariants({
85
+ visibility
86
+ }), className),
87
+ ...props,
88
+ children: [
89
+ children,
90
+ visible.map((action)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(MessageAction, {
91
+ label: action.label,
92
+ disabled: action.disabled,
93
+ onClick: action.onSelect,
94
+ children: action.icon
95
+ }, action.id)),
96
+ overflow.length > 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(MessageActionsOverflow, {
97
+ items: overflow,
98
+ strings: {
99
+ more: text.more
100
+ }
101
+ })
102
+ ]
103
+ })
104
+ });
105
+ });
106
+ MessageActions.displayName = 'MessageActions';
107
+ const MessageAction = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ label, tooltipSide = 'bottom', variant = 'ghost', size = '3xs', icon = true, ...props }, ref)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_tooltip_cjs_namespaceObject.Tooltip, {
108
+ children: [
109
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_tooltip_cjs_namespaceObject.TooltipTrigger, {
110
+ asChild: true,
111
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_button_cjs_namespaceObject.Button, {
112
+ ref: ref,
113
+ "data-slot": "message-action",
114
+ "aria-label": label,
115
+ variant: variant,
116
+ size: size,
117
+ icon: icon,
118
+ ...props
119
+ })
120
+ }),
121
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_tooltip_cjs_namespaceObject.TooltipContent, {
122
+ side: tooltipSide,
123
+ children: label
124
+ })
125
+ ]
126
+ }));
127
+ MessageAction.displayName = 'MessageAction';
128
+ const DEFAULT_MESSAGE_ACTION_COPY_STRINGS = {
129
+ copy: 'Copy',
130
+ copied: 'Copied'
131
+ };
132
+ const COPIED_RESET_MS = 1500;
133
+ const MessageActionCopy = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ text: copyText, onCopy, strings, onClick, ...props }, ref)=>{
134
+ const text = {
135
+ ...DEFAULT_MESSAGE_ACTION_COPY_STRINGS,
136
+ ...strings
137
+ };
138
+ const [copied, setCopied] = external_react_namespaceObject.useState(false);
139
+ const timer = external_react_namespaceObject.useRef(void 0);
140
+ external_react_namespaceObject.useEffect(()=>()=>clearTimeout(timer.current), []);
141
+ const handleClick = async (event)=>{
142
+ onClick?.(event);
143
+ if (event.defaultPrevented) return;
144
+ if (!await (0, clipboard_cjs_namespaceObject.copyTextToClipboard)(copyText)) return;
145
+ onCopy?.(copyText);
146
+ setCopied(true);
147
+ clearTimeout(timer.current);
148
+ timer.current = setTimeout(()=>setCopied(false), COPIED_RESET_MS);
149
+ };
150
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
151
+ children: [
152
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(MessageAction, {
153
+ ref: ref,
154
+ "data-copied": copied || void 0,
155
+ label: copied ? text.copied : text.copy,
156
+ onClick: handleClick,
157
+ ...props,
158
+ children: copied ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Check, {}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Copy, {})
159
+ }),
160
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("output", {
161
+ "aria-live": "polite",
162
+ className: "sr-only",
163
+ children: copied ? text.copied : ''
164
+ })
165
+ ]
166
+ });
167
+ });
168
+ MessageActionCopy.displayName = 'MessageActionCopy';
169
+ const DEFAULT_MESSAGE_ACTION_FEEDBACK_STRINGS = {
170
+ label: 'Rate this response',
171
+ helpful: 'Helpful',
172
+ notHelpful: 'Not helpful'
173
+ };
174
+ const feedbackToggleClass = 'size-6 min-w-6 px-0 aria-pressed:bg-accent aria-pressed:text-accent-foreground future:aria-pressed:text-foreground';
175
+ const MessageActionFeedback = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ value: valueProp, defaultValue = null, onChange, disabled, strings, className, 'aria-label': ariaLabel, ...props }, ref)=>{
176
+ const text = {
177
+ ...DEFAULT_MESSAGE_ACTION_FEEDBACK_STRINGS,
178
+ ...strings
179
+ };
180
+ const [uncontrolled, setUncontrolled] = external_react_namespaceObject.useState(defaultValue);
181
+ const value = void 0 === valueProp ? uncontrolled : valueProp;
182
+ const set = (next)=>{
183
+ if (next === value) return;
184
+ if (void 0 === valueProp) setUncontrolled(next);
185
+ onChange?.(next);
186
+ };
187
+ const thumbs = [
188
+ {
189
+ rating: 'up',
190
+ label: text.helpful,
191
+ icon: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.ThumbsUp, {})
192
+ },
193
+ {
194
+ rating: 'down',
195
+ label: text.notHelpful,
196
+ icon: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.ThumbsDown, {})
197
+ }
198
+ ];
199
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
200
+ ref: ref,
201
+ role: "group",
202
+ "aria-label": ariaLabel ?? text.label,
203
+ "data-slot": "message-action-feedback",
204
+ "data-value": value ?? void 0,
205
+ className: (0, index_cjs_namespaceObject.cn)('flex items-center gap-0.5', className),
206
+ ...props,
207
+ children: thumbs.map(({ rating, label, icon })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_tooltip_cjs_namespaceObject.Tooltip, {
208
+ children: [
209
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_tooltip_cjs_namespaceObject.TooltipTrigger, {
210
+ asChild: true,
211
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_toggle_cjs_namespaceObject.Toggle, {
212
+ "data-slot": "message-action",
213
+ size: "xs",
214
+ className: feedbackToggleClass,
215
+ "aria-label": label,
216
+ pressed: value === rating,
217
+ onPressedChange: ()=>set(rating),
218
+ disabled: disabled,
219
+ children: icon
220
+ })
221
+ }),
222
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_tooltip_cjs_namespaceObject.TooltipContent, {
223
+ side: "bottom",
224
+ children: label
225
+ })
226
+ ]
227
+ }, rating))
228
+ });
229
+ });
230
+ MessageActionFeedback.displayName = 'MessageActionFeedback';
231
+ const MessageActionsOverflow = /*#__PURE__*/ external_react_namespaceObject.forwardRef(({ items, strings, align = 'start', tooltipSide = 'bottom', ...props }, ref)=>{
232
+ const text = {
233
+ ...DEFAULT_MESSAGE_ACTIONS_OVERFLOW_STRINGS,
234
+ ...strings
235
+ };
236
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_dropdown_menu_cjs_namespaceObject.DropdownMenu, {
237
+ children: [
238
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_tooltip_cjs_namespaceObject.Tooltip, {
239
+ children: [
240
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuTrigger, {
241
+ asChild: true,
242
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_tooltip_cjs_namespaceObject.TooltipTrigger, {
243
+ asChild: true,
244
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_button_cjs_namespaceObject.Button, {
245
+ ref: ref,
246
+ "data-slot": "message-actions-overflow",
247
+ "aria-label": text.more,
248
+ variant: "ghost",
249
+ size: "3xs",
250
+ icon: true,
251
+ ...props,
252
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Ellipsis, {})
253
+ })
254
+ })
255
+ }),
256
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_tooltip_cjs_namespaceObject.TooltipContent, {
257
+ side: tooltipSide,
258
+ children: text.more
259
+ })
260
+ ]
261
+ }),
262
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuContent, {
263
+ align: align,
264
+ children: items.map((item)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_dropdown_menu_cjs_namespaceObject.DropdownMenuItem, {
265
+ disabled: item.disabled,
266
+ onSelect: item.onSelect,
267
+ className: (0, index_cjs_namespaceObject.cn)(item.destructive && 'text-error focus:bg-error-background focus:text-error'),
268
+ children: [
269
+ item.icon,
270
+ item.label
271
+ ]
272
+ }, item.id))
273
+ })
274
+ ]
275
+ });
276
+ });
277
+ MessageActionsOverflow.displayName = 'MessageActionsOverflow';
278
+ exports.DEFAULT_MESSAGE_ACTIONS_OVERFLOW_STRINGS = __webpack_exports__.DEFAULT_MESSAGE_ACTIONS_OVERFLOW_STRINGS;
279
+ exports.DEFAULT_MESSAGE_ACTIONS_STRINGS = __webpack_exports__.DEFAULT_MESSAGE_ACTIONS_STRINGS;
280
+ exports.DEFAULT_MESSAGE_ACTION_COPY_STRINGS = __webpack_exports__.DEFAULT_MESSAGE_ACTION_COPY_STRINGS;
281
+ exports.DEFAULT_MESSAGE_ACTION_FEEDBACK_STRINGS = __webpack_exports__.DEFAULT_MESSAGE_ACTION_FEEDBACK_STRINGS;
282
+ exports.MessageAction = __webpack_exports__.MessageAction;
283
+ exports.MessageActionCopy = __webpack_exports__.MessageActionCopy;
284
+ exports.MessageActionFeedback = __webpack_exports__.MessageActionFeedback;
285
+ exports.MessageActions = __webpack_exports__.MessageActions;
286
+ exports.MessageActionsOverflow = __webpack_exports__.MessageActionsOverflow;
287
+ exports.messageActionsVariants = __webpack_exports__.messageActionsVariants;
288
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
289
+ "DEFAULT_MESSAGE_ACTIONS_OVERFLOW_STRINGS",
290
+ "DEFAULT_MESSAGE_ACTIONS_STRINGS",
291
+ "DEFAULT_MESSAGE_ACTION_COPY_STRINGS",
292
+ "DEFAULT_MESSAGE_ACTION_FEEDBACK_STRINGS",
293
+ "MessageAction",
294
+ "MessageActionCopy",
295
+ "MessageActionFeedback",
296
+ "MessageActions",
297
+ "MessageActionsOverflow",
298
+ "messageActionsVariants"
299
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
300
+ Object.defineProperty(exports, '__esModule', {
301
+ value: true
302
+ });