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