@docyrus/ui-pro-ai-assistant 0.4.1 → 0.4.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.
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import { Input } from '@docyrus/ui-pro-shared/components/input';
9
9
  import { Tabs as Tabs$1, TabsList as TabsList$1, TabsTrigger as TabsTrigger$1, TabsContent as TabsContent$1 } from '@docyrus/ui-pro-shared/components/tabs';
10
10
  import { cn } from '@docyrus/ui-pro-shared/lib/utils';
11
11
  import { DefaultChatTransport, lastAssistantMessageIsCompleteWithToolCalls } from 'ai';
12
- import { PilcrowIcon, Heading1Icon, Heading2Icon, Heading3Icon, SquareIcon, ListIcon, ListOrderedIcon, ChevronDownIcon, Code2Icon, QuoteIcon, LightbulbIcon, Columns3Icon, GripVertical, FileUpIcon, TableIcon, ImageIcon, FilmIcon, AudioLinesIcon, TableOfContentsIcon, RadicalIcon, RectangleVerticalIcon, CalendarIcon, PlusIcon, FileCodeIcon, MinusIcon, ChevronRightIcon, ListTree, PenToolIcon, Link2Icon, Check, Copy, FilesIcon, Link, Text, ExternalLink, Unlink, Bold, Italic, Underline, Strikethrough, Code2, MoreHorizontal, ArrowLeftIcon, ArrowRightIcon, Minus, Plus, CircleArrowDown, Minimize2, Trash2, FileUp, CheckCircle2, FileText, Loader2, CornerDownLeftIcon, PencilLineIcon, MessageSquareTextIcon, MessagesSquareIcon, ArrowUpIcon, CheckIcon, CaptionsIcon, ZoomInIcon, CircleArrowDownIcon, MoveUpRightIcon, MoreHorizontalIcon, Eye, Pencil, PlusCircle, HelpCircle, Maximize2, X, Download, FileSpreadsheet, ChevronDown, Search, Globe, CheckCircle, FolderOpen, User, ArrowRight, MapPin, CalendarClock, List, RefreshCw, FilePlus, XIcon, CornerUpLeftIcon, AlbumIcon, FeatherIcon, ListMinusIcon, ListPlusIcon, ListEnd, Wand, LanguagesIcon, BadgeHelpIcon, PenLineIcon, SearchIcon, MusicIcon, CompassIcon, SmileIcon, LeafIcon, ClockIcon, AppleIcon, FlagIcon, StarIcon, DeleteIcon, AlignLeft, AlignCenter, AlignRight, RotateCcw, AlertTriangle, XCircle, AlertCircle, ArrowUpDown, ArrowDownToLine, PenLine, PencilIcon, TrashIcon, RefreshCwIcon, PaintRoller, MessageSquareText, ArrowLeft, ChevronLeft, Bot, ChevronRight, Brain, Lightbulb, BookOpen, PenTool, SlidersHorizontal, Wand2, Mic, RefreshCcw, Code, Star, Trash, Edit, FolderInput, Archive, Sparkles, PanelLeft, MessageSquare, NotebookText, CirclePlus, MoreVertical, FileSearch, Microscope, Ruler, AudioLines, BrainCircuit, File as File$1, Plug, Inbox, Menu, LayoutDashboard, Table2, WandSparklesIcon, ArrowUpToLineIcon, BoldIcon, ItalicIcon, UnderlineIcon, StrikethroughIcon, HighlighterIcon, Undo2Icon, Redo2Icon, ArrowDownToLineIcon, AlignLeftIcon, AlignCenterIcon, AlignRightIcon, AlignJustifyIcon, ListOrdered, ListTodoIcon, ListCollapseIcon, Table, Grid3x3Icon, Combine, Ungroup, ArrowUp, ArrowDown, Trash2Icon, LinkIcon, WrapText, OutdentIcon, IndentIcon, EyeIcon, PenIcon } from 'lucide-react';
12
+ import { PilcrowIcon, Heading1Icon, Heading2Icon, Heading3Icon, SquareIcon, ListIcon, ListOrderedIcon, ChevronDownIcon, Code2Icon, QuoteIcon, LightbulbIcon, Columns3Icon, GripVertical, FileUpIcon, TableIcon, ImageIcon, FilmIcon, AudioLinesIcon, TableOfContentsIcon, RadicalIcon, RectangleVerticalIcon, CalendarIcon, PlusIcon, FileCodeIcon, MinusIcon, ChevronRightIcon, ListTree, PenToolIcon, Link2Icon, Check, Copy, FilesIcon, Link, Text, ExternalLink, Unlink, Bold, Italic, Underline, Strikethrough, Code2, MoreHorizontal, ArrowLeftIcon, ArrowRightIcon, Minus, Plus, CircleArrowDown, Minimize2, Trash2, FileUp, CheckCircle2, FileText, Loader2, CornerDownLeftIcon, PencilLineIcon, MessageSquareTextIcon, MessagesSquareIcon, ArrowUpIcon, CheckIcon, CaptionsIcon, ZoomInIcon, CircleArrowDownIcon, MoveUpRightIcon, MoreHorizontalIcon, Eye, Pencil, PlusCircle, HelpCircle, Maximize2, X, Download, FileSpreadsheet, ChevronDown, CheckCircle, XCircle, Search, Globe, FolderOpen, User, ArrowRight, MapPin, CalendarClock, List, RefreshCw, FilePlus, XIcon, CornerUpLeftIcon, AlbumIcon, FeatherIcon, ListMinusIcon, ListPlusIcon, ListEnd, Wand, LanguagesIcon, BadgeHelpIcon, PenLineIcon, SearchIcon, MusicIcon, CompassIcon, SmileIcon, LeafIcon, ClockIcon, AppleIcon, FlagIcon, StarIcon, DeleteIcon, AlignLeft, AlignCenter, AlignRight, RotateCcw, AlertTriangle, AlertCircle, ArrowUpDown, ArrowDownToLine, PenLine, PencilIcon, TrashIcon, RefreshCwIcon, PaintRoller, MessageSquareText, ArrowLeft, ChevronLeft, Bot, ChevronRight, Brain, Lightbulb, BookOpen, PenTool, SlidersHorizontal, Wand2, Mic, RefreshCcw, Code, Star, Trash, Edit, FolderInput, Archive, Sparkles, PanelLeft, MessageSquare, NotebookText, CirclePlus, MoreVertical, FileSearch, Microscope, Ruler, AudioLines, BrainCircuit, File as File$1, Plug, Inbox, Menu, LayoutDashboard, Table2, WandSparklesIcon, ArrowUpToLineIcon, BoldIcon, ItalicIcon, UnderlineIcon, StrikethroughIcon, HighlighterIcon, Undo2Icon, Redo2Icon, ArrowDownToLineIcon, AlignLeftIcon, AlignCenterIcon, AlignRightIcon, AlignJustifyIcon, ListOrdered, ListTodoIcon, ListCollapseIcon, Table, Grid3x3Icon, Combine, Ungroup, ArrowUp, ArrowDown, Trash2Icon, LinkIcon, WrapText, OutdentIcon, IndentIcon, EyeIcon, PenIcon } from 'lucide-react';
13
13
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
14
14
  import { AsyncTokenManager, RestApiClient } from '@docyrus/api-client';
15
15
  import { TooltipProvider, Tooltip as Tooltip$1, TooltipTrigger, TooltipContent } from '@docyrus/ui-pro-shared/components/tooltip';
@@ -4799,6 +4799,368 @@ function AssistantAnimations({
4799
4799
  }
4800
4800
  );
4801
4801
  }
