@livelayer/react 0.5.4 → 0.5.5

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