@qfei-design/make-ai-assistant 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PUBLIC_API.md +12 -1
- package/README.md +40 -2
- package/dist/react/artifact-renderer.d.ts +4 -2
- package/dist/react/artifact-templates.d.ts +3 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/make-ai-assistant.d.ts +8 -1
- package/dist/react/theme.d.ts +45 -0
- package/dist/react.cjs +3 -3
- package/dist/react.mjs +700 -605
- package/dist/styles.css +80 -42
- package/package.json +1 -1
package/dist/react.mjs
CHANGED
|
@@ -1,34 +1,88 @@
|
|
|
1
|
-
import { jsxs as i, jsx as a, Fragment as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { a as
|
|
6
|
-
import { d as
|
|
7
|
-
|
|
1
|
+
import { jsxs as i, jsx as a, Fragment as G } from "react/jsx-runtime";
|
|
2
|
+
import { isValidElement as Gt, cloneElement as Zt, useState as E, useRef as M, useLayoutEffect as wt, useEffect as ee, useId as Qt, useMemo as ft } from "react";
|
|
3
|
+
import { resolveArtifactTemplate as Jt, createArtifactTemplateRegistry as It, createArtifactCapabilities as ea } from "./index.mjs";
|
|
4
|
+
import { extendArtifactTemplateRegistry as rs } from "./index.mjs";
|
|
5
|
+
import { a as Ce, r as Se, c as $e, M as L, b as ta, p as aa } from "./conversation-B7eGUXi-.js";
|
|
6
|
+
import { d as os, e as cs, f as ls, g as ds, v as ms } from "./conversation-B7eGUXi-.js";
|
|
7
|
+
const At = (e) => e?.trim() || void 0, H = (e, t) => At(e) ?? t, Oe = (e) => {
|
|
8
|
+
const t = At(e?.primary);
|
|
9
|
+
if (t)
|
|
10
|
+
return {
|
|
11
|
+
"--make-ai-theme-primary": t,
|
|
12
|
+
"--make-ai-theme-primary-hover": H(
|
|
13
|
+
e?.primaryHover,
|
|
14
|
+
"color-mix(in srgb, var(--make-ai-theme-primary) 84%, var(--make-ai-theme-text))"
|
|
15
|
+
),
|
|
16
|
+
"--make-ai-theme-on-primary": H(
|
|
17
|
+
e?.onPrimary,
|
|
18
|
+
"#fcfcff"
|
|
19
|
+
),
|
|
20
|
+
"--make-ai-theme-bg": H(
|
|
21
|
+
e?.background,
|
|
22
|
+
"color-mix(in srgb, var(--make-ai-theme-primary) 2%, #fcfcff)"
|
|
23
|
+
),
|
|
24
|
+
"--make-ai-theme-surface": H(
|
|
25
|
+
e?.surface,
|
|
26
|
+
"color-mix(in srgb, var(--make-ai-theme-primary) 4%, var(--make-ai-theme-bg))"
|
|
27
|
+
),
|
|
28
|
+
"--make-ai-theme-surface-strong": H(
|
|
29
|
+
e?.surfaceStrong,
|
|
30
|
+
"color-mix(in srgb, var(--make-ai-theme-primary) 8%, var(--make-ai-theme-bg))"
|
|
31
|
+
),
|
|
32
|
+
"--make-ai-theme-text": H(
|
|
33
|
+
e?.text,
|
|
34
|
+
"color-mix(in srgb, var(--make-ai-theme-primary) 12%, #252631)"
|
|
35
|
+
),
|
|
36
|
+
"--make-ai-theme-text-secondary": H(
|
|
37
|
+
e?.textSecondary,
|
|
38
|
+
"color-mix(in srgb, var(--make-ai-theme-text) 74%, var(--make-ai-theme-primary))"
|
|
39
|
+
),
|
|
40
|
+
"--make-ai-theme-border": H(
|
|
41
|
+
e?.border,
|
|
42
|
+
"color-mix(in srgb, var(--make-ai-theme-primary) 14%, var(--make-ai-theme-bg))"
|
|
43
|
+
),
|
|
44
|
+
"--make-ai-theme-overlay": H(
|
|
45
|
+
e?.overlay,
|
|
46
|
+
"color-mix(in srgb, var(--make-ai-theme-text) 88%, var(--make-ai-theme-primary))"
|
|
47
|
+
),
|
|
48
|
+
"--make-ai-theme-on-overlay": H(
|
|
49
|
+
e?.onOverlay,
|
|
50
|
+
"#fcfcff"
|
|
51
|
+
)
|
|
52
|
+
};
|
|
53
|
+
}, gt = (e, t) => !t || !Gt(e) || typeof e.type != "string" ? e : Zt(e, {
|
|
54
|
+
style: { ...e.props.style, ...t }
|
|
55
|
+
});
|
|
56
|
+
function sa({
|
|
8
57
|
artifact: e,
|
|
9
58
|
context: t,
|
|
10
59
|
fallback: s,
|
|
11
60
|
onAction: r,
|
|
12
61
|
onActionError: n,
|
|
13
|
-
registry: o
|
|
62
|
+
registry: o,
|
|
63
|
+
theme: l
|
|
14
64
|
}) {
|
|
15
|
-
const l =
|
|
16
|
-
if (!
|
|
17
|
-
|
|
65
|
+
const m = Oe(l), _ = Jt(o, e, t);
|
|
66
|
+
if (!_) {
|
|
67
|
+
const T = s ? s(e) : /* @__PURE__ */ i("section", { className: "make-ai-artifact make-ai-artifact--unsupported", role: "status", children: [
|
|
18
68
|
/* @__PURE__ */ a("strong", { children: "暂不支持展示此结果" }),
|
|
19
69
|
/* @__PURE__ */ i("span", { children: [
|
|
20
70
|
"结果类型:",
|
|
21
71
|
e.kind
|
|
22
72
|
] })
|
|
23
73
|
] });
|
|
24
|
-
|
|
74
|
+
return gt(T, m);
|
|
75
|
+
}
|
|
76
|
+
const f = {
|
|
25
77
|
context: t,
|
|
26
78
|
onAction: r,
|
|
27
|
-
onActionError: n
|
|
28
|
-
|
|
29
|
-
|
|
79
|
+
onActionError: n,
|
|
80
|
+
theme: l,
|
|
81
|
+
themeStyle: m
|
|
82
|
+
}, N = _.template.render(e, t, f);
|
|
83
|
+
return gt(N, m);
|
|
30
84
|
}
|
|
31
|
-
const
|
|
85
|
+
const te = (e, t, s) => {
|
|
32
86
|
if (e == null || e === "") return "—";
|
|
33
87
|
if (typeof e == "boolean") return e ? "是" : "否";
|
|
34
88
|
if (typeof e != "number") return `${e}${t?.unit ?? ""}`;
|
|
@@ -43,12 +97,12 @@ const J = (e, t, s) => {
|
|
|
43
97
|
} catch {
|
|
44
98
|
return `${e}${t?.unit ?? ""}`;
|
|
45
99
|
}
|
|
46
|
-
},
|
|
100
|
+
}, Nt = (e) => {
|
|
47
101
|
let t = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY;
|
|
48
102
|
for (const r of e)
|
|
49
103
|
t = Math.min(t, r), s = Math.max(s, r);
|
|
50
104
|
return Number.isFinite(t) && Number.isFinite(s) ? { min: t, max: s } : { min: 0, max: 0 };
|
|
51
|
-
},
|
|
105
|
+
}, Mt = (e, t, s) => {
|
|
52
106
|
if (!s.onAction) return;
|
|
53
107
|
const r = (o) => {
|
|
54
108
|
console.error("[make-ai-assistant] host action error handler failed", {
|
|
@@ -80,44 +134,45 @@ const J = (e, t, s) => {
|
|
|
80
134
|
} catch (o) {
|
|
81
135
|
n(o);
|
|
82
136
|
}
|
|
83
|
-
},
|
|
137
|
+
}, me = (e, t) => e.actions?.length && t.onAction ? /* @__PURE__ */ a("div", { className: "make-ai-artifact__actions", children: e.actions.map((s) => /* @__PURE__ */ i(
|
|
84
138
|
"button",
|
|
85
139
|
{
|
|
86
140
|
className: `make-ai-artifact__action make-ai-artifact__action--${s.appearance ?? "link"}`,
|
|
87
141
|
type: "button",
|
|
88
|
-
onClick: () =>
|
|
142
|
+
onClick: () => Mt(s, { artifact: e, context: t.context }, t),
|
|
89
143
|
children: [
|
|
90
144
|
s.label,
|
|
91
145
|
/* @__PURE__ */ a("span", { "aria-hidden": "true", children: "→" })
|
|
92
146
|
]
|
|
93
147
|
},
|
|
94
148
|
s.id
|
|
95
|
-
)) }) : null,
|
|
149
|
+
)) }) : null, ue = (e, t, s = "", r) => /* @__PURE__ */ i(
|
|
96
150
|
"section",
|
|
97
151
|
{
|
|
98
152
|
"aria-label": e.title ?? `${e.kind} result`,
|
|
99
153
|
className: `make-ai-artifact ${s}`.trim(),
|
|
100
154
|
"data-artifact-density": e.presentation?.density,
|
|
101
155
|
"data-artifact-kind": e.kind,
|
|
156
|
+
style: r,
|
|
102
157
|
children: [
|
|
103
158
|
e.title ? /* @__PURE__ */ a("h4", { className: "make-ai-artifact__title", children: e.title }) : null,
|
|
104
159
|
e.summary ? /* @__PURE__ */ a("p", { className: "make-ai-artifact__summary", children: e.summary }) : null,
|
|
105
160
|
t
|
|
106
161
|
]
|
|
107
162
|
}
|
|
108
|
-
),
|
|
163
|
+
), na = ({
|
|
109
164
|
artifact: e,
|
|
110
165
|
renderContext: t
|
|
111
166
|
}) => {
|
|
112
|
-
const s = e.data.delta, r = s ?
|
|
167
|
+
const s = e.data.delta, r = s ? te(
|
|
113
168
|
s.value,
|
|
114
169
|
s.format === "percent" ? { style: "percent" } : void 0,
|
|
115
170
|
t.context.locale
|
|
116
171
|
) : void 0;
|
|
117
|
-
return
|
|
172
|
+
return ue(
|
|
118
173
|
e,
|
|
119
|
-
/* @__PURE__ */ i(
|
|
120
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__metric-value", children:
|
|
174
|
+
/* @__PURE__ */ i(G, { children: [
|
|
175
|
+
/* @__PURE__ */ a("div", { className: "make-ai-artifact__metric-value", children: te(
|
|
121
176
|
e.data.value,
|
|
122
177
|
e.data.format,
|
|
123
178
|
t.context.locale
|
|
@@ -134,41 +189,43 @@ const J = (e, t, s) => {
|
|
|
134
189
|
}
|
|
135
190
|
) : null,
|
|
136
191
|
e.data.context ? /* @__PURE__ */ a("p", { className: "make-ai-artifact__context", children: e.data.context }) : null,
|
|
137
|
-
|
|
192
|
+
me(e, t)
|
|
138
193
|
] }),
|
|
139
|
-
"make-ai-artifact--metric"
|
|
194
|
+
"make-ai-artifact--metric",
|
|
195
|
+
t.themeStyle
|
|
140
196
|
);
|
|
141
|
-
},
|
|
197
|
+
}, ra = ({
|
|
142
198
|
artifact: e,
|
|
143
199
|
renderContext: t
|
|
144
|
-
}) =>
|
|
200
|
+
}) => ue(
|
|
145
201
|
e,
|
|
146
|
-
/* @__PURE__ */ i(
|
|
202
|
+
/* @__PURE__ */ i(G, { children: [
|
|
147
203
|
/* @__PURE__ */ a("div", { className: "make-ai-artifact__comparison", children: e.data.items.map((s) => /* @__PURE__ */ i("div", { className: "make-ai-artifact__comparison-item", children: [
|
|
148
204
|
/* @__PURE__ */ a("span", { children: s.label }),
|
|
149
|
-
/* @__PURE__ */ a("strong", { children:
|
|
205
|
+
/* @__PURE__ */ a("strong", { children: te(s.value, s.format, t.context.locale) }),
|
|
150
206
|
s.hint ? /* @__PURE__ */ a("small", { children: s.hint }) : null
|
|
151
207
|
] }, s.id)) }),
|
|
152
|
-
|
|
208
|
+
me(e, t)
|
|
153
209
|
] }),
|
|
154
|
-
"make-ai-artifact--comparison"
|
|
155
|
-
|
|
210
|
+
"make-ai-artifact--comparison",
|
|
211
|
+
t.themeStyle
|
|
212
|
+
), ia = ({
|
|
156
213
|
artifact: e,
|
|
157
214
|
renderContext: t
|
|
158
215
|
}) => {
|
|
159
|
-
const s = e.data.series.flatMap((l) => l.points.map((m) => m.y)), { max: r, min: n } =
|
|
160
|
-
return
|
|
216
|
+
const s = e.data.series.flatMap((l) => l.points.map((m) => m.y)), { max: r, min: n } = Nt(s), o = r - n || 1;
|
|
217
|
+
return ue(
|
|
161
218
|
e,
|
|
162
|
-
/* @__PURE__ */ i(
|
|
219
|
+
/* @__PURE__ */ i(G, { children: [
|
|
163
220
|
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend", children: e.data.series.map((l) => /* @__PURE__ */ i("div", { className: "make-ai-artifact__trend-series", children: [
|
|
164
221
|
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-label", children: l.label }),
|
|
165
|
-
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-bars", children: l.points.map((m,
|
|
222
|
+
/* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-bars", children: l.points.map((m, _) => {
|
|
166
223
|
const f = 18 + (m.y - n) / o * 70;
|
|
167
224
|
return /* @__PURE__ */ i("div", { className: "make-ai-artifact__trend-point", children: [
|
|
168
225
|
/* @__PURE__ */ a(
|
|
169
226
|
"span",
|
|
170
227
|
{
|
|
171
|
-
"aria-label": `${m.x}: ${
|
|
228
|
+
"aria-label": `${m.x}: ${te(
|
|
172
229
|
m.y,
|
|
173
230
|
l.format,
|
|
174
231
|
t.context.locale
|
|
@@ -176,7 +233,7 @@ const J = (e, t, s) => {
|
|
|
176
233
|
className: "make-ai-artifact__trend-bar",
|
|
177
234
|
role: "img",
|
|
178
235
|
style: { height: `${f}%` },
|
|
179
|
-
title: `${m.x}: ${
|
|
236
|
+
title: `${m.x}: ${te(
|
|
180
237
|
m.y,
|
|
181
238
|
l.format,
|
|
182
239
|
t.context.locale
|
|
@@ -184,23 +241,24 @@ const J = (e, t, s) => {
|
|
|
184
241
|
}
|
|
185
242
|
),
|
|
186
243
|
/* @__PURE__ */ a("small", { children: m.x })
|
|
187
|
-
] }, `${m.x}-${
|
|
244
|
+
] }, `${m.x}-${_}`);
|
|
188
245
|
}) })
|
|
189
246
|
] }, l.id)) }),
|
|
190
|
-
|
|
247
|
+
me(e, t)
|
|
191
248
|
] }),
|
|
192
|
-
"make-ai-artifact--trend"
|
|
249
|
+
"make-ai-artifact--trend",
|
|
250
|
+
t.themeStyle
|
|
193
251
|
);
|
|
194
|
-
},
|
|
252
|
+
}, oa = ({
|
|
195
253
|
artifact: e,
|
|
196
254
|
renderContext: t
|
|
197
255
|
}) => {
|
|
198
|
-
const { max: s } =
|
|
256
|
+
const { max: s } = Nt(
|
|
199
257
|
e.data.items.map((n) => Math.abs(n.value))
|
|
200
258
|
), r = Math.max(s, 1);
|
|
201
|
-
return
|
|
259
|
+
return ue(
|
|
202
260
|
e,
|
|
203
|
-
/* @__PURE__ */ i(
|
|
261
|
+
/* @__PURE__ */ i(G, { children: [
|
|
204
262
|
/* @__PURE__ */ a("ol", { className: "make-ai-artifact__ranking", children: e.data.items.map((n, o) => /* @__PURE__ */ i("li", { children: [
|
|
205
263
|
/* @__PURE__ */ a("span", { className: "make-ai-artifact__rank", children: o + 1 }),
|
|
206
264
|
/* @__PURE__ */ i("span", { className: "make-ai-artifact__ranking-label", children: [
|
|
@@ -208,29 +266,30 @@ const J = (e, t, s) => {
|
|
|
208
266
|
n.description ? /* @__PURE__ */ a("small", { children: n.description }) : null
|
|
209
267
|
] }),
|
|
210
268
|
/* @__PURE__ */ a("span", { className: "make-ai-artifact__ranking-track", "aria-hidden": "true", children: /* @__PURE__ */ a("span", { style: { width: `${Math.abs(n.value) / r * 100}%` } }) }),
|
|
211
|
-
/* @__PURE__ */ a("strong", { children:
|
|
269
|
+
/* @__PURE__ */ a("strong", { children: te(n.value, n.format, t.context.locale) })
|
|
212
270
|
] }, n.id)) }),
|
|
213
|
-
|
|
271
|
+
me(e, t)
|
|
214
272
|
] }),
|
|
215
|
-
"make-ai-artifact--ranking"
|
|
273
|
+
"make-ai-artifact--ranking",
|
|
274
|
+
t.themeStyle
|
|
216
275
|
);
|
|
217
|
-
},
|
|
276
|
+
}, ca = (e, t) => t.action ?? {
|
|
218
277
|
id: `open-${t.id}`,
|
|
219
278
|
label: t.title ?? t.id,
|
|
220
279
|
intent: "open-record",
|
|
221
280
|
target: { entityKey: e.data.entity.key, recordId: t.id }
|
|
222
|
-
},
|
|
281
|
+
}, la = ({
|
|
223
282
|
artifact: e,
|
|
224
283
|
renderContext: t
|
|
225
|
-
}) =>
|
|
284
|
+
}) => ue(
|
|
226
285
|
e,
|
|
227
|
-
/* @__PURE__ */ i(
|
|
286
|
+
/* @__PURE__ */ i(G, { children: [
|
|
228
287
|
/* @__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) => {
|
|
229
|
-
const r =
|
|
288
|
+
const r = ca(e, s), n = /* @__PURE__ */ i(G, { children: [
|
|
230
289
|
/* @__PURE__ */ a("strong", { children: s.title ?? s.id }),
|
|
231
290
|
/* @__PURE__ */ a("span", { className: "make-ai-artifact__record-values", children: e.data.columns.map((o) => /* @__PURE__ */ i("span", { children: [
|
|
232
291
|
/* @__PURE__ */ a("small", { children: o.label }),
|
|
233
|
-
|
|
292
|
+
te(
|
|
234
293
|
s.values[o.key],
|
|
235
294
|
o.format,
|
|
236
295
|
t.context.locale
|
|
@@ -243,7 +302,7 @@ const J = (e, t, s) => {
|
|
|
243
302
|
{
|
|
244
303
|
className: "make-ai-artifact__record",
|
|
245
304
|
type: "button",
|
|
246
|
-
onClick: () =>
|
|
305
|
+
onClick: () => Mt(r, {
|
|
247
306
|
artifact: e,
|
|
248
307
|
context: t.context
|
|
249
308
|
}, t),
|
|
@@ -257,91 +316,99 @@ const J = (e, t, s) => {
|
|
|
257
316
|
e.data.total,
|
|
258
317
|
" 条"
|
|
259
318
|
] }) : null,
|
|
260
|
-
|
|
319
|
+
me(e, t)
|
|
261
320
|
] }),
|
|
262
|
-
"make-ai-artifact--record-list"
|
|
263
|
-
|
|
321
|
+
"make-ai-artifact--record-list",
|
|
322
|
+
t.themeStyle
|
|
323
|
+
), da = ({
|
|
264
324
|
artifact: e,
|
|
265
325
|
renderContext: t
|
|
266
|
-
}) =>
|
|
326
|
+
}) => ue(
|
|
267
327
|
e,
|
|
268
|
-
/* @__PURE__ */ i(
|
|
328
|
+
/* @__PURE__ */ i(G, { children: [
|
|
269
329
|
/* @__PURE__ */ i("div", { className: `make-ai-artifact__notice make-ai-artifact__notice--${e.data.tone}`, children: [
|
|
270
330
|
/* @__PURE__ */ a("span", { "aria-hidden": "true", children: e.data.tone === "success" ? "✓" : e.data.tone === "warning" ? "!" : e.data.tone === "danger" ? "×" : "i" }),
|
|
271
331
|
/* @__PURE__ */ a("p", { children: e.data.body })
|
|
272
332
|
] }),
|
|
273
|
-
|
|
333
|
+
me(e, t)
|
|
274
334
|
] }),
|
|
275
|
-
"make-ai-artifact--notice"
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
335
|
+
"make-ai-artifact--notice",
|
|
336
|
+
t.themeStyle
|
|
337
|
+
), de = (e, t, s) => ({ id: e, kinds: [t], priority: 0, render: s }), ma = [
|
|
338
|
+
de("platform.metric.default", "metric", (e, t, s) => /* @__PURE__ */ a(na, { artifact: e, renderContext: s })),
|
|
339
|
+
de("platform.comparison.default", "comparison", (e, t, s) => /* @__PURE__ */ a(ra, { artifact: e, renderContext: s })),
|
|
340
|
+
de("platform.trend.default", "trend", (e, t, s) => /* @__PURE__ */ a(ia, { artifact: e, renderContext: s })),
|
|
341
|
+
de("platform.ranking.default", "ranking", (e, t, s) => /* @__PURE__ */ a(oa, { artifact: e, renderContext: s })),
|
|
342
|
+
de("platform.record-list.default", "record-list", (e, t, s) => /* @__PURE__ */ a(la, { artifact: e, renderContext: s })),
|
|
343
|
+
de("platform.notice.default", "notice", (e, t, s) => /* @__PURE__ */ a(da, { artifact: e, renderContext: s }))
|
|
344
|
+
], ua = It(ma).templates, ha = (e = ua) => It(e), pa = (e) => `${e}-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, fa = "Make", ga = [
|
|
284
345
|
"总结当前页面数据",
|
|
285
346
|
"找出需要关注的记录",
|
|
286
347
|
"列出我有权限查看的数据对象"
|
|
287
|
-
],
|
|
348
|
+
], Tt = (e, t) => t ?? `${e?.trim() || fa} AI 助手`, va = (e) => e ?? ga, _a = /^只读分析\s*[·•]\s*/u, ya = (e, t) => e?.trim().replace(_a, "").trim() || `当前对象:${t ?? "未命名应用"}`, ka = 432, xt = 1024, ba = 0.72, vt = 16, B = 16, ke = 8, We = (e, t, s) => Math.min(Math.max(e, Math.min(t, s)), s), wa = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : void 0, Ia = (e, t, s) => {
|
|
349
|
+
const r = Math.min(
|
|
350
|
+
xt,
|
|
351
|
+
s * ba
|
|
352
|
+
);
|
|
353
|
+
return Math.max(e, Math.min(t ?? r, s));
|
|
354
|
+
}, _t = (e, t, s) => Math.min(Math.max(e, t), Math.max(t, s)), Aa = (e, t, s, r) => {
|
|
288
355
|
const n = Math.min(
|
|
289
356
|
Math.max(t.width, 1),
|
|
290
|
-
Math.max(1, r -
|
|
357
|
+
Math.max(1, r - B * 2)
|
|
291
358
|
), o = Math.min(
|
|
292
359
|
Math.max(t.height, 1),
|
|
293
|
-
Math.max(1, s -
|
|
360
|
+
Math.max(1, s - B * 2)
|
|
294
361
|
), l = e.left + e.width / 2, m = e.top + e.height / 2, f = [
|
|
295
362
|
{
|
|
296
|
-
left: e.right +
|
|
363
|
+
left: e.right + ke,
|
|
297
364
|
placement: "right",
|
|
298
365
|
top: m - o / 2
|
|
299
366
|
},
|
|
300
367
|
{
|
|
301
|
-
left: e.left -
|
|
368
|
+
left: e.left - ke - n,
|
|
302
369
|
placement: "left",
|
|
303
370
|
top: m - o / 2
|
|
304
371
|
},
|
|
305
372
|
{
|
|
306
373
|
left: l - n / 2,
|
|
307
374
|
placement: "bottom",
|
|
308
|
-
top: e.bottom +
|
|
375
|
+
top: e.bottom + ke
|
|
309
376
|
},
|
|
310
377
|
{
|
|
311
378
|
left: l - n / 2,
|
|
312
379
|
placement: "top",
|
|
313
|
-
top: e.top -
|
|
380
|
+
top: e.top - ke - o
|
|
314
381
|
}
|
|
315
382
|
].find(
|
|
316
|
-
({ left:
|
|
383
|
+
({ left: N, top: T }) => N >= B && T >= B && N + n <= r - B && T + o <= s - B
|
|
317
384
|
);
|
|
318
385
|
return f || {
|
|
319
|
-
left:
|
|
386
|
+
left: _t(
|
|
320
387
|
l - n / 2,
|
|
321
|
-
|
|
322
|
-
r -
|
|
388
|
+
B,
|
|
389
|
+
r - B - n
|
|
323
390
|
),
|
|
324
391
|
placement: "bottom",
|
|
325
|
-
top:
|
|
326
|
-
e.bottom +
|
|
327
|
-
|
|
328
|
-
s -
|
|
392
|
+
top: _t(
|
|
393
|
+
e.bottom + ke,
|
|
394
|
+
B,
|
|
395
|
+
s - B - o
|
|
329
396
|
)
|
|
330
397
|
};
|
|
331
|
-
},
|
|
332
|
-
class
|
|
398
|
+
}, Na = (e) => typeof e == "number" ? Number.isFinite(e) ? `${e}px` : void 0 : e?.trim() || void 0;
|
|
399
|
+
class w extends Error {
|
|
333
400
|
}
|
|
334
|
-
const
|
|
401
|
+
const Le = (e, t) => {
|
|
335
402
|
if (!(typeof e != "object" || e === null))
|
|
336
403
|
return e[t];
|
|
337
|
-
},
|
|
338
|
-
const t =
|
|
339
|
-
return typeof t == "number" ? t :
|
|
340
|
-
|
|
404
|
+
}, Ma = (e) => {
|
|
405
|
+
const t = Le(e, "status");
|
|
406
|
+
return typeof t == "number" ? t : Le(
|
|
407
|
+
Le(e, "response"),
|
|
341
408
|
"status"
|
|
342
409
|
);
|
|
343
|
-
},
|
|
344
|
-
const t =
|
|
410
|
+
}, Ta = (e) => {
|
|
411
|
+
const t = Le(e, "code"), s = Ma(e), r = e instanceof Error ? e.message : "", n = [t, r].filter((_) => typeof _ == "string").join(" ").toLowerCase(), l = globalThis.navigator?.onLine === !1 || /network|fetch|timeout|offline|connection|网络|连接|超时/.test(n), m = typeof s == "number" && s >= 500 || /server|service|服务器|服务异常/.test(n);
|
|
345
412
|
return l ? {
|
|
346
413
|
actionLabel: "重新连接",
|
|
347
414
|
description: "请检查网络后再试。",
|
|
@@ -361,7 +428,7 @@ const Ce = (e, t) => {
|
|
|
361
428
|
label: "加载异常",
|
|
362
429
|
title: "暂时无法加载对话"
|
|
363
430
|
};
|
|
364
|
-
},
|
|
431
|
+
}, yt = (e) => {
|
|
365
432
|
try {
|
|
366
433
|
const t = e?.return?.();
|
|
367
434
|
if (!t) return;
|
|
@@ -375,7 +442,7 @@ const Ce = (e, t) => {
|
|
|
375
442
|
errorType: t instanceof Error ? t.name : typeof t
|
|
376
443
|
});
|
|
377
444
|
}
|
|
378
|
-
},
|
|
445
|
+
}, xa = async (e) => {
|
|
379
446
|
if (globalThis.navigator?.clipboard?.writeText) {
|
|
380
447
|
await globalThis.navigator.clipboard.writeText(e);
|
|
381
448
|
return;
|
|
@@ -387,63 +454,63 @@ const Ce = (e, t) => {
|
|
|
387
454
|
const s = document.execCommand("copy");
|
|
388
455
|
if (t.remove(), !s)
|
|
389
456
|
throw new Error("Clipboard copy failed");
|
|
390
|
-
},
|
|
457
|
+
}, Et = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
391
458
|
/* @__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" }),
|
|
392
459
|
/* @__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" })
|
|
393
|
-
] }),
|
|
460
|
+
] }), Ea = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "m6 6 12 12M18 6 6 18" }) }), Ra = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
394
461
|
/* @__PURE__ */ a("path", { d: "M8 8h10v12H8z" }),
|
|
395
462
|
/* @__PURE__ */ a("path", { d: "M6 16H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
|
|
396
|
-
] }),
|
|
463
|
+
] }), Ca = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
397
464
|
/* @__PURE__ */ a("path", { d: "M20 11a8 8 0 0 0-14.7-4.4L4 8" }),
|
|
398
465
|
/* @__PURE__ */ a("path", { d: "M4 4v4h4" }),
|
|
399
466
|
/* @__PURE__ */ a("path", { d: "M4 13a8 8 0 0 0 14.7 4.4L20 16" }),
|
|
400
467
|
/* @__PURE__ */ a("path", { d: "M20 20v-4h-4" })
|
|
401
|
-
] }),
|
|
468
|
+
] }), Sa = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
402
469
|
/* @__PURE__ */ a("circle", { cx: "12", cy: "12", r: "8" }),
|
|
403
470
|
/* @__PURE__ */ a("path", { d: "M9.8 9.4a2.35 2.35 0 1 1 3.93 1.73c-.96.86-1.73 1.42-1.73 2.87" }),
|
|
404
471
|
/* @__PURE__ */ a("path", { d: "M12 17h.01" })
|
|
405
|
-
] }),
|
|
472
|
+
] }), $a = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
406
473
|
/* @__PURE__ */ a("path", { d: "M12 4v11" }),
|
|
407
474
|
/* @__PURE__ */ a("path", { d: "m7 10 5 5 5-5" }),
|
|
408
475
|
/* @__PURE__ */ a("path", { d: "M5 20h14" })
|
|
409
|
-
] }),
|
|
476
|
+
] }), La = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "M12 5v14M5 12h14" }) }), Da = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
410
477
|
/* @__PURE__ */ a("path", { d: "m4 4 17 8-17 8 3-8-3-8Z" }),
|
|
411
478
|
/* @__PURE__ */ a("path", { d: "M7 12h14" })
|
|
412
|
-
] }),
|
|
479
|
+
] }), Rt = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
413
480
|
/* @__PURE__ */ a("path", { d: "M20 11a8 8 0 0 0-14.7-4.4L4 8" }),
|
|
414
481
|
/* @__PURE__ */ a("path", { d: "M4 4v4h4" }),
|
|
415
482
|
/* @__PURE__ */ a("path", { d: "M4 13a8 8 0 0 0 14.7 4.4L20 16" }),
|
|
416
483
|
/* @__PURE__ */ a("path", { d: "M20 20v-4h-4" })
|
|
417
|
-
] }),
|
|
484
|
+
] }), Fa = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
|
|
418
485
|
/* @__PURE__ */ a("circle", { cx: "12", cy: "12", r: "8" }),
|
|
419
486
|
/* @__PURE__ */ a("path", { d: "M12 8v4.5" }),
|
|
420
487
|
/* @__PURE__ */ a("path", { d: "M12 16h.01" })
|
|
421
|
-
] }),
|
|
488
|
+
] }), De = ({ className: e = "" }) => /* @__PURE__ */ a("span", { className: `make-ai-assistant__avatar ${e}`.trim(), "aria-hidden": "true", children: /* @__PURE__ */ a(Et, {}) }), Pa = ({ src: e }) => e ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__user-avatar", "aria-hidden": "true", children: /* @__PURE__ */ a("img", { alt: "", src: e }) }) : null, Wa = ({
|
|
422
489
|
userAvatarUrl: e,
|
|
423
490
|
userName: t
|
|
424
491
|
}) => {
|
|
425
492
|
const s = t?.trim();
|
|
426
493
|
return !s && !e ? null : /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-identity", children: [
|
|
427
494
|
s ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: s }) : null,
|
|
428
|
-
/* @__PURE__ */ a(
|
|
495
|
+
/* @__PURE__ */ a(Pa, { src: e })
|
|
429
496
|
] });
|
|
430
|
-
},
|
|
497
|
+
}, He = (e) => {
|
|
431
498
|
const t = e.trim();
|
|
432
499
|
if (!(!t.startsWith("|") || !t.endsWith("|")))
|
|
433
500
|
return t.slice(1, -1).split("|").map((s) => s.trim());
|
|
434
|
-
},
|
|
435
|
-
const s =
|
|
436
|
-
if (!s || !r || s.length !== r.length || !
|
|
501
|
+
}, Ha = (e) => e.length > 0 && e.every((t) => /^:?-{3,}:?$/.test(t)), Ba = (e, t) => {
|
|
502
|
+
const s = He(e[t] ?? ""), r = He(e[t + 1] ?? "");
|
|
503
|
+
if (!s || !r || s.length !== r.length || !Ha(r))
|
|
437
504
|
return;
|
|
438
505
|
const n = [];
|
|
439
506
|
let o = t + 2;
|
|
440
507
|
for (; o < e.length; ) {
|
|
441
|
-
const l =
|
|
508
|
+
const l = He(e[o] ?? "");
|
|
442
509
|
if (!l || l.length !== s.length) break;
|
|
443
510
|
n.push(l), o += 1;
|
|
444
511
|
}
|
|
445
512
|
return { headers: s, lastIndex: o - 1, rows: n };
|
|
446
|
-
},
|
|
513
|
+
}, Oa = (e) => {
|
|
447
514
|
const t = [], s = [], r = [], n = [], o = e.replace(/\r\n?/g, `
|
|
448
515
|
`).split(`
|
|
449
516
|
`), l = () => {
|
|
@@ -452,46 +519,46 @@ const Ce = (e, t) => {
|
|
|
452
519
|
s.length = 0, f && t.push({ type: "paragraph", text: f });
|
|
453
520
|
}, m = () => {
|
|
454
521
|
r.length && t.push({ type: "list", items: r.splice(0) });
|
|
455
|
-
},
|
|
522
|
+
}, _ = () => {
|
|
456
523
|
const f = n.join(`
|
|
457
524
|
`).trim();
|
|
458
525
|
n.length = 0, f && t.push({ type: "pre", text: f });
|
|
459
526
|
};
|
|
460
527
|
for (let f = 0; f < o.length; f += 1) {
|
|
461
|
-
const
|
|
528
|
+
const N = o[f] ?? "", T = N.trim();
|
|
462
529
|
if (!T) {
|
|
463
|
-
l(), m(),
|
|
530
|
+
l(), m(), _();
|
|
464
531
|
continue;
|
|
465
532
|
}
|
|
466
|
-
const
|
|
467
|
-
if (
|
|
468
|
-
l(), m(),
|
|
533
|
+
const $ = Ba(o, f);
|
|
534
|
+
if ($) {
|
|
535
|
+
l(), m(), _(), t.push({ headers: $.headers, rows: $.rows, type: "table" }), f = $.lastIndex;
|
|
469
536
|
continue;
|
|
470
537
|
}
|
|
471
|
-
const
|
|
472
|
-
if (
|
|
473
|
-
l(), m(),
|
|
474
|
-
const
|
|
475
|
-
|
|
538
|
+
const D = /^(#{1,6})\s+(.+)$/.exec(T);
|
|
539
|
+
if (D) {
|
|
540
|
+
l(), m(), _();
|
|
541
|
+
const C = (D[2] ?? "").replace(/\s+#+\s*$/, "").trim();
|
|
542
|
+
C && t.push({
|
|
476
543
|
type: "heading",
|
|
477
|
-
level:
|
|
478
|
-
text:
|
|
544
|
+
level: D[1]?.length,
|
|
545
|
+
text: C
|
|
479
546
|
});
|
|
480
547
|
continue;
|
|
481
548
|
}
|
|
482
|
-
if (/^\s*\|.+\|\s*$/.test(
|
|
483
|
-
l(), m(), n.push(
|
|
549
|
+
if (/^\s*\|.+\|\s*$/.test(N)) {
|
|
550
|
+
l(), m(), n.push(N.trim());
|
|
484
551
|
continue;
|
|
485
552
|
}
|
|
486
|
-
const
|
|
487
|
-
if (
|
|
488
|
-
l(),
|
|
553
|
+
const b = /^\s*[-*]\s+(.+)$/.exec(N);
|
|
554
|
+
if (b) {
|
|
555
|
+
l(), _(), r.push(b[1]?.trim() ?? "");
|
|
489
556
|
continue;
|
|
490
557
|
}
|
|
491
|
-
m(),
|
|
558
|
+
m(), _(), s.push(T);
|
|
492
559
|
}
|
|
493
|
-
return l(), m(),
|
|
494
|
-
},
|
|
560
|
+
return l(), m(), _(), t;
|
|
561
|
+
}, be = (e) => {
|
|
495
562
|
const t = [], s = /(\*\*[^*]+\*\*|`[^`]+`)/g;
|
|
496
563
|
let r = 0;
|
|
497
564
|
for (const n of e.matchAll(s)) {
|
|
@@ -499,8 +566,8 @@ const Ce = (e, t) => {
|
|
|
499
566
|
l > r && t.push(e.slice(r, l)), o.startsWith("**") ? t.push(/* @__PURE__ */ a("strong", { children: o.slice(2, -2) }, `${l}-strong`)) : t.push(/* @__PURE__ */ a("code", { children: o.slice(1, -1) }, `${l}-code`)), r = l + o.length;
|
|
500
567
|
}
|
|
501
568
|
return r < e.length && t.push(e.slice(r)), t;
|
|
502
|
-
},
|
|
503
|
-
const t =
|
|
569
|
+
}, za = ({ content: e }) => {
|
|
570
|
+
const t = Oa(e);
|
|
504
571
|
return t.length ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble make-ai-assistant__assistant-text", children: t.map((s, r) => {
|
|
505
572
|
if (s.type === "heading") {
|
|
506
573
|
const n = s.level <= 2 ? "h3" : "h4";
|
|
@@ -508,12 +575,12 @@ const Ce = (e, t) => {
|
|
|
508
575
|
n,
|
|
509
576
|
{
|
|
510
577
|
className: `make-ai-assistant__markdown-heading make-ai-assistant__markdown-heading--${s.level}`,
|
|
511
|
-
children:
|
|
578
|
+
children: be(s.text)
|
|
512
579
|
},
|
|
513
580
|
`${r}-heading`
|
|
514
581
|
);
|
|
515
582
|
}
|
|
516
|
-
return s.type === "paragraph" ? /* @__PURE__ */ a("p", { children:
|
|
583
|
+
return s.type === "paragraph" ? /* @__PURE__ */ a("p", { children: be(s.text) }, `${r}-paragraph`) : s.type === "pre" ? /* @__PURE__ */ a("pre", { children: /* @__PURE__ */ a("code", { children: s.text }) }, `${r}-pre`) : s.type === "table" ? /* @__PURE__ */ a(
|
|
517
584
|
"div",
|
|
518
585
|
{
|
|
519
586
|
"aria-label": "表格内容,可横向滚动",
|
|
@@ -521,46 +588,46 @@ const Ce = (e, t) => {
|
|
|
521
588
|
role: "region",
|
|
522
589
|
tabIndex: 0,
|
|
523
590
|
children: /* @__PURE__ */ i("table", { className: "make-ai-assistant__markdown-table", children: [
|
|
524
|
-
/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: s.headers.map((n, o) => /* @__PURE__ */ a("th", { scope: "col", children:
|
|
525
|
-
/* @__PURE__ */ a("tbody", { children: s.rows.map((n, o) => /* @__PURE__ */ a("tr", { children: n.map((l, m) => /* @__PURE__ */ a("td", { children:
|
|
591
|
+
/* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: s.headers.map((n, o) => /* @__PURE__ */ a("th", { scope: "col", children: be(n) }, `${o}-${n}`)) }) }),
|
|
592
|
+
/* @__PURE__ */ a("tbody", { children: s.rows.map((n, o) => /* @__PURE__ */ a("tr", { children: n.map((l, m) => /* @__PURE__ */ a("td", { children: be(l) }, `${m}-${l}`)) }, `${o}-${n.join("|")}`)) })
|
|
526
593
|
] })
|
|
527
594
|
},
|
|
528
595
|
`${r}-table`
|
|
529
|
-
) : /* @__PURE__ */ a("ul", { children: s.items.map((n, o) => /* @__PURE__ */ a("li", { children:
|
|
596
|
+
) : /* @__PURE__ */ a("ul", { children: s.items.map((n, o) => /* @__PURE__ */ a("li", { children: be(n) }, `${o}-${n}`)) }, `${r}-list`);
|
|
530
597
|
}) }) : null;
|
|
531
|
-
},
|
|
532
|
-
/* @__PURE__ */ a(
|
|
598
|
+
}, Ct = ({ assistantName: e }) => /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-identity", children: [
|
|
599
|
+
/* @__PURE__ */ a(De, { className: "make-ai-assistant__avatar--message" }),
|
|
533
600
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: e })
|
|
534
|
-
] }),
|
|
601
|
+
] }), St = (e) => {
|
|
535
602
|
for (let t = e.messages.length - 1; t >= 0; t -= 1) {
|
|
536
603
|
const s = e.messages[t];
|
|
537
604
|
if (s.role === "assistant" && s.status === "streaming")
|
|
538
605
|
return s.id;
|
|
539
606
|
}
|
|
540
|
-
},
|
|
607
|
+
}, Ua = (e) => {
|
|
541
608
|
for (let t = e.messages.length - 1; t >= 0; t -= 1)
|
|
542
609
|
if (e.messages[t].role === "user") return t;
|
|
543
610
|
return -1;
|
|
544
|
-
},
|
|
545
|
-
const t =
|
|
611
|
+
}, $t = (e) => {
|
|
612
|
+
const t = Ua(e);
|
|
546
613
|
if (!(t < 0))
|
|
547
614
|
for (let s = e.messages.length - 1; s > t; s -= 1) {
|
|
548
615
|
const r = e.messages[s];
|
|
549
616
|
if (r.role === "assistant") return r.id;
|
|
550
617
|
}
|
|
551
|
-
},
|
|
618
|
+
}, Va = (e) => {
|
|
552
619
|
if (e.status === "idle")
|
|
553
620
|
for (let t = e.messages.length - 1; t >= 0; t -= 1) {
|
|
554
621
|
const s = e.messages[t];
|
|
555
622
|
if (s.role === "assistant" && s.status === "complete")
|
|
556
623
|
return s.id;
|
|
557
624
|
}
|
|
558
|
-
},
|
|
625
|
+
}, qa = (e) => {
|
|
559
626
|
for (let t = e.messages.length - 1; t >= 0; t -= 1) {
|
|
560
627
|
const s = e.messages[t];
|
|
561
628
|
if (s.role === "user") return s;
|
|
562
629
|
}
|
|
563
|
-
},
|
|
630
|
+
}, Ka = (e, t) => {
|
|
564
631
|
const s = e.messages.findIndex(
|
|
565
632
|
(r) => r.id === t && r.role === "user"
|
|
566
633
|
);
|
|
@@ -571,9 +638,9 @@ const Ce = (e, t) => {
|
|
|
571
638
|
status: "streaming",
|
|
572
639
|
messages: s < 0 ? e.messages : e.messages.slice(0, s + 1)
|
|
573
640
|
};
|
|
574
|
-
},
|
|
641
|
+
}, ja = (e) => e.scrollHeight - e.scrollTop - e.clientHeight <= 48, kt = (e = "smooth") => globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : e, Be = (e, t) => {
|
|
575
642
|
typeof e.scrollTo == "function" ? e.scrollTo({ top: e.scrollHeight, behavior: t }) : e.scrollTop = e.scrollHeight;
|
|
576
|
-
},
|
|
643
|
+
}, Lt = ({
|
|
577
644
|
error: e,
|
|
578
645
|
onRetry: t
|
|
579
646
|
}) => /* @__PURE__ */ i(
|
|
@@ -584,7 +651,7 @@ const Ce = (e, t) => {
|
|
|
584
651
|
role: "alert",
|
|
585
652
|
children: [
|
|
586
653
|
/* @__PURE__ */ i("div", { className: "make-ai-assistant__message-status-header", children: [
|
|
587
|
-
/* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-icon", "aria-hidden": "true", children: /* @__PURE__ */ a(
|
|
654
|
+
/* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-icon", "aria-hidden": "true", children: /* @__PURE__ */ a(Fa, {}) }),
|
|
588
655
|
/* @__PURE__ */ a("strong", { children: "请求未完成" })
|
|
589
656
|
] }),
|
|
590
657
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-message", children: e.message }),
|
|
@@ -595,18 +662,18 @@ const Ce = (e, t) => {
|
|
|
595
662
|
type: "button",
|
|
596
663
|
onClick: t,
|
|
597
664
|
children: [
|
|
598
|
-
/* @__PURE__ */ a(
|
|
665
|
+
/* @__PURE__ */ a(Rt, {}),
|
|
599
666
|
"重新发送"
|
|
600
667
|
]
|
|
601
668
|
}
|
|
602
669
|
) : null
|
|
603
670
|
]
|
|
604
671
|
}
|
|
605
|
-
),
|
|
672
|
+
), Xa = ({
|
|
606
673
|
error: e,
|
|
607
674
|
onRetry: t
|
|
608
675
|
}) => {
|
|
609
|
-
const s =
|
|
676
|
+
const s = Ta(e);
|
|
610
677
|
return /* @__PURE__ */ i(
|
|
611
678
|
"section",
|
|
612
679
|
{
|
|
@@ -631,7 +698,7 @@ const Ce = (e, t) => {
|
|
|
631
698
|
type: "button",
|
|
632
699
|
onClick: t,
|
|
633
700
|
children: [
|
|
634
|
-
/* @__PURE__ */ a(
|
|
701
|
+
/* @__PURE__ */ a(Rt, {}),
|
|
635
702
|
s.actionLabel
|
|
636
703
|
]
|
|
637
704
|
}
|
|
@@ -639,7 +706,7 @@ const Ce = (e, t) => {
|
|
|
639
706
|
]
|
|
640
707
|
}
|
|
641
708
|
);
|
|
642
|
-
},
|
|
709
|
+
}, Dt = ({
|
|
643
710
|
active: e,
|
|
644
711
|
steps: t
|
|
645
712
|
}) => {
|
|
@@ -668,7 +735,7 @@ const Ce = (e, t) => {
|
|
|
668
735
|
`${n}-${r}`
|
|
669
736
|
)) })
|
|
670
737
|
] });
|
|
671
|
-
},
|
|
738
|
+
}, Ya = ({
|
|
672
739
|
copyFeedback: e,
|
|
673
740
|
onCopy: t,
|
|
674
741
|
onRegenerate: s
|
|
@@ -681,7 +748,7 @@ const Ce = (e, t) => {
|
|
|
681
748
|
"data-tooltip": "复制",
|
|
682
749
|
type: "button",
|
|
683
750
|
onClick: t,
|
|
684
|
-
children: /* @__PURE__ */ a(
|
|
751
|
+
children: /* @__PURE__ */ a(Ra, {})
|
|
685
752
|
}
|
|
686
753
|
) : null,
|
|
687
754
|
s ? /* @__PURE__ */ a(
|
|
@@ -692,7 +759,7 @@ const Ce = (e, t) => {
|
|
|
692
759
|
"data-tooltip": "重新生成",
|
|
693
760
|
type: "button",
|
|
694
761
|
onClick: s,
|
|
695
|
-
children: /* @__PURE__ */ a(
|
|
762
|
+
children: /* @__PURE__ */ a(Ca, {})
|
|
696
763
|
}
|
|
697
764
|
) : null,
|
|
698
765
|
e ? /* @__PURE__ */ a(
|
|
@@ -704,7 +771,7 @@ const Ce = (e, t) => {
|
|
|
704
771
|
children: e.message
|
|
705
772
|
}
|
|
706
773
|
) : null
|
|
707
|
-
] }),
|
|
774
|
+
] }), bt = ({
|
|
708
775
|
assistantName: e,
|
|
709
776
|
error: t,
|
|
710
777
|
onRetry: s,
|
|
@@ -719,82 +786,83 @@ const Ce = (e, t) => {
|
|
|
719
786
|
"data-message-role": "assistant",
|
|
720
787
|
"data-message-state": n,
|
|
721
788
|
children: /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-turn", children: [
|
|
722
|
-
/* @__PURE__ */ a(
|
|
723
|
-
/* @__PURE__ */ a("div", { className: "make-ai-assistant__message-stack", children: t ? /* @__PURE__ */ a(
|
|
789
|
+
/* @__PURE__ */ a(Ct, { assistantName: e }),
|
|
790
|
+
/* @__PURE__ */ a("div", { className: "make-ai-assistant__message-stack", children: t ? /* @__PURE__ */ a(Lt, { error: t, onRetry: s }) : /* @__PURE__ */ a(Dt, { active: !0, steps: r?.steps }) })
|
|
724
791
|
] })
|
|
725
792
|
}
|
|
726
793
|
) : null;
|
|
727
|
-
},
|
|
728
|
-
const
|
|
729
|
-
let
|
|
730
|
-
return e.messages.map((
|
|
731
|
-
const
|
|
732
|
-
|
|
733
|
-
const A =
|
|
794
|
+
}, Ga = (e, t, s, r, n, o, l, m, _, f, N, T, $, D) => {
|
|
795
|
+
const b = $t(e), C = St(e), V = Va(e);
|
|
796
|
+
let x;
|
|
797
|
+
return e.messages.map((h) => {
|
|
798
|
+
const I = h.role === "assistant", q = x;
|
|
799
|
+
I || (x = h);
|
|
800
|
+
const A = h.id === C, Z = h.id === b ? e.error : void 0, F = h.error ?? Z, P = !I && !!(_?.trim() || f), O = I ? l : _?.trim() || "用户", p = I && h.status === "complete" && !F && (h.content.trim() || h.id === V);
|
|
734
801
|
return /* @__PURE__ */ a(
|
|
735
802
|
"article",
|
|
736
803
|
{
|
|
737
|
-
"aria-label": `${
|
|
738
|
-
className: `make-ai-assistant__message make-ai-assistant__message--${
|
|
739
|
-
"data-message-role":
|
|
740
|
-
"data-message-state":
|
|
741
|
-
"data-message-status":
|
|
742
|
-
"data-message-has-identity":
|
|
804
|
+
"aria-label": `${O}的消息`,
|
|
805
|
+
className: `make-ai-assistant__message make-ai-assistant__message--${h.role}`,
|
|
806
|
+
"data-message-role": h.role,
|
|
807
|
+
"data-message-state": F ? "error" : void 0,
|
|
808
|
+
"data-message-status": h.status,
|
|
809
|
+
"data-message-has-identity": I || P ? !0 : void 0,
|
|
743
810
|
children: /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-turn", children: [
|
|
744
|
-
|
|
811
|
+
I ? /* @__PURE__ */ a(Ct, { assistantName: l }) : P ? /* @__PURE__ */ a(Wa, { userAvatarUrl: f, userName: _ }) : null,
|
|
745
812
|
/* @__PURE__ */ i("div", { className: "make-ai-assistant__message-stack", children: [
|
|
746
|
-
|
|
813
|
+
h.content ? I ? /* @__PURE__ */ a(za, { content: h.content }) : /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble", children: h.content }) : h.status === "streaming" ? /* @__PURE__ */ i("div", { className: "make-ai-assistant__typing", "aria-label": `${l}正在思考`, children: [
|
|
747
814
|
/* @__PURE__ */ a("span", {}),
|
|
748
815
|
/* @__PURE__ */ a("span", {}),
|
|
749
816
|
/* @__PURE__ */ a("span", {})
|
|
750
817
|
] }) : null,
|
|
751
|
-
|
|
752
|
-
|
|
818
|
+
I ? /* @__PURE__ */ a(
|
|
819
|
+
Dt,
|
|
753
820
|
{
|
|
754
821
|
active: A && e.status === "streaming",
|
|
755
|
-
steps:
|
|
822
|
+
steps: h.progressSteps
|
|
756
823
|
}
|
|
757
824
|
) : null,
|
|
758
|
-
|
|
759
|
-
|
|
825
|
+
F ? /* @__PURE__ */ a(
|
|
826
|
+
Lt,
|
|
760
827
|
{
|
|
761
|
-
error:
|
|
762
|
-
onRetry:
|
|
828
|
+
error: F,
|
|
829
|
+
onRetry: Z ? m : void 0
|
|
763
830
|
}
|
|
764
831
|
) : null,
|
|
765
|
-
|
|
766
|
-
|
|
832
|
+
h.artifacts.map((S) => /* @__PURE__ */ a(
|
|
833
|
+
sa,
|
|
767
834
|
{
|
|
768
|
-
artifact:
|
|
835
|
+
artifact: S,
|
|
769
836
|
context: t,
|
|
770
|
-
onAction:
|
|
771
|
-
onActionError:
|
|
772
|
-
registry: s
|
|
837
|
+
onAction: n,
|
|
838
|
+
onActionError: o,
|
|
839
|
+
registry: s,
|
|
840
|
+
theme: r
|
|
773
841
|
},
|
|
774
|
-
|
|
842
|
+
S.id
|
|
775
843
|
)),
|
|
776
|
-
|
|
777
|
-
|
|
844
|
+
p ? /* @__PURE__ */ a(
|
|
845
|
+
Ya,
|
|
778
846
|
{
|
|
779
|
-
copyFeedback:
|
|
780
|
-
message:
|
|
781
|
-
status:
|
|
847
|
+
copyFeedback: N?.messageId === h.id ? {
|
|
848
|
+
message: N.message,
|
|
849
|
+
status: N.status
|
|
782
850
|
} : void 0,
|
|
783
|
-
onCopy:
|
|
784
|
-
onRegenerate:
|
|
785
|
-
userMessage:
|
|
786
|
-
assistantMessage:
|
|
851
|
+
onCopy: h.content.trim() ? () => $(h.id, h.content) : void 0,
|
|
852
|
+
onRegenerate: T && h.id === V && q ? () => D({
|
|
853
|
+
userMessage: q,
|
|
854
|
+
assistantMessage: h
|
|
787
855
|
}) : void 0
|
|
788
856
|
}
|
|
789
857
|
) : null
|
|
790
858
|
] })
|
|
791
859
|
] })
|
|
792
860
|
},
|
|
793
|
-
|
|
861
|
+
h.id
|
|
794
862
|
);
|
|
795
863
|
});
|
|
796
864
|
};
|
|
797
|
-
function
|
|
865
|
+
function Ft({
|
|
798
866
|
assistantName: e = "AI 助手",
|
|
799
867
|
brandName: t,
|
|
800
868
|
context: s,
|
|
@@ -803,359 +871,363 @@ function Mt({
|
|
|
803
871
|
onClose: o,
|
|
804
872
|
onNewConversation: l,
|
|
805
873
|
headerHeight: m,
|
|
806
|
-
privacyNotice:
|
|
874
|
+
privacyNotice: _,
|
|
807
875
|
registry: f,
|
|
808
|
-
subtitle:
|
|
876
|
+
subtitle: N,
|
|
809
877
|
suggestions: T,
|
|
810
|
-
title:
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
878
|
+
title: $,
|
|
879
|
+
theme: D,
|
|
880
|
+
transport: b,
|
|
881
|
+
userAvatarUrl: C,
|
|
882
|
+
userName: V,
|
|
883
|
+
visible: x
|
|
815
884
|
}) {
|
|
816
|
-
const
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
885
|
+
const h = Tt(t, $), I = _?.trim(), q = ya(N, s.app.name), A = Na(m), Z = Oe(D), F = Z || A ? {
|
|
886
|
+
...Z,
|
|
887
|
+
...A ? { "--make-ai-internal-header-height": A } : {}
|
|
888
|
+
} : void 0, [P, O] = E(""), [p, S] = E(Ce), K = M(p);
|
|
889
|
+
K.current = p;
|
|
890
|
+
const [ae, Q] = E(void 0), [we, J] = E(void 0), [he, Ie] = E(0), [u, y] = E(() => b.loadConversation ? "loading" : "ready"), [z, se] = E(void 0), [Pt, j] = E(!1), [ne, ze] = E(!1), [pe, Ue] = E(void 0), re = M(void 0), ie = M(void 0), oe = M(0), Ve = M(null), fe = M(null), qe = M(null), Ke = M(null), je = M(null), Xe = M(null), X = M(!0), Ye = M(s.app.id), Ge = M(x), Ze = Qt(), Qe = ft(
|
|
891
|
+
() => f ?? ha(),
|
|
820
892
|
[f]
|
|
821
|
-
),
|
|
822
|
-
() =>
|
|
893
|
+
), Je = ft(
|
|
894
|
+
() => va(T),
|
|
823
895
|
[T]
|
|
824
|
-
),
|
|
825
|
-
const c =
|
|
826
|
-
if (!c || !
|
|
827
|
-
const
|
|
896
|
+
), et = () => {
|
|
897
|
+
const c = Ke.current, v = je.current;
|
|
898
|
+
if (!c || !v || typeof window > "u") return;
|
|
899
|
+
const g = Aa(
|
|
828
900
|
c.getBoundingClientRect(),
|
|
829
|
-
|
|
901
|
+
v.getBoundingClientRect(),
|
|
830
902
|
window.innerHeight,
|
|
831
903
|
window.innerWidth
|
|
832
904
|
);
|
|
833
|
-
|
|
834
|
-
(
|
|
905
|
+
Ue(
|
|
906
|
+
(k) => k?.left === g.left && k.top === g.top && k.placement === g.placement ? k : g
|
|
835
907
|
);
|
|
836
|
-
},
|
|
837
|
-
left: `${
|
|
838
|
-
top: `${
|
|
908
|
+
}, tt = () => ze(!0), at = () => ze(!1), Wt = pe ? {
|
|
909
|
+
left: `${pe.left}px`,
|
|
910
|
+
top: `${pe.top}px`
|
|
839
911
|
} : void 0;
|
|
840
|
-
|
|
841
|
-
if (!
|
|
842
|
-
|
|
912
|
+
wt(() => {
|
|
913
|
+
if (!ne || !I) {
|
|
914
|
+
Ue(void 0);
|
|
843
915
|
return;
|
|
844
916
|
}
|
|
845
|
-
|
|
846
|
-
}, [
|
|
847
|
-
if (!
|
|
848
|
-
const c = () =>
|
|
917
|
+
et();
|
|
918
|
+
}, [ne, I]), ee(() => {
|
|
919
|
+
if (!ne || !I) return;
|
|
920
|
+
const c = () => et();
|
|
849
921
|
return window.addEventListener("resize", c), window.addEventListener("scroll", c, !0), () => {
|
|
850
922
|
window.removeEventListener("resize", c), window.removeEventListener("scroll", c, !0);
|
|
851
923
|
};
|
|
852
|
-
}, [
|
|
853
|
-
const
|
|
854
|
-
const
|
|
855
|
-
return !
|
|
924
|
+
}, [ne, I]);
|
|
925
|
+
const Ae = (c) => {
|
|
926
|
+
const v = re.current, g = ie.current?.iterator;
|
|
927
|
+
return !v && !g ? !1 : (oe.current += 1, re.current = void 0, ie.current = void 0, console.info("[make-ai-assistant] local run cancellation requested", { reason: c }), v?.abort(), yt(g), !0);
|
|
856
928
|
};
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
}, []),
|
|
860
|
-
const c =
|
|
861
|
-
if (
|
|
862
|
-
|
|
929
|
+
ee(() => () => {
|
|
930
|
+
Ae("unmount");
|
|
931
|
+
}, []), ee(() => {
|
|
932
|
+
const c = b.loadConversation, v = Ye.current !== s.app.id;
|
|
933
|
+
if (Ye.current = s.app.id, Ae("reinitialize"), v && (O(""), X.current = !0), Q(void 0), J(void 0), j(!1), S(Ce()), !c) {
|
|
934
|
+
se(void 0), y("ready");
|
|
863
935
|
return;
|
|
864
936
|
}
|
|
865
|
-
const
|
|
866
|
-
return
|
|
937
|
+
const g = new AbortController();
|
|
938
|
+
return se(void 0), y("loading"), console.info("[make-ai-assistant] conversation load start", {
|
|
867
939
|
appId: s.app.id
|
|
868
|
-
}), c.call(
|
|
869
|
-
|
|
940
|
+
}), c.call(b, s, { signal: g.signal }).then((k) => {
|
|
941
|
+
g.signal.aborted || (S(Ce(k)), y("ready"), console.info("[make-ai-assistant] conversation load success", {
|
|
870
942
|
appId: s.app.id,
|
|
871
|
-
messageCount:
|
|
943
|
+
messageCount: k.messages.length
|
|
872
944
|
}));
|
|
873
|
-
}).catch((
|
|
874
|
-
|
|
945
|
+
}).catch((k) => {
|
|
946
|
+
g.signal.aborted || (console.error("[make-ai-assistant] conversation load failed", {
|
|
875
947
|
appId: s.app.id,
|
|
876
|
-
errorType:
|
|
877
|
-
}),
|
|
878
|
-
}), () =>
|
|
879
|
-
}, [s.app.id,
|
|
880
|
-
const c =
|
|
881
|
-
if (!c || !
|
|
882
|
-
|
|
883
|
-
const
|
|
884
|
-
if (!
|
|
885
|
-
const
|
|
886
|
-
|
|
948
|
+
errorType: k instanceof Error ? k.name : typeof k
|
|
949
|
+
}), se(k), y("error"));
|
|
950
|
+
}), () => g.abort();
|
|
951
|
+
}, [s.app.id, he, b]), ee(() => {
|
|
952
|
+
const c = fe.current;
|
|
953
|
+
if (!c || !X.current) return;
|
|
954
|
+
j(!1);
|
|
955
|
+
const v = requestAnimationFrame(() => {
|
|
956
|
+
if (!X.current) return;
|
|
957
|
+
const g = p.status === "streaming" || globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
|
|
958
|
+
Be(c, g);
|
|
887
959
|
});
|
|
888
|
-
return () => cancelAnimationFrame(
|
|
889
|
-
}, [
|
|
890
|
-
const c =
|
|
891
|
-
if (
|
|
892
|
-
const
|
|
893
|
-
const
|
|
894
|
-
if (
|
|
895
|
-
|
|
896
|
-
const
|
|
897
|
-
|
|
898
|
-
} else
|
|
899
|
-
const
|
|
900
|
-
(
|
|
960
|
+
return () => cancelAnimationFrame(v);
|
|
961
|
+
}, [p.messages, p.progress, p.status]), ee(() => {
|
|
962
|
+
const c = x && !Ge.current;
|
|
963
|
+
if (Ge.current = x, !c) return;
|
|
964
|
+
const v = requestAnimationFrame(() => {
|
|
965
|
+
const g = fe.current;
|
|
966
|
+
if (g && X.current) {
|
|
967
|
+
j(!1);
|
|
968
|
+
const ge = K.current.status === "streaming" ? "auto" : kt();
|
|
969
|
+
Be(g, ge);
|
|
970
|
+
} else g && j(K.current.messages.length > 0);
|
|
971
|
+
const k = qe.current;
|
|
972
|
+
(k && !k.disabled ? k : Xe.current ?? Ve.current?.querySelector("button:not(:disabled)"))?.focus();
|
|
901
973
|
});
|
|
902
|
-
return () => cancelAnimationFrame(
|
|
903
|
-
}, [
|
|
904
|
-
const
|
|
905
|
-
const c =
|
|
974
|
+
return () => cancelAnimationFrame(v);
|
|
975
|
+
}, [x]);
|
|
976
|
+
const Ht = () => {
|
|
977
|
+
const c = fe.current;
|
|
906
978
|
if (!c) return;
|
|
907
|
-
const
|
|
908
|
-
|
|
909
|
-
},
|
|
910
|
-
const c =
|
|
979
|
+
const v = ja(c);
|
|
980
|
+
X.current = v, j(!v && K.current.messages.length > 0);
|
|
981
|
+
}, Bt = () => {
|
|
982
|
+
const c = fe.current;
|
|
911
983
|
if (!c) return;
|
|
912
|
-
|
|
913
|
-
const
|
|
914
|
-
|
|
915
|
-
},
|
|
916
|
-
const
|
|
917
|
-
if (!
|
|
918
|
-
if (
|
|
919
|
-
|
|
984
|
+
X.current = !0, j(!1);
|
|
985
|
+
const v = kt();
|
|
986
|
+
Be(c, v);
|
|
987
|
+
}, st = async (c, v) => {
|
|
988
|
+
const g = c.trim(), k = K.current, U = v?.regenerateFrom, ge = b.regenerate;
|
|
989
|
+
if (!g || u !== "ready" || k.status === "streaming" || re.current || U && !ge) return;
|
|
990
|
+
if ($e(
|
|
991
|
+
g,
|
|
920
992
|
L.messageCharacters
|
|
921
993
|
) > L.messageCharacters) {
|
|
922
|
-
|
|
994
|
+
Q(
|
|
923
995
|
`输入内容过长,请控制在 ${L.messageCharacters} 个字符以内`
|
|
924
996
|
);
|
|
925
997
|
return;
|
|
926
998
|
}
|
|
927
|
-
const
|
|
928
|
-
id:
|
|
929
|
-
content:
|
|
930
|
-
},
|
|
931
|
-
|
|
999
|
+
const Te = {
|
|
1000
|
+
id: U?.userMessage.id ?? pa("user"),
|
|
1001
|
+
content: g
|
|
1002
|
+
}, xe = U ? Ka(k, U.userMessage.id) : ta(k, Te), Ee = new AbortController(), ce = oe.current + 1;
|
|
1003
|
+
oe.current = ce, re.current = Ee, Q(void 0), J(void 0), j(!X.current && k.messages.length > 0), U || O(""), S(xe);
|
|
932
1004
|
try {
|
|
933
|
-
let
|
|
934
|
-
const
|
|
1005
|
+
let Y = !1, R, it = 0, ot = 0, ct = 0, Fe = 0, ve = 0;
|
|
1006
|
+
const _e = /* @__PURE__ */ new Map(), lt = /* @__PURE__ */ new Set(), dt = /* @__PURE__ */ new Set(
|
|
935
1007
|
[
|
|
936
|
-
...
|
|
937
|
-
|
|
1008
|
+
...xe.messages.map((Re) => Re.id),
|
|
1009
|
+
Te.id
|
|
938
1010
|
]
|
|
939
|
-
),
|
|
940
|
-
let
|
|
941
|
-
if (
|
|
942
|
-
if (!
|
|
943
|
-
throw new
|
|
944
|
-
|
|
945
|
-
threadId:
|
|
946
|
-
message:
|
|
1011
|
+
), ye = /* @__PURE__ */ new Set(), mt = ea(Qe), ut = { signal: Ee.signal };
|
|
1012
|
+
let Pe;
|
|
1013
|
+
if (U) {
|
|
1014
|
+
if (!ge)
|
|
1015
|
+
throw new w("当前 AI 助手不支持重新生成");
|
|
1016
|
+
Pe = ge({
|
|
1017
|
+
threadId: xe.threadId,
|
|
1018
|
+
message: Te,
|
|
947
1019
|
assistantMessage: {
|
|
948
|
-
id:
|
|
949
|
-
content:
|
|
1020
|
+
id: U.assistantMessage.id,
|
|
1021
|
+
content: U.assistantMessage.content
|
|
950
1022
|
},
|
|
951
1023
|
context: s,
|
|
952
|
-
capabilities:
|
|
953
|
-
},
|
|
1024
|
+
capabilities: mt
|
|
1025
|
+
}, ut);
|
|
954
1026
|
} else
|
|
955
|
-
|
|
1027
|
+
Pe = b.run(
|
|
956
1028
|
{
|
|
957
|
-
threadId:
|
|
958
|
-
message:
|
|
1029
|
+
threadId: xe.threadId,
|
|
1030
|
+
message: Te,
|
|
959
1031
|
context: s,
|
|
960
|
-
capabilities:
|
|
1032
|
+
capabilities: mt
|
|
961
1033
|
},
|
|
962
|
-
|
|
1034
|
+
ut
|
|
963
1035
|
);
|
|
964
|
-
const
|
|
965
|
-
for (
|
|
966
|
-
const
|
|
967
|
-
if (
|
|
1036
|
+
const ht = Pe[Symbol.asyncIterator]();
|
|
1037
|
+
for (ie.current = { iterator: ht, requestVersion: ce }; ; ) {
|
|
1038
|
+
const Re = await ht.next();
|
|
1039
|
+
if (oe.current !== ce || Re.done) break;
|
|
968
1040
|
let d;
|
|
969
1041
|
try {
|
|
970
|
-
d =
|
|
971
|
-
} catch (
|
|
972
|
-
throw new
|
|
973
|
-
|
|
1042
|
+
d = aa(Re.value);
|
|
1043
|
+
} catch (W) {
|
|
1044
|
+
throw new w(
|
|
1045
|
+
W instanceof Error ? W.message : "Invalid assistant event"
|
|
974
1046
|
);
|
|
975
1047
|
}
|
|
976
1048
|
if (d.type === "message.start") {
|
|
977
|
-
if (
|
|
978
|
-
throw new
|
|
979
|
-
if (
|
|
980
|
-
throw new
|
|
981
|
-
if (
|
|
982
|
-
throw new
|
|
983
|
-
|
|
1049
|
+
if (R !== void 0 && R !== d.runId)
|
|
1050
|
+
throw new w("AI 助手响应 run id 不一致");
|
|
1051
|
+
if (R ??= d.runId, ot += 1, ot > L.assistantMessagesPerRun)
|
|
1052
|
+
throw new w("AI 助手单次响应消息数量超过限制");
|
|
1053
|
+
if (dt.has(d.messageId))
|
|
1054
|
+
throw new w("AI 助手响应包含重复的 message id");
|
|
1055
|
+
dt.add(d.messageId), ye.add(d.messageId), _e.set(d.messageId, 0);
|
|
984
1056
|
}
|
|
985
1057
|
if (d.type === "message.delta") {
|
|
986
|
-
if (!
|
|
987
|
-
throw new
|
|
988
|
-
const
|
|
1058
|
+
if (!ye.has(d.messageId))
|
|
1059
|
+
throw new w("AI 助手响应事件顺序无效");
|
|
1060
|
+
const W = _e.get(d.messageId) ?? 0, le = $e(
|
|
989
1061
|
d.delta,
|
|
990
|
-
L.messageCharacters -
|
|
1062
|
+
L.messageCharacters - ve
|
|
991
1063
|
);
|
|
992
|
-
if (
|
|
993
|
-
throw new
|
|
994
|
-
|
|
1064
|
+
if (ve + le > L.messageCharacters)
|
|
1065
|
+
throw new w("AI 助手响应文本超过大小限制");
|
|
1066
|
+
ve += le, _e.set(
|
|
995
1067
|
d.messageId,
|
|
996
|
-
|
|
1068
|
+
W + le
|
|
997
1069
|
);
|
|
998
1070
|
}
|
|
999
1071
|
if (d.type === "message.replace") {
|
|
1000
|
-
if (!
|
|
1001
|
-
throw new
|
|
1002
|
-
const
|
|
1072
|
+
if (!ye.has(d.messageId))
|
|
1073
|
+
throw new w("AI 助手响应事件顺序无效");
|
|
1074
|
+
const W = _e.get(d.messageId) ?? 0, le = $e(
|
|
1003
1075
|
d.content,
|
|
1004
1076
|
L.messageCharacters
|
|
1005
|
-
),
|
|
1006
|
-
if (
|
|
1007
|
-
throw new
|
|
1008
|
-
|
|
1077
|
+
), pt = ve - W + le;
|
|
1078
|
+
if (pt > L.messageCharacters)
|
|
1079
|
+
throw new w("AI 助手响应文本超过大小限制");
|
|
1080
|
+
ve = pt, _e.set(d.messageId, le);
|
|
1009
1081
|
}
|
|
1010
1082
|
if (d.type === "run.progress") {
|
|
1011
|
-
if (
|
|
1012
|
-
throw new
|
|
1013
|
-
if (
|
|
1014
|
-
throw new
|
|
1015
|
-
const
|
|
1083
|
+
if (R !== void 0 && R !== d.runId)
|
|
1084
|
+
throw new w("AI 助手响应 run id 不一致");
|
|
1085
|
+
if (R ??= d.runId, ct += 1, ct > L.progressStepsPerRun)
|
|
1086
|
+
throw new w("AI 助手处理过程数量超过限制");
|
|
1087
|
+
const W = $e(
|
|
1016
1088
|
d.message,
|
|
1017
|
-
L.progressCharactersPerRun -
|
|
1089
|
+
L.progressCharactersPerRun - Fe
|
|
1018
1090
|
);
|
|
1019
|
-
if (
|
|
1020
|
-
throw new
|
|
1021
|
-
|
|
1091
|
+
if (Fe + W > L.progressCharactersPerRun)
|
|
1092
|
+
throw new w("AI 助手处理过程文本超过大小限制");
|
|
1093
|
+
Fe += W;
|
|
1022
1094
|
}
|
|
1023
1095
|
if (d.type === "artifact") {
|
|
1024
|
-
if (!
|
|
1025
|
-
throw new
|
|
1026
|
-
if (
|
|
1027
|
-
throw new
|
|
1028
|
-
if (
|
|
1029
|
-
throw new
|
|
1030
|
-
|
|
1096
|
+
if (!ye.has(d.messageId))
|
|
1097
|
+
throw new w("AI 助手响应事件顺序无效");
|
|
1098
|
+
if (it += 1, it > L.artifactsPerRun)
|
|
1099
|
+
throw new w("AI 助手单次响应 Artifact 数量超过限制");
|
|
1100
|
+
if (lt.has(d.artifact.id))
|
|
1101
|
+
throw new w("AI 助手响应包含重复的 Artifact id");
|
|
1102
|
+
lt.add(d.artifact.id);
|
|
1031
1103
|
}
|
|
1032
|
-
if (d.type === "message.complete" && !
|
|
1033
|
-
throw new
|
|
1034
|
-
if (d.type === "run.complete" &&
|
|
1035
|
-
throw new
|
|
1036
|
-
if (d.type === "run.cancelled" && d.runId !== void 0 &&
|
|
1037
|
-
throw new
|
|
1038
|
-
if (S((
|
|
1039
|
-
|
|
1104
|
+
if (d.type === "message.complete" && !ye.delete(d.messageId))
|
|
1105
|
+
throw new w("AI 助手响应事件顺序无效");
|
|
1106
|
+
if (d.type === "run.complete" && R !== void 0 && R !== d.runId)
|
|
1107
|
+
throw new w("AI 助手响应 run id 不一致");
|
|
1108
|
+
if (d.type === "run.cancelled" && d.runId !== void 0 && R !== void 0 && R !== d.runId)
|
|
1109
|
+
throw new w("AI 助手响应 run id 不一致");
|
|
1110
|
+
if (S((W) => Se(W, d)), d.type === "error" || d.type === "run.cancelled" || d.type === "run.complete") {
|
|
1111
|
+
Y = !0;
|
|
1040
1112
|
break;
|
|
1041
1113
|
}
|
|
1042
1114
|
}
|
|
1043
|
-
if (!
|
|
1044
|
-
throw new
|
|
1045
|
-
} catch (
|
|
1046
|
-
if (
|
|
1047
|
-
if (
|
|
1115
|
+
if (!Y)
|
|
1116
|
+
throw new w("AI 助手流式响应在终止事件前结束");
|
|
1117
|
+
} catch (Y) {
|
|
1118
|
+
if (oe.current !== ce) return;
|
|
1119
|
+
if (Ee.signal.aborted) {
|
|
1048
1120
|
S(
|
|
1049
|
-
(
|
|
1121
|
+
(R) => Se(R, { type: "run.cancelled" })
|
|
1050
1122
|
);
|
|
1051
1123
|
return;
|
|
1052
1124
|
}
|
|
1053
1125
|
console.error("[make-ai-assistant] assistant run failed", {
|
|
1054
1126
|
appId: s.app.id,
|
|
1055
|
-
errorType:
|
|
1127
|
+
errorType: Y instanceof Error ? Y.name : typeof Y
|
|
1056
1128
|
}), S(
|
|
1057
|
-
(
|
|
1129
|
+
(R) => Se(R, {
|
|
1058
1130
|
type: "error",
|
|
1059
1131
|
code: "TRANSPORT_ERROR",
|
|
1060
|
-
message:
|
|
1132
|
+
message: Y instanceof w ? Y.message : "连接失败,请重试",
|
|
1061
1133
|
retryable: !0
|
|
1062
1134
|
})
|
|
1063
1135
|
);
|
|
1064
1136
|
} finally {
|
|
1065
|
-
|
|
1137
|
+
oe.current === ce && re.current === Ee && (re.current = void 0), ie.current?.requestVersion === ce && (yt(ie.current.iterator), ie.current = void 0);
|
|
1066
1138
|
}
|
|
1067
|
-
},
|
|
1139
|
+
}, Ne = (c) => st(c), Ot = (c) => st(c.userMessage.content, { regenerateFrom: c }), zt = async (c, v) => {
|
|
1068
1140
|
try {
|
|
1069
|
-
await
|
|
1070
|
-
} catch (
|
|
1141
|
+
await xa(v), J({ messageId: c, message: "已复制", status: "success" });
|
|
1142
|
+
} catch (g) {
|
|
1071
1143
|
console.error("[make-ai-assistant] copy answer failed", {
|
|
1072
|
-
errorType:
|
|
1073
|
-
}),
|
|
1144
|
+
errorType: g instanceof Error ? g.name : typeof g
|
|
1145
|
+
}), J({ messageId: c, message: "复制失败", status: "error" });
|
|
1074
1146
|
}
|
|
1075
|
-
},
|
|
1076
|
-
c.preventDefault(),
|
|
1077
|
-
},
|
|
1078
|
-
c.key === "Enter" && !c.shiftKey && !c.nativeEvent.isComposing && (c.preventDefault(),
|
|
1079
|
-
},
|
|
1080
|
-
|
|
1081
|
-
(c) =>
|
|
1147
|
+
}, Ut = (c) => {
|
|
1148
|
+
c.preventDefault(), Ne(P);
|
|
1149
|
+
}, Vt = (c) => {
|
|
1150
|
+
c.key === "Enter" && !c.shiftKey && !c.nativeEvent.isComposing && (c.preventDefault(), Ne(P));
|
|
1151
|
+
}, qt = () => {
|
|
1152
|
+
Ae("stop") && S(
|
|
1153
|
+
(c) => Se(c, { type: "run.cancelled" })
|
|
1082
1154
|
);
|
|
1083
|
-
},
|
|
1084
|
-
|
|
1085
|
-
},
|
|
1086
|
-
|
|
1155
|
+
}, Kt = () => {
|
|
1156
|
+
Ae("new-conversation"), O(""), Q(void 0), J(void 0), j(!1), X.current = !0, S(Ce()), l?.();
|
|
1157
|
+
}, nt = b.features?.remoteCancellation === !1 ? "停止接收" : "停止生成", jt = St(p), Xt = $t(p), Me = qa(p), Yt = typeof b.regenerate == "function" && b.features?.regeneration !== !1, rt = () => {
|
|
1158
|
+
Me && Ne(Me.content);
|
|
1087
1159
|
};
|
|
1088
1160
|
return /* @__PURE__ */ i(
|
|
1089
1161
|
"section",
|
|
1090
1162
|
{
|
|
1091
1163
|
className: "make-ai-assistant make-ai-assistant__panel",
|
|
1092
|
-
ref:
|
|
1093
|
-
style:
|
|
1164
|
+
ref: Ve,
|
|
1165
|
+
style: F,
|
|
1094
1166
|
children: [
|
|
1095
1167
|
/* @__PURE__ */ i("header", { className: "make-ai-assistant__header", children: [
|
|
1096
|
-
/* @__PURE__ */ a(
|
|
1168
|
+
/* @__PURE__ */ a(De, {}),
|
|
1097
1169
|
/* @__PURE__ */ i("div", { className: "make-ai-assistant__header-content", children: [
|
|
1098
1170
|
/* @__PURE__ */ i("div", { className: "make-ai-assistant__header-title-row", children: [
|
|
1099
|
-
/* @__PURE__ */ a("h2", { className: "make-ai-assistant__header-title", title:
|
|
1171
|
+
/* @__PURE__ */ a("h2", { className: "make-ai-assistant__header-title", title: h, children: h }),
|
|
1100
1172
|
/* @__PURE__ */ a("span", { className: "make-ai-assistant__read-only-tag", children: "只读" })
|
|
1101
1173
|
] }),
|
|
1102
1174
|
/* @__PURE__ */ i("div", { className: "make-ai-assistant__header-context", children: [
|
|
1103
|
-
/* @__PURE__ */ a("p", { title:
|
|
1104
|
-
|
|
1175
|
+
/* @__PURE__ */ a("p", { title: q, children: q }),
|
|
1176
|
+
I ? /* @__PURE__ */ i(G, { children: [
|
|
1105
1177
|
/* @__PURE__ */ a(
|
|
1106
1178
|
"span",
|
|
1107
1179
|
{
|
|
1108
|
-
"aria-describedby":
|
|
1109
|
-
"aria-label": `使用提示:${
|
|
1180
|
+
"aria-describedby": Ze,
|
|
1181
|
+
"aria-label": `使用提示:${I}`,
|
|
1110
1182
|
className: "make-ai-assistant__header-context-help",
|
|
1111
|
-
"data-tooltip":
|
|
1112
|
-
ref:
|
|
1183
|
+
"data-tooltip": I,
|
|
1184
|
+
ref: Ke,
|
|
1113
1185
|
role: "note",
|
|
1114
1186
|
tabIndex: 0,
|
|
1115
|
-
onBlur:
|
|
1116
|
-
onFocus:
|
|
1117
|
-
onPointerEnter:
|
|
1118
|
-
onPointerLeave:
|
|
1119
|
-
children: /* @__PURE__ */ a(
|
|
1187
|
+
onBlur: at,
|
|
1188
|
+
onFocus: tt,
|
|
1189
|
+
onPointerEnter: tt,
|
|
1190
|
+
onPointerLeave: at,
|
|
1191
|
+
children: /* @__PURE__ */ a(Sa, {})
|
|
1120
1192
|
}
|
|
1121
1193
|
),
|
|
1122
1194
|
/* @__PURE__ */ a(
|
|
1123
1195
|
"span",
|
|
1124
1196
|
{
|
|
1125
|
-
"aria-hidden": !
|
|
1197
|
+
"aria-hidden": !ne,
|
|
1126
1198
|
className: "make-ai-assistant__header-context-tooltip",
|
|
1127
|
-
"data-placement":
|
|
1128
|
-
"data-positioned":
|
|
1129
|
-
"data-visible":
|
|
1130
|
-
id:
|
|
1131
|
-
ref:
|
|
1199
|
+
"data-placement": pe?.placement,
|
|
1200
|
+
"data-positioned": pe ? !0 : void 0,
|
|
1201
|
+
"data-visible": ne || void 0,
|
|
1202
|
+
id: Ze,
|
|
1203
|
+
ref: je,
|
|
1132
1204
|
role: "tooltip",
|
|
1133
|
-
style:
|
|
1134
|
-
children:
|
|
1205
|
+
style: Wt,
|
|
1206
|
+
children: I
|
|
1135
1207
|
}
|
|
1136
1208
|
)
|
|
1137
1209
|
] }) : null
|
|
1138
1210
|
] })
|
|
1139
1211
|
] }),
|
|
1140
1212
|
/* @__PURE__ */ i("div", { className: "make-ai-assistant__header-actions", children: [
|
|
1141
|
-
|
|
1213
|
+
b.features?.newConversation !== !1 ? /* @__PURE__ */ a(
|
|
1142
1214
|
"button",
|
|
1143
1215
|
{
|
|
1144
1216
|
"aria-label": "新建对话",
|
|
1145
1217
|
className: "make-ai-assistant__icon-button",
|
|
1146
1218
|
type: "button",
|
|
1147
|
-
onClick:
|
|
1148
|
-
children: /* @__PURE__ */ a(
|
|
1219
|
+
onClick: Kt,
|
|
1220
|
+
children: /* @__PURE__ */ a(La, {})
|
|
1149
1221
|
}
|
|
1150
1222
|
) : null,
|
|
1151
1223
|
o ? /* @__PURE__ */ a(
|
|
1152
1224
|
"button",
|
|
1153
1225
|
{
|
|
1154
|
-
"aria-label": `关闭 ${
|
|
1226
|
+
"aria-label": `关闭 ${h}`,
|
|
1155
1227
|
className: "make-ai-assistant__icon-button",
|
|
1156
1228
|
type: "button",
|
|
1157
1229
|
onClick: o,
|
|
1158
|
-
children: /* @__PURE__ */ a(
|
|
1230
|
+
children: /* @__PURE__ */ a(Ea, {})
|
|
1159
1231
|
}
|
|
1160
1232
|
) : null
|
|
1161
1233
|
] })
|
|
@@ -1166,111 +1238,112 @@ function Mt({
|
|
|
1166
1238
|
className: "make-ai-assistant__body",
|
|
1167
1239
|
"aria-live": "polite",
|
|
1168
1240
|
"aria-relevant": "additions text",
|
|
1169
|
-
ref:
|
|
1241
|
+
ref: fe,
|
|
1170
1242
|
role: "log",
|
|
1171
|
-
onScroll:
|
|
1243
|
+
onScroll: Ht,
|
|
1172
1244
|
children: [
|
|
1173
|
-
|
|
1174
|
-
/* @__PURE__ */ a(
|
|
1245
|
+
u === "loading" ? /* @__PURE__ */ i("div", { className: "make-ai-assistant__empty", role: "status", children: [
|
|
1246
|
+
/* @__PURE__ */ a(De, {}),
|
|
1175
1247
|
/* @__PURE__ */ a("h3", { children: "正在恢复对话" }),
|
|
1176
1248
|
/* @__PURE__ */ a("p", { children: "正在读取当前 App 的历史消息…" })
|
|
1177
|
-
] }) :
|
|
1178
|
-
|
|
1249
|
+
] }) : u === "error" ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__empty", children: /* @__PURE__ */ a(
|
|
1250
|
+
Xa,
|
|
1179
1251
|
{
|
|
1180
|
-
error:
|
|
1181
|
-
onRetry: () =>
|
|
1252
|
+
error: z,
|
|
1253
|
+
onRetry: () => Ie((c) => c + 1)
|
|
1182
1254
|
}
|
|
1183
|
-
) }) :
|
|
1184
|
-
/* @__PURE__ */ a(
|
|
1255
|
+
) }) : p.messages.length === 0 ? /* @__PURE__ */ i("div", { className: "make-ai-assistant__empty", children: [
|
|
1256
|
+
/* @__PURE__ */ a(De, {}),
|
|
1185
1257
|
/* @__PURE__ */ a("h3", { children: "有什么可以帮你?" }),
|
|
1186
1258
|
/* @__PURE__ */ a("p", { children: "我会结合当前 App、页面位置和宿主允许的上下文回答,并把过程与结果分开展示。" })
|
|
1187
|
-
] }) :
|
|
1188
|
-
|
|
1259
|
+
] }) : Ga(
|
|
1260
|
+
p,
|
|
1189
1261
|
s,
|
|
1190
|
-
|
|
1262
|
+
Qe,
|
|
1263
|
+
D,
|
|
1191
1264
|
r,
|
|
1192
1265
|
n,
|
|
1193
1266
|
e,
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
(c,
|
|
1200
|
-
|
|
1267
|
+
Me ? rt : void 0,
|
|
1268
|
+
V,
|
|
1269
|
+
C,
|
|
1270
|
+
we,
|
|
1271
|
+
Yt,
|
|
1272
|
+
(c, v) => {
|
|
1273
|
+
zt(c, v);
|
|
1201
1274
|
},
|
|
1202
1275
|
(c) => {
|
|
1203
|
-
|
|
1276
|
+
Ot(c);
|
|
1204
1277
|
}
|
|
1205
1278
|
),
|
|
1206
|
-
|
|
1207
|
-
|
|
1279
|
+
p.progress && !jt ? /* @__PURE__ */ a(
|
|
1280
|
+
bt,
|
|
1208
1281
|
{
|
|
1209
1282
|
assistantName: e,
|
|
1210
|
-
progress:
|
|
1283
|
+
progress: p.progress
|
|
1211
1284
|
}
|
|
1212
1285
|
) : null,
|
|
1213
|
-
|
|
1214
|
-
|
|
1286
|
+
p.error && !Xt ? /* @__PURE__ */ a(
|
|
1287
|
+
bt,
|
|
1215
1288
|
{
|
|
1216
1289
|
assistantName: e,
|
|
1217
|
-
error:
|
|
1218
|
-
onRetry:
|
|
1290
|
+
error: p.error,
|
|
1291
|
+
onRetry: Me ? rt : void 0
|
|
1219
1292
|
}
|
|
1220
1293
|
) : null
|
|
1221
1294
|
]
|
|
1222
1295
|
}
|
|
1223
1296
|
),
|
|
1224
|
-
|
|
1297
|
+
Pt ? /* @__PURE__ */ a(
|
|
1225
1298
|
"button",
|
|
1226
1299
|
{
|
|
1227
1300
|
"aria-label": "回到最新消息",
|
|
1228
1301
|
className: "make-ai-assistant__back-to-latest",
|
|
1229
1302
|
type: "button",
|
|
1230
|
-
onClick:
|
|
1231
|
-
children: /* @__PURE__ */ a(
|
|
1303
|
+
onClick: Bt,
|
|
1304
|
+
children: /* @__PURE__ */ a($a, {})
|
|
1232
1305
|
}
|
|
1233
1306
|
) : null,
|
|
1234
1307
|
/* @__PURE__ */ i("footer", { className: "make-ai-assistant__composer-region", children: [
|
|
1235
|
-
|
|
1308
|
+
u === "ready" && Je.length > 0 && p.messages.length === 0 ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__suggestions", "aria-label": "推荐问题", children: Je.map((c, v) => /* @__PURE__ */ a(
|
|
1236
1309
|
"button",
|
|
1237
1310
|
{
|
|
1238
1311
|
type: "button",
|
|
1239
1312
|
onClick: () => {
|
|
1240
|
-
|
|
1313
|
+
Ne(c);
|
|
1241
1314
|
},
|
|
1242
1315
|
children: c
|
|
1243
1316
|
},
|
|
1244
|
-
`${
|
|
1317
|
+
`${v}-${c}`
|
|
1245
1318
|
)) }) : null,
|
|
1246
|
-
/* @__PURE__ */ i("form", { className: "make-ai-assistant__composer", onSubmit:
|
|
1319
|
+
/* @__PURE__ */ i("form", { className: "make-ai-assistant__composer", onSubmit: Ut, children: [
|
|
1247
1320
|
/* @__PURE__ */ a(
|
|
1248
1321
|
"textarea",
|
|
1249
1322
|
{
|
|
1250
1323
|
"aria-label": `向 ${e} 提问`,
|
|
1251
|
-
"aria-describedby":
|
|
1252
|
-
"aria-invalid":
|
|
1324
|
+
"aria-describedby": ae ? "make-ai-composer-error" : void 0,
|
|
1325
|
+
"aria-invalid": ae ? !0 : void 0,
|
|
1253
1326
|
autoFocus: !0,
|
|
1254
|
-
disabled:
|
|
1327
|
+
disabled: u !== "ready" || p.status === "streaming",
|
|
1255
1328
|
placeholder: `询问当前 ${s.app.name ?? "App"} 中的数据…`,
|
|
1256
|
-
ref:
|
|
1329
|
+
ref: qe,
|
|
1257
1330
|
rows: 2,
|
|
1258
|
-
value:
|
|
1331
|
+
value: P,
|
|
1259
1332
|
onChange: (c) => {
|
|
1260
|
-
|
|
1333
|
+
O(c.currentTarget.value), Q(void 0);
|
|
1261
1334
|
},
|
|
1262
|
-
onKeyDown:
|
|
1335
|
+
onKeyDown: Vt
|
|
1263
1336
|
}
|
|
1264
1337
|
),
|
|
1265
|
-
|
|
1338
|
+
p.status === "streaming" ? /* @__PURE__ */ a(
|
|
1266
1339
|
"button",
|
|
1267
1340
|
{
|
|
1268
|
-
"aria-label":
|
|
1341
|
+
"aria-label": nt,
|
|
1269
1342
|
className: "make-ai-assistant__send make-ai-assistant__send--stop",
|
|
1270
|
-
"data-tooltip":
|
|
1271
|
-
ref:
|
|
1343
|
+
"data-tooltip": nt,
|
|
1344
|
+
ref: Xe,
|
|
1272
1345
|
type: "button",
|
|
1273
|
-
onClick:
|
|
1346
|
+
onClick: qt,
|
|
1274
1347
|
children: /* @__PURE__ */ a("span", { "aria-hidden": "true" })
|
|
1275
1348
|
}
|
|
1276
1349
|
) : /* @__PURE__ */ a(
|
|
@@ -1278,156 +1351,178 @@ function Mt({
|
|
|
1278
1351
|
{
|
|
1279
1352
|
"aria-label": "发送",
|
|
1280
1353
|
className: "make-ai-assistant__send",
|
|
1281
|
-
disabled:
|
|
1354
|
+
disabled: u !== "ready" || !P.trim(),
|
|
1282
1355
|
type: "submit",
|
|
1283
|
-
children: /* @__PURE__ */ a(
|
|
1356
|
+
children: /* @__PURE__ */ a(Da, {})
|
|
1284
1357
|
}
|
|
1285
1358
|
)
|
|
1286
1359
|
] }),
|
|
1287
|
-
|
|
1360
|
+
ae ? /* @__PURE__ */ a("p", { id: "make-ai-composer-error", role: "alert", children: ae }) : null,
|
|
1288
1361
|
/* @__PURE__ */ a("p", { children: "AI 生成的结果可能存在偏差,重要数据请核对明细。" })
|
|
1289
1362
|
] })
|
|
1290
1363
|
]
|
|
1291
1364
|
}
|
|
1292
1365
|
);
|
|
1293
1366
|
}
|
|
1294
|
-
function
|
|
1295
|
-
return /* @__PURE__ */ a(
|
|
1367
|
+
function ts(e) {
|
|
1368
|
+
return /* @__PURE__ */ a(Ft, { ...e, visible: !0 });
|
|
1296
1369
|
}
|
|
1297
|
-
function
|
|
1370
|
+
function as({
|
|
1298
1371
|
defaultOpen: e = !1,
|
|
1299
1372
|
hideLauncher: t = !1,
|
|
1300
1373
|
launcher: s,
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1374
|
+
maxDrawerWidth: r,
|
|
1375
|
+
onOpenChange: n,
|
|
1376
|
+
open: o,
|
|
1377
|
+
...l
|
|
1304
1378
|
}) {
|
|
1305
|
-
const
|
|
1306
|
-
() => e ||
|
|
1307
|
-
),
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1379
|
+
const m = Tt(l.brandName, l.title), [_, f] = E(e), [N, T] = E(
|
|
1380
|
+
() => e || o === !0
|
|
1381
|
+
), $ = M(null), D = M(null), b = M(void 0), [C, V] = E(), [x, h] = E(ka), [I, q] = E(!1), A = o ?? _, Z = Oe(l.theme), F = wa(r), P = () => Ia(
|
|
1382
|
+
x,
|
|
1383
|
+
F,
|
|
1384
|
+
typeof window > "u" ? xt : window.innerWidth
|
|
1385
|
+
), O = P(), p = C === void 0 ? void 0 : We(C, x, O), S = p === void 0 && F === void 0 ? void 0 : {
|
|
1386
|
+
...p === void 0 ? {} : { "--make-ai-internal-drawer-width": `${p}px` },
|
|
1387
|
+
...F === void 0 ? {} : {
|
|
1388
|
+
"--make-ai-internal-drawer-max-width": `max(var(--make-ai-internal-drawer-min-width), ${F}px)`
|
|
1389
|
+
}
|
|
1390
|
+
};
|
|
1391
|
+
wt(() => {
|
|
1392
|
+
p !== void 0 && p !== C && V(p);
|
|
1393
|
+
}, [p, C]);
|
|
1394
|
+
const K = () => {
|
|
1395
|
+
if (p !== void 0) return p;
|
|
1396
|
+
const u = D.current?.getBoundingClientRect().width;
|
|
1397
|
+
return u && Number.isFinite(u) && u > 0 ? u : x;
|
|
1398
|
+
}, ae = (u) => {
|
|
1399
|
+
if (u.button !== 0) return;
|
|
1400
|
+
const y = K(), z = C === void 0 ? y : x;
|
|
1401
|
+
h(z), b.current = {
|
|
1402
|
+
minimumWidth: z,
|
|
1403
|
+
pointerId: u.pointerId,
|
|
1404
|
+
startWidth: y,
|
|
1405
|
+
startX: u.clientX
|
|
1406
|
+
}, q(!0), typeof u.currentTarget.setPointerCapture == "function" && u.currentTarget.setPointerCapture(u.pointerId), u.preventDefault();
|
|
1407
|
+
}, Q = (u) => {
|
|
1408
|
+
const y = b.current;
|
|
1409
|
+
if (!y || y.pointerId !== u.pointerId) return;
|
|
1410
|
+
const z = We(
|
|
1411
|
+
y.startWidth + y.startX - u.clientX,
|
|
1412
|
+
y.minimumWidth,
|
|
1413
|
+
P()
|
|
1327
1414
|
);
|
|
1328
|
-
|
|
1329
|
-
},
|
|
1330
|
-
const
|
|
1331
|
-
!
|
|
1332
|
-
},
|
|
1333
|
-
const
|
|
1334
|
-
if (
|
|
1335
|
-
|
|
1336
|
-
const
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1415
|
+
V(z);
|
|
1416
|
+
}, we = (u) => {
|
|
1417
|
+
const y = b.current;
|
|
1418
|
+
!y || y.pointerId !== u.pointerId || (b.current = void 0, q(!1));
|
|
1419
|
+
}, J = (u) => {
|
|
1420
|
+
const y = u.key === "ArrowLeft" ? vt : u.key === "ArrowRight" ? -vt : void 0;
|
|
1421
|
+
if (y === void 0) return;
|
|
1422
|
+
u.preventDefault();
|
|
1423
|
+
const z = K(), se = C === void 0 ? z : x;
|
|
1424
|
+
h(se), V(We(
|
|
1425
|
+
z + y,
|
|
1426
|
+
se,
|
|
1427
|
+
P()
|
|
1341
1428
|
));
|
|
1342
|
-
},
|
|
1343
|
-
|
|
1344
|
-
},
|
|
1345
|
-
return
|
|
1346
|
-
A &&
|
|
1347
|
-
}, [A]),
|
|
1429
|
+
}, he = (u) => {
|
|
1430
|
+
o === void 0 && f(u), n?.(u), u || requestAnimationFrame(() => $.current?.focus());
|
|
1431
|
+
}, Ie = () => he(!A);
|
|
1432
|
+
return ee(() => {
|
|
1433
|
+
A && T(!0);
|
|
1434
|
+
}, [A]), ee(() => {
|
|
1348
1435
|
if (!A) return;
|
|
1349
|
-
const
|
|
1350
|
-
|
|
1436
|
+
const u = (y) => {
|
|
1437
|
+
y.key === "Escape" && (he(!1), requestAnimationFrame(() => $.current?.focus()));
|
|
1351
1438
|
};
|
|
1352
|
-
return document.addEventListener("keydown",
|
|
1353
|
-
}, [
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1439
|
+
return document.addEventListener("keydown", u), () => document.removeEventListener("keydown", u);
|
|
1440
|
+
}, [n, A]), /* @__PURE__ */ i(
|
|
1441
|
+
"div",
|
|
1442
|
+
{
|
|
1443
|
+
className: "make-ai-assistant",
|
|
1444
|
+
"data-open": A || void 0,
|
|
1445
|
+
style: Z,
|
|
1446
|
+
children: [
|
|
1447
|
+
!t && (!A || s) ? s ? s({ open: A, toggle: Ie }) : /* @__PURE__ */ i(
|
|
1448
|
+
"button",
|
|
1449
|
+
{
|
|
1450
|
+
"aria-label": A ? `关闭 ${m}` : `打开 ${m}`,
|
|
1451
|
+
"aria-expanded": A,
|
|
1452
|
+
className: "make-ai-assistant__launcher",
|
|
1453
|
+
ref: $,
|
|
1454
|
+
type: "button",
|
|
1455
|
+
onClick: Ie,
|
|
1456
|
+
children: [
|
|
1457
|
+
/* @__PURE__ */ a("span", { className: "make-ai-assistant__launcher-orbit", "aria-hidden": "true" }),
|
|
1458
|
+
/* @__PURE__ */ a(Et, {})
|
|
1459
|
+
]
|
|
1460
|
+
}
|
|
1461
|
+
) : null,
|
|
1462
|
+
N ? /* @__PURE__ */ i(
|
|
1463
|
+
"aside",
|
|
1464
|
+
{
|
|
1465
|
+
"aria-label": m,
|
|
1466
|
+
"aria-modal": "false",
|
|
1467
|
+
className: "make-ai-assistant__drawer",
|
|
1468
|
+
"data-resizing": I || void 0,
|
|
1469
|
+
hidden: !A,
|
|
1470
|
+
ref: D,
|
|
1471
|
+
role: "dialog",
|
|
1472
|
+
style: S,
|
|
1473
|
+
children: [
|
|
1474
|
+
/* @__PURE__ */ a(
|
|
1475
|
+
"div",
|
|
1476
|
+
{
|
|
1477
|
+
"aria-label": "调整对话框宽度",
|
|
1478
|
+
"aria-orientation": "vertical",
|
|
1479
|
+
"aria-valuemax": O,
|
|
1480
|
+
"aria-valuemin": x,
|
|
1481
|
+
"aria-valuenow": p ?? x,
|
|
1482
|
+
className: "make-ai-assistant__drawer-resize-handle",
|
|
1483
|
+
role: "separator",
|
|
1484
|
+
tabIndex: 0,
|
|
1485
|
+
onKeyDown: J,
|
|
1486
|
+
onPointerCancel: we,
|
|
1487
|
+
onPointerDown: ae,
|
|
1488
|
+
onPointerMove: Q,
|
|
1489
|
+
onPointerUp: we
|
|
1490
|
+
}
|
|
1491
|
+
),
|
|
1492
|
+
/* @__PURE__ */ a(
|
|
1493
|
+
Ft,
|
|
1494
|
+
{
|
|
1495
|
+
...l,
|
|
1496
|
+
onClose: () => he(!1),
|
|
1497
|
+
visible: A
|
|
1498
|
+
}
|
|
1499
|
+
)
|
|
1500
|
+
]
|
|
1501
|
+
}
|
|
1502
|
+
) : null
|
|
1503
|
+
]
|
|
1504
|
+
}
|
|
1505
|
+
);
|
|
1411
1506
|
}
|
|
1412
1507
|
export {
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1508
|
+
sa as ArtifactRenderer,
|
|
1509
|
+
ts as AssistantPanel,
|
|
1510
|
+
os as MAKE_AI_ARTIFACT_KINDS,
|
|
1511
|
+
cs as MAKE_AI_ARTIFACT_LIMITS,
|
|
1512
|
+
ls as MAKE_AI_ARTIFACT_SCHEMA_VERSION,
|
|
1418
1513
|
L as MAKE_AI_CONVERSATION_LIMITS,
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1514
|
+
as as MakeAiAssistant,
|
|
1515
|
+
ta as appendUserMessage,
|
|
1516
|
+
ea as createArtifactCapabilities,
|
|
1517
|
+
It as createArtifactTemplateRegistry,
|
|
1518
|
+
Ce as createAssistantConversationState,
|
|
1519
|
+
ha as createPlatformArtifactRegistry,
|
|
1520
|
+
rs as extendArtifactTemplateRegistry,
|
|
1521
|
+
te as formatArtifactValue,
|
|
1522
|
+
ds as parseArtifact,
|
|
1523
|
+
aa as parseAssistantEvent,
|
|
1524
|
+
ua as platformArtifactTemplates,
|
|
1525
|
+
Se as reduceAssistantEvent,
|
|
1526
|
+
Jt as resolveArtifactTemplate,
|
|
1527
|
+
ms as validateArtifact
|
|
1433
1528
|
};
|