@tomny-dev/uzi 0.14.0-pr.111.381.1.1f0abc3 → 0.14.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.cjs +14 -18
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -16
- package/dist/index57.js +10 -21
- package/dist/index57.js.map +1 -1
- package/dist/index58.cjs +11 -30
- package/dist/index58.cjs.map +1 -1
- package/dist/index58.js +14 -101
- package/dist/index58.js.map +1 -1
- package/dist/index59.cjs +13 -104
- package/dist/index59.cjs.map +1 -1
- package/dist/index59.js +11 -10
- package/dist/index59.js.map +1 -1
- package/dist/index60.cjs +13 -11
- package/dist/index60.cjs.map +1 -1
- package/dist/index60.js +16 -13
- package/dist/index60.js.map +1 -1
- package/dist/index61.cjs +16 -13
- package/dist/index61.cjs.map +1 -1
- package/dist/index61.js +8 -10
- package/dist/index61.js.map +1 -1
- package/dist/index62.cjs +10 -11
- package/dist/index62.cjs.map +1 -1
- package/dist/index62.js +87 -15
- package/dist/index62.js.map +1 -1
- package/dist/index63.cjs +89 -15
- package/dist/index63.cjs.map +1 -1
- package/dist/index63.js +23 -9
- package/dist/index63.js.map +1 -1
- package/dist/index64.cjs +33 -12
- package/dist/index64.cjs.map +1 -1
- package/dist/index64.js +43 -89
- package/dist/index64.js.map +1 -1
- package/dist/index65.cjs +42 -88
- package/dist/index65.cjs.map +1 -1
- package/dist/index65.js +15 -23
- package/dist/index65.js.map +1 -1
- package/dist/index66.cjs +21 -33
- package/dist/index66.cjs.map +1 -1
- package/dist/index66.js +51 -44
- package/dist/index66.js.map +1 -1
- package/dist/index67.cjs +52 -43
- package/dist/index67.cjs.map +1 -1
- package/dist/index67.js +14 -14
- package/dist/index67.js.map +1 -1
- package/dist/index68.cjs +19 -19
- package/dist/index68.cjs.map +1 -1
- package/dist/index68.js +290 -49
- package/dist/index68.js.map +1 -1
- package/dist/index69.cjs +290 -51
- package/dist/index69.cjs.map +1 -1
- package/dist/index69.js +57 -15
- package/dist/index69.js.map +1 -1
- package/dist/index70.cjs +83 -20
- package/dist/index70.cjs.map +1 -1
- package/dist/index70.js +418 -276
- package/dist/index70.js.map +1 -1
- package/dist/index71.cjs +419 -275
- package/dist/index71.cjs.map +1 -1
- package/dist/index71.js +58 -56
- package/dist/index71.js.map +1 -1
- package/dist/index72.cjs +85 -82
- package/dist/index72.cjs.map +1 -1
- package/dist/index72.js +226 -420
- package/dist/index72.js.map +1 -1
- package/dist/index73.cjs +225 -421
- package/dist/index73.cjs.map +1 -1
- package/dist/index73.js +42 -58
- package/dist/index73.js.map +1 -1
- package/dist/index74.cjs +61 -85
- package/dist/index74.cjs.map +1 -1
- package/dist/index74.js +76 -236
- package/dist/index74.js.map +1 -1
- package/dist/index75.cjs +75 -235
- package/dist/index75.cjs.map +1 -1
- package/dist/index75.js +20 -42
- package/dist/index75.js.map +1 -1
- package/dist/index76.cjs +27 -60
- package/dist/index76.cjs.map +1 -1
- package/dist/index76.js +88 -73
- package/dist/index76.js.map +1 -1
- package/dist/index77.cjs +90 -73
- package/dist/index77.cjs.map +1 -1
- package/dist/index77.js +15 -17
- package/dist/index77.js.map +1 -1
- package/dist/index78.cjs +19 -22
- package/dist/index78.cjs.map +1 -1
- package/dist/index78.js +143 -85
- package/dist/index78.js.map +1 -1
- package/dist/index79.cjs +143 -87
- package/dist/index79.cjs.map +1 -1
- package/dist/index79.js +91 -19
- package/dist/index79.js.map +1 -1
- package/dist/index80.cjs +135 -27
- package/dist/index80.cjs.map +1 -1
- package/dist/index80.js +673 -140
- package/dist/index80.js.map +1 -1
- package/dist/index81.cjs +673 -140
- package/dist/index81.cjs.map +1 -1
- package/dist/index81.js +31 -91
- package/dist/index81.js.map +1 -1
- package/dist/index82.cjs +45 -135
- package/dist/index82.cjs.map +1 -1
- package/dist/index82.js +206 -667
- package/dist/index82.js.map +1 -1
- package/dist/index83.cjs +204 -667
- package/dist/index83.cjs.map +1 -1
- package/dist/index83.js +15 -31
- package/dist/index83.js.map +1 -1
- package/dist/index84.cjs +21 -45
- package/dist/index84.cjs.map +1 -1
- package/dist/index84.js +29 -224
- package/dist/index84.js.map +1 -1
- package/dist/index85.cjs +30 -224
- package/dist/index85.cjs.map +1 -1
- package/dist/style.css +0 -53
- package/package.json +1 -1
- package/dist/components/filter-workspace/FilterWorkspace.d.ts +0 -40
- package/dist/components/filter-workspace/FilterWorkspace.d.ts.map +0 -1
- package/dist/components/filter-workspace/FilterWorkspace.test.d.ts +0 -2
- package/dist/components/filter-workspace/FilterWorkspace.test.d.ts.map +0 -1
- package/dist/index85.js +0 -19
- package/dist/index85.js.map +0 -1
- package/dist/index86.cjs +0 -25
- package/dist/index86.cjs.map +0 -1
- package/dist/index86.js +0 -36
- package/dist/index86.js.map +0 -1
- package/dist/index87.cjs +0 -37
- package/dist/index87.cjs.map +0 -1
package/dist/index82.js
CHANGED
|
@@ -1,692 +1,231 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
3
|
-
import { useEffect,
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return /* @__PURE__ */ jsx(AIChatMessageBubble, {
|
|
34
|
-
role: message.role,
|
|
35
|
-
children: message.parts.map((part, index) => /* @__PURE__ */ jsx("div", { children: isRecord(part) ? renderMessagePart(part, index) : null }, isRecord(part) && typeof part.id === "string" ? part.id : index))
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
function DefaultReasoningRenderer({ children, title = "Reasoning" }) {
|
|
39
|
-
return /* @__PURE__ */ jsxs("details", {
|
|
40
|
-
className: ai_chat_module_default.reasoning,
|
|
41
|
-
children: [/* @__PURE__ */ jsx("summary", {
|
|
42
|
-
className: ai_chat_module_default.reasoningSummary,
|
|
43
|
-
children: title
|
|
44
|
-
}), /* @__PURE__ */ jsx("p", {
|
|
45
|
-
className: ai_chat_module_default.reasoningText,
|
|
46
|
-
children
|
|
47
|
-
})]
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
function DefaultSourceRenderer({ sources, renderSource }) {
|
|
51
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
52
|
-
className: ai_chat_module_default.sources,
|
|
53
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
54
|
-
className: ai_chat_module_default.sourcesLabel,
|
|
55
|
-
children: "Sources"
|
|
56
|
-
}), /* @__PURE__ */ jsx("ul", { children: sources.map((source, index) => /* @__PURE__ */ jsx("li", { children: renderSource(source, index) }, source.id)) })]
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
function DefaultDataRenderer({ data, renderDataItem }) {
|
|
60
|
-
return /* @__PURE__ */ jsx("div", {
|
|
61
|
-
className: ai_chat_module_default.data,
|
|
62
|
-
children: data.map((item, index) => /* @__PURE__ */ jsx("div", { children: renderDataItem(item, index) }, index))
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
function DefaultErrorRenderer({ error, onRetry, onClear }) {
|
|
66
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
67
|
-
className: ai_chat_module_default.error,
|
|
68
|
-
role: "alert",
|
|
69
|
-
children: [/* @__PURE__ */ jsx("p", { children: error.message }), /* @__PURE__ */ jsxs("div", {
|
|
70
|
-
className: ai_chat_module_default.errorActions,
|
|
71
|
-
children: [/* @__PURE__ */ jsx("button", {
|
|
72
|
-
type: "button",
|
|
73
|
-
onClick: onRetry,
|
|
74
|
-
children: "Retry response"
|
|
75
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
76
|
-
type: "button",
|
|
77
|
-
onClick: onClear,
|
|
78
|
-
children: "Start new chat"
|
|
79
|
-
})]
|
|
80
|
-
})]
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
function renderPart(part, index, components, onToolApproval, pendingApprovalId) {
|
|
84
|
-
const type = asString(part.type) ?? "";
|
|
85
|
-
if (type === "step-start") return null;
|
|
86
|
-
if (type === "text") return /* @__PURE__ */ jsx("span", {
|
|
87
|
-
className: ai_chat_module_default.textPart,
|
|
88
|
-
children: asString(part.text) ?? ""
|
|
89
|
-
});
|
|
90
|
-
if (type === "reasoning") return /* @__PURE__ */ jsx(components?.ReasoningRenderer ?? DefaultReasoningRenderer, { children: asString(part.text) ?? "" });
|
|
91
|
-
if (type === "source-url" || type === "source-document") return /* @__PURE__ */ jsx(components?.SourceRenderer ?? DefaultSourceRenderer, {
|
|
92
|
-
sources: [{
|
|
93
|
-
id: asString(part.sourceId) ?? asString(part.id) ?? `source-${index}`,
|
|
94
|
-
title: asString(part.title) ?? asString(part.filename),
|
|
95
|
-
url: safeHttpUrl(part.url)
|
|
96
|
-
}],
|
|
97
|
-
renderSource: (item) => item.url ? /* @__PURE__ */ jsx("a", {
|
|
98
|
-
href: item.url,
|
|
99
|
-
target: "_blank",
|
|
100
|
-
rel: "noopener noreferrer",
|
|
101
|
-
children: item.title ?? item.url
|
|
102
|
-
}) : /* @__PURE__ */ jsx("span", { children: item.title ?? item.id })
|
|
103
|
-
});
|
|
104
|
-
if (type.startsWith("data-")) return /* @__PURE__ */ jsx(components?.DataRenderer ?? DefaultDataRenderer, {
|
|
105
|
-
data: [part],
|
|
106
|
-
renderDataItem: (item) => /* @__PURE__ */ jsx("pre", {
|
|
107
|
-
className: ai_chat_module_default.structuredData,
|
|
108
|
-
children: JSON.stringify(item.data ?? item, null, 2)
|
|
109
|
-
})
|
|
110
|
-
});
|
|
111
|
-
if (type.startsWith("tool-") || type === "dynamic-tool") {
|
|
112
|
-
const name = asString(part.toolName) ?? type.replace(/^tool-/, "");
|
|
113
|
-
const approval = isRecord(part.approval) ? asString(part.approval.id) : void 0;
|
|
114
|
-
const approvalId = part.state === "approval-requested" ? approval : void 0;
|
|
115
|
-
const controlsDisabled = pendingApprovalId !== null && pendingApprovalId !== void 0;
|
|
116
|
-
const ToolRenderer = components?.ToolRenderer;
|
|
117
|
-
const props = {
|
|
118
|
-
part,
|
|
119
|
-
name,
|
|
120
|
-
approvalId,
|
|
121
|
-
approvalPending: controlsDisabled,
|
|
122
|
-
...approvalId && onToolApproval ? {
|
|
123
|
-
onApprove: () => {
|
|
124
|
-
if (!controlsDisabled) onToolApproval(approvalId, true);
|
|
125
|
-
},
|
|
126
|
-
onDeny: () => {
|
|
127
|
-
if (!controlsDisabled) onToolApproval(approvalId, false);
|
|
128
|
-
}
|
|
129
|
-
} : {}
|
|
130
|
-
};
|
|
131
|
-
if (ToolRenderer) return /* @__PURE__ */ jsx(ToolRenderer, { ...props });
|
|
132
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
133
|
-
className: ai_chat_module_default.toolPart,
|
|
134
|
-
children: [/* @__PURE__ */ jsxs("details", { children: [/* @__PURE__ */ jsx("summary", { children: name }), /* @__PURE__ */ jsx("pre", {
|
|
135
|
-
className: ai_chat_module_default.structuredData,
|
|
136
|
-
children: JSON.stringify(part.output ?? part.input ?? part, null, 2)
|
|
137
|
-
})] }), approvalId && /* @__PURE__ */ jsx("div", {
|
|
138
|
-
className: ai_chat_module_default.approvalActions,
|
|
139
|
-
"aria-label": `Approval required for ${name}`,
|
|
140
|
-
children: props.onApprove && props.onDeny ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("button", {
|
|
141
|
-
type: "button",
|
|
142
|
-
disabled: controlsDisabled,
|
|
143
|
-
onClick: props.onApprove,
|
|
144
|
-
children: "Approve"
|
|
145
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
146
|
-
type: "button",
|
|
147
|
-
disabled: controlsDisabled,
|
|
148
|
-
onClick: props.onDeny,
|
|
149
|
-
children: "Deny"
|
|
150
|
-
})] }) : /* @__PURE__ */ jsx("span", { children: "Approval required in application" })
|
|
151
|
-
})]
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
if (type === "file" || type === "image") {
|
|
155
|
-
const url = safeHttpUrl(part.url);
|
|
156
|
-
return url ? /* @__PURE__ */ jsx("a", {
|
|
157
|
-
href: url,
|
|
158
|
-
target: "_blank",
|
|
159
|
-
rel: "noopener noreferrer",
|
|
160
|
-
children: asString(part.filename) ?? "View attachment"
|
|
161
|
-
}) : /* @__PURE__ */ jsx("span", { children: "Attachment" });
|
|
162
|
-
}
|
|
163
|
-
return /* @__PURE__ */ jsx("pre", {
|
|
164
|
-
className: ai_chat_module_default.structuredData,
|
|
165
|
-
children: JSON.stringify(part, null, 2)
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
var DEFAULT_MESSAGE_LIMIT = 8;
|
|
169
|
-
function AIChat({ api, scope, scopeLabel, fetch: requestFetch, headers, credentials, prepareSendMessagesRequest, sessionKey, messageLimit = DEFAULT_MESSAGE_LIMIT, inputPlaceholder = "Ask a question...", inputAriaLabel = "Message", inputMaxLength = 2e3, components, toolbarActions, attachments, history, sendAutomaticallyWhen, onClose, className, style }) {
|
|
170
|
-
const [session, setSession] = useState(0);
|
|
171
|
-
const transport = useMemo(() => new AssistantChatTransport({
|
|
172
|
-
api,
|
|
173
|
-
...scope ? { body: { scope } } : {},
|
|
174
|
-
...requestFetch ? { fetch: requestFetch } : {},
|
|
175
|
-
...headers ? { headers } : {},
|
|
176
|
-
...credentials ? { credentials } : {},
|
|
177
|
-
...prepareSendMessagesRequest ? { prepareSendMessagesRequest } : {}
|
|
178
|
-
}), [
|
|
179
|
-
api,
|
|
180
|
-
scope,
|
|
181
|
-
requestFetch,
|
|
182
|
-
headers,
|
|
183
|
-
credentials,
|
|
184
|
-
prepareSendMessagesRequest
|
|
185
|
-
]);
|
|
186
|
-
const config = useMemo(() => AuiConfig({ threads: AISDKChat({
|
|
187
|
-
transport,
|
|
188
|
-
...sendAutomaticallyWhen ? { sendAutomaticallyWhen } : {}
|
|
189
|
-
}) }), [
|
|
190
|
-
transport,
|
|
191
|
-
session,
|
|
192
|
-
sendAutomaticallyWhen
|
|
193
|
-
]);
|
|
194
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
195
|
-
className: [ai_chat_module_default.container, className].filter(Boolean).join(" "),
|
|
196
|
-
style,
|
|
197
|
-
children: [
|
|
198
|
-
scopeLabel && /* @__PURE__ */ jsxs("div", {
|
|
199
|
-
className: ai_chat_module_default.scope,
|
|
200
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
201
|
-
className: ai_chat_module_default.scopeLabel,
|
|
202
|
-
children: "Current scope"
|
|
203
|
-
}), /* @__PURE__ */ jsx("strong", { children: scopeLabel })]
|
|
204
|
-
}),
|
|
205
|
-
onClose && /* @__PURE__ */ jsx("button", {
|
|
206
|
-
className: ai_chat_module_default.closeBtn,
|
|
207
|
-
type: "button",
|
|
208
|
-
onClick: onClose,
|
|
209
|
-
"aria-label": "Close chat",
|
|
210
|
-
children: "✕"
|
|
211
|
-
}),
|
|
212
|
-
/* @__PURE__ */ jsx(AuiProvider, {
|
|
213
|
-
config,
|
|
214
|
-
children: /* @__PURE__ */ jsx(ThreadPrimitive.Root, {
|
|
215
|
-
className: ai_chat_module_default.thread,
|
|
216
|
-
children: /* @__PURE__ */ jsx(ChatViewport, {
|
|
217
|
-
messageLimit: Number.isFinite(messageLimit) ? Math.max(1, Math.floor(messageLimit)) : DEFAULT_MESSAGE_LIMIT,
|
|
218
|
-
inputPlaceholder,
|
|
219
|
-
inputAriaLabel,
|
|
220
|
-
inputMaxLength,
|
|
221
|
-
components,
|
|
222
|
-
toolbarActions,
|
|
223
|
-
attachmentOptions: attachments,
|
|
224
|
-
history,
|
|
225
|
-
onNewChat: () => setSession((previous) => previous + 1)
|
|
226
|
-
})
|
|
227
|
-
})
|
|
228
|
-
}, JSON.stringify([
|
|
229
|
-
api,
|
|
230
|
-
scope,
|
|
231
|
-
sessionKey,
|
|
232
|
-
session
|
|
233
|
-
]))
|
|
234
|
-
]
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
function ChatViewport({ messageLimit, inputPlaceholder, inputAriaLabel, inputMaxLength, components, toolbarActions, attachmentOptions, history, onNewChat }) {
|
|
238
|
-
const chat = useAISDKChat();
|
|
239
|
-
const [draft, setDraft] = useState("");
|
|
240
|
-
const [selectedFiles, setSelectedFiles] = useState([]);
|
|
241
|
-
const [attachmentError, setAttachmentError] = useState(null);
|
|
242
|
-
const [attachmentPreviews, setAttachmentPreviews] = useState([]);
|
|
243
|
-
const [hydrated, setHydrated] = useState(!history);
|
|
244
|
-
const expectedRestoredId = useRef(null);
|
|
245
|
-
const saveQueue = useRef(Promise.resolve());
|
|
246
|
-
const [approvalBusy, setApprovalBusy] = useState(false);
|
|
247
|
-
useEffect(() => {
|
|
248
|
-
const urls = selectedFiles.map((file) => file.type.startsWith("image/") && typeof URL.createObjectURL === "function" ? URL.createObjectURL(file) : "");
|
|
249
|
-
setAttachmentPreviews(urls);
|
|
250
|
-
return () => urls.forEach((url) => {
|
|
251
|
-
if (url && typeof URL.revokeObjectURL === "function") URL.revokeObjectURL(url);
|
|
252
|
-
});
|
|
253
|
-
}, [selectedFiles]);
|
|
254
|
-
const messages = chat?.messages ?? [];
|
|
255
|
-
const status = chat?.status ?? "ready";
|
|
256
|
-
const isBusy = status === "submitted" || status === "streaming";
|
|
257
|
-
const historyFull = messages.filter((message) => message.role === "user").length >= messageLimit;
|
|
258
|
-
const reportHistoryError = (operation, error) => {
|
|
259
|
-
if (history?.onError) history.onError(operation, error);
|
|
260
|
-
else console.warn(`[Uzi AIChat] History ${operation} failed`);
|
|
2
|
+
import ai_chat_dock_module_default from "./index81.js";
|
|
3
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/ai-chat/AIChatDock.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Shared chat navigation chrome. Children remain mounted while closed to retain
|
|
8
|
+
* the consumer's active AI SDK conversation, pending approvals and attachments.
|
|
9
|
+
* The dock never creates a second chat runtime or reads application messages.
|
|
10
|
+
* Desktop is deliberately non-modal: Tab can move back into the page.
|
|
11
|
+
* On mobile the full-screen modal sheet traps sequential keyboard focus.
|
|
12
|
+
*/
|
|
13
|
+
function AIChatDock({ title, description, launcherLabel, showLauncher = true, panelId: controlledPanelId, externalLauncherId, children, open, defaultOpen = false, onOpenChange, expanded, defaultExpanded = false, onExpandedChange, className }) {
|
|
14
|
+
const autoId = useId();
|
|
15
|
+
const panelId = controlledPanelId ?? `uzi-ai-dock-${autoId}`;
|
|
16
|
+
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
17
|
+
const [internalExpanded, setInternalExpanded] = useState(defaultExpanded);
|
|
18
|
+
const isOpen = open ?? internalOpen;
|
|
19
|
+
const isExpanded = expanded ?? internalExpanded;
|
|
20
|
+
const [mobile, setMobile] = useState(false);
|
|
21
|
+
const launcherRef = useRef(null);
|
|
22
|
+
const panelRef = useRef(null);
|
|
23
|
+
const openerRef = useRef(null);
|
|
24
|
+
const wasOpen = useRef(false);
|
|
25
|
+
const changeOpen = (next) => {
|
|
26
|
+
if (open === void 0) setInternalOpen(next);
|
|
27
|
+
onOpenChange?.(next);
|
|
28
|
+
};
|
|
29
|
+
const changeExpanded = (next) => {
|
|
30
|
+
if (expanded === void 0) setInternalExpanded(next);
|
|
31
|
+
onExpandedChange?.(next);
|
|
32
|
+
if (next && !isOpen) changeOpen(true);
|
|
261
33
|
};
|
|
262
34
|
useEffect(() => {
|
|
263
|
-
if (
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
35
|
+
if (typeof window.matchMedia !== "function") return;
|
|
36
|
+
const media = window.matchMedia("(max-width: 640px)");
|
|
37
|
+
const update = () => setMobile(media.matches);
|
|
38
|
+
update();
|
|
39
|
+
media.addEventListener("change", update);
|
|
40
|
+
return () => media.removeEventListener("change", update);
|
|
41
|
+
}, []);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (isOpen && !wasOpen.current) {
|
|
44
|
+
openerRef.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
45
|
+
panelRef.current?.focus();
|
|
46
|
+
} else if (!isOpen && wasOpen.current) {
|
|
47
|
+
const previous = openerRef.current;
|
|
48
|
+
if (previous?.isConnected && previous !== panelRef.current) previous.focus();
|
|
49
|
+
else if (externalLauncherId) document.getElementById(externalLauncherId)?.focus();
|
|
50
|
+
else launcherRef.current?.focus();
|
|
51
|
+
}
|
|
52
|
+
wasOpen.current = isOpen;
|
|
53
|
+
}, [isOpen, externalLauncherId]);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (!isOpen || !mobile) return;
|
|
56
|
+
const previous = document.body.style.overflow;
|
|
57
|
+
document.body.style.overflow = "hidden";
|
|
279
58
|
return () => {
|
|
280
|
-
|
|
59
|
+
document.body.style.overflow = previous;
|
|
281
60
|
};
|
|
282
|
-
}, [
|
|
61
|
+
}, [isOpen, mobile]);
|
|
283
62
|
useEffect(() => {
|
|
284
|
-
if (!
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
...isRecord(message.metadata) ? { metadata: message.metadata } : {}
|
|
290
|
-
}));
|
|
291
|
-
if (expectedRestoredId.current) {
|
|
292
|
-
if (!snapshot.some((message) => message.id === expectedRestoredId.current)) return;
|
|
293
|
-
expectedRestoredId.current = null;
|
|
294
|
-
}
|
|
295
|
-
saveQueue.current = saveQueue.current.then(() => history.save(snapshot), () => history.save(snapshot)).then(() => {}, (error) => {
|
|
296
|
-
reportHistoryError("save", error);
|
|
297
|
-
});
|
|
298
|
-
}, [
|
|
299
|
-
history,
|
|
300
|
-
hydrated,
|
|
301
|
-
isBusy,
|
|
302
|
-
messages
|
|
303
|
-
]);
|
|
304
|
-
const handleSelectedFiles = (files) => {
|
|
305
|
-
if (!attachmentOptions) return;
|
|
306
|
-
const selected = Array.from(files);
|
|
307
|
-
if (selected.length + selectedFiles.length > (attachmentOptions.maxFiles ?? 3)) {
|
|
308
|
-
setAttachmentError("Too many attachments.");
|
|
309
|
-
return;
|
|
310
|
-
}
|
|
311
|
-
if (selected.some((file) => file.size > (attachmentOptions.maxBytesPerFile ?? 5 * 1024 * 1024))) {
|
|
312
|
-
setAttachmentError("An attachment exceeds the size limit.");
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
const allowedTypes = attachmentOptions.accept.split(",").map((item) => item.trim());
|
|
316
|
-
if (selected.some((file) => !allowedTypes.some((allow) => allow === file.type || allow.endsWith("/*") && file.type.startsWith(allow.slice(0, -1))))) {
|
|
317
|
-
setAttachmentError("Unsupported attachment type.");
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
320
|
-
setAttachmentError(null);
|
|
321
|
-
setSelectedFiles((existing) => [...existing, ...selected]);
|
|
322
|
-
};
|
|
323
|
-
const handleSubmit = () => {
|
|
324
|
-
const text = draft.trim();
|
|
325
|
-
if (!chat || !text && selectedFiles.length === 0 || isBusy || historyFull || chat.error || !hydrated || approvalBusy) return;
|
|
326
|
-
const files = selectedFiles.length ? new DataTransfer() : null;
|
|
327
|
-
selectedFiles.forEach((file) => files?.items.add(file));
|
|
328
|
-
const previousDraft = draft;
|
|
329
|
-
const previousFiles = selectedFiles;
|
|
330
|
-
setDraft("");
|
|
331
|
-
setSelectedFiles([]);
|
|
332
|
-
setAttachmentError(null);
|
|
333
|
-
Promise.resolve(chat.sendMessage({
|
|
334
|
-
text,
|
|
335
|
-
...files ? { files: files.files } : {}
|
|
336
|
-
})).catch(() => {
|
|
337
|
-
setDraft((current) => current || previousDraft);
|
|
338
|
-
setSelectedFiles((current) => current.length ? current : previousFiles);
|
|
339
|
-
});
|
|
340
|
-
};
|
|
341
|
-
const handleNewChat = () => {
|
|
342
|
-
(async () => {
|
|
343
|
-
await chat?.stop();
|
|
344
|
-
if (history) try {
|
|
345
|
-
await saveQueue.current;
|
|
346
|
-
await history.clear();
|
|
347
|
-
} catch (error) {
|
|
348
|
-
reportHistoryError("clear", error);
|
|
63
|
+
if (!isOpen) return;
|
|
64
|
+
const keydown = (event) => {
|
|
65
|
+
if (event.key === "Escape") {
|
|
66
|
+
event.preventDefault();
|
|
67
|
+
changeOpen(false);
|
|
349
68
|
return;
|
|
350
69
|
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
chat.regenerate();
|
|
358
|
-
};
|
|
359
|
-
return /* @__PURE__ */ jsx(AIChatView, {
|
|
360
|
-
messages: messages.filter((message) => message.role === "user" || message.role === "assistant").map((message) => ({
|
|
361
|
-
id: message.id,
|
|
362
|
-
role: message.role,
|
|
363
|
-
parts: message.parts,
|
|
364
|
-
...isRecord(message.metadata) ? { metadata: message.metadata } : {}
|
|
365
|
-
})),
|
|
366
|
-
status,
|
|
367
|
-
error: chat?.error,
|
|
368
|
-
draft,
|
|
369
|
-
onDraftChange: setDraft,
|
|
370
|
-
onSend: handleSubmit,
|
|
371
|
-
onStop: () => {
|
|
372
|
-
chat?.stop();
|
|
373
|
-
},
|
|
374
|
-
onRetry: handleRetry,
|
|
375
|
-
onNewChat: handleNewChat,
|
|
376
|
-
toolbarActions,
|
|
377
|
-
messageLimit,
|
|
378
|
-
attachments: selectedFiles.map((file, index) => ({
|
|
379
|
-
name: file.name,
|
|
380
|
-
size: file.size,
|
|
381
|
-
...attachmentPreviews[index] ? { previewUrl: attachmentPreviews[index] } : {}
|
|
382
|
-
})),
|
|
383
|
-
onSelectAttachments: attachmentOptions ? handleSelectedFiles : void 0,
|
|
384
|
-
onRemoveAttachment: attachmentOptions ? (index) => setSelectedFiles((files) => files.filter((_, i) => i !== index)) : void 0,
|
|
385
|
-
attachmentAccept: attachmentOptions?.accept,
|
|
386
|
-
attachmentError,
|
|
387
|
-
onToolApproval: chat ? async (id, approved) => {
|
|
388
|
-
if (approvalBusy) return;
|
|
389
|
-
setApprovalBusy(true);
|
|
390
|
-
try {
|
|
391
|
-
await chat.addToolApprovalResponse({
|
|
392
|
-
id,
|
|
393
|
-
approved,
|
|
394
|
-
...!approved ? { reason: "User denied approval" } : {}
|
|
395
|
-
});
|
|
396
|
-
} finally {
|
|
397
|
-
setApprovalBusy(false);
|
|
70
|
+
if (event.key !== "Tab" || !mobile) return;
|
|
71
|
+
const focusable = Array.from(panelRef.current?.querySelectorAll("a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex=\"-1\"])") ?? []).filter((item) => item.tabIndex >= 0 && item.getClientRects().length > 0);
|
|
72
|
+
if (!focusable.length) {
|
|
73
|
+
event.preventDefault();
|
|
74
|
+
panelRef.current?.focus();
|
|
75
|
+
return;
|
|
398
76
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
const [pendingApprovalId, setPendingApprovalId] = useState(null);
|
|
417
|
-
const [approvalError, setApprovalError] = useState(null);
|
|
418
|
-
const respondToApproval = async (id, approved) => {
|
|
419
|
-
if (!onToolApproval || approvalRef.current) return;
|
|
420
|
-
approvalRef.current = id;
|
|
421
|
-
setPendingApprovalId(id);
|
|
422
|
-
setApprovalError(null);
|
|
423
|
-
try {
|
|
424
|
-
await onToolApproval(id, approved);
|
|
425
|
-
} catch {
|
|
426
|
-
setApprovalError("Could not submit approval. Please try again.");
|
|
427
|
-
} finally {
|
|
428
|
-
approvalRef.current = null;
|
|
429
|
-
setPendingApprovalId(null);
|
|
430
|
-
}
|
|
431
|
-
};
|
|
432
|
-
const isBusy = status === "submitted" || status === "streaming";
|
|
433
|
-
const limit = messageLimit != null && Number.isFinite(messageLimit) ? Math.max(1, Math.floor(messageLimit)) : null;
|
|
434
|
-
const historyFull = limit !== null && messages.filter((message) => message.role === "user").length >= limit;
|
|
435
|
-
const MessageRenderer = components?.MessageRenderer ?? DefaultMessageRenderer;
|
|
436
|
-
const ErrorRenderer = components?.ErrorRenderer ?? DefaultErrorRenderer;
|
|
437
|
-
useEffect(() => {
|
|
438
|
-
const viewport = viewportRef.current;
|
|
439
|
-
if (viewport && pinnedToBottom.current) viewport.scrollTop = viewport.scrollHeight;
|
|
440
|
-
});
|
|
441
|
-
const handleKeyDown = (event) => {
|
|
442
|
-
if (event.key === "Enter" && !event.shiftKey && !event.nativeEvent.isComposing) {
|
|
443
|
-
event.preventDefault();
|
|
444
|
-
if (!isBusy && !historyFull && !error && (draft.trim() || (attachments?.length ?? 0) > 0)) onSend?.();
|
|
445
|
-
}
|
|
446
|
-
};
|
|
447
|
-
const handleFormSubmit = (event) => {
|
|
448
|
-
event.preventDefault();
|
|
449
|
-
if (!isBusy && !historyFull && !error && (draft.trim() || (attachments?.length ?? 0) > 0)) onSend?.();
|
|
450
|
-
};
|
|
77
|
+
const first = focusable[0], last = focusable[focusable.length - 1];
|
|
78
|
+
if (event.shiftKey && (document.activeElement === first || !panelRef.current?.contains(document.activeElement))) {
|
|
79
|
+
event.preventDefault();
|
|
80
|
+
last?.focus();
|
|
81
|
+
} else if (!event.shiftKey && (document.activeElement === last || !panelRef.current?.contains(document.activeElement))) {
|
|
82
|
+
event.preventDefault();
|
|
83
|
+
first?.focus();
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
document.addEventListener("keydown", keydown);
|
|
87
|
+
return () => document.removeEventListener("keydown", keydown);
|
|
88
|
+
}, [
|
|
89
|
+
isOpen,
|
|
90
|
+
mobile,
|
|
91
|
+
onOpenChange,
|
|
92
|
+
open
|
|
93
|
+
]);
|
|
451
94
|
return /* @__PURE__ */ jsxs("div", {
|
|
452
|
-
className: [
|
|
453
|
-
style,
|
|
95
|
+
className: [ai_chat_dock_module_default.dock, className].filter(Boolean).join(" "),
|
|
454
96
|
children: [
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
"aria-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
strokeLinecap: "round",
|
|
478
|
-
strokeLinejoin: "round",
|
|
479
|
-
children: [/* @__PURE__ */ jsx("path", { d: "M12 5H6a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2v-6" }), /* @__PURE__ */ jsx("path", {
|
|
480
|
-
d: "m15 5 4 4M13 11l7-7a2.12 2.12 0 0 1 3 3l-7 7-4 1 1-4Z",
|
|
481
|
-
transform: "translate(-2 -2)"
|
|
482
|
-
})]
|
|
483
|
-
})
|
|
97
|
+
showLauncher && !isOpen && /* @__PURE__ */ jsxs("button", {
|
|
98
|
+
ref: launcherRef,
|
|
99
|
+
type: "button",
|
|
100
|
+
className: ai_chat_dock_module_default.launcher,
|
|
101
|
+
"aria-controls": panelId,
|
|
102
|
+
"aria-expanded": false,
|
|
103
|
+
"aria-label": launcherLabel ?? `Open ${title}`,
|
|
104
|
+
onClick: () => changeOpen(true),
|
|
105
|
+
children: [/* @__PURE__ */ jsx("svg", {
|
|
106
|
+
"aria-hidden": "true",
|
|
107
|
+
width: "23",
|
|
108
|
+
height: "23",
|
|
109
|
+
viewBox: "0 0 24 24",
|
|
110
|
+
fill: "none",
|
|
111
|
+
stroke: "currentColor",
|
|
112
|
+
strokeWidth: "1.8",
|
|
113
|
+
strokeLinecap: "round",
|
|
114
|
+
strokeLinejoin: "round",
|
|
115
|
+
children: /* @__PURE__ */ jsx("path", { d: "M21 11.5a8.5 8.5 0 0 1-8.5 8.5 9.1 9.1 0 0 1-4-.9L3 21l1.9-5.5a9.1 9.1 0 0 1-.9-4 8.5 8.5 0 0 1 8.5-8.5h.5A8.5 8.5 0 0 1 21 11.5Z" })
|
|
116
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
117
|
+
className: ai_chat_dock_module_default.launcherText,
|
|
118
|
+
children: title
|
|
484
119
|
})]
|
|
485
120
|
}),
|
|
486
|
-
/* @__PURE__ */ jsx("div", {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
const viewport = event.currentTarget;
|
|
491
|
-
pinnedToBottom.current = viewport.scrollHeight - viewport.scrollTop - viewport.clientHeight < 80;
|
|
492
|
-
},
|
|
493
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
494
|
-
className: ai_chat_module_default.messageList,
|
|
495
|
-
role: "log",
|
|
496
|
-
"aria-label": "Chat history",
|
|
497
|
-
"aria-live": "polite",
|
|
498
|
-
children: [
|
|
499
|
-
messages.length === 0 && /* @__PURE__ */ jsx("div", {
|
|
500
|
-
className: ai_chat_module_default.emptyState,
|
|
501
|
-
children: emptyState ?? /* @__PURE__ */ jsx("p", { children: "Start a conversation" })
|
|
502
|
-
}),
|
|
503
|
-
messages.map((message) => /* @__PURE__ */ jsx(MessageRenderer, {
|
|
504
|
-
message,
|
|
505
|
-
renderMessagePart: (part, index) => renderPart(part, index, components, onToolApproval ? respondToApproval : void 0, pendingApprovalId),
|
|
506
|
-
onToolApproval: onToolApproval ? respondToApproval : void 0
|
|
507
|
-
}, message.id)),
|
|
508
|
-
isBusy && /* @__PURE__ */ jsx("p", {
|
|
509
|
-
className: ai_chat_module_default.status,
|
|
510
|
-
children: "Thinking..."
|
|
511
|
-
})
|
|
512
|
-
]
|
|
513
|
-
})
|
|
121
|
+
isOpen && mobile && /* @__PURE__ */ jsx("div", {
|
|
122
|
+
className: ai_chat_dock_module_default.backdrop,
|
|
123
|
+
"aria-hidden": "true",
|
|
124
|
+
onClick: () => changeOpen(false)
|
|
514
125
|
}),
|
|
515
|
-
/* @__PURE__ */ jsxs("
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
126
|
+
/* @__PURE__ */ jsxs("section", {
|
|
127
|
+
ref: panelRef,
|
|
128
|
+
id: panelId,
|
|
129
|
+
role: "dialog",
|
|
130
|
+
"aria-modal": mobile && isOpen,
|
|
131
|
+
"aria-label": title,
|
|
132
|
+
tabIndex: -1,
|
|
133
|
+
className: ai_chat_dock_module_default.panel,
|
|
134
|
+
"data-expanded": isExpanded,
|
|
135
|
+
hidden: !isOpen,
|
|
136
|
+
children: [/* @__PURE__ */ jsxs("header", {
|
|
137
|
+
className: ai_chat_dock_module_default.header,
|
|
138
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
139
|
+
className: ai_chat_dock_module_default.identity,
|
|
140
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
141
|
+
className: ai_chat_dock_module_default.avatar,
|
|
142
|
+
"aria-hidden": "true",
|
|
143
|
+
children: /* @__PURE__ */ jsxs("svg", {
|
|
144
|
+
width: "18",
|
|
145
|
+
height: "18",
|
|
146
|
+
viewBox: "0 0 24 24",
|
|
147
|
+
fill: "none",
|
|
148
|
+
stroke: "currentColor",
|
|
149
|
+
strokeWidth: "1.8",
|
|
150
|
+
strokeLinecap: "round",
|
|
151
|
+
strokeLinejoin: "round",
|
|
152
|
+
children: [/* @__PURE__ */ jsx("rect", {
|
|
153
|
+
x: "4",
|
|
154
|
+
y: "6",
|
|
155
|
+
width: "16",
|
|
156
|
+
height: "14",
|
|
157
|
+
rx: "4"
|
|
158
|
+
}), /* @__PURE__ */ jsx("path", { d: "M12 3v3M9 13h.01M15 13h.01M9 17h6" })]
|
|
159
|
+
})
|
|
160
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
161
|
+
className: ai_chat_dock_module_default.titles,
|
|
162
|
+
children: [/* @__PURE__ */ jsx("strong", {
|
|
163
|
+
className: ai_chat_dock_module_default.title,
|
|
164
|
+
children: title
|
|
165
|
+
}), description && /* @__PURE__ */ jsx("span", {
|
|
166
|
+
className: ai_chat_dock_module_default.description,
|
|
167
|
+
children: description
|
|
545
168
|
})]
|
|
546
169
|
})]
|
|
547
|
-
})
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
children: [/* @__PURE__ */ jsxs("span", { children: [
|
|
551
|
-
"This chat has reached its ",
|
|
552
|
-
limit,
|
|
553
|
-
"-question limit."
|
|
554
|
-
] }), /* @__PURE__ */ jsx("button", {
|
|
170
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
171
|
+
className: ai_chat_dock_module_default.actions,
|
|
172
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
555
173
|
type: "button",
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
children:
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
}), attachments && attachments.length > 0 && /* @__PURE__ */ jsx("ul", {
|
|
583
|
-
className: ai_chat_module_default.attachmentList,
|
|
584
|
-
children: attachments.map((attachment, index) => /* @__PURE__ */ jsxs("li", { children: [attachment.previewUrl ? /* @__PURE__ */ jsx("img", {
|
|
585
|
-
className: ai_chat_module_default.attachmentThumbnail,
|
|
586
|
-
src: attachment.previewUrl,
|
|
587
|
-
alt: attachment.name
|
|
588
|
-
}) : /* @__PURE__ */ jsx("span", {
|
|
589
|
-
className: ai_chat_module_default.attachmentFilename,
|
|
590
|
-
children: attachment.name
|
|
591
|
-
}), onRemoveAttachment && /* @__PURE__ */ jsx("button", {
|
|
592
|
-
type: "button",
|
|
593
|
-
onClick: () => onRemoveAttachment(index),
|
|
594
|
-
"aria-label": `Remove ${attachment.name}`,
|
|
595
|
-
title: `Remove ${attachment.name}`,
|
|
596
|
-
children: "×"
|
|
597
|
-
})] }, index))
|
|
598
|
-
})]
|
|
599
|
-
}),
|
|
600
|
-
/* @__PURE__ */ jsx("div", {
|
|
601
|
-
className: ai_chat_module_default.composerSurface,
|
|
602
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
603
|
-
className: ai_chat_module_default.composerRow,
|
|
604
|
-
children: [
|
|
605
|
-
onSelectAttachments && /* @__PURE__ */ jsx("button", {
|
|
606
|
-
type: "button",
|
|
607
|
-
className: ai_chat_module_default.composerIconButton,
|
|
608
|
-
"aria-label": "Attach file",
|
|
609
|
-
title: "Attach file",
|
|
610
|
-
disabled: isBusy,
|
|
611
|
-
onClick: () => fileInputRef.current?.click(),
|
|
612
|
-
children: /* @__PURE__ */ jsx("svg", {
|
|
613
|
-
width: "20",
|
|
614
|
-
height: "20",
|
|
615
|
-
viewBox: "0 0 24 24",
|
|
616
|
-
fill: "none",
|
|
617
|
-
stroke: "currentColor",
|
|
618
|
-
strokeWidth: "1.8",
|
|
619
|
-
strokeLinecap: "round",
|
|
620
|
-
strokeLinejoin: "round",
|
|
621
|
-
"aria-hidden": "true",
|
|
622
|
-
children: /* @__PURE__ */ jsx("path", { d: "m21 11-8.5 8.5a6 6 0 0 1-8.5-8.5l9-9a4 4 0 0 1 5.7 5.7l-9 9a2 2 0 0 1-2.8-2.8l8.5-8.5" })
|
|
623
|
-
})
|
|
624
|
-
}),
|
|
625
|
-
/* @__PURE__ */ jsx("textarea", {
|
|
626
|
-
className: ai_chat_module_default.input,
|
|
627
|
-
"aria-label": inputAriaLabel,
|
|
628
|
-
rows: 1,
|
|
629
|
-
value: draft,
|
|
630
|
-
onChange: (event) => onDraftChange?.(event.target.value),
|
|
631
|
-
onKeyDown: handleKeyDown,
|
|
632
|
-
placeholder: inputPlaceholder,
|
|
633
|
-
maxLength: inputMaxLength,
|
|
634
|
-
disabled: isBusy || !onSend || !onDraftChange,
|
|
635
|
-
readOnly: !onDraftChange
|
|
636
|
-
}),
|
|
637
|
-
/* @__PURE__ */ jsxs("div", {
|
|
638
|
-
className: ai_chat_module_default.composerActions,
|
|
639
|
-
children: [composerTrailing, isBusy ? onStop && /* @__PURE__ */ jsx("button", {
|
|
640
|
-
type: "button",
|
|
641
|
-
className: ai_chat_module_default.composerIconButton,
|
|
642
|
-
onClick: onStop,
|
|
643
|
-
"aria-label": "Stop response",
|
|
644
|
-
title: "Stop response",
|
|
645
|
-
children: /* @__PURE__ */ jsx("svg", {
|
|
646
|
-
width: "18",
|
|
647
|
-
height: "18",
|
|
648
|
-
viewBox: "0 0 24 24",
|
|
649
|
-
fill: "currentColor",
|
|
650
|
-
"aria-hidden": "true",
|
|
651
|
-
children: /* @__PURE__ */ jsx("rect", {
|
|
652
|
-
x: "5",
|
|
653
|
-
y: "5",
|
|
654
|
-
width: "14",
|
|
655
|
-
height: "14",
|
|
656
|
-
rx: "2"
|
|
657
|
-
})
|
|
658
|
-
})
|
|
659
|
-
}) : /* @__PURE__ */ jsx("button", {
|
|
660
|
-
type: "submit",
|
|
661
|
-
className: ai_chat_module_default.sendButton,
|
|
662
|
-
"aria-label": "Send message",
|
|
663
|
-
title: "Send message",
|
|
664
|
-
disabled: !onSend || !draft.trim() && !attachments?.length,
|
|
665
|
-
children: /* @__PURE__ */ jsx("svg", {
|
|
666
|
-
width: "20",
|
|
667
|
-
height: "20",
|
|
668
|
-
viewBox: "0 0 24 24",
|
|
669
|
-
fill: "none",
|
|
670
|
-
stroke: "currentColor",
|
|
671
|
-
strokeWidth: "2",
|
|
672
|
-
strokeLinecap: "round",
|
|
673
|
-
strokeLinejoin: "round",
|
|
674
|
-
"aria-hidden": "true",
|
|
675
|
-
children: /* @__PURE__ */ jsx("path", { d: "M12 19V5m-7 7 7-7 7 7" })
|
|
676
|
-
})
|
|
677
|
-
})]
|
|
678
|
-
})
|
|
679
|
-
]
|
|
680
|
-
})
|
|
174
|
+
className: ai_chat_dock_module_default.iconButton,
|
|
175
|
+
"aria-label": isExpanded ? `Collapse ${title}` : `Expand ${title}`,
|
|
176
|
+
title: isExpanded ? "Collapse" : "Expand",
|
|
177
|
+
onClick: () => changeExpanded(!isExpanded),
|
|
178
|
+
children: isExpanded ? /* @__PURE__ */ jsx("svg", {
|
|
179
|
+
width: "17",
|
|
180
|
+
height: "17",
|
|
181
|
+
viewBox: "0 0 24 24",
|
|
182
|
+
fill: "none",
|
|
183
|
+
stroke: "currentColor",
|
|
184
|
+
strokeWidth: "2",
|
|
185
|
+
strokeLinecap: "round",
|
|
186
|
+
strokeLinejoin: "round",
|
|
187
|
+
"aria-hidden": "true",
|
|
188
|
+
children: /* @__PURE__ */ jsx("path", { d: "M9 3v6H3M15 21v-6h6M3 9l6-6M21 15l-6 6" })
|
|
189
|
+
}) : /* @__PURE__ */ jsx("svg", {
|
|
190
|
+
width: "17",
|
|
191
|
+
height: "17",
|
|
192
|
+
viewBox: "0 0 24 24",
|
|
193
|
+
fill: "none",
|
|
194
|
+
stroke: "currentColor",
|
|
195
|
+
strokeWidth: "2",
|
|
196
|
+
strokeLinecap: "round",
|
|
197
|
+
strokeLinejoin: "round",
|
|
198
|
+
"aria-hidden": "true",
|
|
199
|
+
children: /* @__PURE__ */ jsx("path", { d: "M8 3H3v5M16 21h5v-5M3 3l7 7M21 21l-7-7" })
|
|
681
200
|
})
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
201
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
202
|
+
type: "button",
|
|
203
|
+
className: ai_chat_dock_module_default.iconButton,
|
|
204
|
+
"aria-label": `Close ${title}`,
|
|
205
|
+
title: "Close",
|
|
206
|
+
onClick: () => changeOpen(false),
|
|
207
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
208
|
+
width: "18",
|
|
209
|
+
height: "18",
|
|
210
|
+
viewBox: "0 0 24 24",
|
|
211
|
+
fill: "none",
|
|
212
|
+
stroke: "currentColor",
|
|
213
|
+
strokeWidth: "2",
|
|
214
|
+
strokeLinecap: "round",
|
|
215
|
+
"aria-hidden": "true",
|
|
216
|
+
children: /* @__PURE__ */ jsx("path", { d: "M18 6 6 18M6 6l12 12" })
|
|
217
|
+
})
|
|
218
|
+
})]
|
|
219
|
+
})]
|
|
220
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
221
|
+
className: ai_chat_dock_module_default.content,
|
|
222
|
+
children
|
|
223
|
+
})]
|
|
685
224
|
})
|
|
686
225
|
]
|
|
687
226
|
});
|
|
688
227
|
}
|
|
689
228
|
//#endregion
|
|
690
|
-
export {
|
|
229
|
+
export { AIChatDock };
|
|
691
230
|
|
|
692
231
|
//# sourceMappingURL=index82.js.map
|