4802
+ function getFieldLabel(key, property) {
4803
+ if (property?.title) return property.title;
4804
+ return key.toString().replace(/_/g, " ").replace(/([A-Z])/g, " $1").split(" ").map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join(" ").trim();
4805
+ }
4806
+ function formatLabel(key) {
4807
+ return key.replace(/([A-Z])/g, " $1").replace(/^./, (s) => s.toUpperCase());
4808
+ }
4809
+ function inferType(value) {
4810
+ if (value === null || value === void 0) return "string";
4811
+ if (Array.isArray(value)) return "array";
4812
+ if (typeof value === "object") return "object";
4813
+ return typeof value;
4814
+ }
4815
+ function formatValue(value, property) {
4816
+ if (value === null || value === void 0) return "\u2014";
4817
+ const type = property?.type;
4818
+ switch (type) {
4819
+ case "boolean":
4820
+ return value ? "Yes" : "No";
4821
+ case "number":
4822
+ case "integer":
4823
+ return String(value);
4824
+ case "string":
4825
+ if (property?.format === "date") return new Date(value).toLocaleDateString();
4826
+ if (property?.format === "date-time") return new Date(value).toLocaleString();
4827
+ if (typeof value === "object") return JSON.stringify(value, null, 2);
4828
+ return String(value);
4829
+ case "array":
4830
+ return Array.isArray(value) ? `${value.length} items` : "\u2014";
4831
+ case "object":
4832
+ return typeof value === "object" ? JSON.stringify(value, null, 2) : "\u2014";
4833
+ default:
4834
+ return String(value);
4835
+ }
4836
+ }
4837
+ function formatNestedObject(value) {
4838
+ if (value === null || value === void 0) return "\u2014";
4839
+ if (typeof value !== "object") return String(value);
4840
+ return Object.entries(value).map(([k, v]) => typeof v === "object" && v !== null ? `${k}: ${JSON.stringify(v)}` : `${k}: ${v}`).join("\n");
4841
+ }
4842
+ function formatNestedArray(value) {
4843
+ if (!Array.isArray(value)) return "\u2014";
4844
+ if (value.length === 0) return "(empty)";
4845
+ if (value.every((item) => typeof item !== "object" || item === null)) return value.join(", ");
4846
+ return `${value.length} items:
4847
+ ${JSON.stringify(value[0], null, 2)}${value.length > 1 ? "\n..." : ""}`;
4848
+ }
4849
+ function formatPrimitive(value) {
4850
+ if (value === null || value === void 0) return "\u2014";
4851
+ if (typeof value === "boolean") return value ? "Yes" : "No";
4852
+ return String(value);
4853
+ }
4854
+ function getCitationsForField(basis, fieldKey) {
4855
+ if (!Array.isArray(basis) || basis.length === 0) return [];
4856
+ const entry = basis.find((item) => item.field === fieldKey);
4857
+ return entry?.citations || [];
4858
+ }
4859
+ function JsonSchemaArray({ schema, data, showHeader = true }) {
4860
+ const isEmpty = !data || data.length === 0;
4861
+ const isArrayOfObjects = !isEmpty && (schema?.items?.type === "object" || data.some((item) => typeof item === "object" && item !== null && !Array.isArray(item)));
4862
+ const columns = useMemo(() => {
4863
+ const itemSchema = schema?.items;
4864
+ if (itemSchema?.properties) {
4865
+ const cols = {};
4866
+ Object.keys(itemSchema.properties).forEach((key) => {
4867
+ cols[key] = {
4868
+ label: itemSchema.properties[key]?.title || formatLabel(key),
4869
+ property: itemSchema.properties[key]
4870
+ };
4871
+ });
4872
+ return cols;
4873
+ }
4874
+ if (isArrayOfObjects && data.length > 0) {
4875
+ const allKeys = /* @__PURE__ */ new Set();
4876
+ data.forEach((item) => {
4877
+ if (typeof item === "object" && item !== null) Object.keys(item).forEach((k) => allKeys.add(k));
4878
+ });
4879
+ const cols = {};
4880
+ allKeys.forEach((key) => {
4881
+ cols[key] = {
4882
+ label: formatLabel(key),
4883
+ property: { type: inferType(data[0]?.[key]) }
4884
+ };
4885
+ });
4886
+ return cols;
4887
+ }
4888
+ return {};
4889
+ }, [schema, data, isArrayOfObjects]);
4890
+ return /* @__PURE__ */ jsxs("div", { className: "w-full not-prose", children: [
4891
+ showHeader && schema?.title && /* @__PURE__ */ jsx("div", { className: "text-lg font-semibold text-slate-700 mb-3", children: schema.title }),
4892
+ showHeader && schema?.description && /* @__PURE__ */ jsx("div", { className: "text-sm text-slate-600 mb-3", children: schema.description }),
4893
+ isEmpty ? /* @__PURE__ */ jsx("div", { className: "text-sm text-slate-500 italic py-4", children: "No items" }) : isArrayOfObjects ? /* @__PURE__ */ jsx("div", { className: "overflow-x-auto overflow-hidden shadow-sm rounded-lg border border-slate-200", children: /* @__PURE__ */ jsxs("table", { className: "min-w-full divide-y divide-slate-200", children: [
4894
+ /* @__PURE__ */ jsx("thead", { className: "bg-slate-50", children: /* @__PURE__ */ jsx("tr", { children: Object.entries(columns).map(([key, col]) => /* @__PURE__ */ jsx(
4895
+ "th",
4896
+ {
4897
+ className: "px-4 py-3 text-left text-xs font-medium text-slate-700 uppercase tracking-wider",
4898
+ children: col.label
4899
+ },
4900
+ key
4901
+ )) }) }),
4902
+ /* @__PURE__ */ jsx("tbody", { className: "bg-white divide-y divide-slate-200", children: data.map((item, index) => /* @__PURE__ */ jsx("tr", { className: "hover:bg-slate-50", children: Object.entries(columns).map(([key, col]) => /* @__PURE__ */ jsx("td", { className: "px-4 py-3 text-sm text-slate-700", children: col.property?.type === "object" ? /* @__PURE__ */ jsx("div", { className: "text-xs font-mono bg-slate-100 rounded px-2 py-1 whitespace-pre-wrap break-all max-w-xs", children: formatNestedObject(item[key]) }) : col.property?.type === "array" ? /* @__PURE__ */ jsx("div", { className: "text-xs font-mono bg-slate-100 rounded px-2 py-1 whitespace-pre-wrap break-all max-w-xs", children: formatNestedArray(item[key]) }) : /* @__PURE__ */ jsx("span", { className: col.property?.type === "number" || col.property?.type === "integer" ? "font-mono" : "", children: formatValue(item[key], col.property) }) }, key)) }, index)) })
4903
+ ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-2", children: data.map((item, index) => /* @__PURE__ */ jsx(
4904
+ "div",
4905
+ {
4906
+ className: "px-3 py-2 bg-white border border-slate-200 rounded-md text-sm text-slate-700",
4907
+ children: formatPrimitive(item)
4908
+ },
4909
+ index
4910
+ )) })
4911
+ ] });
4912
+ }
4913
+ function JsonSchemaObject({ schema, data, basis = [] }) {
4914
+ const properties = schema?.properties || {};
4915
+ const required = schema?.required || [];
4916
+ return /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
4917
+ schema?.title && /* @__PURE__ */ jsx("div", { className: "text-lg font-semibold text-slate-700 mb-4", children: schema.title }),
4918
+ schema?.description && /* @__PURE__ */ jsx("div", { className: "text-sm text-slate-600 mb-4", children: schema.description }),
4919
+ /* @__PURE__ */ jsx("div", { className: "space-y-4", children: Object.entries(properties).map(([key, property]) => {
4920
+ const isNestedObject = property?.type === "object" && property?.properties;
4921
+ const isArr = property?.type === "array";
4922
+ const citations = getCitationsForField(basis, key);
4923
+ const isReq = required.includes(key);
4924
+ if (isNestedObject) {
4925
+ return /* @__PURE__ */ jsx("div", { className: "border border-slate-200 rounded-lg p-4 bg-slate-50", children: /* @__PURE__ */ jsx(JsonSchemaObject, { schema: property, data: data?.[key] || {}, basis }) }, key);
4926
+ }
4927
+ if (isArr) {
4928
+ return /* @__PURE__ */ jsxs("div", { className: "border border-slate-200 rounded-lg p-4 bg-slate-50", children: [
4929
+ property?.title && /* @__PURE__ */ jsx("div", { className: "text-sm font-medium text-slate-700 mb-2", children: property.title }),
4930
+ /* @__PURE__ */ jsx(JsonSchemaArray, { schema: property, data: data?.[key] || [], showHeader: false })
4931
+ ] }, key);
4932
+ }
4933
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
4934
+ /* @__PURE__ */ jsx("label", { className: `text-sm font-medium text-slate-700 mb-1${isReq ? " after:content-['*'] after:ml-0.5 after:text-red-500" : ""}`, children: getFieldLabel(key, property) }),
4935
+ property?.description && /* @__PURE__ */ jsx("div", { className: "text-xs text-slate-500 mb-1", children: property.description }),
4936
+ /* @__PURE__ */ jsx("div", { className: `px-3 py-2 bg-white border border-slate-300 rounded-md text-sm text-slate-700${property?.type === "number" || property?.type === "integer" ? " font-mono" : ""}`, children: formatValue(data?.[key], property) }),
4937
+ citations.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mt-2 text-xs text-slate-600 bg-slate-50 border border-slate-200 rounded-md p-3", children: [
4938
+ /* @__PURE__ */ jsxs("div", { className: "font-medium text-slate-700 mb-2 flex items-center gap-1", children: [
4939
+ /* @__PURE__ */ jsx("svg", { className: "w-3 h-3", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ jsx(
4940
+ "path",
4941
+ {
4942
+ fillRule: "evenodd",
4943
+ d: "M12.586 4.586a2 2 0 112.828 2.828l-3 3a2 2 0 01-2.828 0 1 1 0 00-1.414 1.414 4 4 0 005.656 0l3-3a4 4 0 00-5.656-5.656l-1.5 1.5a1 1 0 101.414 1.414l1.5-1.5zm-5 5a2 2 0 012.828 0 1 1 0 101.414-1.414 4 4 0 00-5.656 0l-3 3a4 4 0 105.656 5.656l1.5-1.5a1 1 0 10-1.414-1.414l-1.5 1.5a2 2 0 11-2.828-2.828l3-3z",
4944
+ clipRule: "evenodd"
4945
+ }
4946
+ ) }),
4947
+ "Sources (",
4948
+ citations.length,
4949
+ ")"
4950
+ ] }),
4951
+ /* @__PURE__ */ jsx("div", { className: "space-y-2", children: citations.map((citation, idx) => /* @__PURE__ */ jsxs("div", { className: "flex gap-2 scroll-mt-4", children: [
4952
+ /* @__PURE__ */ jsxs("span", { className: "font-mono text-slate-500", children: [
4953
+ "[",
4954
+ idx + 1,
4955
+ "]"
4956
+ ] }),
4957
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
4958
+ /* @__PURE__ */ jsx(
4959
+ "a",
4960
+ {
4961
+ href: citation.url,
4962
+ target: "_blank",
4963
+ rel: "noopener noreferrer",
4964
+ className: "text-blue-600 hover:text-blue-800 hover:underline break-all truncate block",
4965
+ children: citation.url
4966
+ }
4967
+ ),
4968
+ citation.excerpts && citation.excerpts.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mt-1 text-slate-600 italic truncate", children: [
4969
+ '"',
4970
+ citation.excerpts[0],
4971
+ '"'
4972
+ ] })
4973
+ ] })
4974
+ ] }, idx)) })
4975
+ ] })
4976
+ ] }, key);
4977
+ }) })
4978
+ ] });
4979
+ }
4980
+ function JsonSchemaLayout({ schema, data, basis = [] }) {
4981
+ const schemaType = schema?.type || (Array.isArray(data) ? "array" : "object");
4982
+ if (schemaType === "array") {
4983
+ return /* @__PURE__ */ jsx(JsonSchemaArray, { schema, data });
4984
+ }
4985
+ return /* @__PURE__ */ jsx(JsonSchemaObject, { schema, data, basis });
4986
+ }
4987
+ function generateSchemaFromValue(value) {
4988
+ if (value === null || value === void 0) return { type: "string" };
4989
+ if (Array.isArray(value)) {
4990
+ return {
4991
+ type: "array",
4992
+ items: value.length > 0 ? generateSchemaFromValue(value[0]) : { type: "string" }
4993
+ };
4994
+ }
4995
+ if (typeof value === "object") {
4996
+ const properties = {};
4997
+ for (const [k, v] of Object.entries(value)) {
4998
+ properties[k] = generateSchemaFromValue(v);
4999
+ }
5000
+ return { type: "object", properties };
5001
+ }
5002
+ if (typeof value === "number") return { type: Number.isInteger(value) ? "integer" : "number" };
5003
+ if (typeof value === "boolean") return { type: "boolean" };
5004
+ return { type: "string" };
5005
+ }
5006
+ function safeParse(value) {
5007
+ if (value == null) return null;
5008
+ if (typeof value === "string") {
5009
+ try {
5010
+ return JSON.parse(value);
5011
+ } catch {
5012
+ return null;
5013
+ }
5014
+ }
5015
+ return value;
5016
+ }
5017
+ function CreateRecord({
5018
+ dataSourceId,
5019
+ record,
5020
+ records,
5021
+ state,
5022
+ toolName = "createRecord",
5023
+ toolCallId,
5024
+ onToolAction
5025
+ }) {
5026
+ const apiClient = useApiClient();
5027
+ const [loading, setLoading] = useState(false);
5028
+ const [submitted, setSubmitted] = useState(false);
5029
+ const [resultMessage, setResultMessage] = useState("");
5030
+ const [resultError, setResultError] = useState(false);
5031
+ const parsedRecord = useMemo(() => safeParse(record), [record]);
5032
+ const parsedRecords = useMemo(() => {
5033
+ const parsed = safeParse(records);
5034
+ return Array.isArray(parsed) ? parsed : null;
5035
+ }, [records]);
5036
+ const isBatch = parsedRecords != null && parsedRecords.length > 0;
5037
+ const recordCount = isBatch ? parsedRecords.length : 1;
5038
+ const parsedData = isBatch ? parsedRecords : parsedRecord;
5039
+ const generatedSchema = useMemo(() => {
5040
+ if (!parsedData) return null;
5041
+ return generateSchemaFromValue(parsedData);
5042
+ }, [parsedData]);
5043
+ const handleApprove = useCallback(async () => {
5044
+ setLoading(true);
5045
+ setResultError(false);
5046
+ try {
5047
+ const metaRes = await apiClient.get(`/dev/data-sources/${dataSourceId}`);
5048
+ if (!metaRes.success || !metaRes.data) {
5049
+ throw new Error("Data source metadata not available");
5050
+ }
5051
+ const ds = metaRes.data;
5052
+ const appSlug = ds.app_slug || ds.app?.slug;
5053
+ const dsSlug = ds.slug;
5054
+ if (!appSlug || !dsSlug) {
5055
+ throw new Error("Data source metadata not available");
5056
+ }
5057
+ const endpoint = `/apps/${appSlug}/data-sources/${dsSlug}/items`;
5058
+ let result;
5059
+ if (isBatch) {
5060
+ result = await apiClient.post(endpoint, { records: parsedRecords });
5061
+ } else {
5062
+ result = await apiClient.post(endpoint, parsedRecord);
5063
+ }
5064
+ if (!result.success) {
5065
+ throw new Error(
5066
+ typeof result.error === "string" ? result.error : "Failed to create record(s)"
5067
+ );
5068
+ }
5069
+ setSubmitted(true);
5070
+ setResultMessage(
5071
+ isBatch ? `${recordCount} record(s) created successfully` : "Record created successfully"
5072
+ );
5073
+ onToolAction({
5074
+ tool: toolName,
5075
+ toolCallId,
5076
+ decision: "submit",
5077
+ input: {
5078
+ success: true,
5079
+ data: result.data,
5080
+ count: isBatch ? result.data?.length ?? recordCount : 1
5081
+ }
5082
+ });
5083
+ } catch (error) {
5084
+ const message = error instanceof Error ? error.message : "Failed to create record(s)";
5085
+ setResultError(true);
5086
+ setResultMessage(message);
5087
+ onToolAction({
5088
+ tool: toolName,
5089
+ toolCallId,
5090
+ decision: "submit",
5091
+ input: {
5092
+ success: false,
5093
+ error: message
5094
+ }
5095
+ });
5096
+ } finally {
5097
+ setLoading(false);
5098
+ }
5099
+ }, [
5100
+ apiClient,
5101
+ dataSourceId,
5102
+ isBatch,
5103
+ parsedRecord,
5104
+ parsedRecords,
5105
+ recordCount,
5106
+ toolName,
5107
+ toolCallId,
5108
+ onToolAction
5109
+ ]);
5110
+ const handleReject = useCallback(() => {
5111
+ setSubmitted(true);
5112
+ setResultMessage("Record creation rejected by user");
5113
+ setResultError(true);
5114
+ onToolAction({
5115
+ tool: toolName,
5116
+ toolCallId,
5117
+ decision: "submit",
5118
+ input: {
5119
+ success: false,
5120
+ error: "User rejected the record creation"
5121
+ }
5122
+ });
5123
+ }, [toolName, toolCallId, onToolAction]);
5124
+ const showActions = state !== "output-available" && !submitted;
5125
+ return /* @__PURE__ */ jsxs("div", { className: "rounded-lg border bg-card p-4 space-y-3", children: [
5126
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
5127
+ /* @__PURE__ */ jsx(PlusCircle, { className: "size-5 text-blue-500" }),
5128
+ /* @__PURE__ */ jsx("h4", { className: "font-medium text-sm", children: isBatch ? `Create ${recordCount} new records` : "Create new record" })
5129
+ ] }),
5130
+ parsedData && /* @__PURE__ */ jsx("div", { className: "max-h-80 overflow-auto", children: generatedSchema ? /* @__PURE__ */ jsx(JsonSchemaLayout, { schema: generatedSchema, data: parsedData }) : /* @__PURE__ */ jsx(CodeBlock, { code: JSON.stringify(parsedData, null, 2), language: "json", children: /* @__PURE__ */ jsx(CodeBlockCopyButton, {}) }) }),
5131
+ showActions && /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
5132
+ /* @__PURE__ */ jsx(
5133
+ Button,
5134
+ {
5135
+ size: "sm",
5136
+ onClick: handleApprove,
5137
+ disabled: loading,
5138
+ children: loading ? /* @__PURE__ */ jsxs(Fragment, { children: [
5139
+ /* @__PURE__ */ jsx(Loader2, { className: "size-3.5 mr-1.5 animate-spin" }),
5140
+ isBatch ? `Creating ${recordCount} Records\u2026` : "Creating\u2026"
5141
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
5142
+ /* @__PURE__ */ jsx(CheckCircle, { className: "size-3.5 mr-1.5" }),
5143
+ isBatch ? `Create ${recordCount} Records` : "Create Record"
5144
+ ] })
5145
+ }
5146
+ ),
5147
+ /* @__PURE__ */ jsxs(
5148
+ Button,
5149
+ {
5150
+ size: "sm",
5151
+ variant: "outline",
5152
+ onClick: handleReject,
5153
+ disabled: loading,
5154
+ children: [
5155
+ /* @__PURE__ */ jsx(XCircle, { className: "size-3.5 mr-1.5" }),
5156
+ "Reject"
5157
+ ]
5158
+ }
5159
+ )
5160
+ ] }),
5161
+ resultMessage && /* @__PURE__ */ jsx("div", { className: `text-xs font-medium ${resultError ? "text-destructive" : "text-green-600"}`, children: resultMessage })
5162
+ ] });
5163
+ }
4802
5164
  function truncateText(text, maxLength) {
4803
5165
  if (!text) return "";
4804
5166
  return text.length > maxLength ? `${text.substring(0, maxLength)}...` : text;
@@ -5695,24 +6057,15 @@ function ShowAdvancedDataTable({
5695
6057
  const [open, setOpen] = useState(true);
5696
6058
  const containerRef = useRef(null);
5697
6059
  const tableRef = useRef(null);
5698
- const parsedData = useMemo(() => {
5699
- if (!data) return [];
6060
+ const { parsedData, parseError } = useMemo(() => {
6061
+ if (state !== "output-available" || !data) return { parsedData: [], parseError: null };
5700
6062
  try {
5701
6063
  const parsed = JSON.parse(data);
5702
- return Array.isArray(parsed) ? parsed : [];
5703
- } catch {
5704
- return null;
5705
- }
5706
- }, [data]);
5707
- const parseError = useMemo(() => {
5708
- if (!data) return null;
5709
- try {
5710
- JSON.parse(data);
5711
- return null;
6064
+ return { parsedData: Array.isArray(parsed) ? parsed : [], parseError: null };
5712
6065
  } catch (e) {
5713
- return e.message;
6066
+ return { parsedData: null, parseError: e.message };
5714
6067
  }
5715
- }, [data]);
6068
+ }, [data, state]);
5716
6069
  const vtableColumns = useMemo(() => {
5717
6070
  return columns.map((col) => {
5718
6071
  const field = col.field ?? col.name ?? "";
@@ -5752,7 +6105,9 @@ function ShowAdvancedDataTable({
5752
6105
  defaultHeaderRowHeight,
5753
6106
  defaultColWidth,
5754
6107
  widthMode: "standard",
5755
- height,
6108
+ canvasHeight: "auto",
6109
+ maxCanvasHeight: height,
6110
+ heightMode: "autoHeight",
5756
6111
  animationAppear: false
5757
6112
  };
5758
6113
  if (enableTree) {
@@ -5854,14 +6209,14 @@ function ShowAdvancedDataTable({
5854
6209
  }
5855
6210
  ),
5856
6211
  /* @__PURE__ */ jsxs("div", { className: cn("p-4", !open && "hidden"), children: [
5857
- state !== "output-available" && !parseError && /* @__PURE__ */ jsx("div", { className: "w-full h-[200px] rounded-lg bg-muted/30 animate-pulse" }),
5858
- parseError && /* @__PURE__ */ jsxs("div", { className: "text-sm text-destructive bg-destructive/10 border border-destructive/20 rounded-lg p-3", children: [
6212
+ state !== "output-available" && /* @__PURE__ */ jsx("div", { className: "w-full h-[200px] rounded-lg bg-muted/30 animate-pulse" }),
6213
+ state === "output-available" && parseError && /* @__PURE__ */ jsxs("div", { className: "text-sm text-destructive bg-destructive/10 border border-destructive/20 rounded-lg p-3", children: [
5859
6214
  /* @__PURE__ */ jsx("div", { className: "font-medium", children: "Error parsing data" }),
5860
6215
  /* @__PURE__ */ jsx("div", { className: "text-xs mt-1", children: parseError })
5861
6216
  ] }),
5862
6217
  errorText && !parseError && /* @__PURE__ */ jsx("div", { className: "text-sm text-destructive bg-destructive/10 border border-destructive/20 rounded-lg p-3", children: errorText }),
5863
6218
  state === "output-available" && !parseError && parsedData && parsedData.length === 0 && /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground text-center py-6", children: "No data to display" }),
5864
- /* @__PURE__ */ jsx("div", { ref: containerRef, className: "w-full rounded-lg", style: { height: `${height}px` } }),
6219
+ /* @__PURE__ */ jsx("div", { ref: containerRef, className: "w-full rounded-lg" }),
5865
6220
  state === "output-available" && parsedData && parsedData.length > 0 && /* @__PURE__ */ jsxs("div", { className: "text-xs text-muted-foreground mt-2", children: [
5866
6221
  parsedData.length,
5867
6222
  " ",
@@ -6741,6 +7096,20 @@ function GenerativeUITool({
6741
7096
  }
6742
7097
  ) });
6743
7098
  }
7099
+ if (toolName === "createRecord") {
7100
+ return /* @__PURE__ */ jsx("div", { className: "not-prose mb-4 w-full", children: /* @__PURE__ */ jsx(
7101
+ CreateRecord,
7102
+ {
7103
+ dataSourceId: part.input?.dataSourceId,
7104
+ record: part.input?.record,
7105
+ records: part.input?.records,
7106
+ state: part.state,
7107
+ toolName,
7108
+ toolCallId: part.toolCallId,
7109
+ onToolAction
7110
+ }
7111
+ ) });
7112
+ }
6744
7113
  if (toolName === "showCreateRecordForm" || toolName === "showUpdateRecordForm" || toolName === "showRecordDetailsForm") {
6745
7114
  const recordMode = toolName === "showCreateRecordForm" ? "add" : toolName === "showUpdateRecordForm" ? "edit" : "view";
6746
7115
  const dataSourceId = part.input?.dataSourceId || part.output?.result?.dataSourceId;
@@ -7248,7 +7617,12 @@ var DISPLAY_ONLY_TOOLS = /* @__PURE__ */ new Set([
7248
7617
  "showGeneratedContentOptions",
7249
7618
  "createAgentTask"
7250
7619
  ]);
7251
- var INTERACTIVE_GENERATIVE_TOOLS = /* @__PURE__ */ new Set(["requestApproval", "previewCode", "requestUserInput"]);
7620
+ var INTERACTIVE_GENERATIVE_TOOLS = /* @__PURE__ */ new Set([
7621
+ "requestApproval",
7622
+ "previewCode",
7623
+ "requestUserInput",
7624
+ "createRecord"
7625
+ ]);
7252
7626
  function CopyButton({ text }) {
7253
7627
  const { t } = useAssistantTranslation();
7254
7628
  const [copied, setCopied] = useState(false);
@@ -9774,191 +10148,6 @@ function CanvasSpreadsheetView({
9774
10148
  }
9775
10149
  ) });
9776
10150
  }
9777
- function getFieldLabel(key, property) {
9778
- if (property?.title) return property.title;
9779
- return key.toString().replace(/_/g, " ").replace(/([A-Z])/g, " $1").split(" ").map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join(" ").trim();
9780
- }
9781
- function formatLabel(key) {
9782
- return key.replace(/([A-Z])/g, " $1").replace(/^./, (s) => s.toUpperCase());
9783
- }
9784
- function inferType(value) {
9785
- if (value === null || value === void 0) return "string";
9786
- if (Array.isArray(value)) return "array";
9787
- if (typeof value === "object") return "object";
9788
- return typeof value;
9789
- }
9790
- function formatValue(value, property) {
9791
- if (value === null || value === void 0) return "\u2014";
9792
- const type = property?.type;
9793
- switch (type) {
9794
- case "boolean":
9795
- return value ? "Yes" : "No";
9796
- case "number":
9797
- case "integer":
9798
- return String(value);
9799
- case "string":
9800
- if (property?.format === "date") return new Date(value).toLocaleDateString();
9801
- if (property?.format === "date-time") return new Date(value).toLocaleString();
9802
- if (typeof value === "object") return JSON.stringify(value, null, 2);
9803
- return String(value);
9804
- case "array":
9805
- return Array.isArray(value) ? `${value.length} items` : "\u2014";
9806
- case "object":
9807
- return typeof value === "object" ? JSON.stringify(value, null, 2) : "\u2014";
9808
- default:
9809
- return String(value);
9810
- }
9811
- }
9812
- function formatNestedObject(value) {
9813
- if (value === null || value === void 0) return "\u2014";
9814
- if (typeof value !== "object") return String(value);
9815
- return Object.entries(value).map(([k, v]) => typeof v === "object" && v !== null ? `${k}: ${JSON.stringify(v)}` : `${k}: ${v}`).join("\n");
9816
- }
9817
- function formatNestedArray(value) {
9818
- if (!Array.isArray(value)) return "\u2014";
9819
- if (value.length === 0) return "(empty)";
9820
- if (value.every((item) => typeof item !== "object" || item === null)) return value.join(", ");
9821
- return `${value.length} items:
9822
- ${JSON.stringify(value[0], null, 2)}${value.length > 1 ? "\n..." : ""}`;
9823
- }
9824
- function formatPrimitive(value) {
9825
- if (value === null || value === void 0) return "\u2014";
9826
- if (typeof value === "boolean") return value ? "Yes" : "No";
9827
- return String(value);
9828
- }
9829
- function getCitationsForField(basis, fieldKey) {
9830
- if (!Array.isArray(basis) || basis.length === 0) return [];
9831
- const entry = basis.find((item) => item.field === fieldKey);
9832
- return entry?.citations || [];
9833
- }
9834
- function JsonSchemaArray({ schema, data, showHeader = true }) {
9835
- const isEmpty = !data || data.length === 0;
9836
- const isArrayOfObjects = !isEmpty && (schema?.items?.type === "object" || data.some((item) => typeof item === "object" && item !== null && !Array.isArray(item)));
9837
- const columns = useMemo(() => {
9838
- const itemSchema = schema?.items;
9839
- if (itemSchema?.properties) {
9840
- const cols = {};
9841
- Object.keys(itemSchema.properties).forEach((key) => {
9842
- cols[key] = {
9843
- label: itemSchema.properties[key]?.title || formatLabel(key),
9844
- property: itemSchema.properties[key]
9845
- };
9846
- });
9847
- return cols;
9848
- }
9849
- if (isArrayOfObjects && data.length > 0) {
9850
- const allKeys = /* @__PURE__ */ new Set();
9851
- data.forEach((item) => {
9852
- if (typeof item === "object" && item !== null) Object.keys(item).forEach((k) => allKeys.add(k));
9853
- });
9854
- const cols = {};
9855
- allKeys.forEach((key) => {
9856
- cols[key] = {
9857
- label: formatLabel(key),
9858
- property: { type: inferType(data[0]?.[key]) }
9859
- };
9860
- });
9861
- return cols;
9862
- }
9863
- return {};
9864
- }, [schema, data, isArrayOfObjects]);
9865
- return /* @__PURE__ */ jsxs("div", { className: "w-full not-prose", children: [
9866
- showHeader && schema?.title && /* @__PURE__ */ jsx("div", { className: "text-lg font-semibold text-slate-700 mb-3", children: schema.title }),
9867
- showHeader && schema?.description && /* @__PURE__ */ jsx("div", { className: "text-sm text-slate-600 mb-3", children: schema.description }),
9868
- isEmpty ? /* @__PURE__ */ jsx("div", { className: "text-sm text-slate-500 italic py-4", children: "No items" }) : isArrayOfObjects ? /* @__PURE__ */ jsx("div", { className: "overflow-x-auto overflow-hidden shadow-sm rounded-lg border border-slate-200", children: /* @__PURE__ */ jsxs("table", { className: "min-w-full divide-y divide-slate-200", children: [
9869
- /* @__PURE__ */ jsx("thead", { className: "bg-slate-50", children: /* @__PURE__ */ jsx("tr", { children: Object.entries(columns).map(([key, col]) => /* @__PURE__ */ jsx(
9870
- "th",
9871
- {
9872
- className: "px-4 py-3 text-left text-xs font-medium text-slate-700 uppercase tracking-wider",
9873
- children: col.label
9874
- },
9875
- key
9876
- )) }) }),
9877
- /* @__PURE__ */ jsx("tbody", { className: "bg-white divide-y divide-slate-200", children: data.map((item, index) => /* @__PURE__ */ jsx("tr", { className: "hover:bg-slate-50", children: Object.entries(columns).map(([key, col]) => /* @__PURE__ */ jsx("td", { className: "px-4 py-3 text-sm text-slate-700", children: col.property?.type === "object" ? /* @__PURE__ */ jsx("div", { className: "text-xs font-mono bg-slate-100 rounded px-2 py-1 whitespace-pre-wrap break-all max-w-xs", children: formatNestedObject(item[key]) }) : col.property?.type === "array" ? /* @__PURE__ */ jsx("div", { className: "text-xs font-mono bg-slate-100 rounded px-2 py-1 whitespace-pre-wrap break-all max-w-xs", children: formatNestedArray(item[key]) }) : /* @__PURE__ */ jsx("span", { className: col.property?.type === "number" || col.property?.type === "integer" ? "font-mono" : "", children: formatValue(item[key], col.property) }) }, key)) }, index)) })
9878
- ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-2", children: data.map((item, index) => /* @__PURE__ */ jsx(
9879
- "div",
9880
- {
9881
- className: "px-3 py-2 bg-white border border-slate-200 rounded-md text-sm text-slate-700",
9882
- children: formatPrimitive(item)
9883
- },
9884
- index
9885
- )) })
9886
- ] });
9887
- }
9888
- function JsonSchemaObject({ schema, data, basis = [] }) {
9889
- const properties = schema?.properties || {};
9890
- const required = schema?.required || [];
9891
- return /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
9892
- schema?.title && /* @__PURE__ */ jsx("div", { className: "text-lg font-semibold text-slate-700 mb-4", children: schema.title }),
9893
- schema?.description && /* @__PURE__ */ jsx("div", { className: "text-sm text-slate-600 mb-4", children: schema.description }),
9894
- /* @__PURE__ */ jsx("div", { className: "space-y-4", children: Object.entries(properties).map(([key, property]) => {
9895
- const isNestedObject = property?.type === "object" && property?.properties;
9896
- const isArr = property?.type === "array";
9897
- const citations = getCitationsForField(basis, key);
9898
- const isReq = required.includes(key);
9899
- if (isNestedObject) {
9900
- return /* @__PURE__ */ jsx("div", { className: "border border-slate-200 rounded-lg p-4 bg-slate-50", children: /* @__PURE__ */ jsx(JsonSchemaObject, { schema: property, data: data?.[key] || {}, basis }) }, key);
9901
- }
9902
- if (isArr) {
9903
- return /* @__PURE__ */ jsxs("div", { className: "border border-slate-200 rounded-lg p-4 bg-slate-50", children: [
9904
- property?.title && /* @__PURE__ */ jsx("div", { className: "text-sm font-medium text-slate-700 mb-2", children: property.title }),
9905
- /* @__PURE__ */ jsx(JsonSchemaArray, { schema: property, data: data?.[key] || [], showHeader: false })
9906
- ] }, key);
9907
- }
9908
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
9909
- /* @__PURE__ */ jsx("label", { className: `text-sm font-medium text-slate-700 mb-1${isReq ? " after:content-['*'] after:ml-0.5 after:text-red-500" : ""}`, children: getFieldLabel(key, property) }),
9910
- property?.description && /* @__PURE__ */ jsx("div", { className: "text-xs text-slate-500 mb-1", children: property.description }),
9911
- /* @__PURE__ */ jsx("div", { className: `px-3 py-2 bg-white border border-slate-300 rounded-md text-sm text-slate-700${property?.type === "number" || property?.type === "integer" ? " font-mono" : ""}`, children: formatValue(data?.[key], property) }),
9912
- citations.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mt-2 text-xs text-slate-600 bg-slate-50 border border-slate-200 rounded-md p-3", children: [
9913
- /* @__PURE__ */ jsxs("div", { className: "font-medium text-slate-700 mb-2 flex items-center gap-1", children: [
9914
- /* @__PURE__ */ jsx("svg", { className: "w-3 h-3", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ jsx(
9915
- "path",
9916
- {
9917
- fillRule: "evenodd",
9918
- d: "M12.586 4.586a2 2 0 112.828 2.828l-3 3a2 2 0 01-2.828 0 1 1 0 00-1.414 1.414 4 4 0 005.656 0l3-3a4 4 0 00-5.656-5.656l-1.5 1.5a1 1 0 101.414 1.414l1.5-1.5zm-5 5a2 2 0 012.828 0 1 1 0 101.414-1.414 4 4 0 00-5.656 0l-3 3a4 4 0 105.656 5.656l1.5-1.5a1 1 0 10-1.414-1.414l-1.5 1.5a2 2 0 11-2.828-2.828l3-3z",
9919
- clipRule: "evenodd"
9920
- }
9921
- ) }),
9922
- "Sources (",
9923
- citations.length,
9924
- ")"
9925
- ] }),
9926
- /* @__PURE__ */ jsx("div", { className: "space-y-2", children: citations.map((citation, idx) => /* @__PURE__ */ jsxs("div", { className: "flex gap-2 scroll-mt-4", children: [
9927
- /* @__PURE__ */ jsxs("span", { className: "font-mono text-slate-500", children: [
9928
- "[",
9929
- idx + 1,
9930
- "]"
9931
- ] }),
9932
- /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
9933
- /* @__PURE__ */ jsx(
9934
- "a",
9935
- {
9936
- href: citation.url,
9937
- target: "_blank",
9938
- rel: "noopener noreferrer",
9939
- className: "text-blue-600 hover:text-blue-800 hover:underline break-all truncate block",
9940
- children: citation.url
9941
- }
9942
- ),
9943
- citation.excerpts && citation.excerpts.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mt-1 text-slate-600 italic truncate", children: [
9944
- '"',
9945
- citation.excerpts[0],
9946
- '"'
9947
- ] })
9948
- ] })
9949
- ] }, idx)) })
9950
- ] })
9951
- ] }, key);
9952
- }) })
9953
- ] });
9954
- }
9955
- function JsonSchemaLayout({ schema, data, basis = [] }) {
9956
- const schemaType = schema?.type || (Array.isArray(data) ? "array" : "object");
9957
- if (schemaType === "array") {
9958
- return /* @__PURE__ */ jsx(JsonSchemaArray, { schema, data });
9959
- }
9960
- return /* @__PURE__ */ jsx(JsonSchemaObject, { schema, data, basis });
9961
- }
9962
10151
  function CanvasDeepResearchView({
9963
10152
  title,
9964
10153
  output_schema,
@@ -10512,7 +10701,7 @@ var buttonVariants = cva(
10512
10701
  }
10513
10702
  }
10514
10703
  );
