@plaisolutions/react 0.3.0 → 0.5.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.
package/dist/index.js CHANGED
@@ -1,25 +1,22 @@
1
1
  import { PlaiChat } from "@plaisolutions/client";
2
2
  import { createContext, forwardRef, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
3
3
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
- import { Bot, CheckCircle2, Database, File, FileText, Globe, LoaderCircle, MessageSquare, Minus, Plug, Plus, Workflow, XCircle } from "lucide-react";
4
+ import { Bot, Check, CheckCircle2, Copy, Database, File, FileText, Globe, LoaderCircle, MessageSquare, Minus, Plug, Plus, ThumbsDown, ThumbsUp, Workflow, XCircle } from "lucide-react";
5
5
 
6
6
  //#region src/use-chat.ts
7
7
  function useChat(options) {
8
8
  const optionsRef = useRef(options);
9
9
  optionsRef.current = options;
10
- const chat = useMemo(() => new PlaiChat({
11
- transport: options.transport,
12
- initialMessages: options.initialMessages,
13
- generateId: options.generateId,
14
- onEvent: options.onEvent,
15
- onError: options.onError
16
- }), [
17
- options.transport,
18
- options.initialMessages,
19
- options.generateId,
20
- options.onEvent,
21
- options.onError
22
- ]);
10
+ const { transport, conversationId } = options;
11
+ const chat = useMemo(() => {
12
+ return new PlaiChat({
13
+ transport,
14
+ initialMessages: optionsRef.current.initialMessages,
15
+ generateId: () => optionsRef.current.generateId?.() ?? `local_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`,
16
+ onEvent: (event) => optionsRef.current.onEvent?.(event),
17
+ onError: (error) => optionsRef.current.onError?.(error)
18
+ });
19
+ }, [conversationId, transport]);
23
20
  const [state, setState] = useState(() => chat.getState());
24
21
  useEffect(() => {
25
22
  setState(chat.getState());
@@ -30,14 +27,23 @@ function useChat(options) {
30
27
  chat.stop();
31
28
  };
32
29
  }, [chat]);
30
+ const actions = useMemo(() => ({
31
+ sendMessage: chat.sendMessage.bind(chat),
32
+ rateMessage: chat.rateMessage.bind(chat),
33
+ transcribeAudio: chat.transcribeAudio.bind(chat),
34
+ uploadFile: chat.uploadFile.bind(chat),
35
+ stop: chat.stop.bind(chat),
36
+ reset: chat.reset.bind(chat),
37
+ hydrate: chat.hydrate.bind(chat),
38
+ clearError: chat.clearError.bind(chat)
39
+ }), [chat]);
33
40
  return {
34
41
  messages: state.messages,
35
42
  status: state.status,
36
43
  error: state.error,
37
44
  usage: state.usage,
38
- sendMessage: chat.sendMessage.bind(chat),
39
- stop: chat.stop.bind(chat),
40
- reset: chat.reset.bind(chat)
45
+ uploadState: state.uploadState,
46
+ ...actions
41
47
  };
42
48
  }
43
49
 
@@ -82,11 +88,15 @@ function DatasourceIcon() {
82
88
  ]
83
89
  });
84
90
  }
