@burdenoff/fe-libs 2026.1014.3 → 2026.1014.4

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.
@@ -1,9 +1,9 @@
1
1
  import { AvatarNotReadyError as e, LiveKitAvatarTransport as t } from "./avatarTransport.js";
2
2
  import { createAvatarTransportPort as n } from "./avatarTransportPort.js";
3
3
  import { createAvatarReplyOutputs as r } from "./avatarReplyOutputs.js";
4
- import { AvatarApiError as i, avatarRefusalFor as a } from "./avatarSessionClient.js";
4
+ import { AvatarApiError as i, avatarAvailabilityRefusal as a, avatarRefusalFor as o } from "./avatarSessionClient.js";
5
5
  //#region src/shared/assistant/avatar/live/liveAvatarController.ts
6
- var o = 12e4, s = 1e4, c = 8e3, l = 5e3, u = 2e4, d = {
6
+ var s = 12e4, c = 1e4, l = 8e3, u = 5e3, d = 2e4, f = {
7
7
  voiceLive: !1,
8
8
  offered: !1,
9
9
  phase: "off",
@@ -15,8 +15,13 @@ var o = 12e4, s = 1e4, c = 8e3, l = 5e3, u = 2e4, d = {
15
15
  audioBlocked: !1,
16
16
  videoReady: !1
17
17
  };
18
- function f(e) {
18
+ function p(e) {
19
19
  switch (e) {
20
+ case "permission_revoked": return {
21
+ problem: "unavailable",
22
+ notice: null,
23
+ hide: !0
24
+ };
20
25
  case "start_superseded": return {
21
26
  problem: "already-running",
22
27
  notice: null
@@ -46,69 +51,72 @@ function f(e) {
46
51
  };
47
52
  }
48
53
  }
49
- var p = new Set(["playback-blocked", "needs-hosted-voice"]);
50
- function m(o) {
51
- let { scheduler: s, preferences: c } = o, u = o.idleMs ?? 12e4, m = o.endBeforeDeadlineMs ?? 1e4, h = o.connectTimeoutMs ?? 2e4, g = o.requestTimeoutMs ?? 8e3, _ = d, v = /* @__PURE__ */ new Set(), y = !1, b = null, x = 0, S = !1, C = !1, w = 0, T = null, E = null, D = null, O = 0, k = !1, A = null, j = null, M = !1;
52
- function N(e) {
54
+ var m = new Set(["playback-blocked", "needs-hosted-voice"]), h = {
55
+ problem: "unavailable",
56
+ hide: !0
57
+ };
58
+ function g(s) {
59
+ let { scheduler: c, preferences: l } = s, d = s.idleMs ?? 12e4, g = s.endBeforeDeadlineMs ?? 1e4, _ = s.connectTimeoutMs ?? 2e4, v = s.requestTimeoutMs ?? 8e3, y = f, b = /* @__PURE__ */ new Set(), x = !1, S = null, C = 0, w = !1, T = !1, E = 0, D = null, O = null, k = null, A = 0, j = !1, M = null, N = null, P = !1;
60
+ function F(e) {
53
61
  try {
54
- o.onLog?.(e);
62
+ s.onLog?.(e);
55
63
  } catch {}
56
64
  }
57
- function P(e) {
58
- return e && !y && o.browserSupported();
65
+ function I(e) {
66
+ return e && !x && s.browserSupported();
59
67
  }
60
- function F(e) {
68
+ function L(e) {
61
69
  let t = {
62
- ..._,
70
+ ...y,
63
71
  ...e
64
- }, n = P(t.voiceLive), r = {
72
+ }, n = I(t.voiceLive), r = {
65
73
  ...t,
66
74
  offered: n
67
75
  };
68
- if (!Object.keys(r).every((e) => r[e] === _[e])) {
69
- _ = r;
70
- for (let e of [...v]) try {
76
+ if (!Object.keys(r).every((e) => r[e] === y[e])) {
77
+ y = r;
78
+ for (let e of [...b]) try {
71
79
  e();
72
80
  } catch {}
73
81
  }
74
82
  }
75
- function I() {
76
- c.getState().avatarEnabled !== S && c.setAvatarEnabled(S);
83
+ function R() {
84
+ l.getState().avatarEnabled !== w && l.setAvatarEnabled(w);
77
85
  }
78
- let L = {
86
+ let z = {
79
87
  positionSec: null,
80
88
  synthetic: !0,
81
89
  rpc: "none"
82
- }, R = r({
90
+ }, B = r({
83
91
  port: {
84
- isActive: () => E !== null && E.port.isActive(),
85
- isAudioBlocked: () => E?.port.isAudioBlocked() ?? !1,
86
- connectionId: () => E?.port.connectionId() ?? 0,
87
- isMeterHealthy: () => E?.port.isMeterHealthy() ?? !1,
88
- isMeterAudible: () => E?.port.isMeterAudible() ?? !1,
89
- openSegment: () => E ? E.port.openSegment() : Promise.reject(new e("connection")),
90
- clearBuffer: (e) => E ? E.port.clearBuffer(e) : Promise.resolve(L),
91
- setOutputMuted: (e) => E?.port.setOutputMuted(e),
92
- subscribe: (e) => E ? E.port.subscribe(e) : () => void 0
92
+ isActive: () => O !== null && O.port.isActive(),
93
+ isAudioBlocked: () => O?.port.isAudioBlocked() ?? !1,
94
+ connectionId: () => O?.port.connectionId() ?? 0,
95
+ isMeterHealthy: () => O?.port.isMeterHealthy() ?? !1,
96
+ isMeterAudible: () => O?.port.isMeterAudible() ?? !1,
97
+ openSegment: () => O ? O.port.openSegment() : Promise.reject(new e("connection")),
98
+ clearBuffer: (e) => O ? O.port.clearBuffer(e) : Promise.resolve(z),
99
+ setOutputMuted: (e) => O?.port.setOutputMuted(e),
100
+ subscribe: (e) => O ? O.port.subscribe(e) : () => void 0
93
101
  },
94
- scheduler: s,
95
- decode: o.decode,
96
- ...o.trackerConfig ? { trackerConfig: o.trackerConfig } : {},
97
- ...o.maxDrainMs === void 0 ? {} : { maxDrainMs: o.maxDrainMs },
98
- ...o.stallMs === void 0 ? {} : { stallMs: o.stallMs },
102
+ scheduler: c,
103
+ decode: s.decode,
104
+ ...s.trackerConfig ? { trackerConfig: s.trackerConfig } : {},
105
+ ...s.maxDrainMs === void 0 ? {} : { maxDrainMs: s.maxDrainMs },
106
+ ...s.stallMs === void 0 ? {} : { stallMs: s.stallMs },
99
107
  onNotice: (e) => {
100
- switch (N({
108
+ switch (F({
101
109
  event: "notice",
102
110
  notice: e
103
111
  }), e.kind) {
104
112
  case "interrupted":
105
- F({ notice: "interrupted" });
113
+ L({ notice: "interrupted" });
106
114
  return;
107
115
  case "voice-fallback":
108
- S && F({ notice: "voice-only" });
116
+ w && L({ notice: "voice-only" });
109
117
  return;
110
118
  case "audio-blocked":
111
- F({
119
+ L({
112
120
  audioBlocked: !0,
113
121
  problem: "playback-blocked"
114
122
  });
@@ -118,28 +126,28 @@ function m(o) {
118
126
  },
119
127
  onActivity: (e) => {
120
128
  if (e) {
121
- A?.(), A = null;
129
+ M?.(), M = null;
122
130
  return;
123
131
  }
124
- if (C) {
125
- H("user", { notice: "time-limit" });
132
+ if (T) {
133
+ W("user", { notice: "time-limit" });
126
134
  return;
127
135
  }
128
- z();
136
+ V();
129
137
  }
130
138
  });
131
- function z() {
132
- A?.(), A = null, _.phase === "ready" && (A = s.setTimeout(() => {
133
- A = null, _.phase === "ready" && !R.isBusy() && H("idle", {});
134
- }, u));
139
+ function V() {
140
+ M?.(), M = null, y.phase === "ready" && (M = c.setTimeout(() => {
141
+ M = null, y.phase === "ready" && !B.isBusy() && W("idle", {});
142
+ }, d));
135
143
  }
136
- function B() {
137
- A?.(), A = null, j?.(), j = null;
144
+ function H() {
145
+ M?.(), M = null, N?.(), N = null;
138
146
  }
139
- function V() {
140
- R.leave();
141
- let e = E;
142
- if (E = null, e !== null) {
147
+ function U() {
148
+ B.leave();
149
+ let e = O;
150
+ if (O = null, e !== null) {
143
151
  if (e.unsubscribe?.(), e.meter !== null) {
144
152
  if (e.meterAudible) {
145
153
  e.meterAudible = !1;
@@ -147,193 +155,194 @@ function m(o) {
147
155
  }
148
156
  e.meter.stop();
149
157
  }
150
- e.videoTrack?.detach(), e.transport.dispose(), e.audioElement !== null && o.releaseAudioElement(e.audioElement);
158
+ e.videoTrack?.detach(), e.transport.dispose(), e.audioElement !== null && s.releaseAudioElement(e.audioElement);
151
159
  }
152
160
  }
153
- function H(e, t) {
154
- w += 1, S = !1, C = !1, V(), B();
155
- let n = T;
156
- T = null, I(), n !== null && (N({
161
+ function W(e, t) {
162
+ E += 1, w = !1, T = !1, U(), H();
163
+ let n = D;
164
+ D = null, R(), n !== null && (F({
157
165
  event: "session-ended",
158
166
  reason: e
159
- }), o.client()?.end(n, {
167
+ }), s.client()?.end(n, {
160
168
  reason: e,
161
169
  keepalive: t.keepalive === !0
162
- }).catch(() => void 0)), F({
170
+ }).catch(() => void 0)), L({
163
171
  phase: "off",
164
172
  audioBlocked: !1,
165
173
  videoReady: !1,
166
- ...t.problem === void 0 ? _.problem !== null && p.has(_.problem) ? { problem: null } : {} : { problem: t.problem },
174
+ ...t.problem === void 0 ? y.problem !== null && m.has(y.problem) ? { problem: null } : {} : { problem: t.problem },
167
175
  ...t.notice === void 0 ? {} : { notice: t.notice }
168
176
  });
169
177
  }
170
- function U(e) {
171
- let t = a(e);
172
- t.hide && (y = !0), e instanceof i && N({
178
+ function G(e) {
179
+ let t = o(e);
180
+ return t.hide && (x = !0), e instanceof i && F({
173
181
  event: "refused",
174
182
  status: e.status,
175
183
  code: e.code
176
- }), S = !1, I(), F({
184
+ }), w = !1, R(), L({
177
185
  phase: "off",
178
186
  problem: t.problem
179
- });
187
+ }), t;
180
188
  }
181
- function W() {
182
- y = !0, S = !1, I(), F({
189
+ function K(e = h) {
190
+ e.hide && (x = !0), w = !1, R(), L({
183
191
  phase: "off",
184
- problem: "unavailable",
192
+ problem: e.problem,
185
193
  avatars: []
186
194
  });
187
195
  }
188
- function G(e) {
196
+ function q(e) {
189
197
  switch (e.type) {
190
198
  case "audioPlayback":
191
- e.canPlay ? _.problem === "playback-blocked" ? F({
199
+ e.canPlay ? y.problem === "playback-blocked" ? L({
192
200
  audioBlocked: !1,
193
201
  problem: null
194
- }) : F({ audioBlocked: !1 }) : F({
202
+ }) : L({ audioBlocked: !1 }) : L({
195
203
  audioBlocked: !0,
196
204
  problem: "playback-blocked"
197
205
  });
198
206
  return;
199
207
  case "avatarLeft":
200
208
  case "disconnected":
201
- K();
209
+ J();
202
210
  return;
203
211
  default: return;
204
212
  }
205
213
  }
206
- async function K() {
207
- let e = T;
208
- if (e === null || _.phase === "ending" || _.phase === "off") return;
209
- let t = w;
210
- F({ phase: "ending" });
214
+ async function J() {
215
+ let e = D;
216
+ if (e === null || y.phase === "ending" || y.phase === "off") return;
217
+ let t = E;
218
+ L({ phase: "ending" });
211
219
  let n = null, r = !1;
212
220
  try {
213
- let t = o.client(), i = t === null ? void 0 : await J((n) => t.status(e, n));
221
+ let t = s.client(), i = t === null ? void 0 : await X((n) => t.status(e, n));
214
222
  n = i?.endedReason ?? null, r = i !== void 0 && [
215
223
  "ended",
216
224
  "failed",
217
225
  "canceled"
218
226
  ].includes(i.state);
219
227
  } catch {}
220
- if (w !== t) return;
221
- let i = f(n);
222
- r && (T = null, N({
228
+ if (E !== t) return;
229
+ let i = p(n);
230
+ i.hide && (x = !0), r && (D = null, F({
223
231
  event: "session-ended",
224
232
  reason: "server"
225
- })), H("client_error", i);
233
+ })), W("client_error", i);
226
234
  }
227
- async function q(e, r) {
228
- let i = o.client();
235
+ async function Y(e, r) {
236
+ let i = s.client();
229
237
  if (i === null) {
230
- W();
238
+ K();
231
239
  return;
232
240
  }
233
- let a = ++w;
234
- F({
241
+ let a = ++E;
242
+ L({
235
243
  phase: "starting",
236
244
  problem: null,
237
245
  notice: null
238
246
  });
239
- let c;
247
+ let o;
240
248
  try {
241
- c = await o.openRoom();
249
+ o = await s.openRoom();
242
250
  } catch {
243
- w === a && W();
251
+ E === a && K();
244
252
  return;
245
253
  }
246
- let u = () => {
247
- c.disconnect().catch(() => void 0);
254
+ let l = () => {
255
+ o.disconnect().catch(() => void 0);
248
256
  };
249
- if (w !== a) {
250
- u();
257
+ if (E !== a) {
258
+ l();
251
259
  return;
252
260
  }
253
- let d = s.now(), f;
261
+ let d = c.now(), f;
254
262
  try {
255
263
  f = await i.create({
256
264
  avatarId: e,
257
265
  consentVersion: r,
258
- idempotencyKey: o.newIdempotencyKey()
266
+ idempotencyKey: s.newIdempotencyKey()
259
267
  });
260
268
  } catch (e) {
261
- u(), w === a && U(e);
269
+ if (l(), E !== a) return;
270
+ G(e).showDisclosure && (S = null, $.requestOn());
262
271
  return;
263
272
  }
264
- if (w !== a) {
265
- u(), i.end(f.sessionId, { reason: k ? "voice_end" : "user" }).catch(() => void 0);
273
+ if (E !== a) {
274
+ l(), i.end(f.sessionId, { reason: j ? "voice_end" : "user" }).catch(() => void 0);
266
275
  return;
267
276
  }
268
- T = f.sessionId, F({ phase: "connecting" });
277
+ D = f.sessionId, L({ phase: "connecting" });
269
278
  let p = new t({
270
- room: c,
279
+ room: o,
271
280
  avatarIdentity: f.avatarIdentity,
272
- scheduler: s,
273
- ...o.readinessProbe === void 0 ? {} : { readinessProbe: o.readinessProbe }
274
- }), g = /* @__PURE__ */ new Set(), _ = {
281
+ scheduler: c,
282
+ ...s.readinessProbe === void 0 ? {} : { readinessProbe: s.readinessProbe }
283
+ }), m = /* @__PURE__ */ new Set(), h = {
275
284
  session: f,
276
285
  transport: p,
277
- audioElement: o.createAudioElement(),
286
+ audioElement: s.createAudioElement(),
278
287
  meter: null,
279
288
  meterAudible: !1,
280
- meterListeners: g,
289
+ meterListeners: m,
281
290
  videoTrack: null,
282
291
  unsubscribe: null,
283
292
  port: n({
284
293
  transport: p,
285
- isEnabled: () => S && !C,
286
- subscribeMeter: (e) => (g.add(e), () => {
287
- g.delete(e);
294
+ isEnabled: () => w && !T,
295
+ subscribeMeter: (e) => (m.add(e), () => {
296
+ m.delete(e);
288
297
  }),
289
- isMeterHealthy: () => _.meter?.isRunning() ?? !1
298
+ isMeterHealthy: () => h.meter?.isRunning() ?? !1
290
299
  })
291
300
  };
292
- E = _, _.unsubscribe = p.subscribe(G);
301
+ O = h, h.unsubscribe = p.subscribe(q);
293
302
  try {
294
- await Y(p.connect({
303
+ await Z(p.connect({
295
304
  url: f.livekitUrl,
296
305
  token: f.participantToken,
297
- audioElement: _.audioElement,
306
+ audioElement: h.audioElement,
298
307
  onAvatarAudio: (e) => {
299
- if (!(e.mediaStreamTrack === null || _.meter !== null)) try {
300
- _.meter = o.startMeter(e.mediaStreamTrack, (e) => {
301
- _.meterAudible = e;
302
- for (let t of [...g]) t(e);
308
+ if (!(e.mediaStreamTrack === null || h.meter !== null)) try {
309
+ h.meter = s.startMeter(e.mediaStreamTrack, (e) => {
310
+ h.meterAudible = e;
311
+ for (let t of [...m]) t(e);
303
312
  });
304
313
  } catch {
305
- _.meter = null;
314
+ h.meter = null;
306
315
  }
307
316
  },
308
317
  onAvatarVideo: (e) => {
309
- _.videoTrack = e, D !== null && e.attach(D), E === _ && F({ videoReady: !0 });
318
+ h.videoTrack = e, k !== null && e.attach(k), O === h && L({ videoReady: !0 });
310
319
  }
311
- }), h);
320
+ }), _);
312
321
  } catch (e) {
313
- if (w !== a) return;
314
- N({
322
+ if (E !== a) return;
323
+ F({
315
324
  event: "connect-failed",
316
325
  error: e instanceof Error ? e.name : "error"
317
- }), H("client_error", { problem: "connection" });
326
+ }), W("client_error", { problem: "connection" });
318
327
  return;
319
328
  }
320
- if (w !== a || E !== _) return;
321
- F({
329
+ if (E !== a || O !== h) return;
330
+ L({
322
331
  phase: "ready",
323
332
  audioBlocked: p.audioBlocked,
324
333
  ...p.audioBlocked ? { problem: "playback-blocked" } : {}
325
- }), z();
326
- let v = x > 0 ? d + x - l - s.now() : f.endsAt - o.now(), y = Math.max(0, v - m);
327
- j = s.setTimeout(() => {
328
- j = null, w === a && (C = !0, R.isBusy() || H("user", { notice: "time-limit" }));
334
+ }), V();
335
+ let v = C > 0 ? d + C - u - c.now() : f.endsAt - s.now(), y = Math.max(0, v - g);
336
+ N = c.setTimeout(() => {
337
+ N = null, E === a && (T = !0, B.isBusy() || W("user", { notice: "time-limit" }));
329
338
  }, y);
330
339
  }
331
- function J(t) {
340
+ function X(t) {
332
341
  let n = new AbortController();
333
342
  return new Promise((r, i) => {
334
- let a = s.setTimeout(() => {
343
+ let a = c.setTimeout(() => {
335
344
  n.abort(), i(new e("connection"));
336
- }, g);
345
+ }, v);
337
346
  t(n.signal).then((e) => {
338
347
  a(), r(e);
339
348
  }, (e) => {
@@ -341,9 +350,9 @@ function m(o) {
341
350
  });
342
351
  });
343
352
  }
344
- function Y(t, n) {
353
+ function Z(t, n) {
345
354
  return new Promise((r, i) => {
346
- let a = s.setTimeout(() => i(new e("connection")), n);
355
+ let a = c.setTimeout(() => i(new e("connection")), n);
347
356
  t.then((e) => {
348
357
  a(), r(e);
349
358
  }, (e) => {
@@ -351,138 +360,138 @@ function m(o) {
351
360
  });
352
361
  });
353
362
  }
354
- let X = [];
355
- X.push(c.subscribe(() => {
356
- let e = c.getState().avatarEnabled;
357
- if (e !== S) {
363
+ let Q = [];
364
+ Q.push(l.subscribe(() => {
365
+ let e = l.getState().avatarEnabled;
366
+ if (e !== w) {
358
367
  if (e) {
359
- c.setAvatarEnabled(!1);
368
+ l.setAvatarEnabled(!1);
360
369
  return;
361
370
  }
362
- _.phase !== "off" && _.phase !== "checking" && _.phase !== "choosing" ? H(k ? "voice_end" : "user", {}) : S = !1;
371
+ y.phase !== "off" && y.phase !== "checking" && y.phase !== "choosing" ? W(j ? "voice_end" : "user", {}) : w = !1;
363
372
  }
364
- })), o.subscribeWorkspaceChange && X.push(o.subscribeWorkspaceChange(() => {
365
- if (y = !1, _.phase === "off") {
366
- F({
373
+ })), s.subscribeWorkspaceChange && Q.push(s.subscribeWorkspaceChange(() => {
374
+ if (x = !1, y.phase === "off") {
375
+ L({
367
376
  problem: null,
368
377
  avatars: [],
369
378
  consentVersion: null
370
379
  });
371
380
  return;
372
381
  }
373
- H("workspace_switch", { problem: null }), F({
382
+ W("workspace_switch", { problem: null }), L({
374
383
  avatars: [],
375
384
  consentVersion: null
376
385
  });
377
- })), o.subscribePageHide && X.push(o.subscribePageHide(() => {
378
- (T !== null || _.phase !== "off") && H("page_hide", { keepalive: !0 });
386
+ })), s.subscribePageHide && Q.push(s.subscribePageHide(() => {
387
+ (D !== null || y.phase !== "off") && W("page_hide", { keepalive: !0 });
379
388
  }));
380
- let Z = {
389
+ let $ = {
381
390
  subscribe(e) {
382
- return v.add(e), () => {
383
- v.delete(e);
391
+ return b.add(e), () => {
392
+ b.delete(e);
384
393
  };
385
394
  },
386
- getSnapshot: () => _,
395
+ getSnapshot: () => y,
387
396
  setVoiceLive(e) {
388
- if (k = !e, e) {
389
- F({
397
+ if (j = !e, e) {
398
+ L({
390
399
  voiceLive: !0,
391
- problem: y ? _.problem : null,
400
+ problem: x ? y.problem : null,
392
401
  notice: null
393
402
  });
394
403
  return;
395
404
  }
396
- (T !== null || _.phase !== "off") && (_.phase === "checking" || _.phase === "choosing" ? (w += 1, F({ phase: "off" })) : H("voice_end", {})), F({
405
+ (D !== null || y.phase !== "off") && (y.phase === "checking" || y.phase === "choosing" ? (E += 1, L({ phase: "off" })) : W("voice_end", {})), L({
397
406
  voiceLive: !1,
398
407
  notice: null
399
408
  });
400
409
  },
401
410
  requestOn() {
402
- if (M || !_.offered || _.phase !== "off") return;
403
- let e = o.client();
411
+ if (P || !y.offered || y.phase !== "off") return;
412
+ let e = s.client();
404
413
  if (e === null) {
405
- W();
414
+ K();
406
415
  return;
407
416
  }
408
- let t = ++w;
409
- F({
417
+ let t = ++E;
418
+ L({
410
419
  phase: "checking",
411
420
  problem: null,
412
421
  notice: null
413
- }), J((t) => e.availability(t)).then((e) => {
414
- if (w !== t) return;
422
+ }), X((t) => e.availability(t)).then((e) => {
423
+ if (E !== t) return;
415
424
  if (!e.available) {
416
- W();
425
+ K(a(e.reason));
417
426
  return;
418
427
  }
419
- x = e.maxSessionSeconds * 1e3;
420
- let n = c.getState().avatarId, r = n !== null && e.avatars.includes(n) ? n : e.avatars[0] ?? null;
421
- F({
428
+ C = e.maxSessionSeconds * 1e3;
429
+ let n = l.getState().avatarId, r = n !== null && e.avatars.includes(n) ? n : e.avatars[0] ?? null;
430
+ L({
422
431
  phase: "choosing",
423
432
  avatars: e.avatars,
424
433
  selectedAvatarId: r,
425
434
  consentVersion: e.consentVersion
426
- }), b === e.consentVersion && e.avatars.length === 1 && Z.confirm();
435
+ }), S === e.consentVersion && e.avatars.length === 1 && $.confirm();
427
436
  }, (e) => {
428
- w === t && U(e);
437
+ E === t && G(e);
429
438
  });
430
439
  },
431
440
  confirm() {
432
- if (_.phase !== "choosing" || !_.voiceLive) return;
433
- let e = _.selectedAvatarId, t = _.consentVersion;
434
- e === null || t === null || (b = t, c.setAvatarId(e), S = !0, I(), q(e, t));
441
+ if (y.phase !== "choosing" || !y.voiceLive) return;
442
+ let e = y.selectedAvatarId, t = y.consentVersion;
443
+ e === null || t === null || (S = t, l.setAvatarId(e), w = !0, R(), Y(e, t));
435
444
  },
436
445
  cancelChoice() {
437
- _.phase === "choosing" && (w += 1, F({ phase: "off" }));
446
+ y.phase === "choosing" && (E += 1, L({ phase: "off" }));
438
447
  },
439
448
  selectAvatar(e) {
440
- _.avatars.includes(e) && F({ selectedAvatarId: e });
449
+ y.avatars.includes(e) && L({ selectedAvatarId: e });
441
450
  },
442
451
  switchOff() {
443
- if (_.phase === "checking" || _.phase === "choosing") {
444
- w += 1, F({ phase: "off" });
452
+ if (y.phase === "checking" || y.phase === "choosing") {
453
+ E += 1, L({ phase: "off" });
445
454
  return;
446
455
  }
447
- if (_.phase === "off" && !S) {
448
- I();
456
+ if (y.phase === "off" && !w) {
457
+ R();
449
458
  return;
450
459
  }
451
- H(k ? "voice_end" : "user", {});
460
+ W(j ? "voice_end" : "user", {});
452
461
  },
453
462
  resumeAudio() {
454
- let e = E;
463
+ let e = O;
455
464
  e !== null && (e.transport.resumeAudio().catch(() => void 0), e.meter?.resume().catch(() => void 0));
456
465
  },
457
466
  setStageMounted(e) {
458
- O = Math.max(0, O + (e ? 1 : -1));
467
+ A = Math.max(0, A + (e ? 1 : -1));
459
468
  },
460
469
  attachVideo(e) {
461
- let t = E?.videoTrack ?? null;
470
+ let t = O?.videoTrack ?? null;
462
471
  if (e === null) {
463
- D !== null && t?.detach(), D = null;
472
+ k !== null && t?.detach(), k = null;
464
473
  return;
465
474
  }
466
- D = e, t?.attach(e);
475
+ k = e, t?.attach(e);
467
476
  },
468
477
  route(e, t) {
469
- if (_.phase !== "ready" || C || !S || O === 0 || E === null || E.port.isAudioBlocked() || e.fallback === !1) return "speakers";
478
+ if (y.phase !== "ready" || T || !w || A === 0 || O === null || O.port.isAudioBlocked() || e.fallback === !1) return "speakers";
470
479
  let n = e.voice;
471
- return n !== null && n.source !== "hosted" || !t.listVoices().some((e) => e.source === "hosted") ? (N({
480
+ return n !== null && n.source !== "hosted" || !t.listVoices().some((e) => e.source === "hosted") ? (F({
472
481
  event: "notice",
473
482
  notice: { kind: "needs-hosted-voice" }
474
- }), F({ problem: "needs-hosted-voice" }), "speakers") : (_.problem === "needs-hosted-voice" && F({ problem: null }), "avatar");
483
+ }), L({ problem: "needs-hosted-voice" }), "speakers") : (y.problem === "needs-hosted-voice" && L({ problem: null }), "avatar");
475
484
  },
476
- createOutput: () => R.createOutput(),
485
+ createOutput: () => B.createOutput(),
477
486
  dispose() {
478
- if (!M) {
479
- M = !0, (T !== null || _.phase !== "off") && H("user", {});
480
- for (let e of X.splice(0)) e();
481
- v.clear();
487
+ if (!P) {
488
+ P = !0, (D !== null || y.phase !== "off") && W("user", {});
489
+ for (let e of Q.splice(0)) e();
490
+ b.clear();
482
491
  }
483
492
  }
484
493
  };
485
- return Z;
494
+ return $;
486
495
  }
487
496
  //#endregion
488
- export { u as LIVE_AVATAR_CONNECT_TIMEOUT_MS, s as LIVE_AVATAR_END_BEFORE_DEADLINE_MS, o as LIVE_AVATAR_IDLE_MS, c as LIVE_AVATAR_REQUEST_TIMEOUT_MS, m as createLiveAvatarController };
497
+ export { d as LIVE_AVATAR_CONNECT_TIMEOUT_MS, c as LIVE_AVATAR_END_BEFORE_DEADLINE_MS, s as LIVE_AVATAR_IDLE_MS, l as LIVE_AVATAR_REQUEST_TIMEOUT_MS, g as createLiveAvatarController };
@@ -17,7 +17,7 @@
17
17
  * word for word by `avatarConsentCopy.test.ts`.
18
18
  */
19
19
  /** What the person can be told went wrong; the adapter maps server codes onto these. */
20
- export type AvatarProblem = 'unavailable' | 'not-ready' | 'already-running' | 'capacity' | 'rate-limited' | 'paused' | 'provider' | 'connection' | 'needs-hosted-voice' | 'unsupported-browser' | 'playback-blocked';
20
+ export type AvatarProblem = 'unavailable' | 'not-ready' | 'already-running' | 'capacity' | 'rate-limited' | 'paused' | 'start-timeout' | 'provider' | 'connection' | 'needs-hosted-voice' | 'unsupported-browser' | 'playback-blocked';
21
21
  export interface AvatarCopy {
22
22
  toggle: string;
23
23
  toggleHint: string;