@livelayer/react 0.3.0 → 0.4.0

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