@livelayer/react 0.5.24-debug.1 → 0.5.24-debug.3

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 (3) hide show
  1. package/dist/index.js +3 -3
  2. package/dist/index.mjs +1089 -1101
  3. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  "use client";
2
- import { jsxs as x, jsx as n, Fragment as Ct } from "react/jsx-runtime";
3
- import { Component as bn, useState as E, useRef as A, useEffect as M, useCallback as S, useMemo as gt, forwardRef as Nt, createElement as vn } from "react";
4
- import { LiveKitSession as wn } from "@livelayer/sdk";
5
- import { createLocalAudioTrack as _n, Track as rn, createLocalVideoTrack as xn } from "livekit-client";
6
- class kn extends bn {
2
+ import { jsxs as x, jsx as n, Fragment as Nt } from "react/jsx-runtime";
3
+ import { Component as wn, useState as C, useRef as N, useEffect as I, useCallback as S, useMemo as yt, forwardRef as At, createElement as _n } from "react";
4
+ import { LiveKitSession as xn } from "@livelayer/sdk";
5
+ import { createLocalAudioTrack as kn, Track as on, createLocalVideoTrack as Ln } from "livekit-client";
6
+ class Sn extends wn {
7
7
  constructor() {
8
8
  super(...arguments), this.state = { hasError: !1, error: null }, this.reset = () => {
9
9
  this.setState({ hasError: !1, error: null });
@@ -33,38 +33,45 @@ class kn extends bn {
33
33
  ] }) : this.props.children;
34
34
  }
35
35
  }
