@burdenoff/fe-libs 2026.1016.2 → 2026.1017.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/shared/assistant/avatar/live/AvatarFace.d.ts +13 -0
  2. package/dist/shared/assistant/avatar/live/AvatarFace.js +46 -0
  3. package/dist/shared/assistant/avatar/live/LiveAvatarTabView.d.ts +2 -0
  4. package/dist/shared/assistant/avatar/live/LiveAvatarTabView.js +172 -145
  5. package/dist/shared/assistant/avatar/live/avatarFaces.d.ts +31 -0
  6. package/dist/shared/assistant/avatar/live/avatarFaces.js +33 -0
  7. package/dist/shared/assistant/avatar/live/createLiveAvatarSeam.d.ts +12 -0
  8. package/dist/shared/assistant/avatar/live/createLiveAvatarSeam.js +142 -75
  9. package/dist/shared/assistant/avatar/live/liveAvatarController.d.ts +5 -0
  10. package/dist/shared/assistant/avatar/live/liveAvatarController.js +3 -1
  11. package/dist/shared/assistant/avatar/live/liveAvatarStatus.d.ts +14 -0
  12. package/dist/shared/assistant/avatar/live/liveAvatarStatus.js +11 -2
  13. package/dist/shared/assistant/avatar/useAvatarCopy.d.ts +42 -0
  14. package/dist/shared/assistant/avatar/useAvatarCopy.js +113 -75
  15. package/dist/shared/assistant/i18nManifest.d.ts +29 -0
  16. package/dist/shared/assistant/i18nManifest.js +29 -0
  17. package/dist/shared/assistant/index.d.ts +8 -0
  18. package/dist/shared/assistant/speech/hostedTtsSpeechEngine.d.ts +6 -0
  19. package/dist/shared/assistant/speech/hostedTtsSpeechEngine.js +118 -101
  20. package/dist/shared/assistant/speech/notifyCancellationSpeechEngine.js +3 -0
  21. package/dist/shared/assistant/speech/replySpeechRequests.d.ts +84 -0
  22. package/dist/shared/assistant/speech/replySpeechRequests.js +70 -0
  23. package/dist/shared/assistant/speech/routingSpeechEngine.js +13 -9
  24. package/dist/shared/assistant/speech/types.d.ts +39 -1
  25. package/dist/shared/assistant/ui/AIAssistantPanel.js +128 -119
  26. package/dist/shared/assistant/ui/AssistantChatArea.js +1572 -1430
  27. package/dist/shared/assistant/ui/AssistantMessageItem.js +110 -100
  28. package/dist/shared/assistant/ui/AssistantSpeechProvider.d.ts +10 -0
  29. package/dist/shared/assistant/ui/AssistantSpeechProvider.js +286 -225
  30. package/dist/shared/assistant/ui/assistantLiveAvatarSeam.d.ts +40 -0
  31. package/dist/shared/assistant/ui/avatar/AssistantAvatarTab.d.ts +6 -0
  32. package/dist/shared/assistant/ui/avatar/AssistantAvatarTab.js +99 -52
  33. package/dist/shared/assistant/ui/avatar/AvatarTabAskBox.d.ts +8 -0
  34. package/dist/shared/assistant/ui/avatar/AvatarTabAskBox.js +87 -0
  35. package/dist/shared/assistant/ui/avatar/AvatarTabLastExchange.d.ts +13 -0
  36. package/dist/shared/assistant/ui/avatar/AvatarTabLastExchange.js +97 -0
  37. package/dist/shared/assistant/ui/avatar/avatarAskGate.d.ts +104 -0
  38. package/dist/shared/assistant/ui/avatar/avatarAskGate.js +39 -0
  39. package/dist/shared/assistant/ui/avatar/avatarTabDraft.d.ts +17 -0
  40. package/dist/shared/assistant/ui/avatar/avatarTabDraft.js +22 -0
  41. package/dist/shared/assistant/ui/avatar/avatarTabExchange.d.ts +47 -0
  42. package/dist/shared/assistant/ui/avatar/avatarTabExchange.js +50 -0
  43. package/dist/shared/assistant/ui/panelOverlays.d.ts +8 -1
  44. package/dist/shared/assistant/ui/panelOverlays.js +1 -1
  45. package/dist/shared/assistant/ui/useVoiceSession.js +222 -227
  46. package/dist/shared/assistant/voice/handsfree/playbackReference.d.ts +15 -4
  47. package/dist/shared/assistant/voice/handsfree/playbackReference.js +9 -6
  48. package/dist/shared-assistant.js +270 -262
  49. package/package.json +1 -1
@@ -2,25 +2,27 @@ import { useI18n as e } from "../../providers/shell/I18nProvider.js";
2
2
  import { useAssistantTr as t } from "../i18n.js";
3
3
  import { useAssistantStore as n } from "../store.js";
