@zenera/chat-widget 0.1.4 → 0.1.6
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/README.md +53 -8
- package/dist/catalog-BYJPdVB0.js +358 -0
- package/dist/index-Dw5Lv6cs.js +3151 -0
- package/dist/index.js +22 -14
- package/dist/shadow-CEK6vAGQ.js +4 -0
- package/dist/styles.css +1 -1
- package/dist/types/packages/chat-widget/src/index.d.ts +4 -2
- package/dist/types/packages/chat-widget/src/interceptors.d.ts +50 -0
- package/dist/types/packages/chat-widget/src/reducer.d.ts +14 -0
- package/dist/types/packages/chat-widget/src/transport.d.ts +37 -4
- package/dist/types/packages/chat-widget/src/ui/ChatThreadView.d.ts +22 -2
- package/dist/types/packages/chat-widget/src/ui/ZeneraChat.d.ts +8 -2
- package/dist/types/packages/chat-widget/src/ui/internal/composerDraft.d.ts +1 -1
- package/dist/types/packages/chat-widget/src/useAttachments.d.ts +32 -0
- package/dist/types/packages/chat-widget/src/useChatThread.d.ts +3 -2
- package/dist/types/packages/chat-widget/src/widget.d.ts +8 -2
- package/dist/types/shared/components/A2uiSurface.d.ts +3 -0
- package/dist/types/shared/components/a2ui/Chart.d.ts +2 -0
- package/dist/types/shared/components/a2ui/ChartView.d.ts +3 -0
- package/dist/types/shared/components/a2ui/DataTable.d.ts +2 -0
- package/dist/types/shared/components/a2ui/Notice.d.ts +6 -0
- package/dist/types/shared/components/a2ui/catalog.d.ts +2 -0
- package/dist/types/shared/components/a2ui/catalogApi.d.ts +16 -0
- package/dist/types/shared/components/a2ui/chartData.d.ts +8 -0
- package/dist/types/shared/components/a2ui/tableData.d.ts +21 -0
- package/dist/types/shared/components/a2ui/useChartPayload.d.ts +9 -0
- package/dist/types/shared/lib/a2ui.d.ts +22 -0
- package/dist/types/shared/lib/a2uiData.d.ts +2 -0
- package/dist/types/shared/lib/a2uiFeed.d.ts +40 -0
- package/dist/types/shared/lib/promptHistory.d.ts +1 -1
- package/dist/ui.js +15 -2822
- package/dist/useThreadList-BbWSgDw_.js +899 -0
- package/dist/widget/chat-widget.iife.js +6179 -88
- package/package.json +7 -9
- package/dist/shadow-BRAwePHz.js +0 -4
- package/dist/useThreadList-Pg29akQ4.js +0 -576
|
@@ -0,0 +1,3151 @@
|
|
|
1
|
+
var Ht = Object.defineProperty;
|
|
2
|
+
var Ft = (e, t, s) => t in e ? Ht(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
|
3
|
+
var he = (e, t, s) => Ft(e, typeof t != "symbol" ? t + "" : t, s);
|
|
4
|
+
import { jsx as n, jsxs as d, Fragment as _e } from "react/jsx-runtime";
|
|
5
|
+
import * as Ie from "react";
|
|
6
|
+
import { useSyncExternalStore as qt, useState as O, useRef as W, useId as Ut, useLayoutEffect as ze, useEffect as T, useContext as ot, createContext as lt, useMemo as ne, useCallback as le, Fragment as Jt } from "react";
|
|
7
|
+
import { clsx as Kt } from "clsx";
|
|
8
|
+
import { twMerge as Xt } from "tailwind-merge";
|
|
9
|
+
import { ChevronDown as ct, Check as Re, Copy as Zt, TriangleAlert as Gt, Loader2 as Yt, PauseCircle as Vt, Wrench as Qt, Plug as er, Users as tr, Globe as rr, Terminal as nr, Files as sr, Brain as dt, LoaderCircle as ge, ChevronRight as ut, MessageSquarePlus as ir, Paperclip as ar, Square as or, SendHorizontal as lr, FileText as mt, RotateCw as cr, X as dr, Trash2 as ur, PanelRightOpen as mr, PanelRightClose as fr, PanelLeftOpen as pr, PanelLeftClose as hr, Plus as gr, SquarePen as br } from "lucide-react";
|
|
10
|
+
import { w as xr, l as yr, u as vr, p as wr } from "./useThreadList-BbWSgDw_.js";
|
|
11
|
+
import { Slot as Nr } from "@radix-ui/react-slot";
|
|
12
|
+
import { cva as kr } from "class-variance-authority";
|
|
13
|
+
import * as ve from "@radix-ui/react-tooltip";
|
|
14
|
+
import _r from "react-markdown";
|
|
15
|
+
import Sr from "rehype-sanitize";
|
|
16
|
+
import Cr from "remark-gfm";
|
|
17
|
+
import B from "highlight.js/lib/core";
|
|
18
|
+
import Er from "highlight.js/lib/languages/bash";
|
|
19
|
+
import zr from "highlight.js/lib/languages/css";
|
|
20
|
+
import Ar from "highlight.js/lib/languages/dockerfile";
|
|
21
|
+
import Lr from "highlight.js/lib/languages/diff";
|
|
22
|
+
import Or from "highlight.js/lib/languages/ini";
|
|
23
|
+
import jr from "highlight.js/lib/languages/javascript";
|
|
24
|
+
import Ir from "highlight.js/lib/languages/json";
|
|
25
|
+
import Rr from "highlight.js/lib/languages/markdown";
|
|
26
|
+
import $r from "highlight.js/lib/languages/python";
|
|
27
|
+
import Mr from "highlight.js/lib/languages/sql";
|
|
28
|
+
import Tr from "highlight.js/lib/languages/typescript";
|
|
29
|
+
import Dr from "highlight.js/lib/languages/xml";
|
|
30
|
+
import Pr from "highlight.js/lib/languages/yaml";
|
|
31
|
+
import { createPortal as ft } from "react-dom";
|
|
32
|
+
function Wr(e) {
|
|
33
|
+
const t = new MutationObserver(e);
|
|
34
|
+
return t.observe(document.documentElement, { attributes: !0, attributeFilter: ["class"] }), () => t.disconnect();
|
|
35
|
+
}
|
|
36
|
+
function $e() {
|
|
37
|
+
return qt(
|
|
38
|
+
Wr,
|
|
39
|
+
() => document.documentElement.classList.contains("dark") ? "dark" : "light",
|
|
40
|
+
() => "light"
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
function k(...e) {
|
|
44
|
+
return Xt(Kt(e));
|
|
45
|
+
}
|
|
46
|
+
const Br = kr(
|
|
47
|
+
"inline-flex shrink-0 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0",
|
|
48
|
+
{
|
|
49
|
+
variants: {
|
|
50
|
+
variant: {
|
|
51
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
52
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
53
|
+
outline: "border border-input bg-transparent hover:bg-accent",
|
|
54
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
55
|
+
destructive: "bg-destructive text-white hover:bg-destructive/90",
|
|
56
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
57
|
+
},
|
|
58
|
+
size: {
|
|
59
|
+
default: "h-9 px-4 py-2",
|
|
60
|
+
sm: "h-8 px-3 text-xs",
|
|
61
|
+
lg: "h-10 px-6",
|
|
62
|
+
icon: "size-9"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
defaultVariants: { variant: "default", size: "default" }
|
|
66
|
+
}
|
|
67
|
+
), re = Ie.forwardRef(
|
|
68
|
+
({ className: e, variant: t, size: s, asChild: i = !1, ...a }, r) => /* @__PURE__ */ n(
|
|
69
|
+
i ? Nr : "button",
|
|
70
|
+
{
|
|
71
|
+
ref: r,
|
|
72
|
+
className: k(Br({ variant: t, size: s, className: e })),
|
|
73
|
+
...a
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
);
|
|
77
|
+
re.displayName = "Button";
|
|
78
|
+
const pt = 240, Hr = 48, Fr = (e) => e > pt + Hr;
|
|
79
|
+
function qr({
|
|
80
|
+
children: e,
|
|
81
|
+
className: t
|
|
82
|
+
}) {
|
|
83
|
+
const [s, i] = O(!1), [a, r] = O(!1), o = W(null), l = Ut();
|
|
84
|
+
ze(() => {
|
|
85
|
+
const f = o.current;
|
|
86
|
+
if (!f) return;
|
|
87
|
+
const p = () => r(Fr(f.offsetHeight));
|
|
88
|
+
p();
|
|
89
|
+
const u = new ResizeObserver(p);
|
|
90
|
+
return u.observe(f), () => u.disconnect();
|
|
91
|
+
}, []);
|
|
92
|
+
const c = a && !s;
|
|
93
|
+
return /* @__PURE__ */ d("div", { className: t, children: [
|
|
94
|
+
/* @__PURE__ */ n(
|
|
95
|
+
"div",
|
|
96
|
+
{
|
|
97
|
+
id: l,
|
|
98
|
+
style: c ? { maxHeight: pt } : void 0,
|
|
99
|
+
className: k(
|
|
100
|
+
c && "overflow-hidden [mask-image:linear-gradient(to_bottom,black_70%,transparent)]"
|
|
101
|
+
),
|
|
102
|
+
children: /* @__PURE__ */ n("div", { ref: o, children: e })
|
|
103
|
+
}
|
|
104
|
+
),
|
|
105
|
+
a && /* @__PURE__ */ d(
|
|
106
|
+
"button",
|
|
107
|
+
{
|
|
108
|
+
type: "button",
|
|
109
|
+
"aria-expanded": s,
|
|
110
|
+
"aria-controls": l,
|
|
111
|
+
onClick: () => i((f) => !f),
|
|
112
|
+
className: "mt-1 flex cursor-pointer items-center gap-1 rounded-sm text-xs text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3.5",
|
|
113
|
+
children: [
|
|
114
|
+
s ? "Show less" : "Show more",
|
|
115
|
+
/* @__PURE__ */ n(ct, { className: k("transition-transform", s && "rotate-180") })
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
)
|
|
119
|
+
] });
|
|
120
|
+
}
|
|
121
|
+
async function Ur(e) {
|
|
122
|
+
var s;
|
|
123
|
+
if ((s = navigator.clipboard) != null && s.writeText)
|
|
124
|
+
try {
|
|
125
|
+
await navigator.clipboard.writeText(e);
|
|
126
|
+
return;
|
|
127
|
+
} catch {
|
|
128
|
+
}
|
|
129
|
+
const t = document.createElement("textarea");
|
|
130
|
+
t.value = e, t.setAttribute("readonly", ""), t.style.position = "fixed", t.style.opacity = "0", document.body.append(t), t.select();
|
|
131
|
+
try {
|
|
132
|
+
if (!document.execCommand("copy")) throw new Error("copy was refused");
|
|
133
|
+
} finally {
|
|
134
|
+
t.remove();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const ht = (e) => e.replace(/[\r\n]+$/, "");
|
|
138
|
+
function Fe(e) {
|
|
139
|
+
var i;
|
|
140
|
+
const t = ((i = window.getSelection()) == null ? void 0 : i.toString()) ?? "", s = ht(t);
|
|
141
|
+
!t || s === t || (e.clipboardData.setData("text/plain", s), e.preventDefault());
|
|
142
|
+
}
|
|
143
|
+
const Jr = 1500, qe = "opacity-0 group-hover/msg:opacity-100 [@media(hover:none)]:opacity-100";
|
|
144
|
+
function Le({
|
|
145
|
+
text: e,
|
|
146
|
+
label: t = "Copy",
|
|
147
|
+
className: s
|
|
148
|
+
}) {
|
|
149
|
+
const [i, a] = O("idle"), r = W(void 0);
|
|
150
|
+
T(() => () => clearTimeout(r.current), []);
|
|
151
|
+
const o = async () => {
|
|
152
|
+
try {
|
|
153
|
+
await Ur(ht(e)), a("copied");
|
|
154
|
+
} catch {
|
|
155
|
+
a("failed");
|
|
156
|
+
}
|
|
157
|
+
clearTimeout(r.current), r.current = setTimeout(() => a("idle"), Jr);
|
|
158
|
+
}, l = i === "copied" ? "Copied" : i === "failed" ? "Copy failed" : t;
|
|
159
|
+
return /* @__PURE__ */ d(
|
|
160
|
+
"button",
|
|
161
|
+
{
|
|
162
|
+
type: "button",
|
|
163
|
+
title: l,
|
|
164
|
+
"aria-label": l,
|
|
165
|
+
onClick: () => void o(),
|
|
166
|
+
className: k(
|
|
167
|
+
// `relative` anchors the absolutely positioned sr-only status: without it the status
|
|
168
|
+
// is placed against the page, outside the scrolling panes, and makes the page scroll.
|
|
169
|
+
"relative inline-flex size-6 cursor-pointer select-none items-center justify-center rounded-md text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3.5",
|
|
170
|
+
i === "failed" && "text-danger",
|
|
171
|
+
s
|
|
172
|
+
),
|
|
173
|
+
children: [
|
|
174
|
+
i === "copied" ? /* @__PURE__ */ n(Re, {}) : /* @__PURE__ */ n(Zt, {}),
|
|
175
|
+
/* @__PURE__ */ n("span", { role: "status", className: "sr-only", children: i === "idle" ? "" : l })
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
const gt = lt(null), Kr = () => ot(gt);
|
|
181
|
+
function be({
|
|
182
|
+
label: e,
|
|
183
|
+
side: t,
|
|
184
|
+
className: s,
|
|
185
|
+
children: i
|
|
186
|
+
}) {
|
|
187
|
+
const a = Kr();
|
|
188
|
+
return /* @__PURE__ */ n(ve.Provider, { delayDuration: 300, children: /* @__PURE__ */ d(ve.Root, { children: [
|
|
189
|
+
/* @__PURE__ */ n(ve.Trigger, { asChild: !0, children: i }),
|
|
190
|
+
/* @__PURE__ */ n(ve.Portal, { container: a, children: /* @__PURE__ */ n(
|
|
191
|
+
ve.Content,
|
|
192
|
+
{
|
|
193
|
+
side: t,
|
|
194
|
+
sideOffset: 6,
|
|
195
|
+
className: k(
|
|
196
|
+
"z-50 max-w-sm rounded-md border border-border bg-popover px-3 py-1.5 text-xs whitespace-pre-line text-popover-foreground shadow-md",
|
|
197
|
+
s
|
|
198
|
+
),
|
|
199
|
+
children: e
|
|
200
|
+
}
|
|
201
|
+
) })
|
|
202
|
+
] }) });
|
|
203
|
+
}
|
|
204
|
+
function bt(e) {
|
|
205
|
+
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
206
|
+
}
|
|
207
|
+
function xt(e, t) {
|
|
208
|
+
const s = [];
|
|
209
|
+
let i = 0, a = 0, r = !1, o = !1;
|
|
210
|
+
for (let l = t; l < e.length; l++) {
|
|
211
|
+
const c = e[l];
|
|
212
|
+
if (i > 0) {
|
|
213
|
+
if (r)
|
|
214
|
+
o ? o = !1 : c === "\\" ? o = !0 : c === '"' && (r = !1);
|
|
215
|
+
else if (c === '"') r = !0;
|
|
216
|
+
else if (c === "{") i++;
|
|
217
|
+
else if (c === "}" && --i === 0)
|
|
218
|
+
try {
|
|
219
|
+
const f = JSON.parse(e.slice(a, l + 1));
|
|
220
|
+
if (!bt(f)) return { objects: s, tail: -1, bad: !0 };
|
|
221
|
+
s.push(f);
|
|
222
|
+
} catch {
|
|
223
|
+
return { objects: s, tail: -1, bad: !0 };
|
|
224
|
+
}
|
|
225
|
+
} else if (c === "{")
|
|
226
|
+
i = 1, a = l;
|
|
227
|
+
else {
|
|
228
|
+
if (c === "]")
|
|
229
|
+
break;
|
|
230
|
+
if (c !== "," && !/\s/.test(c))
|
|
231
|
+
return { objects: s, tail: -1, bad: !0 };
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return { objects: s, tail: i > 0 ? a : -1, bad: !1 };
|
|
235
|
+
}
|
|
236
|
+
function Xr(e) {
|
|
237
|
+
var o;
|
|
238
|
+
const t = /"updateComponents"\s*:\s*\{/.exec(e);
|
|
239
|
+
if (!t) return;
|
|
240
|
+
const s = e.slice(t.index + t[0].length), i = /"components"\s*:\s*\[/.exec(s), a = /"surfaceId"\s*:\s*"((?:[^"\\]|\\.)*)"/.exec(s);
|
|
241
|
+
if (!i || !a || a.index > i.index) return;
|
|
242
|
+
const { objects: r } = xt(s, i.index + i[0].length);
|
|
243
|
+
if (r.length !== 0)
|
|
244
|
+
return {
|
|
245
|
+
version: ((o = /"version"\s*:\s*"([^"]*)"/.exec(e)) == null ? void 0 : o[1]) ?? "v0.9",
|
|
246
|
+
updateComponents: { surfaceId: JSON.parse(`"${a[1]}"`), components: r }
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
function Zr(e) {
|
|
250
|
+
const t = e.trim(), { objects: s, tail: i, bad: a } = xt(t, t.startsWith("[") ? 1 : 0);
|
|
251
|
+
if (a) return { messages: s, broken: !0 };
|
|
252
|
+
const r = i >= 0 ? Xr(t.slice(i)) : void 0;
|
|
253
|
+
return { messages: s, partial: r, broken: !1 };
|
|
254
|
+
}
|
|
255
|
+
function Gr(e) {
|
|
256
|
+
const t = [], s = (a) => {
|
|
257
|
+
typeof a == "string" ? t.push(a) : Array.isArray(a) ? a.forEach(s) : bt(a) && (s(a.componentId), s(a.child));
|
|
258
|
+
}, i = ["children", "child", "trigger", "content", "tabs"].filter((a) => a in e);
|
|
259
|
+
return i.forEach((a) => s(e[a])), i.length > 0 ? t : null;
|
|
260
|
+
}
|
|
261
|
+
let Yr;
|
|
262
|
+
const Vr = () => Yr ?? (Yr = Promise.all([
|
|
263
|
+
import("@a2ui/web_core/v0_9"),
|
|
264
|
+
import("@a2ui/web_core/v0_9/basic_catalog"),
|
|
265
|
+
import("@a2ui/react/v0_9"),
|
|
266
|
+
import("@a2ui/react/styles"),
|
|
267
|
+
import("./catalog-BYJPdVB0.js")
|
|
268
|
+
]).then(([e, t, s, i, a]) => (i.injectStyles(), t.injectBasicCatalogStyles(), { core: e, catalog: a.zeneraCatalog, Surface: s.A2uiSurface })));
|
|
269
|
+
class Qr {
|
|
270
|
+
constructor(t) {
|
|
271
|
+
he(this, "processor");
|
|
272
|
+
he(this, "code", "");
|
|
273
|
+
he(this, "fed", 0);
|
|
274
|
+
he(this, "rejected", 0);
|
|
275
|
+
/** per surface, the components waiting for one of their children */
|
|
276
|
+
he(this, "held", /* @__PURE__ */ new Map());
|
|
277
|
+
this.lib = t, this.reset();
|
|
278
|
+
}
|
|
279
|
+
/** `parsed` is parseA2ui(code), which the caller already needs. */
|
|
280
|
+
update(t, { messages: s, partial: i }) {
|
|
281
|
+
for (t.startsWith(this.code) || this.reset(), this.code = t; this.fed < s.length; this.fed++)
|
|
282
|
+
this.rejected += this.send(s[this.fed]).length;
|
|
283
|
+
i && this.send(i);
|
|
284
|
+
const a = Array.from(this.processor.model.surfacesMap.values()), r = a.filter((l) => l.componentsModel.get("root"));
|
|
285
|
+
let o = "building";
|
|
286
|
+
return r.length > 0 ? o = "ready" : this.rejected > 0 ? o = "rejected" : a.length === 0 && this.fed > 0 && (o = "deleted"), { surfaces: r, status: o };
|
|
287
|
+
}
|
|
288
|
+
dispose() {
|
|
289
|
+
this.processor.dispose();
|
|
290
|
+
}
|
|
291
|
+
reset() {
|
|
292
|
+
var t;
|
|
293
|
+
(t = this.processor) == null || t.dispose(), this.processor = new this.lib.core.MessageProcessor(
|
|
294
|
+
[this.lib.catalog],
|
|
295
|
+
() => {
|
|
296
|
+
},
|
|
297
|
+
{ validationConfig: this.lib.core.RELAXED_VALIDATION }
|
|
298
|
+
), this.fed = 0, this.rejected = 0, this.held.clear();
|
|
299
|
+
}
|
|
300
|
+
/** Returns the errors the processor reported for the message. */
|
|
301
|
+
send(t) {
|
|
302
|
+
const s = t.createSurface;
|
|
303
|
+
typeof s == "object" && s !== null && (t = {
|
|
304
|
+
...t,
|
|
305
|
+
createSurface: { ...s, catalogId: this.lib.catalog.id }
|
|
306
|
+
});
|
|
307
|
+
const i = this.withoutEmptyContainers(t);
|
|
308
|
+
return i ? this.processor.processMessagesWithErrors(i) : [];
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Cuts an updateComponents message down to the components that can be shown: leaves, and
|
|
312
|
+
* containers with a child that is already on the surface or comes with them. The rest wait
|
|
313
|
+
* and are tried again with every later message. Returns null when nothing can be shown yet.
|
|
314
|
+
*/
|
|
315
|
+
withoutEmptyContainers(t) {
|
|
316
|
+
const s = t.updateComponents, i = s == null ? void 0 : s.surfaceId, a = i ? this.processor.model.getSurface(i) : void 0;
|
|
317
|
+
if (!i || !a || !Array.isArray(s == null ? void 0 : s.components)) return t;
|
|
318
|
+
let r = this.held.get(i);
|
|
319
|
+
r || this.held.set(i, r = /* @__PURE__ */ new Map());
|
|
320
|
+
for (const c of s.components) r.set(c.id, c);
|
|
321
|
+
const o = [], l = (c) => !!a.componentsModel.get(c) || o.some((f) => f.id === c);
|
|
322
|
+
for (let c = -1; c !== r.size; ) {
|
|
323
|
+
c = r.size;
|
|
324
|
+
for (const [f, p] of r) {
|
|
325
|
+
const u = Gr(p);
|
|
326
|
+
(!u || u.some(l)) && (o.push(p), r.delete(f));
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return o.length > 0 ? { ...t, updateComponents: { ...s, components: o } } : null;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
function Ue({ icon: e, children: t }) {
|
|
333
|
+
return /* @__PURE__ */ d("div", { className: "my-2 flex w-fit items-center gap-2 rounded-lg border border-border bg-muted/50 px-3 py-2 text-xs text-muted-foreground", children: [
|
|
334
|
+
e,
|
|
335
|
+
t
|
|
336
|
+
] });
|
|
337
|
+
}
|
|
338
|
+
function en({ code: e }) {
|
|
339
|
+
const [t, s] = O(null), [i, a] = O(!1), [r, o] = O(null), l = ne(() => Zr(e), [e]), c = W(null);
|
|
340
|
+
if (T(() => {
|
|
341
|
+
let f = !0;
|
|
342
|
+
return Vr().then(
|
|
343
|
+
(p) => f && s(p),
|
|
344
|
+
() => f && a(!0)
|
|
345
|
+
), () => {
|
|
346
|
+
f = !1;
|
|
347
|
+
};
|
|
348
|
+
}, []), T(() => {
|
|
349
|
+
t && (c.current ?? (c.current = new Qr(t)), o(c.current.update(e, l)));
|
|
350
|
+
}, [t, e, l]), T(
|
|
351
|
+
() => () => {
|
|
352
|
+
var f;
|
|
353
|
+
(f = c.current) == null || f.dispose(), c.current = null;
|
|
354
|
+
},
|
|
355
|
+
[]
|
|
356
|
+
), (r == null ? void 0 : r.status) === "ready") {
|
|
357
|
+
const f = t.Surface;
|
|
358
|
+
return /* @__PURE__ */ n("div", { className: "my-2 flex max-w-xl flex-col gap-2", children: r.surfaces.map((p) => /* @__PURE__ */ n("div", { className: "a2ui-theme ", children: /* @__PURE__ */ n(f, { surface: p }) }, p.id)) });
|
|
359
|
+
}
|
|
360
|
+
return l.broken || i || (r == null ? void 0 : r.status) === "rejected" ? /* @__PURE__ */ n(Ue, { icon: /* @__PURE__ */ n(Gt, { className: "size-3.5" }), children: "Not possible to render this interface" }) : (r == null ? void 0 : r.status) === "deleted" ? null : /* @__PURE__ */ n(Ue, { icon: /* @__PURE__ */ n(Yt, { className: "size-3.5 animate-spin" }), children: "Building interface…" });
|
|
361
|
+
}
|
|
362
|
+
B.registerLanguage("bash", Er);
|
|
363
|
+
B.registerLanguage("css", zr);
|
|
364
|
+
B.registerLanguage("dockerfile", Ar);
|
|
365
|
+
B.registerLanguage("diff", Lr);
|
|
366
|
+
B.registerLanguage("ini", Or);
|
|
367
|
+
B.registerLanguage("javascript", jr);
|
|
368
|
+
B.registerLanguage("json", Ir);
|
|
369
|
+
B.registerLanguage("markdown", Rr);
|
|
370
|
+
B.registerLanguage("python", $r);
|
|
371
|
+
B.registerLanguage("sql", Mr);
|
|
372
|
+
B.registerLanguage("typescript", Tr);
|
|
373
|
+
B.registerLanguage("xml", Dr);
|
|
374
|
+
B.registerLanguage("yaml", Pr);
|
|
375
|
+
B.registerAliases(["jsonl", "ndjson"], { languageName: "json" });
|
|
376
|
+
const tn = 5e5, rn = /(^|\/)(docker|container)file(\.[^/]+)?$|\.(docker|container)file$/i;
|
|
377
|
+
function nn(e) {
|
|
378
|
+
if (rn.test(e)) return "dockerfile";
|
|
379
|
+
const t = e.slice(e.lastIndexOf(".") + 1).toLowerCase();
|
|
380
|
+
return B.getLanguage(t) ? t : void 0;
|
|
381
|
+
}
|
|
382
|
+
function sn(e, t) {
|
|
383
|
+
return !t || !B.getLanguage(t) || e.length > tn ? null : B.highlight(e, { language: t, ignoreIllegals: !0 }).value;
|
|
384
|
+
}
|
|
385
|
+
function V({
|
|
386
|
+
code: e,
|
|
387
|
+
lang: t,
|
|
388
|
+
className: s
|
|
389
|
+
}) {
|
|
390
|
+
const i = ne(() => sn(e, t), [e, t]);
|
|
391
|
+
return /* @__PURE__ */ d("div", { className: "group/code relative min-w-0", children: [
|
|
392
|
+
/* @__PURE__ */ n("pre", { className: k("overflow-x-auto font-mono text-xs", s), children: i === null ? /* @__PURE__ */ n("code", { children: e }) : /* @__PURE__ */ n("code", { dangerouslySetInnerHTML: { __html: i } }) }),
|
|
393
|
+
e && /* @__PURE__ */ n(
|
|
394
|
+
Le,
|
|
395
|
+
{
|
|
396
|
+
text: e,
|
|
397
|
+
label: "Copy code",
|
|
398
|
+
className: "absolute top-1.5 right-1.5 bg-surface-code/80 opacity-0 group-hover/code:opacity-100 [@media(hover:none)]:opacity-100"
|
|
399
|
+
}
|
|
400
|
+
)
|
|
401
|
+
] });
|
|
402
|
+
}
|
|
403
|
+
let an, on = 0;
|
|
404
|
+
const ln = () => an ?? (an = import("mermaid").then(({ default: e }) => e));
|
|
405
|
+
function cn({ code: e, natural: t = !1 }) {
|
|
406
|
+
const [s, i] = O(null), [a, r] = O(null), o = $e();
|
|
407
|
+
return T(() => {
|
|
408
|
+
let l = !0;
|
|
409
|
+
return ln().then((c) => (c.initialize({
|
|
410
|
+
startOnLoad: !1,
|
|
411
|
+
theme: o === "dark" ? "dark" : "default",
|
|
412
|
+
securityLevel: "strict",
|
|
413
|
+
suppressErrorRendering: !0,
|
|
414
|
+
flowchart: { useMaxWidth: !t },
|
|
415
|
+
state: { useMaxWidth: !t },
|
|
416
|
+
themeVariables: { fontSize: "14px" }
|
|
417
|
+
}), c.render(`mermaid-${++on}`, e))).then(
|
|
418
|
+
(c) => {
|
|
419
|
+
l && (i(c.svg), r(null));
|
|
420
|
+
},
|
|
421
|
+
(c) => {
|
|
422
|
+
l && (i(null), r(c instanceof Error ? c.message : String(c)));
|
|
423
|
+
}
|
|
424
|
+
), () => {
|
|
425
|
+
l = !1;
|
|
426
|
+
};
|
|
427
|
+
}, [e, o, t]), s === null ? /* @__PURE__ */ d("div", { children: [
|
|
428
|
+
a && /* @__PURE__ */ d("p", { className: "mb-1 text-xs text-danger", children: [
|
|
429
|
+
"Mermaid: ",
|
|
430
|
+
a
|
|
431
|
+
] }),
|
|
432
|
+
/* @__PURE__ */ n(V, { code: e })
|
|
433
|
+
] }) : t ? /* @__PURE__ */ n("div", { className: "overflow-x-auto", children: /* @__PURE__ */ n("div", { className: "mx-auto w-max", dangerouslySetInnerHTML: { __html: s } }) }) : /* @__PURE__ */ n(
|
|
434
|
+
"div",
|
|
435
|
+
{
|
|
436
|
+
className: "flex justify-center overflow-x-auto",
|
|
437
|
+
dangerouslySetInnerHTML: { __html: s }
|
|
438
|
+
}
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
const dn = [
|
|
442
|
+
"p",
|
|
443
|
+
"h1",
|
|
444
|
+
"h2",
|
|
445
|
+
"h3",
|
|
446
|
+
"h4",
|
|
447
|
+
"h5",
|
|
448
|
+
"h6",
|
|
449
|
+
"ul",
|
|
450
|
+
"ol",
|
|
451
|
+
"li",
|
|
452
|
+
"blockquote",
|
|
453
|
+
"table"
|
|
454
|
+
];
|
|
455
|
+
function un(e) {
|
|
456
|
+
return function({ node: s, ...i }) {
|
|
457
|
+
var r;
|
|
458
|
+
return /* @__PURE__ */ n(e, { ...i, "data-line": (r = s == null ? void 0 : s.position) == null ? void 0 : r.start.line });
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
function ce({
|
|
462
|
+
children: e,
|
|
463
|
+
className: t,
|
|
464
|
+
lines: s,
|
|
465
|
+
linkAction: i
|
|
466
|
+
}) {
|
|
467
|
+
const a = ne(
|
|
468
|
+
() => ({
|
|
469
|
+
...s ? Object.fromEntries(dn.map((r) => [r, un(r)])) : void 0,
|
|
470
|
+
a: ({ href: r, children: o }) => {
|
|
471
|
+
if (r && /^https?:\/\//.test(r))
|
|
472
|
+
return /* @__PURE__ */ n("a", { href: r, target: "_blank", rel: "noreferrer", children: o });
|
|
473
|
+
const l = r ? i == null ? void 0 : i(r) : void 0;
|
|
474
|
+
return l ? /* @__PURE__ */ n(
|
|
475
|
+
"button",
|
|
476
|
+
{
|
|
477
|
+
type: "button",
|
|
478
|
+
className: "cursor-pointer text-primary underline-offset-2 hover:underline",
|
|
479
|
+
onClick: l,
|
|
480
|
+
children: o
|
|
481
|
+
}
|
|
482
|
+
) : /* @__PURE__ */ n("span", { className: "text-primary", children: o });
|
|
483
|
+
},
|
|
484
|
+
pre: ({ node: r, children: o }) => {
|
|
485
|
+
var m, h;
|
|
486
|
+
const l = r == null ? void 0 : r.children[0];
|
|
487
|
+
if ((l == null ? void 0 : l.type) !== "element" || l.tagName !== "code")
|
|
488
|
+
return /* @__PURE__ */ n("pre", { children: o });
|
|
489
|
+
const c = l.properties.className, f = (m = (Array.isArray(c) ? c.map(String) : []).find((x) => x.startsWith("language-"))) == null ? void 0 : m.slice(9), p = l.children.map((x) => x.type === "text" ? x.value : "").join("").replace(/\n$/, ""), u = f === "mermaid" ? /* @__PURE__ */ n(cn, { code: p }) : f === "a2ui" ? /* @__PURE__ */ n(en, { code: p }) : /* @__PURE__ */ n(V, { code: p, lang: f });
|
|
490
|
+
return s ? /* @__PURE__ */ n("div", { "data-line": (h = r == null ? void 0 : r.position) == null ? void 0 : h.start.line, children: u }) : u;
|
|
491
|
+
}
|
|
492
|
+
}),
|
|
493
|
+
[s, i]
|
|
494
|
+
);
|
|
495
|
+
return /* @__PURE__ */ n("div", { className: k("markdown", t), children: /* @__PURE__ */ n(
|
|
496
|
+
_r,
|
|
497
|
+
{
|
|
498
|
+
remarkPlugins: [Cr],
|
|
499
|
+
rehypePlugins: [Sr],
|
|
500
|
+
components: a,
|
|
501
|
+
children: e
|
|
502
|
+
}
|
|
503
|
+
) });
|
|
504
|
+
}
|
|
505
|
+
const yt = Ie.forwardRef(({ className: e, ...t }, s) => /* @__PURE__ */ n(
|
|
506
|
+
"textarea",
|
|
507
|
+
{
|
|
508
|
+
ref: s,
|
|
509
|
+
className: k(
|
|
510
|
+
"w-full rounded-md border border-input bg-surface-input px-3 py-2 text-sm outline-none placeholder:text-muted-foreground focus-visible:border-ring disabled:opacity-50",
|
|
511
|
+
e
|
|
512
|
+
),
|
|
513
|
+
...t
|
|
514
|
+
}
|
|
515
|
+
));
|
|
516
|
+
yt.displayName = "Textarea";
|
|
517
|
+
function mn() {
|
|
518
|
+
var t;
|
|
519
|
+
let e = document.activeElement;
|
|
520
|
+
for (; (t = e == null ? void 0 : e.shadowRoot) != null && t.activeElement; ) e = e.shadowRoot.activeElement;
|
|
521
|
+
return e;
|
|
522
|
+
}
|
|
523
|
+
function fn(e) {
|
|
524
|
+
var i;
|
|
525
|
+
if ((i = window.matchMedia) != null && i.call(window, "(pointer: coarse)").matches) return !1;
|
|
526
|
+
const t = mn();
|
|
527
|
+
return !t || t === document.body ? !0 : t.closest('[role="dialog"], [role="menu"], [role="listbox"]') || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName) || t.isContentEditable === !0 ? !1 : e === void 0 || !!(e != null && e.contains(t));
|
|
528
|
+
}
|
|
529
|
+
function pn(e, t) {
|
|
530
|
+
!e || e.disabled || !fn(t) || (e.focus({ preventScroll: !0 }), e.setSelectionRange(e.value.length, e.value.length));
|
|
531
|
+
}
|
|
532
|
+
const hn = 30, gn = 1e4, Zs = (e, t, s) => `zenera.history.${e}.${t}.${s}`;
|
|
533
|
+
function vt(e) {
|
|
534
|
+
try {
|
|
535
|
+
const t = JSON.parse(localStorage.getItem(e) ?? "[]");
|
|
536
|
+
return Array.isArray(t) ? t.filter((s) => typeof s == "string") : [];
|
|
537
|
+
} catch {
|
|
538
|
+
return [];
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
function bn(e, t) {
|
|
542
|
+
const s = t.trim();
|
|
543
|
+
if (!(!s || s.length > gn))
|
|
544
|
+
try {
|
|
545
|
+
const i = [...vt(e).filter((a) => a !== s), s];
|
|
546
|
+
localStorage.setItem(e, JSON.stringify(i.slice(-hn)));
|
|
547
|
+
} catch {
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
function xn(e) {
|
|
551
|
+
const t = /* @__PURE__ */ new Set(), s = [];
|
|
552
|
+
for (let i = e.length - 1; i >= 0; i--)
|
|
553
|
+
!e[i].trim() || t.has(e[i]) || (t.add(e[i]), s.unshift(e[i]));
|
|
554
|
+
return s;
|
|
555
|
+
}
|
|
556
|
+
function yn(e, t, s, i) {
|
|
557
|
+
if (s === "up") {
|
|
558
|
+
if (!e.length) return null;
|
|
559
|
+
const r = t ? t.draft : i, o = t ? Math.max(0, t.index - 1) : e.length - 1;
|
|
560
|
+
return { value: e[o], browsing: { index: o, draft: r, shown: e[o] } };
|
|
561
|
+
}
|
|
562
|
+
if (!t) return null;
|
|
563
|
+
const a = t.index + 1;
|
|
564
|
+
return a >= e.length ? { value: t.draft, browsing: null } : {
|
|
565
|
+
value: e[a],
|
|
566
|
+
browsing: { index: a, draft: t.draft, shown: e[a] }
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
const vn = (e, t, s) => t === s && !e.slice(0, t).includes(`
|
|
570
|
+
`);
|
|
571
|
+
function wn(e) {
|
|
572
|
+
const t = W(null), s = W(e);
|
|
573
|
+
T(() => {
|
|
574
|
+
s.current = e;
|
|
575
|
+
});
|
|
576
|
+
const i = le(() => {
|
|
577
|
+
t.current = null;
|
|
578
|
+
}, []);
|
|
579
|
+
return { onKeyDown: le(
|
|
580
|
+
(r, o, l) => {
|
|
581
|
+
if (r.key !== "ArrowUp" && r.key !== "ArrowDown" || r.shiftKey || r.altKey || r.ctrlKey || r.metaKey || r.nativeEvent.isComposing)
|
|
582
|
+
return;
|
|
583
|
+
const c = r.currentTarget, f = t.current !== null && t.current.shown === o;
|
|
584
|
+
f || (t.current = null);
|
|
585
|
+
const p = r.key === "ArrowUp" ? "up" : "down";
|
|
586
|
+
if (p === "up" && !f && !vn(o, c.selectionStart, c.selectionEnd))
|
|
587
|
+
return;
|
|
588
|
+
const u = yn(
|
|
589
|
+
xn(s.current()),
|
|
590
|
+
t.current,
|
|
591
|
+
p,
|
|
592
|
+
o
|
|
593
|
+
);
|
|
594
|
+
u && (r.preventDefault(), t.current = u.browsing, l(u.value), requestAnimationFrame(
|
|
595
|
+
() => c.setSelectionRange(u.value.length, u.value.length)
|
|
596
|
+
));
|
|
597
|
+
},
|
|
598
|
+
[]
|
|
599
|
+
), reset: i };
|
|
600
|
+
}
|
|
601
|
+
const Nn = "zenera.draft.chat", Gs = (e, t, s, i) => `${Nn}.${e}.${t}.${s}.${i ?? "new"}`;
|
|
602
|
+
function kn(e) {
|
|
603
|
+
try {
|
|
604
|
+
return localStorage.getItem(e) ?? "";
|
|
605
|
+
} catch {
|
|
606
|
+
return "";
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
function Je(e, t) {
|
|
610
|
+
try {
|
|
611
|
+
t ? localStorage.setItem(e, t) : localStorage.removeItem(e);
|
|
612
|
+
} catch {
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
const wt = lt(null);
|
|
616
|
+
function _n(e, t) {
|
|
617
|
+
return e.ended ? e.ended : !t || t.status === "pending" ? "waiting" : t.status === "superseded" || t.resumeState === "stale" ? "superseded" : t.resumeState === "failed" ? "failed" : t.resumeState === "queued" ? "resuming" : t.status;
|
|
618
|
+
}
|
|
619
|
+
function Ke({
|
|
620
|
+
icon: e,
|
|
621
|
+
title: t,
|
|
622
|
+
text: s,
|
|
623
|
+
tone: i,
|
|
624
|
+
children: a
|
|
625
|
+
}) {
|
|
626
|
+
return /* @__PURE__ */ d(
|
|
627
|
+
"div",
|
|
628
|
+
{
|
|
629
|
+
role: "group",
|
|
630
|
+
"aria-label": "The agent is waiting for you",
|
|
631
|
+
className: k(
|
|
632
|
+
"my-1 flex flex-col gap-2 rounded-lg border px-3 py-2.5 text-sm sm:flex-row sm:items-center",
|
|
633
|
+
i === "active" && "border-primary/40 bg-primary/5",
|
|
634
|
+
i === "done" && "border-border bg-secondary/40",
|
|
635
|
+
i === "muted" && "border-border bg-transparent text-muted-foreground",
|
|
636
|
+
i === "danger" && "border-danger/40 text-danger"
|
|
637
|
+
),
|
|
638
|
+
children: [
|
|
639
|
+
/* @__PURE__ */ d("div", { className: "flex min-w-0 flex-1 items-center gap-3", children: [
|
|
640
|
+
e,
|
|
641
|
+
/* @__PURE__ */ d("div", { className: "min-w-0", children: [
|
|
642
|
+
/* @__PURE__ */ n("div", { className: "font-medium", children: t }),
|
|
643
|
+
s && /* @__PURE__ */ n("div", { className: "text-xs text-muted-foreground", children: s })
|
|
644
|
+
] })
|
|
645
|
+
] }),
|
|
646
|
+
a && /* @__PURE__ */ n("div", { className: "flex shrink-0 items-center gap-2", children: a })
|
|
647
|
+
]
|
|
648
|
+
}
|
|
649
|
+
);
|
|
650
|
+
}
|
|
651
|
+
function Sn({ interrupt: e, info: t, actions: s }) {
|
|
652
|
+
const i = _n(e, t);
|
|
653
|
+
return i !== "waiting" ? /* @__PURE__ */ n(
|
|
654
|
+
Ke,
|
|
655
|
+
{
|
|
656
|
+
tone: "muted",
|
|
657
|
+
icon: /* @__PURE__ */ n(Re, { className: "size-4" }),
|
|
658
|
+
title: i === "cancelled" || i === "superseded" ? "Skipped" : "Done - continuing"
|
|
659
|
+
}
|
|
660
|
+
) : /* @__PURE__ */ n(
|
|
661
|
+
Ke,
|
|
662
|
+
{
|
|
663
|
+
tone: "active",
|
|
664
|
+
icon: /* @__PURE__ */ n(Vt, { className: "size-4 text-primary" }),
|
|
665
|
+
title: e.message ?? "The agent is waiting for you",
|
|
666
|
+
children: t && /* @__PURE__ */ n(
|
|
667
|
+
re,
|
|
668
|
+
{
|
|
669
|
+
type: "button",
|
|
670
|
+
size: "sm",
|
|
671
|
+
variant: "ghost",
|
|
672
|
+
onClick: () => void s.cancel(e.id),
|
|
673
|
+
children: "Skip"
|
|
674
|
+
}
|
|
675
|
+
)
|
|
676
|
+
}
|
|
677
|
+
);
|
|
678
|
+
}
|
|
679
|
+
function Cn({ interrupt: e }) {
|
|
680
|
+
var a, r;
|
|
681
|
+
const t = ot(wt);
|
|
682
|
+
if (!t) return null;
|
|
683
|
+
const s = typeof ((a = e.metadata) == null ? void 0 : a.kind) == "string" ? e.metadata.kind : e.reason, i = ((r = t.cards) == null ? void 0 : r[s]) ?? Sn;
|
|
684
|
+
return /* @__PURE__ */ n(i, { interrupt: e, info: t.info[e.id], actions: t });
|
|
685
|
+
}
|
|
686
|
+
const Xe = {
|
|
687
|
+
stdout: "Output",
|
|
688
|
+
stderr: "Standard error",
|
|
689
|
+
cwd: "Working directory",
|
|
690
|
+
ids: "Memory IDs",
|
|
691
|
+
job_id: "Job ID",
|
|
692
|
+
url: "URL",
|
|
693
|
+
urls: "URLs",
|
|
694
|
+
duration_ms: "Duration (ms)",
|
|
695
|
+
start_line: "Start line",
|
|
696
|
+
end_line: "End line"
|
|
697
|
+
};
|
|
698
|
+
function Nt(e) {
|
|
699
|
+
return Object.hasOwn(Xe, e) ? Xe[e] : e.replace(/_/g, " ").replace(/^./, (t) => t.toUpperCase());
|
|
700
|
+
}
|
|
701
|
+
function xe({ url: e, children: t }) {
|
|
702
|
+
return /^https?:\/\//i.test(e) ? /* @__PURE__ */ n("a", { className: "break-all text-primary underline", href: e, target: "_blank", rel: "noreferrer", children: t ?? e }) : /* @__PURE__ */ n("span", { className: "break-all", children: t ?? e });
|
|
703
|
+
}
|
|
704
|
+
function kt({ text: e, path: t }) {
|
|
705
|
+
return e === "" ? /* @__PURE__ */ n("span", { className: "text-muted-foreground", children: "(empty)" }) : t && /\.(md|markdown)$/i.test(t) ? /* @__PURE__ */ n(ce, { className: "text-xs [overflow-wrap:anywhere]", children: e }) : /* @__PURE__ */ n(V, { code: e, lang: t ? nn(t) : void 0 });
|
|
706
|
+
}
|
|
707
|
+
function P({
|
|
708
|
+
value: e,
|
|
709
|
+
field: t = "",
|
|
710
|
+
depth: s = 0
|
|
711
|
+
}) {
|
|
712
|
+
if (typeof e == "string")
|
|
713
|
+
return t === "url" || t === "urls" ? /* @__PURE__ */ n(xe, { url: e }) : ["command", "stdout", "stderr", "content", "patch", "output"].includes(t) ? /* @__PURE__ */ n(
|
|
714
|
+
V,
|
|
715
|
+
{
|
|
716
|
+
className: k(t === "stderr" && "text-danger"),
|
|
717
|
+
code: e || "(empty)",
|
|
718
|
+
lang: t === "patch" ? "diff" : t === "command" ? "bash" : void 0
|
|
719
|
+
}
|
|
720
|
+
) : /* @__PURE__ */ n("div", { className: "whitespace-pre-wrap break-words [overflow-wrap:anywhere]", children: e || "(empty)" });
|
|
721
|
+
if (e === null || typeof e != "object")
|
|
722
|
+
return /* @__PURE__ */ n("span", { className: "font-mono", children: String(e) });
|
|
723
|
+
if (s >= 3) return /* @__PURE__ */ n(V, { code: JSON.stringify(e, null, 2), lang: "json" });
|
|
724
|
+
if (Array.isArray(e))
|
|
725
|
+
return e.length ? /* @__PURE__ */ n("div", { className: "space-y-2", children: e.map((a, r) => /* @__PURE__ */ n(P, { value: a, field: t, depth: s + 1 }, r)) }) : /* @__PURE__ */ n("span", { className: "text-muted-foreground", children: "None" });
|
|
726
|
+
const i = Object.entries(e);
|
|
727
|
+
return i.length ? /* @__PURE__ */ n("dl", { className: "grid min-w-0 grid-cols-[minmax(0,6rem)_minmax(0,1fr)] items-start gap-x-3 gap-y-2", children: i.map(([a, r]) => /* @__PURE__ */ d(Jt, { children: [
|
|
728
|
+
/* @__PURE__ */ n(
|
|
729
|
+
"dt",
|
|
730
|
+
{
|
|
731
|
+
className: k(
|
|
732
|
+
"break-words text-[11px] text-muted-foreground",
|
|
733
|
+
(a === "error" || a === "failed") && "text-danger"
|
|
734
|
+
),
|
|
735
|
+
children: Nt(a)
|
|
736
|
+
}
|
|
737
|
+
),
|
|
738
|
+
/* @__PURE__ */ n("dd", { className: "min-w-0", children: /* @__PURE__ */ n(P, { value: r, field: a, depth: s + 1 }) })
|
|
739
|
+
] }, a)) }) : /* @__PURE__ */ n("span", { className: "text-muted-foreground", children: "No fields" });
|
|
740
|
+
}
|
|
741
|
+
function Ne({ value: e }) {
|
|
742
|
+
return /* @__PURE__ */ n("dl", { className: "flex min-w-0 flex-wrap gap-x-4 gap-y-1 text-[11px] text-muted-foreground", children: Object.entries(e).map(([t, s]) => /* @__PURE__ */ d("div", { className: "flex min-w-0 max-w-full items-baseline gap-1", children: [
|
|
743
|
+
/* @__PURE__ */ d("dt", { className: "shrink-0", children: [
|
|
744
|
+
Nt(t),
|
|
745
|
+
":"
|
|
746
|
+
] }),
|
|
747
|
+
/* @__PURE__ */ n("dd", { className: "min-w-0 break-all", children: /* @__PURE__ */ n(P, { value: s }) })
|
|
748
|
+
] }, t)) });
|
|
749
|
+
}
|
|
750
|
+
function G({
|
|
751
|
+
value: e,
|
|
752
|
+
omit: t,
|
|
753
|
+
renderValue: s = (i) => /* @__PURE__ */ n(P, { value: i })
|
|
754
|
+
}) {
|
|
755
|
+
const i = Object.fromEntries(Object.entries(e).filter(([a]) => !t.includes(a)));
|
|
756
|
+
return Object.keys(i).length ? /* @__PURE__ */ d("details", { className: "mt-2 text-muted-foreground", children: [
|
|
757
|
+
/* @__PURE__ */ n("summary", { className: "w-fit cursor-pointer rounded-sm text-[11px] outline-none hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground", children: "Details" }),
|
|
758
|
+
/* @__PURE__ */ n("div", { className: "mt-2", children: s(i) })
|
|
759
|
+
] }) : null;
|
|
760
|
+
}
|
|
761
|
+
function I(e) {
|
|
762
|
+
return e !== null && typeof e == "object" && !Array.isArray(e) ? Object.fromEntries(Object.entries(e)) : void 0;
|
|
763
|
+
}
|
|
764
|
+
function ke(e) {
|
|
765
|
+
try {
|
|
766
|
+
return { value: JSON.parse(e) };
|
|
767
|
+
} catch (t) {
|
|
768
|
+
if (!(t instanceof SyntaxError)) throw t;
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
function En(e) {
|
|
773
|
+
let t = "", s = 0, i = !1, a = !1;
|
|
774
|
+
const r = () => {
|
|
775
|
+
t = t.trimEnd() + `
|
|
776
|
+
` + " ".repeat(s);
|
|
777
|
+
};
|
|
778
|
+
for (const o of e) {
|
|
779
|
+
if (i) {
|
|
780
|
+
t += o, a ? a = !1 : o === "\\" ? a = !0 : o === '"' && (i = !1);
|
|
781
|
+
continue;
|
|
782
|
+
}
|
|
783
|
+
o === '"' ? (i = !0, t += o) : o === "{" || o === "[" ? (t += o, s++, r()) : o === "}" || o === "]" ? (s = Math.max(0, s - 1), r(), t += o) : o === "," ? (t += o, r()) : o === ":" ? t += ": " : /\s/.test(o) ? t && !/\s$/.test(t) && (t += " ") : t += o;
|
|
784
|
+
}
|
|
785
|
+
return t;
|
|
786
|
+
}
|
|
787
|
+
function zn(e) {
|
|
788
|
+
var i;
|
|
789
|
+
let t = 1;
|
|
790
|
+
for (; t < e.length; ) {
|
|
791
|
+
const a = e[t];
|
|
792
|
+
if (a === '"' || a.charCodeAt(0) < 32) break;
|
|
793
|
+
if (a === "\\") {
|
|
794
|
+
const r = e[t + 1];
|
|
795
|
+
if (!r) break;
|
|
796
|
+
if (r === "u") {
|
|
797
|
+
if (!/^[\da-f]{4}$/i.test(e.slice(t + 2, t + 6))) break;
|
|
798
|
+
t += 6;
|
|
799
|
+
continue;
|
|
800
|
+
}
|
|
801
|
+
if (!'"\\/bfnrt'.includes(r)) break;
|
|
802
|
+
t += 2;
|
|
803
|
+
} else
|
|
804
|
+
t++;
|
|
805
|
+
}
|
|
806
|
+
const s = (i = ke(e.slice(0, t) + '"')) == null ? void 0 : i.value;
|
|
807
|
+
return typeof s == "string" ? s : void 0;
|
|
808
|
+
}
|
|
809
|
+
function An(e) {
|
|
810
|
+
var c, f, p;
|
|
811
|
+
if (!e.startsWith("{")) return;
|
|
812
|
+
const t = [];
|
|
813
|
+
let s = 1, i = 1, a = !1, r = !1;
|
|
814
|
+
for (let u = 1; u < e.length; u++) {
|
|
815
|
+
const m = e[u];
|
|
816
|
+
if (a)
|
|
817
|
+
r ? r = !1 : m === "\\" ? r = !0 : m === '"' && (a = !1);
|
|
818
|
+
else if (m === '"')
|
|
819
|
+
a = !0;
|
|
820
|
+
else if (m === "{" || m === "[")
|
|
821
|
+
i++;
|
|
822
|
+
else if (m === "}" || m === "]")
|
|
823
|
+
i--;
|
|
824
|
+
else if (m === "," && i === 1) {
|
|
825
|
+
const h = I((c = ke("{" + e.slice(s, u) + "}")) == null ? void 0 : c.value);
|
|
826
|
+
if (!h) return t.length ? Object.fromEntries(t) : void 0;
|
|
827
|
+
t.push(...Object.entries(h)), s = u + 1;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
const o = e.slice(s), l = I((f = ke("{" + o + "}")) == null ? void 0 : f.value);
|
|
831
|
+
if (l && /(?:true|false|null|["}\]])\s*$/.test(o))
|
|
832
|
+
t.push(...Object.entries(l));
|
|
833
|
+
else {
|
|
834
|
+
const u = /^\s*("(?:[^"\\]|\\.)*")\s*:\s*(".*)$/s.exec(o);
|
|
835
|
+
if (u) {
|
|
836
|
+
const m = (p = ke(u[1])) == null ? void 0 : p.value, h = zn(u[2]);
|
|
837
|
+
typeof m == "string" && h !== void 0 && t.push([m, h]);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
return t.length ? Object.fromEntries(t) : void 0;
|
|
841
|
+
}
|
|
842
|
+
function Ze(e) {
|
|
843
|
+
const t = /\n\u2026 (\d+) more characters$/.exec(e), s = (t ? e.slice(0, t.index) : e).trimStart(), i = ke(s), a = t ? Number(t[1]) : void 0;
|
|
844
|
+
if (i)
|
|
845
|
+
return {
|
|
846
|
+
value: i.value,
|
|
847
|
+
raw: JSON.stringify(i.value, null, 2) + (t ? t[0] : ""),
|
|
848
|
+
incomplete: !1,
|
|
849
|
+
omitted: a
|
|
850
|
+
};
|
|
851
|
+
const r = /^[{["]/.test(s);
|
|
852
|
+
return {
|
|
853
|
+
value: r ? An(s) : void 0,
|
|
854
|
+
raw: r ? En(s) + (t ? t[0] : "") : e,
|
|
855
|
+
incomplete: r,
|
|
856
|
+
omitted: a
|
|
857
|
+
};
|
|
858
|
+
}
|
|
859
|
+
const Ge = {
|
|
860
|
+
memory_search: { title: "Memory search", family: "memory" },
|
|
861
|
+
memory_grep: { title: "Search memory text", family: "memory" },
|
|
862
|
+
memory_load: { title: "Load memories", family: "memory" },
|
|
863
|
+
memory_commit: { title: "Remember", family: "memory" },
|
|
864
|
+
memory_forget: { title: "Forget memories", family: "memory" },
|
|
865
|
+
read_file: { title: "Read file", family: "file" },
|
|
866
|
+
list_dir: { title: "List directory", family: "file" },
|
|
867
|
+
find_files: { title: "Find files", family: "file" },
|
|
868
|
+
write_file: { title: "Write file", family: "file" },
|
|
869
|
+
apply_patch: { title: "Apply patch", family: "file" },
|
|
870
|
+
move_file: { title: "Move file", family: "file" },
|
|
871
|
+
copy_file: { title: "Copy file", family: "file" },
|
|
872
|
+
delete_file: { title: "Delete file", family: "file" },
|
|
873
|
+
run_command: { title: "Run command", family: "command" },
|
|
874
|
+
run_command_background: { title: "Start command", family: "command" },
|
|
875
|
+
read_command_output: { title: "Read command output", family: "command" },
|
|
876
|
+
stop_command: { title: "Stop command", family: "command" },
|
|
877
|
+
web_search: { title: "Web search", family: "web" },
|
|
878
|
+
web_answer: { title: "Web answer", family: "web" },
|
|
879
|
+
web_read: { title: "Read web pages", family: "web" },
|
|
880
|
+
fork: { title: "Parallel agents", family: "agent" },
|
|
881
|
+
compact: { title: "Summarize context", family: "agent" },
|
|
882
|
+
mcp_servers: { title: "Connected services", family: "mcp" },
|
|
883
|
+
mcp_tools: { title: "List service tools", family: "mcp" },
|
|
884
|
+
mcp_describe: { title: "Read tool", family: "mcp" },
|
|
885
|
+
mcp_call: { title: "Service call", family: "mcp" }
|
|
886
|
+
};
|
|
887
|
+
function oe(e) {
|
|
888
|
+
return e.replace(/[_-]+/g, " ").trim();
|
|
889
|
+
}
|
|
890
|
+
function Ln(e) {
|
|
891
|
+
return Object.values(I(e) ?? {}).filter(
|
|
892
|
+
(t) => ["string", "number", "boolean"].includes(typeof t) && String(t).length <= 80
|
|
893
|
+
).slice(0, 3).map(String).join(" · ");
|
|
894
|
+
}
|
|
895
|
+
function ie(e, t) {
|
|
896
|
+
const s = t === "memory" ? "memories" : `${t}s`;
|
|
897
|
+
return Array.isArray(e) ? `${e.length} ${e.length === 1 ? t : s}` : void 0;
|
|
898
|
+
}
|
|
899
|
+
function R(e) {
|
|
900
|
+
return typeof e == "string" ? e : "";
|
|
901
|
+
}
|
|
902
|
+
function On(e, t, s) {
|
|
903
|
+
var f, p;
|
|
904
|
+
const i = e.startsWith("transfer_to_") ? e.slice(12) : "", a = Object.hasOwn(Ge, e) ? Ge[e] : void 0, r = I(t.value) ?? {}, o = i ? "Transfer to agent" : e === "mcp_call" && R(r.tool) ? R(r.tool) : (a == null ? void 0 : a.title) ?? e, l = i ? "agent" : (a == null ? void 0 : a.family) ?? "other";
|
|
905
|
+
let c = "";
|
|
906
|
+
switch (e) {
|
|
907
|
+
case "memory_search":
|
|
908
|
+
case "web_search":
|
|
909
|
+
case "web_answer":
|
|
910
|
+
c = R(r.query);
|
|
911
|
+
break;
|
|
912
|
+
case "memory_grep":
|
|
913
|
+
c = R(r.pattern);
|
|
914
|
+
break;
|
|
915
|
+
case "memory_load":
|
|
916
|
+
case "memory_forget":
|
|
917
|
+
c = [ie(r.ids, "memory"), R(r.reason)].filter(Boolean).join(" - ");
|
|
918
|
+
break;
|
|
919
|
+
case "memory_commit":
|
|
920
|
+
c = [ie(r.nodes, "node"), ie(r.edges, "link")].filter(Boolean).join(" - ");
|
|
921
|
+
break;
|
|
922
|
+
case "run_command":
|
|
923
|
+
case "run_command_background":
|
|
924
|
+
c = R(r.command);
|
|
925
|
+
break;
|
|
926
|
+
case "read_command_output":
|
|
927
|
+
case "stop_command":
|
|
928
|
+
c = R(r.job_id), typeof r.start_line == "number" && (c += ` from line ${r.start_line}`);
|
|
929
|
+
break;
|
|
930
|
+
case "read_file":
|
|
931
|
+
c = R(r.path), typeof r.start_line == "number" ? (c += `:${r.start_line}`, typeof r.end_line == "number" && (c += `-${r.end_line}`)) : typeof r.end_line == "number" && (c += `:1-${r.end_line}`);
|
|
932
|
+
break;
|
|
933
|
+
case "write_file":
|
|
934
|
+
case "delete_file":
|
|
935
|
+
c = R(r.path);
|
|
936
|
+
break;
|
|
937
|
+
case "list_dir":
|
|
938
|
+
c = R(r.path) || (t.incomplete ? "" : "/");
|
|
939
|
+
break;
|
|
940
|
+
case "find_files":
|
|
941
|
+
c = [R(r.pattern), R(r.path)].filter(Boolean).join(" in ");
|
|
942
|
+
break;
|
|
943
|
+
case "move_file":
|
|
944
|
+
case "copy_file":
|
|
945
|
+
c = [R(r.from), R(r.to)].filter(Boolean).join(" -> ");
|
|
946
|
+
break;
|
|
947
|
+
case "apply_patch": {
|
|
948
|
+
const u = [
|
|
949
|
+
...R(r.patch).matchAll(/^\*\*\* (?:Update|Add|Delete) File: (.+)$/gm)
|
|
950
|
+
].map((m) => m[1]);
|
|
951
|
+
c = u.length ? `${u[0]}${u.length > 1 ? ` +${ie(u.slice(1), "file")}` : ""}` : "";
|
|
952
|
+
break;
|
|
953
|
+
}
|
|
954
|
+
case "web_read": {
|
|
955
|
+
const u = Array.isArray(r.urls) ? r.urls : [];
|
|
956
|
+
c = R(u[0]), u.length > 1 && (c += ` +${u.length - 1} URLs`);
|
|
957
|
+
break;
|
|
958
|
+
}
|
|
959
|
+
case "mcp_servers": {
|
|
960
|
+
const u = (f = I(s == null ? void 0 : s.value)) == null ? void 0 : f.servers;
|
|
961
|
+
c = ie(u, "service") ?? "";
|
|
962
|
+
break;
|
|
963
|
+
}
|
|
964
|
+
case "mcp_tools": {
|
|
965
|
+
const u = (p = I(s == null ? void 0 : s.value)) == null ? void 0 : p.tools;
|
|
966
|
+
c = [oe(R(r.server)), ie(u, "tool")].filter(Boolean).join(" · ");
|
|
967
|
+
break;
|
|
968
|
+
}
|
|
969
|
+
case "mcp_describe":
|
|
970
|
+
c = [oe(R(r.server)), R(r.tool)].filter(Boolean).join(" · ");
|
|
971
|
+
break;
|
|
972
|
+
case "mcp_call":
|
|
973
|
+
c = [oe(R(r.server)), Ln(r.arguments)].filter(Boolean).join(" · ");
|
|
974
|
+
break;
|
|
975
|
+
default:
|
|
976
|
+
c = i ? [i, R(r.reason)].filter(Boolean).join(" - ") : R(r.reason) || R(Object.values(r).find((u) => typeof u == "string"));
|
|
977
|
+
}
|
|
978
|
+
return !c && typeof t.value == "string" && (c = t.value), !c && l === "other" && Object.keys(r).length && (c = ie(Object.keys(r), "argument") ?? ""), { title: o, family: l, preview: c.replace(/\s+/g, " ").trim() };
|
|
979
|
+
}
|
|
980
|
+
function jn(e, t, s) {
|
|
981
|
+
if (!e)
|
|
982
|
+
return s ? { label: "Running", tone: "muted", pending: !0 } : { label: "No result", tone: "muted" };
|
|
983
|
+
const i = I(e.value);
|
|
984
|
+
return t || i != null && i.error || (i == null ? void 0 : i.isError) === !0 || (i == null ? void 0 : i.stopped) === !1 ? { label: "Failed", tone: "danger" } : (i == null ? void 0 : i.auth_required) === !0 ? { label: "Needs connection", tone: "warning" } : (i == null ? void 0 : i.timed_out) === !0 ? { label: "Timed out", tone: "danger" } : typeof (i == null ? void 0 : i.exit_code) == "number" && i.exit_code !== 0 ? { label: `Exit ${i.exit_code}`, tone: "danger" } : e.omitted !== void 0 ? { label: "Truncated", tone: "warning" } : e.incomplete ? { label: "Invalid JSON", tone: "warning" } : i != null && i.truncated ? { label: "Truncated", tone: "warning" } : Array.isArray(i == null ? void 0 : i.failed) && i.failed.length ? { label: "Partial failure", tone: "warning" } : (i == null ? void 0 : i.running) === !0 ? { label: "Job running", tone: "muted" } : (i == null ? void 0 : i.started) === !0 ? { label: "Started", tone: "success" } : typeof (i == null ? void 0 : i.exit_code) == "number" ? { label: `Exit ${i.exit_code}`, tone: "success" } : { label: "Done", tone: "success" };
|
|
985
|
+
}
|
|
986
|
+
function Ce(e, t) {
|
|
987
|
+
return Object.fromEntries(Object.entries(e).filter(([s]) => t.includes(s)));
|
|
988
|
+
}
|
|
989
|
+
function ae(e) {
|
|
990
|
+
if (!Array.isArray(e)) return;
|
|
991
|
+
const t = e.map(I);
|
|
992
|
+
return t.every((s) => s !== void 0) ? t : void 0;
|
|
993
|
+
}
|
|
994
|
+
function In({ value: e }) {
|
|
995
|
+
return /* @__PURE__ */ n("div", { className: "space-y-4", children: e.map((t, s) => /* @__PURE__ */ d("article", { className: "min-w-0 space-y-2 [overflow-wrap:anywhere]", children: [
|
|
996
|
+
typeof t.url == "string" ? /* @__PURE__ */ n(xe, { url: t.url, children: typeof t.title == "string" ? t.title : t.url }) : t.title !== void 0 ? /* @__PURE__ */ n(P, { value: t.title }) : null,
|
|
997
|
+
t.error !== void 0 && /* @__PURE__ */ n("div", { className: "text-danger", children: /* @__PURE__ */ n(P, { value: t.error }) }),
|
|
998
|
+
typeof t.text == "string" && /* @__PURE__ */ n("div", { className: "whitespace-pre-wrap", children: t.text }),
|
|
999
|
+
typeof t.excerpt == "string" && /* @__PURE__ */ n("p", { className: "whitespace-pre-wrap", children: t.excerpt }),
|
|
1000
|
+
t.truncated === !0 && /* @__PURE__ */ n("p", { className: "text-warning", children: "Page content is truncated." }),
|
|
1001
|
+
/* @__PURE__ */ n(Ne, { value: Ce(t, ["author", "published_date", "status"]) }),
|
|
1002
|
+
/* @__PURE__ */ n(
|
|
1003
|
+
G,
|
|
1004
|
+
{
|
|
1005
|
+
value: t,
|
|
1006
|
+
omit: [
|
|
1007
|
+
"error",
|
|
1008
|
+
"author",
|
|
1009
|
+
"published_date",
|
|
1010
|
+
"status",
|
|
1011
|
+
...typeof t.url == "string" ? ["url", ...typeof t.title == "string" ? ["title"] : []] : ["title"],
|
|
1012
|
+
...typeof t.text == "string" ? ["text"] : [],
|
|
1013
|
+
...typeof t.excerpt == "string" ? ["excerpt"] : [],
|
|
1014
|
+
...typeof t.truncated == "boolean" ? ["truncated"] : []
|
|
1015
|
+
]
|
|
1016
|
+
}
|
|
1017
|
+
)
|
|
1018
|
+
] }, s)) });
|
|
1019
|
+
}
|
|
1020
|
+
function _t({
|
|
1021
|
+
name: e,
|
|
1022
|
+
input: t,
|
|
1023
|
+
value: s,
|
|
1024
|
+
args: i,
|
|
1025
|
+
partial: a
|
|
1026
|
+
}) {
|
|
1027
|
+
var p;
|
|
1028
|
+
const r = I(s);
|
|
1029
|
+
if (!r) return /* @__PURE__ */ n(P, { value: s });
|
|
1030
|
+
const o = I(i), l = (u, m, h = []) => /* @__PURE__ */ d("div", { className: "min-w-0 space-y-2 [overflow-wrap:anywhere]", children: [
|
|
1031
|
+
r.error !== void 0 && /* @__PURE__ */ n("div", { className: "text-danger", children: /* @__PURE__ */ n(P, { value: r.error }) }),
|
|
1032
|
+
r.hint !== void 0 && /* @__PURE__ */ n("div", { className: "text-muted-foreground", children: /* @__PURE__ */ n(P, { value: r.hint }) }),
|
|
1033
|
+
u,
|
|
1034
|
+
!t && (r.truncated === !0 || typeof r.truncated == "number" && r.truncated > 0) && /* @__PURE__ */ n("p", { className: "text-warning", children: e === "list_dir" && typeof r.truncated == "number" ? `${r.truncated} total entries; this listing is limited.` : "Only part of the available output is included." }),
|
|
1035
|
+
r.out_of_memory !== void 0 && /* @__PURE__ */ d("div", { className: "text-danger", children: [
|
|
1036
|
+
/* @__PURE__ */ n("p", { className: "mb-1", children: "Out of memory" }),
|
|
1037
|
+
/* @__PURE__ */ n(P, { value: r.out_of_memory })
|
|
1038
|
+
] }),
|
|
1039
|
+
/* @__PURE__ */ n(Ne, { value: Ce(r, h) }),
|
|
1040
|
+
/* @__PURE__ */ n(
|
|
1041
|
+
G,
|
|
1042
|
+
{
|
|
1043
|
+
value: r,
|
|
1044
|
+
omit: [
|
|
1045
|
+
...m,
|
|
1046
|
+
...h,
|
|
1047
|
+
"error",
|
|
1048
|
+
"hint",
|
|
1049
|
+
"out_of_memory",
|
|
1050
|
+
...!t && (typeof r.truncated == "boolean" || typeof r.truncated == "number") ? ["truncated"] : []
|
|
1051
|
+
]
|
|
1052
|
+
}
|
|
1053
|
+
)
|
|
1054
|
+
] }), c = typeof r.path == "string" ? r.path : typeof (o == null ? void 0 : o.path) == "string" ? o.path : void 0, f = ["path", "start_line", "end_line", "lines", "bytes"];
|
|
1055
|
+
switch (e) {
|
|
1056
|
+
case "read_file":
|
|
1057
|
+
case "write_file":
|
|
1058
|
+
if (typeof r.content == "string")
|
|
1059
|
+
return l(
|
|
1060
|
+
/* @__PURE__ */ n(kt, { text: r.content, path: c }),
|
|
1061
|
+
["content"],
|
|
1062
|
+
f
|
|
1063
|
+
);
|
|
1064
|
+
if (t && typeof r.path == "string")
|
|
1065
|
+
return l(
|
|
1066
|
+
/* @__PURE__ */ n("code", { className: "block break-all", children: r.path }),
|
|
1067
|
+
["path"],
|
|
1068
|
+
["start_line", "end_line"]
|
|
1069
|
+
);
|
|
1070
|
+
if (!t && e === "write_file" && r.written === !0)
|
|
1071
|
+
return l(
|
|
1072
|
+
/* @__PURE__ */ d("p", { children: [
|
|
1073
|
+
"Wrote ",
|
|
1074
|
+
/* @__PURE__ */ n("code", { className: "break-all", children: c })
|
|
1075
|
+
] }),
|
|
1076
|
+
["written", "path"],
|
|
1077
|
+
["lines", "bytes"]
|
|
1078
|
+
);
|
|
1079
|
+
break;
|
|
1080
|
+
case "list_dir":
|
|
1081
|
+
if (t)
|
|
1082
|
+
return l(/* @__PURE__ */ n("code", { className: "block break-all", children: c ?? "/" }), ["path"]);
|
|
1083
|
+
if ((p = ae(r.entries)) != null && p.every((u) => typeof u.name == "string")) {
|
|
1084
|
+
const u = ae(r.entries) ?? [];
|
|
1085
|
+
return l(
|
|
1086
|
+
u.length ? /* @__PURE__ */ n("ul", { className: "space-y-1", children: u.map((m, h) => /* @__PURE__ */ d("li", { className: "min-w-0", children: [
|
|
1087
|
+
/* @__PURE__ */ d("div", { className: "flex flex-wrap items-baseline gap-x-3 gap-y-1", children: [
|
|
1088
|
+
/* @__PURE__ */ d("code", { className: "break-all", children: [
|
|
1089
|
+
String(m.name),
|
|
1090
|
+
m.kind === "dir" ? "/" : ""
|
|
1091
|
+
] }),
|
|
1092
|
+
/* @__PURE__ */ n(
|
|
1093
|
+
Ne,
|
|
1094
|
+
{
|
|
1095
|
+
value: Ce(m, [
|
|
1096
|
+
"kind",
|
|
1097
|
+
"format",
|
|
1098
|
+
"bytes",
|
|
1099
|
+
"lines"
|
|
1100
|
+
])
|
|
1101
|
+
}
|
|
1102
|
+
)
|
|
1103
|
+
] }),
|
|
1104
|
+
/* @__PURE__ */ n(
|
|
1105
|
+
G,
|
|
1106
|
+
{
|
|
1107
|
+
value: m,
|
|
1108
|
+
omit: ["name", "kind", "format", "bytes", "lines"]
|
|
1109
|
+
}
|
|
1110
|
+
)
|
|
1111
|
+
] }, h)) }) : /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: "Directory is empty" }),
|
|
1112
|
+
["entries"],
|
|
1113
|
+
["path"]
|
|
1114
|
+
);
|
|
1115
|
+
}
|
|
1116
|
+
break;
|
|
1117
|
+
case "find_files":
|
|
1118
|
+
if (t && typeof r.pattern == "string")
|
|
1119
|
+
return l(
|
|
1120
|
+
/* @__PURE__ */ n("code", { className: "block break-all", children: r.pattern }),
|
|
1121
|
+
["pattern"],
|
|
1122
|
+
["path"]
|
|
1123
|
+
);
|
|
1124
|
+
if (Array.isArray(r.matches) && r.matches.every((u) => typeof u == "string"))
|
|
1125
|
+
return l(
|
|
1126
|
+
r.matches.length ? /* @__PURE__ */ n("ul", { className: "space-y-1", children: r.matches.map((u, m) => /* @__PURE__ */ n("li", { children: /* @__PURE__ */ n("code", { className: "break-all", children: u }) }, m)) }) : /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: "No matching files" }),
|
|
1127
|
+
["matches"],
|
|
1128
|
+
["pattern"]
|
|
1129
|
+
);
|
|
1130
|
+
break;
|
|
1131
|
+
case "apply_patch": {
|
|
1132
|
+
if (t && typeof r.patch == "string")
|
|
1133
|
+
return l(/* @__PURE__ */ n(V, { code: r.patch, lang: "diff" }), ["patch"]);
|
|
1134
|
+
const u = ae(r.files);
|
|
1135
|
+
if (!t && (u != null && u.every((m) => typeof m.path == "string")))
|
|
1136
|
+
return l(
|
|
1137
|
+
/* @__PURE__ */ d(_e, { children: [
|
|
1138
|
+
/* @__PURE__ */ n("ul", { className: "space-y-1", children: u.map((m, h) => /* @__PURE__ */ d("li", { children: [
|
|
1139
|
+
/* @__PURE__ */ d("div", { className: "flex flex-wrap gap-x-2", children: [
|
|
1140
|
+
/* @__PURE__ */ n("code", { className: "break-all", children: String(m.path) }),
|
|
1141
|
+
/* @__PURE__ */ n(Ne, { value: Ce(m, ["action", "to"]) })
|
|
1142
|
+
] }),
|
|
1143
|
+
/* @__PURE__ */ n(G, { value: m, omit: ["path", "action", "to"] })
|
|
1144
|
+
] }, h)) }),
|
|
1145
|
+
r.fuzzy !== void 0 && /* @__PURE__ */ d("p", { className: "text-warning", children: [
|
|
1146
|
+
"Whitespace-tolerant matches: ",
|
|
1147
|
+
String(r.fuzzy)
|
|
1148
|
+
] }),
|
|
1149
|
+
r.ignoredHeadings !== void 0 && /* @__PURE__ */ d("p", { className: "text-warning", children: [
|
|
1150
|
+
"Ignored patch headings: ",
|
|
1151
|
+
String(r.ignoredHeadings)
|
|
1152
|
+
] })
|
|
1153
|
+
] }),
|
|
1154
|
+
["files", "fuzzy", "ignoredHeadings"],
|
|
1155
|
+
["applied"]
|
|
1156
|
+
);
|
|
1157
|
+
break;
|
|
1158
|
+
}
|
|
1159
|
+
case "move_file":
|
|
1160
|
+
case "copy_file":
|
|
1161
|
+
if (typeof r.from == "string" && typeof r.to == "string")
|
|
1162
|
+
return l(
|
|
1163
|
+
/* @__PURE__ */ d("code", { className: "block break-all", children: [
|
|
1164
|
+
r.from,
|
|
1165
|
+
" ",
|
|
1166
|
+
"->",
|
|
1167
|
+
" ",
|
|
1168
|
+
r.to
|
|
1169
|
+
] }),
|
|
1170
|
+
["from", "to"],
|
|
1171
|
+
["moved", "copied", "bytes", "directory", "overwrite", "recursive"]
|
|
1172
|
+
);
|
|
1173
|
+
break;
|
|
1174
|
+
case "delete_file":
|
|
1175
|
+
if (typeof r.path == "string")
|
|
1176
|
+
return l(
|
|
1177
|
+
/* @__PURE__ */ n("code", { className: "block break-all", children: r.path }),
|
|
1178
|
+
["path"],
|
|
1179
|
+
["deleted", "directory", "recursive"]
|
|
1180
|
+
);
|
|
1181
|
+
break;
|
|
1182
|
+
case "run_command":
|
|
1183
|
+
case "run_command_background":
|
|
1184
|
+
case "read_command_output":
|
|
1185
|
+
case "stop_command":
|
|
1186
|
+
if (t) {
|
|
1187
|
+
if (typeof r.command == "string")
|
|
1188
|
+
return l(
|
|
1189
|
+
/* @__PURE__ */ n(V, { code: r.command, lang: "bash" }),
|
|
1190
|
+
["command"],
|
|
1191
|
+
["cwd", "timeout"]
|
|
1192
|
+
);
|
|
1193
|
+
if (typeof r.job_id == "string")
|
|
1194
|
+
return l(
|
|
1195
|
+
/* @__PURE__ */ n("code", { className: "break-all", children: r.job_id }),
|
|
1196
|
+
["job_id"],
|
|
1197
|
+
["start_line"]
|
|
1198
|
+
);
|
|
1199
|
+
} else {
|
|
1200
|
+
const u = ["stdout", "output", "stderr"].filter(
|
|
1201
|
+
(m) => typeof r[m] == "string"
|
|
1202
|
+
);
|
|
1203
|
+
if (u.length)
|
|
1204
|
+
return l(
|
|
1205
|
+
/* @__PURE__ */ d("div", { className: "space-y-2", children: [
|
|
1206
|
+
u.every((m) => r[m] === "") && /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: a ? "No output in the received prefix" : "No output" }),
|
|
1207
|
+
u.filter((m) => r[m] !== "").map((m) => /* @__PURE__ */ d(
|
|
1208
|
+
"div",
|
|
1209
|
+
{
|
|
1210
|
+
className: m === "stderr" ? "text-danger" : void 0,
|
|
1211
|
+
children: [
|
|
1212
|
+
m === "stderr" && /* @__PURE__ */ n("p", { className: "mb-1 text-[11px]", children: "Standard error" }),
|
|
1213
|
+
/* @__PURE__ */ n(V, { code: String(r[m]) })
|
|
1214
|
+
]
|
|
1215
|
+
},
|
|
1216
|
+
m
|
|
1217
|
+
))
|
|
1218
|
+
] }),
|
|
1219
|
+
u,
|
|
1220
|
+
[
|
|
1221
|
+
"exit_code",
|
|
1222
|
+
"duration_ms",
|
|
1223
|
+
"job_id",
|
|
1224
|
+
"command",
|
|
1225
|
+
"running",
|
|
1226
|
+
"start_line",
|
|
1227
|
+
"end_line",
|
|
1228
|
+
"lines",
|
|
1229
|
+
"timed_out"
|
|
1230
|
+
]
|
|
1231
|
+
);
|
|
1232
|
+
if (typeof r.job_id == "string")
|
|
1233
|
+
return l(
|
|
1234
|
+
/* @__PURE__ */ n("code", { className: "break-all", children: r.job_id }),
|
|
1235
|
+
["job_id"],
|
|
1236
|
+
["started", "stopped"]
|
|
1237
|
+
);
|
|
1238
|
+
}
|
|
1239
|
+
break;
|
|
1240
|
+
case "web_search":
|
|
1241
|
+
case "web_read":
|
|
1242
|
+
case "web_answer":
|
|
1243
|
+
if (t) {
|
|
1244
|
+
if (typeof r.query == "string")
|
|
1245
|
+
return l(/* @__PURE__ */ n("p", { className: "whitespace-pre-wrap", children: r.query }), ["query"]);
|
|
1246
|
+
if (Array.isArray(r.urls) && r.urls.every((u) => typeof u == "string"))
|
|
1247
|
+
return l(
|
|
1248
|
+
/* @__PURE__ */ n("ul", { className: "space-y-1", children: r.urls.map((u, m) => /* @__PURE__ */ n("li", { children: /* @__PURE__ */ n(xe, { url: u }) }, m)) }),
|
|
1249
|
+
["urls"]
|
|
1250
|
+
);
|
|
1251
|
+
} else {
|
|
1252
|
+
const m = ["results", "pages", "sources", "failed"].filter((h) => ae(r[h]) !== void 0);
|
|
1253
|
+
if (m.length || typeof r.answer == "string")
|
|
1254
|
+
return l(
|
|
1255
|
+
/* @__PURE__ */ d("div", { className: "space-y-4", children: [
|
|
1256
|
+
typeof r.answer == "string" && /* @__PURE__ */ n(ce, { className: "text-xs", children: r.answer }),
|
|
1257
|
+
m.map((h) => {
|
|
1258
|
+
var x, v;
|
|
1259
|
+
return /* @__PURE__ */ d("div", { children: [
|
|
1260
|
+
h === "failed" && (((x = ae(r[h])) == null ? void 0 : x.length) ?? 0) > 0 && /* @__PURE__ */ n("p", { className: "mb-2 text-danger", children: "Some pages could not be fetched." }),
|
|
1261
|
+
h !== "failed" && ((v = ae(r[h])) == null ? void 0 : v.length) === 0 && /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: "No sources returned" }),
|
|
1262
|
+
/* @__PURE__ */ n(In, { value: ae(r[h]) ?? [] })
|
|
1263
|
+
] }, h);
|
|
1264
|
+
}),
|
|
1265
|
+
Array.isArray(r.skipped) && r.skipped.length > 0 && /* @__PURE__ */ d("div", { className: "text-warning", children: [
|
|
1266
|
+
/* @__PURE__ */ n("p", { className: "mb-1", children: "Some URLs were skipped." }),
|
|
1267
|
+
/* @__PURE__ */ n(P, { value: r.skipped, field: "urls" })
|
|
1268
|
+
] })
|
|
1269
|
+
] }),
|
|
1270
|
+
[
|
|
1271
|
+
...m,
|
|
1272
|
+
...typeof r.answer == "string" ? ["answer"] : [],
|
|
1273
|
+
...Array.isArray(r.skipped) ? ["skipped"] : []
|
|
1274
|
+
],
|
|
1275
|
+
["query", "found", "cost_usd"]
|
|
1276
|
+
);
|
|
1277
|
+
}
|
|
1278
|
+
break;
|
|
1279
|
+
case "compact":
|
|
1280
|
+
if (t && typeof r.reason == "string")
|
|
1281
|
+
return l(
|
|
1282
|
+
/* @__PURE__ */ n("p", { className: "whitespace-pre-wrap", children: r.reason }),
|
|
1283
|
+
["reason"],
|
|
1284
|
+
["nodes"]
|
|
1285
|
+
);
|
|
1286
|
+
break;
|
|
1287
|
+
default:
|
|
1288
|
+
if (t && e.startsWith("transfer_to_"))
|
|
1289
|
+
return l(
|
|
1290
|
+
r.reason !== void 0 ? /* @__PURE__ */ n(P, { value: r.reason }) : /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: "No additional arguments" }),
|
|
1291
|
+
["reason"]
|
|
1292
|
+
);
|
|
1293
|
+
}
|
|
1294
|
+
return r.error !== void 0 ? l(null, []) : /* @__PURE__ */ n(P, { value: s });
|
|
1295
|
+
}
|
|
1296
|
+
const St = Ie.forwardRef(({ className: e, ...t }, s) => /* @__PURE__ */ n(
|
|
1297
|
+
"input",
|
|
1298
|
+
{
|
|
1299
|
+
ref: s,
|
|
1300
|
+
className: k(
|
|
1301
|
+
"h-9 w-full rounded-md border border-input bg-surface-input px-3 text-sm outline-none placeholder:text-muted-foreground focus-visible:border-ring disabled:opacity-50",
|
|
1302
|
+
e
|
|
1303
|
+
),
|
|
1304
|
+
...t
|
|
1305
|
+
}
|
|
1306
|
+
));
|
|
1307
|
+
St.displayName = "Input";
|
|
1308
|
+
function Oe(e) {
|
|
1309
|
+
if (!Array.isArray(e)) return;
|
|
1310
|
+
const t = e.map(I);
|
|
1311
|
+
return t.every((s) => s !== void 0) ? t : void 0;
|
|
1312
|
+
}
|
|
1313
|
+
const E = (e) => typeof e == "string" ? e : void 0;
|
|
1314
|
+
function ee({ children: e }) {
|
|
1315
|
+
return /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: e });
|
|
1316
|
+
}
|
|
1317
|
+
function Rn({ tools: e }) {
|
|
1318
|
+
const [t, s] = O(""), i = t.trim().toLowerCase(), a = i ? e.filter(
|
|
1319
|
+
(r) => `${E(r.name) ?? ""} ${E(r.description) ?? ""}`.toLowerCase().includes(i)
|
|
1320
|
+
) : e;
|
|
1321
|
+
return e.length ? /* @__PURE__ */ d("div", { className: "space-y-2", children: [
|
|
1322
|
+
e.length > 12 && /* @__PURE__ */ n(
|
|
1323
|
+
St,
|
|
1324
|
+
{
|
|
1325
|
+
className: "h-7 text-xs",
|
|
1326
|
+
placeholder: `Filter ${e.length} tools`,
|
|
1327
|
+
"aria-label": "Filter tools",
|
|
1328
|
+
value: t,
|
|
1329
|
+
onChange: (r) => s(r.target.value)
|
|
1330
|
+
}
|
|
1331
|
+
),
|
|
1332
|
+
/* @__PURE__ */ n("ul", { className: "space-y-1.5", children: a.map((r, o) => /* @__PURE__ */ d("li", { className: "min-w-0", children: [
|
|
1333
|
+
/* @__PURE__ */ n("code", { className: "break-all text-foreground", children: E(r.name) ?? "?" }),
|
|
1334
|
+
E(r.description) && /* @__PURE__ */ n(
|
|
1335
|
+
"p",
|
|
1336
|
+
{
|
|
1337
|
+
className: "line-clamp-2 text-muted-foreground",
|
|
1338
|
+
title: E(r.description),
|
|
1339
|
+
children: E(r.description)
|
|
1340
|
+
}
|
|
1341
|
+
)
|
|
1342
|
+
] }, o)) }),
|
|
1343
|
+
i && !a.length && /* @__PURE__ */ n(ee, { children: "No matching tools" })
|
|
1344
|
+
] }) : /* @__PURE__ */ n(ee, { children: "No tools" });
|
|
1345
|
+
}
|
|
1346
|
+
function $n({ schema: e }) {
|
|
1347
|
+
const t = I(e), s = Object.entries(I(t == null ? void 0 : t.properties) ?? {}), i = Array.isArray(t == null ? void 0 : t.required) ? t.required : [];
|
|
1348
|
+
return s.length ? /* @__PURE__ */ n("ul", { className: "space-y-1.5", children: s.map(([a, r]) => {
|
|
1349
|
+
var c;
|
|
1350
|
+
const o = I(r) ?? {}, l = Array.isArray(o.enum) ? o.enum.map(String).join(" | ") : o.type === "array" ? `${E((c = I(o.items)) == null ? void 0 : c.type) ?? "any"}[]` : Array.isArray(o.type) ? o.type.join(" | ") : E(o.type) ?? "";
|
|
1351
|
+
return /* @__PURE__ */ d("li", { className: "min-w-0", children: [
|
|
1352
|
+
/* @__PURE__ */ d("div", { className: "flex flex-wrap items-baseline gap-x-2", children: [
|
|
1353
|
+
/* @__PURE__ */ n("code", { className: "break-all text-foreground", children: a }),
|
|
1354
|
+
l && /* @__PURE__ */ n("span", { className: "text-muted-foreground", children: l }),
|
|
1355
|
+
i.includes(a) && /* @__PURE__ */ n("span", { className: "text-[11px] text-warning", children: "required" })
|
|
1356
|
+
] }),
|
|
1357
|
+
E(o.description) && /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: E(o.description) })
|
|
1358
|
+
] }, a);
|
|
1359
|
+
}) }) : /* @__PURE__ */ n(ee, { children: "Takes no arguments" });
|
|
1360
|
+
}
|
|
1361
|
+
function Mn(e) {
|
|
1362
|
+
if (/^\s*[{[]/.test(e))
|
|
1363
|
+
try {
|
|
1364
|
+
return { value: JSON.parse(e) };
|
|
1365
|
+
} catch {
|
|
1366
|
+
return;
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
function Ct({ part: e }) {
|
|
1370
|
+
switch (e.type) {
|
|
1371
|
+
case "text": {
|
|
1372
|
+
const t = E(e.text) ?? "", s = Mn(t);
|
|
1373
|
+
return s ? /* @__PURE__ */ n(P, { value: s.value }) : t ? /* @__PURE__ */ n(ce, { className: "text-xs [overflow-wrap:anywhere]", children: t }) : /* @__PURE__ */ n(ee, { children: "(empty)" });
|
|
1374
|
+
}
|
|
1375
|
+
case "image": {
|
|
1376
|
+
const t = E(e.mimeType) ?? "", s = E(e.data);
|
|
1377
|
+
return /^image\/[\w.+-]+$/.test(t) && s ? /* @__PURE__ */ n(
|
|
1378
|
+
"img",
|
|
1379
|
+
{
|
|
1380
|
+
className: "max-h-64 max-w-full rounded border border-border",
|
|
1381
|
+
src: `data:${t};base64,${s}`,
|
|
1382
|
+
alt: ""
|
|
1383
|
+
}
|
|
1384
|
+
) : /* @__PURE__ */ n(ee, { children: `Image (${t || "unknown type"})` });
|
|
1385
|
+
}
|
|
1386
|
+
case "resource_link": {
|
|
1387
|
+
const t = E(e.uri);
|
|
1388
|
+
return t ? /* @__PURE__ */ n(xe, { url: t, children: E(e.name) ?? E(e.title) ?? t }) : null;
|
|
1389
|
+
}
|
|
1390
|
+
case "resource": {
|
|
1391
|
+
const t = I(e.resource) ?? {}, s = E(t.uri);
|
|
1392
|
+
return /* @__PURE__ */ d("div", { className: "space-y-1", children: [
|
|
1393
|
+
s && /* @__PURE__ */ n(xe, { url: s }),
|
|
1394
|
+
E(t.text) !== void 0 && /* @__PURE__ */ n(Ct, { part: { type: "text", text: t.text } })
|
|
1395
|
+
] });
|
|
1396
|
+
}
|
|
1397
|
+
default:
|
|
1398
|
+
return /* @__PURE__ */ n(P, { value: e });
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
function Tn({ object: e }) {
|
|
1402
|
+
if (e.auth_required === !0) {
|
|
1403
|
+
const a = E(e.connect_url);
|
|
1404
|
+
return /* @__PURE__ */ d("div", { className: "space-y-1 text-warning", children: [
|
|
1405
|
+
/* @__PURE__ */ n("p", { children: E(e.message) ?? "This service needs a connected account." }),
|
|
1406
|
+
a && /* @__PURE__ */ d(xe, { url: a, children: [
|
|
1407
|
+
"Connect ",
|
|
1408
|
+
oe(E(e.server) ?? "")
|
|
1409
|
+
] })
|
|
1410
|
+
] });
|
|
1411
|
+
}
|
|
1412
|
+
const t = Oe(e.content) ?? [], s = e.structuredContent, i = s !== void 0 ? t.filter((a) => a.type !== "text") : t;
|
|
1413
|
+
return /* @__PURE__ */ d("div", { className: "min-w-0 space-y-2 [overflow-wrap:anywhere]", children: [
|
|
1414
|
+
e.isError === !0 && /* @__PURE__ */ n("p", { className: "text-danger", children: "The service returned an error." }),
|
|
1415
|
+
/* @__PURE__ */ d("div", { className: k("space-y-2", e.isError === !0 && "text-danger"), children: [
|
|
1416
|
+
s !== void 0 && /* @__PURE__ */ n(P, { value: s }),
|
|
1417
|
+
i.map((a, r) => /* @__PURE__ */ n(Ct, { part: a }, r)),
|
|
1418
|
+
s === void 0 && !t.length && /* @__PURE__ */ n(ee, { children: "No content" })
|
|
1419
|
+
] }),
|
|
1420
|
+
e.truncated === !0 && /* @__PURE__ */ n("p", { className: "text-warning", children: E(e.note) ?? "Only part of the result is included." })
|
|
1421
|
+
] });
|
|
1422
|
+
}
|
|
1423
|
+
function Dn({
|
|
1424
|
+
name: e,
|
|
1425
|
+
input: t,
|
|
1426
|
+
value: s,
|
|
1427
|
+
args: i,
|
|
1428
|
+
partial: a
|
|
1429
|
+
}) {
|
|
1430
|
+
const r = I(s), o = /* @__PURE__ */ n(_t, { name: e, input: t, value: s, args: i, partial: a });
|
|
1431
|
+
if (!r || r.error !== void 0) return o;
|
|
1432
|
+
if (t) {
|
|
1433
|
+
const l = E(r.server);
|
|
1434
|
+
switch (e) {
|
|
1435
|
+
case "mcp_servers":
|
|
1436
|
+
return Object.keys(r).length ? o : /* @__PURE__ */ n(ee, { children: "No arguments" });
|
|
1437
|
+
case "mcp_tools":
|
|
1438
|
+
case "mcp_describe":
|
|
1439
|
+
if (!l) break;
|
|
1440
|
+
return /* @__PURE__ */ d("p", { children: [
|
|
1441
|
+
oe(l),
|
|
1442
|
+
E(r.tool) && /* @__PURE__ */ d(_e, { children: [
|
|
1443
|
+
" · ",
|
|
1444
|
+
/* @__PURE__ */ n("code", { className: "break-all", children: E(r.tool) })
|
|
1445
|
+
] })
|
|
1446
|
+
] });
|
|
1447
|
+
case "mcp_call": {
|
|
1448
|
+
if (!l) break;
|
|
1449
|
+
const c = I(r.arguments);
|
|
1450
|
+
return /* @__PURE__ */ d("div", { className: "space-y-2", children: [
|
|
1451
|
+
c && Object.keys(c).length ? /* @__PURE__ */ n(P, { value: c }) : r.arguments === void 0 || c ? /* @__PURE__ */ n(ee, { children: "No arguments" }) : /* @__PURE__ */ n(P, { value: r.arguments }),
|
|
1452
|
+
/* @__PURE__ */ n(
|
|
1453
|
+
Ne,
|
|
1454
|
+
{
|
|
1455
|
+
value: {
|
|
1456
|
+
service: oe(l),
|
|
1457
|
+
...E(r.tool) ? { tool: r.tool } : {}
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
)
|
|
1461
|
+
] });
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
return o;
|
|
1465
|
+
}
|
|
1466
|
+
switch (e) {
|
|
1467
|
+
case "mcp_servers": {
|
|
1468
|
+
const l = Oe(r.servers);
|
|
1469
|
+
if (!l) break;
|
|
1470
|
+
return l.length ? /* @__PURE__ */ n("ul", { className: "space-y-1", children: l.map((c, f) => /* @__PURE__ */ d("li", { className: "flex flex-wrap items-baseline gap-x-2", children: [
|
|
1471
|
+
/* @__PURE__ */ n("span", { className: "text-foreground", title: E(c.server), children: oe(E(c.server) ?? "?") }),
|
|
1472
|
+
typeof c.tools == "number" && /* @__PURE__ */ d("span", { className: "text-muted-foreground", children: [
|
|
1473
|
+
c.tools,
|
|
1474
|
+
" ",
|
|
1475
|
+
c.tools === 1 ? "tool" : "tools"
|
|
1476
|
+
] })
|
|
1477
|
+
] }, f)) }) : /* @__PURE__ */ n(ee, { children: "No services are enabled for this chat" });
|
|
1478
|
+
}
|
|
1479
|
+
case "mcp_tools": {
|
|
1480
|
+
const l = Oe(r.tools);
|
|
1481
|
+
if (!l) break;
|
|
1482
|
+
return /* @__PURE__ */ n(Rn, { tools: l });
|
|
1483
|
+
}
|
|
1484
|
+
case "mcp_describe":
|
|
1485
|
+
if (r.inputSchema === void 0 && E(r.description) === void 0) break;
|
|
1486
|
+
return /* @__PURE__ */ d("div", { className: "min-w-0 space-y-3 [overflow-wrap:anywhere]", children: [
|
|
1487
|
+
E(r.description) && /* @__PURE__ */ n(ce, { className: "text-xs", children: E(r.description) ?? "" }),
|
|
1488
|
+
/* @__PURE__ */ d("div", { children: [
|
|
1489
|
+
/* @__PURE__ */ n("p", { className: "mb-1 text-[11px] font-semibold text-muted-foreground", children: "Parameters" }),
|
|
1490
|
+
/* @__PURE__ */ n($n, { schema: r.inputSchema })
|
|
1491
|
+
] })
|
|
1492
|
+
] });
|
|
1493
|
+
case "mcp_call":
|
|
1494
|
+
if (r.auth_required !== !0 && r.content === void 0 && r.structuredContent === void 0)
|
|
1495
|
+
break;
|
|
1496
|
+
return /* @__PURE__ */ n(Tn, { object: r });
|
|
1497
|
+
}
|
|
1498
|
+
return o;
|
|
1499
|
+
}
|
|
1500
|
+
function Pn(e) {
|
|
1501
|
+
const t = [], s = [];
|
|
1502
|
+
for (const i of e.split(/\r?\n/)) {
|
|
1503
|
+
const a = i.trim();
|
|
1504
|
+
if (!a || /^<\/?memory-recollection>$/.test(i)) continue;
|
|
1505
|
+
const r = /^( *)(?:(\d+\.\d+|--) {2,}|([\u2190\u2192][\w-]+) {2,}(?:(\d+\.\d+) {2,})?)([A-Za-z0-9_ -]+?) {2,}(\S+)\s*$/.exec(
|
|
1506
|
+
i
|
|
1507
|
+
);
|
|
1508
|
+
if (r && (r[3] || r[1].length <= 2))
|
|
1509
|
+
t.push({
|
|
1510
|
+
id: r[6],
|
|
1511
|
+
kind: r[5],
|
|
1512
|
+
depth: r[3] ? Math.floor(r[1].length / 2) : 0,
|
|
1513
|
+
score: r[2] === "--" ? void 0 : r[2] ?? r[4],
|
|
1514
|
+
relation: r[3],
|
|
1515
|
+
lines: []
|
|
1516
|
+
});
|
|
1517
|
+
else if (a.startsWith("(more memory matched than fits;") || /^\u2026 \d+ more characters$/.test(a))
|
|
1518
|
+
s.push(a);
|
|
1519
|
+
else if (t.length && /^ {6,}\S/.test(i))
|
|
1520
|
+
t[t.length - 1].lines.push(a);
|
|
1521
|
+
else
|
|
1522
|
+
return;
|
|
1523
|
+
}
|
|
1524
|
+
return t.length ? { entries: t, notes: s } : void 0;
|
|
1525
|
+
}
|
|
1526
|
+
function Et({ node: e }) {
|
|
1527
|
+
return /* @__PURE__ */ d("div", { className: "flex flex-wrap items-baseline gap-x-2 gap-y-1 text-[11px] text-muted-foreground", children: [
|
|
1528
|
+
typeof e.kind == "string" && /* @__PURE__ */ n("span", { className: "font-medium capitalize", children: e.kind }),
|
|
1529
|
+
e.stale === !0 && /* @__PURE__ */ n("span", { className: "text-warning", children: "Superseded" }),
|
|
1530
|
+
typeof e.id == "string" && /* @__PURE__ */ n("code", { className: "break-all", children: e.id }),
|
|
1531
|
+
typeof e.ref == "string" && /* @__PURE__ */ d("code", { className: "break-all", children: [
|
|
1532
|
+
"Ref: ",
|
|
1533
|
+
e.ref
|
|
1534
|
+
] })
|
|
1535
|
+
] });
|
|
1536
|
+
}
|
|
1537
|
+
function Ye({
|
|
1538
|
+
nodes: e,
|
|
1539
|
+
renderValue: t
|
|
1540
|
+
}) {
|
|
1541
|
+
return e.length ? /* @__PURE__ */ n("div", { className: "space-y-4", children: e.map((s, i) => {
|
|
1542
|
+
const a = I(s.file), r = typeof s.file == "string" ? s.file : a == null ? void 0 : a.path;
|
|
1543
|
+
return /* @__PURE__ */ d("article", { className: "min-w-0 space-y-2 [overflow-wrap:anywhere]", children: [
|
|
1544
|
+
/* @__PURE__ */ n(Et, { node: s }),
|
|
1545
|
+
typeof s.text == "string" && /* @__PURE__ */ n(ce, { className: "text-xs", children: s.text }),
|
|
1546
|
+
typeof r == "string" && /* @__PURE__ */ d("div", { className: "text-[11px] text-muted-foreground", children: [
|
|
1547
|
+
/* @__PURE__ */ n("code", { className: "break-all", children: r }),
|
|
1548
|
+
typeof (a == null ? void 0 : a.bytes) == "number" && /* @__PURE__ */ d("span", { children: [
|
|
1549
|
+
" (",
|
|
1550
|
+
a.bytes.toLocaleString(),
|
|
1551
|
+
" bytes)"
|
|
1552
|
+
] })
|
|
1553
|
+
] }),
|
|
1554
|
+
typeof s.content == "string" && /* @__PURE__ */ n(
|
|
1555
|
+
kt,
|
|
1556
|
+
{
|
|
1557
|
+
text: s.content,
|
|
1558
|
+
path: typeof r == "string" ? r : void 0
|
|
1559
|
+
}
|
|
1560
|
+
),
|
|
1561
|
+
/* @__PURE__ */ n(
|
|
1562
|
+
G,
|
|
1563
|
+
{
|
|
1564
|
+
value: s,
|
|
1565
|
+
omit: [
|
|
1566
|
+
"id",
|
|
1567
|
+
"ref",
|
|
1568
|
+
"kind",
|
|
1569
|
+
"text",
|
|
1570
|
+
"content",
|
|
1571
|
+
...typeof s.file == "string" ? ["file"] : []
|
|
1572
|
+
],
|
|
1573
|
+
renderValue: t
|
|
1574
|
+
}
|
|
1575
|
+
)
|
|
1576
|
+
] }, i);
|
|
1577
|
+
}) }) : /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: "No memories" });
|
|
1578
|
+
}
|
|
1579
|
+
function Ve(e) {
|
|
1580
|
+
if (!Array.isArray(e)) return;
|
|
1581
|
+
const t = e.map(I);
|
|
1582
|
+
if (t.every(
|
|
1583
|
+
(s) => s !== void 0 && ["id", "ref", "kind", "text", "content"].every(
|
|
1584
|
+
(i) => s[i] === void 0 || typeof s[i] == "string"
|
|
1585
|
+
) && ["id", "ref", "text", "file"].some((i) => s[i] !== void 0)
|
|
1586
|
+
))
|
|
1587
|
+
return t;
|
|
1588
|
+
}
|
|
1589
|
+
function Wn({ value: e, renderValue: t }) {
|
|
1590
|
+
const s = Array.isArray(e) ? e.map(I) : void 0;
|
|
1591
|
+
return !s || !s.every(
|
|
1592
|
+
(i) => i !== void 0 && typeof i.in == "string" && typeof i.line == "number" && typeof i.text == "string"
|
|
1593
|
+
) ? /* @__PURE__ */ n(_e, { children: t({ hits: e }) }) : /* @__PURE__ */ n("div", { className: "space-y-2", children: s.map((i, a) => /* @__PURE__ */ d("div", { children: [
|
|
1594
|
+
/* @__PURE__ */ d("div", { className: "mb-1 text-[11px] text-muted-foreground", children: [
|
|
1595
|
+
String(i.in),
|
|
1596
|
+
":",
|
|
1597
|
+
String(i.line)
|
|
1598
|
+
] }),
|
|
1599
|
+
/* @__PURE__ */ n("pre", { className: "whitespace-pre-wrap break-words font-mono text-xs", children: String(i.text) }),
|
|
1600
|
+
/* @__PURE__ */ n(G, { value: i, omit: ["in", "line", "text"], renderValue: t })
|
|
1601
|
+
] }, a)) });
|
|
1602
|
+
}
|
|
1603
|
+
function Bn({
|
|
1604
|
+
name: e,
|
|
1605
|
+
input: t,
|
|
1606
|
+
value: s,
|
|
1607
|
+
text: i,
|
|
1608
|
+
renderValue: a
|
|
1609
|
+
}) {
|
|
1610
|
+
const r = I(s), o = typeof s == "string" ? s : i;
|
|
1611
|
+
if (!t && e === "memory_search" && (s === void 0 || typeof s == "string")) {
|
|
1612
|
+
const l = Pn(o);
|
|
1613
|
+
return l ? /* @__PURE__ */ d("div", { className: "space-y-3", children: [
|
|
1614
|
+
l.entries.map((c, f) => /* @__PURE__ */ d(
|
|
1615
|
+
"article",
|
|
1616
|
+
{
|
|
1617
|
+
className: "min-w-0 space-y-1 [overflow-wrap:anywhere]",
|
|
1618
|
+
style: { marginLeft: `${Math.min(c.depth, 6) * 0.75}rem` },
|
|
1619
|
+
children: [
|
|
1620
|
+
/* @__PURE__ */ d("div", { className: "flex flex-wrap items-baseline gap-x-2 gap-y-1 text-[11px] text-muted-foreground", children: [
|
|
1621
|
+
c.relation && /* @__PURE__ */ n("span", { children: c.relation }),
|
|
1622
|
+
/* @__PURE__ */ n("span", { className: "font-medium capitalize", children: c.kind }),
|
|
1623
|
+
c.score && /* @__PURE__ */ d("span", { children: [
|
|
1624
|
+
"Score ",
|
|
1625
|
+
c.score
|
|
1626
|
+
] }),
|
|
1627
|
+
/* @__PURE__ */ n("code", { className: "break-all", children: c.id })
|
|
1628
|
+
] }),
|
|
1629
|
+
c.lines.map((p, u) => /* @__PURE__ */ n(
|
|
1630
|
+
"div",
|
|
1631
|
+
{
|
|
1632
|
+
className: p.startsWith("/memory/") || p.startsWith("+ ") ? "whitespace-pre-wrap font-mono text-[11px] text-muted-foreground" : "whitespace-pre-wrap",
|
|
1633
|
+
children: p
|
|
1634
|
+
},
|
|
1635
|
+
u
|
|
1636
|
+
))
|
|
1637
|
+
]
|
|
1638
|
+
},
|
|
1639
|
+
f
|
|
1640
|
+
)),
|
|
1641
|
+
l.notes.map((c, f) => /* @__PURE__ */ n("p", { className: "text-warning", children: c }, f))
|
|
1642
|
+
] }) : /* @__PURE__ */ n("div", { className: "whitespace-pre-wrap [overflow-wrap:anywhere]", children: o || "(empty)" });
|
|
1643
|
+
}
|
|
1644
|
+
if (!t && e === "memory_load") {
|
|
1645
|
+
const l = Ve(s);
|
|
1646
|
+
if (l) return /* @__PURE__ */ n(Ye, { nodes: l, renderValue: a });
|
|
1647
|
+
}
|
|
1648
|
+
if (t && e === "memory_commit" && r) {
|
|
1649
|
+
const l = Ve(r.nodes);
|
|
1650
|
+
if (l)
|
|
1651
|
+
return /* @__PURE__ */ d("div", { children: [
|
|
1652
|
+
/* @__PURE__ */ n(Ye, { nodes: l, renderValue: a }),
|
|
1653
|
+
r.edges !== void 0 && /* @__PURE__ */ n("div", { className: "mt-3", children: a({ links: r.edges }) }),
|
|
1654
|
+
/* @__PURE__ */ n(G, { value: r, omit: ["nodes", "edges"], renderValue: a })
|
|
1655
|
+
] });
|
|
1656
|
+
}
|
|
1657
|
+
if (t && r && (e === "memory_load" || e === "memory_forget") && Array.isArray(r.ids) && r.ids.every((l) => typeof l == "string"))
|
|
1658
|
+
return /* @__PURE__ */ d("div", { children: [
|
|
1659
|
+
/* @__PURE__ */ n("div", { className: "flex flex-wrap gap-x-3 gap-y-1 font-mono text-[11px]", children: r.ids.map((l, c) => /* @__PURE__ */ n("code", { className: "break-all", children: l }, c)) }),
|
|
1660
|
+
r.reason !== void 0 && /* @__PURE__ */ n("div", { className: "mt-2", children: a({ reason: r.reason }) }),
|
|
1661
|
+
/* @__PURE__ */ n(G, { value: r, omit: ["ids", "reason"], renderValue: a })
|
|
1662
|
+
] });
|
|
1663
|
+
if (!t && e === "memory_grep" && r && Array.isArray(r.matches)) {
|
|
1664
|
+
const l = r.matches.map(I);
|
|
1665
|
+
if (l.every(
|
|
1666
|
+
(c) => c !== void 0 && typeof c.id == "string" && Array.isArray(c.hits)
|
|
1667
|
+
))
|
|
1668
|
+
return /* @__PURE__ */ d("div", { className: "space-y-3", children: [
|
|
1669
|
+
typeof r.found == "number" && /* @__PURE__ */ d("p", { className: "text-muted-foreground", children: [
|
|
1670
|
+
r.found,
|
|
1671
|
+
" ",
|
|
1672
|
+
r.found === 1 ? "match" : "matches"
|
|
1673
|
+
] }),
|
|
1674
|
+
r.truncated === !0 && /* @__PURE__ */ n("p", { className: "text-warning", children: "More matches are available." }),
|
|
1675
|
+
l.map((c, f) => /* @__PURE__ */ d("article", { className: "min-w-0 space-y-2 [overflow-wrap:anywhere]", children: [
|
|
1676
|
+
/* @__PURE__ */ n(Et, { node: c }),
|
|
1677
|
+
typeof c.file == "string" && /* @__PURE__ */ n("code", { className: "block break-all text-[11px] text-muted-foreground", children: c.file }),
|
|
1678
|
+
/* @__PURE__ */ n(Wn, { value: c.hits, renderValue: a }),
|
|
1679
|
+
typeof c.more == "number" && c.more > 0 && /* @__PURE__ */ d("p", { className: "text-warning", children: [
|
|
1680
|
+
c.more,
|
|
1681
|
+
" additional hits"
|
|
1682
|
+
] }),
|
|
1683
|
+
/* @__PURE__ */ n(
|
|
1684
|
+
G,
|
|
1685
|
+
{
|
|
1686
|
+
value: c,
|
|
1687
|
+
omit: [
|
|
1688
|
+
"id",
|
|
1689
|
+
"hits",
|
|
1690
|
+
...typeof c.kind == "string" ? ["kind"] : [],
|
|
1691
|
+
...typeof c.stale == "boolean" ? ["stale"] : [],
|
|
1692
|
+
...typeof c.file == "string" ? ["file"] : [],
|
|
1693
|
+
...typeof c.more == "number" ? ["more"] : []
|
|
1694
|
+
],
|
|
1695
|
+
renderValue: a
|
|
1696
|
+
}
|
|
1697
|
+
)
|
|
1698
|
+
] }, f)),
|
|
1699
|
+
r.unsearched !== void 0 && /* @__PURE__ */ d("div", { className: "text-warning", children: [
|
|
1700
|
+
/* @__PURE__ */ n("p", { className: "mb-1", children: "Some memories were not searched." }),
|
|
1701
|
+
a({ unsearched: r.unsearched })
|
|
1702
|
+
] }),
|
|
1703
|
+
/* @__PURE__ */ n(
|
|
1704
|
+
G,
|
|
1705
|
+
{
|
|
1706
|
+
value: r,
|
|
1707
|
+
omit: [
|
|
1708
|
+
"matches",
|
|
1709
|
+
"unsearched",
|
|
1710
|
+
...typeof r.found == "number" ? ["found"] : [],
|
|
1711
|
+
...typeof r.truncated == "boolean" ? ["truncated"] : []
|
|
1712
|
+
],
|
|
1713
|
+
renderValue: a
|
|
1714
|
+
}
|
|
1715
|
+
)
|
|
1716
|
+
] });
|
|
1717
|
+
}
|
|
1718
|
+
return !t && e === "memory_commit" && r && typeof r.summary == "string" ? /* @__PURE__ */ d("div", { className: "space-y-2", children: [
|
|
1719
|
+
/* @__PURE__ */ n("p", { children: r.summary.replace(/^memory_commit /, "Remembered ") }),
|
|
1720
|
+
r.ids !== void 0 && a({ "Memory IDs": r.ids }),
|
|
1721
|
+
/* @__PURE__ */ n(G, { value: r, omit: ["summary", "ids"], renderValue: a })
|
|
1722
|
+
] }) : s !== void 0 ? a(s) : /* @__PURE__ */ n("div", { className: "whitespace-pre-wrap [overflow-wrap:anywhere]", children: o || "(empty)" });
|
|
1723
|
+
}
|
|
1724
|
+
const Hn = {
|
|
1725
|
+
memory: dt,
|
|
1726
|
+
file: sr,
|
|
1727
|
+
command: nr,
|
|
1728
|
+
web: rr,
|
|
1729
|
+
agent: tr,
|
|
1730
|
+
mcp: er,
|
|
1731
|
+
other: Qt
|
|
1732
|
+
};
|
|
1733
|
+
function zt({
|
|
1734
|
+
className: e,
|
|
1735
|
+
children: t
|
|
1736
|
+
}) {
|
|
1737
|
+
return /* @__PURE__ */ d("div", { className: k("relative ml-[7px] pl-2", e), children: [
|
|
1738
|
+
/* @__PURE__ */ n(
|
|
1739
|
+
"span",
|
|
1740
|
+
{
|
|
1741
|
+
"aria-hidden": !0,
|
|
1742
|
+
className: "absolute -top-1 left-0 h-4 w-3 rounded-bl-lg border-b border-l border-border"
|
|
1743
|
+
}
|
|
1744
|
+
),
|
|
1745
|
+
t
|
|
1746
|
+
] });
|
|
1747
|
+
}
|
|
1748
|
+
function Qe({
|
|
1749
|
+
payload: e,
|
|
1750
|
+
raw: t,
|
|
1751
|
+
markdown: s,
|
|
1752
|
+
receiving: i,
|
|
1753
|
+
tool: a
|
|
1754
|
+
}) {
|
|
1755
|
+
return /* @__PURE__ */ d(_e, { children: [
|
|
1756
|
+
e.omitted !== void 0 ? /* @__PURE__ */ d("p", { className: "mb-2 text-warning", children: [
|
|
1757
|
+
"Output truncated: ",
|
|
1758
|
+
e.omitted.toLocaleString(),
|
|
1759
|
+
" more characters were not sent.",
|
|
1760
|
+
e.incomplete && " Showing only the available prefix."
|
|
1761
|
+
] }) : e.incomplete ? /* @__PURE__ */ n("p", { className: "mb-2 text-muted-foreground", children: i ? "Receiving arguments..." : "Incomplete or invalid JSON. Only the available content is shown." }) : null,
|
|
1762
|
+
t ? /* @__PURE__ */ n(
|
|
1763
|
+
V,
|
|
1764
|
+
{
|
|
1765
|
+
code: e.raw || "(empty)",
|
|
1766
|
+
lang: e.incomplete ? void 0 : "json"
|
|
1767
|
+
}
|
|
1768
|
+
) : (a == null ? void 0 : a.family) === "memory" && !e.incomplete ? /* @__PURE__ */ n(
|
|
1769
|
+
Bn,
|
|
1770
|
+
{
|
|
1771
|
+
name: a.name,
|
|
1772
|
+
input: a.input,
|
|
1773
|
+
value: e.value,
|
|
1774
|
+
text: e.raw,
|
|
1775
|
+
renderValue: (r) => /* @__PURE__ */ n(P, { value: r })
|
|
1776
|
+
}
|
|
1777
|
+
) : (a == null ? void 0 : a.family) === "mcp" && e.value !== void 0 ? /* @__PURE__ */ n(
|
|
1778
|
+
Dn,
|
|
1779
|
+
{
|
|
1780
|
+
name: a.name,
|
|
1781
|
+
input: a.input,
|
|
1782
|
+
value: e.value,
|
|
1783
|
+
args: a.args,
|
|
1784
|
+
partial: e.incomplete || e.omitted !== void 0
|
|
1785
|
+
}
|
|
1786
|
+
) : a && e.value !== void 0 ? /* @__PURE__ */ n(
|
|
1787
|
+
_t,
|
|
1788
|
+
{
|
|
1789
|
+
name: a.name,
|
|
1790
|
+
input: a.input,
|
|
1791
|
+
value: e.value,
|
|
1792
|
+
args: a.args,
|
|
1793
|
+
partial: e.incomplete || e.omitted !== void 0
|
|
1794
|
+
}
|
|
1795
|
+
) : e.value !== void 0 ? /* @__PURE__ */ n(P, { value: e.value }) : e.incomplete ? /* @__PURE__ */ n(V, { code: e.raw }) : s ? /* @__PURE__ */ n(ce, { children: e.raw }) : /* @__PURE__ */ n("div", { className: "whitespace-pre-wrap break-words [overflow-wrap:anywhere]", children: e.raw || "(empty)" })
|
|
1796
|
+
] });
|
|
1797
|
+
}
|
|
1798
|
+
function Fn({
|
|
1799
|
+
item: e,
|
|
1800
|
+
running: t
|
|
1801
|
+
}) {
|
|
1802
|
+
const [s, i] = O(!1), [a, r] = O(!1), o = ne(() => Ze(e.args), [e.args]), l = ne(
|
|
1803
|
+
() => e.result === void 0 ? void 0 : Ze(e.result),
|
|
1804
|
+
[e.result]
|
|
1805
|
+
), { title: c, family: f, preview: p } = On(e.name, o, l), u = t && l === void 0 && (o.incomplete || !e.args.trim()), m = I(o.value), h = !u && !o.incomplete && (!e.args.trim() || m !== void 0 && !Object.keys(m).length), x = jn(l, e.isError, t), v = Hn[f], S = e.interrupt && !e.interrupt.ended && l === void 0, w = /* @__PURE__ */ d(
|
|
1806
|
+
"details",
|
|
1807
|
+
{
|
|
1808
|
+
className: "group min-w-0 text-xs",
|
|
1809
|
+
onToggle: (N) => i(N.currentTarget.open),
|
|
1810
|
+
children: [
|
|
1811
|
+
/* @__PURE__ */ d("summary", { className: "group/row flex min-w-0 cursor-pointer list-none items-center gap-2 -mx-1.5 rounded-sm px-1.5 py-1.5 text-muted-foreground outline-none hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground [&::-webkit-details-marker]:hidden", children: [
|
|
1812
|
+
/* @__PURE__ */ n(v, { className: "size-3.5 shrink-0 text-muted-foreground" }),
|
|
1813
|
+
/* @__PURE__ */ n("span", { className: "max-w-[40%] shrink-0 truncate", title: e.name, children: c }),
|
|
1814
|
+
/* @__PURE__ */ n(
|
|
1815
|
+
"span",
|
|
1816
|
+
{
|
|
1817
|
+
className: k(
|
|
1818
|
+
"min-w-0 flex-1 truncate text-muted-foreground",
|
|
1819
|
+
(f === "command" || f === "file") && "font-mono"
|
|
1820
|
+
),
|
|
1821
|
+
title: p,
|
|
1822
|
+
children: p || (u ? "Receiving arguments..." : "")
|
|
1823
|
+
}
|
|
1824
|
+
),
|
|
1825
|
+
/* @__PURE__ */ d(
|
|
1826
|
+
"span",
|
|
1827
|
+
{
|
|
1828
|
+
className: k(
|
|
1829
|
+
"ml-auto flex shrink-0 items-center gap-1 text-[11px]",
|
|
1830
|
+
x.tone === "danger" ? "text-danger" : x.tone === "warning" ? "text-warning" : "text-muted-foreground"
|
|
1831
|
+
),
|
|
1832
|
+
children: [
|
|
1833
|
+
S ? null : x.pending ? /* @__PURE__ */ n(ge, { className: "size-3 animate-spin" }) : x.tone === "success" ? /* @__PURE__ */ n(Re, { className: "size-3" }) : null,
|
|
1834
|
+
/* @__PURE__ */ n("span", { children: S ? "Paused" : x.label })
|
|
1835
|
+
]
|
|
1836
|
+
}
|
|
1837
|
+
),
|
|
1838
|
+
/* @__PURE__ */ n(ut, { className: "size-3.5 shrink-0 text-muted-foreground opacity-0 transition group-open:rotate-90 group-open:opacity-100 group-hover/row:opacity-100 group-focus-visible/row:opacity-100" })
|
|
1839
|
+
] }),
|
|
1840
|
+
s && /* @__PURE__ */ d(zt, { className: "my-1", children: [
|
|
1841
|
+
/* @__PURE__ */ d("div", { className: "flex items-center justify-between gap-2 py-1.5 pl-3 text-[11px] text-muted-foreground", children: [
|
|
1842
|
+
/* @__PURE__ */ n("span", { className: "min-w-0 truncate font-mono", children: e.name }),
|
|
1843
|
+
/* @__PURE__ */ n(
|
|
1844
|
+
"button",
|
|
1845
|
+
{
|
|
1846
|
+
type: "button",
|
|
1847
|
+
"aria-label": "Show raw arguments and result",
|
|
1848
|
+
"aria-pressed": a,
|
|
1849
|
+
className: k("shrink-0 cursor-pointer rounded-sm outline-none"),
|
|
1850
|
+
onClick: () => r(!a),
|
|
1851
|
+
children: "Raw"
|
|
1852
|
+
}
|
|
1853
|
+
)
|
|
1854
|
+
] }),
|
|
1855
|
+
!h && /* @__PURE__ */ d("section", { className: "px-3 pb-3", "aria-label": "Arguments", children: [
|
|
1856
|
+
/* @__PURE__ */ n("h4", { className: "mb-2 text-[11px] font-semibold text-muted-foreground", children: "Arguments" }),
|
|
1857
|
+
/* @__PURE__ */ n("div", { className: "max-h-64 overflow-auto", children: /* @__PURE__ */ n(
|
|
1858
|
+
Qe,
|
|
1859
|
+
{
|
|
1860
|
+
payload: o,
|
|
1861
|
+
raw: a,
|
|
1862
|
+
receiving: t && l === void 0,
|
|
1863
|
+
tool: {
|
|
1864
|
+
name: e.name,
|
|
1865
|
+
family: f,
|
|
1866
|
+
input: !0,
|
|
1867
|
+
args: o.value
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
) })
|
|
1871
|
+
] }),
|
|
1872
|
+
/* @__PURE__ */ d("section", { className: "px-3 pb-3", "aria-label": "Result", children: [
|
|
1873
|
+
/* @__PURE__ */ n("h4", { className: "mb-2 text-[11px] font-semibold text-muted-foreground", children: "Result" }),
|
|
1874
|
+
/* @__PURE__ */ n("div", { className: "max-h-80 overflow-auto", children: l ? /* @__PURE__ */ n(
|
|
1875
|
+
Qe,
|
|
1876
|
+
{
|
|
1877
|
+
payload: l,
|
|
1878
|
+
raw: a,
|
|
1879
|
+
markdown: e.name === "fork",
|
|
1880
|
+
tool: {
|
|
1881
|
+
name: e.name,
|
|
1882
|
+
family: f,
|
|
1883
|
+
input: !1,
|
|
1884
|
+
args: o.value
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
) : /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: t ? "Waiting for result..." : "No result was received." }) })
|
|
1888
|
+
] })
|
|
1889
|
+
] })
|
|
1890
|
+
]
|
|
1891
|
+
}
|
|
1892
|
+
);
|
|
1893
|
+
return e.interrupt ? /* @__PURE__ */ d("div", { className: "min-w-0", children: [
|
|
1894
|
+
w,
|
|
1895
|
+
/* @__PURE__ */ n(Cn, { interrupt: e.interrupt })
|
|
1896
|
+
] }) : w;
|
|
1897
|
+
}
|
|
1898
|
+
function qn(e) {
|
|
1899
|
+
const t = /* @__PURE__ */ new Map();
|
|
1900
|
+
let s, i;
|
|
1901
|
+
for (const a of e)
|
|
1902
|
+
if (a.kind === "assistant") {
|
|
1903
|
+
if (a.subagent) {
|
|
1904
|
+
const r = [a.agent, a.branch].filter((o, l, c) => o && c.indexOf(o) === l).join(" · ");
|
|
1905
|
+
i !== a.subagent && t.set(a.id, r || "Subagent");
|
|
1906
|
+
} else a.agent && ((s && s !== a.agent || i && s) && t.set(a.id, a.agent), s = a.agent);
|
|
1907
|
+
i = a.subagent;
|
|
1908
|
+
}
|
|
1909
|
+
return t;
|
|
1910
|
+
}
|
|
1911
|
+
function et(e, t) {
|
|
1912
|
+
const s = (i) => i.kind === "tool" || i.kind === "reasoning";
|
|
1913
|
+
return s(e) && s(t) ? "" : "mt-3";
|
|
1914
|
+
}
|
|
1915
|
+
const At = (e) => e.kind === "tool" || e.kind === "reasoning";
|
|
1916
|
+
function Un(e) {
|
|
1917
|
+
let t = e.length;
|
|
1918
|
+
for (; t > 0 && e[t - 1].item.kind === "assistant"; ) t--;
|
|
1919
|
+
const s = e.slice(t), i = e.findIndex(({ item: o }) => o.kind !== "user"), a = i < 0 ? [] : e.slice(i, t);
|
|
1920
|
+
return a.some(({ item: o }) => At(o)) && s.some(({ item: o }) => o.kind === "assistant" && o.text.trim() !== "") && !a.some(({ item: o }) => o.kind === "tool" && o.interrupt && !o.interrupt.ended) ? { before: e.slice(0, i), steps: a, answer: s } : { before: e, steps: [], answer: [] };
|
|
1921
|
+
}
|
|
1922
|
+
function Jn({
|
|
1923
|
+
count: e,
|
|
1924
|
+
className: t,
|
|
1925
|
+
children: s
|
|
1926
|
+
}) {
|
|
1927
|
+
const [i, a] = O(!1);
|
|
1928
|
+
return /* @__PURE__ */ d("div", { className: t, children: [
|
|
1929
|
+
/* @__PURE__ */ d(
|
|
1930
|
+
"button",
|
|
1931
|
+
{
|
|
1932
|
+
type: "button",
|
|
1933
|
+
"aria-expanded": i,
|
|
1934
|
+
onClick: () => a(!i),
|
|
1935
|
+
className: k(
|
|
1936
|
+
"-mx-1.5 flex cursor-pointer items-center gap-1.5 rounded-sm px-1.5 py-1.5 text-sm outline-none hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground",
|
|
1937
|
+
i ? "text-foreground" : "text-muted-foreground"
|
|
1938
|
+
),
|
|
1939
|
+
children: [
|
|
1940
|
+
"Completed ",
|
|
1941
|
+
e,
|
|
1942
|
+
" ",
|
|
1943
|
+
e === 1 ? "step" : "steps",
|
|
1944
|
+
i ? /* @__PURE__ */ n(ct, { className: "size-4" }) : /* @__PURE__ */ n(ut, { className: "size-4" })
|
|
1945
|
+
]
|
|
1946
|
+
}
|
|
1947
|
+
),
|
|
1948
|
+
i && /* @__PURE__ */ n("div", { className: "mb-1 ml-1.5 border-l border-border pl-3", children: s })
|
|
1949
|
+
] });
|
|
1950
|
+
}
|
|
1951
|
+
function Kn({ item: e, running: t, agent: s }) {
|
|
1952
|
+
switch (e.kind) {
|
|
1953
|
+
case "user":
|
|
1954
|
+
return /* @__PURE__ */ d(
|
|
1955
|
+
"div",
|
|
1956
|
+
{
|
|
1957
|
+
className: "group/msg relative ml-auto flex w-fit max-w-[80%] flex-col items-end gap-1.5",
|
|
1958
|
+
onCopy: Fe,
|
|
1959
|
+
children: [
|
|
1960
|
+
e.attachments && /* @__PURE__ */ n(Yn, { files: e.attachments }),
|
|
1961
|
+
(e.text || !e.attachments) && /* @__PURE__ */ n(qr, { className: "max-w-full rounded-xl bg-accent px-3 py-2 text-sm whitespace-pre-wrap [overflow-wrap:anywhere]", children: e.text }),
|
|
1962
|
+
e.text && /* @__PURE__ */ n(
|
|
1963
|
+
Le,
|
|
1964
|
+
{
|
|
1965
|
+
text: e.text,
|
|
1966
|
+
label: "Copy message",
|
|
1967
|
+
className: k("absolute bottom-1 right-full mr-1", qe)
|
|
1968
|
+
}
|
|
1969
|
+
)
|
|
1970
|
+
]
|
|
1971
|
+
}
|
|
1972
|
+
);
|
|
1973
|
+
case "assistant":
|
|
1974
|
+
return /* @__PURE__ */ d("div", { className: "group/msg relative min-w-0", onCopy: Fe, children: [
|
|
1975
|
+
s && /* @__PURE__ */ n("div", { className: "mb-1 text-xs text-muted-foreground", children: s }),
|
|
1976
|
+
/* @__PURE__ */ n(ce, { className: "text-sm", children: e.text }),
|
|
1977
|
+
e.text && // Over the end of the last line, so it takes no height of its own.
|
|
1978
|
+
/* @__PURE__ */ n(
|
|
1979
|
+
Le,
|
|
1980
|
+
{
|
|
1981
|
+
text: e.text,
|
|
1982
|
+
label: "Copy message",
|
|
1983
|
+
className: k(
|
|
1984
|
+
"absolute bottom-0 right-0 bg-background",
|
|
1985
|
+
qe
|
|
1986
|
+
)
|
|
1987
|
+
}
|
|
1988
|
+
)
|
|
1989
|
+
] });
|
|
1990
|
+
case "reasoning":
|
|
1991
|
+
return /* @__PURE__ */ d("details", { className: "group text-xs text-muted-foreground", children: [
|
|
1992
|
+
/* @__PURE__ */ d("summary", { className: "-mx-1.5 flex cursor-pointer list-none items-center gap-1.5 rounded-sm px-1.5 py-1.5 outline-none hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground [&::-webkit-details-marker]:hidden", children: [
|
|
1993
|
+
/* @__PURE__ */ n(dt, { className: "size-3.5" }),
|
|
1994
|
+
"Thinking"
|
|
1995
|
+
] }),
|
|
1996
|
+
/* @__PURE__ */ n(zt, { className: "mb-1", children: /* @__PURE__ */ n("div", { className: "whitespace-pre-wrap pl-3", children: e.text }) })
|
|
1997
|
+
] });
|
|
1998
|
+
case "error":
|
|
1999
|
+
return /* @__PURE__ */ n("div", { className: "rounded-md border border-danger/40 px-3 py-2 text-sm text-danger", children: e.text });
|
|
2000
|
+
case "tool":
|
|
2001
|
+
return /* @__PURE__ */ n(Fn, { item: e, running: t });
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
function Xn({
|
|
2005
|
+
items: e,
|
|
2006
|
+
running: t,
|
|
2007
|
+
interrupts: s,
|
|
2008
|
+
turnFooter: i
|
|
2009
|
+
}) {
|
|
2010
|
+
var m, h;
|
|
2011
|
+
const a = ne(() => qn(e), [e]), r = ne(() => {
|
|
2012
|
+
const x = [];
|
|
2013
|
+
return e.forEach((v, S) => {
|
|
2014
|
+
(v.kind === "user" || x.length === 0) && x.push({ key: v.kind === "user" ? v.id : "head", rows: [] }), x.at(-1).rows.push({ item: v, index: S });
|
|
2015
|
+
}), x;
|
|
2016
|
+
}, [e]), o = (m = e.findLast((x) => x.kind === "user")) == null ? void 0 : m.id, l = W(null), c = W(null), f = W(void 0), p = W(void 0), u = (h = e[0]) == null ? void 0 : h.id;
|
|
2017
|
+
return ze(() => {
|
|
2018
|
+
var v, S, w;
|
|
2019
|
+
const x = f.current;
|
|
2020
|
+
f.current = o, u !== p.current ? (p.current = u, t && o ? (v = l.current) == null || v.scrollIntoView({ block: "start", behavior: "instant" }) : (S = c.current) == null || S.scrollIntoView({ block: "end", behavior: "instant" })) : t && o && o !== x && ((w = l.current) == null || w.scrollIntoView({ block: "start", behavior: "smooth" }));
|
|
2021
|
+
}, [u, o, t]), /* @__PURE__ */ n(wt.Provider, { value: s ?? null, children: /* @__PURE__ */ d("div", { className: "mx-auto flex w-full max-w-5xl flex-col p-4", children: [
|
|
2022
|
+
r.map((x, v) => {
|
|
2023
|
+
var g;
|
|
2024
|
+
const S = v === r.length - 1, w = S && t ? { before: x.rows, steps: [], answer: [] } : Un(x.rows), N = (z, A = !1) => z.map(({ item: _, index: D }) => /* @__PURE__ */ n(
|
|
2025
|
+
"div",
|
|
2026
|
+
{
|
|
2027
|
+
className: k(
|
|
2028
|
+
"min-w-0",
|
|
2029
|
+
D > 0 && !A && _.kind !== "user" && et(e[D - 1], _),
|
|
2030
|
+
// Folded steps are evenly spaced, remarks as tall as a step row.
|
|
2031
|
+
A && _.kind === "assistant" && "py-1.5"
|
|
2032
|
+
),
|
|
2033
|
+
children: /* @__PURE__ */ n(Kn, { item: _, running: t, agent: a.get(_.id) })
|
|
2034
|
+
},
|
|
2035
|
+
`${_.kind}:${_.id}`
|
|
2036
|
+
));
|
|
2037
|
+
return (
|
|
2038
|
+
// The last turn is tall enough to scroll its message up to the top.
|
|
2039
|
+
/* @__PURE__ */ d(
|
|
2040
|
+
"div",
|
|
2041
|
+
{
|
|
2042
|
+
ref: S && x.rows[0].item.kind === "user" ? l : void 0,
|
|
2043
|
+
className: k(
|
|
2044
|
+
"flex flex-col scroll-mt-4",
|
|
2045
|
+
v > 0 && "mt-6",
|
|
2046
|
+
S && "min-h-[var(--chat-turn-min,calc(100cqh-var(--chat-turn-gap,2rem)))]"
|
|
2047
|
+
),
|
|
2048
|
+
children: [
|
|
2049
|
+
N(w.before),
|
|
2050
|
+
w.steps.length > 0 && /* @__PURE__ */ n(
|
|
2051
|
+
Jn,
|
|
2052
|
+
{
|
|
2053
|
+
count: w.steps.filter(({ item: z }) => At(z)).length,
|
|
2054
|
+
className: w.steps[0].index > 0 ? et(
|
|
2055
|
+
e[w.steps[0].index - 1],
|
|
2056
|
+
w.steps[0].item
|
|
2057
|
+
) : void 0,
|
|
2058
|
+
children: N(w.steps, !0)
|
|
2059
|
+
},
|
|
2060
|
+
`steps:${w.steps[0].item.id}`
|
|
2061
|
+
),
|
|
2062
|
+
N(w.answer),
|
|
2063
|
+
S && t && ((g = e.at(-1)) == null ? void 0 : g.kind) === "user" && /* @__PURE__ */ n(ge, { className: "mt-4 size-4 animate-spin text-muted-foreground" }),
|
|
2064
|
+
i && x.rows[0].item.kind === "user" && /* @__PURE__ */ n("div", { className: "mt-2 min-w-0", children: i({
|
|
2065
|
+
runId: x.rows[0].item.runId,
|
|
2066
|
+
answering: S && t
|
|
2067
|
+
}) })
|
|
2068
|
+
]
|
|
2069
|
+
},
|
|
2070
|
+
x.key
|
|
2071
|
+
)
|
|
2072
|
+
);
|
|
2073
|
+
}),
|
|
2074
|
+
/* @__PURE__ */ n("div", { ref: c })
|
|
2075
|
+
] }) });
|
|
2076
|
+
}
|
|
2077
|
+
function Zn({
|
|
2078
|
+
title: e,
|
|
2079
|
+
nudge: t = 0,
|
|
2080
|
+
variants: s
|
|
2081
|
+
}) {
|
|
2082
|
+
const i = s != null && s.length ? Gn(s, t) : void 0, a = (i == null ? void 0 : i.title) ?? "Start your chat here", r = i ? i.subtitle : e;
|
|
2083
|
+
return /* @__PURE__ */ n("div", { className: "flex flex-1 flex-col items-center justify-center gap-2 p-6 text-center", children: /* @__PURE__ */ d("div", { className: "empty-chat-nudge flex flex-col items-center gap-2", children: [
|
|
2084
|
+
/* @__PURE__ */ n(ir, { className: "size-8 text-muted-foreground" }),
|
|
2085
|
+
/* @__PURE__ */ n("h2", { className: "text-xl font-semibold", children: a }),
|
|
2086
|
+
r && /* @__PURE__ */ n("p", { className: "text-sm text-muted-foreground", children: r })
|
|
2087
|
+
] }, t) });
|
|
2088
|
+
}
|
|
2089
|
+
function Gn(e, t) {
|
|
2090
|
+
const s = e[(t % e.length + e.length) % e.length];
|
|
2091
|
+
return typeof s == "string" ? { title: s } : s;
|
|
2092
|
+
}
|
|
2093
|
+
function Lt(e) {
|
|
2094
|
+
if (e < 1024) return `${e} B`;
|
|
2095
|
+
const t = ["KB", "MB", "GB"];
|
|
2096
|
+
let s = e / 1024, i = 0;
|
|
2097
|
+
for (; s >= 1024 && i < t.length - 1; )
|
|
2098
|
+
s /= 1024, i++;
|
|
2099
|
+
return `${s >= 10 ? Math.round(s) : Math.round(s * 10) / 10} ${t[i]}`;
|
|
2100
|
+
}
|
|
2101
|
+
const Ot = "flex max-w-64 min-w-0 items-center gap-1.5 rounded-lg border border-border bg-background px-2 py-1 text-xs";
|
|
2102
|
+
function Yn({ files: e }) {
|
|
2103
|
+
return /* @__PURE__ */ n("ul", { className: "flex flex-wrap justify-end gap-1.5", "aria-label": "Attached files", children: e.map((t, s) => /* @__PURE__ */ d("li", { className: Ot, title: t.path ?? t.name, children: [
|
|
2104
|
+
/* @__PURE__ */ n(mt, { className: "size-3.5 shrink-0 text-muted-foreground" }),
|
|
2105
|
+
/* @__PURE__ */ n("span", { className: "truncate", children: t.name }),
|
|
2106
|
+
t.size !== void 0 && /* @__PURE__ */ n("span", { className: "shrink-0 text-muted-foreground", children: Lt(t.size) })
|
|
2107
|
+
] }, `${t.name}-${s}`)) });
|
|
2108
|
+
}
|
|
2109
|
+
function Vn({
|
|
2110
|
+
file: e,
|
|
2111
|
+
onRemove: t,
|
|
2112
|
+
onRetry: s
|
|
2113
|
+
}) {
|
|
2114
|
+
const i = e.size ? Math.min(100, Math.round(e.sent / e.size * 100)) : 100;
|
|
2115
|
+
return /* @__PURE__ */ d(
|
|
2116
|
+
"li",
|
|
2117
|
+
{
|
|
2118
|
+
className: k(
|
|
2119
|
+
Ot,
|
|
2120
|
+
"relative overflow-hidden",
|
|
2121
|
+
e.status === "error" && "border-danger"
|
|
2122
|
+
),
|
|
2123
|
+
title: e.error ?? e.name,
|
|
2124
|
+
children: [
|
|
2125
|
+
e.status === "uploading" ? /* @__PURE__ */ n(ge, { className: "size-3.5 shrink-0 animate-spin text-muted-foreground" }) : /* @__PURE__ */ n(mt, { className: "size-3.5 shrink-0 text-muted-foreground" }),
|
|
2126
|
+
/* @__PURE__ */ n("span", { className: "truncate", children: e.name }),
|
|
2127
|
+
/* @__PURE__ */ n(
|
|
2128
|
+
"span",
|
|
2129
|
+
{
|
|
2130
|
+
className: k(
|
|
2131
|
+
"shrink-0",
|
|
2132
|
+
e.status === "error" ? "text-danger" : "text-muted-foreground"
|
|
2133
|
+
),
|
|
2134
|
+
children: e.status === "uploading" ? `${i}%` : e.status === "error" ? "failed" : Lt(e.size)
|
|
2135
|
+
}
|
|
2136
|
+
),
|
|
2137
|
+
e.status === "error" && /* @__PURE__ */ n(
|
|
2138
|
+
"button",
|
|
2139
|
+
{
|
|
2140
|
+
type: "button",
|
|
2141
|
+
onClick: s,
|
|
2142
|
+
"aria-label": `Upload ${e.name} again`,
|
|
2143
|
+
className: "shrink-0 cursor-pointer text-muted-foreground hover:text-foreground",
|
|
2144
|
+
children: /* @__PURE__ */ n(cr, { className: "size-3.5" })
|
|
2145
|
+
}
|
|
2146
|
+
),
|
|
2147
|
+
/* @__PURE__ */ n(
|
|
2148
|
+
"button",
|
|
2149
|
+
{
|
|
2150
|
+
type: "button",
|
|
2151
|
+
onClick: t,
|
|
2152
|
+
"aria-label": `Remove ${e.name}`,
|
|
2153
|
+
className: "shrink-0 cursor-pointer text-muted-foreground hover:text-foreground",
|
|
2154
|
+
children: /* @__PURE__ */ n(dr, { className: "size-3.5" })
|
|
2155
|
+
}
|
|
2156
|
+
),
|
|
2157
|
+
e.status === "uploading" && /* @__PURE__ */ n(
|
|
2158
|
+
"span",
|
|
2159
|
+
{
|
|
2160
|
+
className: "absolute bottom-0 left-0 h-0.5 bg-primary transition-[width]",
|
|
2161
|
+
style: { width: `${i}%` },
|
|
2162
|
+
"aria-hidden": "true"
|
|
2163
|
+
}
|
|
2164
|
+
)
|
|
2165
|
+
]
|
|
2166
|
+
}
|
|
2167
|
+
);
|
|
2168
|
+
}
|
|
2169
|
+
const Se = (e) => Array.from(e.dataTransfer.types).includes("Files");
|
|
2170
|
+
function Qn(e) {
|
|
2171
|
+
return /* @__PURE__ */ n(es, { ...e }, e.draftKey ?? "");
|
|
2172
|
+
}
|
|
2173
|
+
function es({
|
|
2174
|
+
disabled: e,
|
|
2175
|
+
running: t,
|
|
2176
|
+
placeholder: s,
|
|
2177
|
+
historyKey: i,
|
|
2178
|
+
draftKey: a,
|
|
2179
|
+
focusSignal: r,
|
|
2180
|
+
fill: o,
|
|
2181
|
+
attachments: l,
|
|
2182
|
+
onSend: c,
|
|
2183
|
+
onStop: f
|
|
2184
|
+
}) {
|
|
2185
|
+
const [p, u] = O(() => a ? kn(a) : ""), m = l != null && l.supported ? l : void 0, h = W(null), [x, v] = O(0), S = !!(m != null && m.files.some((b) => b.status === "done")), w = !e && !t && (!!p.trim() || S) && ((m == null ? void 0 : m.ready) ?? !0);
|
|
2186
|
+
T(() => {
|
|
2187
|
+
a && Je(a, p);
|
|
2188
|
+
}, [a, p]);
|
|
2189
|
+
const N = wn(() => i ? vt(i) : []), g = W(null), z = W(null), A = le(
|
|
2190
|
+
(b) => pn(g.current, b),
|
|
2191
|
+
[]
|
|
2192
|
+
);
|
|
2193
|
+
T(() => {
|
|
2194
|
+
e || A();
|
|
2195
|
+
}, [e, A]), T(() => {
|
|
2196
|
+
r && A();
|
|
2197
|
+
}, [r, A]), T(() => {
|
|
2198
|
+
o && (u(o.text), A());
|
|
2199
|
+
}, [o, A]);
|
|
2200
|
+
const _ = W(t);
|
|
2201
|
+
T(() => {
|
|
2202
|
+
_.current && !t && A(z.current), _.current = t;
|
|
2203
|
+
}, [t, A]), ze(() => {
|
|
2204
|
+
const b = g.current;
|
|
2205
|
+
b && (b.style.height = "auto", b.style.height = `${b.scrollHeight}px`);
|
|
2206
|
+
}, [p]);
|
|
2207
|
+
const D = (b) => {
|
|
2208
|
+
if (b == null || b.preventDefault(), !w) return;
|
|
2209
|
+
const H = (m == null ? void 0 : m.take()) ?? [];
|
|
2210
|
+
c(p, H.length ? H : void 0), i && p.trim() && bn(i, p), N.reset(), a && Je(a, ""), u(""), A(z.current);
|
|
2211
|
+
}, $ = (b) => {
|
|
2212
|
+
b.key === "Enter" && !b.shiftKey && !b.nativeEvent.isComposing ? D(b) : i && N.onKeyDown(b, p, u);
|
|
2213
|
+
}, U = (b) => {
|
|
2214
|
+
!m || e || !b.clipboardData.files.length || (b.preventDefault(), m.add(Array.from(b.clipboardData.files)));
|
|
2215
|
+
};
|
|
2216
|
+
return /* @__PURE__ */ n("form", { ref: z, onSubmit: D, className: "mx-auto w-full max-w-5xl p-4", ...m && !e && {
|
|
2217
|
+
onDragEnter: (b) => {
|
|
2218
|
+
Se(b) && (b.preventDefault(), v((H) => H + 1));
|
|
2219
|
+
},
|
|
2220
|
+
onDragOver: (b) => {
|
|
2221
|
+
Se(b) && (b.preventDefault(), b.dataTransfer.dropEffect = "copy");
|
|
2222
|
+
},
|
|
2223
|
+
onDragLeave: (b) => {
|
|
2224
|
+
Se(b) && v((H) => Math.max(0, H - 1));
|
|
2225
|
+
},
|
|
2226
|
+
onDrop: (b) => {
|
|
2227
|
+
Se(b) && (b.preventDefault(), v(0), m.add(Array.from(b.dataTransfer.files)), A(z.current));
|
|
2228
|
+
}
|
|
2229
|
+
}, children: /* @__PURE__ */ d(
|
|
2230
|
+
"div",
|
|
2231
|
+
{
|
|
2232
|
+
className: k(
|
|
2233
|
+
"thinking-border flex flex-col gap-2 rounded-xl border border-input bg-surface-input p-2",
|
|
2234
|
+
x > 0 && "border-primary ring-2 ring-primary/40"
|
|
2235
|
+
),
|
|
2236
|
+
"data-thinking": t,
|
|
2237
|
+
children: [
|
|
2238
|
+
m && m.files.length > 0 && /* @__PURE__ */ n("ul", { className: "flex flex-wrap gap-1.5", "aria-label": "Files to send", children: m.files.map((b) => /* @__PURE__ */ n(
|
|
2239
|
+
Vn,
|
|
2240
|
+
{
|
|
2241
|
+
file: b,
|
|
2242
|
+
onRemove: () => m.remove(b.key),
|
|
2243
|
+
onRetry: () => m.retry(b.key)
|
|
2244
|
+
},
|
|
2245
|
+
b.key
|
|
2246
|
+
)) }),
|
|
2247
|
+
(m == null ? void 0 : m.notice) && /* @__PURE__ */ n("p", { className: "px-1 text-xs text-danger", children: m.notice }),
|
|
2248
|
+
/* @__PURE__ */ d("div", { className: "flex items-end gap-2", children: [
|
|
2249
|
+
m && /* @__PURE__ */ d(_e, { children: [
|
|
2250
|
+
/* @__PURE__ */ n(
|
|
2251
|
+
"input",
|
|
2252
|
+
{
|
|
2253
|
+
ref: h,
|
|
2254
|
+
type: "file",
|
|
2255
|
+
multiple: !0,
|
|
2256
|
+
hidden: !0,
|
|
2257
|
+
onChange: (b) => {
|
|
2258
|
+
var H;
|
|
2259
|
+
(H = b.target.files) != null && H.length && m.add(Array.from(b.target.files)), b.target.value = "";
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
),
|
|
2263
|
+
/* @__PURE__ */ n(be, { label: "Attach files", className: "zenera-chat", children: /* @__PURE__ */ n(
|
|
2264
|
+
re,
|
|
2265
|
+
{
|
|
2266
|
+
type: "button",
|
|
2267
|
+
size: "icon",
|
|
2268
|
+
variant: "ghost",
|
|
2269
|
+
disabled: e,
|
|
2270
|
+
onClick: () => {
|
|
2271
|
+
var b;
|
|
2272
|
+
return (b = h.current) == null ? void 0 : b.click();
|
|
2273
|
+
},
|
|
2274
|
+
"aria-label": "Attach files",
|
|
2275
|
+
children: /* @__PURE__ */ n(ar, {})
|
|
2276
|
+
}
|
|
2277
|
+
) })
|
|
2278
|
+
] }),
|
|
2279
|
+
/* @__PURE__ */ n(
|
|
2280
|
+
yt,
|
|
2281
|
+
{
|
|
2282
|
+
onPaste: U,
|
|
2283
|
+
ref: g,
|
|
2284
|
+
disabled: e,
|
|
2285
|
+
rows: 1,
|
|
2286
|
+
value: p,
|
|
2287
|
+
onChange: (b) => u(b.target.value),
|
|
2288
|
+
onKeyDown: $,
|
|
2289
|
+
placeholder: s,
|
|
2290
|
+
className: "max-h-60 min-h-9 resize-none overflow-y-auto border-0 bg-transparent leading-5 focus-visible:ring-0"
|
|
2291
|
+
}
|
|
2292
|
+
),
|
|
2293
|
+
t ? /* @__PURE__ */ n(be, { label: "Stop", className: "zenera-chat", children: /* @__PURE__ */ n(
|
|
2294
|
+
re,
|
|
2295
|
+
{
|
|
2296
|
+
type: "button",
|
|
2297
|
+
size: "icon",
|
|
2298
|
+
variant: "outline",
|
|
2299
|
+
onClick: () => {
|
|
2300
|
+
f(), A(z.current);
|
|
2301
|
+
},
|
|
2302
|
+
"aria-label": "Stop",
|
|
2303
|
+
children: /* @__PURE__ */ n(or, {})
|
|
2304
|
+
}
|
|
2305
|
+
) }) : /* @__PURE__ */ n(be, { label: "Send (Enter)", className: "zenera-chat", children: /* @__PURE__ */ n(
|
|
2306
|
+
re,
|
|
2307
|
+
{
|
|
2308
|
+
type: "submit",
|
|
2309
|
+
size: "icon",
|
|
2310
|
+
disabled: !w,
|
|
2311
|
+
"aria-label": "Send",
|
|
2312
|
+
className: k(!w && "opacity-60"),
|
|
2313
|
+
children: /* @__PURE__ */ n(lr, {})
|
|
2314
|
+
}
|
|
2315
|
+
) })
|
|
2316
|
+
] }),
|
|
2317
|
+
t && /* @__PURE__ */ n("span", { className: "thinking-border-ring", "aria-hidden": "true", children: /* @__PURE__ */ n("span", { className: "thinking-border-fill" }) })
|
|
2318
|
+
]
|
|
2319
|
+
}
|
|
2320
|
+
) });
|
|
2321
|
+
}
|
|
2322
|
+
let ts;
|
|
2323
|
+
const rs = () => ts ?? (ts = import("./shadow-CEK6vAGQ.js").then((e) => e.default));
|
|
2324
|
+
function ns(e) {
|
|
2325
|
+
if (document.querySelector("style[data-zenera-chat-properties]")) return;
|
|
2326
|
+
const t = e.match(/@property\s+[^{]+\{[^}]*\}/g);
|
|
2327
|
+
if (!t) return;
|
|
2328
|
+
const s = document.createElement("style");
|
|
2329
|
+
s.dataset.zeneraChatProperties = "", s.textContent = t.join(`
|
|
2330
|
+
`), document.head.append(s);
|
|
2331
|
+
}
|
|
2332
|
+
function jt({
|
|
2333
|
+
children: e,
|
|
2334
|
+
className: t,
|
|
2335
|
+
style: s
|
|
2336
|
+
}) {
|
|
2337
|
+
const i = W(null), [a, r] = O(null);
|
|
2338
|
+
return ze(() => {
|
|
2339
|
+
const o = i.current;
|
|
2340
|
+
if (!o) return;
|
|
2341
|
+
const l = o.shadowRoot ?? o.attachShadow({ mode: "open" }), c = document.createElement("style"), f = document.createElement("div");
|
|
2342
|
+
f.style.height = "100%", l.append(c, f);
|
|
2343
|
+
let p = !0;
|
|
2344
|
+
return rs().then((u) => {
|
|
2345
|
+
p && (ns(u), c.textContent = u, r(f));
|
|
2346
|
+
}), () => {
|
|
2347
|
+
p = !1, c.remove(), f.remove(), r(null);
|
|
2348
|
+
};
|
|
2349
|
+
}, []), /* @__PURE__ */ n(
|
|
2350
|
+
"div",
|
|
2351
|
+
{
|
|
2352
|
+
ref: i,
|
|
2353
|
+
className: t,
|
|
2354
|
+
style: { display: "block", height: "100%", ...s },
|
|
2355
|
+
children: a && ft(
|
|
2356
|
+
/* @__PURE__ */ n(gt.Provider, { value: a, children: e }),
|
|
2357
|
+
a
|
|
2358
|
+
)
|
|
2359
|
+
}
|
|
2360
|
+
);
|
|
2361
|
+
}
|
|
2362
|
+
const Ee = (e) => e && Object.fromEntries(
|
|
2363
|
+
Object.entries(e).map(([t, s]) => [`--${t}`, s])
|
|
2364
|
+
);
|
|
2365
|
+
function Ys({ isolate: e = !0, className: t, style: s, theme: i, ...a }) {
|
|
2366
|
+
const r = $e();
|
|
2367
|
+
return e ? /* @__PURE__ */ n(jt, { className: t, style: s, children: /* @__PURE__ */ n(je, { ...a, dark: r === "dark", rootStyle: Ee(i) }) }) : /* @__PURE__ */ n(
|
|
2368
|
+
je,
|
|
2369
|
+
{
|
|
2370
|
+
...a,
|
|
2371
|
+
rootClassName: t,
|
|
2372
|
+
rootStyle: { ...Ee(i), ...s }
|
|
2373
|
+
}
|
|
2374
|
+
);
|
|
2375
|
+
}
|
|
2376
|
+
function je({
|
|
2377
|
+
transport: e,
|
|
2378
|
+
interceptors: t,
|
|
2379
|
+
threadId: s,
|
|
2380
|
+
onThreadChange: i,
|
|
2381
|
+
onTurnEnd: a,
|
|
2382
|
+
placeholder: r = "Message…",
|
|
2383
|
+
starterMessages: o,
|
|
2384
|
+
newChatSignal: l = 0,
|
|
2385
|
+
historyKey: c,
|
|
2386
|
+
draftKey: f,
|
|
2387
|
+
rootClassName: p,
|
|
2388
|
+
rootStyle: u,
|
|
2389
|
+
dark: m,
|
|
2390
|
+
nested: h
|
|
2391
|
+
}) {
|
|
2392
|
+
const x = W(t);
|
|
2393
|
+
x.current = t;
|
|
2394
|
+
const v = ne(
|
|
2395
|
+
() => e && xr(e, () => x.current),
|
|
2396
|
+
[e]
|
|
2397
|
+
), [S, w] = O(null), N = s ?? S;
|
|
2398
|
+
T(() => w(null), [s]);
|
|
2399
|
+
const g = yr(v, N), [z, A] = O(null), [_, D] = O(!1);
|
|
2400
|
+
T(() => {
|
|
2401
|
+
z && N && (A(null), g.send(z));
|
|
2402
|
+
}, [z, N, g]);
|
|
2403
|
+
const $ = g.status === "running", [U, de] = O(!1);
|
|
2404
|
+
T(() => {
|
|
2405
|
+
U && !$ && (a == null || a()), de($);
|
|
2406
|
+
}, [$, U, a]);
|
|
2407
|
+
const b = le(async () => {
|
|
2408
|
+
if (!v) throw new Error("this chat is not connected");
|
|
2409
|
+
const { thread: K } = await v.createThread();
|
|
2410
|
+
return w(K.id), i == null || i(K.id), K.id;
|
|
2411
|
+
}, [v, i]), H = vr(v, N, b), te = le(
|
|
2412
|
+
(K, F) => {
|
|
2413
|
+
if (N) {
|
|
2414
|
+
g.send(K, F);
|
|
2415
|
+
return;
|
|
2416
|
+
}
|
|
2417
|
+
v && (D(!0), v.createThread().then(({ thread: J }) => {
|
|
2418
|
+
A(K), w(J.id), i == null || i(J.id);
|
|
2419
|
+
}).catch(() => {
|
|
2420
|
+
}).finally(() => D(!1)));
|
|
2421
|
+
},
|
|
2422
|
+
[N, g, v, i]
|
|
2423
|
+
), ue = !!(N && g.status === "idle" && !g.items.length && g.error);
|
|
2424
|
+
return /* @__PURE__ */ d(
|
|
2425
|
+
"div",
|
|
2426
|
+
{
|
|
2427
|
+
className: k(
|
|
2428
|
+
!h && "zenera-chat",
|
|
2429
|
+
"flex h-full min-h-0 flex-col text-foreground",
|
|
2430
|
+
m && "dark",
|
|
2431
|
+
p
|
|
2432
|
+
),
|
|
2433
|
+
style: u,
|
|
2434
|
+
children: [
|
|
2435
|
+
ue ? /* @__PURE__ */ n("div", { className: "flex flex-1 items-center justify-center p-6 text-center", children: /* @__PURE__ */ n("h2", { className: "text-xl font-semibold", children: g.error }) }) : !N && !g.items.length && (o != null && o.length) ? /* @__PURE__ */ n(Zn, { nudge: l, variants: o }) : /* @__PURE__ */ d("div", { className: "min-h-0 flex-1 overflow-y-auto [container-type:size]", children: [
|
|
2436
|
+
/* @__PURE__ */ n(
|
|
2437
|
+
Xn,
|
|
2438
|
+
{
|
|
2439
|
+
items: g.items,
|
|
2440
|
+
running: $,
|
|
2441
|
+
interrupts: {
|
|
2442
|
+
info: g.interruptInfo,
|
|
2443
|
+
cancel: g.cancelInterrupt,
|
|
2444
|
+
refresh: g.refreshInterrupts
|
|
2445
|
+
}
|
|
2446
|
+
}
|
|
2447
|
+
),
|
|
2448
|
+
N && g.status === "loading" && !g.starting && /* @__PURE__ */ n(ge, { className: "mx-auto size-4 animate-spin text-muted-foreground" })
|
|
2449
|
+
] }),
|
|
2450
|
+
g.starting && /* @__PURE__ */ d("p", { className: "mx-auto flex items-center gap-2 text-sm text-muted-foreground", children: [
|
|
2451
|
+
/* @__PURE__ */ n(ge, { className: "size-3.5 animate-spin" }),
|
|
2452
|
+
"Starting the project (",
|
|
2453
|
+
g.starting,
|
|
2454
|
+
")…"
|
|
2455
|
+
] }),
|
|
2456
|
+
g.reconnecting && !g.starting && /* @__PURE__ */ d("p", { className: "mx-auto flex items-center gap-2 text-sm text-muted-foreground", children: [
|
|
2457
|
+
/* @__PURE__ */ n(ge, { className: "size-3.5 animate-spin" }),
|
|
2458
|
+
"Connection lost, reconnecting… the answer goes on meanwhile."
|
|
2459
|
+
] }),
|
|
2460
|
+
g.error && !ue && /* @__PURE__ */ n("p", { className: "mx-auto w-full max-w-5xl px-4 text-sm text-danger", children: g.error }),
|
|
2461
|
+
/* @__PURE__ */ n(
|
|
2462
|
+
Qn,
|
|
2463
|
+
{
|
|
2464
|
+
disabled: !v || !!g.starting || _,
|
|
2465
|
+
running: $,
|
|
2466
|
+
placeholder: r,
|
|
2467
|
+
historyKey: c,
|
|
2468
|
+
draftKey: f,
|
|
2469
|
+
attachments: H,
|
|
2470
|
+
onSend: te,
|
|
2471
|
+
onStop: g.cancel
|
|
2472
|
+
}
|
|
2473
|
+
)
|
|
2474
|
+
]
|
|
2475
|
+
}
|
|
2476
|
+
);
|
|
2477
|
+
}
|
|
2478
|
+
function ss(e, t = 4e3) {
|
|
2479
|
+
const [s, i] = O(null), a = W(void 0);
|
|
2480
|
+
T(() => () => clearTimeout(a.current), []);
|
|
2481
|
+
const r = le(() => {
|
|
2482
|
+
clearTimeout(a.current), i(null);
|
|
2483
|
+
}, []);
|
|
2484
|
+
return { armed: s, request: (l) => {
|
|
2485
|
+
if (clearTimeout(a.current), s !== l) {
|
|
2486
|
+
i(l), a.current = setTimeout(() => i(null), t);
|
|
2487
|
+
return;
|
|
2488
|
+
}
|
|
2489
|
+
i(null), e(l);
|
|
2490
|
+
}, disarm: r };
|
|
2491
|
+
}
|
|
2492
|
+
function is({
|
|
2493
|
+
armed: e,
|
|
2494
|
+
onClick: t,
|
|
2495
|
+
disabled: s,
|
|
2496
|
+
label: i = "Delete",
|
|
2497
|
+
alwaysShown: a,
|
|
2498
|
+
className: r
|
|
2499
|
+
}) {
|
|
2500
|
+
const o = e ? "Click again to delete" : i;
|
|
2501
|
+
return /* @__PURE__ */ n(be, { label: o, children: /* @__PURE__ */ d(
|
|
2502
|
+
"button",
|
|
2503
|
+
{
|
|
2504
|
+
type: "button",
|
|
2505
|
+
"aria-label": o,
|
|
2506
|
+
disabled: s,
|
|
2507
|
+
onClick: (l) => {
|
|
2508
|
+
l.stopPropagation(), t();
|
|
2509
|
+
},
|
|
2510
|
+
className: k(
|
|
2511
|
+
"cursor-pointer items-center gap-1 rounded p-1 text-xs text-muted-foreground hover:text-danger disabled:opacity-50",
|
|
2512
|
+
e ? "flex bg-danger/15 px-1.5 text-danger" : a ? "flex" : "hidden group-focus-within:flex group-hover:flex [@media(hover:none)]:flex",
|
|
2513
|
+
r
|
|
2514
|
+
),
|
|
2515
|
+
children: [
|
|
2516
|
+
/* @__PURE__ */ n(ur, { className: "size-3.5" }),
|
|
2517
|
+
e && "Delete"
|
|
2518
|
+
]
|
|
2519
|
+
}
|
|
2520
|
+
) });
|
|
2521
|
+
}
|
|
2522
|
+
const as = 45, os = 256, Ae = 192, tt = 480, It = 300, ls = 140, rt = (e) => typeof localStorage > "u" ? null : localStorage.getItem(e);
|
|
2523
|
+
function cs(e, t, s) {
|
|
2524
|
+
return e === "right" ? s.right - t : t - s.left;
|
|
2525
|
+
}
|
|
2526
|
+
function ds(e = "zenera.chatSidebar", t = "left", s) {
|
|
2527
|
+
const i = `${e}Collapsed`, a = `${e}Width`, [r, o] = O(() => {
|
|
2528
|
+
if (s !== void 0) return s;
|
|
2529
|
+
const h = rt(i);
|
|
2530
|
+
return h !== null ? h === "1" : typeof window < "u" && window.matchMedia("(max-width: 767px)").matches;
|
|
2531
|
+
}), [l, c] = O(() => {
|
|
2532
|
+
const h = Number(rt(a));
|
|
2533
|
+
return h >= Ae && h <= tt ? h : os;
|
|
2534
|
+
}), [f, p] = O(!1);
|
|
2535
|
+
return { collapsed: r, width: l, resizing: f, toggle: () => o((h) => (localStorage.setItem(i, h ? "0" : "1"), !h)), setCollapsed: o, startResize: (h) => {
|
|
2536
|
+
var D;
|
|
2537
|
+
const x = h.currentTarget.parentElement;
|
|
2538
|
+
if (!x) return;
|
|
2539
|
+
const v = (((D = x.parentElement) == null ? void 0 : D.clientWidth) ?? 1 / 0) - It, S = Math.min(tt, v);
|
|
2540
|
+
if (S < Ae) return;
|
|
2541
|
+
h.preventDefault();
|
|
2542
|
+
const w = h.currentTarget;
|
|
2543
|
+
w.setPointerCapture(h.pointerId);
|
|
2544
|
+
const N = x.getBoundingClientRect();
|
|
2545
|
+
let g = r, z = l;
|
|
2546
|
+
p(!0);
|
|
2547
|
+
const A = ($) => {
|
|
2548
|
+
const U = cs(t, $.clientX, N);
|
|
2549
|
+
g = U < ls, o(g), g || (z = Math.round(Math.min(Math.max(U, Ae), S)), c(z));
|
|
2550
|
+
}, _ = () => {
|
|
2551
|
+
w.removeEventListener("pointermove", A), w.removeEventListener("lostpointercapture", _), p(!1), localStorage.setItem(i, g ? "1" : "0"), localStorage.setItem(a, String(z));
|
|
2552
|
+
};
|
|
2553
|
+
w.addEventListener("pointermove", A), w.addEventListener("lostpointercapture", _);
|
|
2554
|
+
} };
|
|
2555
|
+
}
|
|
2556
|
+
function us({
|
|
2557
|
+
transport: e,
|
|
2558
|
+
layout: t,
|
|
2559
|
+
activeThreadId: s,
|
|
2560
|
+
onSelect: i,
|
|
2561
|
+
onNew: a,
|
|
2562
|
+
onDelete: r,
|
|
2563
|
+
renderLink: o,
|
|
2564
|
+
newDisabled: l,
|
|
2565
|
+
refreshKey: c,
|
|
2566
|
+
footer: f,
|
|
2567
|
+
side: p = "left",
|
|
2568
|
+
showToggle: u = !1,
|
|
2569
|
+
className: m
|
|
2570
|
+
}) {
|
|
2571
|
+
const { collapsed: h, width: x, resizing: v, startResize: S } = t, w = wr(e, c), N = ss((_) => {
|
|
2572
|
+
w.remove(_).then(() => r == null ? void 0 : r(_)).catch(() => {
|
|
2573
|
+
});
|
|
2574
|
+
}), g = !e || l, z = p === "right" ? "left" : "right", A = p === "right" ? h ? mr : fr : h ? pr : hr;
|
|
2575
|
+
return /* @__PURE__ */ d(
|
|
2576
|
+
"aside",
|
|
2577
|
+
{
|
|
2578
|
+
style: { width: h ? as : x },
|
|
2579
|
+
className: k(
|
|
2580
|
+
"relative flex shrink-0 flex-col gap-2 border-border",
|
|
2581
|
+
p === "right" ? "border-l" : "border-r",
|
|
2582
|
+
h ? "items-center p-1 pt-3" : "p-3",
|
|
2583
|
+
!v && "transition-[width] duration-150",
|
|
2584
|
+
m
|
|
2585
|
+
),
|
|
2586
|
+
children: [
|
|
2587
|
+
/* @__PURE__ */ n(
|
|
2588
|
+
"div",
|
|
2589
|
+
{
|
|
2590
|
+
className: k(
|
|
2591
|
+
"group absolute inset-y-0 z-10 w-2 cursor-col-resize touch-none",
|
|
2592
|
+
p === "right" ? "-left-1" : "-right-1"
|
|
2593
|
+
),
|
|
2594
|
+
title: "Drag to resize",
|
|
2595
|
+
onPointerDown: S,
|
|
2596
|
+
children: /* @__PURE__ */ n("div", { className: "mx-auto h-full w-px group-hover:w-0.5 group-hover:bg-primary/60" })
|
|
2597
|
+
}
|
|
2598
|
+
),
|
|
2599
|
+
/* @__PURE__ */ d(
|
|
2600
|
+
"div",
|
|
2601
|
+
{
|
|
2602
|
+
className: k(
|
|
2603
|
+
"flex gap-2",
|
|
2604
|
+
h ? "flex-col items-center" : p === "right" ? "flex-row-reverse" : "flex-row"
|
|
2605
|
+
),
|
|
2606
|
+
children: [
|
|
2607
|
+
u && /* @__PURE__ */ n(
|
|
2608
|
+
be,
|
|
2609
|
+
{
|
|
2610
|
+
label: h ? "Expand sidebar" : "Collapse sidebar",
|
|
2611
|
+
side: h ? z : "bottom",
|
|
2612
|
+
children: /* @__PURE__ */ n(
|
|
2613
|
+
re,
|
|
2614
|
+
{
|
|
2615
|
+
variant: "outline",
|
|
2616
|
+
size: "icon",
|
|
2617
|
+
"aria-label": h ? "Expand sidebar" : "Collapse sidebar",
|
|
2618
|
+
"aria-expanded": !h,
|
|
2619
|
+
onClick: t.toggle,
|
|
2620
|
+
children: /* @__PURE__ */ n(A, {})
|
|
2621
|
+
}
|
|
2622
|
+
)
|
|
2623
|
+
}
|
|
2624
|
+
),
|
|
2625
|
+
h ? /* @__PURE__ */ n(be, { label: "New chat", side: z, children: /* @__PURE__ */ n(
|
|
2626
|
+
re,
|
|
2627
|
+
{
|
|
2628
|
+
variant: "outline",
|
|
2629
|
+
size: "icon",
|
|
2630
|
+
"aria-label": "New chat",
|
|
2631
|
+
disabled: g,
|
|
2632
|
+
onClick: a,
|
|
2633
|
+
children: /* @__PURE__ */ n(gr, {})
|
|
2634
|
+
}
|
|
2635
|
+
) }) : /* @__PURE__ */ d(
|
|
2636
|
+
re,
|
|
2637
|
+
{
|
|
2638
|
+
variant: "outline",
|
|
2639
|
+
className: "min-w-0 flex-1 justify-start overflow",
|
|
2640
|
+
disabled: g,
|
|
2641
|
+
onClick: a,
|
|
2642
|
+
children: [
|
|
2643
|
+
/* @__PURE__ */ n(br, {}),
|
|
2644
|
+
"New chat"
|
|
2645
|
+
]
|
|
2646
|
+
}
|
|
2647
|
+
)
|
|
2648
|
+
]
|
|
2649
|
+
}
|
|
2650
|
+
),
|
|
2651
|
+
/* @__PURE__ */ n(
|
|
2652
|
+
"div",
|
|
2653
|
+
{
|
|
2654
|
+
className: k(
|
|
2655
|
+
"flex min-h-0 flex-1 flex-col gap-1.5 overflow-y-auto",
|
|
2656
|
+
h && "hidden"
|
|
2657
|
+
),
|
|
2658
|
+
children: w.threads.map((_) => {
|
|
2659
|
+
const D = _.id === s, $ = {
|
|
2660
|
+
className: k(
|
|
2661
|
+
"flex min-w-0 flex-1 cursor-pointer items-center gap-2 px-2 py-1.5 text-left text-sm text-muted-foreground hover:text-foreground",
|
|
2662
|
+
D && "text-foreground"
|
|
2663
|
+
),
|
|
2664
|
+
children: /* @__PURE__ */ n("span", { className: "truncate", children: _.title })
|
|
2665
|
+
};
|
|
2666
|
+
return /* @__PURE__ */ d(
|
|
2667
|
+
"div",
|
|
2668
|
+
{
|
|
2669
|
+
className: k(
|
|
2670
|
+
"group flex items-center rounded-md hover:bg-accent",
|
|
2671
|
+
D && "bg-accent"
|
|
2672
|
+
),
|
|
2673
|
+
children: [
|
|
2674
|
+
o ? o(_, $) : /* @__PURE__ */ n(
|
|
2675
|
+
"button",
|
|
2676
|
+
{
|
|
2677
|
+
type: "button",
|
|
2678
|
+
className: $.className,
|
|
2679
|
+
onClick: () => i == null ? void 0 : i(_.id),
|
|
2680
|
+
children: $.children
|
|
2681
|
+
}
|
|
2682
|
+
),
|
|
2683
|
+
/* @__PURE__ */ n(
|
|
2684
|
+
is,
|
|
2685
|
+
{
|
|
2686
|
+
armed: N.armed === _.id,
|
|
2687
|
+
disabled: w.removing,
|
|
2688
|
+
label: "Delete chat",
|
|
2689
|
+
onClick: () => N.request(_.id),
|
|
2690
|
+
className: "mr-1"
|
|
2691
|
+
}
|
|
2692
|
+
)
|
|
2693
|
+
]
|
|
2694
|
+
},
|
|
2695
|
+
_.id
|
|
2696
|
+
);
|
|
2697
|
+
})
|
|
2698
|
+
}
|
|
2699
|
+
),
|
|
2700
|
+
f
|
|
2701
|
+
]
|
|
2702
|
+
}
|
|
2703
|
+
);
|
|
2704
|
+
}
|
|
2705
|
+
function Vs({
|
|
2706
|
+
isolate: e = !0,
|
|
2707
|
+
className: t,
|
|
2708
|
+
style: s,
|
|
2709
|
+
theme: i,
|
|
2710
|
+
...a
|
|
2711
|
+
}) {
|
|
2712
|
+
const r = $e();
|
|
2713
|
+
return e ? /* @__PURE__ */ n(jt, { className: t, style: s, children: /* @__PURE__ */ n(nt, { ...a, dark: r === "dark", rootStyle: Ee(i) }) }) : /* @__PURE__ */ n(
|
|
2714
|
+
nt,
|
|
2715
|
+
{
|
|
2716
|
+
...a,
|
|
2717
|
+
rootClassName: t,
|
|
2718
|
+
rootStyle: { ...Ee(i), ...s }
|
|
2719
|
+
}
|
|
2720
|
+
);
|
|
2721
|
+
}
|
|
2722
|
+
function nt({
|
|
2723
|
+
transport: e,
|
|
2724
|
+
threadId: t,
|
|
2725
|
+
onThreadChange: s,
|
|
2726
|
+
onTurnEnd: i,
|
|
2727
|
+
renderLink: a,
|
|
2728
|
+
sidebarStorageKey: r,
|
|
2729
|
+
sidebarSide: o = "left",
|
|
2730
|
+
sidebarCollapsed: l,
|
|
2731
|
+
onSidebarCollapsedChange: c,
|
|
2732
|
+
sidebarToggle: f = !1,
|
|
2733
|
+
sidebarClassName: p,
|
|
2734
|
+
rootClassName: u,
|
|
2735
|
+
rootStyle: m,
|
|
2736
|
+
dark: h,
|
|
2737
|
+
...x
|
|
2738
|
+
}) {
|
|
2739
|
+
const v = ds(r, o, l), { collapsed: S, setCollapsed: w } = v, N = W(null), [g, z] = O(null);
|
|
2740
|
+
T(() => {
|
|
2741
|
+
const M = N.current;
|
|
2742
|
+
if (!M || typeof ResizeObserver > "u") return;
|
|
2743
|
+
const se = new ResizeObserver(() => z(M.clientWidth));
|
|
2744
|
+
return se.observe(M), () => se.disconnect();
|
|
2745
|
+
}, []);
|
|
2746
|
+
const _ = g !== null && g - v.width < It && !S ? { ...v, collapsed: !0 } : v, D = W(!1);
|
|
2747
|
+
T(() => {
|
|
2748
|
+
D.current ? l !== void 0 && w(l) : D.current = !0;
|
|
2749
|
+
}, [l, w]);
|
|
2750
|
+
const $ = W(c);
|
|
2751
|
+
$.current = c, T(() => {
|
|
2752
|
+
var M;
|
|
2753
|
+
return (M = $.current) == null ? void 0 : M.call($, S);
|
|
2754
|
+
}, [S]);
|
|
2755
|
+
const [U, de] = O(null), [b, H] = O(0), te = t === void 0 ? U : t, [ue, K] = O(0), F = le(
|
|
2756
|
+
(M) => {
|
|
2757
|
+
de(M), s == null || s(M);
|
|
2758
|
+
},
|
|
2759
|
+
[s]
|
|
2760
|
+
), J = /* @__PURE__ */ n(
|
|
2761
|
+
us,
|
|
2762
|
+
{
|
|
2763
|
+
transport: e,
|
|
2764
|
+
layout: _,
|
|
2765
|
+
side: o,
|
|
2766
|
+
showToggle: f,
|
|
2767
|
+
activeThreadId: te,
|
|
2768
|
+
onSelect: F,
|
|
2769
|
+
onNew: () => {
|
|
2770
|
+
H((M) => M + 1), F(null);
|
|
2771
|
+
},
|
|
2772
|
+
onDelete: (M) => M === te && F(null),
|
|
2773
|
+
renderLink: a,
|
|
2774
|
+
refreshKey: ue,
|
|
2775
|
+
className: p
|
|
2776
|
+
}
|
|
2777
|
+
);
|
|
2778
|
+
return /* @__PURE__ */ d(
|
|
2779
|
+
"div",
|
|
2780
|
+
{
|
|
2781
|
+
ref: N,
|
|
2782
|
+
className: k(
|
|
2783
|
+
"zenera-chat flex h-full min-h-0 text-foreground",
|
|
2784
|
+
h && "dark",
|
|
2785
|
+
u
|
|
2786
|
+
),
|
|
2787
|
+
style: m,
|
|
2788
|
+
children: [
|
|
2789
|
+
o === "left" && J,
|
|
2790
|
+
/* @__PURE__ */ n("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ n(
|
|
2791
|
+
je,
|
|
2792
|
+
{
|
|
2793
|
+
...x,
|
|
2794
|
+
nested: !0,
|
|
2795
|
+
newChatSignal: b,
|
|
2796
|
+
transport: e,
|
|
2797
|
+
threadId: te,
|
|
2798
|
+
onThreadChange: (M) => {
|
|
2799
|
+
K((se) => se + 1), F(M);
|
|
2800
|
+
},
|
|
2801
|
+
onTurnEnd: () => {
|
|
2802
|
+
K((M) => M + 1), i == null || i();
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2805
|
+
) }),
|
|
2806
|
+
o === "right" && J
|
|
2807
|
+
]
|
|
2808
|
+
}
|
|
2809
|
+
);
|
|
2810
|
+
}
|
|
2811
|
+
const Rt = 360, $t = 320, Mt = 360, ms = 240, Q = (e, t, s) => Math.min(Math.max(e, t), s), ye = (e, t) => Math.min(e, t);
|
|
2812
|
+
function Tt(e, t) {
|
|
2813
|
+
const s = Q(
|
|
2814
|
+
e.width,
|
|
2815
|
+
ye(Rt, t.width),
|
|
2816
|
+
Math.max(t.width, 0)
|
|
2817
|
+
), i = Q(
|
|
2818
|
+
e.height,
|
|
2819
|
+
ye($t, t.height),
|
|
2820
|
+
Math.max(t.height, 0)
|
|
2821
|
+
);
|
|
2822
|
+
return {
|
|
2823
|
+
width: s,
|
|
2824
|
+
height: i,
|
|
2825
|
+
left: Q(e.left, 0, t.width - s),
|
|
2826
|
+
top: Q(e.top, 0, t.height - i)
|
|
2827
|
+
};
|
|
2828
|
+
}
|
|
2829
|
+
function fs(e, t, s, i) {
|
|
2830
|
+
return Tt({ ...e, left: e.left + t, top: e.top + s }, i);
|
|
2831
|
+
}
|
|
2832
|
+
function ps(e, t, s, i, a) {
|
|
2833
|
+
const r = ye(Rt, a.width), o = ye($t, a.height);
|
|
2834
|
+
let l = e.left, c = e.top, f = e.left + e.width, p = e.top + e.height;
|
|
2835
|
+
return t.includes("w") && (l = Q(l + s, 0, f - r)), t.includes("e") && (f = Q(f + s, l + r, a.width)), t.includes("n") && (c = Q(c + i, 0, p - o)), t.includes("s") && (p = Q(p + i, c + o, a.height)), { left: l, top: c, width: f - l, height: p - c };
|
|
2836
|
+
}
|
|
2837
|
+
function hs(e, t) {
|
|
2838
|
+
const s = t ? e - ms : e;
|
|
2839
|
+
return Math.max(s, ye(Mt, e));
|
|
2840
|
+
}
|
|
2841
|
+
function Dt(e, t, s) {
|
|
2842
|
+
return Q(
|
|
2843
|
+
e,
|
|
2844
|
+
ye(Mt, t),
|
|
2845
|
+
hs(t, s)
|
|
2846
|
+
);
|
|
2847
|
+
}
|
|
2848
|
+
function st(e, t, s, i, a) {
|
|
2849
|
+
const r = t === "right" ? e - s : e + s;
|
|
2850
|
+
return Dt(r, i, a);
|
|
2851
|
+
}
|
|
2852
|
+
const we = (e) => {
|
|
2853
|
+
throw new Error(`ZeneraChatLauncher: ${e}`);
|
|
2854
|
+
};
|
|
2855
|
+
function it(e, t) {
|
|
2856
|
+
const { mode: s, side: i = "right", width: a, resizable: r = !0, defaultOpen: o = !1 } = e, { placement: l, height: c, contentTarget: f, draggable: p = !0 } = e;
|
|
2857
|
+
s !== "popup" && s !== "sidebar" && we(`presentation.mode must be 'popup' or 'sidebar', not ${String(s)}`), i !== "left" && i !== "right" && we(`presentation.side must be 'left' or 'right', not ${String(i)}`);
|
|
2858
|
+
let u = null;
|
|
2859
|
+
return s === "sidebar" && (l !== "overlay" && l !== "docked" && we("a sidebar needs presentation.placement: 'overlay' or 'docked'"), l === "docked" && (f || we("a docked sidebar needs presentation.contentTarget"), u = typeof f == "string" ? t(f) : f, u || we(`contentTarget ${String(f)} matches no element`))), {
|
|
2860
|
+
mode: s,
|
|
2861
|
+
docked: s === "sidebar" && l === "docked",
|
|
2862
|
+
side: i,
|
|
2863
|
+
width: a ?? (s === "popup" ? "380px" : "820px"),
|
|
2864
|
+
height: c ?? "600px",
|
|
2865
|
+
contentTarget: u,
|
|
2866
|
+
resizable: r,
|
|
2867
|
+
draggable: p,
|
|
2868
|
+
defaultOpen: o
|
|
2869
|
+
};
|
|
2870
|
+
}
|
|
2871
|
+
const gs = "(max-width: 767px)", bs = ["n", "s", "e", "w", "ne", "nw", "se", "sw"], at = 16, xs = `
|
|
2872
|
+
:host { display: contents; }
|
|
2873
|
+
* { box-sizing: border-box; }
|
|
2874
|
+
.button {
|
|
2875
|
+
position: fixed; bottom: 24px; z-index: 2147483000;
|
|
2876
|
+
width: 56px; height: 56px; padding: 0; border: 0; border-radius: 50%;
|
|
2877
|
+
display: flex; align-items: center; justify-content: center; cursor: pointer;
|
|
2878
|
+
background: var(--zenera-launcher-accent, #4f46e5); color: #fff;
|
|
2879
|
+
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
|
|
2880
|
+
}
|
|
2881
|
+
.button[hidden] { display: none; }
|
|
2882
|
+
.button:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }
|
|
2883
|
+
.button[data-side='right'] { right: 24px; }
|
|
2884
|
+
.button[data-side='left'] { left: 24px; }
|
|
2885
|
+
.panel {
|
|
2886
|
+
position: fixed; z-index: 2147483001; display: flex; flex-direction: column;
|
|
2887
|
+
background: #fff; color: #111827; border: 0 solid #e5e7eb;
|
|
2888
|
+
font: 14px/1.4 system-ui, -apple-system, 'Segoe UI', sans-serif;
|
|
2889
|
+
}
|
|
2890
|
+
.panel[hidden] { display: none; }
|
|
2891
|
+
.panel:focus { outline: none; }
|
|
2892
|
+
.panel[data-mode='popup'] {
|
|
2893
|
+
bottom: 96px; max-width: calc(100vw - 32px); max-height: calc(100vh - 120px);
|
|
2894
|
+
border-width: 1px; border-radius: 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
|
|
2895
|
+
}
|
|
2896
|
+
.panel[data-mode='popup'][data-side='right'] { right: 24px; }
|
|
2897
|
+
.panel[data-mode='popup'][data-side='left'] { left: 24px; }
|
|
2898
|
+
.panel[data-mode='sidebar'] { top: 0; bottom: 0; max-width: 100vw; }
|
|
2899
|
+
.panel[data-mode='sidebar'][data-side='right'] { right: 0; border-left-width: 1px; }
|
|
2900
|
+
.panel[data-mode='sidebar'][data-side='left'] { left: 0; border-right-width: 1px; }
|
|
2901
|
+
.panel[data-mode='sidebar'][data-overlay] { box-shadow: 0 0 32px rgba(0, 0, 0, 0.2); }
|
|
2902
|
+
.header {
|
|
2903
|
+
display: flex; align-items: center; justify-content: space-between; flex: none;
|
|
2904
|
+
height: 44px; padding: 0 8px 0 16px; border-bottom: 1px solid #e5e7eb; font-weight: 600;
|
|
2905
|
+
}
|
|
2906
|
+
.close {
|
|
2907
|
+
width: 32px; height: 32px; padding: 0; border: 0; border-radius: 6px;
|
|
2908
|
+
background: transparent; color: inherit; cursor: pointer; font-size: 20px; line-height: 1;
|
|
2909
|
+
}
|
|
2910
|
+
.close:hover { background: rgba(127, 127, 127, 0.2); }
|
|
2911
|
+
.close:focus-visible { outline: 2px solid #93c5fd; }
|
|
2912
|
+
.header[data-draggable] { cursor: grab; touch-action: none; user-select: none; }
|
|
2913
|
+
.panel[data-gesture] .header[data-draggable] { cursor: grabbing; }
|
|
2914
|
+
.panel[data-gesture], .panel[data-gesture] ::slotted(*) { user-select: none; }
|
|
2915
|
+
.handle { position: absolute; z-index: 1; touch-action: none; }
|
|
2916
|
+
.handle[hidden] { display: none; }
|
|
2917
|
+
.handle[data-edge='n'] { top: -3px; left: 14px; right: 14px; height: 6px; cursor: ns-resize; }
|
|
2918
|
+
.handle[data-edge='s'] { bottom: -3px; left: 14px; right: 14px; height: 6px; cursor: ns-resize; }
|
|
2919
|
+
.handle[data-edge='e'] { right: -3px; top: 14px; bottom: 14px; width: 6px; cursor: ew-resize; }
|
|
2920
|
+
.handle[data-edge='w'] { left: -3px; top: 14px; bottom: 14px; width: 6px; cursor: ew-resize; }
|
|
2921
|
+
.handle[data-edge='ne'] { top: -4px; right: -4px; width: 14px; height: 14px; cursor: nesw-resize; }
|
|
2922
|
+
.handle[data-edge='nw'] { top: -4px; left: -4px; width: 14px; height: 14px; cursor: nwse-resize; }
|
|
2923
|
+
.handle[data-edge='se'] { bottom: -4px; right: -4px; width: 14px; height: 14px; cursor: nwse-resize; }
|
|
2924
|
+
.handle[data-edge='sw'] { bottom: -4px; left: -4px; width: 14px; height: 14px; cursor: nesw-resize; }
|
|
2925
|
+
.panel[data-mode='sidebar'] .handle { top: 0; bottom: 0; }
|
|
2926
|
+
.handle:focus-visible { outline: 2px solid #93c5fd; outline-offset: -2px; }
|
|
2927
|
+
.body { flex: 1; min-height: 0; }
|
|
2928
|
+
slot { display: block; height: 100%; }
|
|
2929
|
+
:host([data-scheme='dark']) .panel { background: #111827; color: #f9fafb; border-color: #374151; }
|
|
2930
|
+
:host([data-scheme='dark']) .header { border-color: #374151; }
|
|
2931
|
+
`, ys = '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>', Z = (e, t = {}) => {
|
|
2932
|
+
const s = document.createElement(e);
|
|
2933
|
+
for (const [i, a] of Object.entries(t)) s.setAttribute(i, a);
|
|
2934
|
+
return s;
|
|
2935
|
+
};
|
|
2936
|
+
function vs(e) {
|
|
2937
|
+
var Be;
|
|
2938
|
+
const { chatId: t, onOpenChange: s } = e;
|
|
2939
|
+
if (!t) throw new Error("ZeneraChatLauncher: chatId is required");
|
|
2940
|
+
if (document.getElementById(t))
|
|
2941
|
+
throw new Error(`ZeneraChatLauncher: the page already has an element with id "${t}"`);
|
|
2942
|
+
const i = (y) => document.querySelector(y), a = (Be = window.matchMedia) == null ? void 0 : Be.call(window, gs);
|
|
2943
|
+
let r = e.presentation, o = it(r, i), l = o.defaultOpen, c = !1, f = (a == null ? void 0 : a.matches) ?? !1, p = null, u = null, m = null, h = null;
|
|
2944
|
+
const x = Z("div", { "data-zenera-chat-launcher": "" }), v = Z("div", { id: t });
|
|
2945
|
+
v.style.cssText = "display:block;height:100%", x.append(v);
|
|
2946
|
+
const S = x.attachShadow({ mode: "open" }), w = Z("style");
|
|
2947
|
+
w.textContent = xs;
|
|
2948
|
+
const N = Z("button", { type: "button", class: "button" });
|
|
2949
|
+
N.innerHTML = ys;
|
|
2950
|
+
const g = Z("div", {
|
|
2951
|
+
class: "panel",
|
|
2952
|
+
role: "dialog",
|
|
2953
|
+
"aria-modal": "false",
|
|
2954
|
+
"aria-label": "Chat",
|
|
2955
|
+
tabindex: "-1"
|
|
2956
|
+
}), z = Z("div", { class: "header" }), A = Z("span");
|
|
2957
|
+
A.textContent = "Chat";
|
|
2958
|
+
const _ = Z("button", { type: "button", class: "close", "aria-label": "Close chat" });
|
|
2959
|
+
_.textContent = "×", z.append(A, _);
|
|
2960
|
+
const D = Z("div", { class: "body" });
|
|
2961
|
+
D.append(Z("slot")), g.append(z, D);
|
|
2962
|
+
const $ = /* @__PURE__ */ new Map();
|
|
2963
|
+
for (const y of bs) {
|
|
2964
|
+
const L = Z("div", { class: "handle", "data-edge": y });
|
|
2965
|
+
$.set(y, L), g.append(L);
|
|
2966
|
+
}
|
|
2967
|
+
S.append(w, N, g);
|
|
2968
|
+
const U = () => {
|
|
2969
|
+
if (!p) return;
|
|
2970
|
+
const { target: y, property: L, value: C, priority: j } = p;
|
|
2971
|
+
C ? y.style.setProperty(L, C, j) : y.style.removeProperty(L), p = null;
|
|
2972
|
+
}, de = (y, L) => {
|
|
2973
|
+
const C = y.contentTarget, j = y.side === "left" ? "margin-left" : "margin-right";
|
|
2974
|
+
p = {
|
|
2975
|
+
target: C,
|
|
2976
|
+
property: j,
|
|
2977
|
+
value: C.style.getPropertyValue(j),
|
|
2978
|
+
priority: C.style.getPropertyPriority(j)
|
|
2979
|
+
}, C.style.setProperty(j, L);
|
|
2980
|
+
}, b = () => ({
|
|
2981
|
+
width: document.documentElement.clientWidth || window.innerWidth,
|
|
2982
|
+
height: window.innerHeight
|
|
2983
|
+
}), H = () => {
|
|
2984
|
+
const { left: y, top: L, width: C, height: j } = g.getBoundingClientRect();
|
|
2985
|
+
return { left: y, top: L, width: C, height: j };
|
|
2986
|
+
}, te = () => l && o.docked && !f, ue = (y) => {
|
|
2987
|
+
const { mode: L, side: C, width: j, height: X, resizable: Y, draggable: me } = o, fe = L === "popup", q = g.style;
|
|
2988
|
+
fe && m ? (m = Tt(m, b()), q.left = `${m.left}px`, q.top = `${m.top}px`, q.width = `${m.width}px`, q.height = `${m.height}px`, q.right = q.bottom = "auto", q.maxWidth = q.maxHeight = "none") : (q.left = q.top = q.right = q.bottom = "", q.maxWidth = q.maxHeight = "", q.width = fe ? j : K(y), q.height = fe ? X : ""), z.toggleAttribute("data-draggable", fe && me);
|
|
2989
|
+
const Pt = C === "right" ? "w" : "e";
|
|
2990
|
+
for (const [Wt, pe] of $) {
|
|
2991
|
+
const He = Y && (fe || Wt === Pt);
|
|
2992
|
+
if (pe.hidden = !He, He && !fe)
|
|
2993
|
+
pe.setAttribute("role", "separator"), pe.setAttribute("aria-orientation", "vertical"), pe.setAttribute("aria-label", "Resize chat"), pe.tabIndex = 0;
|
|
2994
|
+
else
|
|
2995
|
+
for (const Bt of ["role", "aria-orientation", "aria-label", "tabindex"])
|
|
2996
|
+
pe.removeAttribute(Bt);
|
|
2997
|
+
}
|
|
2998
|
+
}, K = (y) => h === null ? o.width : `${Dt(h, b().width, y)}px`, F = () => {
|
|
2999
|
+
const { mode: y, side: L, docked: C } = o, j = l && C && !f;
|
|
3000
|
+
g.dataset.mode = y, g.dataset.side = L, N.dataset.side = L, g.toggleAttribute("data-overlay", y === "sidebar" && !j), g.hidden = !l, N.hidden = l && y === "sidebar", N.setAttribute("aria-expanded", String(l)), N.setAttribute("aria-label", l ? "Close chat" : "Open chat"), ue(j), U(), j && de(o, g.style.width);
|
|
3001
|
+
}, J = (y) => {
|
|
3002
|
+
if (y === l) return;
|
|
3003
|
+
y && (u = document.activeElement);
|
|
3004
|
+
const L = !y && x.contains(document.activeElement);
|
|
3005
|
+
l = y, F(), y ? g.focus() : L && (u instanceof HTMLElement && u.isConnected ? u : N).focus(), s == null || s(l);
|
|
3006
|
+
}, M = () => {
|
|
3007
|
+
if (c) throw new Error("ZeneraChatLauncher: already unmounted");
|
|
3008
|
+
}, se = (y) => {
|
|
3009
|
+
y.key === "Escape" && l && !y.defaultPrevented && J(!1);
|
|
3010
|
+
}, Me = (y) => {
|
|
3011
|
+
f = y.matches, F();
|
|
3012
|
+
}, Te = () => {
|
|
3013
|
+
l && (m || h !== null) && F();
|
|
3014
|
+
}, De = (y, L) => {
|
|
3015
|
+
y.addEventListener("pointerdown", (C) => {
|
|
3016
|
+
if (C.button !== 0 || !C.isPrimary) return;
|
|
3017
|
+
const j = L(C);
|
|
3018
|
+
if (!j) return;
|
|
3019
|
+
C.preventDefault(), y.setPointerCapture(C.pointerId), g.setAttribute("data-gesture", "");
|
|
3020
|
+
const X = (me) => j(me.clientX - C.clientX, me.clientY - C.clientY), Y = () => {
|
|
3021
|
+
g.removeAttribute("data-gesture"), y.removeEventListener("pointermove", X), y.removeEventListener("pointerup", Y), y.removeEventListener("pointercancel", Y);
|
|
3022
|
+
};
|
|
3023
|
+
y.addEventListener("pointermove", X), y.addEventListener("pointerup", Y), y.addEventListener("pointercancel", Y);
|
|
3024
|
+
});
|
|
3025
|
+
};
|
|
3026
|
+
for (const [y, L] of $)
|
|
3027
|
+
De(L, () => {
|
|
3028
|
+
if (!o.resizable) return null;
|
|
3029
|
+
if (o.mode === "popup") {
|
|
3030
|
+
const X = H();
|
|
3031
|
+
return (Y, me) => {
|
|
3032
|
+
m = ps(X, y, Y, me, b()), F();
|
|
3033
|
+
};
|
|
3034
|
+
}
|
|
3035
|
+
const C = g.getBoundingClientRect().width, j = te();
|
|
3036
|
+
return (X) => {
|
|
3037
|
+
h = st(
|
|
3038
|
+
C,
|
|
3039
|
+
o.side,
|
|
3040
|
+
X,
|
|
3041
|
+
b().width,
|
|
3042
|
+
j
|
|
3043
|
+
), F();
|
|
3044
|
+
};
|
|
3045
|
+
});
|
|
3046
|
+
De(z, (y) => {
|
|
3047
|
+
if (o.mode !== "popup" || !o.draggable || y.target instanceof Node && _.contains(y.target)) return null;
|
|
3048
|
+
const L = H();
|
|
3049
|
+
return (C, j) => {
|
|
3050
|
+
m = fs(L, C, j, b()), F();
|
|
3051
|
+
};
|
|
3052
|
+
}), S.addEventListener("keydown", (y) => {
|
|
3053
|
+
const { key: L, target: C } = y;
|
|
3054
|
+
!(C instanceof HTMLElement) || !C.classList.contains("handle") || L !== "ArrowLeft" && L !== "ArrowRight" || o.mode !== "sidebar" || !o.resizable || (y.preventDefault(), h = st(
|
|
3055
|
+
g.getBoundingClientRect().width,
|
|
3056
|
+
o.side,
|
|
3057
|
+
L === "ArrowLeft" ? -at : at,
|
|
3058
|
+
b().width,
|
|
3059
|
+
te()
|
|
3060
|
+
), F());
|
|
3061
|
+
});
|
|
3062
|
+
const Pe = () => x.setAttribute(
|
|
3063
|
+
"data-scheme",
|
|
3064
|
+
document.documentElement.classList.contains("dark") ? "dark" : "light"
|
|
3065
|
+
), We = new MutationObserver(Pe);
|
|
3066
|
+
return We.observe(document.documentElement, {
|
|
3067
|
+
attributes: !0,
|
|
3068
|
+
attributeFilter: ["class"]
|
|
3069
|
+
}), N.addEventListener("click", () => J(!l)), _.addEventListener("click", () => J(!1)), document.addEventListener("keydown", se), a == null || a.addEventListener("change", Me), window.addEventListener("resize", Te), Pe(), F(), document.body.append(x), {
|
|
3070
|
+
container: v,
|
|
3071
|
+
get isOpen() {
|
|
3072
|
+
return l;
|
|
3073
|
+
},
|
|
3074
|
+
open() {
|
|
3075
|
+
M(), J(!0);
|
|
3076
|
+
},
|
|
3077
|
+
close() {
|
|
3078
|
+
M(), J(!1);
|
|
3079
|
+
},
|
|
3080
|
+
toggle() {
|
|
3081
|
+
M(), J(!l);
|
|
3082
|
+
},
|
|
3083
|
+
update(y) {
|
|
3084
|
+
M();
|
|
3085
|
+
const L = Object.fromEntries(
|
|
3086
|
+
Object.entries(y).filter(([, Y]) => Y !== void 0)
|
|
3087
|
+
), C = { ...r, ...L }, j = it(C, i), X = j.width !== o.width;
|
|
3088
|
+
(X || j.side !== o.side || j.height !== o.height) && (m = null), X && (h = null), o = j, r = C, F();
|
|
3089
|
+
},
|
|
3090
|
+
unmount() {
|
|
3091
|
+
c || (c = !0, U(), document.removeEventListener("keydown", se), a == null || a.removeEventListener("change", Me), window.removeEventListener("resize", Te), We.disconnect(), x.remove());
|
|
3092
|
+
}
|
|
3093
|
+
};
|
|
3094
|
+
}
|
|
3095
|
+
function Qs({
|
|
3096
|
+
chatId: e,
|
|
3097
|
+
presentation: t,
|
|
3098
|
+
open: s,
|
|
3099
|
+
onOpenChange: i,
|
|
3100
|
+
children: a
|
|
3101
|
+
}) {
|
|
3102
|
+
const [r, o] = O(null), l = W({ presentation: t, open: s, onOpenChange: i });
|
|
3103
|
+
l.current = { presentation: t, open: s, onOpenChange: i }, T(() => {
|
|
3104
|
+
const { presentation: S, open: w } = l.current, N = vs({
|
|
3105
|
+
chatId: e,
|
|
3106
|
+
presentation: { ...S, defaultOpen: w ?? S.defaultOpen },
|
|
3107
|
+
onOpenChange: (g) => {
|
|
3108
|
+
var z, A;
|
|
3109
|
+
return (A = (z = l.current).onOpenChange) == null ? void 0 : A.call(z, g);
|
|
3110
|
+
}
|
|
3111
|
+
});
|
|
3112
|
+
return o(N), () => {
|
|
3113
|
+
N.unmount(), o(null);
|
|
3114
|
+
};
|
|
3115
|
+
}, [e]);
|
|
3116
|
+
const { mode: c, side: f, width: p } = t, u = "placement" in t ? t.placement : void 0, m = "height" in t ? t.height : void 0, h = "contentTarget" in t ? t.contentTarget : void 0, x = "draggable" in t ? t.draggable : void 0, { resizable: v } = t;
|
|
3117
|
+
return T(() => {
|
|
3118
|
+
r == null || r.update({
|
|
3119
|
+
mode: c,
|
|
3120
|
+
placement: u,
|
|
3121
|
+
side: f,
|
|
3122
|
+
width: p,
|
|
3123
|
+
height: m,
|
|
3124
|
+
contentTarget: h,
|
|
3125
|
+
resizable: v,
|
|
3126
|
+
draggable: x
|
|
3127
|
+
});
|
|
3128
|
+
}, [r, c, u, f, p, m, h, v, x]), T(() => {
|
|
3129
|
+
!r || s === void 0 || s === r.isOpen || (s ? r.open() : r.close());
|
|
3130
|
+
}, [r, s]), r ? ft(a, r.container) : null;
|
|
3131
|
+
}
|
|
3132
|
+
export {
|
|
3133
|
+
re as B,
|
|
3134
|
+
Xn as C,
|
|
3135
|
+
Zn as E,
|
|
3136
|
+
Cn as I,
|
|
3137
|
+
Ue as N,
|
|
3138
|
+
Ke as S,
|
|
3139
|
+
Ys as Z,
|
|
3140
|
+
us as a,
|
|
3141
|
+
Qn as b,
|
|
3142
|
+
k as c,
|
|
3143
|
+
wt as d,
|
|
3144
|
+
Qs as e,
|
|
3145
|
+
Vs as f,
|
|
3146
|
+
Gs as g,
|
|
3147
|
+
Zs as h,
|
|
3148
|
+
_n as i,
|
|
3149
|
+
ds as j,
|
|
3150
|
+
$e as u
|
|
3151
|
+
};
|