@qfei-design/make-ai-assistant 0.3.0 → 0.3.1

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,53 +1,53 @@
1
- import { jsxs as u, jsx as a, Fragment as Ie } from "react/jsx-runtime";
2
- import { isValidElement as Oa, cloneElement as qa, useContext as ja, createContext as Ba, forwardRef as Yt, createElement as Nt, useRef as D, useState as $, useEffect as ne, useLayoutEffect as At, useCallback as Va, useId as Ka, useMemo as Ft } from "react";
3
- import { resolveArtifactTemplate as Wa, createArtifactTemplateRegistry as Qt, createArtifactCapabilities as Xa } from "./index.mjs";
1
+ import { jsxs as m, jsx as a, Fragment as Ne } from "react/jsx-runtime";
2
+ import { isValidElement as Oa, cloneElement as qa, useContext as Ba, createContext as Va, forwardRef as Yt, createElement as Nt, useRef as P, useState as R, useEffect as se, useLayoutEffect as At, useCallback as Ka, useId as Wa, useMemo as Ft } from "react";
3
+ import { resolveArtifactTemplate as Xa, createArtifactTemplateRegistry as Qt, createArtifactCapabilities as Ga } from "./index.mjs";
4
4
  import { extendArtifactTemplateRegistry as En } from "./index.mjs";
5
- import { a as fe, r as we, p as ea, b as ta, c as ht, M as de } from "./conversation-DuqMadaQ.js";
5
+ import { a as ye, r as Ie, p as ea, b as ta, c as lt, M as ue } from "./conversation-DuqMadaQ.js";
6
6
  import { d as Sn, e as Rn, f as Ln, g as zn, v as xn } from "./conversation-DuqMadaQ.js";
7
- import { i as gt } from "./conversation-management-DZROhXyK.js";
7
+ import { i as kt } from "./conversation-management-DZROhXyK.js";
8
8
  import { createPortal as aa } from "react-dom";
