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

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