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