@livelayer/react 0.5.5-pr66c.4 → 0.5.5-pr66c.6

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