@qfei-design/make-ai-assistant 0.2.6 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.mjs CHANGED
@@ -1,56 +1,56 @@
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";
1
+ import { jsxs as i, jsx as a, Fragment as Z } from "react/jsx-runtime";
2
+ import { isValidElement as Gt, cloneElement as Zt, useState as E, useRef as T, useLayoutEffect as It, useEffect as ae, useId as Qt, useMemo as gt } from "react";
3
+ import { resolveArtifactTemplate as Jt, createArtifactTemplateRegistry as At, createArtifactCapabilities as ea } from "./index.mjs";
4
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";
5
+ import { a as Re, r as Ce, c as Se, M as $, b as ta, p as aa } from "./conversation-B7eGUXi-.js";
6
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);
7
+ const Nt = (e) => e?.trim() || void 0, O = (e, t) => Nt(e) ?? t, ze = (e) => {
8
+ const t = Nt(e?.primary);
9
9
  if (t)
10
10
  return {
11
11
  "--make-ai-theme-primary": t,
12
- "--make-ai-theme-primary-hover": H(
12
+ "--make-ai-theme-primary-hover": O(
13
13
  e?.primaryHover,
14
- "color-mix(in srgb, var(--make-ai-theme-primary) 84%, var(--make-ai-theme-text))"
14
+ "color-mix(in srgb, var(--make-ai-theme-primary) 84%, #15233d)"
15
15
  ),
16
- "--make-ai-theme-on-primary": H(
16
+ "--make-ai-theme-on-primary": O(
17
17
  e?.onPrimary,
18
18
  "#fcfcff"
19
19
  ),
20
- "--make-ai-theme-bg": H(
20
+ "--make-ai-theme-bg": O(
21
21
  e?.background,
22
22
  "color-mix(in srgb, var(--make-ai-theme-primary) 2%, #fcfcff)"
23
23
  ),
24
- "--make-ai-theme-surface": H(
24
+ "--make-ai-theme-surface": O(
25
25
  e?.surface,
26
26
  "color-mix(in srgb, var(--make-ai-theme-primary) 4%, var(--make-ai-theme-bg))"
27
27
  ),
28
- "--make-ai-theme-surface-strong": H(
28
+ "--make-ai-theme-surface-strong": O(
29
29
  e?.surfaceStrong,
30
30
  "color-mix(in srgb, var(--make-ai-theme-primary) 8%, var(--make-ai-theme-bg))"
31
31
  ),
32
- "--make-ai-theme-text": H(
32
+ "--make-ai-theme-text": O(
33
33
  e?.text,
34
34
  "color-mix(in srgb, var(--make-ai-theme-primary) 12%, #252631)"
35
35
  ),
36
- "--make-ai-theme-text-secondary": H(
36
+ "--make-ai-theme-text-secondary": O(
37
37
  e?.textSecondary,
38
38
  "color-mix(in srgb, var(--make-ai-theme-text) 74%, var(--make-ai-theme-primary))"
39
39
  ),
40
- "--make-ai-theme-border": H(
40
+ "--make-ai-theme-border": O(
41
41
  e?.border,
42
42
  "color-mix(in srgb, var(--make-ai-theme-primary) 14%, var(--make-ai-theme-bg))"
43
43
  ),
44
- "--make-ai-theme-overlay": H(
44
+ "--make-ai-theme-overlay": O(
45
45
  e?.overlay,
46
46
  "color-mix(in srgb, var(--make-ai-theme-text) 88%, var(--make-ai-theme-primary))"
47
47
  ),
48
- "--make-ai-theme-on-overlay": H(
48
+ "--make-ai-theme-on-overlay": O(
49
49
  e?.onOverlay,
50
50
  "#fcfcff"
51
51
  )
52
52
  };
53
- }, gt = (e, t) => !t || !Gt(e) || typeof e.type != "string" ? e : Zt(e, {
53
+ }, vt = (e, t) => !t || !Gt(e) || typeof e.type != "string" ? e : Zt(e, {
54
54
  style: { ...e.props.style, ...t }
55
55
  });
56
56
  function sa({
@@ -62,27 +62,27 @@ function sa({
62
62
  registry: o,
63
63
  theme: l
64
64
  }) {
65
- const m = Oe(l), _ = Jt(o, e, t);
66
- if (!_) {
67
- const T = s ? s(e) : /* @__PURE__ */ i("section", { className: "make-ai-artifact make-ai-artifact--unsupported", role: "status", children: [
65
+ const m = ze(l), g = Jt(o, e, t);
66
+ if (!g) {
67
+ const x = s ? s(e) : /* @__PURE__ */ i("section", { className: "make-ai-artifact make-ai-artifact--unsupported", role: "status", children: [
68
68
  /* @__PURE__ */ a("strong", { children: "暂不支持展示此结果" }),
69
69
  /* @__PURE__ */ i("span", { children: [
70
70
  "结果类型:",
71
71
  e.kind
72
72
  ] })
73
73
  ] });
74
- return gt(T, m);
74
+ return vt(x, m);
75
75
  }
76
- const f = {
76
+ const p = {
77
77
  context: t,
78
78
  onAction: r,
79
79
  onActionError: n,
80
80
  theme: l,
81
81
  themeStyle: m
82
- }, N = _.template.render(e, t, f);
83
- return gt(N, m);
82
+ }, M = g.template.render(e, t, p);
83
+ return vt(M, m);
84
84
  }
85
- const te = (e, t, s) => {
85
+ const se = (e, t, s) => {
86
86
  if (e == null || e === "") return "—";
87
87
  if (typeof e == "boolean") return e ? "是" : "否";
88
88
  if (typeof e != "number") return `${e}${t?.unit ?? ""}`;
@@ -97,12 +97,12 @@ const te = (e, t, s) => {
97
97
  } catch {
98
98
  return `${e}${t?.unit ?? ""}`;
99
99
  }
100
- }, Nt = (e) => {
100
+ }, Mt = (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
- }, Mt = (e, t, s) => {
105
+ }, Tt = (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", {
@@ -139,7 +139,7 @@ const te = (e, t, s) => {
139
139
  {
140
140
  className: `make-ai-artifact__action make-ai-artifact__action--${s.appearance ?? "link"}`,
141
141
  type: "button",
142
- onClick: () => Mt(s, { artifact: e, context: t.context }, t),
142
+ onClick: () => Tt(s, { artifact: e, context: t.context }, t),
143
143
  children: [
144
144
  s.label,
145
145
  /* @__PURE__ */ a("span", { "aria-hidden": "true", children: "→" })
@@ -164,15 +164,15 @@ const te = (e, t, s) => {
164
164
  artifact: e,
165
165
  renderContext: t
166
166
  }) => {
167
- const s = e.data.delta, r = s ? te(
167
+ const s = e.data.delta, r = s ? se(
168
168
  s.value,
169
169
  s.format === "percent" ? { style: "percent" } : void 0,
170
170
  t.context.locale
171
171
  ) : void 0;
172
172
  return ue(
173
173
  e,
174
- /* @__PURE__ */ i(G, { children: [
175
- /* @__PURE__ */ a("div", { className: "make-ai-artifact__metric-value", children: te(
174
+ /* @__PURE__ */ i(Z, { children: [
175
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__metric-value", children: se(
176
176
  e.data.value,
177
177
  e.data.format,
178
178
  t.context.locale
@@ -199,10 +199,10 @@ const te = (e, t, s) => {
199
199
  renderContext: t
200
200
  }) => ue(
201
201
  e,
202
- /* @__PURE__ */ i(G, { children: [
202
+ /* @__PURE__ */ i(Z, { 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
- /* @__PURE__ */ a("strong", { children: te(s.value, s.format, t.context.locale) }),
205
+ /* @__PURE__ */ a("strong", { children: se(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)
@@ -213,27 +213,27 @@ const te = (e, t, s) => {
213
213
  artifact: e,
214
214
  renderContext: t
215
215
  }) => {
216
- const s = e.data.series.flatMap((l) => l.points.map((m) => m.y)), { max: r, min: n } = Nt(s), o = r - n || 1;
216
+ const s = e.data.series.flatMap((l) => l.points.map((m) => m.y)), { max: r, min: n } = Mt(s), o = r - n || 1;
217
217
  return ue(
218
218
  e,
219
- /* @__PURE__ */ i(G, { children: [
219
+ /* @__PURE__ */ i(Z, { children: [
220
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
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;
222
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-bars", children: l.points.map((m, g) => {
223
+ const p = 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": `${m.x}: ${te(
228
+ "aria-label": `${m.x}: ${se(
229
229
  m.y,
230
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: `${f}%` },
236
- title: `${m.x}: ${te(
235
+ style: { height: `${p}%` },
236
+ title: `${m.x}: ${se(
237
237
  m.y,
238
238
  l.format,
239
239
  t.context.locale
@@ -241,7 +241,7 @@ const te = (e, t, s) => {
241
241
  }
242
242
  ),
243
243
  /* @__PURE__ */ a("small", { children: m.x })
244
- ] }, `${m.x}-${_}`);
244
+ ] }, `${m.x}-${g}`);
245
245
  }) })
246
246
  ] }, l.id)) }),
247
247
  me(e, t)
@@ -253,12 +253,12 @@ const te = (e, t, s) => {
253
253
  artifact: e,
254
254
  renderContext: t
255
255
  }) => {
256
- const { max: s } = Nt(
256
+ const { max: s } = Mt(
257
257
  e.data.items.map((n) => Math.abs(n.value))
258
258
  ), r = Math.max(s, 1);
259
259
  return ue(
260
260
  e,
261
- /* @__PURE__ */ i(G, { children: [
261
+ /* @__PURE__ */ i(Z, { 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: [
@@ -266,7 +266,7 @@ const te = (e, t, s) => {
266
266
  n.description ? /* @__PURE__ */ a("small", { children: n.description }) : null
267
267
  ] }),
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
- /* @__PURE__ */ a("strong", { children: te(n.value, n.format, t.context.locale) })
269
+ /* @__PURE__ */ a("strong", { children: se(n.value, n.format, t.context.locale) })
270
270
  ] }, n.id)) }),
271
271
  me(e, t)
272
272
  ] }),
@@ -283,13 +283,13 @@ const te = (e, t, s) => {
283
283
  renderContext: t
284
284
  }) => ue(
285
285
  e,
286
- /* @__PURE__ */ i(G, { children: [
286
+ /* @__PURE__ */ i(Z, { 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 = ca(e, s), n = /* @__PURE__ */ i(G, { children: [
288
+ const r = ca(e, s), n = /* @__PURE__ */ i(Z, { 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 }),
292
- te(
292
+ se(
293
293
  s.values[o.key],
294
294
  o.format,
295
295
  t.context.locale
@@ -302,7 +302,7 @@ const te = (e, t, s) => {
302
302
  {
303
303
  className: "make-ai-artifact__record",
304
304
  type: "button",
305
- onClick: () => Mt(r, {
305
+ onClick: () => Tt(r, {
306
306
  artifact: e,
307
307
  context: t.context
308
308
  }, t),
@@ -325,7 +325,7 @@ const te = (e, t, s) => {
325
325
  renderContext: t
326
326
  }) => ue(
327
327
  e,
328
- /* @__PURE__ */ i(G, { children: [
328
+ /* @__PURE__ */ i(Z, { 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 })
@@ -341,24 +341,24 @@ const te = (e, t, s) => {
341
341
  de("platform.ranking.default", "ranking", (e, t, s) => /* @__PURE__ */ a(oa, { artifact: e, renderContext: s })),
342
342
  de("platform.record-list.default", "record-list", (e, t, s) => /* @__PURE__ */ a(la, { artifact: e, renderContext: s })),
343
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 = [
344
+ ], ua = At(ma).templates, ha = (e = ua) => At(e), pa = (e) => `${e}-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, fa = "Make", ga = [
345
345
  "总结当前页面数据",
346
346
  "找出需要关注的记录",
347
347
  "列出我有权限查看的数据对象"
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) => {
348
+ ], xt = (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 = 480, Et = 1024, ba = 0.72, _t = 16, z = 16, ke = 8, He = (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
349
  const r = Math.min(
350
- xt,
350
+ Et,
351
351
  s * ba
352
352
  );
353
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) => {
354
+ }, yt = (e, t, s) => Math.min(Math.max(e, t), Math.max(t, s)), Aa = (e, t, s, r) => {
355
355
  const n = Math.min(
356
356
  Math.max(t.width, 1),
357
- Math.max(1, r - B * 2)
357
+ Math.max(1, r - z * 2)
358
358
  ), o = Math.min(
359
359
  Math.max(t.height, 1),
360
- Math.max(1, s - B * 2)
361
- ), l = e.left + e.width / 2, m = e.top + e.height / 2, f = [
360
+ Math.max(1, s - z * 2)
361
+ ), l = e.left + e.width / 2, m = e.top + e.height / 2, p = [
362
362
  {
363
363
  left: e.right + ke,
364
364
  placement: "right",
@@ -380,35 +380,35 @@ const te = (e, t, s) => {
380
380
  top: e.top - ke - o
381
381
  }
382
382
  ].find(
383
- ({ left: N, top: T }) => N >= B && T >= B && N + n <= r - B && T + o <= s - B
383
+ ({ left: M, top: x }) => M >= z && x >= z && M + n <= r - z && x + o <= s - z
384
384
  );
385
- return f || {
386
- left: _t(
385
+ return p || {
386
+ left: yt(
387
387
  l - n / 2,
388
- B,
389
- r - B - n
388
+ z,
389
+ r - z - n
390
390
  ),
391
391
  placement: "bottom",
392
- top: _t(
392
+ top: yt(
393
393
  e.bottom + ke,
394
- B,
395
- s - B - o
394
+ z,
395
+ s - z - o
396
396
  )
397
397
  };
398
398
  }, Na = (e) => typeof e == "number" ? Number.isFinite(e) ? `${e}px` : void 0 : e?.trim() || void 0;
399
399
  class w extends Error {
400
400
  }
401
- const Le = (e, t) => {
401
+ const $e = (e, t) => {
402
402
  if (!(typeof e != "object" || e === null))
403
403
  return e[t];
404
404
  }, Ma = (e) => {
405
- const t = Le(e, "status");
406
- return typeof t == "number" ? t : Le(
407
- Le(e, "response"),
405
+ const t = $e(e, "status");
406
+ return typeof t == "number" ? t : $e(
407
+ $e(e, "response"),
408
408
  "status"
409
409
  );
410
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);
411
+ const t = $e(e, "code"), s = Ma(e), r = e instanceof Error ? e.message : "", n = [t, r].filter((g) => typeof g == "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
412
  return l ? {
413
413
  actionLabel: "重新连接",
414
414
  description: "请检查网络后再试。",
@@ -428,7 +428,7 @@ const Le = (e, t) => {
428
428
  label: "加载异常",
429
429
  title: "暂时无法加载对话"
430
430
  };
431
- }, yt = (e) => {
431
+ }, kt = (e) => {
432
432
  try {
433
433
  const t = e?.return?.();
434
434
  if (!t) return;
@@ -454,7 +454,7 @@ const Le = (e, t) => {
454
454
  const s = document.execCommand("copy");
455
455
  if (t.remove(), !s)
456
456
  throw new Error("Clipboard copy failed");
457
- }, Et = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
457
+ }, Rt = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
458
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" }),
459
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" })
460
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: [
@@ -476,7 +476,7 @@ const Le = (e, t) => {
476
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: [
477
477
  /* @__PURE__ */ a("path", { d: "m4 4 17 8-17 8 3-8-3-8Z" }),
478
478
  /* @__PURE__ */ a("path", { d: "M7 12h14" })
479
- ] }), Rt = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
479
+ ] }), Ct = () => /* @__PURE__ */ i("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
480
480
  /* @__PURE__ */ a("path", { d: "M20 11a8 8 0 0 0-14.7-4.4L4 8" }),
481
481
  /* @__PURE__ */ a("path", { d: "M4 4v4h4" }),
482
482
  /* @__PURE__ */ a("path", { d: "M4 13a8 8 0 0 0 14.7 4.4L20 16" }),
@@ -485,7 +485,7 @@ const Le = (e, t) => {
485
485
  /* @__PURE__ */ a("circle", { cx: "12", cy: "12", r: "8" }),
486
486
  /* @__PURE__ */ a("path", { d: "M12 8v4.5" }),
487
487
  /* @__PURE__ */ a("path", { d: "M12 16h.01" })
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 = ({
488
+ ] }), Le = ({ className: e = "" }) => /* @__PURE__ */ a("span", { className: `make-ai-assistant__avatar ${e}`.trim(), "aria-hidden": "true", children: /* @__PURE__ */ a(Rt, {}) }), 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 = ({
489
489
  userAvatarUrl: e,
490
490
  userName: t
491
491
  }) => {
@@ -494,18 +494,18 @@ const Le = (e, t) => {
494
494
  s ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: s }) : null,
495
495
  /* @__PURE__ */ a(Pa, { src: e })
496
496
  ] });
497
- }, He = (e) => {
497
+ }, Be = (e) => {
498
498
  const t = e.trim();
499
499
  if (!(!t.startsWith("|") || !t.endsWith("|")))
500
500
  return t.slice(1, -1).split("|").map((s) => s.trim());
501
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] ?? "");
502
+ const s = Be(e[t] ?? ""), r = Be(e[t + 1] ?? "");
503
503
  if (!s || !r || s.length !== r.length || !Ha(r))
504
504
  return;
505
505
  const n = [];
506
506
  let o = t + 2;
507
507
  for (; o < e.length; ) {
508
- const l = He(e[o] ?? "");
508
+ const l = Be(e[o] ?? "");
509
509
  if (!l || l.length !== s.length) break;
510
510
  n.push(l), o += 1;
511
511
  }
@@ -514,50 +514,50 @@ const Le = (e, t) => {
514
514
  const t = [], s = [], r = [], n = [], o = e.replace(/\r\n?/g, `
515
515
  `).split(`
516
516
  `), l = () => {
517
- const f = s.join(`
517
+ const p = s.join(`
518
518
  `).trim();
519
- s.length = 0, f && t.push({ type: "paragraph", text: f });
519
+ s.length = 0, p && t.push({ type: "paragraph", text: p });
520
520
  }, m = () => {
521
521
  r.length && t.push({ type: "list", items: r.splice(0) });
522
- }, _ = () => {
523
- const f = n.join(`
522
+ }, g = () => {
523
+ const p = n.join(`
524
524
  `).trim();
525
- n.length = 0, f && t.push({ type: "pre", text: f });
525
+ n.length = 0, p && t.push({ type: "pre", text: p });
526
526
  };
527
- for (let f = 0; f < o.length; f += 1) {
528
- const N = o[f] ?? "", T = N.trim();
529
- if (!T) {
530
- l(), m(), _();
527
+ for (let p = 0; p < o.length; p += 1) {
528
+ const M = o[p] ?? "", x = M.trim();
529
+ if (!x) {
530
+ l(), m(), g();
531
531
  continue;
532
532
  }
533
- const $ = Ba(o, f);
534
- if ($) {
535
- l(), m(), _(), t.push({ headers: $.headers, rows: $.rows, type: "table" }), f = $.lastIndex;
533
+ const H = Ba(o, p);
534
+ if (H) {
535
+ l(), m(), g(), t.push({ headers: H.headers, rows: H.rows, type: "table" }), p = H.lastIndex;
536
536
  continue;
537
537
  }
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({
538
+ const C = /^(#{1,6})\s+(.+)$/.exec(x);
539
+ if (C) {
540
+ l(), m(), g();
541
+ const L = (C[2] ?? "").replace(/\s+#+\s*$/, "").trim();
542
+ L && t.push({
543
543
  type: "heading",
544
- level: D[1]?.length,
545
- text: C
544
+ level: C[1]?.length,
545
+ text: L
546
546
  });
547
547
  continue;
548
548
  }
549
- if (/^\s*\|.+\|\s*$/.test(N)) {
550
- l(), m(), n.push(N.trim());
549
+ if (/^\s*\|.+\|\s*$/.test(M)) {
550
+ l(), m(), n.push(M.trim());
551
551
  continue;
552
552
  }
553
- const b = /^\s*[-*]\s+(.+)$/.exec(N);
554
- if (b) {
555
- l(), _(), r.push(b[1]?.trim() ?? "");
553
+ const I = /^\s*[-*]\s+(.+)$/.exec(M);
554
+ if (I) {
555
+ l(), g(), r.push(I[1]?.trim() ?? "");
556
556
  continue;
557
557
  }
558
- m(), _(), s.push(T);
558
+ m(), g(), s.push(x);
559
559
  }
560
- return l(), m(), _(), t;
560
+ return l(), m(), g(), t;
561
561
  }, be = (e) => {
562
562
  const t = [], s = /(\*\*[^*]+\*\*|`[^`]+`)/g;
563
563
  let r = 0;
@@ -595,10 +595,10 @@ const Le = (e, t) => {
595
595
  `${r}-table`
596
596
  ) : /* @__PURE__ */ a("ul", { children: s.items.map((n, o) => /* @__PURE__ */ a("li", { children: be(n) }, `${o}-${n}`)) }, `${r}-list`);
597
597
  }) }) : null;
598
- }, Ct = ({ assistantName: e }) => /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-identity", children: [
599
- /* @__PURE__ */ a(De, { className: "make-ai-assistant__avatar--message" }),
598
+ }, St = ({ assistantName: e }) => /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-identity", children: [
599
+ /* @__PURE__ */ a(Le, { className: "make-ai-assistant__avatar--message" }),
600
600
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: e })
601
- ] }), St = (e) => {
601
+ ] }), $t = (e) => {
602
602
  for (let t = e.messages.length - 1; t >= 0; t -= 1) {
603
603
  const s = e.messages[t];
604
604
  if (s.role === "assistant" && s.status === "streaming")
@@ -608,7 +608,7 @@ const Le = (e, t) => {
608
608
  for (let t = e.messages.length - 1; t >= 0; t -= 1)
609
609
  if (e.messages[t].role === "user") return t;
610
610
  return -1;
611
- }, $t = (e) => {
611
+ }, Lt = (e) => {
612
612
  const t = Ua(e);
613
613
  if (!(t < 0))
614
614
  for (let s = e.messages.length - 1; s > t; s -= 1) {
@@ -638,9 +638,9 @@ const Le = (e, t) => {
638
638
  status: "streaming",
639
639
  messages: s < 0 ? e.messages : e.messages.slice(0, s + 1)
640
640
  };
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) => {
641
+ }, ja = (e) => e.scrollHeight - e.scrollTop - e.clientHeight <= 48, bt = (e = "smooth") => globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : e, Oe = (e, t) => {
642
642
  typeof e.scrollTo == "function" ? e.scrollTo({ top: e.scrollHeight, behavior: t }) : e.scrollTop = e.scrollHeight;
643
- }, Lt = ({
643
+ }, Dt = ({
644
644
  error: e,
645
645
  onRetry: t
646
646
  }) => /* @__PURE__ */ i(
@@ -662,7 +662,7 @@ const Le = (e, t) => {
662
662
  type: "button",
663
663
  onClick: t,
664
664
  children: [
665
- /* @__PURE__ */ a(Rt, {}),
665
+ /* @__PURE__ */ a(Ct, {}),
666
666
  "重新发送"
667
667
  ]
668
668
  }
@@ -698,7 +698,7 @@ const Le = (e, t) => {
698
698
  type: "button",
699
699
  onClick: t,
700
700
  children: [
701
- /* @__PURE__ */ a(Rt, {}),
701
+ /* @__PURE__ */ a(Ct, {}),
702
702
  s.actionLabel
703
703
  ]
704
704
  }
@@ -706,7 +706,7 @@ const Le = (e, t) => {
706
706
  ]
707
707
  }
708
708
  );
709
- }, Dt = ({
709
+ }, Ft = ({
710
710
  active: e,
711
711
  steps: t
712
712
  }) => {
@@ -771,7 +771,7 @@ const Le = (e, t) => {
771
771
  children: e.message
772
772
  }
773
773
  ) : null
774
- ] }), bt = ({
774
+ ] }), wt = ({
775
775
  assistantName: e,
776
776
  error: t,
777
777
  onRetry: s,
@@ -786,83 +786,83 @@ const Le = (e, t) => {
786
786
  "data-message-role": "assistant",
787
787
  "data-message-state": n,
788
788
  children: /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-turn", children: [
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 }) })
789
+ /* @__PURE__ */ a(St, { assistantName: e }),
790
+ /* @__PURE__ */ a("div", { className: "make-ai-assistant__message-stack", children: t ? /* @__PURE__ */ a(Dt, { error: t, onRetry: s }) : /* @__PURE__ */ a(Ft, { active: !0, steps: r?.steps }) })
791
791
  ] })
792
792
  }
793
793
  ) : null;
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);
794
+ }, Ga = (e, t, s, r, n, o, l, m, g, p, M, x, H, C) => {
795
+ const I = Lt(e), L = $t(e), D = Va(e);
796
+ let F;
797
+ return e.messages.map((u) => {
798
+ const b = u.role === "assistant", Q = F;
799
+ b || (F = u);
800
+ const q = u.id === L, A = u.id === I ? e.error : void 0, K = u.error ?? A, S = !b && !!(g?.trim() || p), B = b ? l : g?.trim() || "用户", _ = b && u.status === "complete" && !K && (u.content.trim() || u.id === D);
801
801
  return /* @__PURE__ */ a(
802
802
  "article",
803
803
  {
804
- "aria-label": `${O}的消息`,
805
- className: `make-ai-assistant__message make-ai-assistant__message--${h.role}`,
806
- "data-message-role": h.role,
807
- "data-message-state": F ? "error" : void 0,
808
- "data-message-status": h.status,
809
- "data-message-has-identity": I || P ? !0 : void 0,
804
+ "aria-label": `${B}的消息`,
805
+ className: `make-ai-assistant__message make-ai-assistant__message--${u.role}`,
806
+ "data-message-role": u.role,
807
+ "data-message-state": K ? "error" : void 0,
808
+ "data-message-status": u.status,
809
+ "data-message-has-identity": b || S ? !0 : void 0,
810
810
  children: /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-turn", children: [
811
- I ? /* @__PURE__ */ a(Ct, { assistantName: l }) : P ? /* @__PURE__ */ a(Wa, { userAvatarUrl: f, userName: _ }) : null,
811
+ b ? /* @__PURE__ */ a(St, { assistantName: l }) : S ? /* @__PURE__ */ a(Wa, { userAvatarUrl: p, userName: g }) : null,
812
812
  /* @__PURE__ */ i("div", { className: "make-ai-assistant__message-stack", children: [
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: [
813
+ u.content ? b ? /* @__PURE__ */ a(za, { content: u.content }) : /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble", children: u.content }) : u.status === "streaming" ? /* @__PURE__ */ i("div", { className: "make-ai-assistant__typing", "aria-label": `${l}正在思考`, children: [
814
814
  /* @__PURE__ */ a("span", {}),
815
815
  /* @__PURE__ */ a("span", {}),
816
816
  /* @__PURE__ */ a("span", {})
817
817
  ] }) : null,
818
- I ? /* @__PURE__ */ a(
819
- Dt,
818
+ b ? /* @__PURE__ */ a(
819
+ Ft,
820
820
  {
821
- active: A && e.status === "streaming",
822
- steps: h.progressSteps
821
+ active: q && e.status === "streaming",
822
+ steps: u.progressSteps
823
823
  }
824
824
  ) : null,
825
- F ? /* @__PURE__ */ a(
826
- Lt,
825
+ K ? /* @__PURE__ */ a(
826
+ Dt,
827
827
  {
828
- error: F,
829
- onRetry: Z ? m : void 0
828
+ error: K,
829
+ onRetry: A ? m : void 0
830
830
  }
831
831
  ) : null,
832
- h.artifacts.map((S) => /* @__PURE__ */ a(
832
+ u.artifacts.map((y) => /* @__PURE__ */ a(
833
833
  sa,
834
834
  {
835
- artifact: S,
835
+ artifact: y,
836
836
  context: t,
837
837
  onAction: n,
838
838
  onActionError: o,
839
839
  registry: s,
840
840
  theme: r
841
841
  },
842
- S.id
842
+ y.id
843
843
  )),
844
- p ? /* @__PURE__ */ a(
844
+ _ ? /* @__PURE__ */ a(
845
845
  Ya,
846
846
  {
847
- copyFeedback: N?.messageId === h.id ? {
848
- message: N.message,
849
- status: N.status
847
+ copyFeedback: M?.messageId === u.id ? {
848
+ message: M.message,
849
+ status: M.status
850
850
  } : void 0,
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
851
+ onCopy: u.content.trim() ? () => H(u.id, u.content) : void 0,
852
+ onRegenerate: x && u.id === D && Q ? () => C({
853
+ userMessage: Q,
854
+ assistantMessage: u
855
855
  }) : void 0
856
856
  }
857
857
  ) : null
858
858
  ] })
859
859
  ] })
860
860
  },
861
- h.id
861
+ u.id
862
862
  );
863
863
  });
864
864
  };
865
- function Ft({
865
+ function Pt({
866
866
  assistantName: e = "AI 助手",
867
867
  brandName: t,
868
868
  context: s,
@@ -871,175 +871,175 @@ function Ft({
871
871
  onClose: o,
872
872
  onNewConversation: l,
873
873
  headerHeight: m,
874
- privacyNotice: _,
875
- registry: f,
876
- subtitle: N,
877
- suggestions: T,
878
- title: $,
879
- theme: D,
880
- transport: b,
881
- userAvatarUrl: C,
882
- userName: V,
883
- visible: x
874
+ privacyNotice: g,
875
+ registry: p,
876
+ subtitle: M,
877
+ suggestions: x,
878
+ title: H,
879
+ theme: C,
880
+ transport: I,
881
+ userAvatarUrl: L,
882
+ userName: D,
883
+ visible: F
884
884
  }) {
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),
895
- [T]
896
- ), et = () => {
897
- const c = Ke.current, v = je.current;
885
+ const u = xt(t, H), b = g?.trim(), Q = ya(M, s.app.name), q = Na(m), A = ze(C), K = A || q ? {
886
+ ...A,
887
+ ...q ? { "--make-ai-internal-header-height": q } : {}
888
+ } : void 0, [S, B] = E(""), [_, y] = E(Re), J = T(_);
889
+ J.current = _;
890
+ const [ee, te] = E(void 0), [De, j] = E(void 0), [Fe, he] = E(0), [U, h] = E(() => I.loadConversation ? "loading" : "ready"), [N, P] = E(void 0), [we, X] = E(!1), [ne, Ue] = E(!1), [pe, Ve] = E(void 0), re = T(void 0), ie = T(void 0), oe = T(0), qe = T(null), fe = T(null), Ke = T(null), je = T(null), Xe = T(null), Ye = T(null), Y = T(!0), Ge = T(s.app.id), Ze = T(F), Qe = Qt(), Je = gt(
891
+ () => p ?? ha(),
892
+ [p]
893
+ ), et = gt(
894
+ () => va(x),
895
+ [x]
896
+ ), tt = () => {
897
+ const c = je.current, v = Xe.current;
898
898
  if (!c || !v || typeof window > "u") return;
899
- const g = Aa(
899
+ const f = Aa(
900
900
  c.getBoundingClientRect(),
901
901
  v.getBoundingClientRect(),
902
902
  window.innerHeight,
903
903
  window.innerWidth
904
904
  );
905
- Ue(
906
- (k) => k?.left === g.left && k.top === g.top && k.placement === g.placement ? k : g
905
+ Ve(
906
+ (k) => k?.left === f.left && k.top === f.top && k.placement === f.placement ? k : f
907
907
  );
908
- }, tt = () => ze(!0), at = () => ze(!1), Wt = pe ? {
908
+ }, at = () => Ue(!0), st = () => Ue(!1), Wt = pe ? {
909
909
  left: `${pe.left}px`,
910
910
  top: `${pe.top}px`
911
911
  } : void 0;
912
- wt(() => {
913
- if (!ne || !I) {
914
- Ue(void 0);
912
+ It(() => {
913
+ if (!ne || !b) {
914
+ Ve(void 0);
915
915
  return;
916
916
  }
917
- et();
918
- }, [ne, I]), ee(() => {
919
- if (!ne || !I) return;
920
- const c = () => et();
917
+ tt();
918
+ }, [ne, b]), ae(() => {
919
+ if (!ne || !b) return;
920
+ const c = () => tt();
921
921
  return window.addEventListener("resize", c), window.addEventListener("scroll", c, !0), () => {
922
922
  window.removeEventListener("resize", c), window.removeEventListener("scroll", c, !0);
923
923
  };
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);
924
+ }, [ne, b]);
925
+ const Ie = (c) => {
926
+ const v = re.current, f = ie.current?.iterator;
927
+ return !v && !f ? !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(), kt(f), !0);
928
928
  };
929
- ee(() => () => {
930
- Ae("unmount");
931
- }, []), ee(() => {
932
- const c = b.loadConversation, v = Ye.current !== s.app.id;
933
- if (Ye.current = s.app.id, Ae("reinitialize"), v && (O(""), X.current = !0), Q(void 0), J(void 0), j(!1), S(Ce()), !c) {
934
- se(void 0), y("ready");
929
+ ae(() => () => {
930
+ Ie("unmount");
931
+ }, []), ae(() => {
932
+ const c = I.loadConversation, v = Ge.current !== s.app.id;
933
+ if (Ge.current = s.app.id, Ie("reinitialize"), v && (B(""), Y.current = !0), te(void 0), j(void 0), X(!1), y(Re()), !c) {
934
+ P(void 0), h("ready");
935
935
  return;
936
936
  }
937
- const g = new AbortController();
938
- return se(void 0), y("loading"), console.info("[make-ai-assistant] conversation load start", {
937
+ const f = new AbortController();
938
+ return P(void 0), h("loading"), console.info("[make-ai-assistant] conversation load start", {
939
939
  appId: s.app.id
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", {
940
+ }), c.call(I, s, { signal: f.signal }).then((k) => {
941
+ f.signal.aborted || (y(Re(k)), h("ready"), console.info("[make-ai-assistant] conversation load success", {
942
942
  appId: s.app.id,
943
943
  messageCount: k.messages.length
944
944
  }));
945
945
  }).catch((k) => {
946
- g.signal.aborted || (console.error("[make-ai-assistant] conversation load failed", {
946
+ f.signal.aborted || (console.error("[make-ai-assistant] conversation load failed", {
947
947
  appId: s.app.id,
948
948
  errorType: k instanceof Error ? k.name : typeof k
949
- }), se(k), y("error"));
950
- }), () => g.abort();
951
- }, [s.app.id, he, b]), ee(() => {
949
+ }), P(k), h("error"));
950
+ }), () => f.abort();
951
+ }, [s.app.id, Fe, I]), ae(() => {
952
952
  const c = fe.current;
953
- if (!c || !X.current) return;
954
- j(!1);
953
+ if (!c || !Y.current) return;
954
+ X(!1);
955
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);
956
+ if (!Y.current) return;
957
+ const f = _.status === "streaming" || globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
958
+ Oe(c, f);
959
959
  });
960
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;
961
+ }, [_.messages, _.progress, _.status]), ae(() => {
962
+ const c = F && !Ze.current;
963
+ if (Ze.current = F, !c) return;
964
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();
965
+ const f = fe.current;
966
+ if (f && Y.current) {
967
+ X(!1);
968
+ const ge = J.current.status === "streaming" ? "auto" : bt();
969
+ Oe(f, ge);
970
+ } else f && X(J.current.messages.length > 0);
971
+ const k = Ke.current;
972
+ (k && !k.disabled ? k : Ye.current ?? qe.current?.querySelector("button:not(:disabled)"))?.focus();
973
973
  });
974
974
  return () => cancelAnimationFrame(v);
975
- }, [x]);
975
+ }, [F]);
976
976
  const Ht = () => {
977
977
  const c = fe.current;
978
978
  if (!c) return;
979
979
  const v = ja(c);
980
- X.current = v, j(!v && K.current.messages.length > 0);
980
+ Y.current = v, X(!v && J.current.messages.length > 0);
981
981
  }, Bt = () => {
982
982
  const c = fe.current;
983
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} 个字符以内`
984
+ Y.current = !0, X(!1);
985
+ const v = bt();
986
+ Oe(c, v);
987
+ }, nt = async (c, v) => {
988
+ const f = c.trim(), k = J.current, V = v?.regenerateFrom, ge = I.regenerate;
989
+ if (!f || U !== "ready" || k.status === "streaming" || re.current || V && !ge) return;
990
+ if (Se(
991
+ f,
992
+ $.messageCharacters
993
+ ) > $.messageCharacters) {
994
+ te(
995
+ `输入内容过长,请控制在 ${$.messageCharacters} 个字符以内`
996
996
  );
997
997
  return;
998
998
  }
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);
999
+ const Me = {
1000
+ id: V?.userMessage.id ?? pa("user"),
1001
+ content: f
1002
+ }, Te = V ? Ka(k, V.userMessage.id) : ta(k, Me), xe = new AbortController(), ce = oe.current + 1;
1003
+ oe.current = ce, re.current = xe, te(void 0), j(void 0), X(!Y.current && k.messages.length > 0), V || B(""), y(Te);
1004
1004
  try {
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(
1005
+ let G = !1, R, ot = 0, ct = 0, lt = 0, Pe = 0, ve = 0;
1006
+ const _e = /* @__PURE__ */ new Map(), dt = /* @__PURE__ */ new Set(), mt = /* @__PURE__ */ new Set(
1007
1007
  [
1008
- ...xe.messages.map((Re) => Re.id),
1009
- Te.id
1008
+ ...Te.messages.map((Ee) => Ee.id),
1009
+ Me.id
1010
1010
  ]
1011
- ), ye = /* @__PURE__ */ new Set(), mt = ea(Qe), ut = { signal: Ee.signal };
1012
- let Pe;
1013
- if (U) {
1011
+ ), ye = /* @__PURE__ */ new Set(), ut = ea(Je), ht = { signal: xe.signal };
1012
+ let We;
1013
+ if (V) {
1014
1014
  if (!ge)
1015
1015
  throw new w("当前 AI 助手不支持重新生成");
1016
- Pe = ge({
1017
- threadId: xe.threadId,
1018
- message: Te,
1016
+ We = ge({
1017
+ threadId: Te.threadId,
1018
+ message: Me,
1019
1019
  assistantMessage: {
1020
- id: U.assistantMessage.id,
1021
- content: U.assistantMessage.content
1020
+ id: V.assistantMessage.id,
1021
+ content: V.assistantMessage.content
1022
1022
  },
1023
1023
  context: s,
1024
- capabilities: mt
1025
- }, ut);
1024
+ capabilities: ut
1025
+ }, ht);
1026
1026
  } else
1027
- Pe = b.run(
1027
+ We = I.run(
1028
1028
  {
1029
- threadId: xe.threadId,
1030
- message: Te,
1029
+ threadId: Te.threadId,
1030
+ message: Me,
1031
1031
  context: s,
1032
- capabilities: mt
1032
+ capabilities: ut
1033
1033
  },
1034
- ut
1034
+ ht
1035
1035
  );
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;
1036
+ const pt = We[Symbol.asyncIterator]();
1037
+ for (ie.current = { iterator: pt, requestVersion: ce }; ; ) {
1038
+ const Ee = await pt.next();
1039
+ if (oe.current !== ce || Ee.done) break;
1040
1040
  let d;
1041
1041
  try {
1042
- d = aa(Re.value);
1042
+ d = aa(Ee.value);
1043
1043
  } catch (W) {
1044
1044
  throw new w(
1045
1045
  W instanceof Error ? W.message : "Invalid assistant event"
@@ -1048,20 +1048,20 @@ function Ft({
1048
1048
  if (d.type === "message.start") {
1049
1049
  if (R !== void 0 && R !== d.runId)
1050
1050
  throw new w("AI 助手响应 run id 不一致");
1051
- if (R ??= d.runId, ot += 1, ot > L.assistantMessagesPerRun)
1051
+ if (R ??= d.runId, ct += 1, ct > $.assistantMessagesPerRun)
1052
1052
  throw new w("AI 助手单次响应消息数量超过限制");
1053
- if (dt.has(d.messageId))
1053
+ if (mt.has(d.messageId))
1054
1054
  throw new w("AI 助手响应包含重复的 message id");
1055
- dt.add(d.messageId), ye.add(d.messageId), _e.set(d.messageId, 0);
1055
+ mt.add(d.messageId), ye.add(d.messageId), _e.set(d.messageId, 0);
1056
1056
  }
1057
1057
  if (d.type === "message.delta") {
1058
1058
  if (!ye.has(d.messageId))
1059
1059
  throw new w("AI 助手响应事件顺序无效");
1060
- const W = _e.get(d.messageId) ?? 0, le = $e(
1060
+ const W = _e.get(d.messageId) ?? 0, le = Se(
1061
1061
  d.delta,
1062
- L.messageCharacters - ve
1062
+ $.messageCharacters - ve
1063
1063
  );
1064
- if (ve + le > L.messageCharacters)
1064
+ if (ve + le > $.messageCharacters)
1065
1065
  throw new w("AI 助手响应文本超过大小限制");
1066
1066
  ve += le, _e.set(
1067
1067
  d.messageId,
@@ -1071,35 +1071,35 @@ function Ft({
1071
1071
  if (d.type === "message.replace") {
1072
1072
  if (!ye.has(d.messageId))
1073
1073
  throw new w("AI 助手响应事件顺序无效");
1074
- const W = _e.get(d.messageId) ?? 0, le = $e(
1074
+ const W = _e.get(d.messageId) ?? 0, le = Se(
1075
1075
  d.content,
1076
- L.messageCharacters
1077
- ), pt = ve - W + le;
1078
- if (pt > L.messageCharacters)
1076
+ $.messageCharacters
1077
+ ), ft = ve - W + le;
1078
+ if (ft > $.messageCharacters)
1079
1079
  throw new w("AI 助手响应文本超过大小限制");
1080
- ve = pt, _e.set(d.messageId, le);
1080
+ ve = ft, _e.set(d.messageId, le);
1081
1081
  }
1082
1082
  if (d.type === "run.progress") {
1083
1083
  if (R !== void 0 && R !== d.runId)
1084
1084
  throw new w("AI 助手响应 run id 不一致");
1085
- if (R ??= d.runId, ct += 1, ct > L.progressStepsPerRun)
1085
+ if (R ??= d.runId, lt += 1, lt > $.progressStepsPerRun)
1086
1086
  throw new w("AI 助手处理过程数量超过限制");
1087
- const W = $e(
1087
+ const W = Se(
1088
1088
  d.message,
1089
- L.progressCharactersPerRun - Fe
1089
+ $.progressCharactersPerRun - Pe
1090
1090
  );
1091
- if (Fe + W > L.progressCharactersPerRun)
1091
+ if (Pe + W > $.progressCharactersPerRun)
1092
1092
  throw new w("AI 助手处理过程文本超过大小限制");
1093
- Fe += W;
1093
+ Pe += W;
1094
1094
  }
1095
1095
  if (d.type === "artifact") {
1096
1096
  if (!ye.has(d.messageId))
1097
1097
  throw new w("AI 助手响应事件顺序无效");
1098
- if (it += 1, it > L.artifactsPerRun)
1098
+ if (ot += 1, ot > $.artifactsPerRun)
1099
1099
  throw new w("AI 助手单次响应 Artifact 数量超过限制");
1100
- if (lt.has(d.artifact.id))
1100
+ if (dt.has(d.artifact.id))
1101
1101
  throw new w("AI 助手响应包含重复的 Artifact id");
1102
- lt.add(d.artifact.id);
1102
+ dt.add(d.artifact.id);
1103
1103
  }
1104
1104
  if (d.type === "message.complete" && !ye.delete(d.messageId))
1105
1105
  throw new w("AI 助手响应事件顺序无效");
@@ -1107,87 +1107,87 @@ function Ft({
1107
1107
  throw new w("AI 助手响应 run id 不一致");
1108
1108
  if (d.type === "run.cancelled" && d.runId !== void 0 && R !== void 0 && R !== d.runId)
1109
1109
  throw new w("AI 助手响应 run id 不一致");
1110
- if (S((W) => Se(W, d)), d.type === "error" || d.type === "run.cancelled" || d.type === "run.complete") {
1111
- Y = !0;
1110
+ if (y((W) => Ce(W, d)), d.type === "error" || d.type === "run.cancelled" || d.type === "run.complete") {
1111
+ G = !0;
1112
1112
  break;
1113
1113
  }
1114
1114
  }
1115
- if (!Y)
1115
+ if (!G)
1116
1116
  throw new w("AI 助手流式响应在终止事件前结束");
1117
- } catch (Y) {
1117
+ } catch (G) {
1118
1118
  if (oe.current !== ce) return;
1119
- if (Ee.signal.aborted) {
1120
- S(
1121
- (R) => Se(R, { type: "run.cancelled" })
1119
+ if (xe.signal.aborted) {
1120
+ y(
1121
+ (R) => Ce(R, { type: "run.cancelled" })
1122
1122
  );
1123
1123
  return;
1124
1124
  }
1125
1125
  console.error("[make-ai-assistant] assistant run failed", {
1126
1126
  appId: s.app.id,
1127
- errorType: Y instanceof Error ? Y.name : typeof Y
1128
- }), S(
1129
- (R) => Se(R, {
1127
+ errorType: G instanceof Error ? G.name : typeof G
1128
+ }), y(
1129
+ (R) => Ce(R, {
1130
1130
  type: "error",
1131
1131
  code: "TRANSPORT_ERROR",
1132
- message: Y instanceof w ? Y.message : "连接失败,请重试",
1132
+ message: G instanceof w ? G.message : "连接失败,请重试",
1133
1133
  retryable: !0
1134
1134
  })
1135
1135
  );
1136
1136
  } finally {
1137
- oe.current === ce && re.current === Ee && (re.current = void 0), ie.current?.requestVersion === ce && (yt(ie.current.iterator), ie.current = void 0);
1137
+ oe.current === ce && re.current === xe && (re.current = void 0), ie.current?.requestVersion === ce && (kt(ie.current.iterator), ie.current = void 0);
1138
1138
  }
1139
- }, Ne = (c) => st(c), Ot = (c) => st(c.userMessage.content, { regenerateFrom: c }), zt = async (c, v) => {
1139
+ }, Ae = (c) => nt(c), Ot = (c) => nt(c.userMessage.content, { regenerateFrom: c }), zt = async (c, v) => {
1140
1140
  try {
1141
- await xa(v), J({ messageId: c, message: "已复制", status: "success" });
1142
- } catch (g) {
1141
+ await xa(v), j({ messageId: c, message: "已复制", status: "success" });
1142
+ } catch (f) {
1143
1143
  console.error("[make-ai-assistant] copy answer failed", {
1144
- errorType: g instanceof Error ? g.name : typeof g
1145
- }), J({ messageId: c, message: "复制失败", status: "error" });
1144
+ errorType: f instanceof Error ? f.name : typeof f
1145
+ }), j({ messageId: c, message: "复制失败", status: "error" });
1146
1146
  }
1147
1147
  }, Ut = (c) => {
1148
- c.preventDefault(), Ne(P);
1148
+ c.preventDefault(), Ae(S);
1149
1149
  }, Vt = (c) => {
1150
- c.key === "Enter" && !c.shiftKey && !c.nativeEvent.isComposing && (c.preventDefault(), Ne(P));
1150
+ c.key === "Enter" && !c.shiftKey && !c.nativeEvent.isComposing && (c.preventDefault(), Ae(S));
1151
1151
  }, qt = () => {
1152
- Ae("stop") && S(
1153
- (c) => Se(c, { type: "run.cancelled" })
1152
+ Ie("stop") && y(
1153
+ (c) => Ce(c, { type: "run.cancelled" })
1154
1154
  );
1155
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);
1156
+ Ie("new-conversation"), B(""), te(void 0), j(void 0), X(!1), Y.current = !0, y(Re()), l?.();
1157
+ }, rt = I.features?.remoteCancellation === !1 ? "停止接收" : "停止生成", jt = $t(_), Xt = Lt(_), Ne = qa(_), Yt = typeof I.regenerate == "function" && I.features?.regeneration !== !1, it = () => {
1158
+ Ne && Ae(Ne.content);
1159
1159
  };
1160
1160
  return /* @__PURE__ */ i(
1161
1161
  "section",
1162
1162
  {
1163
1163
  className: "make-ai-assistant make-ai-assistant__panel",
1164
- ref: Ve,
1165
- style: F,
1164
+ ref: qe,
1165
+ style: K,
1166
1166
  children: [
1167
1167
  /* @__PURE__ */ i("header", { className: "make-ai-assistant__header", children: [
1168
- /* @__PURE__ */ a(De, {}),
1168
+ /* @__PURE__ */ a(Le, {}),
1169
1169
  /* @__PURE__ */ i("div", { className: "make-ai-assistant__header-content", children: [
1170
1170
  /* @__PURE__ */ i("div", { className: "make-ai-assistant__header-title-row", children: [
1171
- /* @__PURE__ */ a("h2", { className: "make-ai-assistant__header-title", title: h, children: h }),
1171
+ /* @__PURE__ */ a("h2", { className: "make-ai-assistant__header-title", title: u, children: u }),
1172
1172
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__read-only-tag", children: "只读" })
1173
1173
  ] }),
1174
1174
  /* @__PURE__ */ i("div", { className: "make-ai-assistant__header-context", children: [
1175
- /* @__PURE__ */ a("p", { title: q, children: q }),
1176
- I ? /* @__PURE__ */ i(G, { children: [
1175
+ /* @__PURE__ */ a("p", { title: Q, children: Q }),
1176
+ b ? /* @__PURE__ */ i(Z, { children: [
1177
1177
  /* @__PURE__ */ a(
1178
1178
  "span",
1179
1179
  {
1180
- "aria-describedby": Ze,
1181
- "aria-label": `使用提示:${I}`,
1180
+ "aria-describedby": Qe,
1181
+ "aria-label": `使用提示:${b}`,
1182
1182
  className: "make-ai-assistant__header-context-help",
1183
- "data-tooltip": I,
1184
- ref: Ke,
1183
+ "data-tooltip": b,
1184
+ ref: je,
1185
1185
  role: "note",
1186
1186
  tabIndex: 0,
1187
- onBlur: at,
1188
- onFocus: tt,
1189
- onPointerEnter: tt,
1190
- onPointerLeave: at,
1187
+ onBlur: st,
1188
+ onFocus: at,
1189
+ onPointerEnter: at,
1190
+ onPointerLeave: st,
1191
1191
  children: /* @__PURE__ */ a(Sa, {})
1192
1192
  }
1193
1193
  ),
@@ -1199,18 +1199,18 @@ function Ft({
1199
1199
  "data-placement": pe?.placement,
1200
1200
  "data-positioned": pe ? !0 : void 0,
1201
1201
  "data-visible": ne || void 0,
1202
- id: Ze,
1203
- ref: je,
1202
+ id: Qe,
1203
+ ref: Xe,
1204
1204
  role: "tooltip",
1205
1205
  style: Wt,
1206
- children: I
1206
+ children: b
1207
1207
  }
1208
1208
  )
1209
1209
  ] }) : null
1210
1210
  ] })
1211
1211
  ] }),
1212
1212
  /* @__PURE__ */ i("div", { className: "make-ai-assistant__header-actions", children: [
1213
- b.features?.newConversation !== !1 ? /* @__PURE__ */ a(
1213
+ I.features?.newConversation !== !1 ? /* @__PURE__ */ a(
1214
1214
  "button",
1215
1215
  {
1216
1216
  "aria-label": "新建对话",
@@ -1223,7 +1223,7 @@ function Ft({
1223
1223
  o ? /* @__PURE__ */ a(
1224
1224
  "button",
1225
1225
  {
1226
- "aria-label": `关闭 ${h}`,
1226
+ "aria-label": `关闭 ${u}`,
1227
1227
  className: "make-ai-assistant__icon-button",
1228
1228
  type: "button",
1229
1229
  onClick: o,
@@ -1242,32 +1242,32 @@ function Ft({
1242
1242
  role: "log",
1243
1243
  onScroll: Ht,
1244
1244
  children: [
1245
- u === "loading" ? /* @__PURE__ */ i("div", { className: "make-ai-assistant__empty", role: "status", children: [
1246
- /* @__PURE__ */ a(De, {}),
1245
+ U === "loading" ? /* @__PURE__ */ i("div", { className: "make-ai-assistant__empty", role: "status", children: [
1246
+ /* @__PURE__ */ a(Le, {}),
1247
1247
  /* @__PURE__ */ a("h3", { children: "正在恢复对话" }),
1248
1248
  /* @__PURE__ */ a("p", { children: "正在读取当前 App 的历史消息…" })
1249
- ] }) : u === "error" ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__empty", children: /* @__PURE__ */ a(
1249
+ ] }) : U === "error" ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__empty", children: /* @__PURE__ */ a(
1250
1250
  Xa,
1251
1251
  {
1252
- error: z,
1253
- onRetry: () => Ie((c) => c + 1)
1252
+ error: N,
1253
+ onRetry: () => he((c) => c + 1)
1254
1254
  }
1255
- ) }) : p.messages.length === 0 ? /* @__PURE__ */ i("div", { className: "make-ai-assistant__empty", children: [
1256
- /* @__PURE__ */ a(De, {}),
1255
+ ) }) : _.messages.length === 0 ? /* @__PURE__ */ i("div", { className: "make-ai-assistant__empty", children: [
1256
+ /* @__PURE__ */ a(Le, {}),
1257
1257
  /* @__PURE__ */ a("h3", { children: "有什么可以帮你?" }),
1258
1258
  /* @__PURE__ */ a("p", { children: "我会结合当前 App、页面位置和宿主允许的上下文回答,并把过程与结果分开展示。" })
1259
1259
  ] }) : Ga(
1260
- p,
1260
+ _,
1261
1261
  s,
1262
- Qe,
1263
- D,
1262
+ Je,
1263
+ C,
1264
1264
  r,
1265
1265
  n,
1266
1266
  e,
1267
- Me ? rt : void 0,
1268
- V,
1269
- C,
1270
- we,
1267
+ Ne ? it : void 0,
1268
+ D,
1269
+ L,
1270
+ De,
1271
1271
  Yt,
1272
1272
  (c, v) => {
1273
1273
  zt(c, v);
@@ -1276,25 +1276,25 @@ function Ft({
1276
1276
  Ot(c);
1277
1277
  }
1278
1278
  ),
1279
- p.progress && !jt ? /* @__PURE__ */ a(
1280
- bt,
1279
+ _.progress && !jt ? /* @__PURE__ */ a(
1280
+ wt,
1281
1281
  {
1282
1282
  assistantName: e,
1283
- progress: p.progress
1283
+ progress: _.progress
1284
1284
  }
1285
1285
  ) : null,
1286
- p.error && !Xt ? /* @__PURE__ */ a(
1287
- bt,
1286
+ _.error && !Xt ? /* @__PURE__ */ a(
1287
+ wt,
1288
1288
  {
1289
1289
  assistantName: e,
1290
- error: p.error,
1291
- onRetry: Me ? rt : void 0
1290
+ error: _.error,
1291
+ onRetry: Ne ? it : void 0
1292
1292
  }
1293
1293
  ) : null
1294
1294
  ]
1295
1295
  }
1296
1296
  ),
1297
- Pt ? /* @__PURE__ */ a(
1297
+ we ? /* @__PURE__ */ a(
1298
1298
  "button",
1299
1299
  {
1300
1300
  "aria-label": "回到最新消息",
@@ -1305,12 +1305,12 @@ function Ft({
1305
1305
  }
1306
1306
  ) : null,
1307
1307
  /* @__PURE__ */ i("footer", { className: "make-ai-assistant__composer-region", children: [
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(
1308
+ U === "ready" && et.length > 0 && _.messages.length === 0 ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__suggestions", "aria-label": "推荐问题", children: et.map((c, v) => /* @__PURE__ */ a(
1309
1309
  "button",
1310
1310
  {
1311
1311
  type: "button",
1312
1312
  onClick: () => {
1313
- Ne(c);
1313
+ Ae(c);
1314
1314
  },
1315
1315
  children: c
1316
1316
  },
@@ -1321,27 +1321,27 @@ function Ft({
1321
1321
  "textarea",
1322
1322
  {
1323
1323
  "aria-label": `向 ${e} 提问`,
1324
- "aria-describedby": ae ? "make-ai-composer-error" : void 0,
1325
- "aria-invalid": ae ? !0 : void 0,
1324
+ "aria-describedby": ee ? "make-ai-composer-error" : void 0,
1325
+ "aria-invalid": ee ? !0 : void 0,
1326
1326
  autoFocus: !0,
1327
- disabled: u !== "ready" || p.status === "streaming",
1327
+ disabled: U !== "ready" || _.status === "streaming",
1328
1328
  placeholder: `询问当前 ${s.app.name ?? "App"} 中的数据…`,
1329
- ref: qe,
1329
+ ref: Ke,
1330
1330
  rows: 2,
1331
- value: P,
1331
+ value: S,
1332
1332
  onChange: (c) => {
1333
- O(c.currentTarget.value), Q(void 0);
1333
+ B(c.currentTarget.value), te(void 0);
1334
1334
  },
1335
1335
  onKeyDown: Vt
1336
1336
  }
1337
1337
  ),
1338
- p.status === "streaming" ? /* @__PURE__ */ a(
1338
+ _.status === "streaming" ? /* @__PURE__ */ a(
1339
1339
  "button",
1340
1340
  {
1341
- "aria-label": nt,
1341
+ "aria-label": rt,
1342
1342
  className: "make-ai-assistant__send make-ai-assistant__send--stop",
1343
- "data-tooltip": nt,
1344
- ref: Xe,
1343
+ "data-tooltip": rt,
1344
+ ref: Ye,
1345
1345
  type: "button",
1346
1346
  onClick: qt,
1347
1347
  children: /* @__PURE__ */ a("span", { "aria-hidden": "true" })
@@ -1351,13 +1351,13 @@ function Ft({
1351
1351
  {
1352
1352
  "aria-label": "发送",
1353
1353
  className: "make-ai-assistant__send",
1354
- disabled: u !== "ready" || !P.trim(),
1354
+ disabled: U !== "ready" || !S.trim(),
1355
1355
  type: "submit",
1356
1356
  children: /* @__PURE__ */ a(Da, {})
1357
1357
  }
1358
1358
  )
1359
1359
  ] }),
1360
- ae ? /* @__PURE__ */ a("p", { id: "make-ai-composer-error", role: "alert", children: ae }) : null,
1360
+ ee ? /* @__PURE__ */ a("p", { id: "make-ai-composer-error", role: "alert", children: ee }) : null,
1361
1361
  /* @__PURE__ */ a("p", { children: "AI 生成的结果可能存在偏差,重要数据请核对明细。" })
1362
1362
  ] })
1363
1363
  ]
@@ -1365,134 +1365,136 @@ function Ft({
1365
1365
  );
1366
1366
  }
1367
1367
  function ts(e) {
1368
- return /* @__PURE__ */ a(Ft, { ...e, visible: !0 });
1368
+ return /* @__PURE__ */ a(Pt, { ...e, visible: !0 });
1369
1369
  }
1370
1370
  function as({
1371
1371
  defaultOpen: e = !1,
1372
1372
  hideLauncher: t = !1,
1373
1373
  launcher: s,
1374
- maxDrawerWidth: r,
1375
- onOpenChange: n,
1376
- open: o,
1377
- ...l
1374
+ launcherPosition: r = "bottom-right",
1375
+ maxDrawerWidth: n,
1376
+ onOpenChange: o,
1377
+ open: l,
1378
+ ...m
1378
1379
  }) {
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)`
1380
+ const g = xt(m.brandName, m.title), [p, M] = E(e), [x, H] = E(
1381
+ () => e || l === !0
1382
+ ), C = T(null), I = T(null), L = T(void 0), [D, F] = E(), [u, b] = E(ka), [Q, q] = E(!1), A = l ?? p, K = ze(m.theme), S = wa(n), B = () => Ia(
1383
+ u,
1384
+ S,
1385
+ typeof window > "u" ? Et : window.innerWidth
1386
+ ), _ = B(), y = D === void 0 ? void 0 : He(D, u, _), J = y === void 0 && S === void 0 ? void 0 : {
1387
+ ...y === void 0 ? {} : { "--make-ai-internal-drawer-width": `${y}px` },
1388
+ ...S === void 0 ? {} : {
1389
+ "--make-ai-internal-drawer-max-width": `max(var(--make-ai-internal-drawer-min-width), ${S}px)`
1389
1390
  }
1390
1391
  };
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()
1392
+ It(() => {
1393
+ y !== void 0 && y !== D && F(y);
1394
+ }, [y, D]);
1395
+ const ee = () => {
1396
+ if (y !== void 0) return y;
1397
+ const h = I.current?.getBoundingClientRect().width;
1398
+ return h && Number.isFinite(h) && h > 0 ? h : u;
1399
+ }, te = (h) => {
1400
+ if (h.button !== 0) return;
1401
+ const N = ee(), P = D === void 0 ? N : u;
1402
+ b(P), L.current = {
1403
+ minimumWidth: P,
1404
+ pointerId: h.pointerId,
1405
+ startWidth: N,
1406
+ startX: h.clientX
1407
+ }, q(!0), typeof h.currentTarget.setPointerCapture == "function" && h.currentTarget.setPointerCapture(h.pointerId), h.preventDefault();
1408
+ }, De = (h) => {
1409
+ const N = L.current;
1410
+ if (!N || N.pointerId !== h.pointerId) return;
1411
+ const P = He(
1412
+ N.startWidth + N.startX - h.clientX,
1413
+ N.minimumWidth,
1414
+ B()
1414
1415
  );
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()
1416
+ F(P);
1417
+ }, j = (h) => {
1418
+ const N = L.current;
1419
+ !N || N.pointerId !== h.pointerId || (L.current = void 0, q(!1));
1420
+ }, Fe = (h) => {
1421
+ const N = h.key === "ArrowLeft" ? _t : h.key === "ArrowRight" ? -_t : void 0;
1422
+ if (N === void 0) return;
1423
+ h.preventDefault();
1424
+ const P = ee(), we = D === void 0 ? P : u;
1425
+ b(we), F(He(
1426
+ P + N,
1427
+ we,
1428
+ B()
1428
1429
  ));
1429
- }, he = (u) => {
1430
- o === void 0 && f(u), n?.(u), u || requestAnimationFrame(() => $.current?.focus());
1431
- }, Ie = () => he(!A);
1432
- return ee(() => {
1433
- A && T(!0);
1434
- }, [A]), ee(() => {
1430
+ }, he = (h) => {
1431
+ l === void 0 && M(h), o?.(h), h || requestAnimationFrame(() => C.current?.focus());
1432
+ }, U = () => he(!A);
1433
+ return ae(() => {
1434
+ A && H(!0);
1435
+ }, [A]), ae(() => {
1435
1436
  if (!A) return;
1436
- const u = (y) => {
1437
- y.key === "Escape" && (he(!1), requestAnimationFrame(() => $.current?.focus()));
1437
+ const h = (N) => {
1438
+ N.key === "Escape" && (he(!1), requestAnimationFrame(() => C.current?.focus()));
1438
1439
  };
1439
- return document.addEventListener("keydown", u), () => document.removeEventListener("keydown", u);
1440
- }, [n, A]), /* @__PURE__ */ i(
1440
+ return document.addEventListener("keydown", h), () => document.removeEventListener("keydown", h);
1441
+ }, [o, A]), /* @__PURE__ */ i(
1441
1442
  "div",
1442
1443
  {
1443
1444
  className: "make-ai-assistant",
1444
1445
  "data-open": A || void 0,
1445
- style: Z,
1446
+ style: K,
1446
1447
  children: [
1447
- !t && (!A || s) ? s ? s({ open: A, toggle: Ie }) : /* @__PURE__ */ i(
1448
+ !t && (!A || s) ? s ? s({ open: A, toggle: U }) : /* @__PURE__ */ i(
1448
1449
  "button",
1449
1450
  {
1450
- "aria-label": A ? `关闭 ${m}` : `打开 ${m}`,
1451
+ "aria-label": A ? `关闭 ${g}` : `打开 ${g}`,
1451
1452
  "aria-expanded": A,
1452
1453
  className: "make-ai-assistant__launcher",
1453
- ref: $,
1454
+ "data-launcher-position": r,
1455
+ ref: C,
1454
1456
  type: "button",
1455
- onClick: Ie,
1457
+ onClick: U,
1456
1458
  children: [
1457
1459
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__launcher-orbit", "aria-hidden": "true" }),
1458
- /* @__PURE__ */ a(Et, {})
1460
+ /* @__PURE__ */ a(Rt, {})
1459
1461
  ]
1460
1462
  }
1461
1463
  ) : null,
1462
- N ? /* @__PURE__ */ i(
1464
+ x ? /* @__PURE__ */ i(
1463
1465
  "aside",
1464
1466
  {
1465
- "aria-label": m,
1467
+ "aria-label": g,
1466
1468
  "aria-modal": "false",
1467
1469
  className: "make-ai-assistant__drawer",
1468
- "data-resizing": I || void 0,
1470
+ "data-resizing": Q || void 0,
1469
1471
  hidden: !A,
1470
- ref: D,
1472
+ ref: I,
1471
1473
  role: "dialog",
1472
- style: S,
1474
+ style: J,
1473
1475
  children: [
1474
1476
  /* @__PURE__ */ a(
1475
1477
  "div",
1476
1478
  {
1477
1479
  "aria-label": "调整对话框宽度",
1478
1480
  "aria-orientation": "vertical",
1479
- "aria-valuemax": O,
1480
- "aria-valuemin": x,
1481
- "aria-valuenow": p ?? x,
1481
+ "aria-valuemax": _,
1482
+ "aria-valuemin": u,
1483
+ "aria-valuenow": y ?? u,
1482
1484
  className: "make-ai-assistant__drawer-resize-handle",
1483
1485
  role: "separator",
1484
1486
  tabIndex: 0,
1485
- onKeyDown: J,
1486
- onPointerCancel: we,
1487
- onPointerDown: ae,
1488
- onPointerMove: Q,
1489
- onPointerUp: we
1487
+ onKeyDown: Fe,
1488
+ onPointerCancel: j,
1489
+ onPointerDown: te,
1490
+ onPointerMove: De,
1491
+ onPointerUp: j
1490
1492
  }
1491
1493
  ),
1492
1494
  /* @__PURE__ */ a(
1493
- Ft,
1495
+ Pt,
1494
1496
  {
1495
- ...l,
1497
+ ...m,
1496
1498
  onClose: () => he(!1),
1497
1499
  visible: A
1498
1500
  }
@@ -1510,19 +1512,19 @@ export {
1510
1512
  os as MAKE_AI_ARTIFACT_KINDS,
1511
1513
  cs as MAKE_AI_ARTIFACT_LIMITS,
1512
1514
  ls as MAKE_AI_ARTIFACT_SCHEMA_VERSION,
1513
- L as MAKE_AI_CONVERSATION_LIMITS,
1515
+ $ as MAKE_AI_CONVERSATION_LIMITS,
1514
1516
  as as MakeAiAssistant,
1515
1517
  ta as appendUserMessage,
1516
1518
  ea as createArtifactCapabilities,
1517
- It as createArtifactTemplateRegistry,
1518
- Ce as createAssistantConversationState,
1519
+ At as createArtifactTemplateRegistry,
1520
+ Re as createAssistantConversationState,
1519
1521
  ha as createPlatformArtifactRegistry,
1520
1522
  rs as extendArtifactTemplateRegistry,
1521
- te as formatArtifactValue,
1523
+ se as formatArtifactValue,
1522
1524
  ds as parseArtifact,
1523
1525
  aa as parseAssistantEvent,
1524
1526
  ua as platformArtifactTemplates,
1525
- Se as reduceAssistantEvent,
1527
+ Ce as reduceAssistantEvent,
1526
1528
  Jt as resolveArtifactTemplate,
1527
1529
  ms as validateArtifact
1528
1530
  };