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