@malette/agent-sdk 0.1.3-beta.6 → 0.1.3-beta.8
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 +1494 -682
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +922 -112
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,11 +4,11 @@ var Cookies2 = require('js-cookie');
|
|
|
4
4
|
var OSS = require('ali-oss');
|
|
5
5
|
var zustand = require('zustand');
|
|
6
6
|
var middleware = require('zustand/middleware');
|
|
7
|
-
var
|
|
7
|
+
var React16 = require('react');
|
|
8
8
|
var lucideReact = require('lucide-react');
|
|
9
9
|
var ReactMarkdown = require('react-markdown');
|
|
10
10
|
var jsxRuntime = require('react/jsx-runtime');
|
|
11
|
-
require('react-dom');
|
|
11
|
+
var ReactDOM = require('react-dom');
|
|
12
12
|
var shallow = require('zustand/react/shallow');
|
|
13
13
|
var DialogPrimitive = require('@radix-ui/react-dialog');
|
|
14
14
|
var reactSlot = require('@radix-ui/react-slot');
|
|
@@ -37,8 +37,9 @@ function _interopNamespace(e) {
|
|
|
37
37
|
|
|
38
38
|
var Cookies2__default = /*#__PURE__*/_interopDefault(Cookies2);
|
|
39
39
|
var OSS__default = /*#__PURE__*/_interopDefault(OSS);
|
|
40
|
-
var
|
|
40
|
+
var React16__namespace = /*#__PURE__*/_interopNamespace(React16);
|
|
41
41
|
var ReactMarkdown__default = /*#__PURE__*/_interopDefault(ReactMarkdown);
|
|
42
|
+
var ReactDOM__default = /*#__PURE__*/_interopDefault(ReactDOM);
|
|
42
43
|
var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
|
|
43
44
|
var ScrollAreaPrimitive__namespace = /*#__PURE__*/_interopNamespace(ScrollAreaPrimitive);
|
|
44
45
|
|
|
@@ -889,7 +890,7 @@ function getCacheKey(text3) {
|
|
|
889
890
|
return text3.slice(0, 200);
|
|
890
891
|
}
|
|
891
892
|
async function submitGenerateTask(text3) {
|
|
892
|
-
const response = await
|
|
893
|
+
const response = await fetcher("/api/v1/ai/design/generate", {
|
|
893
894
|
method: "POST",
|
|
894
895
|
headers: { "content-type": "application/json" },
|
|
895
896
|
credentials: "include",
|
|
@@ -903,11 +904,10 @@ async function submitGenerateTask(text3) {
|
|
|
903
904
|
version: "0.1.0"
|
|
904
905
|
})
|
|
905
906
|
});
|
|
906
|
-
if (!response.
|
|
907
|
+
if (!response.success) {
|
|
907
908
|
throw new Error(`TTS generate request failed: ${response.status}`);
|
|
908
909
|
}
|
|
909
|
-
const
|
|
910
|
-
const data = result.data ?? result;
|
|
910
|
+
const data = response.data;
|
|
911
911
|
console.log("[TTS] Generate task submitted:", data);
|
|
912
912
|
const publicId = data?.publicId || data?.recordVO?.publicId || (typeof data === "string" ? data : null);
|
|
913
913
|
if (!publicId) {
|
|
@@ -1606,6 +1606,7 @@ var useAgentStore = zustand.create()(
|
|
|
1606
1606
|
...state.artifacts,
|
|
1607
1607
|
[artifactId]: {
|
|
1608
1608
|
...existing,
|
|
1609
|
+
source,
|
|
1609
1610
|
currentContent: content,
|
|
1610
1611
|
version: existing.version + 1,
|
|
1611
1612
|
gmtModified: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -5210,7 +5211,7 @@ function remarkGfm(options) {
|
|
|
5210
5211
|
toMarkdownExtensions.push(gfmToMarkdown(settings));
|
|
5211
5212
|
}
|
|
5212
5213
|
|
|
5213
|
-
// node_modules/clsx/dist/clsx.mjs
|
|
5214
|
+
// ../../node_modules/clsx/dist/clsx.mjs
|
|
5214
5215
|
function r(e) {
|
|
5215
5216
|
var t, f, n = "";
|
|
5216
5217
|
if ("string" == typeof e || "number" == typeof e) n += e;
|
|
@@ -7761,7 +7762,7 @@ var resolveAssetForDisplay = async (asset, config) => {
|
|
|
7761
7762
|
}
|
|
7762
7763
|
return null;
|
|
7763
7764
|
};
|
|
7764
|
-
var ComponentContext =
|
|
7765
|
+
var ComponentContext = React16.createContext(void 0);
|
|
7765
7766
|
var ComponentProvider = ({
|
|
7766
7767
|
components = {},
|
|
7767
7768
|
children
|
|
@@ -7769,7 +7770,7 @@ var ComponentProvider = ({
|
|
|
7769
7770
|
return /* @__PURE__ */ jsxRuntime.jsx(ComponentContext.Provider, { value: components, children });
|
|
7770
7771
|
};
|
|
7771
7772
|
var useComponents = () => {
|
|
7772
|
-
const context =
|
|
7773
|
+
const context = React16.useContext(ComponentContext);
|
|
7773
7774
|
if (!context) {
|
|
7774
7775
|
return {};
|
|
7775
7776
|
}
|
|
@@ -7780,14 +7781,14 @@ function useComponent(componentName) {
|
|
|
7780
7781
|
return components[componentName];
|
|
7781
7782
|
}
|
|
7782
7783
|
var imageLoadedCache = /* @__PURE__ */ new Map();
|
|
7783
|
-
var MessageImageInternal =
|
|
7784
|
+
var MessageImageInternal = React16.memo(function MessageImageInternal2({ src, alt, className }) {
|
|
7784
7785
|
const cachedStatus = imageLoadedCache.get(src);
|
|
7785
|
-
const [loaded, setLoaded] =
|
|
7786
|
-
const [error, setError] =
|
|
7787
|
-
const imgRef =
|
|
7788
|
-
const [previewUrl, setPreviewUrl] =
|
|
7786
|
+
const [loaded, setLoaded] = React16.useState(cachedStatus === "loaded");
|
|
7787
|
+
const [error, setError] = React16.useState(cachedStatus === "error");
|
|
7788
|
+
const imgRef = React16__namespace.default.useRef(null);
|
|
7789
|
+
const [previewUrl, setPreviewUrl] = React16.useState(null);
|
|
7789
7790
|
const ImagePreviewComp = useComponent("ImagePreview") || ImagePreviewInternal;
|
|
7790
|
-
|
|
7791
|
+
React16.useEffect(() => {
|
|
7791
7792
|
const status = imageLoadedCache.get(src);
|
|
7792
7793
|
if (status === "loaded") {
|
|
7793
7794
|
setLoaded(true);
|
|
@@ -7801,7 +7802,7 @@ var MessageImageInternal = React24.memo(function MessageImageInternal2({ src, al
|
|
|
7801
7802
|
setError(false);
|
|
7802
7803
|
}
|
|
7803
7804
|
}, [src]);
|
|
7804
|
-
|
|
7805
|
+
React16.useEffect(() => {
|
|
7805
7806
|
const img = imgRef.current;
|
|
7806
7807
|
if (!img) return;
|
|
7807
7808
|
if (img.complete && img.naturalWidth > 0) {
|
|
@@ -7851,20 +7852,20 @@ var MessageImageInternal = React24.memo(function MessageImageInternal2({ src, al
|
|
|
7851
7852
|
)
|
|
7852
7853
|
] });
|
|
7853
7854
|
});
|
|
7854
|
-
var MessageVideoInternal =
|
|
7855
|
-
const videoRef =
|
|
7856
|
-
const canvasRef =
|
|
7857
|
-
const [posterUrl, setPosterUrl] =
|
|
7858
|
-
const [isHovering, setIsHovering] =
|
|
7859
|
-
const [isPlaying, setIsPlaying] =
|
|
7860
|
-
const [isMuted, setIsMuted] =
|
|
7861
|
-
const [duration, setDuration] =
|
|
7862
|
-
const [currentTime, setCurrentTime] =
|
|
7863
|
-
const [isFullPlaying, setIsFullPlaying] =
|
|
7864
|
-
const hoverTimerRef =
|
|
7855
|
+
var MessageVideoInternal = React16.memo(function MessageVideoInternal2({ src, className }) {
|
|
7856
|
+
const videoRef = React16__namespace.default.useRef(null);
|
|
7857
|
+
const canvasRef = React16__namespace.default.useRef(null);
|
|
7858
|
+
const [posterUrl, setPosterUrl] = React16.useState(null);
|
|
7859
|
+
const [isHovering, setIsHovering] = React16.useState(false);
|
|
7860
|
+
const [isPlaying, setIsPlaying] = React16.useState(false);
|
|
7861
|
+
const [isMuted, setIsMuted] = React16.useState(true);
|
|
7862
|
+
const [duration, setDuration] = React16.useState(0);
|
|
7863
|
+
const [currentTime, setCurrentTime] = React16.useState(0);
|
|
7864
|
+
const [isFullPlaying, setIsFullPlaying] = React16.useState(false);
|
|
7865
|
+
const hoverTimerRef = React16__namespace.default.useRef(null);
|
|
7865
7866
|
const VideoPreviewComp = useComponent("VideoPreview") || VideoPreviewInternal;
|
|
7866
|
-
const [showPreview, setShowPreview] =
|
|
7867
|
-
|
|
7867
|
+
const [showPreview, setShowPreview] = React16.useState(false);
|
|
7868
|
+
React16.useEffect(() => {
|
|
7868
7869
|
const video = document.createElement("video");
|
|
7869
7870
|
video.crossOrigin = "anonymous";
|
|
7870
7871
|
video.preload = "metadata";
|
|
@@ -8121,12 +8122,12 @@ var MessageVideoInternal = React24.memo(function MessageVideoInternal2({ src, cl
|
|
|
8121
8122
|
)
|
|
8122
8123
|
] });
|
|
8123
8124
|
});
|
|
8124
|
-
var ImagePreviewInternal =
|
|
8125
|
+
var ImagePreviewInternal = React16.memo(function ImagePreviewInternal2({
|
|
8125
8126
|
src,
|
|
8126
8127
|
alt,
|
|
8127
8128
|
onClose
|
|
8128
8129
|
}) {
|
|
8129
|
-
|
|
8130
|
+
React16.useEffect(() => {
|
|
8130
8131
|
const handleKeyDown = (e) => {
|
|
8131
8132
|
if (e.key === "Escape") {
|
|
8132
8133
|
onClose();
|
|
@@ -8179,11 +8180,11 @@ var ImagePreviewInternal = React24.memo(function ImagePreviewInternal2({
|
|
|
8179
8180
|
}
|
|
8180
8181
|
);
|
|
8181
8182
|
});
|
|
8182
|
-
var VideoPreviewInternal =
|
|
8183
|
+
var VideoPreviewInternal = React16.memo(function VideoPreviewInternal2({
|
|
8183
8184
|
src,
|
|
8184
8185
|
onClose
|
|
8185
8186
|
}) {
|
|
8186
|
-
|
|
8187
|
+
React16.useEffect(() => {
|
|
8187
8188
|
const handleKeyDown = (e) => {
|
|
8188
8189
|
if (e.key === "Escape") {
|
|
8189
8190
|
onClose();
|
|
@@ -8220,7 +8221,7 @@ var VideoPreviewInternal = React24.memo(function VideoPreviewInternal2({
|
|
|
8220
8221
|
);
|
|
8221
8222
|
});
|
|
8222
8223
|
var mediaResolveCache = /* @__PURE__ */ new Map();
|
|
8223
|
-
var ResolvedMarkdownMedia =
|
|
8224
|
+
var ResolvedMarkdownMedia = React16.memo(function ResolvedMarkdownMedia2({
|
|
8224
8225
|
src,
|
|
8225
8226
|
alt,
|
|
8226
8227
|
skipImages,
|
|
@@ -8228,8 +8229,8 @@ var ResolvedMarkdownMedia = React24.memo(function ResolvedMarkdownMedia2({
|
|
|
8228
8229
|
}) {
|
|
8229
8230
|
const cacheKey = src || "";
|
|
8230
8231
|
const cachedMedia = mediaResolveCache.get(cacheKey);
|
|
8231
|
-
const [media, setMedia] =
|
|
8232
|
-
|
|
8232
|
+
const [media, setMedia] = React16.useState(cachedMedia ?? null);
|
|
8233
|
+
React16.useEffect(() => {
|
|
8233
8234
|
let active = true;
|
|
8234
8235
|
const load = async () => {
|
|
8235
8236
|
if (!src) {
|
|
@@ -8467,8 +8468,8 @@ function getToolCallStatus(tc) {
|
|
|
8467
8468
|
if (tc.error) return "failed";
|
|
8468
8469
|
return "success";
|
|
8469
8470
|
}
|
|
8470
|
-
var CodeBlock =
|
|
8471
|
-
const [copied, setCopied] =
|
|
8471
|
+
var CodeBlock = React16.memo(function CodeBlock2({ children, className }) {
|
|
8472
|
+
const [copied, setCopied] = React16.useState(false);
|
|
8472
8473
|
const language = className?.replace("language-", "") || "text";
|
|
8473
8474
|
const handleCopy = async () => {
|
|
8474
8475
|
await navigator.clipboard.writeText(children);
|
|
@@ -8493,7 +8494,7 @@ var CodeBlock = React24.memo(function CodeBlock2({ children, className }) {
|
|
|
8493
8494
|
/* @__PURE__ */ jsxRuntime.jsx("pre", { className: "p-4 overflow-x-auto text-sm whitespace-pre-wrap break-all", children: /* @__PURE__ */ jsxRuntime.jsx("code", { className: `${className} text-zinc-300`, children }) })
|
|
8494
8495
|
] });
|
|
8495
8496
|
});
|
|
8496
|
-
var MarkdownContent =
|
|
8497
|
+
var MarkdownContent = React16.memo(function MarkdownContent2({ content, skipImages = false, config, variant = "default" }) {
|
|
8497
8498
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
8498
8499
|
ReactMarkdown__default.default,
|
|
8499
8500
|
{
|
|
@@ -8707,17 +8708,17 @@ var contentTypeConfig = {
|
|
|
8707
8708
|
bgColor: "bg-zinc-500/10"
|
|
8708
8709
|
}
|
|
8709
8710
|
};
|
|
8710
|
-
var ContentPreviewCard =
|
|
8711
|
+
var ContentPreviewCard = React16.memo(function ContentPreviewCard2({
|
|
8711
8712
|
parsed,
|
|
8712
8713
|
index = 0,
|
|
8713
8714
|
config,
|
|
8714
8715
|
onOpenArtifact
|
|
8715
8716
|
}) {
|
|
8716
|
-
const [isModalOpen, setIsModalOpen] =
|
|
8717
|
-
const [copied, setCopied] =
|
|
8717
|
+
const [isModalOpen, setIsModalOpen] = React16.useState(false);
|
|
8718
|
+
const [copied, setCopied] = React16.useState(false);
|
|
8718
8719
|
const typeConfig = contentTypeConfig[parsed.type];
|
|
8719
8720
|
const Icon = typeConfig.icon;
|
|
8720
|
-
const handleCopy =
|
|
8721
|
+
const handleCopy = React16.useCallback(async (e) => {
|
|
8721
8722
|
e.stopPropagation();
|
|
8722
8723
|
try {
|
|
8723
8724
|
await navigator.clipboard.writeText(parsed.content);
|
|
@@ -8726,7 +8727,7 @@ var ContentPreviewCard = React24.memo(function ContentPreviewCard2({
|
|
|
8726
8727
|
} catch {
|
|
8727
8728
|
}
|
|
8728
8729
|
}, [parsed.content]);
|
|
8729
|
-
const handleOpenPreview =
|
|
8730
|
+
const handleOpenPreview = React16.useCallback(() => {
|
|
8730
8731
|
console.log("[ContentPreviewCard] Open preview:", onOpenArtifact);
|
|
8731
8732
|
if (onOpenArtifact) {
|
|
8732
8733
|
onOpenArtifact({
|
|
@@ -8739,10 +8740,10 @@ var ContentPreviewCard = React24.memo(function ContentPreviewCard2({
|
|
|
8739
8740
|
setIsModalOpen(true);
|
|
8740
8741
|
}
|
|
8741
8742
|
}, [onOpenArtifact, parsed]);
|
|
8742
|
-
const handleCloseModal =
|
|
8743
|
+
const handleCloseModal = React16.useCallback(() => {
|
|
8743
8744
|
setIsModalOpen(false);
|
|
8744
8745
|
}, []);
|
|
8745
|
-
const preview =
|
|
8746
|
+
const preview = React16.useMemo(() => {
|
|
8746
8747
|
const content = parsed.content;
|
|
8747
8748
|
if (parsed.type === "html") {
|
|
8748
8749
|
const title = parsed.title || "HTML Document";
|
|
@@ -8850,15 +8851,15 @@ var ContentPreviewCard = React24.memo(function ContentPreviewCard2({
|
|
|
8850
8851
|
)
|
|
8851
8852
|
] });
|
|
8852
8853
|
});
|
|
8853
|
-
var ContentPreviewModal =
|
|
8854
|
+
var ContentPreviewModal = React16.memo(function ContentPreviewModal2({
|
|
8854
8855
|
parsed,
|
|
8855
8856
|
onClose,
|
|
8856
8857
|
config
|
|
8857
8858
|
}) {
|
|
8858
|
-
const [viewMode, setViewMode] =
|
|
8859
|
-
const [copied, setCopied] =
|
|
8859
|
+
const [viewMode, setViewMode] = React16.useState("preview");
|
|
8860
|
+
const [copied, setCopied] = React16.useState(false);
|
|
8860
8861
|
const typeConfig = contentTypeConfig[parsed.type];
|
|
8861
|
-
const handleCopy =
|
|
8862
|
+
const handleCopy = React16.useCallback(async () => {
|
|
8862
8863
|
try {
|
|
8863
8864
|
await navigator.clipboard.writeText(parsed.content);
|
|
8864
8865
|
setCopied(true);
|
|
@@ -8866,13 +8867,13 @@ var ContentPreviewModal = React24.memo(function ContentPreviewModal2({
|
|
|
8866
8867
|
} catch {
|
|
8867
8868
|
}
|
|
8868
8869
|
}, [parsed.content]);
|
|
8869
|
-
|
|
8870
|
+
React16__namespace.default.useEffect(() => {
|
|
8870
8871
|
document.body.style.overflow = "hidden";
|
|
8871
8872
|
return () => {
|
|
8872
8873
|
document.body.style.overflow = "";
|
|
8873
8874
|
};
|
|
8874
8875
|
}, []);
|
|
8875
|
-
|
|
8876
|
+
React16__namespace.default.useEffect(() => {
|
|
8876
8877
|
const handleKeyDown = (e) => {
|
|
8877
8878
|
if (e.key === "Escape") {
|
|
8878
8879
|
onClose();
|
|
@@ -8958,7 +8959,7 @@ var ContentPreviewModal = React24.memo(function ContentPreviewModal2({
|
|
|
8958
8959
|
}
|
|
8959
8960
|
);
|
|
8960
8961
|
});
|
|
8961
|
-
var ContentPreviewRenderer =
|
|
8962
|
+
var ContentPreviewRenderer = React16.memo(function ContentPreviewRenderer2({
|
|
8962
8963
|
parsed,
|
|
8963
8964
|
config
|
|
8964
8965
|
}) {
|
|
@@ -8970,14 +8971,14 @@ var ContentPreviewRenderer = React24.memo(function ContentPreviewRenderer2({
|
|
|
8970
8971
|
}
|
|
8971
8972
|
return /* @__PURE__ */ jsxRuntime.jsx(SourceCodeViewer, { content: parsed.content, language: parsed.language || parsed.type });
|
|
8972
8973
|
});
|
|
8973
|
-
var HtmlPreview =
|
|
8974
|
-
const iframeRef =
|
|
8975
|
-
const [scale, setScale] =
|
|
8976
|
-
const blobUrl =
|
|
8974
|
+
var HtmlPreview = React16.memo(function HtmlPreview2({ content }) {
|
|
8975
|
+
const iframeRef = React16__namespace.default.useRef(null);
|
|
8976
|
+
const [scale, setScale] = React16.useState(0.5);
|
|
8977
|
+
const blobUrl = React16.useMemo(() => {
|
|
8977
8978
|
const blob = new Blob([content], { type: "text/html" });
|
|
8978
8979
|
return URL.createObjectURL(blob);
|
|
8979
8980
|
}, [content]);
|
|
8980
|
-
|
|
8981
|
+
React16__namespace.default.useEffect(() => {
|
|
8981
8982
|
return () => {
|
|
8982
8983
|
URL.revokeObjectURL(blobUrl);
|
|
8983
8984
|
};
|
|
@@ -9039,7 +9040,7 @@ var HtmlPreview = React24.memo(function HtmlPreview2({ content }) {
|
|
|
9039
9040
|
) })
|
|
9040
9041
|
] });
|
|
9041
9042
|
});
|
|
9042
|
-
var SourceCodeViewer =
|
|
9043
|
+
var SourceCodeViewer = React16.memo(function SourceCodeViewer2({
|
|
9043
9044
|
content,
|
|
9044
9045
|
language
|
|
9045
9046
|
}) {
|
|
@@ -9049,12 +9050,12 @@ var SourceCodeViewer = React24.memo(function SourceCodeViewer2({
|
|
|
9049
9050
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-zinc-300 whitespace-pre-wrap break-all", children: line || " " })
|
|
9050
9051
|
] }, i)) }) }) });
|
|
9051
9052
|
});
|
|
9052
|
-
|
|
9053
|
+
React16.memo(function CustomResponseRenderer2({
|
|
9053
9054
|
result,
|
|
9054
9055
|
config,
|
|
9055
9056
|
onOpenArtifact
|
|
9056
9057
|
}) {
|
|
9057
|
-
const parsedContents =
|
|
9058
|
+
const parsedContents = React16.useMemo(() => extractCustomResponses(result), [result]);
|
|
9058
9059
|
if (parsedContents.length === 0) {
|
|
9059
9060
|
return null;
|
|
9060
9061
|
}
|
|
@@ -10152,15 +10153,15 @@ async function fetchBackendExtraData(localMessageId, backendMessageId, updateMes
|
|
|
10152
10153
|
}
|
|
10153
10154
|
}
|
|
10154
10155
|
function useSSE(options) {
|
|
10155
|
-
const abortControllerRef =
|
|
10156
|
-
const currentMessageIdRef =
|
|
10157
|
-
const [isConnected, setIsConnected] =
|
|
10158
|
-
const heartbeatTimeoutRef =
|
|
10159
|
-
const reconnectAttemptsRef =
|
|
10160
|
-
const lastActivityTimeRef =
|
|
10161
|
-
const isReconnectingRef =
|
|
10162
|
-
const currentSessionIdRef =
|
|
10163
|
-
const currentLocalMessageIdRef =
|
|
10156
|
+
const abortControllerRef = React16.useRef(null);
|
|
10157
|
+
const currentMessageIdRef = React16.useRef(null);
|
|
10158
|
+
const [isConnected, setIsConnected] = React16.useState(false);
|
|
10159
|
+
const heartbeatTimeoutRef = React16.useRef(null);
|
|
10160
|
+
const reconnectAttemptsRef = React16.useRef(0);
|
|
10161
|
+
const lastActivityTimeRef = React16.useRef(Date.now());
|
|
10162
|
+
const isReconnectingRef = React16.useRef(false);
|
|
10163
|
+
const currentSessionIdRef = React16.useRef(null);
|
|
10164
|
+
const currentLocalMessageIdRef = React16.useRef(null);
|
|
10164
10165
|
const {
|
|
10165
10166
|
addMessage,
|
|
10166
10167
|
updateMessage,
|
|
@@ -10198,13 +10199,13 @@ function useSSE(options) {
|
|
|
10198
10199
|
setOrchestrating,
|
|
10199
10200
|
clearMultiAgentState
|
|
10200
10201
|
} = useAgentStore();
|
|
10201
|
-
const clearHeartbeatTimeout =
|
|
10202
|
+
const clearHeartbeatTimeout = React16.useCallback(() => {
|
|
10202
10203
|
if (heartbeatTimeoutRef.current) {
|
|
10203
10204
|
clearTimeout(heartbeatTimeoutRef.current);
|
|
10204
10205
|
heartbeatTimeoutRef.current = null;
|
|
10205
10206
|
}
|
|
10206
10207
|
}, []);
|
|
10207
|
-
const resetHeartbeatTimeout =
|
|
10208
|
+
const resetHeartbeatTimeout = React16.useCallback((onTimeout) => {
|
|
10208
10209
|
lastActivityTimeRef.current = Date.now();
|
|
10209
10210
|
clearHeartbeatTimeout();
|
|
10210
10211
|
heartbeatTimeoutRef.current = setTimeout(() => {
|
|
@@ -10212,17 +10213,17 @@ function useSSE(options) {
|
|
|
10212
10213
|
onTimeout();
|
|
10213
10214
|
}, SSE_HEARTBEAT_TIMEOUT);
|
|
10214
10215
|
}, [clearHeartbeatTimeout]);
|
|
10215
|
-
const getReconnectDelay =
|
|
10216
|
+
const getReconnectDelay = React16.useCallback(() => {
|
|
10216
10217
|
const attempt = reconnectAttemptsRef.current;
|
|
10217
10218
|
const delay = RECONNECT_BASE_DELAY * Math.pow(2, attempt);
|
|
10218
10219
|
return Math.min(delay, 8e3);
|
|
10219
10220
|
}, []);
|
|
10220
|
-
|
|
10221
|
+
React16.useEffect(() => {
|
|
10221
10222
|
return () => {
|
|
10222
10223
|
clearHeartbeatTimeout();
|
|
10223
10224
|
};
|
|
10224
10225
|
}, [clearHeartbeatTimeout]);
|
|
10225
|
-
const handleFinalEvent =
|
|
10226
|
+
const handleFinalEvent = React16.useCallback(async (data, localMessageId) => {
|
|
10226
10227
|
setIsStreaming(false);
|
|
10227
10228
|
setIsThinking(false);
|
|
10228
10229
|
clearStreamingContent();
|
|
@@ -10301,7 +10302,7 @@ function useSSE(options) {
|
|
|
10301
10302
|
upsertArtifact,
|
|
10302
10303
|
options
|
|
10303
10304
|
]);
|
|
10304
|
-
const persistPartialExtraData =
|
|
10305
|
+
const persistPartialExtraData = React16.useCallback((localMessageId) => {
|
|
10305
10306
|
const state = useAgentStore.getState();
|
|
10306
10307
|
const currentThoughts = state.chatUI.currentThoughts;
|
|
10307
10308
|
const pendingToolCalls = state.chatUI.pendingToolCalls;
|
|
@@ -10318,13 +10319,13 @@ function useSSE(options) {
|
|
|
10318
10319
|
}
|
|
10319
10320
|
});
|
|
10320
10321
|
}, [updateMessage]);
|
|
10321
|
-
const normalizeToolCalls2 =
|
|
10322
|
+
const normalizeToolCalls2 = React16.useCallback((toolCalls) => {
|
|
10322
10323
|
return normalizeToolCallsData(toolCalls, generateId);
|
|
10323
10324
|
}, []);
|
|
10324
|
-
const buildTerminalExtraData =
|
|
10325
|
+
const buildTerminalExtraData = React16.useCallback((toolCallStatus) => {
|
|
10325
10326
|
return buildTerminalExtraDataFromState(useAgentStore.getState(), toolCallStatus);
|
|
10326
10327
|
}, []);
|
|
10327
|
-
const handlePlanEvent =
|
|
10328
|
+
const handlePlanEvent = React16.useCallback(createPlanEventHandler({
|
|
10328
10329
|
setIsThinking,
|
|
10329
10330
|
setIsStreaming,
|
|
10330
10331
|
appendStreamingContent,
|
|
@@ -10350,7 +10351,7 @@ function useSSE(options) {
|
|
|
10350
10351
|
clearPlanState,
|
|
10351
10352
|
options
|
|
10352
10353
|
]);
|
|
10353
|
-
const handleThoughtEvent =
|
|
10354
|
+
const handleThoughtEvent = React16.useCallback(createThoughtEventHandler({
|
|
10354
10355
|
onThought: options?.onThought,
|
|
10355
10356
|
onFrontendToolCall: options?.onFrontendToolCall,
|
|
10356
10357
|
onComponentPending: options?.onComponentPending,
|
|
@@ -10421,7 +10422,7 @@ function useSSE(options) {
|
|
|
10421
10422
|
handleFinalEvent,
|
|
10422
10423
|
handlePlanEvent
|
|
10423
10424
|
]);
|
|
10424
|
-
const processSSEStream =
|
|
10425
|
+
const processSSEStream = React16.useCallback(async (response, localMessageId, onMessageStart) => {
|
|
10425
10426
|
const reader = response.body?.getReader();
|
|
10426
10427
|
const decoder = new TextDecoder();
|
|
10427
10428
|
let buffer = "";
|
|
@@ -10525,7 +10526,7 @@ function useSSE(options) {
|
|
|
10525
10526
|
}
|
|
10526
10527
|
}
|
|
10527
10528
|
}, [handleThoughtEvent, resetHeartbeatTimeout, clearHeartbeatTimeout, getReconnectDelay, setChatError]);
|
|
10528
|
-
const sendMessage =
|
|
10529
|
+
const sendMessage = React16.useCallback(async (sessionId, content, sendOptions) => {
|
|
10529
10530
|
abortControllerRef.current?.abort();
|
|
10530
10531
|
abortControllerRef.current = new AbortController();
|
|
10531
10532
|
clearThoughts();
|
|
@@ -10671,7 +10672,7 @@ function useSSE(options) {
|
|
|
10671
10672
|
options,
|
|
10672
10673
|
persistPartialExtraData
|
|
10673
10674
|
]);
|
|
10674
|
-
const reconnect =
|
|
10675
|
+
const reconnect = React16.useCallback(async (messageId) => {
|
|
10675
10676
|
abortControllerRef.current?.abort();
|
|
10676
10677
|
abortControllerRef.current = new AbortController();
|
|
10677
10678
|
clearThoughts();
|
|
@@ -10706,7 +10707,7 @@ function useSSE(options) {
|
|
|
10706
10707
|
currentMessageIdRef.current = null;
|
|
10707
10708
|
}
|
|
10708
10709
|
}, [clearThoughts, clearStreamingContent, clearPendingToolCalls, addPendingToolCall, setIsThinking, setIsStreaming, processSSEStream, options]);
|
|
10709
|
-
const abort =
|
|
10710
|
+
const abort = React16.useCallback(async () => {
|
|
10710
10711
|
clearHeartbeatTimeout();
|
|
10711
10712
|
reconnectAttemptsRef.current = 0;
|
|
10712
10713
|
isReconnectingRef.current = false;
|
|
@@ -10756,9 +10757,9 @@ function useCanvasBridge(options = {}) {
|
|
|
10756
10757
|
onArtifactSelected,
|
|
10757
10758
|
onArtifactContentChanged
|
|
10758
10759
|
} = options;
|
|
10759
|
-
const optionsRef =
|
|
10760
|
+
const optionsRef = React16.useRef(options);
|
|
10760
10761
|
optionsRef.current = options;
|
|
10761
|
-
const postToCanvas =
|
|
10762
|
+
const postToCanvas = React16.useCallback((type, payload) => {
|
|
10762
10763
|
const iframe = canvasIframeRef?.current;
|
|
10763
10764
|
if (!iframe?.contentWindow) {
|
|
10764
10765
|
console.warn("[CanvasBridge] Canvas iframe not available");
|
|
@@ -10775,7 +10776,7 @@ function useCanvasBridge(options = {}) {
|
|
|
10775
10776
|
iframe.contentWindow.postMessage(envelope, targetOrigin);
|
|
10776
10777
|
console.log("[CanvasBridge] Sent:", type, payload.artifactId || payload.artifact?.id);
|
|
10777
10778
|
}, [canvasIframeRef, targetOrigin]);
|
|
10778
|
-
|
|
10779
|
+
React16.useEffect(() => {
|
|
10779
10780
|
if (!enabled) return;
|
|
10780
10781
|
const handleMessage = (event) => {
|
|
10781
10782
|
if (targetOrigin !== "*" && event.origin !== targetOrigin) return;
|
|
@@ -10809,19 +10810,19 @@ function useCanvasBridge(options = {}) {
|
|
|
10809
10810
|
window.addEventListener("message", handleMessage);
|
|
10810
10811
|
return () => window.removeEventListener("message", handleMessage);
|
|
10811
10812
|
}, [enabled, targetOrigin]);
|
|
10812
|
-
const notifyArtifactCreated =
|
|
10813
|
+
const notifyArtifactCreated = React16.useCallback((artifact) => {
|
|
10813
10814
|
if (!enabled) return;
|
|
10814
10815
|
postToCanvas("artifact_created", { artifact });
|
|
10815
10816
|
}, [enabled, postToCanvas]);
|
|
10816
|
-
const notifyArtifactUpdated =
|
|
10817
|
+
const notifyArtifactUpdated = React16.useCallback((artifact) => {
|
|
10817
10818
|
if (!enabled) return;
|
|
10818
10819
|
postToCanvas("artifact_updated", { artifact });
|
|
10819
10820
|
}, [enabled, postToCanvas]);
|
|
10820
|
-
const notifyArtifactDeleted =
|
|
10821
|
+
const notifyArtifactDeleted = React16.useCallback((artifactId) => {
|
|
10821
10822
|
if (!enabled) return;
|
|
10822
10823
|
postToCanvas("artifact_deleted", { artifactId });
|
|
10823
10824
|
}, [enabled, postToCanvas]);
|
|
10824
|
-
const syncAllArtifacts =
|
|
10825
|
+
const syncAllArtifacts = React16.useCallback(() => {
|
|
10825
10826
|
if (!enabled) return;
|
|
10826
10827
|
const artifacts = Object.values(useAgentStore.getState().artifacts);
|
|
10827
10828
|
postToCanvas("artifacts_sync", { artifacts });
|
|
@@ -11657,12 +11658,12 @@ function highlightJson(content) {
|
|
|
11657
11658
|
}
|
|
11658
11659
|
return tokens;
|
|
11659
11660
|
}
|
|
11660
|
-
var StreamingJsonDisplay =
|
|
11661
|
+
var StreamingJsonDisplay = React16.memo(function StreamingJsonDisplay2({
|
|
11661
11662
|
content,
|
|
11662
11663
|
className
|
|
11663
11664
|
}) {
|
|
11664
|
-
const jsonContent =
|
|
11665
|
-
const formattedContent =
|
|
11665
|
+
const jsonContent = React16.useMemo(() => extractJsonContent(content), [content]);
|
|
11666
|
+
const formattedContent = React16.useMemo(() => {
|
|
11666
11667
|
try {
|
|
11667
11668
|
const parsed = JSON.parse(jsonContent);
|
|
11668
11669
|
return JSON.stringify(parsed, null, 2);
|
|
@@ -11670,7 +11671,7 @@ var StreamingJsonDisplay = React24.memo(function StreamingJsonDisplay2({
|
|
|
11670
11671
|
return formatPartialJson(jsonContent);
|
|
11671
11672
|
}
|
|
11672
11673
|
}, [jsonContent]);
|
|
11673
|
-
const highlightedTokens =
|
|
11674
|
+
const highlightedTokens = React16.useMemo(() => {
|
|
11674
11675
|
return highlightJson(formattedContent);
|
|
11675
11676
|
}, [formattedContent]);
|
|
11676
11677
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn(
|
|
@@ -11786,7 +11787,7 @@ var collectMediaAssetsFromResult = (result) => {
|
|
|
11786
11787
|
}
|
|
11787
11788
|
return assets;
|
|
11788
11789
|
};
|
|
11789
|
-
var PlanMarkdownContent =
|
|
11790
|
+
var PlanMarkdownContent = React16.memo(function PlanMarkdownContent2({
|
|
11790
11791
|
content,
|
|
11791
11792
|
className = ""
|
|
11792
11793
|
}) {
|
|
@@ -11843,12 +11844,12 @@ var PlanMarkdownContent = React24.memo(function PlanMarkdownContent2({
|
|
|
11843
11844
|
}
|
|
11844
11845
|
) });
|
|
11845
11846
|
});
|
|
11846
|
-
var ImagePreviewModal =
|
|
11847
|
+
var ImagePreviewModal = React16.memo(function ImagePreviewModal2({
|
|
11847
11848
|
src,
|
|
11848
11849
|
onClose,
|
|
11849
11850
|
config
|
|
11850
11851
|
}) {
|
|
11851
|
-
|
|
11852
|
+
React16.useEffect(() => {
|
|
11852
11853
|
const handleKeyDown = (e) => {
|
|
11853
11854
|
if (e.key === "Escape") onClose();
|
|
11854
11855
|
};
|
|
@@ -11907,22 +11908,22 @@ var ImagePreviewModal = React24.memo(function ImagePreviewModal2({
|
|
|
11907
11908
|
}
|
|
11908
11909
|
);
|
|
11909
11910
|
});
|
|
11910
|
-
var StepResultRenderer =
|
|
11911
|
+
var StepResultRenderer = React16.memo(function StepResultRenderer2({
|
|
11911
11912
|
result,
|
|
11912
11913
|
stepType,
|
|
11913
11914
|
toolInput,
|
|
11914
11915
|
stepStatus,
|
|
11915
11916
|
config
|
|
11916
11917
|
}) {
|
|
11917
|
-
const [showDetails, setShowDetails] =
|
|
11918
|
-
const [showPlannedParams, setShowPlannedParams] =
|
|
11919
|
-
const [copied, setCopied] =
|
|
11920
|
-
const [previewImage, setPreviewImage] =
|
|
11921
|
-
const [imgLoaded, setImgLoaded] =
|
|
11922
|
-
const [imgError, setImgError] =
|
|
11923
|
-
const [media, setMedia] =
|
|
11924
|
-
const text3 =
|
|
11925
|
-
|
|
11918
|
+
const [showDetails, setShowDetails] = React16.useState(false);
|
|
11919
|
+
const [showPlannedParams, setShowPlannedParams] = React16.useState(false);
|
|
11920
|
+
const [copied, setCopied] = React16.useState(false);
|
|
11921
|
+
const [previewImage, setPreviewImage] = React16.useState(null);
|
|
11922
|
+
const [imgLoaded, setImgLoaded] = React16.useState({});
|
|
11923
|
+
const [imgError, setImgError] = React16.useState({});
|
|
11924
|
+
const [media, setMedia] = React16.useState([]);
|
|
11925
|
+
const text3 = React16.useMemo(() => extractTextContent(result), [result]);
|
|
11926
|
+
React16.useEffect(() => {
|
|
11926
11927
|
let active = true;
|
|
11927
11928
|
const loadMedia = async () => {
|
|
11928
11929
|
const assets = collectMediaAssetsFromResult(result);
|
|
@@ -11952,11 +11953,11 @@ var StepResultRenderer = React24.memo(function StepResultRenderer2({
|
|
|
11952
11953
|
}, [result, config]);
|
|
11953
11954
|
const isToolCall = stepType === "TOOL_CALL";
|
|
11954
11955
|
const isCompleted = stepStatus === "COMPLETED";
|
|
11955
|
-
const actualParams =
|
|
11956
|
+
const actualParams = React16.useMemo(() => {
|
|
11956
11957
|
if (!result || typeof result !== "object") return null;
|
|
11957
11958
|
return result.actualArguments || result.executedArguments || result.input || null;
|
|
11958
11959
|
}, [result]);
|
|
11959
|
-
const paramsChanged =
|
|
11960
|
+
const paramsChanged = React16.useMemo(() => {
|
|
11960
11961
|
if (!toolInput || !actualParams) return false;
|
|
11961
11962
|
return JSON.stringify(toolInput) !== JSON.stringify(actualParams);
|
|
11962
11963
|
}, [toolInput, actualParams]);
|
|
@@ -12090,7 +12091,7 @@ var StepResultRenderer = React24.memo(function StepResultRenderer2({
|
|
|
12090
12091
|
] })
|
|
12091
12092
|
] });
|
|
12092
12093
|
});
|
|
12093
|
-
var StepItem =
|
|
12094
|
+
var StepItem = React16.memo(function StepItem2({
|
|
12094
12095
|
step,
|
|
12095
12096
|
index,
|
|
12096
12097
|
isWaitingInput,
|
|
@@ -12098,8 +12099,8 @@ var StepItem = React24.memo(function StepItem2({
|
|
|
12098
12099
|
streamingContent,
|
|
12099
12100
|
onHumanInput
|
|
12100
12101
|
}) {
|
|
12101
|
-
const [inputValue, setInputValue] =
|
|
12102
|
-
const [submitting, setSubmitting] =
|
|
12102
|
+
const [inputValue, setInputValue] = React16.useState("");
|
|
12103
|
+
const [submitting, setSubmitting] = React16.useState(false);
|
|
12103
12104
|
const style = getStepStatusStyle(step.status);
|
|
12104
12105
|
const isRunning = step.status === "RUNNING" || isCurrentStep && step.status !== "COMPLETED" && step.status !== "FAILED";
|
|
12105
12106
|
const handleSubmit = async () => {
|
|
@@ -12109,7 +12110,7 @@ var StepItem = React24.memo(function StepItem2({
|
|
|
12109
12110
|
setSubmitting(false);
|
|
12110
12111
|
setInputValue("");
|
|
12111
12112
|
};
|
|
12112
|
-
const executionTime =
|
|
12113
|
+
const executionTime = React16.useMemo(() => {
|
|
12113
12114
|
const s = step;
|
|
12114
12115
|
if (s.startTime && s.endTime) {
|
|
12115
12116
|
const duration = s.endTime - s.startTime;
|
|
@@ -12207,7 +12208,7 @@ var StepItem = React24.memo(function StepItem2({
|
|
|
12207
12208
|
] }) })
|
|
12208
12209
|
] });
|
|
12209
12210
|
});
|
|
12210
|
-
var PlanCard =
|
|
12211
|
+
var PlanCard = React16.memo(function PlanCard2({
|
|
12211
12212
|
plan = {},
|
|
12212
12213
|
isProcessing = false,
|
|
12213
12214
|
waitingStepId,
|
|
@@ -12222,10 +12223,10 @@ var PlanCard = React24.memo(function PlanCard2({
|
|
|
12222
12223
|
onSkip,
|
|
12223
12224
|
onCancel
|
|
12224
12225
|
}) {
|
|
12225
|
-
const [expanded, setExpanded] =
|
|
12226
|
+
const [expanded, setExpanded] = React16.useState(true);
|
|
12226
12227
|
const rawSteps = Array.isArray(plan?.steps) ? plan?.steps : plan?.steps?.steps || [];
|
|
12227
12228
|
const validSteps = rawSteps.filter((step) => step && step.type && !("$ref" in step)) || [];
|
|
12228
|
-
|
|
12229
|
+
React16.useEffect(() => {
|
|
12229
12230
|
console.log("[PlanCard] ===== \u6570\u636E\u8BCA\u65AD =====");
|
|
12230
12231
|
console.log("[PlanCard] plan.status:", plan.status);
|
|
12231
12232
|
console.log("[PlanCard] \u540E\u7AEF completedSteps:", plan.completedSteps, "(\u6CE8\u610F: \u540E\u7AEF\u6709bug\uFF0C\u53EF\u80FD\u591A1)");
|
|
@@ -12241,7 +12242,7 @@ var PlanCard = React24.memo(function PlanCard2({
|
|
|
12241
12242
|
const isPaused = plan.status === "PAUSED";
|
|
12242
12243
|
const isCancelled = plan.status === "CANCELLED";
|
|
12243
12244
|
const hasError = isPaused && !!plan.errorMessage;
|
|
12244
|
-
|
|
12245
|
+
React16.useMemo(() => {
|
|
12245
12246
|
if (hasError) {
|
|
12246
12247
|
const failedIndex = plan.failedStepIndex;
|
|
12247
12248
|
if (failedIndex !== void 0 && failedIndex >= 0) {
|
|
@@ -12251,21 +12252,21 @@ var PlanCard = React24.memo(function PlanCard2({
|
|
|
12251
12252
|
}
|
|
12252
12253
|
return null;
|
|
12253
12254
|
}, [hasError, plan, validSteps]);
|
|
12254
|
-
const completedCount =
|
|
12255
|
+
const completedCount = React16.useMemo(() => {
|
|
12255
12256
|
const count = validSteps.filter((s) => {
|
|
12256
12257
|
const status = (s.status || "").toUpperCase();
|
|
12257
12258
|
return status === "COMPLETED" || status === "SUCCESS" || status === "DONE";
|
|
12258
12259
|
}).length;
|
|
12259
12260
|
return Math.min(count, validSteps.length);
|
|
12260
12261
|
}, [validSteps]);
|
|
12261
|
-
const allStepsCompleted =
|
|
12262
|
+
const allStepsCompleted = React16.useMemo(() => {
|
|
12262
12263
|
if (validSteps.length === 0) return false;
|
|
12263
12264
|
return validSteps.every((s) => {
|
|
12264
12265
|
const status = (s.status || "").toUpperCase();
|
|
12265
12266
|
return status === "COMPLETED" || status === "SKIPPED" || status === "SUCCESS" || status === "DONE";
|
|
12266
12267
|
});
|
|
12267
12268
|
}, [validSteps]);
|
|
12268
|
-
const waitingStep =
|
|
12269
|
+
const waitingStep = React16.useMemo(() => {
|
|
12269
12270
|
if (waitingStepId) {
|
|
12270
12271
|
return validSteps.find((s) => {
|
|
12271
12272
|
const stepId = s.publicId || s.id;
|
|
@@ -12277,7 +12278,7 @@ var PlanCard = React24.memo(function PlanCard2({
|
|
|
12277
12278
|
}
|
|
12278
12279
|
return null;
|
|
12279
12280
|
}, [waitingStepId, validSteps, isExecuting]);
|
|
12280
|
-
const isIntelligentSummary =
|
|
12281
|
+
const isIntelligentSummary = React16.useMemo(() => {
|
|
12281
12282
|
if (!plan.summary) return false;
|
|
12282
12283
|
return !isMechanicalSummary(plan.summary);
|
|
12283
12284
|
}, [plan.summary]);
|
|
@@ -12527,7 +12528,7 @@ function MessageTimeline({
|
|
|
12527
12528
|
renderParallel
|
|
12528
12529
|
}) {
|
|
12529
12530
|
if (!items || items.length === 0) return null;
|
|
12530
|
-
const thoughtItems =
|
|
12531
|
+
const thoughtItems = React16.useMemo(() => items.filter((item) => item.kind === "thought"), [items]);
|
|
12531
12532
|
let thoughtIndex = 0;
|
|
12532
12533
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: className || "mt-3 space-y-3 w-full", children: items.map((item) => {
|
|
12533
12534
|
if (item.kind === "thought") {
|
|
@@ -12661,7 +12662,7 @@ function getDisplayName(key) {
|
|
|
12661
12662
|
if (PARAM_NAMES[key]) return PARAM_NAMES[key];
|
|
12662
12663
|
return key.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/_/g, " ");
|
|
12663
12664
|
}
|
|
12664
|
-
var ParamRow =
|
|
12665
|
+
var ParamRow = React16.memo(function ParamRow2({
|
|
12665
12666
|
name,
|
|
12666
12667
|
value,
|
|
12667
12668
|
isExpanded,
|
|
@@ -12693,8 +12694,8 @@ var ParamRow = React24.memo(function ParamRow2({
|
|
|
12693
12694
|
] }) : value })
|
|
12694
12695
|
] });
|
|
12695
12696
|
});
|
|
12696
|
-
var JsonView =
|
|
12697
|
-
const [copied, setCopied] =
|
|
12697
|
+
var JsonView = React16.memo(function JsonView2({ data }) {
|
|
12698
|
+
const [copied, setCopied] = React16.useState(false);
|
|
12698
12699
|
const json = JSON.stringify(data, null, 2);
|
|
12699
12700
|
const handleCopy = async () => {
|
|
12700
12701
|
await navigator.clipboard.writeText(json);
|
|
@@ -12721,10 +12722,10 @@ function ParameterDisplay({
|
|
|
12721
12722
|
compact = false,
|
|
12722
12723
|
maxCompactItems = 3
|
|
12723
12724
|
}) {
|
|
12724
|
-
const [showJson, setShowJson] =
|
|
12725
|
-
const [expandedTech, setExpandedTech] =
|
|
12726
|
-
const [expandedValues, setExpandedValues] =
|
|
12727
|
-
const { mainParams, techParams } =
|
|
12725
|
+
const [showJson, setShowJson] = React16.useState(false);
|
|
12726
|
+
const [expandedTech, setExpandedTech] = React16.useState(defaultExpanded);
|
|
12727
|
+
const [expandedValues, setExpandedValues] = React16.useState(/* @__PURE__ */ new Set());
|
|
12728
|
+
const { mainParams, techParams } = React16.useMemo(() => {
|
|
12728
12729
|
if (!parameters || typeof parameters !== "object") {
|
|
12729
12730
|
return { mainParams: [], techParams: [] };
|
|
12730
12731
|
}
|
|
@@ -12841,7 +12842,7 @@ function ParameterDisplay({
|
|
|
12841
12842
|
}
|
|
12842
12843
|
function ToolConfirmCard({ toolCall, compact = false }) {
|
|
12843
12844
|
const { removePendingToolCall, updatePendingToolCall, updateMessage, messages, tools } = useAgentStore();
|
|
12844
|
-
const updateToolCallInMessage =
|
|
12845
|
+
const updateToolCallInMessage = React16.useCallback((toolCallId, newStatus) => {
|
|
12845
12846
|
const msg = messages.find((m) => {
|
|
12846
12847
|
const tcs = m.extraData?.tool_calls || [];
|
|
12847
12848
|
return tcs.some((tc) => tc.id === toolCallId);
|
|
@@ -12855,18 +12856,18 @@ function ToolConfirmCard({ toolCall, compact = false }) {
|
|
|
12855
12856
|
});
|
|
12856
12857
|
}
|
|
12857
12858
|
}, [messages, updateMessage]);
|
|
12858
|
-
const [expanded, setExpanded] =
|
|
12859
|
-
const [isEditing, setIsEditing] =
|
|
12860
|
-
const [editedArguments, setEditedArguments] =
|
|
12861
|
-
const [loading, setLoading] =
|
|
12862
|
-
const [error, setError] =
|
|
12863
|
-
const toolDisplayName =
|
|
12859
|
+
const [expanded, setExpanded] = React16.useState(false);
|
|
12860
|
+
const [isEditing, setIsEditing] = React16.useState(false);
|
|
12861
|
+
const [editedArguments, setEditedArguments] = React16.useState("");
|
|
12862
|
+
const [loading, setLoading] = React16.useState(null);
|
|
12863
|
+
const [error, setError] = React16.useState("");
|
|
12864
|
+
const toolDisplayName = React16.useMemo(() => {
|
|
12864
12865
|
const toolName = tools?.find((t) => t.name === toolCall.name)?.displayName;
|
|
12865
12866
|
if (toolName) return toolName;
|
|
12866
12867
|
if (toolCall.displayName) return toolCall.displayName;
|
|
12867
12868
|
return toolCall.name.replace(/^comfy_/, "").replace(/_/g, " ").replace(/\b\w/g, (l) => l.toUpperCase());
|
|
12868
12869
|
}, [toolCall]);
|
|
12869
|
-
const toolDescription =
|
|
12870
|
+
const toolDescription = React16.useMemo(() => {
|
|
12870
12871
|
return generateToolCallDescription(toolCall.name, toolCall.arguments || {});
|
|
12871
12872
|
}, [toolCall.name, toolCall.arguments]);
|
|
12872
12873
|
const hasParams = Object.keys(toolCall.arguments || {}).length > 0;
|
|
@@ -13101,8 +13102,8 @@ function ToolConfirmCard({ toolCall, compact = false }) {
|
|
|
13101
13102
|
] })
|
|
13102
13103
|
] });
|
|
13103
13104
|
}
|
|
13104
|
-
var JsonValue =
|
|
13105
|
-
const [collapsed, setCollapsed] =
|
|
13105
|
+
var JsonValue = React16.memo(function JsonValue2({ value, depth = 0, isLast = true }) {
|
|
13106
|
+
const [collapsed, setCollapsed] = React16.useState(depth > 1);
|
|
13106
13107
|
const indent2 = depth * 16;
|
|
13107
13108
|
if (value === null) {
|
|
13108
13109
|
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-zinc-500", children: "null" });
|
|
@@ -13230,13 +13231,13 @@ var JsonValue = React24.memo(function JsonValue2({ value, depth = 0, isLast = tr
|
|
|
13230
13231
|
}
|
|
13231
13232
|
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-zinc-400", children: String(value) });
|
|
13232
13233
|
});
|
|
13233
|
-
var ElegantJsonRenderer =
|
|
13234
|
+
var ElegantJsonRenderer = React16.memo(function ElegantJsonRenderer2({
|
|
13234
13235
|
data,
|
|
13235
13236
|
title,
|
|
13236
13237
|
defaultExpanded = false
|
|
13237
13238
|
}) {
|
|
13238
|
-
const [expanded, setExpanded] =
|
|
13239
|
-
const [copied, setCopied] =
|
|
13239
|
+
const [expanded, setExpanded] = React16.useState(defaultExpanded);
|
|
13240
|
+
const [copied, setCopied] = React16.useState(false);
|
|
13240
13241
|
const handleCopy = async (e) => {
|
|
13241
13242
|
e.stopPropagation();
|
|
13242
13243
|
try {
|
|
@@ -13283,15 +13284,15 @@ var ElegantJsonRenderer = React24.memo(function ElegantJsonRenderer2({
|
|
|
13283
13284
|
expanded && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-3 bg-zinc-900/30 text-xs font-mono overflow-x-auto max-h-80 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(JsonValue, { value: data, depth: 0 }) })
|
|
13284
13285
|
] });
|
|
13285
13286
|
});
|
|
13286
|
-
var ToolResultRenderer =
|
|
13287
|
+
var ToolResultRenderer = React16.memo(function ToolResultRenderer2({
|
|
13287
13288
|
result,
|
|
13288
13289
|
mediaUrls,
|
|
13289
13290
|
config,
|
|
13290
13291
|
toolCallData,
|
|
13291
13292
|
onOpenArtifact
|
|
13292
13293
|
}) {
|
|
13293
|
-
const [imgLoaded, setImgLoaded] =
|
|
13294
|
-
const [previewUrl, setPreviewUrl] =
|
|
13294
|
+
const [imgLoaded, setImgLoaded] = React16.useState({});
|
|
13295
|
+
const [previewUrl, setPreviewUrl] = React16.useState(null);
|
|
13295
13296
|
const extracted = extractCustomResponses(result);
|
|
13296
13297
|
const customResult = extracted?.map?.((data, index) => {
|
|
13297
13298
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -13309,9 +13310,9 @@ var ToolResultRenderer = React24.memo(function ToolResultRenderer2({
|
|
|
13309
13310
|
const imageUrls = mediaUrls.filter((m) => !m.isVideo);
|
|
13310
13311
|
const videoUrls = mediaUrls.filter((m) => m.isVideo);
|
|
13311
13312
|
const hasMedia = imageUrls.length > 0 || videoUrls.length > 0;
|
|
13312
|
-
const customResponses =
|
|
13313
|
+
const customResponses = React16.useMemo(() => extractCustomResponses(result), [result]);
|
|
13313
13314
|
const hasCustomResponses = customResponses.length > 0;
|
|
13314
|
-
const filteredResult =
|
|
13315
|
+
const filteredResult = React16.useMemo(() => {
|
|
13315
13316
|
if (!result || typeof result !== "object") return result;
|
|
13316
13317
|
const mediaUrlSet = new Set(mediaUrls.map((m) => m.url));
|
|
13317
13318
|
mediaUrls.forEach((m) => {
|
|
@@ -13361,8 +13362,7 @@ var ToolResultRenderer = React24.memo(function ToolResultRenderer2({
|
|
|
13361
13362
|
if (!toolCallData) return void 0;
|
|
13362
13363
|
const resultAny = toolCallData.result;
|
|
13363
13364
|
const metadata = {};
|
|
13364
|
-
|
|
13365
|
-
if (resultAny?.relation?.toolName) metadata.toolName = resultAny.relation.toolName;
|
|
13365
|
+
metadata.toolName = toolCallData?.displayName || toolCallData?.name || "\u5DE5\u5177\u8C03\u7528";
|
|
13366
13366
|
if (toolCallData.arguments) metadata.generationParams = toolCallData.arguments;
|
|
13367
13367
|
if (resultAny?.relation) metadata.relation = resultAny.relation;
|
|
13368
13368
|
if (resultAny?.taskId) metadata.taskId = resultAny.taskId;
|
|
@@ -13392,8 +13392,7 @@ var ToolResultRenderer = React24.memo(function ToolResultRenderer2({
|
|
|
13392
13392
|
{
|
|
13393
13393
|
onClick: (e) => {
|
|
13394
13394
|
e.stopPropagation();
|
|
13395
|
-
const
|
|
13396
|
-
const displayName = resultAny?.relation?.toolName || toolCallData?.name || "\u89C6\u9891\u751F\u6210";
|
|
13395
|
+
const displayName = toolCallData?.displayName || "\u89C6\u9891\u751F\u6210";
|
|
13397
13396
|
onOpenArtifact({
|
|
13398
13397
|
type: "video",
|
|
13399
13398
|
title: `${displayName} #${i + 1}`,
|
|
@@ -13447,8 +13446,7 @@ var ToolResultRenderer = React24.memo(function ToolResultRenderer2({
|
|
|
13447
13446
|
{
|
|
13448
13447
|
onClick: (e) => {
|
|
13449
13448
|
e.stopPropagation();
|
|
13450
|
-
const
|
|
13451
|
-
const displayName = resultAny?.relation?.toolName || toolCallData?.name || "\u56FE\u7247\u751F\u6210";
|
|
13449
|
+
const displayName = toolCallData?.displayName || "\u56FE\u7247\u751F\u6210";
|
|
13452
13450
|
onOpenArtifact({
|
|
13453
13451
|
type: "image",
|
|
13454
13452
|
title: `${displayName} #${i + 1}`,
|
|
@@ -13527,7 +13525,7 @@ var collectMediaAssetsFromResult2 = (result) => {
|
|
|
13527
13525
|
return assets;
|
|
13528
13526
|
};
|
|
13529
13527
|
var INTERNAL_SYSTEM_TOOLS = ["load_skill", "switch_skill", "unload_skill", "call_agent"];
|
|
13530
|
-
var SkillLoadCard =
|
|
13528
|
+
var SkillLoadCard = React16.memo(function SkillLoadCard2({ toolCall }) {
|
|
13531
13529
|
const status = getToolCallStatus(toolCall);
|
|
13532
13530
|
const isPending = status === "pending" || status === "confirmed";
|
|
13533
13531
|
const isSuccess = status === "success";
|
|
@@ -13540,13 +13538,13 @@ var SkillLoadCard = React24.memo(function SkillLoadCard2({ toolCall }) {
|
|
|
13540
13538
|
isSuccess && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-zinc-500", children: "\u6280\u80FD" })
|
|
13541
13539
|
] });
|
|
13542
13540
|
});
|
|
13543
|
-
var ToolCallCard =
|
|
13541
|
+
var ToolCallCard = React16.memo(function ToolCallCard2({
|
|
13544
13542
|
toolCall,
|
|
13545
13543
|
config,
|
|
13546
13544
|
onOpenArtifact
|
|
13547
13545
|
}) {
|
|
13548
|
-
const [headerExpanded, setHeaderExpanded] =
|
|
13549
|
-
const [mediaUrls, setMediaUrls] =
|
|
13546
|
+
const [headerExpanded, setHeaderExpanded] = React16.useState(false);
|
|
13547
|
+
const [mediaUrls, setMediaUrls] = React16.useState([]);
|
|
13550
13548
|
const status = getToolCallStatus(toolCall);
|
|
13551
13549
|
const isPending = status === "pending" || status === "confirmed";
|
|
13552
13550
|
const isSuccess = status === "success";
|
|
@@ -13566,7 +13564,7 @@ var ToolCallCard = React24.memo(function ToolCallCard2({
|
|
|
13566
13564
|
if (toolCall.name === "call_agent") return null;
|
|
13567
13565
|
return /* @__PURE__ */ jsxRuntime.jsx(SkillLoadCard, { toolCall });
|
|
13568
13566
|
}
|
|
13569
|
-
|
|
13567
|
+
React16.useEffect(() => {
|
|
13570
13568
|
if (status === "waiting_confirmation") {
|
|
13571
13569
|
setMediaUrls([]);
|
|
13572
13570
|
return;
|
|
@@ -13617,7 +13615,10 @@ var ToolCallCard = React24.memo(function ToolCallCard2({
|
|
|
13617
13615
|
result: toolCall.result,
|
|
13618
13616
|
mediaUrls,
|
|
13619
13617
|
config,
|
|
13620
|
-
toolCallData:
|
|
13618
|
+
toolCallData: {
|
|
13619
|
+
...toolCall,
|
|
13620
|
+
displayName: toolDisplayName
|
|
13621
|
+
},
|
|
13621
13622
|
defaultExpanded: false,
|
|
13622
13623
|
onOpenArtifact
|
|
13623
13624
|
}
|
|
@@ -13645,7 +13646,7 @@ var ToolCallCard = React24.memo(function ToolCallCard2({
|
|
|
13645
13646
|
] })
|
|
13646
13647
|
] });
|
|
13647
13648
|
});
|
|
13648
|
-
var StreamingToolCard =
|
|
13649
|
+
var StreamingToolCard = React16.memo(function StreamingToolCard2({ toolCall }) {
|
|
13649
13650
|
const status = getToolCallStatus(toolCall);
|
|
13650
13651
|
if (status === "waiting_confirmation") {
|
|
13651
13652
|
const toolCallForCard = {
|
|
@@ -13672,15 +13673,15 @@ var StreamingToolCard = React24.memo(function StreamingToolCard2({ toolCall }) {
|
|
|
13672
13673
|
toolCall.gmtCreate && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-zinc-500 mt-1", children: new Date(toolCall.gmtCreate).toLocaleTimeString("zh-CN", { hour: "2-digit", minute: "2-digit", second: "2-digit" }) })
|
|
13673
13674
|
] });
|
|
13674
13675
|
});
|
|
13675
|
-
var ComponentPendingCard =
|
|
13676
|
+
var ComponentPendingCard = React16.memo(function ComponentPendingCard2({
|
|
13676
13677
|
component,
|
|
13677
13678
|
onResolved
|
|
13678
13679
|
}) {
|
|
13679
13680
|
const { showItemTime } = useAgentStore();
|
|
13680
|
-
const [loading, setLoading] =
|
|
13681
|
-
const [error, setError] =
|
|
13682
|
-
const [collapsed, setCollapsed] =
|
|
13683
|
-
const [jsonValue, setJsonValue] =
|
|
13681
|
+
const [loading, setLoading] = React16.useState(null);
|
|
13682
|
+
const [error, setError] = React16.useState("");
|
|
13683
|
+
const [collapsed, setCollapsed] = React16.useState(false);
|
|
13684
|
+
const [jsonValue, setJsonValue] = React16.useState(() => {
|
|
13684
13685
|
const initialPayload = component.props || component.content || {};
|
|
13685
13686
|
return typeof initialPayload === "string" ? initialPayload : JSON.stringify(initialPayload, null, 2);
|
|
13686
13687
|
});
|
|
@@ -13689,7 +13690,7 @@ var ComponentPendingCard = React24.memo(function ComponentPendingCard2({
|
|
|
13689
13690
|
const components = useComponents();
|
|
13690
13691
|
const registry = components.ComponentRegistry || {};
|
|
13691
13692
|
const normalizeName = (value) => (value || "").toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
13692
|
-
const registryMap =
|
|
13693
|
+
const registryMap = React16.useMemo(() => {
|
|
13693
13694
|
const map3 = /* @__PURE__ */ new Map();
|
|
13694
13695
|
Object.entries(registry).forEach(([key, Comp]) => {
|
|
13695
13696
|
map3.set(key, Comp);
|
|
@@ -13708,7 +13709,7 @@ var ComponentPendingCard = React24.memo(function ComponentPendingCard2({
|
|
|
13708
13709
|
}
|
|
13709
13710
|
return void 0;
|
|
13710
13711
|
})();
|
|
13711
|
-
const resolvedProps =
|
|
13712
|
+
const resolvedProps = React16.useMemo(() => {
|
|
13712
13713
|
const raw = component.props ?? component.content ?? {};
|
|
13713
13714
|
if (typeof raw === "string") {
|
|
13714
13715
|
try {
|
|
@@ -13727,8 +13728,8 @@ var ComponentPendingCard = React24.memo(function ComponentPendingCard2({
|
|
|
13727
13728
|
}, [component]);
|
|
13728
13729
|
console.log("Resolved Props:", resolvedProps);
|
|
13729
13730
|
console.log("Component gmtCreate:", component.gmtCreate, typeof component.gmtCreate);
|
|
13730
|
-
const [localConfirmed, setLocalConfirmed] =
|
|
13731
|
-
const [localCancelled, setLocalCancelled] =
|
|
13731
|
+
const [localConfirmed, setLocalConfirmed] = React16.useState(false);
|
|
13732
|
+
const [localCancelled, setLocalCancelled] = React16.useState(false);
|
|
13732
13733
|
const isActionDisabled = isReadonly || localConfirmed || localCancelled;
|
|
13733
13734
|
const handleConfirm = async () => {
|
|
13734
13735
|
if (isActionDisabled) return;
|
|
@@ -13775,7 +13776,7 @@ var ComponentPendingCard = React24.memo(function ComponentPendingCard2({
|
|
|
13775
13776
|
setLoading(null);
|
|
13776
13777
|
}
|
|
13777
13778
|
};
|
|
13778
|
-
|
|
13779
|
+
React16.useEffect(() => {
|
|
13779
13780
|
const initialPayload = component.props || component.content || {};
|
|
13780
13781
|
setJsonValue(typeof initialPayload === "string" ? initialPayload : JSON.stringify(initialPayload, null, 2));
|
|
13781
13782
|
if (statusUpper === "SUBMITTED" || statusUpper === "CONFIRMED" || statusUpper === "COMPLETED" || statusUpper === "DONE") {
|
|
@@ -13844,8 +13845,8 @@ function extractHtmlTitleSimple(html2) {
|
|
|
13844
13845
|
if (h1Match) return h1Match[1].trim();
|
|
13845
13846
|
return void 0;
|
|
13846
13847
|
}
|
|
13847
|
-
var ThoughtTimelineCard =
|
|
13848
|
-
const [expanded, setExpanded] =
|
|
13848
|
+
var ThoughtTimelineCard = React16.memo(function ThoughtTimelineCard2({ thought, config, isLoading = false, skipImages = false }) {
|
|
13849
|
+
const [expanded, setExpanded] = React16.useState(true);
|
|
13849
13850
|
const { showItemTime } = useAgentStore();
|
|
13850
13851
|
const thoughtType = thought?.type || "";
|
|
13851
13852
|
const excludedTypes = [
|
|
@@ -13868,9 +13869,9 @@ var ThoughtTimelineCard = React24.memo(function ThoughtTimelineCard2({ thought,
|
|
|
13868
13869
|
return null;
|
|
13869
13870
|
}
|
|
13870
13871
|
if (thought?.raw && Array.isArray(thought.raw)) {
|
|
13871
|
-
const hasConfirmationEvent = thought.raw.some((
|
|
13872
|
-
const type =
|
|
13873
|
-
return excludedTypes.includes(type) ||
|
|
13872
|
+
const hasConfirmationEvent = thought.raw.some((r2) => {
|
|
13873
|
+
const type = r2?.type || "";
|
|
13874
|
+
return excludedTypes.includes(type) || r2?.content && (r2.content.includes('"type":"tool_confirmed"') || r2.content.includes('"type":"component_submitted"') || r2.content.includes("\u7528\u6237\u786E\u8BA4\u6267\u884C\u5DE5\u5177\u8C03\u7528"));
|
|
13874
13875
|
});
|
|
13875
13876
|
if (hasConfirmationEvent) {
|
|
13876
13877
|
return null;
|
|
@@ -13880,8 +13881,8 @@ var ThoughtTimelineCard = React24.memo(function ThoughtTimelineCard2({ thought,
|
|
|
13880
13881
|
const withoutJsonImages = removeJsonImageUrls(withoutTags);
|
|
13881
13882
|
const cleaned = sanitizeMarkdownContent(parseThinkingContent(withoutJsonImages));
|
|
13882
13883
|
if (!cleaned || !cleaned.trim()) return null;
|
|
13883
|
-
const lineCount =
|
|
13884
|
-
|
|
13884
|
+
const lineCount = React16.useMemo(() => cleaned.split("\n").length, [cleaned]);
|
|
13885
|
+
React16__namespace.default.useEffect(() => {
|
|
13885
13886
|
if (isLoading) {
|
|
13886
13887
|
setExpanded(true);
|
|
13887
13888
|
} else {
|
|
@@ -14053,7 +14054,7 @@ function AgentIdentity({ agentId, agentName, agentIcon }) {
|
|
|
14053
14054
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium text-zinc-300", children: agentName })
|
|
14054
14055
|
] });
|
|
14055
14056
|
}
|
|
14056
|
-
var HandoffDivider =
|
|
14057
|
+
var HandoffDivider = React16.memo(function HandoffDivider2({
|
|
14057
14058
|
data
|
|
14058
14059
|
}) {
|
|
14059
14060
|
const { agentId, agentName, agentIcon, type, duration, nextAgentName, nextAgentId } = data;
|
|
@@ -14297,8 +14298,8 @@ function getStatusConfig(status, retryCount) {
|
|
|
14297
14298
|
};
|
|
14298
14299
|
}
|
|
14299
14300
|
}
|
|
14300
|
-
var ToolCallMiniCard =
|
|
14301
|
-
const [expanded, setExpanded] =
|
|
14301
|
+
var ToolCallMiniCard = React16.memo(function ToolCallMiniCard2({ toolCall }) {
|
|
14302
|
+
const [expanded, setExpanded] = React16.useState(false);
|
|
14302
14303
|
const statusLower = (toolCall.status || "pending").toLowerCase();
|
|
14303
14304
|
const isPending = statusLower === "pending" || statusLower === "executing";
|
|
14304
14305
|
const isSuccess = statusLower === "completed";
|
|
@@ -14369,30 +14370,30 @@ var ToolCallMiniCard = React24.memo(function ToolCallMiniCard2({ toolCall }) {
|
|
|
14369
14370
|
] })
|
|
14370
14371
|
] });
|
|
14371
14372
|
});
|
|
14372
|
-
var SubAgentPanelCard =
|
|
14373
|
+
var SubAgentPanelCard = React16.memo(function SubAgentPanelCard2({
|
|
14373
14374
|
panel,
|
|
14374
14375
|
onToggleExpand,
|
|
14375
14376
|
isStreaming
|
|
14376
14377
|
}) {
|
|
14377
|
-
const [localExpanded, setLocalExpanded] =
|
|
14378
|
+
const [localExpanded, setLocalExpanded] = React16.useState(panel.isExpanded);
|
|
14378
14379
|
const isExpanded = onToggleExpand ? panel.isExpanded : localExpanded;
|
|
14379
14380
|
const statusConfig = getStatusConfig(panel.status, panel.retryCount);
|
|
14380
|
-
const handleToggle =
|
|
14381
|
+
const handleToggle = React16.useCallback(() => {
|
|
14381
14382
|
if (onToggleExpand) {
|
|
14382
14383
|
onToggleExpand();
|
|
14383
14384
|
} else {
|
|
14384
14385
|
setLocalExpanded((prev) => !prev);
|
|
14385
14386
|
}
|
|
14386
14387
|
}, [onToggleExpand]);
|
|
14387
|
-
const filteredThoughts =
|
|
14388
|
+
const filteredThoughts = React16.useMemo(
|
|
14388
14389
|
() => panel.thoughts.filter((t) => !META_EVENT_TYPES.has(t.type)),
|
|
14389
14390
|
[panel.thoughts]
|
|
14390
14391
|
);
|
|
14391
|
-
const thinkingContent =
|
|
14392
|
+
const thinkingContent = React16.useMemo(
|
|
14392
14393
|
() => extractThinkingFromThoughts(filteredThoughts),
|
|
14393
14394
|
[filteredThoughts]
|
|
14394
14395
|
);
|
|
14395
|
-
const toolCalls =
|
|
14396
|
+
const toolCalls = React16.useMemo(
|
|
14396
14397
|
() => extractToolCallsFromThoughts(filteredThoughts),
|
|
14397
14398
|
[filteredThoughts]
|
|
14398
14399
|
);
|
|
@@ -14473,7 +14474,7 @@ var SubAgentPanelCard = React24.memo(function SubAgentPanelCard2({
|
|
|
14473
14474
|
] })
|
|
14474
14475
|
] });
|
|
14475
14476
|
});
|
|
14476
|
-
var ParallelAgentContainer =
|
|
14477
|
+
var ParallelAgentContainer = React16.memo(function ParallelAgentContainer2({
|
|
14477
14478
|
panels,
|
|
14478
14479
|
parallelSummary,
|
|
14479
14480
|
isStreaming,
|
|
@@ -14524,7 +14525,7 @@ var ParallelAgentContainer = React24.memo(function ParallelAgentContainer2({
|
|
|
14524
14525
|
] }) })
|
|
14525
14526
|
] });
|
|
14526
14527
|
});
|
|
14527
|
-
var MultiAgentThoughts =
|
|
14528
|
+
var MultiAgentThoughts = React16.memo(function MultiAgentThoughts2({
|
|
14528
14529
|
thoughts,
|
|
14529
14530
|
isStreaming,
|
|
14530
14531
|
useStorePanels
|
|
@@ -14535,13 +14536,13 @@ var MultiAgentThoughts = React24.memo(function MultiAgentThoughts2({
|
|
|
14535
14536
|
const toggleSubAgentExpanded = useAgentStore((state) => state.toggleSubAgentExpanded);
|
|
14536
14537
|
const storeHasPanels = Object.keys(storePanels).length > 0;
|
|
14537
14538
|
const shouldUseStore = useStorePanels !== void 0 ? useStorePanels : storeHasPanels;
|
|
14538
|
-
const thoughtBasedPanels =
|
|
14539
|
+
const thoughtBasedPanels = React16.useMemo(() => {
|
|
14539
14540
|
if (shouldUseStore) return {};
|
|
14540
14541
|
return buildPanelsFromThoughts(thoughts);
|
|
14541
14542
|
}, [shouldUseStore, thoughts]);
|
|
14542
14543
|
const activePanels = shouldUseStore ? storePanels : thoughtBasedPanels;
|
|
14543
|
-
const panelList =
|
|
14544
|
-
const handleToggleExpand =
|
|
14544
|
+
const panelList = React16.useMemo(() => Object.values(activePanels), [activePanels]);
|
|
14545
|
+
const handleToggleExpand = React16.useCallback((agentId) => {
|
|
14545
14546
|
if (shouldUseStore) {
|
|
14546
14547
|
toggleSubAgentExpanded(agentId);
|
|
14547
14548
|
}
|
|
@@ -14572,14 +14573,14 @@ var MultiAgentThoughts = React24.memo(function MultiAgentThoughts2({
|
|
|
14572
14573
|
)) });
|
|
14573
14574
|
});
|
|
14574
14575
|
var MultiAgentThoughts_default = MultiAgentThoughts;
|
|
14575
|
-
var ParallelTimelineBlock =
|
|
14576
|
+
var ParallelTimelineBlock = React16.memo(function ParallelTimelineBlock2({
|
|
14576
14577
|
data
|
|
14577
14578
|
}) {
|
|
14578
14579
|
const { thoughts, isStreaming } = data;
|
|
14579
14580
|
const subAgents = useAgentStore((state) => state.subAgents);
|
|
14580
14581
|
const subAgentPanels = useAgentStore((state) => state.multiAgent.subAgentPanels);
|
|
14581
14582
|
const subAgentConfigs = useAgentStore((state) => state.subAgentConfigs);
|
|
14582
|
-
const panels =
|
|
14583
|
+
const panels = React16.useMemo(() => {
|
|
14583
14584
|
const resolveAgentName = (agentId, fallbackName) => {
|
|
14584
14585
|
const fromConfig = subAgentConfigs.find((c) => c.publicId === agentId);
|
|
14585
14586
|
if (fromConfig?.name) return fromConfig.name;
|
|
@@ -14618,7 +14619,7 @@ function useMessageContent({
|
|
|
14618
14619
|
isUser,
|
|
14619
14620
|
hasToolCallImages
|
|
14620
14621
|
}) {
|
|
14621
|
-
const displayContent =
|
|
14622
|
+
const displayContent = React16.useMemo(() => {
|
|
14622
14623
|
const isInvalidContent = (content2) => {
|
|
14623
14624
|
if (!content2) return true;
|
|
14624
14625
|
if (typeof content2 !== "string") return false;
|
|
@@ -14671,7 +14672,7 @@ function useMessageContent({
|
|
|
14671
14672
|
}
|
|
14672
14673
|
return typeof content === "string" ? content : String(content ?? "");
|
|
14673
14674
|
}, [isStreaming, streamingContent, message]);
|
|
14674
|
-
const markdownMedia =
|
|
14675
|
+
const markdownMedia = React16.useMemo(() => {
|
|
14675
14676
|
if (!isUser || !displayContent) {
|
|
14676
14677
|
return { media: [], content: displayContent };
|
|
14677
14678
|
}
|
|
@@ -14686,7 +14687,7 @@ function useMessageContent({
|
|
|
14686
14687
|
const cleaned = displayContent.replace(mediaRegex, "").replace(/\n{3,}/g, "\n\n").trim();
|
|
14687
14688
|
return { media, content: cleaned };
|
|
14688
14689
|
}, [displayContent, isUser]);
|
|
14689
|
-
const effectiveDisplayContent =
|
|
14690
|
+
const effectiveDisplayContent = React16.useMemo(() => {
|
|
14690
14691
|
const baseContent = isUser ? markdownMedia.content || "" : displayContent || "";
|
|
14691
14692
|
if (!baseContent) return "";
|
|
14692
14693
|
if (isUser) return baseContent;
|
|
@@ -14698,7 +14699,7 @@ function useMessageContent({
|
|
|
14698
14699
|
}
|
|
14699
14700
|
return baseContent;
|
|
14700
14701
|
}, [displayContent, hasToolCallImages, isUser, markdownMedia.content]);
|
|
14701
|
-
const sanitizedDisplayContent =
|
|
14702
|
+
const sanitizedDisplayContent = React16.useMemo(
|
|
14702
14703
|
() => sanitizeMarkdownContent(effectiveDisplayContent),
|
|
14703
14704
|
[effectiveDisplayContent]
|
|
14704
14705
|
);
|
|
@@ -14749,7 +14750,7 @@ function useToolCalls({
|
|
|
14749
14750
|
thoughts,
|
|
14750
14751
|
pendingToolCalls = []
|
|
14751
14752
|
}) {
|
|
14752
|
-
const toolCalls =
|
|
14753
|
+
const toolCalls = React16.useMemo(() => {
|
|
14753
14754
|
const toolCallMap = /* @__PURE__ */ new Map();
|
|
14754
14755
|
const normalizeId = (value) => {
|
|
14755
14756
|
if (value === void 0 || value === null) return "";
|
|
@@ -14877,7 +14878,7 @@ function useToolCalls({
|
|
|
14877
14878
|
});
|
|
14878
14879
|
return toolCalls2;
|
|
14879
14880
|
}, [message, isStreaming, thoughts, pendingToolCalls]);
|
|
14880
|
-
const dedupedToolCalls =
|
|
14881
|
+
const dedupedToolCalls = React16.useMemo(() => {
|
|
14881
14882
|
if (!toolCalls || toolCalls.length === 0) return [];
|
|
14882
14883
|
const uniqueCalls = toolCalls.reduce((acc, tc) => {
|
|
14883
14884
|
const id = String(tc.id);
|
|
@@ -14902,9 +14903,9 @@ function useComponents2({
|
|
|
14902
14903
|
thoughts,
|
|
14903
14904
|
isStreaming
|
|
14904
14905
|
}) {
|
|
14905
|
-
const [componentDetailMap, setComponentDetailMap] =
|
|
14906
|
-
const componentDetailRequestedRef =
|
|
14907
|
-
const componentsToRender =
|
|
14906
|
+
const [componentDetailMap, setComponentDetailMap] = React16.useState({});
|
|
14907
|
+
const componentDetailRequestedRef = React16.useRef(/* @__PURE__ */ new Set());
|
|
14908
|
+
const componentsToRender = React16.useMemo(() => {
|
|
14908
14909
|
const extraComponents = message.extraData?.components || [];
|
|
14909
14910
|
const backendId = message.metadata?.backendId;
|
|
14910
14911
|
const messageStatus = (message.status || "").toUpperCase();
|
|
@@ -15017,7 +15018,7 @@ function useComponents2({
|
|
|
15017
15018
|
}
|
|
15018
15019
|
return enrichedPendingComponents.filter((c) => c.messageId === backendId);
|
|
15019
15020
|
}, [message, pendingComponents, pendingComponentsSessionId, thoughts, isStreaming]);
|
|
15020
|
-
|
|
15021
|
+
React16.useEffect(() => {
|
|
15021
15022
|
if (!componentsToRender || componentsToRender.length === 0) return;
|
|
15022
15023
|
componentsToRender.forEach((component) => {
|
|
15023
15024
|
if (!component?.id) return;
|
|
@@ -15044,7 +15045,7 @@ function useComponents2({
|
|
|
15044
15045
|
});
|
|
15045
15046
|
});
|
|
15046
15047
|
}, [componentsToRender]);
|
|
15047
|
-
const effectiveComponents =
|
|
15048
|
+
const effectiveComponents = React16.useMemo(() => {
|
|
15048
15049
|
if (!componentsToRender || componentsToRender.length === 0) return [];
|
|
15049
15050
|
return componentsToRender.map((component) => {
|
|
15050
15051
|
const detail = componentDetailMap[component.id];
|
|
@@ -15061,7 +15062,7 @@ function useComponents2({
|
|
|
15061
15062
|
return { effectiveComponents };
|
|
15062
15063
|
}
|
|
15063
15064
|
function usePlanState({ message, thoughts }) {
|
|
15064
|
-
const planFromThoughts =
|
|
15065
|
+
const planFromThoughts = React16.useMemo(() => {
|
|
15065
15066
|
const extraPlan = message.extraData?.plan;
|
|
15066
15067
|
if (extraPlan && extraPlan.steps && Array.isArray(extraPlan.steps) && extraPlan.steps.length > 0) {
|
|
15067
15068
|
return null;
|
|
@@ -15138,10 +15139,10 @@ function usePlanState({ message, thoughts }) {
|
|
|
15138
15139
|
return plan;
|
|
15139
15140
|
}, [message, thoughts]);
|
|
15140
15141
|
const effectivePlan = message.extraData?.plan || planFromThoughts;
|
|
15141
|
-
const [fullPlan, setFullPlan] =
|
|
15142
|
-
const [planLoading, setPlanLoading] =
|
|
15143
|
-
const [loadedPlanId, setLoadedPlanId] =
|
|
15144
|
-
|
|
15142
|
+
const [fullPlan, setFullPlan] = React16.useState(null);
|
|
15143
|
+
const [planLoading, setPlanLoading] = React16.useState(false);
|
|
15144
|
+
const [loadedPlanId, setLoadedPlanId] = React16.useState(null);
|
|
15145
|
+
React16.useEffect(() => {
|
|
15145
15146
|
if (!effectivePlan) {
|
|
15146
15147
|
setFullPlan(null);
|
|
15147
15148
|
setLoadedPlanId(null);
|
|
@@ -15195,7 +15196,7 @@ var COMPONENT_TAGS_TO_STRIP2 = [
|
|
|
15195
15196
|
"ComponentPreview"
|
|
15196
15197
|
];
|
|
15197
15198
|
function useThinkingContent({ message, thoughts, isStreaming, messageContent }) {
|
|
15198
|
-
return
|
|
15199
|
+
return React16.useMemo(() => {
|
|
15199
15200
|
const historyThoughts = message.extraData?.thoughts || [];
|
|
15200
15201
|
const allThoughts = thoughts && thoughts.length > 0 ? thoughts : historyThoughts;
|
|
15201
15202
|
const hasSubAgents = allThoughts.some((t) => t.agent_id || t.agentId || t.agent_name || t.agentName);
|
|
@@ -15383,7 +15384,7 @@ function useTimelineItems({
|
|
|
15383
15384
|
const mainAgentPublicId = useAgentStore((state) => state.mainAgentPublicId);
|
|
15384
15385
|
const mainAgentName = useAgentStore((state) => state.mainAgentName);
|
|
15385
15386
|
const mainAgentIcon = useAgentStore((state) => state.mainAgentIcon);
|
|
15386
|
-
return
|
|
15387
|
+
return React16.useMemo(() => {
|
|
15387
15388
|
if (isUser) return [];
|
|
15388
15389
|
const resolveAgentName = (agentId, fallbackName) => {
|
|
15389
15390
|
if (!agentId) return mainAgentName || "Assistant";
|
|
@@ -15799,7 +15800,111 @@ function __insertCSS(code3) {
|
|
|
15799
15800
|
head.appendChild(style);
|
|
15800
15801
|
style.styleSheet ? style.styleSheet.cssText = code3 : style.appendChild(document.createTextNode(code3));
|
|
15801
15802
|
}
|
|
15802
|
-
|
|
15803
|
+
var getAsset = (type) => {
|
|
15804
|
+
switch (type) {
|
|
15805
|
+
case "success":
|
|
15806
|
+
return SuccessIcon;
|
|
15807
|
+
case "info":
|
|
15808
|
+
return InfoIcon;
|
|
15809
|
+
case "warning":
|
|
15810
|
+
return WarningIcon;
|
|
15811
|
+
case "error":
|
|
15812
|
+
return ErrorIcon;
|
|
15813
|
+
default:
|
|
15814
|
+
return null;
|
|
15815
|
+
}
|
|
15816
|
+
};
|
|
15817
|
+
var bars = Array(12).fill(0);
|
|
15818
|
+
var Loader = ({ visible, className }) => {
|
|
15819
|
+
return /* @__PURE__ */ React16__namespace.default.createElement("div", {
|
|
15820
|
+
className: [
|
|
15821
|
+
"sonner-loading-wrapper",
|
|
15822
|
+
className
|
|
15823
|
+
].filter(Boolean).join(" "),
|
|
15824
|
+
"data-visible": visible
|
|
15825
|
+
}, /* @__PURE__ */ React16__namespace.default.createElement("div", {
|
|
15826
|
+
className: "sonner-spinner"
|
|
15827
|
+
}, bars.map((_, i) => /* @__PURE__ */ React16__namespace.default.createElement("div", {
|
|
15828
|
+
className: "sonner-loading-bar",
|
|
15829
|
+
key: `spinner-bar-${i}`
|
|
15830
|
+
}))));
|
|
15831
|
+
};
|
|
15832
|
+
var SuccessIcon = /* @__PURE__ */ React16__namespace.default.createElement("svg", {
|
|
15833
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
15834
|
+
viewBox: "0 0 20 20",
|
|
15835
|
+
fill: "currentColor",
|
|
15836
|
+
height: "20",
|
|
15837
|
+
width: "20"
|
|
15838
|
+
}, /* @__PURE__ */ React16__namespace.default.createElement("path", {
|
|
15839
|
+
fillRule: "evenodd",
|
|
15840
|
+
d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",
|
|
15841
|
+
clipRule: "evenodd"
|
|
15842
|
+
}));
|
|
15843
|
+
var WarningIcon = /* @__PURE__ */ React16__namespace.default.createElement("svg", {
|
|
15844
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
15845
|
+
viewBox: "0 0 24 24",
|
|
15846
|
+
fill: "currentColor",
|
|
15847
|
+
height: "20",
|
|
15848
|
+
width: "20"
|
|
15849
|
+
}, /* @__PURE__ */ React16__namespace.default.createElement("path", {
|
|
15850
|
+
fillRule: "evenodd",
|
|
15851
|
+
d: "M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",
|
|
15852
|
+
clipRule: "evenodd"
|
|
15853
|
+
}));
|
|
15854
|
+
var InfoIcon = /* @__PURE__ */ React16__namespace.default.createElement("svg", {
|
|
15855
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
15856
|
+
viewBox: "0 0 20 20",
|
|
15857
|
+
fill: "currentColor",
|
|
15858
|
+
height: "20",
|
|
15859
|
+
width: "20"
|
|
15860
|
+
}, /* @__PURE__ */ React16__namespace.default.createElement("path", {
|
|
15861
|
+
fillRule: "evenodd",
|
|
15862
|
+
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",
|
|
15863
|
+
clipRule: "evenodd"
|
|
15864
|
+
}));
|
|
15865
|
+
var ErrorIcon = /* @__PURE__ */ React16__namespace.default.createElement("svg", {
|
|
15866
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
15867
|
+
viewBox: "0 0 20 20",
|
|
15868
|
+
fill: "currentColor",
|
|
15869
|
+
height: "20",
|
|
15870
|
+
width: "20"
|
|
15871
|
+
}, /* @__PURE__ */ React16__namespace.default.createElement("path", {
|
|
15872
|
+
fillRule: "evenodd",
|
|
15873
|
+
d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",
|
|
15874
|
+
clipRule: "evenodd"
|
|
15875
|
+
}));
|
|
15876
|
+
var CloseIcon = /* @__PURE__ */ React16__namespace.default.createElement("svg", {
|
|
15877
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
15878
|
+
width: "12",
|
|
15879
|
+
height: "12",
|
|
15880
|
+
viewBox: "0 0 24 24",
|
|
15881
|
+
fill: "none",
|
|
15882
|
+
stroke: "currentColor",
|
|
15883
|
+
strokeWidth: "1.5",
|
|
15884
|
+
strokeLinecap: "round",
|
|
15885
|
+
strokeLinejoin: "round"
|
|
15886
|
+
}, /* @__PURE__ */ React16__namespace.default.createElement("line", {
|
|
15887
|
+
x1: "18",
|
|
15888
|
+
y1: "6",
|
|
15889
|
+
x2: "6",
|
|
15890
|
+
y2: "18"
|
|
15891
|
+
}), /* @__PURE__ */ React16__namespace.default.createElement("line", {
|
|
15892
|
+
x1: "6",
|
|
15893
|
+
y1: "6",
|
|
15894
|
+
x2: "18",
|
|
15895
|
+
y2: "18"
|
|
15896
|
+
}));
|
|
15897
|
+
var useIsDocumentHidden = () => {
|
|
15898
|
+
const [isDocumentHidden, setIsDocumentHidden] = React16__namespace.default.useState(document.hidden);
|
|
15899
|
+
React16__namespace.default.useEffect(() => {
|
|
15900
|
+
const callback = () => {
|
|
15901
|
+
setIsDocumentHidden(document.hidden);
|
|
15902
|
+
};
|
|
15903
|
+
document.addEventListener("visibilitychange", callback);
|
|
15904
|
+
return () => window.removeEventListener("visibilitychange", callback);
|
|
15905
|
+
}, []);
|
|
15906
|
+
return isDocumentHidden;
|
|
15907
|
+
};
|
|
15803
15908
|
var toastsCounter = 1;
|
|
15804
15909
|
var Observer = class {
|
|
15805
15910
|
constructor() {
|
|
@@ -15940,7 +16045,7 @@ var Observer = class {
|
|
|
15940
16045
|
"resolve",
|
|
15941
16046
|
response
|
|
15942
16047
|
];
|
|
15943
|
-
const isReactElementResponse =
|
|
16048
|
+
const isReactElementResponse = React16__namespace.default.isValidElement(response);
|
|
15944
16049
|
if (isReactElementResponse) {
|
|
15945
16050
|
shouldDismiss = false;
|
|
15946
16051
|
this.create({
|
|
@@ -15952,7 +16057,7 @@ var Observer = class {
|
|
|
15952
16057
|
shouldDismiss = false;
|
|
15953
16058
|
const promiseData = typeof data.error === "function" ? await data.error(`HTTP error! status: ${response.status}`) : data.error;
|
|
15954
16059
|
const description = typeof data.description === "function" ? await data.description(`HTTP error! status: ${response.status}`) : data.description;
|
|
15955
|
-
const isExtendedResult = typeof promiseData === "object" && !
|
|
16060
|
+
const isExtendedResult = typeof promiseData === "object" && !React16__namespace.default.isValidElement(promiseData);
|
|
15956
16061
|
const toastSettings = isExtendedResult ? promiseData : {
|
|
15957
16062
|
message: promiseData
|
|
15958
16063
|
};
|
|
@@ -15966,7 +16071,7 @@ var Observer = class {
|
|
|
15966
16071
|
shouldDismiss = false;
|
|
15967
16072
|
const promiseData = typeof data.error === "function" ? await data.error(response) : data.error;
|
|
15968
16073
|
const description = typeof data.description === "function" ? await data.description(response) : data.description;
|
|
15969
|
-
const isExtendedResult = typeof promiseData === "object" && !
|
|
16074
|
+
const isExtendedResult = typeof promiseData === "object" && !React16__namespace.default.isValidElement(promiseData);
|
|
15970
16075
|
const toastSettings = isExtendedResult ? promiseData : {
|
|
15971
16076
|
message: promiseData
|
|
15972
16077
|
};
|
|
@@ -15980,7 +16085,7 @@ var Observer = class {
|
|
|
15980
16085
|
shouldDismiss = false;
|
|
15981
16086
|
const promiseData = typeof data.success === "function" ? await data.success(response) : data.success;
|
|
15982
16087
|
const description = typeof data.description === "function" ? await data.description(response) : data.description;
|
|
15983
|
-
const isExtendedResult = typeof promiseData === "object" && !
|
|
16088
|
+
const isExtendedResult = typeof promiseData === "object" && !React16__namespace.default.isValidElement(promiseData);
|
|
15984
16089
|
const toastSettings = isExtendedResult ? promiseData : {
|
|
15985
16090
|
message: promiseData
|
|
15986
16091
|
};
|
|
@@ -16000,7 +16105,7 @@ var Observer = class {
|
|
|
16000
16105
|
shouldDismiss = false;
|
|
16001
16106
|
const promiseData = typeof data.error === "function" ? await data.error(error) : data.error;
|
|
16002
16107
|
const description = typeof data.description === "function" ? await data.description(error) : data.description;
|
|
16003
|
-
const isExtendedResult = typeof promiseData === "object" && !
|
|
16108
|
+
const isExtendedResult = typeof promiseData === "object" && !React16__namespace.default.isValidElement(promiseData);
|
|
16004
16109
|
const toastSettings = isExtendedResult ? promiseData : {
|
|
16005
16110
|
message: promiseData
|
|
16006
16111
|
};
|
|
@@ -16029,10 +16134,10 @@ var Observer = class {
|
|
|
16029
16134
|
});
|
|
16030
16135
|
}
|
|
16031
16136
|
};
|
|
16032
|
-
this.custom = (
|
|
16137
|
+
this.custom = (jsx63, data) => {
|
|
16033
16138
|
const id = (data == null ? void 0 : data.id) || toastsCounter++;
|
|
16034
16139
|
this.create({
|
|
16035
|
-
jsx:
|
|
16140
|
+
jsx: jsx63(id),
|
|
16036
16141
|
id,
|
|
16037
16142
|
...data
|
|
16038
16143
|
});
|
|
@@ -16077,20 +16182,710 @@ var toast = Object.assign(basicToast, {
|
|
|
16077
16182
|
getToasts
|
|
16078
16183
|
});
|
|
16079
16184
|
__insertCSS("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");
|
|
16080
|
-
|
|
16185
|
+
function isAction(action) {
|
|
16186
|
+
return action.label !== void 0;
|
|
16187
|
+
}
|
|
16188
|
+
var VISIBLE_TOASTS_AMOUNT = 3;
|
|
16189
|
+
var VIEWPORT_OFFSET = "24px";
|
|
16190
|
+
var MOBILE_VIEWPORT_OFFSET = "16px";
|
|
16191
|
+
var TOAST_LIFETIME = 4e3;
|
|
16192
|
+
var TOAST_WIDTH = 356;
|
|
16193
|
+
var GAP = 14;
|
|
16194
|
+
var SWIPE_THRESHOLD = 45;
|
|
16195
|
+
var TIME_BEFORE_UNMOUNT = 200;
|
|
16196
|
+
function cn2(...classes) {
|
|
16197
|
+
return classes.filter(Boolean).join(" ");
|
|
16198
|
+
}
|
|
16199
|
+
function getDefaultSwipeDirections(position) {
|
|
16200
|
+
const [y, x] = position.split("-");
|
|
16201
|
+
const directions = [];
|
|
16202
|
+
if (y) {
|
|
16203
|
+
directions.push(y);
|
|
16204
|
+
}
|
|
16205
|
+
if (x) {
|
|
16206
|
+
directions.push(x);
|
|
16207
|
+
}
|
|
16208
|
+
return directions;
|
|
16209
|
+
}
|
|
16210
|
+
var Toast = (props) => {
|
|
16211
|
+
var _toast_classNames, _toast_classNames1, _toast_classNames2, _toast_classNames3, _toast_classNames4, _toast_classNames5, _toast_classNames6, _toast_classNames7, _toast_classNames8;
|
|
16212
|
+
const { invert: ToasterInvert, toast: toast2, unstyled, interacting, setHeights, visibleToasts, heights, index, toasts, expanded, removeToast, defaultRichColors, closeButton: closeButtonFromToaster, style, cancelButtonStyle, actionButtonStyle, className = "", descriptionClassName = "", duration: durationFromToaster, position, gap, expandByDefault, classNames, icons, closeButtonAriaLabel = "Close toast" } = props;
|
|
16213
|
+
const [swipeDirection, setSwipeDirection] = React16__namespace.default.useState(null);
|
|
16214
|
+
const [swipeOutDirection, setSwipeOutDirection] = React16__namespace.default.useState(null);
|
|
16215
|
+
const [mounted, setMounted] = React16__namespace.default.useState(false);
|
|
16216
|
+
const [removed, setRemoved] = React16__namespace.default.useState(false);
|
|
16217
|
+
const [swiping, setSwiping] = React16__namespace.default.useState(false);
|
|
16218
|
+
const [swipeOut, setSwipeOut] = React16__namespace.default.useState(false);
|
|
16219
|
+
const [isSwiped, setIsSwiped] = React16__namespace.default.useState(false);
|
|
16220
|
+
const [offsetBeforeRemove, setOffsetBeforeRemove] = React16__namespace.default.useState(0);
|
|
16221
|
+
const [initialHeight, setInitialHeight] = React16__namespace.default.useState(0);
|
|
16222
|
+
const remainingTime = React16__namespace.default.useRef(toast2.duration || durationFromToaster || TOAST_LIFETIME);
|
|
16223
|
+
const dragStartTime = React16__namespace.default.useRef(null);
|
|
16224
|
+
const toastRef = React16__namespace.default.useRef(null);
|
|
16225
|
+
const isFront = index === 0;
|
|
16226
|
+
const isVisible = index + 1 <= visibleToasts;
|
|
16227
|
+
const toastType = toast2.type;
|
|
16228
|
+
const dismissible = toast2.dismissible !== false;
|
|
16229
|
+
const toastClassname = toast2.className || "";
|
|
16230
|
+
const toastDescriptionClassname = toast2.descriptionClassName || "";
|
|
16231
|
+
const heightIndex = React16__namespace.default.useMemo(() => heights.findIndex((height) => height.toastId === toast2.id) || 0, [
|
|
16232
|
+
heights,
|
|
16233
|
+
toast2.id
|
|
16234
|
+
]);
|
|
16235
|
+
const closeButton = React16__namespace.default.useMemo(() => {
|
|
16236
|
+
var _toast_closeButton;
|
|
16237
|
+
return (_toast_closeButton = toast2.closeButton) != null ? _toast_closeButton : closeButtonFromToaster;
|
|
16238
|
+
}, [
|
|
16239
|
+
toast2.closeButton,
|
|
16240
|
+
closeButtonFromToaster
|
|
16241
|
+
]);
|
|
16242
|
+
const duration = React16__namespace.default.useMemo(() => toast2.duration || durationFromToaster || TOAST_LIFETIME, [
|
|
16243
|
+
toast2.duration,
|
|
16244
|
+
durationFromToaster
|
|
16245
|
+
]);
|
|
16246
|
+
const closeTimerStartTimeRef = React16__namespace.default.useRef(0);
|
|
16247
|
+
const offset = React16__namespace.default.useRef(0);
|
|
16248
|
+
const lastCloseTimerStartTimeRef = React16__namespace.default.useRef(0);
|
|
16249
|
+
const pointerStartRef = React16__namespace.default.useRef(null);
|
|
16250
|
+
const [y, x] = position.split("-");
|
|
16251
|
+
const toastsHeightBefore = React16__namespace.default.useMemo(() => {
|
|
16252
|
+
return heights.reduce((prev, curr, reducerIndex) => {
|
|
16253
|
+
if (reducerIndex >= heightIndex) {
|
|
16254
|
+
return prev;
|
|
16255
|
+
}
|
|
16256
|
+
return prev + curr.height;
|
|
16257
|
+
}, 0);
|
|
16258
|
+
}, [
|
|
16259
|
+
heights,
|
|
16260
|
+
heightIndex
|
|
16261
|
+
]);
|
|
16262
|
+
const isDocumentHidden = useIsDocumentHidden();
|
|
16263
|
+
const invert = toast2.invert || ToasterInvert;
|
|
16264
|
+
const disabled = toastType === "loading";
|
|
16265
|
+
offset.current = React16__namespace.default.useMemo(() => heightIndex * gap + toastsHeightBefore, [
|
|
16266
|
+
heightIndex,
|
|
16267
|
+
toastsHeightBefore
|
|
16268
|
+
]);
|
|
16269
|
+
React16__namespace.default.useEffect(() => {
|
|
16270
|
+
remainingTime.current = duration;
|
|
16271
|
+
}, [
|
|
16272
|
+
duration
|
|
16273
|
+
]);
|
|
16274
|
+
React16__namespace.default.useEffect(() => {
|
|
16275
|
+
setMounted(true);
|
|
16276
|
+
}, []);
|
|
16277
|
+
React16__namespace.default.useEffect(() => {
|
|
16278
|
+
const toastNode = toastRef.current;
|
|
16279
|
+
if (toastNode) {
|
|
16280
|
+
const height = toastNode.getBoundingClientRect().height;
|
|
16281
|
+
setInitialHeight(height);
|
|
16282
|
+
setHeights((h) => [
|
|
16283
|
+
{
|
|
16284
|
+
toastId: toast2.id,
|
|
16285
|
+
height,
|
|
16286
|
+
position: toast2.position
|
|
16287
|
+
},
|
|
16288
|
+
...h
|
|
16289
|
+
]);
|
|
16290
|
+
return () => setHeights((h) => h.filter((height2) => height2.toastId !== toast2.id));
|
|
16291
|
+
}
|
|
16292
|
+
}, [
|
|
16293
|
+
setHeights,
|
|
16294
|
+
toast2.id
|
|
16295
|
+
]);
|
|
16296
|
+
React16__namespace.default.useLayoutEffect(() => {
|
|
16297
|
+
if (!mounted) return;
|
|
16298
|
+
const toastNode = toastRef.current;
|
|
16299
|
+
const originalHeight = toastNode.style.height;
|
|
16300
|
+
toastNode.style.height = "auto";
|
|
16301
|
+
const newHeight = toastNode.getBoundingClientRect().height;
|
|
16302
|
+
toastNode.style.height = originalHeight;
|
|
16303
|
+
setInitialHeight(newHeight);
|
|
16304
|
+
setHeights((heights2) => {
|
|
16305
|
+
const alreadyExists = heights2.find((height) => height.toastId === toast2.id);
|
|
16306
|
+
if (!alreadyExists) {
|
|
16307
|
+
return [
|
|
16308
|
+
{
|
|
16309
|
+
toastId: toast2.id,
|
|
16310
|
+
height: newHeight,
|
|
16311
|
+
position: toast2.position
|
|
16312
|
+
},
|
|
16313
|
+
...heights2
|
|
16314
|
+
];
|
|
16315
|
+
} else {
|
|
16316
|
+
return heights2.map((height) => height.toastId === toast2.id ? {
|
|
16317
|
+
...height,
|
|
16318
|
+
height: newHeight
|
|
16319
|
+
} : height);
|
|
16320
|
+
}
|
|
16321
|
+
});
|
|
16322
|
+
}, [
|
|
16323
|
+
mounted,
|
|
16324
|
+
toast2.title,
|
|
16325
|
+
toast2.description,
|
|
16326
|
+
setHeights,
|
|
16327
|
+
toast2.id,
|
|
16328
|
+
toast2.jsx,
|
|
16329
|
+
toast2.action,
|
|
16330
|
+
toast2.cancel
|
|
16331
|
+
]);
|
|
16332
|
+
const deleteToast = React16__namespace.default.useCallback(() => {
|
|
16333
|
+
setRemoved(true);
|
|
16334
|
+
setOffsetBeforeRemove(offset.current);
|
|
16335
|
+
setHeights((h) => h.filter((height) => height.toastId !== toast2.id));
|
|
16336
|
+
setTimeout(() => {
|
|
16337
|
+
removeToast(toast2);
|
|
16338
|
+
}, TIME_BEFORE_UNMOUNT);
|
|
16339
|
+
}, [
|
|
16340
|
+
toast2,
|
|
16341
|
+
removeToast,
|
|
16342
|
+
setHeights,
|
|
16343
|
+
offset
|
|
16344
|
+
]);
|
|
16345
|
+
React16__namespace.default.useEffect(() => {
|
|
16346
|
+
if (toast2.promise && toastType === "loading" || toast2.duration === Infinity || toast2.type === "loading") return;
|
|
16347
|
+
let timeoutId;
|
|
16348
|
+
const pauseTimer = () => {
|
|
16349
|
+
if (lastCloseTimerStartTimeRef.current < closeTimerStartTimeRef.current) {
|
|
16350
|
+
const elapsedTime = (/* @__PURE__ */ new Date()).getTime() - closeTimerStartTimeRef.current;
|
|
16351
|
+
remainingTime.current = remainingTime.current - elapsedTime;
|
|
16352
|
+
}
|
|
16353
|
+
lastCloseTimerStartTimeRef.current = (/* @__PURE__ */ new Date()).getTime();
|
|
16354
|
+
};
|
|
16355
|
+
const startTimer = () => {
|
|
16356
|
+
if (remainingTime.current === Infinity) return;
|
|
16357
|
+
closeTimerStartTimeRef.current = (/* @__PURE__ */ new Date()).getTime();
|
|
16358
|
+
timeoutId = setTimeout(() => {
|
|
16359
|
+
toast2.onAutoClose == null ? void 0 : toast2.onAutoClose.call(toast2, toast2);
|
|
16360
|
+
deleteToast();
|
|
16361
|
+
}, remainingTime.current);
|
|
16362
|
+
};
|
|
16363
|
+
if (expanded || interacting || isDocumentHidden) {
|
|
16364
|
+
pauseTimer();
|
|
16365
|
+
} else {
|
|
16366
|
+
startTimer();
|
|
16367
|
+
}
|
|
16368
|
+
return () => clearTimeout(timeoutId);
|
|
16369
|
+
}, [
|
|
16370
|
+
expanded,
|
|
16371
|
+
interacting,
|
|
16372
|
+
toast2,
|
|
16373
|
+
toastType,
|
|
16374
|
+
isDocumentHidden,
|
|
16375
|
+
deleteToast
|
|
16376
|
+
]);
|
|
16377
|
+
React16__namespace.default.useEffect(() => {
|
|
16378
|
+
if (toast2.delete) {
|
|
16379
|
+
deleteToast();
|
|
16380
|
+
toast2.onDismiss == null ? void 0 : toast2.onDismiss.call(toast2, toast2);
|
|
16381
|
+
}
|
|
16382
|
+
}, [
|
|
16383
|
+
deleteToast,
|
|
16384
|
+
toast2.delete
|
|
16385
|
+
]);
|
|
16386
|
+
function getLoadingIcon() {
|
|
16387
|
+
var _toast_classNames9;
|
|
16388
|
+
if (icons == null ? void 0 : icons.loading) {
|
|
16389
|
+
var _toast_classNames12;
|
|
16390
|
+
return /* @__PURE__ */ React16__namespace.default.createElement("div", {
|
|
16391
|
+
className: cn2(classNames == null ? void 0 : classNames.loader, toast2 == null ? void 0 : (_toast_classNames12 = toast2.classNames) == null ? void 0 : _toast_classNames12.loader, "sonner-loader"),
|
|
16392
|
+
"data-visible": toastType === "loading"
|
|
16393
|
+
}, icons.loading);
|
|
16394
|
+
}
|
|
16395
|
+
return /* @__PURE__ */ React16__namespace.default.createElement(Loader, {
|
|
16396
|
+
className: cn2(classNames == null ? void 0 : classNames.loader, toast2 == null ? void 0 : (_toast_classNames9 = toast2.classNames) == null ? void 0 : _toast_classNames9.loader),
|
|
16397
|
+
visible: toastType === "loading"
|
|
16398
|
+
});
|
|
16399
|
+
}
|
|
16400
|
+
const icon = toast2.icon || (icons == null ? void 0 : icons[toastType]) || getAsset(toastType);
|
|
16401
|
+
var _toast_richColors, _icons_close;
|
|
16402
|
+
return /* @__PURE__ */ React16__namespace.default.createElement("li", {
|
|
16403
|
+
tabIndex: 0,
|
|
16404
|
+
ref: toastRef,
|
|
16405
|
+
className: cn2(className, toastClassname, classNames == null ? void 0 : classNames.toast, toast2 == null ? void 0 : (_toast_classNames = toast2.classNames) == null ? void 0 : _toast_classNames.toast, classNames == null ? void 0 : classNames.default, classNames == null ? void 0 : classNames[toastType], toast2 == null ? void 0 : (_toast_classNames1 = toast2.classNames) == null ? void 0 : _toast_classNames1[toastType]),
|
|
16406
|
+
"data-sonner-toast": "",
|
|
16407
|
+
"data-rich-colors": (_toast_richColors = toast2.richColors) != null ? _toast_richColors : defaultRichColors,
|
|
16408
|
+
"data-styled": !Boolean(toast2.jsx || toast2.unstyled || unstyled),
|
|
16409
|
+
"data-mounted": mounted,
|
|
16410
|
+
"data-promise": Boolean(toast2.promise),
|
|
16411
|
+
"data-swiped": isSwiped,
|
|
16412
|
+
"data-removed": removed,
|
|
16413
|
+
"data-visible": isVisible,
|
|
16414
|
+
"data-y-position": y,
|
|
16415
|
+
"data-x-position": x,
|
|
16416
|
+
"data-index": index,
|
|
16417
|
+
"data-front": isFront,
|
|
16418
|
+
"data-swiping": swiping,
|
|
16419
|
+
"data-dismissible": dismissible,
|
|
16420
|
+
"data-type": toastType,
|
|
16421
|
+
"data-invert": invert,
|
|
16422
|
+
"data-swipe-out": swipeOut,
|
|
16423
|
+
"data-swipe-direction": swipeOutDirection,
|
|
16424
|
+
"data-expanded": Boolean(expanded || expandByDefault && mounted),
|
|
16425
|
+
"data-testid": toast2.testId,
|
|
16426
|
+
style: {
|
|
16427
|
+
"--index": index,
|
|
16428
|
+
"--toasts-before": index,
|
|
16429
|
+
"--z-index": toasts.length - index,
|
|
16430
|
+
"--offset": `${removed ? offsetBeforeRemove : offset.current}px`,
|
|
16431
|
+
"--initial-height": expandByDefault ? "auto" : `${initialHeight}px`,
|
|
16432
|
+
...style,
|
|
16433
|
+
...toast2.style
|
|
16434
|
+
},
|
|
16435
|
+
onDragEnd: () => {
|
|
16436
|
+
setSwiping(false);
|
|
16437
|
+
setSwipeDirection(null);
|
|
16438
|
+
pointerStartRef.current = null;
|
|
16439
|
+
},
|
|
16440
|
+
onPointerDown: (event) => {
|
|
16441
|
+
if (event.button === 2) return;
|
|
16442
|
+
if (disabled || !dismissible) return;
|
|
16443
|
+
dragStartTime.current = /* @__PURE__ */ new Date();
|
|
16444
|
+
setOffsetBeforeRemove(offset.current);
|
|
16445
|
+
event.target.setPointerCapture(event.pointerId);
|
|
16446
|
+
if (event.target.tagName === "BUTTON") return;
|
|
16447
|
+
setSwiping(true);
|
|
16448
|
+
pointerStartRef.current = {
|
|
16449
|
+
x: event.clientX,
|
|
16450
|
+
y: event.clientY
|
|
16451
|
+
};
|
|
16452
|
+
},
|
|
16453
|
+
onPointerUp: () => {
|
|
16454
|
+
var _toastRef_current, _toastRef_current1, _dragStartTime_current;
|
|
16455
|
+
if (swipeOut || !dismissible) return;
|
|
16456
|
+
pointerStartRef.current = null;
|
|
16457
|
+
const swipeAmountX = Number(((_toastRef_current = toastRef.current) == null ? void 0 : _toastRef_current.style.getPropertyValue("--swipe-amount-x").replace("px", "")) || 0);
|
|
16458
|
+
const swipeAmountY = Number(((_toastRef_current1 = toastRef.current) == null ? void 0 : _toastRef_current1.style.getPropertyValue("--swipe-amount-y").replace("px", "")) || 0);
|
|
16459
|
+
const timeTaken = (/* @__PURE__ */ new Date()).getTime() - ((_dragStartTime_current = dragStartTime.current) == null ? void 0 : _dragStartTime_current.getTime());
|
|
16460
|
+
const swipeAmount = swipeDirection === "x" ? swipeAmountX : swipeAmountY;
|
|
16461
|
+
const velocity = Math.abs(swipeAmount) / timeTaken;
|
|
16462
|
+
if (Math.abs(swipeAmount) >= SWIPE_THRESHOLD || velocity > 0.11) {
|
|
16463
|
+
setOffsetBeforeRemove(offset.current);
|
|
16464
|
+
toast2.onDismiss == null ? void 0 : toast2.onDismiss.call(toast2, toast2);
|
|
16465
|
+
if (swipeDirection === "x") {
|
|
16466
|
+
setSwipeOutDirection(swipeAmountX > 0 ? "right" : "left");
|
|
16467
|
+
} else {
|
|
16468
|
+
setSwipeOutDirection(swipeAmountY > 0 ? "down" : "up");
|
|
16469
|
+
}
|
|
16470
|
+
deleteToast();
|
|
16471
|
+
setSwipeOut(true);
|
|
16472
|
+
return;
|
|
16473
|
+
} else {
|
|
16474
|
+
var _toastRef_current2, _toastRef_current3;
|
|
16475
|
+
(_toastRef_current2 = toastRef.current) == null ? void 0 : _toastRef_current2.style.setProperty("--swipe-amount-x", `0px`);
|
|
16476
|
+
(_toastRef_current3 = toastRef.current) == null ? void 0 : _toastRef_current3.style.setProperty("--swipe-amount-y", `0px`);
|
|
16477
|
+
}
|
|
16478
|
+
setIsSwiped(false);
|
|
16479
|
+
setSwiping(false);
|
|
16480
|
+
setSwipeDirection(null);
|
|
16481
|
+
},
|
|
16482
|
+
onPointerMove: (event) => {
|
|
16483
|
+
var _window_getSelection, _toastRef_current, _toastRef_current1;
|
|
16484
|
+
if (!pointerStartRef.current || !dismissible) return;
|
|
16485
|
+
const isHighlighted = ((_window_getSelection = window.getSelection()) == null ? void 0 : _window_getSelection.toString().length) > 0;
|
|
16486
|
+
if (isHighlighted) return;
|
|
16487
|
+
const yDelta = event.clientY - pointerStartRef.current.y;
|
|
16488
|
+
const xDelta = event.clientX - pointerStartRef.current.x;
|
|
16489
|
+
var _props_swipeDirections;
|
|
16490
|
+
const swipeDirections = (_props_swipeDirections = props.swipeDirections) != null ? _props_swipeDirections : getDefaultSwipeDirections(position);
|
|
16491
|
+
if (!swipeDirection && (Math.abs(xDelta) > 1 || Math.abs(yDelta) > 1)) {
|
|
16492
|
+
setSwipeDirection(Math.abs(xDelta) > Math.abs(yDelta) ? "x" : "y");
|
|
16493
|
+
}
|
|
16494
|
+
let swipeAmount = {
|
|
16495
|
+
x: 0,
|
|
16496
|
+
y: 0
|
|
16497
|
+
};
|
|
16498
|
+
const getDampening = (delta) => {
|
|
16499
|
+
const factor = Math.abs(delta) / 20;
|
|
16500
|
+
return 1 / (1.5 + factor);
|
|
16501
|
+
};
|
|
16502
|
+
if (swipeDirection === "y") {
|
|
16503
|
+
if (swipeDirections.includes("top") || swipeDirections.includes("bottom")) {
|
|
16504
|
+
if (swipeDirections.includes("top") && yDelta < 0 || swipeDirections.includes("bottom") && yDelta > 0) {
|
|
16505
|
+
swipeAmount.y = yDelta;
|
|
16506
|
+
} else {
|
|
16507
|
+
const dampenedDelta = yDelta * getDampening(yDelta);
|
|
16508
|
+
swipeAmount.y = Math.abs(dampenedDelta) < Math.abs(yDelta) ? dampenedDelta : yDelta;
|
|
16509
|
+
}
|
|
16510
|
+
}
|
|
16511
|
+
} else if (swipeDirection === "x") {
|
|
16512
|
+
if (swipeDirections.includes("left") || swipeDirections.includes("right")) {
|
|
16513
|
+
if (swipeDirections.includes("left") && xDelta < 0 || swipeDirections.includes("right") && xDelta > 0) {
|
|
16514
|
+
swipeAmount.x = xDelta;
|
|
16515
|
+
} else {
|
|
16516
|
+
const dampenedDelta = xDelta * getDampening(xDelta);
|
|
16517
|
+
swipeAmount.x = Math.abs(dampenedDelta) < Math.abs(xDelta) ? dampenedDelta : xDelta;
|
|
16518
|
+
}
|
|
16519
|
+
}
|
|
16520
|
+
}
|
|
16521
|
+
if (Math.abs(swipeAmount.x) > 0 || Math.abs(swipeAmount.y) > 0) {
|
|
16522
|
+
setIsSwiped(true);
|
|
16523
|
+
}
|
|
16524
|
+
(_toastRef_current = toastRef.current) == null ? void 0 : _toastRef_current.style.setProperty("--swipe-amount-x", `${swipeAmount.x}px`);
|
|
16525
|
+
(_toastRef_current1 = toastRef.current) == null ? void 0 : _toastRef_current1.style.setProperty("--swipe-amount-y", `${swipeAmount.y}px`);
|
|
16526
|
+
}
|
|
16527
|
+
}, closeButton && !toast2.jsx && toastType !== "loading" ? /* @__PURE__ */ React16__namespace.default.createElement("button", {
|
|
16528
|
+
"aria-label": closeButtonAriaLabel,
|
|
16529
|
+
"data-disabled": disabled,
|
|
16530
|
+
"data-close-button": true,
|
|
16531
|
+
onClick: disabled || !dismissible ? () => {
|
|
16532
|
+
} : () => {
|
|
16533
|
+
deleteToast();
|
|
16534
|
+
toast2.onDismiss == null ? void 0 : toast2.onDismiss.call(toast2, toast2);
|
|
16535
|
+
},
|
|
16536
|
+
className: cn2(classNames == null ? void 0 : classNames.closeButton, toast2 == null ? void 0 : (_toast_classNames2 = toast2.classNames) == null ? void 0 : _toast_classNames2.closeButton)
|
|
16537
|
+
}, (_icons_close = icons == null ? void 0 : icons.close) != null ? _icons_close : CloseIcon) : null, (toastType || toast2.icon || toast2.promise) && toast2.icon !== null && ((icons == null ? void 0 : icons[toastType]) !== null || toast2.icon) ? /* @__PURE__ */ React16__namespace.default.createElement("div", {
|
|
16538
|
+
"data-icon": "",
|
|
16539
|
+
className: cn2(classNames == null ? void 0 : classNames.icon, toast2 == null ? void 0 : (_toast_classNames3 = toast2.classNames) == null ? void 0 : _toast_classNames3.icon)
|
|
16540
|
+
}, toast2.promise || toast2.type === "loading" && !toast2.icon ? toast2.icon || getLoadingIcon() : null, toast2.type !== "loading" ? icon : null) : null, /* @__PURE__ */ React16__namespace.default.createElement("div", {
|
|
16541
|
+
"data-content": "",
|
|
16542
|
+
className: cn2(classNames == null ? void 0 : classNames.content, toast2 == null ? void 0 : (_toast_classNames4 = toast2.classNames) == null ? void 0 : _toast_classNames4.content)
|
|
16543
|
+
}, /* @__PURE__ */ React16__namespace.default.createElement("div", {
|
|
16544
|
+
"data-title": "",
|
|
16545
|
+
className: cn2(classNames == null ? void 0 : classNames.title, toast2 == null ? void 0 : (_toast_classNames5 = toast2.classNames) == null ? void 0 : _toast_classNames5.title)
|
|
16546
|
+
}, toast2.jsx ? toast2.jsx : typeof toast2.title === "function" ? toast2.title() : toast2.title), toast2.description ? /* @__PURE__ */ React16__namespace.default.createElement("div", {
|
|
16547
|
+
"data-description": "",
|
|
16548
|
+
className: cn2(descriptionClassName, toastDescriptionClassname, classNames == null ? void 0 : classNames.description, toast2 == null ? void 0 : (_toast_classNames6 = toast2.classNames) == null ? void 0 : _toast_classNames6.description)
|
|
16549
|
+
}, typeof toast2.description === "function" ? toast2.description() : toast2.description) : null), /* @__PURE__ */ React16__namespace.default.isValidElement(toast2.cancel) ? toast2.cancel : toast2.cancel && isAction(toast2.cancel) ? /* @__PURE__ */ React16__namespace.default.createElement("button", {
|
|
16550
|
+
"data-button": true,
|
|
16551
|
+
"data-cancel": true,
|
|
16552
|
+
style: toast2.cancelButtonStyle || cancelButtonStyle,
|
|
16553
|
+
onClick: (event) => {
|
|
16554
|
+
if (!isAction(toast2.cancel)) return;
|
|
16555
|
+
if (!dismissible) return;
|
|
16556
|
+
toast2.cancel.onClick == null ? void 0 : toast2.cancel.onClick.call(toast2.cancel, event);
|
|
16557
|
+
deleteToast();
|
|
16558
|
+
},
|
|
16559
|
+
className: cn2(classNames == null ? void 0 : classNames.cancelButton, toast2 == null ? void 0 : (_toast_classNames7 = toast2.classNames) == null ? void 0 : _toast_classNames7.cancelButton)
|
|
16560
|
+
}, toast2.cancel.label) : null, /* @__PURE__ */ React16__namespace.default.isValidElement(toast2.action) ? toast2.action : toast2.action && isAction(toast2.action) ? /* @__PURE__ */ React16__namespace.default.createElement("button", {
|
|
16561
|
+
"data-button": true,
|
|
16562
|
+
"data-action": true,
|
|
16563
|
+
style: toast2.actionButtonStyle || actionButtonStyle,
|
|
16564
|
+
onClick: (event) => {
|
|
16565
|
+
if (!isAction(toast2.action)) return;
|
|
16566
|
+
toast2.action.onClick == null ? void 0 : toast2.action.onClick.call(toast2.action, event);
|
|
16567
|
+
if (event.defaultPrevented) return;
|
|
16568
|
+
deleteToast();
|
|
16569
|
+
},
|
|
16570
|
+
className: cn2(classNames == null ? void 0 : classNames.actionButton, toast2 == null ? void 0 : (_toast_classNames8 = toast2.classNames) == null ? void 0 : _toast_classNames8.actionButton)
|
|
16571
|
+
}, toast2.action.label) : null);
|
|
16572
|
+
};
|
|
16573
|
+
function getDocumentDirection() {
|
|
16574
|
+
if (typeof window === "undefined") return "ltr";
|
|
16575
|
+
if (typeof document === "undefined") return "ltr";
|
|
16576
|
+
const dirAttribute = document.documentElement.getAttribute("dir");
|
|
16577
|
+
if (dirAttribute === "auto" || !dirAttribute) {
|
|
16578
|
+
return window.getComputedStyle(document.documentElement).direction;
|
|
16579
|
+
}
|
|
16580
|
+
return dirAttribute;
|
|
16581
|
+
}
|
|
16582
|
+
function assignOffset(defaultOffset, mobileOffset) {
|
|
16583
|
+
const styles = {};
|
|
16584
|
+
[
|
|
16585
|
+
defaultOffset,
|
|
16586
|
+
mobileOffset
|
|
16587
|
+
].forEach((offset, index) => {
|
|
16588
|
+
const isMobile = index === 1;
|
|
16589
|
+
const prefix = isMobile ? "--mobile-offset" : "--offset";
|
|
16590
|
+
const defaultValue = isMobile ? MOBILE_VIEWPORT_OFFSET : VIEWPORT_OFFSET;
|
|
16591
|
+
function assignAll(offset2) {
|
|
16592
|
+
[
|
|
16593
|
+
"top",
|
|
16594
|
+
"right",
|
|
16595
|
+
"bottom",
|
|
16596
|
+
"left"
|
|
16597
|
+
].forEach((key) => {
|
|
16598
|
+
styles[`${prefix}-${key}`] = typeof offset2 === "number" ? `${offset2}px` : offset2;
|
|
16599
|
+
});
|
|
16600
|
+
}
|
|
16601
|
+
if (typeof offset === "number" || typeof offset === "string") {
|
|
16602
|
+
assignAll(offset);
|
|
16603
|
+
} else if (typeof offset === "object") {
|
|
16604
|
+
[
|
|
16605
|
+
"top",
|
|
16606
|
+
"right",
|
|
16607
|
+
"bottom",
|
|
16608
|
+
"left"
|
|
16609
|
+
].forEach((key) => {
|
|
16610
|
+
if (offset[key] === void 0) {
|
|
16611
|
+
styles[`${prefix}-${key}`] = defaultValue;
|
|
16612
|
+
} else {
|
|
16613
|
+
styles[`${prefix}-${key}`] = typeof offset[key] === "number" ? `${offset[key]}px` : offset[key];
|
|
16614
|
+
}
|
|
16615
|
+
});
|
|
16616
|
+
} else {
|
|
16617
|
+
assignAll(defaultValue);
|
|
16618
|
+
}
|
|
16619
|
+
});
|
|
16620
|
+
return styles;
|
|
16621
|
+
}
|
|
16622
|
+
var Toaster = /* @__PURE__ */ React16__namespace.default.forwardRef(function Toaster2(props, ref) {
|
|
16623
|
+
const { id, invert, position = "bottom-right", hotkey = [
|
|
16624
|
+
"altKey",
|
|
16625
|
+
"KeyT"
|
|
16626
|
+
], expand, closeButton, className, offset, mobileOffset, theme = "light", richColors, duration, style, visibleToasts = VISIBLE_TOASTS_AMOUNT, toastOptions, dir = getDocumentDirection(), gap = GAP, icons, containerAriaLabel = "Notifications" } = props;
|
|
16627
|
+
const [toasts, setToasts] = React16__namespace.default.useState([]);
|
|
16628
|
+
const filteredToasts = React16__namespace.default.useMemo(() => {
|
|
16629
|
+
if (id) {
|
|
16630
|
+
return toasts.filter((toast2) => toast2.toasterId === id);
|
|
16631
|
+
}
|
|
16632
|
+
return toasts.filter((toast2) => !toast2.toasterId);
|
|
16633
|
+
}, [
|
|
16634
|
+
toasts,
|
|
16635
|
+
id
|
|
16636
|
+
]);
|
|
16637
|
+
const possiblePositions = React16__namespace.default.useMemo(() => {
|
|
16638
|
+
return Array.from(new Set([
|
|
16639
|
+
position
|
|
16640
|
+
].concat(filteredToasts.filter((toast2) => toast2.position).map((toast2) => toast2.position))));
|
|
16641
|
+
}, [
|
|
16642
|
+
filteredToasts,
|
|
16643
|
+
position
|
|
16644
|
+
]);
|
|
16645
|
+
const [heights, setHeights] = React16__namespace.default.useState([]);
|
|
16646
|
+
const [expanded, setExpanded] = React16__namespace.default.useState(false);
|
|
16647
|
+
const [interacting, setInteracting] = React16__namespace.default.useState(false);
|
|
16648
|
+
const [actualTheme, setActualTheme] = React16__namespace.default.useState(theme !== "system" ? theme : typeof window !== "undefined" ? window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" : "light");
|
|
16649
|
+
const listRef = React16__namespace.default.useRef(null);
|
|
16650
|
+
const hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
|
|
16651
|
+
const lastFocusedElementRef = React16__namespace.default.useRef(null);
|
|
16652
|
+
const isFocusWithinRef = React16__namespace.default.useRef(false);
|
|
16653
|
+
const removeToast = React16__namespace.default.useCallback((toastToRemove) => {
|
|
16654
|
+
setToasts((toasts2) => {
|
|
16655
|
+
var _toasts_find;
|
|
16656
|
+
if (!((_toasts_find = toasts2.find((toast2) => toast2.id === toastToRemove.id)) == null ? void 0 : _toasts_find.delete)) {
|
|
16657
|
+
ToastState.dismiss(toastToRemove.id);
|
|
16658
|
+
}
|
|
16659
|
+
return toasts2.filter(({ id: id2 }) => id2 !== toastToRemove.id);
|
|
16660
|
+
});
|
|
16661
|
+
}, []);
|
|
16662
|
+
React16__namespace.default.useEffect(() => {
|
|
16663
|
+
return ToastState.subscribe((toast2) => {
|
|
16664
|
+
if (toast2.dismiss) {
|
|
16665
|
+
requestAnimationFrame(() => {
|
|
16666
|
+
setToasts((toasts2) => toasts2.map((t) => t.id === toast2.id ? {
|
|
16667
|
+
...t,
|
|
16668
|
+
delete: true
|
|
16669
|
+
} : t));
|
|
16670
|
+
});
|
|
16671
|
+
return;
|
|
16672
|
+
}
|
|
16673
|
+
setTimeout(() => {
|
|
16674
|
+
ReactDOM__default.default.flushSync(() => {
|
|
16675
|
+
setToasts((toasts2) => {
|
|
16676
|
+
const indexOfExistingToast = toasts2.findIndex((t) => t.id === toast2.id);
|
|
16677
|
+
if (indexOfExistingToast !== -1) {
|
|
16678
|
+
return [
|
|
16679
|
+
...toasts2.slice(0, indexOfExistingToast),
|
|
16680
|
+
{
|
|
16681
|
+
...toasts2[indexOfExistingToast],
|
|
16682
|
+
...toast2
|
|
16683
|
+
},
|
|
16684
|
+
...toasts2.slice(indexOfExistingToast + 1)
|
|
16685
|
+
];
|
|
16686
|
+
}
|
|
16687
|
+
return [
|
|
16688
|
+
toast2,
|
|
16689
|
+
...toasts2
|
|
16690
|
+
];
|
|
16691
|
+
});
|
|
16692
|
+
});
|
|
16693
|
+
});
|
|
16694
|
+
});
|
|
16695
|
+
}, [
|
|
16696
|
+
toasts
|
|
16697
|
+
]);
|
|
16698
|
+
React16__namespace.default.useEffect(() => {
|
|
16699
|
+
if (theme !== "system") {
|
|
16700
|
+
setActualTheme(theme);
|
|
16701
|
+
return;
|
|
16702
|
+
}
|
|
16703
|
+
if (theme === "system") {
|
|
16704
|
+
if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
|
16705
|
+
setActualTheme("dark");
|
|
16706
|
+
} else {
|
|
16707
|
+
setActualTheme("light");
|
|
16708
|
+
}
|
|
16709
|
+
}
|
|
16710
|
+
if (typeof window === "undefined") return;
|
|
16711
|
+
const darkMediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
16712
|
+
try {
|
|
16713
|
+
darkMediaQuery.addEventListener("change", ({ matches }) => {
|
|
16714
|
+
if (matches) {
|
|
16715
|
+
setActualTheme("dark");
|
|
16716
|
+
} else {
|
|
16717
|
+
setActualTheme("light");
|
|
16718
|
+
}
|
|
16719
|
+
});
|
|
16720
|
+
} catch (error) {
|
|
16721
|
+
darkMediaQuery.addListener(({ matches }) => {
|
|
16722
|
+
try {
|
|
16723
|
+
if (matches) {
|
|
16724
|
+
setActualTheme("dark");
|
|
16725
|
+
} else {
|
|
16726
|
+
setActualTheme("light");
|
|
16727
|
+
}
|
|
16728
|
+
} catch (e) {
|
|
16729
|
+
console.error(e);
|
|
16730
|
+
}
|
|
16731
|
+
});
|
|
16732
|
+
}
|
|
16733
|
+
}, [
|
|
16734
|
+
theme
|
|
16735
|
+
]);
|
|
16736
|
+
React16__namespace.default.useEffect(() => {
|
|
16737
|
+
if (toasts.length <= 1) {
|
|
16738
|
+
setExpanded(false);
|
|
16739
|
+
}
|
|
16740
|
+
}, [
|
|
16741
|
+
toasts
|
|
16742
|
+
]);
|
|
16743
|
+
React16__namespace.default.useEffect(() => {
|
|
16744
|
+
const handleKeyDown = (event) => {
|
|
16745
|
+
var _listRef_current;
|
|
16746
|
+
const isHotkeyPressed = hotkey.every((key) => event[key] || event.code === key);
|
|
16747
|
+
if (isHotkeyPressed) {
|
|
16748
|
+
var _listRef_current1;
|
|
16749
|
+
setExpanded(true);
|
|
16750
|
+
(_listRef_current1 = listRef.current) == null ? void 0 : _listRef_current1.focus();
|
|
16751
|
+
}
|
|
16752
|
+
if (event.code === "Escape" && (document.activeElement === listRef.current || ((_listRef_current = listRef.current) == null ? void 0 : _listRef_current.contains(document.activeElement)))) {
|
|
16753
|
+
setExpanded(false);
|
|
16754
|
+
}
|
|
16755
|
+
};
|
|
16756
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
16757
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
16758
|
+
}, [
|
|
16759
|
+
hotkey
|
|
16760
|
+
]);
|
|
16761
|
+
React16__namespace.default.useEffect(() => {
|
|
16762
|
+
if (listRef.current) {
|
|
16763
|
+
return () => {
|
|
16764
|
+
if (lastFocusedElementRef.current) {
|
|
16765
|
+
lastFocusedElementRef.current.focus({
|
|
16766
|
+
preventScroll: true
|
|
16767
|
+
});
|
|
16768
|
+
lastFocusedElementRef.current = null;
|
|
16769
|
+
isFocusWithinRef.current = false;
|
|
16770
|
+
}
|
|
16771
|
+
};
|
|
16772
|
+
}
|
|
16773
|
+
}, [
|
|
16774
|
+
listRef.current
|
|
16775
|
+
]);
|
|
16776
|
+
return (
|
|
16777
|
+
// Remove item from normal navigation flow, only available via hotkey
|
|
16778
|
+
/* @__PURE__ */ React16__namespace.default.createElement("section", {
|
|
16779
|
+
ref,
|
|
16780
|
+
"aria-label": `${containerAriaLabel} ${hotkeyLabel}`,
|
|
16781
|
+
tabIndex: -1,
|
|
16782
|
+
"aria-live": "polite",
|
|
16783
|
+
"aria-relevant": "additions text",
|
|
16784
|
+
"aria-atomic": "false",
|
|
16785
|
+
suppressHydrationWarning: true
|
|
16786
|
+
}, possiblePositions.map((position2, index) => {
|
|
16787
|
+
var _heights_;
|
|
16788
|
+
const [y, x] = position2.split("-");
|
|
16789
|
+
if (!filteredToasts.length) return null;
|
|
16790
|
+
return /* @__PURE__ */ React16__namespace.default.createElement("ol", {
|
|
16791
|
+
key: position2,
|
|
16792
|
+
dir: dir === "auto" ? getDocumentDirection() : dir,
|
|
16793
|
+
tabIndex: -1,
|
|
16794
|
+
ref: listRef,
|
|
16795
|
+
className,
|
|
16796
|
+
"data-sonner-toaster": true,
|
|
16797
|
+
"data-sonner-theme": actualTheme,
|
|
16798
|
+
"data-y-position": y,
|
|
16799
|
+
"data-x-position": x,
|
|
16800
|
+
style: {
|
|
16801
|
+
"--front-toast-height": `${((_heights_ = heights[0]) == null ? void 0 : _heights_.height) || 0}px`,
|
|
16802
|
+
"--width": `${TOAST_WIDTH}px`,
|
|
16803
|
+
"--gap": `${gap}px`,
|
|
16804
|
+
...style,
|
|
16805
|
+
...assignOffset(offset, mobileOffset)
|
|
16806
|
+
},
|
|
16807
|
+
onBlur: (event) => {
|
|
16808
|
+
if (isFocusWithinRef.current && !event.currentTarget.contains(event.relatedTarget)) {
|
|
16809
|
+
isFocusWithinRef.current = false;
|
|
16810
|
+
if (lastFocusedElementRef.current) {
|
|
16811
|
+
lastFocusedElementRef.current.focus({
|
|
16812
|
+
preventScroll: true
|
|
16813
|
+
});
|
|
16814
|
+
lastFocusedElementRef.current = null;
|
|
16815
|
+
}
|
|
16816
|
+
}
|
|
16817
|
+
},
|
|
16818
|
+
onFocus: (event) => {
|
|
16819
|
+
const isNotDismissible = event.target instanceof HTMLElement && event.target.dataset.dismissible === "false";
|
|
16820
|
+
if (isNotDismissible) return;
|
|
16821
|
+
if (!isFocusWithinRef.current) {
|
|
16822
|
+
isFocusWithinRef.current = true;
|
|
16823
|
+
lastFocusedElementRef.current = event.relatedTarget;
|
|
16824
|
+
}
|
|
16825
|
+
},
|
|
16826
|
+
onMouseEnter: () => setExpanded(true),
|
|
16827
|
+
onMouseMove: () => setExpanded(true),
|
|
16828
|
+
onMouseLeave: () => {
|
|
16829
|
+
if (!interacting) {
|
|
16830
|
+
setExpanded(false);
|
|
16831
|
+
}
|
|
16832
|
+
},
|
|
16833
|
+
onDragEnd: () => setExpanded(false),
|
|
16834
|
+
onPointerDown: (event) => {
|
|
16835
|
+
const isNotDismissible = event.target instanceof HTMLElement && event.target.dataset.dismissible === "false";
|
|
16836
|
+
if (isNotDismissible) return;
|
|
16837
|
+
setInteracting(true);
|
|
16838
|
+
},
|
|
16839
|
+
onPointerUp: () => setInteracting(false)
|
|
16840
|
+
}, filteredToasts.filter((toast2) => !toast2.position && index === 0 || toast2.position === position2).map((toast2, index2) => {
|
|
16841
|
+
var _toastOptions_duration, _toastOptions_closeButton;
|
|
16842
|
+
return /* @__PURE__ */ React16__namespace.default.createElement(Toast, {
|
|
16843
|
+
key: toast2.id,
|
|
16844
|
+
icons,
|
|
16845
|
+
index: index2,
|
|
16846
|
+
toast: toast2,
|
|
16847
|
+
defaultRichColors: richColors,
|
|
16848
|
+
duration: (_toastOptions_duration = toastOptions == null ? void 0 : toastOptions.duration) != null ? _toastOptions_duration : duration,
|
|
16849
|
+
className: toastOptions == null ? void 0 : toastOptions.className,
|
|
16850
|
+
descriptionClassName: toastOptions == null ? void 0 : toastOptions.descriptionClassName,
|
|
16851
|
+
invert,
|
|
16852
|
+
visibleToasts,
|
|
16853
|
+
closeButton: (_toastOptions_closeButton = toastOptions == null ? void 0 : toastOptions.closeButton) != null ? _toastOptions_closeButton : closeButton,
|
|
16854
|
+
interacting,
|
|
16855
|
+
position: position2,
|
|
16856
|
+
style: toastOptions == null ? void 0 : toastOptions.style,
|
|
16857
|
+
unstyled: toastOptions == null ? void 0 : toastOptions.unstyled,
|
|
16858
|
+
classNames: toastOptions == null ? void 0 : toastOptions.classNames,
|
|
16859
|
+
cancelButtonStyle: toastOptions == null ? void 0 : toastOptions.cancelButtonStyle,
|
|
16860
|
+
actionButtonStyle: toastOptions == null ? void 0 : toastOptions.actionButtonStyle,
|
|
16861
|
+
closeButtonAriaLabel: toastOptions == null ? void 0 : toastOptions.closeButtonAriaLabel,
|
|
16862
|
+
removeToast,
|
|
16863
|
+
toasts: filteredToasts.filter((t) => t.position == toast2.position),
|
|
16864
|
+
heights: heights.filter((h) => h.position == toast2.position),
|
|
16865
|
+
setHeights,
|
|
16866
|
+
expandByDefault: expand,
|
|
16867
|
+
gap,
|
|
16868
|
+
expanded,
|
|
16869
|
+
swipeDirections: props.swipeDirections
|
|
16870
|
+
});
|
|
16871
|
+
}));
|
|
16872
|
+
}))
|
|
16873
|
+
);
|
|
16874
|
+
});
|
|
16875
|
+
var TTSButton = React16.memo(function TTSButton2({
|
|
16081
16876
|
text: text3,
|
|
16082
16877
|
onActiveChange,
|
|
16083
16878
|
className
|
|
16084
16879
|
}) {
|
|
16085
|
-
const [state, setState] =
|
|
16086
|
-
const [progress, setProgress] =
|
|
16087
|
-
const audioRef =
|
|
16088
|
-
const progressIntervalRef =
|
|
16089
|
-
|
|
16880
|
+
const [state, setState] = React16.useState("idle");
|
|
16881
|
+
const [progress, setProgress] = React16.useState(0);
|
|
16882
|
+
const audioRef = React16.useRef(null);
|
|
16883
|
+
const progressIntervalRef = React16.useRef(null);
|
|
16884
|
+
React16.useEffect(() => {
|
|
16090
16885
|
const active = state !== "idle" && state !== "error";
|
|
16091
16886
|
onActiveChange?.(active);
|
|
16092
16887
|
}, [state, onActiveChange]);
|
|
16093
|
-
const cleanup =
|
|
16888
|
+
const cleanup = React16.useCallback(() => {
|
|
16094
16889
|
if (progressIntervalRef.current) {
|
|
16095
16890
|
clearInterval(progressIntervalRef.current);
|
|
16096
16891
|
progressIntervalRef.current = null;
|
|
@@ -16102,8 +16897,8 @@ var TTSButton = React24.memo(function TTSButton2({
|
|
|
16102
16897
|
}
|
|
16103
16898
|
setProgress(0);
|
|
16104
16899
|
}, []);
|
|
16105
|
-
|
|
16106
|
-
const startProgressTracking =
|
|
16900
|
+
React16.useEffect(() => cleanup, [cleanup]);
|
|
16901
|
+
const startProgressTracking = React16.useCallback((audio) => {
|
|
16107
16902
|
if (progressIntervalRef.current) {
|
|
16108
16903
|
clearInterval(progressIntervalRef.current);
|
|
16109
16904
|
}
|
|
@@ -16113,7 +16908,7 @@ var TTSButton = React24.memo(function TTSButton2({
|
|
|
16113
16908
|
}
|
|
16114
16909
|
}, 100);
|
|
16115
16910
|
}, []);
|
|
16116
|
-
const handleClick =
|
|
16911
|
+
const handleClick = React16.useCallback(async () => {
|
|
16117
16912
|
if (state === "playing") {
|
|
16118
16913
|
audioRef.current?.pause();
|
|
16119
16914
|
if (progressIntervalRef.current) {
|
|
@@ -16161,7 +16956,7 @@ var TTSButton = React24.memo(function TTSButton2({
|
|
|
16161
16956
|
setTimeout(() => setState("idle"), 2e3);
|
|
16162
16957
|
}
|
|
16163
16958
|
}, [state, text3, cleanup, startProgressTracking]);
|
|
16164
|
-
const handleStop =
|
|
16959
|
+
const handleStop = React16.useCallback((e) => {
|
|
16165
16960
|
e.stopPropagation();
|
|
16166
16961
|
if (state === "playing" || state === "paused") {
|
|
16167
16962
|
cleanup();
|
|
@@ -16225,13 +17020,13 @@ var TTSButton = React24.memo(function TTSButton2({
|
|
|
16225
17020
|
}
|
|
16226
17021
|
) });
|
|
16227
17022
|
});
|
|
16228
|
-
var ThoughtBlockItem =
|
|
17023
|
+
var ThoughtBlockItem = React16.memo(function ThoughtBlockItem2({
|
|
16229
17024
|
content,
|
|
16230
17025
|
config,
|
|
16231
17026
|
skipImages = false
|
|
16232
17027
|
}) {
|
|
16233
|
-
const [expanded, setExpanded] =
|
|
16234
|
-
const lineCount =
|
|
17028
|
+
const [expanded, setExpanded] = React16.useState(false);
|
|
17029
|
+
const lineCount = React16.useMemo(() => content.split("\n").length, [content]);
|
|
16235
17030
|
const shouldToggle = lineCount > 2 || content.length > 120;
|
|
16236
17031
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
16237
17032
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -16255,7 +17050,7 @@ var ThoughtBlockItem = React24.memo(function ThoughtBlockItem2({
|
|
|
16255
17050
|
)
|
|
16256
17051
|
] });
|
|
16257
17052
|
});
|
|
16258
|
-
var MessageBubble =
|
|
17053
|
+
var MessageBubble = React16.memo(function MessageBubble2({
|
|
16259
17054
|
message,
|
|
16260
17055
|
isStreaming = false,
|
|
16261
17056
|
streamingContent,
|
|
@@ -16283,12 +17078,12 @@ var MessageBubble = React24.memo(function MessageBubble2({
|
|
|
16283
17078
|
const MessageImageComp = useComponent("MessageImage") || MessageImageInternal;
|
|
16284
17079
|
const MessageVideoComp = useComponent("MessageVideo") || MessageVideoInternal;
|
|
16285
17080
|
const ImagePreviewComp = useComponent("ImagePreview") || ImagePreviewInternal;
|
|
16286
|
-
const [copied, setCopied] =
|
|
16287
|
-
const [showThoughts, setShowThoughts] =
|
|
16288
|
-
const [showDeleteConfirm, setShowDeleteConfirm] =
|
|
16289
|
-
const [isDeleting, setIsDeleting] =
|
|
16290
|
-
const [previewMedia, setPreviewMedia] =
|
|
16291
|
-
const [ttsActive, setTtsActive] =
|
|
17081
|
+
const [copied, setCopied] = React16.useState(false);
|
|
17082
|
+
const [showThoughts, setShowThoughts] = React16.useState(false);
|
|
17083
|
+
const [showDeleteConfirm, setShowDeleteConfirm] = React16.useState(false);
|
|
17084
|
+
const [isDeleting, setIsDeleting] = React16.useState(false);
|
|
17085
|
+
const [previewMedia, setPreviewMedia] = React16.useState(null);
|
|
17086
|
+
const [ttsActive, setTtsActive] = React16.useState(false);
|
|
16292
17087
|
const pendingComponents = useAgentStore((state) => state.chatUI.pendingComponents);
|
|
16293
17088
|
const pendingComponentsSessionId = useAgentStore((state) => state.chatUI.pendingComponentsSessionId);
|
|
16294
17089
|
const isUser = message.role === "user";
|
|
@@ -16301,7 +17096,7 @@ var MessageBubble = React24.memo(function MessageBubble2({
|
|
|
16301
17096
|
thoughts,
|
|
16302
17097
|
pendingToolCalls
|
|
16303
17098
|
});
|
|
16304
|
-
const hasToolCallImages =
|
|
17099
|
+
const hasToolCallImages = React16.useMemo(() => {
|
|
16305
17100
|
return toolCalls.some((tc) => {
|
|
16306
17101
|
if (tc.result?.works?.some((w) => w.fileUrl || w.fileId)) return true;
|
|
16307
17102
|
if (tc.result?.outputs?.images) return true;
|
|
@@ -16315,13 +17110,13 @@ var MessageBubble = React24.memo(function MessageBubble2({
|
|
|
16315
17110
|
isUser,
|
|
16316
17111
|
hasToolCallImages
|
|
16317
17112
|
});
|
|
16318
|
-
const handleCopy =
|
|
17113
|
+
const handleCopy = React16.useCallback(async () => {
|
|
16319
17114
|
if (!displayContent) return;
|
|
16320
17115
|
await navigator.clipboard.writeText(displayContent);
|
|
16321
17116
|
setCopied(true);
|
|
16322
17117
|
setTimeout(() => setCopied(false), 2e3);
|
|
16323
17118
|
}, [displayContent]);
|
|
16324
|
-
const handleDelete2 =
|
|
17119
|
+
const handleDelete2 = React16.useCallback(async () => {
|
|
16325
17120
|
if (!onDelete || !message.messageId) return;
|
|
16326
17121
|
setIsDeleting(true);
|
|
16327
17122
|
try {
|
|
@@ -16333,7 +17128,7 @@ var MessageBubble = React24.memo(function MessageBubble2({
|
|
|
16333
17128
|
setIsDeleting(false);
|
|
16334
17129
|
}
|
|
16335
17130
|
}, [onDelete, message.messageId]);
|
|
16336
|
-
const attachments =
|
|
17131
|
+
const attachments = React16.useMemo(() => {
|
|
16337
17132
|
const rawAttachments = message.attachments || message.extraData?.attachments || [];
|
|
16338
17133
|
const assetStrategy = config?.asset;
|
|
16339
17134
|
const processedAttachments = rawAttachments.map((att) => {
|
|
@@ -16368,8 +17163,8 @@ var MessageBubble = React24.memo(function MessageBubble2({
|
|
|
16368
17163
|
thoughts,
|
|
16369
17164
|
isStreaming
|
|
16370
17165
|
});
|
|
16371
|
-
const [stickyComponents, setStickyComponents] =
|
|
16372
|
-
const mergedComponents =
|
|
17166
|
+
const [stickyComponents, setStickyComponents] = React16.useState([]);
|
|
17167
|
+
const mergedComponents = React16.useMemo(() => {
|
|
16373
17168
|
const map3 = /* @__PURE__ */ new Map();
|
|
16374
17169
|
effectiveComponents.forEach((c) => {
|
|
16375
17170
|
if (c?.id) map3.set(String(c.id), c);
|
|
@@ -16393,7 +17188,7 @@ var MessageBubble = React24.memo(function MessageBubble2({
|
|
|
16393
17188
|
const hasAttachmentOnly = isUser && attachments.length > 0 && !hasValidContent;
|
|
16394
17189
|
const showThoughtsInTimeline = (config?.chatLayout?.showThoughtsInTimeline ?? true) && !hasPlan;
|
|
16395
17190
|
const includeMessageInTimeline = !isUser && showThoughtsInTimeline && !isStreaming && !!sanitizedDisplayContent;
|
|
16396
|
-
const messageArtifactParsed =
|
|
17191
|
+
const messageArtifactParsed = React16.useMemo(() => {
|
|
16397
17192
|
if (!message.content || isUser || isStreaming) return null;
|
|
16398
17193
|
const rawContent = typeof message.content === "string" ? message.content : "";
|
|
16399
17194
|
if (!rawContent.trim()) return null;
|
|
@@ -16847,13 +17642,13 @@ var MessageBubble = React24.memo(function MessageBubble2({
|
|
|
16847
17642
|
] });
|
|
16848
17643
|
});
|
|
16849
17644
|
var MessageBubble_default = MessageBubble;
|
|
16850
|
-
var EmptyState =
|
|
17645
|
+
var EmptyState = React16.memo(function EmptyState2() {
|
|
16851
17646
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center", children: [
|
|
16852
17647
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-12 h-12 rounded-xl bg-zinc-800/50 flex items-center justify-center mx-auto mb-3", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Sparkles, { size: 24, className: "text-zinc-600" }) }),
|
|
16853
17648
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-zinc-600 text-sm", children: "\u5F00\u59CB\u5BF9\u8BDD\u5427" })
|
|
16854
17649
|
] }) });
|
|
16855
17650
|
});
|
|
16856
|
-
var LoadingState =
|
|
17651
|
+
var LoadingState = React16.memo(function LoadingState2() {
|
|
16857
17652
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "animate-spin rounded-full h-6 w-6 border-b-2 border-[#d8ff00]" }) }) });
|
|
16858
17653
|
});
|
|
16859
17654
|
function ChatWindow({
|
|
@@ -16889,42 +17684,42 @@ function ChatWindow({
|
|
|
16889
17684
|
currentThoughtsSessionId: state.chatUI.currentThoughtsSessionId
|
|
16890
17685
|
}))
|
|
16891
17686
|
);
|
|
16892
|
-
const sessionPendingToolCalls =
|
|
17687
|
+
const sessionPendingToolCalls = React16.useMemo(
|
|
16893
17688
|
() => pendingToolCallsSessionId === sessionId ? pendingToolCalls : [],
|
|
16894
17689
|
[pendingToolCalls, pendingToolCallsSessionId, sessionId]
|
|
16895
17690
|
);
|
|
16896
|
-
const sessionCurrentThoughts =
|
|
17691
|
+
const sessionCurrentThoughts = React16.useMemo(
|
|
16897
17692
|
() => currentThoughtsSessionId === sessionId ? currentThoughts : [],
|
|
16898
17693
|
[currentThoughts, currentThoughtsSessionId, sessionId]
|
|
16899
17694
|
);
|
|
16900
17695
|
const isCurrentSessionStreaming = streamingSessionId === sessionId;
|
|
16901
|
-
const containerRef =
|
|
16902
|
-
const messagesEndRef =
|
|
16903
|
-
const [showScrollButton, setShowScrollButton] =
|
|
16904
|
-
const sessionMessages =
|
|
17696
|
+
const containerRef = React16.useRef(null);
|
|
17697
|
+
const messagesEndRef = React16.useRef(null);
|
|
17698
|
+
const [showScrollButton, setShowScrollButton] = React16.useState(false);
|
|
17699
|
+
const sessionMessages = React16.useMemo(
|
|
16905
17700
|
() => messages.filter((m) => m.sessionId === sessionId),
|
|
16906
17701
|
[messages, sessionId]
|
|
16907
17702
|
);
|
|
16908
|
-
const streamingMessage =
|
|
17703
|
+
const streamingMessage = React16.useMemo(
|
|
16909
17704
|
() => sessionMessages.find((m) => m.status === "streaming"),
|
|
16910
17705
|
[sessionMessages]
|
|
16911
17706
|
);
|
|
16912
|
-
const shouldAutoScrollRef =
|
|
16913
|
-
const isNearBottom =
|
|
17707
|
+
const shouldAutoScrollRef = React16.useRef(true);
|
|
17708
|
+
const isNearBottom = React16.useCallback((threshold = 150) => {
|
|
16914
17709
|
const container = containerRef.current;
|
|
16915
17710
|
if (!container) return true;
|
|
16916
17711
|
const { scrollTop, scrollHeight, clientHeight } = container;
|
|
16917
17712
|
return scrollHeight - scrollTop - clientHeight < threshold;
|
|
16918
17713
|
}, []);
|
|
16919
|
-
const scrollToBottom =
|
|
17714
|
+
const scrollToBottom = React16.useCallback((behavior = "smooth") => {
|
|
16920
17715
|
messagesEndRef.current?.scrollIntoView({ behavior, block: "end" });
|
|
16921
17716
|
}, []);
|
|
16922
|
-
const autoScrollIfNeeded =
|
|
17717
|
+
const autoScrollIfNeeded = React16.useCallback(() => {
|
|
16923
17718
|
if (shouldAutoScrollRef.current) {
|
|
16924
17719
|
scrollToBottom("smooth");
|
|
16925
17720
|
}
|
|
16926
17721
|
}, [scrollToBottom]);
|
|
16927
|
-
const getScrollMetrics =
|
|
17722
|
+
const getScrollMetrics = React16.useCallback(() => {
|
|
16928
17723
|
const container = containerRef.current;
|
|
16929
17724
|
if (container && container.scrollHeight - container.clientHeight > 1) {
|
|
16930
17725
|
return {
|
|
@@ -16940,7 +17735,7 @@ function ChatWindow({
|
|
|
16940
17735
|
clientHeight: doc.clientHeight
|
|
16941
17736
|
};
|
|
16942
17737
|
}, []);
|
|
16943
|
-
const updateScrollState =
|
|
17738
|
+
const updateScrollState = React16.useCallback(() => {
|
|
16944
17739
|
const { scrollTop, scrollHeight, clientHeight } = getScrollMetrics();
|
|
16945
17740
|
const distanceFromBottom = scrollHeight - scrollTop - clientHeight;
|
|
16946
17741
|
setShowScrollButton(distanceFromBottom > 200);
|
|
@@ -16948,8 +17743,8 @@ function ChatWindow({
|
|
|
16948
17743
|
shouldAutoScrollRef.current = true;
|
|
16949
17744
|
}
|
|
16950
17745
|
}, [getScrollMetrics]);
|
|
16951
|
-
const lastScrollTopRef =
|
|
16952
|
-
|
|
17746
|
+
const lastScrollTopRef = React16.useRef(0);
|
|
17747
|
+
React16.useEffect(() => {
|
|
16953
17748
|
const handleScroll = () => {
|
|
16954
17749
|
const container2 = containerRef.current;
|
|
16955
17750
|
if (!container2) return;
|
|
@@ -17004,14 +17799,14 @@ function ChatWindow({
|
|
|
17004
17799
|
window.removeEventListener("wheel", handleWheel);
|
|
17005
17800
|
};
|
|
17006
17801
|
}, [isNearBottom, updateScrollState]);
|
|
17007
|
-
|
|
17802
|
+
React16.useEffect(() => {
|
|
17008
17803
|
if (!loading && sessionMessages.length > 0) {
|
|
17009
17804
|
shouldAutoScrollRef.current = true;
|
|
17010
17805
|
scrollToBottom("instant");
|
|
17011
17806
|
}
|
|
17012
17807
|
}, [loading, sessionId, scrollToBottom]);
|
|
17013
|
-
const prevMessageCountRef =
|
|
17014
|
-
|
|
17808
|
+
const prevMessageCountRef = React16.useRef(sessionMessages.length);
|
|
17809
|
+
React16.useEffect(() => {
|
|
17015
17810
|
const prevCount = prevMessageCountRef.current;
|
|
17016
17811
|
const currentCount = sessionMessages.length;
|
|
17017
17812
|
prevMessageCountRef.current = currentCount;
|
|
@@ -17026,17 +17821,17 @@ function ChatWindow({
|
|
|
17026
17821
|
}
|
|
17027
17822
|
updateScrollState();
|
|
17028
17823
|
}, [sessionMessages.length, sessionMessages, scrollToBottom, autoScrollIfNeeded, updateScrollState]);
|
|
17029
|
-
|
|
17824
|
+
React16.useEffect(() => {
|
|
17030
17825
|
if (streamingContent) {
|
|
17031
17826
|
autoScrollIfNeeded();
|
|
17032
17827
|
}
|
|
17033
17828
|
}, [streamingContent, autoScrollIfNeeded]);
|
|
17034
|
-
|
|
17829
|
+
React16.useEffect(() => {
|
|
17035
17830
|
if (isThinking && isCurrentSessionStreaming && sessionCurrentThoughts.length > 0) {
|
|
17036
17831
|
autoScrollIfNeeded();
|
|
17037
17832
|
}
|
|
17038
17833
|
}, [isThinking, isCurrentSessionStreaming, sessionCurrentThoughts.length, autoScrollIfNeeded]);
|
|
17039
|
-
|
|
17834
|
+
React16.useEffect(() => {
|
|
17040
17835
|
if (!isCurrentSessionStreaming) return;
|
|
17041
17836
|
if (sessionPendingToolCalls.length > 0) {
|
|
17042
17837
|
setTimeout(() => autoScrollIfNeeded(), 50);
|
|
@@ -17119,10 +17914,10 @@ function ChatWindow({
|
|
|
17119
17914
|
chatError && /* @__PURE__ */ jsxRuntime.jsx(ChatErrorBanner, { error: chatError })
|
|
17120
17915
|
] });
|
|
17121
17916
|
}
|
|
17122
|
-
var ChatErrorBanner =
|
|
17123
|
-
const [visible, setVisible] =
|
|
17917
|
+
var ChatErrorBanner = React16.memo(function ChatErrorBanner2({ error }) {
|
|
17918
|
+
const [visible, setVisible] = React16.useState(true);
|
|
17124
17919
|
const { setChatError } = useAgentStore();
|
|
17125
|
-
|
|
17920
|
+
React16.useEffect(() => {
|
|
17126
17921
|
const timer = setTimeout(() => {
|
|
17127
17922
|
setVisible(false);
|
|
17128
17923
|
setChatError(void 0);
|
|
@@ -17145,10 +17940,10 @@ var ChatErrorBanner = React24.memo(function ChatErrorBanner2({ error }) {
|
|
|
17145
17940
|
)
|
|
17146
17941
|
] }) });
|
|
17147
17942
|
});
|
|
17148
|
-
var ChatWindow_default =
|
|
17149
|
-
var MessageImage =
|
|
17150
|
-
const [loaded, setLoaded] =
|
|
17151
|
-
const [error, setError] =
|
|
17943
|
+
var ChatWindow_default = React16.memo(ChatWindow);
|
|
17944
|
+
var MessageImage = React16.memo(function MessageImage2({ src, alt }) {
|
|
17945
|
+
const [loaded, setLoaded] = React16.useState(false);
|
|
17946
|
+
const [error, setError] = React16.useState(false);
|
|
17152
17947
|
if (error) {
|
|
17153
17948
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 p-3 bg-zinc-800/50 rounded-lg text-zinc-500 text-sm", children: [
|
|
17154
17949
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ImageIcon, { size: 16 }),
|
|
@@ -17170,7 +17965,7 @@ var MessageImage = React24.memo(function MessageImage2({ src, alt }) {
|
|
|
17170
17965
|
)
|
|
17171
17966
|
] });
|
|
17172
17967
|
});
|
|
17173
|
-
var MessageVideo =
|
|
17968
|
+
var MessageVideo = React16.memo(function MessageVideo2({ src }) {
|
|
17174
17969
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "my-2 relative rounded-lg overflow-hidden bg-zinc-900 border border-zinc-800", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
17175
17970
|
"video",
|
|
17176
17971
|
{
|
|
@@ -17182,12 +17977,12 @@ var MessageVideo = React24.memo(function MessageVideo2({ src }) {
|
|
|
17182
17977
|
}
|
|
17183
17978
|
) });
|
|
17184
17979
|
});
|
|
17185
|
-
var ImagePreview =
|
|
17980
|
+
var ImagePreview = React16.memo(function ImagePreview2({
|
|
17186
17981
|
src,
|
|
17187
17982
|
alt,
|
|
17188
17983
|
onClose
|
|
17189
17984
|
}) {
|
|
17190
|
-
|
|
17985
|
+
React16.useEffect(() => {
|
|
17191
17986
|
const handleKeyDown = (e) => {
|
|
17192
17987
|
if (e.key === "Escape") {
|
|
17193
17988
|
onClose();
|
|
@@ -17196,7 +17991,7 @@ var ImagePreview = React24.memo(function ImagePreview2({
|
|
|
17196
17991
|
window.addEventListener("keydown", handleKeyDown);
|
|
17197
17992
|
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
17198
17993
|
}, [onClose]);
|
|
17199
|
-
const handleDownload =
|
|
17994
|
+
const handleDownload = React16.useCallback((e) => {
|
|
17200
17995
|
e.stopPropagation();
|
|
17201
17996
|
const link2 = document.createElement("a");
|
|
17202
17997
|
link2.href = src;
|
|
@@ -17361,7 +18156,7 @@ function CompactThinking({ thoughts }) {
|
|
|
17361
18156
|
] });
|
|
17362
18157
|
}
|
|
17363
18158
|
function ToolCallCard3({ toolCall }) {
|
|
17364
|
-
const [showDetails, setShowDetails] =
|
|
18159
|
+
const [showDetails, setShowDetails] = React16.useState(false);
|
|
17365
18160
|
const isPending = !toolCall.result && toolCall.status !== "completed";
|
|
17366
18161
|
toolCall.status === "completed" || toolCall.result;
|
|
17367
18162
|
const toolName = toolCall.displayName || toolCall.name?.replace("comfy_", "Workflow ") || "Tool";
|
|
@@ -17436,7 +18231,7 @@ function FullThinking({ thoughts }) {
|
|
|
17436
18231
|
] });
|
|
17437
18232
|
}
|
|
17438
18233
|
function ThinkingProcess({ thoughts, collapsed = false, compact = false }) {
|
|
17439
|
-
const [expanded, setExpanded] =
|
|
18234
|
+
const [expanded, setExpanded] = React16.useState(!collapsed);
|
|
17440
18235
|
if (thoughts.length === 0) return null;
|
|
17441
18236
|
if (compact) {
|
|
17442
18237
|
return /* @__PURE__ */ jsxRuntime.jsx(CompactThinking, { thoughts });
|
|
@@ -17469,14 +18264,14 @@ function ThinkingProcess({ thoughts, collapsed = false, compact = false }) {
|
|
|
17469
18264
|
}
|
|
17470
18265
|
function ToolConfirmDialog({ toolCall }) {
|
|
17471
18266
|
const { removePendingToolCall } = useAgentStore();
|
|
17472
|
-
const [isEditing, setIsEditing] =
|
|
17473
|
-
const [editedArguments, setEditedArguments] =
|
|
18267
|
+
const [isEditing, setIsEditing] = React16.useState(false);
|
|
18268
|
+
const [editedArguments, setEditedArguments] = React16.useState(
|
|
17474
18269
|
JSON.stringify(toolCall.arguments, null, 2)
|
|
17475
18270
|
);
|
|
17476
|
-
const [rejectReason, setRejectReason] =
|
|
17477
|
-
const [loading, setLoading] =
|
|
17478
|
-
const [showRejectInput, setShowRejectInput] =
|
|
17479
|
-
const [error, setError] =
|
|
18271
|
+
const [rejectReason, setRejectReason] = React16.useState("");
|
|
18272
|
+
const [loading, setLoading] = React16.useState(false);
|
|
18273
|
+
const [showRejectInput, setShowRejectInput] = React16.useState(false);
|
|
18274
|
+
const [error, setError] = React16.useState("");
|
|
17480
18275
|
const handleConfirm = async () => {
|
|
17481
18276
|
setLoading(true);
|
|
17482
18277
|
setError("");
|
|
@@ -17637,7 +18432,7 @@ function ToolConfirmDialog({ toolCall }) {
|
|
|
17637
18432
|
}
|
|
17638
18433
|
var Dialog = DialogPrimitive__namespace.Root;
|
|
17639
18434
|
var DialogPortal = DialogPrimitive__namespace.Portal;
|
|
17640
|
-
var DialogOverlay =
|
|
18435
|
+
var DialogOverlay = React16__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
17641
18436
|
DialogPrimitive__namespace.Overlay,
|
|
17642
18437
|
{
|
|
17643
18438
|
ref,
|
|
@@ -17649,7 +18444,7 @@ var DialogOverlay = React24__namespace.forwardRef(({ className, ...props }, ref)
|
|
|
17649
18444
|
}
|
|
17650
18445
|
));
|
|
17651
18446
|
DialogOverlay.displayName = DialogPrimitive__namespace.Overlay.displayName;
|
|
17652
|
-
var DialogContent =
|
|
18447
|
+
var DialogContent = React16__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(DialogPortal, { children: [
|
|
17653
18448
|
/* @__PURE__ */ jsxRuntime.jsx(DialogOverlay, {}),
|
|
17654
18449
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
17655
18450
|
DialogPrimitive__namespace.Content,
|
|
@@ -17699,7 +18494,7 @@ var DialogFooter = ({
|
|
|
17699
18494
|
}
|
|
17700
18495
|
);
|
|
17701
18496
|
DialogFooter.displayName = "DialogFooter";
|
|
17702
|
-
var DialogTitle =
|
|
18497
|
+
var DialogTitle = React16__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
17703
18498
|
DialogPrimitive__namespace.Title,
|
|
17704
18499
|
{
|
|
17705
18500
|
ref,
|
|
@@ -17711,7 +18506,7 @@ var DialogTitle = React24__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
17711
18506
|
}
|
|
17712
18507
|
));
|
|
17713
18508
|
DialogTitle.displayName = DialogPrimitive__namespace.Title.displayName;
|
|
17714
|
-
var DialogDescription =
|
|
18509
|
+
var DialogDescription = React16__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
17715
18510
|
DialogPrimitive__namespace.Description,
|
|
17716
18511
|
{
|
|
17717
18512
|
ref,
|
|
@@ -17721,24 +18516,9 @@ var DialogDescription = React24__namespace.forwardRef(({ className, ...props },
|
|
|
17721
18516
|
));
|
|
17722
18517
|
DialogDescription.displayName = DialogPrimitive__namespace.Description.displayName;
|
|
17723
18518
|
|
|
17724
|
-
// ../../node_modules/clsx/dist/clsx.mjs
|
|
17725
|
-
function r2(e) {
|
|
17726
|
-
var t, f, n = "";
|
|
17727
|
-
if ("string" == typeof e || "number" == typeof e) n += e;
|
|
17728
|
-
else if ("object" == typeof e) if (Array.isArray(e)) {
|
|
17729
|
-
var o = e.length;
|
|
17730
|
-
for (t = 0; t < o; t++) e[t] && (f = r2(e[t])) && (n && (n += " "), n += f);
|
|
17731
|
-
} else for (f in e) e[f] && (n && (n += " "), n += f);
|
|
17732
|
-
return n;
|
|
17733
|
-
}
|
|
17734
|
-
function clsx2() {
|
|
17735
|
-
for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r2(e)) && (n && (n += " "), n += t);
|
|
17736
|
-
return n;
|
|
17737
|
-
}
|
|
17738
|
-
|
|
17739
18519
|
// ../../node_modules/class-variance-authority/dist/index.mjs
|
|
17740
18520
|
var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
|
|
17741
|
-
var cx =
|
|
18521
|
+
var cx = clsx;
|
|
17742
18522
|
var cva = (base, config) => (props) => {
|
|
17743
18523
|
var _config_compoundVariants;
|
|
17744
18524
|
if ((config === null || config === void 0 ? void 0 : config.variants) == null) return cx(base, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
|
|
@@ -17802,7 +18582,7 @@ var buttonVariants = cva(
|
|
|
17802
18582
|
}
|
|
17803
18583
|
}
|
|
17804
18584
|
);
|
|
17805
|
-
var Button =
|
|
18585
|
+
var Button = React16__namespace.forwardRef(
|
|
17806
18586
|
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
17807
18587
|
const Comp = asChild ? reactSlot.Slot : "button";
|
|
17808
18588
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -17819,7 +18599,7 @@ Button.displayName = "Button";
|
|
|
17819
18599
|
var Badge = ({ children, className }) => {
|
|
17820
18600
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("inline-flex items-center rounded-md bg-muted px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", className), children });
|
|
17821
18601
|
};
|
|
17822
|
-
var Card =
|
|
18602
|
+
var Card = React16__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
17823
18603
|
"div",
|
|
17824
18604
|
{
|
|
17825
18605
|
ref,
|
|
@@ -17831,7 +18611,7 @@ var Card = React24__namespace.forwardRef(({ className, ...props }, ref) => /* @_
|
|
|
17831
18611
|
}
|
|
17832
18612
|
));
|
|
17833
18613
|
Card.displayName = "Card";
|
|
17834
|
-
var CardHeader =
|
|
18614
|
+
var CardHeader = React16__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
17835
18615
|
"div",
|
|
17836
18616
|
{
|
|
17837
18617
|
ref,
|
|
@@ -17840,7 +18620,7 @@ var CardHeader = React24__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
17840
18620
|
}
|
|
17841
18621
|
));
|
|
17842
18622
|
CardHeader.displayName = "CardHeader";
|
|
17843
|
-
var CardTitle =
|
|
18623
|
+
var CardTitle = React16__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
17844
18624
|
"h3",
|
|
17845
18625
|
{
|
|
17846
18626
|
ref,
|
|
@@ -17852,7 +18632,7 @@ var CardTitle = React24__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
17852
18632
|
}
|
|
17853
18633
|
));
|
|
17854
18634
|
CardTitle.displayName = "CardTitle";
|
|
17855
|
-
var CardDescription =
|
|
18635
|
+
var CardDescription = React16__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
17856
18636
|
"p",
|
|
17857
18637
|
{
|
|
17858
18638
|
ref,
|
|
@@ -17861,9 +18641,9 @@ var CardDescription = React24__namespace.forwardRef(({ className, ...props }, re
|
|
|
17861
18641
|
}
|
|
17862
18642
|
));
|
|
17863
18643
|
CardDescription.displayName = "CardDescription";
|
|
17864
|
-
var CardContent =
|
|
18644
|
+
var CardContent = React16__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("p-6 pt-0", className), ...props }));
|
|
17865
18645
|
CardContent.displayName = "CardContent";
|
|
17866
|
-
var CardFooter =
|
|
18646
|
+
var CardFooter = React16__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
17867
18647
|
"div",
|
|
17868
18648
|
{
|
|
17869
18649
|
ref,
|
|
@@ -17885,7 +18665,7 @@ var Separator = ({ className, orientation = "horizontal", decorative = true }) =
|
|
|
17885
18665
|
}
|
|
17886
18666
|
);
|
|
17887
18667
|
};
|
|
17888
|
-
var ScrollArea =
|
|
18668
|
+
var ScrollArea = React16__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
17889
18669
|
ScrollAreaPrimitive__namespace.Root,
|
|
17890
18670
|
{
|
|
17891
18671
|
ref,
|
|
@@ -17899,7 +18679,7 @@ var ScrollArea = React24__namespace.forwardRef(({ className, children, ...props
|
|
|
17899
18679
|
}
|
|
17900
18680
|
));
|
|
17901
18681
|
ScrollArea.displayName = ScrollAreaPrimitive__namespace.Root.displayName;
|
|
17902
|
-
var ScrollBar =
|
|
18682
|
+
var ScrollBar = React16__namespace.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
17903
18683
|
ScrollAreaPrimitive__namespace.ScrollAreaScrollbar,
|
|
17904
18684
|
{
|
|
17905
18685
|
ref,
|
|
@@ -18193,7 +18973,7 @@ var PlanProgressPanel = ({
|
|
|
18193
18973
|
] });
|
|
18194
18974
|
};
|
|
18195
18975
|
var PlanProgressPanel_default = PlanProgressPanel;
|
|
18196
|
-
var Textarea =
|
|
18976
|
+
var Textarea = React16__namespace.forwardRef(
|
|
18197
18977
|
({ className, theme, ...props }, ref) => {
|
|
18198
18978
|
const themeClass = theme === "dark" ? "bg-gray-800 text-white" : "bg-white text-black";
|
|
18199
18979
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -18217,8 +18997,8 @@ var HumanInputDialog = ({
|
|
|
18217
18997
|
onSubmit,
|
|
18218
18998
|
onCancel
|
|
18219
18999
|
}) => {
|
|
18220
|
-
const [input, setInput] =
|
|
18221
|
-
const [error, setError] =
|
|
19000
|
+
const [input, setInput] = React16.useState("");
|
|
19001
|
+
const [error, setError] = React16.useState(null);
|
|
18222
19002
|
const handleSubmit = () => {
|
|
18223
19003
|
if (!input.trim()) {
|
|
18224
19004
|
setError("\u8BF7\u8F93\u5165\u5185\u5BB9");
|
|
@@ -18319,22 +19099,22 @@ var HumanInputDialog = ({
|
|
|
18319
19099
|
};
|
|
18320
19100
|
var HumanInputDialog_default = HumanInputDialog;
|
|
18321
19101
|
function ShareModal({ sessionId, sessionTitle, isOpen, onClose }) {
|
|
18322
|
-
const [loading, setLoading] =
|
|
18323
|
-
const [creating, setCreating] =
|
|
18324
|
-
const [shares, setShares] =
|
|
18325
|
-
const [copied, setCopied] =
|
|
18326
|
-
const [showCreateForm, setShowCreateForm] =
|
|
18327
|
-
const [title, setTitle] =
|
|
18328
|
-
const [hasPassword, setHasPassword] =
|
|
18329
|
-
const [password, setPassword] =
|
|
18330
|
-
const [expireDays, setExpireDays] =
|
|
18331
|
-
const [editingShare, setEditingShare] =
|
|
18332
|
-
const [editTitle, setEditTitle] =
|
|
18333
|
-
const [editHasPassword, setEditHasPassword] =
|
|
18334
|
-
const [editPassword, setEditPassword] =
|
|
18335
|
-
const [editEnabled, setEditEnabled] =
|
|
18336
|
-
const [updating, setUpdating] =
|
|
18337
|
-
|
|
19102
|
+
const [loading, setLoading] = React16.useState(true);
|
|
19103
|
+
const [creating, setCreating] = React16.useState(false);
|
|
19104
|
+
const [shares, setShares] = React16.useState([]);
|
|
19105
|
+
const [copied, setCopied] = React16.useState(null);
|
|
19106
|
+
const [showCreateForm, setShowCreateForm] = React16.useState(false);
|
|
19107
|
+
const [title, setTitle] = React16.useState("");
|
|
19108
|
+
const [hasPassword, setHasPassword] = React16.useState(false);
|
|
19109
|
+
const [password, setPassword] = React16.useState("");
|
|
19110
|
+
const [expireDays, setExpireDays] = React16.useState(30);
|
|
19111
|
+
const [editingShare, setEditingShare] = React16.useState(null);
|
|
19112
|
+
const [editTitle, setEditTitle] = React16.useState("");
|
|
19113
|
+
const [editHasPassword, setEditHasPassword] = React16.useState(false);
|
|
19114
|
+
const [editPassword, setEditPassword] = React16.useState("");
|
|
19115
|
+
const [editEnabled, setEditEnabled] = React16.useState(true);
|
|
19116
|
+
const [updating, setUpdating] = React16.useState(false);
|
|
19117
|
+
React16.useEffect(() => {
|
|
18338
19118
|
if (!isOpen || !sessionId) return;
|
|
18339
19119
|
async function loadShares() {
|
|
18340
19120
|
try {
|
|
@@ -18738,17 +19518,17 @@ var SaveTemplateDialog = ({
|
|
|
18738
19518
|
onCancel,
|
|
18739
19519
|
isSaving = false
|
|
18740
19520
|
}) => {
|
|
18741
|
-
const [name, setName] =
|
|
18742
|
-
const [description, setDescription] =
|
|
18743
|
-
const [content, setContent] =
|
|
18744
|
-
const [category, setCategory] =
|
|
18745
|
-
const [visibility, setVisibility] =
|
|
18746
|
-
const [variables, setVariables] =
|
|
18747
|
-
const [error, setError] =
|
|
18748
|
-
|
|
19521
|
+
const [name, setName] = React16.useState("");
|
|
19522
|
+
const [description, setDescription] = React16.useState("");
|
|
19523
|
+
const [content, setContent] = React16.useState(originalContent);
|
|
19524
|
+
const [category, setCategory] = React16.useState("\u5176\u4ED6");
|
|
19525
|
+
const [visibility, setVisibility] = React16.useState("PRIVATE");
|
|
19526
|
+
const [variables, setVariables] = React16.useState([]);
|
|
19527
|
+
const [error, setError] = React16.useState(null);
|
|
19528
|
+
React16.useEffect(() => {
|
|
18749
19529
|
setContent(originalContent);
|
|
18750
19530
|
}, [originalContent]);
|
|
18751
|
-
|
|
19531
|
+
React16.useEffect(() => {
|
|
18752
19532
|
const detectedVars = extractVariables(content);
|
|
18753
19533
|
setVariables(detectedVars);
|
|
18754
19534
|
}, [content]);
|
|
@@ -18941,8 +19721,8 @@ var UpdateTemplateDialog = ({
|
|
|
18941
19721
|
onCancel,
|
|
18942
19722
|
isUpdating = false
|
|
18943
19723
|
}) => {
|
|
18944
|
-
const [changeDescription, setChangeDescription] =
|
|
18945
|
-
const [error, setError] =
|
|
19724
|
+
const [changeDescription, setChangeDescription] = React16.useState("");
|
|
19725
|
+
const [error, setError] = React16.useState(null);
|
|
18946
19726
|
const handleUpdate = () => {
|
|
18947
19727
|
if (!changeDescription.trim()) {
|
|
18948
19728
|
setError("\u8BF7\u8F93\u5165\u53D8\u66F4\u8BF4\u660E");
|
|
@@ -19081,7 +19861,7 @@ var TemplateSourceBadge = ({
|
|
|
19081
19861
|
onUpdateTemplate,
|
|
19082
19862
|
onSaveAsNewTemplate
|
|
19083
19863
|
}) => {
|
|
19084
|
-
const [isExpanded, setIsExpanded] =
|
|
19864
|
+
const [isExpanded, setIsExpanded] = React16.useState(false);
|
|
19085
19865
|
if (!template) return null;
|
|
19086
19866
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2", children: [
|
|
19087
19867
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -19138,12 +19918,12 @@ var TemplateSourceBadge = ({
|
|
|
19138
19918
|
};
|
|
19139
19919
|
var TemplateSourceBadge_default = TemplateSourceBadge;
|
|
19140
19920
|
var TemplateSelector = ({ isOpen, onClose, onSelectTemplate }) => {
|
|
19141
|
-
const [activeTab, setActiveTab] =
|
|
19142
|
-
const [searchKeyword, setSearchKeyword] =
|
|
19143
|
-
const [selectedCategory, setSelectedCategory] =
|
|
19144
|
-
const [loading, setLoading] =
|
|
19145
|
-
const [templates, setTemplates] =
|
|
19146
|
-
const [categories, setCategories] =
|
|
19921
|
+
const [activeTab, setActiveTab] = React16.useState("recent");
|
|
19922
|
+
const [searchKeyword, setSearchKeyword] = React16.useState("");
|
|
19923
|
+
const [selectedCategory, setSelectedCategory] = React16.useState("");
|
|
19924
|
+
const [loading, setLoading] = React16.useState(false);
|
|
19925
|
+
const [templates, setTemplates] = React16.useState([]);
|
|
19926
|
+
const [categories, setCategories] = React16.useState([]);
|
|
19147
19927
|
const loadTemplates = async () => {
|
|
19148
19928
|
try {
|
|
19149
19929
|
setLoading(true);
|
|
@@ -19198,14 +19978,14 @@ var TemplateSelector = ({ isOpen, onClose, onSelectTemplate }) => {
|
|
|
19198
19978
|
setLoading(false);
|
|
19199
19979
|
}
|
|
19200
19980
|
};
|
|
19201
|
-
|
|
19981
|
+
React16.useEffect(() => {
|
|
19202
19982
|
if (isOpen) {
|
|
19203
19983
|
setSearchKeyword("");
|
|
19204
19984
|
setSelectedCategory("");
|
|
19205
19985
|
loadTemplates();
|
|
19206
19986
|
}
|
|
19207
19987
|
}, [isOpen, activeTab]);
|
|
19208
|
-
|
|
19988
|
+
React16.useEffect(() => {
|
|
19209
19989
|
const timer = setTimeout(() => {
|
|
19210
19990
|
if (searchKeyword.trim()) {
|
|
19211
19991
|
searchTemplates();
|
|
@@ -19354,11 +20134,11 @@ var TemplateVariableDialog = ({
|
|
|
19354
20134
|
onSend,
|
|
19355
20135
|
onClose
|
|
19356
20136
|
}) => {
|
|
19357
|
-
const [formValues, setFormValues] =
|
|
19358
|
-
const [formErrors, setFormErrors] =
|
|
19359
|
-
const [isSending, setIsSending] =
|
|
19360
|
-
const [showPreview, setShowPreview] =
|
|
19361
|
-
|
|
20137
|
+
const [formValues, setFormValues] = React16.useState({});
|
|
20138
|
+
const [formErrors, setFormErrors] = React16.useState({});
|
|
20139
|
+
const [isSending, setIsSending] = React16.useState(false);
|
|
20140
|
+
const [showPreview, setShowPreview] = React16.useState(true);
|
|
20141
|
+
React16.useEffect(() => {
|
|
19362
20142
|
if (template && template.variables) {
|
|
19363
20143
|
const initialValues = {};
|
|
19364
20144
|
template.variables.forEach((variable) => {
|
|
@@ -19901,12 +20681,12 @@ var useVoiceRecognition = (config = {}) => {
|
|
|
19901
20681
|
engine = "webspeech",
|
|
19902
20682
|
customProvider: customProvider2
|
|
19903
20683
|
} = config;
|
|
19904
|
-
const [status, setStatus] =
|
|
19905
|
-
const [result, setResult] =
|
|
19906
|
-
const [error, setError] =
|
|
19907
|
-
const [isSupported, setIsSupported] =
|
|
19908
|
-
const providerRef =
|
|
19909
|
-
|
|
20684
|
+
const [status, setStatus] = React16.useState("idle");
|
|
20685
|
+
const [result, setResult] = React16.useState(null);
|
|
20686
|
+
const [error, setError] = React16.useState(null);
|
|
20687
|
+
const [isSupported, setIsSupported] = React16.useState(true);
|
|
20688
|
+
const providerRef = React16.useRef(null);
|
|
20689
|
+
React16.useEffect(() => {
|
|
19910
20690
|
if (engine === "webspeech") {
|
|
19911
20691
|
providerRef.current = createWebSpeechProvider(config);
|
|
19912
20692
|
} else if (engine === "custom" && customProvider2) {
|
|
@@ -19930,7 +20710,7 @@ var useVoiceRecognition = (config = {}) => {
|
|
|
19930
20710
|
providerRef.current = null;
|
|
19931
20711
|
};
|
|
19932
20712
|
}, [engine, customProvider2, config.language, config.maxDuration, config.autoStopSilence]);
|
|
19933
|
-
const startRecording =
|
|
20713
|
+
const startRecording = React16.useCallback(async () => {
|
|
19934
20714
|
setError(null);
|
|
19935
20715
|
setResult(null);
|
|
19936
20716
|
setStatus("requesting");
|
|
@@ -19945,7 +20725,7 @@ var useVoiceRecognition = (config = {}) => {
|
|
|
19945
20725
|
setStatus("error");
|
|
19946
20726
|
}
|
|
19947
20727
|
}, []);
|
|
19948
|
-
const stopRecording =
|
|
20728
|
+
const stopRecording = React16.useCallback(() => {
|
|
19949
20729
|
providerRef.current?.stop();
|
|
19950
20730
|
}, []);
|
|
19951
20731
|
return {
|
|
@@ -19963,14 +20743,14 @@ var VoiceWaveform = ({
|
|
|
19963
20743
|
className = "",
|
|
19964
20744
|
color: color2 = "#d8ff00"
|
|
19965
20745
|
}) => {
|
|
19966
|
-
const canvasRef =
|
|
19967
|
-
const animationRef =
|
|
19968
|
-
const audioContextRef =
|
|
19969
|
-
const analyserRef =
|
|
19970
|
-
const dataArrayRef =
|
|
19971
|
-
const sourceRef =
|
|
19972
|
-
const streamRef =
|
|
19973
|
-
const draw =
|
|
20746
|
+
const canvasRef = React16.useRef(null);
|
|
20747
|
+
const animationRef = React16.useRef();
|
|
20748
|
+
const audioContextRef = React16.useRef(null);
|
|
20749
|
+
const analyserRef = React16.useRef(null);
|
|
20750
|
+
const dataArrayRef = React16.useRef(null);
|
|
20751
|
+
const sourceRef = React16.useRef(null);
|
|
20752
|
+
const streamRef = React16.useRef(null);
|
|
20753
|
+
const draw = React16.useCallback(() => {
|
|
19974
20754
|
const canvas = canvasRef.current;
|
|
19975
20755
|
const ctx = canvas?.getContext("2d");
|
|
19976
20756
|
const analyser = analyserRef.current;
|
|
@@ -20018,7 +20798,7 @@ var VoiceWaveform = ({
|
|
|
20018
20798
|
}
|
|
20019
20799
|
animationRef.current = requestAnimationFrame(draw);
|
|
20020
20800
|
}, [color2]);
|
|
20021
|
-
|
|
20801
|
+
React16.useEffect(() => {
|
|
20022
20802
|
if (!isRecording) {
|
|
20023
20803
|
if (animationRef.current) {
|
|
20024
20804
|
cancelAnimationFrame(animationRef.current);
|
|
@@ -20090,10 +20870,10 @@ var VoiceInput = ({
|
|
|
20090
20870
|
className = ""
|
|
20091
20871
|
}) => {
|
|
20092
20872
|
const { enabled = true } = config;
|
|
20093
|
-
const resultHandledRef =
|
|
20094
|
-
const lastResultRef =
|
|
20095
|
-
const [isExpanded, setIsExpanded] =
|
|
20096
|
-
const [showResult, setShowResult] =
|
|
20873
|
+
const resultHandledRef = React16.useRef(false);
|
|
20874
|
+
const lastResultRef = React16.useRef(null);
|
|
20875
|
+
const [isExpanded, setIsExpanded] = React16.useState(false);
|
|
20876
|
+
const [showResult, setShowResult] = React16.useState(false);
|
|
20097
20877
|
const {
|
|
20098
20878
|
status,
|
|
20099
20879
|
result,
|
|
@@ -20107,34 +20887,34 @@ var VoiceInput = ({
|
|
|
20107
20887
|
const isRecognizing = status === "recognizing";
|
|
20108
20888
|
const isCompleted = status === "completed";
|
|
20109
20889
|
const hasError = status === "error";
|
|
20110
|
-
const handleStart =
|
|
20890
|
+
const handleStart = React16.useCallback(async () => {
|
|
20111
20891
|
if (!isSupported || disabled) return;
|
|
20112
20892
|
resultHandledRef.current = false;
|
|
20113
20893
|
setIsExpanded(true);
|
|
20114
20894
|
await startRecording();
|
|
20115
20895
|
}, [isSupported, disabled, startRecording]);
|
|
20116
|
-
const handleStop =
|
|
20896
|
+
const handleStop = React16.useCallback(() => {
|
|
20117
20897
|
stopRecording();
|
|
20118
20898
|
}, [stopRecording]);
|
|
20119
|
-
const handleConfirm =
|
|
20899
|
+
const handleConfirm = React16.useCallback((text3) => {
|
|
20120
20900
|
onResult(text3);
|
|
20121
20901
|
setIsExpanded(false);
|
|
20122
20902
|
setShowResult(false);
|
|
20123
20903
|
lastResultRef.current = null;
|
|
20124
20904
|
}, [onResult]);
|
|
20125
|
-
const handleCancel =
|
|
20905
|
+
const handleCancel = React16.useCallback(() => {
|
|
20126
20906
|
stopRecording();
|
|
20127
20907
|
setIsExpanded(false);
|
|
20128
20908
|
setShowResult(false);
|
|
20129
20909
|
resultHandledRef.current = false;
|
|
20130
20910
|
lastResultRef.current = null;
|
|
20131
20911
|
}, [stopRecording]);
|
|
20132
|
-
|
|
20912
|
+
React16.useEffect(() => {
|
|
20133
20913
|
if (result?.text) {
|
|
20134
20914
|
lastResultRef.current = result;
|
|
20135
20915
|
}
|
|
20136
20916
|
}, [result]);
|
|
20137
|
-
|
|
20917
|
+
React16.useEffect(() => {
|
|
20138
20918
|
if (isCompleted && !resultHandledRef.current) {
|
|
20139
20919
|
resultHandledRef.current = true;
|
|
20140
20920
|
const finalText = lastResultRef.current?.text || result?.text;
|
|
@@ -20151,14 +20931,14 @@ var VoiceInput = ({
|
|
|
20151
20931
|
}
|
|
20152
20932
|
}
|
|
20153
20933
|
}, [isCompleted, result, config.autoConfirm, handleConfirm]);
|
|
20154
|
-
|
|
20934
|
+
React16.useEffect(() => {
|
|
20155
20935
|
if (isRecording) {
|
|
20156
20936
|
resultHandledRef.current = false;
|
|
20157
20937
|
lastResultRef.current = null;
|
|
20158
20938
|
setShowResult(false);
|
|
20159
20939
|
}
|
|
20160
20940
|
}, [isRecording]);
|
|
20161
|
-
|
|
20941
|
+
React16.useEffect(() => {
|
|
20162
20942
|
if (error && onError) {
|
|
20163
20943
|
onError(error);
|
|
20164
20944
|
setTimeout(() => {
|
|
@@ -20261,9 +21041,9 @@ var VoiceButton = ({
|
|
|
20261
21041
|
onStart,
|
|
20262
21042
|
onStop
|
|
20263
21043
|
}) => {
|
|
20264
|
-
const buttonRef =
|
|
21044
|
+
const buttonRef = React16.useRef(null);
|
|
20265
21045
|
const isTouchDevice = typeof window !== "undefined" && ("ontouchstart" in window || navigator.maxTouchPoints > 0);
|
|
20266
|
-
const handleClick =
|
|
21046
|
+
const handleClick = React16.useCallback(() => {
|
|
20267
21047
|
if (disabled) return;
|
|
20268
21048
|
if (isRecording) {
|
|
20269
21049
|
onStop();
|
|
@@ -20271,10 +21051,10 @@ var VoiceButton = ({
|
|
|
20271
21051
|
onStart();
|
|
20272
21052
|
}
|
|
20273
21053
|
}, [disabled, isRecording, onStart, onStop]);
|
|
20274
|
-
const pressTimerRef =
|
|
20275
|
-
const longPressRef =
|
|
21054
|
+
const pressTimerRef = React16.useRef(null);
|
|
21055
|
+
const longPressRef = React16.useRef(false);
|
|
20276
21056
|
const LONG_PRESS_DURATION = 300;
|
|
20277
|
-
const handleTouchStart =
|
|
21057
|
+
const handleTouchStart = React16.useCallback((e) => {
|
|
20278
21058
|
e.preventDefault();
|
|
20279
21059
|
if (disabled) return;
|
|
20280
21060
|
longPressRef.current = false;
|
|
@@ -20283,7 +21063,7 @@ var VoiceButton = ({
|
|
|
20283
21063
|
onStart();
|
|
20284
21064
|
}, LONG_PRESS_DURATION);
|
|
20285
21065
|
}, [disabled, onStart]);
|
|
20286
|
-
const handleTouchEnd =
|
|
21066
|
+
const handleTouchEnd = React16.useCallback((e) => {
|
|
20287
21067
|
e.preventDefault();
|
|
20288
21068
|
if (pressTimerRef.current) {
|
|
20289
21069
|
clearTimeout(pressTimerRef.current);
|
|
@@ -20337,12 +21117,12 @@ var VoiceRecordingModal = ({
|
|
|
20337
21117
|
const isRecognizing = status === "recognizing";
|
|
20338
21118
|
const isCompleted = status === "completed";
|
|
20339
21119
|
const hasError = status === "error";
|
|
20340
|
-
const hasConfirmedRef =
|
|
20341
|
-
const onConfirmRef =
|
|
20342
|
-
|
|
21120
|
+
const hasConfirmedRef = React16.useRef(false);
|
|
21121
|
+
const onConfirmRef = React16.useRef(onConfirm);
|
|
21122
|
+
React16.useEffect(() => {
|
|
20343
21123
|
onConfirmRef.current = onConfirm;
|
|
20344
21124
|
}, [onConfirm]);
|
|
20345
|
-
|
|
21125
|
+
React16.useEffect(() => {
|
|
20346
21126
|
if (isCompleted && result?.isFinal && result.text && !hasConfirmedRef.current) {
|
|
20347
21127
|
hasConfirmedRef.current = true;
|
|
20348
21128
|
const timer = setTimeout(() => {
|
|
@@ -20351,7 +21131,7 @@ var VoiceRecordingModal = ({
|
|
|
20351
21131
|
return () => clearTimeout(timer);
|
|
20352
21132
|
}
|
|
20353
21133
|
}, [isCompleted, result]);
|
|
20354
|
-
|
|
21134
|
+
React16.useEffect(() => {
|
|
20355
21135
|
if (!visible) {
|
|
20356
21136
|
hasConfirmedRef.current = false;
|
|
20357
21137
|
}
|
|
@@ -20482,8 +21262,8 @@ var VoiceInputButton = ({
|
|
|
20482
21262
|
style
|
|
20483
21263
|
}) => {
|
|
20484
21264
|
const { enabled = true } = config;
|
|
20485
|
-
const [modalVisible, setModalVisible] =
|
|
20486
|
-
const [hasPermission, setHasPermission] =
|
|
21265
|
+
const [modalVisible, setModalVisible] = React16.useState(false);
|
|
21266
|
+
const [hasPermission, setHasPermission] = React16.useState(null);
|
|
20487
21267
|
const {
|
|
20488
21268
|
status,
|
|
20489
21269
|
result,
|
|
@@ -20492,7 +21272,7 @@ var VoiceInputButton = ({
|
|
|
20492
21272
|
startRecording,
|
|
20493
21273
|
stopRecording
|
|
20494
21274
|
} = useVoiceRecognition(config);
|
|
20495
|
-
|
|
21275
|
+
React16.useEffect(() => {
|
|
20496
21276
|
if (typeof navigator === "undefined") return;
|
|
20497
21277
|
navigator.permissions?.query({ name: "microphone" }).then((permissionStatus) => {
|
|
20498
21278
|
setHasPermission(permissionStatus.state === "granted");
|
|
@@ -20502,7 +21282,7 @@ var VoiceInputButton = ({
|
|
|
20502
21282
|
}).catch(() => {
|
|
20503
21283
|
});
|
|
20504
21284
|
}, []);
|
|
20505
|
-
const handleOpenModal =
|
|
21285
|
+
const handleOpenModal = React16.useCallback(() => {
|
|
20506
21286
|
if (!isSupported) {
|
|
20507
21287
|
onError?.({
|
|
20508
21288
|
code: "NOT_SUPPORTED",
|
|
@@ -20513,17 +21293,17 @@ var VoiceInputButton = ({
|
|
|
20513
21293
|
}
|
|
20514
21294
|
setModalVisible(true);
|
|
20515
21295
|
}, [isSupported, onError]);
|
|
20516
|
-
const handleCloseModal =
|
|
21296
|
+
const handleCloseModal = React16.useCallback(() => {
|
|
20517
21297
|
if (status === "recording") {
|
|
20518
21298
|
stopRecording();
|
|
20519
21299
|
}
|
|
20520
21300
|
setModalVisible(false);
|
|
20521
21301
|
}, [status, stopRecording]);
|
|
20522
|
-
const handleConfirm =
|
|
21302
|
+
const handleConfirm = React16.useCallback((text3) => {
|
|
20523
21303
|
onResult(text3);
|
|
20524
21304
|
setModalVisible(false);
|
|
20525
21305
|
}, [onResult]);
|
|
20526
|
-
|
|
21306
|
+
React16.useEffect(() => {
|
|
20527
21307
|
if (error && onError) {
|
|
20528
21308
|
onError(error);
|
|
20529
21309
|
}
|
|
@@ -20567,14 +21347,14 @@ var VoiceInputButton = ({
|
|
|
20567
21347
|
};
|
|
20568
21348
|
|
|
20569
21349
|
// src/utils/cn.ts
|
|
20570
|
-
function
|
|
21350
|
+
function cn3(...inputs) {
|
|
20571
21351
|
return twMerge(clsx(inputs));
|
|
20572
21352
|
}
|
|
20573
21353
|
function useResizablePanel(defaultWidth, minWidth, maxWidth, onWidthChange) {
|
|
20574
|
-
const [width, setWidth] =
|
|
20575
|
-
const [isResizing, setIsResizing] =
|
|
20576
|
-
const containerRef =
|
|
20577
|
-
const startResize =
|
|
21354
|
+
const [width, setWidth] = React16.useState(defaultWidth);
|
|
21355
|
+
const [isResizing, setIsResizing] = React16.useState(false);
|
|
21356
|
+
const containerRef = React16.useRef(null);
|
|
21357
|
+
const startResize = React16.useCallback((e) => {
|
|
20578
21358
|
e.preventDefault();
|
|
20579
21359
|
setIsResizing(true);
|
|
20580
21360
|
const startX = e.clientX;
|
|
@@ -20600,7 +21380,7 @@ function useResizablePanel(defaultWidth, minWidth, maxWidth, onWidthChange) {
|
|
|
20600
21380
|
}, [width, minWidth, maxWidth, onWidthChange]);
|
|
20601
21381
|
return { width, isResizing, startResize, containerRef };
|
|
20602
21382
|
}
|
|
20603
|
-
var SidePanel =
|
|
21383
|
+
var SidePanel = React16.memo(function SidePanel2({
|
|
20604
21384
|
isOpen,
|
|
20605
21385
|
onClose,
|
|
20606
21386
|
title,
|
|
@@ -20623,7 +21403,7 @@ var SidePanel = React24.memo(function SidePanel2({
|
|
|
20623
21403
|
minWidth,
|
|
20624
21404
|
maxWidth
|
|
20625
21405
|
);
|
|
20626
|
-
|
|
21406
|
+
React16.useEffect(() => {
|
|
20627
21407
|
const handleKeyDown = (e) => {
|
|
20628
21408
|
if (e.key === "Escape" && isOpen) {
|
|
20629
21409
|
onClose();
|
|
@@ -20632,7 +21412,7 @@ var SidePanel = React24.memo(function SidePanel2({
|
|
|
20632
21412
|
window.addEventListener("keydown", handleKeyDown);
|
|
20633
21413
|
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
20634
21414
|
}, [isOpen, onClose]);
|
|
20635
|
-
|
|
21415
|
+
React16.useEffect(() => {
|
|
20636
21416
|
if (isOpen) {
|
|
20637
21417
|
const originalOverflow = document.body.style.overflow;
|
|
20638
21418
|
document.body.style.overflow = "hidden";
|
|
@@ -20654,7 +21434,7 @@ var SidePanel = React24.memo(function SidePanel2({
|
|
|
20654
21434
|
"div",
|
|
20655
21435
|
{
|
|
20656
21436
|
ref: containerRef,
|
|
20657
|
-
className:
|
|
21437
|
+
className: cn3(
|
|
20658
21438
|
"fixed right-0 top-0 h-full z-50 flex flex-col",
|
|
20659
21439
|
"bg-zinc-950 border-l border-zinc-800/50",
|
|
20660
21440
|
"shadow-2xl shadow-black/50",
|
|
@@ -20669,7 +21449,7 @@ var SidePanel = React24.memo(function SidePanel2({
|
|
|
20669
21449
|
resizable && !isFullscreen && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
20670
21450
|
"div",
|
|
20671
21451
|
{
|
|
20672
|
-
className:
|
|
21452
|
+
className: cn3(
|
|
20673
21453
|
"absolute left-0 top-0 bottom-0 w-4 -translate-x-1/2",
|
|
20674
21454
|
"cursor-col-resize z-10 flex items-center justify-center",
|
|
20675
21455
|
"group hover:bg-zinc-800/50 transition-colors",
|
|
@@ -20677,7 +21457,7 @@ var SidePanel = React24.memo(function SidePanel2({
|
|
|
20677
21457
|
),
|
|
20678
21458
|
onMouseDown: startResize,
|
|
20679
21459
|
children: [
|
|
20680
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className:
|
|
21460
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: cn3(
|
|
20681
21461
|
"w-1 h-12 rounded-full bg-zinc-700",
|
|
20682
21462
|
"group-hover:bg-zinc-500 transition-colors",
|
|
20683
21463
|
isResizing && "bg-zinc-400"
|
|
@@ -20686,7 +21466,7 @@ var SidePanel = React24.memo(function SidePanel2({
|
|
|
20686
21466
|
lucideReact.GripVertical,
|
|
20687
21467
|
{
|
|
20688
21468
|
size: 14,
|
|
20689
|
-
className:
|
|
21469
|
+
className: cn3(
|
|
20690
21470
|
"absolute text-zinc-600 opacity-0",
|
|
20691
21471
|
"group-hover:opacity-100 transition-opacity",
|
|
20692
21472
|
isResizing && "opacity-100 text-zinc-400"
|
|
@@ -20723,7 +21503,7 @@ var SidePanel = React24.memo(function SidePanel2({
|
|
|
20723
21503
|
)
|
|
20724
21504
|
] })
|
|
20725
21505
|
] }),
|
|
20726
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className:
|
|
21506
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: cn3(
|
|
20727
21507
|
"flex-1 overflow-hidden flex flex-col",
|
|
20728
21508
|
contentClassName
|
|
20729
21509
|
), children }),
|
|
@@ -20734,7 +21514,7 @@ var SidePanel = React24.memo(function SidePanel2({
|
|
|
20734
21514
|
isResizing && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "fixed inset-0 z-[60]" })
|
|
20735
21515
|
] });
|
|
20736
21516
|
});
|
|
20737
|
-
var ViewTabs =
|
|
21517
|
+
var ViewTabs = React16.memo(function ViewTabs2({
|
|
20738
21518
|
activeView,
|
|
20739
21519
|
onViewChange,
|
|
20740
21520
|
views
|
|
@@ -20743,7 +21523,7 @@ var ViewTabs = React24.memo(function ViewTabs2({
|
|
|
20743
21523
|
"button",
|
|
20744
21524
|
{
|
|
20745
21525
|
onClick: () => onViewChange(view.id),
|
|
20746
|
-
className:
|
|
21526
|
+
className: cn3(
|
|
20747
21527
|
"flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md transition-colors",
|
|
20748
21528
|
activeView === view.id ? "bg-zinc-700 text-zinc-200" : "text-zinc-400 hover:text-zinc-300"
|
|
20749
21529
|
),
|
|
@@ -20755,7 +21535,7 @@ var ViewTabs = React24.memo(function ViewTabs2({
|
|
|
20755
21535
|
view.id
|
|
20756
21536
|
)) });
|
|
20757
21537
|
});
|
|
20758
|
-
var ToolbarButton =
|
|
21538
|
+
var ToolbarButton = React16.memo(function ToolbarButton2({
|
|
20759
21539
|
onClick,
|
|
20760
21540
|
title,
|
|
20761
21541
|
children,
|
|
@@ -20766,7 +21546,7 @@ var ToolbarButton = React24.memo(function ToolbarButton2({
|
|
|
20766
21546
|
{
|
|
20767
21547
|
onClick,
|
|
20768
21548
|
title,
|
|
20769
|
-
className:
|
|
21549
|
+
className: cn3(
|
|
20770
21550
|
"p-2 rounded-lg hover:bg-zinc-800/50 text-zinc-400 hover:text-zinc-200 transition-colors",
|
|
20771
21551
|
className
|
|
20772
21552
|
),
|
|
@@ -20824,14 +21604,14 @@ var artifactTypeConfig = {
|
|
|
20824
21604
|
bgColor: "bg-pink-500/10"
|
|
20825
21605
|
}
|
|
20826
21606
|
};
|
|
20827
|
-
var CodeBlock3 =
|
|
21607
|
+
var CodeBlock3 = React16.memo(function CodeBlock4({
|
|
20828
21608
|
code: code3,
|
|
20829
21609
|
language,
|
|
20830
21610
|
showLineNumbers = true
|
|
20831
21611
|
}) {
|
|
20832
21612
|
const lines = code3.split("\n");
|
|
20833
|
-
const [copied, setCopied] =
|
|
20834
|
-
const handleCopy =
|
|
21613
|
+
const [copied, setCopied] = React16.useState(false);
|
|
21614
|
+
const handleCopy = React16.useCallback(async () => {
|
|
20835
21615
|
try {
|
|
20836
21616
|
await navigator.clipboard.writeText(code3);
|
|
20837
21617
|
setCopied(true);
|
|
@@ -20866,14 +21646,14 @@ var CodeBlock3 = React24.memo(function CodeBlock4({
|
|
|
20866
21646
|
] }, i)) }) }) })
|
|
20867
21647
|
] });
|
|
20868
21648
|
});
|
|
20869
|
-
var HtmlPreview3 =
|
|
20870
|
-
const [scale, setScale] =
|
|
20871
|
-
const [deviceMode, setDeviceMode] =
|
|
20872
|
-
const [isLoading, setIsLoading] =
|
|
20873
|
-
const [iframeHeight, setIframeHeight] =
|
|
20874
|
-
const iframeRef =
|
|
20875
|
-
const containerRef =
|
|
20876
|
-
const blobUrl =
|
|
21649
|
+
var HtmlPreview3 = React16.memo(function HtmlPreview4({ content }) {
|
|
21650
|
+
const [scale, setScale] = React16.useState(1);
|
|
21651
|
+
const [deviceMode, setDeviceMode] = React16.useState("responsive");
|
|
21652
|
+
const [isLoading, setIsLoading] = React16.useState(true);
|
|
21653
|
+
const [iframeHeight, setIframeHeight] = React16.useState(600);
|
|
21654
|
+
const iframeRef = React16.useRef(null);
|
|
21655
|
+
const containerRef = React16.useRef(null);
|
|
21656
|
+
const blobUrl = React16.useMemo(() => {
|
|
20877
21657
|
const styleInjection = `
|
|
20878
21658
|
<style>
|
|
20879
21659
|
html, body {
|
|
@@ -20901,7 +21681,7 @@ var HtmlPreview3 = React24.memo(function HtmlPreview4({ content }) {
|
|
|
20901
21681
|
const blob = new Blob([modifiedContent], { type: "text/html" });
|
|
20902
21682
|
return URL.createObjectURL(blob);
|
|
20903
21683
|
}, [content]);
|
|
20904
|
-
|
|
21684
|
+
React16.useEffect(() => {
|
|
20905
21685
|
return () => {
|
|
20906
21686
|
URL.revokeObjectURL(blobUrl);
|
|
20907
21687
|
};
|
|
@@ -20913,7 +21693,7 @@ var HtmlPreview3 = React24.memo(function HtmlPreview4({ content }) {
|
|
|
20913
21693
|
responsive: { width: "100%", height: 600, icon: lucideReact.Maximize2, label: "Responsive" }
|
|
20914
21694
|
};
|
|
20915
21695
|
const currentDevice = deviceConfig[deviceMode];
|
|
20916
|
-
const adjustIframeHeight =
|
|
21696
|
+
const adjustIframeHeight = React16.useCallback(() => {
|
|
20917
21697
|
if (deviceMode === "responsive" && containerRef.current) {
|
|
20918
21698
|
const containerHeight = containerRef.current.clientHeight - 32;
|
|
20919
21699
|
setIframeHeight(Math.max(containerHeight, 400));
|
|
@@ -20921,12 +21701,12 @@ var HtmlPreview3 = React24.memo(function HtmlPreview4({ content }) {
|
|
|
20921
21701
|
setIframeHeight(currentDevice.height);
|
|
20922
21702
|
}
|
|
20923
21703
|
}, [deviceMode, currentDevice.height]);
|
|
20924
|
-
|
|
21704
|
+
React16.useEffect(() => {
|
|
20925
21705
|
adjustIframeHeight();
|
|
20926
21706
|
window.addEventListener("resize", adjustIframeHeight);
|
|
20927
21707
|
return () => window.removeEventListener("resize", adjustIframeHeight);
|
|
20928
21708
|
}, [adjustIframeHeight]);
|
|
20929
|
-
const handleIframeLoad =
|
|
21709
|
+
const handleIframeLoad = React16.useCallback(() => {
|
|
20930
21710
|
setIsLoading(false);
|
|
20931
21711
|
try {
|
|
20932
21712
|
const iframe = iframeRef.current;
|
|
@@ -20947,13 +21727,13 @@ var HtmlPreview3 = React24.memo(function HtmlPreview4({ content }) {
|
|
|
20947
21727
|
} catch {
|
|
20948
21728
|
}
|
|
20949
21729
|
}, [deviceMode]);
|
|
20950
|
-
const handleRefresh =
|
|
21730
|
+
const handleRefresh = React16.useCallback(() => {
|
|
20951
21731
|
setIsLoading(true);
|
|
20952
21732
|
if (iframeRef.current) {
|
|
20953
21733
|
iframeRef.current.src = blobUrl;
|
|
20954
21734
|
}
|
|
20955
21735
|
}, [blobUrl]);
|
|
20956
|
-
const handleDownload =
|
|
21736
|
+
const handleDownload = React16.useCallback(() => {
|
|
20957
21737
|
const link2 = document.createElement("a");
|
|
20958
21738
|
link2.href = blobUrl;
|
|
20959
21739
|
link2.download = `artifact-${Date.now()}.html`;
|
|
@@ -20961,7 +21741,7 @@ var HtmlPreview3 = React24.memo(function HtmlPreview4({ content }) {
|
|
|
20961
21741
|
link2.click();
|
|
20962
21742
|
document.body.removeChild(link2);
|
|
20963
21743
|
}, [blobUrl]);
|
|
20964
|
-
const handleOpenNewTab =
|
|
21744
|
+
const handleOpenNewTab = React16.useCallback(() => {
|
|
20965
21745
|
window.open(blobUrl, "_blank");
|
|
20966
21746
|
}, [blobUrl]);
|
|
20967
21747
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "h-full flex flex-col bg-zinc-950 agent-sdk-light:bg-white", children: [
|
|
@@ -20975,7 +21755,7 @@ var HtmlPreview3 = React24.memo(function HtmlPreview4({ content }) {
|
|
|
20975
21755
|
setDeviceMode(mode);
|
|
20976
21756
|
setScale(1);
|
|
20977
21757
|
},
|
|
20978
|
-
className:
|
|
21758
|
+
className: cn3(
|
|
20979
21759
|
"flex items-center gap-1.5 px-2.5 py-1.5 text-xs rounded-md transition-all",
|
|
20980
21760
|
deviceMode === mode ? "bg-zinc-700 text-zinc-200 agent-sdk-light:bg-zinc-200 agent-sdk-light:text-zinc-900" : "text-zinc-500 agent-sdk-light:text-zinc-600 hover:text-zinc-300 agent-sdk-light:hover:text-zinc-900 hover:bg-zinc-800/50 agent-sdk-light:hover:bg-zinc-200/50"
|
|
20981
21761
|
),
|
|
@@ -20994,7 +21774,7 @@ var HtmlPreview3 = React24.memo(function HtmlPreview4({ content }) {
|
|
|
20994
21774
|
"button",
|
|
20995
21775
|
{
|
|
20996
21776
|
onClick: () => setScale(s),
|
|
20997
|
-
className:
|
|
21777
|
+
className: cn3(
|
|
20998
21778
|
"px-2 py-1 text-[10px] rounded transition-colors",
|
|
20999
21779
|
scale === s ? "bg-zinc-700 text-zinc-200 agent-sdk-light:bg-zinc-300 agent-sdk-light:text-zinc-900" : "text-zinc-500 agent-sdk-light:text-zinc-600 hover:text-zinc-300 agent-sdk-light:hover:text-zinc-900"
|
|
21000
21780
|
),
|
|
@@ -21046,7 +21826,7 @@ var HtmlPreview3 = React24.memo(function HtmlPreview4({ content }) {
|
|
|
21046
21826
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
21047
21827
|
"div",
|
|
21048
21828
|
{
|
|
21049
|
-
className:
|
|
21829
|
+
className: cn3(
|
|
21050
21830
|
"bg-white rounded-lg shadow-2xl overflow-hidden transition-all duration-300 relative",
|
|
21051
21831
|
deviceMode !== "responsive" && "border-4 border-zinc-800 agent-sdk-light:border-zinc-300 rounded-xl"
|
|
21052
21832
|
),
|
|
@@ -21082,21 +21862,21 @@ var HtmlPreview3 = React24.memo(function HtmlPreview4({ content }) {
|
|
|
21082
21862
|
)
|
|
21083
21863
|
] });
|
|
21084
21864
|
});
|
|
21085
|
-
var MarkdownPreview =
|
|
21865
|
+
var MarkdownPreview = React16.memo(function MarkdownPreview2({
|
|
21086
21866
|
content,
|
|
21087
21867
|
config
|
|
21088
21868
|
}) {
|
|
21089
21869
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full overflow-auto bg-zinc-950 agent-sdk-light:bg-white", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-w-3xl mx-auto p-8", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "prose prose-invert prose-zinc agent-sdk-light:prose max-w-none", children: /* @__PURE__ */ jsxRuntime.jsx(MarkdownContent, { content, config }) }) }) });
|
|
21090
21870
|
});
|
|
21091
|
-
|
|
21092
|
-
const parsedData =
|
|
21871
|
+
React16.memo(function JsonPreview2({ content }) {
|
|
21872
|
+
const parsedData = React16.useMemo(() => {
|
|
21093
21873
|
try {
|
|
21094
21874
|
return JSON.parse(content);
|
|
21095
21875
|
} catch {
|
|
21096
21876
|
return null;
|
|
21097
21877
|
}
|
|
21098
21878
|
}, [content]);
|
|
21099
|
-
const formattedJson =
|
|
21879
|
+
const formattedJson = React16.useMemo(() => {
|
|
21100
21880
|
if (parsedData === null) return content;
|
|
21101
21881
|
try {
|
|
21102
21882
|
return JSON.stringify(parsedData, null, 2);
|
|
@@ -21112,13 +21892,13 @@ React24.memo(function JsonPreview2({ content }) {
|
|
|
21112
21892
|
}
|
|
21113
21893
|
return /* @__PURE__ */ jsxRuntime.jsx(CodeBlock3, { code: formattedJson, language: "json" });
|
|
21114
21894
|
});
|
|
21115
|
-
var CodeEditor =
|
|
21895
|
+
var CodeEditor = React16.memo(function CodeEditor2({
|
|
21116
21896
|
code: code3,
|
|
21117
21897
|
language,
|
|
21118
21898
|
onChange
|
|
21119
21899
|
}) {
|
|
21120
|
-
const textareaRef =
|
|
21121
|
-
const handleKeyDown =
|
|
21900
|
+
const textareaRef = React16.useRef(null);
|
|
21901
|
+
const handleKeyDown = React16.useCallback((e) => {
|
|
21122
21902
|
if (e.key === "Tab") {
|
|
21123
21903
|
e.preventDefault();
|
|
21124
21904
|
const textarea = e.currentTarget;
|
|
@@ -21155,10 +21935,10 @@ var CodeEditor = React24.memo(function CodeEditor2({
|
|
|
21155
21935
|
});
|
|
21156
21936
|
function useResolvedMediaUrl(content, options) {
|
|
21157
21937
|
const { fileId, type = "image", config } = options || {};
|
|
21158
|
-
const [resolvedUrl, setResolvedUrl] =
|
|
21159
|
-
const [resolvedHdUrl, setResolvedHdUrl] =
|
|
21160
|
-
const [isLoading, setIsLoading] =
|
|
21161
|
-
|
|
21938
|
+
const [resolvedUrl, setResolvedUrl] = React16.useState(content);
|
|
21939
|
+
const [resolvedHdUrl, setResolvedHdUrl] = React16.useState(content);
|
|
21940
|
+
const [isLoading, setIsLoading] = React16.useState(true);
|
|
21941
|
+
React16.useEffect(() => {
|
|
21162
21942
|
let active = true;
|
|
21163
21943
|
setIsLoading(true);
|
|
21164
21944
|
const resolve = async () => {
|
|
@@ -21196,8 +21976,8 @@ function useResolvedMediaUrl(content, options) {
|
|
|
21196
21976
|
}
|
|
21197
21977
|
function useResolvedThumbnailUrl(content, options) {
|
|
21198
21978
|
const { fileId, type = "image", config, enabled = true } = options || {};
|
|
21199
|
-
const [url, setUrl] =
|
|
21200
|
-
|
|
21979
|
+
const [url, setUrl] = React16.useState(null);
|
|
21980
|
+
React16.useEffect(() => {
|
|
21201
21981
|
if (!enabled || !content) {
|
|
21202
21982
|
setUrl(null);
|
|
21203
21983
|
return;
|
|
@@ -21229,15 +22009,15 @@ function useResolvedThumbnailUrl(content, options) {
|
|
|
21229
22009
|
}, [content, fileId, type, config, enabled]);
|
|
21230
22010
|
return url;
|
|
21231
22011
|
}
|
|
21232
|
-
var ImageArtifactPreview =
|
|
22012
|
+
var ImageArtifactPreview = React16.memo(function ImageArtifactPreview2({
|
|
21233
22013
|
content,
|
|
21234
22014
|
metadata,
|
|
21235
22015
|
config
|
|
21236
22016
|
}) {
|
|
21237
|
-
const [isZoomed, setIsZoomed] =
|
|
21238
|
-
const [showInfo, setShowInfo] =
|
|
21239
|
-
const [imgNaturalSize, setImgNaturalSize] =
|
|
21240
|
-
const [copied, setCopied] =
|
|
22017
|
+
const [isZoomed, setIsZoomed] = React16.useState(false);
|
|
22018
|
+
const [showInfo, setShowInfo] = React16.useState(true);
|
|
22019
|
+
const [imgNaturalSize, setImgNaturalSize] = React16.useState(null);
|
|
22020
|
+
const [copied, setCopied] = React16.useState(null);
|
|
21241
22021
|
const { hdUrl: resolvedHdUrl } = useResolvedMediaUrl(content, {
|
|
21242
22022
|
fileId: metadata?.fileId,
|
|
21243
22023
|
type: "image",
|
|
@@ -21246,7 +22026,7 @@ var ImageArtifactPreview = React24.memo(function ImageArtifactPreview2({
|
|
|
21246
22026
|
const generationParams = metadata?.generationParams;
|
|
21247
22027
|
const toolName = metadata?.toolName;
|
|
21248
22028
|
const relation = metadata?.relation;
|
|
21249
|
-
const handleCopy =
|
|
22029
|
+
const handleCopy = React16.useCallback(async (text3, label) => {
|
|
21250
22030
|
try {
|
|
21251
22031
|
await navigator.clipboard.writeText(text3);
|
|
21252
22032
|
setCopied(label);
|
|
@@ -21254,7 +22034,7 @@ var ImageArtifactPreview = React24.memo(function ImageArtifactPreview2({
|
|
|
21254
22034
|
} catch {
|
|
21255
22035
|
}
|
|
21256
22036
|
}, []);
|
|
21257
|
-
const handleDownload =
|
|
22037
|
+
const handleDownload = React16.useCallback(() => {
|
|
21258
22038
|
const link2 = document.createElement("a");
|
|
21259
22039
|
link2.href = resolvedHdUrl;
|
|
21260
22040
|
link2.download = `generated-${Date.now()}.png`;
|
|
@@ -21292,7 +22072,7 @@ var ImageArtifactPreview = React24.memo(function ImageArtifactPreview2({
|
|
|
21292
22072
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
21293
22073
|
"div",
|
|
21294
22074
|
{
|
|
21295
|
-
className:
|
|
22075
|
+
className: cn3(
|
|
21296
22076
|
"relative transition-transform duration-300 cursor-zoom-in z-10",
|
|
21297
22077
|
isZoomed && "cursor-zoom-out scale-[2] z-50"
|
|
21298
22078
|
),
|
|
@@ -21317,7 +22097,7 @@ var ImageArtifactPreview = React24.memo(function ImageArtifactPreview2({
|
|
|
21317
22097
|
"button",
|
|
21318
22098
|
{
|
|
21319
22099
|
onClick: () => setShowInfo((prev) => !prev),
|
|
21320
|
-
className:
|
|
22100
|
+
className: cn3(
|
|
21321
22101
|
"p-2 rounded-lg backdrop-blur-sm transition-colors",
|
|
21322
22102
|
showInfo ? "bg-[#d8ff00]/20 text-[#d8ff00]" : "bg-black/30 text-white/70 hover:text-white hover:bg-black/50"
|
|
21323
22103
|
),
|
|
@@ -21409,7 +22189,7 @@ var ImageArtifactPreview = React24.memo(function ImageArtifactPreview2({
|
|
|
21409
22189
|
] }) })
|
|
21410
22190
|
] });
|
|
21411
22191
|
});
|
|
21412
|
-
var VideoArtifactPreview =
|
|
22192
|
+
var VideoArtifactPreview = React16.memo(function VideoArtifactPreview2({
|
|
21413
22193
|
content,
|
|
21414
22194
|
metadata,
|
|
21415
22195
|
config
|
|
@@ -21419,20 +22199,20 @@ var VideoArtifactPreview = React24.memo(function VideoArtifactPreview2({
|
|
|
21419
22199
|
type: "video",
|
|
21420
22200
|
config
|
|
21421
22201
|
});
|
|
21422
|
-
const videoRef =
|
|
21423
|
-
const progressRef =
|
|
21424
|
-
const [isPlaying, setIsPlaying] =
|
|
21425
|
-
const [isMuted, setIsMuted] =
|
|
21426
|
-
const [duration, setDuration] =
|
|
21427
|
-
const [currentTime, setCurrentTime] =
|
|
21428
|
-
const [volume, setVolume] =
|
|
21429
|
-
const [isLoaded, setIsLoaded] =
|
|
21430
|
-
const [showVolumeSlider, setShowVolumeSlider] =
|
|
21431
|
-
const [posterUrl, setPosterUrl] =
|
|
21432
|
-
const [isDraggingProgress, setIsDraggingProgress] =
|
|
22202
|
+
const videoRef = React16.useRef(null);
|
|
22203
|
+
const progressRef = React16.useRef(null);
|
|
22204
|
+
const [isPlaying, setIsPlaying] = React16.useState(false);
|
|
22205
|
+
const [isMuted, setIsMuted] = React16.useState(false);
|
|
22206
|
+
const [duration, setDuration] = React16.useState(0);
|
|
22207
|
+
const [currentTime, setCurrentTime] = React16.useState(0);
|
|
22208
|
+
const [volume, setVolume] = React16.useState(1);
|
|
22209
|
+
const [isLoaded, setIsLoaded] = React16.useState(false);
|
|
22210
|
+
const [showVolumeSlider, setShowVolumeSlider] = React16.useState(false);
|
|
22211
|
+
const [posterUrl, setPosterUrl] = React16.useState(null);
|
|
22212
|
+
const [isDraggingProgress, setIsDraggingProgress] = React16.useState(false);
|
|
21433
22213
|
const generationParams = metadata?.generationParams;
|
|
21434
22214
|
const toolName = metadata?.toolName;
|
|
21435
|
-
|
|
22215
|
+
React16.useEffect(() => {
|
|
21436
22216
|
const video = document.createElement("video");
|
|
21437
22217
|
video.crossOrigin = "anonymous";
|
|
21438
22218
|
video.preload = "metadata";
|
|
@@ -21473,7 +22253,7 @@ var VideoArtifactPreview = React24.memo(function VideoArtifactPreview2({
|
|
|
21473
22253
|
setCurrentTime(videoRef.current.currentTime);
|
|
21474
22254
|
}
|
|
21475
22255
|
};
|
|
21476
|
-
const togglePlay =
|
|
22256
|
+
const togglePlay = React16.useCallback(() => {
|
|
21477
22257
|
const video = videoRef.current;
|
|
21478
22258
|
if (!video) return;
|
|
21479
22259
|
if (isPlaying) {
|
|
@@ -21484,14 +22264,14 @@ var VideoArtifactPreview = React24.memo(function VideoArtifactPreview2({
|
|
|
21484
22264
|
});
|
|
21485
22265
|
}
|
|
21486
22266
|
}, [isPlaying]);
|
|
21487
|
-
const toggleMute =
|
|
22267
|
+
const toggleMute = React16.useCallback(() => {
|
|
21488
22268
|
const video = videoRef.current;
|
|
21489
22269
|
if (video) {
|
|
21490
22270
|
video.muted = !isMuted;
|
|
21491
22271
|
setIsMuted(!isMuted);
|
|
21492
22272
|
}
|
|
21493
22273
|
}, [isMuted]);
|
|
21494
|
-
const handleVolumeChange =
|
|
22274
|
+
const handleVolumeChange = React16.useCallback((e) => {
|
|
21495
22275
|
const newVolume = parseFloat(e.target.value);
|
|
21496
22276
|
setVolume(newVolume);
|
|
21497
22277
|
if (videoRef.current) {
|
|
@@ -21505,7 +22285,7 @@ var VideoArtifactPreview = React24.memo(function VideoArtifactPreview2({
|
|
|
21505
22285
|
}
|
|
21506
22286
|
}
|
|
21507
22287
|
}, [isMuted]);
|
|
21508
|
-
const handleProgressClick =
|
|
22288
|
+
const handleProgressClick = React16.useCallback((e) => {
|
|
21509
22289
|
const video = videoRef.current;
|
|
21510
22290
|
const bar = progressRef.current;
|
|
21511
22291
|
if (!video || !bar || !duration) return;
|
|
@@ -21514,7 +22294,7 @@ var VideoArtifactPreview = React24.memo(function VideoArtifactPreview2({
|
|
|
21514
22294
|
video.currentTime = ratio * duration;
|
|
21515
22295
|
setCurrentTime(ratio * duration);
|
|
21516
22296
|
}, [duration]);
|
|
21517
|
-
const handleProgressDrag =
|
|
22297
|
+
const handleProgressDrag = React16.useCallback((e) => {
|
|
21518
22298
|
if (!isDraggingProgress) return;
|
|
21519
22299
|
const bar = progressRef.current;
|
|
21520
22300
|
if (!bar || !duration) return;
|
|
@@ -21522,13 +22302,13 @@ var VideoArtifactPreview = React24.memo(function VideoArtifactPreview2({
|
|
|
21522
22302
|
const ratio = Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width));
|
|
21523
22303
|
setCurrentTime(ratio * duration);
|
|
21524
22304
|
}, [isDraggingProgress, duration]);
|
|
21525
|
-
const handleProgressDragEnd =
|
|
22305
|
+
const handleProgressDragEnd = React16.useCallback(() => {
|
|
21526
22306
|
if (isDraggingProgress && videoRef.current) {
|
|
21527
22307
|
videoRef.current.currentTime = currentTime;
|
|
21528
22308
|
}
|
|
21529
22309
|
setIsDraggingProgress(false);
|
|
21530
22310
|
}, [isDraggingProgress, currentTime]);
|
|
21531
|
-
|
|
22311
|
+
React16.useEffect(() => {
|
|
21532
22312
|
if (!isDraggingProgress) return;
|
|
21533
22313
|
const handleMouseUp = () => handleProgressDragEnd();
|
|
21534
22314
|
const handleMouseMove = (e) => {
|
|
@@ -21545,7 +22325,7 @@ var VideoArtifactPreview = React24.memo(function VideoArtifactPreview2({
|
|
|
21545
22325
|
window.removeEventListener("mousemove", handleMouseMove);
|
|
21546
22326
|
};
|
|
21547
22327
|
}, [isDraggingProgress, duration, handleProgressDragEnd]);
|
|
21548
|
-
const handleDownload =
|
|
22328
|
+
const handleDownload = React16.useCallback(() => {
|
|
21549
22329
|
const link2 = document.createElement("a");
|
|
21550
22330
|
link2.href = resolvedUrl;
|
|
21551
22331
|
link2.download = `video-${Date.now()}.mp4`;
|
|
@@ -21581,7 +22361,7 @@ var VideoArtifactPreview = React24.memo(function VideoArtifactPreview2({
|
|
|
21581
22361
|
onTimeUpdate: handleTimeUpdate,
|
|
21582
22362
|
onEnded: () => setIsPlaying(false),
|
|
21583
22363
|
onClick: togglePlay,
|
|
21584
|
-
className:
|
|
22364
|
+
className: cn3(
|
|
21585
22365
|
"max-w-full max-h-full object-contain cursor-pointer",
|
|
21586
22366
|
!isPlaying && posterUrl && !currentTime && "opacity-0"
|
|
21587
22367
|
)
|
|
@@ -21592,7 +22372,7 @@ var VideoArtifactPreview = React24.memo(function VideoArtifactPreview2({
|
|
|
21592
22372
|
{
|
|
21593
22373
|
className: "absolute inset-0 z-[2] flex items-center justify-center cursor-pointer",
|
|
21594
22374
|
onClick: togglePlay,
|
|
21595
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className:
|
|
22375
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn3(
|
|
21596
22376
|
"w-16 h-16 rounded-full bg-white/15 backdrop-blur-md",
|
|
21597
22377
|
"flex items-center justify-center",
|
|
21598
22378
|
"transition-all duration-200",
|
|
@@ -21601,7 +22381,7 @@ var VideoArtifactPreview = React24.memo(function VideoArtifactPreview2({
|
|
|
21601
22381
|
), children: /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "26", height: "26", viewBox: "0 0 24 24", fill: "white", className: "ml-1", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M8 5v14l11-7z" }) }) })
|
|
21602
22382
|
}
|
|
21603
22383
|
),
|
|
21604
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className:
|
|
22384
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn3(
|
|
21605
22385
|
"absolute bottom-0 left-0 right-0 z-[3]",
|
|
21606
22386
|
"bg-gradient-to-t from-black/90 via-black/50 to-transparent",
|
|
21607
22387
|
"px-4 pb-3 pt-10",
|
|
@@ -21870,7 +22650,7 @@ ${codeContent.trim()}
|
|
|
21870
22650
|
rows.push(cells);
|
|
21871
22651
|
});
|
|
21872
22652
|
if (rows.length === 0) return "";
|
|
21873
|
-
const colCount = Math.max(...rows.map((
|
|
22653
|
+
const colCount = Math.max(...rows.map((r2) => r2.length));
|
|
21874
22654
|
const colWidths = Array(colCount).fill(3);
|
|
21875
22655
|
rows.forEach((row) => {
|
|
21876
22656
|
row.forEach((cell, i) => {
|
|
@@ -21898,20 +22678,20 @@ ${codeContent.trim()}
|
|
|
21898
22678
|
});
|
|
21899
22679
|
return lines.join("").replace(/\n{3,}/g, "\n\n").trim() + "\n";
|
|
21900
22680
|
}
|
|
21901
|
-
var MarkdownEditor =
|
|
22681
|
+
var MarkdownEditor = React16.memo(function MarkdownEditor2({
|
|
21902
22682
|
content,
|
|
21903
22683
|
onChange,
|
|
21904
22684
|
config
|
|
21905
22685
|
}) {
|
|
21906
|
-
const editorRef =
|
|
21907
|
-
const textareaRef =
|
|
21908
|
-
const [isSourceMode, setIsSourceMode] =
|
|
21909
|
-
const isInternalUpdate =
|
|
21910
|
-
const lastMarkdownRef =
|
|
21911
|
-
const contentToHtml =
|
|
22686
|
+
const editorRef = React16.useRef(null);
|
|
22687
|
+
const textareaRef = React16.useRef(null);
|
|
22688
|
+
const [isSourceMode, setIsSourceMode] = React16.useState(false);
|
|
22689
|
+
const isInternalUpdate = React16.useRef(false);
|
|
22690
|
+
const lastMarkdownRef = React16.useRef(content);
|
|
22691
|
+
const contentToHtml = React16.useCallback((markdown) => {
|
|
21912
22692
|
return marked.marked.parse(markdown, { breaks: true, gfm: true });
|
|
21913
22693
|
}, []);
|
|
21914
|
-
|
|
22694
|
+
React16.useEffect(() => {
|
|
21915
22695
|
if (isSourceMode) return;
|
|
21916
22696
|
if (isInternalUpdate.current) {
|
|
21917
22697
|
isInternalUpdate.current = false;
|
|
@@ -21923,31 +22703,31 @@ var MarkdownEditor = React24.memo(function MarkdownEditor2({
|
|
|
21923
22703
|
lastMarkdownRef.current = content;
|
|
21924
22704
|
}
|
|
21925
22705
|
}, [content, isSourceMode, contentToHtml]);
|
|
21926
|
-
|
|
22706
|
+
React16.useEffect(() => {
|
|
21927
22707
|
if (editorRef.current && !isSourceMode) {
|
|
21928
22708
|
const html2 = contentToHtml(content);
|
|
21929
22709
|
editorRef.current.innerHTML = html2;
|
|
21930
22710
|
}
|
|
21931
22711
|
}, []);
|
|
21932
|
-
const handleInput =
|
|
22712
|
+
const handleInput = React16.useCallback(() => {
|
|
21933
22713
|
if (!editorRef.current) return;
|
|
21934
22714
|
const markdown = htmlToMarkdown(editorRef.current);
|
|
21935
22715
|
lastMarkdownRef.current = markdown;
|
|
21936
22716
|
isInternalUpdate.current = true;
|
|
21937
22717
|
onChange(markdown);
|
|
21938
22718
|
}, [onChange]);
|
|
21939
|
-
const execCommand =
|
|
22719
|
+
const execCommand = React16.useCallback((command, value) => {
|
|
21940
22720
|
editorRef.current?.focus();
|
|
21941
22721
|
document.execCommand(command, false, value);
|
|
21942
22722
|
requestAnimationFrame(() => handleInput());
|
|
21943
22723
|
}, [handleInput]);
|
|
21944
|
-
const formatBlock =
|
|
22724
|
+
const formatBlock = React16.useCallback((tag) => {
|
|
21945
22725
|
execCommand("formatBlock", tag);
|
|
21946
22726
|
}, [execCommand]);
|
|
21947
|
-
const insertHorizontalRule =
|
|
22727
|
+
const insertHorizontalRule = React16.useCallback(() => {
|
|
21948
22728
|
execCommand("insertHorizontalRule");
|
|
21949
22729
|
}, [execCommand]);
|
|
21950
|
-
const insertLink =
|
|
22730
|
+
const insertLink = React16.useCallback(() => {
|
|
21951
22731
|
const selection = window.getSelection();
|
|
21952
22732
|
const selectedText = selection?.toString() || "\u94FE\u63A5\u6587\u672C";
|
|
21953
22733
|
const url = prompt("\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740:", "https://");
|
|
@@ -21967,13 +22747,13 @@ var MarkdownEditor = React24.memo(function MarkdownEditor2({
|
|
|
21967
22747
|
requestAnimationFrame(() => handleInput());
|
|
21968
22748
|
}
|
|
21969
22749
|
}, [handleInput]);
|
|
21970
|
-
const insertImage =
|
|
22750
|
+
const insertImage = React16.useCallback(() => {
|
|
21971
22751
|
const url = prompt("\u8BF7\u8F93\u5165\u56FE\u7247\u5730\u5740:", "https://");
|
|
21972
22752
|
if (url) {
|
|
21973
22753
|
execCommand("insertImage", url);
|
|
21974
22754
|
}
|
|
21975
22755
|
}, [execCommand]);
|
|
21976
|
-
const insertCodeBlock =
|
|
22756
|
+
const insertCodeBlock = React16.useCallback(() => {
|
|
21977
22757
|
const editor = editorRef.current;
|
|
21978
22758
|
if (!editor) return;
|
|
21979
22759
|
const selection = window.getSelection();
|
|
@@ -21995,7 +22775,7 @@ var MarkdownEditor = React24.memo(function MarkdownEditor2({
|
|
|
21995
22775
|
}
|
|
21996
22776
|
requestAnimationFrame(() => handleInput());
|
|
21997
22777
|
}, [handleInput]);
|
|
21998
|
-
const handleKeyDown =
|
|
22778
|
+
const handleKeyDown = React16.useCallback((e) => {
|
|
21999
22779
|
const isMod = e.metaKey || e.ctrlKey;
|
|
22000
22780
|
if (isMod && e.key === "b") {
|
|
22001
22781
|
e.preventDefault();
|
|
@@ -22018,7 +22798,7 @@ var MarkdownEditor = React24.memo(function MarkdownEditor2({
|
|
|
22018
22798
|
execCommand("insertHTML", " ");
|
|
22019
22799
|
}
|
|
22020
22800
|
}, [execCommand]);
|
|
22021
|
-
const handleSourceKeyDown =
|
|
22801
|
+
const handleSourceKeyDown = React16.useCallback((e) => {
|
|
22022
22802
|
if (e.key === "Tab") {
|
|
22023
22803
|
e.preventDefault();
|
|
22024
22804
|
const textarea = e.currentTarget;
|
|
@@ -22031,7 +22811,7 @@ var MarkdownEditor = React24.memo(function MarkdownEditor2({
|
|
|
22031
22811
|
});
|
|
22032
22812
|
}
|
|
22033
22813
|
}, [content, onChange]);
|
|
22034
|
-
const toggleSourceMode =
|
|
22814
|
+
const toggleSourceMode = React16.useCallback(() => {
|
|
22035
22815
|
if (isSourceMode) {
|
|
22036
22816
|
setIsSourceMode(false);
|
|
22037
22817
|
requestAnimationFrame(() => {
|
|
@@ -22051,7 +22831,7 @@ var MarkdownEditor = React24.memo(function MarkdownEditor2({
|
|
|
22051
22831
|
setIsSourceMode(true);
|
|
22052
22832
|
}
|
|
22053
22833
|
}, [isSourceMode, content, contentToHtml, onChange]);
|
|
22054
|
-
const toolbarGroups =
|
|
22834
|
+
const toolbarGroups = React16.useMemo(() => [
|
|
22055
22835
|
{
|
|
22056
22836
|
items: [
|
|
22057
22837
|
{ icon: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-bold text-[11px]", children: "B" }), label: "\u52A0\u7C97 (\u2318B)", onClick: () => execCommand("bold") },
|
|
@@ -22094,7 +22874,7 @@ var MarkdownEditor = React24.memo(function MarkdownEditor2({
|
|
|
22094
22874
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] text-[#d8ff00] font-medium whitespace-nowrap", children: isSourceMode ? "Markdown \u6E90\u7801" : "\u5BCC\u6587\u672C\u7F16\u8F91" })
|
|
22095
22875
|
] }),
|
|
22096
22876
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-4 w-px bg-zinc-700/50 agent-sdk-light:bg-zinc-300 mx-1" }),
|
|
22097
|
-
!isSourceMode && toolbarGroups.map((group, groupIndex) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
22877
|
+
!isSourceMode && toolbarGroups.map((group, groupIndex) => /* @__PURE__ */ jsxRuntime.jsxs(React16__namespace.default.Fragment, { children: [
|
|
22098
22878
|
group.items.map((action, actionIndex) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
22099
22879
|
"button",
|
|
22100
22880
|
{
|
|
@@ -22112,7 +22892,7 @@ var MarkdownEditor = React24.memo(function MarkdownEditor2({
|
|
|
22112
22892
|
"button",
|
|
22113
22893
|
{
|
|
22114
22894
|
onClick: toggleSourceMode,
|
|
22115
|
-
className:
|
|
22895
|
+
className: cn3(
|
|
22116
22896
|
"p-1.5 flex items-center gap-1 text-[11px] rounded transition-colors whitespace-nowrap",
|
|
22117
22897
|
isSourceMode ? "bg-[#d8ff00]/10 text-[#d8ff00]" : "text-zinc-400 agent-sdk-light:text-zinc-600 hover:text-zinc-100 agent-sdk-light:hover:text-zinc-900 hover:bg-zinc-700/50 agent-sdk-light:hover:bg-zinc-200"
|
|
22118
22898
|
),
|
|
@@ -22159,7 +22939,7 @@ var MarkdownEditor = React24.memo(function MarkdownEditor2({
|
|
|
22159
22939
|
) })
|
|
22160
22940
|
] });
|
|
22161
22941
|
});
|
|
22162
|
-
var ArtifactThumbnail =
|
|
22942
|
+
var ArtifactThumbnail = React16.memo(function ArtifactThumbnail2({
|
|
22163
22943
|
artifact,
|
|
22164
22944
|
config
|
|
22165
22945
|
}) {
|
|
@@ -22186,9 +22966,9 @@ var ArtifactThumbnail = React24.memo(function ArtifactThumbnail2({
|
|
|
22186
22966
|
}
|
|
22187
22967
|
);
|
|
22188
22968
|
}
|
|
22189
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className:
|
|
22969
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn3("w-6 h-6 rounded flex items-center justify-center flex-shrink-0", typeConf.bgColor), children: /* @__PURE__ */ jsxRuntime.jsx(TypeIcon, { size: 12, className: typeConf.color }) });
|
|
22190
22970
|
});
|
|
22191
|
-
var ArtifactTabs =
|
|
22971
|
+
var ArtifactTabs = React16.memo(function ArtifactTabs2({
|
|
22192
22972
|
artifacts,
|
|
22193
22973
|
activeId,
|
|
22194
22974
|
onSwitch,
|
|
@@ -22196,19 +22976,19 @@ var ArtifactTabs = React24.memo(function ArtifactTabs2({
|
|
|
22196
22976
|
onReorder,
|
|
22197
22977
|
config
|
|
22198
22978
|
}) {
|
|
22199
|
-
const scrollContainerRef =
|
|
22200
|
-
const [canScrollLeft, setCanScrollLeft] =
|
|
22201
|
-
const [canScrollRight, setCanScrollRight] =
|
|
22202
|
-
const [showAllPanel, setShowAllPanel] =
|
|
22203
|
-
const allPanelRef =
|
|
22204
|
-
const [dragState, setDragState] =
|
|
22205
|
-
const checkScrollState =
|
|
22979
|
+
const scrollContainerRef = React16.useRef(null);
|
|
22980
|
+
const [canScrollLeft, setCanScrollLeft] = React16.useState(false);
|
|
22981
|
+
const [canScrollRight, setCanScrollRight] = React16.useState(false);
|
|
22982
|
+
const [showAllPanel, setShowAllPanel] = React16.useState(false);
|
|
22983
|
+
const allPanelRef = React16.useRef(null);
|
|
22984
|
+
const [dragState, setDragState] = React16.useState({ draggingId: null, dragOverId: null, dragStartX: 0, isDragging: false });
|
|
22985
|
+
const checkScrollState = React16.useCallback(() => {
|
|
22206
22986
|
const container = scrollContainerRef.current;
|
|
22207
22987
|
if (!container) return;
|
|
22208
22988
|
setCanScrollLeft(container.scrollLeft > 2);
|
|
22209
22989
|
setCanScrollRight(container.scrollLeft < container.scrollWidth - container.clientWidth - 2);
|
|
22210
22990
|
}, []);
|
|
22211
|
-
|
|
22991
|
+
React16.useEffect(() => {
|
|
22212
22992
|
checkScrollState();
|
|
22213
22993
|
const container = scrollContainerRef.current;
|
|
22214
22994
|
if (!container) return;
|
|
@@ -22220,7 +23000,7 @@ var ArtifactTabs = React24.memo(function ArtifactTabs2({
|
|
|
22220
23000
|
resizeObserver.disconnect();
|
|
22221
23001
|
};
|
|
22222
23002
|
}, [checkScrollState, artifacts.length]);
|
|
22223
|
-
|
|
23003
|
+
React16.useEffect(() => {
|
|
22224
23004
|
if (!showAllPanel) return;
|
|
22225
23005
|
const handleClickOutside = (e) => {
|
|
22226
23006
|
if (allPanelRef.current && !allPanelRef.current.contains(e.target)) {
|
|
@@ -22230,7 +23010,7 @@ var ArtifactTabs = React24.memo(function ArtifactTabs2({
|
|
|
22230
23010
|
document.addEventListener("mousedown", handleClickOutside);
|
|
22231
23011
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
22232
23012
|
}, [showAllPanel]);
|
|
22233
|
-
const scrollBy =
|
|
23013
|
+
const scrollBy = React16.useCallback((direction) => {
|
|
22234
23014
|
const container = scrollContainerRef.current;
|
|
22235
23015
|
if (!container) return;
|
|
22236
23016
|
const scrollAmount = 200;
|
|
@@ -22239,20 +23019,20 @@ var ArtifactTabs = React24.memo(function ArtifactTabs2({
|
|
|
22239
23019
|
behavior: "smooth"
|
|
22240
23020
|
});
|
|
22241
23021
|
}, []);
|
|
22242
|
-
const handleDragStart =
|
|
23022
|
+
const handleDragStart = React16.useCallback((e, artifactId) => {
|
|
22243
23023
|
e.dataTransfer.effectAllowed = "move";
|
|
22244
23024
|
e.dataTransfer.setData("text/plain", artifactId);
|
|
22245
23025
|
setDragState((prev) => ({ ...prev, draggingId: artifactId, dragStartX: e.clientX, isDragging: true }));
|
|
22246
23026
|
}, []);
|
|
22247
|
-
const handleDragOver =
|
|
23027
|
+
const handleDragOver = React16.useCallback((e, artifactId) => {
|
|
22248
23028
|
e.preventDefault();
|
|
22249
23029
|
e.dataTransfer.dropEffect = "move";
|
|
22250
23030
|
setDragState((prev) => ({ ...prev, dragOverId: artifactId }));
|
|
22251
23031
|
}, []);
|
|
22252
|
-
const handleDragEnd =
|
|
23032
|
+
const handleDragEnd = React16.useCallback(() => {
|
|
22253
23033
|
setDragState({ draggingId: null, dragOverId: null, dragStartX: 0, isDragging: false });
|
|
22254
23034
|
}, []);
|
|
22255
|
-
const handleDrop =
|
|
23035
|
+
const handleDrop = React16.useCallback((e, targetId) => {
|
|
22256
23036
|
e.preventDefault();
|
|
22257
23037
|
const sourceId = e.dataTransfer.getData("text/plain");
|
|
22258
23038
|
if (!sourceId || sourceId === targetId || !onReorder) {
|
|
@@ -22266,7 +23046,7 @@ var ArtifactTabs = React24.memo(function ArtifactTabs2({
|
|
|
22266
23046
|
}
|
|
22267
23047
|
handleDragEnd();
|
|
22268
23048
|
}, [artifacts, onReorder, handleDragEnd]);
|
|
22269
|
-
const handleCloseTab =
|
|
23049
|
+
const handleCloseTab = React16.useCallback((e, artifactId) => {
|
|
22270
23050
|
e.stopPropagation();
|
|
22271
23051
|
if (!onClose) return;
|
|
22272
23052
|
if (artifactId === activeId && artifacts.length > 1) {
|
|
@@ -22309,7 +23089,7 @@ var ArtifactTabs = React24.memo(function ArtifactTabs2({
|
|
|
22309
23089
|
onDragEnd: handleDragEnd,
|
|
22310
23090
|
onDrop: (e) => handleDrop(e, artifact.id),
|
|
22311
23091
|
onClick: () => onSwitch(artifact.id),
|
|
22312
|
-
className:
|
|
23092
|
+
className: cn3(
|
|
22313
23093
|
"group/tab flex items-center gap-1 pl-2.5 pr-1 py-1 text-xs rounded-md transition-all whitespace-nowrap flex-shrink-0 cursor-pointer select-none",
|
|
22314
23094
|
isActive ? "bg-zinc-800 text-zinc-100 agent-sdk-light:bg-zinc-200 agent-sdk-light:text-zinc-900" : "text-zinc-500 agent-sdk-light:text-zinc-600 hover:text-zinc-300 agent-sdk-light:hover:text-zinc-900 hover:bg-zinc-800/50 agent-sdk-light:hover:bg-zinc-200/50",
|
|
22315
23095
|
isDragging && "opacity-40",
|
|
@@ -22318,13 +23098,13 @@ var ArtifactTabs = React24.memo(function ArtifactTabs2({
|
|
|
22318
23098
|
),
|
|
22319
23099
|
title: artifact.title,
|
|
22320
23100
|
children: [
|
|
22321
|
-
/* @__PURE__ */ jsxRuntime.jsx(TypeIcon, { size: 12, className:
|
|
23101
|
+
/* @__PURE__ */ jsxRuntime.jsx(TypeIcon, { size: 12, className: cn3("flex-shrink-0", isActive ? typeConf.color : "") }),
|
|
22322
23102
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "max-w-[120px] truncate", children: artifact.title }),
|
|
22323
23103
|
onClose && /* @__PURE__ */ jsxRuntime.jsx(
|
|
22324
23104
|
"button",
|
|
22325
23105
|
{
|
|
22326
23106
|
onClick: (e) => handleCloseTab(e, artifact.id),
|
|
22327
|
-
className:
|
|
23107
|
+
className: cn3(
|
|
22328
23108
|
"ml-0.5 p-0.5 rounded transition-colors flex-shrink-0",
|
|
22329
23109
|
isActive ? "text-zinc-400 hover:text-zinc-100 hover:bg-zinc-700" : "text-transparent group-hover/tab:text-zinc-500 hover:!text-zinc-300 hover:!bg-zinc-700"
|
|
22330
23110
|
),
|
|
@@ -22352,7 +23132,7 @@ var ArtifactTabs = React24.memo(function ArtifactTabs2({
|
|
|
22352
23132
|
"button",
|
|
22353
23133
|
{
|
|
22354
23134
|
onClick: () => setShowAllPanel((prev) => !prev),
|
|
22355
|
-
className:
|
|
23135
|
+
className: cn3(
|
|
22356
23136
|
"p-1.5 mr-1 text-zinc-500 hover:text-zinc-300 hover:bg-zinc-800/50 rounded transition-colors",
|
|
22357
23137
|
showAllPanel && "bg-zinc-800 text-zinc-300"
|
|
22358
23138
|
),
|
|
@@ -22377,7 +23157,7 @@ var ArtifactTabs = React24.memo(function ArtifactTabs2({
|
|
|
22377
23157
|
onSwitch(artifact.id);
|
|
22378
23158
|
setShowAllPanel(false);
|
|
22379
23159
|
},
|
|
22380
|
-
className:
|
|
23160
|
+
className: cn3(
|
|
22381
23161
|
"flex items-center gap-2.5 px-2.5 py-2 text-xs rounded-md transition-all w-full text-left",
|
|
22382
23162
|
isActive ? "bg-zinc-800 text-zinc-100 agent-sdk-light:bg-zinc-100 agent-sdk-light:text-zinc-900" : "text-zinc-400 agent-sdk-light:text-zinc-600 hover:text-zinc-200 agent-sdk-light:hover:text-zinc-900 hover:bg-zinc-800/50 agent-sdk-light:hover:bg-zinc-100"
|
|
22383
23163
|
),
|
|
@@ -22411,7 +23191,7 @@ var ArtifactTabs = React24.memo(function ArtifactTabs2({
|
|
|
22411
23191
|
] })
|
|
22412
23192
|
] });
|
|
22413
23193
|
});
|
|
22414
|
-
var ArtifactViewer =
|
|
23194
|
+
var ArtifactViewer = React16.memo(function ArtifactViewer2({
|
|
22415
23195
|
artifact,
|
|
22416
23196
|
isOpen,
|
|
22417
23197
|
onClose,
|
|
@@ -22428,12 +23208,12 @@ var ArtifactViewer = React24.memo(function ArtifactViewer2({
|
|
|
22428
23208
|
onContentChange,
|
|
22429
23209
|
onSave
|
|
22430
23210
|
}) {
|
|
22431
|
-
const [viewMode, setViewMode] =
|
|
22432
|
-
const [isEditing, setIsEditing] =
|
|
22433
|
-
const [editContent, setEditContent] =
|
|
22434
|
-
const [undoStack, setUndoStack] =
|
|
22435
|
-
const [redoStack, setRedoStack] =
|
|
22436
|
-
|
|
23211
|
+
const [viewMode, setViewMode] = React16.useState(defaultView);
|
|
23212
|
+
const [isEditing, setIsEditing] = React16.useState(false);
|
|
23213
|
+
const [editContent, setEditContent] = React16.useState("");
|
|
23214
|
+
const [undoStack, setUndoStack] = React16.useState([]);
|
|
23215
|
+
const [redoStack, setRedoStack] = React16.useState([]);
|
|
23216
|
+
React16.useEffect(() => {
|
|
22437
23217
|
if (artifact) {
|
|
22438
23218
|
if (artifact.type === "html" || artifact.type === "markdown" || artifact.type === "svg") {
|
|
22439
23219
|
setViewMode("preview");
|
|
@@ -22446,7 +23226,7 @@ var ArtifactViewer = React24.memo(function ArtifactViewer2({
|
|
|
22446
23226
|
setRedoStack([]);
|
|
22447
23227
|
}
|
|
22448
23228
|
}, [artifact?.id]);
|
|
22449
|
-
|
|
23229
|
+
React16.useEffect(() => {
|
|
22450
23230
|
if (artifact && !isEditing) {
|
|
22451
23231
|
setEditContent(artifact.content);
|
|
22452
23232
|
}
|
|
@@ -22721,7 +23501,7 @@ function InformationSupplement({
|
|
|
22721
23501
|
referenceImage,
|
|
22722
23502
|
qrCode
|
|
22723
23503
|
}) {
|
|
22724
|
-
const [open, setOpen] =
|
|
23504
|
+
const [open, setOpen] = React16__namespace.default.useState(!confirmed);
|
|
22725
23505
|
const resolvedMain = main_image || mainImage;
|
|
22726
23506
|
const resolvedRef = reference_image || referenceImage;
|
|
22727
23507
|
const resolvedQr = qrcode || qrCode;
|
|
@@ -22769,8 +23549,8 @@ function InformationSupplement({
|
|
|
22769
23549
|
] });
|
|
22770
23550
|
}
|
|
22771
23551
|
function BriefReview({ content, confirmed }) {
|
|
22772
|
-
const [open, setOpen] =
|
|
22773
|
-
const sanitizedContent =
|
|
23552
|
+
const [open, setOpen] = React16.useState(!confirmed);
|
|
23553
|
+
const sanitizedContent = React16.useMemo(() => sanitizeMarkdownContent(content || ""), [content]);
|
|
22774
23554
|
if (!sanitizedContent) {
|
|
22775
23555
|
return null;
|
|
22776
23556
|
}
|
|
@@ -22802,8 +23582,8 @@ function SessionItem({
|
|
|
22802
23582
|
onReplay,
|
|
22803
23583
|
onShare
|
|
22804
23584
|
}) {
|
|
22805
|
-
const [editing, setEditing] =
|
|
22806
|
-
const [title, setTitle] =
|
|
23585
|
+
const [editing, setEditing] = React16.useState(false);
|
|
23586
|
+
const [title, setTitle] = React16.useState("");
|
|
22807
23587
|
const startEdit = (e) => {
|
|
22808
23588
|
e.stopPropagation();
|
|
22809
23589
|
setTitle(session.title || "\u65B0\u5BF9\u8BDD");
|
|
@@ -22875,10 +23655,11 @@ function Sidebar({
|
|
|
22875
23655
|
onNew,
|
|
22876
23656
|
agentName,
|
|
22877
23657
|
agentType,
|
|
23658
|
+
agentIcon,
|
|
22878
23659
|
collapsed,
|
|
22879
23660
|
onToggle
|
|
22880
23661
|
}) {
|
|
22881
|
-
const [search, setSearch] =
|
|
23662
|
+
const [search, setSearch] = React16.useState("");
|
|
22882
23663
|
const filtered = sessions.filter(
|
|
22883
23664
|
(s) => !search || (s.title || "").toLowerCase().includes(search.toLowerCase())
|
|
22884
23665
|
);
|
|
@@ -22898,7 +23679,7 @@ function Sidebar({
|
|
|
22898
23679
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-3 border-b border-zinc-800/50", children: [
|
|
22899
23680
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between mb-3", children: [
|
|
22900
23681
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 min-w-0", children: [
|
|
22901
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-7 h-7 rounded-lg bg-[#d8ff00]/10 flex items-center justify-center flex-shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Bot, { size: 14, className: "text-[#d8ff00]" }) }),
|
|
23682
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-7 h-7 rounded-lg bg-[#d8ff00]/10 flex items-center justify-center flex-shrink-0", children: agentIcon ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: getImageUrl(agentIcon), alt: "Agent Icon", className: "w-7 h-7 rounded-lg" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Bot, { size: 14, className: "text-[#d8ff00]" }) }),
|
|
22902
23683
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium text-white truncate", children: agentName || "Agent" })
|
|
22903
23684
|
] }),
|
|
22904
23685
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-0.5", children: /* @__PURE__ */ jsxRuntime.jsx("button", { onClick: onToggle, className: "p-1.5 text-zinc-500 hover:text-zinc-300 hover:bg-zinc-800 rounded-lg", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PanelLeftClose, { size: 14 }) }) })
|
|
@@ -22953,7 +23734,7 @@ function Sidebar({
|
|
|
22953
23734
|
] });
|
|
22954
23735
|
}
|
|
22955
23736
|
function WelcomePage({ agentName, welcomeMessage, tools, onNew, onPrompt }) {
|
|
22956
|
-
const quickPrompts =
|
|
23737
|
+
const quickPrompts = React16__namespace.default.useMemo(() => {
|
|
22957
23738
|
const prompts = [];
|
|
22958
23739
|
const hasImageTool = tools?.some(
|
|
22959
23740
|
(t) => t.name?.toLowerCase().includes("image") || t.name?.toLowerCase().includes("\u56FE\u7247") || t.type === "COMFY_APP"
|
|
@@ -23041,8 +23822,8 @@ function ChatInputArea({
|
|
|
23041
23822
|
onDetachArtifact,
|
|
23042
23823
|
onOpenTemplates
|
|
23043
23824
|
}) {
|
|
23044
|
-
const textareaRef =
|
|
23045
|
-
const fileInputRef =
|
|
23825
|
+
const textareaRef = React16.useRef(null);
|
|
23826
|
+
const fileInputRef = React16.useRef(null);
|
|
23046
23827
|
const removeImage = (index) => {
|
|
23047
23828
|
setImages((prev) => {
|
|
23048
23829
|
const newImages = [...prev];
|
|
@@ -23272,13 +24053,13 @@ function ChatInputArea({
|
|
|
23272
24053
|
] })
|
|
23273
24054
|
] }) });
|
|
23274
24055
|
}
|
|
23275
|
-
var DragHandle =
|
|
24056
|
+
var DragHandle = React16__namespace.default.memo(function DragHandle2({
|
|
23276
24057
|
artifactPanelWidth,
|
|
23277
24058
|
isDragging,
|
|
23278
24059
|
onMouseDown
|
|
23279
24060
|
}) {
|
|
23280
|
-
const [isHovered, setIsHovered] =
|
|
23281
|
-
|
|
24061
|
+
const [isHovered, setIsHovered] = React16.useState(false);
|
|
24062
|
+
React16.useEffect(() => {
|
|
23282
24063
|
if (isHovered || isDragging) {
|
|
23283
24064
|
document.body.style.cursor = "col-resize";
|
|
23284
24065
|
} else {
|
|
@@ -23299,7 +24080,7 @@ var DragHandle = React24__namespace.default.memo(function DragHandle2({
|
|
|
23299
24080
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
23300
24081
|
"div",
|
|
23301
24082
|
{
|
|
23302
|
-
className:
|
|
24083
|
+
className: cn3(
|
|
23303
24084
|
"absolute left-1/2 top-0 bottom-0 -translate-x-1/2",
|
|
23304
24085
|
"transition-all duration-100"
|
|
23305
24086
|
),
|
|
@@ -23322,7 +24103,7 @@ var artifactTypeIconMap = {
|
|
|
23322
24103
|
image: lucideReact.FileImage,
|
|
23323
24104
|
video: lucideReact.Video
|
|
23324
24105
|
};
|
|
23325
|
-
var ArtifactBarItemThumbnail =
|
|
24106
|
+
var ArtifactBarItemThumbnail = React16.memo(function ArtifactBarItemThumbnail2({
|
|
23326
24107
|
artifact,
|
|
23327
24108
|
config
|
|
23328
24109
|
}) {
|
|
@@ -23350,7 +24131,7 @@ var ArtifactBarItemThumbnail = React24.memo(function ArtifactBarItemThumbnail2({
|
|
|
23350
24131
|
}
|
|
23351
24132
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-10 h-10 rounded-lg bg-zinc-800/50 agent-sdk-light:bg-zinc-100 flex items-center justify-center flex-shrink-0 border border-zinc-700/30 agent-sdk-light:border-zinc-300", children: /* @__PURE__ */ jsxRuntime.jsx(TypeIcon, { size: 18, className: "text-zinc-400 agent-sdk-light:text-zinc-500" }) });
|
|
23352
24133
|
});
|
|
23353
|
-
var ArtifactBarMiniThumbnail =
|
|
24134
|
+
var ArtifactBarMiniThumbnail = React16.memo(function ArtifactBarMiniThumbnail2({
|
|
23354
24135
|
artifact,
|
|
23355
24136
|
config
|
|
23356
24137
|
}) {
|
|
@@ -23378,14 +24159,14 @@ var ArtifactBarMiniThumbnail = React24.memo(function ArtifactBarMiniThumbnail2({
|
|
|
23378
24159
|
}
|
|
23379
24160
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-6 h-6 rounded border border-zinc-700 agent-sdk-light:border-zinc-300 bg-zinc-800 agent-sdk-light:bg-zinc-200 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(TypeIcon, { size: 10, className: "text-zinc-400" }) });
|
|
23380
24161
|
});
|
|
23381
|
-
var ArtifactBar =
|
|
24162
|
+
var ArtifactBar = React16__namespace.default.memo(function ArtifactBar2({
|
|
23382
24163
|
artifacts,
|
|
23383
24164
|
onOpenArtifact,
|
|
23384
24165
|
config
|
|
23385
24166
|
}) {
|
|
23386
|
-
const [expanded, setExpanded] =
|
|
23387
|
-
const barRef =
|
|
23388
|
-
|
|
24167
|
+
const [expanded, setExpanded] = React16.useState(false);
|
|
24168
|
+
const barRef = React16.useRef(null);
|
|
24169
|
+
React16.useEffect(() => {
|
|
23389
24170
|
if (!expanded) return;
|
|
23390
24171
|
const handleClickOutside = (e) => {
|
|
23391
24172
|
if (barRef.current && !barRef.current.contains(e.target)) {
|
|
@@ -23485,7 +24266,7 @@ var ArtifactBar = React24__namespace.default.memo(function ArtifactBar2({
|
|
|
23485
24266
|
artifacts.length - 4
|
|
23486
24267
|
] }) })
|
|
23487
24268
|
] }),
|
|
23488
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronUp, { size: 14, className:
|
|
24269
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronUp, { size: 14, className: cn3(
|
|
23489
24270
|
"text-zinc-500 transition-transform flex-shrink-0",
|
|
23490
24271
|
expanded && "rotate-180"
|
|
23491
24272
|
) })
|
|
@@ -23507,12 +24288,12 @@ function useArtifactPanel({ currentSessionId }) {
|
|
|
23507
24288
|
reorderArtifacts,
|
|
23508
24289
|
updateArtifactContent
|
|
23509
24290
|
} = useAgentStore();
|
|
23510
|
-
const [isArtifactFullscreen, setIsArtifactFullscreen] =
|
|
23511
|
-
const [artifactPanelWidth, setArtifactPanelWidth] =
|
|
23512
|
-
const [isDragging, setIsDragging] =
|
|
23513
|
-
const dragStartRef =
|
|
23514
|
-
const containerRef =
|
|
23515
|
-
const artifactList =
|
|
24291
|
+
const [isArtifactFullscreen, setIsArtifactFullscreen] = React16.useState(false);
|
|
24292
|
+
const [artifactPanelWidth, setArtifactPanelWidth] = React16.useState(50);
|
|
24293
|
+
const [isDragging, setIsDragging] = React16.useState(false);
|
|
24294
|
+
const dragStartRef = React16.useRef(null);
|
|
24295
|
+
const containerRef = React16.useRef(null);
|
|
24296
|
+
const artifactList = React16__namespace.default.useMemo(() => {
|
|
23516
24297
|
const ordered = artifactOrder.map((id) => artifacts[id]).filter(Boolean);
|
|
23517
24298
|
const unordered = Object.values(artifacts).filter(
|
|
23518
24299
|
(a) => !artifactOrder.includes(a.id)
|
|
@@ -23520,7 +24301,7 @@ function useArtifactPanel({ currentSessionId }) {
|
|
|
23520
24301
|
return [...ordered, ...unordered];
|
|
23521
24302
|
}, [artifacts, artifactOrder]);
|
|
23522
24303
|
const activeArtifact = activeArtifactId ? artifacts[activeArtifactId] ?? null : null;
|
|
23523
|
-
const handleDragMouseDown =
|
|
24304
|
+
const handleDragMouseDown = React16.useCallback((e) => {
|
|
23524
24305
|
e.preventDefault();
|
|
23525
24306
|
e.stopPropagation();
|
|
23526
24307
|
dragStartRef.current = {
|
|
@@ -23531,7 +24312,7 @@ function useArtifactPanel({ currentSessionId }) {
|
|
|
23531
24312
|
document.body.style.cursor = "col-resize";
|
|
23532
24313
|
document.body.style.userSelect = "none";
|
|
23533
24314
|
}, [artifactPanelWidth]);
|
|
23534
|
-
|
|
24315
|
+
React16.useEffect(() => {
|
|
23535
24316
|
if (!isDragging) return;
|
|
23536
24317
|
const handleMouseMove = (e) => {
|
|
23537
24318
|
if (!dragStartRef.current || !containerRef.current) return;
|
|
@@ -23562,7 +24343,7 @@ function useArtifactPanel({ currentSessionId }) {
|
|
|
23562
24343
|
document.body.style.userSelect = "";
|
|
23563
24344
|
};
|
|
23564
24345
|
}, [isDragging]);
|
|
23565
|
-
const handleOpenArtifact =
|
|
24346
|
+
const handleOpenArtifact = React16.useCallback((data) => {
|
|
23566
24347
|
const currentArtifact = activeArtifactId ? artifacts[activeArtifactId] : null;
|
|
23567
24348
|
if (currentArtifact && currentArtifact.currentContent === data.content && currentArtifact.type === data.type) {
|
|
23568
24349
|
setActiveArtifact(null);
|
|
@@ -23570,7 +24351,11 @@ function useArtifactPanel({ currentSessionId }) {
|
|
|
23570
24351
|
return;
|
|
23571
24352
|
}
|
|
23572
24353
|
const existingArtifact = Object.values(artifacts).find(
|
|
23573
|
-
(a) =>
|
|
24354
|
+
(a) => {
|
|
24355
|
+
const sameContent = a.currentContent === data.content && a.type === data.type;
|
|
24356
|
+
const sameId = a?.metadata?.workId === data.metadata?.workId;
|
|
24357
|
+
return sameContent || sameId;
|
|
24358
|
+
}
|
|
23574
24359
|
);
|
|
23575
24360
|
if (existingArtifact) {
|
|
23576
24361
|
setActiveArtifact(existingArtifact.id);
|
|
@@ -23592,11 +24377,11 @@ function useArtifactPanel({ currentSessionId }) {
|
|
|
23592
24377
|
setActiveArtifact(newArtifactEntry.id);
|
|
23593
24378
|
}
|
|
23594
24379
|
}, [activeArtifactId, artifacts, currentSessionId, upsertArtifact, setActiveArtifact]);
|
|
23595
|
-
const handleCloseArtifact =
|
|
24380
|
+
const handleCloseArtifact = React16.useCallback(() => {
|
|
23596
24381
|
setActiveArtifact(null);
|
|
23597
24382
|
setIsArtifactFullscreen(false);
|
|
23598
24383
|
}, [setActiveArtifact]);
|
|
23599
|
-
|
|
24384
|
+
React16.useEffect(() => {
|
|
23600
24385
|
const handleKeyDown = (e) => {
|
|
23601
24386
|
if (e.key === "Escape" && activeArtifactId) {
|
|
23602
24387
|
if (isArtifactFullscreen) {
|
|
@@ -23609,7 +24394,7 @@ function useArtifactPanel({ currentSessionId }) {
|
|
|
23609
24394
|
document.addEventListener("keydown", handleKeyDown);
|
|
23610
24395
|
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
23611
24396
|
}, [activeArtifactId, isArtifactFullscreen, setActiveArtifact]);
|
|
23612
|
-
const handleToggleArtifactFullscreen =
|
|
24397
|
+
const handleToggleArtifactFullscreen = React16.useCallback(() => {
|
|
23613
24398
|
setIsArtifactFullscreen((prev) => !prev);
|
|
23614
24399
|
}, []);
|
|
23615
24400
|
return {
|
|
@@ -23826,8 +24611,8 @@ function useSessionManager({
|
|
|
23826
24611
|
onSessionIdChange,
|
|
23827
24612
|
reconnect
|
|
23828
24613
|
}) {
|
|
23829
|
-
const [loading, setLoading] =
|
|
23830
|
-
const [messagesLoading, setMessagesLoading] =
|
|
24614
|
+
const [loading, setLoading] = React16.useState(true);
|
|
24615
|
+
const [messagesLoading, setMessagesLoading] = React16.useState(false);
|
|
23831
24616
|
const {
|
|
23832
24617
|
sessions,
|
|
23833
24618
|
setSessions,
|
|
@@ -23840,7 +24625,7 @@ function useSessionManager({
|
|
|
23840
24625
|
upsertArtifact,
|
|
23841
24626
|
setMessages
|
|
23842
24627
|
} = useAgentStore();
|
|
23843
|
-
|
|
24628
|
+
React16.useEffect(() => {
|
|
23844
24629
|
setCurrentSession(null);
|
|
23845
24630
|
setMessages([]);
|
|
23846
24631
|
clearArtifacts();
|
|
@@ -23855,7 +24640,7 @@ function useSessionManager({
|
|
|
23855
24640
|
}
|
|
23856
24641
|
}).finally(() => setLoading(false));
|
|
23857
24642
|
}, [projectId, agentId, setSessions, setCurrentSession, setMessages, clearArtifacts]);
|
|
23858
|
-
const loadMessages =
|
|
24643
|
+
const loadMessages = React16.useCallback(async (sessionId) => {
|
|
23859
24644
|
const res = await sessionService.getMessages(sessionId, { pageNo: 1, pageSize: 100 });
|
|
23860
24645
|
if (res.success && res.data?.list) {
|
|
23861
24646
|
const msgs = res.data.list.map((m) => {
|
|
@@ -23896,7 +24681,7 @@ function useSessionManager({
|
|
|
23896
24681
|
}
|
|
23897
24682
|
}
|
|
23898
24683
|
}, [setMessages, reconnect]);
|
|
23899
|
-
const handleNew =
|
|
24684
|
+
const handleNew = React16.useCallback(async () => {
|
|
23900
24685
|
const s = await createAndStartSession(projectId, agentId, "\u65B0\u5BF9\u8BDD");
|
|
23901
24686
|
if (s?.sessionId) {
|
|
23902
24687
|
addSession(s);
|
|
@@ -23906,7 +24691,7 @@ function useSessionManager({
|
|
|
23906
24691
|
clearArtifacts();
|
|
23907
24692
|
}
|
|
23908
24693
|
}, [projectId, agentId, addSession, setCurrentSession, onSessionIdChange, setMessages, clearArtifacts]);
|
|
23909
|
-
const handleSelect =
|
|
24694
|
+
const handleSelect = React16.useCallback(async (s) => {
|
|
23910
24695
|
setCurrentSession(s);
|
|
23911
24696
|
onSessionIdChange?.(s.sessionId);
|
|
23912
24697
|
setMessages([]);
|
|
@@ -23933,7 +24718,7 @@ function useSessionManager({
|
|
|
23933
24718
|
}
|
|
23934
24719
|
setMessagesLoading(false);
|
|
23935
24720
|
}, [setCurrentSession, onSessionIdChange, setMessages, clearArtifacts, setArtifacts, loadMessages, upsertArtifact]);
|
|
23936
|
-
const handleDelete2 =
|
|
24721
|
+
const handleDelete2 = React16.useCallback((id) => {
|
|
23937
24722
|
toast("\u5220\u9664\u6B64\u5BF9\u8BDD\uFF1F", {
|
|
23938
24723
|
action: {
|
|
23939
24724
|
label: "\u786E\u8BA4\u5220\u9664",
|
|
@@ -23958,7 +24743,7 @@ function useSessionManager({
|
|
|
23958
24743
|
}
|
|
23959
24744
|
});
|
|
23960
24745
|
}, [currentSession, sessions, removeSession, setCurrentSession]);
|
|
23961
|
-
const handleRename =
|
|
24746
|
+
const handleRename = React16.useCallback(async (id, title) => {
|
|
23962
24747
|
const res = await sessionService.updateTitle(id, title);
|
|
23963
24748
|
if (res.success) {
|
|
23964
24749
|
useAgentStore.getState().updateSession(id, { title });
|
|
@@ -23986,14 +24771,14 @@ function useMessageSender({
|
|
|
23986
24771
|
activeArtifactId,
|
|
23987
24772
|
artifacts
|
|
23988
24773
|
}) {
|
|
23989
|
-
const [input, setInput] =
|
|
23990
|
-
const [images, setImages] =
|
|
23991
|
-
const [isSending, setIsSending] =
|
|
23992
|
-
const textareaRef =
|
|
23993
|
-
const fileInputRef =
|
|
23994
|
-
const lastUserMessageRef =
|
|
24774
|
+
const [input, setInput] = React16.useState("");
|
|
24775
|
+
const [images, setImages] = React16.useState([]);
|
|
24776
|
+
const [isSending, setIsSending] = React16.useState(false);
|
|
24777
|
+
const textareaRef = React16.useRef(null);
|
|
24778
|
+
const fileInputRef = React16.useRef(null);
|
|
24779
|
+
const lastUserMessageRef = React16.useRef("");
|
|
23995
24780
|
const { addMessage, updateMessage } = useAgentStore();
|
|
23996
|
-
const handleSend =
|
|
24781
|
+
const handleSend = React16.useCallback(async () => {
|
|
23997
24782
|
if (!input.trim() && images.length === 0) return;
|
|
23998
24783
|
if (!currentSessionId) return;
|
|
23999
24784
|
if (isSending) return;
|
|
@@ -24102,13 +24887,13 @@ function useMessageSender({
|
|
|
24102
24887
|
setIsSending(false);
|
|
24103
24888
|
}
|
|
24104
24889
|
}, [input, images, currentSessionId, sendMessage, config, activeArtifactId, artifacts, isSending, addMessage, updateMessage]);
|
|
24105
|
-
const sendTextMessage =
|
|
24890
|
+
const sendTextMessage = React16.useCallback(async (content) => {
|
|
24106
24891
|
if (!content.trim()) return;
|
|
24107
24892
|
if (!currentSessionId) return;
|
|
24108
24893
|
lastUserMessageRef.current = content.trim();
|
|
24109
24894
|
await sendMessage(currentSessionId, content.trim());
|
|
24110
24895
|
}, [currentSessionId, sendMessage]);
|
|
24111
|
-
const addAssetsWithPreview =
|
|
24896
|
+
const addAssetsWithPreview = React16.useCallback(async (assets) => {
|
|
24112
24897
|
const previews = await Promise.all(
|
|
24113
24898
|
assets.map(async (asset) => {
|
|
24114
24899
|
if (asset.file instanceof File) {
|
|
@@ -24204,15 +24989,15 @@ function useTemplateManager({
|
|
|
24204
24989
|
onTemplateSend,
|
|
24205
24990
|
setInput
|
|
24206
24991
|
} = {}) {
|
|
24207
|
-
const [showTemplateSelector, setShowTemplateSelector] =
|
|
24208
|
-
const [selectedTemplate, setSelectedTemplate] =
|
|
24209
|
-
const [showSaveTemplate, setShowSaveTemplate] =
|
|
24210
|
-
const [saveTemplateContent, setSaveTemplateContent] =
|
|
24211
|
-
const [isSavingTemplate, setIsSavingTemplate] =
|
|
24212
|
-
const handleOpenTemplates =
|
|
24992
|
+
const [showTemplateSelector, setShowTemplateSelector] = React16.useState(false);
|
|
24993
|
+
const [selectedTemplate, setSelectedTemplate] = React16.useState(null);
|
|
24994
|
+
const [showSaveTemplate, setShowSaveTemplate] = React16.useState(false);
|
|
24995
|
+
const [saveTemplateContent, setSaveTemplateContent] = React16.useState("");
|
|
24996
|
+
const [isSavingTemplate, setIsSavingTemplate] = React16.useState(false);
|
|
24997
|
+
const handleOpenTemplates = React16.useCallback(() => {
|
|
24213
24998
|
setShowTemplateSelector(true);
|
|
24214
24999
|
}, []);
|
|
24215
|
-
const handleSelectTemplate =
|
|
25000
|
+
const handleSelectTemplate = React16.useCallback((template) => {
|
|
24216
25001
|
setShowTemplateSelector(false);
|
|
24217
25002
|
if (template.variables && template.variables.length > 0) {
|
|
24218
25003
|
setSelectedTemplate(template);
|
|
@@ -24220,15 +25005,15 @@ function useTemplateManager({
|
|
|
24220
25005
|
setInput?.(template.content);
|
|
24221
25006
|
}
|
|
24222
25007
|
}, [setInput]);
|
|
24223
|
-
const handleTemplateSend =
|
|
25008
|
+
const handleTemplateSend = React16.useCallback((content) => {
|
|
24224
25009
|
setSelectedTemplate(null);
|
|
24225
25010
|
onTemplateSend?.(content);
|
|
24226
25011
|
}, [onTemplateSend]);
|
|
24227
|
-
const handleSaveAsTemplate =
|
|
25012
|
+
const handleSaveAsTemplate = React16.useCallback((content) => {
|
|
24228
25013
|
setSaveTemplateContent(content);
|
|
24229
25014
|
setShowSaveTemplate(true);
|
|
24230
25015
|
}, []);
|
|
24231
|
-
const handleSaveTemplate =
|
|
25016
|
+
const handleSaveTemplate = React16.useCallback(async (templateData) => {
|
|
24232
25017
|
setIsSavingTemplate(true);
|
|
24233
25018
|
try {
|
|
24234
25019
|
await templateService.create(templateData);
|
|
@@ -24241,7 +25026,7 @@ function useTemplateManager({
|
|
|
24241
25026
|
setIsSavingTemplate(false);
|
|
24242
25027
|
}
|
|
24243
25028
|
}, []);
|
|
24244
|
-
const handleCancelSaveTemplate =
|
|
25029
|
+
const handleCancelSaveTemplate = React16.useCallback(() => {
|
|
24245
25030
|
setShowSaveTemplate(false);
|
|
24246
25031
|
setSaveTemplateContent("");
|
|
24247
25032
|
}, []);
|
|
@@ -24261,13 +25046,13 @@ function useTemplateManager({
|
|
|
24261
25046
|
};
|
|
24262
25047
|
}
|
|
24263
25048
|
function usePlanMode() {
|
|
24264
|
-
const [planProcessing, setPlanProcessing] =
|
|
25049
|
+
const [planProcessing, setPlanProcessing] = React16.useState(false);
|
|
24265
25050
|
const currentPlan = useAgentStore((state) => state.chatUI.currentPlan);
|
|
24266
25051
|
const waitingStepId = useAgentStore((state) => state.chatUI.waitingStepId);
|
|
24267
25052
|
const setShowPlanConfirmDialog = useAgentStore((state) => state.setShowPlanConfirmDialog);
|
|
24268
25053
|
const setShowHumanInputDialog = useAgentStore((state) => state.setShowHumanInputDialog);
|
|
24269
25054
|
const clearPlanState = useAgentStore((state) => state.clearPlanState);
|
|
24270
|
-
const handlePlanConfirm =
|
|
25055
|
+
const handlePlanConfirm = React16.useCallback(async () => {
|
|
24271
25056
|
if (!currentPlan?.publicId) return;
|
|
24272
25057
|
setPlanProcessing(true);
|
|
24273
25058
|
try {
|
|
@@ -24280,7 +25065,7 @@ function usePlanMode() {
|
|
|
24280
25065
|
setPlanProcessing(false);
|
|
24281
25066
|
}
|
|
24282
25067
|
}, [currentPlan, setShowPlanConfirmDialog]);
|
|
24283
|
-
const handlePlanReject =
|
|
25068
|
+
const handlePlanReject = React16.useCallback(async () => {
|
|
24284
25069
|
if (!currentPlan?.publicId) return;
|
|
24285
25070
|
setPlanProcessing(true);
|
|
24286
25071
|
try {
|
|
@@ -24294,7 +25079,7 @@ function usePlanMode() {
|
|
|
24294
25079
|
setPlanProcessing(false);
|
|
24295
25080
|
}
|
|
24296
25081
|
}, [currentPlan, clearPlanState]);
|
|
24297
|
-
const handlePlanPause =
|
|
25082
|
+
const handlePlanPause = React16.useCallback(async () => {
|
|
24298
25083
|
if (!currentPlan?.publicId) return;
|
|
24299
25084
|
try {
|
|
24300
25085
|
await planService.pause(currentPlan.publicId);
|
|
@@ -24303,7 +25088,7 @@ function usePlanMode() {
|
|
|
24303
25088
|
toast.error("\u6682\u505C\u8BA1\u5212\u5931\u8D25");
|
|
24304
25089
|
}
|
|
24305
25090
|
}, [currentPlan]);
|
|
24306
|
-
const handlePlanResume =
|
|
25091
|
+
const handlePlanResume = React16.useCallback(async () => {
|
|
24307
25092
|
if (!currentPlan?.publicId) return;
|
|
24308
25093
|
try {
|
|
24309
25094
|
await planService.resume(currentPlan.publicId);
|
|
@@ -24312,7 +25097,7 @@ function usePlanMode() {
|
|
|
24312
25097
|
toast.error("\u6062\u590D\u8BA1\u5212\u5931\u8D25");
|
|
24313
25098
|
}
|
|
24314
25099
|
}, [currentPlan]);
|
|
24315
|
-
const handlePlanCancel =
|
|
25100
|
+
const handlePlanCancel = React16.useCallback(async () => {
|
|
24316
25101
|
if (!currentPlan?.publicId) return;
|
|
24317
25102
|
try {
|
|
24318
25103
|
await planService.cancel(currentPlan.publicId);
|
|
@@ -24322,7 +25107,7 @@ function usePlanMode() {
|
|
|
24322
25107
|
toast.error("\u53D6\u6D88\u8BA1\u5212\u5931\u8D25");
|
|
24323
25108
|
}
|
|
24324
25109
|
}, [currentPlan, clearPlanState]);
|
|
24325
|
-
const handlePlanRetry =
|
|
25110
|
+
const handlePlanRetry = React16.useCallback(async () => {
|
|
24326
25111
|
if (!currentPlan?.publicId) return;
|
|
24327
25112
|
setPlanProcessing(true);
|
|
24328
25113
|
try {
|
|
@@ -24335,7 +25120,7 @@ function usePlanMode() {
|
|
|
24335
25120
|
setPlanProcessing(false);
|
|
24336
25121
|
}
|
|
24337
25122
|
}, [currentPlan]);
|
|
24338
|
-
const handlePlanSkip =
|
|
25123
|
+
const handlePlanSkip = React16.useCallback(async () => {
|
|
24339
25124
|
if (!currentPlan?.publicId) return;
|
|
24340
25125
|
setPlanProcessing(true);
|
|
24341
25126
|
try {
|
|
@@ -24348,7 +25133,7 @@ function usePlanMode() {
|
|
|
24348
25133
|
setPlanProcessing(false);
|
|
24349
25134
|
}
|
|
24350
25135
|
}, [currentPlan]);
|
|
24351
|
-
const handleHumanInput =
|
|
25136
|
+
const handleHumanInput = React16.useCallback(async (stepId, input) => {
|
|
24352
25137
|
if (!stepId || !currentPlan?.publicId) return;
|
|
24353
25138
|
try {
|
|
24354
25139
|
await planService.provideHumanInput(currentPlan.publicId, stepId, { input });
|
|
@@ -24372,7 +25157,7 @@ function usePlanMode() {
|
|
|
24372
25157
|
handleHumanInput
|
|
24373
25158
|
};
|
|
24374
25159
|
}
|
|
24375
|
-
var AgentChat =
|
|
25160
|
+
var AgentChat = React16__namespace.default.forwardRef(({
|
|
24376
25161
|
agentId,
|
|
24377
25162
|
projectId,
|
|
24378
25163
|
agentName,
|
|
@@ -24400,7 +25185,7 @@ var AgentChat = React24__namespace.default.forwardRef(({
|
|
|
24400
25185
|
const showSidebar = !embedded && !hideSidebar;
|
|
24401
25186
|
const showHeader = !embedded && !hideHeader;
|
|
24402
25187
|
const outerComponents = useComponents();
|
|
24403
|
-
const mergedComponents =
|
|
25188
|
+
const mergedComponents = React16__namespace.default.useMemo(() => {
|
|
24404
25189
|
const configComponents = config?.components || {};
|
|
24405
25190
|
const mergedRegistry = {
|
|
24406
25191
|
InformationSupplement,
|
|
@@ -24418,6 +25203,7 @@ var AgentChat = React24__namespace.default.forwardRef(({
|
|
|
24418
25203
|
tools: _tools,
|
|
24419
25204
|
setTools,
|
|
24420
25205
|
setSkills,
|
|
25206
|
+
mainAgentIcon,
|
|
24421
25207
|
setShowItemTime,
|
|
24422
25208
|
setSubAgentConfigs,
|
|
24423
25209
|
setMainAgentPublicId,
|
|
@@ -24425,11 +25211,11 @@ var AgentChat = React24__namespace.default.forwardRef(({
|
|
|
24425
25211
|
setMainAgentIcon,
|
|
24426
25212
|
setSubAgents
|
|
24427
25213
|
} = useAgentStore();
|
|
24428
|
-
const [mobileOpen, setMobileOpen] =
|
|
24429
|
-
const [collapsed, setCollapsed] =
|
|
24430
|
-
const [shareModalOpen, setShareModalOpen] =
|
|
24431
|
-
const [shareSession, setShareSession] =
|
|
24432
|
-
const [selectedTemplate, setSelectedTemplate] =
|
|
25214
|
+
const [mobileOpen, setMobileOpen] = React16.useState(false);
|
|
25215
|
+
const [collapsed, setCollapsed] = React16.useState(false);
|
|
25216
|
+
const [shareModalOpen, setShareModalOpen] = React16.useState(false);
|
|
25217
|
+
const [shareSession, setShareSession] = React16.useState(null);
|
|
25218
|
+
const [selectedTemplate, setSelectedTemplate] = React16.useState(null);
|
|
24433
25219
|
const {
|
|
24434
25220
|
artifactList,
|
|
24435
25221
|
activeArtifact,
|
|
@@ -24446,8 +25232,8 @@ var AgentChat = React24__namespace.default.forwardRef(({
|
|
|
24446
25232
|
reorderArtifacts,
|
|
24447
25233
|
updateArtifactContent
|
|
24448
25234
|
} = useArtifactPanel({ currentSessionId: useAgentStore((state) => state.currentSession?.sessionId) });
|
|
24449
|
-
const reconnectRef =
|
|
24450
|
-
const reconnectWrapper =
|
|
25235
|
+
const reconnectRef = React16.useRef(null);
|
|
25236
|
+
const reconnectWrapper = React16.useCallback(async (messageId) => {
|
|
24451
25237
|
if (reconnectRef.current) {
|
|
24452
25238
|
await reconnectRef.current(messageId);
|
|
24453
25239
|
}
|
|
@@ -24493,14 +25279,14 @@ var AgentChat = React24__namespace.default.forwardRef(({
|
|
|
24493
25279
|
}
|
|
24494
25280
|
}
|
|
24495
25281
|
});
|
|
24496
|
-
|
|
25282
|
+
React16.useEffect(() => {
|
|
24497
25283
|
reconnectRef.current = reconnect;
|
|
24498
25284
|
}, [reconnect]);
|
|
24499
25285
|
const isStreaming = useAgentStore((state) => state.chatUI.isStreaming);
|
|
24500
25286
|
const streamingSessionId = useAgentStore((state) => state.chatUI.streamingSessionId);
|
|
24501
25287
|
const isCurrentSessionStreaming = isStreaming && streamingSessionId === currentSession?.sessionId;
|
|
24502
25288
|
const messages = useAgentStore((state) => state.messages);
|
|
24503
|
-
const hasWaitingToolConfirmation =
|
|
25289
|
+
const hasWaitingToolConfirmation = React16.useMemo(() => {
|
|
24504
25290
|
if (!currentSession?.sessionId) return false;
|
|
24505
25291
|
return messages.some((m) => {
|
|
24506
25292
|
if (m.sessionId !== currentSession.sessionId) return false;
|
|
@@ -24556,10 +25342,10 @@ var AgentChat = React24__namespace.default.forwardRef(({
|
|
|
24556
25342
|
handlePlanSkip,
|
|
24557
25343
|
handleHumanInput
|
|
24558
25344
|
} = usePlanMode();
|
|
24559
|
-
|
|
25345
|
+
React16.useEffect(() => {
|
|
24560
25346
|
setShowItemTime(showItemTime);
|
|
24561
25347
|
}, [showItemTime]);
|
|
24562
|
-
|
|
25348
|
+
React16.useEffect(() => {
|
|
24563
25349
|
agentToolService.list(agentId).then((res) => {
|
|
24564
25350
|
res?.data?.length && setTools(res.data);
|
|
24565
25351
|
});
|
|
@@ -24584,7 +25370,7 @@ var AgentChat = React24__namespace.default.forwardRef(({
|
|
|
24584
25370
|
}
|
|
24585
25371
|
});
|
|
24586
25372
|
}, [agentId]);
|
|
24587
|
-
|
|
25373
|
+
React16.useEffect(() => {
|
|
24588
25374
|
if (initialSessionId && sessions.length > 0) {
|
|
24589
25375
|
const session = sessions.find((s) => s.sessionId === initialSessionId);
|
|
24590
25376
|
if (session) {
|
|
@@ -24592,7 +25378,7 @@ var AgentChat = React24__namespace.default.forwardRef(({
|
|
|
24592
25378
|
}
|
|
24593
25379
|
}
|
|
24594
25380
|
}, [initialSessionId, sessions]);
|
|
24595
|
-
const handleDeleteMessage =
|
|
25381
|
+
const handleDeleteMessage = React16.useCallback(async (messageId) => {
|
|
24596
25382
|
try {
|
|
24597
25383
|
const { messages: messages2, updateMessage } = useAgentStore.getState();
|
|
24598
25384
|
const target = messages2.find((m) => m.messageId === messageId);
|
|
@@ -24616,7 +25402,7 @@ var AgentChat = React24__namespace.default.forwardRef(({
|
|
|
24616
25402
|
return false;
|
|
24617
25403
|
}
|
|
24618
25404
|
}, []);
|
|
24619
|
-
const handleAbortMessage =
|
|
25405
|
+
const handleAbortMessage = React16.useCallback(async (messageId) => {
|
|
24620
25406
|
const { messages: messages2, updateMessage, clearPendingToolCalls, clearPendingFrontendToolCalls, clearPendingComponents } = useAgentStore.getState();
|
|
24621
25407
|
const target = messages2.find((m) => m.messageId === messageId);
|
|
24622
25408
|
const activeStreaming = messages2.find((m) => m.status === "streaming");
|
|
@@ -24654,7 +25440,7 @@ var AgentChat = React24__namespace.default.forwardRef(({
|
|
|
24654
25440
|
}
|
|
24655
25441
|
}
|
|
24656
25442
|
}, [abort, messageService]);
|
|
24657
|
-
const handleStop =
|
|
25443
|
+
const handleStop = React16.useCallback(() => {
|
|
24658
25444
|
const storeState = useAgentStore.getState();
|
|
24659
25445
|
const streamingMsg = storeState.messages.find((m) => m.status === "streaming");
|
|
24660
25446
|
if (streamingMsg) {
|
|
@@ -24671,7 +25457,7 @@ var AgentChat = React24__namespace.default.forwardRef(({
|
|
|
24671
25457
|
}
|
|
24672
25458
|
abort();
|
|
24673
25459
|
}, [handleAbortMessage, abort]);
|
|
24674
|
-
|
|
25460
|
+
React16.useImperativeHandle(ref, () => ({
|
|
24675
25461
|
sendTextMessage,
|
|
24676
25462
|
abortStreaming: async () => abort()
|
|
24677
25463
|
}), [sendTextMessage, abort]);
|
|
@@ -24710,6 +25496,7 @@ var AgentChat = React24__namespace.default.forwardRef(({
|
|
|
24710
25496
|
onNew: handleNew,
|
|
24711
25497
|
agentName,
|
|
24712
25498
|
agentType,
|
|
25499
|
+
agentIcon: mainAgentIcon,
|
|
24713
25500
|
collapsed,
|
|
24714
25501
|
onToggle: () => setCollapsed(!collapsed)
|
|
24715
25502
|
}
|
|
@@ -24751,21 +25538,21 @@ var AgentChat = React24__namespace.default.forwardRef(({
|
|
|
24751
25538
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
24752
25539
|
"div",
|
|
24753
25540
|
{
|
|
24754
|
-
className:
|
|
25541
|
+
className: cn3(
|
|
24755
25542
|
"flex flex-col min-h-0 overflow-hidden",
|
|
24756
25543
|
!isDragging && "transition-[width,opacity,transform] duration-300 ease-out",
|
|
24757
25544
|
isArtifactFullscreen ? "w-0 min-w-0 opacity-0 -translate-x-4" : currentArtifact ? "min-w-[350px]" : "w-full"
|
|
24758
25545
|
),
|
|
24759
25546
|
style: currentArtifact && !isArtifactFullscreen ? { width: `${100 - artifactPanelWidth}%` } : void 0,
|
|
24760
25547
|
children: [
|
|
24761
|
-
showHeader
|
|
25548
|
+
showHeader ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 h-12 px-3 border-b border-zinc-800/50 bg-zinc-950/80 backdrop-blur-sm flex-shrink-0", children: [
|
|
24762
25549
|
/* @__PURE__ */ jsxRuntime.jsx("button", { onClick: () => setMobileOpen(true), className: "lg:hidden p-1.5 text-zinc-500 hover:text-zinc-300 hover:bg-zinc-800 rounded-lg", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PanelLeft, { size: 18 }) }),
|
|
24763
25550
|
onNavigateBack && /* @__PURE__ */ jsxRuntime.jsx("button", { onClick: onNavigateBack, className: "p-1.5 text-zinc-500 hover:text-zinc-300 hover:bg-zinc-800 rounded-lg", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowLeft, { size: 18 }) }),
|
|
24764
25551
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-4 w-px bg-zinc-800 mx-1" }),
|
|
24765
25552
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-zinc-300 font-medium", children: agentName || "Agent" }),
|
|
24766
25553
|
agentType && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-zinc-600 bg-zinc-800/50 px-1.5 py-0.5 rounded", children: agentType === "BUILTIN" ? "\u5185\u7F6E" : agentType === "EXTERNAL" ? "\u5916\u90E8" : "\u591AAgent" }),
|
|
24767
25554
|
onNavigateToSettings && /* @__PURE__ */ jsxRuntime.jsx("button", { onClick: onNavigateToSettings, className: "ml-auto p-1.5 text-zinc-500 hover:text-zinc-300 hover:bg-zinc-800 rounded-lg", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Settings, { size: 18 }) })
|
|
24768
|
-
] }),
|
|
25555
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("button", { onClick: () => setMobileOpen(true), className: "lg:hidden p-1.5 text-zinc-500 hover:text-zinc-300 hover:bg-zinc-800 rounded-lg w-8", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PanelLeft, { size: 18 }) }),
|
|
24769
25556
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
24770
25557
|
ChatWindow_default,
|
|
24771
25558
|
{
|
|
@@ -24842,7 +25629,7 @@ var AgentChat = React24__namespace.default.forwardRef(({
|
|
|
24842
25629
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
24843
25630
|
"div",
|
|
24844
25631
|
{
|
|
24845
|
-
className:
|
|
25632
|
+
className: cn3(
|
|
24846
25633
|
"flex-shrink-0 overflow-hidden h-full relative",
|
|
24847
25634
|
!isDragging && "transition-[width,opacity] duration-300 ease-out",
|
|
24848
25635
|
currentArtifact ? isArtifactFullscreen ? "w-full min-w-0 border-l-0" : "min-w-[400px]" : "w-0 min-w-0 opacity-0"
|
|
@@ -24875,21 +25662,18 @@ var AgentChat = React24__namespace.default.forwardRef(({
|
|
|
24875
25662
|
}
|
|
24876
25663
|
},
|
|
24877
25664
|
onReorderArtifacts: (fromIndex, toIndex) => {
|
|
24878
|
-
|
|
24879
|
-
const [moved] = newOrder.splice(fromIndex, 1);
|
|
24880
|
-
newOrder.splice(toIndex, 0, moved);
|
|
24881
|
-
reorderArtifacts(newOrder);
|
|
25665
|
+
reorderArtifacts(fromIndex, toIndex);
|
|
24882
25666
|
},
|
|
24883
25667
|
onContentChange: (content) => {
|
|
24884
25668
|
if (activeArtifact) {
|
|
24885
|
-
updateArtifactContent(activeArtifact.id, content);
|
|
25669
|
+
updateArtifactContent(activeArtifact.id, content, "user");
|
|
24886
25670
|
}
|
|
24887
25671
|
},
|
|
24888
25672
|
onSave: async (artifactId, content) => {
|
|
24889
25673
|
try {
|
|
24890
25674
|
const res = await artifactService.updateContent(artifactId, content);
|
|
24891
25675
|
if (res.success) {
|
|
24892
|
-
updateArtifactContent(artifactId, content);
|
|
25676
|
+
updateArtifactContent(artifactId, content, "user");
|
|
24893
25677
|
toast.success("\u4EA7\u7269\u5DF2\u4FDD\u5B58");
|
|
24894
25678
|
} else {
|
|
24895
25679
|
toast.error("\u4FDD\u5B58\u5931\u8D25");
|
|
@@ -24982,26 +25766,26 @@ var SPEED_OPTIONS = [
|
|
|
24982
25766
|
{ value: 20, label: "20x" }
|
|
24983
25767
|
];
|
|
24984
25768
|
function ShareReplayPage({ shareId, onNavigateBack }) {
|
|
24985
|
-
const [pageState, setPageState] =
|
|
24986
|
-
const [error, setError] =
|
|
24987
|
-
const [password, setPassword] =
|
|
24988
|
-
const [verifying, setVerifying] =
|
|
24989
|
-
const [shareToken, setShareToken] =
|
|
24990
|
-
const [sharedData, setSharedData] =
|
|
24991
|
-
const [allMessages, setAllMessages] =
|
|
24992
|
-
const [playState, setPlayState] =
|
|
24993
|
-
const [currentIndex, setCurrentIndex] =
|
|
24994
|
-
const [displayedMessages, setDisplayedMessages] =
|
|
24995
|
-
const [speed, setSpeed] =
|
|
24996
|
-
const [isTyping, setIsTyping] =
|
|
24997
|
-
const [typingContent, setTypingContent] =
|
|
24998
|
-
const timerRef =
|
|
24999
|
-
const messagesEndRef =
|
|
25000
|
-
const playStateRef =
|
|
25001
|
-
const currentIndexRef =
|
|
25002
|
-
const isTypingRef =
|
|
25003
|
-
const typingStartTimeRef =
|
|
25004
|
-
const typingMessage =
|
|
25769
|
+
const [pageState, setPageState] = React16.useState("loading");
|
|
25770
|
+
const [error, setError] = React16.useState(null);
|
|
25771
|
+
const [password, setPassword] = React16.useState("");
|
|
25772
|
+
const [verifying, setVerifying] = React16.useState(false);
|
|
25773
|
+
const [shareToken, setShareToken] = React16.useState(null);
|
|
25774
|
+
const [sharedData, setSharedData] = React16.useState(null);
|
|
25775
|
+
const [allMessages, setAllMessages] = React16.useState([]);
|
|
25776
|
+
const [playState, setPlayState] = React16.useState("idle");
|
|
25777
|
+
const [currentIndex, setCurrentIndex] = React16.useState(0);
|
|
25778
|
+
const [displayedMessages, setDisplayedMessages] = React16.useState([]);
|
|
25779
|
+
const [speed, setSpeed] = React16.useState(2);
|
|
25780
|
+
const [isTyping, setIsTyping] = React16.useState(false);
|
|
25781
|
+
const [typingContent, setTypingContent] = React16.useState("");
|
|
25782
|
+
const timerRef = React16.useRef(null);
|
|
25783
|
+
const messagesEndRef = React16.useRef(null);
|
|
25784
|
+
const playStateRef = React16.useRef("idle");
|
|
25785
|
+
const currentIndexRef = React16.useRef(0);
|
|
25786
|
+
const isTypingRef = React16.useRef(false);
|
|
25787
|
+
const typingStartTimeRef = React16.useRef("");
|
|
25788
|
+
const typingMessage = React16.useMemo(() => {
|
|
25005
25789
|
const sessionIdValue = sharedData?.session?.sessionId || shareId;
|
|
25006
25790
|
if (!sessionIdValue) return null;
|
|
25007
25791
|
return {
|
|
@@ -25014,7 +25798,7 @@ function ShareReplayPage({ shareId, onNavigateBack }) {
|
|
|
25014
25798
|
};
|
|
25015
25799
|
}, [sharedData?.session?.sessionId, shareId]);
|
|
25016
25800
|
const getTokenStorageKey = (id) => `share_token_${id}`;
|
|
25017
|
-
|
|
25801
|
+
React16.useEffect(() => {
|
|
25018
25802
|
async function checkShare() {
|
|
25019
25803
|
if (!shareId) {
|
|
25020
25804
|
setError("\u5206\u4EAB ID \u65E0\u6548");
|
|
@@ -25081,29 +25865,29 @@ function ShareReplayPage({ shareId, onNavigateBack }) {
|
|
|
25081
25865
|
setVerifying(false);
|
|
25082
25866
|
}
|
|
25083
25867
|
};
|
|
25084
|
-
const scrollToBottom =
|
|
25868
|
+
const scrollToBottom = React16.useCallback(() => {
|
|
25085
25869
|
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
25086
25870
|
}, []);
|
|
25087
|
-
|
|
25871
|
+
React16.useEffect(() => {
|
|
25088
25872
|
scrollToBottom();
|
|
25089
25873
|
}, [displayedMessages, typingContent, scrollToBottom]);
|
|
25090
|
-
|
|
25874
|
+
React16.useEffect(() => {
|
|
25091
25875
|
return () => {
|
|
25092
25876
|
if (timerRef.current) {
|
|
25093
25877
|
clearTimeout(timerRef.current);
|
|
25094
25878
|
}
|
|
25095
25879
|
};
|
|
25096
25880
|
}, []);
|
|
25097
|
-
|
|
25881
|
+
React16.useEffect(() => {
|
|
25098
25882
|
playStateRef.current = playState;
|
|
25099
25883
|
}, [playState]);
|
|
25100
|
-
|
|
25884
|
+
React16.useEffect(() => {
|
|
25101
25885
|
currentIndexRef.current = currentIndex;
|
|
25102
25886
|
}, [currentIndex]);
|
|
25103
|
-
|
|
25887
|
+
React16.useEffect(() => {
|
|
25104
25888
|
isTypingRef.current = isTyping;
|
|
25105
25889
|
}, [isTyping]);
|
|
25106
|
-
const scheduleNext =
|
|
25890
|
+
const scheduleNext = React16.useCallback(() => {
|
|
25107
25891
|
if (playStateRef.current !== "playing") return;
|
|
25108
25892
|
const idx = currentIndexRef.current;
|
|
25109
25893
|
if (idx >= allMessages.length) {
|
|
@@ -25153,7 +25937,7 @@ function ShareReplayPage({ shareId, onNavigateBack }) {
|
|
|
25153
25937
|
};
|
|
25154
25938
|
typeChar();
|
|
25155
25939
|
}, [allMessages, speed]);
|
|
25156
|
-
const handlePlay =
|
|
25940
|
+
const handlePlay = React16.useCallback(() => {
|
|
25157
25941
|
if (timerRef.current) {
|
|
25158
25942
|
clearTimeout(timerRef.current);
|
|
25159
25943
|
}
|
|
@@ -25183,14 +25967,14 @@ function ShareReplayPage({ shareId, onNavigateBack }) {
|
|
|
25183
25967
|
scheduleNext();
|
|
25184
25968
|
}, 100);
|
|
25185
25969
|
}, [playState, allMessages, scheduleNext]);
|
|
25186
|
-
const handlePause =
|
|
25970
|
+
const handlePause = React16.useCallback(() => {
|
|
25187
25971
|
if (timerRef.current) {
|
|
25188
25972
|
clearTimeout(timerRef.current);
|
|
25189
25973
|
}
|
|
25190
25974
|
setPlayState("paused");
|
|
25191
25975
|
playStateRef.current = "paused";
|
|
25192
25976
|
}, []);
|
|
25193
|
-
const handleReset =
|
|
25977
|
+
const handleReset = React16.useCallback(() => {
|
|
25194
25978
|
if (timerRef.current) {
|
|
25195
25979
|
clearTimeout(timerRef.current);
|
|
25196
25980
|
}
|
|
@@ -25203,7 +25987,7 @@ function ShareReplayPage({ shareId, onNavigateBack }) {
|
|
|
25203
25987
|
isTypingRef.current = false;
|
|
25204
25988
|
setTypingContent("");
|
|
25205
25989
|
}, []);
|
|
25206
|
-
const handleSkip =
|
|
25990
|
+
const handleSkip = React16.useCallback(() => {
|
|
25207
25991
|
if (timerRef.current) {
|
|
25208
25992
|
clearTimeout(timerRef.current);
|
|
25209
25993
|
}
|
|
@@ -25221,12 +26005,12 @@ function ShareReplayPage({ shareId, onNavigateBack }) {
|
|
|
25221
26005
|
}
|
|
25222
26006
|
}
|
|
25223
26007
|
}, [allMessages, scheduleNext]);
|
|
25224
|
-
const handleShare =
|
|
26008
|
+
const handleShare = React16.useCallback(() => {
|
|
25225
26009
|
const url = window.location.href;
|
|
25226
26010
|
navigator.clipboard.writeText(url);
|
|
25227
26011
|
toast.success("\u94FE\u63A5\u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F");
|
|
25228
26012
|
}, []);
|
|
25229
|
-
const handleShowAll =
|
|
26013
|
+
const handleShowAll = React16.useCallback(() => {
|
|
25230
26014
|
if (timerRef.current) {
|
|
25231
26015
|
clearTimeout(timerRef.current);
|
|
25232
26016
|
}
|
|
@@ -25414,8 +26198,36 @@ function ShareReplayPage({ shareId, onNavigateBack }) {
|
|
|
25414
26198
|
] }) })
|
|
25415
26199
|
] });
|
|
25416
26200
|
}
|
|
26201
|
+
var AgentSDKProvider = ({
|
|
26202
|
+
children,
|
|
26203
|
+
toasterOptions,
|
|
26204
|
+
components
|
|
26205
|
+
}) => {
|
|
26206
|
+
const defaultToastOptions = {
|
|
26207
|
+
position: "top-center",
|
|
26208
|
+
toastOptions: {
|
|
26209
|
+
style: {
|
|
26210
|
+
background: "#27272a",
|
|
26211
|
+
border: "1px solid #3f3f46",
|
|
26212
|
+
color: "#fff"
|
|
26213
|
+
}
|
|
26214
|
+
}
|
|
26215
|
+
};
|
|
26216
|
+
const mergedOptions = toasterOptions ? { ...defaultToastOptions, ...toasterOptions } : defaultToastOptions;
|
|
26217
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ComponentProvider, { components, children: [
|
|
26218
|
+
children,
|
|
26219
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
26220
|
+
Toaster,
|
|
26221
|
+
{
|
|
26222
|
+
position: mergedOptions.position,
|
|
26223
|
+
toastOptions: mergedOptions.toastOptions
|
|
26224
|
+
}
|
|
26225
|
+
)
|
|
26226
|
+
] });
|
|
26227
|
+
};
|
|
25417
26228
|
|
|
25418
26229
|
exports.AgentChat = AgentChat_default;
|
|
26230
|
+
exports.AgentSDKProvider = AgentSDKProvider;
|
|
25419
26231
|
exports.ChatWindow = ChatWindow_default;
|
|
25420
26232
|
exports.ComponentProvider = ComponentProvider;
|
|
25421
26233
|
exports.HumanInputDialog = HumanInputDialog_default;
|