4
4
  import { isVoiceTurn as r } from "../voice/turnVisibility.js";
5
- import { VOICE_LIST_TIMEOUT_MS as i, languageDisplayName as a, selectVoiceForLocale as o, speechGate as s, speechLangForLocale as c, voiceAvailability as l, voicesForLocale as u } from "../voice/speechVoices.js";
6
- import { getSpeechEngine as d, subscribeSpeechEngine as f } from "../speech/createSpeechEngine.js";
7
- import { speechFeed as p } from "../speech/speechFeed.js";
8
- import { isTurnSuperseded as m } from "../voice/supersededTurns.js";
9
- import { chunkForSpeech as ee, toSpeakableText as h } from "../voice/speakableText.js";
10
- import { voicePreviewText as te } from "../voice/voicePreview.js";
11
- import { findAssistantLanguage as ne } from "../voice/languages.js";
12
- import { resolveLanguagePair as re } from "../voice/languagePair.js";
13
- import { speechLabelsFor as ie } from "../voice/speechLabels.js";
14
- import { resolveSpeechLocale as ae } from "../voice/replyLanguage.js";
15
- import { IDLE_PLAYBACK as oe, isSpeakingMessage as se, publishedChunks as ce, speechPlaybackReducer as le } from "../voice/speechPlayback.js";
16
- import { isTurnInFlight as ue } from "../turnState.js";
17
- import { parseToolActivity as de } from "./AssistantToolActivity.js";
5
+ import { HOSTED_VOICES as i } from "../speech/hostedVoiceCatalogue.js";
6
+ import { VOICE_LIST_TIMEOUT_MS as a, languageDisplayName as o, selectVoiceForLocale as s, speechGate as ee, speechLangForLocale as c, voiceAvailability as te, voicesForLocale as l } from "../voice/speechVoices.js";
7
+ import { getSpeechEngine as u, subscribeSpeechEngine as ne } from "../speech/createSpeechEngine.js";
8
+ import { speechFeed as d } from "../speech/speechFeed.js";
9
+ import { hasPendingReplyRequests as f, releaseReplyRequestsOutside as p, replyWantsAvatar as re, settleReplyRequest as m, subscribeReplyRequests as h } from "../speech/replySpeechRequests.js";
10
+ import { isTurnSuperseded as g } from "../voice/supersededTurns.js";
11
+ import { chunkForSpeech as ie, toSpeakableText as _ } from "../voice/speakableText.js";
12
+ import { voicePreviewText as ae } from "../voice/voicePreview.js";
13
+ import { findAssistantLanguage as v } from "../voice/languages.js";
14
+ import { resolveLanguagePair as oe } from "../voice/languagePair.js";
15
+ import { speechLabelsFor as se } from "../voice/speechLabels.js";
16
+ import { resolveSpeechLocale as ce } from "../voice/replyLanguage.js";
17
+ import { IDLE_PLAYBACK as le, isSpeakingMessage as ue, publishedChunks as de, speechPlaybackReducer as fe } from "../voice/speechPlayback.js";
18
+ import { isTurnInFlight as pe } from "../turnState.js";
19
+ import { parseToolActivity as me } from "./AssistantToolActivity.js";
18
20
  import "../speech/index.js";
19
- import { markTurn as g } from "../turnTimeline.js";
20
- import { createContext as fe, useCallback as _, useContext as v, useEffect as y, useMemo as b, useReducer as pe, useRef as x, useState as S, useSyncExternalStore as me } from "react";
21
- import { jsx as he } from "react/jsx-runtime";
21
+ import { markTurn as he } from "../turnTimeline.js";
22
+ import { createContext as ge, useCallback as y, useContext as _e, useEffect as b, useMemo as x, useReducer as ve, useRef as S, useState as C, useSyncExternalStore as ye } from "react";
23
+ import { jsx as be } from "react/jsx-runtime";
22
24
  //#region src/shared/assistant/ui/AssistantSpeechProvider.tsx