85
- function DatasourceToolResultCardContent({ title, description, type, resourceCount }) {
91
+ function DatasourceToolResultCardContent({ title, description, type, icon, resourceCount }) {
86
92
  return /* @__PURE__ */ jsxs(Fragment, { children: [
87
93
  /* @__PURE__ */ jsxs("header", {
88
94
  className: "flex items-center gap-3",
89
- children: [/* @__PURE__ */ jsx(DatasourceIcon, {}), /* @__PURE__ */ jsx("p", {
95
+ children: [icon ? /* @__PURE__ */ jsx("img", {
96
+ src: icon,
97
+ alt: "",
98
+ className: "size-5 shrink-0 object-contain"
99
+ }) : /* @__PURE__ */ jsx(DatasourceIcon, {}), /* @__PURE__ */ jsx("p", {
90
100
  className: "min-w-0 truncate text-base leading-5",
91
101
  children: type
92
102
  })]
@@ -112,33 +122,43 @@ function DatasourceToolResultCardContent({ title, description, type, resourceCou
112
122
  function DatasourceToolResultCard(props) {
113
123
  return /* @__PURE__ */ jsx("article", {
114
124
  "aria-label": `${props.type}: ${props.title}`,
115
- className: "w-[186px] rounded-lg bg-neutral-100 p-4 text-neutral-950",
125
+ className: "w-46.5 rounded-lg bg-neutral-100 p-4 text-neutral-950",
116
126
  children: /* @__PURE__ */ jsx(DatasourceToolResultCardContent, { ...props })
117
127
  });
118
128
  }
119
129
 
120
130
  //#endregion
121
131
  //#region src/components/resource-card.tsx
122
- function ResourceCardContent({ icon, title, description }) {
123
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("header", {
124
- className: "flex min-w-0 items-center gap-3",
125
- children: [icon ? /* @__PURE__ */ jsx("img", {
126
- src: icon,
127
- alt: "",
128
- width: "20",
129
- height: "20",
130
- className: "h-5 w-5 shrink-0 object-contain"
131
- }) : /* @__PURE__ */ jsx(File, {
132
- className: "h-5 w-5 shrink-0",
133
- "aria-hidden": "true"
134
- }), /* @__PURE__ */ jsx("p", {
135
- className: "min-w-0 truncate text-base leading-5",
136
- children: title
137
- })]
138
- }), /* @__PURE__ */ jsx("p", {
139
- className: "mt-2 line-clamp-2 text-sm leading-5",
140
- children: description
141
- })] });
132
+ function ResourceCardContent({ icon, type, title, description }) {
133
+ const heading = type ?? title;
134
+ const bodyTitle = type ? title : description;
135
+ const bodyDescription = type ? description : void 0;
136
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
137
+ /* @__PURE__ */ jsxs("header", {
138
+ className: "flex min-w-0 items-center gap-3",
139
+ children: [icon ? /* @__PURE__ */ jsx("img", {
140
+ src: icon,
141
+ alt: "",
142
+ width: "20",
143
+ height: "20",
144
+ className: "h-5 w-5 shrink-0 object-contain"
145
+ }) : /* @__PURE__ */ jsx(File, {
146
+ className: "h-5 w-5 shrink-0",
147
+ "aria-hidden": "true"
148
+ }), /* @__PURE__ */ jsx("p", {
149
+ className: "min-w-0 truncate text-base leading-5",
150
+ children: heading
151
+ })]
152
+ }),
153
+ bodyTitle ? /* @__PURE__ */ jsx("p", {
154
+ className: "mt-2 line-clamp-2 text-sm font-medium leading-5",
155
+ children: bodyTitle
156
+ }) : null,
157
+ bodyDescription ? /* @__PURE__ */ jsx("p", {
158
+ className: "mt-2 line-clamp-2 text-xs leading-4 text-neutral-600",
159
+ children: bodyDescription
160
+ }) : null
161
+ ] });
142
162
  }
143
163
  function ResourceCard(props) {
144
164
  const className = "block w-full rounded-lg bg-neutral-100 p-4 text-left text-neutral-950";
@@ -506,11 +526,12 @@ const SheetDescription = forwardRef(function SheetDescription$1({ className, id,
506
526
 
507
527
  //#endregion
508
528
  //#region src/components/datasource-folder-card.tsx
509
- function DatasourceFolderCard({ title, description, type, resources }) {
529
+ function DatasourceFolderCard({ icon, title, description, type, url, resources }) {
510
530
  return /* @__PURE__ */ jsxs(Sheet, { children: [/* @__PURE__ */ jsx(SheetTrigger, {
511
531
  "aria-label": `${type}: ${title}`,
512
532
  className: "min-h-[183px] w-[186px] rounded-lg bg-neutral-100 p-4 text-left font-normal text-neutral-950 transition-colors hover:bg-neutral-200 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950",
513
533
  children: /* @__PURE__ */ jsx(DatasourceToolResultCardContent, {
534
+ icon,
514
535
  title,
515
536
  description,
516
537
  type,
@@ -520,16 +541,30 @@ function DatasourceFolderCard({ title, description, type, resources }) {
520
541
  closeLabel: "Cerrar",
521
542
  children: [/* @__PURE__ */ jsxs(SheetHeader, {
522
543
  className: "pr-10",
523
- children: [/* @__PURE__ */ jsxs("div", {
524
- className: "flex items-start gap-3",
525
- children: [/* @__PURE__ */ jsx("span", {
526
- className: "mt-0.5 shrink-0",
527
- children: /* @__PURE__ */ jsx(DatasourceIcon, {})
528
- }), /* @__PURE__ */ jsx(SheetTitle, { children: title })]
529
- }), description ? /* @__PURE__ */ jsx(SheetDescription, {
530
- className: "line-clamp-2 text-xs leading-4",
531
- children: description
532
- }) : null]
544
+ children: [
545
+ /* @__PURE__ */ jsxs("div", {
546
+ className: "flex items-start gap-3",
547
+ children: [/* @__PURE__ */ jsx("span", {
548
+ className: "mt-0.5 shrink-0",
549
+ children: icon ? /* @__PURE__ */ jsx("img", {
550
+ src: icon,
551
+ alt: "",
552
+ className: "size-5 object-contain"
553
+ }) : /* @__PURE__ */ jsx(DatasourceIcon, {})
554
+ }), /* @__PURE__ */ jsx(SheetTitle, { children: title })]
555
+ }),
556
+ description ? /* @__PURE__ */ jsx(SheetDescription, {
557
+ className: "line-clamp-2 text-xs leading-4",
558
+ children: description
559
+ }) : null,
560
+ url ? /* @__PURE__ */ jsx("a", {
561
+ href: url,
562
+ target: "_blank",
563
+ rel: "noreferrer noopener",
564
+ className: "text-xs font-medium text-neutral-700 underline underline-offset-2",
565
+ children: "View"
566
+ }) : null
567
+ ]
533
568
  }), /* @__PURE__ */ jsxs("section", {
534
569
  className: "mt-5",
535
570
  "aria-label": "Recursos",
@@ -544,6 +579,109 @@ function DatasourceFolderCard({ title, description, type, resources }) {
544
579
  })] });
545
580
  }
546
581
 
582
+ //#endregion
583
+ //#region src/components/opengraph.ts
584
+ function normalizeLocale(locale) {
585
+ return locale?.trim().toLowerCase();
586
+ }
587
+ function getCurrentLocale() {
588
+ if (typeof document !== "undefined" && document.documentElement.lang) return document.documentElement.lang;
589
+ if (typeof navigator !== "undefined") return navigator.language || navigator.userLanguage;
590
+ }
591
+ function getLocaleCandidates(locale) {
592
+ const normalized = normalizeLocale(locale);
593
+ if (!normalized) return [];
594
+ const [language] = normalized.split("-");
595
+ return language === normalized ? [normalized] : [normalized, language];
596
+ }
597
+ function hasStringValue(value) {
598
+ return typeof value === "string" && value.trim().length > 0;
599
+ }
600
+ function getTranslation(translations, locale) {
601
+ if (!translations) return void 0;
602
+ return Object.entries(translations).find(([translationLocale]) => normalizeLocale(translationLocale) === locale)?.[1];
603
+ }
604
+ function getLocalizedOpenGraphValue(container, field, locale) {
605
+ const opengraph = container.extra_info?.opengraph;
606
+ if (!opengraph) return void 0;
607
+ for (const candidate of getLocaleCandidates(locale ?? getCurrentLocale())) {
608
+ const translated = getTranslation(opengraph.translations, candidate)?.[field];
609
+ if (hasStringValue(translated)) return translated.trim();
610
+ }
611
+ const fallback = opengraph[field];
612
+ return hasStringValue(fallback) ? fallback.trim() : void 0;
613
+ }
614
+ function getResourceTitle(resource, locale) {
615
+ return getLocalizedOpenGraphValue(resource, "title", locale) ?? resource.name;
616
+ }
617
+ function getResourceDescription(resource, locale) {
618
+ return getLocalizedOpenGraphValue(resource, "description", locale) ?? resource.summary ?? resource.content ?? void 0;
619
+ }
620
+ function getResourceOpenGraphImage(resource, locale) {
621
+ return getLocalizedOpenGraphValue(resource, "image", locale);
622
+ }
623
+ function getResourceOpenGraphType(resource, locale) {
624
+ return getLocalizedOpenGraphValue(resource, "type", locale);
625
+ }
626
+ function readNestedString(records, path) {
627
+ for (const record of records) {
628
+ let current = record;
629
+ for (const key of path) {
630
+ if (!current || typeof current !== "object" || Array.isArray(current)) {
631
+ current = void 0;
632
+ break;
633
+ }
634
+ current = current[key];
635
+ }
636
+ if (hasStringValue(current)) return current.trim();
637
+ }
638
+ }
639
+ function isGoogleDriveUrl(url) {
640
+ if (!url) return false;
641
+ try {
642
+ const hostname = new URL(url).hostname;
643
+ return hostname === "drive.google.com" || hostname.endsWith(".google.com");
644
+ } catch {
645
+ return false;
646
+ }
647
+ }
648
+ function isGoogleDriveResource(resource) {
649
+ const records = [resource.extra_info, resource.metadata];
650
+ return [
651
+ resource.datasource?.source,
652
+ readNestedString(records, ["datasource_source"]),
653
+ readNestedString(records, ["source"]),
654
+ readNestedString(records, ["origin"]),
655
+ readNestedString(records, ["datasource", "source"]),
656
+ readNestedString(records, ["datasource", "origin"])
657
+ ].some((candidate) => candidate?.toUpperCase() === "GOOGLE_DRIVE") || isGoogleDriveUrl(resource.external_url) || isGoogleDriveUrl(resource.url);
658
+ }
659
+ function getResourceUrl(resource, locale) {
660
+ const openGraphUrl = getLocalizedOpenGraphValue(resource, "url", locale);
661
+ if (openGraphUrl) return openGraphUrl;
662
+ if (isGoogleDriveResource(resource)) return resource.url ?? resource.external_url;
663
+ return resource.external_url ?? resource.url;
664
+ }
665
+ function getResourceType(resource, locale) {
666
+ const openGraphType = getResourceOpenGraphType(resource, locale);
667
+ if (openGraphType) return openGraphType;
668
+ if (resource.type?.trim()) return resource.type.charAt(0).toUpperCase() + resource.type.slice(1);
669
+ const metadataType = resource.metadata.type;
670
+ if (hasStringValue(metadataType)) return metadataType.charAt(0).toUpperCase() + metadataType.slice(1);
671
+ const url = resource.url ?? resource.external_url ?? "";
672
+ if (/\.pdf(?:$|[?#])/i.test(url)) return "PDF";
673
+ if (/\.docx?(?:$|[?#])/i.test(url)) return "Document";
674
+ if (/\.xlsx?(?:$|[?#])/i.test(url)) return "Spreadsheet";
675
+ if (/\.pptx?(?:$|[?#])/i.test(url)) return "Presentation";
676
+ if (/\.(?:jpe?g|png|gif|webp)(?:$|[?#])/i.test(url)) return "Image";
677
+ if (/\.(?:mp4|mov|avi)(?:$|[?#])/i.test(url)) return "Video";
678
+ if (/^https?:\/\//i.test(url)) return "Webpage";
679
+ return "Document";
680
+ }
681
+ function getResourceIcon(resource, locale) {
682
+ return getResourceOpenGraphImage(resource, locale) ?? readNestedString([resource.extra_info], ["icon"]) ?? readNestedString([resource.metadata], ["icon"]);
683
+ }
684
+
547
685
  //#endregion
548
686
  //#region src/components/datasource-tool-resources.tsx
549
687
  function isObject(value) {
@@ -553,15 +691,13 @@ function readString(value, key) {
553
691
  const candidate = value?.[key];
554
692
  return typeof candidate === "string" && candidate.trim() ? candidate : null;
555
693
  }
556
- function getResourceIcon(resource) {
557
- return readString(resource.extra_info, "icon") ?? readString(resource.metadata, "icon") ?? void 0;
558
- }
559
- function toResourceCardProps(resource) {
694
+ function toResourceCardProps(resource, locale) {
560
695
  return {
561
- icon: getResourceIcon(resource),
562
- title: resource.type,
563
- description: resource.name,
564
- url: resource.external_url ?? resource.url
696
+ icon: getResourceIcon(resource, locale),
697
+ type: getResourceType(resource, locale),
698
+ title: getResourceTitle(resource, locale),
699
+ description: getResourceDescription(resource, locale),
700
+ url: getResourceUrl(resource, locale)
565
701
  };
566
702
  }
567
703
  function isDatasourceResource(value) {
@@ -570,10 +706,17 @@ function isDatasourceResource(value) {
570
706
  const datasource = value.datasource;
571
707
  return typeof value.id === "string" && typeof value.name === "string" && typeof value.type === "string" && (value.url === null || typeof value.url === "string") && (value.external_url === null || typeof value.external_url === "string") && isObject(value.metadata) && isObject(value.extra_info) && (folder === null || isObject(folder) && typeof folder.id === "string" && typeof folder.name === "string" && isObject(folder.extra_info)) && (datasource === null || isObject(datasource) && typeof datasource.type === "string" && (datasource.description === null || typeof datasource.description === "string") && (datasource.summary === null || typeof datasource.summary === "string"));
572
708
  }
573
- function DatasourceToolResources({ resources, className }) {
709
+ function DatasourceToolResources({ resources, locale, className }) {
574
710
  const folderGroups = /* @__PURE__ */ new Map();
575
711
  const ungroupedResources = [];
712
+ const seenUrls = /* @__PURE__ */ new Set();
576
713
  for (const resource of resources) {
714
+ if (resource.extra_info.public === false) continue;
715
+ const resourceUrl = getResourceUrl(resource, locale);
716
+ if (resourceUrl) {
717
+ if (seenUrls.has(resourceUrl)) continue;
718
+ seenUrls.add(resourceUrl);
719
+ }
577
720
  if (!resource.folder) {
578
721
  ungroupedResources.push(resource);
579
722
  continue;
@@ -590,15 +733,20 @@ function DatasourceToolResources({ resources, className }) {
590
733
  className: joinClasses("flex flex-wrap gap-3", className),
591
734
  children: [Array.from(folderGroups.values()).map(({ folder, resources: group }) => {
592
735
  const datasource = group[0]?.datasource;
593
- const type = readString(folder.extra_info, "type") ?? datasource?.type ?? "FOLDER";
594
- const description = readString(folder.extra_info, "description") ?? readString(folder.extra_info, "summary") ?? datasource?.description ?? datasource?.summary ?? "";
736
+ const type = getLocalizedOpenGraphValue(folder, "type", locale) ?? readString(folder.extra_info, "type") ?? datasource?.type ?? "FOLDER";
737
+ const title = getLocalizedOpenGraphValue(folder, "title", locale) ?? folder.name;
738
+ const description = getLocalizedOpenGraphValue(folder, "description", locale) ?? readString(folder.extra_info, "description") ?? readString(folder.extra_info, "summary") ?? datasource?.description ?? datasource?.summary ?? "";
739
+ const icon = getLocalizedOpenGraphValue(folder, "image", locale);
740
+ const url = getLocalizedOpenGraphValue(folder, "url", locale);
595
741
  return /* @__PURE__ */ jsx(DatasourceFolderCard, {
596
- title: folder.name,
742
+ icon,
743
+ title,
597
744
  description,
598
- type,
599
- resources: group.map(toResourceCardProps)
745
+ type: getLocalizedOpenGraphValue(folder, "type", locale) ?? type,
746
+ url,
747
+ resources: group.map((resource) => toResourceCardProps(resource, locale))
600
748
  }, folder.id);
601
- }), ungroupedResources.map((resource) => /* @__PURE__ */ jsx(ResourceCard, { ...toResourceCardProps(resource) }, resource.id))]
749
+ }), ungroupedResources.map((resource) => /* @__PURE__ */ jsx(ResourceCard, { ...toResourceCardProps(resource, locale) }, resource.id))]
602
750
  });
603
751
  }
604
752
 
@@ -1902,7 +2050,7 @@ function getDatasourceResources(part) {
1902
2050
  const resources = part.metadata.resources;
1903
2051
  return Array.isArray(resources) ? resources.filter(isDatasourceResource) : [];
1904
2052
  }
1905
- function ToolResultCard({ part, className, detailsOpen = true, onOpenAgentThread }) {
2053
+ function ToolResultCard({ part, className, detailsOpen = true, locale, onOpenAgentThread }) {
1906
2054
  const officeMediaFiles = getOfficeDocumentMediaFiles(part);
1907
2055
  const datasourceResources = getDatasourceResources(part);
1908
2056
  const errorDetails = formatToolErrorDetails(part.errorDetails);
@@ -1945,6 +2093,7 @@ function ToolResultCard({ part, className, detailsOpen = true, onOpenAgentThread
1945
2093
  });
1946
2094
  if (datasourceResources.length > 0) return /* @__PURE__ */ jsx(DatasourceToolResources, {
1947
2095
  resources: datasourceResources,
2096
+ locale,
1948
2097
  className
1949
2098
  });
1950
2099
  const statusClass = part.state === "error" ? "border-rose-200 bg-rose-50 text-rose-800" : part.state === "pending" ? "border-amber-200 bg-amber-50 text-amber-800" : "border-emerald-200 bg-emerald-50 text-emerald-800";
@@ -2039,6 +2188,56 @@ function ToolResultCard({ part, className, detailsOpen = true, onOpenAgentThread
2039
2188
 
2040
2189
  //#endregion
2041
2190
  //#region src/components/message.tsx
2191
+ function Message({ align = "start", className,...props }) {
2192
+ return /* @__PURE__ */ jsx("article", {
2193
+ className: joinClasses("flex w-full items-start gap-3", align === "end" ? "flex-row-reverse" : void 0, className),
2194
+ "data-align": align,
2195
+ ...props
2196
+ });
2197
+ }
2198
+ function getFallbackInitials(fallback) {
2199
+ const words = fallback.trim().split(/\s+/).filter(Boolean);
2200
+ if (words.length === 0) return "?";
2201
+ if (words.length === 1) return words[0].slice(0, 2).toUpperCase();
2202
+ return `${words[0][0]}${words[words.length - 1][0]}`.toUpperCase();
2203
+ }
2204
+ function MessageAvatar({ src, fallback, alt = fallback, className, imageClassName,...props }) {
2205
+ const [failedSrc, setFailedSrc] = useState(null);
2206
+ const showImage = src.trim().length > 0 && failedSrc !== src;
2207
+ const initials = getFallbackInitials(fallback);
2208
+ return /* @__PURE__ */ jsx("div", {
2209
+ className: joinClasses("flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-full bg-neutral-200 text-xs font-semibold uppercase text-neutral-700", className),
2210
+ ...props,
2211
+ children: showImage ? /* @__PURE__ */ jsx("img", {
2212
+ src,
2213
+ alt,
2214
+ className: joinClasses("size-full rounded-full object-cover", imageClassName),
2215
+ onError: () => setFailedSrc(src)
2216
+ }) : /* @__PURE__ */ jsx("span", {
2217
+ role: "img",
2218
+ "aria-label": alt,
2219
+ children: initials
2220
+ })
2221
+ });
2222
+ }
2223
+ function MessageContent({ className,...props }) {
2224
+ return /* @__PURE__ */ jsx("div", {
2225
+ className: joinClasses("min-w-0 max-w-full flex-1 space-y-2", className),
2226
+ ...props
2227
+ });
2228
+ }
2229
+ function MessageHeader({ className,...props }) {
2230
+ return /* @__PURE__ */ jsx("header", {
2231
+ className: joinClasses("text-xs font-semibold uppercase tracking-wide text-neutral-500", className),
2232
+ ...props
2233
+ });
2234
+ }
2235
+ function MessageFooter({ className,...props }) {
2236
+ return /* @__PURE__ */ jsx("footer", {
2237
+ className: joinClasses("flex items-center gap-2", className),
2238
+ ...props
2239
+ });
2240
+ }
2042
2241
  const DEFAULT_COLLAPSE_THRESHOLD = 600;
2043
2242
  function getFilenameFromUrl(url) {
2044
2243
  try {
@@ -2049,16 +2248,22 @@ function getFilenameFromUrl(url) {
2049
2248
  }
2050
2249
  }
2051
2250
  function getDisplayExtension(label) {
2052
- if (!label) return;
2251
+ if (!label) return void 0;
2053
2252
  const ext = label.split(".").pop()?.trim().toUpperCase();
2054
- if (!ext || ext === label.toUpperCase()) return;
2253
+ if (!ext || ext === label.toUpperCase()) return void 0;
2055
2254
  return ext;
2056
2255
  }
2057
- function renderPart(part, index, onOpenAgentThread) {
2058
- if (part.type === "text") return /* @__PURE__ */ jsx("p", {
2059
- className: "whitespace-pre-wrap text-sm leading-6",
2060
- children: part.text
2061
- }, `text-${index}`);
2256
+ function renderPart(part, index, message, isStreaming, onOpenAgentThread, locale, renderText, renderToolCall) {
2257
+ if (part.type === "text") {
2258
+ if (renderText) return /* @__PURE__ */ jsx("div", { children: renderText(part, {
2259
+ message,
2260
+ isStreaming
2261
+ }) }, `text-${index}`);
2262
+ return /* @__PURE__ */ jsx("p", {
2263
+ className: "whitespace-pre-wrap text-sm leading-6",
2264
+ children: part.text
2265
+ }, `text-${index}`);
2266
+ }
2062
2267
  if (part.type === "input_image") {
2063
2268
  const title = part.metadata?.originalFileName || part.title || getFilenameFromUrl(part.url);
2064
2269
  return /* @__PURE__ */ jsxs("a", {
@@ -2099,59 +2304,157 @@ function renderPart(part, index, onOpenAgentThread) {
2099
2304
  })]
2100
2305
  }, `file-${index}`);
2101
2306
  }
2102
- if (part.type === "tool-call") return /* @__PURE__ */ jsx(ToolResultCard, {
2103
- part,
2104
- onOpenAgentThread
2105
- }, `tool-${part.id}-${index}`);
2307
+ if (part.type === "tool-call") {
2308
+ if (renderToolCall) return /* @__PURE__ */ jsx("div", { children: renderToolCall(part, { message }) }, `tool-${part.id}-${index}`);
2309
+ return /* @__PURE__ */ jsx(ToolResultCard, {
2310
+ part,
2311
+ locale,
2312
+ onOpenAgentThread
2313
+ }, `tool-${part.id}-${index}`);
2314
+ }
2106
2315
  if (part.type === "guardrail") return /* @__PURE__ */ jsx("p", {
2107
2316
  className: "rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-900",
2108
2317
  children: part.content
2109
2318
  }, `guardrail-${index}`);
2110
2319
  return null;
2111
2320
  }
2112
- function orderMessageParts(parts, datasourceToolResultsPosition) {
2321
+ function orderMessageParts(parts, position) {
2113
2322
  const indexedParts = parts.map((part, index) => ({
2114
2323
  part,
2115
2324
  index
2116
2325
  }));
2117
- if (datasourceToolResultsPosition === "inline") return indexedParts;
2326
+ if (position === "inline") return indexedParts;
2118
2327
  const datasourceParts = [];
2119
2328
  const remainingParts = [];
2120
2329
  for (const indexedPart of indexedParts) if (indexedPart.part.type === "tool-call" && indexedPart.part.toolType === "datasource") datasourceParts.push(indexedPart);
2121
2330
  else remainingParts.push(indexedPart);
2122
2331
  return [...datasourceParts, ...remainingParts];
2123
2332
  }
2124
- function Message({ message, className, showRole = true, collapseThreshold = DEFAULT_COLLAPSE_THRESHOLD, datasourceToolResultsPosition = "inline", onOpenAgentThread }) {
2125
- const roleLabel = message.role.charAt(0).toUpperCase() + message.role.slice(1);
2333
+ function MessageParts({ message, collapseThreshold = DEFAULT_COLLAPSE_THRESHOLD, datasourceToolResultsPosition = "inline", onOpenAgentThread, locale, renderText, renderToolCall, isStreaming = false, readMoreLabel = "Read more", readLessLabel = "Read less", className,...props }) {
2126
2334
  const [isExpanded, setIsExpanded] = useState(false);
2127
- const textContent = useMemo(() => {
2128
- return message.parts.filter((part) => part.type === "text").map((part) => part.text).join("\n");
2129
- }, [message.parts]);
2335
+ const textContent = useMemo(() => message.parts.filter((part) => part.type === "text").map((part) => part.text).join("\n"), [message.parts]);
2130
2336
  const canCollapse = message.role === "user" && message.parts.every((part) => part.type === "text") && textContent.length > collapseThreshold;
2131
2337
  const previewText = canCollapse ? `${textContent.slice(0, collapseThreshold).trimEnd()}...` : textContent;
2132
2338
  const orderedParts = useMemo(() => orderMessageParts(message.parts, datasourceToolResultsPosition), [message.parts, datasourceToolResultsPosition]);
2133
- return /* @__PURE__ */ jsxs("article", {
2134
- className: joinClasses("space-y-3 rounded-xl border border-slate-200 bg-white p-4 shadow-sm", className),
2339
+ return /* @__PURE__ */ jsxs("div", {
2340
+ className: joinClasses("space-y-2", className),
2135
2341
  "data-message-role": message.role,
2136
- children: [
2137
- showRole ? /* @__PURE__ */ jsx("header", {
2138
- className: "text-xs font-semibold uppercase tracking-wide text-slate-500",
2139
- children: roleLabel
2140
- }) : null,
2141
- /* @__PURE__ */ jsx("div", {
2142
- className: "space-y-2",
2143
- children: canCollapse && !isExpanded ? /* @__PURE__ */ jsx("p", {
2144
- className: "whitespace-pre-wrap text-sm leading-6",
2145
- children: previewText
2146
- }) : orderedParts.map(({ part, index }) => renderPart(part, index, onOpenAgentThread))
2147
- }),
2148
- canCollapse ? /* @__PURE__ */ jsx("button", {
2149
- type: "button",
2150
- className: "text-left text-xs font-medium text-slate-600 hover:text-slate-900",
2151
- onClick: () => setIsExpanded((previous) => !previous),
2152
- children: isExpanded ? "Read less" : "Read more"
2153
- }) : null
2154
- ]
2342
+ ...props,
2343
+ children: [canCollapse && !isExpanded ? /* @__PURE__ */ jsx("p", {
2344
+ className: "whitespace-pre-wrap text-sm leading-6",
2345
+ children: previewText
2346
+ }) : orderedParts.map(({ part, index }) => renderPart(part, index, message, isStreaming, onOpenAgentThread, locale, renderText, renderToolCall)), canCollapse ? /* @__PURE__ */ jsx("button", {
2347
+ type: "button",
2348
+ className: "text-left text-xs font-medium text-slate-600 hover:text-slate-900",
2349
+ onClick: () => setIsExpanded((previous) => !previous),
2350
+ children: isExpanded ? readLessLabel : readMoreLabel
2351
+ }) : null]
2352
+ });
2353
+ }
2354
+
2355
+ //#endregion
2356
+ //#region src/components/clipboard.tsx
2357
+ async function writeTextToClipboard(text$1) {
2358
+ if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) {
2359
+ await navigator.clipboard.writeText(text$1);
2360
+ return;
2361
+ }
2362
+ if (typeof document === "undefined") throw new Error("Clipboard is not available in this environment.");
2363
+ const textarea = document.createElement("textarea");
2364
+ textarea.value = text$1;
2365
+ textarea.setAttribute("readonly", "");
2366
+ textarea.style.position = "fixed";
2367
+ textarea.style.opacity = "0";
2368
+ document.body.appendChild(textarea);
2369
+ textarea.select();
2370
+ try {
2371
+ if (!document.execCommand("copy")) throw new Error("The browser rejected the clipboard operation.");
2372
+ } finally {
2373
+ textarea.remove();
2374
+ }
2375
+ }
2376
+ function Clipboard({ text: text$1, onCopy, copiedDuration = 2e3, copyLabel = "Copy", copiedLabel = "Copied", children, className, disabled, onClick, type = "button",...props }) {
2377
+ const [isCopied, setIsCopied] = useState(false);
2378
+ const [isCopying, setIsCopying] = useState(false);
2379
+ const timeoutRef = useRef();
2380
+ useEffect(() => () => {
2381
+ if (timeoutRef.current) clearTimeout(timeoutRef.current);
2382
+ }, []);
2383
+ async function handleClick(event) {
2384
+ onClick?.(event);
2385
+ if (event.defaultPrevented || disabled || isCopying) return;
2386
+ setIsCopying(true);
2387
+ try {
2388
+ await writeTextToClipboard(text$1);
2389
+ setIsCopied(true);
2390
+ if (timeoutRef.current) clearTimeout(timeoutRef.current);
2391
+ timeoutRef.current = setTimeout(() => setIsCopied(false), copiedDuration);
2392
+ try {
2393
+ await onCopy?.(text$1);
2394
+ } catch {}
2395
+ } catch {
2396
+ setIsCopied(false);
2397
+ } finally {
2398
+ setIsCopying(false);
2399
+ }
2400
+ }
2401
+ const state = {
2402
+ isCopied,
2403
+ isCopying
2404
+ };
2405
+ return /* @__PURE__ */ jsxs("button", {
2406
+ type,
2407
+ "aria-label": isCopied ? copiedLabel : copyLabel,
2408
+ className: joinClasses("inline-flex size-9 shrink-0 items-center justify-center rounded-lg border border-neutral-200 bg-white text-neutral-700 transition-colors hover:bg-neutral-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950 disabled:cursor-not-allowed disabled:opacity-40", className),
2409
+ disabled: disabled || isCopying,
2410
+ onClick: handleClick,
2411
+ ...props,
2412
+ children: [typeof children === "function" ? children(state) : children !== void 0 && children !== null ? children : isCopied ? /* @__PURE__ */ jsx(Check, {
2413
+ className: "size-4",
2414
+ "aria-hidden": "true"
2415
+ }) : /* @__PURE__ */ jsx(Copy, {
2416
+ className: "size-4",
2417
+ "aria-hidden": "true"
2418
+ }), /* @__PURE__ */ jsx("span", {
2419
+ className: "sr-only",
2420
+ "aria-live": "polite",
2421
+ children: isCopied ? copiedLabel : copyLabel
2422
+ })]
2423
+ });
2424
+ }
2425
+
2426
+ //#endregion
2427
+ //#region src/components/thumbs.tsx
2428
+ function ThumbButton({ label, icon, className, type = "button",...props }) {
2429
+ return /* @__PURE__ */ jsxs("button", {
2430
+ type,
2431
+ "aria-label": label,
2432
+ className: joinClasses("inline-flex size-9 shrink-0 items-center justify-center rounded-lg border border-neutral-200 bg-white text-neutral-700 transition-colors hover:bg-neutral-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-950 disabled:cursor-not-allowed disabled:opacity-40 aria-pressed:border-neutral-950 aria-pressed:bg-neutral-950 aria-pressed:text-white", className),
2433
+ ...props,
2434
+ children: [icon, /* @__PURE__ */ jsx("span", {
2435
+ className: "sr-only",
2436
+ children: label
2437
+ })]
2438
+ });
2439
+ }
2440
+ function ThumbUp({ label = "Rate positively",...props }) {
2441
+ return /* @__PURE__ */ jsx(ThumbButton, {
2442
+ label,
2443
+ icon: /* @__PURE__ */ jsx(ThumbsUp, {
2444
+ className: "size-4",
2445
+ "aria-hidden": "true"
2446
+ }),
2447
+ ...props
2448
+ });
2449
+ }
2450
+ function ThumbDown({ label = "Rate negatively",...props }) {
2451
+ return /* @__PURE__ */ jsx(ThumbButton, {
2452
+ label,
2453
+ icon: /* @__PURE__ */ jsx(ThumbsDown, {
2454
+ className: "size-4",
2455
+ "aria-hidden": "true"
2456
+ }),
2457
+ ...props
2155
2458
  });
2156
2459
  }
2157
2460
 
@@ -2249,16 +2552,17 @@ function PromptFormIconButton({ className, type = "button",...props }) {
2249
2552
  ...props
2250
2553
  });
2251
2554
  }
2252
- function PromptForm({ value, onValueChange, onSubmit, status = "ready", onStop, disabled = false, clearOnSubmit = true, enabledTools, placeholder = "Type a message...", sendLabel = "Send", stopLabel = "Stop", attachLabel = "Attach file", removeFileLabel = "Remove file", enableAttachments = true, files: filesProp, onFilesChange, onInvalidFiles, accept = PROMPT_FORM_FILE_ACCEPT, className, textareaClassName, attachmentsClassName, maxRows = defaultMaxRows, submitButtonClassName, stopButtonClassName, leftSlot, rightSlot }) {
2555
+ function PromptForm({ value, onValueChange, onSubmit, status = "ready", uploadState, onStop, disabled = false, clearOnSubmit = true, enabledTools, placeholder = "Type a message...", sendLabel = "Send", stopLabel = "Stop", attachLabel = "Attach file", removeFileLabel = "Remove file", uploadingLabel = "Uploading", processingUploadLabel = "Processing upload", uploadErrorLabel = "Upload failed", enableAttachments = true, files: filesProp, onFilesChange, onInvalidFiles, accept = PROMPT_FORM_FILE_ACCEPT, className, textareaClassName, attachmentsClassName, uploadProgressClassName, maxRows = defaultMaxRows, submitButtonClassName, stopButtonClassName, leftSlot, rightSlot, submitOnEnter = true, onTextareaKeyDown }) {
2253
2556
  const textareaRef = useRef(null);
2254
2557
  const [internalFiles, setInternalFiles] = useState([]);
2255
2558
  const [isSubmitting, setIsSubmitting] = useState(false);
2256
2559
  const files = filesProp ?? internalFiles;
2257
2560
  const setFiles = onFilesChange ?? setInternalFiles;
2258
2561
  const isStreaming = status === "streaming" || status === "submitted";
2562
+ const isUploading = uploadState?.status === "uploading" || uploadState?.status === "processing";
2259
2563
  const hasContent = value.trim().length > 0 || files.length > 0;
2260
- const canSubmit = !disabled && !isSubmitting && !isStreaming && hasContent;
2261
- const isInteractionDisabled = disabled || isSubmitting;
2564
+ const canSubmit = !disabled && !isSubmitting && !isStreaming && !isUploading && hasContent;
2565
+ const isInteractionDisabled = disabled || isSubmitting || isUploading;
2262
2566
  useLayoutEffect(() => {
2263
2567
  const textarea = textareaRef.current;
2264
2568
  if (textarea) resizeTextarea(textarea, maxRows);
@@ -2310,6 +2614,13 @@ function PromptForm({ value, onValueChange, onSubmit, status = "ready", onStop,
2310
2614
  onValueChange(event.target.value);
2311
2615
  resizeTextarea(event.currentTarget, maxRows);
2312
2616
  },
2617
+ onKeyDown: (event) => {
2618
+ onTextareaKeyDown?.(event);
2619
+ if (submitOnEnter && !event.defaultPrevented && event.key === "Enter" && !event.shiftKey && !event.nativeEvent.isComposing) {
2620
+ event.preventDefault();
2621
+ event.currentTarget.form?.requestSubmit();
2622
+ }
2623
+ },
2313
2624
  placeholder,
2314
2625
  disabled: isInteractionDisabled
2315
2626
  }),
@@ -2340,52 +2651,53 @@ function PromptForm({ value, onValueChange, onSubmit, status = "ready", onStop,
2340
2651
  ]
2341
2652
  })
2342
2653
  ]
2343
- }), files.length > 0 ? /* @__PURE__ */ jsx("div", {
2344
- className: joinClasses("flex flex-wrap gap-2 border-t border-neutral-200 px-4 py-2", attachmentsClassName),
2345
- children: files.map((file, index) => /* @__PURE__ */ jsxs("div", {
2346
- className: "flex max-w-full items-center gap-1.5 rounded-md bg-neutral-100 px-2 py-1 text-xs text-neutral-700",
2347
- children: [/* @__PURE__ */ jsx("span", {
2348
- className: "max-w-[150px] truncate",
2349
- children: file.name
2350
- }), /* @__PURE__ */ jsx("button", {
2351
- type: "button",
2352
- className: "text-neutral-500 transition-colors hover:text-neutral-800 disabled:cursor-not-allowed disabled:opacity-40",
2353
- "aria-label": `${removeFileLabel}: ${file.name}`,
2354
- disabled: isInteractionDisabled,
2355
- onClick: () => removeFile(index),
2356
- children: /* @__PURE__ */ jsx(X, { className: "size-3.5" })
2654
+ }), files.length > 0 ? /* @__PURE__ */ jsxs("div", {
2655
+ className: joinClasses("border-t border-neutral-200", attachmentsClassName),
2656
+ children: [/* @__PURE__ */ jsx("div", {
2657
+ className: "flex flex-wrap gap-2 px-4 py-2",
2658
+ children: files.map((file, index) => /* @__PURE__ */ jsxs("div", {
2659
+ className: "flex max-w-full items-center gap-1.5 rounded-md bg-neutral-100 px-2 py-1 text-xs text-neutral-700",
2660
+ children: [/* @__PURE__ */ jsx("span", {
2661
+ className: "max-w-[150px] truncate",
2662
+ children: file.name
2663
+ }), /* @__PURE__ */ jsx("button", {
2664
+ type: "button",
2665
+ className: "text-neutral-500 transition-colors hover:text-neutral-800 disabled:cursor-not-allowed disabled:opacity-40",
2666
+ "aria-label": `${removeFileLabel}: ${file.name}`,
2667
+ disabled: isInteractionDisabled,
2668
+ onClick: () => removeFile(index),
2669
+ children: /* @__PURE__ */ jsx(X, { className: "size-3.5" })
2670
+ })]
2671
+ }, `${file.name}-${file.lastModified}-${index}`))
2672
+ }), isUploading && uploadState ? /* @__PURE__ */ jsxs("div", {
2673
+ className: "space-y-1.5 px-4 pb-3",
2674
+ children: [/* @__PURE__ */ jsxs("div", {
2675
+ className: "flex items-center justify-between gap-3 text-xs text-neutral-500",
2676
+ children: [/* @__PURE__ */ jsxs("span", {
2677
+ className: "truncate",
2678
+ children: [uploadState.status === "processing" ? processingUploadLabel : uploadingLabel, uploadState.fileName ? `: ${uploadState.fileName}` : ""]
2679
+ }), /* @__PURE__ */ jsxs("span", { children: [Math.round(uploadState.progress), "%"] })]
2680
+ }), /* @__PURE__ */ jsx("div", {
2681
+ role: "progressbar",
2682
+ tabIndex: 0,
2683
+ "aria-label": uploadState.status === "processing" ? processingUploadLabel : uploadingLabel,
2684
+ "aria-valuemin": 0,
2685
+ "aria-valuemax": 100,
2686
+ "aria-valuenow": Math.round(uploadState.progress),
2687
+ className: joinClasses("h-1.5 overflow-hidden rounded-full bg-neutral-200", uploadProgressClassName),
2688
+ children: /* @__PURE__ */ jsx("div", {
2689
+ className: "h-full rounded-full bg-neutral-900 transition-[width] duration-150",
2690
+ style: { width: `${uploadState.progress}%` }
2691
+ })
2357
2692
  })]
2358
- }, `${file.name}-${file.lastModified}-${index}`))
2693
+ }) : uploadState?.status === "error" ? /* @__PURE__ */ jsx("p", {
2694
+ className: "px-4 pb-3 text-xs text-red-600",
2695
+ children: uploadErrorLabel
2696
+ }) : null]
2359
2697
  }) : null]
2360
2698
  });
2361
2699
  }
2362
2700
 
2363
- //#endregion
2364
- //#region src/components/speech-to-text-toggle/transcribe-audio.ts
2365
- const DUMMY_TRANSCRIPTION = "Hello, this is a demo transcription.";
2366
- async function dummyTranscribeAudio(_audio, signal) {
2367
- await new Promise((resolve, reject) => {
2368
- const timeoutId = setTimeout(resolve, 600);
2369
- signal?.addEventListener("abort", () => {
2370
- clearTimeout(timeoutId);
2371
- reject(signal.reason ?? new DOMException("Aborted", "AbortError"));
2372
- }, { once: true });
2373
- });
2374
- return DUMMY_TRANSCRIPTION;
2375
- }
2376
- async function transcribeAudioViaEndpoint(audio, endpoint, signal) {
2377
- const response = await fetch(endpoint, {
2378
- method: "POST",
2379
- body: audio,
2380
- signal
2381
- });
2382
- if (!response.ok) throw new Error(`Transcription request failed with status ${response.status}`);
2383
- const body = await response.json();
2384
- const text$1 = body.text ?? body.data;
2385
- if (!text$1) throw new Error("Transcription response did not include text");
2386
- return text$1;
2387
- }
2388
-
2389
2701
  //#endregion
2390
2702
  //#region src/components/speech-to-text-toggle/use-voice-recording.ts
2391
2703
  function useVoiceRecording() {
@@ -2439,12 +2751,17 @@ function useVoiceRecording() {
2439
2751
 
2440
2752
  //#endregion
2441
2753
  //#region src/components/speech-to-text-toggle/speech-to-text-toggle.tsx
2442
- function SpeechToTextToggle({ onTranscriptionComplete, onTranscriptionError, transcribe, transcriptionEndpoint, disabled = false, label = "Voice input", listeningLabel = "Stop recording", loadingLabel = "Transcribing...", className,...props }) {
2754
+ function SpeechToTextToggle({ onTranscriptionComplete, onTranscriptionError, transcribe, disabled = false, label = "Voice input", listeningLabel = "Stop recording", loadingLabel = "Transcribing...", className,...props }) {
2443
2755
  const [isListening, setIsListening] = useState(false);
2444
2756
  const [isTranscribing, setIsTranscribing] = useState(false);
2445
2757
  const abortControllerRef = useRef(null);
2446
- const { start, stop } = useVoiceRecording();
2447
- const transcribeAudio = transcribe ?? (transcriptionEndpoint ? (audio, signal) => transcribeAudioViaEndpoint(audio, transcriptionEndpoint, signal) : dummyTranscribeAudio);
2758
+ const { start, stop, cancel } = useVoiceRecording();
2759
+ useEffect(() => {
2760
+ return () => {
2761
+ abortControllerRef.current?.abort();
2762
+ cancel();
2763
+ };
2764
+ }, [cancel]);
2448
2765
  async function handleToggle() {
2449
2766
  if (disabled || isTranscribing) return;
2450
2767
  if (!isListening) {
@@ -2461,7 +2778,7 @@ function SpeechToTextToggle({ onTranscriptionComplete, onTranscriptionError, tra
2461
2778
  const abortController = new AbortController();
2462
2779
  abortControllerRef.current = abortController;
2463
2780
  try {
2464
- const text$1 = await transcribeAudio(await stop(), abortController.signal);
2781
+ const text$1 = await transcribe(await stop(), abortController.signal);
2465
2782
  if (text$1.trim()) onTranscriptionComplete(text$1);
2466
2783
  } catch (error) {
2467
2784
  if (error instanceof DOMException && error.name === "AbortError") return;
@@ -2488,5 +2805,19 @@ function SpeechToTextToggle({ onTranscriptionComplete, onTranscriptionError, tra
2488
2805
  }
2489
2806
 
2490
2807
  //#endregion
2491
- export { ArrowUp, DatasourceFolderCard, DatasourceToolResources, DatasourceToolResultCard, Loader, Message, Microphone, PROMPT_FORM_FILE_ACCEPT, Paperclip, PromptForm, PromptFormAttachButton, PromptFormIconButton, ResourceCard, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, SpeechToTextToggle, Stop, ToolResultAgentInvocationCard, ToolResultBrowserCard, ToolResultCard, ToolResultExternalDatasourceCard, ToolResultHttpRequestCard, ToolResultMcpCard, ToolResultOfficeDocumentsCard, ToolResultWebSearchCard, ToolResultWorkflowDispatchCard, X, dummyTranscribeAudio, isAllowedPromptFormFile, partitionPromptFormFiles, transcribeAudioViaEndpoint, useChat };
2808
+ //#region src/components/speech-to-text-toggle/transcribe-audio.ts
2809
+ const DUMMY_TRANSCRIPTION = "Hello, this is a demo transcription.";
2810
+ async function dummyTranscribeAudio(_audio, signal) {
2811
+ await new Promise((resolve, reject) => {
2812
+ const timeoutId = setTimeout(resolve, 600);
2813
+ signal?.addEventListener("abort", () => {
2814
+ clearTimeout(timeoutId);
2815
+ reject(signal.reason ?? new DOMException("Aborted", "AbortError"));
2816
+ }, { once: true });
2817
+ });
2818
+ return DUMMY_TRANSCRIPTION;
2819
+ }
2820
+
2821
+ //#endregion
2822
+ export { ArrowUp, Clipboard, DatasourceFolderCard, DatasourceToolResources, DatasourceToolResultCard, Loader, Message, MessageAvatar, MessageContent, MessageFooter, MessageHeader, MessageParts, Microphone, PROMPT_FORM_FILE_ACCEPT, Paperclip, PromptForm, PromptFormAttachButton, PromptFormIconButton, ResourceCard, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, SpeechToTextToggle, Stop, ThumbDown, ThumbUp, ToolResultAgentInvocationCard, ToolResultBrowserCard, ToolResultCard, ToolResultExternalDatasourceCard, ToolResultHttpRequestCard, ToolResultMcpCard, ToolResultOfficeDocumentsCard, ToolResultWebSearchCard, ToolResultWorkflowDispatchCard, X, dummyTranscribeAudio, getLocalizedOpenGraphValue, getResourceDescription, getResourceIcon, getResourceOpenGraphImage, getResourceOpenGraphType, getResourceTitle, getResourceType, getResourceUrl, isAllowedPromptFormFile, partitionPromptFormFiles, useChat };
2492
2823
  //# sourceMappingURL=index.js.map