@qfei-design/make-ai-assistant 0.2.11 → 0.2.13

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,121 +1,122 @@
1
- import { jsxs as c, jsx as a, Fragment as Ae } from "react/jsx-runtime";
2
- import { isValidElement as ba, cloneElement as ka, useRef as C, useState as N, useEffect as ae, useLayoutEffect as bt, useId as Dt, useMemo as Pt } from "react";
3
- import { resolveArtifactTemplate as _a, createArtifactTemplateRegistry as Vt, createArtifactCapabilities as wa } from "./index.mjs";
4
- import { extendArtifactTemplateRegistry as Fn } from "./index.mjs";
5
- import { n as he, k as ft, r as Ie, l as jt, o as Xt, c as dt, M as le } from "./conversation-CZfbgCXd.js";
6
- import { q as zn, s as Hn, t as On, u as Wn, v as Un } from "./conversation-CZfbgCXd.js";
7
- const Yt = (e) => e?.trim() || void 0, ye = (e, t) => Yt(e) ?? t, kt = (e) => {
8
- const t = Yt(e?.primary);
1
+ import { jsxs as l, jsx as a, Fragment as Ne } from "react/jsx-runtime";
2
+ import { isValidElement as na, cloneElement as ra, useRef as S, useState as N, useEffect as ie, useLayoutEffect as gt, useId as ia, useMemo as Rt } from "react";
3
+ import { resolveArtifactTemplate as oa, createArtifactTemplateRegistry as Wt, createArtifactCapabilities as ca } from "./index.mjs";
4
+ import { extendArtifactTemplateRegistry as Cs } from "./index.mjs";
5
+ import { n as fe, k as ht, r as Me, l as Ot, o as Ht, c as it, M as ue } from "./conversation-CZfbgCXd.js";
6
+ import { q as Rs, s as Es, t as Ss, u as Ls, v as $s } from "./conversation-CZfbgCXd.js";
7
+ import { createPortal as la } from "react-dom";
8
+ const qt = (e) => e?.trim() || void 0, _e = (e, t) => qt(e) ?? t, yt = (e) => {
9
+ const t = qt(e?.primary);
9
10
  if (t)
10
11
  return {
11
12
  "--make-ai-theme-primary": t,
12
- "--make-ai-theme-primary-hover": ye(
13
+ "--make-ai-theme-primary-hover": _e(
13
14
  e?.primaryHover,
14
15
  "color-mix(in srgb, var(--make-ai-theme-primary) 84%, #15233d)"
15
16
  ),
16
- "--make-ai-theme-on-primary": ye(
17
+ "--make-ai-theme-on-primary": _e(
17
18
  e?.onPrimary,
18
19
  "#fcfcff"
19
20
  ),
20
- "--make-ai-theme-bg": ye(
21
+ "--make-ai-theme-bg": _e(
21
22
  e?.background,
22
23
  "color-mix(in srgb, var(--make-ai-theme-primary) 2%, #fcfcff)"
23
24
  ),
24
- "--make-ai-theme-surface": ye(
25
+ "--make-ai-theme-surface": _e(
25
26
  e?.surface,
26
27
  "color-mix(in srgb, var(--make-ai-theme-primary) 4%, var(--make-ai-theme-bg))"
27
28
  ),
28
- "--make-ai-theme-surface-strong": ye(
29
+ "--make-ai-theme-surface-strong": _e(
29
30
  e?.surfaceStrong,
30
31
  "color-mix(in srgb, var(--make-ai-theme-primary) 8%, var(--make-ai-theme-bg))"
31
32
  ),
32
- "--make-ai-theme-text": ye(
33
+ "--make-ai-theme-text": _e(
33
34
  e?.text,
34
35
  "color-mix(in srgb, var(--make-ai-theme-primary) 12%, #252631)"
35
36
  ),
36
- "--make-ai-theme-text-secondary": ye(
37
+ "--make-ai-theme-text-secondary": _e(
37
38
  e?.textSecondary,
38
39
  "color-mix(in srgb, var(--make-ai-theme-text) 74%, var(--make-ai-theme-primary))"
39
40
  ),
40
- "--make-ai-theme-border": ye(
41
+ "--make-ai-theme-border": _e(
41
42
  e?.border,
42
43
  "color-mix(in srgb, var(--make-ai-theme-primary) 14%, var(--make-ai-theme-bg))"
43
44
  ),
44
- "--make-ai-theme-overlay": ye(
45
+ "--make-ai-theme-overlay": _e(
45
46
  e?.overlay,
46
47
  "color-mix(in srgb, var(--make-ai-theme-text) 88%, var(--make-ai-theme-primary))"
47
48
  ),
48
- "--make-ai-theme-on-overlay": ye(
49
+ "--make-ai-theme-on-overlay": _e(
49
50
  e?.onOverlay,
50
51
  "#fcfcff"
51
52
  )
52
53
  };
53
- }, Ft = (e, t) => !t || !ba(e) || typeof e.type != "string" ? e : ka(e, {
54
+ }, Et = (e, t) => !t || !na(e) || typeof e.type != "string" ? e : ra(e, {
54
55
  style: { ...e.props.style, ...t }
55
56
  });
56
- function Ia({
57
+ function da({
57
58
  artifact: e,
58
59
  context: t,
59
- fallback: n,
60
+ fallback: s,
60
61
  onAction: i,
61
- onActionError: s,
62
- registry: o,
62
+ onActionError: o,
63
+ registry: c,
63
64
  theme: d
64
65
  }) {
65
- const g = kt(d), f = _a(o, e, t);
66
- if (!f) {
67
- const $ = n ? n(e) : /* @__PURE__ */ c("section", { className: "make-ai-artifact make-ai-artifact--unsupported", role: "status", children: [
66
+ const h = yt(d), b = oa(c, e, t);
67
+ if (!b) {
68
+ const L = s ? s(e) : /* @__PURE__ */ l("section", { className: "make-ai-artifact make-ai-artifact--unsupported", role: "status", children: [
68
69
  /* @__PURE__ */ a("strong", { children: "暂不支持展示此结果" }),
69
- /* @__PURE__ */ c("span", { children: [
70
+ /* @__PURE__ */ l("span", { children: [
70
71
  "结果类型:",
71
72
  e.kind
72
73
  ] })
73
74
  ] });
74
- return Ft($, g);
75
+ return Et(L, h);
75
76
  }
76
- const p = {
77
+ const f = {
77
78
  context: t,
78
79
  onAction: i,
79
- onActionError: s,
80
+ onActionError: o,
80
81
  theme: d,
81
- themeStyle: g
82
- }, k = f.template.render(e, t, p);
83
- return Ft(k, g);
82
+ themeStyle: h
83
+ }, $ = b.template.render(e, t, f);
84
+ return Et($, h);
84
85
  }
85
- const Fe = (e, t, n) => {
86
+ const $e = (e, t, s) => {
86
87
  if (e == null || e === "") return "—";
87
88
  if (typeof e == "boolean") return e ? "是" : "否";
88
89
  if (typeof e != "number") return `${e}${t?.unit ?? ""}`;
89
- const i = t?.precision, s = {
90
+ const i = t?.precision, o = {
90
91
  maximumFractionDigits: i ?? 2,
91
92
  minimumFractionDigits: i
92
93
  };
93
- t?.style === "currency" && t.currency ? (s.style = "currency", s.currency = t.currency) : t?.style === "percent" && (s.style = "percent");
94
+ t?.style === "currency" && t.currency ? (o.style = "currency", o.currency = t.currency) : t?.style === "percent" && (o.style = "percent");
94
95
  try {
95
- const o = t?.style === "percent" ? e / 100 : e;
96
- return `${new Intl.NumberFormat(n, s).format(o)}${t?.unit ?? ""}`;
96
+ const c = t?.style === "percent" ? e / 100 : e;
97
+ return `${new Intl.NumberFormat(s, o).format(c)}${t?.unit ?? ""}`;
97
98
  } catch {
98
99
  return `${e}${t?.unit ?? ""}`;
99
100
  }
100
- }, Zt = (e) => {
101
- let t = Number.POSITIVE_INFINITY, n = Number.NEGATIVE_INFINITY;
101
+ }, Kt = (e) => {
102
+ let t = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY;
102
103
  for (const i of e)
103
- t = Math.min(t, i), n = Math.max(n, i);
104
- return Number.isFinite(t) && Number.isFinite(n) ? { min: t, max: n } : { min: 0, max: 0 };
105
- }, Gt = (e, t, n) => {
106
- if (!n.onAction) return;
107
- const i = (o) => {
104
+ t = Math.min(t, i), s = Math.max(s, i);
105
+ return Number.isFinite(t) && Number.isFinite(s) ? { min: t, max: s } : { min: 0, max: 0 };
106
+ }, jt = (e, t, s) => {
107
+ if (!s.onAction) return;
108
+ const i = (c) => {
108
109
  console.error("[make-ai-assistant] host action error handler failed", {
109
110
  actionId: e.id,
110
111
  artifactId: t.artifact.id,
111
- errorType: o instanceof Error ? o.name : typeof o,
112
+ errorType: c instanceof Error ? c.name : typeof c,
112
113
  intent: e.intent
113
114
  });
114
- }, s = (o) => {
115
- if (n.onActionError) {
115
+ }, o = (c) => {
116
+ if (s.onActionError) {
116
117
  try {
117
118
  Promise.resolve(
118
- n.onActionError(o, e, t)
119
+ s.onActionError(c, e, t)
119
120
  ).catch(i);
120
121
  } catch (d) {
121
122
  i(d);
@@ -125,32 +126,32 @@ const Fe = (e, t, n) => {
125
126
  console.error("[make-ai-assistant] host action failed", {
126
127
  actionId: e.id,
127
128
  artifactId: t.artifact.id,
128
- errorType: o instanceof Error ? o.name : typeof o,
129
+ errorType: c instanceof Error ? c.name : typeof c,
129
130
  intent: e.intent
130
131
  });
131
132
  };
132
133
  try {
133
- Promise.resolve(n.onAction(e, t)).catch(s);
134
- } catch (o) {
135
- s(o);
134
+ Promise.resolve(s.onAction(e, t)).catch(o);
135
+ } catch (c) {
136
+ o(c);
136
137
  }
137
- }, Ue = (e, t) => e.actions?.length && t.onAction ? /* @__PURE__ */ a("div", { className: "make-ai-artifact__actions", children: e.actions.map((n) => /* @__PURE__ */ c(
138
+ }, ze = (e, t) => e.actions?.length && t.onAction ? /* @__PURE__ */ a("div", { className: "make-ai-artifact__actions", children: e.actions.map((s) => /* @__PURE__ */ l(
138
139
  "button",
139
140
  {
140
- className: `make-ai-artifact__action make-ai-artifact__action--${n.appearance ?? "link"}`,
141
+ className: `make-ai-artifact__action make-ai-artifact__action--${s.appearance ?? "link"}`,
141
142
  type: "button",
142
- onClick: () => Gt(n, { artifact: e, context: t.context }, t),
143
+ onClick: () => jt(s, { artifact: e, context: t.context }, t),
143
144
  children: [
144
- n.label,
145
+ s.label,
145
146
  /* @__PURE__ */ a("span", { "aria-hidden": "true", children: "→" })
146
147
  ]
147
148
  },
148
- n.id
149
- )) }) : null, qe = (e, t, n = "", i) => /* @__PURE__ */ c(
149
+ s.id
150
+ )) }) : null, We = (e, t, s = "", i) => /* @__PURE__ */ l(
150
151
  "section",
151
152
  {
152
153
  "aria-label": e.title ?? `${e.kind} result`,
153
- className: `make-ai-artifact ${n}`.trim(),
154
+ className: `make-ai-artifact ${s}`.trim(),
154
155
  "data-artifact-density": e.presentation?.density,
155
156
  "data-artifact-kind": e.kind,
156
157
  style: i,
@@ -160,141 +161,141 @@ const Fe = (e, t, n) => {
160
161
  t
161
162
  ]
162
163
  }
163
- ), Aa = ({
164
+ ), ua = ({
164
165
  artifact: e,
165
166
  renderContext: t
166
167
  }) => {
167
- const n = e.data.delta, i = n ? Fe(
168
- n.value,
169
- n.format === "percent" ? { style: "percent" } : void 0,
168
+ const s = e.data.delta, i = s ? $e(
169
+ s.value,
170
+ s.format === "percent" ? { style: "percent" } : void 0,
170
171
  t.context.locale
171
172
  ) : void 0;
172
- return qe(
173
+ return We(
173
174
  e,
174
- /* @__PURE__ */ c(Ae, { children: [
175
- /* @__PURE__ */ a("div", { className: "make-ai-artifact__metric-value", children: Fe(
175
+ /* @__PURE__ */ l(Ne, { children: [
176
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__metric-value", children: $e(
176
177
  e.data.value,
177
178
  e.data.format,
178
179
  t.context.locale
179
180
  ) }),
180
- n ? /* @__PURE__ */ c(
181
+ s ? /* @__PURE__ */ l(
181
182
  "div",
182
183
  {
183
- className: `make-ai-artifact__delta make-ai-artifact__delta--${n.direction ?? "flat"}`,
184
+ className: `make-ai-artifact__delta make-ai-artifact__delta--${s.direction ?? "flat"}`,
184
185
  children: [
185
- /* @__PURE__ */ a("span", { "aria-hidden": "true", children: n.direction === "up" ? "↗" : n.direction === "down" ? "↘" : "→" }),
186
+ /* @__PURE__ */ a("span", { "aria-hidden": "true", children: s.direction === "up" ? "↗" : s.direction === "down" ? "↘" : "→" }),
186
187
  /* @__PURE__ */ a("span", { children: i }),
187
- n.label ? /* @__PURE__ */ a("span", { children: n.label }) : null
188
+ s.label ? /* @__PURE__ */ a("span", { children: s.label }) : null
188
189
  ]
189
190
  }
190
191
  ) : null,
191
192
  e.data.context ? /* @__PURE__ */ a("p", { className: "make-ai-artifact__context", children: e.data.context }) : null,
192
- Ue(e, t)
193
+ ze(e, t)
193
194
  ] }),
194
195
  "make-ai-artifact--metric",
195
196
  t.themeStyle
196
197
  );
197
- }, Ma = ({
198
+ }, ma = ({
198
199
  artifact: e,
199
200
  renderContext: t
200
- }) => qe(
201
+ }) => We(
201
202
  e,
202
- /* @__PURE__ */ c(Ae, { children: [
203
- /* @__PURE__ */ a("div", { className: "make-ai-artifact__comparison", children: e.data.items.map((n) => /* @__PURE__ */ c("div", { className: "make-ai-artifact__comparison-item", children: [
204
- /* @__PURE__ */ a("span", { children: n.label }),
205
- /* @__PURE__ */ a("strong", { children: Fe(n.value, n.format, t.context.locale) }),
206
- n.hint ? /* @__PURE__ */ a("small", { children: n.hint }) : null
207
- ] }, n.id)) }),
208
- Ue(e, t)
203
+ /* @__PURE__ */ l(Ne, { children: [
204
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__comparison", children: e.data.items.map((s) => /* @__PURE__ */ l("div", { className: "make-ai-artifact__comparison-item", children: [
205
+ /* @__PURE__ */ a("span", { children: s.label }),
206
+ /* @__PURE__ */ a("strong", { children: $e(s.value, s.format, t.context.locale) }),
207
+ s.hint ? /* @__PURE__ */ a("small", { children: s.hint }) : null
208
+ ] }, s.id)) }),
209
+ ze(e, t)
209
210
  ] }),
210
211
  "make-ai-artifact--comparison",
211
212
  t.themeStyle
212
- ), Ta = ({
213
+ ), ha = ({
213
214
  artifact: e,
214
215
  renderContext: t
215
216
  }) => {
216
- const n = e.data.series.flatMap((d) => d.points.map((g) => g.y)), { max: i, min: s } = Zt(n), o = i - s || 1;
217
- return qe(
217
+ const s = e.data.series.flatMap((d) => d.points.map((h) => h.y)), { max: i, min: o } = Kt(s), c = i - o || 1;
218
+ return We(
218
219
  e,
219
- /* @__PURE__ */ c(Ae, { children: [
220
- /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend", children: e.data.series.map((d) => /* @__PURE__ */ c("div", { className: "make-ai-artifact__trend-series", children: [
220
+ /* @__PURE__ */ l(Ne, { children: [
221
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend", children: e.data.series.map((d) => /* @__PURE__ */ l("div", { className: "make-ai-artifact__trend-series", children: [
221
222
  /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-label", children: d.label }),
222
- /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-bars", children: d.points.map((g, f) => {
223
- const p = 18 + (g.y - s) / o * 70;
224
- return /* @__PURE__ */ c("div", { className: "make-ai-artifact__trend-point", children: [
223
+ /* @__PURE__ */ a("div", { className: "make-ai-artifact__trend-bars", children: d.points.map((h, b) => {
224
+ const f = 18 + (h.y - o) / c * 70;
225
+ return /* @__PURE__ */ l("div", { className: "make-ai-artifact__trend-point", children: [
225
226
  /* @__PURE__ */ a(
226
227
  "span",
227
228
  {
228
- "aria-label": `${g.x}: ${Fe(
229
- g.y,
229
+ "aria-label": `${h.x}: ${$e(
230
+ h.y,
230
231
  d.format,
231
232
  t.context.locale
232
233
  )}`,
233
234
  className: "make-ai-artifact__trend-bar",
234
235
  role: "img",
235
- style: { height: `${p}%` },
236
- title: `${g.x}: ${Fe(
237
- g.y,
236
+ style: { height: `${f}%` },
237
+ title: `${h.x}: ${$e(
238
+ h.y,
238
239
  d.format,
239
240
  t.context.locale
240
241
  )}`
241
242
  }
242
243
  ),
243
- /* @__PURE__ */ a("small", { children: g.x })
244
- ] }, `${g.x}-${f}`);
244
+ /* @__PURE__ */ a("small", { children: h.x })
245
+ ] }, `${h.x}-${b}`);
245
246
  }) })
246
247
  ] }, d.id)) }),
247
- Ue(e, t)
248
+ ze(e, t)
248
249
  ] }),
249
250
  "make-ai-artifact--trend",
250
251
  t.themeStyle
251
252
  );
252
- }, Ca = ({
253
+ }, pa = ({
253
254
  artifact: e,
254
255
  renderContext: t
255
256
  }) => {
256
- const { max: n } = Zt(
257
- e.data.items.map((s) => Math.abs(s.value))
258
- ), i = Math.max(n, 1);
259
- return qe(
257
+ const { max: s } = Kt(
258
+ e.data.items.map((o) => Math.abs(o.value))
259
+ ), i = Math.max(s, 1);
260
+ return We(
260
261
  e,
261
- /* @__PURE__ */ c(Ae, { children: [
262
- /* @__PURE__ */ a("ol", { className: "make-ai-artifact__ranking", children: e.data.items.map((s, o) => /* @__PURE__ */ c("li", { children: [
263
- /* @__PURE__ */ a("span", { className: "make-ai-artifact__rank", children: o + 1 }),
264
- /* @__PURE__ */ c("span", { className: "make-ai-artifact__ranking-label", children: [
265
- /* @__PURE__ */ a("span", { children: s.label }),
266
- s.description ? /* @__PURE__ */ a("small", { children: s.description }) : null
262
+ /* @__PURE__ */ l(Ne, { children: [
263
+ /* @__PURE__ */ a("ol", { className: "make-ai-artifact__ranking", children: e.data.items.map((o, c) => /* @__PURE__ */ l("li", { children: [
264
+ /* @__PURE__ */ a("span", { className: "make-ai-artifact__rank", children: c + 1 }),
265
+ /* @__PURE__ */ l("span", { className: "make-ai-artifact__ranking-label", children: [
266
+ /* @__PURE__ */ a("span", { children: o.label }),
267
+ o.description ? /* @__PURE__ */ a("small", { children: o.description }) : null
267
268
  ] }),
268
- /* @__PURE__ */ a("span", { className: "make-ai-artifact__ranking-track", "aria-hidden": "true", children: /* @__PURE__ */ a("span", { style: { width: `${Math.abs(s.value) / i * 100}%` } }) }),
269
- /* @__PURE__ */ a("strong", { children: Fe(s.value, s.format, t.context.locale) })
270
- ] }, s.id)) }),
271
- Ue(e, t)
269
+ /* @__PURE__ */ a("span", { className: "make-ai-artifact__ranking-track", "aria-hidden": "true", children: /* @__PURE__ */ a("span", { style: { width: `${Math.abs(o.value) / i * 100}%` } }) }),
270
+ /* @__PURE__ */ a("strong", { children: $e(o.value, o.format, t.context.locale) })
271
+ ] }, o.id)) }),
272
+ ze(e, t)
272
273
  ] }),
273
274
  "make-ai-artifact--ranking",
274
275
  t.themeStyle
275
276
  );
276
- }, Na = (e, t) => t.action ?? {
277
+ }, fa = (e, t) => t.action ?? {
277
278
  id: `open-${t.id}`,
278
279
  label: t.title ?? t.id,
279
280
  intent: "open-record",
280
281
  target: { entityKey: e.data.entity.key, recordId: t.id }
281
- }, Ra = ({
282
+ }, va = ({
282
283
  artifact: e,
283
284
  renderContext: t
284
- }) => qe(
285
+ }) => We(
285
286
  e,
286
- /* @__PURE__ */ c(Ae, { children: [
287
- /* @__PURE__ */ a("div", { className: "make-ai-artifact__record-list", children: e.data.records.length === 0 ? /* @__PURE__ */ a("p", { className: "make-ai-artifact__empty", children: "没有符合条件的记录" }) : e.data.records.map((n) => {
288
- const i = Na(e, n), s = /* @__PURE__ */ c(Ae, { children: [
289
- /* @__PURE__ */ a("strong", { children: n.title ?? n.id }),
290
- /* @__PURE__ */ a("span", { className: "make-ai-artifact__record-values", children: e.data.columns.map((o) => /* @__PURE__ */ c("span", { children: [
291
- /* @__PURE__ */ a("small", { children: o.label }),
292
- Fe(
293
- n.values[o.key],
294
- o.format,
287
+ /* @__PURE__ */ l(Ne, { children: [
288
+ /* @__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) => {
289
+ const i = fa(e, s), o = /* @__PURE__ */ l(Ne, { children: [
290
+ /* @__PURE__ */ a("strong", { children: s.title ?? s.id }),
291
+ /* @__PURE__ */ a("span", { className: "make-ai-artifact__record-values", children: e.data.columns.map((c) => /* @__PURE__ */ l("span", { children: [
292
+ /* @__PURE__ */ a("small", { children: c.label }),
293
+ $e(
294
+ s.values[c.key],
295
+ c.format,
295
296
  t.context.locale
296
297
  )
297
- ] }, o.key)) }),
298
+ ] }, c.key)) }),
298
299
  t.onAction ? /* @__PURE__ */ a("span", { "aria-hidden": "true", children: "›" }) : null
299
300
  ] });
300
301
  return t.onAction ? /* @__PURE__ */ a(
@@ -302,244 +303,254 @@ const Fe = (e, t, n) => {
302
303
  {
303
304
  className: "make-ai-artifact__record",
304
305
  type: "button",
305
- onClick: () => Gt(i, {
306
+ onClick: () => jt(i, {
306
307
  artifact: e,
307
308
  context: t.context
308
309
  }, t),
309
- children: s
310
+ children: o
310
311
  },
311
- n.id
312
- ) : /* @__PURE__ */ a("div", { className: "make-ai-artifact__record", children: s }, n.id);
312
+ s.id
313
+ ) : /* @__PURE__ */ a("div", { className: "make-ai-artifact__record", children: o }, s.id);
313
314
  }) }),
314
- e.data.total !== void 0 ? /* @__PURE__ */ c("p", { className: "make-ai-artifact__record-total", children: [
315
+ e.data.total !== void 0 ? /* @__PURE__ */ l("p", { className: "make-ai-artifact__record-total", children: [
315
316
  "共 ",
316
317
  e.data.total,
317
318
  " 条"
318
319
  ] }) : null,
319
- Ue(e, t)
320
+ ze(e, t)
320
321
  ] }),
321
322
  "make-ai-artifact--record-list",
322
323
  t.themeStyle
323
- ), Ea = ({
324
+ ), ga = ({
324
325
  artifact: e,
325
326
  renderContext: t
326
- }) => qe(
327
+ }) => We(
327
328
  e,
328
- /* @__PURE__ */ c(Ae, { children: [
329
- /* @__PURE__ */ c("div", { className: `make-ai-artifact__notice make-ai-artifact__notice--${e.data.tone}`, children: [
329
+ /* @__PURE__ */ l(Ne, { children: [
330
+ /* @__PURE__ */ l("div", { className: `make-ai-artifact__notice make-ai-artifact__notice--${e.data.tone}`, children: [
330
331
  /* @__PURE__ */ a("span", { "aria-hidden": "true", children: e.data.tone === "success" ? "✓" : e.data.tone === "warning" ? "!" : e.data.tone === "danger" ? "×" : "i" }),
331
332
  /* @__PURE__ */ a("p", { children: e.data.body })
332
333
  ] }),
333
- Ue(e, t)
334
+ ze(e, t)
334
335
  ] }),
335
336
  "make-ai-artifact--notice",
336
337
  t.themeStyle
337
- ), Oe = (e, t, n) => ({ id: e, kinds: [t], priority: 0, render: n }), Sa = [
338
- Oe("platform.metric.default", "metric", (e, t, n) => /* @__PURE__ */ a(Aa, { artifact: e, renderContext: n })),
339
- Oe("platform.comparison.default", "comparison", (e, t, n) => /* @__PURE__ */ a(Ma, { artifact: e, renderContext: n })),
340
- Oe("platform.trend.default", "trend", (e, t, n) => /* @__PURE__ */ a(Ta, { artifact: e, renderContext: n })),
341
- Oe("platform.ranking.default", "ranking", (e, t, n) => /* @__PURE__ */ a(Ca, { artifact: e, renderContext: n })),
342
- Oe("platform.record-list.default", "record-list", (e, t, n) => /* @__PURE__ */ a(Ra, { artifact: e, renderContext: n })),
343
- Oe("platform.notice.default", "notice", (e, t, n) => /* @__PURE__ */ a(Ea, { artifact: e, renderContext: n }))
344
- ], xa = Vt(Sa).templates, $a = (e = xa) => Vt(e), We = () => globalThis.crypto.randomUUID(), _t = (e) => {
345
- const t = e, n = t?.status ?? t?.response?.status;
346
- return n === 409 ? "数据已变化或对话仍在运行,请刷新后重试" : n === 401 || t?.code === "AI_AUTH_REQUIRED" || t?.code === "AI_AUTH_EXPIRED" ? "登录已失效,请重新登录" : n === 403 ? "当前账号无权访问该对话" : n === 404 ? "对话或回答已不可见,请刷新列表" : t?.message?.startsWith("输入内容过长") ? t.message : "操作未完成,请重试或刷新对话";
338
+ ), Fe = (e, t, s) => ({ id: e, kinds: [t], priority: 0, render: s }), ya = [
339
+ Fe("platform.metric.default", "metric", (e, t, s) => /* @__PURE__ */ a(ua, { artifact: e, renderContext: s })),
340
+ Fe("platform.comparison.default", "comparison", (e, t, s) => /* @__PURE__ */ a(ma, { artifact: e, renderContext: s })),
341
+ Fe("platform.trend.default", "trend", (e, t, s) => /* @__PURE__ */ a(ha, { artifact: e, renderContext: s })),
342
+ Fe("platform.ranking.default", "ranking", (e, t, s) => /* @__PURE__ */ a(pa, { artifact: e, renderContext: s })),
343
+ Fe("platform.record-list.default", "record-list", (e, t, s) => /* @__PURE__ */ a(va, { artifact: e, renderContext: s })),
344
+ Fe("platform.notice.default", "notice", (e, t, s) => /* @__PURE__ */ a(ga, { artifact: e, renderContext: s }))
345
+ ], ba = Wt(ya).templates, ka = (e = ba) => Wt(e), Pe = () => globalThis.crypto.randomUUID(), bt = (e) => {
346
+ const t = e, s = t?.status ?? t?.response?.status;
347
+ return s === 409 ? "数据已变化或对话仍在运行,请刷新后重试" : s === 401 || t?.code === "AI_AUTH_REQUIRED" || t?.code === "AI_AUTH_EXPIRED" ? "登录已失效,请重新登录" : s === 403 ? "当前账号无权访问该对话" : s === 404 ? "对话或回答已不可见,请刷新列表" : t?.message?.startsWith("输入内容过长") ? t.message : "操作未完成,请重试或刷新对话";
347
348
  };
348
- function La(e, t) {
349
- const n = t.features?.conversationManagement === !0, i = n ? t.scopeKey?.(e) ?? e.app.id : "", s = C(i);
350
- s.current = i;
351
- const o = C(i), [d, g] = N(he), f = C(d), p = (r) => {
352
- const h = typeof r == "function" ? r(f.current) : r;
353
- f.current = h, g(h);
354
- }, [k, $] = N([]), [O, q] = N(), y = C(void 0), [V, ee] = N(""), [j, v] = N(-1), [u, l] = N(!1), [T, L] = N(!1), [re, E] = N(n), [J, K] = N(!1), [D, X] = N(), [ie, oe] = N([]), [pe, Me] = N([]), Te = C(/* @__PURE__ */ new Set()), Y = C(/* @__PURE__ */ new Map()), w = C(0), b = C(0), H = C(0), Z = C(void 0), te = C(void 0), De = C(/* @__PURE__ */ new Map()), S = (r, h = i) => b.current === r && s.current === h, ne = () => {
349
+ function _a(e, t) {
350
+ const s = t.features?.conversationManagement === !0, i = s ? t.scopeKey?.(e) ?? e.app.id : "", o = S(i);
351
+ o.current = i;
352
+ const c = S(i), [d, h] = N(fe), b = S(d), f = (r) => {
353
+ const u = typeof r == "function" ? r(b.current) : r;
354
+ b.current = u, h(u);
355
+ }, [$, L] = N([]), [T, j] = N(), M = S(void 0), [U, g] = N(""), [R, P] = N(-1), [p, n] = N(!1), [v, k] = N(!1), [q, I] = N(s), [G, Y] = N(!1), [z, Q] = N(), [ve, oe] = N([]), [F, ne] = N([]), ce = S(/* @__PURE__ */ new Set()), V = S(/* @__PURE__ */ new Map()), B = S(0), A = S(0), W = S(0), ae = S(void 0), ge = S(void 0), Re = S(/* @__PURE__ */ new Map()), x = (r, u = i) => A.current === r && o.current === u, ee = () => {
355
356
  const r = new AbortController();
356
- return Te.current.add(r), r;
357
- }, ce = (r) => Te.current.delete(r), fe = (r) => {
358
- y.current = r, q(r);
359
- }, Ce = () => {
360
- for (const r of Y.current.values()) r.abort();
361
- Y.current.clear();
362
- }, Q = (r) => {
357
+ return ce.current.add(r), r;
358
+ }, le = (r) => ce.current.delete(r), de = (r) => {
359
+ M.current = r, j(r);
360
+ }, lt = (r) => {
361
+ L(
362
+ (u) => u.map((y) => y.chatId === r.chatId ? r : y)
363
+ );
364
+ }, ye = (r) => {
365
+ L(
366
+ (u) => u.filter((y) => y.chatId !== r)
367
+ );
368
+ }, we = () => {
369
+ W.current += 1;
370
+ }, be = () => {
371
+ for (const r of V.current.values()) r.abort();
372
+ V.current.clear();
373
+ }, te = (r) => {
363
374
  r instanceof Error && r.name === "AbortError" || (console.warn("[make-ai-assistant] conversation operation failed", {
364
375
  errorType: r instanceof Error ? r.name : typeof r
365
- }), X(_t(r)));
366
- }, ke = async (r) => {
367
- if (!n || !t.listConversations) return;
368
- const h = b.current, _ = ++H.current, A = ne();
376
+ }), Q(bt(r)));
377
+ }, Ce = async (r) => {
378
+ if (!s || !t.listConversations) return;
379
+ const u = A.current, y = ++W.current, w = ee();
369
380
  try {
370
- const M = await t.listConversations(
381
+ const C = await t.listConversations(
371
382
  e,
372
383
  { cursor: r },
373
- { signal: A.signal }
384
+ { signal: w.signal }
374
385
  );
375
- if (!S(h) || A.signal.aborted || _ !== H.current)
386
+ if (!x(u) || w.signal.aborted || y !== W.current)
376
387
  return;
377
- $((x) => [
388
+ L((D) => [
378
389
  ...new Map(
379
- [...r ? x : [], ...M.chats].map((I) => [
380
- I.chatId,
381
- I
390
+ [...r ? D : [], ...C.chats].map((_) => [
391
+ _.chatId,
392
+ _
382
393
  ])
383
394
  ).values()
384
- ]), ee(M.nextCursor);
385
- } catch (M) {
386
- S(h) && !A.signal.aborted && Q(M);
395
+ ]), g(C.nextCursor);
396
+ } catch (C) {
397
+ x(u) && !w.signal.aborted && y === W.current && te(C);
387
398
  } finally {
388
- ce(A), S(h) && E(!1);
399
+ le(w), x(u) && y === W.current && I(!1);
389
400
  }
390
- }, Ne = async (r, h, _) => {
391
- const A = b.current, M = w.current;
392
- let x;
401
+ }, ke = async (r, u, y) => {
402
+ const w = A.current, C = B.current;
403
+ let D;
393
404
  try {
394
- for await (const I of r) {
395
- if (!S(A) || h.signal.aborted || M !== w.current || y.current?.chatId !== _)
405
+ for await (const _ of r) {
406
+ if (!x(w) || u.signal.aborted || C !== B.current || M.current?.chatId !== y)
396
407
  return;
397
- const W = jt(I);
398
- if (W.type === "response.accepted" || W.type === "response.state") {
399
- x = W.responseId;
400
- const z = Y.current.get(x);
401
- if (z && z !== h) {
402
- W.type === "response.accepted" && p((B) => Ie(B, W)), h.abort();
408
+ const Z = Ot(_);
409
+ if (Z.type === "response.accepted" || Z.type === "response.state") {
410
+ D = Z.responseId;
411
+ const O = V.current.get(D);
412
+ if (O && O !== u) {
413
+ Z.type === "response.accepted" && f((H) => Me(H, Z)), u.abort();
403
414
  return;
404
415
  }
405
- Y.current.set(x, h);
416
+ V.current.set(D, u);
406
417
  }
407
- p((z) => Ie(z, W)), W.type === "response.terminal" && (oe((z) => z.filter((B) => B !== W.responseId)), ke());
418
+ f((O) => Me(O, Z)), Z.type === "response.terminal" && (oe((O) => O.filter((H) => H !== Z.responseId)), Ce());
408
419
  }
409
- } catch (I) {
410
- S(A) && !h.signal.aborted && M === w.current && (Q(I), x || p((W) => ({
411
- ...W,
412
- status: Object.values(W.responses ?? {}).some(
413
- (z) => !ft(z.status)
420
+ } catch (_) {
421
+ x(w) && !u.signal.aborted && C === B.current && (te(_), D || f((Z) => ({
422
+ ...Z,
423
+ status: Object.values(Z.responses ?? {}).some(
424
+ (O) => !ht(O.status)
414
425
  ) ? "streaming" : "error"
415
426
  })));
416
427
  } finally {
417
- x && Y.current.get(x) === h && Y.current.delete(x), ce(h);
428
+ D && V.current.get(D) === u && V.current.delete(D), le(u);
418
429
  }
419
- }, Qe = async (r, h, _, A) => {
430
+ }, Oe = async (r, u, y, w) => {
420
431
  if (!t.getResponse || !t.watchResponse) return;
421
- const M = new Set(
422
- r.filter((I) => I.role === "assistant" && I.persistent).map((I) => I.responseId)
423
- ), x = [
432
+ const C = new Set(
433
+ r.filter((_) => _.role === "assistant" && _.persistent).map((_) => _.responseId)
434
+ ), D = [
424
435
  ...new Map(
425
436
  r.filter(
426
- (I) => I.role === "user" && I.responseId && !M.has(I.responseId)
427
- ).map((I) => [I.responseId, I.cursor ?? -1])
437
+ (_) => _.role === "user" && _.responseId && !C.has(_.responseId)
438
+ ).map((_) => [_.responseId, _.cursor ?? -1])
428
439
  ).entries()
429
440
  ].slice(-20);
430
- for (const [I, W] of x) {
431
- if (!S(A) || _ !== w.current) return;
432
- if (Y.current.has(I)) continue;
433
- const z = ne();
441
+ for (const [_, Z] of D) {
442
+ if (!x(w) || y !== B.current) return;
443
+ if (V.current.has(_)) continue;
444
+ const O = ee();
434
445
  try {
435
- const B = await t.getResponse(
446
+ const H = await t.getResponse(
436
447
  e,
437
- { chatId: h, responseId: I },
438
- { signal: z.signal }
448
+ { chatId: u, responseId: _ },
449
+ { signal: O.signal }
439
450
  );
440
- if (!S(A) || z.signal.aborted || _ !== w.current || Y.current.has(I)) continue;
441
- p(
442
- (ge) => Ie(
443
- ge,
444
- ft(B.status) ? { type: "response.snapshot", snapshot: B } : {
451
+ if (!x(w) || O.signal.aborted || y !== B.current || V.current.has(_)) continue;
452
+ f(
453
+ (Ie) => Me(
454
+ Ie,
455
+ ht(H.status) ? { type: "response.snapshot", snapshot: H } : {
445
456
  type: "response.state",
446
- chatId: h,
447
- responseId: I,
448
- status: B.status
457
+ chatId: u,
458
+ responseId: _,
459
+ status: H.status
449
460
  }
450
461
  )
451
- ), B.status === "failed" || B.status === "cancelled" ? p(
452
- (ge) => Ie(ge, {
462
+ ), H.status === "failed" || H.status === "cancelled" ? f(
463
+ (Ie) => Me(Ie, {
453
464
  type: "response.terminal",
454
- chatId: h,
455
- responseId: I,
456
- status: B.status
465
+ chatId: u,
466
+ responseId: _,
467
+ status: H.status
457
468
  })
458
- ) : (Y.current.set(I, z), Ne(
469
+ ) : (V.current.set(_, O), ke(
459
470
  t.watchResponse(
460
471
  e,
461
- { chatId: h, responseId: I, historyCursor: W },
462
- { signal: z.signal }
472
+ { chatId: u, responseId: _, historyCursor: Z },
473
+ { signal: O.signal }
463
474
  ),
464
- z,
465
- h
475
+ O,
476
+ u
466
477
  ));
467
- } catch (B) {
468
- S(A) && !z.signal.aborted && Q(B);
478
+ } catch (H) {
479
+ x(w) && !O.signal.aborted && te(H);
469
480
  } finally {
470
- Y.current.get(I) !== z && ce(z);
481
+ V.current.get(_) !== O && le(O);
471
482
  }
472
483
  }
473
- }, de = async (r) => {
474
- const h = ++w.current, _ = b.current, A = ne();
475
- Ce(), X(void 0), E(!0), oe([]), te.current = void 0, fe(r), p({ messages: [], status: "idle", threadId: r.chatId }), v(-1), l(!1), L(!1);
484
+ }, He = async (r) => {
485
+ const u = ++B.current, y = A.current, w = ee();
486
+ be(), Q(void 0), I(!0), oe([]), ge.current = void 0, de(r), f({ messages: [], status: "idle", threadId: r.chatId }), P(-1), n(!1), k(!1);
476
487
  try {
477
- const [M, x] = await Promise.all([
488
+ const [C, D] = await Promise.all([
478
489
  t.getConversation(
479
490
  e,
480
491
  { chatId: r.chatId },
481
- { signal: A.signal }
492
+ { signal: w.signal }
482
493
  ),
483
494
  t.loadConversation(e, {
484
495
  threadId: r.chatId,
485
496
  cursor: -1,
486
- signal: A.signal
497
+ signal: w.signal
487
498
  })
488
499
  ]);
489
- if (!S(_) || A.signal.aborted || h !== w.current)
500
+ if (!x(y) || w.signal.aborted || u !== B.current)
490
501
  return;
491
- if (M.chatId !== r.chatId || x.threadId !== r.chatId)
502
+ if (C.chatId !== r.chatId || D.threadId !== r.chatId)
492
503
  throw new Error("Conversation mismatch");
493
- fe(M), p(he(x)), v(x.nextCursor ?? -1), l(x.hasMore ?? !1), Qe(x.messages, r.chatId, h, _);
494
- } catch (M) {
495
- S(_) && !A.signal.aborted && h === w.current && Q(M);
504
+ de(C), f(fe(D)), P(D.nextCursor ?? -1), n(D.hasMore ?? !1), Oe(D.messages, r.chatId, u, y);
505
+ } catch (C) {
506
+ x(y) && !w.signal.aborted && u === B.current && te(C);
496
507
  } finally {
497
- ce(A), S(_) && h === w.current && E(!1);
508
+ le(w), x(y) && u === B.current && I(!1);
498
509
  }
499
- }, ve = async () => {
500
- if (y.current) return y.current;
501
- if (Z.current ??= { requestId: We() }, Z.current.promise) return Z.current.promise;
502
- const r = b.current, h = w.current, _ = ne(), A = Z.current;
503
- return K(!0), A.promise = t.createConversation(
510
+ }, Ee = async () => {
511
+ if (M.current) return M.current;
512
+ if (ae.current ??= { requestId: Pe() }, ae.current.promise) return ae.current.promise;
513
+ const r = A.current, u = B.current, y = ee(), w = ae.current;
514
+ return Y(!0), w.promise = t.createConversation(
504
515
  e,
505
- { requestId: A.requestId },
506
- { signal: _.signal }
507
- ).then((M) => {
508
- if (!S(r) || _.signal.aborted || h !== w.current)
516
+ { requestId: w.requestId },
517
+ { signal: y.signal }
518
+ ).then((C) => {
519
+ if (!x(r) || y.signal.aborted || u !== B.current)
509
520
  throw Object.assign(new Error("Stale create"), {
510
521
  name: "AbortError"
511
522
  });
512
- return Z.current = void 0, fe(M), p({ messages: [], status: "idle", threadId: M.chatId }), ke(), M;
523
+ return ae.current = void 0, de(C), f({ messages: [], status: "idle", threadId: C.chatId }), Ce(), C;
513
524
  }).finally(() => {
514
- ce(_), A.promise = void 0, S(r) && K(!1);
515
- }), A.promise;
516
- }, et = async () => {
517
- if (!(J || Z.current?.promise)) {
518
- w.current += 1, Ce(), fe(void 0), X(void 0), te.current = void 0, p(he()), l(!1), v(-1);
525
+ le(y), w.promise = void 0, x(r) && Y(!1);
526
+ }), w.promise;
527
+ }, Xe = async () => {
528
+ if (!(G || ae.current?.promise)) {
529
+ B.current += 1, be(), de(void 0), Q(void 0), ge.current = void 0, f(fe()), n(!1), P(-1);
519
530
  try {
520
- await ve();
531
+ await Ee();
521
532
  } catch (r) {
522
- Q(r);
533
+ te(r);
523
534
  }
524
535
  }
525
- }, Re = async (r) => {
526
- const h = ne();
527
- te.current = r, X(void 0), f.current.messages.some((_) => _.id === r.message.id) || p((_) => Xt(_, r.message)), await Ne(
528
- t.run(r, { signal: h.signal }),
529
- h,
536
+ }, me = async (r) => {
537
+ const u = ee();
538
+ ge.current = r, Q(void 0), b.current.messages.some((y) => y.id === r.message.id) || f((y) => Ht(y, r.message)), await ke(
539
+ t.run(r, { signal: u.signal }),
540
+ u,
530
541
  r.threadId
531
542
  );
532
- }, tt = async (r, h) => {
533
- if (!(!r.trim() && !h?.length))
543
+ }, Ge = async (r, u) => {
544
+ if (!(!r.trim() && !u?.length))
534
545
  try {
535
- const _ = await ve(), A = {
536
- id: We(),
546
+ const y = await Ee(), w = {
547
+ id: Pe(),
537
548
  content: r,
538
- ...h ? { parts: h } : {}
549
+ ...u ? { parts: u } : {}
539
550
  };
540
- await Re({
541
- threadId: _.chatId,
542
- message: A,
551
+ await me({
552
+ threadId: y.chatId,
553
+ message: w,
543
554
  context: e,
544
555
  capabilities: {
545
556
  artifactSchemaVersions: [],
@@ -547,247 +558,311 @@ function La(e, t) {
547
558
  templates: []
548
559
  }
549
560
  });
550
- } catch (_) {
551
- Q(_);
561
+ } catch (y) {
562
+ te(y);
552
563
  }
553
- }, Ee = async () => {
554
- const r = te.current;
555
- if (!r || r.threadId !== y.current?.chatId) {
556
- y.current && await de(y.current);
564
+ }, Ye = async () => {
565
+ const r = ge.current;
566
+ if (!r || r.threadId !== M.current?.chatId) {
567
+ M.current && await He(M.current);
557
568
  return;
558
569
  }
559
- const h = f.current.messages.find(
560
- (_) => _.id === r.message.id
570
+ const u = b.current.messages.find(
571
+ (y) => y.id === r.message.id
561
572
  );
562
- if (h?.responseId && t.watchResponse) {
563
- const _ = h.responseId;
564
- if (Y.current.has(_)) return;
565
- const A = ne();
566
- Y.current.set(_, A), X(void 0), await Ne(
573
+ if (u?.responseId && t.watchResponse) {
574
+ const y = u.responseId;
575
+ if (V.current.has(y)) return;
576
+ const w = ee();
577
+ V.current.set(y, w), Q(void 0), await ke(
567
578
  t.watchResponse(
568
579
  e,
569
580
  {
570
581
  chatId: r.threadId,
571
- responseId: _,
572
- historyCursor: h.cursor
582
+ responseId: y,
583
+ historyCursor: u.cursor
573
584
  },
574
- { signal: A.signal }
585
+ { signal: w.signal }
575
586
  ),
576
- A,
587
+ w,
577
588
  r.threadId
578
589
  );
579
- } else await Re(r);
580
- }, Se = async (r = f.current.activeRunId) => {
581
- const h = y.current;
582
- if (!h || !r || !t.cancelResponse || ie.includes(r))
590
+ } else await me(r);
591
+ }, Je = async (r = b.current.activeRunId) => {
592
+ const u = M.current;
593
+ if (!u || !r || !t.cancelResponse || ve.includes(r))
583
594
  return;
584
- const _ = b.current, A = w.current, M = ne();
585
- oe((x) => [...x, r]), X(void 0);
595
+ const y = A.current, w = B.current, C = ee();
596
+ oe((D) => [...D, r]), Q(void 0);
586
597
  try {
587
- const x = await t.cancelResponse(
598
+ const D = await t.cancelResponse(
588
599
  e,
589
- { chatId: h.chatId, responseId: r },
590
- { signal: M.signal }
600
+ { chatId: u.chatId, responseId: r },
601
+ { signal: C.signal }
591
602
  );
592
- if (!S(_) || A !== w.current) return;
593
- if (ft(x.status))
594
- p(
595
- (I) => Ie(I, {
603
+ if (!x(y) || w !== B.current) return;
604
+ if (ht(D.status))
605
+ f(
606
+ (_) => Me(_, {
596
607
  type: "response.snapshot",
597
- snapshot: x
608
+ snapshot: D
598
609
  })
599
- ), oe((I) => I.filter((W) => W !== r));
600
- else if (!Y.current.has(r) && t.watchResponse) {
601
- const I = ne();
602
- Y.current.set(r, I), Ne(
610
+ ), oe((_) => _.filter((Z) => Z !== r));
611
+ else if (!V.current.has(r) && t.watchResponse) {
612
+ const _ = ee();
613
+ V.current.set(r, _), ke(
603
614
  t.watchResponse(
604
615
  e,
605
- { chatId: h.chatId, responseId: r },
606
- { signal: I.signal }
616
+ { chatId: u.chatId, responseId: r },
617
+ { signal: _.signal }
607
618
  ),
608
- I,
609
- h.chatId
619
+ _,
620
+ u.chatId
610
621
  );
611
622
  }
612
- } catch (x) {
613
- S(_) && A === w.current && (Q(x), oe((I) => I.filter((W) => W !== r)));
623
+ } catch (D) {
624
+ x(y) && w === B.current && (te(D), oe((_) => _.filter((Z) => Z !== r)));
614
625
  } finally {
615
- ce(M);
626
+ le(C);
616
627
  }
617
- }, xe = async (r, h = y.current) => {
618
- if (!h || J) return;
619
- const _ = b.current, A = ne();
620
- K(!0), X(void 0);
628
+ }, Qe = async (r, u = M.current) => {
629
+ if (!u || G) return !1;
630
+ const y = A.current, w = ee();
631
+ Y(!0), Q(void 0);
621
632
  try {
622
- const M = await t.updateConversation(
633
+ const C = await t.updateConversation(
623
634
  e,
624
- { chatId: h.chatId, expectedRevision: h.revision, ...r },
625
- { signal: A.signal }
635
+ { chatId: u.chatId, expectedRevision: u.revision, ...r },
636
+ { signal: w.signal }
626
637
  );
627
- if (!S(_)) return;
628
- y.current?.chatId === M.chatId && fe(M), await ke();
629
- } catch (M) {
630
- if (S(_)) {
631
- Q(M);
638
+ return x(y) ? (we(), lt(C), M.current?.chatId === C.chatId && de(C), !0) : !1;
639
+ } catch (C) {
640
+ if (x(y)) {
641
+ te(C);
632
642
  try {
633
- const x = await t.getConversation(
643
+ const D = await t.getConversation(
634
644
  e,
635
- { chatId: h.chatId },
636
- { signal: A.signal }
645
+ { chatId: u.chatId },
646
+ { signal: w.signal }
637
647
  );
638
- S(_) && y.current?.chatId === h.chatId && fe(x);
648
+ x(y) && M.current?.chatId === u.chatId && de(D);
639
649
  } catch {
640
650
  }
641
- ke();
651
+ Ce();
642
652
  }
653
+ return !1;
643
654
  } finally {
644
- ce(A), S(_) && K(!1);
655
+ le(w), x(y) && Y(!1);
645
656
  }
646
- }, at = async (r = y.current) => {
647
- if (!r || J) return;
648
- const h = b.current, _ = ne();
649
- K(!0), X(void 0);
657
+ }, et = async (r = M.current) => {
658
+ if (!r || G) return !1;
659
+ const u = A.current, y = ee();
660
+ Y(!0), Q(void 0);
650
661
  try {
651
- if (await t.deleteConversation(
662
+ return await t.deleteConversation(
652
663
  e,
653
664
  { chatId: r.chatId, expectedRevision: r.revision },
654
- { signal: _.signal }
655
- ), !S(h)) return;
656
- y.current?.chatId === r.chatId && (w.current += 1, Ce(), fe(void 0), p(he())), await ke();
657
- } catch (A) {
658
- S(h) && Q(A);
665
+ { signal: y.signal }
666
+ ), x(u) ? (we(), ye(r.chatId), M.current?.chatId === r.chatId && (B.current += 1, be(), de(void 0), f(fe())), !0) : !1;
667
+ } catch (w) {
668
+ return x(u) && te(w), !1;
659
669
  } finally {
660
- ce(_), S(h) && K(!1);
670
+ le(y), x(u) && Y(!1);
661
671
  }
662
- }, Pe = async (r, h, _ = "", A = "") => {
663
- const M = y.current;
664
- if (!M || !r.persistent || !t.setFeedback || pe.includes(r.id))
672
+ }, xe = async (r, u, y = "", w = "") => {
673
+ const C = M.current;
674
+ if (!C || !r.persistent || !t.setFeedback || F.includes(r.id))
665
675
  return;
666
- const x = {
667
- chatId: M.chatId,
676
+ const D = {
677
+ chatId: C.chatId,
668
678
  messageId: r.id,
669
- rating: h,
670
- ..._ ? { reason: _ } : {},
671
- ...A ? { comment: A } : {}
672
- }, I = De.current.get(r.id), { requestId: W, ...z } = I ?? {
679
+ rating: u,
680
+ ...y ? { reason: y } : {},
681
+ ...w ? { comment: w } : {}
682
+ }, _ = Re.current.get(r.id), { requestId: Z, ...O } = _ ?? {
673
683
  requestId: ""
674
- }, B = I && JSON.stringify(z) === JSON.stringify(x) ? I : { ...x, requestId: We() };
675
- De.current.set(r.id, B);
676
- const ge = b.current, Ke = w.current, Ve = ne();
677
- Me((ue) => [...ue, r.id]), X(void 0);
684
+ }, H = _ && JSON.stringify(O) === JSON.stringify(D) ? _ : { ...D, requestId: Pe() };
685
+ Re.current.set(r.id, H);
686
+ const Ie = A.current, Le = B.current, tt = ee();
687
+ ne((he) => [...he, r.id]), Q(void 0);
678
688
  try {
679
- const ue = await t.setFeedback(e, B, {
680
- signal: Ve.signal
689
+ const he = await t.setFeedback(e, H, {
690
+ signal: tt.signal
681
691
  });
682
- return !S(ge) || Ke !== w.current || De.current.get(r.id) !== B ? void 0 : (p((Be) => ({
683
- ...Be,
684
- messages: Be.messages.map(
685
- (_e) => _e.id === r.id && ue.revision >= (_e.feedback?.revision ?? 0) ? { ..._e, feedback: ue } : _e
692
+ return !x(Ie) || Le !== B.current || Re.current.get(r.id) !== H ? void 0 : (f((De) => ({
693
+ ...De,
694
+ messages: De.messages.map(
695
+ (m) => m.id === r.id && he.revision >= (m.feedback?.revision ?? 0) ? { ...m, feedback: he } : m
686
696
  )
687
- })), De.current.delete(r.id), !0);
688
- } catch (ue) {
689
- return S(ge) && Ke === w.current && Q(ue), !1;
697
+ })), Re.current.delete(r.id), !0);
698
+ } catch (he) {
699
+ return x(Ie) && Le === B.current && te(he), !1;
690
700
  } finally {
691
- ce(Ve), S(ge) && Me((ue) => ue.filter((Be) => Be !== r.id));
701
+ le(tt), x(Ie) && ne((he) => he.filter((De) => De !== r.id));
692
702
  }
693
- }, nt = async () => {
694
- if (!y.current || !u || re) return;
695
- const r = b.current, h = w.current, _ = y.current, A = ne();
696
- E(!0);
703
+ }, dt = async () => {
704
+ if (!M.current || !p || q) return;
705
+ const r = A.current, u = B.current, y = M.current, w = ee();
706
+ I(!0);
697
707
  try {
698
- const M = await t.loadConversation(e, {
699
- threadId: _.chatId,
700
- cursor: j,
701
- signal: A.signal
708
+ const C = await t.loadConversation(e, {
709
+ threadId: y.chatId,
710
+ cursor: R,
711
+ signal: w.signal
702
712
  });
703
- if (!S(r) || h !== w.current) return;
704
- const x = he(M), I = [
713
+ if (!x(r) || u !== B.current) return;
714
+ const D = fe(C), _ = [
705
715
  ...new Map(
706
- [...f.current.messages, ...x.messages].map((B) => [
707
- B.id,
708
- B
716
+ [...b.current.messages, ...D.messages].map((H) => [
717
+ H.id,
718
+ H
709
719
  ])
710
720
  ).values()
711
721
  ];
712
- let W = 0;
713
- const z = [];
714
- for (const B of I.slice(-200).reverse()) {
715
- if (W += [...B.content].length, W > 1e6) break;
716
- z.unshift(B);
722
+ let Z = 0;
723
+ const O = [];
724
+ for (const H of _.slice(-200).reverse()) {
725
+ if (Z += [...H.content].length, Z > 1e6) break;
726
+ O.unshift(H);
717
727
  }
718
- z.length < I.length && L(!0), p((B) => ({ ...B, messages: z })), v(M.nextCursor ?? j), l(M.hasMore ?? !1), Qe(M.messages, _.chatId, h, r);
719
- } catch (M) {
720
- S(r) && Q(M);
728
+ O.length < _.length && k(!0), f((H) => ({ ...H, messages: O })), P(C.nextCursor ?? R), n(C.hasMore ?? !1), Oe(C.messages, y.chatId, u, r);
729
+ } catch (C) {
730
+ x(r) && te(C);
721
731
  } finally {
722
- ce(A), S(r) && E(!1);
732
+ le(w), x(r) && I(!1);
723
733
  }
724
734
  };
725
- ae(() => (b.current += 1, o.current = i, Z.current = void 0, te.current = void 0, De.current.clear(), fe(void 0), $([]), ee(""), p(he()), X(void 0), E(n), K(!1), oe([]), Me([]), n && ke(), () => {
726
- b.current += 1, w.current += 1;
727
- for (const r of Te.current) r.abort();
728
- Te.current.clear(), Y.current.clear();
729
- }), [n, i, t]);
730
- const $e = o.current === i;
735
+ ie(() => (A.current += 1, c.current = i, ae.current = void 0, ge.current = void 0, Re.current.clear(), de(void 0), L([]), g(""), f(fe()), Q(void 0), I(s), Y(!1), oe([]), ne([]), s && Ce(), () => {
736
+ A.current += 1, B.current += 1;
737
+ for (const r of ce.current) r.abort();
738
+ ce.current.clear(), V.current.clear();
739
+ }), [s, i, t]);
740
+ const Se = c.current === i;
731
741
  return {
732
- enabled: n,
733
- state: $e ? d : he(),
734
- setState: p,
735
- chats: $e ? k : [],
736
- chat: $e ? O : void 0,
737
- listCursor: V,
738
- historyMore: u,
739
- historyTruncated: T,
740
- loading: !$e || re,
741
- busy: J,
742
- error: $e ? D : void 0,
743
- cancelling: ie,
744
- feedbackBusy: pe,
745
- refresh: ke,
746
- select: de,
747
- create: et,
748
- ensureChat: ve,
749
- send: tt,
750
- retry: Ee,
751
- stop: Se,
752
- update: xe,
753
- remove: at,
754
- feedback: Pe,
755
- moreHistory: nt,
756
- setError: X
742
+ enabled: s,
743
+ state: Se ? d : fe(),
744
+ setState: f,
745
+ chats: Se ? $ : [],
746
+ chat: Se ? T : void 0,
747
+ listCursor: U,
748
+ historyMore: p,
749
+ historyTruncated: v,
750
+ loading: !Se || q,
751
+ busy: G,
752
+ error: Se ? z : void 0,
753
+ cancelling: ve,
754
+ feedbackBusy: F,
755
+ refresh: Ce,
756
+ select: He,
757
+ create: Xe,
758
+ ensureChat: Ee,
759
+ send: Ge,
760
+ retry: Ye,
761
+ stop: Je,
762
+ update: Qe,
763
+ remove: et,
764
+ feedback: xe,
765
+ moreHistory: dt,
766
+ setError: Q
757
767
  };
758
768
  }
759
- const Da = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
769
+ const wa = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
760
770
  /* @__PURE__ */ a("path", { d: "M5 5.5h14v10H9l-4 3v-13Z" }),
761
771
  /* @__PURE__ */ a("path", { d: "M8 9h8M8 12h6" })
762
- ] }), Pa = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "M12 5v14M5 12h14" }) });
763
- function Fa({
772
+ ] }), Ia = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "M12 5v14M5 12h14" }) }), Aa = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
773
+ /* @__PURE__ */ a("path", { d: "m4.5 16.8-.7 3.7 3.7-.7L18 9.3l-3-3L4.5 16.8Z" }),
774
+ /* @__PURE__ */ a("path", { d: "m13.8 7.5 3 3" })
775
+ ] }), Ma = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "M5.5 7.5h13M9.5 7.5V5.7h5v1.8M8 10.5v6M12 10.5v6M16 10.5v6M7 7.5l.7 12h8.6l.7-12" }) }), St = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "m5 12.5 4.5 4.5L19 7.5" }) }), Lt = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "m6 6 12 12M18 6 6 18" }) }), Na = ({
776
+ anchor: e,
777
+ label: t,
778
+ onDismiss: s
779
+ }) => {
780
+ const [i, o] = N();
781
+ if (gt(() => {
782
+ const d = () => {
783
+ if (!e.isConnected) {
784
+ s();
785
+ return;
786
+ }
787
+ const h = e.getBoundingClientRect(), b = h.top >= 48 ? "above" : "below";
788
+ o({
789
+ left: h.left + h.width / 2,
790
+ placement: b,
791
+ top: b === "above" ? h.top - 8 : h.bottom + 8
792
+ });
793
+ };
794
+ return d(), window.addEventListener("resize", d), document.addEventListener("scroll", d, !0), () => {
795
+ window.removeEventListener("resize", d), document.removeEventListener("scroll", d, !0);
796
+ };
797
+ }, [e, s]), !i || typeof document > "u") return null;
798
+ const c = e.closest(".make-ai-assistant") ?? document.body;
799
+ return la(
800
+ /* @__PURE__ */ a(
801
+ "span",
802
+ {
803
+ className: "make-ai-assistant__conversation-tooltip",
804
+ "data-placement": i.placement,
805
+ role: "tooltip",
806
+ style: { left: i.left, top: i.top },
807
+ children: t
808
+ }
809
+ ),
810
+ c
811
+ );
812
+ }, Ca = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
813
+ /* @__PURE__ */ a("path", { d: "M7.5 10.5v9H4.8a1.8 1.8 0 0 1-1.8-1.8v-5.4a1.8 1.8 0 0 1 1.8-1.8h2.7Z" }),
814
+ /* @__PURE__ */ a("path", { d: "M7.5 19.5h8.1a2.4 2.4 0 0 0 2.3-1.8l1.4-5.4a1.5 1.5 0 0 0-1.5-1.8h-4.1l.7-3.4A2.4 2.4 0 0 0 12 4.2L7.5 10.5Z" })
815
+ ] }), Ta = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
816
+ /* @__PURE__ */ a("path", { d: "M7.5 13.5v-9H4.8A1.8 1.8 0 0 0 3 6.3v5.4a1.8 1.8 0 0 0 1.8 1.8h2.7Z" }),
817
+ /* @__PURE__ */ a("path", { d: "M7.5 4.5h8.1a2.4 2.4 0 0 1 2.3 1.8l1.4 5.4a1.5 1.5 0 0 1-1.5 1.8h-4.1l.7 3.4A2.4 2.4 0 0 1 12 19.8l-4.5-6.3Z" })
818
+ ] });
819
+ function Ra({
764
820
  id: e,
765
821
  manager: t,
766
- onDismiss: n,
822
+ onDismiss: s,
767
823
  onNewConversation: i,
768
- triggerRef: s
824
+ triggerRef: o
769
825
  }) {
770
- const [o, d] = N(""), [g, f] = N(!1), p = C(null);
771
- return ae(() => {
772
- d(t.chat?.title ?? ""), f(!1);
773
- }, [t.chat?.chatId, t.chat?.title]), ae(() => {
774
- const k = ($) => {
775
- const O = $.target;
776
- O instanceof Node && (p.current?.contains(O) || s.current?.contains(O) || n());
826
+ const [c, d] = N(), [h, b] = N(""), [f, $] = N(), [L, T] = N(), j = S(null), M = (n, v) => {
827
+ T(
828
+ (k) => k?.anchor === v && k.label === n ? k : { anchor: v, label: n }
829
+ );
830
+ }, U = (n) => {
831
+ T(
832
+ (v) => v?.anchor === n ? void 0 : v
833
+ );
834
+ }, g = (n) => ({
835
+ "data-tooltip": n,
836
+ onBlur: (v) => U(v.currentTarget),
837
+ onFocus: (v) => M(n, v.currentTarget),
838
+ onPointerEnter: (v) => M(n, v.currentTarget),
839
+ onPointerLeave: (v) => U(v.currentTarget)
840
+ }), R = () => {
841
+ d(void 0), b("");
842
+ }, P = async (n) => {
843
+ const v = h.trim();
844
+ v && await t.update({ title: v }, n) && R();
845
+ }, p = async (n) => {
846
+ await t.remove(n) && $(void 0);
847
+ };
848
+ return ie(() => {
849
+ const n = (v) => {
850
+ const k = v.target;
851
+ k instanceof Node && (j.current?.contains(k) || o.current?.contains(k) || s());
777
852
  };
778
- return document.addEventListener("pointerdown", k), () => {
779
- document.removeEventListener("pointerdown", k);
853
+ return document.addEventListener("pointerdown", n), () => {
854
+ document.removeEventListener("pointerdown", n);
780
855
  };
781
- }, [n, s]), /* @__PURE__ */ c(
856
+ }, [s, o]), /* @__PURE__ */ l(
782
857
  "div",
783
858
  {
784
859
  "aria-label": "任务列表",
785
860
  className: "make-ai-assistant__conversation-controls",
786
861
  id: e,
787
- ref: p,
862
+ ref: j,
788
863
  role: "dialog",
789
864
  children: [
790
- /* @__PURE__ */ c("div", { className: "make-ai-assistant__conversation-heading", children: [
865
+ /* @__PURE__ */ l("div", { className: "make-ai-assistant__conversation-heading", children: [
791
866
  /* @__PURE__ */ a("span", { children: "最近对话" }),
792
867
  /* @__PURE__ */ a(
793
868
  "button",
@@ -803,47 +878,172 @@ function Fa({
803
878
  }
804
879
  )
805
880
  ] }),
806
- /* @__PURE__ */ c(
881
+ /* @__PURE__ */ l(
807
882
  "nav",
808
883
  {
809
884
  "aria-label": "对话列表",
810
885
  className: "make-ai-assistant__conversation-list",
811
886
  children: [
812
- t.chats.map((k) => /* @__PURE__ */ c(
813
- "div",
814
- {
815
- className: "make-ai-assistant__conversation-row",
816
- children: [
817
- /* @__PURE__ */ c(
818
- "button",
819
- {
820
- type: "button",
821
- "aria-pressed": t.chat?.chatId === k.chatId,
822
- onClick: () => {
823
- n(), t.select(k);
824
- },
825
- children: [
826
- /* @__PURE__ */ a(Da, {}),
827
- /* @__PURE__ */ a("span", { children: k.title || "未命名对话" })
828
- ]
829
- }
830
- ),
831
- /* @__PURE__ */ a(
832
- "button",
833
- {
834
- type: "button",
835
- disabled: t.busy,
836
- "aria-label": `${k.pinned ? "取消置顶" : "置顶"} ${k.title}`,
837
- onClick: () => {
838
- t.update({ pinned: !k.pinned }, k);
839
- },
840
- children: k.pinned ? "★" : "☆"
841
- }
842
- )
843
- ]
844
- },
845
- k.chatId
846
- )),
887
+ t.chats.map((n) => {
888
+ const v = c === n.chatId, k = f === n.chatId, q = n.title || "未命名对话";
889
+ return /* @__PURE__ */ l(
890
+ "div",
891
+ {
892
+ className: "make-ai-assistant__conversation-row",
893
+ "data-editing": v || k || void 0,
894
+ children: [
895
+ k ? /* @__PURE__ */ l(
896
+ "div",
897
+ {
898
+ "aria-label": "确认删除对话",
899
+ className: "make-ai-assistant__conversation-delete-confirmation",
900
+ role: "group",
901
+ children: [
902
+ /* @__PURE__ */ l("span", { children: [
903
+ "删除“",
904
+ q,
905
+ "”?"
906
+ ] }),
907
+ /* @__PURE__ */ a(
908
+ "button",
909
+ {
910
+ "aria-label": `确认删除:${q}`,
911
+ className: "make-ai-assistant__conversation-row-action make-ai-assistant__conversation-row-action--danger",
912
+ disabled: t.busy,
913
+ type: "button",
914
+ ...g("确认删除"),
915
+ onClick: () => {
916
+ p(n);
917
+ },
918
+ children: /* @__PURE__ */ a(St, {})
919
+ }
920
+ ),
921
+ /* @__PURE__ */ a(
922
+ "button",
923
+ {
924
+ "aria-label": `取消删除:${q}`,
925
+ className: "make-ai-assistant__conversation-row-action",
926
+ disabled: t.busy,
927
+ type: "button",
928
+ ...g("取消"),
929
+ onClick: () => $(void 0),
930
+ children: /* @__PURE__ */ a(Lt, {})
931
+ }
932
+ )
933
+ ]
934
+ }
935
+ ) : v ? /* @__PURE__ */ a(
936
+ "input",
937
+ {
938
+ "aria-label": "对话标题",
939
+ autoFocus: !0,
940
+ className: "make-ai-assistant__conversation-row-title-input",
941
+ disabled: t.busy,
942
+ maxLength: 255,
943
+ value: h,
944
+ onChange: (I) => b(I.currentTarget.value),
945
+ onKeyDown: (I) => {
946
+ I.nativeEvent.isComposing || (I.key === "Escape" && (I.preventDefault(), R()), I.key === "Enter" && (I.preventDefault(), P(n)));
947
+ }
948
+ }
949
+ ) : /* @__PURE__ */ l(
950
+ "button",
951
+ {
952
+ "aria-pressed": t.chat?.chatId === n.chatId,
953
+ className: "make-ai-assistant__conversation-row-select",
954
+ type: "button",
955
+ onClick: () => {
956
+ s(), t.select(n);
957
+ },
958
+ children: [
959
+ /* @__PURE__ */ a(wa, {}),
960
+ /* @__PURE__ */ a("span", { children: q })
961
+ ]
962
+ }
963
+ ),
964
+ v ? /* @__PURE__ */ l(
965
+ "div",
966
+ {
967
+ "aria-label": "修改标题操作",
968
+ className: "make-ai-assistant__conversation-row-actions",
969
+ role: "group",
970
+ children: [
971
+ /* @__PURE__ */ a(
972
+ "button",
973
+ {
974
+ "aria-label": "确认修改标题",
975
+ className: "make-ai-assistant__conversation-row-action",
976
+ disabled: t.busy || !h.trim(),
977
+ type: "button",
978
+ ...g("保存标题"),
979
+ onClick: () => {
980
+ P(n);
981
+ },
982
+ children: /* @__PURE__ */ a(St, {})
983
+ }
984
+ ),
985
+ /* @__PURE__ */ a(
986
+ "button",
987
+ {
988
+ "aria-label": "取消修改标题",
989
+ className: "make-ai-assistant__conversation-row-action",
990
+ disabled: t.busy,
991
+ type: "button",
992
+ ...g("取消"),
993
+ onClick: R,
994
+ children: /* @__PURE__ */ a(Lt, {})
995
+ }
996
+ )
997
+ ]
998
+ }
999
+ ) : k ? null : /* @__PURE__ */ l("div", { className: "make-ai-assistant__conversation-row-actions", children: [
1000
+ /* @__PURE__ */ a(
1001
+ "button",
1002
+ {
1003
+ "aria-label": `${n.pinned ? "取消置顶" : "置顶"} ${q}`,
1004
+ className: "make-ai-assistant__conversation-row-pin",
1005
+ disabled: t.busy,
1006
+ type: "button",
1007
+ onClick: () => {
1008
+ t.update({ pinned: !n.pinned }, n);
1009
+ },
1010
+ children: n.pinned ? "★" : "☆"
1011
+ }
1012
+ ),
1013
+ /* @__PURE__ */ a(
1014
+ "button",
1015
+ {
1016
+ "aria-label": `修改标题:${q}`,
1017
+ className: "make-ai-assistant__conversation-row-action",
1018
+ disabled: t.busy,
1019
+ type: "button",
1020
+ ...g("修改标题"),
1021
+ onClick: () => {
1022
+ $(void 0), d(n.chatId), b(n.title);
1023
+ },
1024
+ children: /* @__PURE__ */ a(Aa, {})
1025
+ }
1026
+ ),
1027
+ /* @__PURE__ */ a(
1028
+ "button",
1029
+ {
1030
+ "aria-label": `删除:${q}`,
1031
+ className: "make-ai-assistant__conversation-row-action make-ai-assistant__conversation-row-action--danger",
1032
+ disabled: t.busy,
1033
+ type: "button",
1034
+ ...g("删除"),
1035
+ onClick: () => {
1036
+ R(), $(n.chatId);
1037
+ },
1038
+ children: /* @__PURE__ */ a(Ma, {})
1039
+ }
1040
+ )
1041
+ ] })
1042
+ ]
1043
+ },
1044
+ n.chatId
1045
+ );
1046
+ }),
847
1047
  !t.loading && !t.chats.length ? /* @__PURE__ */ a("p", { children: "暂无对话,发送消息即可新建" }) : null,
848
1048
  t.listCursor ? /* @__PURE__ */ a(
849
1049
  "button",
@@ -859,180 +1059,166 @@ function Fa({
859
1059
  ]
860
1060
  }
861
1061
  ),
862
- t.chat ? /* @__PURE__ */ c("details", { className: "make-ai-assistant__conversation-management", children: [
863
- /* @__PURE__ */ a("summary", { children: "管理当前对话" }),
864
- /* @__PURE__ */ c("div", { className: "make-ai-assistant__conversation-actions", children: [
865
- /* @__PURE__ */ a(
866
- "input",
867
- {
868
- "aria-label": "对话标题",
869
- maxLength: 255,
870
- value: o,
871
- onChange: (k) => d(k.currentTarget.value)
872
- }
873
- ),
874
- /* @__PURE__ */ a(
875
- "button",
876
- {
877
- type: "button",
878
- disabled: t.busy || !o.trim(),
879
- onClick: () => {
880
- t.update({ title: o });
881
- },
882
- children: "保存标题"
883
- }
884
- ),
885
- /* @__PURE__ */ a(
886
- "button",
887
- {
888
- type: "button",
889
- disabled: t.busy,
890
- onClick: () => f(!0),
891
- children: "删除对话"
892
- }
893
- ),
894
- g ? /* @__PURE__ */ c("div", { role: "group", "aria-label": "确认删除对话", children: [
895
- /* @__PURE__ */ c("span", { children: [
896
- "删除“",
897
- t.chat.title,
898
- "”?"
899
- ] }),
900
- /* @__PURE__ */ a(
901
- "button",
902
- {
903
- type: "button",
904
- disabled: t.busy,
905
- onClick: () => {
906
- f(!1), t.remove();
907
- },
908
- children: "确认删除"
909
- }
910
- ),
911
- /* @__PURE__ */ a("button", { type: "button", onClick: () => f(!1), children: "保留" })
912
- ] }) : null,
913
- t.historyMore ? /* @__PURE__ */ a(
914
- "button",
915
- {
916
- type: "button",
917
- disabled: t.loading,
918
- onClick: () => {
919
- t.moreHistory();
920
- },
921
- children: "继续加载历史"
922
- }
923
- ) : null,
924
- t.historyTruncated || t.state.historyTruncated ? /* @__PURE__ */ a("p", { children: "当前展示有界消息窗口,可重新选择对话从头读取。" }) : null
925
- ] })
1062
+ t.chat && (t.historyMore || t.historyTruncated || t.state.historyTruncated) ? /* @__PURE__ */ l("div", { className: "make-ai-assistant__conversation-history-actions", children: [
1063
+ t.historyMore ? /* @__PURE__ */ a(
1064
+ "button",
1065
+ {
1066
+ type: "button",
1067
+ disabled: t.loading,
1068
+ onClick: () => {
1069
+ t.moreHistory();
1070
+ },
1071
+ children: "继续加载历史"
1072
+ }
1073
+ ) : null,
1074
+ t.historyTruncated || t.state.historyTruncated ? /* @__PURE__ */ a("p", { children: "当前展示有界消息窗口,可重新选择对话从头读取。" }) : null
926
1075
  ] }) : null,
927
- t.error ? /* @__PURE__ */ c("div", { className: "make-ai-assistant__conversation-error", role: "alert", children: [
1076
+ t.error ? /* @__PURE__ */ l("div", { className: "make-ai-assistant__conversation-error", role: "alert", children: [
928
1077
  /* @__PURE__ */ a("span", { children: t.error }),
929
1078
  /* @__PURE__ */ a("button", { type: "button", onClick: () => {
930
1079
  t.retry();
931
1080
  }, children: "恢复对话" })
932
1081
  ] }) : null,
933
- i ? /* @__PURE__ */ c(
1082
+ i ? /* @__PURE__ */ l(
934
1083
  "button",
935
1084
  {
936
1085
  className: "make-ai-assistant__conversation-new",
937
1086
  type: "button",
938
1087
  onClick: i,
939
1088
  children: [
940
- /* @__PURE__ */ a(Pa, {}),
1089
+ /* @__PURE__ */ a(Ia, {}),
941
1090
  /* @__PURE__ */ a("span", { children: "新建对话" })
942
1091
  ]
943
1092
  }
1093
+ ) : null,
1094
+ L ? /* @__PURE__ */ a(
1095
+ Na,
1096
+ {
1097
+ anchor: L.anchor,
1098
+ label: L.label,
1099
+ onDismiss: () => T(void 0)
1100
+ }
944
1101
  ) : null
945
1102
  ]
946
1103
  }
947
1104
  );
948
1105
  }
949
- function Ba({
1106
+ function Ea({
950
1107
  message: e,
951
1108
  manager: t
952
1109
  }) {
953
- const [n, i] = N(!1), [s, o] = N(""), [d, g] = N(""), f = t.feedbackBusy.includes(e.id);
1110
+ const [s, i] = N(!1), [o, c] = N(""), [d, h] = N(""), b = t.feedbackBusy.includes(e.id);
954
1111
  if (!e.persistent || e.role !== "assistant" || e.intermediate)
955
1112
  return null;
956
- const p = e.feedback?.rating ?? "none";
957
- return /* @__PURE__ */ c("div", { className: "make-ai-assistant__feedback", "aria-label": "回答反馈", children: [
958
- /* @__PURE__ */ a(
959
- "button",
960
- {
961
- type: "button",
962
- "aria-label": "点赞",
963
- "aria-pressed": p === "like",
964
- disabled: f,
965
- onClick: () => {
966
- t.feedback(e, p === "like" ? "none" : "like");
967
- },
968
- children: ""
969
- }
970
- ),
971
- /* @__PURE__ */ a(
972
- "button",
973
- {
974
- type: "button",
975
- "aria-label": "点踩",
976
- "aria-pressed": p === "dislike",
977
- disabled: f,
978
- onClick: () => {
979
- if (p === "dislike") {
980
- t.feedback(e, "none");
981
- return;
1113
+ const f = e.feedback?.rating ?? "none";
1114
+ return /* @__PURE__ */ l(
1115
+ "div",
1116
+ {
1117
+ "aria-label": "回答反馈",
1118
+ className: "make-ai-assistant__feedback",
1119
+ role: "group",
1120
+ children: [
1121
+ /* @__PURE__ */ a(
1122
+ "button",
1123
+ {
1124
+ type: "button",
1125
+ "aria-label": "喜欢",
1126
+ "aria-pressed": f === "like",
1127
+ className: "make-ai-assistant__reply-action make-ai-assistant__reply-feedback-action",
1128
+ "data-tooltip": "喜欢",
1129
+ disabled: b,
1130
+ onClick: () => {
1131
+ t.feedback(e, f === "like" ? "none" : "like");
1132
+ },
1133
+ children: /* @__PURE__ */ a(Ca, {})
982
1134
  }
983
- o(e.feedback?.reason ?? ""), g(e.feedback?.comment ?? ""), i(!0);
984
- },
985
- children: ""
986
- }
987
- ),
988
- p === "dislike" ? /* @__PURE__ */ a(
989
- "button",
990
- {
991
- type: "button",
992
- disabled: f,
993
- onClick: () => {
994
- o(e.feedback?.reason ?? ""), g(e.feedback?.comment ?? ""), i(!0);
995
- },
996
- children: "修改反馈"
997
- }
998
- ) : null,
999
- n ? /* @__PURE__ */ c(
1000
- "form",
1001
- {
1002
- onSubmit: (k) => {
1003
- k.preventDefault(), t.feedback(e, "dislike", s, d).then(($) => {
1004
- $ && i(!1);
1005
- });
1006
- },
1007
- children: [
1008
- /* @__PURE__ */ a(
1009
- "input",
1010
- {
1011
- "aria-label": "反馈原因",
1012
- maxLength: 128,
1013
- value: s,
1014
- onChange: (k) => o(k.currentTarget.value),
1015
- placeholder: "原因(可选)"
1016
- }
1017
- ),
1018
- /* @__PURE__ */ a(
1019
- "textarea",
1020
- {
1021
- "aria-label": "反馈说明",
1022
- maxLength: 4e3,
1023
- value: d,
1024
- onChange: (k) => g(k.currentTarget.value),
1025
- placeholder: "补充说明(可选)"
1026
- }
1027
- ),
1028
- /* @__PURE__ */ a("button", { type: "submit", disabled: f, children: "提交反馈" }),
1029
- /* @__PURE__ */ a("button", { type: "button", onClick: () => i(!1), children: "取消" })
1030
- ]
1031
- }
1032
- ) : null
1033
- ] });
1135
+ ),
1136
+ /* @__PURE__ */ a(
1137
+ "button",
1138
+ {
1139
+ type: "button",
1140
+ "aria-label": "不喜欢",
1141
+ "aria-pressed": f === "dislike",
1142
+ className: "make-ai-assistant__reply-action make-ai-assistant__reply-feedback-action",
1143
+ "data-tooltip": "不喜欢",
1144
+ disabled: b,
1145
+ onClick: () => {
1146
+ if (f === "dislike") {
1147
+ t.feedback(e, "none");
1148
+ return;
1149
+ }
1150
+ c(e.feedback?.reason ?? ""), h(e.feedback?.comment ?? ""), i(!0);
1151
+ },
1152
+ children: /* @__PURE__ */ a(Ta, {})
1153
+ }
1154
+ ),
1155
+ f === "dislike" ? /* @__PURE__ */ a(
1156
+ "button",
1157
+ {
1158
+ className: "make-ai-assistant__feedback-text-action",
1159
+ type: "button",
1160
+ disabled: b,
1161
+ onClick: () => {
1162
+ c(e.feedback?.reason ?? ""), h(e.feedback?.comment ?? ""), i(!0);
1163
+ },
1164
+ children: "修改反馈"
1165
+ }
1166
+ ) : null,
1167
+ s ? /* @__PURE__ */ l(
1168
+ "form",
1169
+ {
1170
+ onSubmit: ($) => {
1171
+ $.preventDefault(), t.feedback(e, "dislike", o, d).then((L) => {
1172
+ L && i(!1);
1173
+ });
1174
+ },
1175
+ children: [
1176
+ /* @__PURE__ */ a(
1177
+ "input",
1178
+ {
1179
+ "aria-label": "反馈原因",
1180
+ maxLength: 128,
1181
+ value: o,
1182
+ onChange: ($) => c($.currentTarget.value),
1183
+ placeholder: "原因(可选)"
1184
+ }
1185
+ ),
1186
+ /* @__PURE__ */ a(
1187
+ "textarea",
1188
+ {
1189
+ "aria-label": "反馈说明",
1190
+ maxLength: 4e3,
1191
+ value: d,
1192
+ onChange: ($) => h($.currentTarget.value),
1193
+ placeholder: "补充说明(可选)"
1194
+ }
1195
+ ),
1196
+ /* @__PURE__ */ a(
1197
+ "button",
1198
+ {
1199
+ className: "make-ai-assistant__feedback-text-action",
1200
+ type: "submit",
1201
+ disabled: b,
1202
+ children: "提交反馈"
1203
+ }
1204
+ ),
1205
+ /* @__PURE__ */ a(
1206
+ "button",
1207
+ {
1208
+ className: "make-ai-assistant__feedback-text-action",
1209
+ type: "button",
1210
+ onClick: () => i(!1),
1211
+ children: "取消"
1212
+ }
1213
+ )
1214
+ ]
1215
+ }
1216
+ ) : null
1217
+ ]
1218
+ }
1219
+ );
1034
1220
  }
1035
- const Bt = /* @__PURE__ */ new Set([
1221
+ const $t = /* @__PURE__ */ new Set([
1036
1222
  "image/png",
1037
1223
  "image/jpeg",
1038
1224
  "image/webp",
@@ -1045,428 +1231,390 @@ const Bt = /* @__PURE__ */ new Set([
1045
1231
  "video/webm",
1046
1232
  "video/ogg"
1047
1233
  ]);
1048
- function za({
1234
+ function Sa({
1049
1235
  part: e,
1050
1236
  context: t,
1051
- transport: n,
1237
+ transport: s,
1052
1238
  chatId: i
1053
1239
  }) {
1054
- const [s, o] = N(), [d, g] = N(), [f, p] = N(!1), k = C([]), $ = C(void 0);
1055
- ae(
1240
+ const [o, c] = N(), [d, h] = N(), [b, f] = N(!1), $ = S([]), L = S(void 0);
1241
+ ie(
1056
1242
  () => () => {
1057
- $.current?.abort(), k.current.forEach((q) => URL.revokeObjectURL(q));
1243
+ L.current?.abort(), $.current.forEach((j) => URL.revokeObjectURL(j));
1058
1244
  },
1059
1245
  []
1060
1246
  );
1061
- const O = async (q) => {
1062
- if (!n.readContent || f) return;
1063
- const y = new AbortController();
1064
- $.current = y, p(!0), g(void 0);
1247
+ const T = async (j) => {
1248
+ if (!s.readContent || b) return;
1249
+ const M = new AbortController();
1250
+ L.current = M, f(!0), h(void 0);
1065
1251
  try {
1066
- const V = await n.readContent(
1252
+ const U = await s.readContent(
1067
1253
  t,
1068
1254
  { chatId: i, contentRef: e.media.contentRef },
1069
- { signal: y.signal }
1255
+ { signal: M.signal }
1070
1256
  );
1071
- if (y.signal.aborted) return;
1072
- const ee = new Blob([new Uint8Array(V).buffer], {
1073
- type: q && Bt.has(e.media.contentType) ? e.media.contentType : "application/octet-stream"
1074
- }), j = URL.createObjectURL(ee);
1075
- if (k.current.push(j), q) o(j);
1257
+ if (M.signal.aborted) return;
1258
+ const g = new Blob([new Uint8Array(U).buffer], {
1259
+ type: j && $t.has(e.media.contentType) ? e.media.contentType : "application/octet-stream"
1260
+ }), R = URL.createObjectURL(g);
1261
+ if ($.current.push(R), j) c(R);
1076
1262
  else {
1077
- const v = document.createElement("a");
1078
- v.href = j, v.download = e.name ?? "attachment", v.click();
1263
+ const P = document.createElement("a");
1264
+ P.href = R, P.download = e.name ?? "attachment", P.click();
1079
1265
  }
1080
- } catch (V) {
1081
- y.signal.aborted || g(_t(V));
1266
+ } catch (U) {
1267
+ M.signal.aborted || h(bt(U));
1082
1268
  } finally {
1083
- y.signal.aborted || p(!1);
1269
+ M.signal.aborted || f(!1);
1084
1270
  }
1085
1271
  };
1086
- return /* @__PURE__ */ c("div", { className: "make-ai-assistant__attachment", children: [
1087
- /* @__PURE__ */ c("span", { children: [
1272
+ return /* @__PURE__ */ l("div", { className: "make-ai-assistant__attachment", children: [
1273
+ /* @__PURE__ */ l("span", { children: [
1088
1274
  e.name ?? "附件",
1089
1275
  " · ",
1090
1276
  e.media.sizeBytes,
1091
1277
  " 字节"
1092
1278
  ] }),
1093
- /* @__PURE__ */ a("button", { type: "button", disabled: f, onClick: () => {
1094
- O(!1);
1095
- }, children: "下载附件" }),
1096
- Bt.has(e.media.contentType) ? /* @__PURE__ */ a("button", { type: "button", disabled: f, onClick: () => {
1097
- O(!0);
1098
- }, children: "预览附件" }) : null,
1279
+ s.readContent ? /* @__PURE__ */ l(Ne, { children: [
1280
+ /* @__PURE__ */ a("button", { type: "button", disabled: b, onClick: () => {
1281
+ T(!1);
1282
+ }, children: "下载附件" }),
1283
+ $t.has(e.media.contentType) ? /* @__PURE__ */ a("button", { type: "button", disabled: b, onClick: () => {
1284
+ T(!0);
1285
+ }, children: "预览附件" }) : null
1286
+ ] }) : null,
1099
1287
  d ? /* @__PURE__ */ a("span", { role: "alert", children: d }) : null,
1100
- s && e.kind === "image" ? /* @__PURE__ */ a("img", { src: s, alt: e.name ?? "附件图片" }) : null,
1101
- s && e.kind === "audio" ? /* @__PURE__ */ a("audio", { src: s, controls: !0 }) : null,
1102
- s && e.kind === "video" ? /* @__PURE__ */ a("video", { src: s, controls: !0 }) : null
1288
+ o && e.kind === "image" ? /* @__PURE__ */ a("img", { src: o, alt: e.name ?? "附件图片" }) : null,
1289
+ o && e.kind === "audio" ? /* @__PURE__ */ a("audio", { src: o, controls: !0 }) : null,
1290
+ o && e.kind === "video" ? /* @__PURE__ */ a("video", { src: o, controls: !0 }) : null
1103
1291
  ] });
1104
1292
  }
1105
- function Ha({
1293
+ function La({
1106
1294
  message: e,
1107
1295
  context: t,
1108
- transport: n,
1296
+ transport: s,
1109
1297
  chatId: i
1110
1298
  }) {
1111
- return /* @__PURE__ */ a(Ae, { children: e.parts?.map(
1112
- (s, o) => s.kind === "text" ? null : /* @__PURE__ */ a(
1113
- za,
1299
+ return /* @__PURE__ */ a(Ne, { children: e.parts?.map(
1300
+ (o, c) => o.kind === "text" ? null : /* @__PURE__ */ a(
1301
+ Sa,
1114
1302
  {
1115
- part: s,
1303
+ part: o,
1116
1304
  context: t,
1117
- transport: n,
1305
+ transport: s,
1118
1306
  chatId: i
1119
1307
  },
1120
- s.id ?? `${e.id}:${o}`
1308
+ o.id ?? `${e.id}:${c}`
1121
1309
  )
1122
1310
  ) });
1123
1311
  }
1124
- const Oa = (e, t) => new Promise((n, i) => {
1125
- const s = new FileReader(), o = () => t.removeEventListener("abort", d), d = () => {
1126
- s.abort(), o(), i(Object.assign(new Error("Read aborted"), { name: "AbortError" }));
1312
+ const Vt = (e) => e.type.split(";")[0].trim().toLowerCase() || "application/octet-stream", $a = (e) => e.startsWith("image/") && e !== "image/svg+xml" ? "image" : e.startsWith("audio/") ? "audio" : e.startsWith("video/") ? "video" : "file", xa = (e) => {
1313
+ const t = Vt(e);
1314
+ if (!(!t.startsWith("image/") || t === "image/svg+xml" || typeof URL > "u" || typeof URL.createObjectURL != "function"))
1315
+ return URL.createObjectURL(e);
1316
+ }, xt = (e) => {
1317
+ e && typeof URL < "u" && typeof URL.revokeObjectURL == "function" && URL.revokeObjectURL(e);
1318
+ }, Da = (e, t) => new Promise((s, i) => {
1319
+ const o = new FileReader(), c = () => t.removeEventListener("abort", d), d = () => {
1320
+ o.abort(), c(), i(Object.assign(new Error("Read aborted"), { name: "AbortError" }));
1127
1321
  };
1128
1322
  if (t.aborted) {
1129
1323
  d();
1130
1324
  return;
1131
1325
  }
1132
- t.addEventListener("abort", d, { once: !0 }), s.onload = () => {
1133
- o(), n(new Uint8Array(s.result));
1134
- }, s.onerror = () => {
1135
- o(), i(new Error("无法读取文件"));
1136
- }, s.readAsArrayBuffer(e);
1326
+ t.addEventListener("abort", d, { once: !0 }), o.onload = () => {
1327
+ c(), s(new Uint8Array(o.result));
1328
+ }, o.onerror = () => {
1329
+ c(), i(new Error("无法读取文件"));
1330
+ }, o.readAsArrayBuffer(e);
1137
1331
  });
1138
- function Wa(e, t, n) {
1139
- const [i, s] = N([]), o = C(/* @__PURE__ */ new Map()), d = C(Promise.resolve()), g = t.scopeKey?.(e) ?? e.app.id, f = C(g);
1140
- f.current = g;
1141
- const p = C(void 0), k = n.enabled && t.features?.attachments === !0, $ = (u, l) => {
1142
- !o.current.has(u.draft.id) || u.scope !== f.current || (u.draft = { ...u.draft, ...l }, s([...o.current.values()].map((T) => T.draft)));
1143
- }, O = () => {
1144
- for (const u of o.current.values()) u.controller.abort();
1145
- o.current.clear(), s([]), p.current = void 0, d.current = Promise.resolve();
1332
+ function Ba(e, t, s) {
1333
+ const [i, o] = N([]), c = S(/* @__PURE__ */ new Map()), d = S(Promise.resolve()), h = t.scopeKey?.(e) ?? e.app.id, b = S(h);
1334
+ b.current = h;
1335
+ const f = S(void 0), $ = s.enabled && t.features?.attachments === !0, L = (p, n) => {
1336
+ !c.current.has(p.draft.id) || p.scope !== b.current || (p.draft = { ...p.draft, ...n }, o([...c.current.values()].map((v) => v.draft)));
1337
+ }, T = () => {
1338
+ for (const p of c.current.values())
1339
+ p.controller.abort(), xt(p.draft.previewUrl);
1340
+ c.current.clear(), o([]), f.current = void 0, d.current = Promise.resolve();
1146
1341
  };
1147
- ae(() => (O(), O), [g, t]), ae(() => {
1148
- p.current && n.chat?.chatId !== p.current && O();
1149
- }, [n.chat?.chatId]);
1150
- const q = async (u) => {
1151
- const l = u.controller.signal, T = () => {
1152
- if (l.aborted || u.scope !== f.current || !o.current.has(u.draft.id))
1342
+ ie(() => (T(), T), [h, t]), ie(() => {
1343
+ f.current && s.chat?.chatId !== f.current && T();
1344
+ }, [s.chat?.chatId]);
1345
+ const j = async (p) => {
1346
+ const n = p.controller.signal, v = () => {
1347
+ if (n.aborted || p.scope !== b.current || !c.current.has(p.draft.id))
1153
1348
  throw Object.assign(new Error("Upload aborted"), {
1154
1349
  name: "AbortError"
1155
1350
  });
1156
1351
  };
1157
1352
  try {
1158
- if (T(), u.file.size > 64 << 20) throw new Error("文件不能超过 64 MiB");
1159
- const L = await n.ensureChat();
1160
- T(), p.current = L.chatId;
1161
- const re = u.file.type.split(";")[0].trim().toLowerCase() || "application/octet-stream";
1162
- $(u, { status: "uploading", error: void 0 });
1163
- let E = u.draft.upload ? await t.getUpload(
1353
+ if (v(), p.file.size > 64 << 20) throw new Error("文件不能超过 64 MiB");
1354
+ const k = await s.ensureChat();
1355
+ v(), f.current = k.chatId;
1356
+ const q = Vt(p.file);
1357
+ L(p, { status: "uploading", error: void 0 });
1358
+ let I = p.draft.upload ? await t.getUpload(
1164
1359
  e,
1165
- { chatId: L.chatId, uploadId: u.draft.upload.id },
1166
- { signal: l }
1360
+ { chatId: k.chatId, uploadId: p.draft.upload.id },
1361
+ { signal: n }
1167
1362
  ) : await t.startUpload(
1168
1363
  e,
1169
1364
  {
1170
- chatId: L.chatId,
1171
- fileId: u.draft.fileId,
1172
- name: u.file.name,
1173
- contentType: re,
1174
- sizeBytes: u.file.size
1365
+ chatId: k.chatId,
1366
+ fileId: p.draft.fileId,
1367
+ name: p.file.name,
1368
+ contentType: q,
1369
+ sizeBytes: p.file.size
1175
1370
  },
1176
- { signal: l }
1371
+ { signal: n }
1177
1372
  );
1178
- if (T(), $(u, { upload: E }), E.name !== u.file.name || E.contentType !== re || E.sizeBytes !== u.file.size)
1373
+ if (v(), L(p, { upload: I }), I.name !== p.file.name || I.contentType !== q || I.sizeBytes !== p.file.size)
1179
1374
  throw new Error("上传文件身份不一致");
1180
- if (E.status !== "ready") {
1181
- E = await t.getUpload(
1375
+ if (I.status !== "ready") {
1376
+ I = await t.getUpload(
1182
1377
  e,
1183
- { chatId: L.chatId, uploadId: E.id },
1184
- { signal: l }
1185
- ), T();
1186
- const J = new Set(E.completedParts), K = Math.ceil(u.file.size / E.partSize);
1187
- for (let D = 0; D < K; D += 1) {
1188
- if (T(), !J.has(D)) {
1189
- const X = await Oa(
1190
- u.file.slice(
1191
- D * E.partSize,
1192
- Math.min(u.file.size, (D + 1) * E.partSize)
1378
+ { chatId: k.chatId, uploadId: I.id },
1379
+ { signal: n }
1380
+ ), v();
1381
+ const G = new Set(I.completedParts), Y = Math.ceil(p.file.size / I.partSize);
1382
+ for (let z = 0; z < Y; z += 1) {
1383
+ if (v(), !G.has(z)) {
1384
+ const Q = await Da(
1385
+ p.file.slice(
1386
+ z * I.partSize,
1387
+ Math.min(p.file.size, (z + 1) * I.partSize)
1193
1388
  ),
1194
- l
1389
+ n
1195
1390
  );
1196
- T(), await t.uploadPart(
1391
+ v(), await t.uploadPart(
1197
1392
  e,
1198
- { chatId: L.chatId, uploadId: E.id, part: D, bytes: X },
1199
- { signal: l }
1200
- ), T(), J.add(D);
1393
+ { chatId: k.chatId, uploadId: I.id, part: z, bytes: Q },
1394
+ { signal: n }
1395
+ ), v(), G.add(z);
1201
1396
  }
1202
- $(u, { progress: J.size / Math.max(K, 1) });
1397
+ L(p, { progress: G.size / Math.max(Y, 1) });
1203
1398
  }
1204
- $(u, { status: "completing" }), E = await t.completeUpload(
1399
+ L(p, { status: "completing" }), I = await t.completeUpload(
1205
1400
  e,
1206
- { chatId: L.chatId, uploadId: E.id },
1207
- { signal: l }
1208
- ), T();
1401
+ { chatId: k.chatId, uploadId: I.id },
1402
+ { signal: n }
1403
+ ), v();
1209
1404
  }
1210
- if (E.status !== "ready" || !E.content)
1405
+ if (I.status !== "ready" || !I.content)
1211
1406
  throw new Error("上传尚未完成");
1212
- $(u, { status: "ready", progress: 1, upload: E });
1213
- } catch (L) {
1214
- $(u, {
1215
- status: l.aborted ? "paused" : "failed",
1216
- error: l.aborted ? void 0 : _t(L)
1407
+ L(p, { status: "ready", progress: 1, upload: I });
1408
+ } catch (k) {
1409
+ L(p, {
1410
+ status: n.aborted ? "paused" : "failed",
1411
+ error: n.aborted ? void 0 : bt(k)
1217
1412
  });
1218
1413
  }
1219
- }, y = (u) => {
1220
- if (k) {
1221
- if (u.length + o.current.size > 32) {
1222
- n.setError("每条消息最多包含 32 个附件或文本片段");
1414
+ }, M = (p) => {
1415
+ if ($) {
1416
+ if (p.length + c.current.size > 32) {
1417
+ s.setError("每条消息最多包含 32 个附件或文本片段");
1223
1418
  return;
1224
1419
  }
1225
- for (const l of u) {
1226
- const T = {
1227
- id: We(),
1228
- fileId: We(),
1229
- name: l.name,
1230
- size: l.size,
1420
+ for (const n of p) {
1421
+ const v = {
1422
+ id: Pe(),
1423
+ fileId: Pe(),
1424
+ name: n.name,
1425
+ size: n.size,
1231
1426
  status: "queued",
1232
- progress: 0
1233
- }, L = {
1234
- draft: T,
1235
- file: l,
1427
+ progress: 0,
1428
+ previewUrl: xa(n)
1429
+ }, k = {
1430
+ draft: v,
1431
+ file: n,
1236
1432
  controller: new AbortController(),
1237
- scope: g
1433
+ scope: h
1238
1434
  };
1239
- o.current.set(T.id, L), d.current = d.current.then(() => q(L));
1435
+ c.current.set(v.id, k), d.current = d.current.then(() => j(k));
1240
1436
  }
1241
- s([...o.current.values()].map((l) => l.draft));
1437
+ o([...c.current.values()].map((n) => n.draft));
1242
1438
  }
1243
- }, V = (u) => {
1244
- const l = o.current.get(u);
1245
- !l || !["paused", "failed"].includes(l.draft.status) || (l.controller = new AbortController(), $(l, { status: "queued" }), d.current = d.current.then(() => q(l)));
1246
- }, ee = (u) => {
1247
- o.current.get(u)?.controller.abort(), o.current.delete(u), s([...o.current.values()].map((T) => T.draft));
1248
- }, j = (u) => o.current.get(u)?.controller.abort(), v = i.flatMap((u) => {
1249
- const l = u.upload;
1250
- if (u.status !== "ready" || !l?.content) return [];
1251
- const T = l.contentType.startsWith("image/") && l.contentType !== "image/svg+xml" ? "image" : l.contentType.startsWith("audio/") ? "audio" : l.contentType.startsWith("video/") ? "video" : "file";
1439
+ }, U = (p) => {
1440
+ const n = c.current.get(p);
1441
+ !n || !["paused", "failed"].includes(n.draft.status) || (n.controller = new AbortController(), L(n, { status: "queued" }), d.current = d.current.then(() => j(n)));
1442
+ }, g = (p) => {
1443
+ const n = c.current.get(p);
1444
+ n?.controller.abort(), xt(n?.draft.previewUrl), c.current.delete(p), o([...c.current.values()].map((v) => v.draft));
1445
+ }, R = (p) => c.current.get(p)?.controller.abort(), P = i.flatMap((p) => {
1446
+ const n = p.upload;
1447
+ if (p.status !== "ready" || !n?.content) return [];
1448
+ const v = $a(n.contentType);
1252
1449
  return [
1253
1450
  {
1254
- id: u.id,
1255
- kind: T,
1256
- name: l.name,
1451
+ id: p.id,
1452
+ kind: v,
1453
+ name: n.name,
1257
1454
  media: {
1258
- contentRef: l.content.contentRef,
1259
- contentType: l.contentType,
1260
- sizeBytes: l.content.sizeBytes,
1261
- digestSha256: l.content.digestSha256
1455
+ contentRef: n.content.contentRef,
1456
+ contentType: n.contentType,
1457
+ sizeBytes: n.content.sizeBytes,
1458
+ digestSha256: n.content.digestSha256
1262
1459
  }
1263
1460
  }
1264
1461
  ];
1265
1462
  });
1266
1463
  return {
1267
- enabled: k,
1464
+ enabled: $,
1268
1465
  drafts: i,
1269
- parts: v,
1270
- pending: i.some((u) => u.status !== "ready"),
1271
- add: y,
1272
- retry: V,
1273
- remove: ee,
1274
- pause: j,
1275
- clear: O
1466
+ parts: P,
1467
+ pending: i.some((p) => p.status !== "ready"),
1468
+ add: M,
1469
+ retry: U,
1470
+ remove: g,
1471
+ pause: R,
1472
+ clear: T
1276
1473
  };
1277
1474
  }
1278
1475
  function Ua({
1279
1476
  attachments: e,
1280
1477
  onOpenChange: t,
1281
- open: n,
1478
+ open: s,
1282
1479
  triggerRef: i
1283
1480
  }) {
1284
- const s = C(null), o = C(null), d = C(null);
1285
- ae(() => {
1286
- if (!n) return;
1287
- const f = (p) => {
1288
- const k = p.target;
1289
- k instanceof Node && !s.current?.contains(k) && t(!1);
1481
+ const o = S(null), c = S(null);
1482
+ ie(() => {
1483
+ if (!s) return;
1484
+ const h = (b) => {
1485
+ const f = b.target;
1486
+ f instanceof Node && !o.current?.contains(f) && t(!1);
1290
1487
  };
1291
- return document.addEventListener("pointerdown", f), () => {
1292
- document.removeEventListener("pointerdown", f);
1488
+ return document.addEventListener("pointerdown", h), () => {
1489
+ document.removeEventListener("pointerdown", h);
1293
1490
  };
1294
- }, [t, n]);
1295
- const g = (f) => {
1296
- e.add(Array.from(f.files ?? [])), f.value = "", t(!1);
1491
+ }, [t, s]);
1492
+ const d = (h) => {
1493
+ e.add(Array.from(h.files ?? [])), h.value = "", t(!1);
1297
1494
  };
1298
- return /* @__PURE__ */ c("div", { className: "make-ai-assistant__attachment-composer", ref: s, children: [
1495
+ return /* @__PURE__ */ l("div", { className: "make-ai-assistant__attachment-composer", ref: o, children: [
1299
1496
  /* @__PURE__ */ a(
1300
1497
  "button",
1301
1498
  {
1302
- "aria-expanded": n,
1499
+ "aria-expanded": s,
1303
1500
  "aria-haspopup": "menu",
1304
1501
  "aria-label": "添加附件",
1305
1502
  className: "make-ai-assistant__attachment-trigger",
1306
1503
  ref: i,
1307
1504
  title: "添加附件",
1308
1505
  type: "button",
1309
- onClick: () => t(!n),
1506
+ onClick: () => t(!s),
1310
1507
  children: /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "M12 5v14M5 12h14" }) })
1311
1508
  }
1312
1509
  ),
1313
- n ? /* @__PURE__ */ c(
1510
+ s ? /* @__PURE__ */ a(
1314
1511
  "div",
1315
1512
  {
1316
1513
  "aria-label": "附件选项",
1317
1514
  className: "make-ai-assistant__attachment-menu",
1318
1515
  role: "menu",
1319
- children: [
1320
- /* @__PURE__ */ c(
1321
- "button",
1322
- {
1323
- role: "menuitem",
1324
- type: "button",
1325
- onClick: () => o.current?.click(),
1326
- children: [
1327
- /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1328
- /* @__PURE__ */ a("rect", { height: "15", rx: "2", width: "18", x: "3", y: "4.5" }),
1329
- /* @__PURE__ */ a("circle", { cx: "8.5", cy: "9", r: "1.5" }),
1330
- /* @__PURE__ */ a("path", { d: "m5.5 17 4.2-4.2 2.8 2.7 2.2-2.1 3.8 3.6" })
1331
- ] }),
1332
- /* @__PURE__ */ a("span", { children: "上传图片" })
1333
- ]
1334
- }
1335
- ),
1336
- /* @__PURE__ */ c(
1337
- "button",
1338
- {
1339
- role: "menuitem",
1340
- type: "button",
1341
- onClick: () => d.current?.click(),
1342
- children: [
1343
- /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1344
- /* @__PURE__ */ a("path", { d: "M7 3.5h7l4 4V20H7z" }),
1345
- /* @__PURE__ */ a("path", { d: "M14 3.5v4h4M10 12h5M10 15h5" })
1346
- ] }),
1347
- /* @__PURE__ */ a("span", { children: "上传文件" })
1348
- ]
1349
- }
1350
- )
1351
- ]
1516
+ children: /* @__PURE__ */ l(
1517
+ "button",
1518
+ {
1519
+ role: "menuitem",
1520
+ type: "button",
1521
+ onClick: () => c.current?.click(),
1522
+ children: [
1523
+ /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1524
+ /* @__PURE__ */ a("path", { d: "M12 15V4M7.5 8.5 12 4l4.5 4.5" }),
1525
+ /* @__PURE__ */ a("path", { d: "M5 14v5h14v-5" })
1526
+ ] }),
1527
+ /* @__PURE__ */ a("span", { children: "上传文件或图片" })
1528
+ ]
1529
+ }
1530
+ )
1352
1531
  }
1353
1532
  ) : null,
1354
1533
  /* @__PURE__ */ a(
1355
1534
  "input",
1356
1535
  {
1357
- accept: "image/*",
1358
- "aria-label": "上传图片",
1536
+ "aria-label": "上传文件或图片",
1359
1537
  hidden: !0,
1360
1538
  multiple: !0,
1361
- ref: o,
1539
+ ref: c,
1362
1540
  type: "file",
1363
- onChange: (f) => g(f.currentTarget)
1364
- }
1365
- ),
1366
- /* @__PURE__ */ a(
1367
- "input",
1368
- {
1369
- "aria-label": "上传文件",
1370
- hidden: !0,
1371
- multiple: !0,
1372
- ref: d,
1373
- type: "file",
1374
- onChange: (f) => g(f.currentTarget)
1541
+ onChange: (h) => d(h.currentTarget)
1375
1542
  }
1376
1543
  )
1377
1544
  ] });
1378
1545
  }
1379
- function qa({
1546
+ function Fa({
1380
1547
  attachments: e
1381
1548
  }) {
1382
- return e.drafts.length ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__attachment-drafts", "aria-label": "待发送附件", children: /* @__PURE__ */ a("ul", { children: e.drafts.map((t) => /* @__PURE__ */ c("li", { children: [
1383
- /* @__PURE__ */ c("span", { children: [
1384
- t.name,
1385
- " ·",
1386
- " ",
1387
- t.status === "ready" ? "已上传" : t.status === "completing" ? "校验中" : t.status === "paused" ? "已暂停" : t.status === "failed" ? "上传失败" : `${Math.round(t.progress * 100)}%`
1549
+ return e.drafts.length ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__attachment-drafts", "aria-label": "待发送附件", children: /* @__PURE__ */ a("ul", { children: e.drafts.map((t) => /* @__PURE__ */ l("li", { "data-status": t.status, children: [
1550
+ t.previewUrl ? /* @__PURE__ */ a(
1551
+ "img",
1552
+ {
1553
+ alt: "",
1554
+ className: "make-ai-assistant__attachment-draft-preview",
1555
+ src: t.previewUrl
1556
+ }
1557
+ ) : /* @__PURE__ */ a(
1558
+ "span",
1559
+ {
1560
+ "aria-hidden": "true",
1561
+ className: "make-ai-assistant__attachment-draft-file",
1562
+ children: /* @__PURE__ */ l("svg", { viewBox: "0 0 24 24", children: [
1563
+ /* @__PURE__ */ a("path", { d: "M6 3h8l4 4v14H6z" }),
1564
+ /* @__PURE__ */ a("path", { d: "M14 3v5h5M9 13h6M9 16h6" })
1565
+ ] })
1566
+ }
1567
+ ),
1568
+ /* @__PURE__ */ l("span", { className: "make-ai-assistant__attachment-draft-details", children: [
1569
+ /* @__PURE__ */ a("span", { className: "make-ai-assistant__attachment-draft-name", title: t.name, children: t.name }),
1570
+ /* @__PURE__ */ a("span", { className: "make-ai-assistant__attachment-draft-status", children: t.status === "ready" ? "已上传" : t.status === "completing" ? "校验中" : t.status === "paused" ? "已暂停" : t.status === "failed" ? "上传失败" : `${Math.round(t.progress * 100)}%` })
1388
1571
  ] }),
1389
1572
  t.error ? /* @__PURE__ */ a("span", { role: "alert", children: t.error }) : null,
1390
1573
  t.status === "failed" || t.status === "paused" ? /* @__PURE__ */ a("button", { type: "button", onClick: () => e.retry(t.id), children: "重试上传" }) : null,
1391
1574
  t.status === "uploading" ? /* @__PURE__ */ a("button", { type: "button", onClick: () => e.pause(t.id), children: "暂停上传" }) : null,
1392
- /* @__PURE__ */ a("button", { type: "button", onClick: () => e.remove(t.id), children: "移除附件" })
1575
+ /* @__PURE__ */ a(
1576
+ "button",
1577
+ {
1578
+ "aria-label": `移除附件 ${t.name}`,
1579
+ className: "make-ai-assistant__attachment-draft-remove",
1580
+ type: "button",
1581
+ onClick: () => e.remove(t.id),
1582
+ children: /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "m7 7 10 10M17 7 7 17" }) })
1583
+ }
1584
+ )
1393
1585
  ] }, t.id)) }) }) : null;
1394
1586
  }
1395
- const Ka = (e) => `${e}-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, Va = "Make", ja = [
1587
+ const Pa = (e) => `${e}-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, za = "Make", Wa = [
1396
1588
  "总结当前页面数据",
1397
1589
  "找出需要关注的记录",
1398
1590
  "列出我有权限查看的数据对象"
1399
- ], Jt = (e, t) => t ?? `${e?.trim() || Va} AI 助手`, Xa = (e) => e ?? ja, Ya = /^只读分析\s*[·•]\s*/u, Za = (e, t) => e?.trim().replace(Ya, "").trim() || `当前对象:${t ?? "未命名应用"}`, Ga = 480, Qt = 1024, Ja = 0.72, zt = 16, be = 16, Ge = 8, vt = (e, t, n) => Math.min(Math.max(e, Math.min(t, n)), n), Qa = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : void 0, en = (e, t, n) => {
1591
+ ], Zt = (e, t) => t ?? `${e?.trim() || za} AI 助手`, Oa = (e) => e ?? Wa, Ha = 480, Xt = 1024, qa = 0.72, Dt = 16, pt = (e, t, s) => Math.min(Math.max(e, Math.min(t, s)), s), Ka = (e) => typeof e == "number" && Number.isFinite(e) && e > 0 ? e : void 0, ja = (e, t, s) => {
1400
1592
  const i = Math.min(
1401
- Qt,
1402
- n * Ja
1593
+ Xt,
1594
+ s * qa
1403
1595
  );
1404
- return Math.max(e, Math.min(t ?? i, n));
1405
- }, Ht = (e, t, n) => Math.min(Math.max(e, t), Math.max(t, n)), tn = (e, t, n, i) => {
1406
- const s = Math.min(
1407
- Math.max(t.width, 1),
1408
- Math.max(1, i - be * 2)
1409
- ), o = Math.min(
1410
- Math.max(t.height, 1),
1411
- Math.max(1, n - be * 2)
1412
- ), d = e.left + e.width / 2, g = e.top + e.height / 2, p = [
1413
- {
1414
- left: e.right + Ge,
1415
- placement: "right",
1416
- top: g - o / 2
1417
- },
1418
- {
1419
- left: e.left - Ge - s,
1420
- placement: "left",
1421
- top: g - o / 2
1422
- },
1423
- {
1424
- left: d - s / 2,
1425
- placement: "bottom",
1426
- top: e.bottom + Ge
1427
- },
1428
- {
1429
- left: d - s / 2,
1430
- placement: "top",
1431
- top: e.top - Ge - o
1432
- }
1433
- ].find(
1434
- ({ left: k, top: $ }) => k >= be && $ >= be && k + s <= i - be && $ + o <= n - be
1435
- );
1436
- return p || {
1437
- left: Ht(
1438
- d - s / 2,
1439
- be,
1440
- i - be - s
1441
- ),
1442
- placement: "bottom",
1443
- top: Ht(
1444
- e.bottom + Ge,
1445
- be,
1446
- n - be - o
1447
- )
1448
- };
1449
- }, an = (e) => typeof e == "number" ? Number.isFinite(e) ? `${e}px` : void 0 : e?.trim() || void 0;
1450
- class G extends Error {
1596
+ return Math.max(e, Math.min(t ?? i, s));
1597
+ }, Va = (e) => typeof e == "number" ? Number.isFinite(e) ? `${e}px` : void 0 : e?.trim() || void 0;
1598
+ class J extends Error {
1451
1599
  }
1452
- const ut = (e, t) => {
1600
+ const ot = (e, t) => {
1453
1601
  if (!(typeof e != "object" || e === null))
1454
1602
  return e[t];
1455
- }, nn = (e) => {
1456
- const t = ut(e, "status");
1457
- return typeof t == "number" ? t : ut(
1458
- ut(e, "response"),
1603
+ }, Za = (e) => {
1604
+ const t = ot(e, "status");
1605
+ return typeof t == "number" ? t : ot(
1606
+ ot(e, "response"),
1459
1607
  "status"
1460
1608
  );
1461
- }, sn = (e) => {
1462
- const t = ut(e, "code"), n = nn(e), i = e instanceof Error ? e.message : "", s = [t, i].filter((f) => typeof f == "string").join(" ").toLowerCase(), d = globalThis.navigator?.onLine === !1 || /network|fetch|timeout|offline|connection|网络|连接|超时/.test(s), g = typeof n == "number" && n >= 500 || /server|service|服务器|服务异常/.test(s);
1609
+ }, Xa = (e) => {
1610
+ const t = ot(e, "code"), s = Za(e), i = e instanceof Error ? e.message : "", o = [t, i].filter((b) => typeof b == "string").join(" ").toLowerCase(), d = globalThis.navigator?.onLine === !1 || /network|fetch|timeout|offline|connection|网络|连接|超时/.test(o), h = typeof s == "number" && s >= 500 || /server|service|服务器|服务异常/.test(o);
1463
1611
  return d ? {
1464
1612
  actionLabel: "重新连接",
1465
1613
  description: "请检查网络后再试。",
1466
1614
  kind: "network",
1467
1615
  label: "网络连接",
1468
1616
  title: "网络连接不可用"
1469
- } : g ? {
1617
+ } : h ? {
1470
1618
  actionLabel: "重新加载",
1471
1619
  description: "服务暂时未能响应,请稍后重试。",
1472
1620
  kind: "service",
@@ -1479,13 +1627,13 @@ const ut = (e, t) => {
1479
1627
  label: "加载异常",
1480
1628
  title: "暂时无法加载对话"
1481
1629
  };
1482
- }, Ot = (e) => {
1630
+ }, Bt = (e) => {
1483
1631
  try {
1484
1632
  const t = e?.return?.();
1485
1633
  if (!t) return;
1486
- Promise.resolve(t).catch((n) => {
1634
+ Promise.resolve(t).catch((s) => {
1487
1635
  console.error("[make-ai-assistant] transport iterator close failed", {
1488
- errorType: n instanceof Error ? n.name : typeof n
1636
+ errorType: s instanceof Error ? s.name : typeof s
1489
1637
  });
1490
1638
  });
1491
1639
  } catch (t) {
@@ -1493,7 +1641,7 @@ const ut = (e, t) => {
1493
1641
  errorType: t instanceof Error ? t.name : typeof t
1494
1642
  });
1495
1643
  }
1496
- }, rn = async (e) => {
1644
+ }, Ga = async (e) => {
1497
1645
  if (globalThis.navigator?.clipboard?.writeText) {
1498
1646
  await globalThis.navigator.clipboard.writeText(e);
1499
1647
  return;
@@ -1502,187 +1650,183 @@ const ut = (e, t) => {
1502
1650
  throw new Error("Clipboard API is unavailable");
1503
1651
  const t = document.createElement("textarea");
1504
1652
  t.value = e, t.setAttribute("readonly", ""), t.style.position = "fixed", t.style.inset = "0 auto auto 0", t.style.opacity = "0", document.body.append(t), t.select();
1505
- const n = document.execCommand("copy");
1506
- if (t.remove(), !n)
1653
+ const s = document.execCommand("copy");
1654
+ if (t.remove(), !s)
1507
1655
  throw new Error("Clipboard copy failed");
1508
- }, ea = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1656
+ }, Gt = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1509
1657
  /* @__PURE__ */ a("path", { d: "M12 2.8c.5 4.4 2.8 6.8 7.2 7.2-4.4.5-6.8 2.8-7.2 7.2-.5-4.4-2.8-6.8-7.2-7.2 4.4-.5 6.8-2.8 7.2-7.2Z" }),
1510
1658
  /* @__PURE__ */ a("path", { d: "M18.3 16.1c.2 1.8 1.2 2.8 3 3-1.8.2-2.8 1.2-3 3-.2-1.8-1.2-2.8-3-3 1.8-.2 2.8-1.2 3-3Z" })
1511
- ] }), on = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "m6 6 12 12M18 6 6 18" }) }), cn = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1659
+ ] }), Ya = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "m6 6 12 12M18 6 6 18" }) }), Ja = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1512
1660
  /* @__PURE__ */ a("path", { d: "M8 8h10v12H8z" }),
1513
1661
  /* @__PURE__ */ a("path", { d: "M6 16H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
1514
- ] }), ln = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1662
+ ] }), Qa = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1515
1663
  /* @__PURE__ */ a("path", { d: "M20 11a8 8 0 0 0-14.7-4.4L4 8" }),
1516
1664
  /* @__PURE__ */ a("path", { d: "M4 4v4h4" }),
1517
1665
  /* @__PURE__ */ a("path", { d: "M4 13a8 8 0 0 0 14.7 4.4L20 16" }),
1518
1666
  /* @__PURE__ */ a("path", { d: "M20 20v-4h-4" })
1519
- ] }), dn = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1520
- /* @__PURE__ */ a("circle", { cx: "12", cy: "12", r: "8" }),
1521
- /* @__PURE__ */ a("path", { d: "M9.8 9.4a2.35 2.35 0 1 1 3.93 1.73c-.96.86-1.73 1.42-1.73 2.87" }),
1522
- /* @__PURE__ */ a("path", { d: "M12 17h.01" })
1523
- ] }), un = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1667
+ ] }), es = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1524
1668
  /* @__PURE__ */ a("path", { d: "M12 4v11" }),
1525
1669
  /* @__PURE__ */ a("path", { d: "m7 10 5 5 5-5" }),
1526
1670
  /* @__PURE__ */ a("path", { d: "M5 20h14" })
1527
- ] }), mn = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "M12 5v14M5 12h14" }) }), hn = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1671
+ ] }), ts = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "M12 5v14M5 12h14" }) }), as = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1528
1672
  /* @__PURE__ */ a("path", { d: "M10 6h9M10 12h9M10 18h9" }),
1529
1673
  /* @__PURE__ */ a("path", { d: "M5 6h.01M5 12h.01M5 18h.01" })
1530
- ] }), pn = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "m7 10 5 5 5-5" }) }), Wt = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1674
+ ] }), ss = () => /* @__PURE__ */ a("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: /* @__PURE__ */ a("path", { d: "m7 10 5 5 5-5" }) }), Ut = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1531
1675
  /* @__PURE__ */ a("path", { d: "m4 4 17 8-17 8 3-8-3-8Z" }),
1532
1676
  /* @__PURE__ */ a("path", { d: "M7 12h14" })
1533
- ] }), ta = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1677
+ ] }), Yt = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1534
1678
  /* @__PURE__ */ a("path", { d: "M20 11a8 8 0 0 0-14.7-4.4L4 8" }),
1535
1679
  /* @__PURE__ */ a("path", { d: "M4 4v4h4" }),
1536
1680
  /* @__PURE__ */ a("path", { d: "M4 13a8 8 0 0 0 14.7 4.4L20 16" }),
1537
1681
  /* @__PURE__ */ a("path", { d: "M20 20v-4h-4" })
1538
- ] }), fn = () => /* @__PURE__ */ c("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1682
+ ] }), ns = () => /* @__PURE__ */ l("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", children: [
1539
1683
  /* @__PURE__ */ a("circle", { cx: "12", cy: "12", r: "8" }),
1540
1684
  /* @__PURE__ */ a("path", { d: "M12 8v4.5" }),
1541
1685
  /* @__PURE__ */ a("path", { d: "M12 16h.01" })
1542
- ] }), mt = ({ className: e = "" }) => /* @__PURE__ */ a("span", { className: `make-ai-assistant__avatar ${e}`.trim(), "aria-hidden": "true", children: /* @__PURE__ */ a(ea, {}) }), vn = ({ src: e }) => e ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__user-avatar", "aria-hidden": "true", children: /* @__PURE__ */ a("img", { alt: "", src: e }) }) : null, gn = ({
1686
+ ] }), ct = ({ className: e = "" }) => /* @__PURE__ */ a("span", { className: `make-ai-assistant__avatar ${e}`.trim(), "aria-hidden": "true", children: /* @__PURE__ */ a(Gt, {}) }), rs = ({ src: e }) => e ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__user-avatar", "aria-hidden": "true", children: /* @__PURE__ */ a("img", { alt: "", src: e }) }) : null, is = ({
1543
1687
  userAvatarUrl: e,
1544
1688
  userName: t
1545
1689
  }) => {
1546
- const n = t?.trim();
1547
- return !n && !e ? null : /* @__PURE__ */ c("div", { className: "make-ai-assistant__message-identity", children: [
1548
- n ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: n }) : null,
1549
- /* @__PURE__ */ a(vn, { src: e })
1690
+ const s = t?.trim();
1691
+ return !s && !e ? null : /* @__PURE__ */ l("div", { className: "make-ai-assistant__message-identity", children: [
1692
+ s ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: s }) : null,
1693
+ /* @__PURE__ */ a(rs, { src: e })
1550
1694
  ] });
1551
- }, gt = (e) => {
1695
+ }, ft = (e) => {
1552
1696
  const t = e.trim();
1553
1697
  if (!(!t.startsWith("|") || !t.endsWith("|")))
1554
- return t.slice(1, -1).split("|").map((n) => n.trim());
1555
- }, yn = (e) => e.length > 0 && e.every((t) => /^:?-{3,}:?$/.test(t)), bn = (e, t) => {
1556
- const n = gt(e[t] ?? ""), i = gt(e[t + 1] ?? "");
1557
- if (!n || !i || n.length !== i.length || !yn(i))
1698
+ return t.slice(1, -1).split("|").map((s) => s.trim());
1699
+ }, os = (e) => e.length > 0 && e.every((t) => /^:?-{3,}:?$/.test(t)), cs = (e, t) => {
1700
+ const s = ft(e[t] ?? ""), i = ft(e[t + 1] ?? "");
1701
+ if (!s || !i || s.length !== i.length || !os(i))
1558
1702
  return;
1559
- const s = [];
1560
- let o = t + 2;
1561
- for (; o < e.length; ) {
1562
- const d = gt(e[o] ?? "");
1563
- if (!d || d.length !== n.length) break;
1564
- s.push(d), o += 1;
1703
+ const o = [];
1704
+ let c = t + 2;
1705
+ for (; c < e.length; ) {
1706
+ const d = ft(e[c] ?? "");
1707
+ if (!d || d.length !== s.length) break;
1708
+ o.push(d), c += 1;
1565
1709
  }
1566
- return { headers: n, lastIndex: o - 1, rows: s };
1567
- }, kn = (e) => {
1568
- const t = [], n = [], i = [], s = [], o = e.replace(/\r\n?/g, `
1710
+ return { headers: s, lastIndex: c - 1, rows: o };
1711
+ }, ls = (e) => {
1712
+ const t = [], s = [], i = [], o = [], c = e.replace(/\r\n?/g, `
1569
1713
  `).split(`
1570
1714
  `), d = () => {
1571
- const p = n.join(`
1715
+ const f = s.join(`
1572
1716
  `).trim();
1573
- n.length = 0, p && t.push({ type: "paragraph", text: p });
1574
- }, g = () => {
1717
+ s.length = 0, f && t.push({ type: "paragraph", text: f });
1718
+ }, h = () => {
1575
1719
  i.length && t.push({ type: "list", items: i.splice(0) });
1576
- }, f = () => {
1577
- const p = s.join(`
1720
+ }, b = () => {
1721
+ const f = o.join(`
1578
1722
  `).trim();
1579
- s.length = 0, p && t.push({ type: "pre", text: p });
1723
+ o.length = 0, f && t.push({ type: "pre", text: f });
1580
1724
  };
1581
- for (let p = 0; p < o.length; p += 1) {
1582
- const k = o[p] ?? "", $ = k.trim();
1583
- if (!$) {
1584
- d(), g(), f();
1725
+ for (let f = 0; f < c.length; f += 1) {
1726
+ const $ = c[f] ?? "", L = $.trim();
1727
+ if (!L) {
1728
+ d(), h(), b();
1585
1729
  continue;
1586
1730
  }
1587
- const O = bn(o, p);
1588
- if (O) {
1589
- d(), g(), f(), t.push({ headers: O.headers, rows: O.rows, type: "table" }), p = O.lastIndex;
1731
+ const T = cs(c, f);
1732
+ if (T) {
1733
+ d(), h(), b(), t.push({ headers: T.headers, rows: T.rows, type: "table" }), f = T.lastIndex;
1590
1734
  continue;
1591
1735
  }
1592
- const q = /^(#{1,6})\s+(.+)$/.exec($);
1593
- if (q) {
1594
- d(), g(), f();
1595
- const V = (q[2] ?? "").replace(/\s+#+\s*$/, "").trim();
1596
- V && t.push({
1736
+ const j = /^(#{1,6})\s+(.+)$/.exec(L);
1737
+ if (j) {
1738
+ d(), h(), b();
1739
+ const U = (j[2] ?? "").replace(/\s+#+\s*$/, "").trim();
1740
+ U && t.push({
1597
1741
  type: "heading",
1598
- level: q[1]?.length,
1599
- text: V
1742
+ level: j[1]?.length,
1743
+ text: U
1600
1744
  });
1601
1745
  continue;
1602
1746
  }
1603
- if (/^\s*\|.+\|\s*$/.test(k)) {
1604
- d(), g(), s.push(k.trim());
1747
+ if (/^\s*\|.+\|\s*$/.test($)) {
1748
+ d(), h(), o.push($.trim());
1605
1749
  continue;
1606
1750
  }
1607
- const y = /^\s*[-*]\s+(.+)$/.exec(k);
1608
- if (y) {
1609
- d(), f(), i.push(y[1]?.trim() ?? "");
1751
+ const M = /^\s*[-*]\s+(.+)$/.exec($);
1752
+ if (M) {
1753
+ d(), b(), i.push(M[1]?.trim() ?? "");
1610
1754
  continue;
1611
1755
  }
1612
- g(), f(), n.push($);
1756
+ h(), b(), s.push(L);
1613
1757
  }
1614
- return d(), g(), f(), t;
1615
- }, Je = (e) => {
1616
- const t = [], n = /(\*\*[^*]+\*\*|`[^`]+`)/g;
1758
+ return d(), h(), b(), t;
1759
+ }, Ze = (e) => {
1760
+ const t = [], s = /(\*\*[^*]+\*\*|`[^`]+`)/g;
1617
1761
  let i = 0;
1618
- for (const s of e.matchAll(n)) {
1619
- const o = s[0], d = s.index ?? 0;
1620
- d > i && t.push(e.slice(i, 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`)), i = d + o.length;
1762
+ for (const o of e.matchAll(s)) {
1763
+ const c = o[0], d = o.index ?? 0;
1764
+ d > i && t.push(e.slice(i, d)), c.startsWith("**") ? t.push(/* @__PURE__ */ a("strong", { children: c.slice(2, -2) }, `${d}-strong`)) : t.push(/* @__PURE__ */ a("code", { children: c.slice(1, -1) }, `${d}-code`)), i = d + c.length;
1621
1765
  }
1622
1766
  return i < e.length && t.push(e.slice(i)), t;
1623
- }, Ut = ({ content: e }) => {
1624
- const t = kn(e);
1625
- return t.length ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble make-ai-assistant__assistant-text", children: t.map((n, i) => {
1626
- if (n.type === "heading") {
1627
- const s = n.level <= 2 ? "h3" : "h4";
1767
+ }, Ft = ({ content: e }) => {
1768
+ const t = ls(e);
1769
+ return t.length ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble make-ai-assistant__assistant-text", children: t.map((s, i) => {
1770
+ if (s.type === "heading") {
1771
+ const o = s.level <= 2 ? "h3" : "h4";
1628
1772
  return /* @__PURE__ */ a(
1629
- s,
1773
+ o,
1630
1774
  {
1631
- className: `make-ai-assistant__markdown-heading make-ai-assistant__markdown-heading--${n.level}`,
1632
- children: Je(n.text)
1775
+ className: `make-ai-assistant__markdown-heading make-ai-assistant__markdown-heading--${s.level}`,
1776
+ children: Ze(s.text)
1633
1777
  },
1634
1778
  `${i}-heading`
1635
1779
  );
1636
1780
  }
1637
- return n.type === "paragraph" ? /* @__PURE__ */ a("p", { children: Je(n.text) }, `${i}-paragraph`) : n.type === "pre" ? /* @__PURE__ */ a("pre", { children: /* @__PURE__ */ a("code", { children: n.text }) }, `${i}-pre`) : n.type === "table" ? /* @__PURE__ */ a(
1781
+ return s.type === "paragraph" ? /* @__PURE__ */ a("p", { children: Ze(s.text) }, `${i}-paragraph`) : s.type === "pre" ? /* @__PURE__ */ a("pre", { children: /* @__PURE__ */ a("code", { children: s.text }) }, `${i}-pre`) : s.type === "table" ? /* @__PURE__ */ a(
1638
1782
  "div",
1639
1783
  {
1640
1784
  "aria-label": "表格内容,可横向滚动",
1641
1785
  className: "make-ai-assistant__markdown-table-scroll",
1642
1786
  role: "region",
1643
1787
  tabIndex: 0,
1644
- children: /* @__PURE__ */ c("table", { className: "make-ai-assistant__markdown-table", children: [
1645
- /* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: n.headers.map((s, o) => /* @__PURE__ */ a("th", { scope: "col", children: Je(s) }, `${o}-${s}`)) }) }),
1646
- /* @__PURE__ */ a("tbody", { children: n.rows.map((s, o) => /* @__PURE__ */ a("tr", { children: s.map((d, g) => /* @__PURE__ */ a("td", { children: Je(d) }, `${g}-${d}`)) }, `${o}-${s.join("|")}`)) })
1788
+ children: /* @__PURE__ */ l("table", { className: "make-ai-assistant__markdown-table", children: [
1789
+ /* @__PURE__ */ a("thead", { children: /* @__PURE__ */ a("tr", { children: s.headers.map((o, c) => /* @__PURE__ */ a("th", { scope: "col", children: Ze(o) }, `${c}-${o}`)) }) }),
1790
+ /* @__PURE__ */ a("tbody", { children: s.rows.map((o, c) => /* @__PURE__ */ a("tr", { children: o.map((d, h) => /* @__PURE__ */ a("td", { children: Ze(d) }, `${h}-${d}`)) }, `${c}-${o.join("|")}`)) })
1647
1791
  ] })
1648
1792
  },
1649
1793
  `${i}-table`
1650
- ) : /* @__PURE__ */ a("ul", { children: n.items.map((s, o) => /* @__PURE__ */ a("li", { children: Je(s) }, `${o}-${s}`)) }, `${i}-list`);
1794
+ ) : /* @__PURE__ */ a("ul", { children: s.items.map((o, c) => /* @__PURE__ */ a("li", { children: Ze(o) }, `${c}-${o}`)) }, `${i}-list`);
1651
1795
  }) }) : null;
1652
- }, aa = ({ assistantName: e }) => /* @__PURE__ */ c("div", { className: "make-ai-assistant__message-identity", children: [
1653
- /* @__PURE__ */ a(mt, { className: "make-ai-assistant__avatar--message" }),
1796
+ }, Jt = ({ assistantName: e }) => /* @__PURE__ */ l("div", { className: "make-ai-assistant__message-identity", children: [
1797
+ /* @__PURE__ */ a(ct, { className: "make-ai-assistant__avatar--message" }),
1654
1798
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-sender", children: e })
1655
- ] }), na = (e) => {
1799
+ ] }), Qt = (e) => {
1656
1800
  for (let t = e.messages.length - 1; t >= 0; t -= 1) {
1657
- const n = e.messages[t];
1658
- if (n.role === "assistant" && n.status === "streaming")
1659
- return n.id;
1801
+ const s = e.messages[t];
1802
+ if (s.role === "assistant" && s.status === "streaming")
1803
+ return s.id;
1660
1804
  }
1661
- }, _n = (e) => {
1805
+ }, ds = (e) => {
1662
1806
  for (let t = e.messages.length - 1; t >= 0; t -= 1)
1663
1807
  if (e.messages[t].role === "user") return t;
1664
1808
  return -1;
1665
- }, sa = (e) => {
1666
- const t = _n(e);
1809
+ }, ea = (e) => {
1810
+ const t = ds(e);
1667
1811
  if (!(t < 0))
1668
- for (let n = e.messages.length - 1; n > t; n -= 1) {
1669
- const i = e.messages[n];
1812
+ for (let s = e.messages.length - 1; s > t; s -= 1) {
1813
+ const i = e.messages[s];
1670
1814
  if (i.role === "assistant") return i.id;
1671
1815
  }
1672
- }, wn = (e) => {
1816
+ }, us = (e) => {
1673
1817
  if (e.status === "idle")
1674
1818
  for (let t = e.messages.length - 1; t >= 0; t -= 1) {
1675
- const n = e.messages[t];
1676
- if (n.role === "assistant" && n.status === "complete")
1677
- return n.id;
1819
+ const s = e.messages[t];
1820
+ if (s.role === "assistant" && s.status === "complete")
1821
+ return s.id;
1678
1822
  }
1679
- }, In = (e) => {
1823
+ }, ms = (e) => {
1680
1824
  for (let t = e.messages.length - 1; t >= 0; t -= 1) {
1681
- const n = e.messages[t];
1682
- if (n.role === "user") return n;
1825
+ const s = e.messages[t];
1826
+ if (s.role === "user") return s;
1683
1827
  }
1684
- }, An = (e, t) => {
1685
- const n = e.messages.findIndex(
1828
+ }, hs = (e, t) => {
1829
+ const s = e.messages.findIndex(
1686
1830
  (i) => i.id === t && i.role === "user"
1687
1831
  );
1688
1832
  return {
@@ -1690,130 +1834,151 @@ const ut = (e, t) => {
1690
1834
  error: void 0,
1691
1835
  progress: void 0,
1692
1836
  status: "streaming",
1693
- messages: n < 0 ? e.messages : e.messages.slice(0, n + 1)
1837
+ messages: s < 0 ? e.messages : e.messages.slice(0, s + 1)
1694
1838
  };
1695
- }, Mn = (e) => e.scrollHeight - e.scrollTop - e.clientHeight <= 48, qt = (e = "smooth") => globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : e, yt = (e, t) => {
1839
+ }, ps = (e) => e.scrollHeight - e.scrollTop - e.clientHeight <= 48, Pt = (e = "smooth") => globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : e, vt = (e, t) => {
1696
1840
  typeof e.scrollTo == "function" ? e.scrollTo({ top: e.scrollHeight, behavior: t }) : e.scrollTop = e.scrollHeight;
1697
- }, ra = ({
1841
+ }, ta = ({
1698
1842
  error: e,
1699
1843
  onRetry: t
1700
- }) => /* @__PURE__ */ c(
1844
+ }) => /* @__PURE__ */ l(
1701
1845
  "div",
1702
1846
  {
1703
1847
  className: "make-ai-assistant__message-status make-ai-assistant__message-status--error",
1704
1848
  "data-error-presentation": "request-failed",
1705
1849
  role: "alert",
1706
1850
  children: [
1707
- /* @__PURE__ */ c("div", { className: "make-ai-assistant__message-status-header", children: [
1708
- /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-icon", "aria-hidden": "true", children: /* @__PURE__ */ a(fn, {}) }),
1851
+ /* @__PURE__ */ l("div", { className: "make-ai-assistant__message-status-header", children: [
1852
+ /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-icon", "aria-hidden": "true", children: /* @__PURE__ */ a(ns, {}) }),
1709
1853
  /* @__PURE__ */ a("strong", { children: "请求未完成" })
1710
1854
  ] }),
1711
1855
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__message-status-message", children: e.message }),
1712
- e.retryable && t ? /* @__PURE__ */ c(
1856
+ e.retryable && t ? /* @__PURE__ */ l(
1713
1857
  "button",
1714
1858
  {
1715
1859
  className: "make-ai-assistant__retry",
1716
1860
  type: "button",
1717
1861
  onClick: t,
1718
1862
  children: [
1719
- /* @__PURE__ */ a(ta, {}),
1863
+ /* @__PURE__ */ a(Yt, {}),
1720
1864
  "重新发送"
1721
1865
  ]
1722
1866
  }
1723
1867
  ) : null
1724
1868
  ]
1725
1869
  }
1726
- ), Tn = ({
1870
+ ), fs = ({
1727
1871
  error: e,
1728
1872
  onRetry: t
1729
1873
  }) => {
1730
- const n = sn(e);
1731
- return /* @__PURE__ */ c(
1874
+ const s = Xa(e);
1875
+ return /* @__PURE__ */ l(
1732
1876
  "section",
1733
1877
  {
1734
1878
  "aria-live": "assertive",
1735
1879
  className: "make-ai-assistant__load-failure",
1736
- "data-load-failure-kind": n.kind,
1880
+ "data-load-failure-kind": s.kind,
1737
1881
  role: "alert",
1738
1882
  children: [
1739
- /* @__PURE__ */ a("span", { className: "make-ai-assistant__load-failure-icon", "aria-hidden": "true", children: /* @__PURE__ */ c("svg", { viewBox: "0 0 24 24", children: [
1883
+ /* @__PURE__ */ a("span", { className: "make-ai-assistant__load-failure-icon", "aria-hidden": "true", children: /* @__PURE__ */ l("svg", { viewBox: "0 0 24 24", children: [
1740
1884
  /* @__PURE__ */ a("path", { d: "M5 12a7 7 0 0 1 13.4-2.8A4.5 4.5 0 0 1 18 18H7.5A4.5 4.5 0 0 1 5 12Z" }),
1741
1885
  /* @__PURE__ */ a("path", { d: "m9.2 14.8 5.6-5.6M9.2 9.2l5.6 5.6" })
1742
1886
  ] }) }),
1743
- /* @__PURE__ */ c("div", { className: "make-ai-assistant__load-failure-copy", children: [
1744
- /* @__PURE__ */ a("span", { className: "make-ai-assistant__load-failure-label", children: n.label }),
1745
- /* @__PURE__ */ a("h3", { children: n.title }),
1746
- /* @__PURE__ */ a("p", { children: n.description })
1887
+ /* @__PURE__ */ l("div", { className: "make-ai-assistant__load-failure-copy", children: [
1888
+ /* @__PURE__ */ a("span", { className: "make-ai-assistant__load-failure-label", children: s.label }),
1889
+ /* @__PURE__ */ a("h3", { children: s.title }),
1890
+ /* @__PURE__ */ a("p", { children: s.description })
1747
1891
  ] }),
1748
- /* @__PURE__ */ c(
1892
+ /* @__PURE__ */ l(
1749
1893
  "button",
1750
1894
  {
1751
1895
  className: "make-ai-assistant__retry make-ai-assistant__retry--primary",
1752
1896
  type: "button",
1753
1897
  onClick: t,
1754
1898
  children: [
1755
- /* @__PURE__ */ a(ta, {}),
1756
- n.actionLabel
1899
+ /* @__PURE__ */ a(Yt, {}),
1900
+ s.actionLabel
1757
1901
  ]
1758
1902
  }
1759
1903
  )
1760
1904
  ]
1761
1905
  }
1762
1906
  );
1763
- }, ia = ({
1907
+ }, aa = ({
1764
1908
  active: e,
1765
1909
  steps: t
1766
1910
  }) => {
1911
+ const [s, i] = N(!1);
1767
1912
  if (!e || !t?.length) return null;
1768
- const n = t[t.length - 1] ?? "处理中";
1769
- return /* @__PURE__ */ c("details", { className: "make-ai-assistant__process", open: !0, children: [
1770
- /* @__PURE__ */ c("summary", { children: [
1771
- /* @__PURE__ */ c("span", { className: "make-ai-assistant__progress", role: "status", children: [
1772
- /* @__PURE__ */ a("span", { "aria-hidden": "true" }),
1773
- /* @__PURE__ */ a("span", { children: n })
1774
- ] }),
1775
- /* @__PURE__ */ c("span", { className: "make-ai-assistant__process-count", children: [
1776
- t.length,
1777
- " "
1778
- ] })
1779
- ] }),
1780
- /* @__PURE__ */ a("ol", { children: t.map((i, s) => /* @__PURE__ */ c(
1781
- "li",
1782
- {
1783
- "data-step-active": s === t.length - 1 ? !0 : void 0,
1784
- children: [
1785
- /* @__PURE__ */ a("span", { "aria-hidden": "true" }),
1786
- /* @__PURE__ */ a("span", { children: i })
1787
- ]
1788
- },
1789
- `${s}-${i}`
1790
- )) })
1791
- ] });
1792
- }, Cn = ({
1913
+ const o = t[t.length - 1] ?? "处理中";
1914
+ return /* @__PURE__ */ l(
1915
+ "details",
1916
+ {
1917
+ className: "make-ai-assistant__process",
1918
+ open: s,
1919
+ onToggle: (c) => i(c.currentTarget.open),
1920
+ children: [
1921
+ /* @__PURE__ */ l("summary", { "aria-label": `查看处理过程,共 ${t.length} 步`, children: [
1922
+ /* @__PURE__ */ l("span", { className: "make-ai-assistant__process-summary", children: [
1923
+ /* @__PURE__ */ a("span", { className: "make-ai-assistant__process-indicator", "aria-hidden": "true" }),
1924
+ /* @__PURE__ */ l("span", { className: "make-ai-assistant__process-copy", children: [
1925
+ /* @__PURE__ */ a("span", { className: "make-ai-assistant__process-title", children: "处理过程" }),
1926
+ /* @__PURE__ */ a(
1927
+ "span",
1928
+ {
1929
+ className: "make-ai-assistant__progress make-ai-assistant__process-latest",
1930
+ role: "status",
1931
+ children: o
1932
+ }
1933
+ )
1934
+ ] })
1935
+ ] }),
1936
+ /* @__PURE__ */ l("span", { className: "make-ai-assistant__process-count", children: [
1937
+ t.length,
1938
+ " 步"
1939
+ ] })
1940
+ ] }),
1941
+ /* @__PURE__ */ a("ol", { children: t.map((c, d) => /* @__PURE__ */ l(
1942
+ "li",
1943
+ {
1944
+ "data-step-active": d === t.length - 1 ? !0 : void 0,
1945
+ children: [
1946
+ /* @__PURE__ */ a("span", { "aria-hidden": "true" }),
1947
+ /* @__PURE__ */ a("span", { children: c })
1948
+ ]
1949
+ },
1950
+ `${d}-${c}`
1951
+ )) })
1952
+ ]
1953
+ }
1954
+ );
1955
+ }, vs = ({
1793
1956
  copyFeedback: e,
1794
- onCopy: t,
1795
- onRegenerate: n
1796
- }) => !t && !n ? null : /* @__PURE__ */ c("div", { className: "make-ai-assistant__reply-actions", "aria-label": "回复操作", children: [
1797
- t ? /* @__PURE__ */ a(
1957
+ feedback: t,
1958
+ onCopy: s,
1959
+ onRegenerate: i
1960
+ }) => !t && !s && !i ? null : /* @__PURE__ */ l("div", { className: "make-ai-assistant__reply-actions", "aria-label": "回复操作", children: [
1961
+ s ? /* @__PURE__ */ a(
1798
1962
  "button",
1799
1963
  {
1800
1964
  "aria-label": "复制回答",
1801
1965
  className: "make-ai-assistant__reply-action make-ai-assistant__reply-copy",
1802
1966
  "data-tooltip": "复制",
1803
1967
  type: "button",
1804
- onClick: t,
1805
- children: /* @__PURE__ */ a(cn, {})
1968
+ onClick: s,
1969
+ children: /* @__PURE__ */ a(Ja, {})
1806
1970
  }
1807
1971
  ) : null,
1808
- n ? /* @__PURE__ */ a(
1972
+ t,
1973
+ i ? /* @__PURE__ */ a(
1809
1974
  "button",
1810
1975
  {
1811
1976
  "aria-label": "重新生成",
1812
1977
  className: "make-ai-assistant__reply-action make-ai-assistant__reply-regenerate",
1813
1978
  "data-tooltip": "重新生成",
1814
1979
  type: "button",
1815
- onClick: n,
1816
- children: /* @__PURE__ */ a(ln, {})
1980
+ onClick: i,
1981
+ children: /* @__PURE__ */ a(Qa, {})
1817
1982
  }
1818
1983
  ) : null,
1819
1984
  e ? /* @__PURE__ */ a(
@@ -1825,678 +1990,602 @@ const ut = (e, t) => {
1825
1990
  children: e.message
1826
1991
  }
1827
1992
  ) : null
1828
- ] }), Kt = ({
1993
+ ] }), zt = ({
1829
1994
  assistantName: e,
1830
1995
  error: t,
1831
- onRetry: n,
1996
+ onRetry: s,
1832
1997
  progress: i
1833
1998
  }) => {
1834
- const s = t ? "error" : "progress";
1999
+ const o = t ? "error" : "progress";
1835
2000
  return t?.message ?? i?.message ? /* @__PURE__ */ a(
1836
2001
  "article",
1837
2002
  {
1838
- "aria-label": `${e}的${s === "error" ? "错误消息" : "状态消息"}`,
1839
- className: `make-ai-assistant__message make-ai-assistant__message--assistant make-ai-assistant__message--${s}`,
2003
+ "aria-label": `${e}的${o === "error" ? "错误消息" : "状态消息"}`,
2004
+ className: `make-ai-assistant__message make-ai-assistant__message--assistant make-ai-assistant__message--${o}`,
1840
2005
  "data-message-role": "assistant",
1841
- "data-message-state": s,
1842
- children: /* @__PURE__ */ c("div", { className: "make-ai-assistant__message-turn", children: [
1843
- /* @__PURE__ */ a(aa, { assistantName: e }),
1844
- /* @__PURE__ */ a("div", { className: "make-ai-assistant__message-stack", children: t ? /* @__PURE__ */ a(ra, { error: t, onRetry: n }) : /* @__PURE__ */ a(ia, { active: !0, steps: i?.steps }) })
2006
+ "data-message-state": o,
2007
+ children: /* @__PURE__ */ l("div", { className: "make-ai-assistant__message-turn", children: [
2008
+ /* @__PURE__ */ a(Jt, { assistantName: e }),
2009
+ /* @__PURE__ */ a("div", { className: "make-ai-assistant__message-stack", children: t ? /* @__PURE__ */ a(ta, { error: t, onRetry: s }) : /* @__PURE__ */ a(aa, { active: !0, steps: i?.steps }) })
1845
2010
  ] })
1846
2011
  }
1847
2012
  ) : null;
1848
- }, Nn = (e, t, n, i, s, o, d, g, f, p, k, $, O, q, y, V) => {
1849
- const ee = sa(e), j = na(e), v = wn(e);
1850
- let u;
1851
- return e.messages.map((l) => {
1852
- if (l.intermediate) return /* @__PURE__ */ c("details", { className: "make-ai-assistant__process", children: [
2013
+ }, gs = (e, t, s, i, o, c, d, h, b, f, $, L, T, j, M, U) => {
2014
+ const g = ea(e), R = Qt(e), P = us(e);
2015
+ let p;
2016
+ return e.messages.map((n) => {
2017
+ if (n.intermediate) return /* @__PURE__ */ l("details", { className: "make-ai-assistant__process", children: [
1853
2018
  /* @__PURE__ */ a("summary", { children: "处理过程" }),
1854
- /* @__PURE__ */ a(Ut, { content: l.content })
1855
- ] }, l.id);
1856
- const T = l.role === "assistant", L = u;
1857
- T || (u = l);
1858
- const re = l.id === j, E = l.id === ee ? e.error : void 0, J = l.error ?? E, K = !T && !!(f?.trim() || p), D = T ? d : f?.trim() || "用户", X = T && l.status === "complete" && !J && (l.content.trim() || l.id === v);
2019
+ /* @__PURE__ */ a(Ft, { content: n.content })
2020
+ ] }, n.id);
2021
+ const v = n.role === "assistant", k = p;
2022
+ v || (p = n);
2023
+ const q = n.id === R, I = n.id === g ? e.error : void 0, G = n.error ?? I, Y = !v && !!(b?.trim() || f), z = v ? d : b?.trim() || "用户", Q = v && n.status === "complete" && !G && (n.content.trim() || n.id === P), ve = !!(M && U?.features?.feedback && v && n.persistent), oe = Q || ve;
1859
2024
  return /* @__PURE__ */ a(
1860
2025
  "article",
1861
2026
  {
1862
- "aria-label": `${D}的消息`,
1863
- className: `make-ai-assistant__message make-ai-assistant__message--${l.role}`,
1864
- "data-message-role": l.role,
1865
- "data-message-state": J ? "error" : void 0,
1866
- "data-message-status": l.status,
1867
- "data-message-has-identity": T || K ? !0 : void 0,
1868
- children: /* @__PURE__ */ c("div", { className: "make-ai-assistant__message-turn", children: [
1869
- T ? /* @__PURE__ */ a(aa, { assistantName: d }) : K ? /* @__PURE__ */ a(gn, { userAvatarUrl: p, userName: f }) : null,
1870
- /* @__PURE__ */ c("div", { className: "make-ai-assistant__message-stack", children: [
1871
- T && l.responseId && e.responses?.[l.responseId]?.status === "cancelled" ? /* @__PURE__ */ a("p", { className: "make-ai-assistant__response-status", role: "status", children: "已停止生成" }) : null,
1872
- l.content ? T ? /* @__PURE__ */ a(Ut, { content: l.content }) : /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble", children: l.content }) : l.status === "streaming" ? /* @__PURE__ */ c("div", { className: "make-ai-assistant__typing", "aria-label": `${d}正在思考`, children: [
2027
+ "aria-label": `${z}的消息`,
2028
+ className: `make-ai-assistant__message make-ai-assistant__message--${n.role}`,
2029
+ "data-message-role": n.role,
2030
+ "data-message-state": G ? "error" : void 0,
2031
+ "data-message-status": n.status,
2032
+ "data-message-has-identity": v || Y ? !0 : void 0,
2033
+ children: /* @__PURE__ */ l("div", { className: "make-ai-assistant__message-turn", children: [
2034
+ v ? /* @__PURE__ */ a(Jt, { assistantName: d }) : Y ? /* @__PURE__ */ a(is, { userAvatarUrl: f, userName: b }) : null,
2035
+ /* @__PURE__ */ l("div", { className: "make-ai-assistant__message-stack", children: [
2036
+ v && n.responseId && e.responses?.[n.responseId]?.status === "cancelled" ? /* @__PURE__ */ a("p", { className: "make-ai-assistant__response-status", role: "status", children: "已停止生成" }) : null,
2037
+ n.content ? v ? /* @__PURE__ */ a(Ft, { content: n.content }) : /* @__PURE__ */ a("div", { className: "make-ai-assistant__bubble", children: n.content }) : n.status === "streaming" ? /* @__PURE__ */ l("div", { className: "make-ai-assistant__typing", "aria-label": `${d}正在思考`, children: [
1873
2038
  /* @__PURE__ */ a("span", {}),
1874
2039
  /* @__PURE__ */ a("span", {}),
1875
2040
  /* @__PURE__ */ a("span", {})
1876
2041
  ] }) : null,
1877
- T ? /* @__PURE__ */ a(
1878
- ia,
2042
+ v ? /* @__PURE__ */ a(
2043
+ aa,
1879
2044
  {
1880
- active: re && e.status === "streaming",
1881
- steps: l.progressSteps
2045
+ active: q && e.status === "streaming",
2046
+ steps: n.progressSteps
1882
2047
  }
1883
2048
  ) : null,
1884
- J ? /* @__PURE__ */ a(
1885
- ra,
2049
+ G ? /* @__PURE__ */ a(
2050
+ ta,
1886
2051
  {
1887
- error: J,
1888
- onRetry: E ? g : void 0
2052
+ error: G,
2053
+ onRetry: I ? h : void 0
1889
2054
  }
1890
2055
  ) : null,
1891
- l.artifacts.map((ie) => /* @__PURE__ */ a(
1892
- Ia,
2056
+ n.artifacts.map((F) => /* @__PURE__ */ a(
2057
+ da,
1893
2058
  {
1894
- artifact: ie,
2059
+ artifact: F,
1895
2060
  context: t,
1896
- onAction: s,
1897
- onActionError: o,
1898
- registry: n,
2061
+ onAction: o,
2062
+ onActionError: c,
2063
+ registry: s,
1899
2064
  theme: i
1900
2065
  },
1901
- ie.id
2066
+ F.id
1902
2067
  )),
1903
- y && V && e.threadId ? /* @__PURE__ */ a(Ha, { message: l, context: t, transport: V, chatId: e.threadId }) : null,
1904
- y && V?.features?.feedback ? /* @__PURE__ */ a(Ba, { message: l, manager: y }) : null,
1905
- X ? /* @__PURE__ */ a(
1906
- Cn,
2068
+ M && U && e.threadId ? /* @__PURE__ */ a(La, { message: n, context: t, transport: U, chatId: e.threadId }) : null,
2069
+ oe ? /* @__PURE__ */ a(
2070
+ vs,
1907
2071
  {
1908
- copyFeedback: k?.messageId === l.id ? {
1909
- message: k.message,
1910
- status: k.status
2072
+ copyFeedback: $?.messageId === n.id ? {
2073
+ message: $.message,
2074
+ status: $.status
1911
2075
  } : void 0,
1912
- onCopy: l.content.trim() ? () => O(l.id, l.content) : void 0,
1913
- onRegenerate: $ && l.id === v && L ? () => q({
1914
- userMessage: L,
1915
- assistantMessage: l
2076
+ onCopy: n.content.trim() ? () => T(n.id, n.content) : void 0,
2077
+ feedback: M && ve ? /* @__PURE__ */ a(Ea, { message: n, manager: M }) : void 0,
2078
+ onRegenerate: L && n.id === P && k ? () => j({
2079
+ userMessage: k,
2080
+ assistantMessage: n
1916
2081
  }) : void 0
1917
2082
  }
1918
2083
  ) : null
1919
2084
  ] })
1920
2085
  ] })
1921
2086
  },
1922
- `${e.threadId ?? "local"}:${l.id}`
2087
+ `${e.threadId ?? "local"}:${n.id}`
1923
2088
  );
1924
2089
  });
1925
2090
  };
1926
- function oa({
2091
+ function sa({
1927
2092
  assistantName: e = "AI 助手",
1928
2093
  brandName: t,
1929
- context: n,
2094
+ context: s,
1930
2095
  onAction: i,
1931
- onActionError: s,
1932
- onClose: o,
2096
+ onActionError: o,
2097
+ onClose: c,
1933
2098
  onNewConversation: d,
1934
- headerHeight: g,
1935
- privacyNotice: f,
1936
- registry: p,
1937
- subtitle: k,
1938
- suggestions: $,
1939
- title: O,
1940
- theme: q,
1941
- transport: y,
1942
- userAvatarUrl: V,
1943
- userName: ee,
1944
- visible: j
2099
+ headerHeight: h,
2100
+ registry: b,
2101
+ suggestions: f,
2102
+ title: $,
2103
+ theme: L,
2104
+ transport: T,
2105
+ userAvatarUrl: j,
2106
+ userName: M,
2107
+ visible: U
1945
2108
  }) {
1946
- const v = La(n, y), u = Wa(n, y, v), l = Jt(t, O), T = f?.trim(), L = Za(k, n.app.name), re = an(g), E = kt(q), J = E || re ? {
1947
- ...E,
1948
- ...re ? { "--make-ai-internal-header-height": re } : {}
1949
- } : void 0, [K, D] = N(""), [X, ie] = N(!1), [oe, pe] = N(!1), Me = v.enabled ? y.scopeKey?.(n) ?? n.app.id : "";
1950
- bt(() => {
1951
- v.enabled && D("");
1952
- }, [Me, v.enabled]);
1953
- const [Te, Y] = N(he), w = v.enabled ? v.state : Te, b = v.enabled ? v.setState : Y, H = C(w);
1954
- H.current = w;
1955
- const [Z, te] = N(void 0), [De, S] = N(void 0), [ne, ce] = N(0), [fe, Ce] = N(() => y.loadConversation ? "loading" : "ready"), Q = v.enabled ? v.loading && !w.messages.length ? "loading" : "ready" : fe, [ke, Ne] = N(void 0), [Qe, de] = N(!1), [ve, et] = N(!1), [Re, tt] = N(void 0), Ee = C(void 0), Se = C(void 0), xe = C(0), at = C(null), Pe = C(null), nt = C(null), $e = C(null), r = C(null), h = C(null), _ = C(null), A = C(null), M = C(!0), x = C(n.app.id), I = C(j), W = Dt(), z = Dt(), B = Pt(
1956
- () => p ?? $a(),
1957
- [p]
1958
- ), ge = Pt(
1959
- () => Xa($),
1960
- [$]
1961
- ), Ke = () => {
1962
- const m = h.current, P = _.current;
1963
- if (!m || !P || typeof window > "u") return;
1964
- const F = tn(
1965
- m.getBoundingClientRect(),
1966
- P.getBoundingClientRect(),
1967
- window.innerHeight,
1968
- window.innerWidth
1969
- );
1970
- tt(
1971
- (U) => U?.left === F.left && U.top === F.top && U.placement === F.placement ? U : F
1972
- );
1973
- }, Ve = () => et(!0), ue = () => et(!1), Be = Re ? {
1974
- left: `${Re.left}px`,
1975
- top: `${Re.top}px`
1976
- } : void 0;
1977
- bt(() => {
1978
- if (!ve || !T) {
1979
- tt(void 0);
1980
- return;
1981
- }
1982
- Ke();
1983
- }, [ve, T]), ae(() => {
1984
- if (!ve || !T) return;
1985
- const m = () => Ke();
1986
- return window.addEventListener("resize", m), window.addEventListener("scroll", m, !0), () => {
1987
- window.removeEventListener("resize", m), window.removeEventListener("scroll", m, !0);
1988
- };
1989
- }, [ve, T]);
1990
- const _e = (m) => {
1991
- const P = Ee.current, F = Se.current?.iterator;
1992
- return !P && !F ? !1 : (xe.current += 1, Ee.current = void 0, Se.current = void 0, console.info("[make-ai-assistant] local run cancellation requested", { reason: m }), P?.abort(), Ot(F), !0);
2109
+ const g = _a(s, T), R = Ba(s, T, g), P = Zt(t, $), p = Va(h), n = yt(L), v = n || p ? {
2110
+ ...n,
2111
+ ...p ? { "--make-ai-internal-header-height": p } : {}
2112
+ } : void 0, [k, q] = N(""), [I, G] = N(!1), [Y, z] = N(!1), Q = g.enabled ? T.scopeKey?.(s) ?? s.app.id : "";
2113
+ gt(() => {
2114
+ g.enabled && q("");
2115
+ }, [Q, g.enabled]);
2116
+ const [ve, oe] = N(fe), F = g.enabled ? g.state : ve, ne = g.enabled ? g.setState : oe, ce = S(F);
2117
+ ce.current = F;
2118
+ const [V, B] = N(void 0), [A, W] = N(void 0), [ae, ge] = N(0), [Re, x] = N(() => T.loadConversation ? "loading" : "ready"), ee = g.enabled ? g.loading && !F.messages.length ? "loading" : "ready" : Re, [le, de] = N(void 0), [lt, ye] = N(!1), we = S(void 0), be = S(void 0), te = S(0), Ce = S(null), ke = S(null), Oe = S(null), He = S(null), Ee = S(null), Xe = S(null), me = S(!0), Ge = S(s.app.id), Ye = S(U), Je = ia(), Qe = Rt(
2119
+ () => b ?? ka(),
2120
+ [b]
2121
+ ), et = Rt(
2122
+ () => Oa(f),
2123
+ [f]
2124
+ ), xe = (m) => {
2125
+ const K = we.current, X = be.current?.iterator;
2126
+ return !K && !X ? !1 : (te.current += 1, we.current = void 0, be.current = void 0, console.info("[make-ai-assistant] local run cancellation requested", { reason: m }), K?.abort(), Bt(X), !0);
1993
2127
  };
1994
- ae(() => () => {
1995
- _e("unmount");
1996
- }, []), ae(() => {
1997
- if (v.enabled) return;
1998
- const m = y.loadConversation, P = x.current !== n.app.id;
1999
- if (x.current = n.app.id, _e("reinitialize"), P && (D(""), M.current = !0), te(void 0), S(void 0), de(!1), b(he()), !m) {
2000
- Ne(void 0), Ce("ready");
2128
+ ie(() => () => {
2129
+ xe("unmount");
2130
+ }, []), ie(() => {
2131
+ if (g.enabled) return;
2132
+ const m = T.loadConversation, K = Ge.current !== s.app.id;
2133
+ if (Ge.current = s.app.id, xe("reinitialize"), K && (q(""), me.current = !0), B(void 0), W(void 0), ye(!1), ne(fe()), !m) {
2134
+ de(void 0), x("ready");
2001
2135
  return;
2002
2136
  }
2003
- const F = new AbortController();
2004
- return Ne(void 0), Ce("loading"), console.info("[make-ai-assistant] conversation load start", {
2005
- appId: n.app.id
2006
- }), m.call(y, n, { signal: F.signal }).then((U) => {
2007
- F.signal.aborted || (b(he(U)), Ce("ready"), console.info("[make-ai-assistant] conversation load success", {
2008
- appId: n.app.id,
2009
- messageCount: U.messages.length
2137
+ const X = new AbortController();
2138
+ return de(void 0), x("loading"), console.info("[make-ai-assistant] conversation load start", {
2139
+ appId: s.app.id
2140
+ }), m.call(T, s, { signal: X.signal }).then((se) => {
2141
+ X.signal.aborted || (ne(fe(se)), x("ready"), console.info("[make-ai-assistant] conversation load success", {
2142
+ appId: s.app.id,
2143
+ messageCount: se.messages.length
2010
2144
  }));
2011
- }).catch((U) => {
2012
- F.signal.aborted || (console.error("[make-ai-assistant] conversation load failed", {
2013
- appId: n.app.id,
2014
- errorType: U instanceof Error ? U.name : typeof U
2015
- }), Ne(U), Ce("error"));
2016
- }), () => F.abort();
2017
- }, [n.app.id, ne, y, v.enabled]), ae(() => {
2018
- const m = Pe.current;
2019
- if (!m || !M.current) return;
2020
- de(!1);
2021
- const P = requestAnimationFrame(() => {
2022
- if (!M.current) return;
2023
- const F = w.status === "streaming" || globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
2024
- yt(m, F);
2145
+ }).catch((se) => {
2146
+ X.signal.aborted || (console.error("[make-ai-assistant] conversation load failed", {
2147
+ appId: s.app.id,
2148
+ errorType: se instanceof Error ? se.name : typeof se
2149
+ }), de(se), x("error"));
2150
+ }), () => X.abort();
2151
+ }, [s.app.id, ae, T, g.enabled]), ie(() => {
2152
+ const m = ke.current;
2153
+ if (!m || !me.current) return;
2154
+ ye(!1);
2155
+ const K = requestAnimationFrame(() => {
2156
+ if (!me.current) return;
2157
+ const X = F.status === "streaming" || globalThis.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
2158
+ vt(m, X);
2025
2159
  });
2026
- return () => cancelAnimationFrame(P);
2027
- }, [w.messages, w.progress, w.status]), ae(() => {
2028
- j || (ie(!1), pe(!1));
2029
- }, [j]), ae(() => {
2030
- const m = j && !I.current;
2031
- if (I.current = j, !m) return;
2032
- const P = requestAnimationFrame(() => {
2033
- const F = Pe.current;
2034
- if (F && M.current) {
2035
- de(!1);
2036
- const je = H.current.status === "streaming" ? "auto" : qt();
2037
- yt(F, je);
2038
- } else F && de(H.current.messages.length > 0);
2039
- const U = nt.current;
2040
- (U && !U.disabled ? U : A.current ?? at.current?.querySelector("button:not(:disabled)"))?.focus();
2160
+ return () => cancelAnimationFrame(K);
2161
+ }, [F.messages, F.progress, F.status]), ie(() => {
2162
+ U || (G(!1), z(!1));
2163
+ }, [U]), ie(() => {
2164
+ const m = U && !Ye.current;
2165
+ if (Ye.current = U, !m) return;
2166
+ const K = requestAnimationFrame(() => {
2167
+ const X = ke.current;
2168
+ if (X && me.current) {
2169
+ ye(!1);
2170
+ const qe = ce.current.status === "streaming" ? "auto" : Pt();
2171
+ vt(X, qe);
2172
+ } else X && ye(ce.current.messages.length > 0);
2173
+ const se = Oe.current;
2174
+ (se && !se.disabled ? se : Xe.current ?? Ce.current?.querySelector("button:not(:disabled)"))?.focus();
2041
2175
  });
2042
- return () => cancelAnimationFrame(P);
2043
- }, [j]);
2044
- const ca = () => {
2045
- const m = Pe.current;
2176
+ return () => cancelAnimationFrame(K);
2177
+ }, [U]);
2178
+ const dt = () => {
2179
+ const m = ke.current;
2046
2180
  if (!m) return;
2047
- const P = Mn(m);
2048
- M.current = P, de(!P && H.current.messages.length > 0);
2049
- }, la = () => {
2050
- const m = Pe.current;
2181
+ const K = ps(m);
2182
+ me.current = K, ye(!K && ce.current.messages.length > 0);
2183
+ }, Se = () => {
2184
+ const m = ke.current;
2051
2185
  if (!m) return;
2052
- M.current = !0, de(!1);
2053
- const P = qt();
2054
- yt(m, P);
2055
- }, wt = async (m, P) => {
2056
- const F = m.trim(), U = H.current, we = P?.regenerateFrom, je = y.regenerate;
2057
- if (!F || Q !== "ready" || U.status === "streaming" || Ee.current || we && !je) return;
2058
- if (dt(
2059
- F,
2060
- le.messageCharacters
2061
- ) > le.messageCharacters) {
2062
- te(
2063
- `输入内容过长,请控制在 ${le.messageCharacters} 个字符以内`
2186
+ me.current = !0, ye(!1);
2187
+ const K = Pt();
2188
+ vt(m, K);
2189
+ }, r = async (m, K) => {
2190
+ const X = m.trim(), se = ce.current, Ae = K?.regenerateFrom, qe = T.regenerate;
2191
+ if (!X || ee !== "ready" || se.status === "streaming" || we.current || Ae && !qe) return;
2192
+ if (it(
2193
+ X,
2194
+ ue.messageCharacters
2195
+ ) > ue.messageCharacters) {
2196
+ B(
2197
+ `输入内容过长,请控制在 ${ue.messageCharacters} 个字符以内`
2064
2198
  );
2065
2199
  return;
2066
2200
  }
2067
- const it = {
2068
- id: we?.userMessage.id ?? Ka("user"),
2069
- content: F
2070
- }, ot = we ? An(U, we.userMessage.id) : Xt(U, it), ct = new AbortController(), ze = xe.current + 1;
2071
- xe.current = ze, Ee.current = ct, te(void 0), S(void 0), de(!M.current && U.messages.length > 0), we || D(""), b(ot);
2201
+ const at = {
2202
+ id: Ae?.userMessage.id ?? Pa("user"),
2203
+ content: X
2204
+ }, st = Ae ? hs(se, Ae.userMessage.id) : Ht(se, at), nt = new AbortController(), Be = te.current + 1;
2205
+ te.current = Be, we.current = nt, B(void 0), W(void 0), ye(!me.current && se.messages.length > 0), Ae || q(""), ne(st);
2072
2206
  try {
2073
- let Le = !1, se, Tt = 0, Ct = 0, Nt = 0, ht = 0, Xe = 0;
2074
- const Ye = /* @__PURE__ */ new Map(), Rt = /* @__PURE__ */ new Set(), Et = /* @__PURE__ */ new Set(
2207
+ let Te = !1, re, kt = 0, _t = 0, wt = 0, ut = 0, Ke = 0;
2208
+ const je = /* @__PURE__ */ new Map(), It = /* @__PURE__ */ new Set(), At = /* @__PURE__ */ new Set(
2075
2209
  [
2076
- ...ot.messages.map((lt) => lt.id),
2077
- it.id
2210
+ ...st.messages.map((rt) => rt.id),
2211
+ at.id
2078
2212
  ]
2079
- ), Ze = /* @__PURE__ */ new Set(), St = wa(B), xt = { signal: ct.signal };
2080
- let pt;
2081
- if (we) {
2082
- if (!je)
2083
- throw new G("当前 AI 助手不支持重新生成");
2084
- pt = je({
2085
- threadId: ot.threadId,
2086
- message: it,
2213
+ ), Ve = /* @__PURE__ */ new Set(), Mt = ca(Qe), Nt = { signal: nt.signal };
2214
+ let mt;
2215
+ if (Ae) {
2216
+ if (!qe)
2217
+ throw new J("当前 AI 助手不支持重新生成");
2218
+ mt = qe({
2219
+ threadId: st.threadId,
2220
+ message: at,
2087
2221
  assistantMessage: {
2088
- id: we.assistantMessage.id,
2089
- content: we.assistantMessage.content
2222
+ id: Ae.assistantMessage.id,
2223
+ content: Ae.assistantMessage.content
2090
2224
  },
2091
- context: n,
2092
- capabilities: St
2093
- }, xt);
2225
+ context: s,
2226
+ capabilities: Mt
2227
+ }, Nt);
2094
2228
  } else
2095
- pt = y.run(
2229
+ mt = T.run(
2096
2230
  {
2097
- threadId: ot.threadId,
2098
- message: it,
2099
- context: n,
2100
- capabilities: St
2231
+ threadId: st.threadId,
2232
+ message: at,
2233
+ context: s,
2234
+ capabilities: Mt
2101
2235
  },
2102
- xt
2236
+ Nt
2103
2237
  );
2104
- const $t = pt[Symbol.asyncIterator]();
2105
- for (Se.current = { iterator: $t, requestVersion: ze }; ; ) {
2106
- const lt = await $t.next();
2107
- if (xe.current !== ze || lt.done) break;
2108
- let R;
2238
+ const Ct = mt[Symbol.asyncIterator]();
2239
+ for (be.current = { iterator: Ct, requestVersion: Be }; ; ) {
2240
+ const rt = await Ct.next();
2241
+ if (te.current !== Be || rt.done) break;
2242
+ let E;
2109
2243
  try {
2110
- R = jt(lt.value);
2111
- } catch (me) {
2112
- throw new G(
2113
- me instanceof Error ? me.message : "Invalid assistant event"
2244
+ E = Ot(rt.value);
2245
+ } catch (pe) {
2246
+ throw new J(
2247
+ pe instanceof Error ? pe.message : "Invalid assistant event"
2114
2248
  );
2115
2249
  }
2116
- if (R.type === "message.start") {
2117
- if (se !== void 0 && se !== R.runId)
2118
- throw new G("AI 助手响应 run id 不一致");
2119
- if (se ??= R.runId, Ct += 1, Ct > le.assistantMessagesPerRun)
2120
- throw new G("AI 助手单次响应消息数量超过限制");
2121
- if (Et.has(R.messageId))
2122
- throw new G("AI 助手响应包含重复的 message id");
2123
- Et.add(R.messageId), Ze.add(R.messageId), Ye.set(R.messageId, 0);
2250
+ if (E.type === "message.start") {
2251
+ if (re !== void 0 && re !== E.runId)
2252
+ throw new J("AI 助手响应 run id 不一致");
2253
+ if (re ??= E.runId, _t += 1, _t > ue.assistantMessagesPerRun)
2254
+ throw new J("AI 助手单次响应消息数量超过限制");
2255
+ if (At.has(E.messageId))
2256
+ throw new J("AI 助手响应包含重复的 message id");
2257
+ At.add(E.messageId), Ve.add(E.messageId), je.set(E.messageId, 0);
2124
2258
  }
2125
- if (R.type === "message.delta") {
2126
- if (!Ze.has(R.messageId))
2127
- throw new G("AI 助手响应事件顺序无效");
2128
- const me = Ye.get(R.messageId) ?? 0, He = dt(
2129
- R.delta,
2130
- le.messageCharacters - Xe
2259
+ if (E.type === "message.delta") {
2260
+ if (!Ve.has(E.messageId))
2261
+ throw new J("AI 助手响应事件顺序无效");
2262
+ const pe = je.get(E.messageId) ?? 0, Ue = it(
2263
+ E.delta,
2264
+ ue.messageCharacters - Ke
2131
2265
  );
2132
- if (Xe + He > le.messageCharacters)
2133
- throw new G("AI 助手响应文本超过大小限制");
2134
- Xe += He, Ye.set(
2135
- R.messageId,
2136
- me + He
2266
+ if (Ke + Ue > ue.messageCharacters)
2267
+ throw new J("AI 助手响应文本超过大小限制");
2268
+ Ke += Ue, je.set(
2269
+ E.messageId,
2270
+ pe + Ue
2137
2271
  );
2138
2272
  }
2139
- if (R.type === "message.replace") {
2140
- if (!Ze.has(R.messageId))
2141
- throw new G("AI 助手响应事件顺序无效");
2142
- const me = Ye.get(R.messageId) ?? 0, He = dt(
2143
- R.content,
2144
- le.messageCharacters
2145
- ), Lt = Xe - me + He;
2146
- if (Lt > le.messageCharacters)
2147
- throw new G("AI 助手响应文本超过大小限制");
2148
- Xe = Lt, Ye.set(R.messageId, He);
2273
+ if (E.type === "message.replace") {
2274
+ if (!Ve.has(E.messageId))
2275
+ throw new J("AI 助手响应事件顺序无效");
2276
+ const pe = je.get(E.messageId) ?? 0, Ue = it(
2277
+ E.content,
2278
+ ue.messageCharacters
2279
+ ), Tt = Ke - pe + Ue;
2280
+ if (Tt > ue.messageCharacters)
2281
+ throw new J("AI 助手响应文本超过大小限制");
2282
+ Ke = Tt, je.set(E.messageId, Ue);
2149
2283
  }
2150
- if (R.type === "run.progress") {
2151
- if (se !== void 0 && se !== R.runId)
2152
- throw new G("AI 助手响应 run id 不一致");
2153
- if (se ??= R.runId, Nt += 1, Nt > le.progressStepsPerRun)
2154
- throw new G("AI 助手处理过程数量超过限制");
2155
- const me = dt(
2156
- R.message,
2157
- le.progressCharactersPerRun - ht
2284
+ if (E.type === "run.progress") {
2285
+ if (re !== void 0 && re !== E.runId)
2286
+ throw new J("AI 助手响应 run id 不一致");
2287
+ if (re ??= E.runId, wt += 1, wt > ue.progressStepsPerRun)
2288
+ throw new J("AI 助手处理过程数量超过限制");
2289
+ const pe = it(
2290
+ E.message,
2291
+ ue.progressCharactersPerRun - ut
2158
2292
  );
2159
- if (ht + me > le.progressCharactersPerRun)
2160
- throw new G("AI 助手处理过程文本超过大小限制");
2161
- ht += me;
2293
+ if (ut + pe > ue.progressCharactersPerRun)
2294
+ throw new J("AI 助手处理过程文本超过大小限制");
2295
+ ut += pe;
2162
2296
  }
2163
- if (R.type === "artifact") {
2164
- if (!Ze.has(R.messageId))
2165
- throw new G("AI 助手响应事件顺序无效");
2166
- if (Tt += 1, Tt > le.artifactsPerRun)
2167
- throw new G("AI 助手单次响应 Artifact 数量超过限制");
2168
- if (Rt.has(R.artifact.id))
2169
- throw new G("AI 助手响应包含重复的 Artifact id");
2170
- Rt.add(R.artifact.id);
2297
+ if (E.type === "artifact") {
2298
+ if (!Ve.has(E.messageId))
2299
+ throw new J("AI 助手响应事件顺序无效");
2300
+ if (kt += 1, kt > ue.artifactsPerRun)
2301
+ throw new J("AI 助手单次响应 Artifact 数量超过限制");
2302
+ if (It.has(E.artifact.id))
2303
+ throw new J("AI 助手响应包含重复的 Artifact id");
2304
+ It.add(E.artifact.id);
2171
2305
  }
2172
- if (R.type === "message.complete" && !Ze.delete(R.messageId))
2173
- throw new G("AI 助手响应事件顺序无效");
2174
- if (R.type === "run.complete" && se !== void 0 && se !== R.runId)
2175
- throw new G("AI 助手响应 run id 不一致");
2176
- if (R.type === "run.cancelled" && R.runId !== void 0 && se !== void 0 && se !== R.runId)
2177
- throw new G("AI 助手响应 run id 不一致");
2178
- if (b((me) => Ie(me, R)), R.type === "error" || R.type === "run.cancelled" || R.type === "run.complete") {
2179
- Le = !0;
2306
+ if (E.type === "message.complete" && !Ve.delete(E.messageId))
2307
+ throw new J("AI 助手响应事件顺序无效");
2308
+ if (E.type === "run.complete" && re !== void 0 && re !== E.runId)
2309
+ throw new J("AI 助手响应 run id 不一致");
2310
+ if (E.type === "run.cancelled" && E.runId !== void 0 && re !== void 0 && re !== E.runId)
2311
+ throw new J("AI 助手响应 run id 不一致");
2312
+ if (ne((pe) => Me(pe, E)), E.type === "error" || E.type === "run.cancelled" || E.type === "run.complete") {
2313
+ Te = !0;
2180
2314
  break;
2181
2315
  }
2182
2316
  }
2183
- if (!Le)
2184
- throw new G("AI 助手流式响应在终止事件前结束");
2185
- } catch (Le) {
2186
- if (xe.current !== ze) return;
2187
- if (ct.signal.aborted) {
2188
- b(
2189
- (se) => Ie(se, { type: "run.cancelled" })
2317
+ if (!Te)
2318
+ throw new J("AI 助手流式响应在终止事件前结束");
2319
+ } catch (Te) {
2320
+ if (te.current !== Be) return;
2321
+ if (nt.signal.aborted) {
2322
+ ne(
2323
+ (re) => Me(re, { type: "run.cancelled" })
2190
2324
  );
2191
2325
  return;
2192
2326
  }
2193
2327
  console.error("[make-ai-assistant] assistant run failed", {
2194
- appId: n.app.id,
2195
- errorType: Le instanceof Error ? Le.name : typeof Le
2196
- }), b(
2197
- (se) => Ie(se, {
2328
+ appId: s.app.id,
2329
+ errorType: Te instanceof Error ? Te.name : typeof Te
2330
+ }), ne(
2331
+ (re) => Me(re, {
2198
2332
  type: "error",
2199
2333
  code: "TRANSPORT_ERROR",
2200
- message: Le instanceof G ? Le.message : "连接失败,请重试",
2334
+ message: Te instanceof J ? Te.message : "连接失败,请重试",
2201
2335
  retryable: !0
2202
2336
  })
2203
2337
  );
2204
2338
  } finally {
2205
- xe.current === ze && Ee.current === ct && (Ee.current = void 0), Se.current?.requestVersion === ze && (Ot(Se.current.iterator), Se.current = void 0);
2339
+ te.current === Be && we.current === nt && (we.current = void 0), be.current?.requestVersion === Be && (Bt(be.current.iterator), be.current = void 0);
2206
2340
  }
2207
- }, st = (m) => {
2208
- if (v.enabled) {
2209
- if (u.pending)
2210
- return te("请等待附件上传完成,或移除失败的附件"), Promise.resolve();
2211
- if (u.parts.some((U) => !y.features?.modelInputKinds?.includes(U.kind)))
2212
- return te("当前模型尚未开放此类附件理解,已上传原件可保留或移除"), Promise.resolve();
2213
- const P = m.trim(), F = u.parts.length ? [...P ? [{ id: We(), kind: "text", text: P }] : [], ...u.parts] : void 0;
2214
- return D(""), u.clear(), v.send(P, F);
2341
+ }, u = (m) => {
2342
+ if (g.enabled) {
2343
+ if (R.pending)
2344
+ return B("请等待附件上传完成,或移除失败的附件"), Promise.resolve();
2345
+ const K = m.trim(), X = R.parts.length ? [...K ? [{ id: Pe(), kind: "text", text: K }] : [], ...R.parts] : void 0;
2346
+ return q(""), R.clear(), g.send(K, X);
2215
2347
  }
2216
- return wt(m);
2217
- }, da = (m) => wt(m.userMessage.content, { regenerateFrom: m }), ua = async (m, P) => {
2348
+ return r(m);
2349
+ }, y = (m) => r(m.userMessage.content, { regenerateFrom: m }), w = async (m, K) => {
2218
2350
  try {
2219
- await rn(P), S({ messageId: m, message: "已复制", status: "success" });
2220
- } catch (F) {
2351
+ await Ga(K), W({ messageId: m, message: "已复制", status: "success" });
2352
+ } catch (X) {
2221
2353
  console.error("[make-ai-assistant] copy answer failed", {
2222
- errorType: F instanceof Error ? F.name : typeof F
2223
- }), S({ messageId: m, message: "复制失败", status: "error" });
2354
+ errorType: X instanceof Error ? X.name : typeof X
2355
+ }), W({ messageId: m, message: "复制失败", status: "error" });
2224
2356
  }
2225
- }, ma = (m) => {
2226
- m.preventDefault(), st(K);
2227
- }, ha = (m) => {
2228
- m.key === "Enter" && !m.shiftKey && !m.nativeEvent.isComposing && (m.preventDefault(), st(K));
2229
- }, pa = () => {
2230
- if (v.enabled) {
2231
- v.stop();
2357
+ }, C = (m) => {
2358
+ m.preventDefault(), u(k);
2359
+ }, D = (m) => {
2360
+ m.key === "Enter" && !m.shiftKey && !m.nativeEvent.isComposing && (m.preventDefault(), u(k));
2361
+ }, _ = () => {
2362
+ if (g.enabled) {
2363
+ g.stop();
2232
2364
  return;
2233
2365
  }
2234
- _e("stop") && b(
2235
- (m) => Ie(m, { type: "run.cancelled" })
2366
+ xe("stop") && ne(
2367
+ (m) => Me(m, { type: "run.cancelled" })
2236
2368
  );
2237
- }, It = () => {
2238
- if (pe(!1), v.enabled) {
2239
- D(""), v.create(), d?.();
2369
+ }, Z = () => {
2370
+ if (z(!1), g.enabled) {
2371
+ q(""), g.create(), d?.();
2240
2372
  return;
2241
2373
  }
2242
- _e("new-conversation"), D(""), te(void 0), S(void 0), de(!1), M.current = !0, b(he()), d?.();
2243
- }, At = v.enabled && v.cancelling.length ? "停止中" : y.features?.remoteCancellation === !1 ? "停止接收" : "停止生成", fa = na(w), va = sa(w), rt = In(w), ga = typeof y.regenerate == "function" && y.features?.regeneration !== !1, Mt = () => {
2244
- if (v.enabled) {
2245
- v.retry();
2374
+ xe("new-conversation"), q(""), B(void 0), W(void 0), ye(!1), me.current = !0, ne(fe()), d?.();
2375
+ }, O = g.enabled && g.cancelling.length ? "停止中" : T.features?.remoteCancellation === !1 ? "停止接收" : "停止生成", H = Qt(F), Ie = ea(F), Le = ms(F), tt = typeof T.regenerate == "function" && T.features?.regeneration !== !1, he = () => {
2376
+ if (g.enabled) {
2377
+ g.retry();
2246
2378
  return;
2247
2379
  }
2248
- rt && st(rt.content);
2249
- }, ya = (m) => {
2250
- if (m.key === "Escape" && !(!X && !oe)) {
2251
- if (m.preventDefault(), m.stopPropagation(), X) {
2252
- ie(!1), $e.current?.focus();
2380
+ Le && u(Le.content);
2381
+ }, De = (m) => {
2382
+ if (m.key === "Escape" && !(!I && !Y)) {
2383
+ if (m.preventDefault(), m.stopPropagation(), I) {
2384
+ G(!1), He.current?.focus();
2253
2385
  return;
2254
2386
  }
2255
- pe(!1), r.current?.focus();
2387
+ z(!1), Ee.current?.focus();
2256
2388
  }
2257
2389
  };
2258
- return /* @__PURE__ */ c(
2390
+ return /* @__PURE__ */ l(
2259
2391
  "section",
2260
2392
  {
2261
- className: `make-ai-assistant make-ai-assistant__panel${v.enabled ? " make-ai-assistant__panel--managed" : ""}`,
2262
- ref: at,
2263
- style: J,
2264
- onKeyDown: ya,
2393
+ className: `make-ai-assistant make-ai-assistant__panel${g.enabled ? " make-ai-assistant__panel--managed" : ""}`,
2394
+ ref: Ce,
2395
+ style: v,
2396
+ onKeyDown: De,
2265
2397
  onDragOver: (m) => {
2266
- u.enabled && m.dataTransfer.types.includes("Files") && m.preventDefault();
2398
+ R.enabled && m.dataTransfer.types.includes("Files") && m.preventDefault();
2267
2399
  },
2268
2400
  onDrop: (m) => {
2269
- u.enabled && m.dataTransfer.files.length && (m.preventDefault(), u.add(Array.from(m.dataTransfer.files)));
2401
+ R.enabled && m.dataTransfer.files.length && (m.preventDefault(), R.add(Array.from(m.dataTransfer.files)));
2270
2402
  },
2271
2403
  children: [
2272
- /* @__PURE__ */ c("header", { className: "make-ai-assistant__header", children: [
2273
- /* @__PURE__ */ a("div", { className: "make-ai-assistant__header-leading", children: v.enabled ? /* @__PURE__ */ c(
2404
+ /* @__PURE__ */ l("header", { className: "make-ai-assistant__header", children: [
2405
+ /* @__PURE__ */ a("div", { className: "make-ai-assistant__header-leading", children: g.enabled ? /* @__PURE__ */ l(
2274
2406
  "button",
2275
2407
  {
2276
- "aria-controls": z,
2277
- "aria-expanded": oe,
2408
+ "aria-controls": Je,
2409
+ "aria-expanded": Y,
2278
2410
  "aria-haspopup": "dialog",
2279
2411
  "aria-label": "任务列表",
2280
2412
  className: "make-ai-assistant__task-list-trigger",
2281
- ref: r,
2413
+ ref: Ee,
2282
2414
  type: "button",
2283
- onClick: () => pe((m) => !m),
2415
+ onClick: () => z((m) => !m),
2284
2416
  children: [
2285
- /* @__PURE__ */ a(hn, {}),
2417
+ /* @__PURE__ */ a(as, {}),
2286
2418
  /* @__PURE__ */ a("span", { children: "任务列表" }),
2287
- /* @__PURE__ */ a(pn, {})
2419
+ /* @__PURE__ */ a(ss, {})
2288
2420
  ]
2289
2421
  }
2290
2422
  ) : null }),
2291
- /* @__PURE__ */ c("div", { className: "make-ai-assistant__header-center", children: [
2292
- /* @__PURE__ */ a(mt, {}),
2293
- /* @__PURE__ */ c("div", { className: "make-ai-assistant__header-content", children: [
2294
- /* @__PURE__ */ c("div", { className: "make-ai-assistant__header-title-row", children: [
2295
- /* @__PURE__ */ a("h2", { className: "make-ai-assistant__header-title", title: l, children: l }),
2296
- v.enabled ? /* @__PURE__ */ a("span", { className: "make-ai-assistant__current-conversation", children: v.chat?.title || "新对话" }) : null,
2297
- /* @__PURE__ */ a("span", { className: "make-ai-assistant__read-only-tag", children: "只读" })
2298
- ] }),
2299
- /* @__PURE__ */ c("div", { className: "make-ai-assistant__header-context", children: [
2300
- /* @__PURE__ */ a("p", { title: L, children: L }),
2301
- T ? /* @__PURE__ */ c(Ae, { children: [
2302
- /* @__PURE__ */ a(
2303
- "span",
2304
- {
2305
- "aria-describedby": W,
2306
- "aria-label": `使用提示:${T}`,
2307
- className: "make-ai-assistant__header-context-help",
2308
- "data-tooltip": T,
2309
- ref: h,
2310
- role: "note",
2311
- tabIndex: 0,
2312
- onBlur: ue,
2313
- onFocus: Ve,
2314
- onPointerEnter: Ve,
2315
- onPointerLeave: ue,
2316
- children: /* @__PURE__ */ a(dn, {})
2317
- }
2318
- ),
2319
- /* @__PURE__ */ a(
2320
- "span",
2321
- {
2322
- "aria-hidden": !ve,
2323
- className: "make-ai-assistant__header-context-tooltip",
2324
- "data-placement": Re?.placement,
2325
- "data-positioned": Re ? !0 : void 0,
2326
- "data-visible": ve || void 0,
2327
- id: W,
2328
- ref: _,
2329
- role: "tooltip",
2330
- style: Be,
2331
- children: T
2332
- }
2333
- )
2334
- ] }) : null
2335
- ] })
2336
- ] })
2423
+ /* @__PURE__ */ l("div", { className: "make-ai-assistant__header-center", children: [
2424
+ /* @__PURE__ */ a(ct, {}),
2425
+ /* @__PURE__ */ a("h2", { className: "make-ai-assistant__header-title", title: P, children: P })
2337
2426
  ] }),
2338
- /* @__PURE__ */ c("div", { className: "make-ai-assistant__header-actions", children: [
2339
- y.features?.newConversation !== !1 ? /* @__PURE__ */ a(
2427
+ /* @__PURE__ */ l("div", { className: "make-ai-assistant__header-actions", children: [
2428
+ T.features?.newConversation !== !1 ? /* @__PURE__ */ a(
2340
2429
  "button",
2341
2430
  {
2342
2431
  "aria-label": "新建对话",
2343
2432
  className: "make-ai-assistant__icon-button",
2344
2433
  type: "button",
2345
- onClick: It,
2346
- children: /* @__PURE__ */ a(mn, {})
2434
+ onClick: Z,
2435
+ children: /* @__PURE__ */ a(ts, {})
2347
2436
  }
2348
2437
  ) : null,
2349
- o ? /* @__PURE__ */ a(
2438
+ c ? /* @__PURE__ */ a(
2350
2439
  "button",
2351
2440
  {
2352
- "aria-label": `关闭 ${l}`,
2441
+ "aria-label": `关闭 ${P}`,
2353
2442
  className: "make-ai-assistant__icon-button",
2354
2443
  type: "button",
2355
- onClick: o,
2356
- children: /* @__PURE__ */ a(on, {})
2444
+ onClick: c,
2445
+ children: /* @__PURE__ */ a(Ya, {})
2357
2446
  }
2358
2447
  ) : null
2359
2448
  ] })
2360
2449
  ] }),
2361
- v.enabled && oe ? /* @__PURE__ */ a(
2362
- Fa,
2450
+ g.enabled && Y ? /* @__PURE__ */ a(
2451
+ Ra,
2363
2452
  {
2364
- id: z,
2365
- manager: v,
2366
- triggerRef: r,
2367
- onDismiss: () => pe(!1),
2368
- onNewConversation: y.features?.newConversation !== !1 ? It : void 0
2453
+ id: Je,
2454
+ manager: g,
2455
+ triggerRef: Ee,
2456
+ onDismiss: () => z(!1),
2457
+ onNewConversation: T.features?.newConversation !== !1 ? Z : void 0
2369
2458
  }
2370
2459
  ) : null,
2371
- /* @__PURE__ */ c(
2460
+ /* @__PURE__ */ l(
2372
2461
  "div",
2373
2462
  {
2374
2463
  className: "make-ai-assistant__body",
2375
2464
  "aria-live": "polite",
2376
2465
  "aria-relevant": "additions text",
2377
- ref: Pe,
2466
+ ref: ke,
2378
2467
  role: "log",
2379
- onScroll: ca,
2468
+ onScroll: dt,
2380
2469
  children: [
2381
- Q === "loading" ? /* @__PURE__ */ c("div", { className: "make-ai-assistant__empty", role: "status", children: [
2382
- /* @__PURE__ */ a(mt, {}),
2470
+ ee === "loading" ? /* @__PURE__ */ l("div", { className: "make-ai-assistant__empty", role: "status", children: [
2471
+ /* @__PURE__ */ a(ct, {}),
2383
2472
  /* @__PURE__ */ a("h3", { children: "正在恢复对话" }),
2384
2473
  /* @__PURE__ */ a("p", { children: "正在读取当前 App 的历史消息…" })
2385
- ] }) : Q === "error" ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__empty", children: /* @__PURE__ */ a(
2386
- Tn,
2474
+ ] }) : ee === "error" ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__empty", children: /* @__PURE__ */ a(
2475
+ fs,
2387
2476
  {
2388
- error: ke,
2389
- onRetry: () => ce((m) => m + 1)
2477
+ error: le,
2478
+ onRetry: () => ge((m) => m + 1)
2390
2479
  }
2391
- ) }) : w.messages.length === 0 ? /* @__PURE__ */ c("div", { className: "make-ai-assistant__empty", children: [
2392
- /* @__PURE__ */ a(mt, {}),
2480
+ ) }) : F.messages.length === 0 ? /* @__PURE__ */ l("div", { className: "make-ai-assistant__empty", children: [
2481
+ /* @__PURE__ */ a(ct, {}),
2393
2482
  /* @__PURE__ */ a("h3", { children: "有什么可以帮你?" }),
2394
2483
  /* @__PURE__ */ a("p", { children: "我会结合当前 App、页面位置和宿主允许的上下文回答,并把过程与结果分开展示。" })
2395
- ] }) : Nn(
2396
- w,
2397
- n,
2398
- B,
2399
- q,
2400
- i,
2484
+ ] }) : gs(
2485
+ F,
2401
2486
  s,
2487
+ Qe,
2488
+ L,
2489
+ i,
2490
+ o,
2402
2491
  e,
2403
- rt ? Mt : void 0,
2404
- ee,
2405
- V,
2406
- De,
2407
- ga,
2408
- (m, P) => {
2409
- ua(m, P);
2492
+ Le ? he : void 0,
2493
+ M,
2494
+ j,
2495
+ A,
2496
+ tt,
2497
+ (m, K) => {
2498
+ w(m, K);
2410
2499
  },
2411
2500
  (m) => {
2412
- da(m);
2501
+ y(m);
2413
2502
  },
2414
- v.enabled ? v : void 0,
2415
- y
2503
+ g.enabled ? g : void 0,
2504
+ T
2416
2505
  ),
2417
- w.progress && !fa ? /* @__PURE__ */ a(
2418
- Kt,
2506
+ F.progress && !H ? /* @__PURE__ */ a(
2507
+ zt,
2419
2508
  {
2420
2509
  assistantName: e,
2421
- progress: w.progress
2510
+ progress: F.progress
2422
2511
  }
2423
2512
  ) : null,
2424
- w.error && !va ? /* @__PURE__ */ a(
2425
- Kt,
2513
+ F.error && !Ie ? /* @__PURE__ */ a(
2514
+ zt,
2426
2515
  {
2427
2516
  assistantName: e,
2428
- error: w.error,
2429
- onRetry: rt ? Mt : void 0
2517
+ error: F.error,
2518
+ onRetry: Le ? he : void 0
2430
2519
  }
2431
2520
  ) : null
2432
2521
  ]
2433
2522
  }
2434
2523
  ),
2435
- Qe ? /* @__PURE__ */ a(
2524
+ lt ? /* @__PURE__ */ a(
2436
2525
  "button",
2437
2526
  {
2438
2527
  "aria-label": "回到最新消息",
2439
2528
  className: "make-ai-assistant__back-to-latest",
2440
2529
  type: "button",
2441
- onClick: la,
2442
- children: /* @__PURE__ */ a(un, {})
2530
+ onClick: Se,
2531
+ children: /* @__PURE__ */ a(es, {})
2443
2532
  }
2444
2533
  ) : null,
2445
- /* @__PURE__ */ c("footer", { className: "make-ai-assistant__composer-region", children: [
2446
- u.enabled ? /* @__PURE__ */ a(qa, { attachments: u }) : null,
2447
- Q === "ready" && ge.length > 0 && w.messages.length === 0 ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__suggestions", "aria-label": "推荐问题", children: ge.map((m, P) => /* @__PURE__ */ a(
2534
+ /* @__PURE__ */ l("footer", { className: "make-ai-assistant__composer-region", children: [
2535
+ R.enabled ? /* @__PURE__ */ a(Fa, { attachments: R }) : null,
2536
+ ee === "ready" && et.length > 0 && F.messages.length === 0 ? /* @__PURE__ */ a("div", { className: "make-ai-assistant__suggestions", "aria-label": "推荐问题", children: et.map((m, K) => /* @__PURE__ */ a(
2448
2537
  "button",
2449
2538
  {
2450
2539
  type: "button",
2451
2540
  onClick: () => {
2452
- st(m);
2541
+ u(m);
2453
2542
  },
2454
2543
  children: m
2455
2544
  },
2456
- `${P}-${m}`
2545
+ `${K}-${m}`
2457
2546
  )) }) : null,
2458
- /* @__PURE__ */ c("form", { className: "make-ai-assistant__composer", onSubmit: ma, children: [
2547
+ /* @__PURE__ */ l("form", { className: "make-ai-assistant__composer", onSubmit: C, children: [
2459
2548
  /* @__PURE__ */ a(
2460
2549
  "textarea",
2461
2550
  {
2462
2551
  "aria-label": `向 ${e} 提问`,
2463
- "aria-describedby": Z ? "make-ai-composer-error" : void 0,
2464
- "aria-invalid": Z ? !0 : void 0,
2552
+ "aria-describedby": V ? "make-ai-composer-error" : void 0,
2553
+ "aria-invalid": V ? !0 : void 0,
2465
2554
  autoFocus: !0,
2466
- disabled: Q !== "ready" || !v.enabled && w.status === "streaming",
2467
- placeholder: `询问当前 ${n.app.name ?? "App"} 中的数据…`,
2468
- ref: nt,
2555
+ disabled: ee !== "ready" || !g.enabled && F.status === "streaming",
2556
+ placeholder: `询问当前 ${s.app.name ?? "App"} 中的数据…`,
2557
+ ref: Oe,
2469
2558
  rows: 2,
2470
- value: K,
2559
+ value: k,
2471
2560
  onChange: (m) => {
2472
- D(m.currentTarget.value), te(void 0);
2561
+ q(m.currentTarget.value), B(void 0);
2473
2562
  },
2474
- onKeyDown: ha,
2563
+ onKeyDown: D,
2475
2564
  onPaste: (m) => {
2476
- u.enabled && m.clipboardData.files.length && (m.preventDefault(), u.add(Array.from(m.clipboardData.files)));
2565
+ R.enabled && m.clipboardData.files.length && (m.preventDefault(), R.add(Array.from(m.clipboardData.files)));
2477
2566
  }
2478
2567
  }
2479
2568
  ),
2480
- u.enabled ? /* @__PURE__ */ a(
2569
+ R.enabled ? /* @__PURE__ */ a(
2481
2570
  Ua,
2482
2571
  {
2483
- attachments: u,
2484
- open: X,
2485
- triggerRef: $e,
2486
- onOpenChange: ie
2572
+ attachments: R,
2573
+ open: I,
2574
+ triggerRef: He,
2575
+ onOpenChange: G
2487
2576
  }
2488
2577
  ) : null,
2489
- /* @__PURE__ */ c("div", { className: "make-ai-assistant__composer-actions", children: [
2490
- w.status === "streaming" ? /* @__PURE__ */ a(
2578
+ /* @__PURE__ */ l("div", { className: "make-ai-assistant__composer-actions", children: [
2579
+ F.status === "streaming" ? /* @__PURE__ */ a(
2491
2580
  "button",
2492
2581
  {
2493
- "aria-label": At,
2582
+ "aria-label": O,
2494
2583
  className: "make-ai-assistant__send make-ai-assistant__send--stop",
2495
- "data-tooltip": At,
2496
- ref: A,
2497
- disabled: v.enabled && v.cancelling.includes(w.activeRunId ?? ""),
2584
+ "data-tooltip": O,
2585
+ ref: Xe,
2586
+ disabled: g.enabled && g.cancelling.includes(F.activeRunId ?? ""),
2498
2587
  type: "button",
2499
- onClick: pa,
2588
+ onClick: _,
2500
2589
  children: /* @__PURE__ */ a("span", { "aria-hidden": "true" })
2501
2590
  }
2502
2591
  ) : /* @__PURE__ */ a(
@@ -2504,154 +2593,154 @@ function oa({
2504
2593
  {
2505
2594
  "aria-label": "发送",
2506
2595
  className: "make-ai-assistant__send",
2507
- disabled: Q !== "ready" || u.pending || !K.trim() && !u.parts.length,
2596
+ disabled: ee !== "ready" || R.pending || !k.trim() && !R.parts.length,
2508
2597
  type: "submit",
2509
- children: /* @__PURE__ */ a(Wt, {})
2598
+ children: /* @__PURE__ */ a(Ut, {})
2510
2599
  }
2511
2600
  ),
2512
- v.enabled && w.status === "streaming" ? /* @__PURE__ */ a("button", { "aria-label": "发送", className: "make-ai-assistant__send", disabled: v.busy || u.pending || !K.trim() && !u.parts.length, type: "submit", children: /* @__PURE__ */ a(Wt, {}) }) : null
2601
+ g.enabled && F.status === "streaming" ? /* @__PURE__ */ a("button", { "aria-label": "发送", className: "make-ai-assistant__send", disabled: g.busy || R.pending || !k.trim() && !R.parts.length, type: "submit", children: /* @__PURE__ */ a(Ut, {}) }) : null
2513
2602
  ] })
2514
2603
  ] }),
2515
- Z ? /* @__PURE__ */ a("p", { id: "make-ai-composer-error", role: "alert", children: Z }) : null,
2604
+ V ? /* @__PURE__ */ a("p", { id: "make-ai-composer-error", role: "alert", children: V }) : null,
2516
2605
  /* @__PURE__ */ a("p", { children: "AI 生成的结果可能存在偏差,重要数据请核对明细。" })
2517
2606
  ] })
2518
2607
  ]
2519
2608
  }
2520
2609
  );
2521
2610
  }
2522
- function $n(e) {
2523
- return /* @__PURE__ */ a(oa, { ...e, visible: !0 });
2611
+ function Is(e) {
2612
+ return /* @__PURE__ */ a(sa, { ...e, visible: !0 });
2524
2613
  }
2525
- function Ln({
2614
+ function As({
2526
2615
  defaultOpen: e = !1,
2527
2616
  hideLauncher: t = !1,
2528
- launcher: n,
2617
+ launcher: s,
2529
2618
  launcherPosition: i = "bottom-right",
2530
- maxDrawerWidth: s,
2531
- onOpenChange: o,
2619
+ maxDrawerWidth: o,
2620
+ onOpenChange: c,
2532
2621
  open: d,
2533
- ...g
2622
+ ...h
2534
2623
  }) {
2535
- const f = Jt(g.brandName, g.title), [p, k] = N(e), [$, O] = N(
2624
+ const b = Zt(h.brandName, h.title), [f, $] = N(e), [L, T] = N(
2536
2625
  () => e || d === !0
2537
- ), q = C(null), y = C(null), V = C(void 0), [ee, j] = N(), [v, u] = N(Ga), [l, T] = N(!1), L = d ?? p, re = kt(g.theme), E = Qa(s), J = () => en(
2538
- v,
2539
- E,
2540
- typeof window > "u" ? Qt : window.innerWidth
2541
- ), K = J(), D = ee === void 0 ? void 0 : vt(ee, v, K), X = D === void 0 && E === void 0 ? void 0 : {
2542
- ...D === void 0 ? {} : { "--make-ai-internal-drawer-width": `${D}px` },
2543
- ...E === void 0 ? {} : {
2544
- "--make-ai-internal-drawer-max-width": `max(var(--make-ai-internal-drawer-min-width), ${E}px)`
2626
+ ), j = S(null), M = S(null), U = S(void 0), [g, R] = N(), [P, p] = N(Ha), [n, v] = N(!1), k = d ?? f, q = yt(h.theme), I = Ka(o), G = () => ja(
2627
+ P,
2628
+ I,
2629
+ typeof window > "u" ? Xt : window.innerWidth
2630
+ ), Y = G(), z = g === void 0 ? void 0 : pt(g, P, Y), Q = z === void 0 && I === void 0 ? void 0 : {
2631
+ ...z === void 0 ? {} : { "--make-ai-internal-drawer-width": `${z}px` },
2632
+ ...I === void 0 ? {} : {
2633
+ "--make-ai-internal-drawer-max-width": `max(var(--make-ai-internal-drawer-min-width), ${I}px)`
2545
2634
  }
2546
2635
  };
2547
- bt(() => {
2548
- D !== void 0 && D !== ee && j(D);
2549
- }, [D, ee]);
2550
- const ie = () => {
2551
- if (D !== void 0) return D;
2552
- const b = y.current?.getBoundingClientRect().width;
2553
- return b && Number.isFinite(b) && b > 0 ? b : v;
2554
- }, oe = (b) => {
2555
- if (b.button !== 0) return;
2556
- const H = ie(), Z = ee === void 0 ? H : v;
2557
- u(Z), V.current = {
2558
- minimumWidth: Z,
2559
- pointerId: b.pointerId,
2560
- startWidth: H,
2561
- startX: b.clientX
2562
- }, T(!0), typeof b.currentTarget.setPointerCapture == "function" && b.currentTarget.setPointerCapture(b.pointerId), b.preventDefault();
2563
- }, pe = (b) => {
2564
- const H = V.current;
2565
- if (!H || H.pointerId !== b.pointerId) return;
2566
- const Z = vt(
2567
- H.startWidth + H.startX - b.clientX,
2568
- H.minimumWidth,
2569
- J()
2636
+ gt(() => {
2637
+ z !== void 0 && z !== g && R(z);
2638
+ }, [z, g]);
2639
+ const ve = () => {
2640
+ if (z !== void 0) return z;
2641
+ const A = M.current?.getBoundingClientRect().width;
2642
+ return A && Number.isFinite(A) && A > 0 ? A : P;
2643
+ }, oe = (A) => {
2644
+ if (A.button !== 0) return;
2645
+ const W = ve(), ae = g === void 0 ? W : P;
2646
+ p(ae), U.current = {
2647
+ minimumWidth: ae,
2648
+ pointerId: A.pointerId,
2649
+ startWidth: W,
2650
+ startX: A.clientX
2651
+ }, v(!0), typeof A.currentTarget.setPointerCapture == "function" && A.currentTarget.setPointerCapture(A.pointerId), A.preventDefault();
2652
+ }, F = (A) => {
2653
+ const W = U.current;
2654
+ if (!W || W.pointerId !== A.pointerId) return;
2655
+ const ae = pt(
2656
+ W.startWidth + W.startX - A.clientX,
2657
+ W.minimumWidth,
2658
+ G()
2570
2659
  );
2571
- j(Z);
2572
- }, Me = (b) => {
2573
- const H = V.current;
2574
- !H || H.pointerId !== b.pointerId || (V.current = void 0, T(!1));
2575
- }, Te = (b) => {
2576
- const H = b.key === "ArrowLeft" ? zt : b.key === "ArrowRight" ? -zt : void 0;
2577
- if (H === void 0) return;
2578
- b.preventDefault();
2579
- const Z = ie(), te = ee === void 0 ? Z : v;
2580
- u(te), j(vt(
2581
- Z + H,
2582
- te,
2583
- J()
2660
+ R(ae);
2661
+ }, ne = (A) => {
2662
+ const W = U.current;
2663
+ !W || W.pointerId !== A.pointerId || (U.current = void 0, v(!1));
2664
+ }, ce = (A) => {
2665
+ const W = A.key === "ArrowLeft" ? Dt : A.key === "ArrowRight" ? -Dt : void 0;
2666
+ if (W === void 0) return;
2667
+ A.preventDefault();
2668
+ const ae = ve(), ge = g === void 0 ? ae : P;
2669
+ p(ge), R(pt(
2670
+ ae + W,
2671
+ ge,
2672
+ G()
2584
2673
  ));
2585
- }, Y = (b) => {
2586
- d === void 0 && k(b), o?.(b), b || requestAnimationFrame(() => q.current?.focus());
2587
- }, w = () => Y(!L);
2588
- return ae(() => {
2589
- L && O(!0);
2590
- }, [L]), ae(() => {
2591
- if (!L) return;
2592
- const b = (H) => {
2593
- H.key === "Escape" && (Y(!1), requestAnimationFrame(() => q.current?.focus()));
2674
+ }, V = (A) => {
2675
+ d === void 0 && $(A), c?.(A), A || requestAnimationFrame(() => j.current?.focus());
2676
+ }, B = () => V(!k);
2677
+ return ie(() => {
2678
+ k && T(!0);
2679
+ }, [k]), ie(() => {
2680
+ if (!k) return;
2681
+ const A = (W) => {
2682
+ W.key === "Escape" && (V(!1), requestAnimationFrame(() => j.current?.focus()));
2594
2683
  };
2595
- return document.addEventListener("keydown", b), () => document.removeEventListener("keydown", b);
2596
- }, [o, L]), /* @__PURE__ */ c(
2684
+ return document.addEventListener("keydown", A), () => document.removeEventListener("keydown", A);
2685
+ }, [c, k]), /* @__PURE__ */ l(
2597
2686
  "div",
2598
2687
  {
2599
2688
  className: "make-ai-assistant",
2600
- "data-open": L || void 0,
2601
- style: re,
2689
+ "data-open": k || void 0,
2690
+ style: q,
2602
2691
  children: [
2603
- !t && (!L || n) ? n ? n({ open: L, toggle: w }) : /* @__PURE__ */ c(
2692
+ !t && (!k || s) ? s ? s({ open: k, toggle: B }) : /* @__PURE__ */ l(
2604
2693
  "button",
2605
2694
  {
2606
- "aria-label": L ? `关闭 ${f}` : `打开 ${f}`,
2607
- "aria-expanded": L,
2695
+ "aria-label": k ? `关闭 ${b}` : `打开 ${b}`,
2696
+ "aria-expanded": k,
2608
2697
  className: "make-ai-assistant__launcher",
2609
2698
  "data-launcher-position": i,
2610
- ref: q,
2699
+ ref: j,
2611
2700
  type: "button",
2612
- onClick: w,
2701
+ onClick: B,
2613
2702
  children: [
2614
2703
  /* @__PURE__ */ a("span", { className: "make-ai-assistant__launcher-orbit", "aria-hidden": "true" }),
2615
- /* @__PURE__ */ a(ea, {})
2704
+ /* @__PURE__ */ a(Gt, {})
2616
2705
  ]
2617
2706
  }
2618
2707
  ) : null,
2619
- $ ? /* @__PURE__ */ c(
2708
+ L ? /* @__PURE__ */ l(
2620
2709
  "aside",
2621
2710
  {
2622
- "aria-label": f,
2711
+ "aria-label": b,
2623
2712
  "aria-modal": "false",
2624
2713
  className: "make-ai-assistant__drawer",
2625
- "data-resizing": l || void 0,
2626
- hidden: !L,
2627
- ref: y,
2714
+ "data-resizing": n || void 0,
2715
+ hidden: !k,
2716
+ ref: M,
2628
2717
  role: "dialog",
2629
- style: X,
2718
+ style: Q,
2630
2719
  children: [
2631
2720
  /* @__PURE__ */ a(
2632
2721
  "div",
2633
2722
  {
2634
2723
  "aria-label": "调整对话框宽度",
2635
2724
  "aria-orientation": "vertical",
2636
- "aria-valuemax": K,
2637
- "aria-valuemin": v,
2638
- "aria-valuenow": D ?? v,
2725
+ "aria-valuemax": Y,
2726
+ "aria-valuemin": P,
2727
+ "aria-valuenow": z ?? P,
2639
2728
  className: "make-ai-assistant__drawer-resize-handle",
2640
2729
  role: "separator",
2641
2730
  tabIndex: 0,
2642
- onKeyDown: Te,
2643
- onPointerCancel: Me,
2731
+ onKeyDown: ce,
2732
+ onPointerCancel: ne,
2644
2733
  onPointerDown: oe,
2645
- onPointerMove: pe,
2646
- onPointerUp: Me
2734
+ onPointerMove: F,
2735
+ onPointerUp: ne
2647
2736
  }
2648
2737
  ),
2649
2738
  /* @__PURE__ */ a(
2650
- oa,
2739
+ sa,
2651
2740
  {
2652
- ...g,
2653
- onClose: () => Y(!1),
2654
- visible: L
2741
+ ...h,
2742
+ onClose: () => V(!1),
2743
+ visible: k
2655
2744
  }
2656
2745
  )
2657
2746
  ]
@@ -2662,24 +2751,24 @@ function Ln({
2662
2751
  );
2663
2752
  }
2664
2753
  export {
2665
- Ia as ArtifactRenderer,
2666
- $n as AssistantPanel,
2667
- zn as MAKE_AI_ARTIFACT_KINDS,
2668
- Hn as MAKE_AI_ARTIFACT_LIMITS,
2669
- On as MAKE_AI_ARTIFACT_SCHEMA_VERSION,
2670
- le as MAKE_AI_CONVERSATION_LIMITS,
2671
- Ln as MakeAiAssistant,
2672
- Xt as appendUserMessage,
2673
- wa as createArtifactCapabilities,
2674
- Vt as createArtifactTemplateRegistry,
2675
- he as createAssistantConversationState,
2676
- $a as createPlatformArtifactRegistry,
2677
- Fn as extendArtifactTemplateRegistry,
2678
- Fe as formatArtifactValue,
2679
- Wn as parseArtifact,
2680
- jt as parseAssistantEvent,
2681
- xa as platformArtifactTemplates,
2682
- Ie as reduceAssistantEvent,
2683
- _a as resolveArtifactTemplate,
2684
- Un as validateArtifact
2754
+ da as ArtifactRenderer,
2755
+ Is as AssistantPanel,
2756
+ Rs as MAKE_AI_ARTIFACT_KINDS,
2757
+ Es as MAKE_AI_ARTIFACT_LIMITS,
2758
+ Ss as MAKE_AI_ARTIFACT_SCHEMA_VERSION,
2759
+ ue as MAKE_AI_CONVERSATION_LIMITS,
2760
+ As as MakeAiAssistant,
2761
+ Ht as appendUserMessage,
2762
+ ca as createArtifactCapabilities,
2763
+ Wt as createArtifactTemplateRegistry,
2764
+ fe as createAssistantConversationState,
2765
+ ka as createPlatformArtifactRegistry,
2766
+ Cs as extendArtifactTemplateRegistry,
2767
+ $e as formatArtifactValue,
2768
+ Ls as parseArtifact,
2769
+ Ot as parseAssistantEvent,
2770
+ ba as platformArtifactTemplates,
2771
+ Me as reduceAssistantEvent,
2772
+ oa as resolveArtifactTemplate,
2773
+ $s as validateArtifact
2685
2774
  };