@qfei-design/make-ai-assistant 0.2.15 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react.cjs +4 -4
- package/dist/react.mjs +1870 -1372
- package/dist/styles.css +133 -121
- package/docs/make-app-integration.md +37 -0
- package/package.ai.json +1 -1
- package/package.json +3 -3
- package/dist/react/icons.d.ts +0 -19
package/dist/react.mjs
CHANGED
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { isValidElement as
|
|
3
|
-
import { resolveArtifactTemplate as
|
|
4
|
-
import { extendArtifactTemplateRegistry as
|
|
5
|
-
import { a as fe, r as we, p as
|
|
6
|
-
import { d as
|
|
1
|
+
import { jsxs as u, jsx as a, Fragment as Ie } from "react/jsx-runtime";
|
|
2
|
+
import { isValidElement as Oa, cloneElement as qa, useContext as ja, createContext as Ba, forwardRef as Yt, createElement as Nt, useRef as D, useState as $, useEffect as ne, useLayoutEffect as At, useCallback as Va, useId as Ka, useMemo as Ft } from "react";
|
|
3
|
+
import { resolveArtifactTemplate as Wa, createArtifactTemplateRegistry as Qt, createArtifactCapabilities as Xa } from "./index.mjs";
|
|
4
|
+
import { extendArtifactTemplateRegistry as En } from "./index.mjs";
|
|
5
|
+
import { a as fe, r as we, p as ea, b as ta, c as ht, M as de } from "./conversation-DuqMadaQ.js";
|
|
6
|
+
import { d as Sn, e as Rn, f as Ln, g as zn, v as xn } from "./conversation-DuqMadaQ.js";
|
|
7
7
|
import { i as gt } from "./conversation-management-DZROhXyK.js";
|
|
8
|
-
import { createPortal as
|
|
9
|
-
const
|
|
10
|
-
const t =
|
|
8
|
+
import { createPortal as aa } from "react-dom";
|
|
9
|
+
const sa = (e) => e?.trim() || void 0, ke = (e, t) => sa(e) ?? t, Mt = (e) => {
|
|
10
|
+
const t = sa(e?.primary);
|
|
11
11
|
if (t)
|
|
12
12
|
return {
|
|
13
13
|
"--make-ai-theme-primary": t,
|
|
14
|
-
"--make-ai-theme-primary-hover":
|
|
14
|
+
"--make-ai-theme-primary-hover": ke(
|
|
15
15
|
e?.primaryHover,
|
|
16
16
|
"color-mix(in srgb, var(--make-ai-theme-primary) 84%, #15233d)"
|
|
17
17
|
),
|
|
18
|
-
"--make-ai-theme-on-primary":
|
|
18
|
+
"--make-ai-theme-on-primary": ke(
|
|
19
19
|
e?.onPrimary,
|
|
20
20
|
"#fcfcff"
|
|
21
21
|
),
|
|
22
|
-
"--make-ai-theme-bg":
|
|
22
|
+
"--make-ai-theme-bg": ke(
|
|
23
23
|
e?.background,
|
|
24
24
|
"color-mix(in srgb, var(--make-ai-theme-primary) 2%, #fcfcff)"
|
|
25
25
|
),
|
|
26
|
-
"--make-ai-theme-surface":
|
|
26
|
+
"--make-ai-theme-surface": ke(
|
|
27
27
|
e?.surface,
|
|
28
28
|
"color-mix(in srgb, var(--make-ai-theme-primary) 4%, var(--make-ai-theme-bg))"
|
|
29
29
|
),
|
|
30
|
-
"--make-ai-theme-surface-strong":
|
|
30
|
+
"--make-ai-theme-surface-strong": ke(
|
|
31
31
|
e?.surfaceStrong,
|
|
32
32
|
"color-mix(in srgb, var(--make-ai-theme-primary) 8%, var(--make-ai-theme-bg))"
|
|
33
33
|
),
|
|
34
|
-
"--make-ai-theme-text":
|
|
34
|
+
"--make-ai-theme-text": ke(
|
|
35
35
|
e?.text,
|
|
36
36
|
"color-mix(in srgb, var(--make-ai-theme-primary) 12%, #252631)"
|
|
37
37
|
),
|
|
38
|
-
"--make-ai-theme-text-secondary":
|
|
38
|
+
"--make-ai-theme-text-secondary": ke(
|
|
39
39
|
e?.textSecondary,
|
|
40
40
|
"color-mix(in srgb, var(--make-ai-theme-text) 74%, var(--make-ai-theme-primary))"
|
|
41
41
|
),
|
|
42
|
-
"--make-ai-theme-border":
|
|
42
|
+
"--make-ai-theme-border": ke(
|
|
43
43
|
e?.border,
|
|
44
44
|
"color-mix(in srgb, var(--make-ai-theme-primary) 14%, var(--make-ai-theme-bg))"
|
|
45
45
|
),
|
|
46
|
-
"--make-ai-theme-overlay":
|
|
46
|
+
"--make-ai-theme-overlay": ke(
|
|
47
47
|
e?.overlay,
|
|
48
48
|
"color-mix(in srgb, var(--make-ai-theme-text) 88%, var(--make-ai-theme-primary))"
|
|
49
49
|
),
|
|
50
|
-
"--make-ai-theme-on-overlay":
|
|
50
|
+
"--make-ai-theme-on-overlay": ke(
|
|
51
51
|
e?.onOverlay,
|
|
52
52
|
"#fcfcff"
|
|
53
53
|
)
|
|
54
54
|
};
|
|
55
|
-
},
|
|
55
|
+
}, Ht = (e, t) => !t || !Oa(e) || typeof e.type != "string" ? e : qa(e, {
|
|
56
56
|
style: { ...e.props.style, ...t }
|
|
57
57
|
});
|
|
58
|
-
function
|
|
58
|
+
function Ga({
|
|
59
59
|
artifact: e,
|
|
60
60
|
context: t,
|
|
61
61
|
fallback: s,
|
|
62
|
-
onAction:
|
|
62
|
+
onAction: n,
|
|
63
63
|
onActionError: i,
|
|
64
64
|
registry: c,
|
|
65
|
-
theme:
|
|
65
|
+
theme: l
|
|
66
66
|
}) {
|
|
67
|
-
const
|
|
68
|
-
if (!
|
|
69
|
-
const
|
|
67
|
+
const m = Mt(l), y = Wa(c, e, t);
|
|
68
|
+
if (!y) {
|
|
69
|
+
const A = s ? s(e) : /* @__PURE__ */ u("section", { className: "make-ai-artifact make-ai-artifact--unsupported", role: "status", children: [
|
|
70
70
|
/* @__PURE__ */ a("strong", { children: "暂不支持展示此结果" }),
|
|
71
|
-
/* @__PURE__ */
|
|
71
|
+
/* @__PURE__ */ u("span", { children: [
|
|
72
72
|
"结果类型:",
|
|
73
73
|
e.kind
|
|
74
74
|
] })
|
|
75
75
|
] });
|
|
76
|
-
return
|
|
76
|
+
return Ht(A, m);
|
|
77
77
|
}
|
|
78
78
|
const v = {
|
|
79
79
|
context: t,
|
|
80
|
-
onAction:
|
|
80
|
+
onAction: n,
|
|
81
81
|
onActionError: i,
|
|
82
|
-
theme:
|
|
83
|
-
themeStyle:
|
|
84
|
-
},
|
|
85
|
-
return
|
|
82
|
+
theme: l,
|
|
83
|
+
themeStyle: m
|
|
84
|
+
}, p = y.template.render(e, t, v);
|
|
85
|
+
return Ht(p, m);
|
|
86
86
|
}
|
|
87
87
|
const Le = (e, t, s) => {
|
|
88
88
|
if (e == null || e === "") return "—";
|
|
89
89
|
if (typeof e == "boolean") return e ? "是" : "否";
|
|
90
90
|
if (typeof e != "number") return `${e}${t?.unit ?? ""}`;
|
|
91
|
-
const
|
|
92
|
-
maximumFractionDigits:
|
|
93
|
-
minimumFractionDigits:
|
|
91
|
+
const n = t?.precision, i = {
|
|
92
|
+
maximumFractionDigits: n ?? 2,
|
|
93
|
+
minimumFractionDigits: n
|
|
94
94
|
};
|
|
95
95
|
t?.style === "currency" && t.currency ? (i.style = "currency", i.currency = t.currency) : t?.style === "percent" && (i.style = "percent");
|
|
96
96
|
try {
|
|
@@ -99,14 +99,14 @@ const Le = (e, t, s) => {
|
|
|
99
99
|
} catch {
|
|
100
100
|
return `${e}${t?.unit ?? ""}`;
|
|
101
101
|
}
|
|
102
|
-
},
|
|
102
|
+
}, na = (e) => {
|
|
103
103
|
let t = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY;
|
|
104
|
-
for (const
|
|
105
|
-
t = Math.min(t,
|
|
104
|
+
for (const n of e)
|
|
105
|
+
t = Math.min(t, n), s = Math.max(s, n);
|
|
106
106
|
return Number.isFinite(t) && Number.isFinite(s) ? { min: t, max: s } : { min: 0, max: 0 };
|
|
107
|
-
},
|
|
107
|
+
}, ia = (e, t, s) => {
|
|
108
108
|
if (!s.onAction) return;
|
|
109
|
-
const
|
|
109
|
+
const n = (c) => {
|
|
110
110
|
console.error("[make-ai-assistant] host action error handler failed", {
|
|
111
111
|
actionId: e.id,
|
|
112
112
|
artifactId: t.artifact.id,
|
|
@@ -118,9 +118,9 @@ const Le = (e, t, s) => {
|
|
|
118
118
|
try {
|
|
119
119
|
Promise.resolve(
|
|
120
120
|
s.onActionError(c, e, t)
|
|
121
|
-
).catch(
|
|
122
|
-
} catch (
|
|
123
|
-
|
|
121
|
+
).catch(n);
|
|
122
|
+
} catch (l) {
|
|
123
|
+
n(l);
|
|
124
124
|
}
|
|
125
125
|
return;
|
|
126
126
|
}
|
|
@@ -136,160 +136,160 @@ const Le = (e, t, s) => {
|
|
|
136
136
|
} catch (c) {
|
|
137
137
|
i(c);
|
|
138
138
|
}
|
|
139
|
-
},
|
|
139
|
+
}, qe = (e, t) => e.actions?.length && t.onAction ? /* @__PURE__ */ a("div", { className: "make-ai-artifact__actions", children: e.actions.map((s) => /* @__PURE__ */ u(
|
|
140
140
|
"button",
|
|
141
141
|
{
|
|
142
142
|
className: `make-ai-artifact__action make-ai-artifact__action--${s.appearance ?? "link"}`,
|
|
143
143
|
type: "button",
|
|
144
|
-
onClick: () =>
|
|
144
|
+
onClick: () => ia(s, { artifact: e, context: t.context }, t),
|
|
145
145
|
children: [
|
|
146
146
|
s.label,
|
|
147
147
|
/* @__PURE__ */ a("span", { "aria-hidden": "true", children: "→" })
|
|
148
148
|
]
|
|
149
149
|
},
|
|
150
150
|
s.id
|
|
151
|
-
)) }) : null,
|
|
151
|
+
)) }) : null, je = (e, t, s = "", n) => /* @__PURE__ */ u(
|
|
152
152
|
"section",
|
|
153
153
|
{
|
|
154
154
|
"aria-label": e.title ?? `${e.kind} result`,
|
|
155
155
|
className: `make-ai-artifact ${s}`.trim(),
|
|
156
156
|
"data-artifact-density": e.presentation?.density,
|
|
157
157
|
"data-artifact-kind": e.kind,
|
|
158
|
-
style:
|
|
158
|
+
style: n,
|
|
159
159
|
children: [
|
|
160
160
|
e.title ? /* @__PURE__ */ a("h4", { className: "make-ai-artifact__title", children: e.title }) : null,
|
|
161
161
|
e.summary ? /* @__PURE__ */ a("p", { className: "make-ai-artifact__summary", children: e.summary }) : null,
|
|
162
162
|
t
|
|
163
163
|
]
|
|
164
164
|
}
|
|
165
|
-
),
|
|
165
|
+
), Za = ({
|
|
166
166
|
artifact: e,
|
|
167
167
|
renderContext: t
|
|
168
168
|
}) => {
|
|
169
|
-
const s = e.data.delta,
|
|
169
|
+
const s = e.data.delta, n = s ? Le(
|
|
170
170
|
s.value,
|
|
171
171
|
s.format === "percent" ? { style: "percent" } : void 0,
|
|
172
172
|
t.context.locale
|
|
173
173
|
) : void 0;
|
|
174
|
-
return
|
|
174
|
+
return je(
|
|
175
175
|
e,
|
|
176
|
-
/* @__PURE__ */
|
|
176
|
+
/* @__PURE__ */ u(Ie, { children: [
|
|
177
177
|
/* @__PURE__ */ a("div", { className: "make-ai-artifact__metric-value", children: Le(
|
|
178
178
|
e.data.value,
|
|
179
179
|
e.data.format,
|
|
180
180
|
t.context.locale
|
|
181
181
|
) }),
|
|
182
|
-
s ? /* @__PURE__ */
|
|
182
|
+
s ? /* @__PURE__ */ u(
|
|
183
183
|
"div",
|
|
184
184
|
{
|
|
185
185
|
className: `make-ai-artifact__delta make-ai-artifact__delta--${s.direction ?? "flat"}`,
|
|
186
186
|
children: [
|
|
187
187
|
/* @__PURE__ */ a("span", { "aria-hidden": "true", children: s.direction === "up" ? "↗" : s.direction === "down" ? "↘" : "→" }),
|
|
188
|
-
/* @__PURE__ */ a("span", { children:
|
|
188
|
+
/* @__PURE__ */ a("span", { children: n }),
|
|
189
189
|
s.label ? /* @__PURE__ */ a("span", { children: s.label }) : null
|
|
190
190
|
]
|
|
191
191
|
}
|
|
192
192
|
) : null,
|
|
193
193
|
e.data.context ? /* @__PURE__ */ a("p", { className: "make-ai-artifact__context", children: e.data.context }) : null,
|
|
194
|
-
|
|
194
|
+
qe(e, t)
|
|
195
195
|
] }),
|
|
196
196
|
"make-ai-artifact--metric",
|
|
197
197
|
t.themeStyle
|
|
198
198
|
);
|
|
199
|
-
},
|
|
199
|
+
}, Ja = ({
|
|
200
200
|
artifact: e,
|
|
201
201
|
renderContext: t
|
|
202
|
-
}) =>
|
|
202
|
+
}) => je(
|
|
203
203
|
e,
|
|
204
|
-
/* @__PURE__ */
|
|
205
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__comparison", children: e.data.items.map((s) => /* @__PURE__ */
|
|
204
|
+
/* @__PURE__ */ u(Ie, { children: [
|
|
205
|
+
/* @__PURE__ */ a("div", { className: "make-ai-artifact__comparison", children: e.data.items.map((s) => /* @__PURE__ */ u("div", { className: "make-ai-artifact__comparison-item", children: [
|
|
206
206
|
/* @__PURE__ */ a("span", { children: s.label }),
|
|
207
207
|
/* @__PURE__ */ a("strong", { children: Le(s.value, s.format, t.context.locale) }),
|
|
208
208
|
s.hint ? /* @__PURE__ */ a("small", { children: s.hint }) : null
|
|
209
209
|
] }, s.id)) }),
|
|
210
|
-
|
|
210
|
+
qe(e, t)
|
|
211
211
|
] }),
|
|
212
212
|
"make-ai-artifact--comparison",
|
|
213
213
|
t.themeStyle
|
|
214
|
-
),
|
|
214
|
+
), Ya = ({
|
|
215
215
|
artifact: e,
|
|
216
216
|
renderContext: t
|
|
217
217
|
}) => {
|
|
218
|
-
const s = e.data.series.flatMap((
|
|
219
|
-
return
|
|
218
|
+
const s = e.data.series.flatMap((l) => l.points.map((m) => m.y)), { max: n, min: i } = na(s), c = n - i || 1;
|
|
219
|
+
return je(
|
|
220
220
|
e,
|
|
221
|
-
/* @__PURE__ */
|
|
222
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend", children: e.data.series.map((
|
|
223
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-label", children:
|
|
224
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-bars", children:
|
|
225
|
-
const v = 18 + (
|
|
226
|
-
return /* @__PURE__ */
|
|
221
|
+
/* @__PURE__ */ u(Ie, { children: [
|
|
222
|
+
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend", children: e.data.series.map((l) => /* @__PURE__ */ u("div", { className: "make-ai-artifact__trend-series", children: [
|
|
223
|
+
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-label", children: l.label }),
|
|
224
|
+
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-bars", children: l.points.map((m, y) => {
|
|
225
|
+
const v = 18 + (m.y - i) / c * 70;
|
|
226
|
+
return /* @__PURE__ */ u("div", { className: "make-ai-artifact__trend-point", children: [
|
|
227
227
|
/* @__PURE__ */ a(
|
|
228
228
|
"span",
|
|
229
229
|
{
|
|
230
|
-
"aria-label": `${
|
|
231
|
-
|
|
232
|
-
|
|
230
|
+
"aria-label": `${m.x}: ${Le(
|
|
231
|
+
m.y,
|
|
232
|
+
l.format,
|
|
233
233
|
t.context.locale
|
|
234
234
|
)}`,
|
|
235
235
|
className: "make-ai-artifact__trend-bar",
|
|
236
236
|
role: "img",
|
|
237
237
|
style: { height: `${v}%` },
|
|
238
|
-
title: `${
|
|
239
|
-
|
|
240
|
-
|
|
238
|
+
title: `${m.x}: ${Le(
|
|
239
|
+
m.y,
|
|
240
|
+
l.format,
|
|
241
241
|
t.context.locale
|
|
242
242
|
)}`
|
|
243
243
|
}
|
|
244
244
|
),
|
|
245
|
-
/* @__PURE__ */ a("small", { children:
|
|
246
|
-
] }, `${
|
|
245
|
+
/* @__PURE__ */ a("small", { children: m.x })
|
|
246
|
+
] }, `${m.x}-${y}`);
|
|
247
247
|
}) })
|
|
248
|
-
] },
|
|
249
|
-
|
|
248
|
+
] }, l.id)) }),
|
|
249
|
+
qe(e, t)
|
|
250
250
|
] }),
|
|
251
251
|
"make-ai-artifact--trend",
|
|
252
252
|
t.themeStyle
|
|
253
253
|
);
|
|
254
|
-
},
|
|
254
|
+
}, Qa = ({
|
|
255
255
|
artifact: e,
|
|
256
256
|
renderContext: t
|
|
257
257
|
}) => {
|
|
258
|
-
const { max: s } =
|
|
258
|
+
const { max: s } = na(
|
|
259
259
|
e.data.items.map((i) => Math.abs(i.value))
|
|
260
|
-
),
|
|
261
|
-
return
|
|
260
|
+
), n = Math.max(s, 1);
|
|
261
|
+
return je(
|
|
262
262
|
e,
|
|
263
|
-
/* @__PURE__ */
|
|
264
|
-
/* @__PURE__ */ a("ol", { className: "make-ai-artifact__ranking", children: e.data.items.map((i, c) => /* @__PURE__ */
|
|
263
|
+
/* @__PURE__ */ u(Ie, { children: [
|
|
264
|
+
/* @__PURE__ */ a("ol", { className: "make-ai-artifact__ranking", children: e.data.items.map((i, c) => /* @__PURE__ */ u("li", { children: [
|
|
265
265
|
/* @__PURE__ */ a("span", { className: "make-ai-artifact__rank", children: c + 1 }),
|
|
266
|
-
/* @__PURE__ */
|
|
266
|
+
/* @__PURE__ */ u("span", { className: "make-ai-artifact__ranking-label", children: [
|
|
267
267
|
/* @__PURE__ */ a("span", { children: i.label }),
|
|
268
268
|
i.description ? /* @__PURE__ */ a("small", { children: i.description }) : null
|
|
269
269
|
] }),
|
|
270
|
-
/* @__PURE__ */ a("span", { className: "make-ai-artifact__ranking-track", "aria-hidden": "true", children: /* @__PURE__ */ a("span", { style: { width: `${Math.abs(i.value) /
|
|
270
|
+
/* @__PURE__ */ a("span", { className: "make-ai-artifact__ranking-track", "aria-hidden": "true", children: /* @__PURE__ */ a("span", { style: { width: `${Math.abs(i.value) / n * 100}%` } }) }),
|
|
271
271
|
/* @__PURE__ */ a("strong", { children: Le(i.value, i.format, t.context.locale) })
|
|
272
272
|
] }, i.id)) }),
|
|
273
|
-
|
|
273
|
+
qe(e, t)
|
|
274
274
|
] }),
|
|
275
275
|
"make-ai-artifact--ranking",
|
|
276
276
|
t.themeStyle
|
|
277
277
|
);
|
|
278
|
-
},
|
|
278
|
+
}, es = (e, t) => t.action ?? {
|
|
279
279
|
id: `open-${t.id}`,
|
|
280
280
|
label: t.title ?? t.id,
|
|
281
281
|
intent: "open-record",
|
|
282
282
|
target: { entityKey: e.data.entity.key, recordId: t.id }
|
|
283
|
-
},
|
|
283
|
+
}, ts = ({
|
|
284
284
|
artifact: e,
|
|
285
285
|
renderContext: t
|
|
286
|
-
}) =>
|
|
286
|
+
}) => je(
|
|
287
287
|
e,
|
|
288
|
-
/* @__PURE__ */
|
|
288
|
+
/* @__PURE__ */ u(Ie, { children: [
|
|
289
289
|
/* @__PURE__ */ a("div", { className: "make-ai-artifact__record-list", children: e.data.records.length === 0 ? /* @__PURE__ */ a("p", { className: "make-ai-artifact__empty", children: "没有符合条件的记录" }) : e.data.records.map((s) => {
|
|
290
|
-
const
|
|
290
|
+
const n = es(e, s), i = /* @__PURE__ */ u(Ie, { children: [
|
|
291
291
|
/* @__PURE__ */ a("strong", { children: s.title ?? s.id }),
|
|
292
|
-
/* @__PURE__ */ a("span", { className: "make-ai-artifact__record-values", children: e.data.columns.map((c) => /* @__PURE__ */
|
|
292
|
+
/* @__PURE__ */ a("span", { className: "make-ai-artifact__record-values", children: e.data.columns.map((c) => /* @__PURE__ */ u("span", { children: [
|
|
293
293
|
/* @__PURE__ */ a("small", { children: c.label }),
|
|
294
294
|
Le(
|
|
295
295
|
s.values[c.key],
|
|
@@ -304,7 +304,7 @@ const Le = (e, t, s) => {
|
|
|
304
304
|
{
|
|
305
305
|
className: "make-ai-artifact__record",
|
|
306
306
|
type: "button",
|
|
307
|
-
onClick: () =>
|
|
307
|
+
onClick: () => ia(n, {
|
|
308
308
|
artifact: e,
|
|
309
309
|
context: t.context
|
|
310
310
|
}, t),
|
|
@@ -313,290 +313,759 @@ const Le = (e, t, s) => {
|
|
|
313
313
|
s.id
|
|
314
314
|
) : /* @__PURE__ */ a("div", { className: "make-ai-artifact__record", children: i }, s.id);
|
|
315
315
|
}) }),
|
|
316
|
-
e.data.total !== void 0 ? /* @__PURE__ */
|
|
316
|
+
e.data.total !== void 0 ? /* @__PURE__ */ u("p", { className: "make-ai-artifact__record-total", children: [
|
|
317
317
|
"共 ",
|
|
318
318
|
e.data.total,
|
|
319
319
|
" 条"
|
|
320
320
|
] }) : null,
|
|
321
|
-
|
|
321
|
+
qe(e, t)
|
|
322
322
|
] }),
|
|
323
323
|
"make-ai-artifact--record-list",
|
|
324
324
|
t.themeStyle
|
|
325
|
-
),
|
|
325
|
+
), as = ({
|
|
326
326
|
artifact: e,
|
|
327
327
|
renderContext: t
|
|
328
|
-
}) =>
|
|
328
|
+
}) => je(
|
|
329
329
|
e,
|
|
330
|
-
/* @__PURE__ */
|
|
331
|
-
/* @__PURE__ */
|
|
330
|
+
/* @__PURE__ */ u(Ie, { children: [
|
|
331
|
+
/* @__PURE__ */ u("div", { className: `make-ai-artifact__notice make-ai-artifact__notice--${e.data.tone}`, children: [
|
|
332
332
|
/* @__PURE__ */ a("span", { "aria-hidden": "true", children: e.data.tone === "success" ? "✓" : e.data.tone === "warning" ? "!" : e.data.tone === "danger" ? "×" : "i" }),
|
|
333
333
|
/* @__PURE__ */ a("p", { children: e.data.body })
|
|
334
334
|
] }),
|
|
335
|
-
|
|
335
|
+
qe(e, t)
|
|
336
336
|
] }),
|
|
337
337
|
"make-ai-artifact--notice",
|
|
338
338
|
t.themeStyle
|
|
339
|
-
), He = (e, t, s) => ({ id: e, kinds: [t], priority: 0, render: s }),
|
|
340
|
-
He("platform.metric.default", "metric", (e, t, s) => /* @__PURE__ */ a(
|
|
341
|
-
He("platform.comparison.default", "comparison", (e, t, s) => /* @__PURE__ */ a(
|
|
342
|
-
He("platform.trend.default", "trend", (e, t, s) => /* @__PURE__ */ a(
|
|
343
|
-
He("platform.ranking.default", "ranking", (e, t, s) => /* @__PURE__ */ a(
|
|
344
|
-
He("platform.record-list.default", "record-list", (e, t, s) => /* @__PURE__ */ a(
|
|
345
|
-
He("platform.notice.default", "notice", (e, t, s) => /* @__PURE__ */ a(
|
|
346
|
-
],
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
339
|
+
), He = (e, t, s) => ({ id: e, kinds: [t], priority: 0, render: s }), ss = [
|
|
340
|
+
He("platform.metric.default", "metric", (e, t, s) => /* @__PURE__ */ a(Za, { artifact: e, renderContext: s })),
|
|
341
|
+
He("platform.comparison.default", "comparison", (e, t, s) => /* @__PURE__ */ a(Ja, { artifact: e, renderContext: s })),
|
|
342
|
+
He("platform.trend.default", "trend", (e, t, s) => /* @__PURE__ */ a(Ya, { artifact: e, renderContext: s })),
|
|
343
|
+
He("platform.ranking.default", "ranking", (e, t, s) => /* @__PURE__ */ a(Qa, { artifact: e, renderContext: s })),
|
|
344
|
+
He("platform.record-list.default", "record-list", (e, t, s) => /* @__PURE__ */ a(ts, { artifact: e, renderContext: s })),
|
|
345
|
+
He("platform.notice.default", "notice", (e, t, s) => /* @__PURE__ */ a(as, { artifact: e, renderContext: s }))
|
|
346
|
+
], ns = Qt(ss).templates, is = (e = ns) => Qt(e);
|
|
347
|
+
const rs = (e) => e?.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
348
|
+
function os(e, t, s = []) {
|
|
349
|
+
if (t == null)
|
|
350
|
+
throw new Error("[lucide]: iconNode is required when icon name is used");
|
|
351
|
+
return {
|
|
352
|
+
name: rs(e),
|
|
353
|
+
size: 24,
|
|
354
|
+
node: t,
|
|
355
|
+
...s.length > 0 ? { aliases: s } : {}
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
const cs = (e) => {
|
|
359
|
+
let t = "", s = !1;
|
|
360
|
+
for (const n of e) {
|
|
361
|
+
if (n === "-" || n === "_" || n <= " ") {
|
|
362
|
+
s = t.length > 0;
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
t.length === 0 ? t += n.toLowerCase() : t += s ? n.toUpperCase() : n, s = !1;
|
|
366
|
+
}
|
|
367
|
+
return t;
|
|
368
|
+
};
|
|
369
|
+
const ls = (e) => {
|
|
370
|
+
const t = cs(e);
|
|
371
|
+
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
372
|
+
};
|
|
373
|
+
const Ct = (...e) => e.filter((t, s, n) => !!t && t.trim() !== "" && n.indexOf(t) === s).join(" ").trim();
|
|
374
|
+
const Re = {
|
|
375
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
376
|
+
width: 24,
|
|
377
|
+
height: 24,
|
|
378
|
+
viewBox: "0 0 24 24",
|
|
379
|
+
fill: "none",
|
|
380
|
+
stroke: "currentColor",
|
|
381
|
+
"stroke-width": 2,
|
|
382
|
+
"stroke-linecap": "round",
|
|
383
|
+
"stroke-linejoin": "round"
|
|
384
|
+
};
|
|
385
|
+
function bt(e) {
|
|
386
|
+
return e != null;
|
|
387
|
+
}
|
|
388
|
+
function ds(e, t = {}) {
|
|
389
|
+
const s = t.attributeNames ?? {}, n = (C) => s[C] ?? C, i = e.size ?? e.width ?? Re.width, c = e.size ?? e.height ?? Re.height, l = e.aliases?.filter((C) => typeof C == "string" && C.trim() !== "").map((C) => `lucide-${C}`) ?? [], m = [...e.name ? [`lucide-${e.name}`] : [], ...l], y = t.className?.split(" ").filter(Boolean) ?? [], v = t.includeDefaultClasses === !1 ? Ct(...y) : Ct("lucide", ...m, ...y), p = t.absoluteStrokeWidth ? Number(t.strokeWidth ?? Re["stroke-width"]) * Number(e.size ?? e.width ?? Re.width) / Number(t.size ?? t.width ?? Re.width) : t.strokeWidth ?? Re["stroke-width"];
|
|
390
|
+
return [
|
|
391
|
+
"svg",
|
|
392
|
+
{
|
|
393
|
+
...Object.entries(Re).reduce((C, [S, k]) => (C[n(S)] = k, C), {}),
|
|
394
|
+
..."color" in t && t.color && {
|
|
395
|
+
[n("stroke")]: t.color
|
|
396
|
+
},
|
|
397
|
+
..."size" in t && bt(t.size) && {
|
|
398
|
+
[n("width")]: t.size,
|
|
399
|
+
[n("height")]: t.size
|
|
400
|
+
},
|
|
401
|
+
..."width" in t && bt(t.width) && {
|
|
402
|
+
[n("width")]: t.width
|
|
403
|
+
},
|
|
404
|
+
..."height" in t && bt(t.height) && {
|
|
405
|
+
[n("height")]: t.height
|
|
406
|
+
},
|
|
407
|
+
[n("stroke-width")]: p,
|
|
408
|
+
...v && {
|
|
409
|
+
[n("class")]: v
|
|
410
|
+
},
|
|
411
|
+
[n("viewBox")]: `0 0 ${i} ${c}`,
|
|
412
|
+
...t.hasA11yProp === !1 ? {
|
|
413
|
+
[n("aria-hidden")]: "true"
|
|
414
|
+
} : {},
|
|
415
|
+
..."attributes" in t && t.attributes
|
|
416
|
+
},
|
|
417
|
+
e.node.map((C) => {
|
|
418
|
+
const [S, k, U] = C, L = t.nonScalingStroke ? { [n("vector-effect")]: "non-scaling-stroke", ...k } : k;
|
|
419
|
+
return U ? [S, L, U] : [S, L];
|
|
420
|
+
})
|
|
421
|
+
];
|
|
422
|
+
}
|
|
423
|
+
function us(e, t = {}) {
|
|
424
|
+
return ds(e, {
|
|
357
425
|
...t,
|
|
358
|
-
|
|
426
|
+
attributeNames: {
|
|
427
|
+
...t.attributeNames,
|
|
428
|
+
class: "className",
|
|
429
|
+
"stroke-width": "strokeWidth",
|
|
430
|
+
"stroke-linecap": "strokeLinecap",
|
|
431
|
+
"stroke-linejoin": "strokeLinejoin",
|
|
432
|
+
"vector-effect": "vectorEffect"
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
const ms = (e) => {
|
|
437
|
+
for (const t in e)
|
|
438
|
+
if (t.startsWith("aria-") || t === "role" || t === "title")
|
|
439
|
+
return !0;
|
|
440
|
+
return !1;
|
|
441
|
+
}, hs = Ba({}), ps = () => ja(hs), fs = Yt(
|
|
442
|
+
({
|
|
443
|
+
color: e,
|
|
444
|
+
size: t,
|
|
445
|
+
width: s,
|
|
446
|
+
height: n,
|
|
447
|
+
strokeWidth: i,
|
|
448
|
+
absoluteStrokeWidth: c,
|
|
449
|
+
nonScalingStroke: l,
|
|
450
|
+
className: m = "",
|
|
451
|
+
children: y,
|
|
452
|
+
iconNode: v = [],
|
|
453
|
+
icon: p = {
|
|
454
|
+
node: v,
|
|
455
|
+
aliases: [],
|
|
456
|
+
size: 24
|
|
457
|
+
},
|
|
458
|
+
...A
|
|
459
|
+
}, C) => {
|
|
460
|
+
const {
|
|
461
|
+
size: S = 24,
|
|
462
|
+
strokeWidth: k = 2,
|
|
463
|
+
absoluteStrokeWidth: U = !1,
|
|
464
|
+
nonScalingStroke: L = !1,
|
|
465
|
+
color: H = "currentColor",
|
|
466
|
+
className: _ = ""
|
|
467
|
+
} = ps() ?? {}, h = !!y || ms(A), [r, b, M = []] = us(p, {
|
|
468
|
+
color: e ?? H,
|
|
469
|
+
width: s ?? t ?? S,
|
|
470
|
+
height: n ?? t ?? S,
|
|
471
|
+
strokeWidth: i ?? k,
|
|
472
|
+
absoluteStrokeWidth: c ?? U,
|
|
473
|
+
nonScalingStroke: l ?? L,
|
|
474
|
+
className: Ct(_, m),
|
|
475
|
+
hasA11yProp: h,
|
|
476
|
+
attributes: A
|
|
477
|
+
});
|
|
478
|
+
return Nt(
|
|
479
|
+
r,
|
|
480
|
+
{
|
|
481
|
+
ref: C,
|
|
482
|
+
...b
|
|
483
|
+
},
|
|
484
|
+
[
|
|
485
|
+
...M.map(([W, N]) => Nt(W, N)),
|
|
486
|
+
...Array.isArray(y) ? y : [y]
|
|
487
|
+
]
|
|
488
|
+
);
|
|
359
489
|
}
|
|
360
|
-
)
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
490
|
+
);
|
|
491
|
+
function j(e, t = [], s = []) {
|
|
492
|
+
const n = typeof e == "string" ? os(e, t, s) : e, i = Yt(
|
|
493
|
+
({ className: c, ...l }, m) => Nt(fs, {
|
|
494
|
+
ref: m,
|
|
495
|
+
icon: n,
|
|
496
|
+
className: c,
|
|
497
|
+
...l
|
|
498
|
+
})
|
|
499
|
+
);
|
|
500
|
+
return n.name && (i.displayName = ls(n.name)), i;
|
|
501
|
+
}
|
|
502
|
+
const ra = {
|
|
503
|
+
name: "arrow-down-to-line",
|
|
504
|
+
size: 24,
|
|
505
|
+
node: [
|
|
506
|
+
["path", { d: "M12 17V3", key: "1cwfxf" }],
|
|
507
|
+
["path", { d: "m6 11 6 6 6-6", key: "12ii2o" }],
|
|
508
|
+
["path", { d: "M19 21H5", key: "150jfl" }]
|
|
509
|
+
]
|
|
510
|
+
};
|
|
511
|
+
ra.node;
|
|
512
|
+
const vs = j(ra);
|
|
513
|
+
const oa = {
|
|
514
|
+
name: "check",
|
|
515
|
+
size: 24,
|
|
516
|
+
node: [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]]
|
|
517
|
+
};
|
|
518
|
+
oa.node;
|
|
519
|
+
const ys = j(oa);
|
|
520
|
+
const ca = {
|
|
521
|
+
name: "chevron-down",
|
|
522
|
+
size: 24,
|
|
523
|
+
node: [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]]
|
|
524
|
+
};
|
|
525
|
+
ca.node;
|
|
526
|
+
const ks = j(ca);
|
|
527
|
+
const la = {
|
|
528
|
+
name: "chevron-up",
|
|
529
|
+
size: 24,
|
|
530
|
+
node: [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]]
|
|
531
|
+
};
|
|
532
|
+
la.node;
|
|
533
|
+
const gs = j(la);
|
|
534
|
+
const da = {
|
|
535
|
+
name: "circle-alert",
|
|
536
|
+
size: 24,
|
|
537
|
+
node: [
|
|
538
|
+
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
539
|
+
["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
|
|
540
|
+
["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
|
|
541
|
+
],
|
|
542
|
+
aliases: ["alert-circle"]
|
|
543
|
+
};
|
|
544
|
+
da.node;
|
|
545
|
+
const bs = j(da);
|
|
546
|
+
const ua = {
|
|
547
|
+
name: "cloud-off",
|
|
548
|
+
size: 24,
|
|
549
|
+
node: [
|
|
550
|
+
[
|
|
551
|
+
"path",
|
|
552
|
+
{ d: "M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057", key: "1uxyv8" }
|
|
553
|
+
],
|
|
554
|
+
["path", { d: "M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78", key: "99tcn7" }],
|
|
555
|
+
["path", { d: "m2 2 20 20", key: "1ooewy" }]
|
|
556
|
+
]
|
|
557
|
+
};
|
|
558
|
+
ua.node;
|
|
559
|
+
const _s = j(ua);
|
|
560
|
+
const ma = {
|
|
561
|
+
name: "copy",
|
|
562
|
+
size: 24,
|
|
563
|
+
node: [
|
|
564
|
+
["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
|
|
565
|
+
["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2", key: "zix9uf" }]
|
|
566
|
+
]
|
|
567
|
+
};
|
|
568
|
+
ma.node;
|
|
569
|
+
const ws = j(ma);
|
|
570
|
+
const ha = {
|
|
571
|
+
name: "file-text",
|
|
572
|
+
size: 24,
|
|
573
|
+
node: [
|
|
574
|
+
[
|
|
575
|
+
"path",
|
|
576
|
+
{
|
|
577
|
+
d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",
|
|
578
|
+
key: "1oefj6"
|
|
579
|
+
}
|
|
580
|
+
],
|
|
581
|
+
["path", { d: "M14 2v5a1 1 0 0 0 1 1h5", key: "wfsgrz" }],
|
|
582
|
+
["path", { d: "M10 9H8", key: "b1mrlr" }],
|
|
583
|
+
["path", { d: "M16 13H8", key: "t4e002" }],
|
|
584
|
+
["path", { d: "M16 17H8", key: "z1uh3a" }]
|
|
585
|
+
]
|
|
586
|
+
};
|
|
587
|
+
ha.node;
|
|
588
|
+
const Ot = j(ha);
|
|
589
|
+
const pa = {
|
|
590
|
+
name: "list",
|
|
591
|
+
size: 24,
|
|
592
|
+
node: [
|
|
593
|
+
["path", { d: "M3 5h.01", key: "18ugdj" }],
|
|
594
|
+
["path", { d: "M3 12h.01", key: "nlz23k" }],
|
|
595
|
+
["path", { d: "M3 19h.01", key: "noohij" }],
|
|
596
|
+
["path", { d: "M8 5h13", key: "1pao27" }],
|
|
597
|
+
["path", { d: "M8 12h13", key: "1za7za" }],
|
|
598
|
+
["path", { d: "M8 19h13", key: "m83p4d" }]
|
|
599
|
+
]
|
|
600
|
+
};
|
|
601
|
+
pa.node;
|
|
602
|
+
const Is = j(pa);
|
|
603
|
+
const fa = {
|
|
604
|
+
name: "maximize",
|
|
605
|
+
size: 24,
|
|
606
|
+
node: [
|
|
607
|
+
["path", { d: "M8 3H5a2 2 0 0 0-2 2v3", key: "1dcmit" }],
|
|
608
|
+
["path", { d: "M21 8V5a2 2 0 0 0-2-2h-3", key: "1e4gt3" }],
|
|
609
|
+
["path", { d: "M3 16v3a2 2 0 0 0 2 2h3", key: "wsl5sc" }],
|
|
610
|
+
["path", { d: "M16 21h3a2 2 0 0 0 2-2v-3", key: "18trek" }]
|
|
611
|
+
]
|
|
612
|
+
};
|
|
613
|
+
fa.node;
|
|
614
|
+
const Ns = j(fa);
|
|
615
|
+
const va = {
|
|
616
|
+
name: "message-square-text",
|
|
617
|
+
size: 24,
|
|
618
|
+
node: [
|
|
619
|
+
[
|
|
620
|
+
"path",
|
|
621
|
+
{
|
|
622
|
+
d: "M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",
|
|
623
|
+
key: "18887p"
|
|
624
|
+
}
|
|
625
|
+
],
|
|
626
|
+
["path", { d: "M7 11h10", key: "1twpyw" }],
|
|
627
|
+
["path", { d: "M7 15h6", key: "d9of3u" }],
|
|
628
|
+
["path", { d: "M7 7h8", key: "af5zfr" }]
|
|
629
|
+
]
|
|
630
|
+
};
|
|
631
|
+
va.node;
|
|
632
|
+
const As = j(va);
|
|
633
|
+
const ya = {
|
|
634
|
+
name: "minimize",
|
|
635
|
+
size: 24,
|
|
636
|
+
node: [
|
|
637
|
+
["path", { d: "M8 3v3a2 2 0 0 1-2 2H3", key: "hohbtr" }],
|
|
638
|
+
["path", { d: "M21 8h-3a2 2 0 0 1-2-2V3", key: "5jw1f3" }],
|
|
639
|
+
["path", { d: "M3 16h3a2 2 0 0 1 2 2v3", key: "198tvr" }],
|
|
640
|
+
["path", { d: "M16 21v-3a2 2 0 0 1 2-2h3", key: "ph8mxp" }]
|
|
641
|
+
]
|
|
642
|
+
};
|
|
643
|
+
ya.node;
|
|
644
|
+
const Cs = j(ya);
|
|
645
|
+
const ka = {
|
|
646
|
+
name: "pause",
|
|
647
|
+
size: 24,
|
|
648
|
+
node: [
|
|
649
|
+
["rect", { x: "14", y: "3", width: "5", height: "18", rx: "1", key: "kaeet6" }],
|
|
650
|
+
["rect", { x: "5", y: "3", width: "5", height: "18", rx: "1", key: "1wsw3u" }]
|
|
651
|
+
]
|
|
652
|
+
};
|
|
653
|
+
ka.node;
|
|
654
|
+
const Ms = j(ka);
|
|
655
|
+
const ga = {
|
|
656
|
+
name: "pencil",
|
|
657
|
+
size: 24,
|
|
658
|
+
node: [
|
|
659
|
+
[
|
|
660
|
+
"path",
|
|
661
|
+
{
|
|
662
|
+
d: "M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",
|
|
663
|
+
key: "1a8usu"
|
|
664
|
+
}
|
|
665
|
+
],
|
|
666
|
+
["path", { d: "m15 5 4 4", key: "1mk7zo" }]
|
|
667
|
+
]
|
|
668
|
+
};
|
|
669
|
+
ga.node;
|
|
670
|
+
const Ts = j(ga);
|
|
671
|
+
const ba = {
|
|
672
|
+
name: "pin",
|
|
673
|
+
size: 24,
|
|
674
|
+
node: [
|
|
675
|
+
["path", { d: "M12 17v5", key: "bb1du9" }],
|
|
676
|
+
[
|
|
677
|
+
"path",
|
|
678
|
+
{
|
|
679
|
+
d: "M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",
|
|
680
|
+
key: "1nkz8b"
|
|
681
|
+
}
|
|
682
|
+
]
|
|
683
|
+
]
|
|
684
|
+
};
|
|
685
|
+
ba.node;
|
|
686
|
+
const Es = j(ba);
|
|
687
|
+
const _a = {
|
|
688
|
+
name: "plus",
|
|
689
|
+
size: 24,
|
|
690
|
+
node: [
|
|
691
|
+
["path", { d: "M5 12h14", key: "1ays0h" }],
|
|
692
|
+
["path", { d: "M12 5v14", key: "s699le" }]
|
|
693
|
+
]
|
|
694
|
+
};
|
|
695
|
+
_a.node;
|
|
696
|
+
const Tt = j(_a);
|
|
697
|
+
const wa = {
|
|
698
|
+
name: "refresh-cw",
|
|
699
|
+
size: 24,
|
|
700
|
+
node: [
|
|
701
|
+
["path", { d: "M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8", key: "v9h5vc" }],
|
|
702
|
+
["path", { d: "M21 3v5h-5", key: "1q7to0" }],
|
|
703
|
+
["path", { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16", key: "3uifl3" }],
|
|
704
|
+
["path", { d: "M8 16H3v5", key: "1cv678" }]
|
|
705
|
+
]
|
|
706
|
+
};
|
|
707
|
+
wa.node;
|
|
708
|
+
const vt = j(wa);
|
|
709
|
+
const Ia = {
|
|
710
|
+
name: "rotate-ccw",
|
|
711
|
+
size: 24,
|
|
712
|
+
node: [
|
|
713
|
+
["path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8", key: "1357e3" }],
|
|
714
|
+
["path", { d: "M3 3v5h5", key: "1xhq8a" }]
|
|
715
|
+
]
|
|
716
|
+
};
|
|
717
|
+
Ia.node;
|
|
718
|
+
const $s = j(Ia);
|
|
719
|
+
const Na = {
|
|
720
|
+
name: "send",
|
|
721
|
+
size: 24,
|
|
722
|
+
node: [
|
|
723
|
+
[
|
|
724
|
+
"path",
|
|
725
|
+
{
|
|
726
|
+
d: "M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",
|
|
727
|
+
key: "1ffxy3"
|
|
728
|
+
}
|
|
729
|
+
],
|
|
730
|
+
["path", { d: "m21.854 2.147-10.94 10.939", key: "12cjpa" }]
|
|
731
|
+
]
|
|
732
|
+
};
|
|
733
|
+
Na.node;
|
|
734
|
+
const qt = j(Na);
|
|
735
|
+
const Aa = {
|
|
736
|
+
name: "sparkles",
|
|
737
|
+
size: 24,
|
|
738
|
+
node: [
|
|
739
|
+
[
|
|
740
|
+
"path",
|
|
741
|
+
{
|
|
742
|
+
d: "M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",
|
|
743
|
+
key: "1s2grr"
|
|
744
|
+
}
|
|
745
|
+
],
|
|
746
|
+
["path", { d: "M20 2v4", key: "1rf3ol" }],
|
|
747
|
+
["path", { d: "M22 4h-4", key: "gwowj6" }],
|
|
748
|
+
["circle", { cx: "4", cy: "20", r: "2", key: "6kqj1y" }]
|
|
749
|
+
],
|
|
750
|
+
aliases: ["stars"]
|
|
751
|
+
};
|
|
752
|
+
Aa.node;
|
|
753
|
+
const Ca = j(Aa);
|
|
754
|
+
const Ma = {
|
|
755
|
+
name: "thumbs-down",
|
|
756
|
+
size: 24,
|
|
757
|
+
node: [
|
|
758
|
+
[
|
|
759
|
+
"path",
|
|
760
|
+
{
|
|
761
|
+
d: "M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",
|
|
762
|
+
key: "m61m77"
|
|
763
|
+
}
|
|
764
|
+
],
|
|
765
|
+
["path", { d: "M17 14V2", key: "8ymqnk" }]
|
|
766
|
+
]
|
|
767
|
+
};
|
|
768
|
+
Ma.node;
|
|
769
|
+
const Ss = j(Ma);
|
|
770
|
+
const Ta = {
|
|
771
|
+
name: "thumbs-up",
|
|
772
|
+
size: 24,
|
|
773
|
+
node: [
|
|
774
|
+
[
|
|
775
|
+
"path",
|
|
776
|
+
{
|
|
777
|
+
d: "M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",
|
|
778
|
+
key: "emmmcr"
|
|
779
|
+
}
|
|
780
|
+
],
|
|
781
|
+
["path", { d: "M7 10v12", key: "1qc93n" }]
|
|
782
|
+
]
|
|
783
|
+
};
|
|
784
|
+
Ta.node;
|
|
785
|
+
const Rs = j(Ta);
|
|
786
|
+
const Ea = {
|
|
787
|
+
name: "trash",
|
|
788
|
+
size: 24,
|
|
789
|
+
node: [
|
|
790
|
+
["path", { d: "M10 11v6", key: "nco0om" }],
|
|
791
|
+
["path", { d: "M14 11v6", key: "outv1u" }],
|
|
792
|
+
["path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6", key: "miytrc" }],
|
|
793
|
+
["path", { d: "M3 6h18", key: "d0wm0j" }],
|
|
794
|
+
["path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2", key: "e791ji" }]
|
|
795
|
+
],
|
|
796
|
+
aliases: ["trash-2"]
|
|
797
|
+
};
|
|
798
|
+
Ea.node;
|
|
799
|
+
const jt = j(Ea);
|
|
800
|
+
const $a = {
|
|
801
|
+
name: "triangle-alert",
|
|
802
|
+
size: 24,
|
|
803
|
+
node: [
|
|
804
|
+
[
|
|
805
|
+
"path",
|
|
806
|
+
{
|
|
807
|
+
d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",
|
|
808
|
+
key: "wmoenq"
|
|
809
|
+
}
|
|
810
|
+
],
|
|
811
|
+
["path", { d: "M12 9v4", key: "juzpu7" }],
|
|
812
|
+
["path", { d: "M12 17h.01", key: "p32p05" }]
|
|
813
|
+
],
|
|
814
|
+
aliases: ["alert-triangle"]
|
|
815
|
+
};
|
|
816
|
+
$a.node;
|
|
817
|
+
const Ls = j($a);
|
|
818
|
+
const Sa = {
|
|
819
|
+
name: "upload",
|
|
820
|
+
size: 24,
|
|
821
|
+
node: [
|
|
822
|
+
["path", { d: "M12 3v12", key: "1x0j5s" }],
|
|
823
|
+
["path", { d: "m17 8-5-5-5 5", key: "7q97r8" }],
|
|
824
|
+
["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }]
|
|
825
|
+
]
|
|
826
|
+
};
|
|
827
|
+
Sa.node;
|
|
828
|
+
const zs = j(Sa);
|
|
829
|
+
const Ra = {
|
|
830
|
+
name: "x",
|
|
831
|
+
size: 24,
|
|
832
|
+
node: [
|
|
833
|
+
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
|
|
834
|
+
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
835
|
+
]
|
|
836
|
+
};
|
|
837
|
+
Ra.node;
|
|
838
|
+
const tt = j(Ra), Oe = () => globalThis.crypto.randomUUID(), Bt = 1e3, _t = (e, t) => e?.chatId === t.chatId && e.revision > t.revision ? e : t, Et = (e) => {
|
|
370
839
|
const t = e, s = t?.status ?? t?.response?.status;
|
|
371
840
|
return s === 410 || t?.code === "AI_UPLOAD_EXPIRED" ? "上传已过期,请移除后重新选择文件" : s === 409 ? "数据已变化或对话仍在运行,请刷新后重试" : s === 401 || t?.code === "AI_AUTH_REQUIRED" || t?.code === "AI_AUTH_EXPIRED" ? "登录已失效,请重新登录" : s === 403 ? "当前账号无权访问该对话" : s === 404 ? "对话或回答已不可见,请刷新列表" : t?.message?.startsWith("输入内容过长") ? t.message : "操作未完成,请重试或刷新对话";
|
|
372
841
|
};
|
|
373
|
-
function
|
|
374
|
-
const s = t.features?.conversationManagement === !0,
|
|
375
|
-
i.current =
|
|
376
|
-
const c =
|
|
377
|
-
const
|
|
378
|
-
|
|
379
|
-
}, [
|
|
380
|
-
const
|
|
381
|
-
return
|
|
382
|
-
},
|
|
383
|
-
const
|
|
384
|
-
|
|
385
|
-
},
|
|
386
|
-
|
|
387
|
-
(
|
|
388
|
-
(g) => g.chatId ===
|
|
842
|
+
function xs(e, t) {
|
|
843
|
+
const s = t.features?.conversationManagement === !0, n = s ? t.scopeKey?.(e) ?? e.app.id : "", i = D(n);
|
|
844
|
+
i.current = n;
|
|
845
|
+
const c = D(n), [l, m] = $(fe), y = D(l), v = (o) => {
|
|
846
|
+
const d = typeof o == "function" ? o(y.current) : o;
|
|
847
|
+
y.current = d, m(d);
|
|
848
|
+
}, [p, A] = $([]), [C, S] = $(), k = D(void 0), [U, L] = $(""), [H, _] = $(void 0), [h, r] = $(!1), [b, M] = $(!1), [W, N] = $(s), [X, Q] = $(!1), [ie, Z] = $(), [ue, ve] = $([]), [Me, Be] = $([]), O = D(/* @__PURE__ */ new Set()), V = D(/* @__PURE__ */ new Map()), F = D(0), Y = D(0), oe = D(0), ge = D(void 0), me = D(void 0), Te = D(/* @__PURE__ */ new Map()), P = (o, d = n) => Y.current === o && i.current === d, ae = () => {
|
|
849
|
+
const o = new AbortController();
|
|
850
|
+
return O.current.add(o), o;
|
|
851
|
+
}, ee = (o) => O.current.delete(o), te = (o) => {
|
|
852
|
+
const d = o ? _t(k.current, o) : void 0;
|
|
853
|
+
k.current = d, S(d);
|
|
854
|
+
}, Ve = (o) => {
|
|
855
|
+
A(
|
|
856
|
+
(d) => d.map(
|
|
857
|
+
(g) => g.chatId === o.chatId ? _t(g, o) : g
|
|
389
858
|
)
|
|
390
859
|
);
|
|
391
|
-
},
|
|
392
|
-
|
|
393
|
-
},
|
|
860
|
+
}, Ke = (o) => {
|
|
861
|
+
A((d) => d.filter((g) => g.chatId !== o));
|
|
862
|
+
}, at = () => {
|
|
394
863
|
oe.current += 1;
|
|
395
864
|
}, ce = () => {
|
|
396
|
-
for (const
|
|
397
|
-
|
|
398
|
-
},
|
|
399
|
-
|
|
400
|
-
errorType:
|
|
401
|
-
}),
|
|
402
|
-
}, le = async (
|
|
865
|
+
for (const o of V.current.values()) o.abort();
|
|
866
|
+
V.current.clear();
|
|
867
|
+
}, G = (o) => {
|
|
868
|
+
o instanceof Error && o.name === "AbortError" || (console.warn("[make-ai-assistant] conversation operation failed", {
|
|
869
|
+
errorType: o instanceof Error ? o.name : typeof o
|
|
870
|
+
}), Z(Et(o)));
|
|
871
|
+
}, le = async (o) => {
|
|
403
872
|
if (!s || !t.listConversations) return;
|
|
404
|
-
const
|
|
873
|
+
const d = Y.current, g = ++oe.current, w = ae();
|
|
405
874
|
try {
|
|
406
|
-
const
|
|
875
|
+
const T = await t.listConversations(
|
|
407
876
|
e,
|
|
408
|
-
{ cursor:
|
|
409
|
-
{ signal:
|
|
877
|
+
{ cursor: o },
|
|
878
|
+
{ signal: w.signal }
|
|
410
879
|
);
|
|
411
|
-
if (
|
|
880
|
+
if (!P(d) || w.signal.aborted || g !== oe.current)
|
|
412
881
|
return;
|
|
413
|
-
|
|
414
|
-
const
|
|
415
|
-
(
|
|
882
|
+
A((z) => {
|
|
883
|
+
const I = new Map(z.map((E) => [E.chatId, E])), R = T.chats.map(
|
|
884
|
+
(E) => _t(I.get(E.chatId), E)
|
|
416
885
|
);
|
|
417
886
|
return [
|
|
418
887
|
...new Map(
|
|
419
|
-
[...
|
|
420
|
-
|
|
421
|
-
|
|
888
|
+
[...o ? z : [], ...R].map((E) => [
|
|
889
|
+
E.chatId,
|
|
890
|
+
E
|
|
422
891
|
])
|
|
423
892
|
).values()
|
|
424
893
|
];
|
|
425
|
-
}),
|
|
426
|
-
} catch (
|
|
427
|
-
|
|
894
|
+
}), L(T.nextCursor);
|
|
895
|
+
} catch (T) {
|
|
896
|
+
P(d) && !w.signal.aborted && g === oe.current && G(T);
|
|
428
897
|
} finally {
|
|
429
|
-
|
|
898
|
+
ee(w), P(d) && g === oe.current && N(!1);
|
|
430
899
|
}
|
|
431
|
-
}, Ne = async (
|
|
900
|
+
}, Ne = async (o) => {
|
|
432
901
|
if (!t.getConversation) return;
|
|
433
|
-
const
|
|
902
|
+
const d = Y.current, g = ae();
|
|
434
903
|
try {
|
|
435
|
-
const
|
|
904
|
+
const w = await t.getConversation(
|
|
436
905
|
e,
|
|
437
|
-
{ chatId:
|
|
906
|
+
{ chatId: o },
|
|
438
907
|
{ signal: g.signal }
|
|
439
908
|
);
|
|
440
|
-
if (
|
|
441
|
-
|
|
442
|
-
} catch (
|
|
443
|
-
|
|
909
|
+
if (!P(d) || g.signal.aborted || w.chatId !== o) return;
|
|
910
|
+
Ve(w), k.current?.chatId === o && te(w);
|
|
911
|
+
} catch (w) {
|
|
912
|
+
P(d) && !g.signal.aborted && G(w);
|
|
444
913
|
} finally {
|
|
445
|
-
|
|
914
|
+
ee(g);
|
|
446
915
|
}
|
|
447
|
-
}, Ee = async (
|
|
448
|
-
const
|
|
449
|
-
let
|
|
916
|
+
}, Ee = async (o, d, g) => {
|
|
917
|
+
const w = Y.current, T = F.current;
|
|
918
|
+
let z;
|
|
450
919
|
try {
|
|
451
|
-
for await (const
|
|
452
|
-
if (
|
|
920
|
+
for await (const I of o) {
|
|
921
|
+
if (!P(w) || d.signal.aborted || T !== F.current || k.current?.chatId !== g)
|
|
453
922
|
return;
|
|
454
|
-
const
|
|
455
|
-
if (
|
|
456
|
-
|
|
457
|
-
const
|
|
458
|
-
if (
|
|
459
|
-
|
|
923
|
+
const R = ea(I);
|
|
924
|
+
if (R.type === "response.accepted" || R.type === "response.state") {
|
|
925
|
+
z = R.responseId;
|
|
926
|
+
const E = V.current.get(z);
|
|
927
|
+
if (E && E !== d) {
|
|
928
|
+
R.type === "response.accepted" && v((q) => we(q, R)), d.abort();
|
|
460
929
|
return;
|
|
461
930
|
}
|
|
462
|
-
|
|
931
|
+
V.current.set(z, d);
|
|
463
932
|
}
|
|
464
|
-
v((
|
|
933
|
+
v((E) => we(E, R)), R.type === "response.accepted" && Ne(g), R.type === "response.terminal" && (ve((E) => E.filter((q) => q !== R.responseId)), le());
|
|
465
934
|
}
|
|
466
|
-
} catch (
|
|
467
|
-
|
|
468
|
-
...
|
|
469
|
-
status: Object.values(
|
|
470
|
-
(
|
|
935
|
+
} catch (I) {
|
|
936
|
+
P(w) && !d.signal.aborted && T === F.current && (G(I), z || v((R) => ({
|
|
937
|
+
...R,
|
|
938
|
+
status: Object.values(R.responses ?? {}).some(
|
|
939
|
+
(E) => !gt(E)
|
|
471
940
|
) ? "streaming" : "error"
|
|
472
941
|
})));
|
|
473
942
|
} finally {
|
|
474
|
-
|
|
943
|
+
z && V.current.get(z) === d && V.current.delete(z), ee(d);
|
|
475
944
|
}
|
|
476
|
-
}, Ae = async (
|
|
945
|
+
}, Ae = async (o, d, g, w) => {
|
|
477
946
|
if (!t.getResponse || !t.watchResponse) return;
|
|
478
|
-
const
|
|
479
|
-
|
|
480
|
-
),
|
|
947
|
+
const T = new Set(
|
|
948
|
+
o.filter((I) => I.role === "assistant" && I.persistent).map((I) => I.responseId)
|
|
949
|
+
), z = [
|
|
481
950
|
...new Map(
|
|
482
|
-
|
|
483
|
-
(
|
|
484
|
-
).map((
|
|
951
|
+
o.filter(
|
|
952
|
+
(I) => I.role === "user" && I.responseId && !T.has(I.responseId)
|
|
953
|
+
).map((I) => [I.responseId, I.cursor])
|
|
485
954
|
).entries()
|
|
486
955
|
].slice(-20);
|
|
487
|
-
for (const [
|
|
488
|
-
if (
|
|
489
|
-
if (
|
|
490
|
-
const
|
|
956
|
+
for (const [I, R] of z) {
|
|
957
|
+
if (!P(w) || g !== F.current) return;
|
|
958
|
+
if (V.current.has(I)) continue;
|
|
959
|
+
const E = ae();
|
|
491
960
|
try {
|
|
492
|
-
const
|
|
961
|
+
const q = await t.getResponse(
|
|
493
962
|
e,
|
|
494
|
-
{ chatId:
|
|
495
|
-
{ signal:
|
|
963
|
+
{ chatId: d, responseId: I },
|
|
964
|
+
{ signal: E.signal }
|
|
496
965
|
);
|
|
497
|
-
if (
|
|
966
|
+
if (!P(w) || E.signal.aborted || g !== F.current || V.current.has(I)) continue;
|
|
498
967
|
v(
|
|
499
|
-
(
|
|
500
|
-
|
|
501
|
-
gt(
|
|
968
|
+
(be) => we(
|
|
969
|
+
be,
|
|
970
|
+
gt(q) ? { type: "response.snapshot", snapshot: q } : {
|
|
502
971
|
type: "response.state",
|
|
503
|
-
chatId:
|
|
504
|
-
responseId:
|
|
505
|
-
status:
|
|
972
|
+
chatId: d,
|
|
973
|
+
responseId: I,
|
|
974
|
+
status: q.status
|
|
506
975
|
}
|
|
507
976
|
)
|
|
508
|
-
),
|
|
509
|
-
(
|
|
977
|
+
), q.status === "failed" || q.status === "cancelled" ? v(
|
|
978
|
+
(be) => we(be, {
|
|
510
979
|
type: "response.terminal",
|
|
511
|
-
chatId:
|
|
512
|
-
responseId:
|
|
513
|
-
status:
|
|
980
|
+
chatId: d,
|
|
981
|
+
responseId: I,
|
|
982
|
+
status: q.status
|
|
514
983
|
})
|
|
515
|
-
) : (
|
|
984
|
+
) : (V.current.set(I, E), Ee(
|
|
516
985
|
t.watchResponse(
|
|
517
986
|
e,
|
|
518
|
-
{ chatId:
|
|
519
|
-
{ signal:
|
|
987
|
+
{ chatId: d, responseId: I, historyCursor: R },
|
|
988
|
+
{ signal: E.signal }
|
|
520
989
|
),
|
|
521
|
-
|
|
522
|
-
|
|
990
|
+
E,
|
|
991
|
+
d
|
|
523
992
|
));
|
|
524
|
-
} catch (
|
|
525
|
-
|
|
993
|
+
} catch (q) {
|
|
994
|
+
P(w) && !E.signal.aborted && G(q);
|
|
526
995
|
} finally {
|
|
527
|
-
|
|
996
|
+
V.current.get(I) !== E && ee(E);
|
|
528
997
|
}
|
|
529
998
|
}
|
|
530
|
-
},
|
|
531
|
-
const
|
|
532
|
-
ce(),
|
|
999
|
+
}, ze = async (o) => {
|
|
1000
|
+
const d = ++F.current, g = Y.current, w = ae();
|
|
1001
|
+
ce(), Z(void 0), N(!0), ve([]), me.current = void 0, te(o), v({ messages: [], status: "idle", threadId: o.chatId }), _(void 0), r(!1), M(!1);
|
|
533
1002
|
try {
|
|
534
|
-
const [
|
|
1003
|
+
const [T, z] = await Promise.all([
|
|
535
1004
|
t.getConversation(
|
|
536
1005
|
e,
|
|
537
|
-
{ chatId:
|
|
538
|
-
{ signal:
|
|
1006
|
+
{ chatId: o.chatId },
|
|
1007
|
+
{ signal: w.signal }
|
|
539
1008
|
),
|
|
540
1009
|
t.loadConversation(e, {
|
|
541
|
-
threadId:
|
|
1010
|
+
threadId: o.chatId,
|
|
542
1011
|
cursor: void 0,
|
|
543
|
-
signal:
|
|
1012
|
+
signal: w.signal
|
|
544
1013
|
})
|
|
545
1014
|
]);
|
|
546
|
-
if (
|
|
1015
|
+
if (!P(g) || w.signal.aborted || d !== F.current)
|
|
547
1016
|
return;
|
|
548
|
-
if (
|
|
1017
|
+
if (T.chatId !== o.chatId || z.threadId !== o.chatId)
|
|
549
1018
|
throw new Error("Conversation mismatch");
|
|
550
|
-
|
|
551
|
-
} catch (
|
|
552
|
-
|
|
1019
|
+
te(T), v(fe(z)), _(z.nextCursor ?? -1), r(z.hasMore ?? !1), Ae(z.messages, o.chatId, d, g);
|
|
1020
|
+
} catch (T) {
|
|
1021
|
+
P(g) && !w.signal.aborted && d === F.current && G(T);
|
|
553
1022
|
} finally {
|
|
554
|
-
|
|
1023
|
+
ee(w), P(g) && d === F.current && N(!1);
|
|
555
1024
|
}
|
|
556
1025
|
}, xe = async () => {
|
|
557
|
-
if (
|
|
558
|
-
if (
|
|
559
|
-
const
|
|
560
|
-
return
|
|
1026
|
+
if (k.current) return k.current;
|
|
1027
|
+
if (ge.current ??= { requestId: Oe() }, ge.current.promise) return ge.current.promise;
|
|
1028
|
+
const o = Y.current, d = F.current, g = ae(), w = ge.current;
|
|
1029
|
+
return Q(!0), w.promise = t.createConversation(
|
|
561
1030
|
e,
|
|
562
|
-
{ requestId:
|
|
1031
|
+
{ requestId: w.requestId },
|
|
563
1032
|
{ signal: g.signal }
|
|
564
|
-
).then((
|
|
565
|
-
if (
|
|
1033
|
+
).then((T) => {
|
|
1034
|
+
if (!P(o) || g.signal.aborted || d !== F.current)
|
|
566
1035
|
throw Object.assign(new Error("Stale create"), {
|
|
567
1036
|
name: "AbortError"
|
|
568
1037
|
});
|
|
569
|
-
return
|
|
1038
|
+
return ge.current = void 0, te(T), v({ messages: [], status: "idle", threadId: T.chatId }), le(), T;
|
|
570
1039
|
}).finally(() => {
|
|
571
|
-
|
|
572
|
-
}),
|
|
573
|
-
},
|
|
574
|
-
if (!(
|
|
575
|
-
|
|
1040
|
+
ee(g), w.promise = void 0, P(o) && Q(!1);
|
|
1041
|
+
}), w.promise;
|
|
1042
|
+
}, We = async () => {
|
|
1043
|
+
if (!(X || ge.current?.promise)) {
|
|
1044
|
+
F.current += 1, ce(), te(void 0), Z(void 0), me.current = void 0, v(fe()), r(!1), _(void 0);
|
|
576
1045
|
try {
|
|
577
1046
|
await xe();
|
|
578
|
-
} catch (
|
|
579
|
-
|
|
1047
|
+
} catch (o) {
|
|
1048
|
+
G(o);
|
|
580
1049
|
}
|
|
581
1050
|
}
|
|
582
|
-
},
|
|
583
|
-
const
|
|
584
|
-
me.current =
|
|
585
|
-
t.run(
|
|
586
|
-
|
|
587
|
-
|
|
1051
|
+
}, Xe = async (o) => {
|
|
1052
|
+
const d = ae();
|
|
1053
|
+
me.current = o, Z(void 0), y.current.messages.some((g) => g.id === o.message.id) || v((g) => ta(g, o.message)), await Ee(
|
|
1054
|
+
t.run(o, { signal: d.signal }),
|
|
1055
|
+
d,
|
|
1056
|
+
o.threadId
|
|
588
1057
|
);
|
|
589
|
-
},
|
|
590
|
-
if (!(!
|
|
1058
|
+
}, ye = async (o, d) => {
|
|
1059
|
+
if (!(!o.trim() && !d?.length))
|
|
591
1060
|
try {
|
|
592
|
-
const g = await xe(),
|
|
593
|
-
id:
|
|
594
|
-
content:
|
|
595
|
-
...
|
|
1061
|
+
const g = await xe(), w = {
|
|
1062
|
+
id: Oe(),
|
|
1063
|
+
content: o,
|
|
1064
|
+
...d ? { parts: d } : {}
|
|
596
1065
|
};
|
|
597
|
-
await
|
|
1066
|
+
await Xe({
|
|
598
1067
|
threadId: g.chatId,
|
|
599
|
-
message:
|
|
1068
|
+
message: w,
|
|
600
1069
|
context: e,
|
|
601
1070
|
capabilities: {
|
|
602
1071
|
artifactSchemaVersions: [],
|
|
@@ -605,343 +1074,340 @@ function Fa(e, t) {
|
|
|
605
1074
|
}
|
|
606
1075
|
});
|
|
607
1076
|
} catch (g) {
|
|
608
|
-
|
|
1077
|
+
G(g);
|
|
609
1078
|
}
|
|
610
|
-
},
|
|
611
|
-
const
|
|
612
|
-
if (!
|
|
613
|
-
|
|
1079
|
+
}, st = async () => {
|
|
1080
|
+
const o = me.current;
|
|
1081
|
+
if (!o || o.threadId !== k.current?.chatId) {
|
|
1082
|
+
k.current && await ze(k.current);
|
|
614
1083
|
return;
|
|
615
1084
|
}
|
|
616
|
-
const
|
|
617
|
-
(g) => g.id ===
|
|
1085
|
+
const d = y.current.messages.find(
|
|
1086
|
+
(g) => g.id === o.message.id
|
|
618
1087
|
);
|
|
619
|
-
if (
|
|
620
|
-
const g =
|
|
621
|
-
if (
|
|
622
|
-
const
|
|
623
|
-
|
|
1088
|
+
if (d?.responseId && t.watchResponse) {
|
|
1089
|
+
const g = d.responseId;
|
|
1090
|
+
if (V.current.has(g)) return;
|
|
1091
|
+
const w = ae();
|
|
1092
|
+
V.current.set(g, w), Z(void 0), await Ee(
|
|
624
1093
|
t.watchResponse(
|
|
625
1094
|
e,
|
|
626
1095
|
{
|
|
627
|
-
chatId:
|
|
1096
|
+
chatId: o.threadId,
|
|
628
1097
|
responseId: g,
|
|
629
|
-
historyCursor:
|
|
1098
|
+
historyCursor: d.cursor
|
|
630
1099
|
},
|
|
631
|
-
{ signal:
|
|
1100
|
+
{ signal: w.signal }
|
|
632
1101
|
),
|
|
633
|
-
|
|
634
|
-
|
|
1102
|
+
w,
|
|
1103
|
+
o.threadId
|
|
635
1104
|
);
|
|
636
|
-
} else await
|
|
637
|
-
},
|
|
638
|
-
const
|
|
639
|
-
if (!
|
|
1105
|
+
} else await Xe(o);
|
|
1106
|
+
}, nt = async (o = y.current.activeRunId) => {
|
|
1107
|
+
const d = k.current;
|
|
1108
|
+
if (!d || !o || !t.cancelResponse || ue.includes(o))
|
|
640
1109
|
return;
|
|
641
|
-
const g =
|
|
642
|
-
ve((
|
|
1110
|
+
const g = Y.current, w = F.current, T = ae();
|
|
1111
|
+
ve((z) => [...z, o]), Z(void 0);
|
|
643
1112
|
try {
|
|
644
|
-
const
|
|
1113
|
+
const z = await t.cancelResponse(
|
|
645
1114
|
e,
|
|
646
|
-
{ chatId:
|
|
647
|
-
{ signal:
|
|
1115
|
+
{ chatId: d.chatId, responseId: o },
|
|
1116
|
+
{ signal: T.signal }
|
|
648
1117
|
);
|
|
649
|
-
if (
|
|
650
|
-
if (gt(
|
|
1118
|
+
if (!P(g) || w !== F.current) return;
|
|
1119
|
+
if (gt(z))
|
|
651
1120
|
v(
|
|
652
|
-
(
|
|
1121
|
+
(I) => we(I, {
|
|
653
1122
|
type: "response.snapshot",
|
|
654
|
-
snapshot:
|
|
1123
|
+
snapshot: z
|
|
655
1124
|
})
|
|
656
|
-
), ve((
|
|
657
|
-
else if (!
|
|
658
|
-
const
|
|
659
|
-
|
|
1125
|
+
), ve((I) => I.filter((R) => R !== o));
|
|
1126
|
+
else if (!V.current.has(o) && t.watchResponse) {
|
|
1127
|
+
const I = ae();
|
|
1128
|
+
V.current.set(o, I), Ee(
|
|
660
1129
|
t.watchResponse(
|
|
661
1130
|
e,
|
|
662
|
-
{ chatId:
|
|
663
|
-
{ signal:
|
|
1131
|
+
{ chatId: d.chatId, responseId: o },
|
|
1132
|
+
{ signal: I.signal }
|
|
664
1133
|
),
|
|
665
|
-
|
|
666
|
-
|
|
1134
|
+
I,
|
|
1135
|
+
d.chatId
|
|
667
1136
|
);
|
|
668
1137
|
}
|
|
669
|
-
} catch (
|
|
670
|
-
|
|
1138
|
+
} catch (z) {
|
|
1139
|
+
P(g) && w === F.current && (G(z), ve((I) => I.filter((R) => R !== o)));
|
|
671
1140
|
} finally {
|
|
672
|
-
|
|
1141
|
+
ee(T);
|
|
673
1142
|
}
|
|
674
|
-
},
|
|
675
|
-
if (!
|
|
676
|
-
const g =
|
|
677
|
-
|
|
1143
|
+
}, it = async (o, d = k.current) => {
|
|
1144
|
+
if (!d || X) return !1;
|
|
1145
|
+
const g = Y.current, w = ae();
|
|
1146
|
+
Q(!0), Z(void 0);
|
|
678
1147
|
try {
|
|
679
|
-
const
|
|
1148
|
+
const T = await t.updateConversation(
|
|
680
1149
|
e,
|
|
681
|
-
{ chatId:
|
|
682
|
-
{ signal:
|
|
1150
|
+
{ chatId: d.chatId, expectedRevision: d.revision, ...o },
|
|
1151
|
+
{ signal: w.signal }
|
|
683
1152
|
);
|
|
684
|
-
return
|
|
685
|
-
} catch (
|
|
686
|
-
if (
|
|
687
|
-
|
|
1153
|
+
return P(g) ? (at(), Ve(T), k.current?.chatId === T.chatId && te(T), !0) : !1;
|
|
1154
|
+
} catch (T) {
|
|
1155
|
+
if (P(g)) {
|
|
1156
|
+
G(T);
|
|
688
1157
|
try {
|
|
689
|
-
const
|
|
1158
|
+
const z = await t.getConversation(
|
|
690
1159
|
e,
|
|
691
|
-
{ chatId:
|
|
692
|
-
{ signal:
|
|
1160
|
+
{ chatId: d.chatId },
|
|
1161
|
+
{ signal: w.signal }
|
|
693
1162
|
);
|
|
694
|
-
|
|
1163
|
+
P(g) && k.current?.chatId === d.chatId && te(z);
|
|
695
1164
|
} catch {
|
|
696
1165
|
}
|
|
697
1166
|
le();
|
|
698
1167
|
}
|
|
699
1168
|
return !1;
|
|
700
1169
|
} finally {
|
|
701
|
-
|
|
1170
|
+
ee(w), P(g) && Q(!1);
|
|
702
1171
|
}
|
|
703
|
-
},
|
|
704
|
-
if (!
|
|
705
|
-
const
|
|
706
|
-
|
|
1172
|
+
}, rt = async (o = k.current) => {
|
|
1173
|
+
if (!o || X) return !1;
|
|
1174
|
+
const d = Y.current, g = ae();
|
|
1175
|
+
Q(!0), Z(void 0);
|
|
707
1176
|
try {
|
|
708
1177
|
return await t.deleteConversation(
|
|
709
1178
|
e,
|
|
710
|
-
{ chatId:
|
|
1179
|
+
{ chatId: o.chatId, expectedRevision: o.revision },
|
|
711
1180
|
{ signal: g.signal }
|
|
712
|
-
),
|
|
713
|
-
} catch (
|
|
714
|
-
return
|
|
1181
|
+
), P(d) ? (at(), Ke(o.chatId), k.current?.chatId === o.chatId && (F.current += 1, ce(), te(void 0), v(fe())), !0) : !1;
|
|
1182
|
+
} catch (w) {
|
|
1183
|
+
return P(d) && G(w), !1;
|
|
715
1184
|
} finally {
|
|
716
|
-
|
|
1185
|
+
ee(g), P(d) && Q(!1);
|
|
717
1186
|
}
|
|
718
|
-
},
|
|
719
|
-
const
|
|
720
|
-
if (!
|
|
1187
|
+
}, ot = async (o, d, g = "", w = "") => {
|
|
1188
|
+
const T = k.current;
|
|
1189
|
+
if (!T || !o.persistent || !t.setFeedback || Me.includes(o.id))
|
|
721
1190
|
return;
|
|
722
|
-
const
|
|
723
|
-
chatId:
|
|
724
|
-
messageId:
|
|
725
|
-
rating:
|
|
1191
|
+
const z = {
|
|
1192
|
+
chatId: T.chatId,
|
|
1193
|
+
messageId: o.id,
|
|
1194
|
+
rating: d,
|
|
726
1195
|
...g ? { reason: g } : {},
|
|
727
|
-
...
|
|
728
|
-
},
|
|
1196
|
+
...w ? { comment: w } : {}
|
|
1197
|
+
}, I = Te.current.get(o.id), { requestId: R, ...E } = I ?? {
|
|
729
1198
|
requestId: ""
|
|
730
|
-
},
|
|
731
|
-
Te.current.set(
|
|
732
|
-
const
|
|
733
|
-
|
|
1199
|
+
}, q = I && JSON.stringify(E) === JSON.stringify(z) ? I : { ...z, requestId: Oe() };
|
|
1200
|
+
Te.current.set(o.id, q);
|
|
1201
|
+
const be = Y.current, Se = F.current, ct = ae();
|
|
1202
|
+
Be((he) => [...he, o.id]), Z(void 0);
|
|
734
1203
|
try {
|
|
735
|
-
const he = await t.setFeedback(e,
|
|
736
|
-
signal:
|
|
1204
|
+
const he = await t.setFeedback(e, q, {
|
|
1205
|
+
signal: ct.signal
|
|
737
1206
|
});
|
|
738
|
-
return
|
|
1207
|
+
return !P(be) || Se !== F.current || Te.current.get(o.id) !== q ? void 0 : (v((Pe) => ({
|
|
739
1208
|
...Pe,
|
|
740
1209
|
messages: Pe.messages.map(
|
|
741
|
-
(
|
|
1210
|
+
(f) => f.id === o.id && he.revision >= (f.feedback?.revision ?? 0) ? { ...f, feedback: he } : f
|
|
742
1211
|
)
|
|
743
|
-
})), Te.current.delete(
|
|
1212
|
+
})), Te.current.delete(o.id), !0);
|
|
744
1213
|
} catch (he) {
|
|
745
|
-
return
|
|
1214
|
+
return P(be) && Se === F.current && G(he), !1;
|
|
746
1215
|
} finally {
|
|
747
|
-
|
|
1216
|
+
ee(ct), P(be) && Be((he) => he.filter((Pe) => Pe !== o.id));
|
|
748
1217
|
}
|
|
749
1218
|
}, De = async () => {
|
|
750
|
-
if (!
|
|
751
|
-
const
|
|
752
|
-
|
|
1219
|
+
if (!k.current || !h || W) return;
|
|
1220
|
+
const o = Y.current, d = F.current, g = k.current, w = ae();
|
|
1221
|
+
N(!0);
|
|
753
1222
|
try {
|
|
754
|
-
const
|
|
1223
|
+
const T = await t.loadConversation(e, {
|
|
755
1224
|
threadId: g.chatId,
|
|
756
|
-
cursor:
|
|
757
|
-
signal:
|
|
1225
|
+
cursor: H,
|
|
1226
|
+
signal: w.signal
|
|
758
1227
|
});
|
|
759
|
-
if (
|
|
760
|
-
const
|
|
1228
|
+
if (!P(o) || d !== F.current) return;
|
|
1229
|
+
const z = fe(T), I = [
|
|
761
1230
|
...new Map(
|
|
762
|
-
[...
|
|
763
|
-
|
|
764
|
-
|
|
1231
|
+
[...y.current.messages, ...z.messages].map((q) => [
|
|
1232
|
+
q.id,
|
|
1233
|
+
q
|
|
765
1234
|
])
|
|
766
1235
|
).values()
|
|
767
1236
|
];
|
|
768
|
-
let
|
|
769
|
-
const
|
|
770
|
-
for (const
|
|
771
|
-
if (
|
|
772
|
-
|
|
1237
|
+
let R = 0;
|
|
1238
|
+
const E = [];
|
|
1239
|
+
for (const q of I.slice(-200).reverse()) {
|
|
1240
|
+
if (R += [...q.content].length, R > 1e6) break;
|
|
1241
|
+
E.unshift(q);
|
|
773
1242
|
}
|
|
774
|
-
|
|
775
|
-
} catch (
|
|
776
|
-
|
|
1243
|
+
E.length < I.length && M(!0), v((q) => ({ ...q, messages: E })), _(T.nextCursor ?? H), r(T.hasMore ?? !1), Ae(T.messages, g.chatId, d, o);
|
|
1244
|
+
} catch (T) {
|
|
1245
|
+
P(o) && G(T);
|
|
777
1246
|
} finally {
|
|
778
|
-
|
|
1247
|
+
ee(w), P(o) && N(!1);
|
|
779
1248
|
}
|
|
780
|
-
},
|
|
1249
|
+
}, Ge = [
|
|
781
1250
|
.../* @__PURE__ */ new Set([
|
|
782
|
-
...
|
|
783
|
-
...
|
|
1251
|
+
...p.filter((o) => o.titlePending).map((o) => o.chatId),
|
|
1252
|
+
...C?.titlePending ? [C.chatId] : []
|
|
784
1253
|
])
|
|
785
1254
|
].sort().join("\0");
|
|
786
|
-
|
|
787
|
-
if (!s || !t.getConversation || !
|
|
788
|
-
const
|
|
789
|
-
let
|
|
1255
|
+
ne(() => {
|
|
1256
|
+
if (!s || !t.getConversation || !Ge) return;
|
|
1257
|
+
const o = Y.current, d = ae(), g = Ge.split("\0"), w = /* @__PURE__ */ new Set();
|
|
1258
|
+
let T;
|
|
790
1259
|
console.debug("[make-ai-assistant] watching pending conversation titles", {
|
|
791
1260
|
count: g.length
|
|
792
1261
|
});
|
|
793
|
-
const
|
|
1262
|
+
const z = async () => {
|
|
794
1263
|
await Promise.all(
|
|
795
|
-
g.map(async (
|
|
796
|
-
if (!
|
|
1264
|
+
g.map(async (I) => {
|
|
1265
|
+
if (!w.has(I))
|
|
797
1266
|
try {
|
|
798
|
-
const
|
|
1267
|
+
const R = await t.getConversation(
|
|
799
1268
|
e,
|
|
800
|
-
{ chatId:
|
|
801
|
-
{ signal:
|
|
1269
|
+
{ chatId: I },
|
|
1270
|
+
{ signal: d.signal }
|
|
802
1271
|
);
|
|
803
|
-
if (
|
|
1272
|
+
if (!P(o) || d.signal.aborted || R.chatId !== I)
|
|
804
1273
|
return;
|
|
805
|
-
|
|
806
|
-
} catch (
|
|
807
|
-
if (
|
|
1274
|
+
Ve(R), k.current?.chatId === I && te(R);
|
|
1275
|
+
} catch (R) {
|
|
1276
|
+
if (!P(o) || d.signal.aborted) return;
|
|
808
1277
|
console.warn("[make-ai-assistant] title metadata refresh failed", {
|
|
809
|
-
errorType:
|
|
1278
|
+
errorType: R instanceof Error ? R.name : typeof R
|
|
810
1279
|
});
|
|
811
|
-
const
|
|
812
|
-
|
|
1280
|
+
const E = R?.status;
|
|
1281
|
+
E === 401 ? (d.abort(), G(R)) : (E === 403 || E === 404) && (w.add(I), k.current?.chatId === I && G(R));
|
|
813
1282
|
}
|
|
814
1283
|
})
|
|
815
|
-
),
|
|
816
|
-
|
|
817
|
-
},
|
|
1284
|
+
), P(o) && !d.signal.aborted && g.some((I) => !w.has(I)) && (T = setTimeout(() => {
|
|
1285
|
+
z();
|
|
1286
|
+
}, Bt));
|
|
818
1287
|
};
|
|
819
|
-
return
|
|
820
|
-
|
|
821
|
-
},
|
|
822
|
-
clearTimeout(
|
|
1288
|
+
return T = setTimeout(() => {
|
|
1289
|
+
z();
|
|
1290
|
+
}, Bt), () => {
|
|
1291
|
+
clearTimeout(T), d.abort(), ee(d);
|
|
823
1292
|
};
|
|
824
|
-
}, [s,
|
|
825
|
-
|
|
826
|
-
for (const
|
|
827
|
-
|
|
828
|
-
}), [s,
|
|
829
|
-
const
|
|
1293
|
+
}, [s, n, t, Ge]), ne(() => (Y.current += 1, c.current = n, ge.current = void 0, me.current = void 0, Te.current.clear(), te(void 0), A([]), L(""), v(fe()), Z(void 0), N(s), Q(!1), ve([]), Be([]), s && le(), () => {
|
|
1294
|
+
Y.current += 1, F.current += 1;
|
|
1295
|
+
for (const o of O.current) o.abort();
|
|
1296
|
+
O.current.clear(), V.current.clear();
|
|
1297
|
+
}), [s, n, t]);
|
|
1298
|
+
const $e = c.current === n;
|
|
830
1299
|
return {
|
|
831
1300
|
enabled: s,
|
|
832
1301
|
canEdit: t.features?.conversationEditing !== !1,
|
|
833
|
-
state:
|
|
1302
|
+
state: $e ? l : fe(),
|
|
834
1303
|
setState: v,
|
|
835
|
-
chats:
|
|
836
|
-
chat:
|
|
837
|
-
listCursor:
|
|
838
|
-
historyMore:
|
|
1304
|
+
chats: $e ? p : [],
|
|
1305
|
+
chat: $e ? C : void 0,
|
|
1306
|
+
listCursor: U,
|
|
1307
|
+
historyMore: h,
|
|
839
1308
|
historyTruncated: b,
|
|
840
|
-
loading:
|
|
841
|
-
busy:
|
|
842
|
-
error:
|
|
1309
|
+
loading: !$e || W,
|
|
1310
|
+
busy: X,
|
|
1311
|
+
error: $e ? ie : void 0,
|
|
843
1312
|
cancelling: ue,
|
|
844
|
-
feedbackBusy:
|
|
1313
|
+
feedbackBusy: Me,
|
|
845
1314
|
refresh: le,
|
|
846
|
-
select:
|
|
847
|
-
create:
|
|
1315
|
+
select: ze,
|
|
1316
|
+
create: We,
|
|
848
1317
|
ensureChat: xe,
|
|
849
|
-
send:
|
|
850
|
-
retry:
|
|
851
|
-
stop:
|
|
852
|
-
update:
|
|
853
|
-
remove:
|
|
854
|
-
feedback:
|
|
1318
|
+
send: ye,
|
|
1319
|
+
retry: st,
|
|
1320
|
+
stop: nt,
|
|
1321
|
+
update: it,
|
|
1322
|
+
remove: rt,
|
|
1323
|
+
feedback: ot,
|
|
855
1324
|
moreHistory: De,
|
|
856
|
-
setError:
|
|
1325
|
+
setError: Z
|
|
857
1326
|
};
|
|
858
1327
|
}
|
|
859
|
-
const
|
|
860
|
-
/* @__PURE__ */ a("path", { d: "M5 5.5h14v10H9l-4 3v-13Z" }),
|
|
861
|
-
/* @__PURE__ */ a("path", { d: "M8 9h8M8 12h6" })
|
|
862
|
-
] }), Ba = ({
|
|
1328
|
+
const Ds = ({
|
|
863
1329
|
anchor: e,
|
|
864
1330
|
label: t,
|
|
865
1331
|
onDismiss: s
|
|
866
1332
|
}) => {
|
|
867
|
-
const [
|
|
868
|
-
if (
|
|
869
|
-
const
|
|
1333
|
+
const [n, i] = $();
|
|
1334
|
+
if (At(() => {
|
|
1335
|
+
const l = () => {
|
|
870
1336
|
if (!e.isConnected) {
|
|
871
1337
|
s();
|
|
872
1338
|
return;
|
|
873
1339
|
}
|
|
874
|
-
const
|
|
1340
|
+
const m = e.getBoundingClientRect(), y = m.top >= 48 ? "above" : "below";
|
|
875
1341
|
i({
|
|
876
|
-
left:
|
|
877
|
-
placement:
|
|
878
|
-
top:
|
|
1342
|
+
left: m.left + m.width / 2,
|
|
1343
|
+
placement: y,
|
|
1344
|
+
top: y === "above" ? m.top - 8 : m.bottom + 8
|
|
879
1345
|
});
|
|
880
1346
|
};
|
|
881
|
-
return
|
|
882
|
-
window.removeEventListener("resize",
|
|
1347
|
+
return l(), window.addEventListener("resize", l), document.addEventListener("scroll", l, !0), () => {
|
|
1348
|
+
window.removeEventListener("resize", l), document.removeEventListener("scroll", l, !0);
|
|
883
1349
|
};
|
|
884
|
-
}, [e, s]), !
|
|
1350
|
+
}, [e, s]), !n || typeof document > "u") return null;
|
|
885
1351
|
const c = e.closest(".make-ai-assistant") ?? document.body;
|
|
886
|
-
return
|
|
1352
|
+
return aa(
|
|
887
1353
|
/* @__PURE__ */ a(
|
|
888
1354
|
"span",
|
|
889
1355
|
{
|
|
890
1356
|
className: "make-ai-assistant__conversation-tooltip",
|
|
891
|
-
"data-placement":
|
|
1357
|
+
"data-placement": n.placement,
|
|
892
1358
|
role: "tooltip",
|
|
893
|
-
style: { left:
|
|
1359
|
+
style: { left: n.left, top: n.top },
|
|
894
1360
|
children: t
|
|
895
1361
|
}
|
|
896
1362
|
),
|
|
897
1363
|
c
|
|
898
1364
|
);
|
|
899
1365
|
};
|
|
900
|
-
function
|
|
1366
|
+
function Ps({
|
|
901
1367
|
id: e,
|
|
902
1368
|
manager: t,
|
|
903
1369
|
onDismiss: s,
|
|
904
|
-
onNewConversation:
|
|
1370
|
+
onNewConversation: n,
|
|
905
1371
|
triggerRef: i
|
|
906
1372
|
}) {
|
|
907
|
-
const [c,
|
|
908
|
-
|
|
909
|
-
(
|
|
1373
|
+
const [c, l] = $(), [m, y] = $(""), [v, p] = $(), [A, C] = $(), S = D(null), k = (r, b) => {
|
|
1374
|
+
C(
|
|
1375
|
+
(M) => M?.anchor === b && M.label === r ? M : { anchor: b, label: r }
|
|
910
1376
|
);
|
|
911
|
-
},
|
|
912
|
-
|
|
913
|
-
},
|
|
914
|
-
"data-tooltip":
|
|
915
|
-
onBlur: (b) =>
|
|
916
|
-
onFocus: (b) =>
|
|
917
|
-
onPointerEnter: (b) =>
|
|
918
|
-
onPointerLeave: (b) =>
|
|
919
|
-
}),
|
|
920
|
-
|
|
921
|
-
},
|
|
922
|
-
const b =
|
|
923
|
-
b && await t.update({ title: b },
|
|
924
|
-
},
|
|
925
|
-
await t.remove(
|
|
1377
|
+
}, U = (r) => {
|
|
1378
|
+
C((b) => b?.anchor === r ? void 0 : b);
|
|
1379
|
+
}, L = (r) => ({
|
|
1380
|
+
"data-tooltip": r,
|
|
1381
|
+
onBlur: (b) => U(b.currentTarget),
|
|
1382
|
+
onFocus: (b) => k(r, b.currentTarget),
|
|
1383
|
+
onPointerEnter: (b) => k(r, b.currentTarget),
|
|
1384
|
+
onPointerLeave: (b) => U(b.currentTarget)
|
|
1385
|
+
}), H = () => {
|
|
1386
|
+
l(void 0), y("");
|
|
1387
|
+
}, _ = async (r) => {
|
|
1388
|
+
const b = m.trim();
|
|
1389
|
+
b && await t.update({ title: b }, r) && H();
|
|
1390
|
+
}, h = async (r) => {
|
|
1391
|
+
await t.remove(r) && p(void 0);
|
|
926
1392
|
};
|
|
927
|
-
return
|
|
928
|
-
const
|
|
929
|
-
const
|
|
930
|
-
|
|
1393
|
+
return ne(() => {
|
|
1394
|
+
const r = (b) => {
|
|
1395
|
+
const M = b.target;
|
|
1396
|
+
M instanceof Node && (S.current?.contains(M) || i.current?.contains(M) || s());
|
|
931
1397
|
};
|
|
932
|
-
return document.addEventListener("pointerdown",
|
|
933
|
-
document.removeEventListener("pointerdown",
|
|
1398
|
+
return document.addEventListener("pointerdown", r), () => {
|
|
1399
|
+
document.removeEventListener("pointerdown", r);
|
|
934
1400
|
};
|
|
935
|
-
}, [s, i]), /* @__PURE__ */
|
|
1401
|
+
}, [s, i]), /* @__PURE__ */ u(
|
|
936
1402
|
"div",
|
|
937
1403
|
{
|
|
938
1404
|
"aria-label": "任务列表",
|
|
939
1405
|
className: "make-ai-assistant__conversation-controls",
|
|
940
1406
|
id: e,
|
|
941
|
-
ref:
|
|
1407
|
+
ref: S,
|
|
942
1408
|
role: "dialog",
|
|
943
1409
|
children: [
|
|
944
|
-
/* @__PURE__ */
|
|
1410
|
+
/* @__PURE__ */ u("div", { className: "make-ai-assistant__conversation-heading", children: [
|
|
945
1411
|
/* @__PURE__ */ a("span", { children: "最近对话" }),
|
|
946
1412
|
/* @__PURE__ */ a(
|
|
947
1413
|
"button",
|
|
@@ -950,12 +1416,12 @@ function Oa({
|
|
|
950
1416
|
className: "make-ai-assistant__conversation-refresh",
|
|
951
1417
|
disabled: t.busy,
|
|
952
1418
|
type: "button",
|
|
953
|
-
...
|
|
1419
|
+
...L("刷新"),
|
|
954
1420
|
onClick: () => {
|
|
955
1421
|
t.refresh();
|
|
956
1422
|
},
|
|
957
1423
|
children: /* @__PURE__ */ a(
|
|
958
|
-
|
|
1424
|
+
vt,
|
|
959
1425
|
{
|
|
960
1426
|
"aria-hidden": "true",
|
|
961
1427
|
className: "make-ai-assistant__conversation-refresh-icon"
|
|
@@ -964,22 +1430,22 @@ function Oa({
|
|
|
964
1430
|
}
|
|
965
1431
|
)
|
|
966
1432
|
] }),
|
|
967
|
-
/* @__PURE__ */
|
|
1433
|
+
/* @__PURE__ */ u(
|
|
968
1434
|
"nav",
|
|
969
1435
|
{
|
|
970
1436
|
"aria-label": "对话列表",
|
|
971
1437
|
className: "make-ai-assistant__conversation-list",
|
|
972
1438
|
children: [
|
|
973
|
-
t.chats.map((
|
|
974
|
-
const b = c ===
|
|
975
|
-
return /* @__PURE__ */
|
|
1439
|
+
t.chats.map((r) => {
|
|
1440
|
+
const b = c === r.chatId, M = v === r.chatId, W = r.title || "未命名对话";
|
|
1441
|
+
return /* @__PURE__ */ u(
|
|
976
1442
|
"div",
|
|
977
1443
|
{
|
|
978
1444
|
className: "make-ai-assistant__conversation-row",
|
|
979
|
-
"data-active": t.chat?.chatId ===
|
|
980
|
-
"data-editing": b ||
|
|
1445
|
+
"data-active": t.chat?.chatId === r.chatId || void 0,
|
|
1446
|
+
"data-editing": b || M || void 0,
|
|
981
1447
|
children: [
|
|
982
|
-
|
|
1448
|
+
M ? /* @__PURE__ */ u(
|
|
983
1449
|
"div",
|
|
984
1450
|
{
|
|
985
1451
|
"aria-label": "确认删除对话",
|
|
@@ -987,30 +1453,30 @@ function Oa({
|
|
|
987
1453
|
role: "group",
|
|
988
1454
|
children: [
|
|
989
1455
|
/* @__PURE__ */ a(
|
|
990
|
-
|
|
1456
|
+
Ls,
|
|
991
1457
|
{
|
|
992
1458
|
"aria-hidden": "true",
|
|
993
1459
|
className: "make-ai-assistant__conversation-delete-confirmation-icon"
|
|
994
1460
|
}
|
|
995
1461
|
),
|
|
996
|
-
/* @__PURE__ */
|
|
1462
|
+
/* @__PURE__ */ u("span", { className: "make-ai-assistant__conversation-delete-confirmation-message", children: [
|
|
997
1463
|
"确认删除“",
|
|
998
|
-
|
|
1464
|
+
W,
|
|
999
1465
|
"”?"
|
|
1000
1466
|
] }),
|
|
1001
1467
|
/* @__PURE__ */ a(
|
|
1002
1468
|
"button",
|
|
1003
1469
|
{
|
|
1004
|
-
"aria-label": `确认删除:${
|
|
1470
|
+
"aria-label": `确认删除:${W}`,
|
|
1005
1471
|
className: "make-ai-assistant__conversation-row-action make-ai-assistant__conversation-row-action--danger make-ai-assistant__conversation-delete-confirmation-confirm",
|
|
1006
1472
|
disabled: t.busy || !t.canEdit,
|
|
1007
1473
|
type: "button",
|
|
1008
|
-
...
|
|
1474
|
+
...L("确认删除"),
|
|
1009
1475
|
onClick: () => {
|
|
1010
|
-
|
|
1476
|
+
h(r);
|
|
1011
1477
|
},
|
|
1012
1478
|
children: /* @__PURE__ */ a(
|
|
1013
|
-
|
|
1479
|
+
jt,
|
|
1014
1480
|
{
|
|
1015
1481
|
"aria-hidden": "true",
|
|
1016
1482
|
className: "make-ai-assistant__conversation-row-action-icon"
|
|
@@ -1021,14 +1487,14 @@ function Oa({
|
|
|
1021
1487
|
/* @__PURE__ */ a(
|
|
1022
1488
|
"button",
|
|
1023
1489
|
{
|
|
1024
|
-
"aria-label": `取消删除:${
|
|
1490
|
+
"aria-label": `取消删除:${W}`,
|
|
1025
1491
|
className: "make-ai-assistant__conversation-row-action make-ai-assistant__conversation-delete-confirmation-cancel",
|
|
1026
1492
|
disabled: t.busy,
|
|
1027
1493
|
type: "button",
|
|
1028
|
-
...
|
|
1029
|
-
onClick: () =>
|
|
1494
|
+
...L("取消"),
|
|
1495
|
+
onClick: () => p(void 0),
|
|
1030
1496
|
children: /* @__PURE__ */ a(
|
|
1031
|
-
|
|
1497
|
+
tt,
|
|
1032
1498
|
{
|
|
1033
1499
|
"aria-hidden": "true",
|
|
1034
1500
|
className: "make-ai-assistant__conversation-row-action-icon"
|
|
@@ -1046,28 +1512,28 @@ function Oa({
|
|
|
1046
1512
|
className: "make-ai-assistant__conversation-row-title-input",
|
|
1047
1513
|
disabled: t.busy,
|
|
1048
1514
|
maxLength: 255,
|
|
1049
|
-
value:
|
|
1050
|
-
onChange: (
|
|
1051
|
-
onKeyDown: (
|
|
1052
|
-
|
|
1515
|
+
value: m,
|
|
1516
|
+
onChange: (N) => y(N.currentTarget.value),
|
|
1517
|
+
onKeyDown: (N) => {
|
|
1518
|
+
N.nativeEvent.isComposing || (N.key === "Escape" && (N.preventDefault(), H()), N.key === "Enter" && (N.preventDefault(), _(r)));
|
|
1053
1519
|
}
|
|
1054
1520
|
}
|
|
1055
|
-
) : /* @__PURE__ */
|
|
1521
|
+
) : /* @__PURE__ */ u(
|
|
1056
1522
|
"button",
|
|
1057
1523
|
{
|
|
1058
|
-
"aria-pressed": t.chat?.chatId ===
|
|
1524
|
+
"aria-pressed": t.chat?.chatId === r.chatId,
|
|
1059
1525
|
className: "make-ai-assistant__conversation-row-select",
|
|
1060
1526
|
type: "button",
|
|
1061
1527
|
onClick: () => {
|
|
1062
|
-
s(), t.select(
|
|
1528
|
+
s(), t.select(r);
|
|
1063
1529
|
},
|
|
1064
1530
|
children: [
|
|
1065
|
-
/* @__PURE__ */ a(
|
|
1066
|
-
/* @__PURE__ */ a("span", { children:
|
|
1531
|
+
/* @__PURE__ */ a(As, { "aria-hidden": "true" }),
|
|
1532
|
+
/* @__PURE__ */ a("span", { children: W })
|
|
1067
1533
|
]
|
|
1068
1534
|
}
|
|
1069
1535
|
),
|
|
1070
|
-
b ? /* @__PURE__ */
|
|
1536
|
+
b ? /* @__PURE__ */ u(
|
|
1071
1537
|
"div",
|
|
1072
1538
|
{
|
|
1073
1539
|
"aria-label": "修改标题操作",
|
|
@@ -1079,14 +1545,14 @@ function Oa({
|
|
|
1079
1545
|
{
|
|
1080
1546
|
"aria-label": "确认修改标题",
|
|
1081
1547
|
className: "make-ai-assistant__conversation-row-action",
|
|
1082
|
-
disabled: t.busy || !
|
|
1548
|
+
disabled: t.busy || !m.trim(),
|
|
1083
1549
|
type: "button",
|
|
1084
|
-
...
|
|
1550
|
+
...L("保存标题"),
|
|
1085
1551
|
onClick: () => {
|
|
1086
|
-
|
|
1552
|
+
_(r);
|
|
1087
1553
|
},
|
|
1088
1554
|
children: /* @__PURE__ */ a(
|
|
1089
|
-
|
|
1555
|
+
ys,
|
|
1090
1556
|
{
|
|
1091
1557
|
"aria-hidden": "true",
|
|
1092
1558
|
className: "make-ai-assistant__conversation-row-action-icon"
|
|
@@ -1101,10 +1567,10 @@ function Oa({
|
|
|
1101
1567
|
className: "make-ai-assistant__conversation-row-action",
|
|
1102
1568
|
disabled: t.busy,
|
|
1103
1569
|
type: "button",
|
|
1104
|
-
...
|
|
1105
|
-
onClick:
|
|
1570
|
+
...L("取消"),
|
|
1571
|
+
onClick: H,
|
|
1106
1572
|
children: /* @__PURE__ */ a(
|
|
1107
|
-
|
|
1573
|
+
tt,
|
|
1108
1574
|
{
|
|
1109
1575
|
"aria-hidden": "true",
|
|
1110
1576
|
className: "make-ai-assistant__conversation-row-action-icon"
|
|
@@ -1114,21 +1580,21 @@ function Oa({
|
|
|
1114
1580
|
)
|
|
1115
1581
|
]
|
|
1116
1582
|
}
|
|
1117
|
-
) :
|
|
1583
|
+
) : M ? null : /* @__PURE__ */ u("div", { className: "make-ai-assistant__conversation-row-actions", children: [
|
|
1118
1584
|
/* @__PURE__ */ a(
|
|
1119
1585
|
"button",
|
|
1120
1586
|
{
|
|
1121
|
-
"aria-label": `${
|
|
1122
|
-
"aria-pressed":
|
|
1587
|
+
"aria-label": `${r.pinned ? "取消置顶" : "置顶"} ${W}`,
|
|
1588
|
+
"aria-pressed": r.pinned,
|
|
1123
1589
|
className: "make-ai-assistant__conversation-row-action make-ai-assistant__conversation-row-pin",
|
|
1124
1590
|
disabled: t.busy || !t.canEdit,
|
|
1125
1591
|
type: "button",
|
|
1126
|
-
...
|
|
1592
|
+
...L(r.pinned ? "取消置顶" : "置顶"),
|
|
1127
1593
|
onClick: () => {
|
|
1128
|
-
t.update({ pinned: !
|
|
1594
|
+
t.update({ pinned: !r.pinned }, r);
|
|
1129
1595
|
},
|
|
1130
1596
|
children: /* @__PURE__ */ a(
|
|
1131
|
-
|
|
1597
|
+
Es,
|
|
1132
1598
|
{
|
|
1133
1599
|
"aria-hidden": "true",
|
|
1134
1600
|
className: "make-ai-assistant__conversation-row-action-icon"
|
|
@@ -1139,16 +1605,16 @@ function Oa({
|
|
|
1139
1605
|
/* @__PURE__ */ a(
|
|
1140
1606
|
"button",
|
|
1141
1607
|
{
|
|
1142
|
-
"aria-label": `修改标题:${
|
|
1608
|
+
"aria-label": `修改标题:${W}`,
|
|
1143
1609
|
className: "make-ai-assistant__conversation-row-action",
|
|
1144
1610
|
disabled: t.busy || !t.canEdit,
|
|
1145
1611
|
type: "button",
|
|
1146
|
-
...
|
|
1612
|
+
...L("修改标题"),
|
|
1147
1613
|
onClick: () => {
|
|
1148
|
-
|
|
1614
|
+
p(void 0), l(r.chatId), y(r.title);
|
|
1149
1615
|
},
|
|
1150
1616
|
children: /* @__PURE__ */ a(
|
|
1151
|
-
|
|
1617
|
+
Ts,
|
|
1152
1618
|
{
|
|
1153
1619
|
"aria-hidden": "true",
|
|
1154
1620
|
className: "make-ai-assistant__conversation-row-action-icon"
|
|
@@ -1159,16 +1625,16 @@ function Oa({
|
|
|
1159
1625
|
/* @__PURE__ */ a(
|
|
1160
1626
|
"button",
|
|
1161
1627
|
{
|
|
1162
|
-
"aria-label": `删除:${
|
|
1628
|
+
"aria-label": `删除:${W}`,
|
|
1163
1629
|
className: "make-ai-assistant__conversation-row-action make-ai-assistant__conversation-row-action--danger",
|
|
1164
1630
|
disabled: t.busy,
|
|
1165
1631
|
type: "button",
|
|
1166
|
-
...
|
|
1632
|
+
...L("删除"),
|
|
1167
1633
|
onClick: () => {
|
|
1168
|
-
|
|
1634
|
+
H(), p(r.chatId);
|
|
1169
1635
|
},
|
|
1170
1636
|
children: /* @__PURE__ */ a(
|
|
1171
|
-
|
|
1637
|
+
jt,
|
|
1172
1638
|
{
|
|
1173
1639
|
"aria-hidden": "true",
|
|
1174
1640
|
className: "make-ai-assistant__conversation-row-action-icon"
|
|
@@ -1179,7 +1645,7 @@ function Oa({
|
|
|
1179
1645
|
] })
|
|
1180
1646
|
]
|
|
1181
1647
|
},
|
|
1182
|
-
|
|
1648
|
+
r.chatId
|
|
1183
1649
|
);
|
|
1184
1650
|
}),
|
|
1185
1651
|
!t.loading && !t.chats.length ? /* @__PURE__ */ a("p", { children: "暂无对话,发送消息即可新建" }) : null,
|
|
@@ -1197,7 +1663,7 @@ function Oa({
|
|
|
1197
1663
|
]
|
|
1198
1664
|
}
|
|
1199
1665
|
),
|
|
1200
|
-
t.chat && (t.historyMore || t.historyTruncated || t.state.historyTruncated) ? /* @__PURE__ */
|
|
1666
|
+
t.chat && (t.historyMore || t.historyTruncated || t.state.historyTruncated) ? /* @__PURE__ */ u("div", { className: "make-ai-assistant__conversation-history-actions", children: [
|
|
1201
1667
|
t.historyMore ? /* @__PURE__ */ a(
|
|
1202
1668
|
"button",
|
|
1203
1669
|
{
|
|
@@ -1211,21 +1677,21 @@ function Oa({
|
|
|
1211
1677
|
) : null,
|
|
1212
1678
|
t.historyTruncated || t.state.historyTruncated ? /* @__PURE__ */ a("p", { children: "当前展示有界消息窗口,可重新选择对话从头读取。" }) : null
|
|
1213
1679
|
] }) : null,
|
|
1214
|
-
t.error ? /* @__PURE__ */
|
|
1680
|
+
t.error ? /* @__PURE__ */ u("div", { className: "make-ai-assistant__conversation-error", role: "alert", children: [
|
|
1215
1681
|
/* @__PURE__ */ a("span", { children: t.error }),
|
|
1216
1682
|
/* @__PURE__ */ a("button", { type: "button", onClick: () => {
|
|
1217
1683
|
t.retry();
|
|
1218
1684
|
}, children: "恢复对话" })
|
|
1219
1685
|
] }) : null,
|
|
1220
|
-
|
|
1686
|
+
n ? /* @__PURE__ */ u(
|
|
1221
1687
|
"button",
|
|
1222
1688
|
{
|
|
1223
1689
|
className: "make-ai-assistant__conversation-new",
|
|
1224
1690
|
type: "button",
|
|
1225
|
-
onClick:
|
|
1691
|
+
onClick: n,
|
|
1226
1692
|
children: [
|
|
1227
1693
|
/* @__PURE__ */ a(
|
|
1228
|
-
|
|
1694
|
+
Tt,
|
|
1229
1695
|
{
|
|
1230
1696
|
"aria-hidden": "true",
|
|
1231
1697
|
className: "make-ai-assistant__conversation-new-icon"
|
|
@@ -1235,27 +1701,27 @@ function Oa({
|
|
|
1235
1701
|
]
|
|
1236
1702
|
}
|
|
1237
1703
|
) : null,
|
|
1238
|
-
|
|
1239
|
-
|
|
1704
|
+
A ? /* @__PURE__ */ a(
|
|
1705
|
+
Ds,
|
|
1240
1706
|
{
|
|
1241
|
-
anchor:
|
|
1242
|
-
label:
|
|
1243
|
-
onDismiss: () =>
|
|
1707
|
+
anchor: A.anchor,
|
|
1708
|
+
label: A.label,
|
|
1709
|
+
onDismiss: () => C(void 0)
|
|
1244
1710
|
}
|
|
1245
1711
|
) : null
|
|
1246
1712
|
]
|
|
1247
1713
|
}
|
|
1248
1714
|
);
|
|
1249
1715
|
}
|
|
1250
|
-
function
|
|
1716
|
+
function Us({
|
|
1251
1717
|
message: e,
|
|
1252
1718
|
manager: t
|
|
1253
1719
|
}) {
|
|
1254
|
-
const [s,
|
|
1720
|
+
const [s, n] = $(!1), [i, c] = $(""), [l, m] = $(""), y = t.feedbackBusy.includes(e.id);
|
|
1255
1721
|
if (!e.persistent || e.role !== "assistant" || e.intermediate)
|
|
1256
1722
|
return null;
|
|
1257
1723
|
const v = e.feedback?.rating ?? "none";
|
|
1258
|
-
return /* @__PURE__ */
|
|
1724
|
+
return /* @__PURE__ */ u(
|
|
1259
1725
|
"div",
|
|
1260
1726
|
{
|
|
1261
1727
|
"aria-label": "回答反馈",
|
|
@@ -1270,12 +1736,12 @@ function za({
|
|
|
1270
1736
|
"aria-pressed": v === "like",
|
|
1271
1737
|
className: "make-ai-assistant__reply-action make-ai-assistant__reply-feedback-action",
|
|
1272
1738
|
"data-tooltip": "喜欢",
|
|
1273
|
-
disabled:
|
|
1739
|
+
disabled: y,
|
|
1274
1740
|
onClick: () => {
|
|
1275
1741
|
t.feedback(e, v === "like" ? "none" : "like");
|
|
1276
1742
|
},
|
|
1277
1743
|
children: /* @__PURE__ */ a(
|
|
1278
|
-
|
|
1744
|
+
Rs,
|
|
1279
1745
|
{
|
|
1280
1746
|
"aria-hidden": "true",
|
|
1281
1747
|
className: "make-ai-assistant__reply-feedback-icon"
|
|
@@ -1291,16 +1757,16 @@ function za({
|
|
|
1291
1757
|
"aria-pressed": v === "dislike",
|
|
1292
1758
|
className: "make-ai-assistant__reply-action make-ai-assistant__reply-feedback-action",
|
|
1293
1759
|
"data-tooltip": "不喜欢",
|
|
1294
|
-
disabled:
|
|
1760
|
+
disabled: y,
|
|
1295
1761
|
onClick: () => {
|
|
1296
1762
|
if (v === "dislike") {
|
|
1297
1763
|
t.feedback(e, "none");
|
|
1298
1764
|
return;
|
|
1299
1765
|
}
|
|
1300
|
-
c(e.feedback?.reason ?? ""),
|
|
1766
|
+
c(e.feedback?.reason ?? ""), m(e.feedback?.comment ?? ""), n(!0);
|
|
1301
1767
|
},
|
|
1302
1768
|
children: /* @__PURE__ */ a(
|
|
1303
|
-
|
|
1769
|
+
Ss,
|
|
1304
1770
|
{
|
|
1305
1771
|
"aria-hidden": "true",
|
|
1306
1772
|
className: "make-ai-assistant__reply-feedback-icon"
|
|
@@ -1313,19 +1779,19 @@ function za({
|
|
|
1313
1779
|
{
|
|
1314
1780
|
className: "make-ai-assistant__feedback-text-action",
|
|
1315
1781
|
type: "button",
|
|
1316
|
-
disabled:
|
|
1782
|
+
disabled: y,
|
|
1317
1783
|
onClick: () => {
|
|
1318
|
-
c(e.feedback?.reason ?? ""),
|
|
1784
|
+
c(e.feedback?.reason ?? ""), m(e.feedback?.comment ?? ""), n(!0);
|
|
1319
1785
|
},
|
|
1320
1786
|
children: "修改反馈"
|
|
1321
1787
|
}
|
|
1322
1788
|
) : null,
|
|
1323
|
-
s ? /* @__PURE__ */
|
|
1789
|
+
s ? /* @__PURE__ */ u(
|
|
1324
1790
|
"form",
|
|
1325
1791
|
{
|
|
1326
|
-
onSubmit: (
|
|
1327
|
-
|
|
1328
|
-
|
|
1792
|
+
onSubmit: (p) => {
|
|
1793
|
+
p.preventDefault(), t.feedback(e, "dislike", i, l).then((A) => {
|
|
1794
|
+
A && n(!1);
|
|
1329
1795
|
});
|
|
1330
1796
|
},
|
|
1331
1797
|
children: [
|
|
@@ -1335,7 +1801,7 @@ function za({
|
|
|
1335
1801
|
"aria-label": "反馈原因",
|
|
1336
1802
|
maxLength: 128,
|
|
1337
1803
|
value: i,
|
|
1338
|
-
onChange: (
|
|
1804
|
+
onChange: (p) => c(p.currentTarget.value),
|
|
1339
1805
|
placeholder: "原因(可选)"
|
|
1340
1806
|
}
|
|
1341
1807
|
),
|
|
@@ -1344,8 +1810,8 @@ function za({
|
|
|
1344
1810
|
{
|
|
1345
1811
|
"aria-label": "反馈说明",
|
|
1346
1812
|
maxLength: 4e3,
|
|
1347
|
-
value:
|
|
1348
|
-
onChange: (
|
|
1813
|
+
value: l,
|
|
1814
|
+
onChange: (p) => m(p.currentTarget.value),
|
|
1349
1815
|
placeholder: "补充说明(可选)"
|
|
1350
1816
|
}
|
|
1351
1817
|
),
|
|
@@ -1354,7 +1820,7 @@ function za({
|
|
|
1354
1820
|
{
|
|
1355
1821
|
className: "make-ai-assistant__feedback-text-action",
|
|
1356
1822
|
type: "submit",
|
|
1357
|
-
disabled:
|
|
1823
|
+
disabled: y,
|
|
1358
1824
|
children: "提交反馈"
|
|
1359
1825
|
}
|
|
1360
1826
|
),
|
|
@@ -1363,7 +1829,7 @@ function za({
|
|
|
1363
1829
|
{
|
|
1364
1830
|
className: "make-ai-assistant__feedback-text-action",
|
|
1365
1831
|
type: "button",
|
|
1366
|
-
onClick: () =>
|
|
1832
|
+
onClick: () => n(!1),
|
|
1367
1833
|
children: "取消"
|
|
1368
1834
|
}
|
|
1369
1835
|
)
|
|
@@ -1374,7 +1840,7 @@ function za({
|
|
|
1374
1840
|
}
|
|
1375
1841
|
);
|
|
1376
1842
|
}
|
|
1377
|
-
const
|
|
1843
|
+
const Vt = /* @__PURE__ */ new Set([
|
|
1378
1844
|
"image/png",
|
|
1379
1845
|
"image/jpeg",
|
|
1380
1846
|
"image/webp",
|
|
@@ -1387,86 +1853,86 @@ const Ft = /* @__PURE__ */ new Set([
|
|
|
1387
1853
|
"video/webm",
|
|
1388
1854
|
"video/ogg"
|
|
1389
1855
|
]);
|
|
1390
|
-
function
|
|
1856
|
+
function Fs({
|
|
1391
1857
|
part: e,
|
|
1392
1858
|
context: t,
|
|
1393
1859
|
transport: s,
|
|
1394
|
-
chatId:
|
|
1860
|
+
chatId: n
|
|
1395
1861
|
}) {
|
|
1396
|
-
const [i, c] =
|
|
1397
|
-
|
|
1862
|
+
const [i, c] = $(), [l, m] = $(), [y, v] = $(!1), p = D([]), A = D(void 0);
|
|
1863
|
+
ne(
|
|
1398
1864
|
() => () => {
|
|
1399
|
-
|
|
1865
|
+
A.current?.abort(), p.current.forEach((S) => URL.revokeObjectURL(S));
|
|
1400
1866
|
},
|
|
1401
1867
|
[]
|
|
1402
1868
|
);
|
|
1403
|
-
const
|
|
1404
|
-
if (!s.readContent ||
|
|
1405
|
-
const
|
|
1406
|
-
|
|
1869
|
+
const C = async (S) => {
|
|
1870
|
+
if (!s.readContent || y) return;
|
|
1871
|
+
const k = new AbortController();
|
|
1872
|
+
A.current = k, v(!0), m(void 0);
|
|
1407
1873
|
try {
|
|
1408
|
-
const
|
|
1874
|
+
const U = await s.readContent(
|
|
1409
1875
|
t,
|
|
1410
|
-
{ chatId:
|
|
1411
|
-
{ signal:
|
|
1876
|
+
{ chatId: n, contentRef: e.media.contentRef },
|
|
1877
|
+
{ signal: k.signal }
|
|
1412
1878
|
);
|
|
1413
|
-
if (
|
|
1414
|
-
const
|
|
1415
|
-
type:
|
|
1416
|
-
}),
|
|
1417
|
-
if (
|
|
1879
|
+
if (k.signal.aborted) return;
|
|
1880
|
+
const L = new Blob([new Uint8Array(U).buffer], {
|
|
1881
|
+
type: S && Vt.has(e.media.contentType) ? e.media.contentType : "application/octet-stream"
|
|
1882
|
+
}), H = URL.createObjectURL(L);
|
|
1883
|
+
if (p.current.push(H), S) c(H);
|
|
1418
1884
|
else {
|
|
1419
|
-
const
|
|
1420
|
-
|
|
1885
|
+
const _ = document.createElement("a");
|
|
1886
|
+
_.href = H, _.download = e.name ?? "attachment", _.click();
|
|
1421
1887
|
}
|
|
1422
|
-
} catch (
|
|
1423
|
-
|
|
1888
|
+
} catch (U) {
|
|
1889
|
+
k.signal.aborted || m(Et(U));
|
|
1424
1890
|
} finally {
|
|
1425
|
-
|
|
1891
|
+
k.signal.aborted || v(!1);
|
|
1426
1892
|
}
|
|
1427
1893
|
};
|
|
1428
|
-
return /* @__PURE__ */
|
|
1429
|
-
/* @__PURE__ */
|
|
1894
|
+
return /* @__PURE__ */ u("div", { className: "make-ai-assistant__attachment", children: [
|
|
1895
|
+
/* @__PURE__ */ u("span", { children: [
|
|
1430
1896
|
e.name ?? "附件",
|
|
1431
1897
|
" · ",
|
|
1432
1898
|
e.media.sizeBytes,
|
|
1433
1899
|
" 字节"
|
|
1434
1900
|
] }),
|
|
1435
|
-
s.readContent ? /* @__PURE__ */
|
|
1901
|
+
s.readContent ? /* @__PURE__ */ u(Ie, { children: [
|
|
1436
1902
|
/* @__PURE__ */ a(
|
|
1437
1903
|
"button",
|
|
1438
1904
|
{
|
|
1439
1905
|
type: "button",
|
|
1440
|
-
disabled:
|
|
1906
|
+
disabled: y,
|
|
1441
1907
|
onClick: () => {
|
|
1442
|
-
|
|
1908
|
+
C(!1);
|
|
1443
1909
|
},
|
|
1444
1910
|
children: "下载附件"
|
|
1445
1911
|
}
|
|
1446
1912
|
),
|
|
1447
|
-
|
|
1913
|
+
Vt.has(e.media.contentType) ? /* @__PURE__ */ a(
|
|
1448
1914
|
"button",
|
|
1449
1915
|
{
|
|
1450
1916
|
type: "button",
|
|
1451
|
-
disabled:
|
|
1917
|
+
disabled: y,
|
|
1452
1918
|
onClick: () => {
|
|
1453
|
-
|
|
1919
|
+
C(!0);
|
|
1454
1920
|
},
|
|
1455
1921
|
children: "预览附件"
|
|
1456
1922
|
}
|
|
1457
1923
|
) : null
|
|
1458
1924
|
] }) : null,
|
|
1459
|
-
|
|
1925
|
+
l ? /* @__PURE__ */ a("span", { role: "alert", children: l }) : null,
|
|
1460
1926
|
i && e.kind === "image" ? /* @__PURE__ */ a("img", { src: i, alt: e.name ?? "附件图片" }) : null,
|
|
1461
1927
|
i && e.kind === "audio" ? /* @__PURE__ */ a("audio", { src: i, controls: !0 }) : null,
|
|
1462
1928
|
i && e.kind === "video" ? /* @__PURE__ */ a("video", { src: i, controls: !0 }) : null
|
|
1463
1929
|
] });
|
|
1464
1930
|
}
|
|
1465
|
-
function
|
|
1931
|
+
function Hs({
|
|
1466
1932
|
message: e,
|
|
1467
1933
|
context: t,
|
|
1468
1934
|
transport: s,
|
|
1469
|
-
chatId:
|
|
1935
|
+
chatId: n
|
|
1470
1936
|
}) {
|
|
1471
1937
|
return /* @__PURE__ */ a(Ie, { children: e.parts?.map(
|
|
1472
1938
|
(i, c) => i.kind === "text" ? null : i.kind === "unknown" ? /* @__PURE__ */ a(
|
|
@@ -1477,201 +1943,228 @@ function Ka({
|
|
|
1477
1943
|
},
|
|
1478
1944
|
i.id ?? `${e.id}:${c}`
|
|
1479
1945
|
) : /* @__PURE__ */ a(
|
|
1480
|
-
|
|
1946
|
+
Fs,
|
|
1481
1947
|
{
|
|
1482
1948
|
part: i,
|
|
1483
1949
|
context: t,
|
|
1484
1950
|
transport: s,
|
|
1485
|
-
chatId:
|
|
1951
|
+
chatId: n
|
|
1486
1952
|
},
|
|
1487
1953
|
i.id ?? `${e.id}:${c}`
|
|
1488
1954
|
)
|
|
1489
1955
|
) });
|
|
1490
1956
|
}
|
|
1491
|
-
const
|
|
1492
|
-
|
|
1957
|
+
const Kt = (e) => {
|
|
1958
|
+
switch (e.status) {
|
|
1959
|
+
case "ready":
|
|
1960
|
+
return "已上传";
|
|
1961
|
+
case "completing":
|
|
1962
|
+
return "校验中";
|
|
1963
|
+
case "paused":
|
|
1964
|
+
return "已暂停";
|
|
1965
|
+
case "failed":
|
|
1966
|
+
return "上传失败";
|
|
1967
|
+
default:
|
|
1968
|
+
return `${Math.round(e.progress * 100)}%`;
|
|
1969
|
+
}
|
|
1970
|
+
}, Os = (e, t) => {
|
|
1971
|
+
switch (e.status) {
|
|
1972
|
+
case "uploading":
|
|
1973
|
+
case "queued":
|
|
1974
|
+
return t;
|
|
1975
|
+
case "completing":
|
|
1976
|
+
return "校验";
|
|
1977
|
+
case "paused":
|
|
1978
|
+
return "暂停";
|
|
1979
|
+
case "failed":
|
|
1980
|
+
return "失败";
|
|
1981
|
+
case "ready":
|
|
1982
|
+
return;
|
|
1983
|
+
}
|
|
1984
|
+
}, La = (e) => e.type.split(";")[0].trim().toLowerCase() || "application/octet-stream", qs = (e) => e.startsWith("image/") && e !== "image/svg+xml" ? "image" : e.startsWith("audio/") ? "audio" : e.startsWith("video/") ? "video" : "file", js = (e) => {
|
|
1985
|
+
const t = La(e);
|
|
1493
1986
|
if (!(!t.startsWith("image/") || t === "image/svg+xml" || typeof URL > "u" || typeof URL.createObjectURL != "function"))
|
|
1494
1987
|
return URL.createObjectURL(e);
|
|
1495
|
-
},
|
|
1988
|
+
}, Wt = (e) => {
|
|
1496
1989
|
e && typeof URL < "u" && typeof URL.revokeObjectURL == "function" && URL.revokeObjectURL(e);
|
|
1497
|
-
},
|
|
1498
|
-
const i = new FileReader(), c = () => t.removeEventListener("abort",
|
|
1499
|
-
i.abort(), c(),
|
|
1990
|
+
}, Bs = (e, t) => new Promise((s, n) => {
|
|
1991
|
+
const i = new FileReader(), c = () => t.removeEventListener("abort", l), l = () => {
|
|
1992
|
+
i.abort(), c(), n(Object.assign(new Error("Read aborted"), { name: "AbortError" }));
|
|
1500
1993
|
};
|
|
1501
1994
|
if (t.aborted) {
|
|
1502
|
-
|
|
1995
|
+
l();
|
|
1503
1996
|
return;
|
|
1504
1997
|
}
|
|
1505
|
-
t.addEventListener("abort",
|
|
1998
|
+
t.addEventListener("abort", l, { once: !0 }), i.onload = () => {
|
|
1506
1999
|
c(), s(new Uint8Array(i.result));
|
|
1507
2000
|
}, i.onerror = () => {
|
|
1508
|
-
c(),
|
|
2001
|
+
c(), n(new Error("无法读取文件"));
|
|
1509
2002
|
}, i.readAsArrayBuffer(e);
|
|
1510
2003
|
});
|
|
1511
|
-
function
|
|
1512
|
-
const [
|
|
1513
|
-
|
|
1514
|
-
const v =
|
|
1515
|
-
!c.current.has(
|
|
1516
|
-
},
|
|
1517
|
-
for (const
|
|
1518
|
-
|
|
1519
|
-
c.current.clear(), i([]), v.current = void 0,
|
|
2004
|
+
function Vs(e, t, s) {
|
|
2005
|
+
const [n, i] = $([]), c = D(/* @__PURE__ */ new Map()), l = D(Promise.resolve()), m = t.scopeKey?.(e) ?? e.app.id, y = D(m);
|
|
2006
|
+
y.current = m;
|
|
2007
|
+
const v = D(void 0), p = s.enabled && t.features?.attachments === !0, A = (h, r) => {
|
|
2008
|
+
!c.current.has(h.draft.id) || h.scope !== y.current || (h.draft = { ...h.draft, ...r }, i([...c.current.values()].map((b) => b.draft)));
|
|
2009
|
+
}, C = () => {
|
|
2010
|
+
for (const h of c.current.values())
|
|
2011
|
+
h.controller.abort(), Wt(h.draft.previewUrl);
|
|
2012
|
+
c.current.clear(), i([]), v.current = void 0, l.current = Promise.resolve();
|
|
1520
2013
|
};
|
|
1521
|
-
|
|
1522
|
-
v.current && s.chat?.chatId !== v.current &&
|
|
2014
|
+
ne(() => (C(), C), [m, t]), ne(() => {
|
|
2015
|
+
v.current && s.chat?.chatId !== v.current && C();
|
|
1523
2016
|
}, [s.chat?.chatId]);
|
|
1524
|
-
const
|
|
1525
|
-
const
|
|
1526
|
-
if (
|
|
2017
|
+
const S = async (h) => {
|
|
2018
|
+
const r = h.controller.signal, b = () => {
|
|
2019
|
+
if (r.aborted || h.scope !== y.current || !c.current.has(h.draft.id))
|
|
1527
2020
|
throw Object.assign(new Error("Upload aborted"), {
|
|
1528
2021
|
name: "AbortError"
|
|
1529
2022
|
});
|
|
1530
2023
|
};
|
|
1531
2024
|
try {
|
|
1532
|
-
if (b(),
|
|
1533
|
-
const
|
|
1534
|
-
b(), v.current =
|
|
1535
|
-
const
|
|
1536
|
-
|
|
1537
|
-
let
|
|
2025
|
+
if (b(), h.file.size > 64 << 20) throw new Error("文件不能超过 64 MiB");
|
|
2026
|
+
const M = await s.ensureChat();
|
|
2027
|
+
b(), v.current = M.chatId;
|
|
2028
|
+
const W = La(h.file);
|
|
2029
|
+
A(h, { status: "uploading", error: void 0 });
|
|
2030
|
+
let N = h.draft.upload ? await t.getUpload(
|
|
1538
2031
|
e,
|
|
1539
|
-
{ chatId:
|
|
1540
|
-
{ signal:
|
|
2032
|
+
{ chatId: M.chatId, uploadId: h.draft.upload.id },
|
|
2033
|
+
{ signal: r }
|
|
1541
2034
|
) : await t.startUpload(
|
|
1542
2035
|
e,
|
|
1543
2036
|
{
|
|
1544
|
-
chatId:
|
|
1545
|
-
fileId:
|
|
1546
|
-
name:
|
|
1547
|
-
contentType:
|
|
1548
|
-
sizeBytes:
|
|
2037
|
+
chatId: M.chatId,
|
|
2038
|
+
fileId: h.draft.fileId,
|
|
2039
|
+
name: h.file.name,
|
|
2040
|
+
contentType: W,
|
|
2041
|
+
sizeBytes: h.file.size
|
|
1549
2042
|
},
|
|
1550
|
-
{ signal:
|
|
2043
|
+
{ signal: r }
|
|
1551
2044
|
);
|
|
1552
|
-
if (b(),
|
|
2045
|
+
if (b(), A(h, { upload: N }), N.name !== h.file.name || N.contentType !== W || N.sizeBytes !== h.file.size)
|
|
1553
2046
|
throw new Error("上传文件身份不一致");
|
|
1554
|
-
if (
|
|
1555
|
-
if (
|
|
2047
|
+
if (N.status !== "ready") {
|
|
2048
|
+
if (N = await t.getUpload(
|
|
1556
2049
|
e,
|
|
1557
|
-
{ chatId:
|
|
1558
|
-
{ signal:
|
|
1559
|
-
), b(),
|
|
1560
|
-
const
|
|
1561
|
-
for (let
|
|
1562
|
-
if (b(), !
|
|
1563
|
-
const
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
Math.min(
|
|
2050
|
+
{ chatId: M.chatId, uploadId: N.id },
|
|
2051
|
+
{ signal: r }
|
|
2052
|
+
), b(), N.status !== "uploading" || !Number.isSafeInteger(N.partSize) || N.partSize <= 0 || N.partSize > 1 << 20) throw new Error("当前上传状态无法继续,请重新选择文件");
|
|
2053
|
+
const X = new Set(N.completedParts), Q = Math.ceil(h.file.size / N.partSize);
|
|
2054
|
+
for (let ie = 0; ie < Q; ie += 1) {
|
|
2055
|
+
if (b(), !X.has(ie)) {
|
|
2056
|
+
const Z = await Bs(
|
|
2057
|
+
h.file.slice(
|
|
2058
|
+
ie * N.partSize,
|
|
2059
|
+
Math.min(h.file.size, (ie + 1) * N.partSize)
|
|
1567
2060
|
),
|
|
1568
|
-
|
|
2061
|
+
r
|
|
1569
2062
|
);
|
|
1570
2063
|
b(), await t.uploadPart(
|
|
1571
2064
|
e,
|
|
1572
|
-
{ chatId:
|
|
1573
|
-
{ signal:
|
|
1574
|
-
), b(),
|
|
2065
|
+
{ chatId: M.chatId, uploadId: N.id, part: ie, bytes: Z },
|
|
2066
|
+
{ signal: r }
|
|
2067
|
+
), b(), X.add(ie);
|
|
1575
2068
|
}
|
|
1576
|
-
|
|
2069
|
+
A(h, { progress: X.size / Math.max(Q, 1) });
|
|
1577
2070
|
}
|
|
1578
|
-
|
|
2071
|
+
A(h, { status: "completing" }), N = await t.completeUpload(
|
|
1579
2072
|
e,
|
|
1580
|
-
{ chatId:
|
|
1581
|
-
{ signal:
|
|
2073
|
+
{ chatId: M.chatId, uploadId: N.id },
|
|
2074
|
+
{ signal: r }
|
|
1582
2075
|
), b();
|
|
1583
2076
|
}
|
|
1584
|
-
if (
|
|
2077
|
+
if (N.status !== "ready" || !N.content)
|
|
1585
2078
|
throw new Error("上传尚未完成");
|
|
1586
|
-
|
|
1587
|
-
} catch (
|
|
1588
|
-
|
|
1589
|
-
status:
|
|
1590
|
-
error:
|
|
2079
|
+
A(h, { status: "ready", progress: 1, upload: N });
|
|
2080
|
+
} catch (M) {
|
|
2081
|
+
A(h, {
|
|
2082
|
+
status: r.aborted ? "paused" : "failed",
|
|
2083
|
+
error: r.aborted ? void 0 : Et(M)
|
|
1591
2084
|
});
|
|
1592
2085
|
}
|
|
1593
|
-
},
|
|
1594
|
-
if (
|
|
1595
|
-
if (
|
|
2086
|
+
}, k = (h) => {
|
|
2087
|
+
if (p) {
|
|
2088
|
+
if (h.length + c.current.size > 32) {
|
|
1596
2089
|
s.setError("每条消息最多包含 32 个附件或文本片段");
|
|
1597
2090
|
return;
|
|
1598
2091
|
}
|
|
1599
|
-
for (const
|
|
2092
|
+
for (const r of h) {
|
|
1600
2093
|
const b = {
|
|
1601
|
-
id:
|
|
1602
|
-
fileId:
|
|
1603
|
-
name:
|
|
1604
|
-
size:
|
|
2094
|
+
id: Oe(),
|
|
2095
|
+
fileId: Oe(),
|
|
2096
|
+
name: r.name,
|
|
2097
|
+
size: r.size,
|
|
1605
2098
|
status: "queued",
|
|
1606
2099
|
progress: 0,
|
|
1607
|
-
previewUrl:
|
|
1608
|
-
},
|
|
2100
|
+
previewUrl: js(r)
|
|
2101
|
+
}, M = {
|
|
1609
2102
|
draft: b,
|
|
1610
|
-
file:
|
|
2103
|
+
file: r,
|
|
1611
2104
|
controller: new AbortController(),
|
|
1612
|
-
scope:
|
|
2105
|
+
scope: m
|
|
1613
2106
|
};
|
|
1614
|
-
c.current.set(b.id,
|
|
2107
|
+
c.current.set(b.id, M), l.current = l.current.then(() => S(M));
|
|
1615
2108
|
}
|
|
1616
|
-
i([...c.current.values()].map((
|
|
2109
|
+
i([...c.current.values()].map((r) => r.draft));
|
|
1617
2110
|
}
|
|
1618
|
-
},
|
|
1619
|
-
const
|
|
1620
|
-
!
|
|
1621
|
-
},
|
|
1622
|
-
const
|
|
1623
|
-
|
|
1624
|
-
},
|
|
1625
|
-
const
|
|
1626
|
-
if (
|
|
1627
|
-
const b =
|
|
2111
|
+
}, U = (h) => {
|
|
2112
|
+
const r = c.current.get(h);
|
|
2113
|
+
!r || !["paused", "failed"].includes(r.draft.status) || (r.controller = new AbortController(), A(r, { status: "queued" }), l.current = l.current.then(() => S(r)));
|
|
2114
|
+
}, L = (h) => {
|
|
2115
|
+
const r = c.current.get(h);
|
|
2116
|
+
r?.controller.abort(), Wt(r?.draft.previewUrl), c.current.delete(h), i([...c.current.values()].map((b) => b.draft));
|
|
2117
|
+
}, H = (h) => c.current.get(h)?.controller.abort(), _ = n.flatMap((h) => {
|
|
2118
|
+
const r = h.upload;
|
|
2119
|
+
if (h.status !== "ready" || !r?.content) return [];
|
|
2120
|
+
const b = qs(r.contentType);
|
|
1628
2121
|
return [
|
|
1629
2122
|
{
|
|
1630
|
-
id:
|
|
2123
|
+
id: h.id,
|
|
1631
2124
|
kind: b,
|
|
1632
|
-
name:
|
|
2125
|
+
name: r.name,
|
|
1633
2126
|
media: {
|
|
1634
|
-
contentRef:
|
|
1635
|
-
contentType:
|
|
1636
|
-
sizeBytes:
|
|
1637
|
-
digestSha256:
|
|
2127
|
+
contentRef: r.content.contentRef,
|
|
2128
|
+
contentType: r.contentType,
|
|
2129
|
+
sizeBytes: r.content.sizeBytes,
|
|
2130
|
+
digestSha256: r.content.digestSha256
|
|
1638
2131
|
}
|
|
1639
2132
|
}
|
|
1640
2133
|
];
|
|
1641
2134
|
});
|
|
1642
2135
|
return {
|
|
1643
|
-
enabled:
|
|
1644
|
-
drafts:
|
|
1645
|
-
parts:
|
|
1646
|
-
pending:
|
|
1647
|
-
add:
|
|
1648
|
-
retry:
|
|
1649
|
-
remove:
|
|
1650
|
-
pause:
|
|
1651
|
-
clear:
|
|
2136
|
+
enabled: p,
|
|
2137
|
+
drafts: n,
|
|
2138
|
+
parts: _,
|
|
2139
|
+
pending: n.some((h) => h.status !== "ready"),
|
|
2140
|
+
add: k,
|
|
2141
|
+
retry: U,
|
|
2142
|
+
remove: L,
|
|
2143
|
+
pause: H,
|
|
2144
|
+
clear: C
|
|
1652
2145
|
};
|
|
1653
2146
|
}
|
|
1654
|
-
function
|
|
2147
|
+
function Ks({
|
|
1655
2148
|
attachments: e,
|
|
1656
2149
|
onOpenChange: t,
|
|
1657
2150
|
open: s,
|
|
1658
|
-
triggerRef:
|
|
2151
|
+
triggerRef: n
|
|
1659
2152
|
}) {
|
|
1660
|
-
const i =
|
|
1661
|
-
|
|
2153
|
+
const i = D(null), c = D(null);
|
|
2154
|
+
ne(() => {
|
|
1662
2155
|
if (!s) return;
|
|
1663
|
-
const
|
|
1664
|
-
const v =
|
|
2156
|
+
const m = (y) => {
|
|
2157
|
+
const v = y.target;
|
|
1665
2158
|
v instanceof Node && !i.current?.contains(v) && t(!1);
|
|
1666
2159
|
};
|
|
1667
|
-
return document.addEventListener("pointerdown",
|
|
1668
|
-
document.removeEventListener("pointerdown",
|
|
2160
|
+
return document.addEventListener("pointerdown", m), () => {
|
|
2161
|
+
document.removeEventListener("pointerdown", m);
|
|
1669
2162
|
};
|
|
1670
2163
|
}, [t, s]);
|
|
1671
|
-
const
|
|
1672
|
-
e.add(Array.from(
|
|
2164
|
+
const l = (m) => {
|
|
2165
|
+
e.add(Array.from(m.files ?? [])), m.value = "", t(!1);
|
|
1673
2166
|
};
|
|
1674
|
-
return /* @__PURE__ */
|
|
2167
|
+
return /* @__PURE__ */ u("div", { className: "make-ai-assistant__attachment-composer", ref: i, children: [
|
|
1675
2168
|
/* @__PURE__ */ a(
|
|
1676
2169
|
"button",
|
|
1677
2170
|
{
|
|
@@ -1679,12 +2172,12 @@ function Ga({
|
|
|
1679
2172
|
"aria-haspopup": "menu",
|
|
1680
2173
|
"aria-label": "添加附件",
|
|
1681
2174
|
className: "make-ai-assistant__attachment-trigger",
|
|
1682
|
-
ref:
|
|
2175
|
+
ref: n,
|
|
1683
2176
|
title: "添加附件",
|
|
1684
2177
|
type: "button",
|
|
1685
2178
|
onClick: () => t(!s),
|
|
1686
2179
|
children: /* @__PURE__ */ a(
|
|
1687
|
-
|
|
2180
|
+
Tt,
|
|
1688
2181
|
{
|
|
1689
2182
|
"aria-hidden": "true",
|
|
1690
2183
|
className: "make-ai-assistant__attachment-trigger-icon"
|
|
@@ -1698,17 +2191,14 @@ function Ga({
|
|
|
1698
2191
|
"aria-label": "附件选项",
|
|
1699
2192
|
className: "make-ai-assistant__attachment-menu",
|
|
1700
2193
|
role: "menu",
|
|
1701
|
-
children: /* @__PURE__ */
|
|
2194
|
+
children: /* @__PURE__ */ u(
|
|
1702
2195
|
"button",
|
|
1703
2196
|
{
|
|
1704
2197
|
role: "menuitem",
|
|
1705
2198
|
type: "button",
|
|
1706
2199
|
onClick: () => c.current?.click(),
|
|
1707
2200
|
children: [
|
|
1708
|
-
/* @__PURE__ */
|
|
1709
|
-
/* @__PURE__ */ a("path", { d: "M12 15V4M7.5 8.5 12 4l4.5 4.5" }),
|
|
1710
|
-
/* @__PURE__ */ a("path", { d: "M5 14v5h14v-5" })
|
|
1711
|
-
] }),
|
|
2201
|
+
/* @__PURE__ */ a(zs, { "aria-hidden": "true" }),
|
|
1712
2202
|
/* @__PURE__ */ a("span", { children: "上传文件或图片" })
|
|
1713
2203
|
]
|
|
1714
2204
|
}
|
|
@@ -1723,120 +2213,150 @@ function Ga({
|
|
|
1723
2213
|
multiple: !0,
|
|
1724
2214
|
ref: c,
|
|
1725
2215
|
type: "file",
|
|
1726
|
-
onChange: (
|
|
2216
|
+
onChange: (m) => l(m.currentTarget)
|
|
1727
2217
|
}
|
|
1728
2218
|
)
|
|
1729
2219
|
] });
|
|
1730
2220
|
}
|
|
1731
|
-
function
|
|
2221
|
+
function Ws({
|
|
1732
2222
|
attachments: e,
|
|
1733
2223
|
visible: t
|
|
1734
2224
|
}) {
|
|
1735
|
-
const [s,
|
|
1736
|
-
|
|
2225
|
+
const [s, n] = $(), i = e.drafts.find((p) => p.id === s), c = !!i, l = D(null), m = D(null), y = Va(() => {
|
|
2226
|
+
n(void 0), m.current?.focus();
|
|
1737
2227
|
}, []);
|
|
1738
|
-
if (
|
|
1739
|
-
if (!
|
|
1740
|
-
const
|
|
1741
|
-
|
|
2228
|
+
if (ne(() => {
|
|
2229
|
+
if (!c) return;
|
|
2230
|
+
const p = (A) => {
|
|
2231
|
+
A.key === "Escape" && (A.preventDefault(), A.stopImmediatePropagation(), y());
|
|
1742
2232
|
};
|
|
1743
|
-
return document.addEventListener("keydown",
|
|
1744
|
-
}, [
|
|
1745
|
-
t ||
|
|
2233
|
+
return document.addEventListener("keydown", p, !0), () => document.removeEventListener("keydown", p, !0);
|
|
2234
|
+
}, [y, c]), ne(() => {
|
|
2235
|
+
t || n(void 0);
|
|
1746
2236
|
}, [t]), !e.drafts.length) return null;
|
|
1747
|
-
const
|
|
1748
|
-
return /* @__PURE__ */
|
|
2237
|
+
const v = typeof document > "u" ? void 0 : l.current?.closest(".make-ai-assistant") ?? document.body;
|
|
2238
|
+
return /* @__PURE__ */ u(
|
|
1749
2239
|
"div",
|
|
1750
2240
|
{
|
|
1751
2241
|
"aria-label": "待发送附件",
|
|
1752
2242
|
className: "make-ai-assistant__attachment-drafts",
|
|
1753
|
-
ref:
|
|
2243
|
+
ref: l,
|
|
1754
2244
|
children: [
|
|
1755
|
-
/* @__PURE__ */ a("ul", { children: e.drafts.map((
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
"aria-label": `预览附件 ${d.name}`,
|
|
1760
|
-
className: "make-ai-assistant__attachment-draft-preview-button",
|
|
1761
|
-
type: "button",
|
|
1762
|
-
onClick: (v) => {
|
|
1763
|
-
c.current = v.currentTarget, o(d);
|
|
1764
|
-
},
|
|
1765
|
-
children: /* @__PURE__ */ a(
|
|
1766
|
-
"img",
|
|
1767
|
-
{
|
|
1768
|
-
alt: "",
|
|
1769
|
-
className: "make-ai-assistant__attachment-draft-preview",
|
|
1770
|
-
src: d.previewUrl
|
|
1771
|
-
}
|
|
1772
|
-
)
|
|
1773
|
-
}
|
|
1774
|
-
) : /* @__PURE__ */ a(
|
|
1775
|
-
"span",
|
|
1776
|
-
{
|
|
1777
|
-
"aria-hidden": "true",
|
|
1778
|
-
className: "make-ai-assistant__attachment-draft-file",
|
|
1779
|
-
children: /* @__PURE__ */ l("svg", { viewBox: "0 0 24 24", children: [
|
|
1780
|
-
/* @__PURE__ */ a("path", { d: "M6 3h8l4 4v14H6z" }),
|
|
1781
|
-
/* @__PURE__ */ a("path", { d: "M14 3v5h5M9 13h6M9 16h6" })
|
|
1782
|
-
] })
|
|
1783
|
-
}
|
|
1784
|
-
),
|
|
1785
|
-
/* @__PURE__ */ l("span", { className: "make-ai-assistant__attachment-draft-details", children: [
|
|
1786
|
-
/* @__PURE__ */ a("span", { className: "make-ai-assistant__attachment-draft-name", title: d.name, children: d.name }),
|
|
1787
|
-
/* @__PURE__ */ a("span", { className: "make-ai-assistant__attachment-draft-status", children: d.status === "ready" ? "已上传" : d.status === "completing" ? "校验中" : d.status === "paused" ? "已暂停" : d.status === "failed" ? "上传失败" : `${Math.round(d.progress * 100)}%` })
|
|
1788
|
-
] }),
|
|
1789
|
-
d.error ? /* @__PURE__ */ a("span", { role: "alert", children: d.error }) : null,
|
|
1790
|
-
d.status === "failed" || d.status === "paused" ? /* @__PURE__ */ a("button", { type: "button", onClick: () => e.retry(d.id), children: "重试上传" }) : null,
|
|
1791
|
-
d.status === "uploading" ? /* @__PURE__ */ a("button", { type: "button", onClick: () => e.pause(d.id), children: "暂停上传" }) : null,
|
|
1792
|
-
/* @__PURE__ */ a(
|
|
1793
|
-
"button",
|
|
2245
|
+
/* @__PURE__ */ a("ul", { children: e.drafts.map((p) => {
|
|
2246
|
+
const A = Kt(p), C = Os(p, A);
|
|
2247
|
+
return /* @__PURE__ */ u(
|
|
2248
|
+
"li",
|
|
1794
2249
|
{
|
|
1795
|
-
"aria-label":
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
2250
|
+
"aria-label": `${p.name},${A}`,
|
|
2251
|
+
"data-status": p.status,
|
|
2252
|
+
children: [
|
|
2253
|
+
p.previewUrl ? /* @__PURE__ */ a(
|
|
2254
|
+
"button",
|
|
2255
|
+
{
|
|
2256
|
+
"aria-label": `预览附件 ${p.name}`,
|
|
2257
|
+
className: "make-ai-assistant__attachment-draft-preview-button",
|
|
2258
|
+
type: "button",
|
|
2259
|
+
onClick: (S) => {
|
|
2260
|
+
m.current = S.currentTarget, n(p.id);
|
|
2261
|
+
},
|
|
2262
|
+
children: /* @__PURE__ */ a(
|
|
2263
|
+
"img",
|
|
2264
|
+
{
|
|
2265
|
+
alt: "",
|
|
2266
|
+
className: "make-ai-assistant__attachment-draft-preview",
|
|
2267
|
+
src: p.previewUrl
|
|
2268
|
+
}
|
|
2269
|
+
)
|
|
2270
|
+
}
|
|
2271
|
+
) : /* @__PURE__ */ a(
|
|
2272
|
+
"button",
|
|
2273
|
+
{
|
|
2274
|
+
"aria-label": `查看附件详情 ${p.name}`,
|
|
2275
|
+
className: "make-ai-assistant__attachment-draft-file",
|
|
2276
|
+
type: "button",
|
|
2277
|
+
onClick: (S) => {
|
|
2278
|
+
m.current = S.currentTarget, n(p.id);
|
|
2279
|
+
},
|
|
2280
|
+
children: /* @__PURE__ */ a(Ot, { "aria-hidden": "true" })
|
|
2281
|
+
}
|
|
2282
|
+
),
|
|
2283
|
+
C ? /* @__PURE__ */ a("span", { "aria-hidden": "true", className: "make-ai-assistant__attachment-draft-status", children: C }) : null,
|
|
2284
|
+
p.error ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__attachment-draft-error", role: "alert", children: p.error }) : null,
|
|
2285
|
+
p.status === "failed" || p.status === "paused" ? /* @__PURE__ */ a(
|
|
2286
|
+
"button",
|
|
2287
|
+
{
|
|
2288
|
+
"aria-label": `重试上传 ${p.name}`,
|
|
2289
|
+
className: "make-ai-assistant__attachment-draft-control",
|
|
2290
|
+
title: "重试上传",
|
|
2291
|
+
type: "button",
|
|
2292
|
+
onClick: () => e.retry(p.id),
|
|
2293
|
+
children: /* @__PURE__ */ a($s, { "aria-hidden": "true" })
|
|
2294
|
+
}
|
|
2295
|
+
) : null,
|
|
2296
|
+
p.status === "uploading" ? /* @__PURE__ */ a(
|
|
2297
|
+
"button",
|
|
2298
|
+
{
|
|
2299
|
+
"aria-label": `暂停上传 ${p.name}`,
|
|
2300
|
+
className: "make-ai-assistant__attachment-draft-control",
|
|
2301
|
+
title: "暂停上传",
|
|
2302
|
+
type: "button",
|
|
2303
|
+
onClick: () => e.pause(p.id),
|
|
2304
|
+
children: /* @__PURE__ */ a(Ms, { "aria-hidden": "true" })
|
|
2305
|
+
}
|
|
2306
|
+
) : null,
|
|
2307
|
+
/* @__PURE__ */ a(
|
|
2308
|
+
"button",
|
|
2309
|
+
{
|
|
2310
|
+
"aria-label": `移除附件 ${p.name}`,
|
|
2311
|
+
className: "make-ai-assistant__attachment-draft-remove",
|
|
2312
|
+
type: "button",
|
|
2313
|
+
onClick: () => {
|
|
2314
|
+
s === p.id && y(), e.remove(p.id);
|
|
2315
|
+
},
|
|
2316
|
+
children: /* @__PURE__ */ a(
|
|
2317
|
+
tt,
|
|
2318
|
+
{
|
|
2319
|
+
"aria-hidden": "true",
|
|
2320
|
+
className: "make-ai-assistant__attachment-draft-remove-icon"
|
|
2321
|
+
}
|
|
2322
|
+
)
|
|
2323
|
+
}
|
|
2324
|
+
)
|
|
2325
|
+
]
|
|
2326
|
+
},
|
|
2327
|
+
p.id
|
|
2328
|
+
);
|
|
2329
|
+
}) }),
|
|
2330
|
+
i && v ? aa(
|
|
1812
2331
|
/* @__PURE__ */ a(
|
|
1813
2332
|
"div",
|
|
1814
2333
|
{
|
|
1815
2334
|
className: "make-ai-assistant__attachment-preview-backdrop",
|
|
1816
|
-
onPointerDown: (
|
|
1817
|
-
|
|
2335
|
+
onPointerDown: (p) => {
|
|
2336
|
+
p.target === p.currentTarget && y();
|
|
1818
2337
|
},
|
|
1819
|
-
children: /* @__PURE__ */
|
|
2338
|
+
children: /* @__PURE__ */ u(
|
|
1820
2339
|
"div",
|
|
1821
2340
|
{
|
|
1822
|
-
"aria-label":
|
|
2341
|
+
"aria-label": `${i.previewUrl ? "预览附件" : "附件详情"} ${i.name}`,
|
|
1823
2342
|
"aria-modal": "true",
|
|
1824
2343
|
className: "make-ai-assistant__attachment-preview-dialog",
|
|
2344
|
+
"data-kind": i.previewUrl ? "image" : "file",
|
|
1825
2345
|
role: "dialog",
|
|
1826
|
-
onKeyDown: (
|
|
1827
|
-
|
|
2346
|
+
onKeyDown: (p) => {
|
|
2347
|
+
p.key === "Tab" && p.preventDefault();
|
|
1828
2348
|
},
|
|
1829
2349
|
children: [
|
|
1830
2350
|
/* @__PURE__ */ a(
|
|
1831
2351
|
"button",
|
|
1832
2352
|
{
|
|
1833
|
-
"aria-label":
|
|
2353
|
+
"aria-label": `${i.previewUrl ? "关闭图片预览" : "关闭附件详情"} ${i.name}`,
|
|
1834
2354
|
autoFocus: !0,
|
|
1835
2355
|
className: "make-ai-assistant__attachment-preview-close",
|
|
1836
2356
|
type: "button",
|
|
1837
|
-
onClick:
|
|
2357
|
+
onClick: y,
|
|
1838
2358
|
children: /* @__PURE__ */ a(
|
|
1839
|
-
|
|
2359
|
+
tt,
|
|
1840
2360
|
{
|
|
1841
2361
|
"aria-hidden": "true",
|
|
1842
2362
|
className: "make-ai-assistant__attachment-preview-close-icon"
|
|
@@ -1844,43 +2364,48 @@ function Xa({
|
|
|
1844
2364
|
)
|
|
1845
2365
|
}
|
|
1846
2366
|
),
|
|
1847
|
-
/* @__PURE__ */ a("img", { alt:
|
|
2367
|
+
i.previewUrl ? /* @__PURE__ */ a("img", { alt: i.name, src: i.previewUrl }) : /* @__PURE__ */ a("div", { "aria-hidden": "true", className: "make-ai-assistant__attachment-preview-file", children: /* @__PURE__ */ a(Ot, {}) }),
|
|
2368
|
+
/* @__PURE__ */ u("div", { className: "make-ai-assistant__attachment-preview-details", children: [
|
|
2369
|
+
/* @__PURE__ */ a("strong", { children: i.name }),
|
|
2370
|
+
/* @__PURE__ */ a("span", { children: Kt(i) }),
|
|
2371
|
+
i.error ? /* @__PURE__ */ a("p", { children: i.error }) : null
|
|
2372
|
+
] })
|
|
1848
2373
|
]
|
|
1849
2374
|
}
|
|
1850
2375
|
)
|
|
1851
2376
|
}
|
|
1852
2377
|
),
|
|
1853
|
-
|
|
2378
|
+
v
|
|
1854
2379
|
) : null
|
|
1855
2380
|
]
|
|
1856
2381
|
}
|
|
1857
2382
|
);
|
|
1858
2383
|
}
|
|
1859
|
-
const
|
|
2384
|
+
const Xs = (e) => `${e}-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, Gs = "Make", Zs = [
|
|
1860
2385
|
"总结当前页面数据",
|
|
1861
2386
|
"找出需要关注的记录",
|
|
1862
2387
|
"列出我有权限查看的数据对象"
|
|
1863
|
-
],
|
|
1864
|
-
class
|
|
2388
|
+
], Js = 48, Ys = 160, za = (e, t) => t ?? `${e?.trim() || Gs} AI 助手`, Qs = (e) => e ?? Zs, en = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : void 0, tn = (e) => typeof e == "number" ? Number.isFinite(e) ? `${e}px` : void 0 : e?.trim() || void 0;
|
|
2389
|
+
class J extends Error {
|
|
1865
2390
|
}
|
|
1866
|
-
const
|
|
2391
|
+
const pt = (e, t) => {
|
|
1867
2392
|
if (!(typeof e != "object" || e === null))
|
|
1868
2393
|
return e[t];
|
|
1869
|
-
},
|
|
1870
|
-
const t =
|
|
1871
|
-
return typeof t == "number" ? t :
|
|
1872
|
-
|
|
2394
|
+
}, an = (e) => {
|
|
2395
|
+
const t = pt(e, "status");
|
|
2396
|
+
return typeof t == "number" ? t : pt(
|
|
2397
|
+
pt(e, "response"),
|
|
1873
2398
|
"status"
|
|
1874
2399
|
);
|
|
1875
|
-
},
|
|
1876
|
-
const t =
|
|
1877
|
-
return
|
|
2400
|
+
}, sn = (e) => {
|
|
2401
|
+
const t = pt(e, "code"), s = an(e), n = e instanceof Error ? e.message : "", i = [t, n].filter((y) => typeof y == "string").join(" ").toLowerCase(), l = globalThis.navigator?.onLine === !1 || /network|fetch|timeout|offline|connection|网络|连接|超时/.test(i), m = typeof s == "number" && s >= 500 || /server|service|服务器|服务异常/.test(i);
|
|
2402
|
+
return l ? {
|
|
1878
2403
|
actionLabel: "重新连接",
|
|
1879
2404
|
description: "请检查网络后再试。",
|
|
1880
2405
|
kind: "network",
|
|
1881
2406
|
label: "网络连接",
|
|
1882
2407
|
title: "网络连接不可用"
|
|
1883
|
-
} :
|
|
2408
|
+
} : m ? {
|
|
1884
2409
|
actionLabel: "重新加载",
|
|
1885
2410
|
description: "服务暂时未能响应,请稍后重试。",
|
|
1886
2411
|
kind: "service",
|
|
@@ -1893,7 +2418,7 @@ const mt = (e, t) => {
|
|
|
1893
2418
|
label: "加载异常",
|
|
1894
2419
|
title: "暂时无法加载对话"
|
|
1895
2420
|
};
|
|
1896
|
-
},
|
|
2421
|
+
}, Xt = (e) => {
|
|
1897
2422
|
try {
|
|
1898
2423
|
const t = e?.return?.();
|
|
1899
2424
|
if (!t) return;
|
|
@@ -1907,7 +2432,7 @@ const mt = (e, t) => {
|
|
|
1907
2432
|
errorType: t instanceof Error ? t.name : typeof t
|
|
1908
2433
|
});
|
|
1909
2434
|
}
|
|
1910
|
-
},
|
|
2435
|
+
}, nn = async (e) => {
|
|
1911
2436
|
if (globalThis.navigator?.clipboard?.writeText) {
|
|
1912
2437
|
await globalThis.navigator.clipboard.writeText(e);
|
|
1913
2438
|
return;
|
|
@@ -1919,175 +2444,151 @@ const mt = (e, t) => {
|
|
|
1919
2444
|
const s = document.execCommand("copy");
|
|
1920
2445
|
if (t.remove(), !s)
|
|
1921
2446
|
throw new Error("Clipboard copy failed");
|
|
1922
|
-
},
|
|
1923
|
-
/* @__PURE__ */ a("path", { d: "M12 2.8c.5 4.4 2.8 6.8 7.2 7.2-4.4.5-6.8 2.8-7.2 7.2-.5-4.4-2.8-6.8-7.2-7.2 4.4-.5 6.8-2.8 7.2-7.2Z" }),
|
|
1924
|
-
/* @__PURE__ */ a("path", { d: "M18.3 16.1c.2 1.8 1.2 2.8 3 3-1.8.2-2.8 1.2-3 3-.2-1.8-1.2-2.8-3-3 1.8-.2 2.8-1.2 3-3Z" })
|
|
1925
|
-
] }), cs = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "m6 6 12 12M18 6 6 18" }) }), ls = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
1926
|
-
/* @__PURE__ */ a("path", { d: "M20 11a8 8 0 0 0-14.7-4.4L4 8" }),
|
|
1927
|
-
/* @__PURE__ */ a("path", { d: "M4 4v4h4" }),
|
|
1928
|
-
/* @__PURE__ */ a("path", { d: "M4 13a8 8 0 0 0 14.7 4.4L20 16" }),
|
|
1929
|
-
/* @__PURE__ */ a("path", { d: "M20 20v-4h-4" })
|
|
1930
|
-
] }), ds = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
1931
|
-
/* @__PURE__ */ a("path", { d: "M12 4v11" }),
|
|
1932
|
-
/* @__PURE__ */ a("path", { d: "m7 10 5 5 5-5" }),
|
|
1933
|
-
/* @__PURE__ */ a("path", { d: "M5 20h14" })
|
|
1934
|
-
] }), Ot = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
1935
|
-
/* @__PURE__ */ a("path", { d: "m4 4 17 8-17 8 3-8-3-8Z" }),
|
|
1936
|
-
/* @__PURE__ */ a("path", { d: "M7 12h14" })
|
|
1937
|
-
] }), ta = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
1938
|
-
/* @__PURE__ */ a("path", { d: "M20 11a8 8 0 0 0-14.7-4.4L4 8" }),
|
|
1939
|
-
/* @__PURE__ */ a("path", { d: "M4 4v4h4" }),
|
|
1940
|
-
/* @__PURE__ */ a("path", { d: "M4 13a8 8 0 0 0 14.7 4.4L20 16" }),
|
|
1941
|
-
/* @__PURE__ */ a("path", { d: "M20 20v-4h-4" })
|
|
1942
|
-
] }), us = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
1943
|
-
/* @__PURE__ */ a("circle", { cx: "12", cy: "12", r: "8" }),
|
|
1944
|
-
/* @__PURE__ */ a("path", { d: "M12 8v4.5" }),
|
|
1945
|
-
/* @__PURE__ */ a("path", { d: "M12 16h.01" })
|
|
1946
|
-
] }), ht = ({ className: e = "" }) => /* @__PURE__ */ a("span", { className: `make-ai-assistant__avatar ${e}`.trim(), "aria-hidden": "true", children: /* @__PURE__ */ a(ea, {}) }), ms = ({ src: e }) => e ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__user-avatar", "aria-hidden": "true", children: /* @__PURE__ */ a("img", { alt: "", src: e }) }) : null, hs = ({
|
|
2447
|
+
}, ft = ({ className: e = "" }) => /* @__PURE__ */ a("span", { className: `make-ai-assistant__avatar ${e}`.trim(), "aria-hidden": "true", children: /* @__PURE__ */ a(Ca, { "aria-hidden": "true" }) }), rn = ({ src: e }) => e ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__user-avatar", "aria-hidden": "true", children: /* @__PURE__ */ a("img", { alt: "", src: e }) }) : null, on = ({
|
|
1947
2448
|
userAvatarUrl: e,
|
|
1948
2449
|
userName: t
|
|
1949
2450
|
}) => {
|
|
1950
2451
|
const s = t?.trim();
|
|
1951
|
-
return !s && !e ? null : /* @__PURE__ */
|
|
2452
|
+
return !s && !e ? null : /* @__PURE__ */ u("div", { className: "make-ai-assistant__message-identity", children: [
|
|
1952
2453
|
s ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: s }) : null,
|
|
1953
|
-
/* @__PURE__ */ a(
|
|
2454
|
+
/* @__PURE__ */ a(rn, { src: e })
|
|
1954
2455
|
] });
|
|
1955
|
-
},
|
|
2456
|
+
}, wt = (e) => {
|
|
1956
2457
|
const t = e.trim();
|
|
1957
2458
|
if (!(!t.startsWith("|") || !t.endsWith("|")))
|
|
1958
2459
|
return t.slice(1, -1).split("|").map((s) => s.trim());
|
|
1959
|
-
},
|
|
1960
|
-
const s =
|
|
1961
|
-
if (!s || !
|
|
2460
|
+
}, cn = (e) => e.length > 0 && e.every((t) => /^:?-{3,}:?$/.test(t)), ln = (e, t) => {
|
|
2461
|
+
const s = wt(e[t] ?? ""), n = wt(e[t + 1] ?? "");
|
|
2462
|
+
if (!s || !n || s.length !== n.length || !cn(n))
|
|
1962
2463
|
return;
|
|
1963
2464
|
const i = [];
|
|
1964
2465
|
let c = t + 2;
|
|
1965
2466
|
for (; c < e.length; ) {
|
|
1966
|
-
const
|
|
1967
|
-
if (!
|
|
1968
|
-
i.push(
|
|
2467
|
+
const l = wt(e[c] ?? "");
|
|
2468
|
+
if (!l || l.length !== s.length) break;
|
|
2469
|
+
i.push(l), c += 1;
|
|
1969
2470
|
}
|
|
1970
2471
|
return { headers: s, lastIndex: c - 1, rows: i };
|
|
1971
|
-
},
|
|
1972
|
-
const t = [], s = [],
|
|
2472
|
+
}, dn = (e) => {
|
|
2473
|
+
const t = [], s = [], n = [], i = [], c = e.replace(/\r\n?/g, `
|
|
1973
2474
|
`).split(`
|
|
1974
|
-
`),
|
|
2475
|
+
`), l = () => {
|
|
1975
2476
|
const v = s.join(`
|
|
1976
2477
|
`).trim();
|
|
1977
2478
|
s.length = 0, v && t.push({ type: "paragraph", text: v });
|
|
1978
|
-
},
|
|
1979
|
-
|
|
1980
|
-
},
|
|
2479
|
+
}, m = () => {
|
|
2480
|
+
n.length && t.push({ type: "list", items: n.splice(0) });
|
|
2481
|
+
}, y = () => {
|
|
1981
2482
|
const v = i.join(`
|
|
1982
2483
|
`).trim();
|
|
1983
2484
|
i.length = 0, v && t.push({ type: "pre", text: v });
|
|
1984
2485
|
};
|
|
1985
2486
|
for (let v = 0; v < c.length; v += 1) {
|
|
1986
|
-
const
|
|
1987
|
-
if (!
|
|
1988
|
-
|
|
2487
|
+
const p = c[v] ?? "", A = p.trim();
|
|
2488
|
+
if (!A) {
|
|
2489
|
+
l(), m(), y();
|
|
1989
2490
|
continue;
|
|
1990
2491
|
}
|
|
1991
|
-
const
|
|
1992
|
-
if (
|
|
1993
|
-
|
|
2492
|
+
const C = ln(c, v);
|
|
2493
|
+
if (C) {
|
|
2494
|
+
l(), m(), y(), t.push({ headers: C.headers, rows: C.rows, type: "table" }), v = C.lastIndex;
|
|
1994
2495
|
continue;
|
|
1995
2496
|
}
|
|
1996
|
-
const
|
|
1997
|
-
if (
|
|
1998
|
-
|
|
1999
|
-
const
|
|
2000
|
-
|
|
2497
|
+
const S = /^(#{1,6})\s+(.+)$/.exec(A);
|
|
2498
|
+
if (S) {
|
|
2499
|
+
l(), m(), y();
|
|
2500
|
+
const U = (S[2] ?? "").replace(/\s+#+\s*$/, "").trim();
|
|
2501
|
+
U && t.push({
|
|
2001
2502
|
type: "heading",
|
|
2002
|
-
level:
|
|
2003
|
-
text:
|
|
2503
|
+
level: S[1]?.length,
|
|
2504
|
+
text: U
|
|
2004
2505
|
});
|
|
2005
2506
|
continue;
|
|
2006
2507
|
}
|
|
2007
|
-
if (/^\s*\|.+\|\s*$/.test(
|
|
2008
|
-
|
|
2508
|
+
if (/^\s*\|.+\|\s*$/.test(p)) {
|
|
2509
|
+
l(), m(), i.push(p.trim());
|
|
2009
2510
|
continue;
|
|
2010
2511
|
}
|
|
2011
|
-
const
|
|
2012
|
-
if (
|
|
2013
|
-
|
|
2512
|
+
const k = /^\s*[-*]\s+(.+)$/.exec(p);
|
|
2513
|
+
if (k) {
|
|
2514
|
+
l(), y(), n.push(k[1]?.trim() ?? "");
|
|
2014
2515
|
continue;
|
|
2015
2516
|
}
|
|
2016
|
-
|
|
2517
|
+
m(), y(), s.push(A);
|
|
2017
2518
|
}
|
|
2018
|
-
return
|
|
2019
|
-
},
|
|
2519
|
+
return l(), m(), y(), t;
|
|
2520
|
+
}, et = (e) => {
|
|
2020
2521
|
const t = [], s = /(\*\*[^*]+\*\*|`[^`]+`)/g;
|
|
2021
|
-
let
|
|
2522
|
+
let n = 0;
|
|
2022
2523
|
for (const i of e.matchAll(s)) {
|
|
2023
|
-
const c = i[0],
|
|
2024
|
-
|
|
2524
|
+
const c = i[0], l = i.index ?? 0;
|
|
2525
|
+
l > n && t.push(e.slice(n, l)), c.startsWith("**") ? t.push(/* @__PURE__ */ a("strong", { children: c.slice(2, -2) }, `${l}-strong`)) : t.push(/* @__PURE__ */ a("code", { children: c.slice(1, -1) }, `${l}-code`)), n = l + c.length;
|
|
2025
2526
|
}
|
|
2026
|
-
return
|
|
2027
|
-
},
|
|
2028
|
-
const t =
|
|
2029
|
-
return t.length ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble make-ai-assistant__assistant-text", children: t.map((s,
|
|
2527
|
+
return n < e.length && t.push(e.slice(n)), t;
|
|
2528
|
+
}, Gt = ({ content: e }) => {
|
|
2529
|
+
const t = dn(e);
|
|
2530
|
+
return t.length ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble make-ai-assistant__assistant-text", children: t.map((s, n) => {
|
|
2030
2531
|
if (s.type === "heading") {
|
|
2031
2532
|
const i = s.level <= 2 ? "h3" : "h4";
|
|
2032
2533
|
return /* @__PURE__ */ a(
|
|
2033
2534
|
i,
|
|
2034
2535
|
{
|
|
2035
2536
|
className: `make-ai-assistant__markdown-heading make-ai-assistant__markdown-heading--${s.level}`,
|
|
2036
|
-
children:
|
|
2537
|
+
children: et(s.text)
|
|
2037
2538
|
},
|
|
2038
|
-
`${
|
|
2539
|
+
`${n}-heading`
|
|
2039
2540
|
);
|
|
2040
2541
|
}
|
|
2041
|
-
return s.type === "paragraph" ? /* @__PURE__ */ a("p", { children:
|
|
2542
|
+
return s.type === "paragraph" ? /* @__PURE__ */ a("p", { children: et(s.text) }, `${n}-paragraph`) : s.type === "pre" ? /* @__PURE__ */ a("pre", { children: /* @__PURE__ */ a("code", { children: s.text }) }, `${n}-pre`) : s.type === "table" ? /* @__PURE__ */ a(
|
|
2042
2543
|
"div",
|
|
2043
2544
|
{
|
|
2044
2545
|
"aria-label": "表格内容,可横向滚动",
|
|
2045
2546
|
className: "make-ai-assistant__markdown-table-scroll",
|
|
2046
2547
|
role: "region",
|
|
2047
2548
|
tabIndex: 0,
|
|
2048
|
-
children: /* @__PURE__ */
|
|
2049
|
-
/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: s.headers.map((i, c) => /* @__PURE__ */ a("th", { scope: "col", children:
|
|
2050
|
-
/* @__PURE__ */ a("tbody", { children: s.rows.map((i, c) => /* @__PURE__ */ a("tr", { children: i.map((
|
|
2549
|
+
children: /* @__PURE__ */ u("table", { className: "make-ai-assistant__markdown-table", children: [
|
|
2550
|
+
/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: s.headers.map((i, c) => /* @__PURE__ */ a("th", { scope: "col", children: et(i) }, `${c}-${i}`)) }) }),
|
|
2551
|
+
/* @__PURE__ */ a("tbody", { children: s.rows.map((i, c) => /* @__PURE__ */ a("tr", { children: i.map((l, m) => /* @__PURE__ */ a("td", { children: et(l) }, `${m}-${l}`)) }, `${c}-${i.join("|")}`)) })
|
|
2051
2552
|
] })
|
|
2052
2553
|
},
|
|
2053
|
-
`${
|
|
2054
|
-
) : /* @__PURE__ */ a("ul", { children: s.items.map((i, c) => /* @__PURE__ */ a("li", { children:
|
|
2554
|
+
`${n}-table`
|
|
2555
|
+
) : /* @__PURE__ */ a("ul", { children: s.items.map((i, c) => /* @__PURE__ */ a("li", { children: et(i) }, `${c}-${i}`)) }, `${n}-list`);
|
|
2055
2556
|
}) }) : null;
|
|
2056
|
-
},
|
|
2057
|
-
/* @__PURE__ */ a(
|
|
2557
|
+
}, xa = ({ assistantName: e }) => /* @__PURE__ */ u("div", { className: "make-ai-assistant__message-identity", children: [
|
|
2558
|
+
/* @__PURE__ */ a(ft, { className: "make-ai-assistant__avatar--message" }),
|
|
2058
2559
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: e })
|
|
2059
|
-
] }),
|
|
2560
|
+
] }), Da = (e) => {
|
|
2060
2561
|
for (let t = e.messages.length - 1; t >= 0; t -= 1) {
|
|
2061
2562
|
const s = e.messages[t];
|
|
2062
2563
|
if (s.role === "assistant" && s.status === "streaming")
|
|
2063
2564
|
return s.id;
|
|
2064
2565
|
}
|
|
2065
|
-
},
|
|
2566
|
+
}, un = (e) => {
|
|
2066
2567
|
for (let t = e.messages.length - 1; t >= 0; t -= 1)
|
|
2067
2568
|
if (e.messages[t].role === "user") return t;
|
|
2068
2569
|
return -1;
|
|
2069
|
-
},
|
|
2070
|
-
const t =
|
|
2570
|
+
}, Pa = (e) => {
|
|
2571
|
+
const t = un(e);
|
|
2071
2572
|
if (!(t < 0))
|
|
2072
2573
|
for (let s = e.messages.length - 1; s > t; s -= 1) {
|
|
2073
|
-
const
|
|
2074
|
-
if (
|
|
2574
|
+
const n = e.messages[s];
|
|
2575
|
+
if (n.role === "assistant") return n.id;
|
|
2075
2576
|
}
|
|
2076
|
-
},
|
|
2577
|
+
}, mn = (e) => {
|
|
2077
2578
|
if (e.status === "idle")
|
|
2078
2579
|
for (let t = e.messages.length - 1; t >= 0; t -= 1) {
|
|
2079
2580
|
const s = e.messages[t];
|
|
2080
2581
|
if (s.role === "assistant" && s.status === "complete")
|
|
2081
2582
|
return s.id;
|
|
2082
2583
|
}
|
|
2083
|
-
},
|
|
2584
|
+
}, hn = (e) => {
|
|
2084
2585
|
for (let t = e.messages.length - 1; t >= 0; t -= 1) {
|
|
2085
2586
|
const s = e.messages[t];
|
|
2086
2587
|
if (s.role === "user") return s;
|
|
2087
2588
|
}
|
|
2088
|
-
},
|
|
2589
|
+
}, pn = (e, t) => {
|
|
2089
2590
|
const s = e.messages.findIndex(
|
|
2090
|
-
(
|
|
2591
|
+
(n) => n.id === t && n.role === "user"
|
|
2091
2592
|
);
|
|
2092
2593
|
return {
|
|
2093
2594
|
...e,
|
|
@@ -2096,43 +2597,43 @@ const mt = (e, t) => {
|
|
|
2096
2597
|
status: "streaming",
|
|
2097
2598
|
messages: s < 0 ? e.messages : e.messages.slice(0, s + 1)
|
|
2098
2599
|
};
|
|
2099
|
-
},
|
|
2600
|
+
}, fn = (e) => e.scrollHeight - e.scrollTop - e.clientHeight <= 48, Zt = (e = "smooth") => globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : e, It = (e, t) => {
|
|
2100
2601
|
typeof e.scrollTo == "function" ? e.scrollTo({ top: e.scrollHeight, behavior: t }) : e.scrollTop = e.scrollHeight;
|
|
2101
|
-
},
|
|
2602
|
+
}, Ua = ({
|
|
2102
2603
|
error: e,
|
|
2103
2604
|
onRetry: t
|
|
2104
|
-
}) => /* @__PURE__ */
|
|
2605
|
+
}) => /* @__PURE__ */ u(
|
|
2105
2606
|
"div",
|
|
2106
2607
|
{
|
|
2107
2608
|
className: "make-ai-assistant__message-status make-ai-assistant__message-status--error",
|
|
2108
2609
|
"data-error-presentation": "request-failed",
|
|
2109
2610
|
role: "alert",
|
|
2110
2611
|
children: [
|
|
2111
|
-
/* @__PURE__ */
|
|
2112
|
-
/* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-icon", "aria-hidden": "true", children: /* @__PURE__ */ a(
|
|
2612
|
+
/* @__PURE__ */ u("div", { className: "make-ai-assistant__message-status-header", children: [
|
|
2613
|
+
/* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-icon", "aria-hidden": "true", children: /* @__PURE__ */ a(bs, { "aria-hidden": "true" }) }),
|
|
2113
2614
|
/* @__PURE__ */ a("strong", { children: "请求未完成" })
|
|
2114
2615
|
] }),
|
|
2115
2616
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-message", children: e.message }),
|
|
2116
|
-
e.retryable && t ? /* @__PURE__ */
|
|
2617
|
+
e.retryable && t ? /* @__PURE__ */ u(
|
|
2117
2618
|
"button",
|
|
2118
2619
|
{
|
|
2119
2620
|
className: "make-ai-assistant__retry",
|
|
2120
2621
|
type: "button",
|
|
2121
2622
|
onClick: t,
|
|
2122
2623
|
children: [
|
|
2123
|
-
/* @__PURE__ */ a(
|
|
2624
|
+
/* @__PURE__ */ a(vt, { "aria-hidden": "true" }),
|
|
2124
2625
|
"重新发送"
|
|
2125
2626
|
]
|
|
2126
2627
|
}
|
|
2127
2628
|
) : null
|
|
2128
2629
|
]
|
|
2129
2630
|
}
|
|
2130
|
-
),
|
|
2631
|
+
), vn = ({
|
|
2131
2632
|
error: e,
|
|
2132
2633
|
onRetry: t
|
|
2133
2634
|
}) => {
|
|
2134
|
-
const s =
|
|
2135
|
-
return /* @__PURE__ */
|
|
2635
|
+
const s = sn(e);
|
|
2636
|
+
return /* @__PURE__ */ u(
|
|
2136
2637
|
"section",
|
|
2137
2638
|
{
|
|
2138
2639
|
"aria-live": "assertive",
|
|
@@ -2140,23 +2641,20 @@ const mt = (e, t) => {
|
|
|
2140
2641
|
"data-load-failure-kind": s.kind,
|
|
2141
2642
|
role: "alert",
|
|
2142
2643
|
children: [
|
|
2143
|
-
/* @__PURE__ */ a("span", { className: "make-ai-assistant__load-failure-icon", "aria-hidden": "true", children: /* @__PURE__ */
|
|
2144
|
-
|
|
2145
|
-
/* @__PURE__ */ a("path", { d: "m9.2 14.8 5.6-5.6M9.2 9.2l5.6 5.6" })
|
|
2146
|
-
] }) }),
|
|
2147
|
-
/* @__PURE__ */ l("div", { className: "make-ai-assistant__load-failure-copy", children: [
|
|
2644
|
+
/* @__PURE__ */ a("span", { className: "make-ai-assistant__load-failure-icon", "aria-hidden": "true", children: /* @__PURE__ */ a(_s, { "aria-hidden": "true" }) }),
|
|
2645
|
+
/* @__PURE__ */ u("div", { className: "make-ai-assistant__load-failure-copy", children: [
|
|
2148
2646
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__load-failure-label", children: s.label }),
|
|
2149
2647
|
/* @__PURE__ */ a("h3", { children: s.title }),
|
|
2150
2648
|
/* @__PURE__ */ a("p", { children: s.description })
|
|
2151
2649
|
] }),
|
|
2152
|
-
/* @__PURE__ */
|
|
2650
|
+
/* @__PURE__ */ u(
|
|
2153
2651
|
"button",
|
|
2154
2652
|
{
|
|
2155
2653
|
className: "make-ai-assistant__retry make-ai-assistant__retry--primary",
|
|
2156
2654
|
type: "button",
|
|
2157
2655
|
onClick: t,
|
|
2158
2656
|
children: [
|
|
2159
|
-
/* @__PURE__ */ a(
|
|
2657
|
+
/* @__PURE__ */ a(vt, { "aria-hidden": "true" }),
|
|
2160
2658
|
s.actionLabel
|
|
2161
2659
|
]
|
|
2162
2660
|
}
|
|
@@ -2164,24 +2662,24 @@ const mt = (e, t) => {
|
|
|
2164
2662
|
]
|
|
2165
2663
|
}
|
|
2166
2664
|
);
|
|
2167
|
-
},
|
|
2665
|
+
}, Fa = ({
|
|
2168
2666
|
active: e,
|
|
2169
2667
|
steps: t
|
|
2170
2668
|
}) => {
|
|
2171
|
-
const [s,
|
|
2669
|
+
const [s, n] = $(!1);
|
|
2172
2670
|
if (!e || !t?.length) return null;
|
|
2173
2671
|
const i = t[t.length - 1] ?? "处理中";
|
|
2174
|
-
return /* @__PURE__ */
|
|
2672
|
+
return /* @__PURE__ */ u(
|
|
2175
2673
|
"details",
|
|
2176
2674
|
{
|
|
2177
2675
|
className: "make-ai-assistant__process",
|
|
2178
2676
|
open: s,
|
|
2179
|
-
onToggle: (c) =>
|
|
2677
|
+
onToggle: (c) => n(c.currentTarget.open),
|
|
2180
2678
|
children: [
|
|
2181
|
-
/* @__PURE__ */
|
|
2182
|
-
/* @__PURE__ */
|
|
2679
|
+
/* @__PURE__ */ u("summary", { "aria-label": `查看处理过程,共 ${t.length} 步`, children: [
|
|
2680
|
+
/* @__PURE__ */ u("span", { className: "make-ai-assistant__process-summary", children: [
|
|
2183
2681
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__process-indicator", "aria-hidden": "true" }),
|
|
2184
|
-
/* @__PURE__ */
|
|
2682
|
+
/* @__PURE__ */ u("span", { className: "make-ai-assistant__process-copy", children: [
|
|
2185
2683
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__process-title", children: "处理过程" }),
|
|
2186
2684
|
/* @__PURE__ */ a(
|
|
2187
2685
|
"span",
|
|
@@ -2193,31 +2691,31 @@ const mt = (e, t) => {
|
|
|
2193
2691
|
)
|
|
2194
2692
|
] })
|
|
2195
2693
|
] }),
|
|
2196
|
-
/* @__PURE__ */
|
|
2694
|
+
/* @__PURE__ */ u("span", { className: "make-ai-assistant__process-count", children: [
|
|
2197
2695
|
t.length,
|
|
2198
2696
|
" 步"
|
|
2199
2697
|
] })
|
|
2200
2698
|
] }),
|
|
2201
|
-
/* @__PURE__ */ a("ol", { children: t.map((c,
|
|
2699
|
+
/* @__PURE__ */ a("ol", { children: t.map((c, l) => /* @__PURE__ */ u(
|
|
2202
2700
|
"li",
|
|
2203
2701
|
{
|
|
2204
|
-
"data-step-active":
|
|
2702
|
+
"data-step-active": l === t.length - 1 ? !0 : void 0,
|
|
2205
2703
|
children: [
|
|
2206
2704
|
/* @__PURE__ */ a("span", { "aria-hidden": "true" }),
|
|
2207
2705
|
/* @__PURE__ */ a("span", { children: c })
|
|
2208
2706
|
]
|
|
2209
2707
|
},
|
|
2210
|
-
`${
|
|
2708
|
+
`${l}-${c}`
|
|
2211
2709
|
)) })
|
|
2212
2710
|
]
|
|
2213
2711
|
}
|
|
2214
2712
|
);
|
|
2215
|
-
},
|
|
2713
|
+
}, yn = ({
|
|
2216
2714
|
copyFeedback: e,
|
|
2217
2715
|
feedback: t,
|
|
2218
2716
|
onCopy: s,
|
|
2219
|
-
onRegenerate:
|
|
2220
|
-
}) => !t && !s && !
|
|
2717
|
+
onRegenerate: n
|
|
2718
|
+
}) => !t && !s && !n ? null : /* @__PURE__ */ u("div", { className: "make-ai-assistant__reply-actions", "aria-label": "回复操作", children: [
|
|
2221
2719
|
s ? /* @__PURE__ */ a(
|
|
2222
2720
|
"button",
|
|
2223
2721
|
{
|
|
@@ -2227,7 +2725,7 @@ const mt = (e, t) => {
|
|
|
2227
2725
|
type: "button",
|
|
2228
2726
|
onClick: s,
|
|
2229
2727
|
children: /* @__PURE__ */ a(
|
|
2230
|
-
|
|
2728
|
+
ws,
|
|
2231
2729
|
{
|
|
2232
2730
|
"aria-hidden": "true",
|
|
2233
2731
|
className: "make-ai-assistant__reply-copy-icon"
|
|
@@ -2236,15 +2734,15 @@ const mt = (e, t) => {
|
|
|
2236
2734
|
}
|
|
2237
2735
|
) : null,
|
|
2238
2736
|
t,
|
|
2239
|
-
|
|
2737
|
+
n ? /* @__PURE__ */ a(
|
|
2240
2738
|
"button",
|
|
2241
2739
|
{
|
|
2242
2740
|
"aria-label": "重新生成",
|
|
2243
2741
|
className: "make-ai-assistant__reply-action make-ai-assistant__reply-regenerate",
|
|
2244
2742
|
"data-tooltip": "重新生成",
|
|
2245
2743
|
type: "button",
|
|
2246
|
-
onClick:
|
|
2247
|
-
children: /* @__PURE__ */ a(
|
|
2744
|
+
onClick: n,
|
|
2745
|
+
children: /* @__PURE__ */ a(vt, { "aria-hidden": "true" })
|
|
2248
2746
|
}
|
|
2249
2747
|
) : null,
|
|
2250
2748
|
e ? /* @__PURE__ */ a(
|
|
@@ -2256,217 +2754,217 @@ const mt = (e, t) => {
|
|
|
2256
2754
|
children: e.message
|
|
2257
2755
|
}
|
|
2258
2756
|
) : null
|
|
2259
|
-
] }),
|
|
2757
|
+
] }), Jt = ({
|
|
2260
2758
|
assistantName: e,
|
|
2261
2759
|
error: t,
|
|
2262
2760
|
onRetry: s,
|
|
2263
|
-
progress:
|
|
2761
|
+
progress: n
|
|
2264
2762
|
}) => {
|
|
2265
2763
|
const i = t ? "error" : "progress";
|
|
2266
|
-
return t?.message ??
|
|
2764
|
+
return t?.message ?? n?.message ? /* @__PURE__ */ a(
|
|
2267
2765
|
"article",
|
|
2268
2766
|
{
|
|
2269
2767
|
"aria-label": `${e}的${i === "error" ? "错误消息" : "状态消息"}`,
|
|
2270
2768
|
className: `make-ai-assistant__message make-ai-assistant__message--assistant make-ai-assistant__message--${i}`,
|
|
2271
2769
|
"data-message-role": "assistant",
|
|
2272
2770
|
"data-message-state": i,
|
|
2273
|
-
children: /* @__PURE__ */
|
|
2274
|
-
/* @__PURE__ */ a(
|
|
2275
|
-
/* @__PURE__ */ a("div", { className: "make-ai-assistant__message-stack", children: t ? /* @__PURE__ */ a(
|
|
2771
|
+
children: /* @__PURE__ */ u("div", { className: "make-ai-assistant__message-turn", children: [
|
|
2772
|
+
/* @__PURE__ */ a(xa, { assistantName: e }),
|
|
2773
|
+
/* @__PURE__ */ a("div", { className: "make-ai-assistant__message-stack", children: t ? /* @__PURE__ */ a(Ua, { error: t, onRetry: s }) : /* @__PURE__ */ a(Fa, { active: !0, steps: n?.steps }) })
|
|
2276
2774
|
] })
|
|
2277
2775
|
}
|
|
2278
2776
|
) : null;
|
|
2279
|
-
},
|
|
2280
|
-
const
|
|
2281
|
-
let
|
|
2282
|
-
return e.messages.map((
|
|
2283
|
-
if (
|
|
2777
|
+
}, kn = (e, t, s, n, i, c, l, m, y, v, p, A, C, S, k, U) => {
|
|
2778
|
+
const L = Pa(e), H = Da(e), _ = mn(e);
|
|
2779
|
+
let h;
|
|
2780
|
+
return e.messages.map((r) => {
|
|
2781
|
+
if (r.intermediate) return /* @__PURE__ */ u("details", { className: "make-ai-assistant__process", children: [
|
|
2284
2782
|
/* @__PURE__ */ a("summary", { children: "处理过程" }),
|
|
2285
|
-
/* @__PURE__ */ a(
|
|
2286
|
-
] },
|
|
2287
|
-
const b =
|
|
2288
|
-
b || (
|
|
2289
|
-
const
|
|
2783
|
+
/* @__PURE__ */ a(Gt, { content: r.content })
|
|
2784
|
+
] }, r.id);
|
|
2785
|
+
const b = r.role === "assistant", M = h;
|
|
2786
|
+
b || (h = r);
|
|
2787
|
+
const W = r.id === H, N = r.id === L ? e.error : void 0, X = r.error ?? N, Q = !b && !!(y?.trim() || v), ie = b ? l : y?.trim() || "用户", Z = b && r.status === "complete" && !X && (r.content.trim() || r.id === _), ue = !!(k && U?.features?.feedback && b && r.persistent), ve = Z || ue;
|
|
2290
2788
|
return /* @__PURE__ */ a(
|
|
2291
2789
|
"article",
|
|
2292
2790
|
{
|
|
2293
|
-
"aria-label": `${
|
|
2294
|
-
className: `make-ai-assistant__message make-ai-assistant__message--${
|
|
2295
|
-
"data-message-role":
|
|
2296
|
-
"data-message-state":
|
|
2297
|
-
"data-message-status":
|
|
2298
|
-
"data-message-has-identity": b ||
|
|
2299
|
-
children: /* @__PURE__ */
|
|
2300
|
-
b ? /* @__PURE__ */ a(
|
|
2301
|
-
/* @__PURE__ */
|
|
2302
|
-
b &&
|
|
2303
|
-
|
|
2791
|
+
"aria-label": `${ie}的消息`,
|
|
2792
|
+
className: `make-ai-assistant__message make-ai-assistant__message--${r.role}`,
|
|
2793
|
+
"data-message-role": r.role,
|
|
2794
|
+
"data-message-state": X ? "error" : void 0,
|
|
2795
|
+
"data-message-status": r.status,
|
|
2796
|
+
"data-message-has-identity": b || Q ? !0 : void 0,
|
|
2797
|
+
children: /* @__PURE__ */ u("div", { className: "make-ai-assistant__message-turn", children: [
|
|
2798
|
+
b ? /* @__PURE__ */ a(xa, { assistantName: l }) : Q ? /* @__PURE__ */ a(on, { userAvatarUrl: v, userName: y }) : null,
|
|
2799
|
+
/* @__PURE__ */ u("div", { className: "make-ai-assistant__message-stack", children: [
|
|
2800
|
+
b && r.responseId && e.responses?.[r.responseId]?.status === "cancelled" ? /* @__PURE__ */ a("p", { className: "make-ai-assistant__response-status", role: "status", children: "已停止生成" }) : null,
|
|
2801
|
+
r.content ? b ? /* @__PURE__ */ a(Gt, { content: r.content }) : /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble", children: r.content }) : r.status === "streaming" ? /* @__PURE__ */ u("div", { className: "make-ai-assistant__typing", "aria-label": `${l}正在思考`, children: [
|
|
2304
2802
|
/* @__PURE__ */ a("span", {}),
|
|
2305
2803
|
/* @__PURE__ */ a("span", {}),
|
|
2306
2804
|
/* @__PURE__ */ a("span", {})
|
|
2307
2805
|
] }) : null,
|
|
2308
2806
|
b ? /* @__PURE__ */ a(
|
|
2309
|
-
|
|
2807
|
+
Fa,
|
|
2310
2808
|
{
|
|
2311
|
-
active:
|
|
2312
|
-
steps:
|
|
2809
|
+
active: W && e.status === "streaming",
|
|
2810
|
+
steps: r.progressSteps
|
|
2313
2811
|
}
|
|
2314
2812
|
) : null,
|
|
2315
|
-
|
|
2316
|
-
|
|
2813
|
+
X ? /* @__PURE__ */ a(
|
|
2814
|
+
Ua,
|
|
2317
2815
|
{
|
|
2318
|
-
error:
|
|
2319
|
-
onRetry:
|
|
2816
|
+
error: X,
|
|
2817
|
+
onRetry: N ? m : void 0
|
|
2320
2818
|
}
|
|
2321
2819
|
) : null,
|
|
2322
|
-
|
|
2323
|
-
|
|
2820
|
+
r.artifacts.map((Me) => /* @__PURE__ */ a(
|
|
2821
|
+
Ga,
|
|
2324
2822
|
{
|
|
2325
|
-
artifact:
|
|
2823
|
+
artifact: Me,
|
|
2326
2824
|
context: t,
|
|
2327
2825
|
onAction: i,
|
|
2328
2826
|
onActionError: c,
|
|
2329
2827
|
registry: s,
|
|
2330
|
-
theme:
|
|
2828
|
+
theme: n
|
|
2331
2829
|
},
|
|
2332
|
-
|
|
2830
|
+
Me.id
|
|
2333
2831
|
)),
|
|
2334
|
-
|
|
2832
|
+
k && U && e.threadId ? /* @__PURE__ */ a(Hs, { message: r, context: t, transport: U, chatId: e.threadId }) : null,
|
|
2335
2833
|
ve ? /* @__PURE__ */ a(
|
|
2336
|
-
|
|
2834
|
+
yn,
|
|
2337
2835
|
{
|
|
2338
|
-
copyFeedback:
|
|
2339
|
-
message:
|
|
2340
|
-
status:
|
|
2836
|
+
copyFeedback: p?.messageId === r.id ? {
|
|
2837
|
+
message: p.message,
|
|
2838
|
+
status: p.status
|
|
2341
2839
|
} : void 0,
|
|
2342
|
-
onCopy:
|
|
2343
|
-
feedback:
|
|
2344
|
-
onRegenerate:
|
|
2345
|
-
userMessage:
|
|
2346
|
-
assistantMessage:
|
|
2840
|
+
onCopy: r.content.trim() ? () => C(r.id, r.content) : void 0,
|
|
2841
|
+
feedback: k && ue ? /* @__PURE__ */ a(Us, { message: r, manager: k }) : void 0,
|
|
2842
|
+
onRegenerate: A && r.id === _ && M ? () => S({
|
|
2843
|
+
userMessage: M,
|
|
2844
|
+
assistantMessage: r
|
|
2347
2845
|
}) : void 0
|
|
2348
2846
|
}
|
|
2349
2847
|
) : null
|
|
2350
2848
|
] })
|
|
2351
2849
|
] })
|
|
2352
2850
|
},
|
|
2353
|
-
`${e.threadId ?? "local"}:${
|
|
2851
|
+
`${e.threadId ?? "local"}:${r.id}`
|
|
2354
2852
|
);
|
|
2355
2853
|
});
|
|
2356
2854
|
};
|
|
2357
|
-
function
|
|
2855
|
+
function Ha({
|
|
2358
2856
|
assistantName: e = "AI 助手",
|
|
2359
2857
|
brandName: t,
|
|
2360
2858
|
context: s,
|
|
2361
|
-
onAction:
|
|
2859
|
+
onAction: n,
|
|
2362
2860
|
onActionError: i,
|
|
2363
2861
|
onClose: c,
|
|
2364
|
-
onNewConversation:
|
|
2365
|
-
onToggleFullscreen:
|
|
2366
|
-
headerHeight:
|
|
2862
|
+
onNewConversation: l,
|
|
2863
|
+
onToggleFullscreen: m,
|
|
2864
|
+
headerHeight: y,
|
|
2367
2865
|
isFullscreen: v = !1,
|
|
2368
|
-
registry:
|
|
2369
|
-
suggestions:
|
|
2370
|
-
title:
|
|
2371
|
-
theme:
|
|
2372
|
-
transport:
|
|
2373
|
-
userAvatarUrl:
|
|
2374
|
-
userName:
|
|
2375
|
-
visible:
|
|
2866
|
+
registry: p,
|
|
2867
|
+
suggestions: A,
|
|
2868
|
+
title: C,
|
|
2869
|
+
theme: S,
|
|
2870
|
+
transport: k,
|
|
2871
|
+
userAvatarUrl: U,
|
|
2872
|
+
userName: L,
|
|
2873
|
+
visible: H
|
|
2376
2874
|
}) {
|
|
2377
|
-
const
|
|
2378
|
-
...
|
|
2875
|
+
const _ = xs(s, k), h = Vs(s, k, _), r = za(t, C), b = tn(y), M = Mt(S), W = M || b ? {
|
|
2876
|
+
...M,
|
|
2379
2877
|
...b ? { "--make-ai-internal-header-height": b } : {}
|
|
2380
|
-
} : void 0, [
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
}, [ve,
|
|
2384
|
-
const [
|
|
2385
|
-
|
|
2386
|
-
const [
|
|
2387
|
-
|
|
2388
|
-
const
|
|
2389
|
-
|
|
2390
|
-
Math.max(
|
|
2391
|
-
|
|
2878
|
+
} : void 0, [N, X] = $(""), [Q, ie] = $(!1), [Z, ue] = $(!1), ve = _.enabled ? k.scopeKey?.(s) ?? s.app.id : "";
|
|
2879
|
+
At(() => {
|
|
2880
|
+
_.enabled && X("");
|
|
2881
|
+
}, [ve, _.enabled]);
|
|
2882
|
+
const [Me, Be] = $(fe), O = _.enabled ? _.state : Me, V = _.enabled ? _.setState : Be, F = D(O);
|
|
2883
|
+
F.current = O;
|
|
2884
|
+
const [Y, oe] = $(void 0), [ge, me] = $(void 0), [Te, P] = $(0), [ae, ee] = $(() => k.loadConversation ? "loading" : "ready"), te = _.enabled ? _.loading && !O.messages.length ? "loading" : "ready" : ae, [Ve, Ke] = $(void 0), [at, ce] = $(!1), G = D(void 0), le = D(void 0), Ne = D(0), Ee = D(null), Ae = D(null), ze = D(null), xe = D(null), We = D(null), Xe = D(null), ye = D(!0), st = D(s.app.id), nt = D(H), it = Ka();
|
|
2885
|
+
At(() => {
|
|
2886
|
+
const f = ze.current;
|
|
2887
|
+
f && (f.style.height = "auto", f.style.height = `${Math.min(
|
|
2888
|
+
Math.max(f.scrollHeight, Js),
|
|
2889
|
+
Ys
|
|
2392
2890
|
)}px`);
|
|
2393
|
-
}, [
|
|
2394
|
-
const
|
|
2395
|
-
() =>
|
|
2396
|
-
[
|
|
2397
|
-
),
|
|
2398
|
-
() =>
|
|
2399
|
-
[
|
|
2400
|
-
), De = (
|
|
2401
|
-
const
|
|
2402
|
-
return !
|
|
2891
|
+
}, [N]);
|
|
2892
|
+
const rt = Ft(
|
|
2893
|
+
() => p ?? is(),
|
|
2894
|
+
[p]
|
|
2895
|
+
), ot = Ft(
|
|
2896
|
+
() => Qs(A),
|
|
2897
|
+
[A]
|
|
2898
|
+
), De = (f) => {
|
|
2899
|
+
const B = G.current, K = le.current?.iterator;
|
|
2900
|
+
return !B && !K ? !1 : (Ne.current += 1, G.current = void 0, le.current = void 0, console.info("[make-ai-assistant] local run cancellation requested", { reason: f }), B?.abort(), Xt(K), !0);
|
|
2403
2901
|
};
|
|
2404
|
-
|
|
2902
|
+
ne(() => () => {
|
|
2405
2903
|
De("unmount");
|
|
2406
|
-
}, []),
|
|
2407
|
-
if (
|
|
2408
|
-
const
|
|
2409
|
-
if (
|
|
2410
|
-
|
|
2904
|
+
}, []), ne(() => {
|
|
2905
|
+
if (_.enabled) return;
|
|
2906
|
+
const f = k.loadConversation, B = st.current !== s.app.id;
|
|
2907
|
+
if (st.current = s.app.id, De("reinitialize"), B && (X(""), ye.current = !0), oe(void 0), me(void 0), ce(!1), V(fe()), !f) {
|
|
2908
|
+
Ke(void 0), ee("ready");
|
|
2411
2909
|
return;
|
|
2412
2910
|
}
|
|
2413
|
-
const
|
|
2414
|
-
return
|
|
2911
|
+
const K = new AbortController();
|
|
2912
|
+
return Ke(void 0), ee("loading"), console.info("[make-ai-assistant] conversation load start", {
|
|
2415
2913
|
appId: s.app.id
|
|
2416
|
-
}),
|
|
2417
|
-
|
|
2914
|
+
}), f.call(k, s, { signal: K.signal }).then((se) => {
|
|
2915
|
+
K.signal.aborted || (V(fe(se)), ee("ready"), console.info("[make-ai-assistant] conversation load success", {
|
|
2418
2916
|
appId: s.app.id,
|
|
2419
|
-
messageCount:
|
|
2917
|
+
messageCount: se.messages.length
|
|
2420
2918
|
}));
|
|
2421
|
-
}).catch((
|
|
2422
|
-
|
|
2919
|
+
}).catch((se) => {
|
|
2920
|
+
K.signal.aborted || (console.error("[make-ai-assistant] conversation load failed", {
|
|
2423
2921
|
appId: s.app.id,
|
|
2424
|
-
errorType:
|
|
2425
|
-
}),
|
|
2426
|
-
}), () =>
|
|
2427
|
-
}, [s.app.id, Te,
|
|
2428
|
-
const
|
|
2429
|
-
if (!
|
|
2922
|
+
errorType: se instanceof Error ? se.name : typeof se
|
|
2923
|
+
}), Ke(se), ee("error"));
|
|
2924
|
+
}), () => K.abort();
|
|
2925
|
+
}, [s.app.id, Te, k, _.enabled]), ne(() => {
|
|
2926
|
+
const f = Ae.current;
|
|
2927
|
+
if (!f || !ye.current) return;
|
|
2430
2928
|
ce(!1);
|
|
2431
|
-
const
|
|
2432
|
-
if (!
|
|
2433
|
-
const
|
|
2434
|
-
|
|
2929
|
+
const B = requestAnimationFrame(() => {
|
|
2930
|
+
if (!ye.current) return;
|
|
2931
|
+
const K = O.status === "streaming" || globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
|
|
2932
|
+
It(f, K);
|
|
2435
2933
|
});
|
|
2436
|
-
return () => cancelAnimationFrame(
|
|
2437
|
-
}, [
|
|
2438
|
-
|
|
2439
|
-
}, [
|
|
2440
|
-
const
|
|
2441
|
-
if (
|
|
2442
|
-
const
|
|
2443
|
-
const
|
|
2444
|
-
if (
|
|
2934
|
+
return () => cancelAnimationFrame(B);
|
|
2935
|
+
}, [O.messages, O.progress, O.status]), ne(() => {
|
|
2936
|
+
H || (ie(!1), ue(!1));
|
|
2937
|
+
}, [H]), ne(() => {
|
|
2938
|
+
const f = H && !nt.current;
|
|
2939
|
+
if (nt.current = H, !f) return;
|
|
2940
|
+
const B = requestAnimationFrame(() => {
|
|
2941
|
+
const K = Ae.current;
|
|
2942
|
+
if (K && ye.current) {
|
|
2445
2943
|
ce(!1);
|
|
2446
|
-
const
|
|
2447
|
-
|
|
2448
|
-
} else
|
|
2449
|
-
const
|
|
2450
|
-
(
|
|
2944
|
+
const Ze = F.current.status === "streaming" ? "auto" : Zt();
|
|
2945
|
+
It(K, Ze);
|
|
2946
|
+
} else K && ce(F.current.messages.length > 0);
|
|
2947
|
+
const se = ze.current;
|
|
2948
|
+
(se && !se.disabled ? se : Xe.current ?? Ee.current?.querySelector("button:not(:disabled)"))?.focus();
|
|
2451
2949
|
});
|
|
2452
|
-
return () => cancelAnimationFrame(
|
|
2453
|
-
}, [
|
|
2454
|
-
const
|
|
2455
|
-
const
|
|
2456
|
-
if (!
|
|
2457
|
-
const
|
|
2458
|
-
|
|
2459
|
-
},
|
|
2460
|
-
const
|
|
2461
|
-
if (!
|
|
2462
|
-
|
|
2463
|
-
const
|
|
2464
|
-
|
|
2465
|
-
},
|
|
2466
|
-
const
|
|
2467
|
-
if (!
|
|
2468
|
-
if (
|
|
2469
|
-
|
|
2950
|
+
return () => cancelAnimationFrame(B);
|
|
2951
|
+
}, [H]);
|
|
2952
|
+
const Ge = () => {
|
|
2953
|
+
const f = Ae.current;
|
|
2954
|
+
if (!f) return;
|
|
2955
|
+
const B = fn(f);
|
|
2956
|
+
ye.current = B, ce(!B && F.current.messages.length > 0);
|
|
2957
|
+
}, $e = () => {
|
|
2958
|
+
const f = Ae.current;
|
|
2959
|
+
if (!f) return;
|
|
2960
|
+
ye.current = !0, ce(!1);
|
|
2961
|
+
const B = Zt();
|
|
2962
|
+
It(f, B);
|
|
2963
|
+
}, o = async (f, B) => {
|
|
2964
|
+
const K = f.trim(), se = F.current, _e = B?.regenerateFrom, Ze = k.regenerate;
|
|
2965
|
+
if (!K || te !== "ready" || se.status === "streaming" || G.current || _e && !Ze) return;
|
|
2966
|
+
if (ht(
|
|
2967
|
+
K,
|
|
2470
2968
|
de.messageCharacters
|
|
2471
2969
|
) > de.messageCharacters) {
|
|
2472
2970
|
oe(
|
|
@@ -2474,238 +2972,238 @@ function oa({
|
|
|
2474
2972
|
);
|
|
2475
2973
|
return;
|
|
2476
2974
|
}
|
|
2477
|
-
const
|
|
2478
|
-
id:
|
|
2479
|
-
content:
|
|
2480
|
-
},
|
|
2481
|
-
Ne.current = Ue,
|
|
2975
|
+
const lt = {
|
|
2976
|
+
id: _e?.userMessage.id ?? Xs("user"),
|
|
2977
|
+
content: K
|
|
2978
|
+
}, dt = _e ? pn(se, _e.userMessage.id) : ta(se, lt), ut = new AbortController(), Ue = Ne.current + 1;
|
|
2979
|
+
Ne.current = Ue, G.current = ut, oe(void 0), me(void 0), ce(!ye.current && se.messages.length > 0), _e || X(""), V(dt);
|
|
2482
2980
|
try {
|
|
2483
|
-
let
|
|
2484
|
-
const
|
|
2981
|
+
let Ce = !1, re, $t = 0, St = 0, Rt = 0, yt = 0, Je = 0;
|
|
2982
|
+
const Ye = /* @__PURE__ */ new Map(), Lt = /* @__PURE__ */ new Set(), zt = /* @__PURE__ */ new Set(
|
|
2485
2983
|
[
|
|
2486
|
-
...
|
|
2487
|
-
|
|
2984
|
+
...dt.messages.map((mt) => mt.id),
|
|
2985
|
+
lt.id
|
|
2488
2986
|
]
|
|
2489
|
-
),
|
|
2490
|
-
let
|
|
2491
|
-
if (
|
|
2492
|
-
if (!
|
|
2493
|
-
throw new
|
|
2494
|
-
|
|
2495
|
-
threadId:
|
|
2496
|
-
message:
|
|
2987
|
+
), Qe = /* @__PURE__ */ new Set(), xt = Xa(rt), Dt = { signal: ut.signal };
|
|
2988
|
+
let kt;
|
|
2989
|
+
if (_e) {
|
|
2990
|
+
if (!Ze)
|
|
2991
|
+
throw new J("当前 AI 助手不支持重新生成");
|
|
2992
|
+
kt = Ze({
|
|
2993
|
+
threadId: dt.threadId,
|
|
2994
|
+
message: lt,
|
|
2497
2995
|
assistantMessage: {
|
|
2498
|
-
id:
|
|
2499
|
-
content:
|
|
2996
|
+
id: _e.assistantMessage.id,
|
|
2997
|
+
content: _e.assistantMessage.content
|
|
2500
2998
|
},
|
|
2501
2999
|
context: s,
|
|
2502
|
-
capabilities:
|
|
2503
|
-
},
|
|
3000
|
+
capabilities: xt
|
|
3001
|
+
}, Dt);
|
|
2504
3002
|
} else
|
|
2505
|
-
|
|
3003
|
+
kt = k.run(
|
|
2506
3004
|
{
|
|
2507
|
-
threadId:
|
|
2508
|
-
message:
|
|
3005
|
+
threadId: dt.threadId,
|
|
3006
|
+
message: lt,
|
|
2509
3007
|
context: s,
|
|
2510
|
-
capabilities:
|
|
3008
|
+
capabilities: xt
|
|
2511
3009
|
},
|
|
2512
|
-
|
|
3010
|
+
Dt
|
|
2513
3011
|
);
|
|
2514
|
-
const
|
|
2515
|
-
for (le.current = { iterator:
|
|
2516
|
-
const
|
|
2517
|
-
if (Ne.current !== Ue ||
|
|
2518
|
-
let
|
|
3012
|
+
const Pt = kt[Symbol.asyncIterator]();
|
|
3013
|
+
for (le.current = { iterator: Pt, requestVersion: Ue }; ; ) {
|
|
3014
|
+
const mt = await Pt.next();
|
|
3015
|
+
if (Ne.current !== Ue || mt.done) break;
|
|
3016
|
+
let x;
|
|
2519
3017
|
try {
|
|
2520
|
-
|
|
3018
|
+
x = ea(mt.value);
|
|
2521
3019
|
} catch (pe) {
|
|
2522
|
-
throw new
|
|
3020
|
+
throw new J(
|
|
2523
3021
|
pe instanceof Error ? pe.message : "Invalid assistant event"
|
|
2524
3022
|
);
|
|
2525
3023
|
}
|
|
2526
|
-
if (
|
|
2527
|
-
if (
|
|
2528
|
-
throw new
|
|
2529
|
-
if (
|
|
2530
|
-
throw new
|
|
2531
|
-
if (
|
|
2532
|
-
throw new
|
|
2533
|
-
|
|
3024
|
+
if (x.type === "message.start") {
|
|
3025
|
+
if (re !== void 0 && re !== x.runId)
|
|
3026
|
+
throw new J("AI 助手响应 run id 不一致");
|
|
3027
|
+
if (re ??= x.runId, St += 1, St > de.assistantMessagesPerRun)
|
|
3028
|
+
throw new J("AI 助手单次响应消息数量超过限制");
|
|
3029
|
+
if (zt.has(x.messageId))
|
|
3030
|
+
throw new J("AI 助手响应包含重复的 message id");
|
|
3031
|
+
zt.add(x.messageId), Qe.add(x.messageId), Ye.set(x.messageId, 0);
|
|
2534
3032
|
}
|
|
2535
|
-
if (
|
|
2536
|
-
if (!
|
|
2537
|
-
throw new
|
|
2538
|
-
const pe =
|
|
2539
|
-
|
|
2540
|
-
de.messageCharacters -
|
|
3033
|
+
if (x.type === "message.delta") {
|
|
3034
|
+
if (!Qe.has(x.messageId))
|
|
3035
|
+
throw new J("AI 助手响应事件顺序无效");
|
|
3036
|
+
const pe = Ye.get(x.messageId) ?? 0, Fe = ht(
|
|
3037
|
+
x.delta,
|
|
3038
|
+
de.messageCharacters - Je
|
|
2541
3039
|
);
|
|
2542
|
-
if (
|
|
2543
|
-
throw new
|
|
2544
|
-
|
|
2545
|
-
|
|
3040
|
+
if (Je + Fe > de.messageCharacters)
|
|
3041
|
+
throw new J("AI 助手响应文本超过大小限制");
|
|
3042
|
+
Je += Fe, Ye.set(
|
|
3043
|
+
x.messageId,
|
|
2546
3044
|
pe + Fe
|
|
2547
3045
|
);
|
|
2548
3046
|
}
|
|
2549
|
-
if (
|
|
2550
|
-
if (!
|
|
2551
|
-
throw new
|
|
2552
|
-
const pe =
|
|
2553
|
-
|
|
3047
|
+
if (x.type === "message.replace") {
|
|
3048
|
+
if (!Qe.has(x.messageId))
|
|
3049
|
+
throw new J("AI 助手响应事件顺序无效");
|
|
3050
|
+
const pe = Ye.get(x.messageId) ?? 0, Fe = ht(
|
|
3051
|
+
x.content,
|
|
2554
3052
|
de.messageCharacters
|
|
2555
|
-
),
|
|
2556
|
-
if (
|
|
2557
|
-
throw new
|
|
2558
|
-
|
|
3053
|
+
), Ut = Je - pe + Fe;
|
|
3054
|
+
if (Ut > de.messageCharacters)
|
|
3055
|
+
throw new J("AI 助手响应文本超过大小限制");
|
|
3056
|
+
Je = Ut, Ye.set(x.messageId, Fe);
|
|
2559
3057
|
}
|
|
2560
|
-
if (
|
|
2561
|
-
if (
|
|
2562
|
-
throw new
|
|
2563
|
-
if (
|
|
2564
|
-
throw new
|
|
2565
|
-
const pe =
|
|
2566
|
-
|
|
2567
|
-
de.progressCharactersPerRun -
|
|
3058
|
+
if (x.type === "run.progress") {
|
|
3059
|
+
if (re !== void 0 && re !== x.runId)
|
|
3060
|
+
throw new J("AI 助手响应 run id 不一致");
|
|
3061
|
+
if (re ??= x.runId, Rt += 1, Rt > de.progressStepsPerRun)
|
|
3062
|
+
throw new J("AI 助手处理过程数量超过限制");
|
|
3063
|
+
const pe = ht(
|
|
3064
|
+
x.message,
|
|
3065
|
+
de.progressCharactersPerRun - yt
|
|
2568
3066
|
);
|
|
2569
|
-
if (
|
|
2570
|
-
throw new
|
|
2571
|
-
|
|
3067
|
+
if (yt + pe > de.progressCharactersPerRun)
|
|
3068
|
+
throw new J("AI 助手处理过程文本超过大小限制");
|
|
3069
|
+
yt += pe;
|
|
2572
3070
|
}
|
|
2573
|
-
if (
|
|
2574
|
-
if (!
|
|
2575
|
-
throw new
|
|
2576
|
-
if (
|
|
2577
|
-
throw new
|
|
2578
|
-
if (
|
|
2579
|
-
throw new
|
|
2580
|
-
|
|
3071
|
+
if (x.type === "artifact") {
|
|
3072
|
+
if (!Qe.has(x.messageId))
|
|
3073
|
+
throw new J("AI 助手响应事件顺序无效");
|
|
3074
|
+
if ($t += 1, $t > de.artifactsPerRun)
|
|
3075
|
+
throw new J("AI 助手单次响应 Artifact 数量超过限制");
|
|
3076
|
+
if (Lt.has(x.artifact.id))
|
|
3077
|
+
throw new J("AI 助手响应包含重复的 Artifact id");
|
|
3078
|
+
Lt.add(x.artifact.id);
|
|
2581
3079
|
}
|
|
2582
|
-
if (
|
|
2583
|
-
throw new
|
|
2584
|
-
if (
|
|
2585
|
-
throw new
|
|
2586
|
-
if (
|
|
2587
|
-
throw new
|
|
2588
|
-
if (
|
|
2589
|
-
|
|
3080
|
+
if (x.type === "message.complete" && !Qe.delete(x.messageId))
|
|
3081
|
+
throw new J("AI 助手响应事件顺序无效");
|
|
3082
|
+
if (x.type === "run.complete" && re !== void 0 && re !== x.runId)
|
|
3083
|
+
throw new J("AI 助手响应 run id 不一致");
|
|
3084
|
+
if (x.type === "run.cancelled" && x.runId !== void 0 && re !== void 0 && re !== x.runId)
|
|
3085
|
+
throw new J("AI 助手响应 run id 不一致");
|
|
3086
|
+
if (V((pe) => we(pe, x)), x.type === "error" || x.type === "run.cancelled" || x.type === "run.complete") {
|
|
3087
|
+
Ce = !0;
|
|
2590
3088
|
break;
|
|
2591
3089
|
}
|
|
2592
3090
|
}
|
|
2593
|
-
if (!
|
|
2594
|
-
throw new
|
|
2595
|
-
} catch (
|
|
3091
|
+
if (!Ce)
|
|
3092
|
+
throw new J("AI 助手流式响应在终止事件前结束");
|
|
3093
|
+
} catch (Ce) {
|
|
2596
3094
|
if (Ne.current !== Ue) return;
|
|
2597
|
-
if (
|
|
2598
|
-
|
|
2599
|
-
(
|
|
3095
|
+
if (ut.signal.aborted) {
|
|
3096
|
+
V(
|
|
3097
|
+
(re) => we(re, { type: "run.cancelled" })
|
|
2600
3098
|
);
|
|
2601
3099
|
return;
|
|
2602
3100
|
}
|
|
2603
3101
|
console.error("[make-ai-assistant] assistant run failed", {
|
|
2604
3102
|
appId: s.app.id,
|
|
2605
|
-
errorType:
|
|
2606
|
-
}),
|
|
2607
|
-
(
|
|
3103
|
+
errorType: Ce instanceof Error ? Ce.name : typeof Ce
|
|
3104
|
+
}), V(
|
|
3105
|
+
(re) => we(re, {
|
|
2608
3106
|
type: "error",
|
|
2609
3107
|
code: "TRANSPORT_ERROR",
|
|
2610
|
-
message:
|
|
3108
|
+
message: Ce instanceof J ? Ce.message : "连接失败,请重试",
|
|
2611
3109
|
retryable: !0
|
|
2612
3110
|
})
|
|
2613
3111
|
);
|
|
2614
3112
|
} finally {
|
|
2615
|
-
Ne.current === Ue &&
|
|
3113
|
+
Ne.current === Ue && G.current === ut && (G.current = void 0), le.current?.requestVersion === Ue && (Xt(le.current.iterator), le.current = void 0);
|
|
2616
3114
|
}
|
|
2617
|
-
},
|
|
2618
|
-
if (
|
|
2619
|
-
if (
|
|
3115
|
+
}, d = (f) => {
|
|
3116
|
+
if (_.enabled) {
|
|
3117
|
+
if (h.pending)
|
|
2620
3118
|
return oe("请等待附件上传完成,或移除失败的附件"), Promise.resolve();
|
|
2621
|
-
const
|
|
2622
|
-
return
|
|
3119
|
+
const B = f.trim(), K = h.parts.length ? [...B ? [{ id: Oe(), kind: "text", text: B }] : [], ...h.parts] : void 0;
|
|
3120
|
+
return X(""), h.clear(), _.send(B, K);
|
|
2623
3121
|
}
|
|
2624
|
-
return
|
|
2625
|
-
}, g = (
|
|
3122
|
+
return o(f);
|
|
3123
|
+
}, g = (f) => o(f.userMessage.content, { regenerateFrom: f }), w = async (f, B) => {
|
|
2626
3124
|
try {
|
|
2627
|
-
await
|
|
2628
|
-
} catch (
|
|
3125
|
+
await nn(B), me({ messageId: f, message: "已复制", status: "success" });
|
|
3126
|
+
} catch (K) {
|
|
2629
3127
|
console.error("[make-ai-assistant] copy answer failed", {
|
|
2630
|
-
errorType:
|
|
2631
|
-
}), me({ messageId:
|
|
3128
|
+
errorType: K instanceof Error ? K.name : typeof K
|
|
3129
|
+
}), me({ messageId: f, message: "复制失败", status: "error" });
|
|
2632
3130
|
}
|
|
2633
|
-
},
|
|
2634
|
-
|
|
2635
|
-
},
|
|
2636
|
-
|
|
2637
|
-
},
|
|
2638
|
-
if (
|
|
2639
|
-
|
|
3131
|
+
}, T = (f) => {
|
|
3132
|
+
f.preventDefault(), d(N);
|
|
3133
|
+
}, z = (f) => {
|
|
3134
|
+
f.key === "Enter" && !f.shiftKey && !f.nativeEvent.isComposing && (f.preventDefault(), d(N));
|
|
3135
|
+
}, I = () => {
|
|
3136
|
+
if (_.enabled) {
|
|
3137
|
+
_.stop();
|
|
2640
3138
|
return;
|
|
2641
3139
|
}
|
|
2642
|
-
De("stop") &&
|
|
2643
|
-
(
|
|
3140
|
+
De("stop") && V(
|
|
3141
|
+
(f) => we(f, { type: "run.cancelled" })
|
|
2644
3142
|
);
|
|
2645
|
-
},
|
|
2646
|
-
if (ue(!1),
|
|
2647
|
-
|
|
3143
|
+
}, R = () => {
|
|
3144
|
+
if (ue(!1), _.enabled) {
|
|
3145
|
+
X(""), _.create(), l?.();
|
|
2648
3146
|
return;
|
|
2649
3147
|
}
|
|
2650
|
-
De("new-conversation"),
|
|
2651
|
-
},
|
|
2652
|
-
if (
|
|
2653
|
-
|
|
3148
|
+
De("new-conversation"), X(""), oe(void 0), me(void 0), ce(!1), ye.current = !0, V(fe()), l?.();
|
|
3149
|
+
}, E = _.enabled && _.cancelling.length ? "停止中" : k.features?.remoteCancellation === !1 ? "停止接收" : "停止生成", q = Da(O), be = Pa(O), Se = hn(O), ct = typeof k.regenerate == "function" && k.features?.regeneration !== !1, he = () => {
|
|
3150
|
+
if (_.enabled) {
|
|
3151
|
+
_.retry();
|
|
2654
3152
|
return;
|
|
2655
3153
|
}
|
|
2656
|
-
Se &&
|
|
2657
|
-
}, Pe = (
|
|
2658
|
-
if (
|
|
2659
|
-
if (
|
|
2660
|
-
|
|
3154
|
+
Se && d(Se.content);
|
|
3155
|
+
}, Pe = (f) => {
|
|
3156
|
+
if (f.key === "Escape" && !(!Q && !Z)) {
|
|
3157
|
+
if (f.preventDefault(), f.stopPropagation(), Q) {
|
|
3158
|
+
ie(!1), xe.current?.focus();
|
|
2661
3159
|
return;
|
|
2662
3160
|
}
|
|
2663
|
-
ue(!1),
|
|
3161
|
+
ue(!1), We.current?.focus();
|
|
2664
3162
|
}
|
|
2665
3163
|
};
|
|
2666
|
-
return /* @__PURE__ */
|
|
3164
|
+
return /* @__PURE__ */ u(
|
|
2667
3165
|
"section",
|
|
2668
3166
|
{
|
|
2669
|
-
className: `make-ai-assistant make-ai-assistant__panel${
|
|
3167
|
+
className: `make-ai-assistant make-ai-assistant__panel${_.enabled ? " make-ai-assistant__panel--managed" : ""}`,
|
|
2670
3168
|
ref: Ee,
|
|
2671
|
-
style:
|
|
3169
|
+
style: W,
|
|
2672
3170
|
onKeyDown: Pe,
|
|
2673
|
-
onDragOver: (
|
|
2674
|
-
|
|
3171
|
+
onDragOver: (f) => {
|
|
3172
|
+
h.enabled && f.dataTransfer.types.includes("Files") && f.preventDefault();
|
|
2675
3173
|
},
|
|
2676
|
-
onDrop: (
|
|
2677
|
-
|
|
3174
|
+
onDrop: (f) => {
|
|
3175
|
+
h.enabled && f.dataTransfer.files.length && (f.preventDefault(), h.add(Array.from(f.dataTransfer.files)));
|
|
2678
3176
|
},
|
|
2679
3177
|
children: [
|
|
2680
|
-
/* @__PURE__ */
|
|
2681
|
-
/* @__PURE__ */ a("div", { className: "make-ai-assistant__header-leading", children:
|
|
3178
|
+
/* @__PURE__ */ u("header", { className: "make-ai-assistant__header", children: [
|
|
3179
|
+
/* @__PURE__ */ a("div", { className: "make-ai-assistant__header-leading", children: _.enabled ? /* @__PURE__ */ u(
|
|
2682
3180
|
"button",
|
|
2683
3181
|
{
|
|
2684
|
-
"aria-controls":
|
|
2685
|
-
"aria-expanded":
|
|
3182
|
+
"aria-controls": it,
|
|
3183
|
+
"aria-expanded": Z,
|
|
2686
3184
|
"aria-haspopup": "dialog",
|
|
2687
3185
|
"aria-label": "任务列表",
|
|
2688
3186
|
className: "make-ai-assistant__task-list-trigger",
|
|
2689
|
-
ref:
|
|
3187
|
+
ref: We,
|
|
2690
3188
|
type: "button",
|
|
2691
|
-
onClick: () => ue((
|
|
3189
|
+
onClick: () => ue((f) => !f),
|
|
2692
3190
|
children: [
|
|
2693
3191
|
/* @__PURE__ */ a(
|
|
2694
|
-
|
|
3192
|
+
Is,
|
|
2695
3193
|
{
|
|
2696
3194
|
"aria-hidden": "true",
|
|
2697
3195
|
className: "make-ai-assistant__task-list-icon"
|
|
2698
3196
|
}
|
|
2699
3197
|
),
|
|
2700
3198
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__task-list-label", children: "任务列表" }),
|
|
2701
|
-
|
|
2702
|
-
|
|
3199
|
+
Z ? /* @__PURE__ */ a(
|
|
3200
|
+
gs,
|
|
2703
3201
|
{
|
|
2704
3202
|
"aria-hidden": "true",
|
|
2705
3203
|
className: "make-ai-assistant__task-list-disclosure"
|
|
2706
3204
|
}
|
|
2707
3205
|
) : /* @__PURE__ */ a(
|
|
2708
|
-
|
|
3206
|
+
ks,
|
|
2709
3207
|
{
|
|
2710
3208
|
"aria-hidden": "true",
|
|
2711
3209
|
className: "make-ai-assistant__task-list-disclosure"
|
|
@@ -2714,12 +3212,12 @@ function oa({
|
|
|
2714
3212
|
]
|
|
2715
3213
|
}
|
|
2716
3214
|
) : null }),
|
|
2717
|
-
/* @__PURE__ */
|
|
2718
|
-
/* @__PURE__ */ a(
|
|
2719
|
-
/* @__PURE__ */ a("h2", { className: "make-ai-assistant__header-title", title:
|
|
3215
|
+
/* @__PURE__ */ u("div", { className: "make-ai-assistant__header-center", children: [
|
|
3216
|
+
/* @__PURE__ */ a(ft, {}),
|
|
3217
|
+
/* @__PURE__ */ a("h2", { className: "make-ai-assistant__header-title", title: r, children: r })
|
|
2720
3218
|
] }),
|
|
2721
|
-
/* @__PURE__ */
|
|
2722
|
-
|
|
3219
|
+
/* @__PURE__ */ u("div", { className: "make-ai-assistant__header-actions", children: [
|
|
3220
|
+
m ? /* @__PURE__ */ a(
|
|
2723
3221
|
"button",
|
|
2724
3222
|
{
|
|
2725
3223
|
"aria-label": v ? "退出全屏" : "全屏显示",
|
|
@@ -2727,15 +3225,15 @@ function oa({
|
|
|
2727
3225
|
className: "make-ai-assistant__icon-button",
|
|
2728
3226
|
title: v ? "退出全屏" : "全屏显示",
|
|
2729
3227
|
type: "button",
|
|
2730
|
-
onClick:
|
|
3228
|
+
onClick: m,
|
|
2731
3229
|
children: v ? /* @__PURE__ */ a(
|
|
2732
|
-
|
|
3230
|
+
Cs,
|
|
2733
3231
|
{
|
|
2734
3232
|
"aria-hidden": "true",
|
|
2735
3233
|
className: "make-ai-assistant__icon-button-icon"
|
|
2736
3234
|
}
|
|
2737
3235
|
) : /* @__PURE__ */ a(
|
|
2738
|
-
|
|
3236
|
+
Ns,
|
|
2739
3237
|
{
|
|
2740
3238
|
"aria-hidden": "true",
|
|
2741
3239
|
className: "make-ai-assistant__icon-button-icon"
|
|
@@ -2743,15 +3241,15 @@ function oa({
|
|
|
2743
3241
|
)
|
|
2744
3242
|
}
|
|
2745
3243
|
) : null,
|
|
2746
|
-
|
|
3244
|
+
k.features?.newConversation !== !1 ? /* @__PURE__ */ a(
|
|
2747
3245
|
"button",
|
|
2748
3246
|
{
|
|
2749
3247
|
"aria-label": "新建对话",
|
|
2750
3248
|
className: "make-ai-assistant__icon-button",
|
|
2751
3249
|
type: "button",
|
|
2752
|
-
onClick:
|
|
3250
|
+
onClick: R,
|
|
2753
3251
|
children: /* @__PURE__ */ a(
|
|
2754
|
-
|
|
3252
|
+
Tt,
|
|
2755
3253
|
{
|
|
2756
3254
|
"aria-hidden": "true",
|
|
2757
3255
|
className: "make-ai-assistant__icon-button-icon"
|
|
@@ -2762,26 +3260,26 @@ function oa({
|
|
|
2762
3260
|
c ? /* @__PURE__ */ a(
|
|
2763
3261
|
"button",
|
|
2764
3262
|
{
|
|
2765
|
-
"aria-label": `关闭 ${
|
|
3263
|
+
"aria-label": `关闭 ${r}`,
|
|
2766
3264
|
className: "make-ai-assistant__icon-button",
|
|
2767
3265
|
type: "button",
|
|
2768
3266
|
onClick: c,
|
|
2769
|
-
children: /* @__PURE__ */ a(
|
|
3267
|
+
children: /* @__PURE__ */ a(tt, { "aria-hidden": "true", className: "make-ai-assistant__icon-button-icon" })
|
|
2770
3268
|
}
|
|
2771
3269
|
) : null
|
|
2772
3270
|
] })
|
|
2773
3271
|
] }),
|
|
2774
|
-
|
|
2775
|
-
|
|
3272
|
+
_.enabled && Z ? /* @__PURE__ */ a(
|
|
3273
|
+
Ps,
|
|
2776
3274
|
{
|
|
2777
|
-
id:
|
|
2778
|
-
manager:
|
|
2779
|
-
triggerRef:
|
|
3275
|
+
id: it,
|
|
3276
|
+
manager: _,
|
|
3277
|
+
triggerRef: We,
|
|
2780
3278
|
onDismiss: () => ue(!1),
|
|
2781
|
-
onNewConversation:
|
|
3279
|
+
onNewConversation: k.features?.newConversation !== !1 ? R : void 0
|
|
2782
3280
|
}
|
|
2783
3281
|
) : null,
|
|
2784
|
-
/* @__PURE__ */
|
|
3282
|
+
/* @__PURE__ */ u(
|
|
2785
3283
|
"div",
|
|
2786
3284
|
{
|
|
2787
3285
|
className: "make-ai-assistant__body",
|
|
@@ -2789,128 +3287,128 @@ function oa({
|
|
|
2789
3287
|
"aria-relevant": "additions text",
|
|
2790
3288
|
ref: Ae,
|
|
2791
3289
|
role: "log",
|
|
2792
|
-
onScroll:
|
|
3290
|
+
onScroll: Ge,
|
|
2793
3291
|
children: [
|
|
2794
|
-
|
|
2795
|
-
/* @__PURE__ */ a(
|
|
3292
|
+
te === "loading" ? /* @__PURE__ */ u("div", { className: "make-ai-assistant__empty", role: "status", children: [
|
|
3293
|
+
/* @__PURE__ */ a(ft, {}),
|
|
2796
3294
|
/* @__PURE__ */ a("h3", { children: "正在恢复对话" }),
|
|
2797
3295
|
/* @__PURE__ */ a("p", { children: "正在读取当前 App 的历史消息…" })
|
|
2798
|
-
] }) :
|
|
2799
|
-
|
|
3296
|
+
] }) : te === "error" ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__empty", children: /* @__PURE__ */ a(
|
|
3297
|
+
vn,
|
|
2800
3298
|
{
|
|
2801
|
-
error:
|
|
2802
|
-
onRetry: () =>
|
|
3299
|
+
error: Ve,
|
|
3300
|
+
onRetry: () => P((f) => f + 1)
|
|
2803
3301
|
}
|
|
2804
|
-
) }) :
|
|
2805
|
-
/* @__PURE__ */ a(
|
|
3302
|
+
) }) : O.messages.length === 0 ? /* @__PURE__ */ u("div", { className: "make-ai-assistant__empty", children: [
|
|
3303
|
+
/* @__PURE__ */ a(ft, {}),
|
|
2806
3304
|
/* @__PURE__ */ a("h3", { children: "有什么可以帮你?" }),
|
|
2807
3305
|
/* @__PURE__ */ a("p", { children: "我会结合当前 App、页面位置和宿主允许的上下文回答,并把过程与结果分开展示。" })
|
|
2808
|
-
] }) :
|
|
2809
|
-
|
|
3306
|
+
] }) : kn(
|
|
3307
|
+
O,
|
|
2810
3308
|
s,
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
3309
|
+
rt,
|
|
3310
|
+
S,
|
|
3311
|
+
n,
|
|
2814
3312
|
i,
|
|
2815
3313
|
e,
|
|
2816
3314
|
Se ? he : void 0,
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
(
|
|
2822
|
-
|
|
3315
|
+
L,
|
|
3316
|
+
U,
|
|
3317
|
+
ge,
|
|
3318
|
+
ct,
|
|
3319
|
+
(f, B) => {
|
|
3320
|
+
w(f, B);
|
|
2823
3321
|
},
|
|
2824
|
-
(
|
|
2825
|
-
g(
|
|
3322
|
+
(f) => {
|
|
3323
|
+
g(f);
|
|
2826
3324
|
},
|
|
2827
|
-
|
|
2828
|
-
|
|
3325
|
+
_.enabled ? _ : void 0,
|
|
3326
|
+
k
|
|
2829
3327
|
),
|
|
2830
|
-
|
|
2831
|
-
|
|
3328
|
+
O.progress && !q ? /* @__PURE__ */ a(
|
|
3329
|
+
Jt,
|
|
2832
3330
|
{
|
|
2833
3331
|
assistantName: e,
|
|
2834
|
-
progress:
|
|
3332
|
+
progress: O.progress
|
|
2835
3333
|
}
|
|
2836
3334
|
) : null,
|
|
2837
|
-
|
|
2838
|
-
|
|
3335
|
+
O.error && !be ? /* @__PURE__ */ a(
|
|
3336
|
+
Jt,
|
|
2839
3337
|
{
|
|
2840
3338
|
assistantName: e,
|
|
2841
|
-
error:
|
|
3339
|
+
error: O.error,
|
|
2842
3340
|
onRetry: Se ? he : void 0
|
|
2843
3341
|
}
|
|
2844
3342
|
) : null
|
|
2845
3343
|
]
|
|
2846
3344
|
}
|
|
2847
3345
|
),
|
|
2848
|
-
|
|
3346
|
+
at ? /* @__PURE__ */ a(
|
|
2849
3347
|
"button",
|
|
2850
3348
|
{
|
|
2851
3349
|
"aria-label": "回到最新消息",
|
|
2852
3350
|
className: "make-ai-assistant__back-to-latest",
|
|
2853
3351
|
type: "button",
|
|
2854
|
-
onClick:
|
|
2855
|
-
children: /* @__PURE__ */ a(
|
|
3352
|
+
onClick: $e,
|
|
3353
|
+
children: /* @__PURE__ */ a(vs, { "aria-hidden": "true" })
|
|
2856
3354
|
}
|
|
2857
3355
|
) : null,
|
|
2858
|
-
/* @__PURE__ */
|
|
2859
|
-
|
|
3356
|
+
/* @__PURE__ */ u("footer", { className: "make-ai-assistant__composer-region", children: [
|
|
3357
|
+
te === "ready" && ot.length > 0 && O.messages.length === 0 ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__suggestions", "aria-label": "推荐问题", children: ot.map((f, B) => /* @__PURE__ */ a(
|
|
2860
3358
|
"button",
|
|
2861
3359
|
{
|
|
2862
3360
|
type: "button",
|
|
2863
3361
|
onClick: () => {
|
|
2864
|
-
|
|
3362
|
+
d(f);
|
|
2865
3363
|
},
|
|
2866
|
-
children:
|
|
3364
|
+
children: f
|
|
2867
3365
|
},
|
|
2868
|
-
`${
|
|
3366
|
+
`${B}-${f}`
|
|
2869
3367
|
)) }) : null,
|
|
2870
|
-
/* @__PURE__ */
|
|
2871
|
-
|
|
3368
|
+
/* @__PURE__ */ u("form", { className: "make-ai-assistant__composer", onSubmit: T, children: [
|
|
3369
|
+
h.enabled ? /* @__PURE__ */ a(Ws, { attachments: h, visible: H }) : null,
|
|
2872
3370
|
/* @__PURE__ */ a(
|
|
2873
3371
|
"textarea",
|
|
2874
3372
|
{
|
|
2875
3373
|
"aria-label": `向 ${e} 提问`,
|
|
2876
|
-
"aria-describedby":
|
|
2877
|
-
"aria-invalid":
|
|
3374
|
+
"aria-describedby": Y ? "make-ai-composer-error" : void 0,
|
|
3375
|
+
"aria-invalid": Y ? !0 : void 0,
|
|
2878
3376
|
autoFocus: !0,
|
|
2879
|
-
disabled:
|
|
3377
|
+
disabled: te !== "ready" || !_.enabled && O.status === "streaming",
|
|
2880
3378
|
placeholder: `询问当前 ${s.app.name ?? "App"} 中的数据…`,
|
|
2881
|
-
ref:
|
|
3379
|
+
ref: ze,
|
|
2882
3380
|
rows: 2,
|
|
2883
|
-
value:
|
|
2884
|
-
onChange: (
|
|
2885
|
-
|
|
3381
|
+
value: N,
|
|
3382
|
+
onChange: (f) => {
|
|
3383
|
+
X(f.currentTarget.value), oe(void 0);
|
|
2886
3384
|
},
|
|
2887
|
-
onKeyDown:
|
|
2888
|
-
onPaste: (
|
|
2889
|
-
!
|
|
3385
|
+
onKeyDown: z,
|
|
3386
|
+
onPaste: (f) => {
|
|
3387
|
+
!h.enabled || !f.clipboardData.files.length || (f.preventDefault(), h.add(Array.from(f.clipboardData.files)));
|
|
2890
3388
|
}
|
|
2891
3389
|
}
|
|
2892
3390
|
),
|
|
2893
|
-
/* @__PURE__ */
|
|
2894
|
-
|
|
2895
|
-
|
|
3391
|
+
/* @__PURE__ */ u("div", { className: "make-ai-assistant__composer-toolbar", children: [
|
|
3392
|
+
h.enabled ? /* @__PURE__ */ a(
|
|
3393
|
+
Ks,
|
|
2896
3394
|
{
|
|
2897
|
-
attachments:
|
|
2898
|
-
open:
|
|
3395
|
+
attachments: h,
|
|
3396
|
+
open: Q,
|
|
2899
3397
|
triggerRef: xe,
|
|
2900
|
-
onOpenChange:
|
|
3398
|
+
onOpenChange: ie
|
|
2901
3399
|
}
|
|
2902
3400
|
) : null,
|
|
2903
|
-
/* @__PURE__ */
|
|
2904
|
-
|
|
3401
|
+
/* @__PURE__ */ u("div", { className: "make-ai-assistant__composer-actions", children: [
|
|
3402
|
+
O.status === "streaming" ? /* @__PURE__ */ a(
|
|
2905
3403
|
"button",
|
|
2906
3404
|
{
|
|
2907
|
-
"aria-label":
|
|
3405
|
+
"aria-label": E,
|
|
2908
3406
|
className: "make-ai-assistant__send make-ai-assistant__send--stop",
|
|
2909
|
-
"data-tooltip":
|
|
2910
|
-
ref:
|
|
2911
|
-
disabled:
|
|
3407
|
+
"data-tooltip": E,
|
|
3408
|
+
ref: Xe,
|
|
3409
|
+
disabled: _.enabled && _.cancelling.includes(O.activeRunId ?? ""),
|
|
2912
3410
|
type: "button",
|
|
2913
|
-
onClick:
|
|
3411
|
+
onClick: I,
|
|
2914
3412
|
children: /* @__PURE__ */ a("span", { "aria-hidden": "true" })
|
|
2915
3413
|
}
|
|
2916
3414
|
) : /* @__PURE__ */ a(
|
|
@@ -2918,103 +3416,103 @@ function oa({
|
|
|
2918
3416
|
{
|
|
2919
3417
|
"aria-label": "发送",
|
|
2920
3418
|
className: "make-ai-assistant__send",
|
|
2921
|
-
disabled:
|
|
3419
|
+
disabled: te !== "ready" || h.pending || !N.trim() && !h.parts.length,
|
|
2922
3420
|
type: "submit",
|
|
2923
|
-
children: /* @__PURE__ */ a(
|
|
3421
|
+
children: /* @__PURE__ */ a(qt, { "aria-hidden": "true" })
|
|
2924
3422
|
}
|
|
2925
3423
|
),
|
|
2926
|
-
|
|
3424
|
+
_.enabled && O.status === "streaming" ? /* @__PURE__ */ a(
|
|
2927
3425
|
"button",
|
|
2928
3426
|
{
|
|
2929
3427
|
"aria-label": "发送",
|
|
2930
3428
|
className: "make-ai-assistant__send",
|
|
2931
|
-
disabled:
|
|
3429
|
+
disabled: _.busy || h.pending || !N.trim() && !h.parts.length,
|
|
2932
3430
|
type: "submit",
|
|
2933
|
-
children: /* @__PURE__ */ a(
|
|
3431
|
+
children: /* @__PURE__ */ a(qt, { "aria-hidden": "true" })
|
|
2934
3432
|
}
|
|
2935
3433
|
) : null
|
|
2936
3434
|
] })
|
|
2937
3435
|
] })
|
|
2938
3436
|
] }),
|
|
2939
|
-
|
|
3437
|
+
Y ? /* @__PURE__ */ a("p", { id: "make-ai-composer-error", role: "alert", children: Y }) : null,
|
|
2940
3438
|
/* @__PURE__ */ a("p", { children: "AI 生成的结果可能存在偏差,重要数据请核对明细。" })
|
|
2941
3439
|
] })
|
|
2942
3440
|
]
|
|
2943
3441
|
}
|
|
2944
3442
|
);
|
|
2945
3443
|
}
|
|
2946
|
-
function
|
|
2947
|
-
return /* @__PURE__ */ a(
|
|
3444
|
+
function An(e) {
|
|
3445
|
+
return /* @__PURE__ */ a(Ha, { ...e, visible: !0 });
|
|
2948
3446
|
}
|
|
2949
|
-
function
|
|
3447
|
+
function Cn({
|
|
2950
3448
|
defaultOpen: e = !1,
|
|
2951
3449
|
hideLauncher: t = !1,
|
|
2952
3450
|
launcher: s,
|
|
2953
|
-
launcherPosition:
|
|
3451
|
+
launcherPosition: n = "bottom-right",
|
|
2954
3452
|
maxDrawerWidth: i,
|
|
2955
3453
|
onOpenChange: c,
|
|
2956
|
-
open:
|
|
2957
|
-
...
|
|
3454
|
+
open: l,
|
|
3455
|
+
...m
|
|
2958
3456
|
}) {
|
|
2959
|
-
const
|
|
2960
|
-
() => e ||
|
|
2961
|
-
), [
|
|
2962
|
-
|
|
2963
|
-
}, b = () =>
|
|
2964
|
-
return
|
|
2965
|
-
|
|
2966
|
-
}, [
|
|
2967
|
-
if (!
|
|
2968
|
-
const
|
|
2969
|
-
if (
|
|
2970
|
-
if (
|
|
2971
|
-
|
|
3457
|
+
const y = za(m.brandName, m.title), [v, p] = $(e), [A, C] = $(
|
|
3458
|
+
() => e || l === !0
|
|
3459
|
+
), [S, k] = $(!1), U = D(null), L = l ?? v, H = Mt(m.theme), _ = en(i), h = _ === void 0 ? void 0 : { "--make-ai-internal-drawer-max-width": `${_}px` }, r = (M) => {
|
|
3460
|
+
l === void 0 && p(M), c?.(M), M || (k(!1), requestAnimationFrame(() => U.current?.focus()));
|
|
3461
|
+
}, b = () => r(!L);
|
|
3462
|
+
return ne(() => {
|
|
3463
|
+
L && C(!0);
|
|
3464
|
+
}, [L]), ne(() => {
|
|
3465
|
+
if (!L) return;
|
|
3466
|
+
const M = (W) => {
|
|
3467
|
+
if (W.key === "Escape") {
|
|
3468
|
+
if (S) {
|
|
3469
|
+
k(!1);
|
|
2972
3470
|
return;
|
|
2973
3471
|
}
|
|
2974
|
-
|
|
3472
|
+
r(!1), requestAnimationFrame(() => U.current?.focus());
|
|
2975
3473
|
}
|
|
2976
3474
|
};
|
|
2977
|
-
return document.addEventListener("keydown",
|
|
2978
|
-
}, [
|
|
3475
|
+
return document.addEventListener("keydown", M), () => document.removeEventListener("keydown", M);
|
|
3476
|
+
}, [S, c, L]), /* @__PURE__ */ u(
|
|
2979
3477
|
"div",
|
|
2980
3478
|
{
|
|
2981
3479
|
className: "make-ai-assistant",
|
|
2982
|
-
"data-open":
|
|
2983
|
-
style:
|
|
3480
|
+
"data-open": L || void 0,
|
|
3481
|
+
style: H,
|
|
2984
3482
|
children: [
|
|
2985
|
-
!t && (!
|
|
3483
|
+
!t && (!L || s) ? s ? s({ open: L, toggle: b }) : /* @__PURE__ */ u(
|
|
2986
3484
|
"button",
|
|
2987
3485
|
{
|
|
2988
|
-
"aria-label":
|
|
2989
|
-
"aria-expanded":
|
|
3486
|
+
"aria-label": L ? `关闭 ${y}` : `打开 ${y}`,
|
|
3487
|
+
"aria-expanded": L,
|
|
2990
3488
|
className: "make-ai-assistant__launcher",
|
|
2991
|
-
"data-launcher-position":
|
|
2992
|
-
ref:
|
|
3489
|
+
"data-launcher-position": n,
|
|
3490
|
+
ref: U,
|
|
2993
3491
|
type: "button",
|
|
2994
3492
|
onClick: b,
|
|
2995
3493
|
children: [
|
|
2996
3494
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__launcher-orbit", "aria-hidden": "true" }),
|
|
2997
|
-
/* @__PURE__ */ a(
|
|
3495
|
+
/* @__PURE__ */ a(Ca, { "aria-hidden": "true" })
|
|
2998
3496
|
]
|
|
2999
3497
|
}
|
|
3000
3498
|
) : null,
|
|
3001
|
-
|
|
3499
|
+
A ? /* @__PURE__ */ a(
|
|
3002
3500
|
"aside",
|
|
3003
3501
|
{
|
|
3004
|
-
"aria-label":
|
|
3502
|
+
"aria-label": y,
|
|
3005
3503
|
"aria-modal": "false",
|
|
3006
|
-
className: `make-ai-assistant__drawer${
|
|
3007
|
-
hidden: !
|
|
3504
|
+
className: `make-ai-assistant__drawer${S ? " make-ai-assistant__drawer--fullscreen" : ""}`,
|
|
3505
|
+
hidden: !L,
|
|
3008
3506
|
role: "dialog",
|
|
3009
|
-
style:
|
|
3507
|
+
style: h,
|
|
3010
3508
|
children: /* @__PURE__ */ a(
|
|
3011
|
-
|
|
3509
|
+
Ha,
|
|
3012
3510
|
{
|
|
3013
|
-
...
|
|
3014
|
-
isFullscreen:
|
|
3015
|
-
onClose: () =>
|
|
3016
|
-
onToggleFullscreen: () =>
|
|
3017
|
-
visible:
|
|
3511
|
+
...m,
|
|
3512
|
+
isFullscreen: S,
|
|
3513
|
+
onClose: () => r(!1),
|
|
3514
|
+
onToggleFullscreen: () => k((M) => !M),
|
|
3515
|
+
visible: L
|
|
3018
3516
|
}
|
|
3019
3517
|
)
|
|
3020
3518
|
}
|
|
@@ -3024,24 +3522,24 @@ function Ls({
|
|
|
3024
3522
|
);
|
|
3025
3523
|
}
|
|
3026
3524
|
export {
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3525
|
+
Ga as ArtifactRenderer,
|
|
3526
|
+
An as AssistantPanel,
|
|
3527
|
+
Sn as MAKE_AI_ARTIFACT_KINDS,
|
|
3528
|
+
Rn as MAKE_AI_ARTIFACT_LIMITS,
|
|
3529
|
+
Ln as MAKE_AI_ARTIFACT_SCHEMA_VERSION,
|
|
3032
3530
|
de as MAKE_AI_CONVERSATION_LIMITS,
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3531
|
+
Cn as MakeAiAssistant,
|
|
3532
|
+
ta as appendUserMessage,
|
|
3533
|
+
Xa as createArtifactCapabilities,
|
|
3534
|
+
Qt as createArtifactTemplateRegistry,
|
|
3037
3535
|
fe as createAssistantConversationState,
|
|
3038
|
-
|
|
3039
|
-
|
|
3536
|
+
is as createPlatformArtifactRegistry,
|
|
3537
|
+
En as extendArtifactTemplateRegistry,
|
|
3040
3538
|
Le as formatArtifactValue,
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3539
|
+
zn as parseArtifact,
|
|
3540
|
+
ea as parseAssistantEvent,
|
|
3541
|
+
ns as platformArtifactTemplates,
|
|
3044
3542
|
we as reduceAssistantEvent,
|
|
3045
|
-
|
|
3046
|
-
|
|
3543
|
+
Wa as resolveArtifactTemplate,
|
|
3544
|
+
xn as validateArtifact
|
|
3047
3545
|
};
|