23
- var ge = {
25
+ var xe = {
24
26
  codeBlock: "",
25
27
  image: "",
26
28
  link: "",
@@ -29,12 +31,36 @@ var ge = {
29
31
  emailAt: "at",
30
32
  emailDot: "dot",
31
33
  nestedItem: ""
32
- }, _e = 4e3, ve = fe({
34
+ }, Se = 4e3, w = () => {}, Ce = {
35
+ subscribe: () => w,
36
+ getSnapshot: () => !1
37
+ }, we = {
38
+ subscribe: h,
39
+ getSnapshot: f
40
+ };
41
+ function Te(e, t) {
42
+ return re(t) ? {
43
+ ...e,
44
+ autoSpeakEnabled: !0
45
+ } : e;
46
+ }
47
+ function Ee(e, t) {
48
+ let n = e.activeConversationId;
49
+ if (!n || n !== t.activeConversationId) return null;
50
+ let r = e.processingByConversationId[n], i = t.processingByConversationId[n];
51
+ if (r?.status !== "complete" || !pe(i?.status)) return null;
52
+ let a = r.messageId ?? i?.messageId ?? null;
53
+ if (!a) return null;
54
+ let o = e.conversations.find((e) => e.id === n)?.messages.find((e) => e.id === a);
55
+ return o && o.role === "assistant" ? o : null;
56
+ }
57
+ var De = ge({
33
58
  isSupported: !1,
34
59
  availability: "unsupported",
35
60
  isBlocked: !0,
36
61
  disabledReason: null,
37
62
  blockedFor: () => null,
63
+ deviceFallbackFor: () => null,
38
64
  voiceChoices: [],
39
65
  spokenChunks: null,
40
66
  activeVoiceName: null,
@@ -53,52 +79,52 @@ var ge = {
53
79
  speakFinishedReply: () => {},
54
80
  previewVoice: () => {}
55
81
  });
56
- function ye() {
57
- return v(ve);
82
+ function T() {
83
+ return _e(De);
58
84
  }
59
- var be = ({ children: fe, visible: v = !0, engine: ye }) => {
60
- let be = me(f, d, d), C = ye ?? be, w = t(), { locale: T } = e(), [E, D] = pe(le, oe), [O, k] = S(() => C.listVoices()), [A, xe] = S(!1), [Se, j] = S(() => /* @__PURE__ */ new Map()), [Ce, we] = S(null), M = x(0), N = x(null), P = x(null), F = x(null);
61
- y(() => () => {
62
- F.current !== null && clearTimeout(F.current);
85
+ var E = ({ children: f, visible: h = !0, engine: ge }) => {
86
+ let _e = ye(ne, u, u), w = ge ?? _e, T = t(), { locale: E } = e(), [D, O] = ve(fe, le), [k, A] = C(() => w.listVoices()), [j, Oe] = C(!1), [ke, M] = C(() => /* @__PURE__ */ new Map()), [Ae, N] = C(() => /* @__PURE__ */ new Set()), [je, Me] = C(null), P = S(0), F = S(null), I = S(null), L = S(null), R = S(null);
87
+ b(() => () => {
88
+ R.current !== null && clearTimeout(R.current);
63
89
  }, []);
64
- let [Te, I] = S(null), L = x(null), Ee = x(() => {}), R = _(() => {
65
- L.current?.(), L.current = null;
66
- }, []), z = n((e) => e.autoSpeakEnabled), De = n((e) => e.setAutoSpeak), [B, Oe] = S(!1), V = x(!1), ke = _((e) => {
67
- V.current = e;
68
- }, []), H = n((e) => e.activeConversationId), U = b(() => C.isSupported(), [C]);
69
- y(() => {
90
+ let [Ne, Pe] = C(null), z = S(null), Fe = S(() => {}), B = y(() => {
91
+ z.current?.(), z.current = null;
92
+ }, []), V = n((e) => e.autoSpeakEnabled), Ie = n((e) => e.setAutoSpeak), [H, Le] = C(!1), Re = S(!1), ze = y((e) => {
93
+ Re.current = e;
94
+ }, []), Be = n((e) => e.activeConversationId), U = x(() => w.isSupported(), [w]), Ve = w.wouldSpeakOnAvatar === void 0 ? Ce : we, He = ye(Ve.subscribe, Ve.getSnapshot, Ve.getSnapshot);
95
+ b(() => {
70
96
  if (!U) return;
71
97
  let e = () => {
72
- k(C.listVoices()), j((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
98
+ A(w.listVoices()), M((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
73
99
  };
74
- return e(), C.subscribeVoices(e);
75
- }, [C, U]);
76
- let Ae = n((e) => e.assistantLanguage), je = n((e) => e.replyLanguage), W = n((e) => e.preferredVoices), Me = n((e) => e.setPreferredVoice), G = b(() => re(Ae, je, T).reply, [
77
- Ae,
78
- je,
79
- T
80
- ]), K = G.code, q = _((e) => ne(e)?.tag ?? c(e), []), Ne = _((e) => ne(e)?.rate ?? .9, []), J = b(() => l(U, O, G.tag, A), [
100
+ return e(), w.subscribeVoices(e);
101
+ }, [w, U]);
102
+ let Ue = n((e) => e.assistantLanguage), We = n((e) => e.replyLanguage), W = n((e) => e.preferredVoices), Ge = n((e) => e.setPreferredVoice), G = x(() => oe(Ue, We, E).reply, [
103
+ Ue,
104
+ We,
105
+ E
106
+ ]), K = G.code, q = y((e) => v(e)?.tag ?? c(e), []), Ke = y((e) => v(e)?.rate ?? .9, []), J = x(() => te(U, k, G.tag, j), [
81
107
  U,
82
- O,
108
+ k,
83
109
  G,
84
- A
85
- ]), Pe = b(() => ({
86
- codeBlock: w("speech.codeBlock", "Code block"),
87
- image: w("speech.image", "image"),
88
- link: w("speech.link", "link"),
89
- largeTable: w("speech.largeTable", "Table with {{rows}} rows and {{columns}} columns"),
90
- truncated: w("speech.truncated", "The rest of this message is not read aloud"),
91
- nestedItem: w("speech.nestedItem", "Sub-item {{ordinal}}"),
92
- emailAt: w("speech.emailAt", "at"),
93
- emailDot: w("speech.emailDot", "dot")
94
- }), [w]), Y = _(() => {
95
- R(), N.current = null, C.cancel(), D({ type: "stop" });
96
- }, [R, C]), Fe = _((e) => {
97
- let t = C.listVoices().find((t) => t.name === e) ?? null;
110
+ j
111
+ ]), qe = x(() => ({
112
+ codeBlock: T("speech.codeBlock", "Code block"),
113
+ image: T("speech.image", "image"),
114
+ link: T("speech.link", "link"),
115
+ largeTable: T("speech.largeTable", "Table with {{rows}} rows and {{columns}} columns"),
116
+ truncated: T("speech.truncated", "The rest of this message is not read aloud"),
117
+ nestedItem: T("speech.nestedItem", "Sub-item {{ordinal}}"),
118
+ emailAt: T("speech.emailAt", "at"),
119
+ emailDot: T("speech.emailDot", "dot")
120
+ }), [T]), Y = y(() => {
121
+ B(), I.current = null, w.cancel(), m(F.current, "stopped"), O({ type: "stop" });
122
+ }, [B, w]), Je = y((e) => {
123
+ let t = w.listVoices().find((t) => t.name === e) ?? null;
98
124
  if (t) {
99
125
  Y();
100
126
  try {
101
- C.speak([te(K)], {
127
+ w.speak([ae(K)], {
102
128
  voice: t,
103
129
  lang: q(K),
104
130
  fallback: !1
@@ -106,310 +132,345 @@ var be = ({ children: fe, visible: v = !0, engine: ye }) => {
106
132
  } catch {}
107
133
  }
108
134
  }, [
109
- C,
135
+ w,
110
136
  K,
111
137
  Y,
112
138
  q
113
- ]), Ie = _((e) => Se.get(e) ?? null, [Se]), Le = _((e, t, n, r, a) => {
114
- R();
115
- let o = !1, s = () => {}, c = (i) => {
139
+ ]), Ye = y((e) => ke.get(e) ?? null, [ke]), Xe = y((e) => Ae.has(e) ? T("speech.deviceFallback", "Device voice used: the selected voice was unavailable.") : null, [Ae, T]), Ze = y((e, t, n, r, i) => {
140
+ B();
141
+ let o = !1, s = () => {}, ee = (a) => {
116
142
  if (!o) {
117
- if (o = !0, L.current = null, clearTimeout(l), s(), i.length === 0) {
118
- xe(!0);
143
+ if (o = !0, z.current = null, clearTimeout(c), s(), a.length === 0) {
144
+ Oe(!0), m(e, "declined");
119
145
  return;
120
146
  }
121
- k(i), Ee.current(e, t, i, n, r, a);
147
+ A(a), Fe.current(e, t, a, n, r, i);
122
148
  }
123
- }, l = setTimeout(() => c(C.listVoices()), i);
124
- s = C.subscribeVoices(() => c(C.listVoices())), L.current = () => {
125
- o || (o = !0, clearTimeout(l), s(), L.current = null);
149
+ }, c = setTimeout(() => ee(w.listVoices()), a);
150
+ s = w.subscribeVoices(() => ee(w.listVoices())), z.current = () => {
151
+ o || (o = !0, clearTimeout(c), s(), z.current = null, m(e, "stopped"));
126
152
  };
127
- }, [R, C]), X = _((e, t, n, r, i = !1, c) => {
128
- let u = n;
129
- if (u.length === 0) {
130
- let e = C.listVoices();
131
- e.length > 0 && (u = e, k(e));
153
+ }, [B, w]), X = y((e, t, n, r, a = !1, c) => {
154
+ let l = n;
155
+ if (l.length === 0) {
156
+ let e = w.listVoices();
157
+ e.length > 0 && (l = e, A(e));
132
158
  }
133
- let d = q(r), f = s(l(!0, u, r, A));
134
- if (f === "block") {
135
- let t = w("speech.noVoiceForReply", "This reply is in {{language}}, and no {{language}} voice is installed on this device.", { language: a(d, T) });
136
- j((n) => new Map(n).set(e, t));
159
+ let u = q(r), ne = ee(te(!0, l, r, j));
160
+ if (ne === "block") {
161
+ let t = T("speech.noVoiceForReply", "This reply is in {{language}}, and no {{language}} voice is installed on this device.", { language: o(u, E) });
162
+ M((n) => new Map(n).set(e, t)), m(e, "declined");
137
163
  return;
138
164
  }
139
- if (f === "wait-for-voices") {
140
- Le(e, t, r, i, c);
165
+ if (ne === "wait-for-voices") {
166
+ Ze(e, t, r, a, c);
141
167
  return;
142
168
  }
143
- j((t) => {
169
+ let d = {
170
+ voice: s(l, u, W[r]),
171
+ lang: u,
172
+ rate: Ke(r)
173
+ }, f = $e.current;
174
+ if (a && !f.autoSpeakEnabled && !f.sessionSpeaking && re(e)) {
175
+ if (w.wouldSpeakOnAvatar?.(d) !== !0) {
176
+ m(e, "declined");
177
+ return;
178
+ }
179
+ d.avatarOnly = !0;
180
+ }
181
+ M((t) => {
144
182
  if (!t.has(e)) return t;
145
183
  let n = new Map(t);
146
184
  return n.delete(e), n;
147
- }), R();
148
- let p = M.current + 1;
149
- M.current = p, D({
185
+ });
186
+ let p = W[r], h = typeof p == "string" && i.some((e) => e.name === p) && !l.some((e) => e.name === p);
187
+ N((t) => {
188
+ if (t.has(e) === h) return t;
189
+ let n = new Set(t);
190
+ return h ? n.add(e) : n.delete(e), n;
191
+ }), B();
192
+ let g = P.current + 1;
193
+ P.current = g, F.current !== e && m(F.current, "stopped"), F.current = e, m(e, "speaking"), O({
150
194
  type: "start",
151
195
  messageId: e,
152
- requestId: p
153
- }), N.current = i ? p : null, i && g(e, "ttsStarted");
154
- let m = c === void 0 ? ee(t) : ee(t, void 0, void 0, { firstChunkMaxChars: c });
155
- I({
156
- requestId: p,
157
- chunks: m,
196
+ requestId: g
197
+ }), I.current = a ? g : null, a && he(e, "ttsStarted");
198
+ let _ = c === void 0 ? ie(t) : ie(t, void 0, void 0, { firstChunkMaxChars: c });
199
+ Pe({
200
+ requestId: g,
201
+ chunks: _,
158
202
  index: -1
159
- }), F.current !== null && clearTimeout(F.current), F.current = setTimeout(() => {
160
- I((e) => e?.requestId === p && e.index < 0 ? null : e);
161
- }, _e);
162
- let h = () => {
163
- M.current === p && F.current !== null && (clearTimeout(F.current), F.current = null), D({
203
+ }), R.current !== null && clearTimeout(R.current), R.current = setTimeout(() => {
204
+ Pe((e) => e?.requestId === g && e.index < 0 ? null : e);
205
+ }, Se);
206
+ let ae = () => {
207
+ P.current === g && R.current !== null && (clearTimeout(R.current), R.current = null), m(e, "failed"), O({
164
208
  type: "failed",
165
- requestId: p
209
+ requestId: g
166
210
  });
167
- };
211
+ }, v = !1;
168
212
  try {
169
- C.speak(m, {
170
- voice: o(u, d, W[r]),
171
- lang: d,
172
- rate: Ne(r)
173
- }, {
213
+ w.speak(_, d, {
174
214
  onStart: () => {
175
- M.current === p && N.current === p && g(e, "firstAudio");
215
+ P.current === g && I.current === g && he(e, "firstAudio");
176
216
  },
177
217
  onChunkStart: (e) => {
178
- M.current === p && F.current !== null && (clearTimeout(F.current), F.current = null), I((t) => t?.requestId === p ? {
218
+ v = !0, P.current === g && R.current !== null && (clearTimeout(R.current), R.current = null), Pe((t) => t?.requestId === g ? {
179
219
  ...t,
180
220
  index: e
181
- } : M.current === p ? {
182
- requestId: p,
183
- chunks: m,
221
+ } : P.current === g ? {
222
+ requestId: g,
223
+ chunks: _,
184
224
  index: e
185
225
  } : t);
186
226
  },
227
+ onDeviceFallback: () => {
228
+ P.current === g && N((t) => t.has(e) ? t : new Set(t).add(e));
229
+ },
187
230
  onEnd: () => {
188
- M.current === p && N.current === p && g(e, "audioEnded"), D({
231
+ P.current === g && I.current === g && he(e, "audioEnded"), m(e, "spoken"), O({
189
232
  type: "finished",
190
- requestId: p
233
+ requestId: g
191
234
  });
192
235
  },
193
236
  onError: (t) => {
194
- t === "output-not-cleared" && M.current === p && we({ messageId: e }), D({
237
+ !v && P.current === g && N((t) => {
238
+ if (!t.has(e)) return t;
239
+ let n = new Set(t);
240
+ return n.delete(e), n;
241
+ }), t === "output-not-cleared" && P.current === g && Me({ messageId: e }), m(e, t === "output-not-cleared" ? "not-cleared" : t === "output-left" ? v ? "cut" : "declined" : t === "cancelled" ? "stopped" : "failed"), O({
195
242
  type: "failed",
196
- requestId: p
243
+ requestId: g
197
244
  });
198
245
  }
199
246
  });
200
247
  } catch {
201
- h();
248
+ ae();
202
249
  }
203
250
  }, [
204
- R,
205
- C,
206
- T,
251
+ B,
252
+ w,
253
+ E,
207
254
  W,
208
- Ne,
255
+ Ke,
209
256
  q,
210
- w,
211
- A,
212
- Le
257
+ T,
258
+ j,
259
+ Ze
213
260
  ]);
214
- y(() => {
215
- Ee.current = X;
261
+ b(() => {
262
+ Fe.current = X;
216
263
  }, [X]);
217
- let Z = _((e, t, n, r) => {
264
+ let Z = y((e, t, n, r) => {
218
265
  if (!U) return;
219
- let i = ae(h(t, { labels: ge }), n ?? K), a = h(t, { labels: ie(i, Pe) });
220
- a && X(e, a, O, i, r?.auto === !0, r?.firstChunkMaxChars);
266
+ let i = ce(_(t, { labels: xe }), n ?? K), a = _(t, { labels: se(i, qe) });
267
+ a && X(e, a, k, i, r?.auto === !0, r?.firstChunkMaxChars);
221
268
  }, [
222
269
  U,
223
- Pe,
270
+ qe,
224
271
  K,
225
272
  X,
226
- O
227
- ]), Re = _((e, t, n) => {
228
- if (se(E, e)) {
273
+ k
274
+ ]), Qe = y((e, t, n) => {
275
+ if (ue(D, e)) {
229
276
  Y();
230
277
  return;
231
278
  }
232
279
  Z(e, t, n);
233
280
  }, [
234
- E,
281
+ D,
235
282
  Z,
236
283
  Y
237
284
  ]);
238
- y(() => {
239
- v || Y();
240
- }, [v, Y]);
241
- let ze = x({
242
- autoSpeakEnabled: z,
243
- sessionSpeaking: B,
244
- visible: v,
285
+ b(() => {
286
+ h || Y();
287
+ }, [h, Y]);
288
+ let $e = S({
289
+ autoSpeakEnabled: V,
290
+ sessionSpeaking: H,
291
+ visible: h,
245
292
  isSupported: U
246
293
  });
247
- y(() => {
248
- ze.current = {
249
- autoSpeakEnabled: z,
250
- sessionSpeaking: B,
251
- visible: v,
294
+ b(() => {
295
+ $e.current = {
296
+ autoSpeakEnabled: V,
297
+ sessionSpeaking: H,
298
+ visible: h,
252
299
  isSupported: U
253
300
  };
254
301
  }, [
255
- z,
256
- B,
257
- v,
302
+ V,
303
+ H,
304
+ h,
258
305
  U
259
306
  ]);
260
- let Be = x(null), Ve = x(null), He = x(() => {});
261
- y(() => {
262
- Y(), j(/* @__PURE__ */ new Map()), Be.current = H;
263
- let e = Ve.current;
264
- Ve.current = null, e && e.conversationId === H && He.current(e.conversationId, e.messageId);
265
- }, [H, Y]), y(() => {
266
- j((e) => e.size === 0 ? e : /* @__PURE__ */ new Map()), Y();
267
- }, [K, Y]), y(() => () => {
268
- L.current?.(), L.current = null, C.cancel();
269
- }, [C]), y(() => {
307
+ let et = S(null), tt = S(null), nt = S(() => {});
308
+ b(() => {
309
+ Y(), M(/* @__PURE__ */ new Map()), N(/* @__PURE__ */ new Set()), p(n.getState().activeConversationId), et.current = Be;
310
+ let e = tt.current;
311
+ tt.current = null, e && e.conversationId === Be && nt.current(e.conversationId, e.messageId);
312
+ }, [Be, Y]), b(() => {
313
+ M((e) => e.size === 0 ? e : /* @__PURE__ */ new Map()), Y();
314
+ }, [K, Y]), b(() => () => {
315
+ z.current?.(), z.current = null, w.cancel();
316
+ }, [w]), b(() => {
270
317
  if (typeof window > "u") return;
271
- let e = () => C.cancel();
318
+ let e = () => w.cancel();
272
319
  return window.addEventListener("pagehide", e), () => window.removeEventListener("pagehide", e);
273
- }, [C]), y(() => {
320
+ }, [w]), b(() => {
274
321
  if (typeof document > "u" || !U) return;
275
322
  let e = () => {
276
323
  if (document.visibilityState !== "visible") return;
277
- let e = C.listVoices();
278
- e.length > 0 && R(), k(e), xe(!1), j((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
324
+ let e = w.listVoices();
325
+ e.length > 0 && B(), A(e), Oe(!1), M((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
279
326
  };
280
327
  return document.addEventListener("visibilitychange", e), window.addEventListener("focus", e), () => {
281
328
  document.removeEventListener("visibilitychange", e), window.removeEventListener("focus", e);
282
329
  };
283
330
  }, [
284
- R,
285
- C,
331
+ B,
332
+ w,
286
333
  U
287
334
  ]);
288
- let Ue = x(Z);
289
- y(() => {
290
- Ue.current = Z;
335
+ let rt = S(Z);
336
+ b(() => {
337
+ rt.current = Z;
291
338
  }, [Z]);
292
- let Q = _((e, t) => {
293
- if (r(e) !== t || m(e.id) || P.current?.messageId === e.id || V.current) return;
294
- let { text: n } = de(e.content);
339
+ let Q = y((e, t) => {
340
+ if (r(e) !== t || g(e.id) || L.current?.messageId === e.id || Re.current) return;
341
+ let { text: n } = me(e.content);
295
342
  if (n.trim()) try {
296
- Ue.current(e.id, n, e.metadata?.lang, { auto: !0 });
343
+ rt.current(e.id, n, e.metadata?.lang, { auto: !0 });
297
344
  } catch {}
298
- }, []), $ = _((e, t) => {
299
- if (e !== Be.current) {
300
- n.getState().activeConversationId === e && (Ve.current = {
345
+ }, []), $ = y((e, t) => {
346
+ if (e !== et.current) {
347
+ n.getState().activeConversationId === e && (tt.current = {
301
348
  conversationId: e,
302
349
  messageId: t
303
350
  });
304
351
  return;
305
352
  }
306
- let r = ze.current;
353
+ let r = Te($e.current, t);
307
354
  if (!r.autoSpeakEnabled && !r.sessionSpeaking || !r.visible || !r.isSupported) return;
308
355
  let i = n.getState();
309
356
  if (i.activeConversationId !== e) return;
310
357
  let a = i.conversations.find((t) => t.id === e)?.messages.find((e) => e.id === t);
311
358
  !a || a.role !== "assistant" || Q(a, r.sessionSpeaking);
312
359
  }, [Q]);
313
- y(() => {
314
- He.current = $;
315
- }, [$]), y(() => {
316
- if (!(!z && !B || !v || !U)) return n.subscribe((e, t) => {
360
+ b(() => {
361
+ nt.current = $;
362
+ }, [$]), b(() => {
363
+ if (!(!V && !H || !h || !U)) return n.subscribe((e, t) => {
317
364
  let n = e.activeConversationId;
318
365
  if (!n || n !== t.activeConversationId) return;
319
366
  let r = e.processingByConversationId[n], i = t.processingByConversationId[n];
320
- if (r?.status !== "complete" || !ue(i?.status)) return;
367
+ if (r?.status !== "complete" || !pe(i?.status)) return;
321
368
  let a = r.messageId ?? i?.messageId ?? null;
322
369
  if (!a) return;
323
370
  let o = e.conversations.find((e) => e.id === n)?.messages.find((e) => e.id === a);
324
- !o || o.role !== "assistant" || Q(o, B);
371
+ !o || o.role !== "assistant" || Q(o, H);
325
372
  });
326
373
  }, [
327
- z,
328
- B,
374
+ V,
375
+ H,
329
376
  U,
330
- v,
377
+ h,
378
+ Q
379
+ ]), b(() => {
380
+ if (!(V || H || !He || !h || !U)) return n.subscribe((e, t) => {
381
+ let n = Ee(e, t);
382
+ !n || !re(n.id) || Q(n, !1);
383
+ });
384
+ }, [
385
+ V,
386
+ H,
387
+ He,
388
+ U,
389
+ h,
331
390
  Q
332
391
  ]);
333
- let We = _((e) => {
392
+ let it = y((e) => {
334
393
  if (e.type === "abort") {
335
- let t = P.current;
394
+ let t = L.current;
336
395
  if (!t || t.messageId !== e.messageId) return;
337
- P.current = null, (t.requestId === null ? t.waiting && L.current !== null : M.current === t.requestId) && Y();
396
+ L.current = null, (t.requestId === null ? t.waiting && z.current !== null : P.current === t.requestId) && Y();
338
397
  return;
339
398
  }
340
- let { messageId: t, item: r } = e, i = ze.current;
341
- if (!i.autoSpeakEnabled && !i.sessionSpeaking || !i.visible || !i.isSupported || r.channel === "voice" !== i.sessionSpeaking || m(t) || V.current || P.current?.messageId === t || n.getState().activeConversationId !== r.conversationId || Be.current !== r.conversationId) return;
342
- let { text: a } = de(r.text);
399
+ let { messageId: t, item: r } = e, i = Te($e.current, t);
400
+ if (!i.autoSpeakEnabled && !i.sessionSpeaking || !i.visible || !i.isSupported || r.channel === "voice" !== i.sessionSpeaking || g(t) || Re.current || L.current?.messageId === t || n.getState().activeConversationId !== r.conversationId || et.current !== r.conversationId) return;
401
+ let { text: a } = me(r.text);
343
402
  if (!a.trim()) return;
344
- let o = M.current;
403
+ let o = P.current;
345
404
  try {
346
- Ue.current(t, a, r.lang, {
405
+ rt.current(t, a, r.lang, {
347
406
  auto: !0,
348
407
  firstChunkMaxChars: 110
349
408
  });
350
409
  } catch {}
351
- let s = M.current !== o;
352
- P.current = {
410
+ let s = P.current !== o;
411
+ L.current = {
353
412
  messageId: t,
354
- requestId: s ? M.current : null,
355
- waiting: !s && L.current !== null
413
+ requestId: s ? P.current : null,
414
+ waiting: !s && z.current !== null
356
415
  };
357
416
  }, [Y]);
358
- y(() => p.subscribe(We), [We]);
359
- let Ge = b(() => u(O, G.tag), [O, G]), Ke = b(() => o(O, G.tag, W[K]), [
360
- O,
417
+ b(() => d.subscribe(it), [it]);
418
+ let at = x(() => l(k, G.tag), [k, G]), ot = x(() => s(k, G.tag, W[K]), [
419
+ k,
361
420
  G,
362
421
  W,
363
422
  K
364
- ]), qe = b(() => ({
423
+ ]), st = x(() => ({
365
424
  isSupported: U,
366
425
  availability: J,
367
426
  isBlocked: J === "no-voices",
368
- disabledReason: J === "no-voices" ? w("speech.noVoicesOnDevice", "This device has no speech voices installed. Add one in your device speech or accessibility settings.") : null,
369
- blockedFor: Ie,
370
- voiceChoices: Ge,
371
- spokenChunks: ce(E, Te),
372
- activeVoiceName: Ke?.name ?? null,
427
+ disabledReason: J === "no-voices" ? T("speech.noVoicesOnDevice", "This device has no speech voices installed. Add one in your device speech or accessibility settings.") : null,
428
+ blockedFor: Ye,
429
+ deviceFallbackFor: Xe,
430
+ voiceChoices: at,
431
+ spokenChunks: de(D, Ne),
432
+ activeVoiceName: ot?.name ?? null,
373
433
  preferredVoiceName: W[K] ?? null,
374
- setVoice: (e) => Me(K, e),
375
- speakingMessageId: E.status === "speaking" ? E.messageId : null,
376
- outputNotCleared: Ce,
377
- isSpeaking: (e) => se(E, e),
378
- toggle: Re,
434
+ setVoice: (e) => Ge(K, e),
435
+ speakingMessageId: D.status === "speaking" ? D.messageId : null,
436
+ outputNotCleared: je,
437
+ isSpeaking: (e) => ue(D, e),
438
+ toggle: Qe,
379
439
  stop: Y,
380
- autoSpeakEnabled: z,
381
- setAutoSpeak: De,
382
- sessionSpeaking: B,
383
- setSessionSpeaking: Oe,
384
- setSessionMicOpen: ke,
440
+ autoSpeakEnabled: V,
441
+ setAutoSpeak: Ie,
442
+ sessionSpeaking: H,
443
+ setSessionSpeaking: Le,
444
+ setSessionMicOpen: ze,
385
445
  speakFinishedReply: $,
386
- previewVoice: Fe
446
+ previewVoice: Je
387
447
  }), [
388
448
  U,
389
449
  J,
390
- Ie,
391
- Ge,
392
- Ke,
450
+ Ye,
451
+ Xe,
452
+ at,
453
+ ot,
393
454
  W,
394
- Me,
455
+ Ge,
395
456
  K,
396
- E,
397
- Ce,
398
- Re,
457
+ D,
458
+ je,
459
+ Qe,
399
460
  Y,
400
- z,
401
- De,
402
- B,
403
- ke,
461
+ V,
462
+ Ie,
463
+ H,
464
+ ze,
404
465
  $,
405
- Fe,
406
- w,
407
- Te
466
+ Je,
467
+ T,
468
+ Ne
408
469
  ]);
409
- return /* @__PURE__ */ he(ve.Provider, {
410
- value: qe,
411
- children: fe
470
+ return /* @__PURE__ */ be(De.Provider, {
471
+ value: st,
472
+ children: f
412
473
  });
413
474
  };
414
475
  //#endregion
415
- export { be as AssistantSpeechProvider, ye as useAssistantSpeech };
476
+ export { E as AssistantSpeechProvider, T as useAssistantSpeech };