@livelayer/react 0.2.6 → 0.3.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,9 +1,9 @@
1
1
  "use client";
2
- import { jsxs as _, jsx as e, Fragment as Ze } from "react/jsx-runtime";
3
- import { Component as et, useState as k, useRef as L, useEffect as S, useCallback as g, useMemo as Se } from "react";
4
- import { LiveKitSession as tt } from "@livelayer/sdk";
5
- import { createLocalAudioTrack as nt, Track as We, createLocalVideoTrack as rt } from "livekit-client";
6
- class it extends et {
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 {
7
7
  constructor() {
8
8
  super(...arguments), this.state = { hasError: !1, error: null }, this.reset = () => {
9
9
  this.setState({ hasError: !1, error: null });
@@ -12,16 +12,16 @@ class it extends et {
12
12
  static getDerivedStateFromError(n) {
13
13
  return { hasError: !0, error: n };
14
14
  }
15
- componentDidCatch(n, i) {
16
- var l, r;
17
- (r = (l = this.props).onError) == null || r.call(l, n, i);
15
+ componentDidCatch(n, r) {
16
+ var i, o;
17
+ (o = (i = this.props).onError) == null || o.call(i, n, r);
18
18
  }
19
19
  render() {
20
20
  var n;
21
21
  return this.state.hasError ? this.props.fallback ? this.props.fallback : /* @__PURE__ */ _("div", { className: "ll-error-boundary", role: "alert", children: [
22
- /* @__PURE__ */ e("p", { className: "ll-error-boundary__title", children: "Widget crashed" }),
23
- /* @__PURE__ */ e("p", { className: "ll-error-boundary__message", children: ((n = this.state.error) == null ? void 0 : n.message) || "Something went wrong." }),
24
- /* @__PURE__ */ e(
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(
25
25
  "button",
26
26
  {
27
27
  type: "button",
@@ -33,282 +33,282 @@ class it extends et {
33
33
  ] }) : this.props.children;
34
34
  }
35
35
  }
36
- function lt(t) {
37
- const [n, i] = k("idle"), [l, r] = k("idle"), [s, c] = k([]), [m, d] = k(null), [f, p] = k(null), [o, a] = k(null), [C, b] = k(!1), [N, D] = k(null), E = L(null), R = L(t.onDataMessage);
38
- R.current = t.onDataMessage, S(() => {
39
- const w = {
40
- onConnectionStateChange: (y) => {
41
- i(y), y === "connected" && D(null);
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 = {
40
+ onConnectionStateChange: (w) => {
41
+ r(w), w === "connected" && P(null);
42
42
  },
43
- onAgentStateChange: r,
44
- onTranscript: (y) => c([...y]),
45
- onAgentConfig: d,
46
- onAudioTrack: (y) => a(y),
47
- onVideoTrack: (y) => p(y),
48
- onVideoTrackRemoved: () => p(null),
49
- onError: (y) => D(y),
50
- onDataMessage: (y) => {
51
- var A;
52
- (A = R.current) == null || A.call(R, y);
43
+ onAgentStateChange: o,
44
+ onTranscript: (w) => d([...w]),
45
+ onAgentConfig: s,
46
+ onAudioTrack: (w) => c(w),
47
+ onVideoTrack: (w) => f(w),
48
+ onVideoTrackRemoved: () => f(null),
49
+ onError: (w) => P(w),
50
+ onDataMessage: (w) => {
51
+ var z;
52
+ (z = T.current) == null || z.call(T, w);
53
53
  },
54
- onResumabilityChange: b
55
- }, x = new tt(
54
+ onResumabilityChange: x
55
+ }, L = new Bt(
56
56
  {
57
- agentId: t.agentId,
58
- baseUrl: t.baseUrl,
59
- apiKey: t.apiKey,
60
- sessionEndpoint: t.sessionEndpoint,
61
- sessionBody: t.sessionBody
57
+ agentId: e.agentId,
58
+ baseUrl: e.baseUrl,
59
+ apiKey: e.apiKey,
60
+ sessionEndpoint: e.sessionEndpoint,
61
+ sessionBody: e.sessionBody
62
62
  },
63
- w
63
+ k
64
64
  );
65
- return E.current = x, i("idle"), r("idle"), c([]), d(null), p(null), a(null), b(!1), D(null), () => {
66
- var y;
67
- (y = x.destroy) == null || y.call(x), E.current = null;
65
+ return b.current = L, r("idle"), o("idle"), d([]), s(null), f(null), c(null), x(!1), P(null), () => {
66
+ var w;
67
+ (w = L.destroy) == null || w.call(L), b.current = null;
68
68
  };
69
69
  }, [
70
- t.agentId,
71
- t.baseUrl,
72
- t.apiKey,
73
- t.sessionEndpoint,
74
- JSON.stringify(t.sessionBody ?? {})
70
+ e.agentId,
71
+ e.baseUrl,
72
+ e.apiKey,
73
+ e.sessionEndpoint,
74
+ JSON.stringify(e.sessionBody ?? {})
75
75
  ]);
76
- const T = g(async () => {
77
- const w = E.current;
78
- if (w)
76
+ const p = y(async () => {
77
+ const k = b.current;
78
+ if (k)
79
79
  try {
80
- await w.connect();
81
- } catch (x) {
82
- throw D(x instanceof Error ? x.message : String(x)), x;
80
+ await k.connect();
81
+ } catch (L) {
82
+ throw P(L instanceof Error ? L.message : String(L)), L;
83
83
  }
84
- }, []), z = g(() => {
85
- const w = E.current;
86
- w && w.disconnect();
87
- }, []), I = g(() => {
88
- var w;
89
- return ((w = E.current) == null ? void 0 : w.getRoom()) ?? null;
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;
90
90
  }, []);
91
91
  return {
92
92
  connectionState: n,
93
- agentState: l,
94
- transcript: s,
95
- agentConfig: m,
96
- videoElement: f,
97
- audioElement: o,
98
- canResume: C,
99
- error: N,
100
- connect: T,
101
- disconnect: z,
102
- getRoom: I,
103
- session: E.current
93
+ agentState: i,
94
+ transcript: l,
95
+ agentConfig: u,
96
+ videoElement: g,
97
+ audioElement: a,
98
+ canResume: S,
99
+ error: E,
100
+ connect: p,
101
+ disconnect: N,
102
+ getRoom: R,
103
+ session: b.current
104
104
  };
105
105
  }
106
- function ot() {
107
- const t = L(null), n = L(null), i = L(null), l = L(null), r = L(/* @__PURE__ */ new Set()), s = L(null), c = g(() => {
108
- const o = n.current;
109
- if (!o) {
110
- l.current = null;
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;
109
+ if (!a) {
110
+ i.current = null;
111
111
  return;
112
112
  }
113
- (!s.current || s.current.length !== o.frequencyBinCount) && (s.current = new Uint8Array(
114
- new ArrayBuffer(o.frequencyBinCount)
113
+ (!l.current || l.current.length !== a.frequencyBinCount) && (l.current = new Uint8Array(
114
+ new ArrayBuffer(a.frequencyBinCount)
115
115
  ));
116
- const a = s.current;
117
- o.getByteFrequencyData(a);
118
- let C = 0;
119
- for (let N = 0; N < a.length; N++) C += a[N];
120
- const b = C / a.length / 255;
121
- for (const N of r.current)
116
+ const c = l.current;
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)
122
122
  try {
123
- N(b);
124
- } catch (D) {
125
- console.error("[useAudioLevel] subscriber threw:", D);
123
+ E(x);
124
+ } catch (P) {
125
+ console.error("[useAudioLevel] subscriber threw:", P);
126
126
  }
127
- l.current = requestAnimationFrame(c);
128
- }, []), m = g(() => {
129
- if (t.current || typeof window > "u" || typeof AudioContext > "u") return;
130
- const o = new AudioContext(), a = o.createAnalyser();
131
- a.fftSize = 64, a.connect(o.destination), t.current = o, n.current = a;
132
- }, []), d = g(
133
- (o) => {
134
- if (m(), !(!t.current || !n.current)) {
135
- if (i.current) {
127
+ i.current = requestAnimationFrame(d);
128
+ }, []), u = y(() => {
129
+ if (e.current || typeof window > "u" || typeof AudioContext > "u") return;
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(
133
+ (a) => {
134
+ if (u(), !(!e.current || !n.current)) {
135
+ if (r.current) {
136
136
  try {
137
- i.current.disconnect();
137
+ r.current.disconnect();
138
138
  } catch {
139
139
  }
140
- i.current = null;
140
+ r.current = null;
141
141
  }
142
142
  try {
143
- const a = t.current.createMediaElementSource(o);
144
- a.connect(n.current), i.current = a;
145
- } catch (a) {
146
- console.warn("[useAudioLevel] createMediaElementSource failed:", a);
143
+ const c = e.current.createMediaElementSource(a);
144
+ c.connect(n.current), r.current = c;
145
+ } catch (c) {
146
+ console.warn("[useAudioLevel] createMediaElementSource failed:", c);
147
147
  return;
148
148
  }
149
- l.current === null && (l.current = requestAnimationFrame(c));
149
+ i.current === null && (i.current = requestAnimationFrame(d));
150
150
  }
151
151
  },
152
- [m, c]
153
- ), f = g(() => {
154
- if (l.current !== null && (cancelAnimationFrame(l.current), l.current = null), i.current) {
152
+ [u, d]
153
+ ), g = y(() => {
154
+ if (i.current !== null && (cancelAnimationFrame(i.current), i.current = null), r.current) {
155
155
  try {
156
- i.current.disconnect();
156
+ r.current.disconnect();
157
157
  } catch {
158
158
  }
159
- i.current = null;
159
+ r.current = null;
160
160
  }
161
- }, []), p = g((o) => (r.current.add(o), () => {
162
- r.current.delete(o);
161
+ }, []), f = y((a) => (o.current.add(a), () => {
162
+ o.current.delete(a);
163
163
  }), []);
164
- return S(() => () => {
165
- if (f(), n.current) {
164
+ return I(() => () => {
165
+ if (g(), n.current) {
166
166
  try {
167
167
  n.current.disconnect();
168
168
  } catch {
169
169
  }
170
170
  n.current = null;
171
171
  }
172
- if (t.current) {
172
+ if (e.current) {
173
173
  try {
174
- t.current.close();
174
+ e.current.close();
175
175
  } catch {
176
176
  }
177
- t.current = null;
177
+ e.current = null;
178
178
  }
179
- r.current.clear(), s.current = null;
180
- }, [f]), { attach: d, detach: f, subscribe: p };
179
+ o.current.clear(), l.current = null;
180
+ }, [g]), { attach: s, detach: g, subscribe: f };
181
181
  }
182
- function at() {
183
- const [t, n] = k(!1), [i, l] = k(null), r = L(null), s = L(null), c = g(async (p) => {
184
- if (r.current && s.current) {
182
+ function Vt() {
183
+ const [e, n] = C(!1), [r, i] = C(null), o = A(null), l = A(null), d = y(async (f) => {
184
+ if (o.current && l.current) {
185
185
  try {
186
- await s.current.localParticipant.unpublishTrack(r.current);
186
+ await l.current.localParticipant.unpublishTrack(o.current);
187
187
  } catch {
188
188
  }
189
- r.current.stop(), r.current = null;
189
+ o.current.stop(), o.current = null;
190
190
  }
191
- s.current = p, l(null);
191
+ l.current = f, i(null);
192
192
  try {
193
- const o = await nt({
193
+ const a = await Ut({
194
194
  echoCancellation: !0,
195
195
  noiseSuppression: !0
196
196
  });
197
- await p.localParticipant.publishTrack(o), r.current = o, n(o.isMuted);
198
- } catch (o) {
199
- const a = o instanceof Error && o.name === "NotAllowedError" ? "Enable your microphone to talk with the agent." : "Microphone unavailable. Check browser permissions and try again.";
200
- throw l(a), o;
197
+ await f.localParticipant.publishTrack(a), o.current = a, n(a.isMuted);
198
+ } catch (a) {
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
+ throw i(c), a;
201
201
  }
202
- }, []), m = g(() => {
203
- const p = r.current;
204
- p && (p.isMuted ? (p.unmute(), n(!1)) : (p.mute(), n(!0)));
205
- }, []), d = g(() => {
206
- const p = r.current, o = s.current;
207
- if (p && o) {
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) {
208
208
  try {
209
- o.localParticipant.unpublishTrack(p);
209
+ a.localParticipant.unpublishTrack(f);
210
210
  } catch {
211
211
  }
212
- p.stop();
212
+ f.stop();
213
213
  }
214
- r.current = null, s.current = null, n(!1);
215
- }, []), f = g(() => l(null), []);
214
+ o.current = null, l.current = null, n(!1);
215
+ }, []), g = y(() => i(null), []);
216
216
  return {
217
- isMuted: t,
218
- micError: i,
219
- toggleMute: m,
220
- setupMic: c,
221
- teardownMic: d,
222
- clearError: f
217
+ isMuted: e,
218
+ micError: r,
219
+ toggleMute: u,
220
+ setupMic: d,
221
+ teardownMic: s,
222
+ clearError: g
223
223
  };
224
224
  }
225
- const st = { resolution: { width: 640, height: 480, frameRate: 24 } };
226
- function ct() {
227
- const [t, n] = k(!1), [i, l] = k(null), [r, s] = k(null), [c, m] = k(""), d = L(null), f = L(null), p = g((E) => {
228
- d.current = E;
229
- }, []), o = g(() => {
230
- const E = d.current, R = f.current;
231
- if (R && E) {
232
- const T = E.localParticipant.getTrackPublication(We.Source.Camera);
233
- if (T != null && T.track) {
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) {
234
234
  try {
235
- E.localParticipant.unpublishTrack(T.track);
235
+ b.localParticipant.unpublishTrack(p.track);
236
236
  } catch {
237
237
  }
238
- T.track.stop();
238
+ p.track.stop();
239
239
  } else
240
- R.stop();
240
+ T.stop();
241
241
  }
242
- f.current = null, s(null), n(!1);
243
- }, []), a = g(async (E) => {
244
- const R = d.current;
245
- if (R) {
246
- l(null);
242
+ g.current = null, l(null), n(!1);
243
+ }, []), c = y(async (b) => {
244
+ const T = s.current;
245
+ if (T) {
246
+ i(null);
247
247
  try {
248
- const T = { ...st };
249
- E && (T.deviceId = E);
250
- const z = await rt(T);
251
- await R.localParticipant.publishTrack(z), f.current = z;
252
- const I = z.attach();
253
- s(I), n(!0), E && m(E);
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);
254
254
  try {
255
- R.localParticipant.publishData(
255
+ T.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 (T) {
262
- const z = T instanceof Error && T.name === "NotAllowedError" ? "Enable your camera in the browser to share video." : "Camera unavailable. Check permissions and try again.";
263
- l(z);
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);
264
264
  }
265
265
  }
266
- }, []), C = g(async () => {
267
- t ? o() : await a(c || void 0);
268
- }, [t, c, o, a]), b = g(async (E) => {
269
- o(), await a(E);
270
- }, [o, a]), N = g(() => {
271
- o(), d.current = null, l(null), m("");
272
- }, [o]), D = g(() => l(null), []);
273
- return S(() => () => {
274
- f.current && f.current.stop();
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), []);
273
+ return I(() => () => {
274
+ g.current && g.current.stop();
275
275
  }, []), {
276
- isEnabled: t,
277
- error: i,
278
- previewEl: r,
279
- activeDeviceId: c,
280
- toggle: C,
281
- switchDevice: b,
282
- attachRoom: p,
283
- teardown: N,
284
- clearError: D
276
+ isEnabled: e,
277
+ error: r,
278
+ previewEl: o,
279
+ activeDeviceId: d,
280
+ toggle: S,
281
+ switchDevice: x,
282
+ attachRoom: f,
283
+ teardown: E,
284
+ clearError: P
285
285
  };
286
286
  }
287
- function dt() {
288
- const [t, n] = k(!1), [i, l] = k(null), [r, s] = k(null), c = L(null), m = g((a) => {
289
- c.current = a;
290
- }, []), d = g(() => s(null), []), f = g(async () => {
291
- const a = c.current;
292
- if (a) {
293
- if (t) {
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;
292
+ if (c) {
293
+ if (e) {
294
294
  try {
295
- await a.localParticipant.setScreenShareEnabled(!1);
295
+ await c.localParticipant.setScreenShareEnabled(!1);
296
296
  } catch {
297
297
  }
298
- d(), n(!1);
298
+ s(), n(!1);
299
299
  return;
300
300
  }
301
- l(null);
301
+ i(null);
302
302
  try {
303
- await a.localParticipant.setScreenShareEnabled(!0);
304
- let C = 0;
305
- const b = () => {
306
- const N = a.localParticipant.getTrackPublication(We.Source.ScreenShare);
307
- if (N != null && N.track) {
308
- const D = N.track.attach();
309
- s(D), n(!0);
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);
310
310
  try {
311
- a.localParticipant.publishData(
311
+ c.localParticipant.publishData(
312
312
  new TextEncoder().encode(JSON.stringify({ type: "user_screen_share_on" })),
313
313
  { reliable: !0 }
314
314
  );
@@ -316,132 +316,192 @@ function dt() {
316
316
  }
317
317
  return;
318
318
  }
319
- C++ < 10 ? setTimeout(b, 100) : n(!0);
319
+ S++ < 10 ? setTimeout(x, 100) : n(!0);
320
320
  };
321
- b();
322
- } catch (C) {
323
- const b = C instanceof Error ? C.name : "";
324
- b !== "NotAllowedError" && b !== "AbortError" && l("Screen share unavailable. Try again."), n(!1);
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);
325
325
  }
326
326
  }
327
- }, [t, d]), p = g(() => {
328
- const a = c.current;
329
- if (a && t)
327
+ }, [e, s]), f = y(() => {
328
+ const c = d.current;
329
+ if (c && e)
330
330
  try {
331
- a.localParticipant.setScreenShareEnabled(!1);
331
+ c.localParticipant.setScreenShareEnabled(!1);
332
332
  } catch {
333
333
  }
334
- d(), n(!1), l(null), c.current = null;
335
- }, [t, d]), o = g(() => l(null), []);
336
- return { isEnabled: t, error: i, previewEl: r, toggle: f, attachRoom: m, teardown: p, clearError: o };
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 };
337
337
  }
338
- function ut() {
339
- const [t, n] = k([]), [i, l] = k([]), r = g(async () => {
338
+ function Yt() {
339
+ const [e, n] = C([]), [r, i] = C([]), o = y(async () => {
340
340
  if (!(typeof navigator > "u" || !navigator.mediaDevices))
341
341
  try {
342
- const s = await navigator.mediaDevices.enumerateDevices();
343
- n(s.filter((c) => c.kind === "audioinput")), l(s.filter((c) => c.kind === "videoinput"));
342
+ const l = await navigator.mediaDevices.enumerateDevices();
343
+ n(l.filter((d) => d.kind === "audioinput")), i(l.filter((d) => d.kind === "videoinput"));
344
344
  } catch {
345
345
  }
346
346
  }, []);
347
- return S(() => {
348
- if (r(), typeof navigator > "u" || !navigator.mediaDevices) return;
349
- const s = () => void r();
350
- return navigator.mediaDevices.addEventListener("devicechange", s), () => navigator.mediaDevices.removeEventListener("devicechange", s);
351
- }, [r]), { mics: t, cameras: i, refresh: r };
347
+ return I(() => {
348
+ if (o(), typeof navigator > "u" || !navigator.mediaDevices) return;
349
+ const l = () => void o();
350
+ return navigator.mediaDevices.addEventListener("devicechange", l), () => navigator.mediaDevices.removeEventListener("devicechange", l);
351
+ }, [o]), { mics: e, cameras: r, refresh: o };
352
352
  }
353
- function ht(t, n, i = !1) {
354
- const [l, r] = k(null), [s, c] = k(null), [m, d] = k(!i && !!t);
355
- return S(() => {
356
- if (i || !t) {
357
- d(!1);
353
+ function Kt(e, n, r = !1) {
354
+ const [i, o] = C(null), [l, d] = C(null), [u, s] = C(!r && !!e);
355
+ return I(() => {
356
+ if (r || !e) {
357
+ s(!1);
358
358
  return;
359
359
  }
360
- const f = new AbortController(), p = n || "https://app.livelayer.studio";
361
- return d(!0), c(null), fetch(`${p}/api/widget/agent/${encodeURIComponent(t)}`, {
362
- signal: f.signal
363
- }).then(async (o) => {
364
- if (!o.ok) {
365
- const a = await o.json().catch(() => ({}));
366
- throw new Error(a.error || `HTTP ${o.status}`);
360
+ const g = new AbortController(), f = n || "https://app.livelayer.studio";
361
+ return s(!0), d(null), fetch(`${f}/api/widget/agent/${encodeURIComponent(e)}`, {
362
+ signal: g.signal
363
+ }).then(async (a) => {
364
+ if (!a.ok) {
365
+ const c = await a.json().catch(() => ({}));
366
+ throw new Error(c.error || `HTTP ${a.status}`);
367
367
  }
368
- return o.json();
369
- }).then((o) => {
370
- f.signal.aborted || (r(o), d(!1));
371
- }).catch((o) => {
372
- f.signal.aborted || (c(o instanceof Error ? o.message : "Agent lookup failed"), d(!1));
373
- }), () => f.abort();
374
- }, [t, n, i]), { info: l, error: s, loading: m };
368
+ return a.json();
369
+ }).then((a) => {
370
+ g.signal.aborted || (o(a), s(!1));
371
+ }).catch((a) => {
372
+ g.signal.aborted || (d(a instanceof Error ? a.message : "Agent lookup failed"), s(!1));
373
+ }), () => g.abort();
374
+ }, [e, n, r]), { info: i, error: l, loading: u };
375
375
  }
376
- function pt(t) {
376
+ function Xt(e) {
377
377
  if (typeof window > "u") return null;
378
378
  try {
379
- return window.localStorage.getItem(t);
379
+ return window.localStorage.getItem(e);
380
380
  } catch {
381
381
  return null;
382
382
  }
383
383
  }
384
- function mt(t, n) {
384
+ function Jt(e, n) {
385
385
  if (!(typeof window > "u"))
386
386
  try {
387
- window.localStorage.setItem(t, n);
387
+ window.localStorage.setItem(e, n);
388
388
  } catch {
389
389
  }
390
390
  }
391
- function ft({
392
- value: t,
391
+ function Qt({
392
+ value: e,
393
393
  defaultValue: n = "expanded",
394
- onChange: i
394
+ onChange: r
395
395
  } = {}) {
396
- const l = t !== void 0, [r, s] = k(n), c = l ? t : r, m = g(
397
- (d) => {
398
- d !== c && (l || s(d), i == null || i(d));
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));
399
399
  },
400
- [c, l, i]
400
+ [d, i, r]
401
401
  );
402
- return [c, m];
402
+ return [d, u];
403
403
  }
404
- const gt = ["hidden", "minimized", "expanded"];
405
- function vt(t) {
406
- return t && gt.includes(t) ? t : null;
404
+ const Zt = ["hidden", "minimized", "expanded"];
405
+ function en(e) {
406
+ return e && Zt.includes(e) ? e : null;
407
407
  }
408
- function yt({
409
- value: t,
408
+ function tn({
409
+ value: e,
410
410
  defaultValue: n = "expanded",
411
- onChange: i,
412
- persistKey: l = "ll-widget",
413
- disablePersistence: r = !1
411
+ onChange: r,
412
+ persistKey: i = "ll-widget",
413
+ disablePersistence: o = !1
414
414
  } = {}) {
415
- const s = `${l}:display-mode`, c = L(!1), [m, d] = ft({
416
- value: t,
415
+ const l = `${i}:display-mode`, d = A(!1), [u, s] = Qt({
416
+ value: e,
417
417
  defaultValue: n,
418
- onChange: (f) => {
419
- t === void 0 && !r && mt(s, f), i == null || i(f);
418
+ onChange: (g) => {
419
+ e === void 0 && !o && Jt(l, g), r == null || r(g);
420
420
  }
421
421
  });
422
- return S(() => {
423
- if (c.current || (c.current = !0, r || t !== void 0)) return;
424
- const f = vt(pt(s));
425
- f && f !== m && d(f);
426
- }, []), [m, d];
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];
427
427
  }
428
- const _t = 640;
429
- function bt(t = _t) {
430
- const [n, i] = k(!1);
431
- return S(() => {
432
- if (t === !1) {
433
- i(!1);
428
+ const nn = 640;
429
+ function rn(e = nn) {
430
+ const [n, r] = C(!1);
431
+ return I(() => {
432
+ if (e === !1) {
433
+ r(!1);
434
434
  return;
435
435
  }
436
436
  if (typeof window > "u" || typeof window.matchMedia > "u")
437
437
  return;
438
- const l = `(max-width: ${t - 1}px)`, r = window.matchMedia(l), s = () => i(r.matches);
439
- return s(), typeof r.addEventListener == "function" ? (r.addEventListener("change", s), () => r.removeEventListener("change", s)) : (r.addListener(s), () => {
440
- r.removeListener(s);
438
+ const i = `(max-width: ${e - 1}px)`, o = window.matchMedia(i), l = () => r(o.matches);
439
+ return l(), typeof o.addEventListener == "function" ? (o.addEventListener("change", l), () => o.removeEventListener("change", l)) : (o.addListener(l), () => {
440
+ o.removeListener(l);
441
441
  });
442
- }, [t]), n;
442
+ }, [e]), n;
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;
448
+ window.history.pushState = function(...r) {
449
+ const i = e.apply(this, r);
450
+ return window.dispatchEvent(new Event(ze)), i;
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;
455
+ }
456
+ function st() {
457
+ return typeof window > "u" ? "/" : window.location.pathname || "/";
458
+ }
459
+ function ln(e) {
460
+ const [n, r] = C(
461
+ () => e ?? st()
462
+ );
463
+ return I(() => {
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);
469
+ };
470
+ }, [e]), e ?? n;
443
471
  }
444
- const Pe = ({ muted: t = !1, className: n }) => t ? /* @__PURE__ */ _(
472
+ const dt = /* @__PURE__ */ new Map(), an = /[\\^$+?.()|{}[\]]/g;
473
+ function cn(e) {
474
+ return e.replace(an, "\\$&");
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;
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);
485
+ }
486
+ function un(e, n) {
487
+ return typeof e == "function" ? e(n) : e instanceof RegExp ? e.test(n) : dn(e, n);
488
+ }
489
+ function ut(e, n) {
490
+ if (!e || e.length === 0) return !1;
491
+ for (const r of e)
492
+ if (un(r, n)) return !0;
493
+ return !1;
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;
497
+ }
498
+ function fn(e, n, r) {
499
+ return De(
500
+ () => hn(e, n, r),
501
+ [e, n, r]
502
+ );
503
+ }
504
+ const ht = ({ muted: e = !1, className: n }) => e ? /* @__PURE__ */ _(
445
505
  "svg",
446
506
  {
447
507
  className: n,
@@ -451,7 +511,7 @@ const Pe = ({ muted: t = !1, className: n }) => t ? /* @__PURE__ */ _(
451
511
  strokeWidth: 2,
452
512
  "aria-hidden": "true",
453
513
  children: [
454
- /* @__PURE__ */ e(
514
+ /* @__PURE__ */ t(
455
515
  "path",
456
516
  {
457
517
  strokeLinecap: "round",
@@ -459,7 +519,7 @@ const Pe = ({ muted: t = !1, className: n }) => t ? /* @__PURE__ */ _(
459
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"
460
520
  }
461
521
  ),
462
- /* @__PURE__ */ e(
522
+ /* @__PURE__ */ t(
463
523
  "path",
464
524
  {
465
525
  strokeLinecap: "round",
@@ -469,7 +529,7 @@ const Pe = ({ muted: t = !1, className: n }) => t ? /* @__PURE__ */ _(
469
529
  )
470
530
  ]
471
531
  }
472
- ) : /* @__PURE__ */ e(
532
+ ) : /* @__PURE__ */ t(
473
533
  "svg",
474
534
  {
475
535
  className: n,
@@ -478,7 +538,7 @@ const Pe = ({ muted: t = !1, className: n }) => t ? /* @__PURE__ */ _(
478
538
  stroke: "currentColor",
479
539
  strokeWidth: 2,
480
540
  "aria-hidden": "true",
481
- children: /* @__PURE__ */ e(
541
+ children: /* @__PURE__ */ t(
482
542
  "path",
483
543
  {
484
544
  strokeLinecap: "round",
@@ -487,16 +547,16 @@ const Pe = ({ muted: t = !1, className: n }) => t ? /* @__PURE__ */ _(
487
547
  }
488
548
  )
489
549
  }
490
- ), Be = ({ className: t }) => /* @__PURE__ */ e(
550
+ ), ft = ({ className: e }) => /* @__PURE__ */ t(
491
551
  "svg",
492
552
  {
493
- className: t,
553
+ className: e,
494
554
  fill: "none",
495
555
  viewBox: "0 0 24 24",
496
556
  stroke: "currentColor",
497
557
  strokeWidth: 2,
498
558
  "aria-hidden": "true",
499
- children: /* @__PURE__ */ e(
559
+ children: /* @__PURE__ */ t(
500
560
  "path",
501
561
  {
502
562
  strokeLinecap: "round",
@@ -505,23 +565,23 @@ const Pe = ({ muted: t = !1, className: n }) => t ? /* @__PURE__ */ _(
505
565
  }
506
566
  )
507
567
  }
508
- ), wt = ({ className: t }) => /* @__PURE__ */ e(
568
+ ), pn = ({ className: e }) => /* @__PURE__ */ t(
509
569
  "svg",
510
570
  {
511
- className: t,
571
+ className: e,
512
572
  fill: "none",
513
573
  viewBox: "0 0 24 24",
514
574
  stroke: "currentColor",
515
575
  strokeWidth: 2,
516
576
  "aria-hidden": "true",
517
- children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
577
+ children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
518
578
  }
519
- ), kt = {
579
+ ), mn = {
520
580
  left: 180,
521
581
  right: 0,
522
582
  up: -90,
523
583
  down: 90
524
- }, xt = ({ direction: t = "right", className: n }) => /* @__PURE__ */ e(
584
+ }, gn = ({ direction: e = "right", className: n }) => /* @__PURE__ */ t(
525
585
  "svg",
526
586
  {
527
587
  className: n,
@@ -529,304 +589,304 @@ const Pe = ({ muted: t = !1, className: n }) => t ? /* @__PURE__ */ _(
529
589
  viewBox: "0 0 24 24",
530
590
  stroke: "currentColor",
531
591
  strokeWidth: 2,
532
- style: { transform: `rotate(${kt[t]}deg)` },
592
+ style: { transform: `rotate(${mn[e]}deg)` },
533
593
  "aria-hidden": "true",
534
- children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M9 6l6 6-6 6" })
594
+ children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M9 6l6 6-6 6" })
535
595
  }
536
596
  );
537
- function Ct(t) {
538
- return t === "top-left" || t === "bottom-left" ? "left" : "right";
597
+ function vn(e) {
598
+ return e === "top-left" || e === "bottom-left" ? "left" : "right";
539
599
  }
540
- const Fe = "ll-hidden-tab-center-y", Nt = 5, Ue = 16;
541
- function Et() {
600
+ const kt = "ll-hidden-tab-center-y", yn = 5, pt = 16;
601
+ function bn() {
542
602
  if (typeof window > "u") return null;
543
603
  try {
544
- const t = window.localStorage.getItem(Fe);
545
- if (!t) return null;
546
- const n = Number.parseFloat(t);
604
+ const e = window.localStorage.getItem(kt);
605
+ if (!e) return null;
606
+ const n = Number.parseFloat(e);
547
607
  return Number.isFinite(n) ? n : null;
548
608
  } catch {
549
609
  return null;
550
610
  }
551
611
  }
552
- function $e(t) {
612
+ function mt(e) {
553
613
  if (!(typeof window > "u"))
554
614
  try {
555
- window.localStorage.setItem(Fe, String(t));
615
+ window.localStorage.setItem(kt, String(e));
556
616
  } catch {
557
617
  }
558
618
  }
559
- const St = ({
560
- position: t,
619
+ const wn = ({
620
+ position: e,
561
621
  isMobile: n,
562
- isSpeaking: i,
563
- onExpand: l,
564
- label: r = "Open widget"
622
+ isSpeaking: r,
623
+ onExpand: i,
624
+ label: o = "Open widget"
565
625
  }) => {
566
- const s = Ct(t), c = s === "right" ? "left" : "right", m = n ? 80 : 72, [d, f] = k(null), [p, o] = k(!1), a = L(null), C = L(!1), b = g(
567
- (w) => {
568
- if (typeof window > "u") return w;
569
- const x = m / 2, y = Ue + x, A = window.innerHeight - Ue - x;
570
- return A < y ? Math.max(y, w) : Math.max(y, Math.min(A, w));
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));
571
631
  },
572
- [m]
632
+ [u]
573
633
  );
574
- S(() => {
575
- const w = Et();
576
- f(b(w ?? window.innerHeight / 2));
577
- const x = () => {
578
- f((y) => y === null ? null : b(y));
634
+ I(() => {
635
+ const k = bn();
636
+ g(x(k ?? window.innerHeight / 2));
637
+ const L = () => {
638
+ g((w) => w === null ? null : x(w));
579
639
  };
580
- return window.addEventListener("resize", x), () => window.removeEventListener("resize", x);
581
- }, [b]);
582
- const N = g(
583
- (w) => {
584
- if (!(w.pointerType === "mouse" && w.button !== 0) && d !== null) {
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) {
585
645
  try {
586
- w.currentTarget.setPointerCapture(w.pointerId);
646
+ k.currentTarget.setPointerCapture(k.pointerId);
587
647
  } catch {
588
648
  }
589
- a.current = {
590
- startClientY: w.clientY,
591
- startCenterY: d,
649
+ c.current = {
650
+ startClientY: k.clientY,
651
+ startCenterY: s,
592
652
  moved: !1
593
653
  };
594
654
  }
595
655
  },
596
- [d]
597
- ), D = g(
598
- (w) => {
599
- const x = a.current;
600
- if (!x) return;
601
- const y = w.clientY - x.startClientY;
602
- !x.moved && Math.abs(y) > Nt && (x.moved = !0, o(!0)), x.moved && f(b(x.startCenterY + y));
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));
603
663
  },
604
- [b]
605
- ), E = g(
606
- (w) => {
607
- const x = a.current;
608
- if (x) {
664
+ [x]
665
+ ), b = y(
666
+ (k) => {
667
+ const L = c.current;
668
+ if (L) {
609
669
  try {
610
- w.currentTarget.releasePointerCapture(w.pointerId);
670
+ k.currentTarget.releasePointerCapture(k.pointerId);
611
671
  } catch {
612
672
  }
613
- a.current = null, x.moved && (o(!1), C.current = !0, f((y) => (y !== null && $e(y), y)));
673
+ c.current = null, L.moved && (a(!1), S.current = !0, g((w) => (w !== null && mt(w), w)));
614
674
  }
615
675
  },
616
676
  []
617
- ), R = g(() => {
618
- if (C.current) {
619
- C.current = !1;
677
+ ), T = y(() => {
678
+ if (S.current) {
679
+ S.current = !1;
620
680
  return;
621
681
  }
622
- l();
623
- }, [l]), T = g(
624
- (w) => {
625
- if (w.key === "ArrowUp" || w.key === "ArrowDown") {
626
- w.preventDefault();
627
- const x = w.key === "ArrowUp" ? -8 : 8;
628
- f((y) => {
629
- if (y === null) return y;
630
- const A = b(y + x);
631
- return $e(A), A;
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;
688
+ g((w) => {
689
+ if (w === null) return w;
690
+ const z = x(w + L);
691
+ return mt(z), z;
632
692
  });
633
693
  }
634
694
  },
635
- [b]
636
- ), z = [
695
+ [x]
696
+ ), N = [
637
697
  "ll-hidden",
638
- `ll-hidden--${s}`,
698
+ `ll-hidden--${l}`,
639
699
  n ? "ll-hidden--mobile" : "ll-hidden--desktop",
640
- i ? "ll-hidden--speaking" : null,
641
- p ? "is-dragging" : null
642
- ].filter(Boolean).join(" "), I = d === null ? void 0 : { top: `${d - m / 2}px`, transform: "none" };
643
- return /* @__PURE__ */ e(
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(
644
704
  "button",
645
705
  {
646
706
  type: "button",
647
- className: z,
648
- onPointerDown: N,
649
- onPointerMove: D,
650
- onPointerUp: E,
651
- onPointerCancel: E,
652
- onClick: R,
653
- onKeyDown: T,
654
- "aria-label": r,
655
- "data-position": t,
656
- style: I,
657
- children: /* @__PURE__ */ e(xt, { direction: c, className: "ll-hidden__chevron" })
707
+ className: N,
708
+ onPointerDown: E,
709
+ onPointerMove: P,
710
+ onPointerUp: b,
711
+ onPointerCancel: b,
712
+ onClick: T,
713
+ onKeyDown: p,
714
+ "aria-label": o,
715
+ "data-position": e,
716
+ style: R,
717
+ children: /* @__PURE__ */ t(gn, { direction: d, className: "ll-hidden__chevron" })
658
718
  }
659
719
  );
660
- }, Lt = ({
661
- audioLevel: t,
720
+ }, _n = ({
721
+ audioLevel: e,
662
722
  bars: n = 20,
663
- maxHeight: i = 20,
664
- minHeight: l = 4,
665
- className: r,
666
- barClassName: s
723
+ maxHeight: r = 20,
724
+ minHeight: i = 4,
725
+ className: o,
726
+ barClassName: l
667
727
  }) => {
668
- const c = L(null), m = L([]), d = Se(() => {
669
- const p = (Math.sqrt(5) - 1) / 2;
670
- return Array.from({ length: n }, (o, a) => 0.5 + a * p % 1 * 0.5);
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);
671
731
  }, [n]);
672
- S(() => t.subscribe((o) => {
673
- for (let a = 0; a < n; a++) {
674
- const C = m.current[a];
675
- if (!C) continue;
676
- const b = Math.max(l, o * i * d[a]);
677
- C.style.height = `${b}px`;
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`;
678
738
  }
679
- }), [t, n, i, l, d]);
680
- const f = ["ll-waveform", r].filter(Boolean).join(" ");
681
- return /* @__PURE__ */ e("div", { ref: c, className: f, "aria-hidden": "true", children: Array.from({ length: n }, (p, o) => /* @__PURE__ */ e(
739
+ }), [e, n, r, i, s]);
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(
682
742
  "div",
683
743
  {
684
- ref: (a) => {
685
- m.current[o] = a;
744
+ ref: (c) => {
745
+ u.current[a] = c;
686
746
  },
687
- className: ["ll-waveform__bar", s].filter(Boolean).join(" "),
688
- style: { height: `${l}px` }
747
+ className: ["ll-waveform__bar", l].filter(Boolean).join(" "),
748
+ style: { height: `${i}px` }
689
749
  },
690
- o
750
+ a
691
751
  )) });
692
- }, Mt = ({
693
- position: t,
752
+ }, xn = ({
753
+ position: e,
694
754
  isMobile: n,
695
- agentName: i,
696
- avatarImageUrl: l,
697
- agentState: r,
698
- isMuted: s,
699
- audioLevel: c,
700
- onExpand: m,
701
- onToggleMute: d,
702
- onClose: f
703
- }) => n ? /* @__PURE__ */ e(
755
+ agentName: r,
756
+ avatarImageUrl: i,
757
+ agentState: o,
758
+ isMuted: l,
759
+ audioLevel: d,
760
+ onExpand: u,
761
+ onToggleMute: s,
762
+ onClose: g
763
+ }) => n ? /* @__PURE__ */ t(
704
764
  "div",
705
765
  {
706
766
  className: "ll-minimized ll-minimized--mobile",
707
767
  role: "region",
708
- "aria-label": `${i} widget`,
768
+ "aria-label": `${r} widget`,
709
769
  children: /* @__PURE__ */ _(
710
770
  "button",
711
771
  {
712
772
  type: "button",
713
773
  className: "ll-minimized__surface",
714
- onClick: m,
715
- "aria-label": `Expand ${i} widget`,
774
+ onClick: u,
775
+ "aria-label": `Expand ${r} widget`,
716
776
  children: [
717
- l ? (
777
+ i ? (
718
778
  // eslint-disable-next-line @next/next/no-img-element
719
- /* @__PURE__ */ e(
779
+ /* @__PURE__ */ t(
720
780
  "img",
721
781
  {
722
- src: l,
723
- alt: i,
782
+ src: i,
783
+ alt: r,
724
784
  className: "ll-minimized__avatar"
725
785
  }
726
786
  )
727
- ) : /* @__PURE__ */ e("div", { className: "ll-minimized__avatar ll-minimized__avatar--placeholder" }),
728
- /* @__PURE__ */ e(
729
- Lt,
787
+ ) : /* @__PURE__ */ t("div", { className: "ll-minimized__avatar ll-minimized__avatar--placeholder" }),
788
+ /* @__PURE__ */ t(
789
+ _n,
730
790
  {
731
- audioLevel: c,
791
+ audioLevel: d,
732
792
  bars: 16,
733
793
  maxHeight: 18,
734
794
  className: "ll-minimized__waveform"
735
795
  }
736
796
  ),
737
- /* @__PURE__ */ e("span", { className: "ll-minimized__name", children: i }),
797
+ /* @__PURE__ */ t("span", { className: "ll-minimized__name", children: r }),
738
798
  /* @__PURE__ */ _("div", { className: "ll-minimized__controls", children: [
739
- /* @__PURE__ */ e(
799
+ /* @__PURE__ */ t(
740
800
  "span",
741
801
  {
742
802
  className: "ll-minimized__btn",
743
803
  role: "button",
744
804
  tabIndex: 0,
745
- onClick: (p) => {
746
- p.stopPropagation(), d();
805
+ onClick: (f) => {
806
+ f.stopPropagation(), s();
747
807
  },
748
- onKeyDown: (p) => {
749
- (p.key === "Enter" || p.key === " ") && (p.stopPropagation(), p.preventDefault(), d());
808
+ onKeyDown: (f) => {
809
+ (f.key === "Enter" || f.key === " ") && (f.stopPropagation(), f.preventDefault(), s());
750
810
  },
751
- "aria-label": s ? "Unmute microphone" : "Mute microphone",
752
- children: /* @__PURE__ */ e(Pe, { muted: s, className: "ll-minimized__icon" })
811
+ "aria-label": l ? "Unmute microphone" : "Mute microphone",
812
+ children: /* @__PURE__ */ t(ht, { muted: l, className: "ll-minimized__icon" })
753
813
  }
754
814
  ),
755
- /* @__PURE__ */ e(Be, { className: "ll-minimized__icon ll-minimized__icon--expand" })
815
+ /* @__PURE__ */ t(ft, { className: "ll-minimized__icon ll-minimized__icon--expand" })
756
816
  ] })
757
817
  ]
758
818
  }
759
819
  )
760
820
  }
761
- ) : /* @__PURE__ */ e(
821
+ ) : /* @__PURE__ */ t(
762
822
  "div",
763
823
  {
764
824
  className: "ll-minimized ll-minimized--desktop",
765
- "data-position": t,
825
+ "data-position": e,
766
826
  role: "region",
767
- "aria-label": `${i} widget`,
827
+ "aria-label": `${r} widget`,
768
828
  children: /* @__PURE__ */ _("div", { className: "ll-minimized__surface", children: [
769
- l ? (
829
+ i ? (
770
830
  // eslint-disable-next-line @next/next/no-img-element
771
- /* @__PURE__ */ e(
831
+ /* @__PURE__ */ t(
772
832
  "img",
773
833
  {
774
- src: l,
775
- alt: i,
834
+ src: i,
835
+ alt: r,
776
836
  className: "ll-minimized__avatar"
777
837
  }
778
838
  )
779
- ) : /* @__PURE__ */ e("div", { className: "ll-minimized__avatar ll-minimized__avatar--placeholder" }),
839
+ ) : /* @__PURE__ */ t("div", { className: "ll-minimized__avatar ll-minimized__avatar--placeholder" }),
780
840
  /* @__PURE__ */ _("div", { className: "ll-minimized__meta", children: [
781
- /* @__PURE__ */ e("span", { className: "ll-minimized__name", children: i }),
782
- /* @__PURE__ */ e("span", { className: "ll-minimized__state", children: r === "speaking" ? "Speaking" : r === "thinking" ? "Thinking" : "Listening" })
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" })
783
843
  ] }),
784
844
  /* @__PURE__ */ _("div", { className: "ll-minimized__controls", children: [
785
- /* @__PURE__ */ e(
845
+ /* @__PURE__ */ t(
786
846
  "button",
787
847
  {
788
848
  type: "button",
789
849
  className: "ll-minimized__btn",
790
- onClick: d,
791
- "aria-label": s ? "Unmute microphone" : "Mute microphone",
792
- children: /* @__PURE__ */ e(Pe, { muted: s, className: "ll-minimized__icon" })
850
+ onClick: s,
851
+ "aria-label": l ? "Unmute microphone" : "Mute microphone",
852
+ children: /* @__PURE__ */ t(ht, { muted: l, className: "ll-minimized__icon" })
793
853
  }
794
854
  ),
795
- /* @__PURE__ */ e(
855
+ /* @__PURE__ */ t(
796
856
  "button",
797
857
  {
798
858
  type: "button",
799
859
  className: "ll-minimized__btn",
800
- onClick: m,
801
- "aria-label": `Expand ${i} widget`,
802
- children: /* @__PURE__ */ e(Be, { className: "ll-minimized__icon" })
860
+ onClick: u,
861
+ "aria-label": `Expand ${r} widget`,
862
+ children: /* @__PURE__ */ t(ft, { className: "ll-minimized__icon" })
803
863
  }
804
864
  ),
805
- /* @__PURE__ */ e(
865
+ /* @__PURE__ */ t(
806
866
  "button",
807
867
  {
808
868
  type: "button",
809
869
  className: "ll-minimized__btn ll-minimized__btn--close",
810
- onClick: f,
870
+ onClick: g,
811
871
  "aria-label": "Close widget",
812
- children: /* @__PURE__ */ e(wt, { className: "ll-minimized__icon" })
872
+ children: /* @__PURE__ */ t(pn, { className: "ll-minimized__icon" })
813
873
  }
814
874
  )
815
875
  ] })
816
876
  ] })
817
877
  }
818
- ), It = ({
819
- src: t,
878
+ ), kn = ({
879
+ src: e,
820
880
  alt: n,
821
- preCannedPlaying: i = !1,
822
- className: l,
823
- style: r
881
+ preCannedPlaying: r = !1,
882
+ className: i,
883
+ style: o
824
884
  }) => {
825
- const [s, c] = k(!1), m = L(t);
826
- if (S(() => {
827
- m.current !== t && (m.current = t, c(!1));
828
- }, [t]), !t) return null;
829
- const d = {
885
+ const [l, d] = C(!1), u = A(e);
886
+ if (I(() => {
887
+ u.current !== e && (u.current = e, d(!1));
888
+ }, [e]), !e) return null;
889
+ const s = {
830
890
  position: "absolute",
831
891
  inset: 0,
832
892
  width: "100%",
@@ -834,133 +894,133 @@ const St = ({
834
894
  objectFit: "cover",
835
895
  objectPosition: "top",
836
896
  transition: "opacity 500ms ease, transform 500ms ease",
837
- transform: i ? "scale(1.02)" : "scale(1)",
838
- opacity: s ? 1 : 0,
839
- ...r
897
+ transform: r ? "scale(1.02)" : "scale(1)",
898
+ opacity: l ? 1 : 0,
899
+ ...o
840
900
  };
841
901
  return (
842
902
  // eslint-disable-next-line @next/next/no-img-element
843
- /* @__PURE__ */ e(
903
+ /* @__PURE__ */ t(
844
904
  "img",
845
905
  {
846
- src: t,
906
+ src: e,
847
907
  alt: n,
848
- className: l,
849
- style: d,
908
+ className: i,
909
+ style: s,
850
910
  loading: "eager",
851
911
  fetchpriority: "high",
852
- onLoad: () => c(!0)
912
+ onLoad: () => d(!0)
853
913
  }
854
914
  )
855
915
  );
856
- }, At = ({
857
- position: t,
916
+ }, Cn = ({
917
+ position: e,
858
918
  isMobile: n,
859
- agentName: i,
860
- avatarImageUrl: l,
861
- idleLoopUrl: r,
862
- greeting: s,
863
- branding: c,
864
- teamMembers: m,
865
- currentTeamMemberId: d,
866
- isSwitchingTeamMember: f,
867
- teamSwitcherOpen: p,
868
- onToggleTeamSwitcher: o,
869
- onSelectTeamMember: a,
870
- languageMenuOpen: C,
871
- onToggleLanguageMenu: b,
872
- connectionState: N,
873
- agentState: D,
874
- transcript: E,
875
- canResume: R,
876
- needsUserGesture: T,
877
- error: z,
878
- isMuted: I,
879
- micError: w,
880
- micDevices: x,
881
- isCameraEnabled: y,
882
- cameraPreviewEl: A,
883
- cameraDevices: X,
884
- activeCameraId: ne,
885
- isScreenShareEnabled: $,
886
- screenPreviewEl: j,
887
- isSpeakerMuted: F,
888
- allowCamera: re,
889
- allowScreenShare: P,
890
- allowTyping: be,
891
- avatarVideoContainerRef: we,
892
- onConnect: ge,
893
- onDisconnect: ue,
894
- onRetry: ke,
895
- onResumeAudio: xe,
896
- onToggleMute: Q,
897
- onToggleCamera: U,
898
- onSwitchCameraDevice: ve,
899
- onToggleScreenShare: Z,
900
- onToggleSpeaker: G,
901
- onSendMessage: ee,
902
- onMinimize: ie,
903
- onClose: V,
904
- onClearMicError: K
919
+ agentName: r,
920
+ avatarImageUrl: i,
921
+ idleLoopUrl: o,
922
+ greeting: l,
923
+ branding: d,
924
+ teamMembers: u,
925
+ currentTeamMemberId: s,
926
+ isSwitchingTeamMember: g,
927
+ teamSwitcherOpen: f,
928
+ onToggleTeamSwitcher: a,
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,
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
905
965
  }) => {
906
- var ye;
907
- const O = E.length > 0 ? E[E.length - 1] : null, Y = ((m == null ? void 0 : m.length) ?? 0) > 1, le = N === "connecting" || N === "connected", H = N === "connected", he = N === "idle" || N === "disconnected" || N === "error", pe = L(null), oe = L(null);
908
- S(() => {
909
- const h = pe.current;
910
- h && (h.innerHTML = "", A && (A.style.width = "100%", A.style.height = "100%", A.style.objectFit = "cover", A.style.transform = "scaleX(-1)", h.appendChild(A)));
911
- }, [A]), S(() => {
912
- const h = oe.current;
913
- h && (h.innerHTML = "", j && (j.style.width = "100%", j.style.height = "100%", j.style.objectFit = "contain", h.appendChild(j)));
914
- }, [j]);
915
- const [q, ae] = k(!1), [se, J] = k(!1);
916
- S(() => {
917
- if (!q && !se && !C && !p) return;
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);
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);
976
+ I(() => {
977
+ if (!j && !q && !S && !f) return;
918
978
  const h = () => {
919
- ae(!1), J(!1), C && b(), p && o();
979
+ F(!1), Q(!1), S && x(), f && a();
920
980
  };
921
981
  return document.addEventListener("click", h), () => document.removeEventListener("click", h);
922
982
  }, [
983
+ j,
923
984
  q,
924
- se,
925
- C,
926
- p,
927
- b,
928
- o
985
+ S,
986
+ f,
987
+ x,
988
+ a
929
989
  ]);
930
- const [ce, de] = k(""), B = g(
990
+ const [pe, me] = C(""), we = y(
931
991
  (h) => {
932
992
  h.preventDefault();
933
- const W = ce.trim();
934
- W && (ee(W), de(""));
993
+ const O = pe.trim();
994
+ O && (ue(O), me(""));
935
995
  },
936
- [ce, ee]
937
- ), u = c.productName || "Live Layer", me = H && (O != null && O.text) ? O.text : s || "", Ce = [
996
+ [pe, ue]
997
+ ), Ae = d.productName || "Live Layer", ge = W && (V != null && V.text) ? V.text : l || "", _e = [
938
998
  "ll-expanded",
939
999
  n ? "ll-expanded--mobile" : "ll-expanded--desktop"
940
1000
  ].join(" ");
941
1001
  return /* @__PURE__ */ _(
942
1002
  "div",
943
1003
  {
944
- className: Ce,
945
- "data-position": t,
946
- "data-state": H ? "connected" : le ? "connecting" : "idle",
1004
+ className: _e,
1005
+ "data-position": e,
1006
+ "data-state": W ? "connected" : te ? "connecting" : "idle",
947
1007
  role: "dialog",
948
- "aria-label": `${i} widget`,
1008
+ "aria-label": `${r} widget`,
949
1009
  children: [
950
1010
  /* @__PURE__ */ _("div", { className: "ll-expanded__bg", children: [
951
- l ? /* @__PURE__ */ e(
952
- It,
1011
+ i ? /* @__PURE__ */ t(
1012
+ kn,
953
1013
  {
954
- src: l,
955
- alt: i,
1014
+ src: i,
1015
+ alt: r,
956
1016
  className: "ll-expanded__bg-img"
957
1017
  }
958
- ) : /* @__PURE__ */ e("div", { className: "ll-expanded__bg-fallback", children: /* @__PURE__ */ e("span", { className: "ll-expanded__bg-initial", children: ((ye = i == null ? void 0 : i.charAt(0)) == null ? void 0 : ye.toUpperCase()) || "A" }) }),
959
- r && !H && /* @__PURE__ */ e(
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(
960
1020
  "video",
961
1021
  {
962
1022
  className: "ll-expanded__bg-idle",
963
- src: r,
1023
+ src: o,
964
1024
  autoPlay: !0,
965
1025
  loop: !0,
966
1026
  muted: !0,
@@ -968,24 +1028,24 @@ const St = ({
968
1028
  }
969
1029
  )
970
1030
  ] }),
971
- /* @__PURE__ */ e("div", { ref: we, className: "ll-expanded__video" }),
972
- N === "connecting" && /* @__PURE__ */ _("div", { className: "ll-expanded__overlay ll-expanded__overlay--connecting", children: [
973
- /* @__PURE__ */ e("div", { className: "ll-expanded__spinner" }),
974
- /* @__PURE__ */ e("p", { className: "ll-expanded__overlay-text", children: f ? "Switching..." : "Connecting..." })
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..." })
975
1035
  ] }),
976
- T && H && /* @__PURE__ */ _(
1036
+ p && W && /* @__PURE__ */ _(
977
1037
  "button",
978
1038
  {
979
1039
  type: "button",
980
1040
  className: "ll-expanded__overlay ll-expanded__overlay--gesture",
981
- onClick: xe,
1041
+ onClick: de,
982
1042
  children: [
983
- /* @__PURE__ */ e("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": !0, children: /* @__PURE__ */ e("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" }) }),
984
- /* @__PURE__ */ e("p", { className: "ll-expanded__overlay-text", children: "Tap to enable audio" })
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" })
985
1045
  ]
986
1046
  }
987
1047
  ),
988
- le ? /* @__PURE__ */ _("div", { className: "ll-expanded__topbar", children: [
1048
+ te ? /* @__PURE__ */ _("div", { className: "ll-expanded__topbar", children: [
989
1049
  /* @__PURE__ */ _("div", { className: "ll-expanded__topbar-left", children: [
990
1050
  /* @__PURE__ */ _("div", { className: "ll-expanded__pill-wrap", children: [
991
1051
  /* @__PURE__ */ _(
@@ -994,32 +1054,32 @@ const St = ({
994
1054
  type: "button",
995
1055
  className: "ll-hpill",
996
1056
  onClick: (h) => {
997
- Y && (h.stopPropagation(), o());
1057
+ $ && (h.stopPropagation(), a());
998
1058
  },
999
- "aria-haspopup": Y ? "listbox" : void 0,
1000
- "aria-expanded": Y ? p : void 0,
1059
+ "aria-haspopup": $ ? "listbox" : void 0,
1060
+ "aria-expanded": $ ? f : void 0,
1001
1061
  children: [
1002
- /* @__PURE__ */ e("span", { className: "ll-hpill__label", children: i }),
1003
- Y && /* @__PURE__ */ e(_e, {})
1062
+ /* @__PURE__ */ t("span", { className: "ll-hpill__label", children: r }),
1063
+ $ && /* @__PURE__ */ t(Te, {})
1004
1064
  ]
1005
1065
  }
1006
1066
  ),
1007
- Y && p && /* @__PURE__ */ e(
1067
+ $ && f && /* @__PURE__ */ t(
1008
1068
  "div",
1009
1069
  {
1010
1070
  className: "ll-hmenu",
1011
1071
  onClick: (h) => h.stopPropagation(),
1012
1072
  role: "listbox",
1013
- children: m == null ? void 0 : m.map((h) => /* @__PURE__ */ _(
1073
+ children: u == null ? void 0 : u.map((h) => /* @__PURE__ */ _(
1014
1074
  "button",
1015
1075
  {
1016
1076
  type: "button",
1017
- className: `ll-hmenu__item ${h.id === d ? "is-active" : ""}`,
1018
- onClick: () => a(h.id),
1077
+ className: `ll-hmenu__item ${h.id === s ? "is-active" : ""}`,
1078
+ onClick: () => c(h.id),
1019
1079
  role: "option",
1020
- "aria-selected": h.id === d,
1080
+ "aria-selected": h.id === s,
1021
1081
  children: [
1022
- h.avatarImageUrl && /* @__PURE__ */ e(
1082
+ h.avatarImageUrl && /* @__PURE__ */ t(
1023
1083
  "img",
1024
1084
  {
1025
1085
  src: h.avatarImageUrl,
@@ -1027,8 +1087,8 @@ const St = ({
1027
1087
  className: "ll-hmenu__avatar"
1028
1088
  }
1029
1089
  ),
1030
- /* @__PURE__ */ e("span", { className: "ll-hmenu__name", children: h.name }),
1031
- h.role && /* @__PURE__ */ e("span", { className: "ll-hmenu__role", children: h.role })
1090
+ /* @__PURE__ */ t("span", { className: "ll-hmenu__name", children: h.name }),
1091
+ h.role && /* @__PURE__ */ t("span", { className: "ll-hmenu__role", children: h.role })
1032
1092
  ]
1033
1093
  },
1034
1094
  h.id
@@ -1043,294 +1103,309 @@ const St = ({
1043
1103
  type: "button",
1044
1104
  className: "ll-hpill ll-hpill--compact",
1045
1105
  onClick: (h) => {
1046
- h.stopPropagation(), b();
1106
+ h.stopPropagation(), x();
1047
1107
  },
1048
1108
  "aria-haspopup": "listbox",
1049
- "aria-expanded": C,
1109
+ "aria-expanded": S,
1050
1110
  "aria-label": "Language: English",
1051
1111
  title: "Language: English",
1052
1112
  children: [
1053
- /* @__PURE__ */ e("span", { className: "ll-hpill__label", children: "EN" }),
1054
- /* @__PURE__ */ e(_e, {})
1113
+ /* @__PURE__ */ t("span", { className: "ll-hpill__label", children: "EN" }),
1114
+ /* @__PURE__ */ t(Te, {})
1055
1115
  ]
1056
1116
  }
1057
1117
  ),
1058
- C && /* @__PURE__ */ e(
1118
+ S && /* @__PURE__ */ t(
1059
1119
  "div",
1060
1120
  {
1061
1121
  className: "ll-hmenu",
1062
1122
  onClick: (h) => h.stopPropagation(),
1063
1123
  role: "listbox",
1064
- children: /* @__PURE__ */ e(
1124
+ children: /* @__PURE__ */ t(
1065
1125
  "button",
1066
1126
  {
1067
1127
  type: "button",
1068
1128
  className: "ll-hmenu__item is-active",
1069
1129
  role: "option",
1070
1130
  "aria-selected": !0,
1071
- children: /* @__PURE__ */ e("span", { className: "ll-hmenu__name", children: "English" })
1131
+ children: /* @__PURE__ */ t("span", { className: "ll-hmenu__name", children: "English" })
1072
1132
  }
1073
1133
  )
1074
1134
  }
1075
1135
  )
1076
1136
  ] }),
1077
- /* @__PURE__ */ e(
1137
+ /* @__PURE__ */ t(
1078
1138
  "span",
1079
1139
  {
1080
- className: `ll-expanded__state ll-expanded__state--${D}`,
1081
- children: D
1140
+ className: `ll-expanded__state ll-expanded__state--${P}`,
1141
+ children: P
1082
1142
  }
1083
1143
  )
1084
1144
  ] }),
1085
1145
  /* @__PURE__ */ _("div", { className: "ll-expanded__header-actions", children: [
1086
- /* @__PURE__ */ e(
1146
+ /* @__PURE__ */ t(
1087
1147
  "button",
1088
1148
  {
1089
1149
  type: "button",
1090
1150
  className: "ll-hbtn",
1091
- onClick: ie,
1151
+ onClick: he,
1092
1152
  "aria-label": "Minimize widget",
1093
1153
  title: "Minimize",
1094
- children: /* @__PURE__ */ e(Ve, {})
1154
+ children: /* @__PURE__ */ t(vt, {})
1095
1155
  }
1096
1156
  ),
1097
- /* @__PURE__ */ e(
1157
+ /* @__PURE__ */ t(
1098
1158
  "button",
1099
1159
  {
1100
1160
  type: "button",
1101
1161
  className: "ll-hbtn ll-hbtn--danger",
1102
- onClick: V,
1103
- "aria-label": "End conversation",
1104
- title: "End conversation",
1105
- children: /* @__PURE__ */ e(je, {})
1162
+ onClick: Le,
1163
+ "aria-label": "End call",
1164
+ title: "End call",
1165
+ children: /* @__PURE__ */ t(gt, {})
1106
1166
  }
1107
1167
  )
1108
1168
  ] })
1109
1169
  ] }) : (
1110
1170
  // Idle-state header with Live Layer product name + minimize/close
1111
1171
  /* @__PURE__ */ _("div", { className: "ll-expanded__header ll-expanded__header--idle", children: [
1112
- /* @__PURE__ */ e("span", { className: "ll-expanded__brand", children: u }),
1172
+ /* @__PURE__ */ t("span", { className: "ll-expanded__brand", children: Ae }),
1113
1173
  /* @__PURE__ */ _("div", { className: "ll-expanded__header-actions", children: [
1114
- /* @__PURE__ */ e(
1174
+ /* @__PURE__ */ t(
1115
1175
  "button",
1116
1176
  {
1117
1177
  type: "button",
1118
1178
  className: "ll-hbtn ll-hbtn--ghost",
1119
- onClick: ie,
1179
+ onClick: he,
1120
1180
  "aria-label": "Minimize widget",
1121
- children: /* @__PURE__ */ e(Ve, {})
1181
+ children: /* @__PURE__ */ t(vt, {})
1122
1182
  }
1123
1183
  ),
1124
- /* @__PURE__ */ e(
1184
+ /* @__PURE__ */ t(
1125
1185
  "button",
1126
1186
  {
1127
1187
  type: "button",
1128
1188
  className: "ll-hbtn ll-hbtn--danger",
1129
- onClick: V,
1189
+ onClick: Le,
1130
1190
  "aria-label": "Close widget",
1131
- children: /* @__PURE__ */ e(je, {})
1191
+ children: /* @__PURE__ */ t(gt, {})
1132
1192
  }
1133
1193
  )
1134
1194
  ] })
1135
1195
  ] })
1136
1196
  ),
1137
- he && /* @__PURE__ */ _(
1138
- "button",
1139
- {
1140
- type: "button",
1141
- className: "ll-expanded__play",
1142
- onClick: ge,
1143
- "aria-label": R ? "Resume session" : "Start video call",
1144
- children: [
1145
- /* @__PURE__ */ e("div", { className: "ll-expanded__play-circle", children: /* @__PURE__ */ e("svg", { width: "22", height: "22", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": !0, children: /* @__PURE__ */ e("polygon", { points: "6 3 20 12 6 21 6 3" }) }) }),
1146
- /* @__PURE__ */ e("span", { className: "ll-expanded__play-label", children: R ? "Restart session" : "Start video call" }),
1147
- R && /* @__PURE__ */ e("span", { className: "ll-expanded__play-sublabel", children: "Pick up where you left off" })
1148
- ]
1149
- }
1150
- ),
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__ */ _(
1201
+ "button",
1202
+ {
1203
+ type: "button",
1204
+ className: "ll-expanded__play",
1205
+ onClick: ee,
1206
+ "aria-label": h,
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 })
1210
+ ]
1211
+ }
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(
1217
+ "button",
1218
+ {
1219
+ type: "button",
1220
+ className: "ll-expanded__cta",
1221
+ onClick: ee,
1222
+ "aria-label": h,
1223
+ children: h
1224
+ }
1225
+ )
1226
+ ] })
1227
+ ] });
1228
+ })(),
1151
1229
  /* @__PURE__ */ _(
1152
1230
  "div",
1153
1231
  {
1154
- className: `ll-expanded__pip ${le && (y || $) ? "is-visible" : ""}`,
1232
+ className: `ll-expanded__pip ${te && (w || K) ? "is-visible" : ""}`,
1155
1233
  children: [
1156
- /* @__PURE__ */ e(
1234
+ /* @__PURE__ */ t(
1157
1235
  "div",
1158
1236
  {
1159
- ref: oe,
1160
- className: $ ? "ll-expanded__pip-host" : "ll-expanded__pip-host is-hidden"
1237
+ ref: fe,
1238
+ className: K ? "ll-expanded__pip-host" : "ll-expanded__pip-host is-hidden"
1161
1239
  }
1162
1240
  ),
1163
- /* @__PURE__ */ e(
1241
+ /* @__PURE__ */ t(
1164
1242
  "div",
1165
1243
  {
1166
- ref: pe,
1167
- className: !$ && y ? "ll-expanded__pip-host" : "ll-expanded__pip-host is-hidden"
1244
+ ref: ne,
1245
+ className: !K && w ? "ll-expanded__pip-host" : "ll-expanded__pip-host is-hidden"
1168
1246
  }
1169
1247
  )
1170
1248
  ]
1171
1249
  }
1172
1250
  ),
1173
- le ? /* @__PURE__ */ _("div", { className: "ll-expanded__bottom", children: [
1174
- me && /* @__PURE__ */ e("div", { className: "ll-expanded__transcript", children: /* @__PURE__ */ e("p", { className: "ll-expanded__transcript-text", children: me }) }),
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 }) }),
1175
1253
  /* @__PURE__ */ _("div", { className: "ll-toolbar", onClick: (h) => h.stopPropagation(), children: [
1176
- P && /* @__PURE__ */ e(
1254
+ oe && /* @__PURE__ */ t(
1177
1255
  "button",
1178
1256
  {
1179
1257
  type: "button",
1180
- className: `ll-tool ${$ ? "is-on" : ""}`,
1181
- onClick: Z,
1182
- "aria-label": $ ? "Stop sharing screen" : "Share screen",
1183
- title: $ ? "Stop sharing" : "Share screen",
1184
- children: /* @__PURE__ */ e(Dt, {})
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, {})
1185
1263
  }
1186
1264
  ),
1187
- re && /* @__PURE__ */ _("div", { className: "ll-tool-split", children: [
1188
- /* @__PURE__ */ e(
1265
+ Ne && /* @__PURE__ */ _("div", { className: "ll-tool-split", children: [
1266
+ /* @__PURE__ */ t(
1189
1267
  "button",
1190
1268
  {
1191
1269
  type: "button",
1192
- className: `ll-tool ll-tool--left ${y ? "is-on" : ""}`,
1193
- onClick: U,
1194
- "aria-label": y ? "Turn off camera" : "Turn on camera",
1195
- title: y ? "Stop camera" : "Start camera",
1196
- children: /* @__PURE__ */ e(Rt, {})
1270
+ className: `ll-tool ll-tool--left ${w ? "is-on" : ""}`,
1271
+ onClick: Be,
1272
+ "aria-label": w ? "Turn off camera" : "Turn on camera",
1273
+ title: w ? "Stop camera" : "Start camera",
1274
+ children: /* @__PURE__ */ t(Nn, {})
1197
1275
  }
1198
1276
  ),
1199
- /* @__PURE__ */ e(
1277
+ /* @__PURE__ */ t(
1200
1278
  "button",
1201
1279
  {
1202
1280
  type: "button",
1203
- className: `ll-tool ll-tool--right ${y ? "is-on" : ""}`,
1281
+ className: `ll-tool ll-tool--right ${w ? "is-on" : ""}`,
1204
1282
  onClick: (h) => {
1205
- h.stopPropagation(), J((W) => !W), ae(!1);
1283
+ h.stopPropagation(), Q((O) => !O), F(!1);
1206
1284
  },
1207
1285
  "aria-label": "Camera devices",
1208
1286
  "aria-haspopup": "listbox",
1209
- "aria-expanded": se,
1210
- children: /* @__PURE__ */ e(_e, {})
1287
+ "aria-expanded": q,
1288
+ children: /* @__PURE__ */ t(Te, {})
1211
1289
  }
1212
1290
  ),
1213
- se && X.length > 0 && /* @__PURE__ */ e(
1214
- Oe,
1291
+ q && Ee.length > 0 && /* @__PURE__ */ t(
1292
+ yt,
1215
1293
  {
1216
1294
  label: "Camera",
1217
- devices: X,
1218
- activeId: ne,
1295
+ devices: Ee,
1296
+ activeId: $e,
1219
1297
  onPick: (h) => {
1220
- J(!1), ve(h);
1298
+ Q(!1), Ue(h);
1221
1299
  }
1222
1300
  }
1223
1301
  )
1224
1302
  ] }),
1225
1303
  /* @__PURE__ */ _("div", { className: "ll-tool-split", children: [
1226
- /* @__PURE__ */ e(
1304
+ /* @__PURE__ */ t(
1227
1305
  "button",
1228
1306
  {
1229
1307
  type: "button",
1230
- className: `ll-tool ll-tool--left ${I ? "is-muted" : ""}`,
1231
- onClick: Q,
1232
- "aria-label": I ? "Unmute microphone" : "Mute microphone",
1233
- title: I ? "Unmute" : "Mute",
1234
- children: /* @__PURE__ */ e(Tt, { muted: I })
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 })
1235
1313
  }
1236
1314
  ),
1237
- /* @__PURE__ */ e(
1315
+ /* @__PURE__ */ t(
1238
1316
  "button",
1239
1317
  {
1240
1318
  type: "button",
1241
- className: `ll-tool ll-tool--right ${I ? "is-muted" : ""}`,
1319
+ className: `ll-tool ll-tool--right ${R ? "is-muted" : ""}`,
1242
1320
  onClick: (h) => {
1243
- h.stopPropagation(), ae((W) => !W), J(!1);
1321
+ h.stopPropagation(), F((O) => !O), Q(!1);
1244
1322
  },
1245
1323
  "aria-label": "Microphone devices",
1246
1324
  "aria-haspopup": "listbox",
1247
- "aria-expanded": q,
1248
- children: /* @__PURE__ */ e(_e, {})
1325
+ "aria-expanded": j,
1326
+ children: /* @__PURE__ */ t(Te, {})
1249
1327
  }
1250
1328
  ),
1251
- q && x.length > 0 && /* @__PURE__ */ e(
1252
- Oe,
1329
+ j && L.length > 0 && /* @__PURE__ */ t(
1330
+ yt,
1253
1331
  {
1254
1332
  label: "Microphone",
1255
- devices: x,
1333
+ devices: L,
1256
1334
  activeId: "",
1257
- onPick: () => ae(!1)
1335
+ onPick: () => F(!1)
1258
1336
  }
1259
1337
  )
1260
1338
  ] }),
1261
- /* @__PURE__ */ e(
1339
+ /* @__PURE__ */ t(
1262
1340
  "button",
1263
1341
  {
1264
1342
  type: "button",
1265
- className: `ll-tool ${F ? "is-muted" : ""}`,
1266
- onClick: G,
1267
- "aria-label": F ? "Unmute speaker" : "Mute speaker",
1268
- title: F ? "Unmute speaker" : "Mute speaker",
1269
- children: /* @__PURE__ */ e(zt, { muted: F })
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 })
1270
1348
  }
1271
1349
  )
1272
1350
  ] }),
1273
- be && /* @__PURE__ */ _("form", { className: "ll-message-input", onSubmit: B, children: [
1274
- /* @__PURE__ */ e(
1351
+ le && /* @__PURE__ */ _("form", { className: "ll-message-input", onSubmit: we, children: [
1352
+ /* @__PURE__ */ t(
1275
1353
  "input",
1276
1354
  {
1277
1355
  type: "text",
1278
1356
  className: "ll-message-input__field",
1279
1357
  placeholder: "Message...",
1280
- value: ce,
1281
- onChange: (h) => de(h.target.value),
1358
+ value: pe,
1359
+ onChange: (h) => me(h.target.value),
1282
1360
  "aria-label": "Message the agent"
1283
1361
  }
1284
1362
  ),
1285
- ce.trim() && /* @__PURE__ */ e(
1363
+ pe.trim() && /* @__PURE__ */ t(
1286
1364
  "button",
1287
1365
  {
1288
1366
  type: "submit",
1289
1367
  className: "ll-message-input__send",
1290
1368
  "aria-label": "Send message",
1291
- children: /* @__PURE__ */ e(Pt, {})
1369
+ children: /* @__PURE__ */ t(An, {})
1292
1370
  }
1293
1371
  )
1294
1372
  ] }),
1295
- /* @__PURE__ */ e(
1373
+ /* @__PURE__ */ t(
1296
1374
  "button",
1297
1375
  {
1298
1376
  type: "button",
1299
1377
  className: "ll-expanded__end",
1300
- onClick: ue,
1378
+ onClick: ce,
1301
1379
  children: "End conversation"
1302
1380
  }
1303
1381
  )
1304
- ] }) : (
1305
- // Idle-state footer: start button + greeting
1306
- s && /* @__PURE__ */ e("div", { className: "ll-expanded__bottom ll-expanded__bottom--idle", children: /* @__PURE__ */ e("div", { className: "ll-expanded__transcript", children: /* @__PURE__ */ e("p", { className: "ll-expanded__transcript-text", children: s }) }) })
1307
- ),
1382
+ ] }) : null,
1308
1383
  (() => {
1309
- if (w && N !== "error")
1384
+ if (k && E !== "error")
1310
1385
  return /* @__PURE__ */ _("div", { className: "ll-expanded__banner", role: "alert", children: [
1311
- /* @__PURE__ */ e("span", { children: w }),
1312
- /* @__PURE__ */ e(
1386
+ /* @__PURE__ */ t("span", { children: k }),
1387
+ /* @__PURE__ */ t(
1313
1388
  "button",
1314
1389
  {
1315
1390
  type: "button",
1316
1391
  className: "ll-expanded__banner-x",
1317
- onClick: K,
1392
+ onClick: He,
1318
1393
  "aria-label": "Dismiss",
1319
1394
  children: "×"
1320
1395
  }
1321
1396
  )
1322
1397
  ] });
1323
- if (!z || N !== "error") return null;
1324
- let h = "Failed to connect", W = "Try again";
1325
- return z === "MIC_PERMISSION_DENIED" ? h = "Microphone blocked. Allow access to talk." : z === "MIC_NOT_FOUND" ? h = "No microphone found. Plug one in + retry." : z === "MIC_UNAVAILABLE" ? h = "Mic unavailable. Check other apps using it." : z === "AGENT_TIMEOUT" ? h = "Agent didn't pick up. Try again." : z === "CONNECT_FAILED" ? h = "Connection failed. Check your network." : z.length < 80 && (h = z), /* @__PURE__ */ _("div", { className: "ll-expanded__banner ll-expanded__banner--error", role: "alert", children: [
1326
- /* @__PURE__ */ e("span", { children: h }),
1327
- /* @__PURE__ */ e(
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(
1328
1403
  "button",
1329
1404
  {
1330
1405
  type: "button",
1331
1406
  className: "ll-expanded__banner-retry",
1332
- onClick: ke,
1333
- children: W
1407
+ onClick: se,
1408
+ children: O
1334
1409
  }
1335
1410
  )
1336
1411
  ] });
@@ -1339,83 +1414,218 @@ const St = ({
1339
1414
  }
1340
1415
  );
1341
1416
  };
1342
- function _e() {
1343
- return /* @__PURE__ */ e("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", "aria-hidden": !0, children: /* @__PURE__ */ e("polyline", { points: "6 9 12 15 18 9" }) });
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" }) });
1344
1419
  }
1345
- function je() {
1420
+ function gt() {
1346
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: [
1347
- /* @__PURE__ */ e("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
1348
- /* @__PURE__ */ e("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1422
+ /* @__PURE__ */ t("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
1423
+ /* @__PURE__ */ t("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1349
1424
  ] });
1350
1425
  }
1351
- function Ve() {
1352
- return /* @__PURE__ */ e("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", "aria-hidden": !0, children: /* @__PURE__ */ e("line", { x1: "5", y1: "12", x2: "19", y2: "12" }) });
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" }) });
1353
1428
  }
1354
- function Dt() {
1429
+ function En() {
1355
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: [
1356
- /* @__PURE__ */ e("rect", { x: "2", y: "3", width: "20", height: "14", rx: "2" }),
1357
- /* @__PURE__ */ e("line", { x1: "8", y1: "21", x2: "16", y2: "21" }),
1358
- /* @__PURE__ */ e("line", { x1: "12", y1: "17", x2: "12", y2: "21" })
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" })
1359
1434
  ] });
1360
1435
  }
1361
- function Rt() {
1436
+ function Nn() {
1362
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: [
1363
- /* @__PURE__ */ e("path", { d: "M23 7l-7 5 7 5V7z" }),
1364
- /* @__PURE__ */ e("rect", { x: "1", y: "5", width: "15", height: "14", rx: "2" })
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" })
1365
1440
  ] });
1366
1441
  }
1367
- function Tt({ muted: t }) {
1442
+ function Sn({ muted: e }) {
1368
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: [
1369
- /* @__PURE__ */ e("path", { d: "M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z" }),
1370
- /* @__PURE__ */ e("path", { d: "M19 10v2a7 7 0 0 1-14 0v-2" }),
1371
- /* @__PURE__ */ e("line", { x1: "12", y1: "19", x2: "12", y2: "23" }),
1372
- t && /* @__PURE__ */ e("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
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" })
1373
1448
  ] });
1374
1449
  }
1375
- function zt({ muted: t }) {
1450
+ function Ln({ muted: e }) {
1376
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: [
1377
- /* @__PURE__ */ e("polygon", { points: "11 5 6 9 2 9 2 15 6 15 11 19 11 5" }),
1378
- t ? /* @__PURE__ */ e("line", { x1: "23", y1: "9", x2: "17", y2: "15" }) : /* @__PURE__ */ _(Ze, { children: [
1379
- /* @__PURE__ */ e("path", { d: "M19.07 4.93a10 10 0 0 1 0 14.14" }),
1380
- /* @__PURE__ */ e("path", { d: "M15.54 8.46a5 5 0 0 1 0 7.07" })
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" })
1381
1456
  ] })
1382
1457
  ] });
1383
1458
  }
1384
- function Pt() {
1459
+ function An() {
1385
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: [
1386
- /* @__PURE__ */ e("line", { x1: "5", y1: "12", x2: "19", y2: "12" }),
1387
- /* @__PURE__ */ e("polyline", { points: "12 5 19 12 12 19" })
1461
+ /* @__PURE__ */ t("line", { x1: "5", y1: "12", x2: "19", y2: "12" }),
1462
+ /* @__PURE__ */ t("polyline", { points: "12 5 19 12 12 19" })
1388
1463
  ] });
1389
1464
  }
1390
- const Oe = ({ label: t, devices: n, activeId: i, onPick: l }) => /* @__PURE__ */ _(
1465
+ const yt = ({ label: e, devices: n, activeId: r, onPick: i }) => /* @__PURE__ */ _(
1391
1466
  "div",
1392
1467
  {
1393
1468
  className: "ll-device-menu",
1394
- onClick: (r) => r.stopPropagation(),
1469
+ onClick: (o) => o.stopPropagation(),
1395
1470
  role: "listbox",
1396
1471
  children: [
1397
- /* @__PURE__ */ e("p", { className: "ll-device-menu__label", children: t }),
1398
- n.map((r, s) => {
1399
- const c = i === r.deviceId;
1472
+ /* @__PURE__ */ t("p", { className: "ll-device-menu__label", children: e }),
1473
+ n.map((o, l) => {
1474
+ const d = r === o.deviceId;
1400
1475
  return /* @__PURE__ */ _(
1401
1476
  "button",
1402
1477
  {
1403
1478
  type: "button",
1404
- className: `ll-device-menu__item ${c ? "is-active" : ""}`,
1405
- onClick: () => l(r.deviceId),
1479
+ className: `ll-device-menu__item ${d ? "is-active" : ""}`,
1480
+ onClick: () => i(o.deviceId),
1406
1481
  role: "option",
1407
- "aria-selected": c,
1482
+ "aria-selected": d,
1408
1483
  children: [
1409
- c && /* @__PURE__ */ e("span", { className: "ll-device-menu__dot", children: "●" }),
1410
- /* @__PURE__ */ e("span", { className: "ll-device-menu__name", children: r.label || `${t} ${s + 1}` })
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}` })
1411
1486
  ]
1412
1487
  },
1413
- r.deviceId || s
1488
+ o.deviceId || l
1414
1489
  );
1415
1490
  })
1416
1491
  ]
1417
1492
  }
1418
- ), Bt = /* @__PURE__ */ new Set([
1493
+ ), Pe = 4096, Mn = 20, Rn = 20, In = 10, bt = 500, Tn = [
1494
+ '[data-ll-private="true"]',
1495
+ ".ll-widget",
1496
+ "script",
1497
+ "style",
1498
+ "noscript",
1499
+ "iframe"
1500
+ ];
1501
+ function ke(e) {
1502
+ 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;
1508
+ }
1509
+ return !1;
1510
+ }
1511
+ function Ce(e) {
1512
+ if (typeof window > "u") return !0;
1513
+ const n = e.getBoundingClientRect();
1514
+ if (n.width <= 0 || n.height <= 0) return !1;
1515
+ 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;
1517
+ }
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)}"]`);
1527
+ if (l != null && l.textContent) return l.textContent.trim();
1528
+ }
1529
+ const r = e.getAttribute("aria-label");
1530
+ if (r) return r.trim();
1531
+ const i = e.getAttribute("placeholder");
1532
+ if (i) return i.trim();
1533
+ const o = e.closest("label");
1534
+ return o != null && o.textContent ? o.textContent.trim() : "";
1535
+ }
1536
+ function ve(e, n) {
1537
+ return e.length <= n ? e : e.slice(0, n - 1) + "…";
1538
+ }
1539
+ function ye(e) {
1540
+ return e.length;
1541
+ }
1542
+ function zn(e, n = {}) {
1543
+ const r = n.doc ?? (typeof document < "u" ? document : null);
1544
+ if (!r)
1545
+ return {
1546
+ url: "",
1547
+ title: "",
1548
+ pathname: "/",
1549
+ regions: [],
1550
+ visibleText: "",
1551
+ visibleLinks: [],
1552
+ visibleFields: [],
1553
+ extras: e
1554
+ };
1555
+ const i = typeof window < "u" && window.location.href || "", o = typeof window < "u" && window.location.pathname || "/", l = r.title || "", d = Array.from(
1556
+ 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
1564
+ );
1565
+ !N || !k || u.push({ id: N, intent: R, text: k });
1566
+ }
1567
+ const s = [], g = ["H1", "H2", "H3", "H4", "H5", "H6"], f = Array.from(
1568
+ r.querySelectorAll("h1, h2, h3, h4, h5, h6")
1569
+ );
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)}`);
1574
+ }
1575
+ 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));
1580
+ }
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) });
1588
+ }
1589
+ const E = [], P = Array.from(
1590
+ r.querySelectorAll(
1591
+ "input, textarea, select"
1592
+ )
1593
+ );
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 });
1599
+ }
1600
+ const b = {
1601
+ url: i,
1602
+ title: l,
1603
+ pathname: o,
1604
+ regions: u,
1605
+ visibleText: c,
1606
+ visibleLinks: S,
1607
+ visibleFields: E,
1608
+ extras: e
1609
+ };
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;
1616
+ }
1617
+ let be = null;
1618
+ function wt(e, n = {}) {
1619
+ 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;
1624
+ }
1625
+ function $n() {
1626
+ be = null;
1627
+ }
1628
+ const Bn = /* @__PURE__ */ new Set([
1419
1629
  "agent_state",
1420
1630
  "avatar_stream_ready",
1421
1631
  "avatar_active",
@@ -1423,89 +1633,235 @@ const Oe = ({ label: t, devices: n, activeId: i, onPick: l }) => /* @__PURE__ */
1423
1633
  "bot_ready",
1424
1634
  "agent_error",
1425
1635
  "idle_warning",
1426
- "idle_timeout"
1636
+ "idle_timeout",
1637
+ // 0.3.0 — page-aware commands. Handled internally by the widget.
1638
+ // Consumers who want observability subscribe via onAgentEvent (which
1639
+ // fires for every message including these).
1640
+ "navigate",
1641
+ "scroll_to",
1642
+ "request_page_context"
1427
1643
  ]);
1428
- function Ut(t) {
1429
- var Ie, Ae, De, Re, Te, ze;
1644
+ function Un(e) {
1645
+ var tt, nt, rt, it, ot, lt;
1430
1646
  const {
1431
1647
  agentId: n,
1432
- apiKey: i,
1433
- baseUrl: l = "https://app.livelayer.studio",
1434
- sessionEndpoint: r,
1435
- sessionBody: s,
1436
- autoConnect: c = !1,
1437
- displayMode: m,
1438
- defaultDisplayMode: d = "expanded",
1439
- onDisplayModeChange: f,
1440
- position: p = "bottom-right",
1441
- mobileBreakpoint: o = 640,
1442
- persistKey: a = "ll-widget",
1443
- disablePersistence: C = !1,
1444
- teamMembers: b,
1445
- currentTeamMemberId: N,
1446
- onTeamMemberChange: D,
1447
- idleLoopUrl: E,
1448
- greeting: R,
1449
- avatarImageUrl: T,
1450
- agentName: z,
1451
- branding: I = {},
1452
- allowCamera: w = !0,
1453
- allowScreenShare: x = !0,
1454
- allowTyping: y = !0,
1455
- onConnect: A,
1456
- onDisconnect: X,
1457
- onTranscript: ne,
1458
- onAgentState: $,
1459
- onConnectionStateChange: j,
1460
- onAgentEvent: F,
1461
- onAgentCommand: re,
1462
- controlledSession: P,
1463
- className: be,
1464
- style: we,
1465
- zIndex: ge = 2147483647
1466
- } = t, ue = N !== void 0, [ke, xe] = k(() => {
1648
+ apiKey: r,
1649
+ baseUrl: i = "https://app.livelayer.studio",
1650
+ sessionEndpoint: o,
1651
+ sessionBody: l,
1652
+ autoConnect: d = !1,
1653
+ displayMode: u,
1654
+ defaultDisplayMode: s = "expanded",
1655
+ onDisplayModeChange: g,
1656
+ position: f = "bottom-right",
1657
+ mobileBreakpoint: a = 640,
1658
+ 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,
1670
+ 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);
1690
+ I(() => {
1691
+ $n();
1692
+ }, [Se]);
1693
+ const he = E !== void 0, [Le, He] = C(() => {
1467
1694
  var v;
1468
- return N ?? ((v = b == null ? void 0 : b[0]) == null ? void 0 : v.id);
1469
- }), Q = ue ? N : ke, U = Se(
1470
- () => (b == null ? void 0 : b.find((v) => v.id === Q)) ?? null,
1471
- [b, Q]
1472
- ), ve = (U == null ? void 0 : U.agentId) ?? n, [Z, G] = yt({
1473
- value: m,
1474
- defaultValue: d,
1475
- onChange: f,
1476
- persistKey: a,
1477
- disablePersistence: C
1478
- }), ee = bt(o), ie = ot(), V = at(), K = ct(), O = dt(), Y = ut(), [le, H] = k(!1), [he, pe] = k(!1), [oe, q] = k(!1), [ae, se] = k(!1), [J, ce] = k(!1), de = g(
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,
1702
+ onChange: g,
1703
+ 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(
1479
1708
  (v) => {
1709
+ var G;
1480
1710
  const M = v;
1481
- !M.type || typeof M.type != "string" || (F == null || F({ eventName: M.type, data: v }), Bt.has(M.type) || re == null || re(M));
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) {
1715
+ console.warn(
1716
+ `[LiveLayer] Agent emitted "navigate" without href. Skipping. Check your agent's tool schema. See https://livelayer.studio/docs/errors/navigate-missing-href`
1717
+ );
1718
+ return;
1719
+ }
1720
+ if (je.current) {
1721
+ try {
1722
+ je.current(H);
1723
+ } catch (U) {
1724
+ console.warn(
1725
+ `[LiveLayer] onNavigate threw for "${H}". Falling back. Error:`,
1726
+ U
1727
+ );
1728
+ }
1729
+ return;
1730
+ }
1731
+ if (typeof document < "u") {
1732
+ const U = document.querySelector(
1733
+ `a[href="${H.replace(/"/g, '\\"')}"]`
1734
+ );
1735
+ if (U) {
1736
+ U.click();
1737
+ return;
1738
+ }
1739
+ }
1740
+ if (typeof window < "u" && typeof history < "u")
1741
+ try {
1742
+ history.pushState({}, "", H), window.dispatchEvent(new PopStateEvent("popstate"));
1743
+ } catch (U) {
1744
+ 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
1747
+ );
1748
+ }
1749
+ return;
1750
+ }
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) {
1756
+ try {
1757
+ Fe.current(
1758
+ H,
1759
+ U
1760
+ );
1761
+ } catch (Y) {
1762
+ console.warn("[LiveLayer] onScrollToSelector threw.", Y);
1763
+ }
1764
+ return;
1765
+ }
1766
+ if (typeof document < "u") {
1767
+ let Y = null;
1768
+ try {
1769
+ Y = document.querySelector(H);
1770
+ } catch {
1771
+ console.warn(
1772
+ `[LiveLayer] scroll_to: invalid selector "${H}".`
1773
+ );
1774
+ return;
1775
+ }
1776
+ if (!Y) {
1777
+ 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`
1779
+ );
1780
+ return;
1781
+ }
1782
+ Y.scrollIntoView({
1783
+ behavior: U,
1784
+ block: "start"
1785
+ });
1786
+ }
1787
+ return;
1788
+ }
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)
1793
+ 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);
1798
+ }
1799
+ }, Y = Xe.current, at = Ke.current;
1800
+ 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) => {
1805
+ console.warn(
1806
+ "[LiveLayer] getPageContext rejected; falling back to default walker.",
1807
+ ie
1808
+ ), U({
1809
+ type: "page_context",
1810
+ context: wt(Y)
1811
+ });
1812
+ });
1813
+ return;
1814
+ }
1815
+ U({ type: "page_context", context: re });
1816
+ return;
1817
+ }
1818
+ U({
1819
+ type: "page_context",
1820
+ context: wt(Y)
1821
+ });
1822
+ } catch (re) {
1823
+ console.warn(
1824
+ "[LiveLayer] page-context extraction threw. Sending empty context.",
1825
+ re
1826
+ ), U({
1827
+ type: "page_context",
1828
+ context: { url: "", title: "", pathname: "/", regions: [], visibleText: "", visibleLinks: [], visibleFields: [], extras: Y }
1829
+ });
1830
+ }
1831
+ return;
1832
+ }
1833
+ Bn.has(M.type) || de == null || de(M);
1834
+ }
1482
1835
  },
1483
- [re, F]
1484
- ), B = lt({
1485
- agentId: P ? "__controlled__" : ve,
1486
- baseUrl: l,
1487
- apiKey: i,
1488
- sessionEndpoint: r,
1489
- sessionBody: s,
1490
- onDataMessage: P ? void 0 : de
1836
+ [de, se]
1837
+ ), B = jt({
1838
+ agentId: D ? "__controlled__" : te,
1839
+ baseUrl: i,
1840
+ apiKey: r,
1841
+ sessionEndpoint: o,
1842
+ sessionBody: l,
1843
+ onDataMessage: D ? void 0 : Ve
1491
1844
  });
1492
- S(() => {
1493
- if (P != null && P.subscribeToDataMessages)
1494
- return P.subscribeToDataMessages(de);
1495
- }, [P, de]);
1496
- const u = Se(() => P ? {
1497
- connectionState: P.connectionState,
1498
- agentState: P.agentState,
1499
- transcript: P.transcript,
1500
- videoElement: P.videoElement,
1501
- audioElement: P.audioElement,
1502
- canResume: P.canResume,
1503
- error: P.error,
1845
+ I(() => {
1846
+ if (D != null && D.subscribeToDataMessages)
1847
+ return D.subscribeToDataMessages(Ve);
1848
+ }, [D, Ve]), Re.current = () => {
1849
+ var v;
1850
+ return (v = B.getRoom) == null ? void 0 : v.call(B);
1851
+ };
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,
1504
1860
  agentConfig: null,
1505
1861
  connect: async () => {
1506
- await P.onConnect();
1862
+ await D.onConnect();
1507
1863
  },
1508
- disconnect: () => P.onDisconnect(),
1864
+ disconnect: () => D.onDisconnect(),
1509
1865
  // Dummy getRoom for shape compatibility — controlled consumers own the Room.
1510
1866
  // Internal session's getRoom returns null when no real connect has happened,
1511
1867
  // so we reuse its reference for type consistency.
@@ -1524,254 +1880,276 @@ function Ut(t) {
1524
1880
  disconnect: B.disconnect,
1525
1881
  getRoom: B.getRoom,
1526
1882
  isControlled: !1
1527
- }, [P, B]), me = L(null);
1528
- S(() => {
1529
- const v = u.videoElement, M = me.current;
1883
+ }, [D, B]), Je = A(null);
1884
+ I(() => {
1885
+ const v = m.videoElement, M = Je.current;
1530
1886
  if (!(!v || !M))
1531
1887
  return M.appendChild(v), () => {
1532
1888
  v.parentNode === M && M.removeChild(v);
1533
1889
  };
1534
- }, [u.videoElement]), S(() => {
1535
- const v = u.audioElement;
1890
+ }, [m.videoElement]), I(() => {
1891
+ const v = m.audioElement;
1536
1892
  if (!v) return;
1537
- ie.attach(v);
1893
+ fe.attach(v);
1538
1894
  const M = v.play();
1539
- return M && typeof M.catch == "function" && M.catch((te) => {
1540
- (te == null ? void 0 : te.name) === "NotAllowedError" && H(!0);
1895
+ return M && typeof M.catch == "function" && M.catch((G) => {
1896
+ (G == null ? void 0 : G.name) === "NotAllowedError" && me(!0);
1541
1897
  }), () => {
1542
- ie.detach();
1898
+ fe.detach();
1543
1899
  };
1544
- }, [u.audioElement]), S(() => {
1545
- if (u.isControlled || u.connectionState !== "connected") return;
1546
- const v = u.getRoom();
1900
+ }, [m.audioElement]), I(() => {
1901
+ if (m.isControlled || m.connectionState !== "connected") return;
1902
+ const v = m.getRoom();
1547
1903
  if (v)
1548
- return V.setupMic(v).catch(() => {
1549
- }), K.attachRoom(v), O.attachRoom(v), Y.refresh(), () => {
1550
- V.teardownMic(), K.teardown(), O.teardown();
1904
+ return j.setupMic(v).catch(() => {
1905
+ }), F.attachRoom(v), q.attachRoom(v), Q.refresh(), () => {
1906
+ j.teardownMic(), F.teardown(), q.teardown();
1551
1907
  };
1552
- }, [u.isControlled, u.connectionState]), S(() => {
1553
- const v = u.audioElement;
1554
- v && (v.muted = J);
1555
- }, [u.audioElement, J]);
1556
- const Ce = g((v) => {
1557
- const M = u.getRoom();
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();
1558
1914
  if (M)
1559
1915
  try {
1560
- const te = new TextEncoder().encode(
1916
+ const G = new TextEncoder().encode(
1561
1917
  JSON.stringify({ type: "user_message", text: v })
1562
1918
  );
1563
- M.localParticipant.publishData(te, { reliable: !0 });
1919
+ M.localParticipant.publishData(G, { reliable: !0 });
1564
1920
  } catch {
1565
1921
  }
1566
- }, [u]), ye = g(() => {
1567
- ce((v) => !v);
1922
+ }, [m]), Et = y(() => {
1923
+ Ye((v) => !v);
1568
1924
  }, []);
1569
- S(() => {
1570
- j == null || j(u.connectionState), u.connectionState === "connected" ? A == null || A() : u.connectionState === "disconnected" && (X == null || X());
1571
- }, [u.connectionState, A, X, j]), S(() => {
1572
- ne == null || ne(u.transcript);
1573
- }, [u.transcript, ne]), S(() => {
1574
- $ == null || $(u.agentState);
1575
- }, [u.agentState, $]);
1576
- const h = L(!1);
1577
- S(() => {
1578
- u.isControlled || !c || h.current || u.connectionState === "idle" && (h.current = !0, u.connect());
1579
- }, [c, u.connectionState, u]);
1580
- const W = g(
1925
+ 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);
1933
+ 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(
1581
1937
  (v) => {
1582
- const M = b == null ? void 0 : b.find((te) => te.id === v);
1583
- M && (q(!1), v !== Q && (pe(!0), u.disconnect(), ue || xe(v), D == null || D(M)));
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)));
1584
1940
  },
1585
1941
  [
1586
- b,
1587
- Q,
1588
- u,
1589
- ue,
1590
- D
1942
+ x,
1943
+ V,
1944
+ m,
1945
+ he,
1946
+ P
1591
1947
  ]
1592
1948
  );
1593
- S(() => {
1594
- he && u.connectionState === "connected" && pe(!1);
1595
- }, [u.connectionState, he]), S(() => {
1596
- if (!oe) return;
1949
+ I(() => {
1950
+ we && m.connectionState === "connected" && Ae(!1);
1951
+ }, [m.connectionState, we]), I(() => {
1952
+ if (!ge) return;
1597
1953
  const v = (M) => {
1598
- M.key === "Escape" && q(!1);
1954
+ M.key === "Escape" && _e(!1);
1599
1955
  };
1600
1956
  return window.addEventListener("keydown", v), () => window.removeEventListener("keydown", v);
1601
- }, [oe]);
1602
- const Ge = !!T || !!(U != null && U.avatarImageUrl) || u.isControlled, Ne = ht(ve, l, Ge), Ee = (U == null ? void 0 : U.name) ?? z ?? ((Ie = u.agentConfig) == null ? void 0 : Ie.name) ?? ((Ae = Ne.info) == null ? void 0 : Ae.name) ?? "Live Layer", Le = (U == null ? void 0 : U.avatarImageUrl) ?? T ?? ((De = u.agentConfig) == null ? void 0 : De.avatarImageUrl) ?? ((Re = Ne.info) == null ? void 0 : Re.avatarImageUrl) ?? null, Ke = E ?? ((Te = u.agentConfig) == null ? void 0 : Te.idleLoopUrl) ?? ((ze = Ne.info) == null ? void 0 : ze.idleLoopUrl) ?? null, Ye = R ?? null, He = g(() => G("expanded"), [G]), qe = g(
1603
- () => G("minimized"),
1604
- [G]
1605
- ), Me = g(() => {
1606
- u.disconnect(), G("hidden");
1607
- }, [u, G]), Je = g(() => {
1608
- const v = u.audioElement;
1609
- v && v.play().then(() => H(!1)).catch(() => {
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(() => {
1610
1966
  });
1611
- }, [u.audioElement]), Xe = g(() => {
1612
- H(!1), u.connect();
1613
- }, [u]), fe = {
1614
- ...we,
1615
- zIndex: ge
1967
+ }, [m.audioElement]), Tt = y(() => {
1968
+ me(!1), m.connect();
1969
+ }, [m]), xe = {
1970
+ ...Ue,
1971
+ zIndex: Oe
1616
1972
  };
1617
- I.primaryColor && (fe["--ll-color-primary"] = I.primaryColor), I.accentColor && (fe["--ll-color-accent"] = I.accentColor), I.backgroundColor && (fe["--ll-color-bg"] = I.backgroundColor), I.textColor && (fe["--ll-color-fg"] = I.textColor);
1618
- const Qe = [
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 = [
1619
1975
  "ll-widget",
1620
- `ll-widget--${Z}`,
1621
- `ll-widget--${ee ? "mobile" : "desktop"}`,
1622
- be
1976
+ `ll-widget--${W}`,
1977
+ `ll-widget--${ne ? "mobile" : "desktop"}`,
1978
+ Be
1623
1979
  ].filter(Boolean).join(" ");
1624
- return /* @__PURE__ */ _(
1980
+ return ue ? /* @__PURE__ */ _(
1625
1981
  "div",
1626
1982
  {
1627
- className: Qe,
1628
- style: fe,
1629
- "data-display-mode": Z,
1630
- "data-position": p,
1983
+ className: Pt,
1984
+ style: xe,
1985
+ "data-display-mode": W,
1986
+ "data-position": f,
1631
1987
  children: [
1632
- Z === "hidden" && /* @__PURE__ */ e(
1633
- St,
1988
+ W === "hidden" && /* @__PURE__ */ t(
1989
+ wn,
1634
1990
  {
1635
- position: p,
1636
- isMobile: ee,
1637
- isSpeaking: u.agentState === "speaking",
1638
- onExpand: () => G("expanded"),
1639
- label: `Open ${Ee} widget`
1991
+ position: f,
1992
+ isMobile: ne,
1993
+ isSpeaking: m.agentState === "speaking",
1994
+ onExpand: () => J("expanded"),
1995
+ label: `Open ${qe} widget`
1640
1996
  }
1641
1997
  ),
1642
- Z === "minimized" && /* @__PURE__ */ e(
1643
- Mt,
1998
+ W === "minimized" && /* @__PURE__ */ t(
1999
+ xn,
1644
2000
  {
1645
- position: p,
1646
- isMobile: ee,
1647
- agentName: Ee,
1648
- avatarImageUrl: Le,
1649
- agentState: u.agentState,
1650
- isMuted: V.isMuted,
1651
- audioLevel: ie,
1652
- onExpand: He,
1653
- onToggleMute: V.toggleMute,
1654
- onClose: Me
2001
+ position: f,
2002
+ 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
1655
2011
  }
1656
2012
  ),
1657
- Z === "expanded" && /* @__PURE__ */ e(
1658
- At,
2013
+ W === "expanded" && /* @__PURE__ */ t(
2014
+ Cn,
1659
2015
  {
1660
- position: p,
1661
- isMobile: ee,
1662
- agentName: Ee,
1663
- avatarImageUrl: Le,
1664
- idleLoopUrl: Ke,
1665
- greeting: Ye,
1666
- branding: I,
1667
- teamMembers: b,
1668
- currentTeamMemberId: Q,
1669
- isSwitchingTeamMember: he,
1670
- teamSwitcherOpen: oe,
1671
- onToggleTeamSwitcher: () => q((v) => !v),
1672
- onSelectTeamMember: W,
1673
- connectionState: u.connectionState,
1674
- agentState: u.agentState,
1675
- transcript: u.transcript,
1676
- isMuted: V.isMuted,
1677
- micDevices: Y.mics,
1678
- isCameraEnabled: K.isEnabled,
1679
- cameraPreviewEl: K.previewEl,
1680
- cameraDevices: Y.cameras,
1681
- activeCameraId: K.activeDeviceId,
1682
- isScreenShareEnabled: O.isEnabled,
1683
- screenPreviewEl: O.previewEl,
1684
- isSpeakerMuted: J,
1685
- allowCamera: w,
1686
- allowScreenShare: x,
1687
- allowTyping: y,
1688
- languageMenuOpen: ae,
1689
- onToggleLanguageMenu: () => se((v) => !v),
1690
- needsUserGesture: le,
1691
- canResume: u.canResume,
1692
- micError: V.micError,
1693
- error: u.error,
1694
- avatarVideoContainerRef: me,
1695
- onConnect: () => void u.connect(),
1696
- onDisconnect: () => u.disconnect(),
1697
- onRetry: Xe,
1698
- onResumeAudio: Je,
1699
- onToggleMute: V.toggleMute,
1700
- onToggleCamera: () => void K.toggle(),
1701
- onSwitchCameraDevice: (v) => void K.switchDevice(v),
1702
- onToggleScreenShare: () => void O.toggle(),
1703
- onToggleSpeaker: ye,
1704
- onSendMessage: Ce,
1705
- onMinimize: qe,
1706
- onClose: Me,
1707
- onClearMicError: V.clearError
2016
+ position: f,
2017
+ 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,
2043
+ 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
1708
2064
  }
1709
2065
  )
1710
2066
  ]
1711
2067
  }
1712
- );
2068
+ ) : null;
1713
2069
  }
1714
- function Ft(t) {
1715
- return /* @__PURE__ */ e(it, { children: /* @__PURE__ */ e(Ut, { ...t }) });
2070
+ function Wn(e) {
2071
+ return /* @__PURE__ */ t(Ht, { children: /* @__PURE__ */ t(Un, { ...e }) });
1716
2072
  }
1717
- const Gt = ({
1718
- agentId: t,
2073
+ const qn = ({
2074
+ agentId: e,
1719
2075
  baseUrl: n,
1720
- apiKey: i,
1721
- mode: l,
1722
- onAgentEvent: r,
1723
- className: s,
1724
- style: c
2076
+ apiKey: r,
2077
+ mode: i,
2078
+ onAgentEvent: o,
2079
+ className: l,
2080
+ style: d
1725
2081
  }) => {
1726
- const m = L(null), d = L(null), f = L(r);
1727
- f.current = r;
1728
- const p = g((o) => {
1729
- var C;
1730
- const a = o.detail;
1731
- (C = f.current) == null || C.call(f, a);
2082
+ const u = A(null), s = A(null), g = A(o);
2083
+ g.current = o;
2084
+ const f = y((a) => {
2085
+ var S;
2086
+ const c = a.detail;
2087
+ (S = g.current) == null || S.call(g, c);
1732
2088
  }, []);
1733
- return S(() => {
1734
- const o = m.current;
1735
- if (!o) return;
1736
- const a = document.createElement("livelayer-widget");
1737
- return a.setAttribute("agent-id", t), n && a.setAttribute("base-url", n), i && a.setAttribute("api-key", i), l && a.setAttribute("mode", l), a.addEventListener("agent-event", p), o.appendChild(a), d.current = a, () => {
1738
- a.removeEventListener("agent-event", p), o.removeChild(a), d.current = null;
2089
+ return I(() => {
2090
+ const a = u.current;
2091
+ if (!a) return;
2092
+ 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;
1739
2095
  };
1740
- }, [t]), S(() => {
1741
- d.current && (l ? d.current.setAttribute("mode", l) : d.current.removeAttribute("mode"));
1742
- }, [l]), /* @__PURE__ */ e("div", { ref: m, className: s, style: c });
1743
- };
1744
- function Kt() {
1745
- const [t, n] = k([]), i = g((r) => {
1746
- n((s) => {
1747
- const c = s.findIndex((m) => m.id === r.id);
1748
- if (c >= 0) {
1749
- const m = s.slice();
1750
- return m[c] = r, m;
2096
+ }, [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(
2102
+ i,
2103
+ {
2104
+ ref: u,
2105
+ "data-ll-region": n,
2106
+ "data-ll-intent": r,
2107
+ className: o,
2108
+ style: l
2109
+ },
2110
+ d
2111
+ );
2112
+ }
2113
+ );
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;
1751
2121
  }
1752
- return [...s, r];
2122
+ return [...l, o];
1753
2123
  });
1754
- }, []), l = g(() => n([]), []);
2124
+ }, []), i = y(() => n([]), []);
1755
2125
  return {
1756
- entries: t,
1757
- pushSegment: i,
1758
- clear: l,
1759
- latest: t.length > 0 ? t[t.length - 1] : null
2126
+ entries: e,
2127
+ pushSegment: r,
2128
+ clear: i,
2129
+ latest: e.length > 0 ? e[e.length - 1] : null
1760
2130
  };
1761
2131
  }
1762
2132
  export {
1763
- Ft as AvatarWidget,
1764
- it as ErrorBoundary,
1765
- Gt as LiveLayerWidget,
1766
- ht as useAgentInfo,
1767
- ot as useAudioLevel,
1768
- ct as useCameraState,
1769
- ft as useDisplayMode,
1770
- yt as useDisplayModePersistence,
1771
- bt as useIsMobile,
1772
- lt as useLiveKitSession,
1773
- ut as useMediaDevices,
1774
- at as useMicrophoneState,
1775
- dt as useScreenShareState,
1776
- Kt as useTranscript
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
1777
2155
  };