36
- function Ln(e) {
37
- const [t, r] = E("idle"), [o, i] = E("idle"), [l, d] = E([]), [u, f] = E(null), [y, w] = E(null), [s, a] = E(null), [L, D] = E(!1), [C, v] = E(null), _ = A(null), O = A(e.onDataMessage);
38
- O.current = e.onDataMessage, M(() => {
39
- const I = {
40
- onConnectionStateChange: (B) => {
41
- r(B), B === "connected" && v(null);
36
+ function En(e) {
37
+ const [t, r] = C("idle"), [o, i] = C("idle"), [l, u] = C([]), [d, p] = C(null), [y, w] = C(null), [s, a] = C(null), [L, R] = C(!1), [A, v] = C(null), _ = N(null), H = N(e.onDataMessage);
38
+ H.current = e.onDataMessage, I(() => {
39
+ const T = {
40
+ onConnectionStateChange: (z) => {
41
+ r(z), z === "connected" && v(null);
42
42
  },
43
43
  onAgentStateChange: i,
44
- onTranscript: (B) => d([...B]),
45
- onAgentConfig: f,
46
- onAudioTrack: (B) => a(B),
47
- onVideoTrack: (B) => w(B),
44
+ onTranscript: (z) => u([...z]),
45
+ onAgentConfig: p,
46
+ onAudioTrack: (z) => a(z),
47
+ onVideoTrack: (z) => w(z),
48
48
  onVideoTrackRemoved: () => w(null),
49
- onError: (B) => v(B),
50
- onDataMessage: (B) => {
49
+ onError: (z) => v(z),
50
+ onDataMessage: (z) => {
51
51
  var P;
52
- (P = O.current) == null || P.call(O, B);
52
+ (P = H.current) == null || P.call(H, z);
53
53
  },
54
- onResumabilityChange: D
55
- }, q = new wn(
54
+ onResumabilityChange: R
55
+ }, V = new xn(
56
56
  {
57
57
  agentId: e.agentId,
58
58
  baseUrl: e.baseUrl,
59
59
  apiKey: e.apiKey,
60
60
  sessionEndpoint: e.sessionEndpoint,
61
- sessionBody: e.sessionBody
61
+ sessionBody: e.sessionBody,
62
+ // useMicrophoneState owns the mic track. If we let the SDK
63
+ // also publish, livekit-client logs "publishing a second track
64
+ // with the same source: microphone" and renegotiates the
65
+ // publisher PC, which closes the data channel — every later
66
+ // publishData throws "PC manager is closed". That breaks the
67
+ // pathname / page_context / routes pushes the agent depends on.
68
+ manageMic: !1
62
69
  },
63
- I
70
+ T
64
71
  );
65
- return _.current = q, r("idle"), i("idle"), d([]), f(null), w(null), a(null), D(!1), v(null), () => {
66
- var B;
67
- (B = q.destroy) == null || B.call(q), _.current = null;
72
+ return _.current = V, r("idle"), i("idle"), u([]), p(null), w(null), a(null), R(!1), v(null), () => {
73
+ var z;
74
+ (z = V.destroy) == null || z.call(V), _.current = null;
68
75
  };
69
76
  }, [
70
77
  e.agentId,
@@ -74,37 +81,37 @@ function Ln(e) {
74
81
  JSON.stringify(e.sessionBody ?? {})
75
82
  ]);
76
83
  const $ = S(async () => {
77
- const I = _.current;
78
- if (I)
84
+ const T = _.current;
85
+ if (T)
79
86
  try {
80
- await I.connect();
81
- } catch (q) {
82
- throw v(q instanceof Error ? q.message : String(q)), q;
87
+ await T.connect();
88
+ } catch (V) {
89
+ throw v(V instanceof Error ? V.message : String(V)), V;
83
90
  }
84
- }, []), U = S(() => {
85
- const I = _.current;
86
- I && I.disconnect();
91
+ }, []), q = S(() => {
92
+ const T = _.current;
93
+ T && T.disconnect();
87
94
  }, []), m = S(() => {
88
- var I;
89
- return ((I = _.current) == null ? void 0 : I.getRoom()) ?? null;
95
+ var T;
96
+ return ((T = _.current) == null ? void 0 : T.getRoom()) ?? null;
90
97
  }, []);
91
98
  return {
92
99
  connectionState: t,
93
100
  agentState: o,
94
101
  transcript: l,
95
- agentConfig: u,
102
+ agentConfig: d,
96
103
  videoElement: y,
97
104
  audioElement: s,
98
105
  canResume: L,
99
- error: C,
106
+ error: A,
100
107
  connect: $,
101
- disconnect: U,
108
+ disconnect: q,
102
109
  getRoom: m,
103
110
  session: _.current
104
111
  };
105
112
  }
106
- function Sn() {
107
- const e = A(null), t = A(null), r = A(null), o = A(null), i = A(/* @__PURE__ */ new Set()), l = A(null), d = S(() => {
113
+ function Cn() {
114
+ const e = N(null), t = N(null), r = N(null), o = N(null), i = N(/* @__PURE__ */ new Set()), l = N(null), u = S(() => {
108
115
  const s = t.current;
109
116
  if (!s) {
110
117
  o.current = null;
@@ -116,22 +123,22 @@ function Sn() {
116
123
  const a = l.current;
117
124
  s.getByteFrequencyData(a);
118
125
  let L = 0;
119
- for (let C = 0; C < a.length; C++) L += a[C];
120
- const D = L / a.length / 255;
121
- for (const C of i.current)
126
+ for (let A = 0; A < a.length; A++) L += a[A];
127
+ const R = L / a.length / 255;
128
+ for (const A of i.current)
122
129
  try {
123
- C(D);
130
+ A(R);
124
131
  } catch (v) {
125
132
  console.error("[useAudioLevel] subscriber threw:", v);
126
133
  }
127
- o.current = requestAnimationFrame(d);
128
- }, []), u = S(() => {
134
+ o.current = requestAnimationFrame(u);
135
+ }, []), d = S(() => {
129
136
  if (e.current || typeof window > "u" || typeof AudioContext > "u") return;
130
137
  const s = new AudioContext(), a = s.createAnalyser();
131
138
  a.fftSize = 64, a.connect(s.destination), e.current = s, t.current = a;
132
- }, []), f = S(
139
+ }, []), p = S(
133
140
  (s) => {
134
- if (u(), !(!e.current || !t.current)) {
141
+ if (d(), !(!e.current || !t.current)) {
135
142
  if (r.current) {
136
143
  try {
137
144
  r.current.disconnect();
@@ -146,10 +153,10 @@ function Sn() {
146
153
  console.warn("[useAudioLevel] createMediaElementSource failed:", a);
147
154
  return;
148
155
  }
149
- o.current === null && (o.current = requestAnimationFrame(d));
156
+ o.current === null && (o.current = requestAnimationFrame(u));
150
157
  }
151
158
  },
152
- [u, d]
159
+ [d, u]
153
160
  ), y = S(() => {
154
161
  if (o.current !== null && (cancelAnimationFrame(o.current), o.current = null), r.current) {
155
162
  try {
@@ -161,7 +168,7 @@ function Sn() {
161
168
  }, []), w = S((s) => (i.current.add(s), () => {
162
169
  i.current.delete(s);
163
170
  }), []);
164
- return M(() => () => {
171
+ return I(() => () => {
165
172
  if (y(), t.current) {
166
173
  try {
167
174
  t.current.disconnect();
@@ -177,10 +184,10 @@ function Sn() {
177
184
  e.current = null;
178
185
  }
179
186
  i.current.clear(), l.current = null;
180
- }, [y]), { attach: f, detach: y, subscribe: w };
187
+ }, [y]), { attach: p, detach: y, subscribe: w };
181
188
  }
182
- function En() {
183
- const [e, t] = E(!1), [r, o] = E(null), i = A(null), l = A(null), d = S(
189
+ function Nn() {
190
+ const [e, t] = C(!1), [r, o] = C(null), i = N(null), l = N(null), u = S(
184
191
  async (s, a) => {
185
192
  if (i.current && l.current) {
186
193
  try {
@@ -191,21 +198,21 @@ function En() {
191
198
  }
192
199
  l.current = s, o(null);
193
200
  try {
194
- const L = await _n({
201
+ const L = await kn({
195
202
  echoCancellation: !0,
196
203
  noiseSuppression: !0
197
204
  });
198
- a != null && a.startMuted && await L.mute(), await s.localParticipant.publishTrack(L), i.current = L, t(L.isMuted);
205
+ await s.localParticipant.publishTrack(L), i.current = L, a != null && a.startMuted && await L.mute(), t(L.isMuted);
199
206
  } catch (L) {
200
- const D = L instanceof Error && L.name === "NotAllowedError" ? "Enable your microphone to talk with the agent." : "Microphone unavailable. Check browser permissions and try again.";
201
- throw o(D), L;
207
+ const R = L instanceof Error && L.name === "NotAllowedError" ? "Enable your microphone to talk with the agent." : "Microphone unavailable. Check browser permissions and try again.";
208
+ throw o(R), L;
202
209
  }
203
210
  },
204
211
  []
205
- ), u = S(() => {
212
+ ), d = S(() => {
206
213
  const s = i.current;
207
214
  s && (s.isMuted ? (s.unmute(), t(!1)) : (s.mute(), t(!0)));
208
- }, []), f = S((s) => {
215
+ }, []), p = S((s) => {
209
216
  const a = i.current;
210
217
  a && (s && !a.isMuted ? (a.mute(), t(!0)) : !s && a.isMuted && (a.unmute(), t(!1)));
211
218
  }, []), y = S(() => {
@@ -222,21 +229,21 @@ function En() {
222
229
  return {
223
230
  isMuted: e,
224
231
  micError: r,
225
- toggleMute: u,
226
- setMuted: f,
227
- setupMic: d,
232
+ toggleMute: d,
233
+ setMuted: p,
234
+ setupMic: u,
228
235
  teardownMic: y,
229
236
  clearError: w
230
237
  };
231
238
  }
232
- const Cn = { resolution: { width: 640, height: 480, frameRate: 24 } };
233
- function Nn() {
234
- const [e, t] = E(!1), [r, o] = E(null), [i, l] = E(null), [d, u] = E(""), f = A(null), y = A(null), w = S((_) => {
235
- f.current = _;
239
+ const An = { resolution: { width: 640, height: 480, frameRate: 24 } };
240
+ function Rn() {
241
+ const [e, t] = C(!1), [r, o] = C(null), [i, l] = C(null), [u, d] = C(""), p = N(null), y = N(null), w = S((_) => {
242
+ p.current = _;
236
243
  }, []), s = S(() => {
237
- const _ = f.current, O = y.current;
238
- if (O && _) {
239
- const $ = _.localParticipant.getTrackPublication(rn.Source.Camera);
244
+ const _ = p.current, H = y.current;
245
+ if (H && _) {
246
+ const $ = _.localParticipant.getTrackPublication(on.Source.Camera);
240
247
  if ($ != null && $.track) {
241
248
  try {
242
249
  _.localParticipant.unpublishTrack($.track);
@@ -244,75 +251,75 @@ function Nn() {
244
251
  }
245
252
  $.track.stop();
246
253
  } else
247
- O.stop();
254
+ H.stop();
248
255
  }
249
256
  y.current = null, l(null), t(!1);
250
257
  }, []), a = S(async (_) => {
251
- const O = f.current;
252
- if (O) {
258
+ const H = p.current;
259
+ if (H) {
253
260
  o(null);
254
261
  try {
255
- const $ = { ...Cn };
262
+ const $ = { ...An };
256
263
  _ && ($.deviceId = _);
257
- const U = await xn($);
258
- await O.localParticipant.publishTrack(U), y.current = U;
259
- const m = U.attach();
260
- l(m), t(!0), _ && u(_);
264
+ const q = await Ln($);
265
+ await H.localParticipant.publishTrack(q), y.current = q;
266
+ const m = q.attach();
267
+ l(m), t(!0), _ && d(_);
261
268
  try {
262
- O.localParticipant.publishData(
269
+ H.localParticipant.publishData(
263
270
  new TextEncoder().encode(JSON.stringify({ type: "user_camera_on" })),
264
271
  { reliable: !0 }
265
272
  );
266
273
  } catch {
267
274
  }
268
275
  } catch ($) {
269
- const U = $ instanceof Error && $.name === "NotAllowedError" ? "Enable your camera in the browser to share video." : "Camera unavailable. Check permissions and try again.";
270
- o(U);
276
+ const q = $ instanceof Error && $.name === "NotAllowedError" ? "Enable your camera in the browser to share video." : "Camera unavailable. Check permissions and try again.";
277
+ o(q);
271
278
  }
272
279
  }
273
280
  }, []), L = S(async () => {
274
- e ? s() : await a(d || void 0);
275
- }, [e, d, s, a]), D = S(async (_) => {
281
+ e ? s() : await a(u || void 0);
282
+ }, [e, u, s, a]), R = S(async (_) => {
276
283
  s(), await a(_);
277
- }, [s, a]), C = S(() => {
278
- s(), f.current = null, o(null), u("");
284
+ }, [s, a]), A = S(() => {
285
+ s(), p.current = null, o(null), d("");
279
286
  }, [s]), v = S(() => o(null), []);
280
- return M(() => () => {
287
+ return I(() => () => {
281
288
  y.current && y.current.stop();
282
289
  }, []), {
283
290
  isEnabled: e,
284
291
  error: r,
285
292
  previewEl: i,
286
- activeDeviceId: d,
293
+ activeDeviceId: u,
287
294
  toggle: L,
288
- switchDevice: D,
295
+ switchDevice: R,
289
296
  attachRoom: w,
290
- teardown: C,
297
+ teardown: A,
291
298
  clearError: v
292
299
  };
293
300
  }
294
- function An() {
295
- const [e, t] = E(!1), [r, o] = E(null), [i, l] = E(null), d = A(null), u = S((a) => {
296
- d.current = a;
297
- }, []), f = S(() => l(null), []), y = S(async () => {
298
- const a = d.current;
301
+ function Dn() {
302
+ const [e, t] = C(!1), [r, o] = C(null), [i, l] = C(null), u = N(null), d = S((a) => {
303
+ u.current = a;
304
+ }, []), p = S(() => l(null), []), y = S(async () => {
305
+ const a = u.current;
299
306
  if (a) {
300
307
  if (e) {
301
308
  try {
302
309
  await a.localParticipant.setScreenShareEnabled(!1);
303
310
  } catch {
304
311
  }
305
- f(), t(!1);
312
+ p(), t(!1);
306
313
  return;
307
314
  }
308
315
  o(null);
309
316
  try {
310
317
  await a.localParticipant.setScreenShareEnabled(!0);
311
318
  let L = 0;
312
- const D = () => {
313
- const C = a.localParticipant.getTrackPublication(rn.Source.ScreenShare);
314
- if (C != null && C.track) {
315
- const v = C.track.attach();
319
+ const R = () => {
320
+ const A = a.localParticipant.getTrackPublication(on.Source.ScreenShare);
321
+ if (A != null && A.track) {
322
+ const v = A.track.attach();
316
323
  l(v), t(!0);
317
324
  try {
318
325
  a.localParticipant.publishData(
@@ -323,49 +330,49 @@ function An() {
323
330
  }
324
331
  return;
325
332
  }
326
- L++ < 10 ? setTimeout(D, 100) : t(!0);
333
+ L++ < 10 ? setTimeout(R, 100) : t(!0);
327
334
  };
328
- D();
335
+ R();
329
336
  } catch (L) {
330
- const D = L instanceof Error ? L.name : "";
331
- D !== "NotAllowedError" && D !== "AbortError" && o("Screen share unavailable. Try again."), t(!1);
337
+ const R = L instanceof Error ? L.name : "";
338
+ R !== "NotAllowedError" && R !== "AbortError" && o("Screen share unavailable. Try again."), t(!1);
332
339
  }
333
340
  }
334
- }, [e, f]), w = S(() => {
335
- const a = d.current;
341
+ }, [e, p]), w = S(() => {
342
+ const a = u.current;
336
343
  if (a && e)
337
344
  try {
338
345
  a.localParticipant.setScreenShareEnabled(!1);
339
346
  } catch {
340
347
  }
341
- f(), t(!1), o(null), d.current = null;
342
- }, [e, f]), s = S(() => o(null), []);
343
- return { isEnabled: e, error: r, previewEl: i, toggle: y, attachRoom: u, teardown: w, clearError: s };
348
+ p(), t(!1), o(null), u.current = null;
349
+ }, [e, p]), s = S(() => o(null), []);
350
+ return { isEnabled: e, error: r, previewEl: i, toggle: y, attachRoom: d, teardown: w, clearError: s };
344
351
  }
345
- function Dn() {
346
- const [e, t] = E([]), [r, o] = E([]), i = S(async () => {
352
+ function Mn() {
353
+ const [e, t] = C([]), [r, o] = C([]), i = S(async () => {
347
354
  if (!(typeof navigator > "u" || !navigator.mediaDevices))
348
355
  try {
349
356
  const l = await navigator.mediaDevices.enumerateDevices();
350
- t(l.filter((d) => d.kind === "audioinput")), o(l.filter((d) => d.kind === "videoinput"));
357
+ t(l.filter((u) => u.kind === "audioinput")), o(l.filter((u) => u.kind === "videoinput"));
351
358
  } catch {
352
359
  }
353
360
  }, []);
354
- return M(() => {
361
+ return I(() => {
355
362
  if (i(), typeof navigator > "u" || !navigator.mediaDevices) return;
356
363
  const l = () => void i();
357
364
  return navigator.mediaDevices.addEventListener("devicechange", l), () => navigator.mediaDevices.removeEventListener("devicechange", l);
358
365
  }, [i]), { mics: e, cameras: r, refresh: i };
359
366
  }
360
- function Rn(e, t, r = !1) {
361
- const [o, i] = E(null), [l, d] = E(null), [u, f] = E(!r && !!e);
362
- return M(() => {
367
+ function In(e, t, r = !1) {
368
+ const [o, i] = C(null), [l, u] = C(null), [d, p] = C(!r && !!e);
369
+ return I(() => {
363
370
  if (r || !e) {
364
- f(!1);
371
+ p(!1);
365
372
  return;
366
373
  }
367
374
  const y = new AbortController(), w = t || "https://app.livelayer.studio";
368
- return f(!0), d(null), fetch(`${w}/api/widget/agent/${encodeURIComponent(e)}`, {
375
+ return p(!0), u(null), fetch(`${w}/api/widget/agent/${encodeURIComponent(e)}`, {
369
376
  signal: y.signal
370
377
  }).then(async (s) => {
371
378
  if (!s.ok) {
@@ -374,13 +381,13 @@ function Rn(e, t, r = !1) {
374
381
  }
375
382
  return s.json();
376
383
  }).then((s) => {
377
- y.signal.aborted || (i(s), f(!1));
384
+ y.signal.aborted || (i(s), p(!1));
378
385
  }).catch((s) => {
379
- y.signal.aborted || (d(s instanceof Error ? s.message : "Agent lookup failed"), f(!1));
386
+ y.signal.aborted || (u(s instanceof Error ? s.message : "Agent lookup failed"), p(!1));
380
387
  }), () => y.abort();
381
- }, [e, t, r]), { info: o, error: l, loading: u };
388
+ }, [e, t, r]), { info: o, error: l, loading: d };
382
389
  }
383
- function Mn(e) {
390
+ function Tn(e) {
384
391
  if (typeof window > "u") return null;
385
392
  try {
386
393
  return window.localStorage.getItem(e);
@@ -388,54 +395,54 @@ function Mn(e) {
388
395
  return null;
389
396
  }
390
397
  }
391
- function Tn(e, t) {
398
+ function Pn(e, t) {
392
399
  if (!(typeof window > "u"))
393
400
  try {
394
401
  window.localStorage.setItem(e, t);
395
402
  } catch {
396
403
  }
397
404
  }
398
- function In({
405
+ function $n({
399
406
  value: e,
400
407
  defaultValue: t = "expanded",
401
408
  onChange: r
402
409
  } = {}) {
403
- const o = e !== void 0, [i, l] = E(t), d = o ? e : i, u = S(
404
- (f) => {
405
- f !== d && (o || l(f), r == null || r(f));
410
+ const o = e !== void 0, [i, l] = C(t), u = o ? e : i, d = S(
411
+ (p) => {
412
+ p !== u && (o || l(p), r == null || r(p));
406
413
  },
407
- [d, o, r]
414
+ [u, o, r]
408
415
  );
409
- return [d, u];
416
+ return [u, d];
410
417
  }
411
- const Pn = ["hidden", "minimized", "expanded"];
412
- function $n(e) {
413
- return e && Pn.includes(e) ? e : null;
418
+ const Bn = ["hidden", "minimized", "expanded"];
419
+ function zn(e) {
420
+ return e && Bn.includes(e) ? e : null;
414
421
  }
415
- function Bn({
422
+ function Hn({
416
423
  value: e,
417
424
  defaultValue: t = "expanded",
418
425
  onChange: r,
419
426
  persistKey: o = "ll-widget",
420
427
  disablePersistence: i = !1
421
428
  } = {}) {
422
- const l = `${o}:display-mode`, d = A(!1), [u, f] = In({
429
+ const l = `${o}:display-mode`, u = N(!1), [d, p] = $n({
423
430
  value: e,
424
431
  defaultValue: t,
425
432
  onChange: (y) => {
426
- e === void 0 && !i && Tn(l, y), r == null || r(y);
433
+ e === void 0 && !i && Pn(l, y), r == null || r(y);
427
434
  }
428
435
  });
429
- return M(() => {
430
- if (d.current || (d.current = !0, i || e !== void 0)) return;
431
- const y = $n(Mn(l));
432
- y && y !== u && f(y);
433
- }, []), [u, f];
434
- }
435
- const zn = 640;
436
- function On(e = zn) {
437
- const [t, r] = E(!1);
438
- return M(() => {
436
+ return I(() => {
437
+ if (u.current || (u.current = !0, i || e !== void 0)) return;
438
+ const y = zn(Tn(l));
439
+ y && y !== d && p(y);
440
+ }, []), [d, p];
441
+ }
442
+ const qn = 640;
443
+ function On(e = qn) {
444
+ const [t, r] = C(!1);
445
+ return I(() => {
439
446
  if (e === !1) {
440
447
  r(!1);
441
448
  return;
@@ -448,67 +455,67 @@ function On(e = zn) {
448
455
  });
449
456
  }, [e]), t;
450
457
  }
451
- const Ht = "__llHistoryPatched", yt = "ll:pathname";
458
+ const Ut = "__llHistoryPatched", vt = "ll:pathname";
452
459
  function Un() {
453
- if (typeof window > "u" || window.history[Ht]) return;
460
+ if (typeof window > "u" || window.history[Ut]) return;
454
461
  const e = window.history.pushState, t = window.history.replaceState;
455
462
  window.history.pushState = function(...r) {
456
463
  const o = e.apply(this, r);
457
- return window.dispatchEvent(new Event(yt)), o;
464
+ return window.dispatchEvent(new Event(vt)), o;
458
465
  }, window.history.replaceState = function(...r) {
459
466
  const o = t.apply(this, r);
460
- return window.dispatchEvent(new Event(yt)), o;
461
- }, window.history[Ht] = !0;
467
+ return window.dispatchEvent(new Event(vt)), o;
468
+ }, window.history[Ut] = !0;
462
469
  }
463
470
  function Vt() {
464
471
  return typeof window > "u" ? "/" : window.location.pathname || "/";
465
472
  }
466
- function Hn(e) {
467
- const [t, r] = E(
473
+ function Vn(e) {
474
+ const [t, r] = C(
468
475
  () => e ?? Vt()
469
476
  );
470
- return M(() => {
477
+ return I(() => {
471
478
  if (e !== void 0) return;
472
479
  Un();
473
480
  const o = () => r(Vt());
474
- return o(), window.addEventListener("popstate", o), window.addEventListener(yt, o), () => {
475
- window.removeEventListener("popstate", o), window.removeEventListener(yt, o);
481
+ return o(), window.addEventListener("popstate", o), window.addEventListener(vt, o), () => {
482
+ window.removeEventListener("popstate", o), window.removeEventListener(vt, o);
476
483
  };
477
484
  }, [e]), e ?? t;
478
485
  }
479
- const qt = /* @__PURE__ */ new Map(), Vn = /[\\^$+?.()|{}[\]]/g;
480
- function qn(e) {
481
- return e.replace(Vn, "\\$&");
486
+ const Wt = /* @__PURE__ */ new Map(), Wn = /[\\^$+?.()|{}[\]]/g;
487
+ function Fn(e) {
488
+ return e.replace(Wn, "\\$&");
482
489
  }
483
- function Wn(e) {
484
- const t = qt.get(e);
490
+ function jn(e) {
491
+ const t = Wt.get(e);
485
492
  if (t) return t;
486
- const r = e.length > 1 && e.endsWith("/") ? e.slice(0, -1) : e, o = "", i = "", l = r.replace(/\*\*/g, o).replace(/\*/g, i), u = qn(l).replace(new RegExp(`\\/${o}`, "g"), "(?:\\/.*)?").replace(new RegExp(o, "g"), ".*").replace(new RegExp(i, "g"), "[^/]+"), f = new RegExp(`^${u}\\/?$`);
487
- return qt.set(e, f), f;
493
+ const r = e.length > 1 && e.endsWith("/") ? e.slice(0, -1) : e, o = "", i = "", l = r.replace(/\*\*/g, o).replace(/\*/g, i), d = Fn(l).replace(new RegExp(`\\/${o}`, "g"), "(?:\\/.*)?").replace(new RegExp(o, "g"), ".*").replace(new RegExp(i, "g"), "[^/]+"), p = new RegExp(`^${d}\\/?$`);
494
+ return Wt.set(e, p), p;
488
495
  }
489
496
  function Gn(e, t) {
490
497
  const r = t.length > 1 && t.endsWith("/") ? t.slice(0, -1) : t;
491
- return Wn(e).test(r);
498
+ return jn(e).test(r);
492
499
  }
493
- function Fn(e, t) {
500
+ function Yn(e, t) {
494
501
  return typeof e == "function" ? e(t) : e instanceof RegExp ? e.test(t) : Gn(e, t);
495
502
  }
496
- function Wt(e, t) {
503
+ function Ft(e, t) {
497
504
  if (!e || e.length === 0) return !1;
498
505
  for (const r of e)
499
- if (Fn(r, t)) return !0;
506
+ if (Yn(r, t)) return !0;
500
507
  return !1;
501
508
  }
502
- function jn(e, t, r) {
503
- return e === void 0 ? !0 : Wt(r, e) ? !1 : t && t.length > 0 ? Wt(t, e) : !0;
504
- }
505
509
  function Jn(e, t, r) {
506
- return gt(
507
- () => jn(e, t, r),
510
+ return e === void 0 ? !0 : Ft(r, e) ? !1 : t && t.length > 0 ? Ft(t, e) : !0;
511
+ }
512
+ function Kn(e, t, r) {
513
+ return yt(
514
+ () => Jn(e, t, r),
508
515
  [e, t, r]
509
516
  );
510
517
  }
511
- const Gt = ({ muted: e = !1, className: t }) => e ? /* @__PURE__ */ x(
518
+ const jt = ({ muted: e = !1, className: t }) => e ? /* @__PURE__ */ x(
512
519
  "svg",
513
520
  {
514
521
  className: t,
@@ -554,7 +561,7 @@ const Gt = ({ muted: e = !1, className: t }) => e ? /* @__PURE__ */ x(
554
561
  }
555
562
  )
556
563
  }
557
- ), Ft = ({ className: e }) => /* @__PURE__ */ n(
564
+ ), Gt = ({ className: e }) => /* @__PURE__ */ n(
558
565
  "svg",
559
566
  {
560
567
  className: e,
@@ -572,7 +579,7 @@ const Gt = ({ muted: e = !1, className: t }) => e ? /* @__PURE__ */ x(
572
579
  }
573
580
  )
574
581
  }
575
- ), Yn = ({ className: e }) => /* @__PURE__ */ n(
582
+ ), Xn = ({ className: e }) => /* @__PURE__ */ n(
576
583
  "svg",
577
584
  {
578
585
  className: e,
@@ -583,12 +590,12 @@ const Gt = ({ muted: e = !1, className: t }) => e ? /* @__PURE__ */ x(
583
590
  "aria-hidden": "true",
584
591
  children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
585
592
  }
586
- ), Kn = {
593
+ ), Qn = {
587
594
  left: 180,
588
595
  right: 0,
589
596
  up: -90,
590
597
  down: 90
591
- }, jt = ({ direction: e = "right", className: t }) => /* @__PURE__ */ n(
598
+ }, Yt = ({ direction: e = "right", className: t }) => /* @__PURE__ */ n(
592
599
  "svg",
593
600
  {
594
601
  className: t,
@@ -596,19 +603,19 @@ const Gt = ({ muted: e = !1, className: t }) => e ? /* @__PURE__ */ x(
596
603
  viewBox: "0 0 24 24",
597
604
  stroke: "currentColor",
598
605
  strokeWidth: 2,
599
- style: { transform: `rotate(${Kn[e]}deg)` },
606
+ style: { transform: `rotate(${Qn[e]}deg)` },
600
607
  "aria-hidden": "true",
601
608
  children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M9 6l6 6-6 6" })
602
609
  }
603
610
  );
604
- function Xn(e) {
611
+ function Zn(e) {
605
612
  return e === "top-left" || e === "bottom-left" ? "left" : "right";
606
613
  }
607
- const on = "ll-hidden-tab-center-y", Qn = 5, Jt = 16;
608
- function Zn() {
614
+ const ln = "ll-hidden-tab-center-y", er = 5, Jt = 16;
615
+ function tr() {
609
616
  if (typeof window > "u") return null;
610
617
  try {
611
- const e = window.localStorage.getItem(on);
618
+ const e = window.localStorage.getItem(ln);
612
619
  if (!e) return null;
613
620
  const t = Number.parseFloat(e);
614
621
  return Number.isFinite(t) ? t : null;
@@ -616,46 +623,46 @@ function Zn() {
616
623
  return null;
617
624
  }
618
625
  }
619
- function Yt(e) {
626
+ function Kt(e) {
620
627
  if (!(typeof window > "u"))
621
628
  try {
622
- window.localStorage.setItem(on, String(e));
629
+ window.localStorage.setItem(ln, String(e));
623
630
  } catch {
624
631
  }
625
632
  }
626
- const er = ({
633
+ const nr = ({
627
634
  position: e,
628
635
  isMobile: t,
629
636
  isSpeaking: r,
630
637
  onExpand: o,
631
638
  label: i = "Open widget",
632
639
  avatarImageUrl: l,
633
- agentName: d
640
+ agentName: u
634
641
  }) => {
635
- const u = Xn(e), f = u === "right" ? "left" : "right", y = t ? 80 : 72, w = !!l, [s, a] = E(null), [L, D] = E(!1), C = A(null), v = A(!1), _ = S(
642
+ const d = Zn(e), p = d === "right" ? "left" : "right", y = t ? 80 : 72, w = !!l, [s, a] = C(null), [L, R] = C(!1), A = N(null), v = N(!1), _ = S(
636
643
  (P) => {
637
644
  if (typeof window > "u") return P;
638
- const H = y / 2, G = Jt + H, Z = window.innerHeight - Jt - H;
639
- return Z < G ? Math.max(G, P) : Math.max(G, Math.min(Z, P));
645
+ const O = y / 2, G = Jt + O, ee = window.innerHeight - Jt - O;
646
+ return ee < G ? Math.max(G, P) : Math.max(G, Math.min(ee, P));
640
647
  },
641
648
  [y]
642
649
  );
643
- M(() => {
644
- const P = Zn();
650
+ I(() => {
651
+ const P = tr();
645
652
  a(_(P ?? window.innerHeight / 2));
646
- const H = () => {
653
+ const O = () => {
647
654
  a((G) => G === null ? null : _(G));
648
655
  };
649
- return window.addEventListener("resize", H), () => window.removeEventListener("resize", H);
656
+ return window.addEventListener("resize", O), () => window.removeEventListener("resize", O);
650
657
  }, [_]);
651
- const O = S(
658
+ const H = S(
652
659
  (P) => {
653
660
  if (!(P.pointerType === "mouse" && P.button !== 0) && s !== null) {
654
661
  try {
655
662
  P.currentTarget.setPointerCapture(P.pointerId);
656
663
  } catch {
657
664
  }
658
- C.current = {
665
+ A.current = {
659
666
  startClientY: P.clientY,
660
667
  startCenterY: s,
661
668
  moved: !1
@@ -665,21 +672,21 @@ const er = ({
665
672
  [s]
666
673
  ), $ = S(
667
674
  (P) => {
668
- const H = C.current;
669
- if (!H) return;
670
- const G = P.clientY - H.startClientY;
671
- !H.moved && Math.abs(G) > Qn && (H.moved = !0, D(!0)), H.moved && a(_(H.startCenterY + G));
675
+ const O = A.current;
676
+ if (!O) return;
677
+ const G = P.clientY - O.startClientY;
678
+ !O.moved && Math.abs(G) > er && (O.moved = !0, R(!0)), O.moved && a(_(O.startCenterY + G));
672
679
  },
673
680
  [_]
674
- ), U = S(
681
+ ), q = S(
675
682
  (P) => {
676
- const H = C.current;
677
- if (H) {
683
+ const O = A.current;
684
+ if (O) {
678
685
  try {
679
686
  P.currentTarget.releasePointerCapture(P.pointerId);
680
687
  } catch {
681
688
  }
682
- C.current = null, H.moved && (D(!1), v.current = !0, a((G) => (G !== null && Yt(G), G)));
689
+ A.current = null, O.moved && (R(!1), v.current = !0, a((G) => (G !== null && Kt(G), G)));
683
690
  }
684
691
  },
685
692
  []
@@ -689,51 +696,51 @@ const er = ({
689
696
  return;
690
697
  }
691
698
  o();
692
- }, [o]), I = S(
699
+ }, [o]), T = S(
693
700
  (P) => {
694
701
  if (P.key === "ArrowUp" || P.key === "ArrowDown") {
695
702
  P.preventDefault();
696
- const H = P.key === "ArrowUp" ? -8 : 8;
703
+ const O = P.key === "ArrowUp" ? -8 : 8;
697
704
  a((G) => {
698
705
  if (G === null) return G;
699
- const Z = _(G + H);
700
- return Yt(Z), Z;
706
+ const ee = _(G + O);
707
+ return Kt(ee), ee;
701
708
  });
702
709
  }
703
710
  },
704
711
  [_]
705
- ), q = [
712
+ ), V = [
706
713
  "ll-hidden",
707
- `ll-hidden--${u}`,
714
+ `ll-hidden--${d}`,
708
715
  t ? "ll-hidden--mobile" : "ll-hidden--desktop",
709
716
  r ? "ll-hidden--speaking" : null,
710
717
  L ? "is-dragging" : null,
711
718
  w ? "ll-hidden--with-avatar" : null
712
- ].filter(Boolean).join(" "), B = s === null ? void 0 : { top: `${s - y / 2}px`, transform: "none" };
719
+ ].filter(Boolean).join(" "), z = s === null ? void 0 : { top: `${s - y / 2}px`, transform: "none" };
713
720
  return /* @__PURE__ */ n(
714
721
  "button",
715
722
  {
716
723
  type: "button",
717
- className: q,
718
- onPointerDown: O,
724
+ className: V,
725
+ onPointerDown: H,
719
726
  onPointerMove: $,
720
- onPointerUp: U,
721
- onPointerCancel: U,
727
+ onPointerUp: q,
728
+ onPointerCancel: q,
722
729
  onClick: m,
723
- onKeyDown: I,
730
+ onKeyDown: T,
724
731
  "aria-label": i,
725
732
  "data-position": e,
726
- style: B,
733
+ style: z,
727
734
  children: w ? (
728
735
  // Layout: tiny chevron flush against the inward edge (peeks out
729
736
  // as the click affordance), then the circular avatar photo
730
737
  // taking the rest of the tab. Reinforces "this is an
731
738
  // avatar-based experience" even when collapsed.
732
- /* @__PURE__ */ x(Ct, { children: [
739
+ /* @__PURE__ */ x(Nt, { children: [
733
740
  /* @__PURE__ */ n(
734
- jt,
741
+ Yt,
735
742
  {
736
- direction: f,
743
+ direction: p,
737
744
  className: "ll-hidden__chevron ll-hidden__chevron--mini"
738
745
  }
739
746
  ),
@@ -741,22 +748,22 @@ const er = ({
741
748
  "img",
742
749
  {
743
750
  src: l,
744
- alt: d ? `${d} avatar` : "Agent avatar",
751
+ alt: u ? `${u} avatar` : "Agent avatar",
745
752
  className: "ll-hidden__avatar",
746
753
  draggable: !1
747
754
  }
748
755
  )
749
756
  ] })
750
757
  ) : /* @__PURE__ */ n(
751
- jt,
758
+ Yt,
752
759
  {
753
- direction: f,
760
+ direction: p,
754
761
  className: "ll-hidden__chevron"
755
762
  }
756
763
  )
757
764
  }
758
765
  );
759
- }, tr = ({
766
+ }, rr = ({
760
767
  audioLevel: e,
761
768
  bars: t = 20,
762
769
  maxHeight: r = 20,
@@ -764,40 +771,40 @@ const er = ({
764
771
  className: i,
765
772
  barClassName: l
766
773
  }) => {
767
- const d = A(null), u = A([]), f = gt(() => {
774
+ const u = N(null), d = N([]), p = yt(() => {
768
775
  const w = (Math.sqrt(5) - 1) / 2;
769
776
  return Array.from({ length: t }, (s, a) => 0.5 + a * w % 1 * 0.5);
770
777
  }, [t]);
771
- M(() => e.subscribe((s) => {
778
+ I(() => e.subscribe((s) => {
772
779
  for (let a = 0; a < t; a++) {
773
- const L = u.current[a];
780
+ const L = d.current[a];
774
781
  if (!L) continue;
775
- const D = Math.max(o, s * r * f[a]);
776
- L.style.height = `${D}px`;
782
+ const R = Math.max(o, s * r * p[a]);
783
+ L.style.height = `${R}px`;
777
784
  }
778
- }), [e, t, r, o, f]);
785
+ }), [e, t, r, o, p]);
779
786
  const y = ["ll-waveform", i].filter(Boolean).join(" ");
780
- return /* @__PURE__ */ n("div", { ref: d, className: y, "aria-hidden": "true", children: Array.from({ length: t }, (w, s) => /* @__PURE__ */ n(
787
+ return /* @__PURE__ */ n("div", { ref: u, className: y, "aria-hidden": "true", children: Array.from({ length: t }, (w, s) => /* @__PURE__ */ n(
781
788
  "div",
782
789
  {
783
790
  ref: (a) => {
784
- u.current[s] = a;
791
+ d.current[s] = a;
785
792
  },
786
793
  className: ["ll-waveform__bar", l].filter(Boolean).join(" "),
787
794
  style: { height: `${o}px` }
788
795
  },
789
796
  s
790
797
  )) });
791
- }, nr = ({
798
+ }, or = ({
792
799
  position: e,
793
800
  isMobile: t,
794
801
  agentName: r,
795
802
  avatarImageUrl: o,
796
803
  agentState: i,
797
804
  isMuted: l,
798
- audioLevel: d,
799
- onExpand: u,
800
- onToggleMute: f,
805
+ audioLevel: u,
806
+ onExpand: d,
807
+ onToggleMute: p,
801
808
  onClose: y
802
809
  }) => t ? /* @__PURE__ */ n(
803
810
  "div",
@@ -810,7 +817,7 @@ const er = ({
810
817
  {
811
818
  type: "button",
812
819
  className: "ll-minimized__surface",
813
- onClick: u,
820
+ onClick: d,
814
821
  "aria-label": `Expand ${r} widget`,
815
822
  children: [
816
823
  o ? (
@@ -825,9 +832,9 @@ const er = ({
825
832
  )
826
833
  ) : /* @__PURE__ */ n("div", { className: "ll-minimized__avatar ll-minimized__avatar--placeholder" }),
827
834
  /* @__PURE__ */ n(
828
- tr,
835
+ rr,
829
836
  {
830
- audioLevel: d,
837
+ audioLevel: u,
831
838
  bars: 16,
832
839
  maxHeight: 18,
833
840
  className: "ll-minimized__waveform"
@@ -842,16 +849,16 @@ const er = ({
842
849
  role: "button",
843
850
  tabIndex: 0,
844
851
  onClick: (w) => {
845
- w.stopPropagation(), f();
852
+ w.stopPropagation(), p();
846
853
  },
847
854
  onKeyDown: (w) => {
848
- (w.key === "Enter" || w.key === " ") && (w.stopPropagation(), w.preventDefault(), f());
855
+ (w.key === "Enter" || w.key === " ") && (w.stopPropagation(), w.preventDefault(), p());
849
856
  },
850
857
  "aria-label": l ? "Unmute microphone" : "Mute microphone",
851
- children: /* @__PURE__ */ n(Gt, { muted: l, className: "ll-minimized__icon" })
858
+ children: /* @__PURE__ */ n(jt, { muted: l, className: "ll-minimized__icon" })
852
859
  }
853
860
  ),
854
- /* @__PURE__ */ n(Ft, { className: "ll-minimized__icon ll-minimized__icon--expand" })
861
+ /* @__PURE__ */ n(Gt, { className: "ll-minimized__icon ll-minimized__icon--expand" })
855
862
  ] })
856
863
  ]
857
864
  }
@@ -886,9 +893,9 @@ const er = ({
886
893
  {
887
894
  type: "button",
888
895
  className: "ll-minimized__btn",
889
- onClick: f,
896
+ onClick: p,
890
897
  "aria-label": l ? "Unmute microphone" : "Mute microphone",
891
- children: /* @__PURE__ */ n(Gt, { muted: l, className: "ll-minimized__icon" })
898
+ children: /* @__PURE__ */ n(jt, { muted: l, className: "ll-minimized__icon" })
892
899
  }
893
900
  ),
894
901
  /* @__PURE__ */ n(
@@ -896,9 +903,9 @@ const er = ({
896
903
  {
897
904
  type: "button",
898
905
  className: "ll-minimized__btn",
899
- onClick: u,
906
+ onClick: d,
900
907
  "aria-label": `Expand ${r} widget`,
901
- children: /* @__PURE__ */ n(Ft, { className: "ll-minimized__icon" })
908
+ children: /* @__PURE__ */ n(Gt, { className: "ll-minimized__icon" })
902
909
  }
903
910
  ),
904
911
  /* @__PURE__ */ n(
@@ -908,24 +915,24 @@ const er = ({
908
915
  className: "ll-minimized__btn ll-minimized__btn--close",
909
916
  onClick: y,
910
917
  "aria-label": "Close widget",
911
- children: /* @__PURE__ */ n(Yn, { className: "ll-minimized__icon" })
918
+ children: /* @__PURE__ */ n(Xn, { className: "ll-minimized__icon" })
912
919
  }
913
920
  )
914
921
  ] })
915
922
  ] })
916
923
  }
917
- ), rr = ({
924
+ ), ir = ({
918
925
  src: e,
919
926
  alt: t,
920
927
  preCannedPlaying: r = !1,
921
928
  className: o,
922
929
  style: i
923
930
  }) => {
924
- const [l, d] = E(!1), u = A(e);
925
- if (M(() => {
926
- u.current !== e && (u.current = e, d(!1));
931
+ const [l, u] = C(!1), d = N(e);
932
+ if (I(() => {
933
+ d.current !== e && (d.current = e, u(!1));
927
934
  }, [e]), !e) return null;
928
- const f = {
935
+ const p = {
929
936
  position: "absolute",
930
937
  inset: 0,
931
938
  width: "100%",
@@ -945,68 +952,68 @@ const er = ({
945
952
  src: e,
946
953
  alt: t,
947
954
  className: o,
948
- style: f,
955
+ style: p,
949
956
  loading: "eager",
950
957
  fetchPriority: "high",
951
- onLoad: () => d(!0)
958
+ onLoad: () => u(!0)
952
959
  }
953
960
  )
954
961
  );
955
- }, or = ({
962
+ }, lr = ({
956
963
  position: e,
957
964
  isMobile: t,
958
965
  agentName: r,
959
966
  avatarImageUrl: o,
960
967
  idleLoopUrl: i,
961
968
  greeting: l,
962
- branding: d,
963
- teamMembers: u,
964
- currentTeamMemberId: f,
969
+ branding: u,
970
+ teamMembers: d,
971
+ currentTeamMemberId: p,
965
972
  isSwitchingTeamMember: y,
966
973
  teamSwitcherOpen: w,
967
974
  onToggleTeamSwitcher: s,
968
975
  onSelectTeamMember: a,
969
976
  languageMenuOpen: L,
970
- onToggleLanguageMenu: D,
971
- connectionState: C,
977
+ onToggleLanguageMenu: R,
978
+ connectionState: A,
972
979
  agentState: v,
973
980
  transcript: _,
974
- canResume: O,
981
+ canResume: H,
975
982
  needsUserGesture: $,
976
- error: U,
983
+ error: q,
977
984
  isMuted: m,
978
- micError: I,
979
- micDevices: q,
980
- isCameraEnabled: B,
985
+ micError: T,
986
+ micDevices: V,
987
+ isCameraEnabled: z,
981
988
  cameraPreviewEl: P,
982
- cameraDevices: H,
989
+ cameraDevices: O,
983
990
  activeCameraId: G,
984
- isScreenShareEnabled: Z,
991
+ isScreenShareEnabled: ee,
985
992
  screenPreviewEl: le,
986
993
  isSpeakerMuted: Le,
987
- allowCamera: rt,
988
- allowScreenShare: ot,
989
- allowTyping: it,
990
- avatarVideoContainerRef: lt,
994
+ allowCamera: ot,
995
+ allowScreenShare: it,
996
+ allowTyping: lt,
997
+ avatarVideoContainerRef: at,
991
998
  agentVideoEl: ie,
992
- micGateOpen: pe,
999
+ micGateOpen: he,
993
1000
  onConnect: Se,
994
- onDisconnect: De,
995
- onRetry: Re,
1001
+ onDisconnect: Re,
1002
+ onRetry: De,
996
1003
  onResumeAudio: Me,
997
- onToggleMute: Te,
998
- onToggleCamera: Ie,
999
- onSwitchCameraDevice: Y,
1000
- onToggleScreenShare: vt,
1001
- onToggleSpeaker: wt,
1002
- onSendMessage: at,
1004
+ onToggleMute: Ie,
1005
+ onToggleCamera: Te,
1006
+ onSwitchCameraDevice: J,
1007
+ onToggleScreenShare: wt,
1008
+ onToggleSpeaker: _t,
1009
+ onSendMessage: st,
1003
1010
  onMinimize: ae,
1004
1011
  onClose: Pe,
1005
- onClearMicError: We
1012
+ onClearMicError: Fe
1006
1013
  }) => {
1007
- var Ue;
1008
- const Ee = ((u == null ? void 0 : u.length) ?? 0) > 1, $e = C === "connecting" || C === "connected", Q = C === "connected", ne = C === "idle" || C === "disconnected" || C === "error", [Be, se] = E(!1);
1009
- M(() => {
1014
+ var qe;
1015
+ const Ee = ((d == null ? void 0 : d.length) ?? 0) > 1, $e = A === "connecting" || A === "connected", X = A === "connected", te = A === "idle" || A === "disconnected" || A === "error", [Be, se] = C(!1);
1016
+ I(() => {
1010
1017
  if (!ie) {
1011
1018
  se(!1);
1012
1019
  return;
@@ -1016,80 +1023,80 @@ const er = ({
1016
1023
  return;
1017
1024
  }
1018
1025
  se(!1);
1019
- const p = () => se(!0);
1020
- return ie.addEventListener("playing", p), ie.addEventListener("loadeddata", p), () => {
1021
- ie.removeEventListener("playing", p), ie.removeEventListener("loadeddata", p);
1026
+ const h = () => se(!0);
1027
+ return ie.addEventListener("playing", h), ie.addEventListener("loadeddata", h), () => {
1028
+ ie.removeEventListener("playing", h), ie.removeEventListener("loadeddata", h);
1022
1029
  };
1023
1030
  }, [ie]);
1024
- const [he, Ce] = E(!1);
1025
- M(() => {
1026
- if (!Q) {
1031
+ const [me, Ce] = C(!1);
1032
+ I(() => {
1033
+ if (!X) {
1027
1034
  Ce(!1);
1028
1035
  return;
1029
1036
  }
1030
1037
  if (Be) return;
1031
- const p = setTimeout(() => Ce(!0), 8e3);
1032
- return () => clearTimeout(p);
1033
- }, [Q, Be]);
1034
- const Ge = C === "connecting" || Q && !!o && !Be && !he, re = A(null), ce = A(null);
1035
- M(() => {
1036
- const p = re.current;
1037
- p && (p.innerHTML = "", P && (P.style.width = "100%", P.style.height = "100%", P.style.objectFit = "cover", P.style.transform = "scaleX(-1)", p.appendChild(P)));
1038
- }, [P]), M(() => {
1039
- const p = ce.current;
1040
- p && (p.innerHTML = "", le && (le.style.width = "100%", le.style.height = "100%", le.style.objectFit = "contain", p.appendChild(le)));
1038
+ const h = setTimeout(() => Ce(!0), 8e3);
1039
+ return () => clearTimeout(h);
1040
+ }, [X, Be]);
1041
+ const je = A === "connecting" || X && !!o && !Be && !me, re = N(null), ce = N(null);
1042
+ I(() => {
1043
+ const h = re.current;
1044
+ h && (h.innerHTML = "", P && (P.style.width = "100%", P.style.height = "100%", P.style.objectFit = "cover", P.style.transform = "scaleX(-1)", h.appendChild(P)));
1045
+ }, [P]), I(() => {
1046
+ const h = ce.current;
1047
+ h && (h.innerHTML = "", le && (le.style.width = "100%", le.style.height = "100%", le.style.objectFit = "contain", h.appendChild(le)));
1041
1048
  }, [le]);
1042
- const [de, me] = E(!1), [ze, ge] = E(!1);
1043
- M(() => {
1044
- if (!de && !ze && !L && !w) return;
1045
- const p = () => {
1046
- me(!1), ge(!1), L && D(), w && s();
1049
+ const [ue, ge] = C(!1), [ze, ye] = C(!1);
1050
+ I(() => {
1051
+ if (!ue && !ze && !L && !w) return;
1052
+ const h = () => {
1053
+ ge(!1), ye(!1), L && R(), w && s();
1047
1054
  };
1048
- return document.addEventListener("click", p), () => document.removeEventListener("click", p);
1055
+ return document.addEventListener("click", h), () => document.removeEventListener("click", h);
1049
1056
  }, [
1050
- de,
1057
+ ue,
1051
1058
  ze,
1052
1059
  L,
1053
1060
  w,
1054
- D,
1061
+ R,
1055
1062
  s
1056
1063
  ]);
1057
- const [ye, Fe] = E(""), je = S(
1058
- (p) => {
1059
- p.preventDefault();
1060
- const K = ye.trim();
1061
- K && (at(K), Fe(""));
1064
+ const [ve, Ge] = C(""), Ye = S(
1065
+ (h) => {
1066
+ h.preventDefault();
1067
+ const K = ve.trim();
1068
+ K && (st(K), Ge(""));
1062
1069
  },
1063
- [ye, at]
1064
- ), Je = d.productName || "Live Layer";
1065
- let be = null, ve = null;
1066
- for (let p = _.length - 1; p >= 0; p--) {
1067
- const K = _[p];
1068
- if (!be && K.role === "agent" ? be = K : !ve && K.role === "user" && (ve = K), be && ve) break;
1070
+ [ve, st]
1071
+ ), Je = u.productName || "Live Layer";
1072
+ let be = null, we = null;
1073
+ for (let h = _.length - 1; h >= 0; h--) {
1074
+ const K = _[h];
1075
+ if (!be && K.role === "agent" ? be = K : !we && K.role === "user" && (we = K), be && we) break;
1069
1076
  }
1070
- const Oe = Q ? (be == null ? void 0 : be.text) || null : l || null, st = Q && (ve == null ? void 0 : ve.text) || null, Ye = [
1077
+ const He = X ? (be == null ? void 0 : be.text) || null : l || null, ct = X && (we == null ? void 0 : we.text) || null, Ke = [
1071
1078
  "ll-expanded",
1072
1079
  t ? "ll-expanded--mobile" : "ll-expanded--desktop"
1073
1080
  ].join(" ");
1074
1081
  return /* @__PURE__ */ x(
1075
1082
  "div",
1076
1083
  {
1077
- className: Ye,
1084
+ className: Ke,
1078
1085
  "data-position": e,
1079
- "data-state": Q ? "connected" : $e ? "connecting" : "idle",
1086
+ "data-state": X ? "connected" : $e ? "connecting" : "idle",
1080
1087
  role: "dialog",
1081
1088
  "aria-label": `${r} widget`,
1082
1089
  children: [
1083
1090
  /* @__PURE__ */ x("div", { className: "ll-expanded__bg", children: [
1084
1091
  o ? /* @__PURE__ */ n(
1085
- rr,
1092
+ ir,
1086
1093
  {
1087
1094
  src: o,
1088
1095
  alt: r,
1089
1096
  className: "ll-expanded__bg-img"
1090
1097
  }
1091
- ) : /* @__PURE__ */ n("div", { className: "ll-expanded__bg-fallback", children: /* @__PURE__ */ n("span", { className: "ll-expanded__bg-initial", children: ((Ue = r == null ? void 0 : r.charAt(0)) == null ? void 0 : Ue.toUpperCase()) || "A" }) }),
1092
- i && !Q && /* @__PURE__ */ n(
1098
+ ) : /* @__PURE__ */ n("div", { className: "ll-expanded__bg-fallback", children: /* @__PURE__ */ n("span", { className: "ll-expanded__bg-initial", children: ((qe = r == null ? void 0 : r.charAt(0)) == null ? void 0 : qe.toUpperCase()) || "A" }) }),
1099
+ i && !X && /* @__PURE__ */ n(
1093
1100
  "video",
1094
1101
  {
1095
1102
  className: "ll-expanded__bg-idle",
@@ -1101,12 +1108,12 @@ const er = ({
1101
1108
  }
1102
1109
  )
1103
1110
  ] }),
1104
- /* @__PURE__ */ n("div", { ref: lt, className: "ll-expanded__video" }),
1105
- Ge && /* @__PURE__ */ x("div", { className: "ll-expanded__overlay ll-expanded__overlay--connecting", children: [
1111
+ /* @__PURE__ */ n("div", { ref: at, className: "ll-expanded__video" }),
1112
+ je && /* @__PURE__ */ x("div", { className: "ll-expanded__overlay ll-expanded__overlay--connecting", children: [
1106
1113
  /* @__PURE__ */ n("div", { className: "ll-expanded__spinner" }),
1107
1114
  /* @__PURE__ */ n("p", { className: "ll-expanded__overlay-text", children: y ? "Switching..." : "Connecting..." })
1108
1115
  ] }),
1109
- $ && Q && /* @__PURE__ */ x(
1116
+ $ && X && /* @__PURE__ */ x(
1110
1117
  "button",
1111
1118
  {
1112
1119
  type: "button",
@@ -1126,14 +1133,14 @@ const er = ({
1126
1133
  {
1127
1134
  type: "button",
1128
1135
  className: "ll-hpill",
1129
- onClick: (p) => {
1130
- Ee && (p.stopPropagation(), s());
1136
+ onClick: (h) => {
1137
+ Ee && (h.stopPropagation(), s());
1131
1138
  },
1132
1139
  "aria-haspopup": Ee ? "listbox" : void 0,
1133
1140
  "aria-expanded": Ee ? w : void 0,
1134
1141
  children: [
1135
1142
  /* @__PURE__ */ n("span", { className: "ll-hpill__label", children: r }),
1136
- Ee && /* @__PURE__ */ n(pt, {})
1143
+ Ee && /* @__PURE__ */ n(ht, {})
1137
1144
  ]
1138
1145
  }
1139
1146
  ),
@@ -1141,30 +1148,30 @@ const er = ({
1141
1148
  "div",
1142
1149
  {
1143
1150
  className: "ll-hmenu",
1144
- onClick: (p) => p.stopPropagation(),
1151
+ onClick: (h) => h.stopPropagation(),
1145
1152
  role: "listbox",
1146
- children: u == null ? void 0 : u.map((p) => /* @__PURE__ */ x(
1153
+ children: d == null ? void 0 : d.map((h) => /* @__PURE__ */ x(
1147
1154
  "button",
1148
1155
  {
1149
1156
  type: "button",
1150
- className: `ll-hmenu__item ${p.id === f ? "is-active" : ""}`,
1151
- onClick: () => a(p.id),
1157
+ className: `ll-hmenu__item ${h.id === p ? "is-active" : ""}`,
1158
+ onClick: () => a(h.id),
1152
1159
  role: "option",
1153
- "aria-selected": p.id === f,
1160
+ "aria-selected": h.id === p,
1154
1161
  children: [
1155
- p.avatarImageUrl && /* @__PURE__ */ n(
1162
+ h.avatarImageUrl && /* @__PURE__ */ n(
1156
1163
  "img",
1157
1164
  {
1158
- src: p.avatarImageUrl,
1165
+ src: h.avatarImageUrl,
1159
1166
  alt: "",
1160
1167
  className: "ll-hmenu__avatar"
1161
1168
  }
1162
1169
  ),
1163
- /* @__PURE__ */ n("span", { className: "ll-hmenu__name", children: p.name }),
1164
- p.role && /* @__PURE__ */ n("span", { className: "ll-hmenu__role", children: p.role })
1170
+ /* @__PURE__ */ n("span", { className: "ll-hmenu__name", children: h.name }),
1171
+ h.role && /* @__PURE__ */ n("span", { className: "ll-hmenu__role", children: h.role })
1165
1172
  ]
1166
1173
  },
1167
- p.id
1174
+ h.id
1168
1175
  ))
1169
1176
  }
1170
1177
  )
@@ -1175,8 +1182,8 @@ const er = ({
1175
1182
  {
1176
1183
  type: "button",
1177
1184
  className: "ll-hpill ll-hpill--compact",
1178
- onClick: (p) => {
1179
- p.stopPropagation(), D();
1185
+ onClick: (h) => {
1186
+ h.stopPropagation(), R();
1180
1187
  },
1181
1188
  "aria-haspopup": "listbox",
1182
1189
  "aria-expanded": L,
@@ -1184,7 +1191,7 @@ const er = ({
1184
1191
  title: "Language: English",
1185
1192
  children: [
1186
1193
  /* @__PURE__ */ n("span", { className: "ll-hpill__label", children: "EN" }),
1187
- /* @__PURE__ */ n(pt, {})
1194
+ /* @__PURE__ */ n(ht, {})
1188
1195
  ]
1189
1196
  }
1190
1197
  ),
@@ -1192,7 +1199,7 @@ const er = ({
1192
1199
  "div",
1193
1200
  {
1194
1201
  className: "ll-hmenu",
1195
- onClick: (p) => p.stopPropagation(),
1202
+ onClick: (h) => h.stopPropagation(),
1196
1203
  role: "listbox",
1197
1204
  children: /* @__PURE__ */ n(
1198
1205
  "button",
@@ -1224,7 +1231,7 @@ const er = ({
1224
1231
  onClick: ae,
1225
1232
  "aria-label": "Minimize widget",
1226
1233
  title: "Minimize",
1227
- children: /* @__PURE__ */ n(Xt, {})
1234
+ children: /* @__PURE__ */ n(Qt, {})
1228
1235
  }
1229
1236
  ),
1230
1237
  /* @__PURE__ */ n(
@@ -1235,7 +1242,7 @@ const er = ({
1235
1242
  onClick: Pe,
1236
1243
  "aria-label": "End call",
1237
1244
  title: "End call",
1238
- children: /* @__PURE__ */ n(Kt, {})
1245
+ children: /* @__PURE__ */ n(Xt, {})
1239
1246
  }
1240
1247
  )
1241
1248
  ] })
@@ -1251,7 +1258,7 @@ const er = ({
1251
1258
  className: "ll-hbtn ll-hbtn--ghost",
1252
1259
  onClick: ae,
1253
1260
  "aria-label": "Minimize widget",
1254
- children: /* @__PURE__ */ n(Xt, {})
1261
+ children: /* @__PURE__ */ n(Qt, {})
1255
1262
  }
1256
1263
  ),
1257
1264
  /* @__PURE__ */ n(
@@ -1261,25 +1268,25 @@ const er = ({
1261
1268
  className: "ll-hbtn ll-hbtn--danger",
1262
1269
  onClick: Pe,
1263
1270
  "aria-label": "Close widget",
1264
- children: /* @__PURE__ */ n(Kt, {})
1271
+ children: /* @__PURE__ */ n(Xt, {})
1265
1272
  }
1266
1273
  )
1267
1274
  ] })
1268
1275
  ] })
1269
1276
  ),
1270
- ne && /* @__PURE__ */ (() => {
1271
- const p = O ? "Restart paused session" : C === "disconnected" ? "Reconnect to agent" : "Start video call", K = O ? "Pick up where you left off" : null;
1272
- return /* @__PURE__ */ x(Ct, { children: [
1273
- C === "idle" && !O && !U && /* @__PURE__ */ x(
1277
+ te && /* @__PURE__ */ (() => {
1278
+ const h = H ? "Restart paused session" : A === "disconnected" ? "Reconnect to agent" : "Start video call", K = H ? "Pick up where you left off" : null;
1279
+ return /* @__PURE__ */ x(Nt, { children: [
1280
+ A === "idle" && !H && !q && /* @__PURE__ */ x(
1274
1281
  "button",
1275
1282
  {
1276
1283
  type: "button",
1277
1284
  className: "ll-expanded__play",
1278
1285
  onClick: Se,
1279
- "aria-label": p,
1286
+ "aria-label": h,
1280
1287
  children: [
1281
1288
  /* @__PURE__ */ n("div", { className: "ll-expanded__play-circle", children: /* @__PURE__ */ n("svg", { width: "22", height: "22", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": !0, children: /* @__PURE__ */ n("polygon", { points: "6 3 20 12 6 21 6 3" }) }) }),
1282
- /* @__PURE__ */ n("span", { className: "ll-expanded__play-label", children: p })
1289
+ /* @__PURE__ */ n("span", { className: "ll-expanded__play-label", children: h })
1283
1290
  ]
1284
1291
  }
1285
1292
  ),
@@ -1292,8 +1299,8 @@ const er = ({
1292
1299
  type: "button",
1293
1300
  className: "ll-expanded__cta",
1294
1301
  onClick: Se,
1295
- "aria-label": p,
1296
- children: p
1302
+ "aria-label": h,
1303
+ children: h
1297
1304
  }
1298
1305
  )
1299
1306
  ] })
@@ -1302,88 +1309,88 @@ const er = ({
1302
1309
  /* @__PURE__ */ x(
1303
1310
  "div",
1304
1311
  {
1305
- className: `ll-expanded__pip ${$e && (B || Z) ? "is-visible" : ""}`,
1312
+ className: `ll-expanded__pip ${$e && (z || ee) ? "is-visible" : ""}`,
1306
1313
  children: [
1307
1314
  /* @__PURE__ */ n(
1308
1315
  "div",
1309
1316
  {
1310
1317
  ref: ce,
1311
- className: Z ? "ll-expanded__pip-host" : "ll-expanded__pip-host is-hidden"
1318
+ className: ee ? "ll-expanded__pip-host" : "ll-expanded__pip-host is-hidden"
1312
1319
  }
1313
1320
  ),
1314
1321
  /* @__PURE__ */ n(
1315
1322
  "div",
1316
1323
  {
1317
1324
  ref: re,
1318
- className: !Z && B ? "ll-expanded__pip-host" : "ll-expanded__pip-host is-hidden"
1325
+ className: !ee && z ? "ll-expanded__pip-host" : "ll-expanded__pip-host is-hidden"
1319
1326
  }
1320
1327
  )
1321
1328
  ]
1322
1329
  }
1323
1330
  ),
1324
1331
  $e ? /* @__PURE__ */ x("div", { className: "ll-expanded__bottom", children: [
1325
- Oe && /* @__PURE__ */ n(
1332
+ He && /* @__PURE__ */ n(
1326
1333
  "div",
1327
1334
  {
1328
1335
  className: "ll-expanded__transcript ll-expanded__transcript--agent",
1329
1336
  "data-role": "agent",
1330
- children: /* @__PURE__ */ n("p", { className: "ll-expanded__transcript-text", children: Oe })
1337
+ children: /* @__PURE__ */ n("p", { className: "ll-expanded__transcript-text", children: He })
1331
1338
  }
1332
1339
  ),
1333
- st && /* @__PURE__ */ n(
1340
+ ct && /* @__PURE__ */ n(
1334
1341
  "div",
1335
1342
  {
1336
1343
  className: "ll-expanded__transcript ll-expanded__transcript--user",
1337
1344
  "data-role": "user",
1338
- children: /* @__PURE__ */ n("p", { className: "ll-expanded__transcript-text", children: st })
1345
+ children: /* @__PURE__ */ n("p", { className: "ll-expanded__transcript-text", children: ct })
1339
1346
  }
1340
1347
  ),
1341
- /* @__PURE__ */ x("div", { className: "ll-toolbar", onClick: (p) => p.stopPropagation(), children: [
1342
- ot && /* @__PURE__ */ n(
1348
+ /* @__PURE__ */ x("div", { className: "ll-toolbar", onClick: (h) => h.stopPropagation(), children: [
1349
+ it && /* @__PURE__ */ n(
1343
1350
  "button",
1344
1351
  {
1345
1352
  type: "button",
1346
- className: `ll-tool ${Z ? "is-on" : ""}`,
1347
- onClick: vt,
1348
- "aria-label": Z ? "Stop sharing screen" : "Share screen",
1349
- title: Z ? "Stop sharing" : "Share screen",
1350
- children: /* @__PURE__ */ n(ir, {})
1353
+ className: `ll-tool ${ee ? "is-on" : ""}`,
1354
+ onClick: wt,
1355
+ "aria-label": ee ? "Stop sharing screen" : "Share screen",
1356
+ title: ee ? "Stop sharing" : "Share screen",
1357
+ children: /* @__PURE__ */ n(ar, {})
1351
1358
  }
1352
1359
  ),
1353
- rt && /* @__PURE__ */ x("div", { className: "ll-tool-split", children: [
1360
+ ot && /* @__PURE__ */ x("div", { className: "ll-tool-split", children: [
1354
1361
  /* @__PURE__ */ n(
1355
1362
  "button",
1356
1363
  {
1357
1364
  type: "button",
1358
- className: `ll-tool ll-tool--left ${B ? "is-on" : ""}`,
1359
- onClick: Ie,
1360
- "aria-label": B ? "Turn off camera" : "Turn on camera",
1361
- title: B ? "Stop camera" : "Start camera",
1362
- children: /* @__PURE__ */ n(lr, {})
1365
+ className: `ll-tool ll-tool--left ${z ? "is-on" : ""}`,
1366
+ onClick: Te,
1367
+ "aria-label": z ? "Turn off camera" : "Turn on camera",
1368
+ title: z ? "Stop camera" : "Start camera",
1369
+ children: /* @__PURE__ */ n(sr, {})
1363
1370
  }
1364
1371
  ),
1365
1372
  /* @__PURE__ */ n(
1366
1373
  "button",
1367
1374
  {
1368
1375
  type: "button",
1369
- className: `ll-tool ll-tool--right ${B ? "is-on" : ""}`,
1370
- onClick: (p) => {
1371
- p.stopPropagation(), ge((K) => !K), me(!1);
1376
+ className: `ll-tool ll-tool--right ${z ? "is-on" : ""}`,
1377
+ onClick: (h) => {
1378
+ h.stopPropagation(), ye((K) => !K), ge(!1);
1372
1379
  },
1373
1380
  "aria-label": "Camera devices",
1374
1381
  "aria-haspopup": "listbox",
1375
1382
  "aria-expanded": ze,
1376
- children: /* @__PURE__ */ n(pt, {})
1383
+ children: /* @__PURE__ */ n(ht, {})
1377
1384
  }
1378
1385
  ),
1379
- ze && H.length > 0 && /* @__PURE__ */ n(
1380
- Qt,
1386
+ ze && O.length > 0 && /* @__PURE__ */ n(
1387
+ Zt,
1381
1388
  {
1382
1389
  label: "Camera",
1383
- devices: H,
1390
+ devices: O,
1384
1391
  activeId: G,
1385
- onPick: (p) => {
1386
- ge(!1), Y(p);
1392
+ onPick: (h) => {
1393
+ ye(!1), J(h);
1387
1394
  }
1388
1395
  }
1389
1396
  )
@@ -1391,18 +1398,18 @@ const er = ({
1391
1398
  /* @__PURE__ */ x(
1392
1399
  "div",
1393
1400
  {
1394
- className: `ll-tool-split${!pe && Q ? " ll-tool-split--gated" : ""}`,
1401
+ className: `ll-tool-split${!he && X ? " ll-tool-split--gated" : ""}`,
1395
1402
  children: [
1396
1403
  /* @__PURE__ */ n(
1397
1404
  "button",
1398
1405
  {
1399
1406
  type: "button",
1400
1407
  className: `ll-tool ll-tool--left ${m ? "is-muted" : ""}`,
1401
- onClick: Te,
1402
- disabled: !pe && Q,
1403
- "aria-label": !pe && Q ? "Microphone enables once the agent finishes its greeting" : m ? "Unmute microphone" : "Mute microphone",
1404
- title: !pe && Q ? "Mic enables after greeting" : m ? "Unmute" : "Mute",
1405
- children: /* @__PURE__ */ n(ar, { muted: m })
1408
+ onClick: Ie,
1409
+ disabled: !he && X,
1410
+ "aria-label": !he && X ? "Microphone enables once the agent finishes its greeting" : m ? "Unmute microphone" : "Mute microphone",
1411
+ title: !he && X ? "Mic enables after greeting" : m ? "Unmute" : "Mute",
1412
+ children: /* @__PURE__ */ n(cr, { muted: m })
1406
1413
  }
1407
1414
  ),
1408
1415
  /* @__PURE__ */ n(
@@ -1410,22 +1417,22 @@ const er = ({
1410
1417
  {
1411
1418
  type: "button",
1412
1419
  className: `ll-tool ll-tool--right ${m ? "is-muted" : ""}`,
1413
- onClick: (p) => {
1414
- p.stopPropagation(), me((K) => !K), ge(!1);
1420
+ onClick: (h) => {
1421
+ h.stopPropagation(), ge((K) => !K), ye(!1);
1415
1422
  },
1416
1423
  "aria-label": "Microphone devices",
1417
1424
  "aria-haspopup": "listbox",
1418
- "aria-expanded": de,
1419
- children: /* @__PURE__ */ n(pt, {})
1425
+ "aria-expanded": ue,
1426
+ children: /* @__PURE__ */ n(ht, {})
1420
1427
  }
1421
1428
  ),
1422
- de && q.length > 0 && /* @__PURE__ */ n(
1423
- Qt,
1429
+ ue && V.length > 0 && /* @__PURE__ */ n(
1430
+ Zt,
1424
1431
  {
1425
1432
  label: "Microphone",
1426
- devices: q,
1433
+ devices: V,
1427
1434
  activeId: "",
1428
- onPick: () => me(!1)
1435
+ onPick: () => ge(!1)
1429
1436
  }
1430
1437
  )
1431
1438
  ]
@@ -1436,10 +1443,10 @@ const er = ({
1436
1443
  {
1437
1444
  type: "button",
1438
1445
  className: `ll-tool ${Le ? "is-muted" : ""}`,
1439
- onClick: wt,
1446
+ onClick: _t,
1440
1447
  "aria-label": Le ? "Unmute speaker" : "Mute speaker",
1441
1448
  title: Le ? "Unmute speaker" : "Mute speaker",
1442
- children: /* @__PURE__ */ n(sr, { muted: Le })
1449
+ children: /* @__PURE__ */ n(ur, { muted: Le })
1443
1450
  }
1444
1451
  ),
1445
1452
  /* @__PURE__ */ n(
@@ -1447,61 +1454,61 @@ const er = ({
1447
1454
  {
1448
1455
  type: "button",
1449
1456
  className: "ll-tool ll-tool--danger",
1450
- onClick: De,
1457
+ onClick: Re,
1451
1458
  "aria-label": "End conversation",
1452
1459
  title: "End conversation",
1453
- children: /* @__PURE__ */ n(dr, {})
1460
+ children: /* @__PURE__ */ n(fr, {})
1454
1461
  }
1455
1462
  )
1456
1463
  ] }),
1457
- it && /* @__PURE__ */ x("form", { className: "ll-message-input", onSubmit: je, children: [
1464
+ lt && /* @__PURE__ */ x("form", { className: "ll-message-input", onSubmit: Ye, children: [
1458
1465
  /* @__PURE__ */ n(
1459
1466
  "input",
1460
1467
  {
1461
1468
  type: "text",
1462
1469
  className: "ll-message-input__field",
1463
1470
  placeholder: "Message...",
1464
- value: ye,
1465
- onChange: (p) => Fe(p.target.value),
1471
+ value: ve,
1472
+ onChange: (h) => Ge(h.target.value),
1466
1473
  "aria-label": "Message the agent"
1467
1474
  }
1468
1475
  ),
1469
- ye.trim() && /* @__PURE__ */ n(
1476
+ ve.trim() && /* @__PURE__ */ n(
1470
1477
  "button",
1471
1478
  {
1472
1479
  type: "submit",
1473
1480
  className: "ll-message-input__send",
1474
1481
  "aria-label": "Send message",
1475
- children: /* @__PURE__ */ n(cr, {})
1482
+ children: /* @__PURE__ */ n(dr, {})
1476
1483
  }
1477
1484
  )
1478
1485
  ] })
1479
1486
  ] }) : null,
1480
1487
  (() => {
1481
- if (I && C !== "error")
1488
+ if (T && A !== "error")
1482
1489
  return /* @__PURE__ */ x("div", { className: "ll-expanded__banner", role: "alert", children: [
1483
- /* @__PURE__ */ n("span", { children: I }),
1490
+ /* @__PURE__ */ n("span", { children: T }),
1484
1491
  /* @__PURE__ */ n(
1485
1492
  "button",
1486
1493
  {
1487
1494
  type: "button",
1488
1495
  className: "ll-expanded__banner-x",
1489
- onClick: We,
1496
+ onClick: Fe,
1490
1497
  "aria-label": "Dismiss",
1491
1498
  children: "×"
1492
1499
  }
1493
1500
  )
1494
1501
  ] });
1495
- if (!U || C !== "error") return null;
1496
- let p = "Failed to connect", K = "Try again";
1497
- return U === "MIC_PERMISSION_DENIED" ? p = "Microphone blocked. Allow access to talk." : U === "MIC_NOT_FOUND" ? p = "No microphone found. Plug one in + retry." : U === "MIC_UNAVAILABLE" ? p = "Mic unavailable. Check other apps using it." : U === "AGENT_TIMEOUT" ? p = "Agent didn't pick up. Try again." : U === "CONNECT_FAILED" ? p = "Connection failed. Check your network." : U.length < 80 && (p = U), /* @__PURE__ */ x("div", { className: "ll-expanded__banner ll-expanded__banner--error", role: "alert", children: [
1498
- /* @__PURE__ */ n("span", { children: p }),
1502
+ if (!q || A !== "error") return null;
1503
+ let h = "Failed to connect", K = "Try again";
1504
+ return q === "MIC_PERMISSION_DENIED" ? h = "Microphone blocked. Allow access to talk." : q === "MIC_NOT_FOUND" ? h = "No microphone found. Plug one in + retry." : q === "MIC_UNAVAILABLE" ? h = "Mic unavailable. Check other apps using it." : q === "AGENT_TIMEOUT" ? h = "Agent didn't pick up. Try again." : q === "CONNECT_FAILED" ? h = "Connection failed. Check your network." : q.length < 80 && (h = q), /* @__PURE__ */ x("div", { className: "ll-expanded__banner ll-expanded__banner--error", role: "alert", children: [
1505
+ /* @__PURE__ */ n("span", { children: h }),
1499
1506
  /* @__PURE__ */ n(
1500
1507
  "button",
1501
1508
  {
1502
1509
  type: "button",
1503
1510
  className: "ll-expanded__banner-retry",
1504
- onClick: Re,
1511
+ onClick: De,
1505
1512
  children: K
1506
1513
  }
1507
1514
  )
@@ -1511,32 +1518,32 @@ const er = ({
1511
1518
  }
1512
1519
  );
1513
1520
  };
1514
- function pt() {
1521
+ function ht() {
1515
1522
  return /* @__PURE__ */ n("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", "aria-hidden": !0, children: /* @__PURE__ */ n("polyline", { points: "6 9 12 15 18 9" }) });
1516
1523
  }
1517
- function Kt() {
1524
+ function Xt() {
1518
1525
  return /* @__PURE__ */ x("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", "aria-hidden": !0, children: [
1519
1526
  /* @__PURE__ */ n("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
1520
1527
  /* @__PURE__ */ n("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1521
1528
  ] });
1522
1529
  }
1523
- function Xt() {
1530
+ function Qt() {
1524
1531
  return /* @__PURE__ */ n("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", "aria-hidden": !0, children: /* @__PURE__ */ n("line", { x1: "5", y1: "12", x2: "19", y2: "12" }) });
1525
1532
  }
1526
- function ir() {
1533
+ function ar() {
1527
1534
  return /* @__PURE__ */ x("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
1528
1535
  /* @__PURE__ */ n("rect", { x: "2", y: "3", width: "20", height: "14", rx: "2" }),
1529
1536
  /* @__PURE__ */ n("line", { x1: "8", y1: "21", x2: "16", y2: "21" }),
1530
1537
  /* @__PURE__ */ n("line", { x1: "12", y1: "17", x2: "12", y2: "21" })
1531
1538
  ] });
1532
1539
  }
1533
- function lr() {
1540
+ function sr() {
1534
1541
  return /* @__PURE__ */ x("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
1535
1542
  /* @__PURE__ */ n("path", { d: "M23 7l-7 5 7 5V7z" }),
1536
1543
  /* @__PURE__ */ n("rect", { x: "1", y: "5", width: "15", height: "14", rx: "2" })
1537
1544
  ] });
1538
1545
  }
1539
- function ar({ muted: e }) {
1546
+ function cr({ muted: e }) {
1540
1547
  return /* @__PURE__ */ x("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
1541
1548
  /* @__PURE__ */ n("path", { d: "M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z" }),
1542
1549
  /* @__PURE__ */ n("path", { d: "M19 10v2a7 7 0 0 1-14 0v-2" }),
@@ -1544,22 +1551,22 @@ function ar({ muted: e }) {
1544
1551
  e && /* @__PURE__ */ n("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
1545
1552
  ] });
1546
1553
  }
1547
- function sr({ muted: e }) {
1554
+ function ur({ muted: e }) {
1548
1555
  return /* @__PURE__ */ x("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
1549
1556
  /* @__PURE__ */ n("polygon", { points: "11 5 6 9 2 9 2 15 6 15 11 19 11 5" }),
1550
- e ? /* @__PURE__ */ n("line", { x1: "23", y1: "9", x2: "17", y2: "15" }) : /* @__PURE__ */ x(Ct, { children: [
1557
+ e ? /* @__PURE__ */ n("line", { x1: "23", y1: "9", x2: "17", y2: "15" }) : /* @__PURE__ */ x(Nt, { children: [
1551
1558
  /* @__PURE__ */ n("path", { d: "M19.07 4.93a10 10 0 0 1 0 14.14" }),
1552
1559
  /* @__PURE__ */ n("path", { d: "M15.54 8.46a5 5 0 0 1 0 7.07" })
1553
1560
  ] })
1554
1561
  ] });
1555
1562
  }
1556
- function cr() {
1563
+ function dr() {
1557
1564
  return /* @__PURE__ */ x("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: [
1558
1565
  /* @__PURE__ */ n("line", { x1: "5", y1: "12", x2: "19", y2: "12" }),
1559
1566
  /* @__PURE__ */ n("polyline", { points: "12 5 19 12 12 19" })
1560
1567
  ] });
1561
1568
  }
1562
- function dr() {
1569
+ function fr() {
1563
1570
  return /* @__PURE__ */ n("svg", { width: "16", height: "16", viewBox: "-4 -4 32 32", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": !0, children: /* @__PURE__ */ n(
1564
1571
  "path",
1565
1572
  {
@@ -1568,7 +1575,7 @@ function dr() {
1568
1575
  }
1569
1576
  ) });
1570
1577
  }
1571
- const Qt = ({ label: e, devices: t, activeId: r, onPick: o }) => /* @__PURE__ */ x(
1578
+ const Zt = ({ label: e, devices: t, activeId: r, onPick: o }) => /* @__PURE__ */ x(
1572
1579
  "div",
1573
1580
  {
1574
1581
  className: "ll-device-menu",
@@ -1577,17 +1584,17 @@ const Qt = ({ label: e, devices: t, activeId: r, onPick: o }) => /* @__PURE__ */
1577
1584
  children: [
1578
1585
  /* @__PURE__ */ n("p", { className: "ll-device-menu__label", children: e }),
1579
1586
  t.map((i, l) => {
1580
- const d = r === i.deviceId;
1587
+ const u = r === i.deviceId;
1581
1588
  return /* @__PURE__ */ x(
1582
1589
  "button",
1583
1590
  {
1584
1591
  type: "button",
1585
- className: `ll-device-menu__item ${d ? "is-active" : ""}`,
1592
+ className: `ll-device-menu__item ${u ? "is-active" : ""}`,
1586
1593
  onClick: () => o(i.deviceId),
1587
1594
  role: "option",
1588
- "aria-selected": d,
1595
+ "aria-selected": u,
1589
1596
  children: [
1590
- d && /* @__PURE__ */ n("span", { className: "ll-device-menu__dot", children: "●" }),
1597
+ u && /* @__PURE__ */ n("span", { className: "ll-device-menu__dot", children: "●" }),
1591
1598
  /* @__PURE__ */ n("span", { className: "ll-device-menu__name", children: i.label || `${e} ${l + 1}` })
1592
1599
  ]
1593
1600
  },
@@ -1596,21 +1603,21 @@ const Qt = ({ label: e, devices: t, activeId: r, onPick: o }) => /* @__PURE__ */
1596
1603
  })
1597
1604
  ]
1598
1605
  }
1599
- ), ur = [
1606
+ ), pr = [
1600
1607
  '[data-ll-private="true"]',
1601
1608
  ".ll-widget"
1602
1609
  ];
1603
- function At(e) {
1610
+ function Rt(e) {
1604
1611
  let t = e;
1605
1612
  for (; t; ) {
1606
- for (const r of ur)
1613
+ for (const r of pr)
1607
1614
  if (t.matches(r)) return !0;
1608
1615
  t = t.parentElement;
1609
1616
  }
1610
1617
  return !1;
1611
1618
  }
1612
1619
  function bt(e) {
1613
- if (At(e)) return !1;
1620
+ if (Rt(e)) return !1;
1614
1621
  if (e instanceof HTMLInputElement) {
1615
1622
  if (e.type === "password") return !1;
1616
1623
  const t = (e.getAttribute("autocomplete") || "").toLowerCase();
@@ -1618,7 +1625,7 @@ function bt(e) {
1618
1625
  }
1619
1626
  return !0;
1620
1627
  }
1621
- const ht = 4096, fr = 20, pr = 20, hr = 10, mr = 10, gr = 30, Zt = 500, yr = [
1628
+ const mt = 4096, hr = 20, mr = 20, gr = 10, yr = 10, vr = 30, en = 500, br = [
1622
1629
  '[data-ll-private="true"]',
1623
1630
  ".ll-widget",
1624
1631
  "script",
@@ -1626,24 +1633,24 @@ const ht = 4096, fr = 20, pr = 20, hr = 10, mr = 10, gr = 30, Zt = 500, yr = [
1626
1633
  "noscript",
1627
1634
  "iframe"
1628
1635
  ];
1629
- function et(e) {
1636
+ function tt(e) {
1630
1637
  if (e.getAttribute("aria-hidden") === "true" || e.hasAttribute("hidden")) return !0;
1631
1638
  let t = e;
1632
1639
  for (; t; ) {
1633
- for (const r of yr)
1640
+ for (const r of br)
1634
1641
  if (t.matches(r)) return !0;
1635
1642
  t = t.parentElement;
1636
1643
  }
1637
1644
  return !1;
1638
1645
  }
1639
- function tt(e) {
1646
+ function nt(e) {
1640
1647
  if (typeof window > "u") return !0;
1641
1648
  const t = e.getBoundingClientRect();
1642
1649
  if (t.width <= 0 || t.height <= 0) return !1;
1643
1650
  const r = window.innerHeight || document.documentElement.clientHeight, o = window.innerWidth || document.documentElement.clientWidth;
1644
1651
  return t.bottom > 0 && t.right > 0 && t.top < r && t.left < o;
1645
1652
  }
1646
- function en(e) {
1653
+ function tn(e) {
1647
1654
  const t = e.getAttribute("id");
1648
1655
  if (t) {
1649
1656
  const l = document.querySelector(`label[for="${CSS.escape(t)}"]`);
@@ -1659,10 +1666,10 @@ function en(e) {
1659
1666
  function Ae(e, t) {
1660
1667
  return e.length <= t ? e : e.slice(0, t - 1) + "…";
1661
1668
  }
1662
- function He(e) {
1669
+ function Ue(e) {
1663
1670
  return e.length;
1664
1671
  }
1665
- function br(e, t = {}) {
1672
+ function wr(e, t = {}) {
1666
1673
  const r = t.doc ?? (typeof document < "u" ? document : null);
1667
1674
  if (!r)
1668
1675
  return {
@@ -1676,105 +1683,105 @@ function br(e, t = {}) {
1676
1683
  forms: [],
1677
1684
  extras: e
1678
1685
  };
1679
- const o = typeof window < "u" && window.location.href || "", i = typeof window < "u" && window.location.pathname || "/", l = r.title || "", d = Array.from(
1686
+ const o = typeof window < "u" && window.location.href || "", i = typeof window < "u" && window.location.pathname || "/", l = r.title || "", u = Array.from(
1680
1687
  r.querySelectorAll("[data-ll-region]")
1681
- ), u = [];
1682
- for (const m of d) {
1683
- if (u.length >= hr) break;
1684
- if (et(m) || !tt(m)) continue;
1685
- const I = m.getAttribute("data-ll-region") ?? "", q = m.getAttribute("data-ll-intent") ?? void 0, B = Ae(
1688
+ ), d = [];
1689
+ for (const m of u) {
1690
+ if (d.length >= gr) break;
1691
+ if (tt(m) || !nt(m)) continue;
1692
+ const T = m.getAttribute("data-ll-region") ?? "", V = m.getAttribute("data-ll-intent") ?? void 0, z = Ae(
1686
1693
  (m.innerText || m.textContent || "").trim(),
1687
- Zt * 2
1694
+ en * 2
1688
1695
  );
1689
- !I || !B || u.push({ id: I, intent: q, text: B });
1696
+ !T || !z || d.push({ id: T, intent: V, text: z });
1690
1697
  }
1691
- const f = [], y = ["H1", "H2", "H3", "H4", "H5", "H6"], w = Array.from(
1698
+ const p = [], y = ["H1", "H2", "H3", "H4", "H5", "H6"], w = Array.from(
1692
1699
  r.querySelectorAll("h1, h2, h3, h4, h5, h6")
1693
1700
  );
1694
1701
  for (const m of w) {
1695
- if (et(m) || !tt(m)) continue;
1696
- const I = (m.textContent || "").trim();
1697
- I && f.push(`${m.tagName}: ${Ae(I, 200)}`);
1702
+ if (tt(m) || !nt(m)) continue;
1703
+ const T = (m.textContent || "").trim();
1704
+ T && p.push(`${m.tagName}: ${Ae(T, 200)}`);
1698
1705
  }
1699
1706
  const s = Array.from(r.querySelectorAll("p, li"));
1700
1707
  for (const m of s) {
1701
- if (et(m) || !tt(m) || y.includes(m.tagName)) continue;
1702
- const I = (m.textContent || "").trim();
1703
- I.length > 10 && f.push(Ae(I, Zt));
1708
+ if (tt(m) || !nt(m) || y.includes(m.tagName)) continue;
1709
+ const T = (m.textContent || "").trim();
1710
+ T.length > 10 && p.push(Ae(T, en));
1704
1711
  }
1705
- const a = f.join(`
1706
- `), L = [], D = Array.from(r.querySelectorAll("a[href]"));
1707
- for (const m of D) {
1708
- if (L.length >= fr) break;
1709
- if (et(m) || !tt(m)) continue;
1710
- const I = m.getAttribute("href") || "", q = (m.textContent || "").trim();
1711
- !I || !q || L.push({ href: I, text: Ae(q, 100) });
1712
+ const a = p.join(`
1713
+ `), L = [], R = Array.from(r.querySelectorAll("a[href]"));
1714
+ for (const m of R) {
1715
+ if (L.length >= hr) break;
1716
+ if (tt(m) || !nt(m)) continue;
1717
+ const T = m.getAttribute("href") || "", V = (m.textContent || "").trim();
1718
+ !T || !V || L.push({ href: T, text: Ae(V, 100) });
1712
1719
  }
1713
- const C = [], v = Array.from(
1720
+ const A = [], v = Array.from(
1714
1721
  r.querySelectorAll(
1715
1722
  "input, textarea, select"
1716
1723
  )
1717
1724
  );
1718
1725
  for (const m of v) {
1719
- if (C.length >= pr) break;
1720
- if (et(m) || !bt(m) || !tt(m)) continue;
1721
- const I = en(m), q = m instanceof HTMLInputElement ? m.type : m.tagName.toLowerCase();
1722
- I && C.push({ label: Ae(I, 100), type: q });
1726
+ if (A.length >= mr) break;
1727
+ if (tt(m) || !bt(m) || !nt(m)) continue;
1728
+ const T = tn(m), V = m instanceof HTMLInputElement ? m.type : m.tagName.toLowerCase();
1729
+ T && A.push({ label: Ae(T, 100), type: V });
1723
1730
  }
1724
1731
  const _ = Array.from(
1725
1732
  r.querySelectorAll("[data-ll-form]")
1726
- ), O = [];
1733
+ ), H = [];
1727
1734
  for (const m of _) {
1728
- if (O.length >= mr) break;
1729
- if (At(m)) continue;
1730
- const I = m.getAttribute("data-ll-form") || "";
1731
- if (!I) continue;
1732
- const q = m.getAttribute("data-ll-intent") || void 0, B = Array.from(
1735
+ if (H.length >= yr) break;
1736
+ if (Rt(m)) continue;
1737
+ const T = m.getAttribute("data-ll-form") || "";
1738
+ if (!T) continue;
1739
+ const V = m.getAttribute("data-ll-intent") || void 0, z = Array.from(
1733
1740
  m.querySelectorAll(
1734
1741
  "[data-ll-field]"
1735
1742
  )
1736
1743
  ), P = [];
1737
- for (const H of B) {
1738
- if (P.length >= gr) break;
1739
- if (!bt(H)) continue;
1740
- const G = H.getAttribute("data-ll-field") || "";
1744
+ for (const O of z) {
1745
+ if (P.length >= vr) break;
1746
+ if (!bt(O)) continue;
1747
+ const G = O.getAttribute("data-ll-field") || "";
1741
1748
  if (!G) continue;
1742
- const Z = en(H) || G, le = H instanceof HTMLInputElement ? H.type : H.tagName.toLowerCase();
1743
- P.push({ name: G, label: Ae(Z, 100), type: le });
1749
+ const ee = tn(O) || G, le = O instanceof HTMLInputElement ? O.type : O.tagName.toLowerCase();
1750
+ P.push({ name: G, label: Ae(ee, 100), type: le });
1744
1751
  }
1745
- O.push({ id: I, intent: q, fields: P });
1752
+ H.push({ id: T, intent: V, fields: P });
1746
1753
  }
1747
1754
  const $ = {
1748
1755
  url: o,
1749
1756
  title: l,
1750
1757
  pathname: i,
1751
- regions: u,
1758
+ regions: d,
1752
1759
  visibleText: a,
1753
1760
  visibleLinks: L,
1754
- visibleFields: C,
1755
- forms: O,
1761
+ visibleFields: A,
1762
+ forms: H,
1756
1763
  extras: e
1757
1764
  };
1758
- let U = He(JSON.stringify($.regions)) + He($.visibleText) + He(JSON.stringify($.visibleLinks)) + He(JSON.stringify($.visibleFields));
1759
- for (; U > ht && $.visibleFields.length > 0; )
1760
- $.visibleFields.pop(), U = He(JSON.stringify($.visibleFields));
1761
- for (; U > ht && $.visibleLinks.length > 0; )
1762
- $.visibleLinks.pop(), U -= 80;
1763
- return He($.visibleText) > ht && ($.visibleText = Ae($.visibleText, ht - 100)), $;
1765
+ let q = Ue(JSON.stringify($.regions)) + Ue($.visibleText) + Ue(JSON.stringify($.visibleLinks)) + Ue(JSON.stringify($.visibleFields));
1766
+ for (; q > mt && $.visibleFields.length > 0; )
1767
+ $.visibleFields.pop(), q = Ue(JSON.stringify($.visibleFields));
1768
+ for (; q > mt && $.visibleLinks.length > 0; )
1769
+ $.visibleLinks.pop(), q -= 80;
1770
+ return Ue($.visibleText) > mt && ($.visibleText = Ae($.visibleText, mt - 100)), $;
1764
1771
  }
1765
1772
  let Ve = null;
1766
- function mt(e, t = {}) {
1773
+ function gt(e, t = {}) {
1767
1774
  const r = Date.now(), i = `${typeof window < "u" && window.location.pathname || "/"}::${typeof window < "u" ? window.scrollY : 0}`;
1768
1775
  if (Ve && Ve.key === i && r - Ve.at < 1e3)
1769
1776
  return Ve.ctx;
1770
- const l = br(e, t);
1777
+ const l = wr(e, t);
1771
1778
  return Ve = { key: i, at: r, ctx: l }, l;
1772
1779
  }
1773
- function vr() {
1780
+ function _r() {
1774
1781
  Ve = null;
1775
1782
  }
1776
- const wr = 200;
1777
- function _r(e) {
1783
+ const xr = 200;
1784
+ function kr(e) {
1778
1785
  const t = String(e.href || "");
1779
1786
  return {
1780
1787
  href: t,
@@ -1784,63 +1791,63 @@ function _r(e) {
1784
1791
  description: e.description
1785
1792
  };
1786
1793
  }
1787
- function xr(e) {
1794
+ function Lr(e) {
1788
1795
  return !(!e || e.startsWith("#") || e.startsWith("javascript:") || e.startsWith("mailto:") || e.startsWith("tel:"));
1789
1796
  }
1790
- function kr(e) {
1797
+ function Sr(e) {
1791
1798
  const t = e ?? (typeof document < "u" ? document : null);
1792
1799
  if (!t) return [];
1793
1800
  const r = typeof window < "u" && window.location.origin || "", o = /* @__PURE__ */ new Set(), i = [], l = Array.from(t.querySelectorAll("a[href]"));
1794
- for (const d of l) {
1795
- if (i.length >= wr) break;
1796
- if (At(d)) continue;
1797
- const u = d.getAttribute("href") || "";
1798
- if (!xr(u)) continue;
1799
- let f = u, y = !0;
1801
+ for (const u of l) {
1802
+ if (i.length >= xr) break;
1803
+ if (Rt(u)) continue;
1804
+ const d = u.getAttribute("href") || "";
1805
+ if (!Lr(d)) continue;
1806
+ let p = d, y = !0;
1800
1807
  try {
1801
1808
  if (typeof window < "u") {
1802
- const s = new URL(u, r);
1803
- y = s.origin === r, y && u.startsWith("http") && (f = s.pathname + s.search + s.hash);
1809
+ const s = new URL(d, r);
1810
+ y = s.origin === r, y && d.startsWith("http") && (p = s.pathname + s.search + s.hash);
1804
1811
  }
1805
1812
  } catch {
1806
1813
  continue;
1807
1814
  }
1808
- if (o.has(f)) continue;
1809
- o.add(f);
1810
- const w = (d.textContent || "").trim().slice(0, 120);
1811
- i.push({ href: f, text: w, internal: y });
1815
+ if (o.has(p)) continue;
1816
+ o.add(p);
1817
+ const w = (u.textContent || "").trim().slice(0, 120);
1818
+ i.push({ href: p, text: w, internal: y });
1812
1819
  }
1813
1820
  return i;
1814
1821
  }
1815
- let qe = null;
1816
- const Lr = 5e3;
1817
- function nt() {
1822
+ let We = null;
1823
+ const Er = 5e3;
1824
+ function rt() {
1818
1825
  const e = Date.now(), t = typeof window < "u" && window.location.pathname || "/";
1819
- if (qe && qe.pathname === t && e - qe.at < Lr)
1820
- return qe.routes;
1821
- const r = kr();
1822
- return qe = { at: e, pathname: t, routes: r }, r;
1826
+ if (We && We.pathname === t && e - We.at < Er)
1827
+ return We.routes;
1828
+ const r = Sr();
1829
+ return We = { at: e, pathname: t, routes: r }, r;
1823
1830
  }
1824
- function Sr() {
1825
- qe = null;
1831
+ function Cr() {
1832
+ We = null;
1826
1833
  }
1827
- function Er(e, t) {
1834
+ function Nr(e, t) {
1828
1835
  const r = e instanceof HTMLInputElement ? HTMLInputElement.prototype : e instanceof HTMLTextAreaElement ? HTMLTextAreaElement.prototype : HTMLSelectElement.prototype, o = Object.getOwnPropertyDescriptor(r, "value"), i = o == null ? void 0 : o.set;
1829
1836
  i ? i.call(e, t) : e.value = t;
1830
1837
  }
1831
- function Cr(e, t, r = {}) {
1838
+ function Ar(e, t, r = {}) {
1832
1839
  const o = r.triggerInput ?? !0, i = r.triggerChange ?? !0;
1833
1840
  if (e instanceof HTMLInputElement && (e.type === "checkbox" || e.type === "radio")) {
1834
1841
  const l = Object.getOwnPropertyDescriptor(
1835
1842
  HTMLInputElement.prototype,
1836
1843
  "checked"
1837
- ), d = l == null ? void 0 : l.set, u = t === "true" || t === "1" || t === "on";
1838
- d ? d.call(e, u) : e.checked = u, o && e.dispatchEvent(new Event("input", { bubbles: !0 })), i && e.dispatchEvent(new Event("change", { bubbles: !0 }));
1844
+ ), u = l == null ? void 0 : l.set, d = t === "true" || t === "1" || t === "on";
1845
+ u ? u.call(e, d) : e.checked = d, o && e.dispatchEvent(new Event("input", { bubbles: !0 })), i && e.dispatchEvent(new Event("change", { bubbles: !0 }));
1839
1846
  return;
1840
1847
  }
1841
- Er(e, t), o && e.dispatchEvent(new Event("input", { bubbles: !0 })), i && e.dispatchEvent(new Event("change", { bubbles: !0 }));
1848
+ Nr(e, t), o && e.dispatchEvent(new Event("input", { bubbles: !0 })), i && e.dispatchEvent(new Event("change", { bubbles: !0 }));
1842
1849
  }
1843
- function Nr() {
1850
+ function Rr() {
1844
1851
  if (typeof window > "u" || typeof document > "u")
1845
1852
  return !1;
1846
1853
  const e = document.scrollingElement || document.documentElement;
@@ -1848,19 +1855,19 @@ function Nr() {
1848
1855
  const t = window.getComputedStyle(e);
1849
1856
  return !(t.overflowY === "hidden" || t.overflowY === "clip");
1850
1857
  }
1851
- function Ar(e) {
1858
+ function Dr(e) {
1852
1859
  if (!(e instanceof HTMLElement)) return !1;
1853
1860
  const r = window.getComputedStyle(e).overflowY;
1854
1861
  return !(r !== "auto" && r !== "scroll" || e.scrollHeight <= e.clientHeight + 2);
1855
1862
  }
1856
- function Dr() {
1863
+ function Mr() {
1857
1864
  if (typeof document > "u") return null;
1858
1865
  const e = Array.from(
1859
1866
  document.querySelectorAll("body, body *")
1860
1867
  );
1861
1868
  let t = null, r = 0;
1862
1869
  for (const o of e) {
1863
- if (!Ar(o)) continue;
1870
+ if (!Dr(o)) continue;
1864
1871
  const i = o.getBoundingClientRect();
1865
1872
  if (i.bottom <= 0 || i.top >= window.innerHeight || i.right <= 0 || i.left >= window.innerWidth || i.width <= 0 || i.height <= 0 || o.closest(".ll-widget")) continue;
1866
1873
  const l = i.width * i.height;
@@ -1868,24 +1875,24 @@ function Dr() {
1868
1875
  }
1869
1876
  return t;
1870
1877
  }
1871
- function Rr() {
1878
+ function Ir() {
1872
1879
  if (typeof window > "u")
1873
1880
  return null;
1874
- if (Nr()) return window;
1875
- const e = Dr();
1881
+ if (Rr()) return window;
1882
+ const e = Mr();
1876
1883
  return e || window;
1877
1884
  }
1878
- function tn(e) {
1885
+ function nn(e) {
1879
1886
  return e instanceof Window ? e.innerHeight || 0 : e.clientHeight || 0;
1880
1887
  }
1881
- function Mr(e) {
1888
+ function Tr(e) {
1882
1889
  var t, r;
1883
1890
  return e instanceof Window ? typeof document > "u" ? 0 : Math.max(
1884
1891
  ((t = document.body) == null ? void 0 : t.scrollHeight) ?? 0,
1885
1892
  ((r = document.documentElement) == null ? void 0 : r.scrollHeight) ?? 0
1886
1893
  ) : e.scrollHeight - e.clientHeight;
1887
1894
  }
1888
- const Tr = /* @__PURE__ */ new Set([
1895
+ const Pr = /* @__PURE__ */ new Set([
1889
1896
  "agent_state",
1890
1897
  "avatar_stream_ready",
1891
1898
  "avatar_active",
@@ -1912,100 +1919,100 @@ const Tr = /* @__PURE__ */ new Set([
1912
1919
  // where the agent's listener attaches AFTER the widget's first push.
1913
1920
  "request_initial_sync"
1914
1921
  ]);
1915
- function Ir(e) {
1916
- var It, Pt, $t, Bt, zt, Ot, Ut;
1922
+ function $r(e) {
1923
+ var Pt, $t, Bt, zt, Ht, qt, Ot;
1917
1924
  const {
1918
1925
  agentId: t,
1919
1926
  apiKey: r,
1920
1927
  baseUrl: o = "https://app.livelayer.studio",
1921
1928
  sessionEndpoint: i,
1922
1929
  sessionBody: l,
1923
- autoConnect: d = !1,
1924
- displayMode: u,
1925
- defaultDisplayMode: f = "expanded",
1930
+ autoConnect: u = !1,
1931
+ displayMode: d,
1932
+ defaultDisplayMode: p = "expanded",
1926
1933
  onDisplayModeChange: y,
1927
1934
  position: w = "bottom-right",
1928
1935
  mobileBreakpoint: s = 640,
1929
1936
  persistKey: a = "ll-widget",
1930
1937
  disablePersistence: L = !1,
1931
- teamMembers: D,
1932
- currentTeamMemberId: C,
1938
+ teamMembers: R,
1939
+ currentTeamMemberId: A,
1933
1940
  onTeamMemberChange: v,
1934
1941
  idleLoopUrl: _,
1935
- greeting: O,
1942
+ greeting: H,
1936
1943
  avatarImageUrl: $,
1937
- agentName: U,
1944
+ agentName: q,
1938
1945
  branding: m = {},
1939
- allowCamera: I = !0,
1940
- allowScreenShare: q = !0,
1941
- allowTyping: B = !0,
1946
+ allowCamera: T = !0,
1947
+ allowScreenShare: V = !0,
1948
+ allowTyping: z = !0,
1942
1949
  showOn: P,
1943
- hideOn: H,
1950
+ hideOn: O,
1944
1951
  pathname: G,
1945
- onNavigate: Z,
1952
+ onNavigate: ee,
1946
1953
  onScrollToSelector: le,
1947
1954
  getPageContext: Le,
1948
- pageContextExtras: rt,
1949
- getRoutes: ot,
1950
- onScrollPage: it,
1951
- onClick: lt,
1955
+ pageContextExtras: ot,
1956
+ getRoutes: it,
1957
+ onScrollPage: lt,
1958
+ onClick: at,
1952
1959
  capabilities: ie,
1953
- onConnect: pe,
1960
+ onConnect: he,
1954
1961
  onDisconnect: Se,
1955
- onTranscript: De,
1956
- onAgentState: Re,
1962
+ onTranscript: Re,
1963
+ onAgentState: De,
1957
1964
  onConnectionStateChange: Me,
1958
- onAgentEvent: Te,
1959
- onAgentCommand: Ie,
1960
- controlledSession: Y,
1961
- className: vt,
1962
- style: wt,
1963
- zIndex: at = 2147483647
1964
- } = e, ae = Hn(G), Pe = Jn(ae, P, H);
1965
- M(() => {
1966
- vr(), Sr();
1965
+ onAgentEvent: Ie,
1966
+ onAgentCommand: Te,
1967
+ controlledSession: J,
1968
+ className: wt,
1969
+ style: _t,
1970
+ zIndex: st = 2147483647
1971
+ } = e, ae = Vn(G), Pe = Kn(ae, P, O);
1972
+ I(() => {
1973
+ _r(), Cr();
1967
1974
  }, [ae]);
1968
- const We = C !== void 0, [Ee, $e] = E(() => {
1969
- var h;
1970
- return C ?? ((h = D == null ? void 0 : D[0]) == null ? void 0 : h.id);
1971
- }), Q = We ? C : Ee, ne = gt(
1972
- () => (D == null ? void 0 : D.find((h) => h.id === Q)) ?? null,
1973
- [D, Q]
1974
- ), Be = (ne == null ? void 0 : ne.agentId) ?? t, [se, he] = Bn({
1975
- value: u,
1976
- defaultValue: f,
1975
+ const Fe = A !== void 0, [Ee, $e] = C(() => {
1976
+ var f;
1977
+ return A ?? ((f = R == null ? void 0 : R[0]) == null ? void 0 : f.id);
1978
+ }), X = Fe ? A : Ee, te = yt(
1979
+ () => (R == null ? void 0 : R.find((f) => f.id === X)) ?? null,
1980
+ [R, X]
1981
+ ), Be = (te == null ? void 0 : te.agentId) ?? t, [se, me] = Hn({
1982
+ value: d,
1983
+ defaultValue: p,
1977
1984
  onChange: y,
1978
1985
  persistKey: a,
1979
1986
  disablePersistence: L
1980
- }), Ce = On(s), Ge = Sn(), re = En(), ce = Nn(), de = An(), me = Dn(), [ze, ge] = E(!1), [ye, Fe] = E(!1), [je, Je] = E(!1), [be, ve] = E(!1), [Oe, st] = E(!1), Ye = A(Z), Ue = A(le), p = A(it), K = A(lt), _t = A(Le), ct = A(rt), dt = A(ot), xt = A(ie), oe = A(null), ut = A(null), Dt = A(void 0);
1981
- Dt.current = ae, Ye.current = Z, Ue.current = le, p.current = it, K.current = lt, _t.current = Le, ct.current = rt, dt.current = ot, xt.current = ie;
1982
- function we(h) {
1983
- const c = xt.current;
1984
- return c ? c.includes(h) : !0;
1987
+ }), Ce = On(s), je = Cn(), re = Nn(), ce = Rn(), ue = Dn(), ge = Mn(), [ze, ye] = C(!1), [ve, Ge] = C(!1), [Ye, Je] = C(!1), [be, we] = C(!1), [He, ct] = C(!1), Ke = N(ee), qe = N(le), h = N(lt), K = N(at), xt = N(Le), ut = N(ot), dt = N(it), kt = N(ie), oe = N(null), ft = N(null), Oe = N(null), Dt = N(void 0);
1988
+ Dt.current = ae, Ke.current = ee, qe.current = le, h.current = lt, K.current = at, xt.current = Le, ut.current = ot, dt.current = it, kt.current = ie;
1989
+ function _e(f) {
1990
+ const c = kt.current;
1991
+ return c ? c.includes(f) : !0;
1985
1992
  }
1986
- function _e(h, c) {
1993
+ function xe(f, c) {
1987
1994
  console.warn(
1988
- `[LiveLayer] Agent command "${h}" blocked — capability "${c}" not in allowlist. See https://livelayer.studio/docs/react/capabilities`
1995
+ `[LiveLayer] Agent command "${f}" blocked — capability "${c}" not in allowlist. See https://livelayer.studio/docs/react/capabilities`
1989
1996
  );
1990
1997
  }
1991
- const Ke = S(
1992
- (h) => {
1993
- var J, ue, te, xe, ke, X;
1994
- const c = h;
1998
+ const Xe = S(
1999
+ (f) => {
2000
+ var W, ne, Q, de, fe, ke;
2001
+ const c = f;
1995
2002
  if (!(!c.type || typeof c.type != "string")) {
1996
- if (Te == null || Te({ eventName: c.type, data: h }), c.type === "bot_ready" || c.type === "request_initial_sync") {
2003
+ if (Ie == null || Ie({ eventName: c.type, data: f }), c.type === "bot_ready" || c.type === "request_initial_sync") {
1997
2004
  console.log(
1998
2005
  `[NAV-DEBUG][widget] received ${c.type} → triggering pushSnapshot`
1999
2006
  );
2000
2007
  try {
2001
- (J = ut.current) == null || J.call(ut);
2008
+ (W = ft.current) == null || W.call(ft);
2002
2009
  } catch (b) {
2003
2010
  console.warn("[NAV-DEBUG][widget] pushSnapshot threw:", b);
2004
2011
  }
2005
2012
  }
2006
2013
  if (c.type === "navigate") {
2007
- if (!we("navigate")) {
2008
- _e("navigate", "navigate");
2014
+ if (!_e("navigate")) {
2015
+ xe("navigate", "navigate");
2009
2016
  return;
2010
2017
  }
2011
2018
  const b = typeof c.href == "string" ? c.href : null;
@@ -2015,130 +2022,131 @@ function Ir(e) {
2015
2022
  );
2016
2023
  return;
2017
2024
  }
2018
- if (Ye.current) {
2025
+ if (Ke.current) {
2019
2026
  try {
2020
- Ye.current(b);
2021
- } catch (k) {
2027
+ Ke.current(b);
2028
+ } catch (E) {
2022
2029
  console.warn(
2023
2030
  `[LiveLayer] onNavigate threw for "${b}". Falling back. Error:`,
2024
- k
2031
+ E
2025
2032
  );
2026
2033
  }
2027
2034
  return;
2028
2035
  }
2029
2036
  if (typeof document < "u") {
2030
- const k = document.querySelector(
2037
+ const E = document.querySelector(
2031
2038
  `a[href="${b.replace(/"/g, '\\"')}"]`
2032
2039
  );
2033
- if (k) {
2034
- k.click();
2040
+ if (E) {
2041
+ E.click();
2035
2042
  return;
2036
2043
  }
2037
2044
  }
2038
2045
  if (typeof window < "u" && typeof history < "u")
2039
2046
  try {
2040
2047
  history.pushState({}, "", b), window.dispatchEvent(new PopStateEvent("popstate"));
2041
- } catch (k) {
2048
+ } catch (E) {
2042
2049
  console.warn(
2043
2050
  `[LiveLayer] history.pushState fallback failed for "${b}". Pass an onNavigate prop to use your router directly. See https://livelayer.studio/docs/react/navigation`,
2044
- k
2051
+ E
2045
2052
  );
2046
2053
  }
2047
2054
  return;
2048
2055
  }
2049
2056
  if (c.type === "scroll_to") {
2050
- if (!we("scroll")) {
2051
- _e("scroll_to", "scroll");
2057
+ if (!_e("scroll")) {
2058
+ xe("scroll_to", "scroll");
2052
2059
  return;
2053
2060
  }
2054
2061
  const b = typeof c.selector == "string" ? c.selector : null;
2055
2062
  if (!b) return;
2056
- const k = c.behavior === "instant" ? "instant" : "smooth";
2057
- if (Ue.current) {
2063
+ const E = c.behavior === "instant" ? "instant" : "smooth";
2064
+ if (qe.current) {
2058
2065
  try {
2059
- Ue.current(
2066
+ qe.current(
2060
2067
  b,
2061
- k
2068
+ E
2062
2069
  );
2063
- } catch (R) {
2064
- console.warn("[LiveLayer] onScrollToSelector threw.", R);
2070
+ } catch (k) {
2071
+ console.warn("[LiveLayer] onScrollToSelector threw.", k);
2065
2072
  }
2066
2073
  return;
2067
2074
  }
2068
2075
  if (typeof document < "u") {
2069
- let R = null;
2076
+ let k = null;
2070
2077
  try {
2071
- R = document.querySelector(b);
2078
+ k = document.querySelector(b);
2072
2079
  } catch {
2073
2080
  console.warn(
2074
2081
  `[LiveLayer] scroll_to: invalid selector "${b}".`
2075
2082
  );
2076
2083
  return;
2077
2084
  }
2078
- if (!R) {
2085
+ if (!k) {
2079
2086
  console.warn(
2080
2087
  `[LiveLayer] scroll_to: no element matched "${b}". The user may be on a different page. See https://livelayer.studio/docs/errors/scroll-no-match`
2081
2088
  );
2082
2089
  return;
2083
2090
  }
2084
- R.scrollIntoView({
2085
- behavior: k,
2091
+ k.scrollIntoView({
2092
+ behavior: E,
2086
2093
  block: "start"
2087
2094
  });
2088
2095
  }
2089
2096
  return;
2090
2097
  }
2091
2098
  if (c.type === "request_page_context") {
2092
- if (!we("read_page")) {
2093
- _e("request_page_context", "read_page");
2099
+ if (!_e("read_page")) {
2100
+ xe("request_page_context", "read_page");
2094
2101
  return;
2095
2102
  }
2096
- const b = typeof c.requestId == "string" ? c.requestId : void 0, k = (ue = oe.current) == null ? void 0 : ue.call(oe), R = (j) => {
2097
- const T = k, F = T == null ? void 0 : T.localParticipant;
2098
- if (F != null && F.publishData)
2099
- try {
2100
- const z = b ? { ...j, requestId: b } : j, ee = new TextEncoder().encode(JSON.stringify(z));
2101
- F.publishData(ee, { reliable: !0 });
2102
- } catch (z) {
2103
- console.warn("[LiveLayer] publishData failed.", z);
2104
- }
2105
- }, N = ct.current, W = _t.current;
2103
+ const b = typeof c.requestId == "string" ? c.requestId : void 0, E = (ne = oe.current) == null ? void 0 : ne.call(oe), k = (j) => {
2104
+ const M = E, Y = M == null ? void 0 : M.localParticipant;
2105
+ if (!(Y != null && Y.publishData)) {
2106
+ console.warn(
2107
+ "[NAV-DEBUG][widget] request_page_context response: no publishData"
2108
+ );
2109
+ return;
2110
+ }
2111
+ const B = b ? { ...j, requestId: b } : j, Z = Oe.current;
2112
+ Z && Z(Y, B, `request_page_context-resp/${String(j.type)}`);
2113
+ }, D = ut.current, F = xt.current;
2106
2114
  try {
2107
- if (W) {
2108
- const j = W(N);
2115
+ if (F) {
2116
+ const j = F(D);
2109
2117
  if (j instanceof Promise) {
2110
- R({ type: "page_context_pending" }), j.then((T) => R({ type: "page_context", context: T })).catch((T) => {
2118
+ k({ type: "page_context_pending" }), j.then((M) => k({ type: "page_context", context: M })).catch((M) => {
2111
2119
  console.warn(
2112
2120
  "[LiveLayer] getPageContext rejected; falling back to default walker.",
2113
- T
2114
- ), R({
2121
+ M
2122
+ ), k({
2115
2123
  type: "page_context",
2116
- context: mt(N)
2124
+ context: gt(D)
2117
2125
  });
2118
2126
  });
2119
2127
  return;
2120
2128
  }
2121
- R({ type: "page_context", context: j });
2129
+ k({ type: "page_context", context: j });
2122
2130
  return;
2123
2131
  }
2124
- R({
2132
+ k({
2125
2133
  type: "page_context",
2126
- context: mt(N)
2134
+ context: gt(D)
2127
2135
  });
2128
2136
  } catch (j) {
2129
2137
  console.warn(
2130
2138
  "[LiveLayer] page-context extraction threw. Sending empty context.",
2131
2139
  j
2132
- ), R({
2140
+ ), k({
2133
2141
  type: "page_context",
2134
- context: { url: "", title: "", pathname: "/", regions: [], visibleText: "", visibleLinks: [], visibleFields: [], forms: [], extras: N }
2142
+ context: { url: "", title: "", pathname: "/", regions: [], visibleText: "", visibleLinks: [], visibleFields: [], forms: [], extras: D }
2135
2143
  });
2136
2144
  }
2137
2145
  return;
2138
2146
  }
2139
2147
  if (c.type === "scroll_page") {
2140
- if (!we("scroll")) {
2141
- _e("scroll_page", "scroll");
2148
+ if (!_e("scroll")) {
2149
+ xe("scroll_page", "scroll");
2142
2150
  return;
2143
2151
  }
2144
2152
  const b = c.direction;
@@ -2148,30 +2156,30 @@ function Ir(e) {
2148
2156
  );
2149
2157
  return;
2150
2158
  }
2151
- const k = c.behavior === "instant" ? "instant" : "smooth";
2152
- if (p.current) {
2159
+ const E = c.behavior === "instant" ? "instant" : "smooth";
2160
+ if (h.current) {
2153
2161
  try {
2154
- p.current(
2162
+ h.current(
2155
2163
  b,
2156
- k
2164
+ E
2157
2165
  );
2158
- } catch (T) {
2159
- console.warn("[LiveLayer] onScrollPage threw.", T);
2166
+ } catch (M) {
2167
+ console.warn("[LiveLayer] onScrollPage threw.", M);
2160
2168
  }
2161
2169
  return;
2162
2170
  }
2163
2171
  if (typeof window > "u") return;
2164
- const R = { behavior: k }, N = Rr(), W = (T) => {
2165
- N instanceof Window ? N.scrollBy({ top: T, ...R }) : N.scrollBy({ top: T, ...R });
2166
- }, j = (T) => {
2167
- N instanceof Window ? N.scrollTo({ top: T, ...R }) : N.scrollTo({ top: T, ...R });
2172
+ const k = { behavior: E }, D = Ir(), F = (M) => {
2173
+ D instanceof Window ? D.scrollBy({ top: M, ...k }) : D.scrollBy({ top: M, ...k });
2174
+ }, j = (M) => {
2175
+ D instanceof Window ? D.scrollTo({ top: M, ...k }) : D.scrollTo({ top: M, ...k });
2168
2176
  };
2169
- b === "up" ? W(-tn(N)) : b === "down" ? W(tn(N)) : j(b === "top" ? 0 : Mr(N));
2177
+ b === "up" ? F(-nn(D)) : b === "down" ? F(nn(D)) : j(b === "top" ? 0 : Tr(D));
2170
2178
  return;
2171
2179
  }
2172
2180
  if (c.type === "click") {
2173
- if (!we("click")) {
2174
- _e("click", "click");
2181
+ if (!_e("click")) {
2182
+ xe("click", "click");
2175
2183
  return;
2176
2184
  }
2177
2185
  const b = typeof c.selector == "string" ? c.selector : null;
@@ -2182,152 +2190,152 @@ function Ir(e) {
2182
2190
  if (K.current) {
2183
2191
  try {
2184
2192
  K.current(b);
2185
- } catch (R) {
2186
- console.warn("[LiveLayer] onClick threw.", R);
2193
+ } catch (k) {
2194
+ console.warn("[LiveLayer] onClick threw.", k);
2187
2195
  }
2188
2196
  return;
2189
2197
  }
2190
2198
  if (typeof document > "u") return;
2191
- let k = null;
2199
+ let E = null;
2192
2200
  try {
2193
- k = document.querySelector(b);
2201
+ E = document.querySelector(b);
2194
2202
  } catch {
2195
2203
  console.warn(
2196
2204
  `[LiveLayer] click: invalid selector "${b}".`
2197
2205
  );
2198
2206
  return;
2199
2207
  }
2200
- if (!k) {
2208
+ if (!E) {
2201
2209
  console.warn(
2202
2210
  `[LiveLayer] click: no element matched "${b}". See https://livelayer.studio/docs/errors/click-no-match`
2203
2211
  );
2204
2212
  return;
2205
2213
  }
2206
- if (k.closest('[data-ll-private="true"], .ll-widget')) {
2214
+ if (E.closest('[data-ll-private="true"], .ll-widget')) {
2207
2215
  console.warn(
2208
2216
  "[LiveLayer] click: refusing to click element inside a private subtree."
2209
2217
  );
2210
2218
  return;
2211
2219
  }
2212
- (te = k.click) == null || te.call(k);
2220
+ (Q = E.click) == null || Q.call(E);
2213
2221
  return;
2214
2222
  }
2215
2223
  if (c.type === "fill_form" || c.type === "focus_field") {
2216
- if (!we("fill_forms")) {
2217
- _e(c.type, "fill_forms");
2224
+ if (!_e("fill_forms")) {
2225
+ xe(c.type, "fill_forms");
2218
2226
  return;
2219
2227
  }
2220
2228
  if (typeof document > "u") return;
2221
- const b = typeof c.requestId == "string" ? c.requestId : void 0, k = (xe = oe.current) == null ? void 0 : xe.call(oe), R = (z) => {
2229
+ const b = typeof c.requestId == "string" ? c.requestId : void 0, E = (de = oe.current) == null ? void 0 : de.call(oe), k = (B) => {
2222
2230
  if (c.type !== "fill_form") return;
2223
- const ee = k, fe = ee == null ? void 0 : ee.localParticipant;
2224
- if (fe != null && fe.publishData)
2231
+ const Z = E, pe = Z == null ? void 0 : Z.localParticipant;
2232
+ if (pe != null && pe.publishData)
2225
2233
  try {
2226
- const Ne = b ? { ...z, requestId: b } : z, yn = new TextEncoder().encode(JSON.stringify(Ne));
2227
- fe.publishData(yn, { reliable: !0 });
2234
+ const Ne = b ? { ...B, requestId: b } : B, bn = new TextEncoder().encode(JSON.stringify(Ne));
2235
+ pe.publishData(bn, { reliable: !0 });
2228
2236
  } catch (Ne) {
2229
2237
  console.warn("[LiveLayer] publishData failed.", Ne);
2230
2238
  }
2231
- }, N = typeof c.formId == "string" ? c.formId : null;
2232
- if (!N) {
2233
- console.warn(`[LiveLayer] ${c.type}: missing formId.`), R({ type: "fill_form_result", ok: !1, reason: "missing formId" });
2239
+ }, D = typeof c.formId == "string" ? c.formId : null;
2240
+ if (!D) {
2241
+ console.warn(`[LiveLayer] ${c.type}: missing formId.`), k({ type: "fill_form_result", ok: !1, reason: "missing formId" });
2234
2242
  return;
2235
2243
  }
2236
- const W = document.querySelector(
2237
- `[data-ll-form="${N.replace(/"/g, '\\"')}"]`
2244
+ const F = document.querySelector(
2245
+ `[data-ll-form="${D.replace(/"/g, '\\"')}"]`
2238
2246
  );
2239
- if (!W) {
2247
+ if (!F) {
2240
2248
  console.warn(
2241
- `[LiveLayer] ${c.type}: no form with data-ll-form="${N}". Tag your form with <LiveLayerForm id> or data-ll-form. See https://livelayer.studio/docs/react/forms`
2242
- ), R({
2249
+ `[LiveLayer] ${c.type}: no form with data-ll-form="${D}". Tag your form with <LiveLayerForm id> or data-ll-form. See https://livelayer.studio/docs/react/forms`
2250
+ ), k({
2243
2251
  type: "fill_form_result",
2244
2252
  ok: !1,
2245
- reason: `no form with data-ll-form="${N}" on this page`,
2246
- formId: N
2253
+ reason: `no form with data-ll-form="${D}" on this page`,
2254
+ formId: D
2247
2255
  });
2248
2256
  return;
2249
2257
  }
2250
- if (W.closest('[data-ll-private="true"], .ll-widget')) {
2258
+ if (F.closest('[data-ll-private="true"], .ll-widget')) {
2251
2259
  console.warn(
2252
2260
  `[LiveLayer] ${c.type}: refusing to touch a form in a private subtree.`
2253
- ), R({
2261
+ ), k({
2254
2262
  type: "fill_form_result",
2255
2263
  ok: !1,
2256
2264
  reason: "form is in a private subtree (data-ll-private)",
2257
- formId: N
2265
+ formId: D
2258
2266
  });
2259
2267
  return;
2260
2268
  }
2261
2269
  if (c.type === "focus_field") {
2262
- const z = typeof c.fieldName == "string" ? c.fieldName : null;
2263
- if (!z) {
2270
+ const B = typeof c.fieldName == "string" ? c.fieldName : null;
2271
+ if (!B) {
2264
2272
  console.warn("[LiveLayer] focus_field: missing fieldName.");
2265
2273
  return;
2266
2274
  }
2267
- const ee = W.querySelector(`[data-ll-field="${z.replace(/"/g, '\\"')}"]`);
2268
- if (!ee) {
2275
+ const Z = F.querySelector(`[data-ll-field="${B.replace(/"/g, '\\"')}"]`);
2276
+ if (!Z) {
2269
2277
  console.warn(
2270
- `[LiveLayer] focus_field: no field "${z}" in form "${N}".`
2278
+ `[LiveLayer] focus_field: no field "${B}" in form "${D}".`
2271
2279
  );
2272
2280
  return;
2273
2281
  }
2274
- if (!bt(ee)) {
2282
+ if (!bt(Z)) {
2275
2283
  console.warn(
2276
- `[LiveLayer] focus_field: field "${z}" is privacy-protected and not focusable.`
2284
+ `[LiveLayer] focus_field: field "${B}" is privacy-protected and not focusable.`
2277
2285
  );
2278
2286
  return;
2279
2287
  }
2280
- ee.focus();
2288
+ Z.focus();
2281
2289
  return;
2282
2290
  }
2283
2291
  const j = c.values && typeof c.values == "object" ? c.values : null;
2284
2292
  if (!j) {
2285
- console.warn("[LiveLayer] fill_form: missing or invalid values."), R({
2293
+ console.warn("[LiveLayer] fill_form: missing or invalid values."), k({
2286
2294
  type: "fill_form_result",
2287
2295
  ok: !1,
2288
2296
  reason: "missing or invalid values",
2289
- formId: N
2297
+ formId: D
2290
2298
  });
2291
2299
  return;
2292
2300
  }
2293
- const T = [], F = [];
2294
- for (const [z, ee] of Object.entries(j)) {
2295
- if (typeof ee != "string") continue;
2296
- const fe = W.querySelector(`[data-ll-field="${z.replace(/"/g, '\\"')}"]`);
2297
- if (!fe) {
2301
+ const M = [], Y = [];
2302
+ for (const [B, Z] of Object.entries(j)) {
2303
+ if (typeof Z != "string") continue;
2304
+ const pe = F.querySelector(`[data-ll-field="${B.replace(/"/g, '\\"')}"]`);
2305
+ if (!pe) {
2298
2306
  console.warn(
2299
- `[LiveLayer] fill_form: no field "${z}" in form "${N}". Skipping.`
2300
- ), F.push(z);
2307
+ `[LiveLayer] fill_form: no field "${B}" in form "${D}". Skipping.`
2308
+ ), Y.push(B);
2301
2309
  continue;
2302
2310
  }
2303
- if (!bt(fe)) {
2311
+ if (!bt(pe)) {
2304
2312
  console.warn(
2305
- `[LiveLayer] fill_form: field "${z}" is privacy-protected (password / cc-* / private). Skipping.`
2306
- ), F.push(z);
2313
+ `[LiveLayer] fill_form: field "${B}" is privacy-protected (password / cc-* / private). Skipping.`
2314
+ ), Y.push(B);
2307
2315
  continue;
2308
2316
  }
2309
2317
  try {
2310
- Cr(fe, ee), T.push(z);
2318
+ Ar(pe, Z), M.push(B);
2311
2319
  } catch (Ne) {
2312
2320
  console.warn(
2313
- `[LiveLayer] fill_form: failed to set "${z}".`,
2321
+ `[LiveLayer] fill_form: failed to set "${B}".`,
2314
2322
  Ne
2315
- ), F.push(z);
2323
+ ), Y.push(B);
2316
2324
  }
2317
2325
  }
2318
- R({
2326
+ k({
2319
2327
  type: "fill_form_result",
2320
- ok: T.length > 0,
2321
- formId: N,
2322
- filled: T,
2323
- skipped: F,
2324
- reason: T.length === 0 ? `none of the requested fields exist on this form (skipped: ${F.join(", ")})` : void 0
2328
+ ok: M.length > 0,
2329
+ formId: D,
2330
+ filled: M,
2331
+ skipped: Y,
2332
+ reason: M.length === 0 ? `none of the requested fields exist on this form (skipped: ${Y.join(", ")})` : void 0
2325
2333
  });
2326
2334
  return;
2327
2335
  }
2328
2336
  if (c.type === "submit_form") {
2329
- if (!we("submit_forms")) {
2330
- _e("submit_form", "submit_forms");
2337
+ if (!_e("submit_forms")) {
2338
+ xe("submit_form", "submit_forms");
2331
2339
  return;
2332
2340
  }
2333
2341
  if (typeof document > "u") return;
@@ -2336,39 +2344,39 @@ function Ir(e) {
2336
2344
  console.warn("[LiveLayer] submit_form: missing formId.");
2337
2345
  return;
2338
2346
  }
2339
- const k = document.querySelector(
2347
+ const E = document.querySelector(
2340
2348
  `[data-ll-form="${b.replace(/"/g, '\\"')}"]`
2341
2349
  );
2342
- if (!k) {
2350
+ if (!E) {
2343
2351
  console.warn(
2344
2352
  `[LiveLayer] submit_form: no form with data-ll-form="${b}".`
2345
2353
  );
2346
2354
  return;
2347
2355
  }
2348
- if (k.closest('[data-ll-private="true"], .ll-widget')) {
2356
+ if (E.closest('[data-ll-private="true"], .ll-widget')) {
2349
2357
  console.warn(
2350
2358
  "[LiveLayer] submit_form: refusing to submit a form in a private subtree."
2351
2359
  );
2352
2360
  return;
2353
2361
  }
2354
- const R = typeof c.requestId == "string" ? c.requestId : void 0, N = (ke = oe.current) == null ? void 0 : ke.call(oe), W = (F) => {
2355
- const z = N, ee = z == null ? void 0 : z.localParticipant;
2356
- if (ee != null && ee.publishData)
2362
+ const k = typeof c.requestId == "string" ? c.requestId : void 0, D = (fe = oe.current) == null ? void 0 : fe.call(oe), F = (Y) => {
2363
+ const B = D, Z = B == null ? void 0 : B.localParticipant;
2364
+ if (Z != null && Z.publishData)
2357
2365
  try {
2358
- const fe = R ? { ...F, requestId: R } : F, Ne = new TextEncoder().encode(JSON.stringify(fe));
2359
- ee.publishData(Ne, { reliable: !0 });
2366
+ const pe = k ? { ...Y, requestId: k } : Y, Ne = new TextEncoder().encode(JSON.stringify(pe));
2367
+ Z.publishData(Ne, { reliable: !0 });
2360
2368
  } catch {
2361
2369
  }
2362
2370
  };
2363
2371
  let j = !1;
2364
- const T = () => {
2365
- j = !0, W({ type: "form_submitted", formId: b });
2372
+ const M = () => {
2373
+ j = !0, F({ type: "form_submitted", formId: b });
2366
2374
  };
2367
- k.addEventListener("submit", T, { once: !0 });
2375
+ E.addEventListener("submit", M, { once: !0 });
2368
2376
  try {
2369
- typeof k.requestSubmit == "function" ? k.requestSubmit() : k.submit();
2370
- } catch (F) {
2371
- console.warn("[LiveLayer] submit_form: requestSubmit threw.", F), k.removeEventListener("submit", T), W({
2377
+ typeof E.requestSubmit == "function" ? E.requestSubmit() : E.submit();
2378
+ } catch (Y) {
2379
+ console.warn("[LiveLayer] submit_form: requestSubmit threw.", Y), E.removeEventListener("submit", M), F({
2372
2380
  type: "form_submit_blocked",
2373
2381
  formId: b,
2374
2382
  reason: "exception"
@@ -2376,7 +2384,7 @@ function Ir(e) {
2376
2384
  return;
2377
2385
  }
2378
2386
  setTimeout(() => {
2379
- j || (k.removeEventListener("submit", T), W({
2387
+ j || (E.removeEventListener("submit", M), F({
2380
2388
  type: "form_submit_blocked",
2381
2389
  formId: b,
2382
2390
  reason: "validation"
@@ -2385,440 +2393,420 @@ function Ir(e) {
2385
2393
  return;
2386
2394
  }
2387
2395
  if (c.type === "request_routes") {
2388
- if (!we("read_page")) {
2389
- _e("request_routes", "read_page");
2396
+ if (!_e("read_page")) {
2397
+ xe("request_routes", "read_page");
2390
2398
  return;
2391
2399
  }
2392
- const b = typeof c.requestId == "string" ? c.requestId : void 0, R = (X = oe.current) == null ? void 0 : X.call(oe), N = R == null ? void 0 : R.localParticipant;
2393
- if (!(N != null && N.publishData)) return;
2394
- const W = (T) => {
2395
- try {
2396
- const F = b ? { type: "routes", routes: T, requestId: b } : { type: "routes", routes: T }, z = new TextEncoder().encode(JSON.stringify(F));
2397
- N.publishData(z, { reliable: !0 });
2398
- } catch (F) {
2399
- console.warn("[LiveLayer] request_routes: publishData failed.", F);
2400
- }
2400
+ const b = typeof c.requestId == "string" ? c.requestId : void 0, k = (ke = oe.current) == null ? void 0 : ke.call(oe), D = k == null ? void 0 : k.localParticipant;
2401
+ if (!(D != null && D.publishData)) return;
2402
+ const F = (M) => {
2403
+ const Y = b ? { type: "routes", routes: M, requestId: b } : { type: "routes", routes: M }, B = Oe.current;
2404
+ B && B(D, Y, `request_routes-resp(${M.length})`);
2401
2405
  }, j = dt.current;
2402
2406
  if (j) {
2403
2407
  try {
2404
- const T = j(), F = (z) => {
2405
- if (!Array.isArray(z)) {
2406
- W([]);
2408
+ const M = j(), Y = (B) => {
2409
+ if (!Array.isArray(B)) {
2410
+ F([]);
2407
2411
  return;
2408
2412
  }
2409
- W(z.map(_r).slice(0, 200));
2413
+ F(B.map(kr).slice(0, 200));
2410
2414
  };
2411
- T instanceof Promise ? T.then(F).catch((z) => {
2415
+ M instanceof Promise ? M.then(Y).catch((B) => {
2412
2416
  console.warn(
2413
2417
  "[LiveLayer] getRoutes rejected; falling back to DOM walker.",
2414
- z
2415
- ), W(nt());
2416
- }) : F(T);
2417
- } catch (T) {
2418
+ B
2419
+ ), F(rt());
2420
+ }) : Y(M);
2421
+ } catch (M) {
2418
2422
  console.warn(
2419
2423
  "[LiveLayer] getRoutes threw; falling back to DOM walker.",
2420
- T
2421
- ), W(nt());
2424
+ M
2425
+ ), F(rt());
2422
2426
  }
2423
2427
  return;
2424
2428
  }
2425
2429
  try {
2426
- W(nt());
2427
- } catch (T) {
2428
- console.warn("[LiveLayer] request_routes: extractRoutes threw.", T);
2430
+ F(rt());
2431
+ } catch (M) {
2432
+ console.warn("[LiveLayer] request_routes: extractRoutes threw.", M);
2429
2433
  }
2430
2434
  return;
2431
2435
  }
2432
- Tr.has(c.type) || Ie == null || Ie(c);
2436
+ Pr.has(c.type) || Te == null || Te(c);
2433
2437
  }
2434
2438
  },
2435
- [Ie, Te]
2436
- ), V = Ln({
2437
- agentId: Y ? "__controlled__" : Be,
2439
+ [Te, Ie]
2440
+ ), U = En({
2441
+ agentId: J ? "__controlled__" : Be,
2438
2442
  baseUrl: o,
2439
2443
  apiKey: r,
2440
2444
  sessionEndpoint: i,
2441
2445
  sessionBody: l,
2442
- onDataMessage: Y ? void 0 : Ke
2446
+ onDataMessage: J ? void 0 : Xe
2443
2447
  });
2444
- M(() => {
2445
- if (Y != null && Y.subscribeToDataMessages)
2446
- return Y.subscribeToDataMessages(Ke);
2447
- }, [Y, Ke]), oe.current = () => {
2448
- var h;
2449
- return (h = V.getRoom) == null ? void 0 : h.call(V);
2450
- }, ut.current = () => {
2451
- var ue, te, xe, ke;
2452
- const h = Dt.current;
2453
- if (!h) {
2448
+ I(() => {
2449
+ if (J != null && J.subscribeToDataMessages)
2450
+ return J.subscribeToDataMessages(Xe);
2451
+ }, [J, Xe]), oe.current = () => {
2452
+ var f;
2453
+ return (f = U.getRoom) == null ? void 0 : f.call(U);
2454
+ };
2455
+ const an = (f, c, W) => {
2456
+ if (!(f != null && f.publishData))
2457
+ return console.warn(`[NAV-DEBUG][widget] ${W}: no publishData on lp`), Promise.resolve();
2458
+ const ne = new TextEncoder().encode(JSON.stringify(c));
2459
+ return Promise.resolve().then(() => f.publishData(ne, { reliable: !0 })).then(() => {
2460
+ console.log(`[NAV-DEBUG][widget] ${W}: publishData resolved (${ne.byteLength}b)`);
2461
+ }).catch((Q) => {
2462
+ const de = Q instanceof Error ? Q.message : String(Q), fe = Q instanceof Error ? Q.name : "unknown";
2463
+ console.error(
2464
+ `[NAV-DEBUG][widget] ${W}: publishData REJECTED — ${fe}: ${de} (${ne.byteLength}b)`
2465
+ );
2466
+ });
2467
+ };
2468
+ Oe.current = an, ft.current = () => {
2469
+ var de, fe, ke, b;
2470
+ const f = Dt.current;
2471
+ if (!f) {
2454
2472
  console.log("[NAV-DEBUG][widget] pushSnapshot bailed: no pathname");
2455
2473
  return;
2456
2474
  }
2457
- const c = (ue = V.getRoom) == null ? void 0 : ue.call(V), J = c == null ? void 0 : c.localParticipant;
2458
- if (!(J != null && J.publishData)) {
2475
+ const c = (de = U.getRoom) == null ? void 0 : de.call(U), W = c == null ? void 0 : c.localParticipant;
2476
+ if (!(W != null && W.publishData)) {
2459
2477
  console.log(
2460
2478
  "[NAV-DEBUG][widget] pushSnapshot bailed: no publishData (not connected)"
2461
2479
  );
2462
2480
  return;
2463
2481
  }
2464
- try {
2465
- J.publishData(
2466
- new TextEncoder().encode(JSON.stringify({ type: "pathname", pathname: h })),
2467
- { reliable: !0 }
2468
- );
2469
- } catch (X) {
2470
- console.warn("[NAV-DEBUG][widget] pushSnapshot pathname threw:", X);
2471
- }
2472
- try {
2473
- const X = mt(ct.current);
2474
- J.publishData(
2475
- new TextEncoder().encode(
2476
- JSON.stringify({ type: "page_context_push", pathname: h, context: X })
2477
- ),
2478
- { reliable: !0 }
2479
- ), console.log(
2480
- `[NAV-DEBUG][widget] pushSnapshot page_context_push sent (regions=${((te = X.regions) == null ? void 0 : te.length) ?? 0} forms=${((xe = X.forms) == null ? void 0 : xe.length) ?? 0} links=${((ke = X.visibleLinks) == null ? void 0 : ke.length) ?? 0})`
2481
- );
2482
- } catch (X) {
2483
- console.warn("[NAV-DEBUG][widget] pushSnapshot page_context threw:", X);
2484
- }
2485
- (async () => {
2482
+ const ne = Oe.current;
2483
+ ne(W, { type: "pathname", pathname: f }, "pushSnapshot/pathname");
2484
+ const Q = gt(ut.current);
2485
+ ne(
2486
+ W,
2487
+ { type: "page_context_push", pathname: f, context: Q },
2488
+ `pushSnapshot/page_context_push(regions=${((fe = Q.regions) == null ? void 0 : fe.length) ?? 0} forms=${((ke = Q.forms) == null ? void 0 : ke.length) ?? 0} links=${((b = Q.visibleLinks) == null ? void 0 : b.length) ?? 0})`
2489
+ ), (async () => {
2486
2490
  try {
2487
- const X = dt.current;
2488
- let b = [];
2489
- if (X) {
2490
- const k = X(), R = k instanceof Promise ? await k : k;
2491
- b = Array.isArray(R) ? R.slice(0, 200) : [];
2491
+ const E = dt.current;
2492
+ let k = [];
2493
+ if (E) {
2494
+ const D = E(), F = D instanceof Promise ? await D : D;
2495
+ k = Array.isArray(F) ? F.slice(0, 200) : [];
2492
2496
  } else
2493
- b = nt();
2494
- J.publishData(
2495
- new TextEncoder().encode(JSON.stringify({ type: "routes_push", routes: b })),
2496
- { reliable: !0 }
2497
- ), console.log(
2498
- `[NAV-DEBUG][widget] pushSnapshot routes_push sent (${b.length} routes)`
2497
+ k = rt();
2498
+ await ne(
2499
+ W,
2500
+ { type: "routes_push", routes: k },
2501
+ `pushSnapshot/routes_push(${k.length})`
2499
2502
  );
2500
- } catch (X) {
2501
- console.warn("[NAV-DEBUG][widget] pushSnapshot routes threw:", X);
2503
+ } catch (E) {
2504
+ console.warn("[NAV-DEBUG][widget] pushSnapshot routes outer threw:", E);
2502
2505
  }
2503
2506
  })();
2504
- }, M(() => {
2505
- var ue;
2507
+ }, I(() => {
2508
+ var Q;
2506
2509
  if (console.log(
2507
- `[NAV-DEBUG][widget] pathname-effect fired pathname=${ae} connState=${V.connectionState} t=${Date.now()}`
2510
+ `[NAV-DEBUG][widget] pathname-effect fired pathname=${ae} connState=${U.connectionState} t=${Date.now()}`
2508
2511
  ), !ae) {
2509
2512
  console.log("[NAV-DEBUG][widget] effect bailed: no pathname");
2510
2513
  return;
2511
2514
  }
2512
- const h = (ue = V.getRoom) == null ? void 0 : ue.call(V), c = h == null ? void 0 : h.localParticipant;
2515
+ const f = (Q = U.getRoom) == null ? void 0 : Q.call(U), c = f == null ? void 0 : f.localParticipant;
2513
2516
  if (console.log(
2514
- `[NAV-DEBUG][widget] immediate-push state: room=${!!h} lp=${!!c} publishData=${!!(c != null && c.publishData)}`
2517
+ `[NAV-DEBUG][widget] immediate-push state: room=${!!f} lp=${!!c} publishData=${!!(c != null && c.publishData)}`
2515
2518
  ), !(c != null && c.publishData)) {
2516
2519
  console.log("[NAV-DEBUG][widget] effect bailed: no publishData (not connected yet)");
2517
2520
  return;
2518
2521
  }
2519
- try {
2520
- const te = new TextEncoder().encode(
2521
- JSON.stringify({ type: "pathname", pathname: ae })
2522
- );
2523
- c.publishData(te, { reliable: !0 }), console.log(`[NAV-DEBUG][widget] pathname push sent (${te.byteLength} bytes)`);
2524
- } catch (te) {
2525
- console.warn("[NAV-DEBUG][widget] pathname push threw:", te);
2526
- }
2527
- const J = setTimeout(async () => {
2528
- var te, xe, ke, X;
2522
+ const W = Oe.current;
2523
+ W && W(c, { type: "pathname", pathname: ae }, "pathname-effect/pathname");
2524
+ const ne = setTimeout(async () => {
2525
+ var de, fe, ke, b;
2529
2526
  console.log("[NAV-DEBUG][widget] settle timer fired (250ms after pathname-effect)");
2530
2527
  try {
2531
- const b = (te = V.getRoom) == null ? void 0 : te.call(V), k = b == null ? void 0 : b.localParticipant;
2528
+ const E = (de = U.getRoom) == null ? void 0 : de.call(U), k = E == null ? void 0 : E.localParticipant;
2532
2529
  if (console.log(
2533
- `[NAV-DEBUG][widget] settle-time state: room=${!!b} lp=${!!k} publishData=${!!(k != null && k.publishData)}`
2530
+ `[NAV-DEBUG][widget] settle-time state: room=${!!E} lp=${!!k} publishData=${!!(k != null && k.publishData)}`
2534
2531
  ), !(k != null && k.publishData)) {
2535
2532
  console.log("[NAV-DEBUG][widget] settle bailed: no publishData");
2536
2533
  return;
2537
2534
  }
2538
- const R = mt(ct.current);
2539
- console.log(
2540
- `[NAV-DEBUG][widget] page_context built: regions=${((xe = R.regions) == null ? void 0 : xe.length) ?? 0} forms=${((ke = R.forms) == null ? void 0 : ke.length) ?? 0} links=${((X = R.visibleLinks) == null ? void 0 : X.length) ?? 0}`
2535
+ const D = gt(ut.current), F = Oe.current;
2536
+ if (!F) return;
2537
+ await F(
2538
+ k,
2539
+ { type: "page_context_push", pathname: ae, context: D },
2540
+ `settle/page_context_push(regions=${((fe = D.regions) == null ? void 0 : fe.length) ?? 0} forms=${((ke = D.forms) == null ? void 0 : ke.length) ?? 0} links=${((b = D.visibleLinks) == null ? void 0 : b.length) ?? 0})`
2541
2541
  );
2542
2542
  try {
2543
- const N = new TextEncoder().encode(
2544
- JSON.stringify({ type: "page_context_push", pathname: ae, context: R })
2545
- );
2546
- k.publishData(N, { reliable: !0 }), console.log(
2547
- `[NAV-DEBUG][widget] page_context_push SENT (${N.byteLength} bytes)`
2548
- );
2549
- } catch (N) {
2550
- console.warn("[NAV-DEBUG][widget] page_context_push threw:", N);
2551
- }
2552
- try {
2553
- const N = dt.current;
2554
- let W = [];
2555
- if (N) {
2556
- console.log("[NAV-DEBUG][widget] routes: calling custom getRoutes()");
2557
- const T = N(), F = T instanceof Promise ? await T : T;
2558
- W = Array.isArray(F) ? F.slice(0, 200) : [], console.log(`[NAV-DEBUG][widget] routes: custom returned ${W.length}`);
2543
+ const j = dt.current;
2544
+ let M = [];
2545
+ if (j) {
2546
+ const Y = j(), B = Y instanceof Promise ? await Y : Y;
2547
+ M = Array.isArray(B) ? B.slice(0, 200) : [];
2559
2548
  } else
2560
- console.log("[NAV-DEBUG][widget] routes: walking DOM (no custom getRoutes)"), W = nt(), console.log(`[NAV-DEBUG][widget] routes: DOM walk returned ${W.length}`);
2561
- const j = new TextEncoder().encode(
2562
- JSON.stringify({ type: "routes_push", routes: W })
2563
- );
2564
- k.publishData(j, { reliable: !0 }), console.log(
2565
- `[NAV-DEBUG][widget] routes_push SENT (${j.byteLength} bytes, ${W.length} routes)`
2549
+ M = rt();
2550
+ await F(
2551
+ k,
2552
+ { type: "routes_push", routes: M },
2553
+ `settle/routes_push(${M.length})`
2566
2554
  );
2567
- } catch (N) {
2568
- console.warn("[NAV-DEBUG][widget] routes_push threw:", N);
2555
+ } catch (j) {
2556
+ console.warn("[NAV-DEBUG][widget] routes_push outer threw:", j);
2569
2557
  }
2570
- } catch (b) {
2571
- console.warn("[NAV-DEBUG][widget] settle outer threw:", b);
2558
+ } catch (E) {
2559
+ console.warn("[NAV-DEBUG][widget] settle outer threw:", E);
2572
2560
  }
2573
2561
  }, 250);
2574
2562
  return () => {
2575
- clearTimeout(J);
2563
+ clearTimeout(ne);
2576
2564
  };
2577
- }, [ae, V, V.connectionState]), M(() => {
2578
- var J;
2565
+ }, [ae, U, U.connectionState]), I(() => {
2566
+ var W;
2579
2567
  if (typeof window > "u") return;
2580
- const h = ((J = window.location) == null ? void 0 : J.hostname) || "";
2581
- if (h === "localhost" || h === "127.0.0.1" || h === "0.0.0.0" || h.endsWith(".local") || h.endsWith(".test"))
2582
- return window.__livelayerSimulateCommand = (ue) => {
2568
+ const f = ((W = window.location) == null ? void 0 : W.hostname) || "";
2569
+ if (f === "localhost" || f === "127.0.0.1" || f === "0.0.0.0" || f.endsWith(".local") || f.endsWith(".test"))
2570
+ return window.__livelayerSimulateCommand = (ne) => {
2583
2571
  try {
2584
- Ke(ue);
2585
- } catch (te) {
2586
- console.warn("[LiveLayer] simulate-command threw:", te);
2572
+ Xe(ne);
2573
+ } catch (Q) {
2574
+ console.warn("[LiveLayer] simulate-command threw:", Q);
2587
2575
  }
2588
2576
  }, () => {
2589
2577
  delete window.__livelayerSimulateCommand;
2590
2578
  };
2591
- }, [Ke]);
2592
- const g = gt(() => Y ? {
2593
- connectionState: Y.connectionState,
2594
- agentState: Y.agentState,
2595
- transcript: Y.transcript,
2596
- videoElement: Y.videoElement,
2597
- audioElement: Y.audioElement,
2598
- canResume: Y.canResume,
2599
- error: Y.error,
2579
+ }, [Xe]);
2580
+ const g = yt(() => J ? {
2581
+ connectionState: J.connectionState,
2582
+ agentState: J.agentState,
2583
+ transcript: J.transcript,
2584
+ videoElement: J.videoElement,
2585
+ audioElement: J.audioElement,
2586
+ canResume: J.canResume,
2587
+ error: J.error,
2600
2588
  agentConfig: null,
2601
2589
  connect: async () => {
2602
- await Y.onConnect();
2590
+ await J.onConnect();
2603
2591
  },
2604
- disconnect: () => Y.onDisconnect(),
2592
+ disconnect: () => J.onDisconnect(),
2605
2593
  // Dummy getRoom for shape compatibility — controlled consumers own the Room.
2606
2594
  // Internal session's getRoom returns null when no real connect has happened,
2607
2595
  // so we reuse its reference for type consistency.
2608
- getRoom: V.getRoom,
2596
+ getRoom: U.getRoom,
2609
2597
  isControlled: !0
2610
2598
  } : {
2611
- connectionState: V.connectionState,
2612
- agentState: V.agentState,
2613
- transcript: V.transcript,
2614
- videoElement: V.videoElement,
2615
- audioElement: V.audioElement,
2616
- canResume: V.canResume,
2617
- error: V.error,
2618
- agentConfig: V.agentConfig,
2619
- connect: V.connect,
2620
- disconnect: V.disconnect,
2621
- getRoom: V.getRoom,
2599
+ connectionState: U.connectionState,
2600
+ agentState: U.agentState,
2601
+ transcript: U.transcript,
2602
+ videoElement: U.videoElement,
2603
+ audioElement: U.audioElement,
2604
+ canResume: U.canResume,
2605
+ error: U.error,
2606
+ agentConfig: U.agentConfig,
2607
+ connect: U.connect,
2608
+ disconnect: U.disconnect,
2609
+ getRoom: U.getRoom,
2622
2610
  isControlled: !1
2623
- }, [Y, V]), Rt = A(null);
2624
- M(() => {
2625
- const h = g.videoElement, c = Rt.current;
2626
- if (!(!h || !c))
2627
- return c.appendChild(h), () => {
2628
- h.parentNode === c && c.removeChild(h);
2611
+ }, [J, U]), Mt = N(null);
2612
+ I(() => {
2613
+ const f = g.videoElement, c = Mt.current;
2614
+ if (!(!f || !c))
2615
+ return c.appendChild(f), () => {
2616
+ f.parentNode === c && c.removeChild(f);
2629
2617
  };
2630
- }, [g.videoElement]), M(() => {
2631
- const h = g.audioElement;
2632
- if (!h) return;
2633
- Ge.attach(h);
2634
- const c = h.play();
2635
- return c && typeof c.catch == "function" && c.catch((J) => {
2636
- (J == null ? void 0 : J.name) === "NotAllowedError" && ge(!0);
2618
+ }, [g.videoElement]), I(() => {
2619
+ const f = g.audioElement;
2620
+ if (!f) return;
2621
+ je.attach(f);
2622
+ const c = f.play();
2623
+ return c && typeof c.catch == "function" && c.catch((W) => {
2624
+ (W == null ? void 0 : W.name) === "NotAllowedError" && ye(!0);
2637
2625
  }), () => {
2638
- Ge.detach();
2626
+ je.detach();
2639
2627
  };
2640
- }, [g.audioElement]), M(() => {
2628
+ }, [g.audioElement]), I(() => {
2641
2629
  if (g.isControlled || g.connectionState !== "connected") return;
2642
- const h = g.getRoom();
2643
- if (h)
2644
- return re.setupMic(h, { startMuted: !0 }).catch(() => {
2645
- }), ce.attachRoom(h), de.attachRoom(h), me.refresh(), () => {
2646
- re.teardownMic(), ce.teardown(), de.teardown();
2630
+ const f = g.getRoom();
2631
+ if (f)
2632
+ return re.setupMic(f, { startMuted: !0 }).catch(() => {
2633
+ }), ce.attachRoom(f), ue.attachRoom(f), ge.refresh(), () => {
2634
+ re.teardownMic(), ce.teardown(), ue.teardown();
2647
2635
  };
2648
2636
  }, [g.isControlled, g.connectionState]);
2649
- const [Xe, kt] = E(!1), Lt = A("idle");
2650
- M(() => {
2637
+ const [Qe, Lt] = C(!1), St = N("idle");
2638
+ I(() => {
2651
2639
  if (g.connectionState === "idle" || g.connectionState === "disconnected") {
2652
- kt(!1), Lt.current = "idle";
2640
+ Lt(!1), St.current = "idle";
2653
2641
  return;
2654
2642
  }
2655
- !Xe && Lt.current === "speaking" && g.agentState !== "speaking" && (kt(!0), re.setMuted(!1)), Lt.current = g.agentState;
2656
- }, [g.agentState, g.connectionState, Xe]), M(() => {
2657
- if (g.connectionState !== "connected" || Xe) return;
2658
- const h = setTimeout(() => {
2659
- kt(!0), re.setMuted(!1);
2643
+ !Qe && St.current === "speaking" && g.agentState !== "speaking" && (Lt(!0), re.setMuted(!1)), St.current = g.agentState;
2644
+ }, [g.agentState, g.connectionState, Qe]), I(() => {
2645
+ if (g.connectionState !== "connected" || Qe) return;
2646
+ const f = setTimeout(() => {
2647
+ Lt(!0), re.setMuted(!1);
2660
2648
  }, 4e3);
2661
- return () => clearTimeout(h);
2662
- }, [g.connectionState, Xe]), M(() => {
2663
- const h = g.audioElement;
2664
- h && (h.muted = Oe);
2665
- }, [g.audioElement, Oe]);
2666
- const ln = S((h) => {
2649
+ return () => clearTimeout(f);
2650
+ }, [g.connectionState, Qe]), I(() => {
2651
+ const f = g.audioElement;
2652
+ f && (f.muted = He);
2653
+ }, [g.audioElement, He]);
2654
+ const sn = S((f) => {
2667
2655
  const c = g.getRoom();
2668
2656
  if (c)
2669
2657
  try {
2670
- const J = new TextEncoder().encode(
2671
- JSON.stringify({ type: "user_message", text: h })
2658
+ const W = new TextEncoder().encode(
2659
+ JSON.stringify({ type: "user_message", text: f })
2672
2660
  );
2673
- c.localParticipant.publishData(J, { reliable: !0 });
2661
+ c.localParticipant.publishData(W, { reliable: !0 });
2674
2662
  } catch {
2675
2663
  }
2676
- }, [g]), an = S(() => {
2677
- st((h) => !h);
2664
+ }, [g]), cn = S(() => {
2665
+ ct((f) => !f);
2678
2666
  }, []);
2679
- M(() => {
2680
- Me == null || Me(g.connectionState), g.connectionState === "connected" ? pe == null || pe() : g.connectionState === "disconnected" && (Se == null || Se());
2681
- }, [g.connectionState, pe, Se, Me]), M(() => {
2682
- De == null || De(g.transcript);
2683
- }, [g.transcript, De]), M(() => {
2684
- Re == null || Re(g.agentState);
2685
- }, [g.agentState, Re]);
2686
- const Mt = A(!1);
2687
- M(() => {
2688
- g.isControlled || !d || Mt.current || Pe && g.connectionState === "idle" && (Mt.current = !0, g.connect());
2689
- }, [d, g.connectionState, g, Pe]);
2690
- const sn = S(
2691
- (h) => {
2692
- const c = D == null ? void 0 : D.find((J) => J.id === h);
2693
- c && (Je(!1), h !== Q && (Fe(!0), g.disconnect(), We || $e(h), v == null || v(c)));
2667
+ I(() => {
2668
+ Me == null || Me(g.connectionState), g.connectionState === "connected" ? he == null || he() : g.connectionState === "disconnected" && (Se == null || Se());
2669
+ }, [g.connectionState, he, Se, Me]), I(() => {
2670
+ Re == null || Re(g.transcript);
2671
+ }, [g.transcript, Re]), I(() => {
2672
+ De == null || De(g.agentState);
2673
+ }, [g.agentState, De]);
2674
+ const It = N(!1);
2675
+ I(() => {
2676
+ g.isControlled || !u || It.current || Pe && g.connectionState === "idle" && (It.current = !0, g.connect());
2677
+ }, [u, g.connectionState, g, Pe]);
2678
+ const un = S(
2679
+ (f) => {
2680
+ const c = R == null ? void 0 : R.find((W) => W.id === f);
2681
+ c && (Je(!1), f !== X && (Ge(!0), g.disconnect(), Fe || $e(f), v == null || v(c)));
2694
2682
  },
2695
2683
  [
2696
- D,
2697
- Q,
2684
+ R,
2685
+ X,
2698
2686
  g,
2699
- We,
2687
+ Fe,
2700
2688
  v
2701
2689
  ]
2702
2690
  );
2703
- M(() => {
2704
- ye && g.connectionState === "connected" && Fe(!1);
2705
- }, [g.connectionState, ye]), M(() => {
2706
- if (!je) return;
2707
- const h = (c) => {
2691
+ I(() => {
2692
+ ve && g.connectionState === "connected" && Ge(!1);
2693
+ }, [g.connectionState, ve]), I(() => {
2694
+ if (!Ye) return;
2695
+ const f = (c) => {
2708
2696
  c.key === "Escape" && Je(!1);
2709
2697
  };
2710
- return window.addEventListener("keydown", h), () => window.removeEventListener("keydown", h);
2711
- }, [je]);
2712
- const cn = !!$ || !!(ne != null && ne.avatarImageUrl) || g.isControlled, Qe = Rn(Be, o, cn);
2713
- ie === void 0 && ((It = Qe.info) != null && It.capabilities) && (xt.current = Qe.info.capabilities);
2714
- const ft = (ne == null ? void 0 : ne.name) ?? U ?? ((Pt = g.agentConfig) == null ? void 0 : Pt.name) ?? (($t = Qe.info) == null ? void 0 : $t.name) ?? "Live Layer", St = (ne == null ? void 0 : ne.avatarImageUrl) ?? $ ?? ((Bt = g.agentConfig) == null ? void 0 : Bt.avatarImageUrl) ?? ((zt = Qe.info) == null ? void 0 : zt.avatarImageUrl) ?? null, dn = _ ?? ((Ot = g.agentConfig) == null ? void 0 : Ot.idleLoopUrl) ?? ((Ut = Qe.info) == null ? void 0 : Ut.idleLoopUrl) ?? null, un = O ?? null, fn = S(() => he("expanded"), [he]), pn = S(
2715
- () => he("minimized"),
2716
- [he]
2698
+ return window.addEventListener("keydown", f), () => window.removeEventListener("keydown", f);
2699
+ }, [Ye]);
2700
+ const dn = !!$ || !!(te != null && te.avatarImageUrl) || g.isControlled, Ze = In(Be, o, dn);
2701
+ ie === void 0 && ((Pt = Ze.info) != null && Pt.capabilities) && (kt.current = Ze.info.capabilities);
2702
+ const pt = (te == null ? void 0 : te.name) ?? q ?? (($t = g.agentConfig) == null ? void 0 : $t.name) ?? ((Bt = Ze.info) == null ? void 0 : Bt.name) ?? "Live Layer", Et = (te == null ? void 0 : te.avatarImageUrl) ?? $ ?? ((zt = g.agentConfig) == null ? void 0 : zt.avatarImageUrl) ?? ((Ht = Ze.info) == null ? void 0 : Ht.avatarImageUrl) ?? null, fn = _ ?? ((qt = g.agentConfig) == null ? void 0 : qt.idleLoopUrl) ?? ((Ot = Ze.info) == null ? void 0 : Ot.idleLoopUrl) ?? null, pn = H ?? null, hn = S(() => me("expanded"), [me]), mn = S(
2703
+ () => me("minimized"),
2704
+ [me]
2717
2705
  ), Tt = S(() => {
2718
- g.disconnect(), he("hidden");
2719
- }, [g, he]), hn = S(() => {
2720
- const h = g.audioElement;
2721
- h && h.play().then(() => ge(!1)).catch(() => {
2706
+ g.disconnect(), me("hidden");
2707
+ }, [g, me]), gn = S(() => {
2708
+ const f = g.audioElement;
2709
+ f && f.play().then(() => ye(!1)).catch(() => {
2722
2710
  });
2723
- }, [g.audioElement]), mn = S(() => {
2724
- ge(!1), g.connect();
2725
- }, [g]), Ze = {
2726
- ...wt,
2727
- zIndex: at
2711
+ }, [g.audioElement]), yn = S(() => {
2712
+ ye(!1), g.connect();
2713
+ }, [g]), et = {
2714
+ ..._t,
2715
+ zIndex: st
2728
2716
  };
2729
- m.primaryColor && (Ze["--ll-color-primary"] = m.primaryColor), m.accentColor && (Ze["--ll-color-accent"] = m.accentColor), m.backgroundColor && (Ze["--ll-color-bg"] = m.backgroundColor), m.textColor && (Ze["--ll-color-fg"] = m.textColor);
2730
- const gn = [
2717
+ m.primaryColor && (et["--ll-color-primary"] = m.primaryColor), m.accentColor && (et["--ll-color-accent"] = m.accentColor), m.backgroundColor && (et["--ll-color-bg"] = m.backgroundColor), m.textColor && (et["--ll-color-fg"] = m.textColor);
2718
+ const vn = [
2731
2719
  "ll-widget",
2732
2720
  `ll-widget--${se}`,
2733
2721
  `ll-widget--${Ce ? "mobile" : "desktop"}`,
2734
- vt
2722
+ wt
2735
2723
  ].filter(Boolean).join(" ");
2736
2724
  return Pe ? /* @__PURE__ */ x(
2737
2725
  "div",
2738
2726
  {
2739
- className: gn,
2740
- style: Ze,
2727
+ className: vn,
2728
+ style: et,
2741
2729
  "data-display-mode": se,
2742
2730
  "data-position": w,
2743
2731
  children: [
2744
2732
  se === "hidden" && /* @__PURE__ */ n(
2745
- er,
2733
+ nr,
2746
2734
  {
2747
2735
  position: w,
2748
2736
  isMobile: Ce,
2749
2737
  isSpeaking: g.agentState === "speaking",
2750
- onExpand: () => he("expanded"),
2751
- label: `Open ${ft} widget`,
2752
- avatarImageUrl: St,
2753
- agentName: ft
2738
+ onExpand: () => me("expanded"),
2739
+ label: `Open ${pt} widget`,
2740
+ avatarImageUrl: Et,
2741
+ agentName: pt
2754
2742
  }
2755
2743
  ),
2756
2744
  se === "minimized" && /* @__PURE__ */ n(
2757
- nr,
2745
+ or,
2758
2746
  {
2759
2747
  position: w,
2760
2748
  isMobile: Ce,
2761
- agentName: ft,
2762
- avatarImageUrl: St,
2749
+ agentName: pt,
2750
+ avatarImageUrl: Et,
2763
2751
  agentState: g.agentState,
2764
2752
  isMuted: re.isMuted,
2765
- audioLevel: Ge,
2766
- onExpand: fn,
2753
+ audioLevel: je,
2754
+ onExpand: hn,
2767
2755
  onToggleMute: re.toggleMute,
2768
2756
  onClose: Tt
2769
2757
  }
2770
2758
  ),
2771
2759
  se === "expanded" && /* @__PURE__ */ n(
2772
- or,
2760
+ lr,
2773
2761
  {
2774
2762
  position: w,
2775
2763
  isMobile: Ce,
2776
- agentName: ft,
2777
- avatarImageUrl: St,
2778
- idleLoopUrl: dn,
2779
- greeting: un,
2764
+ agentName: pt,
2765
+ avatarImageUrl: Et,
2766
+ idleLoopUrl: fn,
2767
+ greeting: pn,
2780
2768
  branding: m,
2781
- teamMembers: D,
2782
- currentTeamMemberId: Q,
2783
- isSwitchingTeamMember: ye,
2784
- teamSwitcherOpen: je,
2785
- onToggleTeamSwitcher: () => Je((h) => !h),
2786
- onSelectTeamMember: sn,
2769
+ teamMembers: R,
2770
+ currentTeamMemberId: X,
2771
+ isSwitchingTeamMember: ve,
2772
+ teamSwitcherOpen: Ye,
2773
+ onToggleTeamSwitcher: () => Je((f) => !f),
2774
+ onSelectTeamMember: un,
2787
2775
  connectionState: g.connectionState,
2788
2776
  agentState: g.agentState,
2789
2777
  transcript: g.transcript,
2790
2778
  isMuted: re.isMuted,
2791
- micDevices: me.mics,
2779
+ micDevices: ge.mics,
2792
2780
  isCameraEnabled: ce.isEnabled,
2793
2781
  cameraPreviewEl: ce.previewEl,
2794
- cameraDevices: me.cameras,
2782
+ cameraDevices: ge.cameras,
2795
2783
  activeCameraId: ce.activeDeviceId,
2796
- isScreenShareEnabled: de.isEnabled,
2797
- screenPreviewEl: de.previewEl,
2798
- isSpeakerMuted: Oe,
2799
- allowCamera: I,
2800
- allowScreenShare: q,
2801
- allowTyping: B,
2784
+ isScreenShareEnabled: ue.isEnabled,
2785
+ screenPreviewEl: ue.previewEl,
2786
+ isSpeakerMuted: He,
2787
+ allowCamera: T,
2788
+ allowScreenShare: V,
2789
+ allowTyping: z,
2802
2790
  languageMenuOpen: be,
2803
- onToggleLanguageMenu: () => ve((h) => !h),
2791
+ onToggleLanguageMenu: () => we((f) => !f),
2804
2792
  needsUserGesture: ze,
2805
2793
  canResume: g.canResume,
2806
2794
  micError: re.micError,
2807
2795
  error: g.error,
2808
- avatarVideoContainerRef: Rt,
2796
+ avatarVideoContainerRef: Mt,
2809
2797
  agentVideoEl: g.videoElement,
2810
- micGateOpen: g.isControlled ? !0 : Xe,
2798
+ micGateOpen: g.isControlled ? !0 : Qe,
2811
2799
  onConnect: () => void g.connect(),
2812
2800
  onDisconnect: () => g.disconnect(),
2813
- onRetry: mn,
2814
- onResumeAudio: hn,
2801
+ onRetry: yn,
2802
+ onResumeAudio: gn,
2815
2803
  onToggleMute: re.toggleMute,
2816
2804
  onToggleCamera: () => void ce.toggle(),
2817
- onSwitchCameraDevice: (h) => void ce.switchDevice(h),
2818
- onToggleScreenShare: () => void de.toggle(),
2819
- onToggleSpeaker: an,
2820
- onSendMessage: ln,
2821
- onMinimize: pn,
2805
+ onSwitchCameraDevice: (f) => void ce.switchDevice(f),
2806
+ onToggleScreenShare: () => void ue.toggle(),
2807
+ onToggleSpeaker: cn,
2808
+ onSendMessage: sn,
2809
+ onMinimize: mn,
2822
2810
  onClose: Tt,
2823
2811
  onClearMicError: re.clearError
2824
2812
  }
@@ -2827,50 +2815,50 @@ function Ir(e) {
2827
2815
  }
2828
2816
  ) : null;
2829
2817
  }
2830
- function Vr(e) {
2831
- return /* @__PURE__ */ n(kn, { children: /* @__PURE__ */ n(Ir, { ...e }) });
2818
+ function Wr(e) {
2819
+ return /* @__PURE__ */ n(Sn, { children: /* @__PURE__ */ n($r, { ...e }) });
2832
2820
  }
2833
- const qr = ({
2821
+ const Fr = ({
2834
2822
  agentId: e,
2835
2823
  baseUrl: t,
2836
2824
  apiKey: r,
2837
2825
  mode: o,
2838
2826
  onAgentEvent: i,
2839
2827
  className: l,
2840
- style: d
2828
+ style: u
2841
2829
  }) => {
2842
- const u = A(null), f = A(null), y = A(i);
2830
+ const d = N(null), p = N(null), y = N(i);
2843
2831
  y.current = i;
2844
2832
  const w = S((s) => {
2845
2833
  var L;
2846
2834
  const a = s.detail;
2847
2835
  (L = y.current) == null || L.call(y, a);
2848
2836
  }, []);
2849
- return M(() => {
2850
- const s = u.current;
2837
+ return I(() => {
2838
+ const s = d.current;
2851
2839
  if (!s) return;
2852
2840
  const a = document.createElement("livelayer-widget");
2853
- return a.setAttribute("agent-id", e), t && a.setAttribute("base-url", t), r && a.setAttribute("api-key", r), o && a.setAttribute("mode", o), a.addEventListener("agent-event", w), s.appendChild(a), f.current = a, () => {
2854
- a.removeEventListener("agent-event", w), s.removeChild(a), f.current = null;
2841
+ return a.setAttribute("agent-id", e), t && a.setAttribute("base-url", t), r && a.setAttribute("api-key", r), o && a.setAttribute("mode", o), a.addEventListener("agent-event", w), s.appendChild(a), p.current = a, () => {
2842
+ a.removeEventListener("agent-event", w), s.removeChild(a), p.current = null;
2855
2843
  };
2856
- }, [e]), M(() => {
2857
- f.current && (o ? f.current.setAttribute("mode", o) : f.current.removeAttribute("mode"));
2858
- }, [o]), /* @__PURE__ */ n("div", { ref: u, className: l, style: d });
2859
- }, Wr = Nt(
2860
- function({ id: t, intent: r, as: o = "div", className: i, style: l, children: d }, u) {
2861
- return vn(
2844
+ }, [e]), I(() => {
2845
+ p.current && (o ? p.current.setAttribute("mode", o) : p.current.removeAttribute("mode"));
2846
+ }, [o]), /* @__PURE__ */ n("div", { ref: d, className: l, style: u });
2847
+ }, jr = At(
2848
+ function({ id: t, intent: r, as: o = "div", className: i, style: l, children: u }, d) {
2849
+ return _n(
2862
2850
  o,
2863
2851
  {
2864
- ref: u,
2852
+ ref: d,
2865
2853
  "data-ll-region": t,
2866
2854
  "data-ll-intent": r,
2867
2855
  className: i,
2868
2856
  style: l
2869
2857
  },
2870
- d
2858
+ u
2871
2859
  );
2872
2860
  }
2873
- ), Gr = Nt(
2861
+ ), Gr = At(
2874
2862
  function({ id: t, intent: r, children: o, ...i }, l) {
2875
2863
  return /* @__PURE__ */ n(
2876
2864
  "form",
@@ -2883,108 +2871,108 @@ const qr = ({
2883
2871
  }
2884
2872
  );
2885
2873
  }
2886
- ), Fr = Nt(
2874
+ ), Yr = At(
2887
2875
  function(t, r) {
2888
- const { name: o, label: i, labelClassName: l } = t, d = { name: o, "data-ll-field": o };
2889
- let u;
2876
+ const { name: o, label: i, labelClassName: l } = t, u = { name: o, "data-ll-field": o };
2877
+ let d;
2890
2878
  if ("as" in t && t.as === "textarea") {
2891
- const { name: f, label: y, labelClassName: w, as: s, ...a } = t;
2892
- u = /* @__PURE__ */ n(
2879
+ const { name: p, label: y, labelClassName: w, as: s, ...a } = t;
2880
+ d = /* @__PURE__ */ n(
2893
2881
  "textarea",
2894
2882
  {
2895
2883
  ref: r,
2896
- ...d,
2884
+ ...u,
2897
2885
  ...a
2898
2886
  }
2899
2887
  );
2900
2888
  } else if ("as" in t && t.as === "select") {
2901
- const { name: f, label: y, labelClassName: w, as: s, children: a, ...L } = t;
2902
- u = /* @__PURE__ */ n(
2889
+ const { name: p, label: y, labelClassName: w, as: s, children: a, ...L } = t;
2890
+ d = /* @__PURE__ */ n(
2903
2891
  "select",
2904
2892
  {
2905
2893
  ref: r,
2906
- ...d,
2894
+ ...u,
2907
2895
  ...L,
2908
2896
  children: a
2909
2897
  }
2910
2898
  );
2911
2899
  } else {
2912
- const { name: f, label: y, labelClassName: w, as: s, ...a } = t;
2913
- u = /* @__PURE__ */ n(
2900
+ const { name: p, label: y, labelClassName: w, as: s, ...a } = t;
2901
+ d = /* @__PURE__ */ n(
2914
2902
  "input",
2915
2903
  {
2916
2904
  ref: r,
2917
- ...d,
2905
+ ...u,
2918
2906
  ...a
2919
2907
  }
2920
2908
  );
2921
2909
  }
2922
- return i === void 0 ? u : /* @__PURE__ */ x("label", { className: l, children: [
2910
+ return i === void 0 ? d : /* @__PURE__ */ x("label", { className: l, children: [
2923
2911
  i,
2924
- u
2912
+ d
2925
2913
  ] });
2926
2914
  }
2927
2915
  );
2928
- let nn = 1;
2929
- function jr({
2916
+ let rn = 1;
2917
+ function Jr({
2930
2918
  onMount: e,
2931
2919
  defaultOpen: t = !1,
2932
2920
  storageKey: r = "ll-debug-open"
2933
2921
  }) {
2934
- const [o, i] = E(t), [l, d] = E([]), [u, f] = E(""), [y, w] = E(!1), s = A(/* @__PURE__ */ new Set()), a = A([]), L = A(y);
2935
- L.current = y, M(() => {
2922
+ const [o, i] = C(t), [l, u] = C([]), [d, p] = C(""), [y, w] = C(!1), s = N(/* @__PURE__ */ new Set()), a = N([]), L = N(y);
2923
+ L.current = y, I(() => {
2936
2924
  try {
2937
2925
  const v = localStorage.getItem(r);
2938
2926
  v === "1" && i(!0), v === "0" && i(!1);
2939
2927
  } catch {
2940
2928
  }
2941
- }, [r]), M(() => {
2929
+ }, [r]), I(() => {
2942
2930
  try {
2943
2931
  localStorage.setItem(r, o ? "1" : "0");
2944
2932
  } catch {
2945
2933
  }
2946
- }, [o, r]), M(() => {
2934
+ }, [o, r]), I(() => {
2947
2935
  const v = (_) => {
2948
- (_.metaKey || _.ctrlKey) && _.shiftKey && _.key.toLowerCase() === "l" && (_.preventDefault(), i((O) => !O));
2936
+ (_.metaKey || _.ctrlKey) && _.shiftKey && _.key.toLowerCase() === "l" && (_.preventDefault(), i((H) => !H));
2949
2937
  };
2950
2938
  return window.addEventListener("keydown", v), () => window.removeEventListener("keydown", v);
2951
- }, []), M(() => {
2939
+ }, []), I(() => {
2952
2940
  const v = setInterval(() => {
2953
2941
  if (a.current.length === 0 || L.current) return;
2954
2942
  const _ = a.current.splice(0, a.current.length);
2955
- d(
2956
- (O) => [..._.reverse(), ...O].slice(0, 200)
2943
+ u(
2944
+ (H) => [..._.reverse(), ...H].slice(0, 200)
2957
2945
  );
2958
2946
  }, 100);
2959
2947
  return () => clearInterval(v);
2960
2948
  }, []);
2961
- const D = A(!1);
2962
- if (M(() => {
2963
- !e || D.current || (D.current = !0, e((v) => {
2949
+ const R = N(!1);
2950
+ if (I(() => {
2951
+ !e || R.current || (R.current = !0, e((v) => {
2964
2952
  a.current.push({
2965
- id: nn++,
2953
+ id: rn++,
2966
2954
  ts: Date.now(),
2967
2955
  kind: "event",
2968
2956
  type: v.eventName,
2969
2957
  data: v.data
2970
2958
  });
2971
2959
  }));
2972
- }, [e]), M(() => {
2973
- const v = console.warn, _ = console.log, O = ($, U) => function(...m) {
2960
+ }, [e]), I(() => {
2961
+ const v = console.warn, _ = console.log, H = ($, q) => function(...m) {
2974
2962
  try {
2975
- const I = typeof m[0] == "string" ? m[0] : "";
2976
- I.startsWith("[LiveLayer]") && a.current.push({
2977
- id: nn++,
2963
+ const T = typeof m[0] == "string" ? m[0] : "";
2964
+ T.startsWith("[LiveLayer]") && a.current.push({
2965
+ id: rn++,
2978
2966
  ts: Date.now(),
2979
2967
  kind: $,
2980
- type: I.slice(0, 120),
2981
- data: { args: m.slice(1).map((q) => $r(q)) }
2968
+ type: T.slice(0, 120),
2969
+ data: { args: m.slice(1).map((V) => zr(V)) }
2982
2970
  });
2983
2971
  } catch {
2984
2972
  }
2985
- return U.apply(this, m);
2973
+ return q.apply(this, m);
2986
2974
  };
2987
- return console.warn = O("warn", v), console.log = O("log", _), () => {
2975
+ return console.warn = H("warn", v), console.log = H("log", _), () => {
2988
2976
  console.warn = v, console.log = _;
2989
2977
  };
2990
2978
  }, []), !o)
@@ -3014,9 +3002,9 @@ function jr({
3014
3002
  children: "🛰 LL debug"
3015
3003
  }
3016
3004
  );
3017
- const C = l.filter((v) => {
3018
- if (!u) return !0;
3019
- const _ = u.toLowerCase();
3005
+ const A = l.filter((v) => {
3006
+ if (!d) return !0;
3007
+ const _ = d.toLowerCase();
3020
3008
  return v.type.toLowerCase().includes(_) || JSON.stringify(v.data || {}).toLowerCase().includes(_);
3021
3009
  });
3022
3010
  return /* @__PURE__ */ x(
@@ -3065,7 +3053,7 @@ function jr({
3065
3053
  {
3066
3054
  type: "button",
3067
3055
  onClick: () => w((v) => !v),
3068
- style: Et(y ? "#f59e0b" : "transparent"),
3056
+ style: Ct(y ? "#f59e0b" : "transparent"),
3069
3057
  title: "Pause / resume capture",
3070
3058
  children: y ? "▶ resume" : "⏸ pause"
3071
3059
  }
@@ -3075,9 +3063,9 @@ function jr({
3075
3063
  {
3076
3064
  type: "button",
3077
3065
  onClick: () => {
3078
- d([]), a.current = [];
3066
+ u([]), a.current = [];
3079
3067
  },
3080
- style: Et("transparent"),
3068
+ style: Ct("transparent"),
3081
3069
  title: "Clear buffer",
3082
3070
  children: "clear"
3083
3071
  }
@@ -3087,7 +3075,7 @@ function jr({
3087
3075
  {
3088
3076
  type: "button",
3089
3077
  onClick: () => i(!1),
3090
- style: Et("transparent"),
3078
+ style: Ct("transparent"),
3091
3079
  "aria-label": "Close",
3092
3080
  title: "Close (Cmd/Ctrl + Shift + L)",
3093
3081
  children: "✕"
@@ -3100,8 +3088,8 @@ function jr({
3100
3088
  "input",
3101
3089
  {
3102
3090
  type: "text",
3103
- value: u,
3104
- onChange: (v) => f(v.target.value),
3091
+ value: d,
3092
+ onChange: (v) => p(v.target.value),
3105
3093
  placeholder: "filter by type or data…",
3106
3094
  style: {
3107
3095
  margin: 8,
@@ -3123,7 +3111,7 @@ function jr({
3123
3111
  overflowY: "auto",
3124
3112
  padding: "0 8px 8px"
3125
3113
  },
3126
- children: C.length === 0 ? /* @__PURE__ */ x(
3114
+ children: A.length === 0 ? /* @__PURE__ */ x(
3127
3115
  "div",
3128
3116
  {
3129
3117
  style: {
@@ -3153,13 +3141,13 @@ function jr({
3153
3141
  )
3154
3142
  ]
3155
3143
  }
3156
- ) : C.map((v) => /* @__PURE__ */ n(
3157
- Pr,
3144
+ ) : A.map((v) => /* @__PURE__ */ n(
3145
+ Br,
3158
3146
  {
3159
3147
  entry: v,
3160
3148
  expanded: s.current.has(v.id),
3161
3149
  onToggle: () => {
3162
- s.current.has(v.id) ? s.current.delete(v.id) : s.current.add(v.id), d((_) => [..._]);
3150
+ s.current.has(v.id) ? s.current.delete(v.id) : s.current.add(v.id), u((_) => [..._]);
3163
3151
  }
3164
3152
  },
3165
3153
  v.id
@@ -3170,7 +3158,7 @@ function jr({
3170
3158
  }
3171
3159
  );
3172
3160
  }
3173
- function Pr({
3161
+ function Br({
3174
3162
  entry: e,
3175
3163
  expanded: t,
3176
3164
  onToggle: r
@@ -3240,7 +3228,7 @@ function Pr({
3240
3228
  }
3241
3229
  );
3242
3230
  }
3243
- function Et(e) {
3231
+ function Ct(e) {
3244
3232
  return {
3245
3233
  background: e,
3246
3234
  color: "#fff",
@@ -3251,20 +3239,20 @@ function Et(e) {
3251
3239
  cursor: "pointer"
3252
3240
  };
3253
3241
  }
3254
- function $r(e) {
3242
+ function zr(e) {
3255
3243
  try {
3256
3244
  return e instanceof Error ? { message: e.message, stack: e.stack } : (JSON.stringify(e), e);
3257
3245
  } catch {
3258
3246
  return String(e);
3259
3247
  }
3260
3248
  }
3261
- function Jr() {
3262
- const [e, t] = E([]), r = S((i) => {
3249
+ function Kr() {
3250
+ const [e, t] = C([]), r = S((i) => {
3263
3251
  t((l) => {
3264
- const d = l.findIndex((u) => u.id === i.id);
3265
- if (d >= 0) {
3266
- const u = l.slice();
3267
- return u[d] = i, u;
3252
+ const u = l.findIndex((d) => d.id === i.id);
3253
+ if (u >= 0) {
3254
+ const d = l.slice();
3255
+ return d[u] = i, d;
3268
3256
  }
3269
3257
  return [...l, i];
3270
3258
  });
@@ -3277,33 +3265,33 @@ function Jr() {
3277
3265
  };
3278
3266
  }
3279
3267
  export {
3280
- Vr as AvatarWidget,
3281
- kn as ErrorBoundary,
3282
- jr as LiveLayerDebugPanel,
3283
- Fr as LiveLayerField,
3268
+ Wr as AvatarWidget,
3269
+ Sn as ErrorBoundary,
3270
+ Jr as LiveLayerDebugPanel,
3271
+ Yr as LiveLayerField,
3284
3272
  Gr as LiveLayerForm,
3285
- Wr as LiveLayerRegion,
3286
- qr as LiveLayerWidget,
3287
- vr as clearPageContextCache,
3288
- Sr as clearRoutesCache,
3289
- br as extractPageContext,
3290
- kr as extractRoutes,
3291
- mt as getCachedPageContext,
3292
- nt as getCachedRoutes,
3293
- Fn as matchesPattern,
3294
- _r as normalizeRouteInput,
3295
- jn as shouldRenderAtPath,
3296
- Rn as useAgentInfo,
3297
- Sn as useAudioLevel,
3298
- Nn as useCameraState,
3299
- In as useDisplayMode,
3300
- Bn as useDisplayModePersistence,
3273
+ jr as LiveLayerRegion,
3274
+ Fr as LiveLayerWidget,
3275
+ _r as clearPageContextCache,
3276
+ Cr as clearRoutesCache,
3277
+ wr as extractPageContext,
3278
+ Sr as extractRoutes,
3279
+ gt as getCachedPageContext,
3280
+ rt as getCachedRoutes,
3281
+ Yn as matchesPattern,
3282
+ kr as normalizeRouteInput,
3283
+ Jn as shouldRenderAtPath,
3284
+ In as useAgentInfo,
3285
+ Cn as useAudioLevel,
3286
+ Rn as useCameraState,
3287
+ $n as useDisplayMode,
3288
+ Hn as useDisplayModePersistence,
3301
3289
  On as useIsMobile,
3302
- Ln as useLiveKitSession,
3303
- Dn as useMediaDevices,
3304
- En as useMicrophoneState,
3305
- Hn as usePathname,
3306
- Jn as useRouteMatch,
3307
- An as useScreenShareState,
3308
- Jr as useTranscript
3290
+ En as useLiveKitSession,
3291
+ Mn as useMediaDevices,
3292
+ Nn as useMicrophoneState,
3293
+ Vn as usePathname,
3294
+ Kn as useRouteMatch,
3295
+ Dn as useScreenShareState,
3296
+ Kr as useTranscript
3309
3297
  };