@szjy/ai-coms 0.1.12 → 0.1.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/index.mjs CHANGED
@@ -1,15 +1,15 @@
1
- var it = Object.defineProperty;
2
- var lt = (r, e, a) => e in r ? it(r, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : r[e] = a;
3
- var U = (r, e, a) => lt(r, typeof e != "symbol" ? e + "" : e, a);
4
- import { computed as O, openBlock as w, createElementBlock as C, normalizeStyle as ue, createElementVNode as u, normalizeClass as ne, getCurrentInstance as je, ref as x, watch as Fe, onUnmounted as ct, createBlock as me, Transition as ge, withCtx as J, toDisplayString as q, withDirectives as He, vShow as qe, createCommentVNode as M, createVNode as j, nextTick as We, onBeforeUnmount as ut, resolveComponent as Ae, createTextVNode as fe, Fragment as pe, renderList as Ne, withKeys as dt, defineComponent as Ge, withModifiers as ht } from "vue";
5
- const ft = "/images/ai-round.png", pt = "/images/ai-sqrt.png", mt = "/images/bars-loading.svg";
6
- function Je(r) {
7
- return r.startsWith("http://") || r.startsWith("https://") ? r : `${location.protocol}//${location.host}${r}`;
1
+ var yt = Object.defineProperty;
2
+ var vt = (e, t, s) => t in e ? yt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
3
+ var M = (e, t, s) => vt(e, typeof t != "symbol" ? t + "" : t, s);
4
+ import { computed as N, openBlock as S, createElementBlock as x, normalizeStyle as ue, createElementVNode as d, normalizeClass as re, getCurrentInstance as Je, ref as T, watch as Pe, onUnmounted as wt, createBlock as ge, Transition as ye, withCtx as J, toDisplayString as W, withDirectives as Ke, vShow as Xe, createCommentVNode as $, createVNode as D, nextTick as Ye, onBeforeUnmount as bt, resolveComponent as Me, createTextVNode as pe, Fragment as me, renderList as Be, withKeys as kt, defineComponent as Ze, withModifiers as St } from "vue";
5
+ const Ct = "/images/ai-round.png", At = "/images/ai-sqrt.png", xt = "/images/bars-loading.svg";
6
+ function Qe(e) {
7
+ return e.startsWith("http://") || e.startsWith("https://") ? e : `${location.protocol}//${location.host}${e}`;
8
8
  }
9
- async function gt(r, e, a, t = "", o = {}) {
10
- const { projectId: n } = o, s = Je(t), i = new URL(`${s}/v1/chat/completions`), l = (o == null ? void 0 : o.authToken) || "app-oLZVFFdYyJX2QK3rdOLWsC2u";
9
+ async function Tt(e, t, s, r = "", o = {}) {
10
+ const { projectId: n } = o, a = Qe(r), i = new URL(`${a}/v1/chat/completions`), l = (o == null ? void 0 : o.authToken) || "app-oLZVFFdYyJX2QK3rdOLWsC2u";
11
11
  o != null && o.authToken || console.error("缺少 authToken!现在默认使用内网的 authToken");
12
- const y = new Request(i, {
12
+ const c = new Request(i, {
13
13
  method: "post",
14
14
  headers: {
15
15
  "Content-Type": "application/json",
@@ -19,8 +19,8 @@ async function gt(r, e, a, t = "", o = {}) {
19
19
  model: "dify",
20
20
  stream: !0,
21
21
  inputs: {
22
- token: e,
23
- projectCode: a,
22
+ token: t,
23
+ projectCode: s,
24
24
  ...n ? { projectId: n } : {}
25
25
  },
26
26
  messages: [
@@ -30,17 +30,17 @@ async function gt(r, e, a, t = "", o = {}) {
30
30
  },
31
31
  {
32
32
  role: "user",
33
- content: r
33
+ content: e
34
34
  }
35
35
  ]
36
36
  })
37
37
  });
38
- return fetch(y);
38
+ return fetch(c);
39
39
  }
40
- async function vt(r, e, a, t = "", o = {}) {
41
- const n = new URL("http://localhost:11434/api/chat"), s = {};
42
- Object.keys(s).forEach((l) => {
43
- n.searchParams.append(l, s[l]);
40
+ async function Rt(e, t, s, r = "", o = {}) {
41
+ const n = new URL("http://localhost:11434/api/chat"), a = {};
42
+ Object.keys(a).forEach((l) => {
43
+ n.searchParams.append(l, a[l]);
44
44
  });
45
45
  const i = new Request(n, {
46
46
  mode: "cors",
@@ -58,23 +58,23 @@ async function vt(r, e, a, t = "", o = {}) {
58
58
  },
59
59
  {
60
60
  role: "user",
61
- content: r
61
+ content: e
62
62
  }
63
63
  ]
64
64
  })
65
65
  });
66
66
  return fetch(i);
67
67
  }
68
- async function yt(r, e, a, t = "", o = {}) {
69
- const n = new URL(`${location.origin}/spark/v1/chat/completions`), s = {};
70
- Object.keys(s).forEach((l) => {
71
- n.searchParams.append(l, s[l]);
68
+ async function Ut(e, t, s, r = "", o = {}) {
69
+ const n = new URL(`${location.origin}/spark/v1/chat/completions`), a = {};
70
+ Object.keys(a).forEach((l) => {
71
+ n.searchParams.append(l, a[l]);
72
72
  });
73
73
  const i = new Request(n, {
74
74
  method: "post",
75
75
  headers: {
76
76
  "Content-Type": "application/json",
77
- Authorization: `Bearer ${e}`
77
+ Authorization: `Bearer ${t}`
78
78
  },
79
79
  body: JSON.stringify({
80
80
  model: "generalv4.0Ultra",
@@ -82,23 +82,23 @@ async function yt(r, e, a, t = "", o = {}) {
82
82
  messages: [
83
83
  {
84
84
  role: "user",
85
- content: r
85
+ content: e
86
86
  }
87
87
  ]
88
88
  })
89
89
  });
90
90
  return fetch(i);
91
91
  }
92
- async function wt(r, e, a, t = "", o = {}) {
93
- const n = new URL(`${location.origin}/siliconflow/v1/chat/completions`), s = {};
94
- Object.keys(s).forEach((l) => {
95
- n.searchParams.append(l, s[l]);
92
+ async function _t(e, t, s, r = "", o = {}) {
93
+ const n = new URL(`${location.origin}/siliconflow/v1/chat/completions`), a = {};
94
+ Object.keys(a).forEach((l) => {
95
+ n.searchParams.append(l, a[l]);
96
96
  });
97
97
  const i = new Request(n, {
98
98
  method: "post",
99
99
  headers: {
100
100
  "Content-Type": "application/json",
101
- Authorization: `Bearer ${e}`
101
+ Authorization: `Bearer ${t}`
102
102
  },
103
103
  body: JSON.stringify({
104
104
  // 集成了大部分模型,可以免费使用
@@ -107,23 +107,23 @@ async function wt(r, e, a, t = "", o = {}) {
107
107
  messages: [
108
108
  {
109
109
  role: "user",
110
- content: r
110
+ content: e
111
111
  }
112
112
  ]
113
113
  })
114
114
  });
115
115
  return fetch(i);
116
116
  }
117
- async function kt(r, e, a, t = "", o = {}) {
118
- const n = new URL(`${location.origin}/moonshot/v1/chat/completions`), s = {};
119
- Object.keys(s).forEach((l) => {
120
- n.searchParams.append(l, s[l]);
117
+ async function Pt(e, t, s, r = "", o = {}) {
118
+ const n = new URL(`${location.origin}/moonshot/v1/chat/completions`), a = {};
119
+ Object.keys(a).forEach((l) => {
120
+ n.searchParams.append(l, a[l]);
121
121
  });
122
122
  const i = new Request(n, {
123
123
  method: "post",
124
124
  headers: {
125
125
  "Content-Type": "application/json",
126
- Authorization: `Bearer ${e}`
126
+ Authorization: `Bearer ${t}`
127
127
  },
128
128
  body: JSON.stringify({
129
129
  model: "moonshot-v1-8k",
@@ -135,23 +135,23 @@ async function kt(r, e, a, t = "", o = {}) {
135
135
  },
136
136
  {
137
137
  role: "user",
138
- content: r
138
+ content: e
139
139
  }
140
140
  ]
141
141
  })
142
142
  });
143
143
  return fetch(i);
144
144
  }
145
- async function bt(r, e, a, t = "", o = {}) {
146
- const n = new URL(`${location.origin}/dashscope/compatible-mode/v1/chat/completions`), s = {};
147
- Object.keys(s).forEach((l) => {
148
- n.searchParams.append(l, s[l]);
145
+ async function Mt(e, t, s, r = "", o = {}) {
146
+ const n = new URL(`${location.origin}/dashscope/compatible-mode/v1/chat/completions`), a = {};
147
+ Object.keys(a).forEach((l) => {
148
+ n.searchParams.append(l, a[l]);
149
149
  });
150
150
  const i = new Request(n, {
151
151
  method: "post",
152
152
  headers: {
153
153
  "Content-Type": "application/json",
154
- Authorization: `Bearer ${e}`
154
+ Authorization: `Bearer ${t}`
155
155
  },
156
156
  body: JSON.stringify({
157
157
  model: "qwq-32b-preview",
@@ -163,197 +163,268 @@ async function bt(r, e, a, t = "", o = {}) {
163
163
  },
164
164
  {
165
165
  role: "user",
166
- content: r
166
+ content: e
167
167
  }
168
168
  ]
169
169
  })
170
170
  });
171
171
  return fetch(i);
172
172
  }
173
- async function St(r, e, a, t = "", o = {}) {
174
- const n = Je(t), s = new URL(`${n}/support/${a}/a`), i = {};
175
- Object.keys(i).forEach((y) => {
176
- s.searchParams.append(y, i[y]);
173
+ async function It(e, t, s, r = "", o = {}) {
174
+ const n = Qe(r), a = new URL(`${n}/support/${s}/a`), i = {};
175
+ Object.keys(i).forEach((c) => {
176
+ a.searchParams.append(c, i[c]);
177
177
  });
178
- const l = new Request(s, {
178
+ const l = new Request(a, {
179
179
  method: "post",
180
180
  headers: {
181
181
  "Content-Type": "application/json",
182
- Authorization: `Bearer ${e}`
182
+ Authorization: `Bearer ${t}`
183
183
  },
184
184
  body: JSON.stringify({
185
- content: r
185
+ content: e
186
186
  })
187
187
  });
188
188
  return fetch(l);
189
189
  }
190
- const Ct = (r) => {
191
- if (r.startsWith("data:")) {
192
- const e = r.substring(5).trim();
193
- if (e === "[DONE]")
190
+ const Et = [
191
+ "根据您的问题,我为您整理了以下构件:",
192
+ "",
193
+ "```szjy-ui",
194
+ JSON.stringify(
195
+ {
196
+ title: "构件列表",
197
+ type: "list",
198
+ gap: 12,
199
+ items: [
200
+ {
201
+ type: "button",
202
+ props: { type: "primary", content: "查看构件1(CHKS-TJ01-02-01-01-01-01)" },
203
+ action: "postMessage",
204
+ actionParams: {
205
+ type: "BIM_SANDBOX",
206
+ action: "locateComponent",
207
+ payload: { wbsCode: "CHKS-TJ01-02-01-01-01-01" }
208
+ }
209
+ },
210
+ {
211
+ type: "button",
212
+ props: { type: "primary", content: "查看构件2(CHKS-TJ01-02-01-01-04-02)" },
213
+ action: "postMessage",
214
+ actionParams: {
215
+ type: "BIM_SANDBOX",
216
+ action: "locateComponent",
217
+ payload: { wbsCode: "CHKS-TJ01-02-01-01-04-02" }
218
+ }
219
+ },
220
+ {
221
+ type: "button",
222
+ props: { type: "default", content: "查看构件3(不存在的编码,演示失败反馈)" },
223
+ action: "postMessage",
224
+ actionParams: {
225
+ type: "BIM_SANDBOX",
226
+ action: "locateComponent",
227
+ payload: { wbsCode: "CHKS-NOT-EXIST" }
228
+ }
229
+ }
230
+ ]
231
+ },
232
+ null,
233
+ 2
234
+ ),
235
+ "```",
236
+ "",
237
+ "点击上方按钮即可在 BIM 沙盘中定位对应构件。"
238
+ ].join(`
239
+ `), jt = 8, zt = 80, Lt = (e) => new Promise((t) => setTimeout(t, e));
240
+ function $t(e, t) {
241
+ const s = Math.ceil(e.length / t), r = [];
242
+ for (let o = 0; o < e.length; o += s)
243
+ r.push(e.slice(o, o + s));
244
+ return r.length ? r : [""];
245
+ }
246
+ async function Ot(e, t, s, r = "", o = {}) {
247
+ const a = (o && typeof o.mockResponse == "string" ? o.mockResponse.trim() : "") || Et, i = new TextEncoder(), l = new ReadableStream({
248
+ async start(c) {
249
+ for (const b of $t(a, jt))
250
+ c.enqueue(i.encode(b)), await Lt(zt);
251
+ c.close();
252
+ }
253
+ });
254
+ return new Response(l, {
255
+ status: 200,
256
+ headers: { "Content-Type": "text/plain; charset=utf-8" }
257
+ });
258
+ }
259
+ const Nt = (e) => {
260
+ if (e.startsWith("data:")) {
261
+ const t = e.substring(5).trim();
262
+ if (t === "[DONE]")
194
263
  return {
195
264
  done: !0
196
265
  };
197
266
  try {
198
- return JSON.parse(e);
199
- } catch (a) {
200
- console.error("JSON parsing error:", a);
267
+ return JSON.parse(t);
268
+ } catch (s) {
269
+ console.error("JSON parsing error:", s);
201
270
  }
202
271
  }
203
272
  return null;
204
- }, _e = "<think>", ke = "</think>", Ue = (r, e) => {
205
- const a = Math.max(0, r.length - (e.length - 1));
206
- for (let t = a; t < r.length; t++)
207
- if (e.startsWith(r.slice(t)))
208
- return r.length - t;
273
+ }, Ie = "<think>", Se = "</think>", Ee = (e, t) => {
274
+ const s = Math.max(0, e.length - (t.length - 1));
275
+ for (let r = s; r < e.length; r++)
276
+ if (t.startsWith(e.slice(r)))
277
+ return e.length - r;
209
278
  return 0;
210
- }, xt = (r) => {
211
- let e = "", a = "", t = r || "", o = !1;
212
- for (; t; ) {
213
- const n = t.indexOf(_e), s = t.indexOf(ke);
214
- if (n >= 0 && (s < 0 || n < s))
215
- a += t.slice(0, n), t = t.slice(n + _e.length), o = !0;
216
- else if (s >= 0 && (n < 0 || s < n))
217
- e += t.slice(0, s), t = t.slice(s + ke.length), o = !1;
279
+ }, Ft = (e) => {
280
+ let t = "", s = "", r = e || "", o = !1;
281
+ for (; r; ) {
282
+ const n = r.indexOf(Ie), a = r.indexOf(Se);
283
+ if (n >= 0 && (a < 0 || n < a))
284
+ s += r.slice(0, n), r = r.slice(n + Ie.length), o = !0;
285
+ else if (a >= 0 && (n < 0 || a < n))
286
+ t += r.slice(0, a), r = r.slice(a + Se.length), o = !1;
218
287
  else if (o) {
219
- const i = Ue(t, ke);
220
- e += t.slice(0, t.length - i), t = "";
288
+ const i = Ee(r, Se);
289
+ t += r.slice(0, r.length - i), r = "";
221
290
  } else {
222
291
  const i = Math.max(
223
- Ue(t, _e),
224
- Ue(t, ke)
292
+ Ee(r, Ie),
293
+ Ee(r, Se)
225
294
  );
226
- a += t.slice(0, t.length - i), t = "";
295
+ s += r.slice(0, r.length - i), r = "";
227
296
  }
228
297
  }
229
298
  return {
230
- thinking: e.trim(),
231
- content: a.trim(),
299
+ thinking: t.trim(),
300
+ content: s.trim(),
232
301
  isThinkingStreaming: o
233
302
  };
234
- }, Oe = [
303
+ }, Ve = [
235
304
  {
236
305
  label: "模拟数据模型",
237
306
  modelName: "standard",
238
- api: null
307
+ // 不请求真实后端:流式输出 extraConfig.mockResponse(或内置样例),
308
+ // 配合 sz-ai-chat 的 mockResponse prop 用于本地联调
309
+ api: Ot
239
310
  },
240
311
  {
241
312
  label: "Spark 星火大模型",
242
313
  modelName: "spark",
243
- api: yt
314
+ api: Ut
244
315
  },
245
316
  {
246
317
  label: "Ollama 3 大模型",
247
318
  modelName: "ollama3",
248
- api: vt
319
+ api: Rt
249
320
  },
250
321
  {
251
322
  label: "SiliconFlow 硅基流动大模型",
252
323
  modelName: "siliconflow",
253
- api: wt
324
+ api: _t
254
325
  },
255
326
  {
256
327
  label: "Kimi Moonshot 月之暗面大模型",
257
328
  modelName: "moonshot",
258
- api: kt
329
+ api: Pt
259
330
  },
260
331
  {
261
332
  label: "通义千问大模型",
262
333
  modelName: "dashscope",
263
- api: bt
334
+ api: Mt
264
335
  },
265
336
  {
266
337
  label: "数智建管大模型",
267
338
  modelName: "szjy",
268
- api: St
339
+ api: It
269
340
  },
270
341
  {
271
342
  label: "Dify (OpenAI 兼容)",
272
343
  modelName: "dify-openai",
273
- api: gt
344
+ api: Tt
274
345
  }
275
- ], Ve = {
276
- standard(r, e) {
277
- let a = "";
278
- return r instanceof Uint8Array ? a = e.decode(r, {
346
+ ], He = {
347
+ standard(e, t) {
348
+ let s = "";
349
+ return e instanceof Uint8Array ? s = t.decode(e, {
279
350
  stream: !0
280
- }) : a = r, {
281
- content: a
351
+ }) : s = e, {
352
+ content: s
282
353
  };
283
354
  },
284
- spark(r) {
285
- const e = Ct(r);
286
- if (e.done)
355
+ spark(e) {
356
+ const t = Nt(e);
357
+ if (t.done)
287
358
  return {
288
359
  done: !0
289
360
  };
290
- const a = e.choices[0].delta, t = a.reasoning_content || a.reasoning;
291
- let o = a.content || "";
292
- return t && (o = `<think>${t}</think>${o}`), {
361
+ const s = t.choices[0].delta, r = s.reasoning_content || s.reasoning;
362
+ let o = s.content || "";
363
+ return r && (o = `<think>${r}</think>${o}`), {
293
364
  content: o
294
365
  };
295
366
  },
296
- siliconflow(r) {
297
- return this.spark(r);
367
+ siliconflow(e) {
368
+ return this.spark(e);
298
369
  },
299
- moonshot(r) {
300
- return this.spark(r);
370
+ moonshot(e) {
371
+ return this.spark(e);
301
372
  },
302
- dashscope(r) {
303
- return this.spark(r);
373
+ dashscope(e) {
374
+ return this.spark(e);
304
375
  },
305
- szjy(r) {
306
- return this.spark(r);
376
+ szjy(e) {
377
+ return this.spark(e);
307
378
  },
308
- "dify-openai"(r) {
309
- return this.spark(r);
379
+ "dify-openai"(e) {
380
+ return this.spark(e);
310
381
  },
311
- ollama3(r) {
382
+ ollama3(e) {
312
383
  return {
313
- content: JSON.parse(r).message.content
384
+ content: JSON.parse(e).message.content
314
385
  };
315
386
  }
316
- }, $e = (r, e, a) => {
317
- const t = r.split(a);
318
- return t.slice(0, -1).forEach((o) => {
319
- o.trim() !== "" && e.enqueue(o);
320
- }), t[t.length - 1];
321
- }, Rt = (r) => {
322
- let e = "";
387
+ }, De = (e, t, s) => {
388
+ const r = e.split(s);
389
+ return r.slice(0, -1).forEach((o) => {
390
+ o.trim() !== "" && t.enqueue(o);
391
+ }), r[r.length - 1];
392
+ }, Bt = (e) => {
393
+ let t = "";
323
394
  return new TransformStream({
324
- transform(a, t) {
325
- if (e += a, e.trim().startsWith("data:"))
326
- e = $e(e, t, r);
395
+ transform(s, r) {
396
+ if (t += s, t.trim().startsWith("data:"))
397
+ t = De(t, r, e);
327
398
  else
328
399
  try {
329
- JSON.parse(e), e = $e(e, t, r);
400
+ JSON.parse(t), t = De(t, r, e);
330
401
  } catch {
331
- t.enqueue(a), e = "";
402
+ r.enqueue(s), t = "";
332
403
  }
333
404
  },
334
- flush(a) {
335
- e.trim() !== "" && a.enqueue(e);
405
+ flush(s) {
406
+ t.trim() !== "" && s.enqueue(t);
336
407
  }
337
408
  });
338
409
  };
339
- async function Tt(r, e) {
340
- const a = r.api;
341
- return a ? new Promise((t) => {
342
- a(e.text, e.token, e.identifier, e.baseUrl, e.extraConfig).then((o) => {
410
+ async function Vt(e, t) {
411
+ const s = e.api;
412
+ return s ? new Promise((r) => {
413
+ s(t.text, t.token, t.identifier, t.baseUrl, t.extraConfig).then((o) => {
343
414
  if (o.body) {
344
- const n = o.body.pipeThrough(new TextDecoderStream()).pipeThrough(Rt(`
415
+ const n = o.body.pipeThrough(new TextDecoderStream()).pipeThrough(Bt(`
345
416
  `)).getReader();
346
- console.log("reader from response:", n), t({
417
+ console.log("reader from response:", n), r({
347
418
  error: 0,
348
419
  reader: n
349
420
  });
350
421
  } else
351
- t({
422
+ r({
352
423
  error: 1,
353
424
  reader: null
354
425
  });
355
426
  }).catch(() => {
356
- t({
427
+ r({
357
428
  error: 1,
358
429
  reader: null
359
430
  });
@@ -363,30 +434,315 @@ async function Tt(r, e) {
363
434
  reader: null
364
435
  };
365
436
  }
366
- let Z = null;
367
- function At() {
368
- return Z || (window.markdownit ? (Z = new window.markdownit({
437
+ const Le = /* @__PURE__ */ new Map(), $e = /* @__PURE__ */ new Map();
438
+ function et(e, t) {
439
+ Le.set(e, t);
440
+ }
441
+ function Ht(e, t) {
442
+ $e.set(e, t);
443
+ }
444
+ function Dt(e) {
445
+ return Le.get(e);
446
+ }
447
+ function qt(e) {
448
+ return Le.has(e);
449
+ }
450
+ function Wt(e) {
451
+ return $e.get(e);
452
+ }
453
+ function Gt(e) {
454
+ return $e.has(e);
455
+ }
456
+ const Jt = {
457
+ "&": "&amp;",
458
+ "<": "&lt;",
459
+ ">": "&gt;",
460
+ '"': "&quot;",
461
+ "'": "&#39;"
462
+ };
463
+ function ve(e) {
464
+ return String(e ?? "").replace(/[&<>"']/g, (t) => Jt[t]);
465
+ }
466
+ function Kt(e) {
467
+ const s = tt(e, { block: e });
468
+ return s ? `<div class="szjy-ui" data-szjy-ui="1">${s}</div>` : "";
469
+ }
470
+ function tt(e, t) {
471
+ if (!e || typeof e != "object" || typeof e.type != "string") return "";
472
+ const s = Dt(e.type);
473
+ return s ? s(e, t) : "";
474
+ }
475
+ function Xt(e) {
476
+ const t = e.action;
477
+ if (!t || typeof t != "string") return "";
478
+ if (!Gt(t))
479
+ return ` disabled title="未知动作:${ve(t)}"`;
480
+ const s = e.actionParams === void 0 ? "" : encodeURIComponent(JSON.stringify(e.actionParams ?? null));
481
+ return ` data-szjy-ui-action="${ve(t)}" data-szjy-ui-params="${s}"`;
482
+ }
483
+ function Yt(e) {
484
+ return typeof e == "number" && Number.isFinite(e) && e >= 0 ? `${e}px` : typeof e == "string" && /^\d+(\.\d+)?(px|rem|em|%)?$/.test(e.trim()) ? /^\d+(\.\d+)?$/.test(e.trim()) ? `${e.trim()}px` : e.trim() : "12px";
485
+ }
486
+ function Zt(e, t) {
487
+ const s = typeof e.title == "string" && e.title ? `<div class="szjy-ui-list__title">${ve(e.title)}</div>` : "", o = (Array.isArray(e.items) ? e.items : []).map((a) => tt(a, t)).filter(Boolean).map((a) => `<div class="szjy-ui-list__item">${a}</div>`).join(""), n = ve(Yt(e.gap));
488
+ return '<div class="szjy-ui-list">' + s + `<div class="szjy-ui-list__items" style="gap:${n}">${o}</div></div>`;
489
+ }
490
+ et("list", Zt);
491
+ const Qt = ["default", "primary", "success", "warning", "danger", "info", "text"], en = ["small", "default", "large"];
492
+ function tn(e, t) {
493
+ const s = e.props, r = s && typeof s == "object" ? s : {}, o = Qt.includes(r.type) ? r.type : "default", n = en.includes(r.size) ? r.size : "default", a = ve(r.content ?? r.text ?? "按钮"), i = Xt(e);
494
+ return `<button type="button" class="${["szjy-ui-btn", `szjy-ui-btn--${o}`, `szjy-ui-btn--${n}`].join(" ")}"${i}><span class="szjy-ui-btn__text">${a}</span><span class="szjy-ui-btn__status" aria-live="polite"></span></button>`;
495
+ }
496
+ et("button", tn);
497
+ const nn = 15e3, nt = /未就绪|未加载/, rn = "BIM_SANDBOX", sn = {
498
+ locateComponent: (e) => [e == null ? void 0 : e.wbsCode],
499
+ openPDFSearch: () => []
500
+ };
501
+ let on = 0;
502
+ function an(e, t) {
503
+ let s;
504
+ if (!e || e === "self")
505
+ s = [window];
506
+ else if (e === "parent")
507
+ s = [window.parent];
508
+ else if (e === "top")
509
+ s = [window.top];
510
+ else if (typeof e == "function")
511
+ try {
512
+ s = e(t);
513
+ } catch (n) {
514
+ console.error("[szjy-ui] 解析 postMessage 目标窗口失败:", n), s = [];
515
+ }
516
+ else Array.isArray(e) ? s = e : s = [e];
517
+ const r = [], o = (n) => {
518
+ if (n) {
519
+ if (Array.isArray(n)) {
520
+ n.forEach(o);
521
+ return;
522
+ }
523
+ typeof n.postMessage == "function" && !r.includes(n) && r.push(n);
524
+ }
525
+ };
526
+ return o(s), r;
527
+ }
528
+ function de(e) {
529
+ if (e === window) return `self (${location.origin})`;
530
+ if (e === window.parent) return "parent";
531
+ if (e === window.top) return "top";
532
+ try {
533
+ return `window (${e.location.href.slice(0, 60)})`;
534
+ } catch {
535
+ return "window (cross-origin)";
536
+ }
537
+ }
538
+ function ln(e) {
539
+ try {
540
+ const t = e.$bimSandbox;
541
+ return t && typeof t == "object" ? t : null;
542
+ } catch {
543
+ return null;
544
+ }
545
+ }
546
+ function cn(e, t, s) {
547
+ if (t.type !== rn) return { handled: !1 };
548
+ const r = sn[t.action];
549
+ if (!r) return { handled: !1 };
550
+ const o = ln(e);
551
+ if (!o || typeof o[t.action] != "function") return { handled: !1 };
552
+ const n = r(t.payload);
553
+ let a;
554
+ try {
555
+ a = o[t.action](...n);
556
+ } catch (i) {
557
+ return console.error("[szjy-ui] $bimSandbox 方法调用异常,回退 postMessage:", i), { handled: !1 };
558
+ }
559
+ return s && console.log("[szjy-ui] $bimSandbox 直调", {
560
+ method: t.action,
561
+ args: n,
562
+ result: a,
563
+ target: de(e)
564
+ }), { handled: !0, result: a };
565
+ }
566
+ function rt(e, t, s, r, o, n, a) {
567
+ return (() => {
568
+ const { handled: l, result: c } = cn(e, t, a);
569
+ return l ? (c && c.success ? n && K(s, "success", c.message || "执行成功") : c && nt.test(String(c.message || "")) && r > 0 ? (a && console.warn(
570
+ `[szjy-ui] $bimSandbox 直调失败(${c.message}),${o}ms 后自动重试,剩余 ${r - 1} 次`
571
+ ), n && K(s, "retrying", `${c.message},${Math.round(o / 1e3)}s 后自动重试`), setTimeout(() => {
572
+ rt(e, t, s, r - 1, o, n, a);
573
+ }, o)) : n && K(s, "error", c && c.message || "执行失败"), !0) : !1;
574
+ })();
575
+ }
576
+ function un(e) {
577
+ const t = dn(e.config), s = !e.config || e.config.debug !== !1, r = t.feedback !== !1, o = t.retry === !1 ? { retries: 0, delay: 2e3 } : { retries: 2, delay: 2e3, ...t.retry || {} };
578
+ if (!e.params || typeof e.params != "object" || Array.isArray(e.params)) {
579
+ console.warn("[szjy-ui] postMessage 动作的 actionParams 必须是对象:", e.params), K(e.triggerEl, "error", "参数无效");
580
+ return;
581
+ }
582
+ const n = { ...e.params }, a = an(t.target, n);
583
+ if (!a.length) {
584
+ console.warn("[szjy-ui] postMessage 无可用目标窗口,target 配置:", t.target), K(e.triggerEl, "error", "无目标窗口");
585
+ return;
586
+ }
587
+ const i = t.targetOrigin || "*", l = t.transport || "auto";
588
+ if (l !== "postMessage") {
589
+ let c = !1;
590
+ for (const b of a)
591
+ if (rt(b, n, e.triggerEl, o.retries, o.delay, r, s)) {
592
+ c = !0;
593
+ break;
594
+ }
595
+ if (c)
596
+ return;
597
+ if (l === "global") {
598
+ console.warn("[szjy-ui] transport=global 但 $bimSandbox 全局方法不可用:", {
599
+ targets: a.map(de),
600
+ message: n
601
+ }), K(e.triggerEl, "error", "全局方法不可用");
602
+ return;
603
+ }
604
+ s && console.log("[szjy-ui] $bimSandbox 不可用,回退 postMessage 通道");
605
+ }
606
+ n.requestId === void 0 && (n.requestId = `szjy-ui-${Date.now()}-${++on}`), st(a, n, i), s && console.log("[szjy-ui] postMessage 已发送", {
607
+ message: n,
608
+ targets: a.map(de),
609
+ targetOrigin: i,
610
+ feedback: r
611
+ }), r && (K(e.triggerEl, "loading", "已发送"), fn(n, a, e.triggerEl, i, o, s));
612
+ }
613
+ function dn(e) {
614
+ return e && e.postMessage || {};
615
+ }
616
+ function st(e, t, s) {
617
+ e.forEach((r) => {
618
+ try {
619
+ r.postMessage(t, s);
620
+ } catch (o) {
621
+ console.error("[szjy-ui] postMessage 发送失败:", o);
622
+ }
623
+ });
624
+ }
625
+ function fn(e, t, s, r, o, n) {
626
+ let a = o.retries;
627
+ const i = o.delay;
628
+ let l = null;
629
+ const c = () => {
630
+ window.removeEventListener("message", P), l && (clearTimeout(l), l = null);
631
+ }, b = () => {
632
+ l && clearTimeout(l), l = setTimeout(() => {
633
+ c(), n && console.warn("[szjy-ui] postMessage 超时未收到回执", { message: e, targets: t.map(de), targetOrigin: r }), K(s, "none", "未收到回执");
634
+ }, nn);
635
+ }, P = (A) => {
636
+ const p = A.data;
637
+ !p || typeof p != "object" || e.type !== void 0 && p.type !== e.type || p.success !== void 0 && (e.requestId !== void 0 && p.requestId !== void 0 && String(p.requestId) !== String(e.requestId) || A.source && !t.includes(A.source) || (n && console.log("[szjy-ui] postMessage 收到回执", {
638
+ requestId: p.requestId,
639
+ success: p.success,
640
+ message: p.message,
641
+ data: p.data,
642
+ from: de(A.source)
643
+ }), p.success ? (c(), K(s, "success", p.message || "执行成功")) : nt.test(String(p.message || "")) && a > 0 ? (a -= 1, n && console.warn(`[szjy-ui] postMessage 回执失败(${p.message}),${i}ms 后自动重试,剩余 ${a} 次`), K(s, "retrying", `${p.message},${Math.round(i / 1e3)}s 后自动重试`), l && clearTimeout(l), setTimeout(() => {
644
+ st(t, e, r), n && console.log("[szjy-ui] postMessage 重试已发送", { message: e, targets: t.map(de), targetOrigin: r }), K(s, "loading", "已发送"), b();
645
+ }, i)) : (c(), K(s, "error", p.message || "执行失败"))));
646
+ };
647
+ window.addEventListener("message", P), b();
648
+ }
649
+ function K(e, t, s) {
650
+ if (!e || !e.isConnected) return;
651
+ const r = e.querySelector(":scope > .szjy-ui-btn__status");
652
+ e.classList.remove("is-loading", "is-success", "is-error", "is-retrying"), t && t !== "none" && e.classList.add(`is-${t}`), r && (r.textContent = s || "");
653
+ }
654
+ Ht("postMessage", un);
655
+ const hn = "szjy-ui";
656
+ function pn(e) {
657
+ if (!e || typeof e != "string") return null;
658
+ const t = e.trim();
659
+ if (!t.startsWith("{")) return null;
660
+ let s;
661
+ try {
662
+ s = JSON.parse(t);
663
+ } catch {
664
+ return null;
665
+ }
666
+ return mn(s);
667
+ }
668
+ function mn(e) {
669
+ return !e || typeof e != "object" || Array.isArray(e) || typeof e.type != "string" || !qt(e.type) || e.items !== void 0 && !Array.isArray(e.items) ? null : e;
670
+ }
671
+ function gn(e, t = {}) {
672
+ if (!e) return () => {
673
+ };
674
+ const s = (r) => {
675
+ var A;
676
+ const o = r.target, n = o && typeof o.closest == "function" ? o.closest("[data-szjy-ui-action]") : null;
677
+ if (!n || !e.contains(n)) return;
678
+ const a = n.getAttribute("data-szjy-ui-action") || "", i = Wt(a);
679
+ if (!i) {
680
+ console.warn(`[szjy-ui] 未注册的动作: ${a}`);
681
+ return;
682
+ }
683
+ const l = n.getAttribute("data-szjy-ui-params");
684
+ let c = null;
685
+ if (l)
686
+ try {
687
+ c = JSON.parse(decodeURIComponent(l));
688
+ } catch (p) {
689
+ console.error("[szjy-ui] actionParams 解析失败:", p);
690
+ return;
691
+ }
692
+ const b = t.getConfig ? t.getConfig() : null;
693
+ if (!b || b.debug !== !1) {
694
+ const p = (A = n.querySelector(":scope > .szjy-ui-btn__text")) == null ? void 0 : A.textContent;
695
+ console.log("[szjy-ui] 动作触发", {
696
+ action: a,
697
+ params: c,
698
+ text: (p || n.textContent || "").trim().slice(0, 40),
699
+ trigger: n
700
+ });
701
+ }
702
+ const P = t.getInterceptor ? t.getInterceptor() : null;
703
+ if (!(P && P(a, c, n) === !1)) {
704
+ if (t.onAction)
705
+ try {
706
+ t.onAction({ action: a, params: c, triggerEl: n });
707
+ } catch (p) {
708
+ console.error("[szjy-ui] onAction 回调执行失败:", p);
709
+ }
710
+ i({ params: c, config: b, triggerEl: n });
711
+ }
712
+ };
713
+ return e.addEventListener("click", s), () => {
714
+ e.removeEventListener("click", s);
715
+ };
716
+ }
717
+ let ee = null;
718
+ function yn() {
719
+ return ee || (window.markdownit ? (ee = new window.markdownit({
369
720
  html: !0,
370
721
  linkify: !0,
371
722
  typographer: !0
372
- }), Z.renderer.rules.fence = (r, e) => {
373
- const a = r[e], t = (a.info || "").trim().split(/\s+/)[0];
723
+ }), ee.renderer.rules.fence = (e, t) => {
724
+ const s = e[t], r = (s.info || "").trim().split(/\s+/)[0];
725
+ if (r === hn) {
726
+ const n = pn(s.content), a = n ? Kt(n) : "";
727
+ if (a)
728
+ return a;
729
+ }
374
730
  let o = "";
375
- if (t && window.hljs && window.hljs.getLanguage(t))
731
+ if (r && window.hljs && window.hljs.getLanguage(r))
376
732
  try {
377
- o = window.hljs.highlight(a.content, { language: t }).value;
733
+ o = window.hljs.highlight(s.content, { language: r }).value;
378
734
  } catch {
379
735
  o = "";
380
736
  }
381
- return o || (o = Z.utils.escapeHtml(a.content)), `<pre class="md-code-block"><code class="hljs${t ? " language-" + t : ""}">${o}</code></pre>`;
382
- }) : console.log("markdownit is not loaded"), Z);
737
+ return o || (o = ee.utils.escapeHtml(s.content)), `<pre class="md-code-block"><code class="hljs${r ? " language-" + r : ""}">${o}</code></pre>`;
738
+ }) : console.log("markdownit is not loaded"), ee);
383
739
  }
384
- const _t = (r, e) => {
385
- const a = r.__vccOpts || r;
386
- for (const [t, o] of e)
387
- a[t] = o;
388
- return a;
389
- }, Ut = ["src", "alt"], Pt = {
740
+ const vn = (e, t) => {
741
+ const s = e.__vccOpts || e;
742
+ for (const [r, o] of t)
743
+ s[r] = o;
744
+ return s;
745
+ }, wn = ["src", "alt"], bn = {
390
746
  __name: "SvgIcon",
391
747
  props: {
392
748
  // 图标名称或完整URL
@@ -415,14 +771,14 @@ const _t = (r, e) => {
415
771
  default: "/icons/"
416
772
  }
417
773
  },
418
- setup(r) {
419
- const e = r, a = O(() => {
420
- if (e.name.startsWith("http://") || e.name.startsWith("https://") || e.name.startsWith("/"))
421
- return e.name;
422
- const n = e.name.endsWith(".svg") ? e.name : `${e.name}.svg`;
423
- return `${e.basePath}${n}`;
424
- }), t = O(() => {
425
- const n = typeof e.size == "number" ? `${e.size}px` : e.size;
774
+ setup(e) {
775
+ const t = e, s = N(() => {
776
+ if (t.name.startsWith("http://") || t.name.startsWith("https://") || t.name.startsWith("/"))
777
+ return t.name;
778
+ const n = t.name.endsWith(".svg") ? t.name : `${t.name}.svg`;
779
+ return `${t.basePath}${n}`;
780
+ }), r = N(() => {
781
+ const n = typeof t.size == "number" ? `${t.size}px` : t.size;
426
782
  return {
427
783
  width: n,
428
784
  height: n,
@@ -430,33 +786,33 @@ const _t = (r, e) => {
430
786
  justifyContent: "center",
431
787
  alignItems: "center"
432
788
  };
433
- }), o = O(() => {
789
+ }), o = N(() => {
434
790
  const n = {
435
791
  width: "100%",
436
792
  height: "100%"
437
793
  };
438
- return e.color && (n.filter = `drop-shadow(0 0 0 ${e.color})`), n;
794
+ return t.color && (n.filter = `drop-shadow(0 0 0 ${t.color})`), n;
439
795
  });
440
- return (n, s) => (w(), C("div", {
796
+ return (n, a) => (S(), x("div", {
441
797
  class: "svg-icon-wrapper",
442
- style: ue(t.value)
798
+ style: ue(r.value)
443
799
  }, [
444
- u("img", {
445
- src: a.value,
446
- alt: r.name,
447
- class: ne(["svg-icon", r.className]),
800
+ d("img", {
801
+ src: s.value,
802
+ alt: e.name,
803
+ class: re(["svg-icon", e.className]),
448
804
  style: ue(o.value)
449
- }, null, 14, Ut)
805
+ }, null, 14, wn)
450
806
  ], 4));
451
807
  }
452
- }, be = /* @__PURE__ */ _t(Pt, [["__scopeId", "data-v-490b11c1"]]), It = async (r) => {
808
+ }, Ce = /* @__PURE__ */ vn(bn, [["__scopeId", "data-v-490b11c1"]]), kn = async (e) => {
453
809
  if (navigator.clipboard && navigator.permissions)
454
- await navigator.clipboard.writeText(r);
810
+ await navigator.clipboard.writeText(e);
455
811
  else {
456
- const e = document.createElement("textArea");
457
- e.value = r, e.style.width = 0, e.style.position = "fixed", e.style.left = "-999px", e.style.top = "10px", e.setAttribute("readonly", "readonly"), document.body.appendChild(e), e.select(), document.execCommand("copy"), document.body.removeChild(e);
812
+ const t = document.createElement("textArea");
813
+ t.value = e, t.style.width = 0, t.style.position = "fixed", t.style.left = "-999px", t.style.top = "10px", t.setAttribute("readonly", "readonly"), document.body.appendChild(t), t.select(), document.execCommand("copy"), document.body.removeChild(t);
458
814
  }
459
- }, Lt = { class: "thinking-title" }, Et = { class: "thinking-toggle-hint" }, Mt = ["innerHTML"], Ft = ["innerHTML"], Nt = 10, Ot = {
815
+ }, Sn = { class: "thinking-title" }, Cn = { class: "thinking-toggle-hint" }, An = ["innerHTML"], xn = ["innerHTML"], Tn = 10, Rn = {
460
816
  __name: "Previewer",
461
817
  props: {
462
818
  reader: null,
@@ -466,96 +822,121 @@ const _t = (r, e) => {
466
822
  messagePostRender: {
467
823
  type: Function,
468
824
  default: null
825
+ },
826
+ /**
827
+ * szjy-ui fence 自定义 UI 配置(透传给动作处理器)
828
+ * 例如:{ postMessage: { target: () => iframe.contentWindow, targetOrigin: 'http://...' } }
829
+ */
830
+ customUi: {
831
+ type: Object,
832
+ default: null
833
+ },
834
+ /**
835
+ * szjy-ui 动作拦截钩子:(action, params, triggerEl) => false 可阻止内置动作执行
836
+ */
837
+ uiActionHandler: {
838
+ type: Function,
839
+ default: null
469
840
  }
470
841
  },
471
842
  emits: [
472
843
  "failed",
473
844
  "completed",
474
- "updating"
845
+ "updating",
846
+ "ui-action"
475
847
  ],
476
- setup(r, { expose: e, emit: a }) {
477
- const { appContext: t } = je(), { $message: o } = t.config.globalProperties, n = r, s = x(n.displayText || ""), i = x(!0), l = x(!1), y = x(!!n.displayText), R = a, F = x(null);
478
- let _ = null;
479
- const S = O(() => xt(s.value)), W = O(() => S.value.thinking.length > 0), T = x(n.displayText ? S.value.content.length : 0), N = O(() => S.value.isThinkingStreaming && !y.value), v = x(!1), p = () => {
480
- v.value = !v.value;
848
+ setup(e, { expose: t, emit: s }) {
849
+ const { appContext: r } = Je(), { $message: o } = r.config.globalProperties, n = e, a = T(n.displayText || ""), i = T(!0), l = T(!1), c = T(!!n.displayText), b = s, P = T(null);
850
+ let A = null;
851
+ Pe(P, (j) => {
852
+ A && (A(), A = null), j && (A = gn(j, {
853
+ // 点击时才读取最新 props,宿主更新 customUi/uiActionHandler 后立即生效
854
+ getConfig: () => n.customUi,
855
+ getInterceptor: () => n.uiActionHandler,
856
+ onAction: (_) => b("ui-action", _)
857
+ }));
858
+ });
859
+ let p = null;
860
+ const F = N(() => Ft(a.value)), U = N(() => F.value.thinking.length > 0), z = T(n.displayText ? F.value.content.length : 0), y = N(() => F.value.isThinkingStreaming && !c.value), m = T(!1), v = () => {
861
+ m.value = !m.value;
481
862
  };
482
- let m = null, d = null;
483
- const c = x(0);
484
- Fe(() => S.value.thinking, ($) => {
485
- !$ || c.value > 0 || (d === null && (d = m ?? Date.now()), S.value.content && k());
863
+ let f = null, u = null;
864
+ const k = T(0);
865
+ Pe(() => F.value.thinking, (j) => {
866
+ !j || k.value > 0 || (u === null && (u = f ?? Date.now()), F.value.content && C());
486
867
  });
487
- const k = () => {
488
- if (c.value > 0 || !W.value) return;
489
- const $ = d ?? m;
490
- $ && (c.value = Math.max(1, Math.round((Date.now() - $) / 1e3)));
491
- }, b = O(() => N.value ? "正在思考..." : c.value > 0 ? `已深度思考(用时 ${c.value} 秒)` : "思考过程"), L = O(() => W.value ? Z ? Z.render(S.value.thinking) : S.value.thinking : ""), A = O(() => S.value.content.slice(0, T.value)), I = O(() => Z ? Z.render(A.value) : A.value), g = () => {
492
- n.reader && n.reader.cancel(), l.value = !0, H.value = !1, G(), y.value = !0, k(), R("completed", s.value), i.value = !1, _ && (cancelAnimationFrame(_), _ = null);
493
- }, V = O(() => `${I.value}`), K = x(!1), X = () => {
494
- K.value = !0;
495
- }, G = () => {
496
- K.value = !1;
497
- }, H = x(!1), oe = async () => {
868
+ const C = () => {
869
+ if (k.value > 0 || !U.value) return;
870
+ const j = u ?? f;
871
+ j && (k.value = Math.max(1, Math.round((Date.now() - j) / 1e3)));
872
+ }, L = N(() => y.value ? "正在思考..." : k.value > 0 ? `已深度思考(用时 ${k.value} 秒)` : "思考过程"), R = N(() => U.value ? ee ? ee.render(F.value.thinking) : F.value.thinking : ""), I = N(() => F.value.content.slice(0, z.value)), w = N(() => ee ? ee.render(I.value) : I.value), O = () => {
873
+ n.reader && n.reader.cancel(), l.value = !0, q.value = !1, ne(), c.value = !0, C(), b("completed", a.value), i.value = !1, p && (cancelAnimationFrame(p), p = null);
874
+ }, X = N(() => `${w.value}`), Y = T(!1), Z = () => {
875
+ Y.value = !0;
876
+ }, ne = () => {
877
+ Y.value = !1;
878
+ }, q = T(!1), oe = async () => {
498
879
  if (!n.reader) return;
499
- const $ = new TextDecoder("utf-8");
880
+ const j = new TextDecoder("utf-8");
500
881
  for (i.value = !0; !l.value; )
501
882
  try {
502
883
  if (!n.reader) {
503
- H.value = !0;
884
+ q.value = !0;
504
885
  break;
505
886
  }
506
- const { value: z, done: E } = await n.reader.read();
887
+ const { value: _, done: V } = await n.reader.read();
507
888
  if (!n.reader) {
508
- H.value = !0;
889
+ q.value = !0;
509
890
  break;
510
891
  }
511
- if (E) {
512
- H.value = !0;
892
+ if (V) {
893
+ q.value = !0;
513
894
  break;
514
895
  }
515
- const Q = Ve[n.model];
516
- if (!Q)
896
+ const ie = He[n.model];
897
+ if (!ie)
517
898
  break;
518
- const re = Q.call(Ve, z, $);
519
- if (re.done) {
520
- H.value = !0;
899
+ const G = ie.call(He, _, j);
900
+ if (G.done) {
901
+ q.value = !0;
521
902
  break;
522
903
  }
523
- !m && re.content && (m = Date.now()), s.value += re.content, _ === null && de();
524
- } catch (z) {
525
- H.value = !0, console.log(3333, z), R("failed", z), g();
904
+ !f && G.content && (f = Date.now()), a.value += G.content, p === null && ae();
905
+ } catch (_) {
906
+ q.value = !0, console.log(3333, _), b("failed", _), O();
526
907
  break;
527
908
  } finally {
528
- G();
909
+ ne();
529
910
  }
530
- }, se = async () => {
911
+ }, fe = async () => {
531
912
  n.scrollToBottomFn && n.scrollToBottomFn();
532
- }, ie = ($ = () => {
533
- }, z = () => {
913
+ }, ke = (j = () => {
914
+ }, _ = () => {
534
915
  }) => {
535
- const E = S.value.content.length;
536
- T.value > E && (T.value = E), T.value < E ? (T.value = Math.min(E, T.value + Nt), $()) : z();
537
- }, de = () => {
538
- if (l.value && _) {
539
- cancelAnimationFrame(_), _ = null, i.value = !1;
916
+ const V = F.value.content.length;
917
+ z.value > V && (z.value = V), z.value < V ? (z.value = Math.min(V, z.value + Tn), j()) : _();
918
+ }, ae = () => {
919
+ if (l.value && p) {
920
+ cancelAnimationFrame(p), p = null, i.value = !1;
540
921
  return;
541
922
  }
542
- H.value ? ie(
923
+ q.value ? ke(
543
924
  () => {
544
- _ = requestAnimationFrame(de), R("updating", null);
925
+ p = requestAnimationFrame(ae), b("updating", null);
545
926
  },
546
927
  () => {
547
- k(), R("completed", s.value), i.value = !1, y.value = !0, We(() => {
548
- if (H.value = !1, n.messagePostRender && F.value)
928
+ C(), b("completed", a.value), i.value = !1, c.value = !0, Ye(() => {
929
+ if (q.value = !1, n.messagePostRender && P.value)
549
930
  try {
550
- n.messagePostRender(F.value, S.value.content);
551
- } catch ($) {
552
- console.error("messagePostRender 执行失败:", $);
931
+ n.messagePostRender(P.value, F.value.content);
932
+ } catch (j) {
933
+ console.error("messagePostRender 执行失败:", j);
553
934
  }
554
- }), _ = null;
935
+ }), p = null;
555
936
  }
556
- ) : (ie(), _ = requestAnimationFrame(de)), se();
937
+ ) : (ke(), p = requestAnimationFrame(ae)), fe();
557
938
  };
558
- Fe(
939
+ Pe(
559
940
  () => n.reader,
560
941
  () => {
561
942
  n.reader && oe();
@@ -564,124 +945,124 @@ const _t = (r, e) => {
564
945
  immediate: !0,
565
946
  deep: !0
566
947
  }
567
- ), ct(() => {
568
- g();
569
- }), e({
570
- abortReader: g,
571
- initializeStart: X,
572
- initializeEnd: G
573
- }), O(() => K.value ? !0 : (!n.reader || !i || s.value, !1));
574
- const we = async () => {
948
+ ), wt(() => {
949
+ A && (A(), A = null), O();
950
+ }), t({
951
+ abortReader: O,
952
+ initializeStart: Z,
953
+ initializeEnd: ne
954
+ }), N(() => Y.value ? !0 : (!n.reader || !i || a.value, !1));
955
+ const xe = async () => {
575
956
  try {
576
- const $ = S.value.content || s.value;
577
- await It($), o.success("复制成功");
578
- } catch ($) {
579
- console.error("复制失败:", $), o.error("复制失败");
957
+ const j = F.value.content || a.value;
958
+ await kn(j), o.success("复制成功");
959
+ } catch (j) {
960
+ console.error("复制失败:", j), o.error("复制失败");
580
961
  }
581
962
  };
582
- return ($, z) => (w(), me(ge, { name: "fade" }, {
963
+ return (j, _) => (S(), ge(ye, { name: "fade" }, {
583
964
  default: J(() => [
584
- V.value || W.value ? (w(), C("div", {
965
+ X.value || U.value ? (S(), x("div", {
585
966
  key: 0,
586
967
  ref_key: "refWrapperContent",
587
- ref: F,
968
+ ref: P,
588
969
  "text-16": "",
589
970
  class: "w-full h-full overflow-y-auto relative",
590
971
  "p-24px": ""
591
972
  }, [
592
- W.value ? (w(), C("div", {
973
+ U.value ? (S(), x("div", {
593
974
  key: 0,
594
- class: ne(["ai-thinking-block", {
595
- "is-expanded": v.value || N.value,
596
- "is-streaming": N.value
975
+ class: re(["ai-thinking-block", {
976
+ "is-expanded": m.value || y.value,
977
+ "is-streaming": y.value
597
978
  }])
598
979
  }, [
599
- u("div", {
980
+ d("div", {
600
981
  class: "thinking-header",
601
- onClick: p
982
+ onClick: v
602
983
  }, [
603
- z[0] || (z[0] = u("svg", {
984
+ _[0] || (_[0] = d("svg", {
604
985
  class: "thinking-arrow",
605
986
  viewBox: "0 0 1024 1024",
606
987
  width: "10",
607
988
  height: "10"
608
989
  }, [
609
- u("path", {
990
+ d("path", {
610
991
  d: "M704 512 320 256v512z",
611
992
  fill: "currentColor"
612
993
  })
613
994
  ], -1)),
614
- u("span", Lt, q(b.value), 1),
615
- u("span", Et, q(v.value || N.value ? "收起" : "展开"), 1)
995
+ d("span", Sn, W(L.value), 1),
996
+ d("span", Cn, W(m.value || y.value ? "收起" : "展开"), 1)
616
997
  ]),
617
- He(u("div", {
998
+ Ke(d("div", {
618
999
  class: "thinking-body",
619
- innerHTML: L.value
620
- }, null, 8, Mt), [
621
- [qe, v.value || N.value]
1000
+ innerHTML: R.value
1001
+ }, null, 8, An), [
1002
+ [Xe, m.value || y.value]
622
1003
  ])
623
- ], 2)) : M("", !0),
624
- u("div", {
1004
+ ], 2)) : $("", !0),
1005
+ d("div", {
625
1006
  class: "markdown-wrapper",
626
- innerHTML: V.value
627
- }, null, 8, Ft),
628
- y.value ? (w(), C("div", {
1007
+ innerHTML: X.value
1008
+ }, null, 8, xn),
1009
+ c.value ? (S(), x("div", {
629
1010
  key: 1,
630
1011
  class: "ai-copy-btn-wrapper",
631
- onClick: we
1012
+ onClick: xe
632
1013
  }, [
633
- j(be, {
1014
+ D(Ce, {
634
1015
  name: "/images/svg/copy.svg",
635
1016
  color: "#666666"
636
1017
  }),
637
- z[1] || (z[1] = u("span", { class: "copy-text" }, "复制", -1))
638
- ])) : M("", !0)
639
- ], 512)) : M("", !0)
1018
+ _[1] || (_[1] = d("span", { class: "copy-text" }, "复制", -1))
1019
+ ])) : $("", !0)
1020
+ ], 512)) : $("", !0)
640
1021
  ]),
641
1022
  _: 1
642
1023
  }));
643
1024
  }
644
1025
  };
645
- class Vt {
646
- constructor(e, a) {
647
- U(this, "ratio");
648
- U(this, "leftover", new Float32Array(0));
649
- U(this, "fracOffset", 0);
650
- this.ratio = e / a;
1026
+ class Un {
1027
+ constructor(t, s) {
1028
+ M(this, "ratio");
1029
+ M(this, "leftover", new Float32Array(0));
1030
+ M(this, "fracOffset", 0);
1031
+ this.ratio = t / s;
651
1032
  }
652
1033
  reset() {
653
1034
  this.leftover = new Float32Array(0), this.fracOffset = 0;
654
1035
  }
655
- process(e) {
1036
+ process(t) {
656
1037
  if (this.ratio === 1)
657
- return new Float32Array(e);
658
- const a = new Float32Array(this.leftover.length + e.length);
659
- if (a.set(this.leftover), a.set(e, this.leftover.length), a.length < 2)
660
- return this.leftover = a, new Float32Array(0);
661
- const t = [];
1038
+ return new Float32Array(t);
1039
+ const s = new Float32Array(this.leftover.length + t.length);
1040
+ if (s.set(this.leftover), s.set(t, this.leftover.length), s.length < 2)
1041
+ return this.leftover = s, new Float32Array(0);
1042
+ const r = [];
662
1043
  let o = this.fracOffset;
663
- for (; o < a.length - 1; ) {
664
- const s = Math.floor(o), i = o - s, l = a[s], y = a[s + 1];
665
- t.push(l + i * (y - l)), o += this.ratio;
1044
+ for (; o < s.length - 1; ) {
1045
+ const a = Math.floor(o), i = o - a, l = s[a], c = s[a + 1];
1046
+ r.push(l + i * (c - l)), o += this.ratio;
666
1047
  }
667
- const n = Math.min(a.length, Math.floor(o));
668
- return this.leftover = a.slice(n), this.fracOffset = o - n, Float32Array.from(t);
1048
+ const n = Math.min(s.length, Math.floor(o));
1049
+ return this.leftover = s.slice(n), this.fracOffset = o - n, Float32Array.from(r);
669
1050
  }
670
1051
  }
671
- class $t {
672
- constructor(e = {}) {
673
- U(this, "targetSampleRate");
674
- U(this, "audioContext", null);
675
- U(this, "mediaStream", null);
676
- U(this, "sourceNode", null);
677
- U(this, "processorNode", null);
678
- U(this, "muteGain", null);
679
- U(this, "resampler", null);
680
- U(this, "audioChunks", []);
681
- U(this, "onVolumeChange");
682
- U(this, "onAudioChunk");
683
- U(this, "_isRecording", !1);
684
- this.targetSampleRate = e.sampleRate || 16e3, this.onVolumeChange = e.onVolumeChange, this.onAudioChunk = e.onAudioChunk;
1052
+ class _n {
1053
+ constructor(t = {}) {
1054
+ M(this, "targetSampleRate");
1055
+ M(this, "audioContext", null);
1056
+ M(this, "mediaStream", null);
1057
+ M(this, "sourceNode", null);
1058
+ M(this, "processorNode", null);
1059
+ M(this, "muteGain", null);
1060
+ M(this, "resampler", null);
1061
+ M(this, "audioChunks", []);
1062
+ M(this, "onVolumeChange");
1063
+ M(this, "onAudioChunk");
1064
+ M(this, "_isRecording", !1);
1065
+ this.targetSampleRate = t.sampleRate || 16e3, this.onVolumeChange = t.onVolumeChange, this.onAudioChunk = t.onAudioChunk;
685
1066
  }
686
1067
  get isRecording() {
687
1068
  return this._isRecording;
@@ -703,30 +1084,30 @@ class $t {
703
1084
  autoGainControl: !0
704
1085
  }
705
1086
  });
706
- } catch (t) {
707
- throw t.name === "NotAllowedError" || t.name === "PermissionDeniedError" ? new Error("麦克风权限被拒绝,请在浏览器地址栏允许麦克风访问权限。") : t.name === "NotFoundError" || t.name === "DevicesNotFoundError" ? new Error("未检测到可用的麦克风输入设备。") : new Error(`无法启动麦克风: ${t.message || t}`);
1087
+ } catch (r) {
1088
+ throw r.name === "NotAllowedError" || r.name === "PermissionDeniedError" ? new Error("麦克风权限被拒绝,请在浏览器地址栏允许麦克风访问权限。") : r.name === "NotFoundError" || r.name === "DevicesNotFoundError" ? new Error("未检测到可用的麦克风输入设备。") : new Error(`无法启动麦克风: ${r.message || r}`);
708
1089
  }
709
- const e = window.AudioContext || window.webkitAudioContext;
1090
+ const t = window.AudioContext || window.webkitAudioContext;
710
1091
  try {
711
- this.audioContext = new e({ sampleRate: this.targetSampleRate });
1092
+ this.audioContext = new t({ sampleRate: this.targetSampleRate });
712
1093
  } catch {
713
- this.audioContext = new e();
1094
+ this.audioContext = new t();
714
1095
  }
715
- this.audioContext.state === "suspended" && await this.audioContext.resume(), this.audioChunks = [], this.resampler = this.audioContext.sampleRate === this.targetSampleRate ? null : new Vt(this.audioContext.sampleRate, this.targetSampleRate), this.sourceNode = this.audioContext.createMediaStreamSource(this.mediaStream);
716
- const a = 4096;
717
- this.processorNode = this.audioContext.createScriptProcessor(a, 1, 1), this.processorNode.onaudioprocess = (t) => {
718
- var s;
1096
+ this.audioContext.state === "suspended" && await this.audioContext.resume(), this.audioChunks = [], this.resampler = this.audioContext.sampleRate === this.targetSampleRate ? null : new Un(this.audioContext.sampleRate, this.targetSampleRate), this.sourceNode = this.audioContext.createMediaStreamSource(this.mediaStream);
1097
+ const s = 4096;
1098
+ this.processorNode = this.audioContext.createScriptProcessor(s, 1, 1), this.processorNode.onaudioprocess = (r) => {
1099
+ var a;
719
1100
  if (!this._isRecording) return;
720
- const o = new Float32Array(t.inputBuffer.getChannelData(0));
1101
+ const o = new Float32Array(r.inputBuffer.getChannelData(0));
721
1102
  if (this.onVolumeChange) {
722
1103
  let i = 0;
723
- for (let R = 0; R < o.length; R++)
724
- i += o[R] * o[R];
725
- const l = Math.sqrt(i / o.length), y = Math.min(100, Math.round(l * 100 * 5));
726
- this.onVolumeChange(y);
1104
+ for (let b = 0; b < o.length; b++)
1105
+ i += o[b] * o[b];
1106
+ const l = Math.sqrt(i / o.length), c = Math.min(100, Math.round(l * 100 * 5));
1107
+ this.onVolumeChange(c);
727
1108
  }
728
1109
  const n = this.resampler ? this.resampler.process(o) : o;
729
- n.length && (this.audioChunks.push(n), (s = this.onAudioChunk) == null || s.call(this, n));
1110
+ n.length && (this.audioChunks.push(n), (a = this.onAudioChunk) == null || a.call(this, n));
730
1111
  }, this.muteGain = this.audioContext.createGain(), this.muteGain.gain.value = 0, this.sourceNode.connect(this.processorNode), this.processorNode.connect(this.muteGain), this.muteGain.connect(this.audioContext.destination), this._isRecording = !0;
731
1112
  }
732
1113
  /**
@@ -736,11 +1117,11 @@ class $t {
736
1117
  if (!this._isRecording)
737
1118
  return new Float32Array(0);
738
1119
  this._isRecording = !1, this.cleanup();
739
- const e = this.audioChunks.reduce((o, n) => o + n.length, 0), a = new Float32Array(e);
740
- let t = 0;
1120
+ const t = this.audioChunks.reduce((o, n) => o + n.length, 0), s = new Float32Array(t);
1121
+ let r = 0;
741
1122
  for (const o of this.audioChunks)
742
- a.set(o, t), t += o.length;
743
- return this.audioChunks = [], a;
1123
+ s.set(o, r), r += o.length;
1124
+ return this.audioChunks = [], s;
744
1125
  }
745
1126
  /**
746
1127
  * 取消录音并丢弃采集的数据
@@ -749,109 +1130,109 @@ class $t {
749
1130
  this._isRecording = !1, this.audioChunks = [], this.cleanup();
750
1131
  }
751
1132
  cleanup() {
752
- this.processorNode && (this.processorNode.disconnect(), this.processorNode.onaudioprocess = null, this.processorNode = null), this.muteGain && (this.muteGain.disconnect(), this.muteGain = null), this.sourceNode && (this.sourceNode.disconnect(), this.sourceNode = null), this.resampler = null, this.mediaStream && (this.mediaStream.getTracks().forEach((e) => e.stop()), this.mediaStream = null), this.audioContext && this.audioContext.state !== "closed" && (this.audioContext.close().catch(() => {
1133
+ this.processorNode && (this.processorNode.disconnect(), this.processorNode.onaudioprocess = null, this.processorNode = null), this.muteGain && (this.muteGain.disconnect(), this.muteGain = null), this.sourceNode && (this.sourceNode.disconnect(), this.sourceNode = null), this.resampler = null, this.mediaStream && (this.mediaStream.getTracks().forEach((t) => t.stop()), this.mediaStream = null), this.audioContext && this.audioContext.state !== "closed" && (this.audioContext.close().catch(() => {
753
1134
  }), this.audioContext = null);
754
1135
  }
755
1136
  }
756
- function Bt(r, e, a) {
757
- if (e === a)
758
- return new Float32Array(r);
759
- const t = e / a, o = Math.round(r.length / t), n = new Float32Array(o);
760
- for (let s = 0; s < o; s++) {
761
- const i = s * t, l = Math.floor(i), y = i - l, R = r[l] ?? 0, F = r[l + 1] ?? R;
762
- n[s] = R + y * (F - R);
1137
+ function Pn(e, t, s) {
1138
+ if (t === s)
1139
+ return new Float32Array(e);
1140
+ const r = t / s, o = Math.round(e.length / r), n = new Float32Array(o);
1141
+ for (let a = 0; a < o; a++) {
1142
+ const i = a * r, l = Math.floor(i), c = i - l, b = e[l] ?? 0, P = e[l + 1] ?? b;
1143
+ n[a] = b + c * (P - b);
763
1144
  }
764
1145
  return n;
765
1146
  }
766
- async function zt(r, e = 16e3) {
767
- const a = await r.arrayBuffer(), t = window.AudioContext || window.webkitAudioContext, o = new t();
1147
+ async function Mn(e, t = 16e3) {
1148
+ const s = await e.arrayBuffer(), r = window.AudioContext || window.webkitAudioContext, o = new r();
768
1149
  try {
769
- const n = await o.decodeAudioData(a);
770
- let s;
1150
+ const n = await o.decodeAudioData(s);
1151
+ let a;
771
1152
  if (n.numberOfChannels > 1) {
772
- s = new Float32Array(n.length);
1153
+ a = new Float32Array(n.length);
773
1154
  for (let i = 0; i < n.numberOfChannels; i++) {
774
1155
  const l = n.getChannelData(i);
775
- for (let y = 0; y < n.length; y++)
776
- s[y] += l[y] / n.numberOfChannels;
1156
+ for (let c = 0; c < n.length; c++)
1157
+ a[c] += l[c] / n.numberOfChannels;
777
1158
  }
778
1159
  } else
779
- s = n.getChannelData(0);
780
- return Bt(s, n.sampleRate, e);
1160
+ a = n.getChannelData(0);
1161
+ return Pn(a, n.sampleRate, t);
781
1162
  } finally {
782
1163
  o.state !== "closed" && await o.close().catch(() => {
783
1164
  });
784
1165
  }
785
1166
  }
786
- function Be(r, e = 16e3) {
787
- const a = new ArrayBuffer(44 + r.length * 2), t = new DataView(a), o = (s, i) => {
1167
+ function qe(e, t = 16e3) {
1168
+ const s = new ArrayBuffer(44 + e.length * 2), r = new DataView(s), o = (a, i) => {
788
1169
  for (let l = 0; l < i.length; l++)
789
- t.setUint8(s + l, i.charCodeAt(l));
1170
+ r.setUint8(a + l, i.charCodeAt(l));
790
1171
  };
791
- o(0, "RIFF"), t.setUint32(4, 36 + r.length * 2, !0), o(8, "WAVE"), o(12, "fmt "), t.setUint32(16, 16, !0), t.setUint16(20, 1, !0), t.setUint16(22, 1, !0), t.setUint32(24, e, !0), t.setUint32(28, e * 2, !0), t.setUint16(32, 2, !0), t.setUint16(34, 16, !0), o(36, "data"), t.setUint32(40, r.length * 2, !0);
1172
+ o(0, "RIFF"), r.setUint32(4, 36 + e.length * 2, !0), o(8, "WAVE"), o(12, "fmt "), r.setUint32(16, 16, !0), r.setUint16(20, 1, !0), r.setUint16(22, 1, !0), r.setUint32(24, t, !0), r.setUint32(28, t * 2, !0), r.setUint16(32, 2, !0), r.setUint16(34, 16, !0), o(36, "data"), r.setUint32(40, e.length * 2, !0);
792
1173
  let n = 44;
793
- for (let s = 0; s < r.length; s++, n += 2) {
794
- const i = Math.max(-1, Math.min(1, r[s]));
795
- t.setInt16(n, i < 0 ? i * 32768 : i * 32767, !0);
1174
+ for (let a = 0; a < e.length; a++, n += 2) {
1175
+ const i = Math.max(-1, Math.min(1, e[a]));
1176
+ r.setInt16(n, i < 0 ? i * 32768 : i * 32767, !0);
796
1177
  }
797
- return new Blob([t], { type: "audio/wav" });
1178
+ return new Blob([r], { type: "audio/wav" });
798
1179
  }
799
- const Ke = 16e3, Dt = Math.round(Ke * 0.35), Qe = "/scripts/ai/whisper.worker.js";
800
- function jt() {
801
- return new Worker(Pe(Qe), { type: "module" });
1180
+ const ot = 16e3, In = Math.round(ot * 0.35), at = "/scripts/ai/whisper.worker.js";
1181
+ function En() {
1182
+ return new Worker(je(at), { type: "module" });
802
1183
  }
803
- function Pe(r) {
804
- return /^https?:\/\//i.test(r) ? r : typeof location < "u" ? new URL(r, location.origin).href : r;
1184
+ function je(e) {
1185
+ return /^https?:\/\//i.test(e) ? e : typeof location < "u" ? new URL(e, location.origin).href : e;
805
1186
  }
806
- function ze(r) {
807
- if (!r.ok) return !1;
808
- const e = (r.headers.get("content-type") || "").toLowerCase();
809
- return !(e.includes("text/html") || e.includes("application/xhtml+xml"));
1187
+ function We(e) {
1188
+ if (!e.ok) return !1;
1189
+ const t = (e.headers.get("content-type") || "").toLowerCase();
1190
+ return !(t.includes("text/html") || t.includes("application/xhtml+xml"));
810
1191
  }
811
- async function Ht(r) {
1192
+ async function jn(e) {
812
1193
  try {
813
- const e = await fetch(r, { method: "HEAD" });
814
- if (ze(e)) return !0;
1194
+ const t = await fetch(e, { method: "HEAD" });
1195
+ if (We(t)) return !0;
815
1196
  } catch {
816
1197
  }
817
1198
  try {
818
- const e = await fetch(r, { headers: { Range: "bytes=0-64" } });
819
- if (ze(e)) return !0;
1199
+ const t = await fetch(e, { headers: { Range: "bytes=0-64" } });
1200
+ if (We(t)) return !0;
820
1201
  } catch {
821
1202
  }
822
1203
  return !1;
823
1204
  }
824
- async function qt(r) {
825
- const e = [];
826
- r && e.push(Pe(r)), e.push(Pe(Qe));
827
- const a = [...new Set(e.filter(Boolean))];
828
- for (const t of a)
829
- if (await Ht(t))
830
- return console.log("[VoiceInputManager] 使用语音 Worker:", t), t;
1205
+ async function zn(e) {
1206
+ const t = [];
1207
+ e && t.push(je(e)), t.push(je(at));
1208
+ const s = [...new Set(t.filter(Boolean))];
1209
+ for (const r of s)
1210
+ if (await jn(r))
1211
+ return console.log("[VoiceInputManager] 使用语音 Worker:", r), r;
831
1212
  return console.warn(
832
1213
  "[VoiceInputManager] 未探测到可访问的 Worker 脚本,将回退到 Vite 打包注入地址。已尝试:",
833
- a.join(" , ")
1214
+ s.join(" , ")
834
1215
  ), null;
835
1216
  }
836
- class Wt {
837
- constructor(e = {}) {
838
- U(this, "recorder", null);
839
- U(this, "worker", null);
840
- U(this, "status", "idle");
841
- U(this, "options");
842
- U(this, "isReady", !1);
843
- U(this, "initPromise", null);
844
- U(this, "currentTaskId", 0);
845
- U(this, "pcmParts", []);
846
- U(this, "pcmLength", 0);
847
- U(this, "streamChunkIndex", 0);
848
- U(this, "committedText", "");
1217
+ class Ln {
1218
+ constructor(t = {}) {
1219
+ M(this, "recorder", null);
1220
+ M(this, "worker", null);
1221
+ M(this, "status", "idle");
1222
+ M(this, "options");
1223
+ M(this, "isReady", !1);
1224
+ M(this, "initPromise", null);
1225
+ M(this, "currentTaskId", 0);
1226
+ M(this, "pcmParts", []);
1227
+ M(this, "pcmLength", 0);
1228
+ M(this, "streamChunkIndex", 0);
1229
+ M(this, "committedText", "");
849
1230
  this.options = {
850
1231
  soundBaseUrl: "/sounds/",
851
1232
  remoteHost: "https://hf-mirror.com",
852
1233
  modelId: "onnx-community/whisper-base",
853
1234
  language: "chinese",
854
- ...e
1235
+ ...t
855
1236
  };
856
1237
  }
857
1238
  get currentStatus() {
@@ -863,19 +1244,19 @@ class Wt {
863
1244
  /**
864
1245
  * 初始化语音引擎(延迟加载,仅在首次使用或调用时触发)
865
1246
  */
866
- async init(e) {
1247
+ async init(t) {
867
1248
  if (!this.isReady)
868
- return this.initPromise ? this.initPromise : (e && (this.options.soundBaseUrl = e), this.initPromise = new Promise((a, t) => {
1249
+ return this.initPromise ? this.initPromise : (t && (this.options.soundBaseUrl = t), this.initPromise = new Promise((s, r) => {
869
1250
  this.setStatus("loading", "正在准备语音识别引擎..."), (async () => {
870
- var n, s;
1251
+ var n, a;
871
1252
  try {
872
- const i = await qt(this.options.workerUrl);
873
- this.worker = i ? new Worker(i, { type: "module" }) : jt(), this.worker.onmessage = (l) => {
874
- this.handleWorkerMessage(l, a, t);
1253
+ const i = await zn(this.options.workerUrl);
1254
+ this.worker = i ? new Worker(i, { type: "module" }) : En(), this.worker.onmessage = (l) => {
1255
+ this.handleWorkerMessage(l, s, r);
875
1256
  }, this.worker.onerror = (l) => {
876
- var F, _;
877
- const R = `语音后台线程异常: ${l.message || l.filename || i || "未知错误"}`;
878
- this.initPromise = null, this.setStatus("error", R), (_ = (F = this.options).onError) == null || _.call(F, R), t(l);
1257
+ var P, A;
1258
+ const b = `语音后台线程异常: ${l.message || l.filename || i || "未知错误"}`;
1259
+ this.initPromise = null, this.setStatus("error", b), (A = (P = this.options).onError) == null || A.call(P, b), r(l);
879
1260
  }, this.worker.postMessage({
880
1261
  type: "INIT",
881
1262
  data: {
@@ -886,7 +1267,7 @@ class Wt {
886
1267
  });
887
1268
  } catch (i) {
888
1269
  const l = `创建语音 Worker 失败: ${i.message || i}`;
889
- this.initPromise = null, this.setStatus("error", l), (s = (n = this.options).onError) == null || s.call(n, l), t(i);
1270
+ this.initPromise = null, this.setStatus("error", l), (a = (n = this.options).onError) == null || a.call(n, l), r(i);
890
1271
  }
891
1272
  })();
892
1273
  }), this.initPromise);
@@ -895,15 +1276,15 @@ class Wt {
895
1276
  * 开始语音录入(只采集,点「完成」后再转写)
896
1277
  */
897
1278
  async startRecording() {
898
- var e, a, t, o;
1279
+ var t, s, r, o;
899
1280
  if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
900
1281
  const n = window.isSecureContext ? "当前浏览器环境不支持获取麦克风音频,请使用现代浏览器。" : "当前页面不是安全上下文,浏览器禁止调用麦克风。请使用 https:// 或 http://localhost / http://127.0.0.1 访问(通过局域网 IP 的 http 地址无法录音)。";
901
- throw this.setStatus("error", n), (a = (e = this.options).onError) == null || a.call(e, n), new Error(n);
1282
+ throw this.setStatus("error", n), (s = (t = this.options).onError) == null || s.call(t, n), new Error(n);
902
1283
  }
903
- this.isReady || await this.init(), this.recorder || (this.recorder = new $t({
1284
+ this.isReady || await this.init(), this.recorder || (this.recorder = new _n({
904
1285
  onVolumeChange: (n) => {
905
- var s, i;
906
- (i = (s = this.options).onVolumeChange) == null || i.call(s, n);
1286
+ var a, i;
1287
+ (i = (a = this.options).onVolumeChange) == null || i.call(a, n);
907
1288
  },
908
1289
  onAudioChunk: (n) => {
909
1290
  this.appendPcm(n);
@@ -912,14 +1293,14 @@ class Wt {
912
1293
  try {
913
1294
  this.currentTaskId++, this.resetStreamState(), await this.recorder.start(), this.setStatus("recording", "正在录音...");
914
1295
  } catch (n) {
915
- throw this.setStatus("error", n.message || "启动录音失败"), (o = (t = this.options).onError) == null || o.call(t, n.message || "启动录音失败"), n;
1296
+ throw this.setStatus("error", n.message || "启动录音失败"), (o = (r = this.options).onError) == null || o.call(r, n.message || "启动录音失败"), n;
916
1297
  }
917
1298
  }
918
1299
  /**
919
1300
  * 停止录音并触发模型端侧推理
920
1301
  */
921
1302
  async stopAndTranscribe() {
922
- var e, a, t, o;
1303
+ var t, s, r, o;
923
1304
  if (!(!this.recorder || !this.recorder.isRecording))
924
1305
  try {
925
1306
  await this.recorder.stop();
@@ -930,59 +1311,59 @@ class Wt {
930
1311
  }
931
1312
  this.setStatus("transcribing", "正在识别语音...");
932
1313
  try {
933
- const s = Be(n), i = URL.createObjectURL(s);
934
- (a = (e = this.options).onAudioRecorded) == null || a.call(e, i, s);
935
- } catch (s) {
936
- console.warn("生成录音回放音频失败:", s);
1314
+ const a = qe(n), i = URL.createObjectURL(a);
1315
+ (s = (t = this.options).onAudioRecorded) == null || s.call(t, i, a);
1316
+ } catch (a) {
1317
+ console.warn("生成录音回放音频失败:", a);
937
1318
  }
938
1319
  await this.transcribeAudioData(n);
939
1320
  } catch (n) {
940
- this.setStatus("error", n.message || "音频处理失败"), (o = (t = this.options).onError) == null || o.call(t, n.message || "音频处理失败");
1321
+ this.setStatus("error", n.message || "音频处理失败"), (o = (r = this.options).onError) == null || o.call(r, n.message || "音频处理失败");
941
1322
  }
942
1323
  }
943
1324
  /**
944
1325
  * 直接对外部传入的 16kHz Float32Array 音频进行端侧推理(例如文件上传)
945
1326
  */
946
- async transcribeAudioData(e, a) {
947
- var t, o, n, s;
1327
+ async transcribeAudioData(t, s) {
1328
+ var r, o, n, a;
948
1329
  this.isReady || await this.init(), this.setStatus("transcribing", "正在流式识别音频...");
949
1330
  try {
950
- a && ((o = (t = this.options).onAudioRecorded) == null || o.call(t, a, Be(e))), this.currentTaskId++, this.resetStreamState(), this.appendPcm(e), this.dispatchFullAudio();
1331
+ s && ((o = (r = this.options).onAudioRecorded) == null || o.call(r, s, qe(t))), this.currentTaskId++, this.resetStreamState(), this.appendPcm(t), this.dispatchFullAudio();
951
1332
  } catch (i) {
952
- this.setStatus("error", i.message || "音频处理失败"), (s = (n = this.options).onError) == null || s.call(n, i.message || "音频处理失败");
1333
+ this.setStatus("error", i.message || "音频处理失败"), (a = (n = this.options).onError) == null || a.call(n, i.message || "音频处理失败");
953
1334
  }
954
1335
  }
955
1336
  /**
956
1337
  * 上传音频/视频文件(支持 mp4, wav, mp3, m4a 等)并在浏览器端解析识别
957
1338
  */
958
- async transcribeFile(e) {
959
- var a, t;
1339
+ async transcribeFile(t) {
1340
+ var s, r;
960
1341
  this.isReady || await this.init(), this.setStatus("loading", "正在解析音频文件...");
961
1342
  try {
962
- const o = await zt(e);
1343
+ const o = await Mn(t);
963
1344
  if (o.length === 0)
964
1345
  throw new Error("未能从该文件中提取出有效音频");
965
- const n = URL.createObjectURL(e);
1346
+ const n = URL.createObjectURL(t);
966
1347
  await this.transcribeAudioData(o, n);
967
1348
  } catch (o) {
968
- this.setStatus("error", o.message || "音频文件解析失败"), (t = (a = this.options).onError) == null || t.call(a, o.message || "音频文件解析失败");
1349
+ this.setStatus("error", o.message || "音频文件解析失败"), (r = (s = this.options).onError) == null || r.call(s, o.message || "音频文件解析失败");
969
1350
  }
970
1351
  }
971
1352
  /**
972
1353
  * 取消当前录音并丢弃
973
1354
  */
974
1355
  cancelRecording() {
975
- var a;
976
- const e = this.currentTaskId;
977
- this.currentTaskId++, (a = this.worker) == null || a.postMessage({ type: "CANCEL", taskId: e }), this.resetStreamState(), this.recorder && this.recorder.cancel(), this.setStatus("idle");
1356
+ var s;
1357
+ const t = this.currentTaskId;
1358
+ this.currentTaskId++, (s = this.worker) == null || s.postMessage({ type: "CANCEL", taskId: t }), this.resetStreamState(), this.recorder && this.recorder.cancel(), this.setStatus("idle");
978
1359
  }
979
1360
  /**
980
1361
  * 取消当前的语音识别推理任务
981
1362
  */
982
1363
  cancelTranscribe() {
983
- var a;
984
- const e = this.currentTaskId;
985
- this.currentTaskId++, (a = this.worker) == null || a.postMessage({ type: "CANCEL", taskId: e }), this.resetStreamState(), (this.status === "transcribing" || this.status === "recording") && this.setStatus("idle");
1364
+ var s;
1365
+ const t = this.currentTaskId;
1366
+ this.currentTaskId++, (s = this.worker) == null || s.postMessage({ type: "CANCEL", taskId: t }), this.resetStreamState(), (this.status === "transcribing" || this.status === "recording") && this.setStatus("idle");
986
1367
  }
987
1368
  /**
988
1369
  * 清除本地模型缓存
@@ -994,31 +1375,31 @@ class Wt {
994
1375
  * 销毁并释放所有资源
995
1376
  */
996
1377
  destroy() {
997
- var a;
998
- const e = this.currentTaskId;
999
- this.currentTaskId++, (a = this.worker) == null || a.postMessage({ type: "CANCEL", taskId: e }), this.resetStreamState(), this.recorder && (this.recorder.cancel(), this.recorder = null), this.worker && (this.worker.terminate(), this.worker = null), this.isReady = !1, this.initPromise = null, this.setStatus("idle");
1378
+ var s;
1379
+ const t = this.currentTaskId;
1380
+ this.currentTaskId++, (s = this.worker) == null || s.postMessage({ type: "CANCEL", taskId: t }), this.resetStreamState(), this.recorder && (this.recorder.cancel(), this.recorder = null), this.worker && (this.worker.terminate(), this.worker = null), this.isReady = !1, this.initPromise = null, this.setStatus("idle");
1000
1381
  }
1001
1382
  resetStreamState() {
1002
1383
  this.pcmParts = [], this.pcmLength = 0, this.streamChunkIndex = 0, this.committedText = "";
1003
1384
  }
1004
- appendPcm(e) {
1005
- !e || e.length === 0 || (this.pcmParts.push(new Float32Array(e)), this.pcmLength += e.length);
1385
+ appendPcm(t) {
1386
+ !t || t.length === 0 || (this.pcmParts.push(new Float32Array(t)), this.pcmLength += t.length);
1006
1387
  }
1007
1388
  mergePcm() {
1008
- const e = new Float32Array(this.pcmLength);
1009
- let a = 0;
1010
- for (const t of this.pcmParts)
1011
- e.set(t, a), a += t.length;
1012
- return e;
1389
+ const t = new Float32Array(this.pcmLength);
1390
+ let s = 0;
1391
+ for (const r of this.pcmParts)
1392
+ t.set(r, s), s += r.length;
1393
+ return t;
1013
1394
  }
1014
- emitPartial(e) {
1015
- var a, t;
1016
- (t = (a = this.options).onPartial) == null || t.call(a, (e || "").trim());
1395
+ emitPartial(t) {
1396
+ var s, r;
1397
+ (r = (s = this.options).onPartial) == null || r.call(s, (t || "").trim());
1017
1398
  }
1018
- finishStream(e) {
1019
- var t, o;
1020
- const a = (e ?? this.committedText).trim();
1021
- this.setStatus("idle"), (o = (t = this.options).onResult) == null || o.call(t, a);
1399
+ finishStream(t) {
1400
+ var r, o;
1401
+ const s = (t ?? this.committedText).trim();
1402
+ this.setStatus("idle"), (o = (r = this.options).onResult) == null || o.call(r, s);
1022
1403
  }
1023
1404
  /**
1024
1405
  * 录音结束或上传:整段一次送入 Worker。超过 30s 由 Worker 按重叠窗口切分。
@@ -1028,41 +1409,41 @@ class Wt {
1028
1409
  this.finishStream();
1029
1410
  return;
1030
1411
  }
1031
- if (this.pcmLength < Dt) {
1412
+ if (this.pcmLength < In) {
1032
1413
  this.finishStream();
1033
1414
  return;
1034
1415
  }
1035
- const e = this.mergePcm(), a = e.length > Ke * 30;
1416
+ const t = this.mergePcm(), s = t.length > ot * 30;
1036
1417
  this.committedText = "", this.worker.postMessage(
1037
1418
  {
1038
1419
  type: "TRANSCRIBE",
1039
1420
  data: {
1040
1421
  taskId: this.currentTaskId,
1041
- audio: e,
1422
+ audio: t,
1042
1423
  language: this.options.language,
1043
1424
  stream: !0,
1044
1425
  chunkIndex: this.streamChunkIndex++,
1045
1426
  isFinal: !0,
1046
1427
  mode: "append",
1047
- nativeChunking: a
1428
+ nativeChunking: s
1048
1429
  }
1049
1430
  },
1050
- [e.buffer]
1431
+ [t.buffer]
1051
1432
  );
1052
1433
  }
1053
- handleWorkerMessage(e, a, t) {
1054
- var y, R, F, _;
1055
- const { type: o, data: n, taskId: s, text: i, error: l } = e.data;
1434
+ handleWorkerMessage(t, s, r) {
1435
+ var c, b, P, A;
1436
+ const { type: o, data: n, taskId: a, text: i, error: l } = t.data;
1056
1437
  switch (o) {
1057
1438
  case "READY":
1058
- this.isReady = !0, this.setStatus("ready", "语音引擎就绪"), a == null || a();
1439
+ this.isReady = !0, this.setStatus("ready", "语音引擎就绪"), s == null || s();
1059
1440
  break;
1060
1441
  case "PROGRESS":
1061
1442
  if (n) {
1062
- const S = typeof n.progress == "number" ? Math.round(n.progress) : 0;
1063
- this.setStatus("downloading", `正在下载语音模型... ${S}%`), (R = (y = this.options).onProgress) == null || R.call(y, {
1443
+ const p = typeof n.progress == "number" ? Math.round(n.progress) : 0;
1444
+ this.setStatus("downloading", `正在下载语音模型... ${p}%`), (b = (c = this.options).onProgress) == null || b.call(c, {
1064
1445
  status: n.status || "progress",
1065
- progress: S,
1446
+ progress: p,
1066
1447
  file: n.file,
1067
1448
  loaded: n.loaded,
1068
1449
  total: n.total
@@ -1070,15 +1451,15 @@ class Wt {
1070
1451
  }
1071
1452
  break;
1072
1453
  case "TRANSCRIBING":
1073
- if (s && s !== this.currentTaskId) return;
1454
+ if (a && a !== this.currentTaskId) return;
1074
1455
  this.status !== "recording" && this.setStatus("transcribing", "正在流式转写文字...");
1075
1456
  break;
1076
1457
  case "PARTIAL":
1077
- if (s && s !== this.currentTaskId) return;
1458
+ if (a && a !== this.currentTaskId) return;
1078
1459
  this.committedText = i || "", this.emitPartial(this.committedText);
1079
1460
  break;
1080
1461
  case "RESULT":
1081
- if (s && s !== this.currentTaskId)
1462
+ if (a && a !== this.currentTaskId)
1082
1463
  return;
1083
1464
  this.committedText = (i || "").trim() || this.committedText, this.emitPartial(this.committedText), this.finishStream(this.committedText);
1084
1465
  break;
@@ -1086,64 +1467,64 @@ class Wt {
1086
1467
  this.setStatus("idle", "语音模型缓存已清空");
1087
1468
  break;
1088
1469
  case "ERROR":
1089
- if (s && s !== this.currentTaskId) return;
1090
- this.setStatus("error", l || "语音服务异常"), (_ = (F = this.options).onError) == null || _.call(F, l || "语音服务异常"), t == null || t(new Error(l));
1470
+ if (a && a !== this.currentTaskId) return;
1471
+ this.setStatus("error", l || "语音服务异常"), (A = (P = this.options).onError) == null || A.call(P, l || "语音服务异常"), r == null || r(new Error(l));
1091
1472
  break;
1092
1473
  }
1093
1474
  }
1094
- setStatus(e, a) {
1095
- var t, o;
1096
- this.status = e, (o = (t = this.options).onStatusChange) == null || o.call(t, e, a);
1475
+ setStatus(t, s) {
1476
+ var r, o;
1477
+ this.status = t, (o = (r = this.options).onStatusChange) == null || o.call(r, t, s);
1097
1478
  }
1098
1479
  }
1099
- const Gt = { class: "panel-header" }, Jt = { class: "header-actions" }, Kt = { class: "header-title" }, Qt = { class: "action-icons" }, Zt = { class: "body-content" }, Yt = {
1480
+ const $n = { class: "panel-header" }, On = { class: "header-actions" }, Nn = { class: "header-title" }, Fn = { class: "action-icons" }, Bn = { class: "body-content" }, Vn = {
1100
1481
  key: 0,
1101
1482
  class: "welcome-content"
1102
- }, Xt = { class: "subtitle" }, en = { class: "highlight" }, tn = { class: "quick-questions" }, nn = ["onClick"], rn = {
1483
+ }, Hn = { class: "subtitle" }, Dn = { class: "highlight" }, qn = { class: "quick-questions" }, Wn = ["onClick"], Gn = {
1103
1484
  key: 1,
1104
1485
  class: "message-content user-content"
1105
- }, an = { class: "panel-footer" }, on = {
1486
+ }, Jn = { class: "panel-footer" }, Kn = {
1106
1487
  key: 0,
1107
- src: mt,
1488
+ src: xt,
1108
1489
  alt: "加载中",
1109
1490
  class: "loading-icon"
1110
- }, sn = {
1491
+ }, Xn = {
1111
1492
  key: 0,
1112
1493
  class: "voice-progress-banner"
1113
- }, ln = { class: "progress-info" }, cn = { class: "progress-text" }, un = {
1494
+ }, Yn = { class: "progress-info" }, Zn = { class: "progress-text" }, Qn = {
1114
1495
  key: 0,
1115
1496
  class: "progress-percent"
1116
- }, dn = {
1497
+ }, er = {
1117
1498
  key: 0,
1118
1499
  class: "progress-track"
1119
- }, hn = { class: "recording-main" }, fn = { class: "recording-status" }, pn = {
1500
+ }, tr = { class: "recording-main" }, nr = { class: "recording-status" }, rr = {
1120
1501
  key: 0,
1121
1502
  class: "recording-time"
1122
- }, mn = { class: "recording-hint" }, gn = {
1503
+ }, sr = { class: "recording-hint" }, or = {
1123
1504
  key: 1,
1124
1505
  class: "volume-waves"
1125
- }, vn = { class: "recording-actions" }, yn = ["title"], wn = {
1506
+ }, ar = { class: "recording-actions" }, ir = ["title"], lr = {
1126
1507
  key: 0,
1127
1508
  class: "voice-playback-bar"
1128
- }, kn = ["title"], bn = { class: "playback-play-icon" }, Sn = {
1509
+ }, cr = ["title"], ur = { class: "playback-play-icon" }, dr = {
1129
1510
  key: 0,
1130
1511
  viewBox: "0 0 24 24",
1131
1512
  width: "14",
1132
1513
  height: "14",
1133
1514
  fill: "currentColor"
1134
- }, Cn = {
1515
+ }, fr = {
1135
1516
  key: 1,
1136
1517
  viewBox: "0 0 24 24",
1137
1518
  width: "14",
1138
1519
  height: "14",
1139
1520
  fill: "currentColor"
1140
- }, xn = { class: "playback-title" }, Rn = {
1521
+ }, hr = { class: "playback-title" }, pr = {
1141
1522
  key: 0,
1142
1523
  class: "playback-time"
1143
- }, Tn = {
1524
+ }, mr = {
1144
1525
  key: 1,
1145
1526
  class: "playback-waves"
1146
- }, An = { class: "input-box" }, _n = { class: "input-actions-box" }, Un = ["src"], Ze = {
1527
+ }, gr = { class: "input-box" }, yr = { class: "input-actions-box" }, vr = ["src"], it = {
1147
1528
  __name: "ChatPanel",
1148
1529
  props: {
1149
1530
  modelValue: {
@@ -1221,213 +1602,237 @@ const Gt = { class: "panel-header" }, Jt = { class: "header-actions" }, Kt = { c
1221
1602
  embedded: {
1222
1603
  type: Boolean,
1223
1604
  default: !1
1605
+ },
1606
+ /**
1607
+ * szjy-ui fence 自定义 UI 配置,透传给动作处理器。
1608
+ * 例如:{ postMessage: { target: () => sandboxIframe.contentWindow, targetOrigin: 'http://...' } }
1609
+ */
1610
+ customUi: {
1611
+ type: Object,
1612
+ default: null
1613
+ },
1614
+ /**
1615
+ * szjy-ui 动作拦截钩子:(action, params, triggerEl) => false 可阻止内置动作执行
1616
+ */
1617
+ uiActionHandler: {
1618
+ type: Function,
1619
+ default: null
1620
+ },
1621
+ /**
1622
+ * Mock 响应内容:llmName 为 standard(模拟数据模型)时不请求真实后端,
1623
+ * 将该内容流式输出,用于联调 szjy-ui fence / postMessage 动作
1624
+ */
1625
+ mockResponse: {
1626
+ type: String,
1627
+ default: ""
1224
1628
  }
1225
1629
  },
1226
- emits: ["update:modelValue", "submit"],
1227
- setup(r, { emit: e }) {
1228
- const { appContext: a } = je(), { $message: t } = a.config.globalProperties, o = r;
1630
+ emits: ["update:modelValue", "submit", "ui-action"],
1631
+ setup(e, { emit: t }) {
1632
+ const { appContext: s } = Je(), { $message: r } = s.config.globalProperties, o = e;
1229
1633
  let n = null;
1230
- const s = x("idle"), i = x(""), l = x(0), y = x(0), R = x(0);
1231
- let F = null;
1232
- const _ = x(""), S = x(!1), W = x(0);
1233
- let T = null;
1234
- const N = x(""), v = x(""), p = O(() => s.value === "downloading"), m = O(() => s.value === "loading"), d = O(() => s.value === "recording"), c = O(() => s.value === "transcribing"), k = O(() => d.value ? "正在录音,点击完成后开始识别" : N.value ? "正在流式转写..." : "正在识别语音中..."), b = O(() => o.enableVoiceInput ? "请输入您的问题或点击麦克风语音输入" : o.enableVoiceUpload ? "请输入您的问题或上传音频识别" : "请输入您的问题"), L = (f, h) => {
1235
- const P = (f || "").trim(), B = (h || "").trim();
1236
- return B ? P ? /[A-Za-z0-9]$/.test(P) && /[A-Za-z0-9]/.test(B.charAt(0)) ? `${P} ${B}` : `${P}${B}` : B : P;
1237
- }, A = (f) => {
1238
- const h = Math.floor(f / 60), P = f % 60;
1239
- return `${h.toString().padStart(2, "0")}:${P.toString().padStart(2, "0")}`;
1240
- }, I = () => (n || (n = new Wt({
1634
+ const a = T("idle"), i = T(""), l = T(0), c = T(0), b = T(0);
1635
+ let P = null;
1636
+ const A = T(""), p = T(!1), F = T(0);
1637
+ let U = null;
1638
+ const z = T(""), y = T(""), m = N(() => a.value === "downloading"), v = N(() => a.value === "loading"), f = N(() => a.value === "recording"), u = N(() => a.value === "transcribing"), k = N(() => f.value ? "正在录音,点击完成后开始识别" : z.value ? "正在流式转写..." : "正在识别语音中..."), C = N(() => o.enableVoiceInput ? "请输入您的问题或点击麦克风语音输入" : o.enableVoiceUpload ? "请输入您的问题或上传音频识别" : "请输入您的问题"), L = (g, h) => {
1639
+ const E = (g || "").trim(), B = (h || "").trim();
1640
+ return B ? E ? /[A-Za-z0-9]$/.test(E) && /[A-Za-z0-9]/.test(B.charAt(0)) ? `${E} ${B}` : `${E}${B}` : B : E;
1641
+ }, R = (g) => {
1642
+ const h = Math.floor(g / 60), E = g % 60;
1643
+ return `${h.toString().padStart(2, "0")}:${E.toString().padStart(2, "0")}`;
1644
+ }, I = () => (n || (n = new Ln({
1241
1645
  soundBaseUrl: o.soundBaseUrl || "/sounds/",
1242
1646
  workerUrl: o.workerUrl || void 0,
1243
- onStatusChange: (f, h) => {
1244
- s.value = f, h && (i.value = h);
1647
+ onStatusChange: (g, h) => {
1648
+ a.value = g, h && (i.value = h);
1245
1649
  },
1246
- onProgress: (f) => {
1247
- typeof f.progress == "number" && (l.value = f.progress);
1650
+ onProgress: (g) => {
1651
+ typeof g.progress == "number" && (l.value = g.progress);
1248
1652
  },
1249
- onVolumeChange: (f) => {
1250
- y.value = f;
1653
+ onVolumeChange: (g) => {
1654
+ c.value = g;
1251
1655
  },
1252
- onAudioRecorded: (f) => {
1253
- _.value && URL.revokeObjectURL(_.value), _.value = f, W.value = R.value;
1656
+ onAudioRecorded: (g) => {
1657
+ A.value && URL.revokeObjectURL(A.value), A.value = g, F.value = b.value;
1254
1658
  },
1255
- onPartial: (f) => {
1256
- N.value = f || "", E.value = L(v.value, f);
1659
+ onPartial: (g) => {
1660
+ z.value = g || "", _.value = L(y.value, g);
1257
1661
  },
1258
- onResult: (f) => {
1259
- N.value = f || "", E.value = L(v.value, f), f ? t.success("语音识别完成") : t.warning("未能识别出有效语音,请重试"), setTimeout(() => {
1260
- N.value = "", Q.value && Q.value.focus();
1662
+ onResult: (g) => {
1663
+ z.value = g || "", _.value = L(y.value, g), g ? r.success("语音识别完成") : r.warning("未能识别出有效语音,请重试"), setTimeout(() => {
1664
+ z.value = "", V.value && V.value.focus();
1261
1665
  }, 100);
1262
1666
  },
1263
- onError: (f) => {
1264
- t.error(f || "语音输入服务出错"), V();
1667
+ onError: (g) => {
1668
+ r.error(g || "语音输入服务出错"), O();
1265
1669
  }
1266
- })), n), g = () => {
1267
- V(), R.value = 0, F = setInterval(() => {
1268
- R.value += 1;
1670
+ })), n), w = () => {
1671
+ O(), b.value = 0, P = setInterval(() => {
1672
+ b.value += 1;
1269
1673
  }, 1e3);
1270
- }, V = () => {
1271
- F && (clearInterval(F), F = null);
1272
- }, K = async () => {
1674
+ }, O = () => {
1675
+ P && (clearInterval(P), P = null);
1676
+ }, X = async () => {
1273
1677
  if (!o.enableVoiceInput) return;
1274
- if (d.value) {
1275
- await X();
1678
+ if (f.value) {
1679
+ await Y();
1276
1680
  return;
1277
1681
  }
1278
- S.value && T && (T.pause(), S.value = !1);
1279
- const f = I();
1682
+ p.value && U && (U.pause(), p.value = !1);
1683
+ const g = I();
1280
1684
  try {
1281
- v.value = E.value, N.value = "", g(), await f.startRecording();
1685
+ y.value = _.value, z.value = "", w(), await g.startRecording();
1282
1686
  } catch (h) {
1283
- V(), console.error("启动录音失败:", h);
1687
+ O(), console.error("启动录音失败:", h);
1284
1688
  }
1285
- }, X = async () => {
1286
- V(), n && await n.stopAndTranscribe();
1287
- }, G = x(null), H = () => {
1288
- o.enableVoiceUpload && G.value && (G.value.value = "", G.value.click());
1289
- }, oe = async (f) => {
1290
- var Y;
1689
+ }, Y = async () => {
1690
+ O(), n && await n.stopAndTranscribe();
1691
+ }, Z = T(null), ne = () => {
1692
+ o.enableVoiceUpload && Z.value && (Z.value.value = "", Z.value.click());
1693
+ }, q = async (g) => {
1694
+ var te;
1291
1695
  if (!o.enableVoiceUpload) return;
1292
- const h = f.target, P = (Y = h == null ? void 0 : h.files) == null ? void 0 : Y[0];
1293
- if (!P) return;
1294
- S.value && T && (T.pause(), S.value = !1);
1696
+ const h = g.target, E = (te = h == null ? void 0 : h.files) == null ? void 0 : te[0];
1697
+ if (!E) return;
1698
+ p.value && U && (U.pause(), p.value = !1);
1295
1699
  const B = I();
1296
1700
  try {
1297
- v.value = E.value, N.value = "", t.info(`正在流式识别文件: ${P.name}`), await B.transcribeFile(P);
1298
- } catch (D) {
1299
- t.error(`文件识别失败: ${D.message || D}`);
1701
+ y.value = _.value, z.value = "", r.info(`正在流式识别文件: ${E.name}`), await B.transcribeFile(E);
1702
+ } catch (H) {
1703
+ r.error(`文件识别失败: ${H.message || H}`);
1300
1704
  }
1301
- }, se = () => {
1302
- V(), N.value = "", E.value = v.value, n && n.cancelRecording();
1303
- }, ie = () => {
1304
- N.value = "", E.value = v.value, n && n.cancelTranscribe(), t.info("已取消本次语音识别");
1305
- }, de = () => {
1306
- if (_.value) {
1307
- if (S.value && T) {
1308
- T.pause(), S.value = !1;
1705
+ }, oe = () => {
1706
+ O(), z.value = "", _.value = y.value, n && n.cancelRecording();
1707
+ }, fe = () => {
1708
+ z.value = "", _.value = y.value, n && n.cancelTranscribe(), r.info("已取消本次语音识别");
1709
+ }, ke = () => {
1710
+ if (A.value) {
1711
+ if (p.value && U) {
1712
+ U.pause(), p.value = !1;
1309
1713
  return;
1310
1714
  }
1311
- T && (T.pause(), T = null), T = new Audio(_.value), T.onloadedmetadata = () => {
1312
- T && !isNaN(T.duration) && (W.value = Math.round(T.duration));
1313
- }, T.onended = () => {
1314
- S.value = !1;
1315
- }, T.onerror = () => {
1316
- S.value = !1, t.error("音频试听播放失败");
1317
- }, T.play().then(() => {
1318
- S.value = !0;
1319
- }).catch((f) => {
1320
- console.error("音频播放出错:", f), S.value = !1;
1715
+ U && (U.pause(), U = null), U = new Audio(A.value), U.onloadedmetadata = () => {
1716
+ U && !isNaN(U.duration) && (F.value = Math.round(U.duration));
1717
+ }, U.onended = () => {
1718
+ p.value = !1;
1719
+ }, U.onerror = () => {
1720
+ p.value = !1, r.error("音频试听播放失败");
1721
+ }, U.play().then(() => {
1722
+ p.value = !0;
1723
+ }).catch((g) => {
1724
+ console.error("音频播放出错:", g), p.value = !1;
1321
1725
  });
1322
1726
  }
1323
- }, we = () => {
1324
- T && (T.pause(), T = null), S.value = !1, _.value && (URL.revokeObjectURL(_.value), _.value = "");
1727
+ }, ae = () => {
1728
+ U && (U.pause(), U = null), p.value = !1, A.value && (URL.revokeObjectURL(A.value), A.value = "");
1325
1729
  };
1326
- ut(() => {
1327
- V(), we(), n && (n.destroy(), n = null);
1730
+ bt(() => {
1731
+ O(), ae(), n && (n.destroy(), n = null);
1328
1732
  });
1329
- const $ = O(() => Oe.find((f) => f.modelName === o.llmName) ?? Oe.find((f) => f.modelName === "szjy")), z = e, E = x(""), Q = x(null), re = x(!1), ee = x([]), et = x([
1733
+ const xe = N(() => Ve.find((g) => g.modelName === o.llmName) ?? Ve.find((g) => g.modelName === "szjy")), j = t, _ = T(""), V = T(null), ie = T(!1), G = T([]), ut = T([
1330
1734
  "什么是AI助理,能做什么?",
1331
1735
  "当前项目的基本情况?",
1332
1736
  "当前项目的进度情况?",
1333
1737
  "当前项目的参建方有哪些?",
1334
1738
  "数智建管平台有哪些功能?能做什么?"
1335
- ]), le = x([]), he = x(!1), Ce = x(null), xe = () => {
1336
- We(() => {
1337
- if (Ce.value) {
1338
- const f = Ce.value, h = f.scrollHeight, P = f.scrollTop, B = f.clientHeight;
1339
- h - P - B < 100 ? f.scrollTop = h : f.scrollTo({
1739
+ ]), le = T([]), he = T(!1), Te = T(null), Re = () => {
1740
+ Ye(() => {
1741
+ if (Te.value) {
1742
+ const g = Te.value, h = g.scrollHeight, E = g.scrollTop, B = g.clientHeight;
1743
+ h - E - B < 100 ? g.scrollTop = h : g.scrollTo({
1340
1744
  top: h
1341
1745
  });
1342
1746
  }
1343
1747
  });
1344
- }, ae = x(!1), tt = O(() => ae.value ? "/images/ai-stop.png" : "/images/ai-send.png"), Ee = (f, h) => {
1345
- console.log("onFailedReader", f, h), he.value = !1;
1346
- const P = Me();
1347
- P && P.initializeEnd(), t.error("转换失败,请重试"), ae.value = !1, setTimeout(() => {
1348
- Q.value && Q.value.focus();
1748
+ }, se = T(!1), dt = N(() => se.value ? "/images/ai-stop.png" : "/images/ai-send.png"), Ne = (g, h) => {
1749
+ console.log("onFailedReader", g, h), he.value = !1;
1750
+ const E = Fe();
1751
+ E && E.initializeEnd(), r.error("转换失败,请重试"), se.value = !1, setTimeout(() => {
1752
+ V.value && V.value.focus();
1349
1753
  });
1350
- }, nt = (f, h) => {
1351
- he.value = !1, ae.value = !1, xe(), h && ee.value[f] && (ee.value[f].displayText = h), setTimeout(() => {
1352
- Q.value && Q.value.focus();
1754
+ }, ft = (g, h) => {
1755
+ he.value = !1, se.value = !1, Re(), h && G.value[g] && (G.value[g].displayText = h), setTimeout(() => {
1756
+ V.value && V.value.focus();
1353
1757
  });
1354
- }, rt = (f) => {
1355
- ae.value = !0;
1356
- }, at = () => {
1357
- ae.value = !1, z("update:modelValue", !1), re.value = !1, ee.value = [];
1358
- }, Re = x(!1), ot = () => {
1359
- Re.value = !Re.value;
1360
- }, st = (f) => {
1361
- E.value = f, Te();
1362
- }, Me = () => {
1363
- for (let f = le.value.length - 1; f >= 0; f--)
1364
- if (le.value[f])
1365
- return le.value[f];
1758
+ }, ht = (g) => {
1759
+ se.value = !0;
1760
+ }, pt = () => {
1761
+ se.value = !1, j("update:modelValue", !1), ie.value = !1, G.value = [];
1762
+ }, Ue = T(!1), mt = () => {
1763
+ Ue.value = !Ue.value;
1764
+ }, gt = (g) => {
1765
+ _.value = g, _e();
1766
+ }, Fe = () => {
1767
+ for (let g = le.value.length - 1; g >= 0; g--)
1768
+ if (le.value[g])
1769
+ return le.value[g];
1366
1770
  return null;
1367
- }, Te = async () => {
1771
+ }, _e = async () => {
1368
1772
  if (console.log("stylizingLoading:", he.value), he.value) {
1369
- const Y = Me();
1370
- console.log("lastPreviewer:", Y), Y && (console.log("abortReader"), Y.abortReader());
1773
+ const te = Fe();
1774
+ console.log("lastPreviewer:", te), te && (console.log("abortReader"), te.abortReader());
1371
1775
  return;
1372
1776
  }
1373
- if (!E.value.trim()) {
1374
- console.log("no input, return"), Q.value.focus();
1777
+ if (!_.value.trim()) {
1778
+ console.log("no input, return"), V.value.focus();
1375
1779
  return;
1376
1780
  }
1377
- ee.value.push({
1781
+ G.value.push({
1378
1782
  type: "user",
1379
- content: E.value
1380
- }), ae.value = !0, re.value = !0, z("submit", E.value), xe();
1381
- const f = E.value;
1382
- E.value = "";
1383
- const h = ee.value.length;
1384
- le.value[h] && le.value[h].initializeStart(), he.value = !0, ee.value.push({
1783
+ content: _.value
1784
+ }), se.value = !0, ie.value = !0, j("submit", _.value), Re();
1785
+ const g = _.value;
1786
+ _.value = "";
1787
+ const h = G.value.length;
1788
+ le.value[h] && le.value[h].initializeStart(), he.value = !0, G.value.push({
1385
1789
  type: "ai"
1386
1790
  });
1387
- const { error: P, reader: B } = await Tt($.value, {
1388
- text: f,
1791
+ const { error: E, reader: B } = await Vt(xe.value, {
1792
+ text: g,
1389
1793
  token: o.token,
1390
1794
  identifier: o.identifier,
1391
1795
  baseUrl: o.baseUrl,
1392
- extraConfig: o.extraConfig
1796
+ // mock 模式(llmName=standard)经 extraConfig 读取 mockResponse,不侵入 API 签名
1797
+ extraConfig: o.mockResponse ? Object.assign({}, o.extraConfig, { mockResponse: o.mockResponse }) : o.extraConfig
1393
1798
  });
1394
- if (P) {
1395
- console.log(45455, P), Ee(h, P);
1799
+ if (E) {
1800
+ console.log(45455, E), Ne(h, E);
1396
1801
  return;
1397
1802
  }
1398
- B && (ee.value[h].reader = B);
1803
+ B && (G.value[h].reader = B);
1399
1804
  };
1400
- return (f, h) => {
1401
- const P = Ae("el-icon"), B = Ae("el-button"), Y = Ae("el-input");
1402
- return w(), me(ge, { name: "slide" }, {
1805
+ return (g, h) => {
1806
+ const E = Me("el-icon"), B = Me("el-button"), te = Me("el-input");
1807
+ return S(), ge(ye, { name: "slide" }, {
1403
1808
  default: J(() => [
1404
- r.modelValue ? (w(), C("div", {
1809
+ e.modelValue ? (S(), x("div", {
1405
1810
  key: 0,
1406
- class: ne(["ai-panel", { "drawer-mode": Re.value, "embedded-mode": r.embedded }])
1811
+ class: re(["ai-panel", { "drawer-mode": Ue.value, "embedded-mode": e.embedded }])
1407
1812
  }, [
1408
- u("div", Gt, [
1409
- u("div", Jt, [
1410
- u("div", Kt, q(r.title), 1),
1411
- u("div", Qt, [
1412
- r.embedded ? M("", !0) : (w(), me(P, {
1813
+ d("div", $n, [
1814
+ d("div", On, [
1815
+ d("div", Nn, W(e.title), 1),
1816
+ d("div", Fn, [
1817
+ e.embedded ? $("", !0) : (S(), ge(E, {
1413
1818
  key: 0,
1414
1819
  class: "action-icon",
1415
- onClick: ot
1820
+ onClick: mt
1416
1821
  }, {
1417
1822
  default: J(() => [
1418
- j(be, {
1823
+ D(Ce, {
1419
1824
  name: "/images/svg/drawer-layout.svg",
1420
1825
  color: "#999999"
1421
1826
  })
1422
1827
  ]),
1423
1828
  _: 1
1424
1829
  })),
1425
- j(P, {
1830
+ D(E, {
1426
1831
  class: "action-icon",
1427
- onClick: at
1832
+ onClick: pt
1428
1833
  }, {
1429
1834
  default: J(() => [
1430
- j(be, {
1835
+ D(Ce, {
1431
1836
  name: "/images/svg/close.svg",
1432
1837
  color: "#999999"
1433
1838
  })
@@ -1437,129 +1842,132 @@ const Gt = { class: "panel-header" }, Jt = { class: "header-actions" }, Kt = { c
1437
1842
  ])
1438
1843
  ])
1439
1844
  ]),
1440
- u("div", Zt, [
1441
- re.value ? (w(), C("div", {
1845
+ d("div", Bn, [
1846
+ ie.value ? (S(), x("div", {
1442
1847
  key: 1,
1443
1848
  class: "chat-messages",
1444
1849
  ref_key: "messageContainerRef",
1445
- ref: Ce
1850
+ ref: Te
1446
1851
  }, [
1447
- (w(!0), C(pe, null, Ne(ee.value, (D, ce) => (w(), C("div", {
1852
+ (S(!0), x(me, null, Be(G.value, (H, ce) => (S(), x("div", {
1448
1853
  key: ce,
1449
- class: ne(["message-item", D.type === "user" ? "user-message" : "ai-message"])
1854
+ class: re(["message-item", H.type === "user" ? "user-message" : "ai-message"])
1450
1855
  }, [
1451
- D.type === "ai" ? (w(), me(Ot, {
1856
+ H.type === "ai" ? (S(), ge(Rn, {
1452
1857
  key: 0,
1453
1858
  ref_for: !0,
1454
- ref: (te) => le.value[ce] = te,
1455
- reader: D.reader,
1456
- "onUpdate:reader": (te) => D.reader = te,
1859
+ ref: (Q) => le.value[ce] = Q,
1860
+ reader: H.reader,
1861
+ "onUpdate:reader": (Q) => H.reader = Q,
1457
1862
  model: o.llmName,
1458
- displayText: D.displayText,
1459
- scrollToBottomFn: xe,
1460
- messagePostRender: r.messagePostRender,
1461
- onFailed: (te) => Ee(ce, te),
1462
- onCompleted: (te) => nt(ce, te),
1463
- onUpdating: () => rt()
1464
- }, null, 8, ["reader", "onUpdate:reader", "model", "displayText", "messagePostRender", "onFailed", "onCompleted", "onUpdating"])) : (w(), C("div", rn, q(D.content), 1))
1863
+ displayText: H.displayText,
1864
+ scrollToBottomFn: Re,
1865
+ messagePostRender: e.messagePostRender,
1866
+ customUi: e.customUi,
1867
+ uiActionHandler: e.uiActionHandler,
1868
+ onFailed: (Q) => Ne(ce, Q),
1869
+ onCompleted: (Q) => ft(ce, Q),
1870
+ onUpdating: () => ht(),
1871
+ onUiAction: h[0] || (h[0] = (Q) => j("ui-action", Q))
1872
+ }, null, 8, ["reader", "onUpdate:reader", "model", "displayText", "messagePostRender", "customUi", "uiActionHandler", "onFailed", "onCompleted", "onUpdating"])) : (S(), x("div", Gn, W(H.content), 1))
1465
1873
  ], 2))), 128))
1466
- ], 512)) : (w(), C("div", Yt, [
1467
- h[2] || (h[2] = u("div", { class: "title" }, [
1468
- u("img", {
1469
- src: pt,
1874
+ ], 512)) : (S(), x("div", Vn, [
1875
+ h[3] || (h[3] = d("div", { class: "title" }, [
1876
+ d("img", {
1877
+ src: At,
1470
1878
  alt: "AI助手",
1471
1879
  class: "panel-icon"
1472
1880
  }),
1473
- u("h3", { class: "title-text" }, "Hi, 您好")
1881
+ d("h3", { class: "title-text" }, "Hi, 您好")
1474
1882
  ], -1)),
1475
- u("div", Xt, [
1476
- h[1] || (h[1] = fe(" 我是", -1)),
1477
- u("span", en, q(r.title), 1)
1883
+ d("div", Hn, [
1884
+ h[2] || (h[2] = pe(" 我是", -1)),
1885
+ d("span", Dn, W(e.title), 1)
1478
1886
  ]),
1479
- u("div", tn, [
1480
- (w(!0), C(pe, null, Ne(et.value, (D, ce) => (w(), C("div", {
1887
+ d("div", qn, [
1888
+ (S(!0), x(me, null, Be(ut.value, (H, ce) => (S(), x("div", {
1481
1889
  key: ce,
1482
1890
  class: "question-item",
1483
- onClick: (te) => st(D)
1891
+ onClick: (Q) => gt(H)
1484
1892
  }, [
1485
- u("span", null, q(D), 1),
1486
- j(P, null, {
1893
+ d("span", null, W(H), 1),
1894
+ D(E, null, {
1487
1895
  default: J(() => [
1488
- j(be, {
1896
+ D(Ce, {
1489
1897
  name: "/images/svg/arrow-right.svg",
1490
1898
  color: "#999999"
1491
1899
  })
1492
1900
  ]),
1493
1901
  _: 1
1494
1902
  })
1495
- ], 8, nn))), 128))
1903
+ ], 8, Wn))), 128))
1496
1904
  ])
1497
1905
  ]))
1498
1906
  ]),
1499
- u("div", an, [
1500
- ae.value ? (w(), C("img", on)) : M("", !0),
1501
- j(ge, { name: "fade" }, {
1907
+ d("div", Jn, [
1908
+ se.value ? (S(), x("img", Kn)) : $("", !0),
1909
+ D(ye, { name: "fade" }, {
1502
1910
  default: J(() => [
1503
- p.value || m.value ? (w(), C("div", sn, [
1504
- u("div", ln, [
1505
- h[3] || (h[3] = u("span", { class: "progress-icon" }, "⏳", -1)),
1506
- u("span", cn, q(i.value), 1),
1507
- l.value > 0 ? (w(), C("span", un, q(l.value) + "%", 1)) : M("", !0)
1911
+ m.value || v.value ? (S(), x("div", Xn, [
1912
+ d("div", Yn, [
1913
+ h[4] || (h[4] = d("span", { class: "progress-icon" }, "⏳", -1)),
1914
+ d("span", Zn, W(i.value), 1),
1915
+ l.value > 0 ? (S(), x("span", Qn, W(l.value) + "%", 1)) : $("", !0)
1508
1916
  ]),
1509
- l.value > 0 ? (w(), C("div", dn, [
1510
- u("div", {
1917
+ l.value > 0 ? (S(), x("div", er, [
1918
+ d("div", {
1511
1919
  class: "progress-bar",
1512
1920
  style: ue({ width: l.value + "%" })
1513
1921
  }, null, 4)
1514
- ])) : M("", !0)
1515
- ])) : M("", !0)
1922
+ ])) : $("", !0)
1923
+ ])) : $("", !0)
1516
1924
  ]),
1517
1925
  _: 1
1518
1926
  }),
1519
- j(ge, { name: "fade" }, {
1927
+ D(ye, { name: "fade" }, {
1520
1928
  default: J(() => [
1521
- d.value || c.value ? (w(), C("div", {
1929
+ f.value || u.value ? (S(), x("div", {
1522
1930
  key: 0,
1523
- class: ne(["voice-recording-panel", { "has-transcript": c.value }])
1931
+ class: re(["voice-recording-panel", { "has-transcript": u.value }])
1524
1932
  }, [
1525
- u("div", hn, [
1526
- u("div", fn, [
1527
- u("span", {
1528
- class: ne(["recording-pulse", { transcribing: c.value }])
1933
+ d("div", tr, [
1934
+ d("div", nr, [
1935
+ d("span", {
1936
+ class: re(["recording-pulse", { transcribing: u.value }])
1529
1937
  }, null, 2),
1530
- d.value ? (w(), C("span", pn, q(A(R.value)), 1)) : M("", !0),
1531
- u("span", mn, q(k.value), 1),
1532
- d.value ? (w(), C("div", gn, [
1533
- u("span", {
1938
+ f.value ? (S(), x("span", rr, W(R(b.value)), 1)) : $("", !0),
1939
+ d("span", sr, W(k.value), 1),
1940
+ f.value ? (S(), x("div", or, [
1941
+ d("span", {
1534
1942
  class: "wave",
1535
- style: ue({ height: Math.max(4, Math.min(22, y.value * 0.3)) + "px" })
1943
+ style: ue({ height: Math.max(4, Math.min(22, c.value * 0.3)) + "px" })
1536
1944
  }, null, 4),
1537
- u("span", {
1945
+ d("span", {
1538
1946
  class: "wave",
1539
- style: ue({ height: Math.max(4, Math.min(30, y.value * 0.5)) + "px" })
1947
+ style: ue({ height: Math.max(4, Math.min(30, c.value * 0.5)) + "px" })
1540
1948
  }, null, 4),
1541
- u("span", {
1949
+ d("span", {
1542
1950
  class: "wave",
1543
- style: ue({ height: Math.max(4, Math.min(18, y.value * 0.25)) + "px" })
1951
+ style: ue({ height: Math.max(4, Math.min(18, c.value * 0.25)) + "px" })
1544
1952
  }, null, 4)
1545
- ])) : M("", !0)
1953
+ ])) : $("", !0)
1546
1954
  ]),
1547
- u("div", vn, [
1548
- d.value ? (w(), C(pe, { key: 0 }, [
1549
- j(B, {
1955
+ d("div", ar, [
1956
+ f.value ? (S(), x(me, { key: 0 }, [
1957
+ D(B, {
1550
1958
  size: "small",
1551
1959
  circle: "",
1552
- onClick: se,
1960
+ onClick: oe,
1553
1961
  title: "取消录音",
1554
1962
  class: "voice-cancel-btn"
1555
1963
  }, {
1556
- default: J(() => [...h[4] || (h[4] = [
1557
- u("svg", {
1964
+ default: J(() => [...h[5] || (h[5] = [
1965
+ d("svg", {
1558
1966
  viewBox: "0 0 1024 1024",
1559
1967
  width: "12",
1560
1968
  height: "12"
1561
1969
  }, [
1562
- u("path", {
1970
+ d("path", {
1563
1971
  d: "M512 456.310154L94.247385 38.557538a39.384615 39.384615 0 0 0-55.689847 55.689847L456.310154 512 38.557538 929.752615a39.384615 39.384615 0 0 0 55.689847 55.689847L512 567.689846l417.752615 417.752616c15.163077 15.163077 40.526769 15.163077 55.689847 0s15.163077-40.526769 0-55.689847L567.689846 512l417.752616-417.752615a39.384615 39.384615 0 0 0-55.689847-55.689847L512 456.310154z",
1564
1972
  fill: "currentColor"
1565
1973
  })
@@ -1567,111 +1975,111 @@ const Gt = { class: "panel-header" }, Jt = { class: "header-actions" }, Kt = { c
1567
1975
  ])]),
1568
1976
  _: 1
1569
1977
  }),
1570
- j(B, {
1978
+ D(B, {
1571
1979
  type: "primary",
1572
1980
  size: "small",
1573
1981
  round: "",
1574
- onClick: X,
1982
+ onClick: Y,
1575
1983
  class: "voice-finish-btn"
1576
1984
  }, {
1577
- default: J(() => [...h[5] || (h[5] = [
1578
- fe(" 完成 ", -1)
1985
+ default: J(() => [...h[6] || (h[6] = [
1986
+ pe(" 完成 ", -1)
1579
1987
  ])]),
1580
1988
  _: 1
1581
1989
  })
1582
- ], 64)) : c.value ? (w(), me(B, {
1990
+ ], 64)) : u.value ? (S(), ge(B, {
1583
1991
  key: 1,
1584
1992
  size: "small",
1585
1993
  round: "",
1586
- onClick: ie,
1994
+ onClick: fe,
1587
1995
  class: "voice-cancel-transcribe-btn"
1588
1996
  }, {
1589
- default: J(() => [...h[6] || (h[6] = [
1590
- fe(" 取消识别 ", -1)
1997
+ default: J(() => [...h[7] || (h[7] = [
1998
+ pe(" 取消识别 ", -1)
1591
1999
  ])]),
1592
2000
  _: 1
1593
- })) : M("", !0)
2001
+ })) : $("", !0)
1594
2002
  ])
1595
2003
  ]),
1596
- c.value ? (w(), C("div", {
2004
+ u.value ? (S(), x("div", {
1597
2005
  key: 0,
1598
- class: ne(["live-transcript", { empty: !N.value }]),
1599
- title: N.value
2006
+ class: re(["live-transcript", { empty: !z.value }]),
2007
+ title: z.value
1600
2008
  }, [
1601
- N.value ? (w(), C(pe, { key: 0 }, [
1602
- fe(q(N.value), 1),
1603
- h[7] || (h[7] = u("span", { class: "caret" }, "|", -1))
1604
- ], 64)) : (w(), C(pe, { key: 1 }, [
1605
- fe("正在识别,文字将实时显示...")
2009
+ z.value ? (S(), x(me, { key: 0 }, [
2010
+ pe(W(z.value), 1),
2011
+ h[8] || (h[8] = d("span", { class: "caret" }, "|", -1))
2012
+ ], 64)) : (S(), x(me, { key: 1 }, [
2013
+ pe("正在识别,文字将实时显示...")
1606
2014
  ], 64))
1607
- ], 10, yn)) : M("", !0)
1608
- ], 2)) : M("", !0)
2015
+ ], 10, ir)) : $("", !0)
2016
+ ], 2)) : $("", !0)
1609
2017
  ]),
1610
2018
  _: 1
1611
2019
  }),
1612
- j(ge, { name: "fade" }, {
2020
+ D(ye, { name: "fade" }, {
1613
2021
  default: J(() => [
1614
- _.value && !d.value && !c.value ? (w(), C("div", wn, [
1615
- u("div", {
2022
+ A.value && !f.value && !u.value ? (S(), x("div", lr, [
2023
+ d("div", {
1616
2024
  class: "playback-main",
1617
- onClick: de,
1618
- title: S.value ? "点击暂停" : "点击播放录音"
2025
+ onClick: ke,
2026
+ title: p.value ? "点击暂停" : "点击播放录音"
1619
2027
  }, [
1620
- u("div", bn, [
1621
- S.value ? (w(), C("svg", Cn, [...h[9] || (h[9] = [
1622
- u("path", { d: "M6 19h4V5H6v14zm8-14v14h4V5h-4z" }, null, -1)
1623
- ])])) : (w(), C("svg", Sn, [...h[8] || (h[8] = [
1624
- u("path", { d: "M8 5v14l11-7z" }, null, -1)
2028
+ d("div", ur, [
2029
+ p.value ? (S(), x("svg", fr, [...h[10] || (h[10] = [
2030
+ d("path", { d: "M6 19h4V5H6v14zm8-14v14h4V5h-4z" }, null, -1)
2031
+ ])])) : (S(), x("svg", dr, [...h[9] || (h[9] = [
2032
+ d("path", { d: "M8 5v14l11-7z" }, null, -1)
1625
2033
  ])]))
1626
2034
  ]),
1627
- u("span", xn, q(S.value ? "正在播放录音..." : "点击试听本次录音"), 1),
1628
- W.value > 0 ? (w(), C("span", Rn, q(A(W.value)), 1)) : M("", !0),
1629
- S.value ? (w(), C("div", Tn, [...h[10] || (h[10] = [
1630
- u("span", { class: "wave-bar" }, null, -1),
1631
- u("span", { class: "wave-bar" }, null, -1),
1632
- u("span", { class: "wave-bar" }, null, -1),
1633
- u("span", { class: "wave-bar" }, null, -1)
1634
- ])])) : M("", !0)
1635
- ], 8, kn),
1636
- u("div", {
2035
+ d("span", hr, W(p.value ? "正在播放录音..." : "点击试听本次录音"), 1),
2036
+ F.value > 0 ? (S(), x("span", pr, W(R(F.value)), 1)) : $("", !0),
2037
+ p.value ? (S(), x("div", mr, [...h[11] || (h[11] = [
2038
+ d("span", { class: "wave-bar" }, null, -1),
2039
+ d("span", { class: "wave-bar" }, null, -1),
2040
+ d("span", { class: "wave-bar" }, null, -1),
2041
+ d("span", { class: "wave-bar" }, null, -1)
2042
+ ])])) : $("", !0)
2043
+ ], 8, cr),
2044
+ d("div", {
1637
2045
  class: "playback-close",
1638
- onClick: we,
2046
+ onClick: ae,
1639
2047
  title: "清除试听"
1640
- }, [...h[11] || (h[11] = [
1641
- u("svg", {
2048
+ }, [...h[12] || (h[12] = [
2049
+ d("svg", {
1642
2050
  viewBox: "0 0 1024 1024",
1643
2051
  width: "12",
1644
2052
  height: "12"
1645
2053
  }, [
1646
- u("path", {
2054
+ d("path", {
1647
2055
  d: "M512 456.310154L94.247385 38.557538a39.384615 39.384615 0 0 0-55.689847 55.689847L456.310154 512 38.557538 929.752615a39.384615 39.384615 0 0 0 55.689847 55.689847L512 567.689846l417.752615 417.752616c15.163077 15.163077 40.526769 15.163077 55.689847 0s15.163077-40.526769 0-55.689847L567.689846 512l417.752616-417.752615a39.384615 39.384615 0 0 0-55.689847-55.689847L512 456.310154z",
1648
2056
  fill: "currentColor"
1649
2057
  })
1650
2058
  ], -1)
1651
2059
  ])])
1652
- ])) : M("", !0)
2060
+ ])) : $("", !0)
1653
2061
  ]),
1654
2062
  _: 1
1655
2063
  }),
1656
- He(u("div", An, [
1657
- j(Y, {
1658
- modelValue: E.value,
1659
- "onUpdate:modelValue": h[0] || (h[0] = (D) => E.value = D),
2064
+ Ke(d("div", gr, [
2065
+ D(te, {
2066
+ modelValue: _.value,
2067
+ "onUpdate:modelValue": h[1] || (h[1] = (H) => _.value = H),
1660
2068
  ref_key: "refInputTextString",
1661
- ref: Q,
1662
- placeholder: b.value,
2069
+ ref: V,
2070
+ placeholder: C.value,
1663
2071
  autofocus: "",
1664
- onKeyup: dt(Te, ["enter"])
2072
+ onKeyup: kt(_e, ["enter"])
1665
2073
  }, {
1666
2074
  append: J(() => [
1667
- u("div", _n, [
1668
- r.enableVoiceUpload ? (w(), C("div", {
2075
+ d("div", yr, [
2076
+ e.enableVoiceUpload ? (S(), x("div", {
1669
2077
  key: 0,
1670
2078
  class: "voice-upload-btn",
1671
- onClick: H,
2079
+ onClick: ne,
1672
2080
  title: "上传音频/视频文件识别 (支持 .wav, .mp4, .mp3, .m4a)"
1673
- }, [...h[12] || (h[12] = [
1674
- u("svg", {
2081
+ }, [...h[13] || (h[13] = [
2082
+ d("svg", {
1675
2083
  viewBox: "0 0 24 24",
1676
2084
  width: "17",
1677
2085
  height: "17",
@@ -1681,32 +2089,32 @@ const Gt = { class: "panel-header" }, Jt = { class: "header-actions" }, Kt = { c
1681
2089
  "stroke-linecap": "round",
1682
2090
  "stroke-linejoin": "round"
1683
2091
  }, [
1684
- u("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
1685
- u("polyline", { points: "17 8 12 3 7 8" }),
1686
- u("line", {
2092
+ d("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
2093
+ d("polyline", { points: "17 8 12 3 7 8" }),
2094
+ d("line", {
1687
2095
  x1: "12",
1688
2096
  y1: "3",
1689
2097
  x2: "12",
1690
2098
  y2: "15"
1691
2099
  })
1692
2100
  ], -1)
1693
- ])])) : M("", !0),
1694
- r.enableVoiceUpload ? (w(), C("input", {
2101
+ ])])) : $("", !0),
2102
+ e.enableVoiceUpload ? (S(), x("input", {
1695
2103
  key: 1,
1696
2104
  type: "file",
1697
2105
  ref_key: "refAudioFileInput",
1698
- ref: G,
2106
+ ref: Z,
1699
2107
  accept: "audio/*,video/mp4,.wav,.mp4,.mp3,.m4a",
1700
2108
  style: { display: "none" },
1701
- onChange: oe
1702
- }, null, 544)) : M("", !0),
1703
- r.enableVoiceInput ? (w(), C("div", {
2109
+ onChange: q
2110
+ }, null, 544)) : $("", !0),
2111
+ e.enableVoiceInput ? (S(), x("div", {
1704
2112
  key: 2,
1705
- class: ne(["voice-mic-btn", { "loading-anim": p.value || m.value }]),
1706
- onClick: K,
2113
+ class: re(["voice-mic-btn", { "loading-anim": m.value || v.value }]),
2114
+ onClick: X,
1707
2115
  title: "语音输入"
1708
- }, [...h[13] || (h[13] = [
1709
- u("svg", {
2116
+ }, [...h[14] || (h[14] = [
2117
+ d("svg", {
1710
2118
  viewBox: "0 0 24 24",
1711
2119
  width: "18",
1712
2120
  height: "18",
@@ -1716,261 +2124,261 @@ const Gt = { class: "panel-header" }, Jt = { class: "header-actions" }, Kt = { c
1716
2124
  "stroke-linecap": "round",
1717
2125
  "stroke-linejoin": "round"
1718
2126
  }, [
1719
- u("path", {
2127
+ d("path", {
1720
2128
  d: "M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",
1721
2129
  fill: "currentColor",
1722
2130
  opacity: "0.2"
1723
2131
  }),
1724
- u("path", { d: "M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z" }),
1725
- u("path", { d: "M19 10v2a7 7 0 0 1-14 0v-2" }),
1726
- u("line", {
2132
+ d("path", { d: "M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z" }),
2133
+ d("path", { d: "M19 10v2a7 7 0 0 1-14 0v-2" }),
2134
+ d("line", {
1727
2135
  x1: "12",
1728
2136
  y1: "19",
1729
2137
  x2: "12",
1730
2138
  y2: "22"
1731
2139
  })
1732
2140
  ], -1)
1733
- ])], 2)) : M("", !0),
1734
- u("div", {
2141
+ ])], 2)) : $("", !0),
2142
+ d("div", {
1735
2143
  class: "send-icon-box",
1736
- onClick: Te
2144
+ onClick: _e
1737
2145
  }, [
1738
- u("img", {
1739
- src: tt.value,
2146
+ d("img", {
2147
+ src: dt.value,
1740
2148
  alt: "发送",
1741
2149
  class: "send-icon"
1742
- }, null, 8, Un)
2150
+ }, null, 8, vr)
1743
2151
  ])
1744
2152
  ])
1745
2153
  ]),
1746
2154
  _: 1
1747
2155
  }, 8, ["modelValue", "placeholder"])
1748
2156
  ], 512), [
1749
- [qe, !d.value && !c.value]
2157
+ [Xe, !f.value && !u.value]
1750
2158
  ])
1751
2159
  ])
1752
- ], 2)) : M("", !0)
2160
+ ], 2)) : $("", !0)
1753
2161
  ]),
1754
2162
  _: 1
1755
2163
  });
1756
2164
  };
1757
2165
  }
1758
2166
  };
1759
- var Ye = { exports: {} };
1760
- (function(r, e) {
1761
- (function(a, t) {
1762
- r.exports = t();
2167
+ var lt = { exports: {} };
2168
+ (function(e, t) {
2169
+ (function(s, r) {
2170
+ e.exports = r();
1763
2171
  })(window, function() {
1764
- return function(a) {
1765
- var t = {};
2172
+ return function(s) {
2173
+ var r = {};
1766
2174
  function o(n) {
1767
- if (t[n]) return t[n].exports;
1768
- var s = t[n] = { i: n, l: !1, exports: {} };
1769
- return a[n].call(s.exports, s, s.exports, o), s.l = !0, s.exports;
2175
+ if (r[n]) return r[n].exports;
2176
+ var a = r[n] = { i: n, l: !1, exports: {} };
2177
+ return s[n].call(a.exports, a, a.exports, o), a.l = !0, a.exports;
1770
2178
  }
1771
- return o.m = a, o.c = t, o.d = function(n, s, i) {
1772
- o.o(n, s) || Object.defineProperty(n, s, { enumerable: !0, get: i });
2179
+ return o.m = s, o.c = r, o.d = function(n, a, i) {
2180
+ o.o(n, a) || Object.defineProperty(n, a, { enumerable: !0, get: i });
1773
2181
  }, o.r = function(n) {
1774
2182
  typeof Symbol < "u" && Symbol.toStringTag && Object.defineProperty(n, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(n, "__esModule", { value: !0 });
1775
- }, o.t = function(n, s) {
1776
- if (1 & s && (n = o(n)), 8 & s || 4 & s && typeof n == "object" && n && n.__esModule) return n;
2183
+ }, o.t = function(n, a) {
2184
+ if (1 & a && (n = o(n)), 8 & a || 4 & a && typeof n == "object" && n && n.__esModule) return n;
1777
2185
  var i = /* @__PURE__ */ Object.create(null);
1778
- if (o.r(i), Object.defineProperty(i, "default", { enumerable: !0, value: n }), 2 & s && typeof n != "string") for (var l in n) o.d(i, l, (function(y) {
1779
- return n[y];
2186
+ if (o.r(i), Object.defineProperty(i, "default", { enumerable: !0, value: n }), 2 & a && typeof n != "string") for (var l in n) o.d(i, l, (function(c) {
2187
+ return n[c];
1780
2188
  }).bind(null, l));
1781
2189
  return i;
1782
2190
  }, o.n = function(n) {
1783
- var s = n && n.__esModule ? function() {
2191
+ var a = n && n.__esModule ? function() {
1784
2192
  return n.default;
1785
2193
  } : function() {
1786
2194
  return n;
1787
2195
  };
1788
- return o.d(s, "a", s), s;
1789
- }, o.o = function(n, s) {
1790
- return Object.prototype.hasOwnProperty.call(n, s);
2196
+ return o.d(a, "a", a), a;
2197
+ }, o.o = function(n, a) {
2198
+ return Object.prototype.hasOwnProperty.call(n, a);
1791
2199
  }, o.p = "", o(o.s = 0);
1792
- }([function(a, t, o) {
1793
- function n(v, p, m, d) {
1794
- m.push(v), d.push([].concat(p[v] || []));
2200
+ }([function(s, r, o) {
2201
+ function n(y, m, v, f) {
2202
+ v.push(y), f.push([].concat(m[y] || []));
1795
2203
  }
1796
- function s(v, p) {
1797
- if (!v) throw new Error("[getMaxDepsChain] dep 参数不能为空");
1798
- var m = [], d = [], c = [];
1799
- for (n(v, p, d, c); d.length; ) {
1800
- var k = c.pop();
2204
+ function a(y, m) {
2205
+ if (!y) throw new Error("[getMaxDepsChain] dep 参数不能为空");
2206
+ var v = [], f = [], u = [];
2207
+ for (n(y, m, f, u); f.length; ) {
2208
+ var k = u.pop();
1801
2209
  if (k && k.length) {
1802
- var b = k.shift();
1803
- if (c.push(k), ~d.indexOf(b)) throw new Error("[getMaxDepsChain][loop] 存在循环依赖,请检查依赖关系; nextName: " + b + ", mainStack: " + d);
1804
- n(b, p, d, c);
1805
- } else m.push([].concat(d)), d.pop();
2210
+ var C = k.shift();
2211
+ if (u.push(k), ~f.indexOf(C)) throw new Error("[getMaxDepsChain][loop] 存在循环依赖,请检查依赖关系; nextName: " + C + ", mainStack: " + f);
2212
+ n(C, m, f, u);
2213
+ } else v.push([].concat(f)), f.pop();
1806
2214
  }
1807
- return m.reduce(function(L, A) {
1808
- return A.length > L.length ? A : L;
2215
+ return v.reduce(function(L, R) {
2216
+ return R.length > L.length ? R : L;
1809
2217
  }, []);
1810
2218
  }
1811
- function i(v) {
1812
- if (!v) throw new Error("[depsParser] 入参不能为空");
1813
- var p = {};
1814
- v.forEach(function(d) {
1815
- p[d.name] = d.deps || [];
2219
+ function i(y) {
2220
+ if (!y) throw new Error("[depsParser] 入参不能为空");
2221
+ var m = {};
2222
+ y.forEach(function(f) {
2223
+ m[f.name] = f.deps || [];
1816
2224
  });
1817
- var m = [];
1818
- return v.forEach(function(d) {
1819
- var c = s(d.name, p).length - 1;
1820
- d.priority = c, m[c] = (m[c] || []).concat(d);
1821
- }), m;
2225
+ var v = [];
2226
+ return y.forEach(function(f) {
2227
+ var u = a(f.name, m).length - 1;
2228
+ f.priority = u, v[u] = (v[u] || []).concat(f);
2229
+ }), v;
1822
2230
  }
1823
- o.r(t), o.d(t, "loadScript", function() {
1824
- return _;
1825
- }), o.d(t, "loadScripts", function() {
1826
- return S;
1827
- }), o.d(t, "dynamicLoadScripts", function() {
1828
- return W;
1829
- }), o.d(t, "createScriptsLoadIterator", function() {
1830
- return T;
1831
- }), o.d(t, "loadScriptsQueue", function() {
1832
- return N;
1833
- }), o.d(t, "getMaxDepsChain", function() {
1834
- return s;
1835
- }), o.d(t, "depsParser", function() {
2231
+ o.r(r), o.d(r, "loadScript", function() {
2232
+ return A;
2233
+ }), o.d(r, "loadScripts", function() {
2234
+ return p;
2235
+ }), o.d(r, "dynamicLoadScripts", function() {
2236
+ return F;
2237
+ }), o.d(r, "createScriptsLoadIterator", function() {
2238
+ return U;
2239
+ }), o.d(r, "loadScriptsQueue", function() {
2240
+ return z;
2241
+ }), o.d(r, "getMaxDepsChain", function() {
2242
+ return a;
2243
+ }), o.d(r, "depsParser", function() {
1836
2244
  return i;
1837
2245
  });
1838
2246
  var l = function() {
1839
- return (l = Object.assign || function(v) {
1840
- for (var p, m = 1, d = arguments.length; m < d; m++) for (var c in p = arguments[m]) Object.prototype.hasOwnProperty.call(p, c) && (v[c] = p[c]);
1841
- return v;
2247
+ return (l = Object.assign || function(y) {
2248
+ for (var m, v = 1, f = arguments.length; v < f; v++) for (var u in m = arguments[v]) Object.prototype.hasOwnProperty.call(m, u) && (y[u] = m[u]);
2249
+ return y;
1842
2250
  }).apply(this, arguments);
1843
- }, y = function(v, p, m, d) {
1844
- return new (m || (m = Promise))(function(c, k) {
1845
- function b(I) {
2251
+ }, c = function(y, m, v, f) {
2252
+ return new (v || (v = Promise))(function(u, k) {
2253
+ function C(I) {
1846
2254
  try {
1847
- A(d.next(I));
1848
- } catch (g) {
1849
- k(g);
2255
+ R(f.next(I));
2256
+ } catch (w) {
2257
+ k(w);
1850
2258
  }
1851
2259
  }
1852
2260
  function L(I) {
1853
2261
  try {
1854
- A(d.throw(I));
1855
- } catch (g) {
1856
- k(g);
2262
+ R(f.throw(I));
2263
+ } catch (w) {
2264
+ k(w);
1857
2265
  }
1858
2266
  }
1859
- function A(I) {
1860
- var g;
1861
- I.done ? c(I.value) : (g = I.value, g instanceof m ? g : new m(function(V) {
1862
- V(g);
1863
- })).then(b, L);
2267
+ function R(I) {
2268
+ var w;
2269
+ I.done ? u(I.value) : (w = I.value, w instanceof v ? w : new v(function(O) {
2270
+ O(w);
2271
+ })).then(C, L);
1864
2272
  }
1865
- A((d = d.apply(v, [])).next());
2273
+ R((f = f.apply(y, [])).next());
1866
2274
  });
1867
- }, R = function(v, p) {
1868
- var m, d, c, k, b = { label: 0, sent: function() {
1869
- if (1 & c[0]) throw c[1];
1870
- return c[1];
2275
+ }, b = function(y, m) {
2276
+ var v, f, u, k, C = { label: 0, sent: function() {
2277
+ if (1 & u[0]) throw u[1];
2278
+ return u[1];
1871
2279
  }, trys: [], ops: [] };
1872
2280
  return k = { next: L(0), throw: L(1), return: L(2) }, typeof Symbol == "function" && (k[Symbol.iterator] = function() {
1873
2281
  return this;
1874
2282
  }), k;
1875
- function L(A) {
2283
+ function L(R) {
1876
2284
  return function(I) {
1877
- return function(g) {
1878
- if (m) throw new TypeError("Generator is already executing.");
1879
- for (; b; ) try {
1880
- if (m = 1, d && (c = 2 & g[0] ? d.return : g[0] ? d.throw || ((c = d.return) && c.call(d), 0) : d.next) && !(c = c.call(d, g[1])).done) return c;
1881
- switch (d = 0, c && (g = [2 & g[0], c.value]), g[0]) {
2285
+ return function(w) {
2286
+ if (v) throw new TypeError("Generator is already executing.");
2287
+ for (; C; ) try {
2288
+ if (v = 1, f && (u = 2 & w[0] ? f.return : w[0] ? f.throw || ((u = f.return) && u.call(f), 0) : f.next) && !(u = u.call(f, w[1])).done) return u;
2289
+ switch (f = 0, u && (w = [2 & w[0], u.value]), w[0]) {
1882
2290
  case 0:
1883
2291
  case 1:
1884
- c = g;
2292
+ u = w;
1885
2293
  break;
1886
2294
  case 4:
1887
- return b.label++, { value: g[1], done: !1 };
2295
+ return C.label++, { value: w[1], done: !1 };
1888
2296
  case 5:
1889
- b.label++, d = g[1], g = [0];
2297
+ C.label++, f = w[1], w = [0];
1890
2298
  continue;
1891
2299
  case 7:
1892
- g = b.ops.pop(), b.trys.pop();
2300
+ w = C.ops.pop(), C.trys.pop();
1893
2301
  continue;
1894
2302
  default:
1895
- if (c = b.trys, !((c = c.length > 0 && c[c.length - 1]) || g[0] !== 6 && g[0] !== 2)) {
1896
- b = 0;
2303
+ if (u = C.trys, !((u = u.length > 0 && u[u.length - 1]) || w[0] !== 6 && w[0] !== 2)) {
2304
+ C = 0;
1897
2305
  continue;
1898
2306
  }
1899
- if (g[0] === 3 && (!c || g[1] > c[0] && g[1] < c[3])) {
1900
- b.label = g[1];
2307
+ if (w[0] === 3 && (!u || w[1] > u[0] && w[1] < u[3])) {
2308
+ C.label = w[1];
1901
2309
  break;
1902
2310
  }
1903
- if (g[0] === 6 && b.label < c[1]) {
1904
- b.label = c[1], c = g;
2311
+ if (w[0] === 6 && C.label < u[1]) {
2312
+ C.label = u[1], u = w;
1905
2313
  break;
1906
2314
  }
1907
- if (c && b.label < c[2]) {
1908
- b.label = c[2], b.ops.push(g);
2315
+ if (u && C.label < u[2]) {
2316
+ C.label = u[2], C.ops.push(w);
1909
2317
  break;
1910
2318
  }
1911
- c[2] && b.ops.pop(), b.trys.pop();
2319
+ u[2] && C.ops.pop(), C.trys.pop();
1912
2320
  continue;
1913
2321
  }
1914
- g = p.call(v, b);
1915
- } catch (V) {
1916
- g = [6, V], d = 0;
2322
+ w = m.call(y, C);
2323
+ } catch (O) {
2324
+ w = [6, O], f = 0;
1917
2325
  } finally {
1918
- m = c = 0;
2326
+ v = u = 0;
1919
2327
  }
1920
- if (5 & g[0]) throw g[1];
1921
- return { value: g[0] ? g[1] : void 0, done: !0 };
1922
- }([A, I]);
2328
+ if (5 & w[0]) throw w[1];
2329
+ return { value: w[0] ? w[1] : void 0, done: !0 };
2330
+ }([R, I]);
1923
2331
  };
1924
2332
  }
1925
- }, F = function(v) {
2333
+ }, P = function(y) {
1926
2334
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
1927
- var p, m = v[Symbol.asyncIterator];
1928
- return m ? m.call(v) : (v = typeof __values == "function" ? __values(v) : v[Symbol.iterator](), p = {}, d("next"), d("throw"), d("return"), p[Symbol.asyncIterator] = function() {
2335
+ var m, v = y[Symbol.asyncIterator];
2336
+ return v ? v.call(y) : (y = typeof __values == "function" ? __values(y) : y[Symbol.iterator](), m = {}, f("next"), f("throw"), f("return"), m[Symbol.asyncIterator] = function() {
1929
2337
  return this;
1930
- }, p);
1931
- function d(c) {
1932
- p[c] = v[c] && function(k) {
1933
- return new Promise(function(b, L) {
1934
- (function(A, I, g, V) {
1935
- Promise.resolve(V).then(function(K) {
1936
- A({ value: K, done: g });
2338
+ }, m);
2339
+ function f(u) {
2340
+ m[u] = y[u] && function(k) {
2341
+ return new Promise(function(C, L) {
2342
+ (function(R, I, w, O) {
2343
+ Promise.resolve(O).then(function(X) {
2344
+ R({ value: X, done: w });
1937
2345
  }, I);
1938
- })(b, L, (k = v[c](k)).done, k.value);
2346
+ })(C, L, (k = y[u](k)).done, k.value);
1939
2347
  });
1940
2348
  };
1941
2349
  }
1942
2350
  };
1943
- function _(v, p) {
1944
- return p === void 0 && (p = !1), new Promise(function(m, d) {
1945
- var c = p ? document.head : document.body, k = document.createElement("script");
1946
- k.type = "text/javascript", k.src = v, k.crossOrigin = "anonymous", k.onreadystatechange = m, k.onload = m, k.onerror = d, c.appendChild(k);
2351
+ function A(y, m) {
2352
+ return m === void 0 && (m = !1), new Promise(function(v, f) {
2353
+ var u = m ? document.head : document.body, k = document.createElement("script");
2354
+ k.type = "text/javascript", k.src = y, k.crossOrigin = "anonymous", k.onreadystatechange = v, k.onload = v, k.onerror = f, u.appendChild(k);
1947
2355
  });
1948
2356
  }
1949
- var S = function(v, p) {
1950
- return p === void 0 && (p = {}), y(void 0, void 0, void 0, function() {
1951
- var m, d, c, k, b;
1952
- return R(this, function(L) {
2357
+ var p = function(y, m) {
2358
+ return m === void 0 && (m = {}), c(void 0, void 0, void 0, function() {
2359
+ var v, f, u, k, C;
2360
+ return b(this, function(L) {
1953
2361
  switch (L.label) {
1954
2362
  case 0:
1955
- return m = p.baseUrl, d = m === void 0 ? "" : m, c = p.lastLoadResult, k = p.inHead, b = k !== void 0 && k, [4, Promise.all(v.map(function(A) {
1956
- return y(void 0, void 0, void 0, function() {
1957
- var I, g, V, K, X, G, H, oe;
1958
- return R(this, function(se) {
1959
- switch (se.label) {
2363
+ return v = m.baseUrl, f = v === void 0 ? "" : v, u = m.lastLoadResult, k = m.inHead, C = k !== void 0 && k, [4, Promise.all(y.map(function(R) {
2364
+ return c(void 0, void 0, void 0, function() {
2365
+ var I, w, O, X, Y, Z, ne, q;
2366
+ return b(this, function(oe) {
2367
+ switch (oe.label) {
1960
2368
  case 0:
1961
- return I = A.name, g = A.path, V = A.deps, (H = {})[I] = !0, K = H, (oe = {})[I] = !1, X = oe, window[I] ? [2, K] : [3, 1];
2369
+ return I = R.name, w = R.path, O = R.deps, (ne = {})[I] = !0, X = ne, (q = {})[I] = !1, Y = q, window[I] ? [2, X] : [3, 1];
1962
2370
  case 1:
1963
- return G = !0, V && c && [].concat(V).forEach(function(ie) {
1964
- c[ie] !== !1 && (G = !0);
1965
- }), G ? [4, _(g.indexOf("http") === 0 || g.indexOf("//:") === 0 ? g : d + g, b).then(function() {
1966
- return K;
1967
- }).catch(function() {
2371
+ return Z = !0, O && u && [].concat(O).forEach(function(fe) {
2372
+ u[fe] !== !1 && (Z = !0);
2373
+ }), Z ? [4, A(w.indexOf("http") === 0 || w.indexOf("//:") === 0 ? w : f + w, C).then(function() {
1968
2374
  return X;
2375
+ }).catch(function() {
2376
+ return Y;
1969
2377
  })] : [3, 3];
1970
2378
  case 2:
1971
- return [2, se.sent()];
2379
+ return [2, oe.sent()];
1972
2380
  case 3:
1973
- return [2, X];
2381
+ return [2, Y];
1974
2382
  }
1975
2383
  });
1976
2384
  });
@@ -1980,65 +2388,65 @@ var Ye = { exports: {} };
1980
2388
  }
1981
2389
  });
1982
2390
  });
1983
- }, W = function(v, p) {
1984
- return p === void 0 && (p = {}), function() {
1985
- var m = [].concat(i(v));
2391
+ }, F = function(y, m) {
2392
+ return m === void 0 && (m = {}), function() {
2393
+ var v = [].concat(i(y));
1986
2394
  return { next: function() {
1987
- if (m.length) {
1988
- var d = m.shift();
1989
- return S(d, p).then(function(c) {
1990
- return { value: c, done: !1 };
2395
+ if (v.length) {
2396
+ var f = v.shift();
2397
+ return p(f, m).then(function(u) {
2398
+ return { value: u, done: !1 };
1991
2399
  });
1992
2400
  }
1993
2401
  return Promise.resolve({ done: !0 });
1994
2402
  } };
1995
2403
  };
1996
- }, T = function(v, p) {
1997
- var m;
1998
- return p === void 0 && (p = {}), (m = {})[Symbol.asyncIterator] = W(v, p), m;
1999
- }, N = function(v, p) {
2000
- return p === void 0 && (p = {}), y(void 0, void 0, void 0, function() {
2001
- var m, d, c, k, b, L;
2002
- return R(this, function(A) {
2003
- switch (A.label) {
2404
+ }, U = function(y, m) {
2405
+ var v;
2406
+ return m === void 0 && (m = {}), (v = {})[Symbol.asyncIterator] = F(y, m), v;
2407
+ }, z = function(y, m) {
2408
+ return m === void 0 && (m = {}), c(void 0, void 0, void 0, function() {
2409
+ var v, f, u, k, C, L;
2410
+ return b(this, function(R) {
2411
+ switch (R.label) {
2004
2412
  case 0:
2005
- A.trys.push([0, 5, 6, 11]), m = F(T(v, p)), A.label = 1;
2413
+ R.trys.push([0, 5, 6, 11]), v = P(U(y, m)), R.label = 1;
2006
2414
  case 1:
2007
- return [4, m.next()];
2415
+ return [4, v.next()];
2008
2416
  case 2:
2009
- if ((d = A.sent()).done) return [3, 4];
2010
- c = d.value, p.lastLoadResult = p.lastLoadResult || {}, console.log("current load: ", c), c.forEach(function(I) {
2011
- p.lastLoadResult = l(l({}, p.lastLoadResult), I);
2012
- }), A.label = 3;
2417
+ if ((f = R.sent()).done) return [3, 4];
2418
+ u = f.value, m.lastLoadResult = m.lastLoadResult || {}, console.log("current load: ", u), u.forEach(function(I) {
2419
+ m.lastLoadResult = l(l({}, m.lastLoadResult), I);
2420
+ }), R.label = 3;
2013
2421
  case 3:
2014
2422
  return [3, 1];
2015
2423
  case 4:
2016
2424
  return [3, 11];
2017
2425
  case 5:
2018
- return k = A.sent(), b = { error: k }, [3, 11];
2426
+ return k = R.sent(), C = { error: k }, [3, 11];
2019
2427
  case 6:
2020
- return A.trys.push([6, , 9, 10]), d && !d.done && (L = m.return) ? [4, L.call(m)] : [3, 8];
2428
+ return R.trys.push([6, , 9, 10]), f && !f.done && (L = v.return) ? [4, L.call(v)] : [3, 8];
2021
2429
  case 7:
2022
- A.sent(), A.label = 8;
2430
+ R.sent(), R.label = 8;
2023
2431
  case 8:
2024
2432
  return [3, 10];
2025
2433
  case 9:
2026
- if (b) throw b.error;
2434
+ if (C) throw C.error;
2027
2435
  return [7];
2028
2436
  case 10:
2029
2437
  return [7];
2030
2438
  case 11:
2031
- return [2, p.lastLoadResult];
2439
+ return [2, m.lastLoadResult];
2032
2440
  }
2033
2441
  });
2034
2442
  });
2035
2443
  };
2036
2444
  }]);
2037
2445
  });
2038
- })(Ye);
2039
- var Pn = Ye.exports;
2040
- function Xe() {
2041
- const r = [
2446
+ })(lt);
2447
+ var wr = lt.exports;
2448
+ function ct() {
2449
+ const e = [
2042
2450
  {
2043
2451
  name: "markdownit",
2044
2452
  path: "markdown-it.min.js"
@@ -2048,26 +2456,26 @@ function Xe() {
2048
2456
  path: "highlight.11.11.1.min.js"
2049
2457
  }
2050
2458
  ];
2051
- let e = {};
2052
- Pn.loadScriptsQueue(r, {
2459
+ let t = {};
2460
+ wr.loadScriptsQueue(e, {
2053
2461
  baseUrl: "/scripts/ai/",
2054
- lastLoadResult: e,
2462
+ lastLoadResult: t,
2055
2463
  inHead: !1
2056
- }).then((a) => {
2057
- if (console.log("load ai deps: ", a), window.markdownit) {
2058
- const t = window.markdownit();
2059
- console.log("markdownit: ", t), At();
2464
+ }).then((s) => {
2465
+ if (console.log("load ai deps: ", s), window.markdownit) {
2466
+ const r = window.markdownit();
2467
+ console.log("markdownit: ", r), yn();
2060
2468
  }
2061
2469
  });
2062
2470
  }
2063
- const In = {
2471
+ const br = {
2064
2472
  key: 0,
2065
2473
  class: "ai-assistant"
2066
- }, Ln = {
2474
+ }, kr = {
2067
2475
  name: "AiChat"
2068
2476
  //这个⾮常重要,就是未来你放到其他项⽬中,组件标签的名字,⽐如:<sz-workflow></sz-workflow>
2069
- }, En = /* @__PURE__ */ Ge({
2070
- ...Ln,
2477
+ }, Sr = /* @__PURE__ */ Ze({
2478
+ ...kr,
2071
2479
  props: {
2072
2480
  token: {
2073
2481
  type: String,
@@ -2139,65 +2547,93 @@ const In = {
2139
2547
  enableVoiceUpload: {
2140
2548
  type: Boolean,
2141
2549
  default: !1
2550
+ },
2551
+ /**
2552
+ * szjy-ui fence 自定义 UI 配置,透传给动作处理器。
2553
+ * 例如:{ postMessage: { target: () => sandboxIframe.contentWindow, targetOrigin: 'http://...' } }
2554
+ */
2555
+ customUi: {
2556
+ type: Object,
2557
+ default: null
2558
+ },
2559
+ /**
2560
+ * szjy-ui 动作拦截钩子:(action, params, triggerEl) => false 可阻止内置动作执行
2561
+ */
2562
+ uiActionHandler: {
2563
+ type: Function,
2564
+ default: null
2565
+ },
2566
+ /**
2567
+ * Mock 响应内容:llmName 为 standard(模拟数据模型)时不请求真实后端,
2568
+ * 将该内容流式输出,用于联调 szjy-ui fence / postMessage 动作
2569
+ */
2570
+ mockResponse: {
2571
+ type: String,
2572
+ default: ""
2142
2573
  }
2143
2574
  },
2144
- setup(r) {
2145
- const e = x(!1), a = x(!1), t = () => {
2146
- e.value = !e.value;
2147
- }, o = () => {
2148
- a.value = !0, e.value = !1;
2149
- }, n = (s) => {
2150
- console.log("用户输入:", s);
2575
+ emits: ["ui-action"],
2576
+ setup(e, { emit: t }) {
2577
+ const s = T(!1), r = T(!1), o = t, n = () => {
2578
+ s.value = !s.value;
2579
+ }, a = () => {
2580
+ r.value = !0, s.value = !1;
2581
+ }, i = (l) => {
2582
+ console.log("用户输入:", l);
2151
2583
  };
2152
- return Xe(), (s, i) => a.value ? M("", !0) : (w(), C("div", In, [
2153
- j(Ze, {
2154
- modelValue: e.value,
2155
- "onUpdate:modelValue": i[0] || (i[0] = (l) => e.value = l),
2156
- onSubmit: n,
2157
- token: r.token,
2158
- identifier: r.identifier,
2159
- baseUrl: r.baseUrl,
2160
- title: r.title,
2161
- llmName: r.llmName,
2162
- messagePostRender: r.messagePostRender,
2163
- extraConfig: r.extraConfig,
2164
- soundBaseUrl: r.soundBaseUrl,
2165
- workerUrl: r.workerUrl,
2166
- enableVoiceInput: r.enableVoiceInput,
2167
- enableVoiceUpload: r.enableVoiceUpload
2168
- }, null, 8, ["modelValue", "token", "identifier", "baseUrl", "title", "llmName", "messagePostRender", "extraConfig", "soundBaseUrl", "workerUrl", "enableVoiceInput", "enableVoiceUpload"]),
2169
- u("div", {
2584
+ return ct(), (l, c) => r.value ? $("", !0) : (S(), x("div", br, [
2585
+ D(it, {
2586
+ modelValue: s.value,
2587
+ "onUpdate:modelValue": c[0] || (c[0] = (b) => s.value = b),
2588
+ onSubmit: i,
2589
+ onUiAction: c[1] || (c[1] = (b) => o("ui-action", b)),
2590
+ token: e.token,
2591
+ identifier: e.identifier,
2592
+ baseUrl: e.baseUrl,
2593
+ title: e.title,
2594
+ llmName: e.llmName,
2595
+ messagePostRender: e.messagePostRender,
2596
+ extraConfig: e.extraConfig,
2597
+ customUi: e.customUi,
2598
+ uiActionHandler: e.uiActionHandler,
2599
+ mockResponse: e.mockResponse,
2600
+ soundBaseUrl: e.soundBaseUrl,
2601
+ workerUrl: e.workerUrl,
2602
+ enableVoiceInput: e.enableVoiceInput,
2603
+ enableVoiceUpload: e.enableVoiceUpload
2604
+ }, null, 8, ["modelValue", "token", "identifier", "baseUrl", "title", "llmName", "messagePostRender", "extraConfig", "customUi", "uiActionHandler", "mockResponse", "soundBaseUrl", "workerUrl", "enableVoiceInput", "enableVoiceUpload"]),
2605
+ d("div", {
2170
2606
  class: "ai-icon",
2171
- onClick: t
2607
+ onClick: n
2172
2608
  }, [
2173
- u("div", {
2609
+ d("div", {
2174
2610
  class: "close-icon",
2175
- onClick: ht(o, ["stop"])
2176
- }, [...i[1] || (i[1] = [
2177
- u("svg", {
2611
+ onClick: St(a, ["stop"])
2612
+ }, [...c[2] || (c[2] = [
2613
+ d("svg", {
2178
2614
  viewBox: "0 0 1024 1024",
2179
2615
  width: "8",
2180
2616
  height: "8"
2181
2617
  }, [
2182
- u("path", {
2618
+ d("path", {
2183
2619
  d: "M512 456.310154L94.247385 38.557538a39.384615 39.384615 0 0 0-55.689847 55.689847L456.310154 512 38.557538 929.752615a39.384615 39.384615 0 0 0 55.689847 55.689847L512 567.689846l417.752615 417.752616c15.163077 15.163077 40.526769 15.163077 55.689847 0s15.163077-40.526769 0-55.689847L567.689846 512l417.752616-417.752615a39.384615 39.384615 0 0 0-55.689847-55.689847L512 456.310154z",
2184
2620
  fill: "currentColor"
2185
2621
  })
2186
2622
  ], -1)
2187
2623
  ])]),
2188
- i[2] || (i[2] = u("img", {
2189
- src: ft,
2624
+ c[3] || (c[3] = d("img", {
2625
+ src: Ct,
2190
2626
  alt: "AI助手"
2191
2627
  }, null, -1)),
2192
- i[3] || (i[3] = u("span", { class: "ai-icon-text" }, "AI助手", -1))
2628
+ c[4] || (c[4] = d("span", { class: "ai-icon-text" }, "AI助手", -1))
2193
2629
  ])
2194
2630
  ]));
2195
2631
  }
2196
- }), Mn = { class: "ai-chat-plain" }, Fn = {
2632
+ }), Cr = { class: "ai-chat-plain" }, Ar = {
2197
2633
  name: "AiChatPlain"
2198
2634
  // 注册后的组件标签名:<sz-ai-chat-plain>
2199
- }, Nn = /* @__PURE__ */ Ge({
2200
- ...Fn,
2635
+ }, xr = /* @__PURE__ */ Ze({
2636
+ ...Ar,
2201
2637
  props: {
2202
2638
  token: {
2203
2639
  type: String,
@@ -2269,244 +2705,286 @@ const In = {
2269
2705
  enableVoiceUpload: {
2270
2706
  type: Boolean,
2271
2707
  default: !1
2708
+ },
2709
+ /**
2710
+ * szjy-ui fence 自定义 UI 配置,透传给动作处理器。
2711
+ * 例如:{ postMessage: { target: () => sandboxIframe.contentWindow, targetOrigin: 'http://...' } }
2712
+ */
2713
+ customUi: {
2714
+ type: Object,
2715
+ default: null
2716
+ },
2717
+ /**
2718
+ * szjy-ui 动作拦截钩子:(action, params, triggerEl) => false 可阻止内置动作执行
2719
+ */
2720
+ uiActionHandler: {
2721
+ type: Function,
2722
+ default: null
2723
+ },
2724
+ /**
2725
+ * Mock 响应内容:llmName 为 standard(模拟数据模型)时不请求真实后端,
2726
+ * 将该内容流式输出,用于联调 szjy-ui fence / postMessage 动作
2727
+ */
2728
+ mockResponse: {
2729
+ type: String,
2730
+ default: ""
2272
2731
  }
2273
2732
  },
2274
- emits: ["submit"],
2275
- setup(r, { emit: e }) {
2276
- const a = e;
2277
- return Xe(), (t, o) => (w(), C("div", Mn, [
2278
- j(Ze, {
2733
+ emits: ["submit", "ui-action"],
2734
+ setup(e, { emit: t }) {
2735
+ const s = t;
2736
+ return ct(), (r, o) => (S(), x("div", Cr, [
2737
+ D(it, {
2279
2738
  "model-value": !0,
2280
- token: r.token,
2281
- identifier: r.identifier,
2282
- baseUrl: r.baseUrl,
2283
- title: r.title,
2284
- llmName: r.llmName,
2285
- messagePostRender: r.messagePostRender,
2286
- extraConfig: r.extraConfig,
2287
- soundBaseUrl: r.soundBaseUrl,
2288
- workerUrl: r.workerUrl,
2289
- enableVoiceInput: r.enableVoiceInput,
2290
- enableVoiceUpload: r.enableVoiceUpload,
2739
+ token: e.token,
2740
+ identifier: e.identifier,
2741
+ baseUrl: e.baseUrl,
2742
+ title: e.title,
2743
+ llmName: e.llmName,
2744
+ messagePostRender: e.messagePostRender,
2745
+ extraConfig: e.extraConfig,
2746
+ customUi: e.customUi,
2747
+ uiActionHandler: e.uiActionHandler,
2748
+ mockResponse: e.mockResponse,
2749
+ soundBaseUrl: e.soundBaseUrl,
2750
+ workerUrl: e.workerUrl,
2751
+ enableVoiceInput: e.enableVoiceInput,
2752
+ enableVoiceUpload: e.enableVoiceUpload,
2291
2753
  embedded: !0,
2292
- onSubmit: o[0] || (o[0] = (n) => a("submit", n))
2293
- }, null, 8, ["token", "identifier", "baseUrl", "title", "llmName", "messagePostRender", "extraConfig", "soundBaseUrl", "workerUrl", "enableVoiceInput", "enableVoiceUpload"])
2754
+ onSubmit: o[0] || (o[0] = (n) => s("submit", n)),
2755
+ onUiAction: o[1] || (o[1] = (n) => s("ui-action", n))
2756
+ }, null, 8, ["token", "identifier", "baseUrl", "title", "llmName", "messagePostRender", "extraConfig", "customUi", "uiActionHandler", "mockResponse", "soundBaseUrl", "workerUrl", "enableVoiceInput", "enableVoiceUpload"])
2294
2757
  ]));
2295
2758
  }
2296
- }), De = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2759
+ }), Ge = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2297
2760
  __proto__: null,
2298
- SzAiChat: En,
2299
- SzAiChatPlain: Nn
2300
- }, Symbol.toStringTag, { value: "Module" })), Ie = function(r) {
2301
- if (!Ie.installed) {
2302
- Ie.installed = !0;
2303
- for (let e in De) {
2304
- const a = Reflect.get(De, e);
2305
- r.component(a.name, a);
2761
+ SzAiChat: Sr,
2762
+ SzAiChatPlain: xr
2763
+ }, Symbol.toStringTag, { value: "Module" })), ze = function(e) {
2764
+ if (!ze.installed) {
2765
+ ze.installed = !0;
2766
+ for (let t in Ge) {
2767
+ const s = Reflect.get(Ge, t);
2768
+ e.component(s.name, s);
2306
2769
  }
2307
2770
  }
2308
- }, On = (r, e) => {
2309
- const a = e ? `?${new URLSearchParams(e).toString()}` : "";
2310
- console.log(`点击了路由链接: ${r}${a}`);
2311
- }, Vn = (r) => {
2312
- const e = r.indexOf("?");
2313
- if (e === -1)
2314
- return { routeName: r };
2315
- const a = r.substring(0, e), t = r.substring(e + 1), o = {};
2316
- return new URLSearchParams(t).forEach((s, i) => {
2317
- o[i] = s;
2318
- }), { routeName: a, queryParams: Object.keys(o).length > 0 ? o : void 0 };
2319
- }, $n = {
2771
+ }, Tr = (e, t) => {
2772
+ const s = t ? `?${new URLSearchParams(t).toString()}` : "";
2773
+ console.log(`点击了路由链接: ${e}${s}`);
2774
+ }, Rr = (e) => {
2775
+ const t = e.indexOf("?");
2776
+ if (t === -1)
2777
+ return { routeName: e };
2778
+ const s = e.substring(0, t), r = e.substring(t + 1), o = {};
2779
+ return new URLSearchParams(r).forEach((a, i) => {
2780
+ o[i] = a;
2781
+ }), { routeName: s, queryParams: Object.keys(o).length > 0 ? o : void 0 };
2782
+ }, Ur = {
2320
2783
  color: "#536fec",
2321
2784
  fontWeight: "bold",
2322
2785
  textDecoration: "underline",
2323
2786
  cursor: "pointer",
2324
2787
  padding: "0 3px"
2325
- }, Bn = (r) => {
2326
- const e = /#router:([^#]+)#/g, a = [];
2327
- let t = 0, o;
2328
- for (; (o = e.exec(r)) !== null; ) {
2329
- o.index > t && a.push({ text: r.substring(t, o.index) });
2330
- const n = o[1], { routeName: s, queryParams: i } = Vn(n);
2331
- a.push({ text: s, routeName: s, queryParams: i }), t = e.lastIndex;
2788
+ }, _r = (e) => {
2789
+ const t = /#router:([^#]+)#/g, s = [];
2790
+ let r = 0, o;
2791
+ for (; (o = t.exec(e)) !== null; ) {
2792
+ o.index > r && s.push({ text: e.substring(r, o.index) });
2793
+ const n = o[1], { routeName: a, queryParams: i } = Rr(n);
2794
+ s.push({ text: a, routeName: a, queryParams: i }), r = t.lastIndex;
2332
2795
  }
2333
- return t < r.length && a.push({ text: r.substring(t) }), a;
2334
- }, zn = (r, e, a = {}, t) => {
2335
- const { onRouteClick: o = On, linkStyle: n = {} } = a, s = document.createElement("a");
2336
- s.href = "#", s.textContent = r;
2337
- const i = { ...$n, ...n };
2338
- return Object.assign(s.style, i), s.addEventListener("click", (l) => {
2339
- l.preventDefault(), o(e, t);
2340
- }), s;
2341
- }, Dn = (r) => {
2342
- const e = /#router:([^#]+)#/g, a = [], t = document.createTreeWalker(
2343
- r,
2796
+ return r < e.length && s.push({ text: e.substring(r) }), s;
2797
+ }, Pr = (e, t, s = {}, r) => {
2798
+ const { onRouteClick: o = Tr, linkStyle: n = {} } = s, a = document.createElement("a");
2799
+ a.href = "#", a.textContent = e;
2800
+ const i = { ...Ur, ...n };
2801
+ return Object.assign(a.style, i), a.addEventListener("click", (l) => {
2802
+ l.preventDefault(), o(t, r);
2803
+ }), a;
2804
+ }, Mr = (e) => {
2805
+ const t = /#router:([^#]+)#/g, s = [], r = document.createTreeWalker(
2806
+ e,
2344
2807
  NodeFilter.SHOW_TEXT,
2345
2808
  null
2346
2809
  );
2347
- let o = t.nextNode();
2810
+ let o = r.nextNode();
2348
2811
  for (; o; ) {
2349
- const n = o, s = n.textContent || "";
2350
- if (e.test(s)) {
2351
- e.lastIndex = 0;
2352
- const i = Bn(s);
2353
- i.length > 0 && a.push({ node: n, replacements: i });
2812
+ const n = o, a = n.textContent || "";
2813
+ if (t.test(a)) {
2814
+ t.lastIndex = 0;
2815
+ const i = _r(a);
2816
+ i.length > 0 && s.push({ node: n, replacements: i });
2354
2817
  }
2355
- o = t.nextNode();
2818
+ o = r.nextNode();
2356
2819
  }
2357
- return a;
2358
- }, Gn = (r, e, a = {}) => {
2359
- const t = Dn(r);
2360
- t.forEach(({ node: o, replacements: n }) => {
2820
+ return s;
2821
+ }, Lr = (e, t, s = {}) => {
2822
+ const r = Mr(e);
2823
+ r.forEach(({ node: o, replacements: n }) => {
2361
2824
  var i;
2362
- const s = document.createDocumentFragment();
2363
- n.forEach(({ text: l, routeName: y, queryParams: R }) => {
2364
- if (y) {
2365
- const F = zn(l, y, a, R);
2366
- s.appendChild(F);
2825
+ const a = document.createDocumentFragment();
2826
+ n.forEach(({ text: l, routeName: c, queryParams: b }) => {
2827
+ if (c) {
2828
+ const P = Pr(l, c, s, b);
2829
+ a.appendChild(P);
2367
2830
  } else
2368
- s.appendChild(document.createTextNode(l));
2369
- }), (i = o.parentNode) == null || i.replaceChild(s, o);
2370
- }), a != null && a.nodeCallback && t.forEach(({ node: o, replacements: n }) => {
2371
- var s;
2372
- (s = a.nodeCallback) == null || s.call(a, o, n);
2831
+ a.appendChild(document.createTextNode(l));
2832
+ }), (i = o.parentNode) == null || i.replaceChild(a, o);
2833
+ }), s != null && s.nodeCallback && r.forEach(({ node: o, replacements: n }) => {
2834
+ var a;
2835
+ (a = s.nodeCallback) == null || a.call(s, o, n);
2373
2836
  });
2374
- }, ve = "szjy-voice-models", Se = "szjy-voice-cache-v1";
2375
- function ye() {
2837
+ }, we = "szjy-voice-models", Ae = "szjy-voice-cache-v1";
2838
+ function be() {
2376
2839
  return typeof navigator < "u" && !!navigator.storage && typeof navigator.storage.getDirectory == "function";
2377
2840
  }
2378
- async function Le(r = ve) {
2379
- if (!ye()) return null;
2841
+ async function Oe(e = we) {
2842
+ if (!be()) return null;
2380
2843
  try {
2381
- return await (await navigator.storage.getDirectory()).getDirectoryHandle(r, { create: !0 });
2382
- } catch (e) {
2383
- return console.warn("[OPFS] 获取目录失败,将使用降级缓存:", e), null;
2844
+ return await (await navigator.storage.getDirectory()).getDirectoryHandle(e, { create: !0 });
2845
+ } catch (t) {
2846
+ return console.warn("[OPFS] 获取目录失败,将使用降级缓存:", t), null;
2384
2847
  }
2385
2848
  }
2386
- async function Jn(r, e, a = ve) {
2387
- if (ye())
2849
+ async function $r(e, t, s = we) {
2850
+ if (be())
2388
2851
  try {
2389
- const t = await Le(a);
2390
- if (t) {
2391
- const n = await (await t.getFileHandle(r, { create: !0 })).createWritable();
2392
- return await n.write(e), await n.close(), !0;
2852
+ const r = await Oe(s);
2853
+ if (r) {
2854
+ const n = await (await r.getFileHandle(e, { create: !0 })).createWritable();
2855
+ return await n.write(t), await n.close(), !0;
2393
2856
  }
2394
- } catch (t) {
2395
- console.warn(`[OPFS] 写入文件 ${r} 失败:`, t);
2857
+ } catch (r) {
2858
+ console.warn(`[OPFS] 写入文件 ${e} 失败:`, r);
2396
2859
  }
2397
2860
  if (typeof caches < "u")
2398
2861
  try {
2399
- const t = await caches.open(Se), o = new Response(e, {
2862
+ const r = await caches.open(Ae), o = new Response(t, {
2400
2863
  headers: { "Content-Type": "application/octet-stream" }
2401
2864
  });
2402
- return await t.put(`/${a}/${r}`, o), !0;
2403
- } catch (t) {
2404
- console.warn(`[CacheStorage] 缓存写入 ${r} 失败:`, t);
2865
+ return await r.put(`/${s}/${e}`, o), !0;
2866
+ } catch (r) {
2867
+ console.warn(`[CacheStorage] 缓存写入 ${e} 失败:`, r);
2405
2868
  }
2406
2869
  return !1;
2407
2870
  }
2408
- async function Kn(r, e = ve) {
2409
- if (ye())
2871
+ async function Or(e, t = we) {
2872
+ if (be())
2410
2873
  try {
2411
- const a = await Le(e);
2412
- if (a)
2413
- return await (await (await a.getFileHandle(r, { create: !1 })).getFile()).arrayBuffer();
2874
+ const s = await Oe(t);
2875
+ if (s)
2876
+ return await (await (await s.getFileHandle(e, { create: !1 })).getFile()).arrayBuffer();
2414
2877
  } catch {
2415
2878
  }
2416
2879
  if (typeof caches < "u")
2417
2880
  try {
2418
- const t = await (await caches.open(Se)).match(`/${e}/${r}`);
2419
- if (t)
2420
- return await t.arrayBuffer();
2881
+ const r = await (await caches.open(Ae)).match(`/${t}/${e}`);
2882
+ if (r)
2883
+ return await r.arrayBuffer();
2421
2884
  } catch {
2422
2885
  }
2423
2886
  return null;
2424
2887
  }
2425
- async function Qn(r, e = ve) {
2426
- if (ye())
2888
+ async function Nr(e, t = we) {
2889
+ if (be())
2427
2890
  try {
2428
- const a = await Le(e);
2429
- if (a)
2430
- return (await (await a.getFileHandle(r, { create: !1 })).getFile()).size > 0;
2891
+ const s = await Oe(t);
2892
+ if (s)
2893
+ return (await (await s.getFileHandle(e, { create: !1 })).getFile()).size > 0;
2431
2894
  } catch {
2432
2895
  }
2433
2896
  if (typeof caches < "u")
2434
2897
  try {
2435
- return !!await (await caches.open(Se)).match(`/${e}/${r}`);
2898
+ return !!await (await caches.open(Ae)).match(`/${t}/${e}`);
2436
2899
  } catch {
2437
2900
  }
2438
2901
  return !1;
2439
2902
  }
2440
- async function Zn(r = ve) {
2441
- let e = !1;
2442
- if (ye())
2903
+ async function Fr(e = we) {
2904
+ let t = !1;
2905
+ if (be())
2443
2906
  try {
2444
- await (await navigator.storage.getDirectory()).removeEntry(r, { recursive: !0 }), e = !0, console.log(`[OPFS] 成功清空语音模型缓存目录: ${r}`);
2445
- } catch (a) {
2446
- a.name === "NotFoundError" ? e = !0 : console.warn(`[OPFS] 清理目录 ${r} 异常:`, a);
2907
+ await (await navigator.storage.getDirectory()).removeEntry(e, { recursive: !0 }), t = !0, console.log(`[OPFS] 成功清空语音模型缓存目录: ${e}`);
2908
+ } catch (s) {
2909
+ s.name === "NotFoundError" ? t = !0 : console.warn(`[OPFS] 清理目录 ${e} 异常:`, s);
2447
2910
  }
2448
2911
  if (typeof caches < "u")
2449
2912
  try {
2450
- const a = await caches.keys();
2451
- for (const t of a)
2452
- (t.includes("transformers") || t.includes("szjy-voice") || t === Se) && (await caches.delete(t), e = !0);
2453
- } catch (a) {
2454
- console.warn("[CacheStorage] 清除缓存异常:", a);
2913
+ const s = await caches.keys();
2914
+ for (const r of s)
2915
+ (r.includes("transformers") || r.includes("szjy-voice") || r === Ae) && (await caches.delete(r), t = !0);
2916
+ } catch (s) {
2917
+ console.warn("[CacheStorage] 清除缓存异常:", s);
2455
2918
  }
2456
- return e;
2919
+ return t;
2457
2920
  }
2458
- const jn = "0.1.12", Hn = "Sz";
2459
- function Yn({
2460
- componentPrefix: r = Hn,
2461
- components: e = []
2921
+ const Ir = "0.1.13", Er = "Sz";
2922
+ function Br({
2923
+ componentPrefix: e = Er,
2924
+ components: t = []
2462
2925
  } = {}) {
2463
- const a = [];
2464
- function t(n, s, i) {
2465
- n.component(r + s) || n.component(
2466
- r + s,
2926
+ const s = [];
2927
+ function r(n, a, i) {
2928
+ n.component(e + a) || n.component(
2929
+ e + a,
2467
2930
  i
2468
2931
  );
2469
2932
  }
2470
2933
  function o(n) {
2471
- a.includes(n) || (a.push(n), e.forEach((s) => {
2472
- const { name: i, alias: l } = s;
2473
- t(n, i, s), l && l.forEach((y) => {
2474
- t(n, y, s);
2934
+ s.includes(n) || (s.push(n), t.forEach((a) => {
2935
+ const { name: i, alias: l } = a;
2936
+ r(n, i, a), l && l.forEach((c) => {
2937
+ r(n, c, a);
2475
2938
  });
2476
2939
  }));
2477
2940
  }
2478
2941
  return {
2479
- version: jn,
2480
- componentPrefix: r,
2942
+ version: Ir,
2943
+ componentPrefix: e,
2481
2944
  install: o
2482
2945
  };
2483
2946
  }
2484
- const Xn = {
2485
- install(r) {
2486
- Ie(r);
2947
+ const Vr = {
2948
+ install(e) {
2949
+ ze(e);
2487
2950
  }
2488
2951
  };
2489
2952
  export {
2490
- $t as AudioRecorder,
2491
- Qe as DEFAULT_WHISPER_WORKER_URL,
2492
- Vt as StreamResampler,
2493
- En as SzAiChat,
2494
- Nn as SzAiChatPlain,
2495
- Wt as VoiceInputManager,
2496
- Zn as clearVoiceModelCache,
2497
- Yn as create,
2498
- zn as createRouteLink,
2499
- zt as decodeAudioFile,
2500
- Xn as default,
2501
- Dn as findRouteTextNodes,
2502
- Be as float32ToWav,
2503
- Kn as getFileFromCache,
2504
- Le as getOPFSDirectory,
2505
- Qn as hasFileInCache,
2506
- ye as isOPFSSupported,
2507
- Vn as parseRouteMarkerContent,
2508
- Bn as parseRouteMarkers,
2509
- Bt as resampleAudioData,
2510
- Gn as routeLinkRender,
2511
- Jn as saveFileToCache
2953
+ _n as AudioRecorder,
2954
+ Et as DEFAULT_MOCK_RESPONSE,
2955
+ at as DEFAULT_WHISPER_WORKER_URL,
2956
+ hn as SZJY_UI_FENCE_LANG,
2957
+ Un as StreamResampler,
2958
+ Sr as SzAiChat,
2959
+ xr as SzAiChatPlain,
2960
+ Ln as VoiceInputManager,
2961
+ gn as bindSzjyUiEvents,
2962
+ Fr as clearVoiceModelCache,
2963
+ Br as create,
2964
+ Ot as createMockStylized,
2965
+ Pr as createRouteLink,
2966
+ Mn as decodeAudioFile,
2967
+ Vr as default,
2968
+ ve as escapeHtml,
2969
+ Mr as findRouteTextNodes,
2970
+ qe as float32ToWav,
2971
+ Or as getFileFromCache,
2972
+ Oe as getOPFSDirectory,
2973
+ Wt as getSzjyUiAction,
2974
+ Dt as getSzjyUiComponent,
2975
+ Nr as hasFileInCache,
2976
+ Gt as hasSzjyUiAction,
2977
+ qt as hasSzjyUiComponent,
2978
+ be as isOPFSSupported,
2979
+ Rr as parseRouteMarkerContent,
2980
+ _r as parseRouteMarkers,
2981
+ pn as parseSzjyUiFence,
2982
+ Ht as registerSzjyUiAction,
2983
+ et as registerSzjyUiComponent,
2984
+ Xt as renderActionAttrs,
2985
+ Kt as renderSzjyUiBlock,
2986
+ tt as renderSzjyUiNode,
2987
+ Pn as resampleAudioData,
2988
+ Lr as routeLinkRender,
2989
+ $r as saveFileToCache
2512
2990
  };