@livelayer/react 0.2.0 → 0.2.2

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