9
- const sa = (e) => e?.trim() || void 0, ke = (e, t) => sa(e) ?? t, Mt = (e) => {
9
+ const sa = (e) => e?.trim() || void 0, _e = (e, t) => sa(e) ?? t, Mt = (e) => {
10
10
  const t = sa(e?.primary);
11
11
  if (t)
12
12
  return {
13
13
  "--make-ai-theme-primary": t,
14
- "--make-ai-theme-primary-hover": ke(
14
+ "--make-ai-theme-primary-hover": _e(
15
15
  e?.primaryHover,
16
16
  "color-mix(in srgb, var(--make-ai-theme-primary) 84%, #15233d)"
17
17
  ),
18
- "--make-ai-theme-on-primary": ke(
18
+ "--make-ai-theme-on-primary": _e(
19
19
  e?.onPrimary,
20
20
  "#fcfcff"
21
21
  ),
22
- "--make-ai-theme-bg": ke(
22
+ "--make-ai-theme-bg": _e(
23
23
  e?.background,
24
24
  "color-mix(in srgb, var(--make-ai-theme-primary) 2%, #fcfcff)"
25
25
  ),
26
- "--make-ai-theme-surface": ke(
26
+ "--make-ai-theme-surface": _e(
27
27
  e?.surface,
28
28
  "color-mix(in srgb, var(--make-ai-theme-primary) 4%, var(--make-ai-theme-bg))"
29
29
  ),
30
- "--make-ai-theme-surface-strong": ke(
30
+ "--make-ai-theme-surface-strong": _e(
31
31
  e?.surfaceStrong,
32
32
  "color-mix(in srgb, var(--make-ai-theme-primary) 8%, var(--make-ai-theme-bg))"
33
33
  ),
34
- "--make-ai-theme-text": ke(
34
+ "--make-ai-theme-text": _e(
35
35
  e?.text,
36
36
  "color-mix(in srgb, var(--make-ai-theme-primary) 12%, #252631)"
37
37
  ),
38
- "--make-ai-theme-text-secondary": ke(
38
+ "--make-ai-theme-text-secondary": _e(
39
39
  e?.textSecondary,
40
40
  "color-mix(in srgb, var(--make-ai-theme-text) 74%, var(--make-ai-theme-primary))"
41
41
  ),
42
- "--make-ai-theme-border": ke(
42
+ "--make-ai-theme-border": _e(
43
43
  e?.border,
44
44
  "color-mix(in srgb, var(--make-ai-theme-primary) 14%, var(--make-ai-theme-bg))"
45
45
  ),
46
- "--make-ai-theme-overlay": ke(
46
+ "--make-ai-theme-overlay": _e(
47
47
  e?.overlay,
48
48
  "color-mix(in srgb, var(--make-ai-theme-text) 88%, var(--make-ai-theme-primary))"
49
49
  ),
50
- "--make-ai-theme-on-overlay": ke(
50
+ "--make-ai-theme-on-overlay": _e(
51
51
  e?.onOverlay,
52
52
  "#fcfcff"
53
53
  )
@@ -55,36 +55,36 @@ const sa = (e) => e?.trim() || void 0, ke = (e, t) => sa(e) ?? t, Mt = (e) => {
55
55
  }, Ht = (e, t) => !t || !Oa(e) || typeof e.type != "string" ? e : qa(e, {
56
56
  style: { ...e.props.style, ...t }
57
57
  });
58
- function Ga({
58
+ function Za({
59
59
  artifact: e,
60
60
  context: t,
61
61
  fallback: s,
62
62
  onAction: n,
63
63
  onActionError: i,
64
- registry: c,
65
- theme: l
64
+ registry: o,
65
+ theme: d
66
66
  }) {
67
- const m = Mt(l), y = Wa(c, e, t);
68
- if (!y) {
69
- const A = s ? s(e) : /* @__PURE__ */ u("section", { className: "make-ai-artifact make-ai-artifact--unsupported", role: "status", children: [
67
+ const h = Mt(d), v = Xa(o, e, t);
68
+ if (!v) {
69
+ const N = s ? s(e) : /* @__PURE__ */ m("section", { className: "make-ai-artifact make-ai-artifact--unsupported", role: "status", children: [
70
70
  /* @__PURE__ */ a("strong", { children: "暂不支持展示此结果" }),
71
- /* @__PURE__ */ u("span", { children: [
71
+ /* @__PURE__ */ m("span", { children: [
72
72
  "结果类型:",
73
73
  e.kind
74
74
  ] })
75
75
  ] });
76
- return Ht(A, m);
76
+ return Ht(N, h);
77
77
  }
78
- const v = {
78
+ const I = {
79
79
  context: t,
80
80
  onAction: n,
81
81
  onActionError: i,
82
- theme: l,
83
- themeStyle: m
84
- }, p = y.template.render(e, t, v);
85
- return Ht(p, m);
82
+ theme: d,
83
+ themeStyle: h
84
+ }, f = v.template.render(e, t, I);
85
+ return Ht(f, h);
86
86
  }
87
- const Le = (e, t, s) => {
87
+ const xe = (e, t, s) => {
88
88
  if (e == null || e === "") return "—";
89
89
  if (typeof e == "boolean") return e ? "是" : "否";
90
90
  if (typeof e != "number") return `${e}${t?.unit ?? ""}`;
@@ -94,8 +94,8 @@ const Le = (e, t, s) => {
94
94
  };
95
95
  t?.style === "currency" && t.currency ? (i.style = "currency", i.currency = t.currency) : t?.style === "percent" && (i.style = "percent");
96
96
  try {
97
- const c = t?.style === "percent" ? e / 100 : e;
98
- return `${new Intl.NumberFormat(s, i).format(c)}${t?.unit ?? ""}`;
97
+ const o = t?.style === "percent" ? e / 100 : e;
98
+ return `${new Intl.NumberFormat(s, i).format(o)}${t?.unit ?? ""}`;
99
99
  } catch {
100
100
  return `${e}${t?.unit ?? ""}`;
101
101
  }
@@ -106,37 +106,37 @@ const Le = (e, t, s) => {
106
106
  return Number.isFinite(t) && Number.isFinite(s) ? { min: t, max: s } : { min: 0, max: 0 };
107
107
  }, ia = (e, t, s) => {
108
108
  if (!s.onAction) return;
109
- const n = (c) => {
109
+ const n = (o) => {
110
110
  console.error("[make-ai-assistant] host action error handler failed", {
111
111
  actionId: e.id,
112
112
  artifactId: t.artifact.id,
113
- errorType: c instanceof Error ? c.name : typeof c,
113
+ errorType: o instanceof Error ? o.name : typeof o,
114
114
  intent: e.intent
115
115
  });
116
- }, i = (c) => {
116
+ }, i = (o) => {
117
117
  if (s.onActionError) {
118
118
  try {
119
119
  Promise.resolve(
120
- s.onActionError(c, e, t)
120
+ s.onActionError(o, e, t)
121
121
  ).catch(n);
122
- } catch (l) {
123
- n(l);
122
+ } catch (d) {
123
+ n(d);
124
124
  }
125
125
  return;
126
126
  }
127
127
  console.error("[make-ai-assistant] host action failed", {
128
128
  actionId: e.id,
129
129
  artifactId: t.artifact.id,
130
- errorType: c instanceof Error ? c.name : typeof c,
130
+ errorType: o instanceof Error ? o.name : typeof o,
131
131
  intent: e.intent
132
132
  });
133
133
  };
134
134
  try {
135
135
  Promise.resolve(s.onAction(e, t)).catch(i);
136
- } catch (c) {
137
- i(c);
136
+ } catch (o) {
137
+ i(o);
138
138
  }
139
- }, qe = (e, t) => e.actions?.length && t.onAction ? /* @__PURE__ */ a("div", { className: "make-ai-artifact__actions", children: e.actions.map((s) => /* @__PURE__ */ u(
139
+ }, Be = (e, t) => e.actions?.length && t.onAction ? /* @__PURE__ */ a("div", { className: "make-ai-artifact__actions", children: e.actions.map((s) => /* @__PURE__ */ m(
140
140
  "button",
141
141
  {
142
142
  className: `make-ai-artifact__action make-ai-artifact__action--${s.appearance ?? "link"}`,
@@ -148,7 +148,7 @@ const Le = (e, t, s) => {
148
148
  ]
149
149
  },
150
150
  s.id
151
- )) }) : null, je = (e, t, s = "", n) => /* @__PURE__ */ u(
151
+ )) }) : null, Ve = (e, t, s = "", n) => /* @__PURE__ */ m(
152
152
  "section",
153
153
  {
154
154
  "aria-label": e.title ?? `${e.kind} result`,
@@ -162,24 +162,24 @@ const Le = (e, t, s) => {
162
162
  t
163
163
  ]
164
164
  }
165
- ), Za = ({
165
+ ), Ja = ({
166
166
  artifact: e,
167
167
  renderContext: t
168
168
  }) => {
169
- const s = e.data.delta, n = s ? Le(
169
+ const s = e.data.delta, n = s ? xe(
170
170
  s.value,
171
171
  s.format === "percent" ? { style: "percent" } : void 0,
172
172
  t.context.locale
173
173
  ) : void 0;
174
- return je(
174
+ return Ve(
175
175
  e,
176
- /* @__PURE__ */ u(Ie, { children: [
177
- /* @__PURE__ */ a("div", { className: "make-ai-artifact__metric-value", children: Le(
176
+ /* @__PURE__ */ m(Ne, { children: [
177
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__metric-value", children: xe(
178
178
  e.data.value,
179
179
  e.data.format,
180
180
  t.context.locale
181
181
  ) }),
182
- s ? /* @__PURE__ */ u(
182
+ s ? /* @__PURE__ */ m(
183
183
  "div",
184
184
  {
185
185
  className: `make-ai-artifact__delta make-ai-artifact__delta--${s.direction ?? "flat"}`,
@@ -191,112 +191,112 @@ const Le = (e, t, s) => {
191
191
  }
192
192
  ) : null,
193
193
  e.data.context ? /* @__PURE__ */ a("p", { className: "make-ai-artifact__context", children: e.data.context }) : null,
194
- qe(e, t)
194
+ Be(e, t)
195
195
  ] }),
196
196
  "make-ai-artifact--metric",
197
197
  t.themeStyle
198
198
  );
199
- }, Ja = ({
199
+ }, Ya = ({
200
200
  artifact: e,
201
201
  renderContext: t
202
- }) => je(
202
+ }) => Ve(
203
203
  e,
204
- /* @__PURE__ */ u(Ie, { children: [
205
- /* @__PURE__ */ a("div", { className: "make-ai-artifact__comparison", children: e.data.items.map((s) => /* @__PURE__ */ u("div", { className: "make-ai-artifact__comparison-item", children: [
204
+ /* @__PURE__ */ m(Ne, { children: [
205
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__comparison", children: e.data.items.map((s) => /* @__PURE__ */ m("div", { className: "make-ai-artifact__comparison-item", children: [
206
206
  /* @__PURE__ */ a("span", { children: s.label }),
207
- /* @__PURE__ */ a("strong", { children: Le(s.value, s.format, t.context.locale) }),
207
+ /* @__PURE__ */ a("strong", { children: xe(s.value, s.format, t.context.locale) }),
208
208
  s.hint ? /* @__PURE__ */ a("small", { children: s.hint }) : null
209
209
  ] }, s.id)) }),
210
- qe(e, t)
210
+ Be(e, t)
211
211
  ] }),
212
212
  "make-ai-artifact--comparison",
213
213
  t.themeStyle
214
- ), Ya = ({
214
+ ), Qa = ({
215
215
  artifact: e,
216
216
  renderContext: t
217
217
  }) => {
218
- const s = e.data.series.flatMap((l) => l.points.map((m) => m.y)), { max: n, min: i } = na(s), c = n - i || 1;
219
- return je(
218
+ const s = e.data.series.flatMap((d) => d.points.map((h) => h.y)), { max: n, min: i } = na(s), o = n - i || 1;
219
+ return Ve(
220
220
  e,
221
- /* @__PURE__ */ u(Ie, { children: [
222
- /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend", children: e.data.series.map((l) => /* @__PURE__ */ u("div", { className: "make-ai-artifact__trend-series", children: [
223
- /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-label", children: l.label }),
224
- /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-bars", children: l.points.map((m, y) => {
225
- const v = 18 + (m.y - i) / c * 70;
226
- return /* @__PURE__ */ u("div", { className: "make-ai-artifact__trend-point", children: [
221
+ /* @__PURE__ */ m(Ne, { children: [
222
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend", children: e.data.series.map((d) => /* @__PURE__ */ m("div", { className: "make-ai-artifact__trend-series", children: [
223
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-label", children: d.label }),
224
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-bars", children: d.points.map((h, v) => {
225
+ const I = 18 + (h.y - i) / o * 70;
226
+ return /* @__PURE__ */ m("div", { className: "make-ai-artifact__trend-point", children: [
227
227
  /* @__PURE__ */ a(
228
228
  "span",
229
229
  {
230
- "aria-label": `${m.x}: ${Le(
231
- m.y,
232
- l.format,
230
+ "aria-label": `${h.x}: ${xe(
231
+ h.y,
232
+ d.format,
233
233
  t.context.locale
234
234
  )}`,
235
235
  className: "make-ai-artifact__trend-bar",
236
236
  role: "img",
237
- style: { height: `${v}%` },
238
- title: `${m.x}: ${Le(
239
- m.y,
240
- l.format,
237
+ style: { height: `${I}%` },
238
+ title: `${h.x}: ${xe(
239
+ h.y,
240
+ d.format,
241
241
  t.context.locale
242
242
  )}`
243
243
  }
244
244
  ),
245
- /* @__PURE__ */ a("small", { children: m.x })
246
- ] }, `${m.x}-${y}`);
245
+ /* @__PURE__ */ a("small", { children: h.x })
246
+ ] }, `${h.x}-${v}`);
247
247
  }) })
248
- ] }, l.id)) }),
249
- qe(e, t)
248
+ ] }, d.id)) }),
249
+ Be(e, t)
250
250
  ] }),
251
251
  "make-ai-artifact--trend",
252
252
  t.themeStyle
253
253
  );
254
- }, Qa = ({
254
+ }, es = ({
255
255
  artifact: e,
256
256
  renderContext: t
257
257
  }) => {
258
258
  const { max: s } = na(
259
259
  e.data.items.map((i) => Math.abs(i.value))
260
260
  ), n = Math.max(s, 1);
261
- return je(
261
+ return Ve(
262
262
  e,
263
- /* @__PURE__ */ u(Ie, { children: [
264
- /* @__PURE__ */ a("ol", { className: "make-ai-artifact__ranking", children: e.data.items.map((i, c) => /* @__PURE__ */ u("li", { children: [
265
- /* @__PURE__ */ a("span", { className: "make-ai-artifact__rank", children: c + 1 }),
266
- /* @__PURE__ */ u("span", { className: "make-ai-artifact__ranking-label", children: [
263
+ /* @__PURE__ */ m(Ne, { children: [
264
+ /* @__PURE__ */ a("ol", { className: "make-ai-artifact__ranking", children: e.data.items.map((i, o) => /* @__PURE__ */ m("li", { children: [
265
+ /* @__PURE__ */ a("span", { className: "make-ai-artifact__rank", children: o + 1 }),
266
+ /* @__PURE__ */ m("span", { className: "make-ai-artifact__ranking-label", children: [
267
267
  /* @__PURE__ */ a("span", { children: i.label }),
268
268
  i.description ? /* @__PURE__ */ a("small", { children: i.description }) : null
269
269
  ] }),
270
270
  /* @__PURE__ */ a("span", { className: "make-ai-artifact__ranking-track", "aria-hidden": "true", children: /* @__PURE__ */ a("span", { style: { width: `${Math.abs(i.value) / n * 100}%` } }) }),
271
- /* @__PURE__ */ a("strong", { children: Le(i.value, i.format, t.context.locale) })
271
+ /* @__PURE__ */ a("strong", { children: xe(i.value, i.format, t.context.locale) })
272
272
  ] }, i.id)) }),
273
- qe(e, t)
273
+ Be(e, t)
274
274
  ] }),
275
275
  "make-ai-artifact--ranking",
276
276
  t.themeStyle
277
277
  );
278
- }, es = (e, t) => t.action ?? {
278
+ }, ts = (e, t) => t.action ?? {
279
279
  id: `open-${t.id}`,
280
280
  label: t.title ?? t.id,
281
281
  intent: "open-record",
282
282
  target: { entityKey: e.data.entity.key, recordId: t.id }
283
- }, ts = ({
283
+ }, as = ({
284
284
  artifact: e,
285
285
  renderContext: t
286
- }) => je(
286
+ }) => Ve(
287
287
  e,
288
- /* @__PURE__ */ u(Ie, { children: [
288
+ /* @__PURE__ */ m(Ne, { children: [
289
289
  /* @__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) => {
290
- const n = es(e, s), i = /* @__PURE__ */ u(Ie, { children: [
290
+ const n = ts(e, s), i = /* @__PURE__ */ m(Ne, { children: [
291
291
  /* @__PURE__ */ a("strong", { children: s.title ?? s.id }),
292
- /* @__PURE__ */ a("span", { className: "make-ai-artifact__record-values", children: e.data.columns.map((c) => /* @__PURE__ */ u("span", { children: [
293
- /* @__PURE__ */ a("small", { children: c.label }),
294
- Le(
295
- s.values[c.key],
296
- c.format,
292
+ /* @__PURE__ */ a("span", { className: "make-ai-artifact__record-values", children: e.data.columns.map((o) => /* @__PURE__ */ m("span", { children: [
293
+ /* @__PURE__ */ a("small", { children: o.label }),
294
+ xe(
295
+ s.values[o.key],
296
+ o.format,
297
297
  t.context.locale
298
298
  )
299
- ] }, c.key)) }),
299
+ ] }, o.key)) }),
300
300
  t.onAction ? /* @__PURE__ */ a("span", { "aria-hidden": "true", children: "›" }) : null
301
301
  ] });
302
302
  return t.onAction ? /* @__PURE__ */ a(
@@ -313,49 +313,49 @@ const Le = (e, t, s) => {
313
313
  s.id
314
314
  ) : /* @__PURE__ */ a("div", { className: "make-ai-artifact__record", children: i }, s.id);
315
315
  }) }),
316
- e.data.total !== void 0 ? /* @__PURE__ */ u("p", { className: "make-ai-artifact__record-total", children: [
316
+ e.data.total !== void 0 ? /* @__PURE__ */ m("p", { className: "make-ai-artifact__record-total", children: [
317
317
  "共 ",
318
318
  e.data.total,
319
319
  " 条"
320
320
  ] }) : null,
321
- qe(e, t)
321
+ Be(e, t)
322
322
  ] }),
323
323
  "make-ai-artifact--record-list",
324
324
  t.themeStyle
325
- ), as = ({
325
+ ), ss = ({
326
326
  artifact: e,
327
327
  renderContext: t
328
- }) => je(
328
+ }) => Ve(
329
329
  e,
330
- /* @__PURE__ */ u(Ie, { children: [
331
- /* @__PURE__ */ u("div", { className: `make-ai-artifact__notice make-ai-artifact__notice--${e.data.tone}`, children: [
330
+ /* @__PURE__ */ m(Ne, { children: [
331
+ /* @__PURE__ */ m("div", { className: `make-ai-artifact__notice make-ai-artifact__notice--${e.data.tone}`, children: [
332
332
  /* @__PURE__ */ a("span", { "aria-hidden": "true", children: e.data.tone === "success" ? "✓" : e.data.tone === "warning" ? "!" : e.data.tone === "danger" ? "×" : "i" }),
333
333
  /* @__PURE__ */ a("p", { children: e.data.body })
334
334
  ] }),
335
- qe(e, t)
335
+ Be(e, t)
336
336
  ] }),
337
337
  "make-ai-artifact--notice",
338
338
  t.themeStyle
339
- ), He = (e, t, s) => ({ id: e, kinds: [t], priority: 0, render: s }), ss = [
340
- He("platform.metric.default", "metric", (e, t, s) => /* @__PURE__ */ a(Za, { artifact: e, renderContext: s })),
341
- He("platform.comparison.default", "comparison", (e, t, s) => /* @__PURE__ */ a(Ja, { artifact: e, renderContext: s })),
342
- He("platform.trend.default", "trend", (e, t, s) => /* @__PURE__ */ a(Ya, { artifact: e, renderContext: s })),
343
- He("platform.ranking.default", "ranking", (e, t, s) => /* @__PURE__ */ a(Qa, { artifact: e, renderContext: s })),
344
- He("platform.record-list.default", "record-list", (e, t, s) => /* @__PURE__ */ a(ts, { artifact: e, renderContext: s })),
345
- He("platform.notice.default", "notice", (e, t, s) => /* @__PURE__ */ a(as, { artifact: e, renderContext: s }))
346
- ], ns = Qt(ss).templates, is = (e = ns) => Qt(e);
347
- const rs = (e) => e?.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
348
- function os(e, t, s = []) {
339
+ ), Oe = (e, t, s) => ({ id: e, kinds: [t], priority: 0, render: s }), ns = [
340
+ Oe("platform.metric.default", "metric", (e, t, s) => /* @__PURE__ */ a(Ja, { artifact: e, renderContext: s })),
341
+ Oe("platform.comparison.default", "comparison", (e, t, s) => /* @__PURE__ */ a(Ya, { artifact: e, renderContext: s })),
342
+ Oe("platform.trend.default", "trend", (e, t, s) => /* @__PURE__ */ a(Qa, { artifact: e, renderContext: s })),
343
+ Oe("platform.ranking.default", "ranking", (e, t, s) => /* @__PURE__ */ a(es, { artifact: e, renderContext: s })),
344
+ Oe("platform.record-list.default", "record-list", (e, t, s) => /* @__PURE__ */ a(as, { artifact: e, renderContext: s })),
345
+ Oe("platform.notice.default", "notice", (e, t, s) => /* @__PURE__ */ a(ss, { artifact: e, renderContext: s }))
346
+ ], is = Qt(ns).templates, rs = (e = is) => Qt(e);
347
+ const os = (e) => e?.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
348
+ function cs(e, t, s = []) {
349
349
  if (t == null)
350
350
  throw new Error("[lucide]: iconNode is required when icon name is used");
351
351
  return {
352
- name: rs(e),
352
+ name: os(e),
353
353
  size: 24,
354
354
  node: t,
355
355
  ...s.length > 0 ? { aliases: s } : {}
356
356
  };
357
357
  }
358
- const cs = (e) => {
358
+ const ls = (e) => {
359
359
  let t = "", s = !1;
360
360
  for (const n of e) {
361
361
  if (n === "-" || n === "_" || n <= " ") {
@@ -366,12 +366,12 @@ const cs = (e) => {
366
366
  }
367
367
  return t;
368
368
  };
369
- const ls = (e) => {
370
- const t = cs(e);
369
+ const ds = (e) => {
370
+ const t = ls(e);
371
371
  return t.charAt(0).toUpperCase() + t.slice(1);
372
372
  };
373
373
  const Ct = (...e) => e.filter((t, s, n) => !!t && t.trim() !== "" && n.indexOf(t) === s).join(" ").trim();
374
- const Re = {
374
+ const ze = {
375
375
  xmlns: "http://www.w3.org/2000/svg",
376
376
  width: 24,
377
377
  height: 24,
@@ -385,12 +385,12 @@ const Re = {
385
385
  function bt(e) {
386
386
  return e != null;
387
387
  }
388
- function ds(e, t = {}) {
389
- const s = t.attributeNames ?? {}, n = (C) => s[C] ?? C, i = e.size ?? e.width ?? Re.width, c = e.size ?? e.height ?? Re.height, l = e.aliases?.filter((C) => typeof C == "string" && C.trim() !== "").map((C) => `lucide-${C}`) ?? [], m = [...e.name ? [`lucide-${e.name}`] : [], ...l], y = t.className?.split(" ").filter(Boolean) ?? [], v = t.includeDefaultClasses === !1 ? Ct(...y) : Ct("lucide", ...m, ...y), p = t.absoluteStrokeWidth ? Number(t.strokeWidth ?? Re["stroke-width"]) * Number(e.size ?? e.width ?? Re.width) / Number(t.size ?? t.width ?? Re.width) : t.strokeWidth ?? Re["stroke-width"];
388
+ function us(e, t = {}) {
389
+ const s = t.attributeNames ?? {}, n = (C) => s[C] ?? C, i = e.size ?? e.width ?? ze.width, o = e.size ?? e.height ?? ze.height, d = e.aliases?.filter((C) => typeof C == "string" && C.trim() !== "").map((C) => `lucide-${C}`) ?? [], h = [...e.name ? [`lucide-${e.name}`] : [], ...d], v = t.className?.split(" ").filter(Boolean) ?? [], I = t.includeDefaultClasses === !1 ? Ct(...v) : Ct("lucide", ...h, ...v), f = t.absoluteStrokeWidth ? Number(t.strokeWidth ?? ze["stroke-width"]) * Number(e.size ?? e.width ?? ze.width) / Number(t.size ?? t.width ?? ze.width) : t.strokeWidth ?? ze["stroke-width"];
390
390
  return [
391
391
  "svg",
392
392
  {
393
- ...Object.entries(Re).reduce((C, [S, k]) => (C[n(S)] = k, C), {}),
393
+ ...Object.entries(ze).reduce((C, [A, g]) => (C[n(A)] = g, C), {}),
394
394
  ..."color" in t && t.color && {
395
395
  [n("stroke")]: t.color
396
396
  },
@@ -404,24 +404,24 @@ function ds(e, t = {}) {
404
404
  ..."height" in t && bt(t.height) && {
405
405
  [n("height")]: t.height
406
406
  },
407
- [n("stroke-width")]: p,
408
- ...v && {
409
- [n("class")]: v
407
+ [n("stroke-width")]: f,
408
+ ...I && {
409
+ [n("class")]: I
410
410
  },
411
- [n("viewBox")]: `0 0 ${i} ${c}`,
411
+ [n("viewBox")]: `0 0 ${i} ${o}`,
412
412
  ...t.hasA11yProp === !1 ? {
413
413
  [n("aria-hidden")]: "true"
414
414
  } : {},
415
415
  ..."attributes" in t && t.attributes
416
416
  },
417
417
  e.node.map((C) => {
418
- const [S, k, U] = C, L = t.nonScalingStroke ? { [n("vector-effect")]: "non-scaling-stroke", ...k } : k;
419
- return U ? [S, L, U] : [S, L];
418
+ const [A, g, F] = C, T = t.nonScalingStroke ? { [n("vector-effect")]: "non-scaling-stroke", ...g } : g;
419
+ return F ? [A, T, F] : [A, T];
420
420
  })
421
421
  ];
422
422
  }
423
- function us(e, t = {}) {
424
- return ds(e, {
423
+ function ms(e, t = {}) {
424
+ return us(e, {
425
425
  ...t,
426
426
  attributeNames: {
427
427
  ...t.attributeNames,
@@ -433,71 +433,71 @@ function us(e, t = {}) {
433
433
  }
434
434
  });
435
435
  }
436
- const ms = (e) => {
436
+ const hs = (e) => {
437
437
  for (const t in e)
438
438
  if (t.startsWith("aria-") || t === "role" || t === "title")
439
439
  return !0;
440
440
  return !1;
441
- }, hs = Ba({}), ps = () => ja(hs), fs = Yt(
441
+ }, fs = Va({}), ps = () => Ba(fs), vs = Yt(
442
442
  ({
443
443
  color: e,
444
444
  size: t,
445
445
  width: s,
446
446
  height: n,
447
447
  strokeWidth: i,
448
- absoluteStrokeWidth: c,
449
- nonScalingStroke: l,
450
- className: m = "",
451
- children: y,
452
- iconNode: v = [],
453
- icon: p = {
454
- node: v,
448
+ absoluteStrokeWidth: o,
449
+ nonScalingStroke: d,
450
+ className: h = "",
451
+ children: v,
452
+ iconNode: I = [],
453
+ icon: f = {
454
+ node: I,
455
455
  aliases: [],
456
456
  size: 24
457
457
  },
458
- ...A
458
+ ...N
459
459
  }, C) => {
460
460
  const {
461
- size: S = 24,
462
- strokeWidth: k = 2,
463
- absoluteStrokeWidth: U = !1,
464
- nonScalingStroke: L = !1,
461
+ size: A = 24,
462
+ strokeWidth: g = 2,
463
+ absoluteStrokeWidth: F = !1,
464
+ nonScalingStroke: T = !1,
465
465
  color: H = "currentColor",
466
- className: _ = ""
467
- } = ps() ?? {}, h = !!y || ms(A), [r, b, M = []] = us(p, {
466
+ className: b = ""
467
+ } = ps() ?? {}, l = !!v || hs(N), [c, k, E = []] = ms(f, {
468
468
  color: e ?? H,
469
- width: s ?? t ?? S,
470
- height: n ?? t ?? S,
471
- strokeWidth: i ?? k,
472
- absoluteStrokeWidth: c ?? U,
473
- nonScalingStroke: l ?? L,
474
- className: Ct(_, m),
475
- hasA11yProp: h,
476
- attributes: A
469
+ width: s ?? t ?? A,
470
+ height: n ?? t ?? A,
471
+ strokeWidth: i ?? g,
472
+ absoluteStrokeWidth: o ?? F,
473
+ nonScalingStroke: d ?? T,
474
+ className: Ct(b, h),
475
+ hasA11yProp: l,
476
+ attributes: N
477
477
  });
478
478
  return Nt(
479
- r,
479
+ c,
480
480
  {
481
481
  ref: C,
482
- ...b
482
+ ...k
483
483
  },
484
484
  [
485
- ...M.map(([W, N]) => Nt(W, N)),
486
- ...Array.isArray(y) ? y : [y]
485
+ ...E.map(([W, M]) => Nt(W, M)),
486
+ ...Array.isArray(v) ? v : [v]
487
487
  ]
488
488
  );
489
489
  }
490
490
  );
491
- function j(e, t = [], s = []) {
492
- const n = typeof e == "string" ? os(e, t, s) : e, i = Yt(
493
- ({ className: c, ...l }, m) => Nt(fs, {
494
- ref: m,
491
+ function B(e, t = [], s = []) {
492
+ const n = typeof e == "string" ? cs(e, t, s) : e, i = Yt(
493
+ ({ className: o, ...d }, h) => Nt(vs, {
494
+ ref: h,
495
495
  icon: n,
496
- className: c,
497
- ...l
496
+ className: o,
497
+ ...d
498
498
  })
499
499
  );
500
- return n.name && (i.displayName = ls(n.name)), i;
500
+ return n.name && (i.displayName = ds(n.name)), i;
501
501
  }
502
502
  const ra = {
503
503
  name: "arrow-down-to-line",
@@ -509,28 +509,28 @@ const ra = {
509
509
  ]
510
510
  };
511
511
  ra.node;
512
- const vs = j(ra);
512
+ const ys = B(ra);
513
513
  const oa = {
514
514
  name: "check",
515
515
  size: 24,
516
516
  node: [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]]
517
517
  };
518
518
  oa.node;
519
- const ys = j(oa);
519
+ const gs = B(oa);
520
520
  const ca = {
521
521
  name: "chevron-down",
522
522
  size: 24,
523
523
  node: [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]]
524
524
  };
525
525
  ca.node;
526
- const ks = j(ca);
526
+ const ks = B(ca);
527
527
  const la = {
528
528
  name: "chevron-up",
529
529
  size: 24,
530
530
  node: [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]]
531
531
  };
532
532
  la.node;
533
- const gs = j(la);
533
+ const bs = B(la);
534
534
  const da = {
535
535
  name: "circle-alert",
536
536
  size: 24,
@@ -542,8 +542,8 @@ const da = {
542
542
  aliases: ["alert-circle"]
543
543
  };
544
544
  da.node;
545
- const bs = j(da);
546
- const ua = {
545
+ const ua = B(da);
546
+ const ma = {
547
547
  name: "cloud-off",
548
548
  size: 24,
549
549
  node: [
@@ -555,9 +555,9 @@ const ua = {
555
555
  ["path", { d: "m2 2 20 20", key: "1ooewy" }]
556
556
  ]
557
557
  };
558
- ua.node;
559
- const _s = j(ua);
560
- const ma = {
558
+ ma.node;
559
+ const _s = B(ma);
560
+ const ha = {
561
561
  name: "copy",
562
562
  size: 24,
563
563
  node: [
@@ -565,9 +565,9 @@ const ma = {
565
565
  ["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2", key: "zix9uf" }]
566
566
  ]
567
567
  };
568
- ma.node;
569
- const ws = j(ma);
570
- const ha = {
568
+ ha.node;
569
+ const ws = B(ha);
570
+ const fa = {
571
571
  name: "file-text",
572
572
  size: 24,
573
573
  node: [
@@ -584,8 +584,8 @@ const ha = {
584
584
  ["path", { d: "M16 17H8", key: "z1uh3a" }]
585
585
  ]
586
586
  };
587
- ha.node;
588
- const Ot = j(ha);
587
+ fa.node;
588
+ const jt = B(fa);
589
589
  const pa = {
590
590
  name: "list",
591
591
  size: 24,
@@ -599,8 +599,8 @@ const pa = {
599
599
  ]
600
600
  };
601
601
  pa.node;
602
- const Is = j(pa);
603
- const fa = {
602
+ const Is = B(pa);
603
+ const va = {
604
604
  name: "maximize",
605
605
  size: 24,
606
606
  node: [
@@ -610,9 +610,9 @@ const fa = {
610
610
  ["path", { d: "M16 21h3a2 2 0 0 0 2-2v-3", key: "18trek" }]
611
611
  ]
612
612
  };
613
- fa.node;
614
- const Ns = j(fa);
615
- const va = {
613
+ va.node;
614
+ const Ns = B(va);
615
+ const ya = {
616
616
  name: "message-square-text",
617
617
  size: 24,
618
618
  node: [
@@ -628,9 +628,9 @@ const va = {
628
628
  ["path", { d: "M7 7h8", key: "af5zfr" }]
629
629
  ]
630
630
  };
631
- va.node;
632
- const As = j(va);
633
- const ya = {
631
+ ya.node;
632
+ const As = B(ya);
633
+ const ga = {
634
634
  name: "minimize",
635
635
  size: 24,
636
636
  node: [
@@ -640,8 +640,8 @@ const ya = {
640
640
  ["path", { d: "M16 21v-3a2 2 0 0 1 2-2h3", key: "ph8mxp" }]
641
641
  ]
642
642
  };
643
- ya.node;
644
- const Cs = j(ya);
643
+ ga.node;
644
+ const Cs = B(ga);
645
645
  const ka = {
646
646
  name: "pause",
647
647
  size: 24,
@@ -651,8 +651,8 @@ const ka = {
651
651
  ]
652
652
  };
653
653
  ka.node;
654
- const Ms = j(ka);
655
- const ga = {
654
+ const Ms = B(ka);
655
+ const ba = {
656
656
  name: "pencil",
657
657
  size: 24,
658
658
  node: [
@@ -666,9 +666,9 @@ const ga = {
666
666
  ["path", { d: "m15 5 4 4", key: "1mk7zo" }]
667
667
  ]
668
668
  };
669
- ga.node;
670
- const Ts = j(ga);
671
- const ba = {
669
+ ba.node;
670
+ const Ts = B(ba);
671
+ const _a = {
672
672
  name: "pin",
673
673
  size: 24,
674
674
  node: [
@@ -682,9 +682,9 @@ const ba = {
682
682
  ]
683
683
  ]
684
684
  };
685
- ba.node;
686
- const Es = j(ba);
687
- const _a = {
685
+ _a.node;
686
+ const Es = B(_a);
687
+ const wa = {
688
688
  name: "plus",
689
689
  size: 24,
690
690
  node: [
@@ -692,9 +692,9 @@ const _a = {
692
692
  ["path", { d: "M12 5v14", key: "s699le" }]
693
693
  ]
694
694
  };
695
- _a.node;
696
- const Tt = j(_a);
697
- const wa = {
695
+ wa.node;
696
+ const Tt = B(wa);
697
+ const Ia = {
698
698
  name: "refresh-cw",
699
699
  size: 24,
700
700
  node: [
@@ -704,9 +704,9 @@ const wa = {
704
704
  ["path", { d: "M8 16H3v5", key: "1cv678" }]
705
705
  ]
706
706
  };
707
- wa.node;
708
- const vt = j(wa);
709
- const Ia = {
707
+ Ia.node;
708
+ const mt = B(Ia);
709
+ const Na = {
710
710
  name: "rotate-ccw",
711
711
  size: 24,
712
712
  node: [
@@ -714,9 +714,9 @@ const Ia = {
714
714
  ["path", { d: "M3 3v5h5", key: "1xhq8a" }]
715
715
  ]
716
716
  };
717
- Ia.node;
718
- const $s = j(Ia);
719
- const Na = {
717
+ Na.node;
718
+ const $s = B(Na);
719
+ const Aa = {
720
720
  name: "send",
721
721
  size: 24,
722
722
  node: [
@@ -730,9 +730,9 @@ const Na = {
730
730
  ["path", { d: "m21.854 2.147-10.94 10.939", key: "12cjpa" }]
731
731
  ]
732
732
  };
733
- Na.node;
734
- const qt = j(Na);
735
- const Aa = {
733
+ Aa.node;
734
+ const Ot = B(Aa);
735
+ const Ca = {
736
736
  name: "sparkles",
737
737
  size: 24,
738
738
  node: [
@@ -749,9 +749,9 @@ const Aa = {
749
749
  ],
750
750
  aliases: ["stars"]
751
751
  };
752
- Aa.node;
753
- const Ca = j(Aa);
754
- const Ma = {
752
+ Ca.node;
753
+ const Ma = B(Ca);
754
+ const Ta = {
755
755
  name: "thumbs-down",
756
756
  size: 24,
757
757
  node: [
@@ -765,9 +765,9 @@ const Ma = {
765
765
  ["path", { d: "M17 14V2", key: "8ymqnk" }]
766
766
  ]
767
767
  };
768
- Ma.node;
769
- const Ss = j(Ma);
770
- const Ta = {
768
+ Ta.node;
769
+ const Ss = B(Ta);
770
+ const Ea = {
771
771
  name: "thumbs-up",
772
772
  size: 24,
773
773
  node: [
@@ -781,9 +781,9 @@ const Ta = {
781
781
  ["path", { d: "M7 10v12", key: "1qc93n" }]
782
782
  ]
783
783
  };
784
- Ta.node;
785
- const Rs = j(Ta);
786
- const Ea = {
784
+ Ea.node;
785
+ const Rs = B(Ea);
786
+ const $a = {
787
787
  name: "trash",
788
788
  size: 24,
789
789
  node: [
@@ -795,9 +795,9 @@ const Ea = {
795
795
  ],
796
796
  aliases: ["trash-2"]
797
797
  };
798
- Ea.node;
799
- const jt = j(Ea);
800
- const $a = {
798
+ $a.node;
799
+ const qt = B($a);
800
+ const Sa = {
801
801
  name: "triangle-alert",
802
802
  size: 24,
803
803
  node: [
@@ -813,9 +813,9 @@ const $a = {
813
813
  ],
814
814
  aliases: ["alert-triangle"]
815
815
  };
816
- $a.node;
817
- const Ls = j($a);
818
- const Sa = {
816
+ Sa.node;
817
+ const Ls = B(Sa);
818
+ const Ra = {
819
819
  name: "upload",
820
820
  size: 24,
821
821
  node: [
@@ -824,9 +824,9 @@ const Sa = {
824
824
  ["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }]
825
825
  ]
826
826
  };
827
- Sa.node;
828
- const zs = j(Sa);
829
- const Ra = {
827
+ Ra.node;
828
+ const zs = B(Ra);
829
+ const La = {
830
830
  name: "x",
831
831
  size: 24,
832
832
  node: [
@@ -834,237 +834,239 @@ const Ra = {
834
834
  ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
835
835
  ]
836
836
  };
837
- Ra.node;
838
- const tt = j(Ra), Oe = () => globalThis.crypto.randomUUID(), Bt = 1e3, _t = (e, t) => e?.chatId === t.chatId && e.revision > t.revision ? e : t, Et = (e) => {
837
+ La.node;
838
+ const tt = B(La), qe = () => globalThis.crypto.randomUUID(), Bt = 1e3, _t = (e, t) => e?.chatId === t.chatId && e.revision > t.revision ? e : t, Et = (e) => {
839
839
  const t = e, s = t?.status ?? t?.response?.status;
840
840
  return s === 410 || t?.code === "AI_UPLOAD_EXPIRED" ? "上传已过期,请移除后重新选择文件" : s === 409 ? "数据已变化或对话仍在运行,请刷新后重试" : s === 401 || t?.code === "AI_AUTH_REQUIRED" || t?.code === "AI_AUTH_EXPIRED" ? "登录已失效,请重新登录" : s === 403 ? "当前账号无权访问该对话" : s === 404 ? "对话或回答已不可见,请刷新列表" : t?.message?.startsWith("输入内容过长") ? t.message : "操作未完成,请重试或刷新对话";
841
841
  };
842
842
  function xs(e, t) {
843
- const s = t.features?.conversationManagement === !0, n = s ? t.scopeKey?.(e) ?? e.app.id : "", i = D(n);
844
- i.current = n;
845
- const c = D(n), [l, m] = $(fe), y = D(l), v = (o) => {
846
- const d = typeof o == "function" ? o(y.current) : o;
847
- y.current = d, m(d);
848
- }, [p, A] = $([]), [C, S] = $(), k = D(void 0), [U, L] = $(""), [H, _] = $(void 0), [h, r] = $(!1), [b, M] = $(!1), [W, N] = $(s), [X, Q] = $(!1), [ie, Z] = $(), [ue, ve] = $([]), [Me, Be] = $([]), O = D(/* @__PURE__ */ new Set()), V = D(/* @__PURE__ */ new Map()), F = D(0), Y = D(0), oe = D(0), ge = D(void 0), me = D(void 0), Te = D(/* @__PURE__ */ new Map()), P = (o, d = n) => Y.current === o && i.current === d, ae = () => {
849
- const o = new AbortController();
850
- return O.current.add(o), o;
851
- }, ee = (o) => O.current.delete(o), te = (o) => {
852
- const d = o ? _t(k.current, o) : void 0;
853
- k.current = d, S(d);
854
- }, Ve = (o) => {
855
- A(
856
- (d) => d.map(
857
- (g) => g.chatId === o.chatId ? _t(g, o) : g
843
+ const s = t.features?.conversationManagement === !0, n = s ? ["listConversations", "createConversation", "getConversation", "loadConversation"].filter((r) => typeof t[r] != "function") : [], i = n.length ? `会话管理配置不完整:缺少 ${n.join("、")}` : void 0, o = s && !i, d = o && t.features?.conversationEditing !== !1 && typeof t.updateConversation == "function", h = o && t.features?.conversationEditing !== !1 && typeof t.deleteConversation == "function", v = s ? t.scopeKey?.(e) ?? e.app.id : "", I = P(v);
844
+ I.current = v;
845
+ const f = P(v), [N, C] = R(ye), A = P(N), g = (r) => {
846
+ const u = typeof r == "function" ? r(A.current) : r;
847
+ A.current = u, C(u);
848
+ }, [F, T] = R([]), [H, b] = R(), l = P(void 0), [c, k] = R(""), [E, W] = R(void 0), [M, X] = R(!1), [me, ee] = R(!1), [he, ne] = R(o), [Ae, ce] = R(!1), [ht, U] = R(), [fe, le] = R([]), [Ee, ge] = R([]), De = P(/* @__PURE__ */ new Set()), G = P(/* @__PURE__ */ new Map()), K = P(0), te = P(0), $e = P(0), de = P(void 0), oe = P(void 0), Se = P(/* @__PURE__ */ new Map()), L = (r, u = v) => te.current === r && I.current === u, ae = () => {
849
+ const r = new AbortController();
850
+ return De.current.add(r), r;
851
+ }, Z = (r) => De.current.delete(r), Q = (r) => {
852
+ const u = r ? _t(l.current, r) : void 0;
853
+ l.current = u, b(u);
854
+ }, ke = (r) => {
855
+ T(
856
+ (u) => u.map(
857
+ (y) => y.chatId === r.chatId ? _t(y, r) : y
858
858
  )
859
859
  );
860
- }, Ke = (o) => {
861
- A((d) => d.filter((g) => g.chatId !== o));
862
- }, at = () => {
863
- oe.current += 1;
864
- }, ce = () => {
865
- for (const o of V.current.values()) o.abort();
866
- V.current.clear();
867
- }, G = (o) => {
868
- o instanceof Error && o.name === "AbortError" || (console.warn("[make-ai-assistant] conversation operation failed", {
869
- errorType: o instanceof Error ? o.name : typeof o
870
- }), Z(Et(o)));
871
- }, le = async (o) => {
872
- if (!s || !t.listConversations) return;
873
- const d = Y.current, g = ++oe.current, w = ae();
860
+ }, Ce = (r) => {
861
+ T((u) => u.filter((y) => y.chatId !== r));
862
+ }, Ke = () => {
863
+ $e.current += 1;
864
+ }, we = () => {
865
+ for (const r of G.current.values()) r.abort();
866
+ G.current.clear();
867
+ }, Y = (r) => {
868
+ r instanceof Error && r.name === "AbortError" || (console.warn("[make-ai-assistant] conversation operation failed", {
869
+ errorType: r instanceof Error ? r.name : typeof r
870
+ }), U(Et(r)));
871
+ }, Me = async (r) => {
872
+ if (!o || !t.listConversations) return;
873
+ const u = te.current, y = ++$e.current, w = ae();
874
874
  try {
875
- const T = await t.listConversations(
875
+ const $ = await t.listConversations(
876
876
  e,
877
- { cursor: o },
877
+ { cursor: r },
878
878
  { signal: w.signal }
879
879
  );
880
- if (!P(d) || w.signal.aborted || g !== oe.current)
880
+ if (!L(u) || w.signal.aborted || y !== $e.current)
881
881
  return;
882
- A((z) => {
883
- const I = new Map(z.map((E) => [E.chatId, E])), R = T.chats.map(
884
- (E) => _t(I.get(E.chatId), E)
882
+ T((z) => {
883
+ const _ = new Map(z.map((S) => [S.chatId, S])), x = $.chats.map(
884
+ (S) => _t(_.get(S.chatId), S)
885
885
  );
886
886
  return [
887
887
  ...new Map(
888
- [...o ? z : [], ...R].map((E) => [
889
- E.chatId,
890
- E
888
+ [...r ? z : [], ...x].map((S) => [
889
+ S.chatId,
890
+ S
891
891
  ])
892
892
  ).values()
893
893
  ];
894
- }), L(T.nextCursor);
895
- } catch (T) {
896
- P(d) && !w.signal.aborted && g === oe.current && G(T);
894
+ }), k($.nextCursor);
895
+ } catch ($) {
896
+ L(u) && !w.signal.aborted && y === $e.current && Y($);
897
897
  } finally {
898
- ee(w), P(d) && g === oe.current && N(!1);
898
+ Z(w), L(u) && y === $e.current && ne(!1);
899
899
  }
900
- }, Ne = async (o) => {
900
+ }, We = async (r) => {
901
901
  if (!t.getConversation) return;
902
- const d = Y.current, g = ae();
902
+ const u = te.current, y = ae();
903
903
  try {
904
904
  const w = await t.getConversation(
905
905
  e,
906
- { chatId: o },
907
- { signal: g.signal }
906
+ { chatId: r },
907
+ { signal: y.signal }
908
908
  );
909
- if (!P(d) || g.signal.aborted || w.chatId !== o) return;
910
- Ve(w), k.current?.chatId === o && te(w);
909
+ if (!L(u) || y.signal.aborted || w.chatId !== r) return;
910
+ ke(w), l.current?.chatId === r && Q(w);
911
911
  } catch (w) {
912
- P(d) && !g.signal.aborted && G(w);
912
+ L(u) && !y.signal.aborted && Y(w);
913
913
  } finally {
914
- ee(g);
914
+ Z(y);
915
915
  }
916
- }, Ee = async (o, d, g) => {
917
- const w = Y.current, T = F.current;
916
+ }, Re = async (r, u, y) => {
917
+ const w = te.current, $ = K.current;
918
918
  let z;
919
919
  try {
920
- for await (const I of o) {
921
- if (!P(w) || d.signal.aborted || T !== F.current || k.current?.chatId !== g)
920
+ for await (const _ of r) {
921
+ if (!L(w) || u.signal.aborted || $ !== K.current || l.current?.chatId !== y)
922
922
  return;
923
- const R = ea(I);
924
- if (R.type === "response.accepted" || R.type === "response.state") {
925
- z = R.responseId;
926
- const E = V.current.get(z);
927
- if (E && E !== d) {
928
- R.type === "response.accepted" && v((q) => we(q, R)), d.abort();
923
+ const x = ea(_);
924
+ if (x.type === "response.accepted" || x.type === "response.state") {
925
+ z = x.responseId;
926
+ const S = G.current.get(z);
927
+ if (S && S !== u) {
928
+ x.type === "response.accepted" && g((O) => Ie(O, x)), u.abort();
929
929
  return;
930
930
  }
931
- V.current.set(z, d);
931
+ G.current.set(z, u);
932
932
  }
933
- v((E) => we(E, R)), R.type === "response.accepted" && Ne(g), R.type === "response.terminal" && (ve((E) => E.filter((q) => q !== R.responseId)), le());
933
+ g((S) => Ie(S, x)), x.type === "response.accepted" && We(y), x.type === "response.terminal" && (le((S) => S.filter((O) => O !== x.responseId)), Me());
934
934
  }
935
- } catch (I) {
936
- P(w) && !d.signal.aborted && T === F.current && (G(I), z || v((R) => ({
937
- ...R,
938
- status: Object.values(R.responses ?? {}).some(
939
- (E) => !gt(E)
935
+ } catch (_) {
936
+ L(w) && !u.signal.aborted && $ === K.current && (Y(_), z || g((x) => ({
937
+ ...x,
938
+ status: Object.values(x.responses ?? {}).some(
939
+ (S) => !kt(S)
940
940
  ) ? "streaming" : "error"
941
941
  })));
942
942
  } finally {
943
- z && V.current.get(z) === d && V.current.delete(z), ee(d);
943
+ z && G.current.get(z) === u && G.current.delete(z), Z(u);
944
944
  }
945
- }, Ae = async (o, d, g, w) => {
945
+ }, pe = async (r, u, y, w) => {
946
946
  if (!t.getResponse || !t.watchResponse) return;
947
- const T = new Set(
948
- o.filter((I) => I.role === "assistant" && I.persistent).map((I) => I.responseId)
947
+ const $ = new Set(
948
+ r.filter((_) => _.role === "assistant" && _.persistent).map((_) => _.responseId)
949
949
  ), z = [
950
950
  ...new Map(
951
- o.filter(
952
- (I) => I.role === "user" && I.responseId && !T.has(I.responseId)
953
- ).map((I) => [I.responseId, I.cursor])
951
+ r.filter(
952
+ (_) => _.role === "user" && _.responseId && !$.has(_.responseId)
953
+ ).map((_) => [_.responseId, _.cursor])
954
954
  ).entries()
955
955
  ].slice(-20);
956
- for (const [I, R] of z) {
957
- if (!P(w) || g !== F.current) return;
958
- if (V.current.has(I)) continue;
959
- const E = ae();
956
+ for (const [_, x] of z) {
957
+ if (!L(w) || y !== K.current) return;
958
+ if (G.current.has(_)) continue;
959
+ const S = ae();
960
960
  try {
961
- const q = await t.getResponse(
961
+ const O = await t.getResponse(
962
962
  e,
963
- { chatId: d, responseId: I },
964
- { signal: E.signal }
963
+ { chatId: u, responseId: _ },
964
+ { signal: S.signal }
965
965
  );
966
- if (!P(w) || E.signal.aborted || g !== F.current || V.current.has(I)) continue;
967
- v(
968
- (be) => we(
969
- be,
970
- gt(q) ? { type: "response.snapshot", snapshot: q } : {
966
+ if (!L(w) || S.signal.aborted || y !== K.current || G.current.has(_)) continue;
967
+ g(
968
+ (p) => Ie(
969
+ p,
970
+ kt(O) ? { type: "response.snapshot", snapshot: O } : {
971
971
  type: "response.state",
972
- chatId: d,
973
- responseId: I,
974
- status: q.status
972
+ chatId: u,
973
+ responseId: _,
974
+ status: O.status
975
975
  }
976
976
  )
977
- ), q.status === "failed" || q.status === "cancelled" ? v(
978
- (be) => we(be, {
977
+ ), O.status === "failed" || O.status === "cancelled" ? g(
978
+ (p) => Ie(p, {
979
979
  type: "response.terminal",
980
- chatId: d,
981
- responseId: I,
982
- status: q.status
980
+ chatId: u,
981
+ responseId: _,
982
+ status: O.status
983
983
  })
984
- ) : (V.current.set(I, E), Ee(
984
+ ) : (G.current.set(_, S), Re(
985
985
  t.watchResponse(
986
986
  e,
987
- { chatId: d, responseId: I, historyCursor: R },
988
- { signal: E.signal }
987
+ { chatId: u, responseId: _, historyCursor: x },
988
+ { signal: S.signal }
989
989
  ),
990
- E,
991
- d
990
+ S,
991
+ u
992
992
  ));
993
- } catch (q) {
994
- P(w) && !E.signal.aborted && G(q);
993
+ } catch (O) {
994
+ L(w) && !S.signal.aborted && Y(O);
995
995
  } finally {
996
- V.current.get(I) !== E && ee(E);
996
+ G.current.get(_) !== S && Z(S);
997
997
  }
998
998
  }
999
- }, ze = async (o) => {
1000
- const d = ++F.current, g = Y.current, w = ae();
1001
- ce(), Z(void 0), N(!0), ve([]), me.current = void 0, te(o), v({ messages: [], status: "idle", threadId: o.chatId }), _(void 0), r(!1), M(!1);
999
+ }, Xe = async (r) => {
1000
+ if (!o) return;
1001
+ const u = ++K.current, y = te.current, w = ae();
1002
+ we(), U(void 0), ne(!0), le([]), oe.current = void 0, Q(r), g({ messages: [], status: "idle", threadId: r.chatId }), W(void 0), X(!1), ee(!1);
1002
1003
  try {
1003
- const [T, z] = await Promise.all([
1004
+ const [$, z] = await Promise.all([
1004
1005
  t.getConversation(
1005
1006
  e,
1006
- { chatId: o.chatId },
1007
+ { chatId: r.chatId },
1007
1008
  { signal: w.signal }
1008
1009
  ),
1009
1010
  t.loadConversation(e, {
1010
- threadId: o.chatId,
1011
+ threadId: r.chatId,
1011
1012
  cursor: void 0,
1012
1013
  signal: w.signal
1013
1014
  })
1014
1015
  ]);
1015
- if (!P(g) || w.signal.aborted || d !== F.current)
1016
+ if (!L(y) || w.signal.aborted || u !== K.current)
1016
1017
  return;
1017
- if (T.chatId !== o.chatId || z.threadId !== o.chatId)
1018
+ if ($.chatId !== r.chatId || z.threadId !== r.chatId)
1018
1019
  throw new Error("Conversation mismatch");
1019
- te(T), v(fe(z)), _(z.nextCursor ?? -1), r(z.hasMore ?? !1), Ae(z.messages, o.chatId, d, g);
1020
- } catch (T) {
1021
- P(g) && !w.signal.aborted && d === F.current && G(T);
1020
+ Q($), g(ye(z)), W(z.nextCursor ?? -1), X(z.hasMore ?? !1), pe(z.messages, r.chatId, u, y);
1021
+ } catch ($) {
1022
+ L(y) && !w.signal.aborted && u === K.current && Y($);
1022
1023
  } finally {
1023
- ee(w), P(g) && d === F.current && N(!1);
1024
+ Z(w), L(y) && u === K.current && ne(!1);
1024
1025
  }
1025
- }, xe = async () => {
1026
- if (k.current) return k.current;
1027
- if (ge.current ??= { requestId: Oe() }, ge.current.promise) return ge.current.promise;
1028
- const o = Y.current, d = F.current, g = ae(), w = ge.current;
1029
- return Q(!0), w.promise = t.createConversation(
1026
+ }, Pe = async () => {
1027
+ if (!o) throw new Error(i ?? "会话管理不可用");
1028
+ if (l.current) return l.current;
1029
+ if (de.current ??= { requestId: qe() }, de.current.promise) return de.current.promise;
1030
+ const r = te.current, u = K.current, y = ae(), w = de.current;
1031
+ return ce(!0), w.promise = t.createConversation(
1030
1032
  e,
1031
1033
  { requestId: w.requestId },
1032
- { signal: g.signal }
1033
- ).then((T) => {
1034
- if (!P(o) || g.signal.aborted || d !== F.current)
1034
+ { signal: y.signal }
1035
+ ).then(($) => {
1036
+ if (!L(r) || y.signal.aborted || u !== K.current)
1035
1037
  throw Object.assign(new Error("Stale create"), {
1036
1038
  name: "AbortError"
1037
1039
  });
1038
- return ge.current = void 0, te(T), v({ messages: [], status: "idle", threadId: T.chatId }), le(), T;
1040
+ return de.current = void 0, Q($), g({ messages: [], status: "idle", threadId: $.chatId }), Me(), $;
1039
1041
  }).finally(() => {
1040
- ee(g), w.promise = void 0, P(o) && Q(!1);
1042
+ Z(y), w.promise = void 0, L(r) && ce(!1);
1041
1043
  }), w.promise;
1042
- }, We = async () => {
1043
- if (!(X || ge.current?.promise)) {
1044
- F.current += 1, ce(), te(void 0), Z(void 0), me.current = void 0, v(fe()), r(!1), _(void 0);
1044
+ }, at = async () => {
1045
+ if (!(!o || Ae || de.current?.promise)) {
1046
+ K.current += 1, we(), Q(void 0), U(void 0), oe.current = void 0, g(ye()), X(!1), W(void 0);
1045
1047
  try {
1046
- await xe();
1047
- } catch (o) {
1048
- G(o);
1048
+ await Pe();
1049
+ } catch (r) {
1050
+ Y(r);
1049
1051
  }
1050
1052
  }
1051
- }, Xe = async (o) => {
1052
- const d = ae();
1053
- me.current = o, Z(void 0), y.current.messages.some((g) => g.id === o.message.id) || v((g) => ta(g, o.message)), await Ee(
1054
- t.run(o, { signal: d.signal }),
1055
- d,
1056
- o.threadId
1053
+ }, Ge = async (r) => {
1054
+ const u = ae();
1055
+ oe.current = r, U(void 0), A.current.messages.some((y) => y.id === r.message.id) || g((y) => ta(y, r.message)), await Re(
1056
+ t.run(r, { signal: u.signal }),
1057
+ u,
1058
+ r.threadId
1057
1059
  );
1058
- }, ye = async (o, d) => {
1059
- if (!(!o.trim() && !d?.length))
1060
+ }, st = async (r, u) => {
1061
+ if (!(!o || !r.trim() && !u?.length))
1060
1062
  try {
1061
- const g = await xe(), w = {
1062
- id: Oe(),
1063
- content: o,
1064
- ...d ? { parts: d } : {}
1063
+ const y = await Pe(), w = {
1064
+ id: qe(),
1065
+ content: r,
1066
+ ...u ? { parts: u } : {}
1065
1067
  };
1066
- await Xe({
1067
- threadId: g.chatId,
1068
+ await Ge({
1069
+ threadId: y.chatId,
1068
1070
  message: w,
1069
1071
  context: e,
1070
1072
  capabilities: {
@@ -1073,256 +1075,259 @@ function xs(e, t) {
1073
1075
  templates: []
1074
1076
  }
1075
1077
  });
1076
- } catch (g) {
1077
- G(g);
1078
+ } catch (y) {
1079
+ Y(y);
1078
1080
  }
1079
- }, st = async () => {
1080
- const o = me.current;
1081
- if (!o || o.threadId !== k.current?.chatId) {
1082
- k.current && await ze(k.current);
1081
+ }, Ue = async () => {
1082
+ const r = oe.current;
1083
+ if (!r || r.threadId !== l.current?.chatId) {
1084
+ l.current && await Xe(l.current);
1083
1085
  return;
1084
1086
  }
1085
- const d = y.current.messages.find(
1086
- (g) => g.id === o.message.id
1087
+ const u = A.current.messages.find(
1088
+ (y) => y.id === r.message.id
1087
1089
  );
1088
- if (d?.responseId && t.watchResponse) {
1089
- const g = d.responseId;
1090
- if (V.current.has(g)) return;
1090
+ if (u?.responseId && t.watchResponse) {
1091
+ const y = u.responseId;
1092
+ if (G.current.has(y)) return;
1091
1093
  const w = ae();
1092
- V.current.set(g, w), Z(void 0), await Ee(
1094
+ G.current.set(y, w), U(void 0), await Re(
1093
1095
  t.watchResponse(
1094
1096
  e,
1095
1097
  {
1096
- chatId: o.threadId,
1097
- responseId: g,
1098
- historyCursor: d.cursor
1098
+ chatId: r.threadId,
1099
+ responseId: y,
1100
+ historyCursor: u.cursor
1099
1101
  },
1100
1102
  { signal: w.signal }
1101
1103
  ),
1102
1104
  w,
1103
- o.threadId
1105
+ r.threadId
1104
1106
  );
1105
- } else await Xe(o);
1106
- }, nt = async (o = y.current.activeRunId) => {
1107
- const d = k.current;
1108
- if (!d || !o || !t.cancelResponse || ue.includes(o))
1107
+ } else await Ge(r);
1108
+ }, ft = async (r = A.current.activeRunId) => {
1109
+ const u = l.current;
1110
+ if (!u || !r || !t.cancelResponse || fe.includes(r))
1109
1111
  return;
1110
- const g = Y.current, w = F.current, T = ae();
1111
- ve((z) => [...z, o]), Z(void 0);
1112
+ const y = te.current, w = K.current, $ = ae();
1113
+ le((z) => [...z, r]), U(void 0);
1112
1114
  try {
1113
1115
  const z = await t.cancelResponse(
1114
1116
  e,
1115
- { chatId: d.chatId, responseId: o },
1116
- { signal: T.signal }
1117
+ { chatId: u.chatId, responseId: r },
1118
+ { signal: $.signal }
1117
1119
  );
1118
- if (!P(g) || w !== F.current) return;
1119
- if (gt(z))
1120
- v(
1121
- (I) => we(I, {
1120
+ if (!L(y) || w !== K.current) return;
1121
+ if (kt(z))
1122
+ g(
1123
+ (_) => Ie(_, {
1122
1124
  type: "response.snapshot",
1123
1125
  snapshot: z
1124
1126
  })
1125
- ), ve((I) => I.filter((R) => R !== o));
1126
- else if (!V.current.has(o) && t.watchResponse) {
1127
- const I = ae();
1128
- V.current.set(o, I), Ee(
1127
+ ), le((_) => _.filter((x) => x !== r));
1128
+ else if (!G.current.has(r) && t.watchResponse) {
1129
+ const _ = ae();
1130
+ G.current.set(r, _), Re(
1129
1131
  t.watchResponse(
1130
1132
  e,
1131
- { chatId: d.chatId, responseId: o },
1132
- { signal: I.signal }
1133
+ { chatId: u.chatId, responseId: r },
1134
+ { signal: _.signal }
1133
1135
  ),
1134
- I,
1135
- d.chatId
1136
+ _,
1137
+ u.chatId
1136
1138
  );
1137
1139
  }
1138
1140
  } catch (z) {
1139
- P(g) && w === F.current && (G(z), ve((I) => I.filter((R) => R !== o)));
1141
+ L(y) && w === K.current && (Y(z), le((_) => _.filter((x) => x !== r)));
1140
1142
  } finally {
1141
- ee(T);
1143
+ Z($);
1142
1144
  }
1143
- }, it = async (o, d = k.current) => {
1144
- if (!d || X) return !1;
1145
- const g = Y.current, w = ae();
1146
- Q(!0), Z(void 0);
1145
+ }, pt = async (r, u = l.current) => {
1146
+ if (!d || !u || Ae) return !1;
1147
+ const y = te.current, w = ae();
1148
+ ce(!0), U(void 0);
1147
1149
  try {
1148
- const T = await t.updateConversation(
1150
+ const $ = await t.updateConversation(
1149
1151
  e,
1150
- { chatId: d.chatId, expectedRevision: d.revision, ...o },
1152
+ { chatId: u.chatId, expectedRevision: u.revision, ...r },
1151
1153
  { signal: w.signal }
1152
1154
  );
1153
- return P(g) ? (at(), Ve(T), k.current?.chatId === T.chatId && te(T), !0) : !1;
1154
- } catch (T) {
1155
- if (P(g)) {
1156
- G(T);
1155
+ return L(y) ? (Ke(), ke($), l.current?.chatId === $.chatId && Q($), !0) : !1;
1156
+ } catch ($) {
1157
+ if (L(y)) {
1158
+ Y($);
1157
1159
  try {
1158
1160
  const z = await t.getConversation(
1159
1161
  e,
1160
- { chatId: d.chatId },
1162
+ { chatId: u.chatId },
1161
1163
  { signal: w.signal }
1162
1164
  );
1163
- P(g) && k.current?.chatId === d.chatId && te(z);
1165
+ L(y) && l.current?.chatId === u.chatId && Q(z);
1164
1166
  } catch {
1165
1167
  }
1166
- le();
1168
+ Me();
1167
1169
  }
1168
1170
  return !1;
1169
1171
  } finally {
1170
- ee(w), P(g) && Q(!1);
1172
+ Z(w), L(y) && ce(!1);
1171
1173
  }
1172
- }, rt = async (o = k.current) => {
1173
- if (!o || X) return !1;
1174
- const d = Y.current, g = ae();
1175
- Q(!0), Z(void 0);
1174
+ }, nt = async (r = l.current) => {
1175
+ if (!h || !r || Ae) return !1;
1176
+ const u = te.current, y = ae();
1177
+ ce(!0), U(void 0);
1176
1178
  try {
1177
1179
  return await t.deleteConversation(
1178
1180
  e,
1179
- { chatId: o.chatId, expectedRevision: o.revision },
1180
- { signal: g.signal }
1181
- ), P(d) ? (at(), Ke(o.chatId), k.current?.chatId === o.chatId && (F.current += 1, ce(), te(void 0), v(fe())), !0) : !1;
1181
+ { chatId: r.chatId, expectedRevision: r.revision },
1182
+ { signal: y.signal }
1183
+ ), L(u) ? (Ke(), Ce(r.chatId), l.current?.chatId === r.chatId && (K.current += 1, we(), Q(void 0), g(ye())), !0) : !1;
1182
1184
  } catch (w) {
1183
- return P(d) && G(w), !1;
1185
+ return L(u) && Y(w), !1;
1184
1186
  } finally {
1185
- ee(g), P(d) && Q(!1);
1187
+ Z(y), L(u) && ce(!1);
1186
1188
  }
1187
- }, ot = async (o, d, g = "", w = "") => {
1188
- const T = k.current;
1189
- if (!T || !o.persistent || !t.setFeedback || Me.includes(o.id))
1189
+ }, Fe = async (r, u, y = "", w = "") => {
1190
+ const $ = l.current;
1191
+ if (!$ || !r.persistent || !t.setFeedback || Ee.includes(r.id))
1190
1192
  return;
1191
1193
  const z = {
1192
- chatId: T.chatId,
1193
- messageId: o.id,
1194
- rating: d,
1195
- ...g ? { reason: g } : {},
1194
+ chatId: $.chatId,
1195
+ messageId: r.id,
1196
+ rating: u,
1197
+ ...y ? { reason: y } : {},
1196
1198
  ...w ? { comment: w } : {}
1197
- }, I = Te.current.get(o.id), { requestId: R, ...E } = I ?? {
1199
+ }, _ = Se.current.get(r.id), { requestId: x, ...S } = _ ?? {
1198
1200
  requestId: ""
1199
- }, q = I && JSON.stringify(E) === JSON.stringify(z) ? I : { ...z, requestId: Oe() };
1200
- Te.current.set(o.id, q);
1201
- const be = Y.current, Se = F.current, ct = ae();
1202
- Be((he) => [...he, o.id]), Z(void 0);
1201
+ }, O = _ && JSON.stringify(S) === JSON.stringify(z) ? _ : { ...z, requestId: qe() };
1202
+ Se.current.set(r.id, O);
1203
+ const p = te.current, j = K.current, q = ae();
1204
+ ge((V) => [...V, r.id]), U(void 0);
1203
1205
  try {
1204
- const he = await t.setFeedback(e, q, {
1205
- signal: ct.signal
1206
+ const V = await t.setFeedback(e, O, {
1207
+ signal: q.signal
1206
1208
  });
1207
- return !P(be) || Se !== F.current || Te.current.get(o.id) !== q ? void 0 : (v((Pe) => ({
1208
- ...Pe,
1209
- messages: Pe.messages.map(
1210
- (f) => f.id === o.id && he.revision >= (f.feedback?.revision ?? 0) ? { ...f, feedback: he } : f
1209
+ return !L(p) || j !== K.current || Se.current.get(r.id) !== O ? void 0 : (g((ie) => ({
1210
+ ...ie,
1211
+ messages: ie.messages.map(
1212
+ (be) => be.id === r.id && V.revision >= (be.feedback?.revision ?? 0) ? { ...be, feedback: V } : be
1211
1213
  )
1212
- })), Te.current.delete(o.id), !0);
1213
- } catch (he) {
1214
- return P(be) && Se === F.current && G(he), !1;
1214
+ })), Se.current.delete(r.id), !0);
1215
+ } catch (V) {
1216
+ return L(p) && j === K.current && Y(V), !1;
1215
1217
  } finally {
1216
- ee(ct), P(be) && Be((he) => he.filter((Pe) => Pe !== o.id));
1218
+ Z(q), L(p) && ge((V) => V.filter((ie) => ie !== r.id));
1217
1219
  }
1218
- }, De = async () => {
1219
- if (!k.current || !h || W) return;
1220
- const o = Y.current, d = F.current, g = k.current, w = ae();
1221
- N(!0);
1220
+ }, vt = async () => {
1221
+ if (!l.current || !M || he) return;
1222
+ const r = te.current, u = K.current, y = l.current, w = ae();
1223
+ ne(!0);
1222
1224
  try {
1223
- const T = await t.loadConversation(e, {
1224
- threadId: g.chatId,
1225
- cursor: H,
1225
+ const $ = await t.loadConversation(e, {
1226
+ threadId: y.chatId,
1227
+ cursor: E,
1226
1228
  signal: w.signal
1227
1229
  });
1228
- if (!P(o) || d !== F.current) return;
1229
- const z = fe(T), I = [
1230
+ if (!L(r) || u !== K.current) return;
1231
+ const z = ye($), _ = [
1230
1232
  ...new Map(
1231
- [...y.current.messages, ...z.messages].map((q) => [
1232
- q.id,
1233
- q
1233
+ [...A.current.messages, ...z.messages].map((O) => [
1234
+ O.id,
1235
+ O
1234
1236
  ])
1235
1237
  ).values()
1236
1238
  ];
1237
- let R = 0;
1238
- const E = [];
1239
- for (const q of I.slice(-200).reverse()) {
1240
- if (R += [...q.content].length, R > 1e6) break;
1241
- E.unshift(q);
1239
+ let x = 0;
1240
+ const S = [];
1241
+ for (const O of _.slice(-200).reverse()) {
1242
+ if (x += [...O.content].length, x > 1e6) break;
1243
+ S.unshift(O);
1242
1244
  }
1243
- E.length < I.length && M(!0), v((q) => ({ ...q, messages: E })), _(T.nextCursor ?? H), r(T.hasMore ?? !1), Ae(T.messages, g.chatId, d, o);
1244
- } catch (T) {
1245
- P(o) && G(T);
1245
+ S.length < _.length && ee(!0), g((O) => ({ ...O, messages: S })), W($.nextCursor ?? E), X($.hasMore ?? !1), pe($.messages, y.chatId, u, r);
1246
+ } catch ($) {
1247
+ L(r) && Y($);
1246
1248
  } finally {
1247
- ee(w), P(o) && N(!1);
1249
+ Z(w), L(r) && ne(!1);
1248
1250
  }
1249
- }, Ge = [
1251
+ }, Ze = [
1250
1252
  .../* @__PURE__ */ new Set([
1251
- ...p.filter((o) => o.titlePending).map((o) => o.chatId),
1252
- ...C?.titlePending ? [C.chatId] : []
1253
+ ...F.filter((r) => r.titlePending).map((r) => r.chatId),
1254
+ ...H?.titlePending ? [H.chatId] : []
1253
1255
  ])
1254
1256
  ].sort().join("\0");
1255
- ne(() => {
1256
- if (!s || !t.getConversation || !Ge) return;
1257
- const o = Y.current, d = ae(), g = Ge.split("\0"), w = /* @__PURE__ */ new Set();
1258
- let T;
1257
+ se(() => {
1258
+ if (!s || !t.getConversation || !Ze) return;
1259
+ const r = te.current, u = ae(), y = Ze.split("\0"), w = /* @__PURE__ */ new Set();
1260
+ let $;
1259
1261
  console.debug("[make-ai-assistant] watching pending conversation titles", {
1260
- count: g.length
1262
+ count: y.length
1261
1263
  });
1262
1264
  const z = async () => {
1263
1265
  await Promise.all(
1264
- g.map(async (I) => {
1265
- if (!w.has(I))
1266
+ y.map(async (_) => {
1267
+ if (!w.has(_))
1266
1268
  try {
1267
- const R = await t.getConversation(
1269
+ const x = await t.getConversation(
1268
1270
  e,
1269
- { chatId: I },
1270
- { signal: d.signal }
1271
+ { chatId: _ },
1272
+ { signal: u.signal }
1271
1273
  );
1272
- if (!P(o) || d.signal.aborted || R.chatId !== I)
1274
+ if (!L(r) || u.signal.aborted || x.chatId !== _)
1273
1275
  return;
1274
- Ve(R), k.current?.chatId === I && te(R);
1275
- } catch (R) {
1276
- if (!P(o) || d.signal.aborted) return;
1276
+ ke(x), l.current?.chatId === _ && Q(x);
1277
+ } catch (x) {
1278
+ if (!L(r) || u.signal.aborted) return;
1277
1279
  console.warn("[make-ai-assistant] title metadata refresh failed", {
1278
- errorType: R instanceof Error ? R.name : typeof R
1280
+ errorType: x instanceof Error ? x.name : typeof x
1279
1281
  });
1280
- const E = R?.status;
1281
- E === 401 ? (d.abort(), G(R)) : (E === 403 || E === 404) && (w.add(I), k.current?.chatId === I && G(R));
1282
+ const S = x?.status;
1283
+ S === 401 ? (u.abort(), Y(x)) : (S === 403 || S === 404) && (w.add(_), l.current?.chatId === _ && Y(x));
1282
1284
  }
1283
1285
  })
1284
- ), P(o) && !d.signal.aborted && g.some((I) => !w.has(I)) && (T = setTimeout(() => {
1286
+ ), L(r) && !u.signal.aborted && y.some((_) => !w.has(_)) && ($ = setTimeout(() => {
1285
1287
  z();
1286
1288
  }, Bt));
1287
1289
  };
1288
- return T = setTimeout(() => {
1290
+ return $ = setTimeout(() => {
1289
1291
  z();
1290
1292
  }, Bt), () => {
1291
- clearTimeout(T), d.abort(), ee(d);
1293
+ clearTimeout($), u.abort(), Z(u);
1292
1294
  };
1293
- }, [s, n, t, Ge]), ne(() => (Y.current += 1, c.current = n, ge.current = void 0, me.current = void 0, Te.current.clear(), te(void 0), A([]), L(""), v(fe()), Z(void 0), N(s), Q(!1), ve([]), Be([]), s && le(), () => {
1294
- Y.current += 1, F.current += 1;
1295
- for (const o of O.current) o.abort();
1296
- O.current.clear(), V.current.clear();
1297
- }), [s, n, t]);
1298
- const $e = c.current === n;
1295
+ }, [s, v, t, Ze]), se(() => (te.current += 1, f.current = v, de.current = void 0, oe.current = void 0, Se.current.clear(), Q(void 0), T([]), k(""), g(ye()), U(void 0), ne(o), ce(!1), le([]), ge([]), o && Me(), () => {
1296
+ te.current += 1, K.current += 1;
1297
+ for (const r of De.current) r.abort();
1298
+ De.current.clear(), G.current.clear();
1299
+ }), [o, v, t]);
1300
+ const Le = f.current === v;
1299
1301
  return {
1300
1302
  enabled: s,
1301
- canEdit: t.features?.conversationEditing !== !1,
1302
- state: $e ? l : fe(),
1303
- setState: v,
1304
- chats: $e ? p : [],
1305
- chat: $e ? C : void 0,
1306
- listCursor: U,
1307
- historyMore: h,
1308
- historyTruncated: b,
1309
- loading: !$e || W,
1310
- busy: X,
1311
- error: $e ? ie : void 0,
1312
- cancelling: ue,
1313
- feedbackBusy: Me,
1314
- refresh: le,
1315
- select: ze,
1316
- create: We,
1317
- ensureChat: xe,
1318
- send: ye,
1319
- retry: st,
1320
- stop: nt,
1321
- update: it,
1322
- remove: rt,
1323
- feedback: ot,
1324
- moreHistory: De,
1325
- setError: Z
1303
+ available: o,
1304
+ configurationError: i,
1305
+ canEdit: d,
1306
+ canDelete: h,
1307
+ state: Le ? N : ye(),
1308
+ setState: g,
1309
+ chats: Le ? F : [],
1310
+ chat: Le ? H : void 0,
1311
+ listCursor: c,
1312
+ historyMore: M,
1313
+ historyTruncated: me,
1314
+ loading: !Le || he,
1315
+ busy: Ae,
1316
+ error: Le ? ht : void 0,
1317
+ cancelling: fe,
1318
+ feedbackBusy: Ee,
1319
+ refresh: Me,
1320
+ select: Xe,
1321
+ create: at,
1322
+ ensureChat: Pe,
1323
+ send: st,
1324
+ retry: Ue,
1325
+ stop: ft,
1326
+ update: pt,
1327
+ remove: nt,
1328
+ feedback: Fe,
1329
+ moreHistory: vt,
1330
+ setError: U
1326
1331
  };
1327
1332
  }
1328
1333
  const Ds = ({
@@ -1330,25 +1335,25 @@ const Ds = ({
1330
1335
  label: t,
1331
1336
  onDismiss: s
1332
1337
  }) => {
1333
- const [n, i] = $();
1338
+ const [n, i] = R();
1334
1339
  if (At(() => {
1335
- const l = () => {
1340
+ const d = () => {
1336
1341
  if (!e.isConnected) {
1337
1342
  s();
1338
1343
  return;
1339
1344
  }
1340
- const m = e.getBoundingClientRect(), y = m.top >= 48 ? "above" : "below";
1345
+ const h = e.getBoundingClientRect(), v = h.top >= 48 ? "above" : "below";
1341
1346
  i({
1342
- left: m.left + m.width / 2,
1343
- placement: y,
1344
- top: y === "above" ? m.top - 8 : m.bottom + 8
1347
+ left: h.left + h.width / 2,
1348
+ placement: v,
1349
+ top: v === "above" ? h.top - 8 : h.bottom + 8
1345
1350
  });
1346
1351
  };
1347
- return l(), window.addEventListener("resize", l), document.addEventListener("scroll", l, !0), () => {
1348
- window.removeEventListener("resize", l), document.removeEventListener("scroll", l, !0);
1352
+ return d(), window.addEventListener("resize", d), document.addEventListener("scroll", d, !0), () => {
1353
+ window.removeEventListener("resize", d), document.removeEventListener("scroll", d, !0);
1349
1354
  };
1350
1355
  }, [e, s]), !n || typeof document > "u") return null;
1351
- const c = e.closest(".make-ai-assistant") ?? document.body;
1356
+ const o = e.closest(".make-ai-assistant") ?? document.body;
1352
1357
  return aa(
1353
1358
  /* @__PURE__ */ a(
1354
1359
  "span",
@@ -1360,7 +1365,7 @@ const Ds = ({
1360
1365
  children: t
1361
1366
  }
1362
1367
  ),
1363
- c
1368
+ o
1364
1369
  );
1365
1370
  };
1366
1371
  function Ps({
@@ -1370,44 +1375,44 @@ function Ps({
1370
1375
  onNewConversation: n,
1371
1376
  triggerRef: i
1372
1377
  }) {
1373
- const [c, l] = $(), [m, y] = $(""), [v, p] = $(), [A, C] = $(), S = D(null), k = (r, b) => {
1378
+ const [o, d] = R(), [h, v] = R(""), [I, f] = R(), [N, C] = R(), A = P(null), g = (c, k) => {
1374
1379
  C(
1375
- (M) => M?.anchor === b && M.label === r ? M : { anchor: b, label: r }
1380
+ (E) => E?.anchor === k && E.label === c ? E : { anchor: k, label: c }
1376
1381
  );
1377
- }, U = (r) => {
1378
- C((b) => b?.anchor === r ? void 0 : b);
1379
- }, L = (r) => ({
1380
- "data-tooltip": r,
1381
- onBlur: (b) => U(b.currentTarget),
1382
- onFocus: (b) => k(r, b.currentTarget),
1383
- onPointerEnter: (b) => k(r, b.currentTarget),
1384
- onPointerLeave: (b) => U(b.currentTarget)
1382
+ }, F = (c) => {
1383
+ C((k) => k?.anchor === c ? void 0 : k);
1384
+ }, T = (c) => ({
1385
+ "data-tooltip": c,
1386
+ onBlur: (k) => F(k.currentTarget),
1387
+ onFocus: (k) => g(c, k.currentTarget),
1388
+ onPointerEnter: (k) => g(c, k.currentTarget),
1389
+ onPointerLeave: (k) => F(k.currentTarget)
1385
1390
  }), H = () => {
1386
- l(void 0), y("");
1387
- }, _ = async (r) => {
1388
- const b = m.trim();
1389
- b && await t.update({ title: b }, r) && H();
1390
- }, h = async (r) => {
1391
- await t.remove(r) && p(void 0);
1391
+ d(void 0), v("");
1392
+ }, b = async (c) => {
1393
+ const k = h.trim();
1394
+ k && await t.update({ title: k }, c) && H();
1395
+ }, l = async (c) => {
1396
+ await t.remove(c) && f(void 0);
1392
1397
  };
1393
- return ne(() => {
1394
- const r = (b) => {
1395
- const M = b.target;
1396
- M instanceof Node && (S.current?.contains(M) || i.current?.contains(M) || s());
1398
+ return se(() => {
1399
+ const c = (k) => {
1400
+ const E = k.target;
1401
+ E instanceof Node && (A.current?.contains(E) || i.current?.contains(E) || s());
1397
1402
  };
1398
- return document.addEventListener("pointerdown", r), () => {
1399
- document.removeEventListener("pointerdown", r);
1403
+ return document.addEventListener("pointerdown", c), () => {
1404
+ document.removeEventListener("pointerdown", c);
1400
1405
  };
1401
- }, [s, i]), /* @__PURE__ */ u(
1406
+ }, [s, i]), /* @__PURE__ */ m(
1402
1407
  "div",
1403
1408
  {
1404
1409
  "aria-label": "任务列表",
1405
1410
  className: "make-ai-assistant__conversation-controls",
1406
1411
  id: e,
1407
- ref: S,
1412
+ ref: A,
1408
1413
  role: "dialog",
1409
1414
  children: [
1410
- /* @__PURE__ */ u("div", { className: "make-ai-assistant__conversation-heading", children: [
1415
+ /* @__PURE__ */ m("div", { className: "make-ai-assistant__conversation-heading", children: [
1411
1416
  /* @__PURE__ */ a("span", { children: "最近对话" }),
1412
1417
  /* @__PURE__ */ a(
1413
1418
  "button",
@@ -1416,12 +1421,12 @@ function Ps({
1416
1421
  className: "make-ai-assistant__conversation-refresh",
1417
1422
  disabled: t.busy,
1418
1423
  type: "button",
1419
- ...L("刷新"),
1424
+ ...T("刷新"),
1420
1425
  onClick: () => {
1421
1426
  t.refresh();
1422
1427
  },
1423
1428
  children: /* @__PURE__ */ a(
1424
- vt,
1429
+ mt,
1425
1430
  {
1426
1431
  "aria-hidden": "true",
1427
1432
  className: "make-ai-assistant__conversation-refresh-icon"
@@ -1430,22 +1435,22 @@ function Ps({
1430
1435
  }
1431
1436
  )
1432
1437
  ] }),
1433
- /* @__PURE__ */ u(
1438
+ /* @__PURE__ */ m(
1434
1439
  "nav",
1435
1440
  {
1436
1441
  "aria-label": "对话列表",
1437
1442
  className: "make-ai-assistant__conversation-list",
1438
1443
  children: [
1439
- t.chats.map((r) => {
1440
- const b = c === r.chatId, M = v === r.chatId, W = r.title || "未命名对话";
1441
- return /* @__PURE__ */ u(
1444
+ t.chats.map((c) => {
1445
+ const k = o === c.chatId, E = I === c.chatId, W = c.title || "未命名对话";
1446
+ return /* @__PURE__ */ m(
1442
1447
  "div",
1443
1448
  {
1444
1449
  className: "make-ai-assistant__conversation-row",
1445
- "data-active": t.chat?.chatId === r.chatId || void 0,
1446
- "data-editing": b || M || void 0,
1450
+ "data-active": t.chat?.chatId === c.chatId || void 0,
1451
+ "data-editing": k || E || void 0,
1447
1452
  children: [
1448
- M ? /* @__PURE__ */ u(
1453
+ E ? /* @__PURE__ */ m(
1449
1454
  "div",
1450
1455
  {
1451
1456
  "aria-label": "确认删除对话",
@@ -1459,7 +1464,7 @@ function Ps({
1459
1464
  className: "make-ai-assistant__conversation-delete-confirmation-icon"
1460
1465
  }
1461
1466
  ),
1462
- /* @__PURE__ */ u("span", { className: "make-ai-assistant__conversation-delete-confirmation-message", children: [
1467
+ /* @__PURE__ */ m("span", { className: "make-ai-assistant__conversation-delete-confirmation-message", children: [
1463
1468
  "确认删除“",
1464
1469
  W,
1465
1470
  "”?"
@@ -1469,14 +1474,14 @@ function Ps({
1469
1474
  {
1470
1475
  "aria-label": `确认删除:${W}`,
1471
1476
  className: "make-ai-assistant__conversation-row-action make-ai-assistant__conversation-row-action--danger make-ai-assistant__conversation-delete-confirmation-confirm",
1472
- disabled: t.busy || !t.canEdit,
1477
+ disabled: t.busy || !t.canDelete,
1473
1478
  type: "button",
1474
- ...L("确认删除"),
1479
+ ...T("确认删除"),
1475
1480
  onClick: () => {
1476
- h(r);
1481
+ l(c);
1477
1482
  },
1478
1483
  children: /* @__PURE__ */ a(
1479
- jt,
1484
+ qt,
1480
1485
  {
1481
1486
  "aria-hidden": "true",
1482
1487
  className: "make-ai-assistant__conversation-row-action-icon"
@@ -1491,8 +1496,8 @@ function Ps({
1491
1496
  className: "make-ai-assistant__conversation-row-action make-ai-assistant__conversation-delete-confirmation-cancel",
1492
1497
  disabled: t.busy,
1493
1498
  type: "button",
1494
- ...L("取消"),
1495
- onClick: () => p(void 0),
1499
+ ...T("取消"),
1500
+ onClick: () => f(void 0),
1496
1501
  children: /* @__PURE__ */ a(
1497
1502
  tt,
1498
1503
  {
@@ -1504,7 +1509,7 @@ function Ps({
1504
1509
  )
1505
1510
  ]
1506
1511
  }
1507
- ) : b ? /* @__PURE__ */ a(
1512
+ ) : k ? /* @__PURE__ */ a(
1508
1513
  "input",
1509
1514
  {
1510
1515
  "aria-label": "对话标题",
@@ -1512,20 +1517,20 @@ function Ps({
1512
1517
  className: "make-ai-assistant__conversation-row-title-input",
1513
1518
  disabled: t.busy,
1514
1519
  maxLength: 255,
1515
- value: m,
1516
- onChange: (N) => y(N.currentTarget.value),
1517
- onKeyDown: (N) => {
1518
- N.nativeEvent.isComposing || (N.key === "Escape" && (N.preventDefault(), H()), N.key === "Enter" && (N.preventDefault(), _(r)));
1520
+ value: h,
1521
+ onChange: (M) => v(M.currentTarget.value),
1522
+ onKeyDown: (M) => {
1523
+ M.nativeEvent.isComposing || (M.key === "Escape" && (M.preventDefault(), H()), M.key === "Enter" && (M.preventDefault(), b(c)));
1519
1524
  }
1520
1525
  }
1521
- ) : /* @__PURE__ */ u(
1526
+ ) : /* @__PURE__ */ m(
1522
1527
  "button",
1523
1528
  {
1524
- "aria-pressed": t.chat?.chatId === r.chatId,
1529
+ "aria-pressed": t.chat?.chatId === c.chatId,
1525
1530
  className: "make-ai-assistant__conversation-row-select",
1526
1531
  type: "button",
1527
1532
  onClick: () => {
1528
- s(), t.select(r);
1533
+ s(), t.select(c);
1529
1534
  },
1530
1535
  children: [
1531
1536
  /* @__PURE__ */ a(As, { "aria-hidden": "true" }),
@@ -1533,7 +1538,7 @@ function Ps({
1533
1538
  ]
1534
1539
  }
1535
1540
  ),
1536
- b ? /* @__PURE__ */ u(
1541
+ k ? /* @__PURE__ */ m(
1537
1542
  "div",
1538
1543
  {
1539
1544
  "aria-label": "修改标题操作",
@@ -1545,14 +1550,14 @@ function Ps({
1545
1550
  {
1546
1551
  "aria-label": "确认修改标题",
1547
1552
  className: "make-ai-assistant__conversation-row-action",
1548
- disabled: t.busy || !m.trim(),
1553
+ disabled: t.busy || !h.trim(),
1549
1554
  type: "button",
1550
- ...L("保存标题"),
1555
+ ...T("保存标题"),
1551
1556
  onClick: () => {
1552
- _(r);
1557
+ b(c);
1553
1558
  },
1554
1559
  children: /* @__PURE__ */ a(
1555
- ys,
1560
+ gs,
1556
1561
  {
1557
1562
  "aria-hidden": "true",
1558
1563
  className: "make-ai-assistant__conversation-row-action-icon"
@@ -1567,7 +1572,7 @@ function Ps({
1567
1572
  className: "make-ai-assistant__conversation-row-action",
1568
1573
  disabled: t.busy,
1569
1574
  type: "button",
1570
- ...L("取消"),
1575
+ ...T("取消"),
1571
1576
  onClick: H,
1572
1577
  children: /* @__PURE__ */ a(
1573
1578
  tt,
@@ -1580,18 +1585,18 @@ function Ps({
1580
1585
  )
1581
1586
  ]
1582
1587
  }
1583
- ) : M ? null : /* @__PURE__ */ u("div", { className: "make-ai-assistant__conversation-row-actions", children: [
1588
+ ) : E ? null : /* @__PURE__ */ m("div", { className: "make-ai-assistant__conversation-row-actions", children: [
1584
1589
  /* @__PURE__ */ a(
1585
1590
  "button",
1586
1591
  {
1587
- "aria-label": `${r.pinned ? "取消置顶" : "置顶"} ${W}`,
1588
- "aria-pressed": r.pinned,
1592
+ "aria-label": `${c.pinned ? "取消置顶" : "置顶"} ${W}`,
1593
+ "aria-pressed": c.pinned,
1589
1594
  className: "make-ai-assistant__conversation-row-action make-ai-assistant__conversation-row-pin",
1590
1595
  disabled: t.busy || !t.canEdit,
1591
1596
  type: "button",
1592
- ...L(r.pinned ? "取消置顶" : "置顶"),
1597
+ ...T(c.pinned ? "取消置顶" : "置顶"),
1593
1598
  onClick: () => {
1594
- t.update({ pinned: !r.pinned }, r);
1599
+ t.update({ pinned: !c.pinned }, c);
1595
1600
  },
1596
1601
  children: /* @__PURE__ */ a(
1597
1602
  Es,
@@ -1609,9 +1614,9 @@ function Ps({
1609
1614
  className: "make-ai-assistant__conversation-row-action",
1610
1615
  disabled: t.busy || !t.canEdit,
1611
1616
  type: "button",
1612
- ...L("修改标题"),
1617
+ ...T("修改标题"),
1613
1618
  onClick: () => {
1614
- p(void 0), l(r.chatId), y(r.title);
1619
+ f(void 0), d(c.chatId), v(c.title);
1615
1620
  },
1616
1621
  children: /* @__PURE__ */ a(
1617
1622
  Ts,
@@ -1627,14 +1632,14 @@ function Ps({
1627
1632
  {
1628
1633
  "aria-label": `删除:${W}`,
1629
1634
  className: "make-ai-assistant__conversation-row-action make-ai-assistant__conversation-row-action--danger",
1630
- disabled: t.busy,
1635
+ disabled: t.busy || !t.canDelete,
1631
1636
  type: "button",
1632
- ...L("删除"),
1637
+ ...T("删除"),
1633
1638
  onClick: () => {
1634
- H(), p(r.chatId);
1639
+ H(), f(c.chatId);
1635
1640
  },
1636
1641
  children: /* @__PURE__ */ a(
1637
- jt,
1642
+ qt,
1638
1643
  {
1639
1644
  "aria-hidden": "true",
1640
1645
  className: "make-ai-assistant__conversation-row-action-icon"
@@ -1645,7 +1650,7 @@ function Ps({
1645
1650
  ] })
1646
1651
  ]
1647
1652
  },
1648
- r.chatId
1653
+ c.chatId
1649
1654
  );
1650
1655
  }),
1651
1656
  !t.loading && !t.chats.length ? /* @__PURE__ */ a("p", { children: "暂无对话,发送消息即可新建" }) : null,
@@ -1663,7 +1668,7 @@ function Ps({
1663
1668
  ]
1664
1669
  }
1665
1670
  ),
1666
- t.chat && (t.historyMore || t.historyTruncated || t.state.historyTruncated) ? /* @__PURE__ */ u("div", { className: "make-ai-assistant__conversation-history-actions", children: [
1671
+ t.chat && (t.historyMore || t.historyTruncated || t.state.historyTruncated) ? /* @__PURE__ */ m("div", { className: "make-ai-assistant__conversation-history-actions", children: [
1667
1672
  t.historyMore ? /* @__PURE__ */ a(
1668
1673
  "button",
1669
1674
  {
@@ -1677,13 +1682,13 @@ function Ps({
1677
1682
  ) : null,
1678
1683
  t.historyTruncated || t.state.historyTruncated ? /* @__PURE__ */ a("p", { children: "当前展示有界消息窗口,可重新选择对话从头读取。" }) : null
1679
1684
  ] }) : null,
1680
- t.error ? /* @__PURE__ */ u("div", { className: "make-ai-assistant__conversation-error", role: "alert", children: [
1685
+ t.error ? /* @__PURE__ */ m("div", { className: "make-ai-assistant__conversation-error", role: "alert", children: [
1681
1686
  /* @__PURE__ */ a("span", { children: t.error }),
1682
1687
  /* @__PURE__ */ a("button", { type: "button", onClick: () => {
1683
1688
  t.retry();
1684
1689
  }, children: "恢复对话" })
1685
1690
  ] }) : null,
1686
- n ? /* @__PURE__ */ u(
1691
+ n ? /* @__PURE__ */ m(
1687
1692
  "button",
1688
1693
  {
1689
1694
  className: "make-ai-assistant__conversation-new",
@@ -1701,11 +1706,11 @@ function Ps({
1701
1706
  ]
1702
1707
  }
1703
1708
  ) : null,
1704
- A ? /* @__PURE__ */ a(
1709
+ N ? /* @__PURE__ */ a(
1705
1710
  Ds,
1706
1711
  {
1707
- anchor: A.anchor,
1708
- label: A.label,
1712
+ anchor: N.anchor,
1713
+ label: N.label,
1709
1714
  onDismiss: () => C(void 0)
1710
1715
  }
1711
1716
  ) : null
@@ -1717,11 +1722,11 @@ function Us({
1717
1722
  message: e,
1718
1723
  manager: t
1719
1724
  }) {
1720
- const [s, n] = $(!1), [i, c] = $(""), [l, m] = $(""), y = t.feedbackBusy.includes(e.id);
1725
+ const [s, n] = R(!1), [i, o] = R(""), [d, h] = R(""), v = t.feedbackBusy.includes(e.id);
1721
1726
  if (!e.persistent || e.role !== "assistant" || e.intermediate)
1722
1727
  return null;
1723
- const v = e.feedback?.rating ?? "none";
1724
- return /* @__PURE__ */ u(
1728
+ const I = e.feedback?.rating ?? "none";
1729
+ return /* @__PURE__ */ m(
1725
1730
  "div",
1726
1731
  {
1727
1732
  "aria-label": "回答反馈",
@@ -1733,12 +1738,12 @@ function Us({
1733
1738
  {
1734
1739
  type: "button",
1735
1740
  "aria-label": "喜欢",
1736
- "aria-pressed": v === "like",
1741
+ "aria-pressed": I === "like",
1737
1742
  className: "make-ai-assistant__reply-action make-ai-assistant__reply-feedback-action",
1738
1743
  "data-tooltip": "喜欢",
1739
- disabled: y,
1744
+ disabled: v,
1740
1745
  onClick: () => {
1741
- t.feedback(e, v === "like" ? "none" : "like");
1746
+ t.feedback(e, I === "like" ? "none" : "like");
1742
1747
  },
1743
1748
  children: /* @__PURE__ */ a(
1744
1749
  Rs,
@@ -1754,16 +1759,16 @@ function Us({
1754
1759
  {
1755
1760
  type: "button",
1756
1761
  "aria-label": "不喜欢",
1757
- "aria-pressed": v === "dislike",
1762
+ "aria-pressed": I === "dislike",
1758
1763
  className: "make-ai-assistant__reply-action make-ai-assistant__reply-feedback-action",
1759
1764
  "data-tooltip": "不喜欢",
1760
- disabled: y,
1765
+ disabled: v,
1761
1766
  onClick: () => {
1762
- if (v === "dislike") {
1767
+ if (I === "dislike") {
1763
1768
  t.feedback(e, "none");
1764
1769
  return;
1765
1770
  }
1766
- c(e.feedback?.reason ?? ""), m(e.feedback?.comment ?? ""), n(!0);
1771
+ o(e.feedback?.reason ?? ""), h(e.feedback?.comment ?? ""), n(!0);
1767
1772
  },
1768
1773
  children: /* @__PURE__ */ a(
1769
1774
  Ss,
@@ -1774,24 +1779,24 @@ function Us({
1774
1779
  )
1775
1780
  }
1776
1781
  ),
1777
- v === "dislike" ? /* @__PURE__ */ a(
1782
+ I === "dislike" ? /* @__PURE__ */ a(
1778
1783
  "button",
1779
1784
  {
1780
1785
  className: "make-ai-assistant__feedback-text-action",
1781
1786
  type: "button",
1782
- disabled: y,
1787
+ disabled: v,
1783
1788
  onClick: () => {
1784
- c(e.feedback?.reason ?? ""), m(e.feedback?.comment ?? ""), n(!0);
1789
+ o(e.feedback?.reason ?? ""), h(e.feedback?.comment ?? ""), n(!0);
1785
1790
  },
1786
1791
  children: "修改反馈"
1787
1792
  }
1788
1793
  ) : null,
1789
- s ? /* @__PURE__ */ u(
1794
+ s ? /* @__PURE__ */ m(
1790
1795
  "form",
1791
1796
  {
1792
- onSubmit: (p) => {
1793
- p.preventDefault(), t.feedback(e, "dislike", i, l).then((A) => {
1794
- A && n(!1);
1797
+ onSubmit: (f) => {
1798
+ f.preventDefault(), t.feedback(e, "dislike", i, d).then((N) => {
1799
+ N && n(!1);
1795
1800
  });
1796
1801
  },
1797
1802
  children: [
@@ -1801,7 +1806,7 @@ function Us({
1801
1806
  "aria-label": "反馈原因",
1802
1807
  maxLength: 128,
1803
1808
  value: i,
1804
- onChange: (p) => c(p.currentTarget.value),
1809
+ onChange: (f) => o(f.currentTarget.value),
1805
1810
  placeholder: "原因(可选)"
1806
1811
  }
1807
1812
  ),
@@ -1810,8 +1815,8 @@ function Us({
1810
1815
  {
1811
1816
  "aria-label": "反馈说明",
1812
1817
  maxLength: 4e3,
1813
- value: l,
1814
- onChange: (p) => m(p.currentTarget.value),
1818
+ value: d,
1819
+ onChange: (f) => h(f.currentTarget.value),
1815
1820
  placeholder: "补充说明(可选)"
1816
1821
  }
1817
1822
  ),
@@ -1820,7 +1825,7 @@ function Us({
1820
1825
  {
1821
1826
  className: "make-ai-assistant__feedback-text-action",
1822
1827
  type: "submit",
1823
- disabled: y,
1828
+ disabled: v,
1824
1829
  children: "提交反馈"
1825
1830
  }
1826
1831
  ),
@@ -1859,51 +1864,51 @@ function Fs({
1859
1864
  transport: s,
1860
1865
  chatId: n
1861
1866
  }) {
1862
- const [i, c] = $(), [l, m] = $(), [y, v] = $(!1), p = D([]), A = D(void 0);
1863
- ne(
1867
+ const [i, o] = R(), [d, h] = R(), [v, I] = R(!1), f = P([]), N = P(void 0);
1868
+ se(
1864
1869
  () => () => {
1865
- A.current?.abort(), p.current.forEach((S) => URL.revokeObjectURL(S));
1870
+ N.current?.abort(), f.current.forEach((A) => URL.revokeObjectURL(A));
1866
1871
  },
1867
1872
  []
1868
1873
  );
1869
- const C = async (S) => {
1870
- if (!s.readContent || y) return;
1871
- const k = new AbortController();
1872
- A.current = k, v(!0), m(void 0);
1874
+ const C = async (A) => {
1875
+ if (!s.readContent || v) return;
1876
+ const g = new AbortController();
1877
+ N.current = g, I(!0), h(void 0);
1873
1878
  try {
1874
- const U = await s.readContent(
1879
+ const F = await s.readContent(
1875
1880
  t,
1876
1881
  { chatId: n, contentRef: e.media.contentRef },
1877
- { signal: k.signal }
1882
+ { signal: g.signal }
1878
1883
  );
1879
- if (k.signal.aborted) return;
1880
- const L = new Blob([new Uint8Array(U).buffer], {
1881
- type: S && Vt.has(e.media.contentType) ? e.media.contentType : "application/octet-stream"
1882
- }), H = URL.createObjectURL(L);
1883
- if (p.current.push(H), S) c(H);
1884
+ if (g.signal.aborted) return;
1885
+ const T = new Blob([new Uint8Array(F).buffer], {
1886
+ type: A && Vt.has(e.media.contentType) ? e.media.contentType : "application/octet-stream"
1887
+ }), H = URL.createObjectURL(T);
1888
+ if (f.current.push(H), A) o(H);
1884
1889
  else {
1885
- const _ = document.createElement("a");
1886
- _.href = H, _.download = e.name ?? "attachment", _.click();
1890
+ const b = document.createElement("a");
1891
+ b.href = H, b.download = e.name ?? "attachment", b.click();
1887
1892
  }
1888
- } catch (U) {
1889
- k.signal.aborted || m(Et(U));
1893
+ } catch (F) {
1894
+ g.signal.aborted || h(Et(F));
1890
1895
  } finally {
1891
- k.signal.aborted || v(!1);
1896
+ g.signal.aborted || I(!1);
1892
1897
  }
1893
1898
  };
1894
- return /* @__PURE__ */ u("div", { className: "make-ai-assistant__attachment", children: [
1895
- /* @__PURE__ */ u("span", { children: [
1899
+ return /* @__PURE__ */ m("div", { className: "make-ai-assistant__attachment", children: [
1900
+ /* @__PURE__ */ m("span", { children: [
1896
1901
  e.name ?? "附件",
1897
1902
  " · ",
1898
1903
  e.media.sizeBytes,
1899
1904
  " 字节"
1900
1905
  ] }),
1901
- s.readContent ? /* @__PURE__ */ u(Ie, { children: [
1906
+ s.readContent ? /* @__PURE__ */ m(Ne, { children: [
1902
1907
  /* @__PURE__ */ a(
1903
1908
  "button",
1904
1909
  {
1905
1910
  type: "button",
1906
- disabled: y,
1911
+ disabled: v,
1907
1912
  onClick: () => {
1908
1913
  C(!1);
1909
1914
  },
@@ -1914,7 +1919,7 @@ function Fs({
1914
1919
  "button",
1915
1920
  {
1916
1921
  type: "button",
1917
- disabled: y,
1922
+ disabled: v,
1918
1923
  onClick: () => {
1919
1924
  C(!0);
1920
1925
  },
@@ -1922,7 +1927,7 @@ function Fs({
1922
1927
  }
1923
1928
  ) : null
1924
1929
  ] }) : null,
1925
- l ? /* @__PURE__ */ a("span", { role: "alert", children: l }) : null,
1930
+ d ? /* @__PURE__ */ a("span", { role: "alert", children: d }) : null,
1926
1931
  i && e.kind === "image" ? /* @__PURE__ */ a("img", { src: i, alt: e.name ?? "附件图片" }) : null,
1927
1932
  i && e.kind === "audio" ? /* @__PURE__ */ a("audio", { src: i, controls: !0 }) : null,
1928
1933
  i && e.kind === "video" ? /* @__PURE__ */ a("video", { src: i, controls: !0 }) : null
@@ -1934,14 +1939,14 @@ function Hs({
1934
1939
  transport: s,
1935
1940
  chatId: n
1936
1941
  }) {
1937
- return /* @__PURE__ */ a(Ie, { children: e.parts?.map(
1938
- (i, c) => i.kind === "text" ? null : i.kind === "unknown" ? /* @__PURE__ */ a(
1942
+ return /* @__PURE__ */ a(Ne, { children: e.parts?.map(
1943
+ (i, o) => i.kind === "text" ? null : i.kind === "unknown" ? /* @__PURE__ */ a(
1939
1944
  "span",
1940
1945
  {
1941
1946
  className: "make-ai-assistant__attachment",
1942
1947
  children: i.textFallback ?? "此内容类型暂不支持展示"
1943
1948
  },
1944
- i.id ?? `${e.id}:${c}`
1949
+ i.id ?? `${e.id}:${o}`
1945
1950
  ) : /* @__PURE__ */ a(
1946
1951
  Fs,
1947
1952
  {
@@ -1950,7 +1955,7 @@ function Hs({
1950
1955
  transport: s,
1951
1956
  chatId: n
1952
1957
  },
1953
- i.id ?? `${e.id}:${c}`
1958
+ i.id ?? `${e.id}:${o}`
1954
1959
  )
1955
1960
  ) });
1956
1961
  }
@@ -1967,7 +1972,7 @@ const Kt = (e) => {
1967
1972
  default:
1968
1973
  return `${Math.round(e.progress * 100)}%`;
1969
1974
  }
1970
- }, Os = (e, t) => {
1975
+ }, js = (e, t) => {
1971
1976
  switch (e.status) {
1972
1977
  case "uploading":
1973
1978
  case "queued":
@@ -1981,165 +1986,165 @@ const Kt = (e) => {
1981
1986
  case "ready":
1982
1987
  return;
1983
1988
  }
1984
- }, La = (e) => e.type.split(";")[0].trim().toLowerCase() || "application/octet-stream", qs = (e) => e.startsWith("image/") && e !== "image/svg+xml" ? "image" : e.startsWith("audio/") ? "audio" : e.startsWith("video/") ? "video" : "file", js = (e) => {
1985
- const t = La(e);
1989
+ }, za = (e) => e.type.split(";")[0].trim().toLowerCase() || "application/octet-stream", Os = (e) => e.startsWith("image/") && e !== "image/svg+xml" ? "image" : e.startsWith("audio/") ? "audio" : e.startsWith("video/") ? "video" : "file", qs = (e) => {
1990
+ const t = za(e);
1986
1991
  if (!(!t.startsWith("image/") || t === "image/svg+xml" || typeof URL > "u" || typeof URL.createObjectURL != "function"))
1987
1992
  return URL.createObjectURL(e);
1988
1993
  }, Wt = (e) => {
1989
1994
  e && typeof URL < "u" && typeof URL.revokeObjectURL == "function" && URL.revokeObjectURL(e);
1990
1995
  }, Bs = (e, t) => new Promise((s, n) => {
1991
- const i = new FileReader(), c = () => t.removeEventListener("abort", l), l = () => {
1992
- i.abort(), c(), n(Object.assign(new Error("Read aborted"), { name: "AbortError" }));
1996
+ const i = new FileReader(), o = () => t.removeEventListener("abort", d), d = () => {
1997
+ i.abort(), o(), n(Object.assign(new Error("Read aborted"), { name: "AbortError" }));
1993
1998
  };
1994
1999
  if (t.aborted) {
1995
- l();
2000
+ d();
1996
2001
  return;
1997
2002
  }
1998
- t.addEventListener("abort", l, { once: !0 }), i.onload = () => {
1999
- c(), s(new Uint8Array(i.result));
2003
+ t.addEventListener("abort", d, { once: !0 }), i.onload = () => {
2004
+ o(), s(new Uint8Array(i.result));
2000
2005
  }, i.onerror = () => {
2001
- c(), n(new Error("无法读取文件"));
2006
+ o(), n(new Error("无法读取文件"));
2002
2007
  }, i.readAsArrayBuffer(e);
2003
2008
  });
2004
2009
  function Vs(e, t, s) {
2005
- const [n, i] = $([]), c = D(/* @__PURE__ */ new Map()), l = D(Promise.resolve()), m = t.scopeKey?.(e) ?? e.app.id, y = D(m);
2006
- y.current = m;
2007
- const v = D(void 0), p = s.enabled && t.features?.attachments === !0, A = (h, r) => {
2008
- !c.current.has(h.draft.id) || h.scope !== y.current || (h.draft = { ...h.draft, ...r }, i([...c.current.values()].map((b) => b.draft)));
2010
+ const [n, i] = R([]), o = P(/* @__PURE__ */ new Map()), d = P(Promise.resolve()), h = t.scopeKey?.(e) ?? e.app.id, v = P(h);
2011
+ v.current = h;
2012
+ const I = P(void 0), f = s.available && t.features?.attachments === !0 && typeof t.startUpload == "function" && typeof t.getUpload == "function" && typeof t.uploadPart == "function" && typeof t.completeUpload == "function", N = (l, c) => {
2013
+ !o.current.has(l.draft.id) || l.scope !== v.current || (l.draft = { ...l.draft, ...c }, i([...o.current.values()].map((k) => k.draft)));
2009
2014
  }, C = () => {
2010
- for (const h of c.current.values())
2011
- h.controller.abort(), Wt(h.draft.previewUrl);
2012
- c.current.clear(), i([]), v.current = void 0, l.current = Promise.resolve();
2015
+ for (const l of o.current.values())
2016
+ l.controller.abort(), Wt(l.draft.previewUrl);
2017
+ o.current.clear(), i([]), I.current = void 0, d.current = Promise.resolve();
2013
2018
  };
2014
- ne(() => (C(), C), [m, t]), ne(() => {
2015
- v.current && s.chat?.chatId !== v.current && C();
2019
+ se(() => (C(), C), [h, t]), se(() => {
2020
+ I.current && s.chat?.chatId !== I.current && C();
2016
2021
  }, [s.chat?.chatId]);
2017
- const S = async (h) => {
2018
- const r = h.controller.signal, b = () => {
2019
- if (r.aborted || h.scope !== y.current || !c.current.has(h.draft.id))
2022
+ const A = async (l) => {
2023
+ const c = l.controller.signal, k = () => {
2024
+ if (c.aborted || l.scope !== v.current || !o.current.has(l.draft.id))
2020
2025
  throw Object.assign(new Error("Upload aborted"), {
2021
2026
  name: "AbortError"
2022
2027
  });
2023
2028
  };
2024
2029
  try {
2025
- if (b(), h.file.size > 64 << 20) throw new Error("文件不能超过 64 MiB");
2026
- const M = await s.ensureChat();
2027
- b(), v.current = M.chatId;
2028
- const W = La(h.file);
2029
- A(h, { status: "uploading", error: void 0 });
2030
- let N = h.draft.upload ? await t.getUpload(
2030
+ if (k(), l.file.size > 64 << 20) throw new Error("文件不能超过 64 MiB");
2031
+ const E = await s.ensureChat();
2032
+ k(), I.current = E.chatId;
2033
+ const W = za(l.file);
2034
+ N(l, { status: "uploading", error: void 0 });
2035
+ let M = l.draft.upload ? await t.getUpload(
2031
2036
  e,
2032
- { chatId: M.chatId, uploadId: h.draft.upload.id },
2033
- { signal: r }
2037
+ { chatId: E.chatId, uploadId: l.draft.upload.id },
2038
+ { signal: c }
2034
2039
  ) : await t.startUpload(
2035
2040
  e,
2036
2041
  {
2037
- chatId: M.chatId,
2038
- fileId: h.draft.fileId,
2039
- name: h.file.name,
2042
+ chatId: E.chatId,
2043
+ fileId: l.draft.fileId,
2044
+ name: l.file.name,
2040
2045
  contentType: W,
2041
- sizeBytes: h.file.size
2046
+ sizeBytes: l.file.size
2042
2047
  },
2043
- { signal: r }
2048
+ { signal: c }
2044
2049
  );
2045
- if (b(), A(h, { upload: N }), N.name !== h.file.name || N.contentType !== W || N.sizeBytes !== h.file.size)
2050
+ if (k(), N(l, { upload: M }), M.name !== l.file.name || M.contentType !== W || M.sizeBytes !== l.file.size)
2046
2051
  throw new Error("上传文件身份不一致");
2047
- if (N.status !== "ready") {
2048
- if (N = await t.getUpload(
2052
+ if (M.status !== "ready") {
2053
+ if (M = await t.getUpload(
2049
2054
  e,
2050
- { chatId: M.chatId, uploadId: N.id },
2051
- { signal: r }
2052
- ), b(), N.status !== "uploading" || !Number.isSafeInteger(N.partSize) || N.partSize <= 0 || N.partSize > 1 << 20) throw new Error("当前上传状态无法继续,请重新选择文件");
2053
- const X = new Set(N.completedParts), Q = Math.ceil(h.file.size / N.partSize);
2054
- for (let ie = 0; ie < Q; ie += 1) {
2055
- if (b(), !X.has(ie)) {
2056
- const Z = await Bs(
2057
- h.file.slice(
2058
- ie * N.partSize,
2059
- Math.min(h.file.size, (ie + 1) * N.partSize)
2055
+ { chatId: E.chatId, uploadId: M.id },
2056
+ { signal: c }
2057
+ ), k(), M.status !== "uploading" || !Number.isSafeInteger(M.partSize) || M.partSize <= 0 || M.partSize > 1 << 20) throw new Error("当前上传状态无法继续,请重新选择文件");
2058
+ const X = new Set(M.completedParts), me = Math.ceil(l.file.size / M.partSize);
2059
+ for (let ee = 0; ee < me; ee += 1) {
2060
+ if (k(), !X.has(ee)) {
2061
+ const he = await Bs(
2062
+ l.file.slice(
2063
+ ee * M.partSize,
2064
+ Math.min(l.file.size, (ee + 1) * M.partSize)
2060
2065
  ),
2061
- r
2066
+ c
2062
2067
  );
2063
- b(), await t.uploadPart(
2068
+ k(), await t.uploadPart(
2064
2069
  e,
2065
- { chatId: M.chatId, uploadId: N.id, part: ie, bytes: Z },
2066
- { signal: r }
2067
- ), b(), X.add(ie);
2070
+ { chatId: E.chatId, uploadId: M.id, part: ee, bytes: he },
2071
+ { signal: c }
2072
+ ), k(), X.add(ee);
2068
2073
  }
2069
- A(h, { progress: X.size / Math.max(Q, 1) });
2074
+ N(l, { progress: X.size / Math.max(me, 1) });
2070
2075
  }
2071
- A(h, { status: "completing" }), N = await t.completeUpload(
2076
+ N(l, { status: "completing" }), M = await t.completeUpload(
2072
2077
  e,
2073
- { chatId: M.chatId, uploadId: N.id },
2074
- { signal: r }
2075
- ), b();
2078
+ { chatId: E.chatId, uploadId: M.id },
2079
+ { signal: c }
2080
+ ), k();
2076
2081
  }
2077
- if (N.status !== "ready" || !N.content)
2082
+ if (M.status !== "ready" || !M.content)
2078
2083
  throw new Error("上传尚未完成");
2079
- A(h, { status: "ready", progress: 1, upload: N });
2080
- } catch (M) {
2081
- A(h, {
2082
- status: r.aborted ? "paused" : "failed",
2083
- error: r.aborted ? void 0 : Et(M)
2084
+ N(l, { status: "ready", progress: 1, upload: M });
2085
+ } catch (E) {
2086
+ N(l, {
2087
+ status: c.aborted ? "paused" : "failed",
2088
+ error: c.aborted ? void 0 : Et(E)
2084
2089
  });
2085
2090
  }
2086
- }, k = (h) => {
2087
- if (p) {
2088
- if (h.length + c.current.size > 32) {
2091
+ }, g = (l) => {
2092
+ if (f) {
2093
+ if (l.length + o.current.size > 32) {
2089
2094
  s.setError("每条消息最多包含 32 个附件或文本片段");
2090
2095
  return;
2091
2096
  }
2092
- for (const r of h) {
2093
- const b = {
2094
- id: Oe(),
2095
- fileId: Oe(),
2096
- name: r.name,
2097
- size: r.size,
2097
+ for (const c of l) {
2098
+ const k = {
2099
+ id: qe(),
2100
+ fileId: qe(),
2101
+ name: c.name,
2102
+ size: c.size,
2098
2103
  status: "queued",
2099
2104
  progress: 0,
2100
- previewUrl: js(r)
2101
- }, M = {
2102
- draft: b,
2103
- file: r,
2105
+ previewUrl: qs(c)
2106
+ }, E = {
2107
+ draft: k,
2108
+ file: c,
2104
2109
  controller: new AbortController(),
2105
- scope: m
2110
+ scope: h
2106
2111
  };
2107
- c.current.set(b.id, M), l.current = l.current.then(() => S(M));
2112
+ o.current.set(k.id, E), d.current = d.current.then(() => A(E));
2108
2113
  }
2109
- i([...c.current.values()].map((r) => r.draft));
2114
+ i([...o.current.values()].map((c) => c.draft));
2110
2115
  }
2111
- }, U = (h) => {
2112
- const r = c.current.get(h);
2113
- !r || !["paused", "failed"].includes(r.draft.status) || (r.controller = new AbortController(), A(r, { status: "queued" }), l.current = l.current.then(() => S(r)));
2114
- }, L = (h) => {
2115
- const r = c.current.get(h);
2116
- r?.controller.abort(), Wt(r?.draft.previewUrl), c.current.delete(h), i([...c.current.values()].map((b) => b.draft));
2117
- }, H = (h) => c.current.get(h)?.controller.abort(), _ = n.flatMap((h) => {
2118
- const r = h.upload;
2119
- if (h.status !== "ready" || !r?.content) return [];
2120
- const b = qs(r.contentType);
2116
+ }, F = (l) => {
2117
+ const c = o.current.get(l);
2118
+ !c || !["paused", "failed"].includes(c.draft.status) || (c.controller = new AbortController(), N(c, { status: "queued" }), d.current = d.current.then(() => A(c)));
2119
+ }, T = (l) => {
2120
+ const c = o.current.get(l);
2121
+ c?.controller.abort(), Wt(c?.draft.previewUrl), o.current.delete(l), i([...o.current.values()].map((k) => k.draft));
2122
+ }, H = (l) => o.current.get(l)?.controller.abort(), b = n.flatMap((l) => {
2123
+ const c = l.upload;
2124
+ if (l.status !== "ready" || !c?.content) return [];
2125
+ const k = Os(c.contentType);
2121
2126
  return [
2122
2127
  {
2123
- id: h.id,
2124
- kind: b,
2125
- name: r.name,
2128
+ id: l.id,
2129
+ kind: k,
2130
+ name: c.name,
2126
2131
  media: {
2127
- contentRef: r.content.contentRef,
2128
- contentType: r.contentType,
2129
- sizeBytes: r.content.sizeBytes,
2130
- digestSha256: r.content.digestSha256
2132
+ contentRef: c.content.contentRef,
2133
+ contentType: c.contentType,
2134
+ sizeBytes: c.content.sizeBytes,
2135
+ digestSha256: c.content.digestSha256
2131
2136
  }
2132
2137
  }
2133
2138
  ];
2134
2139
  });
2135
2140
  return {
2136
- enabled: p,
2141
+ enabled: f,
2137
2142
  drafts: n,
2138
- parts: _,
2139
- pending: n.some((h) => h.status !== "ready"),
2140
- add: k,
2141
- retry: U,
2142
- remove: L,
2143
+ parts: b,
2144
+ pending: n.some((l) => l.status !== "ready"),
2145
+ add: g,
2146
+ retry: F,
2147
+ remove: T,
2143
2148
  pause: H,
2144
2149
  clear: C
2145
2150
  };
@@ -2150,21 +2155,21 @@ function Ks({
2150
2155
  open: s,
2151
2156
  triggerRef: n
2152
2157
  }) {
2153
- const i = D(null), c = D(null);
2154
- ne(() => {
2158
+ const i = P(null), o = P(null);
2159
+ se(() => {
2155
2160
  if (!s) return;
2156
- const m = (y) => {
2157
- const v = y.target;
2158
- v instanceof Node && !i.current?.contains(v) && t(!1);
2161
+ const h = (v) => {
2162
+ const I = v.target;
2163
+ I instanceof Node && !i.current?.contains(I) && t(!1);
2159
2164
  };
2160
- return document.addEventListener("pointerdown", m), () => {
2161
- document.removeEventListener("pointerdown", m);
2165
+ return document.addEventListener("pointerdown", h), () => {
2166
+ document.removeEventListener("pointerdown", h);
2162
2167
  };
2163
2168
  }, [t, s]);
2164
- const l = (m) => {
2165
- e.add(Array.from(m.files ?? [])), m.value = "", t(!1);
2169
+ const d = (h) => {
2170
+ e.add(Array.from(h.files ?? [])), h.value = "", t(!1);
2166
2171
  };
2167
- return /* @__PURE__ */ u("div", { className: "make-ai-assistant__attachment-composer", ref: i, children: [
2172
+ return /* @__PURE__ */ m("div", { className: "make-ai-assistant__attachment-composer", ref: i, children: [
2168
2173
  /* @__PURE__ */ a(
2169
2174
  "button",
2170
2175
  {
@@ -2191,12 +2196,12 @@ function Ks({
2191
2196
  "aria-label": "附件选项",
2192
2197
  className: "make-ai-assistant__attachment-menu",
2193
2198
  role: "menu",
2194
- children: /* @__PURE__ */ u(
2199
+ children: /* @__PURE__ */ m(
2195
2200
  "button",
2196
2201
  {
2197
2202
  role: "menuitem",
2198
2203
  type: "button",
2199
- onClick: () => c.current?.click(),
2204
+ onClick: () => o.current?.click(),
2200
2205
  children: [
2201
2206
  /* @__PURE__ */ a(zs, { "aria-hidden": "true" }),
2202
2207
  /* @__PURE__ */ a("span", { children: "上传文件或图片" })
@@ -2211,9 +2216,9 @@ function Ks({
2211
2216
  "aria-label": "上传文件或图片",
2212
2217
  hidden: !0,
2213
2218
  multiple: !0,
2214
- ref: c,
2219
+ ref: o,
2215
2220
  type: "file",
2216
- onChange: (m) => l(m.currentTarget)
2221
+ onChange: (h) => d(h.currentTarget)
2217
2222
  }
2218
2223
  )
2219
2224
  ] });
@@ -2222,96 +2227,96 @@ function Ws({
2222
2227
  attachments: e,
2223
2228
  visible: t
2224
2229
  }) {
2225
- const [s, n] = $(), i = e.drafts.find((p) => p.id === s), c = !!i, l = D(null), m = D(null), y = Va(() => {
2226
- n(void 0), m.current?.focus();
2230
+ const [s, n] = R(), i = e.drafts.find((f) => f.id === s), o = !!i, d = P(null), h = P(null), v = Ka(() => {
2231
+ n(void 0), h.current?.focus();
2227
2232
  }, []);
2228
- if (ne(() => {
2229
- if (!c) return;
2230
- const p = (A) => {
2231
- A.key === "Escape" && (A.preventDefault(), A.stopImmediatePropagation(), y());
2233
+ if (se(() => {
2234
+ if (!o) return;
2235
+ const f = (N) => {
2236
+ N.key === "Escape" && (N.preventDefault(), N.stopImmediatePropagation(), v());
2232
2237
  };
2233
- return document.addEventListener("keydown", p, !0), () => document.removeEventListener("keydown", p, !0);
2234
- }, [y, c]), ne(() => {
2238
+ return document.addEventListener("keydown", f, !0), () => document.removeEventListener("keydown", f, !0);
2239
+ }, [v, o]), se(() => {
2235
2240
  t || n(void 0);
2236
2241
  }, [t]), !e.drafts.length) return null;
2237
- const v = typeof document > "u" ? void 0 : l.current?.closest(".make-ai-assistant") ?? document.body;
2238
- return /* @__PURE__ */ u(
2242
+ const I = typeof document > "u" ? void 0 : d.current?.closest(".make-ai-assistant") ?? document.body;
2243
+ return /* @__PURE__ */ m(
2239
2244
  "div",
2240
2245
  {
2241
2246
  "aria-label": "待发送附件",
2242
2247
  className: "make-ai-assistant__attachment-drafts",
2243
- ref: l,
2248
+ ref: d,
2244
2249
  children: [
2245
- /* @__PURE__ */ a("ul", { children: e.drafts.map((p) => {
2246
- const A = Kt(p), C = Os(p, A);
2247
- return /* @__PURE__ */ u(
2250
+ /* @__PURE__ */ a("ul", { children: e.drafts.map((f) => {
2251
+ const N = Kt(f), C = js(f, N);
2252
+ return /* @__PURE__ */ m(
2248
2253
  "li",
2249
2254
  {
2250
- "aria-label": `${p.name},${A}`,
2251
- "data-status": p.status,
2255
+ "aria-label": `${f.name},${N}`,
2256
+ "data-status": f.status,
2252
2257
  children: [
2253
- p.previewUrl ? /* @__PURE__ */ a(
2258
+ f.previewUrl ? /* @__PURE__ */ a(
2254
2259
  "button",
2255
2260
  {
2256
- "aria-label": `预览附件 ${p.name}`,
2261
+ "aria-label": `预览附件 ${f.name}`,
2257
2262
  className: "make-ai-assistant__attachment-draft-preview-button",
2258
2263
  type: "button",
2259
- onClick: (S) => {
2260
- m.current = S.currentTarget, n(p.id);
2264
+ onClick: (A) => {
2265
+ h.current = A.currentTarget, n(f.id);
2261
2266
  },
2262
2267
  children: /* @__PURE__ */ a(
2263
2268
  "img",
2264
2269
  {
2265
2270
  alt: "",
2266
2271
  className: "make-ai-assistant__attachment-draft-preview",
2267
- src: p.previewUrl
2272
+ src: f.previewUrl
2268
2273
  }
2269
2274
  )
2270
2275
  }
2271
2276
  ) : /* @__PURE__ */ a(
2272
2277
  "button",
2273
2278
  {
2274
- "aria-label": `查看附件详情 ${p.name}`,
2279
+ "aria-label": `查看附件详情 ${f.name}`,
2275
2280
  className: "make-ai-assistant__attachment-draft-file",
2276
2281
  type: "button",
2277
- onClick: (S) => {
2278
- m.current = S.currentTarget, n(p.id);
2282
+ onClick: (A) => {
2283
+ h.current = A.currentTarget, n(f.id);
2279
2284
  },
2280
- children: /* @__PURE__ */ a(Ot, { "aria-hidden": "true" })
2285
+ children: /* @__PURE__ */ a(jt, { "aria-hidden": "true" })
2281
2286
  }
2282
2287
  ),
2283
2288
  C ? /* @__PURE__ */ a("span", { "aria-hidden": "true", className: "make-ai-assistant__attachment-draft-status", children: C }) : null,
2284
- p.error ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__attachment-draft-error", role: "alert", children: p.error }) : null,
2285
- p.status === "failed" || p.status === "paused" ? /* @__PURE__ */ a(
2289
+ f.error ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__attachment-draft-error", role: "alert", children: f.error }) : null,
2290
+ f.status === "failed" || f.status === "paused" ? /* @__PURE__ */ a(
2286
2291
  "button",
2287
2292
  {
2288
- "aria-label": `重试上传 ${p.name}`,
2293
+ "aria-label": `重试上传 ${f.name}`,
2289
2294
  className: "make-ai-assistant__attachment-draft-control",
2290
2295
  title: "重试上传",
2291
2296
  type: "button",
2292
- onClick: () => e.retry(p.id),
2297
+ onClick: () => e.retry(f.id),
2293
2298
  children: /* @__PURE__ */ a($s, { "aria-hidden": "true" })
2294
2299
  }
2295
2300
  ) : null,
2296
- p.status === "uploading" ? /* @__PURE__ */ a(
2301
+ f.status === "uploading" ? /* @__PURE__ */ a(
2297
2302
  "button",
2298
2303
  {
2299
- "aria-label": `暂停上传 ${p.name}`,
2304
+ "aria-label": `暂停上传 ${f.name}`,
2300
2305
  className: "make-ai-assistant__attachment-draft-control",
2301
2306
  title: "暂停上传",
2302
2307
  type: "button",
2303
- onClick: () => e.pause(p.id),
2308
+ onClick: () => e.pause(f.id),
2304
2309
  children: /* @__PURE__ */ a(Ms, { "aria-hidden": "true" })
2305
2310
  }
2306
2311
  ) : null,
2307
2312
  /* @__PURE__ */ a(
2308
2313
  "button",
2309
2314
  {
2310
- "aria-label": `移除附件 ${p.name}`,
2315
+ "aria-label": `移除附件 ${f.name}`,
2311
2316
  className: "make-ai-assistant__attachment-draft-remove",
2312
2317
  type: "button",
2313
2318
  onClick: () => {
2314
- s === p.id && y(), e.remove(p.id);
2319
+ s === f.id && v(), e.remove(f.id);
2315
2320
  },
2316
2321
  children: /* @__PURE__ */ a(
2317
2322
  tt,
@@ -2324,18 +2329,18 @@ function Ws({
2324
2329
  )
2325
2330
  ]
2326
2331
  },
2327
- p.id
2332
+ f.id
2328
2333
  );
2329
2334
  }) }),
2330
- i && v ? aa(
2335
+ i && I ? aa(
2331
2336
  /* @__PURE__ */ a(
2332
2337
  "div",
2333
2338
  {
2334
2339
  className: "make-ai-assistant__attachment-preview-backdrop",
2335
- onPointerDown: (p) => {
2336
- p.target === p.currentTarget && y();
2340
+ onPointerDown: (f) => {
2341
+ f.target === f.currentTarget && v();
2337
2342
  },
2338
- children: /* @__PURE__ */ u(
2343
+ children: /* @__PURE__ */ m(
2339
2344
  "div",
2340
2345
  {
2341
2346
  "aria-label": `${i.previewUrl ? "预览附件" : "附件详情"} ${i.name}`,
@@ -2343,8 +2348,8 @@ function Ws({
2343
2348
  className: "make-ai-assistant__attachment-preview-dialog",
2344
2349
  "data-kind": i.previewUrl ? "image" : "file",
2345
2350
  role: "dialog",
2346
- onKeyDown: (p) => {
2347
- p.key === "Tab" && p.preventDefault();
2351
+ onKeyDown: (f) => {
2352
+ f.key === "Tab" && f.preventDefault();
2348
2353
  },
2349
2354
  children: [
2350
2355
  /* @__PURE__ */ a(
@@ -2354,7 +2359,7 @@ function Ws({
2354
2359
  autoFocus: !0,
2355
2360
  className: "make-ai-assistant__attachment-preview-close",
2356
2361
  type: "button",
2357
- onClick: y,
2362
+ onClick: v,
2358
2363
  children: /* @__PURE__ */ a(
2359
2364
  tt,
2360
2365
  {
@@ -2364,8 +2369,8 @@ function Ws({
2364
2369
  )
2365
2370
  }
2366
2371
  ),
2367
- i.previewUrl ? /* @__PURE__ */ a("img", { alt: i.name, src: i.previewUrl }) : /* @__PURE__ */ a("div", { "aria-hidden": "true", className: "make-ai-assistant__attachment-preview-file", children: /* @__PURE__ */ a(Ot, {}) }),
2368
- /* @__PURE__ */ u("div", { className: "make-ai-assistant__attachment-preview-details", children: [
2372
+ i.previewUrl ? /* @__PURE__ */ a("img", { alt: i.name, src: i.previewUrl }) : /* @__PURE__ */ a("div", { "aria-hidden": "true", className: "make-ai-assistant__attachment-preview-file", children: /* @__PURE__ */ a(jt, {}) }),
2373
+ /* @__PURE__ */ m("div", { className: "make-ai-assistant__attachment-preview-details", children: [
2369
2374
  /* @__PURE__ */ a("strong", { children: i.name }),
2370
2375
  /* @__PURE__ */ a("span", { children: Kt(i) }),
2371
2376
  i.error ? /* @__PURE__ */ a("p", { children: i.error }) : null
@@ -2375,7 +2380,7 @@ function Ws({
2375
2380
  )
2376
2381
  }
2377
2382
  ),
2378
- v
2383
+ I
2379
2384
  ) : null
2380
2385
  ]
2381
2386
  }
@@ -2385,27 +2390,27 @@ const Xs = (e) => `${e}-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`
2385
2390
  "总结当前页面数据",
2386
2391
  "找出需要关注的记录",
2387
2392
  "列出我有权限查看的数据对象"
2388
- ], Js = 48, Ys = 160, za = (e, t) => t ?? `${e?.trim() || Gs} AI 助手`, Qs = (e) => e ?? Zs, en = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : void 0, tn = (e) => typeof e == "number" ? Number.isFinite(e) ? `${e}px` : void 0 : e?.trim() || void 0;
2393
+ ], Js = 48, Ys = 160, xa = (e, t) => t ?? `${e?.trim() || Gs} AI 助手`, Qs = (e) => e ?? Zs, en = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : void 0, tn = (e) => typeof e == "number" ? Number.isFinite(e) ? `${e}px` : void 0 : e?.trim() || void 0;
2389
2394
  class J extends Error {
2390
2395
  }
2391
- const pt = (e, t) => {
2396
+ const dt = (e, t) => {
2392
2397
  if (!(typeof e != "object" || e === null))
2393
2398
  return e[t];
2394
2399
  }, an = (e) => {
2395
- const t = pt(e, "status");
2396
- return typeof t == "number" ? t : pt(
2397
- pt(e, "response"),
2400
+ const t = dt(e, "status");
2401
+ return typeof t == "number" ? t : dt(
2402
+ dt(e, "response"),
2398
2403
  "status"
2399
2404
  );
2400
2405
  }, sn = (e) => {
2401
- const t = pt(e, "code"), s = an(e), n = e instanceof Error ? e.message : "", i = [t, n].filter((y) => typeof y == "string").join(" ").toLowerCase(), l = globalThis.navigator?.onLine === !1 || /network|fetch|timeout|offline|connection|网络|连接|超时/.test(i), m = typeof s == "number" && s >= 500 || /server|service|服务器|服务异常/.test(i);
2402
- return l ? {
2406
+ const t = dt(e, "code"), s = an(e), n = e instanceof Error ? e.message : "", i = [t, n].filter((v) => typeof v == "string").join(" ").toLowerCase(), d = globalThis.navigator?.onLine === !1 || /network|fetch|timeout|offline|connection|网络|连接|超时/.test(i), h = typeof s == "number" && s >= 500 || /server|service|服务器|服务异常/.test(i);
2407
+ return d ? {
2403
2408
  actionLabel: "重新连接",
2404
2409
  description: "请检查网络后再试。",
2405
2410
  kind: "network",
2406
2411
  label: "网络连接",
2407
2412
  title: "网络连接不可用"
2408
- } : m ? {
2413
+ } : h ? {
2409
2414
  actionLabel: "重新加载",
2410
2415
  description: "服务暂时未能响应,请稍后重试。",
2411
2416
  kind: "service",
@@ -2444,12 +2449,12 @@ const pt = (e, t) => {
2444
2449
  const s = document.execCommand("copy");
2445
2450
  if (t.remove(), !s)
2446
2451
  throw new Error("Clipboard copy failed");
2447
- }, ft = ({ className: e = "" }) => /* @__PURE__ */ a("span", { className: `make-ai-assistant__avatar ${e}`.trim(), "aria-hidden": "true", children: /* @__PURE__ */ a(Ca, { "aria-hidden": "true" }) }), rn = ({ src: e }) => e ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__user-avatar", "aria-hidden": "true", children: /* @__PURE__ */ a("img", { alt: "", src: e }) }) : null, on = ({
2452
+ }, ut = ({ className: e = "" }) => /* @__PURE__ */ a("span", { className: `make-ai-assistant__avatar ${e}`.trim(), "aria-hidden": "true", children: /* @__PURE__ */ a(Ma, { "aria-hidden": "true" }) }), rn = ({ src: e }) => e ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__user-avatar", "aria-hidden": "true", children: /* @__PURE__ */ a("img", { alt: "", src: e }) }) : null, on = ({
2448
2453
  userAvatarUrl: e,
2449
2454
  userName: t
2450
2455
  }) => {
2451
2456
  const s = t?.trim();
2452
- return !s && !e ? null : /* @__PURE__ */ u("div", { className: "make-ai-assistant__message-identity", children: [
2457
+ return !s && !e ? null : /* @__PURE__ */ m("div", { className: "make-ai-assistant__message-identity", children: [
2453
2458
  s ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: s }) : null,
2454
2459
  /* @__PURE__ */ a(rn, { src: e })
2455
2460
  ] });
@@ -2462,67 +2467,80 @@ const pt = (e, t) => {
2462
2467
  if (!s || !n || s.length !== n.length || !cn(n))
2463
2468
  return;
2464
2469
  const i = [];
2465
- let c = t + 2;
2466
- for (; c < e.length; ) {
2467
- const l = wt(e[c] ?? "");
2468
- if (!l || l.length !== s.length) break;
2469
- i.push(l), c += 1;
2470
+ let o = t + 2;
2471
+ for (; o < e.length; ) {
2472
+ const d = wt(e[o] ?? "");
2473
+ if (!d || d.length !== s.length) break;
2474
+ i.push(d), o += 1;
2470
2475
  }
2471
- return { headers: s, lastIndex: c - 1, rows: i };
2476
+ return { headers: s, lastIndex: o - 1, rows: i };
2472
2477
  }, dn = (e) => {
2473
- const t = [], s = [], n = [], i = [], c = e.replace(/\r\n?/g, `
2478
+ const t = [], s = [], n = [], i = [], o = [], d = e.replace(/\r\n?/g, `
2474
2479
  `).split(`
2475
- `), l = () => {
2476
- const v = s.join(`
2480
+ `);
2481
+ let h;
2482
+ const v = () => {
2483
+ const N = s.join(`
2477
2484
  `).trim();
2478
- s.length = 0, v && t.push({ type: "paragraph", text: v });
2479
- }, m = () => {
2485
+ s.length = 0, N && t.push({ type: "paragraph", text: N });
2486
+ }, I = () => {
2480
2487
  n.length && t.push({ type: "list", items: n.splice(0) });
2481
- }, y = () => {
2482
- const v = i.join(`
2488
+ }, f = () => {
2489
+ const N = i.join(`
2483
2490
  `).trim();
2484
- i.length = 0, v && t.push({ type: "pre", text: v });
2491
+ i.length = 0, N && t.push({ type: "pre", text: N });
2485
2492
  };
2486
- for (let v = 0; v < c.length; v += 1) {
2487
- const p = c[v] ?? "", A = p.trim();
2488
- if (!A) {
2489
- l(), m(), y();
2493
+ for (let N = 0; N < d.length; N += 1) {
2494
+ const C = d[N] ?? "", A = /^ {0,3}(`{3,}|~{3,})(.*)$/.exec(C);
2495
+ if (h) {
2496
+ A && A[1]?.[0] === h.marker && A[1].length >= h.length && !A[2]?.trim() ? (t.push({ type: "pre", text: o.join(`
2497
+ `) }), o.length = 0, h = void 0) : o.push(C);
2498
+ continue;
2499
+ }
2500
+ if (A && (A[1]?.[0] === "~" || !A[2]?.includes("`"))) {
2501
+ v(), I(), f(), h = { marker: A[1]?.[0] ?? "`", length: A[1]?.length ?? 3 };
2490
2502
  continue;
2491
2503
  }
2492
- const C = ln(c, v);
2493
- if (C) {
2494
- l(), m(), y(), t.push({ headers: C.headers, rows: C.rows, type: "table" }), v = C.lastIndex;
2504
+ const g = C.trim();
2505
+ if (!g) {
2506
+ v(), I(), f();
2495
2507
  continue;
2496
2508
  }
2497
- const S = /^(#{1,6})\s+(.+)$/.exec(A);
2498
- if (S) {
2499
- l(), m(), y();
2500
- const U = (S[2] ?? "").replace(/\s+#+\s*$/, "").trim();
2501
- U && t.push({
2509
+ const F = ln(d, N);
2510
+ if (F) {
2511
+ v(), I(), f(), t.push({ headers: F.headers, rows: F.rows, type: "table" }), N = F.lastIndex;
2512
+ continue;
2513
+ }
2514
+ const T = /^(#{1,6})\s+(.+)$/.exec(g);
2515
+ if (T) {
2516
+ v(), I(), f();
2517
+ const b = (T[2] ?? "").replace(/\s+#+\s*$/, "").trim();
2518
+ b && t.push({
2502
2519
  type: "heading",
2503
- level: S[1]?.length,
2504
- text: U
2520
+ level: T[1]?.length,
2521
+ text: b
2505
2522
  });
2506
2523
  continue;
2507
2524
  }
2508
- if (/^\s*\|.+\|\s*$/.test(p)) {
2509
- l(), m(), i.push(p.trim());
2525
+ if (/^\s*\|.+\|\s*$/.test(C)) {
2526
+ v(), I(), i.push(C.trim());
2510
2527
  continue;
2511
2528
  }
2512
- const k = /^\s*[-*]\s+(.+)$/.exec(p);
2513
- if (k) {
2514
- l(), y(), n.push(k[1]?.trim() ?? "");
2529
+ const H = /^\s*[-*]\s+(.+)$/.exec(C);
2530
+ if (H) {
2531
+ v(), f(), n.push(H[1]?.trim() ?? "");
2515
2532
  continue;
2516
2533
  }
2517
- m(), y(), s.push(A);
2534
+ I(), f(), s.push(g);
2518
2535
  }
2519
- return l(), m(), y(), t;
2536
+ return v(), I(), f(), h && t.push({ type: "pre", text: o.join(`
2537
+ `) }), t;
2520
2538
  }, et = (e) => {
2521
2539
  const t = [], s = /(\*\*[^*]+\*\*|`[^`]+`)/g;
2522
2540
  let n = 0;
2523
2541
  for (const i of e.matchAll(s)) {
2524
- const c = i[0], l = i.index ?? 0;
2525
- l > n && t.push(e.slice(n, l)), c.startsWith("**") ? t.push(/* @__PURE__ */ a("strong", { children: c.slice(2, -2) }, `${l}-strong`)) : t.push(/* @__PURE__ */ a("code", { children: c.slice(1, -1) }, `${l}-code`)), n = l + c.length;
2542
+ const o = i[0], d = i.index ?? 0;
2543
+ d > n && t.push(e.slice(n, d)), o.startsWith("**") ? t.push(/* @__PURE__ */ a("strong", { children: o.slice(2, -2) }, `${d}-strong`)) : t.push(/* @__PURE__ */ a("code", { children: o.slice(1, -1) }, `${d}-code`)), n = d + o.length;
2526
2544
  }
2527
2545
  return n < e.length && t.push(e.slice(n)), t;
2528
2546
  }, Gt = ({ content: e }) => {
@@ -2539,25 +2557,25 @@ const pt = (e, t) => {
2539
2557
  `${n}-heading`
2540
2558
  );
2541
2559
  }
2542
- return s.type === "paragraph" ? /* @__PURE__ */ a("p", { children: et(s.text) }, `${n}-paragraph`) : s.type === "pre" ? /* @__PURE__ */ a("pre", { children: /* @__PURE__ */ a("code", { children: s.text }) }, `${n}-pre`) : s.type === "table" ? /* @__PURE__ */ a(
2560
+ return s.type === "paragraph" ? /* @__PURE__ */ a("p", { children: et(s.text) }, `${n}-paragraph`) : s.type === "pre" ? /* @__PURE__ */ a("pre", { "aria-label": "代码块,可横向滚动", role: "region", tabIndex: 0, children: /* @__PURE__ */ a("code", { children: s.text }) }, `${n}-pre`) : s.type === "table" ? /* @__PURE__ */ a(
2543
2561
  "div",
2544
2562
  {
2545
2563
  "aria-label": "表格内容,可横向滚动",
2546
2564
  className: "make-ai-assistant__markdown-table-scroll",
2547
2565
  role: "region",
2548
2566
  tabIndex: 0,
2549
- children: /* @__PURE__ */ u("table", { className: "make-ai-assistant__markdown-table", children: [
2550
- /* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: s.headers.map((i, c) => /* @__PURE__ */ a("th", { scope: "col", children: et(i) }, `${c}-${i}`)) }) }),
2551
- /* @__PURE__ */ a("tbody", { children: s.rows.map((i, c) => /* @__PURE__ */ a("tr", { children: i.map((l, m) => /* @__PURE__ */ a("td", { children: et(l) }, `${m}-${l}`)) }, `${c}-${i.join("|")}`)) })
2567
+ children: /* @__PURE__ */ m("table", { className: "make-ai-assistant__markdown-table", children: [
2568
+ /* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: s.headers.map((i, o) => /* @__PURE__ */ a("th", { scope: "col", children: et(i) }, `${o}-${i}`)) }) }),
2569
+ /* @__PURE__ */ a("tbody", { children: s.rows.map((i, o) => /* @__PURE__ */ a("tr", { children: i.map((d, h) => /* @__PURE__ */ a("td", { children: et(d) }, `${h}-${d}`)) }, `${o}-${i.join("|")}`)) })
2552
2570
  ] })
2553
2571
  },
2554
2572
  `${n}-table`
2555
- ) : /* @__PURE__ */ a("ul", { children: s.items.map((i, c) => /* @__PURE__ */ a("li", { children: et(i) }, `${c}-${i}`)) }, `${n}-list`);
2573
+ ) : /* @__PURE__ */ a("ul", { children: s.items.map((i, o) => /* @__PURE__ */ a("li", { children: et(i) }, `${o}-${i}`)) }, `${n}-list`);
2556
2574
  }) }) : null;
2557
- }, xa = ({ assistantName: e }) => /* @__PURE__ */ u("div", { className: "make-ai-assistant__message-identity", children: [
2558
- /* @__PURE__ */ a(ft, { className: "make-ai-assistant__avatar--message" }),
2575
+ }, Da = ({ assistantName: e }) => /* @__PURE__ */ m("div", { className: "make-ai-assistant__message-identity", children: [
2576
+ /* @__PURE__ */ a(ut, { className: "make-ai-assistant__avatar--message" }),
2559
2577
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: e })
2560
- ] }), Da = (e) => {
2578
+ ] }), Pa = (e) => {
2561
2579
  for (let t = e.messages.length - 1; t >= 0; t -= 1) {
2562
2580
  const s = e.messages[t];
2563
2581
  if (s.role === "assistant" && s.status === "streaming")
@@ -2567,7 +2585,7 @@ const pt = (e, t) => {
2567
2585
  for (let t = e.messages.length - 1; t >= 0; t -= 1)
2568
2586
  if (e.messages[t].role === "user") return t;
2569
2587
  return -1;
2570
- }, Pa = (e) => {
2588
+ }, Ua = (e) => {
2571
2589
  const t = un(e);
2572
2590
  if (!(t < 0))
2573
2591
  for (let s = e.messages.length - 1; s > t; s -= 1) {
@@ -2586,7 +2604,7 @@ const pt = (e, t) => {
2586
2604
  const s = e.messages[t];
2587
2605
  if (s.role === "user") return s;
2588
2606
  }
2589
- }, pn = (e, t) => {
2607
+ }, fn = (e, t) => {
2590
2608
  const s = e.messages.findIndex(
2591
2609
  (n) => n.id === t && n.role === "user"
2592
2610
  );
@@ -2597,31 +2615,31 @@ const pt = (e, t) => {
2597
2615
  status: "streaming",
2598
2616
  messages: s < 0 ? e.messages : e.messages.slice(0, s + 1)
2599
2617
  };
2600
- }, fn = (e) => e.scrollHeight - e.scrollTop - e.clientHeight <= 48, Zt = (e = "smooth") => globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : e, It = (e, t) => {
2618
+ }, pn = (e) => e.scrollHeight - e.scrollTop - e.clientHeight <= 48, Zt = (e = "smooth") => globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : e, It = (e, t) => {
2601
2619
  typeof e.scrollTo == "function" ? e.scrollTo({ top: e.scrollHeight, behavior: t }) : e.scrollTop = e.scrollHeight;
2602
- }, Ua = ({
2620
+ }, Fa = ({
2603
2621
  error: e,
2604
2622
  onRetry: t
2605
- }) => /* @__PURE__ */ u(
2623
+ }) => /* @__PURE__ */ m(
2606
2624
  "div",
2607
2625
  {
2608
2626
  className: "make-ai-assistant__message-status make-ai-assistant__message-status--error",
2609
2627
  "data-error-presentation": "request-failed",
2610
2628
  role: "alert",
2611
2629
  children: [
2612
- /* @__PURE__ */ u("div", { className: "make-ai-assistant__message-status-header", children: [
2613
- /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-icon", "aria-hidden": "true", children: /* @__PURE__ */ a(bs, { "aria-hidden": "true" }) }),
2630
+ /* @__PURE__ */ m("div", { className: "make-ai-assistant__message-status-header", children: [
2631
+ /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-icon", "aria-hidden": "true", children: /* @__PURE__ */ a(ua, { "aria-hidden": "true" }) }),
2614
2632
  /* @__PURE__ */ a("strong", { children: "请求未完成" })
2615
2633
  ] }),
2616
2634
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-message", children: e.message }),
2617
- e.retryable && t ? /* @__PURE__ */ u(
2635
+ e.retryable && t ? /* @__PURE__ */ m(
2618
2636
  "button",
2619
2637
  {
2620
2638
  className: "make-ai-assistant__retry",
2621
2639
  type: "button",
2622
2640
  onClick: t,
2623
2641
  children: [
2624
- /* @__PURE__ */ a(vt, { "aria-hidden": "true" }),
2642
+ /* @__PURE__ */ a(mt, { "aria-hidden": "true" }),
2625
2643
  "重新发送"
2626
2644
  ]
2627
2645
  }
@@ -2633,7 +2651,7 @@ const pt = (e, t) => {
2633
2651
  onRetry: t
2634
2652
  }) => {
2635
2653
  const s = sn(e);
2636
- return /* @__PURE__ */ u(
2654
+ return /* @__PURE__ */ m(
2637
2655
  "section",
2638
2656
  {
2639
2657
  "aria-live": "assertive",
@@ -2642,19 +2660,19 @@ const pt = (e, t) => {
2642
2660
  role: "alert",
2643
2661
  children: [
2644
2662
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__load-failure-icon", "aria-hidden": "true", children: /* @__PURE__ */ a(_s, { "aria-hidden": "true" }) }),
2645
- /* @__PURE__ */ u("div", { className: "make-ai-assistant__load-failure-copy", children: [
2663
+ /* @__PURE__ */ m("div", { className: "make-ai-assistant__load-failure-copy", children: [
2646
2664
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__load-failure-label", children: s.label }),
2647
2665
  /* @__PURE__ */ a("h3", { children: s.title }),
2648
2666
  /* @__PURE__ */ a("p", { children: s.description })
2649
2667
  ] }),
2650
- /* @__PURE__ */ u(
2668
+ /* @__PURE__ */ m(
2651
2669
  "button",
2652
2670
  {
2653
2671
  className: "make-ai-assistant__retry make-ai-assistant__retry--primary",
2654
2672
  type: "button",
2655
2673
  onClick: t,
2656
2674
  children: [
2657
- /* @__PURE__ */ a(vt, { "aria-hidden": "true" }),
2675
+ /* @__PURE__ */ a(mt, { "aria-hidden": "true" }),
2658
2676
  s.actionLabel
2659
2677
  ]
2660
2678
  }
@@ -2662,24 +2680,24 @@ const pt = (e, t) => {
2662
2680
  ]
2663
2681
  }
2664
2682
  );
2665
- }, Fa = ({
2683
+ }, Ha = ({
2666
2684
  active: e,
2667
2685
  steps: t
2668
2686
  }) => {
2669
- const [s, n] = $(!1);
2687
+ const [s, n] = R(!1);
2670
2688
  if (!e || !t?.length) return null;
2671
2689
  const i = t[t.length - 1] ?? "处理中";
2672
- return /* @__PURE__ */ u(
2690
+ return /* @__PURE__ */ m(
2673
2691
  "details",
2674
2692
  {
2675
2693
  className: "make-ai-assistant__process",
2676
2694
  open: s,
2677
- onToggle: (c) => n(c.currentTarget.open),
2695
+ onToggle: (o) => n(o.currentTarget.open),
2678
2696
  children: [
2679
- /* @__PURE__ */ u("summary", { "aria-label": `查看处理过程,共 ${t.length} 步`, children: [
2680
- /* @__PURE__ */ u("span", { className: "make-ai-assistant__process-summary", children: [
2697
+ /* @__PURE__ */ m("summary", { "aria-label": `查看处理过程,共 ${t.length} 步`, children: [
2698
+ /* @__PURE__ */ m("span", { className: "make-ai-assistant__process-summary", children: [
2681
2699
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__process-indicator", "aria-hidden": "true" }),
2682
- /* @__PURE__ */ u("span", { className: "make-ai-assistant__process-copy", children: [
2700
+ /* @__PURE__ */ m("span", { className: "make-ai-assistant__process-copy", children: [
2683
2701
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__process-title", children: "处理过程" }),
2684
2702
  /* @__PURE__ */ a(
2685
2703
  "span",
@@ -2691,21 +2709,21 @@ const pt = (e, t) => {
2691
2709
  )
2692
2710
  ] })
2693
2711
  ] }),
2694
- /* @__PURE__ */ u("span", { className: "make-ai-assistant__process-count", children: [
2712
+ /* @__PURE__ */ m("span", { className: "make-ai-assistant__process-count", children: [
2695
2713
  t.length,
2696
2714
  " 步"
2697
2715
  ] })
2698
2716
  ] }),
2699
- /* @__PURE__ */ a("ol", { children: t.map((c, l) => /* @__PURE__ */ u(
2717
+ /* @__PURE__ */ a("ol", { children: t.map((o, d) => /* @__PURE__ */ m(
2700
2718
  "li",
2701
2719
  {
2702
- "data-step-active": l === t.length - 1 ? !0 : void 0,
2720
+ "data-step-active": d === t.length - 1 ? !0 : void 0,
2703
2721
  children: [
2704
2722
  /* @__PURE__ */ a("span", { "aria-hidden": "true" }),
2705
- /* @__PURE__ */ a("span", { children: c })
2723
+ /* @__PURE__ */ a("span", { children: o })
2706
2724
  ]
2707
2725
  },
2708
- `${l}-${c}`
2726
+ `${d}-${o}`
2709
2727
  )) })
2710
2728
  ]
2711
2729
  }
@@ -2715,7 +2733,7 @@ const pt = (e, t) => {
2715
2733
  feedback: t,
2716
2734
  onCopy: s,
2717
2735
  onRegenerate: n
2718
- }) => !t && !s && !n ? null : /* @__PURE__ */ u("div", { className: "make-ai-assistant__reply-actions", "aria-label": "回复操作", children: [
2736
+ }) => !t && !s && !n ? null : /* @__PURE__ */ m("div", { className: "make-ai-assistant__reply-actions", "aria-label": "回复操作", children: [
2719
2737
  s ? /* @__PURE__ */ a(
2720
2738
  "button",
2721
2739
  {
@@ -2742,7 +2760,7 @@ const pt = (e, t) => {
2742
2760
  "data-tooltip": "重新生成",
2743
2761
  type: "button",
2744
2762
  onClick: n,
2745
- children: /* @__PURE__ */ a(vt, { "aria-hidden": "true" })
2763
+ children: /* @__PURE__ */ a(mt, { "aria-hidden": "true" })
2746
2764
  }
2747
2765
  ) : null,
2748
2766
  e ? /* @__PURE__ */ a(
@@ -2768,465 +2786,471 @@ const pt = (e, t) => {
2768
2786
  className: `make-ai-assistant__message make-ai-assistant__message--assistant make-ai-assistant__message--${i}`,
2769
2787
  "data-message-role": "assistant",
2770
2788
  "data-message-state": i,
2771
- children: /* @__PURE__ */ u("div", { className: "make-ai-assistant__message-turn", children: [
2772
- /* @__PURE__ */ a(xa, { assistantName: e }),
2773
- /* @__PURE__ */ a("div", { className: "make-ai-assistant__message-stack", children: t ? /* @__PURE__ */ a(Ua, { error: t, onRetry: s }) : /* @__PURE__ */ a(Fa, { active: !0, steps: n?.steps }) })
2789
+ children: /* @__PURE__ */ m("div", { className: "make-ai-assistant__message-turn", children: [
2790
+ /* @__PURE__ */ a(Da, { assistantName: e }),
2791
+ /* @__PURE__ */ a("div", { className: "make-ai-assistant__message-stack", children: t ? /* @__PURE__ */ a(Fa, { error: t, onRetry: s }) : /* @__PURE__ */ a(Ha, { active: !0, steps: n?.steps }) })
2774
2792
  ] })
2775
2793
  }
2776
2794
  ) : null;
2777
- }, kn = (e, t, s, n, i, c, l, m, y, v, p, A, C, S, k, U) => {
2778
- const L = Pa(e), H = Da(e), _ = mn(e);
2779
- let h;
2780
- return e.messages.map((r) => {
2781
- if (r.intermediate) return /* @__PURE__ */ u("details", { className: "make-ai-assistant__process", children: [
2795
+ }, gn = (e, t, s, n, i, o, d, h, v, I, f, N, C, A, g, F) => {
2796
+ const T = Ua(e), H = Pa(e), b = mn(e);
2797
+ let l;
2798
+ return e.messages.map((c) => {
2799
+ if (c.intermediate) return /* @__PURE__ */ m("details", { className: "make-ai-assistant__process", children: [
2782
2800
  /* @__PURE__ */ a("summary", { children: "处理过程" }),
2783
- /* @__PURE__ */ a(Gt, { content: r.content })
2784
- ] }, r.id);
2785
- const b = r.role === "assistant", M = h;
2786
- b || (h = r);
2787
- const W = r.id === H, N = r.id === L ? e.error : void 0, X = r.error ?? N, Q = !b && !!(y?.trim() || v), ie = b ? l : y?.trim() || "用户", Z = b && r.status === "complete" && !X && (r.content.trim() || r.id === _), ue = !!(k && U?.features?.feedback && b && r.persistent), ve = Z || ue;
2801
+ /* @__PURE__ */ a(Gt, { content: c.content })
2802
+ ] }, c.id);
2803
+ const k = c.role === "assistant", E = l;
2804
+ k || (l = c);
2805
+ const W = c.id === H, M = c.id === T ? e.error : void 0, X = c.error ?? M, me = !k && !!(v?.trim() || I), ee = k ? d : v?.trim() || "用户", he = k && c.status === "complete" && !X && (c.content.trim() || c.id === b), ne = !!(g && F?.features?.feedback && typeof F.setFeedback == "function" && k && c.persistent), Ae = he || ne;
2788
2806
  return /* @__PURE__ */ a(
2789
2807
  "article",
2790
2808
  {
2791
- "aria-label": `${ie}的消息`,
2792
- className: `make-ai-assistant__message make-ai-assistant__message--${r.role}`,
2793
- "data-message-role": r.role,
2809
+ "aria-label": `${ee}的消息`,
2810
+ className: `make-ai-assistant__message make-ai-assistant__message--${c.role}`,
2811
+ "data-message-role": c.role,
2794
2812
  "data-message-state": X ? "error" : void 0,
2795
- "data-message-status": r.status,
2796
- "data-message-has-identity": b || Q ? !0 : void 0,
2797
- children: /* @__PURE__ */ u("div", { className: "make-ai-assistant__message-turn", children: [
2798
- b ? /* @__PURE__ */ a(xa, { assistantName: l }) : Q ? /* @__PURE__ */ a(on, { userAvatarUrl: v, userName: y }) : null,
2799
- /* @__PURE__ */ u("div", { className: "make-ai-assistant__message-stack", children: [
2800
- b && r.responseId && e.responses?.[r.responseId]?.status === "cancelled" ? /* @__PURE__ */ a("p", { className: "make-ai-assistant__response-status", role: "status", children: "已停止生成" }) : null,
2801
- r.content ? b ? /* @__PURE__ */ a(Gt, { content: r.content }) : /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble", children: r.content }) : r.status === "streaming" ? /* @__PURE__ */ u("div", { className: "make-ai-assistant__typing", "aria-label": `${l}正在思考`, children: [
2813
+ "data-message-status": c.status,
2814
+ "data-message-has-identity": k || me ? !0 : void 0,
2815
+ children: /* @__PURE__ */ m("div", { className: "make-ai-assistant__message-turn", children: [
2816
+ k ? /* @__PURE__ */ a(Da, { assistantName: d }) : me ? /* @__PURE__ */ a(on, { userAvatarUrl: I, userName: v }) : null,
2817
+ /* @__PURE__ */ m("div", { className: "make-ai-assistant__message-stack", children: [
2818
+ k && c.responseId && e.responses?.[c.responseId]?.status === "cancelled" ? /* @__PURE__ */ a("p", { className: "make-ai-assistant__response-status", role: "status", children: "已停止生成" }) : null,
2819
+ c.content ? k ? /* @__PURE__ */ a(Gt, { content: c.content }) : /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble", children: c.content }) : c.status === "streaming" ? /* @__PURE__ */ m("div", { className: "make-ai-assistant__typing", "aria-label": `${d}正在思考`, children: [
2802
2820
  /* @__PURE__ */ a("span", {}),
2803
2821
  /* @__PURE__ */ a("span", {}),
2804
2822
  /* @__PURE__ */ a("span", {})
2805
2823
  ] }) : null,
2806
- b ? /* @__PURE__ */ a(
2807
- Fa,
2824
+ k ? /* @__PURE__ */ a(
2825
+ Ha,
2808
2826
  {
2809
2827
  active: W && e.status === "streaming",
2810
- steps: r.progressSteps
2828
+ steps: c.progressSteps
2811
2829
  }
2812
2830
  ) : null,
2813
2831
  X ? /* @__PURE__ */ a(
2814
- Ua,
2832
+ Fa,
2815
2833
  {
2816
2834
  error: X,
2817
- onRetry: N ? m : void 0
2835
+ onRetry: M ? h : void 0
2818
2836
  }
2819
2837
  ) : null,
2820
- r.artifacts.map((Me) => /* @__PURE__ */ a(
2821
- Ga,
2838
+ c.artifacts.map((ce) => /* @__PURE__ */ a(
2839
+ Za,
2822
2840
  {
2823
- artifact: Me,
2841
+ artifact: ce,
2824
2842
  context: t,
2825
2843
  onAction: i,
2826
- onActionError: c,
2844
+ onActionError: o,
2827
2845
  registry: s,
2828
2846
  theme: n
2829
2847
  },
2830
- Me.id
2848
+ ce.id
2831
2849
  )),
2832
- k && U && e.threadId ? /* @__PURE__ */ a(Hs, { message: r, context: t, transport: U, chatId: e.threadId }) : null,
2833
- ve ? /* @__PURE__ */ a(
2850
+ g && F && e.threadId ? /* @__PURE__ */ a(Hs, { message: c, context: t, transport: F, chatId: e.threadId }) : null,
2851
+ Ae ? /* @__PURE__ */ a(
2834
2852
  yn,
2835
2853
  {
2836
- copyFeedback: p?.messageId === r.id ? {
2837
- message: p.message,
2838
- status: p.status
2854
+ copyFeedback: f?.messageId === c.id ? {
2855
+ message: f.message,
2856
+ status: f.status
2839
2857
  } : void 0,
2840
- onCopy: r.content.trim() ? () => C(r.id, r.content) : void 0,
2841
- feedback: k && ue ? /* @__PURE__ */ a(Us, { message: r, manager: k }) : void 0,
2842
- onRegenerate: A && r.id === _ && M ? () => S({
2843
- userMessage: M,
2844
- assistantMessage: r
2858
+ onCopy: c.content.trim() ? () => C(c.id, c.content) : void 0,
2859
+ feedback: g && ne ? /* @__PURE__ */ a(Us, { message: c, manager: g }) : void 0,
2860
+ onRegenerate: N && c.id === b && E ? () => A({
2861
+ userMessage: E,
2862
+ assistantMessage: c
2845
2863
  }) : void 0
2846
2864
  }
2847
2865
  ) : null
2848
2866
  ] })
2849
2867
  ] })
2850
2868
  },
2851
- `${e.threadId ?? "local"}:${r.id}`
2869
+ `${e.threadId ?? "local"}:${c.id}`
2852
2870
  );
2853
2871
  });
2854
2872
  };
2855
- function Ha({
2873
+ function ja({
2856
2874
  assistantName: e = "AI 助手",
2857
2875
  brandName: t,
2858
2876
  context: s,
2859
2877
  onAction: n,
2860
2878
  onActionError: i,
2861
- onClose: c,
2862
- onNewConversation: l,
2863
- onToggleFullscreen: m,
2864
- headerHeight: y,
2865
- isFullscreen: v = !1,
2866
- registry: p,
2867
- suggestions: A,
2879
+ onClose: o,
2880
+ onNewConversation: d,
2881
+ onToggleFullscreen: h,
2882
+ headerHeight: v,
2883
+ isFullscreen: I = !1,
2884
+ registry: f,
2885
+ suggestions: N,
2868
2886
  title: C,
2869
- theme: S,
2870
- transport: k,
2871
- userAvatarUrl: U,
2872
- userName: L,
2887
+ theme: A,
2888
+ transport: g,
2889
+ userAvatarUrl: F,
2890
+ userName: T,
2873
2891
  visible: H
2874
2892
  }) {
2875
- const _ = xs(s, k), h = Vs(s, k, _), r = za(t, C), b = tn(y), M = Mt(S), W = M || b ? {
2876
- ...M,
2877
- ...b ? { "--make-ai-internal-header-height": b } : {}
2878
- } : void 0, [N, X] = $(""), [Q, ie] = $(!1), [Z, ue] = $(!1), ve = _.enabled ? k.scopeKey?.(s) ?? s.app.id : "";
2893
+ const b = xs(s, g), l = Vs(s, g, b), c = xa(t, C), k = tn(v), E = Mt(A), W = E || k ? {
2894
+ ...E,
2895
+ ...k ? { "--make-ai-internal-header-height": k } : {}
2896
+ } : void 0, [M, X] = R(""), [me, ee] = R(!1), [he, ne] = R(!1), Ae = b.enabled ? g.scopeKey?.(s) ?? s.app.id : "";
2879
2897
  At(() => {
2880
- _.enabled && X("");
2881
- }, [ve, _.enabled]);
2882
- const [Me, Be] = $(fe), O = _.enabled ? _.state : Me, V = _.enabled ? _.setState : Be, F = D(O);
2883
- F.current = O;
2884
- const [Y, oe] = $(void 0), [ge, me] = $(void 0), [Te, P] = $(0), [ae, ee] = $(() => k.loadConversation ? "loading" : "ready"), te = _.enabled ? _.loading && !O.messages.length ? "loading" : "ready" : ae, [Ve, Ke] = $(void 0), [at, ce] = $(!1), G = D(void 0), le = D(void 0), Ne = D(0), Ee = D(null), Ae = D(null), ze = D(null), xe = D(null), We = D(null), Xe = D(null), ye = D(!0), st = D(s.app.id), nt = D(H), it = Ka();
2898
+ b.enabled && X("");
2899
+ }, [Ae, b.enabled]);
2900
+ const [ce, ht] = R(ye), U = b.enabled ? b.state : ce, fe = b.enabled ? b.setState : ht, le = P(U);
2901
+ le.current = U;
2902
+ const [Ee, ge] = R(void 0), [De, G] = R(void 0), [K, te] = R(0), [$e, de] = R(() => g.loadConversation ? "loading" : "ready"), oe = b.configurationError ? "error" : b.enabled ? b.loading && !U.messages.length ? "loading" : "ready" : $e, [Se, L] = R(void 0), [ae, Z] = R(!1), Q = P(void 0), ke = P(void 0), Ce = P(0), Ke = P(null), we = P(null), Y = P(null), Me = P(null), We = P(null), Re = P(null), pe = P(!0), Xe = P(s.app.id), Pe = P(H), at = Wa();
2885
2903
  At(() => {
2886
- const f = ze.current;
2887
- f && (f.style.height = "auto", f.style.height = `${Math.min(
2888
- Math.max(f.scrollHeight, Js),
2904
+ const p = Y.current;
2905
+ p && (p.style.height = "auto", p.style.height = `${Math.min(
2906
+ Math.max(p.scrollHeight, Js),
2889
2907
  Ys
2890
2908
  )}px`);
2891
- }, [N]);
2892
- const rt = Ft(
2893
- () => p ?? is(),
2894
- [p]
2895
- ), ot = Ft(
2896
- () => Qs(A),
2897
- [A]
2898
- ), De = (f) => {
2899
- const B = G.current, K = le.current?.iterator;
2900
- return !B && !K ? !1 : (Ne.current += 1, G.current = void 0, le.current = void 0, console.info("[make-ai-assistant] local run cancellation requested", { reason: f }), B?.abort(), Xt(K), !0);
2909
+ }, [M]);
2910
+ const Ge = Ft(
2911
+ () => f ?? rs(),
2912
+ [f]
2913
+ ), st = Ft(
2914
+ () => Qs(N),
2915
+ [N]
2916
+ ), Ue = (p) => {
2917
+ const j = Q.current, q = ke.current?.iterator;
2918
+ return !j && !q ? !1 : (Ce.current += 1, Q.current = void 0, ke.current = void 0, console.info("[make-ai-assistant] local run cancellation requested", { reason: p }), j?.abort(), Xt(q), !0);
2901
2919
  };
2902
- ne(() => () => {
2903
- De("unmount");
2904
- }, []), ne(() => {
2905
- if (_.enabled) return;
2906
- const f = k.loadConversation, B = st.current !== s.app.id;
2907
- if (st.current = s.app.id, De("reinitialize"), B && (X(""), ye.current = !0), oe(void 0), me(void 0), ce(!1), V(fe()), !f) {
2908
- Ke(void 0), ee("ready");
2920
+ se(() => () => {
2921
+ Ue("unmount");
2922
+ }, []), se(() => {
2923
+ if (b.enabled) return;
2924
+ const p = g.loadConversation, j = Xe.current !== s.app.id;
2925
+ if (Xe.current = s.app.id, Ue("reinitialize"), j && (X(""), pe.current = !0), ge(void 0), G(void 0), Z(!1), fe(ye()), !p) {
2926
+ L(void 0), de("ready");
2909
2927
  return;
2910
2928
  }
2911
- const K = new AbortController();
2912
- return Ke(void 0), ee("loading"), console.info("[make-ai-assistant] conversation load start", {
2929
+ const q = new AbortController();
2930
+ return L(void 0), de("loading"), console.info("[make-ai-assistant] conversation load start", {
2913
2931
  appId: s.app.id
2914
- }), f.call(k, s, { signal: K.signal }).then((se) => {
2915
- K.signal.aborted || (V(fe(se)), ee("ready"), console.info("[make-ai-assistant] conversation load success", {
2932
+ }), p.call(g, s, { signal: q.signal }).then((V) => {
2933
+ q.signal.aborted || (fe(ye(V)), de("ready"), console.info("[make-ai-assistant] conversation load success", {
2916
2934
  appId: s.app.id,
2917
- messageCount: se.messages.length
2935
+ messageCount: V.messages.length
2918
2936
  }));
2919
- }).catch((se) => {
2920
- K.signal.aborted || (console.error("[make-ai-assistant] conversation load failed", {
2937
+ }).catch((V) => {
2938
+ q.signal.aborted || (console.error("[make-ai-assistant] conversation load failed", {
2921
2939
  appId: s.app.id,
2922
- errorType: se instanceof Error ? se.name : typeof se
2923
- }), Ke(se), ee("error"));
2924
- }), () => K.abort();
2925
- }, [s.app.id, Te, k, _.enabled]), ne(() => {
2926
- const f = Ae.current;
2927
- if (!f || !ye.current) return;
2928
- ce(!1);
2929
- const B = requestAnimationFrame(() => {
2930
- if (!ye.current) return;
2931
- const K = O.status === "streaming" || globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
2932
- It(f, K);
2940
+ errorType: V instanceof Error ? V.name : typeof V
2941
+ }), L(V), de("error"));
2942
+ }), () => q.abort();
2943
+ }, [s.app.id, K, g, b.enabled]), se(() => {
2944
+ const p = we.current;
2945
+ if (!p || !pe.current) return;
2946
+ Z(!1);
2947
+ const j = requestAnimationFrame(() => {
2948
+ if (!pe.current) return;
2949
+ const q = U.status === "streaming" || globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
2950
+ It(p, q);
2933
2951
  });
2934
- return () => cancelAnimationFrame(B);
2935
- }, [O.messages, O.progress, O.status]), ne(() => {
2936
- H || (ie(!1), ue(!1));
2937
- }, [H]), ne(() => {
2938
- const f = H && !nt.current;
2939
- if (nt.current = H, !f) return;
2940
- const B = requestAnimationFrame(() => {
2941
- const K = Ae.current;
2942
- if (K && ye.current) {
2943
- ce(!1);
2944
- const Ze = F.current.status === "streaming" ? "auto" : Zt();
2945
- It(K, Ze);
2946
- } else K && ce(F.current.messages.length > 0);
2947
- const se = ze.current;
2948
- (se && !se.disabled ? se : Xe.current ?? Ee.current?.querySelector("button:not(:disabled)"))?.focus();
2952
+ return () => cancelAnimationFrame(j);
2953
+ }, [U.messages, U.progress, U.status]), se(() => {
2954
+ H || (ee(!1), ne(!1));
2955
+ }, [H]), se(() => {
2956
+ const p = H && !Pe.current;
2957
+ if (Pe.current = H, !p) return;
2958
+ const j = requestAnimationFrame(() => {
2959
+ const q = we.current;
2960
+ if (q && pe.current) {
2961
+ Z(!1);
2962
+ const be = le.current.status === "streaming" ? "auto" : Zt();
2963
+ It(q, be);
2964
+ } else q && Z(le.current.messages.length > 0);
2965
+ const V = Y.current;
2966
+ (V && !V.disabled ? V : Re.current ?? Ke.current?.querySelector("button:not(:disabled)"))?.focus();
2949
2967
  });
2950
- return () => cancelAnimationFrame(B);
2968
+ return () => cancelAnimationFrame(j);
2951
2969
  }, [H]);
2952
- const Ge = () => {
2953
- const f = Ae.current;
2954
- if (!f) return;
2955
- const B = fn(f);
2956
- ye.current = B, ce(!B && F.current.messages.length > 0);
2957
- }, $e = () => {
2958
- const f = Ae.current;
2959
- if (!f) return;
2960
- ye.current = !0, ce(!1);
2961
- const B = Zt();
2962
- It(f, B);
2963
- }, o = async (f, B) => {
2964
- const K = f.trim(), se = F.current, _e = B?.regenerateFrom, Ze = k.regenerate;
2965
- if (!K || te !== "ready" || se.status === "streaming" || G.current || _e && !Ze) return;
2966
- if (ht(
2967
- K,
2968
- de.messageCharacters
2969
- ) > de.messageCharacters) {
2970
- oe(
2971
- `输入内容过长,请控制在 ${de.messageCharacters} 个字符以内`
2970
+ const ft = () => {
2971
+ const p = we.current;
2972
+ if (!p) return;
2973
+ const j = pn(p);
2974
+ pe.current = j, Z(!j && le.current.messages.length > 0);
2975
+ }, pt = () => {
2976
+ const p = we.current;
2977
+ if (!p) return;
2978
+ pe.current = !0, Z(!1);
2979
+ const j = Zt();
2980
+ It(p, j);
2981
+ }, nt = async (p, j) => {
2982
+ const q = p.trim(), V = le.current, ie = j?.regenerateFrom, be = g.regenerate;
2983
+ if (!q || oe !== "ready" || V.status === "streaming" || Q.current || ie && !be) return;
2984
+ if (lt(
2985
+ q,
2986
+ ue.messageCharacters
2987
+ ) > ue.messageCharacters) {
2988
+ ge(
2989
+ `输入内容过长,请控制在 ${ue.messageCharacters} 个字符以内`
2972
2990
  );
2973
2991
  return;
2974
2992
  }
2975
- const lt = {
2976
- id: _e?.userMessage.id ?? Xs("user"),
2977
- content: K
2978
- }, dt = _e ? pn(se, _e.userMessage.id) : ta(se, lt), ut = new AbortController(), Ue = Ne.current + 1;
2979
- Ne.current = Ue, G.current = ut, oe(void 0), me(void 0), ce(!ye.current && se.messages.length > 0), _e || X(""), V(dt);
2993
+ const it = {
2994
+ id: ie?.userMessage.id ?? Xs("user"),
2995
+ content: q
2996
+ }, rt = ie ? fn(V, ie.userMessage.id) : ta(V, it), ot = new AbortController(), He = Ce.current + 1;
2997
+ Ce.current = He, Q.current = ot, ge(void 0), G(void 0), Z(!pe.current && V.messages.length > 0), ie || X(""), fe(rt);
2980
2998
  try {
2981
- let Ce = !1, re, $t = 0, St = 0, Rt = 0, yt = 0, Je = 0;
2999
+ let Te = !1, re, $t = 0, St = 0, Rt = 0, yt = 0, Je = 0;
2982
3000
  const Ye = /* @__PURE__ */ new Map(), Lt = /* @__PURE__ */ new Set(), zt = /* @__PURE__ */ new Set(
2983
3001
  [
2984
- ...dt.messages.map((mt) => mt.id),
2985
- lt.id
3002
+ ...rt.messages.map((ct) => ct.id),
3003
+ it.id
2986
3004
  ]
2987
- ), Qe = /* @__PURE__ */ new Set(), xt = Xa(rt), Dt = { signal: ut.signal };
2988
- let kt;
2989
- if (_e) {
2990
- if (!Ze)
3005
+ ), Qe = /* @__PURE__ */ new Set(), xt = Ga(Ge), Dt = { signal: ot.signal };
3006
+ let gt;
3007
+ if (ie) {
3008
+ if (!be)
2991
3009
  throw new J("当前 AI 助手不支持重新生成");
2992
- kt = Ze({
2993
- threadId: dt.threadId,
2994
- message: lt,
3010
+ gt = be({
3011
+ threadId: rt.threadId,
3012
+ message: it,
2995
3013
  assistantMessage: {
2996
- id: _e.assistantMessage.id,
2997
- content: _e.assistantMessage.content
3014
+ id: ie.assistantMessage.id,
3015
+ content: ie.assistantMessage.content
2998
3016
  },
2999
3017
  context: s,
3000
3018
  capabilities: xt
3001
3019
  }, Dt);
3002
3020
  } else
3003
- kt = k.run(
3021
+ gt = g.run(
3004
3022
  {
3005
- threadId: dt.threadId,
3006
- message: lt,
3023
+ threadId: rt.threadId,
3024
+ message: it,
3007
3025
  context: s,
3008
3026
  capabilities: xt
3009
3027
  },
3010
3028
  Dt
3011
3029
  );
3012
- const Pt = kt[Symbol.asyncIterator]();
3013
- for (le.current = { iterator: Pt, requestVersion: Ue }; ; ) {
3014
- const mt = await Pt.next();
3015
- if (Ne.current !== Ue || mt.done) break;
3016
- let x;
3030
+ const Pt = gt[Symbol.asyncIterator]();
3031
+ for (ke.current = { iterator: Pt, requestVersion: He }; ; ) {
3032
+ const ct = await Pt.next();
3033
+ if (Ce.current !== He || ct.done) break;
3034
+ let D;
3017
3035
  try {
3018
- x = ea(mt.value);
3019
- } catch (pe) {
3036
+ D = ea(ct.value);
3037
+ } catch (ve) {
3020
3038
  throw new J(
3021
- pe instanceof Error ? pe.message : "Invalid assistant event"
3039
+ ve instanceof Error ? ve.message : "Invalid assistant event"
3022
3040
  );
3023
3041
  }
3024
- if (x.type === "message.start") {
3025
- if (re !== void 0 && re !== x.runId)
3042
+ if (D.type === "message.start") {
3043
+ if (re !== void 0 && re !== D.runId)
3026
3044
  throw new J("AI 助手响应 run id 不一致");
3027
- if (re ??= x.runId, St += 1, St > de.assistantMessagesPerRun)
3045
+ if (re ??= D.runId, St += 1, St > ue.assistantMessagesPerRun)
3028
3046
  throw new J("AI 助手单次响应消息数量超过限制");
3029
- if (zt.has(x.messageId))
3047
+ if (zt.has(D.messageId))
3030
3048
  throw new J("AI 助手响应包含重复的 message id");
3031
- zt.add(x.messageId), Qe.add(x.messageId), Ye.set(x.messageId, 0);
3049
+ zt.add(D.messageId), Qe.add(D.messageId), Ye.set(D.messageId, 0);
3032
3050
  }
3033
- if (x.type === "message.delta") {
3034
- if (!Qe.has(x.messageId))
3051
+ if (D.type === "message.delta") {
3052
+ if (!Qe.has(D.messageId))
3035
3053
  throw new J("AI 助手响应事件顺序无效");
3036
- const pe = Ye.get(x.messageId) ?? 0, Fe = ht(
3037
- x.delta,
3038
- de.messageCharacters - Je
3054
+ const ve = Ye.get(D.messageId) ?? 0, je = lt(
3055
+ D.delta,
3056
+ ue.messageCharacters - Je
3039
3057
  );
3040
- if (Je + Fe > de.messageCharacters)
3058
+ if (Je + je > ue.messageCharacters)
3041
3059
  throw new J("AI 助手响应文本超过大小限制");
3042
- Je += Fe, Ye.set(
3043
- x.messageId,
3044
- pe + Fe
3060
+ Je += je, Ye.set(
3061
+ D.messageId,
3062
+ ve + je
3045
3063
  );
3046
3064
  }
3047
- if (x.type === "message.replace") {
3048
- if (!Qe.has(x.messageId))
3065
+ if (D.type === "message.replace") {
3066
+ if (!Qe.has(D.messageId))
3049
3067
  throw new J("AI 助手响应事件顺序无效");
3050
- const pe = Ye.get(x.messageId) ?? 0, Fe = ht(
3051
- x.content,
3052
- de.messageCharacters
3053
- ), Ut = Je - pe + Fe;
3054
- if (Ut > de.messageCharacters)
3068
+ const ve = Ye.get(D.messageId) ?? 0, je = lt(
3069
+ D.content,
3070
+ ue.messageCharacters
3071
+ ), Ut = Je - ve + je;
3072
+ if (Ut > ue.messageCharacters)
3055
3073
  throw new J("AI 助手响应文本超过大小限制");
3056
- Je = Ut, Ye.set(x.messageId, Fe);
3074
+ Je = Ut, Ye.set(D.messageId, je);
3057
3075
  }
3058
- if (x.type === "run.progress") {
3059
- if (re !== void 0 && re !== x.runId)
3076
+ if (D.type === "run.progress") {
3077
+ if (re !== void 0 && re !== D.runId)
3060
3078
  throw new J("AI 助手响应 run id 不一致");
3061
- if (re ??= x.runId, Rt += 1, Rt > de.progressStepsPerRun)
3079
+ if (re ??= D.runId, Rt += 1, Rt > ue.progressStepsPerRun)
3062
3080
  throw new J("AI 助手处理过程数量超过限制");
3063
- const pe = ht(
3064
- x.message,
3065
- de.progressCharactersPerRun - yt
3081
+ const ve = lt(
3082
+ D.message,
3083
+ ue.progressCharactersPerRun - yt
3066
3084
  );
3067
- if (yt + pe > de.progressCharactersPerRun)
3085
+ if (yt + ve > ue.progressCharactersPerRun)
3068
3086
  throw new J("AI 助手处理过程文本超过大小限制");
3069
- yt += pe;
3087
+ yt += ve;
3070
3088
  }
3071
- if (x.type === "artifact") {
3072
- if (!Qe.has(x.messageId))
3089
+ if (D.type === "artifact") {
3090
+ if (!Qe.has(D.messageId))
3073
3091
  throw new J("AI 助手响应事件顺序无效");
3074
- if ($t += 1, $t > de.artifactsPerRun)
3092
+ if ($t += 1, $t > ue.artifactsPerRun)
3075
3093
  throw new J("AI 助手单次响应 Artifact 数量超过限制");
3076
- if (Lt.has(x.artifact.id))
3094
+ if (Lt.has(D.artifact.id))
3077
3095
  throw new J("AI 助手响应包含重复的 Artifact id");
3078
- Lt.add(x.artifact.id);
3096
+ Lt.add(D.artifact.id);
3079
3097
  }
3080
- if (x.type === "message.complete" && !Qe.delete(x.messageId))
3098
+ if (D.type === "message.complete" && !Qe.delete(D.messageId))
3081
3099
  throw new J("AI 助手响应事件顺序无效");
3082
- if (x.type === "run.complete" && re !== void 0 && re !== x.runId)
3100
+ if (D.type === "run.complete" && re !== void 0 && re !== D.runId)
3083
3101
  throw new J("AI 助手响应 run id 不一致");
3084
- if (x.type === "run.cancelled" && x.runId !== void 0 && re !== void 0 && re !== x.runId)
3102
+ if (D.type === "run.cancelled" && D.runId !== void 0 && re !== void 0 && re !== D.runId)
3085
3103
  throw new J("AI 助手响应 run id 不一致");
3086
- if (V((pe) => we(pe, x)), x.type === "error" || x.type === "run.cancelled" || x.type === "run.complete") {
3087
- Ce = !0;
3104
+ if (fe((ve) => Ie(ve, D)), D.type === "error" || D.type === "run.cancelled" || D.type === "run.complete") {
3105
+ Te = !0;
3088
3106
  break;
3089
3107
  }
3090
3108
  }
3091
- if (!Ce)
3109
+ if (!Te)
3092
3110
  throw new J("AI 助手流式响应在终止事件前结束");
3093
- } catch (Ce) {
3094
- if (Ne.current !== Ue) return;
3095
- if (ut.signal.aborted) {
3096
- V(
3097
- (re) => we(re, { type: "run.cancelled" })
3111
+ } catch (Te) {
3112
+ if (Ce.current !== He) return;
3113
+ if (ot.signal.aborted) {
3114
+ fe(
3115
+ (re) => Ie(re, { type: "run.cancelled" })
3098
3116
  );
3099
3117
  return;
3100
3118
  }
3101
3119
  console.error("[make-ai-assistant] assistant run failed", {
3102
3120
  appId: s.app.id,
3103
- errorType: Ce instanceof Error ? Ce.name : typeof Ce
3104
- }), V(
3105
- (re) => we(re, {
3121
+ errorType: Te instanceof Error ? Te.name : typeof Te
3122
+ }), fe(
3123
+ (re) => Ie(re, {
3106
3124
  type: "error",
3107
3125
  code: "TRANSPORT_ERROR",
3108
- message: Ce instanceof J ? Ce.message : "连接失败,请重试",
3126
+ message: Te instanceof J ? Te.message : "连接失败,请重试",
3109
3127
  retryable: !0
3110
3128
  })
3111
3129
  );
3112
3130
  } finally {
3113
- Ne.current === Ue && G.current === ut && (G.current = void 0), le.current?.requestVersion === Ue && (Xt(le.current.iterator), le.current = void 0);
3131
+ Ce.current === He && Q.current === ot && (Q.current = void 0), ke.current?.requestVersion === He && (Xt(ke.current.iterator), ke.current = void 0);
3114
3132
  }
3115
- }, d = (f) => {
3116
- if (_.enabled) {
3117
- if (h.pending)
3118
- return oe("请等待附件上传完成,或移除失败的附件"), Promise.resolve();
3119
- const B = f.trim(), K = h.parts.length ? [...B ? [{ id: Oe(), kind: "text", text: B }] : [], ...h.parts] : void 0;
3120
- return X(""), h.clear(), _.send(B, K);
3133
+ }, Fe = (p) => {
3134
+ if (oe !== "ready") return Promise.resolve();
3135
+ if (b.enabled) {
3136
+ if (l.pending)
3137
+ return ge("请等待附件上传完成,或移除失败的附件"), Promise.resolve();
3138
+ const j = p.trim(), q = l.parts.length ? [...j ? [{ id: qe(), kind: "text", text: j }] : [], ...l.parts] : void 0;
3139
+ return X(""), l.clear(), b.send(j, q);
3121
3140
  }
3122
- return o(f);
3123
- }, g = (f) => o(f.userMessage.content, { regenerateFrom: f }), w = async (f, B) => {
3141
+ return nt(p);
3142
+ }, vt = (p) => nt(p.userMessage.content, { regenerateFrom: p }), Ze = async (p, j) => {
3124
3143
  try {
3125
- await nn(B), me({ messageId: f, message: "已复制", status: "success" });
3126
- } catch (K) {
3144
+ await nn(j), G({ messageId: p, message: "已复制", status: "success" });
3145
+ } catch (q) {
3127
3146
  console.error("[make-ai-assistant] copy answer failed", {
3128
- errorType: K instanceof Error ? K.name : typeof K
3129
- }), me({ messageId: f, message: "复制失败", status: "error" });
3147
+ errorType: q instanceof Error ? q.name : typeof q
3148
+ }), G({ messageId: p, message: "复制失败", status: "error" });
3130
3149
  }
3131
- }, T = (f) => {
3132
- f.preventDefault(), d(N);
3133
- }, z = (f) => {
3134
- f.key === "Enter" && !f.shiftKey && !f.nativeEvent.isComposing && (f.preventDefault(), d(N));
3135
- }, I = () => {
3136
- if (_.enabled) {
3137
- _.stop();
3150
+ }, Le = (p) => {
3151
+ p.preventDefault(), Fe(M);
3152
+ }, r = (p) => {
3153
+ p.key === "Enter" && !p.shiftKey && !p.nativeEvent.isComposing && (p.preventDefault(), Fe(M));
3154
+ }, u = () => {
3155
+ if (b.enabled) {
3156
+ b.stop();
3138
3157
  return;
3139
3158
  }
3140
- De("stop") && V(
3141
- (f) => we(f, { type: "run.cancelled" })
3159
+ Ue("stop") && fe(
3160
+ (p) => Ie(p, { type: "run.cancelled" })
3142
3161
  );
3143
- }, R = () => {
3144
- if (ue(!1), _.enabled) {
3145
- X(""), _.create(), l?.();
3146
- return;
3162
+ }, y = () => {
3163
+ if (!b.configurationError) {
3164
+ if (ne(!1), b.enabled) {
3165
+ X(""), b.create(), d?.();
3166
+ return;
3167
+ }
3168
+ Ue("new-conversation"), X(""), ge(void 0), G(void 0), Z(!1), pe.current = !0, fe(ye()), d?.();
3147
3169
  }
3148
- De("new-conversation"), X(""), oe(void 0), me(void 0), ce(!1), ye.current = !0, V(fe()), l?.();
3149
- }, E = _.enabled && _.cancelling.length ? "停止中" : k.features?.remoteCancellation === !1 ? "停止接收" : "停止生成", q = Da(O), be = Pa(O), Se = hn(O), ct = typeof k.regenerate == "function" && k.features?.regeneration !== !1, he = () => {
3150
- if (_.enabled) {
3151
- _.retry();
3170
+ }, w = b.enabled && b.cancelling.length ? "停止中" : g.features?.remoteCancellation === !1 ? "停止接收" : "停止生成", $ = Pa(U), z = Ua(U), _ = hn(U), x = typeof g.regenerate == "function" && g.features?.regeneration !== !1, S = () => {
3171
+ if (b.enabled) {
3172
+ b.retry();
3152
3173
  return;
3153
3174
  }
3154
- Se && d(Se.content);
3155
- }, Pe = (f) => {
3156
- if (f.key === "Escape" && !(!Q && !Z)) {
3157
- if (f.preventDefault(), f.stopPropagation(), Q) {
3158
- ie(!1), xe.current?.focus();
3175
+ _ && Fe(_.content);
3176
+ }, O = (p) => {
3177
+ if (p.key === "Escape" && !(!me && !he)) {
3178
+ if (p.preventDefault(), p.stopPropagation(), me) {
3179
+ ee(!1), Me.current?.focus();
3159
3180
  return;
3160
3181
  }
3161
- ue(!1), We.current?.focus();
3182
+ ne(!1), We.current?.focus();
3162
3183
  }
3163
3184
  };
3164
- return /* @__PURE__ */ u(
3185
+ return /* @__PURE__ */ m(
3165
3186
  "section",
3166
3187
  {
3167
- className: `make-ai-assistant make-ai-assistant__panel${_.enabled ? " make-ai-assistant__panel--managed" : ""}`,
3168
- ref: Ee,
3188
+ className: `make-ai-assistant make-ai-assistant__panel${b.enabled ? " make-ai-assistant__panel--managed" : ""}`,
3189
+ ref: Ke,
3169
3190
  style: W,
3170
- onKeyDown: Pe,
3171
- onDragOver: (f) => {
3172
- h.enabled && f.dataTransfer.types.includes("Files") && f.preventDefault();
3191
+ onKeyDown: O,
3192
+ onDragOver: (p) => {
3193
+ l.enabled && p.dataTransfer.types.includes("Files") && p.preventDefault();
3173
3194
  },
3174
- onDrop: (f) => {
3175
- h.enabled && f.dataTransfer.files.length && (f.preventDefault(), h.add(Array.from(f.dataTransfer.files)));
3195
+ onDrop: (p) => {
3196
+ l.enabled && p.dataTransfer.files.length && (p.preventDefault(), l.add(Array.from(p.dataTransfer.files)));
3176
3197
  },
3177
3198
  children: [
3178
- /* @__PURE__ */ u("header", { className: "make-ai-assistant__header", children: [
3179
- /* @__PURE__ */ a("div", { className: "make-ai-assistant__header-leading", children: _.enabled ? /* @__PURE__ */ u(
3199
+ /* @__PURE__ */ m("header", { className: "make-ai-assistant__header", children: [
3200
+ /* @__PURE__ */ a("div", { className: "make-ai-assistant__header-leading", children: b.available ? /* @__PURE__ */ m(
3180
3201
  "button",
3181
3202
  {
3182
- "aria-controls": it,
3183
- "aria-expanded": Z,
3203
+ "aria-controls": at,
3204
+ "aria-expanded": he,
3184
3205
  "aria-haspopup": "dialog",
3185
3206
  "aria-label": "任务列表",
3186
3207
  className: "make-ai-assistant__task-list-trigger",
3187
3208
  ref: We,
3188
3209
  type: "button",
3189
- onClick: () => ue((f) => !f),
3210
+ onClick: () => ne((p) => !p),
3190
3211
  children: [
3191
3212
  /* @__PURE__ */ a(
3192
3213
  Is,
3193
3214
  {
3194
3215
  "aria-hidden": "true",
3195
- className: "make-ai-assistant__task-list-icon"
3216
+ className: "make-ai-assistant__task-list-icon",
3217
+ size: 14
3196
3218
  }
3197
3219
  ),
3198
3220
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__task-list-label", children: "任务列表" }),
3199
- Z ? /* @__PURE__ */ a(
3200
- gs,
3221
+ he ? /* @__PURE__ */ a(
3222
+ bs,
3201
3223
  {
3202
3224
  "aria-hidden": "true",
3203
- className: "make-ai-assistant__task-list-disclosure"
3225
+ className: "make-ai-assistant__task-list-disclosure",
3226
+ size: 14
3204
3227
  }
3205
3228
  ) : /* @__PURE__ */ a(
3206
3229
  ks,
3207
3230
  {
3208
3231
  "aria-hidden": "true",
3209
- className: "make-ai-assistant__task-list-disclosure"
3232
+ className: "make-ai-assistant__task-list-disclosure",
3233
+ size: 14
3210
3234
  }
3211
3235
  )
3212
3236
  ]
3213
3237
  }
3214
3238
  ) : null }),
3215
- /* @__PURE__ */ u("div", { className: "make-ai-assistant__header-center", children: [
3216
- /* @__PURE__ */ a(ft, {}),
3217
- /* @__PURE__ */ a("h2", { className: "make-ai-assistant__header-title", title: r, children: r })
3239
+ /* @__PURE__ */ m("div", { className: "make-ai-assistant__header-center", children: [
3240
+ /* @__PURE__ */ a(ut, {}),
3241
+ /* @__PURE__ */ a("h2", { className: "make-ai-assistant__header-title", title: c, children: c })
3218
3242
  ] }),
3219
- /* @__PURE__ */ u("div", { className: "make-ai-assistant__header-actions", children: [
3220
- m ? /* @__PURE__ */ a(
3243
+ /* @__PURE__ */ m("div", { className: "make-ai-assistant__header-actions", children: [
3244
+ h ? /* @__PURE__ */ a(
3221
3245
  "button",
3222
3246
  {
3223
- "aria-label": v ? "退出全屏" : "全屏显示",
3224
- "aria-pressed": v,
3247
+ "aria-label": I ? "退出全屏" : "全屏显示",
3248
+ "aria-pressed": I,
3225
3249
  className: "make-ai-assistant__icon-button",
3226
- title: v ? "退出全屏" : "全屏显示",
3250
+ title: I ? "退出全屏" : "全屏显示",
3227
3251
  type: "button",
3228
- onClick: m,
3229
- children: v ? /* @__PURE__ */ a(
3252
+ onClick: h,
3253
+ children: I ? /* @__PURE__ */ a(
3230
3254
  Cs,
3231
3255
  {
3232
3256
  "aria-hidden": "true",
@@ -3241,13 +3265,13 @@ function Ha({
3241
3265
  )
3242
3266
  }
3243
3267
  ) : null,
3244
- k.features?.newConversation !== !1 ? /* @__PURE__ */ a(
3268
+ g.features?.newConversation !== !1 && !b.configurationError ? /* @__PURE__ */ a(
3245
3269
  "button",
3246
3270
  {
3247
3271
  "aria-label": "新建对话",
3248
3272
  className: "make-ai-assistant__icon-button",
3249
3273
  type: "button",
3250
- onClick: R,
3274
+ onClick: y,
3251
3275
  children: /* @__PURE__ */ a(
3252
3276
  Tt,
3253
3277
  {
@@ -3257,158 +3281,162 @@ function Ha({
3257
3281
  )
3258
3282
  }
3259
3283
  ) : null,
3260
- c ? /* @__PURE__ */ a(
3284
+ o ? /* @__PURE__ */ a(
3261
3285
  "button",
3262
3286
  {
3263
- "aria-label": `关闭 ${r}`,
3287
+ "aria-label": `关闭 ${c}`,
3264
3288
  className: "make-ai-assistant__icon-button",
3265
3289
  type: "button",
3266
- onClick: c,
3290
+ onClick: o,
3267
3291
  children: /* @__PURE__ */ a(tt, { "aria-hidden": "true", className: "make-ai-assistant__icon-button-icon" })
3268
3292
  }
3269
3293
  ) : null
3270
3294
  ] })
3271
3295
  ] }),
3272
- _.enabled && Z ? /* @__PURE__ */ a(
3296
+ b.available && he ? /* @__PURE__ */ a(
3273
3297
  Ps,
3274
3298
  {
3275
- id: it,
3276
- manager: _,
3299
+ id: at,
3300
+ manager: b,
3277
3301
  triggerRef: We,
3278
- onDismiss: () => ue(!1),
3279
- onNewConversation: k.features?.newConversation !== !1 ? R : void 0
3302
+ onDismiss: () => ne(!1),
3303
+ onNewConversation: g.features?.newConversation !== !1 ? y : void 0
3280
3304
  }
3281
3305
  ) : null,
3282
- /* @__PURE__ */ u(
3306
+ /* @__PURE__ */ m(
3283
3307
  "div",
3284
3308
  {
3285
3309
  className: "make-ai-assistant__body",
3286
3310
  "aria-live": "polite",
3287
3311
  "aria-relevant": "additions text",
3288
- ref: Ae,
3312
+ ref: we,
3289
3313
  role: "log",
3290
- onScroll: Ge,
3314
+ onScroll: ft,
3291
3315
  children: [
3292
- te === "loading" ? /* @__PURE__ */ u("div", { className: "make-ai-assistant__empty", role: "status", children: [
3293
- /* @__PURE__ */ a(ft, {}),
3316
+ b.configurationError ? /* @__PURE__ */ m("div", { className: "make-ai-assistant__empty", role: "alert", children: [
3317
+ /* @__PURE__ */ a(ua, { "aria-hidden": "true" }),
3318
+ /* @__PURE__ */ a("h3", { children: "会话管理不可用" }),
3319
+ /* @__PURE__ */ a("p", { children: b.configurationError })
3320
+ ] }) : oe === "loading" ? /* @__PURE__ */ m("div", { className: "make-ai-assistant__empty", role: "status", children: [
3321
+ /* @__PURE__ */ a(ut, {}),
3294
3322
  /* @__PURE__ */ a("h3", { children: "正在恢复对话" }),
3295
3323
  /* @__PURE__ */ a("p", { children: "正在读取当前 App 的历史消息…" })
3296
- ] }) : te === "error" ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__empty", children: /* @__PURE__ */ a(
3324
+ ] }) : oe === "error" ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__empty", children: /* @__PURE__ */ a(
3297
3325
  vn,
3298
3326
  {
3299
- error: Ve,
3300
- onRetry: () => P((f) => f + 1)
3327
+ error: Se,
3328
+ onRetry: () => te((p) => p + 1)
3301
3329
  }
3302
- ) }) : O.messages.length === 0 ? /* @__PURE__ */ u("div", { className: "make-ai-assistant__empty", children: [
3303
- /* @__PURE__ */ a(ft, {}),
3330
+ ) }) : U.messages.length === 0 ? /* @__PURE__ */ m("div", { className: "make-ai-assistant__empty", children: [
3331
+ /* @__PURE__ */ a(ut, {}),
3304
3332
  /* @__PURE__ */ a("h3", { children: "有什么可以帮你?" }),
3305
3333
  /* @__PURE__ */ a("p", { children: "我会结合当前 App、页面位置和宿主允许的上下文回答,并把过程与结果分开展示。" })
3306
- ] }) : kn(
3307
- O,
3334
+ ] }) : gn(
3335
+ U,
3308
3336
  s,
3309
- rt,
3310
- S,
3337
+ Ge,
3338
+ A,
3311
3339
  n,
3312
3340
  i,
3313
3341
  e,
3314
- Se ? he : void 0,
3315
- L,
3316
- U,
3317
- ge,
3318
- ct,
3319
- (f, B) => {
3320
- w(f, B);
3342
+ _ ? S : void 0,
3343
+ T,
3344
+ F,
3345
+ De,
3346
+ x,
3347
+ (p, j) => {
3348
+ Ze(p, j);
3321
3349
  },
3322
- (f) => {
3323
- g(f);
3350
+ (p) => {
3351
+ vt(p);
3324
3352
  },
3325
- _.enabled ? _ : void 0,
3326
- k
3353
+ b.enabled ? b : void 0,
3354
+ g
3327
3355
  ),
3328
- O.progress && !q ? /* @__PURE__ */ a(
3356
+ U.progress && !$ ? /* @__PURE__ */ a(
3329
3357
  Jt,
3330
3358
  {
3331
3359
  assistantName: e,
3332
- progress: O.progress
3360
+ progress: U.progress
3333
3361
  }
3334
3362
  ) : null,
3335
- O.error && !be ? /* @__PURE__ */ a(
3363
+ U.error && !z ? /* @__PURE__ */ a(
3336
3364
  Jt,
3337
3365
  {
3338
3366
  assistantName: e,
3339
- error: O.error,
3340
- onRetry: Se ? he : void 0
3367
+ error: U.error,
3368
+ onRetry: _ ? S : void 0
3341
3369
  }
3342
3370
  ) : null
3343
3371
  ]
3344
3372
  }
3345
3373
  ),
3346
- at ? /* @__PURE__ */ a(
3374
+ ae ? /* @__PURE__ */ a(
3347
3375
  "button",
3348
3376
  {
3349
3377
  "aria-label": "回到最新消息",
3350
3378
  className: "make-ai-assistant__back-to-latest",
3351
3379
  type: "button",
3352
- onClick: $e,
3353
- children: /* @__PURE__ */ a(vs, { "aria-hidden": "true" })
3380
+ onClick: pt,
3381
+ children: /* @__PURE__ */ a(ys, { "aria-hidden": "true" })
3354
3382
  }
3355
3383
  ) : null,
3356
- /* @__PURE__ */ u("footer", { className: "make-ai-assistant__composer-region", children: [
3357
- te === "ready" && ot.length > 0 && O.messages.length === 0 ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__suggestions", "aria-label": "推荐问题", children: ot.map((f, B) => /* @__PURE__ */ a(
3384
+ /* @__PURE__ */ m("footer", { className: "make-ai-assistant__composer-region", children: [
3385
+ oe === "ready" && st.length > 0 && U.messages.length === 0 ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__suggestions", "aria-label": "推荐问题", children: st.map((p, j) => /* @__PURE__ */ a(
3358
3386
  "button",
3359
3387
  {
3360
3388
  type: "button",
3361
3389
  onClick: () => {
3362
- d(f);
3390
+ Fe(p);
3363
3391
  },
3364
- children: f
3392
+ children: p
3365
3393
  },
3366
- `${B}-${f}`
3394
+ `${j}-${p}`
3367
3395
  )) }) : null,
3368
- /* @__PURE__ */ u("form", { className: "make-ai-assistant__composer", onSubmit: T, children: [
3369
- h.enabled ? /* @__PURE__ */ a(Ws, { attachments: h, visible: H }) : null,
3396
+ /* @__PURE__ */ m("form", { className: "make-ai-assistant__composer", onSubmit: Le, children: [
3397
+ l.enabled ? /* @__PURE__ */ a(Ws, { attachments: l, visible: H }) : null,
3370
3398
  /* @__PURE__ */ a(
3371
3399
  "textarea",
3372
3400
  {
3373
3401
  "aria-label": `向 ${e} 提问`,
3374
- "aria-describedby": Y ? "make-ai-composer-error" : void 0,
3375
- "aria-invalid": Y ? !0 : void 0,
3402
+ "aria-describedby": Ee ? "make-ai-composer-error" : void 0,
3403
+ "aria-invalid": Ee ? !0 : void 0,
3376
3404
  autoFocus: !0,
3377
- disabled: te !== "ready" || !_.enabled && O.status === "streaming",
3405
+ disabled: oe !== "ready" || !b.enabled && U.status === "streaming",
3378
3406
  placeholder: `询问当前 ${s.app.name ?? "App"} 中的数据…`,
3379
- ref: ze,
3407
+ ref: Y,
3380
3408
  rows: 2,
3381
- value: N,
3382
- onChange: (f) => {
3383
- X(f.currentTarget.value), oe(void 0);
3409
+ value: M,
3410
+ onChange: (p) => {
3411
+ X(p.currentTarget.value), ge(void 0);
3384
3412
  },
3385
- onKeyDown: z,
3386
- onPaste: (f) => {
3387
- !h.enabled || !f.clipboardData.files.length || (f.preventDefault(), h.add(Array.from(f.clipboardData.files)));
3413
+ onKeyDown: r,
3414
+ onPaste: (p) => {
3415
+ !l.enabled || !p.clipboardData.files.length || (p.preventDefault(), l.add(Array.from(p.clipboardData.files)));
3388
3416
  }
3389
3417
  }
3390
3418
  ),
3391
- /* @__PURE__ */ u("div", { className: "make-ai-assistant__composer-toolbar", children: [
3392
- h.enabled ? /* @__PURE__ */ a(
3419
+ /* @__PURE__ */ m("div", { className: "make-ai-assistant__composer-toolbar", children: [
3420
+ l.enabled ? /* @__PURE__ */ a(
3393
3421
  Ks,
3394
3422
  {
3395
- attachments: h,
3396
- open: Q,
3397
- triggerRef: xe,
3398
- onOpenChange: ie
3423
+ attachments: l,
3424
+ open: me,
3425
+ triggerRef: Me,
3426
+ onOpenChange: ee
3399
3427
  }
3400
3428
  ) : null,
3401
- /* @__PURE__ */ u("div", { className: "make-ai-assistant__composer-actions", children: [
3402
- O.status === "streaming" ? /* @__PURE__ */ a(
3429
+ /* @__PURE__ */ m("div", { className: "make-ai-assistant__composer-actions", children: [
3430
+ U.status === "streaming" ? /* @__PURE__ */ a(
3403
3431
  "button",
3404
3432
  {
3405
- "aria-label": E,
3433
+ "aria-label": w,
3406
3434
  className: "make-ai-assistant__send make-ai-assistant__send--stop",
3407
- "data-tooltip": E,
3408
- ref: Xe,
3409
- disabled: _.enabled && _.cancelling.includes(O.activeRunId ?? ""),
3435
+ "data-tooltip": w,
3436
+ ref: Re,
3437
+ disabled: b.enabled && b.cancelling.includes(U.activeRunId ?? ""),
3410
3438
  type: "button",
3411
- onClick: I,
3439
+ onClick: u,
3412
3440
  children: /* @__PURE__ */ a("span", { "aria-hidden": "true" })
3413
3441
  }
3414
3442
  ) : /* @__PURE__ */ a(
@@ -3416,25 +3444,25 @@ function Ha({
3416
3444
  {
3417
3445
  "aria-label": "发送",
3418
3446
  className: "make-ai-assistant__send",
3419
- disabled: te !== "ready" || h.pending || !N.trim() && !h.parts.length,
3447
+ disabled: oe !== "ready" || l.pending || !M.trim() && !l.parts.length,
3420
3448
  type: "submit",
3421
- children: /* @__PURE__ */ a(qt, { "aria-hidden": "true" })
3449
+ children: /* @__PURE__ */ a(Ot, { "aria-hidden": "true" })
3422
3450
  }
3423
3451
  ),
3424
- _.enabled && O.status === "streaming" ? /* @__PURE__ */ a(
3452
+ b.enabled && U.status === "streaming" ? /* @__PURE__ */ a(
3425
3453
  "button",
3426
3454
  {
3427
3455
  "aria-label": "发送",
3428
3456
  className: "make-ai-assistant__send",
3429
- disabled: _.busy || h.pending || !N.trim() && !h.parts.length,
3457
+ disabled: b.busy || l.pending || !M.trim() && !l.parts.length,
3430
3458
  type: "submit",
3431
- children: /* @__PURE__ */ a(qt, { "aria-hidden": "true" })
3459
+ children: /* @__PURE__ */ a(Ot, { "aria-hidden": "true" })
3432
3460
  }
3433
3461
  ) : null
3434
3462
  ] })
3435
3463
  ] })
3436
3464
  ] }),
3437
- Y ? /* @__PURE__ */ a("p", { id: "make-ai-composer-error", role: "alert", children: Y }) : null,
3465
+ Ee ? /* @__PURE__ */ a("p", { id: "make-ai-composer-error", role: "alert", children: Ee }) : null,
3438
3466
  /* @__PURE__ */ a("p", { children: "AI 生成的结果可能存在偏差,重要数据请核对明细。" })
3439
3467
  ] })
3440
3468
  ]
@@ -3442,7 +3470,7 @@ function Ha({
3442
3470
  );
3443
3471
  }
3444
3472
  function An(e) {
3445
- return /* @__PURE__ */ a(Ha, { ...e, visible: !0 });
3473
+ return /* @__PURE__ */ a(ja, { ...e, visible: !0 });
3446
3474
  }
3447
3475
  function Cn({
3448
3476
  defaultOpen: e = !1,
@@ -3450,69 +3478,69 @@ function Cn({
3450
3478
  launcher: s,
3451
3479
  launcherPosition: n = "bottom-right",
3452
3480
  maxDrawerWidth: i,
3453
- onOpenChange: c,
3454
- open: l,
3455
- ...m
3481
+ onOpenChange: o,
3482
+ open: d,
3483
+ ...h
3456
3484
  }) {
3457
- const y = za(m.brandName, m.title), [v, p] = $(e), [A, C] = $(
3458
- () => e || l === !0
3459
- ), [S, k] = $(!1), U = D(null), L = l ?? v, H = Mt(m.theme), _ = en(i), h = _ === void 0 ? void 0 : { "--make-ai-internal-drawer-max-width": `${_}px` }, r = (M) => {
3460
- l === void 0 && p(M), c?.(M), M || (k(!1), requestAnimationFrame(() => U.current?.focus()));
3461
- }, b = () => r(!L);
3462
- return ne(() => {
3463
- L && C(!0);
3464
- }, [L]), ne(() => {
3465
- if (!L) return;
3466
- const M = (W) => {
3485
+ const v = xa(h.brandName, h.title), [I, f] = R(e), [N, C] = R(
3486
+ () => e || d === !0
3487
+ ), [A, g] = R(!1), F = P(null), T = d ?? I, H = Mt(h.theme), b = en(i), l = b === void 0 ? void 0 : { "--make-ai-internal-drawer-max-width": `${b}px` }, c = (E) => {
3488
+ d === void 0 && f(E), o?.(E), E || (g(!1), requestAnimationFrame(() => F.current?.focus()));
3489
+ }, k = () => c(!T);
3490
+ return se(() => {
3491
+ T && C(!0);
3492
+ }, [T]), se(() => {
3493
+ if (!T) return;
3494
+ const E = (W) => {
3467
3495
  if (W.key === "Escape") {
3468
- if (S) {
3469
- k(!1);
3496
+ if (A) {
3497
+ g(!1);
3470
3498
  return;
3471
3499
  }
3472
- r(!1), requestAnimationFrame(() => U.current?.focus());
3500
+ c(!1), requestAnimationFrame(() => F.current?.focus());
3473
3501
  }
3474
3502
  };
3475
- return document.addEventListener("keydown", M), () => document.removeEventListener("keydown", M);
3476
- }, [S, c, L]), /* @__PURE__ */ u(
3503
+ return document.addEventListener("keydown", E), () => document.removeEventListener("keydown", E);
3504
+ }, [A, o, T]), /* @__PURE__ */ m(
3477
3505
  "div",
3478
3506
  {
3479
3507
  className: "make-ai-assistant",
3480
- "data-open": L || void 0,
3508
+ "data-open": T || void 0,
3481
3509
  style: H,
3482
3510
  children: [
3483
- !t && (!L || s) ? s ? s({ open: L, toggle: b }) : /* @__PURE__ */ u(
3511
+ !t && (!T || s) ? s ? s({ open: T, toggle: k }) : /* @__PURE__ */ m(
3484
3512
  "button",
3485
3513
  {
3486
- "aria-label": L ? `关闭 ${y}` : `打开 ${y}`,
3487
- "aria-expanded": L,
3514
+ "aria-label": T ? `关闭 ${v}` : `打开 ${v}`,
3515
+ "aria-expanded": T,
3488
3516
  className: "make-ai-assistant__launcher",
3489
3517
  "data-launcher-position": n,
3490
- ref: U,
3518
+ ref: F,
3491
3519
  type: "button",
3492
- onClick: b,
3520
+ onClick: k,
3493
3521
  children: [
3494
3522
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__launcher-orbit", "aria-hidden": "true" }),
3495
- /* @__PURE__ */ a(Ca, { "aria-hidden": "true" })
3523
+ /* @__PURE__ */ a(Ma, { "aria-hidden": "true" })
3496
3524
  ]
3497
3525
  }
3498
3526
  ) : null,
3499
- A ? /* @__PURE__ */ a(
3527
+ N ? /* @__PURE__ */ a(
3500
3528
  "aside",
3501
3529
  {
3502
- "aria-label": y,
3530
+ "aria-label": v,
3503
3531
  "aria-modal": "false",
3504
- className: `make-ai-assistant__drawer${S ? " make-ai-assistant__drawer--fullscreen" : ""}`,
3505
- hidden: !L,
3532
+ className: `make-ai-assistant__drawer${A ? " make-ai-assistant__drawer--fullscreen" : ""}`,
3533
+ hidden: !T,
3506
3534
  role: "dialog",
3507
- style: h,
3535
+ style: l,
3508
3536
  children: /* @__PURE__ */ a(
3509
- Ha,
3537
+ ja,
3510
3538
  {
3511
- ...m,
3512
- isFullscreen: S,
3513
- onClose: () => r(!1),
3514
- onToggleFullscreen: () => k((M) => !M),
3515
- visible: L
3539
+ ...h,
3540
+ isFullscreen: A,
3541
+ onClose: () => c(!1),
3542
+ onToggleFullscreen: () => g((E) => !E),
3543
+ visible: T
3516
3544
  }
3517
3545
  )
3518
3546
  }
@@ -3522,24 +3550,24 @@ function Cn({
3522
3550
  );
3523
3551
  }
3524
3552
  export {
3525
- Ga as ArtifactRenderer,
3553
+ Za as ArtifactRenderer,
3526
3554
  An as AssistantPanel,
3527
3555
  Sn as MAKE_AI_ARTIFACT_KINDS,
3528
3556
  Rn as MAKE_AI_ARTIFACT_LIMITS,
3529
3557
  Ln as MAKE_AI_ARTIFACT_SCHEMA_VERSION,
3530
- de as MAKE_AI_CONVERSATION_LIMITS,
3558
+ ue as MAKE_AI_CONVERSATION_LIMITS,
3531
3559
  Cn as MakeAiAssistant,
3532
3560
  ta as appendUserMessage,
3533
- Xa as createArtifactCapabilities,
3561
+ Ga as createArtifactCapabilities,
3534
3562
  Qt as createArtifactTemplateRegistry,
3535
- fe as createAssistantConversationState,
3536
- is as createPlatformArtifactRegistry,
3563
+ ye as createAssistantConversationState,
3564
+ rs as createPlatformArtifactRegistry,
3537
3565
  En as extendArtifactTemplateRegistry,
3538
- Le as formatArtifactValue,
3566
+ xe as formatArtifactValue,
3539
3567
  zn as parseArtifact,
3540
3568
  ea as parseAssistantEvent,
3541
- ns as platformArtifactTemplates,
3542
- we as reduceAssistantEvent,
3543
- Wa as resolveArtifactTemplate,
3569
+ is as platformArtifactTemplates,
3570
+ Ie as reduceAssistantEvent,
3571
+ Xa as resolveArtifactTemplate,
3544
3572
  xn as validateArtifact
3545
3573
  };