10515
- var Button12 = withTooltip(({
10704
+ var Button13 = withTooltip(({
10516
10705
  active,
10517
10706
  asChild = false,
10518
10707
  children,
@@ -11120,7 +11309,7 @@ function AIMenu() {
11120
11309
  }
11121
11310
  ),
11122
11311
  /* @__PURE__ */ jsx(
11123
- Button12,
11312
+ Button13,
11124
11313
  {
11125
11314
  className: "no-focus-ring mt-1 shrink-0",
11126
11315
  disabled: !isLoading && input.trim().length === 0,
@@ -11994,7 +12183,7 @@ function Comment(props) {
11994
12183
  ] }),
11995
12184
  isMyComment && (hovering || dropdownOpen) && /* @__PURE__ */ jsxs("div", { className: "absolute top-0 right-0 flex space-x-1", children: [
11996
12185
  index === 0 && /* @__PURE__ */ jsx(
11997
- Button12,
12186
+ Button13,
11998
12187
  {
11999
12188
  className: "h-6 p-1 text-muted-foreground",
12000
12189
  onClick: onResolveComment,
@@ -12043,7 +12232,7 @@ function Comment(props) {
12043
12232
  ),
12044
12233
  isEditing && /* @__PURE__ */ jsxs("div", { className: "ml-auto flex shrink-0 gap-1", children: [
12045
12234
  /* @__PURE__ */ jsx(
12046
- Button12,
12235
+ Button13,
12047
12236
  {
12048
12237
  className: "size-[28px]",
12049
12238
  onClick: (e) => {
@@ -12056,7 +12245,7 @@ function Comment(props) {
12056
12245
  }
12057
12246
  ),
12058
12247
  /* @__PURE__ */ jsx(
12059
- Button12,
12248
+ Button13,
12060
12249
  {
12061
12250
  onClick: (e) => {
12062
12251
  e.stopPropagation();
@@ -12124,7 +12313,7 @@ function CommentMoreDropdown(props) {
12124
12313
  onOpenChange: setDropdownOpen,
12125
12314
  open: dropdownOpen,
12126
12315
  children: [
12127
- /* @__PURE__ */ jsx(DropdownMenuTrigger3, { asChild: true, onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsx(Button12, { className: cn("h-6 p-1 text-muted-foreground"), variant: "ghost", children: /* @__PURE__ */ jsx(MoreHorizontalIcon, { className: "size-4" }) }) }),
12316
+ /* @__PURE__ */ jsx(DropdownMenuTrigger3, { asChild: true, onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsx(Button13, { className: cn("h-6 p-1 text-muted-foreground"), variant: "ghost", children: /* @__PURE__ */ jsx(MoreHorizontalIcon, { className: "size-4" }) }) }),
12128
12317
  /* @__PURE__ */ jsx(
12129
12318
  DropdownMenuContent3,
12130
12319
  {
@@ -12296,7 +12485,7 @@ function CommentCreateForm({
12296
12485
  }
12297
12486
  ),
12298
12487
  /* @__PURE__ */ jsx(
12299
- Button12,
12488
+ Button13,
12300
12489
  {
12301
12490
  className: "absolute right-0 bottom-0 ml-auto shrink-0",
12302
12491
  disabled: commentContent.trim().length === 0,
@@ -12630,7 +12819,7 @@ function BlockSuggestionCard({
12630
12819
  )),
12631
12820
  hovering && /* @__PURE__ */ jsxs("div", { className: "absolute top-4 right-4 flex gap-2", children: [
12632
12821
  /* @__PURE__ */ jsx(
12633
- Button12,
12822
+ Button13,
12634
12823
  {
12635
12824
  variant: "ghost",
12636
12825
  className: "size-6 p-1 text-muted-foreground",
@@ -12639,7 +12828,7 @@ function BlockSuggestionCard({
12639
12828
  }
12640
12829
  ),
12641
12830
  /* @__PURE__ */ jsx(
12642
- Button12,
12831
+ Button13,
12643
12832
  {
12644
12833
  variant: "ghost",
12645
12834
  className: "size-6 p-1 text-muted-foreground",
@@ -13109,7 +13298,7 @@ var BlockCommentsContent = ({
13109
13298
  }
13110
13299
  ),
13111
13300
  totalCount > 0 && /* @__PURE__ */ jsx("div", { className: "relative left-0 size-0 select-none", children: /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
13112
- Button12,
13301
+ Button13,
13113
13302
  {
13114
13303
  className: "mt-1 ml-1 flex h-6 gap-1 px-1.5 py-0 text-muted-foreground/80 hover:text-muted-foreground/80 data-[active=true]:bg-muted",
13115
13304
  contentEditable: false,
@@ -15025,7 +15214,7 @@ function BlockActionButton({
15025
15214
  const editor = useEditorRef();
15026
15215
  const element = useElement();
15027
15216
  return /* @__PURE__ */ jsx(
15028
- Button12,
15217
+ Button13,
15029
15218
  {
15030
15219
  className: cn(
15031
15220
  defaultStyles && "absolute top-1 right-1 opacity-0 transition-opacity group-hover:opacity-100",
@@ -15364,7 +15553,7 @@ function EmojiPickerSearchAndClear({
15364
15553
  }
15365
15554
  ),
15366
15555
  searchValue && /* @__PURE__ */ jsx(
15367
- Button12,
15556
+ Button13,
15368
15557
  {
15369
15558
  "aria-label": "Clear",
15370
15559
  className: cn(
@@ -15453,7 +15642,7 @@ function EmojiPickerNavigation({
15453
15642
  id: "emoji-nav",
15454
15643
  children: /* @__PURE__ */ jsxs("div", { className: "relative flex items-center", children: [
15455
15644
  emojiLibrary.getGrid().sections().map(({ id }) => /* @__PURE__ */ jsx(
15456
- Button12,
15645
+ Button13,
15457
15646
  {
15458
15647
  "aria-label": i18n.categories[id],
15459
15648
  className: cn(
@@ -15615,7 +15804,7 @@ function CalloutElement(props) {
15615
15804
  {
15616
15805
  ...emojiToolbarDropdownProps,
15617
15806
  control: /* @__PURE__ */ jsx(
15618
- Button12,
15807
+ Button13,
15619
15808
  {
15620
15809
  className: "size-6 select-none p-1 text-[18px] hover:bg-muted-foreground/15",
15621
15810
  contentEditable: false,
@@ -15854,7 +16043,7 @@ function CodeBlockElement(props) {
15854
16043
  contentEditable: false,
15855
16044
  children: [
15856
16045
  /* @__PURE__ */ jsxs(
15857
- Button12,
16046
+ Button13,
15858
16047
  {
15859
16048
  className: "relative top-0 right-0 w-auto",
15860
16049
  onClick: () => {
@@ -15899,7 +16088,7 @@ function CodeBlockCombobox({ className }) {
15899
16088
  if (readOnly) return null;
15900
16089
  return /* @__PURE__ */ jsxs(Popover, { onOpenChange: setOpen, open, children: [
15901
16090
  /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
15902
- Button12,
16091
+ Button13,
15903
16092
  {
15904
16093
  "aria-expanded": open,
15905
16094
  className: cn(
@@ -16260,7 +16449,7 @@ function Draggable(props) {
16260
16449
  ),
16261
16450
  children: [
16262
16451
  /* @__PURE__ */ jsx(
16263
- Button12,
16452
+ Button13,
16264
16453
  {
16265
16454
  className: "absolute right-0 h-6 w-6 p-0",
16266
16455
  "data-plate-prevent-deselect": true,
@@ -16447,7 +16636,7 @@ var DraggableInsertHandle = () => {
16447
16636
  const editor = useEditorRef();
16448
16637
  const element = useElement();
16449
16638
  return /* @__PURE__ */ jsx(
16450
- Button12,
16639
+ Button13,
16451
16640
  {
16452
16641
  className: "size-6 shrink-0 p-1",
16453
16642
  onClick: (event) => {
@@ -17678,7 +17867,7 @@ function EquationPopoverContent({
17678
17867
  ...props
17679
17868
  }
17680
17869
  ),
17681
- /* @__PURE__ */ jsxs(Button12, { className: "px-3", onClick: onClose, variant: "brand", children: [
17870
+ /* @__PURE__ */ jsxs(Button13, { className: "px-3", onClick: onClose, variant: "brand", children: [
17682
17871
  "Done ",
17683
17872
  /* @__PURE__ */ jsx(CornerDownLeftIcon, { className: "size-3.5" })
17684
17873
  ] })
@@ -18556,7 +18745,7 @@ function MediaPlaceholderPopover({ children }) {
18556
18745
  /* @__PURE__ */ jsx(TabsTrigger, { value: "password", children: "Embed link" })
18557
18746
  ] }),
18558
18747
  /* @__PURE__ */ jsxs(TabsContent, { className: "w-[300px] px-3 py-2", value: "account", children: [
18559
- /* @__PURE__ */ jsx(Button12, { className: "w-full", onClick: openFilePicker, variant: "brand", children: currentMedia.buttonText }),
18748
+ /* @__PURE__ */ jsx(Button13, { className: "w-full", onClick: openFilePicker, variant: "brand", children: currentMedia.buttonText }),
18560
18749
  /* @__PURE__ */ jsx("div", { className: "mt-3 text-muted-foreground text-xs", children: "The maximum size per file is 5MB" })
18561
18750
  ] }),
18562
18751
  /* @__PURE__ */ jsxs(
@@ -18574,7 +18763,7 @@ function MediaPlaceholderPopover({ children }) {
18574
18763
  }
18575
18764
  ),
18576
18765
  /* @__PURE__ */ jsx(
18577
- Button12,
18766
+ Button13,
18578
18767
  {
18579
18768
  className: "mt-2 w-full max-w-[300px]",
18580
18769
  onClick: () => onEmbed(embedValue),
@@ -18694,12 +18883,12 @@ function ImagePreview() {
18694
18883
  onClick: (e) => e.stopPropagation(),
18695
18884
  children: [
18696
18885
  !prevDisabled && !nextDisabled && /* @__PURE__ */ jsxs("div", { className: "flex rounded-sm bg-black/70", children: [
18697
- /* @__PURE__ */ jsx(Button12, { ...prevProps, disabled: prevDisabled, children: /* @__PURE__ */ jsx(ArrowLeftIcon, { className: "size-5" }) }),
18698
- /* @__PURE__ */ jsx(Button12, { ...nextProps, disabled: nextDisabled, children: /* @__PURE__ */ jsx(ArrowRightIcon, { className: "size-5" }) })
18886
+ /* @__PURE__ */ jsx(Button13, { ...prevProps, disabled: prevDisabled, children: /* @__PURE__ */ jsx(ArrowLeftIcon, { className: "size-5" }) }),
18887
+ /* @__PURE__ */ jsx(Button13, { ...nextProps, disabled: nextDisabled, children: /* @__PURE__ */ jsx(ArrowRightIcon, { className: "size-5" }) })
18699
18888
  ] }),
18700
18889
  currentPreview && /* @__PURE__ */ jsxs("div", { className: "flex rounded-sm bg-black/70", children: [
18701
18890
  /* @__PURE__ */ jsx(
18702
- Button12,
18891
+ Button13,
18703
18892
  {
18704
18893
  ...zommOutProps,
18705
18894
  disabled: zoomOutDisabled,
@@ -18712,7 +18901,7 @@ function ImagePreview() {
18712
18901
  /* @__PURE__ */ jsx("div", { children: "%" })
18713
18902
  ] }),
18714
18903
  /* @__PURE__ */ jsx(
18715
- Button12,
18904
+ Button13,
18716
18905
  {
18717
18906
  ...zoomInProps,
18718
18907
  disabled: zoomInDisabled,
@@ -18721,7 +18910,7 @@ function ImagePreview() {
18721
18910
  }
18722
18911
  ),
18723
18912
  /* @__PURE__ */ jsx(
18724
- Button12,
18913
+ Button13,
18725
18914
  {
18726
18915
  onClick: () => {
18727
18916
  void downloadFile(currentPreview.url, currentPreview.id);
@@ -18730,7 +18919,7 @@ function ImagePreview() {
18730
18919
  children: /* @__PURE__ */ jsx(CircleArrowDown, { className: "size-4" })
18731
18920
  }
18732
18921
  ),
18733
- /* @__PURE__ */ jsx(Button12, { ...closeProps, tooltip: "Close", children: /* @__PURE__ */ jsx(Minimize2, { className: "size-4" }) })
18922
+ /* @__PURE__ */ jsx(Button13, { ...closeProps, tooltip: "Close", children: /* @__PURE__ */ jsx(Minimize2, { className: "size-4" }) })
18734
18923
  ] })
18735
18924
  ]
18736
18925
  }
@@ -19370,7 +19559,7 @@ var TableElement = withHOC(
19370
19559
  "group-has-[tr:last-child:hover]/table:opacity-100 max-sm:group-has-[tr[data-selected]:last-child]/table:opacity-100"
19371
19560
  ),
19372
19561
  children: /* @__PURE__ */ jsx(
19373
- Button12,
19562
+ Button13,
19374
19563
  {
19375
19564
  className: "flex h-4 w-full grow items-center justify-center bg-muted",
19376
19565
  onClick: () => tf.insert.tableRow({ at: editor.api.findPath(element) }),
@@ -19392,7 +19581,7 @@ var TableElement = withHOC(
19392
19581
  "group-has-[td:last-child:hover,th:last-child:hover]/table:opacity-100 max-sm:group-has-[td[data-selected]:last-child,th[data-selected]:last-child]/table:opacity-100"
19393
19582
  ),
19394
19583
  children: /* @__PURE__ */ jsx(
19395
- Button12,
19584
+ Button13,
19396
19585
  {
19397
19586
  className: "flex h-full w-4 grow items-center justify-center bg-muted",
19398
19587
  onClick: () => tf.insert.tableColumn({
@@ -19416,7 +19605,7 @@ var TableElement = withHOC(
19416
19605
  "group-has-[td:last-child:hover,th:last-child:hover]/table:group-has-[tr:last-child:hover]/table:opacity-100 max-sm:group-has-[td[data-selected]:last-child,th[data-selected]:last-child]/table:group-has-[tr[data-selected]:last-child]/table:opacity-100"
19417
19606
  ),
19418
19607
  children: /* @__PURE__ */ jsx(
19419
- Button12,
19608
+ Button13,
19420
19609
  {
19421
19610
  className: "flex size-4 items-center justify-center rounded-full bg-muted",
19422
19611
  onClick: () => {
@@ -19622,7 +19811,7 @@ function TocElement(props) {
19622
19811
  const { headingList } = state;
19623
19812
  return /* @__PURE__ */ jsxs(PlateElement, { ...props, className: "my-1", children: [
19624
19813
  /* @__PURE__ */ jsx("div", { contentEditable: false, children: headingList.length > 0 ? headingList.map((item) => /* @__PURE__ */ jsx(
19625
- Button12,
19814
+ Button13,
19626
19815
  {
19627
19816
  "aria-current": true,
19628
19817
  className: headingItemVariants({ depth: item.depth }),
@@ -20724,7 +20913,7 @@ function TocElementStatic(props) {
20724
20913
  const headingList = getHeadingList(editor);
20725
20914
  return /* @__PURE__ */ jsxs(SlateElement, { ...props, className: "mb-1 p-0", children: [
20726
20915
  /* @__PURE__ */ jsx("div", { children: headingList.length > 0 ? headingList.map((item) => /* @__PURE__ */ jsx(
20727
- Button12,
20916
+ Button13,
20728
20917
  {
20729
20918
  className: headingItemVariants2({ depth: item.depth }),
20730
20919
  variant: "ghost",
@@ -24969,6 +25158,7 @@ var DocyAssistant = ({
24969
25158
  } = useChat$1({
24970
25159
  id: `docy-assistant:${activeAgentId}`,
24971
25160
  transport,
25161
+ experimental_throttle: 80,
24972
25162
  sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls,
24973
25163
  onFinish: (message, options3) => {
24974
25164
  const { usage, finishReason } = options3 || {};