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

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