@burdenoff/fe-libs 2026.1023.16 → 2026.1024.2

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.
@@ -3,7 +3,7 @@ import { createAvatarTransportPort as n } from "./avatarTransportPort.js";
3
3
  import { createAvatarReplyOutputs as r } from "./avatarReplyOutputs.js";
4
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 s = 12e4, c = 1e4, l = 8e3, ee = 5e3, u = 2e4, d = 1e3, f = {
6
+ var s = 12e4, c = 1e4, l = 8e3, ee = 5e3, u = 2e4, te = 1e3, d = {
7
7
  voiceLive: !1,
8
8
  offered: !1,
9
9
  tabOpen: !1,
@@ -16,11 +16,12 @@ var s = 12e4, c = 1e4, l = 8e3, ee = 5e3, u = 2e4, d = 1e3, f = {
16
16
  selectedAvatarId: null,
17
17
  consentVersion: null,
18
18
  problem: null,
19
+ budgetScope: null,
19
20
  notice: null,
20
21
  audioBlocked: !1,
21
22
  videoReady: !1
22
23
  };
23
- function p(e) {
24
+ function f(e) {
24
25
  switch (e) {
25
26
  case "permission_revoked": return {
26
27
  problem: "unavailable",
@@ -56,53 +57,53 @@ function p(e) {
56
57
  };
57
58
  }
58
59
  }
59
- var m = new Set(["playback-blocked", "needs-hosted-voice"]), h = {
60
+ var p = new Set(["playback-blocked", "needs-hosted-voice"]), m = {
60
61
  problem: "unavailable",
61
62
  hide: !0
62
63
  };
63
- function g(s) {
64
- let { scheduler: c, preferences: l } = s, u = s.idleMs ?? 12e4, d = s.endBeforeDeadlineMs ?? 1e4, g = s.connectTimeoutMs ?? 2e4, _ = s.requestTimeoutMs ?? 8e3, v = {
65
- ...f,
64
+ function h(s) {
65
+ let { scheduler: c, preferences: l } = s, u = s.idleMs ?? 12e4, te = s.endBeforeDeadlineMs ?? 1e4, h = s.connectTimeoutMs ?? 2e4, g = s.requestTimeoutMs ?? 8e3, _ = {
66
+ ...d,
66
67
  tabOffered: s.browserSupported()
67
- }, y = /* @__PURE__ */ new Set(), b = !1, x = null, S = 0, C = !1, w = !1, T = 0, E = null, D = null, O = [], k = 0, A = !1, te = "user", j = !1, M = !1, N = null, P = null, F = null, I = null, L = !1;
68
+ }, v = /* @__PURE__ */ new Set(), y = !1, b = null, x = 0, S = !1, C = !1, w = 0, T = null, E = null, D = [], O = 0, k = !1, A = "user", j = !1, M = !1, N = null, P = null, F = null, I = null, L = !1;
68
69
  function R(e) {
69
70
  try {
70
71
  s.onLog?.(e);
71
72
  } catch {}
72
73
  }
73
74
  function z() {
74
- return !b && s.browserSupported();
75
+ return !y && s.browserSupported();
75
76
  }
76
77
  function ne(e, t) {
77
78
  return (e || t) && z();
78
79
  }
79
80
  function B() {
80
- return v.retryAt !== null && s.now() < v.retryAt;
81
+ return _.retryAt !== null && s.now() < _.retryAt;
81
82
  }
82
83
  function V(e) {
83
84
  let t = {
84
- ...v,
85
+ ..._,
85
86
  ...e
86
87
  };
87
- e.problem !== void 0 && e.retryAt === void 0 && e.problem !== v.problem && (t.retryAt = null);
88
+ e.problem !== void 0 && e.problem !== _.problem && (e.retryAt === void 0 && (t.retryAt = null), e.budgetScope === void 0 && (t.budgetScope = null));
88
89
  let n = {
89
90
  ...t,
90
91
  offered: ne(t.voiceLive, t.tabOpen),
91
92
  tabOffered: z(),
92
93
  heldByVoice: M && t.voiceLive
93
94
  };
94
- if (!Object.keys(n).every((e) => n[e] === v[e])) {
95
- n.retryAt !== v.retryAt && (I?.(), I = null), v = n;
96
- for (let e of [...y]) try {
95
+ if (!Object.keys(n).every((e) => n[e] === _[e])) {
96
+ n.retryAt !== _.retryAt && (I?.(), I = null), _ = n;
97
+ for (let e of [...v]) try {
97
98
  e();
98
99
  } catch {}
99
100
  }
100
101
  }
101
102
  function H() {
102
- return A && !j ? "voice_end" : "user";
103
+ return k && !j ? "voice_end" : "user";
103
104
  }
104
105
  function U() {
105
- l.getState().avatarEnabled !== C && l.setAvatarEnabled(C);
106
+ l.getState().avatarEnabled !== S && l.setAvatarEnabled(S);
106
107
  }
107
108
  let re = {
108
109
  positionSec: null,
@@ -110,15 +111,15 @@ function g(s) {
110
111
  rpc: "none"
111
112
  }, W = r({
112
113
  port: {
113
- isActive: () => D !== null && D.port.isActive(),
114
- isAudioBlocked: () => D?.port.isAudioBlocked() ?? !1,
115
- connectionId: () => D?.port.connectionId() ?? 0,
116
- isMeterHealthy: () => D?.port.isMeterHealthy() ?? !1,
117
- isMeterAudible: () => D?.port.isMeterAudible() ?? !1,
118
- openSegment: () => D ? D.port.openSegment() : Promise.reject(new e("connection")),
119
- clearBuffer: (e) => D ? D.port.clearBuffer(e) : Promise.resolve(re),
120
- setOutputMuted: (e) => D?.port.setOutputMuted(e),
121
- subscribe: (e) => D ? D.port.subscribe(e) : () => void 0
114
+ isActive: () => E !== null && E.port.isActive(),
115
+ isAudioBlocked: () => E?.port.isAudioBlocked() ?? !1,
116
+ connectionId: () => E?.port.connectionId() ?? 0,
117
+ isMeterHealthy: () => E?.port.isMeterHealthy() ?? !1,
118
+ isMeterAudible: () => E?.port.isMeterAudible() ?? !1,
119
+ openSegment: () => E ? E.port.openSegment() : Promise.reject(new e("connection")),
120
+ clearBuffer: (e) => E ? E.port.clearBuffer(e) : Promise.resolve(re),
121
+ setOutputMuted: (e) => E?.port.setOutputMuted(e),
122
+ subscribe: (e) => E ? E.port.subscribe(e) : () => void 0
122
123
  },
123
124
  scheduler: c,
124
125
  decode: s.decode,
@@ -134,7 +135,7 @@ function g(s) {
134
135
  V({ notice: "interrupted" });
135
136
  return;
136
137
  case "voice-fallback":
137
- C && V({ notice: "voice-only" });
138
+ S && V({ notice: "voice-only" });
138
139
  return;
139
140
  case "audio-blocked":
140
141
  V({
@@ -150,7 +151,7 @@ function g(s) {
150
151
  P?.(), P = null;
151
152
  return;
152
153
  }
153
- if (w) {
154
+ if (C) {
154
155
  K("user", { notice: "time-limit" });
155
156
  return;
156
157
  }
@@ -158,8 +159,8 @@ function g(s) {
158
159
  }
159
160
  });
160
161
  function G() {
161
- P?.(), P = null, v.phase === "ready" && (P = c.setTimeout(() => {
162
- P = null, v.phase === "ready" && !W.isBusy() && K("idle", {});
162
+ P?.(), P = null, _.phase === "ready" && (P = c.setTimeout(() => {
163
+ P = null, _.phase === "ready" && !W.isBusy() && K("idle", {});
163
164
  }, u));
164
165
  }
165
166
  function ie() {
@@ -167,8 +168,8 @@ function g(s) {
167
168
  }
168
169
  function ae() {
169
170
  W.leave();
170
- let e = D;
171
- if (D = null, e !== null) {
171
+ let e = E;
172
+ if (E = null, e !== null) {
172
173
  if (e.unsubscribe?.(), e.meter !== null) {
173
174
  if (e.meterAudible) {
174
175
  e.meterAudible = !1;
@@ -180,9 +181,9 @@ function g(s) {
180
181
  }
181
182
  }
182
183
  function K(e, t) {
183
- T += 1, te = e, C = !1, w = !1, M = !1, N = null, ae(), ie();
184
- let n = E;
185
- E = null, U(), n !== null && (R({
184
+ w += 1, A = e, S = !1, C = !1, M = !1, N = null, ae(), ie();
185
+ let n = T;
186
+ T = null, U(), n !== null && (R({
186
187
  event: "session-ended",
187
188
  reason: e
188
189
  }), s.client()?.end(n, {
@@ -193,31 +194,39 @@ function g(s) {
193
194
  closing: !1,
194
195
  audioBlocked: !1,
195
196
  videoReady: !1,
196
- ...t.problem === void 0 ? v.problem !== null && m.has(v.problem) ? { problem: null } : {} : { problem: t.problem },
197
+ ...t.problem === void 0 ? _.problem !== null && p.has(_.problem) ? { problem: null } : {} : { problem: t.problem },
197
198
  ...t.notice === void 0 ? {} : { notice: t.notice }
198
199
  });
199
200
  }
200
201
  function q(e) {
201
202
  let t = o(e);
202
- t.hide && (b = !0), e instanceof i && R({
203
+ t.hide && (y = !0), e instanceof i && R({
203
204
  event: "refused",
204
205
  status: e.status,
205
206
  code: e.code
206
- }), C = !1, M = !1, N = null, U();
207
+ }), S = !1, M = !1, N = null, U();
207
208
  let n = t.retryAfterSeconds !== void 0 && t.retryAfterSeconds > 0 ? t.retryAfterSeconds * 1e3 : 0, r = n > 0 ? s.now() + n : null;
208
209
  return V({
209
210
  phase: "off",
210
211
  problem: t.problem,
211
- retryAt: r
212
- }), r !== null && v.retryAt === r && (I = c.setTimeout(() => {
213
- I = null, v.retryAt === r && V({
214
- problem: null,
215
- retryAt: null
216
- });
212
+ retryAt: r,
213
+ budgetScope: t.scope ?? null
214
+ }), r !== null && _.retryAt === r && (I = c.setTimeout(() => {
215
+ I = null, J(r);
217
216
  }, n)), t;
218
217
  }
219
- function J(e = h) {
220
- e.hide && (b = !0), C = !1, M = !1, N = null, U(), V({
218
+ function J(e) {
219
+ _.retryAt === e && V({
220
+ problem: null,
221
+ retryAt: null
222
+ });
223
+ }
224
+ function Y() {
225
+ let e = _.retryAt;
226
+ L || e === null || B() || J(e);
227
+ }
228
+ function X(e = m) {
229
+ e.hide && (y = !0), S = !1, M = !1, N = null, U(), V({
221
230
  phase: "off",
222
231
  problem: e.problem,
223
232
  retryAt: null,
@@ -227,7 +236,7 @@ function g(s) {
227
236
  function oe(e) {
228
237
  switch (e.type) {
229
238
  case "audioPlayback":
230
- e.canPlay ? v.problem === "playback-blocked" ? V({
239
+ e.canPlay ? _.problem === "playback-blocked" ? V({
231
240
  audioBlocked: !1,
232
241
  problem: null
233
242
  }) : V({ audioBlocked: !1 }) : V({
@@ -243,22 +252,22 @@ function g(s) {
243
252
  }
244
253
  }
245
254
  async function se() {
246
- let e = E;
247
- if (e === null || v.phase === "ending" || v.phase === "off") return;
248
- let t = T;
255
+ let e = T;
256
+ if (e === null || _.phase === "ending" || _.phase === "off") return;
257
+ let t = w;
249
258
  V({ phase: "ending" });
250
259
  let n = null, r = !1;
251
260
  try {
252
- let t = s.client(), i = t === null ? void 0 : await Y((n) => t.status(e, n));
261
+ let t = s.client(), i = t === null ? void 0 : await le((n) => t.status(e, n));
253
262
  n = i?.endedReason ?? null, r = i !== void 0 && [
254
263
  "ended",
255
264
  "failed",
256
265
  "canceled"
257
266
  ].includes(i.state);
258
267
  } catch {}
259
- if (T !== t) return;
260
- let i = p(n);
261
- i.hide && (b = !0), r && (E = null, R({
268
+ if (w !== t) return;
269
+ let i = f(n);
270
+ i.hide && (y = !0), r && (T = null, R({
262
271
  event: "session-ended",
263
272
  reason: "server"
264
273
  })), K("client_error", i);
@@ -266,10 +275,10 @@ function g(s) {
266
275
  async function ce(e, r) {
267
276
  let i = s.client();
268
277
  if (i === null) {
269
- J();
278
+ X();
270
279
  return;
271
280
  }
272
- let a = ++T;
281
+ let a = ++w;
273
282
  V({
274
283
  phase: "starting",
275
284
  problem: null,
@@ -279,103 +288,103 @@ function g(s) {
279
288
  try {
280
289
  o = await s.openRoom();
281
290
  } catch {
282
- T === a && J();
291
+ w === a && X();
283
292
  return;
284
293
  }
285
294
  let l = () => {
286
295
  o.disconnect().catch(() => void 0);
287
296
  };
288
- if (T !== a) {
297
+ if (w !== a) {
289
298
  l();
290
299
  return;
291
300
  }
292
- let u = c.now(), f;
301
+ let u = c.now(), d;
293
302
  try {
294
- f = await i.create({
303
+ d = await i.create({
295
304
  avatarId: e,
296
305
  consentVersion: r,
297
306
  idempotencyKey: s.newIdempotencyKey()
298
307
  });
299
308
  } catch (e) {
300
- if (l(), T !== a) return;
301
- q(e).showDisclosure && (x = null, $.requestOn({ start: !1 }));
309
+ if (l(), w !== a) return;
310
+ q(e).showDisclosure && (b = null, $.requestOn({ start: !1 }));
302
311
  return;
303
312
  }
304
- if (T !== a) {
305
- l(), i.end(f.sessionId, { reason: te === "voice_end" ? "voice_end" : "user" }).catch(() => void 0);
313
+ if (w !== a) {
314
+ l(), i.end(d.sessionId, { reason: A === "voice_end" ? "voice_end" : "user" }).catch(() => void 0);
306
315
  return;
307
316
  }
308
- E = f.sessionId, V({ phase: "connecting" });
309
- let p = new t({
317
+ T = d.sessionId, V({ phase: "connecting" });
318
+ let f = new t({
310
319
  room: o,
311
- avatarIdentity: f.avatarIdentity,
320
+ avatarIdentity: d.avatarIdentity,
312
321
  scheduler: c,
313
322
  ...s.readinessProbe === void 0 ? {} : { readinessProbe: s.readinessProbe }
314
- }), m = /* @__PURE__ */ new Set(), h = {
315
- session: f,
316
- transport: p,
323
+ }), p = /* @__PURE__ */ new Set(), m = {
324
+ session: d,
325
+ transport: f,
317
326
  audioElement: s.createAudioElement(),
318
327
  meter: null,
319
328
  meterAudible: !1,
320
- meterListeners: m,
329
+ meterListeners: p,
321
330
  videoTrack: null,
322
331
  unsubscribe: null,
323
332
  port: n({
324
- transport: p,
325
- isEnabled: () => C && !w,
326
- subscribeMeter: (e) => (m.add(e), () => {
327
- m.delete(e);
333
+ transport: f,
334
+ isEnabled: () => S && !C,
335
+ subscribeMeter: (e) => (p.add(e), () => {
336
+ p.delete(e);
328
337
  }),
329
- isMeterHealthy: () => h.meter?.isRunning() ?? !1
338
+ isMeterHealthy: () => m.meter?.isRunning() ?? !1
330
339
  })
331
340
  };
332
- D = h, h.unsubscribe = p.subscribe(oe);
341
+ E = m, m.unsubscribe = f.subscribe(oe);
333
342
  try {
334
- await le(p.connect({
335
- url: f.livekitUrl,
336
- token: f.participantToken,
337
- audioElement: h.audioElement,
343
+ await ue(f.connect({
344
+ url: d.livekitUrl,
345
+ token: d.participantToken,
346
+ audioElement: m.audioElement,
338
347
  onAvatarAudio: (e) => {
339
- if (!(e.mediaStreamTrack === null || h.meter !== null)) try {
340
- h.meter = s.startMeter(e.mediaStreamTrack, (e) => {
341
- h.meterAudible = e;
342
- for (let t of [...m]) t(e);
348
+ if (!(e.mediaStreamTrack === null || m.meter !== null)) try {
349
+ m.meter = s.startMeter(e.mediaStreamTrack, (e) => {
350
+ m.meterAudible = e;
351
+ for (let t of [...p]) t(e);
343
352
  });
344
353
  } catch {
345
- h.meter = null;
354
+ m.meter = null;
346
355
  }
347
356
  },
348
357
  onAvatarVideo: (e) => {
349
- h.videoTrack = e;
350
- let t = X();
351
- t !== null && e.attach(t), D === h && V({ videoReady: !0 });
358
+ m.videoTrack = e;
359
+ let t = Z();
360
+ t !== null && e.attach(t), E === m && V({ videoReady: !0 });
352
361
  }
353
- }), g);
362
+ }), h);
354
363
  } catch (e) {
355
- if (T !== a) return;
364
+ if (w !== a) return;
356
365
  R({
357
366
  event: "connect-failed",
358
367
  error: e instanceof Error ? e.name : "error"
359
368
  }), K("client_error", { problem: "connection" });
360
369
  return;
361
370
  }
362
- if (T !== a || D !== h) return;
371
+ if (w !== a || E !== m) return;
363
372
  V({
364
373
  phase: "ready",
365
- audioBlocked: p.audioBlocked,
366
- ...p.audioBlocked ? { problem: "playback-blocked" } : {}
374
+ audioBlocked: f.audioBlocked,
375
+ ...f.audioBlocked ? { problem: "playback-blocked" } : {}
367
376
  }), G();
368
- let _ = S > 0 ? u + S - ee - c.now() : f.endsAt - s.now(), v = Math.max(0, _ - d);
377
+ let g = x > 0 ? u + x - ee - c.now() : d.endsAt - s.now(), _ = Math.max(0, g - te);
369
378
  F = c.setTimeout(() => {
370
- F = null, T === a && (w = !0, V({ closing: !0 }), W.isBusy() || K("user", { notice: "time-limit" }));
371
- }, v);
379
+ F = null, w === a && (C = !0, V({ closing: !0 }), W.isBusy() || K("user", { notice: "time-limit" }));
380
+ }, _);
372
381
  }
373
- function Y(t) {
382
+ function le(t) {
374
383
  let n = new AbortController();
375
384
  return new Promise((r, i) => {
376
385
  let a = c.setTimeout(() => {
377
386
  n.abort(), i(new e("connection"));
378
- }, _);
387
+ }, g);
379
388
  t(n.signal).then((e) => {
380
389
  a(), r(e);
381
390
  }, (e) => {
@@ -383,7 +392,7 @@ function g(s) {
383
392
  });
384
393
  });
385
394
  }
386
- function le(t, n) {
395
+ function ue(t, n) {
387
396
  return new Promise((r, i) => {
388
397
  let a = c.setTimeout(() => i(new e("connection")), n);
389
398
  t.then((e) => {
@@ -393,32 +402,32 @@ function g(s) {
393
402
  });
394
403
  });
395
404
  }
396
- function X() {
397
- return O[O.length - 1] ?? null;
405
+ function Z() {
406
+ return D[D.length - 1] ?? null;
398
407
  }
399
- function Z(e) {
400
- let t = O.indexOf(e);
408
+ function de(e) {
409
+ let t = D.indexOf(e);
401
410
  if (t === -1) return;
402
- let n = t === O.length - 1;
403
- O.splice(t, 1);
404
- let r = D?.videoTrack ?? null;
411
+ let n = t === D.length - 1;
412
+ D.splice(t, 1);
413
+ let r = E?.videoTrack ?? null;
405
414
  if (!n || r === null) return;
406
415
  r.detach();
407
- let i = X();
416
+ let i = Z();
408
417
  i !== null && r.attach(i);
409
418
  }
410
419
  let Q = [];
411
420
  Q.push(l.subscribe(() => {
412
421
  let e = l.getState().avatarEnabled;
413
- if (e !== C) {
422
+ if (e !== S) {
414
423
  if (e) {
415
424
  l.setAvatarEnabled(!1);
416
425
  return;
417
426
  }
418
- v.phase !== "off" && v.phase !== "checking" && v.phase !== "choosing" ? K(H(), {}) : C = !1;
427
+ _.phase !== "off" && _.phase !== "checking" && _.phase !== "choosing" ? K(H(), {}) : S = !1;
419
428
  }
420
429
  })), s.subscribeWorkspaceChange && Q.push(s.subscribeWorkspaceChange(() => {
421
- if (b = !1, v.phase === "off" ? V({
430
+ if (y = !1, _.phase === "off" ? V({
422
431
  problem: null,
423
432
  avatars: [],
424
433
  consentVersion: null
@@ -426,26 +435,26 @@ function g(s) {
426
435
  avatars: [],
427
436
  consentVersion: null
428
437
  })), j) {
429
- let e = T;
438
+ let e = w;
430
439
  c.setTimeout(() => {
431
- j && T === e && $.requestOn({ start: !1 });
440
+ j && w === e && $.requestOn({ start: !1 });
432
441
  }, 0);
433
442
  }
434
443
  })), s.subscribePageHide && Q.push(s.subscribePageHide(() => {
435
- (E !== null || v.phase !== "off") && K("page_hide", { keepalive: !0 });
436
- }));
444
+ (T !== null || _.phase !== "off") && K("page_hide", { keepalive: !0 });
445
+ })), s.subscribePageShow && Q.push(s.subscribePageShow(Y));
437
446
  let $ = {
438
447
  subscribe(e) {
439
- return y.add(e), () => {
440
- y.delete(e);
448
+ return v.add(e), () => {
449
+ v.delete(e);
441
450
  };
442
451
  },
443
- getSnapshot: () => v,
452
+ getSnapshot: () => _,
444
453
  setVoiceLive(e) {
445
- if (A = !e, e) {
454
+ if (k = !e, e) {
446
455
  V({
447
456
  voiceLive: !0,
448
- problem: b || j && B() ? v.problem : null,
457
+ problem: y || j && B() ? _.problem : null,
449
458
  notice: null
450
459
  });
451
460
  return;
@@ -454,33 +463,33 @@ function g(s) {
454
463
  V({ voiceLive: !1 });
455
464
  return;
456
465
  }
457
- (E !== null || v.phase !== "off") && (v.phase === "checking" || v.phase === "choosing" ? (T += 1, V({ phase: "off" })) : K("voice_end", {})), V({
466
+ (T !== null || _.phase !== "off") && (_.phase === "checking" || _.phase === "choosing" ? (w += 1, V({ phase: "off" })) : K("voice_end", {})), V({
458
467
  voiceLive: !1,
459
468
  notice: null
460
469
  });
461
470
  },
462
471
  requestOn(e = {}) {
463
- if (L || !v.offered || v.phase !== "off") return;
472
+ if (L || !_.offered || _.phase !== "off") return;
464
473
  let t = e.start === void 0 ? "auto" : e.start ? "start" : "choose";
465
474
  if (t === "start" && B()) return;
466
- let n = e.avatarId ?? v.selectedAvatarId, r = v.consentVersion, i = s.client();
475
+ let n = e.avatarId ?? _.selectedAvatarId, r = _.consentVersion, i = s.client();
467
476
  if (i === null) {
468
- J();
477
+ X();
469
478
  return;
470
479
  }
471
480
  t === "start" && (N = c.now());
472
- let o = ++T;
481
+ let o = ++w;
473
482
  V({
474
483
  phase: "checking",
475
- problem: B() ? v.problem : null,
484
+ problem: B() ? _.problem : null,
476
485
  notice: null
477
- }), Y((e) => i.availability(e)).then((e) => {
478
- if (T !== o) return;
486
+ }), le((e) => i.availability(e)).then((e) => {
487
+ if (w !== o) return;
479
488
  if (!e.available) {
480
- J(a(e.reason));
489
+ X(a(e.reason));
481
490
  return;
482
491
  }
483
- S = e.maxSessionSeconds * 1e3;
492
+ x = e.maxSessionSeconds * 1e3;
484
493
  let i = t === "start" && n !== null && e.avatars.includes(n), s = l.getState().avatarId, c = i ? n : s !== null && e.avatars.includes(s) ? s : e.avatars[0] ?? null;
485
494
  switch (V({
486
495
  phase: "choosing",
@@ -489,7 +498,7 @@ function g(s) {
489
498
  consentVersion: e.consentVersion
490
499
  }), t) {
491
500
  case "auto":
492
- x === e.consentVersion && e.avatars.length === 1 && $.confirm();
501
+ b === e.consentVersion && e.avatars.length === 1 && $.confirm();
493
502
  return;
494
503
  case "start":
495
504
  i && r === e.consentVersion ? $.confirm() : N = null;
@@ -497,45 +506,46 @@ function g(s) {
497
506
  case "choose": return;
498
507
  }
499
508
  }, (e) => {
500
- T === o && q(e);
509
+ w === o && q(e);
501
510
  });
502
511
  },
503
512
  confirm() {
504
- if (v.phase !== "choosing" || !(v.voiceLive || j) || B()) return;
505
- let e = v.selectedAvatarId, t = v.consentVersion;
506
- e === null || t === null || (x = t, l.setAvatarId(e), C = !0, M = !j, j && (N ??= c.now()), U(), ce(e, t));
513
+ if (_.phase !== "choosing" || !(_.voiceLive || j) || B()) return;
514
+ let e = _.selectedAvatarId, t = _.consentVersion;
515
+ e === null || t === null || (b = t, l.setAvatarId(e), S = !0, M = !j, j && (N ??= c.now()), U(), ce(e, t));
507
516
  },
517
+ recheckRetry: Y,
508
518
  cancelChoice() {
509
- v.phase === "choosing" && (T += 1, N = null, V({ phase: "off" }));
519
+ _.phase === "choosing" && (w += 1, N = null, V({ phase: "off" }));
510
520
  },
511
521
  setTabOpen(e) {
512
522
  if (L || e === j) return;
513
523
  if (j = e, e) {
514
- V({ tabOpen: !0 }), v.phase === "checking" && (T += 1, V({ phase: "off" }), $.requestOn({ start: !1 }));
524
+ V({ tabOpen: !0 }), _.phase === "checking" && (w += 1, V({ phase: "off" }), $.requestOn({ start: !1 }));
515
525
  return;
516
526
  }
517
527
  N = null;
518
- let t = v.phase;
528
+ let t = _.phase;
519
529
  if (t === "checking" || t === "choosing") {
520
- T += 1, V({
530
+ w += 1, V({
521
531
  tabOpen: !1,
522
532
  phase: "off"
523
533
  });
524
534
  return;
525
535
  }
526
- (E !== null || t !== "off") && !v.heldByVoice && K("user", {}), V({ tabOpen: !1 });
536
+ (T !== null || t !== "off") && !_.heldByVoice && K("user", {}), V({ tabOpen: !1 });
527
537
  },
528
538
  selectAvatar(e) {
529
- v.avatars.includes(e) && V({ selectedAvatarId: e });
539
+ _.avatars.includes(e) && V({ selectedAvatarId: e });
530
540
  },
531
541
  switchOff() {
532
- let { phase: e } = v;
542
+ let { phase: e } = _;
533
543
  if (!(j && N !== null && (e === "checking" || e === "starting" || e === "connecting") && c.now() - N < 1e3)) {
534
544
  if (e === "checking" || e === "choosing") {
535
- T += 1, N = null, V({ phase: "off" });
545
+ w += 1, N = null, V({ phase: "off" });
536
546
  return;
537
547
  }
538
- if (e === "off" && !C) {
548
+ if (e === "off" && !S) {
539
549
  U();
540
550
  return;
541
551
  }
@@ -543,41 +553,41 @@ function g(s) {
543
553
  }
544
554
  },
545
555
  resumeAudio() {
546
- let e = D;
556
+ let e = E;
547
557
  e !== null && (e.transport.resumeAudio().catch(() => void 0), e.meter?.resume().catch(() => void 0));
548
558
  },
549
559
  setStageMounted(e) {
550
- k = Math.max(0, k + (e ? 1 : -1));
560
+ O = Math.max(0, O + (e ? 1 : -1));
551
561
  },
552
562
  attachVideo(e) {
553
563
  if (e === null) {
554
- let e = X();
555
- e !== null && Z(e);
564
+ let e = Z();
565
+ e !== null && de(e);
556
566
  return;
557
567
  }
558
- let t = O.indexOf(e);
559
- t !== -1 && O.splice(t, 1), O.push(e);
560
- let n = D?.videoTrack ?? null;
561
- return n !== null && (n.detach(), n.attach(e)), () => Z(e);
568
+ let t = D.indexOf(e);
569
+ t !== -1 && D.splice(t, 1), D.push(e);
570
+ let n = E?.videoTrack ?? null;
571
+ return n !== null && (n.detach(), n.attach(e)), () => de(e);
562
572
  },
563
573
  route(e, t) {
564
- if (v.phase !== "ready" || w || !C || k === 0 || D === null || D.port.isAudioBlocked() || e.fallback === !1) return "speakers";
574
+ if (_.phase !== "ready" || C || !S || O === 0 || E === null || E.port.isAudioBlocked() || e.fallback === !1) return "speakers";
565
575
  let n = e.voice;
566
576
  return n !== null && n.source !== "hosted" || !t.listVoices().some((e) => e.source === "hosted") ? (R({
567
577
  event: "notice",
568
578
  notice: { kind: "needs-hosted-voice" }
569
- }), V({ problem: "needs-hosted-voice" }), "speakers") : (v.problem === "needs-hosted-voice" && V({ problem: null }), "avatar");
579
+ }), V({ problem: "needs-hosted-voice" }), "speakers") : (_.problem === "needs-hosted-voice" && V({ problem: null }), "avatar");
570
580
  },
571
581
  createOutput: () => W.createOutput(),
572
582
  dispose() {
573
583
  if (!L) {
574
- L = !0, (E !== null || v.phase !== "off") && K("user", {}), I?.(), I = null;
584
+ L = !0, (T !== null || _.phase !== "off") && K("user", {}), I?.(), I = null;
575
585
  for (let e of Q.splice(0)) e();
576
- y.clear();
586
+ v.clear();
577
587
  }
578
588
  }
579
589
  };
580
590
  return $;
581
591
  }
582
592
  //#endregion
583
- export { u 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, d as LIVE_AVATAR_TAB_OFF_GUARD_MS, g as createLiveAvatarController };
593
+ export { u 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, te as LIVE_AVATAR_TAB_OFF_GUARD_MS, h as createLiveAvatarController };